@rjsf/core 6.0.0-beta.21 → 6.0.0-beta.22

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 (83) hide show
  1. package/dist/core.umd.js +1369 -1574
  2. package/dist/index.cjs +1438 -1646
  3. package/dist/index.cjs.map +3 -3
  4. package/dist/index.esm.js +1465 -1660
  5. package/dist/index.esm.js.map +3 -3
  6. package/lib/components/Form.d.ts +9 -4
  7. package/lib/components/Form.d.ts.map +1 -1
  8. package/lib/components/Form.js +48 -22
  9. package/lib/components/fields/ArrayField.d.ts +2 -197
  10. package/lib/components/fields/ArrayField.d.ts.map +1 -1
  11. package/lib/components/fields/ArrayField.js +518 -536
  12. package/lib/components/fields/BooleanField.js +2 -2
  13. package/lib/components/fields/LayoutGridField.d.ts +109 -191
  14. package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
  15. package/lib/components/fields/LayoutGridField.js +417 -444
  16. package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
  17. package/lib/components/fields/LayoutMultiSchemaField.js +2 -3
  18. package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
  19. package/lib/components/fields/MultiSchemaField.js +5 -3
  20. package/lib/components/fields/ObjectField.d.ts +2 -68
  21. package/lib/components/fields/ObjectField.d.ts.map +1 -1
  22. package/lib/components/fields/ObjectField.js +166 -168
  23. package/lib/components/fields/SchemaField.d.ts.map +1 -1
  24. package/lib/components/fields/SchemaField.js +31 -12
  25. package/lib/components/fields/StringField.js +2 -2
  26. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +3 -3
  27. package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
  28. package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +3 -8
  29. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +3 -3
  30. package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
  31. package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
  32. package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
  33. package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
  34. package/lib/components/templates/ArrayFieldTemplate.js +2 -4
  35. package/lib/components/templates/BaseInputTemplate.js +2 -2
  36. package/lib/components/templates/ObjectFieldTemplate.js +2 -2
  37. package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -2
  38. package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
  39. package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
  40. package/lib/components/widgets/CheckboxWidget.js +2 -2
  41. package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
  42. package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
  43. package/lib/components/widgets/CheckboxesWidget.js +2 -2
  44. package/lib/components/widgets/HiddenWidget.d.ts +1 -1
  45. package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
  46. package/lib/components/widgets/HiddenWidget.js +2 -2
  47. package/lib/components/widgets/RadioWidget.d.ts +1 -1
  48. package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
  49. package/lib/components/widgets/RadioWidget.js +2 -2
  50. package/lib/components/widgets/RatingWidget.d.ts +1 -1
  51. package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
  52. package/lib/components/widgets/RatingWidget.js +2 -2
  53. package/lib/components/widgets/SelectWidget.d.ts +1 -1
  54. package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
  55. package/lib/components/widgets/SelectWidget.js +2 -2
  56. package/lib/components/widgets/TextareaWidget.d.ts +1 -1
  57. package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
  58. package/lib/components/widgets/TextareaWidget.js +2 -2
  59. package/lib/tsconfig.tsbuildinfo +1 -1
  60. package/package.json +5 -5
  61. package/src/components/Form.tsx +61 -26
  62. package/src/components/fields/ArrayField.tsx +849 -758
  63. package/src/components/fields/BooleanField.tsx +2 -2
  64. package/src/components/fields/LayoutGridField.tsx +613 -600
  65. package/src/components/fields/LayoutMultiSchemaField.tsx +4 -5
  66. package/src/components/fields/MultiSchemaField.tsx +30 -25
  67. package/src/components/fields/ObjectField.tsx +315 -242
  68. package/src/components/fields/OptionalDataControlsField.tsx +1 -1
  69. package/src/components/fields/SchemaField.tsx +43 -46
  70. package/src/components/fields/StringField.tsx +2 -2
  71. package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +11 -16
  72. package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -3
  73. package/src/components/templates/ArrayFieldTemplate.tsx +2 -13
  74. package/src/components/templates/BaseInputTemplate.tsx +2 -2
  75. package/src/components/templates/ObjectFieldTemplate.tsx +2 -2
  76. package/src/components/templates/WrapIfAdditionalTemplate.tsx +4 -4
  77. package/src/components/widgets/CheckboxWidget.tsx +2 -1
  78. package/src/components/widgets/CheckboxesWidget.tsx +2 -1
  79. package/src/components/widgets/HiddenWidget.tsx +2 -1
  80. package/src/components/widgets/RadioWidget.tsx +2 -1
  81. package/src/components/widgets/RatingWidget.tsx +2 -1
  82. package/src/components/widgets/SelectWidget.tsx +2 -1
  83. package/src/components/widgets/TextareaWidget.tsx +2 -1
