@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/utils.esm.js CHANGED
@@ -128,25 +128,14 @@ function createErrorHandler(formData) {
128
128
  }
129
129
 
130
130
  // src/deepEquals.ts
131
- import { createCustomEqual } from "fast-equals";
132
- function isFunctions(a, b) {
133
- return typeof a === "function" && typeof b === "function";
134
- }
135
- var customDeepEqual = createCustomEqual({
136
- createInternalComparator: (comparator) => {
137
- return (a, b, _idxA, _idxB, _parentA, _parentB, state) => {
138
- if (isFunctions(a, b)) {
139
- return true;
140
- }
141
- return comparator(a, b, state);
142
- };
143
- }
144
- });
131
+ import isEqualWith from "lodash/isEqualWith";
145
132
  function deepEquals(a, b) {
146
- if (isFunctions(a, b)) {
147
- return true;
148
- }
149
- return customDeepEqual(a, b);
133
+ return isEqualWith(a, b, (obj, other) => {
134
+ if (typeof obj === "function" && typeof other === "function") {
135
+ return true;
136
+ }
137
+ return void 0;
138
+ });
150
139
  }
151
140
 
152
141
  // src/schema/getDefaultFormState.ts
@@ -290,6 +279,7 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
290
279
 
291
280
  // src/schema/retrieveSchema.ts
292
281
  import get4 from "lodash/get";
282
+ import isEqual from "lodash/isEqual";
293
283
  import set from "lodash/set";
294
284
  import times from "lodash/times";
295
285
  import transform from "lodash/transform";
@@ -469,10 +459,7 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurse
469
459
  )
470
460
  );
471
461
  const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
472
- return allPermutations.map((permutation) => ({
473
- ...schema,
474
- allOf: permutation
475
- }));
462
+ return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
476
463
  }
477
464
  return [schema];
478
465
  }
@@ -524,7 +511,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
524
511
  items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
525
512
  };
526
513
  }
527
- return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
514
+ return isEqual(schema, resolvedSchema) ? schema : resolvedSchema;
528
515
  }
529
516
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
530
517
  const schema = {
@@ -1429,10 +1416,11 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1429
1416
 
1430
1417
  // src/schema/toIdSchema.ts
1431
1418
  import get9 from "lodash/get";
1419
+ import isEqual2 from "lodash/isEqual";
1432
1420
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
1433
1421
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1434
1422
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1435
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1423
+ const sameSchemaIndex = _recurseList.findIndex((item) => isEqual2(item, _schema));
1436
1424
  if (sameSchemaIndex === -1) {
1437
1425
  return toIdSchemaInternal(
1438
1426
  validator,
@@ -1486,11 +1474,12 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
1486
1474
 
1487
1475
  // src/schema/toPathSchema.ts
1488
1476
  import get10 from "lodash/get";
1477
+ import isEqual3 from "lodash/isEqual";
1489
1478
  import set2 from "lodash/set";
1490
1479
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1491
1480
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1492
1481
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1493
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1482
+ const sameSchemaIndex = _recurseList.findIndex((item) => isEqual3(item, _schema));
1494
1483
  if (sameSchemaIndex === -1) {
1495
1484
  return toPathSchemaInternal(
1496
1485
  validator,
@@ -1861,6 +1850,9 @@ function englishStringTranslator(stringToTranslate, params) {
1861
1850
  return replaceStringParameters(stringToTranslate, params);
1862
1851
  }
1863
1852
 
1853
+ // src/enumOptionsDeselectValue.ts
1854
+ import isEqual4 from "lodash/isEqual";
1855
+
1864
1856
  // src/enumOptionsValueForIndex.ts
1865
1857
  function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
1866
1858
  if (Array.isArray(valueIndex)) {
@@ -1875,17 +1867,18 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
1875
1867
  function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
1876
1868
  const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
1877
1869
  if (Array.isArray(selected)) {
1878
- return selected.filter((v) => !deepEquals(v, value));
1870
+ return selected.filter((v) => !isEqual4(v, value));
1879
1871
  }
1880
- return deepEquals(value, selected) ? void 0 : selected;
1872
+ return isEqual4(value, selected) ? void 0 : selected;
1881
1873
  }
1882
1874
 
1883
1875
  // src/enumOptionsIsSelected.ts
1876
+ import isEqual5 from "lodash/isEqual";
1884
1877
  function enumOptionsIsSelected(value, selected) {
1885
1878
  if (Array.isArray(selected)) {
1886
- return selected.some((sel) => deepEquals(sel, value));
1879
+ return selected.some((sel) => isEqual5(sel, value));
1887
1880
  }
1888
- return deepEquals(selected, value);
1881
+ return isEqual5(selected, value);
1889
1882
  }
1890
1883
 
1891
1884
  // src/enumOptionsIndexForValue.ts
@@ -2580,9 +2573,11 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
2580
2573
 
2581
2574
  // src/parser/schemaParser.ts
2582
2575
  import forEach from "lodash/forEach";
2576
+ import isEqual7 from "lodash/isEqual";
2583
2577
 
2584
2578
  // src/parser/ParserValidator.ts
2585
2579
  import get13 from "lodash/get";
2580
+ import isEqual6 from "lodash/isEqual";
2586
2581
  var ParserValidator = class {
2587
2582
  /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
2588
2583
  * first.
@@ -2613,7 +2608,7 @@ var ParserValidator = class {
2613
2608
  const existing = this.schemaMap[key];
2614
2609
  if (!existing) {
2615
2610
  this.schemaMap[key] = identifiedSchema;
2616
- } else if (!deepEquals(existing, identifiedSchema)) {
2611
+ } else if (!isEqual6(existing, identifiedSchema)) {
2617
2612
  console.error("existing schema:", JSON.stringify(existing, null, 2));
2618
2613
  console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
2619
2614
  throw new Error(
@@ -2635,7 +2630,7 @@ var ParserValidator = class {
2635
2630
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
2636
2631
  */
2637
2632
  isValid(schema, _formData, rootSchema) {
2638
- if (!deepEquals(rootSchema, this.rootSchema)) {
2633
+ if (!isEqual6(rootSchema, this.rootSchema)) {
2639
2634
  throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
2640
2635
  }
2641
2636
  this.addSchema(schema, hashForSchema(schema));
@@ -2675,7 +2670,7 @@ var ParserValidator = class {
2675
2670
  function parseSchema(validator, recurseList, rootSchema, schema) {
2676
2671
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2677
2672
  schemas.forEach((schema2) => {
2678
- const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
2673
+ const sameSchemaIndex = recurseList.findIndex((item) => isEqual7(item, schema2));
2679
2674
  if (sameSchemaIndex === -1) {
2680
2675
  recurseList.push(schema2);
2681
2676
  const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);