-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial documentation for the forms package and its patterns dire…
…ctory
- Loading branch information
1 parent
fd9fa10
commit 97a83b4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# @atj/forms | ||
|
||
This library includes all of the core business logic of the Forms Platform. | ||
|
||
- [./src/services](./src/services): The public interface of the Forms Platform is implemented here | ||
- [./src/patterns](./src/patterns/README.md): Form building blocks, aka "patterns" | ||
- [./src/repository](./src/repository): Database routines | ||
- [./src/documents](./src/documents): Document ingest and creation | ||
- [./src/context](./src/context): Runtime contexts for the platform (testing, in-browser, server-side) are defined here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Forms Platform - Patterns | ||
|
||
Patterns are the Forms Platform's primary building block, a reusable module that may be configured via the no-code form builder to craft custom user experiences. | ||
|
||
Patterns are stored on the form `Blueprint`'s pattern attribute. | ||
|
||
## Pattern configuration | ||
|
||
Each pattern must define a configuration object, which provides the definition of its behavior. | ||
|
||
The `PatternConfig` type is defined in [../pattern.ts](../pattern.ts). | ||
|
||
## Data structure | ||
|
||
Patterns are defined by the generic `Pattern<C>` type in `pattern.ts`. | ||
|
||
```typescript | ||
export type Pattern<C = any> = { | ||
type: string; // A string identifier for the pattern type | ||
id: PatternId; // A unique identifier for the pattern instance | ||
data: C; // The configuration data specific to the pattern type | ||
}; | ||
``` | ||
|
||
Constructing patterns may be accomplished manually, or via `PatternBuilder` helper classes. | ||
|
||
For example, an input pattern may be defined directly: | ||
|
||
```typescript | ||
const input: InputPattern = { | ||
type: 'input', | ||
id: 'my-input', | ||
data: { | ||
label: 'My input', | ||
initial: '', | ||
required: true, | ||
maxLength: 64 | ||
}, | ||
} | ||
``` | ||
|
||
```typescript | ||
const input = new InputPatternBuilder(); | ||
const page1 = new Page({ title: 'Page 1', patterns: [input1.id] }); | ||
const pageSet = new PageSet({ pages: [page1.id] }, 'page-set'); | ||
const page2 = new Page({ title: 'Page 2', patterns: [input1.id] }); | ||
pageSet.addPage(page2) | ||
|
||
// Construct the pattern objects | ||
page1.toPattern(); | ||
page2.toPattern(); | ||
pageSet.toPattern(); | ||
``` | ||
|