package/dist/core.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isFunction'), require('lodash/isEqual'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/unset'), require('@rjsf/validator-ajv8')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isFunction', 'lodash/isEqual', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', 'lodash/unset', '@rjsf/validator-ajv8'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.cloneDeep, global.get2, global.isEmpty, global._pick, global.set, global._toPath, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.unset, global.validator));
5
- })(this, (function (exports, react, utils, cloneDeep, get2, isEmpty, _pick, set, _toPath, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, unset, validator) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.unset, global.validator));
5
+ })(this, (function (exports, react, utils, cloneDeep, get, isEmpty, _pick, set, _toPath, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, unset, validator) { 'use strict';
6
6
 
7
7
  // src/components/Form.tsx
8
8
  function generateRowId() {
@@ -22,795 +22,747 @@
22
22
  }
23
23
  return [];
24
24
  }
25
- var ArrayField = class extends react.Component {
26
- /** Constructs an `ArrayField` from the `props`, generating the initial keyed data from the `formData`
27
- *
28
- * @param props - The `FieldProps` for this template
29
- */
30
- constructor(props) {
31
- super(props);
32
- const { formData } = props;
33
- const keyedFormData = generateKeyedFormData(formData);
34
- this.state = {
35
- keyedFormData,
36
- updatedKeyedFormData: false
37
- };
38
- }
39
- /** React lifecycle method that is called when the props are about to change allowing the state to be updated. It
40
- * regenerates the keyed form data and returns it
41
- *
42
- * @param nextProps - The next set of props data
43
- * @param prevState - The previous set of state data
44
- */
45
- static getDerivedStateFromProps(nextProps, prevState) {
46
- if (prevState.updatedKeyedFormData) {
47
- return {
48
- updatedKeyedFormData: false
49
- };
50
- }
51
- const nextFormData = Array.isArray(nextProps.formData) ? nextProps.formData : [];
52
- const previousKeyedFormData = prevState.keyedFormData || [];
53
- const newKeyedFormData = nextFormData.length === previousKeyedFormData.length ? previousKeyedFormData.map((previousKeyedFormDatum, index) => {
54
- return {
55
- key: previousKeyedFormDatum.key,
56
- item: nextFormData[index]
57
- };
58
- }) : generateKeyedFormData(nextFormData);
59
- return {
60
- keyedFormData: newKeyedFormData
61
- };
62
- }
63
- /** Returns the appropriate title for an item by getting first the title from the schema.items, then falling back to
64
- * the description from the schema.items, and finally the string "Item"
65
- */
66
- get itemTitle() {
67
- const { schema, registry } = this.props;
68
- const { translateString } = registry;
69
- return get2(
70
- schema,
71
- [utils.ITEMS_KEY, "title"],
72
- get2(schema, [utils.ITEMS_KEY, "description"], translateString(utils.TranslatableString.ArrayItemTitle))
73
- );
74
- }
75
- /** Determines whether the item described in the schema is always required, which is determined by whether any item
76
- * may be null.
77
- *
78
- * @param itemSchema - The schema for the item
79
- * @return - True if the item schema type does not contain the "null" type
80
- */
81
- isItemRequired(itemSchema) {
82
- if (Array.isArray(itemSchema.type)) {
83
- return !itemSchema.type.includes("null");
84
- }
85
- return itemSchema.type !== "null";
86
- }
87
- /** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
88
- * then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
89
- * `formData` matches that value, then false is returned, otherwise true is returned.
90
- *
91
- * @param formItems - The list of items in the form
92
- * @returns - True if the item is addable otherwise false
93
- */
94
- canAddItem(formItems) {
95
- const { schema, uiSchema, registry } = this.props;
96
- let { addable } = utils.getUiOptions(uiSchema, registry.globalUiOptions);
97
- if (addable !== false) {
98
- if (schema.maxItems !== void 0) {
99
- addable = formItems.length < schema.maxItems;
100
- } else {
101
- addable = true;
102
- }
103
- }
104
- return addable;
25
+ function isItemRequired(itemSchema) {
26
+ if (Array.isArray(itemSchema.type)) {
27
+ return !itemSchema.type.includes("null");
105
28
  }
106
- /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
107
- * that the schema is fixed and allows additional items.
108
- */
109
- _getNewFormDataRow = () => {
110
- const { schema, registry } = this.props;
111
- const { schemaUtils } = registry;
112
- let itemSchema = schema.items;
113
- if (utils.isFixedItems(schema) && utils.allowAdditionalItems(schema)) {
114
- itemSchema = schema.additionalItems;
115
- }
116
- return schemaUtils.getDefaultFormState(itemSchema);
117
- };
118
- /** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
119
- * either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
120
- * the state, and then returning `onChange()` with the plain form data converted from the keyed data
121
- *
122
- * @param event - The event for the click
123
- * @param [index] - The optional index at which to add the new data
124
- */
125
- _handleAddClick(event, index) {
126
- if (event) {
127
- event.preventDefault();
128
- }
129
- const { onChange, errorSchema, fieldPathId } = this.props;
130
- const { keyedFormData } = this.state;
131
- let newErrorSchema;
132
- if (errorSchema) {
133
- newErrorSchema = {};
134
- for (const idx in errorSchema) {
135
- const i = parseInt(idx);
136
- if (index === void 0 || i < index) {
137
- set(newErrorSchema, [i], errorSchema[idx]);
138
- } else if (i >= index) {
139
- set(newErrorSchema, [i + 1], errorSchema[idx]);
140
- }
141
- }
142
- }
143
- const newKeyedFormDataRow = {
144
- key: generateRowId(),
145
- item: this._getNewFormDataRow()
146
- };
147
- const newKeyedFormData = [...keyedFormData];
148
- if (index !== void 0) {
149
- newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
29
+ return itemSchema.type !== "null";
30
+ }
31
+ function canAddItem(registry, schema, formItems, uiSchema) {
32
+ let { addable } = utils.getUiOptions(uiSchema, registry.globalUiOptions);
33
+ if (addable !== false) {
34
+ if (schema.maxItems !== void 0) {
35
+ addable = formItems.length < schema.maxItems;
150
36
  } else {
151
- newKeyedFormData.push(newKeyedFormDataRow);
37
+ addable = true;
152
38
  }
153
- this.setState(
154
- {
155
- keyedFormData: newKeyedFormData,
156
- updatedKeyedFormData: true
157
- },
158
- // add click will pass the empty `path` array to the onChange which adds the appropriate path
159
- () => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
160
- );
161
39
  }
162
- /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
163
- * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
164
- * keyed data
165
- *
166
- * @param event - The event for the click
167
- */
168
- onAddClick = (event) => {
169
- this._handleAddClick(event);
170
- };
171
- /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
172
- * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
173
- * form data converted from the keyed data
174
- *
175
- * @param index - The index at which the add button is clicked
176
- */
177
- onAddIndexClick = (index) => {
178
- return (event) => {
179
- this._handleAddClick(event, index);
180
- };
181
- };
182
- /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
183
- * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
184
- * form data converted from the keyed data
185
- *
186
- * @param index - The index at which the copy button is clicked
187
- */
188
- onCopyIndexClick = (index) => {
189
- return (event) => {
190
- if (event) {
191
- event.preventDefault();
192
- }
193
- const { onChange, errorSchema, fieldPathId } = this.props;
194
- const { keyedFormData } = this.state;
195
- let newErrorSchema;
196
- if (errorSchema) {
197
- newErrorSchema = {};
198
- for (const idx in errorSchema) {
199
- const i = parseInt(idx);
200
- if (i <= index) {
201
- set(newErrorSchema, [i], errorSchema[idx]);
202
- } else if (i > index) {
203
- set(newErrorSchema, [i + 1], errorSchema[idx]);
204
- }
205
- }
206
- }
207
- const newKeyedFormDataRow = {
208
- key: generateRowId(),
209
- item: cloneDeep(keyedFormData[index].item)
210
- };
211
- const newKeyedFormData = [...keyedFormData];
212
- if (index !== void 0) {
213
- newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
214
- } else {
215
- newKeyedFormData.push(newKeyedFormDataRow);
216
- }
217
- this.setState(
218
- {
219
- keyedFormData: newKeyedFormData,
220
- updatedKeyedFormData: true
221
- },
222
- () => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
223
- );
224
- };
225
- };
226
- /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
227
- * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
228
- * from the keyed data
229
- *
230
- * @param index - The index at which the remove button is clicked
231
- */
232
- onDropIndexClick = (index) => {
233
- return (event) => {
234
- if (event) {
235
- event.preventDefault();
236
- }
237
- const { onChange, errorSchema, fieldPathId } = this.props;
238
- const { keyedFormData } = this.state;
239
- let newErrorSchema;
240
- if (errorSchema) {
241
- newErrorSchema = {};
242
- for (const idx in errorSchema) {
243
- const i = parseInt(idx);
244
- if (i < index) {
245
- set(newErrorSchema, [i], errorSchema[idx]);
246
- } else if (i > index) {
247
- set(newErrorSchema, [i - 1], errorSchema[idx]);
248
- }
249
- }
250
- }
251
- const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
252
- this.setState(
253
- {
254
- keyedFormData: newKeyedFormData,
255
- updatedKeyedFormData: true
256
- },
257
- () => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
258
- );
259
- };
260
- };
261
- /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
262
- * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
263
- * plain form data converted from the keyed data
264
- *
265
- * @param index - The index of the item to move
266
- * @param newIndex - The index to where the item is to be moved
267
- */
268
- onReorderClick = (index, newIndex) => {
269
- return (event) => {
270
- if (event) {
271
- event.preventDefault();
272
- event.currentTarget.blur();
273
- }
274
- const { onChange, errorSchema, fieldPathId } = this.props;
275
- let newErrorSchema;
276
- if (errorSchema) {
277
- newErrorSchema = {};
278
- for (const idx in errorSchema) {
279
- const i = parseInt(idx);
280
- if (i == index) {
281
- set(newErrorSchema, [newIndex], errorSchema[index]);
282
- } else if (i == newIndex) {
283
- set(newErrorSchema, [index], errorSchema[newIndex]);
284
- } else {
285
- set(newErrorSchema, [idx], errorSchema[i]);
286
- }
287
- }
288
- }
289
- const { keyedFormData } = this.state;
290
- function reOrderArray() {
291
- const _newKeyedFormData = keyedFormData.slice();
292
- _newKeyedFormData.splice(index, 1);
293
- _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
294
- return _newKeyedFormData;
295
- }
296
- const newKeyedFormData = reOrderArray();
297
- this.setState(
298
- {
299
- keyedFormData: newKeyedFormData
300
- },
301
- () => onChange(keyedToPlainFormData(newKeyedFormData), fieldPathId.path, newErrorSchema)
302
- );
303
- };
304
- };
305
- /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
306
- * `onChange` callback with the updated form data
307
- *
308
- * @param index - The index of the item being changed
309
- */
310
- onChangeForIndex = (index) => {
311
- return (value, path, newErrorSchema, id) => {
312
- const { onChange } = this.props;
313
- onChange(
314
- // We need to treat undefined items as nulls to have validation.
315
- // See https://github.com/tdegrunt/jsonschema/issues/206
316
- value === void 0 ? null : value,
317
- path,
318
- newErrorSchema,
319
- id
320
- );
321
- };
322
- };
323
- /** Callback handler used to change the value for a checkbox */
324
- onSelectChange = (value) => {
325
- const { onChange, fieldPathId } = this.props;
326
- onChange(value, fieldPathId.path, void 0, fieldPathId && fieldPathId.$id);
327
- };
328
- /** Helper method to compute item UI schema for both normal and fixed arrays
329
- * Handles both static object and dynamic function cases
330
- *
331
- * @param uiSchema - The parent UI schema containing items definition
332
- * @param item - The item data
333
- * @param index - The index of the item
334
- * @param formContext - The form context
335
- * @returns The computed UI schema for the item
336
- */
337
- computeItemUiSchema(uiSchema, item, index, formContext) {
338
- if (typeof uiSchema.items === "function") {
339
- try {
340
- const result = uiSchema.items(item, index, formContext);
341
- return result;
342
- } catch (e) {
343
- console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
344
- return void 0;
345
- }
346
- } else {
347
- return uiSchema.items;
40
+ return addable;
41
+ }
42
+ function computeItemUiSchema(uiSchema, item, index, formContext) {
43
+ if (typeof uiSchema.items === "function") {
44
+ try {
45
+ const result = uiSchema.items(item, index, formContext);
46
+ return result;
47
+ } catch (e) {
48
+ console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
49
+ return void 0;
348
50
  }
51
+ } else {
52
+ return uiSchema.items;
349
53
  }
350
- /** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
351
- */
352
- render() {
353
- const { schema, uiSchema, fieldPathId, registry } = this.props;
354
- const { schemaUtils, translateString } = registry;
355
- if (!(utils.ITEMS_KEY in schema)) {
356
- const uiOptions = utils.getUiOptions(uiSchema);
357
- const UnsupportedFieldTemplate = utils.getTemplate(
358
- "UnsupportedFieldTemplate",
359
- registry,
360
- uiOptions
361
- );
362
- return /* @__PURE__ */ jsxRuntime.jsx(
363
- UnsupportedFieldTemplate,
364
- {
365
- schema,
366
- fieldPathId,
367
- reason: translateString(utils.TranslatableString.MissingItems),
368
- registry
369
- }
370
- );
371
- }
372
- if (schemaUtils.isMultiSelect(schema)) {
373
- return this.renderMultiSelect();
374
- }
375
- if (utils.isCustomWidget(uiSchema)) {
376
- return this.renderCustomWidget();
377
- }
378
- if (utils.isFixedItems(schema)) {
379
- return this.renderFixedArray();
380
- }
381
- if (schemaUtils.isFilesArray(schema, uiSchema)) {
382
- return this.renderFiles();
383
- }
384
- return this.renderNormalArray();
54
+ }
55
+ function getNewFormDataRow(registry, schema) {
56
+ const { schemaUtils } = registry;
57
+ let itemSchema = schema.items;
58
+ if (utils.isFixedItems(schema) && utils.allowAdditionalItems(schema)) {
59
+ itemSchema = schema.additionalItems;
385
60
  }
386
- /** Renders a normal array without any limitations of length
387
- */
388
- renderNormalArray() {
389
- const {
390
- schema,
391
- uiSchema = {},
392
- errorSchema,
393
- fieldPathId,
61
+ return schemaUtils.getDefaultFormState(itemSchema);
62
+ }
63
+ function ArrayAsMultiSelect(props) {
64
+ const {
65
+ schema,
66
+ fieldPathId,
67
+ uiSchema,
68
+ formData: items = [],
69
+ disabled = false,
70
+ readonly = false,
71
+ autofocus = false,
72
+ required = false,
73
+ placeholder,
74
+ onBlur,
75
+ onFocus,
76
+ registry,
77
+ rawErrors,
78
+ name,
79
+ onSelectChange
80
+ } = props;
81
+ const { widgets: widgets2, schemaUtils, globalFormOptions, globalUiOptions } = registry;
82
+ const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
83
+ const enumOptions = utils.optionsList(itemsSchema, uiSchema);
84
+ const { widget = "select", title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
85
+ const Widget = utils.getWidget(schema, widget, widgets2);
86
+ const label = uiTitle ?? schema.title ?? name;
87
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
88
+ const multiValueFieldPathId = utils.useDeepCompareMemo(utils.toFieldPathId("", globalFormOptions, fieldPathId, true));
89
+ return /* @__PURE__ */ jsxRuntime.jsx(
90
+ Widget,
91
+ {
92
+ id: multiValueFieldPathId[utils.ID_KEY],
394
93
  name,
395
- title,
396
- disabled = false,
397
- readonly = false,
398
- autofocus = false,
399
- required = false,
400
- registry,
94
+ multiple: true,
95
+ onChange: onSelectChange,
401
96
  onBlur,
402
97
  onFocus,
403
- rawErrors
404
- } = this.props;
405
- const { keyedFormData } = this.state;
406
- const fieldTitle = schema.title || title || name;
407
- const { schemaUtils, fields: fields2, formContext, globalFormOptions } = registry;
408
- const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
409
- const uiOptions = utils.getUiOptions(uiSchema);
410
- const _schemaItems = isObject(schema.items) ? schema.items : {};
411
- const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
412
- const formData = keyedToPlainFormData(this.state.keyedFormData);
413
- const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
414
- const hasFormData = utils.isFormDataAvailable(this.props.formData);
415
- const canAdd = this.canAddItem(formData) && (!renderOptionalField || hasFormData);
416
- const actualFormData = hasFormData ? keyedFormData : [];
417
- const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
418
- const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...this.props }) : void 0;
419
- const arrayProps = {
420
- canAdd,
421
- items: actualFormData.map((keyedItem, index) => {
422
- const { key, item } = keyedItem;
423
- const itemCast = item;
424
- const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
425
- const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
426
- const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, fieldPathId);
427
- const itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
428
- return this.renderArrayFieldItem({
429
- key,
430
- index,
431
- name: name && `${name}-${index}`,
432
- title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
433
- canAdd,
434
- canMoveUp: index > 0,
435
- canMoveDown: index < formData.length - 1,
436
- itemSchema,
437
- itemFieldPathId,
438
- itemErrorSchema,
439
- itemData: itemCast,
440
- itemUiSchema,
441
- autofocus: autofocus && index === 0,
442
- onBlur,
443
- onFocus,
444
- rawErrors,
445
- totalItems: keyedFormData.length
446
- });
447
- }),
448
- className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}${extraClass}`,
449
- disabled,
450
- fieldPathId,
98
+ options: { ...options, enumOptions },
99
+ schema,
451
100
  uiSchema,
452
- onAddClick: this.onAddClick,
101
+ registry,
102
+ value: items,
103
+ disabled,
453
104
  readonly,
454
105
  required,
455
- schema,
456
- title: fieldTitle,
457
- formData,
106
+ label,
107
+ hideLabel: !displayLabel,
108
+ placeholder,
109
+ autofocus,
458
110
  rawErrors,
459
- registry,
460
- optionalDataControl
461
- };
462
- const Template = utils.getTemplate("ArrayFieldTemplate", registry, uiOptions);
463
- return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
464
- }
465
- /** Renders an array using the custom widget provided by the user in the `uiSchema`
466
- */
467
- renderCustomWidget() {
468
- const {
111
+ htmlName: multiValueFieldPathId.name
112
+ }
113
+ );
114
+ }
115
+ function ArrayAsCustomWidget(props) {
116
+ const {
117
+ schema,
118
+ fieldPathId,
119
+ uiSchema,
120
+ disabled = false,
121
+ readonly = false,
122
+ autofocus = false,
123
+ required = false,
124
+ hideError,
125
+ placeholder,
126
+ onBlur,
127
+ onFocus,
128
+ formData: items = [],
129
+ registry,
130
+ rawErrors,
131
+ name,
132
+ onSelectChange
133
+ } = props;
134
+ const { widgets: widgets2, schemaUtils, globalFormOptions, globalUiOptions } = registry;
135
+ const { widget, title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
136
+ const Widget = utils.getWidget(schema, widget, widgets2);
137
+ const label = uiTitle ?? schema.title ?? name;
138
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
139
+ const multiValueFieldPathId = utils.useDeepCompareMemo(utils.toFieldPathId("", globalFormOptions, fieldPathId, true));
140
+ return /* @__PURE__ */ jsxRuntime.jsx(
141
+ Widget,
142
+ {
143
+ id: multiValueFieldPathId[utils.ID_KEY],
144
+ name,
145
+ multiple: true,
146
+ onChange: onSelectChange,
147
+ onBlur,
148
+ onFocus,
149
+ options,
469
150
  schema,
470
- fieldPathId,
471
151
  uiSchema,
472
- disabled = false,
473
- readonly = false,
474
- autofocus = false,
475
- required = false,
152
+ registry,
153
+ value: items,
154
+ disabled,
155
+ readonly,
476
156
  hideError,
157
+ required,
158
+ label,
159
+ hideLabel: !displayLabel,
477
160
  placeholder,
161
+ autofocus,
162
+ rawErrors,
163
+ htmlName: multiValueFieldPathId.name
164
+ }
165
+ );
166
+ }
167
+ function ArrayAsFiles(props) {
168
+ const {
169
+ schema,
170
+ uiSchema,
171
+ fieldPathId,
172
+ name,
173
+ disabled = false,
174
+ readonly = false,
175
+ autofocus = false,
176
+ required = false,
177
+ onBlur,
178
+ onFocus,
179
+ registry,
180
+ formData: items = [],
181
+ rawErrors,
182
+ onSelectChange
183
+ } = props;
184
+ const { widgets: widgets2, schemaUtils, globalFormOptions, globalUiOptions } = registry;
185
+ const { widget = "files", title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
186
+ const Widget = utils.getWidget(schema, widget, widgets2);
187
+ const label = uiTitle ?? schema.title ?? name;
188
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
189
+ const multiValueFieldPathId = utils.useDeepCompareMemo(utils.toFieldPathId("", globalFormOptions, fieldPathId, true));
190
+ return /* @__PURE__ */ jsxRuntime.jsx(
191
+ Widget,
192
+ {
193
+ options,
194
+ id: multiValueFieldPathId[utils.ID_KEY],
195
+ name,
196
+ multiple: true,
197
+ onChange: onSelectChange,
478
198
  onBlur,
479
199
  onFocus,
480
- formData: items = [],
481
- registry,
482
- rawErrors,
483
- name
484
- } = this.props;
485
- const { widgets: widgets2, formContext, globalUiOptions, schemaUtils } = registry;
486
- const { widget, title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
487
- const Widget = utils.getWidget(schema, widget, widgets2);
488
- const label = uiTitle ?? schema.title ?? name;
489
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
490
- return /* @__PURE__ */ jsxRuntime.jsx(
491
- Widget,
492
- {
493
- id: fieldPathId.$id,
494
- name,
495
- multiple: true,
496
- onChange: this.onSelectChange,
497
- onBlur,
498
- onFocus,
499
- options,
500
- schema,
501
- uiSchema,
502
- registry,
503
- value: items,
504
- disabled,
505
- readonly,
506
- hideError,
507
- required,
508
- label,
509
- hideLabel: !displayLabel,
510
- placeholder,
511
- formContext,
512
- autofocus,
513
- rawErrors
514
- }
515
- );
516
- }
517
- /** Renders an array as a set of checkboxes
518
- */
519
- renderMultiSelect() {
520
- const {
521
200
  schema,
522
- fieldPathId,
523
201
  uiSchema,
524
- formData: items = [],
525
- disabled = false,
526
- readonly = false,
527
- autofocus = false,
528
- required = false,
529
- placeholder,
530
- onBlur,
531
- onFocus,
202
+ value: items,
203
+ disabled,
204
+ readonly,
205
+ required,
532
206
  registry,
207
+ autofocus,
533
208
  rawErrors,
534
- name
535
- } = this.props;
536
- const { widgets: widgets2, schemaUtils, formContext, globalUiOptions } = registry;
537
- const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
538
- const enumOptions = utils.optionsList(itemsSchema, uiSchema);
539
- const { widget = "select", title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
540
- const Widget = utils.getWidget(schema, widget, widgets2);
541
- const label = uiTitle ?? schema.title ?? name;
542
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
543
- return /* @__PURE__ */ jsxRuntime.jsx(
544
- Widget,
209
+ label,
210
+ hideLabel: !displayLabel,
211
+ htmlName: multiValueFieldPathId.name
212
+ }
213
+ );
214
+ }
215
+ function ArrayFieldItem(props) {
216
+ const {
217
+ itemKey,
218
+ index,
219
+ name,
220
+ disabled,
221
+ hideError,
222
+ readonly,
223
+ registry,
224
+ uiOptions,
225
+ parentUiSchema,
226
+ canAdd,
227
+ canRemove = true,
228
+ canMoveUp,
229
+ canMoveDown,
230
+ itemSchema,
231
+ itemData,
232
+ itemUiSchema,
233
+ itemFieldPathId,
234
+ itemErrorSchema,
235
+ autofocus,
236
+ onBlur,
237
+ onFocus,
238
+ onChange,
239
+ rawErrors,
240
+ totalItems,
241
+ title,
242
+ handleAddItem,
243
+ handleCopyItem,
244
+ handleRemoveItem,
245
+ handleReorderItems
246
+ } = props;
247
+ const {
248
+ fields: { ArraySchemaField, SchemaField: SchemaField2 }
249
+ } = registry;
250
+ const fieldPathId = utils.useDeepCompareMemo(itemFieldPathId);
251
+ const ItemSchemaField = ArraySchemaField || SchemaField2;
252
+ const ArrayFieldItemTemplate2 = utils.getTemplate(
253
+ "ArrayFieldItemTemplate",
254
+ registry,
255
+ uiOptions
256
+ );
257
+ const { orderable = true, removable = true, copyable = false } = uiOptions;
258
+ const has4 = {
259
+ moveUp: orderable && canMoveUp,
260
+ moveDown: orderable && canMoveDown,
261
+ copy: copyable && canAdd,
262
+ remove: removable && canRemove,
263
+ toolbar: false
264
+ };
265
+ has4.toolbar = Object.keys(has4).some((key) => has4[key]);
266
+ const onAddItem = react.useCallback(
267
+ (event) => {
268
+ handleAddItem(event, index + 1);
269
+ },
270
+ [handleAddItem, index]
271
+ );
272
+ const onCopyItem = react.useCallback(
273
+ (event) => {
274
+ handleCopyItem(event, index);
275
+ },
276
+ [handleCopyItem, index]
277
+ );
278
+ const onRemoveItem = react.useCallback(
279
+ (event) => {
280
+ handleRemoveItem(event, index);
281
+ },
282
+ [handleRemoveItem, index]
283
+ );
284
+ const onMoveUpItem = react.useCallback(
285
+ (event) => {
286
+ handleReorderItems(event, index, index - 1);
287
+ },
288
+ [handleReorderItems, index]
289
+ );
290
+ const onMoveDownItem = react.useCallback(
291
+ (event) => {
292
+ handleReorderItems(event, index, index + 1);
293
+ },
294
+ [handleReorderItems, index]
295
+ );
296
+ const templateProps = {
297
+ children: /* @__PURE__ */ jsxRuntime.jsx(
298
+ ItemSchemaField,
545
299
  {
546
- id: fieldPathId.$id,
547
300
  name,
548
- multiple: true,
549
- onChange: this.onSelectChange,
301
+ title,
302
+ index,
303
+ schema: itemSchema,
304
+ uiSchema: itemUiSchema,
305
+ formData: itemData,
306
+ errorSchema: itemErrorSchema,
307
+ fieldPathId,
308
+ required: isItemRequired(itemSchema),
309
+ onChange,
550
310
  onBlur,
551
311
  onFocus,
552
- options: { ...options, enumOptions },
553
- schema,
554
- uiSchema,
555
312
  registry,
556
- value: items,
557
313
  disabled,
558
314
  readonly,
559
- required,
560
- label,
561
- hideLabel: !displayLabel,
562
- placeholder,
563
- formContext,
315
+ hideError,
564
316
  autofocus,
565
317
  rawErrors
566
318
  }
567
- );
568
- }
569
- /** Renders an array of files using the `FileWidget`
570
- */
571
- renderFiles() {
572
- const {
573
- schema,
574
- uiSchema,
319
+ ),
320
+ buttonsProps: {
575
321
  fieldPathId,
576
- name,
577
- disabled = false,
578
- readonly = false,
579
- autofocus = false,
580
- required = false,
581
- onBlur,
582
- onFocus,
322
+ disabled,
323
+ readonly,
324
+ canAdd,
325
+ hasCopy: has4.copy,
326
+ hasMoveUp: has4.moveUp,
327
+ hasMoveDown: has4.moveDown,
328
+ hasRemove: has4.remove,
329
+ index,
330
+ totalItems,
331
+ onAddItem,
332
+ onCopyItem,
333
+ onRemoveItem,
334
+ onMoveUpItem,
335
+ onMoveDownItem,
583
336
  registry,
584
- formData: items = [],
585
- rawErrors
586
- } = this.props;
587
- const { widgets: widgets2, formContext, globalUiOptions, schemaUtils } = registry;
588
- const { widget = "files", title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
589
- const Widget = utils.getWidget(schema, widget, widgets2);
590
- const label = uiTitle ?? schema.title ?? name;
591
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
592
- return /* @__PURE__ */ jsxRuntime.jsx(
593
- Widget,
594
- {
595
- options,
596
- id: fieldPathId.$id,
597
- name,
598
- multiple: true,
599
- onChange: this.onSelectChange,
337
+ schema: itemSchema,
338
+ uiSchema: itemUiSchema
339
+ },
340
+ itemKey,
341
+ className: "rjsf-array-item",
342
+ disabled,
343
+ hasToolbar: has4.toolbar,
344
+ index,
345
+ totalItems,
346
+ readonly,
347
+ registry,
348
+ schema: itemSchema,
349
+ uiSchema: itemUiSchema,
350
+ parentUiSchema
351
+ };
352
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...templateProps });
353
+ }
354
+ function NormalArray(props) {
355
+ const {
356
+ schema,
357
+ uiSchema = {},
358
+ errorSchema,
359
+ fieldPathId,
360
+ formData: formDataFromProps,
361
+ name,
362
+ title,
363
+ disabled = false,
364
+ readonly = false,
365
+ autofocus = false,
366
+ required = false,
367
+ hideError = false,
368
+ registry,
369
+ onBlur,
370
+ onFocus,
371
+ rawErrors,
372
+ onChange,
373
+ keyedFormData,
374
+ handleAddItem,
375
+ handleCopyItem,
376
+ handleRemoveItem,
377
+ handleReorderItems
378
+ } = props;
379
+ const fieldTitle = schema.title || title || name;
380
+ const { schemaUtils, fields: fields2, formContext, globalFormOptions, globalUiOptions } = registry;
381
+ const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
382
+ const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
383
+ const _schemaItems = isObject(schema.items) ? schema.items : {};
384
+ const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
385
+ const formData = keyedToPlainFormData(keyedFormData);
386
+ const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
387
+ const hasFormData = utils.isFormDataAvailable(formDataFromProps);
388
+ const canAdd = canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData);
389
+ const actualFormData = hasFormData ? keyedFormData : [];
390
+ const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
391
+ const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...props }) : void 0;
392
+ const arrayProps = {
393
+ canAdd,
394
+ items: actualFormData.map((keyedItem, index) => {
395
+ const { key, item } = keyedItem;
396
+ const itemCast = item;
397
+ const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
398
+ const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
399
+ const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, fieldPathId);
400
+ const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
401
+ const itemProps = {
402
+ itemKey: key,
403
+ index,
404
+ name: name && `${name}-${index}`,
405
+ registry,
406
+ uiOptions,
407
+ hideError,
408
+ readonly,
409
+ disabled,
410
+ required,
411
+ title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
412
+ canAdd,
413
+ canMoveUp: index > 0,
414
+ canMoveDown: index < formData.length - 1,
415
+ itemSchema,
416
+ itemFieldPathId,
417
+ itemErrorSchema,
418
+ itemData: itemCast,
419
+ itemUiSchema,
420
+ autofocus: autofocus && index === 0,
600
421
  onBlur,
601
422
  onFocus,
602
- schema,
603
- uiSchema,
604
- value: items,
605
- disabled,
423
+ rawErrors,
424
+ totalItems: keyedFormData.length,
425
+ handleAddItem,
426
+ handleCopyItem,
427
+ handleRemoveItem,
428
+ handleReorderItems,
429
+ onChange
430
+ };
431
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItem, { ...itemProps }, key);
432
+ }),
433
+ className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}${extraClass}`,
434
+ disabled,
435
+ fieldPathId,
436
+ uiSchema,
437
+ onAddClick: handleAddItem,
438
+ readonly,
439
+ required,
440
+ schema,
441
+ title: fieldTitle,
442
+ formData,
443
+ rawErrors,
444
+ registry,
445
+ optionalDataControl
446
+ };
447
+ const Template = utils.getTemplate("ArrayFieldTemplate", registry, uiOptions);
448
+ return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
449
+ }
450
+ function FixedArray(props) {
451
+ const {
452
+ schema,
453
+ uiSchema = {},
454
+ formData,
455
+ errorSchema,
456
+ fieldPathId,
457
+ name,
458
+ title,
459
+ disabled = false,
460
+ readonly = false,
461
+ autofocus = false,
462
+ required = false,
463
+ hideError = false,
464
+ registry,
465
+ onBlur,
466
+ onFocus,
467
+ rawErrors,
468
+ keyedFormData,
469
+ onChange,
470
+ handleAddItem,
471
+ handleCopyItem,
472
+ handleRemoveItem,
473
+ handleReorderItems
474
+ } = props;
475
+ let { formData: items = [] } = props;
476
+ const fieldTitle = schema.title || title || name;
477
+ const { schemaUtils, fields: fields2, formContext, globalFormOptions, globalUiOptions } = registry;
478
+ const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
479
+ const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
480
+ const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
481
+ const hasFormData = utils.isFormDataAvailable(formData);
482
+ const _schemaItems = isObject(schema.items) ? schema.items : [];
483
+ const itemSchemas = _schemaItems.map(
484
+ (item, index) => schemaUtils.retrieveSchema(item, items[index])
485
+ );
486
+ const additionalSchema = isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, formData) : null;
487
+ if (items.length < itemSchemas.length) {
488
+ items = items.concat(new Array(itemSchemas.length - items.length));
489
+ }
490
+ const actualFormData = hasFormData ? keyedFormData : [];
491
+ const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
492
+ const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...props }) : void 0;
493
+ const canAdd = canAddItem(registry, schema, items, uiSchema) && !!additionalSchema && (!renderOptionalField || hasFormData);
494
+ const arrayProps = {
495
+ canAdd,
496
+ className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
497
+ disabled,
498
+ fieldPathId,
499
+ formData,
500
+ items: actualFormData.map((keyedItem, index) => {
501
+ const { key, item } = keyedItem;
502
+ const itemCast = item;
503
+ const additional = index >= itemSchemas.length;
504
+ const itemSchema = (additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
505
+ const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, fieldPathId);
506
+ let itemUiSchema;
507
+ if (additional) {
508
+ itemUiSchema = uiSchema.additionalItems;
509
+ } else {
510
+ if (Array.isArray(uiSchema.items)) {
511
+ itemUiSchema = uiSchema.items[index];
512
+ } else {
513
+ itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
514
+ }
515
+ }
516
+ const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
517
+ const itemProps = {
518
+ index,
519
+ itemKey: key,
520
+ name: name && `${name}-${index}`,
521
+ registry,
522
+ uiOptions,
523
+ hideError,
606
524
  readonly,
525
+ disabled,
607
526
  required,
608
- registry,
609
- formContext,
610
- autofocus,
527
+ title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
528
+ canAdd,
529
+ canRemove: additional,
530
+ canMoveUp: index >= itemSchemas.length + 1,
531
+ canMoveDown: additional && index < items.length - 1,
532
+ itemSchema,
533
+ itemData: itemCast,
534
+ itemUiSchema,
535
+ itemFieldPathId,
536
+ itemErrorSchema,
537
+ autofocus: autofocus && index === 0,
538
+ onBlur,
539
+ onFocus,
611
540
  rawErrors,
612
- label,
613
- hideLabel: !displayLabel
614
- }
615
- );
541
+ totalItems: keyedFormData.length,
542
+ onChange,
543
+ handleAddItem,
544
+ handleCopyItem,
545
+ handleRemoveItem,
546
+ handleReorderItems
547
+ };
548
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItem, { ...itemProps }, key);
549
+ }),
550
+ onAddClick: handleAddItem,
551
+ readonly,
552
+ required,
553
+ registry,
554
+ schema,
555
+ uiSchema,
556
+ title: fieldTitle,
557
+ errorSchema,
558
+ rawErrors,
559
+ optionalDataControl
560
+ };
561
+ const Template = utils.getTemplate("ArrayFieldTemplate", registry, uiOptions);
562
+ return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
563
+ }
564
+ function useKeyedFormData(formData = []) {
565
+ const newHash = react.useMemo(() => utils.hashObject(formData), [formData]);
566
+ const [state, setState] = react.useState(() => ({
567
+ formDataHash: newHash,
568
+ keyedFormData: generateKeyedFormData(formData)
569
+ }));
570
+ let { keyedFormData, formDataHash } = state;
571
+ if (newHash !== formDataHash) {
572
+ const nextFormData = Array.isArray(formData) ? formData : [];
573
+ const previousKeyedFormData = keyedFormData || [];
574
+ keyedFormData = nextFormData.length === previousKeyedFormData.length ? previousKeyedFormData.map((previousKeyedFormDatum, index) => ({
575
+ key: previousKeyedFormDatum.key,
576
+ item: nextFormData[index]
577
+ })) : generateKeyedFormData(nextFormData);
578
+ formDataHash = newHash;
579
+ setState({ formDataHash, keyedFormData });
616
580
  }
617
- /** Renders an array that has a maximum limit of items
618
- */
619
- renderFixedArray() {
620
- const {
621
- schema,
622
- uiSchema = {},
623
- formData,
624
- errorSchema,
625
- fieldPathId,
626
- name,
627
- title,
628
- disabled = false,
629
- readonly = false,
630
- autofocus = false,
631
- required = false,
632
- registry,
633
- onBlur,
634
- onFocus,
635
- rawErrors
636
- } = this.props;
637
- let { formData: items = [] } = this.props;
638
- const { keyedFormData } = this.state;
639
- const fieldTitle = schema.title || title || name;
640
- const uiOptions = utils.getUiOptions(uiSchema);
641
- const { schemaUtils, fields: fields2, formContext, globalFormOptions } = registry;
642
- const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
643
- const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
644
- const hasFormData = utils.isFormDataAvailable(formData);
645
- const _schemaItems = isObject(schema.items) ? schema.items : [];
646
- const itemSchemas = _schemaItems.map(
647
- (item, index) => schemaUtils.retrieveSchema(item, items[index])
648
- );
649
- const additionalSchema = isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, formData) : null;
650
- if (items.length < itemSchemas.length) {
651
- items = items.concat(new Array(itemSchemas.length - items.length));
652
- }
653
- const actualFormData = hasFormData ? keyedFormData : [];
654
- const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
655
- const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...this.props }) : void 0;
656
- const canAdd = this.canAddItem(items) && !!additionalSchema && (!renderOptionalField || hasFormData);
657
- const arrayProps = {
658
- canAdd,
659
- className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
660
- disabled,
661
- fieldPathId,
662
- formData,
663
- items: actualFormData.map((keyedItem, index) => {
664
- const { key, item } = keyedItem;
665
- const itemCast = item;
666
- const additional = index >= itemSchemas.length;
667
- const itemSchema = (additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index]) || {};
668
- const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, fieldPathId);
669
- let itemUiSchema;
670
- if (additional) {
671
- itemUiSchema = uiSchema.additionalItems;
672
- } else {
673
- if (Array.isArray(uiSchema.items)) {
674
- itemUiSchema = uiSchema.items[index];
675
- } else {
676
- itemUiSchema = this.computeItemUiSchema(uiSchema, item, index, formContext);
581
+ const updateKeyedFormData = react.useCallback((newData) => {
582
+ const plainFormData = keyedToPlainFormData(newData);
583
+ const newHash2 = utils.hashObject(plainFormData);
584
+ setState({ formDataHash: newHash2, keyedFormData: newData });
585
+ return plainFormData;
586
+ }, []);
587
+ return { keyedFormData, updateKeyedFormData };
588
+ }
589
+ function ArrayField(props) {
590
+ const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
591
+ const { schemaUtils, translateString } = registry;
592
+ const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
593
+ const handleAddItem = react.useCallback(
594
+ (event, index) => {
595
+ if (event) {
596
+ event.preventDefault();
597
+ }
598
+ let newErrorSchema;
599
+ if (errorSchema) {
600
+ newErrorSchema = {};
601
+ for (const idx in errorSchema) {
602
+ const i = parseInt(idx);
603
+ if (index === void 0 || i < index) {
604
+ set(newErrorSchema, [i], errorSchema[idx]);
605
+ } else if (i >= index) {
606
+ set(newErrorSchema, [i + 1], errorSchema[idx]);
677
607
  }
678
608
  }
679
- const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
680
- return this.renderArrayFieldItem({
681
- key,
682
- index,
683
- name: name && `${name}-${index}`,
684
- title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
685
- canAdd,
686
- canRemove: additional,
687
- canMoveUp: index >= itemSchemas.length + 1,
688
- canMoveDown: additional && index < items.length - 1,
689
- itemSchema,
690
- itemData: itemCast,
691
- itemUiSchema,
692
- itemFieldPathId,
693
- itemErrorSchema,
694
- autofocus: autofocus && index === 0,
695
- onBlur,
696
- onFocus,
697
- rawErrors,
698
- totalItems: keyedFormData.length
699
- });
700
- }),
701
- onAddClick: this.onAddClick,
702
- readonly,
703
- required,
704
- registry,
705
- schema,
706
- uiSchema,
707
- title: fieldTitle,
708
- errorSchema,
709
- rawErrors,
710
- optionalDataControl
711
- };
712
- const Template = utils.getTemplate("ArrayFieldTemplate", registry, uiOptions);
713
- return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
714
- }
715
- /** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
716
- * back to the `ArrayFieldItemTemplate`.
717
- *
718
- * @param props - The props for the individual array item to be rendered
719
- */
720
- renderArrayFieldItem(props) {
721
- const {
722
- key,
723
- index,
724
- name,
725
- canAdd,
726
- canRemove = true,
727
- canMoveUp,
728
- canMoveDown,
729
- itemSchema,
730
- itemData,
731
- itemUiSchema,
732
- itemFieldPathId,
733
- itemErrorSchema,
734
- autofocus,
735
- onBlur,
736
- onFocus,
737
- rawErrors,
738
- totalItems,
739
- title
740
- } = props;
741
- const { disabled, hideError, readonly, uiSchema, registry, formContext } = this.props;
742
- const {
743
- fields: { ArraySchemaField, SchemaField: SchemaField2 },
744
- globalUiOptions
745
- } = registry;
746
- const ItemSchemaField = ArraySchemaField || SchemaField2;
747
- const { orderable = true, removable = true, copyable = false } = utils.getUiOptions(uiSchema, globalUiOptions);
748
- const has4 = {
749
- moveUp: orderable && canMoveUp,
750
- moveDown: orderable && canMoveDown,
751
- copy: copyable && canAdd,
752
- remove: removable && canRemove,
753
- toolbar: false
754
- };
755
- has4.toolbar = Object.keys(has4).some((key2) => has4[key2]);
756
- return {
757
- children: /* @__PURE__ */ jsxRuntime.jsx(
758
- ItemSchemaField,
759
- {
760
- name,
761
- title,
762
- index,
763
- schema: itemSchema,
764
- uiSchema: itemUiSchema,
765
- formData: itemData,
766
- formContext,
767
- errorSchema: itemErrorSchema,
768
- fieldPathId: itemFieldPathId,
769
- required: this.isItemRequired(itemSchema),
770
- onChange: this.onChangeForIndex(index),
771
- onBlur,
772
- onFocus,
773
- registry,
774
- disabled,
775
- readonly,
776
- hideError,
777
- autofocus,
778
- rawErrors
609
+ }
610
+ const newKeyedFormDataRow = {
611
+ key: generateRowId(),
612
+ item: getNewFormDataRow(registry, schema)
613
+ };
614
+ const newKeyedFormData = [...keyedFormData];
615
+ if (index !== void 0) {
616
+ newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
617
+ } else {
618
+ newKeyedFormData.push(newKeyedFormDataRow);
619
+ }
620
+ onChange(updateKeyedFormData(newKeyedFormData), fieldPathId.path, newErrorSchema);
621
+ },
622
+ [keyedFormData, registry, schema, onChange, updateKeyedFormData, errorSchema, fieldPathId]
623
+ );
624
+ const handleCopyItem = react.useCallback(
625
+ (event, index) => {
626
+ if (event) {
627
+ event.preventDefault();
628
+ }
629
+ let newErrorSchema;
630
+ if (errorSchema) {
631
+ newErrorSchema = {};
632
+ for (const idx in errorSchema) {
633
+ const i = parseInt(idx);
634
+ if (i <= index) {
635
+ set(newErrorSchema, [i], errorSchema[idx]);
636
+ } else if (i > index) {
637
+ set(newErrorSchema, [i + 1], errorSchema[idx]);
638
+ }
639
+ }
640
+ }
641
+ const newKeyedFormDataRow = {
642
+ key: generateRowId(),
643
+ item: cloneDeep(keyedFormData[index].item)
644
+ };
645
+ const newKeyedFormData = [...keyedFormData];
646
+ if (index !== void 0) {
647
+ newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
648
+ } else {
649
+ newKeyedFormData.push(newKeyedFormDataRow);
650
+ }
651
+ onChange(updateKeyedFormData(newKeyedFormData), fieldPathId.path, newErrorSchema);
652
+ },
653
+ [keyedFormData, onChange, updateKeyedFormData, errorSchema, fieldPathId]
654
+ );
655
+ const handleRemoveItem = react.useCallback(
656
+ (event, index) => {
657
+ if (event) {
658
+ event.preventDefault();
659
+ }
660
+ let newErrorSchema;
661
+ if (errorSchema) {
662
+ newErrorSchema = {};
663
+ for (const idx in errorSchema) {
664
+ const i = parseInt(idx);
665
+ if (i < index) {
666
+ set(newErrorSchema, [i], errorSchema[idx]);
667
+ } else if (i > index) {
668
+ set(newErrorSchema, [i - 1], errorSchema[idx]);
669
+ }
779
670
  }
780
- ),
781
- buttonsProps: {
782
- fieldPathId: itemFieldPathId,
783
- disabled,
784
- readonly,
785
- canAdd,
786
- hasCopy: has4.copy,
787
- hasMoveUp: has4.moveUp,
788
- hasMoveDown: has4.moveDown,
789
- hasRemove: has4.remove,
790
- index,
791
- totalItems,
792
- onAddIndexClick: this.onAddIndexClick,
793
- onCopyIndexClick: this.onCopyIndexClick,
794
- onDropIndexClick: this.onDropIndexClick,
795
- onReorderClick: this.onReorderClick,
796
- registry,
797
- schema: itemSchema,
798
- uiSchema: itemUiSchema
799
- },
800
- className: "rjsf-array-item",
801
- disabled,
802
- hasToolbar: has4.toolbar,
803
- index,
804
- totalItems,
805
- key,
806
- readonly,
671
+ }
672
+ const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
673
+ onChange(updateKeyedFormData(newKeyedFormData), fieldPathId.path, newErrorSchema);
674
+ },
675
+ [keyedFormData, onChange, updateKeyedFormData, errorSchema, fieldPathId]
676
+ );
677
+ const handleReorderItems = react.useCallback(
678
+ (event, index, newIndex) => {
679
+ if (event) {
680
+ event.preventDefault();
681
+ event.currentTarget.blur();
682
+ }
683
+ let newErrorSchema;
684
+ if (errorSchema) {
685
+ newErrorSchema = {};
686
+ for (const idx in errorSchema) {
687
+ const i = parseInt(idx);
688
+ if (i == index) {
689
+ set(newErrorSchema, [newIndex], errorSchema[index]);
690
+ } else if (i == newIndex) {
691
+ set(newErrorSchema, [index], errorSchema[newIndex]);
692
+ } else {
693
+ set(newErrorSchema, [idx], errorSchema[i]);
694
+ }
695
+ }
696
+ }
697
+ function reOrderArray() {
698
+ const _newKeyedFormData = keyedFormData.slice();
699
+ _newKeyedFormData.splice(index, 1);
700
+ _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
701
+ return _newKeyedFormData;
702
+ }
703
+ const newKeyedFormData = reOrderArray();
704
+ onChange(updateKeyedFormData(newKeyedFormData), fieldPathId.path, newErrorSchema);
705
+ },
706
+ [keyedFormData, onChange, updateKeyedFormData, errorSchema, fieldPathId]
707
+ );
708
+ const handleChange = react.useCallback(
709
+ (value, path, newErrorSchema, id) => {
710
+ onChange(
711
+ // We need to treat undefined items as nulls to have validation.
712
+ // See https://github.com/tdegrunt/jsonschema/issues/206
713
+ value === void 0 ? null : value,
714
+ path,
715
+ newErrorSchema,
716
+ id
717
+ );
718
+ },
719
+ [onChange]
720
+ );
721
+ const onSelectChange = react.useCallback(
722
+ (value) => {
723
+ onChange(value, fieldPathId.path, void 0, fieldPathId?.[utils.ID_KEY]);
724
+ },
725
+ [onChange, fieldPathId]
726
+ );
727
+ if (!(utils.ITEMS_KEY in schema)) {
728
+ const uiOptions = utils.getUiOptions(uiSchema);
729
+ const UnsupportedFieldTemplate = utils.getTemplate(
730
+ "UnsupportedFieldTemplate",
807
731
  registry,
808
- schema: itemSchema,
809
- uiSchema: itemUiSchema
810
- };
732
+ uiOptions
733
+ );
734
+ return /* @__PURE__ */ jsxRuntime.jsx(
735
+ UnsupportedFieldTemplate,
736
+ {
737
+ schema,
738
+ fieldPathId,
739
+ reason: translateString(utils.TranslatableString.MissingItems),
740
+ registry
741
+ }
742
+ );
811
743
  }
812
- };
813
- var ArrayField_default = ArrayField;
744
+ const arrayProps = {
745
+ handleAddItem,
746
+ handleCopyItem,
747
+ handleRemoveItem,
748
+ handleReorderItems,
749
+ keyedFormData,
750
+ onChange: handleChange
751
+ };
752
+ if (schemaUtils.isMultiSelect(schema)) {
753
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsMultiSelect, { ...props, onSelectChange });
754
+ }
755
+ if (utils.isCustomWidget(uiSchema)) {
756
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsCustomWidget, { ...props, onSelectChange });
757
+ }
758
+ if (utils.isFixedItems(schema)) {
759
+ return /* @__PURE__ */ jsxRuntime.jsx(FixedArray, { ...props, ...arrayProps });
760
+ }
761
+ if (schemaUtils.isFilesArray(schema, uiSchema)) {
762
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsFiles, { ...props, onSelectChange });
763
+ }
764
+ return /* @__PURE__ */ jsxRuntime.jsx(NormalArray, { ...props, ...arrayProps });
765
+ }
814
766
  function BooleanField(props) {
815
767
  const {
816
768
  schema,
@@ -831,7 +783,7 @@
831
783
  rawErrors
832
784
  } = props;
833
785
  const { title: schemaTitle } = schema;
834
- const { widgets: widgets2, formContext, translateString, globalUiOptions } = registry;
786
+ const { widgets: widgets2, translateString, globalUiOptions } = registry;
835
787
  const {
836
788
  widget = "checkbox",
837
789
  title: uiTitle,
@@ -903,9 +855,9 @@
903
855
  readonly,
904
856
  hideError,
905
857
  registry,
906
- formContext,
907
858
  autofocus,
908
- rawErrors
859
+ rawErrors,
860
+ htmlName: fieldPathId.name
909
861
  }
910
862
  );
