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