@rjsf/utils 5.0.0-beta.11 → 5.0.0-beta.13

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.
@@ -27,7 +27,6 @@
27
27
  if (typeof File !== "undefined" && thing instanceof File) {
28
28
  return false;
29
29
  }
30
-
31
30
  return typeof thing === "object" && thing !== null && !Array.isArray(thing);
32
31
  }
33
32
 
@@ -37,12 +36,10 @@
37
36
  * @param schema - The schema object to check
38
37
  * @returns - True if additional items is allowed, otherwise false
39
38
  */
40
-
41
39
  function allowAdditionalItems(schema) {
42
40
  if (schema.additionalItems === true) {
43
41
  console.warn("additionalItems=true is currently not supported");
44
42
  }
45
-
46
43
  return isObject(schema.additionalItems);
47
44
  }
48
45
 
@@ -59,29 +56,24 @@
59
56
  if (value === "") {
60
57
  return undefined;
61
58
  }
62
-
63
59
  if (value === null) {
64
60
  return null;
65
61
  }
66
-
67
62
  if (/\.$/.test(value)) {
68
63
  // '3.' can't really be considered a number even if it parses in js. The
69
64
  // user is most likely entering a float.
70
65
  return value;
71
66
  }
72
-
73
67
  if (/\.0$/.test(value)) {
74
68
  // we need to return this as a string here, to allow for input like 3.07
75
69
  return value;
76
70
  }
77
-
78
71
  if (/\.\d*0$/.test(value)) {
79
72
  // It's a number, that's cool - but we need it as a string so it doesn't screw
80
73
  // with the user when entering dollar amounts or other values (such as those with
81
74
  // specific precision or number of significant digits)
82
75
  return value;
83
76
  }
84
-
85
77
  const n = Number(value);
86
78
  const valid = typeof n === "number" && !Number.isNaN(n);
87
79
  return valid ? n : value;
@@ -119,29 +111,26 @@
119
111
  * stripped off.
120
112
  *
121
113
  * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
122
- * @returns - An object containing all of the `ui:xxx` options with the stripped off
114
+ * @returns - An object containing all the `ui:xxx` options with the stripped off
123
115
  */
124
-
125
116
  function getUiOptions(uiSchema) {
126
117
  if (uiSchema === void 0) {
127
118
  uiSchema = {};
128
119
  }
129
-
130
120
  return Object.keys(uiSchema).filter(key => key.indexOf("ui:") === 0).reduce((options, key) => {
131
121
  const value = uiSchema[key];
132
-
133
122
  if (key === UI_WIDGET_KEY && isObject(value)) {
134
123
  console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
135
124
  return options;
136
125
  }
137
-
138
126
  if (key === UI_OPTIONS_KEY && isObject(value)) {
139
- return { ...options,
127
+ return {
128
+ ...options,
140
129
  ...value
141
130
  };
142
131
  }
143
-
144
- return { ...options,
132
+ return {
133
+ ...options,
145
134
  [key.substring(3)]: value
146
135
  };
147
136
  }, {});
@@ -156,30 +145,24 @@
156
145
  * @param [formData] - The formData for the field
157
146
  * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
158
147
  */
159
-
160
148
  function canExpand(schema, uiSchema, formData) {
161
149
  if (uiSchema === void 0) {
162
150
  uiSchema = {};
163
151
  }
164
-
165
152
  if (!schema.additionalProperties) {
166
153
  return false;
167
154
  }
168
-
169
155
  const {
170
156
  expandable = true
171
157
  } = getUiOptions(uiSchema);
172
-
173
158
  if (expandable === false) {
174
159
  return expandable;
175
- } // if ui:options.expandable was not explicitly set to false, we can add
160
+ }
161
+ // if ui:options.expandable was not explicitly set to false, we can add
176
162
  // another property if we have not exceeded maxProperties yet
177
-
178
-
179
163
  if (schema.maxProperties !== undefined && formData) {
180
164
  return Object.keys(formData).length < schema.maxProperties;
181
165
  }
182
-
183
166
  return true;
184
167
  }
185
168
 
@@ -190,7 +173,6 @@
190
173
  * @param b - The second element to compare
191
174
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
192
175
  */
193
-
194
176
  function deepEquals(a, b) {
195
177
  return isEqualWith__default["default"](a, b, (obj, other) => {
196
178
  if (typeof obj === "function" && typeof other === "function") {
@@ -198,7 +180,6 @@
198
180
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
199
181
  return true;
200
182
  }
201
-
202
183
  return undefined; // fallback to default isEquals behavior
203
184
  });
204
185
  }
@@ -211,7 +192,6 @@
211
192
  * @returns - An array with the first value being the object minus the `key` element and the second element being the
212
193
  * value from `object[key]`
213
194
  */
214
-
215
195
  function splitKeyElementFromObject(key, object) {
216
196
  const value = object[key];
217
197
  const remaining = omit__default["default"](object, [key]);
@@ -226,40 +206,32 @@
226
206
  * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
227
207
  * @throws - Error indicating that no schema for that reference exists
228
208
  */
229
-
230
209
  function findSchemaDefinition($ref, rootSchema) {
231
210
  if (rootSchema === void 0) {
232
211
  rootSchema = {};
233
212
  }
234
-
235
213
  let ref = $ref || "";
236
-
237
214
  if (ref.startsWith("#")) {
238
215
  // Decode URI fragment representation.
239
216
  ref = decodeURIComponent(ref.substring(1));
240
217
  } else {
241
- throw new Error("Could not find a definition for " + $ref + ".");
218
+ throw new Error(`Could not find a definition for ${$ref}.`);
242
219
  }
243
-
244
220
  const current = jsonpointer__default["default"].get(rootSchema, ref);
245
-
246
221
  if (current === undefined) {
247
- throw new Error("Could not find a definition for " + $ref + ".");
222
+ throw new Error(`Could not find a definition for ${$ref}.`);
248
223
  }
249
-
250
224
  if (current[REF_KEY]) {
251
225
  const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
252
226
  const subSchema = findSchemaDefinition(theRef, rootSchema);
253
-
254
227
  if (Object.keys(remaining).length > 0) {
255
- return { ...remaining,
228
+ return {
229
+ ...remaining,
256
230
  ...subSchema
257
231
  };
258
232
  }
259
-
260
233
  return subSchema;
261
234
  }
262
-
263
235
  return current;
264
236
  }
265
237
 
@@ -277,16 +249,15 @@
277
249
  if (formData === undefined) {
278
250
  return 0;
279
251
  }
280
-
281
252
  for (let i = 0; i < options.length; i++) {
282
- const option = options[i]; // If the schema describes an object then we need to add slightly more
253
+ const option = options[i];
254
+ // If the schema describes an object then we need to add slightly more
283
255
  // strict matching to the schema, because unless the schema uses the
284
256
  // "requires" keyword, an object will match the schema as long as it
285
257
  // doesn't have matching keys with a conflicting type. To do this we use an
286
258
  // "anyOf" with an array of requires. This augmentation expresses that the
287
259
  // schema should match if any of the keys in the schema are present on the
288
260
  // object and pass validation.
289
-
290
261
  if (option.properties) {
291
262
  // Create an "anyOf" schema that requires at least one of the keys in the
292
263
  // "properties" object
@@ -295,30 +266,27 @@
295
266
  required: [key]
296
267
  }))
297
268
  };
298
- let augmentedSchema; // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
299
-
269
+ let augmentedSchema;
270
+ // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
300
271
  if (option.anyOf) {
301
272
  // Create a shallow clone of the option
302
- const { ...shallowClone
273
+ const {
274
+ ...shallowClone
303
275
  } = option;
304
-
305
276
  if (!shallowClone.allOf) {
306
277
  shallowClone.allOf = [];
307
278
  } else {
308
279
  // If "allOf" already exists, shallow clone the array
309
280
  shallowClone.allOf = shallowClone.allOf.slice();
310
281
  }
311
-
312
282
  shallowClone.allOf.push(requiresAnyOf);
313
283
  augmentedSchema = shallowClone;
314
284
  } else {
315
285
  augmentedSchema = Object.assign({}, option, requiresAnyOf);
316
- } // Remove the "required" field as it's likely that not all fields have
286
+ }
287
+ // Remove the "required" field as it's likely that not all fields have
317
288
  // been filled in yet, which will mean that the schema is not valid
318
-
319
-
320
289
  delete augmentedSchema.required;
321
-
322
290
  if (validator.isValid(augmentedSchema, formData, rootSchema)) {
323
291
  return i;
324
292
  }
@@ -326,7 +294,6 @@
326
294
  return i;
327
295
  }
328
296
  }
329
-
330
297
  return 0;
331
298
  }
332
299
 
@@ -340,28 +307,22 @@
340
307
  if (Array.isArray(value)) {
341
308
  return "array";
342
309
  }
