@rjsf/utils 5.0.0-beta.14 → 5.0.0-beta.16

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.esm.js CHANGED
@@ -6,6 +6,7 @@ import omit from 'lodash-es/omit';
6
6
  import set from 'lodash-es/set';
7
7
  import mergeAllOf from 'json-schema-merge-allof';
8
8
  import union from 'lodash-es/union';
9
+ import cloneDeep from 'lodash-es/cloneDeep';
9
10
  import React from 'react';
10
11
  import ReactIs from 'react-is';
11
12
 
@@ -19,6 +20,9 @@ function isObject(thing) {
19
20
  if (typeof File !== "undefined" && thing instanceof File) {
20
21
  return false;
21
22
  }
23
+ if (typeof Date !== "undefined" && thing instanceof Date) {
24
+ return false;
25
+ }
22
26
  return typeof thing === "object" && thing !== null && !Array.isArray(thing);
23
27
  }
24
28
 
@@ -66,38 +70,85 @@ function asNumber(value) {
66
70
  // specific precision or number of significant digits)
67
71
  return value;
68
72
  }
69
- const n = Number(value);
70
- const valid = typeof n === "number" && !Number.isNaN(n);
73
+ var n = Number(value);
74
+ var valid = typeof n === "number" && !Number.isNaN(n);
71
75
  return valid ? n : value;
72
76
  }
73
77
 
78
+ function _defineProperties(target, props) {
79
+ for (var i = 0; i < props.length; i++) {
80
+ var descriptor = props[i];
81
+ descriptor.enumerable = descriptor.enumerable || false;
82
+ descriptor.configurable = true;
83
+ if ("value" in descriptor) descriptor.writable = true;
84
+ Object.defineProperty(target, descriptor.key, descriptor);
85
+ }
86
+ }
87
+ function _createClass(Constructor, protoProps, staticProps) {
88
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
89
+ if (staticProps) _defineProperties(Constructor, staticProps);
90
+ Object.defineProperty(Constructor, "prototype", {
91
+ writable: false
92
+ });
93
+ return Constructor;
94
+ }
95
+ function _extends() {
96
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
97
+ for (var i = 1; i < arguments.length; i++) {
98
+ var source = arguments[i];
99
+ for (var key in source) {
100
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
101
+ target[key] = source[key];
102
+ }
103
+ }
104
+ }
105
+ return target;
106
+ };
107
+ return _extends.apply(this, arguments);
108
+ }
109
+ function _objectDestructuringEmpty(obj) {
110
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
111
+ }
112
+ function _objectWithoutPropertiesLoose(source, excluded) {
113
+ if (source == null) return {};
114
+ var target = {};
115
+ var sourceKeys = Object.keys(source);
116
+ var key, i;
117
+ for (i = 0; i < sourceKeys.length; i++) {
118
+ key = sourceKeys[i];
119
+ if (excluded.indexOf(key) >= 0) continue;
120
+ target[key] = source[key];
121
+ }
122
+ return target;
123
+ }
124
+
74
125
  /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
75
126
  * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
76
127
  * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
77
128
  * utility.
78
129
  */
79
- const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
80
- const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
81
- const ALL_OF_KEY = "allOf";
82
- const ANY_OF_KEY = "anyOf";
83
- const CONST_KEY = "const";
84
- const DEFAULT_KEY = "default";
85
- const DEFINITIONS_KEY = "definitions";
86
- const DEPENDENCIES_KEY = "dependencies";
87
- const ENUM_KEY = "enum";
88
- const ERRORS_KEY = "__errors";
89
- const ID_KEY = "$id";
90
- const ITEMS_KEY = "items";
91
- const NAME_KEY = "$name";
92
- const ONE_OF_KEY = "oneOf";
93
- const PROPERTIES_KEY = "properties";
94
- const REQUIRED_KEY = "required";
95
- const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
96
- const REF_KEY = "$ref";
97
- const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
98
- const UI_FIELD_KEY = "ui:field";
99
- const UI_WIDGET_KEY = "ui:widget";
100
- const UI_OPTIONS_KEY = "ui:options";
130
+ var ADDITIONAL_PROPERTY_FLAG = "__additional_property";
131
+ var ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
132
+ var ALL_OF_KEY = "allOf";
133
+ var ANY_OF_KEY = "anyOf";
134
+ var CONST_KEY = "const";
135
+ var DEFAULT_KEY = "default";
136
+ var DEFINITIONS_KEY = "definitions";
137
+ var DEPENDENCIES_KEY = "dependencies";
138
+ var ENUM_KEY = "enum";
139
+ var ERRORS_KEY = "__errors";
140
+ var ID_KEY = "$id";
141
+ var ITEMS_KEY = "items";
142
+ var NAME_KEY = "$name";
143
+ var ONE_OF_KEY = "oneOf";
144
+ var PROPERTIES_KEY = "properties";
145
+ var REQUIRED_KEY = "required";
146
+ var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
147
+ var REF_KEY = "$ref";
148
+ var RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
149
+ var UI_FIELD_KEY = "ui:field";
150
+ var UI_WIDGET_KEY = "ui:widget";
151
+ var UI_OPTIONS_KEY = "ui:options";
101
152
 
102
153
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
103
154
  * stripped off.