911
863
  }
@@ -918,518 +870,339 @@
918
870
  function isNumericIndex(str) {
919
871
  return /^\d+?$/.test(str);
920
872
  }
921
- var LayoutGridField = class _LayoutGridField extends react.PureComponent {
922
- static defaultProps = {
923
- layoutGridSchema: void 0
924
- };
925
- static TEST_IDS = utils.getTestIds();
926
- /** Computes the uiSchema for the field with `name` from the `uiProps` and `uiSchema` provided. The field UI Schema
927
- * will always contain a copy of the global options from the `uiSchema` (so they can be passed down) as well as
928
- * copying them into the local ui options. When the `forceReadonly` flag is true, then the field UI Schema is
929
- * updated to make "readonly" be true. When the `schemaReadonly` flag is true AND the field UI Schema does NOT have
930
- * the flag already provided, then we also make "readonly" true. We always make sure to return the final value of the
931
- * field UI Schema's "readonly" flag as `uiReadonly` along with the `fieldUiSchema` in the return value.
932
- *
933
- * @param field - The name of the field to pull the existing UI Schema for
934
- * @param uiProps - Any props that should be put into the field's uiSchema
935
- * @param [uiSchema] - The optional UI Schema from which to get the UI schema for the field
936
- * @param [schemaReadonly] - Optional flag indicating whether the schema indicates the field is readonly
937
- * @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
938
- */
939
- static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
940
- const globalUiOptions = get2(uiSchema, [utils.UI_GLOBAL_OPTIONS_KEY], {});
941
- const localUiSchema = get2(uiSchema, field);
942
- const localUiOptions = { ...get2(localUiSchema, [utils.UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
943
- const fieldUiSchema = { ...localUiSchema };
944
- if (!isEmpty(localUiOptions)) {
945
- set(fieldUiSchema, [utils.UI_OPTIONS_KEY], localUiOptions);
946
- }
947
- if (!isEmpty(globalUiOptions)) {
948
- set(fieldUiSchema, [utils.UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
949
- }
950
- let { readonly: uiReadonly } = utils.getUiOptions(fieldUiSchema);
951
- if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
952
- uiReadonly = true;
953
- if (has(localUiOptions, utils.READONLY_KEY)) {
954
- set(fieldUiSchema, [utils.UI_OPTIONS_KEY, utils.READONLY_KEY], true);
955
- } else {
956
- set(fieldUiSchema, `ui:${utils.READONLY_KEY}`, true);
957
- }
958
- }
959
- return { fieldUiSchema, uiReadonly };
873
+ var LAYOUT_GRID_FIELD_TEST_IDS = utils.getTestIds();
874
+ function computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
875
+ const globalUiOptions = get(uiSchema, [utils.UI_GLOBAL_OPTIONS_KEY], {});
876
+ const localUiSchema = get(uiSchema, field);
877
+ const localUiOptions = { ...get(localUiSchema, [utils.UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
878
+ const fieldUiSchema = { ...localUiSchema };
879
+ if (!isEmpty(localUiOptions)) {
880
+ set(fieldUiSchema, [utils.UI_OPTIONS_KEY], localUiOptions);
960
881
  }
961
- /** Given an `operator`, `datum` and `value` determines whether this condition is considered matching. Matching
962
- * depends on the `operator`. The `datum` and `value` are converted into arrays if they aren't already and then the
963
- * contents of the two arrays are compared using the `operator`. When `operator` is All, then the two arrays must be
964
- * equal to match. When `operator` is SOME then the intersection of the two arrays must have at least one value in
965
- * common to match. When `operator` is NONE then the intersection of the two arrays must not have any values in common
966
- * to match.
967
- *
968
- * @param [operator] - The optional operator for the condition
969
- * @param [datum] - The optional datum for the condition, this can be an item or a list of items of type unknown
970
- * @param [value='$0m3tH1nG Un3xP3cT3d'] The optional value for the condition, defaulting to a highly unlikely value
971
- * to avoid comparing two undefined elements when `value` was forgotten in the condition definition.
972
- * This can be an item or a list of items of type unknown
973
- * @returns - True if the condition matches, false otherwise
974
- */
975
- static conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
976
- const data = flatten([datum]).sort();
977
- const values = flatten([value]).sort();
978
- switch (operator) {
979
- case "all" /* ALL */:
980
- return isEqual(data, values);
981
- case "some" /* SOME */:
982
- return intersection(data, values).length > 0;
983
- case "none" /* NONE */:
984
- return intersection(data, values).length === 0;
985
- default:
986
- return false;
987
- }
882
+ if (!isEmpty(globalUiOptions)) {
883
+ set(fieldUiSchema, [utils.UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
988
884
  }
989
- /** From within the `layoutGridSchema` finds the `children` and any extra `gridProps` from the object keyed by
990
- * `schemaKey`. If the `children` contains extra `gridProps` and those props contain a `className` string, try to
991
- * lookup whether that `className` has a replacement value in the `registry` using the `FORM_CONTEXT_LOOKUP_BASE`.
992
- * When the `className` value contains multiple classNames separated by a space, the lookup will look for a
993
- * replacement value for each `className` and combine them into one.
994
- *
995
- * @param layoutGridSchema - The GridSchemaType instance from which to obtain the `schemaKey` children and extra props
996
- * @param schemaKey - A `GridType` value, used to get the children and extra props from within the `layoutGridSchema`
997
- * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
998
- * @returns - An object containing the list of `LayoutGridSchemaType` `children` and any extra `gridProps`
999
- * @throws - A `TypeError` when the `children` is not an array
1000
- */
1001
- static findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
1002
- let gridProps = {};
1003
- let children = layoutGridSchema[schemaKey];
1004
- if (isPlainObject(children)) {
1005
- const { children: elements, className: toMapClassNames, ...otherProps } = children;
1006
- children = elements;
1007
- if (toMapClassNames) {
1008
- const classes = toMapClassNames.split(" ");
1009
- const className = classes.map((ele) => utils.lookupFromFormContext(registry, ele, ele)).join(" ");
1010
- gridProps = { ...otherProps, className };
1011
- } else {
1012
- gridProps = otherProps;
1013
- }
1014
- }
1015
- if (!Array.isArray(children)) {
1016
- throw new TypeError(`Expected array for "${schemaKey}" in ${JSON.stringify(layoutGridSchema)}`);
885
+ let { readonly: uiReadonly } = utils.getUiOptions(fieldUiSchema);
886
+ if (forceReadonly === true || isUndefined(uiReadonly) && schemaReadonly === true) {
887
+ uiReadonly = true;
888
+ if (has(localUiOptions, utils.READONLY_KEY)) {
889
+ set(fieldUiSchema, [utils.UI_OPTIONS_KEY, utils.READONLY_KEY], true);
890
+ } else {
891
+ set(fieldUiSchema, `ui:${utils.READONLY_KEY}`, true);
1017
892
  }
1018
- return { children, gridProps };
1019
893
  }
1020
- /** Computes the `rawSchema` and `fieldPathId` for a `schema` and a `potentialIndex`. If the `schema` is of type array,
1021
- * has an `ITEMS_KEY` element and `potentialIndex` represents a numeric value, the element at `ITEMS_KEY` is checked
1022
- * to see if it is an array. If it is AND the `potentialIndex`th element is available, it is used as the `rawSchema`,
1023
- * otherwise the last value of the element is used. If it is not, then the element is used as the `rawSchema`. In
1024
- * either case, an `fieldPathId` is computed for the array index. If the `schema` does not represent an array or the
1025
- * `potentialIndex` is not a numeric value, then `rawSchema` is returned as undefined and given `fieldPathId` is returned
1026
- * as is.
1027
- *
1028
- * @param schema - The schema to generate the fieldPathId for
1029
- * @param fieldPathId - The FieldPathId for the schema
1030
- * @param potentialIndex - A string containing a potential index
1031
- * @returns - An object containing the `rawSchema` and `fieldPathId` of an array item, otherwise an undefined `rawSchema`
1032
- */
1033
- static computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
1034
- let rawSchema;
1035
- if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, utils.ITEMS_KEY)) {
1036
- const index = Number(potentialIndex);
1037
- const items = schema[utils.ITEMS_KEY];
1038
- if (Array.isArray(items)) {
1039
- if (index > items.length) {
1040
- rawSchema = last(items);
1041
- } else {
1042
- rawSchema = items[index];
1043
- }
1044
- } else {
1045
- rawSchema = items;
1046
- }
1047
- fieldPathId = {
1048
- [utils.ID_KEY]: fieldPathId[utils.ID_KEY],
1049
- path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
1050
- };
1051
- }
1052
- return { rawSchema, fieldPathId };
894
+ return { fieldUiSchema, uiReadonly };
895
+ }
896
+ function conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
897
+ const data = flatten([datum]).sort();
898
+ const values = flatten([value]).sort();
899
+ switch (operator) {
900
+ case "all" /* ALL */:
901
+ return isEqual(data, values);
902
+ case "some" /* SOME */:
903
+ return intersection(data, values).length > 0;
904
+ case "none" /* NONE */:
905
+ return intersection(data, values).length === 0;
906
+ default:
907
+ return false;
1053
908
  }
1054
- /** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
1055
- * the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
1056
- * element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
1057
- * `options`.
1058
- *
1059
- * @param registry - The registry
1060
- * @param dottedPath - The dotted-path to the field for which to get the schema
1061
- * @param initialSchema - The initial schema to start the search from
1062
- * @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
1063
- * @param initialFieldIdPath - The initial fieldPathId to start the search from
1064
- * @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
1065
- * info if a oneOf/anyOf
1066
- */
1067
- static getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
1068
- const { schemaUtils, globalFormOptions } = registry;
1069
- let rawSchema = initialSchema;
1070
- let fieldPathId = initialFieldIdPath;
1071
- const parts = dottedPath.split(".");
1072
- const leafPath = parts.pop();
1073
- let schema = schemaUtils.retrieveSchema(rawSchema, formData);
1074
- let innerData = formData;
1075
- let isReadonly = schema.readOnly;
1076
- parts.forEach((part) => {
1077
- fieldPathId = utils.toFieldPathId(part, globalFormOptions, fieldPathId);
1078
- if (has(schema, utils.PROPERTIES_KEY)) {
1079
- rawSchema = get2(schema, [utils.PROPERTIES_KEY, part], {});
1080
- } else if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
1081
- const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
1082
- const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
1083
- rawSchema = get2(selectedSchema, [utils.PROPERTIES_KEY, part], {});
1084
- } else {
1085
- const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, part);
1086
- rawSchema = result.rawSchema ?? {};
1087
- fieldPathId = result.fieldPathId;
1088
- }
1089
- innerData = get2(innerData, part, {});
1090
- schema = schemaUtils.retrieveSchema(rawSchema, innerData);
1091
- isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
1092
- });
1093
- let optionsInfo;
1094
- let isRequired = false;
1095
- if (isEmpty(schema)) {
1096
- schema = void 0;
909
+ }
910
+ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
911
+ let gridProps = {};
912
+ let children = layoutGridSchema[schemaKey];
913
+ if (isPlainObject(children)) {
914
+ const { children: elements, className: toMapClassNames, ...otherProps } = children;
915
+ children = elements;
916
+ if (toMapClassNames) {
917
+ const classes = toMapClassNames.split(" ");
918
+ const className = classes.map((ele) => utils.lookupFromFormContext(registry, ele, ele)).join(" ");
919
+ gridProps = { ...otherProps, className };
920
+ } else {
921
+ gridProps = otherProps;
1097
922
  }
1098
- if (schema && leafPath) {
1099
- if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
1100
- const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
1101
- schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
1102
- }
1103
- fieldPathId = utils.toFieldPathId(leafPath, globalFormOptions, fieldPathId);
1104
- isRequired = schema !== void 0 && Array.isArray(schema.required) && includes(schema.required, leafPath);
1105
- const result = _LayoutGridField.computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
1106
- if (result.rawSchema) {
1107
- schema = result.rawSchema;
1108
- fieldPathId = result.fieldPathId;
923
+ }
924
+ if (!Array.isArray(children)) {
925
+ throw new TypeError(`Expected array for "${schemaKey}" in ${JSON.stringify(layoutGridSchema)}`);
926
+ }
927
+ return { children, gridProps };
928
+ }
929
+ function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
930
+ let rawSchema;
931
+ if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, utils.ITEMS_KEY)) {
932
+ const index = Number(potentialIndex);
933
+ const items = schema[utils.ITEMS_KEY];
934
+ if (Array.isArray(items)) {
935
+ if (index > items.length) {
936
+ rawSchema = last(items);
1109
937
  } else {
1110
- schema = get2(schema, [utils.PROPERTIES_KEY, leafPath]);
1111
- schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
1112
- }
1113
- isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
1114
- if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
1115
- const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
1116
- const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1117
- optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
938
+ rawSchema = items[index];
1118
939
  }
940
+ } else {
941
+ rawSchema = items;
1119
942
  }
1120
- return { schema, isRequired, isReadonly, optionsInfo, fieldPathId };
943
+ fieldPathId = {
944
+ [utils.ID_KEY]: fieldPathId[utils.ID_KEY],
945
+ path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
946
+ };
1121
947
  }
1122
- /** Gets the custom render component from the `render`, by either determining that it is either already a function or
1123
- * it is a non-function value that can be used to look up the function in the registry. If no function can be found,
1124
- * null is returned.
1125
- *
1126
- * @param render - The potential render function or lookup name to one
1127
- * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
1128
- * @returns - Either a render function if available, or null if not
1129
- */
1130
- static getCustomRenderComponent(render, registry) {
1131
- let customRenderer = render;
1132
- if (isString(customRenderer)) {
1133
- customRenderer = utils.lookupFromFormContext(registry, customRenderer);
1134
- }
1135
- if (isFunction(customRenderer)) {
1136
- return customRenderer;
948
+ return { rawSchema, fieldPathId };
949
+ }
950
+ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
951
+ const { schemaUtils, globalFormOptions } = registry;
952
+ let rawSchema = initialSchema;
953
+ let fieldPathId = initialFieldIdPath;
954
+ const parts = dottedPath.split(".");
955
+ const leafPath = parts.pop();
956
+ let schema = schemaUtils.retrieveSchema(rawSchema, formData);
957
+ let innerData = formData;
958
+ let isReadonly = schema.readOnly;
959
+ parts.forEach((part) => {
960
+ fieldPathId = utils.toFieldPathId(part, globalFormOptions, fieldPathId);
961
+ if (has(schema, utils.PROPERTIES_KEY)) {
962
+ rawSchema = get(schema, [utils.PROPERTIES_KEY, part], {});
963
+ } else if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
964
+ const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
965
+ const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
966
+ rawSchema = get(selectedSchema, [utils.PROPERTIES_KEY, part], {});
967
+ } else {
968
+ const result = computeArraySchemasIfPresent(schema, fieldPathId, part);
969
+ rawSchema = result.rawSchema ?? {};
970
+ fieldPathId = result.fieldPathId;
1137
971
  }
1138
- return null;
972
+ innerData = get(innerData, part, {});
973
+ schema = schemaUtils.retrieveSchema(rawSchema, innerData);
974
+ isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
975
+ });
976
+ let optionsInfo;
977
+ let isRequired2 = false;
978
+ if (isEmpty(schema)) {
979
+ schema = void 0;
1139
980
  }
1140
- /** Extract the `name`, and optional `render` and all other props from the `gridSchema`. We look up the `render` to
1141
- * see if can be resolved to a UIComponent. If `name` does not exist and there is an optional `render` UIComponent, we
1142
- * set the `rendered` component with only specified props for that component in the object.
1143
- *
1144
- * @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
1145
- * @param gridSchema - The string or object that represents the configuration for the grid field
1146
- * @returns - The UIComponentPropsType computed from the gridSchema
1147
- */
1148
- static computeUIComponentPropsFromGridSchema(registry, gridSchema) {
1149
- let name;
1150
- let UIComponent = null;
1151
- let uiProps = {};
1152
- let rendered;
1153
- if (isString(gridSchema) || isUndefined(gridSchema)) {
1154
- name = gridSchema ?? "";
981
+ if (schema && leafPath) {
982
+ if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
983
+ const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
984
+ schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
985
+ }
986
+ fieldPathId = utils.toFieldPathId(leafPath, globalFormOptions, fieldPathId);
987
+ isRequired2 = schema !== void 0 && Array.isArray(schema.required) && includes(schema.required, leafPath);
988
+ const result = computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
989
+ if (result.rawSchema) {
990
+ schema = result.rawSchema;
991
+ fieldPathId = result.fieldPathId;
1155
992
  } else {
1156
- const { name: innerName = "", render, ...innerProps } = gridSchema;
1157
- name = innerName;
1158
- uiProps = innerProps;
1159
- if (!isEmpty(uiProps)) {
1160
- each(uiProps, (prop, key) => {
1161
- if (isString(prop)) {
1162
- const match = LOOKUP_REGEX.exec(prop);
1163
- if (Array.isArray(match) && match.length > 1) {
1164
- const name2 = match[1];
1165
- uiProps[key] = utils.lookupFromFormContext(registry, name2, name2);
1166
- }
1167
- }
1168
- });
1169
- }
1170
- UIComponent = _LayoutGridField.getCustomRenderComponent(render, registry);
1171
- if (!innerName && UIComponent) {
1172
- rendered = /* @__PURE__ */ jsxRuntime.jsx(UIComponent, { ...innerProps, "data-testid": _LayoutGridField.TEST_IDS.uiComponent });
1173
- }
993
+ schema = get(schema, [utils.PROPERTIES_KEY, leafPath]);
994
+ schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
995
+ }
996
+ isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
997
+ if (schema && (has(schema, utils.ONE_OF_KEY) || has(schema, utils.ANY_OF_KEY))) {
998
+ const xxx = has(schema, utils.ONE_OF_KEY) ? utils.ONE_OF_KEY : utils.ANY_OF_KEY;
999
+ const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1000
+ optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
1174
1001
  }
1175
- return { name, UIComponent, uiProps, rendered };
1176
1002
  }
1177
- /** Constructs an `LayoutGridField` with the given `props`
1178
- *
1179
- * @param props - The `LayoutGridField` for this template
1180
- */
1181
- constructor(props) {
1182
- super(props);
1003
+ return { schema, isRequired: isRequired2, isReadonly, optionsInfo, fieldPathId };
1004
+ }
1005
+ function getCustomRenderComponent(render, registry) {
1006
+ let customRenderer = render;
1007
+ if (isString(customRenderer)) {
1008
+ customRenderer = utils.lookupFromFormContext(registry, customRenderer);
1183
1009
  }
1184
- /** Generates an `onChange` handler for the field associated with the `dottedPath`. This handler will clone and update
1185
- * the `formData` with the new `value` and the `errorSchema` if an `errSchema` is provided. After updating those two
1186
- * elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
1187
- *
1188
- * @param dottedPath - The dotted-path to the field for which to generate the onChange handler
1189
- * @returns - The `onChange` handling function for the `dottedPath` field of the `schemaType` type
1190
- */
1191
- onFieldChange = (dottedPath) => {
1192
- return (value, path, errSchema, id) => {
1193
- const { onChange } = this.props;
1194
- onChange(value, path, errSchema, id);
1195
- };
1196
- };
1197
- /** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
1198
- * `GridType.CONDITION` is separated into the `children` and other `gridProps`. The `gridProps` are used to extract
1199
- * the `operator`, `field` and `value` of the condition. If the condition matches, then all of the `children` are
1200
- * rendered, otherwise null is returned.
1201
- *
1202
- * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1203
- * @returns - The rendered the children for the `GridType.CONDITION` or null
1204
- */
1205
- renderCondition(layoutGridSchema) {
1206
- const { formData, registry } = this.props;
1207
- const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1208
- layoutGridSchema,
1209
- "ui:condition" /* CONDITION */,
1210
- registry
1211
- );
1212
- const { operator, field = "", value } = gridProps;
1213
- const fieldData = get2(formData, field, null);
1214
- if (_LayoutGridField.conditionMatches(operator, fieldData, value)) {
1215
- return this.renderChildren(children);
1216
- }
1217
- return null;
1010
+ if (isFunction(customRenderer)) {
1011
+ return customRenderer;
1218
1012
  }
1219
- /** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated
1220
- * into the `children` and other `gridProps`. The `gridProps` will be spread onto the outer `GridTemplate`. Inside
1221
- * the `GridTemplate` all the `children` are rendered.
1222
- *
1223
- * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1224
- * @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMN`
1225
- */
1226
- renderCol(layoutGridSchema) {
1227
- const { registry, uiSchema } = this.props;
1228
- const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1229
- layoutGridSchema,
1230
- "ui:col" /* COLUMN */,
1231
- registry
1232
- );
1233
- const uiOptions = utils.getUiOptions(uiSchema);
1234
- const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1235
- return /* @__PURE__ */ jsxRuntime.jsx(GridTemplate2, { column: true, "data-testid": _LayoutGridField.TEST_IDS.col, ...gridProps, children: this.renderChildren(children) });
1013
+ return null;
1014
+ }
1015
+ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
1016
+ let name;
1017
+ let UIComponent = null;
1018
+ let uiProps = {};
1019
+ let rendered;
1020
+ if (isString(gridSchema) || isUndefined(gridSchema)) {
1021
+ name = gridSchema ?? "";
1022
+ } else {
1023
+ const { name: innerName = "", render, ...innerProps } = gridSchema;
1024
+ name = innerName;
1025
+ uiProps = innerProps;
1026
+ if (!isEmpty(uiProps)) {
1027
+ each(uiProps, (prop, key) => {
1028
+ if (isString(prop)) {
1029
+ const match = LOOKUP_REGEX.exec(prop);
1030
+ if (Array.isArray(match) && match.length > 1) {
1031
+ const name2 = match[1];
1032
+ uiProps[key] = utils.lookupFromFormContext(registry, name2, name2);
1033
+ }
1034
+ }
1035
+ });
1036
+ }
1037
+ UIComponent = getCustomRenderComponent(render, registry);
1038
+ if (!innerName && UIComponent) {
1039
+ rendered = /* @__PURE__ */ jsxRuntime.jsx(UIComponent, { ...innerProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent });
1040
+ }
1236
1041
  }
1237
- /** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated
1238
- * into the `children` and other `gridProps`. The `children` is iterated on and `gridProps` will be spread onto the
1239
- * outer `GridTemplate`. Each child will have their own rendered `GridTemplate`.
1240
- *
1241
- * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1242
- * @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMNS`
1243
- */
1244
- renderColumns(layoutGridSchema) {
1245
- const { registry, uiSchema } = this.props;
1246
- const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1247
- layoutGridSchema,
1248
- "ui:columns" /* COLUMNS */,
1249
- registry
1250
- );
1251
- const uiOptions = utils.getUiOptions(uiSchema);
1252
- const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1253
- return children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
1254
- GridTemplate2,
1255
- {
1256
- column: true,
1257
- "data-testid": _LayoutGridField.TEST_IDS.col,
1258
- ...gridProps,
1259
- children: this.renderChildren([child])
1260
- },
1261
- `column-${utils.hashObject(child)}`
1262
- ));
1042
+ return { name, UIComponent, uiProps, rendered };
1043
+ }
1044
+ function LayoutGridFieldChildren(props) {
1045
+ const { childrenLayoutGridSchemaId, ...layoutGridFieldProps } = props;
1046
+ const { registry, schema: rawSchema, formData } = layoutGridFieldProps;
1047
+ const { schemaUtils } = registry;
1048
+ const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1049
+ return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react.createElement(
1050
+ LayoutGridField,
1051
+ {
1052
+ ...layoutGridFieldProps,
1053
+ key: `layoutGrid-${utils.hashObject(layoutGridSchema)}`,
1054
+ schema,
1055
+ layoutGridSchema
1056
+ }
1057
+ ));
1058
+ }
1059
+ function LayoutGridCondition(props) {
1060
+ const { layoutGridSchema, ...layoutGridFieldProps } = props;
1061
+ const { formData, registry } = layoutGridFieldProps;
1062
+ const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:condition" /* CONDITION */, registry);
1063
+ const { operator, field = "", value } = gridProps;
1064
+ const fieldData = get(formData, field, null);
1065
+ if (conditionMatches(operator, fieldData, value)) {
1066
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children });
1263
1067
  }