343
-
344
310
  if (typeof value === "string") {
345
311
  return "string";
346
312
  }
347
-
348
313
  if (value == null) {
349
314
  return "null";
350
315
  }
351
-
352
316
  if (typeof value === "boolean") {
353
317
  return "boolean";
354
318
  }
355
-
356
319
  if (!isNaN(value)) {
357
320
  return "number";
358
321
  }
359
-
360
322
  if (typeof value === "object") {
361
323
  return "object";
362
- } // Default to string if we can't figure it out
363
-
364
-
324
+ }
325
+ // Default to string if we can't figure it out
365
326
  return "string";
366
327
  }
367
328
 
@@ -376,28 +337,22 @@
376
337
  * @param schema - The schema for which to get the type
377
338
  * @returns - The type of the schema
378
339
  */
379
-
380
340
  function getSchemaType(schema) {
381
341
  let {
382
342
  type
383
343
  } = schema;
384
-
385
344
  if (!type && schema.const) {
386
345
  return guessType(schema.const);
387
346
  }
388
-
389
347
  if (!type && schema.enum) {
390
348
  return "string";
391
349
  }
392
-
393
350
  if (!type && (schema.properties || schema.additionalProperties)) {
394
351
  return "object";
395
352
  }
396
-
397
353
  if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
398
354
  type = type.find(type => type !== "null");
399
355
  }
400
-
401
356
  return type;
402
357
  }
403
358
 
@@ -407,7 +362,6 @@
407
362
  * @param schema - The schema in which to check for fixed items
408
363
  * @returns - True if there are fixed items in the schema, false otherwise
409
364
  */
410
-
411
365
  function isFixedItems(schema) {
412
366
  return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(item => isObject(item));
413
367
  }
@@ -426,7 +380,6 @@
426
380
  * @param formData - The form data into which the defaults will be merged
427
381
  * @returns - The resulting merged form data with defaults
428
382
  */
429
-
430
383
  function mergeDefaultsWithFormData(defaults, formData) {
431
384
  if (Array.isArray(formData)) {
432
385
  const defaultsArray = Array.isArray(defaults) ? defaults : [];
@@ -434,22 +387,17 @@
434
387
  if (defaultsArray[idx]) {
435
388
  return mergeDefaultsWithFormData(defaultsArray[idx], value);
436
389
  }
437
-
438
390
  return value;
439
391
  });
440
392
  return mapped;
441
393
  }
442
-
443
394
  if (isObject(formData)) {
444
- // eslint-disable-next-line no-unused-vars
445
395
  const acc = Object.assign({}, defaults); // Prevent mutation of source object.
446
-
447
396
  return Object.keys(formData).reduce((acc, key) => {
448
397
  acc[key] = mergeDefaultsWithFormData(defaults ? get__default["default"](defaults, key) : {}, get__default["default"](formData, key));
449
398
  return acc;
450
399
  }, acc);
451
400
  }
452
-
453
401
  return formData;
454
402
  }
455
403
 
@@ -460,16 +408,13 @@
460
408
  * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated
461
409
  * @returns - A new object that is the merge of the two given objects
462
410
  */
463
-
464
411
  function mergeObjects(obj1, obj2, concatArrays) {
465
412
  if (concatArrays === void 0) {
466
413
  concatArrays = false;
467
414
  }
468
-
469
415
  return Object.keys(obj2).reduce((acc, key) => {
470
416
  const left = obj1 ? obj1[key] : {},
471
- right = obj2[key];
472
-
417
+ right = obj2[key];
473
418
  if (obj1 && key in obj1 && isObject(right)) {
474
419
  acc[key] = mergeObjects(left, right, concatArrays);
475
420
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
@@ -477,7 +422,6 @@
477
422
  } else {
478
423
  acc[key] = right;
479
424
  }
480
-
481
425
  return acc;
482
426
  }, Object.assign({}, obj1)); // Prevent mutation of source object.
483
427
  }
@@ -488,7 +432,6 @@
488
432
  * @param schema - The schema for a field
489
433
  * @returns - True if the `schema` has a single constant value, false otherwise
490
434
  */
491
-
492
435
  function isConstant(schema) {
493
436
  return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
494
437
  }
@@ -501,14 +444,11 @@
501
444
  * @param obj2 - The second schema object to merge
502
445
  * @returns - The merged schema object
503
446
  */
504
-
505
447
  function mergeSchemas(obj1, obj2) {
506
448
  const acc = Object.assign({}, obj1); // Prevent mutation of source object.
507
-
508
449
  return Object.keys(obj2).reduce((acc, key) => {
509
450
  const left = obj1 ? obj1[key] : {},
510
- right = obj2[key];
511
-
451
+ right = obj2[key];
512
452
  if (obj1 && key in obj1 && isObject(right)) {
513
453
  acc[key] = mergeSchemas(left, right);
514
454
  } else if (obj1 && obj2 && (getSchemaType(obj1) === "object" || getSchemaType(obj2) === "object") && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
@@ -517,7 +457,6 @@
517
457
  } else {
518
458
  acc[key] = right;
519
459
  }
520
-
521
460
  return acc;
522
461
  }, acc);
523
462
  }
@@ -525,13 +464,12 @@
525
464
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
526
465
  * with the rest of the schema
527
466
  *
528
- * @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions
467
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that is used to detect valid schema conditions
529
468
  * @param schema - The schema for which resolving a condition is desired
530
469
  * @param rootSchema - The root schema that will be forwarded to all the APIs
531
470
  * @param formData - The current formData to assist retrieving a schema
532
471
  * @returns - A schema with the appropriate condition resolved
533
472
  */
534
-
535
473
  function resolveCondition(validator, schema, rootSchema, formData) {
536
474
  const {
537
475
  if: expression,
@@ -540,100 +478,94 @@
540
478
  ...resolvedSchemaLessConditional
541
479
  } = schema;
542
480
  const conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
543
-
544
481
  if (conditionalSchema && typeof conditionalSchema !== "boolean") {
545
482
  return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
546
483
  }
547
-
548
484
  return retrieveSchema(validator, resolvedSchemaLessConditional, rootSchema, formData);
549
485
  }
550
486
  /** Resolves references and dependencies within a schema and its 'allOf' children.
551
487
  * Called internally by retrieveSchema.
552
488
  *
553
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
489
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
554
490
  * @param schema - The schema for which resolving a schema is desired
555
491
  * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
556
492
  * @param [formData] - The current formData, if any, to assist retrieving a schema
557
493
  * @returns - The schema having its references and dependencies resolved
558
494
  */
559
-
560
495
  function resolveSchema(validator, schema, rootSchema, formData) {
561
496
  if (rootSchema === void 0) {
562
497
  rootSchema = {};
563
498
  }
564
-
565
499
  if (REF_KEY in schema) {
566
500
  return resolveReference(validator, schema, rootSchema, formData);
567
501
  }
568
-
569
502
  if (DEPENDENCIES_KEY in schema) {
570
503
  const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
571
504
  return retrieveSchema(validator, resolvedSchema, rootSchema, formData);
572
505
  }
573
-
574
506
  if (ALL_OF_KEY in schema) {
575
- return { ...schema,
507
+ return {
508
+ ...schema,
576
509
  allOf: schema.allOf.map(allOfSubschema => retrieveSchema(validator, allOfSubschema, rootSchema, formData))
577
510
  };
578
- } // No $ref or dependencies attribute found, returning the original schema.
579
-
580
-
511
+ }
512
+ // No $ref or dependencies attribute found, returning the original schema.
581
513
  return schema;
582
514
  }
583
515
  /** Resolves references within a schema and its 'allOf' children.
584
516
  *
585
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
517
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
586
518
  * @param schema - The schema for which resolving a reference is desired
587
519
  * @param rootSchema - The root schema that will be forwarded to all the APIs
588
520
  * @param [formData] - The current formData, if any, to assist retrieving a schema
589
521
  * @returns - The schema having its references resolved
590
522
  */
