@rjsf/utils 5.13.0 → 5.13.2

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/utils.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/set'), require('lodash/transform'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash/isEqual'), require('lodash'), require('lodash/cloneDeep'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/forEach')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/set', 'lodash/transform', 'json-schema-merge-allof', 'lodash/union', 'lodash/isEqual', 'lodash', 'lodash/cloneDeep', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/forEach'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject, global.isEqualWith, global.get7, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isObject2, global.isString, global.reduce, global.times, global.set3, global.transform, global.mergeAllOf, global.union, global.isEqual3, global.lodash, global.cloneDeep, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.forEach));
5
- })(this, (function (exports, isPlainObject, isEqualWith, get7, isEmpty, jsonpointer, omit, has3, isObject2, isString, reduce, times, set3, transform, mergeAllOf, union, isEqual3, lodash, cloneDeep, react, ReactIs, jsxRuntime, toPath, forEach) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isNumber'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/isEqual'), require('lodash/set'), require('lodash/transform'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash'), require('lodash/cloneDeep'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/forEach')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isNumber', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/isEqual', 'lodash/set', 'lodash/transform', 'json-schema-merge-allof', 'lodash/union', 'lodash', 'lodash/cloneDeep', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/forEach'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject, global.isEqualWith, global.get8, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isNumber, global.isObject2, global.isString, global.reduce, global.times, global.isEqual4, global.set3, global.transform, global.mergeAllOf, global.union, global.lodash, global.cloneDeep, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.forEach));
5
+ })(this, (function (exports, isPlainObject, isEqualWith, get8, isEmpty, jsonpointer, omit, has3, isNumber, isObject2, isString, reduce, times, isEqual4, set3, transform, mergeAllOf, union, lodash, cloneDeep, react, ReactIs, jsxRuntime, toPath, forEach) { 'use strict';
6
6
 
7
7
  // src/isObject.ts
8
8
  function isObject(thing) {
@@ -162,15 +162,43 @@
162
162
  }
163
163
  return current;
164
164
  }
165
+ function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
166
+ if (formData && discriminatorField) {
167
+ const value = get8(formData, discriminatorField);
168
+ if (value === void 0) {
169
+ return;
170
+ }
171
+ for (let i = 0; i < options.length; i++) {
172
+ const option = options[i];
173
+ const discriminator = get8(option, [PROPERTIES_KEY, discriminatorField], {});
174
+ if (discriminator.type === "object" || discriminator.type === "array") {
175
+ continue;
176
+ }
177
+ if (discriminator.const === value) {
178
+ return i;
179
+ }
180
+ if (discriminator.enum?.includes(value)) {
181
+ return i;
182
+ }
183
+ }
184
+ }
185
+ return;
186
+ }
187
+
188
+ // src/schema/getMatchingOption.ts
165
189
  function getMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
166
190
  if (formData === void 0) {
167
191
  return 0;
168
192
  }
193
+ const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);
194
+ if (isNumber(simpleDiscriminatorMatch)) {
195
+ return simpleDiscriminatorMatch;
196
+ }
169
197
  for (let i = 0; i < options.length; i++) {
170
198
  const option = options[i];
171
199
  if (discriminatorField && has3(option, [PROPERTIES_KEY, discriminatorField])) {
172
- const value = get7(formData, discriminatorField);
173
- const discriminator = get7(option, [PROPERTIES_KEY, discriminatorField], {});
200
+ const value = get8(formData, discriminatorField);
201
+ const discriminator = get8(option, [PROPERTIES_KEY, discriminatorField], {});
174
202
  if (validator.isValid(discriminator, value, rootSchema)) {
175
203
  return i;
176
204
  }
@@ -210,7 +238,7 @@
210
238
  }
211
239
  function getDiscriminatorFieldFromSchema(schema) {
212
240
  let discriminator;
213
- const maybeString = get7(schema, "discriminator.propertyName", void 0);
241
+ const maybeString = get8(schema, "discriminator.propertyName", void 0);
214
242
  if (isString(maybeString)) {
215
243
  discriminator = maybeString;
216
244
  } else if (maybeString !== void 0) {
@@ -254,8 +282,12 @@
254
282
  if (!type && (schema.properties || schema.additionalProperties)) {
255
283
  return "object";
256
284
  }
257
- if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
258
- type = type.find((type2) => type2 !== "null");
285
+ if (Array.isArray(type)) {
286
+ if (type.length === 2 && type.includes("null")) {
287
+ type = type.find((type2) => type2 !== "null");
288
+ } else {
289
+ type = type[0];
290
+ }
259
291
  }
260
292
  return type;
261
293
  }
@@ -280,7 +312,7 @@
280
312
  function retrieveSchema(validator, schema, rootSchema = {}, rawFormData) {
281
313
  return retrieveSchemaInternal(validator, schema, rootSchema, rawFormData)[0];
282
314
  }
283
- function resolveCondition(validator, schema, rootSchema, expandAllBranches, formData) {
315
+ function resolveCondition(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
284
316
  const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
285
317
  const conditionValue = validator.isValid(expression, formData || {}, rootSchema);
286
318
  let resolvedSchemas = [resolvedSchemaLessConditional];
@@ -288,19 +320,26 @@
288
320
  if (expandAllBranches) {
289
321
  if (then && typeof then !== "boolean") {
290
322
  schemas = schemas.concat(
291
- retrieveSchemaInternal(validator, then, rootSchema, formData, expandAllBranches)
323
+ retrieveSchemaInternal(validator, then, rootSchema, formData, expandAllBranches, recurseList)
292
324
  );
293
325
  }
294
326
  if (otherwise && typeof otherwise !== "boolean") {
295
327
  schemas = schemas.concat(
296
- retrieveSchemaInternal(validator, otherwise, rootSchema, formData, expandAllBranches)
328
+ retrieveSchemaInternal(validator, otherwise, rootSchema, formData, expandAllBranches, recurseList)
297
329
  );
298
330
  }
299
331
  } else {
300
332
  const conditionalSchema = conditionValue ? then : otherwise;
301
333
  if (conditionalSchema && typeof conditionalSchema !== "boolean") {
302
334
  schemas = schemas.concat(
303
- retrieveSchemaInternal(validator, conditionalSchema, rootSchema, formData, expandAllBranches)
335
+ retrieveSchemaInternal(
336
+ validator,
337
+ conditionalSchema,
338
+ rootSchema,
339
+ formData,
340
+ expandAllBranches,
341
+ recurseList
342
+ )
304
343
  );
305
344
  }
306
345
  }
@@ -308,7 +347,7 @@
308
347
  resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s));
309
348
  }
310
349
  return resolvedSchemas.flatMap(
311
- (s) => retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches)
350
+ (s) => retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches, recurseList)
312
351
  );
