@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 +40 -2
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +40 -2
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +36 -2
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/nameGenerators.d.ts +13 -0
- package/lib/nameGenerators.js +30 -0
- package/lib/nameGenerators.js.map +1 -0
- package/lib/shouldRenderOptionalField.js.map +1 -1
- package/lib/toFieldPathId.d.ts +4 -2
- package/lib/toFieldPathId.js +10 -3
- package/lib/toFieldPathId.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +50 -30
- package/lib/useDeepCompareMemo.d.ts +8 -0
- package/lib/useDeepCompareMemo.js +17 -0
- package/lib/useDeepCompareMemo.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +5 -0
- package/src/nameGenerators.ts +43 -0
- package/src/shouldRenderOptionalField.ts +3 -3
- package/src/toFieldPathId.ts +12 -2
- package/src/types.ts +53 -35
- package/src/useDeepCompareMemo.ts +17 -0
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
|
-
|
|
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";
|