@rjsf/core 6.6.1 → 6.6.2
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.
- package/dist/core.umd.js +454 -373
- package/dist/index.cjs +416 -334
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +418 -415
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +14 -11
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +97 -62
- package/lib/components/RichDescription.d.ts +2 -2
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichDescription.js +1 -1
- package/lib/components/RichHelp.d.ts +2 -2
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/RichHelp.js +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/SchemaExamples.js +1 -3
- package/lib/components/fields/ArrayField.d.ts +1 -1
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +87 -88
- package/lib/components/fields/BooleanField.d.ts +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -5
- package/lib/components/fields/FallbackField.d.ts +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/FallbackField.js +2 -2
- package/lib/components/fields/LayoutGridField.d.ts +7 -9
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +5 -4
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.js +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +4 -1
- package/lib/components/fields/MultiSchemaField.d.ts +9 -3
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +27 -9
- package/lib/components/fields/NullField.d.ts +1 -1
- package/lib/components/fields/NullField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.d.ts +1 -1
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +7 -9
- package/lib/components/fields/ObjectField.d.ts +1 -1
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +27 -25
- package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +1 -1
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +7 -7
- package/lib/components/fields/StringField.d.ts +1 -1
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/StringField.js +2 -5
- package/lib/components/fields/index.d.ts +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.js +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +7 -6
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +14 -7
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js +14 -6
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -1
- package/lib/components/templates/DescriptionField.d.ts +1 -1
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +1 -1
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.js +2 -4
- package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.js +1 -3
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +2 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +1 -1
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.js +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js +1 -1
- package/lib/components/templates/TitleField.d.ts +1 -1
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -1
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js +1 -1
- package/lib/components/templates/index.d.ts +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.js +2 -2
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/ColorWidget.d.ts +1 -1
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.js +2 -2
- package/lib/components/widgets/DateWidget.d.ts +1 -1
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -1
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -1
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.js +6 -4
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RangeWidget.d.ts +1 -1
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.js +15 -15
- package/lib/components/widgets/SelectWidget.d.ts +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +4 -4
- package/lib/components/widgets/TextWidget.d.ts +1 -1
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +2 -2
- package/lib/components/widgets/TimeWidget.d.ts +1 -1
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -1
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/components/widgets/index.d.ts +1 -1
- package/lib/components/widgets/index.d.ts.map +1 -1
- package/lib/getDefaultRegistry.d.ts +1 -1
- package/lib/getDefaultRegistry.d.ts.map +1 -1
- package/lib/getDefaultRegistry.js +1 -1
- package/lib/getTestRegistry.d.ts +1 -1
- package/lib/getTestRegistry.d.ts.map +1 -1
- package/lib/getTestRegistry.js +1 -1
- package/lib/index.d.ts +10 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +3 -3
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +6 -6
- package/package.json +5 -6
- package/src/components/Form.tsx +164 -97
- package/src/components/RichDescription.tsx +3 -10
- package/src/components/RichHelp.tsx +3 -10
- package/src/components/SchemaExamples.tsx +6 -4
- package/src/components/fields/ArrayField.tsx +122 -108
- package/src/components/fields/BooleanField.tsx +4 -9
- package/src/components/fields/FallbackField.tsx +4 -8
- package/src/components/fields/LayoutGridField.tsx +21 -19
- package/src/components/fields/LayoutHeaderField.tsx +2 -10
- package/src/components/fields/LayoutMultiSchemaField.tsx +15 -10
- package/src/components/fields/MultiSchemaField.tsx +29 -16
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +8 -10
- package/src/components/fields/ObjectField.tsx +48 -39
- package/src/components/fields/OptionalDataControlsField.tsx +6 -4
- package/src/components/fields/SchemaField.tsx +22 -19
- package/src/components/fields/StringField.tsx +4 -15
- package/src/components/fields/index.ts +1 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +2 -7
- package/src/components/templates/ArrayFieldItemTemplate.tsx +3 -9
- package/src/components/templates/ArrayFieldTemplate.tsx +2 -9
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -10
- package/src/components/templates/BaseInputTemplate.tsx +15 -19
- package/src/components/templates/ButtonTemplates/AddButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/IconButton.tsx +16 -7
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +2 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/ErrorList.tsx +8 -15
- package/src/components/templates/FallbackFieldTemplate.tsx +2 -1
- package/src/components/templates/FieldErrorTemplate.tsx +8 -8
- package/src/components/templates/FieldHelpTemplate.tsx +2 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -8
- package/src/components/templates/FieldTemplate/Label.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +1 -1
- package/src/components/templates/MultiSchemaFieldTemplate.tsx +1 -1
- package/src/components/templates/ObjectFieldTemplate.tsx +2 -7
- package/src/components/templates/OptionalDataControlsTemplate.tsx +3 -2
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +3 -2
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +2 -9
- package/src/components/templates/index.ts +1 -1
- package/src/components/widgets/AltDateTimeWidget.tsx +1 -1
- package/src/components/widgets/AltDateWidget.tsx +7 -13
- package/src/components/widgets/CheckboxWidget.tsx +3 -5
- package/src/components/widgets/CheckboxesWidget.tsx +6 -8
- package/src/components/widgets/ColorWidget.tsx +2 -1
- package/src/components/widgets/DateTimeWidget.tsx +3 -10
- package/src/components/widgets/DateWidget.tsx +2 -1
- package/src/components/widgets/EmailWidget.tsx +2 -1
- package/src/components/widgets/FileWidget.tsx +9 -8
- package/src/components/widgets/HiddenWidget.tsx +1 -1
- package/src/components/widgets/PasswordWidget.tsx +2 -1
- package/src/components/widgets/RadioWidget.tsx +6 -8
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +48 -47
- package/src/components/widgets/SelectWidget.tsx +12 -10
- package/src/components/widgets/TextWidget.tsx +2 -1
- package/src/components/widgets/TextareaWidget.tsx +7 -4
- package/src/components/widgets/TimeWidget.tsx +2 -1
- package/src/components/widgets/URLWidget.tsx +2 -1
- package/src/components/widgets/UpDownWidget.tsx +2 -1
- package/src/components/widgets/index.ts +1 -1
- package/src/getDefaultRegistry.ts +2 -9
- package/src/getTestRegistry.tsx +2 -7
- package/src/index.ts +10 -5
- package/src/withTheme.tsx +14 -9
package/dist/core.umd.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
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/unset'), 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/isEqual'), require('lodash/isFunction'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isEqual', 'lodash/isFunction', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react
|
|
5
|
-
})(this, (function (exports, react
|
|
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/unset'), 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/isEqual'), require('lodash/isFunction'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx/react'), require('@rjsf/validator-ajv8')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isEqual', 'lodash/isFunction', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx/react', '@rjsf/validator-ajv8'], factory) :
|
|
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._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isEqual, global.isFunction, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.react$1, global.validator));
|
|
5
|
+
})(this, (function (exports, react, utils, _cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isEqual, isFunction, isPlainObject, isString, isUndefined, last, noop, omit3, react$1, validator) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/components/Form.tsx
|
|
8
8
|
function generateRowId() {
|
|
9
9
|
return uniqueId("rjsf-array-item-");
|
|
10
10
|
}
|
|
11
11
|
function generateKeyedFormData(formData) {
|
|
12
|
-
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
});
|
|
12
|
+
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
13
|
+
key: generateRowId(),
|
|
14
|
+
item
|
|
15
|
+
}));
|
|
18
16
|
}
|
|
19
17
|
function keyedToPlainFormData(keyedFormData) {
|
|
20
18
|
if (Array.isArray(keyedFormData)) {
|
|
@@ -215,7 +213,7 @@
|
|
|
215
213
|
}
|
|
216
214
|
);
|
|
217
215
|
}
|
|
218
|
-
function
|
|
216
|
+
function ArrayFieldItemInner(props) {
|
|
219
217
|
const {
|
|
220
218
|
itemKey,
|
|
221
219
|
index,
|
|
@@ -230,10 +228,10 @@
|
|
|
230
228
|
canRemove = true,
|
|
231
229
|
canMoveUp,
|
|
232
230
|
canMoveDown,
|
|
233
|
-
|
|
231
|
+
rawItemSchema,
|
|
234
232
|
itemData,
|
|
235
233
|
itemUiSchema,
|
|
236
|
-
|
|
234
|
+
parentFieldPathId,
|
|
237
235
|
itemErrorSchema,
|
|
238
236
|
autofocus,
|
|
239
237
|
onBlur,
|
|
@@ -250,9 +248,17 @@
|
|
|
250
248
|
const {
|
|
251
249
|
schemaUtils,
|
|
252
250
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
253
|
-
globalUiOptions
|
|
251
|
+
globalUiOptions,
|
|
252
|
+
globalFormOptions
|
|
254
253
|
} = registry;
|
|
255
|
-
const
|
|
254
|
+
const itemSchema = react.useMemo(
|
|
255
|
+
() => schemaUtils.retrieveSchema(rawItemSchema, itemData),
|
|
256
|
+
[schemaUtils, rawItemSchema, itemData]
|
|
257
|
+
);
|
|
258
|
+
const fieldPathId = react.useMemo(
|
|
259
|
+
() => utils.toFieldPathId(index, globalFormOptions, parentFieldPathId),
|
|
260
|
+
[index, globalFormOptions, parentFieldPathId]
|
|
261
|
+
);
|
|
256
262
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
257
263
|
const ArrayFieldItemTemplate2 = utils.getTemplate(
|
|
258
264
|
"ArrayFieldItemTemplate",
|
|
@@ -271,31 +277,31 @@
|
|
|
271
277
|
toolbar: false
|
|
272
278
|
};
|
|
273
279
|
has4.toolbar = Object.keys(has4).some((key) => has4[key]);
|
|
274
|
-
const onAddItem = react
|
|
280
|
+
const onAddItem = react.useCallback(
|
|
275
281
|
(event) => {
|
|
276
282
|
handleAddItem(event, index + 1);
|
|
277
283
|
},
|
|
278
284
|
[handleAddItem, index]
|
|
279
285
|
);
|
|
280
|
-
const onCopyItem = react
|
|
286
|
+
const onCopyItem = react.useCallback(
|
|
281
287
|
(event) => {
|
|
282
288
|
handleCopyItem(event, index);
|
|
283
289
|
},
|
|
284
290
|
[handleCopyItem, index]
|
|
285
291
|
);
|
|
286
|
-
const onRemoveItem = react
|
|
292
|
+
const onRemoveItem = react.useCallback(
|
|
287
293
|
(event) => {
|
|
288
294
|
handleRemoveItem(event, index);
|
|
289
295
|
},
|
|
290
296
|
[handleRemoveItem, index]
|
|
291
297
|
);
|
|
292
|
-
const onMoveUpItem = react
|
|
298
|
+
const onMoveUpItem = react.useCallback(
|
|
293
299
|
(event) => {
|
|
294
300
|
handleReorderItems(event, index, index - 1);
|
|
295
301
|
},
|
|
296
302
|
[handleReorderItems, index]
|
|
297
303
|
);
|
|
298
|
-
const onMoveDownItem = react
|
|
304
|
+
const onMoveDownItem = react.useCallback(
|
|
299
305
|
(event) => {
|
|
300
306
|
handleReorderItems(event, index, index + 1);
|
|
301
307
|
},
|
|
@@ -361,6 +367,7 @@
|
|
|
361
367
|
};
|
|
362
368
|
return /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...templateProps });
|
|
363
369
|
}
|
|
370
|
+
var ArrayFieldItem = react.memo(ArrayFieldItemInner);
|
|
364
371
|
function NormalArray(props) {
|
|
365
372
|
const {
|
|
366
373
|
schema,
|
|
@@ -387,15 +394,18 @@
|
|
|
387
394
|
handleReorderItems
|
|
388
395
|
} = props;
|
|
389
396
|
const fieldTitle = schema.title || title || name;
|
|
390
|
-
const { schemaUtils, fields: fields2, formContext,
|
|
397
|
+
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
391
398
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
392
|
-
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
393
|
-
const
|
|
394
|
-
const itemsSchema = schemaUtils.retrieveSchema(
|
|
395
|
-
const formData = keyedToPlainFormData(keyedFormData);
|
|
399
|
+
const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
400
|
+
const schemaItems = react.useMemo(() => isObject(schema.items) ? schema.items : {}, [schema.items]);
|
|
401
|
+
const itemsSchema = react.useMemo(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
402
|
+
const formData = react.useMemo(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
396
403
|
const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
397
404
|
const hasFormData = utils.isFormDataAvailable(formDataFromProps);
|
|
398
|
-
const canAdd =
|
|
405
|
+
const canAdd = react.useMemo(
|
|
406
|
+
() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData),
|
|
407
|
+
[registry, schema, formData, uiSchema, renderOptionalField, hasFormData]
|
|
408
|
+
);
|
|
399
409
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
400
410
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
401
411
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -405,9 +415,7 @@
|
|
|
405
415
|
items: actualFormData.map((keyedItem, index) => {
|
|
406
416
|
const { key, item } = keyedItem;
|
|
407
417
|
const itemCast = item;
|
|
408
|
-
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
409
418
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
410
|
-
const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
411
419
|
const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
412
420
|
const itemProps = {
|
|
413
421
|
itemKey: key,
|
|
@@ -424,8 +432,8 @@
|
|
|
424
432
|
canAdd,
|
|
425
433
|
canMoveUp: index > 0,
|
|
426
434
|
canMoveDown: index < formData.length - 1,
|
|
427
|
-
|
|
428
|
-
|
|
435
|
+
rawItemSchema: schemaItems,
|
|
436
|
+
parentFieldPathId: childFieldPathId,
|
|
429
437
|
itemErrorSchema,
|
|
430
438
|
itemData: itemCast,
|
|
431
439
|
itemUiSchema,
|
|
@@ -486,24 +494,24 @@
|
|
|
486
494
|
} = props;
|
|
487
495
|
let { formData: items = [] } = props;
|
|
488
496
|
const fieldTitle = schema.title || title || name;
|
|
489
|
-
const {
|
|
490
|
-
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
497
|
+
const { fields: fields2, formContext, globalUiOptions } = registry;
|
|
498
|
+
const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
491
499
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
492
500
|
const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
493
501
|
const hasFormData = utils.isFormDataAvailable(formData);
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
502
|
+
const schemaItems = react.useMemo(
|
|
503
|
+
() => isObject(schema.items) ? schema.items : [],
|
|
504
|
+
[schema.items]
|
|
497
505
|
);
|
|
498
|
-
const
|
|
506
|
+
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
499
507
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
500
|
-
if (items.length <
|
|
501
|
-
items = items.concat(new Array(
|
|
508
|
+
if (items.length < schemaItems.length) {
|
|
509
|
+
items = items.concat(new Array(schemaItems.length - items.length));
|
|
502
510
|
}
|
|
503
511
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
504
512
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
505
513
|
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsxRuntime.jsx(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId }) : void 0;
|
|
506
|
-
const canAdd = canAddItem(registry, schema, items, uiSchema) &&
|
|
514
|
+
const canAdd = canAddItem(registry, schema, items, uiSchema) && hasAdditionalItems && (!renderOptionalField || hasFormData);
|
|
507
515
|
const arrayProps = {
|
|
508
516
|
canAdd,
|
|
509
517
|
className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
|
|
@@ -513,18 +521,15 @@
|
|
|
513
521
|
items: actualFormData.map((keyedItem, index) => {
|
|
514
522
|
const { key, item } = keyedItem;
|
|
515
523
|
const itemCast = item;
|
|
516
|
-
const additional = index >=
|
|
517
|
-
const
|
|
518
|
-
const itemFieldPathId = utils.toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
524
|
+
const additional = index >= schemaItems.length;
|
|
525
|
+
const rawItemSchema = (additional && isObject(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
|
|
519
526
|
let itemUiSchema;
|
|
520
527
|
if (additional) {
|
|
521
528
|
itemUiSchema = uiSchema.additionalItems;
|
|
529
|
+
} else if (Array.isArray(uiSchema.items)) {
|
|
530
|
+
itemUiSchema = uiSchema.items[index];
|
|
522
531
|
} else {
|
|
523
|
-
|
|
524
|
-
itemUiSchema = uiSchema.items[index];
|
|
525
|
-
} else {
|
|
526
|
-
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
527
|
-
}
|
|
532
|
+
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
528
533
|
}
|
|
529
534
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
530
535
|
const itemProps = {
|
|
@@ -541,12 +546,12 @@
|
|
|
541
546
|
title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
|
|
542
547
|
canAdd,
|
|
543
548
|
canRemove: additional,
|
|
544
|
-
canMoveUp: index >=
|
|
549
|
+
canMoveUp: index >= schemaItems.length + 1,
|
|
545
550
|
canMoveDown: additional && index < items.length - 1,
|
|
546
|
-
|
|
551
|
+
rawItemSchema,
|
|
547
552
|
itemData: itemCast,
|
|
548
553
|
itemUiSchema,
|
|
549
|
-
|
|
554
|
+
parentFieldPathId: childFieldPathId,
|
|
550
555
|
itemErrorSchema,
|
|
551
556
|
autofocus: autofocus && index === 0,
|
|
552
557
|
onBlur,
|
|
@@ -576,8 +581,8 @@
|
|
|
576
581
|
return /* @__PURE__ */ jsxRuntime.jsx(Template, { ...arrayProps });
|
|
577
582
|
}
|
|
578
583
|
function useKeyedFormData(formData = []) {
|
|
579
|
-
const newHash = react
|
|
580
|
-
const [state, setState] = react
|
|
584
|
+
const newHash = react.useMemo(() => utils.hashObject(formData), [formData]);
|
|
585
|
+
const [state, setState] = react.useState(() => ({
|
|
581
586
|
formDataHash: newHash,
|
|
582
587
|
keyedFormData: generateKeyedFormData(formData)
|
|
583
588
|
}));
|
|
@@ -592,10 +597,10 @@
|
|
|
592
597
|
formDataHash = newHash;
|
|
593
598
|
setState({ formDataHash, keyedFormData });
|
|
594
599
|
}
|
|
595
|
-
const updateKeyedFormData = react
|
|
600
|
+
const updateKeyedFormData = react.useCallback((newData) => {
|
|
596
601
|
const plainFormData = keyedToPlainFormData(newData);
|
|
597
|
-
const
|
|
598
|
-
setState({ formDataHash:
|
|
602
|
+
const updatedHash = utils.hashObject(plainFormData);
|
|
603
|
+
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
599
604
|
return plainFormData;
|
|
600
605
|
}, []);
|
|
601
606
|
return { keyedFormData, updateKeyedFormData };
|
|
@@ -604,21 +609,25 @@
|
|
|
604
609
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
605
610
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
606
611
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
612
|
+
const keyedFormDataRef = react.useRef(keyedFormData);
|
|
613
|
+
keyedFormDataRef.current = keyedFormData;
|
|
614
|
+
const errorSchemaRef = react.useRef(errorSchema);
|
|
615
|
+
errorSchemaRef.current = errorSchema;
|
|
607
616
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
608
|
-
const handleAddItem = react
|
|
617
|
+
const handleAddItem = react.useCallback(
|
|
609
618
|
(event, index) => {
|
|
610
619
|
if (event) {
|
|
611
620
|
event.preventDefault();
|
|
612
621
|
}
|
|
613
622
|
let newErrorSchema;
|
|
614
|
-
if (
|
|
623
|
+
if (errorSchemaRef.current) {
|
|
615
624
|
newErrorSchema = {};
|
|
616
|
-
for (const idx
|
|
617
|
-
const i = parseInt(idx);
|
|
625
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
626
|
+
const i = parseInt(idx, 10);
|
|
618
627
|
if (index === void 0 || i < index) {
|
|
619
|
-
set(newErrorSchema, [i],
|
|
628
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
620
629
|
} else if (i >= index) {
|
|
621
|
-
set(newErrorSchema, [i + 1],
|
|
630
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
622
631
|
}
|
|
623
632
|
}
|
|
624
633
|
}
|
|
@@ -626,7 +635,7 @@
|
|
|
626
635
|
key: generateRowId(),
|
|
627
636
|
item: getNewFormDataRow(registry, schema)
|
|
628
637
|
};
|
|
629
|
-
const newKeyedFormData = [...
|
|
638
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
630
639
|
if (index !== void 0) {
|
|
631
640
|
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
632
641
|
} else {
|
|
@@ -634,30 +643,30 @@
|
|
|
634
643
|
}
|
|
635
644
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
636
645
|
},
|
|
637
|
-
[
|
|
646
|
+
[registry, schema, onChange, updateKeyedFormData, childFieldPathId]
|
|
638
647
|
);
|
|
639
|
-
const handleCopyItem = react
|
|
648
|
+
const handleCopyItem = react.useCallback(
|
|
640
649
|
(event, index) => {
|
|
641
650
|
if (event) {
|
|
642
651
|
event.preventDefault();
|
|
643
652
|
}
|
|
644
653
|
let newErrorSchema;
|
|
645
|
-
if (
|
|
654
|
+
if (errorSchemaRef.current) {
|
|
646
655
|
newErrorSchema = {};
|
|
647
|
-
for (const idx
|
|
648
|
-
const i = parseInt(idx);
|
|
656
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
657
|
+
const i = parseInt(idx, 10);
|
|
649
658
|
if (i <= index) {
|
|
650
|
-
set(newErrorSchema, [i],
|
|
659
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
651
660
|
} else if (i > index) {
|
|
652
|
-
set(newErrorSchema, [i + 1],
|
|
661
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
653
662
|
}
|
|
654
663
|
}
|
|
655
664
|
}
|
|
656
665
|
const newKeyedFormDataRow = {
|
|
657
666
|
key: generateRowId(),
|
|
658
|
-
item: _cloneDeep(
|
|
667
|
+
item: _cloneDeep(keyedFormDataRef.current[index].item)
|
|
659
668
|
};
|
|
660
|
-
const newKeyedFormData = [...
|
|
669
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
661
670
|
if (index !== void 0) {
|
|
662
671
|
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
663
672
|
} else {
|
|
@@ -665,62 +674,62 @@
|
|
|
665
674
|
}
|
|
666
675
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
667
676
|
},
|
|
668
|
-
[
|
|
677
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
669
678
|
);
|
|
670
|
-
const handleRemoveItem = react
|
|
679
|
+
const handleRemoveItem = react.useCallback(
|
|
671
680
|
(event, index) => {
|
|
672
681
|
if (event) {
|
|
673
682
|
event.preventDefault();
|
|
674
683
|
}
|
|
675
684
|
let newErrorSchema;
|
|
676
|
-
if (
|
|
685
|
+
if (errorSchemaRef.current) {
|
|
677
686
|
newErrorSchema = {};
|
|
678
|
-
for (const idx
|
|
679
|
-
const i = parseInt(idx);
|
|
687
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
688
|
+
const i = parseInt(idx, 10);
|
|
680
689
|
if (i < index) {
|
|
681
|
-
set(newErrorSchema, [i],
|
|
690
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
682
691
|
} else if (i > index) {
|
|
683
|
-
set(newErrorSchema, [i - 1],
|
|
692
|
+
set(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
|
|
684
693
|
}
|
|
685
694
|
}
|
|
686
695
|
}
|
|
687
|
-
const newKeyedFormData =
|
|
696
|
+
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
688
697
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
689
698
|
},
|
|
690
|
-
[
|
|
699
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
691
700
|
);
|
|
692
|
-
const handleReorderItems = react
|
|
701
|
+
const handleReorderItems = react.useCallback(
|
|
693
702
|
(event, index, newIndex) => {
|
|
694
703
|
if (event) {
|
|
695
704
|
event.preventDefault();
|
|
696
705
|
event.currentTarget.blur();
|
|
697
706
|
}
|
|
698
707
|
let newErrorSchema;
|
|
699
|
-
if (
|
|
708
|
+
if (errorSchemaRef.current) {
|
|
700
709
|
newErrorSchema = {};
|
|
701
|
-
for (const idx
|
|
702
|
-
const i = parseInt(idx);
|
|
703
|
-
if (i
|
|
704
|
-
set(newErrorSchema, [newIndex],
|
|
705
|
-
} else if (i
|
|
706
|
-
set(newErrorSchema, [index],
|
|
710
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
711
|
+
const i = parseInt(idx, 10);
|
|
712
|
+
if (i === index) {
|
|
713
|
+
set(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
|
|
714
|
+
} else if (i === newIndex) {
|
|
715
|
+
set(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
|
|
707
716
|
} else {
|
|
708
|
-
set(newErrorSchema, [idx],
|
|
717
|
+
set(newErrorSchema, [idx], errorSchemaRef.current[i]);
|
|
709
718
|
}
|
|
710
719
|
}
|
|
711
720
|
}
|
|
712
721
|
function reOrderArray() {
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
return
|
|
722
|
+
const newKeyedFormData2 = keyedFormDataRef.current.slice();
|
|
723
|
+
newKeyedFormData2.splice(index, 1);
|
|
724
|
+
newKeyedFormData2.splice(newIndex, 0, keyedFormDataRef.current[index]);
|
|
725
|
+
return newKeyedFormData2;
|
|
717
726
|
}
|
|
718
727
|
const newKeyedFormData = reOrderArray();
|
|
719
728
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
720
729
|
},
|
|
721
|
-
[
|
|
730
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
722
731
|
);
|
|
723
|
-
const handleChange = react
|
|
732
|
+
const handleChange = react.useCallback(
|
|
724
733
|
(value, path, newErrorSchema, id) => {
|
|
725
734
|
const lastPathIsItemIndex = typeof path.at(-1) === "number";
|
|
726
735
|
onChange(
|
|
@@ -735,7 +744,7 @@
|
|
|
735
744
|
},
|
|
736
745
|
[onChange]
|
|
737
746
|
);
|
|
738
|
-
const onSelectChange = react
|
|
747
|
+
const onSelectChange = react.useCallback(
|
|
739
748
|
(value) => {
|
|
740
749
|
onChange(value, childFieldPathId.path, void 0, childFieldPathId?.[utils.ID_KEY]);
|
|
741
750
|
},
|
|
@@ -859,10 +868,8 @@
|
|
|
859
868
|
enumOptions = utils.optionsList({ enum: enums }, uiSchema);
|
|
860
869
|
}
|
|
861
870
|
}
|
|
862
|
-
const onWidgetChange = react
|
|
863
|
-
(value, errorSchema, id) =>
|
|
864
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
865
|
-
},
|
|
871
|
+
const onWidgetChange = react.useCallback(
|
|
872
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
866
873
|
[onChange, fieldPathId]
|
|
867
874
|
);
|
|
868
875
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -915,7 +922,7 @@
|
|
|
915
922
|
return String(formData);
|
|
916
923
|
case "number": {
|
|
917
924
|
const castedNumber = Number(formData);
|
|
918
|
-
return isNaN(castedNumber) ? 0 : castedNumber;
|
|
925
|
+
return Number.isNaN(castedNumber) ? 0 : castedNumber;
|
|
919
926
|
}
|
|
920
927
|
case "boolean":
|
|
921
928
|
return Boolean(formData);
|
|
@@ -942,13 +949,13 @@
|
|
|
942
949
|
errorSchema
|
|
943
950
|
} = props;
|
|
944
951
|
const { translateString, fields: fields2, globalFormOptions } = registry;
|
|
945
|
-
const [type, setType] = react
|
|
952
|
+
const [type, setType] = react.useState(getTypeOfFormData(formData));
|
|
946
953
|
const uiOptions = utils.getUiOptions(uiSchema);
|
|
947
954
|
const typeSelectorInnerFieldPathId = utils.useDeepCompareMemo(
|
|
948
955
|
utils.toFieldPathId("__internal_type_selector", globalFormOptions, fieldPathId)
|
|
949
956
|
);
|
|
950
957
|
const schemaTitle = translateString(utils.TranslatableString.Type);
|
|
951
|
-
const typesOptionSchema = react
|
|
958
|
+
const typesOptionSchema = react.useMemo(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
|
|
952
959
|
const onTypeChange = (newType) => {
|
|
953
960
|
if (newType != null) {
|
|
954
961
|
setType(newType);
|
|
@@ -1073,6 +1080,7 @@
|
|
|
1073
1080
|
}
|
|
1074
1081
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1075
1082
|
let rawSchema;
|
|
1083
|
+
let resultPathId = fieldPathId;
|
|
1076
1084
|
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, utils.ITEMS_KEY)) {
|
|
1077
1085
|
const index = Number(potentialIndex);
|
|
1078
1086
|
const items = schema[utils.ITEMS_KEY];
|
|
@@ -1085,12 +1093,12 @@
|
|
|
1085
1093
|
} else {
|
|
1086
1094
|
rawSchema = items;
|
|
1087
1095
|
}
|
|
1088
|
-
|
|
1096
|
+
resultPathId = {
|
|
1089
1097
|
[utils.ID_KEY]: fieldPathId[utils.ID_KEY],
|
|
1090
1098
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1091
1099
|
};
|
|
1092
1100
|
}
|
|
1093
|
-
return { rawSchema, fieldPathId };
|
|
1101
|
+
return { rawSchema, fieldPathId: resultPathId };
|
|
1094
1102
|
}
|
|
1095
1103
|
function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1096
1104
|
const { schemaUtils, globalFormOptions } = registry;
|
|
@@ -1173,8 +1181,8 @@
|
|
|
1173
1181
|
if (isString(prop)) {
|
|
1174
1182
|
const match = LOOKUP_REGEX.exec(prop);
|
|
1175
1183
|
if (Array.isArray(match) && match.length > 1) {
|
|
1176
|
-
const
|
|
1177
|
-
uiProps[key] = utils.lookupFromFormContext(registry,
|
|
1184
|
+
const lookupName = match[1];
|
|
1185
|
+
uiProps[key] = utils.lookupFromFormContext(registry, lookupName, lookupName);
|
|
1178
1186
|
}
|
|
1179
1187
|
}
|
|
1180
1188
|
});
|
|
@@ -1191,7 +1199,7 @@
|
|
|
1191
1199
|
const { registry, schema: rawSchema, formData } = layoutGridFieldProps;
|
|
1192
1200
|
const { schemaUtils } = registry;
|
|
1193
1201
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1194
|
-
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react
|
|
1202
|
+
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ react.createElement(
|
|
1195
1203
|
LayoutGridField,
|
|
1196
1204
|
{
|
|
1197
1205
|
...layoutGridFieldProps,
|
|
@@ -1278,10 +1286,10 @@
|
|
|
1278
1286
|
return uiComponentProps.rendered;
|
|
1279
1287
|
}
|
|
1280
1288
|
if (schema) {
|
|
1281
|
-
const
|
|
1289
|
+
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1282
1290
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1283
1291
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1284
|
-
|
|
1292
|
+
Field,
|
|
1285
1293
|
{
|
|
1286
1294
|
"data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
|
|
1287
1295
|
...otherProps,
|
|
@@ -1418,7 +1426,7 @@
|
|
|
1418
1426
|
hideError = false
|
|
1419
1427
|
} = props;
|
|
1420
1428
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1421
|
-
const [enumOptions, setEnumOptions] = react
|
|
1429
|
+
const [enumOptions, setEnumOptions] = react.useState(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1422
1430
|
const id = get(fieldPathId, utils.ID_KEY);
|
|
1423
1431
|
const discriminator = utils.getDiscriminatorFieldFromSchema(schema);
|
|
1424
1432
|
const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, options);
|
|
@@ -1427,7 +1435,7 @@
|
|
|
1427
1435
|
const optionsHash = utils.hashObject(options);
|
|
1428
1436
|
const uiSchemaHash = uiSchema ? utils.hashObject(uiSchema) : "";
|
|
1429
1437
|
const formDataHash = formData ? utils.hashObject(formData) : "";
|
|
1430
|
-
react
|
|
1438
|
+
react.useEffect(() => {
|
|
1431
1439
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1432
1440
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
1433
1441
|
const {
|
|
@@ -1451,6 +1459,9 @@
|
|
|
1451
1459
|
const fieldErrorSchema = omit3(errorSchema, [utils.ERRORS_KEY]);
|
|
1452
1460
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1453
1461
|
const onOptionChange = (opt) => {
|
|
1462
|
+
if (disabled || readonly) {
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1454
1465
|
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
1455
1466
|
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1456
1467
|
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
@@ -1512,7 +1523,13 @@
|
|
|
1512
1523
|
}
|
|
1513
1524
|
);
|
|
1514
1525
|
}
|
|
1515
|
-
var AnyOfField = class extends react
|
|
1526
|
+
var AnyOfField = class extends react.Component {
|
|
1527
|
+
/** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
|
|
1528
|
+
* Set to true in the setState callback of onOptionChange (after onChange is called), consumed and reset in
|
|
1529
|
+
* componentDidUpdate. This prevents the matching-option recalculation from overriding a user's explicit choice
|
|
1530
|
+
* when getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
|
|
1531
|
+
*/
|
|
1532
|
+
skipNextOptionRecalculation = false;
|
|
1516
1533
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1517
1534
|
*
|
|
1518
1535
|
* @param props - The `FieldProps` for this template
|
|
@@ -1548,10 +1565,14 @@
|
|
|
1548
1565
|
newState = { selectedOption, retrievedOptions };
|
|
1549
1566
|
}
|
|
1550
1567
|
if (!utils.deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1568
|
+
if (this.skipNextOptionRecalculation) {
|
|
1569
|
+
this.skipNextOptionRecalculation = false;
|
|
1570
|
+
} else {
|
|
1571
|
+
const { retrievedOptions } = newState;
|
|
1572
|
+
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1573
|
+
if (prevState && matchingOption !== selectedOption) {
|
|
1574
|
+
newState = { selectedOption: matchingOption, retrievedOptions };
|
|
1575
|
+
}
|
|
1555
1576
|
}
|
|
1556
1577
|
}
|
|
1557
1578
|
if (newState !== this.state) {
|
|
@@ -1581,7 +1602,10 @@
|
|
|
1581
1602
|
*/
|
|
1582
1603
|
onOptionChange = (option) => {
|
|
1583
1604
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1584
|
-
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1605
|
+
const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
|
|
1606
|
+
if (disabled || readonly) {
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1585
1609
|
const { schemaUtils } = registry;
|
|
1586
1610
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1587
1611
|
if (intOption === selectedOption) {
|
|
@@ -1594,6 +1618,7 @@
|
|
|
1594
1618
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1595
1619
|
}
|
|
1596
1620
|
this.setState({ selectedOption: intOption }, () => {
|
|
1621
|
+
this.skipNextOptionRecalculation = true;
|
|
1597
1622
|
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1598
1623
|
});
|
|
1599
1624
|
};
|
|
@@ -1618,7 +1643,7 @@
|
|
|
1618
1643
|
uiSchema
|
|
1619
1644
|
} = this.props;
|
|
1620
1645
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1621
|
-
const { SchemaField:
|
|
1646
|
+
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1622
1647
|
const MultiSchemaFieldTemplate2 = utils.getTemplate(
|
|
1623
1648
|
"MultiSchemaFieldTemplate",
|
|
1624
1649
|
registry,
|
|
@@ -1642,8 +1667,8 @@
|
|
|
1642
1667
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1643
1668
|
let optionSchema;
|
|
1644
1669
|
if (option) {
|
|
1645
|
-
const { required:
|
|
1646
|
-
optionSchema =
|
|
1670
|
+
const { required: schemaRequired } = schema;
|
|
1671
|
+
optionSchema = schemaRequired ? utils.mergeSchemas({ required: schemaRequired }, option) : option;
|
|
1647
1672
|
}
|
|
1648
1673
|
let optionsUiSchema = [];
|
|
1649
1674
|
if (utils.ONE_OF_KEY in schema && uiSchema && utils.ONE_OF_KEY in uiSchema) {
|
|
@@ -1696,7 +1721,7 @@
|
|
|
1696
1721
|
readonly
|
|
1697
1722
|
}
|
|
1698
1723
|
) : void 0;
|
|
1699
|
-
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1724
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsxRuntime.jsx(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1700
1725
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1701
1726
|
MultiSchemaFieldTemplate2,
|
|
1702
1727
|
{
|
|
@@ -1712,7 +1737,7 @@
|
|
|
1712
1737
|
var MultiSchemaField_default = AnyOfField;
|
|
1713
1738
|
function NullField(props) {
|
|
1714
1739
|
const { formData, onChange, fieldPathId } = props;
|
|
1715
|
-
react
|
|
1740
|
+
react.useEffect(() => {
|
|
1716
1741
|
if (formData === void 0) {
|
|
1717
1742
|
onChange(null, fieldPathId.path);
|
|
1718
1743
|
}
|
|
@@ -1724,16 +1749,14 @@
|
|
|
1724
1749
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1725
1750
|
function NumberField(props) {
|
|
1726
1751
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1727
|
-
const [lastValue, setLastValue] = react
|
|
1752
|
+
const [lastValue, setLastValue] = react.useState(initialValue);
|
|
1728
1753
|
const { StringField: StringField2 } = registry.fields;
|
|
1729
1754
|
let value = formData;
|
|
1730
|
-
const handleChange = react
|
|
1731
|
-
(
|
|
1732
|
-
setLastValue(
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1736
|
-
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? utils.asNumber(value2.replace(trailingCharMatcher, "")) : utils.asNumber(value2);
|
|
1755
|
+
const handleChange = react.useCallback(
|
|
1756
|
+
(newValue, path, errorSchema, id) => {
|
|
1757
|
+
setLastValue(newValue);
|
|
1758
|
+
const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
|
|
1759
|
+
const processed = typeof normalizedValue === "string" && normalizedValue.match(trailingCharMatcherWithPrefix) ? utils.asNumber(normalizedValue.replace(trailingCharMatcher, "")) : utils.asNumber(normalizedValue);
|
|
1737
1760
|
onChange(processed, path, errorSchema, id);
|
|
1738
1761
|
},
|
|
1739
1762
|
[onChange]
|
|
@@ -1752,7 +1775,7 @@
|
|
|
1752
1775
|
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
1753
1776
|
var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
1754
1777
|
function isRequired(schema, name) {
|
|
1755
|
-
return Array.isArray(schema.required) && schema.required.
|
|
1778
|
+
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
1756
1779
|
}
|
|
1757
1780
|
function getDefaultValue(translateString, type) {
|
|
1758
1781
|
switch (type) {
|
|
@@ -1771,7 +1794,7 @@
|
|
|
1771
1794
|
return translateString(utils.TranslatableString.NewStringDefault);
|
|
1772
1795
|
}
|
|
1773
1796
|
}
|
|
1774
|
-
function
|
|
1797
|
+
function ObjectFieldPropertyFn(props) {
|
|
1775
1798
|
const {
|
|
1776
1799
|
fieldPathId,
|
|
1777
1800
|
schema,
|
|
@@ -1791,22 +1814,23 @@
|
|
|
1791
1814
|
handleRemoveProperty,
|
|
1792
1815
|
addedByAdditionalProperties
|
|
1793
1816
|
} = props;
|
|
1794
|
-
const [wasPropertyKeyModified, setWasPropertyKeyModified] = react
|
|
1817
|
+
const [wasPropertyKeyModified, setWasPropertyKeyModified] = react.useState(false);
|
|
1795
1818
|
const { globalFormOptions, fields: fields2 } = registry;
|
|
1796
1819
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1797
1820
|
const innerFieldIdPathId = utils.useDeepCompareMemo(
|
|
1798
1821
|
utils.toFieldPathId(propertyName, globalFormOptions, fieldPathId.path)
|
|
1799
1822
|
);
|
|
1800
|
-
const onPropertyChange = react
|
|
1823
|
+
const onPropertyChange = react.useCallback(
|
|
1801
1824
|
(value, path, newErrorSchema, id) => {
|
|
1825
|
+
let normalizedValue = value;
|
|
1802
1826
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
1803
|
-
|
|
1827
|
+
normalizedValue = "";
|
|
1804
1828
|
}
|
|
1805
|
-
onChange(
|
|
1829
|
+
onChange(normalizedValue, path, newErrorSchema, id);
|
|
1806
1830
|
},
|
|
1807
1831
|
[onChange, addedByAdditionalProperties]
|
|
1808
1832
|
);
|
|
1809
|
-
const onKeyRename = react
|
|
1833
|
+
const onKeyRename = react.useCallback(
|
|
1810
1834
|
(value) => {
|
|
1811
1835
|
if (propertyName !== value) {
|
|
1812
1836
|
setWasPropertyKeyModified(true);
|
|
@@ -1815,7 +1839,7 @@
|
|
|
1815
1839
|
},
|
|
1816
1840
|
[propertyName, handleKeyRename]
|
|
1817
1841
|
);
|
|
1818
|
-
const onKeyRenameBlur = react
|
|
1842
|
+
const onKeyRenameBlur = react.useCallback(
|
|
1819
1843
|
(event) => {
|
|
1820
1844
|
const {
|
|
1821
1845
|
target: { value }
|
|
@@ -1824,7 +1848,7 @@
|
|
|
1824
1848
|
},
|
|
1825
1849
|
[onKeyRename]
|
|
1826
1850
|
);
|
|
1827
|
-
const onRemoveProperty = react
|
|
1851
|
+
const onRemoveProperty = react.useCallback(() => {
|
|
1828
1852
|
handleRemoveProperty(propertyName);
|
|
1829
1853
|
}, [propertyName, handleRemoveProperty]);
|
|
1830
1854
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1851,6 +1875,7 @@
|
|
|
1851
1875
|
}
|
|
1852
1876
|
);
|
|
1853
1877
|
}
|
|
1878
|
+
var ObjectFieldProperty = react.memo(ObjectFieldPropertyFn);
|
|
1854
1879
|
function ObjectField(props) {
|
|
1855
1880
|
const {
|
|
1856
1881
|
schema: rawSchema,
|
|
@@ -1871,35 +1896,38 @@
|
|
|
1871
1896
|
} = props;
|
|
1872
1897
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
1873
1898
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
1874
|
-
const formDataRef = react
|
|
1899
|
+
const formDataRef = react.useRef(formData);
|
|
1875
1900
|
formDataRef.current = formData;
|
|
1876
|
-
const schema =
|
|
1877
|
-
|
|
1901
|
+
const schema = react.useMemo(
|
|
1902
|
+
() => schemaUtils.retrieveSchema(rawSchema, formData, true),
|
|
1903
|
+
[schemaUtils, rawSchema, formData]
|
|
1904
|
+
);
|
|
1905
|
+
const uiOptions = react.useMemo(() => utils.getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
1878
1906
|
const { properties: schemaProperties = {} } = schema;
|
|
1879
1907
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
1880
|
-
const lastRenamedProperty = react
|
|
1908
|
+
const lastRenamedProperty = react.useRef({ previousKey: "", currentKey: void 0 });
|
|
1881
1909
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
1882
1910
|
const description = uiOptions.description ?? schema.description;
|
|
1883
1911
|
const renderOptionalField = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
1884
1912
|
const hasFormData = utils.isFormDataAvailable(formData);
|
|
1885
1913
|
let orderedProperties = [];
|
|
1886
|
-
const getAvailableKey = react
|
|
1887
|
-
(preferredKey,
|
|
1914
|
+
const getAvailableKey = react.useCallback(
|
|
1915
|
+
(preferredKey, existingFormData) => {
|
|
1888
1916
|
const { duplicateKeySuffixSeparator = "-" } = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
1889
1917
|
let index = 0;
|
|
1890
1918
|
let newKey = preferredKey;
|
|
1891
|
-
while (has(
|
|
1892
|
-
|
|
1919
|
+
while (has(existingFormData, newKey)) {
|
|
1920
|
+
index += 1;
|
|
1921
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
1893
1922
|
}
|
|
1894
1923
|
return newKey;
|
|
1895
1924
|
},
|
|
1896
1925
|
[uiSchema, globalUiOptions]
|
|
1897
1926
|
);
|
|
1898
|
-
const onAddProperty = react
|
|
1927
|
+
const onAddProperty = react.useCallback(() => {
|
|
1899
1928
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
1900
1929
|
return;
|
|
1901
1930
|
}
|
|
1902
|
-
const { translateString: translateString2 } = registry;
|
|
1903
1931
|
const newFormData = { ...formData };
|
|
1904
1932
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
1905
1933
|
if (schema.patternProperties) {
|
|
@@ -1914,8 +1942,7 @@
|
|
|
1914
1942
|
defaultValue = schema.additionalProperties.default;
|
|
1915
1943
|
let apSchema = schema.additionalProperties;
|
|
1916
1944
|
if (utils.REF_KEY in apSchema) {
|
|
1917
|
-
|
|
1918
|
-
apSchema = schemaUtils2.retrieveSchema({ [utils.REF_KEY]: apSchema[utils.REF_KEY] }, formData);
|
|
1945
|
+
apSchema = schemaUtils.retrieveSchema({ [utils.REF_KEY]: apSchema[utils.REF_KEY] }, formData);
|
|
1919
1946
|
type = apSchema.type;
|
|
1920
1947
|
constValue = apSchema.const;
|
|
1921
1948
|
defaultValue = apSchema.default;
|
|
@@ -1924,7 +1951,7 @@
|
|
|
1924
1951
|
type = "object";
|
|
1925
1952
|
}
|
|
1926
1953
|
}
|
|
1927
|
-
const newValue = constValue ?? defaultValue ?? getDefaultValue(
|
|
1954
|
+
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
1928
1955
|
set(newFormData, newKey, newValue);
|
|
1929
1956
|
}
|
|
1930
1957
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
@@ -1932,8 +1959,8 @@
|
|
|
1932
1959
|
lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
|
|
1933
1960
|
}
|
|
1934
1961
|
onChange(newFormData, childFieldPathId.path);
|
|
1935
|
-
}, [formData, onChange,
|
|
1936
|
-
const handleKeyRename = react
|
|
1962
|
+
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
1963
|
+
const handleKeyRename = react.useCallback(
|
|
1937
1964
|
(oldKey, newKey) => {
|
|
1938
1965
|
if (oldKey !== newKey) {
|
|
1939
1966
|
const currentFormData = formDataRef.current;
|
|
@@ -1943,8 +1970,8 @@
|
|
|
1943
1970
|
};
|
|
1944
1971
|
const newKeys = { [oldKey]: actualNewKey };
|
|
1945
1972
|
const keyValues = Object.keys(newFormData).map((key) => {
|
|
1946
|
-
const
|
|
1947
|
-
return { [
|
|
1973
|
+
const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
|
|
1974
|
+
return { [mappedKey]: newFormData[key] };
|
|
1948
1975
|
});
|
|
1949
1976
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
1950
1977
|
formDataRef.current = renamedObj;
|
|
@@ -1957,13 +1984,13 @@
|
|
|
1957
1984
|
},
|
|
1958
1985
|
[onChange, childFieldPathId, getAvailableKey]
|
|
1959
1986
|
);
|
|
1960
|
-
const handleRemoveProperty = react
|
|
1987
|
+
const handleRemoveProperty = react.useCallback(
|
|
1961
1988
|
(key) => {
|
|
1962
1989
|
onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
|
|
1963
1990
|
},
|
|
1964
1991
|
[onChange, childFieldPathId]
|
|
1965
1992
|
);
|
|
1966
|
-
const getStableKey = react
|
|
1993
|
+
const getStableKey = react.useCallback((property) => {
|
|
1967
1994
|
if (lastRenamedProperty.current.currentKey === property) {
|
|
1968
1995
|
return lastRenamedProperty.current.previousKey;
|
|
1969
1996
|
}
|
|
@@ -1975,7 +2002,7 @@
|
|
|
1975
2002
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1976
2003
|
} catch (err) {
|
|
1977
2004
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1978
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2005
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1979
2006
|
/* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
|
|
1980
2007
|
] });
|
|
1981
2008
|
}
|
|
@@ -1986,20 +2013,20 @@
|
|
|
1986
2013
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
1987
2014
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
1988
2015
|
description: uiOptions.label === false ? void 0 : description,
|
|
1989
|
-
properties: orderedProperties.map((
|
|
1990
|
-
const addedByAdditionalProperties = has(schema, [utils.PROPERTIES_KEY,
|
|
1991
|
-
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[
|
|
2016
|
+
properties: orderedProperties.map((propertyName) => {
|
|
2017
|
+
const addedByAdditionalProperties = has(schema, [utils.PROPERTIES_KEY, propertyName, utils.ADDITIONAL_PROPERTY_FLAG]);
|
|
2018
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
1992
2019
|
const hidden = utils.getUiOptions(fieldUiSchema).widget === "hidden";
|
|
1993
2020
|
const content = /* @__PURE__ */ jsxRuntime.jsx(
|
|
1994
2021
|
ObjectFieldProperty,
|
|
1995
2022
|
{
|
|
1996
|
-
propertyName
|
|
1997
|
-
required: isRequired(schema,
|
|
1998
|
-
schema: get(schema, [utils.PROPERTIES_KEY,
|
|
2023
|
+
propertyName,
|
|
2024
|
+
required: isRequired(schema, propertyName),
|
|
2025
|
+
schema: get(schema, [utils.PROPERTIES_KEY, propertyName], {}),
|
|
1999
2026
|
uiSchema: fieldUiSchema,
|
|
2000
|
-
errorSchema: get(errorSchema, [
|
|
2027
|
+
errorSchema: get(errorSchema, [propertyName]),
|
|
2001
2028
|
fieldPathId: childFieldPathId,
|
|
2002
|
-
formData: get(formData, [
|
|
2029
|
+
formData: get(formData, [propertyName]),
|
|
2003
2030
|
handleKeyRename,
|
|
2004
2031
|
handleRemoveProperty,
|
|
2005
2032
|
addedByAdditionalProperties,
|
|
@@ -2011,11 +2038,11 @@
|
|
|
2011
2038
|
readonly,
|
|
2012
2039
|
hideError
|
|
2013
2040
|
},
|
|
2014
|
-
getStableKey(
|
|
2041
|
+
getStableKey(propertyName)
|
|
2015
2042
|
);
|
|
2016
2043
|
return {
|
|
2017
2044
|
content,
|
|
2018
|
-
name:
|
|
2045
|
+
name: propertyName,
|
|
2019
2046
|
readonly,
|
|
2020
2047
|
disabled,
|
|
2021
2048
|
required,
|
|
@@ -2103,7 +2130,7 @@
|
|
|
2103
2130
|
null: "NullField"
|
|
2104
2131
|
};
|
|
2105
2132
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
2106
|
-
const field = uiOptions
|
|
2133
|
+
const { field } = uiOptions;
|
|
2107
2134
|
const { fields: fields2 } = registry;
|
|
2108
2135
|
if (typeof field === "function") {
|
|
2109
2136
|
return field;
|
|
@@ -2121,7 +2148,7 @@
|
|
|
2121
2148
|
if (!componentName && (schema.anyOf || schema.oneOf)) {
|
|
2122
2149
|
return () => null;
|
|
2123
2150
|
}
|
|
2124
|
-
return componentName in fields2 ? fields2[componentName] : fields2
|
|
2151
|
+
return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
|
|
2125
2152
|
}
|
|
2126
2153
|
function SchemaFieldRender(props) {
|
|
2127
2154
|
const {
|
|
@@ -2153,10 +2180,10 @@
|
|
|
2153
2180
|
const FieldErrorTemplate2 = utils.getTemplate("FieldErrorTemplate", registry, uiOptions);
|
|
2154
2181
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2155
2182
|
const fieldId = fieldPathId[utils.ID_KEY];
|
|
2156
|
-
const handleFieldComponentChange = react
|
|
2157
|
-
(
|
|
2183
|
+
const handleFieldComponentChange = react.useCallback(
|
|
2184
|
+
(newFormData, path, newErrorSchema, id2) => {
|
|
2158
2185
|
const theId = id2 || fieldId;
|
|
2159
|
-
return onChange(
|
|
2186
|
+
return onChange(newFormData, path, newErrorSchema, theId);
|
|
2160
2187
|
},
|
|
2161
2188
|
[fieldId, onChange]
|
|
2162
2189
|
);
|
|
@@ -2180,12 +2207,12 @@
|
|
|
2180
2207
|
if (schema[utils.ANY_OF_KEY]) {
|
|
2181
2208
|
XxxOfField = _AnyOfField;
|
|
2182
2209
|
XxxOfOptions = schema[utils.ANY_OF_KEY].map(
|
|
2183
|
-
(
|
|
2210
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2184
2211
|
);
|
|
2185
2212
|
} else if (schema[utils.ONE_OF_KEY]) {
|
|
2186
2213
|
XxxOfField = _OneOfField;
|
|
2187
2214
|
XxxOfOptions = schema[utils.ONE_OF_KEY].map(
|
|
2188
|
-
(
|
|
2215
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2189
2216
|
);
|
|
2190
2217
|
}
|
|
2191
2218
|
const isOptionalRender = utils.shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
@@ -2230,7 +2257,7 @@
|
|
|
2230
2257
|
label = registry.translateString(utils.TranslatableString.DeprecatedLabel, [label]);
|
|
2231
2258
|
}
|
|
2232
2259
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2233
|
-
const help = uiOptions
|
|
2260
|
+
const { help } = uiOptions;
|
|
2234
2261
|
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2235
2262
|
const classNames = ["rjsf-field", `rjsf-field-${utils.getSchemaType(schema)}`];
|
|
2236
2263
|
if (!hideError && __errors && __errors.length > 0) {
|
|
@@ -2321,7 +2348,7 @@
|
|
|
2321
2348
|
)
|
|
2322
2349
|
] }) });
|
|
2323
2350
|
}
|
|
2324
|
-
var SchemaField = class extends react
|
|
2351
|
+
var SchemaField = class extends react.Component {
|
|
2325
2352
|
shouldComponentUpdate(nextProps) {
|
|
2326
2353
|
const {
|
|
2327
2354
|
registry: { globalFormOptions }
|
|
@@ -2364,10 +2391,8 @@
|
|
|
2364
2391
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2365
2392
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2366
2393
|
const Widget = utils.getWidget(schema, widget, widgets2);
|
|
2367
|
-
const onWidgetChange = react
|
|
2368
|
-
(value, errorSchema, id) =>
|
|
2369
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2370
|
-
},
|
|
2394
|
+
const onWidgetChange = react.useCallback(
|
|
2395
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
2371
2396
|
[onChange, fieldPathId]
|
|
2372
2397
|
);
|
|
2373
2398
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2630,9 +2655,10 @@
|
|
|
2630
2655
|
}
|
|
2631
2656
|
return /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: utils.examplesId(id), children: examples.concat(
|
|
2632
2657
|
schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
|
|
2633
|
-
).map((example) =>
|
|
2634
|
-
|
|
2635
|
-
|
|
2658
|
+
).map((example) => (
|
|
2659
|
+
// oxlint-disable-next-line jsx-a11y/control-has-associated-label
|
|
2660
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, String(example))
|
|
2661
|
+
)) }, `datalist_${id}`);
|
|
2636
2662
|
}
|
|
2637
2663
|
function BaseInputTemplate(props) {
|
|
2638
2664
|
const {
|
|
@@ -2675,19 +2701,19 @@
|
|
|
2675
2701
|
} else {
|
|
2676
2702
|
inputValue = value == null ? "" : value;
|
|
2677
2703
|
}
|
|
2678
|
-
const
|
|
2679
|
-
({ target: { value:
|
|
2704
|
+
const handleChange = react.useCallback(
|
|
2705
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
2680
2706
|
[onChange, options]
|
|
2681
2707
|
);
|
|
2682
|
-
const
|
|
2708
|
+
const handleBlur = react.useCallback(
|
|
2683
2709
|
({ target }) => onBlur(id, target && target.value),
|
|
2684
2710
|
[onBlur, id]
|
|
2685
2711
|
);
|
|
2686
|
-
const
|
|
2712
|
+
const handleFocus = react.useCallback(
|
|
2687
2713
|
({ target }) => onFocus(id, target && target.value),
|
|
2688
2714
|
[onFocus, id]
|
|
2689
2715
|
);
|
|
2690
|
-
const
|
|
2716
|
+
const handleClear = react.useCallback(
|
|
2691
2717
|
(e) => {
|
|
2692
2718
|
e.preventDefault();
|
|
2693
2719
|
e.stopPropagation();
|
|
@@ -2708,45 +2734,51 @@
|
|
|
2708
2734
|
value: inputValue,
|
|
2709
2735
|
...inputProps,
|
|
2710
2736
|
list: schema.examples ? utils.examplesId(id) : void 0,
|
|
2711
|
-
onChange: onChangeOverride ||
|
|
2712
|
-
onBlur:
|
|
2713
|
-
onFocus:
|
|
2737
|
+
onChange: onChangeOverride || handleChange,
|
|
2738
|
+
onBlur: handleBlur,
|
|
2739
|
+
onFocus: handleFocus,
|
|
2714
2740
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
2715
2741
|
}
|
|
2716
2742
|
),
|
|
2717
|
-
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick:
|
|
2743
|
+
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsxRuntime.jsx(ClearButton2, { registry, onClick: handleClear }),
|
|
2718
2744
|
/* @__PURE__ */ jsxRuntime.jsx(SchemaExamples, { id, schema })
|
|
2719
2745
|
] });
|
|
2720
2746
|
}
|
|
2721
|
-
function
|
|
2747
|
+
function IconButtonFn(props) {
|
|
2722
2748
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2723
2749
|
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsxRuntime.jsx("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
2724
2750
|
}
|
|
2725
|
-
|
|
2751
|
+
var IconButton = react.memo(IconButtonFn);
|
|
2752
|
+
var IconButton_default = IconButton;
|
|
2753
|
+
function CopyButtonFn(props) {
|
|
2726
2754
|
const {
|
|
2727
2755
|
registry: { translateString }
|
|
2728
2756
|
} = props;
|
|
2729
2757
|
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.CopyButton), ...props, icon: "copy" });
|
|
2730
2758
|
}
|
|
2731
|
-
|
|
2759
|
+
var CopyButton = react.memo(CopyButtonFn);
|
|
2760
|
+
function MoveDownButtonFn(props) {
|
|
2732
2761
|
const {
|
|
2733
2762
|
registry: { translateString }
|
|
2734
2763
|
} = props;
|
|
2735
2764
|
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveDownButton), ...props, icon: "arrow-down" });
|
|
2736
2765
|
}
|
|
2737
|
-
|
|
2766
|
+
var MoveDownButton = react.memo(MoveDownButtonFn);
|
|
2767
|
+
function MoveUpButtonFn(props) {
|
|
2738
2768
|
const {
|
|
2739
2769
|
registry: { translateString }
|
|
2740
2770
|
} = props;
|
|
2741
2771
|
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveUpButton), ...props, icon: "arrow-up" });
|
|
2742
2772
|
}
|
|
2743
|
-
|
|
2773
|
+
var MoveUpButton = react.memo(MoveUpButtonFn);
|
|
2774
|
+
function RemoveButtonFn(props) {
|
|
2744
2775
|
const {
|
|
2745
2776
|
registry: { translateString }
|
|
2746
2777
|
} = props;
|
|
2747
2778
|
return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
2748
2779
|
}
|
|
2749
|
-
|
|
2780
|
+
var RemoveButton = react.memo(RemoveButtonFn);
|
|
2781
|
+
function ClearButtonFn({
|
|
2750
2782
|
id,
|
|
2751
2783
|
className,
|
|
2752
2784
|
onClick,
|
|
@@ -2770,6 +2802,7 @@
|
|
|
2770
2802
|
}
|
|
2771
2803
|
);
|
|
2772
2804
|
}
|
|
2805
|
+
var ClearButton = react.memo(ClearButtonFn);
|
|
2773
2806
|
function AddButton({
|
|
2774
2807
|
id,
|
|
2775
2808
|
className,
|
|
@@ -2783,7 +2816,7 @@
|
|
|
2783
2816
|
{
|
|
2784
2817
|
className: `col-xs-4 col-sm-2 col-lg-1 col-xs-offset-8 col-sm-offset-10 col-lg-offset-11 text-right ${className}`,
|
|
2785
2818
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2786
|
-
|
|
2819
|
+
IconButton_default,
|
|
2787
2820
|
{
|
|
2788
2821
|
id,
|
|
2789
2822
|
iconType: "info",
|
|
@@ -2824,7 +2857,7 @@
|
|
|
2824
2857
|
const { globalUiOptions } = registry;
|
|
2825
2858
|
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
2826
2859
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
2827
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
2860
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
2828
2861
|
}
|
|
2829
2862
|
return description;
|
|
2830
2863
|
}
|
|
@@ -2843,9 +2876,10 @@
|
|
|
2843
2876
|
const { translateString } = registry;
|
|
2844
2877
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "panel panel-danger errors", children: [
|
|
2845
2878
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "panel-heading", children: /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "panel-title", children: translateString(utils.TranslatableString.ErrorsLabel) }) }),
|
|
2846
|
-
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-group", children: errors.map((error, i) =>
|
|
2847
|
-
|
|
2848
|
-
|
|
2879
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-group", children: errors.map((error, i) => (
|
|
2880
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
2881
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-group-item text-danger", children: error.stack }, i)
|
|
2882
|
+
)) })
|
|
2849
2883
|
] });
|
|
2850
2884
|
}
|
|
2851
2885
|
function FallbackFieldTemplate(props) {
|
|
@@ -2870,9 +2904,10 @@
|
|
|
2870
2904
|
return null;
|
|
2871
2905
|
}
|
|
2872
2906
|
const id = utils.errorId(fieldPathId);
|
|
2873
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) =>
|
|
2874
|
-
|
|
2875
|
-
|
|
2907
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => (
|
|
2908
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
2909
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-danger", children: error }, index)
|
|
2910
|
+
)) }) });
|
|
2876
2911
|
}
|
|
2877
2912
|
var TEST_IDS2 = utils.getTestIds();
|
|
2878
2913
|
function RichHelp({
|
|
@@ -2883,7 +2918,7 @@
|
|
|
2883
2918
|
const { globalUiOptions } = registry;
|
|
2884
2919
|
const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
2885
2920
|
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
2886
|
-
return /* @__PURE__ */ jsxRuntime.jsx(react.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
2921
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
2887
2922
|
}
|
|
2888
2923
|
return help;
|
|
2889
2924
|
}
|
|
@@ -3014,7 +3049,7 @@
|
|
|
3014
3049
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3015
3050
|
if (onAddClick) {
|
|
3016
3051
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3017
|
-
|
|
3052
|
+
IconButton_default,
|
|
3018
3053
|
{
|
|
3019
3054
|
id,
|
|
3020
3055
|
registry,
|
|
@@ -3024,9 +3059,10 @@
|
|
|
3024
3059
|
title: label
|
|
3025
3060
|
}
|
|
3026
3061
|
);
|
|
3027
|
-
}
|
|
3062
|
+
}
|
|
3063
|
+
if (onRemoveClick) {
|
|
3028
3064
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3029
|
-
|
|
3065
|
+
IconButton_default,
|
|
3030
3066
|
{
|
|
3031
3067
|
id,
|
|
3032
3068
|
registry,
|
|
@@ -3062,7 +3098,7 @@
|
|
|
3062
3098
|
translateParams.push(reason);
|
|
3063
3099
|
}
|
|
3064
3100
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "unsupported-field", children: [
|
|
3065
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3101
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3066
3102
|
schema && /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3067
3103
|
] });
|
|
3068
3104
|
}
|
|
@@ -3172,23 +3208,26 @@
|
|
|
3172
3208
|
const { translateString } = registry;
|
|
3173
3209
|
const { elements, handleChange, handleClear, handleSetNow } = utils.useAltDateWidgetProps(props);
|
|
3174
3210
|
return /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "list-inline", children: [
|
|
3175
|
-
elements.map((elemProps, i) =>
|
|
3176
|
-
|
|
3177
|
-
{
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3211
|
+
elements.map((elemProps, i) => (
|
|
3212
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3213
|
+
/* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3214
|
+
utils.DateElement,
|
|
3215
|
+
{
|
|
3216
|
+
rootId: id,
|
|
3217
|
+
name,
|
|
3218
|
+
select: handleChange,
|
|
3219
|
+
...elemProps,
|
|
3220
|
+
disabled,
|
|
3221
|
+
readonly,
|
|
3222
|
+
registry,
|
|
3223
|
+
onBlur,
|
|
3224
|
+
onFocus,
|
|
3225
|
+
autofocus: autofocus && i === 0
|
|
3226
|
+
}
|
|
3227
|
+
) }, i)
|
|
3228
|
+
)),
|
|
3229
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }) }),
|
|
3230
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx("li", { className: "list-inline-item", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) }) })
|
|
3192
3231
|
] });
|
|
3193
3232
|
}
|
|
3194
3233
|
var AltDateWidget_default = AltDateWidget;
|
|
@@ -3207,17 +3246,17 @@
|
|
|
3207
3246
|
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3208
3247
|
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3209
3248
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3210
|
-
const handleBlur = react
|
|
3249
|
+
const handleBlur = react.useCallback(
|
|
3211
3250
|
({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3212
3251
|
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3213
3252
|
);
|
|
3214
|
-
const handleFocus = react
|
|
3253
|
+
const handleFocus = react.useCallback(
|
|
3215
3254
|
({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3216
3255
|
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3217
3256
|
);
|
|
3218
3257
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3219
3258
|
const checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3220
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3259
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3221
3260
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3222
3261
|
const handleChange = (event) => {
|
|
3223
3262
|
if (event.target.checked) {
|
|
@@ -3245,7 +3284,7 @@
|
|
|
3245
3284
|
),
|
|
3246
3285
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
|
|
3247
3286
|
] });
|
|
3248
|
-
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox },
|
|
3287
|
+
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: checkbox }) }, String(option.value));
|
|
3249
3288
|
}) });
|
|
3250
3289
|
}
|
|
3251
3290
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
@@ -3272,15 +3311,15 @@
|
|
|
3272
3311
|
options
|
|
3273
3312
|
);
|
|
3274
3313
|
const required = utils.schemaRequiresTrueValue(schema);
|
|
3275
|
-
const handleChange = react
|
|
3314
|
+
const handleChange = react.useCallback(
|
|
3276
3315
|
(event) => onChange(event.target.checked),
|
|
3277
3316
|
[onChange]
|
|
3278
3317
|
);
|
|
3279
|
-
const handleBlur = react
|
|
3318
|
+
const handleBlur = react.useCallback(
|
|
3280
3319
|
(event) => onBlur(id, event.target.checked),
|
|
3281
3320
|
[onBlur, id]
|
|
3282
3321
|
);
|
|
3283
|
-
const handleFocus = react
|
|
3322
|
+
const handleFocus = react.useCallback(
|
|
3284
3323
|
(event) => onFocus(id, event.target.checked),
|
|
3285
3324
|
[onFocus, id]
|
|
3286
3325
|
);
|
|
@@ -3334,14 +3373,14 @@
|
|
|
3334
3373
|
type: "datetime-local",
|
|
3335
3374
|
...props,
|
|
3336
3375
|
value: utils.utcToLocal(value),
|
|
3337
|
-
onChange: (
|
|
3376
|
+
onChange: (newValue) => onChange(utils.localToUTC(newValue))
|
|
3338
3377
|
}
|
|
3339
3378
|
);
|
|
3340
3379
|
}
|
|
3341
3380
|
function DateWidget(props) {
|
|
3342
3381
|
const { onChange, options, registry } = props;
|
|
3343
3382
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3344
|
-
const handleChange = react
|
|
3383
|
+
const handleChange = react.useCallback((value) => onChange(value || void 0), [onChange]);
|
|
3345
3384
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3346
3385
|
}
|
|
3347
3386
|
function EmailWidget(props) {
|
|
@@ -3358,12 +3397,13 @@
|
|
|
3358
3397
|
if (!dataURL) {
|
|
3359
3398
|
return null;
|
|
3360
3399
|
}
|
|
3400
|
+
const previewLabel = translateString(utils.TranslatableString.PreviewLabel);
|
|
3361
3401
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3362
|
-
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3402
|
+
return /* @__PURE__ */ jsxRuntime.jsx("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3363
3403
|
}
|
|
3364
3404
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3365
3405
|
" ",
|
|
3366
|
-
/* @__PURE__ */ jsxRuntime.jsx("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children:
|
|
3406
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
|
|
3367
3407
|
] });
|
|
3368
3408
|
}
|
|
3369
3409
|
function FilesInfo({
|
|
@@ -3381,11 +3421,14 @@
|
|
|
3381
3421
|
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3382
3422
|
const { name, size, type } = fileInfo;
|
|
3383
3423
|
const handleRemove = () => onRemove(key);
|
|
3384
|
-
return
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3424
|
+
return (
|
|
3425
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3426
|
+
/* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
|
|
3427
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Markdown, { children: translateString(utils.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3428
|
+
preview && /* @__PURE__ */ jsxRuntime.jsx(FileInfoPreview, { fileInfo, registry }),
|
|
3429
|
+
/* @__PURE__ */ jsxRuntime.jsx(RemoveButton2, { onClick: handleRemove, registry })
|
|
3430
|
+
] }, key)
|
|
3431
|
+
);
|
|
3389
3432
|
}) });
|
|
3390
3433
|
}
|
|
3391
3434
|
function FileWidget(props) {
|
|
@@ -3451,17 +3494,17 @@
|
|
|
3451
3494
|
}) {
|
|
3452
3495
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3453
3496
|
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3454
|
-
const handleBlur = react
|
|
3497
|
+
const handleBlur = react.useCallback(
|
|
3455
3498
|
({ target }) => onBlur(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3456
3499
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat]
|
|
3457
3500
|
);
|
|
3458
|
-
const handleFocus = react
|
|
3501
|
+
const handleFocus = react.useCallback(
|
|
3459
3502
|
({ target }) => onFocus(id, utils.enumOptionValueDecoder(target && target.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3460
3503
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat]
|
|
3461
3504
|
);
|
|
3462
3505
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3463
3506
|
const checked = utils.enumOptionsIsSelected(option.value, value);
|
|
3464
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3507
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3465
3508
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3466
3509
|
const handleChange = () => onChange(option.value);
|
|
3467
3510
|
const radio = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
@@ -3484,7 +3527,7 @@
|
|
|
3484
3527
|
),
|
|
3485
3528
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label })
|
|
3486
3529
|
] });
|
|
3487
|
-
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `radio-inline ${disabledCls}`, children: radio },
|
|
3530
|
+
return inline ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsxRuntime.jsx("label", { children: radio }) }, String(option.value));
|
|
3488
3531
|
}) });
|
|
3489
3532
|
}
|
|
3490
3533
|
var RadioWidget_default = RadioWidget;
|
|
@@ -3517,7 +3560,7 @@
|
|
|
3517
3560
|
const { stars = 5, shape = "star" } = options;
|
|
3518
3561
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3519
3562
|
const min = schema.minimum || 0;
|
|
3520
|
-
const handleStarClick = react
|
|
3563
|
+
const handleStarClick = react.useCallback(
|
|
3521
3564
|
(starValue) => {
|
|
3522
3565
|
if (!disabled && !readonly) {
|
|
3523
3566
|
onChange(starValue);
|
|
@@ -3525,7 +3568,7 @@
|
|
|
3525
3568
|
},
|
|
3526
3569
|
[onChange, disabled, readonly]
|
|
3527
3570
|
);
|
|
3528
|
-
const handleFocus = react
|
|
3571
|
+
const handleFocus = react.useCallback(
|
|
3529
3572
|
(event) => {
|
|
3530
3573
|
if (onFocus) {
|
|
3531
3574
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3534,7 +3577,7 @@
|
|
|
3534
3577
|
},
|
|
3535
3578
|
[onFocus, id]
|
|
3536
3579
|
);
|
|
3537
|
-
const handleBlur = react
|
|
3580
|
+
const handleBlur = react.useCallback(
|
|
3538
3581
|
(event) => {
|
|
3539
3582
|
if (onBlur) {
|
|
3540
3583
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3549,7 +3592,7 @@
|
|
|
3549
3592
|
}
|
|
3550
3593
|
return isFilled ? "\u2605" : "\u2606";
|
|
3551
3594
|
};
|
|
3552
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
3595
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3553
3596
|
"div",
|
|
3554
3597
|
{
|
|
3555
3598
|
className: "rating-widget",
|
|
@@ -3566,6 +3609,7 @@
|
|
|
3566
3609
|
"span",
|
|
3567
3610
|
{
|
|
3568
3611
|
onClick: () => handleStarClick(starValue),
|
|
3612
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && handleStarClick(starValue),
|
|
3569
3613
|
onFocus: handleFocus,
|
|
3570
3614
|
onBlur: handleBlur,
|
|
3571
3615
|
"data-value": starValue,
|
|
@@ -3598,7 +3642,7 @@
|
|
|
3598
3642
|
)
|
|
3599
3643
|
]
|
|
3600
3644
|
}
|
|
3601
|
-
)
|
|
3645
|
+
);
|
|
3602
3646
|
}
|
|
3603
3647
|
function getValue(event, multiple) {
|
|
3604
3648
|
if (multiple) {
|
|
@@ -3625,21 +3669,21 @@
|
|
|
3625
3669
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3626
3670
|
const emptyValue = multiple ? [] : "";
|
|
3627
3671
|
const optionValueFormat = utils.getOptionValueFormat(options);
|
|
3628
|
-
const handleFocus = react
|
|
3672
|
+
const handleFocus = react.useCallback(
|
|
3629
3673
|
(event) => {
|
|
3630
3674
|
const newValue = getValue(event, multiple);
|
|
3631
3675
|
return onFocus(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3632
3676
|
},
|
|
3633
3677
|
[onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3634
3678
|
);
|
|
3635
|
-
const handleBlur = react
|
|
3679
|
+
const handleBlur = react.useCallback(
|
|
3636
3680
|
(event) => {
|
|
3637
3681
|
const newValue = getValue(event, multiple);
|
|
3638
3682
|
return onBlur(id, utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
3639
3683
|
},
|
|
3640
3684
|
[onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
3641
3685
|
);
|
|
3642
|
-
const handleChange = react
|
|
3686
|
+
const handleChange = react.useCallback(
|
|
3643
3687
|
(event) => {
|
|
3644
3688
|
const newValue = getValue(event, multiple);
|
|
3645
3689
|
return onChange(utils.enumOptionValueDecoder(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
@@ -3648,30 +3692,40 @@
|
|
|
3648
3692
|
);
|
|
3649
3693
|
const selectValue = utils.enumOptionSelectedValue(value, enumOptions, multiple, optionValueFormat, emptyValue);
|
|
3650
3694
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
3651
|
-
return
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3695
|
+
return (
|
|
3696
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
3697
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3698
|
+
"select",
|
|
3699
|
+
{
|
|
3700
|
+
id,
|
|
3701
|
+
name: htmlName || id,
|
|
3702
|
+
multiple,
|
|
3703
|
+
className: "form-control",
|
|
3704
|
+
value: selectValue,
|
|
3705
|
+
required,
|
|
3706
|
+
disabled: disabled || readonly,
|
|
3707
|
+
autoFocus: autofocus,
|
|
3708
|
+
onBlur: handleBlur,
|
|
3709
|
+
onFocus: handleFocus,
|
|
3710
|
+
onChange: handleChange,
|
|
3711
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
3712
|
+
children: [
|
|
3713
|
+
showPlaceholderOption && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: placeholder }),
|
|
3714
|
+
Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
3715
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
3716
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3717
|
+
"option",
|
|
3718
|
+
{
|
|
3719
|
+
value: utils.enumOptionValueEncoder(enumValue, i, optionValueFormat),
|
|
3720
|
+
disabled: isDisabled,
|
|
3721
|
+
children: enumLabel
|
|
3722
|
+
},
|
|
3723
|
+
String(enumValue)
|
|
3724
|
+
);
|
|
3725
|
+
})
|
|
3726
|
+
]
|
|
3727
|
+
}
|
|
3728
|
+
)
|
|
3675
3729
|
);
|
|
3676
3730
|
}
|
|
3677
3731
|
var SelectWidget_default = SelectWidget;
|
|
@@ -3689,15 +3743,15 @@
|
|
|
3689
3743
|
onFocus,
|
|
3690
3744
|
htmlName
|
|
3691
3745
|
}) {
|
|
3692
|
-
const handleChange = react
|
|
3693
|
-
({ target: { value:
|
|
3746
|
+
const handleChange = react.useCallback(
|
|
3747
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
3694
3748
|
[onChange, options.emptyValue]
|
|
3695
3749
|
);
|
|
3696
|
-
const handleBlur = react
|
|
3750
|
+
const handleBlur = react.useCallback(
|
|
3697
3751
|
({ target }) => onBlur(id, target && target.value),
|
|
3698
3752
|
[onBlur, id]
|
|
3699
3753
|
);
|
|
3700
|
-
const handleFocus = react
|
|
3754
|
+
const handleFocus = react.useCallback(
|
|
3701
3755
|
({ target }) => onFocus(id, target && target.value),
|
|
3702
3756
|
[id, onFocus]
|
|
3703
3757
|
);
|
|
@@ -3707,7 +3761,7 @@
|
|
|
3707
3761
|
id,
|
|
3708
3762
|
name: htmlName || id,
|
|
3709
3763
|
className: "form-control",
|
|
3710
|
-
value: value
|
|
3764
|
+
value: value || "",
|
|
3711
3765
|
placeholder,
|
|
3712
3766
|
required,
|
|
3713
3767
|
disabled,
|
|
@@ -3730,7 +3784,7 @@
|
|
|
3730
3784
|
function TimeWidget(props) {
|
|
3731
3785
|
const { onChange, options, registry } = props;
|
|
3732
3786
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3733
|
-
const handleChange = react
|
|
3787
|
+
const handleChange = react.useCallback((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
3734
3788
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
3735
3789
|
}
|
|
3736
3790
|
function UpDownWidget(props) {
|
|
@@ -3793,7 +3847,7 @@
|
|
|
3793
3847
|
...status !== void 0 && { status }
|
|
3794
3848
|
};
|
|
3795
3849
|
}
|
|
3796
|
-
var Form = class extends react
|
|
3850
|
+
var Form = class _Form extends react.Component {
|
|
3797
3851
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
3798
3852
|
* provide any possible type here
|
|
3799
3853
|
*/
|
|
@@ -3804,7 +3858,7 @@
|
|
|
3804
3858
|
/** Flag to track when we're processing a user-initiated field change.
|
|
3805
3859
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
3806
3860
|
*/
|
|
3807
|
-
|
|
3861
|
+
isProcessingUserChange = false;
|
|
3808
3862
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
3809
3863
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
3810
3864
|
*
|
|
@@ -3813,7 +3867,7 @@
|
|
|
3813
3867
|
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
3814
3868
|
*/
|
|
3815
3869
|
static getDerivedStateFromProps(props, state) {
|
|
3816
|
-
if (props.extraErrors !== state.
|
|
3870
|
+
if (props.extraErrors !== state.prevExtraErrors) {
|
|
3817
3871
|
const baseErrors = {
|
|
3818
3872
|
errors: state.schemaValidationErrors || [],
|
|
3819
3873
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -3829,7 +3883,7 @@
|
|
|
3829
3883
|
true
|
|
3830
3884
|
));
|
|
3831
3885
|
}
|
|
3832
|
-
return {
|
|
3886
|
+
return { prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
3833
3887
|
}
|
|
3834
3888
|
return null;
|
|
3835
3889
|
}
|
|
@@ -3848,12 +3902,12 @@
|
|
|
3848
3902
|
const formData = propsFormData ?? initialFormData;
|
|
3849
3903
|
this.state = {
|
|
3850
3904
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
3851
|
-
|
|
3905
|
+
prevExtraErrors: props.extraErrors
|
|
3852
3906
|
};
|
|
3853
3907
|
if (onChange && !utils.deepEquals(this.state.formData, formData)) {
|
|
3854
3908
|
onChange(toIChangeEvent(this.state));
|
|
3855
3909
|
}
|
|
3856
|
-
this.formElement = react
|
|
3910
|
+
this.formElement = react.createRef();
|
|
3857
3911
|
}
|
|
3858
3912
|
/**
|
|
3859
3913
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -3913,8 +3967,8 @@
|
|
|
3913
3967
|
if (snapshot.shouldUpdate) {
|
|
3914
3968
|
const { nextState } = snapshot;
|
|
3915
3969
|
const nextStateDiffersFromProps = !utils.deepEquals(nextState.formData, this.props.formData);
|
|
3916
|
-
const wasProcessingUserChange = this.
|
|
3917
|
-
this.
|
|
3970
|
+
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
3971
|
+
this.isProcessingUserChange = false;
|
|
3918
3972
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
3919
3973
|
return;
|
|
3920
3974
|
}
|
|
@@ -3931,12 +3985,13 @@
|
|
|
3931
3985
|
* @param props - The props passed to the `Form`
|
|
3932
3986
|
* @param inputFormData - The new or current data for the `Form`
|
|
3933
3987
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
3934
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
3935
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
3936
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
3988
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
3989
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
3990
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
3991
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
3937
3992
|
* @returns - The new state for the `Form`
|
|
3938
3993
|
*/
|
|
3939
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
3994
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
|
|
3940
3995
|
const state = this.state || {};
|
|
3941
3996
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3942
3997
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -3947,7 +4002,7 @@
|
|
|
3947
4002
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
3948
4003
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
3949
4004
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
3950
|
-
let schemaUtils = state
|
|
4005
|
+
let { schemaUtils } = state;
|
|
3951
4006
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3952
4007
|
validator2,
|
|
3953
4008
|
schema,
|
|
@@ -3968,19 +4023,45 @@
|
|
|
3968
4023
|
} else if (inputFormData === void 0 && isUncontrolled) {
|
|
3969
4024
|
defaultsFormData = state.formData;
|
|
3970
4025
|
}
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
4026
|
+
let formData;
|
|
4027
|
+
let computedRetrievedSchema;
|
|
4028
|
+
let wasSanitized = false;
|
|
4029
|
+
const preventInfiniteSanitize = [];
|
|
4030
|
+
do {
|
|
4031
|
+
formData = schemaUtils.getDefaultFormState(
|
|
4032
|
+
rootSchema,
|
|
4033
|
+
defaultsFormData,
|
|
4034
|
+
false,
|
|
4035
|
+
state.initialDefaultsGenerated
|
|
4036
|
+
);
|
|
4037
|
+
const formHash = shouldSanitize ? utils.hashObject({ formData }) : "";
|
|
4038
|
+
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4039
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4040
|
+
);
|
|
4041
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !utils.deepEquals(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4042
|
+
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4043
|
+
computedRetrievedSchema,
|
|
4044
|
+
state.retrievedSchema,
|
|
4045
|
+
formData
|
|
4046
|
+
);
|
|
4047
|
+
wasSanitized = !utils.deepEquals(sanitizedFormData, formData);
|
|
4048
|
+
if (wasSanitized) {
|
|
4049
|
+
formData = sanitizedFormData;
|
|
4050
|
+
defaultsFormData = sanitizedFormData;
|
|
4051
|
+
const sanitizedFormHash = utils.hashObject({ formData: sanitizedFormData });
|
|
4052
|
+
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
4053
|
+
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
4054
|
+
}
|
|
4055
|
+
preventInfiniteSanitize.push(formHash);
|
|
4056
|
+
} else {
|
|
4057
|
+
wasSanitized = false;
|
|
4058
|
+
}
|
|
4059
|
+
} while (wasSanitized);
|
|
3980
4060
|
const getCurrentErrors = () => {
|
|
3981
4061
|
if (props.noValidate || isSchemaChanged) {
|
|
3982
4062
|
return { errors: [], errorSchema: {} };
|
|
3983
|
-
}
|
|
4063
|
+
}
|
|
4064
|
+
if (!props.liveValidate) {
|
|
3984
4065
|
return {
|
|
3985
4066
|
errors: state.schemaValidationErrors || [],
|
|
3986
4067
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -3993,8 +4074,7 @@
|
|
|
3993
4074
|
};
|
|
3994
4075
|
let errors;
|
|
3995
4076
|
let errorSchema;
|
|
3996
|
-
let schemaValidationErrors = state
|
|
3997
|
-
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4077
|
+
let { schemaValidationErrors, schemaValidationErrorSchema } = state;
|
|
3998
4078
|
if (mustValidate && !skipLiveValidate) {
|
|
3999
4079
|
const liveValidation = this.liveValidate(
|
|
4000
4080
|
rootSchema,
|
|
@@ -4017,24 +4097,22 @@
|
|
|
4017
4097
|
errors = currentErrors.errors;
|
|
4018
4098
|
errorSchema = currentErrors.errorSchema;
|
|
4019
4099
|
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4020
|
-
const newErrorSchema = formDataChangedFields.reduce(
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
{}
|
|
4026
|
-
);
|
|
4027
|
-
errorSchema = schemaValidationErrorSchema = utils.mergeObjects(
|
|
4100
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
|
|
4101
|
+
acc[key] = void 0;
|
|
4102
|
+
return acc;
|
|
4103
|
+
}, {});
|
|
4104
|
+
schemaValidationErrorSchema = utils.mergeObjects(
|
|
4028
4105
|
currentErrors.errorSchema,
|
|
4029
4106
|
newErrorSchema,
|
|
4030
4107
|
"preventDuplicates"
|
|
4031
4108
|
);
|
|
4109
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4032
4110
|
}
|
|
4033
|
-
const mergedErrors =
|
|
4111
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4034
4112
|
errors = mergedErrors.errors;
|
|
4035
4113
|
errorSchema = mergedErrors.errorSchema;
|
|
4036
4114
|
}
|
|
4037
|
-
const newRegistry =
|
|
4115
|
+
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4038
4116
|
const registry = utils.deepEquals(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4039
4117
|
const fieldPathId = state.fieldPathId && state.fieldPathId?.[utils.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : utils.toFieldPathId("", registry.globalFormOptions);
|
|
4040
4118
|
const nextState = {
|
|
@@ -4048,7 +4126,7 @@
|
|
|
4048
4126
|
errorSchema,
|
|
4049
4127
|
schemaValidationErrors,
|
|
4050
4128
|
schemaValidationErrorSchema,
|
|
4051
|
-
retrievedSchema:
|
|
4129
|
+
retrievedSchema: computedRetrievedSchema,
|
|
4052
4130
|
initialDefaultsGenerated: true,
|
|
4053
4131
|
registry
|
|
4054
4132
|
};
|
|
@@ -4073,10 +4151,10 @@
|
|
|
4073
4151
|
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4074
4152
|
*/
|
|
4075
4153
|
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4076
|
-
const schemaUtils = altSchemaUtils
|
|
4154
|
+
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
4077
4155
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4078
|
-
const
|
|
4079
|
-
return schemaUtils.getValidator().validateFormData(formData,
|
|
4156
|
+
const validationSchema = retrievedSchema ?? schema;
|
|
4157
|
+
return schemaUtils.getValidator().validateFormData(formData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
4080
4158
|
}
|
|
4081
4159
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4082
4160
|
renderErrors(registry) {
|
|
@@ -4105,9 +4183,8 @@
|
|
|
4105
4183
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
4106
4184
|
* @private
|
|
4107
4185
|
*/
|
|
4108
|
-
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4109
|
-
let errorSchema = schemaValidation
|
|
4110
|
-
let errors = schemaValidation.errors;
|
|
4186
|
+
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4187
|
+
let { errorSchema, errors } = schemaValidation;
|
|
4111
4188
|
if (extraErrors) {
|
|
4112
4189
|
const merged = utils.validationDataMerge(schemaValidation, extraErrors);
|
|
4113
4190
|
errorSchema = merged.errorSchema;
|
|
@@ -4136,8 +4213,8 @@
|
|
|
4136
4213
|
*/
|
|
4137
4214
|
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
4138
4215
|
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
4139
|
-
const errors = schemaValidation
|
|
4140
|
-
let errorSchema = schemaValidation
|
|
4216
|
+
const { errors } = schemaValidation;
|
|
4217
|
+
let { errorSchema } = schemaValidation;
|
|
4141
4218
|
if (mergeIntoOriginalErrorSchema) {
|
|
4142
4219
|
errorSchema = utils.mergeObjects(
|
|
4143
4220
|
originalErrorSchema,
|
|
@@ -4147,7 +4224,7 @@
|
|
|
4147
4224
|
}
|
|
4148
4225
|
const schemaValidationErrors = errors;
|
|
4149
4226
|
const schemaValidationErrorSchema = errorSchema;
|
|
4150
|
-
const mergedErrors =
|
|
4227
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
4151
4228
|
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
4152
4229
|
}
|
|
4153
4230
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
@@ -4156,18 +4233,16 @@
|
|
|
4156
4233
|
* @param fields - The fields to keep while filtering
|
|
4157
4234
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4158
4235
|
*/
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
};
|
|
4236
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4237
|
+
getUsedFormData = (formData, fields2) => utils.getUsedFormData(formData, fields2);
|
|
4162
4238
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4163
4239
|
*
|
|
4164
4240
|
* @param pathSchema - The `PathSchema` object for the form
|
|
4165
4241
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4166
4242
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4167
4243
|
*/
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
};
|
|
4244
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4245
|
+
getFieldNames = (pathSchema, formData) => utils.getFieldNames(pathSchema, formData);
|
|
4171
4246
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4172
4247
|
*
|
|
4173
4248
|
* @param formData - The data for the `Form`
|
|
@@ -4219,16 +4294,15 @@
|
|
|
4219
4294
|
if (this.pendingChanges.length === 0) {
|
|
4220
4295
|
return;
|
|
4221
4296
|
}
|
|
4222
|
-
this.
|
|
4297
|
+
this.isProcessingUserChange = true;
|
|
4223
4298
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
4224
4299
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4225
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4300
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
|
|
4226
4301
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4227
|
-
let { customErrors } = this.state;
|
|
4302
|
+
let { customErrors, retrievedSchema } = this.state;
|
|
4228
4303
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4229
4304
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4230
4305
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4231
|
-
let retrievedSchema = this.state.retrievedSchema;
|
|
4232
4306
|
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
4233
4307
|
const hasOnlyUndefinedValues = utils.isObject(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4234
4308
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
@@ -4258,18 +4332,25 @@
|
|
|
4258
4332
|
set(formData, path, valueForPath);
|
|
4259
4333
|
}
|
|
4260
4334
|
}
|
|
4261
|
-
const
|
|
4335
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !utils.isObject(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
4336
|
+
const newState = this.getStateFromProps(
|
|
4337
|
+
this.props,
|
|
4338
|
+
inputForDefaults,
|
|
4339
|
+
void 0,
|
|
4340
|
+
void 0,
|
|
4341
|
+
void 0,
|
|
4342
|
+
true,
|
|
4343
|
+
shouldSanitize
|
|
4344
|
+
);
|
|
4262
4345
|
formData = newState.formData;
|
|
4263
4346
|
retrievedSchema = newState.retrievedSchema;
|
|
4264
4347
|
}
|
|
4265
4348
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
4266
|
-
let state = { formData,
|
|
4349
|
+
let state = { formData, retrievedSchema };
|
|
4267
4350
|
let newFormData = formData;
|
|
4268
4351
|
if (omitExtraData === true && (liveOmit === true || liveOmit === "onChange")) {
|
|
4269
4352
|
newFormData = this.omitExtraData(formData);
|
|
4270
|
-
state = {
|
|
4271
|
-
formData: newFormData
|
|
4272
|
-
};
|
|
4353
|
+
state = { ...state, formData: newFormData };
|
|
4273
4354
|
}
|
|
4274
4355
|
if (newErrorSchema) {
|
|
4275
4356
|
const oldValidationError = !isRootPath ? get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
@@ -4285,9 +4366,9 @@
|
|
|
4285
4366
|
customErrors = new utils.ErrorSchemaBuilder();
|
|
4286
4367
|
}
|
|
4287
4368
|
if (isRootPath) {
|
|
4288
|
-
const
|
|
4289
|
-
if (
|
|
4290
|
-
customErrors.setErrors(
|
|
4369
|
+
const pathErrors = get(newErrorSchema, utils.ERRORS_KEY);
|
|
4370
|
+
if (pathErrors) {
|
|
4371
|
+
customErrors.setErrors(pathErrors);
|
|
4291
4372
|
}
|
|
4292
4373
|
} else {
|
|
4293
4374
|
set(customErrors.ErrorSchema, path, newErrorSchema);
|
|
@@ -4306,14 +4387,14 @@
|
|
|
4306
4387
|
customErrors,
|
|
4307
4388
|
retrievedSchema
|
|
4308
4389
|
);
|
|
4309
|
-
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4390
|
+
state = { ...state, formData: newFormData, ...liveValidation, customErrors };
|
|
4310
4391
|
} else if (!noValidate && newErrorSchema) {
|
|
4311
|
-
const mergedErrors =
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
...mergedErrors,
|
|
4392
|
+
const mergedErrors = _Form.mergeErrors(
|
|
4393
|
+
{ errorSchema: mergeBaseErrorSchema, errors },
|
|
4394
|
+
extraErrors,
|
|
4315
4395
|
customErrors
|
|
4316
|
-
|
|
4396
|
+
);
|
|
4397
|
+
state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
|
|
4317
4398
|
}
|
|
4318
4399
|
this.setState(state, () => {
|
|
4319
4400
|
if (onChange) {
|
|
@@ -4466,7 +4547,7 @@
|
|
|
4466
4547
|
* @returns - The `GlobalFormOptions` from the props
|
|
4467
4548
|
* @private
|
|
4468
4549
|
*/
|
|
4469
|
-
getGlobalFormOptions(props) {
|
|
4550
|
+
static getGlobalFormOptions(props) {
|
|
4470
4551
|
const {
|
|
4471
4552
|
uiSchema = {},
|
|
4472
4553
|
experimental_componentUpdateStrategy,
|
|
@@ -4485,7 +4566,7 @@
|
|
|
4485
4566
|
};
|
|
4486
4567
|
}
|
|
4487
4568
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
4488
|
-
getRegistry(props, schema, schemaUtils) {
|
|
4569
|
+
static getRegistry(props, schema, schemaUtils) {
|
|
4489
4570
|
const { translateString: customTranslateString, uiSchema = {} } = props;
|
|
4490
4571
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
4491
4572
|
return {
|
|
@@ -4504,7 +4585,7 @@
|
|
|
4504
4585
|
schemaUtils,
|
|
4505
4586
|
translateString: customTranslateString || translateString,
|
|
4506
4587
|
globalUiOptions: uiSchema[utils.UI_GLOBAL_OPTIONS_KEY],
|
|
4507
|
-
globalFormOptions:
|
|
4588
|
+
globalFormOptions: _Form.getGlobalFormOptions(props),
|
|
4508
4589
|
uiSchemaDefinitions: uiSchema[utils.UI_DEFINITIONS_KEY] ?? {}
|
|
4509
4590
|
};
|
|
4510
4591
|
}
|
|
@@ -4556,7 +4637,7 @@
|
|
|
4556
4637
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
4557
4638
|
const { errors: prevErrors } = this.state;
|
|
4558
4639
|
const schemaValidation = this.validate(formData);
|
|
4559
|
-
const { errors, errorSchema } = extraErrors ?
|
|
4640
|
+
const { errors, errorSchema } = extraErrors ? _Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
4560
4641
|
const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
4561
4642
|
if (hasError) {
|
|
4562
4643
|
if (focusOnFirstError) {
|
|
@@ -4635,7 +4716,7 @@
|
|
|
4635
4716
|
_internalFormWrapper
|
|
4636
4717
|
} = this.props;
|
|
4637
4718
|
const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
|
|
4638
|
-
const { SchemaField:
|
|
4719
|
+
const { SchemaField: SchemaFieldComponent } = registry.fields;
|
|
4639
4720
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
4640
4721
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
4641
4722
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
@@ -4647,7 +4728,7 @@
|
|
|
4647
4728
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4648
4729
|
FormTag,
|
|
4649
4730
|
{
|
|
4650
|
-
className: className
|
|
4731
|
+
className: className || "rjsf",
|
|
4651
4732
|
id,
|
|
4652
4733
|
name,
|
|
4653
4734
|
method,
|
|
@@ -4663,7 +4744,7 @@
|
|
|
4663
4744
|
children: [
|
|
4664
4745
|
showErrorList === "top" && this.renderErrors(registry),
|
|
4665
4746
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4666
|
-
|
|
4747
|
+
SchemaFieldComponent,
|
|
4667
4748
|
{
|
|
4668
4749
|
name: "",
|
|
4669
4750
|
schema,
|
|
@@ -4679,7 +4760,7 @@
|
|
|
4679
4760
|
readonly
|
|
4680
4761
|
}
|
|
4681
4762
|
),
|
|
4682
|
-
children
|
|
4763
|
+
children || /* @__PURE__ */ jsxRuntime.jsx(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
4683
4764
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
4684
4765
|
]
|
|
4685
4766
|
}
|
|
@@ -4705,16 +4786,16 @@
|
|
|
4705
4786
|
};
|
|
4706
4787
|
}
|
|
4707
4788
|
function withTheme(themeProps) {
|
|
4708
|
-
return react
|
|
4709
|
-
({ fields:
|
|
4710
|
-
fields2 = { ...themeProps?.fields, ...
|
|
4711
|
-
widgets2 = { ...themeProps?.widgets, ...
|
|
4712
|
-
templates2 = {
|
|
4789
|
+
return react.forwardRef(
|
|
4790
|
+
({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
|
|
4791
|
+
const fields2 = { ...themeProps?.fields, ...propFields };
|
|
4792
|
+
const widgets2 = { ...themeProps?.widgets, ...propWidgets };
|
|
4793
|
+
const templates2 = {
|
|
4713
4794
|
...themeProps?.templates,
|
|
4714
|
-
...
|
|
4795
|
+
...propTemplates,
|
|
4715
4796
|
ButtonTemplates: {
|
|
4716
4797
|
...themeProps?.templates?.ButtonTemplates,
|
|
4717
|
-
...
|
|
4798
|
+
...propTemplates?.ButtonTemplates
|
|
4718
4799
|
}
|
|
4719
4800
|
};
|
|
4720
4801
|
return /* @__PURE__ */ jsxRuntime.jsx(
|