313
352
  }
314
353
  function getAllPermutationsOfXxxOf(listOfLists) {
@@ -325,40 +364,72 @@
325
364
  );
326
365
  return allPermutations;
327
366
  }
328
- function resolveSchema(validator, schema, rootSchema, expandAllBranches, formData) {
329
- if (REF_KEY in schema) {
330
- return resolveReference(validator, schema, rootSchema, expandAllBranches, formData);
367
+ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
368
+ const updatedSchemas = resolveReference(
369
+ validator,
370
+ schema,
371
+ rootSchema,
372
+ expandAllBranches,
373
+ recurseList,
374
+ formData
375
+ );
376
+ if (updatedSchemas.length > 1 || updatedSchemas[0] !== schema) {
377
+ return updatedSchemas;
331
378
  }
332
379
  if (DEPENDENCIES_KEY in schema) {
333
- const resolvedSchemas = resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData);
380
+ const resolvedSchemas = resolveDependencies(
381
+ validator,
382
+ schema,
383
+ rootSchema,
384
+ expandAllBranches,
385
+ recurseList,
386
+ formData
387
+ );
334
388
  return resolvedSchemas.flatMap((s) => {
335
- return retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches);
389
+ return retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches, recurseList);
336
390
  });
337
391
  }
338
392
  if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
339
393
  const allOfSchemaElements = schema.allOf.map(
340
- (allOfSubschema) => retrieveSchemaInternal(validator, allOfSubschema, rootSchema, formData, expandAllBranches)
394
+ (allOfSubschema) => retrieveSchemaInternal(
395
+ validator,
396
+ allOfSubschema,
397
+ rootSchema,
398
+ formData,
399
+ expandAllBranches,
400
+ recurseList
401
+ )
341
402
  );
342
403
  const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
343
404
  return allPermutations.map((permutation) => ({ ...schema, allOf: permutation }));
344
405
  }
345
406
  return [schema];
346
407
  }
