@rjsf/core 6.6.0 → 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 +6 -7
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArrayField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/ArrayField.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,UAAU,EACV,eAAe,EAEf,UAAU,EACV,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAs1BrB;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,2CAsP7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { memo, useCallback, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { allowAdditionalItems, getTemplate, getUiOptions, getWidget, hashObject, isCustomWidget, isFixedItems, isFormDataAvailable, optionsList, shouldRenderOptionalField, toFieldPathId, useDeepCompareMemo, ITEMS_KEY, ID_KEY, TranslatableString, } from '@rjsf/utils';
|
|
4
4
|
import cloneDeep from 'lodash-es/cloneDeep.js';
|
|
5
5
|
import isObject from 'lodash-es/isObject.js';
|
|
@@ -17,12 +17,10 @@ function generateRowId() {
|
|
|
17
17
|
function generateKeyedFormData(formData) {
|
|
18
18
|
return !Array.isArray(formData)
|
|
19
19
|
? []
|
|
20
|
-
: formData.map((item) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
});
|
|
20
|
+
: formData.map((item) => ({
|
|
21
|
+
key: generateRowId(),
|
|
22
|
+
item,
|
|
23
|
+
}));
|
|
26
24
|
}
|
|
27
25
|
/** Converts `KeyedFormDataType` data into the inner `formData`
|
|
28
26
|
*
|
|
@@ -93,6 +91,7 @@ function computeItemUiSchema(uiSchema, item, index, formContext) {
|
|
|
93
91
|
return result;
|
|
94
92
|
}
|
|
95
93
|
catch (e) {
|
|
94
|
+
// oxlint-disable-next-line no-console
|
|
96
95
|
console.error(`Error executing dynamic uiSchema.items function for item at index ${index}:`, e);
|
|
97
96
|
// Fall back to undefined to allow the field to still render
|
|
98
97
|
return undefined;
|
|
@@ -166,10 +165,13 @@ function ArrayAsFiles(props) {
|
|
|
166
165
|
/** Renders the individual array item using a `SchemaField` along with the additional properties that are needed to
|
|
167
166
|
* render the whole of the `ArrayFieldItemTemplate`.
|
|
168
167
|
*/
|
|
169
|
-
function
|
|
170
|
-
const { itemKey, index, name, disabled, hideError, readonly, registry, uiOptions, parentUiSchema, canAdd, canRemove = true, canMoveUp, canMoveDown,
|
|
171
|
-
const { schemaUtils, fields: { ArraySchemaField, SchemaField }, globalUiOptions, } = registry;
|
|
172
|
-
const
|
|
168
|
+
function ArrayFieldItemInner(props) {
|
|
169
|
+
const { itemKey, index, name, disabled, hideError, readonly, registry, uiOptions, parentUiSchema, canAdd, canRemove = true, canMoveUp, canMoveDown, rawItemSchema, itemData, itemUiSchema, parentFieldPathId, itemErrorSchema, autofocus, onBlur, onFocus, onChange, rawErrors, totalItems, title, handleAddItem, handleCopyItem, handleRemoveItem, handleReorderItems, } = props;
|
|
170
|
+
const { schemaUtils, fields: { ArraySchemaField, SchemaField }, globalUiOptions, globalFormOptions, } = registry;
|
|
171
|
+
const itemSchema = useMemo(() => schemaUtils.retrieveSchema(rawItemSchema, itemData), [schemaUtils, rawItemSchema, itemData]);
|
|
172
|
+
// parentFieldPathId is the same stable reference for all items; index is a stable number.
|
|
173
|
+
// useMemo avoids creating a new FieldPathId object on every render, letting React.memo bail out.
|
|
174
|
+
const fieldPathId = useMemo(() => toFieldPathId(index, globalFormOptions, parentFieldPathId), [index, globalFormOptions, parentFieldPathId]);
|
|
173
175
|
const ItemSchemaField = ArraySchemaField || SchemaField;
|
|
174
176
|
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
175
177
|
const displayLabel = schemaUtils.getDisplayLabel(itemSchema, itemUiSchema, globalUiOptions);
|
|
@@ -210,7 +212,7 @@ function ArrayFieldItem(props) {
|
|
|
210
212
|
hasMoveUp: has.moveUp,
|
|
211
213
|
hasMoveDown: has.moveDown,
|
|
212
214
|
hasRemove: has.remove,
|
|
213
|
-
index
|
|
215
|
+
index,
|
|
214
216
|
totalItems,
|
|
215
217
|
onAddItem,
|
|
216
218
|
onCopyItem,
|
|
@@ -237,20 +239,22 @@ function ArrayFieldItem(props) {
|
|
|
237
239
|
};
|
|
238
240
|
return _jsx(ArrayFieldItemTemplate, { ...templateProps });
|
|
239
241
|
}
|
|
242
|
+
const ArrayFieldItem = memo(ArrayFieldItemInner);
|
|
240
243
|
/** Renders a normal array without any limitations of length
|
|
241
244
|
*/
|
|
242
245
|
function NormalArray(props) {
|
|
243
246
|
const { schema, uiSchema = {}, errorSchema, fieldPathId, formData: formDataFromProps, name, title, disabled = false, readonly = false, autofocus = false, required = false, hideError = false, registry, onBlur, onFocus, rawErrors, onChange, keyedFormData, handleAddItem, handleCopyItem, handleRemoveItem, handleReorderItems, } = props;
|
|
244
247
|
const fieldTitle = schema.title || title || name;
|
|
245
|
-
const { schemaUtils, fields, formContext,
|
|
248
|
+
const { schemaUtils, fields, formContext, globalUiOptions } = registry;
|
|
246
249
|
const { OptionalDataControlsField } = fields;
|
|
247
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
const
|
|
250
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
251
|
+
// Memoize schemaItems to avoid a new `{}` object identity on every render (which would bust retrieveSchema cache)
|
|
252
|
+
const schemaItems = useMemo(() => (isObject(schema.items) ? schema.items : {}), [schema.items]);
|
|
253
|
+
const itemsSchema = useMemo(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
254
|
+
const formData = useMemo(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
251
255
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
252
256
|
const hasFormData = isFormDataAvailable(formDataFromProps);
|
|
253
|
-
const canAdd = canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData);
|
|
257
|
+
const canAdd = useMemo(() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData), [registry, schema, formData, uiSchema, renderOptionalField, hasFormData]);
|
|
254
258
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
255
259
|
const extraClass = renderOptionalField ? ' rjsf-optional-array-field' : '';
|
|
256
260
|
// All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
|
|
@@ -262,9 +266,7 @@ function NormalArray(props) {
|
|
|
262
266
|
const { key, item } = keyedItem;
|
|
263
267
|
// While we are actually dealing with a single item of type T, the types require a T[], so cast
|
|
264
268
|
const itemCast = item;
|
|
265
|
-
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
266
269
|
const itemErrorSchema = errorSchema ? errorSchema[index] : undefined;
|
|
267
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
268
270
|
// Compute the item UI schema using the helper method
|
|
269
271
|
const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
270
272
|
const itemProps = {
|
|
@@ -282,8 +284,8 @@ function NormalArray(props) {
|
|
|
282
284
|
canAdd,
|
|
283
285
|
canMoveUp: index > 0,
|
|
284
286
|
canMoveDown: index < formData.length - 1,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
+
rawItemSchema: schemaItems,
|
|
288
|
+
parentFieldPathId: childFieldPathId,
|
|
287
289
|
itemErrorSchema,
|
|
288
290
|
itemData: itemCast,
|
|
289
291
|
itemUiSchema,
|
|
@@ -323,28 +325,25 @@ function FixedArray(props) {
|
|
|
323
325
|
const { schema, uiSchema = {}, formData, errorSchema, fieldPathId, name, title, disabled = false, readonly = false, autofocus = false, required = false, hideError = false, registry, onBlur, onFocus, rawErrors, keyedFormData, onChange, handleAddItem, handleCopyItem, handleRemoveItem, handleReorderItems, } = props;
|
|
324
326
|
let { formData: items = [] } = props;
|
|
325
327
|
const fieldTitle = schema.title || title || name;
|
|
326
|
-
const {
|
|
327
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
328
|
+
const { fields, formContext, globalUiOptions } = registry;
|
|
329
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
328
330
|
const { OptionalDataControlsField } = fields;
|
|
329
331
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
330
332
|
const hasFormData = isFormDataAvailable(formData);
|
|
331
|
-
const
|
|
332
|
-
const
|
|
333
|
-
const additionalSchema = isObject(schema.additionalItems)
|
|
334
|
-
? schemaUtils.retrieveSchema(schema.additionalItems, formData)
|
|
335
|
-
: null;
|
|
333
|
+
const schemaItems = useMemo(() => (isObject(schema.items) ? schema.items : []), [schema.items]);
|
|
334
|
+
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
336
335
|
// All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
|
|
337
336
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
338
|
-
if (items.length <
|
|
337
|
+
if (items.length < schemaItems.length) {
|
|
339
338
|
// to make sure at least all fixed items are generated
|
|
340
|
-
items = items.concat(new Array(
|
|
339
|
+
items = items.concat(new Array(schemaItems.length - items.length));
|
|
341
340
|
}
|
|
342
341
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
343
342
|
const extraClass = renderOptionalField ? ' rjsf-optional-array-field' : '';
|
|
344
343
|
const optionalDataControl = renderOptionalField ? (_jsx(OptionalDataControlsField, { ...props, fieldPathId: childFieldPathId })) : undefined;
|
|
345
344
|
// These are the props passed into the render function
|
|
346
345
|
const canAdd = canAddItem(registry, schema, items, uiSchema) &&
|
|
347
|
-
|
|
346
|
+
hasAdditionalItems &&
|
|
348
347
|
(!renderOptionalField || hasFormData);
|
|
349
348
|
const arrayProps = {
|
|
350
349
|
canAdd,
|
|
@@ -356,26 +355,22 @@ function FixedArray(props) {
|
|
|
356
355
|
const { key, item } = keyedItem;
|
|
357
356
|
// While we are actually dealing with a single item of type T, the types require a T[], so cast
|
|
358
357
|
const itemCast = item;
|
|
359
|
-
const additional = index >=
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
: itemSchemas[index]) || {};
|
|
363
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
358
|
+
const additional = index >= schemaItems.length;
|
|
359
|
+
const rawItemSchema = (additional && isObject(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) ||
|
|
360
|
+
{};
|
|
364
361
|
// Compute the item UI schema - handle both static and dynamic cases
|
|
365
362
|
let itemUiSchema;
|
|
366
363
|
if (additional) {
|
|
367
364
|
// For additional items, use additionalItems uiSchema
|
|
368
365
|
itemUiSchema = uiSchema.additionalItems;
|
|
369
366
|
}
|
|
370
|
-
else {
|
|
367
|
+
else if (Array.isArray(uiSchema.items)) {
|
|
371
368
|
// For fixed items, uiSchema.items can be an array, a function, or a single object
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
378
|
-
}
|
|
369
|
+
itemUiSchema = uiSchema.items[index];
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// Use the helper method for function or static object cases
|
|
373
|
+
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
379
374
|
}
|
|
380
375
|
const itemErrorSchema = errorSchema ? errorSchema[index] : undefined;
|
|
381
376
|
const itemProps = {
|
|
@@ -392,12 +387,12 @@ function FixedArray(props) {
|
|
|
392
387
|
title: fieldTitle ? `${fieldTitle}-${index + 1}` : undefined,
|
|
393
388
|
canAdd,
|
|
394
389
|
canRemove: additional,
|
|
395
|
-
canMoveUp: index >=
|
|
390
|
+
canMoveUp: index >= schemaItems.length + 1,
|
|
396
391
|
canMoveDown: additional && index < items.length - 1,
|
|
397
|
-
|
|
392
|
+
rawItemSchema,
|
|
398
393
|
itemData: itemCast,
|
|
399
394
|
itemUiSchema,
|
|
400
|
-
|
|
395
|
+
parentFieldPathId: childFieldPathId,
|
|
401
396
|
itemErrorSchema,
|
|
402
397
|
autofocus: autofocus && index === 0,
|
|
403
398
|
onBlur,
|
|
@@ -456,8 +451,8 @@ function useKeyedFormData(formData = []) {
|
|
|
456
451
|
}
|
|
457
452
|
const updateKeyedFormData = useCallback((newData) => {
|
|
458
453
|
const plainFormData = keyedToPlainFormData(newData);
|
|
459
|
-
const
|
|
460
|
-
setState({ formDataHash:
|
|
454
|
+
const updatedHash = hashObject(plainFormData);
|
|
455
|
+
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
461
456
|
return plainFormData;
|
|
462
457
|
}, []);
|
|
463
458
|
return { keyedFormData, updateKeyedFormData };
|
|
@@ -469,6 +464,12 @@ export default function ArrayField(props) {
|
|
|
469
464
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
470
465
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
471
466
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
467
|
+
// Refs keep the latest values accessible inside stable useCallback closures without being in the dep array,
|
|
468
|
+
// so the four mutation handlers don't get new references on every keyedFormData / errorSchema change.
|
|
469
|
+
const keyedFormDataRef = useRef(keyedFormData);
|
|
470
|
+
keyedFormDataRef.current = keyedFormData;
|
|
471
|
+
const errorSchemaRef = useRef(errorSchema);
|
|
472
|
+
errorSchemaRef.current = errorSchema;
|
|
472
473
|
// All the children will use childFieldPathId if present in the props, falling back to the fieldPathId
|
|
473
474
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
474
475
|
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
@@ -483,15 +484,15 @@ export default function ArrayField(props) {
|
|
|
483
484
|
event.preventDefault();
|
|
484
485
|
}
|
|
485
486
|
let newErrorSchema;
|
|
486
|
-
if (
|
|
487
|
+
if (errorSchemaRef.current) {
|
|
487
488
|
newErrorSchema = {};
|
|
488
|
-
for (const idx
|
|
489
|
-
const i = parseInt(idx);
|
|
489
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
490
|
+
const i = parseInt(idx, 10);
|
|
490
491
|
if (index === undefined || i < index) {
|
|
491
|
-
set(newErrorSchema, [i],
|
|
492
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
492
493
|
}
|
|
493
494
|
else if (i >= index) {
|
|
494
|
-
set(newErrorSchema, [i + 1],
|
|
495
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
495
496
|
}
|
|
496
497
|
}
|
|
497
498
|
}
|
|
@@ -499,7 +500,7 @@ export default function ArrayField(props) {
|
|
|
499
500
|
key: generateRowId(),
|
|
500
501
|
item: getNewFormDataRow(registry, schema),
|
|
501
502
|
};
|
|
502
|
-
const newKeyedFormData = [...
|
|
503
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
503
504
|
if (index !== undefined) {
|
|
504
505
|
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
505
506
|
}
|
|
@@ -507,7 +508,7 @@ export default function ArrayField(props) {
|
|
|
507
508
|
newKeyedFormData.push(newKeyedFormDataRow);
|
|
508
509
|
}
|
|
509
510
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
510
|
-
}, [
|
|
511
|
+
}, [registry, schema, onChange, updateKeyedFormData, childFieldPathId]);
|
|
511
512
|
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
512
513
|
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
513
514
|
* form data converted from the keyed data
|
|
@@ -519,23 +520,23 @@ export default function ArrayField(props) {
|
|
|
519
520
|
event.preventDefault();
|
|
520
521
|
}
|
|
521
522
|
let newErrorSchema;
|
|
522
|
-
if (
|
|
523
|
+
if (errorSchemaRef.current) {
|
|
523
524
|
newErrorSchema = {};
|
|
524
|
-
for (const idx
|
|
525
|
-
const i = parseInt(idx);
|
|
525
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
526
|
+
const i = parseInt(idx, 10);
|
|
526
527
|
if (i <= index) {
|
|
527
|
-
set(newErrorSchema, [i],
|
|
528
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
528
529
|
}
|
|
529
530
|
else if (i > index) {
|
|
530
|
-
set(newErrorSchema, [i + 1],
|
|
531
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
531
532
|
}
|
|
532
533
|
}
|
|
533
534
|
}
|
|
534
535
|
const newKeyedFormDataRow = {
|
|
535
536
|
key: generateRowId(),
|
|
536
|
-
item: cloneDeep(
|
|
537
|
+
item: cloneDeep(keyedFormDataRef.current[index].item),
|
|
537
538
|
};
|
|
538
|
-
const newKeyedFormData = [...
|
|
539
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
539
540
|
if (index !== undefined) {
|
|
540
541
|
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
541
542
|
}
|
|
@@ -543,7 +544,7 @@ export default function ArrayField(props) {
|
|
|
543
544
|
newKeyedFormData.push(newKeyedFormDataRow);
|
|
544
545
|
}
|
|
545
546
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
546
|
-
}, [
|
|
547
|
+
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
547
548
|
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
548
549
|
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
549
550
|
* from the keyed data
|
|
@@ -556,21 +557,21 @@ export default function ArrayField(props) {
|
|
|
556
557
|
}
|
|
557
558
|
// refs #195: revalidate to ensure properly reindexing errors
|
|
558
559
|
let newErrorSchema;
|
|
559
|
-
if (
|
|
560
|
+
if (errorSchemaRef.current) {
|
|
560
561
|
newErrorSchema = {};
|
|
561
|
-
for (const idx
|
|
562
|
-
const i = parseInt(idx);
|
|
562
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
563
|
+
const i = parseInt(idx, 10);
|
|
563
564
|
if (i < index) {
|
|
564
|
-
set(newErrorSchema, [i],
|
|
565
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
565
566
|
}
|
|
566
567
|
else if (i > index) {
|
|
567
|
-
set(newErrorSchema, [i - 1],
|
|
568
|
+
set(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
571
|
}
|
|
571
|
-
const newKeyedFormData =
|
|
572
|
+
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
572
573
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
573
|
-
}, [
|
|
574
|
+
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
574
575
|
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
575
576
|
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
576
577
|
* plain form data converted from the keyed data
|
|
@@ -584,32 +585,30 @@ export default function ArrayField(props) {
|
|
|
584
585
|
event.currentTarget.blur();
|
|
585
586
|
}
|
|
586
587
|
let newErrorSchema;
|
|
587
|
-
if (
|
|
588
|
+
if (errorSchemaRef.current) {
|
|
588
589
|
newErrorSchema = {};
|
|
589
|
-
for (const idx
|
|
590
|
-
const i = parseInt(idx);
|
|
591
|
-
if (i
|
|
592
|
-
set(newErrorSchema, [newIndex],
|
|
590
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
591
|
+
const i = parseInt(idx, 10);
|
|
592
|
+
if (i === index) {
|
|
593
|
+
set(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
|
|
593
594
|
}
|
|
594
|
-
else if (i
|
|
595
|
-
set(newErrorSchema, [index],
|
|
595
|
+
else if (i === newIndex) {
|
|
596
|
+
set(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
|
|
596
597
|
}
|
|
597
598
|
else {
|
|
598
|
-
set(newErrorSchema, [idx],
|
|
599
|
+
set(newErrorSchema, [idx], errorSchemaRef.current[i]);
|
|
599
600
|
}
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
603
|
function reOrderArray() {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
608
|
-
return _newKeyedFormData;
|
|
604
|
+
const newKeyedFormData = keyedFormDataRef.current.slice();
|
|
605
|
+
newKeyedFormData.splice(index, 1);
|
|
606
|
+
newKeyedFormData.splice(newIndex, 0, keyedFormDataRef.current[index]);
|
|
607
|
+
return newKeyedFormData;
|
|
609
608
|
}
|
|
610
609
|
const newKeyedFormData = reOrderArray();
|
|
611
610
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
612
|
-
}, [
|
|
611
|
+
}, [onChange, updateKeyedFormData, childFieldPathId]);
|
|
613
612
|
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
614
613
|
* `onChange` callback with the updated form data
|
|
615
614
|
*
|
|
@@ -631,7 +630,7 @@ export default function ArrayField(props) {
|
|
|
631
630
|
...props,
|
|
632
631
|
formData,
|
|
633
632
|
fieldPathId: childFieldPathId,
|
|
634
|
-
onSelectChange
|
|
633
|
+
onSelectChange,
|
|
635
634
|
};
|
|
636
635
|
const arrayProps = {
|
|
637
636
|
...props,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
3
3
|
* two boolean values based on the various alternatives in the schema.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/BooleanField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"BooleanField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/BooleanField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAGf,UAAU,EACV,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAIrB;;;;GAIG;AACH,iBAAS,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EACrG,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CAkG3B;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { getWidget, getUiOptions, optionsList, TranslatableString
|
|
3
|
+
import { getWidget, getUiOptions, optionsList, TranslatableString } from '@rjsf/utils';
|
|
4
4
|
import isObject from 'lodash-es/isObject.js';
|
|
5
5
|
/** The `BooleanField` component is used to render a field in the schema is boolean. It constructs `enumOptions` for the
|
|
6
6
|
* two boolean values based on the various alternatives in the schema.
|
|
@@ -52,10 +52,7 @@ function BooleanField(props) {
|
|
|
52
52
|
enumOptions = optionsList({ enum: enums }, uiSchema);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const onWidgetChange = useCallback((value, errorSchema, id) =>
|
|
56
|
-
// Boolean field change passes an empty path array to the parent field which adds the appropriate path
|
|
57
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
58
|
-
}, [onChange, fieldPathId]);
|
|
55
|
+
const onWidgetChange = useCallback((value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id), [onChange, fieldPathId]);
|
|
59
56
|
return (_jsx(Widget, { options: { ...options, enumOptions }, schema: schema, uiSchema: uiSchema, id: fieldPathId.$id, name: name, onChange: onWidgetChange, onFocus: onFocus, onBlur: onBlur, label: label, hideLabel: !displayLabel, value: formData, required: required, disabled: disabled, readonly: readonly, hideError: hideError, registry: registry, autofocus: autofocus, rawErrors: rawErrors, htmlName: fieldPathId.name }));
|
|
60
57
|
}
|
|
61
58
|
export default BooleanField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FallbackFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FallbackFieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/**
|
|
3
3
|
* The `FallbackField` component is used to render a field for unsupported or unknown schema types. If
|
|
4
4
|
* `useFallbackUiForUnsupportedType` is enabled in the `globalUiOptions`, it provides a type selector
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FallbackField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FallbackField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"FallbackField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/FallbackField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAe,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA4DlH;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA2FnC"}
|
|
@@ -10,7 +10,7 @@ function getFallbackTypeSelectionSchema(title) {
|
|
|
10
10
|
type: 'string',
|
|
11
11
|
enum: ['string', 'number', 'boolean', 'object', 'array'],
|
|
12
12
|
default: 'string',
|
|
13
|
-
title
|
|
13
|
+
title,
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -39,7 +39,7 @@ function castToNewType(formData, newType) {
|
|
|
39
39
|
return String(formData);
|
|
40
40
|
case 'number': {
|
|
41
41
|
const castedNumber = Number(formData);
|
|
42
|
-
return (isNaN(castedNumber) ? 0 : castedNumber);
|
|
42
|
+
return (Number.isNaN(castedNumber) ? 0 : castedNumber);
|
|
43
43
|
}
|
|
44
44
|
case 'boolean':
|
|
45
45
|
return Boolean(formData);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { FieldProps, FieldPathId, FormContextType, GenericObjectType, RJSFSchema, Registry, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { FieldProps, FieldPathId, FormContextType, GenericObjectType, RJSFSchema, Registry, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
3
3
|
/** The enumeration of the three different Layout GridTemplate type values
|
|
4
4
|
*/
|
|
5
5
|
export declare enum GridType {
|
|
@@ -28,9 +28,7 @@ export interface GridProps extends GenericObjectType {
|
|
|
28
28
|
*/
|
|
29
29
|
value?: unknown;
|
|
30
30
|
}
|
|
31
|
-
export type GridSchemaType =
|
|
32
|
-
[gridType in GridType]?: object;
|
|
33
|
-
};
|
|
31
|
+
export type GridSchemaType = Partial<Record<GridType, object>>;
|
|
34
32
|
/** The types which comprise the possibilities for the `layoutGridSchema` prop
|
|
35
33
|
*/
|
|
36
34
|
export type LayoutGridSchemaType = GridSchemaType | ConfigObject | string;
|
|
@@ -49,14 +47,14 @@ export declare const LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
|
49
47
|
*/
|
|
50
48
|
export declare const LAYOUT_GRID_OPTION = "ui:layoutGrid";
|
|
51
49
|
/** Type used to return options list and whether it has a discriminator */
|
|
52
|
-
|
|
50
|
+
interface OneOfOptionsInfoType<S extends StrictRJSFSchema = RJSFSchema> {
|
|
53
51
|
options: S[];
|
|
54
52
|
hasDiscriminator: boolean;
|
|
55
|
-
}
|
|
53
|
+
}
|
|
56
54
|
/** Type used to represent a React-based rendering component */
|
|
57
55
|
type RenderComponent = ComponentType<any>;
|
|
58
56
|
/** Type used to determine what are the UIComponent and props from the grid schema */
|
|
59
|
-
|
|
57
|
+
interface UIComponentPropsType {
|
|
60
58
|
/** The name of the component */
|
|
61
59
|
name: string;
|
|
62
60
|
/** The render component if specified */
|
|
@@ -65,7 +63,7 @@ type UIComponentPropsType = {
|
|
|
65
63
|
uiProps: ConfigObject;
|
|
66
64
|
/** The special case where the component is immediately rendered */
|
|
67
65
|
rendered: ReactNode;
|
|
68
|
-
}
|
|
66
|
+
}
|
|
69
67
|
/** Computes the uiSchema for the field with `name` from the `uiProps` and `uiSchema` provided. The field UI Schema
|
|
70
68
|
* will always contain a copy of the global options from the `uiSchema` (so they can be passed down) as well as
|
|
71
69
|
* copying them into the local ui options. When the `forceReadonly` flag is true, then the field UI Schema is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutGridField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutGridField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LayoutGridField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutGridField.tsx"],"names":[],"mappings":"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"}
|
|
@@ -176,6 +176,7 @@ export function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
176
176
|
*/
|
|
177
177
|
export function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
178
178
|
let rawSchema;
|
|
179
|
+
let resultPathId = fieldPathId;
|
|
179
180
|
if (isNumericIndex(potentialIndex) && schema && schema?.type === 'array' && has(schema, ITEMS_KEY)) {
|
|
180
181
|
const index = Number(potentialIndex);
|
|
181
182
|
const items = schema[ITEMS_KEY];
|
|
@@ -190,12 +191,12 @@ export function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex
|
|
|
190
191
|
else {
|
|
191
192
|
rawSchema = items;
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
resultPathId = {
|
|
194
195
|
[ID_KEY]: fieldPathId[ID_KEY],
|
|
195
196
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index],
|
|
196
197
|
};
|
|
197
198
|
}
|
|
198
|
-
return { rawSchema, fieldPathId };
|
|
199
|
+
return { rawSchema, fieldPathId: resultPathId };
|
|
199
200
|
}
|
|
200
201
|
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
201
202
|
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
@@ -323,8 +324,8 @@ export function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
323
324
|
if (isString(prop)) {
|
|
324
325
|
const match = LOOKUP_REGEX.exec(prop);
|
|
325
326
|
if (Array.isArray(match) && match.length > 1) {
|
|
326
|
-
const
|
|
327
|
-
uiProps[key] = lookupFromFormContext(registry,
|
|
327
|
+
const lookupName = match[1];
|
|
328
|
+
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
1
|
+
import type { FieldProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
2
2
|
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
3
3
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
4
4
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutHeaderField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutHeaderField.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"LayoutHeaderField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutHeaderField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,gBAAgB,EAAiB,MAAM,aAAa,CAAC;AAG5G;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,kDAwB3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getTemplate, getUiOptions, titleId
|
|
2
|
+
import { getTemplate, getUiOptions, titleId } from '@rjsf/utils';
|
|
3
3
|
/** The `LayoutHeaderField` component renders a `TitleFieldTemplate` with an `id` derived from the `fieldPathId`
|
|
4
4
|
* and whether it is `required` from the props. The `title` is derived from the props as follows:
|
|
5
5
|
* - If there is a title in the `uiSchema`, it is displayed
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnumOptionsType, FieldProps, FormContextType, RJSFSchema, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
1
|
+
import type { EnumOptionsType, FieldProps, FormContextType, RJSFSchema, SchemaUtilsType, StrictRJSFSchema, UiSchema } from '@rjsf/utils';
|
|
2
2
|
/** Gets the selected option from the list of `options`, using the `selectorField` to search inside each `option` for
|
|
3
3
|
* the `properties[selectorField].default(or const)` that matches the given `value`.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"LayoutMultiSchemaField.d.ts","sourceRoot":"","sources":["../../../src/components/fields/LayoutMultiSchemaField.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,aAAa,CAAC;AAuBrB;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC7B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,GACb,CAAC,GAAG,SAAS,CAQf;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,gBAAgB,GAAG,UAAU,EAAE,CAAC,SAAS,eAAe,GAAG,GAAG,EAClH,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,CAAC,EAAE,EACZ,WAAW,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,QAAQ,CAAC,EAAE,CAAC,GACX,eAAe,CAAC,CAAC,CAAC,EAAE,CAatB;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,gBAAgB,GAAG,UAAU,EACvC,CAAC,SAAS,eAAe,GAAG,GAAG,EAC/B,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,2CA0I3B"}
|
|
@@ -69,7 +69,7 @@ export default function LayoutMultiSchemaField(props) {
|
|
|
69
69
|
useEffect(() => {
|
|
70
70
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
71
71
|
// We are using hashes in place of the dependencies
|
|
72
|
-
//
|
|
72
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
73
73
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
74
74
|
const { widget = discriminator ? 'radio' : 'select', title = '', placeholder = '', optionsSchemaSelector: selectorField = discriminator, hideError: uiSchemaHideError, ...uiOptions } = getUiOptions(uiSchema);
|
|
75
75
|
if (!selectorField) {
|
|
@@ -94,6 +94,9 @@ export default function LayoutMultiSchemaField(props) {
|
|
|
94
94
|
* will use it as the index of the new option to select
|
|
95
95
|
*/
|
|
96
96
|
const onOptionChange = (opt) => {
|
|
97
|
+
if (disabled || readonly) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
97
100
|
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
98
101
|
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
99
102
|
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|