@rjsf/utils 5.22.3 → 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 +175 -59
  2. package/dist/index.js.map +2 -2
  3. package/dist/utils.esm.js +175 -59
  4. package/dist/utils.esm.js.map +2 -2
  5. package/dist/utils.umd.js +187 -63
  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 +40 -16
  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 +48 -15
  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,13 +1281,17 @@ 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;
1255
- const neverPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "never";
1256
- const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "requiredOnly";
1288
+ const arrayMinItemsStateBehavior = experimental_defaultFormStateBehavior?.arrayMinItems ?? {};
1289
+ const { populate: arrayMinItemsPopulate, mergeExtraDefaults: arrayMergeExtraDefaults } = arrayMinItemsStateBehavior;
1290
+ const neverPopulate = arrayMinItemsPopulate === "never";
1291
+ const ignoreMinItemsFlagSet = arrayMinItemsPopulate === "requiredOnly";
1292
+ const isPopulateAll = arrayMinItemsPopulate === "all" || !neverPopulate && !ignoreMinItemsFlagSet;
1293
+ const computeSkipPopulate = arrayMinItemsStateBehavior?.computeSkipPopulate ?? (() => false);
1257
1294
  const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === "skipEmptyDefaults";
1258
- const computeSkipPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.computeSkipPopulate ?? (() => false);
1259
1295
  const emptyDefault = isSkipEmptyDefaults ? void 0 : [];