347
- function resolveReference(validator, schema, rootSchema, expandAllBranches, formData) {
348
- const { $ref, ...localSchema } = schema;
349
- const refSchema = findSchemaDefinition($ref, rootSchema);
350
- return retrieveSchemaInternal(
351
- validator,
352
- { ...refSchema, ...localSchema },
353
- rootSchema,
354
- formData,
355
- expandAllBranches
356
- );
408
+ function resolveReference(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
409
+ const updatedSchema = resolveAllReferences(schema, rootSchema, recurseList);
410
+ if (updatedSchema !== schema) {
411
+ return retrieveSchemaInternal(
412
+ validator,
413
+ updatedSchema,
414
+ rootSchema,
415
+ formData,
416
+ expandAllBranches,
417
+ recurseList
418
+ );
419
+ }
420
+ return [schema];
357
421
  }
358
- function resolveAllReferences(schema, rootSchema) {
422
+ function resolveAllReferences(schema, rootSchema, recurseList) {
423
+ if (!isObject(schema)) {
424
+ return schema;
425
+ }
359
426
  let resolvedSchema = schema;
360
427
  if (REF_KEY in resolvedSchema) {
361
428
  const { $ref, ...localSchema } = resolvedSchema;
429
+ if (recurseList.includes($ref)) {
430
+ return resolvedSchema;
431
+ }
432
+ recurseList.push($ref);
362
433
  const refSchema = findSchemaDefinition($ref, rootSchema);
363
434
  resolvedSchema = { ...refSchema, ...localSchema };
364
435
  }
@@ -366,16 +437,19 @@
366
437
  const updatedProps = transform(
367
438
  resolvedSchema[PROPERTIES_KEY],
368
439
  (result, value, key) => {
369
- result[key] = resolveAllReferences(value, rootSchema);
440
+ result[key] = resolveAllReferences(value, rootSchema, recurseList);
370
441
  },
371
442
  {}
372
443
  );
373
444
  resolvedSchema = { ...resolvedSchema, [PROPERTIES_KEY]: updatedProps };
374
445
  }
375
446
  if (ITEMS_KEY in resolvedSchema && !Array.isArray(resolvedSchema.items) && typeof resolvedSchema.items !== "boolean") {
376
- resolvedSchema = { ...resolvedSchema, items: resolveAllReferences(resolvedSchema.items, rootSchema) };
447
+ resolvedSchema = {
448
+ ...resolvedSchema,
449
+ items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
450
+ };
377
451
  }
378
- return resolvedSchema;
452
+ return isEqual4(schema, resolvedSchema) ? schema : resolvedSchema;
379
453
  }
380
454
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
381
455
  const schema = {
@@ -392,7 +466,7 @@
392
466
  if (REF_KEY in schema.additionalProperties) {
393
467
  additionalProperties = retrieveSchema(
394
468
  validator,
395
- { $ref: get7(schema.additionalProperties, [REF_KEY]) },
469
+ { $ref: get8(schema.additionalProperties, [REF_KEY]) },
396
470
  rootSchema,
397
471
  formData
398
472
  );
@@ -404,25 +478,39 @@
404
478
  ...schema.additionalProperties
405
479
  };
406
480
  } else {
407
- additionalProperties = { type: guessType(get7(formData, [key])) };
481
+ additionalProperties = { type: guessType(get8(formData, [key])) };
408
482
  }
409
483
  } else {
410
- additionalProperties = { type: guessType(get7(formData, [key])) };
484
+ additionalProperties = { type: guessType(get8(formData, [key])) };
411
485
  }
412
486
  schema.properties[key] = additionalProperties;
413
487
  set3(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
414
488
  });
415
489
  return schema;
416
490
  }
