@rjsf/utils 5.9.0 → 5.11.1

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.
@@ -14,6 +14,7 @@ var isString = require('lodash/isString');
14
14
  var reduce = require('lodash/reduce');
15
15
  var times = require('lodash/times');
16
16
  var set = require('lodash/set');
17
+ var forEach = require('lodash/forEach');
17
18
  var mergeAllOf = require('json-schema-merge-allof');
18
19
  var union = require('lodash/union');
19
20
  var isEqual = require('lodash/isEqual');
@@ -23,7 +24,6 @@ var jsxRuntime = require('react/jsx-runtime');
23
24
  var react = require('react');
24
25
  var ReactIs = require('react-is');
25
26
  var toPath = require('lodash/toPath');
26
- var forEach = require('lodash/forEach');
27
27
 
28
28
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
29
29
 
@@ -39,13 +39,13 @@ var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
39
39
  var reduce__default = /*#__PURE__*/_interopDefaultLegacy(reduce);
40
40
  var times__default = /*#__PURE__*/_interopDefaultLegacy(times);
41
41
  var set__default = /*#__PURE__*/_interopDefaultLegacy(set);
42
+ var forEach__default = /*#__PURE__*/_interopDefaultLegacy(forEach);
42
43
  var mergeAllOf__default = /*#__PURE__*/_interopDefaultLegacy(mergeAllOf);
43
44
  var union__default = /*#__PURE__*/_interopDefaultLegacy(union);
44
45
  var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
45
46
  var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep);
46
47
  var ReactIs__default = /*#__PURE__*/_interopDefaultLegacy(ReactIs);
47
48
  var toPath__default = /*#__PURE__*/_interopDefaultLegacy(toPath);
48
- var forEach__default = /*#__PURE__*/_interopDefaultLegacy(forEach);
49
49
 
50
50
  /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
51
51
  * the type `object` but is NOT null, an array or a File.
@@ -107,103 +107,42 @@ function asNumber(value) {
107
107
  // specific precision or number of significant digits)
108
108
  return value;
109
109
  }
110
- var n = Number(value);
111
- var valid = typeof n === 'number' && !Number.isNaN(n);
110
+ const n = Number(value);
111
+ const valid = typeof n === 'number' && !Number.isNaN(n);
112
112
  return valid ? n : value;
113
113
  }
114
114
 
115
- function _defineProperties(target, props) {
116
- for (var i = 0; i < props.length; i++) {
117
- var descriptor = props[i];
118
- descriptor.enumerable = descriptor.enumerable || false;
119
- descriptor.configurable = true;
120
- if ("value" in descriptor) descriptor.writable = true;
121
- Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
122
- }
123
- }
124
- function _createClass(Constructor, protoProps, staticProps) {
125
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
126
- if (staticProps) _defineProperties(Constructor, staticProps);
127
- Object.defineProperty(Constructor, "prototype", {
128
- writable: false
129
- });
130
- return Constructor;
131
- }
132
- function _extends() {
133
- _extends = Object.assign ? Object.assign.bind() : function (target) {
134
- for (var i = 1; i < arguments.length; i++) {
135
- var source = arguments[i];
136
- for (var key in source) {
137
- if (Object.prototype.hasOwnProperty.call(source, key)) {
138
- target[key] = source[key];
139
- }
140
- }
141
- }
142
- return target;
143
- };
144
- return _extends.apply(this, arguments);
145
- }
146
- function _objectDestructuringEmpty(obj) {
147
- if (obj == null) throw new TypeError("Cannot destructure " + obj);
148
- }
149
- function _objectWithoutPropertiesLoose(source, excluded) {
150
- if (source == null) return {};
151
- var target = {};
152
- var sourceKeys = Object.keys(source);
153
- var key, i;
154
- for (i = 0; i < sourceKeys.length; i++) {
155
- key = sourceKeys[i];
156
- if (excluded.indexOf(key) >= 0) continue;
157
- target[key] = source[key];
158
- }
159
- return target;
160
- }
161
- function _toPrimitive(input, hint) {
162
- if (typeof input !== "object" || input === null) return input;
163
- var prim = input[Symbol.toPrimitive];
164
- if (prim !== undefined) {
165
- var res = prim.call(input, hint || "default");
166
- if (typeof res !== "object") return res;
167
- throw new TypeError("@@toPrimitive must return a primitive value.");
168
- }
169
- return (hint === "string" ? String : Number)(input);
170
- }
171
- function _toPropertyKey(arg) {
172
- var key = _toPrimitive(arg, "string");
173
- return typeof key === "symbol" ? key : String(key);
174
- }
175
-
176
115
  /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
177
116
  * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
178
117
  * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
179
118
  * utility.
180
119
  */
181
- var ADDITIONAL_PROPERTY_FLAG = '__additional_property';
182
- var ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';
183
- var ALL_OF_KEY = 'allOf';
184
- var ANY_OF_KEY = 'anyOf';
185
- var CONST_KEY = 'const';
186
- var DEFAULT_KEY = 'default';
187
- var DEFINITIONS_KEY = 'definitions';
188
- var DEPENDENCIES_KEY = 'dependencies';
189
- var ENUM_KEY = 'enum';
190
- var ERRORS_KEY = '__errors';
191
- var ID_KEY = '$id';
192
- var IF_KEY = 'if';
193
- var ITEMS_KEY = 'items';
194
- var JUNK_OPTION_ID = '_$junk_option_schema_id$_';
195
- var NAME_KEY = '$name';
196
- var ONE_OF_KEY = 'oneOf';
197
- var PROPERTIES_KEY = 'properties';
198
- var REQUIRED_KEY = 'required';
199
- var SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
200
- var REF_KEY = '$ref';
201
- var RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
202
- var ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
203
- var UI_FIELD_KEY = 'ui:field';
204
- var UI_WIDGET_KEY = 'ui:widget';
205
- var UI_OPTIONS_KEY = 'ui:options';
206
- var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
120
+ const ADDITIONAL_PROPERTY_FLAG = '__additional_property';
121
+ const ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';
122
+ const ALL_OF_KEY = 'allOf';
123
+ const ANY_OF_KEY = 'anyOf';
124
+ const CONST_KEY = 'const';
125
+ const DEFAULT_KEY = 'default';
126
+ const DEFINITIONS_KEY = 'definitions';
127
+ const DEPENDENCIES_KEY = 'dependencies';
128
+ const ENUM_KEY = 'enum';
129
+ const ERRORS_KEY = '__errors';
130
+ const ID_KEY = '$id';
131
+ const IF_KEY = 'if';
132
+ const ITEMS_KEY = 'items';
133
+ const JUNK_OPTION_ID = '_$junk_option_schema_id$_';
134
+ const NAME_KEY = '$name';
135
+ const ONE_OF_KEY = 'oneOf';
136
+ const PROPERTIES_KEY = 'properties';
137
+ const REQUIRED_KEY = 'required';
138
+ const SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
139
+ const REF_KEY = '$ref';
140
+ const RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
141
+ const ROOT_SCHEMA_PREFIX = '__rjsf_rootSchema';
142
+ const UI_FIELD_KEY = 'ui:field';
143
+ const UI_WIDGET_KEY = 'ui:widget';
144
+ const UI_OPTIONS_KEY = 'ui:options';
145
+ const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
207
146
 
208
147
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
209
148
  * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
@@ -212,27 +151,26 @@ var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
212
151
  * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
213
152
  * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
214
153
  */