1260
1296
  if (Array.isArray(defaults)) {
1261
1297
  defaults = defaults.map((item, idx) => {
@@ -1264,6 +1300,7 @@ function getArrayDefaults(validator, rawSchema, {
1264
1300
  rootSchema,
1265
1301
  _recurseList,
1266
1302
  experimental_defaultFormStateBehavior,
1303
+ experimental_customMergeAllOf,
1267
1304
  parentDefaults: item,
1268
1305
  required
1269
1306
  });
@@ -1274,19 +1311,22 @@ function getArrayDefaults(validator, rawSchema, {
1274
1311
  if (neverPopulate) {
1275
1312
  defaults = rawFormData;
1276
1313
  } else {
1277
- defaults = rawFormData.map((item, idx) => {
1314
+ const itemDefaults = rawFormData.map((item, idx) => {
1278
1315
  return computeDefaults(validator, schemaItem, {
1279
1316
  rootSchema,
1280
1317
  _recurseList,
1281
1318
  experimental_defaultFormStateBehavior,
1319
+ experimental_customMergeAllOf,
1282
1320
  rawFormData: item,
1283
1321
  parentDefaults: get7(defaults, [idx]),
1284
1322
  required
1285
1323
  });
1286
1324
  });
1325
+ const mergeExtraDefaults = (ignoreMinItemsFlagSet && required || isPopulateAll) && arrayMergeExtraDefaults;
1326
+ defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);
1287
1327
  }
1288
1328
  }
1289
- const hasConst = isObject(schema) && CONST_KEY in schema;
1329
+ const hasConst = isObject(schema) && CONST_KEY in schema && experimental_defaultFormStateBehavior?.constAsDefaults !== "never";
1290
1330
  if (hasConst === false) {
1291
1331
  if (neverPopulate) {
1292
1332
  return defaults ?? emptyDefault;
@@ -1296,7 +1336,7 @@ function getArrayDefaults(validator, rawSchema, {
1296
1336
  }
1297
1337
  }
1298
1338
  const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1299
- 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) {
1300
1340
  return defaults ? defaults : emptyDefault;
1301
1341
  }
1302
1342
  const defaultEntries = defaults || [];
@@ -1308,6 +1348,7 @@ function getArrayDefaults(validator, rawSchema, {
1308
1348
  rootSchema,
1309
1349
  _recurseList,
1310
1350
  experimental_defaultFormStateBehavior,
1351
+ experimental_customMergeAllOf,
1311
1352
  required
1312
1353
  })
1313
1354
  );
@@ -1360,25 +1401,31 @@ function isCustomWidget(uiSchema = {}) {
1360
1401
  }
1361
1402
 
1362
1403
  // src/schema/isFilesArray.ts
1363
- function isFilesArray(validator, schema, uiSchema = {}, rootSchema) {
1404
+ function isFilesArray(validator, schema, uiSchema = {}, rootSchema, experimental_customMergeAllOf) {
1364
1405
  if (uiSchema[UI_WIDGET_KEY] === "files") {
1365
1406
  return true;
1366
1407
  }
1367
1408
  if (schema.items) {
1368
- 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
+ );
1369
1416
  return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1370
1417
  }
1371
1418
  return false;
1372
1419
  }
1373
1420
 
1374
1421
  // src/schema/getDisplayLabel.ts
1375
- function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions) {
1422
+ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions, experimental_customMergeAllOf) {
1376
1423
  const uiOptions = getUiOptions(uiSchema, globalOptions);
1377
1424
  const { label = true } = uiOptions;
1378
1425
  let displayLabel = !!label;
1379
1426
  const schemaType = getSchemaType(schema);
1380
1427
  if (schemaType === "array") {
1381
- 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);
1382
1429
  }
1383
1430
  if (schemaType === "object") {
1384
1431
  displayLabel = false;
@@ -1412,7 +1459,7 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1412
1459
  import get8 from "lodash/get";
1413
1460
  import has3 from "lodash/has";
1414
1461
  var NO_VALUE = Symbol("no Value");
1415
- function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}) {
1462
+ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
1416
1463
  let newFormData;
1417
1464
  if (has3(newSchema, PROPERTIES_KEY)) {
1418
1465
  const removeOldSchemaData = {};
@@ -1431,10 +1478,22 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1431
1478
  let oldKeyedSchema = get8(oldSchema, [PROPERTIES_KEY, key], {});
1432
1479
  let newKeyedSchema = get8(newSchema, [PROPERTIES_KEY, key], {});
1433
1480
  if (has3(oldKeyedSchema, REF_KEY)) {
1434
- oldKeyedSchema = retrieveSchema(validator, oldKeyedSchema, rootSchema, formValue);
1481
+ oldKeyedSchema = retrieveSchema(
1482
+ validator,
1483
+ oldKeyedSchema,
1484
+ rootSchema,
1485
+ formValue,
1486
+ experimental_customMergeAllOf
1487
+ );
1435
1488
  }
1436
1489
  if (has3(newKeyedSchema, REF_KEY)) {
1437
- newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1490
+ newKeyedSchema = retrieveSchema(
1491
+ validator,
1492
+ newKeyedSchema,
1493
+ rootSchema,
1494
+ formValue,
1495
+ experimental_customMergeAllOf
1496
+ );
1438
1497
  }
1439
1498
  const oldSchemaTypeForKey = get8(oldKeyedSchema, "type");
1440
1499
  const newSchemaTypeForKey = get8(newKeyedSchema, "type");
@@ -1448,7 +1507,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1448
1507
  rootSchema,
1449
1508
  newKeyedSchema,
1450
1509
  oldKeyedSchema,
1451
- formValue
1510
+ formValue,
1511
+ experimental_customMergeAllOf
1452
1512
  );
1453
1513
  if (itemData !== void 0 || newSchemaTypeForKey === "array") {
1454
1514
  nestedData[key] = itemData;
@@ -1481,10 +1541,22 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1481
1541
  let newSchemaItems = get8(newSchema, "items");
1482
1542
  if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1483
1543
  if (has3(oldSchemaItems, REF_KEY)) {
1484
- oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
1544
+ oldSchemaItems = retrieveSchema(
1545
+ validator,
1546
+ oldSchemaItems,
1547
+ rootSchema,
1548
+ data,
1549
+ experimental_customMergeAllOf
1550
+ );
1485
1551
  }
1486
1552
  if (has3(newSchemaItems, REF_KEY)) {
1487
- newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1553
+ newSchemaItems = retrieveSchema(
1554
+ validator,
1555
+ newSchemaItems,
1556
+ rootSchema,
1557
+ data,
1558
+ experimental_customMergeAllOf
1559
+ );
1488
1560
  }
1489
1561
  const oldSchemaType = get8(oldSchemaItems, "type");
1490
1562
  const newSchemaType = get8(newSchemaItems, "type");
@@ -1497,7 +1569,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1497
1569
  rootSchema,
1498
1570
  newSchemaItems,
1499
1571
  oldSchemaItems,
1500
- aValue
1572
+ aValue,
1573
+ experimental_customMergeAllOf
1501
1574
  );
1502
1575
  if (itemValue !== void 0 && (maxItems < 0 || newValue.length < maxItems)) {
1503
1576
  newValue.push(itemValue);
@@ -1520,7 +1593,7 @@ import get9 from "lodash/get";
1520
1593
  import isEqual2 from "lodash/isEqual";
1521
1594
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1522
1595
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1523
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1596
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1524
1597
  const sameSchemaIndex = _recurseList.findIndex((item) => isEqual2(item, _schema));
1525
1598
  if (sameSchemaIndex === -1) {
1526
1599
  return toIdSchemaInternal(
@@ -1590,9 +1663,9 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
1590
1663
  import get10 from "lodash/get";
1591
1664
  import isEqual3 from "lodash/isEqual";
1592
1665
  import set2 from "lodash/set";
1593
- function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1666
+ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
1594
1667
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1595
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1668
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
1596
1669
  const sameSchemaIndex = _recurseList.findIndex((item) => isEqual3(item, _schema));
1597
1670
  if (sameSchemaIndex === -1) {
1598
1671
  return toPathSchemaInternal(
@@ -1601,7 +1674,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1601
1674
  name,
1602
1675
  rootSchema,
1603
1676
  formData,
1604
- _recurseList.concat(_schema)
1677
+ _recurseList.concat(_schema),
1678
+ experimental_customMergeAllOf
1605
1679
  );
1606
1680
  }
1607
1681
  }
@@ -1611,11 +1685,27 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1611
1685
  if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
1612
1686
  const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
1613
1687
  const discriminator = getDiscriminatorFieldFromSchema(schema);
1614
- 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
+ );
1615
1697
  const _schema = xxxOf[index];
1616
1698
  pathSchema = {
1617
1699
  ...pathSchema,
1618
- ...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
+ )
1619
1709
  };
1620
1710
  }
1621
1711
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
@@ -1632,7 +1722,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1632
1722
  `${name}.${i}`,
1633
1723
  rootSchema,
1634
1724
  element,
1635
- _recurseList
1725
+ _recurseList,
1726
+ experimental_customMergeAllOf
1636
1727
  );
1637
1728
  } else if (schemaAdditionalItems) {
1638
1729
  pathSchema[i] = toPathSchemaInternal(
@@ -1641,7 +1732,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1641
1732
  `${name}.${i}`,
1642
1733
  rootSchema,
1643
1734
  element,
1644
- _recurseList
1735
+ _recurseList,
1736
+ experimental_customMergeAllOf
1645
1737
  );
1646
1738
  } else {
1647
1739
  console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
@@ -1655,7 +1747,8 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1655
1747
  `${name}.${i}`,
1656
1748
  rootSchema,
1657
1749
  element,
1658
- _recurseList
1750
+ _recurseList,
1751
+ experimental_customMergeAllOf
1659
1752
  );
1660
1753
  });