1264
- /** Renders a material-ui `GridTemplate` as a container. The
1265
- * `layoutGridSchema` for the `GridType.ROW` is separated into the `children` and other `gridProps`. The `gridProps`
1266
- * will be spread onto the outer `GridTemplate`. Inside of the `GridTemplate` all of the `children` are rendered.
1267
- *
1268
- * @param layoutGridSchema - The string or object that represents the configuration for the grid field
1269
- * @returns - The rendered `GridTemplate` containing the children for the `GridType.ROW`
1270
- */
1271
- renderRow(layoutGridSchema) {
1272
- const { registry, uiSchema } = this.props;
1273
- const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
1274
- layoutGridSchema,
1275
- "ui:row" /* ROW */,
1276
- registry
1277
- );
1278
- const uiOptions = utils.getUiOptions(uiSchema);
1279
- const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1280
- return /* @__PURE__ */ jsxRuntime.jsx(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
1068
+ return null;
1069
+ }
1070
+ function LayoutGridCol(props) {
1071
+ const { layoutGridSchema, ...layoutGridFieldProps } = props;
1072
+ const { registry, uiSchema } = layoutGridFieldProps;
1073
+ const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:col" /* COLUMN */, registry);
1074
+ const uiOptions = utils.getUiOptions(uiSchema);
1075
+ const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1076
+ return /* @__PURE__ */ jsxRuntime.jsx(GridTemplate2, { column: true, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col, ...gridProps, children: /* @__PURE__ */ jsxRuntime.jsx(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
1077
+ }
1078
+ function LayoutGridColumns(props) {
1079
+ const { layoutGridSchema, ...layoutGridFieldProps } = props;
1080
+ const { registry, uiSchema } = layoutGridFieldProps;
1081
+ const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:columns" /* COLUMNS */, registry);
1082
+ const uiOptions = utils.getUiOptions(uiSchema);
1083
+ const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1084
+ return children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
1085
+ GridTemplate2,
1086
+ {
1087
+ column: true,
1088
+ "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col,
1089
+ ...gridProps,
1090
+ children: /* @__PURE__ */ jsxRuntime.jsx(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: [child] })
1091
+ },
1092
+ `column-${utils.hashObject(child)}`
1093
+ ));
1094
+ }
1095
+ function LayoutGridRow(props) {
1096
+ const { layoutGridSchema, ...layoutGridFieldProps } = props;
1097
+ const { registry, uiSchema } = layoutGridFieldProps;
1098
+ const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:row" /* ROW */, registry);
1099
+ const uiOptions = utils.getUiOptions(uiSchema);
1100
+ const GridTemplate2 = utils.getTemplate("GridTemplate", registry, uiOptions);
1101
+ return /* @__PURE__ */ jsxRuntime.jsx(GridTemplate2, { ...gridProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.row, children: /* @__PURE__ */ jsxRuntime.jsx(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
1102
+ }
1103
+ function LayoutGridFieldComponent(props) {
1104
+ const {
1105
+ gridSchema,
1106
+ schema: initialSchema,
1107
+ uiSchema,
1108
+ errorSchema,
1109
+ fieldPathId,
1110
+ onBlur,
1111
+ onFocus,
1112
+ formData,
1113
+ readonly,
1114
+ registry,
1115
+ layoutGridSchema,
1116
+ // Used to pull this out of otherProps since we don't want to pass it through
1117
+ ...otherProps
1118
+ } = props;
1119
+ const { onChange } = otherProps;
1120
+ const { fields: fields2 } = registry;
1121
+ const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
1122
+ const uiComponentProps = computeUIComponentPropsFromGridSchema(registry, gridSchema);
1123
+ const { name, UIComponent, uiProps } = uiComponentProps;
1124
+ const {
1125
+ schema,
1126
+ isRequired: isRequired2,
1127
+ isReadonly,
1128
+ optionsInfo,
1129
+ fieldPathId: fieldIdSchema
1130
+ } = getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
1131
+ const memoFieldPathId = utils.useDeepCompareMemo(fieldIdSchema);
1132
+ if (uiComponentProps.rendered) {
1133
+ return uiComponentProps.rendered;
1281
1134
  }
1282
- /** Iterates through all the `childrenLayoutGrfieldPathId`, rendering a nested `LayoutGridField` for each item in the
1283
- * list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
1284
- * `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
1285
- * `childrenLayoutGrfieldPathId` is passed as `layoutGridSchema`.
1286
- *
1287
- * @param childrenLayoutGrfieldPathId - The list of strings or objects that represents the configurations for the
1288
- * children fields
1289
- * @returns - The nested `LayoutGridField`s
1290
- */
1291
- renderChildren(childrenLayoutGrfieldPathId) {
1292
- const { registry, schema: rawSchema, formData } = this.props;
1293
- const { schemaUtils } = registry;
1294
- const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1295
- return childrenLayoutGrfieldPathId.map((layoutGridSchema) => /* @__PURE__ */ react.createElement(
1296
- _LayoutGridField,
1135
+ if (schema) {
1136
+ const Field2 = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
1137
+ const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
1138
+ return /* @__PURE__ */ jsxRuntime.jsx(
1139
+ Field2,
1297
1140
  {
1298
- ...this.props,
1299
- key: `layoutGrid-${utils.hashObject(layoutGridSchema)}`,
1141
+ "data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
1142
+ ...otherProps,
1143
+ name,
1144
+ required: isRequired2,
1145
+ readonly: uiReadonly,
1300
1146
  schema,
1301
- layoutGridSchema
1147
+ uiSchema: fieldUiSchema,
1148
+ errorSchema: get(errorSchema, name),
1149
+ fieldPathId: memoFieldPathId,
1150
+ formData: get(formData, name),
1151
+ onChange,
1152
+ onBlur,
1153
+ onFocus,
1154
+ options: optionsInfo?.options,
1155
+ registry
1302
1156
  }
1303
- ));
1157
+ );
1304
1158
  }
1305
- /** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
1306
- * to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
1307
- * other props. If `name` does not exist and there is an optional `render`, we return the `render` component with only
1308
- * specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
1309
- * and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
1310
- * schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
1311
- * `uiSchema`, `errorSchema`, `fieldPathId` and `formData` drilled down to the dotted-path field, spreading any other
1312
- * props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
1313
- * then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
1314
- * schema was located, but a custom render component was found, then it will be rendered with many of the non-event
1315
- * handling props. If none of the previous render paths are valid, then a null is returned.
1316
- *
1317
- * @param gridSchema - The string or object that represents the configuration for the grid field
1318
- * @returns - One of `LayoutMultiSchemaField`, `SchemaField`, a custom render component or null, depending
1319
- */
1320
- renderField(gridSchema) {
1321
- const {
1322
- schema: initialSchema,
1323
- uiSchema,
1324
- errorSchema,
1325
- fieldPathId,
1326
- onBlur,
1327
- onFocus,
1328
- formData,
1329
- readonly,
1330
- registry,
1331
- layoutGridSchema,
1332
- // Used to pull this out of otherProps since we don't want to pass it through
1333
- ...otherProps
1334
- } = this.props;
1335
- const { fields: fields2 } = registry;
1336
- const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
1337
- const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
1338
- if (uiComponentProps.rendered) {
1339
- return uiComponentProps.rendered;
1340
- }
1341
- const { name, UIComponent, uiProps } = uiComponentProps;
1342
- const {
1343
- schema,
1344
- isRequired,
1345
- isReadonly,
1346
- optionsInfo,
1347
- fieldPathId: fieldIdSchema
1348
- } = _LayoutGridField.getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
1349
- if (schema) {
1350
- const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
1351
- const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
1159
+ if (UIComponent) {
1160
+ return /* @__PURE__ */ jsxRuntime.jsx(
1161
+ UIComponent,
1162
+ {
1163
+ "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent,
1164
+ ...otherProps,
1352
1165
  name,
1353
- uiProps,
1166
+ required: isRequired2,
1167
+ formData,
1168
+ readOnly: !!isReadonly || readonly,
1169
+ errorSchema,
1354
1170
  uiSchema,
1355
- isReadonly,
1356
- readonly
1357
- );
1358
- return /* @__PURE__ */ jsxRuntime.jsx(
1359
- Field,
1360
- {
1361
- "data-testid": optionsInfo?.hasDiscriminator ? _LayoutGridField.TEST_IDS.layoutMultiSchemaField : _LayoutGridField.TEST_IDS.field,
1362
- ...otherProps,
1363
- name,
1364
- required: isRequired,
1365
- readonly: uiReadonly,
1366
- schema,
1367
- uiSchema: fieldUiSchema,
1368
- errorSchema: get2(errorSchema, name),
1369
- fieldPathId: fieldIdSchema,
1370
- formData: get2(formData, name),
1371
- onChange: this.onFieldChange(name),
1372
- onBlur,
1373
- onFocus,
1374
- options: optionsInfo?.options,
1375
- registry
1376
- }
1377
- );
1171
+ schema: initialSchema,
1172
+ fieldPathId,
1173
+ onBlur,
1174
+ onFocus,
1175
+ registry,
1176
+ ...uiProps
1177
+ }
1178
+ );
1179
+ }
1180
+ return null;
1181
+ }
1182
+ function LayoutGridField(props) {
1183
+ const { uiSchema } = props;
1184
+ let { layoutGridSchema } = props;
1185
+ const uiOptions = utils.getUiOptions(uiSchema);
1186
+ if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && isObject(uiOptions[LAYOUT_GRID_UI_OPTION])) {
1187
+ layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
1188
+ }
1189
+ if (isObject(layoutGridSchema)) {
1190
+ if ("ui:row" /* ROW */ in layoutGridSchema) {
1191
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridRow, { ...props, layoutGridSchema });
1378
1192
  }
1379
- if (UIComponent) {
1380
- return /* @__PURE__ */ jsxRuntime.jsx(
1381
- UIComponent,
1382
- {
1383
- "data-testid": _LayoutGridField.TEST_IDS.uiComponent,
1384
- ...otherProps,
1385
- name,
1386
- required: isRequired,
1387
- formData,
1388
- readOnly: !!isReadonly || readonly,
1389
- errorSchema,
1390
- uiSchema,
1391
- schema: initialSchema,
1392
- fieldPathId,
1393
- onBlur,
1394
- onFocus,
1395
- registry,
1396
- ...uiProps
1397
- }
1398
- );
1193
+ if ("ui:col" /* COLUMN */ in layoutGridSchema) {
1194
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridCol, { ...props, layoutGridSchema });
1399
1195
  }
1400
- return null;
1401
- }
1402
- /** Renders the `LayoutGridField`. If there isn't a `layoutGridSchema` prop defined, then try pulling it out of the
1403
- * `uiSchema` via `ui:LayoutGridField`. If `layoutGridSchema` is an object, then check to see if any of the properties
1404
- * match one of the `GridType`s. If so, call the appropriate render function for the type. Otherwise, just call the
1405
- * generic `renderField()` function with the `layoutGridSchema`.
1406
- *
1407
- * @returns - the rendered `LayoutGridField`
1408
- */
1409
- render() {
1410
- const { uiSchema } = this.props;
1411
- let { layoutGridSchema } = this.props;
1412
- const uiOptions = utils.getUiOptions(uiSchema);
1413
- if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && isObject(uiOptions[LAYOUT_GRID_UI_OPTION])) {
1414
- layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
1196
+ if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
1197
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridColumns, { ...props, layoutGridSchema });
1415
1198
  }
1416
- if (isObject(layoutGridSchema)) {
1417
- if ("ui:row" /* ROW */ in layoutGridSchema) {
1418
- return this.renderRow(layoutGridSchema);
1419
- }
1420
- if ("ui:col" /* COLUMN */ in layoutGridSchema) {
1421
- return this.renderCol(layoutGridSchema);
1422
- }
1423
- if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
1424
- return this.renderColumns(layoutGridSchema);
1425
- }
1426
- if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
1427
- return this.renderCondition(layoutGridSchema);
1428
- }
1199
+ if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
1200
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridCondition, { ...props, layoutGridSchema });
1429
1201
  }