417
- function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false) {
491
+ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false, recurseList = []) {
418
492
  if (!isObject(schema)) {
419
493
  return [{}];
420
494
  }
421
- const resolvedSchemas = resolveSchema(validator, schema, rootSchema, expandAllBranches, rawFormData);
495
+ const resolvedSchemas = resolveSchema(
496
+ validator,
497
+ schema,
498
+ rootSchema,
499
+ expandAllBranches,
500
+ recurseList,
501
+ rawFormData
502
+ );
422
503
  return resolvedSchemas.flatMap((s) => {
423
504
  let resolvedSchema = s;
424
505
  if (IF_KEY in resolvedSchema) {
425
- return resolveCondition(validator, resolvedSchema, rootSchema, expandAllBranches, rawFormData);
506
+ return resolveCondition(
507
+ validator,
508
+ resolvedSchema,
509
+ rootSchema,
510
+ expandAllBranches,
511
+ recurseList,
512
+ rawFormData
513
+ );
426
514
  }
427
515
  if (ALL_OF_KEY in resolvedSchema) {
428
516
  if (expandAllBranches) {
@@ -458,7 +546,7 @@
458
546
  const formData = rawFormData === void 0 && expandAllBranches ? {} : rawFormData;
459
547
  const discriminator = getDiscriminatorFieldFromSchema(schema);
460
548
  anyOrOneOf = anyOrOneOf.map((s) => {
461
- return resolveAllReferences(s, rootSchema);
549
+ return resolveAllReferences(s, rootSchema, []);
462
550
  });
463
551
  const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
464
552
  if (expandAllBranches) {
@@ -468,7 +556,7 @@
468
556
  }
469
557
  return [schema];
470
558
  }
471
- function resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData) {
559
+ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
472
560
  const { dependencies, ...remainingSchema } = schema;
473
561
  const resolvedSchemas = resolveAnyOrOneOfSchemas(
474
562
  validator,
@@ -478,13 +566,21 @@
478
566
  formData
479
567
  );
480
568
  return resolvedSchemas.flatMap(
481
- (resolvedSchema) => processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData)
569
+ (resolvedSchema) => processDependencies(
570
+ validator,
571
+ dependencies,
572
+ resolvedSchema,
573
+ rootSchema,
574
+ expandAllBranches,
575
+ recurseList,
576
+ formData
577
+ )
482
578
  );
483
579
  }
484
- function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData) {
580
+ function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData) {
485
581
  let schemas = [resolvedSchema];
486
582
  for (const dependencyKey in dependencies) {
487
- if (!expandAllBranches && get7(formData, [dependencyKey]) === void 0) {
583
+ if (!expandAllBranches && get8(formData, [dependencyKey]) === void 0) {
488
584
  continue;
489
585
  }
490
586
  if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
@@ -504,11 +600,20 @@
504
600
  dependencyKey,
505
601
  dependencyValue,
506
602
  expandAllBranches,
603
+ recurseList,
507
604
  formData
508
605
  );
509
606
  }
510
607
  return schemas.flatMap(
511
- (schema) => processDependencies(validator, remainingDependencies, schema, rootSchema, expandAllBranches, formData)
608
+ (schema) => processDependencies(
609
+ validator,
610
+ remainingDependencies,
611
+ schema,
612
+ rootSchema,
613
+ expandAllBranches,
614
+ recurseList,
615
+ formData
616
+ )
512
617
  );
513
618
  }
514
619
  return schemas;
@@ -520,13 +625,14 @@
520
625
  const required = Array.isArray(schema.required) ? Array.from(/* @__PURE__ */ new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
521
626
  return { ...schema, required };
522
627
  }
523
- function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, formData) {
628
+ function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, recurseList, formData) {
524
629
  const dependentSchemas = retrieveSchemaInternal(
525
630
  validator,
526
631
  dependencyValue,
527
632
  rootSchema,
528
633
  formData,
529
- expandAllBranches
634
+ expandAllBranches,
635
+ recurseList
530
636
  );
531
637
  return dependentSchemas.flatMap((dependent) => {
532
638
  const { oneOf, ...dependentSchema } = dependent;
@@ -538,7 +644,7 @@
538
644
  if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
539
645
  return [subschema];
540
646
  }
541
- return resolveReference(validator, subschema, rootSchema, expandAllBranches, formData);
647
+ return resolveReference(validator, subschema, rootSchema, expandAllBranches, recurseList, formData);
542
648
  });
543
649
  const allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);
544
650
  return allPermutations.flatMap(
@@ -549,12 +655,13 @@
549
655
  dependencyKey,
550
656
  resolvedOneOf,
551
657
  expandAllBranches,
658
+ recurseList,
552
659
  formData
553
660
  )
554
661
  );
555
662
  });
556
663
  }
557
- function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, formData) {
664
+ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, recurseList, formData) {
558
665
  const validSubschemas = oneOf.filter((subschema) => {
559
666
  if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
560
667
  return false;
@@ -584,7 +691,8 @@
584
691
  dependentSchema,
585
692
  rootSchema,
586
693
  formData,
587
- expandAllBranches
694
+ expandAllBranches,
695
+ recurseList
588
696
  );
589
697
  return schemas.map((s2) => mergeSchemas(schema, s2));
590
698
  });
@@ -607,7 +715,7 @@
607
715
  totalScore += reduce(
608
716
  schema.properties,
609
717
  (score, value, key) => {
610
- const formValue = get7(formData, key);
718
+ const formValue = get8(formData, key);
611
719
  if (typeof value === "boolean") {
612
720
  return score;
613
721
  }
@@ -622,7 +730,7 @@
622
730
  validator,
623
731
  rootSchema,
624
732
  formValue,
625
- get7(value, key2),
733
+ get8(value, key2),
626
734
  -1,
627
735
  discriminator
628
736
  );
@@ -651,8 +759,12 @@
651
759
  }
