foldkit-form 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -86,8 +86,8 @@ const RenameForm = Page.at(Slot, {
|
|
|
86
86
|
```
|
|
87
87
|
|
|
88
88
|
- `Form.make` takes the name and an `Entity.input`. It resolves a control per
|
|
89
|
-
key and throws if it cannot
|
|
90
|
-
|
|
89
|
+
key and throws if it cannot. A view must also supply a renderer for each
|
|
90
|
+
control kind, including custom kinds.
|
|
91
91
|
- `Rename.bundle` is an ordinary Bundle. `onOut` is required, so a submit is
|
|
92
92
|
never dropped by omission.
|
|
93
93
|
- `Rename.Message` builds the form's Messages for your view to dispatch:
|
|
@@ -98,6 +98,30 @@ const RenameForm = Page.at(Slot, {
|
|
|
98
98
|
a view that walks `controls`; `model.rename.fields.title` is the same value
|
|
99
99
|
typed to its key.
|
|
100
100
|
|
|
101
|
+
### Run one edit through the parent
|
|
102
|
+
|
|
103
|
+
Continuing the example above, an assembly initializes the slice and routes its
|
|
104
|
+
wrapped Messages. This reducer-level example needs no renderer:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const placements = Page.assemble(RenameForm)
|
|
108
|
+
const update = placements.update(model => ({ model }))
|
|
109
|
+
let model = placements.initial({ saved: [] }).model
|
|
110
|
+
model = update(model, Message.GotRenameMessage({
|
|
111
|
+
message: Rename.Message.Changed({ key: 'title', value: 'Hello' }),
|
|
112
|
+
})).model
|
|
113
|
+
model = update(model, Message.GotRenameMessage({
|
|
114
|
+
message: Rename.Message.Submitted(),
|
|
115
|
+
})).model
|
|
116
|
+
// model.saved contains the decoded input, with title "Hello" and id "".
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Here a plain `Schema.String` allows the empty id. For editing a real row, fill
|
|
120
|
+
the form with that row's id first; add an input-schema constraint if an empty
|
|
121
|
+
id is invalid for your operation. `onOut` stores the value locally in this
|
|
122
|
+
example. It does not save to a server. Forms with asynchronous checks also need
|
|
123
|
+
the runtime to execute their returned Commands.
|
|
124
|
+
|
|
101
125
|
## Controls
|
|
102
126
|
|
|
103
127
|
A control is data: a `kind` (a name), the `draft` the Model holds while it is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Forms for Foldkit: a Bundle over core field validation, built from an operation's input and the Entity it writes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"LICENSE"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"foldkit-entity": "0.3.0",
|
|
41
42
|
"foldkit-bundle": "0.2.0",
|
|
42
|
-
"foldkit-metadata": "0.1.0"
|
|
43
|
-
"foldkit-entity": "0.2.0"
|
|
43
|
+
"foldkit-metadata": "0.1.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"effect": "^4.0.0-rc.112",
|