@rjsf/utils 5.21.0 → 5.21.1

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 CHANGED
@@ -265,25 +265,14 @@ function createErrorHandler(formData) {
265
265
  }
266
266
 
267
267
  // src/deepEquals.ts
268
- var import_fast_equals = require("fast-equals");
269
- function isFunctions(a, b) {
270
- return typeof a === "function" && typeof b === "function";
271
- }
272
- var customDeepEqual = (0, import_fast_equals.createCustomEqual)({
273
- createInternalComparator: (comparator) => {
274
- return (a, b, _idxA, _idxB, _parentA, _parentB, state) => {
275
- if (isFunctions(a, b)) {
276
- return true;
277
- }
278
- return comparator(a, b, state);
279
- };
280
- }
281
- });
268
+ var import_isEqualWith = __toESM(require("lodash/isEqualWith"));
282
269
  function deepEquals(a, b) {
283
- if (isFunctions(a, b)) {
284
- return true;
285
- }
286
- return customDeepEqual(a, b);
270
+ return (0, import_isEqualWith.default)(a, b, (obj, other) => {
271
+ if (typeof obj === "function" && typeof other === "function") {
272
+ return true;
273
+ }
274
+ return void 0;
275
+ });
287
276
  }
288
277
 
289
278
  // src/schema/getDefaultFormState.ts
@@ -427,6 +416,7 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
427
416
 
428
417
  // src/schema/retrieveSchema.ts
429
418
  var import_get4 = __toESM(require("lodash/get"));
419
+ var import_isEqual = __toESM(require("lodash/isEqual"));
430
420
  var import_set = __toESM(require("lodash/set"));
431
421
  var import_times = __toESM(require("lodash/times"));
432
422
  var import_transform = __toESM(require("lodash/transform"));
@@ -606,10 +596,7 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurse
606
596
  )
607
597
  );
608
598
  const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
609
- return allPermutations.map((permutation) => ({
610
- ...schema,
611
- allOf: permutation
612
- }));
599
+ return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
613
600
  }
614
601
  return [schema];
615
602
  }
@@ -661,7 +648,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
661
648
  items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
662
649
  };
663
650
  }
664
- return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
651
+ return (0, import_isEqual.default)(schema, resolvedSchema) ? schema : resolvedSchema;
665
652
  }
666
653
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
667
654
  const schema = {
@@ -1566,10 +1553,11 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1566
1553
 
1567
1554
  // src/schema/toIdSchema.ts
1568
1555
  var import_get9 = __toESM(require("lodash/get"));
1556
+ var import_isEqual2 = __toESM(require("lodash/isEqual"));
1569
1557
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
1570
1558
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1571
1559
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1572
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1560
+ const sameSchemaIndex = _recurseList.findIndex((item) => (0, import_isEqual2.default)(item, _schema));
1573
1561
  if (sameSchemaIndex === -1) {
1574
1562
  return toIdSchemaInternal(
1575
1563
  validator,
@@ -1623,11 +1611,12 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
1623
1611
 
1624
1612
  // src/schema/toPathSchema.ts
1625
1613
  var import_get10 = __toESM(require("lodash/get"));
1614
+ var import_isEqual3 = __toESM(require("lodash/isEqual"));
1626
1615
  var import_set2 = __toESM(require("lodash/set"));
1627
1616
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1628
1617
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1629
1618
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1630
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1619
+ const sameSchemaIndex = _recurseList.findIndex((item) => (0, import_isEqual3.default)(item, _schema));
1631
1620
  if (sameSchemaIndex === -1) {
1632
1621
  return toPathSchemaInternal(
1633
1622
  validator,
@@ -1998,6 +1987,9 @@ function englishStringTranslator(stringToTranslate, params) {
1998
1987
  return replaceStringParameters(stringToTranslate, params);
1999
1988
  }
2000
1989
 
1990
+ // src/enumOptionsDeselectValue.ts
1991
+ var import_isEqual4 = __toESM(require("lodash/isEqual"));
1992
+
2001
1993
  // src/enumOptionsValueForIndex.ts
2002
1994
  function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
2003
1995
  if (Array.isArray(valueIndex)) {
@@ -2012,17 +2004,18 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
2012
2004
  function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
2013
2005
  const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2014
2006
  if (Array.isArray(selected)) {
2015
- return selected.filter((v) => !deepEquals(v, value));
2007
+ return selected.filter((v) => !(0, import_isEqual4.default)(v, value));
2016
2008
  }
2017
- return deepEquals(value, selected) ? void 0 : selected;
2009
+ return (0, import_isEqual4.default)(value, selected) ? void 0 : selected;
2018
2010
  }
2019
2011
 
2020
2012
  // src/enumOptionsIsSelected.ts
2013
+ var import_isEqual5 = __toESM(require("lodash/isEqual"));
2021
2014
  function enumOptionsIsSelected(value, selected) {
2022
2015
  if (Array.isArray(selected)) {
2023
- return selected.some((sel) => deepEquals(sel, value));
2016
+ return selected.some((sel) => (0, import_isEqual5.default)(sel, value));
2024
2017
  }
2025
- return deepEquals(selected, value);
2018
+ return (0, import_isEqual5.default)(selected, value);
2026
2019
  }
2027
2020
 
2028
2021
  // src/enumOptionsIndexForValue.ts
@@ -2717,9 +2710,11 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
2717
2710
 
2718
2711
  // src/parser/schemaParser.ts
2719
2712
  var import_forEach = __toESM(require("lodash/forEach"));
2713
+ var import_isEqual7 = __toESM(require("lodash/isEqual"));
2720
2714
 
2721
2715
  // src/parser/ParserValidator.ts
2722
2716
  var import_get13 = __toESM(require("lodash/get"));
2717
+ var import_isEqual6 = __toESM(require("lodash/isEqual"));
2723
2718
  var ParserValidator = class {
2724
2719
  /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
2725
2720
  * first.
@@ -2750,7 +2745,7 @@ var ParserValidator = class {
2750
2745
  const existing = this.schemaMap[key];
2751
2746
  if (!existing) {
2752
2747
  this.schemaMap[key] = identifiedSchema;
2753
- } else if (!deepEquals(existing, identifiedSchema)) {
2748
+ } else if (!(0, import_isEqual6.default)(existing, identifiedSchema)) {
2754
2749
  console.error("existing schema:", JSON.stringify(existing, null, 2));
2755
2750
  console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
2756
2751
  throw new Error(
@@ -2772,7 +2767,7 @@ var ParserValidator = class {
2772
2767
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
2773
2768
  */
2774
2769
  isValid(schema, _formData, rootSchema) {
2775
- if (!deepEquals(rootSchema, this.rootSchema)) {
2770
+ if (!(0, import_isEqual6.default)(rootSchema, this.rootSchema)) {
2776
2771
  throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
2777
2772
  }
2778
2773
  this.addSchema(schema, hashForSchema(schema));
@@ -2812,7 +2807,7 @@ var ParserValidator = class {
2812
2807
  function parseSchema(validator, recurseList, rootSchema, schema) {
2813
2808
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2814
2809
  schemas.forEach((schema2) => {
2815
- const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
2810
+ const sameSchemaIndex = recurseList.findIndex((item) => (0, import_isEqual7.default)(item, schema2));
2816
2811
  if (sameSchemaIndex === -1) {
2817
2812
  recurseList.push(schema2);
2818
2813
  const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);