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

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.
@@ -10,6 +10,7 @@ var omit = require('lodash/omit');
10
10
  var set = require('lodash/set');
11
11
  var mergeAllOf = require('json-schema-merge-allof');
12
12
  var union = require('lodash/union');
13
+ var cloneDeep = require('lodash/cloneDeep');
13
14
  var React = require('react');
14
15
  var ReactIs = require('react-is');
15
16
 
@@ -23,6 +24,7 @@ var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
23
24
  var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
24
25
  var mergeAllOf__default = /*#__PURE__*/_interopDefaultLegacy(mergeAllOf);
25
26
  var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
27
+ var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
26
28
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
29
  var ReactIs__default = /*#__PURE__*/_interopDefaultLegacy(ReactIs);
28
30
 
@@ -36,6 +38,9 @@ function isObject(thing) {
36
38
  if (typeof File !== "undefined" && thing instanceof File) {
37
39
  return false;
38
40
  }
41
+ if (typeof Date !== "undefined" && thing instanceof Date) {
42
+ return false;
43
+ }
39
44
  return typeof thing === "object" && thing !== null && !Array.isArray(thing);
40
45
  }
41
46
 
@@ -83,38 +88,85 @@ function asNumber(value) {
83
88
  // specific precision or number of significant digits)
84
89
  return value;
85
90
  }
86
- const n = Number(value);
87
- const valid = typeof n === "number" && !Number.isNaN(n);
91
+ var n = Number(value);
92
+ var valid = typeof n === "number" && !Number.isNaN(n);
88
93
  return valid ? n : value;
89
94
  }
90
95
 
96
+ function _defineProperties(target, props) {
97
+ for (var i = 0; i < props.length; i++) {
98
+ var descriptor = props[i];
99
+ descriptor.enumerable = descriptor.enumerable || false;
100
+ descriptor.configurable = true;
101
+ if ("value" in descriptor) descriptor.writable = true;
102
+ Object.defineProperty(target, descriptor.key, descriptor);
103
+ }
104
+ }
105
+ function _createClass(Constructor, protoProps, staticProps) {
106
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
107
+ if (staticProps) _defineProperties(Constructor, staticProps);
108
+ Object.defineProperty(Constructor, "prototype", {
109
+ writable: false
110
+ });
111
+ return Constructor;
112
+ }
113
+ function _extends() {
114
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
115
+ for (var i = 1; i < arguments.length; i++) {
116
+ var source = arguments[i];
117
+ for (var key in source) {
118
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
119
+ target[key] = source[key];
120
+ }
121
+ }
122
+ }
123
+ return target;
124
+ };
125
+ return _extends.apply(this, arguments);
126
+ }
127
+ function _objectDestructuringEmpty(obj) {
128
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
129
+ }
130
+ function _objectWithoutPropertiesLoose(source, excluded) {
131
+ if (source == null) return {};
132
+ var target = {};
133
+ var sourceKeys = Object.keys(source);
134
+ var key, i;
135
+ for (i = 0; i < sourceKeys.length; i++) {
136
+ key = sourceKeys[i];
137
+ if (excluded.indexOf(key) >= 0) continue;
138
+ target[key] = source[key];
139
+ }
140
+ return target;
141
+ }
142
+
91
143
  /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
92
144
  * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
93
145
  * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
94
146
  * utility.
95
147
  */
96
- const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
97
- const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
98
- const ALL_OF_KEY = "allOf";
99
- const ANY_OF_KEY = "anyOf";
100
- const CONST_KEY = "const";
101
- const DEFAULT_KEY = "default";
102
- const DEFINITIONS_KEY = "definitions";
103
- const DEPENDENCIES_KEY = "dependencies";
104
- const ENUM_KEY = "enum";
105
- const ERRORS_KEY = "__errors";
106
- const ID_KEY = "$id";
107
- const ITEMS_KEY = "items";
108
- const NAME_KEY = "$name";
109
- const ONE_OF_KEY = "oneOf";
110
- const PROPERTIES_KEY = "properties";
111
- const REQUIRED_KEY = "required";
112
- const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
113
- const REF_KEY = "$ref";
114
- const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
115
- const UI_FIELD_KEY = "ui:field";
116
- const UI_WIDGET_KEY = "ui:widget";
117
- const UI_OPTIONS_KEY = "ui:options";
148
+ var ADDITIONAL_PROPERTY_FLAG = "__additional_property";
149
+ var ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
150
+ var ALL_OF_KEY = "allOf";
151
+ var ANY_OF_KEY = "anyOf";
152
+ var CONST_KEY = "const";
153
+ var DEFAULT_KEY = "default";
154
+ var DEFINITIONS_KEY = "definitions";
155
+ var DEPENDENCIES_KEY = "dependencies";
156
+ var ENUM_KEY = "enum";
157
+ var ERRORS_KEY = "__errors";
158
+ var ID_KEY = "$id";
159
+ var ITEMS_KEY = "items";
160
+ var NAME_KEY = "$name";
161
+ var ONE_OF_KEY = "oneOf";
162
+ var PROPERTIES_KEY = "properties";
163
+ var REQUIRED_KEY = "required";
164
+ var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
165
+ var REF_KEY = "$ref";
166
+ var RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
167
+ var UI_FIELD_KEY = "ui:field";
168
+ var UI_WIDGET_KEY = "ui:widget";
169
+ var UI_OPTIONS_KEY = "ui:options";
118
170
 
119
171
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
120
172
  * stripped off.
