@rjsf/core 6.8.0 → 6.10.0
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 +183 -152
- package/dist/index.cjs +179 -190
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +209 -198
- package/dist/index.esm.js.map +3 -3
- package/lib/components/Form.d.ts +3 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +62 -45
- package/lib/components/Form.js.map +1 -0
- package/lib/components/RichDescription.js +1 -0
- package/lib/components/RichDescription.js.map +1 -0
- package/lib/components/RichHelp.js +1 -0
- package/lib/components/RichHelp.js.map +1 -0
- package/lib/components/SchemaExamples.js +1 -0
- package/lib/components/SchemaExamples.js.map +1 -0
- package/lib/components/constants.js +1 -0
- package/lib/components/constants.js.map +1 -0
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.js +16 -17
- package/lib/components/fields/ArrayField.js.map +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -2
- package/lib/components/fields/BooleanField.js.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +1 -0
- package/lib/components/fields/CyclicSchemaField.js.map +1 -0
- package/lib/components/fields/FallbackField.js +1 -0
- package/lib/components/fields/FallbackField.js.map +1 -0
- package/lib/components/fields/LayoutGridField.d.ts +61 -1
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.js +50 -63
- package/lib/components/fields/LayoutGridField.js.map +1 -0
- package/lib/components/fields/LayoutHeaderField.js +1 -0
- package/lib/components/fields/LayoutHeaderField.js.map +1 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.js +14 -18
- package/lib/components/fields/LayoutMultiSchemaField.js.map +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +6 -7
- package/lib/components/fields/MultiSchemaField.js.map +1 -0
- package/lib/components/fields/NullField.js +1 -0
- package/lib/components/fields/NullField.js.map +1 -0
- package/lib/components/fields/NumberField.js +1 -0
- package/lib/components/fields/NumberField.js.map +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +20 -25
- package/lib/components/fields/ObjectField.js.map +1 -0
- package/lib/components/fields/OptionalDataControlsField.js +1 -0
- package/lib/components/fields/OptionalDataControlsField.js.map +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +5 -5
- package/lib/components/fields/SchemaField.js.map +1 -0
- package/lib/components/fields/StringField.js +1 -0
- package/lib/components/fields/StringField.js.map +1 -0
- package/lib/components/fields/index.js +15 -14
- package/lib/components/fields/index.js.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +3 -2
- package/lib/components/templates/BaseInputTemplate.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +2 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +4 -3
- package/lib/components/templates/ButtonTemplates/index.js.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js.map +1 -0
- package/lib/components/templates/DescriptionField.js +2 -1
- package/lib/components/templates/DescriptionField.js.map +1 -0
- package/lib/components/templates/ErrorList.js +1 -0
- package/lib/components/templates/ErrorList.js.map +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js +1 -0
- package/lib/components/templates/FallbackFieldTemplate.js.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +1 -0
- package/lib/components/templates/FieldErrorTemplate.js.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +2 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +2 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +1 -0
- package/lib/components/templates/FieldTemplate/Label.js.map +1 -0
- package/lib/components/templates/FieldTemplate/index.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/index.js +2 -1
- package/lib/components/templates/FieldTemplate/index.js.map +1 -0
- package/lib/components/templates/GridTemplate.js +1 -0
- package/lib/components/templates/GridTemplate.js.map +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js +1 -0
- package/lib/components/templates/MultiSchemaFieldTemplate.js.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js.map +1 -0
- package/lib/components/templates/OptionalDataControlsTemplate.js +2 -1
- package/lib/components/templates/OptionalDataControlsTemplate.js.map +1 -0
- package/lib/components/templates/TitleField.js +1 -0
- package/lib/components/templates/TitleField.js.map +1 -0
- package/lib/components/templates/UnsupportedField.js +1 -0
- package/lib/components/templates/UnsupportedField.js.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +2 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -0
- package/lib/components/templates/index.js +22 -21
- package/lib/components/templates/index.js.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +1 -0
- package/lib/components/widgets/AltDateWidget.js.map +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxWidget.js +4 -3
- package/lib/components/widgets/CheckboxWidget.js.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +1 -0
- package/lib/components/widgets/CheckboxesWidget.js.map +1 -0
- package/lib/components/widgets/ColorWidget.js +1 -0
- package/lib/components/widgets/ColorWidget.js.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +1 -0
- package/lib/components/widgets/DateTimeWidget.js.map +1 -0
- package/lib/components/widgets/DateWidget.js +1 -0
- package/lib/components/widgets/DateWidget.js.map +1 -0
- package/lib/components/widgets/EmailWidget.js +1 -0
- package/lib/components/widgets/EmailWidget.js.map +1 -0
- package/lib/components/widgets/FileWidget.js +1 -0
- package/lib/components/widgets/FileWidget.js.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +1 -0
- package/lib/components/widgets/HiddenWidget.js.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +1 -0
- package/lib/components/widgets/PasswordWidget.js.map +1 -0
- package/lib/components/widgets/RadioWidget.js +1 -0
- package/lib/components/widgets/RadioWidget.js.map +1 -0
- package/lib/components/widgets/RangeWidget.js +1 -0
- package/lib/components/widgets/RangeWidget.js.map +1 -0
- 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 +2 -1
- package/lib/components/widgets/RatingWidget.js.map +1 -0
- package/lib/components/widgets/SelectWidget.js +1 -0
- package/lib/components/widgets/SelectWidget.js.map +1 -0
- package/lib/components/widgets/TextWidget.js +1 -0
- package/lib/components/widgets/TextWidget.js.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +1 -0
- package/lib/components/widgets/TextareaWidget.js.map +1 -0
- package/lib/components/widgets/TimeWidget.js +1 -0
- package/lib/components/widgets/TimeWidget.js.map +1 -0
- package/lib/components/widgets/URLWidget.js +1 -0
- package/lib/components/widgets/URLWidget.js.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +1 -0
- package/lib/components/widgets/UpDownWidget.js.map +1 -0
- package/lib/components/widgets/index.js +21 -20
- package/lib/components/widgets/index.js.map +1 -0
- package/lib/getDefaultRegistry.js +4 -3
- package/lib/getDefaultRegistry.js.map +1 -0
- package/lib/getTestRegistry.js +2 -1
- package/lib/getTestRegistry.js.map +1 -0
- package/lib/index.d.ts +12 -12
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -7
- package/lib/index.js.map +1 -0
- package/lib/withTheme.d.ts +1 -1
- package/lib/withTheme.d.ts.map +1 -1
- package/lib/withTheme.js +2 -1
- package/lib/withTheme.js.map +1 -0
- package/package.json +13 -18
- package/src/components/Form.tsx +68 -47
- package/src/components/fields/ArrayField.tsx +17 -19
- package/src/components/fields/BooleanField.tsx +1 -2
- package/src/components/fields/LayoutGridField.tsx +57 -65
- package/src/components/fields/LayoutMultiSchemaField.tsx +18 -18
- package/src/components/fields/MultiSchemaField.tsx +6 -8
- package/src/components/fields/ObjectField.tsx +26 -27
- package/src/components/fields/SchemaField.tsx +13 -4
- package/src/components/fields/index.ts +14 -14
- package/src/components/templates/BaseInputTemplate.tsx +2 -2
- package/src/components/templates/ButtonTemplates/AddButton.tsx +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +3 -3
- package/src/components/templates/DescriptionField.tsx +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/index.ts +1 -1
- package/src/components/templates/OptionalDataControlsTemplate.tsx +1 -1
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +1 -1
- package/src/components/templates/index.ts +21 -21
- package/src/components/widgets/CheckboxWidget.tsx +9 -2
- package/src/components/widgets/RatingWidget.tsx +0 -1
- package/src/components/widgets/index.ts +20 -20
- package/src/getDefaultRegistry.ts +3 -3
- package/src/getTestRegistry.tsx +1 -1
- package/src/index.ts +12 -12
- package/src/withTheme.tsx +2 -2
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/src/tsconfig.json +0 -30
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
// src/components/Form.tsx
|
|
2
2
|
import { Component, createRef } from "react";
|
|
3
3
|
import {
|
|
4
|
+
getByPath as getByPath4,
|
|
5
|
+
setByPath as setByPath4,
|
|
6
|
+
toPath as toPath2,
|
|
7
|
+
unsetByPath,
|
|
4
8
|
createSchemaUtils,
|
|
5
|
-
deepEquals as
|
|
9
|
+
deepEquals as deepEquals5,
|
|
6
10
|
ErrorSchemaBuilder,
|
|
7
11
|
getChangedFields,
|
|
8
12
|
getTemplate as getTemplate29,
|
|
@@ -27,13 +31,6 @@ import {
|
|
|
27
31
|
ANY_OF_KEY as ANY_OF_KEY6,
|
|
28
32
|
ONE_OF_KEY as ONE_OF_KEY6
|
|
29
33
|
} from "@rjsf/utils";
|
|
30
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
31
|
-
import _get from "lodash/get";
|
|
32
|
-
import _isEmpty from "lodash/isEmpty";
|
|
33
|
-
import _pick from "lodash/pick";
|
|
34
|
-
import _set from "lodash/set";
|
|
35
|
-
import _toPath from "lodash/toPath";
|
|
36
|
-
import _unset from "lodash/unset";
|
|
37
34
|
|
|
38
35
|
// src/getDefaultRegistry.ts
|
|
39
36
|
import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from "@rjsf/utils";
|
|
@@ -41,6 +38,7 @@ import { DEFAULT_ID_PREFIX, DEFAULT_ID_SEPARATOR, englishStringTranslator } from
|
|
|
41
38
|
// src/components/fields/ArrayField.tsx
|
|
42
39
|
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
43
40
|
import {
|
|
41
|
+
setByPath,
|
|
44
42
|
allowAdditionalItems,
|
|
45
43
|
getTemplate,
|
|
46
44
|
getUiOptions,
|
|
@@ -49,6 +47,7 @@ import {
|
|
|
49
47
|
isCustomWidget,
|
|
50
48
|
isFixedItems,
|
|
51
49
|
isFormDataAvailable,
|
|
50
|
+
isObject,
|
|
52
51
|
optionsList,
|
|
53
52
|
shouldRenderOptionalField,
|
|
54
53
|
toFieldPathId,
|
|
@@ -57,13 +56,11 @@ import {
|
|
|
57
56
|
ID_KEY,
|
|
58
57
|
TranslatableString
|
|
59
58
|
} from "@rjsf/utils";
|
|
60
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
61
|
-
import isObject from "lodash/isObject";
|
|
62
|
-
import set from "lodash/set";
|
|
63
|
-
import uniqueId from "lodash/uniqueId";
|
|
64
59
|
import { jsx } from "react/jsx-runtime";
|
|
60
|
+
var rowIdCounter = 0;
|
|
65
61
|
function generateRowId() {
|
|
66
|
-
|
|
62
|
+
rowIdCounter += 1;
|
|
63
|
+
return `rjsf-array-item-${rowIdCounter}`;
|
|
67
64
|
}
|
|
68
65
|
function generateKeyedFormData(formData) {
|
|
69
66
|
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
@@ -326,14 +323,14 @@ function ArrayFieldItemInner(props) {
|
|
|
326
323
|
const { description } = getUiOptions(itemUiSchema);
|
|
327
324
|
const hasDescription = !!description || !!itemSchema.description;
|
|
328
325
|
const { orderable = true, removable = true, copyable = false } = uiOptions;
|
|
329
|
-
const
|
|
326
|
+
const has = {
|
|
330
327
|
moveUp: orderable && canMoveUp,
|
|
331
328
|
moveDown: orderable && canMoveDown,
|
|
332
329
|
copy: copyable && canAdd,
|
|
333
330
|
remove: removable && canRemove,
|
|
334
331
|
toolbar: false
|
|
335
332
|
};
|
|
336
|
-
|
|
333
|
+
has.toolbar = Object.keys(has).some((key) => has[key]);
|
|
337
334
|
const onAddItem = useCallback(
|
|
338
335
|
(event) => {
|
|
339
336
|
handleAddItem(event, index + 1);
|
|
@@ -393,10 +390,10 @@ function ArrayFieldItemInner(props) {
|
|
|
393
390
|
disabled,
|
|
394
391
|
readonly,
|
|
395
392
|
canAdd,
|
|
396
|
-
hasCopy:
|
|
397
|
-
hasMoveUp:
|
|
398
|
-
hasMoveDown:
|
|
399
|
-
hasRemove:
|
|
393
|
+
hasCopy: has.copy,
|
|
394
|
+
hasMoveUp: has.moveUp,
|
|
395
|
+
hasMoveDown: has.moveDown,
|
|
396
|
+
hasRemove: has.remove,
|
|
400
397
|
index,
|
|
401
398
|
totalItems,
|
|
402
399
|
onAddItem,
|
|
@@ -411,7 +408,7 @@ function ArrayFieldItemInner(props) {
|
|
|
411
408
|
itemKey,
|
|
412
409
|
className: "rjsf-array-item",
|
|
413
410
|
disabled,
|
|
414
|
-
hasToolbar:
|
|
411
|
+
hasToolbar: has.toolbar,
|
|
415
412
|
index,
|
|
416
413
|
totalItems,
|
|
417
414
|
readonly,
|
|
@@ -556,10 +553,7 @@ function FixedArray(props) {
|
|
|
556
553
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
557
554
|
const renderOptionalField = shouldRenderOptionalField(registry, schema, required, uiSchema);
|
|
558
555
|
const hasFormData = isFormDataAvailable(formData);
|
|
559
|
-
const schemaItems = useMemo(
|
|
560
|
-
() => isObject(schema.items) ? schema.items : [],
|
|
561
|
-
[schema.items]
|
|
562
|
-
);
|
|
556
|
+
const schemaItems = useMemo(() => Array.isArray(schema.items) ? schema.items : [], [schema.items]);
|
|
563
557
|
const hasAdditionalItems = isObject(schema.additionalItems);
|
|
564
558
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
565
559
|
if (items.length < schemaItems.length) {
|
|
@@ -682,9 +676,9 @@ function ArrayField(props) {
|
|
|
682
676
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
683
677
|
const i = parseInt(idx, 10);
|
|
684
678
|
if (index === void 0 || i < index) {
|
|
685
|
-
|
|
679
|
+
setByPath(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
686
680
|
} else if (i >= index) {
|
|
687
|
-
|
|
681
|
+
setByPath(newErrorSchema, i + 1, errorSchemaRef.current[i]);
|
|
688
682
|
}
|
|
689
683
|
}
|
|
690
684
|
}
|
|
@@ -713,15 +707,15 @@ function ArrayField(props) {
|
|
|
713
707
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
714
708
|
const i = parseInt(idx, 10);
|
|
715
709
|
if (i <= index) {
|
|
716
|
-
|
|
710
|
+
setByPath(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
717
711
|
} else if (i > index) {
|
|
718
|
-
|
|
712
|
+
setByPath(newErrorSchema, i + 1, errorSchemaRef.current[i]);
|
|
719
713
|
}
|
|
720
714
|
}
|
|
721
715
|
}
|
|
722
716
|
const newKeyedFormDataRow = {
|
|
723
717
|
key: generateRowId(),
|
|
724
|
-
item:
|
|
718
|
+
item: structuredClone(keyedFormDataRef.current[index].item)
|
|
725
719
|
};
|
|
726
720
|
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
727
721
|
if (index !== void 0) {
|
|
@@ -744,9 +738,9 @@ function ArrayField(props) {
|
|
|
744
738
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
745
739
|
const i = parseInt(idx, 10);
|
|
746
740
|
if (i < index) {
|
|
747
|
-
|
|
741
|
+
setByPath(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
748
742
|
} else if (i > index) {
|
|
749
|
-
|
|
743
|
+
setByPath(newErrorSchema, i - 1, errorSchemaRef.current[i]);
|
|
750
744
|
}
|
|
751
745
|
}
|
|
752
746
|
}
|
|
@@ -767,11 +761,11 @@ function ArrayField(props) {
|
|
|
767
761
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
768
762
|
const i = parseInt(idx, 10);
|
|
769
763
|
if (i === index) {
|
|
770
|
-
|
|
764
|
+
setByPath(newErrorSchema, newIndex, errorSchemaRef.current[index]);
|
|
771
765
|
} else if (i === newIndex) {
|
|
772
|
-
|
|
766
|
+
setByPath(newErrorSchema, index, errorSchemaRef.current[newIndex]);
|
|
773
767
|
} else {
|
|
774
|
-
|
|
768
|
+
setByPath(newErrorSchema, idx, errorSchemaRef.current[i]);
|
|
775
769
|
}
|
|
776
770
|
}
|
|
777
771
|
}
|
|
@@ -861,8 +855,7 @@ function ArrayField(props) {
|
|
|
861
855
|
|
|
862
856
|
// src/components/fields/BooleanField.tsx
|
|
863
857
|
import { useCallback as useCallback2 } from "react";
|
|
864
|
-
import { getWidget as getWidget2, getUiOptions as getUiOptions2, optionsList as optionsList2, TranslatableString as TranslatableString2 } from "@rjsf/utils";
|
|
865
|
-
import isObject2 from "lodash/isObject";
|
|
858
|
+
import { getWidget as getWidget2, getUiOptions as getUiOptions2, isObject as isObject2, optionsList as optionsList2, TranslatableString as TranslatableString2 } from "@rjsf/utils";
|
|
866
859
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
867
860
|
function BooleanField(props) {
|
|
868
861
|
const {
|
|
@@ -1124,13 +1117,19 @@ function FallbackField(props) {
|
|
|
1124
1117
|
|
|
1125
1118
|
// src/components/fields/LayoutGridField.tsx
|
|
1126
1119
|
import {
|
|
1120
|
+
getByPath,
|
|
1121
|
+
toPath,
|
|
1127
1122
|
ANY_OF_KEY,
|
|
1123
|
+
deepEquals,
|
|
1128
1124
|
getDiscriminatorFieldFromSchema,
|
|
1129
1125
|
getTemplate as getTemplate4,
|
|
1130
1126
|
getTestIds,
|
|
1127
|
+
getPropertySchema,
|
|
1131
1128
|
getUiOptions as getUiOptions5,
|
|
1132
1129
|
hashObject as hashObject3,
|
|
1133
1130
|
ID_KEY as ID_KEY2,
|
|
1131
|
+
isObject as isObject3,
|
|
1132
|
+
isPlainObject,
|
|
1134
1133
|
lookupFromFormContext,
|
|
1135
1134
|
ONE_OF_KEY,
|
|
1136
1135
|
PROPERTIES_KEY,
|
|
@@ -1141,21 +1140,6 @@ import {
|
|
|
1141
1140
|
ITEMS_KEY as ITEMS_KEY2,
|
|
1142
1141
|
useDeepCompareMemo as useDeepCompareMemo3
|
|
1143
1142
|
} from "@rjsf/utils";
|
|
1144
|
-
import each from "lodash/each";
|
|
1145
|
-
import flatten from "lodash/flatten";
|
|
1146
|
-
import get from "lodash/get";
|
|
1147
|
-
import has from "lodash/has";
|
|
1148
|
-
import includes from "lodash/includes";
|
|
1149
|
-
import intersection from "lodash/intersection";
|
|
1150
|
-
import isEmpty from "lodash/isEmpty";
|
|
1151
|
-
import isEqual from "lodash/isEqual";
|
|
1152
|
-
import isFunction from "lodash/isFunction";
|
|
1153
|
-
import isObject3 from "lodash/isObject";
|
|
1154
|
-
import isPlainObject from "lodash/isPlainObject";
|
|
1155
|
-
import isString from "lodash/isString";
|
|
1156
|
-
import isUndefined from "lodash/isUndefined";
|
|
1157
|
-
import last from "lodash/last";
|
|
1158
|
-
import set2 from "lodash/set";
|
|
1159
1143
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1160
1144
|
import { createElement } from "react";
|
|
1161
1145
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
@@ -1169,37 +1153,38 @@ function isNumericIndex(str) {
|
|
|
1169
1153
|
}
|
|
1170
1154
|
var LAYOUT_GRID_FIELD_TEST_IDS = getTestIds();
|
|
1171
1155
|
function computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
1172
|
-
const globalUiOptions =
|
|
1173
|
-
const localUiSchema =
|
|
1174
|
-
const localUiOptions = { ...
|
|
1156
|
+
const globalUiOptions = uiSchema?.[UI_GLOBAL_OPTIONS_KEY] ?? {};
|
|
1157
|
+
const localUiSchema = getByPath(uiSchema, toPath(field));
|
|
1158
|
+
const localUiOptions = { ...localUiSchema?.[UI_OPTIONS_KEY] ?? {}, ...uiProps, ...globalUiOptions };
|
|
1175
1159
|
const fieldUiSchema = { ...localUiSchema };
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
1160
|
+
if (Object.keys(localUiOptions).length > 0) {
|
|
1161
|
+
fieldUiSchema[UI_OPTIONS_KEY] = localUiOptions;
|
|
1178
1162
|
}
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1163
|
+
if (Object.keys(globalUiOptions).length > 0) {
|
|
1164
|
+
fieldUiSchema[UI_GLOBAL_OPTIONS_KEY] = globalUiOptions;
|
|
1181
1165
|
}
|
|
1182
1166
|
let { readonly: uiReadonly } = getUiOptions5(fieldUiSchema);
|
|
1183
|
-
if (forceReadonly === true ||
|
|
1167
|
+
if (forceReadonly === true || uiReadonly === void 0 && schemaReadonly === true) {
|
|
1184
1168
|
uiReadonly = true;
|
|
1185
|
-
|
|
1186
|
-
|
|
1169
|
+
const fieldUiOptions = fieldUiSchema[UI_OPTIONS_KEY];
|
|
1170
|
+
if (fieldUiOptions && READONLY_KEY in fieldUiOptions) {
|
|
1171
|
+
fieldUiOptions[READONLY_KEY] = true;
|
|
1187
1172
|
} else {
|
|
1188
|
-
|
|
1173
|
+
fieldUiSchema[`ui:${READONLY_KEY}`] = true;
|
|
1189
1174
|
}
|
|
1190
1175
|
}
|
|
1191
1176
|
return { fieldUiSchema, uiReadonly };
|
|
1192
1177
|
}
|
|
1193
1178
|
function conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
|
|
1194
|
-
const data =
|
|
1195
|
-
const values =
|
|
1179
|
+
const data = [datum].flat().sort();
|
|
1180
|
+
const values = [value].flat().sort();
|
|
1196
1181
|
switch (operator) {
|
|
1197
1182
|
case "all" /* ALL */:
|
|
1198
|
-
return
|
|
1183
|
+
return deepEquals(data, values);
|
|
1199
1184
|
case "some" /* SOME */:
|
|
1200
|
-
return
|
|
1185
|
+
return data.some((entry) => values.includes(entry));
|
|
1201
1186
|
case "none" /* NONE */:
|
|
1202
|
-
return
|
|
1187
|
+
return !data.some((entry) => values.includes(entry));
|
|
1203
1188
|
default:
|
|
1204
1189
|
return false;
|
|
1205
1190
|
}
|
|
@@ -1226,12 +1211,12 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1226
1211
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1227
1212
|
let rawSchema;
|
|
1228
1213
|
let resultPathId = fieldPathId;
|
|
1229
|
-
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" &&
|
|
1214
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && ITEMS_KEY2 in schema) {
|
|
1230
1215
|
const index = Number(potentialIndex);
|
|
1231
1216
|
const items = schema[ITEMS_KEY2];
|
|
1232
1217
|
if (Array.isArray(items)) {
|
|
1233
1218
|
if (index > items.length) {
|
|
1234
|
-
rawSchema =
|
|
1219
|
+
rawSchema = items.at(-1);
|
|
1235
1220
|
} else {
|
|
1236
1221
|
rawSchema = items[index];
|
|
1237
1222
|
}
|
|
@@ -1256,44 +1241,45 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1256
1241
|
let isReadonly = schema.readOnly;
|
|
1257
1242
|
parts.forEach((part) => {
|
|
1258
1243
|
fieldPathId = toFieldPathId3(part, globalFormOptions, fieldPathId);
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1244
|
+
const schemaProperties = schema?.[PROPERTIES_KEY];
|
|
1245
|
+
if (schemaProperties) {
|
|
1246
|
+
rawSchema = schemaProperties[part] ?? {};
|
|
1247
|
+
} else if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
1248
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1263
1249
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1264
|
-
rawSchema =
|
|
1250
|
+
rawSchema = getPropertySchema(selectedSchema, part);
|
|
1265
1251
|
} else {
|
|
1266
1252
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1267
1253
|
rawSchema = result.rawSchema ?? {};
|
|
1268
1254
|
fieldPathId = result.fieldPathId;
|
|
1269
1255
|
}
|
|
1270
|
-
innerData =
|
|
1256
|
+
innerData = getByPath(innerData, part, {});
|
|
1271
1257
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
1272
1258
|
isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
|
|
1273
1259
|
});
|
|
1274
1260
|
let optionsInfo;
|
|
1275
1261
|
let isRequired2 = false;
|
|
1276
|
-
if (
|
|
1262
|
+
if (!schema || Object.keys(schema).length === 0) {
|
|
1277
1263
|
schema = void 0;
|
|
1278
1264
|
}
|
|
1279
1265
|
if (schema && leafPath) {
|
|
1280
|
-
if (schema && (
|
|
1281
|
-
const xxx =
|
|
1266
|
+
if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
1267
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1282
1268
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1283
1269
|
}
|
|
1284
1270
|
fieldPathId = toFieldPathId3(leafPath, globalFormOptions, fieldPathId);
|
|
1285
|
-
isRequired2 = schema !== void 0 && Array.isArray(schema.required) &&
|
|
1271
|
+
isRequired2 = schema !== void 0 && Array.isArray(schema.required) && schema.required.includes(leafPath);
|
|
1286
1272
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1287
1273
|
if (result.rawSchema) {
|
|
1288
1274
|
schema = result.rawSchema;
|
|
1289
1275
|
fieldPathId = result.fieldPathId;
|
|
1290
1276
|
} else {
|
|
1291
|
-
schema =
|
|
1277
|
+
schema = schema?.[PROPERTIES_KEY]?.[leafPath];
|
|
1292
1278
|
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1293
1279
|
}
|
|
1294
1280
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1295
|
-
if (schema && (
|
|
1296
|
-
const xxx =
|
|
1281
|
+
if (schema && (ONE_OF_KEY in schema || ANY_OF_KEY in schema)) {
|
|
1282
|
+
const xxx = ONE_OF_KEY in schema ? ONE_OF_KEY : ANY_OF_KEY;
|
|
1297
1283
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
1298
1284
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1299
1285
|
}
|
|
@@ -1302,10 +1288,10 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1302
1288
|
}
|
|
1303
1289
|
function getCustomRenderComponent(render, registry) {
|
|
1304
1290
|
let customRenderer = render;
|
|
1305
|
-
if (
|
|
1291
|
+
if (typeof customRenderer === "string") {
|
|
1306
1292
|
customRenderer = lookupFromFormContext(registry, customRenderer);
|
|
1307
1293
|
}
|
|
1308
|
-
if (
|
|
1294
|
+
if (typeof customRenderer === "function") {
|
|
1309
1295
|
return customRenderer;
|
|
1310
1296
|
}
|
|
1311
1297
|
return null;
|
|
@@ -1315,23 +1301,21 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1315
1301
|
let UIComponent = null;
|
|
1316
1302
|
let uiProps = {};
|
|
1317
1303
|
let rendered;
|
|
1318
|
-
if (
|
|
1304
|
+
if (typeof gridSchema === "string" || gridSchema === void 0) {
|
|
1319
1305
|
name = gridSchema ?? "";
|
|
1320
1306
|
} else {
|
|
1321
1307
|
const { name: innerName = "", render, ...innerProps } = gridSchema;
|
|
1322
1308
|
name = innerName;
|
|
1323
1309
|
uiProps = innerProps;
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
1331
|
-
}
|
|
1310
|
+
Object.entries(uiProps).forEach(([key, prop]) => {
|
|
1311
|
+
if (typeof prop === "string") {
|
|
1312
|
+
const match = LOOKUP_REGEX.exec(prop);
|
|
1313
|
+
if (Array.isArray(match) && match.length > 1) {
|
|
1314
|
+
const lookupName = match[1];
|
|
1315
|
+
uiProps[key] = lookupFromFormContext(registry, lookupName, lookupName);
|
|
1332
1316
|
}
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1335
1319
|
UIComponent = getCustomRenderComponent(render, registry);
|
|
1336
1320
|
if (!innerName && UIComponent) {
|
|
1337
1321
|
rendered = /* @__PURE__ */ jsx5(UIComponent, { ...innerProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent });
|
|
@@ -1359,7 +1343,7 @@ function LayoutGridCondition(props) {
|
|
|
1359
1343
|
const { formData, registry } = layoutGridFieldProps;
|
|
1360
1344
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:condition" /* CONDITION */, registry);
|
|
1361
1345
|
const { operator, field = "", value } = gridProps;
|
|
1362
|
-
const fieldData =
|
|
1346
|
+
const fieldData = getByPath(formData, toPath(field), null);
|
|
1363
1347
|
if (conditionMatches(operator, fieldData, value)) {
|
|
1364
1348
|
return /* @__PURE__ */ jsx5(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children });
|
|
1365
1349
|
}
|
|
@@ -1433,6 +1417,7 @@ function LayoutGridFieldComponent(props) {
|
|
|
1433
1417
|
if (schema) {
|
|
1434
1418
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1435
1419
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1420
|
+
const namePath = toPath(name);
|
|
1436
1421
|
return /* @__PURE__ */ jsx5(
|
|
1437
1422
|
Field,
|
|
1438
1423
|
{
|
|
@@ -1443,9 +1428,9 @@ function LayoutGridFieldComponent(props) {
|
|
|
1443
1428
|
readonly: uiReadonly,
|
|
1444
1429
|
schema,
|
|
1445
1430
|
uiSchema: fieldUiSchema,
|
|
1446
|
-
errorSchema:
|
|
1431
|
+
errorSchema: getByPath(errorSchema, namePath),
|
|
1447
1432
|
fieldPathId: memoFieldPathId,
|
|
1448
|
-
formData:
|
|
1433
|
+
formData: getByPath(formData, namePath),
|
|
1449
1434
|
onChange,
|
|
1450
1435
|
onBlur,
|
|
1451
1436
|
onFocus,
|
|
@@ -1535,6 +1520,8 @@ function LayoutHeaderField(props) {
|
|
|
1535
1520
|
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1536
1521
|
import { useState as useState4, useEffect } from "react";
|
|
1537
1522
|
import {
|
|
1523
|
+
getByPath as getByPath2,
|
|
1524
|
+
setByPath as setByPath2,
|
|
1538
1525
|
ANY_OF_KEY as ANY_OF_KEY2,
|
|
1539
1526
|
CONST_KEY,
|
|
1540
1527
|
DEFAULT_KEY,
|
|
@@ -1546,31 +1533,27 @@ import {
|
|
|
1546
1533
|
optionsList as optionsList3,
|
|
1547
1534
|
PROPERTIES_KEY as PROPERTIES_KEY2,
|
|
1548
1535
|
getTemplate as getTemplate6,
|
|
1536
|
+
getPropertySchema as getPropertySchema2,
|
|
1549
1537
|
getUiOptions as getUiOptions7,
|
|
1550
|
-
getWidget as getWidget3
|
|
1538
|
+
getWidget as getWidget3,
|
|
1539
|
+
noop
|
|
1551
1540
|
} from "@rjsf/utils";
|
|
1552
|
-
import get2 from "lodash/get";
|
|
1553
|
-
import has2 from "lodash/has";
|
|
1554
|
-
import isEmpty2 from "lodash/isEmpty";
|
|
1555
|
-
import noop from "lodash/noop";
|
|
1556
|
-
import omit from "lodash/omit";
|
|
1557
|
-
import set3 from "lodash/set";
|
|
1558
1541
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1559
1542
|
function getSelectedOption(options, selectorField, value) {
|
|
1560
1543
|
const defaultValue = "!@#!@$@#$!@$#";
|
|
1561
1544
|
const schemaOptions = options.map(({ schema }) => schema);
|
|
1562
1545
|
return schemaOptions.find((option) => {
|
|
1563
|
-
const selector =
|
|
1564
|
-
const result =
|
|
1546
|
+
const selector = option[PROPERTIES_KEY2]?.[selectorField];
|
|
1547
|
+
const result = getByPath2(selector, DEFAULT_KEY, getByPath2(selector, CONST_KEY, defaultValue));
|
|
1565
1548
|
return result === value;
|
|
1566
1549
|
});
|
|
1567
1550
|
}
|
|
1568
1551
|
function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
|
|
1569
1552
|
const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1570
1553
|
let tempSchema = schema;
|
|
1571
|
-
if (
|
|
1554
|
+
if (ONE_OF_KEY2 in schema) {
|
|
1572
1555
|
tempSchema = { ...schema, [ONE_OF_KEY2]: realOptions };
|
|
1573
|
-
} else if (
|
|
1556
|
+
} else if (ANY_OF_KEY2 in schema) {
|
|
1574
1557
|
tempSchema = { ...schema, [ANY_OF_KEY2]: realOptions };
|
|
1575
1558
|
}
|
|
1576
1559
|
const enumOptions = optionsList3(tempSchema, uiSchema);
|
|
@@ -1601,7 +1584,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1601
1584
|
} = props;
|
|
1602
1585
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1603
1586
|
const [enumOptions, setEnumOptions] = useState4(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1604
|
-
const id =
|
|
1587
|
+
const id = fieldPathId[ID_KEY3];
|
|
1605
1588
|
const discriminator = getDiscriminatorFieldFromSchema2(schema);
|
|
1606
1589
|
const FieldErrorTemplate2 = getTemplate6("FieldErrorTemplate", registry, options);
|
|
1607
1590
|
const FieldTemplate2 = getTemplate6("FieldTemplate", registry, options);
|
|
@@ -1623,14 +1606,15 @@ function LayoutMultiSchemaField(props) {
|
|
|
1623
1606
|
if (!selectorField) {
|
|
1624
1607
|
throw new Error("No selector field provided for the LayoutMultiSchemaField");
|
|
1625
1608
|
}
|
|
1626
|
-
const selectedOption =
|
|
1627
|
-
let optionSchema =
|
|
1609
|
+
const selectedOption = getByPath2(formData, selectorField);
|
|
1610
|
+
let optionSchema = getPropertySchema2(enumOptions[0]?.schema, selectorField);
|
|
1628
1611
|
const option = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1629
1612
|
optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
|
|
1630
1613
|
const Widget = getWidget3(optionSchema, widget, widgets2);
|
|
1631
1614
|
const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
|
|
1632
|
-
const rawErrors =
|
|
1633
|
-
const fieldErrorSchema =
|
|
1615
|
+
const rawErrors = errorSchema?.[ERRORS_KEY] ?? [];
|
|
1616
|
+
const fieldErrorSchema = { ...errorSchema };
|
|
1617
|
+
delete fieldErrorSchema[ERRORS_KEY];
|
|
1634
1618
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1635
1619
|
const onOptionChange = (opt) => {
|
|
1636
1620
|
if (disabled || readonly) {
|
|
@@ -1643,7 +1627,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1643
1627
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1644
1628
|
}
|
|
1645
1629
|
if (newFormData) {
|
|
1646
|
-
|
|
1630
|
+
setByPath2(newFormData, selectorField, opt);
|
|
1647
1631
|
}
|
|
1648
1632
|
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1649
1633
|
};
|
|
@@ -1656,7 +1640,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1656
1640
|
id,
|
|
1657
1641
|
schema,
|
|
1658
1642
|
label: (title || schema.title) ?? "",
|
|
1659
|
-
disabled: disabled || Array.isArray(enumOptions) &&
|
|
1643
|
+
disabled: disabled || Array.isArray(enumOptions) && enumOptions.length === 0,
|
|
1660
1644
|
uiSchema,
|
|
1661
1645
|
required,
|
|
1662
1646
|
readonly: !!readonly,
|
|
@@ -1674,7 +1658,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1674
1658
|
name,
|
|
1675
1659
|
schema,
|
|
1676
1660
|
label: (title || schema.title) ?? "",
|
|
1677
|
-
disabled: disabled || Array.isArray(enumOptions) &&
|
|
1661
|
+
disabled: disabled || Array.isArray(enumOptions) && enumOptions.length === 0,
|
|
1678
1662
|
uiSchema,
|
|
1679
1663
|
autofocus,
|
|
1680
1664
|
readonly,
|
|
@@ -1702,7 +1686,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1702
1686
|
import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useRef as useRef2, useState as useState5 } from "react";
|
|
1703
1687
|
import {
|
|
1704
1688
|
ANY_OF_KEY as ANY_OF_KEY3,
|
|
1705
|
-
deepEquals,
|
|
1689
|
+
deepEquals as deepEquals2,
|
|
1706
1690
|
ERRORS_KEY as ERRORS_KEY2,
|
|
1707
1691
|
getDiscriminatorFieldFromSchema as getDiscriminatorFieldFromSchema3,
|
|
1708
1692
|
getTemplate as getTemplate7,
|
|
@@ -1715,15 +1699,12 @@ import {
|
|
|
1715
1699
|
shouldRenderOptionalField as shouldRenderOptionalField2,
|
|
1716
1700
|
TranslatableString as TranslatableString4
|
|
1717
1701
|
} from "@rjsf/utils";
|
|
1718
|
-
import get3 from "lodash/get";
|
|
1719
|
-
import isEmpty3 from "lodash/isEmpty";
|
|
1720
|
-
import omit2 from "lodash/omit";
|
|
1721
1702
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1722
1703
|
function AnyOfField(props) {
|
|
1723
1704
|
const {
|
|
1724
1705
|
name,
|
|
1725
1706
|
disabled = false,
|
|
1726
|
-
errorSchema
|
|
1707
|
+
errorSchema,
|
|
1727
1708
|
formData,
|
|
1728
1709
|
fieldPathId,
|
|
1729
1710
|
onBlur,
|
|
@@ -1755,7 +1736,7 @@ function AnyOfField(props) {
|
|
|
1755
1736
|
const prevFieldId = prevFieldIdRef.current;
|
|
1756
1737
|
prevFormDataRef.current = formData;
|
|
1757
1738
|
prevFieldIdRef.current = fieldPathId.$id;
|
|
1758
|
-
if (!
|
|
1739
|
+
if (!deepEquals2(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
|
|
1759
1740
|
if (skipNextOptionRecalculation.current) {
|
|
1760
1741
|
skipNextOptionRecalculation.current = false;
|
|
1761
1742
|
return;
|
|
@@ -1813,8 +1794,9 @@ function AnyOfField(props) {
|
|
|
1813
1794
|
...uiOptions
|
|
1814
1795
|
} = getUiOptions8(uiSchema, globalUiOptions);
|
|
1815
1796
|
const Widget = getWidget4({ type: "number" }, widget, widgets2);
|
|
1816
|
-
const rawErrors =
|
|
1817
|
-
const fieldErrorSchema =
|
|
1797
|
+
const rawErrors = errorSchema?.[ERRORS_KEY2] ?? [];
|
|
1798
|
+
const fieldErrorSchema = { ...errorSchema };
|
|
1799
|
+
delete fieldErrorSchema[ERRORS_KEY2];
|
|
1818
1800
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1819
1801
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1820
1802
|
let optionSchema;
|
|
@@ -1865,7 +1847,7 @@ function AnyOfField(props) {
|
|
|
1865
1847
|
onChange: onOptionChange,
|
|
1866
1848
|
onBlur,
|
|
1867
1849
|
onFocus,
|
|
1868
|
-
disabled: disabled ||
|
|
1850
|
+
disabled: disabled || enumOptions.length === 0,
|
|
1869
1851
|
multiple: false,
|
|
1870
1852
|
rawErrors,
|
|
1871
1853
|
errorSchema: fieldErrorSchema,
|
|
@@ -1954,9 +1936,14 @@ var NumberField_default = NumberField;
|
|
|
1954
1936
|
// src/components/fields/ObjectField.tsx
|
|
1955
1937
|
import { memo as memo2, useCallback as useCallback5, useMemo as useMemo4, useRef as useRef3, useState as useState7 } from "react";
|
|
1956
1938
|
import {
|
|
1939
|
+
getByPath as getByPath3,
|
|
1940
|
+
hasByPath,
|
|
1941
|
+
setByPath as setByPath3,
|
|
1957
1942
|
ADDITIONAL_PROPERTY_FLAG,
|
|
1958
1943
|
ANY_OF_KEY as ANY_OF_KEY4,
|
|
1944
|
+
deepEquals as deepEquals3,
|
|
1959
1945
|
getTemplate as getTemplate8,
|
|
1946
|
+
getPropertySchema as getPropertySchema3,
|
|
1960
1947
|
getUiOptions as getUiOptions10,
|
|
1961
1948
|
isFormDataAvailable as isFormDataAvailable3,
|
|
1962
1949
|
orderProperties,
|
|
@@ -1964,14 +1951,10 @@ import {
|
|
|
1964
1951
|
toFieldPathId as toFieldPathId4,
|
|
1965
1952
|
useDeepCompareMemo as useDeepCompareMemo4,
|
|
1966
1953
|
ONE_OF_KEY as ONE_OF_KEY4,
|
|
1967
|
-
PROPERTIES_KEY as PROPERTIES_KEY3,
|
|
1968
1954
|
REF_KEY,
|
|
1955
|
+
isObject as isObject4,
|
|
1969
1956
|
TranslatableString as TranslatableString5
|
|
1970
1957
|
} from "@rjsf/utils";
|
|
1971
|
-
import get4 from "lodash/get";
|
|
1972
|
-
import has3 from "lodash/has";
|
|
1973
|
-
import isObject4 from "lodash/isObject";
|
|
1974
|
-
import set4 from "lodash/set";
|
|
1975
1958
|
import { Markdown } from "markdown-to-jsx/react";
|
|
1976
1959
|
|
|
1977
1960
|
// src/components/constants.ts
|
|
@@ -2035,12 +2018,12 @@ function ObjectFieldPropertyFn(props) {
|
|
|
2035
2018
|
const onPropertyChange = useCallback5(
|
|
2036
2019
|
(value, path, newErrorSchema, id) => {
|
|
2037
2020
|
let normalizedValue = value;
|
|
2038
|
-
if (value === void 0 && addedByAdditionalProperties) {
|
|
2021
|
+
if (value === void 0 && addedByAdditionalProperties && deepEquals3(path, innerFieldIdPathId.path)) {
|
|
2039
2022
|
normalizedValue = "";
|
|
2040
2023
|
}
|
|
2041
2024
|
onChange(normalizedValue, path, newErrorSchema, id);
|
|
2042
2025
|
},
|
|
2043
|
-
[onChange, addedByAdditionalProperties]
|
|
2026
|
+
[onChange, addedByAdditionalProperties, innerFieldIdPathId]
|
|
2044
2027
|
);
|
|
2045
2028
|
const onKeyRename = useCallback5(
|
|
2046
2029
|
(value) => {
|
|
@@ -2135,7 +2118,7 @@ function ObjectField(props) {
|
|
|
2135
2118
|
const { duplicateKeySuffixSeparator = "-" } = getUiOptions10(uiSchema, globalUiOptions);
|
|
2136
2119
|
let index = 0;
|
|
2137
2120
|
let newKey = preferredKey;
|
|
2138
|
-
while (
|
|
2121
|
+
while (hasByPath(existingFormData, newKey)) {
|
|
2139
2122
|
index += 1;
|
|
2140
2123
|
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
2141
2124
|
}
|
|
@@ -2150,7 +2133,7 @@ function ObjectField(props) {
|
|
|
2150
2133
|
const newFormData = { ...formData };
|
|
2151
2134
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
2152
2135
|
if (schema.patternProperties) {
|
|
2153
|
-
|
|
2136
|
+
setByPath3(newFormData, newKey, null);
|
|
2154
2137
|
} else {
|
|
2155
2138
|
let type = void 0;
|
|
2156
2139
|
let constValue = void 0;
|
|
@@ -2171,7 +2154,7 @@ function ObjectField(props) {
|
|
|
2171
2154
|
}
|
|
2172
2155
|
}
|
|
2173
2156
|
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
2174
|
-
|
|
2157
|
+
setByPath3(newFormData, newKey, newValue);
|
|
2175
2158
|
}
|
|
2176
2159
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
2177
2160
|
lastRenamedProperty.current.currentKey = newKey;
|
|
@@ -2247,11 +2230,11 @@ function ObjectField(props) {
|
|
|
2247
2230
|
{
|
|
2248
2231
|
propertyName,
|
|
2249
2232
|
required: isRequired(schema, propertyName),
|
|
2250
|
-
schema:
|
|
2233
|
+
schema: getPropertySchema3(schema, propertyName),
|
|
2251
2234
|
uiSchema: fieldUiSchema,
|
|
2252
|
-
errorSchema:
|
|
2235
|
+
errorSchema: getByPath3(errorSchema, propertyName),
|
|
2253
2236
|
fieldPathId: childFieldPathId,
|
|
2254
|
-
formData:
|
|
2237
|
+
formData: getByPath3(formData, propertyName),
|
|
2255
2238
|
handleKeyRename,
|
|
2256
2239
|
handleRemoveProperty,
|
|
2257
2240
|
addedByAdditionalProperties,
|
|
@@ -2362,7 +2345,7 @@ import { useCallback as useCallback6, memo as memo3 } from "react";
|
|
|
2362
2345
|
import {
|
|
2363
2346
|
ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
|
|
2364
2347
|
ANY_OF_KEY as ANY_OF_KEY5,
|
|
2365
|
-
deepEquals as
|
|
2348
|
+
deepEquals as deepEquals4,
|
|
2366
2349
|
descriptionId,
|
|
2367
2350
|
getSchemaType as getSchemaType2,
|
|
2368
2351
|
getTemplate as getTemplate10,
|
|
@@ -2375,11 +2358,10 @@ import {
|
|
|
2375
2358
|
shallowEquals,
|
|
2376
2359
|
shouldRenderOptionalField as shouldRenderOptionalField4,
|
|
2377
2360
|
toFieldPathId as toFieldPathId5,
|
|
2361
|
+
isObject as isObject5,
|
|
2378
2362
|
TranslatableString as TranslatableString7,
|
|
2379
2363
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY2
|
|
2380
2364
|
} from "@rjsf/utils";
|
|
2381
|
-
import isObject5 from "lodash/isObject";
|
|
2382
|
-
import omit3 from "lodash/omit";
|
|
2383
2365
|
import { Fragment, jsx as jsx12, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
2384
2366
|
var COMPONENT_TYPES = {
|
|
2385
2367
|
array: "ArrayField",
|
|
@@ -2490,9 +2472,19 @@ function SchemaFieldRender(props) {
|
|
|
2490
2472
|
};
|
|
2491
2473
|
}
|
|
2492
2474
|
const { __errors, ...fieldErrorSchema } = errorSchema || {};
|
|
2493
|
-
const
|
|
2475
|
+
const {
|
|
2476
|
+
"ui:classNames": consumedUiClassNames,
|
|
2477
|
+
classNames: consumedClassNames,
|
|
2478
|
+
"ui:style": consumedUiStyle,
|
|
2479
|
+
...fieldUiSchema
|
|
2480
|
+
} = uiSchema;
|
|
2494
2481
|
if (UI_OPTIONS_KEY2 in fieldUiSchema) {
|
|
2495
|
-
|
|
2482
|
+
const {
|
|
2483
|
+
classNames: consumedOptionClassNames,
|
|
2484
|
+
style: consumedOptionStyle,
|
|
2485
|
+
...fieldUiOptions
|
|
2486
|
+
} = fieldUiSchema[UI_OPTIONS_KEY2];
|
|
2487
|
+
fieldUiSchema[UI_OPTIONS_KEY2] = fieldUiOptions;
|
|
2496
2488
|
}
|
|
2497
2489
|
const field = /* @__PURE__ */ jsx12(
|
|
2498
2490
|
FieldComponent,
|
|
@@ -2620,7 +2612,7 @@ var SchemaField = memo3(SchemaFieldRender, (prevProps, nextProps) => {
|
|
|
2620
2612
|
if (experimental_componentUpdateStrategy === "shallow") {
|
|
2621
2613
|
return shallowEquals(prevProps, nextProps);
|
|
2622
2614
|
}
|
|
2623
|
-
return
|
|
2615
|
+
return deepEquals4(prevProps, nextProps);
|
|
2624
2616
|
});
|
|
2625
2617
|
var SchemaField_default = SchemaField;
|
|
2626
2618
|
|
|
@@ -3013,7 +3005,7 @@ function BaseInputTemplate(props) {
|
|
|
3013
3005
|
(e) => {
|
|
3014
3006
|
e.preventDefault();
|
|
3015
3007
|
e.stopPropagation();
|
|
3016
|
-
onChange(options.emptyValue
|
|
3008
|
+
onChange(options.emptyValue);
|
|
3017
3009
|
},
|
|
3018
3010
|
[onChange, options.emptyValue]
|
|
3019
3011
|
);
|
|
@@ -3738,14 +3730,15 @@ function CheckboxWidget({
|
|
|
3738
3730
|
onFocus,
|
|
3739
3731
|
onChange,
|
|
3740
3732
|
registry,
|
|
3741
|
-
htmlName
|
|
3733
|
+
htmlName,
|
|
3734
|
+
required
|
|
3742
3735
|
}) {
|
|
3743
3736
|
const DescriptionFieldTemplate = getTemplate18(
|
|
3744
3737
|
"DescriptionFieldTemplate",
|
|
3745
3738
|
registry,
|
|
3746
3739
|
options
|
|
3747
3740
|
);
|
|
3748
|
-
const
|
|
3741
|
+
const trueValueRequired = schemaRequiresTrueValue(schema) && required;
|
|
3749
3742
|
const handleChange = useCallback10(
|
|
3750
3743
|
(event) => onChange(event.target.checked),
|
|
3751
3744
|
[onChange]
|
|
@@ -3789,7 +3782,13 @@ function CheckboxWidget({
|
|
|
3789
3782
|
"aria-describedby": ariaDescribedByIds3(id)
|
|
3790
3783
|
}
|
|
3791
3784
|
),
|
|
3792
|
-
labelValue(
|
|
3785
|
+
labelValue(
|
|
3786
|
+
/* @__PURE__ */ jsxs18("span", { children: [
|
|
3787
|
+
label,
|
|
3788
|
+
trueValueRequired && /* @__PURE__ */ jsx44("span", { className: "required", children: "*" })
|
|
3789
|
+
] }),
|
|
3790
|
+
hideLabel
|
|
3791
|
+
)
|
|
3793
3792
|
] })
|
|
3794
3793
|
] });
|
|
3795
3794
|
}
|
|
@@ -4032,7 +4031,6 @@ function RatingWidget({
|
|
|
4032
4031
|
required,
|
|
4033
4032
|
disabled,
|
|
4034
4033
|
readonly,
|
|
4035
|
-
autofocus,
|
|
4036
4034
|
onChange,
|
|
4037
4035
|
onFocus,
|
|
4038
4036
|
onBlur,
|
|
@@ -4389,8 +4387,16 @@ function getDefaultRegistry() {
|
|
|
4389
4387
|
// src/components/Form.tsx
|
|
4390
4388
|
import { jsx as jsx61, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4391
4389
|
function toIChangeEvent(state, status) {
|
|
4390
|
+
const { schema, uiSchema, fieldPathId, schemaUtils, formData, edit, errors, errorSchema } = state;
|
|
4392
4391
|
return {
|
|
4393
|
-
|
|
4392
|
+
schema,
|
|
4393
|
+
uiSchema,
|
|
4394
|
+
fieldPathId,
|
|
4395
|
+
schemaUtils,
|
|
4396
|
+
formData,
|
|
4397
|
+
edit,
|
|
4398
|
+
errors,
|
|
4399
|
+
errorSchema,
|
|
4394
4400
|
...status !== void 0 && { status }
|
|
4395
4401
|
};
|
|
4396
4402
|
}
|
|
@@ -4451,7 +4457,7 @@ var Form = class _Form extends Component {
|
|
|
4451
4457
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4452
4458
|
prevExtraErrors: props.extraErrors
|
|
4453
4459
|
};
|
|
4454
|
-
if (onChange && !
|
|
4460
|
+
if (onChange && !deepEquals5(this.state.formData, formData)) {
|
|
4455
4461
|
onChange(toIChangeEvent(this.state));
|
|
4456
4462
|
}
|
|
4457
4463
|
this.formElement = createRef();
|
|
@@ -4475,12 +4481,12 @@ var Form = class _Form extends Component {
|
|
|
4475
4481
|
* with a flag indicating that an update is not necessary.
|
|
4476
4482
|
*/
|
|
4477
4483
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4478
|
-
if (!
|
|
4484
|
+
if (!deepEquals5(this.props, prevProps)) {
|
|
4479
4485
|
const formDataChangedFields = getChangedFields(this.props.formData, prevProps.formData);
|
|
4480
4486
|
const stateDataChangedFields = getChangedFields(this.props.formData, this.state.formData);
|
|
4481
|
-
const isSchemaChanged = !
|
|
4482
|
-
const isFormDataChanged = formDataChangedFields.length > 0 || !
|
|
4483
|
-
const isStateDataChanged = stateDataChangedFields.length > 0 || !
|
|
4487
|
+
const isSchemaChanged = !deepEquals5(prevProps.schema, this.props.schema);
|
|
4488
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !deepEquals5(prevProps.formData, this.props.formData);
|
|
4489
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !deepEquals5(this.state.formData, this.props.formData);
|
|
4484
4490
|
const nextState = this.getStateFromProps(
|
|
4485
4491
|
this.props,
|
|
4486
4492
|
this.props.formData,
|
|
@@ -4489,11 +4495,13 @@ var Form = class _Form extends Component {
|
|
|
4489
4495
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4490
4496
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4491
4497
|
isSchemaChanged,
|
|
4492
|
-
|
|
4498
|
+
// Only the error clearing needs the path of each changed field, and it runs only when live validation does
|
|
4499
|
+
// not, so the walk that produces them is left for `getStateFromProps` to ask for
|
|
4500
|
+
() => getChangedFields(this.props.formData, prevProps.formData, true),
|
|
4493
4501
|
// Skip live validation for this request if no form data has changed from the last state
|
|
4494
4502
|
!isStateDataChanged
|
|
4495
4503
|
);
|
|
4496
|
-
const shouldUpdate = !
|
|
4504
|
+
const shouldUpdate = !deepEquals5(nextState, prevState);
|
|
4497
4505
|
return { nextState, shouldUpdate };
|
|
4498
4506
|
}
|
|
4499
4507
|
return { shouldUpdate: false };
|
|
@@ -4513,13 +4521,13 @@ var Form = class _Form extends Component {
|
|
|
4513
4521
|
componentDidUpdate(_, prevState, snapshot) {
|
|
4514
4522
|
if (snapshot.shouldUpdate) {
|
|
4515
4523
|
const { nextState } = snapshot;
|
|
4516
|
-
const nextStateDiffersFromProps = !
|
|
4524
|
+
const nextStateDiffersFromProps = !deepEquals5(nextState.formData, this.props.formData);
|
|
4517
4525
|
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
4518
4526
|
this.isProcessingUserChange = false;
|
|
4519
4527
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
4520
4528
|
return;
|
|
4521
4529
|
}
|
|
4522
|
-
if (nextStateDiffersFromProps && !
|
|
4530
|
+
if (nextStateDiffersFromProps && !deepEquals5(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
4523
4531
|
this.props.onChange(toIChangeEvent(nextState));
|
|
4524
4532
|
}
|
|
4525
4533
|
this.setState(nextState);
|
|
@@ -4533,12 +4541,13 @@ var Form = class _Form extends Component {
|
|
|
4533
4541
|
* @param inputFormData - The new or current data for the `Form`
|
|
4534
4542
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4535
4543
|
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
4536
|
-
* @param [
|
|
4544
|
+
* @param [getFormDataChangedFields=() => []] - Optional function returning the path of each `formData` field that
|
|
4545
|
+
* changed, only called when those paths are needed, which is when live validation is not going to run
|
|
4537
4546
|
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
4538
4547
|
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
4539
4548
|
* @returns - The new state for the `Form`
|
|
4540
4549
|
*/
|
|
4541
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false,
|
|
4550
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, getFormDataChangedFields = () => [], skipLiveValidate = false, shouldSanitize = false) {
|
|
4542
4551
|
const state = this.state || {};
|
|
4543
4552
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4544
4553
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -4585,13 +4594,13 @@ var Form = class _Form extends Component {
|
|
|
4585
4594
|
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4586
4595
|
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4587
4596
|
);
|
|
4588
|
-
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !
|
|
4597
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !deepEquals5(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4589
4598
|
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4590
4599
|
computedRetrievedSchema,
|
|
4591
4600
|
state.retrievedSchema,
|
|
4592
4601
|
formData
|
|
4593
4602
|
);
|
|
4594
|
-
wasSanitized = !
|
|
4603
|
+
wasSanitized = !deepEquals5(sanitizedFormData, formData);
|
|
4595
4604
|
if (wasSanitized) {
|
|
4596
4605
|
formData = sanitizedFormData;
|
|
4597
4606
|
defaultsFormData = sanitizedFormData;
|
|
@@ -4643,24 +4652,30 @@ var Form = class _Form extends Component {
|
|
|
4643
4652
|
const currentErrors = getCurrentErrors();
|
|
4644
4653
|
errors = currentErrors.errors;
|
|
4645
4654
|
errorSchema = currentErrors.errorSchema;
|
|
4646
|
-
if (
|
|
4647
|
-
const
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4655
|
+
if (!mustValidate) {
|
|
4656
|
+
const formDataChangedFields = getFormDataChangedFields();
|
|
4657
|
+
if (formDataChangedFields.length > 0) {
|
|
4658
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, path) => {
|
|
4659
|
+
const pathOfField = toPath2(path);
|
|
4660
|
+
for (let i = 1; i < pathOfField.length; i++) {
|
|
4661
|
+
setByPath4(acc, [...pathOfField.slice(0, i), ERRORS_KEY3], void 0, true);
|
|
4662
|
+
}
|
|
4663
|
+
return setByPath4(acc, pathOfField, void 0, true);
|
|
4664
|
+
}, {});
|
|
4665
|
+
schemaValidationErrorSchema = mergeObjects(
|
|
4666
|
+
currentErrors.errorSchema,
|
|
4667
|
+
newErrorSchema,
|
|
4668
|
+
"preventDuplicates"
|
|
4669
|
+
);
|
|
4670
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4671
|
+
}
|
|
4657
4672
|
}
|
|
4658
4673
|
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4659
4674
|
errors = mergedErrors.errors;
|
|
4660
4675
|
errorSchema = mergedErrors.errorSchema;
|
|
4661
4676
|
}
|
|
4662
4677
|
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4663
|
-
const registry =
|
|
4678
|
+
const registry = deepEquals5(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4664
4679
|
const fieldPathId = state.fieldPathId && state.fieldPathId?.[ID_KEY6] === registry.globalFormOptions.idPrefix ? state.fieldPathId : toFieldPathId6("", registry.globalFormOptions);
|
|
4665
4680
|
const nextState = {
|
|
4666
4681
|
schemaUtils,
|
|
@@ -4851,14 +4866,14 @@ var Form = class _Form extends Component {
|
|
|
4851
4866
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4852
4867
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4853
4868
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4854
|
-
let formData = isRootPath ? newValue :
|
|
4869
|
+
let formData = isRootPath ? newValue : structuredClone(oldFormData);
|
|
4855
4870
|
const hasOnlyUndefinedValues = isObject6(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4856
4871
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
4857
4872
|
const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
|
|
4858
4873
|
if (isObject6(formData) || Array.isArray(formData)) {
|
|
4859
4874
|
let plainLeafWasCleared = false;
|
|
4860
4875
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4861
|
-
|
|
4876
|
+
unsetByPath(formData, path);
|
|
4862
4877
|
} else if (!isRootPath) {
|
|
4863
4878
|
let valueForPath = newValue;
|
|
4864
4879
|
if (newValue === void 0) {
|
|
@@ -4875,9 +4890,9 @@ var Form = class _Form extends Component {
|
|
|
4875
4890
|
}
|
|
4876
4891
|
}
|
|
4877
4892
|
if (plainLeafWasCleared) {
|
|
4878
|
-
|
|
4893
|
+
setByPath4(formData, path, void 0);
|
|
4879
4894
|
} else {
|
|
4880
|
-
|
|
4895
|
+
setByPath4(formData, path, valueForPath);
|
|
4881
4896
|
}
|
|
4882
4897
|
}
|
|
4883
4898
|
const shouldSanitize = retrievedSchema && !isRootPath && !isObject6(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
@@ -4893,7 +4908,7 @@ var Form = class _Form extends Component {
|
|
|
4893
4908
|
formData = newState.formData;
|
|
4894
4909
|
retrievedSchema = newState.retrievedSchema;
|
|
4895
4910
|
if (plainLeafWasCleared && formData) {
|
|
4896
|
-
|
|
4911
|
+
setByPath4(formData, path, void 0);
|
|
4897
4912
|
}
|
|
4898
4913
|
}
|
|
4899
4914
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
@@ -4904,11 +4919,11 @@ var Form = class _Form extends Component {
|
|
|
4904
4919
|
state = { ...state, formData: newFormData };
|
|
4905
4920
|
}
|
|
4906
4921
|
if (newErrorSchema) {
|
|
4907
|
-
const oldValidationError = !isRootPath ?
|
|
4908
|
-
if (
|
|
4922
|
+
const oldValidationError = !isRootPath ? getByPath4(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
4923
|
+
if (oldValidationError && Object.keys(oldValidationError).length > 0) {
|
|
4909
4924
|
if (!isRootPath) {
|
|
4910
|
-
mergeBaseErrorSchema =
|
|
4911
|
-
|
|
4925
|
+
mergeBaseErrorSchema = structuredClone(schemaValidationErrorSchema);
|
|
4926
|
+
setByPath4(mergeBaseErrorSchema, path, newErrorSchema, true);
|
|
4912
4927
|
} else {
|
|
4913
4928
|
mergeBaseErrorSchema = newErrorSchema;
|
|
4914
4929
|
}
|
|
@@ -4917,15 +4932,15 @@ var Form = class _Form extends Component {
|
|
|
4917
4932
|
customErrors = new ErrorSchemaBuilder();
|
|
4918
4933
|
}
|
|
4919
4934
|
if (isRootPath) {
|
|
4920
|
-
const pathErrors =
|
|
4935
|
+
const pathErrors = newErrorSchema[ERRORS_KEY3];
|
|
4921
4936
|
if (pathErrors) {
|
|
4922
4937
|
customErrors.setErrors(pathErrors);
|
|
4923
4938
|
}
|
|
4924
4939
|
} else {
|
|
4925
|
-
|
|
4940
|
+
setByPath4(customErrors.ErrorSchema, path, newErrorSchema, true);
|
|
4926
4941
|
}
|
|
4927
4942
|
}
|
|
4928
|
-
} else if (customErrors &&
|
|
4943
|
+
} else if (customErrors && getByPath4(customErrors.ErrorSchema, [...path, ERRORS_KEY3])) {
|
|
4929
4944
|
customErrors.clearErrors(path);
|
|
4930
4945
|
}
|
|
4931
4946
|
if (mustValidate && this.pendingChanges.length === 1) {
|
|
@@ -4965,7 +4980,7 @@ var Form = class _Form extends Component {
|
|
|
4965
4980
|
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4966
4981
|
*/
|
|
4967
4982
|
updateRetrievedSchema(retrievedSchema) {
|
|
4968
|
-
const isTheSame =
|
|
4983
|
+
const isTheSame = deepEquals5(retrievedSchema, this.state?.retrievedSchema);
|
|
4969
4984
|
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
4970
4985
|
}
|
|
4971
4986
|
/**
|
|
@@ -5031,9 +5046,9 @@ var Form = class _Form extends Component {
|
|
|
5031
5046
|
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
5032
5047
|
}
|
|
5033
5048
|
const hasChanges = Object.keys(state).filter((key) => !key.startsWith("schemaValidation")).some((key) => {
|
|
5034
|
-
const oldData =
|
|
5035
|
-
const newData =
|
|
5036
|
-
return !
|
|
5049
|
+
const oldData = this.state[key];
|
|
5050
|
+
const newData = state[key];
|
|
5051
|
+
return !deepEquals5(oldData, newData);
|
|
5037
5052
|
});
|
|
5038
5053
|
this.setState(state, () => {
|
|
5039
5054
|
if (onChange && hasChanges) {
|
|
@@ -5160,12 +5175,8 @@ var Form = class _Form extends Component {
|
|
|
5160
5175
|
focusOnError(error) {
|
|
5161
5176
|
const { idPrefix = "root", idSeparator = "_" } = this.props;
|
|
5162
5177
|
const { property } = error;
|
|
5163
|
-
const path =
|
|
5164
|
-
|
|
5165
|
-
path[0] = idPrefix;
|
|
5166
|
-
} else {
|
|
5167
|
-
path.unshift(idPrefix);
|
|
5168
|
-
}
|
|
5178
|
+
const path = toPath2(property ?? "");
|
|
5179
|
+
path.unshift(idPrefix);
|
|
5169
5180
|
const elementId = path.join(idSeparator);
|
|
5170
5181
|
let field = this.formElement.current.elements[elementId];
|
|
5171
5182
|
if (!field) {
|