@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
package/dist/index.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getChangedFields,
|
|
8
8
|
getTemplate as getTemplate28,
|
|
9
9
|
getUiOptions as getUiOptions21,
|
|
10
|
+
hashObject as hashObject5,
|
|
10
11
|
isObject as isObject6,
|
|
11
12
|
mergeObjects,
|
|
12
13
|
shouldRender as shouldRender2,
|
|
@@ -35,14 +36,10 @@ import _toPath from "lodash/toPath";
|
|
|
35
36
|
import _unset from "lodash/unset";
|
|
36
37
|
|
|
37
38
|
// src/getDefaultRegistry.ts
|
|
38
|
-
import {
|
|
39
|
-
DEFAULT_ID_PREFIX,
|
|
40
|
-
DEFAULT_ID_SEPARATOR,
|
|
41
|
-
englishStringTranslator
|
|
42
|
-
} from "@rjsf/utils";
|
|
39
|
+
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from "@rjsf/utils";
|
|
43
40
|
|
|
44
41
|
// src/components/fields/ArrayField.tsx
|
|
45
|
-
import { useCallback, useMemo, useState } from "react";
|
|
42
|
+
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
46
43
|
import {
|
|
47
44
|
allowAdditionalItems,
|
|
48
45
|
getTemplate,
|
|
@@ -69,12 +66,10 @@ function generateRowId() {
|
|
|
69
66
|
return uniqueId("rjsf-array-item-");
|
|
70
67
|
}
|
|
71
68
|
function generateKeyedFormData(formData) {
|
|
72
|
-
return !Array.isArray(formData) ? [] : formData.map((item) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
});
|
|
69
|
+
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
70
|
+
key: generateRowId(),
|
|
71
|
+
item
|
|
72
|
+
}));
|
|
78
73
|
}
|
|
79
74
|
function keyedToPlainFormData(keyedFormData) {
|
|
80
75
|
if (Array.isArray(keyedFormData)) {
|
|
@@ -275,7 +270,7 @@ function ArrayAsFiles(props) {
|
|
|
275
270
|
}
|
|
276
271
|
);
|
|
277
272
|
}
|
|
278
|
-
function
|
|
273
|
+
function ArrayFieldItemInner(props) {
|
|
279
274
|
const {
|
|
280
275
|
itemKey,
|
|
281
276
|
index,
|
|
@@ -290,10 +285,10 @@ function ArrayFieldItem(props) {
|
|
|
290
285
|
canRemove = true,
|
|
291
286
|
canMoveUp,
|
|
292
287
|
canMoveDown,
|
|
293
|
-
|
|
288
|
+
rawItemSchema,
|
|
294
289
|
itemData,
|
|
295
290
|
itemUiSchema,
|
|
296
|
-
|
|
291
|
+
parentFieldPathId,
|
|
297
292
|
itemErrorSchema,
|
|
298
293
|
autofocus,
|
|
299
294
|
onBlur,
|
|
@@ -310,9 +305,17 @@ function ArrayFieldItem(props) {
|
|
|
310
305
|
const {
|
|
311
306
|
schemaUtils,
|
|
312
307
|
fields: { ArraySchemaField, SchemaField: SchemaField2 },
|
|
313
|
-
globalUiOptions
|
|
308
|
+
globalUiOptions,
|
|
309
|
+
globalFormOptions
|
|
314
310
|
} = registry;
|
|
315
|
-
const
|
|
311
|
+
const itemSchema = useMemo(
|
|
312
|
+
() => schemaUtils.retrieveSchema(rawItemSchema, itemData),
|
|
313
|
+
[schemaUtils, rawItemSchema, itemData]
|
|
314
|
+
);
|
|
315
|
+
const fieldPathId = useMemo(
|
|
316
|
+
() => toFieldPathId(index, globalFormOptions, parentFieldPathId),
|
|
317
|
+
[index, globalFormOptions, parentFieldPathId]
|
|
318
|
+
);
|
|
316
319
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
317
320
|
const ArrayFieldItemTemplate2 = getTemplate(
|
|
318
321
|
"ArrayFieldItemTemplate",
|
|
@@ -421,6 +424,7 @@ function ArrayFieldItem(props) {
|
|
|
421
424
|
};
|
|
422
425
|
return /* @__PURE__ */ jsx(ArrayFieldItemTemplate2, { ...templateProps });
|
|
423
426
|
}
|
|
427
|
+
var ArrayFieldItem = memo(ArrayFieldItemInner);
|
|
424
428
|
function NormalArray(props) {
|
|
425
429
|
const {
|
|
426
430
|
schema,
|
|
@@ -447,15 +451,18 @@ function NormalArray(props) {
|
|
|
447
451
|
handleReorderItems
|
|
448
452
|
} = props;
|
|
449
453
|
const fieldTitle = schema.title || title || name;
|
|
450
|
-
const { schemaUtils, fields: fields2, formContext,
|
|
454
|
+
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
451
455
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
452
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
453
|
-
const
|
|
454
|
-
const itemsSchema = schemaUtils.retrieveSchema(
|
|
455
|
-
const formData = keyedToPlainFormData(keyedFormData);
|
|
456
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
457
|
+
const schemaItems = useMemo(() => isObject(schema.items) ? schema.items : {}, [schema.items]);
|
|
458
|
+
const itemsSchema = useMemo(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
459
|
+
const formData = useMemo(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
456
460
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
457
461
|
const hasFormData = isFormDataAvailable(formDataFromProps);
|
|
458
|
-
const canAdd =
|
|
462
|
+
const canAdd = useMemo(
|
|
463
|
+
() => canAddItem(registry, schema, formData, uiSchema) && (!renderOptionalField || hasFormData),
|
|
464
|
+
[registry, schema, formData, uiSchema, renderOptionalField, hasFormData]
|
|
465
|
+
);
|
|
459
466
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
460
467
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
461
468
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
@@ -465,9 +472,7 @@ function NormalArray(props) {
|
|
|
465
472
|
items: actualFormData.map((keyedItem, index) => {
|
|
466
473
|
const { key, item } = keyedItem;
|
|
467
474
|
const itemCast = item;
|
|
468
|
-
const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
|
|
469
475
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
470
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
471
476
|
const itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
472
477
|
const itemProps = {
|
|
473
478
|
itemKey: key,
|
|
@@ -484,8 +489,8 @@ function NormalArray(props) {
|
|
|
484
489
|
canAdd,
|
|
485
490
|
canMoveUp: index > 0,
|
|
486
491
|
canMoveDown: index < formData.length - 1,
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
rawItemSchema: schemaItems,
|
|
493
|
+
parentFieldPathId: childFieldPathId,
|
|
489
494
|
itemErrorSchema,
|
|
490
495
|
itemData: itemCast,
|
|
491
496
|
itemUiSchema,
|
|
@@ -546,24 +551,24 @@ function FixedArray(props) {
|
|
|
546
551
|
} = props;
|
|
547
552
|
let { formData: items = [] } = props;
|
|
548
553
|
const fieldTitle = schema.title || title || name;
|
|
549
|
-
const {
|
|
550
|
-
const uiOptions = getUiOptions(uiSchema, globalUiOptions);
|
|
554
|
+
const { fields: fields2, formContext, globalUiOptions } = registry;
|
|
555
|
+
const uiOptions = useMemo(() => getUiOptions(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
551
556
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
552
557
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
553
558
|
const hasFormData = isFormDataAvailable(formData);
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
|
|
559
|
+
const schemaItems = useMemo(
|
|
560
|
+
() => isObject(schema.items) ? schema.items : [],
|
|
561
|
+
[schema.items]
|
|
557
562
|
);
|
|
558
|
-
const
|
|
563
|
+
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
559
564
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
560
|
-
if (items.length <
|
|
561
|
-
items = items.concat(new Array(
|
|
565
|
+
if (items.length < schemaItems.length) {
|
|
566
|
+
items = items.concat(new Array(schemaItems.length - items.length));
|
|
562
567
|
}
|
|
563
568
|
const actualFormData = hasFormData ? keyedFormData : [];
|
|
564
569
|
const extraClass = renderOptionalField ? " rjsf-optional-array-field" : "";
|
|
565
570
|
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ jsx(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId }) : void 0;
|
|
566
|
-
const canAdd = canAddItem(registry, schema, items, uiSchema) &&
|
|
571
|
+
const canAdd = canAddItem(registry, schema, items, uiSchema) && hasAdditionalItems && (!renderOptionalField || hasFormData);
|
|
567
572
|
const arrayProps = {
|
|
568
573
|
canAdd,
|
|
569
574
|
className: `rjsf-field rjsf-field-array rjsf-field-array-fixed-items${extraClass}`,
|
|
@@ -573,18 +578,15 @@ function FixedArray(props) {
|
|
|
573
578
|
items: actualFormData.map((keyedItem, index) => {
|
|
574
579
|
const { key, item } = keyedItem;
|
|
575
580
|
const itemCast = item;
|
|
576
|
-
const additional = index >=
|
|
577
|
-
const
|
|
578
|
-
const itemFieldPathId = toFieldPathId(index, globalFormOptions, childFieldPathId);
|
|
581
|
+
const additional = index >= schemaItems.length;
|
|
582
|
+
const rawItemSchema = (additional && isObject(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
|
|
579
583
|
let itemUiSchema;
|
|
580
584
|
if (additional) {
|
|
581
585
|
itemUiSchema = uiSchema.additionalItems;
|
|
586
|
+
} else if (Array.isArray(uiSchema.items)) {
|
|
587
|
+
itemUiSchema = uiSchema.items[index];
|
|
582
588
|
} else {
|
|
583
|
-
|
|
584
|
-
itemUiSchema = uiSchema.items[index];
|
|
585
|
-
} else {
|
|
586
|
-
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
587
|
-
}
|
|
589
|
+
itemUiSchema = computeItemUiSchema(uiSchema, item, index, formContext);
|
|
588
590
|
}
|
|
589
591
|
const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
|
|
590
592
|
const itemProps = {
|
|
@@ -601,12 +603,12 @@ function FixedArray(props) {
|
|
|
601
603
|
title: fieldTitle ? `${fieldTitle}-${index + 1}` : void 0,
|
|
602
604
|
canAdd,
|
|
603
605
|
canRemove: additional,
|
|
604
|
-
canMoveUp: index >=
|
|
606
|
+
canMoveUp: index >= schemaItems.length + 1,
|
|
605
607
|
canMoveDown: additional && index < items.length - 1,
|
|
606
|
-
|
|
608
|
+
rawItemSchema,
|
|
607
609
|
itemData: itemCast,
|
|
608
610
|
itemUiSchema,
|
|
609
|
-
|
|
611
|
+
parentFieldPathId: childFieldPathId,
|
|
610
612
|
itemErrorSchema,
|
|
611
613
|
autofocus: autofocus && index === 0,
|
|
612
614
|
onBlur,
|
|
@@ -654,8 +656,8 @@ function useKeyedFormData(formData = []) {
|
|
|
654
656
|
}
|
|
655
657
|
const updateKeyedFormData = useCallback((newData) => {
|
|
656
658
|
const plainFormData = keyedToPlainFormData(newData);
|
|
657
|
-
const
|
|
658
|
-
setState({ formDataHash:
|
|
659
|
+
const updatedHash = hashObject(plainFormData);
|
|
660
|
+
setState({ formDataHash: updatedHash, keyedFormData: newData });
|
|
659
661
|
return plainFormData;
|
|
660
662
|
}, []);
|
|
661
663
|
return { keyedFormData, updateKeyedFormData };
|
|
@@ -664,6 +666,10 @@ function ArrayField(props) {
|
|
|
664
666
|
const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
|
|
665
667
|
const { globalFormOptions, schemaUtils, translateString } = registry;
|
|
666
668
|
const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
|
|
669
|
+
const keyedFormDataRef = useRef(keyedFormData);
|
|
670
|
+
keyedFormDataRef.current = keyedFormData;
|
|
671
|
+
const errorSchemaRef = useRef(errorSchema);
|
|
672
|
+
errorSchemaRef.current = errorSchema;
|
|
667
673
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
668
674
|
const handleAddItem = useCallback(
|
|
669
675
|
(event, index) => {
|
|
@@ -671,14 +677,14 @@ function ArrayField(props) {
|
|
|
671
677
|
event.preventDefault();
|
|
672
678
|
}
|
|
673
679
|
let newErrorSchema;
|
|
674
|
-
if (
|
|
680
|
+
if (errorSchemaRef.current) {
|
|
675
681
|
newErrorSchema = {};
|
|
676
|
-
for (const idx
|
|
677
|
-
const i = parseInt(idx);
|
|
682
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
683
|
+
const i = parseInt(idx, 10);
|
|
678
684
|
if (index === void 0 || i < index) {
|
|
679
|
-
set(newErrorSchema, [i],
|
|
685
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
680
686
|
} else if (i >= index) {
|
|
681
|
-
set(newErrorSchema, [i + 1],
|
|
687
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
682
688
|
}
|
|
683
689
|
}
|
|
684
690
|
}
|
|
@@ -686,7 +692,7 @@ function ArrayField(props) {
|
|
|
686
692
|
key: generateRowId(),
|
|
687
693
|
item: getNewFormDataRow(registry, schema)
|
|
688
694
|
};
|
|
689
|
-
const newKeyedFormData = [...
|
|
695
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
690
696
|
if (index !== void 0) {
|
|
691
697
|
newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
|
|
692
698
|
} else {
|
|
@@ -694,7 +700,7 @@ function ArrayField(props) {
|
|
|
694
700
|
}
|
|
695
701
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
696
702
|
},
|
|
697
|
-
[
|
|
703
|
+
[registry, schema, onChange, updateKeyedFormData, childFieldPathId]
|
|
698
704
|
);
|
|
699
705
|
const handleCopyItem = useCallback(
|
|
700
706
|
(event, index) => {
|
|
@@ -702,22 +708,22 @@ function ArrayField(props) {
|
|
|
702
708
|
event.preventDefault();
|
|
703
709
|
}
|
|
704
710
|
let newErrorSchema;
|
|
705
|
-
if (
|
|
711
|
+
if (errorSchemaRef.current) {
|
|
706
712
|
newErrorSchema = {};
|
|
707
|
-
for (const idx
|
|
708
|
-
const i = parseInt(idx);
|
|
713
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
714
|
+
const i = parseInt(idx, 10);
|
|
709
715
|
if (i <= index) {
|
|
710
|
-
set(newErrorSchema, [i],
|
|
716
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
711
717
|
} else if (i > index) {
|
|
712
|
-
set(newErrorSchema, [i + 1],
|
|
718
|
+
set(newErrorSchema, [i + 1], errorSchemaRef.current[i]);
|
|
713
719
|
}
|
|
714
720
|
}
|
|
715
721
|
}
|
|
716
722
|
const newKeyedFormDataRow = {
|
|
717
723
|
key: generateRowId(),
|
|
718
|
-
item: cloneDeep(
|
|
724
|
+
item: cloneDeep(keyedFormDataRef.current[index].item)
|
|
719
725
|
};
|
|
720
|
-
const newKeyedFormData = [...
|
|
726
|
+
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
721
727
|
if (index !== void 0) {
|
|
722
728
|
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
723
729
|
} else {
|
|
@@ -725,7 +731,7 @@ function ArrayField(props) {
|
|
|
725
731
|
}
|
|
726
732
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
727
733
|
},
|
|
728
|
-
[
|
|
734
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
729
735
|
);
|
|
730
736
|
const handleRemoveItem = useCallback(
|
|
731
737
|
(event, index) => {
|
|
@@ -733,21 +739,21 @@ function ArrayField(props) {
|
|
|
733
739
|
event.preventDefault();
|
|
734
740
|
}
|
|
735
741
|
let newErrorSchema;
|
|
736
|
-
if (
|
|
742
|
+
if (errorSchemaRef.current) {
|
|
737
743
|
newErrorSchema = {};
|
|
738
|
-
for (const idx
|
|
739
|
-
const i = parseInt(idx);
|
|
744
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
745
|
+
const i = parseInt(idx, 10);
|
|
740
746
|
if (i < index) {
|
|
741
|
-
set(newErrorSchema, [i],
|
|
747
|
+
set(newErrorSchema, [i], errorSchemaRef.current[i]);
|
|
742
748
|
} else if (i > index) {
|
|
743
|
-
set(newErrorSchema, [i - 1],
|
|
749
|
+
set(newErrorSchema, [i - 1], errorSchemaRef.current[i]);
|
|
744
750
|
}
|
|
745
751
|
}
|
|
746
752
|
}
|
|
747
|
-
const newKeyedFormData =
|
|
753
|
+
const newKeyedFormData = keyedFormDataRef.current.filter((_, i) => i !== index);
|
|
748
754
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
749
755
|
},
|
|
750
|
-
[
|
|
756
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
751
757
|
);
|
|
752
758
|
const handleReorderItems = useCallback(
|
|
753
759
|
(event, index, newIndex) => {
|
|
@@ -756,29 +762,29 @@ function ArrayField(props) {
|
|
|
756
762
|
event.currentTarget.blur();
|
|
757
763
|
}
|
|
758
764
|
let newErrorSchema;
|
|
759
|
-
if (
|
|
765
|
+
if (errorSchemaRef.current) {
|
|
760
766
|
newErrorSchema = {};
|
|
761
|
-
for (const idx
|
|
762
|
-
const i = parseInt(idx);
|
|
763
|
-
if (i
|
|
764
|
-
set(newErrorSchema, [newIndex],
|
|
765
|
-
} else if (i
|
|
766
|
-
set(newErrorSchema, [index],
|
|
767
|
+
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
768
|
+
const i = parseInt(idx, 10);
|
|
769
|
+
if (i === index) {
|
|
770
|
+
set(newErrorSchema, [newIndex], errorSchemaRef.current[index]);
|
|
771
|
+
} else if (i === newIndex) {
|
|
772
|
+
set(newErrorSchema, [index], errorSchemaRef.current[newIndex]);
|
|
767
773
|
} else {
|
|
768
|
-
set(newErrorSchema, [idx],
|
|
774
|
+
set(newErrorSchema, [idx], errorSchemaRef.current[i]);
|
|
769
775
|
}
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
778
|
function reOrderArray() {
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
return
|
|
779
|
+
const newKeyedFormData2 = keyedFormDataRef.current.slice();
|
|
780
|
+
newKeyedFormData2.splice(index, 1);
|
|
781
|
+
newKeyedFormData2.splice(newIndex, 0, keyedFormDataRef.current[index]);
|
|
782
|
+
return newKeyedFormData2;
|
|
777
783
|
}
|
|
778
784
|
const newKeyedFormData = reOrderArray();
|
|
779
785
|
onChange(updateKeyedFormData(newKeyedFormData), childFieldPathId.path, newErrorSchema);
|
|
780
786
|
},
|
|
781
|
-
[
|
|
787
|
+
[onChange, updateKeyedFormData, childFieldPathId]
|
|
782
788
|
);
|
|
783
789
|
const handleChange = useCallback(
|
|
784
790
|
(value, path, newErrorSchema, id) => {
|
|
@@ -855,12 +861,7 @@ function ArrayField(props) {
|
|
|
855
861
|
|
|
856
862
|
// src/components/fields/BooleanField.tsx
|
|
857
863
|
import { useCallback as useCallback2 } from "react";
|
|
858
|
-
import {
|
|
859
|
-
getWidget as getWidget2,
|
|
860
|
-
getUiOptions as getUiOptions2,
|
|
861
|
-
optionsList as optionsList2,
|
|
862
|
-
TranslatableString as TranslatableString2
|
|
863
|
-
} from "@rjsf/utils";
|
|
864
|
+
import { getWidget as getWidget2, getUiOptions as getUiOptions2, optionsList as optionsList2, TranslatableString as TranslatableString2 } from "@rjsf/utils";
|
|
864
865
|
import isObject2 from "lodash/isObject";
|
|
865
866
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
866
867
|
function BooleanField(props) {
|
|
@@ -931,9 +932,7 @@ function BooleanField(props) {
|
|
|
931
932
|
}
|
|
932
933
|
}
|
|
933
934
|
const onWidgetChange = useCallback2(
|
|
934
|
-
(value, errorSchema, id) =>
|
|
935
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
936
|
-
},
|
|
935
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
937
936
|
[onChange, fieldPathId]
|
|
938
937
|
);
|
|
939
938
|
return /* @__PURE__ */ jsx2(
|
|
@@ -998,7 +997,7 @@ function castToNewType(formData, newType) {
|
|
|
998
997
|
return String(formData);
|
|
999
998
|
case "number": {
|
|
1000
999
|
const castedNumber = Number(formData);
|
|
1001
|
-
return isNaN(castedNumber) ? 0 : castedNumber;
|
|
1000
|
+
return Number.isNaN(castedNumber) ? 0 : castedNumber;
|
|
1002
1001
|
}
|
|
1003
1002
|
case "boolean":
|
|
1004
1003
|
return Boolean(formData);
|
|
@@ -1194,6 +1193,7 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1194
1193
|
}
|
|
1195
1194
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1196
1195
|
let rawSchema;
|
|
1196
|
+
let resultPathId = fieldPathId;
|
|
1197
1197
|
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && has(schema, ITEMS_KEY2)) {
|
|
1198
1198
|
const index = Number(potentialIndex);
|
|
1199
1199
|
const items = schema[ITEMS_KEY2];
|
|
@@ -1206,12 +1206,12 @@ function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
|
1206
1206
|
} else {
|
|
1207
1207
|
rawSchema = items;
|
|
1208
1208
|
}
|
|
1209
|
-
|
|
1209
|
+
resultPathId = {
|
|
1210
1210
|
[ID_KEY2]: fieldPathId[ID_KEY2],
|
|
1211
1211
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1212
1212
|
};
|
|
1213
1213
|
}
|
|
1214
|
-
return { rawSchema, fieldPathId };
|
|
1214
|
+
return { rawSchema, fieldPathId: resultPathId };
|
|
1215
1215
|
}
|
|
1216
1216
|
function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData, initialFieldIdPath) {
|
|
1217
1217
|
const { schemaUtils, globalFormOptions } = registry;
|
|
@@ -1294,8 +1294,8 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1294
1294
|
if (isString(prop)) {
|
|
1295
1295
|
const match = LOOKUP_REGEX.exec(prop);
|
|
1296
1296
|
if (Array.isArray(match) && match.length > 1) {
|
|
1297
|
-
const
|
|
1298
|
-
uiProps[key] = lookupFromFormContext(registry,
|
|
1297
|
+
const lookupName = match[1];
|
|
1298
|
+
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
1301
1301
|
});
|
|
@@ -1399,10 +1399,10 @@ function LayoutGridFieldComponent(props) {
|
|
|
1399
1399
|
return uiComponentProps.rendered;
|
|
1400
1400
|
}
|
|
1401
1401
|
if (schema) {
|
|
1402
|
-
const
|
|
1402
|
+
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1403
1403
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1404
1404
|
return /* @__PURE__ */ jsx4(
|
|
1405
|
-
|
|
1405
|
+
Field,
|
|
1406
1406
|
{
|
|
1407
1407
|
"data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
|
|
1408
1408
|
...otherProps,
|
|
@@ -1471,11 +1471,7 @@ function LayoutGridField(props) {
|
|
|
1471
1471
|
LayoutGridField.TEST_IDS = LAYOUT_GRID_FIELD_TEST_IDS;
|
|
1472
1472
|
|
|
1473
1473
|
// src/components/fields/LayoutHeaderField.tsx
|
|
1474
|
-
import {
|
|
1475
|
-
getTemplate as getTemplate4,
|
|
1476
|
-
getUiOptions as getUiOptions5,
|
|
1477
|
-
titleId
|
|
1478
|
-
} from "@rjsf/utils";
|
|
1474
|
+
import { getTemplate as getTemplate4, getUiOptions as getUiOptions5, titleId } from "@rjsf/utils";
|
|
1479
1475
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1480
1476
|
function LayoutHeaderField(props) {
|
|
1481
1477
|
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
@@ -1605,6 +1601,9 @@ function LayoutMultiSchemaField(props) {
|
|
|
1605
1601
|
const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
|
|
1606
1602
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1607
1603
|
const onOptionChange = (opt) => {
|
|
1604
|
+
if (disabled || readonly) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1608
1607
|
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
1609
1608
|
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1610
1609
|
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
@@ -1688,6 +1687,12 @@ import isEmpty3 from "lodash/isEmpty";
|
|
|
1688
1687
|
import omit2 from "lodash/omit";
|
|
1689
1688
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1690
1689
|
var AnyOfField = class extends Component {
|
|
1690
|
+
/** Flag to skip the formData-change-driven option recalculation when the user just selected an option.
|
|
1691
|
+
* Set to true in the setState callback of onOptionChange (after onChange is called), consumed and reset in
|
|
1692
|
+
* componentDidUpdate. This prevents the matching-option recalculation from overriding a user's explicit choice
|
|
1693
|
+
* when getDefaultFormState populates undefined properties that make deepEquals see a false formData change.
|
|
1694
|
+
*/
|
|
1695
|
+
skipNextOptionRecalculation = false;
|
|
1691
1696
|
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1692
1697
|
*
|
|
1693
1698
|
* @param props - The `FieldProps` for this template
|
|
@@ -1723,10 +1728,14 @@ var AnyOfField = class extends Component {
|
|
|
1723
1728
|
newState = { selectedOption, retrievedOptions };
|
|
1724
1729
|
}
|
|
1725
1730
|
if (!deepEquals(formData, prevProps.formData) && fieldPathId.$id === prevProps.fieldPathId.$id) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1731
|
+
if (this.skipNextOptionRecalculation) {
|
|
1732
|
+
this.skipNextOptionRecalculation = false;
|
|
1733
|
+
} else {
|
|
1734
|
+
const { retrievedOptions } = newState;
|
|
1735
|
+
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1736
|
+
if (prevState && matchingOption !== selectedOption) {
|
|
1737
|
+
newState = { selectedOption: matchingOption, retrievedOptions };
|
|
1738
|
+
}
|
|
1730
1739
|
}
|
|
1731
1740
|
}
|
|
1732
1741
|
if (newState !== this.state) {
|
|
@@ -1756,7 +1765,10 @@ var AnyOfField = class extends Component {
|
|
|
1756
1765
|
*/
|
|
1757
1766
|
onOptionChange = (option) => {
|
|
1758
1767
|
const { selectedOption, retrievedOptions } = this.state;
|
|
1759
|
-
const { formData, onChange, registry, fieldPathId } = this.props;
|
|
1768
|
+
const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
|
|
1769
|
+
if (disabled || readonly) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1760
1772
|
const { schemaUtils } = registry;
|
|
1761
1773
|
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1762
1774
|
if (intOption === selectedOption) {
|
|
@@ -1769,6 +1781,7 @@ var AnyOfField = class extends Component {
|
|
|
1769
1781
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1770
1782
|
}
|
|
1771
1783
|
this.setState({ selectedOption: intOption }, () => {
|
|
1784
|
+
this.skipNextOptionRecalculation = true;
|
|
1772
1785
|
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1773
1786
|
});
|
|
1774
1787
|
};
|
|
@@ -1793,7 +1806,7 @@ var AnyOfField = class extends Component {
|
|
|
1793
1806
|
uiSchema
|
|
1794
1807
|
} = this.props;
|
|
1795
1808
|
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1796
|
-
const { SchemaField:
|
|
1809
|
+
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1797
1810
|
const MultiSchemaFieldTemplate2 = getTemplate6(
|
|
1798
1811
|
"MultiSchemaFieldTemplate",
|
|
1799
1812
|
registry,
|
|
@@ -1817,8 +1830,8 @@ var AnyOfField = class extends Component {
|
|
|
1817
1830
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1818
1831
|
let optionSchema;
|
|
1819
1832
|
if (option) {
|
|
1820
|
-
const { required:
|
|
1821
|
-
optionSchema =
|
|
1833
|
+
const { required: schemaRequired } = schema;
|
|
1834
|
+
optionSchema = schemaRequired ? mergeSchemas({ required: schemaRequired }, option) : option;
|
|
1822
1835
|
}
|
|
1823
1836
|
let optionsUiSchema = [];
|
|
1824
1837
|
if (ONE_OF_KEY3 in schema && uiSchema && ONE_OF_KEY3 in uiSchema) {
|
|
@@ -1871,7 +1884,7 @@ var AnyOfField = class extends Component {
|
|
|
1871
1884
|
readonly
|
|
1872
1885
|
}
|
|
1873
1886
|
) : void 0;
|
|
1874
|
-
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx7(
|
|
1887
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ jsx7(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1875
1888
|
return /* @__PURE__ */ jsx7(
|
|
1876
1889
|
MultiSchemaFieldTemplate2,
|
|
1877
1890
|
{
|
|
@@ -1901,9 +1914,7 @@ var NullField_default = NullField;
|
|
|
1901
1914
|
|
|
1902
1915
|
// src/components/fields/NumberField.tsx
|
|
1903
1916
|
import { useState as useState4, useCallback as useCallback3 } from "react";
|
|
1904
|
-
import {
|
|
1905
|
-
asNumber
|
|
1906
|
-
} from "@rjsf/utils";
|
|
1917
|
+
import { asNumber } from "@rjsf/utils";
|
|
1907
1918
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1908
1919
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1909
1920
|
var trailingCharMatcher = /[0.]0*$/;
|
|
@@ -1913,12 +1924,10 @@ function NumberField(props) {
|
|
|
1913
1924
|
const { StringField: StringField2 } = registry.fields;
|
|
1914
1925
|
let value = formData;
|
|
1915
1926
|
const handleChange = useCallback3(
|
|
1916
|
-
(
|
|
1917
|
-
setLastValue(
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
|
|
1927
|
+
(newValue, path, errorSchema, id) => {
|
|
1928
|
+
setLastValue(newValue);
|
|
1929
|
+
const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
|
|
1930
|
+
const processed = typeof normalizedValue === "string" && normalizedValue.match(trailingCharMatcherWithPrefix) ? asNumber(normalizedValue.replace(trailingCharMatcher, "")) : asNumber(normalizedValue);
|
|
1922
1931
|
onChange(processed, path, errorSchema, id);
|
|
1923
1932
|
},
|
|
1924
1933
|
[onChange]
|
|
@@ -1934,7 +1943,7 @@ function NumberField(props) {
|
|
|
1934
1943
|
var NumberField_default = NumberField;
|
|
1935
1944
|
|
|
1936
1945
|
// src/components/fields/ObjectField.tsx
|
|
1937
|
-
import { useCallback as useCallback4, useRef, useState as useState5 } from "react";
|
|
1946
|
+
import { memo as memo2, useCallback as useCallback4, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
|
|
1938
1947
|
import {
|
|
1939
1948
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1940
1949
|
ANY_OF_KEY as ANY_OF_KEY4,
|
|
@@ -1954,7 +1963,7 @@ import get4 from "lodash/get";
|
|
|
1954
1963
|
import has3 from "lodash/has";
|
|
1955
1964
|
import isObject4 from "lodash/isObject";
|
|
1956
1965
|
import set4 from "lodash/set";
|
|
1957
|
-
import { Markdown } from "markdown-to-jsx";
|
|
1966
|
+
import { Markdown } from "markdown-to-jsx/react";
|
|
1958
1967
|
|
|
1959
1968
|
// src/components/constants.ts
|
|
1960
1969
|
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
@@ -1963,7 +1972,7 @@ var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
|
1963
1972
|
// src/components/fields/ObjectField.tsx
|
|
1964
1973
|
import { jsx as jsx9, jsxs } from "react/jsx-runtime";
|
|
1965
1974
|
function isRequired(schema, name) {
|
|
1966
|
-
return Array.isArray(schema.required) && schema.required.
|
|
1975
|
+
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
1967
1976
|
}
|
|
1968
1977
|
function getDefaultValue(translateString, type) {
|
|
1969
1978
|
switch (type) {
|
|
@@ -1982,7 +1991,7 @@ function getDefaultValue(translateString, type) {
|
|
|
1982
1991
|
return translateString(TranslatableString5.NewStringDefault);
|
|
1983
1992
|
}
|
|
1984
1993
|
}
|
|
1985
|
-
function
|
|
1994
|
+
function ObjectFieldPropertyFn(props) {
|
|
1986
1995
|
const {
|
|
1987
1996
|
fieldPathId,
|
|
1988
1997
|
schema,
|
|
@@ -2010,10 +2019,11 @@ function ObjectFieldProperty(props) {
|
|
|
2010
2019
|
);
|
|
2011
2020
|
const onPropertyChange = useCallback4(
|
|
2012
2021
|
(value, path, newErrorSchema, id) => {
|
|
2022
|
+
let normalizedValue = value;
|
|
2013
2023
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
2014
|
-
|
|
2024
|
+
normalizedValue = "";
|
|
2015
2025
|
}
|
|
2016
|
-
onChange(
|
|
2026
|
+
onChange(normalizedValue, path, newErrorSchema, id);
|
|
2017
2027
|
},
|
|
2018
2028
|
[onChange, addedByAdditionalProperties]
|
|
2019
2029
|
);
|
|
@@ -2062,6 +2072,7 @@ function ObjectFieldProperty(props) {
|
|
|
2062
2072
|
}
|
|
2063
2073
|
);
|
|
2064
2074
|
}
|
|
2075
|
+
var ObjectFieldProperty = memo2(ObjectFieldPropertyFn);
|
|
2065
2076
|
function ObjectField(props) {
|
|
2066
2077
|
const {
|
|
2067
2078
|
schema: rawSchema,
|
|
@@ -2082,25 +2093,29 @@ function ObjectField(props) {
|
|
|
2082
2093
|
} = props;
|
|
2083
2094
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2084
2095
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
2085
|
-
const formDataRef =
|
|
2096
|
+
const formDataRef = useRef2(formData);
|
|
2086
2097
|
formDataRef.current = formData;
|
|
2087
|
-
const schema =
|
|
2088
|
-
|
|
2098
|
+
const schema = useMemo3(
|
|
2099
|
+
() => schemaUtils.retrieveSchema(rawSchema, formData, true),
|
|
2100
|
+
[schemaUtils, rawSchema, formData]
|
|
2101
|
+
);
|
|
2102
|
+
const uiOptions = useMemo3(() => getUiOptions8(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
2089
2103
|
const { properties: schemaProperties = {} } = schema;
|
|
2090
2104
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
2091
|
-
const lastRenamedProperty =
|
|
2105
|
+
const lastRenamedProperty = useRef2({ previousKey: "", currentKey: void 0 });
|
|
2092
2106
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
2093
2107
|
const description = uiOptions.description ?? schema.description;
|
|
2094
2108
|
const renderOptionalField = shouldRenderOptionalField3(registry, schema, required, uiSchema);
|
|
2095
2109
|
const hasFormData = isFormDataAvailable3(formData);
|
|
2096
2110
|
let orderedProperties = [];
|
|
2097
2111
|
const getAvailableKey = useCallback4(
|
|
2098
|
-
(preferredKey,
|
|
2112
|
+
(preferredKey, existingFormData) => {
|
|
2099
2113
|
const { duplicateKeySuffixSeparator = "-" } = getUiOptions8(uiSchema, globalUiOptions);
|
|
2100
2114
|
let index = 0;
|
|
2101
2115
|
let newKey = preferredKey;
|
|
2102
|
-
while (has3(
|
|
2103
|
-
|
|
2116
|
+
while (has3(existingFormData, newKey)) {
|
|
2117
|
+
index += 1;
|
|
2118
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
2104
2119
|
}
|
|
2105
2120
|
return newKey;
|
|
2106
2121
|
},
|
|
@@ -2110,7 +2125,6 @@ function ObjectField(props) {
|
|
|
2110
2125
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2111
2126
|
return;
|
|
2112
2127
|
}
|
|
2113
|
-
const { translateString: translateString2 } = registry;
|
|
2114
2128
|
const newFormData = { ...formData };
|
|
2115
2129
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
2116
2130
|
if (schema.patternProperties) {
|
|
@@ -2125,8 +2139,7 @@ function ObjectField(props) {
|
|
|
2125
2139
|
defaultValue = schema.additionalProperties.default;
|
|
2126
2140
|
let apSchema = schema.additionalProperties;
|
|
2127
2141
|
if (REF_KEY in apSchema) {
|
|
2128
|
-
|
|
2129
|
-
apSchema = schemaUtils2.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
|
|
2142
|
+
apSchema = schemaUtils.retrieveSchema({ [REF_KEY]: apSchema[REF_KEY] }, formData);
|
|
2130
2143
|
type = apSchema.type;
|
|
2131
2144
|
constValue = apSchema.const;
|
|
2132
2145
|
defaultValue = apSchema.default;
|
|
@@ -2135,7 +2148,7 @@ function ObjectField(props) {
|
|
|
2135
2148
|
type = "object";
|
|
2136
2149
|
}
|
|
2137
2150
|
}
|
|
2138
|
-
const newValue = constValue ?? defaultValue ?? getDefaultValue(
|
|
2151
|
+
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
2139
2152
|
set4(newFormData, newKey, newValue);
|
|
2140
2153
|
}
|
|
2141
2154
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
@@ -2143,7 +2156,7 @@ function ObjectField(props) {
|
|
|
2143
2156
|
lastRenamedProperty.current.previousKey = getAvailableKey(newKey, newFormData);
|
|
2144
2157
|
}
|
|
2145
2158
|
onChange(newFormData, childFieldPathId.path);
|
|
2146
|
-
}, [formData, onChange,
|
|
2159
|
+
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
2147
2160
|
const handleKeyRename = useCallback4(
|
|
2148
2161
|
(oldKey, newKey) => {
|
|
2149
2162
|
if (oldKey !== newKey) {
|
|
@@ -2154,8 +2167,8 @@ function ObjectField(props) {
|
|
|
2154
2167
|
};
|
|
2155
2168
|
const newKeys = { [oldKey]: actualNewKey };
|
|
2156
2169
|
const keyValues = Object.keys(newFormData).map((key) => {
|
|
2157
|
-
const
|
|
2158
|
-
return { [
|
|
2170
|
+
const mappedKey = Object.hasOwn(newKeys, key) ? newKeys[key] : key;
|
|
2171
|
+
return { [mappedKey]: newFormData[key] };
|
|
2159
2172
|
});
|
|
2160
2173
|
const renamedObj = Object.assign({}, ...keyValues);
|
|
2161
2174
|
formDataRef.current = renamedObj;
|
|
@@ -2197,20 +2210,20 @@ function ObjectField(props) {
|
|
|
2197
2210
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2198
2211
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
2199
2212
|
description: uiOptions.label === false ? void 0 : description,
|
|
2200
|
-
properties: orderedProperties.map((
|
|
2201
|
-
const addedByAdditionalProperties = has3(schema, [PROPERTIES_KEY3,
|
|
2202
|
-
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[
|
|
2213
|
+
properties: orderedProperties.map((propertyName) => {
|
|
2214
|
+
const addedByAdditionalProperties = has3(schema, [PROPERTIES_KEY3, propertyName, ADDITIONAL_PROPERTY_FLAG]);
|
|
2215
|
+
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
2203
2216
|
const hidden = getUiOptions8(fieldUiSchema).widget === "hidden";
|
|
2204
2217
|
const content = /* @__PURE__ */ jsx9(
|
|
2205
2218
|
ObjectFieldProperty,
|
|
2206
2219
|
{
|
|
2207
|
-
propertyName
|
|
2208
|
-
required: isRequired(schema,
|
|
2209
|
-
schema: get4(schema, [PROPERTIES_KEY3,
|
|
2220
|
+
propertyName,
|
|
2221
|
+
required: isRequired(schema, propertyName),
|
|
2222
|
+
schema: get4(schema, [PROPERTIES_KEY3, propertyName], {}),
|
|
2210
2223
|
uiSchema: fieldUiSchema,
|
|
2211
|
-
errorSchema: get4(errorSchema, [
|
|
2224
|
+
errorSchema: get4(errorSchema, [propertyName]),
|
|
2212
2225
|
fieldPathId: childFieldPathId,
|
|
2213
|
-
formData: get4(formData, [
|
|
2226
|
+
formData: get4(formData, [propertyName]),
|
|
2214
2227
|
handleKeyRename,
|
|
2215
2228
|
handleRemoveProperty,
|
|
2216
2229
|
addedByAdditionalProperties,
|
|
@@ -2222,11 +2235,11 @@ function ObjectField(props) {
|
|
|
2222
2235
|
readonly,
|
|
2223
2236
|
hideError
|
|
2224
2237
|
},
|
|
2225
|
-
getStableKey(
|
|
2238
|
+
getStableKey(propertyName)
|
|
2226
2239
|
);
|
|
2227
2240
|
return {
|
|
2228
2241
|
content,
|
|
2229
|
-
name:
|
|
2242
|
+
name: propertyName,
|
|
2230
2243
|
readonly,
|
|
2231
2244
|
disabled,
|
|
2232
2245
|
required,
|
|
@@ -2348,7 +2361,7 @@ var COMPONENT_TYPES = {
|
|
|
2348
2361
|
null: "NullField"
|
|
2349
2362
|
};
|
|
2350
2363
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
2351
|
-
const field = uiOptions
|
|
2364
|
+
const { field } = uiOptions;
|
|
2352
2365
|
const { fields: fields2 } = registry;
|
|
2353
2366
|
if (typeof field === "function") {
|
|
2354
2367
|
return field;
|
|
@@ -2366,7 +2379,7 @@ function getFieldComponent(schema, uiOptions, registry) {
|
|
|
2366
2379
|
if (!componentName && (schema.anyOf || schema.oneOf)) {
|
|
2367
2380
|
return () => null;
|
|
2368
2381
|
}
|
|
2369
|
-
return componentName in fields2 ? fields2[componentName] : fields2
|
|
2382
|
+
return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
|
|
2370
2383
|
}
|
|
2371
2384
|
function SchemaFieldRender(props) {
|
|
2372
2385
|
const {
|
|
@@ -2399,9 +2412,9 @@ function SchemaFieldRender(props) {
|
|
|
2399
2412
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2400
2413
|
const fieldId = fieldPathId[ID_KEY4];
|
|
2401
2414
|
const handleFieldComponentChange = useCallback5(
|
|
2402
|
-
(
|
|
2415
|
+
(newFormData, path, newErrorSchema, id2) => {
|
|
2403
2416
|
const theId = id2 || fieldId;
|
|
2404
|
-
return onChange(
|
|
2417
|
+
return onChange(newFormData, path, newErrorSchema, theId);
|
|
2405
2418
|
},
|
|
2406
2419
|
[fieldId, onChange]
|
|
2407
2420
|
);
|
|
@@ -2425,12 +2438,12 @@ function SchemaFieldRender(props) {
|
|
|
2425
2438
|
if (schema[ANY_OF_KEY5]) {
|
|
2426
2439
|
XxxOfField = _AnyOfField;
|
|
2427
2440
|
XxxOfOptions = schema[ANY_OF_KEY5].map(
|
|
2428
|
-
(
|
|
2441
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject5(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2429
2442
|
);
|
|
2430
2443
|
} else if (schema[ONE_OF_KEY5]) {
|
|
2431
2444
|
XxxOfField = _OneOfField;
|
|
2432
2445
|
XxxOfOptions = schema[ONE_OF_KEY5].map(
|
|
2433
|
-
(
|
|
2446
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema(isObject5(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2434
2447
|
);
|
|
2435
2448
|
}
|
|
2436
2449
|
const isOptionalRender = shouldRenderOptionalField4(registry, schema, required, uiSchema);
|
|
@@ -2475,7 +2488,7 @@ function SchemaFieldRender(props) {
|
|
|
2475
2488
|
label = registry.translateString(TranslatableString7.DeprecatedLabel, [label]);
|
|
2476
2489
|
}
|
|
2477
2490
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2478
|
-
const help = uiOptions
|
|
2491
|
+
const { help } = uiOptions;
|
|
2479
2492
|
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2480
2493
|
const classNames = ["rjsf-field", `rjsf-field-${getSchemaType2(schema)}`];
|
|
2481
2494
|
if (!hideError && __errors && __errors.length > 0) {
|
|
@@ -2582,12 +2595,7 @@ var SchemaField_default = SchemaField;
|
|
|
2582
2595
|
|
|
2583
2596
|
// src/components/fields/StringField.tsx
|
|
2584
2597
|
import { useCallback as useCallback6 } from "react";
|
|
2585
|
-
import {
|
|
2586
|
-
getWidget as getWidget5,
|
|
2587
|
-
getUiOptions as getUiOptions11,
|
|
2588
|
-
optionsList as optionsList4,
|
|
2589
|
-
hasWidget
|
|
2590
|
-
} from "@rjsf/utils";
|
|
2598
|
+
import { getWidget as getWidget5, getUiOptions as getUiOptions11, optionsList as optionsList4, hasWidget } from "@rjsf/utils";
|
|
2591
2599
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2592
2600
|
function StringField(props) {
|
|
2593
2601
|
const {
|
|
@@ -2620,9 +2628,7 @@ function StringField(props) {
|
|
|
2620
2628
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2621
2629
|
const Widget = getWidget5(schema, widget, widgets2);
|
|
2622
2630
|
const onWidgetChange = useCallback6(
|
|
2623
|
-
(value, errorSchema, id) =>
|
|
2624
|
-
return onChange(value, fieldPathId.path, errorSchema, id);
|
|
2625
|
-
},
|
|
2631
|
+
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
2626
2632
|
[onChange, fieldPathId]
|
|
2627
2633
|
);
|
|
2628
2634
|
return /* @__PURE__ */ jsx12(
|
|
@@ -2676,11 +2682,7 @@ function fields() {
|
|
|
2676
2682
|
var fields_default = fields;
|
|
2677
2683
|
|
|
2678
2684
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
2679
|
-
import {
|
|
2680
|
-
descriptionId as descriptionId2,
|
|
2681
|
-
getTemplate as getTemplate10,
|
|
2682
|
-
getUiOptions as getUiOptions12
|
|
2683
|
-
} from "@rjsf/utils";
|
|
2685
|
+
import { descriptionId as descriptionId2, getTemplate as getTemplate10, getUiOptions as getUiOptions12 } from "@rjsf/utils";
|
|
2684
2686
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2685
2687
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2686
2688
|
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
@@ -2707,9 +2709,7 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2707
2709
|
}
|
|
2708
2710
|
|
|
2709
2711
|
// src/components/templates/ArrayFieldItemButtonsTemplate.tsx
|
|
2710
|
-
import {
|
|
2711
|
-
buttonId
|
|
2712
|
-
} from "@rjsf/utils";
|
|
2712
|
+
import { buttonId } from "@rjsf/utils";
|
|
2713
2713
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2714
2714
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2715
2715
|
const {
|
|
@@ -2777,10 +2777,7 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2777
2777
|
}
|
|
2778
2778
|
|
|
2779
2779
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
2780
|
-
import {
|
|
2781
|
-
getTemplate as getTemplate11,
|
|
2782
|
-
getUiOptions as getUiOptions13
|
|
2783
|
-
} from "@rjsf/utils";
|
|
2780
|
+
import { getTemplate as getTemplate11, getUiOptions as getUiOptions13 } from "@rjsf/utils";
|
|
2784
2781
|
import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2785
2782
|
function ArrayFieldItemTemplate(props) {
|
|
2786
2783
|
const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
|
|
@@ -2806,11 +2803,7 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2806
2803
|
}
|
|
2807
2804
|
|
|
2808
2805
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
2809
|
-
import {
|
|
2810
|
-
getTemplate as getTemplate12,
|
|
2811
|
-
getUiOptions as getUiOptions14,
|
|
2812
|
-
buttonId as buttonId2
|
|
2813
|
-
} from "@rjsf/utils";
|
|
2806
|
+
import { getTemplate as getTemplate12, getUiOptions as getUiOptions14, buttonId as buttonId2 } from "@rjsf/utils";
|
|
2814
2807
|
import { jsx as jsx16, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2815
2808
|
function ArrayFieldTemplate(props) {
|
|
2816
2809
|
const {
|
|
@@ -2883,11 +2876,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2883
2876
|
}
|
|
2884
2877
|
|
|
2885
2878
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
2886
|
-
import {
|
|
2887
|
-
getTemplate as getTemplate13,
|
|
2888
|
-
getUiOptions as getUiOptions15,
|
|
2889
|
-
titleId as titleId2
|
|
2890
|
-
} from "@rjsf/utils";
|
|
2879
|
+
import { getTemplate as getTemplate13, getUiOptions as getUiOptions15, titleId as titleId2 } from "@rjsf/utils";
|
|
2891
2880
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
2892
2881
|
function ArrayFieldTitleTemplate(props) {
|
|
2893
2882
|
const { fieldPathId, title, schema, uiSchema, required, registry, optionalDataControl } = props;
|
|
@@ -2917,11 +2906,7 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2917
2906
|
|
|
2918
2907
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2919
2908
|
import { useCallback as useCallback7 } from "react";
|
|
2920
|
-
import {
|
|
2921
|
-
ariaDescribedByIds,
|
|
2922
|
-
examplesId as examplesId2,
|
|
2923
|
-
getInputProps
|
|
2924
|
-
} from "@rjsf/utils";
|
|
2909
|
+
import { ariaDescribedByIds, examplesId as examplesId2, getInputProps } from "@rjsf/utils";
|
|
2925
2910
|
|
|
2926
2911
|
// src/components/SchemaExamples.tsx
|
|
2927
2912
|
import { examplesId } from "@rjsf/utils";
|
|
@@ -2934,9 +2919,10 @@ function SchemaExamples(props) {
|
|
|
2934
2919
|
}
|
|
2935
2920
|
return /* @__PURE__ */ jsx18("datalist", { id: examplesId(id), children: examples.concat(
|
|
2936
2921
|
schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
|
|
2937
|
-
).map((example) =>
|
|
2938
|
-
|
|
2939
|
-
|
|
2922
|
+
).map((example) => (
|
|
2923
|
+
// oxlint-disable-next-line jsx-a11y/control-has-associated-label
|
|
2924
|
+
/* @__PURE__ */ jsx18("option", { value: example }, String(example))
|
|
2925
|
+
)) }, `datalist_${id}`);
|
|
2940
2926
|
}
|
|
2941
2927
|
|
|
2942
2928
|
// src/components/templates/BaseInputTemplate.tsx
|
|
@@ -2982,19 +2968,19 @@ function BaseInputTemplate(props) {
|
|
|
2982
2968
|
} else {
|
|
2983
2969
|
inputValue = value == null ? "" : value;
|
|
2984
2970
|
}
|
|
2985
|
-
const
|
|
2986
|
-
({ target: { value:
|
|
2971
|
+
const handleChange = useCallback7(
|
|
2972
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
2987
2973
|
[onChange, options]
|
|
2988
2974
|
);
|
|
2989
|
-
const
|
|
2975
|
+
const handleBlur = useCallback7(
|
|
2990
2976
|
({ target }) => onBlur(id, target && target.value),
|
|
2991
2977
|
[onBlur, id]
|
|
2992
2978
|
);
|
|
2993
|
-
const
|
|
2979
|
+
const handleFocus = useCallback7(
|
|
2994
2980
|
({ target }) => onFocus(id, target && target.value),
|
|
2995
2981
|
[onFocus, id]
|
|
2996
2982
|
);
|
|
2997
|
-
const
|
|
2983
|
+
const handleClear = useCallback7(
|
|
2998
2984
|
(e) => {
|
|
2999
2985
|
e.preventDefault();
|
|
3000
2986
|
e.stopPropagation();
|
|
@@ -3015,13 +3001,13 @@ function BaseInputTemplate(props) {
|
|
|
3015
3001
|
value: inputValue,
|
|
3016
3002
|
...inputProps,
|
|
3017
3003
|
list: schema.examples ? examplesId2(id) : void 0,
|
|
3018
|
-
onChange: onChangeOverride ||
|
|
3019
|
-
onBlur:
|
|
3020
|
-
onFocus:
|
|
3004
|
+
onChange: onChangeOverride || handleChange,
|
|
3005
|
+
onBlur: handleBlur,
|
|
3006
|
+
onFocus: handleFocus,
|
|
3021
3007
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
3022
3008
|
}
|
|
3023
3009
|
),
|
|
3024
|
-
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsx19(ClearButton2, { registry, onClick:
|
|
3010
|
+
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ jsx19(ClearButton2, { registry, onClick: handleClear }),
|
|
3025
3011
|
/* @__PURE__ */ jsx19(SchemaExamples, { id, schema })
|
|
3026
3012
|
] });
|
|
3027
3013
|
}
|
|
@@ -3030,37 +3016,44 @@ function BaseInputTemplate(props) {
|
|
|
3030
3016
|
import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
|
|
3031
3017
|
|
|
3032
3018
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
3019
|
+
import { memo as memo3 } from "react";
|
|
3033
3020
|
import { TranslatableString as TranslatableString8 } from "@rjsf/utils";
|
|
3034
3021
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
3035
|
-
function
|
|
3022
|
+
function IconButtonFn(props) {
|
|
3036
3023
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
3037
3024
|
return /* @__PURE__ */ jsx20("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx20("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
3038
3025
|
}
|
|
3039
|
-
|
|
3026
|
+
var IconButton = memo3(IconButtonFn);
|
|
3027
|
+
var IconButton_default = IconButton;
|
|
3028
|
+
function CopyButtonFn(props) {
|
|
3040
3029
|
const {
|
|
3041
3030
|
registry: { translateString }
|
|
3042
3031
|
} = props;
|
|
3043
3032
|
return /* @__PURE__ */ jsx20(IconButton, { title: translateString(TranslatableString8.CopyButton), ...props, icon: "copy" });
|
|
3044
3033
|
}
|
|
3045
|
-
|
|
3034
|
+
var CopyButton = memo3(CopyButtonFn);
|
|
3035
|
+
function MoveDownButtonFn(props) {
|
|
3046
3036
|
const {
|
|
3047
3037
|
registry: { translateString }
|
|
3048
3038
|
} = props;
|
|
3049
3039
|
return /* @__PURE__ */ jsx20(IconButton, { title: translateString(TranslatableString8.MoveDownButton), ...props, icon: "arrow-down" });
|
|
3050
3040
|
}
|
|
3051
|
-
|
|
3041
|
+
var MoveDownButton = memo3(MoveDownButtonFn);
|
|
3042
|
+
function MoveUpButtonFn(props) {
|
|
3052
3043
|
const {
|
|
3053
3044
|
registry: { translateString }
|
|
3054
3045
|
} = props;
|
|
3055
3046
|
return /* @__PURE__ */ jsx20(IconButton, { title: translateString(TranslatableString8.MoveUpButton), ...props, icon: "arrow-up" });
|
|
3056
3047
|
}
|
|
3057
|
-
|
|
3048
|
+
var MoveUpButton = memo3(MoveUpButtonFn);
|
|
3049
|
+
function RemoveButtonFn(props) {
|
|
3058
3050
|
const {
|
|
3059
3051
|
registry: { translateString }
|
|
3060
3052
|
} = props;
|
|
3061
3053
|
return /* @__PURE__ */ jsx20(IconButton, { title: translateString(TranslatableString8.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
3062
3054
|
}
|
|
3063
|
-
|
|
3055
|
+
var RemoveButton = memo3(RemoveButtonFn);
|
|
3056
|
+
function ClearButtonFn({
|
|
3064
3057
|
id,
|
|
3065
3058
|
className,
|
|
3066
3059
|
onClick,
|
|
@@ -3084,6 +3077,7 @@ function ClearButton({
|
|
|
3084
3077
|
}
|
|
3085
3078
|
);
|
|
3086
3079
|
}
|
|
3080
|
+
var ClearButton = memo3(ClearButtonFn);
|
|
3087
3081
|
|
|
3088
3082
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
3089
3083
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
@@ -3100,7 +3094,7 @@ function AddButton({
|
|
|
3100
3094
|
{
|
|
3101
3095
|
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}`,
|
|
3102
3096
|
children: /* @__PURE__ */ jsx21(
|
|
3103
|
-
|
|
3097
|
+
IconButton_default,
|
|
3104
3098
|
{
|
|
3105
3099
|
id,
|
|
3106
3100
|
iconType: "info",
|
|
@@ -3142,10 +3136,7 @@ function buttonTemplates() {
|
|
|
3142
3136
|
var ButtonTemplates_default = buttonTemplates;
|
|
3143
3137
|
|
|
3144
3138
|
// src/components/RichDescription.tsx
|
|
3145
|
-
import {
|
|
3146
|
-
getTestIds as getTestIds2,
|
|
3147
|
-
getUiOptions as getUiOptions16
|
|
3148
|
-
} from "@rjsf/utils";
|
|
3139
|
+
import { getTestIds as getTestIds2, getUiOptions as getUiOptions16 } from "@rjsf/utils";
|
|
3149
3140
|
import { Markdown as Markdown2 } from "markdown-to-jsx/react";
|
|
3150
3141
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
3151
3142
|
var TEST_IDS = getTestIds2();
|
|
@@ -3170,9 +3161,7 @@ function DescriptionField(props) {
|
|
|
3170
3161
|
}
|
|
3171
3162
|
|
|
3172
3163
|
// src/components/templates/ErrorList.tsx
|
|
3173
|
-
import {
|
|
3174
|
-
TranslatableString as TranslatableString10
|
|
3175
|
-
} from "@rjsf/utils";
|
|
3164
|
+
import { TranslatableString as TranslatableString10 } from "@rjsf/utils";
|
|
3176
3165
|
import { jsx as jsx25, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3177
3166
|
function ErrorList({
|
|
3178
3167
|
errors,
|
|
@@ -3181,9 +3170,10 @@ function ErrorList({
|
|
|
3181
3170
|
const { translateString } = registry;
|
|
3182
3171
|
return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
|
|
3183
3172
|
/* @__PURE__ */ jsx25("div", { className: "panel-heading", children: /* @__PURE__ */ jsx25("h3", { className: "panel-title", children: translateString(TranslatableString10.ErrorsLabel) }) }),
|
|
3184
|
-
/* @__PURE__ */ jsx25("ul", { className: "list-group", children: errors.map((error, i) =>
|
|
3185
|
-
|
|
3186
|
-
|
|
3173
|
+
/* @__PURE__ */ jsx25("ul", { className: "list-group", children: errors.map((error, i) => (
|
|
3174
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3175
|
+
/* @__PURE__ */ jsx25("li", { className: "list-group-item text-danger", children: error.stack }, i)
|
|
3176
|
+
)) })
|
|
3187
3177
|
] });
|
|
3188
3178
|
}
|
|
3189
3179
|
|
|
@@ -3216,19 +3206,17 @@ function FieldErrorTemplate(props) {
|
|
|
3216
3206
|
return null;
|
|
3217
3207
|
}
|
|
3218
3208
|
const id = errorId(fieldPathId);
|
|
3219
|
-
return /* @__PURE__ */ jsx27("div", { children: /* @__PURE__ */ jsx27("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) =>
|
|
3220
|
-
|
|
3221
|
-
|
|
3209
|
+
return /* @__PURE__ */ jsx27("div", { children: /* @__PURE__ */ jsx27("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => (
|
|
3210
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3211
|
+
/* @__PURE__ */ jsx27("li", { className: "text-danger", children: error }, index)
|
|
3212
|
+
)) }) });
|
|
3222
3213
|
}
|
|
3223
3214
|
|
|
3224
3215
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3225
3216
|
import { helpId } from "@rjsf/utils";
|
|
3226
3217
|
|
|
3227
3218
|
// src/components/RichHelp.tsx
|
|
3228
|
-
import {
|
|
3229
|
-
getTestIds as getTestIds3,
|
|
3230
|
-
getUiOptions as getUiOptions17
|
|
3231
|
-
} from "@rjsf/utils";
|
|
3219
|
+
import { getTestIds as getTestIds3, getUiOptions as getUiOptions17 } from "@rjsf/utils";
|
|
3232
3220
|
import { Markdown as Markdown3 } from "markdown-to-jsx/react";
|
|
3233
3221
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
3234
3222
|
var TEST_IDS2 = getTestIds3();
|
|
@@ -3257,10 +3245,7 @@ function FieldHelpTemplate(props) {
|
|
|
3257
3245
|
}
|
|
3258
3246
|
|
|
3259
3247
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3260
|
-
import {
|
|
3261
|
-
getTemplate as getTemplate15,
|
|
3262
|
-
getUiOptions as getUiOptions18
|
|
3263
|
-
} from "@rjsf/utils";
|
|
3248
|
+
import { getTemplate as getTemplate15, getUiOptions as getUiOptions18 } from "@rjsf/utils";
|
|
3264
3249
|
|
|
3265
3250
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
3266
3251
|
import { jsx as jsx30, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
@@ -3320,14 +3305,7 @@ function MultiSchemaFieldTemplate(props) {
|
|
|
3320
3305
|
}
|
|
3321
3306
|
|
|
3322
3307
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3323
|
-
import {
|
|
3324
|
-
canExpand,
|
|
3325
|
-
descriptionId as descriptionId3,
|
|
3326
|
-
getTemplate as getTemplate16,
|
|
3327
|
-
getUiOptions as getUiOptions19,
|
|
3328
|
-
titleId as titleId3,
|
|
3329
|
-
buttonId as buttonId3
|
|
3330
|
-
} from "@rjsf/utils";
|
|
3308
|
+
import { canExpand, descriptionId as descriptionId3, getTemplate as getTemplate16, getUiOptions as getUiOptions19, titleId as titleId3, buttonId as buttonId3 } from "@rjsf/utils";
|
|
3331
3309
|
import { jsx as jsx34, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3332
3310
|
function ObjectFieldTemplate(props) {
|
|
3333
3311
|
const {
|
|
@@ -3406,7 +3384,7 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3406
3384
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3407
3385
|
if (onAddClick) {
|
|
3408
3386
|
return /* @__PURE__ */ jsx35(
|
|
3409
|
-
|
|
3387
|
+
IconButton_default,
|
|
3410
3388
|
{
|
|
3411
3389
|
id,
|
|
3412
3390
|
registry,
|
|
@@ -3416,9 +3394,10 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3416
3394
|
title: label
|
|
3417
3395
|
}
|
|
3418
3396
|
);
|
|
3419
|
-
}
|
|
3397
|
+
}
|
|
3398
|
+
if (onRemoveClick) {
|
|
3420
3399
|
return /* @__PURE__ */ jsx35(
|
|
3421
|
-
|
|
3400
|
+
IconButton_default,
|
|
3422
3401
|
{
|
|
3423
3402
|
id,
|
|
3424
3403
|
registry,
|
|
@@ -3446,7 +3425,7 @@ function TitleField(props) {
|
|
|
3446
3425
|
|
|
3447
3426
|
// src/components/templates/UnsupportedField.tsx
|
|
3448
3427
|
import { TranslatableString as TranslatableString11 } from "@rjsf/utils";
|
|
3449
|
-
import { Markdown as Markdown4 } from "markdown-to-jsx";
|
|
3428
|
+
import { Markdown as Markdown4 } from "markdown-to-jsx/react";
|
|
3450
3429
|
import { jsx as jsx37, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3451
3430
|
function UnsupportedField(props) {
|
|
3452
3431
|
const { schema, fieldPathId, reason, registry } = props;
|
|
@@ -3469,11 +3448,7 @@ function UnsupportedField(props) {
|
|
|
3469
3448
|
var UnsupportedField_default = UnsupportedField;
|
|
3470
3449
|
|
|
3471
3450
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
3472
|
-
import {
|
|
3473
|
-
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
|
|
3474
|
-
buttonId as buttonId4,
|
|
3475
|
-
TranslatableString as TranslatableString12
|
|
3476
|
-
} from "@rjsf/utils";
|
|
3451
|
+
import { ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3, buttonId as buttonId4, TranslatableString as TranslatableString12 } from "@rjsf/utils";
|
|
3477
3452
|
import { jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3478
3453
|
function WrapIfAdditionalTemplate(props) {
|
|
3479
3454
|
const {
|
|
@@ -3580,34 +3555,33 @@ function AltDateTimeWidget({
|
|
|
3580
3555
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3581
3556
|
|
|
3582
3557
|
// src/components/widgets/AltDateWidget.tsx
|
|
3583
|
-
import {
|
|
3584
|
-
DateElement,
|
|
3585
|
-
TranslatableString as TranslatableString13,
|
|
3586
|
-
useAltDateWidgetProps
|
|
3587
|
-
} from "@rjsf/utils";
|
|
3558
|
+
import { DateElement, TranslatableString as TranslatableString13, useAltDateWidgetProps } from "@rjsf/utils";
|
|
3588
3559
|
import { jsx as jsx40, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3589
3560
|
function AltDateWidget(props) {
|
|
3590
3561
|
const { disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus } = props;
|
|
3591
3562
|
const { translateString } = registry;
|
|
3592
3563
|
const { elements, handleChange, handleClear, handleSetNow } = useAltDateWidgetProps(props);
|
|
3593
3564
|
return /* @__PURE__ */ jsxs15("ul", { className: "list-inline", children: [
|
|
3594
|
-
elements.map((elemProps, i) =>
|
|
3595
|
-
|
|
3596
|
-
{
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3565
|
+
elements.map((elemProps, i) => (
|
|
3566
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3567
|
+
/* @__PURE__ */ jsx40("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx40(
|
|
3568
|
+
DateElement,
|
|
3569
|
+
{
|
|
3570
|
+
rootId: id,
|
|
3571
|
+
name,
|
|
3572
|
+
select: handleChange,
|
|
3573
|
+
...elemProps,
|
|
3574
|
+
disabled,
|
|
3575
|
+
readonly,
|
|
3576
|
+
registry,
|
|
3577
|
+
onBlur,
|
|
3578
|
+
onFocus,
|
|
3579
|
+
autofocus: autofocus && i === 0
|
|
3580
|
+
}
|
|
3581
|
+
) }, i)
|
|
3582
|
+
)),
|
|
3583
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx40("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx40("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString13.NowLabel) }) }),
|
|
3584
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx40("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx40("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString13.ClearLabel) }) })
|
|
3611
3585
|
] });
|
|
3612
3586
|
}
|
|
3613
3587
|
var AltDateWidget_default = AltDateWidget;
|
|
@@ -3650,7 +3624,7 @@ function CheckboxesWidget({
|
|
|
3650
3624
|
);
|
|
3651
3625
|
return /* @__PURE__ */ jsx41("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3652
3626
|
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
3653
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3627
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3654
3628
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3655
3629
|
const handleChange = (event) => {
|
|
3656
3630
|
if (event.target.checked) {
|
|
@@ -3678,7 +3652,7 @@ function CheckboxesWidget({
|
|
|
3678
3652
|
),
|
|
3679
3653
|
/* @__PURE__ */ jsx41("span", { children: option.label })
|
|
3680
3654
|
] });
|
|
3681
|
-
return inline ? /* @__PURE__ */ jsx41("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox },
|
|
3655
|
+
return inline ? /* @__PURE__ */ jsx41("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ jsx41("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx41("label", { children: checkbox }) }, String(option.value));
|
|
3682
3656
|
}) });
|
|
3683
3657
|
}
|
|
3684
3658
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
@@ -3776,11 +3750,7 @@ function ColorWidget(props) {
|
|
|
3776
3750
|
}
|
|
3777
3751
|
|
|
3778
3752
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3779
|
-
import {
|
|
3780
|
-
getTemplate as getTemplate19,
|
|
3781
|
-
localToUTC,
|
|
3782
|
-
utcToLocal
|
|
3783
|
-
} from "@rjsf/utils";
|
|
3753
|
+
import { getTemplate as getTemplate19, localToUTC, utcToLocal } from "@rjsf/utils";
|
|
3784
3754
|
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
3785
3755
|
function DateTimeWidget(props) {
|
|
3786
3756
|
const { onChange, value, options, registry } = props;
|
|
@@ -3791,7 +3761,7 @@ function DateTimeWidget(props) {
|
|
|
3791
3761
|
type: "datetime-local",
|
|
3792
3762
|
...props,
|
|
3793
3763
|
value: utcToLocal(value),
|
|
3794
|
-
onChange: (
|
|
3764
|
+
onChange: (newValue) => onChange(localToUTC(newValue))
|
|
3795
3765
|
}
|
|
3796
3766
|
);
|
|
3797
3767
|
}
|
|
@@ -3817,12 +3787,8 @@ function EmailWidget(props) {
|
|
|
3817
3787
|
}
|
|
3818
3788
|
|
|
3819
3789
|
// src/components/widgets/FileWidget.tsx
|
|
3820
|
-
import {
|
|
3821
|
-
|
|
3822
|
-
TranslatableString as TranslatableString14,
|
|
3823
|
-
useFileWidgetProps
|
|
3824
|
-
} from "@rjsf/utils";
|
|
3825
|
-
import { Markdown as Markdown5 } from "markdown-to-jsx";
|
|
3790
|
+
import { getTemplate as getTemplate22, TranslatableString as TranslatableString14, useFileWidgetProps } from "@rjsf/utils";
|
|
3791
|
+
import { Markdown as Markdown5 } from "markdown-to-jsx/react";
|
|
3826
3792
|
import { Fragment as Fragment4, jsx as jsx47, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3827
3793
|
function FileInfoPreview({
|
|
3828
3794
|
fileInfo,
|
|
@@ -3833,12 +3799,13 @@ function FileInfoPreview({
|
|
|
3833
3799
|
if (!dataURL) {
|
|
3834
3800
|
return null;
|
|
3835
3801
|
}
|
|
3802
|
+
const previewLabel = translateString(TranslatableString14.PreviewLabel);
|
|
3836
3803
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3837
|
-
return /* @__PURE__ */ jsx47("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3804
|
+
return /* @__PURE__ */ jsx47("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3838
3805
|
}
|
|
3839
3806
|
return /* @__PURE__ */ jsxs18(Fragment4, { children: [
|
|
3840
3807
|
" ",
|
|
3841
|
-
/* @__PURE__ */ jsx47("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children:
|
|
3808
|
+
/* @__PURE__ */ jsx47("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
|
|
3842
3809
|
] });
|
|
3843
3810
|
}
|
|
3844
3811
|
function FilesInfo({
|
|
@@ -3856,11 +3823,14 @@ function FilesInfo({
|
|
|
3856
3823
|
return /* @__PURE__ */ jsx47("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3857
3824
|
const { name, size, type } = fileInfo;
|
|
3858
3825
|
const handleRemove = () => onRemove(key);
|
|
3859
|
-
return
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3826
|
+
return (
|
|
3827
|
+
// oxlint-disable-next-line react/no-array-index-key
|
|
3828
|
+
/* @__PURE__ */ jsxs18("li", { children: [
|
|
3829
|
+
/* @__PURE__ */ jsx47(Markdown5, { children: translateString(TranslatableString14.FilesInfo, [name, type, String(size)]) }),
|
|
3830
|
+
preview && /* @__PURE__ */ jsx47(FileInfoPreview, { fileInfo, registry }),
|
|
3831
|
+
/* @__PURE__ */ jsx47(RemoveButton2, { onClick: handleRemove, registry })
|
|
3832
|
+
] }, key)
|
|
3833
|
+
);
|
|
3864
3834
|
}) });
|
|
3865
3835
|
}
|
|
3866
3836
|
function FileWidget(props) {
|
|
@@ -3955,7 +3925,7 @@ function RadioWidget({
|
|
|
3955
3925
|
);
|
|
3956
3926
|
return /* @__PURE__ */ jsx50("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3957
3927
|
const checked = enumOptionsIsSelected2(option.value, value);
|
|
3958
|
-
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.
|
|
3928
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3959
3929
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3960
3930
|
const handleChange = () => onChange(option.value);
|
|
3961
3931
|
const radio = /* @__PURE__ */ jsxs19("span", { children: [
|
|
@@ -3978,7 +3948,7 @@ function RadioWidget({
|
|
|
3978
3948
|
),
|
|
3979
3949
|
/* @__PURE__ */ jsx50("span", { children: option.label })
|
|
3980
3950
|
] });
|
|
3981
|
-
return inline ? /* @__PURE__ */ jsx50("label", { className: `radio-inline ${disabledCls}`, children: radio },
|
|
3951
|
+
return inline ? /* @__PURE__ */ jsx50("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ jsx50("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx50("label", { children: radio }) }, String(option.value));
|
|
3982
3952
|
}) });
|
|
3983
3953
|
}
|
|
3984
3954
|
var RadioWidget_default = RadioWidget;
|
|
@@ -4000,7 +3970,7 @@ function RangeWidget(props) {
|
|
|
4000
3970
|
|
|
4001
3971
|
// src/components/widgets/RatingWidget.tsx
|
|
4002
3972
|
import { useCallback as useCallback12 } from "react";
|
|
4003
|
-
import {
|
|
3973
|
+
import { jsx as jsx52, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4004
3974
|
function RatingWidget({
|
|
4005
3975
|
id,
|
|
4006
3976
|
value,
|
|
@@ -4050,7 +4020,7 @@ function RatingWidget({
|
|
|
4050
4020
|
}
|
|
4051
4021
|
return isFilled ? "\u2605" : "\u2606";
|
|
4052
4022
|
};
|
|
4053
|
-
return /* @__PURE__ */
|
|
4023
|
+
return /* @__PURE__ */ jsxs21(
|
|
4054
4024
|
"div",
|
|
4055
4025
|
{
|
|
4056
4026
|
className: "rating-widget",
|
|
@@ -4067,6 +4037,7 @@ function RatingWidget({
|
|
|
4067
4037
|
"span",
|
|
4068
4038
|
{
|
|
4069
4039
|
onClick: () => handleStarClick(starValue),
|
|
4040
|
+
onKeyDown: (e) => (e.key === "Enter" || e.key === " ") && handleStarClick(starValue),
|
|
4070
4041
|
onFocus: handleFocus,
|
|
4071
4042
|
onBlur: handleBlur,
|
|
4072
4043
|
"data-value": starValue,
|
|
@@ -4099,7 +4070,7 @@ function RatingWidget({
|
|
|
4099
4070
|
)
|
|
4100
4071
|
]
|
|
4101
4072
|
}
|
|
4102
|
-
)
|
|
4073
|
+
);
|
|
4103
4074
|
}
|
|
4104
4075
|
|
|
4105
4076
|
// src/components/widgets/SelectWidget.tsx
|
|
@@ -4160,30 +4131,40 @@ function SelectWidget({
|
|
|
4160
4131
|
);
|
|
4161
4132
|
const selectValue = enumOptionSelectedValue(value, enumOptions, multiple, optionValueFormat, emptyValue);
|
|
4162
4133
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
4163
|
-
return
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4134
|
+
return (
|
|
4135
|
+
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
4136
|
+
/* @__PURE__ */ jsxs22(
|
|
4137
|
+
"select",
|
|
4138
|
+
{
|
|
4139
|
+
id,
|
|
4140
|
+
name: htmlName || id,
|
|
4141
|
+
multiple,
|
|
4142
|
+
className: "form-control",
|
|
4143
|
+
value: selectValue,
|
|
4144
|
+
required,
|
|
4145
|
+
disabled: disabled || readonly,
|
|
4146
|
+
autoFocus: autofocus,
|
|
4147
|
+
onBlur: handleBlur,
|
|
4148
|
+
onFocus: handleFocus,
|
|
4149
|
+
onChange: handleChange,
|
|
4150
|
+
"aria-describedby": ariaDescribedByIds5(id),
|
|
4151
|
+
children: [
|
|
4152
|
+
showPlaceholderOption && /* @__PURE__ */ jsx53("option", { value: "", children: placeholder }),
|
|
4153
|
+
Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
4154
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
4155
|
+
return /* @__PURE__ */ jsx53(
|
|
4156
|
+
"option",
|
|
4157
|
+
{
|
|
4158
|
+
value: enumOptionValueEncoder3(enumValue, i, optionValueFormat),
|
|
4159
|
+
disabled: isDisabled,
|
|
4160
|
+
children: enumLabel
|
|
4161
|
+
},
|
|
4162
|
+
String(enumValue)
|
|
4163
|
+
);
|
|
4164
|
+
})
|
|
4165
|
+
]
|
|
4166
|
+
}
|
|
4167
|
+
)
|
|
4187
4168
|
);
|
|
4188
4169
|
}
|
|
4189
4170
|
var SelectWidget_default = SelectWidget;
|
|
@@ -4207,7 +4188,7 @@ function TextareaWidget({
|
|
|
4207
4188
|
htmlName
|
|
4208
4189
|
}) {
|
|
4209
4190
|
const handleChange = useCallback14(
|
|
4210
|
-
({ target: { value:
|
|
4191
|
+
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
4211
4192
|
[onChange, options.emptyValue]
|
|
4212
4193
|
);
|
|
4213
4194
|
const handleBlur = useCallback14(
|
|
@@ -4224,7 +4205,7 @@ function TextareaWidget({
|
|
|
4224
4205
|
id,
|
|
4225
4206
|
name: htmlName || id,
|
|
4226
4207
|
className: "form-control",
|
|
4227
|
-
value: value
|
|
4208
|
+
value: value || "",
|
|
4228
4209
|
placeholder,
|
|
4229
4210
|
required,
|
|
4230
4211
|
disabled,
|
|
@@ -4330,7 +4311,7 @@ function toIChangeEvent(state, status) {
|
|
|
4330
4311
|
...status !== void 0 && { status }
|
|
4331
4312
|
};
|
|
4332
4313
|
}
|
|
4333
|
-
var Form = class extends Component3 {
|
|
4314
|
+
var Form = class _Form extends Component3 {
|
|
4334
4315
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4335
4316
|
* provide any possible type here
|
|
4336
4317
|
*/
|
|
@@ -4341,7 +4322,7 @@ var Form = class extends Component3 {
|
|
|
4341
4322
|
/** Flag to track when we're processing a user-initiated field change.
|
|
4342
4323
|
* This prevents componentDidUpdate from reverting oneOf/anyOf option switches.
|
|
4343
4324
|
*/
|
|
4344
|
-
|
|
4325
|
+
isProcessingUserChange = false;
|
|
4345
4326
|
/** When the `extraErrors` prop changes, re-merges `schemaValidationErrors` + `extraErrors` + `customErrors` into
|
|
4346
4327
|
* state before render, ensuring the updated errors are visible immediately in a single render cycle.
|
|
4347
4328
|
*
|
|
@@ -4350,7 +4331,7 @@ var Form = class extends Component3 {
|
|
|
4350
4331
|
* @returns Partial state with re-merged errors if `extraErrors` changed, or `null` if no update is needed
|
|
4351
4332
|
*/
|
|
4352
4333
|
static getDerivedStateFromProps(props, state) {
|
|
4353
|
-
if (props.extraErrors !== state.
|
|
4334
|
+
if (props.extraErrors !== state.prevExtraErrors) {
|
|
4354
4335
|
const baseErrors = {
|
|
4355
4336
|
errors: state.schemaValidationErrors || [],
|
|
4356
4337
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4366,7 +4347,7 @@ var Form = class extends Component3 {
|
|
|
4366
4347
|
true
|
|
4367
4348
|
));
|
|
4368
4349
|
}
|
|
4369
|
-
return {
|
|
4350
|
+
return { prevExtraErrors: props.extraErrors, errors, errorSchema };
|
|
4370
4351
|
}
|
|
4371
4352
|
return null;
|
|
4372
4353
|
}
|
|
@@ -4385,7 +4366,7 @@ var Form = class extends Component3 {
|
|
|
4385
4366
|
const formData = propsFormData ?? initialFormData;
|
|
4386
4367
|
this.state = {
|
|
4387
4368
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4388
|
-
|
|
4369
|
+
prevExtraErrors: props.extraErrors
|
|
4389
4370
|
};
|
|
4390
4371
|
if (onChange && !deepEquals2(this.state.formData, formData)) {
|
|
4391
4372
|
onChange(toIChangeEvent(this.state));
|
|
@@ -4450,8 +4431,8 @@ var Form = class extends Component3 {
|
|
|
4450
4431
|
if (snapshot.shouldUpdate) {
|
|
4451
4432
|
const { nextState } = snapshot;
|
|
4452
4433
|
const nextStateDiffersFromProps = !deepEquals2(nextState.formData, this.props.formData);
|
|
4453
|
-
const wasProcessingUserChange = this.
|
|
4454
|
-
this.
|
|
4434
|
+
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
4435
|
+
this.isProcessingUserChange = false;
|
|
4455
4436
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
4456
4437
|
return;
|
|
4457
4438
|
}
|
|
@@ -4468,12 +4449,13 @@ var Form = class extends Component3 {
|
|
|
4468
4449
|
* @param props - The props passed to the `Form`
|
|
4469
4450
|
* @param inputFormData - The new or current data for the `Form`
|
|
4470
4451
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4471
|
-
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4472
|
-
* @param formDataChangedFields - The changed fields of `formData`
|
|
4473
|
-
* @param skipLiveValidate - Optional flag, if true, means that we are not running live validation
|
|
4452
|
+
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
4453
|
+
* @param [formDataChangedFields=[]] - The changed fields of `formData`
|
|
4454
|
+
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
4455
|
+
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
4474
4456
|
* @returns - The new state for the `Form`
|
|
4475
4457
|
*/
|
|
4476
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false) {
|
|
4458
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = [], skipLiveValidate = false, shouldSanitize = false) {
|
|
4477
4459
|
const state = this.state || {};
|
|
4478
4460
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4479
4461
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -4484,7 +4466,7 @@ var Form = class extends Component3 {
|
|
|
4484
4466
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
4485
4467
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4486
4468
|
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
4487
|
-
let schemaUtils = state
|
|
4469
|
+
let { schemaUtils } = state;
|
|
4488
4470
|
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4489
4471
|
validator2,
|
|
4490
4472
|
schema,
|
|
@@ -4505,19 +4487,45 @@ var Form = class extends Component3 {
|
|
|
4505
4487
|
} else if (inputFormData === void 0 && isUncontrolled) {
|
|
4506
4488
|
defaultsFormData = state.formData;
|
|
4507
4489
|
}
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4490
|
+
let formData;
|
|
4491
|
+
let computedRetrievedSchema;
|
|
4492
|
+
let wasSanitized = false;
|
|
4493
|
+
const preventInfiniteSanitize = [];
|
|
4494
|
+
do {
|
|
4495
|
+
formData = schemaUtils.getDefaultFormState(
|
|
4496
|
+
rootSchema,
|
|
4497
|
+
defaultsFormData,
|
|
4498
|
+
false,
|
|
4499
|
+
state.initialDefaultsGenerated
|
|
4500
|
+
);
|
|
4501
|
+
const formHash = shouldSanitize ? hashObject5({ formData }) : "";
|
|
4502
|
+
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4503
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4504
|
+
);
|
|
4505
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !deepEquals2(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4506
|
+
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4507
|
+
computedRetrievedSchema,
|
|
4508
|
+
state.retrievedSchema,
|
|
4509
|
+
formData
|
|
4510
|
+
);
|
|
4511
|
+
wasSanitized = !deepEquals2(sanitizedFormData, formData);
|
|
4512
|
+
if (wasSanitized) {
|
|
4513
|
+
formData = sanitizedFormData;
|
|
4514
|
+
defaultsFormData = sanitizedFormData;
|
|
4515
|
+
const sanitizedFormHash = hashObject5({ formData: sanitizedFormData });
|
|
4516
|
+
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
4517
|
+
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
4518
|
+
}
|
|
4519
|
+
preventInfiniteSanitize.push(formHash);
|
|
4520
|
+
} else {
|
|
4521
|
+
wasSanitized = false;
|
|
4522
|
+
}
|
|
4523
|
+
} while (wasSanitized);
|
|
4517
4524
|
const getCurrentErrors = () => {
|
|
4518
4525
|
if (props.noValidate || isSchemaChanged) {
|
|
4519
4526
|
return { errors: [], errorSchema: {} };
|
|
4520
|
-
}
|
|
4527
|
+
}
|
|
4528
|
+
if (!props.liveValidate) {
|
|
4521
4529
|
return {
|
|
4522
4530
|
errors: state.schemaValidationErrors || [],
|
|
4523
4531
|
errorSchema: state.schemaValidationErrorSchema || {}
|
|
@@ -4530,8 +4538,7 @@ var Form = class extends Component3 {
|
|
|
4530
4538
|
};
|
|
4531
4539
|
let errors;
|
|
4532
4540
|
let errorSchema;
|
|
4533
|
-
let schemaValidationErrors = state
|
|
4534
|
-
let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
|
|
4541
|
+
let { schemaValidationErrors, schemaValidationErrorSchema } = state;
|
|
4535
4542
|
if (mustValidate && !skipLiveValidate) {
|
|
4536
4543
|
const liveValidation = this.liveValidate(
|
|
4537
4544
|
rootSchema,
|
|
@@ -4554,24 +4561,22 @@ var Form = class extends Component3 {
|
|
|
4554
4561
|
errors = currentErrors.errors;
|
|
4555
4562
|
errorSchema = currentErrors.errorSchema;
|
|
4556
4563
|
if (formDataChangedFields.length > 0 && !mustValidate) {
|
|
4557
|
-
const newErrorSchema = formDataChangedFields.reduce(
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
{}
|
|
4563
|
-
);
|
|
4564
|
-
errorSchema = schemaValidationErrorSchema = mergeObjects(
|
|
4564
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, key) => {
|
|
4565
|
+
acc[key] = void 0;
|
|
4566
|
+
return acc;
|
|
4567
|
+
}, {});
|
|
4568
|
+
schemaValidationErrorSchema = mergeObjects(
|
|
4565
4569
|
currentErrors.errorSchema,
|
|
4566
4570
|
newErrorSchema,
|
|
4567
4571
|
"preventDuplicates"
|
|
4568
4572
|
);
|
|
4573
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4569
4574
|
}
|
|
4570
|
-
const mergedErrors =
|
|
4575
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4571
4576
|
errors = mergedErrors.errors;
|
|
4572
4577
|
errorSchema = mergedErrors.errorSchema;
|
|
4573
4578
|
}
|
|
4574
|
-
const newRegistry =
|
|
4579
|
+
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4575
4580
|
const registry = deepEquals2(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4576
4581
|
const fieldPathId = state.fieldPathId && state.fieldPathId?.[ID_KEY5] === registry.globalFormOptions.idPrefix ? state.fieldPathId : toFieldPathId6("", registry.globalFormOptions);
|
|
4577
4582
|
const nextState = {
|
|
@@ -4585,7 +4590,7 @@ var Form = class extends Component3 {
|
|
|
4585
4590
|
errorSchema,
|
|
4586
4591
|
schemaValidationErrors,
|
|
4587
4592
|
schemaValidationErrorSchema,
|
|
4588
|
-
retrievedSchema:
|
|
4593
|
+
retrievedSchema: computedRetrievedSchema,
|
|
4589
4594
|
initialDefaultsGenerated: true,
|
|
4590
4595
|
registry
|
|
4591
4596
|
};
|
|
@@ -4610,10 +4615,10 @@ var Form = class extends Component3 {
|
|
|
4610
4615
|
* @param [retrievedSchema] - An optionally retrieved schema for per
|
|
4611
4616
|
*/
|
|
4612
4617
|
validate(formData, schema = this.state.schema, altSchemaUtils, retrievedSchema) {
|
|
4613
|
-
const schemaUtils = altSchemaUtils
|
|
4618
|
+
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
4614
4619
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4615
|
-
const
|
|
4616
|
-
return schemaUtils.getValidator().validateFormData(formData,
|
|
4620
|
+
const validationSchema = retrievedSchema ?? schema;
|
|
4621
|
+
return schemaUtils.getValidator().validateFormData(formData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
4617
4622
|
}
|
|
4618
4623
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4619
4624
|
renderErrors(registry) {
|
|
@@ -4642,9 +4647,8 @@ var Form = class extends Component3 {
|
|
|
4642
4647
|
* @return - The `extraErrors` and `customErrors` merged into the `schemaValidation`
|
|
4643
4648
|
* @private
|
|
4644
4649
|
*/
|
|
4645
|
-
mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4646
|
-
let errorSchema = schemaValidation
|
|
4647
|
-
let errors = schemaValidation.errors;
|
|
4650
|
+
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4651
|
+
let { errorSchema, errors } = schemaValidation;
|
|
4648
4652
|
if (extraErrors) {
|
|
4649
4653
|
const merged = validationDataMerge(schemaValidation, extraErrors);
|
|
4650
4654
|
errorSchema = merged.errorSchema;
|
|
@@ -4673,8 +4677,8 @@ var Form = class extends Component3 {
|
|
|
4673
4677
|
*/
|
|
4674
4678
|
liveValidate(rootSchema, schemaUtils, originalErrorSchema, formData, extraErrors, customErrors, retrievedSchema, mergeIntoOriginalErrorSchema = false) {
|
|
4675
4679
|
const schemaValidation = this.validate(formData, rootSchema, schemaUtils, retrievedSchema);
|
|
4676
|
-
const errors = schemaValidation
|
|
4677
|
-
let errorSchema = schemaValidation
|
|
4680
|
+
const { errors } = schemaValidation;
|
|
4681
|
+
let { errorSchema } = schemaValidation;
|
|
4678
4682
|
if (mergeIntoOriginalErrorSchema) {
|
|
4679
4683
|
errorSchema = mergeObjects(
|
|
4680
4684
|
originalErrorSchema,
|
|
@@ -4684,7 +4688,7 @@ var Form = class extends Component3 {
|
|
|
4684
4688
|
}
|
|
4685
4689
|
const schemaValidationErrors = errors;
|
|
4686
4690
|
const schemaValidationErrorSchema = errorSchema;
|
|
4687
|
-
const mergedErrors =
|
|
4691
|
+
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, extraErrors, customErrors);
|
|
4688
4692
|
return { ...mergedErrors, schemaValidationErrors, schemaValidationErrorSchema };
|
|
4689
4693
|
}
|
|
4690
4694
|
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
@@ -4693,18 +4697,16 @@ var Form = class extends Component3 {
|
|
|
4693
4697
|
* @param fields - The fields to keep while filtering
|
|
4694
4698
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4695
4699
|
*/
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
};
|
|
4700
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4701
|
+
getUsedFormData = (formData, fields2) => getUsedFormData(formData, fields2);
|
|
4699
4702
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4700
4703
|
*
|
|
4701
4704
|
* @param pathSchema - The `PathSchema` object for the form
|
|
4702
4705
|
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4703
4706
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4704
4707
|
*/
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
};
|
|
4708
|
+
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4709
|
+
getFieldNames = (pathSchema, formData) => getFieldNames(pathSchema, formData);
|
|
4708
4710
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4709
4711
|
*
|
|
4710
4712
|
* @param formData - The data for the `Form`
|
|
@@ -4756,16 +4758,15 @@ var Form = class extends Component3 {
|
|
|
4756
4758
|
if (this.pendingChanges.length === 0) {
|
|
4757
4759
|
return;
|
|
4758
4760
|
}
|
|
4759
|
-
this.
|
|
4761
|
+
this.isProcessingUserChange = true;
|
|
4760
4762
|
const { newValue, path, id } = this.pendingChanges[0];
|
|
4761
4763
|
const { newErrorSchema } = this.pendingChanges[0];
|
|
4762
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4764
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange, disabled, readonly } = this.props;
|
|
4763
4765
|
const { formData: oldFormData, schemaUtils, schema, fieldPathId, schemaValidationErrorSchema, errors } = this.state;
|
|
4764
|
-
let { customErrors } = this.state;
|
|
4766
|
+
let { customErrors, retrievedSchema } = this.state;
|
|
4765
4767
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4766
4768
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4767
4769
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4768
|
-
let retrievedSchema = this.state.retrievedSchema;
|
|
4769
4770
|
let formData = isRootPath ? newValue : _cloneDeep(oldFormData);
|
|
4770
4771
|
const hasOnlyUndefinedValues = isObject6(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4771
4772
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
@@ -4795,18 +4796,25 @@ var Form = class extends Component3 {
|
|
|
4795
4796
|
_set(formData, path, valueForPath);
|
|
4796
4797
|
}
|
|
4797
4798
|
}
|
|
4798
|
-
const
|
|
4799
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !isObject6(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
4800
|
+
const newState = this.getStateFromProps(
|
|
4801
|
+
this.props,
|
|
4802
|
+
inputForDefaults,
|
|
4803
|
+
void 0,
|
|
4804
|
+
void 0,
|
|
4805
|
+
void 0,
|
|
4806
|
+
true,
|
|
4807
|
+
shouldSanitize
|
|
4808
|
+
);
|
|
4799
4809
|
formData = newState.formData;
|
|
4800
4810
|
retrievedSchema = newState.retrievedSchema;
|
|
4801
4811
|
}
|
|
4802
4812
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
4803
|
-
let state = { formData,
|
|
4813
|
+
let state = { formData, retrievedSchema };
|
|
4804
4814
|
let newFormData = formData;
|
|
4805
4815
|
if (omitExtraData === true && (liveOmit === true || liveOmit === "onChange")) {
|
|
4806
4816
|
newFormData = this.omitExtraData(formData);
|
|
4807
|
-
state = {
|
|
4808
|
-
formData: newFormData
|
|
4809
|
-
};
|
|
4817
|
+
state = { ...state, formData: newFormData };
|
|
4810
4818
|
}
|
|
4811
4819
|
if (newErrorSchema) {
|
|
4812
4820
|
const oldValidationError = !isRootPath ? _get(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
@@ -4822,9 +4830,9 @@ var Form = class extends Component3 {
|
|
|
4822
4830
|
customErrors = new ErrorSchemaBuilder();
|
|
4823
4831
|
}
|
|
4824
4832
|
if (isRootPath) {
|
|
4825
|
-
const
|
|
4826
|
-
if (
|
|
4827
|
-
customErrors.setErrors(
|
|
4833
|
+
const pathErrors = _get(newErrorSchema, ERRORS_KEY3);
|
|
4834
|
+
if (pathErrors) {
|
|
4835
|
+
customErrors.setErrors(pathErrors);
|
|
4828
4836
|
}
|
|
4829
4837
|
} else {
|
|
4830
4838
|
_set(customErrors.ErrorSchema, path, newErrorSchema);
|
|
@@ -4843,14 +4851,14 @@ var Form = class extends Component3 {
|
|
|
4843
4851
|
customErrors,
|
|
4844
4852
|
retrievedSchema
|
|
4845
4853
|
);
|
|
4846
|
-
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4854
|
+
state = { ...state, formData: newFormData, ...liveValidation, customErrors };
|
|
4847
4855
|
} else if (!noValidate && newErrorSchema) {
|
|
4848
|
-
const mergedErrors =
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
...mergedErrors,
|
|
4856
|
+
const mergedErrors = _Form.mergeErrors(
|
|
4857
|
+
{ errorSchema: mergeBaseErrorSchema, errors },
|
|
4858
|
+
extraErrors,
|
|
4852
4859
|
customErrors
|
|
4853
|
-
|
|
4860
|
+
);
|
|
4861
|
+
state = { ...state, formData: newFormData, ...mergedErrors, customErrors };
|
|
4854
4862
|
}
|
|
4855
4863
|
this.setState(state, () => {
|
|
4856
4864
|
if (onChange) {
|
|
@@ -5003,7 +5011,7 @@ var Form = class extends Component3 {
|
|
|
5003
5011
|
* @returns - The `GlobalFormOptions` from the props
|
|
5004
5012
|
* @private
|
|
5005
5013
|
*/
|
|
5006
|
-
getGlobalFormOptions(props) {
|
|
5014
|
+
static getGlobalFormOptions(props) {
|
|
5007
5015
|
const {
|
|
5008
5016
|
uiSchema = {},
|
|
5009
5017
|
experimental_componentUpdateStrategy,
|
|
@@ -5022,7 +5030,7 @@ var Form = class extends Component3 {
|
|
|
5022
5030
|
};
|
|
5023
5031
|
}
|
|
5024
5032
|
/** Computed the registry for the form using the given `props`, `schema` and `schemaUtils` */
|
|
5025
|
-
getRegistry(props, schema, schemaUtils) {
|
|
5033
|
+
static getRegistry(props, schema, schemaUtils) {
|
|
5026
5034
|
const { translateString: customTranslateString, uiSchema = {} } = props;
|
|
5027
5035
|
const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
|
|
5028
5036
|
return {
|
|
@@ -5041,7 +5049,7 @@ var Form = class extends Component3 {
|
|
|
5041
5049
|
schemaUtils,
|
|
5042
5050
|
translateString: customTranslateString || translateString,
|
|
5043
5051
|
globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY2],
|
|
5044
|
-
globalFormOptions:
|
|
5052
|
+
globalFormOptions: _Form.getGlobalFormOptions(props),
|
|
5045
5053
|
uiSchemaDefinitions: uiSchema[UI_DEFINITIONS_KEY] ?? {}
|
|
5046
5054
|
};
|
|
5047
5055
|
}
|
|
@@ -5093,7 +5101,7 @@ var Form = class extends Component3 {
|
|
|
5093
5101
|
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
5094
5102
|
const { errors: prevErrors } = this.state;
|
|
5095
5103
|
const schemaValidation = this.validate(formData);
|
|
5096
|
-
const { errors, errorSchema } = extraErrors ?
|
|
5104
|
+
const { errors, errorSchema } = extraErrors ? _Form.mergeErrors(schemaValidation, extraErrors) : schemaValidation;
|
|
5097
5105
|
const hasError = schemaValidation.errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
5098
5106
|
if (hasError) {
|
|
5099
5107
|
if (focusOnFirstError) {
|
|
@@ -5172,7 +5180,7 @@ var Form = class extends Component3 {
|
|
|
5172
5180
|
_internalFormWrapper
|
|
5173
5181
|
} = this.props;
|
|
5174
5182
|
const { schema, uiSchema, formData, errorSchema, fieldPathId, registry } = this.state;
|
|
5175
|
-
const { SchemaField:
|
|
5183
|
+
const { SchemaField: SchemaFieldComponent } = registry.fields;
|
|
5176
5184
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
5177
5185
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
5178
5186
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
@@ -5184,7 +5192,7 @@ var Form = class extends Component3 {
|
|
|
5184
5192
|
return /* @__PURE__ */ jsxs23(
|
|
5185
5193
|
FormTag,
|
|
5186
5194
|
{
|
|
5187
|
-
className: className
|
|
5195
|
+
className: className || "rjsf",
|
|
5188
5196
|
id,
|
|
5189
5197
|
name,
|
|
5190
5198
|
method,
|
|
@@ -5200,7 +5208,7 @@ var Form = class extends Component3 {
|
|
|
5200
5208
|
children: [
|
|
5201
5209
|
showErrorList === "top" && this.renderErrors(registry),
|
|
5202
5210
|
/* @__PURE__ */ jsx59(
|
|
5203
|
-
|
|
5211
|
+
SchemaFieldComponent,
|
|
5204
5212
|
{
|
|
5205
5213
|
name: "",
|
|
5206
5214
|
schema,
|
|
@@ -5216,7 +5224,7 @@ var Form = class extends Component3 {
|
|
|
5216
5224
|
readonly
|
|
5217
5225
|
}
|
|
5218
5226
|
),
|
|
5219
|
-
children
|
|
5227
|
+
children || /* @__PURE__ */ jsx59(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
5220
5228
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
5221
5229
|
]
|
|
5222
5230
|
}
|
|
@@ -5225,12 +5233,7 @@ var Form = class extends Component3 {
|
|
|
5225
5233
|
};
|
|
5226
5234
|
|
|
5227
5235
|
// src/getTestRegistry.tsx
|
|
5228
|
-
import {
|
|
5229
|
-
DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX3,
|
|
5230
|
-
DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR3,
|
|
5231
|
-
createSchemaUtils as createSchemaUtils2,
|
|
5232
|
-
englishStringTranslator as englishStringTranslator2
|
|
5233
|
-
} from "@rjsf/utils";
|
|
5236
|
+
import { DEFAULT_ID_PREFIX as DEFAULT_ID_PREFIX3, DEFAULT_ID_SEPARATOR as DEFAULT_ID_SEPARATOR3, createSchemaUtils as createSchemaUtils2, englishStringTranslator as englishStringTranslator2 } from "@rjsf/utils";
|
|
5234
5237
|
import validator from "@rjsf/validator-ajv8";
|
|
5235
5238
|
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = {
|
|
5236
5239
|
idPrefix: DEFAULT_ID_PREFIX3,
|
|
@@ -5256,15 +5259,15 @@ import { forwardRef } from "react";
|
|
|
5256
5259
|
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
5257
5260
|
function withTheme(themeProps) {
|
|
5258
5261
|
return forwardRef(
|
|
5259
|
-
({ fields:
|
|
5260
|
-
fields2 = { ...themeProps?.fields, ...
|
|
5261
|
-
widgets2 = { ...themeProps?.widgets, ...
|
|
5262
|
-
templates2 = {
|
|
5262
|
+
({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
|
|
5263
|
+
const fields2 = { ...themeProps?.fields, ...propFields };
|
|
5264
|
+
const widgets2 = { ...themeProps?.widgets, ...propWidgets };
|
|
5265
|
+
const templates2 = {
|
|
5263
5266
|
...themeProps?.templates,
|
|
5264
|
-
...
|
|
5267
|
+
...propTemplates,
|
|
5265
5268
|
ButtonTemplates: {
|
|
5266
5269
|
...themeProps?.templates?.ButtonTemplates,
|
|
5267
|
-
...
|
|
5270
|
+
...propTemplates?.ButtonTemplates
|
|
5268
5271
|
}
|
|
5269
5272
|
};
|
|
5270
5273
|
return /* @__PURE__ */ jsx60(
|