@rjsf/utils 6.5.2 → 6.5.3
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 +10 -8
- package/dist/index.cjs.map +2 -2
- package/dist/utils.esm.js +10 -8
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +10 -8
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enums.d.ts +2 -0
- package/lib/enums.js +2 -0
- package/lib/enums.js.map +1 -1
- package/lib/jsonSchemaAugmentation.d.ts +19 -0
- package/lib/jsonSchemaAugmentation.js +2 -0
- package/lib/jsonSchemaAugmentation.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +1 -1
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +2 -2
- package/lib/schema/findFieldInSchema.js +6 -5
- package/lib/schema/findFieldInSchema.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +3 -3
- package/lib/schema/getFromSchema.js +2 -2
- package/lib/schema/getFromSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +13 -4
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +2 -2
- package/src/createSchemaUtils.ts +5 -4
- package/src/enums.ts +2 -0
- package/src/jsonSchemaAugmentation.ts +21 -0
- package/src/mergeDefaultsWithFormData.ts +2 -1
- package/src/schema/findFieldInSchema.ts +8 -6
- package/src/schema/getFromSchema.ts +14 -7
- package/src/types.ts +14 -4
package/dist/index.cjs
CHANGED
|
@@ -1200,9 +1200,9 @@ function getFromSchemaInternal(validator, rootSchema, schema, path, experimental
|
|
|
1200
1200
|
if ((0, import_isEmpty3.default)(path)) {
|
|
1201
1201
|
return fieldSchema;
|
|
1202
1202
|
}
|
|
1203
|
-
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
1203
|
+
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
1204
1204
|
const [part, ...nestedPath] = pathList;
|
|
1205
|
-
if (part && (0, import_has2.default)(fieldSchema, part)) {
|
|
1205
|
+
if (part !== void 0 && part !== "" && (0, import_has2.default)(fieldSchema, part)) {
|
|
1206
1206
|
fieldSchema = (0, import_get7.default)(fieldSchema, part);
|
|
1207
1207
|
return getFromSchemaInternal(
|
|
1208
1208
|
validator,
|
|
@@ -1228,6 +1228,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1228
1228
|
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
1229
1229
|
let parentField = schema;
|
|
1230
1230
|
const fieldName = pathList.pop();
|
|
1231
|
+
const fieldNameKey = String(fieldName);
|
|
1231
1232
|
if (pathList.length) {
|
|
1232
1233
|
pathList.forEach((subPath) => {
|
|
1233
1234
|
parentField = getFromSchema(
|
|
@@ -1243,7 +1244,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1243
1244
|
validator,
|
|
1244
1245
|
rootSchema,
|
|
1245
1246
|
parentField,
|
|
1246
|
-
|
|
1247
|
+
fieldNameKey,
|
|
1247
1248
|
ONE_OF_KEY,
|
|
1248
1249
|
(0, import_get8.default)(formData, subPath),
|
|
1249
1250
|
experimental_customMergeAllOf
|
|
@@ -1253,7 +1254,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1253
1254
|
validator,
|
|
1254
1255
|
rootSchema,
|
|
1255
1256
|
parentField,
|
|
1256
|
-
|
|
1257
|
+
fieldNameKey,
|
|
1257
1258
|
ANY_OF_KEY,
|
|
1258
1259
|
(0, import_get8.default)(formData, subPath),
|
|
1259
1260
|
experimental_customMergeAllOf
|
|
@@ -1266,7 +1267,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1266
1267
|
validator,
|
|
1267
1268
|
rootSchema,
|
|
1268
1269
|
parentField,
|
|
1269
|
-
|
|
1270
|
+
fieldNameKey,
|
|
1270
1271
|
ONE_OF_KEY,
|
|
1271
1272
|
formData,
|
|
1272
1273
|
experimental_customMergeAllOf
|
|
@@ -1276,7 +1277,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1276
1277
|
validator,
|
|
1277
1278
|
rootSchema,
|
|
1278
1279
|
parentField,
|
|
1279
|
-
|
|
1280
|
+
fieldNameKey,
|
|
1280
1281
|
ANY_OF_KEY,
|
|
1281
1282
|
formData,
|
|
1282
1283
|
experimental_customMergeAllOf
|
|
@@ -1303,7 +1304,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1303
1304
|
);
|
|
1304
1305
|
let isRequired;
|
|
1305
1306
|
if (field && Array.isArray(requiredArray)) {
|
|
1306
|
-
isRequired = requiredArray.includes(
|
|
1307
|
+
isRequired = requiredArray.includes(fieldNameKey);
|
|
1307
1308
|
}
|
|
1308
1309
|
return { field, isRequired };
|
|
1309
1310
|
}
|
|
@@ -1473,7 +1474,7 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
|
|
|
1473
1474
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1474
1475
|
const keyExistsInFormData = key in formData;
|
|
1475
1476
|
const keyDefault = (0, import_get10.default)(defaults, key) ?? {};
|
|
1476
|
-
const defaultValueIsNestedObject = keyExistsInDefaults && Object.
|
|
1477
|
+
const defaultValueIsNestedObject = keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
|
|
1477
1478
|
const keyDefaultIsObject = keyExistsInDefaults && isObject((0, import_get10.default)(defaults, key));
|
|
1478
1479
|
const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
|
|
1479
1480
|
if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
|
|
@@ -4055,6 +4056,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
4055
4056
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
4056
4057
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
4057
4058
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
4059
|
+
TranslatableString2["DeprecatedLabel"] = "%1 (deprecated)";
|
|
4058
4060
|
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
4059
4061
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
4060
4062
|
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|