591
-
592
523
  function resolveReference(validator, schema, rootSchema, formData) {
593
524
  // Retrieve the referenced schema definition.
594
- const $refSchema = findSchemaDefinition(schema.$ref, rootSchema); // Drop the $ref property of the source schema.
595
-
525
+ const $refSchema = findSchemaDefinition(schema.$ref, rootSchema);
526
+ // Drop the $ref property of the source schema.
596
527
  const {
597
528
  $ref,
598
529
  ...localSchema
599
- } = schema; // Update referenced schema definition with local schema properties.
600
-
601
- return retrieveSchema(validator, { ...$refSchema,
530
+ } = schema;
531
+ // Update referenced schema definition with local schema properties.
532
+ return retrieveSchema(validator, {
533
+ ...$refSchema,
602
534
  ...localSchema
603
535
  }, rootSchema, formData);
604
536
  }
605
537
  /** Creates new 'properties' items for each key in the `formData`
606
538
  *
607
- * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
539
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be used when necessary
608
540
  * @param theSchema - The schema for which the existing additional properties is desired
609
541
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator
610
542
  * @param [aFormData] - The current formData, if any, to assist retrieving a schema
611
543
  * @returns - The updated schema with additional properties stubbed
612
544
  */
613
-
614
545
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
615
546
  // Clone the schema so we don't ruin the consumer's original
616
- const schema = { ...theSchema,
617
- properties: { ...theSchema.properties
547
+ const schema = {
548
+ ...theSchema,
549
+ properties: {
550
+ ...theSchema.properties
618
551
  }
619
- }; // make sure formData is an object
620
-
552
+ };
553
+ // make sure formData is an object
621
554
  const formData = aFormData && isObject(aFormData) ? aFormData : {};
622
555
  Object.keys(formData).forEach(key => {
623
556
  if (key in schema.properties) {
624
557
  // No need to stub, our schema already has the property
625
558
  return;
626
559
  }
627
-
628
560
  let additionalProperties = {};
629
-
630
561
  if (typeof schema.additionalProperties !== "boolean") {
631
562
  if (REF_KEY in schema.additionalProperties) {
632
563
  additionalProperties = retrieveSchema(validator, {
633
564
  $ref: get__default["default"](schema.additionalProperties, [REF_KEY])
634
565
  }, rootSchema, formData);
635
566
  } else if ("type" in schema.additionalProperties) {
636
- additionalProperties = { ...schema.additionalProperties
567
+ additionalProperties = {
568
+ ...schema.additionalProperties
637
569
  };
638
570
  } else {
639
571
  additionalProperties = {
@@ -644,11 +576,10 @@
644
576
  additionalProperties = {
645
577
  type: guessType(get__default["default"](formData, [key]))
646
578
  };
647
- } // The type of our new key should match the additionalProperties value;
648
-
649
-
650
- schema.properties[key] = additionalProperties; // Set our additional property flag so we know it was dynamically added
651
-
579
+ }
580
+ // The type of our new key should match the additionalProperties value;
581
+ schema.properties[key] = additionalProperties;
582
+ // Set our additional property flag so we know it was dynamically added
652
583
  set__default["default"](schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
653
584
  });
654
585
  return schema;
@@ -657,31 +588,26 @@
657
588
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
658
589
  * potentially recursive resolution.
659
590
  *
660
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
591
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
661
592
  * @param schema - The schema for which retrieving a schema is desired
662
593
  * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
663
594
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
664
595
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
665
596
  */
666
-
667
597
  function retrieveSchema(validator, schema, rootSchema, rawFormData) {
668
598
  if (rootSchema === void 0) {
669
599
  rootSchema = {};
670
600
  }
671
-
672
601
  if (!isObject(schema)) {
673
602
  return {};
674
603
  }
675
-
676
604
  let resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
677
-
678
605
  if ("if" in schema) {
679
606
  return resolveCondition(validator, schema, rootSchema, rawFormData);
680
607
  }
681
-
682
- const formData = rawFormData || {}; // For each level of the dependency, we need to recursively determine the appropriate resolved schema given the current state of formData.
608
+ const formData = rawFormData || {};
609
+ // For each level of the dependency, we need to recursively determine the appropriate resolved schema given the current state of formData.
683
610
  // Otherwise, nested allOf subschemas will not be correctly displayed.
684
-
685
611
  if (resolvedSchema.properties) {
686
612
  const properties = {};
687
613
  Object.entries(resolvedSchema.properties).forEach(entries => {
@@ -691,18 +617,18 @@
691
617
  const propData = isObject(rawPropData) ? rawPropData : {};
692
618
  const resolvedPropSchema = retrieveSchema(validator, propSchema, rootSchema, propData);
693
619
  properties[propName] = resolvedPropSchema;
694
-
695
620
  if (propSchema !== resolvedPropSchema && resolvedSchema.properties !== properties) {
696
- resolvedSchema = { ...resolvedSchema,
621
+ resolvedSchema = {
622
+ ...resolvedSchema,
697
623
  properties
698
624
  };
699
625
  }
700
626
  });
701
627
  }
702
-
703
628
  if (ALL_OF_KEY in schema) {
704
629
  try {
705
- resolvedSchema = mergeAllOf__default["default"]({ ...resolvedSchema,
630
+ resolvedSchema = mergeAllOf__default["default"]({
631
+ ...resolvedSchema,
706
632
  allOf: resolvedSchema.allOf
707
633
  });
708
634
  } catch (e) {
@@ -714,24 +640,20 @@
714
640
  return resolvedSchemaWithoutAllOf;
715
641
  }
716
642
  }
717
-
718
643
  const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
719
-
720
644
  if (hasAdditionalProperties) {
721
645
  return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, formData);
722
646
  }
723
-
724
647
  return resolvedSchema;
725
648
  }
726
649
  /** Resolves dependencies within a schema and its 'allOf' children.
727
650
  *
728
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
651
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
729
652
  * @param schema - The schema for which resolving a dependency is desired
730
653
  * @param rootSchema - The root schema that will be forwarded to all the APIs
731
654
  * @param [formData] - The current formData, if any, to assist retrieving a schema
732
655
  * @returns - The schema with its dependencies resolved
733
656
  */
734
-
735
657
  function resolveDependencies(validator, schema, rootSchema, formData) {
736
658
  // Drop the dependencies from the source schema.
737
659
  const {
@@ -739,50 +661,42 @@
739
661
  ...remainingSchema
740
662
  } = schema;
741
663
  let resolvedSchema = remainingSchema;
742
-
743
664
  if (Array.isArray(resolvedSchema.oneOf)) {
744
665
  resolvedSchema = resolvedSchema.oneOf[getMatchingOption(validator, formData, resolvedSchema.oneOf, rootSchema)];
745
666
  } else if (Array.isArray(resolvedSchema.anyOf)) {
746
667
  resolvedSchema = resolvedSchema.anyOf[getMatchingOption(validator, formData, resolvedSchema.anyOf, rootSchema)];
747
668
  }
748
-
749
669
  return processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData);
750
670
  }
751
671
  /** Processes all the `dependencies` recursively into the `resolvedSchema` as needed
752
672
  *
753
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
673
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
754
674
  * @param dependencies - The set of dependencies that needs to be processed
755
675
  * @param resolvedSchema - The schema for which processing dependencies is desired
756
676
  * @param rootSchema - The root schema that will be forwarded to all the APIs
757
677
  * @param [formData] - The current formData, if any, to assist retrieving a schema
758
678
  * @returns - The schema with the `dependencies` resolved into it
759
679
  */
760
-
761
680
  function processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData) {
762
- let schema = resolvedSchema; // Process dependencies updating the local schema properties as appropriate.
763
-
681
+ let schema = resolvedSchema;
682
+ // Process dependencies updating the local schema properties as appropriate.
764
683
  for (const dependencyKey in dependencies) {
765
684
  // Skip this dependency if its trigger property is not present.
766
685
  if (get__default["default"](formData, [dependencyKey]) === undefined) {
767
686
  continue;
768
- } // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)
769
-
770
-
687
+ }
688
+ // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)
771
689
  if (schema.properties && !(dependencyKey in schema.properties)) {
772
690
  continue;
773
691
  }
774
-
775
692
  const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(dependencyKey, dependencies);
776
-
777
693
  if (Array.isArray(dependencyValue)) {
778
694
  schema = withDependentProperties(schema, dependencyValue);
779
695
  } else if (isObject(dependencyValue)) {
780
696
  schema = withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData);
781
697
  }
782
-
783
698
  return processDependencies(validator, remainingDependencies, schema, rootSchema, formData);
784
699
  }
785
-
786
700
  return schema;
787
701
  }
788
702
  /** Updates a schema with additionally required properties added
@@ -791,20 +705,19 @@
791
705
  * @param [additionallyRequired] - An optional array of additionally required names
792
706
  * @returns - The schema with the additional required values merged in
793
707
  */
794
-
795
708
  function withDependentProperties(schema, additionallyRequired) {
796
709
  if (!additionallyRequired) {
797
710
  return schema;
798
711
  }
799
-
800
712
  const required = Array.isArray(schema.required) ? Array.from(new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
801
- return { ...schema,
713
+ return {
714
+ ...schema,
802
715
  required: required
803
716
  };
804
717
  }
805
718
  /** Merges a dependent schema into the `schema` dealing with oneOfs and references
806
719
  *
807
- * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
720
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be forwarded to all the APIs
808
721
  * @param schema - The schema for which resolving a dependent schema is desired
809
722
  * @param rootSchema - The root schema that will be forwarded to all the APIs
810
723
  * @param dependencyKey - The key name of the dependency
@@ -812,49 +725,43 @@
812
725
  * @param formData- The current formData to assist retrieving a schema
813
726
  * @returns - The schema with the dependent schema resolved into it
814
727
  */
815
-
816
728
  function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData) {
817
729
  const {
818
730
  oneOf,
819
731
  ...dependentSchema
820
732
  } = retrieveSchema(validator, dependencyValue, rootSchema, formData);
821
- schema = mergeSchemas(schema, dependentSchema); // Since it does not contain oneOf, we return the original schema.
822
-
733
+ schema = mergeSchemas(schema, dependentSchema);
734
+ // Since it does not contain oneOf, we return the original schema.
823
735
  if (oneOf === undefined) {
824
736
  return schema;
825
- } // Resolve $refs inside oneOf.
826
-
827
-
737
+ }
738
+ // Resolve $refs inside oneOf.
828
739
  const resolvedOneOf = oneOf.map(subschema => {
829
740
  if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
830
741
  return subschema;
831
742
  }
832
-
833
743
  return resolveReference(validator, subschema, rootSchema, formData);
834
744
  });
835
745
  return withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, resolvedOneOf, formData);
836
746
  }
837
747
  /** Returns a `schema` with the best choice from the `oneOf` options merged into it
838
748
  *
839
- * @param validator - An implementation of the `ValidatorType` interface that will be used to validate oneOf options
749
+ * @param validator - An implementation of the `ValidatorType<T, S>` interface that will be used to validate oneOf options
840
750
  * @param schema - The schema for which resolving a oneOf subschema is desired
841
751
  * @param rootSchema - The root schema that will be forwarded to all the APIs
842
752
  * @param dependencyKey - The key name of the oneOf dependency
843
753
  * @param oneOf - The list of schemas representing the oneOf options
844
754
  * @param [formData] - The current formData to assist retrieving a schema
845
- * @returns The schema with best choice of oneOf schemas merged into
755
+ * @returns The schema with the best choice of oneOf schemas merged into
846
756
  */
847
-
848
757
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
849
758
  const validSubschemas = oneOf.filter(subschema => {
850
- if (typeof subschema === "boolean" || !subschema.properties) {
759
+ if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
851
760
  return false;
852
761
  }
853
-
854
762
  const {
855
763
  [dependencyKey]: conditionPropertySchema
856
764
  } = subschema.properties;
857
-
858
765
  if (conditionPropertySchema) {
859
766
  const conditionSchema = {
860
767
  type: "object",
@@ -867,18 +774,16 @@
867
774
  } = validator.validateFormData(formData, conditionSchema);
868
775
  return errors.length === 0;
869
776
  }
870
-
871
777
  return false;
872
778
  });
873
-
874
779
  if (validSubschemas.length !== 1) {
875
780
  console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
876
781
  return schema;
877
782
  }
878
-
879
783
  const subschema = validSubschemas[0];
880
784
  const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
881
- const dependentSchema = { ...subschema,
785
+ const dependentSchema = {
786
+ ...subschema,
882
787
  properties: dependentSubschema
883
788
  };
884
789
  return mergeSchemas(schema, retrieveSchema(validator, dependentSchema, rootSchema, formData));
@@ -891,23 +796,18 @@
891
796
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
892
797
  * @returns - True if schema contains a select, otherwise false
893
798
  */
894
-
895
799
  function isSelect(validator, theSchema, rootSchema) {
896
800
  if (rootSchema === void 0) {
897
801
  rootSchema = {};
898
802
  }
899
-
900
803
  const schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
901
804
  const altSchemas = schema.oneOf || schema.anyOf;
902
-
903
805
  if (Array.isArray(schema.enum)) {
904
806
  return true;
905
807
  }
906
-
907
808
  if (Array.isArray(altSchemas)) {
908
809
  return altSchemas.every(altSchemas => typeof altSchemas !== "boolean" && isConstant(altSchemas));
909
810
  }
910
-
911
811
  return false;
912
812
  }
913
813
 
@@ -918,20 +818,16 @@
918
818
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
919
819
  * @returns - True if schema contains a multi-select, otherwise false
920
820
  */
921
-
922
821
  function isMultiSelect(validator, schema, rootSchema) {
923
822
  if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
924
823
  return false;
925
824
  }
926
-
927
825
  return isSelect(validator, schema.items, rootSchema);
928
826
  }
929
827
 
930
828
  /** Enum that indicates how `schema.additionalItems` should be handled by the `getInnerSchemaForArrayItem()` function.
931
829
  */
932
-
933
830
  var AdditionalItemsHandling;
934
-
935
831
  (function (AdditionalItemsHandling) {
936
832
  AdditionalItemsHandling[AdditionalItemsHandling["Ignore"] = 0] = "Ignore";
937
833
  AdditionalItemsHandling[AdditionalItemsHandling["Invert"] = 1] = "Invert";
@@ -952,21 +848,16 @@
952
848
  * @param [idx=-1] - Index, if non-negative, will be used to return the idx-th element in a `schema.items` array
953
849
  * @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers
954
850
  */
955
-
956
-
957
851
  function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
958
852
  if (additionalItems === void 0) {
959
853
  additionalItems = AdditionalItemsHandling.Ignore;
960
854
  }
961
-
962
855
  if (idx === void 0) {
963
856
  idx = -1;
964
857
  }
965
-
966
858
  if (idx >= 0) {
967
859
  if (Array.isArray(schema.items) && idx < schema.items.length) {
968
860
  const item = schema.items[idx];
969
-
970
861
  if (typeof item !== "boolean") {
971
862
  return item;
972
863
  }
@@ -974,11 +865,9 @@
974
865
  } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== "boolean") {
975
866
  return schema.items;
976
867
  }
977
-
978
868
  if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {
979
869
  return schema.additionalItems;
980
870
  }
981
-
982
871
  return {};
983
872
  }
984
873
  /** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into
@@ -992,20 +881,16 @@
992
881
  * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
993
882
  * @returns - The resulting `formData` with all the defaults provided
994
883
  */
995
-
996
884
  function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
997
885
  if (rootSchema === void 0) {
998
886
  rootSchema = {};
999
887
  }
1000
-
1001
888
  if (includeUndefinedValues === void 0) {
1002
889
  includeUndefinedValues = false;
1003
890
  }
1004
-
1005
- const formData = isObject(rawFormData) ? rawFormData : {}; // Compute the defaults recursively: give highest priority to deepest nodes.
1006
-
891
+ const formData = isObject(rawFormData) ? rawFormData : {};
892
+ // Compute the defaults recursively: give highest priority to deepest nodes.
1007
893
  let defaults = parentDefaults;
1008
-
1009
894
  if (isObject(defaults) && isObject(schema.default)) {
1010
895
  // For object defaults, only override parent defaults that are defined in
1011
896
  // schema.default.
@@ -1025,13 +910,11 @@
1025
910
  schema = schema.oneOf[getMatchingOption(validator, isEmpty__default["default"](formData) ? undefined : formData, schema.oneOf, rootSchema)];
1026
911
  } else if (ANY_OF_KEY in schema) {
1027
912
  schema = schema.anyOf[getMatchingOption(validator, isEmpty__default["default"](formData) ? undefined : formData, schema.anyOf, rootSchema)];
1028
- } // Not defaults defined for this node, fallback to generic typed ones.
1029
-
1030
-
913
+ }
914
+ // Not defaults defined for this node, fallback to generic typed ones.
1031
915
  if (typeof defaults === "undefined") {
1032
916
  defaults = schema.default;
1033
917
  }
1034
-
1035
918
  switch (getSchemaType(schema)) {
1036
919
  // We need to recur for object schema inner default values.
1037
920
  case "object":
@@ -1039,14 +922,11 @@
1039
922
  // Compute the defaults for this node, with the parent defaults we might
1040
923
  // have from a previous run: defaults[key].
1041
924
  const computedDefault = computeDefaults(validator, get__default["default"](schema, [PROPERTIES_KEY, key]), get__default["default"](defaults, [key]), rootSchema, get__default["default"](formData, [key]), includeUndefinedValues);
1042
-
1043
925
  if (includeUndefinedValues || computedDefault !== undefined) {
1044
926
  acc[key] = computedDefault;
1045
927
  }
1046
-
1047
928
  return acc;
1048
929
  }, {});
