@rjsf/core 5.24.4 → 5.24.7

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 (224) hide show
  1. package/dist/core.umd.js +602 -601
  2. package/dist/index.esm.js +602 -601
  3. package/dist/index.esm.js.map +2 -2
  4. package/dist/index.js +602 -601
  5. package/dist/index.js.map +2 -2
  6. package/lib/components/Form.d.ts +1 -0
  7. package/lib/components/Form.d.ts.map +1 -0
  8. package/lib/components/Form.js +293 -293
  9. package/lib/components/fields/ArrayField.d.ts +1 -0
  10. package/lib/components/fields/ArrayField.d.ts.map +1 -0
  11. package/lib/components/fields/ArrayField.js +190 -194
  12. package/lib/components/fields/BooleanField.d.ts +1 -0
  13. package/lib/components/fields/BooleanField.d.ts.map +1 -0
  14. package/lib/components/fields/BooleanField.js +3 -5
  15. package/lib/components/fields/MultiSchemaField.d.ts +1 -0
  16. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
  17. package/lib/components/fields/MultiSchemaField.js +30 -31
  18. package/lib/components/fields/NullField.d.ts +1 -0
  19. package/lib/components/fields/NullField.d.ts.map +1 -0
  20. package/lib/components/fields/NullField.js +0 -1
  21. package/lib/components/fields/NumberField.d.ts +1 -0
  22. package/lib/components/fields/NumberField.d.ts.map +1 -0
  23. package/lib/components/fields/NumberField.js +0 -1
  24. package/lib/components/fields/ObjectField.d.ts +1 -0
  25. package/lib/components/fields/ObjectField.d.ts.map +1 -0
  26. package/lib/components/fields/ObjectField.js +139 -145
  27. package/lib/components/fields/SchemaField.d.ts +1 -0
  28. package/lib/components/fields/SchemaField.d.ts.map +1 -0
  29. package/lib/components/fields/SchemaField.js +7 -9
  30. package/lib/components/fields/StringField.d.ts +1 -0
  31. package/lib/components/fields/StringField.d.ts.map +1 -0
  32. package/lib/components/fields/StringField.js +1 -3
  33. package/lib/components/fields/index.d.ts +1 -0
  34. package/lib/components/fields/index.d.ts.map +1 -0
  35. package/lib/components/fields/index.js +8 -9
  36. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
  37. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
  38. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
  39. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -0
  40. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
  41. package/lib/components/templates/ArrayFieldItemTemplate.js +0 -1
  42. package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -0
  43. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
  44. package/lib/components/templates/ArrayFieldTemplate.js +0 -1
  45. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
  46. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
  47. package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
  48. package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
  49. package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
  50. package/lib/components/templates/BaseInputTemplate.js +0 -1
  51. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
  52. package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
  53. package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
  54. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
  55. package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
  56. package/lib/components/templates/ButtonTemplates/IconButton.js +0 -1
  57. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
  58. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
  59. package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
  60. package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
  61. package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
  62. package/lib/components/templates/ButtonTemplates/index.js +3 -4
  63. package/lib/components/templates/DescriptionField.d.ts +1 -0
  64. package/lib/components/templates/DescriptionField.d.ts.map +1 -0
  65. package/lib/components/templates/DescriptionField.js +0 -1
  66. package/lib/components/templates/ErrorList.d.ts +1 -0
  67. package/lib/components/templates/ErrorList.d.ts.map +1 -0
  68. package/lib/components/templates/ErrorList.js +0 -1
  69. package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
  70. package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
  71. package/lib/components/templates/FieldErrorTemplate.js +0 -1
  72. package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
  73. package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
  74. package/lib/components/templates/FieldHelpTemplate.js +0 -1
  75. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
  76. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
  77. package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
  78. package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
  79. package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
  80. package/lib/components/templates/FieldTemplate/Label.js +0 -1
  81. package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
  82. package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
  83. package/lib/components/templates/FieldTemplate/index.js +1 -2
  84. package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
  85. package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
  86. package/lib/components/templates/ObjectFieldTemplate.js +0 -1
  87. package/lib/components/templates/TitleField.d.ts +1 -0
  88. package/lib/components/templates/TitleField.d.ts.map +1 -0
  89. package/lib/components/templates/TitleField.js +0 -1
  90. package/lib/components/templates/UnsupportedField.d.ts +1 -0
  91. package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
  92. package/lib/components/templates/UnsupportedField.js +0 -1
  93. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
  94. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
  95. package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -2
  96. package/lib/components/templates/index.d.ts +1 -0
  97. package/lib/components/templates/index.d.ts.map +1 -0
  98. package/lib/components/templates/index.js +15 -16
  99. package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
  100. package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
  101. package/lib/components/widgets/AltDateTimeWidget.js +0 -1
  102. package/lib/components/widgets/AltDateWidget.d.ts +1 -0
  103. package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
  104. package/lib/components/widgets/AltDateWidget.js +0 -1
  105. package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
  106. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
  107. package/lib/components/widgets/CheckboxWidget.js +1 -3
  108. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
  109. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
  110. package/lib/components/widgets/CheckboxesWidget.js +0 -1
  111. package/lib/components/widgets/ColorWidget.d.ts +1 -0
  112. package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
  113. package/lib/components/widgets/ColorWidget.js +0 -1
  114. package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
  115. package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
  116. package/lib/components/widgets/DateTimeWidget.js +0 -1
  117. package/lib/components/widgets/DateWidget.d.ts +1 -0
  118. package/lib/components/widgets/DateWidget.d.ts.map +1 -0
  119. package/lib/components/widgets/DateWidget.js +0 -1
  120. package/lib/components/widgets/EmailWidget.d.ts +1 -0
  121. package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
  122. package/lib/components/widgets/EmailWidget.js +0 -1
  123. package/lib/components/widgets/FileWidget.d.ts +1 -0
  124. package/lib/components/widgets/FileWidget.d.ts.map +1 -0
  125. package/lib/components/widgets/FileWidget.js +1 -3
  126. package/lib/components/widgets/HiddenWidget.d.ts +1 -0
  127. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
  128. package/lib/components/widgets/HiddenWidget.js +0 -1
  129. package/lib/components/widgets/PasswordWidget.d.ts +1 -0
  130. package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
  131. package/lib/components/widgets/PasswordWidget.js +0 -1
  132. package/lib/components/widgets/RadioWidget.d.ts +1 -0
  133. package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
  134. package/lib/components/widgets/RadioWidget.js +0 -1
  135. package/lib/components/widgets/RangeWidget.d.ts +1 -0
  136. package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
  137. package/lib/components/widgets/RangeWidget.js +0 -1
  138. package/lib/components/widgets/SelectWidget.d.ts +1 -0
  139. package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
  140. package/lib/components/widgets/SelectWidget.js +0 -1
  141. package/lib/components/widgets/TextWidget.d.ts +1 -0
  142. package/lib/components/widgets/TextWidget.d.ts.map +1 -0
  143. package/lib/components/widgets/TextWidget.js +0 -1
  144. package/lib/components/widgets/TextareaWidget.d.ts +1 -0
  145. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
  146. package/lib/components/widgets/TextareaWidget.js +0 -1
  147. package/lib/components/widgets/TimeWidget.d.ts +1 -0
  148. package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
  149. package/lib/components/widgets/TimeWidget.js +0 -1
  150. package/lib/components/widgets/URLWidget.d.ts +1 -0
  151. package/lib/components/widgets/URLWidget.d.ts.map +1 -0
  152. package/lib/components/widgets/URLWidget.js +0 -1
  153. package/lib/components/widgets/UpDownWidget.d.ts +1 -0
  154. package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
  155. package/lib/components/widgets/UpDownWidget.js +0 -1
  156. package/lib/components/widgets/index.d.ts +1 -0
  157. package/lib/components/widgets/index.d.ts.map +1 -0
  158. package/lib/components/widgets/index.js +19 -20
  159. package/lib/getDefaultRegistry.d.ts +1 -0
  160. package/lib/getDefaultRegistry.d.ts.map +1 -0
  161. package/lib/getDefaultRegistry.js +3 -4
  162. package/lib/index.d.ts +4 -3
  163. package/lib/index.d.ts.map +1 -0
  164. package/lib/index.js +3 -4
  165. package/lib/tsconfig.tsbuildinfo +1 -1
  166. package/lib/withTheme.d.ts +2 -1
  167. package/lib/withTheme.d.ts.map +1 -0
  168. package/lib/withTheme.js +6 -8
  169. package/package.json +31 -9
  170. package/src/tsconfig.json +14 -3
  171. package/lib/components/Form.js.map +0 -1
  172. package/lib/components/fields/ArrayField.js.map +0 -1
  173. package/lib/components/fields/BooleanField.js.map +0 -1
  174. package/lib/components/fields/MultiSchemaField.js.map +0 -1
  175. package/lib/components/fields/NullField.js.map +0 -1
  176. package/lib/components/fields/NumberField.js.map +0 -1
  177. package/lib/components/fields/ObjectField.js.map +0 -1
  178. package/lib/components/fields/SchemaField.js.map +0 -1
  179. package/lib/components/fields/StringField.js.map +0 -1
  180. package/lib/components/fields/index.js.map +0 -1
  181. package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
  182. package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
  183. package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
  184. package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
  185. package/lib/components/templates/BaseInputTemplate.js.map +0 -1
  186. package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
  187. package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
  188. package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
  189. package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
  190. package/lib/components/templates/DescriptionField.js.map +0 -1
  191. package/lib/components/templates/ErrorList.js.map +0 -1
  192. package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
  193. package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
  194. package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
  195. package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
  196. package/lib/components/templates/FieldTemplate/index.js.map +0 -1
  197. package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
  198. package/lib/components/templates/TitleField.js.map +0 -1
  199. package/lib/components/templates/UnsupportedField.js.map +0 -1
  200. package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
  201. package/lib/components/templates/index.js.map +0 -1
  202. package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
  203. package/lib/components/widgets/AltDateWidget.js.map +0 -1
  204. package/lib/components/widgets/CheckboxWidget.js.map +0 -1
  205. package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
  206. package/lib/components/widgets/ColorWidget.js.map +0 -1
  207. package/lib/components/widgets/DateTimeWidget.js.map +0 -1
  208. package/lib/components/widgets/DateWidget.js.map +0 -1
  209. package/lib/components/widgets/EmailWidget.js.map +0 -1
  210. package/lib/components/widgets/FileWidget.js.map +0 -1
  211. package/lib/components/widgets/HiddenWidget.js.map +0 -1
  212. package/lib/components/widgets/PasswordWidget.js.map +0 -1
  213. package/lib/components/widgets/RadioWidget.js.map +0 -1
  214. package/lib/components/widgets/RangeWidget.js.map +0 -1
  215. package/lib/components/widgets/SelectWidget.js.map +0 -1
  216. package/lib/components/widgets/TextWidget.js.map +0 -1
  217. package/lib/components/widgets/TextareaWidget.js.map +0 -1
  218. package/lib/components/widgets/TimeWidget.js.map +0 -1
  219. package/lib/components/widgets/URLWidget.js.map +0 -1
  220. package/lib/components/widgets/UpDownWidget.js.map +0 -1
  221. package/lib/components/widgets/index.js.map +0 -1
  222. package/lib/getDefaultRegistry.js.map +0 -1
  223. package/lib/index.js.map +0 -1
  224. package/lib/withTheme.js.map +0 -1
