After a post the server refused: the summary, and each message beside its field
<div data-mount="errors"></div>
Held in React state, with an app's own kind and read-only fields
<div data-mount="held"></div>
API reference
FieldFromSpec
Prop
Type
Required
Does
spec
FieldSpec
Yes
value
unknown
onChange
(value: unknown) => void
error
ReactNode
idPrefix
string
The control's id is specId(key, idPrefix): "field-title" by default.
renderers
SpecRenderers
SchemaFields
Prop
Type
Required
Does
specs
readonly FieldSpec[]
Yes
values
Record<string, unknown>
onChange
(key: string, value: unknown) => void
Controlled: the key and its new value. Left out, the fields post by name.
errors
readonly SpecError[]
idPrefix
string
renderers
SpecRenderers
JsonField
Prop
Type
Required
Does
name
string
Yes
value
unknown
Yes
SettingsForm
Prop
Type
Required
Does
specs
readonly FieldSpec[]
Yes
values
Record<string, unknown>
errors
readonly SpecError[]
status
ReactNode
The result of the last save, said in the status region ("Settings saved.").
pending
boolean
submitLabel
string
pendingLabel
string
form
FormComponent | "form"
idPrefix
string
renderers
SpecRenderers
children
ReactNode
Hidden inputs (an intent) and anything else that posts with the fields.
And every attribute of <form>.
Functions
Function
Signature
Does
parseJsonField
<T = unknown>(raw: FormDataEntryValue | null | undefined, valid?: (value: unknown) => value is T): T | null
A JSON value posted in one field (a hidden input an editor fills), or null when it is missing, does not parse, or does not pass valid. Null, never a fallback: an action that saved [] for a broken field would erase what is stored.
One field's value from a post, and the message when it does not do. Values: a string (text, email, url, textarea, date, select, choice), string[] (lines, multi), number (number, money in cents), boolean (checkbox), Date (datetime), unknown (json), or undefined for an empty field. A kind it does not know is read as text.
Every field of a post by its spec: the values by key (an empty field is left out) and the errors in the form's order, for the error summary and the message beside each field.
specId
(key: string, prefix?: string): string
The control's id for a field key, so an error summary's link and a "needs info" link land on it.
Parts and data attributes
Class
Is
.cap-schema-actions
its own class
.cap-schema-cell
its own class
.cap-schema-fields
its own class
.cap-schema-form
the root
.cap-schema-json
its own class
.cap-schema-readonly
its own class
.cap-schema-status
its own class
Attribute
Values
data-wide
present or absent
Accessibility
Each field's own. Enter in a text field sends the form.
Each field is Capsomer's field part, with its label, help and error tied to the control; choices are fieldsets with a legend.