@rjsf/utils 5.24.2 → 5.24.3
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/index.js +24 -29
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +24 -29
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +27 -32
- package/lib/deepEquals.d.ts +3 -3
- package/lib/deepEquals.js +13 -15
- package/lib/deepEquals.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/deepEquals.ts +13 -16
package/dist/utils.esm.js
CHANGED
|
@@ -131,20 +131,15 @@ function createErrorHandler(formData) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/deepEquals.ts
|
|
134
|
-
import
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return typeof b === "function";
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
});
|
|
147
|
-
var deepEquals_default = deepEquals;
|
|
134
|
+
import isEqualWith from "lodash/isEqualWith";
|
|
135
|
+
function deepEquals(a, b) {
|
|
136
|
+
return isEqualWith(a, b, (obj, other) => {
|
|
137
|
+
if (typeof obj === "function" && typeof other === "function") {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
return void 0;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
148
143
|
|
|
149
144
|
// src/schema/getDefaultFormState.ts
|
|
150
145
|
import get7 from "lodash/get";
|
|
@@ -564,7 +559,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
564
559
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
565
560
|
};
|
|
566
561
|
}
|
|
567
|
-
return
|
|
562
|
+
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
568
563
|
}
|
|
569
564
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
570
565
|
const schema = {
|
|
@@ -1313,7 +1308,7 @@ function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, e
|
|
|
1313
1308
|
let validFormData = formData;
|
|
1314
1309
|
if (isSelectField) {
|
|
1315
1310
|
const getOptionsList = optionsList(schema);
|
|
1316
|
-
const isValid = getOptionsList?.some((option) =>
|
|
1311
|
+
const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));
|
|
1317
1312
|
validFormData = isValid ? formData : void 0;
|
|
1318
1313
|
}
|
|
1319
1314
|
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
@@ -1727,7 +1722,7 @@ import get9 from "lodash/get";
|
|
|
1727
1722
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1728
1723
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1729
1724
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1730
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1725
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1731
1726
|
if (sameSchemaIndex === -1) {
|
|
1732
1727
|
return toIdSchemaInternal(
|
|
1733
1728
|
validator,
|
|
@@ -1798,7 +1793,7 @@ import set2 from "lodash/set";
|
|
|
1798
1793
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1799
1794
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1800
1795
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1801
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1796
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1802
1797
|
if (sameSchemaIndex === -1) {
|
|
1803
1798
|
return toPathSchemaInternal(
|
|
1804
1799
|
validator,
|
|
@@ -1942,7 +1937,7 @@ var SchemaUtils = class {
|
|
|
1942
1937
|
if (!validator || !rootSchema) {
|
|
1943
1938
|
return false;
|
|
1944
1939
|
}
|
|
1945
|
-
return this.validator !== validator || !
|
|
1940
|
+
return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
1946
1941
|
}
|
|
1947
1942
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1948
1943
|
* computed to have defaults provided in the `schema`.
|
|
@@ -2250,17 +2245,17 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
|
2250
2245
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2251
2246
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2252
2247
|
if (Array.isArray(selected)) {
|
|
2253
|
-
return selected.filter((v) => !
|
|
2248
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
2254
2249
|
}
|
|
2255
|
-
return
|
|
2250
|
+
return deepEquals(value, selected) ? void 0 : selected;
|
|
2256
2251
|
}
|
|
2257
2252
|
|
|
2258
2253
|
// src/enumOptionsIsSelected.ts
|
|
2259
2254
|
function enumOptionsIsSelected(value, selected) {
|
|
2260
2255
|
if (Array.isArray(selected)) {
|
|
2261
|
-
return selected.some((sel) =>
|
|
2256
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
2262
2257
|
}
|
|
2263
|
-
return
|
|
2258
|
+
return deepEquals(selected, value);
|
|
2264
2259
|
}
|
|
2265
2260
|
|
|
2266
2261
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2727,7 +2722,7 @@ function schemaRequiresTrueValue(schema) {
|
|
|
2727
2722
|
// src/shouldRender.ts
|
|
2728
2723
|
function shouldRender(component, nextProps, nextState) {
|
|
2729
2724
|
const { props, state } = component;
|
|
2730
|
-
return !
|
|
2725
|
+
return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
|
|
2731
2726
|
}
|
|
2732
2727
|
|
|
2733
2728
|
// src/toDateString.ts
|
|
@@ -2885,7 +2880,7 @@ function getChangedFields(a, b) {
|
|
|
2885
2880
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
2886
2881
|
return keys(b);
|
|
2887
2882
|
} else {
|
|
2888
|
-
const unequalFields = keys(pickBy(a, (value, key) => !
|
|
2883
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get13(b, key))));
|
|
2889
2884
|
const diffFields = difference(keys(b), keys(a));
|
|
2890
2885
|
return [...unequalFields, ...diffFields];
|
|
2891
2886
|
}
|
|
@@ -2960,7 +2955,7 @@ var ParserValidator = class {
|
|
|
2960
2955
|
const existing = this.schemaMap[key];
|
|
2961
2956
|
if (!existing) {
|
|
2962
2957
|
this.schemaMap[key] = identifiedSchema;
|
|
2963
|
-
} else if (!
|
|
2958
|
+
} else if (!deepEquals(existing, identifiedSchema)) {
|
|
2964
2959
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
2965
2960
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
2966
2961
|
throw new Error(
|
|
@@ -2982,7 +2977,7 @@ var ParserValidator = class {
|
|
|
2982
2977
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
2983
2978
|
*/
|
|
2984
2979
|
isValid(schema, _formData, rootSchema) {
|
|
2985
|
-
if (!
|
|
2980
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
2986
2981
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
2987
2982
|
}
|
|
2988
2983
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -3022,7 +3017,7 @@ var ParserValidator = class {
|
|
|
3022
3017
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
3023
3018
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
3024
3019
|
schemas.forEach((schema2) => {
|
|
3025
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
3020
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
|
|
3026
3021
|
if (sameSchemaIndex === -1) {
|
|
3027
3022
|
recurseList.push(schema2);
|
|
3028
3023
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
@@ -3083,7 +3078,7 @@ export {
|
|
|
3083
3078
|
createSchemaUtils,
|
|
3084
3079
|
dataURItoBlob,
|
|
3085
3080
|
dateRangeOptions,
|
|
3086
|
-
|
|
3081
|
+
deepEquals,
|
|
3087
3082
|
descriptionId,
|
|
3088
3083
|
englishStringTranslator,
|
|
3089
3084
|
enumOptionsDeselectValue,
|