@rjsf/utils 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.esm.js CHANGED
@@ -13,7 +13,8 @@ import mergeAllOf from 'json-schema-merge-allof';
13
13
  import union from 'lodash-es/union';
14
14
  import isEqual from 'lodash-es/isEqual';
15
15
  import cloneDeep from 'lodash-es/cloneDeep';
16
- import React from 'react';
16
+ import { jsx } from 'react/jsx-runtime';
17
+ import { createElement } from 'react';
17
18
  import ReactIs from 'react-is';
18
19
 
19
20
  /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
@@ -23,13 +24,13 @@ import ReactIs from 'react-is';
23
24
  * @returns - True if it is a non-null, non-array, non-File object
24
25
  */
25
26
  function isObject(thing) {
26
- if (typeof File !== "undefined" && thing instanceof File) {
27
+ if (typeof File !== 'undefined' && thing instanceof File) {
27
28
  return false;
28
29
  }
29
- if (typeof Date !== "undefined" && thing instanceof Date) {
30
+ if (typeof Date !== 'undefined' && thing instanceof Date) {
30
31
  return false;
31
32
  }
32
- return typeof thing === "object" && thing !== null && !Array.isArray(thing);
33
+ return typeof thing === 'object' && thing !== null && !Array.isArray(thing);
33
34
  }
34
35
 
35
36
  /** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
@@ -40,7 +41,7 @@ function isObject(thing) {
40
41
  */
41
42
  function allowAdditionalItems(schema) {
42
43
  if (schema.additionalItems === true) {
43
- console.warn("additionalItems=true is currently not supported");
44
+ console.warn('additionalItems=true is currently not supported');
44
45
  }
45
46
  return isObject(schema.additionalItems);
46
47
  }
@@ -55,7 +56,7 @@ function allowAdditionalItems(schema) {
55
56
  * @returns - The `value` converted to a number when appropriate, otherwise the `value`
56
57
  */
57
58
  function asNumber(value) {
58
- if (value === "") {
59
+ if (value === '') {
59
60
  return undefined;
60
61
  }
61
62
  if (value === null) {
@@ -77,7 +78,7 @@ function asNumber(value) {
77
78
  return value;
78
79
  }
79
80
  var n = Number(value);
80
- var valid = typeof n === "number" && !Number.isNaN(n);
81
+ var valid = typeof n === 'number' && !Number.isNaN(n);
81
82
  return valid ? n : value;
82
83
  }
83
84
 
@@ -147,53 +148,58 @@ function _toPropertyKey(arg) {
147
148
  * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
148
149
  * utility.
149
150
  */
150
- var ADDITIONAL_PROPERTY_FLAG = "__additional_property";
151
- var ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
152
- var ALL_OF_KEY = "allOf";
153
- var ANY_OF_KEY = "anyOf";
154
- var CONST_KEY = "const";
155
- var DEFAULT_KEY = "default";
156
- var DEFINITIONS_KEY = "definitions";
157
- var DEPENDENCIES_KEY = "dependencies";
158
- var ENUM_KEY = "enum";
159
- var ERRORS_KEY = "__errors";
160
- var ID_KEY = "$id";
161
- var ITEMS_KEY = "items";
162
- var NAME_KEY = "$name";
163
- var ONE_OF_KEY = "oneOf";
164
- var PROPERTIES_KEY = "properties";
165
- var REQUIRED_KEY = "required";
166
- var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
167
- var REF_KEY = "$ref";
168
- var RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
169
- var UI_FIELD_KEY = "ui:field";
170
- var UI_WIDGET_KEY = "ui:widget";
171
- var UI_OPTIONS_KEY = "ui:options";
151
+ var ADDITIONAL_PROPERTY_FLAG = '__additional_property';
152
+ var ADDITIONAL_PROPERTIES_KEY = 'additionalProperties';
153
+ var ALL_OF_KEY = 'allOf';
154
+ var ANY_OF_KEY = 'anyOf';
155
+ var CONST_KEY = 'const';
156
+ var DEFAULT_KEY = 'default';
157
+ var DEFINITIONS_KEY = 'definitions';
158
+ var DEPENDENCIES_KEY = 'dependencies';
159
+ var ENUM_KEY = 'enum';
160
+ var ERRORS_KEY = '__errors';
161
+ var ID_KEY = '$id';
162
+ var ITEMS_KEY = 'items';
163
+ var NAME_KEY = '$name';
164
+ var ONE_OF_KEY = 'oneOf';
165
+ var PROPERTIES_KEY = 'properties';
166
+ var REQUIRED_KEY = 'required';
167
+ var SUBMIT_BTN_OPTIONS_KEY = 'submitButtonOptions';
168
+ var REF_KEY = '$ref';
169
+ var RJSF_ADDITONAL_PROPERTIES_FLAG = '__rjsf_additionalProperties';
170
+ var UI_FIELD_KEY = 'ui:field';
171
+ var UI_WIDGET_KEY = 'ui:widget';
172
+ var UI_OPTIONS_KEY = 'ui:options';
173
+ var UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
172
174
 
173
175
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
174
- * stripped off.
176
+ * stripped off. Any `globalOptions` will always be returned, unless they are overridden by options in the `uiSchema`.
175
177
  *
176
178
  * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
177
- * @returns - An object containing all the `ui:xxx` options with the stripped off
179
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
180
+ * @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
178
181
  */
179
- function getUiOptions(uiSchema) {
182
+ function getUiOptions(uiSchema, globalOptions) {
180
183
  if (uiSchema === void 0) {
181
184
  uiSchema = {};
182
185
  }
186
+ if (globalOptions === void 0) {
187
+ globalOptions = {};
188
+ }
183
189
  return Object.keys(uiSchema).filter(function (key) {
184
- return key.indexOf("ui:") === 0;
190
+ return key.indexOf('ui:') === 0;
185
191
  }).reduce(function (options, key) {
186
192
  var _extends2;
187
193
  var value = uiSchema[key];
188
194
  if (key === UI_WIDGET_KEY && isObject(value)) {
189
- console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
195
+ console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');
190
196
  return options;
191
197
  }
192
198
  if (key === UI_OPTIONS_KEY && isObject(value)) {
193
199
  return _extends({}, options, value);
194
200
  }
195
201
  return _extends({}, options, (_extends2 = {}, _extends2[key.substring(3)] = value, _extends2));
196
- }, {});
202
+ }, _extends({}, globalOptions));
197
203
  }
198
204
 
199
205
  /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
@@ -235,7 +241,7 @@ function canExpand(schema, uiSchema, formData) {
235
241
  */
236
242
  function deepEquals(a, b) {
237
243
  return isEqualWith(a, b, function (obj, other) {
238
- if (typeof obj === "function" && typeof other === "function") {
244
+ if (typeof obj === 'function' && typeof other === 'function') {
239
245
  // Assume all functions are equivalent
240
246
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
241
247
  return true;
@@ -270,8 +276,8 @@ function findSchemaDefinition($ref, rootSchema) {
270
276
  if (rootSchema === void 0) {
271
277
  rootSchema = {};
272
278
  }
273
- var ref = $ref || "";
274
- if (ref.startsWith("#")) {
279
+ var ref = $ref || '';
280
+ if (ref.startsWith('#')) {
275
281
  // Decode URI fragment representation.
276
282
  ref = decodeURIComponent(ref.substring(1));
277
283
  } else {
@@ -379,25 +385,25 @@ function getFirstMatchingOption(validator, formData, options, rootSchema) {
379
385
  */
380
386
  function guessType(value) {
381
387
  if (Array.isArray(value)) {
382
- return "array";
388
+ return 'array';
383
389
  }
384
- if (typeof value === "string") {
385
- return "string";
390
+ if (typeof value === 'string') {
391
+ return 'string';
386
392
  }
387
393
  if (value == null) {
388
- return "null";
394
+ return 'null';
389
395
  }
390
- if (typeof value === "boolean") {
391
- return "boolean";
396
+ if (typeof value === 'boolean') {
397
+ return 'boolean';
392
398
  }
393
399
  if (!isNaN(value)) {
394
- return "number";
400
+ return 'number';
395
401
  }
396
- if (typeof value === "object") {
397
- return "object";
402
+ if (typeof value === 'object') {
403
+ return 'object';
398
404
  }
399
405
  // Default to string if we can't figure it out
400
- return "string";
406
+ return 'string';
401
407
  }
402
408
 
403
409
  /** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
@@ -417,14 +423,14 @@ function getSchemaType(schema) {
417
423
  return guessType(schema["const"]);
418
424
  }
419
425
  if (!type && schema["enum"]) {
420
- return "string";
426
+ return 'string';
421
427
  }
422
428
  if (!type && (schema.properties || schema.additionalProperties)) {
423
- return "object";
429
+ return 'object';
424
430
  }
425
- if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
431
+ if (Array.isArray(type) && type.length === 2 && type.includes('null')) {
426
432
  type = type.find(function (type) {
427
- return type !== "null";
433
+ return type !== 'null';
428
434
  });
429
435
  }
430
436
  return type;
@@ -445,7 +451,7 @@ function mergeSchemas(obj1, obj2) {
445
451
  right = obj2[key];
446
452
  if (obj1 && key in obj1 && isObject(right)) {
447
453
  acc[key] = mergeSchemas(left, right);
448
- } else if (obj1 && obj2 && (getSchemaType(obj1) === "object" || getSchemaType(obj2) === "object") && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
454
+ } else if (obj1 && obj2 && (getSchemaType(obj1) === 'object' || getSchemaType(obj2) === 'object') && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
449
455
  // Don't include duplicate values when merging 'required' fields.
450
456
  acc[key] = union(left, right);
451
457
  } else {
@@ -475,7 +481,7 @@ function resolveCondition(validator, schema, rootSchema, formData) {
475
481
  otherwise = schema["else"],
476
482
  resolvedSchemaLessConditional = _objectWithoutPropertiesLoose(schema, _excluded$1);
477
483
  var conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
478
- if (conditionalSchema && typeof conditionalSchema !== "boolean") {
484
+ if (conditionalSchema && typeof conditionalSchema !== 'boolean') {
479
485
  return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
480
486
  }
481
487
  return retrieveSchema(validator, resolvedSchemaLessConditional, rootSchema, formData);
@@ -547,16 +553,16 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
547
553
  return;
548
554
  }
549
555
  var additionalProperties = {};
550
- if (typeof schema.additionalProperties !== "boolean") {
556
+ if (typeof schema.additionalProperties !== 'boolean') {
551
557
  if (REF_KEY in schema.additionalProperties) {
552
558
  additionalProperties = retrieveSchema(validator, {
553
559
  $ref: get(schema.additionalProperties, [REF_KEY])
554
560
  }, rootSchema, formData);
555
- } else if ("type" in schema.additionalProperties) {
561
+ } else if ('type' in schema.additionalProperties) {
556
562
  additionalProperties = _extends({}, schema.additionalProperties);
557
563
  } else if (ANY_OF_KEY in schema.additionalProperties || ONE_OF_KEY in schema.additionalProperties) {
558
564
  additionalProperties = _extends({
559
- type: "object"
565
+ type: 'object'
560
566
  }, schema.additionalProperties);
561
567
  } else {
562
568
  additionalProperties = {
@@ -593,7 +599,7 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
593
599
  return {};
594
600
  }
595
601
  var resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
596
- if ("if" in schema) {
602
+ if ('if' in schema) {
597
603
  return resolveCondition(validator, schema, rootSchema, rawFormData);
598
604
  }
599
605
  var formData = rawFormData || {};
@@ -603,7 +609,7 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
603
609
  deep: false
604
610
  });
605
611
  } catch (e) {
606
- console.warn("could not merge subschemas in allOf:\n" + e);
612
+ console.warn('could not merge subschemas in allOf:\n' + e);
607
613
  var _resolvedSchema = resolvedSchema,
608
614
  resolvedSchemaWithoutAllOf = _objectWithoutPropertiesLoose(_resolvedSchema, _excluded3);
609
615
  return resolvedSchemaWithoutAllOf;
@@ -704,7 +710,7 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
704
710
  }
705
711
  // Resolve $refs inside oneOf.
706
712
  var resolvedOneOf = oneOf.map(function (subschema) {
707
- if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
713
+ if (typeof subschema === 'boolean' || !(REF_KEY in subschema)) {
708
714
  return subschema;
709
715
  }
710
716
  return resolveReference(validator, subschema, rootSchema, formData);
@@ -723,14 +729,14 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
723
729
  */
724
730
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
725
731
  var validSubschemas = oneOf.filter(function (subschema) {
726
- if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
732
+ if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
727
733
  return false;
728
734
  }
729
735
  var conditionPropertySchema = subschema.properties[dependencyKey];
730
736
  if (conditionPropertySchema) {
731
737
  var _properties;
732
738
  var conditionSchema = {
733
- type: "object",
739
+ type: 'object',
734
740
  properties: (_properties = {}, _properties[dependencyKey] = conditionPropertySchema, _properties)
735
741
  };
736
742
  var _validator$validateFo = validator.validateFormData(formData, conditionSchema),
@@ -756,10 +762,10 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
756
762
  * the first item
757
763
  */
758
764
  var JUNK_OPTION = {
759
- type: "object",
765
+ type: 'object',
760
766
  properties: {
761
767
  __not_really_there__: {
762
- type: "number"
768
+ type: 'number'
763
769
  }
764
770
  }
765
771
  };
@@ -792,7 +798,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
792
798
  if (isObject$1(schema.properties)) {
793
799
  totalScore += reduce(schema.properties, function (score, value, key) {
794
800
  var formValue = get(formData, key);
795
- if (typeof value === "boolean") {
801
+ if (typeof value === 'boolean') {
796
802
  return score;
797
803
  }
798
804
  if (has(value, REF_KEY)) {
@@ -802,7 +808,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
802
808
  if (has(value, ONE_OF_KEY) && formValue) {
803
809
  return score + getClosestMatchingOption(validator, rootSchema, formValue, get(value, ONE_OF_KEY));
804
810
  }
805
- if (value.type === "object") {
811
+ if (value.type === 'object') {
806
812
  return score + calculateIndexScore(validator, rootSchema, value, formValue || {});
807
813
  }
808
814
  if (value.type === guessType(formValue)) {
@@ -962,7 +968,7 @@ function mergeObjects(obj1, obj2, concatArrays) {
962
968
  acc[key] = mergeObjects(left, right, concatArrays);
963
969
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
964
970
  var toMerge = right;
965
- if (concatArrays === "preventDuplicates") {
971
+ if (concatArrays === 'preventDuplicates') {
966
972
  toMerge = right.reduce(function (result, value) {
967
973
  if (!left.includes(value)) {
968
974
  result.push(value);
@@ -1006,7 +1012,7 @@ function isSelect(validator, theSchema, rootSchema) {
1006
1012
  }
1007
1013
  if (Array.isArray(altSchemas)) {
1008
1014
  return altSchemas.every(function (altSchemas) {
1009
- return typeof altSchemas !== "boolean" && isConstant(altSchemas);
1015
+ return typeof altSchemas !== 'boolean' && isConstant(altSchemas);
1010
1016
  });
1011
1017
  }
1012
1018
  return false;
@@ -1020,7 +1026,7 @@ function isSelect(validator, theSchema, rootSchema) {
1020
1026
  * @returns - True if schema contains a multi-select, otherwise false
1021
1027
  */
1022
1028
  function isMultiSelect(validator, schema, rootSchema) {
1023
- if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
1029
+ if (!schema.uniqueItems || !schema.items || typeof schema.items === 'boolean') {
1024
1030
  return false;
1025
1031
  }
1026
1032
  return isSelect(validator, schema.items, rootSchema);
@@ -1059,11 +1065,11 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
1059
1065
  if (idx >= 0) {
1060
1066
  if (Array.isArray(schema.items) && idx < schema.items.length) {
1061
1067
  var item = schema.items[idx];
1062
- if (typeof item !== "boolean") {
1068
+ if (typeof item !== 'boolean') {
1063
1069
  return item;
1064
1070
  }
1065
1071
  }
1066
- } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== "boolean") {
1072
+ } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {
1067
1073
  return schema.items;
1068
1074
  }
1069
1075
  if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {
@@ -1155,12 +1161,12 @@ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFo
1155
1161
  schema = schema.anyOf[getClosestMatchingOption(validator, rootSchema, isEmpty(formData) ? undefined : formData, schema.anyOf, 0)];
1156
1162
  }
1157
1163
  // Not defaults defined for this node, fallback to generic typed ones.
1158
- if (typeof defaults === "undefined") {
1164
+ if (typeof defaults === 'undefined') {
1159
1165
  defaults = schema["default"];
1160
1166
  }
1161
1167
  switch (getSchemaType(schema)) {
1162
1168
  // We need to recur for object schema inner default values.
1163
- case "object":
1169
+ case 'object':
1164
1170
  {
1165
1171
  var objectDefaults = Object.keys(schema.properties || {}).reduce(function (acc, key) {
1166
1172
  // Compute the defaults for this node, with the parent defaults we might
@@ -1180,7 +1186,7 @@ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFo
1180
1186
  }
1181
1187
  return objectDefaults;
1182
1188
  }
1183
- case "array":
1189
+ case 'array':
1184
1190
  // Inject defaults into existing array defaults
1185
1191
  if (Array.isArray(defaults)) {
1186
1192
  defaults = defaults.map(function (item, idx) {
@@ -1230,11 +1236,11 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
1230
1236
  includeUndefinedValues = false;
1231
1237
  }
1232
1238
  if (!isObject(theSchema)) {
1233
- throw new Error("Invalid schema: " + theSchema);
1239
+ throw new Error('Invalid schema: ' + theSchema);
1234
1240
  }
1235
1241
  var schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1236
1242
  var defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1237
- if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
1243
+ if (typeof formData === 'undefined' || formData === null || typeof formData === 'number' && isNaN(formData)) {
1238
1244
  // No form data? Use schema defaults.
1239
1245
  return defaults;
1240
1246
  }
@@ -1258,8 +1264,8 @@ function isCustomWidget(uiSchema) {
1258
1264
  }
1259
1265
  return (
1260
1266
  // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1261
- // https://react-jsonschema-form.readthedocs.io/en/latest/usage/widgets/#hidden-widgets
1262
- "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
1267
+ // https://rjsf-team.github.io/react-jsonschema-form/docs/usage/widgets/#hidden-widgets
1268
+ 'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden'
1263
1269
  );
1264
1270
  }
1265
1271
 
@@ -1275,12 +1281,12 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1275
1281
  if (uiSchema === void 0) {
1276
1282
  uiSchema = {};
1277
1283
  }
1278
- if (uiSchema[UI_WIDGET_KEY] === "files") {
1284
+ if (uiSchema[UI_WIDGET_KEY] === 'files') {
1279
1285
  return true;
1280
1286
  }
1281
1287
  if (schema.items) {
1282
1288
  var itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1283
- return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1289
+ return itemsSchema.type === 'string' && itemsSchema.format === 'data-url';
1284
1290
  }
1285
1291
  return false;
1286
1292
  }
@@ -1292,24 +1298,25 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1292
1298
  * @param schema - The schema for which the display label flag is desired
1293
1299
  * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
1294
1300
  * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1301
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1295
1302
  * @returns - True if the label should be displayed or false if it should not
1296
1303
  */
1297
- function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1304
+ function getDisplayLabel(validator, schema, uiSchema, rootSchema, globalOptions) {
1298
1305
  if (uiSchema === void 0) {
1299
1306
  uiSchema = {};
1300
1307
  }
1301
- var uiOptions = getUiOptions(uiSchema);
1308
+ var uiOptions = getUiOptions(uiSchema, globalOptions);
1302
1309
  var _uiOptions$label = uiOptions.label,
1303
1310
  label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1304
1311
  var displayLabel = !!label;
1305
1312
  var schemaType = getSchemaType(schema);
1306
- if (schemaType === "array") {
1313
+ if (schemaType === 'array') {
1307
1314
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1308
1315
  }
1309
- if (schemaType === "object") {
1316
+ if (schemaType === 'object') {
1310
1317
  displayLabel = false;
1311
1318
  }
1312
- if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
1319
+ if (schemaType === 'boolean' && !uiSchema[UI_WIDGET_KEY]) {
1313
1320
  displayLabel = false;
1314
1321
  }
1315
1322
  if (uiSchema[UI_FIELD_KEY]) {
@@ -1346,7 +1353,7 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1346
1353
  };
1347
1354
  }
1348
1355
 
1349
- var NO_VALUE = /*#__PURE__*/Symbol("no Value");
1356
+ var NO_VALUE = /*#__PURE__*/Symbol('no Value');
1350
1357
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new
1351
1358
  * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature
1352
1359
  * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema
@@ -1427,8 +1434,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1427
1434
  newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1428
1435
  }
1429
1436
  // Now get types and see if they are the same
1430
- var oldSchemaTypeForKey = get(oldKeyedSchema, "type");
1431
- var newSchemaTypeForKey = get(newKeyedSchema, "type");
1437
+ var oldSchemaTypeForKey = get(oldKeyedSchema, 'type');
1438
+ var newSchemaTypeForKey = get(newKeyedSchema, 'type');
1432
1439
  // Check if the old option has the same key with the same type
1433
1440
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
1434
1441
  if (has(removeOldSchemaData, key)) {
@@ -1436,10 +1443,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1436
1443
  delete removeOldSchemaData[key];
1437
1444
  }
1438
1445
  // If it is an object, we'll recurse and store the resulting sanitized data for the key
1439
- if (newSchemaTypeForKey === "object" || newSchemaTypeForKey === "array" && Array.isArray(formValue)) {
1446
+ if (newSchemaTypeForKey === 'object' || newSchemaTypeForKey === 'array' && Array.isArray(formValue)) {
1440
1447
  // SIDE-EFFECT: process the new schema type of object recursively to save iterations
1441
1448
  var itemData = sanitizeDataForNewSchema(validator, rootSchema, newKeyedSchema, oldKeyedSchema, formValue);
1442
- if (itemData !== undefined || newSchemaTypeForKey === "array") {
1449
+ if (itemData !== undefined || newSchemaTypeForKey === 'array') {
1443
1450
  // only put undefined values for the array type and not the object type
1444
1451
  nestedData[key] = itemData;
1445
1452
  }
@@ -1447,19 +1454,19 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1447
1454
  // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
1448
1455
  // with the new default or const. This allows the case where two schemas differ that only by the default/const
1449
1456
  // value to be properly selected
1450
- var newOptionDefault = get(newKeyedSchema, "default", NO_VALUE);
1451
- var oldOptionDefault = get(oldKeyedSchema, "default", NO_VALUE);
1457
+ var newOptionDefault = get(newKeyedSchema, 'default', NO_VALUE);
1458
+ var oldOptionDefault = get(oldKeyedSchema, 'default', NO_VALUE);
1452
1459
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
1453
1460
  if (oldOptionDefault === formValue) {
1454
1461
  // If the old default matches the formValue, we'll update the new value to match the new default
1455
1462
  removeOldSchemaData[key] = newOptionDefault;
1456
- } else if (get(newKeyedSchema, "readOnly") === true) {
1463
+ } else if (get(newKeyedSchema, 'readOnly') === true) {
1457
1464
  // If the new schema has the default set to read-only, treat it like a const and remove the value
1458
1465
  removeOldSchemaData[key] = undefined;
1459
1466
  }
1460
1467
  }
1461
- var newOptionConst = get(newKeyedSchema, "const", NO_VALUE);
1462
- var oldOptionConst = get(oldKeyedSchema, "const", NO_VALUE);
1468
+ var newOptionConst = get(newKeyedSchema, 'const', NO_VALUE);
1469
+ var oldOptionConst = get(oldKeyedSchema, 'const', NO_VALUE);
1463
1470
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
1464
1471
  // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
1465
1472
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
@@ -1469,12 +1476,12 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1469
1476
  });
1470
1477
  newFormData = _extends({}, data, removeOldSchemaData, nestedData);
1471
1478
  // First apply removing the old schema data, then apply the nested data, then apply the old data keys to keep
1472
- } else if (get(oldSchema, "type") === "array" && get(newSchema, "type") === "array" && Array.isArray(data)) {
1473
- var oldSchemaItems = get(oldSchema, "items");
1474
- var newSchemaItems = get(newSchema, "items");
1479
+ } else if (get(oldSchema, 'type') === 'array' && get(newSchema, 'type') === 'array' && Array.isArray(data)) {
1480
+ var oldSchemaItems = get(oldSchema, 'items');
1481
+ var newSchemaItems = get(newSchema, 'items');
1475
1482
  // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data
1476
1483
  // Eventually, we may want to deal with when either of the `items` are arrays since those tuple validations
1477
- if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1484
+ if (typeof oldSchemaItems === 'object' && typeof newSchemaItems === 'object' && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1478
1485
  if (has(oldSchemaItems, REF_KEY)) {
1479
1486
  oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
1480
1487
  }
@@ -1482,12 +1489,12 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1482
1489
  newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1483
1490
  }
1484
1491
  // Now get types and see if they are the same
1485
- var oldSchemaType = get(oldSchemaItems, "type");
1486
- var newSchemaType = get(newSchemaItems, "type");
1492
+ var oldSchemaType = get(oldSchemaItems, 'type');
1493
+ var newSchemaType = get(newSchemaItems, 'type');
1487
1494
  // Check if the old option has the same key with the same type
1488
1495
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
1489
- var maxItems = get(newSchema, "maxItems", -1);
1490
- if (newSchemaType === "object") {
1496
+ var maxItems = get(newSchema, 'maxItems', -1);
1497
+ if (newSchemaType === 'object') {
1491
1498
  newFormData = data.reduce(function (newValue, aValue) {
1492
1499
  var itemValue = sanitizeDataForNewSchema(validator, rootSchema, newSchemaItems, oldSchemaItems, aValue);
1493
1500
  if (itemValue !== undefined && (maxItems < 0 || newValue.length < maxItems)) {
@@ -1499,7 +1506,7 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1499
1506
  newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;
1500
1507
  }
1501
1508
  }
1502
- } else if (typeof oldSchemaItems === "boolean" && typeof newSchemaItems === "boolean" && oldSchemaItems === newSchemaItems) {
1509
+ } else if (typeof oldSchemaItems === 'boolean' && typeof newSchemaItems === 'boolean' && oldSchemaItems === newSchemaItems) {
1503
1510
  // If they are both booleans and have the same value just return the data as is otherwise fall-thru to undefined
1504
1511
  newFormData = data;
1505
1512
  }
@@ -1522,10 +1529,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1522
1529
  */
1523
1530
  function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSeparator) {
1524
1531
  if (idPrefix === void 0) {
1525
- idPrefix = "root";
1532
+ idPrefix = 'root';
1526
1533
  }
1527
1534
  if (idSeparator === void 0) {
1528
- idSeparator = "_";
1535
+ idSeparator = '_';
1529
1536
  }
1530
1537
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1531
1538
  var _schema = retrieveSchema(validator, schema, rootSchema, formData);
@@ -1538,7 +1545,7 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1538
1545
  var idSchema = {
1539
1546
  $id: $id
1540
1547
  };
1541
- if (schema.type === "object" && PROPERTIES_KEY in schema) {
1548
+ if (schema.type === 'object' && PROPERTIES_KEY in schema) {
1542
1549
  for (var name in schema.properties) {
1543
1550
  var field = get(schema, [PROPERTIES_KEY, name]);
1544
1551
  var fieldId = idSchema[ID_KEY] + idSeparator + name;
@@ -1563,13 +1570,13 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1563
1570
  function toPathSchema(validator, schema, name, rootSchema, formData) {
1564
1571
  var _pathSchema;
1565
1572
  if (name === void 0) {
1566
- name = "";
1573
+ name = '';
1567
1574
  }
1568
1575
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1569
1576
  var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1570
1577
  return toPathSchema(validator, _schema, name, rootSchema, formData);
1571
1578
  }
1572
- var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ""), _pathSchema);
1579
+ var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ''), _pathSchema);
1573
1580
  if (ONE_OF_KEY in schema) {
1574
1581
  var index = getClosestMatchingOption(validator, rootSchema, formData, schema.oneOf, 0);
1575
1582
  var _schema2 = schema.oneOf[index];
@@ -1659,10 +1666,11 @@ var SchemaUtils = /*#__PURE__*/function () {
1659
1666
  *
1660
1667
  * @param schema - The schema for which the display label flag is desired
1661
1668
  * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1669
+ * @param [globalOptions={}] - The optional Global UI Schema from which to get any fallback `xxx` options
1662
1670
  * @returns - True if the label should be displayed or false if it should not
1663
1671
  */;
1664
- _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema) {
1665
- return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1672
+ _proto.getDisplayLabel = function getDisplayLabel$1(schema, uiSchema, globalOptions) {
1673
+ return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema, globalOptions);
1666
1674
  }
1667
1675
  /** Determines which of the given `options` provided most closely matches the `formData`.
1668
1676
  * Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
@@ -1772,10 +1780,10 @@ var SchemaUtils = /*#__PURE__*/function () {
1772
1780
  */;
1773
1781
  _proto.toIdSchema = function toIdSchema$1(schema, id, formData, idPrefix, idSeparator) {
1774
1782
  if (idPrefix === void 0) {
1775
- idPrefix = "root";
1783
+ idPrefix = 'root';
1776
1784
  }
1777
1785
  if (idSeparator === void 0) {
1778
- idSeparator = "_";
1786
+ idSeparator = '_';
1779
1787
  }
1780
1788
  return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
1781
1789
  }
@@ -1810,38 +1818,48 @@ function createSchemaUtils(validator, rootSchema) {
1810
1818
  */
1811
1819
  function dataURItoBlob(dataURI) {
1812
1820
  // Split metadata from data
1813
- var splitted = dataURI.split(",");
1821
+ var splitted = dataURI.split(',');
1814
1822
  // Split params
1815
- var params = splitted[0].split(";");
1823
+ var params = splitted[0].split(';');
1816
1824
  // Get mime-type from params
1817
- var type = params[0].replace("data:", "");
1825
+ var type = params[0].replace('data:', '');
1818
1826
  // Filter the name property from params
1819
1827
  var properties = params.filter(function (param) {
1820
- return param.split("=")[0] === "name";
1828
+ return param.split('=')[0] === 'name';
1821
1829
  });
1822
1830
  // Look for the name and use unknown if no name property.
1823
1831
  var name;
1824
1832
  if (properties.length !== 1) {
1825
- name = "unknown";
1833
+ name = 'unknown';
1826
1834
  } else {
1827
1835
  // Because we filtered out the other property,
1828
- // we only have the name case here.
1829
- name = properties[0].split("=")[1];
1836
+ // we only have the name case here, which we decode to make it human-readable
1837
+ name = decodeURI(properties[0].split('=')[1]);
1830
1838
  }
1831
1839
  // Built the Uint8Array Blob parameter from the base64 string.
1832
- var binary = atob(splitted[1]);
1833
- var array = [];
1834
- for (var i = 0; i < binary.length; i++) {
1835
- array.push(binary.charCodeAt(i));
1836
- }
1837
- // Create the blob object
1838
- var blob = new window.Blob([new Uint8Array(array)], {
1839
- type: type
1840
- });
1841
- return {
1842
- blob: blob,
1843
- name: name
1844
- };
1840
+ try {
1841
+ var binary = atob(splitted[1]);
1842
+ var array = [];
1843
+ for (var i = 0; i < binary.length; i++) {
1844
+ array.push(binary.charCodeAt(i));
1845
+ }
1846
+ // Create the blob object
1847
+ var blob = new window.Blob([new Uint8Array(array)], {
1848
+ type: type
1849
+ });
1850
+ return {
1851
+ blob: blob,
1852
+ name: name
1853
+ };
1854
+ } catch (error) {
1855
+ return {
1856
+ blob: {
1857
+ size: 0,
1858
+ type: error.message
1859
+ },
1860
+ name: dataURI
1861
+ };
1862
+ }
1845
1863
  }
1846
1864
 
1847
1865
  /** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When
@@ -1855,9 +1873,16 @@ function dataURItoBlob(dataURI) {
1855
1873
  function replaceStringParameters(inputString, params) {
1856
1874
  var output = inputString;
1857
1875
  if (Array.isArray(params)) {
1876
+ var parts = output.split(/(%\d)/);
1858
1877
  params.forEach(function (param, index) {
1859
- output = output.replace("%" + (index + 1), param);
1878
+ var partIndex = parts.findIndex(function (part) {
1879
+ return part === "%" + (index + 1);
1880
+ });
1881
+ if (partIndex >= 0) {
1882
+ parts[partIndex] = param;
1883
+ }
1860
1884
  });
1885
+ output = parts.join('');
1861
1886
  }
1862
1887
  return output;
1863
1888
  }
@@ -1897,7 +1922,7 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions, emptyValue) {
1897
1922
  });
1898
1923
  }
1899
1924
  // So Number(null) and Number('') both return 0, so use emptyValue for those two values
1900
- var index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
1925
+ var index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);
1901
1926
  var option = allEnumOptions[index];
1902
1927
  return option ? option.value : emptyValue;
1903
1928
  }
@@ -1963,7 +1988,7 @@ function enumOptionsIndexForValue(value, allEnumOptions, multiple) {
1963
1988
  var selectedIndexes = allEnumOptions.map(function (opt, index) {
1964
1989
  return enumOptionsIsSelected(opt.value, value) ? String(index) : undefined;
1965
1990
  }).filter(function (opt) {
1966
- return typeof opt !== "undefined";
1991
+ return typeof opt !== 'undefined';
1967
1992
  });
1968
1993
  if (!multiple) {
1969
1994
  return selectedIndexes[0];
@@ -2031,7 +2056,7 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2031
2056
  * @private
2032
2057
  */
2033
2058
  _proto.getOrCreateErrorBlock = function getOrCreateErrorBlock(pathOfError) {
2034
- var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
2059
+ var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === 'string';
2035
2060
  var errorBlock = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;
2036
2061
  if (!errorBlock && pathOfError) {
2037
2062
  errorBlock = {};
@@ -2143,23 +2168,23 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
2143
2168
  autoDefaultStepAny = true;
2144
2169
  }
2145
2170
  var inputProps = _extends({
2146
- type: defaultType || "text"
2171
+ type: defaultType || 'text'
2147
2172
  }, rangeSpec(schema));
2148
2173
  // If options.inputType is set use that as the input type
2149
2174
  if (options.inputType) {
2150
2175
  inputProps.type = options.inputType;
2151
2176
  } else if (!defaultType) {
2152
2177
  // If the schema is of type number or integer, set the input type to number
2153
- if (schema.type === "number") {
2154
- inputProps.type = "number";
2178
+ if (schema.type === 'number') {
2179
+ inputProps.type = 'number';
2155
2180
  // Only add step if one isn't already defined and we are auto-defaulting the "any" step
2156
2181
  if (autoDefaultStepAny && inputProps.step === undefined) {
2157
2182
  // Setting step to 'any' fixes a bug in Safari where decimals are not
2158
2183
  // allowed in number inputs
2159
- inputProps.step = "any";
2184
+ inputProps.step = 'any';
2160
2185
  }
2161
- } else if (schema.type === "integer") {
2162
- inputProps.type = "number";
2186
+ } else if (schema.type === 'integer') {
2187
+ inputProps.type = 'number';
2163
2188
  // Only add step if one isn't already defined
2164
2189
  if (inputProps.step === undefined) {
2165
2190
  // Since this is integer, you always want to step up or down in multiples of 1
@@ -2179,7 +2204,7 @@ var DEFAULT_OPTIONS = {
2179
2204
  props: {
2180
2205
  disabled: false
2181
2206
  },
2182
- submitText: "Submit",
2207
+ submitText: 'Submit',
2183
2208
  norender: false
2184
2209
  };
2185
2210
  /** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
@@ -2212,7 +2237,7 @@ function getTemplate(name, registry, uiOptions) {
2212
2237
  uiOptions = {};
2213
2238
  }
2214
2239
  var templates = registry.templates;
2215
- if (name === "ButtonTemplates") {
2240
+ if (name === 'ButtonTemplates') {
2216
2241
  return templates[name];
2217
2242
  }
2218
2243
  return (
@@ -2227,53 +2252,54 @@ var _excluded = ["options"];
2227
2252
  */
2228
2253
  var widgetMap = {
2229
2254
  "boolean": {
2230
- checkbox: "CheckboxWidget",
2231
- radio: "RadioWidget",
2232
- select: "SelectWidget",
2233
- hidden: "HiddenWidget"
2255
+ checkbox: 'CheckboxWidget',
2256
+ radio: 'RadioWidget',
2257
+ select: 'SelectWidget',
2258
+ hidden: 'HiddenWidget'
2234
2259
  },
2235
2260
  string: {
2236
- text: "TextWidget",
2237
- password: "PasswordWidget",
2238
- email: "EmailWidget",
2239
- hostname: "TextWidget",
2240
- ipv4: "TextWidget",
2241
- ipv6: "TextWidget",
2242
- uri: "URLWidget",
2243
- "data-url": "FileWidget",
2244
- radio: "RadioWidget",
2245
- select: "SelectWidget",
2246
- textarea: "TextareaWidget",
2247
- hidden: "HiddenWidget",
2248
- date: "DateWidget",
2249
- datetime: "DateTimeWidget",
2250
- "date-time": "DateTimeWidget",
2251
- "alt-date": "AltDateWidget",
2252
- "alt-datetime": "AltDateTimeWidget",
2253
- color: "ColorWidget",
2254
- file: "FileWidget"
2261
+ text: 'TextWidget',
2262
+ password: 'PasswordWidget',
2263
+ email: 'EmailWidget',
2264
+ hostname: 'TextWidget',
2265
+ ipv4: 'TextWidget',
2266
+ ipv6: 'TextWidget',
2267
+ uri: 'URLWidget',
2268
+ 'data-url': 'FileWidget',
2269
+ radio: 'RadioWidget',
2270
+ select: 'SelectWidget',
2271
+ textarea: 'TextareaWidget',
2272
+ hidden: 'HiddenWidget',
2273
+ date: 'DateWidget',
2274
+ datetime: 'DateTimeWidget',
2275
+ 'date-time': 'DateTimeWidget',
2276
+ 'alt-date': 'AltDateWidget',
2277
+ 'alt-datetime': 'AltDateTimeWidget',
2278
+ time: 'TimeWidget',
2279
+ color: 'ColorWidget',
2280
+ file: 'FileWidget'
2255
2281
  },
2256
2282
  number: {
2257
- text: "TextWidget",
2258
- select: "SelectWidget",
2259
- updown: "UpDownWidget",
2260
- range: "RangeWidget",
2261
- radio: "RadioWidget",
2262
- hidden: "HiddenWidget"
2283
+ text: 'TextWidget',
2284
+ select: 'SelectWidget',
2285
+ updown: 'UpDownWidget',
2286
+ range: 'RangeWidget',
2287
+ radio: 'RadioWidget',
2288
+ hidden: 'HiddenWidget'
2263
2289
  },
2264
2290
  integer: {
2265
- text: "TextWidget",
2266
- select: "SelectWidget",
2267
- updown: "UpDownWidget",
2268
- range: "RangeWidget",
2269
- radio: "RadioWidget",
2270
- hidden: "HiddenWidget"
2291
+ text: 'TextWidget',
2292
+ select: 'SelectWidget',
2293
+ updown: 'UpDownWidget',
2294
+ range: 'RangeWidget',
2295
+ radio: 'RadioWidget',
2296
+ hidden: 'HiddenWidget'
2271
2297
  },
2272
2298
  array: {
2273
- select: "SelectWidget",
2274
- checkboxes: "CheckboxesWidget",
2275
- files: "FileWidget",
2276
- hidden: "HiddenWidget"
2299
+ select: 'SelectWidget',
2300
+ checkboxes: 'CheckboxesWidget',
2301
+ files: 'FileWidget',
2302
+ hidden: 'HiddenWidget'
2277
2303
  }
2278
2304
  };
2279
2305
  /** Wraps the given widget with stateless functional component that will merge any `defaultProps.options` with the
@@ -2284,18 +2310,18 @@ var widgetMap = {
2284
2310
  * @returns - The wrapper widget
2285
2311
  */
2286
2312
  function mergeWidgetOptions(AWidget) {
2287
- var MergedWidget = get(AWidget, "MergedWidget");
2313
+ var MergedWidget = get(AWidget, 'MergedWidget');
2288
2314
  // cache return value as property of widget for proper react reconciliation
2289
2315
  if (!MergedWidget) {
2290
2316
  var defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
2291
2317
  MergedWidget = function MergedWidget(_ref) {
2292
2318
  var options = _ref.options,
2293
2319
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
2294
- return /*#__PURE__*/React.createElement(AWidget, _extends({
2320
+ return jsx(AWidget, _extends({
2295
2321
  options: _extends({}, defaultOptions, options)
2296
2322
  }, props));
2297
2323
  };
2298
- set(AWidget, "MergedWidget", MergedWidget);
2324
+ set(AWidget, 'MergedWidget', MergedWidget);
2299
2325
  }
2300
2326
  return MergedWidget;
2301
2327
  }
@@ -2315,17 +2341,17 @@ function getWidget(schema, widget, registeredWidgets) {
2315
2341
  registeredWidgets = {};
2316
2342
  }
2317
2343
  var type = getSchemaType(schema);
2318
- if (typeof widget === "function" || widget && ReactIs.isForwardRef( /*#__PURE__*/React.createElement(widget)) || ReactIs.isMemo(widget)) {
2344
+ if (typeof widget === 'function' || widget && ReactIs.isForwardRef( /*#__PURE__*/createElement(widget)) || ReactIs.isMemo(widget)) {
2319
2345
  return mergeWidgetOptions(widget);
2320
2346
  }
2321
- if (typeof widget !== "string") {
2347
+ if (typeof widget !== 'string') {
2322
2348
  throw new Error("Unsupported widget definition: " + typeof widget);
2323
2349
  }
2324
2350
  if (widget in registeredWidgets) {
2325
2351
  var registeredWidget = registeredWidgets[widget];
2326
2352
  return getWidget(schema, registeredWidget, registeredWidgets);
2327
2353
  }
2328
- if (typeof type === "string") {
2354
+ if (typeof type === 'string') {
2329
2355
  if (!(type in widgetMap)) {
2330
2356
  throw new Error("No widget for type '" + type + "'");
2331
2357
  }
@@ -2354,7 +2380,7 @@ function hasWidget(schema, widget, registeredWidgets) {
2354
2380
  return true;
2355
2381
  } catch (e) {
2356
2382
  var err = e;
2357
- if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
2383
+ if (err.message && (err.message.startsWith('No widget') || err.message.startsWith('Unsupported widget'))) {
2358
2384
  return false;
2359
2385
  }
2360
2386
  throw e;
@@ -2376,7 +2402,7 @@ function idGenerator(id, suffix) {
2376
2402
  * @returns - The consistent id for the field description element from the given `id`
2377
2403
  */
2378
2404
  function descriptionId(id) {
2379
- return idGenerator(id, "description");
2405
+ return idGenerator(id, 'description');
2380
2406
  }
2381
2407
  /** Return a consistent `id` for the field error element
2382
2408
  *
@@ -2384,7 +2410,7 @@ function descriptionId(id) {
2384
2410
  * @returns - The consistent id for the field error element from the given `id`
2385
2411
  */
2386
2412
  function errorId(id) {
2387
- return idGenerator(id, "error");
2413
+ return idGenerator(id, 'error');
2388
2414
  }
2389
2415
  /** Return a consistent `id` for the field examples element
2390
2416
  *
@@ -2392,7 +2418,7 @@ function errorId(id) {
2392
2418
  * @returns - The consistent id for the field examples element from the given `id`
2393
2419
  */
2394
2420
  function examplesId(id) {
2395
- return idGenerator(id, "examples");
2421
+ return idGenerator(id, 'examples');
2396
2422
  }
2397
2423
  /** Return a consistent `id` for the field help element
2398
2424
  *
@@ -2400,7 +2426,7 @@ function examplesId(id) {
2400
2426
  * @returns - The consistent id for the field help element from the given `id`
2401
2427
  */
2402
2428
  function helpId(id) {
2403
- return idGenerator(id, "help");
2429
+ return idGenerator(id, 'help');
2404
2430
  }
2405
2431
  /** Return a consistent `id` for the field title element
2406
2432
  *
@@ -2408,7 +2434,7 @@ function helpId(id) {
2408
2434
  * @returns - The consistent id for the field title element from the given `id`
2409
2435
  */
2410
2436
  function titleId(id) {
2411
- return idGenerator(id, "title");
2437
+ return idGenerator(id, 'title');
2412
2438
  }
2413
2439
  /** Return a list of element ids that contain additional information about the field that can be used to as the aria
2414
2440
  * description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
@@ -2422,7 +2448,7 @@ function ariaDescribedByIds(id, includeExamples) {
2422
2448
  if (includeExamples === void 0) {
2423
2449
  includeExamples = false;
2424
2450
  }
2425
- var examples = includeExamples ? " " + examplesId(id) : "";
2451
+ var examples = includeExamples ? " " + examplesId(id) : '';
2426
2452
  return errorId(id) + " " + descriptionId(id) + " " + helpId(id) + examples;
2427
2453
  }
2428
2454
  /** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget
@@ -2458,7 +2484,7 @@ function toConstant(schema) {
2458
2484
  if (CONST_KEY in schema) {
2459
2485
  return schema["const"];
2460
2486
  }
2461
- throw new Error("schema cannot be inferred as a constant");
2487
+ throw new Error('schema cannot be inferred as a constant');
2462
2488
  }
2463
2489
 
2464
2490
  /** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
@@ -2473,8 +2499,8 @@ function optionsList(schema) {
2473
2499
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
2474
2500
  // Cast the type to include enumNames so the feature still works.
2475
2501
  var schemaWithEnumNames = schema;
2476
- if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== "production") {
2477
- console.warn("The enumNames property is deprecated and may be removed in a future major release.");
2502
+ if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== 'production') {
2503
+ console.warn('The enumNames property is deprecated and may be removed in a future major release.');
2478
2504
  }
2479
2505
  if (schema["enum"]) {
2480
2506
  return schema["enum"].map(function (value, i) {
@@ -2523,21 +2549,21 @@ function orderProperties(properties, order) {
2523
2549
  };
2524
2550
  var propertyHash = arrayToHash(properties);
2525
2551
  var orderFiltered = order.filter(function (prop) {
2526
- return prop === "*" || propertyHash[prop];
2552
+ return prop === '*' || propertyHash[prop];
2527
2553
  });
2528
2554
  var orderHash = arrayToHash(orderFiltered);
2529
2555
  var rest = properties.filter(function (prop) {
2530
2556
  return !orderHash[prop];
2531
2557
  });
2532
- var restIndex = orderFiltered.indexOf("*");
2558
+ var restIndex = orderFiltered.indexOf('*');
2533
2559
  if (restIndex === -1) {
2534
2560
  if (rest.length) {
2535
2561
  throw new Error("uiSchema order list does not contain " + errorPropList(rest));
2536
2562
  }
2537
2563
  return orderFiltered;
2538
2564
  }
2539
- if (restIndex !== orderFiltered.lastIndexOf("*")) {
2540
- throw new Error("uiSchema order list contains more than one wildcard item");
2565
+ if (restIndex !== orderFiltered.lastIndexOf('*')) {
2566
+ throw new Error('uiSchema order list contains more than one wildcard item');
2541
2567
  }
2542
2568
  var complete = [].concat(orderFiltered);
2543
2569
  complete.splice.apply(complete, [restIndex, 1].concat(rest));
@@ -2553,7 +2579,7 @@ function orderProperties(properties, order) {
2553
2579
  function pad(num, width) {
2554
2580
  var s = String(num);
2555
2581
  while (s.length < width) {
2556
- s = "0" + s;
2582
+ s = '0' + s;
2557
2583
  }
2558
2584
  return s;
2559
2585
  }
@@ -2581,7 +2607,7 @@ function parseDateString(dateString, includeTime) {
2581
2607
  }
2582
2608
  var date = new Date(dateString);
2583
2609
  if (Number.isNaN(date.getTime())) {
2584
- throw new Error("Unable to parse date " + dateString);
2610
+ throw new Error('Unable to parse date ' + dateString);
2585
2611
  }
2586
2612
  return {
2587
2613
  year: date.getUTCFullYear(),
@@ -2675,7 +2701,7 @@ function toDateString(dateObject, time) {
2675
2701
  */
2676
2702
  function utcToLocal(jsonDate) {
2677
2703
  if (!jsonDate) {
2678
- return "";
2704
+ return '';
2679
2705
  }
2680
2706
  // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'
2681
2707
  // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)
@@ -2719,6 +2745,8 @@ var TranslatableString;
2719
2745
  TranslatableString["AddButton"] = "Add";
2720
2746
  /** Add button title, used by AddButton */
2721
2747
  TranslatableString["AddItemButton"] = "Add Item";
2748
+ /** Copy button title, used by IconButton */
2749
+ TranslatableString["CopyButton"] = "Copy";
2722
2750
  /** Move down button title, used by IconButton */
2723
2751
  TranslatableString["MoveDownButton"] = "Move down";
2724
2752
  /** Move up button title, used by IconButton */
@@ -2747,6 +2775,8 @@ var TranslatableString;
2747
2775
  /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
2748
2776
  TranslatableString["KeyLabel"] = "%1 Key";
2749
2777
  // Strings with replaceable parameters AND/OR that support markdown and html
2778
+ /** Invalid object field configuration as provided by the ObjectField */
2779
+ TranslatableString["InvalidObjectField"] = "Invalid \"%1\" object field configuration: <em>%2</em>.";
2750
2780
  /** Unsupported field schema, used by UnsupportedField */
2751
2781
  TranslatableString["UnsupportedField"] = "Unsupported field schema.";
2752
2782
  /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
@@ -2763,5 +2793,5 @@ var TranslatableString;
2763
2793
  TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
2764
2794
  })(TranslatableString || (TranslatableString = {}));
2765
2795
 
2766
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, TranslatableString, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2796
+ export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, TranslatableString, UI_FIELD_KEY, UI_GLOBAL_OPTIONS_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, findSchemaDefinition, getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, helpId, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2767
2797
  //# sourceMappingURL=utils.esm.js.map