@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/index.js
CHANGED
|
@@ -67,7 +67,7 @@ __export(src_exports, {
|
|
|
67
67
|
createSchemaUtils: () => createSchemaUtils,
|
|
68
68
|
dataURItoBlob: () => dataURItoBlob,
|
|
69
69
|
dateRangeOptions: () => dateRangeOptions,
|
|
70
|
-
deepEquals: () =>
|
|
70
|
+
deepEquals: () => deepEquals,
|
|
71
71
|
descriptionId: () => descriptionId,
|
|
72
72
|
englishStringTranslator: () => englishStringTranslator,
|
|
73
73
|
enumOptionsDeselectValue: () => enumOptionsDeselectValue,
|
|
@@ -269,20 +269,15 @@ function createErrorHandler(formData) {
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// src/deepEquals.ts
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return typeof b === "function";
|
|
282
|
-
}
|
|
283
|
-
})
|
|
284
|
-
});
|
|
285
|
-
var deepEquals_default = deepEquals;
|
|
272
|
+
var import_isEqualWith = __toESM(require("lodash/isEqualWith"));
|
|
273
|
+
function deepEquals(a, b) {
|
|
274
|
+
return (0, import_isEqualWith.default)(a, b, (obj, other) => {
|
|
275
|
+
if (typeof obj === "function" && typeof other === "function") {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
return void 0;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
286
281
|
|
|
287
282
|
// src/schema/getDefaultFormState.ts
|
|
288
283
|
var import_get7 = __toESM(require("lodash/get"));
|
|
@@ -702,7 +697,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
702
697
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
703
698
|
};
|
|
704
699
|
}
|
|
705
|
-
return
|
|
700
|
+
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
706
701
|
}
|
|
707
702
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
708
703
|
const schema = {
|
|
@@ -1451,7 +1446,7 @@ function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, e
|
|
|
1451
1446
|
let validFormData = formData;
|
|
1452
1447
|
if (isSelectField) {
|
|
1453
1448
|
const getOptionsList = optionsList(schema);
|
|
1454
|
-
const isValid = getOptionsList?.some((option) =>
|
|
1449
|
+
const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));
|
|
1455
1450
|
validFormData = isValid ? formData : void 0;
|
|
1456
1451
|
}
|
|
1457
1452
|
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
@@ -1865,7 +1860,7 @@ var import_get9 = __toESM(require("lodash/get"));
|
|
|
1865
1860
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1866
1861
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1867
1862
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1868
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1863
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1869
1864
|
if (sameSchemaIndex === -1) {
|
|
1870
1865
|
return toIdSchemaInternal(
|
|
1871
1866
|
validator,
|
|
@@ -1936,7 +1931,7 @@ var import_set2 = __toESM(require("lodash/set"));
|
|
|
1936
1931
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1937
1932
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1938
1933
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1939
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1934
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1940
1935
|
if (sameSchemaIndex === -1) {
|
|
1941
1936
|
return toPathSchemaInternal(
|
|
1942
1937
|
validator,
|
|
@@ -2080,7 +2075,7 @@ var SchemaUtils = class {
|
|
|
2080
2075
|
if (!validator || !rootSchema) {
|
|
2081
2076
|
return false;
|
|
2082
2077
|
}
|
|
2083
|
-
return this.validator !== validator || !
|
|
2078
|
+
return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
2084
2079
|
}
|
|
2085
2080
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
2086
2081
|
* computed to have defaults provided in the `schema`.
|
|
@@ -2388,17 +2383,17 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
|
2388
2383
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2389
2384
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2390
2385
|
if (Array.isArray(selected)) {
|
|
2391
|
-
return selected.filter((v) => !
|
|
2386
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
2392
2387
|
}
|
|
2393
|
-
return
|
|
2388
|
+
return deepEquals(value, selected) ? void 0 : selected;
|
|
2394
2389
|
}
|
|
2395
2390
|
|
|
2396
2391
|
// src/enumOptionsIsSelected.ts
|
|
2397
2392
|
function enumOptionsIsSelected(value, selected) {
|
|
2398
2393
|
if (Array.isArray(selected)) {
|
|
2399
|
-
return selected.some((sel) =>
|
|
2394
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
2400
2395
|
}
|
|
2401
|
-
return
|
|
2396
|
+
return deepEquals(selected, value);
|
|
2402
2397
|
}
|
|
2403
2398
|
|
|
2404
2399
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2865,7 +2860,7 @@ function schemaRequiresTrueValue(schema) {
|
|
|
2865
2860
|
// src/shouldRender.ts
|
|
2866
2861
|
function shouldRender(component, nextProps, nextState) {
|
|
2867
2862
|
const { props, state } = component;
|
|
2868
|
-
return !
|
|
2863
|
+
return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
|
|
2869
2864
|
}
|
|
2870
2865
|
|
|
2871
2866
|
// src/toDateString.ts
|
|
@@ -3023,7 +3018,7 @@ function getChangedFields(a, b) {
|
|
|
3023
3018
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
3024
3019
|
return (0, import_keys.default)(b);
|
|
3025
3020
|
} else {
|
|
3026
|
-
const unequalFields = (0, import_keys.default)((0, import_pickBy.default)(a, (value, key) => !
|
|
3021
|
+
const unequalFields = (0, import_keys.default)((0, import_pickBy.default)(a, (value, key) => !deepEquals(value, (0, import_get13.default)(b, key))));
|
|
3027
3022
|
const diffFields = (0, import_difference.default)((0, import_keys.default)(b), (0, import_keys.default)(a));
|
|
3028
3023
|
return [...unequalFields, ...diffFields];
|
|
3029
3024
|
}
|
|
@@ -3098,7 +3093,7 @@ var ParserValidator = class {
|
|
|
3098
3093
|
const existing = this.schemaMap[key];
|
|
3099
3094
|
if (!existing) {
|
|
3100
3095
|
this.schemaMap[key] = identifiedSchema;
|
|
3101
|
-
} else if (!
|
|
3096
|
+
} else if (!deepEquals(existing, identifiedSchema)) {
|
|
3102
3097
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
3103
3098
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
3104
3099
|
throw new Error(
|
|
@@ -3120,7 +3115,7 @@ var ParserValidator = class {
|
|
|
3120
3115
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
3121
3116
|
*/
|
|
3122
3117
|
isValid(schema, _formData, rootSchema) {
|
|
3123
|
-
if (!
|
|
3118
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
3124
3119
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
3125
3120
|
}
|
|
3126
3121
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -3160,7 +3155,7 @@ var ParserValidator = class {
|
|
|
3160
3155
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
3161
3156
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
3162
3157
|
schemas.forEach((schema2) => {
|
|
3163
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
3158
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
|
|
3164
3159
|
if (sameSchemaIndex === -1) {
|
|
3165
3160
|
recurseList.push(schema2);
|
|
3166
3161
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|