@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/utils.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('fast-equals'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isNumber'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/set'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash/isNil'), require('lodash/cloneDeep'), require('lodash/setWith'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), require('lodash/forEach')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'fast-equals', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isNumber', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/set', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'lodash/union', 'lodash/isNil', 'lodash/cloneDeep', 'lodash/setWith', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', 'lodash/forEach'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.fastEquals, global.get8, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isNumber, global.isObject2, global.isString, global.reduce, global.times, global.set3, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.union, global.isNil, global.cloneDeep, global.setWith, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.keys, global.pickBy, global.difference, global.forEach));
5
- })(this, (function (exports, isPlainObject4, fastEquals, get8, isEmpty, jsonpointer, omit, has3, isNumber, isObject2, isString, reduce, times, set3, transform, merge, flattenDeep, uniq, mergeAllOf, union, isNil, cloneDeep, setWith, react, ReactIs, jsxRuntime, toPath, keys, pickBy, difference, forEach) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isNumber'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/set'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash/isNil'), require('lodash/cloneDeep'), require('lodash/setWith'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), require('lodash/forEach')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isNumber', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/set', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'lodash/union', 'lodash/isNil', 'lodash/cloneDeep', 'lodash/setWith', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', 'lodash/forEach'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.isEqualWith, global.get8, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isNumber, global.isObject2, global.isString, global.reduce, global.times, global.set3, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.union, global.isNil, global.cloneDeep, global.setWith, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.keys, global.pickBy, global.difference, global.forEach));
5
+ })(this, (function (exports, isPlainObject4, isEqualWith, get8, isEmpty, jsonpointer, omit, has3, isNumber, isObject2, isString, reduce, times, set3, transform, merge, flattenDeep, uniq, mergeAllOf, union, isNil, cloneDeep, setWith, react, ReactIs, jsxRuntime, toPath, keys, pickBy, difference, forEach) { 'use strict';
6
6
 
7
7
  // src/isObject.ts
8
8
  function isObject(thing) {
@@ -132,19 +132,14 @@
132
132
  }
133
133
  return handler;
134
134
  }
135
- var deepEquals = fastEquals.createCustomEqual({
136
- createCustomConfig: () => ({
137
- // Assume all functions are equivalent
138
- // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
139
- //
140
- // Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function.
141
- // https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99
142
- areFunctionsEqual(_a, b) {
143
- return typeof b === "function";
144
- }
145
- })
146
- });
147
- var deepEquals_default = deepEquals;
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
  function splitKeyElementFromObject(key, object) {
149
144
  const value = object[key];
150
145
  const remaining = omit(object, [key]);
@@ -522,7 +517,7 @@
522
517
  items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
523
518
  };
524
519
  }
525
- return deepEquals_default(schema, resolvedSchema) ? schema : resolvedSchema;
520
+ return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
526
521
  }
527
522
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
528
523
  const schema = {
@@ -1264,7 +1259,7 @@
1264
1259
  let validFormData = formData;
1265
1260
  if (isSelectField) {
1266
1261
  const getOptionsList = optionsList(schema);
1267
- const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
1262
+ const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));
1268
1263
  validFormData = isValid ? formData : void 0;
1269
1264
  }
1270
1265
  const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
@@ -1668,7 +1663,7 @@
1668
1663
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1669
1664
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1670
1665
  const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1671
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
1666
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1672
1667
  if (sameSchemaIndex === -1) {
1673
1668
  return toIdSchemaInternal(
1674
1669
  validator,
@@ -1735,7 +1730,7 @@
1735
1730
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1736
1731
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1737
1732
  const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1738
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
1733
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1739
1734
  if (sameSchemaIndex === -1) {
1740
1735
  return toPathSchemaInternal(
1741
1736
  validator,
@@ -1879,7 +1874,7 @@
1879
1874
  if (!validator || !rootSchema) {
1880
1875
  return false;
1881
1876
  }
1882
- return this.validator !== validator || !deepEquals_default(this.rootSchema, rootSchema) || !deepEquals_default(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
1877
+ return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
1883
1878
  }
1884
1879
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1885
1880
  * computed to have defaults provided in the `schema`.
@@ -2187,17 +2182,17 @@
2187
2182
  function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
2188
2183
  const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2189
2184
  if (Array.isArray(selected)) {
2190
- return selected.filter((v) => !deepEquals_default(v, value));
2185
+ return selected.filter((v) => !deepEquals(v, value));
2191
2186
  }
2192
- return deepEquals_default(value, selected) ? void 0 : selected;
2187
+ return deepEquals(value, selected) ? void 0 : selected;
2193
2188
  }
2194
2189
 
2195
2190
  // src/enumOptionsIsSelected.ts
2196
2191
  function enumOptionsIsSelected(value, selected) {
2197
2192
  if (Array.isArray(selected)) {
2198
- return selected.some((sel) => deepEquals_default(sel, value));
2193
+ return selected.some((sel) => deepEquals(sel, value));
2199
2194
  }
2200
- return deepEquals_default(selected, value);
2195
+ return deepEquals(selected, value);
2201
2196
  }
2202
2197
 
2203
2198
  // src/enumOptionsIndexForValue.ts
@@ -2645,7 +2640,7 @@
2645
2640
  // src/shouldRender.ts
2646
2641
  function shouldRender(component, nextProps, nextState) {
2647
2642
  const { props, state } = component;
2648
- return !deepEquals_default(props, nextProps) || !deepEquals_default(state, nextState);
2643
+ return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
2649
2644
  }
2650
2645
 
2651
2646
  // src/toDateString.ts
@@ -2781,7 +2776,7 @@
2781
2776
  } else if (!aIsPlainObject && bIsPlainObject) {
2782
2777
  return keys(b);
2783
2778
  } else {
2784
- const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get8(b, key))));
2779
+ const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get8(b, key))));
2785
2780
  const diffFields = difference(keys(b), keys(a));