1049
-
1050
930
  case "array":
1051
931
  // Inject defaults into existing array defaults
1052
932
  if (Array.isArray(defaults)) {
@@ -1054,36 +934,30 @@
1054
934
  const schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
1055
935
  return computeDefaults(validator, schemaItem, item, rootSchema);
1056
936
  });
1057
- } // Deeply inject defaults into already existing form data
1058
-
1059
-
937
+ }
938
+ // Deeply inject defaults into already existing form data
1060
939
  if (Array.isArray(rawFormData)) {
1061
940
  const schemaItem = getInnerSchemaForArrayItem(schema);
1062
941
  defaults = rawFormData.map((item, idx) => {
1063
942
  return computeDefaults(validator, schemaItem, get__default["default"](defaults, [idx]), rootSchema, item);
1064
943
  });
1065
944
  }
1066
-
1067
945
  if (schema.minItems) {
1068
946
  if (!isMultiSelect(validator, schema, rootSchema)) {
1069
947
  const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1070
-
1071
948
  if (schema.minItems > defaultsLength) {
1072
- const defaultEntries = defaults || []; // populate the array with the defaults
1073
-
949
+ const defaultEntries = defaults || [];
950
+ // populate the array with the defaults
1074
951
  const fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
1075
952
  const fillerDefault = fillerSchema.default;
1076
- const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema)); // then fill up the rest with either the item default or empty, up to minItems
1077
-
953
+ const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema));
954
+ // then fill up the rest with either the item default or empty, up to minItems
1078
955
  return defaultEntries.concat(fillerEntries);
