@rjsf/core 5.19.3 → 5.20.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 +67 -27
- package/dist/index.esm.js +64 -23
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +64 -23
- package/dist/index.js.map +3 -3
- package/lib/components/Form.d.ts +1 -0
- package/lib/components/Form.js +40 -1
- package/lib/components/Form.js.map +1 -1
- package/lib/components/fields/ArrayField.js +1 -1
- package/lib/components/fields/ArrayField.js.map +1 -1
- package/lib/components/fields/BooleanField.js +2 -2
- package/lib/components/fields/BooleanField.js.map +1 -1
- package/lib/components/fields/ObjectField.js +1 -1
- package/lib/components/fields/ObjectField.js.map +1 -1
- package/lib/components/fields/SchemaField.js +1 -1
- package/lib/components/fields/SchemaField.js.map +1 -1
- package/lib/components/fields/StringField.js +1 -1
- package/lib/components/fields/StringField.js.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/UnsupportedField.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/Form.tsx +42 -1
- package/src/components/fields/ArrayField.tsx +1 -1
- package/src/components/fields/BooleanField.tsx +24 -18
- package/src/components/fields/ObjectField.tsx +1 -1
- package/src/components/fields/SchemaField.tsx +5 -2
- package/src/components/fields/StringField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +1 -1
package/dist/core.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/has'), require('lodash/unset')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', 'markdown-to-jsx', 'lodash/has', 'lodash/unset'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.get3, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.Markdown, global.has, global.unset));
|
|
5
|
-
})(this, (function (exports, react, utils, get3, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2, Markdown, has, unset) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/forEach'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/toPath'), require('lodash/cloneDeep'), require('lodash/isObject'), require('lodash/set'), require('nanoid'), require('react/jsx-runtime'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/has'), require('lodash/unset')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/forEach', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/toPath', 'lodash/cloneDeep', 'lodash/isObject', 'lodash/set', 'nanoid', 'react/jsx-runtime', 'lodash/omit', 'markdown-to-jsx', 'lodash/has', 'lodash/unset'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global._forEach, global.get3, global.isEmpty, global._pick, global._toPath, global.cloneDeep, global.isObject, global.set, global.nanoid, global.jsxRuntime, global.omit2, global.Markdown, global.has, global.unset));
|
|
5
|
+
})(this, (function (exports, react, utils, _forEach, get3, isEmpty, _pick, _toPath, cloneDeep, isObject, set, nanoid, jsxRuntime, omit2, Markdown, has, unset) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/components/Form.tsx
|
|
8
8
|
function generateRowId() {
|
|
@@ -513,7 +513,7 @@
|
|
|
513
513
|
} = this.props;
|
|
514
514
|
const { widgets: widgets2, schemaUtils, formContext, globalUiOptions } = registry;
|
|
515
515
|
const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
516
|
-
const enumOptions = utils.optionsList(itemsSchema);
|
|
516
|
+
const enumOptions = utils.optionsList(itemsSchema, uiSchema);
|
|
517
517
|
const { widget = "select", title: uiTitle, ...options } = utils.getUiOptions(uiSchema, globalUiOptions);
|
|
518
518
|
const Widget = utils.getWidget(schema, widget, widgets2);
|
|
519
519
|
const label = uiTitle ?? schema.title ?? name;
|
|
@@ -804,18 +804,21 @@
|
|
|
804
804
|
let enumOptions;
|
|
805
805
|
const label = uiTitle ?? schemaTitle ?? title ?? name;
|
|
806
806
|
if (Array.isArray(schema.oneOf)) {
|
|
807
|
-
enumOptions = utils.optionsList(
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
807
|
+
enumOptions = utils.optionsList(
|
|
808
|
+
{
|
|
809
|
+
oneOf: schema.oneOf.map((option) => {
|
|
810
|
+
if (isObject(option)) {
|
|
811
|
+
return {
|
|
812
|
+
...option,
|
|
813
|
+
title: option.title || (option.const === true ? yes : no)
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
return void 0;
|
|
817
|
+
}).filter((o) => o)
|
|
818
|
+
// cast away the error that typescript can't grok is fixed
|
|
819
|
+
},
|
|
820
|
+
uiSchema
|
|
821
|
+
);
|
|
819
822
|
} else {
|
|
820
823
|
const schemaWithEnumNames = schema;
|
|
821
824
|
const enums = schema.enum ?? [true, false];
|
|
@@ -831,11 +834,14 @@
|
|
|
831
834
|
}
|
|
832
835
|
];
|
|
833
836
|
} else {
|
|
834
|
-
enumOptions = utils.optionsList(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
837
|
+
enumOptions = utils.optionsList(
|
|
838
|
+
{
|
|
839
|
+
enum: enums,
|
|
840
|
+
// NOTE: enumNames is deprecated, but still supported for now.
|
|
841
|
+
enumNames: schemaWithEnumNames.enumNames
|
|
842
|
+
},
|
|
843
|
+
uiSchema
|
|
844
|
+
);
|
|
839
845
|
}
|
|
840
846
|
}
|
|
841
847
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1267,7 +1273,7 @@
|
|
|
1267
1273
|
orderedProperties = utils.orderProperties(properties, uiOptions.order);
|
|
1268
1274
|
} catch (err) {
|
|
1269
1275
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1270
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1276
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(utils.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1271
1277
|
/* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema) })
|
|
1272
1278
|
] });
|
|
1273
1279
|
}
|
|
@@ -1455,7 +1461,7 @@
|
|
|
1455
1461
|
label = utils.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
1456
1462
|
}
|
|
1457
1463
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
1458
|
-
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: description }) : description;
|
|
1464
|
+
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: description }) : description;
|
|
1459
1465
|
const help = uiOptions.help;
|
|
1460
1466
|
const hidden = uiOptions.widget === "hidden";
|
|
1461
1467
|
const classNames = ["form-group", "field", `field-${utils.getSchemaType(schema)}`];
|
|
@@ -1614,7 +1620,7 @@
|
|
|
1614
1620
|
} = props;
|
|
1615
1621
|
const { title, format } = schema;
|
|
1616
1622
|
const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
|
|
1617
|
-
const enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema) : void 0;
|
|
1623
|
+
const enumOptions = schemaUtils.isSelect(schema) ? utils.optionsList(schema, uiSchema) : void 0;
|
|
1618
1624
|
let defaultWidget = enumOptions ? "select" : "text";
|
|
1619
1625
|
if (format && utils.hasWidget(schema, format, widgets2)) {
|
|
1620
1626
|
defaultWidget = format;
|
|
@@ -2210,7 +2216,7 @@
|
|
|
2210
2216
|
translateParams.push(reason);
|
|
2211
2217
|
}
|
|
2212
2218
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "unsupported-field", children: [
|
|
2213
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { children: translateString(translateEnum, translateParams) }) }),
|
|
2219
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
2214
2220
|
schema && /* @__PURE__ */ jsxRuntime.jsx("pre", { children: JSON.stringify(schema, null, 2) })
|
|
2215
2221
|
] });
|
|
2216
2222
|
}
|
|
@@ -3075,6 +3081,10 @@
|
|
|
3075
3081
|
errorSchema = merged.errorSchema;
|
|
3076
3082
|
errors = merged.errors;
|
|
3077
3083
|
}
|
|
3084
|
+
if (newErrorSchema) {
|
|
3085
|
+
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
3086
|
+
errorSchema = utils.mergeObjects(errorSchema, filteredErrors, "preventDuplicates");
|
|
3087
|
+
}
|
|
3078
3088
|
state = {
|
|
3079
3089
|
formData: newFormData,
|
|
3080
3090
|
errors,
|
|
@@ -3352,7 +3362,15 @@
|
|
|
3352
3362
|
if (mustValidate) {
|
|
3353
3363
|
const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
|
|
3354
3364
|
errors = schemaValidation.errors;
|
|
3355
|
-
|
|
3365
|
+
if (isSchemaChanged) {
|
|
3366
|
+
errorSchema = schemaValidation.errorSchema;
|
|
3367
|
+
} else {
|
|
3368
|
+
errorSchema = utils.mergeObjects(
|
|
3369
|
+
this.state?.errorSchema,
|
|
3370
|
+
schemaValidation.errorSchema,
|
|
3371
|
+
"preventDuplicates"
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3356
3374
|
schemaValidationErrors = errors;
|
|
3357
3375
|
schemaValidationErrorSchema = errorSchema;
|
|
3358
3376
|
} else {
|
|
@@ -3430,6 +3448,28 @@
|
|
|
3430
3448
|
}
|
|
3431
3449
|
return null;
|
|
3432
3450
|
}
|
|
3451
|
+
// Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
|
|
3452
|
+
filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
|
|
3453
|
+
const { retrievedSchema, schemaUtils } = this.state;
|
|
3454
|
+
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
3455
|
+
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, "", formData);
|
|
3456
|
+
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
3457
|
+
const filteredErrors = _pick(schemaErrors, fieldNames);
|
|
3458
|
+
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
3459
|
+
filteredErrors.__errors = schemaErrors.__errors;
|
|
3460
|
+
}
|
|
3461
|
+
const filterUndefinedErrors = (errors) => {
|
|
3462
|
+
_forEach(errors, (errorAtKey, errorKey) => {
|
|
3463
|
+
if (errorAtKey === void 0) {
|
|
3464
|
+
delete errors[errorKey];
|
|
3465
|
+
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
3466
|
+
filterUndefinedErrors(errorAtKey);
|
|
3467
|
+
}
|
|
3468
|
+
});
|
|
3469
|
+
return errors;
|
|
3470
|
+
};
|
|
3471
|
+
return filterUndefinedErrors(filteredErrors);
|
|
3472
|
+
}
|
|
3433
3473
|
/** Returns the registry for the form */
|
|
3434
3474
|
getRegistry() {
|
|
3435
3475
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
package/dist/index.esm.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
UI_OPTIONS_KEY as UI_OPTIONS_KEY2,
|
|
17
17
|
validationDataMerge
|
|
18
18
|
} from "@rjsf/utils";
|
|
19
|
+
import _forEach from "lodash/forEach";
|
|
19
20
|
import _get from "lodash/get";
|
|
20
21
|
import _isEmpty from "lodash/isEmpty";
|
|
21
22
|
import _pick from "lodash/pick";
|
|
@@ -551,7 +552,7 @@ var ArrayField = class extends Component {
|
|
|
551
552
|
} = this.props;
|
|
552
553
|
const { widgets: widgets2, schemaUtils, formContext, globalUiOptions } = registry;
|
|
553
554
|
const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
|
|
554
|
-
const enumOptions = optionsList(itemsSchema);
|
|
555
|
+
const enumOptions = optionsList(itemsSchema, uiSchema);
|
|
555
556
|
const { widget = "select", title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
|
|
556
557
|
const Widget = getWidget(schema, widget, widgets2);
|
|
557
558
|
const label = uiTitle ?? schema.title ?? name;
|
|
@@ -852,18 +853,21 @@ function BooleanField(props) {
|
|
|
852
853
|
let enumOptions;
|
|
853
854
|
const label = uiTitle ?? schemaTitle ?? title ?? name;
|
|
854
855
|
if (Array.isArray(schema.oneOf)) {
|
|
855
|
-
enumOptions = optionsList2(
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
856
|
+
enumOptions = optionsList2(
|
|
857
|
+
{
|
|
858
|
+
oneOf: schema.oneOf.map((option) => {
|
|
859
|
+
if (isObject2(option)) {
|
|
860
|
+
return {
|
|
861
|
+
...option,
|
|
862
|
+
title: option.title || (option.const === true ? yes : no)
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
return void 0;
|
|
866
|
+
}).filter((o) => o)
|
|
867
|
+
// cast away the error that typescript can't grok is fixed
|
|
868
|
+
},
|
|
869
|
+
uiSchema
|
|
870
|
+
);
|
|
867
871
|
} else {
|
|
868
872
|
const schemaWithEnumNames = schema;
|
|
869
873
|
const enums = schema.enum ?? [true, false];
|
|
@@ -879,11 +883,14 @@ function BooleanField(props) {
|
|
|
879
883
|
}
|
|
880
884
|
];
|
|
881
885
|
} else {
|
|
882
|
-
enumOptions = optionsList2(
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
886
|
+
enumOptions = optionsList2(
|
|
887
|
+
{
|
|
888
|
+
enum: enums,
|
|
889
|
+
// NOTE: enumNames is deprecated, but still supported for now.
|
|
890
|
+
enumNames: schemaWithEnumNames.enumNames
|
|
891
|
+
},
|
|
892
|
+
uiSchema
|
|
893
|
+
);
|
|
887
894
|
}
|
|
888
895
|
}
|
|
889
896
|
return /* @__PURE__ */ jsx2(
|
|
@@ -1359,7 +1366,7 @@ var ObjectField = class extends Component3 {
|
|
|
1359
1366
|
orderedProperties = orderProperties(properties, uiOptions.order);
|
|
1360
1367
|
} catch (err) {
|
|
1361
1368
|
return /* @__PURE__ */ jsxs2("div", { children: [
|
|
1362
|
-
/* @__PURE__ */ jsx5("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx5(Markdown, { children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1369
|
+
/* @__PURE__ */ jsx5("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx5(Markdown, { options: { disableParsingRawHTML: true }, children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
1363
1370
|
/* @__PURE__ */ jsx5("pre", { children: JSON.stringify(schema) })
|
|
1364
1371
|
] });
|
|
1365
1372
|
}
|
|
@@ -1566,7 +1573,7 @@ function SchemaFieldRender(props) {
|
|
|
1566
1573
|
label = ADDITIONAL_PROPERTY_FLAG2 in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
1567
1574
|
}
|
|
1568
1575
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
1569
|
-
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx6(Markdown2, { children: description }) : description;
|
|
1576
|
+
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx6(Markdown2, { options: { disableParsingRawHTML: true }, children: description }) : description;
|
|
1570
1577
|
const help = uiOptions.help;
|
|
1571
1578
|
const hidden = uiOptions.widget === "hidden";
|
|
1572
1579
|
const classNames = ["form-group", "field", `field-${getSchemaType(schema)}`];
|
|
@@ -1734,7 +1741,7 @@ function StringField(props) {
|
|
|
1734
1741
|
} = props;
|
|
1735
1742
|
const { title, format } = schema;
|
|
1736
1743
|
const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
|
|
1737
|
-
const enumOptions = schemaUtils.isSelect(schema) ? optionsList3(schema) : void 0;
|
|
1744
|
+
const enumOptions = schemaUtils.isSelect(schema) ? optionsList3(schema, uiSchema) : void 0;
|
|
1738
1745
|
let defaultWidget = enumOptions ? "select" : "text";
|
|
1739
1746
|
if (format && hasWidget(schema, format, widgets2)) {
|
|
1740
1747
|
defaultWidget = format;
|
|
@@ -2429,7 +2436,7 @@ function UnsupportedField(props) {
|
|
|
2429
2436
|
translateParams.push(reason);
|
|
2430
2437
|
}
|
|
2431
2438
|
return /* @__PURE__ */ jsxs12("div", { className: "unsupported-field", children: [
|
|
2432
|
-
/* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(Markdown3, { children: translateString(translateEnum, translateParams) }) }),
|
|
2439
|
+
/* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(Markdown3, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
2433
2440
|
schema && /* @__PURE__ */ jsx24("pre", { children: JSON.stringify(schema, null, 2) })
|
|
2434
2441
|
] });
|
|
2435
2442
|
}
|
|
@@ -3425,6 +3432,10 @@ var Form = class extends Component5 {
|
|
|
3425
3432
|
errorSchema = merged.errorSchema;
|
|
3426
3433
|
errors = merged.errors;
|
|
3427
3434
|
}
|
|
3435
|
+
if (newErrorSchema) {
|
|
3436
|
+
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
3437
|
+
errorSchema = mergeObjects2(errorSchema, filteredErrors, "preventDuplicates");
|
|
3438
|
+
}
|
|
3428
3439
|
state = {
|
|
3429
3440
|
formData: newFormData,
|
|
3430
3441
|
errors,
|
|
@@ -3705,7 +3716,15 @@ var Form = class extends Component5 {
|
|
|
3705
3716
|
if (mustValidate) {
|
|
3706
3717
|
const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
|
|
3707
3718
|
errors = schemaValidation.errors;
|
|
3708
|
-
|
|
3719
|
+
if (isSchemaChanged) {
|
|
3720
|
+
errorSchema = schemaValidation.errorSchema;
|
|
3721
|
+
} else {
|
|
3722
|
+
errorSchema = mergeObjects2(
|
|
3723
|
+
this.state?.errorSchema,
|
|
3724
|
+
schemaValidation.errorSchema,
|
|
3725
|
+
"preventDuplicates"
|
|
3726
|
+
);
|
|
3727
|
+
}
|
|
3709
3728
|
schemaValidationErrors = errors;
|
|
3710
3729
|
schemaValidationErrorSchema = errorSchema;
|
|
3711
3730
|
} else {
|
|
@@ -3783,6 +3802,28 @@ var Form = class extends Component5 {
|
|
|
3783
3802
|
}
|
|
3784
3803
|
return null;
|
|
3785
3804
|
}
|
|
3805
|
+
// Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
|
|
3806
|
+
filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
|
|
3807
|
+
const { retrievedSchema, schemaUtils } = this.state;
|
|
3808
|
+
const _retrievedSchema = resolvedSchema ?? retrievedSchema;
|
|
3809
|
+
const pathSchema = schemaUtils.toPathSchema(_retrievedSchema, "", formData);
|
|
3810
|
+
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
3811
|
+
const filteredErrors = _pick(schemaErrors, fieldNames);
|
|
3812
|
+
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
3813
|
+
filteredErrors.__errors = schemaErrors.__errors;
|
|
3814
|
+
}
|
|
3815
|
+
const filterUndefinedErrors = (errors) => {
|
|
3816
|
+
_forEach(errors, (errorAtKey, errorKey) => {
|
|
3817
|
+
if (errorAtKey === void 0) {
|
|
3818
|
+
delete errors[errorKey];
|
|
3819
|
+
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
3820
|
+
filterUndefinedErrors(errorAtKey);
|
|
3821
|
+
}
|
|
3822
|
+
});
|
|
3823
|
+
return errors;
|
|
3824
|
+
};
|
|
3825
|
+
return filterUndefinedErrors(filteredErrors);
|
|
3826
|
+
}
|
|
3786
3827
|
/** Returns the registry for the form */
|
|
3787
3828
|
getRegistry() {
|
|
3788
3829
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|