@rjsf/utils 5.24.0 → 5.24.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.js CHANGED
@@ -67,7 +67,7 @@ __export(src_exports, {
67
67
  createSchemaUtils: () => createSchemaUtils,
68
68
  dataURItoBlob: () => dataURItoBlob,
69
69
  dateRangeOptions: () => dateRangeOptions,
70
- deepEquals: () => deepEquals,
70
+ deepEquals: () => deepEquals_default,
71
71
  descriptionId: () => descriptionId,
72
72
  englishStringTranslator: () => englishStringTranslator,
73
73
  enumOptionsDeselectValue: () => enumOptionsDeselectValue,
@@ -269,15 +269,20 @@ function createErrorHandler(formData) {
269
269
  }
270
270
 
271
271
  // src/deepEquals.ts
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
- }
272
+ var import_fast_equals = require("fast-equals");
273
+ var deepEquals = (0, import_fast_equals.createCustomEqual)({
274
+ createCustomConfig: () => ({
275
+ // Assume all functions are equivalent
276
+ // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
277
+ //
278
+ // Performance improvement: knowing that typeof a === function, so, only needs to check if typeof b === function.
279
+ // https://github.com/planttheidea/fast-equals/blob/c633c4e653cacf8fd5cbb309b6841df62322d74c/src/comparator.ts#L99
280
+ areFunctionsEqual(_a, b) {
281
+ return typeof b === "function";
282
+ }
283
+ })
284
+ });
285
+ var deepEquals_default = deepEquals;
281
286
 
282
287
  // src/schema/getDefaultFormState.ts
283
288
  var import_get7 = __toESM(require("lodash/get"));
@@ -697,7 +702,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
697
702
  items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
698
703
  };
699
704
  }
700
- return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
705
+ return deepEquals_default(schema, resolvedSchema) ? schema : resolvedSchema;
701
706
  }
