Form / foldkit-form
foldkit-form
A form as a Foldkit Submodel: built from the input an operation accepts, holding
what the user is typing, and handing the parent a decoded value when it is
valid. It adds no state system. Field state is Foldkit core's
fieldValidation, and the form is a foldkit-bundle
Bundle the parent places like any other.
Status: headless. It owns the Model, Messages, validation, and a description of each control, and draws nothing.
foldkit-mixins-formdraws it through Mixins slots; or draw fromcontrolsyourself.
What it owns
| Fact | Owner |
|---|---|
| What may be submitted, and when it is valid | the input Schema.Struct |
| What each input key means (a field, a relation's id) | Entity.input |
| The draft in each control, and whether it has been checked | foldkit-form, in the parent's Model |
| What happens to a submitted value | the parent: a Remote mutation, a Sync operation, a plain update |
| Whether a submit is in flight, and its failure | whoever performs it; not the form |
| The options of a relation picker | the application; the form only names the target Entity |
Mental model
Schema.Struct (the operation's input)
+
Entity.input (what each key means)
|
v
Form.make ──► controls: key · control · label · required (draw these)
|
v
Bundle
Model: one fieldValidation Field per key, holding the draft
Changed / Blurred ──► validate the draft against the key's schema
Submitted ──► every key valid, input decoded ──► out Message { value }A draft is what the control holds, which is not the value it submits. A
number being typed is text ("4." is a fine thing to have typed), an unchosen
relation is "". The draft becomes a value only when it is checked.
Install
sh
pnpm add effect foldkit foldkit-bundle foldkit-entity foldkit-form