@rjsf/core 6.7.1 → 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 +199 -155
- package/dist/index.cjs +195 -193
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +225 -201
- 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.d.ts.map +1 -1
- package/lib/components/widgets/TimeWidget.js +16 -3
- 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/TimeWidget.tsx +18 -3
- 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.cjs
CHANGED
|
@@ -43,13 +43,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
43
43
|
// src/components/Form.tsx
|
|
44
44
|
var import_react28 = require("react");
|
|
45
45
|
var import_utils52 = require("@rjsf/utils");
|
|
46
|
-
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
|
|
47
|
-
var import_get5 = __toESM(require("lodash/get"), 1);
|
|
48
|
-
var import_isEmpty4 = __toESM(require("lodash/isEmpty"), 1);
|
|
49
|
-
var import_pick = __toESM(require("lodash/pick"), 1);
|
|
50
|
-
var import_set5 = __toESM(require("lodash/set"), 1);
|
|
51
|
-
var import_toPath = __toESM(require("lodash/toPath"), 1);
|
|
52
|
-
var import_unset = __toESM(require("lodash/unset"), 1);
|
|
53
46
|
|
|
54
47
|
// src/getDefaultRegistry.ts
|
|
55
48
|
var import_utils51 = require("@rjsf/utils");
|
|
@@ -57,13 +50,11 @@ var import_utils51 = require("@rjsf/utils");
|
|
|
57
50
|
// src/components/fields/ArrayField.tsx
|
|
58
51
|
var import_react = require("react");
|
|
59
52
|
var import_utils = require("@rjsf/utils");
|
|
60
|
-
var import_cloneDeep = __toESM(require("lodash/cloneDeep"), 1);
|
|
61
|
-
var import_isObject = __toESM(require("lodash/isObject"), 1);
|
|
62
|
-
var import_set = __toESM(require("lodash/set"), 1);
|
|
63
|
-
var import_uniqueId = __toESM(require("lodash/uniqueId"), 1);
|
|
64
53
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
54
|
+
var rowIdCounter = 0;
|
|
65
55
|
function generateRowId() {
|
|
66
|
-
|
|
56
|
+
rowIdCounter += 1;
|
|
57
|
+
return `rjsf-array-item-${rowIdCounter}`;
|
|
67
58
|
}
|
|
68
59
|
function generateKeyedFormData(formData) {
|
|
69
60
|
return !Array.isArray(formData) ? [] : formData.map((item) => ({
|
|
@@ -326,14 +317,14 @@ function ArrayFieldItemInner(props) {
|
|
|
326
317
|
const { description } = (0, import_utils.getUiOptions)(itemUiSchema);
|
|
327
318
|
const hasDescription = !!description || !!itemSchema.description;
|
|
328
319
|
const { orderable = true, removable = true, copyable = false } = uiOptions;
|
|
329
|
-
const
|
|
320
|
+
const has = {
|
|
330
321
|
moveUp: orderable && canMoveUp,
|
|
331
322
|
moveDown: orderable && canMoveDown,
|
|
332
323
|
copy: copyable && canAdd,
|
|
333
324
|
remove: removable && canRemove,
|
|
334
325
|
toolbar: false
|
|
335
326
|
};
|
|
336
|
-
|
|
327
|
+
has.toolbar = Object.keys(has).some((key) => has[key]);
|
|
337
328
|
const onAddItem = (0, import_react.useCallback)(
|
|
338
329
|
(event) => {
|
|
339
330
|
handleAddItem(event, index + 1);
|
|
@@ -393,10 +384,10 @@ function ArrayFieldItemInner(props) {
|
|
|
393
384
|
disabled,
|
|
394
385
|
readonly,
|
|
395
386
|
canAdd,
|
|
396
|
-
hasCopy:
|
|
397
|
-
hasMoveUp:
|
|
398
|
-
hasMoveDown:
|
|
399
|
-
hasRemove:
|
|
387
|
+
hasCopy: has.copy,
|
|
388
|
+
hasMoveUp: has.moveUp,
|
|
389
|
+
hasMoveDown: has.moveDown,
|
|
390
|
+
hasRemove: has.remove,
|
|
400
391
|
index,
|
|
401
392
|
totalItems,
|
|
402
393
|
onAddItem,
|
|
@@ -411,7 +402,7 @@ function ArrayFieldItemInner(props) {
|
|
|
411
402
|
itemKey,
|
|
412
403
|
className: "rjsf-array-item",
|
|
413
404
|
disabled,
|
|
414
|
-
hasToolbar:
|
|
405
|
+
hasToolbar: has.toolbar,
|
|
415
406
|
index,
|
|
416
407
|
totalItems,
|
|
417
408
|
readonly,
|
|
@@ -454,7 +445,7 @@ function NormalArray(props) {
|
|
|
454
445
|
const { schemaUtils, fields: fields2, formContext, globalUiOptions } = registry;
|
|
455
446
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
456
447
|
const uiOptions = (0, import_react.useMemo)(() => (0, import_utils.getUiOptions)(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
457
|
-
const schemaItems = (0, import_react.useMemo)(() => (0,
|
|
448
|
+
const schemaItems = (0, import_react.useMemo)(() => (0, import_utils.isObject)(schema.items) ? schema.items : {}, [schema.items]);
|
|
458
449
|
const itemsSchema = (0, import_react.useMemo)(() => schemaUtils.retrieveSchema(schemaItems), [schemaUtils, schemaItems]);
|
|
459
450
|
const formData = (0, import_react.useMemo)(() => keyedToPlainFormData(keyedFormData), [keyedFormData]);
|
|
460
451
|
const renderOptionalField = (0, import_utils.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
@@ -556,11 +547,8 @@ function FixedArray(props) {
|
|
|
556
547
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
557
548
|
const renderOptionalField = (0, import_utils.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
558
549
|
const hasFormData = (0, import_utils.isFormDataAvailable)(formData);
|
|
559
|
-
const schemaItems = (0, import_react.useMemo)(
|
|
560
|
-
|
|
561
|
-
[schema.items]
|
|
562
|
-
);
|
|
563
|
-
const hasAdditionalItems = (0, import_isObject.default)(schema.additionalItems);
|
|
550
|
+
const schemaItems = (0, import_react.useMemo)(() => Array.isArray(schema.items) ? schema.items : [], [schema.items]);
|
|
551
|
+
const hasAdditionalItems = (0, import_utils.isObject)(schema.additionalItems);
|
|
564
552
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
565
553
|
if (items.length < schemaItems.length) {
|
|
566
554
|
items = items.concat(new Array(schemaItems.length - items.length));
|
|
@@ -579,7 +567,7 @@ function FixedArray(props) {
|
|
|
579
567
|
const { key, item } = keyedItem;
|
|
580
568
|
const itemCast = item;
|
|
581
569
|
const additional = index >= schemaItems.length;
|
|
582
|
-
const rawItemSchema = (additional && (0,
|
|
570
|
+
const rawItemSchema = (additional && (0, import_utils.isObject)(schema.additionalItems) ? schema.additionalItems : schemaItems[index]) || {};
|
|
583
571
|
let itemUiSchema;
|
|
584
572
|
if (additional) {
|
|
585
573
|
itemUiSchema = uiSchema.additionalItems;
|
|
@@ -682,9 +670,9 @@ function ArrayField(props) {
|
|
|
682
670
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
683
671
|
const i = parseInt(idx, 10);
|
|
684
672
|
if (index === void 0 || i < index) {
|
|
685
|
-
(0,
|
|
673
|
+
(0, import_utils.setByPath)(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
686
674
|
} else if (i >= index) {
|
|
687
|
-
(0,
|
|
675
|
+
(0, import_utils.setByPath)(newErrorSchema, i + 1, errorSchemaRef.current[i]);
|
|
688
676
|
}
|
|
689
677
|
}
|
|
690
678
|
}
|
|
@@ -713,15 +701,15 @@ function ArrayField(props) {
|
|
|
713
701
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
714
702
|
const i = parseInt(idx, 10);
|
|
715
703
|
if (i <= index) {
|
|
716
|
-
(0,
|
|
704
|
+
(0, import_utils.setByPath)(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
717
705
|
} else if (i > index) {
|
|
718
|
-
(0,
|
|
706
|
+
(0, import_utils.setByPath)(newErrorSchema, i + 1, errorSchemaRef.current[i]);
|
|
719
707
|
}
|
|
720
708
|
}
|
|
721
709
|
}
|
|
722
710
|
const newKeyedFormDataRow = {
|
|
723
711
|
key: generateRowId(),
|
|
724
|
-
item: (
|
|
712
|
+
item: structuredClone(keyedFormDataRef.current[index].item)
|
|
725
713
|
};
|
|
726
714
|
const newKeyedFormData = [...keyedFormDataRef.current];
|
|
727
715
|
if (index !== void 0) {
|
|
@@ -744,9 +732,9 @@ function ArrayField(props) {
|
|
|
744
732
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
745
733
|
const i = parseInt(idx, 10);
|
|
746
734
|
if (i < index) {
|
|
747
|
-
(0,
|
|
735
|
+
(0, import_utils.setByPath)(newErrorSchema, i, errorSchemaRef.current[i]);
|
|
748
736
|
} else if (i > index) {
|
|
749
|
-
(0,
|
|
737
|
+
(0, import_utils.setByPath)(newErrorSchema, i - 1, errorSchemaRef.current[i]);
|
|
750
738
|
}
|
|
751
739
|
}
|
|
752
740
|
}
|
|
@@ -767,11 +755,11 @@ function ArrayField(props) {
|
|
|
767
755
|
for (const idx of Object.keys(errorSchemaRef.current)) {
|
|
768
756
|
const i = parseInt(idx, 10);
|
|
769
757
|
if (i === index) {
|
|
770
|
-
(0,
|
|
758
|
+
(0, import_utils.setByPath)(newErrorSchema, newIndex, errorSchemaRef.current[index]);
|
|
771
759
|
} else if (i === newIndex) {
|
|
772
|
-
(0,
|
|
760
|
+
(0, import_utils.setByPath)(newErrorSchema, index, errorSchemaRef.current[newIndex]);
|
|
773
761
|
} else {
|
|
774
|
-
(0,
|
|
762
|
+
(0, import_utils.setByPath)(newErrorSchema, idx, errorSchemaRef.current[i]);
|
|
775
763
|
}
|
|
776
764
|
}
|
|
777
765
|
}
|
|
@@ -862,7 +850,6 @@ function ArrayField(props) {
|
|
|
862
850
|
// src/components/fields/BooleanField.tsx
|
|
863
851
|
var import_react2 = require("react");
|
|
864
852
|
var import_utils2 = require("@rjsf/utils");
|
|
865
|
-
var import_isObject2 = __toESM(require("lodash/isObject"), 1);
|
|
866
853
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
867
854
|
function BooleanField(props) {
|
|
868
855
|
const {
|
|
@@ -902,7 +889,7 @@ function BooleanField(props) {
|
|
|
902
889
|
enumOptions = (0, import_utils2.optionsList)(
|
|
903
890
|
{
|
|
904
891
|
oneOf: schema.oneOf.map((option) => {
|
|
905
|
-
if ((0,
|
|
892
|
+
if ((0, import_utils2.isObject)(option)) {
|
|
906
893
|
return {
|
|
907
894
|
...option,
|
|
908
895
|
title: option.title || (option.const === true ? yes : no)
|
|
@@ -1117,21 +1104,6 @@ function FallbackField(props) {
|
|
|
1117
1104
|
|
|
1118
1105
|
// src/components/fields/LayoutGridField.tsx
|
|
1119
1106
|
var import_utils5 = require("@rjsf/utils");
|
|
1120
|
-
var import_each = __toESM(require("lodash/each"), 1);
|
|
1121
|
-
var import_flatten = __toESM(require("lodash/flatten"), 1);
|
|
1122
|
-
var import_get = __toESM(require("lodash/get"), 1);
|
|
1123
|
-
var import_has = __toESM(require("lodash/has"), 1);
|
|
1124
|
-
var import_includes = __toESM(require("lodash/includes"), 1);
|
|
1125
|
-
var import_intersection = __toESM(require("lodash/intersection"), 1);
|
|
1126
|
-
var import_isEmpty = __toESM(require("lodash/isEmpty"), 1);
|
|
1127
|
-
var import_isEqual = __toESM(require("lodash/isEqual"), 1);
|
|
1128
|
-
var import_isFunction = __toESM(require("lodash/isFunction"), 1);
|
|
1129
|
-
var import_isObject3 = __toESM(require("lodash/isObject"), 1);
|
|
1130
|
-
var import_isPlainObject = __toESM(require("lodash/isPlainObject"), 1);
|
|
1131
|
-
var import_isString = __toESM(require("lodash/isString"), 1);
|
|
1132
|
-
var import_isUndefined = __toESM(require("lodash/isUndefined"), 1);
|
|
1133
|
-
var import_last = __toESM(require("lodash/last"), 1);
|
|
1134
|
-
var import_set2 = __toESM(require("lodash/set"), 1);
|
|
1135
1107
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1136
1108
|
var import_react5 = require("react");
|
|
1137
1109
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
@@ -1145,37 +1117,38 @@ function isNumericIndex(str) {
|
|
|
1145
1117
|
}
|
|
1146
1118
|
var LAYOUT_GRID_FIELD_TEST_IDS = (0, import_utils5.getTestIds)();
|
|
1147
1119
|
function computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
1148
|
-
const globalUiOptions =
|
|
1149
|
-
const localUiSchema = (0,
|
|
1150
|
-
const localUiOptions = { ...
|
|
1120
|
+
const globalUiOptions = uiSchema?.[import_utils5.UI_GLOBAL_OPTIONS_KEY] ?? {};
|
|
1121
|
+
const localUiSchema = (0, import_utils5.getByPath)(uiSchema, (0, import_utils5.toPath)(field));
|
|
1122
|
+
const localUiOptions = { ...localUiSchema?.[import_utils5.UI_OPTIONS_KEY] ?? {}, ...uiProps, ...globalUiOptions };
|
|
1151
1123
|
const fieldUiSchema = { ...localUiSchema };
|
|
1152
|
-
if (
|
|
1153
|
-
|
|
1124
|
+
if (Object.keys(localUiOptions).length > 0) {
|
|
1125
|
+
fieldUiSchema[import_utils5.UI_OPTIONS_KEY] = localUiOptions;
|
|
1154
1126
|
}
|
|
1155
|
-
if (
|
|
1156
|
-
|
|
1127
|
+
if (Object.keys(globalUiOptions).length > 0) {
|
|
1128
|
+
fieldUiSchema[import_utils5.UI_GLOBAL_OPTIONS_KEY] = globalUiOptions;
|
|
1157
1129
|
}
|
|
1158
1130
|
let { readonly: uiReadonly } = (0, import_utils5.getUiOptions)(fieldUiSchema);
|
|
1159
|
-
if (forceReadonly === true ||
|
|
1131
|
+
if (forceReadonly === true || uiReadonly === void 0 && schemaReadonly === true) {
|
|
1160
1132
|
uiReadonly = true;
|
|
1161
|
-
|
|
1162
|
-
|
|
1133
|
+
const fieldUiOptions = fieldUiSchema[import_utils5.UI_OPTIONS_KEY];
|
|
1134
|
+
if (fieldUiOptions && import_utils5.READONLY_KEY in fieldUiOptions) {
|
|
1135
|
+
fieldUiOptions[import_utils5.READONLY_KEY] = true;
|
|
1163
1136
|
} else {
|
|
1164
|
-
|
|
1137
|
+
fieldUiSchema[`ui:${import_utils5.READONLY_KEY}`] = true;
|
|
1165
1138
|
}
|
|
1166
1139
|
}
|
|
1167
1140
|
return { fieldUiSchema, uiReadonly };
|
|
1168
1141
|
}
|
|
1169
1142
|
function conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
|
|
1170
|
-
const data =
|
|
1171
|
-
const values =
|
|
1143
|
+
const data = [datum].flat().sort();
|
|
1144
|
+
const values = [value].flat().sort();
|
|
1172
1145
|
switch (operator) {
|
|
1173
1146
|
case "all" /* ALL */:
|
|
1174
|
-
return (0,
|
|
1147
|
+
return (0, import_utils5.deepEquals)(data, values);
|
|
1175
1148
|
case "some" /* SOME */:
|
|
1176
|
-
return (
|
|
1149
|
+
return data.some((entry) => values.includes(entry));
|
|
1177
1150
|
case "none" /* NONE */:
|
|
1178
|
-
return (
|
|
1151
|
+
return !data.some((entry) => values.includes(entry));
|
|
1179
1152
|
default:
|
|
1180
1153
|
return false;
|
|
1181
1154
|
}
|
|
@@ -1183,7 +1156,7 @@ function conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
|
|
|
1183
1156
|
function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
1184
1157
|
let gridProps = {};
|
|
1185
1158
|
let children = layoutGridSchema[schemaKey];
|
|
1186
|
-
if ((0,
|
|
1159
|
+
if ((0, import_utils5.isPlainObject)(children)) {
|
|
1187
1160
|
const { children: elements, className: toMapClassNames, ...otherProps } = children;
|
|
1188
1161
|
children = elements;
|
|
1189
1162
|
if (toMapClassNames) {
|
|
@@ -1202,12 +1175,12 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1202
1175
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1203
1176
|
let rawSchema;
|
|
1204
1177
|
let resultPathId = fieldPathId;
|
|
1205
|
-
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" &&
|
|
1178
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && import_utils5.ITEMS_KEY in schema) {
|
|
1206
1179
|
const index = Number(potentialIndex);
|
|
1207
1180
|
const items = schema[import_utils5.ITEMS_KEY];
|
|
1208
1181
|
if (Array.isArray(items)) {
|
|
1209
1182
|
if (index > items.length) {
|
|
1210
|
-
rawSchema =
|
|
1183
|
+
rawSchema = items.at(-1);
|
|
1211
1184
|
} else {
|
|
1212
1185
|
rawSchema = items[index];
|
|
1213
1186
|
}
|
|
@@ -1232,44 +1205,45 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1232
1205
|
let isReadonly = schema.readOnly;
|
|
1233
1206
|
parts.forEach((part) => {
|
|
1234
1207
|
fieldPathId = (0, import_utils5.toFieldPathId)(part, globalFormOptions, fieldPathId);
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1208
|
+
const schemaProperties = schema?.[import_utils5.PROPERTIES_KEY];
|
|
1209
|
+
if (schemaProperties) {
|
|
1210
|
+
rawSchema = schemaProperties[part] ?? {};
|
|
1211
|
+
} else if (schema && (import_utils5.ONE_OF_KEY in schema || import_utils5.ANY_OF_KEY in schema)) {
|
|
1212
|
+
const xxx = import_utils5.ONE_OF_KEY in schema ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1239
1213
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1240
|
-
rawSchema = (0,
|
|
1214
|
+
rawSchema = (0, import_utils5.getPropertySchema)(selectedSchema, part);
|
|
1241
1215
|
} else {
|
|
1242
1216
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1243
1217
|
rawSchema = result.rawSchema ?? {};
|
|
1244
1218
|
fieldPathId = result.fieldPathId;
|
|
1245
1219
|
}
|
|
1246
|
-
innerData = (0,
|
|
1220
|
+
innerData = (0, import_utils5.getByPath)(innerData, part, {});
|
|
1247
1221
|
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
1248
1222
|
isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
|
|
1249
1223
|
});
|
|
1250
1224
|
let optionsInfo;
|
|
1251
1225
|
let isRequired2 = false;
|
|
1252
|
-
if (
|
|
1226
|
+
if (!schema || Object.keys(schema).length === 0) {
|
|
1253
1227
|
schema = void 0;
|
|
1254
1228
|
}
|
|
1255
1229
|
if (schema && leafPath) {
|
|
1256
|
-
if (schema && (
|
|
1257
|
-
const xxx =
|
|
1230
|
+
if (schema && (import_utils5.ONE_OF_KEY in schema || import_utils5.ANY_OF_KEY in schema)) {
|
|
1231
|
+
const xxx = import_utils5.ONE_OF_KEY in schema ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1258
1232
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1259
1233
|
}
|
|
1260
1234
|
fieldPathId = (0, import_utils5.toFieldPathId)(leafPath, globalFormOptions, fieldPathId);
|
|
1261
|
-
isRequired2 = schema !== void 0 && Array.isArray(schema.required) &&
|
|
1235
|
+
isRequired2 = schema !== void 0 && Array.isArray(schema.required) && schema.required.includes(leafPath);
|
|
1262
1236
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1263
1237
|
if (result.rawSchema) {
|
|
1264
1238
|
schema = result.rawSchema;
|
|
1265
1239
|
fieldPathId = result.fieldPathId;
|
|
1266
1240
|
} else {
|
|
1267
|
-
schema =
|
|
1241
|
+
schema = schema?.[import_utils5.PROPERTIES_KEY]?.[leafPath];
|
|
1268
1242
|
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1269
1243
|
}
|
|
1270
1244
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1271
|
-
if (schema && (
|
|
1272
|
-
const xxx =
|
|
1245
|
+
if (schema && (import_utils5.ONE_OF_KEY in schema || import_utils5.ANY_OF_KEY in schema)) {
|
|
1246
|
+
const xxx = import_utils5.ONE_OF_KEY in schema ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1273
1247
|
const discriminator = (0, import_utils5.getDiscriminatorFieldFromSchema)(schema);
|
|
1274
1248
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1275
1249
|
}
|
|
@@ -1278,10 +1252,10 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1278
1252
|
}
|
|
1279
1253
|
function getCustomRenderComponent(render, registry) {
|
|
1280
1254
|
let customRenderer = render;
|
|
1281
|
-
if (
|
|
1255
|
+
if (typeof customRenderer === "string") {
|
|
1282
1256
|
customRenderer = (0, import_utils5.lookupFromFormContext)(registry, customRenderer);
|
|
1283
1257
|
}
|
|
1284
|
-
if (
|
|
1258
|
+
if (typeof customRenderer === "function") {
|
|
1285
1259
|
return customRenderer;
|
|
1286
1260
|
}
|
|
1287
1261
|
return null;
|
|
@@ -1291,23 +1265,21 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1291
1265
|
let UIComponent = null;
|
|
1292
1266
|
let uiProps = {};
|
|
1293
1267
|
let rendered;
|
|
1294
|
-
if (
|
|
1268
|
+
if (typeof gridSchema === "string" || gridSchema === void 0) {
|
|
1295
1269
|
name = gridSchema ?? "";
|
|
1296
1270
|
} else {
|
|
1297
1271
|
const { name: innerName = "", render, ...innerProps } = gridSchema;
|
|
1298
1272
|
name = innerName;
|
|
1299
1273
|
uiProps = innerProps;
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
uiProps[key] = (0, import_utils5.lookupFromFormContext)(registry, lookupName, lookupName);
|
|
1307
|
-
}
|
|
1274
|
+
Object.entries(uiProps).forEach(([key, prop]) => {
|
|
1275
|
+
if (typeof prop === "string") {
|
|
1276
|
+
const match = LOOKUP_REGEX.exec(prop);
|
|
1277
|
+
if (Array.isArray(match) && match.length > 1) {
|
|
1278
|
+
const lookupName = match[1];
|
|
1279
|
+
uiProps[key] = (0, import_utils5.lookupFromFormContext)(registry, lookupName, lookupName);
|
|
1308
1280
|
}
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1311
1283
|
UIComponent = getCustomRenderComponent(render, registry);
|
|
1312
1284
|
if (!innerName && UIComponent) {
|
|
1313
1285
|
rendered = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UIComponent, { ...innerProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent });
|
|
@@ -1335,7 +1307,7 @@ function LayoutGridCondition(props) {
|
|
|
1335
1307
|
const { formData, registry } = layoutGridFieldProps;
|
|
1336
1308
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:condition" /* CONDITION */, registry);
|
|
1337
1309
|
const { operator, field = "", value } = gridProps;
|
|
1338
|
-
const fieldData = (0,
|
|
1310
|
+
const fieldData = (0, import_utils5.getByPath)(formData, (0, import_utils5.toPath)(field), null);
|
|
1339
1311
|
if (conditionMatches(operator, fieldData, value)) {
|
|
1340
1312
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children });
|
|
1341
1313
|
}
|
|
@@ -1409,6 +1381,7 @@ function LayoutGridFieldComponent(props) {
|
|
|
1409
1381
|
if (schema) {
|
|
1410
1382
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1411
1383
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1384
|
+
const namePath = (0, import_utils5.toPath)(name);
|
|
1412
1385
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1413
1386
|
Field,
|
|
1414
1387
|
{
|
|
@@ -1419,9 +1392,9 @@ function LayoutGridFieldComponent(props) {
|
|
|
1419
1392
|
readonly: uiReadonly,
|
|
1420
1393
|
schema,
|
|
1421
1394
|
uiSchema: fieldUiSchema,
|
|
1422
|
-
errorSchema: (0,
|
|
1395
|
+
errorSchema: (0, import_utils5.getByPath)(errorSchema, namePath),
|
|
1423
1396
|
fieldPathId: memoFieldPathId,
|
|
1424
|
-
formData: (0,
|
|
1397
|
+
formData: (0, import_utils5.getByPath)(formData, namePath),
|
|
1425
1398
|
onChange,
|
|
1426
1399
|
onBlur,
|
|
1427
1400
|
onFocus,
|
|
@@ -1457,10 +1430,10 @@ function LayoutGridField(props) {
|
|
|
1457
1430
|
const { uiSchema } = props;
|
|
1458
1431
|
let { layoutGridSchema } = props;
|
|
1459
1432
|
const uiOptions = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1460
|
-
if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && (0,
|
|
1433
|
+
if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && (0, import_utils5.isObject)(uiOptions[LAYOUT_GRID_UI_OPTION])) {
|
|
1461
1434
|
layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
|
|
1462
1435
|
}
|
|
1463
|
-
if ((0,
|
|
1436
|
+
if ((0, import_utils5.isObject)(layoutGridSchema)) {
|
|
1464
1437
|
if ("ui:row" /* ROW */ in layoutGridSchema) {
|
|
1465
1438
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridRow, { ...props, layoutGridSchema });
|
|
1466
1439
|
}
|
|
@@ -1511,28 +1484,22 @@ function LayoutHeaderField(props) {
|
|
|
1511
1484
|
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1512
1485
|
var import_react6 = require("react");
|
|
1513
1486
|
var import_utils7 = require("@rjsf/utils");
|
|
1514
|
-
var import_get2 = __toESM(require("lodash/get"), 1);
|
|
1515
|
-
var import_has2 = __toESM(require("lodash/has"), 1);
|
|
1516
|
-
var import_isEmpty2 = __toESM(require("lodash/isEmpty"), 1);
|
|
1517
|
-
var import_noop = __toESM(require("lodash/noop"), 1);
|
|
1518
|
-
var import_omit = __toESM(require("lodash/omit"), 1);
|
|
1519
|
-
var import_set3 = __toESM(require("lodash/set"), 1);
|
|
1520
1487
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1521
1488
|
function getSelectedOption(options, selectorField, value) {
|
|
1522
1489
|
const defaultValue = "!@#!@$@#$!@$#";
|
|
1523
1490
|
const schemaOptions = options.map(({ schema }) => schema);
|
|
1524
1491
|
return schemaOptions.find((option) => {
|
|
1525
|
-
const selector =
|
|
1526
|
-
const result = (0,
|
|
1492
|
+
const selector = option[import_utils7.PROPERTIES_KEY]?.[selectorField];
|
|
1493
|
+
const result = (0, import_utils7.getByPath)(selector, import_utils7.DEFAULT_KEY, (0, import_utils7.getByPath)(selector, import_utils7.CONST_KEY, defaultValue));
|
|
1527
1494
|
return result === value;
|
|
1528
1495
|
});
|
|
1529
1496
|
}
|
|
1530
1497
|
function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
|
|
1531
1498
|
const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1532
1499
|
let tempSchema = schema;
|
|
1533
|
-
if (
|
|
1500
|
+
if (import_utils7.ONE_OF_KEY in schema) {
|
|
1534
1501
|
tempSchema = { ...schema, [import_utils7.ONE_OF_KEY]: realOptions };
|
|
1535
|
-
} else if (
|
|
1502
|
+
} else if (import_utils7.ANY_OF_KEY in schema) {
|
|
1536
1503
|
tempSchema = { ...schema, [import_utils7.ANY_OF_KEY]: realOptions };
|
|
1537
1504
|
}
|
|
1538
1505
|
const enumOptions = (0, import_utils7.optionsList)(tempSchema, uiSchema);
|
|
@@ -1563,7 +1530,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1563
1530
|
} = props;
|
|
1564
1531
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1565
1532
|
const [enumOptions, setEnumOptions] = (0, import_react6.useState)(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1566
|
-
const id =
|
|
1533
|
+
const id = fieldPathId[import_utils7.ID_KEY];
|
|
1567
1534
|
const discriminator = (0, import_utils7.getDiscriminatorFieldFromSchema)(schema);
|
|
1568
1535
|
const FieldErrorTemplate2 = (0, import_utils7.getTemplate)("FieldErrorTemplate", registry, options);
|
|
1569
1536
|
const FieldTemplate2 = (0, import_utils7.getTemplate)("FieldTemplate", registry, options);
|
|
@@ -1585,14 +1552,15 @@ function LayoutMultiSchemaField(props) {
|
|
|
1585
1552
|
if (!selectorField) {
|
|
1586
1553
|
throw new Error("No selector field provided for the LayoutMultiSchemaField");
|
|
1587
1554
|
}
|
|
1588
|
-
const selectedOption = (0,
|
|
1589
|
-
let optionSchema = (0,
|
|
1555
|
+
const selectedOption = (0, import_utils7.getByPath)(formData, selectorField);
|
|
1556
|
+
let optionSchema = (0, import_utils7.getPropertySchema)(enumOptions[0]?.schema, selectorField);
|
|
1590
1557
|
const option = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1591
1558
|
optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
|
|
1592
1559
|
const Widget = (0, import_utils7.getWidget)(optionSchema, widget, widgets2);
|
|
1593
1560
|
const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
|
|
1594
|
-
const rawErrors =
|
|
1595
|
-
const fieldErrorSchema =
|
|
1561
|
+
const rawErrors = errorSchema?.[import_utils7.ERRORS_KEY] ?? [];
|
|
1562
|
+
const fieldErrorSchema = { ...errorSchema };
|
|
1563
|
+
delete fieldErrorSchema[import_utils7.ERRORS_KEY];
|
|
1596
1564
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1597
1565
|
const onOptionChange = (opt) => {
|
|
1598
1566
|
if (disabled || readonly) {
|
|
@@ -1605,7 +1573,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1605
1573
|
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1606
1574
|
}
|
|
1607
1575
|
if (newFormData) {
|
|
1608
|
-
(0,
|
|
1576
|
+
(0, import_utils7.setByPath)(newFormData, selectorField, opt);
|
|
1609
1577
|
}
|
|
1610
1578
|
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1611
1579
|
};
|
|
@@ -1618,7 +1586,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1618
1586
|
id,
|
|
1619
1587
|
schema,
|
|
1620
1588
|
label: (title || schema.title) ?? "",
|
|
1621
|
-
disabled: disabled || Array.isArray(enumOptions) &&
|
|
1589
|
+
disabled: disabled || Array.isArray(enumOptions) && enumOptions.length === 0,
|
|
1622
1590
|
uiSchema,
|
|
1623
1591
|
required,
|
|
1624
1592
|
readonly: !!readonly,
|
|
@@ -1626,9 +1594,9 @@ function LayoutMultiSchemaField(props) {
|
|
|
1626
1594
|
displayLabel,
|
|
1627
1595
|
errors,
|
|
1628
1596
|
onChange,
|
|
1629
|
-
onKeyRename:
|
|
1630
|
-
onKeyRenameBlur:
|
|
1631
|
-
onRemoveProperty:
|
|
1597
|
+
onKeyRename: import_utils7.noop,
|
|
1598
|
+
onKeyRenameBlur: import_utils7.noop,
|
|
1599
|
+
onRemoveProperty: import_utils7.noop,
|
|
1632
1600
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1633
1601
|
Widget,
|
|
1634
1602
|
{
|
|
@@ -1636,7 +1604,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1636
1604
|
name,
|
|
1637
1605
|
schema,
|
|
1638
1606
|
label: (title || schema.title) ?? "",
|
|
1639
|
-
disabled: disabled || Array.isArray(enumOptions) &&
|
|
1607
|
+
disabled: disabled || Array.isArray(enumOptions) && enumOptions.length === 0,
|
|
1640
1608
|
uiSchema,
|
|
1641
1609
|
autofocus,
|
|
1642
1610
|
readonly,
|
|
@@ -1663,15 +1631,12 @@ function LayoutMultiSchemaField(props) {
|
|
|
1663
1631
|
// src/components/fields/MultiSchemaField.tsx
|
|
1664
1632
|
var import_react7 = require("react");
|
|
1665
1633
|
var import_utils8 = require("@rjsf/utils");
|
|
1666
|
-
var import_get3 = __toESM(require("lodash/get"), 1);
|
|
1667
|
-
var import_isEmpty3 = __toESM(require("lodash/isEmpty"), 1);
|
|
1668
|
-
var import_omit2 = __toESM(require("lodash/omit"), 1);
|
|
1669
1634
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1670
1635
|
function AnyOfField(props) {
|
|
1671
1636
|
const {
|
|
1672
1637
|
name,
|
|
1673
1638
|
disabled = false,
|
|
1674
|
-
errorSchema
|
|
1639
|
+
errorSchema,
|
|
1675
1640
|
formData,
|
|
1676
1641
|
fieldPathId,
|
|
1677
1642
|
onBlur,
|
|
@@ -1761,8 +1726,9 @@ function AnyOfField(props) {
|
|
|
1761
1726
|
...uiOptions
|
|
1762
1727
|
} = (0, import_utils8.getUiOptions)(uiSchema, globalUiOptions);
|
|
1763
1728
|
const Widget = (0, import_utils8.getWidget)({ type: "number" }, widget, widgets2);
|
|
1764
|
-
const rawErrors =
|
|
1765
|
-
const fieldErrorSchema =
|
|
1729
|
+
const rawErrors = errorSchema?.[import_utils8.ERRORS_KEY] ?? [];
|
|
1730
|
+
const fieldErrorSchema = { ...errorSchema };
|
|
1731
|
+
delete fieldErrorSchema[import_utils8.ERRORS_KEY];
|
|
1766
1732
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1767
1733
|
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1768
1734
|
let optionSchema;
|
|
@@ -1813,7 +1779,7 @@ function AnyOfField(props) {
|
|
|
1813
1779
|
onChange: onOptionChange,
|
|
1814
1780
|
onBlur,
|
|
1815
1781
|
onFocus,
|
|
1816
|
-
disabled: disabled ||
|
|
1782
|
+
disabled: disabled || enumOptions.length === 0,
|
|
1817
1783
|
multiple: false,
|
|
1818
1784
|
rawErrors,
|
|
1819
1785
|
errorSchema: fieldErrorSchema,
|
|
@@ -1902,10 +1868,6 @@ var NumberField_default = NumberField;
|
|
|
1902
1868
|
// src/components/fields/ObjectField.tsx
|
|
1903
1869
|
var import_react10 = require("react");
|
|
1904
1870
|
var import_utils10 = require("@rjsf/utils");
|
|
1905
|
-
var import_get4 = __toESM(require("lodash/get"), 1);
|
|
1906
|
-
var import_has3 = __toESM(require("lodash/has"), 1);
|
|
1907
|
-
var import_isObject4 = __toESM(require("lodash/isObject"), 1);
|
|
1908
|
-
var import_set4 = __toESM(require("lodash/set"), 1);
|
|
1909
1871
|
var import_react11 = require("markdown-to-jsx/react");
|
|
1910
1872
|
|
|
1911
1873
|
// src/components/constants.ts
|
|
@@ -1969,12 +1931,12 @@ function ObjectFieldPropertyFn(props) {
|
|
|
1969
1931
|
const onPropertyChange = (0, import_react10.useCallback)(
|
|
1970
1932
|
(value, path, newErrorSchema, id) => {
|
|
1971
1933
|
let normalizedValue = value;
|
|
1972
|
-
if (value === void 0 && addedByAdditionalProperties) {
|
|
1934
|
+
if (value === void 0 && addedByAdditionalProperties && (0, import_utils10.deepEquals)(path, innerFieldIdPathId.path)) {
|
|
1973
1935
|
normalizedValue = "";
|
|
1974
1936
|
}
|
|
1975
1937
|
onChange(normalizedValue, path, newErrorSchema, id);
|
|
1976
1938
|
},
|
|
1977
|
-
[onChange, addedByAdditionalProperties]
|
|
1939
|
+
[onChange, addedByAdditionalProperties, innerFieldIdPathId]
|
|
1978
1940
|
);
|
|
1979
1941
|
const onKeyRename = (0, import_react10.useCallback)(
|
|
1980
1942
|
(value) => {
|
|
@@ -2069,7 +2031,7 @@ function ObjectField(props) {
|
|
|
2069
2031
|
const { duplicateKeySuffixSeparator = "-" } = (0, import_utils10.getUiOptions)(uiSchema, globalUiOptions);
|
|
2070
2032
|
let index = 0;
|
|
2071
2033
|
let newKey = preferredKey;
|
|
2072
|
-
while ((0,
|
|
2034
|
+
while ((0, import_utils10.hasByPath)(existingFormData, newKey)) {
|
|
2073
2035
|
index += 1;
|
|
2074
2036
|
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${index}`;
|
|
2075
2037
|
}
|
|
@@ -2084,12 +2046,12 @@ function ObjectField(props) {
|
|
|
2084
2046
|
const newFormData = { ...formData };
|
|
2085
2047
|
const newKey = getAvailableKey("newKey", newFormData);
|
|
2086
2048
|
if (schema.patternProperties) {
|
|
2087
|
-
(0,
|
|
2049
|
+
(0, import_utils10.setByPath)(newFormData, newKey, null);
|
|
2088
2050
|
} else {
|
|
2089
2051
|
let type = void 0;
|
|
2090
2052
|
let constValue = void 0;
|
|
2091
2053
|
let defaultValue = void 0;
|
|
2092
|
-
if ((0,
|
|
2054
|
+
if ((0, import_utils10.isObject)(schema.additionalProperties)) {
|
|
2093
2055
|
type = schema.additionalProperties.type;
|
|
2094
2056
|
constValue = schema.additionalProperties.const;
|
|
2095
2057
|
defaultValue = schema.additionalProperties.default;
|
|
@@ -2105,7 +2067,7 @@ function ObjectField(props) {
|
|
|
2105
2067
|
}
|
|
2106
2068
|
}
|
|
2107
2069
|
const newValue = constValue ?? defaultValue ?? getDefaultValue(translateString, type);
|
|
2108
|
-
(0,
|
|
2070
|
+
(0, import_utils10.setByPath)(newFormData, newKey, newValue);
|
|
2109
2071
|
}
|
|
2110
2072
|
if (lastRenamedProperty.current.previousKey === newKey) {
|
|
2111
2073
|
lastRenamedProperty.current.currentKey = newKey;
|
|
@@ -2181,11 +2143,11 @@ function ObjectField(props) {
|
|
|
2181
2143
|
{
|
|
2182
2144
|
propertyName,
|
|
2183
2145
|
required: isRequired(schema, propertyName),
|
|
2184
|
-
schema: (0,
|
|
2146
|
+
schema: (0, import_utils10.getPropertySchema)(schema, propertyName),
|
|
2185
2147
|
uiSchema: fieldUiSchema,
|
|
2186
|
-
errorSchema: (0,
|
|
2148
|
+
errorSchema: (0, import_utils10.getByPath)(errorSchema, propertyName),
|
|
2187
2149
|
fieldPathId: childFieldPathId,
|
|
2188
|
-
formData: (0,
|
|
2150
|
+
formData: (0, import_utils10.getByPath)(formData, propertyName),
|
|
2189
2151
|
handleKeyRename,
|
|
2190
2152
|
handleRemoveProperty,
|
|
2191
2153
|
addedByAdditionalProperties,
|
|
@@ -2287,8 +2249,6 @@ function OptionalDataControlsField(props) {
|
|
|
2287
2249
|
// src/components/fields/SchemaField.tsx
|
|
2288
2250
|
var import_react12 = require("react");
|
|
2289
2251
|
var import_utils12 = require("@rjsf/utils");
|
|
2290
|
-
var import_isObject5 = __toESM(require("lodash/isObject"), 1);
|
|
2291
|
-
var import_omit3 = __toESM(require("lodash/omit"), 1);
|
|
2292
2252
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2293
2253
|
var COMPONENT_TYPES = {
|
|
2294
2254
|
array: "ArrayField",
|
|
@@ -2380,12 +2340,12 @@ function SchemaFieldRender(props) {
|
|
|
2380
2340
|
if (schema[import_utils12.ANY_OF_KEY]) {
|
|
2381
2341
|
XxxOfField = _AnyOfField;
|
|
2382
2342
|
XxxOfOptions = schema[import_utils12.ANY_OF_KEY].map(
|
|
2383
|
-
(xxxOfSchema) => schemaUtils.retrieveSchema((0,
|
|
2343
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_utils12.isObject)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2384
2344
|
);
|
|
2385
2345
|
} else if (schema[import_utils12.ONE_OF_KEY]) {
|
|
2386
2346
|
XxxOfField = _OneOfField;
|
|
2387
2347
|
XxxOfOptions = schema[import_utils12.ONE_OF_KEY].map(
|
|
2388
|
-
(xxxOfSchema) => schemaUtils.retrieveSchema((0,
|
|
2348
|
+
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_utils12.isObject)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2389
2349
|
);
|
|
2390
2350
|
}
|
|
2391
2351
|
const isOptionalRender = (0, import_utils12.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
@@ -2399,9 +2359,19 @@ function SchemaFieldRender(props) {
|
|
|
2399
2359
|
};
|
|
2400
2360
|
}
|
|
2401
2361
|
const { __errors, ...fieldErrorSchema } = errorSchema || {};
|
|
2402
|
-
const
|
|
2362
|
+
const {
|
|
2363
|
+
"ui:classNames": consumedUiClassNames,
|
|
2364
|
+
classNames: consumedClassNames,
|
|
2365
|
+
"ui:style": consumedUiStyle,
|
|
2366
|
+
...fieldUiSchema
|
|
2367
|
+
} = uiSchema;
|
|
2403
2368
|
if (import_utils12.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
2404
|
-
|
|
2369
|
+
const {
|
|
2370
|
+
classNames: consumedOptionClassNames,
|
|
2371
|
+
style: consumedOptionStyle,
|
|
2372
|
+
...fieldUiOptions
|
|
2373
|
+
} = fieldUiSchema[import_utils12.UI_OPTIONS_KEY];
|
|
2374
|
+
fieldUiSchema[import_utils12.UI_OPTIONS_KEY] = fieldUiOptions;
|
|
2405
2375
|
}
|
|
2406
2376
|
const field = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2407
2377
|
FieldComponent,
|
|
@@ -2922,7 +2892,7 @@ function BaseInputTemplate(props) {
|
|
|
2922
2892
|
(e) => {
|
|
2923
2893
|
e.preventDefault();
|
|
2924
2894
|
e.stopPropagation();
|
|
2925
|
-
onChange(options.emptyValue
|
|
2895
|
+
onChange(options.emptyValue);
|
|
2926
2896
|
},
|
|
2927
2897
|
[onChange, options.emptyValue]
|
|
2928
2898
|
);
|
|
@@ -3631,14 +3601,15 @@ function CheckboxWidget({
|
|
|
3631
3601
|
onFocus,
|
|
3632
3602
|
onChange,
|
|
3633
3603
|
registry,
|
|
3634
|
-
htmlName
|
|
3604
|
+
htmlName,
|
|
3605
|
+
required
|
|
3635
3606
|
}) {
|
|
3636
3607
|
const DescriptionFieldTemplate = (0, import_utils37.getTemplate)(
|
|
3637
3608
|
"DescriptionFieldTemplate",
|
|
3638
3609
|
registry,
|
|
3639
3610
|
options
|
|
3640
3611
|
);
|
|
3641
|
-
const
|
|
3612
|
+
const trueValueRequired = (0, import_utils37.schemaRequiresTrueValue)(schema) && required;
|
|
3642
3613
|
const handleChange = (0, import_react20.useCallback)(
|
|
3643
3614
|
(event) => onChange(event.target.checked),
|
|
3644
3615
|
[onChange]
|
|
@@ -3682,7 +3653,13 @@ function CheckboxWidget({
|
|
|
3682
3653
|
"aria-describedby": (0, import_utils37.ariaDescribedByIds)(id)
|
|
3683
3654
|
}
|
|
3684
3655
|
),
|
|
3685
|
-
(0, import_utils37.labelValue)(
|
|
3656
|
+
(0, import_utils37.labelValue)(
|
|
3657
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("span", { children: [
|
|
3658
|
+
label,
|
|
3659
|
+
trueValueRequired && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "required", children: "*" })
|
|
3660
|
+
] }),
|
|
3661
|
+
hideLabel
|
|
3662
|
+
)
|
|
3686
3663
|
] })
|
|
3687
3664
|
] });
|
|
3688
3665
|
}
|
|
@@ -3918,7 +3895,6 @@ function RatingWidget({
|
|
|
3918
3895
|
required,
|
|
3919
3896
|
disabled,
|
|
3920
3897
|
readonly,
|
|
3921
|
-
autofocus,
|
|
3922
3898
|
onChange,
|
|
3923
3899
|
onFocus,
|
|
3924
3900
|
onBlur,
|
|
@@ -4183,10 +4159,23 @@ var import_react27 = require("react");
|
|
|
4183
4159
|
var import_utils48 = require("@rjsf/utils");
|
|
4184
4160
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
4185
4161
|
function TimeWidget(props) {
|
|
4186
|
-
const { onChange, options, registry } = props;
|
|
4162
|
+
const { onChange, options, registry, schema, value } = props;
|
|
4187
4163
|
const BaseInputTemplate2 = (0, import_utils48.getTemplate)("BaseInputTemplate", registry, options);
|
|
4188
|
-
const
|
|
4189
|
-
|
|
4164
|
+
const hasSecondPrecision = typeof schema.multipleOf === "number" && Number.isFinite(schema.multipleOf) && schema.multipleOf < 60;
|
|
4165
|
+
const handleChange = (0, import_react27.useCallback)(
|
|
4166
|
+
(newValue) => {
|
|
4167
|
+
if (!newValue) {
|
|
4168
|
+
onChange(void 0);
|
|
4169
|
+
} else if (hasSecondPrecision) {
|
|
4170
|
+
onChange(newValue);
|
|
4171
|
+
} else {
|
|
4172
|
+
onChange(`${newValue}:00`);
|
|
4173
|
+
}
|
|
4174
|
+
},
|
|
4175
|
+
[hasSecondPrecision, onChange]
|
|
4176
|
+
);
|
|
4177
|
+
const displayValue = typeof value === "string" && !hasSecondPrecision && /^\d{2}:\d{2}:00$/.test(value) ? value.slice(0, -3) : value;
|
|
4178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(BaseInputTemplate2, { type: "time", ...props, value: displayValue, onChange: handleChange });
|
|
4190
4179
|
}
|
|
4191
4180
|
|
|
4192
4181
|
// src/components/widgets/UpDownWidget.tsx
|
|
@@ -4254,8 +4243,16 @@ function getDefaultRegistry() {
|
|
|
4254
4243
|
// src/components/Form.tsx
|
|
4255
4244
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
4256
4245
|
function toIChangeEvent(state, status) {
|
|
4246
|
+
const { schema, uiSchema, fieldPathId, schemaUtils, formData, edit, errors, errorSchema } = state;
|
|
4257
4247
|
return {
|
|
4258
|
-
|
|
4248
|
+
schema,
|
|
4249
|
+
uiSchema,
|
|
4250
|
+
fieldPathId,
|
|
4251
|
+
schemaUtils,
|
|
4252
|
+
formData,
|
|
4253
|
+
edit,
|
|
4254
|
+
errors,
|
|
4255
|
+
errorSchema,
|
|
4259
4256
|
...status !== void 0 && { status }
|
|
4260
4257
|
};
|
|
4261
4258
|
}
|
|
@@ -4354,7 +4351,9 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4354
4351
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
4355
4352
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
4356
4353
|
isSchemaChanged,
|
|
4357
|
-
|
|
4354
|
+
// Only the error clearing needs the path of each changed field, and it runs only when live validation does
|
|
4355
|
+
// not, so the walk that produces them is left for `getStateFromProps` to ask for
|
|
4356
|
+
() => (0, import_utils52.getChangedFields)(this.props.formData, prevProps.formData, true),
|
|
4358
4357
|
// Skip live validation for this request if no form data has changed from the last state
|
|
4359
4358
|
!isStateDataChanged
|
|
4360
4359
|
);
|
|
@@ -4398,12 +4397,13 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4398
4397
|
* @param inputFormData - The new or current data for the `Form`
|
|
4399
4398
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
4400
4399
|
* @param [isSchemaChanged=false] - A flag indicating whether the schema has changed.
|
|
4401
|
-
* @param [
|
|
4400
|
+
* @param [getFormDataChangedFields=() => []] - Optional function returning the path of each `formData` field that
|
|
4401
|
+
* changed, only called when those paths are needed, which is when live validation is not going to run
|
|
4402
4402
|
* @param [skipLiveValidate=false] - Optional flag, if true, means that we are not running live validation
|
|
4403
4403
|
* @param [shouldSanitize=false] - Optional flag, if true, means that we should attempt to sanitize formData
|
|
4404
4404
|
* @returns - The new state for the `Form`
|
|
4405
4405
|
*/
|
|
4406
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false,
|
|
4406
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, getFormDataChangedFields = () => [], skipLiveValidate = false, shouldSanitize = false) {
|
|
4407
4407
|
const state = this.state || {};
|
|
4408
4408
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
4409
4409
|
const validator2 = "validator" in props ? props.validator : this.props.validator;
|
|
@@ -4508,17 +4508,23 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4508
4508
|
const currentErrors = getCurrentErrors();
|
|
4509
4509
|
errors = currentErrors.errors;
|
|
4510
4510
|
errorSchema = currentErrors.errorSchema;
|
|
4511
|
-
if (
|
|
4512
|
-
const
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4511
|
+
if (!mustValidate) {
|
|
4512
|
+
const formDataChangedFields = getFormDataChangedFields();
|
|
4513
|
+
if (formDataChangedFields.length > 0) {
|
|
4514
|
+
const newErrorSchema = formDataChangedFields.reduce((acc, path) => {
|
|
4515
|
+
const pathOfField = (0, import_utils52.toPath)(path);
|
|
4516
|
+
for (let i = 1; i < pathOfField.length; i++) {
|
|
4517
|
+
(0, import_utils52.setByPath)(acc, [...pathOfField.slice(0, i), import_utils52.ERRORS_KEY], void 0, true);
|
|
4518
|
+
}
|
|
4519
|
+
return (0, import_utils52.setByPath)(acc, pathOfField, void 0, true);
|
|
4520
|
+
}, {});
|
|
4521
|
+
schemaValidationErrorSchema = (0, import_utils52.mergeObjects)(
|
|
4522
|
+
currentErrors.errorSchema,
|
|
4523
|
+
newErrorSchema,
|
|
4524
|
+
"preventDuplicates"
|
|
4525
|
+
);
|
|
4526
|
+
errorSchema = schemaValidationErrorSchema;
|
|
4527
|
+
}
|
|
4522
4528
|
}
|
|
4523
4529
|
const mergedErrors = _Form.mergeErrors({ errorSchema, errors }, props.extraErrors, state.customErrors);
|
|
4524
4530
|
errors = mergedErrors.errors;
|
|
@@ -4716,14 +4722,14 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4716
4722
|
let mergeBaseErrorSchema = schemaValidationErrorSchema;
|
|
4717
4723
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4718
4724
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4719
|
-
let formData = isRootPath ? newValue : (
|
|
4725
|
+
let formData = isRootPath ? newValue : structuredClone(oldFormData);
|
|
4720
4726
|
const hasOnlyUndefinedValues = (0, import_utils52.isObject)(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4721
4727
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
4722
4728
|
const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
|
|
4723
4729
|
if ((0, import_utils52.isObject)(formData) || Array.isArray(formData)) {
|
|
4724
4730
|
let plainLeafWasCleared = false;
|
|
4725
4731
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4726
|
-
(0,
|
|
4732
|
+
(0, import_utils52.unsetByPath)(formData, path);
|
|
4727
4733
|
} else if (!isRootPath) {
|
|
4728
4734
|
let valueForPath = newValue;
|
|
4729
4735
|
if (newValue === void 0) {
|
|
@@ -4740,9 +4746,9 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4740
4746
|
}
|
|
4741
4747
|
}
|
|
4742
4748
|
if (plainLeafWasCleared) {
|
|
4743
|
-
(0,
|
|
4749
|
+
(0, import_utils52.setByPath)(formData, path, void 0);
|
|
4744
4750
|
} else {
|
|
4745
|
-
(0,
|
|
4751
|
+
(0, import_utils52.setByPath)(formData, path, valueForPath);
|
|
4746
4752
|
}
|
|
4747
4753
|
}
|
|
4748
4754
|
const shouldSanitize = retrievedSchema && !isRootPath && !(0, import_utils52.isObject)(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
@@ -4758,7 +4764,7 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4758
4764
|
formData = newState.formData;
|
|
4759
4765
|
retrievedSchema = newState.retrievedSchema;
|
|
4760
4766
|
if (plainLeafWasCleared && formData) {
|
|
4761
|
-
(0,
|
|
4767
|
+
(0, import_utils52.setByPath)(formData, path, void 0);
|
|
4762
4768
|
}
|
|
4763
4769
|
}
|
|
4764
4770
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
@@ -4769,11 +4775,11 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4769
4775
|
state = { ...state, formData: newFormData };
|
|
4770
4776
|
}
|
|
4771
4777
|
if (newErrorSchema) {
|
|
4772
|
-
const oldValidationError = !isRootPath ? (0,
|
|
4773
|
-
if (
|
|
4778
|
+
const oldValidationError = !isRootPath ? (0, import_utils52.getByPath)(schemaValidationErrorSchema, path) : schemaValidationErrorSchema;
|
|
4779
|
+
if (oldValidationError && Object.keys(oldValidationError).length > 0) {
|
|
4774
4780
|
if (!isRootPath) {
|
|
4775
|
-
mergeBaseErrorSchema = (
|
|
4776
|
-
(0,
|
|
4781
|
+
mergeBaseErrorSchema = structuredClone(schemaValidationErrorSchema);
|
|
4782
|
+
(0, import_utils52.setByPath)(mergeBaseErrorSchema, path, newErrorSchema, true);
|
|
4777
4783
|
} else {
|
|
4778
4784
|
mergeBaseErrorSchema = newErrorSchema;
|
|
4779
4785
|
}
|
|
@@ -4782,15 +4788,15 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4782
4788
|
customErrors = new import_utils52.ErrorSchemaBuilder();
|
|
4783
4789
|
}
|
|
4784
4790
|
if (isRootPath) {
|
|
4785
|
-
const pathErrors =
|
|
4791
|
+
const pathErrors = newErrorSchema[import_utils52.ERRORS_KEY];
|
|
4786
4792
|
if (pathErrors) {
|
|
4787
4793
|
customErrors.setErrors(pathErrors);
|
|
4788
4794
|
}
|
|
4789
4795
|
} else {
|
|
4790
|
-
(0,
|
|
4796
|
+
(0, import_utils52.setByPath)(customErrors.ErrorSchema, path, newErrorSchema, true);
|
|
4791
4797
|
}
|
|
4792
4798
|
}
|
|
4793
|
-
} else if (customErrors && (0,
|
|
4799
|
+
} else if (customErrors && (0, import_utils52.getByPath)(customErrors.ErrorSchema, [...path, import_utils52.ERRORS_KEY])) {
|
|
4794
4800
|
customErrors.clearErrors(path);
|
|
4795
4801
|
}
|
|
4796
4802
|
if (mustValidate && this.pendingChanges.length === 1) {
|
|
@@ -4896,8 +4902,8 @@ var Form = class _Form extends import_react28.Component {
|
|
|
4896
4902
|
state = { formData: newFormData, ...liveValidation, customErrors };
|
|
4897
4903
|
}
|
|
4898
4904
|
const hasChanges = Object.keys(state).filter((key) => !key.startsWith("schemaValidation")).some((key) => {
|
|
4899
|
-
const oldData =
|
|
4900
|
-
const newData =
|
|
4905
|
+
const oldData = this.state[key];
|
|
4906
|
+
const newData = state[key];
|
|
4901
4907
|
return !(0, import_utils52.deepEquals)(oldData, newData);
|
|
4902
4908
|
});
|
|
4903
4909
|
this.setState(state, () => {
|
|
@@ -5025,12 +5031,8 @@ var Form = class _Form extends import_react28.Component {
|
|
|
5025
5031
|
focusOnError(error) {
|
|
5026
5032
|
const { idPrefix = "root", idSeparator = "_" } = this.props;
|
|
5027
5033
|
const { property } = error;
|
|
5028
|
-
const path = (0,
|
|
5029
|
-
|
|
5030
|
-
path[0] = idPrefix;
|
|
5031
|
-
} else {
|
|
5032
|
-
path.unshift(idPrefix);
|
|
5033
|
-
}
|
|
5034
|
+
const path = (0, import_utils52.toPath)(property ?? "");
|
|
5035
|
+
path.unshift(idPrefix);
|
|
5034
5036
|
const elementId = path.join(idSeparator);
|
|
5035
5037
|
let field = this.formElement.current.elements[elementId];
|
|
5036
5038
|
if (!field) {
|