1079
956
  }
1080
957
  }
1081
-
1082
958
  return defaults ? defaults : [];
1083
959
  }
1084
-
1085
960
  }
1086
-
1087
961
  return defaults;
1088
962
  }
1089
963
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
@@ -1096,32 +970,25 @@
1096
970
  * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1097
971
  * @returns - The resulting `formData` with all the defaults provided
1098
972
  */
1099
-
1100
973
  function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues) {
1101
974
  if (includeUndefinedValues === void 0) {
1102
975
  includeUndefinedValues = false;
1103
976
  }
1104
-
1105
977
  if (!isObject(theSchema)) {
1106
978
  throw new Error("Invalid schema: " + theSchema);
1107
979
  }
1108
-
1109
980
  const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1110
981
  const defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1111
-
1112
982
  if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
1113
983
  // No form data? Use schema defaults.
1114
984
  return defaults;
1115
985
  }
1116
-
1117
986
  if (isObject(formData)) {
1118
987
  return mergeDefaultsWithFormData(defaults, formData);
1119
988
  }
1120
-
1121
989
  if (Array.isArray(formData)) {
1122
990
  return mergeDefaultsWithFormData(defaults, formData);
1123
991
  }
1124
-
1125
992
  return formData;
1126
993
  }
1127
994
 
@@ -1130,13 +997,12 @@
1130
997
  * @param uiSchema - The UI Schema from which to detect if it is customized
1131
998
  * @returns - True if the `uiSchema` describes a custom widget, false otherwise
1132
999
  */
1133
-
1134
1000
  function isCustomWidget(uiSchema) {
1135
1001
  if (uiSchema === void 0) {
1136
1002
  uiSchema = {};
1137
1003
  }
1138
-
1139
- return (// TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1004
+ return (
1005
+ // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1140
1006
  // https://react-jsonschema-form.readthedocs.io/en/latest/usage/widgets/#hidden-widgets
1141
1007
  "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
1142
1008
  );
@@ -1150,21 +1016,17 @@
1150
1016
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1151
1017
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1152
1018
  */
1153
-
1154
1019
  function isFilesArray(validator, schema, uiSchema, rootSchema) {
1155
1020
  if (uiSchema === void 0) {
1156
1021
  uiSchema = {};
1157
1022
  }
1158
-
1159
1023
  if (uiSchema[UI_WIDGET_KEY] === "files") {
1160
1024
  return true;
1161
1025
  }
1162
-
1163
1026
  if (schema.items) {
1164
1027
  const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1165
1028
  return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1166
1029
  }
1167
-
1168
1030
  return false;
1169
1031
  }
1170
1032
 
@@ -1177,35 +1039,28 @@
1177
1039
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1178
1040
  * @returns - True if the label should be displayed or false if it should not
1179
1041
  */
1180
-
1181
1042
  function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1182
1043
  if (uiSchema === void 0) {
1183
1044
  uiSchema = {};
1184
1045
  }
1185
-
1186
1046
  const uiOptions = getUiOptions(uiSchema);
1187
1047
  const {
1188
1048
  label = true
1189
1049
  } = uiOptions;
1190
1050
  let displayLabel = !!label;
1191
1051
  const schemaType = getSchemaType(schema);
1192
-
1193
1052
  if (schemaType === "array") {
1194
1053
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1195
1054
  }
1196
-
1197
1055
  if (schemaType === "object") {
1198
1056
  displayLabel = false;
1199
1057
  }
1200
-
1201
1058
  if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
1202
1059
  displayLabel = false;
1203
1060
  }
1204
-
1205
1061
  if (uiSchema[UI_FIELD_KEY]) {
1206
1062
  displayLabel = false;
1207
1063
  }
1208
-
1209
1064
  return displayLabel;
1210
1065
  }
1211
1066
 
@@ -1219,24 +1074,20 @@
1219
1074
  * @param [additionalErrorSchema] - The additional set of errors in an `ErrorSchema`
1220
1075
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1221
1076
  */