1430
- return this.renderField(layoutGridSchema);
1431
1202
  }
1432
- };
1203
+ return /* @__PURE__ */ jsxRuntime.jsx(LayoutGridFieldComponent, { ...props, gridSchema: layoutGridSchema });
1204
+ }
1205
+ LayoutGridField.TEST_IDS = LAYOUT_GRID_FIELD_TEST_IDS;
1433
1206
  function LayoutHeaderField(props) {
1434
1207
  const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
1435
1208
  const options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
@@ -1460,8 +1233,8 @@
1460
1233
  const defaultValue = "!@#!@$@#$!@$#";
1461
1234
  const schemaOptions = options.map(({ schema }) => schema);
1462
1235
  return schemaOptions.find((option) => {
1463
- const selector = get2(option, [utils.PROPERTIES_KEY, selectorField]);
1464
- const result = get2(selector, utils.DEFAULT_KEY, get2(selector, utils.CONST_KEY, defaultValue));
1236
+ const selector = get(option, [utils.PROPERTIES_KEY, selectorField]);
1237
+ const result = get(selector, utils.DEFAULT_KEY, get(selector, utils.CONST_KEY, defaultValue));
1465
1238
  return result === value;
1466
1239
  });
1467
1240
  }
@@ -1493,7 +1266,6 @@
1493
1266
  registry,
