@rjsf/utils 5.13.1 → 5.13.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.js +41 -16
- package/dist/index.js.map +2 -2
- package/dist/utils.esm.js +41 -16
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +41 -16
- package/lib/parser/schemaParser.js +2 -3
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +9 -1
- package/lib/schema/retrieveSchema.js +13 -3
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/toPathSchema.js +19 -3
- package/lib/schema/toPathSchema.js.map +1 -1
- package/package.json +3 -3
- package/src/parser/schemaParser.ts +2 -3
- package/src/schema/retrieveSchema.ts +12 -10
- package/src/schema/toPathSchema.ts +38 -10
package/dist/utils.esm.js
CHANGED
|
@@ -574,7 +574,7 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
|
|
|
574
574
|
return resolvedSchema;
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
|
-
function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches,
|
|
577
|
+
function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches, rawFormData) {
|
|
578
578
|
let anyOrOneOf;
|
|
579
579
|
const { oneOf, anyOf, ...remaining } = schema;
|
|
580
580
|
if (Array.isArray(oneOf)) {
|
|
@@ -586,7 +586,7 @@ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranch
|
|
|
586
586
|
const formData = rawFormData === void 0 && expandAllBranches ? {} : rawFormData;
|
|
587
587
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
588
588
|
anyOrOneOf = anyOrOneOf.map((s) => {
|
|
589
|
-
return resolveAllReferences(s, rootSchema,
|
|
589
|
+
return resolveAllReferences(s, rootSchema, []);
|
|
590
590
|
});
|
|
591
591
|
const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
|
|
592
592
|
if (expandAllBranches) {
|
|
@@ -603,7 +603,6 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, r
|
|
|
603
603
|
remainingSchema,
|
|
604
604
|
rootSchema,
|
|
605
605
|
expandAllBranches,
|
|
606
|
-
recurseList,
|
|
607
606
|
formData
|
|
608
607
|
);
|
|
609
608
|
return resolvedSchemas.flatMap(
|
|
@@ -1444,16 +1443,43 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
|
|
|
1444
1443
|
set2(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
|
|
1445
1444
|
}
|
|
1446
1445
|
if (ITEMS_KEY in schema && Array.isArray(formData)) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1446
|
+
const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;
|
|
1447
|
+
if (Array.isArray(schemaItems)) {
|
|
1448
|
+
formData.forEach((element, i) => {
|
|
1449
|
+
if (schemaItems[i]) {
|
|
1450
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
1451
|
+
validator,
|
|
1452
|
+
schemaItems[i],
|
|
1453
|
+
`${name}.${i}`,
|
|
1454
|
+
rootSchema,
|
|
1455
|
+
element,
|
|
1456
|
+
_recurseList
|
|
1457
|
+
);
|
|
1458
|
+
} else if (schemaAdditionalItems) {
|
|
1459
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
1460
|
+
validator,
|
|
1461
|
+
schemaAdditionalItems,
|
|
1462
|
+
`${name}.${i}`,
|
|
1463
|
+
rootSchema,
|
|
1464
|
+
element,
|
|
1465
|
+
_recurseList
|
|
1466
|
+
);
|
|
1467
|
+
} else {
|
|
1468
|
+
console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
} else {
|
|
1472
|
+
formData.forEach((element, i) => {
|
|
1473
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
1474
|
+
validator,
|
|
1475
|
+
schemaItems,
|
|
1476
|
+
`${name}.${i}`,
|
|
1477
|
+
rootSchema,
|
|
1478
|
+
element,
|
|
1479
|
+
_recurseList
|
|
1480
|
+
);
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1457
1483
|
} else if (PROPERTIES_KEY in schema) {
|
|
1458
1484
|
for (const property in schema.properties) {
|
|
1459
1485
|
const field = get10(schema, [PROPERTIES_KEY, property]);
|
|
@@ -2503,13 +2529,12 @@ var ParserValidator = class {
|
|
|
2503
2529
|
|
|
2504
2530
|
// src/parser/schemaParser.ts
|
|
2505
2531
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
2506
|
-
const
|
|
2507
|
-
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true, recurseRefs);
|
|
2532
|
+
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
2508
2533
|
schemas.forEach((schema2) => {
|
|
2509
2534
|
const sameSchemaIndex = recurseList.findIndex((item) => isEqual7(item, schema2));
|
|
2510
2535
|
if (sameSchemaIndex === -1) {
|
|
2511
2536
|
recurseList.push(schema2);
|
|
2512
|
-
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true
|
|
2537
|
+
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
2513
2538
|
allOptions.forEach((s) => {
|
|
2514
2539
|
if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
|
|
2515
2540
|
forEach(schema2[PROPERTIES_KEY], (value) => {
|