@rjsf/core 5.11.2 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/core.umd.js +3464 -0
  2. package/dist/index.esm.js +3814 -0
  3. package/dist/index.esm.js.map +7 -0
  4. package/dist/index.js +3714 -5
  5. package/dist/index.js.map +7 -0
  6. package/{dist/index.d.ts → lib/components/Form.d.ts} +321 -337
  7. package/lib/components/Form.js +474 -0
  8. package/lib/components/Form.js.map +1 -0
  9. package/lib/components/fields/ArrayField.d.ts +179 -0
  10. package/lib/components/fields/ArrayField.js +568 -0
  11. package/lib/components/fields/ArrayField.js.map +1 -0
  12. package/lib/components/fields/BooleanField.d.ts +9 -0
  13. package/lib/components/fields/BooleanField.js +62 -0
  14. package/lib/components/fields/BooleanField.js.map +1 -0
  15. package/lib/components/fields/MultiSchemaField.d.ts +47 -0
  16. package/lib/components/fields/MultiSchemaField.js +129 -0
  17. package/lib/components/fields/MultiSchemaField.js.map +1 -0
  18. package/lib/components/fields/NullField.d.ts +8 -0
  19. package/lib/components/fields/NullField.js +17 -0
  20. package/lib/components/fields/NullField.js.map +1 -0
  21. package/lib/components/fields/NumberField.d.ts +21 -0
  22. package/lib/components/fields/NumberField.js +70 -0
  23. package/lib/components/fields/NumberField.js.map +1 -0
  24. package/lib/components/fields/ObjectField.d.ts +73 -0
  25. package/lib/components/fields/ObjectField.js +222 -0
  26. package/lib/components/fields/ObjectField.js.map +1 -0
  27. package/lib/components/fields/SchemaField.d.ts +10 -0
  28. package/lib/components/fields/SchemaField.js +172 -0
  29. package/lib/components/fields/SchemaField.js.map +1 -0
  30. package/lib/components/fields/StringField.d.ts +8 -0
  31. package/lib/components/fields/StringField.js +25 -0
  32. package/lib/components/fields/StringField.js.map +1 -0
  33. package/lib/components/fields/index.d.ts +3 -0
  34. package/lib/components/fields/index.js +24 -0
  35. package/lib/components/fields/index.js.map +1 -0
  36. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +8 -0
  37. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +18 -0
  38. package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +1 -0
  39. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +7 -0
  40. package/lib/components/templates/ArrayFieldItemTemplate.js +20 -0
  41. package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -0
  42. package/lib/components/templates/ArrayFieldTemplate.d.ts +7 -0
  43. package/lib/components/templates/ArrayFieldTemplate.js +22 -0
  44. package/lib/components/templates/ArrayFieldTemplate.js.map +1 -0
  45. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +8 -0
  46. package/lib/components/templates/ArrayFieldTitleTemplate.js +18 -0
  47. package/lib/components/templates/ArrayFieldTitleTemplate.js.map +1 -0
  48. package/lib/components/templates/BaseInputTemplate.d.ts +9 -0
  49. package/lib/components/templates/BaseInputTemplate.js +39 -0
  50. package/lib/components/templates/BaseInputTemplate.js.map +1 -0
  51. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +5 -0
  52. package/lib/components/templates/ButtonTemplates/AddButton.js +10 -0
  53. package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -0
  54. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +7 -0
  55. package/lib/components/templates/ButtonTemplates/IconButton.js +24 -0
  56. package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -0
  57. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +5 -0
  58. package/lib/components/templates/ButtonTemplates/SubmitButton.js +12 -0
  59. package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -0
  60. package/lib/components/templates/ButtonTemplates/index.d.ts +3 -0
  61. package/lib/components/templates/ButtonTemplates/index.js +15 -0
  62. package/lib/components/templates/ButtonTemplates/index.js.map +1 -0
  63. package/lib/components/templates/DescriptionField.d.ts +7 -0
  64. package/lib/components/templates/DescriptionField.js +18 -0
  65. package/lib/components/templates/DescriptionField.js.map +1 -0
  66. package/lib/components/templates/ErrorList.d.ts +7 -0
  67. package/lib/components/templates/ErrorList.js +13 -0
  68. package/lib/components/templates/ErrorList.js.map +1 -0
  69. package/lib/components/templates/FieldErrorTemplate.d.ts +7 -0
  70. package/lib/components/templates/FieldErrorTemplate.js +19 -0
  71. package/lib/components/templates/FieldErrorTemplate.js.map +1 -0
  72. package/lib/components/templates/FieldHelpTemplate.d.ts +7 -0
  73. package/lib/components/templates/FieldHelpTemplate.js +18 -0
  74. package/lib/components/templates/FieldHelpTemplate.js.map +1 -0
  75. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +8 -0
  76. package/lib/components/templates/FieldTemplate/FieldTemplate.js +18 -0
  77. package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -0
  78. package/lib/components/templates/FieldTemplate/Label.d.ts +14 -0
  79. package/lib/components/templates/FieldTemplate/Label.js +14 -0
  80. package/lib/components/templates/FieldTemplate/Label.js.map +1 -0
  81. package/lib/components/templates/FieldTemplate/index.d.ts +2 -0
  82. package/lib/components/templates/FieldTemplate/index.js +3 -0
  83. package/lib/components/templates/FieldTemplate/index.js.map +1 -0
  84. package/lib/components/templates/ObjectFieldTemplate.d.ts +9 -0
  85. package/lib/components/templates/ObjectFieldTemplate.js +18 -0
  86. package/lib/components/templates/ObjectFieldTemplate.js.map +1 -0
  87. package/lib/components/templates/TitleField.d.ts +7 -0
  88. package/lib/components/templates/TitleField.js +11 -0
  89. package/lib/components/templates/TitleField.js.map +1 -0
  90. package/lib/components/templates/UnsupportedField.d.ts +9 -0
  91. package/lib/components/templates/UnsupportedField.js +28 -0
  92. package/lib/components/templates/UnsupportedField.js.map +1 -0
  93. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +8 -0
  94. package/lib/components/templates/WrapIfAdditionalTemplate.js +21 -0
  95. package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -0
  96. package/lib/components/templates/index.d.ts +3 -0
  97. package/lib/components/templates/index.js +36 -0
  98. package/lib/components/templates/index.js.map +1 -0
  99. package/lib/components/widgets/AltDateTimeWidget.d.ts +9 -0
  100. package/lib/components/widgets/AltDateTimeWidget.js +14 -0
  101. package/lib/components/widgets/AltDateTimeWidget.js.map +1 -0
  102. package/lib/components/widgets/AltDateWidget.d.ts +7 -0
  103. package/lib/components/widgets/AltDateWidget.js +77 -0
  104. package/lib/components/widgets/AltDateWidget.js.map +1 -0
  105. package/lib/components/widgets/CheckboxWidget.d.ts +9 -0
  106. package/lib/components/widgets/CheckboxWidget.js +23 -0
  107. package/lib/components/widgets/CheckboxWidget.js.map +1 -0
  108. package/lib/components/widgets/CheckboxesWidget.d.ts +9 -0
  109. package/lib/components/widgets/CheckboxesWidget.js +31 -0
  110. package/lib/components/widgets/CheckboxesWidget.js.map +1 -0
  111. package/lib/components/widgets/ColorWidget.d.ts +8 -0
  112. package/lib/components/widgets/ColorWidget.js +13 -0
  113. package/lib/components/widgets/ColorWidget.js.map +1 -0
  114. package/lib/components/widgets/DateTimeWidget.d.ts +8 -0
  115. package/lib/components/widgets/DateTimeWidget.js +13 -0
  116. package/lib/components/widgets/DateTimeWidget.js.map +1 -0
  117. package/lib/components/widgets/DateWidget.d.ts +8 -0
  118. package/lib/components/widgets/DateWidget.js +15 -0
  119. package/lib/components/widgets/DateWidget.js.map +1 -0
  120. package/lib/components/widgets/EmailWidget.d.ts +7 -0
  121. package/lib/components/widgets/EmailWidget.js +12 -0
  122. package/lib/components/widgets/EmailWidget.js.map +1 -0
  123. package/lib/components/widgets/FileWidget.d.ts +8 -0
  124. package/lib/components/widgets/FileWidget.js +105 -0
  125. package/lib/components/widgets/FileWidget.js.map +1 -0
  126. package/lib/components/widgets/HiddenWidget.d.ts +9 -0
  127. package/lib/components/widgets/HiddenWidget.js +11 -0
  128. package/lib/components/widgets/HiddenWidget.js.map +1 -0
  129. package/lib/components/widgets/PasswordWidget.d.ts +7 -0
  130. package/lib/components/widgets/PasswordWidget.js +12 -0
  131. package/lib/components/widgets/PasswordWidget.js.map +1 -0
  132. package/lib/components/widgets/RadioWidget.d.ts +9 -0
  133. package/lib/components/widgets/RadioWidget.js +24 -0
  134. package/lib/components/widgets/RadioWidget.js.map +1 -0
  135. package/lib/components/widgets/RangeWidget.d.ts +8 -0
  136. package/lib/components/widgets/RangeWidget.js +11 -0
  137. package/lib/components/widgets/RangeWidget.js.map +1 -0
  138. package/lib/components/widgets/SelectWidget.d.ts +9 -0
  139. package/lib/components/widgets/SelectWidget.js +41 -0
  140. package/lib/components/widgets/SelectWidget.js.map +1 -0
  141. package/lib/components/widgets/TextWidget.d.ts +7 -0
  142. package/lib/components/widgets/TextWidget.js +12 -0
  143. package/lib/components/widgets/TextWidget.js.map +1 -0
  144. package/lib/components/widgets/TextareaWidget.d.ts +14 -0
  145. package/lib/components/widgets/TextareaWidget.js +19 -0
  146. package/lib/components/widgets/TextareaWidget.js.map +1 -0
  147. package/lib/components/widgets/TimeWidget.d.ts +8 -0
  148. package/lib/components/widgets/TimeWidget.js +15 -0
  149. package/lib/components/widgets/TimeWidget.js.map +1 -0
  150. package/lib/components/widgets/URLWidget.d.ts +7 -0
  151. package/lib/components/widgets/URLWidget.js +12 -0
  152. package/lib/components/widgets/URLWidget.js.map +1 -0
  153. package/lib/components/widgets/UpDownWidget.d.ts +7 -0
  154. package/lib/components/widgets/UpDownWidget.js +12 -0
  155. package/lib/components/widgets/UpDownWidget.js.map +1 -0
  156. package/lib/components/widgets/index.d.ts +3 -0
  157. package/lib/components/widgets/index.js +44 -0
  158. package/lib/components/widgets/index.js.map +1 -0
  159. package/lib/getDefaultRegistry.d.ts +6 -0
  160. package/lib/getDefaultRegistry.js +19 -0
  161. package/lib/getDefaultRegistry.js.map +1 -0
  162. package/lib/index.d.ts +6 -0
  163. package/lib/index.js +6 -0
  164. package/lib/index.js.map +1 -0
  165. package/lib/withTheme.d.ts +9 -0
  166. package/lib/withTheme.js +16 -0
  167. package/lib/withTheme.js.map +1 -0
  168. package/package.json +23 -16
  169. package/src/components/Form.tsx +853 -0
  170. package/src/components/fields/ArrayField.tsx +875 -0
  171. package/src/components/fields/BooleanField.tsx +114 -0
  172. package/src/components/fields/MultiSchemaField.tsx +221 -0
  173. package/src/components/fields/NullField.tsx +22 -0
  174. package/src/components/fields/NumberField.tsx +86 -0
  175. package/src/components/fields/ObjectField.tsx +331 -0
  176. package/src/components/fields/SchemaField.tsx +360 -0
  177. package/src/components/fields/StringField.tsx +71 -0
  178. package/src/components/fields/index.ts +31 -0
  179. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +41 -0
  180. package/src/components/templates/ArrayFieldItemTemplate.tsx +90 -0
  181. package/src/components/templates/ArrayFieldTemplate.tsx +88 -0
  182. package/src/components/templates/ArrayFieldTitleTemplate.tsx +43 -0
  183. package/src/components/templates/BaseInputTemplate.tsx +102 -0
  184. package/src/components/templates/ButtonTemplates/AddButton.tsx +29 -0
  185. package/src/components/templates/ButtonTemplates/IconButton.tsx +77 -0
  186. package/src/components/templates/ButtonTemplates/SubmitButton.tsx +21 -0
  187. package/src/components/templates/ButtonTemplates/index.ts +22 -0
  188. package/src/components/templates/DescriptionField.tsx +29 -0
  189. package/src/components/templates/ErrorList.tsx +35 -0
  190. package/src/components/templates/FieldErrorTemplate.tsx +33 -0
  191. package/src/components/templates/FieldHelpTemplate.tsx +29 -0
  192. package/src/components/templates/FieldTemplate/FieldTemplate.tsx +41 -0
  193. package/src/components/templates/FieldTemplate/Label.tsx +27 -0
  194. package/src/components/templates/FieldTemplate/index.ts +3 -0
  195. package/src/components/templates/ObjectFieldTemplate.tsx +83 -0
  196. package/src/components/templates/TitleField.tsx +19 -0
  197. package/src/components/templates/UnsupportedField.tsx +37 -0
  198. package/src/components/templates/WrapIfAdditionalTemplate.tsx +80 -0
  199. package/src/components/templates/index.ts +43 -0
  200. package/src/components/widgets/AltDateTimeWidget.tsx +16 -0
  201. package/src/components/widgets/AltDateWidget.tsx +198 -0
  202. package/src/components/widgets/CheckboxWidget.tsx +92 -0
  203. package/src/components/widgets/CheckboxesWidget.tsx +92 -0
  204. package/src/components/widgets/ColorWidget.tsx +14 -0
  205. package/src/components/widgets/DateTimeWidget.tsx +31 -0
  206. package/src/components/widgets/DateWidget.tsx +17 -0
  207. package/src/components/widgets/EmailWidget.tsx +13 -0
  208. package/src/components/widgets/FileWidget.tsx +178 -0
  209. package/src/components/widgets/HiddenWidget.tsx +15 -0
  210. package/src/components/widgets/PasswordWidget.tsx +15 -0
  211. package/src/components/widgets/RadioWidget.tsx +88 -0
  212. package/src/components/widgets/RangeWidget.tsx +23 -0
  213. package/src/components/widgets/SelectWidget.tsx +100 -0
  214. package/src/components/widgets/TextWidget.tsx +13 -0
  215. package/src/components/widgets/TextareaWidget.tsx +61 -0
  216. package/src/components/widgets/TimeWidget.tsx +17 -0
  217. package/src/components/widgets/URLWidget.tsx +13 -0
  218. package/src/components/widgets/UpDownWidget.tsx +13 -0
  219. package/src/components/widgets/index.ts +51 -0
  220. package/src/getDefaultRegistry.ts +24 -0
  221. package/src/index.ts +8 -0
  222. package/src/withTheme.tsx +42 -0
  223. package/dist/core.cjs.development.js +0 -4403
  224. package/dist/core.cjs.development.js.map +0 -1
  225. package/dist/core.cjs.production.min.js +0 -2
  226. package/dist/core.cjs.production.min.js.map +0 -1
  227. package/dist/core.esm.js +0 -4383
  228. package/dist/core.esm.js.map +0 -1
  229. package/dist/core.umd.development.js +0 -4393
  230. package/dist/core.umd.development.js.map +0 -1
  231. package/dist/core.umd.production.min.js +0 -2
  232. package/dist/core.umd.production.min.js.map +0 -1
