API Reference
Props for the two components and the helpers exported by form-builder-types. * marks required props.
FormRenderer
From @/components/ui/rjsf-form-builder/form-renderer/form-renderer.
| Prop | Type | Description |
|---|---|---|
schema* | FormSchema | The form definition to render. |
locale* | string | Active locale used to resolve LocalizedString values. |
baseLocale | string | Fallback locale when a string has no translation for locale. |
formData | Record<string, unknown> | Controlled form data. When omitted, the renderer keeps its own state. |
onChange | (data) => void | Called on every change. Values of fields hidden by a condition are left out. |
onSubmit | (data) => void | Called with valid data on submit. Hidden fields are left out here too. On multi-page forms, called from the last page after every page validates. |
onError | (errors) => void | Called when submit (or Next) fails validation. |
customValidate | CustomValidator | Extra RJSF validation, run after validators registered with registerValidator. Those run automatically and need no prop. |
theme | Partial<ThemeProps> | Override individual widgets, fields or templates. Define it outside the component or wrap it in useMemo: a new object on every render remounts the form. |
submitButton | ReactNode | Replaces the default submit button. On multi-page forms it is shown on the last page, next to Back. |
disabled | boolean | Disables every input and the submit button. |
className | string | Class name for the wrapper element. |
FormBuilder
From @/components/ui/rjsf-form-builder/form-builder/form-builder.
| Prop | Type | Description |
|---|---|---|
locale* | string | Locale used to display labels in the builder. |
baseLocale | string | Fallback locale for display. New field and option labels are created under it (or under locale if omitted). |
availableLocales | string[] | Locales shown as separate inputs when editing labels. Defaults to [locale]. |
initialSchema | FormSchema | Starting schema. Read once on mount. |
onChange | (schema: FormSchema) => void | Called with the updated schema after every edit. |
className | string | Class name for the builder container. Give it a height. |
Validation helpers
From @/lib/form-builder-types/validation.
| Function | Type | Description |
|---|---|---|
registerValidator | (key, fn) => void | Registers a named rule. fn(value, formData) returns an error message or undefined. Reference it from a field with validation.customRule. |
unregisterValidator | (key) => void | Removes a registered rule. |
createCustomValidator | (schema) => CustomValidator | Builds an RJSF validator that runs the registered rules for a schema. FormRenderer already does this. |
Schema helpers
From @/lib/form-builder-types/schema-builder, except localizeText, which is in @/lib/form-builder-types/i18n.
| Function | Type | Description |
|---|---|---|
toJsonSchema | (schema, locale, baseLocale?) => RJSFSchema | Converts a FormSchema to JSON Schema, for using RJSF or a server-side validator directly. |
toUiSchema | (schema, locale, baseLocale?) => UiSchema | Builds the matching RJSF uiSchema. |
fieldKey | (field) => string | The property name a field's value is stored under: key, or id if there is no key. |
splitIntoPages | (fields) => FormPage[] | Splits fields at each pagebreak. Each page has fields and the break's title/description. Empty pages are dropped. |
evaluateCondition | (condition, data) => boolean | Evaluates a single field condition. |
getVisibleFields | (fields, data) => FormFieldDefinition[] | Fields whose conditions pass. Chained conditions are resolved against visible fields only. |
pruneHiddenData | (fields, data) => Record<string, unknown> | Returns data without the values of hidden fields, as passed to onSubmit. |
localizeText | (value, locale?, baseLocale?) => string | Resolves a LocalizedString with the same fallback rules as the components. |