@rjsf/utils 6.5.0 → 6.5.2
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.cjs +30 -32
- package/dist/index.cjs.map +3 -3
- package/dist/utils.esm.js +30 -32
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +33 -32
- package/lib/deepEquals.d.ts +5 -3
- package/lib/deepEquals.js +13 -13
- package/lib/deepEquals.js.map +1 -1
- package/lib/isRootSchema.js +3 -3
- package/lib/isRootSchema.js.map +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js +2 -2
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
- package/lib/schema/getDefaultFormState.js +8 -5
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/useDeepCompareMemo.js +2 -2
- package/lib/useDeepCompareMemo.js.map +1 -1
- package/package.json +2 -1
- package/src/deepEquals.ts +14 -13
- package/src/isRootSchema.ts +3 -3
- package/src/schema/findSelectedOptionInXxxOf.ts +2 -2
- package/src/schema/getDefaultFormState.ts +8 -5
- package/src/useDeepCompareMemo.ts +3 -2
package/dist/utils.esm.js
CHANGED
|
@@ -145,15 +145,16 @@ function createErrorHandler(formData) {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// src/deepEquals.ts
|
|
148
|
-
import
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
import { createCustomEqual } from "fast-equals";
|
|
149
|
+
var deepEquals = createCustomEqual({
|
|
150
|
+
circular: true,
|
|
151
|
+
createCustomConfig: () => ({
|
|
152
|
+
areFunctionsEqual(_a, b) {
|
|
153
|
+
return typeof b === "function";
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
var deepEquals_default = deepEquals;
|
|
157
158
|
|
|
158
159
|
// src/schema/findFieldInSchema.ts
|
|
159
160
|
import get8 from "lodash/get";
|
|
@@ -161,7 +162,6 @@ import has3 from "lodash/has";
|
|
|
161
162
|
|
|
162
163
|
// src/schema/findSelectedOptionInXxxOf.ts
|
|
163
164
|
import get6 from "lodash/get";
|
|
164
|
-
import isEqual from "lodash/isEqual";
|
|
165
165
|
|
|
166
166
|
// src/schema/retrieveSchema.ts
|
|
167
167
|
import get5 from "lodash/get";
|
|
@@ -664,7 +664,7 @@ function resolveAllReferences(schema, rootSchema, recurseList, baseURI, resolveA
|
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
|
-
return
|
|
667
|
+
return deepEquals_default(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
668
668
|
}
|
|
669
669
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
670
670
|
const schema = {
|
|
@@ -1002,7 +1002,7 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
|
|
|
1002
1002
|
const data = get6(formData, selectorField);
|
|
1003
1003
|
if (data !== void 0) {
|
|
1004
1004
|
return xxxOfs.find((xxx2) => {
|
|
1005
|
-
return
|
|
1005
|
+
return deepEquals_default(
|
|
1006
1006
|
get6(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get6(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
1007
1007
|
data
|
|
1008
1008
|
);
|
|
@@ -1671,7 +1671,7 @@ function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, e
|
|
|
1671
1671
|
let validFormData = formData;
|
|
1672
1672
|
if (isSelectField) {
|
|
1673
1673
|
const getOptionsList = optionsList(schema);
|
|
1674
|
-
const isValid = getOptionsList?.some((option) =>
|
|
1674
|
+
const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
|
|
1675
1675
|
validFormData = isValid ? formData : void 0;
|
|
1676
1676
|
}
|
|
1677
1677
|
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
@@ -1732,14 +1732,14 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1732
1732
|
if (retrievedSchema.additionalProperties && !initialDefaultsGenerated) {
|
|
1733
1733
|
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1734
1734
|
const keys2 = /* @__PURE__ */ new Set();
|
|
1735
|
-
if (isObject(defaults)) {
|
|
1736
|
-
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys2.add(key));
|
|
1737
|
-
}
|
|
1738
1735
|
const formDataRequired = [];
|
|
1739
1736
|
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1740
1737
|
keys2.add(key);
|
|
1741
1738
|
formDataRequired.push(key);
|
|
1742
1739
|
});
|
|
1740
|
+
if (isObject(defaults) && formDataRequired.length === 0) {
|
|
1741
|
+
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys2.add(key));
|
|
1742
|
+
}
|
|
1743
1743
|
keys2.forEach((key) => {
|
|
1744
1744
|
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1745
1745
|
rootSchema,
|
|
@@ -1973,7 +1973,7 @@ import set2 from "lodash/set";
|
|
|
1973
1973
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1974
1974
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
|
|
1975
1975
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1976
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1976
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
1977
1977
|
if (sameSchemaIndex === -1) {
|
|
1978
1978
|
return toPathSchemaInternal(
|
|
1979
1979
|
validator,
|
|
@@ -2325,7 +2325,7 @@ var SchemaUtils = class {
|
|
|
2325
2325
|
if (!validator || !rootSchema) {
|
|
2326
2326
|
return false;
|
|
2327
2327
|
}
|
|
2328
|
-
return this.validator !== validator || !
|
|
2328
|
+
return this.validator !== validator || !deepEquals_default(this.rootSchema, rootSchema) || !deepEquals_default(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
2329
2329
|
}
|
|
2330
2330
|
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
2331
2331
|
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
@@ -2667,9 +2667,9 @@ function englishStringTranslator(stringToTranslate, params) {
|
|
|
2667
2667
|
// src/enumOptionsIsSelected.ts
|
|
2668
2668
|
function enumOptionsIsSelected(value, selected) {
|
|
2669
2669
|
if (Array.isArray(selected)) {
|
|
2670
|
-
return selected.some((sel) =>
|
|
2670
|
+
return selected.some((sel) => deepEquals_default(sel, value));
|
|
2671
2671
|
}
|
|
2672
|
-
return
|
|
2672
|
+
return deepEquals_default(selected, value);
|
|
2673
2673
|
}
|
|
2674
2674
|
|
|
2675
2675
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2748,9 +2748,9 @@ function enumOptionValueEncoder(value, index, format = "indexed") {
|
|
|
2748
2748
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2749
2749
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2750
2750
|
if (Array.isArray(selected)) {
|
|
2751
|
-
return selected.filter((v) => !
|
|
2751
|
+
return selected.filter((v) => !deepEquals_default(v, value));
|
|
2752
2752
|
}
|
|
2753
|
-
return
|
|
2753
|
+
return deepEquals_default(value, selected) ? void 0 : selected;
|
|
2754
2754
|
}
|
|
2755
2755
|
|
|
2756
2756
|
// src/enumOptionsSelectValue.ts
|
|
@@ -2880,7 +2880,7 @@ function getChangedFields(a, b) {
|
|
|
2880
2880
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
2881
2881
|
return keys(b);
|
|
2882
2882
|
} else {
|
|
2883
|
-
const unequalFields = keys(pickBy(a, (value, key) => !
|
|
2883
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get19(b, key))));
|
|
2884
2884
|
const diffFields = difference(keys(b), keys(a));
|
|
2885
2885
|
return [...unequalFields, ...diffFields];
|
|
2886
2886
|
}
|
|
@@ -3200,16 +3200,15 @@ function isFormDataAvailable(formData) {
|
|
|
3200
3200
|
}
|
|
3201
3201
|
|
|
3202
3202
|
// src/isRootSchema.ts
|
|
3203
|
-
import isEqual2 from "lodash/isEqual";
|
|
3204
3203
|
import omit2 from "lodash/omit";
|
|
3205
3204
|
function isRootSchema(registry, schemaToCompare) {
|
|
3206
3205
|
const { rootSchema, schemaUtils } = registry;
|
|
3207
|
-
if (
|
|
3206
|
+
if (deepEquals_default(schemaToCompare, rootSchema)) {
|
|
3208
3207
|
return true;
|
|
3209
3208
|
}
|
|
3210
3209
|
if (REF_KEY in rootSchema) {
|
|
3211
3210
|
const resolvedSchema = schemaUtils.retrieveSchema(rootSchema);
|
|
3212
|
-
return
|
|
3211
|
+
return deepEquals_default(schemaToCompare, omit2(resolvedSchema, RJSF_REF_KEY));
|
|
3213
3212
|
}
|
|
3214
3213
|
return false;
|
|
3215
3214
|
}
|
|
@@ -3446,7 +3445,7 @@ function shouldRender(component, nextProps, nextState, updateStrategy = "customD
|
|
|
3446
3445
|
return !shallowEquals(props2, nextProps) || !shallowEquals(state2, nextState);
|
|
3447
3446
|
}
|
|
3448
3447
|
const { props, state } = component;
|
|
3449
|
-
return !
|
|
3448
|
+
return !deepEquals_default(props, nextProps) || !deepEquals_default(state, nextState);
|
|
3450
3449
|
}
|
|
3451
3450
|
|
|
3452
3451
|
// src/shouldRenderOptionalField.ts
|
|
@@ -3662,10 +3661,9 @@ function useAltDateWidgetProps(props) {
|
|
|
3662
3661
|
|
|
3663
3662
|
// src/useDeepCompareMemo.ts
|
|
3664
3663
|
import { useRef } from "react";
|
|
3665
|
-
import isEqual3 from "lodash/isEqual";
|
|
3666
3664
|
function useDeepCompareMemo(newValue) {
|
|
3667
3665
|
const valueRef = useRef(newValue);
|
|
3668
|
-
if (!
|
|
3666
|
+
if (!deepEquals_default(newValue, valueRef.current)) {
|
|
3669
3667
|
valueRef.current = newValue;
|
|
3670
3668
|
}
|
|
3671
3669
|
return valueRef.current;
|
|
@@ -3925,7 +3923,7 @@ var ParserValidator = class {
|
|
|
3925
3923
|
const existing = this.schemaMap[key];
|
|
3926
3924
|
if (!existing) {
|
|
3927
3925
|
this.schemaMap[key] = identifiedSchema;
|
|
3928
|
-
} else if (!
|
|
3926
|
+
} else if (!deepEquals_default(existing, identifiedSchema)) {
|
|
3929
3927
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
3930
3928
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
3931
3929
|
throw new Error(
|
|
@@ -3947,7 +3945,7 @@ var ParserValidator = class {
|
|
|
3947
3945
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
3948
3946
|
*/
|
|
3949
3947
|
isValid(schema, _formData, rootSchema) {
|
|
3950
|
-
if (!
|
|
3948
|
+
if (!deepEquals_default(rootSchema, this.rootSchema)) {
|
|
3951
3949
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
3952
3950
|
}
|
|
3953
3951
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -3987,7 +3985,7 @@ var ParserValidator = class {
|
|
|
3987
3985
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
3988
3986
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
3989
3987
|
schemas.forEach((schema2) => {
|
|
3990
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
3988
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
|
|
3991
3989
|
if (sameSchemaIndex === -1) {
|
|
3992
3990
|
recurseList.push(schema2);
|
|
3993
3991
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
@@ -4062,7 +4060,7 @@ export {
|
|
|
4062
4060
|
createSchemaUtils,
|
|
4063
4061
|
dataURItoBlob,
|
|
4064
4062
|
dateRangeOptions,
|
|
4065
|
-
deepEquals,
|
|
4063
|
+
deepEquals_default as deepEquals,
|
|
4066
4064
|
descriptionId,
|
|
4067
4065
|
dotNotationNameGenerator,
|
|
4068
4066
|
englishStringTranslator,
|