|
| 1 | +# Dynamic forms |
| 2 | + |
| 3 | +The library uses [specs](./spec.md#specs) to describe the entities of arrays, objects, strings, numbers, and boolean values. The entity description includes instructions for drawing and validating the entity. The library interacts on two levels: [Layouts](./config.md#layouts) and [Inputs](./config.md#inputs). |
| 4 | + |
| 5 | +And it is intended to be used with `final-form`. |
| 6 | + |
| 7 | +## Form |
| 8 | + |
| 9 | +### DynamicField |
| 10 | + |
| 11 | +This component serves as the primary entry point for drawing dynamic forms. |
| 12 | + |
| 13 | +| Property | Type | Required | Description | |
| 14 | +| :------- | :--------------------------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 15 | +| name | `string` | yes | Field name | |
| 16 | +| spec | `Spec` | yes | A [spec](./spec.md#specs) describing the entity | |
| 17 | +| config | `DynamicFormConfig` | yes | A [config](./config.md) containing [Inputs](./config.md#inputs), [Layouts](./config.md#layouts), and [validators](./config.md#validators) for each entity | |
| 18 | +| Monaco | `React.ComponentType<MonacoEditorProps>` | | [MonacoEditor](https://github.com/react-monaco-editor/react-monaco-editor) component for Monaco [Input](./config.md#inputs) | |
| 19 | +| search | `string \| function` | | A string or function for performing a form search | |
| 20 | + |
| 21 | +### Controller |
| 22 | + |
| 23 | +This component locates all required rendering elements and renders the entity. |
| 24 | + |
| 25 | +| Property | Type | Required | Description | |
| 26 | +| :-------------- | :---------------------------------------------------------------------------------------------------------- | :------: | :----------------------------------------------- | |
| 27 | +| name | `string` | yes | Field name | |
| 28 | +| spec | `Spec` | yes | An [spec](./spec.md#specs) describing the entity | |
| 29 | +| initialValue | `FieldValue` | yes | Initial value | |
| 30 | +| parentOnChange | `((childName: string, childValue: FieldValue, childErrors: Record<string, ValidateError>) => void) \| null` | yes | Callback for updating the parent entity's state | |
| 31 | +| parentOnUnmount | `((childName: string) => void) \| null` | yes | Callback for unmount | |
| 32 | + |
| 33 | +## View |
| 34 | + |
| 35 | +### DynamicView |
| 36 | + |
| 37 | +This component serves as the primary entry point for creating an overview of form values. |
| 38 | + |
| 39 | +| Property | Type | Required | Description | |
| 40 | +| :------- | :------------------------------------------------------------------------- | :------: | :-------------------------------------------------------------------------------------------------------------------------- | |
| 41 | +| value | `AnyObject` | yes | Form value | |
| 42 | +| spec | `Spec` | yes | An [spec](./spec.md#specs) describing the entity | |
| 43 | +| config | `DynamicViewConfig` | yes | A [config](./config.md) containing [Views](./config.md#views) and [ViewLayouts](./config.md#viewlayouts) for each entity | |
| 44 | +| Link | `React.ComponentType<{value: FormValue; link: Spec['viewSpec']['link'];}>` | | [Component](./spec.md#link) for converting values to links | |
| 45 | +| Monaco | `React.ComponentType<MonacoEditorProps>` | | [MonacoEditor](https://github.com/react-monaco-editor/react-monaco-editor) component for Monaco [Input](./config.md#inputs) | |
| 46 | + |
| 47 | +### ViewController |
| 48 | + |
| 49 | +This component searches for all required rendering elements and renders the entity. |
| 50 | + |
| 51 | +| Property | Type | Required | Description | |
| 52 | +| :------- | :------- | :------: | :----------------------------------------------- | |
| 53 | +| name | `string` | yes | View name | |
| 54 | +| spec | `Spec` | yes | An [spec](./spec.md#specs) describing the entity | |
0 commit comments