1494
1267
  uiSchema,
1495
1268
  schema,
1496
- formContext,
1497
1269
  autofocus,
1498
1270
  readonly,
1499
1271
  required,
@@ -1502,7 +1274,7 @@
1502
1274
  } = props;
1503
1275
  const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
1504
1276
  const [enumOptions, setEnumOptions] = react.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
1505
- const id = get2(fieldPathId, utils.ID_KEY);
1277
+ const id = get(fieldPathId, utils.ID_KEY);
1506
1278
  const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
1507
1279
  const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, options);
1508
1280
  const FieldTemplate2 = utils.getTemplate("FieldTemplate", registry, options);
@@ -1524,13 +1296,13 @@
1524
1296
  if (!selectorField) {
1525
1297
  throw new Error("No selector field provided for the LayoutMultiSchemaField");
1526
1298
  }
1527
- const selectedOption = get2(formData, selectorField);
1528
- let optionSchema = get2(enumOptions[0]?.schema, [utils.PROPERTIES_KEY, selectorField], {});
1299
+ const selectedOption = get(formData, selectorField);
1300
+ let optionSchema = get(enumOptions[0]?.schema, [utils.PROPERTIES_KEY, selectorField], {});
1529
1301
  const option = getSelectedOption(enumOptions, selectorField, selectedOption);
1530
1302
  optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
1531
1303
  const Widget = utils.getWidget(optionSchema, widget, widgets2);
1532
1304
  const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
1533
- const rawErrors = get2(errorSchema, [utils.ERRORS_KEY], []);
1305
+ const rawErrors = get(errorSchema, [utils.ERRORS_KEY], []);
1534
1306
  const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
1535
1307
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1536
1308
  const onOptionChange = (opt) => {
@@ -1547,7 +1319,6 @@
1547
1319
  };
1548
1320
  const widgetOptions = { enumOptions, ...uiOptions };
1549
1321
  const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
1550
- const ignored = (value) => noop;
1551
1322
  return /* @__PURE__ */ jsxRuntime.jsx(
1552
1323
  FieldTemplate2,
1553
1324
  {
@@ -1562,8 +1333,9 @@
1562
1333
  displayLabel,
1563
1334
  errors,
1564
1335
  onChange,
1565
- onDropPropertyClick: ignored,
1566
- onKeyChange: ignored,
1336
+ onKeyRename: noop,
1337
+ onKeyRenameBlur: noop,
1338
+ onRemoveProperty: noop,
1567
1339
  children: /* @__PURE__ */ jsxRuntime.jsx(
1568
1340
  Widget,
1569
1341
  {
@@ -1573,7 +1345,6 @@
1573
1345
  label: (title || schema.title) ?? "",
1574
1346
  disabled: disabled || Array.isArray(enumOptions) && isEmpty(enumOptions),
1575
1347
  uiSchema,
1576
- formContext,
1577
1348
  autofocus,
1578
1349
  readonly,
1579
1350
  required,
@@ -1588,7 +1359,8 @@
1588
1359
  onBlur,
1589
1360
  onFocus,
1590
1361
  value: selectedOption,
1591
- options: widgetOptions
1362
+ options: widgetOptions,
1363
+ htmlName: fieldPathId.name
1592
1364
  }
1593
1365
  )
1594
1366
  }
@@ -1690,10 +1462,11 @@
1690
1462
  name,
1691
1463
  disabled = false,
1692
1464
  errorSchema = {},
1693
- formContext,
1465
+ formData,
1694
1466
  onBlur,
1695
1467
  onFocus,
1696
1468
  readonly,
1469
+ required = false,
1697
1470
  registry,
1698
1471
  schema,
1699
1472
  uiSchema
@@ -1705,6 +1478,8 @@
1705
1478
  registry,
1706
1479
  globalUiOptions
1707
1480
  );
1481
+ const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
1482
+ const hasFormData = utils.isFormDataAvailable(formData);
1708
1483
  const { selectedOption, retrievedOptions } = this.state;
1709
1484
  const {
1710
1485
  widget = "select",
@@ -1715,14 +1490,14 @@
1715
1490
  ...uiOptions
1716
1491
  } = utils.getUiOptions(uiSchema, globalUiOptions);
1717
1492
  const Widget = utils.getWidget({ type: "number" }, widget, widgets2);
1718
- const rawErrors = get2(errorSchema, utils.ERRORS_KEY, []);
1493
+ const rawErrors = get(errorSchema, utils.ERRORS_KEY, []);
1719
1494
  const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
1720
1495
  const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1721
1496
  const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1722
1497
  let optionSchema;
1723
1498
  if (option) {
1724
- const { required } = schema;
1725
- optionSchema = required ? utils.mergeSchemas({ required }, option) : option;
1499
+ const { required: required2 } = schema;
1500
+ optionSchema = required2 ? utils.mergeSchemas({ required: required2 }, option) : option;
1726
1501
  }
1727
1502
  let optionsUiSchema = [];
1728
1503
  if (utils.ONE_OF_KEY in schema && uiSchema && utils.ONE_OF_KEY in uiSchema) {
@@ -1751,7 +1526,7 @@
1751
1526
  value: index
1752
1527
  };
1753
1528
  });
1754
- const selector = /* @__PURE__ */ jsxRuntime.jsx(
1529
+ const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ jsxRuntime.jsx(
1755
1530
  Widget,
1756
1531
  {
1757
1532
  id: this.getFieldId(),
@@ -1767,7 +1542,6 @@
1767
1542
  value: selectedOption >= 0 ? selectedOption : void 0,
1768
1543
  options: { enumOptions, ...uiOptions },
1769
1544
  registry,
1770
- formContext,
1771
1545
  placeholder,
1772
1546
  autocomplete,
1773
1547
  autofocus,
@@ -1775,7 +1549,7 @@
1775
1549
  hideLabel: !displayLabel,
1776
1550
  readonly
1777
1551
  }
1778
- );
1552
+ ) : void 0;
1779
1553
  const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsxRuntime.jsx(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
1780
1554
  return /* @__PURE__ */ jsxRuntime.jsx(
1781
1555
  MultiSchemaFieldTemplate2,
@@ -1817,132 +1591,154 @@
1817
1591
  return /* @__PURE__ */ jsxRuntime.jsx(StringField2, { ...props, formData: value, onChange: handleChange });
1818
1592
  }
1819
1593
  var NumberField_default = NumberField;
1820
- var ObjectField = class extends react.Component {
1821
- /** Set up the initial state */
1822
- state = {
1823
- wasPropertyKeyModified: false,
1824
- additionalProperties: {}
1825
- };
1826
- /** Returns a flag indicating whether the `name` field is required in the object schema
1827
- *
1828
- * @param name - The name of the field to check for required-ness
1829
- * @returns - True if the field `name` is required, false otherwise
1830
- */
1831
- isRequired(name) {
1832
- const { schema } = this.props;
1833
- return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1594
+ function isRequired(schema, name) {
1595
+ return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1596
+ }
1597
+ function getDefaultValue(translateString, type) {
1598
+ switch (type) {
1599
+ case "array":
1600
+ return [];
1601
+ case "boolean":
1602
+ return false;
1603
+ case "null":
1604
+ return null;
1605
+ case "number":
1606
+ return 0;
1607
+ case "object":
1608
+ return {};
1609
+ case "string":
1610
+ default:
1611
+ return translateString(utils.TranslatableString.NewStringDefault);
1834
1612
  }
1835
- /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1836
- * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1837
- * formData.
1838
- *
1839
- * @param name - The name of the property
1840
- * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1841
- * @returns - The onPropertyChange callback for the `name` property
1842
- */
1843
- onPropertyChange = (name, addedByAdditionalProperties = false) => {
1844
- return (value, path, newErrorSchema, id) => {
1845
- const { onChange } = this.props;
1613
+ }
1614
+ function ObjectFieldProperty(props) {
1615
+ const {
1616
+ fieldPathId,
1617
+ schema,
1618
+ registry,
1619
+ uiSchema,
1620
+ errorSchema,
1621
+ formData,
1622
+ onChange,
1623
+ onBlur,
1624
+ onFocus,
1625
+ disabled,
1626
+ readonly,
1627
+ required,
1628
+ hideError,
1629
+ propertyName,
1630
+ handleKeyRename,
1631
+ handleRemoveProperty,
1632
+ addedByAdditionalProperties
1633
+ } = props;
1634
+ const [wasPropertyKeyModified, setWasPropertyKeyModified] = react.useState(false);
1635
+ const { globalFormOptions, fields: fields2 } = registry;
1636
+ const { SchemaField: SchemaField2 } = fields2;
1637
+ const innerFieldIdPathId = utils.useDeepCompareMemo(
1638
+ utils.toFieldPathId(propertyName, globalFormOptions, fieldPathId.path)
1639
+ );
1640
+ const onPropertyChange = react.useCallback(
1641
+ (value, path, newErrorSchema, id) => {
1846
1642
  if (value === void 0 && addedByAdditionalProperties) {
1847
1643
  value = "";
1848
1644
  }
1849
1645
  onChange(value, path, newErrorSchema, id);
1850
- };
1851
- };
1852
- /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1853
- * and calls the `onChange` callback with it
1854
- *
1855
- * @param key - The key for which the drop callback is desired
1856
- * @returns - The drop property click callback
1857
- */
1858
- onDropPropertyClick = (key) => {
1859
- return (event) => {
1860
- event.preventDefault();
1861
- const { onChange, formData, fieldPathId } = this.props;
1862
- const copiedFormData = { ...formData };
1863
- unset(copiedFormData, key);
1864
- onChange(copiedFormData, fieldPathId.path);
1865
- };
1866
- };
1867
- /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1868
- * that is already not assigned is found.
1869
- *
1870
- * @param preferredKey - The preferred name of a new key
1871
- * @param [formData] - The form data in which to check if the desired key already exists
1872
- * @returns - The name of the next available key from `preferredKey`
1873
- */
1874
- getAvailableKey = (preferredKey, formData) => {
1875
- const { uiSchema, registry } = this.props;
1876
- const { duplicateKeySuffixSeparator = "-" } = utils.getUiOptions(uiSchema, registry.globalUiOptions);
1877
- let index = 0;
1878
- let newKey = preferredKey;
1879
- while (has(formData, newKey)) {
1880
- newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1881
- }
1882
- return newKey;
1883
- };
1884
- /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
1885
- * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
1886
- *
1887
- * @param oldValue - The old value of a field
1888
- * @returns - The key change callback function
1889
- */
1890
- onKeyChange = (oldValue) => {
1891
- return (value) => {
1892
- if (oldValue === value) {
1893
- return;
1646
+ },
1647
+ [onChange, addedByAdditionalProperties]
1648
+ );
1649
+ const onKeyRename = react.useCallback(
1650
+ (value) => {
1651
+ if (propertyName !== value) {
1652
+ setWasPropertyKeyModified(true);
1894
1653
  }
1895
- const { formData, onChange, fieldPathId } = this.props;
1896
- value = this.getAvailableKey(value, formData);
1897
- const newFormData = {
1898
- ...formData
1899
- };
1900
- const newKeys = { [oldValue]: value };
1901
- const keyValues = Object.keys(newFormData).map((key) => {
1902
- const newKey = newKeys[key] || key;
1903
- return { [newKey]: newFormData[key] };
1904
- });
1905
- const renamedObj = Object.assign({}, ...keyValues);
1906
- this.setState({ wasPropertyKeyModified: true });
1907
- onChange(renamedObj, fieldPathId.path);
1908
- };
1909
- };
1910
- /** Returns a default value to be used for a new additional schema property of the given `type`
1911
- *
1912
- * @param type - The type of the new additional schema property
1913
- */
1914
- getDefaultValue(type) {
1915
- const {
1916
- registry: { translateString }
1917
- } = this.props;
1918
- switch (type) {
1919
- case "array":
1920
- return [];
1921
- case "boolean":
1922
- return false;
1923
- case "null":
1924
- return null;
1925
- case "number":
1926
- return 0;
1927
- case "object":
1928
- return {};
1929
- case "string":
1930
- default:
1931
- return translateString(utils.TranslatableString.NewStringDefault);
1654
+ handleKeyRename(propertyName, value);
1655
+ },
1656
+ [propertyName, handleKeyRename]
1657
+ );
1658
+ const onKeyRenameBlur = react.useCallback(
1659
+ (event) => {
1660
+ const {
1661
+ target: { value }
1662
+ } = event;
1663
+ onKeyRename(value);
1664
+ },
1665
+ [onKeyRename]
1666
+ );
1667
+ const onRemoveProperty = react.useCallback(() => {
1668
+ handleRemoveProperty(propertyName);
1669
+ }, [propertyName, handleRemoveProperty]);
1670
+ return /* @__PURE__ */ jsxRuntime.jsx(
1671
+ SchemaField2,
1672
+ {
1673
+ name: propertyName,
1674
+ required,
1675
+ schema,
1676
+ uiSchema,
1677
+ errorSchema,
1678
+ fieldPathId: innerFieldIdPathId,
1679
+ formData,
1680
+ wasPropertyKeyModified,
1681
+ onKeyRename,
1682
+ onKeyRenameBlur,
1683
+ onRemoveProperty,
1684
+ onChange: onPropertyChange,
1685
+ onBlur,
1686
+ onFocus,
1687
+ registry,
1688
+ disabled,
1689
+ readonly,
1690
+ hideError
1932
1691
  }
1933
- }
1934
- /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
1935
- * default data for that field has been added to the formData.
1936
- *
1937
- * @param schema - The schema element to which the new property is being added
1938
- */
1939
- handleAddClick = (schema) => () => {
1692
+ );
1693
+ }
1694
+ function ObjectField(props) {
1695
+ const {
1696
+ schema: rawSchema,
1697
+ uiSchema = {},
1698
+ formData,
1699
+ errorSchema,
1700
+ fieldPathId,
1701
+ name,
1702
+ required = false,
1703
+ disabled,
1704
+ readonly,
1705
+ hideError,
1706
+ onBlur,
1707
+ onFocus,
1708
+ onChange,
1709
+ registry,
1710
+ title
1711
+ } = props;
1712
+ const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
1713
+ const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
1714
+ const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1715
+ const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
1716
+ const { properties: schemaProperties = {} } = schema;
1717
+ const formDataHash = utils.hashObject(formData || {});
1718
+ const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1719
+ const description = uiOptions.description ?? schema.description;
1720
+ const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
1721
+ const hasFormData = utils.isFormDataAvailable(formData);
1722
+ let orderedProperties = [];
1723
+ const getAvailableKey = react.useCallback(
1724
+ (preferredKey, formData2) => {
1725
+ const { duplicateKeySuffixSeparator = "-" } = utils.getUiOptions(uiSchema, globalUiOptions);
1726
+ let index = 0;
1727
+ let newKey = preferredKey;
1728
+ while (has(formData2, newKey)) {
1729
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1730
+ }
1731
+ return newKey;
1732
+ },
1733
+ [uiSchema, globalUiOptions]
1734
+ );
1735
+ const onAddProperty = react.useCallback(() => {
1940
1736
  if (!(schema.additionalProperties || schema.patternProperties)) {
1941
1737
  return;
1942
1738
  }
1943
- const { formData, onChange, registry, fieldPathId } = this.props;
1739
+ const { translateString: translateString2 } = registry;
1944
1740
  const newFormData = { ...formData };
1945
- const newKey = this.getAvailableKey("newKey", newFormData);
1741
+ const newKey = getAvailableKey("newKey", newFormData);
1946
1742
  if (schema.patternProperties) {
1947
1743
  set(newFormData, newKey, null);
1948
1744
  } else {
@@ -1955,8 +1751,8 @@
1955
1751
  defaultValue = schema.additionalProperties.default;
1956
1752
  let apSchema = schema.additionalProperties;
1957
1753
  if (utils.REF_KEY in apSchema) {
1958
- const { schemaUtils } = registry;
1959
- apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[utils.REF_KEY] }, formData);
1754
+ const { schemaUtils: schemaUtils2 } = registry;
1755
+ apSchema = schemaUtils2.retrieveSchema({ [utils.REF_KEY]: apSchema[utils.REF_KEY] }, formData);
1960
1756
  type = apSchema.type;
1961
1757
  constValue = apSchema.const;
1962
1758
  defaultValue = apSchema.default;
@@ -1965,111 +1761,104 @@
1965
1761
  type = "object";
1966
1762
  }
1967
1763
  }
1968
- const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
1764
+ const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString2, type);
1969
1765
  set(newFormData, newKey, newValue);
1970
1766
  }
1971
1767
  onChange(newFormData, fieldPathId.path);
1972
- };
1973
- /** Renders the `ObjectField` from the given props
1974
- */
1975
- render() {
1976
- const {
1977
- schema: rawSchema,
1978
- uiSchema = {},
1979
- formData,
1980
- errorSchema,
1981
- fieldPathId,
1982
- name,
1983
- required = false,
1984
- disabled,
1985
- readonly,
1986
- hideError,
1987
- onBlur,
1988
- onFocus,
1989
- registry,
1990
- title
1991
- } = this.props;
1992
- const { fields: fields2, formContext, schemaUtils, translateString, globalFormOptions, globalUiOptions } = registry;
1993
- const { OptionalDataControlsField: OptionalDataControlsField2, SchemaField: SchemaField2 } = fields2;
1994
- const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1995
- const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
1996
- const { properties: schemaProperties = {} } = schema;
1997
- const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1998
- const description = uiOptions.description ?? schema.description;
1999
- const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
2000
- const hasFormData = utils.isFormDataAvailable(formData);
2001
- let orderedProperties = [];
2002
- if (!renderOptionalField || hasFormData) {
2003
- try {
2004
- const properties = Object.keys(schemaProperties);
2005
- orderedProperties = utils.orderProperties(properties, uiOptions.order);
2006
- } catch (err) {
2007
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2008
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
2009
- /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
2010
- ] });
1768
+ }, [formData, onChange, registry, fieldPathId, getAvailableKey, schema]);
1769
+ const handleKeyRename = react.useCallback(
1770
+ (oldKey, newKey) => {
1771
+ if (oldKey !== newKey) {
1772
+ const actualNewKey = getAvailableKey(newKey, formData);
1773
+ const newFormData = {
1774
+ ...formData
1775
+ };
1776
+ const newKeys = { [oldKey]: actualNewKey };
1777
+ const keyValues = Object.keys(newFormData).map((key) => {
1778
+ const newKey2 = newKeys[key] || key;
1779
+ return { [newKey2]: newFormData[key] };
1780
+ });
1781
+ const renamedObj = Object.assign({}, ...keyValues);
1782
+ onChange(renamedObj, fieldPathId.path);
2011
1783
  }
1784
+ },
1785
+ [formData, onChange, fieldPathId, getAvailableKey]
1786
+ );
1787
+ const handleRemoveProperty = react.useCallback(
1788
+ (key) => {
1789
+ const copiedFormData = { ...formData };
1790
+ unset(copiedFormData, key);
1791
+ onChange(copiedFormData, fieldPathId.path);
1792
+ },
1793
+ [onChange, fieldPathId, formData]
1794
+ );
1795
+ if (!renderOptionalField || hasFormData) {
1796
+ try {
1797
+ const properties = Object.keys(schemaProperties);
1798
+ orderedProperties = utils.orderProperties(properties, uiOptions.order);
1799
+ } catch (err) {
1800
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1801
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
1802
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
1803
+ ] });
2012
1804
  }
