@rjsf/utils 6.0.0-beta.21 → 6.0.0-beta.22

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.cjs CHANGED
@@ -71,6 +71,7 @@ __export(index_exports, {
71
71
  allowAdditionalItems: () => allowAdditionalItems,
72
72
  ariaDescribedByIds: () => ariaDescribedByIds,
73
73
  asNumber: () => asNumber,
74
+ bracketNameGenerator: () => bracketNameGenerator,
74
75
  buttonId: () => buttonId,
75
76
  canExpand: () => canExpand,
76
77
  createErrorHandler: () => createErrorHandler,
@@ -79,6 +80,7 @@ __export(index_exports, {
79
80
  dateRangeOptions: () => dateRangeOptions,
80
81
  deepEquals: () => deepEquals,
81
82
  descriptionId: () => descriptionId,
83
+ dotNotationNameGenerator: () => dotNotationNameGenerator,
82
84
  englishStringTranslator: () => englishStringTranslator,
83
85
  enumOptionsDeselectValue: () => enumOptionsDeselectValue,
84
86
  enumOptionsIndexForValue: () => enumOptionsIndexForValue,
@@ -151,6 +153,7 @@ __export(index_exports, {
151
153
  toFieldPathId: () => toFieldPathId,
152
154
  toPathSchema: () => toPathSchema,
153
155
  unwrapErrorHandler: () => unwrapErrorHandler,
156
+ useDeepCompareMemo: () => useDeepCompareMemo,
154
157
  utcToLocal: () => utcToLocal,
155
158
  validationDataMerge: () => validationDataMerge,
156
159
  withIdRefPrefix: () => withIdRefPrefix
@@ -3380,12 +3383,16 @@ function toErrorSchema(errors) {
3380
3383
  }
3381
3384
 
3382
3385
  // src/toFieldPathId.ts
3383
- function toFieldPathId(fieldPath, globalFormOptions, parentPath) {
3386
+ function toFieldPathId(fieldPath, globalFormOptions, parentPath, isMultiValue) {
3384
3387
  const basePath = Array.isArray(parentPath) ? parentPath : parentPath?.path;
3385
3388
  const childPath = fieldPath === "" ? [] : [fieldPath];
3386
3389
  const path = basePath ? basePath.concat(...childPath) : childPath;
3387
3390
  const id = [globalFormOptions.idPrefix, ...path].join(globalFormOptions.idSeparator);
3388
- return { path, [ID_KEY]: id };
3391
+ let name;
3392
+ if (globalFormOptions.nameGenerator && path.length > 0) {
3393
+ name = globalFormOptions.nameGenerator(path, globalFormOptions.idPrefix, isMultiValue);
3394
+ }
3395
+ return { path, [ID_KEY]: id, ...name !== void 0 && { name } };
3389
3396
  }
3390
3397
 
3391
3398
  // src/unwrapErrorHandler.ts
@@ -3407,6 +3414,17 @@ function unwrapErrorHandler(errorHandler) {
3407
3414
  }, {});
3408
3415
  }
3409
3416
 
3417
+ // src/useDeepCompareMemo.ts
3418
+ var import_react2 = require("react");
3419
+ var import_isEqual3 = __toESM(require("lodash/isEqual"), 1);
3420
+ function useDeepCompareMemo(newValue) {
3421
+ const valueRef = (0, import_react2.useRef)(newValue);
3422
+ if (!(0, import_isEqual3.default)(newValue, valueRef.current)) {
3423
+ valueRef.current = newValue;
3424
+ }
3425
+ return valueRef.current;
3426
+ }
3427
+
3410
3428
  // src/utcToLocal.ts
3411
3429
  function utcToLocal(jsonDate) {
3412
3430
  if (!jsonDate) {
@@ -3473,6 +3491,26 @@ function withIdRefPrefix(schemaNode) {
3473
3491
  return schemaNode;
3474
3492
  }
3475
3493
 
3494
+ // src/nameGenerators.ts
3495
+ var bracketNameGenerator = (path, idPrefix, isMultiValue) => {
3496
+ if (!path || path.length === 0) {
3497
+ return idPrefix;
3498
+ }
3499
+ const baseName = path.reduce((acc, pathUnit, index) => {
3500
+ if (index === 0) {
3501
+ return `${idPrefix}[${String(pathUnit)}]`;
3502
+ }
3503
+ return `${acc}[${String(pathUnit)}]`;
3504
+ }, "");
3505
+ return isMultiValue ? `${baseName}[]` : baseName;
3506
+ };
3507
+ var dotNotationNameGenerator = (path, idPrefix, _isMultiValue) => {
3508
+ if (!path || path.length === 0) {
3509
+ return idPrefix;
3510
+ }
3511
+ return `${idPrefix}.${path.map(String).join(".")}`;
3512
+ };
3513
+
3476
3514
  // src/enums.ts
3477
3515
  var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
3478
3516
  TranslatableString2["ArrayItemTitle"] = "Item";