1222
-
1223
1077
  function mergeValidationData(validator, validationData, additionalErrorSchema) {
1224
1078
  if (!additionalErrorSchema) {
1225
1079
  return validationData;
1226
1080
  }
1227
-
1228
1081
  const {
1229
1082
  errors: oldErrors,
1230
1083
  errorSchema: oldErrorSchema
1231
1084
  } = validationData;
1232
1085
  let errors = validator.toErrorList(additionalErrorSchema);
1233
1086
  let errorSchema = additionalErrorSchema;
1234
-
1235
1087
  if (!isEmpty__default["default"](oldErrorSchema)) {
1236
1088
  errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1237
1089
  errors = [...oldErrors].concat(errors);
1238
1090
  }
1239
-
1240
1091
  return {
1241
1092
  errorSchema,
1242
1093
  errors
@@ -1254,41 +1105,34 @@
1254
1105
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1255
1106
  * @returns - The `IdSchema` object for the `schema`
1256
1107
  */
1257
-
1258
1108
  function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSeparator) {
1259
1109
  if (idPrefix === void 0) {
1260
1110
  idPrefix = "root";
1261
1111
  }
1262
-
1263
1112
  if (idSeparator === void 0) {
1264
1113
  idSeparator = "_";
1265
1114
  }
1266
-
1267
1115
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1268
1116
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1269
-
1270
1117
  return toIdSchema(validator, _schema, id, rootSchema, formData, idPrefix, idSeparator);
1271
1118
  }
1272
-
1273
1119
  if (ITEMS_KEY in schema && !get__default["default"](schema, [ITEMS_KEY, REF_KEY])) {
1274
1120
  return toIdSchema(validator, get__default["default"](schema, ITEMS_KEY), id, rootSchema, formData, idPrefix, idSeparator);
1275
1121
  }
1276
-
1277
1122
  const $id = id || idPrefix;
1278
1123
  const idSchema = {
1279
1124
  $id
1280
1125
  };
1281
-
1282
1126
  if (schema.type === "object" && PROPERTIES_KEY in schema) {
1283
1127
  for (const name in schema.properties) {
1284
1128
  const field = get__default["default"](schema, [PROPERTIES_KEY, name]);
1285
1129
  const fieldId = idSchema[ID_KEY] + idSeparator + name;
1286
- idSchema[name] = toIdSchema(validator, isObject(field) ? field : {}, fieldId, rootSchema, // It's possible that formData is not an object -- this can happen if an
1130
+ idSchema[name] = toIdSchema(validator, isObject(field) ? field : {}, fieldId, rootSchema,
1131
+ // It's possible that formData is not an object -- this can happen if an
1287
1132
  // array item has just been added, but not populated with data yet
1288
1133
  get__default["default"](formData, [name]), idPrefix, idSeparator);
1289
1134
  }
1290
1135
  }
1291
-
1292
1136
  return idSchema;
1293
1137
  }
1294
1138
 
@@ -1301,39 +1145,33 @@
1301
1145
  * @param [formData] - The current formData, if any, to assist retrieving a schema
1302
1146
  * @returns - The `PathSchema` object for the `schema`
1303
1147
  */
1304
-
1305
1148
  function toPathSchema(validator, schema, name, rootSchema, formData) {
1306
1149
  if (name === void 0) {
1307
1150
  name = "";
1308
1151
  }
1309
-
1310
1152
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1311
1153
  const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1312
-
1313
1154
  return toPathSchema(validator, _schema, name, rootSchema, formData);
1314
1155
  }
1315
-
1316
1156
  const pathSchema = {
1317
1157
  [NAME_KEY]: name.replace(/^\./, "")
1318
1158
  };
1319
-
1320
1159
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] === true) {
1321
1160
  set__default["default"](pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1322
1161
  }
1323
-
1324
1162
  if (ITEMS_KEY in schema && Array.isArray(formData)) {
1325
1163
  formData.forEach((element, i) => {
1326
- pathSchema[i] = toPathSchema(validator, schema.items, name + "." + i, rootSchema, element);
1164
+ pathSchema[i] = toPathSchema(validator, schema.items, `${name}.${i}`, rootSchema, element);
1327
1165
  });
1328
1166
  } else if (PROPERTIES_KEY in schema) {
1329
1167
  for (const property in schema.properties) {
1330
1168
  const field = get__default["default"](schema, [PROPERTIES_KEY, property]);
1331
- pathSchema[property] = toPathSchema(validator, field, name + "." + property, rootSchema, // It's possible that formData is not an object -- this can happen if an
1169
+ pathSchema[property] = toPathSchema(validator, field, `${name}.${property}`, rootSchema,
1170
+ // It's possible that formData is not an object -- this can happen if an
1332
1171
  // array item has just been added, but not populated with data yet
1333
1172
  get__default["default"](formData, [property]));
1334
1173
  }
1335
1174
  }
1336
-
1337
1175
  return pathSchema;
1338
1176
  }
1339
1177
 
@@ -1342,7 +1180,6 @@
1342
1180
  * and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified set of APIs to the
1343
1181
  * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
1344
1182
  */
1345
-
1346
1183
  class SchemaUtils {
1347
1184
  /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
1348
1185
  *
@@ -1359,8 +1196,6 @@
1359
1196
  *
1360
1197
  * @returns - The `ValidatorType`
1361
1198
  */
1362
-
1363
-
1364
1199
  getValidator() {
1365
1200
  return this.validator;
1366
1201
  }
@@ -1372,13 +1207,10 @@
1372
1207
  * @param rootSchema - The root schema that will be compared against the current one
1373
1208
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
1374
1209
  */
1375
-
1376
-
1377
1210
  doesSchemaUtilsDiffer(validator, rootSchema) {
1378
1211
  if (!validator || !rootSchema) {
1379
1212
  return false;
1380
1213
  }
1381
-
1382
1214
  return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema);
1383
1215
  }
1384
1216
  /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
@@ -1389,13 +1221,10 @@
1389
1221
  * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1390
1222
  * @returns - The resulting `formData` with all the defaults provided
1391
1223
  */
1392
-
1393
-
1394
1224
  getDefaultFormState(schema, formData, includeUndefinedValues) {
1395
1225
  if (includeUndefinedValues === void 0) {
1396
1226
  includeUndefinedValues = false;
1397
1227
  }
1398
-
1399
1228
  return getDefaultFormState(this.validator, schema, formData, this.rootSchema, includeUndefinedValues);
1400
1229
  }
1401
1230
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
@@ -1405,8 +1234,6 @@
1405
1234
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1406
1235
  * @returns - True if the label should be displayed or false if it should not
1407
1236
  */
1408
-
1409
-
1410
1237
  getDisplayLabel(schema, uiSchema) {
1411
1238
  return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1412
1239
  }
@@ -1416,8 +1243,6 @@
1416
1243
  * @param options - The list of options to find a matching options from
1417
1244
  * @returns - The index of the matched option or 0 if none is available
1418
1245
  */
1419
-
1420
-
1421
1246
  getMatchingOption(formData, options) {
1422
1247
  return getMatchingOption(this.validator, formData, options, this.rootSchema);
1423
1248
  }
@@ -1427,8 +1252,6 @@
1427
1252
  * @param [uiSchema] - The UI schema from which to check the widget
1428
1253
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1429
1254
  */
1430
-
1431
-
1432
1255
  isFilesArray(schema, uiSchema) {
1433
1256
  return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1434
1257
  }
@@ -1437,8 +1260,6 @@
1437
1260
  * @param schema - The schema for which check for a multi-select flag is desired
1438
1261
  * @returns - True if schema contains a multi-select, otherwise false
1439
1262
  */
1440
-
1441
-
1442
1263
  isMultiSelect(schema) {
1443
1264
  return isMultiSelect(this.validator, schema, this.rootSchema);
1444
1265
  }
@@ -1447,8 +1268,6 @@
1447
1268
  * @param schema - The schema for which check for a select flag is desired
1448
1269
  * @returns - True if schema contains a select, otherwise false
1449
1270
  */
1450
-
1451
-
1452
1271
  isSelect(schema) {
1453
1272
  return isSelect(this.validator, schema, this.rootSchema);
1454
1273
  }
@@ -1461,8 +1280,6 @@
1461
1280
  * @param [additionalErrorSchema] - The additional set of errors
1462
1281
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1463
1282
  */
1464
-
1465
-
1466
1283
  mergeValidationData(validationData, additionalErrorSchema) {
1467
1284
  return mergeValidationData(this.validator, validationData, additionalErrorSchema);
1468
1285
  }
@@ -1474,8 +1291,6 @@
1474
1291
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1475
1292
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1476
1293
  */
1477
-
1478
-
1479
1294
  retrieveSchema(schema, rawFormData) {
1480
1295
  return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
1481
1296
  }
@@ -1488,17 +1303,13 @@
1488
1303
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1489
1304
  * @returns - The `IdSchema` object for the `schema`
1490
1305
  */
1491
-
1492
-
1493
1306
  toIdSchema(schema, id, formData, idPrefix, idSeparator) {
1494
1307
  if (idPrefix === void 0) {
1495
1308
  idPrefix = "root";
1496
1309
  }
1497
-
1498
1310
  if (idSeparator === void 0) {
1499
1311
  idSeparator = "_";
1500
1312
  }
1501
-
1502
1313
  return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
1503
1314
  }
1504
1315
  /** Generates an `PathSchema` object for the `schema`, recursively
@@ -1508,12 +1319,9 @@
1508
1319
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1509
1320
  * @returns - The `PathSchema` object for the `schema`
1510
1321
  */
1511
-
1512
-
1513
1322
  toPathSchema(schema, name, formData) {
1514
1323
  return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
1515
1324
  }
1516
-
1517
1325
  }
1518
1326
  /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
1519
1327
  * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
@@ -1522,8 +1330,6 @@
1522
1330
  * @param rootSchema - The root schema that will be forwarded to all the APIs
1523
1331
  * @returns - An implementation of a `SchemaUtilsType` interface
1524
1332
  */
1525
-
1526
-
1527
1333
  function createSchemaUtils(validator, rootSchema) {
1528
1334
  return new SchemaUtils(validator, rootSchema);
1529
1335
  }
@@ -1536,35 +1342,31 @@
1536
1342
  */
1537
1343
  function dataURItoBlob(dataURI) {
1538
1344
  // Split metadata from data
1539
- const splitted = dataURI.split(","); // Split params
1540
-
1541
- const params = splitted[0].split(";"); // Get mime-type from params
1542
-
1543
- const type = params[0].replace("data:", ""); // Filter the name property from params
1544
-
1345
+ const splitted = dataURI.split(",");
1346
+ // Split params
1347
+ const params = splitted[0].split(";");
1348
+ // Get mime-type from params
1349
+ const type = params[0].replace("data:", "");
1350
+ // Filter the name property from params
1545
1351
  const properties = params.filter(param => {
1546
1352
  return param.split("=")[0] === "name";
1547
- }); // Look for the name and use unknown if no name property.
1548
-
1353
+ });
1354
+ // Look for the name and use unknown if no name property.
1549
1355
  let name;
1550
-
1551
1356
  if (properties.length !== 1) {
1552
1357
  name = "unknown";
1553
1358
  } else {
1554
1359
  // Because we filtered out the other property,
1555
1360
  // we only have the name case here.
1556
1361
  name = properties[0].split("=")[1];
1557
- } // Built the Uint8Array Blob parameter from the base64 string.
1558
-
1559
-
1362
+ }
1363
+ // Built the Uint8Array Blob parameter from the base64 string.
1560
1364
  const binary = atob(splitted[1]);
1561
1365
  const array = [];
1562
-
1563
1366
  for (let i = 0; i < binary.length; i++) {
1564
1367
  array.push(binary.charCodeAt(i));
1565
- } // Create the blob object
1566
-
1567
-
1368
+ }
1369
+ // Create the blob object
1568
1370
  const blob = new window.Blob([new Uint8Array(array)], {
1569
1371
  type
1570
1372
  });
@@ -1582,19 +1384,15 @@
1582
1384
  */
1583
1385
  function rangeSpec(schema) {
1584
1386
  const spec = {};
1585
-
1586
1387
  if (schema.multipleOf) {
1587
1388
  spec.step = schema.multipleOf;
1588
1389
  }
1589
-
1590
1390
  if (schema.minimum || schema.minimum === 0) {
1591
1391
  spec.min = schema.minimum;
1592
1392
  }
1593
-
1594
1393
  if (schema.maximum || schema.maximum === 0) {
1595
1394
  spec.max = schema.maximum;
1596
1395
  }
1597
-
1598
1396
  return spec;
1599
1397
  }
1600
1398
 
@@ -1606,53 +1404,47 @@
1606
1404
  * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