1661
1754
  }
@@ -1670,14 +1763,15 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
1670
1763
  // It's possible that formData is not an object -- this can happen if an
1671
1764
  // array item has just been added, but not populated with data yet
1672
1765
  get10(formData, [property]),
1673
- _recurseList
1766
+ _recurseList,
1767
+ experimental_customMergeAllOf
1674
1768
  );
1675
1769
  }
1676
1770
  }
1677
1771
  return pathSchema;
1678
1772
  }
1679
- function toPathSchema(validator, schema, name = "", rootSchema, formData) {
1680
- 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);
1681
1775
  }
1682
1776
 
1683
1777
  // src/createSchemaUtils.ts
@@ -1748,7 +1842,14 @@ var SchemaUtils = class {
1748
1842
  * @returns - True if the label should be displayed or false if it should not
1749
1843
  */
1750
1844
  getDisplayLabel(schema, uiSchema, globalOptions) {
1751
- 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
+ );
1752
1853
  }
1753
1854
  /** Determines which of the given `options` provided most closely matches the `formData`.
1754
1855
  * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
@@ -1770,7 +1871,8 @@ var SchemaUtils = class {
1770
1871
  formData,
1771
1872
  options,
1772
1873
  selectedOption,
1773
- discriminatorField
1874
+ discriminatorField,
1875
+ this.experimental_customMergeAllOf
1774
1876
  );
1775
1877
  }
1776
1878
  /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
@@ -1805,7 +1907,7 @@ var SchemaUtils = class {
1805
1907
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1806
1908
  */