652
760
  function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField) {
653
761
  const resolvedOptions = options.map((option) => {
654
- return resolveAllReferences(option, rootSchema);
762
+ return resolveAllReferences(option, rootSchema, []);
655
763
  });
764
+ const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);
765
+ if (isNumber(simpleDiscriminatorMatch)) {
766
+ return simpleDiscriminatorMatch;
767
+ }
656
768
  const allValidIndexes = resolvedOptions.reduce((validList, option, index) => {
657
769
  const testOptions = [JUNK_OPTION, option];
658
770
  const match = getFirstMatchingOption(validator, formData, testOptions, rootSchema, discriminatorField);
@@ -709,8 +821,8 @@
709
821
  const acc = Object.assign({}, defaults);
710
822
  return Object.keys(formData).reduce((acc2, key) => {
711
823
  acc2[key] = mergeDefaultsWithFormData(
712
- defaults ? get7(defaults, key) : {},
713
- get7(formData, key),
824
+ defaults ? get8(defaults, key) : {},
825
+ get8(formData, key),
714
826
  mergeExtraArrayDefaults
715
827
  );
716
828
  return acc2;
@@ -831,7 +943,7 @@
831
943
  schemaToCompute = findSchemaDefinition(refName, rootSchema);
832
944
  }
833
945
  } else if (DEPENDENCIES_KEY in schema) {
834
- const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, formData);
946
+ const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, [], formData);
835
947
  schemaToCompute = resolvedSchema[0];
836
948
  } else if (isFixedItems(schema)) {
837
949
  defaults = schema.items.map(
@@ -893,13 +1005,13 @@
893
1005
  switch (getSchemaType(schema)) {
894
1006
  case "object": {
895
1007
  const objectDefaults = Object.keys(schema.properties || {}).reduce((acc, key) => {
896
- const computedDefault = computeDefaults(validator, get7(schema, [PROPERTIES_KEY, key]), {
1008
+ const computedDefault = computeDefaults(validator, get8(schema, [PROPERTIES_KEY, key]), {
897
1009
  rootSchema,
898
1010
  _recurseList,
899
1011
  experimental_defaultFormStateBehavior,
900
1012
  includeUndefinedValues: includeUndefinedValues === true,
901
- parentDefaults: get7(defaults, [key]),
902
- rawFormData: get7(formData, [key]),
1013
+ parentDefaults: get8(defaults, [key]),
1014
+ rawFormData: get8(formData, [key]),
903
1015
  required: schema.required?.includes(key)
904
1016
  });
905
1017
  maybeAddDefaultToObject(
@@ -919,22 +1031,19 @@
919
1031
  if (isObject(defaults)) {
920
1032
  Object.keys(defaults).filter((key) => !schema.properties || !schema.properties[key]).forEach((key) => keys.add(key));
921
1033
  }
922
- let formDataRequired;
923
- if (isObject(formData)) {
924
- formDataRequired = [];
925
- Object.keys(formData).filter((key) => !schema.properties || !schema.properties[key]).forEach((key) => {
926
- keys.add(key);
927
- formDataRequired.push(key);
928
- });
929
- }
1034
+ const formDataRequired = [];
1035
+ Object.keys(formData).filter((key) => !schema.properties || !schema.properties[key]).forEach((key) => {
1036
+ keys.add(key);
1037
+ formDataRequired.push(key);
1038
+ });
930
1039
  keys.forEach((key) => {
931
1040
  const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
932
1041
  rootSchema,
933
1042
  _recurseList,
934
1043
  experimental_defaultFormStateBehavior,
935
1044
  includeUndefinedValues: includeUndefinedValues === true,
936
- parentDefaults: get7(defaults, [key]),
937
- rawFormData: get7(formData, [key]),
1045
+ parentDefaults: get8(defaults, [key]),
1046
+ rawFormData: get8(formData, [key]),
938
1047
  required: schema.required?.includes(key)
939
1048
  });
940
1049
  maybeAddDefaultToObject(
@@ -975,7 +1084,7 @@
975
1084
  _recurseList,
976
1085
  experimental_defaultFormStateBehavior,
977
1086
  rawFormData: item,
978
- parentDefaults: get7(defaults, [idx]),
1087
+ parentDefaults: get8(defaults, [idx]),
979
1088
  required
980
1089
  });
981
1090
  });
@@ -1092,27 +1201,27 @@
1092
1201
  if (has3(newSchema, PROPERTIES_KEY)) {
1093
1202
  const removeOldSchemaData = {};
1094
1203
  if (has3(oldSchema, PROPERTIES_KEY)) {
1095
- const properties = get7(oldSchema, PROPERTIES_KEY, {});
1204
+ const properties = get8(oldSchema, PROPERTIES_KEY, {});
1096
1205
  Object.keys(properties).forEach((key) => {
1097
1206
  if (has3(data, key)) {
1098
1207
  removeOldSchemaData[key] = void 0;
1099
1208
  }
1100
1209
  });
1101
1210
  }
1102
- const keys = Object.keys(get7(newSchema, PROPERTIES_KEY, {}));
1211
+ const keys = Object.keys(get8(newSchema, PROPERTIES_KEY, {}));
1103
1212
  const nestedData = {};
1104
1213
  keys.forEach((key) => {
1105
- const formValue = get7(data, key);
1106
- let oldKeyedSchema = get7(oldSchema, [PROPERTIES_KEY, key], {});
1107
- let newKeyedSchema = get7(newSchema, [PROPERTIES_KEY, key], {});
1214
+ const formValue = get8(data, key);
1215
+ let oldKeyedSchema = get8(oldSchema, [PROPERTIES_KEY, key], {});
1216
+ let newKeyedSchema = get8(newSchema, [PROPERTIES_KEY, key], {});
1108
1217
  if (has3(oldKeyedSchema, REF_KEY)) {
1109
1218
  oldKeyedSchema = retrieveSchema(validator, oldKeyedSchema, rootSchema, formValue);
1110
1219
  }
1111
1220
  if (has3(newKeyedSchema, REF_KEY)) {
1112
1221
  newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1113
1222
  }
1114
- const oldSchemaTypeForKey = get7(oldKeyedSchema, "type");
1115
- const newSchemaTypeForKey = get7(newKeyedSchema, "type");
1223
+ const oldSchemaTypeForKey = get8(oldKeyedSchema, "type");
1224
+ const newSchemaTypeForKey = get8(newKeyedSchema, "type");
1116
1225
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
1117
1226
  if (has3(removeOldSchemaData, key)) {
1118
1227
  delete removeOldSchemaData[key];
@@ -1129,17 +1238,17 @@
1129
1238
  nestedData[key] = itemData;
1130
1239
  }
1131
1240
  } else {
1132
- const newOptionDefault = get7(newKeyedSchema, "default", NO_VALUE);
1133
- const oldOptionDefault = get7(oldKeyedSchema, "default", NO_VALUE);
1241
+ const newOptionDefault = get8(newKeyedSchema, "default", NO_VALUE);
1242
+ const oldOptionDefault = get8(oldKeyedSchema, "default", NO_VALUE);
1134
1243
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
1135
1244
  if (oldOptionDefault === formValue) {
1136
1245
  removeOldSchemaData[key] = newOptionDefault;
1137
- } else if (get7(newKeyedSchema, "readOnly") === true) {
1246
+ } else if (get8(newKeyedSchema, "readOnly") === true) {
1138
1247
  removeOldSchemaData[key] = void 0;
1139
1248
  }
1140
1249
  }
1141
- const newOptionConst = get7(newKeyedSchema, "const", NO_VALUE);
1142
- const oldOptionConst = get7(oldKeyedSchema, "const", NO_VALUE);
1250
+ const newOptionConst = get8(newKeyedSchema, "const", NO_VALUE);
1251
+ const oldOptionConst = get8(oldKeyedSchema, "const", NO_VALUE);
1143
1252
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
1144
1253
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
1145
1254
  }
@@ -1151,9 +1260,9 @@
1151
1260
  ...removeOldSchemaData,
1152
1261
  ...nestedData
1153
1262
  };
1154
- } else if (get7(oldSchema, "type") === "array" && get7(newSchema, "type") === "array" && Array.isArray(data)) {
1155
- let oldSchemaItems = get7(oldSchema, "items");
1156
- let newSchemaItems = get7(newSchema, "items");
1263
+ } else if (get8(oldSchema, "type") === "array" && get8(newSchema, "type") === "array" && Array.isArray(data)) {
1264
+ let oldSchemaItems = get8(oldSchema, "items");
1265
+ let newSchemaItems = get8(newSchema, "items");
1157
1266
  if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1158
1267
  if (has3(oldSchemaItems, REF_KEY)) {
1159
1268
  oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
@@ -1161,10 +1270,10 @@
1161
1270
  if (has3(newSchemaItems, REF_KEY)) {
1162
1271
  newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1163
1272
  }
1164
- const oldSchemaType = get7(oldSchemaItems, "type");
1165
- const newSchemaType = get7(newSchemaItems, "type");
1273
+ const oldSchemaType = get8(oldSchemaItems, "type");
1274
+ const newSchemaType = get8(newSchemaItems, "type");
1166
1275
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
1167
- const maxItems = get7(newSchema, "maxItems", -1);
1276
+ const maxItems = get8(newSchema, "maxItems", -1);
1168
1277
  if (newSchemaType === "object") {
1169
1278
  newFormData = data.reduce((newValue, aValue) => {
1170
1279
  const itemValue = sanitizeDataForNewSchema(
@@ -1192,7 +1301,7 @@
1192
1301
  function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
1193
1302
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1194
1303
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1195
- const sameSchemaIndex = _recurseList.findIndex((item) => isEqual3(item, _schema));
1304
+ const sameSchemaIndex = _recurseList.findIndex((item) => isEqual4(item, _schema));
1196
1305
  if (sameSchemaIndex === -1) {
1197
1306
  return toIdSchemaInternal(
1198
1307
  validator,
@@ -1206,10 +1315,10 @@
1206
1315
  );
1207
1316
  }
1208
1317
  }
1209
- if (ITEMS_KEY in schema && !get7(schema, [ITEMS_KEY, REF_KEY])) {
1318
+ if (ITEMS_KEY in schema && !get8(schema, [ITEMS_KEY, REF_KEY])) {
1210
1319
  return toIdSchemaInternal(
1211
1320
  validator,
1212
- get7(schema, ITEMS_KEY),
1321
+ get8(schema, ITEMS_KEY),
1213
1322
  idPrefix,
1214
1323
  idSeparator,
1215
1324
  id,
@@ -1222,7 +1331,7 @@
1222
1331
  const idSchema = { $id };
1223
1332
  if (getSchemaType(schema) === "object" && PROPERTIES_KEY in schema) {
1224
1333
  for (const name in schema.properties) {
1225
- const field = get7(schema, [PROPERTIES_KEY, name]);
1334
+ const field = get8(schema, [PROPERTIES_KEY, name]);
1226
1335
  const fieldId = idSchema[ID_KEY] + idSeparator + name;
1227
1336
  idSchema[name] = toIdSchemaInternal(
1228
1337
  validator,
@@ -1233,7 +1342,7 @@
1233
1342
  rootSchema,
1234
1343
  // It's possible that formData is not an object -- this can happen if an
1235
1344
  // array item has just been added, but not populated with data yet
1236
- get7(formData, [name]),
1345
+ get8(formData, [name]),
1237
1346
  _recurseList
1238
1347
  );
1239
1348
  }
@@ -1246,7 +1355,7 @@
1246
1355
  function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1247
1356
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1248
1357
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1249
- const sameSchemaIndex = _recurseList.findIndex((item) => isEqual3(item, _schema));
1358
+ const sameSchemaIndex = _recurseList.findIndex((item) => isEqual4(item, _schema));
1250
1359
  if (sameSchemaIndex === -1) {
1251
1360
  return toPathSchemaInternal(
1252
1361
  validator,
@@ -1287,7 +1396,7 @@
1287
1396
  });
1288
1397
  } else if (PROPERTIES_KEY in schema) {
1289
1398
  for (const property in schema.properties) {
1290
- const field = get7(schema, [PROPERTIES_KEY, property]);
1399
+ const field = get8(schema, [PROPERTIES_KEY, property]);
1291
1400
  pathSchema[property] = toPathSchemaInternal(
1292
1401
  validator,
1293
1402
  field,
@@ -1295,7 +1404,7 @@
1295
1404
  rootSchema,
1296
1405
  // It's possible that formData is not an object -- this can happen if an
1297
1406
  // array item has just been added, but not populated with data yet
1298
- get7(formData, [property]),
1407
+ get8(formData, [property]),
1299
1408
  _recurseList
1300
1409
  );
1301
1410
  }
@@ -1573,15 +1682,15 @@
1573
1682
  function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
1574
1683
  const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
1575
1684
  if (Array.isArray(selected)) {
1576
- return selected.filter((v) => !isEqual3(v, value));
1685
+ return selected.filter((v) => !isEqual4(v, value));
1577
1686
  }
1578
- return isEqual3(value, selected) ? void 0 : selected;
1687
+ return isEqual4(value, selected) ? void 0 : selected;
1579
1688
  }
1580
1689
  function enumOptionsIsSelected(value, selected) {
1581
1690
  if (Array.isArray(selected)) {
1582
- return selected.some((sel) => isEqual3(sel, value));
1691
+ return selected.some((sel) => isEqual4(sel, value));
1583
1692
  }
1584
- return isEqual3(selected, value);
1693
+ return isEqual4(selected, value);
1585
1694
  }
1586
1695
 
1587
1696
  // src/enumOptionsIndexForValue.ts
@@ -1628,7 +1737,7 @@
1628
1737
  */
1629
1738
  getOrCreateErrorBlock(pathOfError) {
1630
1739
  const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
1631
- let errorBlock = hasPath ? get7(this.errorSchema, pathOfError) : this.errorSchema;
1740
+ let errorBlock = hasPath ? get8(this.errorSchema, pathOfError) : this.errorSchema;
1632
1741
  if (!errorBlock && pathOfError) {
1633
1742
  errorBlock = {};
1634
1743
  set3(this.errorSchema, pathOfError, errorBlock);
@@ -1654,7 +1763,7 @@
1654
1763
  */
1655
1764
  addErrors(errorOrList, pathOfError) {
1656
1765
  const errorBlock = this.getOrCreateErrorBlock(pathOfError);
1657
- let errorsList = get7(errorBlock, ERRORS_KEY);
1766
+ let errorsList = get8(errorBlock, ERRORS_KEY);
1658
1767
  if (!Array.isArray(errorsList)) {
1659
1768
  errorsList = [];
1660
1769
  errorBlock[ERRORS_KEY] = errorsList;
@@ -1818,7 +1927,7 @@
1818
1927
  }
1819
1928
  };
1820
1929
  function mergeWidgetOptions(AWidget) {
1821
- let MergedWidget = get7(AWidget, "MergedWidget");
1930
+ let MergedWidget = get8(AWidget, "MergedWidget");
1822
1931
  if (!MergedWidget) {
1823
1932
  const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1824
1933
  MergedWidget = ({ options, ...props }) => {
@@ -2222,12 +2331,12 @@
2222
2331
  * @param hash - The hash value at which to map the schema
2223
2332
  */
2224
2333
  addSchema(schema, hash) {
2225
- const key = get7(schema, ID_KEY, hash);
2334
+ const key = get8(schema, ID_KEY, hash);
2226
2335
  const identifiedSchema = { ...schema, [ID_KEY]: key };
2227
2336
  const existing = this.schemaMap[key];
2228
2337
  if (!existing) {
2229
2338
  this.schemaMap[key] = identifiedSchema;
2230
- } else if (!isEqual3(existing, identifiedSchema)) {
2339
+ } else if (!isEqual4(existing, identifiedSchema)) {
2231
2340
  console.error("existing schema:", JSON.stringify(existing, null, 2));
2232
2341
  console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
2233
2342
  throw new Error(
@@ -2249,7 +2358,7 @@
2249
2358
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
2250
2359
  */
2251
2360
  isValid(schema, _formData, rootSchema) {
2252
- if (!isEqual3(rootSchema, this.rootSchema)) {
2361
+ if (!isEqual4(rootSchema, this.rootSchema)) {
2253
2362
  throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
2254
2363
  }
2255
2364
  this.addSchema(schema, hashForSchema(schema));
@@ -2289,7 +2398,7 @@
2289
2398
  function parseSchema(validator, recurseList, rootSchema, schema) {
2290
2399
  const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
2291
2400
  schemas.forEach((schema2) => {
2292
- const sameSchemaIndex = recurseList.findIndex((item) => isEqual3(item, schema2));
2401
+ const sameSchemaIndex = recurseList.findIndex((item) => isEqual4(item, schema2));
2293
2402
  if (sameSchemaIndex === -1) {
2294
2403
  recurseList.push(schema2);
2295
2404
  const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
@@ -2366,6 +2475,7 @@
2366
2475
  exports.getFirstMatchingOption = getFirstMatchingOption;
2367
2476
  exports.getInputProps = getInputProps;
2368
2477
  exports.getMatchingOption = getMatchingOption;
2478
+ exports.getOptionMatchingSimpleDiscriminator = getOptionMatchingSimpleDiscriminator;
2369
2479
  exports.getSchemaType = getSchemaType;
2370
2480
  exports.getSubmitButtonOptions = getSubmitButtonOptions;
2371
2481
  exports.getTemplate = getTemplate;