@rjsf/utils 5.1.0 → 5.2.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.
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,28 +148,28 @@ 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';
172
173
 
173
174
  /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
174
175
  * stripped off.
@@ -181,12 +182,12 @@ function getUiOptions(uiSchema) {
181
182
  uiSchema = {};
182
183
  }
183
184
  return Object.keys(uiSchema).filter(function (key) {
184
- return key.indexOf("ui:") === 0;
185
+ return key.indexOf('ui:') === 0;
185
186
  }).reduce(function (options, key) {
186
187
  var _extends2;
187
188
  var value = uiSchema[key];
188
189
  if (key === UI_WIDGET_KEY && isObject(value)) {
189
- console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
190
+ console.error('Setting options via ui:widget object is no longer supported, use ui:options instead');
190
191
  return options;
191
192
  }
192
193
  if (key === UI_OPTIONS_KEY && isObject(value)) {
@@ -235,7 +236,7 @@ function canExpand(schema, uiSchema, formData) {
235
236
  */
236
237
  function deepEquals(a, b) {
237
238
  return isEqualWith(a, b, function (obj, other) {
238
- if (typeof obj === "function" && typeof other === "function") {
239
+ if (typeof obj === 'function' && typeof other === 'function') {
239
240
  // Assume all functions are equivalent
240
241
  // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
241
242
  return true;
@@ -270,8 +271,8 @@ function findSchemaDefinition($ref, rootSchema) {
270
271
  if (rootSchema === void 0) {
271
272
  rootSchema = {};
272
273
  }
273
- var ref = $ref || "";
274
- if (ref.startsWith("#")) {
274
+ var ref = $ref || '';
275
+ if (ref.startsWith('#')) {
275
276
  // Decode URI fragment representation.
276
277
  ref = decodeURIComponent(ref.substring(1));
277
278
  } else {
@@ -379,25 +380,25 @@ function getFirstMatchingOption(validator, formData, options, rootSchema) {
379
380
  */
380
381
  function guessType(value) {
381
382
  if (Array.isArray(value)) {
382
- return "array";
383
+ return 'array';
383
384
  }
384
- if (typeof value === "string") {
385
- return "string";
385
+ if (typeof value === 'string') {
386
+ return 'string';
386
387
  }
387
388
  if (value == null) {
388
- return "null";
389
+ return 'null';
389
390
  }
390
- if (typeof value === "boolean") {
391
- return "boolean";
391
+ if (typeof value === 'boolean') {
392
+ return 'boolean';
392
393
  }
393
394
  if (!isNaN(value)) {
394
- return "number";
395
+ return 'number';
395
396
  }
396
- if (typeof value === "object") {
397
- return "object";
397
+ if (typeof value === 'object') {
398
+ return 'object';
398
399
  }
399
400
  // Default to string if we can't figure it out
400
- return "string";
401
+ return 'string';
401
402
  }
402
403
 
403
404
  /** 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 +418,14 @@ function getSchemaType(schema) {
417
418
  return guessType(schema["const"]);
418
419
  }
419
420
  if (!type && schema["enum"]) {
420
- return "string";
421
+ return 'string';
421
422
  }
422
423
  if (!type && (schema.properties || schema.additionalProperties)) {
423
- return "object";
424
+ return 'object';
424
425
  }
425
- if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
426
+ if (Array.isArray(type) && type.length === 2 && type.includes('null')) {
426
427
  type = type.find(function (type) {
427
- return type !== "null";
428
+ return type !== 'null';
428
429
  });
429
430
  }
430
431
  return type;
@@ -445,7 +446,7 @@ function mergeSchemas(obj1, obj2) {
445
446
  right = obj2[key];
446
447
  if (obj1 && key in obj1 && isObject(right)) {
447
448
  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)) {
449
+ } else if (obj1 && obj2 && (getSchemaType(obj1) === 'object' || getSchemaType(obj2) === 'object') && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
449
450
  // Don't include duplicate values when merging 'required' fields.
450
451
  acc[key] = union(left, right);
451
452
  } else {
@@ -475,7 +476,7 @@ function resolveCondition(validator, schema, rootSchema, formData) {
475
476
  otherwise = schema["else"],
476
477
  resolvedSchemaLessConditional = _objectWithoutPropertiesLoose(schema, _excluded$1);
477
478
  var conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
478
- if (conditionalSchema && typeof conditionalSchema !== "boolean") {
479
+ if (conditionalSchema && typeof conditionalSchema !== 'boolean') {
479
480
  return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
480
481
  }
481
482
  return retrieveSchema(validator, resolvedSchemaLessConditional, rootSchema, formData);
@@ -547,16 +548,16 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
547
548
  return;
548
549
  }
549
550
  var additionalProperties = {};
550
- if (typeof schema.additionalProperties !== "boolean") {
551
+ if (typeof schema.additionalProperties !== 'boolean') {
551
552
  if (REF_KEY in schema.additionalProperties) {
552
553
  additionalProperties = retrieveSchema(validator, {
553
554
  $ref: get(schema.additionalProperties, [REF_KEY])
554
555
  }, rootSchema, formData);
555
- } else if ("type" in schema.additionalProperties) {
556
+ } else if ('type' in schema.additionalProperties) {
556
557
  additionalProperties = _extends({}, schema.additionalProperties);
557
558
  } else if (ANY_OF_KEY in schema.additionalProperties || ONE_OF_KEY in schema.additionalProperties) {
558
559
  additionalProperties = _extends({
559
- type: "object"
560
+ type: 'object'
560
561
  }, schema.additionalProperties);
561
562
  } else {
562
563
  additionalProperties = {
@@ -593,7 +594,7 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
593
594
  return {};
594
595
  }
595
596
  var resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
596
- if ("if" in schema) {
597
+ if ('if' in schema) {
597
598
  return resolveCondition(validator, schema, rootSchema, rawFormData);
598
599
  }
599
600
  var formData = rawFormData || {};
@@ -603,7 +604,7 @@ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
603
604
  deep: false
604
605
  });
605
606
  } catch (e) {
606
- console.warn("could not merge subschemas in allOf:\n" + e);
607
+ console.warn('could not merge subschemas in allOf:\n' + e);
607
608
  var _resolvedSchema = resolvedSchema,
608
609
  resolvedSchemaWithoutAllOf = _objectWithoutPropertiesLoose(_resolvedSchema, _excluded3);
609
610
  return resolvedSchemaWithoutAllOf;
@@ -704,7 +705,7 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
704
705
  }
705
706
  // Resolve $refs inside oneOf.
706
707
  var resolvedOneOf = oneOf.map(function (subschema) {
707
- if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
708
+ if (typeof subschema === 'boolean' || !(REF_KEY in subschema)) {
708
709
  return subschema;
709
710
  }
710
711
  return resolveReference(validator, subschema, rootSchema, formData);
@@ -723,14 +724,14 @@ function withDependentSchema(validator, schema, rootSchema, dependencyKey, depen
723
724
  */
724
725
  function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
725
726
  var validSubschemas = oneOf.filter(function (subschema) {
726
- if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
727
+ if (typeof subschema === 'boolean' || !subschema || !subschema.properties) {
727
728
  return false;
728
729
  }
729
730
  var conditionPropertySchema = subschema.properties[dependencyKey];
730
731
  if (conditionPropertySchema) {
731
732
  var _properties;
732
733
  var conditionSchema = {
733
- type: "object",
734
+ type: 'object',
734
735
  properties: (_properties = {}, _properties[dependencyKey] = conditionPropertySchema, _properties)
735
736
  };
736
737
  var _validator$validateFo = validator.validateFormData(formData, conditionSchema),
@@ -756,10 +757,10 @@ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, o
756
757
  * the first item
757
758
  */
758
759
  var JUNK_OPTION = {
759
- type: "object",
760
+ type: 'object',
760
761
  properties: {
761
762
  __not_really_there__: {
762
- type: "number"
763
+ type: 'number'
763
764
  }
764
765
  }
765
766
  };
@@ -792,7 +793,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
792
793
  if (isObject$1(schema.properties)) {
793
794
  totalScore += reduce(schema.properties, function (score, value, key) {
794
795
  var formValue = get(formData, key);
795
- if (typeof value === "boolean") {
796
+ if (typeof value === 'boolean') {
796
797
  return score;
797
798
  }
798
799
  if (has(value, REF_KEY)) {
@@ -802,7 +803,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData) {
802
803
  if (has(value, ONE_OF_KEY) && formValue) {
803
804
  return score + getClosestMatchingOption(validator, rootSchema, formValue, get(value, ONE_OF_KEY));
804
805
  }
805
- if (value.type === "object") {
806
+ if (value.type === 'object') {
806
807
  return score + calculateIndexScore(validator, rootSchema, value, formValue || {});
807
808
  }
808
809
  if (value.type === guessType(formValue)) {
@@ -962,7 +963,7 @@ function mergeObjects(obj1, obj2, concatArrays) {
962
963
  acc[key] = mergeObjects(left, right, concatArrays);
963
964
  } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
964
965
  var toMerge = right;
965
- if (concatArrays === "preventDuplicates") {
966
+ if (concatArrays === 'preventDuplicates') {
966
967
  toMerge = right.reduce(function (result, value) {
967
968
  if (!left.includes(value)) {
968
969
  result.push(value);
@@ -1006,7 +1007,7 @@ function isSelect(validator, theSchema, rootSchema) {
1006
1007
  }
1007
1008
  if (Array.isArray(altSchemas)) {
1008
1009
  return altSchemas.every(function (altSchemas) {
1009
- return typeof altSchemas !== "boolean" && isConstant(altSchemas);
1010
+ return typeof altSchemas !== 'boolean' && isConstant(altSchemas);
1010
1011
  });
1011
1012
  }
1012
1013
  return false;
@@ -1020,7 +1021,7 @@ function isSelect(validator, theSchema, rootSchema) {
1020
1021
  * @returns - True if schema contains a multi-select, otherwise false
1021
1022
  */
1022
1023
  function isMultiSelect(validator, schema, rootSchema) {
1023
- if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
1024
+ if (!schema.uniqueItems || !schema.items || typeof schema.items === 'boolean') {
1024
1025
  return false;
1025
1026
  }
1026
1027
  return isSelect(validator, schema.items, rootSchema);
@@ -1059,11 +1060,11 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
1059
1060
  if (idx >= 0) {
1060
1061
  if (Array.isArray(schema.items) && idx < schema.items.length) {
1061
1062
  var item = schema.items[idx];
1062
- if (typeof item !== "boolean") {
1063
+ if (typeof item !== 'boolean') {
1063
1064
  return item;
1064
1065
  }
1065
1066
  }
1066
- } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== "boolean") {
1067
+ } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== 'boolean') {
1067
1068
  return schema.items;
1068
1069
  }
1069
1070
  if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {
@@ -1155,12 +1156,12 @@ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFo
1155
1156
  schema = schema.anyOf[getClosestMatchingOption(validator, rootSchema, isEmpty(formData) ? undefined : formData, schema.anyOf, 0)];
1156
1157
  }
1157
1158
  // Not defaults defined for this node, fallback to generic typed ones.
1158
- if (typeof defaults === "undefined") {
1159
+ if (typeof defaults === 'undefined') {
1159
1160
  defaults = schema["default"];
1160
1161
  }
1161
1162
  switch (getSchemaType(schema)) {
1162
1163
  // We need to recur for object schema inner default values.
1163
- case "object":
1164
+ case 'object':
1164
1165
  {
1165
1166
  var objectDefaults = Object.keys(schema.properties || {}).reduce(function (acc, key) {
1166
1167
  // Compute the defaults for this node, with the parent defaults we might
@@ -1180,7 +1181,7 @@ function computeDefaults(validator, rawSchema, parentDefaults, rootSchema, rawFo
1180
1181
  }
1181
1182
  return objectDefaults;
1182
1183
  }
1183
- case "array":
1184
+ case 'array':
1184
1185
  // Inject defaults into existing array defaults
1185
1186
  if (Array.isArray(defaults)) {
1186
1187
  defaults = defaults.map(function (item, idx) {
@@ -1230,11 +1231,11 @@ function getDefaultFormState(validator, theSchema, formData, rootSchema, include
1230
1231
  includeUndefinedValues = false;
1231
1232
  }
1232
1233
  if (!isObject(theSchema)) {
1233
- throw new Error("Invalid schema: " + theSchema);
1234
+ throw new Error('Invalid schema: ' + theSchema);
1234
1235
  }
1235
1236
  var schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1236
1237
  var defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1237
- if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
1238
+ if (typeof formData === 'undefined' || formData === null || typeof formData === 'number' && isNaN(formData)) {
1238
1239
  // No form data? Use schema defaults.
1239
1240
  return defaults;
1240
1241
  }
@@ -1259,7 +1260,7 @@ function isCustomWidget(uiSchema) {
1259
1260
  return (
1260
1261
  // TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1261
1262
  // https://react-jsonschema-form.readthedocs.io/en/latest/usage/widgets/#hidden-widgets
1262
- "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
1263
+ 'widget' in getUiOptions(uiSchema) && getUiOptions(uiSchema)['widget'] !== 'hidden'
1263
1264
  );
1264
1265
  }
1265
1266
 
@@ -1275,12 +1276,12 @@ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1275
1276
  if (uiSchema === void 0) {
1276
1277
  uiSchema = {};
1277
1278
  }
1278
- if (uiSchema[UI_WIDGET_KEY] === "files") {
1279
+ if (uiSchema[UI_WIDGET_KEY] === 'files') {
1279
1280
  return true;
1280
1281
  }
1281
1282
  if (schema.items) {
1282
1283
  var itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1283
- return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1284
+ return itemsSchema.type === 'string' && itemsSchema.format === 'data-url';
1284
1285
  }
1285
1286
  return false;
1286
1287
  }
@@ -1303,13 +1304,13 @@ function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1303
1304
  label = _uiOptions$label === void 0 ? true : _uiOptions$label;
1304
1305
  var displayLabel = !!label;
1305
1306
  var schemaType = getSchemaType(schema);
1306
- if (schemaType === "array") {
1307
+ if (schemaType === 'array') {
1307
1308
  displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1308
1309
  }
1309
- if (schemaType === "object") {
1310
+ if (schemaType === 'object') {
1310
1311
  displayLabel = false;
1311
1312
  }
1312
- if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
1313
+ if (schemaType === 'boolean' && !uiSchema[UI_WIDGET_KEY]) {
1313
1314
  displayLabel = false;
1314
1315
  }
1315
1316
  if (uiSchema[UI_FIELD_KEY]) {
@@ -1346,7 +1347,7 @@ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1346
1347
  };
1347
1348
  }
1348
1349
 
1349
- var NO_VALUE = /*#__PURE__*/Symbol("no Value");
1350
+ var NO_VALUE = /*#__PURE__*/Symbol('no Value');
1350
1351
  /** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the new
1351
1352
  * schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the nature
1352
1353
  * of schemas, this sanitization happens recursively for nested objects of data. Also, any properties in the old schema
@@ -1427,8 +1428,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1427
1428
  newKeyedSchema = retrieveSchema(validator, newKeyedSchema, rootSchema, formValue);
1428
1429
  }
1429
1430
  // Now get types and see if they are the same
1430
- var oldSchemaTypeForKey = get(oldKeyedSchema, "type");
1431
- var newSchemaTypeForKey = get(newKeyedSchema, "type");
1431
+ var oldSchemaTypeForKey = get(oldKeyedSchema, 'type');
1432
+ var newSchemaTypeForKey = get(newKeyedSchema, 'type');
1432
1433
  // Check if the old option has the same key with the same type
1433
1434
  if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
1434
1435
  if (has(removeOldSchemaData, key)) {
@@ -1436,10 +1437,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1436
1437
  delete removeOldSchemaData[key];
1437
1438
  }
1438
1439
  // 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)) {
1440
+ if (newSchemaTypeForKey === 'object' || newSchemaTypeForKey === 'array' && Array.isArray(formValue)) {
1440
1441
  // SIDE-EFFECT: process the new schema type of object recursively to save iterations
1441
1442
  var itemData = sanitizeDataForNewSchema(validator, rootSchema, newKeyedSchema, oldKeyedSchema, formValue);
1442
- if (itemData !== undefined || newSchemaTypeForKey === "array") {
1443
+ if (itemData !== undefined || newSchemaTypeForKey === 'array') {
1443
1444
  // only put undefined values for the array type and not the object type
1444
1445
  nestedData[key] = itemData;
1445
1446
  }
@@ -1447,19 +1448,19 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1447
1448
  // Ok, the non-object types match, let's make sure that a default or a const of a different value is replaced
1448
1449
  // with the new default or const. This allows the case where two schemas differ that only by the default/const
1449
1450
  // value to be properly selected
1450
- var newOptionDefault = get(newKeyedSchema, "default", NO_VALUE);
1451
- var oldOptionDefault = get(oldKeyedSchema, "default", NO_VALUE);
1451
+ var newOptionDefault = get(newKeyedSchema, 'default', NO_VALUE);
1452
+ var oldOptionDefault = get(oldKeyedSchema, 'default', NO_VALUE);
1452
1453
  if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
1453
1454
  if (oldOptionDefault === formValue) {
1454
1455
  // If the old default matches the formValue, we'll update the new value to match the new default
1455
1456
  removeOldSchemaData[key] = newOptionDefault;
1456
- } else if (get(newKeyedSchema, "readOnly") === true) {
1457
+ } else if (get(newKeyedSchema, 'readOnly') === true) {
1457
1458
  // If the new schema has the default set to read-only, treat it like a const and remove the value
1458
1459
  removeOldSchemaData[key] = undefined;
1459
1460
  }
1460
1461
  }
1461
- var newOptionConst = get(newKeyedSchema, "const", NO_VALUE);
1462
- var oldOptionConst = get(oldKeyedSchema, "const", NO_VALUE);
1462
+ var newOptionConst = get(newKeyedSchema, 'const', NO_VALUE);
1463
+ var oldOptionConst = get(oldKeyedSchema, 'const', NO_VALUE);
1463
1464
  if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
1464
1465
  // Since this is a const, if the old value matches, replace the value with the new const otherwise clear it
1465
1466
  removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : undefined;
@@ -1469,12 +1470,12 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1469
1470
  });
1470
1471
  newFormData = _extends({}, data, removeOldSchemaData, nestedData);
1471
1472
  // 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");
1473
+ } else if (get(oldSchema, 'type') === 'array' && get(newSchema, 'type') === 'array' && Array.isArray(data)) {
1474
+ var oldSchemaItems = get(oldSchema, 'items');
1475
+ var newSchemaItems = get(newSchema, 'items');
1475
1476
  // If any of the array types `items` are arrays (remember arrays are objects) then we'll just drop the data
1476
1477
  // 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)) {
1478
+ if (typeof oldSchemaItems === 'object' && typeof newSchemaItems === 'object' && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
1478
1479
  if (has(oldSchemaItems, REF_KEY)) {
1479
1480
  oldSchemaItems = retrieveSchema(validator, oldSchemaItems, rootSchema, data);
1480
1481
  }
@@ -1482,12 +1483,12 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1482
1483
  newSchemaItems = retrieveSchema(validator, newSchemaItems, rootSchema, data);
1483
1484
  }
1484
1485
  // Now get types and see if they are the same
1485
- var oldSchemaType = get(oldSchemaItems, "type");
1486
- var newSchemaType = get(newSchemaItems, "type");
1486
+ var oldSchemaType = get(oldSchemaItems, 'type');
1487
+ var newSchemaType = get(newSchemaItems, 'type');
1487
1488
  // Check if the old option has the same key with the same type
1488
1489
  if (!oldSchemaType || oldSchemaType === newSchemaType) {
1489
- var maxItems = get(newSchema, "maxItems", -1);
1490
- if (newSchemaType === "object") {
1490
+ var maxItems = get(newSchema, 'maxItems', -1);
1491
+ if (newSchemaType === 'object') {
1491
1492
  newFormData = data.reduce(function (newValue, aValue) {
1492
1493
  var itemValue = sanitizeDataForNewSchema(validator, rootSchema, newSchemaItems, oldSchemaItems, aValue);
1493
1494
  if (itemValue !== undefined && (maxItems < 0 || newValue.length < maxItems)) {
@@ -1499,7 +1500,7 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1499
1500
  newFormData = maxItems > 0 && data.length > maxItems ? data.slice(0, maxItems) : data;
1500
1501
  }
1501
1502
  }
1502
- } else if (typeof oldSchemaItems === "boolean" && typeof newSchemaItems === "boolean" && oldSchemaItems === newSchemaItems) {
1503
+ } else if (typeof oldSchemaItems === 'boolean' && typeof newSchemaItems === 'boolean' && oldSchemaItems === newSchemaItems) {
1503
1504
  // If they are both booleans and have the same value just return the data as is otherwise fall-thru to undefined
1504
1505
  newFormData = data;
1505
1506
  }
@@ -1522,10 +1523,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
1522
1523
  */
1523
1524
  function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSeparator) {
1524
1525
  if (idPrefix === void 0) {
1525
- idPrefix = "root";
1526
+ idPrefix = 'root';
1526
1527
  }
1527
1528
  if (idSeparator === void 0) {
1528
- idSeparator = "_";
1529
+ idSeparator = '_';
1529
1530
  }
1530
1531
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1531
1532
  var _schema = retrieveSchema(validator, schema, rootSchema, formData);
@@ -1538,7 +1539,7 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1538
1539
  var idSchema = {
1539
1540
  $id: $id
1540
1541
  };
1541
- if (schema.type === "object" && PROPERTIES_KEY in schema) {
1542
+ if (schema.type === 'object' && PROPERTIES_KEY in schema) {
1542
1543
  for (var name in schema.properties) {
1543
1544
  var field = get(schema, [PROPERTIES_KEY, name]);
1544
1545
  var fieldId = idSchema[ID_KEY] + idSeparator + name;
@@ -1563,13 +1564,13 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSep
1563
1564
  function toPathSchema(validator, schema, name, rootSchema, formData) {
1564
1565
  var _pathSchema;
1565
1566
  if (name === void 0) {
1566
- name = "";
1567
+ name = '';
1567
1568
  }
1568
1569
  if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1569
1570
  var _schema = retrieveSchema(validator, schema, rootSchema, formData);
1570
1571
  return toPathSchema(validator, _schema, name, rootSchema, formData);
1571
1572
  }
1572
- var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ""), _pathSchema);
1573
+ var pathSchema = (_pathSchema = {}, _pathSchema[NAME_KEY] = name.replace(/^\./, ''), _pathSchema);
1573
1574
  if (ONE_OF_KEY in schema) {
1574
1575
  var index = getClosestMatchingOption(validator, rootSchema, formData, schema.oneOf, 0);
1575
1576
  var _schema2 = schema.oneOf[index];
@@ -1772,10 +1773,10 @@ var SchemaUtils = /*#__PURE__*/function () {
1772
1773
  */;
1773
1774
  _proto.toIdSchema = function toIdSchema$1(schema, id, formData, idPrefix, idSeparator) {
1774
1775
  if (idPrefix === void 0) {
1775
- idPrefix = "root";
1776
+ idPrefix = 'root';
1776
1777
  }
1777
1778
  if (idSeparator === void 0) {
1778
- idSeparator = "_";
1779
+ idSeparator = '_';
1779
1780
  }
1780
1781
  return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
1781
1782
  }
@@ -1810,38 +1811,85 @@ function createSchemaUtils(validator, rootSchema) {
1810
1811
  */
1811
1812
  function dataURItoBlob(dataURI) {
1812
1813
  // Split metadata from data
1813
- var splitted = dataURI.split(",");
1814
+ var splitted = dataURI.split(',');
1814
1815
  // Split params
1815
- var params = splitted[0].split(";");
1816
+ var params = splitted[0].split(';');
1816
1817
  // Get mime-type from params
1817
- var type = params[0].replace("data:", "");
1818
+ var type = params[0].replace('data:', '');
1818
1819
  // Filter the name property from params
1819
1820
  var properties = params.filter(function (param) {
1820
- return param.split("=")[0] === "name";
1821
+ return param.split('=')[0] === 'name';
1821
1822
  });
1822
1823
  // Look for the name and use unknown if no name property.
1823
1824
  var name;
1824
1825
  if (properties.length !== 1) {
1825
- name = "unknown";
1826
+ name = 'unknown';
1826
1827
  } else {
1827
1828
  // Because we filtered out the other property,
1828
- // we only have the name case here.
1829
- name = properties[0].split("=")[1];
1829
+ // we only have the name case here, which we decode to make it human-readable
1830
+ name = decodeURI(properties[0].split('=')[1]);
1830
1831
  }
1831
1832
  // 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
- };
1833
+ try {
1834
+ var binary = atob(splitted[1]);
1835
+ var array = [];
1836
+ for (var i = 0; i < binary.length; i++) {
1837
+ array.push(binary.charCodeAt(i));
1838
+ }
1839
+ // Create the blob object
1840
+ var blob = new window.Blob([new Uint8Array(array)], {
1841
+ type: type
1842
+ });
1843
+ return {
1844
+ blob: blob,
1845
+ name: name
1846
+ };
1847
+ } catch (error) {
1848
+ return {
1849
+ blob: {
1850
+ size: 0,
1851
+ type: error.message
1852
+ },
1853
+ name: dataURI
1854
+ };
1855
+ }
1856
+ }
1857
+
1858
+ /** Potentially substitutes all replaceable parameters with the associated value(s) from the `params` if available. When
1859
+ * a `params` array is provided, each value in the array is used to replace any of the replaceable parameters in the
1860
+ * `inputString` using the `%1`, `%2`, etc. replacement specifiers.
1861
+ *
1862
+ * @param inputString - The string which will be potentially updated with replacement parameters
1863
+ * @param params - The optional list of replaceable parameter values to substitute into the english string
1864
+ * @returns - The updated string with any replacement specifiers replaced
1865
+ */
1866
+ function replaceStringParameters(inputString, params) {
1867
+ var output = inputString;
1868
+ if (Array.isArray(params)) {
1869
+ var parts = output.split(/(%\d)/);
1870
+ params.forEach(function (param, index) {
1871
+ var partIndex = parts.findIndex(function (part) {
1872
+ return part === "%" + (index + 1);
1873
+ });
1874
+ if (partIndex >= 0) {
1875
+ parts[partIndex] = param;
1876
+ }
1877
+ });
1878
+ output = parts.join('');
1879
+ }
1880
+ return output;
1881
+ }
1882
+
1883
+ /** Translates a `TranslatableString` value `stringToTranslate` into english. When a `params` array is provided, each
1884
+ * value in the array is used to replace any of the replaceable parameters in the `stringToTranslate` using the `%1`,
1885
+ * `%2`, etc. replacement specifiers.
1886
+ *
1887
+ * @param stringToTranslate - The `TranslatableString` value to convert to english
1888
+ * @param params - The optional list of replaceable parameter values to substitute into the english string
1889
+ * @returns - The `stringToTranslate` itself with any replaceable parameter values substituted
1890
+ */
1891
+ function englishStringTranslator(stringToTranslate, params) {
1892
+ return replaceStringParameters(stringToTranslate, params);
1845
1893
  }
1846
1894
 
1847
1895
  /** Returns the value(s) from `allEnumOptions` at the index(es) provided by `valueIndex`. If `valueIndex` is not an
@@ -1867,7 +1915,7 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions, emptyValue) {
1867
1915
  });
1868
1916
  }
1869
1917
  // So Number(null) and Number('') both return 0, so use emptyValue for those two values
1870
- var index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
1918
+ var index = valueIndex === '' || valueIndex === null ? -1 : Number(valueIndex);
1871
1919
  var option = allEnumOptions[index];
1872
1920
  return option ? option.value : emptyValue;
1873
1921
  }
@@ -1933,7 +1981,7 @@ function enumOptionsIndexForValue(value, allEnumOptions, multiple) {
1933
1981
  var selectedIndexes = allEnumOptions.map(function (opt, index) {
1934
1982
  return enumOptionsIsSelected(opt.value, value) ? String(index) : undefined;
1935
1983
  }).filter(function (opt) {
1936
- return typeof opt !== "undefined";
1984
+ return typeof opt !== 'undefined';
1937
1985
  });
1938
1986
  if (!multiple) {
1939
1987
  return selectedIndexes[0];
@@ -2001,7 +2049,7 @@ var ErrorSchemaBuilder = /*#__PURE__*/function () {
2001
2049
  * @private
2002
2050
  */
2003
2051
  _proto.getOrCreateErrorBlock = function getOrCreateErrorBlock(pathOfError) {
2004
- var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
2052
+ var hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === 'string';
2005
2053
  var errorBlock = hasPath ? get(this.errorSchema, pathOfError) : this.errorSchema;
2006
2054
  if (!errorBlock && pathOfError) {
2007
2055
  errorBlock = {};
@@ -2113,23 +2161,23 @@ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
2113
2161
  autoDefaultStepAny = true;
2114
2162
  }
2115
2163
  var inputProps = _extends({
2116
- type: defaultType || "text"
2164
+ type: defaultType || 'text'
2117
2165
  }, rangeSpec(schema));
2118
2166
  // If options.inputType is set use that as the input type
2119
2167
  if (options.inputType) {
2120
2168
  inputProps.type = options.inputType;
2121
2169
  } else if (!defaultType) {
2122
2170
  // If the schema is of type number or integer, set the input type to number
2123
- if (schema.type === "number") {
2124
- inputProps.type = "number";
2171
+ if (schema.type === 'number') {
2172
+ inputProps.type = 'number';
2125
2173
  // Only add step if one isn't already defined and we are auto-defaulting the "any" step
2126
2174
  if (autoDefaultStepAny && inputProps.step === undefined) {
2127
2175
  // Setting step to 'any' fixes a bug in Safari where decimals are not
2128
2176
  // allowed in number inputs
2129
- inputProps.step = "any";
2177
+ inputProps.step = 'any';
2130
2178
  }
2131
- } else if (schema.type === "integer") {
2132
- inputProps.type = "number";
2179
+ } else if (schema.type === 'integer') {
2180
+ inputProps.type = 'number';
2133
2181
  // Only add step if one isn't already defined
2134
2182
  if (inputProps.step === undefined) {
2135
2183
  // Since this is integer, you always want to step up or down in multiples of 1
@@ -2149,7 +2197,7 @@ var DEFAULT_OPTIONS = {
2149
2197
  props: {
2150
2198
  disabled: false
2151
2199
  },
2152
- submitText: "Submit",
2200
+ submitText: 'Submit',
2153
2201
  norender: false
2154
2202
  };
2155
2203
  /** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
@@ -2182,7 +2230,7 @@ function getTemplate(name, registry, uiOptions) {
2182
2230
  uiOptions = {};
2183
2231
  }
2184
2232
  var templates = registry.templates;
2185
- if (name === "ButtonTemplates") {
2233
+ if (name === 'ButtonTemplates') {
2186
2234
  return templates[name];
2187
2235
  }
2188
2236
  return (
@@ -2197,53 +2245,53 @@ var _excluded = ["options"];
2197
2245
  */
2198
2246
  var widgetMap = {
2199
2247
  "boolean": {
2200
- checkbox: "CheckboxWidget",
2201
- radio: "RadioWidget",
2202
- select: "SelectWidget",
2203
- hidden: "HiddenWidget"
2248
+ checkbox: 'CheckboxWidget',
2249
+ radio: 'RadioWidget',
2250
+ select: 'SelectWidget',
2251
+ hidden: 'HiddenWidget'
2204
2252
  },
2205
2253
  string: {
2206
- text: "TextWidget",
2207
- password: "PasswordWidget",
2208
- email: "EmailWidget",
2209
- hostname: "TextWidget",
2210
- ipv4: "TextWidget",
2211
- ipv6: "TextWidget",
2212
- uri: "URLWidget",
2213
- "data-url": "FileWidget",
2214
- radio: "RadioWidget",
2215
- select: "SelectWidget",
2216
- textarea: "TextareaWidget",
2217
- hidden: "HiddenWidget",
2218
- date: "DateWidget",
2219
- datetime: "DateTimeWidget",
2220
- "date-time": "DateTimeWidget",
2221
- "alt-date": "AltDateWidget",
2222
- "alt-datetime": "AltDateTimeWidget",
2223
- color: "ColorWidget",
2224
- file: "FileWidget"
2254
+ text: 'TextWidget',
2255
+ password: 'PasswordWidget',
2256
+ email: 'EmailWidget',
2257
+ hostname: 'TextWidget',
2258
+ ipv4: 'TextWidget',
2259
+ ipv6: 'TextWidget',
2260
+ uri: 'URLWidget',
2261
+ 'data-url': 'FileWidget',
2262
+ radio: 'RadioWidget',
2263
+ select: 'SelectWidget',
2264
+ textarea: 'TextareaWidget',
2265
+ hidden: 'HiddenWidget',
2266
+ date: 'DateWidget',
2267
+ datetime: 'DateTimeWidget',
2268
+ 'date-time': 'DateTimeWidget',
2269
+ 'alt-date': 'AltDateWidget',
2270
+ 'alt-datetime': 'AltDateTimeWidget',
2271
+ color: 'ColorWidget',
2272
+ file: 'FileWidget'
2225
2273
  },
2226
2274
  number: {
2227
- text: "TextWidget",
2228
- select: "SelectWidget",
2229
- updown: "UpDownWidget",
2230
- range: "RangeWidget",
2231
- radio: "RadioWidget",
2232
- hidden: "HiddenWidget"
2275
+ text: 'TextWidget',
2276
+ select: 'SelectWidget',
2277
+ updown: 'UpDownWidget',
2278
+ range: 'RangeWidget',
2279
+ radio: 'RadioWidget',
2280
+ hidden: 'HiddenWidget'
2233
2281
  },
2234
2282
  integer: {
2235
- text: "TextWidget",
2236
- select: "SelectWidget",
2237
- updown: "UpDownWidget",
2238
- range: "RangeWidget",
2239
- radio: "RadioWidget",
2240
- hidden: "HiddenWidget"
2283
+ text: 'TextWidget',
2284
+ select: 'SelectWidget',
2285
+ updown: 'UpDownWidget',
2286
+ range: 'RangeWidget',
2287
+ radio: 'RadioWidget',
2288
+ hidden: 'HiddenWidget'
2241
2289
  },
2242
2290
  array: {
2243
- select: "SelectWidget",
2244
- checkboxes: "CheckboxesWidget",
2245
- files: "FileWidget",
2246
- hidden: "HiddenWidget"
2291
+ select: 'SelectWidget',
2292
+ checkboxes: 'CheckboxesWidget',
2293
+ files: 'FileWidget',
2294
+ hidden: 'HiddenWidget'
2247
2295
  }
2248
2296
  };
2249
2297
  /** Wraps the given widget with stateless functional component that will merge any `defaultProps.options` with the
@@ -2254,18 +2302,18 @@ var widgetMap = {
2254
2302
  * @returns - The wrapper widget
2255
2303
  */
2256
2304
  function mergeWidgetOptions(AWidget) {
2257
- var MergedWidget = get(AWidget, "MergedWidget");
2305
+ var MergedWidget = get(AWidget, 'MergedWidget');
2258
2306
  // cache return value as property of widget for proper react reconciliation
2259
2307
  if (!MergedWidget) {
2260
2308
  var defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
2261
2309
  MergedWidget = function MergedWidget(_ref) {
2262
2310
  var options = _ref.options,
2263
2311
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
2264
- return /*#__PURE__*/React.createElement(AWidget, _extends({
2312
+ return jsx(AWidget, _extends({
2265
2313
  options: _extends({}, defaultOptions, options)
2266
2314
  }, props));
2267
2315
  };
2268
- set(AWidget, "MergedWidget", MergedWidget);
2316
+ set(AWidget, 'MergedWidget', MergedWidget);
2269
2317
  }
2270
2318
  return MergedWidget;
2271
2319
  }
@@ -2285,17 +2333,17 @@ function getWidget(schema, widget, registeredWidgets) {
2285
2333
  registeredWidgets = {};
2286
2334
  }
2287
2335
  var type = getSchemaType(schema);
2288
- if (typeof widget === "function" || widget && ReactIs.isForwardRef( /*#__PURE__*/React.createElement(widget)) || ReactIs.isMemo(widget)) {
2336
+ if (typeof widget === 'function' || widget && ReactIs.isForwardRef( /*#__PURE__*/createElement(widget)) || ReactIs.isMemo(widget)) {
2289
2337
  return mergeWidgetOptions(widget);
2290
2338
  }
2291
- if (typeof widget !== "string") {
2339
+ if (typeof widget !== 'string') {
2292
2340
  throw new Error("Unsupported widget definition: " + typeof widget);
2293
2341
  }
2294
2342
  if (widget in registeredWidgets) {
2295
2343
  var registeredWidget = registeredWidgets[widget];
2296
2344
  return getWidget(schema, registeredWidget, registeredWidgets);
2297
2345
  }
2298
- if (typeof type === "string") {
2346
+ if (typeof type === 'string') {
2299
2347
  if (!(type in widgetMap)) {
2300
2348
  throw new Error("No widget for type '" + type + "'");
2301
2349
  }
@@ -2324,7 +2372,7 @@ function hasWidget(schema, widget, registeredWidgets) {
2324
2372
  return true;
2325
2373
  } catch (e) {
2326
2374
  var err = e;
2327
- if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
2375
+ if (err.message && (err.message.startsWith('No widget') || err.message.startsWith('Unsupported widget'))) {
2328
2376
  return false;
2329
2377
  }
2330
2378
  throw e;
@@ -2346,7 +2394,7 @@ function idGenerator(id, suffix) {
2346
2394
  * @returns - The consistent id for the field description element from the given `id`
2347
2395
  */
2348
2396
  function descriptionId(id) {
2349
- return idGenerator(id, "description");
2397
+ return idGenerator(id, 'description');
2350
2398
  }
2351
2399
  /** Return a consistent `id` for the field error element
2352
2400
  *
@@ -2354,7 +2402,7 @@ function descriptionId(id) {
2354
2402
  * @returns - The consistent id for the field error element from the given `id`
2355
2403
  */
2356
2404
  function errorId(id) {
2357
- return idGenerator(id, "error");
2405
+ return idGenerator(id, 'error');
2358
2406
  }
2359
2407
  /** Return a consistent `id` for the field examples element
2360
2408
  *
@@ -2362,7 +2410,7 @@ function errorId(id) {
2362
2410
  * @returns - The consistent id for the field examples element from the given `id`
2363
2411
  */
2364
2412
  function examplesId(id) {
2365
- return idGenerator(id, "examples");
2413
+ return idGenerator(id, 'examples');
2366
2414
  }
2367
2415
  /** Return a consistent `id` for the field help element
2368
2416
  *
@@ -2370,7 +2418,7 @@ function examplesId(id) {
2370
2418
  * @returns - The consistent id for the field help element from the given `id`
2371
2419
  */
2372
2420
  function helpId(id) {
2373
- return idGenerator(id, "help");
2421
+ return idGenerator(id, 'help');
2374
2422
  }
2375
2423
  /** Return a consistent `id` for the field title element
2376
2424
  *
@@ -2378,7 +2426,7 @@ function helpId(id) {
2378
2426
  * @returns - The consistent id for the field title element from the given `id`
2379
2427
  */
2380
2428
  function titleId(id) {
2381
- return idGenerator(id, "title");
2429
+ return idGenerator(id, 'title');
2382
2430
  }
2383
2431
  /** Return a list of element ids that contain additional information about the field that can be used to as the aria
2384
2432
  * description of the field. This is correctly omitting `titleId` which would be "labeling" rather than "describing" the
@@ -2392,7 +2440,7 @@ function ariaDescribedByIds(id, includeExamples) {
2392
2440
  if (includeExamples === void 0) {
2393
2441
  includeExamples = false;
2394
2442
  }
2395
- var examples = includeExamples ? " " + examplesId(id) : "";
2443
+ var examples = includeExamples ? " " + examplesId(id) : '';
2396
2444
  return errorId(id) + " " + descriptionId(id) + " " + helpId(id) + examples;
2397
2445
  }
2398
2446
  /** Return a consistent `id` for the `optionIndex`s of a `Radio` or `Checkboxes` widget
@@ -2428,7 +2476,7 @@ function toConstant(schema) {
2428
2476
  if (CONST_KEY in schema) {
2429
2477
  return schema["const"];
2430
2478
  }
2431
- throw new Error("schema cannot be inferred as a constant");
2479
+ throw new Error('schema cannot be inferred as a constant');
2432
2480
  }
2433
2481
 
2434
2482
  /** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
@@ -2443,8 +2491,8 @@ function optionsList(schema) {
2443
2491
  // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
2444
2492
  // Cast the type to include enumNames so the feature still works.
2445
2493
  var schemaWithEnumNames = schema;
2446
- if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== "production") {
2447
- console.warn("The enumNames property is deprecated and may be removed in a future major release.");
2494
+ if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== 'production') {
2495
+ console.warn('The enumNames property is deprecated and may be removed in a future major release.');
2448
2496
  }
2449
2497
  if (schema["enum"]) {
2450
2498
  return schema["enum"].map(function (value, i) {
@@ -2493,21 +2541,21 @@ function orderProperties(properties, order) {
2493
2541
  };
2494
2542
  var propertyHash = arrayToHash(properties);
2495
2543
  var orderFiltered = order.filter(function (prop) {
2496
- return prop === "*" || propertyHash[prop];
2544
+ return prop === '*' || propertyHash[prop];
2497
2545
  });
2498
2546
  var orderHash = arrayToHash(orderFiltered);
2499
2547
  var rest = properties.filter(function (prop) {
2500
2548
  return !orderHash[prop];
2501
2549
  });
2502
- var restIndex = orderFiltered.indexOf("*");
2550
+ var restIndex = orderFiltered.indexOf('*');
2503
2551
  if (restIndex === -1) {
2504
2552
  if (rest.length) {
2505
2553
  throw new Error("uiSchema order list does not contain " + errorPropList(rest));
2506
2554
  }
2507
2555
  return orderFiltered;
2508
2556
  }
2509
- if (restIndex !== orderFiltered.lastIndexOf("*")) {
2510
- throw new Error("uiSchema order list contains more than one wildcard item");
2557
+ if (restIndex !== orderFiltered.lastIndexOf('*')) {
2558
+ throw new Error('uiSchema order list contains more than one wildcard item');
2511
2559
  }
2512
2560
  var complete = [].concat(orderFiltered);
2513
2561
  complete.splice.apply(complete, [restIndex, 1].concat(rest));
@@ -2523,7 +2571,7 @@ function orderProperties(properties, order) {
2523
2571
  function pad(num, width) {
2524
2572
  var s = String(num);
2525
2573
  while (s.length < width) {
2526
- s = "0" + s;
2574
+ s = '0' + s;
2527
2575
  }
2528
2576
  return s;
2529
2577
  }
@@ -2551,7 +2599,7 @@ function parseDateString(dateString, includeTime) {
2551
2599
  }
2552
2600
  var date = new Date(dateString);
2553
2601
  if (Number.isNaN(date.getTime())) {
2554
- throw new Error("Unable to parse date " + dateString);
2602
+ throw new Error('Unable to parse date ' + dateString);
2555
2603
  }
2556
2604
  return {
2557
2605
  year: date.getUTCFullYear(),
@@ -2645,7 +2693,7 @@ function toDateString(dateObject, time) {
2645
2693
  */
2646
2694
  function utcToLocal(jsonDate) {
2647
2695
  if (!jsonDate) {
2648
- return "";
2696
+ return '';
2649
2697
  }
2650
2698
  // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'
2651
2699
  // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)
@@ -2663,5 +2711,75 @@ function utcToLocal(jsonDate) {
2663
2711
  return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
2664
2712
  }
2665
2713
 
2666
- export { ADDITIONAL_PROPERTIES_KEY, ADDITIONAL_PROPERTY_FLAG, ALL_OF_KEY, ANY_OF_KEY, CONST_KEY, DEFAULT_KEY, DEFINITIONS_KEY, DEPENDENCIES_KEY, ENUM_KEY, ERRORS_KEY, ErrorSchemaBuilder, ID_KEY, ITEMS_KEY, NAME_KEY, ONE_OF_KEY, PROPERTIES_KEY, REF_KEY, REQUIRED_KEY, RJSF_ADDITONAL_PROPERTIES_FLAG, SUBMIT_BTN_OPTIONS_KEY, UI_FIELD_KEY, UI_OPTIONS_KEY, UI_WIDGET_KEY, allowAdditionalItems, ariaDescribedByIds, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, descriptionId, 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, retrieveSchema, sanitizeDataForNewSchema, schemaRequiresTrueValue, shouldRender, titleId, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2714
+ /** An enumeration of all the translatable strings used by `@rjsf/core` and its themes. The value of each of the
2715
+ * enumeration keys is expected to be the actual english string. Some strings contain replaceable parameter values
2716
+ * as indicated by `%1`, `%2`, etc. The number after the `%` indicates the order of the parameter. The ordering of
2717
+ * parameters is important because some languages may choose to put the second parameter before the first in its
2718
+ * translation. Also, some strings are rendered using `markdown-to-jsx` and thus support markdown and inline html.
2719
+ */
2720
+ var TranslatableString;
2721
+ (function (TranslatableString) {
2722
+ /** Fallback title of an array item, used by ArrayField */
2723
+ TranslatableString["ArrayItemTitle"] = "Item";
2724
+ /** Missing items reason, used by ArrayField */
2725
+ TranslatableString["MissingItems"] = "Missing items definition";
2726
+ /** Yes label, used by BooleanField */
2727
+ TranslatableString["YesLabel"] = "Yes";
2728
+ /** No label, used by BooleanField */
2729
+ TranslatableString["NoLabel"] = "No";
2730
+ /** Close label, used by ErrorList */
2731
+ TranslatableString["CloseLabel"] = "Close";
2732
+ /** Errors label, used by ErrorList */
2733
+ TranslatableString["ErrorsLabel"] = "Errors";
2734
+ /** New additionalProperties string default value, used by ObjectField */
2735
+ TranslatableString["NewStringDefault"] = "New Value";
2736
+ /** Add button title, used by AddButton */
2737
+ TranslatableString["AddButton"] = "Add";
2738
+ /** Add button title, used by AddButton */
2739
+ TranslatableString["AddItemButton"] = "Add Item";
2740
+ /** Move down button title, used by IconButton */
2741
+ TranslatableString["MoveDownButton"] = "Move down";
2742
+ /** Move up button title, used by IconButton */
2743
+ TranslatableString["MoveUpButton"] = "Move up";
2744
+ /** Remove button title, used by IconButton */
2745
+ TranslatableString["RemoveButton"] = "Remove";
2746
+ /** Now label, used by AltDateWidget */
2747
+ TranslatableString["NowLabel"] = "Now";
2748
+ /** Clear label, used by AltDateWidget */
2749
+ TranslatableString["ClearLabel"] = "Clear";
2750
+ /** Aria date label, used by DateWidget */
2751
+ TranslatableString["AriaDateLabel"] = "Select a date";
2752
+ /** Decrement button aria label, used by UpDownWidget */
2753
+ TranslatableString["DecrementAriaLabel"] = "Decrease value by 1";
2754
+ /** Increment button aria label, used by UpDownWidget */
2755
+ TranslatableString["IncrementAriaLabel"] = "Increase value by 1";
2756
+ // Strings with replaceable parameters
2757
+ /** Unknown field type reason, where %1 will be replaced with the type as provided by SchemaField */
2758
+ TranslatableString["UnknownFieldType"] = "Unknown field type %1";
2759
+ /** Option prefix, where %1 will be replaced with the option index as provided by MultiSchemaField */
2760
+ TranslatableString["OptionPrefix"] = "Option %1";
2761
+ /** Option prefix, where %1 and %2 will be replaced by the schema title and option index, respectively as provided by
2762
+ * MultiSchemaField
2763
+ */
2764
+ TranslatableString["TitleOptionPrefix"] = "%1 option %2";
2765
+ /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
2766
+ TranslatableString["KeyLabel"] = "%1 Key";
2767
+ // Strings with replaceable parameters AND/OR that support markdown and html
2768
+ /** Unsupported field schema, used by UnsupportedField */
2769
+ TranslatableString["UnsupportedField"] = "Unsupported field schema.";
2770
+ /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
2771
+ TranslatableString["UnsupportedFieldWithId"] = "Unsupported field schema for field <code>%1</code>.";
2772
+ /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
2773
+ TranslatableString["UnsupportedFieldWithReason"] = "Unsupported field schema: <em>%1</em>.";
2774
+ /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
2775
+ * as provided by UnsupportedField
2776
+ */
2777
+ TranslatableString["UnsupportedFieldWithIdAndReason"] = "Unsupported field schema for field <code>%1</code>: <em>%2</em>.";
2778
+ /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
2779
+ * provided by FileWidget
2780
+ */
2781
+ TranslatableString["FilesInfo"] = "<strong>%1</strong> (%2, %3 bytes)";
2782
+ })(TranslatableString || (TranslatableString = {}));
2783
+
2784
+ 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 };
2667
2785
  //# sourceMappingURL=utils.esm.js.map