1607
1405
  * @returns - The extracted `InputPropsType` object
1608
1406
  */
1609
-
1610
1407
  function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1611
1408
  if (options === void 0) {
1612
1409
  options = {};
1613
1410
  }
1614
-
1615
1411
  if (autoDefaultStepAny === void 0) {
1616
1412
  autoDefaultStepAny = true;
1617
1413
  }
1618
-
1619
1414
  const inputProps = {
1620
1415
  type: defaultType || "text",
1621
1416
  ...rangeSpec(schema)
1622
- }; // If options.inputType is set use that as the input type
1623
-
1417
+ };
1418
+ // If options.inputType is set use that as the input type
1624
1419
  if (options.inputType) {
1625
1420
  inputProps.type = options.inputType;
1626
1421
  } else if (!defaultType) {
1627
1422
  // If the schema is of type number or integer, set the input type to number
1628
1423
  if (schema.type === "number") {
1629
- inputProps.type = "number"; // Only add step if one isn't already defined and we are auto-defaulting the "any" step
1630
-
1424
+ inputProps.type = "number";
1425
+ // Only add step if one isn't already defined and we are auto-defaulting the "any" step
1631
1426
  if (autoDefaultStepAny && inputProps.step === undefined) {
1632
1427
  // Setting step to 'any' fixes a bug in Safari where decimals are not
1633
1428
  // allowed in number inputs
1634
1429
  inputProps.step = "any";
1635
1430
  }
1636
1431
  } else if (schema.type === "integer") {
1637
- inputProps.type = "number"; // Only add step if one isn't already defined
1638
-
1432
+ inputProps.type = "number";
1433
+ // Only add step if one isn't already defined
1639
1434
  if (inputProps.step === undefined) {
1640
1435
  // Since this is integer, you always want to step up or down in multiples of 1
1641
1436
  inputProps.step = 1;
1642
1437
  }
1643
1438
  }
1644
1439
  }
1645
-
1646
1440
  if (options.autocomplete) {
1647
1441
  inputProps.autoComplete = options.autocomplete;
1648
1442
  }
1649
-
1650
1443
  return inputProps;
1651
1444
  }
1652
1445
 
1653
1446
  /** The default submit button options, exported for testing purposes
1654
1447
  */
