@rjsf/utils 6.0.0-beta.14 → 6.0.0-beta.16

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
@@ -1285,7 +1285,7 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
1285
1285
  return acc2;
1286
1286
  }, acc);
1287
1287
  }
1288
- if (defaultSupercedesUndefined && (!isNil(defaults) && isNil(formData) || typeof formData === "number" && isNaN(formData)) || overrideFormDataWithDefaults && !isNil(formData)) {
1288
+ if (defaultSupercedesUndefined && (!(defaults === void 0) && isNil(formData) || typeof formData === "number" && isNaN(formData)) || overrideFormDataWithDefaults && !isNil(formData)) {
1289
1289
  return defaults;
1290
1290
  }
1291
1291
  return formData;
@@ -1770,8 +1770,9 @@ function getArrayDefaults(validator, rawSchema, {
1770
1770
  const defaultEntries = defaults || [];
1771
1771
  const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
1772
1772
  const fillerDefault = fillerSchema.default;
1773
- const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
1774
- computeDefaults(validator, fillerSchema, {
1773
+ const fillerEntries = Array.from(
1774
+ { length: schema.minItems - defaultsLength },
1775
+ () => computeDefaults(validator, fillerSchema, {
1775
1776
  parentDefaults: fillerDefault,
1776
1777
  rootSchema,
1777
1778
  _recurseList,
@@ -2843,8 +2844,8 @@ function getTemplate(name, registry, uiOptions = {}) {
2843
2844
  }
2844
2845
 
2845
2846
  // src/getTestIds.ts
2846
- import { nanoid } from "nanoid";
2847
2847
  import get18 from "lodash/get";
2848
+ import uniqueId from "lodash/uniqueId";
2848
2849
  function getTestIds() {
2849
2850
  if (typeof process === "undefined" || get18(process, "env.NODE_ENV") !== "test") {
2850
2851
  return {};
@@ -2855,7 +2856,7 @@ function getTestIds() {
2855
2856
  {
2856
2857
  get(_obj, prop) {
2857
2858
  if (!ids.has(prop)) {
2858
- ids.set(prop, nanoid());
2859
+ ids.set(prop, uniqueId("test-id-"));
2859
2860
  }
2860
2861
  return ids.get(prop);
2861
2862
  }
@@ -2938,7 +2939,7 @@ function getWidget(schema, widget, registeredWidgets = {}) {
2938
2939
  return mergeWidgetOptions(widget);
2939
2940
  }
2940
2941
  if (typeof widget !== "string") {
2941
- throw new Error(`Unsupported widget definition: ${typeof widget}`);
2942
+ throw new Error(`Unsupported widget definition: ${typeof widget} in schema: ${JSON.stringify(schema)}`);
2942
2943
  }
2943
2944
  if (widget in registeredWidgets) {
2944
2945
  const registeredWidget = registeredWidgets[widget];
@@ -2946,14 +2947,14 @@ function getWidget(schema, widget, registeredWidgets = {}) {
2946
2947
  }
2947
2948
  if (typeof type === "string") {
2948
2949
  if (!(type in widgetMap)) {
2949
- throw new Error(`No widget for type '${type}'`);
2950
+ throw new Error(`No widget for type '${type}' in schema: ${JSON.stringify(schema)}`);
2950
2951
  }
2951
2952
  if (widget in widgetMap[type]) {
2952
2953
  const registeredWidget = registeredWidgets[widgetMap[type][widget]];
2953
2954
  return getWidget(schema, registeredWidget, registeredWidgets);
2954
2955
  }
2955
2956
  }
2956
- throw new Error(`No widget '${widget}' for type '${type}'`);
2957
+ throw new Error(`No widget '${widget}' for type '${type}' in schema: ${JSON.stringify(schema)}`);
2957
2958
  }
2958
2959
 
2959
2960
  // src/hashForSchema.ts