1807
1909
  isFilesArray(schema, uiSchema) {
1808
- return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1910
+ return isFilesArray(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);
1809
1911
  }
1810
1912
  /** Checks to see if the `schema` combination represents a multi-select
1811
1913
  *
@@ -1813,7 +1915,7 @@ var SchemaUtils = class {
1813
1915
  * @returns - True if schema contains a multi-select, otherwise false
1814
1916
  */
1815
1917
  isMultiSelect(schema) {
1816
- return isMultiSelect(this.validator, schema, this.rootSchema);
1918
+ return isMultiSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
1817
1919
  }
1818
1920
  /** Checks to see if the `schema` combination represents a select
1819
1921
  *
@@ -1821,7 +1923,7 @@ var SchemaUtils = class {
1821
1923
  * @returns - True if schema contains a select, otherwise false
1822
1924
  */
1823
1925
  isSelect(schema) {
1824
- return isSelect(this.validator, schema, this.rootSchema);
1926
+ return isSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
1825
1927
  }
1826
1928
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
1827
1929
  * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
@@ -1866,7 +1968,14 @@ var SchemaUtils = class {
1866
1968
  * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1867
1969
  */
1868
1970
  sanitizeDataForNewSchema(newSchema, oldSchema, data) {
1869
- 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
+ );
1870
1979
  }
1871
1980
  /** Generates an `IdSchema` object for the `schema`, recursively
1872
1981
  *
@@ -1897,7 +2006,14 @@ var SchemaUtils = class {
1897
2006
  * @returns - The `PathSchema` object for the `schema`
1898
2007
  */
1899
2008
  toPathSchema(schema, name, formData) {
1900
- 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
+ );
1901
2017
  }
1902
2018
  };
1903
2019
  function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
@@ -2104,9 +2220,9 @@ var ErrorSchemaBuilder = class {
2104
2220
  errorBlock[ERRORS_KEY] = errorsList;
2105
2221
  }
2106
2222
  if (Array.isArray(errorOrList)) {
2107
- errorsList.push(...errorOrList);
2223
+ set3(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, ...errorOrList])]);
2108
2224
  } else {
2109
- errorsList.push(errorOrList);
2225
+ set3(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, errorOrList])]);
2110
2226
  }
2111
2227
  return this;
2112
2228
  }
@@ -2120,7 +2236,7 @@ var ErrorSchemaBuilder = class {
2120
2236
  */
2121
2237
  setErrors(errorOrList, pathOfError) {
2122
2238
  const errorBlock = this.getOrCreateErrorBlock(pathOfError);
2123
- const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
2239
+ const listToAdd = Array.isArray(errorOrList) ? [.../* @__PURE__ */ new Set([...errorOrList])] : [errorOrList];
2124
2240
  set3(errorBlock, ERRORS_KEY, listToAdd);
2125
2241
  return this;
2126
2242
  }