1655
-
1656
1448
  const DEFAULT_OPTIONS = {
1657
1449
  props: {
1658
1450
  disabled: false
@@ -1665,21 +1457,18 @@
1665
1457
  * @param [uiSchema={}] - the UI Schema from which to extract submit button props
1666
1458
  * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
1667
1459
  */
1668
-
1669
1460
  function getSubmitButtonOptions(uiSchema) {
1670
1461
  if (uiSchema === void 0) {
1671
1462
  uiSchema = {};
1672
1463
  }
1673
-
1674
1464
  const uiOptions = getUiOptions(uiSchema);
1675
-
1676
1465
  if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
1677
1466
  const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1678
- return { ...DEFAULT_OPTIONS,
1467
+ return {
1468
+ ...DEFAULT_OPTIONS,
1679
1469
  ...options
1680
1470
  };
1681
1471
  }
1682
-
1683
1472
  return DEFAULT_OPTIONS;
1684
1473
  }
1685
1474
 
@@ -1695,16 +1484,14 @@
1695
1484
  if (uiOptions === void 0) {
1696
1485
  uiOptions = {};
1697
1486
  }
1698
-
1699
1487
  const {
1700
1488
  templates
1701
1489
  } = registry;
1702
-
1703
1490
  if (name === "ButtonTemplates") {
1704
1491
  return templates[name];
1705
1492
  }
1706
-
1707
- return (// Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
1493
+ return (
1494
+ // Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
1708
1495
  // To avoid that, we cast uiOptions to `any` before accessing the name field
1709
1496
  uiOptions[name] || templates[name]
1710
1497
  );
@@ -1712,7 +1499,6 @@
1712
1499
 
1713
1500
  /** The map of schema types to widget type to widget name
1714
1501
  */
1715
-
1716
1502
  const widgetMap = {
1717
1503
  boolean: {
1718
1504
  checkbox: "CheckboxWidget",
@@ -1771,29 +1557,26 @@
1771
1557
  * @param AWidget - A widget that will be wrapped or one that is already wrapped
1772
1558
  * @returns - The wrapper widget
1773
1559
  */
1774
-
1775
1560
  function mergeWidgetOptions(AWidget) {
1776
- let MergedWidget = get__default["default"](AWidget, "MergedWidget"); // cache return value as property of widget for proper react reconciliation
1777
-
1561
+ let MergedWidget = get__default["default"](AWidget, "MergedWidget");
1562
+ // cache return value as property of widget for proper react reconciliation
1778
1563
  if (!MergedWidget) {
1779
1564
  const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1780
-
1781
1565
  MergedWidget = _ref => {
1782
1566
  let {
1783
1567
  options,
1784
1568
  ...props
1785
1569
  } = _ref;
1786
1570
  return /*#__PURE__*/React__default["default"].createElement(AWidget, {
1787
- options: { ...defaultOptions,
1571
+ options: {
1572
+ ...defaultOptions,
1788
1573
  ...options
1789
1574
  },
1790
1575
  ...props
1791
1576
  });
1792
1577
  };
1793
-
1794
1578
  set__default["default"](AWidget, "MergedWidget", MergedWidget);
1795
1579
  }
1796
-
1797
1580
  return MergedWidget;
1798
1581
  }
1799
1582
  /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
@@ -1807,40 +1590,31 @@
1807
1590
  * @returns - The `Widget` component to use
1808
1591
  * @throws - An error if there is no `Widget` component that can be returned
1809
1592
  */
1810
-
1811
-
1812
1593
  function getWidget(schema, widget, registeredWidgets) {
1813
1594
  if (registeredWidgets === void 0) {
1814
1595
  registeredWidgets = {};
1815
1596
  }
1816
-
1817
1597
  const type = getSchemaType(schema);
1818
-
1819
1598
  if (typeof widget === "function" || widget && ReactIs__default["default"].isForwardRef( /*#__PURE__*/React__default["default"].createElement(widget)) || ReactIs__default["default"].isMemo(widget)) {
1820
1599
  return mergeWidgetOptions(widget);
1821
1600
  }
1822
-
1823
1601
  if (typeof widget !== "string") {
1824
- throw new Error("Unsupported widget definition: " + typeof widget);
1602
+ throw new Error(`Unsupported widget definition: ${typeof widget}`);
1825
1603
  }
1826
-
1827
1604
  if (widget in registeredWidgets) {
1828
1605
  const registeredWidget = registeredWidgets[widget];
1829
1606
  return getWidget(schema, registeredWidget, registeredWidgets);
1830
1607
  }
1831
-
1832
1608
  if (typeof type === "string") {
1833
1609
  if (!(type in widgetMap)) {
1834
- throw new Error("No widget for type '" + type + "'");
1610
+ throw new Error(`No widget for type '${type}'`);
1835
1611
  }
1836
-
1837
1612
  if (widget in widgetMap[type]) {
1838
1613
  const registeredWidget = registeredWidgets[widgetMap[type][widget]];
1839
1614
  return getWidget(schema, registeredWidget, registeredWidgets);
1840
1615
  }
1841
1616
  }
1842
-
1843
- throw new Error("No widget '" + widget + "' for type '" + type + "'");
1617
+ throw new Error(`No widget '${widget}' for type '${type}'`);
1844
1618
  }
1845
1619
 
1846
1620
  /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
@@ -1851,22 +1625,18 @@
1851
1625
  * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
1852
1626
  * @returns - True if the widget exists, false otherwise
1853
1627
  */
1854
-
1855
1628
  function hasWidget(schema, widget, registeredWidgets) {
1856
1629
  if (registeredWidgets === void 0) {
1857
1630
  registeredWidgets = {};
1858
1631
  }
1859
-
1860
1632
  try {
1861
1633
  getWidget(schema, widget, registeredWidgets);
1862
1634
  return true;
1863
1635
  } catch (e) {
1864
1636
  const err = e;
1865
-
1866
1637
  if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
1867
1638
  return false;
1868
1639
  }
1869
-
1870
1640
  throw e;
1871
1641
  }
1872
1642
  }
@@ -1887,16 +1657,13 @@
1887
1657
  * @returns - The constant value for the schema
1888
1658
  * @throws - Error when the schema does not have a constant value
1889
1659
  */
1890
-
1891
1660
  function toConstant(schema) {
1892
1661
  if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
1893
1662
  return schema.enum[0];
1894
1663
  }
1895
-
1896
1664
  if (CONST_KEY in schema) {
1897
1665
  return schema.const;
1898
1666
  }
1899
-
1900
1667
  throw new Error("schema cannot be inferred as a constant");
1901
1668
  }
1902
1669
 
@@ -1908,16 +1675,13 @@
1908
1675
  * @param schema - The schema from which to extract the options list
1909
1676
  * @returns - The list of options from the schema
1910
1677
  */
1911
-
1912
1678
  function optionsList(schema) {
1913
1679
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
1914
1680
  // Cast the type to include enumNames so the feature still works.
1915
1681
  const schemaWithEnumNames = schema;
1916
-
1917
1682
  if (schemaWithEnumNames.enumNames && "development" !== "production") {
1918
1683
  console.warn("The enumNames property is deprecated and may be removed in a future major release.");
1919
1684
  }
1920
-
1921
1685
  if (schema.enum) {
1922
1686
  return schema.enum.map((value, i) => {
1923
1687
  const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
@@ -1927,7 +1691,6 @@
1927
1691
  };
1928
1692
  });
1929
1693
  }
1930
-
1931
1694
  const altSchemas = schema.oneOf || schema.anyOf;
1932
1695
  return altSchemas && altSchemas.map(aSchemaDef => {
1933
1696
  const aSchema = aSchemaDef;
@@ -1955,32 +1718,25 @@
1955
1718
  if (!Array.isArray(order)) {
1956
1719
  return properties;
1957
1720
  }
1958
-
1959
1721
  const arrayToHash = arr => arr.reduce((prev, curr) => {
1960
1722
  prev[curr] = true;
1961
1723
  return prev;
1962
1724
  }, {});
1963
-
1964
- const errorPropList = arr => arr.length > 1 ? "properties '" + arr.join("', '") + "'" : "property '" + arr[0] + "'";
1965
-
1725
+ const errorPropList = arr => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
1966
1726
  const propertyHash = arrayToHash(properties);
1967
1727
  const orderFiltered = order.filter(prop => prop === "*" || propertyHash[prop]);
1968
1728
  const orderHash = arrayToHash(orderFiltered);
1969
1729
  const rest = properties.filter(prop => !orderHash[prop]);
1970
1730
  const restIndex = orderFiltered.indexOf("*");
1971
-
1972
1731
  if (restIndex === -1) {
1973
1732
  if (rest.length) {
1974
- throw new Error("uiSchema order list does not contain " + errorPropList(rest));
1733
+ throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
1975
1734
  }
1976
-
1977
1735
  return orderFiltered;
1978
1736
  }
1979
-
1980
1737
  if (restIndex !== orderFiltered.lastIndexOf("*")) {
1981
1738
  throw new Error("uiSchema order list contains more than one wildcard item");
1982
1739
  }
1983
-
1984
1740
  const complete = [...orderFiltered];
1985
1741
  complete.splice(restIndex, 1, ...rest);
1986
1742
  return complete;
@@ -1994,11 +1750,9 @@
1994
1750
  */
1995
1751
  function pad(num, width) {
1996
1752
  let s = String(num);
1997
-
1998
1753
  while (s.length < width) {
1999
1754
  s = "0" + s;
2000
1755
  }
2001
-
2002
1756
  return s;
2003
1757
  }
2004
1758
 
@@ -2013,7 +1767,6 @@
2013
1767
  if (includeTime === void 0) {
2014
1768
  includeTime = true;
2015
1769
  }
2016
-
2017
1770
  if (!dateString) {
2018
1771
  return {
2019
1772
  year: -1,
@@ -2024,13 +1777,10 @@
2024
1777
  second: includeTime ? -1 : 0
2025
1778
  };
2026
1779
  }
2027
-
2028
1780
  const date = new Date(dateString);
2029
-
2030
1781
  if (Number.isNaN(date.getTime())) {
2031
1782
  throw new Error("Unable to parse date " + dateString);
2032
1783
  }
2033
-
2034
1784
  return {
2035
1785
  year: date.getUTCFullYear(),
2036
1786
  month: date.getUTCMonth() + 1,
@@ -2051,42 +1801,34 @@
2051
1801
  * @param [options] - The UIOptionsType from which to potentially extract the emptyValue
2052
1802
  * @returns - The `value` converted to the proper type
2053
1803
  */
2054
-
2055
1804
  function processSelectValue(schema, value, options) {
2056
1805
  const {
2057
1806
  enum: schemaEnum,
2058
1807
  type,
2059
1808
  items
2060
1809
  } = schema;
2061
-
2062
1810
  if (value === "") {
2063
1811
  return options && options.emptyValue !== undefined ? options.emptyValue : undefined;
2064
1812
  }
2065
-
2066
1813
  if (type === "array" && items && nums.has(get__default["default"](items, "type"))) {
2067
1814
  return value.map(asNumber);
2068
1815
  }
2069
-
2070
1816
  if (type === "boolean") {
2071
1817
  return value === "true";
2072
1818
  }
2073
-
2074
1819
  if (nums.has(type)) {
2075
1820
  return asNumber(value);
2076
- } // If type is undefined, but an enum is present, try and infer the type from
1821
+ }
1822
+ // If type is undefined, but an enum is present, try and infer the type from
2077
1823
  // the enum values
2078
-
2079
-
2080
1824
  if (Array.isArray(schemaEnum)) {
2081
1825
  if (schemaEnum.every(x => nums.has(guessType(x)))) {
2082
1826
  return asNumber(value);
2083
1827
  }
2084
-
2085
1828
  if (schemaEnum.every(x => guessType(x) === "boolean")) {
2086
1829
  return value === "true";
2087
1830
  }
2088
1831
  }
2089
-
2090
1832
  return value;
2091
1833
  }
2092
1834
 
@@ -2103,30 +1845,24 @@
2103
1845
  // Check if const is a truthy value
2104
1846
  if (schema.const) {
2105
1847
  return true;
2106
- } // Check if an enum has a single value of true
2107
-
2108
-
1848
+ }
1849
+ // Check if an enum has a single value of true
2109
1850
  if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
2110
1851
  return true;
2111
- } // If anyOf has a single value, evaluate the subschema
2112
-
2113
-
1852
+ }
1853
+ // If anyOf has a single value, evaluate the subschema
2114
1854
  if (schema.anyOf && schema.anyOf.length === 1) {
2115
1855
  return schemaRequiresTrueValue(schema.anyOf[0]);
2116
- } // If oneOf has a single value, evaluate the subschema
2117
-
2118
-
1856
+ }
1857
+ // If oneOf has a single value, evaluate the subschema
2119
1858
  if (schema.oneOf && schema.oneOf.length === 1) {
2120
1859
  return schemaRequiresTrueValue(schema.oneOf[0]);
2121
- } // Evaluate each subschema in allOf, to see if one of them requires a true value
2122
-
2123
-
1860
+ }
1861
+ // Evaluate each subschema in allOf, to see if one of them requires a true value
2124
1862
  if (schema.allOf) {
2125
1863
  const schemaSome = subSchema => schemaRequiresTrueValue(subSchema);
2126
-
2127
1864
  return schema.allOf.some(schemaSome);
2128
1865
  }
2129
-
2130
1866
  return false;
2131
1867
  }
2132
1868
 
@@ -2138,7 +1874,6 @@
2138
1874
  * @param nextState - The next set of state against which to check
2139
1875
  * @returns - True if the component should be re-rendered, false otherwise
2140
1876
  */
2141
-
2142
1877
  function shouldRender(component, nextProps, nextState) {
2143
1878
  const {
2144
1879
  props,
@@ -2158,7 +1893,6 @@
2158
1893
  if (time === void 0) {
2159
1894
  time = true;
2160
1895
  }
2161
-
2162
1896
  const {
2163
1897
  year,
2164
1898
  month,
@@ -2177,17 +1911,15 @@
2177
1911
  * @param jsonDate - A UTC date string
2178
1912
  * @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format
2179
1913
  */
2180
-
2181
1914
  function utcToLocal(jsonDate) {
2182
1915
  if (!jsonDate) {
2183
1916
  return "";
2184
- } // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'
1917
+ }
1918
+ // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'
2185
1919
  // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)
2186
1920
  // > should be a _valid local date and time string_ (not GMT)
2187
1921
  // Note - date constructor passed local ISO-8601 does not correctly
2188
1922
  // change time to UTC in node pre-8
2189
-
2190
-
2191
1923
  const date = new Date(jsonDate);
2192
1924
  const yyyy = pad(date.getFullYear(), 4);
2193
1925
  const MM = pad(date.getMonth() + 1, 2);
@@ -2196,7 +1928,7 @@
2196
1928
  const mm = pad(date.getMinutes(), 2);
2197
1929
  const ss = pad(date.getSeconds(), 2);
2198
1930
  const SSS = pad(date.getMilliseconds(), 3);
2199
- return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
1931
+ return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;
2200
1932
  }
2201
1933
 
2202
1934
  exports.ADDITIONAL_PROPERTIES_KEY = ADDITIONAL_PROPERTIES_KEY;