2013
- const Template = utils.getTemplate("ObjectFieldTemplate", registry, uiOptions);
2014
- const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...this.props, schema }) : void 0;
2015
- const templateProps = {
2016
- // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
2017
- title: uiOptions.label === false ? "" : templateTitle,
2018
- description: uiOptions.label === false ? void 0 : description,
2019
- properties: orderedProperties.map((name2) => {
2020
- const addedByAdditionalProperties = has(schema, [utils.PROPERTIES_KEY, name2, utils.ADDITIONAL_PROPERTY_FLAG]);
2021
- const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
2022
- const hidden = utils.getUiOptions(fieldUiSchema).widget === "hidden";
2023
- const innerFieldIdPathId = utils.toFieldPathId(name2, globalFormOptions, fieldPathId);
2024
- return {
2025
- content: /* @__PURE__ */ jsxRuntime.jsx(
2026
- SchemaField2,
2027
- {
2028
- name: name2,
2029
- required: this.isRequired(name2),
2030
- schema: get2(schema, [utils.PROPERTIES_KEY, name2], {}),
2031
- uiSchema: fieldUiSchema,
2032
- errorSchema: get2(errorSchema, name2),
2033
- fieldPathId: innerFieldIdPathId,
2034
- formData: get2(formData, name2),
2035
- formContext,
2036
- wasPropertyKeyModified: this.state.wasPropertyKeyModified,
2037
- onKeyChange: this.onKeyChange(name2),
2038
- onChange: this.onPropertyChange(name2, addedByAdditionalProperties),
2039
- onBlur,
2040
- onFocus,
2041
- registry,
2042
- disabled,
2043
- readonly,
2044
- hideError,
2045
- onDropPropertyClick: this.onDropPropertyClick
2046
- },
2047
- name2
2048
- ),
2049
- name: name2,
2050
- readonly,
2051
- disabled,
2052
- required,
2053
- hidden
2054
- };
2055
- }),
2056
- readonly,
2057
- disabled,
2058
- required,
2059
- fieldPathId,
2060
- uiSchema,
2061
- errorSchema,
2062
- schema,
2063
- formData,
2064
- formContext,
2065
- registry,
2066
- optionalDataControl,
2067
- className: renderOptionalField ? "rjsf-optional-object-field" : void 0
2068
- };
2069
- return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...templateProps, onAddClick: this.handleAddClick });
2070
1805
  }