215
- function getUiOptions(uiSchema, globalOptions) {
216
- if (uiSchema === void 0) {
217
- uiSchema = {};
218
- }
219
- if (globalOptions === void 0) {
220
- globalOptions = {};
221
- }
222
- return Object.keys(uiSchema).filter(function (key) {
223
- return key.indexOf('ui:') === 0;
224
- }).reduce(function (options, key) {
225
- var _extends2;
226
- var value = uiSchema[key];
154
+ function getUiOptions(uiSchema = {}, globalOptions = {}) {
155
+ return Object.keys(uiSchema).filter(key => key.indexOf('ui:') === 0).reduce((options, key) => {
156
+ const value = uiSchema[key];
227
157
  if (key === UI_WIDGET_KEY && isObject(value)) {
228
158
  console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');
229
159
  return options;
230
160
  }
231
161
  if (key === UI_OPTIONS_KEY && isObject(value)) {
232
- return _extends({}, options, value);
162
+ return {
163
+ ...options,
164
+ ...value
165
+ };
233
166
  }
234
- return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
235
- }, _extends({}, globalOptions));
167
+ return {
168
+ ...options,
169
+ [key.substring(3)]: value
170
+ };
171
+ }, {
172
+ ...globalOptions
173
+ });
236
174
  }
237
175
 
238
176
  /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
@@ -244,16 +182,13 @@ function getUiOptions(uiSchema, globalOptions) {
244
182
  * @param [formData] - The formData for the field
245
183
  * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
246
184
  */
247
- function canExpand(schema, uiSchema, formData) {
248
- if (uiSchema === void 0) {
249
- uiSchema = {};
250
- }
185
+ function canExpand(schema, uiSchema = {}, formData) {
251
186
  if (!schema.additionalProperties) {
252
187
  return false;
253
188
  }
254
- var _getUiOptions = getUiOptions(uiSchema),
255
- _getUiOptions$expanda = _getUiOptions.expandable,
256
- expandable = _getUiOptions$expanda === void 0 ? true : _getUiOptions$expanda;
189
+ const {
190
+ expandable = true
191
+ } = getUiOptions(uiSchema);
257
192
  if (expandable === false) {
258
193
  return expandable;
259
194
  }
@@ -271,21 +206,30 @@ function canExpand(schema, uiSchema, formData) {
271
206
  * @returns - A `FormValidation` object based on the `formData` structure
272
207
  */
273
208
  function createErrorHandler(formData) {
274
- var _handler;
275
- var handler = (_handler = {}, _handler[ERRORS_KEY] = [], _handler.addError = function addError(message) {
276
- this[ERRORS_KEY].push(message);
277
- }, _handler);
209
+ const handler = {
210
+ // We store the list of errors for this node in a property named __errors
211
+ // to avoid name collision with a possible sub schema field named
212
+ // 'errors' (see `utils.toErrorSchema`).
213
+ [ERRORS_KEY]: [],
214
+ addError(message) {
215
+ this[ERRORS_KEY].push(message);
216
+ }
217
+ };
278
218
  if (Array.isArray(formData)) {
279
- return formData.reduce(function (acc, value, key) {
280
- var _extends2;
281
- return _extends({}, acc, (_extends2 = {}, _extends2[key] = createErrorHandler(value), _extends2));
219
+ return formData.reduce((acc, value, key) => {
220
+ return {
221
+ ...acc,
222
+ [key]: createErrorHandler(value)
223
+ };
282
224
  }, handler);
283
225
  }
284
226
  if (isPlainObject__default["default"](formData)) {
285
- var formObject = formData;
286
- return Object.keys(formObject).reduce(function (acc, key) {
287
- var _extends3;
288
- return _extends({}, acc, (_extends3 = {}, _extends3[key] = createErrorHandler(formObject[key]), _extends3));
227
+ const formObject = formData;
228
+ return Object.keys(formObject).reduce((acc, key) => {
229
+ return {
230
+ ...acc,
231
+ [key]: createErrorHandler(formObject[key])
232
+ };
289
233
  }, handler);
290
234
  }
291
235
  return handler;
@@ -299,7 +243,7 @@ function createErrorHandler(formData) {
299
243
  * @returns - True if the `a` and `b` are deeply equal, false otherwise
300
244
  */
301
245
  function deepEquals(a, b) {
302
- return isEqualWith__default["default"](a, b, function (obj, other) {
246
+ return isEqualWith__default["default"](a, b, (obj, other) => {
303
247
  if (typeof obj === 'function' && typeof other === 'function') {
304
248
  // Assume all functions are equivalent
305
249
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
@@ -318,8 +262,8 @@ function deepEquals(a, b) {
318
262
  * value from `object[key]`
319
263
  */
320
264
  function splitKeyElementFromObject(key, object) {
321
- var value = object[key];
322
- var remaining = omit__default["default"](object, [key]);
265
+ const value = object[key];
266
+ const remaining = omit__default["default"](object, [key]);
323
267
  return [remaining, value];
324
268
  }
325
269
  /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
@@ -331,28 +275,26 @@ function splitKeyElementFromObject(key, object) {
331
275
  * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
332
276
  * @throws - Error indicating that no schema for that reference exists
333
277
  */
334
- function findSchemaDefinition($ref, rootSchema) {
335
- if (rootSchema === void 0) {
336
- rootSchema = {};
337
- }
338
- var ref = $ref || '';
278
+ function findSchemaDefinition($ref, rootSchema = {}) {
279
+ let ref = $ref || '';
339
280
  if (ref.startsWith('#')) {
340
281
  // Decode URI fragment representation.
341
282
  ref = decodeURIComponent(ref.substring(1));
342
283
  } else {
343
- throw new Error("Could not find a definition for " + $ref + ".");
284
+ throw new Error(`Could not find a definition for ${$ref}.`);
344
285
  }
345
- var current = jsonpointer__default["default"].get(rootSchema, ref);
286
+ const current = jsonpointer__default["default"].get(rootSchema, ref);
346
287
  if (current === undefined) {
347
- throw new Error("Could not find a definition for " + $ref + ".");
288
+ throw new Error(`Could not find a definition for ${$ref}.`);
348
289
  }
349
290
  if (current[REF_KEY]) {
350
- var _splitKeyElementFromO = splitKeyElementFromObject(REF_KEY, current),
351
- remaining = _splitKeyElementFromO[0],
352
- theRef = _splitKeyElementFromO[1];
353
- var subSchema = findSchemaDefinition(theRef, rootSchema);
291
+ const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
292
+ const subSchema = findSchemaDefinition(theRef, rootSchema);
354
293
  if (Object.keys(remaining).length > 0) {
355
- return _extends({}, remaining, subSchema);
294
+ return {
295
+ ...remaining,
296
+ ...subSchema
297
+ };
356
298
  }
357
299
  return subSchema;
358
300
  }
@@ -377,12 +319,12 @@ function getMatchingOption(validator, formData, options, rootSchema, discriminat
377
319
  if (formData === undefined) {
378
320
  return 0;
379
321
  }
380
- for (var i = 0; i < options.length; i++) {
381
- var option = options[i];
322
+ for (let i = 0; i < options.length; i++) {
323
+ const option = options[i];
382
324
  // If we have a discriminator field, then we will use this to make the determination
383
325
  if (discriminatorField && has__default["default"](option, [PROPERTIES_KEY, discriminatorField])) {
384
- var value = get__default["default"](formData, discriminatorField);
385
- var discriminator = get__default["default"](option, [PROPERTIES_KEY, discriminatorField], {});
326
+ const value = get__default["default"](formData, discriminatorField);
327
+ const discriminator = get__default["default"](option, [PROPERTIES_KEY, discriminatorField], {});
386
328
  if (validator.isValid(discriminator, value, rootSchema)) {
387
329
  return i;
388
330
  }
@@ -397,18 +339,18 @@ function getMatchingOption(validator, formData, options, rootSchema, discriminat
397
339
  //
398
340
  // Create an "anyOf" schema that requires at least one of the keys in the
399
341
  // "properties" object
400
- var requiresAnyOf = {
401
- anyOf: Object.keys(option[PROPERTIES_KEY]).map(function (key) {
402
- return {
403
- required: [key]
404
- };
405
- })
342
+ const requiresAnyOf = {
343
+ anyOf: Object.keys(option[PROPERTIES_KEY]).map(key => ({
344
+ required: [key]
345
+ }))
406
346
  };
407
- var augmentedSchema = void 0;
347
+ let augmentedSchema;
408
348
  // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
409
349
  if (option.anyOf) {
410
350
  // Create a shallow clone of the option
411
- var shallowClone = _extends({}, (_objectDestructuringEmpty(option), option));
351
+ const {
352
+ ...shallowClone
353
+ } = option;
412
354
  if (!shallowClone.allOf) {
413
355
  shallowClone.allOf = [];
414
356
  } else {
@@ -455,12 +397,12 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
455
397
  * @returns - The `discriminator.propertyName` if it exists in the schema, otherwise `undefined`
456
398
  */
457
399
  function getDiscriminatorFieldFromSchema(schema) {
458
- var discriminator;
459
- var maybeString = get__default["default"](schema, 'discriminator.propertyName', undefined);
400
+ let discriminator;
401
+ const maybeString = get__default["default"](schema, 'discriminator.propertyName', undefined);
460
402
  if (isString__default["default"](maybeString)) {
461
403
  discriminator = maybeString;
462
404
  } else if (maybeString !== undefined) {
463
- console.warn("Expecting discriminator to be a string, got \"" + typeof maybeString + "\" instead");
405
+ console.warn(`Expecting discriminator to be a string, got "${typeof maybeString}" instead`);
464
406
  }
465
407
  return discriminator;
466
408
  }
@@ -506,20 +448,20 @@ function guessType(value) {
506
448
  * @returns - The type of the schema
507
449
  */
508
450
  function getSchemaType(schema) {
509
- var type = schema.type;
510
- if (!type && schema["const"]) {
511
- return guessType(schema["const"]);
451
+ let {
452
+ type
453
+ } = schema;
454
+ if (!type && schema.const) {
455
+ return guessType(schema.const);
512
456
  }
513
- if (!type && schema["enum"]) {
457
+ if (!type && schema.enum) {
514
458
  return 'string';
515
459
  }
516
460
  if (!type && (schema.properties || schema.additionalProperties)) {
517
461
  return 'object';
518
462
  }
519
463
  if (Array.isArray(type) && type.length === 2 && type.includes('null')) {
520
- type = type.find(function (type) {
521
- return type !== 'null';
522
- });
464
+ type = type.find(type => type !== 'null');
523
465
  }
524
466
  return type;
525
467
  }
@@ -533,9 +475,9 @@ function getSchemaType(schema) {
533
475
  * @returns - The merged schema object
534
476
  */
535
477
  function mergeSchemas(obj1, obj2) {
536
- var acc = Object.assign({}, obj1); // Prevent mutation of source object.
537
- return Object.keys(obj2).reduce(function (acc, key) {
538
- var left = obj1 ? obj1[key] : {},
478
+ const acc = Object.assign({}, obj1); // Prevent mutation of source object.
479
+ return Object.keys(obj2).reduce((acc, key) => {
480
+ const left = obj1 ? obj1[key] : {},
539
481
  right = obj2[key];
540
482
  if (obj1 && key in obj1 && isObject(right)) {
541
483
  acc[key] = mergeSchemas(left, right);
@@ -549,11 +491,6 @@ function mergeSchemas(obj1, obj2) {
549
491
  }, acc);
550
492
  }
551
493
 
552
- var _excluded$1 = ["if", "then", "else"],
553
- _excluded2 = ["$ref"],
554
- _excluded3 = ["allOf"],
555
- _excluded4 = ["dependencies"],
556
- _excluded5 = ["oneOf"];
557
494
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
558
495
  * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
559
496
  * potentially recursive resolution.
@@ -564,10 +501,7 @@ var _excluded$1 = ["if", "then", "else"],
564
501
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
565
502
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
566
503
  */
567
- function retrieveSchema(validator, schema, rootSchema, rawFormData) {
568
- if (rootSchema === void 0) {
569
- rootSchema = {};
570
- }
504
+ function retrieveSchema(validator, schema, rootSchema = {}, rawFormData) {
571
505
  return retrieveSchemaInternal(validator, schema, rootSchema, rawFormData)[0];
572
506
  }
573
507
  /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
@@ -583,13 +517,15 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
583
517
  * @returns - A list of schemas with the appropriate conditions resolved, possibly with all branches expanded
584
518
  */
585
519
  function resolveCondition(validator, schema, rootSchema, expandAllBranches, formData) {
586
- var expression = schema["if"],
587
- then = schema.then,
588
- otherwise = schema["else"],
589
- resolvedSchemaLessConditional = _objectWithoutPropertiesLoose(schema, _excluded$1);
590
- var conditionValue = validator.isValid(expression, formData || {}, rootSchema);
591
- var resolvedSchemas = [resolvedSchemaLessConditional];
592
- var schemas = [];
520
+ const {
521
+ if: expression,
522
+ then,
523
+ else: otherwise,
524
+ ...resolvedSchemaLessConditional
525
+ } = schema;
526
+ const conditionValue = validator.isValid(expression, formData || {}, rootSchema);
527
+ let resolvedSchemas = [resolvedSchemaLessConditional];
528
+ let schemas = [];
593
529
  if (expandAllBranches) {
594
530
  if (then && typeof then !== 'boolean') {
595
531
  schemas = schemas.concat(retrieveSchemaInternal(validator, then, rootSchema, formData, expandAllBranches));
@@ -598,19 +534,15 @@ function resolveCondition(validator, schema, rootSchema, expandAllBranches, form
598
534
  schemas = schemas.concat(retrieveSchemaInternal(validator, otherwise, rootSchema, formData, expandAllBranches));
599
535
  }
600
536
  } else {
601
- var conditionalSchema = conditionValue ? then : otherwise;
537
+ const conditionalSchema = conditionValue ? then : otherwise;
602
538
  if (conditionalSchema && typeof conditionalSchema !== 'boolean') {
603
539
  schemas = schemas.concat(retrieveSchemaInternal(validator, conditionalSchema, rootSchema, formData, expandAllBranches));
604
540
  }
605
541
  }
606
542
  if (schemas.length) {
607
- resolvedSchemas = schemas.map(function (s) {
608
- return mergeSchemas(resolvedSchemaLessConditional, s);
609
- });
543
+ resolvedSchemas = schemas.map(s => mergeSchemas(resolvedSchemaLessConditional, s));
610
544
  }
611
- return resolvedSchemas.flatMap(function (s) {
612
- return retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches);
613
- });
545
+ return resolvedSchemas.flatMap(s => retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches));
614
546
  }
615
547
  /** Given a list of lists of allOf, anyOf or oneOf values, create a list of lists of all permutations of the values. The
616
548
  * `listOfLists` is expected to be all resolved values of the 1st...nth schemas within an `allOf`, `anyOf` or `oneOf`.
@@ -627,19 +559,13 @@ function resolveCondition(validator, schema, rootSchema, expandAllBranches, form
627
559
  * @returns - The list of all permutations of schemas for a set of `xxxOf`s
628
560
  */
629
561
  function getAllPermutationsOfXxxOf(listOfLists) {
630
- var allPermutations = listOfLists.reduce(function (permutations, list) {
562
+ const allPermutations = listOfLists.reduce((permutations, list) => {
631
563
  // When there are more than one set of schemas for a row, duplicate the set of permutations and add in the values
632
564
  if (list.length > 1) {
633
- return list.flatMap(function (element) {
634
- return times__default["default"](permutations.length, function (i) {
635
- return [].concat(permutations[i]).concat(element);
636
- });
637
- });
565
+ return list.flatMap(element => times__default["default"](permutations.length, i => [...permutations[i]].concat(element)));
638
566
  }
639
567
  // Otherwise just push in the single value into the current set of permutations
640
- permutations.forEach(function (permutation) {
641
- return permutation.push(list[0]);
642
- });
568
+ permutations.forEach(permutation => permutation.push(list[0]));
643
569
  return permutations;
644
570
  }, [[]] // Start with an empty list
645
571
  );
@@ -663,21 +589,18 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, formDat
663
589
  return resolveReference(validator, schema, rootSchema, expandAllBranches, formData);
664
590
  }
665
591
  if (DEPENDENCIES_KEY in schema) {
666
- var resolvedSchemas = resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData);
667
- return resolvedSchemas.flatMap(function (s) {
592
+ const resolvedSchemas = resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData);
593
+ return resolvedSchemas.flatMap(s => {
668
594
  return retrieveSchemaInternal(validator, s, rootSchema, formData, expandAllBranches);
669
595
  });
670
596
  }
671
597
  if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
672
- var allOfSchemaElements = schema.allOf.map(function (allOfSubschema) {
673
- return retrieveSchemaInternal(validator, allOfSubschema, rootSchema, formData, expandAllBranches);
674
- });
675
- var allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
676
- return allPermutations.map(function (permutation) {
677
- return _extends({}, schema, {
678
- allOf: permutation
679
- });
680
- });
598
+ const allOfSchemaElements = schema.allOf.map(allOfSubschema => retrieveSchemaInternal(validator, allOfSubschema, rootSchema, formData, expandAllBranches));
599
+ const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
600
+ return allPermutations.map(permutation => ({
601
+ ...schema,
602
+ allOf: permutation
603
+ }));
681
604
  }
682
605
  // No $ref or dependencies or allOf attribute was found, returning the original schema.
683
606
  return [schema];
@@ -695,12 +618,48 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, formDat
695
618
  */
696
619
  function resolveReference(validator, schema, rootSchema, expandAllBranches, formData) {
697
620
  // Drop the $ref property of the source schema.
698
- var $ref = schema.$ref,
699
- localSchema = _objectWithoutPropertiesLoose(schema, _excluded2);
621
+ const {
622
+ $ref,
623
+ ...localSchema
624
+ } = schema;
700
625
  // Retrieve the referenced schema definition.
701
- var refSchema = findSchemaDefinition($ref, rootSchema);
626
+ const refSchema = findSchemaDefinition($ref, rootSchema);
702
627
  // Update referenced schema definition with local schema properties.
703
- return retrieveSchemaInternal(validator, _extends({}, refSchema, localSchema), rootSchema, formData, expandAllBranches);
628
+ return retrieveSchemaInternal(validator, {
629
+ ...refSchema,
630
+ ...localSchema
631
+ }, rootSchema, formData, expandAllBranches);
632
+ }
633
+ /** Resolves all references within a schema's properties and array items.
634
+ *
635
+ * @param schema - The schema for which resolving all references is desired
636
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
637
+ * @returns - given schema will all references resolved
638
+ */
639
+ function resolveAllReferences(schema, rootSchema) {
640
+ let resolvedSchema = schema;
641
+ // resolve top level ref
642
+ if (REF_KEY in resolvedSchema) {
643
+ const {
644
+ $ref,
645
+ ...localSchema
646
+ } = resolvedSchema;
647
+ // Retrieve the referenced schema definition.
648
+ const refSchema = findSchemaDefinition($ref, rootSchema);
649
+ resolvedSchema = {
650
+ ...refSchema,
651
+ ...localSchema
652
+ };
653
+ }
654
+ if (PROPERTIES_KEY in resolvedSchema) {
655
+ forEach__default["default"](resolvedSchema[PROPERTIES_KEY], (value, key) => {
656
+ resolvedSchema[PROPERTIES_KEY][key] = resolveAllReferences(value, rootSchema);
657
+ });
658
+ }
659
+ if (ITEMS_KEY in resolvedSchema && !Array.isArray(resolvedSchema.items) && typeof resolvedSchema.items !== 'boolean') {
660
+ resolvedSchema.items = resolveAllReferences(resolvedSchema.items, rootSchema);
661
+ }
662
+ return resolvedSchema;
704
663
  }
705
664
  /** Creates new 'properties' items for each key in the `formData`
706
665
  *
@@ -712,28 +671,34 @@ function resolveReference(validator, schema, rootSchema, expandAllBranches, form
712
671
  */
713
672
  function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
714
673
  // Clone the schema so that we don't ruin the consumer's original
715
- var schema = _extends({}, theSchema, {
716
- properties: _extends({}, theSchema.properties)
717
- });
674
+ const schema = {
675
+ ...theSchema,
676
+ properties: {
677
+ ...theSchema.properties
678
+ }
679
+ };
718
680
  // make sure formData is an object
719
- var formData = aFormData && isObject(aFormData) ? aFormData : {};
720
- Object.keys(formData).forEach(function (key) {
681
+ const formData = aFormData && isObject(aFormData) ? aFormData : {};
682
+ Object.keys(formData).forEach(key => {
721
683
  if (key in schema.properties) {
722
684
  // No need to stub, our schema already has the property
723
685
  return;
724
686
  }
725
- var additionalProperties = {};
687
+ let additionalProperties = {};
726
688
  if (typeof schema.additionalProperties !== 'boolean') {
727
689
  if (REF_KEY in schema.additionalProperties) {
728
690
  additionalProperties = retrieveSchema(validator, {
729
691
  $ref: get__default["default"](schema.additionalProperties, [REF_KEY])
730
692
  }, rootSchema, formData);
731
693
  } else if ('type' in schema.additionalProperties) {
732
- additionalProperties = _extends({}, schema.additionalProperties);
694
+ additionalProperties = {
695
+ ...schema.additionalProperties
696
+ };
733
697
  } else if (ANY_OF_KEY in schema.additionalProperties || ONE_OF_KEY in schema.additionalProperties) {
734
- additionalProperties = _extends({
735
- type: 'object'
736
- }, schema.additionalProperties);
698
+ additionalProperties = {
699
+ type: 'object',
700
+ ...schema.additionalProperties
701
+ };
737
702
  } else {
738
703
  additionalProperties = {
739
704
  type: guessType(get__default["default"](formData, [key]))
@@ -765,36 +730,35 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
765
730
  * @returns - The schema(s) resulting from having its conditions, additional properties, references and dependencies
766
731
  * resolved. Multiple schemas may be returned if `expandAllBranches` is true.
767
732
  */
768
- function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches) {
769
- if (expandAllBranches === void 0) {
770
- expandAllBranches = false;
771
- }
733
+ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false) {
772
734
  if (!isObject(schema)) {
773
735
  return [{}];
774
736
  }
775
- var resolvedSchemas = resolveSchema(validator, schema, rootSchema, expandAllBranches, rawFormData);
776
- return resolvedSchemas.flatMap(function (s) {
777
- var resolvedSchema = s;
737
+ const resolvedSchemas = resolveSchema(validator, schema, rootSchema, expandAllBranches, rawFormData);
738
+ return resolvedSchemas.flatMap(s => {
739
+ let resolvedSchema = s;
778
740
  if (IF_KEY in resolvedSchema) {
779
741
  return resolveCondition(validator, resolvedSchema, rootSchema, expandAllBranches, rawFormData);
780
742
  }
781
- if (ALL_OF_KEY in schema) {
743
+ if (ALL_OF_KEY in resolvedSchema) {
744
+ // resolve allOf schemas
745
+ if (expandAllBranches) {
746
+ return [...resolvedSchema.allOf];
747
+ }
782
748
  try {
783
- resolvedSchema = mergeAllOf__default["default"](s, {
749
+ resolvedSchema = mergeAllOf__default["default"](resolvedSchema, {
784
750
  deep: false
785
751
  });
786
752
  } catch (e) {
787
753
  console.warn('could not merge subschemas in allOf:\n', e);
788
- var _resolvedSchema = resolvedSchema,
789
- allOf = _resolvedSchema.allOf,
790
- resolvedSchemaWithoutAllOf = _objectWithoutPropertiesLoose(_resolvedSchema, _excluded3);
791
- if (expandAllBranches && allOf) {
792
- return [resolvedSchemaWithoutAllOf].concat(allOf);
793
- }
754
+ const {
755
+ allOf,
756
+ ...resolvedSchemaWithoutAllOf
757
+ } = resolvedSchema;
794
758
  return resolvedSchemaWithoutAllOf;
795
759
  }
796
760
  }
797
- var hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
761
+ const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
798
762
  if (hasAdditionalProperties) {
799
763
  return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, rawFormData);
800
764
  }
@@ -814,29 +778,30 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
814
778
  * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true
815
779
  */
816
780
  function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranches, rawFormData) {
817
- var anyOrOneOf;
818
- if (Array.isArray(schema.oneOf)) {
819
- anyOrOneOf = schema.oneOf;
820
- } else if (Array.isArray(schema.anyOf)) {
821
- anyOrOneOf = schema.anyOf;
781
+ let anyOrOneOf;
782
+ const {
783
+ oneOf,
784
+ anyOf,
785
+ ...remaining
786
+ } = schema;
787
+ if (Array.isArray(oneOf)) {
788
+ anyOrOneOf = oneOf;
789
+ } else if (Array.isArray(anyOf)) {
790
+ anyOrOneOf = anyOf;
822
791
  }
823
792
  if (anyOrOneOf) {
824
793
  // Ensure that during expand all branches we pass an object rather than undefined so that all options are interrogated
825
- var formData = rawFormData === undefined && expandAllBranches ? {} : rawFormData;
826
- var discriminator = getDiscriminatorFieldFromSchema(schema);
827
- anyOrOneOf = anyOrOneOf.map(function (s) {
828
- if (REF_KEY in s) {
829
- // For this ref situation, don't expand all branches and just pick the first/only schema result
830
- return resolveReference(validator, s, rootSchema, false, formData)[0];
831
- }
832
- return s;
794
+ const formData = rawFormData === undefined && expandAllBranches ? {} : rawFormData;
795
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
796
+ anyOrOneOf = anyOrOneOf.map(s => {
797
+ return resolveAllReferences(s, rootSchema);
833
798
  });
834
799
  // Call this to trigger the set of isValid() calls that the schema parser will need
835
- var option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
800
+ const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
836
801
  if (expandAllBranches) {
837
- return anyOrOneOf;
802
+ return anyOrOneOf.map(item => mergeSchemas(remaining, item));
838
803
  }
839
- schema = anyOrOneOf[option];
804
+ schema = mergeSchemas(remaining, anyOrOneOf[option]);
840
805
  }
841
806
  return [schema];
842
807
  }
@@ -853,12 +818,12 @@ function resolveAnyOrOneOfSchemas(validator, schema, rootSchema, expandAllBranch
853
818
  */
854
819
  function resolveDependencies(validator, schema, rootSchema, expandAllBranches, formData) {
855
820
  // Drop the dependencies from the source schema.
856
- var dependencies = schema.dependencies,
857
- remainingSchema = _objectWithoutPropertiesLoose(schema, _excluded4);
858
- var resolvedSchemas = resolveAnyOrOneOfSchemas(validator, remainingSchema, rootSchema, expandAllBranches, formData);
859
- return resolvedSchemas.flatMap(function (resolvedSchema) {
860
- return processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData);
861
- });
821
+ const {
822
+ dependencies,
823
+ ...remainingSchema
824
+ } = schema;
825
+ const resolvedSchemas = resolveAnyOrOneOfSchemas(validator, remainingSchema, rootSchema, expandAllBranches, formData);
826
+ return resolvedSchemas.flatMap(resolvedSchema => processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData));
862
827
  }
863
828
  /** Processes all the `dependencies` recursively into the list of `resolvedSchema`s as needed. Passes the
864
829
  * `expandAllBranches` flag down to the `withDependentSchema()` and the recursive `processDependencies()` helper calls.
@@ -873,35 +838,24 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, f
873
838
  * @returns - The schema with the `dependencies` resolved into it
874
839
  */
875
840
  function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, formData) {
876
- var schemas = [resolvedSchema];
841
+ let schemas = [resolvedSchema];
877
842
  // Process dependencies updating the local schema properties as appropriate.
878
- var _loop = function _loop() {
843
+ for (const dependencyKey in dependencies) {
879
844
  // Skip this dependency if its trigger property is not present.
880
845
  if (!expandAllBranches && get__default["default"](formData, [dependencyKey]) === undefined) {
881
- return "continue";
846
+ continue;
882
847
  }
883
848
  // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)
884
849
  if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
885
- return "continue";
850
+ continue;
886
851
  }
887
- var _splitKeyElementFromO = splitKeyElementFromObject(dependencyKey, dependencies),
888
- remainingDependencies = _splitKeyElementFromO[0],
889
- dependencyValue = _splitKeyElementFromO[1];
852
+ const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(dependencyKey, dependencies);
890
853
  if (Array.isArray(dependencyValue)) {
891
854
  schemas[0] = withDependentProperties(resolvedSchema, dependencyValue);
892
855
  } else if (isObject(dependencyValue)) {
893
856
  schemas = withDependentSchema(validator, resolvedSchema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, formData);
894
857
  }
895
- return {
896
- v: schemas.flatMap(function (schema) {
897
- return processDependencies(validator, remainingDependencies, schema, rootSchema, expandAllBranches, formData);
898
- })
899
- };
900
- };
901
- for (var dependencyKey in dependencies) {
902
- var _ret = _loop();
903
- if (_ret === "continue") continue;
904
- if (typeof _ret === "object") return _ret.v;
858
+ return schemas.flatMap(schema => processDependencies(validator, remainingDependencies, schema, rootSchema, expandAllBranches, formData));
905
859
  }
906
860
  return schemas;
907
861
  }
@@ -915,10 +869,11 @@ function withDependentProperties(schema, additionallyRequired) {
915
869
  if (!additionallyRequired) {
916
870
  return schema;
917
871
  }
918
- var required = Array.isArray(schema.required) ? Array.from(new Set([].concat(schema.required, additionallyRequired))) : additionallyRequired;
919
- return _extends({}, schema, {
872
+ const required = Array.isArray(schema.required) ? Array.from(new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
873
+ return {
874
+ ...schema,
920
875
  required: required
921
- });
876
+ };
922
877
  }
923
878
  /** Merges a dependent schema into the `schema` dealing with oneOfs and references. Passes the `expandAllBranches` flag
924
879
  * down to the `retrieveSchemaInternal()`, `resolveReference()` and `withExactlyOneSubschema()` helper calls.
@@ -934,26 +889,26 @@ function withDependentProperties(schema, additionallyRequired) {
934
889
  * @returns - The list of schemas with the dependent schema resolved into them
935
890
  */
936
891
  function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, formData) {
937
- var dependentSchemas = retrieveSchemaInternal(validator, dependencyValue, rootSchema, formData, expandAllBranches);
938
- return dependentSchemas.flatMap(function (dependent) {
939
- var oneOf = dependent.oneOf,
940
- dependentSchema = _objectWithoutPropertiesLoose(dependent, _excluded5);
892
+ const dependentSchemas = retrieveSchemaInternal(validator, dependencyValue, rootSchema, formData, expandAllBranches);
893
+ return dependentSchemas.flatMap(dependent => {
894
+ const {
895
+ oneOf,
896
+ ...dependentSchema
897
+ } = dependent;
941
898
  schema = mergeSchemas(schema, dependentSchema);
942
899
  // Since it does not contain oneOf, we return the original schema.
943
900
  if (oneOf === undefined) {
944
901
  return schema;
945
902
  }
946
903
  // Resolve $refs inside oneOf.
947
- var resolvedOneOfs = oneOf.map(function (subschema) {
904
+ const resolvedOneOfs = oneOf.map(subschema => {
948
905
  if (typeof subschema === 'boolean' || !(REF_KEY in subschema)) {
949
906
  return [subschema];
950
907
  }
951
908
  return resolveReference(validator, subschema, rootSchema, expandAllBranches, formData);
952
909
  });
953
- var allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);
954
- return allPermutations.flatMap(function (resolvedOneOf) {
955
- return withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, resolvedOneOf, expandAllBranches, formData);
956
- });
910
+ const allPermutations = getAllPermutationsOfXxxOf(resolvedOneOfs);
911
+ return allPermutations.flatMap(resolvedOneOf => withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, resolvedOneOf, expandAllBranches, formData));
957
912
  });
958
913
  }
959
914
  /** Returns a list of `schema`s with the best choice from the `oneOf` options merged into it. If `expandAllBranches` is
@@ -971,16 +926,19 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
971
926
  * @returns - Either an array containing the best matching option or all options if `expandAllBranches` is true
972
927
  */
973
928
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, formData) {
974
- var validSubschemas = oneOf.filter(function (subschema) {
929
+ const validSubschemas = oneOf.filter(subschema => {
975
930
  if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
976
931
  return false;
977
932
  }
978
- var conditionPropertySchema = subschema.properties[dependencyKey];
933
+ const {
934
+ [dependencyKey]: conditionPropertySchema
935
+ } = subschema.properties;
979
936
  if (conditionPropertySchema) {
980
- var _properties;
981
- var conditionSchema = {
937
+ const conditionSchema = {
982
938
  type: 'object',
983
- properties: (_properties = {}, _properties[dependencyKey] = conditionPropertySchema, _properties)
939
+ properties: {
940
+ [dependencyKey]: conditionPropertySchema
941
+ }
984
942
  };
985
943
  return validator.isValid(conditionSchema, formData, rootSchema) || expandAllBranches;
986
944
  }
@@ -990,24 +948,22 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
990
948
  console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
991
949
  return [schema];
992
950
  }
993
- return validSubschemas.flatMap(function (s) {
994
- var subschema = s;
995
- var _splitKeyElementFromO2 = splitKeyElementFromObject(dependencyKey, subschema.properties),
996
- dependentSubschema = _splitKeyElementFromO2[0];
997
- var dependentSchema = _extends({}, subschema, {
951
+ return validSubschemas.flatMap(s => {
952
+ const subschema = s;
953
+ const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
954
+ const dependentSchema = {
955
+ ...subschema,
998
956
  properties: dependentSubschema
999
- });
1000
- var schemas = retrieveSchemaInternal(validator, dependentSchema, rootSchema, formData, expandAllBranches);
1001
- return schemas.map(function (s) {
1002
- return mergeSchemas(schema, s);
1003
- });
957
+ };
958
+ const schemas = retrieveSchemaInternal(validator, dependentSchema, rootSchema, formData, expandAllBranches);
959
+ return schemas.map(s => mergeSchemas(schema, s));
1004
960
  });
1005
961
  }
1006
962
 
1007
963
  /** A junk option used to determine when the getFirstMatchingOption call really matches an option rather than returning
1008
964
  * the first item
1009
965
  */
1010
- var JUNK_OPTION = {
966
+ const JUNK_OPTION = {
1011
967
  type: 'object',
1012
968
  $id: JUNK_OPTION_ID,
1013
969
  properties: {
@@ -1036,39 +992,38 @@ var JUNK_OPTION = {
1036
992
  * @param formData - The form data associated with the schema, used to calculate the score
1037
993
  * @returns - The score a schema against the formData
1038
994
  */
1039
- function calculateIndexScore(validator, rootSchema, schema, formData) {
1040
- if (formData === void 0) {
1041
- formData = {};
1042
- }
1043
- var totalScore = 0;
995
+ function calculateIndexScore(validator, rootSchema, schema, formData = {}) {
996
+ let totalScore = 0;
1044
997
  if (schema) {
1045
998
  if (isObject__default["default"](schema.properties)) {
1046
- totalScore += reduce__default["default"](schema.properties, function (score, value, key) {
1047
- var formValue = get__default["default"](formData, key);
999
+ totalScore += reduce__default["default"](schema.properties, (score, value, key) => {
1000
+ const formValue = get__default["default"](formData, key);
1048
1001
  if (typeof value === 'boolean') {
1049
1002
  return score;
1050
1003
  }
1051
1004
  if (has__default["default"](value, REF_KEY)) {
1052
- var newSchema = retrieveSchema(validator, value, rootSchema, formValue);
1005
+ const newSchema = retrieveSchema(validator, value, rootSchema, formValue);
1053
1006
  return score + calculateIndexScore(validator, rootSchema, newSchema, formValue || {});
1054
1007
  }
1055
- if (has__default["default"](value, ONE_OF_KEY) && formValue) {
1056
- return score + getClosestMatchingOption(validator, rootSchema, formValue, get__default["default"](value, ONE_OF_KEY));
1008
+ if ((has__default["default"](value, ONE_OF_KEY) || has__default["default"](value, ANY_OF_KEY)) && formValue) {
1009
+ const key = has__default["default"](value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
1010
+ const discriminator = getDiscriminatorFieldFromSchema(value);
1011
+ return score + getClosestMatchingOption(validator, rootSchema, formValue, get__default["default"](value, key), -1, discriminator);
1057
1012
  }
1058
1013
  if (value.type === 'object') {
1059
1014
  return score + calculateIndexScore(validator, rootSchema, value, formValue || {});
1060
1015
  }
1061
1016
  if (value.type === guessType(formValue)) {
1062
1017
  // If the types match, then we bump the score by one
1063
- var newScore = score + 1;
1064
- if (value["default"]) {
1018
+ let newScore = score + 1;
1019
+ if (value.default) {
1065
1020
  // If the schema contains a readonly default value score the value that matches the default higher and
1066
1021
  // any non-matching value lower
1067
- newScore += formValue === value["default"] ? 1 : -1;
1068
- } else if (value["const"]) {
1022
+ newScore += formValue === value.default ? 1 : -1;
1023
+ } else if (value.const) {
1069
1024
  // If the schema contains a const value score the value that matches the default higher and
1070
1025
  // any non-matching value lower
1071
- newScore += formValue === value["const"] ? 1 : -1;
1026
+ newScore += formValue === value.const ? 1 : -1;
1072
1027
  }
1073
1028
  // TODO eventually, deal with enums/arrays
1074
1029
  return newScore;
@@ -1103,14 +1058,15 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
1103
1058
  * determine which option is selected
1104
1059
  * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match
1105
1060
  */
1106
- function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption, discriminatorField) {
1107
- if (selectedOption === void 0) {
1108
- selectedOption = -1;
1109
- }
1061
+ function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField) {
1062
+ // First resolve any refs in the options
1063
+ const resolvedOptions = options.map(option => {
1064
+ return resolveAllReferences(option, rootSchema);
1065
+ });
1110
1066
  // Reduce the array of options down to a list of the indexes that are considered matching options
1111
- var allValidIndexes = options.reduce(function (validList, option, index) {
1112
- var testOptions = [JUNK_OPTION, option];
1113
- var match = getFirstMatchingOption(validator, formData, testOptions, rootSchema, discriminatorField);
1067
+ const allValidIndexes = resolvedOptions.reduce((validList, option, index) => {
1068
+ const testOptions = [JUNK_OPTION, option];
1069
+ const match = getFirstMatchingOption(validator, formData, testOptions, rootSchema, discriminatorField);
1114
1070
  // The match is the real option, so add its index to list of valid indexes
1115
1071
  if (match === 1) {
1116
1072
  validList.push(index);
@@ -1123,32 +1079,30 @@ function getClosestMatchingOption(validator, rootSchema, formData, options, sele
1123
1079
  }
1124
1080
  if (!allValidIndexes.length) {
1125
1081
  // No indexes were valid, so we'll score all the options, add all the indexes
1126
- times__default["default"](options.length, function (i) {
1127
- return allValidIndexes.push(i);
1128
- });
1082
+ times__default["default"](resolvedOptions.length, i => allValidIndexes.push(i));
1129
1083
  }
1130
- var scoreCount = new Set();
1084
+ const scoreCount = new Set();
1131
1085
  // Score all the options in the list of valid indexes and return the index with the best score
1132
- var _allValidIndexes$redu = allValidIndexes.reduce(function (scoreData, index) {
1133
- var bestScore = scoreData.bestScore;
1134
- var option = options[index];
1135
- if (has__default["default"](option, REF_KEY)) {
1136
- option = retrieveSchema(validator, option, rootSchema, formData);
1137
- }
1138
- var score = calculateIndexScore(validator, rootSchema, option, formData);
1139
- scoreCount.add(score);
1140
- if (score > bestScore) {
1141
- return {
1142
- bestIndex: index,
1143
- bestScore: score
1144
- };
1145
- }
1146
- return scoreData;
1147
- }, {
1148
- bestIndex: selectedOption,
1149
- bestScore: 0
1150
- }),
1151
- bestIndex = _allValidIndexes$redu.bestIndex;
1086
+ const {
1087
+ bestIndex
1088
+ } = allValidIndexes.reduce((scoreData, index) => {
1089
+ const {
1090
+ bestScore
1091
+ } = scoreData;
1092
+ const option = resolvedOptions[index];
1093
+ const score = calculateIndexScore(validator, rootSchema, option, formData);
1094
+ scoreCount.add(score);
1095
+ if (score > bestScore) {
1096
+ return {
1097
+ bestIndex: index,
1098
+ bestScore: score
1099
+ };
1100
+ }
1101
+ return scoreData;
1102
+ }, {
1103
+ bestIndex: selectedOption,
1104
+ bestScore: 0
1105
+ });
1152
1106
  // if all scores are the same go with selectedOption
1153
1107
  if (scoreCount.size === 1 && selectedOption >= 0) {
1154
1108
  return selectedOption;
@@ -1163,9 +1117,7 @@ function getClosestMatchingOption(validator, rootSchema, formData, options, sele
1163
1117
  * @returns - True if there are fixed items in the schema, false otherwise
1164
1118
  */
1165
1119
  function isFixedItems(schema) {
1166
- return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(function (item) {
1167
- return isObject(item);
1168
- });
1120
+ return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(item => isObject(item));
1169
1121
  }
1170
1122
 
1171
1123
  /** Merges the `defaults` object of type `T` into the `formData` of type `T`
@@ -1184,13 +1136,10 @@ function isFixedItems(schema) {
1184
1136
  * @param [mergeExtraArrayDefaults=false] - If true, any additional default array entries are appended onto the formData
1185
1137
  * @returns - The resulting merged form data with defaults
1186
1138
  */
1187
- function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults) {
1188
- if (mergeExtraArrayDefaults === void 0) {
1189
- mergeExtraArrayDefaults = false;
1190
- }
1139
+ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false) {
1191
1140
  if (Array.isArray(formData)) {
1192
- var defaultsArray = Array.isArray(defaults) ? defaults : [];
1193
- var mapped = formData.map(function (value, idx) {
1141
+ const defaultsArray = Array.isArray(defaults) ? defaults : [];
1142
+ const mapped = formData.map((value, idx) => {
1194
1143
  if (defaultsArray[idx]) {
1195
1144
  return mergeDefaultsWithFormData(defaultsArray[idx], value, mergeExtraArrayDefaults);
1196
1145
  }
@@ -1198,13 +1147,13 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults)
1198
1147
  });
1199
1148
  // Merge any extra defaults when mergeExtraArrayDefaults is true
1200
1149
  if (mergeExtraArrayDefaults && mapped.length < defaultsArray.length) {
1201
- mapped.push.apply(mapped, defaultsArray.slice(mapped.length));
1150
+ mapped.push(...defaultsArray.slice(mapped.length));
1202
1151
  }
1203
1152
  return mapped;
1204
1153
  }
1205
1154
  if (isObject(formData)) {
1206
- var acc = Object.assign({}, defaults); // Prevent mutation of source object.
1207
- return Object.keys(formData).reduce(function (acc, key) {
1155
+ const acc = Object.assign({}, defaults); // Prevent mutation of source object.
1156
+ return Object.keys(formData).reduce((acc, key) => {
1208
1157
  acc[key] = mergeDefaultsWithFormData(defaults ? get__default["default"](defaults, key) : {}, get__default["default"](formData, key), mergeExtraArrayDefaults);
1209
1158
  return acc;
1210
1159
  }, acc);
@@ -1221,19 +1170,16 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults)
1221
1170
  * NOTE: Uses shallow comparison for the duplicate checking.
1222
1171
  * @returns - A new object that is the merge of the two given objects
1223
1172
  */
1224
- function mergeObjects(obj1, obj2, concatArrays) {
1225
- if (concatArrays === void 0) {
1226
- concatArrays = false;
1227
- }
1228
- return Object.keys(obj2).reduce(function (acc, key) {
1229
- var left = obj1 ? obj1[key] : {},
1173
+ function mergeObjects(obj1, obj2, concatArrays = false) {
1174
+ return Object.keys(obj2).reduce((acc, key) => {
1175
+ const left = obj1 ? obj1[key] : {},
1230
1176
  right = obj2[key];
1231
1177
  if (obj1 && key in obj1 && isObject(right)) {
1232
1178
  acc[key] = mergeObjects(left, right, concatArrays);
1233
1179
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
1234
- var toMerge = right;
1180
+ let toMerge = right;
1235
1181
  if (concatArrays === 'preventDuplicates') {
1236
- toMerge = right.reduce(function (result, value) {
1182
+ toMerge = right.reduce((result, value) => {
1237
1183
  if (!left.includes(value)) {
1238
1184
  result.push(value);
1239
1185
  }
@@ -1255,7 +1201,7 @@ function mergeObjects(obj1, obj2, concatArrays) {
1255
1201
  * @returns - True if the `schema` has a single constant value, false otherwise
1256
1202
  */
1257
1203
  function isConstant(schema) {
1258
- return Array.isArray(schema["enum"]) && schema["enum"].length === 1 || CONST_KEY in schema;
1204
+ return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
1259
1205
  }
1260
1206
 
1261
1207
  /** Checks to see if the `schema` combination represents a select
@@ -1265,19 +1211,14 @@ function isConstant(schema) {
1265
1211
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1266
1212
  * @returns - True if schema contains a select, otherwise false
1267
1213
  */
1268
- function isSelect(validator, theSchema, rootSchema) {
1269
- if (rootSchema === void 0) {
1270
- rootSchema = {};
1271
- }
1272
- var schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
1273
- var altSchemas = schema.oneOf || schema.anyOf;
1274
- if (Array.isArray(schema["enum"])) {
1214
+ function isSelect(validator, theSchema, rootSchema = {}) {
1215
+ const schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
1216
+ const altSchemas = schema.oneOf || schema.anyOf;
1217
+ if (Array.isArray(schema.enum)) {
1275
1218
  return true;
1276
1219
  }
1277
1220
  if (Array.isArray(altSchemas)) {
1278
- return altSchemas.every(function (altSchemas) {
1279
- return typeof altSchemas !== 'boolean' && isConstant(altSchemas);
1280
- });
1221
+ return altSchemas.every(altSchemas => typeof altSchemas !== 'boolean' && isConstant(altSchemas));
1281
1222
  }
1282
1223
  return false;
1283
1224
  }
@@ -1319,16 +1260,10 @@ var AdditionalItemsHandling;
1319
1260
  * @param [idx=-1] - Index, if non-negative, will be used to return the idx-th element in a `schema.items` array
1320
1261
  * @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers
1321
1262
  */
1322
- function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
1323
- if (additionalItems === void 0) {
1324
- additionalItems = AdditionalItemsHandling.Ignore;
1325
- }
1326
- if (idx === void 0) {
1327
- idx = -1;
1328
- }
1263
+ function getInnerSchemaForArrayItem(schema, additionalItems = AdditionalItemsHandling.Ignore, idx = -1) {
1329
1264
  if (idx >= 0) {
1330
1265
  if (Array.isArray(schema.items) && idx < schema.items.length) {
1331
- var item = schema.items[idx];
1266
+ const item = schema.items[idx];
1332
1267
  if (typeof item !== 'boolean') {
1333
1268
  return item;
1334
1269
  }
@@ -1360,23 +1295,17 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
1360
1295
  * @param experimental_defaultFormStateBehavior - Optional configuration object, if provided, allows users to override
1361
1296
  * default form state behavior
1362
1297
  */
1363
- function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields, experimental_defaultFormStateBehavior) {
1364
- if (requiredFields === void 0) {
1365
- requiredFields = [];
1366
- }
1367
- if (experimental_defaultFormStateBehavior === void 0) {
1368
- experimental_defaultFormStateBehavior = {};
1369
- }
1370
- var _experimental_default = experimental_defaultFormStateBehavior,
1371
- _experimental_default2 = _experimental_default.emptyObjectFields,
1372
- emptyObjectFields = _experimental_default2 === void 0 ? 'populateAllDefaults' : _experimental_default2;
1298
+ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}) {
1299
+ const {
1300
+ emptyObjectFields = 'populateAllDefaults'
1301
+ } = experimental_defaultFormStateBehavior;
1373
1302
  if (includeUndefinedValues) {
1374
1303
  obj[key] = computedDefault;
1375
1304
  } else if (emptyObjectFields !== 'skipDefaults') {
1376
1305
  if (isObject(computedDefault)) {
1377
1306
  // If isParentRequired is undefined, then we are at the root level of the schema so defer to the requiredness of
1378
1307
  // the field key itself in the `requiredField` list
1379
- var isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;
1308
+ const isSelfOrParentRequired = isParentRequired === undefined ? requiredFields.includes(key) : isParentRequired;
1380
1309
  // Store computedDefault if it's a non-empty object(e.g. not {}) and satisfies certain conditions
1381
1310
  // Condition 1: If computedDefault is not empty or if the key is a required field
1382
1311
  // Condition 2: If the parent object is required or emptyObjectFields is not 'populateRequiredDefaults'
@@ -1409,94 +1338,98 @@ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValu
1409
1338
  * @param [props.required] - Optional flag, if true, indicates this schema was required in the parent schema.
1410
1339
  * @returns - The resulting `formData` with all the defaults provided
1411
1340
  */
1412
- function computeDefaults(validator, rawSchema, _temp) {
1413
- var _ref = _temp === void 0 ? {} : _temp,
1414
- parentDefaults = _ref.parentDefaults,
1415
- rawFormData = _ref.rawFormData,
1416
- _ref$rootSchema = _ref.rootSchema,
1417
- rootSchema = _ref$rootSchema === void 0 ? {} : _ref$rootSchema,
1418
- _ref$includeUndefined = _ref.includeUndefinedValues,
1419
- includeUndefinedValues = _ref$includeUndefined === void 0 ? false : _ref$includeUndefined,
1420
- _ref$_recurseList = _ref._recurseList,
1421
- _recurseList = _ref$_recurseList === void 0 ? [] : _ref$_recurseList,
1422
- _ref$experimental_def = _ref.experimental_defaultFormStateBehavior,
1423
- experimental_defaultFormStateBehavior = _ref$experimental_def === void 0 ? undefined : _ref$experimental_def,
1424
- required = _ref.required;
1425
- var formData = isObject(rawFormData) ? rawFormData : {};
1426
- var schema = isObject(rawSchema) ? rawSchema : {};
1341
+ function computeDefaults(validator, rawSchema, {
1342
+ parentDefaults,
1343
+ rawFormData,
1344
+ rootSchema = {},
1345
+ includeUndefinedValues = false,
1346
+ _recurseList = [],
1347
+ experimental_defaultFormStateBehavior = undefined,
1348
+ required
1349
+ } = {}) {
1350
+ const formData = isObject(rawFormData) ? rawFormData : {};
1351
+ const schema = isObject(rawSchema) ? rawSchema : {};
1427
1352
  // Compute the defaults recursively: give highest priority to deepest nodes.
1428
- var defaults = parentDefaults;
1353
+ let defaults = parentDefaults;
1429
1354
  // If we get a new schema, then we need to recompute defaults again for the new schema found.
1430
- var schemaToCompute = null;
1431
- var updatedRecurseList = _recurseList;
1432
- if (isObject(defaults) && isObject(schema["default"])) {
1355
+ let schemaToCompute = null;
1356
+ let updatedRecurseList = _recurseList;
1357
+ if (isObject(defaults) && isObject(schema.default)) {
1433
1358
  // For object defaults, only override parent defaults that are defined in
1434
1359
  // schema.default.
1435
- defaults = mergeObjects(defaults, schema["default"]);
1360
+ defaults = mergeObjects(defaults, schema.default);
1436
1361
  } else if (DEFAULT_KEY in schema) {
1437
- defaults = schema["default"];
1362
+ defaults = schema.default;
1438
1363
  } else if (REF_KEY in schema) {
1439
- var refName = schema[REF_KEY];
1364
+ const refName = schema[REF_KEY];
1440
1365
  // Use referenced schema defaults for this node.
1441
1366
  if (!_recurseList.includes(refName)) {
1442
1367
  updatedRecurseList = _recurseList.concat(refName);
1443
1368
  schemaToCompute = findSchemaDefinition(refName, rootSchema);
1444
1369
  }
1445
1370
  } else if (DEPENDENCIES_KEY in schema) {
1446
- var resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, formData);
1371
+ const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, formData);
1447
1372
  schemaToCompute = resolvedSchema[0]; // pick the first element from resolve dependencies
1448
1373
  } else if (isFixedItems(schema)) {
1449
- defaults = schema.items.map(function (itemSchema, idx) {
1450
- return computeDefaults(validator, itemSchema, {
1451
- rootSchema: rootSchema,
1452
- includeUndefinedValues: includeUndefinedValues,
1453
- _recurseList: _recurseList,
1454
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1455
- parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined,
1456
- rawFormData: formData,
1457
- required: required
1458
- });
1459
- });
1374
+ defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, {
1375
+ rootSchema,
1376
+ includeUndefinedValues,
1377
+ _recurseList,
1378
+ experimental_defaultFormStateBehavior,
1379
+ parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined,
1380
+ rawFormData: formData,
1381
+ required
1382
+ }));
1460
1383
  } else if (ONE_OF_KEY in schema) {
1461
- if (schema.oneOf.length === 0) {
1384
+ const {
1385
+ oneOf,
1386
+ ...remaining
1387
+ } = schema;
1388
+ if (oneOf.length === 0) {
1462
1389
  return undefined;
1463
1390
  }
1464
- var discriminator = getDiscriminatorFieldFromSchema(schema);
1465
- schemaToCompute = schema.oneOf[getClosestMatchingOption(validator, rootSchema, isEmpty__default["default"](formData) ? undefined : formData, schema.oneOf, 0, discriminator)];
1391
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1392
+ schemaToCompute = oneOf[getClosestMatchingOption(validator, rootSchema, isEmpty__default["default"](formData) ? undefined : formData, oneOf, 0, discriminator)];
1393
+ schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1466
1394
  } else if (ANY_OF_KEY in schema) {
1467
- if (schema.anyOf.length === 0) {
1395
+ const {
1396
+ anyOf,
1397
+ ...remaining
1398
+ } = schema;
1399
+ if (anyOf.length === 0) {
1468
1400
  return undefined;
1469
1401
  }
1470
- var _discriminator = getDiscriminatorFieldFromSchema(schema);
1471
- schemaToCompute = schema.anyOf[getClosestMatchingOption(validator, rootSchema, isEmpty__default["default"](formData) ? undefined : formData, schema.anyOf, 0, _discriminator)];
1402
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1403
+ schemaToCompute = anyOf[getClosestMatchingOption(validator, rootSchema, isEmpty__default["default"](formData) ? undefined : formData, anyOf, 0, discriminator)];
1404
+ schemaToCompute = mergeSchemas(remaining, schemaToCompute);
1472
1405
  }
1473
1406
  if (schemaToCompute) {
1474
1407
  return computeDefaults(validator, schemaToCompute, {
1475
- rootSchema: rootSchema,
1476
- includeUndefinedValues: includeUndefinedValues,
1408
+ rootSchema,
1409
+ includeUndefinedValues,
1477
1410
  _recurseList: updatedRecurseList,
1478
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1411
+ experimental_defaultFormStateBehavior,
1479
1412
  parentDefaults: defaults,
1480
1413
  rawFormData: formData,
1481
- required: required
1414
+ required
1482
1415
  });
1483
1416
  }
1484
1417
  // No defaults defined for this node, fallback to generic typed ones.
1485
1418
  if (defaults === undefined) {
1486
- defaults = schema["default"];
1419
+ defaults = schema.default;
1487
1420
  }
1488
1421
  switch (getSchemaType(schema)) {
1489
1422
  // We need to recurse for object schema inner default values.
1490
1423
  case 'object':
1491
1424
  {
1492
- var objectDefaults = Object.keys(schema.properties || {}).reduce(function (acc, key) {
1425
+ const objectDefaults = Object.keys(schema.properties || {}).reduce((acc, key) => {
1493
1426
  var _schema$required;
1494
1427
  // Compute the defaults for this node, with the parent defaults we might
1495
1428
  // have from a previous run: defaults[key].
1496
- var computedDefault = computeDefaults(validator, get__default["default"](schema, [PROPERTIES_KEY, key]), {
1497
- rootSchema: rootSchema,
1498
- _recurseList: _recurseList,
1499
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1429
+ const computedDefault = computeDefaults(validator, get__default["default"](schema, [PROPERTIES_KEY, key]), {
1430
+ rootSchema,
1431
+ _recurseList,
1432
+ experimental_defaultFormStateBehavior,
1500
1433
  includeUndefinedValues: includeUndefinedValues === true,
1501
1434
  parentDefaults: get__default["default"](defaults, [key]),
1502
1435
  rawFormData: get__default["default"](formData, [key]),
@@ -1507,31 +1440,25 @@ function computeDefaults(validator, rawSchema, _temp) {
1507
1440
  }, {});
1508
1441
  if (schema.additionalProperties) {
1509
1442
  // as per spec additionalProperties may be either schema or boolean
1510
- var additionalPropertiesSchema = isObject(schema.additionalProperties) ? schema.additionalProperties : {};
1511
- var keys = new Set();
1443
+ const additionalPropertiesSchema = isObject(schema.additionalProperties) ? schema.additionalProperties : {};
1444
+ const keys = new Set();
1512
1445
  if (isObject(defaults)) {
1513
- Object.keys(defaults).filter(function (key) {
1514
- return !schema.properties || !schema.properties[key];
1515
- }).forEach(function (key) {
1516
- return keys.add(key);
1517
- });
1446
+ Object.keys(defaults).filter(key => !schema.properties || !schema.properties[key]).forEach(key => keys.add(key));
1518
1447
  }
1519
- var formDataRequired;
1448
+ let formDataRequired;
1520
1449
  if (isObject(formData)) {
1521
1450
  formDataRequired = [];
1522
- Object.keys(formData).filter(function (key) {
1523
- return !schema.properties || !schema.properties[key];
1524
- }).forEach(function (key) {
1451
+ Object.keys(formData).filter(key => !schema.properties || !schema.properties[key]).forEach(key => {
1525
1452
  keys.add(key);
1526
1453
  formDataRequired.push(key);
1527
1454
  });
1528
1455
  }
1529
- keys.forEach(function (key) {
1456
+ keys.forEach(key => {
1530
1457
  var _schema$required2;
1531
- var computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
1532
- rootSchema: rootSchema,
1533
- _recurseList: _recurseList,
1534
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1458
+ const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
1459
+ rootSchema,
1460
+ _recurseList,
1461
+ experimental_defaultFormStateBehavior,
1535
1462
  includeUndefinedValues: includeUndefinedValues === true,
1536
1463
  parentDefaults: get__default["default"](defaults, [key]),
1537
1464
  rawFormData: get__default["default"](formData, [key]),
@@ -1545,54 +1472,54 @@ function computeDefaults(validator, rawSchema, _temp) {
1545
1472
  }
1546
1473
  case 'array':
1547
1474
  {
1548
- var _experimental_default3;
1475
+ var _experimental_default;
1549
1476
  // Inject defaults into existing array defaults
1550
1477
  if (Array.isArray(defaults)) {
1551
- defaults = defaults.map(function (item, idx) {
1552
- var schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
1478
+ defaults = defaults.map((item, idx) => {
1479
+ const schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
1553
1480
  return computeDefaults(validator, schemaItem, {
1554
- rootSchema: rootSchema,
1555
- _recurseList: _recurseList,
1556
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1481
+ rootSchema,
1482
+ _recurseList,
1483
+ experimental_defaultFormStateBehavior,
1557
1484
  parentDefaults: item,
1558
- required: required
1485
+ required
1559
1486
  });
1560
1487
  });
1561
1488
  }
1562
1489
  // Deeply inject defaults into already existing form data
1563
1490
  if (Array.isArray(rawFormData)) {
1564
- var schemaItem = getInnerSchemaForArrayItem(schema);
1565
- defaults = rawFormData.map(function (item, idx) {
1491
+ const schemaItem = getInnerSchemaForArrayItem(schema);
1492
+ defaults = rawFormData.map((item, idx) => {
1566
1493
  return computeDefaults(validator, schemaItem, {
1567
- rootSchema: rootSchema,
1568
- _recurseList: _recurseList,
1569
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1494
+ rootSchema,
1495
+ _recurseList,
1496
+ experimental_defaultFormStateBehavior,
1570
1497
  rawFormData: item,
1571
1498
  parentDefaults: get__default["default"](defaults, [idx]),
1572
- required: required
1499
+ required
1573
1500
  });
1574
1501
  });
1575
1502
  }
1576
- var ignoreMinItemsFlagSet = (experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : (_experimental_default3 = experimental_defaultFormStateBehavior.arrayMinItems) === null || _experimental_default3 === void 0 ? void 0 : _experimental_default3.populate) === 'requiredOnly';
1503
+ const ignoreMinItemsFlagSet = (experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : (_experimental_default = experimental_defaultFormStateBehavior.arrayMinItems) === null || _experimental_default === void 0 ? void 0 : _experimental_default.populate) === 'requiredOnly';
1577
1504
  if (ignoreMinItemsFlagSet && !required) {
1578
1505
  // If no form data exists or defaults are set leave the field empty/non-existent, otherwise
1579
1506
  // return form data/defaults
1580
1507
  return defaults ? defaults : undefined;
1581
1508
  }
1582
- var defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1509
+ const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1583
1510
  if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
1584
1511
  return defaults ? defaults : [];
1585
1512
  }
1586
- var defaultEntries = defaults || [];
1587
- var fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
1588
- var fillerDefault = fillerSchema["default"];
1513
+ const defaultEntries = defaults || [];
1514
+ const fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
1515
+ const fillerDefault = fillerSchema.default;
1589
1516
  // Calculate filler entries for remaining items (minItems - existing raw data/defaults)
1590
- var fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, {
1517
+ const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, {
1591
1518
  parentDefaults: fillerDefault,
1592
- rootSchema: rootSchema,
1593
- _recurseList: _recurseList,
1594
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1595
- required: required
1519
+ rootSchema,
1520
+ _recurseList,
1521
+ experimental_defaultFormStateBehavior,
1522
+ required
1596
1523
  }));
1597
1524
  // then fill up the rest with either the item default or empty, up to minItems
1598
1525
  return defaultEntries.concat(fillerEntries);
@@ -1613,26 +1540,24 @@ function computeDefaults(validator, rawSchema, _temp) {
1613
1540
  * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
1614
1541
  * @returns - The resulting `formData` with all the defaults provided
1615
1542
  */
1616
- function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues, experimental_defaultFormStateBehavior) {
1617
- if (includeUndefinedValues === void 0) {
1618
- includeUndefinedValues = false;
1619
- }
1543
+ function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior) {
1620
1544
  if (!isObject(theSchema)) {
1621
1545
  throw new Error('Invalid schema: ' + theSchema);
1622
1546
  }
1623
- var schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1624
- var defaults = computeDefaults(validator, schema, {
1625
- rootSchema: rootSchema,
1626
- includeUndefinedValues: includeUndefinedValues,
1627
- experimental_defaultFormStateBehavior: experimental_defaultFormStateBehavior,
1547
+ const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1548
+ const defaults = computeDefaults(validator, schema, {
1549
+ rootSchema,
1550
+ includeUndefinedValues,
1551
+ experimental_defaultFormStateBehavior,
1628
1552
  rawFormData: formData
1629
1553
  });
1630
1554
  if (formData === undefined || formData === null || typeof formData === 'number' && isNaN(formData)) {
1631
1555
  // No form data? Use schema defaults.
1632
1556
  return defaults;
1633
1557
  }
1634
- var _ref2 = (experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : experimental_defaultFormStateBehavior.arrayMinItems) || {},
1635
- mergeExtraDefaults = _ref2.mergeExtraDefaults;
1558
+ const {
1559
+ mergeExtraDefaults
1560
+ } = (experimental_defaultFormStateBehavior === null || experimental_defaultFormStateBehavior === void 0 ? void 0 : experimental_defaultFormStateBehavior.arrayMinItems) || {};
1636
1561
  if (isObject(formData)) {
1637
1562
  return mergeDefaultsWithFormData(defaults, formData, mergeExtraDefaults);
1638
1563
  }
@@ -1647,10 +1572,7 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
1647
1572
  * @param uiSchema - The UI Schema from which to detect if it is customized
1648
1573
  * @returns - True if the `uiSchema` describes a custom widget, false otherwise
1649
1574
  */
1650
- function isCustomWidget(uiSchema) {
1651
- if (uiSchema === void 0) {
1652
- uiSchema = {};
1653
- }
1575
+ function isCustomWidget(uiSchema = {}) {
1654
1576
  return (
1655
1577
  // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1656
1578
  // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
@@ -1666,15 +1588,12 @@ function isCustomWidget(uiSchema) {
1666
1588
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1667
1589
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
1668
1590
  */
1669
- function isFilesArray(validator, schema, uiSchema, rootSchema) {
1670
- if (uiSchema === void 0) {
1671
- uiSchema = {};
1672
- }
1591
+ function isFilesArray(validator, schema, uiSchema = {}, rootSchema) {
1673
1592
  if (uiSchema[UI_WIDGET_KEY] === 'files') {
1674
1593
  return true;
1675
1594
  }
1676
1595
  if (schema.items) {
1677
- var itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1596
+ const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1678
1597
  return itemsSchema.type === 'string' && itemsSchema.format === 'data-url';
1679
1598
  }
1680
1599
  return false;
@@ -1690,15 +1609,13 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1690
1609
  * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1691
1610
  * @returns - True if the label should be displayed or false if it should not
1692
1611
  */
1693
- function getDisplayLabel(validator, schema, uiSchema, rootSchema, globalOptions) {
1694
- if (uiSchema === void 0) {
1695
- uiSchema = {};
1696
- }
1697
- var uiOptions = getUiOptions(uiSchema, globalOptions);
1698
- var _uiOptions$label = uiOptions.label,
1699
- label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1700
- var displayLabel = !!label;
1701
- var schemaType = getSchemaType(schema);
1612
+ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions) {
1613
+ const uiOptions = getUiOptions(uiSchema, globalOptions);
1614
+ const {
1615
+ label = true
1616
+ } = uiOptions;
1617
+ let displayLabel = !!label;
1618
+ const schemaType = getSchemaType(schema);
1702
1619
  if (schemaType === 'array') {
1703
1620
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1704
1621
  }
@@ -1730,21 +1647,23 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1730
1647
  if (!additionalErrorSchema) {
1731
1648
  return validationData;
1732
1649
  }
1733
- var oldErrors = validationData.errors,
1734
- oldErrorSchema = validationData.errorSchema;
1735
- var errors = validator.toErrorList(additionalErrorSchema);
1736
- var errorSchema = additionalErrorSchema;
1650
+ const {
1651
+ errors: oldErrors,
1652
+ errorSchema: oldErrorSchema
1653
+ } = validationData;
1654
+ let errors = validator.toErrorList(additionalErrorSchema);
1655
+ let errorSchema = additionalErrorSchema;
1737
1656
  if (!isEmpty__default["default"](oldErrorSchema)) {
1738
1657
  errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1739
- errors = [].concat(oldErrors).concat(errors);
1658
+ errors = [...oldErrors].concat(errors);
1740
1659
  }
1741
1660
  return {
1742
- errorSchema: errorSchema,
1743
- errors: errors
1661
+ errorSchema,
1662
+ errors
1744
1663
  };
1745
1664
  }
1746
1665
 
1747
- var NO_VALUE = /*#__PURE__*/Symbol('no Value');
1666
+ const NO_VALUE = /*#__PURE__*/Symbol('no Value');
1748
1667
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new
1749
1668
  * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature
1750
1669
  * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema
@@ -1792,31 +1711,28 @@ var NO_VALUE = /*#__PURE__*/Symbol('no Value');
1792
1711
  * @returns - The new form data, with all the fields uniquely associated with the old schema set
1793
1712
  * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
1794
1713
  */
1795
- function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data) {
1796
- if (data === void 0) {
1797
- data = {};
1798
- }
1714
+ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}) {
1799
1715
  // By default, we will clear the form data
1800
- var newFormData;
1716
+ let newFormData;
1801
1717
  // If the new schema is of type object and that object contains a list of properties
1802
1718
  if (has__default["default"](newSchema, PROPERTIES_KEY)) {
1803
1719
  // Create an object containing root-level keys in the old schema, setting each key to undefined to remove the data
1804
- var removeOldSchemaData = {};
1720
+ const removeOldSchemaData = {};
1805
1721
  if (has__default["default"](oldSchema, PROPERTIES_KEY)) {
1806
- var properties = get__default["default"](oldSchema, PROPERTIES_KEY, {});
1807
- Object.keys(properties).forEach(function (key) {
1722
+ const properties = get__default["default"](oldSchema, PROPERTIES_KEY, {});
1723
+ Object.keys(properties).forEach(key => {
1808
1724
  if (has__default["default"](data, key)) {
1809
1725
  removeOldSchemaData[key] = undefined;
1810
1726
  }
1811
1727
  });
1812
1728
  }
1813
- var keys = Object.keys(get__default["default"](newSchema, PROPERTIES_KEY, {}));
1729
+ const keys = Object.keys(get__default["default"](newSchema, PROPERTIES_KEY, {}));
1814
1730
  // Create a place to store nested data that will be a side-effect of the filter
1815
- var nestedData = {};
1816
- keys.forEach(function (key) {
1817
- var formValue = get__default["default"](data, key);
1818
- var oldKeyedSchema = get__default["default"](oldSchema, [PROPERTIES_KEY, key], {});
1819
- var newKeyedSchema = get__default["default"](newSchema, [PROPERTIES_KEY, key], {});
1731
+ const nestedData = {};
1732
+ keys.forEach(key => {
1733
+ const formValue = get__default["default"](data, key);
1734
+ let oldKeyedSchema = get__default["default"](oldSchema, [PROPERTIES_KEY, key], {});
1735
+ let newKeyedSchema = get__default["default"](newSchema, [PROPERTIES_KEY, key], {});
1820
1736
  // Resolve the refs if they exist
1821
1737
  if (has__default["default"](oldKeyedSchema, REF_KEY)) {
1822
1738
  oldKeyedSchema = retrieveSchema(validator, oldKeyedSchema, rootSchema, formValue);
@@ -1825,8 +1741,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1825
1741
  newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1826
1742
  }
1827
1743
  // Now get types and see if they are the same
1828
- var oldSchemaTypeForKey = get__default["default"](oldKeyedSchema, 'type');
1829
- var newSchemaTypeForKey = get__default["default"](newKeyedSchema, 'type');
1744
+ const oldSchemaTypeForKey = get__default["default"](oldKeyedSchema, 'type');
1745
+ const newSchemaTypeForKey = get__default["default"](newKeyedSchema, 'type');
1830
1746
  // Check if the old option has the same key with the same type
1831
1747
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
1832
1748
  if (has__default["default"](removeOldSchemaData, key)) {
@@ -1836,7 +1752,7 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1836
1752
  // If it is an object, we'll recurse and store the resulting sanitized data for the key
1837
1753
  if (newSchemaTypeForKey === 'object' || newSchemaTypeForKey === 'array' && Array.isArray(formValue)) {
1838
1754
  // SIDE-EFFECT: process the new schema type of object recursively to save iterations
1839
- var itemData = sanitizeDataForNewSchema(validator, rootSchema, newKeyedSchema, oldKeyedSchema, formValue);
1755
+ const itemData = sanitizeDataForNewSchema(validator, rootSchema, newKeyedSchema, oldKeyedSchema, formValue);
1840
1756
  if (itemData !== undefined || newSchemaTypeForKey === 'array') {
1841
1757
  // only put undefined values for the array type and not the object type
1842
1758
  nestedData[key] = itemData;
@@ -1845,8 +1761,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1845
1761
  // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
1846
1762
  // with the new default or const. This allows the case where two schemas differ that only by the default/const
1847
1763
  // value to be properly selected
1848
- var newOptionDefault = get__default["default"](newKeyedSchema, 'default', NO_VALUE);
1849
- var oldOptionDefault = get__default["default"](oldKeyedSchema, 'default', NO_VALUE);
1764
+ const newOptionDefault = get__default["default"](newKeyedSchema, 'default', NO_VALUE);
1765
+ const oldOptionDefault = get__default["default"](oldKeyedSchema, 'default', NO_VALUE);
1850
1766
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
1851
1767
  if (oldOptionDefault === formValue) {
1852
1768
  // If the old default matches the formValue, we'll update the new value to match the new default
@@ -1856,8 +1772,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1856
1772
  removeOldSchemaData[key] = undefined;
1857
1773
  }
1858
1774
  }
1859
- var newOptionConst = get__default["default"](newKeyedSchema, 'const', NO_VALUE);
1860
- var oldOptionConst = get__default["default"](oldKeyedSchema, 'const', NO_VALUE);
1775
+ const newOptionConst = get__default["default"](newKeyedSchema, 'const', NO_VALUE);
1776
+ const oldOptionConst = get__default["default"](oldKeyedSchema, 'const', NO_VALUE);
1861
1777
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
1862
1778
  // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
1863
1779
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
@@ -1865,11 +1781,15 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1865
1781
  }
1866
1782
  }
1867
1783
  });
1868
- newFormData = _extends({}, data, removeOldSchemaData, nestedData);
1784
+ newFormData = {
1785
+ ...data,
1786
+ ...removeOldSchemaData,
1787
+ ...nestedData
1788
+ };
1869
1789
  // First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep
1870
1790
  } else if (get__default["default"](oldSchema, 'type') === 'array' && get__default["default"](newSchema, 'type') === 'array' && Array.isArray(data)) {
1871
- var oldSchemaItems = get__default["default"](oldSchema, 'items');
1872
- var newSchemaItems = get__default["default"](newSchema, 'items');
1791
+ let oldSchemaItems = get__default["default"](oldSchema, 'items');
1792
+ let newSchemaItems = get__default["default"](newSchema, 'items');
1873
1793
  // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data
1874
1794
  // Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations
1875
1795
  if (typeof oldSchemaItems === 'object' && typeof newSchemaItems === 'object' && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
@@ -1880,14 +1800,14 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1880
1800
  newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1881
1801
  }
1882
1802
  // Now get types and see if they are the same
1883
- var oldSchemaType = get__default["default"](oldSchemaItems, 'type');
1884
- var newSchemaType = get__default["default"](newSchemaItems, 'type');
1803
+ const oldSchemaType = get__default["default"](oldSchemaItems, 'type');
1804
+ const newSchemaType = get__default["default"](newSchemaItems, 'type');
1885
1805
  // Check if the old option has the same key with the same type
1886
1806
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
1887
- var maxItems = get__default["default"](newSchema, 'maxItems', -1);
1807
+ const maxItems = get__default["default"](newSchema, 'maxItems', -1);
1888
1808
  if (newSchemaType === 'object') {
1889
- newFormData = data.reduce(function (newValue, aValue) {
1890
- var itemValue = sanitizeDataForNewSchema(validator, rootSchema, newSchemaItems, oldSchemaItems, aValue);
1809
+ newFormData = data.reduce((newValue, aValue) => {
1810
+ const itemValue = sanitizeDataForNewSchema(validator, rootSchema, newSchemaItems, oldSchemaItems, aValue);
1891
1811
  if (itemValue !== undefined && (maxItems < 0 || newValue.length < maxItems)) {
1892
1812
  newValue.push(itemValue);
1893
1813
  }
@@ -1920,15 +1840,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1920
1840
  * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion
1921
1841
  * @returns - The `IdSchema` object for the `schema`
1922
1842
  */
1923
- function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList) {
1924
- if (_recurseList === void 0) {
1925
- _recurseList = [];
1926
- }
1843
+ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
1927
1844
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1928
- var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1929
- var sameSchemaIndex = _recurseList.findIndex(function (item) {
1930
- return isEqual__default["default"](item, _schema);
1931
- });
1845
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1846
+ const sameSchemaIndex = _recurseList.findIndex(item => isEqual__default["default"](item, _schema));
1932
1847
  if (sameSchemaIndex === -1) {
1933
1848
  return toIdSchemaInternal(validator, _schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList.concat(_schema));
1934
1849
  }
@@ -1936,14 +1851,14 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
1936
1851
  if (ITEMS_KEY in schema && !get__default["default"](schema, [ITEMS_KEY, REF_KEY])) {
1937
1852
  return toIdSchemaInternal(validator, get__default["default"](schema, ITEMS_KEY), idPrefix, idSeparator, id, rootSchema, formData, _recurseList);
1938
1853
  }
1939
- var $id = id || idPrefix;
1940
- var idSchema = {
1941
- $id: $id
1854
+ const $id = id || idPrefix;
1855
+ const idSchema = {
1856
+ $id
1942
1857
  };
1943
1858
  if (getSchemaType(schema) === 'object' && PROPERTIES_KEY in schema) {
1944
- for (var name in schema.properties) {
1945
- var field = get__default["default"](schema, [PROPERTIES_KEY, name]);
1946
- var fieldId = idSchema[ID_KEY] + idSeparator + name;
1859
+ for (const name in schema.properties) {
1860
+ const field = get__default["default"](schema, [PROPERTIES_KEY, name]);
1861
+ const fieldId = idSchema[ID_KEY] + idSeparator + name;
1947
1862
  idSchema[name] = toIdSchemaInternal(validator, isObject(field) ? field : {}, idPrefix, idSeparator, fieldId, rootSchema,
1948
1863
  // It's possible that formData is not an object -- this can happen if an
1949
1864
  // array item has just been added, but not populated with data yet
@@ -1963,13 +1878,7 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
1963
1878
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
1964
1879
  * @returns - The `IdSchema` object for the `schema`
1965
1880
  */
1966
- function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSeparator) {
1967
- if (idPrefix === void 0) {
1968
- idPrefix = 'root';
1969
- }
1970
- if (idSeparator === void 0) {
1971
- idSeparator = '_';
1972
- }
1881
+ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = 'root', idSeparator = '_') {
1973
1882
  return toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData);
1974
1883
  }
1975
1884
 
@@ -1984,39 +1893,38 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1984
1893
  * @param [_recurseList=[]] - The list of retrieved schemas currently being recursed, used to prevent infinite recursion
1985
1894
  * @returns - The `PathSchema` object for the `schema`
1986
1895
  */
1987
- function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList) {
1988
- var _pathSchema;
1989
- if (_recurseList === void 0) {
1990
- _recurseList = [];
1991
- }
1896
+ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
1992
1897
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1993
- var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1994
- var sameSchemaIndex = _recurseList.findIndex(function (item) {
1995
- return isEqual__default["default"](item, _schema);
1996
- });
1898
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1899
+ const sameSchemaIndex = _recurseList.findIndex(item => isEqual__default["default"](item, _schema));
1997
1900
  if (sameSchemaIndex === -1) {
1998
1901
  return toPathSchemaInternal(validator, _schema, name, rootSchema, formData, _recurseList.concat(_schema));
1999
1902
  }
2000
1903
  }
2001
- var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ''), _pathSchema);
1904
+ let pathSchema = {
1905
+ [NAME_KEY]: name.replace(/^\./, '')
1906
+ };
2002
1907
  if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
2003
- var xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
2004
- var discriminator = getDiscriminatorFieldFromSchema(schema);
2005
- var index = getClosestMatchingOption(validator, rootSchema, formData, xxxOf, 0, discriminator);
2006
- var _schema2 = xxxOf[index];
2007
- pathSchema = _extends({}, pathSchema, toPathSchemaInternal(validator, _schema2, name, rootSchema, formData, _recurseList));
1908
+ const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
1909
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
1910
+ const index = getClosestMatchingOption(validator, rootSchema, formData, xxxOf, 0, discriminator);
1911
+ const _schema = xxxOf[index];
1912
+ pathSchema = {
1913
+ ...pathSchema,
1914
+ ...toPathSchemaInternal(validator, _schema, name, rootSchema, formData, _recurseList)
1915
+ };
2008
1916
  }
2009
1917
  if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
2010
1918
  set__default["default"](pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
2011
1919
  }
2012
1920
  if (ITEMS_KEY in schema && Array.isArray(formData)) {
2013
- formData.forEach(function (element, i) {
2014
- pathSchema[i] = toPathSchemaInternal(validator, schema.items, name + "." + i, rootSchema, element, _recurseList);
1921
+ formData.forEach((element, i) => {
1922
+ pathSchema[i] = toPathSchemaInternal(validator, schema.items, `${name}.${i}`, rootSchema, element, _recurseList);
2015
1923
  });
2016
1924
  } else if (PROPERTIES_KEY in schema) {
2017
- for (var property in schema.properties) {
2018
- var field = get__default["default"](schema, [PROPERTIES_KEY, property]);
2019
- pathSchema[property] = toPathSchemaInternal(validator, field, name + "." + property, rootSchema,
1925
+ for (const property in schema.properties) {
1926
+ const field = get__default["default"](schema, [PROPERTIES_KEY, property]);
1927
+ pathSchema[property] = toPathSchemaInternal(validator, field, `${name}.${property}`, rootSchema,
2020
1928
  // It's possible that formData is not an object -- this can happen if an
2021
1929
  // array item has just been added, but not populated with data yet
2022
1930
  get__default["default"](formData, [property]), _recurseList);
@@ -2033,10 +1941,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
2033
1941
  * @param [formData] - The current formData, if any, to assist retrieving a schema
2034
1942
  * @returns - The `PathSchema` object for the `schema`
2035
1943
  */
2036
- function toPathSchema(validator, schema, name, rootSchema, formData) {
2037
- if (name === void 0) {
2038
- name = '';
2039
- }
1944
+ function toPathSchema(validator, schema, name = '', rootSchema, formData) {
2040
1945
  return toPathSchemaInternal(validator, schema, name, rootSchema, formData);
2041
1946
  }
2042
1947
 
@@ -2045,14 +1950,14 @@ function toPathSchema(validator, schema, name, rootSchema, formData) {
2045
1950
  * Since these generally do not change across a `Form`, this allows for providing a simplified set of APIs to the
2046
1951
  * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
2047
1952
  */
2048
- var SchemaUtils = /*#__PURE__*/function () {
1953
+ class SchemaUtils {
2049
1954
  /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
2050
1955
  *
2051
1956
  * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
2052
1957
  * @param rootSchema - The root schema that will be forwarded to all the APIs
2053
1958
  * @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior
2054
1959
  */
2055
- function SchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior) {
1960
+ constructor(validator, rootSchema, experimental_defaultFormStateBehavior) {
2056
1961
  this.rootSchema = void 0;
2057
1962
  this.validator = void 0;
2058
1963
  this.experimental_defaultFormStateBehavior = void 0;
@@ -2064,8 +1969,7 @@ var SchemaUtils = /*#__PURE__*/function () {
2064
1969
  *
2065
1970
  * @returns - The `ValidatorType`
2066
1971
  */
2067
- var _proto = SchemaUtils.prototype;
2068
- _proto.getValidator = function getValidator() {
1972
+ getValidator() {
2069
1973
  return this.validator;
2070
1974
  }
2071
1975
  /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
@@ -2076,11 +1980,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2076
1980
  * @param rootSchema - The root schema that will be compared against the current one
2077
1981
  * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
2078
1982
  * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
2079
- */;
2080
- _proto.doesSchemaUtilsDiffer = function doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior) {
2081
- if (experimental_defaultFormStateBehavior === void 0) {
2082
- experimental_defaultFormStateBehavior = {};
2083
- }
1983
+ */
1984
+ doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
2084
1985
  if (!validator || !rootSchema) {
2085
1986
  return false;
2086
1987
  }
@@ -2095,11 +1996,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2095
1996
  * If "excludeObjectChildren", pass `includeUndefinedValues` as false when computing defaults for any nested
2096
1997
  * object properties.
2097
1998
  * @returns - The resulting `formData` with all the defaults provided
2098
- */;
2099
- _proto.getDefaultFormState = function getDefaultFormState$1(schema, formData, includeUndefinedValues) {
2100
- if (includeUndefinedValues === void 0) {
2101
- includeUndefinedValues = false;
2102
- }
1999
+ */
2000
+ getDefaultFormState(schema, formData, includeUndefinedValues = false) {
2103
2001
  return getDefaultFormState(this.validator, schema, formData, this.rootSchema, includeUndefinedValues, this.experimental_defaultFormStateBehavior);
2104
2002
  }
2105
2003
  /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
@@ -2109,8 +2007,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2109
2007
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
2110
2008
  * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
2111
2009
  * @returns - True if the label should be displayed or false if it should not
2112
- */;
2113
- _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema, globalOptions) {
2010
+ */
2011
+ getDisplayLabel(schema, uiSchema, globalOptions) {
2114
2012
  return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
2115
2013
  }
2116
2014
  /** Determines which of the given `options` provided most closely matches the `formData`.
@@ -2125,8 +2023,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2125
2023
  * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
2126
2024
  * determine which option is selected
2127
2025
  * @returns - The index of the option that is the closest match to the `formData` or the `selectedOption` if no match
2128
- */;
2129
- _proto.getClosestMatchingOption = function getClosestMatchingOption$1(formData, options, selectedOption, discriminatorField) {
2026
+ */
2027
+ getClosestMatchingOption(formData, options, selectedOption, discriminatorField) {
2130
2028
  return getClosestMatchingOption(this.validator, this.rootSchema, formData, options, selectedOption, discriminatorField);
2131
2029
  }
2132
2030
  /** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
@@ -2137,8 +2035,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2137
2035
  * @param [discriminatorField] - The optional name of the field within the options object whose value is used to
2138
2036
  * determine which option is selected
2139
2037
  * @returns - The firstindex of the matched option or 0 if none is available
2140
- */;
2141
- _proto.getFirstMatchingOption = function getFirstMatchingOption$1(formData, options, discriminatorField) {
2038
+ */
2039
+ getFirstMatchingOption(formData, options, discriminatorField) {
2142
2040
  return getFirstMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
2143
2041
  }
2144
2042
  /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
@@ -2150,8 +2048,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2150
2048
  * determine which option is selected
2151
2049
  * @returns - The index of the matched option or 0 if none is available
2152
2050
  * @deprecated
2153
- */;
2154
- _proto.getMatchingOption = function getMatchingOption$1(formData, options, discriminatorField) {
2051
+ */
2052
+ getMatchingOption(formData, options, discriminatorField) {
2155
2053
  return getMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
2156
2054
  }
2157
2055
  /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
@@ -2159,24 +2057,24 @@ var SchemaUtils = /*#__PURE__*/function () {
2159
2057
  * @param schema - The schema for which check for array of files flag is desired
2160
2058
  * @param [uiSchema] - The UI schema from which to check the widget
2161
2059
  * @returns - True if schema/uiSchema contains an array of files, otherwise false
2162
- */;
2163
- _proto.isFilesArray = function isFilesArray$1(schema, uiSchema) {
2060
+ */
2061
+ isFilesArray(schema, uiSchema) {
2164
2062
  return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
2165
2063
  }
2166
2064
  /** Checks to see if the `schema` combination represents a multi-select
2167
2065
  *
2168
2066
  * @param schema - The schema for which check for a multi-select flag is desired
2169
2067
  * @returns - True if schema contains a multi-select, otherwise false
2170
- */;
2171
- _proto.isMultiSelect = function isMultiSelect$1(schema) {
2068
+ */
2069
+ isMultiSelect(schema) {
2172
2070
  return isMultiSelect(this.validator, schema, this.rootSchema);
2173
2071
  }
2174
2072
  /** Checks to see if the `schema` combination represents a select
2175
2073
  *
2176
2074
  * @param schema - The schema for which check for a select flag is desired
2177
2075
  * @returns - True if schema contains a select, otherwise false
2178
- */;
2179
- _proto.isSelect = function isSelect$1(schema) {
2076
+ */
2077
+ isSelect(schema) {
2180
2078
  return isSelect(this.validator, schema, this.rootSchema);
2181
2079
  }
2182
2080
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
@@ -2189,8 +2087,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2189
2087
  * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
2190
2088
  * @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
2191
2089
  * removed in the next major release.
2192
- */;
2193
- _proto.mergeValidationData = function mergeValidationData$1(validationData, additionalErrorSchema) {
2090
+ */
2091
+ mergeValidationData(validationData, additionalErrorSchema) {
2194
2092
  return mergeValidationData(this.validator, validationData, additionalErrorSchema);
2195
2093
  }
2196
2094
  /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
@@ -2200,8 +2098,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2200
2098
  * @param schema - The schema for which retrieving a schema is desired
2201
2099
  * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
2202
2100
  * @returns - The schema having its conditions, additional properties, references and dependencies resolved
2203
- */;
2204
- _proto.retrieveSchema = function retrieveSchema$1(schema, rawFormData) {
2101
+ */
2102
+ retrieveSchema(schema, rawFormData) {
2205
2103
  return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
2206
2104
  }
2207
2105
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
@@ -2214,8 +2112,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2214
2112
  * @param [data={}] - The form data associated with the schema, defaulting to an empty object when undefined
2215
2113
  * @returns - The new form data, with all the fields uniquely associated with the old schema set
2216
2114
  * to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
2217
- */;
2218
- _proto.sanitizeDataForNewSchema = function sanitizeDataForNewSchema$1(newSchema, oldSchema, data) {
2115
+ */
2116
+ sanitizeDataForNewSchema(newSchema, oldSchema, data) {
2219
2117
  return sanitizeDataForNewSchema(this.validator, this.rootSchema, newSchema, oldSchema, data);
2220
2118
  }
2221
2119
  /** Generates an `IdSchema` object for the `schema`, recursively
@@ -2226,14 +2124,8 @@ var SchemaUtils = /*#__PURE__*/function () {
2226
2124
  * @param [idPrefix='root'] - The prefix to use for the id
2227
2125
  * @param [idSeparator='_'] - The separator to use for the path segments in the id
2228
2126
  * @returns - The `IdSchema` object for the `schema`
2229
- */;
2230
- _proto.toIdSchema = function toIdSchema$1(schema, id, formData, idPrefix, idSeparator) {
2231
- if (idPrefix === void 0) {
2232
- idPrefix = 'root';
2233
- }
2234
- if (idSeparator === void 0) {
2235
- idSeparator = '_';
2236
- }
2127
+ */
2128
+ toIdSchema(schema, id, formData, idPrefix = 'root', idSeparator = '_') {
2237
2129
  return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
2238
2130
  }
2239
2131
  /** Generates an `PathSchema` object for the `schema`, recursively
@@ -2242,12 +2134,11 @@ var SchemaUtils = /*#__PURE__*/function () {
2242
2134
  * @param [name] - The base name for the schema
2243
2135
  * @param [formData] - The current formData, if any, onto which to provide any missing defaults
2244
2136
  * @returns - The `PathSchema` object for the `schema`
2245
- */;
2246
- _proto.toPathSchema = function toPathSchema$1(schema, name, formData) {
2137
+ */
2138
+ toPathSchema(schema, name, formData) {
2247
2139
  return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
2248
- };
2249
- return SchemaUtils;
2250
- }();
2140
+ }
2141
+ }
2251
2142
  /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
2252
2143
  * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
2253
2144
  *
@@ -2256,10 +2147,7 @@ var SchemaUtils = /*#__PURE__*/function () {
2256
2147
  * @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
2257
2148
  * @returns - An implementation of a `SchemaUtilsType` interface
2258
2149
  */
2259
- function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior) {
2260
- if (experimental_defaultFormStateBehavior === void 0) {
2261
- experimental_defaultFormStateBehavior = {};
2262
- }
2150
+ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
2263
2151
  return new SchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior);
2264
2152
  }
2265
2153
 
@@ -2271,17 +2159,17 @@ function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateB
2271
2159
  */
2272
2160
  function dataURItoBlob(dataURI) {
2273
2161
  // Split metadata from data
2274
- var splitted = dataURI.split(',');
2162
+ const splitted = dataURI.split(',');
2275
2163
  // Split params
2276
- var params = splitted[0].split(';');
2164
+ const params = splitted[0].split(';');
2277
2165
  // Get mime-type from params
2278
- var type = params[0].replace('data:', '');
2166
+ const type = params[0].replace('data:', '');
2279
2167
  // Filter the name property from params
2280
- var properties = params.filter(function (param) {
2168
+ const properties = params.filter(param => {
2281
2169
  return param.split('=')[0] === 'name';
2282
2170
  });
2283
2171
  // Look for the name and use unknown if no name property.
2284
- var name;
2172
+ let name;
2285
2173
  if (properties.length !== 1) {
2286
2174
  name = 'unknown';
2287
2175
  } else {
@@ -2291,18 +2179,18 @@ function dataURItoBlob(dataURI) {
2291
2179
  }
2292
2180
  // Built the Uint8Array Blob parameter from the base64 string.
2293
2181
  try {
2294
- var binary = atob(splitted[1]);
2295
- var array = [];
2296
- for (var i = 0; i < binary.length; i++) {
2182
+ const binary = atob(splitted[1]);
2183
+ const array = [];
2184
+ for (let i = 0; i < binary.length; i++) {
2297
2185
  array.push(binary.charCodeAt(i));
2298
2186
  }
2299
2187
  // Create the blob object
2300
- var blob = new window.Blob([new Uint8Array(array)], {
2301
- type: type
2188
+ const blob = new window.Blob([new Uint8Array(array)], {
2189
+ type
2302
2190
  });
2303
2191
  return {
2304
- blob: blob,
2305
- name: name
2192
+ blob,
2193
+ name
2306
2194
  };
2307
2195
  } catch (error) {
2308
2196
  return {
@@ -2324,13 +2212,11 @@ function dataURItoBlob(dataURI) {
2324
2212
  * @returns - The updated string with any replacement specifiers replaced
2325
2213
  */
2326
2214
  function replaceStringParameters(inputString, params) {
2327
- var output = inputString;
2215
+ let output = inputString;
2328
2216
  if (Array.isArray(params)) {
2329
- var parts = output.split(/(%\d)/);
2330
- params.forEach(function (param, index) {
2331
- var partIndex = parts.findIndex(function (part) {
2332
- return part === "%" + (index + 1);
2333
- });
2217
+ const parts = output.split(/(%\d)/);
2218
+ params.forEach((param, index) => {
2219
+ const partIndex = parts.findIndex(part => part === `%${index + 1}`);
2334
2220
  if (partIndex >= 0) {
2335
2221
  parts[partIndex] = param;
2336
2222
  }
@@ -2363,20 +2249,13 @@ function englishStringTranslator(stringToTranslate, params) {
2363
2249
  * @returns - The single or list of values specified by the single or list of indexes if they are valid. Otherwise,
2364
2250
  * `emptyValue` or an empty list.
2365
2251
  */
2366
- function enumOptionsValueForIndex(valueIndex, allEnumOptions, emptyValue) {
2367
- if (allEnumOptions === void 0) {
2368
- allEnumOptions = [];
2369
- }
2252
+ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
2370
2253
  if (Array.isArray(valueIndex)) {
2371
- return valueIndex.map(function (index) {
2372
- return enumOptionsValueForIndex(index, allEnumOptions);
2373
- }).filter(function (val) {
2374
- return val;
2375
- });
2254
+ return valueIndex.map(index => enumOptionsValueForIndex(index, allEnumOptions)).filter(val => val);
2376
2255
  }
2377
2256
  // So Number(null) and Number('') both return 0, so use emptyValue for those two values
2378
- var index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);
2379
- var option = allEnumOptions[index];
2257
+ const index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);
2258
+ const option = allEnumOptions[index];
2380
2259
  return option ? option.value : emptyValue;
2381
2260
  }
2382
2261
 
@@ -2392,15 +2271,10 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions, emptyValue) {
2392
2271
  * unless `selected` is a single value. In that case, if the `valueIndex` value matches `selected`, returns
2393
2272
  * undefined, otherwise `selected`.
2394
2273
  */
2395
- function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions) {
2396
- if (allEnumOptions === void 0) {
2397
- allEnumOptions = [];
2398
- }
2399
- var value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2274
+ function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
2275
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2400
2276
  if (Array.isArray(selected)) {
2401
- return selected.filter(function (v) {
2402
- return !isEqual__default["default"](v, value);
2403
- });
2277
+ return selected.filter(v => !isEqual__default["default"](v, value));
2404
2278
  }
2405
2279
  return isEqual__default["default"](value, selected) ? undefined : selected;
2406
2280
  }
@@ -2413,9 +2287,7 @@ function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions) {
2413
2287
  */
2414
2288
  function enumOptionsIsSelected(value, selected) {
2415
2289
  if (Array.isArray(selected)) {
2416
- return selected.some(function (sel) {
2417
- return isEqual__default["default"](sel, value);
2418
- });
2290
+ return selected.some(sel => isEqual__default["default"](sel, value));
2419
2291
  }
2420
2292
  return isEqual__default["default"](selected, value);
2421
2293
  }
@@ -2431,18 +2303,8 @@ function enumOptionsIsSelected(value, selected) {
2431
2303
  * @returns - A single string index for the first `value` in `allEnumOptions`, if not `multiple`. Otherwise, the list
2432
2304
  * of indexes for (each of) the value(s) in `value`.
2433
2305
  */
2434
- function enumOptionsIndexForValue(value, allEnumOptions, multiple) {
2435
- if (allEnumOptions === void 0) {
2436
- allEnumOptions = [];
2437
- }
2438
- if (multiple === void 0) {
2439
- multiple = false;
2440
- }
2441
- var selectedIndexes = allEnumOptions.map(function (opt, index) {
2442
- return enumOptionsIsSelected(opt.value, value) ? String(index) : undefined;
2443
- }).filter(function (opt) {
2444
- return typeof opt !== 'undefined';
2445
- });
2306
+ function enumOptionsIndexForValue(value, allEnumOptions = [], multiple = false) {
2307
+ const selectedIndexes = allEnumOptions.map((opt, index) => enumOptionsIsSelected(opt.value, value) ? String(index) : undefined).filter(opt => typeof opt !== 'undefined');
2446
2308
  if (!multiple) {
2447
2309
  return selectedIndexes[0];
2448
2310
  }
@@ -2457,25 +2319,17 @@ function enumOptionsIndexForValue(value, allEnumOptions, multiple) {
2457
2319
  * @param [allEnumOptions=[]] - The list of all the known enumOptions
2458
2320
  * @returns - The updated list of selected enum values with enum value at the `valueIndex` added to it
2459
2321
  */
2460
- function enumOptionsSelectValue(valueIndex, selected, allEnumOptions) {
2461
- if (allEnumOptions === void 0) {
2462
- allEnumOptions = [];
2463
- }
2464
- var value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2322
+ function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
2323
+ const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
2465
2324
  if (!lodash.isNil(value)) {
2466
- var index = allEnumOptions.findIndex(function (opt) {
2467
- return value === opt.value;
2468
- });
2469
- var all = allEnumOptions.map(function (_ref) {
2470
- var val = _ref.value;
2471
- return val;
2472
- });
2473
- var updated = selected.slice(0, index).concat(value, selected.slice(index));
2325
+ const index = allEnumOptions.findIndex(opt => value === opt.value);
2326
+ const all = allEnumOptions.map(({
2327
+ value: val
2328
+ }) => val);
2329
+ const updated = selected.slice(0, index).concat(value, selected.slice(index));
2474
2330
  // As inserting values at predefined index positions doesn't work with empty
2475
2331
  // arrays, we need to reorder the updated selection to match the initial order
2476
- return updated.sort(function (a, b) {
2477
- return Number(all.indexOf(a) > all.indexOf(b));
2478
- });
2332
+ return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));
2479
2333
  }
2480
2334
  return selected;
2481
2335
  }
@@ -2485,12 +2339,12 @@ function enumOptionsSelectValue(valueIndex, selected, allEnumOptions) {
2485
2339
  * schema by using either dotted path or an array of path names. Once you are done building the `ErrorSchema`, you can
2486
2340
  * get the result and/or reset all the errors back to an initial set and start again.
2487
2341
  */
2488
- var ErrorSchemaBuilder = /*#__PURE__*/function () {
2342
+ class ErrorSchemaBuilder {
2489
2343
  /** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
2490
2344
  *
2491
2345
  * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
2492
2346
  */
2493
- function ErrorSchemaBuilder(initialSchema) {
2347
+ constructor(initialSchema) {
2494
2348
  /** The error schema being built
2495
2349
  *
2496
2350
  * @private
@@ -2500,16 +2354,18 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2500
2354
  }
2501
2355
  /** Returns the `ErrorSchema` that has been updated by the methods of the `ErrorSchemaBuilder`
2502
2356
  */
2503
- var _proto = ErrorSchemaBuilder.prototype;
2357
+ get ErrorSchema() {
2358
+ return this.errorSchema;
2359
+ }
2504
2360
  /** Will get an existing `ErrorSchema` at the specified `pathOfError` or create and return one.
2505
2361
  *
2506
2362
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
2507
2363
  * @returns - The error block for the given `pathOfError` or the root if not provided
2508
2364
  * @private
2509
2365
  */
2510
- _proto.getOrCreateErrorBlock = function getOrCreateErrorBlock(pathOfError) {
2511
- var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === 'string';
2512
- var errorBlock = hasPath ? get__default["default"](this.errorSchema, pathOfError) : this.errorSchema;
2366
+ getOrCreateErrorBlock(pathOfError) {
2367
+ const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === 'string';
2368
+ let errorBlock = hasPath ? get__default["default"](this.errorSchema, pathOfError) : this.errorSchema;
2513
2369
  if (!errorBlock && pathOfError) {
2514
2370
  errorBlock = {};
2515
2371
  set__default["default"](this.errorSchema, pathOfError, errorBlock);
@@ -2520,8 +2376,8 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2520
2376
  *
2521
2377
  * @param [initialSchema] - The optional set of initial errors, that will be cloned into the class
2522
2378
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
2523
- */;
2524
- _proto.resetAllErrors = function resetAllErrors(initialSchema) {
2379
+ */
2380
+ resetAllErrors(initialSchema) {
2525
2381
  this.errorSchema = initialSchema ? cloneDeep__default["default"](initialSchema) : {};
2526
2382
  return this;
2527
2383
  }
@@ -2532,17 +2388,16 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2532
2388
  * @param errorOrList - The error or list of errors to add into the `ErrorSchema`
2533
2389
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to add the error(s)
2534
2390
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
2535
- */;
2536
- _proto.addErrors = function addErrors(errorOrList, pathOfError) {
2537
- var errorBlock = this.getOrCreateErrorBlock(pathOfError);
2538
- var errorsList = get__default["default"](errorBlock, ERRORS_KEY);
2391
+ */
2392
+ addErrors(errorOrList, pathOfError) {
2393
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
2394
+ let errorsList = get__default["default"](errorBlock, ERRORS_KEY);
2539
2395
  if (!Array.isArray(errorsList)) {
2540
2396
  errorsList = [];
2541
2397
  errorBlock[ERRORS_KEY] = errorsList;
2542
2398
  }
2543
2399
  if (Array.isArray(errorOrList)) {
2544
- var _errorsList;
2545
- (_errorsList = errorsList).push.apply(_errorsList, errorOrList);
2400
+ errorsList.push(...errorOrList);
2546
2401
  } else {
2547
2402
  errorsList.push(errorOrList);
2548
2403
  }
@@ -2555,11 +2410,11 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2555
2410
  * @param errorOrList - The error or list of errors to set into the `ErrorSchema`
2556
2411
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to set the error(s)
2557
2412
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
2558
- */;
2559
- _proto.setErrors = function setErrors(errorOrList, pathOfError) {
2560
- var errorBlock = this.getOrCreateErrorBlock(pathOfError);
2413
+ */
2414
+ setErrors(errorOrList, pathOfError) {
2415
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
2561
2416
  // Effectively clone the array being given to prevent accidental outside manipulation of the given list
2562
- var listToAdd = Array.isArray(errorOrList) ? [].concat(errorOrList) : [errorOrList];
2417
+ const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
2563
2418
  set__default["default"](errorBlock, ERRORS_KEY, listToAdd);
2564
2419
  return this;
2565
2420
  }
@@ -2569,20 +2424,13 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2569
2424
  *
2570
2425
  * @param [pathOfError] - The optional path into the `ErrorSchema` at which to clear the error(s)
2571
2426
  * @returns - The `ErrorSchemaBuilder` object for chaining purposes
2572
- */;
2573
- _proto.clearErrors = function clearErrors(pathOfError) {
2574
- var errorBlock = this.getOrCreateErrorBlock(pathOfError);
2427
+ */
2428
+ clearErrors(pathOfError) {
2429
+ const errorBlock = this.getOrCreateErrorBlock(pathOfError);
2575
2430
  set__default["default"](errorBlock, ERRORS_KEY, []);
2576
2431
  return this;
2577
- };
2578
- _createClass(ErrorSchemaBuilder, [{
2579
- key: "ErrorSchema",
2580
- get: function get() {
2581
- return this.errorSchema;
2582
- }
2583
- }]);
2584
- return ErrorSchemaBuilder;
2585
- }();
2432
+ }
2433
+ }
2586
2434
 
2587
2435
  /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
2588
2436
  * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
@@ -2591,7 +2439,7 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2591
2439
  * @returns - A range specification from the schema
2592
2440
  */
2593
2441
  function rangeSpec(schema) {
2594
- var spec = {};
2442
+ const spec = {};
2595
2443
  if (schema.multipleOf) {
2596
2444
  spec.step = schema.multipleOf;
2597
2445
  }
@@ -2612,16 +2460,11 @@ function rangeSpec(schema) {
2612
2460
  * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
2613
2461
  * @returns - The extracted `InputPropsType` object
2614
2462
  */
2615
- function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
2616
- if (options === void 0) {
2617
- options = {};
2618
- }
2619
- if (autoDefaultStepAny === void 0) {
2620
- autoDefaultStepAny = true;
2621
- }
2622
- var inputProps = _extends({
2623
- type: defaultType || 'text'
2624
- }, rangeSpec(schema));
2463
+ function getInputProps(schema, defaultType, options = {}, autoDefaultStepAny = true) {
2464
+ const inputProps = {
2465
+ type: defaultType || 'text',
2466
+ ...rangeSpec(schema)
2467
+ };
2625
2468
  // If options.inputType is set use that as the input type
2626
2469
  if (options.inputType) {
2627
2470
  inputProps.type = options.inputType;
@@ -2652,7 +2495,7 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
2652
2495
 
2653
2496
  /** The default submit button options, exported for testing purposes
2654
2497
  */
2655
- var DEFAULT_OPTIONS = {
2498
+ const DEFAULT_OPTIONS = {
2656
2499
  props: {
2657
2500
  disabled: false
2658
2501
  },
@@ -2664,14 +2507,14 @@ var DEFAULT_OPTIONS = {
2664
2507
  * @param [uiSchema={}] - the UI Schema from which to extract submit button props
2665
2508
  * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
2666
2509
  */
2667
- function getSubmitButtonOptions(uiSchema) {
2668
- if (uiSchema === void 0) {
2669
- uiSchema = {};
2670
- }
2671
- var uiOptions = getUiOptions(uiSchema);
2510
+ function getSubmitButtonOptions(uiSchema = {}) {
2511
+ const uiOptions = getUiOptions(uiSchema);
2672
2512
  if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
2673
- var options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
2674
- return _extends({}, DEFAULT_OPTIONS, options);
2513
+ const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
2514
+ return {
2515
+ ...DEFAULT_OPTIONS,
2516
+ ...options
2517
+ };
2675
2518
  }
2676
2519
  return DEFAULT_OPTIONS;
2677
2520
  }
@@ -2684,11 +2527,10 @@ function getSubmitButtonOptions(uiSchema) {
2684
2527
  * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
2685
2528
  * @returns - The template from either the `uiSchema` or `registry` for the `name`
2686
2529
  */
2687
- function getTemplate(name, registry, uiOptions) {
2688
- if (uiOptions === void 0) {
2689
- uiOptions = {};
2690
- }
2691
- var templates = registry.templates;
2530
+ function getTemplate(name, registry, uiOptions = {}) {
2531
+ const {
2532
+ templates
2533
+ } = registry;
2692
2534
  if (name === 'ButtonTemplates') {
2693
2535
  return templates[name];
2694
2536
  }
@@ -2699,11 +2541,10 @@ function getTemplate(name, registry, uiOptions) {
2699
2541
  );
2700
2542
  }
2701
2543
 
2702
- var _excluded = ["options"];
2703
2544
  /** The map of schema types to widget type to widget name
2704
2545
  */
2705
- var widgetMap = {
2706
- "boolean": {
2546
+ const widgetMap = {
2547
+ boolean: {
2707
2548
  checkbox: 'CheckboxWidget',
2708
2549
  radio: 'RadioWidget',
2709
2550
  select: 'SelectWidget',
@@ -2762,16 +2603,21 @@ var widgetMap = {
2762
2603
  * @returns - The wrapper widget
2763
2604
  */
2764
2605
  function mergeWidgetOptions(AWidget) {
2765
- var MergedWidget = get__default["default"](AWidget, 'MergedWidget');
2606
+ let MergedWidget = get__default["default"](AWidget, 'MergedWidget');
2766
2607
  // cache return value as property of widget for proper react reconciliation
2767
2608
  if (!MergedWidget) {
2768
- var defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
2769
- MergedWidget = function MergedWidget(_ref) {
2770
- var options = _ref.options,
2771
- props = _objectWithoutPropertiesLoose(_ref, _excluded);
2772
- return jsxRuntime.jsx(AWidget, _extends({
2773
- options: _extends({}, defaultOptions, options)
2774
- }, props));
2609
+ const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
2610
+ MergedWidget = ({
2611
+ options,
2612
+ ...props
2613
+ }) => {
2614
+ return jsxRuntime.jsx(AWidget, {
2615
+ options: {
2616
+ ...defaultOptions,
2617
+ ...options
2618
+ },
2619
+ ...props
2620
+ });
2775
2621
  };
2776
2622
  set__default["default"](AWidget, 'MergedWidget', MergedWidget);
2777
2623
  }
@@ -2788,31 +2634,28 @@ function mergeWidgetOptions(AWidget) {
2788
2634
  * @returns - The `Widget` component to use
2789
2635
  * @throws - An error if there is no `Widget` component that can be returned
2790
2636
  */
2791
- function getWidget(schema, widget, registeredWidgets) {
2792
- if (registeredWidgets === void 0) {
2793
- registeredWidgets = {};
2794
- }
2795
- var type = getSchemaType(schema);
2637
+ function getWidget(schema, widget, registeredWidgets = {}) {
2638
+ const type = getSchemaType(schema);
2796
2639
  if (typeof widget === 'function' || widget && ReactIs__default["default"].isForwardRef( /*#__PURE__*/react.createElement(widget)) || ReactIs__default["default"].isMemo(widget)) {
2797
2640
  return mergeWidgetOptions(widget);
2798
2641
  }
2799
2642
  if (typeof widget !== 'string') {
2800
- throw new Error("Unsupported widget definition: " + typeof widget);
2643
+ throw new Error(`Unsupported widget definition: ${typeof widget}`);
2801
2644
  }
2802
2645
  if (widget in registeredWidgets) {
2803
- var registeredWidget = registeredWidgets[widget];
2646
+ const registeredWidget = registeredWidgets[widget];
2804
2647
  return getWidget(schema, registeredWidget, registeredWidgets);
2805
2648
  }
2806
2649
  if (typeof type === 'string') {
2807
2650
  if (!(type in widgetMap)) {
2808
- throw new Error("No widget for type '" + type + "'");
2651
+ throw new Error(`No widget for type '${type}'`);
2809
2652
  }
2810
2653
  if (widget in widgetMap[type]) {
2811
- var _registeredWidget = registeredWidgets[widgetMap[type][widget]];
2812
- return getWidget(schema, _registeredWidget, registeredWidgets);
2654
+ const registeredWidget = registeredWidgets[widgetMap[type][widget]];
2655
+ return getWidget(schema, registeredWidget, registeredWidgets);
2813
2656
  }
2814
2657
  }
2815
- throw new Error("No widget '" + widget + "' for type '" + type + "'");
2658
+ throw new Error(`No widget '${widget}' for type '${type}'`);
2816
2659
  }
2817
2660
 
2818
2661
  /** JS has no built-in hashing function, so rolling our own
@@ -2823,9 +2666,9 @@ function getWidget(schema, widget, registeredWidgets) {
2823
2666
  * @returns - The resulting hash of the string in hex format
2824
2667
  */
2825
2668
  function hashString(string) {
2826
- var hash = 0;
2827
- for (var i = 0; i < string.length; i += 1) {
2828
- var chr = string.charCodeAt(i);
2669
+ let hash = 0;
2670
+ for (let i = 0; i < string.length; i += 1) {
2671
+ const chr = string.charCodeAt(i);
2829
2672
  hash = (hash << 5) - hash + chr;
2830
2673
  hash = hash & hash; // Convert to 32bit integer
2831
2674
  }
@@ -2839,11 +2682,9 @@ function hashString(string) {
2839
2682
  * @returns - The string obtained from the hash of the stringified schema
2840
2683
  */
2841
2684
  function hashForSchema(schema) {
2842
- var allKeys = new Set();
2685
+ const allKeys = new Set();
2843
2686
  // solution source: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify/53593328#53593328
2844
- JSON.stringify(schema, function (key, value) {
2845
- return allKeys.add(key), value;
2846
- });
2687
+ JSON.stringify(schema, (key, value) => (allKeys.add(key), value));
2847
2688
  return hashString(JSON.stringify(schema, Array.from(allKeys).sort()));
2848
2689
  }
2849
2690
 
@@ -2855,15 +2696,12 @@ function hashForSchema(schema) {
2855
2696
  * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
2856
2697
  * @returns - True if the widget exists, false otherwise
2857
2698
  */
2858
- function hasWidget(schema, widget, registeredWidgets) {
2859
- if (registeredWidgets === void 0) {
2860
- registeredWidgets = {};
2861
- }
2699
+ function hasWidget(schema, widget, registeredWidgets = {}) {
2862
2700
  try {
2863
2701
  getWidget(schema, widget, registeredWidgets);
2864
2702
  return true;
2865
2703
  } catch (e) {
2866
- var err = e;
2704
+ const err = e;
2867
2705
  if (err.message && (err.message.startsWith('No widget') || err.message.startsWith('Unsupported widget'))) {
2868
2706
  return false;
2869
2707
  }
@@ -2877,8 +2715,8 @@ function hasWidget(schema, widget, registeredWidgets) {
2877
2715
  * @param suffix - The suffix to append to the id
2878
2716
  */
2879
2717
  function idGenerator(id, suffix) {
2880
- var theId = isString__default["default"](id) ? id : id[ID_KEY];
2881
- return theId + "__" + suffix;
2718
+ const theId = isString__default["default"](id) ? id : id[ID_KEY];
2719
+ return `${theId}__${suffix}`;
2882
2720
  }
2883
2721
  /** Return a consistent `id` for the field description element
2884
2722
  *
@@ -2928,12 +2766,9 @@ function titleId(id) {
2928
2766
  * @param [includeExamples=false] - Optional flag, if true, will add the `examplesId` into the list
2929
2767
  * @returns - The string containing the list of ids for use in an `aria-describedBy` attribute
2930
2768
  */
2931
- function ariaDescribedByIds(id, includeExamples) {
2932
- if (includeExamples === void 0) {
2933
- includeExamples = false;
2934
- }
2935
- var examples = includeExamples ? " " + examplesId(id) : '';
2936
- return errorId(id) + " " + descriptionId(id) + " " + helpId(id) + examples;
2769
+ function ariaDescribedByIds(id, includeExamples = false) {
2770
+ const examples = includeExamples ? ` ${examplesId(id)}` : '';
2771
+ return `${errorId(id)} ${descriptionId(id)} ${helpId(id)}${examples}`;
2937
2772
  }
2938
2773
  /** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget
2939
2774
  *
@@ -2942,7 +2777,7 @@ function ariaDescribedByIds(id, includeExamples) {
2942
2777
  * @returns - An id for the option index based on the parent `id`
2943
2778
  */
2944
2779
  function optionId(id, optionIndex) {
2945
- return id + "-" + optionIndex;
2780
+ return `${id}-${optionIndex}`;
2946
2781
  }
2947
2782
 
2948
2783
  function labelValue(label, hideLabel, fallback) {
@@ -2966,11 +2801,11 @@ function localToUTC(dateString) {
2966
2801
  * @throws - Error when the schema does not have a constant value
2967
2802
  */
2968
2803
  function toConstant(schema) {
2969
- if (ENUM_KEY in schema && Array.isArray(schema["enum"]) && schema["enum"].length === 1) {
2970
- return schema["enum"][0];
2804
+ if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
2805
+ return schema.enum[0];
2971
2806
  }
2972
2807
  if (CONST_KEY in schema) {
2973
- return schema["const"];
2808
+ return schema.const;
2974
2809
  }
2975
2810
  throw new Error('schema cannot be inferred as a constant');
2976
2811
  }
@@ -2986,28 +2821,28 @@ function toConstant(schema) {
2986
2821
  function optionsList(schema) {
2987
2822
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
2988
2823
  // Cast the type to include enumNames so the feature still works.
2989
- var schemaWithEnumNames = schema;
2824
+ const schemaWithEnumNames = schema;
2990
2825
  if (schemaWithEnumNames.enumNames && "development" !== 'production') {
2991
2826
  console.warn('The enumNames property is deprecated and may be removed in a future major release.');
2992
2827
  }
2993
- if (schema["enum"]) {
2994
- return schema["enum"].map(function (value, i) {
2995
- var label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
2828
+ if (schema.enum) {
2829
+ return schema.enum.map((value, i) => {
2830
+ const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
2996
2831
  return {
2997
- label: label,
2998
- value: value
2832
+ label,
2833
+ value
2999
2834
  };
3000
2835
  });
3001
2836
  }
3002
- var altSchemas = schema.oneOf || schema.anyOf;
3003
- return altSchemas && altSchemas.map(function (aSchemaDef) {
3004
- var aSchema = aSchemaDef;
3005
- var value = toConstant(aSchema);
3006
- var label = aSchema.title || String(value);
2837
+ const altSchemas = schema.oneOf || schema.anyOf;
2838
+ return altSchemas && altSchemas.map(aSchemaDef => {
2839
+ const aSchema = aSchemaDef;
2840
+ const value = toConstant(aSchema);
2841
+ const label = aSchema.title || String(value);
3007
2842
  return {
3008
2843
  schema: aSchema,
3009
- label: label,
3010
- value: value
2844
+ label,
2845
+ value
3011
2846
  };
3012
2847
  });
3013
2848
  }
@@ -3026,35 +2861,27 @@ function orderProperties(properties, order) {
3026
2861
  if (!Array.isArray(order)) {
3027
2862
  return properties;
3028
2863
  }
3029
- var arrayToHash = function arrayToHash(arr) {
3030
- return arr.reduce(function (prev, curr) {
3031
- prev[curr] = true;
3032
- return prev;
3033
- }, {});
3034
- };
3035
- var errorPropList = function errorPropList(arr) {
3036
- return arr.length > 1 ? "properties '" + arr.join("', '") + "'" : "property '" + arr[0] + "'";
3037
- };
3038
- var propertyHash = arrayToHash(properties);
3039
- var orderFiltered = order.filter(function (prop) {
3040
- return prop === '*' || propertyHash[prop];
3041
- });
3042
- var orderHash = arrayToHash(orderFiltered);
3043
- var rest = properties.filter(function (prop) {
3044
- return !orderHash[prop];
3045
- });
3046
- var restIndex = orderFiltered.indexOf('*');
2864
+ const arrayToHash = arr => arr.reduce((prev, curr) => {
2865
+ prev[curr] = true;
2866
+ return prev;
2867
+ }, {});
2868
+ const errorPropList = arr => arr.length > 1 ? `properties '${arr.join("', '")}'` : `property '${arr[0]}'`;
2869
+ const propertyHash = arrayToHash(properties);
2870
+ const orderFiltered = order.filter(prop => prop === '*' || propertyHash[prop]);
2871
+ const orderHash = arrayToHash(orderFiltered);
2872
+ const rest = properties.filter(prop => !orderHash[prop]);
2873
+ const restIndex = orderFiltered.indexOf('*');
3047
2874
  if (restIndex === -1) {
3048
2875
  if (rest.length) {
3049
- throw new Error("uiSchema order list does not contain " + errorPropList(rest));
2876
+ throw new Error(`uiSchema order list does not contain ${errorPropList(rest)}`);
3050
2877
  }
3051
2878
  return orderFiltered;
3052
2879
  }
3053
2880
  if (restIndex !== orderFiltered.lastIndexOf('*')) {
3054
2881
  throw new Error('uiSchema order list contains more than one wildcard item');
3055
2882
  }
3056
- var complete = [].concat(orderFiltered);
3057
- complete.splice.apply(complete, [restIndex, 1].concat(rest));
2883
+ const complete = [...orderFiltered];
2884
+ complete.splice(restIndex, 1, ...rest);
3058
2885
  return complete;
3059
2886
  }
3060
2887
 
@@ -3065,7 +2892,7 @@ function orderProperties(properties, order) {
3065
2892
  * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
3066
2893
  */
3067
2894
  function pad(num, width) {
3068
- var s = String(num);
2895
+ let s = String(num);
3069
2896
  while (s.length < width) {
3070
2897
  s = '0' + s;
3071
2898
  }
@@ -3079,10 +2906,7 @@ function pad(num, width) {
3079
2906
  * @returns - The date string converted to a `DateObject`
3080
2907
  * @throws - Error when the date cannot be parsed from the string
3081
2908
  */
3082
- function parseDateString(dateString, includeTime) {
3083
- if (includeTime === void 0) {
3084
- includeTime = true;
3085
- }
2909
+ function parseDateString(dateString, includeTime = true) {
3086
2910
  if (!dateString) {
3087
2911
  return {
3088
2912
  year: -1,
@@ -3093,7 +2917,7 @@ function parseDateString(dateString, includeTime) {
3093
2917
  second: includeTime ? -1 : 0
3094
2918
  };
3095
2919
  }
3096
- var date = new Date(dateString);
2920
+ const date = new Date(dateString);
3097
2921
  if (Number.isNaN(date.getTime())) {
3098
2922
  throw new Error('Unable to parse date ' + dateString);
3099
2923
  }
@@ -3118,11 +2942,11 @@ function parseDateString(dateString, includeTime) {
3118
2942
  */
3119
2943
  function schemaRequiresTrueValue(schema) {
3120
2944
  // Check if const is a truthy value
3121
- if (schema["const"]) {
2945
+ if (schema.const) {
3122
2946
  return true;
3123
2947
  }
3124
2948
  // Check if an enum has a single value of true
3125
- if (schema["enum"] && schema["enum"].length === 1 && schema["enum"][0] === true) {
2949
+ if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
3126
2950
  return true;
3127
2951
  }
3128
2952
  // If anyOf has a single value, evaluate the subschema
@@ -3135,9 +2959,7 @@ function schemaRequiresTrueValue(schema) {
3135
2959
  }
3136
2960
  // Evaluate each subschema in allOf, to see if one of them requires a true value
3137
2961
  if (schema.allOf) {
3138
- var schemaSome = function schemaSome(subSchema) {
3139
- return schemaRequiresTrueValue(subSchema);
3140
- };
2962
+ const schemaSome = subSchema => schemaRequiresTrueValue(subSchema);
3141
2963
  return schema.allOf.some(schemaSome);
3142
2964
  }
3143
2965
  return false;
@@ -3152,8 +2974,10 @@ function schemaRequiresTrueValue(schema) {
3152
2974
  * @returns - True if the component should be re-rendered, false otherwise
3153
2975
  */
3154
2976
  function shouldRender(component, nextProps, nextState) {
3155
- var props = component.props,
3156
- state = component.state;
2977
+ const {
2978
+ props,
2979
+ state
2980
+ } = component;
3157
2981
  return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
3158
2982
  }
3159
2983
 
@@ -3164,21 +2988,17 @@ function shouldRender(component, nextProps, nextState) {
3164
2988
  * @param [time=true] - Optional flag used to remove the time portion of the date string if false
3165
2989
  * @returns - The UTC date string
3166
2990
  */
3167
- function toDateString(dateObject, time) {
3168
- if (time === void 0) {
3169
- time = true;
3170
- }
3171
- var year = dateObject.year,
3172
- month = dateObject.month,
3173
- day = dateObject.day,
3174
- _dateObject$hour = dateObject.hour,
3175
- hour = _dateObject$hour === void 0 ? 0 : _dateObject$hour,
3176
- _dateObject$minute = dateObject.minute,
3177
- minute = _dateObject$minute === void 0 ? 0 : _dateObject$minute,
3178
- _dateObject$second = dateObject.second,
3179
- second = _dateObject$second === void 0 ? 0 : _dateObject$second;
3180
- var utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
3181
- var datetime = new Date(utcTime).toJSON();
2991
+ function toDateString(dateObject, time = true) {
2992
+ const {
2993
+ year,
2994
+ month,
2995
+ day,
2996
+ hour = 0,
2997
+ minute = 0,
2998
+ second = 0
2999
+ } = dateObject;
3000
+ const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
3001
+ const datetime = new Date(utcTime).toJSON();
3182
3002
  return time ? datetime : datetime.slice(0, 10);
3183
3003
  }
3184
3004
 
@@ -3188,29 +3008,26 @@ function toDateString(dateObject, time) {
3188
3008
  * @param [fieldPath=[]] - The current field path, defaults to [] if not specified
3189
3009
  * @returns - The list of `RJSFValidationErrors` extracted from the `errorSchema`
3190
3010
  */
3191
- function toErrorList(errorSchema, fieldPath) {
3192
- if (fieldPath === void 0) {
3193
- fieldPath = [];
3194
- }
3011
+ function toErrorList(errorSchema, fieldPath = []) {
3195
3012
  if (!errorSchema) {
3196
3013
  return [];
3197
3014
  }
3198
- var errorList = [];
3015
+ let errorList = [];
3199
3016
  if (ERRORS_KEY in errorSchema) {
3200
- errorList = errorList.concat(errorSchema[ERRORS_KEY].map(function (message) {
3201
- var property = "." + fieldPath.join('.');
3017
+ errorList = errorList.concat(errorSchema[ERRORS_KEY].map(message => {
3018
+ const property = `.${fieldPath.join('.')}`;
3202
3019
  return {
3203
- property: property,
3204
- message: message,
3205
- stack: property + " " + message
3020
+ property,
3021
+ message,
3022
+ stack: `${property} ${message}`
3206
3023
  };
3207
3024
  }));
3208
3025
  }
3209
- return Object.keys(errorSchema).reduce(function (acc, key) {
3026
+ return Object.keys(errorSchema).reduce((acc, key) => {
3210
3027
  if (key !== ERRORS_KEY) {
3211
- var childSchema = errorSchema[key];
3028
+ const childSchema = errorSchema[key];
3212
3029
  if (isPlainObject__default["default"](childSchema)) {
3213
- acc = acc.concat(toErrorList(childSchema, [].concat(fieldPath, [key])));
3030
+ acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));
3214
3031
  }
3215
3032
  }
3216
3033
  return acc;
@@ -3237,13 +3054,15 @@ function toErrorList(errorSchema, fieldPath) {
3237
3054
  * @returns - The `ErrorSchema` built from the list of `RJSFValidationErrors`
3238
3055
  */
3239
3056
  function toErrorSchema(errors) {
3240
- var builder = new ErrorSchemaBuilder();
3057
+ const builder = new ErrorSchemaBuilder();
3241
3058
  if (errors.length) {
3242
- errors.forEach(function (error) {
3243
- var property = error.property,
3244
- message = error.message;
3059
+ errors.forEach(error => {
3060
+ const {
3061
+ property,
3062
+ message
3063
+ } = error;
3245
3064
  // When the property is the root element, just use an empty array for the path
3246
- var path = property === '.' ? [] : toPath__default["default"](property);
3065
+ const path = property === '.' ? [] : toPath__default["default"](property);
3247
3066
  // If the property is at the root (.level1) then toPath creates
3248
3067
  // an empty array element at the first index. Remove it.
3249
3068
  if (path.length > 0 && path[0] === '') {
@@ -3263,17 +3082,21 @@ function toErrorSchema(errors) {
3263
3082
  * @returns - The `ErrorSchema` resulting from the stripping of the `addError()` function
3264
3083
  */
3265
3084
  function unwrapErrorHandler(errorHandler) {
3266
- return Object.keys(errorHandler).reduce(function (acc, key) {
3085
+ return Object.keys(errorHandler).reduce((acc, key) => {
3267
3086
  if (key === 'addError') {
3268
3087
  return acc;
3269
3088
  } else {
3270
- var _extends3;
3271
- var childSchema = errorHandler[key];
3089
+ const childSchema = errorHandler[key];
3272
3090
  if (isPlainObject__default["default"](childSchema)) {
3273
- var _extends2;
3274
- return _extends({}, acc, (_extends2 = {}, _extends2[key] = unwrapErrorHandler(childSchema), _extends2));
3091
+ return {
3092
+ ...acc,
3093
+ [key]: unwrapErrorHandler(childSchema)
3094
+ };
3275
3095
  }
3276
- return _extends({}, acc, (_extends3 = {}, _extends3[key] = childSchema, _extends3));
3096
+ return {
3097
+ ...acc,
3098
+ [key]: childSchema
3099
+ };
3277
3100
  }
3278
3101
  }, {});
3279
3102
  }
@@ -3292,15 +3115,15 @@ function utcToLocal(jsonDate) {
3292
3115
  // > should be a _valid local date and time string_ (not GMT)
3293
3116
  // Note - date constructor passed local ISO-8601 does not correctly
3294
3117
  // change time to UTC in node pre-8
3295
- var date = new Date(jsonDate);
3296
- var yyyy = pad(date.getFullYear(), 4);
3297
- var MM = pad(date.getMonth() + 1, 2);
3298
- var dd = pad(date.getDate(), 2);
3299
- var hh = pad(date.getHours(), 2);
3300
- var mm = pad(date.getMinutes(), 2);
3301
- var ss = pad(date.getSeconds(), 2);
3302
- var SSS = pad(date.getMilliseconds(), 3);
3303
- return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
3118
+ const date = new Date(jsonDate);
3119
+ const yyyy = pad(date.getFullYear(), 4);
3120
+ const MM = pad(date.getMonth() + 1, 2);
3121
+ const dd = pad(date.getDate(), 2);
3122
+ const hh = pad(date.getHours(), 2);
3123
+ const mm = pad(date.getMinutes(), 2);
3124
+ const ss = pad(date.getSeconds(), 2);
3125
+ const SSS = pad(date.getMilliseconds(), 3);
3126
+ return `${yyyy}-${MM}-${dd}T${hh}:${mm}:${ss}.${SSS}`;
3304
3127
  }
3305
3128
 
3306
3129
  /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
@@ -3316,17 +3139,19 @@ function validationDataMerge(validationData, additionalErrorSchema) {
3316
3139
  if (!additionalErrorSchema) {
3317
3140
  return validationData;
3318
3141
  }
3319
- var oldErrors = validationData.errors,
3320
- oldErrorSchema = validationData.errorSchema;
3321
- var errors = toErrorList(additionalErrorSchema);
3322
- var errorSchema = additionalErrorSchema;
3142
+ const {
3143
+ errors: oldErrors,
3144
+ errorSchema: oldErrorSchema
3145
+ } = validationData;
3146
+ let errors = toErrorList(additionalErrorSchema);
3147
+ let errorSchema = additionalErrorSchema;
3323
3148
  if (!isEmpty__default["default"](oldErrorSchema)) {
3324
3149
  errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
3325
- errors = [].concat(oldErrors).concat(errors);
3150
+ errors = [...oldErrors].concat(errors);
3326
3151
  }
3327
3152
  return {
3328
- errorSchema: errorSchema,
3329
- errors: errors
3153
+ errorSchema,
3154
+ errors
3330
3155
  };
3331
3156
  }
3332
3157
 
@@ -3336,9 +3161,9 @@ function validationDataMerge(validationData, additionalErrorSchema) {
3336
3161
  * @param node - The object node to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
3337
3162
  */
3338
3163
  function withIdRefPrefixObject(node) {
3339
- for (var key in node) {
3340
- var realObj = node;
3341
- var value = realObj[key];
3164
+ for (const key in node) {
3165
+ const realObj = node;
3166
+ const value = realObj[key];
3342
3167
  if (key === REF_KEY && typeof value === 'string' && value.startsWith('#')) {
3343
3168
  realObj[key] = ROOT_SCHEMA_PREFIX + value;
3344
3169
  } else {
@@ -3353,7 +3178,7 @@ function withIdRefPrefixObject(node) {
3353
3178
  * @param node - The list of object nodes to which a ROOT_SCHEMA_PREFIX is added when a REF_KEY is part of it
3354
3179
  */
3355
3180
  function withIdRefPrefixArray(node) {
3356
- for (var i = 0; i < node.length; i++) {
3181
+ for (let i = 0; i < node.length; i++) {
3357
3182
  node[i] = withIdRefPrefix(node[i]);
3358
3183
  }
3359
3184
  return node;
@@ -3365,11 +3190,13 @@ function withIdRefPrefixArray(node) {
3365
3190
  * @returns - A copy of the `schemaNode` with updated `$ref`s
3366
3191
  */
3367
3192
  function withIdRefPrefix(schemaNode) {
3368
- if (schemaNode.constructor === Object) {
3369
- return withIdRefPrefixObject(_extends({}, schemaNode));
3370
- }
3371
3193
  if (Array.isArray(schemaNode)) {
3372
- return withIdRefPrefixArray([].concat(schemaNode));
3194
+ return withIdRefPrefixArray([...schemaNode]);
3195
+ }
3196
+ if (isObject__default["default"](schemaNode)) {
3197
+ return withIdRefPrefixObject({
3198
+ ...schemaNode
3199
+ });
3373
3200
  }
3374
3201
  return schemaNode;
3375
3202
  }
@@ -3457,13 +3284,13 @@ exports.TranslatableString = void 0;
3457
3284
  * the hashed value of the schema. NOTE: After hashing the schema, an $id with the hash value is added to the
3458
3285
  * schema IF that schema doesn't already have an $id, prior to putting the schema into the map.
3459
3286
  */
3460
- var ParserValidator = /*#__PURE__*/function () {
3287
+ class ParserValidator {
3461
3288
  /** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
3462
3289
  * first.
3463
3290
  *
3464
3291
  * @param rootSchema - The root schema against which this validator will be executed
3465
3292
  */
3466
- function ParserValidator(rootSchema) {
3293
+ constructor(rootSchema) {
3467
3294
  /** The rootSchema provided during construction of the class */
3468
3295
  this.rootSchema = void 0;
3469
3296
  /** The map of schemas encountered by the ParserValidator */
@@ -3478,23 +3305,24 @@ var ParserValidator = /*#__PURE__*/function () {
3478
3305
  * @param schema - The schema which is to be added to the map
3479
3306
  * @param hash - The hash value at which to map the schema
3480
3307
  */
3481
- var _proto = ParserValidator.prototype;
3482
- _proto.addSchema = function addSchema(schema, hash) {
3483
- var _extends2;
3484
- var key = get__default["default"](schema, ID_KEY, hash);
3485
- var identifiedSchema = _extends({}, schema, (_extends2 = {}, _extends2[ID_KEY] = key, _extends2));
3486
- var existing = this.schemaMap[key];
3308
+ addSchema(schema, hash) {
3309
+ const key = get__default["default"](schema, ID_KEY, hash);
3310
+ const identifiedSchema = {
3311
+ ...schema,
3312
+ [ID_KEY]: key
3313
+ };
3314
+ const existing = this.schemaMap[key];
3487
3315
  if (!existing) {
3488
3316
  this.schemaMap[key] = identifiedSchema;
3489
3317
  } else if (!isEqual__default["default"](existing, identifiedSchema)) {
3490
3318
  console.error('existing schema:', JSON.stringify(existing, null, 2));
3491
3319
  console.error('new schema:', JSON.stringify(identifiedSchema, null, 2));
3492
- throw new Error("Two different schemas exist with the same key " + key + "! What a bad coincidence. If possible, try adding an $id to one of the schemas");
3320
+ throw new Error(`Two different schemas exist with the same key ${key}! What a bad coincidence. If possible, try adding an $id to one of the schemas`);
3493
3321
  }
3494
3322
  }
3495
3323
  /** Returns the current `schemaMap` to the caller
3496
- */;
3497
- _proto.getSchemaMap = function getSchemaMap() {
3324
+ */
3325
+ getSchemaMap() {
3498
3326
  return this.schemaMap;
3499
3327
  }
3500
3328
  /** Implements the `ValidatorType` `isValid()` method to capture the `schema` in the `schemaMap`. Throws an error when
@@ -3504,8 +3332,8 @@ var ParserValidator = /*#__PURE__*/function () {
3504
3332
  * @param _formData - The formData parameter that is ignored
3505
3333
  * @param rootSchema - The root schema associated with the schema
3506
3334
  * @throws - Error when the given `rootSchema` differs from the root schema provided during construction
3507
- */;
3508
- _proto.isValid = function isValid(schema, _formData, rootSchema) {
3335
+ */
3336
+ isValid(schema, _formData, rootSchema) {
3509
3337
  if (!isEqual__default["default"](rootSchema, this.rootSchema)) {
3510
3338
  throw new Error('Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema');
3511
3339
  }
@@ -3516,16 +3344,16 @@ var ParserValidator = /*#__PURE__*/function () {
3516
3344
  *
3517
3345
  * @param _schema - The schema parameter that is ignored
3518
3346
  * @param _formData - The formData parameter that is ignored
3519
- */;
3520
- _proto.rawValidation = function rawValidation(_schema, _formData) {
3347
+ */
3348
+ rawValidation(_schema, _formData) {
3521
3349
  throw new Error('Unexpectedly calling the `rawValidation()` method during schema parsing');
3522
3350
  }
3523
3351
  /** Implements the `ValidatorType` `toErrorList()` method to throw an error since it is never supposed to be called
3524
3352
  *
3525
3353
  * @param _errorSchema - The error schema parameter that is ignored
3526
3354
  * @param _fieldPath - The field path parameter that is ignored
3527
- */;
3528
- _proto.toErrorList = function toErrorList(_errorSchema, _fieldPath) {
3355
+ */
3356
+ toErrorList(_errorSchema, _fieldPath) {
3529
3357
  throw new Error('Unexpectedly calling the `toErrorList()` method during schema parsing');
3530
3358
  }
3531
3359
  /** Implements the `ValidatorType` `validateFormData()` method to throw an error since it is never supposed to be
@@ -3536,12 +3364,11 @@ var ParserValidator = /*#__PURE__*/function () {
3536
3364
  * @param _customValidate - The customValidate parameter that is ignored
3537
3365
  * @param _transformErrors - The transformErrors parameter that is ignored
3538
3366
  * @param _uiSchema - The uiSchema parameter that is ignored
3539
- */;
3540
- _proto.validateFormData = function validateFormData(_formData, _schema, _customValidate, _transformErrors, _uiSchema) {
3367
+ */
3368
+ validateFormData(_formData, _schema, _customValidate, _transformErrors, _uiSchema) {
3541
3369
  throw new Error('Unexpectedly calling the `validateFormData()` method during schema parsing');
3542
- };
3543
- return ParserValidator;
3544
- }();
3370
+ }
3371
+ }
3545
3372
 
3546
3373
  /** Recursive function used to parse the given `schema` belonging to the `rootSchema`. The `validator` is used to
3547
3374
  * capture the sub-schemas that the `isValid()` function is called with. For each schema returned by the
@@ -3554,17 +3381,15 @@ var ParserValidator = /*#__PURE__*/function () {
3554
3381
  * @param schema - The current schema element being parsed
3555
3382
  */
3556
3383
  function parseSchema(validator, recurseList, rootSchema, schema) {
3557
- var schemas = retrieveSchemaInternal(validator, schema, rootSchema, undefined, true);
3558
- schemas.forEach(function (schema) {
3559
- var sameSchemaIndex = recurseList.findIndex(function (item) {
3560
- return isEqual__default["default"](item, schema);
3561
- });
3384
+ const schemas = retrieveSchemaInternal(validator, schema, rootSchema, undefined, true);
3385
+ schemas.forEach(schema => {
3386
+ const sameSchemaIndex = recurseList.findIndex(item => isEqual__default["default"](item, schema));
3562
3387
  if (sameSchemaIndex === -1) {
3563
3388
  recurseList.push(schema);
3564
- var allOptions = resolveAnyOrOneOfSchemas(validator, schema, rootSchema, true);
3565
- allOptions.forEach(function (s) {
3389
+ const allOptions = resolveAnyOrOneOfSchemas(validator, schema, rootSchema, true);
3390
+ allOptions.forEach(s => {
3566
3391
  if (PROPERTIES_KEY in s && s[PROPERTIES_KEY]) {
3567
- forEach__default["default"](schema[PROPERTIES_KEY], function (value) {
3392
+ forEach__default["default"](schema[PROPERTIES_KEY], value => {
3568
3393
  parseSchema(validator, recurseList, rootSchema, value);
3569
3394
  });
3570
3395
  }
@@ -3582,8 +3407,8 @@ function parseSchema(validator, recurseList, rootSchema, schema) {
3582
3407
  * @returns - The `SchemaMap` of all schemas that were parsed
3583
3408
  */
3584
3409
  function schemaParser(rootSchema) {
3585
- var validator = new ParserValidator(rootSchema);
3586
- var recurseList = [];
3410
+ const validator = new ParserValidator(rootSchema);
3411
+ const recurseList = [];
3587
3412
  parseSchema(validator, recurseList, rootSchema, rootSchema);
3588
3413
  return validator.getSchemaMap();
3589
3414
  }