@@ -126,22 +178,19 @@ function getUiOptions(uiSchema) {
126
178
  if (uiSchema === void 0) {
127
179
  uiSchema = {};
128
180
  }
129
- return Object.keys(uiSchema).filter(key => key.indexOf("ui:") === 0).reduce((options, key) => {
130
- const value = uiSchema[key];
181
+ return Object.keys(uiSchema).filter(function (key) {
182
+ return key.indexOf("ui:") === 0;
183
+ }).reduce(function (options, key) {
184
+ var _extends2;
185
+ var value = uiSchema[key];
131
186
  if (key === UI_WIDGET_KEY && isObject(value)) {
132
187
  console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
133
188
  return options;
134
189
  }
135
190
  if (key === UI_OPTIONS_KEY && isObject(value)) {
136
- return {
137
- ...options,
138
- ...value
139
- };
191
+ return _extends({}, options, value);
140
192
  }
141
- return {
142
- ...options,
143
- [key.substring(3)]: value
144
- };
193
+ return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
145
194
  }, {});
146
195
  }
147
196
 
@@ -161,9 +210,9 @@ function canExpand(schema, uiSchema, formData) {
161
210
  if (!schema.additionalProperties) {
162
211
  return false;
163
212
  }
164
- const {
165
- expandable = true
166
- } = getUiOptions(uiSchema);
213
+ var _getUiOptions = getUiOptions(uiSchema),
214
+ _getUiOptions$expanda = _getUiOptions.expandable,
215
+ expandable = _getUiOptions$expanda === void 0 ? true : _getUiOptions$expanda;
167
216
  if (expandable === false) {
168
217
  return expandable;
169
218
  }
@@ -183,7 +232,7 @@ function canExpand(schema, uiSchema, formData) {
183
232
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
184
233
  */
185
234
  function deepEquals(a, b) {
186
- return isEqualWith__default["default"](a, b, (obj, other) => {
235
+ return isEqualWith__default["default"](a, b, function (obj, other) {
187
236
  if (typeof obj === "function" && typeof other === "function") {
188
237
  // Assume all functions are equivalent
189
238
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
@@ -202,8 +251,8 @@ function deepEquals(a, b) {
202
251
  * value from `object[key]`
203
252
  */
204
253
  function splitKeyElementFromObject(key, object) {
205
- const value = object[key];
206
- const remaining = omit__default["default"](object, [key]);
254
+ var value = object[key];
255
+ var remaining = omit__default["default"](object, [key]);
207
256
  return [remaining, value];
208
257
  }
209
258
  /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
@@ -219,25 +268,24 @@ function findSchemaDefinition($ref, rootSchema) {
219
268
  if (rootSchema === void 0) {
220
269
  rootSchema = {};
221
270
  }
222
- let ref = $ref || "";
271
+ var ref = $ref || "";
223
272
  if (ref.startsWith("#")) {
224
273
  // Decode URI fragment representation.
225
274
  ref = decodeURIComponent(ref.substring(1));
226
275
  } else {
227
- throw new Error(`Could not find a definition for ${$ref}.`);
276
+ throw new Error("Could not find a definition for " + $ref + ".");
228
277
  }
229
- const current = jsonpointer__default["default"].get(rootSchema, ref);
278
+ var current = jsonpointer__default["default"].get(rootSchema, ref);
230
279
  if (current === undefined) {
231
- throw new Error(`Could not find a definition for ${$ref}.`);
280
+ throw new Error("Could not find a definition for " + $ref + ".");
232
281
  }
233
282
  if (current[REF_KEY]) {
234
- const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
235
- const subSchema = findSchemaDefinition(theRef, rootSchema);
283
+ var _splitKeyElementFromO = splitKeyElementFromObject(REF_KEY, current),
284
+ remaining = _splitKeyElementFromO[0],
285
+ theRef = _splitKeyElementFromO[1];
286
+ var subSchema = findSchemaDefinition(theRef, rootSchema);
236
287
  if (Object.keys(remaining).length > 0) {
237
- return {
238
- ...remaining,
239
- ...subSchema
240
- };
288
+ return _extends({}, remaining, subSchema);
241
289
  }
242
290
  return subSchema;
243
291
  }
@@ -258,8 +306,8 @@ function getMatchingOption(validator, formData, options, rootSchema) {
258
306
  if (formData === undefined) {
259
307
  return 0;
260
308
  }
261
- for (let i = 0; i < options.length; i++) {
262
- const option = options[i];
309
+ for (var i = 0; i < options.length; i++) {
310
+ var option = options[i];
263
311
  // If the schema describes an object then we need to add slightly more
264
312
  // strict matching to the schema, because unless the schema uses the
265
313
  // "requires" keyword, an object will match the schema as long as it
@@ -270,18 +318,18 @@ function getMatchingOption(validator, formData, options, rootSchema) {
270
318
  if (option.properties) {
271
319
  // Create an "anyOf" schema that requires at least one of the keys in the
272
320
  // "properties" object
273
- const requiresAnyOf = {
274
- anyOf: Object.keys(option.properties).map(key => ({
275
- required: [key]
276
- }))
321
+ var requiresAnyOf = {
322
+ anyOf: Object.keys(option.properties).map(function (key) {
323
+ return {
324
+ required: [key]
325
+ };
326
+ })
277
327
  };
278
- let augmentedSchema;
328
+ var augmentedSchema = void 0;
279
329
  // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
280
330
  if (option.anyOf) {
281
331
  // Create a shallow clone of the option
282
- const {
283
- ...shallowClone
284
- } = option;
332
+ var shallowClone = _extends({}, (_objectDestructuringEmpty(option), option));
285
333
  if (!shallowClone.allOf) {
286
334
  shallowClone.allOf = [];
287
335
  } else {
@@ -347,20 +395,20 @@ function guessType(value) {
347
395
  * @returns - The type of the schema
348
396
  */
349
397
  function getSchemaType(schema) {
350
- let {
351
- type
352
- } = schema;
353
- if (!type && schema.const) {
354
- return guessType(schema.const);
398
+ var type = schema.type;
399
+ if (!type && schema["const"]) {
400
+ return guessType(schema["const"]);
355
401
  }
356
- if (!type && schema.enum) {
402
+ if (!type && schema["enum"]) {
357
403
  return "string";
358
404
  }
359
405
  if (!type && (schema.properties || schema.additionalProperties)) {
360
406
  return "object";
361
407
  }
362
408
  if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
363
- type = type.find(type => type !== "null");
409
+ type = type.find(function (type) {
410
+ return type !== "null";
411
+ });
364
412
  }
365
413
  return type;
366
414
  }
@@ -372,7 +420,9 @@ function getSchemaType(schema) {
372
420
  * @returns - True if there are fixed items in the schema, false otherwise
373
421
  */
374
422
  function isFixedItems(schema) {
375
- return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(item => isObject(item));
423
+ return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(function (item) {
424
+ return isObject(item);
425
+ });
376
426
  }
377
427
 
378
428
  /** Merges the `defaults` object of type `T` into the `formData` of type `T`
@@ -391,8 +441,8 @@ function isFixedItems(schema) {
391
441
  */
392
442
  function mergeDefaultsWithFormData(defaults, formData) {
393
443
  if (Array.isArray(formData)) {
394
- const defaultsArray = Array.isArray(defaults) ? defaults : [];
395
- const mapped = formData.map((value, idx) => {
444
+ var defaultsArray = Array.isArray(defaults) ? defaults : [];
445
+ var mapped = formData.map(function (value, idx) {
396
446
  if (defaultsArray[idx]) {
397
447
  return mergeDefaultsWithFormData(defaultsArray[idx], value);
398
448
  }
@@ -401,8 +451,8 @@ function mergeDefaultsWithFormData(defaults, formData) {
401
451
  return mapped;
402
452
  }
403
453
  if (isObject(formData)) {
404
- const acc = Object.assign({}, defaults); // Prevent mutation of source object.
405
- return Object.keys(formData).reduce((acc, key) => {
454
+ var acc = Object.assign({}, defaults); // Prevent mutation of source object.
455
+ return Object.keys(formData).reduce(function (acc, key) {
406
456
  acc[key] = mergeDefaultsWithFormData(defaults ? get__default["default"](defaults, key) : {}, get__default["default"](formData, key));
407
457
  return acc;
408
458
  }, acc);
@@ -414,20 +464,31 @@ function mergeDefaultsWithFormData(defaults, formData) {
414
464
  *
415
465
  * @param obj1 - The first object to merge
416
466
  * @param obj2 - The second object to merge
417
- * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated
467
+ * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated. Use
468
+ * "preventDuplicates" to merge arrays in a manner that prevents any duplicate entries from being merged.
469
+ * NOTE: Uses shallow comparison for the duplicate checking.
418
470
  * @returns - A new object that is the merge of the two given objects
419
471
  */
420
472
  function mergeObjects(obj1, obj2, concatArrays) {
421
473
  if (concatArrays === void 0) {
422
474
  concatArrays = false;
423
475
  }
424
- return Object.keys(obj2).reduce((acc, key) => {
425
- const left = obj1 ? obj1[key] : {},
476
+ return Object.keys(obj2).reduce(function (acc, key) {
477
+ var left = obj1 ? obj1[key] : {},
426
478
  right = obj2[key];
427
479
  if (obj1 && key in obj1 && isObject(right)) {
428
480
  acc[key] = mergeObjects(left, right, concatArrays);
429
481
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
430
- acc[key] = left.concat(right);
482
+ var toMerge = right;
483
+ if (concatArrays === "preventDuplicates") {
484
+ toMerge = right.reduce(function (result, value) {
485
+ if (!left.includes(value)) {
486
+ result.push(value);
487
+ }
488
+ return result;
489
+ }, []);
490
+ }
491
+ acc[key] = left.concat(toMerge);
431
492
  } else {
432
493
  acc[key] = right;
433
494
  }
@@ -442,7 +503,7 @@ function mergeObjects(obj1, obj2, concatArrays) {
442
503
  * @returns - True if the `schema` has a single constant value, false otherwise
443
504
  */
444
505
  function isConstant(schema) {
445
- return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
506
+ return Array.isArray(schema["enum"]) && schema["enum"].length === 1 || CONST_KEY in schema;
446
507
  }
447
508
 
448
509
  /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
@@ -454,9 +515,9 @@ function isConstant(schema) {
454
515
  * @returns - The merged schema object
455
516
  */
456
517
  function mergeSchemas(obj1, obj2) {
457
- const acc = Object.assign({}, obj1); // Prevent mutation of source object.
458
- return Object.keys(obj2).reduce((acc, key) => {
459
- const left = obj1 ? obj1[key] : {},
518
+ var acc = Object.assign({}, obj1); // Prevent mutation of source object.
519
+ return Object.keys(obj2).reduce(function (acc, key) {
520
+ var left = obj1 ? obj1[key] : {},
460
521
  right = obj2[key];
461
522
  if (obj1 && key in obj1 && isObject(right)) {
462
523
  acc[key] = mergeSchemas(left, right);
@@ -470,6 +531,11 @@ function mergeSchemas(obj1, obj2) {
470
531
  }, acc);
471
532
  }
472
533
 
534
+ var _excluded$1 = ["if", "then", "else"],
535
+ _excluded2 = ["$ref"],
536
+ _excluded3 = ["allOf"],
537
+ _excluded4 = ["dependencies"],
538
+ _excluded5 = ["oneOf"];
473
539
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
474
540
  * with the rest of the schema
475
541
  *
@@ -480,13 +546,11 @@ function mergeSchemas(obj1, obj2) {
480
546
  * @returns - A schema with the appropriate condition resolved
481
547
  */
482
548
  function resolveCondition(validator, schema, rootSchema, formData) {
483
- const {
484
- if: expression,
485
- then,
486
- else: otherwise,
487
- ...resolvedSchemaLessConditional
488
- } = schema;
489
- const conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
549
+ var expression = schema["if"],
550
+ then = schema.then,
551
+ otherwise = schema["else"],
552
+ resolvedSchemaLessConditional = _objectWithoutPropertiesLoose(schema, _excluded$1);
553
+ var conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
490
554
  if (conditionalSchema && typeof conditionalSchema !== "boolean") {
491
555
  return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
492
556
  }
@@ -509,14 +573,15 @@ function resolveSchema(validator, schema, rootSchema, formData) {
509
573
  return resolveReference(validator, schema, rootSchema, formData);
510
574
  }
511
575
  if (DEPENDENCIES_KEY in schema) {
512
- const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
576
+ var resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
513
577
  return retrieveSchema(validator, resolvedSchema, rootSchema, formData);
514
578
  }
515
579
  if (ALL_OF_KEY in schema) {
516
- return {
517
- ...schema,
518
- allOf: schema.allOf.map(allOfSubschema => retrieveSchema(validator, allOfSubschema, rootSchema, formData))
519
- };
580
+ return _extends({}, schema, {
581
+ allOf: schema.allOf.map(function (allOfSubschema) {
582
+ return retrieveSchema(validator, allOfSubschema, rootSchema, formData);
583
+ })
584
+ });
520
585
  }
521
586
  // No $ref or dependencies attribute found, returning the original schema.
522
587
  return schema;
@@ -531,17 +596,11 @@ function resolveSchema(validator, schema, rootSchema, formData) {
531
596
  */
532
597
  function resolveReference(validator, schema, rootSchema, formData) {
533
598
  // Retrieve the referenced schema definition.
534
- const $refSchema = findSchemaDefinition(schema.$ref, rootSchema);
599
+ var $refSchema = findSchemaDefinition(schema.$ref, rootSchema);
535
600
  // Drop the $ref property of the source schema.
536
- const {
537
- $ref,
538
- ...localSchema
539
- } = schema;
601
+ var localSchema = _objectWithoutPropertiesLoose(schema, _excluded2);
540
602
  // Update referenced schema definition with local schema properties.
541
- return retrieveSchema(validator, {
542
- ...$refSchema,
543
- ...localSchema
544
- }, rootSchema, formData);
603
+ return retrieveSchema(validator, _extends({}, $refSchema, localSchema), rootSchema, formData);
545
604
  }
546
605
  /** Creates new 'properties' items for each key in the `formData`
547
606
  *
@@ -553,29 +612,24 @@ function resolveReference(validator, schema, rootSchema, formData) {
553
612
  */
554
613
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
555
614
  // Clone the schema so we don't ruin the consumer's original
556
- const schema = {
557
- ...theSchema,
558
- properties: {
559
- ...theSchema.properties
560
- }
561
- };
615
+ var schema = _extends({}, theSchema, {
616
+ properties: _extends({}, theSchema.properties)
617
+ });
562
618
  // make sure formData is an object
563
- const formData = aFormData && isObject(aFormData) ? aFormData : {};
564
- Object.keys(formData).forEach(key => {
619
+ var formData = aFormData && isObject(aFormData) ? aFormData : {};
620
+ Object.keys(formData).forEach(function (key) {
565
621
  if (key in schema.properties) {
566
622
  // No need to stub, our schema already has the property
567
623
  return;
568
624
  }
569
- let additionalProperties = {};
625
+ var additionalProperties = {};
570
626
  if (typeof schema.additionalProperties !== "boolean") {
571
627
  if (REF_KEY in schema.additionalProperties) {
572
628
  additionalProperties = retrieveSchema(validator, {
573
629
  $ref: get__default["default"](schema.additionalProperties, [REF_KEY])
574
630
  }, rootSchema, formData);
575
631
  } else if ("type" in schema.additionalProperties) {
576
- additionalProperties = {
577
- ...schema.additionalProperties
578
- };
632
+ additionalProperties = _extends({}, schema.additionalProperties);
579
633
  } else {
580
634
  additionalProperties = {
581
635
  type: guessType(get__default["default"](formData, [key]))
@@ -610,46 +664,24 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
610
664
  if (!isObject(schema)) {
611
665
  return {};
612
666
  }
613
- let resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
667
+ var resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
614
668
  if ("if" in schema) {
615
669
  return resolveCondition(validator, schema, rootSchema, rawFormData);
616
670
  }
617
- const formData = rawFormData || {};
618
- // For each level of the dependency, we need to recursively determine the appropriate resolved schema given the current state of formData.
619
- // Otherwise, nested allOf subschemas will not be correctly displayed.
620
- if (resolvedSchema.properties) {
621
- const properties = {};
622
- Object.entries(resolvedSchema.properties).forEach(entries => {
623
- const propName = entries[0];
624
- const propSchema = entries[1];
625
- const rawPropData = formData[propName];
626
- const propData = isObject(rawPropData) ? rawPropData : {};
627
- const resolvedPropSchema = retrieveSchema(validator, propSchema, rootSchema, propData);
628
- properties[propName] = resolvedPropSchema;
629
- if (propSchema !== resolvedPropSchema && resolvedSchema.properties !== properties) {
630
- resolvedSchema = {
631
- ...resolvedSchema,
632
- properties
633
- };
634
- }
635
- });
636
- }
671
+ var formData = rawFormData || {};
637
672
  if (ALL_OF_KEY in schema) {
638
673
  try {
639
- resolvedSchema = mergeAllOf__default["default"]({
640
- ...resolvedSchema,
641
- allOf: resolvedSchema.allOf
674
+ resolvedSchema = mergeAllOf__default["default"](resolvedSchema, {
675
+ deep: false
642
676
  });
643
677
  } catch (e) {
644
678
  console.warn("could not merge subschemas in allOf:\n" + e);
645
- const {
646
- allOf,
647
- ...resolvedSchemaWithoutAllOf
648
- } = resolvedSchema;
679
+ var _resolvedSchema = resolvedSchema,
680
+ resolvedSchemaWithoutAllOf = _objectWithoutPropertiesLoose(_resolvedSchema, _excluded3);
649
681
  return resolvedSchemaWithoutAllOf;
650
682
  }
651
683
  }
652
- const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
684
+ var hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
653
685
  if (hasAdditionalProperties) {
654
686
  return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, formData);
655
687
  }
@@ -665,11 +697,9 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
665
697
  */
666
698
  function resolveDependencies(validator, schema, rootSchema, formData) {
667
699
  // Drop the dependencies from the source schema.
668
- const {
669
- dependencies,
670
- ...remainingSchema
671
- } = schema;
672
- let resolvedSchema = remainingSchema;
700
+ var dependencies = schema.dependencies,
701
+ remainingSchema = _objectWithoutPropertiesLoose(schema, _excluded4);
702
+ var resolvedSchema = remainingSchema;
673
703
  if (Array.isArray(resolvedSchema.oneOf)) {
674
704
  resolvedSchema = resolvedSchema.oneOf[getMatchingOption(validator, formData, resolvedSchema.oneOf, rootSchema)];
675
705
  } else if (Array.isArray(resolvedSchema.anyOf)) {
@@ -687,9 +717,9 @@ function resolveDependencies(validator, schema, rootSchema, formData) {
687
717
  * @returns - The schema with the `dependencies` resolved into it
688
718
  */
689
719
  function processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData) {
690
- let schema = resolvedSchema;
720
+ var schema = resolvedSchema;
691
721
  // Process dependencies updating the local schema properties as appropriate.
692
- for (const dependencyKey in dependencies) {
722
+ for (var dependencyKey in dependencies) {
693
723
  // Skip this dependency if its trigger property is not present.
694
724
  if (get__default["default"](formData, [dependencyKey]) === undefined) {
695
725
  continue;
@@ -698,7 +728,9 @@ function processDependencies(validator, dependencies, resolvedSchema, rootSchema
698
728
  if (schema.properties && !(dependencyKey in schema.properties)) {
699
729
  continue;
700
730
  }
701
- const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(dependencyKey, dependencies);
731
+ var _splitKeyElementFromO = splitKeyElementFromObject(dependencyKey, dependencies),
732
+ remainingDependencies = _splitKeyElementFromO[0],
733
+ dependencyValue = _splitKeyElementFromO[1];
702
734
  if (Array.isArray(dependencyValue)) {
703
735
  schema = withDependentProperties(schema, dependencyValue);
704
736
  } else if (isObject(dependencyValue)) {
@@ -718,11 +750,10 @@ function withDependentProperties(schema, additionallyRequired) {
718
750
  if (!additionallyRequired) {
719
751
  return schema;
720
752
  }
721
- const required = Array.isArray(schema.required) ? Array.from(new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
722
- return {
723
- ...schema,
753
+ var required = Array.isArray(schema.required) ? Array.from(new Set([].concat(schema.required, additionallyRequired))) : additionallyRequired;
754
+ return _extends({}, schema, {
724
755
  required: required
725
- };
756
+ });
726
757
  }
727
758
  /** Merges a dependent schema into the `schema` dealing with oneOfs and references
728
759
  *
@@ -735,17 +766,16 @@ function withDependentProperties(schema, additionallyRequired) {
735
766
  * @returns - The schema with the dependent schema resolved into it
736
767
  */
737
768
  function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData) {
738
- const {
739
- oneOf,
740
- ...dependentSchema
741
- } = retrieveSchema(validator, dependencyValue, rootSchema, formData);
769
+ var _retrieveSchema = retrieveSchema(validator, dependencyValue, rootSchema, formData),
770
+ oneOf = _retrieveSchema.oneOf,
771
+ dependentSchema = _objectWithoutPropertiesLoose(_retrieveSchema, _excluded5);
742
772
  schema = mergeSchemas(schema, dependentSchema);
743
773
  // Since it does not contain oneOf, we return the original schema.
744
774
  if (oneOf === undefined) {
745
775
  return schema;
746
776
  }
747
777
  // Resolve $refs inside oneOf.
748
- const resolvedOneOf = oneOf.map(subschema => {
778
+ var resolvedOneOf = oneOf.map(function (subschema) {
749
779
  if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
750
780
  return subschema;
751
781
  }
@@ -764,23 +794,19 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
764
794
  * @returns The schema with the best choice of oneOf schemas merged into
765
795
  */
766
796
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
767
- const validSubschemas = oneOf.filter(subschema => {
797
+ var validSubschemas = oneOf.filter(function (subschema) {
768
798
  if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
769
799
  return false;
770
800
  }
771
- const {
772
- [dependencyKey]: conditionPropertySchema
773
- } = subschema.properties;
801
+ var conditionPropertySchema = subschema.properties[dependencyKey];
774
802
  if (conditionPropertySchema) {
775
- const conditionSchema = {
803
+ var _properties;
804
+ var conditionSchema = {
776
805
  type: "object",
777
- properties: {
778
- [dependencyKey]: conditionPropertySchema
779
- }
806
+ properties: (_properties = {}, _properties[dependencyKey] = conditionPropertySchema, _properties)
780
807
  };
781
- const {
782
- errors
783
- } = validator.validateFormData(formData, conditionSchema);
808
+ var _validator$validateFo = validator.validateFormData(formData, conditionSchema),
809
+ errors = _validator$validateFo.errors;
784
810
  return errors.length === 0;
785
811
  }
786
812
  return false;
@@ -789,12 +815,12 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
789
815
  console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
790
816
  return schema;
791
817
  }
792
- const subschema = validSubschemas[0];
793
- const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
794
- const dependentSchema = {
795
- ...subschema,
818
+ var subschema = validSubschemas[0];
819
+ var _splitKeyElementFromO2 = splitKeyElementFromObject(dependencyKey, subschema.properties),
820
+ dependentSubschema = _splitKeyElementFromO2[0];
821
+ var dependentSchema = _extends({}, subschema, {
796
822
  properties: dependentSubschema
797
- };
823
+ });
798
824
  return mergeSchemas(schema, retrieveSchema(validator, dependentSchema, rootSchema, formData));
799
825
  }
800
826
 
@@ -809,13 +835,15 @@ function isSelect(validator, theSchema, rootSchema) {
809
835
  if (rootSchema === void 0) {
810
836
  rootSchema = {};
811
837
  }
812
- const schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
813
- const altSchemas = schema.oneOf || schema.anyOf;
814
- if (Array.isArray(schema.enum)) {
838
+ var schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
839
+ var altSchemas = schema.oneOf || schema.anyOf;
840
+ if (Array.isArray(schema["enum"])) {
815
841
  return true;
816
842
  }
817
843
  if (Array.isArray(altSchemas)) {
818
- return altSchemas.every(altSchemas => typeof altSchemas !== "boolean" && isConstant(altSchemas));
844
+ return altSchemas.every(function (altSchemas) {
845
+ return typeof altSchemas !== "boolean" && isConstant(altSchemas);
846
+ });
819
847
  }
820
848
  return false;
821
849
  }
@@ -866,7 +894,7 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
866
894
  }
867
895
  if (idx >= 0) {
868
896
  if (Array.isArray(schema.items) && idx < schema.items.length) {
869
- const item = schema.items[idx];
897
+ var item = schema.items[idx];
870
898
  if (typeof item !== "boolean") {
871
899
  return item;
872
900
  }
@@ -887,34 +915,39 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
887
915
  * @param [parentDefaults] - Any defaults provided by the parent field in the schema
888
916
  * @param [rootSchema] - The options root schema, used to primarily to look up `$ref`s
889
917
  * @param [rawFormData] - The current formData, if any, onto which to provide any missing defaults
890
- * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
918
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
919
+ * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
920
+ * object properties.
891
921
  * @returns - The resulting `formData` with all the defaults provided
892
922
  */
893
- function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
923
+ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
894
924
  if (rootSchema === void 0) {
895
925
  rootSchema = {};
896
926
  }
897
927
  if (includeUndefinedValues === void 0) {
898
928
  includeUndefinedValues = false;
899
929
  }
900
- const formData = isObject(rawFormData) ? rawFormData : {};
930
+ var formData = isObject(rawFormData) ? rawFormData : {};
931
+ var schema = isObject(rawSchema) ? rawSchema : {};
901
932
  // Compute the defaults recursively: give highest priority to deepest nodes.
902
- let defaults = parentDefaults;
903
- if (isObject(defaults) && isObject(schema.default)) {
933
+ var defaults = parentDefaults;
934
+ if (isObject(defaults) && isObject(schema["default"])) {
904
935
  // For object defaults, only override parent defaults that are defined in
905
936
  // schema.default.
906
- defaults = mergeObjects(defaults, schema.default);
937
+ defaults = mergeObjects(defaults, schema["default"]);
907
938
  } else if (DEFAULT_KEY in schema) {
908
- defaults = schema.default;
939
+ defaults = schema["default"];
909
940
  } else if (REF_KEY in schema) {
910
941
  // Use referenced schema defaults for this node.
911
- const refSchema = findSchemaDefinition(schema[REF_KEY], rootSchema);
942
+ var refSchema = findSchemaDefinition(schema[REF_KEY], rootSchema);
912
943
  return computeDefaults(validator, refSchema, defaults, rootSchema, formData, includeUndefinedValues);
913
944
  } else if (DEPENDENCIES_KEY in schema) {
914
- const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
945
+ var resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
915
946
  return computeDefaults(validator, resolvedSchema, defaults, rootSchema, formData, includeUndefinedValues);
916
947
  } else if (isFixedItems(schema)) {
917
- defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues));
948
+ defaults = schema.items.map(function (itemSchema, idx) {
949
+ return computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues);
950
+ });
918
951
  } else if (ONE_OF_KEY in schema) {
919
952
  schema = schema.oneOf[getMatchingOption(validator, isEmpty__default["default"](formData) ? undefined : formData, schema.oneOf, rootSchema)];
920
953
  } else if (ANY_OF_KEY in schema) {
@@ -922,16 +955,24 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
922
955
  }
923
956
  // Not defaults defined for this node, fallback to generic typed ones.
924
957
  if (typeof defaults === "undefined") {
925
- defaults = schema.default;
958
+ defaults = schema["default"];
926
959
  }
927
960
  switch (getSchemaType(schema)) {
928
961
  // We need to recur for object schema inner default values.
929
962
  case "object":
930
- return Object.keys(schema.properties || {}).reduce((acc, key) => {
963
+ return Object.keys(schema.properties || {}).reduce(function (acc, key) {
931
964
  // Compute the defaults for this node, with the parent defaults we might
932
965
  // have from a previous run: defaults[key].
933
- const computedDefault = computeDefaults(validator, get__default["default"](schema, [PROPERTIES_KEY, key]), get__default["default"](defaults, [key]), rootSchema, get__default["default"](formData, [key]), includeUndefinedValues);
934
- if (includeUndefinedValues || computedDefault !== undefined) {
966
+ var computedDefault = computeDefaults(validator, get__default["default"](schema, [PROPERTIES_KEY, key]), get__default["default"](defaults, [key]), rootSchema, get__default["default"](formData, [key]), includeUndefinedValues === "excludeObjectChildren" ? false : includeUndefinedValues);
967
+ if (includeUndefinedValues) {
968
+ acc[key] = computedDefault;
969
+ } else if (isObject(computedDefault)) {
970
+ // Store computedDefault if it's a non-empty object (e.g. not {})
971
+ if (!isEmpty__default["default"](computedDefault)) {
972
+ acc[key] = computedDefault;
973
+ }
974
+ } else if (computedDefault !== undefined) {
975
+ // Store computedDefault if it's a defined primitive (e.g. true)
935
976
  acc[key] = computedDefault;
936
977
  }
937
978
  return acc;
@@ -939,27 +980,27 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
939
980
  case "array":
940
981
  // Inject defaults into existing array defaults
941
982
  if (Array.isArray(defaults)) {
942
- defaults = defaults.map((item, idx) => {
943
- const schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
983
+ defaults = defaults.map(function (item, idx) {
984
+ var schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
944
985
  return computeDefaults(validator, schemaItem, item, rootSchema);
945
986
  });
946
987
  }
947
988
  // Deeply inject defaults into already existing form data
948
989
  if (Array.isArray(rawFormData)) {
949
- const schemaItem = getInnerSchemaForArrayItem(schema);
950
- defaults = rawFormData.map((item, idx) => {
990
+ var schemaItem = getInnerSchemaForArrayItem(schema);
991
+ defaults = rawFormData.map(function (item, idx) {
951
992
  return computeDefaults(validator, schemaItem, get__default["default"](defaults, [idx]), rootSchema, item);
952
993
  });
953
994
  }
954
995
  if (schema.minItems) {
955
996
  if (!isMultiSelect(validator, schema, rootSchema)) {
956
- const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
997
+ var defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
957
998
  if (schema.minItems > defaultsLength) {
958
- const defaultEntries = defaults || [];
999
+ var defaultEntries = defaults || [];
959
1000
  // populate the array with the defaults
960
- const fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
961
- const fillerDefault = fillerSchema.default;
962
- const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema));
1001
+ var fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
1002
+ var fillerDefault = fillerSchema["default"];
1003
+ var fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema));
963
1004
  // then fill up the rest with either the item default or empty, up to minItems
964
1005
  return defaultEntries.concat(fillerEntries);
965
1006
  }
@@ -976,7 +1017,9 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
976
1017
  * @param theSchema - The schema for which the default state is desired
977
1018
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
978
1019
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
979
- * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1020
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
1021
+ * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
1022
+ * object properties.
980
1023
  * @returns - The resulting `formData` with all the defaults provided
981
1024
  */
982
1025
  function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues) {
@@ -986,8 +1029,8 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
986
1029
  if (!isObject(theSchema)) {
987
1030
  throw new Error("Invalid schema: " + theSchema);
988
1031
  }
989
- const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
990
- const defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1032
+ var schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1033
+ var defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
991
1034
  if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
992
1035
  // No form data? Use schema defaults.
993
1036
  return defaults;
@@ -1033,7 +1076,7 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1033
1076
  return true;
1034
1077
  }
1035
1078
  if (schema.items) {
1036
- const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1079
+ var itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1037
1080
  return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1038
1081
  }
1039
1082
  return false;
@@ -1052,12 +1095,11 @@ function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1052
1095
  if (uiSchema === void 0) {
1053
1096
  uiSchema = {};
1054
1097
  }
1055
- const uiOptions = getUiOptions(uiSchema);
1056
- const {
1057
- label = true
1058
- } = uiOptions;
1059
- let displayLabel = !!label;
1060
- const schemaType = getSchemaType(schema);
1098
+ var uiOptions = getUiOptions(uiSchema);
1099
+ var _uiOptions$label = uiOptions.label,
1100
+ label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1101
+ var displayLabel = !!label;
1102
+ var schemaType = getSchemaType(schema);
1061
1103
  if (schemaType === "array") {
1062
1104
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1063
1105
  }
@@ -1087,19 +1129,17 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1087
1129
  if (!additionalErrorSchema) {
1088
1130
  return validationData;
1089
1131
  }
1090
- const {
1091
- errors: oldErrors,
1092
- errorSchema: oldErrorSchema
1093
- } = validationData;
1094
- let errors = validator.toErrorList(additionalErrorSchema);
1095
- let errorSchema = additionalErrorSchema;
1132
+ var oldErrors = validationData.errors,
1133
+ oldErrorSchema = validationData.errorSchema;
1134
+ var errors = validator.toErrorList(additionalErrorSchema);
1135
+ var errorSchema = additionalErrorSchema;
1096
1136
  if (!isEmpty__default["default"](oldErrorSchema)) {
1097
1137
  errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1098
- errors = [...oldErrors].concat(errors);
1138
+ errors = [].concat(oldErrors).concat(errors);
1099
1139
  }
1100
1140
  return {
1101
- errorSchema,
1102
- errors
1141
+ errorSchema: errorSchema,
1142
+ errors: errors
1103
1143
  };
1104
1144
  }
1105
1145
 
@@ -1122,20 +1162,20 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1122
1162
  idSeparator = "_";
1123
1163
  }
1124
1164
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1125
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1165
+ var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1126
1166
  return toIdSchema(validator, _schema, id, rootSchema, formData, idPrefix, idSeparator);
1127
1167
  }
1128
1168
  if (ITEMS_KEY in schema && !get__default["default"](schema, [ITEMS_KEY, REF_KEY])) {
1129
1169
  return toIdSchema(validator, get__default["default"](schema, ITEMS_KEY), id, rootSchema, formData, idPrefix, idSeparator);
1130
1170
  }
1131
- const $id = id || idPrefix;
1132
- const idSchema = {
1133
- $id
1171
+ var $id = id || idPrefix;
1172
+ var idSchema = {
1173
+ $id: $id
1134
1174
  };
1135
1175
  if (schema.type === "object" && PROPERTIES_KEY in schema) {
1136
- for (const name in schema.properties) {
1137
- const field = get__default["default"](schema, [PROPERTIES_KEY, name]);
1138
- const fieldId = idSchema[ID_KEY] + idSeparator + name;
1176
+ for (var name in schema.properties) {
1177
+ var field = get__default["default"](schema, [PROPERTIES_KEY, name]);
1178
+ var fieldId = idSchema[ID_KEY] + idSeparator + name;
1139
1179
  idSchema[name] = toIdSchema(validator, isObject(field) ? field : {}, fieldId, rootSchema,
1140
1180
  // It's possible that formData is not an object -- this can happen if an
1141
1181
  // array item has just been added, but not populated with data yet
@@ -1155,27 +1195,26 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1155
1195
  * @returns - The `PathSchema` object for the `schema`
1156
1196
  */
1157
1197
  function toPathSchema(validator, schema, name, rootSchema, formData) {
1198
+ var _pathSchema;
1158
1199
  if (name === void 0) {
1159
1200
  name = "";
1160
1201
  }
1161
1202
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1162
- const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1203
+ var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1163
1204
  return toPathSchema(validator, _schema, name, rootSchema, formData);
1164
1205
  }
1165
- const pathSchema = {
1166
- [NAME_KEY]: name.replace(/^\./, "")
1167
- };
1168
- if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] === true) {
1206
+ var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ""), _pathSchema);
1207
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
1169
1208
  set__default["default"](pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1170
1209
  }
1171
1210
  if (ITEMS_KEY in schema && Array.isArray(formData)) {
1172
- formData.forEach((element, i) => {
1173
- pathSchema[i] = toPathSchema(validator, schema.items, `${name}.${i}`, rootSchema, element);
1211
+ formData.forEach(function (element, i) {
1212
+ pathSchema[i] = toPathSchema(validator, schema.items, name + "." + i, rootSchema, element);
1174
1213
  });
1175
1214
  } else if (PROPERTIES_KEY in schema) {
1176
- for (const property in schema.properties) {
1177
- const field = get__default["default"](schema, [PROPERTIES_KEY, property]);
1178
- pathSchema[property] = toPathSchema(validator, field, `${name}.${property}`, rootSchema,
1215
+ for (var property in schema.properties) {
1216
+ var field = get__default["default"](schema, [PROPERTIES_KEY, property]);
1217
+ pathSchema[property] = toPathSchema(validator, field, name + "." + property, rootSchema,
1179
1218
  // It's possible that formData is not an object -- this can happen if an
1180
1219
  // array item has just been added, but not populated with data yet
1181
1220
  get__default["default"](formData, [property]));
@@ -1189,13 +1228,13 @@ function toPathSchema(validator, schema, name, rootSchema, formData) {
1189
1228
  * and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified set of APIs to the
1190
1229
  * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
1191
1230
  */
1192
- class SchemaUtils {
1231
+ var SchemaUtils = /*#__PURE__*/function () {
1193
1232
  /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
1194
1233
  *
1195
1234
  * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1196
1235
  * @param rootSchema - The root schema that will be forwarded to all the APIs
1197
1236
  */
1198
- constructor(validator, rootSchema) {
1237
+ function SchemaUtils(validator, rootSchema) {
1199
1238
  this.rootSchema = void 0;
1200
1239
  this.validator = void 0;
1201
1240
  this.rootSchema = rootSchema;
@@ -1205,7 +1244,8 @@ class SchemaUtils {
1205
1244
  *
1206
1245
  * @returns - The `ValidatorType`
1207
1246
  */
1208
- getValidator() {
1247
+ var _proto = SchemaUtils.prototype;
1248
+ _proto.getValidator = function getValidator() {
1209
1249
  return this.validator;
1210
1250
  }
1211
1251
  /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
@@ -1215,8 +1255,8 @@ class SchemaUtils {
1215
1255
  * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
1216
1256
  * @param rootSchema - The root schema that will be compared against the current one
1217
1257
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
1218
- */
1219
- doesSchemaUtilsDiffer(validator, rootSchema) {
1258
+ */;
1259
+ _proto.doesSchemaUtilsDiffer = function doesSchemaUtilsDiffer(validator, rootSchema) {
1220
1260
  if (!validator || !rootSchema) {
1221
1261
  return false;
1222
1262
  }
@@ -1227,10 +1267,12 @@ class SchemaUtils {
1227
1267
  *
1228
1268
  * @param schema - The schema for which the default state is desired
1229
1269
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1230
- * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1270
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults.
1271
+ * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
1272
+ * object properties.
1231
1273
  * @returns - The resulting `formData` with all the defaults provided
1232
- */
1233
- getDefaultFormState(schema, formData, includeUndefinedValues) {
1274
+ */;
1275
+ _proto.getDefaultFormState = function getDefaultFormState$1(schema, formData, includeUndefinedValues) {
1234
1276
  if (includeUndefinedValues === void 0) {
1235
1277
  includeUndefinedValues = false;
1236
1278
  }
@@ -1242,8 +1284,8 @@ class SchemaUtils {
1242
1284
  * @param schema - The schema for which the display label flag is desired
1243
1285
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1244
1286
  * @returns - True if the label should be displayed or false if it should not
1245
- */
1246
- getDisplayLabel(schema, uiSchema) {
1287
+ */;
1288
+ _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
1247
1289
  return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1248
1290
  }
1249
1291
  /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
@@ -1251,8 +1293,8 @@ class SchemaUtils {
1251
1293
  * @param formData - The current formData, if any, onto which to provide any missing defaults
1252
1294
  * @param options - The list of options to find a matching options from
1253
1295
  * @returns - The index of the matched option or 0 if none is available
1254
- */
1255
- getMatchingOption(formData, options) {
1296
+ */;
1297
+ _proto.getMatchingOption = function getMatchingOption$1(formData, options) {
1256
1298
  return getMatchingOption(this.validator, formData, options, this.rootSchema);
1257
1299
  }
1258
1300
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
@@ -1260,24 +1302,24 @@ class SchemaUtils {
1260
1302
  * @param schema - The schema for which check for array of files flag is desired
1261
1303
  * @param [uiSchema] - The UI schema from which to check the widget
1262
1304
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1263
- */
1264
- isFilesArray(schema, uiSchema) {
1305
+ */;
1306
+ _proto.isFilesArray = function isFilesArray$1(schema, uiSchema) {
1265
1307
  return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1266
1308
  }
1267
1309
  /** Checks to see if the `schema` combination represents a multi-select
1268
1310
  *
1269
1311
  * @param schema - The schema for which check for a multi-select flag is desired
1270
1312
  * @returns - True if schema contains a multi-select, otherwise false
1271
- */
1272
- isMultiSelect(schema) {
1313
+ */;
1314
+ _proto.isMultiSelect = function isMultiSelect$1(schema) {
1273
1315
  return isMultiSelect(this.validator, schema, this.rootSchema);
1274
1316
  }
1275
1317
  /** Checks to see if the `schema` combination represents a select
1276
1318
  *
1277
1319
  * @param schema - The schema for which check for a select flag is desired
1278
1320
  * @returns - True if schema contains a select, otherwise false
1279
- */
1280
- isSelect(schema) {
1321
+ */;
1322
+ _proto.isSelect = function isSelect$1(schema) {
1281
1323
  return isSelect(this.validator, schema, this.rootSchema);
1282
1324
  }
1283
1325
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
@@ -1288,8 +1330,8 @@ class SchemaUtils {
1288
1330
  * @param validationData - The current `ValidationData` into which to merge the additional errors
1289
1331
  * @param [additionalErrorSchema] - The additional set of errors
1290
1332
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1291
- */
1292
- mergeValidationData(validationData, additionalErrorSchema) {
1333
+ */;
1334
+ _proto.mergeValidationData = function mergeValidationData$1(validationData, additionalErrorSchema) {
1293
1335
  return mergeValidationData(this.validator, validationData, additionalErrorSchema);
1294
1336
  }
1295
1337
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
@@ -1299,8 +1341,8 @@ class SchemaUtils {
1299
1341
  * @param schema - The schema for which retrieving a schema is desired
1300
1342
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1301
1343
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1302
- */
1303
- retrieveSchema(schema, rawFormData) {
1344
+ */;
1345
+ _proto.retrieveSchema = function retrieveSchema$1(schema, rawFormData) {
1304
1346
  return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
1305
1347
  }
1306
1348
  /** Generates an `IdSchema` object for the `schema`, recursively
@@ -1311,8 +1353,8 @@ class SchemaUtils {
1311
1353
  * @param [idPrefix='root'] - The prefix to use for the id
1312
1354
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1313
1355
  * @returns - The `IdSchema` object for the `schema`
1314
- */
1315
- toIdSchema(schema, id, formData, idPrefix, idSeparator) {
1356
+ */;
1357
+ _proto.toIdSchema = function toIdSchema$1(schema, id, formData, idPrefix, idSeparator) {
1316
1358
  if (idPrefix === void 0) {
1317
1359
  idPrefix = "root";
1318
1360
  }
@@ -1327,11 +1369,12 @@ class SchemaUtils {
1327
1369
  * @param [name] - The base name for the schema
1328
1370
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1329
1371
  * @returns - The `PathSchema` object for the `schema`
1330
- */
1331
- toPathSchema(schema, name, formData) {
1372
+ */;
1373
+ _proto.toPathSchema = function toPathSchema$1(schema, name, formData) {
1332
1374
  return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
1333
- }
1334
- }
1375
+ };
1376
+ return SchemaUtils;
1377
+ }();
1335
1378
  /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
1336
1379
  * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
1337
1380
  *
@@ -1351,17 +1394,17 @@ function createSchemaUtils(validator, rootSchema) {
1351
1394
  */
1352
1395
  function dataURItoBlob(dataURI) {
1353
1396
  // Split metadata from data
1354
- const splitted = dataURI.split(",");
1397
+ var splitted = dataURI.split(",");
1355
1398
  // Split params
1356
- const params = splitted[0].split(";");
1399
+ var params = splitted[0].split(";");
1357
1400
  // Get mime-type from params
1358
- const type = params[0].replace("data:", "");
1401
+ var type = params[0].replace("data:", "");
1359
1402
  // Filter the name property from params
1360
- const properties = params.filter(param => {
1403
+ var properties = params.filter(function (param) {
1361
1404
  return param.split("=")[0] === "name";
1362
1405
  });
1363
1406
  // Look for the name and use unknown if no name property.
1364
- let name;
1407
+ var name;
1365
1408
  if (properties.length !== 1) {
1366
1409
  name = "unknown";
1367
1410
  } else {
@@ -1370,21 +1413,126 @@ function dataURItoBlob(dataURI) {
1370
1413
  name = properties[0].split("=")[1];
1371
1414
  }
1372
1415
  // Built the Uint8Array Blob parameter from the base64 string.
1373
- const binary = atob(splitted[1]);
1374
- const array = [];
1375
- for (let i = 0; i < binary.length; i++) {
1416
+ var binary = atob(splitted[1]);
1417
+ var array = [];
1418
+ for (var i = 0; i < binary.length; i++) {
1376
1419
  array.push(binary.charCodeAt(i));
1377
1420
  }
1378
1421
  // Create the blob object
1379
- const blob = new window.Blob([new Uint8Array(array)], {
1380
- type
1422
+ var blob = new window.Blob([new Uint8Array(array)], {
1423
+ type: type
1381
1424
  });
1382
1425
  return {
1383
- blob,
1384
- name
1426
+ blob: blob,
1427
+ name: name
1385
1428
  };
1386
1429
  }
1387
1430
 
1431
+ /** The `ErrorSchemaBuilder<T>` is used to build an `ErrorSchema<T>` since the definition of the `ErrorSchema` type is
1432
+ * designed for reading information rather than writing it. Use this class to add, replace or clear errors in an error
1433
+ * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
1434
+ * get the result and/or reset all the errors back to an initial set and start again.
1435
+ */
1436
+ var ErrorSchemaBuilder = /*#__PURE__*/function () {
1437
+ /** The error schema being built
1438
+ *
1439
+ * @private
1440
+ */
1441
+
1442
+ /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
1443
+ *
1444
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1445
+ */
1446
+ function ErrorSchemaBuilder(initialSchema) {
1447
+ this.errorSchema = {};
1448
+ this.resetAllErrors(initialSchema);
1449
+ }
1450
+ /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`
1451
+ */
1452
+ var _proto = ErrorSchemaBuilder.prototype;
1453
+ /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.
1454
+ *
1455
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1456
+ * @returns - The error block for the given `pathOfError` or the root if not provided
1457
+ * @private
1458
+ */
1459
+ _proto.getOrCreateErrorBlock = function getOrCreateErrorBlock(pathOfError) {
1460
+ var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
1461
+ var errorBlock = hasPath ? get__default["default"](this.errorSchema, pathOfError) : this.errorSchema;
1462
+ if (!errorBlock && pathOfError) {
1463
+ errorBlock = {};
1464
+ set__default["default"](this.errorSchema, pathOfError, errorBlock);
1465
+ }
1466
+ return errorBlock;
1467
+ }
1468
+ /** Resets all errors in the `ErrorSchemaBuilder` back to the `initialSchema` if provided, otherwise an empty set.
1469
+ *
1470
+ * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
1471
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1472
+ */;
1473
+ _proto.resetAllErrors = function resetAllErrors(initialSchema) {
1474
+ this.errorSchema = initialSchema ? cloneDeep__default["default"](initialSchema) : {};
1475
+ return this;
1476
+ }
1477
+ /** Adds the `errorOrList` to the list of errors in the `ErrorSchema` at either the root level or the location within
1478
+ * the schema described by the `pathOfError`. For more information about how to specify the path see the
1479
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1480
+ *
1481
+ * @param errorOrList - The error or list of errors to add into the `ErrorSchema`
1482
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
1483
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1484
+ */;
1485
+ _proto.addErrors = function addErrors(errorOrList, pathOfError) {
1486
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1487
+ var errorsList = get__default["default"](errorBlock, ERRORS_KEY);
1488
+ if (!Array.isArray(errorsList)) {
1489
+ errorsList = [];
1490
+ errorBlock[ERRORS_KEY] = errorsList;
1491
+ }
1492
+ if (Array.isArray(errorOrList)) {
1493
+ var _errorsList;
1494
+ (_errorsList = errorsList).push.apply(_errorsList, errorOrList);
1495
+ } else {
1496
+ errorsList.push(errorOrList);
1497
+ }
1498
+ return this;
1499
+ }
1500
+ /** Sets/replaces the `errorOrList` as the error(s) in the `ErrorSchema` at either the root level or the location
1501
+ * within the schema described by the `pathOfError`. For more information about how to specify the path see the
1502
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1503
+ *
1504
+ * @param errorOrList - The error or list of errors to set into the `ErrorSchema`
1505
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
1506
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1507
+ */;
1508
+ _proto.setErrors = function setErrors(errorOrList, pathOfError) {
1509
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1510
+ // Effectively clone the array being given to prevent accidental outside manipulation of the given list
1511
+ var listToAdd = Array.isArray(errorOrList) ? [].concat(errorOrList) : [errorOrList];
1512
+ set__default["default"](errorBlock, ERRORS_KEY, listToAdd);
1513
+ return this;
1514
+ }
1515
+ /** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
1516
+ * the `pathOfError`. For more information about how to specify the path see the
1517
+ * [eslint lodash plugin docs](https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/path-style.md).
1518
+ *
1519
+ * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
1520
+ * @returns - The `ErrorSchemaBuilder` object for chaining purposes
1521
+ */;
1522
+ _proto.clearErrors = function clearErrors(pathOfError) {
1523
+ var errorBlock = this.getOrCreateErrorBlock(pathOfError);
1524
+ set__default["default"](errorBlock, ERRORS_KEY, []);
1525
+ return this;
1526
+ };
1527
+ _createClass(ErrorSchemaBuilder, [{
1528
+ key: "ErrorSchema",
1529
+ get: function get() {
1530
+ return this.errorSchema;
1531
+ }
1532
+ }]);
1533
+ return ErrorSchemaBuilder;
1534
+ }();
1535
+
1388
1536
  /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
1389
1537
  * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
1390
1538
  *
@@ -1392,7 +1540,7 @@ function dataURItoBlob(dataURI) {
1392
1540
  * @returns - A range specification from the schema
1393
1541
  */
1394
1542
  function rangeSpec(schema) {
1395
- const spec = {};
1543
+ var spec = {};
1396
1544
  if (schema.multipleOf) {
1397
1545
  spec.step = schema.multipleOf;
1398
1546
  }
@@ -1420,10 +1568,9 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1420
1568
  if (autoDefaultStepAny === void 0) {
1421
1569
  autoDefaultStepAny = true;
1422
1570
  }
1423
- const inputProps = {
1424
- type: defaultType || "text",
1425
- ...rangeSpec(schema)
1426
- };
1571
+ var inputProps = _extends({
1572
+ type: defaultType || "text"
1573
+ }, rangeSpec(schema));
1427
1574
  // If options.inputType is set use that as the input type
1428
1575
  if (options.inputType) {
1429
1576
  inputProps.type = options.inputType;
@@ -1454,7 +1601,7 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1454
1601
 
1455
1602
  /** The default submit button options, exported for testing purposes
1456
1603
  */
1457
- const DEFAULT_OPTIONS = {
1604
+ var DEFAULT_OPTIONS = {
1458
1605
  props: {
1459
1606
  disabled: false
1460
1607
  },
@@ -1470,13 +1617,10 @@ function getSubmitButtonOptions(uiSchema) {
1470
1617
  if (uiSchema === void 0) {
1471
1618
  uiSchema = {};
1472
1619
  }
1473
- const uiOptions = getUiOptions(uiSchema);
1620
+ var uiOptions = getUiOptions(uiSchema);
1474
1621
  if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
1475
- const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1476
- return {
1477
- ...DEFAULT_OPTIONS,
1478
- ...options
1479
- };
1622
+ var options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1623
+ return _extends({}, DEFAULT_OPTIONS, options);
1480
1624
  }
1481
1625
  return DEFAULT_OPTIONS;
1482
1626
  }
@@ -1493,9 +1637,7 @@ function getTemplate(name, registry, uiOptions) {
1493
1637
  if (uiOptions === void 0) {
1494
1638
  uiOptions = {};
1495
1639
  }
1496
- const {
1497
- templates
1498
- } = registry;
1640
+ var templates = registry.templates;
1499
1641
  if (name === "ButtonTemplates") {
1500
1642
  return templates[name];
1501
1643
  }
@@ -1506,10 +1648,11 @@ function getTemplate(name, registry, uiOptions) {
1506
1648
  );
1507
1649
  }
1508
1650
 
1651
+ var _excluded = ["options"];
1509
1652
  /** The map of schema types to widget type to widget name
1510
1653
  */
1511
- const widgetMap = {
1512
- boolean: {
1654
+ var widgetMap = {
1655
+ "boolean": {
1513
1656
  checkbox: "CheckboxWidget",
1514
1657
  radio: "RadioWidget",
1515
1658
  select: "SelectWidget",
@@ -1567,22 +1710,16 @@ const widgetMap = {
1567
1710
  * @returns - The wrapper widget
1568
1711
  */
1569
1712
  function mergeWidgetOptions(AWidget) {
1570
- let MergedWidget = get__default["default"](AWidget, "MergedWidget");
1713
+ var MergedWidget = get__default["default"](AWidget, "MergedWidget");
1571
1714
  // cache return value as property of widget for proper react reconciliation
1572
1715
  if (!MergedWidget) {
1573
- const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1574
- MergedWidget = _ref => {
1575
- let {
1576
- options,
1577
- ...props
1578
- } = _ref;
1579
- return /*#__PURE__*/React__default["default"].createElement(AWidget, {
1580
- options: {
1581
- ...defaultOptions,
1582
- ...options
1583
- },
1584
- ...props
1585
- });
1716
+ var defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1717
+ MergedWidget = function MergedWidget(_ref) {
1718
+ var options = _ref.options,
1719
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
1720
+ return /*#__PURE__*/React__default["default"].createElement(AWidget, _extends({
1721
+ options: _extends({}, defaultOptions, options)
1722
+ }, props));
1586
1723
  };
1587
1724
  set__default["default"](AWidget, "MergedWidget", MergedWidget);
1588
1725
  }
@@ -1603,27 +1740,27 @@ function getWidget(schema, widget, registeredWidgets) {
1603
1740
  if (registeredWidgets === void 0) {
1604
1741
  registeredWidgets = {};
1605
1742
  }
1606
- const type = getSchemaType(schema);
1743
+ var type = getSchemaType(schema);
1607
1744
  if (typeof widget === "function" || widget && ReactIs__default["default"].isForwardRef( /*#__PURE__*/React__default["default"].createElement(widget)) || ReactIs__default["default"].isMemo(widget)) {
1608
1745
  return mergeWidgetOptions(widget);
1609
1746
  }
1610
1747
  if (typeof widget !== "string") {
1611
- throw new Error(`Unsupported widget definition: ${typeof widget}`);
1748
+ throw new Error("Unsupported widget definition: " + typeof widget);
1612
1749
  }
1613
1750
  if (widget in registeredWidgets) {
1614
- const registeredWidget = registeredWidgets[widget];
1751
+ var registeredWidget = registeredWidgets[widget];
1615
1752
  return getWidget(schema, registeredWidget, registeredWidgets);
1616
1753
  }
1617
1754
  if (typeof type === "string") {
1618
1755
  if (!(type in widgetMap)) {
1619
- throw new Error(`No widget for type '${type}'`);
1756
+ throw new Error("No widget for type '" + type + "'");
1620
1757
  }
1621
1758
  if (widget in widgetMap[type]) {
1622
- const registeredWidget = registeredWidgets[widgetMap[type][widget]];
1623
- return getWidget(schema, registeredWidget, registeredWidgets);
1759
+ var _registeredWidget = registeredWidgets[widgetMap[type][widget]];
1760
+ return getWidget(schema, _registeredWidget, registeredWidgets);
1624
1761
  }
1625
1762
  }
1626
- throw new Error(`No widget '${widget}' for type '${type}'`);
1763
+ throw new Error("No widget '" + widget + "' for type '" + type + "'");
1627
1764
  }
1628
1765
 
1629
1766
  /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
@@ -1642,7 +1779,7 @@ function hasWidget(schema, widget, registeredWidgets) {
1642
1779
  getWidget(schema, widget, registeredWidgets);
1643
1780
  return true;
1644
1781
  } catch (e) {
1645
- const err = e;
1782
+ var err = e;
1646
1783
  if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
1647
1784
  return false;
1648
1785
  }
@@ -1667,11 +1804,11 @@ function localToUTC(dateString) {
1667
1804
  * @throws - Error when the schema does not have a constant value
1668
1805
  */
1669
1806
  function toConstant(schema) {
1670
- if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
1671
- return schema.enum[0];
1807
+ if (ENUM_KEY in schema && Array.isArray(schema["enum"]) && schema["enum"].length === 1) {
1808
+ return schema["enum"][0];
1672
1809
  }
1673
1810
  if (CONST_KEY in schema) {
1674
- return schema.const;
1811
+ return schema["const"];
1675
1812
  }
1676
1813
  throw new Error("schema cannot be inferred as a constant");
1677
1814
  }
@@ -1687,28 +1824,28 @@ function toConstant(schema) {
1687
1824
  function optionsList(schema) {
1688
1825
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
1689
1826
  // Cast the type to include enumNames so the feature still works.
1690
- const schemaWithEnumNames = schema;
1827
+ var schemaWithEnumNames = schema;
1691
1828
  if (schemaWithEnumNames.enumNames && "development" !== "production") {
1692
1829
  console.warn("The enumNames property is deprecated and may be removed in a future major release.");
1693
1830
  }
1694
- if (schema.enum) {
1695
- return schema.enum.map((value, i) => {
1696
- const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
1831
+ if (schema["enum"]) {
1832
+ return schema["enum"].map(function (value, i) {
1833
+ var label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
1697
1834
  return {
1698
- label,
1699
- value
1835
+ label: label,
1836
+ value: value
1700
1837
  };
1701
1838
  });
1702
1839
  }
1703
- const altSchemas = schema.oneOf || schema.anyOf;
1704
- return altSchemas && altSchemas.map(aSchemaDef => {
1705
- const aSchema = aSchemaDef;
1706
- const value = toConstant(aSchema);
1707
- const label = aSchema.title || String(value);
1840
+ var altSchemas = schema.oneOf || schema.anyOf;
1841
+ return altSchemas && altSchemas.map(function (aSchemaDef) {
1842
+ var aSchema = aSchemaDef;
1843
+ var value = toConstant(aSchema);
1844
+ var label = aSchema.title || String(value);
1708
1845
  return {
1709
1846
  schema: aSchema,
1710
- label,
1711
- value
1847
+ label: label,
1848
+ value: value
1712
1849
  };
1713
1850
  });
1714
1851
  }
@@ -1727,27 +1864,35 @@ function orderProperties(properties, order) {
1727
1864
  if (!Array.isArray(order)) {
1728
1865
  return properties;
1729
1866
  }
1730
- const arrayToHash = arr => arr.reduce((prev, curr) => {
1731
- prev[curr] = true;
1732
- return prev;
1733
- }, {});
1734
- const errorPropList = arr => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
1735
- const propertyHash = arrayToHash(properties);
1736
- const orderFiltered = order.filter(prop => prop === "*" || propertyHash[prop]);
1737
- const orderHash = arrayToHash(orderFiltered);
1738
- const rest = properties.filter(prop => !orderHash[prop]);
1739
- const restIndex = orderFiltered.indexOf("*");
1867
+ var arrayToHash = function arrayToHash(arr) {
1868
+ return arr.reduce(function (prev, curr) {
1869
+ prev[curr] = true;
1870
+ return prev;
1871
+ }, {});
1872
+ };
1873
+ var errorPropList = function errorPropList(arr) {
1874
+ return arr.length > 1 ? "properties '" + arr.join("', '") + "'" : "property '" + arr[0] + "'";
1875
+ };
1876
+ var propertyHash = arrayToHash(properties);
1877
+ var orderFiltered = order.filter(function (prop) {
1878
+ return prop === "*" || propertyHash[prop];
1879
+ });
1880
+ var orderHash = arrayToHash(orderFiltered);
1881
+ var rest = properties.filter(function (prop) {
1882
+ return !orderHash[prop];
1883
+ });
1884
+ var restIndex = orderFiltered.indexOf("*");
1740
1885
  if (restIndex === -1) {
1741
1886
  if (rest.length) {
1742
- throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
1887
+ throw new Error("uiSchema order list does not contain " + errorPropList(rest));
1743
1888
  }
1744
1889
  return orderFiltered;
1745
1890
  }
1746
1891
  if (restIndex !== orderFiltered.lastIndexOf("*")) {
1747
1892
  throw new Error("uiSchema order list contains more than one wildcard item");
1748
1893
  }
1749
- const complete = [...orderFiltered];
1750
- complete.splice(restIndex, 1, ...rest);
1894
+ var complete = [].concat(orderFiltered);
1895
+ complete.splice.apply(complete, [restIndex, 1].concat(rest));
1751
1896
  return complete;
1752
1897
  }
1753
1898
 
@@ -1758,7 +1903,7 @@ function orderProperties(properties, order) {
1758
1903
  * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
1759
1904
  */
1760
1905
  function pad(num, width) {
1761
- let s = String(num);
1906
+ var s = String(num);
1762
1907
  while (s.length < width) {
1763
1908
  s = "0" + s;
1764
1909
  }
@@ -1786,7 +1931,7 @@ function parseDateString(dateString, includeTime) {
1786
1931
  second: includeTime ? -1 : 0
1787
1932
  };
1788
1933
  }
1789
- const date = new Date(dateString);
1934
+ var date = new Date(dateString);
1790
1935
  if (Number.isNaN(date.getTime())) {
1791
1936
  throw new Error("Unable to parse date " + dateString);
1792
1937
  }
@@ -1800,7 +1945,7 @@ function parseDateString(dateString, includeTime) {
1800
1945
  };
1801
1946
  }
1802
1947
 
1803
- const nums = /*#__PURE__*/new Set(["number", "integer"]);
1948
+ var nums = /*#__PURE__*/new Set(["number", "integer"]);
1804
1949
  /** Returns the real value for a select widget due to a silly limitation in the DOM which causes option change event
1805
1950
  * values to always be retrieved as strings. Uses the `schema` to help determine the value's true type. If the value is
1806
1951
  * an empty string, then the `emptyValue` from the `options` is returned, falling back to undefined.
@@ -1811,11 +1956,9 @@ const nums = /*#__PURE__*/new Set(["number", "integer"]);
1811
1956
  * @returns - The `value` converted to the proper type
1812
1957
  */
1813
1958
  function processSelectValue(schema, value, options) {
1814
- const {
1815
- enum: schemaEnum,
1816
- type,
1817
- items
1818
- } = schema;
1959
+ var schemaEnum = schema["enum"],
1960
+ type = schema.type,
1961
+ items = schema.items;
1819
1962
  if (value === "") {
1820
1963
  return options && options.emptyValue !== undefined ? options.emptyValue : undefined;
1821
1964
  }
@@ -1831,10 +1974,14 @@ function processSelectValue(schema, value, options) {
1831
1974
  // If type is undefined, but an enum is present, try and infer the type from
1832
1975
  // the enum values
1833
1976
  if (Array.isArray(schemaEnum)) {
1834
- if (schemaEnum.every(x => nums.has(guessType(x)))) {
1977
+ if (schemaEnum.every(function (x) {
1978
+ return nums.has(guessType(x));
1979
+ })) {
1835
1980
  return asNumber(value);
1836
1981
  }
1837
- if (schemaEnum.every(x => guessType(x) === "boolean")) {
1982
+ if (schemaEnum.every(function (x) {
1983
+ return guessType(x) === "boolean";
1984
+ })) {
1838
1985
  return value === "true";
1839
1986
  }
1840
1987
  }
@@ -1852,11 +1999,11 @@ function processSelectValue(schema, value, options) {
1852
1999
  */
1853
2000
  function schemaRequiresTrueValue(schema) {
1854
2001
  // Check if const is a truthy value
1855
- if (schema.const) {
2002
+ if (schema["const"]) {
1856
2003
  return true;
1857
2004
  }
1858
2005
  // Check if an enum has a single value of true
1859
- if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
2006
+ if (schema["enum"] && schema["enum"].length === 1 && schema["enum"][0] === true) {
1860
2007
  return true;
1861
2008
  }
1862
2009
  // If anyOf has a single value, evaluate the subschema
@@ -1869,7 +2016,9 @@ function schemaRequiresTrueValue(schema) {
1869
2016
  }
1870
2017
  // Evaluate each subschema in allOf, to see if one of them requires a true value
1871
2018
  if (schema.allOf) {
1872
- const schemaSome = subSchema => schemaRequiresTrueValue(subSchema);
2019
+ var schemaSome = function schemaSome(subSchema) {
2020
+ return schemaRequiresTrueValue(subSchema);
2021
+ };
1873
2022
  return schema.allOf.some(schemaSome);
1874
2023
  }
1875
2024
  return false;
@@ -1884,10 +2033,8 @@ function schemaRequiresTrueValue(schema) {
1884
2033
  * @returns - True if the component should be re-rendered, false otherwise
1885
2034
  */
1886
2035
  function shouldRender(component, nextProps, nextState) {
1887
- const {
1888
- props,
1889
- state
1890
- } = component;
2036
+ var props = component.props,
2037
+ state = component.state;
1891
2038
  return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
1892
2039
  }
1893
2040
 
@@ -1902,16 +2049,17 @@ function toDateString(dateObject, time) {
1902
2049
  if (time === void 0) {
1903
2050
  time = true;
1904
2051
  }
1905
- const {
1906
- year,
1907
- month,
1908
- day,
1909
- hour = 0,
1910
- minute = 0,
1911
- second = 0
1912
- } = dateObject;
1913
- const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
1914
- const datetime = new Date(utcTime).toJSON();
2052
+ var year = dateObject.year,
2053
+ month = dateObject.month,
2054
+ day = dateObject.day,
2055
+ _dateObject$hour = dateObject.hour,
2056
+ hour = _dateObject$hour === void 0 ? 0 : _dateObject$hour,
2057
+ _dateObject$minute = dateObject.minute,
2058
+ minute = _dateObject$minute === void 0 ? 0 : _dateObject$minute,
2059
+ _dateObject$second = dateObject.second,
2060
+ second = _dateObject$second === void 0 ? 0 : _dateObject$second;
2061
+ var utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
2062
+ var datetime = new Date(utcTime).toJSON();
1915
2063
  return time ? datetime : datetime.slice(0, 10);
1916
2064
  }
1917
2065
 
@@ -1929,15 +2077,15 @@ function utcToLocal(jsonDate) {
1929
2077
  // > should be a _valid local date and time string_ (not GMT)
1930
2078
  // Note - date constructor passed local ISO-8601 does not correctly
1931
2079
  // change time to UTC in node pre-8
1932
- const date = new Date(jsonDate);
1933
- const yyyy = pad(date.getFullYear(), 4);
1934
- const MM = pad(date.getMonth() + 1, 2);
1935
- const dd = pad(date.getDate(), 2);
1936
- const hh = pad(date.getHours(), 2);
1937
- const mm = pad(date.getMinutes(), 2);
1938
- const ss = pad(date.getSeconds(), 2);
1939
- const SSS = pad(date.getMilliseconds(), 3);
1940
- return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;
2080
+ var date = new Date(jsonDate);
2081
+ var yyyy = pad(date.getFullYear(), 4);
2082
+ var MM = pad(date.getMonth() + 1, 2);
2083
+ var dd = pad(date.getDate(), 2);
2084
+ var hh = pad(date.getHours(), 2);
2085
+ var mm = pad(date.getMinutes(), 2);
2086
+ var ss = pad(date.getSeconds(), 2);
2087
+ var SSS = pad(date.getMilliseconds(), 3);
2088
+ return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
1941
2089
  }
1942
2090
 
1943
2091
  exports.ADDITIONAL_PROPERTIES_KEY = ADDITIONAL_PROPERTIES_KEY;
@@ -1950,6 +2098,7 @@ exports.DEFINITIONS_KEY = DEFINITIONS_KEY;
1950
2098
  exports.DEPENDENCIES_KEY = DEPENDENCIES_KEY;
1951
2099
  exports.ENUM_KEY = ENUM_KEY;
1952
2100
  exports.ERRORS_KEY = ERRORS_KEY;
2101
+ exports.ErrorSchemaBuilder = ErrorSchemaBuilder;
1953
2102
  exports.ID_KEY = ID_KEY;
1954
2103
  exports.ITEMS_KEY = ITEMS_KEY;
1955
2104
  exports.NAME_KEY = NAME_KEY;