@@ -1,338 +1,322 @@
1
- import { ReactNode, FormEvent, ElementType, Ref, Component, RefObject, ComponentType } from 'react';
2
- import { StrictRJSFSchema, RJSFSchema, FormContextType, ValidatorType, UiSchema, RegistryFieldsType, TemplatesType, RegistryWidgetsType, RJSFValidationError, CustomValidator, ErrorSchema, ErrorTransformer, Registry, Experimental_DefaultFormStateBehavior, IdSchema, SchemaUtilsType, ValidationData, PathSchema } from '@rjsf/utils';
3
-
4
- /** The properties that are passed to the `Form` */
5
- interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
6
- /** The JSON schema object for the form */
7
- schema: S;
8
- /** An implementation of the `ValidatorType` interface that is needed for form validation to work */
9
- validator: ValidatorType<T, S, F>;
10
- /** The optional children for the form, if provided, it will replace the default `SubmitButton` */
11
- children?: ReactNode;
12
- /** The uiSchema for the form */
13
- uiSchema?: UiSchema<T, S, F>;
14
- /** The data for the form, used to prefill a form with existing data */
15
- formData?: T;
16
- /** You can provide a `formContext` object to the form, which is passed down to all fields and widgets. Useful for
17
- * implementing context aware fields and widgets.
18
- *
19
- * NOTE: Setting `{readonlyAsDisabled: false}` on the formContext will make the antd theme treat readOnly fields as
20
- * disabled.
21
- */
22
- formContext?: F;
23
- /** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
24
- * Default is `root`
25
- */
26
- idPrefix?: string;
27
- /** To avoid using a path separator that is present in field names, it is possible to change the separator used for
28
- * ids (Default is `_`)
29
- */
30
- idSeparator?: string;
31
- /** It's possible to disable the whole form by setting the `disabled` prop. The `disabled` prop is then forwarded down
32
- * to each field of the form. If you just want to disable some fields, see the `ui:disabled` parameter in `uiSchema`
33
- */
34
- disabled?: boolean;
35
- /** It's possible to make the whole form read-only by setting the `readonly` prop. The `readonly` prop is then
36
- * forwarded down to each field of the form. If you just want to make some fields read-only, see the `ui:readonly`
37
- * parameter in `uiSchema`
38
- */
39
- readonly?: boolean;
40
- /** The dictionary of registered fields in the form */
41
- fields?: RegistryFieldsType<T, S, F>;
42
- /** The dictionary of registered templates in the form; Partial allows a subset to be provided beyond the defaults */
43
- templates?: Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & {
44
- ButtonTemplates?: Partial<TemplatesType<T, S, F>['ButtonTemplates']>;
45
- };
46
- /** The dictionary of registered widgets in the form */
47
- widgets?: RegistryWidgetsType<T, S, F>;
48
- /** If you plan on being notified every time the form data are updated, you can pass an `onChange` handler, which will
49
- * receive the same args as `onSubmit` any time a value is updated in the form. Can also return the `id` of the field
50
- * that caused the change
51
- */
52
- onChange?: (data: IChangeEvent<T, S, F>, id?: string) => void;
53
- /** To react when submitted form data are invalid, pass an `onError` handler. It will be passed the list of
54
- * encountered errors
55
- */
56
- onError?: (errors: RJSFValidationError[]) => void;
57
- /** You can pass a function as the `onSubmit` prop of your `Form` component to listen to when the form is submitted
58
- * and its data are valid. It will be passed a result object having a `formData` attribute, which is the valid form
59
- * data you're usually after. The original event will also be passed as a second parameter
60
- */
61
- onSubmit?: (data: IChangeEvent<T, S, F>, event: FormEvent<any>) => void;
62
- /** Sometimes you may want to trigger events or modify external state when a field has been touched, so you can pass
63
- * an `onBlur` handler, which will receive the id of the input that was blurred and the field value
64
- */
65
- onBlur?: (id: string, data: any) => void;
66
- /** Sometimes you may want to trigger events or modify external state when a field has been focused, so you can pass
67
- * an `onFocus` handler, which will receive the id of the input that is focused and the field value
68
- */
69
- onFocus?: (id: string, data: any) => void;
70
- /** The value of this prop will be passed to the `accept-charset` HTML attribute on the form */
71
- acceptcharset?: string;
72
- /** The value of this prop will be passed to the `action` HTML attribute on the form
73
- *
74
- * NOTE: this just renders the `action` attribute in the HTML markup. There is no real network request being sent to
75
- * this `action` on submit. Instead, react-jsonschema-form catches the submit event with `event.preventDefault()`
76
- * and then calls the `onSubmit` function, where you could send a request programmatically with `fetch` or similar.
77
- */
78
- action?: string;
79
- /** The value of this prop will be passed to the `autocomplete` HTML attribute on the form */
80
- autoComplete?: string;
81
- /** The value of this prop will be passed to the `class` HTML attribute on the form */
82
- className?: string;
83
- /** The value of this prop will be passed to the `enctype` HTML attribute on the form */
84
- enctype?: string;
85
- /** The value of this prop will be passed to the `id` HTML attribute on the form */
86
- id?: string;
87
- /** The value of this prop will be passed to the `name` HTML attribute on the form */
88
- name?: string;
89
- /** The value of this prop will be passed to the `method` HTML attribute on the form */
90
- method?: string;
91
- /** It's possible to change the default `form` tag name to a different HTML tag, which can be helpful if you are
92
- * nesting forms. However, native browser form behaviour, such as submitting when the `Enter` key is pressed, may no
93
- * longer work
94
- */
95
- tagName?: ElementType;
96
- /** The value of this prop will be passed to the `target` HTML attribute on the form */
97
- target?: string;
98
- /** Formerly the `validate` prop; Takes a function that specifies custom validation rules for the form */
99
- customValidate?: CustomValidator<T, S, F>;
100
- /** This prop allows passing in custom errors that are augmented with the existing JSON Schema errors on the form; it
101
- * can be used to implement asynchronous validation. By default, these are non-blocking errors, meaning that you can
102
- * still submit the form when these are the only errors displayed to the user.
103
- */
104
- extraErrors?: ErrorSchema<T>;
105
- /** If set to true, causes the `extraErrors` to become blocking when the form is submitted */
106
- extraErrorsBlockSubmit?: boolean;
107
- /** If set to true, turns off HTML5 validation on the form; Set to `false` by default */
108
- noHtml5Validate?: boolean;
109
- /** If set to true, turns off all validation. Set to `false` by default
110
- *
111
- * @deprecated - In a future release, this switch may be replaced by making `validator` prop optional
112
- */
113
- noValidate?: boolean;
114
- /** If set to true, the form will perform validation and show any validation errors whenever the form data is changed,
115
- * rather than just on submit
116
- */
117
- liveValidate?: boolean;
118
- /** If `omitExtraData` and `liveOmit` are both set to true, then extra form data values that are not in any form field
119
- * will be removed whenever `onChange` is called. Set to `false` by default
120
- */
121
- liveOmit?: boolean;
122
- /** If set to true, then extra form data values that are not in any form field will be removed whenever `onSubmit` is
123
- * called. Set to `false` by default.
124
- */
125
- omitExtraData?: boolean;
126
- /** When this prop is set to `top` or 'bottom', a list of errors (or the custom error list defined in the `ErrorList`) will also
127
- * show. When set to false, only inline input validation errors will be shown. Set to `top` by default
128
- */
129
- showErrorList?: false | 'top' | 'bottom';
130
- /** A function can be passed to this prop in order to make modifications to the default errors resulting from JSON
131
- * Schema validation
132
- */
133
- transformErrors?: ErrorTransformer<T, S, F>;
134
- /** If set to true, then the first field with an error will receive the focus when the form is submitted with errors
135
- */
136
- focusOnFirstError?: boolean | ((error: RJSFValidationError) => void);
137
- /** Optional string translation function, if provided, allows users to change the translation of the RJSF internal
138
- * strings. Some strings contain replaceable parameter values as indicated by `%1`, `%2`, etc. The number after the
139
- * `%` indicates the order of the parameter. The ordering of parameters is important because some languages may choose
140
- * to put the second parameter before the first in its translation.
141
- */
142
- translateString?: Registry['translateString'];
143
- /** Optional configuration object with flags, if provided, allows users to override default form state behavior
144
- * Currently only affecting minItems on array fields and handling of setting defaults based on the value of
145
- * `emptyObjectFields`
146
- */
147
- experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;
148
- /**
149
- * _internalFormWrapper is currently used by the semantic-ui theme to provide a custom wrapper around `<Form />`
150
- * that supports the proper rendering of those themes. To use this prop, one must pass a component that takes two
151
- * props: `children` and `as`. That component, at minimum, should render the `children` inside of a <form /> tag
152
- * unless `as` is provided, in which case, use the `as` prop in place of `<form />`.
153
- * i.e.:
154
- * ```
155
- * export default function InternalForm({ children, as }) {
156
- * const FormTag = as || 'form';
157
- * return <FormTag>{children}</FormTag>;
158
- * }
159
- * ```
160
- *
161
- * Use at your own risk as this prop is private and may change at any time without notice.
162
- */
163
- _internalFormWrapper?: ElementType;
164
- /** Support receiving a React ref to the Form
165
- */
166
- ref?: Ref<Form<T, S, F>>;
167
- }
168
- /** The data that is contained within the state for the `Form` */
169
- interface FormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
170
- /** The JSON schema object for the form */
171
- schema: S;
172
- /** The uiSchema for the form */
173
- uiSchema: UiSchema<T, S, F>;
174
- /** The `IdSchema` for the form, computed from the `schema`, the `rootFieldId`, the `formData` and the `idPrefix` and
175
- * `idSeparator` props.
176
- */
177
- idSchema: IdSchema<T>;
178
- /** The schemaUtils implementation used by the `Form`, created from the `validator` and the `schema` */
179
- schemaUtils: SchemaUtilsType<T, S, F>;
180
- /** The current data for the form, computed from the `formData` prop and the changes made by the user */
181
- formData?: T;
182
- /** Flag indicating whether the form is in edit mode, true when `formData` is passed to the form, otherwise false */
183
- edit: boolean;
184
- /** The current list of errors for the form, includes `extraErrors` */
185
- errors: RJSFValidationError[];
186
- /** The current errors, in `ErrorSchema` format, for the form, includes `extraErrors` */
187
- errorSchema: ErrorSchema<T>;
188
- /** The current list of errors for the form directly from schema validation, does NOT include `extraErrors` */
189
- schemaValidationErrors: RJSFValidationError[];
190
- /** The current errors, in `ErrorSchema` format, for the form directly from schema validation, does NOT include
191
- * `extraErrors`
192
- */
193
- schemaValidationErrorSchema: ErrorSchema<T>;
194
- }
195
- /** The event data passed when changes have been made to the form, includes everything from the `FormState` except
196
- * the schema validation errors. An additional `status` is added when returned from `onSubmit`
197
- */
198
- interface IChangeEvent<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Omit<FormState<T, S, F>, 'schemaValidationErrors' | 'schemaValidationErrorSchema'> {
199
- /** The status of the form when submitted */
200
- status?: 'submitted';
201
- }
202
- /** The `Form` component renders the outer form and all the fields defined in the `schema` */
203
- declare class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FormProps<T, S, F>, FormState<T, S, F>> {
204
- /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
205
- * provide any possible type here
206
- */
207
- formElement: RefObject<any>;
208
- /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
209
- * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
210
- * state construction.
211
- *
212
- * @param props - The initial props for the `Form`
213
- */
214
- constructor(props: FormProps<T, S, F>);
215
- /** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
216
- * will also call the`onChange` handler if the `formData` is modified to add missing default values as part of the
217
- * state construction.
218
- *
219
- * @param nextProps - The new set of props about to be applied to the `Form`
220
- */
221
- UNSAFE_componentWillReceiveProps(nextProps: FormProps<T, S, F>): void;
222
- /** Extracts the updated state from the given `props` and `inputFormData`. As part of this process, the
223
- * `inputFormData` is first processed to add any missing required defaults. After that, the data is run through the
224
- * validation process IF required by the `props`.
225
- *
226
- * @param props - The props passed to the `Form`
227
- * @param inputFormData - The new or current data for the `Form`
228
- * @returns - The new state for the `Form`
229
- */
230
- getStateFromProps(props: FormProps<T, S, F>, inputFormData?: T): FormState<T, S, F>;
231
- /** React lifecycle method that is used to determine whether component should be updated.
232
- *
233
- * @param nextProps - The next version of the props
234
- * @param nextState - The next version of the state
235
- * @returns - True if the component should be updated, false otherwise
236
- */
237
- shouldComponentUpdate(nextProps: FormProps<T, S, F>, nextState: FormState<T, S, F>): boolean;
238
- /** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
239
- * `schemaUtils` in the state), returning the results.
240
- *
241
- * @param formData - The new form data to validate
242
- * @param schema - The schema used to validate against
243
- * @param altSchemaUtils - The alternate schemaUtils to use for validation
244
- */
245
- validate(formData: T | undefined, schema?: S, altSchemaUtils?: SchemaUtilsType<T, S, F>): ValidationData<T>;
246
- /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
247
- renderErrors(registry: Registry<T, S, F>): JSX.Element | null;
248
- /** Returns the `formData` with only the elements specified in the `fields` list
249
- *
250
- * @param formData - The data for the `Form`
251
- * @param fields - The fields to keep while filtering
252
- */
253
- getUsedFormData: (formData: T | undefined, fields: string[][]) => T | undefined;
254
- /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
255
- *
256
- * @param pathSchema - The `PathSchema` object for the form
257
- * @param [formData] - The form data to use while checking for empty objects/arrays
258
- */
259
- getFieldNames: (pathSchema: PathSchema<T>, formData?: T) => string[][];
260
- /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
261
- * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
262
- * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filterer to remove any extra data not
263
- * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
264
- * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
265
- * callback will be called if specified with the updated state.
266
- *
267
- * @param formData - The new form data from a change to a field
268
- * @param newErrorSchema - The new `ErrorSchema` based on the field change
269
- * @param id - The id of the field that caused the change
270
- */
271
- onChange: (formData: T | undefined, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
272
- /**
273
- * Callback function to handle reset form data.
274
- * - Reset all fields with default values.
275
- * - Reset validations and errors
276
- *
277
- */
278
- reset: () => void;
279
- /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
280
- * was provided.
281
- *
282
- * @param id - The unique `id` of the field that was blurred
283
- * @param data - The data associated with the field that was blurred
284
- */
285
- onBlur: (id: string, data: any) => void;
286
- /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
287
- * was provided.
288
- *
289
- * @param id - The unique `id` of the field that was focused
290
- * @param data - The data associated with the field that was focused
291
- */
292
- onFocus: (id: string, data: any) => void;
293
- /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
294
- * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
295
- * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
296
- * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
297
- * back the `onSubmit` callback if it was provided.
298
- *
299
- * @param event - The submit HTML form event
300
- */
301
- onSubmit: (event: FormEvent<any>) => void;
302
- /** Returns the registry for the form */
303
- getRegistry(): Registry<T, S, F>;
304
- /** Provides a function that can be used to programmatically submit the `Form` */
305
- submit(): void;
306
- /** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
307
- * field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
308
- * id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
309
- *
310
- * @param error - The error on which to focus
311
- */
312
- focusOnError(error: RJSFValidationError): void;
313
- /** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
314
- * same way as would happen on form submission.
315
- *
316
- * @returns - True if the form is valid, false otherwise.
317
- */
318
- validateForm(): boolean;
319
- /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
320
- * needed along with the submit button or any children of the form.
321
- */
322
- render(): JSX.Element;
1
+ import { Component, ElementType, FormEvent, ReactNode, Ref, RefObject } from 'react';
2
+ import { CustomValidator, ErrorSchema, ErrorTransformer, FormContextType, IdSchema, PathSchema, StrictRJSFSchema, Registry, RegistryFieldsType, RegistryWidgetsType, RJSFSchema, RJSFValidationError, SchemaUtilsType, TemplatesType, UiSchema, ValidationData, ValidatorType, Experimental_DefaultFormStateBehavior } from '@rjsf/utils';
3
+ /** The properties that are passed to the `Form` */
4
+ export interface FormProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
5
+ /** The JSON schema object for the form */
6
+ schema: S;
7
+ /** An implementation of the `ValidatorType` interface that is needed for form validation to work */
8
+ validator: ValidatorType<T, S, F>;
9
+ /** The optional children for the form, if provided, it will replace the default `SubmitButton` */
10
+ children?: ReactNode;
11
+ /** The uiSchema for the form */
12
+ uiSchema?: UiSchema<T, S, F>;
13
+ /** The data for the form, used to prefill a form with existing data */
14
+ formData?: T;
15
+ /** You can provide a `formContext` object to the form, which is passed down to all fields and widgets. Useful for
16
+ * implementing context aware fields and widgets.
17
+ *
18
+ * NOTE: Setting `{readonlyAsDisabled: false}` on the formContext will make the antd theme treat readOnly fields as
19
+ * disabled.
20
+ */
21
+ formContext?: F;
22
+ /** To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids;
23
+ * Default is `root`
24
+ */
25
+ idPrefix?: string;
26
+ /** To avoid using a path separator that is present in field names, it is possible to change the separator used for
27
+ * ids (Default is `_`)
28
+ */
29
+ idSeparator?: string;
30
+ /** It's possible to disable the whole form by setting the `disabled` prop. The `disabled` prop is then forwarded down
31
+ * to each field of the form. If you just want to disable some fields, see the `ui:disabled` parameter in `uiSchema`
32
+ */
33
+ disabled?: boolean;
34
+ /** It's possible to make the whole form read-only by setting the `readonly` prop. The `readonly` prop is then
35
+ * forwarded down to each field of the form. If you just want to make some fields read-only, see the `ui:readonly`
36
+ * parameter in `uiSchema`
37
+ */
38
+ readonly?: boolean;
39
+ /** The dictionary of registered fields in the form */
40
+ fields?: RegistryFieldsType<T, S, F>;
41
+ /** The dictionary of registered templates in the form; Partial allows a subset to be provided beyond the defaults */
42
+ templates?: Partial<Omit<TemplatesType<T, S, F>, 'ButtonTemplates'>> & {
43
+ ButtonTemplates?: Partial<TemplatesType<T, S, F>['ButtonTemplates']>;
44
+ };
45
+ /** The dictionary of registered widgets in the form */
46
+ widgets?: RegistryWidgetsType<T, S, F>;
47
+ /** If you plan on being notified every time the form data are updated, you can pass an `onChange` handler, which will
48
+ * receive the same args as `onSubmit` any time a value is updated in the form. Can also return the `id` of the field
49
+ * that caused the change
50
+ */
51
+ onChange?: (data: IChangeEvent<T, S, F>, id?: string) => void;
52
+ /** To react when submitted form data are invalid, pass an `onError` handler. It will be passed the list of
53
+ * encountered errors
54
+ */
55
+ onError?: (errors: RJSFValidationError[]) => void;
56
+ /** You can pass a function as the `onSubmit` prop of your `Form` component to listen to when the form is submitted
57
+ * and its data are valid. It will be passed a result object having a `formData` attribute, which is the valid form
58
+ * data you're usually after. The original event will also be passed as a second parameter
59
+ */
60
+ onSubmit?: (data: IChangeEvent<T, S, F>, event: FormEvent<any>) => void;
61
+ /** Sometimes you may want to trigger events or modify external state when a field has been touched, so you can pass
62
+ * an `onBlur` handler, which will receive the id of the input that was blurred and the field value
63
+ */
64
+ onBlur?: (id: string, data: any) => void;
65
+ /** Sometimes you may want to trigger events or modify external state when a field has been focused, so you can pass
66
+ * an `onFocus` handler, which will receive the id of the input that is focused and the field value
67
+ */
68
+ onFocus?: (id: string, data: any) => void;
69
+ /** The value of this prop will be passed to the `accept-charset` HTML attribute on the form */
70
+ acceptcharset?: string;
71
+ /** The value of this prop will be passed to the `action` HTML attribute on the form
72
+ *
73
+ * NOTE: this just renders the `action` attribute in the HTML markup. There is no real network request being sent to
74
+ * this `action` on submit. Instead, react-jsonschema-form catches the submit event with `event.preventDefault()`
75
+ * and then calls the `onSubmit` function, where you could send a request programmatically with `fetch` or similar.
76
+ */
77
+ action?: string;
78
+ /** The value of this prop will be passed to the `autocomplete` HTML attribute on the form */
79
+ autoComplete?: string;
80
+ /** The value of this prop will be passed to the `class` HTML attribute on the form */
81
+ className?: string;
82
+ /** The value of this prop will be passed to the `enctype` HTML attribute on the form */
83
+ enctype?: string;
84
+ /** The value of this prop will be passed to the `id` HTML attribute on the form */
85
+ id?: string;
86
+ /** The value of this prop will be passed to the `name` HTML attribute on the form */
87
+ name?: string;
88
+ /** The value of this prop will be passed to the `method` HTML attribute on the form */
89
+ method?: string;
90
+ /** It's possible to change the default `form` tag name to a different HTML tag, which can be helpful if you are
91
+ * nesting forms. However, native browser form behaviour, such as submitting when the `Enter` key is pressed, may no
92
+ * longer work
93
+ */
94
+ tagName?: ElementType;
95
+ /** The value of this prop will be passed to the `target` HTML attribute on the form */
96
+ target?: string;
97
+ /** Formerly the `validate` prop; Takes a function that specifies custom validation rules for the form */
98
+ customValidate?: CustomValidator<T, S, F>;
99
+ /** This prop allows passing in custom errors that are augmented with the existing JSON Schema errors on the form; it
100
+ * can be used to implement asynchronous validation. By default, these are non-blocking errors, meaning that you can
101
+ * still submit the form when these are the only errors displayed to the user.
102
+ */
103
+ extraErrors?: ErrorSchema<T>;
104
+ /** If set to true, causes the `extraErrors` to become blocking when the form is submitted */
105
+ extraErrorsBlockSubmit?: boolean;
106
+ /** If set to true, turns off HTML5 validation on the form; Set to `false` by default */
107
+ noHtml5Validate?: boolean;
108
+ /** If set to true, turns off all validation. Set to `false` by default
109
+ *
110
+ * @deprecated - In a future release, this switch may be replaced by making `validator` prop optional
111
+ */
112
+ noValidate?: boolean;
113
+ /** If set to true, the form will perform validation and show any validation errors whenever the form data is changed,
114
+ * rather than just on submit
115
+ */
116
+ liveValidate?: boolean;
117
+ /** If `omitExtraData` and `liveOmit` are both set to true, then extra form data values that are not in any form field
118
+ * will be removed whenever `onChange` is called. Set to `false` by default
119
+ */
120
+ liveOmit?: boolean;
121
+ /** If set to true, then extra form data values that are not in any form field will be removed whenever `onSubmit` is
122
+ * called. Set to `false` by default.
123
+ */
124
+ omitExtraData?: boolean;
125
+ /** When this prop is set to `top` or 'bottom', a list of errors (or the custom error list defined in the `ErrorList`) will also
126
+ * show. When set to false, only inline input validation errors will be shown. Set to `top` by default
127
+ */
128
+ showErrorList?: false | 'top' | 'bottom';
129
+ /** A function can be passed to this prop in order to make modifications to the default errors resulting from JSON
130
+ * Schema validation
131
+ */
132
+ transformErrors?: ErrorTransformer<T, S, F>;
133
+ /** If set to true, then the first field with an error will receive the focus when the form is submitted with errors
134
+ */
135
+ focusOnFirstError?: boolean | ((error: RJSFValidationError) => void);
136
+ /** Optional string translation function, if provided, allows users to change the translation of the RJSF internal
137
+ * strings. Some strings contain replaceable parameter values as indicated by `%1`, `%2`, etc. The number after the
138
+ * `%` indicates the order of the parameter. The ordering of parameters is important because some languages may choose
139
+ * to put the second parameter before the first in its translation.
140
+ */
141
+ translateString?: Registry['translateString'];
142
+ /** Optional configuration object with flags, if provided, allows users to override default form state behavior
143
+ * Currently only affecting minItems on array fields and handling of setting defaults based on the value of
144
+ * `emptyObjectFields`
145
+ */
146
+ experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;
147
+ /**
148
+ * _internalFormWrapper is currently used by the semantic-ui theme to provide a custom wrapper around `<Form />`
149
+ * that supports the proper rendering of those themes. To use this prop, one must pass a component that takes two
150
+ * props: `children` and `as`. That component, at minimum, should render the `children` inside of a <form /> tag
151
+ * unless `as` is provided, in which case, use the `as` prop in place of `<form />`.
152
+ * i.e.:
153
+ * ```
154
+ * export default function InternalForm({ children, as }) {
155
+ * const FormTag = as || 'form';
156
+ * return <FormTag>{children}</FormTag>;
157
+ * }
158
+ * ```
159
+ *
160
+ * Use at your own risk as this prop is private and may change at any time without notice.
161
+ */
162
+ _internalFormWrapper?: ElementType;
163
+ /** Support receiving a React ref to the Form
164
+ */
165
+ ref?: Ref<Form<T, S, F>>;
166
+ }
167
+ /** The data that is contained within the state for the `Form` */
168
+ export interface FormState<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> {
169
+ /** The JSON schema object for the form */
170
+ schema: S;
171
+ /** The uiSchema for the form */
172
+ uiSchema: UiSchema<T, S, F>;
173
+ /** The `IdSchema` for the form, computed from the `schema`, the `rootFieldId`, the `formData` and the `idPrefix` and
174
+ * `idSeparator` props.
175
+ */
176
+ idSchema: IdSchema<T>;
177
+ /** The schemaUtils implementation used by the `Form`, created from the `validator` and the `schema` */
178
+ schemaUtils: SchemaUtilsType<T, S, F>;
179
+ /** The current data for the form, computed from the `formData` prop and the changes made by the user */
180
+ formData?: T;
181
+ /** Flag indicating whether the form is in edit mode, true when `formData` is passed to the form, otherwise false */
182
+ edit: boolean;
183
+ /** The current list of errors for the form, includes `extraErrors` */
184
+ errors: RJSFValidationError[];
185
+ /** The current errors, in `ErrorSchema` format, for the form, includes `extraErrors` */
186
+ errorSchema: ErrorSchema<T>;
187
+ /** The current list of errors for the form directly from schema validation, does NOT include `extraErrors` */
188
+ schemaValidationErrors: RJSFValidationError[];
189
+ /** The current errors, in `ErrorSchema` format, for the form directly from schema validation, does NOT include
190
+ * `extraErrors`
191
+ */
192
+ schemaValidationErrorSchema: ErrorSchema<T>;
193
+ }
194
+ /** The event data passed when changes have been made to the form, includes everything from the `FormState` except
195
+ * the schema validation errors. An additional `status` is added when returned from `onSubmit`
196
+ */
197
+ export interface IChangeEvent<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Omit<FormState<T, S, F>, 'schemaValidationErrors' | 'schemaValidationErrorSchema'> {
198
+ /** The status of the form when submitted */
199
+ status?: 'submitted';
200
+ }
201
+ /** The `Form` component renders the outer form and all the fields defined in the `schema` */
202
+ export default class Form<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> extends Component<FormProps<T, S, F>, FormState<T, S, F>> {
203
+ /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
204
+ * provide any possible type here
205
+ */
206
+ formElement: RefObject<any>;
207
+ /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
208
+ * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
209
+ * state construction.
210
+ *
211
+ * @param props - The initial props for the `Form`
212
+ */
213
+ constructor(props: FormProps<T, S, F>);
214
+ /** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
215
+ * will also call the`onChange` handler if the `formData` is modified to add missing default values as part of the
216
+ * state construction.
217
+ *
218
+ * @param nextProps - The new set of props about to be applied to the `Form`
219
+ */
220
+ UNSAFE_componentWillReceiveProps(nextProps: FormProps<T, S, F>): void;
221
+ /** Extracts the updated state from the given `props` and `inputFormData`. As part of this process, the
222
+ * `inputFormData` is first processed to add any missing required defaults. After that, the data is run through the
223
+ * validation process IF required by the `props`.
224
+ *
225
+ * @param props - The props passed to the `Form`
226
+ * @param inputFormData - The new or current data for the `Form`
227
+ * @returns - The new state for the `Form`
228
+ */
229
+ getStateFromProps(props: FormProps<T, S, F>, inputFormData?: T): FormState<T, S, F>;
230
+ /** React lifecycle method that is used to determine whether component should be updated.
231
+ *
232
+ * @param nextProps - The next version of the props
233
+ * @param nextState - The next version of the state
234
+ * @returns - True if the component should be updated, false otherwise
235
+ */
236
+ shouldComponentUpdate(nextProps: FormProps<T, S, F>, nextState: FormState<T, S, F>): boolean;
237
+ /** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
238
+ * `schemaUtils` in the state), returning the results.
239
+ *
240
+ * @param formData - The new form data to validate
241
+ * @param schema - The schema used to validate against
242
+ * @param altSchemaUtils - The alternate schemaUtils to use for validation
243
+ */
244
+ validate(formData: T | undefined, schema?: S, altSchemaUtils?: SchemaUtilsType<T, S, F>): ValidationData<T>;
245
+ /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
246
+ renderErrors(registry: Registry<T, S, F>): JSX.Element | null;
247
+ /** Returns the `formData` with only the elements specified in the `fields` list
248
+ *
249
+ * @param formData - The data for the `Form`
250
+ * @param fields - The fields to keep while filtering
251
+ */
252
+ getUsedFormData: (formData: T | undefined, fields: string[][]) => T | undefined;
253
+ /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
254
+ *
255
+ * @param pathSchema - The `PathSchema` object for the form
256
+ * @param [formData] - The form data to use while checking for empty objects/arrays
257
+ */
258
+ getFieldNames: (pathSchema: PathSchema<T>, formData?: T) => string[][];
259
+ /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
260
+ * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
261
+ * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filterer to remove any extra data not
262
+ * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
263
+ * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
264
+ * callback will be called if specified with the updated state.
265
+ *
266
+ * @param formData - The new form data from a change to a field
267
+ * @param newErrorSchema - The new `ErrorSchema` based on the field change
268
+ * @param id - The id of the field that caused the change
269
+ */
270
+ onChange: (formData: T | undefined, newErrorSchema?: ErrorSchema<T>, id?: string) => void;
271
+ /**
272
+ * Callback function to handle reset form data.
273
+ * - Reset all fields with default values.
274
+ * - Reset validations and errors
275
+ *
276
+ */
277
+ reset: () => void;
278
+ /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
279
+ * was provided.
280
+ *
281
+ * @param id - The unique `id` of the field that was blurred
282
+ * @param data - The data associated with the field that was blurred
283
+ */
284
+ onBlur: (id: string, data: any) => void;
285
+ /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
286
+ * was provided.
287
+ *
288
+ * @param id - The unique `id` of the field that was focused
289
+ * @param data - The data associated with the field that was focused
290
+ */
291
+ onFocus: (id: string, data: any) => void;
292
+ /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
293
+ * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
294
+ * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
295
+ * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
296
+ * back the `onSubmit` callback if it was provided.
297
+ *
298
+ * @param event - The submit HTML form event
299
+ */
300
+ onSubmit: (event: FormEvent<any>) => void;
301
+ /** Returns the registry for the form */
302
+ getRegistry(): Registry<T, S, F>;
303
+ /** Provides a function that can be used to programmatically submit the `Form` */
304
+ submit(): void;
305
+ /** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
306
+ * field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
307
+ * id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
308
+ *
309
+ * @param error - The error on which to focus
310
+ */
311
+ focusOnError(error: RJSFValidationError): void;
312
+ /** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
313
+ * same way as would happen on form submission.
314
+ *
315
+ * @returns - True if the form is valid, false otherwise.
316
+ */
317
+ validateForm(): boolean;
318
+ /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
319
+ * needed along with the submit button or any children of the form.
320
+ */
321
+ render(): JSX.Element;
323
322
  }
324
-
325
- /** The properties for the `withTheme` function, essentially a subset of properties from the `FormProps` that can be
326
- * overridden while creating a theme
327
- */
328
- type ThemeProps<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any> = Pick<FormProps<T, S, F>, 'fields' | 'templates' | 'widgets' | '_internalFormWrapper'>;
329
- /** A Higher-Order component that creates a wrapper around a `Form` with the overrides from the `WithThemeProps` */
330
- declare function withTheme<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(themeProps: ThemeProps<T, S, F>): ComponentType<FormProps<T, S, F>>;
331
-
332
- /** The default registry consists of all the fields, templates and widgets provided in the core implementation,
333
- * plus an empty `rootSchema` and `formContext. We omit schemaUtils here because it cannot be defaulted without a
334
- * rootSchema and validator. It will be added into the computed registry later in the Form.
335
- */
336
- declare function getDefaultRegistry<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(): Omit<Registry<T, S, F>, 'schemaUtils'>;
337
-
338
- export { FormProps, FormState, IChangeEvent, ThemeProps, Form as default, getDefaultRegistry, withTheme };