FieldComponents
Your component for each field type, by type name: { text: TextInput, group: GroupFieldset }. Each one gets the props of its type's role.
ts
type FieldComponents = Record<
string,
| ComponentType<ValueFieldProps>
| ComponentType<GroupFieldProps>
| ComponentType<ArrayFieldProps>
| ComponentType<DisplayFieldProps>
>Explanation
See field components.
ValueFieldProps
ValueFieldPropsfieldJsonField: the field from the definitionpathFieldPath: its Formisch path, with real indexeskindValueKind: the kind of its valuerequiredboolean: whether the definition makes it requiredinputunknown: its current inputerrors[string, ...string[]] | null: its error messagesinputPropsFieldElementProps: Formisch's element props, to spread on the input elementsetInput(input: unknown) => void: sets the input, after turning what an element gives into the value of its kind
GroupFieldProps
GroupFieldPropsfieldJsonFieldpathFieldPathchildrenReactNode: the group's fields
ArrayFieldProps
ArrayFieldPropsfieldJsonFieldpathFieldPathitemsstring[]: one id per item, to use as itskeyerrors[string, ...string[]] | null: the list's own messagesadd() => void: adds an item at the endremove(index: number) => voidmove(from: number, to: number) => voidchildren(index: number) => ReactNode: renders the fields of the item atindex
DisplayFieldProps
DisplayFieldPropsfieldJsonField
Example
ts
import type { FieldComponents } from '@whatsaaaa/form-builder-react'
import { CheckboxInput } from './CheckboxInput'
import { GroupFieldset } from './GroupFieldset'
import { FileInput } from './FileInput'
import { FormHeading } from './FormHeading'
import { ListRepeater } from './ListRepeater'
import { SelectInput } from './SelectInput'
import { TextInput } from './TextInput'
export const components: FieldComponents = {
text: TextInput,
email: TextInput,
number: TextInput,
checkbox: CheckboxInput,
select: SelectInput,
radio: SelectInput,
file: FileInput,
group: GroupFieldset,
array: ListRepeater,
heading: FormHeading,
// ...one for every type your definitions use
}