@rjsf/utils 5.22.4 → 5.23.0

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.
Files changed (54) hide show
  1. package/dist/index.js +166 -55
  2. package/dist/index.js.map +2 -2
  3. package/dist/utils.esm.js +166 -55
  4. package/dist/utils.esm.js.map +2 -2
  5. package/dist/utils.umd.js +178 -59
  6. package/lib/ErrorSchemaBuilder.js +3 -3
  7. package/lib/ErrorSchemaBuilder.js.map +1 -1
  8. package/lib/createSchemaUtils.js +7 -7
  9. package/lib/createSchemaUtils.js.map +1 -1
  10. package/lib/schema/getClosestMatchingOption.d.ts +5 -3
  11. package/lib/schema/getClosestMatchingOption.js +11 -7
  12. package/lib/schema/getClosestMatchingOption.js.map +1 -1
  13. package/lib/schema/getDefaultFormState.d.ts +1 -1
  14. package/lib/schema/getDefaultFormState.js +28 -11
  15. package/lib/schema/getDefaultFormState.js.map +1 -1
  16. package/lib/schema/getDisplayLabel.d.ts +3 -2
  17. package/lib/schema/getDisplayLabel.js +4 -3
  18. package/lib/schema/getDisplayLabel.js.map +1 -1
  19. package/lib/schema/isFilesArray.d.ts +3 -2
  20. package/lib/schema/isFilesArray.js +3 -2
  21. package/lib/schema/isFilesArray.js.map +1 -1
  22. package/lib/schema/isMultiSelect.d.ts +3 -2
  23. package/lib/schema/isMultiSelect.js +3 -2
  24. package/lib/schema/isMultiSelect.js.map +1 -1
  25. package/lib/schema/isSelect.d.ts +3 -2
  26. package/lib/schema/isSelect.js +3 -2
  27. package/lib/schema/isSelect.js.map +1 -1
  28. package/lib/schema/retrieveSchema.d.ts +2 -1
  29. package/lib/schema/retrieveSchema.js +5 -4
  30. package/lib/schema/retrieveSchema.js.map +1 -1
  31. package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
  32. package/lib/schema/sanitizeDataForNewSchema.js +8 -7
  33. package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
  34. package/lib/schema/toIdSchema.js +1 -1
  35. package/lib/schema/toIdSchema.js.map +1 -1
  36. package/lib/schema/toPathSchema.d.ts +3 -2
  37. package/lib/schema/toPathSchema.js +13 -11
  38. package/lib/schema/toPathSchema.js.map +1 -1
  39. package/lib/tsconfig.tsbuildinfo +1 -1
  40. package/lib/types.d.ts +12 -0
  41. package/package.json +2 -2
  42. package/src/ErrorSchemaBuilder.ts +3 -3
  43. package/src/createSchemaUtils.ts +29 -7
  44. package/src/schema/getClosestMatchingOption.ts +31 -8
  45. package/src/schema/getDefaultFormState.ts +35 -10
  46. package/src/schema/getDisplayLabel.ts +6 -3
  47. package/src/schema/isFilesArray.ts +18 -3
  48. package/src/schema/isMultiSelect.ts +9 -3
  49. package/src/schema/isSelect.ts +5 -3
  50. package/src/schema/retrieveSchema.ts +19 -4
  51. package/src/schema/sanitizeDataForNewSchema.ts +49 -8
  52. package/src/schema/toIdSchema.ts +1 -1
  53. package/src/schema/toPathSchema.ts +45 -12
  54. package/src/types.ts +12 -0
package/dist/utils.esm.js CHANGED
@@ -556,7 +556,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
556
556
  }
557
557
  return isEqual(schema, resolvedSchema) ? schema : resolvedSchema;
558
558
  }
559
- function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
559
+ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
560
560
  const schema = {
561
561
  ...theSchema,
562
562
  properties: { ...theSchema.properties }
@@ -573,7 +573,8 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
573
573
  validator,
574
574
  { $ref: get4(schema.additionalProperties, [REF_KEY]) },
575
575
  rootSchema,
576
- formData
576
+ formData,
577
+ experimental_customMergeAllOf
577
578
  );