2786
2781
  return [...unequalFields, ...diffFields];
2787
2782
  }
@@ -2850,7 +2845,7 @@
2850
2845
  const existing = this.schemaMap[key];
2851
2846
  if (!existing) {
2852
2847
  this.schemaMap[key] = identifiedSchema;
2853
- } else if (!deepEquals_default(existing, identifiedSchema)) {
2848
+ } else if (!deepEquals(existing, identifiedSchema)) {
2854
2849
  console.error("existing schema:", JSON.stringify(existing, null, 2));
2855
2850
  console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
2856
2851
  throw new Error(
@@ -2872,7 +2867,7 @@
2872
2867
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
2873
2868
  */
2874
2869
  isValid(schema, _formData, rootSchema) {
2875
- if (!deepEquals_default(rootSchema, this.rootSchema)) {
2870
+ if (!deepEquals(rootSchema, this.rootSchema)) {
2876
2871
  throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
2877
2872
  }
2878
2873
  this.addSchema(schema, hashForSchema(schema));
@@ -2912,7 +2907,7 @@
2912
2907
  function parseSchema(validator, recurseList, rootSchema, schema) {
2913
2908
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2914
2909
  schemas.forEach((schema2) => {
2915
- const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
2910
+ const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
2916
2911
  if (sameSchemaIndex === -1) {
2917
2912
  recurseList.push(schema2);
2918
2913
  const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
@@ -2973,7 +2968,7 @@
2973
2968
  exports.createSchemaUtils = createSchemaUtils;
2974
2969
  exports.dataURItoBlob = dataURItoBlob;
2975
2970
  exports.dateRangeOptions = dateRangeOptions;
2976
- exports.deepEquals = deepEquals_default;
2971
+ exports.deepEquals = deepEquals;
2977
2972
  exports.descriptionId = descriptionId;
2978
2973
  exports.englishStringTranslator = englishStringTranslator;
2979
2974
  exports.enumOptionsDeselectValue = enumOptionsDeselectValue;
@@ -1,8 +1,8 @@
1
- /** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent.
1
+ /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
2
+ * assumes all functions are equivalent.
2
3
  *
3
4
  * @param a - The first element to compare
4
5
  * @param b - The second element to compare
5
6
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
6
7
  */
7
- declare const deepEquals: <A, B>(a: A, b: B) => boolean;
8
- export default deepEquals;
8
+ export default function deepEquals(a: any, b: any): boolean;
package/lib/deepEquals.js CHANGED
@@ -1,21 +1,19 @@
1
- import { createCustomEqual } from 'fast-equals';
2
- /** Implements a deep equals using the `fast-equals.createCustomEqual` function, providing a customized comparator that assumes all functions are equivalent.
1
+ import isEqualWith from 'lodash/isEqualWith';
2
+ /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
3
+ * assumes all functions are equivalent.
3
4
  *
4
5
  * @param a - The first element to compare
5
6
  * @param b - The second element to compare
6
7
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
7
8
  */
8
- const deepEquals = createCustomEqual({
9
- createCustomConfig: () => ({
10
- // Assume all functions are equivalent
11
- // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
12
- //
13
- // Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function.
14
- // https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99
15
- areFunctionsEqual(_a, b) {
16
- return typeof b === 'function';
17
- },
18
- }),
19
- });
20
- export default deepEquals;
9
+ export default function deepEquals(a, b) {
10
+ return isEqualWith(a, b, (obj, other) => {
11
+ if (typeof obj === 'function' && typeof other === 'function') {
12
+ // Assume all functions are equivalent
13
+ // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
14
+ return true;
15
+ }
16
+ return undefined; // fallback to default isEquals behavior
17
+ });
18
+ }
21
19
  //# sourceMappingURL=deepEquals.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,GAAG,iBAAiB,CAAC;IACnC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;QACzB,sCAAsC;QACtC,oEAAoE;QACpE,EAAE;QACF,iHAAiH;QACjH,kHAAkH;QAClH,iBAAiB,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;QACjC,CAAC;KACF,CAAC;CACH,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAM,EAAE,CAAM;IAC/C,OAAO,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAQ,EAAE,KAAU,EAAE,EAAE;QAChD,IAAI,OAAO,GAAG,KAAK,UAAU,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YAC5D,sCAAsC;YACtC,oEAAoE;YACpE,OAAO,IAAI,CAAC;SACb;QACD,OAAO,SAAS,CAAC,CAAC,wCAAwC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}