702
707
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
703
708
  const schema = {
@@ -1107,7 +1112,7 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
1107
1112
  const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;
1108
1113
  const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;
1109
1114
  const mapped = overrideArray.map((value, idx) => {
1110
- if (overrideOppositeArray[idx]) {
1115
+ if (overrideOppositeArray[idx] !== void 0) {
1111
1116
  return mergeDefaultsWithFormData(
1112
1117
  defaultsArray[idx],
1113
1118
  formData[idx],
@@ -1446,7 +1451,7 @@ function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, e
1446
1451
  let validFormData = formData;
1447
1452
  if (isSelectField) {
1448
1453
  const getOptionsList = optionsList(schema);
1449
- const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));
1454
+ const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
1450
1455
  validFormData = isValid ? formData : void 0;
1451
1456
  }
1452
1457
  const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
@@ -1860,7 +1865,7 @@ var import_get9 = __toESM(require("lodash/get"));
1860
1865
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1861
1866
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1862
1867
  const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1863
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1868
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
1864
1869
  if (sameSchemaIndex === -1) {
1865
1870
  return toIdSchemaInternal(
1866
1871
  validator,
@@ -1931,7 +1936,7 @@ var import_set2 = __toESM(require("lodash/set"));
1931
1936
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1932
1937
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1933
1938
  const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1934
- const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
1939
+ const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
1935
1940
  if (sameSchemaIndex === -1) {
1936
1941
  return toPathSchemaInternal(
1937
1942
  validator,
@@ -2075,7 +2080,7 @@ var SchemaUtils = class {
2075
2080
  if (!validator || !rootSchema) {
2076
2081
  return false;
2077
2082
  }
2078
- return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
2083
+ return this.validator !== validator || !deepEquals_default(this.rootSchema, rootSchema) || !deepEquals_default(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
2079
2084
  }
2080
2085
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
2081
2086
  * computed to have defaults provided in the `schema`.
@@ -2383,17 +2388,17 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
2383
2388
  function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
2384
2389
  const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2385
2390
  if (Array.isArray(selected)) {
2386
- return selected.filter((v) => !deepEquals(v, value));
2391
+ return selected.filter((v) => !deepEquals_default(v, value));
2387
2392
  }
2388
- return deepEquals(value, selected) ? void 0 : selected;
2393
+ return deepEquals_default(value, selected) ? void 0 : selected;
2389
2394
  }
2390
2395
 
2391
2396
  // src/enumOptionsIsSelected.ts
2392
2397
  function enumOptionsIsSelected(value, selected) {
2393
2398
  if (Array.isArray(selected)) {
2394
- return selected.some((sel) => deepEquals(sel, value));
2399
+ return selected.some((sel) => deepEquals_default(sel, value));
2395
2400
  }
2396
- return deepEquals(selected, value);
2401
+ return deepEquals_default(selected, value);
2397
2402
  }
2398
2403
 
2399
2404
  // src/enumOptionsIndexForValue.ts
@@ -2582,6 +2587,9 @@ function getInputProps(schema, defaultType, options = {}, autoDefaultStepAny = t
2582
2587
  if (options.autocomplete) {
2583
2588
  inputProps.autoComplete = options.autocomplete;
2584
2589
  }
2590
+ if (options.accept) {
2591
+ inputProps.accept = options.accept;
2592
+ }
2585
2593
  return inputProps;
2586
2594
  }
2587
2595
 
@@ -2857,7 +2865,7 @@ function schemaRequiresTrueValue(schema) {
2857
2865
  // src/shouldRender.ts
2858
2866
  function shouldRender(component, nextProps, nextState) {
2859
2867
  const { props, state } = component;
2860
- return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
2868
+ return !deepEquals_default(props, nextProps) || !deepEquals_default(state, nextState);
2861
2869
  }
2862
2870
 
2863
2871
  // src/toDateString.ts
@@ -3015,7 +3023,7 @@ function getChangedFields(a, b) {
3015
3023
  } else if (!aIsPlainObject && bIsPlainObject) {
3016
3024
  return (0, import_keys.default)(b);
3017
3025
  } else {
3018
- const unequalFields = (0, import_keys.default)((0, import_pickBy.default)(a, (value, key) => !deepEquals(value, (0, import_get13.default)(b, key))));
3026
+ const unequalFields = (0, import_keys.default)((0, import_pickBy.default)(a, (value, key) => !deepEquals_default(value, (0, import_get13.default)(b, key))));
3019
3027
  const diffFields = (0, import_difference.default)((0, import_keys.default)(b), (0, import_keys.default)(a));
3020
3028
  return [...unequalFields, ...diffFields];
3021
3029
  }
@@ -3090,7 +3098,7 @@ var ParserValidator = class {
3090
3098
  const existing = this.schemaMap[key];
3091
3099
  if (!existing) {
3092
3100
  this.schemaMap[key] = identifiedSchema;
3093
- } else if (!deepEquals(existing, identifiedSchema)) {
3101
+ } else if (!deepEquals_default(existing, identifiedSchema)) {
3094
3102
  console.error("existing schema:", JSON.stringify(existing, null, 2));
3095
3103
  console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
3096
3104
  throw new Error(
@@ -3112,7 +3120,7 @@ var ParserValidator = class {
3112
3120
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
3113
3121
  */
3114
3122
  isValid(schema, _formData, rootSchema) {
3115
- if (!deepEquals(rootSchema, this.rootSchema)) {
3123
+ if (!deepEquals_default(rootSchema, this.rootSchema)) {
3116
3124
  throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
3117
3125
  }
3118
3126
  this.addSchema(schema, hashForSchema(schema));
@@ -3152,7 +3160,7 @@ var ParserValidator = class {
3152
3160
  function parseSchema(validator, recurseList, rootSchema, schema) {
3153
3161
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
3154
3162
  schemas.forEach((schema2) => {
3155
- const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
3163
+ const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
3156
3164
  if (sameSchemaIndex === -1) {
3157
3165
  recurseList.push(schema2);
3158
3166
  const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);