578
579
  } else if ("type" in schema.additionalProperties) {
579
580
  additionalProperties = { ...schema.additionalProperties };
@@ -603,7 +604,8 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
603
604
  rootSchema,
604
605
  expandAllBranches,
605
606
  recurseList,
606
- rawFormData
607
+ rawFormData,
608
+ experimental_customMergeAllOf
607
609
  );
608
610
  return resolvedSchemas.flatMap((s) => {
609
611
  let resolvedSchema = s;
@@ -650,7 +652,13 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
650
652
  }
651
653
  const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
652
654
  if (hasAdditionalProperties) {
653
- return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, rawFormData);
655
+ return stubExistingAdditionalProperties(
656
+ validator,
657
+ resolvedSchema,
658
+ rootSchema,
659
+ rawFormData,
660
+ experimental_customMergeAllOf
661
+ );
654
662
  }
655
663
  return resolvedSchema;
656
664
  });
@@ -835,7 +843,7 @@ var JUNK_OPTION = {
835
843
  }
836
844
  }
837
845
  };
838
- function calculateIndexScore(validator, rootSchema, schema, formData) {
846
+ function calculateIndexScore(validator, rootSchema, schema, formData, experimental_customMergeAllOf) {
839
847
  let totalScore = 0;
840
848
  if (schema) {
841
849
  if (isObject2(schema.properties)) {
@@ -847,8 +855,20 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
847
855
  return score;
848
856
  }
849
857
  if (has2(value, REF_KEY)) {
850
- const newSchema = retrieveSchema(validator, value, rootSchema, formValue);
851
- return score + calculateIndexScore(validator, rootSchema, newSchema, formValue || {});
858
+ const newSchema = retrieveSchema(
859
+ validator,
860
+ value,
861
+ rootSchema,
862
+ formValue,
863
+ experimental_customMergeAllOf
864
+ );
865
+ return score + calculateIndexScore(
866
+ validator,
867
+ rootSchema,
868
+ newSchema,
869
+ formValue || {},
870
+ experimental_customMergeAllOf
871
+ );
852
872
  }
853
873
  if ((has2(value, ONE_OF_KEY) || has2(value, ANY_OF_KEY)) && formValue) {
854
874
  const key2 = has2(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
@@ -859,14 +879,15 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
859
879
  formValue,
860
880
  get5(value, key2),
861
881
  -1,
862
- discriminator
882
+ discriminator,
883
+ experimental_customMergeAllOf
863
884
  );
864
885
  }
865
886
  if (value.type === "object") {
866
887
  if (isObject2(formValue)) {
867
888
  score += 1;
868
889
  }
869
- return score + calculateIndexScore(validator, rootSchema, value, formValue);
890
+ return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
870
891
  }
871
892
  if (value.type === guessType(formValue)) {
872
893
  let newScore = score + 1;
@@ -887,7 +908,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
887
908
  }
888
909
  return totalScore;
889
910
  }
890
- function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField) {
911
+ function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField, experimental_customMergeAllOf) {
891
912
  const resolvedOptions = options.map((option) => {
892
913
  return resolveAllReferences(option, rootSchema, []);
893
914
  });
@@ -914,7 +935,7 @@ function getClosestMatchingOption(validator, rootSchema, formData, options, sele
914
935
  (scoreData, index) => {
915
936
  const { bestScore } = scoreData;
916
937
  const option = resolvedOptions[index];
917
- const score = calculateIndexScore(validator, rootSchema, option, formData);
938
+ const score = calculateIndexScore(validator, rootSchema, option, formData, experimental_customMergeAllOf);
918
939
  scoreCount.add(score);
919
940
  if (score > bestScore) {
920
941
  return { bestIndex: index, bestScore: score };
@@ -1003,8 +1024,8 @@ function isConstant(schema) {
1003
1024
  }
1004
1025
 
1005
1026
  // src/schema/isSelect.ts
1006
- function isSelect(validator, theSchema, rootSchema = {}) {
1007
- const schema = retrieveSchema(validator, theSchema, rootSchema, void 0);
1027
+ function isSelect(validator, theSchema, rootSchema = {}, experimental_customMergeAllOf) {
1028
+ const schema = retrieveSchema(validator, theSchema, rootSchema, void 0, experimental_customMergeAllOf);
1008
1029
  const altSchemas = schema.oneOf || schema.anyOf;
1009
1030
  if (Array.isArray(schema.enum)) {
1010
1031
  return true;
@@ -1016,14 +1037,15 @@ function isSelect(validator, theSchema, rootSchema = {}) {
1016
1037
  }
1017
1038
 
1018
1039
  // src/schema/isMultiSelect.ts
1019
- function isMultiSelect(validator, schema, rootSchema) {
1040
+ function isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) {
1020
1041
  if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
1021
1042
  return false;
1022
1043
  }
1023
- return isSelect(validator, schema.items, rootSchema);
1044
+ return isSelect(validator, schema.items, rootSchema, experimental_customMergeAllOf);
1024
1045
  }
1025
1046
 
1026
1047
  // src/schema/getDefaultFormState.ts
1048
+ var PRIMITIVE_TYPES = ["string", "number", "integer", "boolean", "null"];
1027
1049
  function getInnerSchemaForArrayItem(schema, additionalItems = 0 /* Ignore */, idx = -1) {
1028
1050
  if (idx >= 0) {
1029
1051
  if (Array.isArray(schema.items) && idx < schema.items.length) {
@@ -1079,8 +1101,9 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1079
1101
  const schema = isObject(rawSchema) ? rawSchema : {};
1080
1102
  let defaults = parentDefaults;
1081
1103
  let schemaToCompute = null;
1104
+ let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;
1082
1105
  let updatedRecurseList = _recurseList;
1083
- if (isConstant(schema)) {
1106
+ if (schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults !== "never") {
1084
1107
  defaults = schema.const;
1085
1108
  } else if (isObject(defaults) && isObject(schema.default)) {
1086
1109
  defaults = mergeObjects(defaults, schema.default);
@@ -1114,6 +1137,7 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1114
1137
  includeUndefinedValues,
1115
1138
  _recurseList,
1116
1139
  experimental_defaultFormStateBehavior,
1140
+ experimental_customMergeAllOf,
1117
1141
  parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : void 0,
1118
1142
  rawFormData: formData,
1119
1143
  required
@@ -1125,13 +1149,18 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1125
1149
  return void 0;
1126
1150
  }
1127
1151
  const discriminator = getDiscriminatorFieldFromSchema(schema);
1152
+ const { type = "null" } = remaining;
1153
+ if (!Array.isArray(type) && PRIMITIVE_TYPES.includes(type) && experimental_dfsb_to_compute?.constAsDefaults === "skipOneOf") {
1154
+ experimental_dfsb_to_compute = { ...experimental_dfsb_to_compute, constAsDefaults: "never" };
1155
+ }
1128
1156
  schemaToCompute = oneOf[getClosestMatchingOption(
1129
1157
  validator,
1130
1158
  rootSchema,
1131
1159
  isEmpty(formData) ? void 0 : formData,
1132
1160
  oneOf,
1133
1161
  0,
1134
- discriminator
1162
+ discriminator,
1163
+ experimental_customMergeAllOf
1135
1164
  )];
1136
1165
  schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1137
1166
  } else if (ANY_OF_KEY in schema) {
@@ -1146,7 +1175,8 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1146
1175
  isEmpty(formData) ? void 0 : formData,
1147
1176
  anyOf,
1148
1177
  0,
1149
- discriminator
1178
+ discriminator,
1179
+ experimental_customMergeAllOf
1150
1180
  )];
1151
1181
  schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1152
1182
  }
@@ -1155,7 +1185,8 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
1155
1185
  rootSchema,
1156
1186
  includeUndefinedValues,
1157
1187
  _recurseList: updatedRecurseList,
1158
- experimental_defaultFormStateBehavior,
1188
+ experimental_defaultFormStateBehavior: experimental_dfsb_to_compute,
1189
+ experimental_customMergeAllOf,
1159
1190
  parentDefaults: defaults,
1160
1191
  rawFormData: formData,
1161
1192
  required
@@ -1185,7 +1216,7 @@ function getObjectDefaults(validator, rawSchema, {
1185
1216
  (acc, key) => {
1186
1217
  const propertySchema = get7(retrievedSchema, [PROPERTIES_KEY, key]);
1187
1218
  const hasParentConst = isObject(parentConst) && parentConst[key] !== void 0;
1188
- const hasConst = isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst;
1219
+ const hasConst = (isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst) && experimental_defaultFormStateBehavior?.constAsDefaults !== "never";
1189
1220
  const computedDefault = computeDefaults(validator, propertySchema, {
1190
1221
  rootSchema,
1191
1222
  _recurseList,
@@ -1226,6 +1257,7 @@ function getObjectDefaults(validator, rawSchema, {
1226
1257
  rootSchema,
1227
1258
  _recurseList,
1228
1259
  experimental_defaultFormStateBehavior,
1260
+ experimental_customMergeAllOf,
1229
1261
  includeUndefinedValues: includeUndefinedValues === true,
1230
1262
  parentDefaults: get7(defaults, [key]),
1231
1263
  rawFormData: get7(formData, [key]),
@@ -1249,6 +1281,7 @@ function getArrayDefaults(validator, rawSchema, {
1249
1281
  rootSchema = {},
1250
1282
  _recurseList = [],
1251
1283
  experimental_defaultFormStateBehavior = void 0,
1284
+ experimental_customMergeAllOf = void 0,
1252
1285
  required
1253
1286
  } = {}, defaults) {
1254
1287
  const schema = rawSchema;
@@ -1267,6 +1300,7 @@ function getArrayDefaults(validator, rawSchema, {
1267
1300
  rootSchema,
1268
1301
  _recurseList,
1269
1302
  experimental_defaultFormStateBehavior,
1303
+ experimental_customMergeAllOf,
1270
1304
  parentDefaults: item,
1271
1305
  required
1272
1306
  });
@@ -1282,6 +1316,7 @@ function getArrayDefaults(validator, rawSchema, {
1282
1316
  rootSchema,
1283
1317
  _recurseList,
1284
1318
  experimental_defaultFormStateBehavior,
1319
+ experimental_customMergeAllOf,
1285
1320
  rawFormData: item,
1286
1321
  parentDefaults: get7(defaults, [idx]),
1287
1322
  required
@@ -1291,7 +1326,7 @@ function getArrayDefaults(validator, rawSchema, {
1291
1326
  defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);
1292
1327
  }
1293
1328
  }
1294
- const hasConst = isObject(schema) && CONST_KEY in schema;
1329
+ const hasConst = isObject(schema) && CONST_KEY in schema && experimental_defaultFormStateBehavior?.constAsDefaults !== "never";
1295
1330
  if (hasConst === false) {
1296
1331
  if (neverPopulate) {
1297
1332
  return defaults ?? emptyDefault;
@@ -1301,7 +1336,7 @@ function getArrayDefaults(validator, rawSchema, {
1301
1336
  }
1302
1337
  }
1303
1338
  const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1304
- if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
1339
+ if (!schema.minItems || isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
1305
1340
  return defaults ? defaults : emptyDefault;
1306
1341
  }
1307
1342
  const defaultEntries = defaults || [];
@@ -1313,6 +1348,7 @@ function getArrayDefaults(validator, rawSchema, {
1313
1348
  rootSchema,
1314
1349
  _recurseList,
1315
1350
  experimental_defaultFormStateBehavior,
1351
+ experimental_customMergeAllOf,
1316
1352
  required
1317
1353
  })
1318
1354
  );
@@ -1365,25 +1401,31 @@ function isCustomWidget(uiSchema = {}) {
1365
1401
  }
1366
1402
 
1367
1403
  // src/schema/isFilesArray.ts
1368
- function isFilesArray(validator, schema, uiSchema = {}, rootSchema) {
1404
+ function isFilesArray(validator, schema, uiSchema = {}, rootSchema, experimental_customMergeAllOf) {
1369
1405
  if (uiSchema[UI_WIDGET_KEY] === "files") {
1370
1406
  return true;
1371
1407
  }
1372
1408
  if (schema.items) {
1373
- const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1409
+ const itemsSchema = retrieveSchema(
1410
+ validator,
1411
+ schema.items,
1412
+ rootSchema,
1413
+ void 0,
1414
+ experimental_customMergeAllOf
1415
+ );
1374
1416
  return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1375
1417
  }
1376
1418
  return false;
1377
1419
  }
1378
1420
 
1379
1421
  // src/schema/getDisplayLabel.ts
1380
- function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions) {
1422
+ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions, experimental_customMergeAllOf) {
1381
1423
  const uiOptions = getUiOptions(uiSchema, globalOptions);
1382
1424
  const { label = true } = uiOptions;
1383
1425
  let displayLabel = !!label;
1384
1426
  const schemaType = getSchemaType(schema);
1385
1427
  if (schemaType === "array") {
1386
- displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1428
+ displayLabel = isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || isFilesArray(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) || isCustomWidget(uiSchema);
1387
1429
  }
1388
1430
  if (schemaType === "object") {
1389
1431
  displayLabel = false;
@@ -1417,7 +1459,7 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1417
1459
  import get8 from "lodash/get";
1418
1460
  import has3 from "lodash/has";
1419
1461
  var NO_VALUE = Symbol("no Value");
1420
- function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}) {
1462
+ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
1421
1463
  let newFormData;
1422
1464
  if (has3(newSchema, PROPERTIES_KEY)) {
1423
1465
  const removeOldSchemaData = {};
@@ -1436,10 +1478,22 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1436
1478
  let oldKeyedSchema = get8(oldSchema, [PROPERTIES_KEY, key], {});
1437
1479
  let newKeyedSchema = get8(newSchema, [PROPERTIES_KEY, key], {});
1438
1480
  if (has3(oldKeyedSchema, REF_KEY)) {
1439
- oldKeyedSchema = retrieveSchema(validator, oldKeyedSchema, rootSchema, formValue);
1481
+ oldKeyedSchema = retrieveSchema(
1482
+ validator,
1483
+ oldKeyedSchema,
1484
+ rootSchema,
1485
+ formValue,
1486
+ experimental_customMergeAllOf
1487
+ );
1440
1488
  }
1441
1489
  if (has3(newKeyedSchema, REF_KEY)) {
1442
- newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1490
+ newKeyedSchema = retrieveSchema(
1491
+ validator,
1492
+ newKeyedSchema,
1493
+ rootSchema,
1494
+ formValue,
1495
+ experimental_customMergeAllOf
1496
+ );
1443
1497
  }
1444
1498
  const oldSchemaTypeForKey = get8(oldKeyedSchema, "type");
1445
1499
  const newSchemaTypeForKey = get8(newKeyedSchema, "type");
@@ -1453,7 +1507,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1453
1507
  rootSchema,
1454
1508
  newKeyedSchema,
1455
1509
  oldKeyedSchema,
1456
- formValue
1510
+ formValue,
1511
+ experimental_customMergeAllOf
1457
1512
  );
1458
1513
  if (itemData !== void 0 || newSchemaTypeForKey === "array") {
1459
1514
  nestedData[key] = itemData;
@@ -1486,10 +1541,22 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1486
1541
  let newSchemaItems = get8(newSchema, "items");
1487
1542
  if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1488
1543
  if (has3(oldSchemaItems, REF_KEY)) {
1489
- oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
1544
+ oldSchemaItems = retrieveSchema(
1545
+ validator,
1546
+ oldSchemaItems,
1547
+ rootSchema,
1548
+ data,
1549
+ experimental_customMergeAllOf
1550
+ );
1490
1551
  }
1491
1552
  if (has3(newSchemaItems, REF_KEY)) {
1492
- newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1553
+ newSchemaItems = retrieveSchema(
1554
+ validator,
1555
+ newSchemaItems,
1556
+ rootSchema,
1557
+ data,
1558
+ experimental_customMergeAllOf
1559
+ );
1493
1560
  }
1494
1561
  const oldSchemaType = get8(oldSchemaItems, "type");
1495
1562
  const newSchemaType = get8(newSchemaItems, "type");
@@ -1502,7 +1569,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1502
1569
  rootSchema,
1503
1570
  newSchemaItems,
1504
1571
  oldSchemaItems,
1505
- aValue
1572
+ aValue,
1573
+ experimental_customMergeAllOf
1506
1574
  );
1507
1575
  if (itemValue !== void 0 && (maxItems < 0 || newValue.length < maxItems)) {
1508
1576
  newValue.push(itemValue);
@@ -1525,7 +1593,7 @@ import get9 from "lodash/get";
1525
1593
  import isEqual2 from "lodash/isEqual";
1526
1594
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1527
1595
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1528
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1596
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1529
1597
  const sameSchemaIndex = _recurseList.findIndex((item) => isEqual2(item, _schema));
1530
1598
  if (sameSchemaIndex === -1) {
1531
1599
  return toIdSchemaInternal(
@@ -1595,9 +1663,9 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
1595
1663
  import get10 from "lodash/get";
1596
1664
  import isEqual3 from "lodash/isEqual";
1597
1665
  import set2 from "lodash/set";
1598
- function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1666
+ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1599
1667
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1600
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1668
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1601
1669
  const sameSchemaIndex = _recurseList.findIndex((item) => isEqual3(item, _schema));
1602
1670
  if (sameSchemaIndex === -1) {
1603
1671
  return toPathSchemaInternal(
@@ -1606,7 +1674,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1606
1674
  name,
1607
1675
  rootSchema,
1608
1676
  formData,
1609
- _recurseList.concat(_schema)
1677
+ _recurseList.concat(_schema),
1678
+ experimental_customMergeAllOf
1610
1679
  );
1611
1680
  }
1612
1681
  }
@@ -1616,11 +1685,27 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1616
1685
  if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
1617
1686
  const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
1618
1687
  const discriminator = getDiscriminatorFieldFromSchema(schema);
1619
- const index = getClosestMatchingOption(validator, rootSchema, formData, xxxOf, 0, discriminator);
1688
+ const index = getClosestMatchingOption(
1689
+ validator,
1690
+ rootSchema,
1691
+ formData,
1692
+ xxxOf,
1693
+ 0,
1694
+ discriminator,
1695
+ experimental_customMergeAllOf
1696
+ );
1620
1697
  const _schema = xxxOf[index];
1621
1698
  pathSchema = {
1622
1699
  ...pathSchema,
1623
- ...toPathSchemaInternal(validator, _schema, name, rootSchema, formData, _recurseList)
1700
+ ...toPathSchemaInternal(
1701
+ validator,
1702
+ _schema,
1703
+ name,
1704
+ rootSchema,
1705
+ formData,
1706
+ _recurseList,
1707
+ experimental_customMergeAllOf
1708
+ )
1624
1709
  };
1625
1710
  }
1626
1711
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
@@ -1637,7 +1722,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1637
1722
  `${name}.${i}`,
1638
1723
  rootSchema,
1639
1724
  element,
1640
- _recurseList
1725
+ _recurseList,
1726
+ experimental_customMergeAllOf
1641
1727
  );
1642
1728
  } else if (schemaAdditionalItems) {
1643
1729
  pathSchema[i] = toPathSchemaInternal(
@@ -1646,7 +1732,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1646
1732
  `${name}.${i}`,
1647
1733
  rootSchema,
1648
1734
  element,
1649
- _recurseList
1735
+ _recurseList,
1736
+ experimental_customMergeAllOf
1650
1737
  );
1651
1738
  } else {
1652
1739
  console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
@@ -1660,7 +1747,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1660
1747
  `${name}.${i}`,
1661
1748
  rootSchema,
1662
1749
  element,
1663
- _recurseList
1750
+ _recurseList,
1751
+ experimental_customMergeAllOf
1664
1752
  );
1665
1753
  });
1666
1754
  }
@@ -1675,14 +1763,15 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1675
1763
  // It's possible that formData is not an object -- this can happen if an
1676
1764
  // array item has just been added, but not populated with data yet
1677
1765
  get10(formData, [property]),
1678
- _recurseList
1766
+ _recurseList,
1767
+ experimental_customMergeAllOf
1679
1768
  );
1680
1769
  }
1681
1770
  }
1682
1771
  return pathSchema;
1683
1772
  }
1684
- function toPathSchema(validator, schema, name = "", rootSchema, formData) {
1685
- return toPathSchemaInternal(validator, schema, name, rootSchema, formData);
1773
+ function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
1774
+ return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
1686
1775
  }
1687
1776
 
1688
1777
  // src/createSchemaUtils.ts
@@ -1753,7 +1842,14 @@ var SchemaUtils = class {
1753
1842
  * @returns - True if the label should be displayed or false if it should not
1754
1843
  */
1755
1844
  getDisplayLabel(schema, uiSchema, globalOptions) {
1756
- return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
1845
+ return getDisplayLabel(
1846
+ this.validator,
1847
+ schema,
1848
+ uiSchema,
1849
+ this.rootSchema,
1850
+ globalOptions,
1851
+ this.experimental_customMergeAllOf
1852
+ );
1757
1853
  }
1758
1854
  /** Determines which of the given `options` provided most closely matches the `formData`.
1759
1855
  * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
@@ -1775,7 +1871,8 @@ var SchemaUtils = class {
1775
1871
  formData,
1776
1872
  options,
1777
1873
  selectedOption,
1778
- discriminatorField
1874
+ discriminatorField,
1875
+ this.experimental_customMergeAllOf
1779
1876
  );
1780
1877
  }
1781
1878
  /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
@@ -1810,7 +1907,7 @@ var SchemaUtils = class {
1810
1907
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1811
1908
  */
1812
1909
  isFilesArray(schema, uiSchema) {
1813
- return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1910
+ return isFilesArray(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);
1814
1911
  }
1815
1912
  /** Checks to see if the `schema` combination represents a multi-select
1816
1913
  *
@@ -1818,7 +1915,7 @@ var SchemaUtils = class {
1818
1915
  * @returns - True if schema contains a multi-select, otherwise false
1819
1916
  */
1820
1917
  isMultiSelect(schema) {
1821
- return isMultiSelect(this.validator, schema, this.rootSchema);
1918
+ return isMultiSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
1822
1919
  }
1823
1920
  /** Checks to see if the `schema` combination represents a select
1824
1921
  *
@@ -1826,7 +1923,7 @@ var SchemaUtils = class {
1826
1923
  * @returns - True if schema contains a select, otherwise false
1827
1924
  */
1828
1925
  isSelect(schema) {
1829
- return isSelect(this.validator, schema, this.rootSchema);
1926
+ return isSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
1830
1927
  }
1831
1928
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
1832
1929
  * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
@@ -1871,7 +1968,14 @@ var SchemaUtils = class {
1871
1968
  * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1872
1969
  */
1873
1970
  sanitizeDataForNewSchema(newSchema, oldSchema, data) {
1874
- return sanitizeDataForNewSchema(this.validator, this.rootSchema, newSchema, oldSchema, data);
1971
+ return sanitizeDataForNewSchema(
1972
+ this.validator,
1973
+ this.rootSchema,
1974
+ newSchema,
1975
+ oldSchema,
1976
+ data,
1977
+ this.experimental_customMergeAllOf
1978
+ );
1875
1979
  }
1876
1980
  /** Generates an `IdSchema` object for the `schema`, recursively
1877
1981
  *
@@ -1902,7 +2006,14 @@ var SchemaUtils = class {
1902
2006
  * @returns - The `PathSchema` object for the `schema`
1903
2007
  */
1904
2008
  toPathSchema(schema, name, formData) {
1905
- return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
2009
+ return toPathSchema(
2010
+ this.validator,
2011
+ schema,
2012
+ name,
2013
+ this.rootSchema,
2014
+ formData,
2015
+ this.experimental_customMergeAllOf
2016
+ );
1906
2017
  }
1907
2018
  };
1908
2019
  function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
@@ -2109,9 +2220,9 @@ var ErrorSchemaBuilder = class {
2109
2220
  errorBlock[ERRORS_KEY] = errorsList;
2110
2221
  }
2111
2222
  if (Array.isArray(errorOrList)) {
2112
- errorsList.push(...errorOrList);
2223
+ set3(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, ...errorOrList])]);
2113
2224
  } else {
2114
- errorsList.push(errorOrList);
2225
+ set3(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, errorOrList])]);
2115
2226
  }
2116
2227
  return this;
2117
2228
  }
@@ -2125,7 +2236,7 @@ var ErrorSchemaBuilder = class {
2125
2236
  */
2126
2237
  setErrors(errorOrList, pathOfError) {
2127
2238
  const errorBlock = this.getOrCreateErrorBlock(pathOfError);
2128
- const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
2239
+ const listToAdd = Array.isArray(errorOrList) ? [.../* @__PURE__ */ new Set([...errorOrList])] : [errorOrList];
2129
2240
  set3(errorBlock, ERRORS_KEY, listToAdd);
2130
2241
  return this;
2131
2242
  }