@@ -109,22 +160,19 @@ function getUiOptions(uiSchema) {
109
160
  if (uiSchema === void 0) {
110
161
  uiSchema = {};
111
162
  }
112
- return Object.keys(uiSchema).filter(key => key.indexOf("ui:") === 0).reduce((options, key) => {
113
- const value = uiSchema[key];
163
+ return Object.keys(uiSchema).filter(function (key) {
164
+ return key.indexOf("ui:") === 0;
165
+ }).reduce(function (options, key) {
166
+ var _extends2;
167
+ var value = uiSchema[key];
114
168
  if (key === UI_WIDGET_KEY && isObject(value)) {
115
169
  console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
116
170
  return options;
117
171
  }
118
172
  if (key === UI_OPTIONS_KEY && isObject(value)) {
119
- return {
120
- ...options,
121
- ...value
122
- };
173
+ return _extends({}, options, value);
123
174
  }
124
- return {
125
- ...options,
126
- [key.substring(3)]: value
127
- };
175
+ return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
128
176
  }, {});
129
177
  }
130
178
 
@@ -144,9 +192,9 @@ function canExpand(schema, uiSchema, formData) {
144
192
  if (!schema.additionalProperties) {
145
193
  return false;
146
194
  }
147
- const {
148
- expandable = true
149
- } = getUiOptions(uiSchema);
195
+ var _getUiOptions = getUiOptions(uiSchema),
196
+ _getUiOptions$expanda = _getUiOptions.expandable,
197
+ expandable = _getUiOptions$expanda === void 0 ? true : _getUiOptions$expanda;
150
198
  if (expandable === false) {
151
199
  return expandable;
152
200
  }
@@ -166,7 +214,7 @@ function canExpand(schema, uiSchema, formData) {
166
214
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
167
215
  */
168
216
  function deepEquals(a, b) {
169
- return isEqualWith(a, b, (obj, other) => {
217
+ return isEqualWith(a, b, function (obj, other) {
170
218
  if (typeof obj === "function" && typeof other === "function") {
171
219
  // Assume all functions are equivalent
172
220
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
@@ -185,8 +233,8 @@ function deepEquals(a, b) {
185
233
  * value from `object[key]`
186
234
  */
187
235
  function splitKeyElementFromObject(key, object) {
188
- const value = object[key];
189
- const remaining = omit(object, [key]);
236
+ var value = object[key];
237
+ var remaining = omit(object, [key]);
190
238
  return [remaining, value];
191
239
  }
192
240
  /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
@@ -202,25 +250,24 @@ function findSchemaDefinition($ref, rootSchema) {
202
250
  if (rootSchema === void 0) {
203
251
  rootSchema = {};
204
252
  }
205
- let ref = $ref || "";
253
+ var ref = $ref || "";
206
254
  if (ref.startsWith("#")) {
207
255
  // Decode URI fragment representation.
208
256
  ref = decodeURIComponent(ref.substring(1));
209
257
  } else {
210
- throw new Error(`Could not find a definition for ${$ref}.`);
258
+ throw new Error("Could not find a definition for " + $ref + ".");
211
259
  }
212
- const current = jsonpointer.get(rootSchema, ref);
260
+ var current = jsonpointer.get(rootSchema, ref);
213
261
  if (current === undefined) {
214
- throw new Error(`Could not find a definition for ${$ref}.`);
262
+ throw new Error("Could not find a definition for " + $ref + ".");
215
263
  }
216
264
  if (current[REF_KEY]) {
217
- const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
218
- const subSchema = findSchemaDefinition(theRef, rootSchema);
265
+ var _splitKeyElementFromO = splitKeyElementFromObject(REF_KEY, current),
266
+ remaining = _splitKeyElementFromO[0],
267
+ theRef = _splitKeyElementFromO[1];
268
+ var subSchema = findSchemaDefinition(theRef, rootSchema);
219
269
  if (Object.keys(remaining).length > 0) {
220
- return {
221
- ...remaining,
222
- ...subSchema
223
- };
270
+ return _extends({}, remaining, subSchema);
224
271
  }
225
272
  return subSchema;
226
273
  }
@@ -241,8 +288,8 @@ function getMatchingOption(validator, formData, options, rootSchema) {
241
288
  if (formData === undefined) {
242
289
  return 0;
243
290
  }
244
- for (let i = 0; i < options.length; i++) {
245
- const option = options[i];
291
+ for (var i = 0; i < options.length; i++) {
292
+ var option = options[i];
246
293
  // If the schema describes an object then we need to add slightly more
247
294
  // strict matching to the schema, because unless the schema uses the
248
295
  // "requires" keyword, an object will match the schema as long as it
@@ -253,18 +300,18 @@ function getMatchingOption(validator, formData, options, rootSchema) {
253
300
  if (option.properties) {
254
301
  // Create an "anyOf" schema that requires at least one of the keys in the
255
302
  // "properties" object
256
- const requiresAnyOf = {
257
- anyOf: Object.keys(option.properties).map(key => ({
258
- required: [key]
259
- }))
303
+ var requiresAnyOf = {
304
+ anyOf: Object.keys(option.properties).map(function (key) {
305
+ return {
306
+ required: [key]
307
+ };
308
+ })
260
309
  };
261
- let augmentedSchema;
310
+ var augmentedSchema = void 0;
262
311
  // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
263
312
  if (option.anyOf) {
264
313
  // Create a shallow clone of the option
265
- const {
266
- ...shallowClone
267
- } = option;
314
+ var shallowClone = _extends({}, (_objectDestructuringEmpty(option), option));
268
315
  if (!shallowClone.allOf) {
269
316
  shallowClone.allOf = [];
270
317
  } else {
@@ -330,20 +377,20 @@ function guessType(value) {
330
377
  * @returns - The type of the schema
331
378
  */
332
379
  function getSchemaType(schema) {
333
- let {
334
- type
335
- } = schema;
336
- if (!type && schema.const) {
337
- return guessType(schema.const);
380
+ var type = schema.type;
381
+ if (!type && schema["const"]) {
382
+ return guessType(schema["const"]);
338
383
  }
339
- if (!type && schema.enum) {
384
+ if (!type && schema["enum"]) {
340
385
  return "string";
341
386
  }
342
387
  if (!type && (schema.properties || schema.additionalProperties)) {
343
388
  return "object";
344
389
  }
345
390
  if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
346
- type = type.find(type => type !== "null");
391
+ type = type.find(function (type) {
392
+ return type !== "null";
393
+ });
347
394
  }
348
395
  return type;
349
396
  }
@@ -355,7 +402,9 @@ function getSchemaType(schema) {
355
402
  * @returns - True if there are fixed items in the schema, false otherwise
356
403
  */
357
404
  function isFixedItems(schema) {
358
- return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(item => isObject(item));
405
+ return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(function (item) {
406
+ return isObject(item);
407
+ });
359
408
  }
360
409
 
361
410
  /** Merges the `defaults` object of type `T` into the `formData` of type `T`
@@ -374,8 +423,8 @@ function isFixedItems(schema) {
374
423
  */
375
424
  function mergeDefaultsWithFormData(defaults, formData) {
376
425
  if (Array.isArray(formData)) {
377
- const defaultsArray = Array.isArray(defaults) ? defaults : [];
378
- const mapped = formData.map((value, idx) => {
426
+ var defaultsArray = Array.isArray(defaults) ? defaults : [];
427
+ var mapped = formData.map(function (value, idx) {
379
428
  if (defaultsArray[idx]) {
380
429
  return mergeDefaultsWithFormData(defaultsArray[idx], value);
381
430
  }
@@ -384,8 +433,8 @@ function mergeDefaultsWithFormData(defaults, formData) {
384
433
  return mapped;
385
434
  }
386
435
  if (isObject(formData)) {
387
- const acc = Object.assign({}, defaults); // Prevent mutation of source object.
388
- return Object.keys(formData).reduce((acc, key) => {
436
+ var acc = Object.assign({}, defaults); // Prevent mutation of source object.
437
+ return Object.keys(formData).reduce(function (acc, key) {
389
438
  acc[key] = mergeDefaultsWithFormData(defaults ? get(defaults, key) : {}, get(formData, key));
390
439
  return acc;
391
440
  }, acc);
@@ -406,15 +455,15 @@ function mergeObjects(obj1, obj2, concatArrays) {
406
455
  if (concatArrays === void 0) {
407
456
  concatArrays = false;
408
457
  }
409
- return Object.keys(obj2).reduce((acc, key) => {
410
- const left = obj1 ? obj1[key] : {},
458
+ return Object.keys(obj2).reduce(function (acc, key) {
459
+ var left = obj1 ? obj1[key] : {},
411
460
  right = obj2[key];
412
461
  if (obj1 && key in obj1 && isObject(right)) {
413
462
  acc[key] = mergeObjects(left, right, concatArrays);
414
463
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
415
- let toMerge = right;
464
+ var toMerge = right;
416
465
  if (concatArrays === "preventDuplicates") {
417
- toMerge = right.reduce((result, value) => {
466
+ toMerge = right.reduce(function (result, value) {
418
467
  if (!left.includes(value)) {
419
468
  result.push(value);
420
469
  }
@@ -436,7 +485,7 @@ function mergeObjects(obj1, obj2, concatArrays) {
436
485
  * @returns - True if the `schema` has a single constant value, false otherwise
437
486
  */
438
487
  function isConstant(schema) {
439
- return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
488
+ return Array.isArray(schema["enum"]) && schema["enum"].length === 1 || CONST_KEY in schema;
440
489
  }
441
490
 
442
491
  /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
@@ -448,9 +497,9 @@ function isConstant(schema) {
448
497
  * @returns - The merged schema object
449
498
  */
450
499
  function mergeSchemas(obj1, obj2) {
451
- const acc = Object.assign({}, obj1); // Prevent mutation of source object.
452
- return Object.keys(obj2).reduce((acc, key) => {
453
- const left = obj1 ? obj1[key] : {},
500
+ var acc = Object.assign({}, obj1); // Prevent mutation of source object.
501
+ return Object.keys(obj2).reduce(function (acc, key) {
502
+ var left = obj1 ? obj1[key] : {},
454
503
  right = obj2[key];
455
504
  if (obj1 && key in obj1 && isObject(right)) {
456
505
  acc[key] = mergeSchemas(left, right);
@@ -464,6 +513,11 @@ function mergeSchemas(obj1, obj2) {
464
513
  }, acc);
465
514
  }
466
515
 
516
+ var _excluded$1 = ["if", "then", "else"],
517
+ _excluded2 = ["$ref"],
518
+ _excluded3 = ["allOf"],
519
+ _excluded4 = ["dependencies"],
520
+ _excluded5 = ["oneOf"];
467
521
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
468
522
  * with the rest of the schema
469
523
  *
@@ -474,13 +528,11 @@ function mergeSchemas(obj1, obj2) {
474
528
  * @returns - A schema with the appropriate condition resolved
475
529
  */
476
530
  function resolveCondition(validator, schema, rootSchema, formData) {
477
- const {
478
- if: expression,
479
- then,
480
- else: otherwise,
481
- ...resolvedSchemaLessConditional
482
- } = schema;
483
- const conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
531
+ var expression = schema["if"],
532
+ then = schema.then,
533
+ otherwise = schema["else"],
534
+ resolvedSchemaLessConditional = _objectWithoutPropertiesLoose(schema, _excluded$1);
535
+ var conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
484
536
  if (conditionalSchema && typeof conditionalSchema !== "boolean") {
485
537
  return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
486
538
  }
@@ -503,14 +555,15 @@ function resolveSchema(validator, schema, rootSchema, formData) {
503
555
  return resolveReference(validator, schema, rootSchema, formData);
504
556
  }
505
557
  if (DEPENDENCIES_KEY in schema) {
506
- const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
558
+ var resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
507
559
  return retrieveSchema(validator, resolvedSchema, rootSchema, formData);
508
560
  }
509
561
  if (ALL_OF_KEY in schema) {
510
- return {
511
- ...schema,
512
- allOf: schema.allOf.map(allOfSubschema => retrieveSchema(validator, allOfSubschema, rootSchema, formData))
513
- };
562
+ return _extends({}, schema, {
563
+ allOf: schema.allOf.map(function (allOfSubschema) {
564
+ return retrieveSchema(validator, allOfSubschema, rootSchema, formData);
565
+ })
566
+ });
514
567
  }
515
568
  // No $ref or dependencies attribute found, returning the original schema.
516
569
  return schema;
@@ -525,17 +578,11 @@ function resolveSchema(validator, schema, rootSchema, formData) {
525
578
  */
526
579
  function resolveReference(validator, schema, rootSchema, formData) {
527
580
  // Retrieve the referenced schema definition.
528
- const $refSchema = findSchemaDefinition(schema.$ref, rootSchema);
581
+ var $refSchema = findSchemaDefinition(schema.$ref, rootSchema);
529
582
  // Drop the $ref property of the source schema.
530
- const {
531
- $ref,
532
- ...localSchema
533
- } = schema;
583
+ var localSchema = _objectWithoutPropertiesLoose(schema, _excluded2);
534
584
  // Update referenced schema definition with local schema properties.
535
- return retrieveSchema(validator, {
536
- ...$refSchema,
537
- ...localSchema
538
- }, rootSchema, formData);
585
+ return retrieveSchema(validator, _extends({}, $refSchema, localSchema), rootSchema, formData);
539
586
  }
540
587
  /** Creates new 'properties' items for each key in the `formData`
541
588
  *
@@ -547,29 +594,24 @@ function resolveReference(validator, schema, rootSchema, formData) {
547
594
  */
548
595
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
549
596
  // Clone the schema so we don't ruin the consumer's original
550
- const schema = {
551
- ...theSchema,
552
- properties: {
553
- ...theSchema.properties
554
- }
555
- };
597
+ var schema = _extends({}, theSchema, {
598
+ properties: _extends({}, theSchema.properties)
599
+ });
556
600
  // make sure formData is an object
557
- const formData = aFormData && isObject(aFormData) ? aFormData : {};
558
- Object.keys(formData).forEach(key => {
601
+ var formData = aFormData && isObject(aFormData) ? aFormData : {};
602
+ Object.keys(formData).forEach(function (key) {
559
603
  if (key in schema.properties) {
560
604
  // No need to stub, our schema already has the property
561
605
  return;
562
606
  }
563
- let additionalProperties = {};
607
+ var additionalProperties = {};
564
608
  if (typeof schema.additionalProperties !== "boolean") {
565
609
  if (REF_KEY in schema.additionalProperties) {
566
610
  additionalProperties = retrieveSchema(validator, {
567
611
  $ref: get(schema.additionalProperties, [REF_KEY])
568
612
  }, rootSchema, formData);
569
613
  } else if ("type" in schema.additionalProperties) {
570
- additionalProperties = {
571
- ...schema.additionalProperties
572
- };
614
+ additionalProperties = _extends({}, schema.additionalProperties);
573
615
  } else {
574
616
  additionalProperties = {
575
617
  type: guessType(get(formData, [key]))
@@ -604,46 +646,24 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
604
646
  if (!isObject(schema)) {
605
647
  return {};
606
648
  }
607
- let resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
649
+ var resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
608
650
  if ("if" in schema) {
609
651
  return resolveCondition(validator, schema, rootSchema, rawFormData);
610
652
  }
611
- const formData = rawFormData || {};
612
- // For each level of the dependency, we need to recursively determine the appropriate resolved schema given the current state of formData.
613
- // Otherwise, nested allOf subschemas will not be correctly displayed.
614
- if (resolvedSchema.properties) {
615
- const properties = {};
616
- Object.entries(resolvedSchema.properties).forEach(entries => {
617
- const propName = entries[0];
618
- const propSchema = entries[1];
619
- const rawPropData = formData[propName];
620
- const propData = isObject(rawPropData) ? rawPropData : {};
621
- const resolvedPropSchema = retrieveSchema(validator, propSchema, rootSchema, propData);
622
- properties[propName] = resolvedPropSchema;
623
- if (propSchema !== resolvedPropSchema && resolvedSchema.properties !== properties) {
624
- resolvedSchema = {
625
- ...resolvedSchema,
626
- properties
627
- };
628
- }
629
- });
630
- }
653
+ var formData = rawFormData || {};
631
654
  if (ALL_OF_KEY in schema) {
632
655
  try {
633
- resolvedSchema = mergeAllOf({
634
- ...resolvedSchema,
635
- allOf: resolvedSchema.allOf
656
+ resolvedSchema = mergeAllOf(resolvedSchema, {
657
+ deep: false
636
658
  });
637
659
  } catch (e) {
638
660
  console.warn("could not merge subschemas in allOf:\n" + e);
639
- const {
640
- allOf,
641
- ...resolvedSchemaWithoutAllOf
642
- } = resolvedSchema;
661
+ var _resolvedSchema = resolvedSchema,
662
+ resolvedSchemaWithoutAllOf = _objectWithoutPropertiesLoose(_resolvedSchema, _excluded3);
643
663
  return resolvedSchemaWithoutAllOf;
644
664
  }
645
665
  }
646
- const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
666
+ var hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
647
667
  if (hasAdditionalProperties) {
648
668
  return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, formData);
649
669
  }
@@ -659,11 +679,9 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
659
679
  */
660
680
  function resolveDependencies(validator, schema, rootSchema, formData) {
661
681
  // Drop the dependencies from the source schema.
662
- const {
663
- dependencies,
664
- ...remainingSchema
665
- } = schema;
666
- let resolvedSchema = remainingSchema;
682
+ var dependencies = schema.dependencies,
683
+ remainingSchema = _objectWithoutPropertiesLoose(schema, _excluded4);
684
+ var resolvedSchema = remainingSchema;
667
685
  if (Array.isArray(resolvedSchema.oneOf)) {
668
686
  resolvedSchema = resolvedSchema.oneOf[getMatchingOption(validator, formData, resolvedSchema.oneOf, rootSchema)];
669
687
  } else if (Array.isArray(resolvedSchema.anyOf)) {
@@ -681,9 +699,9 @@ function resolveDependencies(validator, schema, rootSchema, formData) {
681
699
  * @returns - The schema with the `dependencies` resolved into it
682
700
  */
683
701
  function processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData) {
684
- let schema = resolvedSchema;
702
+ var schema = resolvedSchema;
685
703
  // Process dependencies updating the local schema properties as appropriate.
686
- for (const dependencyKey in dependencies) {
704
+ for (var dependencyKey in dependencies) {
687
705
  // Skip this dependency if its trigger property is not present.
688
706
  if (get(formData, [dependencyKey]) === undefined) {
689
707
  continue;
@@ -692,7 +710,9 @@ function processDependencies(validator, dependencies, resolvedSchema, rootSchema
692
710
  if (schema.properties && !(dependencyKey in schema.properties)) {
693
711
  continue;
694
712
  }
695
- const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(dependencyKey, dependencies);
713
+ var _splitKeyElementFromO = splitKeyElementFromObject(dependencyKey, dependencies),
714
+ remainingDependencies = _splitKeyElementFromO[0],
715
+ dependencyValue = _splitKeyElementFromO[1];
696
716
  if (Array.isArray(dependencyValue)) {
697
717
  schema = withDependentProperties(schema, dependencyValue);
698
718
  } else if (isObject(dependencyValue)) {
@@ -712,11 +732,10 @@ function withDependentProperties(schema, additionallyRequired) {
712
732
  if (!additionallyRequired) {
713
733
  return schema;
714
734
  }
715
- const required = Array.isArray(schema.required) ? Array.from(new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
716
- return {
717
- ...schema,
735
+ var required = Array.isArray(schema.required) ? Array.from(new Set([].concat(schema.required, additionallyRequired))) : additionallyRequired;
736
+ return _extends({}, schema, {
718
737
  required: required
719
- };
738
+ });
720
739
  }
721
740
  /** Merges a dependent schema into the `schema` dealing with oneOfs and references
722
741
  *
@@ -729,17 +748,16 @@ function withDependentProperties(schema, additionallyRequired) {
729
748
  * @returns - The schema with the dependent schema resolved into it
730
749
  */
731
750
  function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData) {
732
- const {
733
- oneOf,
734
- ...dependentSchema
735
- } = retrieveSchema(validator, dependencyValue, rootSchema, formData);
751
+ var _retrieveSchema = retrieveSchema(validator, dependencyValue, rootSchema, formData),
752
+ oneOf = _retrieveSchema.oneOf,
753
+ dependentSchema = _objectWithoutPropertiesLoose(_retrieveSchema, _excluded5);
736
754
  schema = mergeSchemas(schema, dependentSchema);
737
755
  // Since it does not contain oneOf, we return the original schema.
738
756
  if (oneOf === undefined) {
739
757
  return schema;
740
758
  }
741
759
  // Resolve $refs inside oneOf.
742
- const resolvedOneOf = oneOf.map(subschema => {
760
+ var resolvedOneOf = oneOf.map(function (subschema) {
743
761
  if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
744
762
  return subschema;
745
763
  }
@@ -758,23 +776,19 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
758
776
  * @returns The schema with the best choice of oneOf schemas merged into
759
777
  */
760
778
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
761
- const validSubschemas = oneOf.filter(subschema => {
779
+ var validSubschemas = oneOf.filter(function (subschema) {
762
780
  if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
763
781
  return false;
764
782
  }
765
- const {
766
- [dependencyKey]: conditionPropertySchema
767
- } = subschema.properties;
783
+ var conditionPropertySchema = subschema.properties[dependencyKey];
768
784
  if (conditionPropertySchema) {
769
- const conditionSchema = {
785
+ var _properties;
786
+ var conditionSchema = {
770
787
  type: "object",
771
- properties: {
772
- [dependencyKey]: conditionPropertySchema
773
- }
788
+ properties: (_properties = {}, _properties[dependencyKey] = conditionPropertySchema, _properties)
774
789
  };
775
- const {
776
- errors
777
- } = validator.validateFormData(formData, conditionSchema);
790
+ var _validator$validateFo = validator.validateFormData(formData, conditionSchema),
791
+ errors = _validator$validateFo.errors;
778
792
  return errors.length === 0;
779
793
  }
780
794
  return false;
@@ -783,12 +797,12 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
783
797
  console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
784
798
  return schema;
785
799
  }
786
- const subschema = validSubschemas[0];
787
- const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
788
- const dependentSchema = {
789
- ...subschema,
800
+ var subschema = validSubschemas[0];
801
+ var _splitKeyElementFromO2 = splitKeyElementFromObject(dependencyKey, subschema.properties),
802
+ dependentSubschema = _splitKeyElementFromO2[0];
803
+ var dependentSchema = _extends({}, subschema, {
790
804
  properties: dependentSubschema
791
- };
805
+ });
792
806
  return mergeSchemas(schema, retrieveSchema(validator, dependentSchema, rootSchema, formData));
793
807
  }
794
808
 
@@ -803,13 +817,15 @@ function isSelect(validator, theSchema, rootSchema) {
803
817
  if (rootSchema === void 0) {
804
818
  rootSchema = {};
805
819
  }
806
- const schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
807
- const altSchemas = schema.oneOf || schema.anyOf;
808
- if (Array.isArray(schema.enum)) {
820
+ var schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
821
+ var altSchemas = schema.oneOf || schema.anyOf;
822
+ if (Array.isArray(schema["enum"])) {
809
823
  return true;
810
824
  }
811
825
  if (Array.isArray(altSchemas)) {
812
- return altSchemas.every(altSchemas => typeof altSchemas !== "boolean" && isConstant(altSchemas));
826
+ return altSchemas.every(function (altSchemas) {
827
+ return typeof altSchemas !== "boolean" && isConstant(altSchemas);
828
+ });
813
829
  }
814
830
  return false;
815
831
  }
@@ -860,7 +876,7 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
860
876
  }
861
877
  if (idx >= 0) {
862
878
  if (Array.isArray(schema.items) && idx < schema.items.length) {
863
- const item = schema.items[idx];
879
+ var item = schema.items[idx];
864
880
  if (typeof item !== "boolean") {
865
881
  return item;
866
882
  }
@@ -886,31 +902,34 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
886
902
  * object properties.
887
903
  * @returns - The resulting `formData` with all the defaults provided
888
904
  */
889
- function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
905
+ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
890
906
  if (rootSchema === void 0) {
891
907
  rootSchema = {};
892
908
  }
893
909
  if (includeUndefinedValues === void 0) {
894
910
  includeUndefinedValues = false;
895
911
  }
896
- const formData = isObject(rawFormData) ? rawFormData : {};
912
+ var formData = isObject(rawFormData) ? rawFormData : {};
913
+ var schema = isObject(rawSchema) ? rawSchema : {};
897
914
  // Compute the defaults recursively: give highest priority to deepest nodes.
898
- let defaults = parentDefaults;
899
- if (isObject(defaults) && isObject(schema.default)) {
915
+ var defaults = parentDefaults;
916
+ if (isObject(defaults) && isObject(schema["default"])) {
900
917
  // For object defaults, only override parent defaults that are defined in
901
918
  // schema.default.
902
- defaults = mergeObjects(defaults, schema.default);
919
+ defaults = mergeObjects(defaults, schema["default"]);
903
920
  } else if (DEFAULT_KEY in schema) {
904
- defaults = schema.default;
921
+ defaults = schema["default"];
905
922
  } else if (REF_KEY in schema) {
906
923
  // Use referenced schema defaults for this node.
907
- const refSchema = findSchemaDefinition(schema[REF_KEY], rootSchema);
924
+ var refSchema = findSchemaDefinition(schema[REF_KEY], rootSchema);
908
925
  return computeDefaults(validator, refSchema, defaults, rootSchema, formData, includeUndefinedValues);
909
926
  } else if (DEPENDENCIES_KEY in schema) {
910
- const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
927
+ var resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
911
928
  return computeDefaults(validator, resolvedSchema, defaults, rootSchema, formData, includeUndefinedValues);
912
929
  } else if (isFixedItems(schema)) {
913
- defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues));
930
+ defaults = schema.items.map(function (itemSchema, idx) {
931
+ return computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues);
932
+ });
914
933
  } else if (ONE_OF_KEY in schema) {
915
934
  schema = schema.oneOf[getMatchingOption(validator, isEmpty(formData) ? undefined : formData, schema.oneOf, rootSchema)];
916
935
  } else if (ANY_OF_KEY in schema) {
@@ -918,15 +937,15 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
918
937
  }
919
938
  // Not defaults defined for this node, fallback to generic typed ones.
920
939
  if (typeof defaults === "undefined") {
921
- defaults = schema.default;
940
+ defaults = schema["default"];
922
941
  }
923
942
  switch (getSchemaType(schema)) {
924
943
  // We need to recur for object schema inner default values.
925
944
  case "object":
926
- return Object.keys(schema.properties || {}).reduce((acc, key) => {
945
+ return Object.keys(schema.properties || {}).reduce(function (acc, key) {
927
946
  // Compute the defaults for this node, with the parent defaults we might
928
947
  // have from a previous run: defaults[key].
929
- const computedDefault = computeDefaults(validator, get(schema, [PROPERTIES_KEY, key]), get(defaults, [key]), rootSchema, get(formData, [key]), includeUndefinedValues === "excludeObjectChildren" ? false : includeUndefinedValues);
948
+ var computedDefault = computeDefaults(validator, get(schema, [PROPERTIES_KEY, key]), get(defaults, [key]), rootSchema, get(formData, [key]), includeUndefinedValues === "excludeObjectChildren" ? false : includeUndefinedValues);
930
949
  if (includeUndefinedValues) {
931
950
  acc[key] = computedDefault;
932
951
  } else if (isObject(computedDefault)) {
@@ -943,27 +962,27 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
943
962
  case "array":
944
963
  // Inject defaults into existing array defaults
945
964
  if (Array.isArray(defaults)) {
946
- defaults = defaults.map((item, idx) => {
947
- const schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
965
+ defaults = defaults.map(function (item, idx) {
966
+ var schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
948
967
  return computeDefaults(validator, schemaItem, item, rootSchema);
949
968
  });
950
969
  }
951
970
  // Deeply inject defaults into already existing form data
952
971
  if (Array.isArray(rawFormData)) {
953
- const schemaItem = getInnerSchemaForArrayItem(schema);
954
- defaults = rawFormData.map((item, idx) => {
972
+ var schemaItem = getInnerSchemaForArrayItem(schema);
973
+ defaults = rawFormData.map(function (item, idx) {
955
974
  return computeDefaults(validator, schemaItem, get(defaults, [idx]), rootSchema, item);
956
975
  });
957
976
  }
958
977
  if (schema.minItems) {
959
978
  if (!isMultiSelect(validator, schema, rootSchema)) {
960
- const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
979
+ var defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
961
980
  if (schema.minItems > defaultsLength) {
962
- const defaultEntries = defaults || [];
981
+ var defaultEntries = defaults || [];
963
982
  // populate the array with the defaults
964
- const fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
965
- const fillerDefault = fillerSchema.default;
966
- const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema));
983
+ var fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
984
+ var fillerDefault = fillerSchema["default"];
985
+ var fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema));
967
986
  // then fill up the rest with either the item default or empty, up to minItems
968
987
  return defaultEntries.concat(fillerEntries);
969
988
  }
@@ -992,8 +1011,8 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
992
1011
  if (!isObject(theSchema)) {
993
1012
  throw new Error("Invalid schema: " + theSchema);
994
1013
  }
995
- const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
996
- const defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1014
+ var schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1015
+ var defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
997
1016
  if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
998
1017
  // No form data? Use schema defaults.
999
1018
  return defaults;
@@ -1039,7 +1058,7 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1039
1058
  return true;
1040
1059
  }
1041
1060
  if (schema.items) {
1042
- const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1061
+ var itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1043
1062
  return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1044
1063
  }
1045
1064
  return false;
@@ -1058,12 +1077,11 @@ function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1058
1077
  if (uiSchema === void 0) {
1059
1078
  uiSchema = {};
1060
1079
  }
1061
- const uiOptions = getUiOptions(uiSchema);
1062
- const {
1063
- label = true
1064
- } = uiOptions;
1065
- let displayLabel = !!label;
1066
- const schemaType = getSchemaType(schema);
1080
+ var uiOptions = getUiOptions(uiSchema);
1081
+ var _uiOptions$label = uiOptions.label,
1082
+ label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1083
+ var displayLabel = !!label;
1084
+ var schemaType = getSchemaType(schema);
1067
1085
  if (schemaType === "array") {
1068
1086
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1069
1087
  }
@@ -1093,19 +1111,17 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1093
1111
  if (!additionalErrorSchema) {
1094
1112
  return validationData;
1095
1113
  }
1096
- const {
1097
- errors: oldErrors,
1098
- errorSchema: oldErrorSchema
1099
- } = validationData;
1100
- let errors = validator.toErrorList(additionalErrorSchema);
1101
- let errorSchema = additionalErrorSchema;
1114
+ var oldErrors = validationData.errors,
1115
+ oldErrorSchema = validationData.errorSchema;
1116
+ var errors = validator.toErrorList(additionalErrorSchema);
1117
+ var errorSchema = additionalErrorSchema;
1102
1118
  if (!isEmpty(oldErrorSchema)) {
1103
1119
  errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1104
- errors = [...oldErrors].concat(errors);
1120
+ errors = [].concat(oldErrors).concat(errors);
1105
1121
  }
1106
1122
  return {
1107
- errorSchema,
1108
- errors
1123
+ errorSchema: errorSchema,
1124
+ errors: errors
1109
1125
  };
1110
1126
  }
1111
1127
 
@@ -1128,20 +1144,20 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1128
1144
  idSeparator = "_";
1129
1145
  }
1130
1146
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1131
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1147
+ var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1132
1148
  return toIdSchema(validator, _schema, id, rootSchema, formData, idPrefix, idSeparator);
1133
1149
  }
1134
1150
  if (ITEMS_KEY in schema && !get(schema, [ITEMS_KEY, REF_KEY])) {
1135
1151
  return toIdSchema(validator, get(schema, ITEMS_KEY), id, rootSchema, formData, idPrefix, idSeparator);
1136
1152
  }
1137
- const $id = id || idPrefix;
1138
- const idSchema = {
1139
- $id
1153
+ var $id = id || idPrefix;
1154
+ var idSchema = {
1155
+ $id: $id
1140
1156
  };
1141
1157
  if (schema.type === "object" && PROPERTIES_KEY in schema) {
1142
- for (const name in schema.properties) {
1143
- const field = get(schema, [PROPERTIES_KEY, name]);
1144
- const fieldId = idSchema[ID_KEY] + idSeparator + name;
1158
+ for (var name in schema.properties) {
1159
+ var field = get(schema, [PROPERTIES_KEY, name]);
1160
+ var fieldId = idSchema[ID_KEY] + idSeparator + name;
1145
1161
  idSchema[name] = toIdSchema(validator, isObject(field) ? field : {}, fieldId, rootSchema,
1146
1162
  // It's possible that formData is not an object -- this can happen if an
1147
1163
  // array item has just been added, but not populated with data yet
@@ -1161,27 +1177,26 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1161
1177
  * @returns - The `PathSchema` object for the `schema`
1162
1178
  */
1163
1179
  function toPathSchema(validator, schema, name, rootSchema, formData) {
1180
+ var _pathSchema;
1164
1181
  if (name === void 0) {
1165
1182
  name = "";
1166
1183
  }
1167
1184
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1168
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1185
+ var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1169
1186
  return toPathSchema(validator, _schema, name, rootSchema, formData);
1170
1187
  }
1171
- const pathSchema = {
1172
- [NAME_KEY]: name.replace(/^\./, "")
1173
- };
1174
- if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] === true) {
1188
+ var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ""), _pathSchema);
1189
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
1175
1190
  set(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1176
1191
  }
1177
1192
  if (ITEMS_KEY in schema && Array.isArray(formData)) {
1178
- formData.forEach((element, i) => {
1179
- pathSchema[i] = toPathSchema(validator, schema.items, `${name}.${i}`, rootSchema, element);
1193
+ formData.forEach(function (element, i) {
1194
+ pathSchema[i] = toPathSchema(validator, schema.items, name + "." + i, rootSchema, element);
1180
1195
  });
1181
1196
  } else if (PROPERTIES_KEY in schema) {
1182
- for (const property in schema.properties) {
1183
- const field = get(schema, [PROPERTIES_KEY, property]);
1184
- pathSchema[property] = toPathSchema(validator, field, `${name}.${property}`, rootSchema,
1197
+ for (var property in schema.properties) {
1198
+ var field = get(schema, [PROPERTIES_KEY, property]);
1199
+ pathSchema[property] = toPathSchema(validator, field, name + "." + property, rootSchema,
1185
1200
  // It's possible that formData is not an object -- this can happen if an
1186
1201
  // array item has just been added, but not populated with data yet
1187
1202
  get(formData, [property]));
@@ -1195,13 +1210,13 @@ function toPathSchema(validator, schema, name, rootSchema, formData) {
1195
1210
  * and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified set of APIs to the
1196
1211
  * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
1197
1212
  */
1198
- class SchemaUtils {
1213
+ var SchemaUtils = /*#__PURE__*/function () {
1199
1214
  /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
1200
1215
  *
1201
1216
  * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1202
1217
  * @param rootSchema - The root schema that will be forwarded to all the APIs
1203
1218
  */
1204
- constructor(validator, rootSchema) {
1219
+ function SchemaUtils(validator, rootSchema) {
1205
1220
  this.rootSchema = void 0;
1206
1221
  this.validator = void 0;
1207
1222
  this.rootSchema = rootSchema;
@@ -1211,7 +1226,8 @@ class SchemaUtils {
1211
1226
  *
1212
1227
  * @returns - The `ValidatorType`
1213
1228
  */
1214
- getValidator() {
1229
+ var _proto = SchemaUtils.prototype;
1230
+ _proto.getValidator = function getValidator() {
1215
1231
  return this.validator;
1216
1232
  }
1217
1233
  /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
@@ -1221,8 +1237,8 @@ class SchemaUtils {
1221
1237
  * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
1222
1238
  * @param rootSchema - The root schema that will be compared against the current one
1223
1239
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
1224
- */
1225
- doesSchemaUtilsDiffer(validator, rootSchema) {
1240
+ */;
1241
+ _proto.doesSchemaUtilsDiffer = function doesSchemaUtilsDiffer(validator, rootSchema) {
1226
1242
  if (!validator || !rootSchema) {
1227
1243
  return false;
1228
1244
  }
@@ -1237,8 +1253,8 @@ class SchemaUtils {
1237
1253
  * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
1238
1254
  * object properties.
1239
1255
  * @returns - The resulting `formData` with all the defaults provided
1240
- */
1241
- getDefaultFormState(schema, formData, includeUndefinedValues) {
1256
+ */;
1257
+ _proto.getDefaultFormState = function getDefaultFormState$1(schema, formData, includeUndefinedValues) {
1242
1258
  if (includeUndefinedValues === void 0) {
1243
1259
  includeUndefinedValues = false;
1244
1260
  }
@@ -1250,8 +1266,8 @@ class SchemaUtils {
1250
1266
  * @param schema - The schema for which the display label flag is desired
1251
1267
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1252
1268
  * @returns - True if the label should be displayed or false if it should not
1253
- */
1254
- getDisplayLabel(schema, uiSchema) {
1269
+ */;
1270
+ _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
1255
1271
  return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1256
1272
  }
1257
1273
  /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
@@ -1259,8 +1275,8 @@ class SchemaUtils {
1259
1275
  * @param formData - The current formData, if any, onto which to provide any missing defaults
1260
1276
  * @param options - The list of options to find a matching options from
1261
1277
  * @returns - The index of the matched option or 0 if none is available
1262
- */
1263
- getMatchingOption(formData, options) {
1278
+ */;
1279
+ _proto.getMatchingOption = function getMatchingOption$1(formData, options) {
1264
1280
  return getMatchingOption(this.validator, formData, options, this.rootSchema);
1265
1281
  }
1266
1282
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
@@ -1268,24 +1284,24 @@ class SchemaUtils {
1268
1284
  * @param schema - The schema for which check for array of files flag is desired
1269
1285
  * @param [uiSchema] - The UI schema from which to check the widget
1270
1286
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1271
- */
1272
- isFilesArray(schema, uiSchema) {
1287
+ */;
1288
+ _proto.isFilesArray = function isFilesArray$1(schema, uiSchema) {
1273
1289
  return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1274
1290
  }
1275
1291
  /** Checks to see if the `schema` combination represents a multi-select
1276
1292
  *
1277
1293
  * @param schema - The schema for which check for a multi-select flag is desired
1278
1294
  * @returns - True if schema contains a multi-select, otherwise false
1279
- */
1280
- isMultiSelect(schema) {
1295
+ */;
1296
+ _proto.isMultiSelect = function isMultiSelect$1(schema) {
1281
1297
  return isMultiSelect(this.validator, schema, this.rootSchema);
1282
1298
  }
1283
1299
  /** Checks to see if the `schema` combination represents a select
1284
1300
  *
1285
1301
  * @param schema - The schema for which check for a select flag is desired
1286
1302
  * @returns - True if schema contains a select, otherwise false
1287
- */
1288
- isSelect(schema) {
1303
+ */;
1304
+ _proto.isSelect = function isSelect$1(schema) {
1289
1305
  return isSelect(this.validator, schema, this.rootSchema);
1290
1306
  }
1291
1307
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
@@ -1296,8 +1312,8 @@ class SchemaUtils {
1296
1312
  * @param validationData - The current `ValidationData` into which to merge the additional errors
1297
1313
  * @param [additionalErrorSchema] - The additional set of errors
1298
1314
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1299
- */
1300
- mergeValidationData(validationData, additionalErrorSchema) {
1315
+ */;
1316
+ _proto.mergeValidationData = function mergeValidationData$1(validationData, additionalErrorSchema) {
1301
1317
  return mergeValidationData(this.validator, validationData, additionalErrorSchema);
1302
1318
  }
1303
1319
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
@@ -1307,8 +1323,8 @@ class SchemaUtils {
1307
1323
  * @param schema - The schema for which retrieving a schema is desired
1308
1324
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1309
1325
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1310
- */
1311
- retrieveSchema(schema, rawFormData) {
1326
+ */;
1327
+ _proto.retrieveSchema = function retrieveSchema$1(schema, rawFormData) {
1312
1328
  return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
1313
1329
  }
1314
1330
  /** Generates an `IdSchema` object for the `schema`, recursively
@@ -1319,8 +1335,8 @@ class SchemaUtils {
1319
1335
  * @param [idPrefix='root'] - The prefix to use for the id
1320
1336
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1321
1337
  * @returns - The `IdSchema` object for the `schema`
1322
- */
1323
- toIdSchema(schema, id, formData, idPrefix, idSeparator) {
1338
+ */;
1339
+ _proto.toIdSchema = function toIdSchema$1(schema, id, formData, idPrefix, idSeparator) {
1324
1340
  if (idPrefix === void 0) {
1325
1341
  idPrefix = "root";
1326
1342
  }
@@ -1335,11 +1351,12 @@ class SchemaUtils {
1335
1351
  * @param [name] - The base name for the schema
1336
1352
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1337
1353
  * @returns - The `PathSchema` object for the `schema`
1338
- */
1339
- toPathSchema(schema, name, formData) {
1354
+ */;
1355
+ _proto.toPathSchema = function toPathSchema$1(schema, name, formData) {
1340
1356
  return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
1341
- }
1342
- }
1357
+ };
1358
+ return SchemaUtils;
1359
+ }();
1343
1360
  /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
1344
1361
  * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
1345
1362
  *
@@ -1359,17 +1376,17 @@ function createSchemaUtils(validator, rootSchema) {
1359
1376
  */
1360
1377
  function dataURItoBlob(dataURI) {
1361
1378
  // Split metadata from data
1362
- const splitted = dataURI.split(",");
1379
+ var splitted = dataURI.split(",");
1363
1380
  // Split params
1364
- const params = splitted[0].split(";");
1381
+ var params = splitted[0].split(";");
1365
1382
  // Get mime-type from params
1366
- const type = params[0].replace("data:", "");
1383
+ var type = params[0].replace("data:", "");
1367
1384
  // Filter the name property from params
1368
- const properties = params.filter(param => {
1385
+ var properties = params.filter(function (param) {
1369
1386
  return param.split("=")[0] === "name";
1370
1387
  });
1371
1388
  // Look for the name and use unknown if no name property.
1372
- let name;
1389
+ var name;
1373
1390
  if (properties.length !== 1) {
1374
1391
  name = "unknown";
1375
1392
  } else {
@@ -1378,21 +1395,126 @@ function dataURItoBlob(dataURI) {
1378
1395
  name = properties[0].split("=")[1];
1379
1396
  }
1380
1397
  // Built the Uint8Array Blob parameter from the base64 string.
1381
- const binary = atob(splitted[1]);
1382
- const array = [];
1383
- for (let i = 0; i < binary.length; i++) {
1398
+ var binary = atob(splitted[1]);
1399
+ var array = [];
1400
+ for (var i = 0; i < binary.length; i++) {
1384
1401
  array.push(binary.charCodeAt(i));
1385
1402
  }
1386
1403
  // Create the blob object
1387
- const blob = new window.Blob([new Uint8Array(array)], {
1388
- type
1404
+ var blob = new window.Blob([new Uint8Array(array)], {
1405
+ type: type
1389
1406
  });
1390
1407
  return {
1391
- blob,
1392
- name
1408
+ blob: blob,
1409
+ name: name
1393
1410
  };
1394
1411
  }
1395
1412
 
1413
+ /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
1414
+ * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
1415
+ * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
1416
+ * get the result and/or reset all the errors back to an initial set and start again.
1417
+ */
1418
+ var ErrorSchemaBuilder = /*#__PURE__*/function () {
1419
+ /** The error schema being built
1420
+ *
1421
+ * @private
1422
+ */
1423
+
1424
+ /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
1425
+ *
1426
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1427
+ */
1428
+ function ErrorSchemaBuilder(initialSchema) {
1429
+ this.errorSchema = {};
1430
+ this.resetAllErrors(initialSchema);
1431
+ }
1432
+ /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`
1433
+ */
1434
+ var _proto = ErrorSchemaBuilder.prototype;
1435
+ /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.
1436
+ *
1437
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1438
+ * @returns - The error block for the given `pathOfError` or the root if not provided
1439
+ * @private
1440
+ */
1441
+ _proto.getOrCreateErrorBlock = function getOrCreateErrorBlock(pathOfError) {
1442
+ var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
1443
+ var errorBlock = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;
1444
+ if (!errorBlock && pathOfError) {
1445
+ errorBlock = {};
1446
+ set(this.errorSchema, pathOfError, errorBlock);
1447
+ }
1448
+ return errorBlock;
1449
+ }
1450
+ /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.
1451
+ *
1452
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1453
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1454
+ */;
1455
+ _proto.resetAllErrors = function resetAllErrors(initialSchema) {
1456
+ this.errorSchema = initialSchema ? cloneDeep(initialSchema) : {};
1457
+ return this;
1458
+ }
1459
+ /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within
1460
+ * the schema described by the `pathOfError`. For more information about how to specify the path see the
1461
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1462
+ *
1463
+ * @param errorOrList - The error or list of errors to add into the `ErrorSchema`
1464
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1465
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1466
+ */;
1467
+ _proto.addErrors = function addErrors(errorOrList, pathOfError) {
1468
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1469
+ var errorsList = get(errorBlock, ERRORS_KEY);
1470
+ if (!Array.isArray(errorsList)) {
1471
+ errorsList = [];
1472
+ errorBlock[ERRORS_KEY] = errorsList;
1473
+ }
1474
+ if (Array.isArray(errorOrList)) {
1475
+ var _errorsList;
1476
+ (_errorsList = errorsList).push.apply(_errorsList, errorOrList);
1477
+ } else {
1478
+ errorsList.push(errorOrList);
1479
+ }
1480
+ return this;
1481
+ }
1482
+ /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location
1483
+ * within the schema described by the `pathOfError`. For more information about how to specify the path see the
1484
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1485
+ *
1486
+ * @param errorOrList - The error or list of errors to set into the `ErrorSchema`
1487
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
1488
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1489
+ */;
1490
+ _proto.setErrors = function setErrors(errorOrList, pathOfError) {
1491
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1492
+ // Effectively clone the array being given to prevent accidental outside manipulation of the given list
1493
+ var listToAdd = Array.isArray(errorOrList) ? [].concat(errorOrList) : [errorOrList];
1494
+ set(errorBlock, ERRORS_KEY, listToAdd);
1495
+ return this;
1496
+ }
1497
+ /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
1498
+ * the `pathOfError`. For more information about how to specify the path see the
1499
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1500
+ *
1501
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
1502
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1503
+ */;
1504
+ _proto.clearErrors = function clearErrors(pathOfError) {
1505
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1506
+ set(errorBlock, ERRORS_KEY, []);
1507
+ return this;
1508
+ };
1509
+ _createClass(ErrorSchemaBuilder, [{
1510
+ key: "ErrorSchema",
1511
+ get: function get() {
1512
+ return this.errorSchema;
1513
+ }
1514
+ }]);
1515
+ return ErrorSchemaBuilder;
1516
+ }();
1517
+
1396
1518
  /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
1397
1519
  * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
1398
1520
  *
@@ -1400,7 +1522,7 @@ function dataURItoBlob(dataURI) {
1400
1522
  * @returns - A range specification from the schema
1401
1523
  */
1402
1524
  function rangeSpec(schema) {
1403
- const spec = {};
1525
+ var spec = {};
1404
1526
  if (schema.multipleOf) {
1405
1527
  spec.step = schema.multipleOf;
1406
1528
  }
@@ -1428,10 +1550,9 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1428
1550
  if (autoDefaultStepAny === void 0) {
1429
1551
  autoDefaultStepAny = true;
1430
1552
  }
1431
- const inputProps = {
1432
- type: defaultType || "text",
1433
- ...rangeSpec(schema)
1434
- };
1553
+ var inputProps = _extends({
1554
+ type: defaultType || "text"
1555
+ }, rangeSpec(schema));
1435
1556
  // If options.inputType is set use that as the input type
1436
1557
  if (options.inputType) {
1437
1558
  inputProps.type = options.inputType;
@@ -1462,7 +1583,7 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1462
1583
 
1463
1584
  /** The default submit button options, exported for testing purposes
1464
1585
  */
1465
- const DEFAULT_OPTIONS = {
1586
+ var DEFAULT_OPTIONS = {
1466
1587
  props: {
1467
1588
  disabled: false
1468
1589
  },
@@ -1478,13 +1599,10 @@ function getSubmitButtonOptions(uiSchema) {
1478
1599
  if (uiSchema === void 0) {
1479
1600
  uiSchema = {};
1480
1601
  }
1481
- const uiOptions = getUiOptions(uiSchema);
1602
+ var uiOptions = getUiOptions(uiSchema);
1482
1603
  if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
1483
- const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1484
- return {
1485
- ...DEFAULT_OPTIONS,
1486
- ...options
1487
- };
1604
+ var options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1605
+ return _extends({}, DEFAULT_OPTIONS, options);
1488
1606
  }
1489
1607
  return DEFAULT_OPTIONS;
1490
1608
  }
@@ -1501,9 +1619,7 @@ function getTemplate(name, registry, uiOptions) {
1501
1619
  if (uiOptions === void 0) {
1502
1620
  uiOptions = {};
1503
1621
  }
1504
- const {
1505
- templates
1506
- } = registry;
1622
+ var templates = registry.templates;
1507
1623
  if (name === "ButtonTemplates") {
1508
1624
  return templates[name];
1509
1625
  }
@@ -1514,10 +1630,11 @@ function getTemplate(name, registry, uiOptions) {
1514
1630
  );
1515
1631
  }
1516
1632
 
1633
+ var _excluded = ["options"];
1517
1634
  /** The map of schema types to widget type to widget name
1518
1635
  */
1519
- const widgetMap = {
1520
- boolean: {
1636
+ var widgetMap = {
1637
+ "boolean": {
1521
1638
  checkbox: "CheckboxWidget",
1522
1639
  radio: "RadioWidget",
1523
1640
  select: "SelectWidget",
@@ -1575,22 +1692,16 @@ const widgetMap = {
1575
1692
  * @returns - The wrapper widget
1576
1693
  */
1577
1694
  function mergeWidgetOptions(AWidget) {
1578
- let MergedWidget = get(AWidget, "MergedWidget");
1695
+ var MergedWidget = get(AWidget, "MergedWidget");
1579
1696
  // cache return value as property of widget for proper react reconciliation
1580
1697
  if (!MergedWidget) {
1581
- const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1582
- MergedWidget = _ref => {
1583
- let {
1584
- options,
1585
- ...props
1586
- } = _ref;
1587
- return /*#__PURE__*/React.createElement(AWidget, {
1588
- options: {
1589
- ...defaultOptions,
1590
- ...options
1591
- },
1592
- ...props
1593
- });
1698
+ var defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1699
+ MergedWidget = function MergedWidget(_ref) {
1700
+ var options = _ref.options,
1701
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
1702
+ return /*#__PURE__*/React.createElement(AWidget, _extends({
1703
+ options: _extends({}, defaultOptions, options)
1704
+ }, props));
1594
1705
  };
1595
1706
  set(AWidget, "MergedWidget", MergedWidget);
1596
1707
  }
@@ -1611,27 +1722,27 @@ function getWidget(schema, widget, registeredWidgets) {
1611
1722
  if (registeredWidgets === void 0) {
1612
1723
  registeredWidgets = {};
1613
1724
  }
1614
- const type = getSchemaType(schema);
1725
+ var type = getSchemaType(schema);
1615
1726
  if (typeof widget === "function" || widget && ReactIs.isForwardRef( /*#__PURE__*/React.createElement(widget)) || ReactIs.isMemo(widget)) {
1616
1727
  return mergeWidgetOptions(widget);
1617
1728
  }
1618
1729
  if (typeof widget !== "string") {
1619
- throw new Error(`Unsupported widget definition: ${typeof widget}`);
1730
+ throw new Error("Unsupported widget definition: " + typeof widget);
1620
1731
  }
1621
1732
  if (widget in registeredWidgets) {
1622
- const registeredWidget = registeredWidgets[widget];
1733
+ var registeredWidget = registeredWidgets[widget];
1623
1734
  return getWidget(schema, registeredWidget, registeredWidgets);
1624
1735
  }
1625
1736
  if (typeof type === "string") {
1626
1737
  if (!(type in widgetMap)) {
1627
- throw new Error(`No widget for type '${type}'`);
1738
+ throw new Error("No widget for type '" + type + "'");
1628
1739
  }
1629
1740
  if (widget in widgetMap[type]) {
1630
- const registeredWidget = registeredWidgets[widgetMap[type][widget]];
1631
- return getWidget(schema, registeredWidget, registeredWidgets);
1741
+ var _registeredWidget = registeredWidgets[widgetMap[type][widget]];
1742
+ return getWidget(schema, _registeredWidget, registeredWidgets);
1632
1743
  }
1633
1744
  }
1634
- throw new Error(`No widget '${widget}' for type '${type}'`);
1745
+ throw new Error("No widget '" + widget + "' for type '" + type + "'");
1635
1746
  }
1636
1747
 
1637
1748
  /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
@@ -1650,7 +1761,7 @@ function hasWidget(schema, widget, registeredWidgets) {
1650
1761
  getWidget(schema, widget, registeredWidgets);
1651
1762
  return true;
1652
1763
  } catch (e) {
1653
- const err = e;
1764
+ var err = e;
1654
1765
  if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
1655
1766
  return false;
1656
1767
  }
@@ -1675,11 +1786,11 @@ function localToUTC(dateString) {
1675
1786
  * @throws - Error when the schema does not have a constant value
1676
1787
  */
1677
1788
  function toConstant(schema) {
1678
- if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
1679
- return schema.enum[0];
1789
+ if (ENUM_KEY in schema && Array.isArray(schema["enum"]) && schema["enum"].length === 1) {
1790
+ return schema["enum"][0];
1680
1791
  }
1681
1792
  if (CONST_KEY in schema) {
1682
- return schema.const;
1793
+ return schema["const"];
1683
1794
  }
1684
1795
  throw new Error("schema cannot be inferred as a constant");
1685
1796
  }
@@ -1695,28 +1806,28 @@ function toConstant(schema) {
1695
1806
  function optionsList(schema) {
1696
1807
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
1697
1808
  // Cast the type to include enumNames so the feature still works.
1698
- const schemaWithEnumNames = schema;
1809
+ var schemaWithEnumNames = schema;
1699
1810
  if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== "production") {
1700
1811
  console.warn("The enumNames property is deprecated and may be removed in a future major release.");
1701
1812
  }
1702
- if (schema.enum) {
1703
- return schema.enum.map((value, i) => {
1704
- const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
1813
+ if (schema["enum"]) {
1814
+ return schema["enum"].map(function (value, i) {
1815
+ var label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
1705
1816
  return {
1706
- label,
1707
- value
1817
+ label: label,
1818
+ value: value
1708
1819
  };
1709
1820
  });
1710
1821
  }
1711
- const altSchemas = schema.oneOf || schema.anyOf;
1712
- return altSchemas && altSchemas.map(aSchemaDef => {
1713
- const aSchema = aSchemaDef;
1714
- const value = toConstant(aSchema);
1715
- const label = aSchema.title || String(value);
1822
+ var altSchemas = schema.oneOf || schema.anyOf;
1823
+ return altSchemas && altSchemas.map(function (aSchemaDef) {
1824
+ var aSchema = aSchemaDef;
1825
+ var value = toConstant(aSchema);
1826
+ var label = aSchema.title || String(value);
1716
1827
  return {
1717
1828
  schema: aSchema,
1718
- label,
1719
- value
1829
+ label: label,
1830
+ value: value
1720
1831
  };
1721
1832
  });
1722
1833
  }
@@ -1735,27 +1846,35 @@ function orderProperties(properties, order) {
1735
1846
  if (!Array.isArray(order)) {
1736
1847
  return properties;
1737
1848
  }
1738
- const arrayToHash = arr => arr.reduce((prev, curr) => {
1739
- prev[curr] = true;
1740
- return prev;
1741
- }, {});
1742
- const errorPropList = arr => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
1743
- const propertyHash = arrayToHash(properties);
1744
- const orderFiltered = order.filter(prop => prop === "*" || propertyHash[prop]);
1745
- const orderHash = arrayToHash(orderFiltered);
1746
- const rest = properties.filter(prop => !orderHash[prop]);
1747
- const restIndex = orderFiltered.indexOf("*");
1849
+ var arrayToHash = function arrayToHash(arr) {
1850
+ return arr.reduce(function (prev, curr) {
1851
+ prev[curr] = true;
1852
+ return prev;
1853
+ }, {});
1854
+ };
1855
+ var errorPropList = function errorPropList(arr) {
1856
+ return arr.length > 1 ? "properties '" + arr.join("', '") + "'" : "property '" + arr[0] + "'";
1857
+ };
1858
+ var propertyHash = arrayToHash(properties);
1859
+ var orderFiltered = order.filter(function (prop) {
1860
+ return prop === "*" || propertyHash[prop];
1861
+ });
1862
+ var orderHash = arrayToHash(orderFiltered);
1863
+ var rest = properties.filter(function (prop) {
1864
+ return !orderHash[prop];
1865
+ });
1866
+ var restIndex = orderFiltered.indexOf("*");
1748
1867
  if (restIndex === -1) {
1749
1868
  if (rest.length) {
1750
- throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
1869
+ throw new Error("uiSchema order list does not contain " + errorPropList(rest));
1751
1870
  }
1752
1871
  return orderFiltered;
1753
1872
  }
1754
1873
  if (restIndex !== orderFiltered.lastIndexOf("*")) {
1755
1874
  throw new Error("uiSchema order list contains more than one wildcard item");
1756
1875
  }
1757
- const complete = [...orderFiltered];
1758
- complete.splice(restIndex, 1, ...rest);
1876
+ var complete = [].concat(orderFiltered);
1877
+ complete.splice.apply(complete, [restIndex, 1].concat(rest));
1759
1878
  return complete;
1760
1879
  }
1761
1880
 
@@ -1766,7 +1885,7 @@ function orderProperties(properties, order) {
1766
1885
  * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
1767
1886
  */
1768
1887
  function pad(num, width) {
1769
- let s = String(num);
1888
+ var s = String(num);
1770
1889
  while (s.length < width) {
1771
1890
  s = "0" + s;
1772
1891
  }
@@ -1794,7 +1913,7 @@ function parseDateString(dateString, includeTime) {
1794
1913
  second: includeTime ? -1 : 0
1795
1914
  };
1796
1915
  }
1797
- const date = new Date(dateString);
1916
+ var date = new Date(dateString);
1798
1917
  if (Number.isNaN(date.getTime())) {
1799
1918
  throw new Error("Unable to parse date " + dateString);
1800
1919
  }
@@ -1808,7 +1927,7 @@ function parseDateString(dateString, includeTime) {
1808
1927
  };
1809
1928
  }
1810
1929
 
1811
- const nums = /*#__PURE__*/new Set(["number", "integer"]);
1930
+ var nums = /*#__PURE__*/new Set(["number", "integer"]);
1812
1931
  /** Returns the real value for a select widget due to a silly limitation in the DOM which causes option change event
1813
1932
  * values to always be retrieved as strings. Uses the `schema` to help determine the value's true type. If the value is
1814
1933
  * an empty string, then the `emptyValue` from the `options` is returned, falling back to undefined.
@@ -1819,11 +1938,9 @@ const nums = /*#__PURE__*/new Set(["number", "integer"]);
1819
1938
  * @returns - The `value` converted to the proper type
1820
1939
  */
1821
1940
  function processSelectValue(schema, value, options) {
1822
- const {
1823
- enum: schemaEnum,
1824
- type,
1825
- items
1826
- } = schema;
1941
+ var schemaEnum = schema["enum"],
1942
+ type = schema.type,
1943
+ items = schema.items;
1827
1944
  if (value === "") {
1828
1945
  return options && options.emptyValue !== undefined ? options.emptyValue : undefined;
1829
1946
  }
@@ -1839,10 +1956,14 @@ function processSelectValue(schema, value, options) {
1839
1956
  // If type is undefined, but an enum is present, try and infer the type from
1840
1957
  // the enum values
1841
1958
  if (Array.isArray(schemaEnum)) {
1842
- if (schemaEnum.every(x => nums.has(guessType(x)))) {
1959
+ if (schemaEnum.every(function (x) {
1960
+ return nums.has(guessType(x));
1961
+ })) {
1843
1962
  return asNumber(value);
1844
1963
  }
1845
- if (schemaEnum.every(x => guessType(x) === "boolean")) {
1964
+ if (schemaEnum.every(function (x) {
1965
+ return guessType(x) === "boolean";
1966
+ })) {
1846
1967
  return value === "true";
1847
1968
  }
1848
1969
  }
@@ -1860,11 +1981,11 @@ function processSelectValue(schema, value, options) {
1860
1981
  */
1861
1982
  function schemaRequiresTrueValue(schema) {
1862
1983
  // Check if const is a truthy value
1863
- if (schema.const) {
1984
+ if (schema["const"]) {
1864
1985
  return true;
1865
1986
  }
1866
1987
  // Check if an enum has a single value of true
1867
- if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
1988
+ if (schema["enum"] && schema["enum"].length === 1 && schema["enum"][0] === true) {
1868
1989
  return true;
1869
1990
  }
1870
1991
  // If anyOf has a single value, evaluate the subschema
@@ -1877,7 +1998,9 @@ function schemaRequiresTrueValue(schema) {
1877
1998
  }
1878
1999
  // Evaluate each subschema in allOf, to see if one of them requires a true value
1879
2000
  if (schema.allOf) {
1880
- const schemaSome = subSchema => schemaRequiresTrueValue(subSchema);
2001
+ var schemaSome = function schemaSome(subSchema) {
2002
+ return schemaRequiresTrueValue(subSchema);
2003
+ };
1881
2004
  return schema.allOf.some(schemaSome);
1882
2005
  }
1883
2006
  return false;
@@ -1892,10 +2015,8 @@ function schemaRequiresTrueValue(schema) {
1892
2015
  * @returns - True if the component should be re-rendered, false otherwise
1893
2016
  */
1894
2017
  function shouldRender(component, nextProps, nextState) {
1895
- const {
1896
- props,
1897
- state
1898
- } = component;
2018
+ var props = component.props,
2019
+ state = component.state;
1899
2020
  return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
1900
2021
  }
1901
2022
 
@@ -1910,16 +2031,17 @@ function toDateString(dateObject, time) {
1910
2031
  if (time === void 0) {
1911
2032
  time = true;
1912
2033
  }
1913
- const {
1914
- year,
1915
- month,
1916
- day,
1917
- hour = 0,
1918
- minute = 0,
1919
- second = 0
1920
- } = dateObject;
1921
- const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
1922
- const datetime = new Date(utcTime).toJSON();
2034
+ var year = dateObject.year,
2035
+ month = dateObject.month,
2036
+ day = dateObject.day,
2037
+ _dateObject$hour = dateObject.hour,
2038
+ hour = _dateObject$hour === void 0 ? 0 : _dateObject$hour,
2039
+ _dateObject$minute = dateObject.minute,
2040
+ minute = _dateObject$minute === void 0 ? 0 : _dateObject$minute,
2041
+ _dateObject$second = dateObject.second,
2042
+ second = _dateObject$second === void 0 ? 0 : _dateObject$second;
2043
+ var utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
2044
+ var datetime = new Date(utcTime).toJSON();
1923
2045
  return time ? datetime : datetime.slice(0, 10);
1924
2046
  }
1925
2047
 
@@ -1937,16 +2059,16 @@ function utcToLocal(jsonDate) {
1937
2059
  // > should be a _valid local date and time string_ (not GMT)
1938
2060
  // Note - date constructor passed local ISO-8601 does not correctly
1939
2061
  // change time to UTC in node pre-8
1940
- const date = new Date(jsonDate);
1941
- const yyyy = pad(date.getFullYear(), 4);
1942
- const MM = pad(date.getMonth() + 1, 2);
1943
- const dd = pad(date.getDate(), 2);
1944
- const hh = pad(date.getHours(), 2);
1945
- const mm = pad(date.getMinutes(), 2);
1946
- const ss = pad(date.getSeconds(), 2);
1947
- const SSS = pad(date.getMilliseconds(), 3);
1948
- return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;
2062
+ var date = new Date(jsonDate);
2063
+ var yyyy = pad(date.getFullYear(), 4);
2064
+ var MM = pad(date.getMonth() + 1, 2);
2065
+ var dd = pad(date.getDate(), 2);
2066
+ var hh = pad(date.getHours(), 2);
2067
+ var mm = pad(date.getMinutes(), 2);
2068
+ var ss = pad(date.getSeconds(), 2);
2069
+ var SSS = pad(date.getMilliseconds(), 3);
2070
+ return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
1949
2071
  }
1950
2072
 
1951
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, findSchemaDefinition, getDefaultFormState, getDisplayLabel, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, retrieveSchema, schemaRequiresTrueValue, shouldRender, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2073
+ export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, findSchemaDefinition, getDefaultFormState, getDisplayLabel, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, retrieveSchema, schemaRequiresTrueValue, shouldRender, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
1952
2074
  //# sourceMappingURL=utils.esm.js.map