2071
- };
2072
- var ObjectField_default = ObjectField;
1806
+ const Template = utils.getTemplate("ObjectFieldTemplate", registry, uiOptions);
1807
+ const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...props, schema }) : void 0;
1808
+ const templateProps = {
1809
+ // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
1810
+ title: uiOptions.label === false ? "" : templateTitle,
1811
+ description: uiOptions.label === false ? void 0 : description,
1812
+ properties: orderedProperties.map((name2) => {
1813
+ const addedByAdditionalProperties = has(schema, [utils.PROPERTIES_KEY, name2, utils.ADDITIONAL_PROPERTY_FLAG]);
1814
+ const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
1815
+ const hidden = utils.getUiOptions(fieldUiSchema).widget === "hidden";
1816
+ const content = /* @__PURE__ */ jsxRuntime.jsx(
1817
+ ObjectFieldProperty,
1818
+ {
1819
+ propertyName: name2,
1820
+ required: isRequired(schema, name2),
1821
+ schema: get(schema, [utils.PROPERTIES_KEY, name2], {}),
1822
+ uiSchema: fieldUiSchema,
1823
+ errorSchema: get(errorSchema, name2),
1824
+ fieldPathId,
1825
+ formData: get(formData, name2),
1826
+ handleKeyRename,
1827
+ handleRemoveProperty,
1828
+ addedByAdditionalProperties,
1829
+ onChange,
1830
+ onBlur,
1831
+ onFocus,
1832
+ registry,
1833
+ disabled,
1834
+ readonly,
1835
+ hideError
1836
+ },
1837
+ addedByAdditionalProperties ? `${name2}-${formDataHash}` : name2
1838
+ );
1839
+ return {
1840
+ content,
1841
+ name: name2,
1842
+ readonly,
1843
+ disabled,
1844
+ required,
1845
+ hidden
1846
+ };
1847
+ }),
1848
+ readonly,
1849
+ disabled,
1850
+ required,
1851
+ fieldPathId,
1852
+ uiSchema,
1853
+ errorSchema,
1854
+ schema,
1855
+ formData,
1856
+ registry,
1857
+ optionalDataControl,
1858
+ className: renderOptionalField ? "rjsf-optional-object-field" : void 0
1859
+ };
1860
+ return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...templateProps, onAddProperty });
1861
+ }
2073
1862
  function OptionalDataControlsField(props) {
2074
1863
  const {
2075
1864
  schema,
@@ -2181,13 +1970,15 @@
2181
1970
  errorSchema,
2182
1971
  name,
2183
1972
  onChange,
2184
- onKeyChange,
2185
- onDropPropertyClick,
2186
- required,
1973
+ onKeyRename,
1974
+ onKeyRenameBlur,
1975
+ onRemoveProperty,
1976
+ required = false,
2187
1977
  registry,
2188
1978
  wasPropertyKeyModified = false
2189
1979
  } = props;
2190
- const { formContext, schemaUtils, globalUiOptions } = registry;
1980
+ const { schemaUtils, globalUiOptions, fields: fields2 } = registry;
1981
+ const { AnyOfField: _AnyOfField, OneOfField: _OneOfField } = fields2;
2191
1982
  const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
2192
1983
  const FieldTemplate2 = utils.getTemplate("FieldTemplate", registry, uiOptions);
2193
1984
  const DescriptionFieldTemplate = utils.getTemplate(
@@ -2215,7 +2006,26 @@
2215
2006
  if (Object.keys(schema).length === 0) {
2216
2007
  return null;
2217
2008
  }
2218
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
2009
+ let displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
2010
+ const isReplacingAnyOrOneOf = uiOptions.field && uiOptions.fieldReplacesAnyOrOneOf === true;
2011
+ let XxxOfField;
2012
+ let XxxOfOptions;
2013
+ if ((utils.ANY_OF_KEY in schema || utils.ONE_OF_KEY in schema) && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema)) {
2014
+ if (schema[utils.ANY_OF_KEY]) {
2015
+ XxxOfField = _AnyOfField;
2016
+ XxxOfOptions = schema[utils.ANY_OF_KEY].map(
2017
+ (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2018
+ );
2019
+ } else if (schema[utils.ONE_OF_KEY]) {
2020
+ XxxOfField = _OneOfField;
2021
+ XxxOfOptions = schema[utils.ONE_OF_KEY].map(
2022
+ (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2023
+ );
2024
+ }
2025
+ const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
2026
+ const hasFormData = utils.isFormDataAvailable(formData);
2027
+ displayLabel = displayLabel && (!isOptionalRender || hasFormData);
2028
+ }
2219
2029
  const { __errors, ...fieldErrorSchema } = errorSchema || {};
2220
2030
  const fieldUiSchema = omit3(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
2221
2031
  if (utils.UI_OPTIONS_KEY in fieldUiSchema) {
@@ -2234,7 +2044,6 @@
2234
2044
  hideError,
2235
2045
  autofocus,
2236
2046
  errorSchema: fieldErrorSchema,
2237
- formContext,
2238
2047
  rawErrors: __errors
2239
2048
  }
2240
2049
  );
@@ -2266,7 +2075,7 @@
2266
2075
  registry
2267
2076
  }
2268
2077
  );
2269
- const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsxRuntime.jsx(
2078
+ const errorsComponent = hideError || XxxOfField && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ jsxRuntime.jsx(
2270
2079
  FieldErrorTemplate2,
2271
2080
  {
2272
2081
  errors: __errors,
@@ -2297,8 +2106,9 @@
2297
2106
  label,
2298
2107
  hidden,
2299
2108
  onChange,
2300
- onKeyChange,
2301
- onDropPropertyClick,
2109
+ onKeyRename,
2110
+ onKeyRenameBlur,
2111
+ onRemoveProperty,
2302
2112
  required,
2303
2113
  disabled,
2304
2114
  readonly,
@@ -2311,36 +2121,10 @@
2311
2121
  uiSchema,
2312
2122
  registry
2313
2123
  };
2314
- const _AnyOfField = registry.fields.AnyOfField;
2315
- const _OneOfField = registry.fields.OneOfField;
2316
- const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
2317
2124
  return /* @__PURE__ */ jsxRuntime.jsx(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2318
2125
  field,
2319
- schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsxRuntime.jsx(
2320
- _AnyOfField,
2321
- {
2322
- name,
2323
- disabled,
2324
- readonly,
2325
- hideError,
2326
- errorSchema,
2327
- formData,
2328
- formContext,
2329
- fieldPathId,
2330
- onBlur: props.onBlur,
2331
- onChange: props.onChange,
2332
- onFocus: props.onFocus,
2333
- options: schema.anyOf.map(
2334
- (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2335
- ),
2336
- registry,
2337
- required,
2338
- schema,
2339
- uiSchema
2340
- }
2341
- ),
2342
- schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsxRuntime.jsx(
2343
- _OneOfField,
2126
+ XxxOfField && /* @__PURE__ */ jsxRuntime.jsx(
2127
+ XxxOfField,
2344
2128
  {
2345
2129
  name,
2346
2130
  disabled,
@@ -2348,14 +2132,11 @@
2348
2132
  hideError,
2349
2133
  errorSchema,
2350
2134
  formData,
2351
- formContext,
2352
2135
  fieldPathId,
2353
2136
  onBlur: props.onBlur,
2354
2137
  onChange: props.onChange,
2355
2138
  onFocus: props.onFocus,
2356
- options: schema.oneOf.map(
2357
- (_schema2) => schemaUtils.retrieveSchema(isObject(_schema2) ? _schema2 : {}, formData)
2358
- ),
2139
+ options: XxxOfOptions,
2359
2140
  registry,
2360
2141
  required,
2361
2142
  schema,
@@ -2396,7 +2177,7 @@
2396
2177
  hideError
2397
2178
  } = props;
2398
2179
  const { title, format } = schema;
2399
- const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
2180
+ const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
2400
2181
  const enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema, uiSchema) : void 0;
2401
2182
  let defaultWidget = enumOptions ? "select" : "text";
2402
2183
  if (format && utils.hasWidget(schema, format, widgets2)) {
@@ -2430,11 +2211,11 @@
2430
2211
  required,
2431
2212
  disabled,
2432
2213
  readonly,
2433
- formContext,
2434
2214
  autofocus,
2435
2215
  registry,
2436
2216
  placeholder,
2437
- rawErrors
2217
+ rawErrors,
2218
+ htmlName: fieldPathId.name
2438
2219
  }
2439
2220
  );
2440
2221
  }
@@ -2454,14 +2235,14 @@
2454
2235
  function fields() {
2455
2236
  return {
2456
2237
  AnyOfField: MultiSchemaField_default,
2457
- ArrayField: ArrayField_default,
2238
+ ArrayField,
2458
2239
  // ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
2459
2240
  BooleanField: BooleanField_default,
2460
2241
  LayoutGridField,
2461
2242
  LayoutHeaderField,
2462
2243
  LayoutMultiSchemaField,
2463
2244
  NumberField: NumberField_default,
2464
- ObjectField: ObjectField_default,
2245
+ ObjectField,
2465
2246
  OneOfField: MultiSchemaField_default,
2466
2247
  OptionalDataControlsField,
2467
2248
  SchemaField: SchemaField_default,
@@ -2530,19 +2311,15 @@
2530
2311
  hasMoveUp,
2531
2312
  hasRemove,
2532
2313
  fieldPathId,
2533
- index,
2534
- onCopyIndexClick,
2535
- onDropIndexClick,
2536
- onReorderClick,
2314
+ onCopyItem,
2315
+ onRemoveItem,
2316
+ onMoveDownItem,
2317
+ onMoveUpItem,
2537
2318
  readonly,
2538
2319
  registry,
2539
2320
  uiSchema
2540
2321
  } = props;
2541
2322
  const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
2542
- const onCopyClick = react.useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
2543
- const onRemoveClick = react.useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
2544
- const onArrowUpClick = react.useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
2545
- const onArrowDownClick = react.useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
2546
2323
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2547
2324
  (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxRuntime.jsx(
2548
2325
  MoveUpButton2,
@@ -2550,7 +2327,7 @@
2550
2327
  id: utils.buttonId(fieldPathId, "moveUp"),
2551
2328
  className: "rjsf-array-item-move-up",
2552
2329
  disabled: disabled || readonly || !hasMoveUp,
2553
- onClick: onArrowUpClick,
2330
+ onClick: onMoveUpItem,
2554
2331
  uiSchema,
2555
2332
  registry
2556
2333
  }
@@ -2561,7 +2338,7 @@
2561
2338
  id: utils.buttonId(fieldPathId, "moveDown"),
2562
2339
  className: "rjsf-array-item-move-down",
2563
2340
  disabled: disabled || readonly || !hasMoveDown,
2564
- onClick: onArrowDownClick,
2341
+ onClick: onMoveDownItem,
2565
2342
  uiSchema,
2566
2343
  registry
2567
2344
  }
@@ -2572,7 +2349,7 @@
2572
2349
  id: utils.buttonId(fieldPathId, "copy"),
2573
2350
  className: "rjsf-array-item-copy",
2574
2351
  disabled: disabled || readonly,
2575
- onClick: onCopyClick,
2352
+ onClick: onCopyItem,
2576
2353
  uiSchema,
2577
2354
  registry
2578
2355
  }
@@ -2583,7 +2360,7 @@
2583
2360
  id: utils.buttonId(fieldPathId, "remove"),
2584
2361
  className: "rjsf-array-item-remove",
2585
2362
  disabled: disabled || readonly,
2586
- onClick: onRemoveClick,
2363
+ onClick: onRemoveItem,
2587
2364
  uiSchema,
2588
2365
  registry
2589
2366
  }
@@ -2612,11 +2389,6 @@
2612
2389
  registry,
2613
2390
  uiOptions
2614
2391
  );
2615
- const ArrayFieldItemTemplate2 = utils.getTemplate(
2616
- "ArrayFieldItemTemplate",
2617
- registry,
2618
- uiOptions
2619
- );
2620
2392
  const ArrayFieldTitleTemplate2 = utils.getTemplate(
2621
2393
  "ArrayFieldTitleTemplate",
2622
2394
  registry,
@@ -2650,7 +2422,7 @@
2650
2422
  }
2651
2423
  ),
2652
2424
  !showOptionalDataControlInTitle ? optionalDataControl : void 0,
2653
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
2425
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "row array-item-list", children: items }),
2654
2426
  canAdd && /* @__PURE__ */ jsxRuntime.jsx(
2655
2427
  AddButton2,
2656
2428
  {
@@ -2694,6 +2466,7 @@
2694
2466
  id,
2695
2467
  name,
2696
2468
  // remove this from ...rest
2469
+ htmlName,
2697
2470
  value,
2698
2471
  readonly,
2699
2472
  disabled,
@@ -2705,7 +2478,6 @@
2705
2478
  options,
2706
2479
  schema,
2707
2480
  uiSchema,
2708
- formContext,
2709
2481
  registry,
2710
2482
  rawErrors,
2711
2483
  type,
@@ -2746,7 +2518,7 @@
2746
2518
  "input",
2747
2519
  {
2748
2520
  id,
2749
- name: id,
2521
+ name: htmlName || id,
2750
2522
  className: "form-control",
2751
2523
  readOnly: readonly,
2752
2524
  disabled,
@@ -2936,7 +2708,7 @@
2936
2708
  disabled,
2937
2709
  formData,
2938
2710
  fieldPathId,
2939
- onAddClick,
2711
+ onAddProperty,
2940
2712
  optionalDataControl,
2941
2713
  properties,
2942
2714
  readonly,
@@ -2987,7 +2759,7 @@
2987
2759
  {
2988
2760
  id: utils.buttonId(fieldPathId, "add"),
2989
2761
  className: "rjsf-object-property-expand",
2990
- onClick: onAddClick(schema),
2762
+ onClick: onAddProperty,
2991
2763
  disabled: disabled || readonly,
2992
2764
  uiSchema,
2993
2765
  registry
@@ -3059,8 +2831,8 @@
3059
2831
  style,
3060
2832
  disabled,
3061
2833
  label,
3062
- onKeyChange,
3063
- onDropPropertyClick,
2834
+ onKeyRenameBlur,
2835
+ onRemoveProperty,
3064
2836
  readonly,
3065
2837
  required,
3066
2838
  schema,
@@ -3091,7 +2863,7 @@
3091
2863
  className: "form-control",
3092
2864
  type: "text",
3093
2865
  id: `${id}-key`,
3094
- onBlur: ({ target }) => onKeyChange(target && target.value),
2866
+ onBlur: onKeyRenameBlur,
3095
2867
  defaultValue: label
3096
2868
  }
3097
2869
  )
@@ -3104,7 +2876,7 @@
3104
2876
  className: "rjsf-object-property-remove btn-block",
3105
2877
  style: { border: "0" },
3106
2878
  disabled: disabled || readonly,
3107
- onClick: onDropPropertyClick(label),
2879
+ onClick: onRemoveProperty,
3108
2880
  uiSchema,
3109
2881
  registry
3110
2882
  }
@@ -3280,7 +3052,8 @@
3280
3052
  onBlur,
3281
3053
  onFocus,
3282
3054
  onChange,
3283
- registry
3055
+ registry,
3056
+ htmlName
3284
3057
  }) {
3285
3058
  const DescriptionFieldTemplate = utils.getTemplate(
3286
3059
  "DescriptionFieldTemplate",
@@ -3318,7 +3091,7 @@
3318
3091
  {
3319
3092
  type: "checkbox",
3320
3093
  id,
3321
- name: id,
3094
+ name: htmlName || id,
3322
3095
  checked: typeof value === "undefined" ? false : value,
3323
3096
  required,
3324
3097
  disabled: disabled || readonly,
@@ -3343,7 +3116,8 @@
3343
3116
  readonly,
3344
3117
  onChange,
3345
3118
  onBlur,
3346
- onFocus
3119
+ onFocus,
3120
+ htmlName
3347
3121
  }) {
3348
3122
  const checkboxesValues = Array.isArray(value) ? value : [value];
3349
3123
  const handleBlur = react.useCallback(
@@ -3371,7 +3145,7 @@
3371
3145
  {
3372
3146
  type: "checkbox",
3373
3147
  id: utils.optionId(id, index),
3374
- name: id,
3148
+ name: htmlName || id,
3375
3149
  checked,
3376
3150
  value: String(index),
3377
3151
  disabled: disabled || itemDisabled || readonly,
@@ -3570,9 +3344,10 @@
3570
3344
  var FileWidget_default = FileWidget;
3571
3345
  function HiddenWidget({
3572
3346
  id,
3573
- value
3347
+ value,
3348
+ htmlName
3574
3349
  }) {
3575
- return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
3350
+ return /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", id, name: htmlName || id, value: typeof value === "undefined" ? "" : value });
3576
3351
  }
3577
3352
  var HiddenWidget_default = HiddenWidget;
3578
3353
  function PasswordWidget(props) {
@@ -3590,7 +3365,8 @@
3590
3365
  onBlur,
3591
3366
  onFocus,
3592
3367
  onChange,
3593
- id
3368
+ id,
3369
+ htmlName
3594
3370
  }) {
3595
3371
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
3596
3372
  const handleBlur = react.useCallback(
@@ -3613,7 +3389,7 @@
3613
3389
  type: "radio",
3614
3390
  id: utils.optionId(id, i),
3615
3391
  checked,
3616
- name: id,
3392
+ name: htmlName || id,
3617
3393
  required,
3618
3394
  value: String(i),
3619
3395
  disabled: disabled || itemDisabled || readonly,
@@ -3653,7 +3429,8 @@
3653
3429
  onFocus,
3654
3430
  onBlur,
3655
3431
  schema,
3656
- options
3432
+ options,
3433
+ htmlName
3657
3434
  }) {
3658
3435
  const { stars = 5, shape = "star" } = options;
3659
3436
  const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
@@ -3730,7 +3507,7 @@
3730
3507
  {
3731
3508
  type: "hidden",
3732
3509
  id,
3733
- name: id,
3510
+ name: htmlName || id,
3734
3511
  value: value || "",
3735
3512
  required,
3736
3513
  disabled: disabled || readonly,
@@ -3760,7 +3537,8 @@
3760
3537
  onChange,
3761
3538
  onBlur,
3762
3539
  onFocus,
3763
- placeholder
3540
+ placeholder,
3541
+ htmlName
3764
3542
  }) {
3765
3543
  const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
3766
3544
  const emptyValue = multiple ? [] : "";
@@ -3791,7 +3569,7 @@
3791
3569
  "select",
3792
3570
  {
3793
3571
  id,
3794
- name: id,
3572
+ name: htmlName || id,
3795
3573
  multiple,
3796
3574
  role: "combobox",
3797
3575
  className: "form-control",
@@ -3825,7 +3603,8 @@
3825
3603
  autofocus = false,
3826
3604
  onChange,
3827
3605
  onBlur,
3828
- onFocus
3606
+ onFocus,
3607
+ htmlName
3829
3608
  }) {
3830
3609
  const handleChange = react.useCallback(
3831
3610
  ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
@@ -3843,7 +3622,7 @@
3843
3622
  "textarea",
3844
3623
  {
3845
3624
  id,
3846
- name: id,
3625
+ name: htmlName || id,
3847
3626
  className: "form-control",
3848
3627
  value: value ? value : "",
3849
3628
  placeholder,
@@ -3925,6 +3704,12 @@
3925
3704
  globalFormOptions: { idPrefix: utils.DEFAULT_ID_PREFIX, idSeparator: utils.DEFAULT_ID_SEPARATOR }
3926
3705
  };
3927
3706
  }
3707
+ function toIChangeEvent(state, status) {
3708
+ return {
3709
+ ..._pick(state, ["schema", "uiSchema", "fieldPathId", "schemaUtils", "formData", "edit", "errors", "errorSchema"]),
3710
+ ...status !== void 0 && { status }
3711
+ };
3712
+ }
3928
3713
  var Form = class extends react.Component {
3929
3714
  /** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
3930
3715
  * provide any possible type here
@@ -3946,7 +3731,7 @@
3946
3731
  }
3947
3732
  this.state = this.getStateFromProps(props, props.formData);
3948
3733
  if (this.props.onChange && !utils.deepEquals(this.state.formData, this.props.formData)) {
3949
- this.props.onChange(this.state);
3734
+ this.props.onChange(toIChangeEvent(this.state));
3950
3735
  }
3951
3736
  this.formElement = react.createRef();
3952
3737
  }
@@ -4008,7 +3793,7 @@
4008
3793
  if (snapshot.shouldUpdate) {
4009
3794
  const { nextState } = snapshot;
4010
3795
  if (!utils.deepEquals(nextState.formData, this.props.formData) && !utils.deepEquals(nextState.formData, prevState.formData) && this.props.onChange) {
4011
- this.props.onChange(nextState);
3796
+ this.props.onChange(toIChangeEvent(nextState));
4012
3797
  }
4013
3798
  this.setState(nextState);
4014
3799
  }
@@ -4116,7 +3901,9 @@
4116
3901
  errors = mergedErrors.errors;
4117
3902
  errorSchema = mergedErrors.errorSchema;
4118
3903
  }
4119
- const fieldPathId = utils.toFieldPathId("", this.getGlobalFormOptions(this.props));
3904
+ const newRegistry = this.getRegistry(props, rootSchema, schemaUtils);
3905
+ const registry = utils.deepEquals(state.registry, newRegistry) ? state.registry : newRegistry;
3906
+ const fieldPathId = state.fieldPathId && state.fieldPathId?.[utils.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : utils.toFieldPathId("", registry.globalFormOptions);
4120
3907
  const nextState = {
4121
3908
  schemaUtils,
4122
3909
  schema: rootSchema,
@@ -4129,7 +3916,8 @@
4129
3916
  schemaValidationErrors,
4130
3917
  schemaValidationErrorSchema,
4131
3918
  retrievedSchema: _retrievedSchema,
4132
- initialDefaultsGenerated: true
3919
+ initialDefaultsGenerated: true,
3920
+ registry
4133
3921
  };
4134
3922
  return nextState;
4135
3923
  }
@@ -4264,7 +4052,7 @@
4264
4052
  }
4265
4053
  } else if (key === utils.NAME_KEY && data !== "") {
4266
4054
  paths.forEach((path) => {
4267
- const formValue = get2(formData, path);
4055
+ const formValue = get(formData, path);
4268
4056
  const isLeaf = objKeys.length === 1;
4269
4057
  if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
4270
4058
  acc.push(path);
@@ -4342,7 +4130,7 @@
4342
4130
  };
4343
4131
  }
4344
4132
  if (newErrorSchema) {
4345
- const oldValidationError = !isRootPath ? get2(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4133
+ const oldValidationError = !isRootPath ? get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
4346
4134
  if (!isEmpty(oldValidationError)) {
4347
4135
  if (!isRootPath) {
4348
4136
  set(originalErrorSchema, path, newErrorSchema);
@@ -4354,12 +4142,15 @@
4354
4142
  customErrors = new utils.ErrorSchemaBuilder();
4355
4143
  }
4356
4144
  if (isRootPath) {
4357
- customErrors.setErrors(get2(newErrorSchema, utils.ERRORS_KEY, ""));
4145
+ const errors2 = get(newErrorSchema, utils.ERRORS_KEY);
4146
+ if (errors2) {
4147
+ customErrors.setErrors(errors2);
4148
+ }
4358
4149
  } else {
4359
4150
  set(customErrors.ErrorSchema, path, newErrorSchema);
4360
4151
  }
4361
4152
  }
4362
- } else if (customErrors && get2(customErrors.ErrorSchema, [...path, utils.ERRORS_KEY])) {
4153
+ } else if (customErrors && get(customErrors.ErrorSchema, [...path, utils.ERRORS_KEY])) {
4363
4154
  customErrors.clearErrors(path);
4364
4155
  }
4365
4156
  if (mustValidate && this.pendingChanges.length === 1) {
@@ -4383,7 +4174,7 @@
4383
4174
  }
4384
4175
  this.setState(state, () => {
4385
4176
  if (onChange) {
4386
- onChange({ ...this.state, ...state }, id);
4177
+ onChange(toIChangeEvent({ ...this.state, ...state }), id);
4387
4178
  }
4388
4179
  this.pendingChanges.shift();
4389
4180
  this.processPendingChange();
@@ -4421,7 +4212,7 @@
4421
4212
  initialDefaultsGenerated: false,
4422
4213
  customErrors: void 0
4423
4214
  };
4424
- this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
4215
+ this.setState(state, () => onChange && onChange(toIChangeEvent({ ...this.state, ...state })));
4425
4216
  };
4426
4217
  /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
4427
4218
  * was provided.
@@ -4479,7 +4270,7 @@
4479
4270
  },
4480
4271
  () => {
4481
4272
  if (onSubmit) {
4482
- onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
4273
+ onSubmit(toIChangeEvent({ ...this.state, formData: newFormData }, "submitted"), event);
4483
4274
  }
4484
4275
  }
4485
4276
  );
@@ -4496,33 +4287,38 @@
4496
4287
  uiSchema = {},
4497
4288
  experimental_componentUpdateStrategy,
4498
4289
  idSeparator = utils.DEFAULT_ID_SEPARATOR,
4499
- idPrefix = utils.DEFAULT_ID_PREFIX
4290
+ idPrefix = utils.DEFAULT_ID_PREFIX,
4291
+ nameGenerator
4500
4292
  } = props;
4501
4293
  const rootFieldId = uiSchema["ui:rootFieldId"];
4502
- return { idPrefix: rootFieldId || idPrefix, idSeparator, experimental_componentUpdateStrategy };
4294
+ return {
4295
+ idPrefix: rootFieldId || idPrefix,
4296
+ idSeparator,
4297
+ ...experimental_componentUpdateStrategy !== void 0 && { experimental_componentUpdateStrategy },
4298
+ ...nameGenerator !== void 0 && { nameGenerator }
4299
+ };
4503
4300
  }
4504
- /** Returns the registry for the form */
4505
- getRegistry() {
4506
- const { translateString: customTranslateString, uiSchema = {} } = this.props;
4507
- const { schema, schemaUtils } = this.state;
4301
+ /** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
4302
+ getRegistry(props, schema, schemaUtils) {
4303
+ const { translateString: customTranslateString, uiSchema = {} } = props;
4508
4304
  const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
4509
4305
  return {
4510
- fields: { ...fields2, ...this.props.fields },
4306
+ fields: { ...fields2, ...props.fields },
4511
4307
  templates: {
4512
4308
  ...templates2,
4513
- ...this.props.templates,
4309
+ ...props.templates,
4514
4310
  ButtonTemplates: {
4515
4311
  ...templates2.ButtonTemplates,
4516
- ...this.props.templates?.ButtonTemplates
4312
+ ...props.templates?.ButtonTemplates
4517
4313
  }
4518
4314
  },
4519
- widgets: { ...widgets2, ...this.props.widgets },
4315
+ widgets: { ...widgets2, ...props.widgets },
4520
4316
  rootSchema: schema,
4521
- formContext: this.props.formContext || formContext,
4317
+ formContext: props.formContext || formContext,
4522
4318
  schemaUtils,
4523
4319
  translateString: customTranslateString || translateString,
4524
4320
  globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY],
4525
- globalFormOptions: this.getGlobalFormOptions(this.props)
4321
+ globalFormOptions: this.getGlobalFormOptions(props)
4526
4322
  };
4527
4323
  }
4528
4324
  /** Provides a function that can be used to programmatically submit the `Form` */
@@ -4652,8 +4448,7 @@
4652
4448
  showErrorList = "top",
4653
4449
  _internalFormWrapper
4654
4450
  } = this.props;
4655
- const { schema, uiSchema, formData, errorSchema, fieldPathId } = this.state;
4656
- const registry = this.getRegistry();
4451
+ const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
4657
4452
  const { SchemaField: _SchemaField } = registry.fields;
4658
4453
  const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
4659
4454
  const as = _internalFormWrapper ? tagName : void 0;