package/dist/index.js CHANGED
@@ -82,189 +82,6 @@ var ArrayField = class extends import_react.Component {
82
82
  */
83
83
  constructor(props) {
84
84
  super(props);
85
- /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
86
- * that the schema is fixed and allows additional items.
87
- */
88
- this._getNewFormDataRow = () => {
89
- const { schema, registry } = this.props;
90
- const { schemaUtils } = registry;
91
- let itemSchema = schema.items;
92
- if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
93
- itemSchema = schema.additionalItems;
94
- }
95
- return schemaUtils.getDefaultFormState(itemSchema);
96
- };
97
- /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
98
- * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
99
- * keyed data
100
- *
101
- * @param event - The event for the click
102
- */
103
- this.onAddClick = (event) => {
104
- this._handleAddClick(event);
105
- };
106
- /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
107
- * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
108
- * form data converted from the keyed data
109
- *
110
- * @param index - The index at which the add button is clicked
111
- */
112
- this.onAddIndexClick = (index) => {
113
- return (event) => {
114
- this._handleAddClick(event, index);
115
- };
116
- };
117
- /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
118
- * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
119
- * form data converted from the keyed data
120
- *
121
- * @param index - The index at which the copy button is clicked
122
- */
123
- this.onCopyIndexClick = (index) => {
124
- return (event) => {
125
- if (event) {
126
- event.preventDefault();
127
- }
128
- const { onChange, errorSchema } = this.props;
129
- const { keyedFormData } = this.state;
130
- let newErrorSchema;
131
- if (errorSchema) {
132
- newErrorSchema = {};
133
- for (const idx in errorSchema) {
134
- const i = parseInt(idx);
135
- if (i <= index) {
136
- (0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
137
- } else if (i > index) {
138
- (0, import_set.default)(newErrorSchema, [i + 1], errorSchema[idx]);
139
- }
140
- }
141
- }
142
- const newKeyedFormDataRow = {
143
- key: generateRowId(),
144
- item: (0, import_cloneDeep.default)(keyedFormData[index].item)
145
- };
146
- const newKeyedFormData = [...keyedFormData];
147
- if (index !== void 0) {
148
- newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
149
- } else {
150
- newKeyedFormData.push(newKeyedFormDataRow);
151
- }
152
- this.setState(
153
- {
154
- keyedFormData: newKeyedFormData,
155
- updatedKeyedFormData: true
156
- },
157
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
158
- );
159
- };
160
- };
161
- /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
162
- * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
163
- * from the keyed data
164
- *
165
- * @param index - The index at which the remove button is clicked
166
- */
167
- this.onDropIndexClick = (index) => {
168
- return (event) => {
169
- if (event) {
170
- event.preventDefault();
171
- }
172
- const { onChange, errorSchema } = this.props;
173
- const { keyedFormData } = this.state;
174
- let newErrorSchema;
175
- if (errorSchema) {
176
- newErrorSchema = {};
177
- for (const idx in errorSchema) {
178
- const i = parseInt(idx);
179
- if (i < index) {
180
- (0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
181
- } else if (i > index) {
182
- (0, import_set.default)(newErrorSchema, [i - 1], errorSchema[idx]);
183
- }
184
- }
185
- }
186
- const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
187
- this.setState(
188
- {
189
- keyedFormData: newKeyedFormData,
190
- updatedKeyedFormData: true
191
- },
192
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
193
- );
194
- };
195
- };
196
- /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
197
- * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
198
- * plain form data converted from the keyed data
199
- *
200
- * @param index - The index of the item to move
201
- * @param newIndex - The index to where the item is to be moved
202
- */
203
- this.onReorderClick = (index, newIndex) => {
204
- return (event) => {
205
- if (event) {
206
- event.preventDefault();
207
- event.currentTarget.blur();
208
- }
209
- const { onChange, errorSchema } = this.props;
210
- let newErrorSchema;
211
- if (errorSchema) {
212
- newErrorSchema = {};
213
- for (const idx in errorSchema) {
214
- const i = parseInt(idx);
215
- if (i == index) {
216
- (0, import_set.default)(newErrorSchema, [newIndex], errorSchema[index]);
217
- } else if (i == newIndex) {
218
- (0, import_set.default)(newErrorSchema, [index], errorSchema[newIndex]);
219
- } else {
220
- (0, import_set.default)(newErrorSchema, [idx], errorSchema[i]);
221
- }
222
- }
223
- }
224
- const { keyedFormData } = this.state;
225
- function reOrderArray() {
226
- const _newKeyedFormData = keyedFormData.slice();
227
- _newKeyedFormData.splice(index, 1);
228
- _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
229
- return _newKeyedFormData;
230
- }
231
- const newKeyedFormData = reOrderArray();
232
- this.setState(
233
- {
234
- keyedFormData: newKeyedFormData
235
- },
236
- () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
237
- );
238
- };
239
- };
240
- /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
241
- * `onChange` callback with the updated form data
242
- *
243
- * @param index - The index of the item being changed
244
- */
245
- this.onChangeForIndex = (index) => {
246
- return (value, newErrorSchema, id) => {
247
- const { formData, onChange, errorSchema } = this.props;
248
- const arrayData = Array.isArray(formData) ? formData : [];
249
- const newFormData = arrayData.map((item, i) => {
250
- const jsonValue = typeof value === "undefined" ? null : value;
251
- return index === i ? jsonValue : item;
252
- });
253
- onChange(
254
- newFormData,
255
- errorSchema && errorSchema && {
256
- ...errorSchema,
257
- [index]: newErrorSchema
258
- },
259
- id
260
- );
261
- };
262
- };
263
- /** Callback handler used to change the value for a checkbox */
264
- this.onSelectChange = (value) => {
265
- const { onChange, idSchema } = this.props;
266
- onChange(value, void 0, idSchema && idSchema.$id);
267
- };
268
85
  const { formData = [] } = props;
269
86
  const keyedFormData = generateKeyedFormData(formData);
270
87
  this.state = {
@@ -339,6 +156,18 @@ var ArrayField = class extends import_react.Component {
339
156
  }
340
157
  return addable;
341
158
  }
159
+ /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
160
+ * that the schema is fixed and allows additional items.
161
+ */
162
+ _getNewFormDataRow = () => {
163
+ const { schema, registry } = this.props;
164
+ const { schemaUtils } = registry;
165
+ let itemSchema = schema.items;
166
+ if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
167
+ itemSchema = schema.additionalItems;
168
+ }
169
+ return schemaUtils.getDefaultFormState(itemSchema);
170
+ };
342
171
  /** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
343
172
  * either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
344
173
  * the state, and then returning `onChange()` with the plain form data converted from the keyed data
@@ -382,6 +211,177 @@ var ArrayField = class extends import_react.Component {
382
211
  () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
383
212
  );
384
213
  }
214
+ /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
215
+ * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
216
+ * keyed data
217
+ *
218
+ * @param event - The event for the click
219
+ */
220
+ onAddClick = (event) => {
221
+ this._handleAddClick(event);
222
+ };
223
+ /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
224
+ * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
225
+ * form data converted from the keyed data
226
+ *
227
+ * @param index - The index at which the add button is clicked
228
+ */
229
+ onAddIndexClick = (index) => {
230
+ return (event) => {
231
+ this._handleAddClick(event, index);
232
+ };
233
+ };
234
+ /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
235
+ * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
236
+ * form data converted from the keyed data
237
+ *
238
+ * @param index - The index at which the copy button is clicked
239
+ */
240
+ onCopyIndexClick = (index) => {
241
+ return (event) => {
242
+ if (event) {
243
+ event.preventDefault();
244
+ }
245
+ const { onChange, errorSchema } = this.props;
246
+ const { keyedFormData } = this.state;
247
+ let newErrorSchema;
248
+ if (errorSchema) {
249
+ newErrorSchema = {};
250
+ for (const idx in errorSchema) {
251
+ const i = parseInt(idx);
252
+ if (i <= index) {
253
+ (0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
254
+ } else if (i > index) {
255
+ (0, import_set.default)(newErrorSchema, [i + 1], errorSchema[idx]);
256
+ }
257
+ }
258
+ }
259
+ const newKeyedFormDataRow = {
260
+ key: generateRowId(),
261
+ item: (0, import_cloneDeep.default)(keyedFormData[index].item)
262
+ };
263
+ const newKeyedFormData = [...keyedFormData];
264
+ if (index !== void 0) {
265
+ newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
266
+ } else {
267
+ newKeyedFormData.push(newKeyedFormDataRow);
268
+ }
269
+ this.setState(
270
+ {
271
+ keyedFormData: newKeyedFormData,
272
+ updatedKeyedFormData: true
273
+ },
274
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
275
+ );
276
+ };
277
+ };
278
+ /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
279
+ * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
280
+ * from the keyed data
281
+ *
282
+ * @param index - The index at which the remove button is clicked
283
+ */
284
+ onDropIndexClick = (index) => {
285
+ return (event) => {
286
+ if (event) {
287
+ event.preventDefault();
288
+ }
289
+ const { onChange, errorSchema } = this.props;
290
+ const { keyedFormData } = this.state;
291
+ let newErrorSchema;
292
+ if (errorSchema) {
293
+ newErrorSchema = {};
294
+ for (const idx in errorSchema) {
295
+ const i = parseInt(idx);
296
+ if (i < index) {
297
+ (0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
298
+ } else if (i > index) {
299
+ (0, import_set.default)(newErrorSchema, [i - 1], errorSchema[idx]);
300
+ }
301
+ }
302
+ }
303
+ const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
304
+ this.setState(
305
+ {
306
+ keyedFormData: newKeyedFormData,
307
+ updatedKeyedFormData: true
308
+ },
309
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
310
+ );
311
+ };
312
+ };
313
+ /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
314
+ * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
315
+ * plain form data converted from the keyed data
316
+ *
317
+ * @param index - The index of the item to move
318
+ * @param newIndex - The index to where the item is to be moved
319
+ */
320
+ onReorderClick = (index, newIndex) => {
321
+ return (event) => {
322
+ if (event) {
323
+ event.preventDefault();
324
+ event.currentTarget.blur();
325
+ }
326
+ const { onChange, errorSchema } = this.props;
327
+ let newErrorSchema;
328
+ if (errorSchema) {
329
+ newErrorSchema = {};
330
+ for (const idx in errorSchema) {
331
+ const i = parseInt(idx);
332
+ if (i == index) {
333
+ (0, import_set.default)(newErrorSchema, [newIndex], errorSchema[index]);
334
+ } else if (i == newIndex) {
335
+ (0, import_set.default)(newErrorSchema, [index], errorSchema[newIndex]);
336
+ } else {
337
+ (0, import_set.default)(newErrorSchema, [idx], errorSchema[i]);
338
+ }
339
+ }
340
+ }
341
+ const { keyedFormData } = this.state;
342
+ function reOrderArray() {
343
+ const _newKeyedFormData = keyedFormData.slice();
344
+ _newKeyedFormData.splice(index, 1);
345
+ _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
346
+ return _newKeyedFormData;
347
+ }
348
+ const newKeyedFormData = reOrderArray();
349
+ this.setState(
350
+ {
351
+ keyedFormData: newKeyedFormData
352
+ },
353
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
354
+ );
355
+ };
356
+ };
357
+ /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
358
+ * `onChange` callback with the updated form data
359
+ *
360
+ * @param index - The index of the item being changed
361
+ */
362
+ onChangeForIndex = (index) => {
363
+ return (value, newErrorSchema, id) => {
364
+ const { formData, onChange, errorSchema } = this.props;
365
+ const arrayData = Array.isArray(formData) ? formData : [];
366
+ const newFormData = arrayData.map((item, i) => {
367
+ const jsonValue = typeof value === "undefined" ? null : value;
368
+ return index === i ? jsonValue : item;
369
+ });
370
+ onChange(
371
+ newFormData,
372
+ errorSchema && errorSchema && {
373
+ ...errorSchema,
374
+ [index]: newErrorSchema
375
+ },
376
+ id
377
+ );
378
+ };
379
+ };
380
+ /** Callback handler used to change the value for a checkbox */
381
+ onSelectChange = (value) => {
382
+ const { onChange, idSchema } = this.props;
383
+ onChange(value, void 0, idSchema && idSchema.$id);
384
+ };
385
385
  /** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
386
386
  */
387
387
  render() {
@@ -943,30 +943,6 @@ var AnyOfField = class extends import_react2.Component {
943
943
  */
944
944
  constructor(props) {
945
945
  super(props);
946
- /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
947
- * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
948
- * the `onChange` handler.
949
- *
950
- * @param option - The new option value being selected
951
- */
952
- this.onOptionChange = (option) => {
953
- const { selectedOption, retrievedOptions } = this.state;
954
- const { formData, onChange, registry } = this.props;
955
- const { schemaUtils } = registry;
956
- const intOption = option !== void 0 ? parseInt(option, 10) : -1;
957
- if (intOption === selectedOption) {
958
- return;
959
- }
960
- const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
961
- const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
962
- let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
963
- if (newOption) {
964
- newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
965
- }
966
- this.setState({ selectedOption: intOption }, () => {
967
- onChange(newFormData, void 0, this.getFieldId());
968
- });
969
- };
970
946
  const {
971
947
  formData,
972
948
  options,
@@ -1021,6 +997,30 @@ var AnyOfField = class extends import_react2.Component {
1021
997
  const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
1022
998
  return option;
1023
999
  }
1000
+ /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
1001
+ * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
1002
+ * the `onChange` handler.
1003
+ *
1004
+ * @param option - The new option value being selected
1005
+ */
1006
+ onOptionChange = (option) => {
1007
+ const { selectedOption, retrievedOptions } = this.state;
1008
+ const { formData, onChange, registry } = this.props;
1009
+ const { schemaUtils } = registry;
1010
+ const intOption = option !== void 0 ? parseInt(option, 10) : -1;
1011
+ if (intOption === selectedOption) {
1012
+ return;
1013
+ }
1014
+ const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
1015
+ const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
1016
+ let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
1017
+ if (newOption) {
1018
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
1019
+ }
1020
+ this.setState({ selectedOption: intOption }, () => {
1021
+ onChange(newFormData, void 0, this.getFieldId());
1022
+ });
1023
+ };
1024
1024
  getFieldId() {
1025
1025
  const { idSchema, schema } = this.props;
1026
1026
  return `${idSchema.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
@@ -1163,138 +1163,11 @@ var import_set2 = __toESM(require("lodash/set"));
1163
1163
  var import_unset = __toESM(require("lodash/unset"));
1164
1164
  var import_jsx_runtime5 = require("react/jsx-runtime");
1165
1165
  var ObjectField = class extends import_react4.Component {
1166
- constructor() {
1167
- super(...arguments);
1168
- /** Set up the initial state */
1169
- this.state = {
1170
- wasPropertyKeyModified: false,
1171
- additionalProperties: {}
1172
- };
1173
- /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1174
- * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1175
- * formData.
1176
- *
1177
- * @param name - The name of the property
1178
- * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1179
- * @returns - The onPropertyChange callback for the `name` property
1180
- */
1181
- this.onPropertyChange = (name, addedByAdditionalProperties = false) => {
1182
- return (value, newErrorSchema, id) => {
1183
- const { formData, onChange, errorSchema } = this.props;
1184
- if (value === void 0 && addedByAdditionalProperties) {
1185
- value = "";
1186
- }
1187
- const newFormData = { ...formData, [name]: value };
1188
- onChange(
1189
- newFormData,
1190
- errorSchema && errorSchema && {
1191
- ...errorSchema,
1192
- [name]: newErrorSchema
1193
- },
1194
- id
1195
- );
1196
- };
1197
- };
1198
- /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1199
- * and calls the `onChange` callback with it
1200
- *
1201
- * @param key - The key for which the drop callback is desired
1202
- * @returns - The drop property click callback
1203
- */
1204
- this.onDropPropertyClick = (key) => {
1205
- return (event) => {
1206
- event.preventDefault();
1207
- const { onChange, formData } = this.props;
1208
- const copiedFormData = { ...formData };
1209
- (0, import_unset.default)(copiedFormData, key);
1210
- onChange(copiedFormData);
1211
- };
1212
- };
1213
- /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1214
- * that is already not assigned is found.
1215
- *
1216
- * @param preferredKey - The preferred name of a new key
1217
- * @param [formData] - The form data in which to check if the desired key already exists
1218
- * @returns - The name of the next available key from `preferredKey`
1219
- */
1220
- this.getAvailableKey = (preferredKey, formData) => {
1221
- const { uiSchema, registry } = this.props;
1222
- const { duplicateKeySuffixSeparator = "-" } = (0, import_utils5.getUiOptions)(uiSchema, registry.globalUiOptions);
1223
- let index = 0;
1224
- let newKey = preferredKey;
1225
- while ((0, import_has.default)(formData, newKey)) {
1226
- newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1227
- }
1228
- return newKey;
1229
- };
1230
- /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
1231
- * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
1232
- *
1233
- * @param oldValue - The old value of a field
1234
- * @returns - The key change callback function
1235
- */
1236
- this.onKeyChange = (oldValue) => {
1237
- return (value, newErrorSchema) => {
1238
- if (oldValue === value) {
1239
- return;
1240
- }
1241
- const { formData, onChange, errorSchema } = this.props;
1242
- value = this.getAvailableKey(value, formData);
1243
- const newFormData = {
1244
- ...formData
1245
- };
1246
- const newKeys = { [oldValue]: value };
1247
- const keyValues = Object.keys(newFormData).map((key) => {
1248
- const newKey = newKeys[key] || key;
1249
- return { [newKey]: newFormData[key] };
1250
- });
1251
- const renamedObj = Object.assign({}, ...keyValues);
1252
- this.setState({ wasPropertyKeyModified: true });
1253
- onChange(
1254
- renamedObj,
1255
- errorSchema && errorSchema && {
1256
- ...errorSchema,
1257
- [value]: newErrorSchema
1258
- }
1259
- );
1260
- };
1261
- };
1262
- /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
1263
- * default data for that field has been added to the formData.
1264
- *
1265
- * @param schema - The schema element to which the new property is being added
1266
- */
1267
- this.handleAddClick = (schema) => () => {
1268
- if (!schema.additionalProperties) {
1269
- return;
1270
- }
1271
- const { formData, onChange, registry } = this.props;
1272
- const newFormData = { ...formData };
1273
- let type = void 0;
1274
- let constValue = void 0;
1275
- let defaultValue = void 0;
1276
- if ((0, import_isObject3.default)(schema.additionalProperties)) {
1277
- type = schema.additionalProperties.type;
1278
- constValue = schema.additionalProperties.const;
1279
- defaultValue = schema.additionalProperties.default;
1280
- let apSchema = schema.additionalProperties;
1281
- if (import_utils5.REF_KEY in apSchema) {
1282
- const { schemaUtils } = registry;
1283
- apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils5.REF_KEY] }, formData);
1284
- type = apSchema.type;
1285
- constValue = apSchema.const;
1286
- defaultValue = apSchema.default;
1287
- }
1288
- if (!type && (import_utils5.ANY_OF_KEY in apSchema || import_utils5.ONE_OF_KEY in apSchema)) {
1289
- type = "object";
1290
- }
1291
- }
1292
- const newKey = this.getAvailableKey("newKey", newFormData);
1293
- const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
1294
- (0, import_set2.default)(newFormData, newKey, newValue);
1295
- onChange(newFormData);
1296
- };
1297
- }
1166
+ /** Set up the initial state */
1167
+ state = {
1168
+ wasPropertyKeyModified: false,
1169
+ additionalProperties: {}
1170
+ };
1298
1171
  /** Returns a flag indicating whether the `name` field is required in the object schema
1299
1172
  *
1300
1173
  * @param name - The name of the field to check for required-ness
@@ -1304,6 +1177,95 @@ var ObjectField = class extends import_react4.Component {
1304
1177
  const { schema } = this.props;
1305
1178
  return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1306
1179
  }
1180
+ /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1181
+ * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1182
+ * formData.
1183
+ *
1184
+ * @param name - The name of the property
1185
+ * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1186
+ * @returns - The onPropertyChange callback for the `name` property
1187
+ */
1188
+ onPropertyChange = (name, addedByAdditionalProperties = false) => {
1189
+ return (value, newErrorSchema, id) => {
1190
+ const { formData, onChange, errorSchema } = this.props;
1191
+ if (value === void 0 && addedByAdditionalProperties) {
1192
+ value = "";
1193
+ }
1194
+ const newFormData = { ...formData, [name]: value };
1195
+ onChange(
1196
+ newFormData,
1197
+ errorSchema && errorSchema && {
1198
+ ...errorSchema,
1199
+ [name]: newErrorSchema
1200
+ },
1201
+ id
1202
+ );
1203
+ };
1204
+ };
1205
+ /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1206
+ * and calls the `onChange` callback with it
1207
+ *
1208
+ * @param key - The key for which the drop callback is desired
1209
+ * @returns - The drop property click callback
1210
+ */
1211
+ onDropPropertyClick = (key) => {
1212
+ return (event) => {
1213
+ event.preventDefault();
1214
+ const { onChange, formData } = this.props;
1215
+ const copiedFormData = { ...formData };
1216
+ (0, import_unset.default)(copiedFormData, key);
1217
+ onChange(copiedFormData);
1218
+ };
1219
+ };
1220
+ /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1221
+ * that is already not assigned is found.
1222
+ *
1223
+ * @param preferredKey - The preferred name of a new key
1224
+ * @param [formData] - The form data in which to check if the desired key already exists
1225
+ * @returns - The name of the next available key from `preferredKey`
1226
+ */
1227
+ getAvailableKey = (preferredKey, formData) => {
1228
+ const { uiSchema, registry } = this.props;
1229
+ const { duplicateKeySuffixSeparator = "-" } = (0, import_utils5.getUiOptions)(uiSchema, registry.globalUiOptions);
1230
+ let index = 0;
1231
+ let newKey = preferredKey;
1232
+ while ((0, import_has.default)(formData, newKey)) {
1233
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1234
+ }
1235
+ return newKey;
1236
+ };
1237
+ /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
1238
+ * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
1239
+ *
1240
+ * @param oldValue - The old value of a field
1241
+ * @returns - The key change callback function
1242
+ */
1243
+ onKeyChange = (oldValue) => {
1244
+ return (value, newErrorSchema) => {
1245
+ if (oldValue === value) {
1246
+ return;
1247
+ }
1248
+ const { formData, onChange, errorSchema } = this.props;
1249
+ value = this.getAvailableKey(value, formData);
1250
+ const newFormData = {
1251
+ ...formData
1252
+ };
1253
+ const newKeys = { [oldValue]: value };
1254
+ const keyValues = Object.keys(newFormData).map((key) => {
1255
+ const newKey = newKeys[key] || key;
1256
+ return { [newKey]: newFormData[key] };
1257
+ });
1258
+ const renamedObj = Object.assign({}, ...keyValues);
1259
+ this.setState({ wasPropertyKeyModified: true });
1260
+ onChange(
1261
+ renamedObj,
1262
+ errorSchema && errorSchema && {
1263
+ ...errorSchema,
1264
+ [value]: newErrorSchema
1265
+ }
1266
+ );
1267
+ };
1268
+ };
1307
1269
  /** Returns a default value to be used for a new additional schema property of the given `type`
1308
1270
  *
1309
1271
  * @param type - The type of the new additional schema property
@@ -1328,6 +1290,41 @@ var ObjectField = class extends import_react4.Component {
1328
1290
  return translateString(import_utils5.TranslatableString.NewStringDefault);
1329
1291
  }
1330
1292
  }
1293
+ /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
1294
+ * default data for that field has been added to the formData.
1295
+ *
1296
+ * @param schema - The schema element to which the new property is being added
1297
+ */
1298
+ handleAddClick = (schema) => () => {
1299
+ if (!schema.additionalProperties) {
1300
+ return;
1301
+ }
1302
+ const { formData, onChange, registry } = this.props;
1303
+ const newFormData = { ...formData };
1304
+ let type = void 0;
1305
+ let constValue = void 0;
1306
+ let defaultValue = void 0;
1307
+ if ((0, import_isObject3.default)(schema.additionalProperties)) {
1308
+ type = schema.additionalProperties.type;
1309
+ constValue = schema.additionalProperties.const;
1310
+ defaultValue = schema.additionalProperties.default;
1311
+ let apSchema = schema.additionalProperties;
1312
+ if (import_utils5.REF_KEY in apSchema) {
1313
+ const { schemaUtils } = registry;
1314
+ apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils5.REF_KEY] }, formData);
1315
+ type = apSchema.type;
1316
+ constValue = apSchema.const;
1317
+ defaultValue = apSchema.default;
1318
+ }
1319
+ if (!type && (import_utils5.ANY_OF_KEY in apSchema || import_utils5.ONE_OF_KEY in apSchema)) {
1320
+ type = "object";
1321
+ }
1322
+ }
1323
+ const newKey = this.getAvailableKey("newKey", newFormData);
1324
+ const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
1325
+ (0, import_set2.default)(newFormData, newKey, newValue);
1326
+ onChange(newFormData);
1327
+ };
1331
1328
  /** Renders the `ObjectField` from the given props
1332
1329
  */
1333
1330
  render() {
@@ -3245,6 +3242,10 @@ function getDefaultRegistry() {
3245
3242
  // src/components/Form.tsx
3246
3243
  var import_jsx_runtime45 = require("react/jsx-runtime");
3247
3244
  var Form = class extends import_react17.Component {
3245
+ /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
3246
+ * provide any possible type here
3247
+ */
3248
+ formElement;
3248
3249
  /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
3249
3250
  * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
3250
3251
  * state construction.
@@ -3253,268 +3254,6 @@ var Form = class extends import_react17.Component {
3253
3254
  */
3254
3255
  constructor(props) {
3255
3256
  super(props);
3256
- /** Returns the `formData` with only the elements specified in the `fields` list
3257
- *
3258
- * @param formData - The data for the `Form`
3259
- * @param fields - The fields to keep while filtering
3260
- */
3261
- this.getUsedFormData = (formData, fields2) => {
3262
- if (fields2.length === 0 && typeof formData !== "object") {
3263
- return formData;
3264
- }
3265
- const data = (0, import_pick.default)(formData, fields2);
3266
- if (Array.isArray(formData)) {
3267
- return Object.keys(data).map((key) => data[key]);
3268
- }
3269
- return data;
3270
- };
3271
- /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
3272
- *
3273
- * @param pathSchema - The `PathSchema` object for the form
3274
- * @param [formData] - The form data to use while checking for empty objects/arrays
3275
- */
3276
- this.getFieldNames = (pathSchema, formData) => {
3277
- const getAllPaths = (_obj, acc = [], paths = [[]]) => {
3278
- Object.keys(_obj).forEach((key) => {
3279
- if (typeof _obj[key] === "object") {
3280
- const newPaths = paths.map((path) => [...path, key]);
3281
- if (_obj[key][import_utils39.RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][import_utils39.NAME_KEY] !== "") {
3282
- acc.push(_obj[key][import_utils39.NAME_KEY]);
3283
- } else {
3284
- getAllPaths(_obj[key], acc, newPaths);
3285
- }
3286
- } else if (key === import_utils39.NAME_KEY && _obj[key] !== "") {
3287
- paths.forEach((path) => {
3288
- const formValue = (0, import_get4.default)(formData, path);
3289
- if (typeof formValue !== "object" || (0, import_isEmpty2.default)(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
3290
- acc.push(path);
3291
- }
3292
- });
3293
- }
3294
- });
3295
- return acc;
3296
- };
3297
- return getAllPaths(pathSchema);
3298
- };
3299
- /** Returns the `formData` after filtering to remove any extra data not in a form field
3300
- *
3301
- * @param formData - The data for the `Form`
3302
- * @returns The `formData` after omitting extra data
3303
- */
3304
- this.omitExtraData = (formData) => {
3305
- const { schema, schemaUtils } = this.state;
3306
- const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
3307
- const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
3308
- const fieldNames = this.getFieldNames(pathSchema, formData);
3309
- const newFormData = this.getUsedFormData(formData, fieldNames);
3310
- return newFormData;
3311
- };
3312
- /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
3313
- * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
3314
- * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
3315
- * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
3316
- * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
3317
- * callback will be called if specified with the updated state.
3318
- *
3319
- * @param formData - The new form data from a change to a field
3320
- * @param newErrorSchema - The new `ErrorSchema` based on the field change
3321
- * @param id - The id of the field that caused the change
3322
- */
3323
- this.onChange = (formData, newErrorSchema, id) => {
3324
- const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
3325
- const { schemaUtils, schema } = this.state;
3326
- let retrievedSchema = this.state.retrievedSchema;
3327
- if ((0, import_utils39.isObject)(formData) || Array.isArray(formData)) {
3328
- const newState = this.getStateFromProps(this.props, formData);
3329
- formData = newState.formData;
3330
- retrievedSchema = newState.retrievedSchema;
3331
- }
3332
- const mustValidate = !noValidate && liveValidate;
3333
- let state = { formData, schema };
3334
- let newFormData = formData;
3335
- if (omitExtraData === true && liveOmit === true) {
3336
- newFormData = this.omitExtraData(formData);
3337
- state = {
3338
- formData: newFormData
3339
- };
3340
- }
3341
- if (mustValidate) {
3342
- const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
3343
- let errors = schemaValidation.errors;
3344
- let errorSchema = schemaValidation.errorSchema;
3345
- const schemaValidationErrors = errors;
3346
- const schemaValidationErrorSchema = errorSchema;
3347
- if (extraErrors) {
3348
- const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
3349
- errorSchema = merged.errorSchema;
3350
- errors = merged.errors;
3351
- }
3352
- if (newErrorSchema) {
3353
- const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
3354
- errorSchema = (0, import_utils39.mergeObjects)(errorSchema, filteredErrors, "preventDuplicates");
3355
- }
3356
- state = {
3357
- formData: newFormData,
3358
- errors,
3359
- errorSchema,
3360
- schemaValidationErrors,
3361
- schemaValidationErrorSchema
3362
- };
3363
- } else if (!noValidate && newErrorSchema) {
3364
- const errorSchema = extraErrors ? (0, import_utils39.mergeObjects)(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
3365
- state = {
3366
- formData: newFormData,
3367
- errorSchema,
3368
- errors: (0, import_utils39.toErrorList)(errorSchema)
3369
- };
3370
- }
3371
- this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
3372
- };
3373
- /**
3374
- * Callback function to handle reset form data.
3375
- * - Reset all fields with default values.
3376
- * - Reset validations and errors
3377
- *
3378
- */
3379
- this.reset = () => {
3380
- const { onChange } = this.props;
3381
- const newState = this.getStateFromProps(this.props, void 0);
3382
- const newFormData = newState.formData;
3383
- const state = {
3384
- formData: newFormData,
3385
- errorSchema: {},
3386
- errors: [],
3387
- schemaValidationErrors: [],
3388
- schemaValidationErrorSchema: {}
3389
- };
3390
- this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
3391
- };
3392
- /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
3393
- * was provided.
3394
- *
3395
- * @param id - The unique `id` of the field that was blurred
3396
- * @param data - The data associated with the field that was blurred
3397
- */
3398
- this.onBlur = (id, data) => {
3399
- const { onBlur } = this.props;
3400
- if (onBlur) {
3401
- onBlur(id, data);
3402
- }
3403
- };
3404
- /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
3405
- * was provided.
3406
- *
3407
- * @param id - The unique `id` of the field that was focused
3408
- * @param data - The data associated with the field that was focused
3409
- */
3410
- this.onFocus = (id, data) => {
3411
- const { onFocus } = this.props;
3412
- if (onFocus) {
3413
- onFocus(id, data);
3414
- }
3415
- };
3416
- /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
3417
- * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
3418
- * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
3419
- * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
3420
- * back the `onSubmit` callback if it was provided.
3421
- *
3422
- * @param event - The submit HTML form event
3423
- */
3424
- this.onSubmit = (event) => {
3425
- event.preventDefault();
3426
- if (event.target !== event.currentTarget) {
3427
- return;
3428
- }
3429
- event.persist();
3430
- const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
3431
- let { formData: newFormData } = this.state;
3432
- if (omitExtraData === true) {
3433
- newFormData = this.omitExtraData(newFormData);
3434
- }
3435
- if (noValidate || this.validateFormWithFormData(newFormData)) {
3436
- const errorSchema = extraErrors || {};
3437
- const errors = extraErrors ? (0, import_utils39.toErrorList)(extraErrors) : [];
3438
- this.setState(
3439
- {
3440
- formData: newFormData,
3441
- errors,
3442
- errorSchema,
3443
- schemaValidationErrors: [],
3444
- schemaValidationErrorSchema: {}
3445
- },
3446
- () => {
3447
- if (onSubmit) {
3448
- onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
3449
- }
3450
- }
3451
- );
3452
- }
3453
- };
3454
- /** Provides a function that can be used to programmatically submit the `Form` */
3455
- this.submit = () => {
3456
- if (this.formElement.current) {
3457
- const submitCustomEvent = new CustomEvent("submit", {
3458
- cancelable: true
3459
- });
3460
- submitCustomEvent.preventDefault();
3461
- this.formElement.current.dispatchEvent(submitCustomEvent);
3462
- this.formElement.current.requestSubmit();
3463
- }
3464
- };
3465
- /** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
3466
- * If `onError` is provided, then it will be called with the list of errors.
3467
- *
3468
- * @param formData - The form data to validate
3469
- * @returns - True if the form is valid, false otherwise.
3470
- */
3471
- this.validateFormWithFormData = (formData) => {
3472
- const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
3473
- const { errors: prevErrors } = this.state;
3474
- const schemaValidation = this.validate(formData);
3475
- let errors = schemaValidation.errors;
3476
- let errorSchema = schemaValidation.errorSchema;
3477
- const schemaValidationErrors = errors;
3478
- const schemaValidationErrorSchema = errorSchema;
3479
- const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
3480
- if (hasError) {
3481
- if (extraErrors) {
3482
- const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
3483
- errorSchema = merged.errorSchema;
3484
- errors = merged.errors;
3485
- }
3486
- if (focusOnFirstError) {
3487
- if (typeof focusOnFirstError === "function") {
3488
- focusOnFirstError(errors[0]);
3489
- } else {
3490
- this.focusOnError(errors[0]);
3491
- }
3492
- }
3493
- this.setState(
3494
- {
3495
- errors,
3496
- errorSchema,
3497
- schemaValidationErrors,
3498
- schemaValidationErrorSchema
3499
- },
3500
- () => {
3501
- if (onError) {
3502
- onError(errors);
3503
- } else {
3504
- console.error("Form validation failed", errors);
3505
- }
3506
- }
3507
- );
3508
- } else if (prevErrors.length > 0) {
3509
- this.setState({
3510
- errors: [],
3511
- errorSchema: {},
3512
- schemaValidationErrors: [],
3513
- schemaValidationErrorSchema: {}
3514
- });
3515
- }
3516
- return !hasError;
3517
- };
3518
3257
  if (!props.validator) {
3519
3258
  throw new Error("A validator is required for Form functionality to work");
3520
3259
  }
@@ -3758,6 +3497,62 @@ var Form = class extends import_react17.Component {
3758
3497
  }
3759
3498
  return null;
3760
3499
  }
3500
+ /** Returns the `formData` with only the elements specified in the `fields` list
3501
+ *
3502
+ * @param formData - The data for the `Form`
3503
+ * @param fields - The fields to keep while filtering
3504
+ */
3505
+ getUsedFormData = (formData, fields2) => {
3506
+ if (fields2.length === 0 && typeof formData !== "object") {
3507
+ return formData;
3508
+ }
3509
+ const data = (0, import_pick.default)(formData, fields2);
3510
+ if (Array.isArray(formData)) {
3511
+ return Object.keys(data).map((key) => data[key]);
3512
+ }
3513
+ return data;
3514
+ };
3515
+ /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
3516
+ *
3517
+ * @param pathSchema - The `PathSchema` object for the form
3518
+ * @param [formData] - The form data to use while checking for empty objects/arrays
3519
+ */
3520
+ getFieldNames = (pathSchema, formData) => {
3521
+ const getAllPaths = (_obj, acc = [], paths = [[]]) => {
3522
+ Object.keys(_obj).forEach((key) => {
3523
+ if (typeof _obj[key] === "object") {
3524
+ const newPaths = paths.map((path) => [...path, key]);
3525
+ if (_obj[key][import_utils39.RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][import_utils39.NAME_KEY] !== "") {
3526
+ acc.push(_obj[key][import_utils39.NAME_KEY]);
3527
+ } else {
3528
+ getAllPaths(_obj[key], acc, newPaths);
3529
+ }
3530
+ } else if (key === import_utils39.NAME_KEY && _obj[key] !== "") {
3531
+ paths.forEach((path) => {
3532
+ const formValue = (0, import_get4.default)(formData, path);
3533
+ if (typeof formValue !== "object" || (0, import_isEmpty2.default)(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
3534
+ acc.push(path);
3535
+ }
3536
+ });
3537
+ }
3538
+ });
3539
+ return acc;
3540
+ };
3541
+ return getAllPaths(pathSchema);
3542
+ };
3543
+ /** Returns the `formData` after filtering to remove any extra data not in a form field
3544
+ *
3545
+ * @param formData - The data for the `Form`
3546
+ * @returns The `formData` after omitting extra data
3547
+ */
3548
+ omitExtraData = (formData) => {
3549
+ const { schema, schemaUtils } = this.state;
3550
+ const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
3551
+ const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
3552
+ const fieldNames = this.getFieldNames(pathSchema, formData);
3553
+ const newFormData = this.getUsedFormData(formData, fieldNames);
3554
+ return newFormData;
3555
+ };
3761
3556
  // Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
3762
3557
  filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
3763
3558
  const { retrievedSchema, schemaUtils } = this.state;
@@ -3792,6 +3587,67 @@ var Form = class extends import_react17.Component {
3792
3587
  };
3793
3588
  return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
3794
3589
  }
3590
+ /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
3591
+ * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
3592
+ * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
3593
+ * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
3594
+ * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
3595
+ * callback will be called if specified with the updated state.
3596
+ *
3597
+ * @param formData - The new form data from a change to a field
3598
+ * @param newErrorSchema - The new `ErrorSchema` based on the field change
3599
+ * @param id - The id of the field that caused the change
3600
+ */
3601
+ onChange = (formData, newErrorSchema, id) => {
3602
+ const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
3603
+ const { schemaUtils, schema } = this.state;
3604
+ let retrievedSchema = this.state.retrievedSchema;
3605
+ if ((0, import_utils39.isObject)(formData) || Array.isArray(formData)) {
3606
+ const newState = this.getStateFromProps(this.props, formData);
3607
+ formData = newState.formData;
3608
+ retrievedSchema = newState.retrievedSchema;
3609
+ }
3610
+ const mustValidate = !noValidate && liveValidate;
3611
+ let state = { formData, schema };
3612
+ let newFormData = formData;
3613
+ if (omitExtraData === true && liveOmit === true) {
3614
+ newFormData = this.omitExtraData(formData);
3615
+ state = {
3616
+ formData: newFormData
3617
+ };
3618
+ }
3619
+ if (mustValidate) {
3620
+ const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
3621
+ let errors = schemaValidation.errors;
3622
+ let errorSchema = schemaValidation.errorSchema;
3623
+ const schemaValidationErrors = errors;
3624
+ const schemaValidationErrorSchema = errorSchema;
3625
+ if (extraErrors) {
3626
+ const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
3627
+ errorSchema = merged.errorSchema;
3628
+ errors = merged.errors;
3629
+ }
3630
+ if (newErrorSchema) {
3631
+ const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
3632
+ errorSchema = (0, import_utils39.mergeObjects)(errorSchema, filteredErrors, "preventDuplicates");
3633
+ }
3634
+ state = {
3635
+ formData: newFormData,
3636
+ errors,
3637
+ errorSchema,
3638
+ schemaValidationErrors,
3639
+ schemaValidationErrorSchema
3640
+ };
3641
+ } else if (!noValidate && newErrorSchema) {
3642
+ const errorSchema = extraErrors ? (0, import_utils39.mergeObjects)(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
3643
+ state = {
3644
+ formData: newFormData,
3645
+ errorSchema,
3646
+ errors: (0, import_utils39.toErrorList)(errorSchema)
3647
+ };
3648
+ }
3649
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
3650
+ };
3795
3651
  /**
3796
3652
  * If the retrievedSchema has changed the new retrievedSchema is returned.
3797
3653
  * Otherwise, the old retrievedSchema is returned to persist reference.
@@ -3805,6 +3661,87 @@ var Form = class extends import_react17.Component {
3805
3661
  const isTheSame = (0, import_utils39.deepEquals)(retrievedSchema, this.state?.retrievedSchema);
3806
3662
  return isTheSame ? this.state.retrievedSchema : retrievedSchema;
3807
3663
  }
3664
+ /**
3665
+ * Callback function to handle reset form data.
3666
+ * - Reset all fields with default values.
3667
+ * - Reset validations and errors
3668
+ *
3669
+ */
3670
+ reset = () => {
3671
+ const { onChange } = this.props;
3672
+ const newState = this.getStateFromProps(this.props, void 0);
3673
+ const newFormData = newState.formData;
3674
+ const state = {
3675
+ formData: newFormData,
3676
+ errorSchema: {},
3677
+ errors: [],
3678
+ schemaValidationErrors: [],
3679
+ schemaValidationErrorSchema: {}
3680
+ };
3681
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
3682
+ };
3683
+ /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
3684
+ * was provided.
3685
+ *
3686
+ * @param id - The unique `id` of the field that was blurred
3687
+ * @param data - The data associated with the field that was blurred
3688
+ */
3689
+ onBlur = (id, data) => {
3690
+ const { onBlur } = this.props;
3691
+ if (onBlur) {
3692
+ onBlur(id, data);
3693
+ }
3694
+ };
3695
+ /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
3696
+ * was provided.
3697
+ *
3698
+ * @param id - The unique `id` of the field that was focused
3699
+ * @param data - The data associated with the field that was focused
3700
+ */
3701
+ onFocus = (id, data) => {
3702
+ const { onFocus } = this.props;
3703
+ if (onFocus) {
3704
+ onFocus(id, data);
3705
+ }
3706
+ };
3707
+ /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
3708
+ * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
3709
+ * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
3710
+ * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
3711
+ * back the `onSubmit` callback if it was provided.
3712
+ *
3713
+ * @param event - The submit HTML form event
3714
+ */
3715
+ onSubmit = (event) => {
3716
+ event.preventDefault();
3717
+ if (event.target !== event.currentTarget) {
3718
+ return;
3719
+ }
3720
+ event.persist();
3721
+ const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
3722
+ let { formData: newFormData } = this.state;
3723
+ if (omitExtraData === true) {
3724
+ newFormData = this.omitExtraData(newFormData);
3725
+ }
3726
+ if (noValidate || this.validateFormWithFormData(newFormData)) {
3727
+ const errorSchema = extraErrors || {};
3728
+ const errors = extraErrors ? (0, import_utils39.toErrorList)(extraErrors) : [];
3729
+ this.setState(
3730
+ {
3731
+ formData: newFormData,
3732
+ errors,
3733
+ errorSchema,
3734
+ schemaValidationErrors: [],
3735
+ schemaValidationErrorSchema: {}
3736
+ },
3737
+ () => {
3738
+ if (onSubmit) {
3739
+ onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
3740
+ }
3741
+ }
3742
+ );
3743
+ }
3744
+ };
3808
3745
  /** Returns the registry for the form */
3809
3746
  getRegistry() {
3810
3747
  const { translateString: customTranslateString, uiSchema = {} } = this.props;
@@ -3828,6 +3765,17 @@ var Form = class extends import_react17.Component {
3828
3765
  globalUiOptions: uiSchema[import_utils39.UI_GLOBAL_OPTIONS_KEY]
3829
3766
  };
3830
3767
  }
3768
+ /** Provides a function that can be used to programmatically submit the `Form` */
3769
+ submit = () => {
3770
+ if (this.formElement.current) {
3771
+ const submitCustomEvent = new CustomEvent("submit", {
3772
+ cancelable: true
3773
+ });
3774
+ submitCustomEvent.preventDefault();
3775
+ this.formElement.current.dispatchEvent(submitCustomEvent);
3776
+ this.formElement.current.requestSubmit();
3777
+ }
3778
+ };
3831
3779
  /** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
3832
3780
  * field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
3833
3781
  * id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
@@ -3855,6 +3803,59 @@ var Form = class extends import_react17.Component {
3855
3803
  field.focus();
3856
3804
  }
3857
3805
  }
3806
+ /** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
3807
+ * If `onError` is provided, then it will be called with the list of errors.
3808
+ *
3809
+ * @param formData - The form data to validate
3810
+ * @returns - True if the form is valid, false otherwise.
3811
+ */
3812
+ validateFormWithFormData = (formData) => {
3813
+ const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
3814
+ const { errors: prevErrors } = this.state;
3815
+ const schemaValidation = this.validate(formData);
3816
+ let errors = schemaValidation.errors;
3817
+ let errorSchema = schemaValidation.errorSchema;
3818
+ const schemaValidationErrors = errors;
3819
+ const schemaValidationErrorSchema = errorSchema;
3820
+ const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
3821
+ if (hasError) {
3822
+ if (extraErrors) {
3823
+ const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
3824
+ errorSchema = merged.errorSchema;
3825
+ errors = merged.errors;
3826
+ }
3827
+ if (focusOnFirstError) {
3828
+ if (typeof focusOnFirstError === "function") {
3829
+ focusOnFirstError(errors[0]);
3830
+ } else {
3831
+ this.focusOnError(errors[0]);
3832
+ }
3833
+ }
3834
+ this.setState(
3835
+ {
3836
+ errors,
3837
+ errorSchema,
3838
+ schemaValidationErrors,
3839
+ schemaValidationErrorSchema
3840
+ },
3841
+ () => {
3842
+ if (onError) {
3843
+ onError(errors);
3844
+ } else {
3845
+ console.error("Form validation failed", errors);
3846
+ }
3847
+ }
3848
+ );
3849
+ } else if (prevErrors.length > 0) {
3850
+ this.setState({
3851
+ errors: [],
3852
+ errorSchema: {},
3853
+ schemaValidationErrors: [],
3854
+ schemaValidationErrorSchema: {}
3855
+ });
3856
+ }
3857
+ return !hasError;
3858
+ };
3858
3859
  /** Programmatically validate the form. If `omitExtraData` is true, the `formData` will first be filtered to remove
3859
3860
  * any extra data not in a form field. If `onError` is provided, then it will be called with the list of errors the
3860
3861
  * same way as would happen on form submission.