@rjsf/utils 5.0.0-beta.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.
Files changed (62) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +106 -0
  3. package/dist/allowAdditionalItems.d.ts +8 -0
  4. package/dist/asNumber.d.ts +10 -0
  5. package/dist/canExpand.d.ts +11 -0
  6. package/dist/constants.d.ts +27 -0
  7. package/dist/createSchemaUtils.d.ts +9 -0
  8. package/dist/dataURItoBlob.d.ts +10 -0
  9. package/dist/deepEquals.d.ts +8 -0
  10. package/dist/findSchemaDefinition.d.ts +20 -0
  11. package/dist/getInputProps.d.ts +10 -0
  12. package/dist/getSchemaType.d.ts +13 -0
  13. package/dist/getSubmitButtonOptions.d.ts +10 -0
  14. package/dist/getTemplate.d.ts +10 -0
  15. package/dist/getUiOptions.d.ts +8 -0
  16. package/dist/getWidget.d.ts +13 -0
  17. package/dist/guessType.d.ts +7 -0
  18. package/dist/hasWidget.d.ts +10 -0
  19. package/dist/index.d.ts +38 -0
  20. package/dist/index.js +8 -0
  21. package/dist/isConstant.d.ts +8 -0
  22. package/dist/isCustomWidget.d.ts +7 -0
  23. package/dist/isFixedItems.d.ts +8 -0
  24. package/dist/isObject.d.ts +7 -0
  25. package/dist/localToUTC.d.ts +6 -0
  26. package/dist/mergeDefaultsWithFormData.d.ts +15 -0
  27. package/dist/mergeObjects.d.ts +9 -0
  28. package/dist/mergeSchemas.d.ts +10 -0
  29. package/dist/optionsList.d.ts +10 -0
  30. package/dist/orderProperties.d.ts +11 -0
  31. package/dist/pad.d.ts +7 -0
  32. package/dist/parseDateString.d.ts +9 -0
  33. package/dist/processSelectValue.d.ts +11 -0
  34. package/dist/rangeSpec.d.ts +9 -0
  35. package/dist/schema/getDefaultFormState.d.ts +47 -0
  36. package/dist/schema/getDisplayLabel.d.ts +11 -0
  37. package/dist/schema/getMatchingOption.d.ts +10 -0
  38. package/dist/schema/index.d.ts +11 -0
  39. package/dist/schema/isFilesArray.d.ts +10 -0
  40. package/dist/schema/isMultiSelect.d.ts +9 -0
  41. package/dist/schema/isSelect.d.ts +9 -0
  42. package/dist/schema/mergeValidationData.d.ts +12 -0
  43. package/dist/schema/retrieveSchema.d.ts +98 -0
  44. package/dist/schema/toIdSchema.d.ts +13 -0
  45. package/dist/schema/toPathSchema.d.ts +11 -0
  46. package/dist/schemaRequiresTrueValue.d.ts +11 -0
  47. package/dist/shouldRender.d.ts +10 -0
  48. package/dist/toConstant.d.ts +9 -0
  49. package/dist/toDateString.d.ts +9 -0
  50. package/dist/types.d.ts +755 -0
  51. package/dist/utcToLocal.d.ts +6 -0
  52. package/dist/utils.cjs.development.js +2274 -0
  53. package/dist/utils.cjs.development.js.map +1 -0
  54. package/dist/utils.cjs.production.min.js +2 -0
  55. package/dist/utils.cjs.production.min.js.map +1 -0
  56. package/dist/utils.esm.js +2192 -0
  57. package/dist/utils.esm.js.map +1 -0
  58. package/dist/utils.umd.development.js +2269 -0
  59. package/dist/utils.umd.development.js.map +1 -0
  60. package/dist/utils.umd.production.min.js +2 -0
  61. package/dist/utils.umd.production.min.js.map +1 -0
  62. package/package.json +79 -0
@@ -0,0 +1,2192 @@
1
+ import isEqualWith from 'lodash-es/isEqualWith';
2
+ import get from 'lodash-es/get';
3
+ import jsonpointer from 'jsonpointer';
4
+ import omit from 'lodash-es/omit';
5
+ import set from 'lodash-es/set';
6
+ import mergeAllOf from 'json-schema-merge-allof';
7
+ import union from 'lodash-es/union';
8
+ import isEmpty from 'lodash-es/isEmpty';
9
+ import React from 'react';
10
+ import ReactIs from 'react-is';
11
+
12
+ /** Determines whether a `thing` is an object for the purposes of RSJF. In this case, `thing` is an object if it has
13
+ * the type `object` but is NOT null, an array or a File.
14
+ *
15
+ * @param thing - The thing to check to see whether it is an object
16
+ * @returns - True if it is a non-null, non-array, non-File object
17
+ */
18
+ function isObject(thing) {
19
+ if (typeof File !== "undefined" && thing instanceof File) {
20
+ return false;
21
+ }
22
+
23
+ return typeof thing === "object" && thing !== null && !Array.isArray(thing);
24
+ }
25
+
26
+ /** Checks the schema to see if it is allowing additional items, by verifying that `schema.additionalItems` is an
27
+ * object. The user is warned in the console if `schema.additionalItems` has the value `true`.
28
+ *
29
+ * @param schema - The schema object to check
30
+ * @returns - True if additional items is allowed, otherwise false
31
+ */
32
+
33
+ function allowAdditionalItems(schema) {
34
+ if (schema.additionalItems === true) {
35
+ console.warn("additionalItems=true is currently not supported");
36
+ }
37
+
38
+ return isObject(schema.additionalItems);
39
+ }
40
+
41
+ /** Attempts to convert the string into a number. If an empty string is provided, then `undefined` is returned. If a
42
+ * `null` is provided, it is returned. If the string ends in a `.` then the string is returned because the user may be
43
+ * in the middle of typing a float number. If a number ends in a pattern like `.0`, `.20`, `.030`, string is returned
44
+ * because the user may be typing number that will end in a non-zero digit. Otherwise, the string is wrapped by
45
+ * `Number()` and if that result is not `NaN`, that number will be returned, otherwise the string `value` will be.
46
+ *
47
+ * @param value - The string or null value to convert to a number
48
+ * @returns - The `value` converted to a number when appropriate, otherwise the `value`
49
+ */
50
+ function asNumber(value) {
51
+ if (value === "") {
52
+ return undefined;
53
+ }
54
+
55
+ if (value === null) {
56
+ return null;
57
+ }
58
+
59
+ if (/\.$/.test(value)) {
60
+ // '3.' can't really be considered a number even if it parses in js. The
61
+ // user is most likely entering a float.
62
+ return value;
63
+ }
64
+
65
+ if (/\.0$/.test(value)) {
66
+ // we need to return this as a string here, to allow for input like 3.07
67
+ return value;
68
+ }
69
+
70
+ if (/\.\d*0$/.test(value)) {
71
+ // It's a number, that's cool - but we need it as a string so it doesn't screw
72
+ // with the user when entering dollar amounts or other values (such as those with
73
+ // specific precision or number of significant digits)
74
+ return value;
75
+ }
76
+
77
+ const n = Number(value);
78
+ const valid = typeof n === "number" && !Number.isNaN(n);
79
+ return valid ? n : value;
80
+ }
81
+
82
+ /** Below are the list of all the keys into various elements of a RJSFSchema or UiSchema that are used by the various
83
+ * utility functions. In addition to those keys, there are the special `ADDITIONAL_PROPERTY_FLAG` and
84
+ * `RJSF_ADDITONAL_PROPERTIES_FLAG` flags that is added to a schema under certain conditions by the `retrieveSchema()`
85
+ * utility.
86
+ */
87
+ const ADDITIONAL_PROPERTY_FLAG = "__additional_property";
88
+ const ADDITIONAL_PROPERTIES_KEY = "additionalProperties";
89
+ const ALL_OF_KEY = "allOf";
90
+ const ANY_OF_KEY = "anyOf";
91
+ const CONST_KEY = "const";
92
+ const DEFAULT_KEY = "default";
93
+ const DEFINITIONS_KEY = "definitions";
94
+ const DEPENDENCIES_KEY = "dependencies";
95
+ const ENUM_KEY = "enum";
96
+ const ERRORS_KEY = "__errors";
97
+ const ID_KEY = "$id";
98
+ const ITEMS_KEY = "items";
99
+ const NAME_KEY = "$name";
100
+ const ONE_OF_KEY = "oneOf";
101
+ const PROPERTIES_KEY = "properties";
102
+ const REQUIRED_KEY = "required";
103
+ const SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
104
+ const REF_KEY = "$ref";
105
+ const RJSF_ADDITONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
106
+ const UI_FIELD_KEY = "ui:field";
107
+ const UI_WIDGET_KEY = "ui:widget";
108
+ const UI_OPTIONS_KEY = "ui:options";
109
+
110
+ /** Get all passed options from ui:options, and ui:<optionName>, returning them in an object with the `ui:`
111
+ * stripped off.
112
+ *
113
+ * @param [uiSchema={}] - The UI Schema from which to get any `ui:xxx` options
114
+ * @returns - An object containing all of the `ui:xxx` options with the stripped off
115
+ */
116
+
117
+ function getUiOptions(uiSchema) {
118
+ if (uiSchema === void 0) {
119
+ uiSchema = {};
120
+ }
121
+
122
+ return Object.keys(uiSchema).filter(key => key.indexOf("ui:") === 0).reduce((options, key) => {
123
+ const value = uiSchema[key];
124
+
125
+ if (key === UI_WIDGET_KEY && isObject(value)) {
126
+ console.error("Setting options via ui:widget object is no longer supported, use ui:options instead");
127
+ return options;
128
+ }
129
+
130
+ if (key === UI_OPTIONS_KEY && isObject(value)) {
131
+ return { ...options,
132
+ ...value
133
+ };
134
+ }
135
+
136
+ return { ...options,
137
+ [key.substring(3)]: value
138
+ };
139
+ }, {});
140
+ }
141
+
142
+ /** Checks whether the field described by `schema`, having the `uiSchema` and `formData` supports expanding. The UI for
143
+ * the field can expand if it has additional properties, is not forced as non-expandable by the `uiSchema` and the
144
+ * `formData` object doesn't already have `schema.maxProperties` elements.
145
+ *
146
+ * @param schema - The schema for the field that is being checked
147
+ * @param [uiSchema={}] - The uiSchema for the field
148
+ * @param [formData] - The formData for the field
149
+ * @returns - True if the schema element has additionalProperties, is expandable, and not at the maxProperties limit
150
+ */
151
+
152
+ function canExpand(schema, uiSchema, formData) {
153
+ if (uiSchema === void 0) {
154
+ uiSchema = {};
155
+ }
156
+
157
+ if (!schema.additionalProperties) {
158
+ return false;
159
+ }
160
+
161
+ const {
162
+ expandable = true
163
+ } = getUiOptions(uiSchema);
164
+
165
+ if (expandable === false) {
166
+ return expandable;
167
+ } // if ui:options.expandable was not explicitly set to false, we can add
168
+ // another property if we have not exceeded maxProperties yet
169
+
170
+
171
+ if (schema.maxProperties !== undefined && formData) {
172
+ return Object.keys(formData).length < schema.maxProperties;
173
+ }
174
+
175
+ return true;
176
+ }
177
+
178
+ /** Implements a deep equals using the `lodash.isEqualWith` function, that provides a customized comparator that
179
+ * assumes all functions are equivalent.
180
+ *
181
+ * @param a - The first element to compare
182
+ * @param b - The second element to compare
183
+ * @returns - True if the `a` and `b` are deeply equal, false otherwise
184
+ */
185
+
186
+ function deepEquals(a, b) {
187
+ return isEqualWith(a, b, (obj, other) => {
188
+ if (typeof obj === "function" && typeof other === "function") {
189
+ // Assume all functions are equivalent
190
+ // see https://github.com/rjsf-team/react-jsonschema-form/issues/255
191
+ return true;
192
+ }
193
+
194
+ return undefined; // fallback to default isEquals behavior
195
+ });
196
+ }
197
+
198
+ /** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
199
+ * location, the `object` minus the `key: value` and in the second location the `value`.
200
+ *
201
+ * @param key - The key from the object to extract
202
+ * @param object - The object from which to extract the element
203
+ * @returns - An array with the first value being the object minus the `key` element and the second element being the
204
+ * value from `object[key]`
205
+ */
206
+
207
+ function splitKeyElementFromObject(key, object) {
208
+ const value = object[key];
209
+ const remaining = omit(object, [key]);
210
+ return [remaining, value];
211
+ }
212
+ /** Given the name of a `$ref` from within a schema, using the `rootSchema`, look up and return the sub-schema using the
213
+ * path provided by that reference. If `#` is not the first character of the reference, or the path does not exist in
214
+ * the schema, then throw an Error. Otherwise return the sub-schema. Also deals with nested `$ref`s in the sub-schema.
215
+ *
216
+ * @param $ref - The ref string for which the schema definition is desired
217
+ * @param [rootSchema={}] - The root schema in which to search for the definition
218
+ * @returns - The sub-schema within the `rootSchema` which matches the `$ref` if it exists
219
+ * @throws - Error indicating that no schema for that reference exists
220
+ */
221
+
222
+ function findSchemaDefinition($ref, rootSchema) {
223
+ if (rootSchema === void 0) {
224
+ rootSchema = {};
225
+ }
226
+
227
+ let ref = $ref || "";
228
+
229
+ if (ref.startsWith("#")) {
230
+ // Decode URI fragment representation.
231
+ ref = decodeURIComponent(ref.substring(1));
232
+ } else {
233
+ throw new Error("Could not find a definition for " + $ref + ".");
234
+ }
235
+
236
+ const current = jsonpointer.get(rootSchema, ref);
237
+
238
+ if (current === undefined) {
239
+ throw new Error("Could not find a definition for " + $ref + ".");
240
+ }
241
+
242
+ if (current[REF_KEY]) {
243
+ const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
244
+ const subSchema = findSchemaDefinition(theRef, rootSchema);
245
+
246
+ if (Object.keys(remaining).length > 0) {
247
+ return { ...remaining,
248
+ ...subSchema
249
+ };
250
+ }
251
+
252
+ return subSchema;
253
+ }
254
+
255
+ return current;
256
+ }
257
+
258
+ /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
259
+ *
260
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
261
+ * @param formData - The current formData, if any, used to figure out a match
262
+ * @param options - The list of options to find a matching options from
263
+ * @param rootSchema - The root schema, used to primarily to look up `$ref`s
264
+ * @returns - The index of the matched option or 0 if none is available
265
+ */
266
+ function getMatchingOption(validator, formData, options, rootSchema) {
267
+ // For performance, skip validating subschemas if formData is undefined. We just
268
+ // want to get the first option in that case.
269
+ if (formData === undefined) {
270
+ return 0;
271
+ }
272
+
273
+ for (let i = 0; i < options.length; i++) {
274
+ const option = options[i]; // If the schema describes an object then we need to add slightly more
275
+ // strict matching to the schema, because unless the schema uses the
276
+ // "requires" keyword, an object will match the schema as long as it
277
+ // doesn't have matching keys with a conflicting type. To do this we use an
278
+ // "anyOf" with an array of requires. This augmentation expresses that the
279
+ // schema should match if any of the keys in the schema are present on the
280
+ // object and pass validation.
281
+
282
+ if (option.properties) {
283
+ // Create an "anyOf" schema that requires at least one of the keys in the
284
+ // "properties" object
285
+ const requiresAnyOf = {
286
+ anyOf: Object.keys(option.properties).map(key => ({
287
+ required: [key]
288
+ }))
289
+ };
290
+ let augmentedSchema; // If the "anyOf" keyword already exists, wrap the augmentation in an "allOf"
291
+
292
+ if (option.anyOf) {
293
+ // Create a shallow clone of the option
294
+ const { ...shallowClone
295
+ } = option;
296
+
297
+ if (!shallowClone.allOf) {
298
+ shallowClone.allOf = [];
299
+ } else {
300
+ // If "allOf" already exists, shallow clone the array
301
+ shallowClone.allOf = shallowClone.allOf.slice();
302
+ }
303
+
304
+ shallowClone.allOf.push(requiresAnyOf);
305
+ augmentedSchema = shallowClone;
306
+ } else {
307
+ augmentedSchema = Object.assign({}, option, requiresAnyOf);
308
+ } // Remove the "required" field as it's likely that not all fields have
309
+ // been filled in yet, which will mean that the schema is not valid
310
+
311
+
312
+ delete augmentedSchema.required;
313
+
314
+ if (validator.isValid(augmentedSchema, formData, rootSchema)) {
315
+ return i;
316
+ }
317
+ } else if (validator.isValid(option, formData, rootSchema)) {
318
+ return i;
319
+ }
320
+ }
321
+
322
+ return 0;
323
+ }
324
+
325
+ /** Given a specific `value` attempts to guess the type of a schema element. In the case where we have to implicitly
326
+ * create a schema, it is useful to know what type to use based on the data we are defining.
327
+ *
328
+ * @param value - The value from which to guess the type
329
+ * @returns - The best guess for the object type
330
+ */
331
+ function guessType(value) {
332
+ if (Array.isArray(value)) {
333
+ return "array";
334
+ }
335
+
336
+ if (typeof value === "string") {
337
+ return "string";
338
+ }
339
+
340
+ if (value == null) {
341
+ return "null";
342
+ }
343
+
344
+ if (typeof value === "boolean") {
345
+ return "boolean";
346
+ }
347
+
348
+ if (!isNaN(value)) {
349
+ return "number";
350
+ }
351
+
352
+ if (typeof value === "object") {
353
+ return "object";
354
+ } // Default to string if we can't figure it out
355
+
356
+
357
+ return "string";
358
+ }
359
+
360
+ /** Gets the type of a given `schema`. If the type is not explicitly defined, then an attempt is made to infer it from
361
+ * other elements of the schema as follows:
362
+ * - schema.const: Returns the `guessType()` of that value
363
+ * - schema.enum: Returns `string`
364
+ * - schema.properties: Returns `object`
365
+ * - schema.additionalProperties: Returns `object`
366
+ * - type is an array with a length of 2 and one type is 'null': Returns the other type
367
+ *
368
+ * @param schema - The schema for which to get the type
369
+ * @returns - The type of the schema
370
+ */
371
+
372
+ function getSchemaType(schema) {
373
+ let {
374
+ type
375
+ } = schema;
376
+
377
+ if (!type && schema.const) {
378
+ return guessType(schema.const);
379
+ }
380
+
381
+ if (!type && schema.enum) {
382
+ return "string";
383
+ }
384
+
385
+ if (!type && (schema.properties || schema.additionalProperties)) {
386
+ return "object";
387
+ }
388
+
389
+ if (Array.isArray(type) && type.length === 2 && type.includes("null")) {
390
+ type = type.find(type => type !== "null");
391
+ }
392
+
393
+ return type;
394
+ }
395
+
396
+ /** Detects whether the given `schema` contains fixed items. This is the case when `schema.items` is a non-empty array
397
+ * that only contains objects.
398
+ *
399
+ * @param schema - The schema in which to check for fixed items
400
+ * @returns - True if there are fixed items in the schema, false otherwise
401
+ */
402
+
403
+ function isFixedItems(schema) {
404
+ return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every(item => isObject(item));
405
+ }
406
+
407
+ /** Merges the `defaults` object of type `T` into the `formData` of type `T`
408
+ *
409
+ * When merging defaults and form data, we want to merge in this specific way:
410
+ * - objects are deeply merged
411
+ * - arrays are merged in such a way that:
412
+ * - when the array is set in form data, only array entries set in form data
413
+ * are deeply merged; additional entries from the defaults are ignored
414
+ * - when the array is not set in form data, the default is copied over
415
+ * - scalars are overwritten/set by form data
416
+ *
417
+ * @param defaults - The defaults to merge
418
+ * @param formData - The form data into which the defaults will be merged
419
+ * @returns - The resulting merged form data with defaults
420
+ */
421
+
422
+ function mergeDefaultsWithFormData(defaults, formData) {
423
+ if (Array.isArray(formData)) {
424
+ const defaultsArray = Array.isArray(defaults) ? defaults : [];
425
+ const mapped = formData.map((value, idx) => {
426
+ if (defaultsArray[idx]) {
427
+ return mergeDefaultsWithFormData(defaultsArray[idx], value);
428
+ }
429
+
430
+ return value;
431
+ });
432
+ return mapped;
433
+ }
434
+
435
+ if (isObject(formData)) {
436
+ // eslint-disable-next-line no-unused-vars
437
+ const acc = Object.assign({}, defaults); // Prevent mutation of source object.
438
+
439
+ return Object.keys(formData).reduce((acc, key) => {
440
+ acc[key] = mergeDefaultsWithFormData(defaults ? get(defaults, key) : {}, get(formData, key));
441
+ return acc;
442
+ }, acc);
443
+ }
444
+
445
+ return formData;
446
+ }
447
+
448
+ /** Recursively merge deeply nested objects.
449
+ *
450
+ * @param obj1 - The first object to merge
451
+ * @param obj2 - The second object to merge
452
+ * @param [concatArrays=false] - Optional flag that, when true, will cause arrays to be concatenated
453
+ * @returns - A new object that is the merge of the two given objects
454
+ */
455
+
456
+ function mergeObjects(obj1, obj2, concatArrays) {
457
+ if (concatArrays === void 0) {
458
+ concatArrays = false;
459
+ }
460
+
461
+ return Object.keys(obj2).reduce((acc, key) => {
462
+ const left = obj1 ? obj1[key] : {},
463
+ right = obj2[key];
464
+
465
+ if (obj1 && key in obj1 && isObject(right)) {
466
+ acc[key] = mergeObjects(left, right, concatArrays);
467
+ } else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
468
+ acc[key] = left.concat(right);
469
+ } else {
470
+ acc[key] = right;
471
+ }
472
+
473
+ return acc;
474
+ }, Object.assign({}, obj1)); // Prevent mutation of source object.
475
+ }
476
+
477
+ /** This function checks if the given `schema` matches a single constant value. This happens when either the schema has
478
+ * an `enum` array with a single value or there is a `const` defined.
479
+ *
480
+ * @param schema - The schema for a field
481
+ * @returns - True if the `schema` has a single constant value, false otherwise
482
+ */
483
+
484
+ function isConstant(schema) {
485
+ return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
486
+ }
487
+
488
+ /** Recursively merge deeply nested schemas. The difference between `mergeSchemas` and `mergeObjects` is that
489
+ * `mergeSchemas` only concats arrays for values under the 'required' keyword, and when it does, it doesn't include
490
+ * duplicate values.
491
+ *
492
+ * @param obj1 - The first schema object to merge
493
+ * @param obj2 - The second schema object to merge
494
+ * @returns - The merged schema object
495
+ */
496
+
497
+ function mergeSchemas(obj1, obj2) {
498
+ const acc = Object.assign({}, obj1); // Prevent mutation of source object.
499
+
500
+ return Object.keys(obj2).reduce((acc, key) => {
501
+ const left = obj1 ? obj1[key] : {},
502
+ right = obj2[key];
503
+
504
+ if (obj1 && key in obj1 && isObject(right)) {
505
+ acc[key] = mergeSchemas(left, right);
506
+ } else if (obj1 && obj2 && (getSchemaType(obj1) === "object" || getSchemaType(obj2) === "object") && key === REQUIRED_KEY && Array.isArray(left) && Array.isArray(right)) {
507
+ // Don't include duplicate values when merging 'required' fields.
508
+ acc[key] = union(left, right);
509
+ } else {
510
+ acc[key] = right;
511
+ }
512
+
513
+ return acc;
514
+ }, acc);
515
+ }
516
+
517
+ /** Resolves a conditional block (if/else/then) by removing the condition and merging the appropriate conditional branch
518
+ * with the rest of the schema
519
+ *
520
+ * @param validator - An implementation of the `ValidatorType` interface that is used to detect valid schema conditions
521
+ * @param schema - The schema for which resolving a condition is desired
522
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
523
+ * @param formData - The current formData to assist retrieving a schema
524
+ * @returns - A schema with the appropriate condition resolved
525
+ */
526
+
527
+ function resolveCondition(validator, schema, rootSchema, formData) {
528
+ const {
529
+ if: expression,
530
+ then,
531
+ else: otherwise,
532
+ ...resolvedSchemaLessConditional
533
+ } = schema;
534
+ const conditionalSchema = validator.isValid(expression, formData, rootSchema) ? then : otherwise;
535
+
536
+ if (conditionalSchema && typeof conditionalSchema !== "boolean") {
537
+ return retrieveSchema(validator, mergeSchemas(resolvedSchemaLessConditional, retrieveSchema(validator, conditionalSchema, rootSchema, formData)), rootSchema, formData);
538
+ }
539
+
540
+ return retrieveSchema(validator, resolvedSchemaLessConditional, rootSchema, formData);
541
+ }
542
+ /** Resolves references and dependencies within a schema and its 'allOf' children.
543
+ * Called internally by retrieveSchema.
544
+ *
545
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
546
+ * @param schema - The schema for which resolving a schema is desired
547
+ * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
548
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
549
+ * @returns - The schema having its references and dependencies resolved
550
+ */
551
+
552
+ function resolveSchema(validator, schema, rootSchema, formData) {
553
+ if (rootSchema === void 0) {
554
+ rootSchema = {};
555
+ }
556
+
557
+ if (REF_KEY in schema) {
558
+ return resolveReference(validator, schema, rootSchema, formData);
559
+ }
560
+
561
+ if (DEPENDENCIES_KEY in schema) {
562
+ const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
563
+ return retrieveSchema(validator, resolvedSchema, rootSchema, formData);
564
+ }
565
+
566
+ if (ALL_OF_KEY in schema) {
567
+ return { ...schema,
568
+ allOf: schema.allOf.map(allOfSubschema => retrieveSchema(validator, allOfSubschema, rootSchema, formData))
569
+ };
570
+ } // No $ref or dependencies attribute found, returning the original schema.
571
+
572
+
573
+ return schema;
574
+ }
575
+ /** Resolves references within a schema and its 'allOf' children.
576
+ *
577
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
578
+ * @param schema - The schema for which resolving a reference is desired
579
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
580
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
581
+ * @returns - The schema having its references resolved
582
+ */
583
+
584
+ function resolveReference(validator, schema, rootSchema, formData) {
585
+ // Retrieve the referenced schema definition.
586
+ const $refSchema = findSchemaDefinition(schema.$ref, rootSchema); // Drop the $ref property of the source schema.
587
+
588
+ const {
589
+ $ref,
590
+ ...localSchema
591
+ } = schema; // Update referenced schema definition with local schema properties.
592
+
593
+ return retrieveSchema(validator, { ...$refSchema,
594
+ ...localSchema
595
+ }, rootSchema, formData);
596
+ }
597
+ /** Creates new 'properties' items for each key in the `formData`
598
+ *
599
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
600
+ * @param theSchema - The schema for which the existing additional properties is desired
601
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s * @param validator
602
+ * @param [aFormData] - The current formData, if any, to assist retrieving a schema
603
+ * @returns - The updated schema with additional properties stubbed
604
+ */
605
+
606
+ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
607
+ // Clone the schema so we don't ruin the consumer's original
608
+ const schema = { ...theSchema,
609
+ properties: { ...theSchema.properties
610
+ }
611
+ }; // make sure formData is an object
612
+
613
+ const formData = aFormData && isObject(aFormData) ? aFormData : {};
614
+ Object.keys(formData).forEach(key => {
615
+ if (key in schema.properties) {
616
+ // No need to stub, our schema already has the property
617
+ return;
618
+ }
619
+
620
+ let additionalProperties = {};
621
+
622
+ if (typeof schema.additionalProperties !== "boolean") {
623
+ if (REF_KEY in schema.additionalProperties) {
624
+ additionalProperties = retrieveSchema(validator, {
625
+ $ref: get(schema.additionalProperties, [REF_KEY])
626
+ }, rootSchema, formData);
627
+ } else if ("type" in schema.additionalProperties) {
628
+ additionalProperties = { ...schema.additionalProperties
629
+ };
630
+ } else {
631
+ additionalProperties = {
632
+ type: guessType(get(formData, [key]))
633
+ };
634
+ }
635
+ } else {
636
+ additionalProperties = {
637
+ type: guessType(get(formData, [key]))
638
+ };
639
+ } // The type of our new key should match the additionalProperties value;
640
+
641
+
642
+ schema.properties[key] = additionalProperties; // Set our additional property flag so we know it was dynamically added
643
+
644
+ set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
645
+ });
646
+ return schema;
647
+ }
648
+ /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and dependencies
649
+ * resolved and merged into the `schema` given a `validator`, `rootSchema` and `rawFormData` that is used to do the
650
+ * potentially recursive resolution.
651
+ *
652
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
653
+ * @param schema - The schema for which retrieving a schema is desired
654
+ * @param [rootSchema={}] - The root schema that will be forwarded to all the APIs
655
+ * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
656
+ * @returns - The schema having its conditions, additional properties, references and dependencies resolved
657
+ */
658
+
659
+ function retrieveSchema(validator, schema, rootSchema, rawFormData) {
660
+ if (rootSchema === void 0) {
661
+ rootSchema = {};
662
+ }
663
+
664
+ if (!isObject(schema)) {
665
+ return {};
666
+ }
667
+
668
+ let resolvedSchema = resolveSchema(validator, schema, rootSchema, rawFormData);
669
+
670
+ if ("if" in schema) {
671
+ return resolveCondition(validator, schema, rootSchema, rawFormData);
672
+ }
673
+
674
+ const formData = rawFormData || {}; // For each level of the dependency, we need to recursively determine the appropriate resolved schema given the current state of formData.
675
+ // Otherwise, nested allOf subschemas will not be correctly displayed.
676
+
677
+ if (resolvedSchema.properties) {
678
+ const properties = {};
679
+ Object.entries(resolvedSchema.properties).forEach(entries => {
680
+ const propName = entries[0];
681
+ const propSchema = entries[1];
682
+ const rawPropData = formData[propName];
683
+ const propData = isObject(rawPropData) ? rawPropData : {};
684
+ const resolvedPropSchema = retrieveSchema(validator, propSchema, rootSchema, propData);
685
+ properties[propName] = resolvedPropSchema;
686
+
687
+ if (propSchema !== resolvedPropSchema && resolvedSchema.properties !== properties) {
688
+ resolvedSchema = { ...resolvedSchema,
689
+ properties
690
+ };
691
+ }
692
+ });
693
+ }
694
+
695
+ if (ALL_OF_KEY in schema) {
696
+ try {
697
+ resolvedSchema = mergeAllOf({ ...resolvedSchema,
698
+ allOf: resolvedSchema.allOf
699
+ });
700
+ } catch (e) {
701
+ console.warn("could not merge subschemas in allOf:\n" + e);
702
+ const {
703
+ allOf,
704
+ ...resolvedSchemaWithoutAllOf
705
+ } = resolvedSchema;
706
+ return resolvedSchemaWithoutAllOf;
707
+ }
708
+ }
709
+
710
+ const hasAdditionalProperties = ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
711
+
712
+ if (hasAdditionalProperties) {
713
+ return stubExistingAdditionalProperties(validator, resolvedSchema, rootSchema, formData);
714
+ }
715
+
716
+ return resolvedSchema;
717
+ }
718
+ /** Resolves dependencies within a schema and its 'allOf' children.
719
+ *
720
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
721
+ * @param schema - The schema for which resolving a dependency is desired
722
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
723
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
724
+ * @returns - The schema with its dependencies resolved
725
+ */
726
+
727
+ function resolveDependencies(validator, schema, rootSchema, formData) {
728
+ // Drop the dependencies from the source schema.
729
+ const {
730
+ dependencies,
731
+ ...remainingSchema
732
+ } = schema;
733
+ let resolvedSchema = remainingSchema;
734
+
735
+ if (Array.isArray(resolvedSchema.oneOf)) {
736
+ resolvedSchema = resolvedSchema.oneOf[getMatchingOption(validator, formData, resolvedSchema.oneOf, rootSchema)];
737
+ } else if (Array.isArray(resolvedSchema.anyOf)) {
738
+ resolvedSchema = resolvedSchema.anyOf[getMatchingOption(validator, formData, resolvedSchema.anyOf, rootSchema)];
739
+ }
740
+
741
+ return processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData);
742
+ }
743
+ /** Processes all the `dependencies` recursively into the `resolvedSchema` as needed
744
+ *
745
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
746
+ * @param dependencies - The set of dependencies that needs to be processed
747
+ * @param resolvedSchema - The schema for which processing dependencies is desired
748
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
749
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
750
+ * @returns - The schema with the `dependencies` resolved into it
751
+ */
752
+
753
+ function processDependencies(validator, dependencies, resolvedSchema, rootSchema, formData) {
754
+ let schema = resolvedSchema; // Process dependencies updating the local schema properties as appropriate.
755
+
756
+ for (const dependencyKey in dependencies) {
757
+ // Skip this dependency if its trigger property is not present.
758
+ if (get(formData, [dependencyKey]) === undefined) {
759
+ continue;
760
+ } // Skip this dependency if it is not included in the schema (such as when dependencyKey is itself a hidden dependency.)
761
+
762
+
763
+ if (schema.properties && !(dependencyKey in schema.properties)) {
764
+ continue;
765
+ }
766
+
767
+ const [remainingDependencies, dependencyValue] = splitKeyElementFromObject(dependencyKey, dependencies);
768
+
769
+ if (Array.isArray(dependencyValue)) {
770
+ schema = withDependentProperties(schema, dependencyValue);
771
+ } else if (isObject(dependencyValue)) {
772
+ schema = withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData);
773
+ }
774
+
775
+ return processDependencies(validator, remainingDependencies, schema, rootSchema, formData);
776
+ }
777
+
778
+ return schema;
779
+ }
780
+ /** Updates a schema with additionally required properties added
781
+ *
782
+ * @param schema - The schema for which resolving a dependent properties is desired
783
+ * @param [additionallyRequired] - An optional array of additionally required names
784
+ * @returns - The schema with the additional required values merged in
785
+ */
786
+
787
+ function withDependentProperties(schema, additionallyRequired) {
788
+ if (!additionallyRequired) {
789
+ return schema;
790
+ }
791
+
792
+ const required = Array.isArray(schema.required) ? Array.from(new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
793
+ return { ...schema,
794
+ required: required
795
+ };
796
+ }
797
+ /** Merges a dependent schema into the `schema` dealing with oneOfs and references
798
+ *
799
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
800
+ * @param schema - The schema for which resolving a dependent schema is desired
801
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
802
+ * @param dependencyKey - The key name of the dependency
803
+ * @param dependencyValue - The potentially dependent schema
804
+ * @param formData- The current formData to assist retrieving a schema
805
+ * @returns - The schema with the dependent schema resolved into it
806
+ */
807
+
808
+ function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, formData) {
809
+ const {
810
+ oneOf,
811
+ ...dependentSchema
812
+ } = retrieveSchema(validator, dependencyValue, rootSchema, formData);
813
+ schema = mergeSchemas(schema, dependentSchema); // Since it does not contain oneOf, we return the original schema.
814
+
815
+ if (oneOf === undefined) {
816
+ return schema;
817
+ } // Resolve $refs inside oneOf.
818
+
819
+
820
+ const resolvedOneOf = oneOf.map(subschema => {
821
+ if (typeof subschema === "boolean" || !(REF_KEY in subschema)) {
822
+ return subschema;
823
+ }
824
+
825
+ return resolveReference(validator, subschema, rootSchema, formData);
826
+ });
827
+ return withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, resolvedOneOf, formData);
828
+ }
829
+ /** Returns a `schema` with the best choice from the `oneOf` options merged into it
830
+ *
831
+ * @param validator - An implementation of the `ValidatorType` interface that will be used to validate oneOf options
832
+ * @param schema - The schema for which resolving a oneOf subschema is desired
833
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
834
+ * @param dependencyKey - The key name of the oneOf dependency
835
+ * @param oneOf - The list of schemas representing the oneOf options
836
+ * @param [formData] - The current formData to assist retrieving a schema
837
+ * @returns The schema with best choice of oneOf schemas merged into
838
+ */
839
+
840
+ function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, formData) {
841
+ const validSubschemas = oneOf.filter(subschema => {
842
+ if (typeof subschema === "boolean" || !subschema.properties) {
843
+ return false;
844
+ }
845
+
846
+ const {
847
+ [dependencyKey]: conditionPropertySchema
848
+ } = subschema.properties;
849
+
850
+ if (conditionPropertySchema) {
851
+ const conditionSchema = {
852
+ type: "object",
853
+ properties: {
854
+ [dependencyKey]: conditionPropertySchema
855
+ }
856
+ };
857
+ const {
858
+ errors
859
+ } = validator.validateFormData(formData, conditionSchema);
860
+ return errors.length === 0;
861
+ }
862
+
863
+ return false;
864
+ });
865
+
866
+ if (validSubschemas.length !== 1) {
867
+ console.warn("ignoring oneOf in dependencies because there isn't exactly one subschema that is valid");
868
+ return schema;
869
+ }
870
+
871
+ const subschema = validSubschemas[0];
872
+ const [dependentSubschema] = splitKeyElementFromObject(dependencyKey, subschema.properties);
873
+ const dependentSchema = { ...subschema,
874
+ properties: dependentSubschema
875
+ };
876
+ return mergeSchemas(schema, retrieveSchema(validator, dependentSchema, rootSchema, formData));
877
+ }
878
+
879
+ /** Checks to see if the `schema` combination represents a select
880
+ *
881
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
882
+ * @param theSchema - The schema for which check for a select flag is desired
883
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
884
+ * @returns - True if schema contains a select, otherwise false
885
+ */
886
+
887
+ function isSelect(validator, theSchema, rootSchema) {
888
+ if (rootSchema === void 0) {
889
+ rootSchema = {};
890
+ }
891
+
892
+ const schema = retrieveSchema(validator, theSchema, rootSchema, undefined);
893
+ const altSchemas = schema.oneOf || schema.anyOf;
894
+
895
+ if (Array.isArray(schema.enum)) {
896
+ return true;
897
+ }
898
+
899
+ if (Array.isArray(altSchemas)) {
900
+ return altSchemas.every(altSchemas => typeof altSchemas !== "boolean" && isConstant(altSchemas));
901
+ }
902
+
903
+ return false;
904
+ }
905
+
906
+ /** Checks to see if the `schema` combination represents a multi-select
907
+ *
908
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
909
+ * @param schema - The schema for which check for a multi-select flag is desired
910
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
911
+ * @returns - True if schema contains a multi-select, otherwise false
912
+ */
913
+
914
+ function isMultiSelect(validator, schema, rootSchema) {
915
+ if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
916
+ return false;
917
+ }
918
+
919
+ return isSelect(validator, schema.items, rootSchema);
920
+ }
921
+
922
+ /** Enum that indicates how `schema.additionalItems` should be handled by the `getInnerSchemaForArrayItem()` function.
923
+ */
924
+
925
+ var AdditionalItemsHandling;
926
+
927
+ (function (AdditionalItemsHandling) {
928
+ AdditionalItemsHandling[AdditionalItemsHandling["Ignore"] = 0] = "Ignore";
929
+ AdditionalItemsHandling[AdditionalItemsHandling["Invert"] = 1] = "Invert";
930
+ AdditionalItemsHandling[AdditionalItemsHandling["Fallback"] = 2] = "Fallback";
931
+ })(AdditionalItemsHandling || (AdditionalItemsHandling = {}));
932
+ /** Given a `schema` will return an inner schema that for an array item. This is computed differently based on the
933
+ * `additionalItems` enum and the value of `idx`. There are four possible returns:
934
+ * 1. If `idx` is >= 0, then if `schema.items` is an array the `idx`th element of the array is returned if it is a valid
935
+ * index and not a boolean, otherwise it falls through to 3.
936
+ * 2. If `schema.items` is not an array AND truthy and not a boolean, then `schema.items` is returned since it actually
937
+ * is a schema, otherwise it falls through to 3.
938
+ * 3. If `additionalItems` is not `AdditionalItemsHandling.Ignore` and `schema.additionalItems` is an object, then
939
+ * `schema.additionalItems` is returned since it actually is a schema, otherwise it falls through to 4.
940
+ * 4. {} is returned representing an empty schema
941
+ *
942
+ * @param schema - The schema from which to get the particular item
943
+ * @param [additionalItems=AdditionalItemsHandling.Ignore] - How do we want to handle additional items?
944
+ * @param [idx=-1] - Index, if non-negative, will be used to return the idx-th element in a `schema.items` array
945
+ * @returns - The best fit schema object from the `schema` given the `additionalItems` and `idx` modifiers
946
+ */
947
+
948
+
949
+ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
950
+ if (additionalItems === void 0) {
951
+ additionalItems = AdditionalItemsHandling.Ignore;
952
+ }
953
+
954
+ if (idx === void 0) {
955
+ idx = -1;
956
+ }
957
+
958
+ if (idx >= 0) {
959
+ if (Array.isArray(schema.items) && idx < schema.items.length) {
960
+ const item = schema.items[idx];
961
+
962
+ if (typeof item !== "boolean") {
963
+ return item;
964
+ }
965
+ }
966
+ } else if (schema.items && !Array.isArray(schema.items) && typeof schema.items !== "boolean") {
967
+ return schema.items;
968
+ }
969
+
970
+ if (additionalItems !== AdditionalItemsHandling.Ignore && isObject(schema.additionalItems)) {
971
+ return schema.additionalItems;
972
+ }
973
+
974
+ return {};
975
+ }
976
+ /** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into
977
+ * the each level of the schema, recursively, to fill out every level of defaults provided by the schema.
978
+ *
979
+ * @param validator - an implementation of the `ValidatorType` interface that will be used when necessary
980
+ * @param schema - The schema for which the default state is desired
981
+ * @param [parentDefaults] - Any defaults provided by the parent field in the schema
982
+ * @param [rootSchema] - The options root schema, used to primarily to look up `$ref`s
983
+ * @param [rawFormData] - The current formData, if any, onto which to provide any missing defaults
984
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
985
+ * @returns - The resulting `formData` with all the defaults provided
986
+ */
987
+
988
+ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormData, includeUndefinedValues) {
989
+ if (rootSchema === void 0) {
990
+ rootSchema = {};
991
+ }
992
+
993
+ if (includeUndefinedValues === void 0) {
994
+ includeUndefinedValues = false;
995
+ }
996
+
997
+ const formData = isObject(rawFormData) ? rawFormData : {}; // Compute the defaults recursively: give highest priority to deepest nodes.
998
+
999
+ let defaults = parentDefaults;
1000
+
1001
+ if (isObject(defaults) && isObject(schema.default)) {
1002
+ // For object defaults, only override parent defaults that are defined in
1003
+ // schema.default.
1004
+ defaults = mergeObjects(defaults, schema.default);
1005
+ } else if (DEFAULT_KEY in schema) {
1006
+ defaults = schema.default;
1007
+ } else if (REF_KEY in schema) {
1008
+ // Use referenced schema defaults for this node.
1009
+ const refSchema = findSchemaDefinition(schema[REF_KEY], rootSchema);
1010
+ return computeDefaults(validator, refSchema, defaults, rootSchema, formData, includeUndefinedValues);
1011
+ } else if (DEPENDENCIES_KEY in schema) {
1012
+ const resolvedSchema = resolveDependencies(validator, schema, rootSchema, formData);
1013
+ return computeDefaults(validator, resolvedSchema, defaults, rootSchema, formData, includeUndefinedValues);
1014
+ } else if (isFixedItems(schema)) {
1015
+ defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues));
1016
+ } else if (ONE_OF_KEY in schema) {
1017
+ schema = schema.oneOf[getMatchingOption(validator, undefined, schema.oneOf, rootSchema)];
1018
+ } else if (ANY_OF_KEY in schema) {
1019
+ schema = schema.anyOf[getMatchingOption(validator, undefined, schema.anyOf, rootSchema)];
1020
+ } // Not defaults defined for this node, fallback to generic typed ones.
1021
+
1022
+
1023
+ if (typeof defaults === "undefined") {
1024
+ defaults = schema.default;
1025
+ }
1026
+
1027
+ switch (getSchemaType(schema)) {
1028
+ // We need to recur for object schema inner default values.
1029
+ case "object":
1030
+ return Object.keys(schema.properties || {}).reduce((acc, key) => {
1031
+ // Compute the defaults for this node, with the parent defaults we might
1032
+ // have from a previous run: defaults[key].
1033
+ const computedDefault = computeDefaults(validator, get(schema, [PROPERTIES_KEY, key]), get(defaults, [key]), rootSchema, get(formData, [key]), includeUndefinedValues);
1034
+
1035
+ if (includeUndefinedValues || computedDefault !== undefined) {
1036
+ acc[key] = computedDefault;
1037
+ }
1038
+
1039
+ return acc;
1040
+ }, {});
1041
+
1042
+ case "array":
1043
+ // Inject defaults into existing array defaults
1044
+ if (Array.isArray(defaults)) {
1045
+ defaults = defaults.map((item, idx) => {
1046
+ const schemaItem = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Fallback, idx);
1047
+ return computeDefaults(validator, schemaItem, item, rootSchema);
1048
+ });
1049
+ } // Deeply inject defaults into already existing form data
1050
+
1051
+
1052
+ if (Array.isArray(rawFormData)) {
1053
+ const schemaItem = getInnerSchemaForArrayItem(schema);
1054
+ defaults = rawFormData.map((item, idx) => {
1055
+ return computeDefaults(validator, schemaItem, get(defaults, [idx]), rootSchema, item);
1056
+ });
1057
+ }
1058
+
1059
+ if (schema.minItems) {
1060
+ if (!isMultiSelect(validator, schema, rootSchema)) {
1061
+ const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
1062
+
1063
+ if (schema.minItems > defaultsLength) {
1064
+ const defaultEntries = defaults || []; // populate the array with the defaults
1065
+
1066
+ const fillerSchema = getInnerSchemaForArrayItem(schema, AdditionalItemsHandling.Invert);
1067
+ const fillerDefault = fillerSchema.default;
1068
+ const fillerEntries = new Array(schema.minItems - defaultsLength).fill(computeDefaults(validator, fillerSchema, fillerDefault, rootSchema)); // then fill up the rest with either the item default or empty, up to minItems
1069
+
1070
+ return defaultEntries.concat(fillerEntries);
1071
+ }
1072
+ }
1073
+
1074
+ return defaults ? defaults : [];
1075
+ }
1076
+
1077
+ }
1078
+
1079
+ return defaults;
1080
+ }
1081
+ /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1082
+ * computed to have defaults provided in the `schema`.
1083
+ *
1084
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1085
+ * @param theSchema - The schema for which the default state is desired
1086
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1087
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1088
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1089
+ * @returns - The resulting `formData` with all the defaults provided
1090
+ */
1091
+
1092
+ function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues) {
1093
+ if (includeUndefinedValues === void 0) {
1094
+ includeUndefinedValues = false;
1095
+ }
1096
+
1097
+ if (!isObject(theSchema)) {
1098
+ throw new Error("Invalid schema: " + theSchema);
1099
+ }
1100
+
1101
+ const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
1102
+ const defaults = computeDefaults(validator, schema, undefined, rootSchema, formData, includeUndefinedValues);
1103
+
1104
+ if (typeof formData === "undefined" || formData === null || typeof formData === "number" && isNaN(formData)) {
1105
+ // No form data? Use schema defaults.
1106
+ return defaults;
1107
+ }
1108
+
1109
+ if (isObject(formData)) {
1110
+ return mergeDefaultsWithFormData(defaults, formData);
1111
+ }
1112
+
1113
+ if (Array.isArray(formData)) {
1114
+ return mergeDefaultsWithFormData(defaults, formData);
1115
+ }
1116
+
1117
+ return formData;
1118
+ }
1119
+
1120
+ /** Checks to see if the `uiSchema` contains the `widget` field and that the widget is not `hidden`
1121
+ *
1122
+ * @param uiSchema - The UI Schema from which to detect if it is customized
1123
+ * @returns - True if the `uiSchema` describes a custom widget, false otherwise
1124
+ */
1125
+
1126
+ function isCustomWidget(uiSchema) {
1127
+ if (uiSchema === void 0) {
1128
+ uiSchema = {};
1129
+ }
1130
+
1131
+ return (// TODO: Remove the `&& uiSchema['ui:widget'] !== 'hidden'` once we support hidden widgets for arrays.
1132
+ // https://react-jsonschema-form.readthedocs.io/en/latest/usage/widgets/#hidden-widgets
1133
+ "widget" in getUiOptions(uiSchema) && getUiOptions(uiSchema)["widget"] !== "hidden"
1134
+ );
1135
+ }
1136
+
1137
+ /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1138
+ *
1139
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1140
+ * @param schema - The schema for which check for array of files flag is desired
1141
+ * @param [uiSchema={}] - The UI schema from which to check the widget
1142
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1143
+ * @returns - True if schema/uiSchema contains an array of files, otherwise false
1144
+ */
1145
+
1146
+ function isFilesArray(validator, schema, uiSchema, rootSchema) {
1147
+ if (uiSchema === void 0) {
1148
+ uiSchema = {};
1149
+ }
1150
+
1151
+ if (uiSchema[UI_WIDGET_KEY] === "files") {
1152
+ return true;
1153
+ }
1154
+
1155
+ if (schema.items) {
1156
+ const itemsSchema = retrieveSchema(validator, schema.items, rootSchema);
1157
+ return itemsSchema.type === "string" && itemsSchema.format === "data-url";
1158
+ }
1159
+
1160
+ return false;
1161
+ }
1162
+
1163
+ /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1164
+ * should be displayed in a UI.
1165
+ *
1166
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1167
+ * @param schema - The schema for which the display label flag is desired
1168
+ * @param [uiSchema={}] - The UI schema from which to derive potentially displayable information
1169
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1170
+ * @returns - True if the label should be displayed or false if it should not
1171
+ */
1172
+
1173
+ function getDisplayLabel(validator, schema, uiSchema, rootSchema) {
1174
+ if (uiSchema === void 0) {
1175
+ uiSchema = {};
1176
+ }
1177
+
1178
+ const uiOptions = getUiOptions(uiSchema);
1179
+ const {
1180
+ label = true
1181
+ } = uiOptions;
1182
+ let displayLabel = !!label;
1183
+ const schemaType = getSchemaType(schema);
1184
+
1185
+ if (schemaType === "array") {
1186
+ displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
1187
+ }
1188
+
1189
+ if (schemaType === "object") {
1190
+ displayLabel = false;
1191
+ }
1192
+
1193
+ if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
1194
+ displayLabel = false;
1195
+ }
1196
+
1197
+ if (uiSchema[UI_FIELD_KEY]) {
1198
+ displayLabel = false;
1199
+ }
1200
+
1201
+ return displayLabel;
1202
+ }
1203
+
1204
+ /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in the
1205
+ * two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1206
+ * `validator.toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed, then
1207
+ * `validationData` is returned.
1208
+ *
1209
+ * @param validator - The validator used to convert an ErrorSchema to a list of errors
1210
+ * @param validationData - The current `ValidationData` into which to merge the additional errors
1211
+ * @param [additionalErrorSchema] - The additional set of errors in an `ErrorSchema`
1212
+ * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1213
+ */
1214
+
1215
+ function mergeValidationData(validator, validationData, additionalErrorSchema) {
1216
+ if (!additionalErrorSchema) {
1217
+ return validationData;
1218
+ }
1219
+
1220
+ const {
1221
+ errors: oldErrors,
1222
+ errorSchema: oldErrorSchema
1223
+ } = validationData;
1224
+ let errors = validator.toErrorList(additionalErrorSchema);
1225
+ let errorSchema = additionalErrorSchema;
1226
+
1227
+ if (!isEmpty(oldErrorSchema)) {
1228
+ errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
1229
+ errors = [...oldErrors].concat(errors);
1230
+ }
1231
+
1232
+ return {
1233
+ errorSchema,
1234
+ errors
1235
+ };
1236
+ }
1237
+
1238
+ /** Generates an `IdSchema` object for the `schema`, recursively
1239
+ *
1240
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1241
+ * @param schema - The schema for which the `IdSchema` is desired
1242
+ * @param [id] - The base id for the schema
1243
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1244
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
1245
+ * @param [idPrefix='root'] - The prefix to use for the id
1246
+ * @param [idSeparator='_'] - The separator to use for the path segments in the id
1247
+ * @returns - The `IdSchema` object for the `schema`
1248
+ */
1249
+
1250
+ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix, idSeparator) {
1251
+ if (idPrefix === void 0) {
1252
+ idPrefix = "root";
1253
+ }
1254
+
1255
+ if (idSeparator === void 0) {
1256
+ idSeparator = "_";
1257
+ }
1258
+
1259
+ if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1260
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1261
+
1262
+ return toIdSchema(validator, _schema, id, rootSchema, formData, idPrefix, idSeparator);
1263
+ }
1264
+
1265
+ if (ITEMS_KEY in schema && !get(schema, [ITEMS_KEY, REF_KEY])) {
1266
+ return toIdSchema(validator, get(schema, ITEMS_KEY), id, rootSchema, formData, idPrefix, idSeparator);
1267
+ }
1268
+
1269
+ const $id = id || idPrefix;
1270
+ const idSchema = {
1271
+ $id
1272
+ };
1273
+
1274
+ if (schema.type === "object" && PROPERTIES_KEY in schema) {
1275
+ for (const name in schema.properties) {
1276
+ const field = get(schema, [PROPERTIES_KEY, name]);
1277
+ const fieldId = idSchema[ID_KEY] + idSeparator + name;
1278
+ idSchema[name] = toIdSchema(validator, isObject(field) ? field : {}, fieldId, rootSchema, // It's possible that formData is not an object -- this can happen if an
1279
+ // array item has just been added, but not populated with data yet
1280
+ get(formData, [name]), idPrefix, idSeparator);
1281
+ }
1282
+ }
1283
+
1284
+ return idSchema;
1285
+ }
1286
+
1287
+ /** Generates an `PathSchema` object for the `schema`, recursively
1288
+ *
1289
+ * @param validator - An implementation of the `ValidatorType` interface that will be used when necessary
1290
+ * @param schema - The schema for which the `PathSchema` is desired
1291
+ * @param [name=''] - The base name for the schema
1292
+ * @param [rootSchema] - The root schema, used to primarily to look up `$ref`s
1293
+ * @param [formData] - The current formData, if any, to assist retrieving a schema
1294
+ * @returns - The `PathSchema` object for the `schema`
1295
+ */
1296
+
1297
+ function toPathSchema(validator, schema, name, rootSchema, formData) {
1298
+ if (name === void 0) {
1299
+ name = "";
1300
+ }
1301
+
1302
+ if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
1303
+ const _schema = retrieveSchema(validator, schema, rootSchema, formData);
1304
+
1305
+ return toPathSchema(validator, _schema, name, rootSchema, formData);
1306
+ }
1307
+
1308
+ const pathSchema = {
1309
+ [NAME_KEY]: name.replace(/^\./, "")
1310
+ };
1311
+
1312
+ if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] === true) {
1313
+ set(pathSchema, RJSF_ADDITONAL_PROPERTIES_FLAG, true);
1314
+ }
1315
+
1316
+ if (ITEMS_KEY in schema && Array.isArray(formData)) {
1317
+ formData.forEach((element, i) => {
1318
+ pathSchema[i] = toPathSchema(validator, schema.items, name + "." + i, rootSchema, element);
1319
+ });
1320
+ } else if (PROPERTIES_KEY in schema) {
1321
+ for (const property in schema.properties) {
1322
+ const field = get(schema, [PROPERTIES_KEY, property]);
1323
+ pathSchema[property] = toPathSchema(validator, field, name + "." + property, rootSchema, // It's possible that formData is not an object -- this can happen if an
1324
+ // array item has just been added, but not populated with data yet
1325
+ get(formData, [property]));
1326
+ }
1327
+ }
1328
+
1329
+ return pathSchema;
1330
+ }
1331
+
1332
+ /** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
1333
+ * that one does not have to explicitly pass the `validator` or `rootSchema` to each method. Since both the `validator`
1334
+ * and `rootSchema` generally does not change across a `Form`, this allows for providing a simplified set of APIs to the
1335
+ * `@rjsf/core` components and the various themes as well. This class implements the `SchemaUtilsType` interface.
1336
+ */
1337
+
1338
+ class SchemaUtils {
1339
+ /** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
1340
+ *
1341
+ * @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1342
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
1343
+ */
1344
+ constructor(validator, rootSchema) {
1345
+ this.rootSchema = void 0;
1346
+ this.validator = void 0;
1347
+ this.rootSchema = rootSchema;
1348
+ this.validator = validator;
1349
+ }
1350
+ /** Returns the `ValidatorType` in the `SchemaUtilsType`
1351
+ *
1352
+ * @returns - The `ValidatorType`
1353
+ */
1354
+
1355
+
1356
+ getValidator() {
1357
+ return this.validator;
1358
+ }
1359
+ /** Determines whether either the `validator` and `rootSchema` differ from the ones associated with this instance of
1360
+ * the `SchemaUtilsType`. If either `validator` or `rootSchema` are falsy, then return false to prevent the creation
1361
+ * of a new `SchemaUtilsType` with incomplete properties.
1362
+ *
1363
+ * @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
1364
+ * @param rootSchema - The root schema that will be compared against the current one
1365
+ * @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
1366
+ */
1367
+
1368
+
1369
+ doesSchemaUtilsDiffer(validator, rootSchema) {
1370
+ if (!validator || !rootSchema) {
1371
+ return false;
1372
+ }
1373
+
1374
+ return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema);
1375
+ }
1376
+ /** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
1377
+ * computed to have defaults provided in the `schema`.
1378
+ *
1379
+ * @param schema - The schema for which the default state is desired
1380
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1381
+ * @param [includeUndefinedValues=false] - Optional flag, if true, cause undefined values to be added as defaults
1382
+ * @returns - The resulting `formData` with all the defaults provided
1383
+ */
1384
+
1385
+
1386
+ getDefaultFormState(schema, formData, includeUndefinedValues) {
1387
+ if (includeUndefinedValues === void 0) {
1388
+ includeUndefinedValues = false;
1389
+ }
1390
+
1391
+ return getDefaultFormState(this.validator, schema, formData, this.rootSchema, includeUndefinedValues);
1392
+ }
1393
+ /** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
1394
+ * should be displayed in a UI.
1395
+ *
1396
+ * @param schema - The schema for which the display label flag is desired
1397
+ * @param [uiSchema] - The UI schema from which to derive potentially displayable information
1398
+ * @returns - True if the label should be displayed or false if it should not
1399
+ */
1400
+
1401
+
1402
+ getDisplayLabel(schema, uiSchema) {
1403
+ return getDisplayLabel(this.validator, schema, uiSchema, this.rootSchema);
1404
+ }
1405
+ /** Given the `formData` and list of `options`, attempts to find the index of the option that best matches the data.
1406
+ *
1407
+ * @param formData - The current formData, if any, onto which to provide any missing defaults
1408
+ * @param options - The list of options to find a matching options from
1409
+ * @returns - The index of the matched option or 0 if none is available
1410
+ */
1411
+
1412
+
1413
+ getMatchingOption(formData, options) {
1414
+ return getMatchingOption(this.validator, formData, options, this.rootSchema);
1415
+ }
1416
+ /** Checks to see if the `schema` and `uiSchema` combination represents an array of files
1417
+ *
1418
+ * @param schema - The schema for which check for array of files flag is desired
1419
+ * @param [uiSchema] - The UI schema from which to check the widget
1420
+ * @returns - True if schema/uiSchema contains an array of files, otherwise false
1421
+ */
1422
+
1423
+
1424
+ isFilesArray(schema, uiSchema) {
1425
+ return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
1426
+ }
1427
+ /** Checks to see if the `schema` combination represents a multi-select
1428
+ *
1429
+ * @param schema - The schema for which check for a multi-select flag is desired
1430
+ * @returns - True if schema contains a multi-select, otherwise false
1431
+ */
1432
+
1433
+
1434
+ isMultiSelect(schema) {
1435
+ return isMultiSelect(this.validator, schema, this.rootSchema);
1436
+ }
1437
+ /** Checks to see if the `schema` combination represents a select
1438
+ *
1439
+ * @param schema - The schema for which check for a select flag is desired
1440
+ * @returns - True if schema contains a select, otherwise false
1441
+ */
1442
+
1443
+
1444
+ isSelect(schema) {
1445
+ return isSelect(this.validator, schema, this.rootSchema);
1446
+ }
1447
+ /** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
1448
+ * the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
1449
+ * `getValidator().toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed,
1450
+ * then `validationData` is returned.
1451
+ *
1452
+ * @param validationData - The current `ValidationData` into which to merge the additional errors
1453
+ * @param [additionalErrorSchema] - The additional set of errors
1454
+ * @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
1455
+ */
1456
+
1457
+
1458
+ mergeValidationData(validationData, additionalErrorSchema) {
1459
+ return mergeValidationData(this.validator, validationData, additionalErrorSchema);
1460
+ }
1461
+ /** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
1462
+ * dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
1463
+ * recursive resolution.
1464
+ *
1465
+ * @param schema - The schema for which retrieving a schema is desired
1466
+ * @param [rawFormData] - The current formData, if any, to assist retrieving a schema
1467
+ * @returns - The schema having its conditions, additional properties, references and dependencies resolved
1468
+ */
1469
+
1470
+
1471
+ retrieveSchema(schema, rawFormData) {
1472
+ return retrieveSchema(this.validator, schema, this.rootSchema, rawFormData);
1473
+ }
1474
+ /** Generates an `IdSchema` object for the `schema`, recursively
1475
+ *
1476
+ * @param schema - The schema for which the display label flag is desired
1477
+ * @param [id] - The base id for the schema
1478
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1479
+ * @param [idPrefix='root'] - The prefix to use for the id
1480
+ * @param [idSeparator='_'] - The separator to use for the path segments in the id
1481
+ * @returns - The `IdSchema` object for the `schema`
1482
+ */
1483
+
1484
+
1485
+ toIdSchema(schema, id, formData, idPrefix, idSeparator) {
1486
+ if (idPrefix === void 0) {
1487
+ idPrefix = "root";
1488
+ }
1489
+
1490
+ if (idSeparator === void 0) {
1491
+ idSeparator = "_";
1492
+ }
1493
+
1494
+ return toIdSchema(this.validator, schema, id, this.rootSchema, formData, idPrefix, idSeparator);
1495
+ }
1496
+ /** Generates an `PathSchema` object for the `schema`, recursively
1497
+ *
1498
+ * @param schema - The schema for which the display label flag is desired
1499
+ * @param [name] - The base name for the schema
1500
+ * @param [formData] - The current formData, if any, onto which to provide any missing defaults
1501
+ * @returns - The `PathSchema` object for the `schema`
1502
+ */
1503
+
1504
+
1505
+ toPathSchema(schema, name, formData) {
1506
+ return toPathSchema(this.validator, schema, name, this.rootSchema, formData);
1507
+ }
1508
+
1509
+ }
1510
+ /** Creates a `SchemaUtilsType` interface that is based around the given `validator` and `rootSchema` parameters. The
1511
+ * resulting interface implementation will forward the `validator` and `rootSchema` to all the wrapped APIs.
1512
+ *
1513
+ * @param validator - an implementation of the `ValidatorType` interface that will be forwarded to all the APIs
1514
+ * @param rootSchema - The root schema that will be forwarded to all the APIs
1515
+ * @returns - An implementation of a `SchemaUtilsType` interface
1516
+ */
1517
+
1518
+
1519
+ function createSchemaUtils(validator, rootSchema) {
1520
+ return new SchemaUtils(validator, rootSchema);
1521
+ }
1522
+
1523
+ /** Given the `FileReader.readAsDataURL()` based `dataURI` extracts that data into an actual Blob along with the name
1524
+ * of that Blob if provided in the URL. If no name is provided, then the name falls back to `unknown`.
1525
+ *
1526
+ * @param dataURI - The `DataUrl` potentially containing name and raw data to be converted to a Blob
1527
+ * @returns - an object containing a Blob and its name, extracted from the URI
1528
+ */
1529
+ function dataURItoBlob(dataURI) {
1530
+ // Split metadata from data
1531
+ const splitted = dataURI.split(","); // Split params
1532
+
1533
+ const params = splitted[0].split(";"); // Get mime-type from params
1534
+
1535
+ const type = params[0].replace("data:", ""); // Filter the name property from params
1536
+
1537
+ const properties = params.filter(param => {
1538
+ return param.split("=")[0] === "name";
1539
+ }); // Look for the name and use unknown if no name property.
1540
+
1541
+ let name;
1542
+
1543
+ if (properties.length !== 1) {
1544
+ name = "unknown";
1545
+ } else {
1546
+ // Because we filtered out the other property,
1547
+ // we only have the name case here.
1548
+ name = properties[0].split("=")[1];
1549
+ } // Built the Uint8Array Blob parameter from the base64 string.
1550
+
1551
+
1552
+ const binary = atob(splitted[1]);
1553
+ const array = [];
1554
+
1555
+ for (let i = 0; i < binary.length; i++) {
1556
+ array.push(binary.charCodeAt(i));
1557
+ } // Create the blob object
1558
+
1559
+
1560
+ const blob = new window.Blob([new Uint8Array(array)], {
1561
+ type
1562
+ });
1563
+ return {
1564
+ blob,
1565
+ name
1566
+ };
1567
+ }
1568
+
1569
+ /** Extracts the range spec information `{ step?: number, min?: number, max?: number }` that can be spread onto an HTML
1570
+ * input from the range analog in the schema `{ multipleOf?: number, minimum?: number, maximum?: number }`.
1571
+ *
1572
+ * @param schema - The schema from which to extract the range spec
1573
+ * @returns - A range specification from the schema
1574
+ */
1575
+ function rangeSpec(schema) {
1576
+ const spec = {};
1577
+
1578
+ if (schema.multipleOf) {
1579
+ spec.step = schema.multipleOf;
1580
+ }
1581
+
1582
+ if (schema.minimum || schema.minimum === 0) {
1583
+ spec.min = schema.minimum;
1584
+ }
1585
+
1586
+ if (schema.maximum || schema.maximum === 0) {
1587
+ spec.max = schema.maximum;
1588
+ }
1589
+
1590
+ return spec;
1591
+ }
1592
+
1593
+ /** Using the `schema`, `defaultType` and `options`, extract out the props for the <input> element that make sense.
1594
+ *
1595
+ * @param schema - The schema for the field provided by the widget
1596
+ * @param [defaultType] - The default type, if any, for the field provided by the widget
1597
+ * @param [options={}] - The UI Options for the field provided by the widget
1598
+ * @param [autoDefaultStepAny=true] - Determines whether to auto-default step=any when the type is number and no step
1599
+ * @returns - The extracted `InputPropsType` object
1600
+ */
1601
+
1602
+ function getInputProps(schema, defaultType, options, autoDefaultStepAny) {
1603
+ if (options === void 0) {
1604
+ options = {};
1605
+ }
1606
+
1607
+ if (autoDefaultStepAny === void 0) {
1608
+ autoDefaultStepAny = true;
1609
+ }
1610
+
1611
+ const inputProps = {
1612
+ type: defaultType || "text",
1613
+ ...rangeSpec(schema)
1614
+ }; // If options.inputType is set use that as the input type
1615
+
1616
+ if (options.inputType) {
1617
+ inputProps.type = options.inputType;
1618
+ } else if (!defaultType) {
1619
+ // If the schema is of type number or integer, set the input type to number
1620
+ if (schema.type === "number") {
1621
+ inputProps.type = "number"; // Only add step if one isn't already defined and we are auto-defaulting the "any" step
1622
+
1623
+ if (autoDefaultStepAny && inputProps.step === undefined) {
1624
+ // Setting step to 'any' fixes a bug in Safari where decimals are not
1625
+ // allowed in number inputs
1626
+ inputProps.step = "any";
1627
+ }
1628
+ } else if (schema.type === "integer") {
1629
+ inputProps.type = "number"; // Only add step if one isn't already defined
1630
+
1631
+ if (inputProps.step === undefined) {
1632
+ // Since this is integer, you always want to step up or down in multiples of 1
1633
+ inputProps.step = 1;
1634
+ }
1635
+ }
1636
+ }
1637
+
1638
+ if (options.autocomplete) {
1639
+ inputProps.autoComplete = options.autocomplete;
1640
+ }
1641
+
1642
+ return inputProps;
1643
+ }
1644
+
1645
+ /** The default submit button options, exported for testing purposes
1646
+ */
1647
+
1648
+ const DEFAULT_OPTIONS = {
1649
+ props: {
1650
+ disabled: false
1651
+ },
1652
+ submitText: "Submit",
1653
+ norender: false
1654
+ };
1655
+ /** Extracts any `ui:submitButtonOptions` from the `uiSchema` and merges them onto the `DEFAULT_OPTIONS`
1656
+ *
1657
+ * @param [uiSchema={}] - the UI Schema from which to extract submit button props
1658
+ * @returns - The merging of the `DEFAULT_OPTIONS` with any custom ones
1659
+ */
1660
+
1661
+ function getSubmitButtonOptions(uiSchema) {
1662
+ if (uiSchema === void 0) {
1663
+ uiSchema = {};
1664
+ }
1665
+
1666
+ const uiOptions = getUiOptions(uiSchema);
1667
+
1668
+ if (uiOptions && uiOptions[SUBMIT_BTN_OPTIONS_KEY]) {
1669
+ const options = uiOptions[SUBMIT_BTN_OPTIONS_KEY];
1670
+ return { ...DEFAULT_OPTIONS,
1671
+ ...options
1672
+ };
1673
+ }
1674
+
1675
+ return DEFAULT_OPTIONS;
1676
+ }
1677
+
1678
+ /** Returns the template with the given `name` from either the `uiSchema` if it is defined or from the `registry`
1679
+ * otherwise. NOTE, since `ButtonTemplates` are not overridden in `uiSchema` only those in the `registry` are returned.
1680
+ *
1681
+ * @param name - The name of the template to fetch, restricted to the keys of `TemplatesType`
1682
+ * @param registry - The `Registry` from which to read the template
1683
+ * @param [uiOptions={}] - The `UIOptionsType` from which to read an alternate template
1684
+ * @returns - The template from either the `uiSchema` or `registry` for the `name`
1685
+ */
1686
+ function getTemplate(name, registry, uiOptions) {
1687
+ if (uiOptions === void 0) {
1688
+ uiOptions = {};
1689
+ }
1690
+
1691
+ const {
1692
+ templates
1693
+ } = registry;
1694
+
1695
+ if (name === "ButtonTemplates") {
1696
+ return templates[name];
1697
+ }
1698
+
1699
+ return uiOptions[name] || templates[name];
1700
+ }
1701
+
1702
+ /** The map of schema types to widget type to widget name
1703
+ */
1704
+
1705
+ const widgetMap = {
1706
+ boolean: {
1707
+ checkbox: "CheckboxWidget",
1708
+ radio: "RadioWidget",
1709
+ select: "SelectWidget",
1710
+ hidden: "HiddenWidget"
1711
+ },
1712
+ string: {
1713
+ text: "TextWidget",
1714
+ password: "PasswordWidget",
1715
+ email: "EmailWidget",
1716
+ hostname: "TextWidget",
1717
+ ipv4: "TextWidget",
1718
+ ipv6: "TextWidget",
1719
+ uri: "URLWidget",
1720
+ "data-url": "FileWidget",
1721
+ radio: "RadioWidget",
1722
+ select: "SelectWidget",
1723
+ textarea: "TextareaWidget",
1724
+ hidden: "HiddenWidget",
1725
+ date: "DateWidget",
1726
+ datetime: "DateTimeWidget",
1727
+ "date-time": "DateTimeWidget",
1728
+ "alt-date": "AltDateWidget",
1729
+ "alt-datetime": "AltDateTimeWidget",
1730
+ color: "ColorWidget",
1731
+ file: "FileWidget"
1732
+ },
1733
+ number: {
1734
+ text: "TextWidget",
1735
+ select: "SelectWidget",
1736
+ updown: "UpDownWidget",
1737
+ range: "RangeWidget",
1738
+ radio: "RadioWidget",
1739
+ hidden: "HiddenWidget"
1740
+ },
1741
+ integer: {
1742
+ text: "TextWidget",
1743
+ select: "SelectWidget",
1744
+ updown: "UpDownWidget",
1745
+ range: "RangeWidget",
1746
+ radio: "RadioWidget",
1747
+ hidden: "HiddenWidget"
1748
+ },
1749
+ array: {
1750
+ select: "SelectWidget",
1751
+ checkboxes: "CheckboxesWidget",
1752
+ files: "FileWidget",
1753
+ hidden: "HiddenWidget"
1754
+ }
1755
+ };
1756
+ /** Wraps the given widget with stateless functional component that will merge any `defaultProps.options` with the
1757
+ * `options` that are provided in the props. It will add the wrapper component as a `MergedWidget` property onto the
1758
+ * `Widget` so that future attempts to wrap `AWidget` will return the already existing wrapper.
1759
+ *
1760
+ * @param AWidget - A widget that will be wrapped or one that is already wrapped
1761
+ * @returns - The wrapper widget
1762
+ */
1763
+
1764
+ function mergeWidgetOptions(AWidget) {
1765
+ let MergedWidget = get(AWidget, "MergedWidget"); // cache return value as property of widget for proper react reconciliation
1766
+
1767
+ if (!MergedWidget) {
1768
+ const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
1769
+
1770
+ MergedWidget = _ref => {
1771
+ let {
1772
+ options,
1773
+ ...props
1774
+ } = _ref;
1775
+ return /*#__PURE__*/React.createElement(AWidget, {
1776
+ options: { ...defaultOptions,
1777
+ ...options
1778
+ },
1779
+ ...props
1780
+ });
1781
+ };
1782
+
1783
+ set(AWidget, "MergedWidget", MergedWidget);
1784
+ }
1785
+
1786
+ return MergedWidget;
1787
+ }
1788
+ /** Given a schema representing a field to render and either the name or actual `Widget` implementation, returns the
1789
+ * React component that is used to render the widget. If the `widget` is already a React component, then it is wrapped
1790
+ * with a `MergedWidget`. Otherwise an attempt is made to look up the widget inside of the `registeredWidgets` map based
1791
+ * on the schema type and `widget` name. If no widget component can be found an `Error` is thrown.
1792
+ *
1793
+ * @param schema - The schema for the field
1794
+ * @param [widget] - Either the name of the widget OR a `Widget` implementation to use
1795
+ * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
1796
+ * @returns - The `Widget` component to use
1797
+ * @throws - An error if there is no `Widget` component that can be returned
1798
+ */
1799
+
1800
+
1801
+ function getWidget(schema, widget, registeredWidgets) {
1802
+ if (registeredWidgets === void 0) {
1803
+ registeredWidgets = {};
1804
+ }
1805
+
1806
+ const type = getSchemaType(schema);
1807
+
1808
+ if (typeof widget === "function" || widget && ReactIs.isForwardRef( /*#__PURE__*/React.createElement(widget)) || ReactIs.isMemo(widget)) {
1809
+ return mergeWidgetOptions(widget);
1810
+ }
1811
+
1812
+ if (typeof widget !== "string") {
1813
+ throw new Error("Unsupported widget definition: " + typeof widget);
1814
+ }
1815
+
1816
+ if (widget in registeredWidgets) {
1817
+ const registeredWidget = registeredWidgets[widget];
1818
+ return getWidget(schema, registeredWidget, registeredWidgets);
1819
+ }
1820
+
1821
+ if (typeof type === "string") {
1822
+ if (!(type in widgetMap)) {
1823
+ throw new Error("No widget for type '" + type + "'");
1824
+ }
1825
+
1826
+ if (widget in widgetMap[type]) {
1827
+ const registeredWidget = registeredWidgets[widgetMap[type][widget]];
1828
+ return getWidget(schema, registeredWidget, registeredWidgets);
1829
+ }
1830
+ }
1831
+
1832
+ throw new Error("No widget '" + widget + "' for type '" + type + "'");
1833
+ }
1834
+
1835
+ /** Detects whether the `widget` exists for the `schema` with the associated `registryWidgets` and returns true if it
1836
+ * does, or false if it doesn't.
1837
+ *
1838
+ * @param schema - The schema for the field
1839
+ * @param widget - Either the name of the widget OR a `Widget` implementation to use
1840
+ * @param [registeredWidgets={}] - A registry of widget name to `Widget` implementation
1841
+ * @returns - True if the widget exists, false otherwise
1842
+ */
1843
+
1844
+ function hasWidget(schema, widget, registeredWidgets) {
1845
+ if (registeredWidgets === void 0) {
1846
+ registeredWidgets = {};
1847
+ }
1848
+
1849
+ try {
1850
+ getWidget(schema, widget, registeredWidgets);
1851
+ return true;
1852
+ } catch (e) {
1853
+ const err = e;
1854
+
1855
+ if (err.message && (err.message.startsWith("No widget") || err.message.startsWith("Unsupported widget"))) {
1856
+ return false;
1857
+ }
1858
+
1859
+ throw e;
1860
+ }
1861
+ }
1862
+
1863
+ /** Converts a local Date string into a UTC date string
1864
+ *
1865
+ * @param dateString - The string representation of a date as accepted by the `Date()` constructor
1866
+ * @returns - A UTC date string if `dateString` is truthy, otherwise undefined
1867
+ */
1868
+ function localToUTC(dateString) {
1869
+ return dateString ? new Date(dateString).toJSON() : undefined;
1870
+ }
1871
+
1872
+ /** Returns the constant value from the schema when it is either a single value enum or has a const key. Otherwise
1873
+ * throws an error.
1874
+ *
1875
+ * @param schema - The schema from which to obtain the constant value
1876
+ * @returns - The constant value for the schema
1877
+ * @throws - Error when the schema does not have a constant value
1878
+ */
1879
+
1880
+ function toConstant(schema) {
1881
+ if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
1882
+ return schema.enum[0];
1883
+ }
1884
+
1885
+ if (CONST_KEY in schema) {
1886
+ return schema.const;
1887
+ }
1888
+
1889
+ throw new Error("schema cannot be inferred as a constant");
1890
+ }
1891
+
1892
+ /** Gets the list of options from the schema. If the schema has an enum list, then those enum values are returned. The
1893
+ * labels for the options will be extracted from the non-standard, RJSF-deprecated `enumNames` if it exists, otherwise
1894
+ * the label will be the same as the `value`. If the schema has a `oneOf` or `anyOf`, then the value is the list of
1895
+ * `const` values from the schema and the label is either the `schema.title` or the value.
1896
+ *
1897
+ * @param schema - The schema from which to extract the options list
1898
+ * @returns - The list of options from the schema
1899
+ */
1900
+
1901
+ function optionsList(schema) {
1902
+ // enumNames was deprecated in v5 and is intentionally omitted from the RJSFSchema type.
1903
+ // Cast the type to include enumNames so the feature still works.
1904
+ const schemaWithEnumNames = schema;
1905
+
1906
+ if (schemaWithEnumNames.enumNames && process.env.NODE_ENV !== "production") {
1907
+ console.warn("The enumNames property is deprecated and may be removed in a future major release.");
1908
+ }
1909
+
1910
+ if (schema.enum) {
1911
+ return schema.enum.map((value, i) => {
1912
+ const label = schemaWithEnumNames.enumNames && schemaWithEnumNames.enumNames[i] || String(value);
1913
+ return {
1914
+ label,
1915
+ value
1916
+ };
1917
+ });
1918
+ }
1919
+
1920
+ const altSchemas = schema.oneOf || schema.anyOf;
1921
+ return altSchemas && altSchemas.map(aSchemaDef => {
1922
+ const aSchema = aSchemaDef;
1923
+ const value = toConstant(aSchema);
1924
+ const label = aSchema.title || String(value);
1925
+ return {
1926
+ schema: aSchema,
1927
+ label,
1928
+ value
1929
+ };
1930
+ });
1931
+ }
1932
+
1933
+ /** Given a list of `properties` and an `order` list, returns a list that contains the `properties` ordered correctly.
1934
+ * If `order` is not an array, then the untouched `properties` list is returned. Otherwise `properties` is ordered per
1935
+ * the `order` list. If `order` contains a '*' then any `properties` that are not mentioned explicity in `order` will be
1936
+ * places in the location of the `*`.
1937
+ *
1938
+ * @param properties - The list of property keys to be ordered
1939
+ * @param order - An array of property keys to be ordered first, with an optional '*' property
1940
+ * @returns - A list with the `properties` ordered
1941
+ * @throws - Error when the properties cannot be ordered correctly
1942
+ */
1943
+ function orderProperties(properties, order) {
1944
+ if (!Array.isArray(order)) {
1945
+ return properties;
1946
+ }
1947
+
1948
+ const arrayToHash = arr => arr.reduce((prev, curr) => {
1949
+ prev[curr] = true;
1950
+ return prev;
1951
+ }, {});
1952
+
1953
+ const errorPropList = arr => arr.length > 1 ? "properties '" + arr.join("', '") + "'" : "property '" + arr[0] + "'";
1954
+
1955
+ const propertyHash = arrayToHash(properties);
1956
+ const orderFiltered = order.filter(prop => prop === "*" || propertyHash[prop]);
1957
+ const orderHash = arrayToHash(orderFiltered);
1958
+ const rest = properties.filter(prop => !orderHash[prop]);
1959
+ const restIndex = orderFiltered.indexOf("*");
1960
+
1961
+ if (restIndex === -1) {
1962
+ if (rest.length) {
1963
+ throw new Error("uiSchema order list does not contain " + errorPropList(rest));
1964
+ }
1965
+
1966
+ return orderFiltered;
1967
+ }
1968
+
1969
+ if (restIndex !== orderFiltered.lastIndexOf("*")) {
1970
+ throw new Error("uiSchema order list contains more than one wildcard item");
1971
+ }
1972
+
1973
+ const complete = [...orderFiltered];
1974
+ complete.splice(restIndex, 1, ...rest);
1975
+ return complete;
1976
+ }
1977
+
1978
+ /** Returns a string representation of the `num` that is padded with leading "0"s if necessary
1979
+ *
1980
+ * @param num - The number to pad
1981
+ * @param width - The width of the string at which no lead padding is necessary
1982
+ * @returns - The number converted to a string with leading zero padding if the number of digits is less than `width`
1983
+ */
1984
+ function pad(num, width) {
1985
+ let s = String(num);
1986
+
1987
+ while (s.length < width) {
1988
+ s = "0" + s;
1989
+ }
1990
+
1991
+ return s;
1992
+ }
1993
+
1994
+ /** Parses the `dateString` into a `DateObject`, including the time information when `includeTime` is true
1995
+ *
1996
+ * @param dateString - The date string to parse into a DateObject
1997
+ * @param [includeTime=true] - Optional flag, if false, will not include the time data into the object
1998
+ * @returns - The date string converted to a `DateObject`
1999
+ * @throws - Error when the date cannot be parsed from the string
2000
+ */
2001
+ function parseDateString(dateString, includeTime) {
2002
+ if (includeTime === void 0) {
2003
+ includeTime = true;
2004
+ }
2005
+
2006
+ if (!dateString) {
2007
+ return {
2008
+ year: -1,
2009
+ month: -1,
2010
+ day: -1,
2011
+ hour: includeTime ? -1 : 0,
2012
+ minute: includeTime ? -1 : 0,
2013
+ second: includeTime ? -1 : 0
2014
+ };
2015
+ }
2016
+
2017
+ const date = new Date(dateString);
2018
+
2019
+ if (Number.isNaN(date.getTime())) {
2020
+ throw new Error("Unable to parse date " + dateString);
2021
+ }
2022
+
2023
+ return {
2024
+ year: date.getUTCFullYear(),
2025
+ month: date.getUTCMonth() + 1,
2026
+ day: date.getUTCDate(),
2027
+ hour: includeTime ? date.getUTCHours() : 0,
2028
+ minute: includeTime ? date.getUTCMinutes() : 0,
2029
+ second: includeTime ? date.getUTCSeconds() : 0
2030
+ };
2031
+ }
2032
+
2033
+ const nums = /*#__PURE__*/new Set(["number", "integer"]);
2034
+ /** Returns the real value for a select widget due to a silly limitation in the DOM which causes option change event
2035
+ * values to always be retrieved as strings. Uses the `schema` to help determine the value's true type. If the value is
2036
+ * an empty string, then the `emptyValue` from the `options` is returned, falling back to undefined.
2037
+ *
2038
+ * @param schema - The schema to used to determine the value's true type
2039
+ * @param [value] - The value to convert
2040
+ * @param [options] - The UIOptionsType from which to potentially extract the emptyValue
2041
+ * @returns - The `value` converted to the proper type
2042
+ */
2043
+
2044
+ function processSelectValue(schema, value, options) {
2045
+ const {
2046
+ enum: schemaEnum,
2047
+ type,
2048
+ items
2049
+ } = schema;
2050
+
2051
+ if (value === "") {
2052
+ return options && options.emptyValue !== undefined ? options.emptyValue : undefined;
2053
+ }
2054
+
2055
+ if (type === "array" && items && nums.has(get(items, "type"))) {
2056
+ return value.map(asNumber);
2057
+ }
2058
+
2059
+ if (type === "boolean") {
2060
+ return value === "true";
2061
+ }
2062
+
2063
+ if (nums.has(type)) {
2064
+ return asNumber(value);
2065
+ } // If type is undefined, but an enum is present, try and infer the type from
2066
+ // the enum values
2067
+
2068
+
2069
+ if (Array.isArray(schemaEnum)) {
2070
+ if (schemaEnum.every(x => nums.has(guessType(x)))) {
2071
+ return asNumber(value);
2072
+ }
2073
+
2074
+ if (schemaEnum.every(x => guessType(x) === "boolean")) {
2075
+ return value === "true";
2076
+ }
2077
+ }
2078
+
2079
+ return value;
2080
+ }
2081
+
2082
+ /** Check to see if a `schema` specifies that a value must be true. This happens when:
2083
+ * - `schema.const` is truthy
2084
+ * - `schema.enum` == `[true]`
2085
+ * - `schema.anyOf` or `schema.oneOf` has a single value which recursively returns true
2086
+ * - `schema.allOf` has at least one value which recursively returns true
2087
+ *
2088
+ * @param schema - The schema to check
2089
+ * @returns - True if the schema specifies a value that must be true, false otherwise
2090
+ */
2091
+ function schemaRequiresTrueValue(schema) {
2092
+ // Check if const is a truthy value
2093
+ if (schema.const) {
2094
+ return true;
2095
+ } // Check if an enum has a single value of true
2096
+
2097
+
2098
+ if (schema.enum && schema.enum.length === 1 && schema.enum[0] === true) {
2099
+ return true;
2100
+ } // If anyOf has a single value, evaluate the subschema
2101
+
2102
+
2103
+ if (schema.anyOf && schema.anyOf.length === 1) {
2104
+ return schemaRequiresTrueValue(schema.anyOf[0]);
2105
+ } // If oneOf has a single value, evaluate the subschema
2106
+
2107
+
2108
+ if (schema.oneOf && schema.oneOf.length === 1) {
2109
+ return schemaRequiresTrueValue(schema.oneOf[0]);
2110
+ } // Evaluate each subschema in allOf, to see if one of them requires a true value
2111
+
2112
+
2113
+ if (schema.allOf) {
2114
+ const schemaSome = subSchema => schemaRequiresTrueValue(subSchema);
2115
+
2116
+ return schema.allOf.some(schemaSome);
2117
+ }
2118
+
2119
+ return false;
2120
+ }
2121
+
2122
+ /** Determines whether the given `component` should be rerendered by comparing its current set of props and state
2123
+ * against the next set. If either of those two sets are not the same, then the component should be rerendered.
2124
+ *
2125
+ * @param component - A React component being checked
2126
+ * @param nextProps - The next set of props against which to check
2127
+ * @param nextState - The next set of state against which to check
2128
+ * @returns - True if the component should be re-rendered, false otherwise
2129
+ */
2130
+
2131
+ function shouldRender(component, nextProps, nextState) {
2132
+ const {
2133
+ props,
2134
+ state
2135
+ } = component;
2136
+ return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
2137
+ }
2138
+
2139
+ /** Returns a UTC date string for the given `dateObject`. If `time` is false, then the time portion of the string is
2140
+ * removed.
2141
+ *
2142
+ * @param dateObject - The `DateObject` to convert to a date string
2143
+ * @param [time=true] - Optional flag used to remove the time portion of the date string if false
2144
+ * @returns - The UTC date string
2145
+ */
2146
+ function toDateString(dateObject, time) {
2147
+ if (time === void 0) {
2148
+ time = true;
2149
+ }
2150
+
2151
+ const {
2152
+ year,
2153
+ month,
2154
+ day,
2155
+ hour = 0,
2156
+ minute = 0,
2157
+ second = 0
2158
+ } = dateObject;
2159
+ const utcTime = Date.UTC(year, month - 1, day, hour, minute, second);
2160
+ const datetime = new Date(utcTime).toJSON();
2161
+ return time ? datetime : datetime.slice(0, 10);
2162
+ }
2163
+
2164
+ /** Converts a UTC date string into a local Date format
2165
+ *
2166
+ * @param jsonDate - A UTC date string
2167
+ * @returns - An empty string when `jsonDate` is falsey, otherwise a date string in local format
2168
+ */
2169
+
2170
+ function utcToLocal(jsonDate) {
2171
+ if (!jsonDate) {
2172
+ return "";
2173
+ } // required format of `'yyyy-MM-ddThh:mm' followed by optional ':ss' or ':ss.SSS'
2174
+ // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type%3Ddatetime-local)
2175
+ // > should be a _valid local date and time string_ (not GMT)
2176
+ // Note - date constructor passed local ISO-8601 does not correctly
2177
+ // change time to UTC in node pre-8
2178
+
2179
+
2180
+ const date = new Date(jsonDate);
2181
+ const yyyy = pad(date.getFullYear(), 4);
2182
+ const MM = pad(date.getMonth() + 1, 2);
2183
+ const dd = pad(date.getDate(), 2);
2184
+ const hh = pad(date.getHours(), 2);
2185
+ const mm = pad(date.getMinutes(), 2);
2186
+ const ss = pad(date.getSeconds(), 2);
2187
+ const SSS = pad(date.getMilliseconds(), 3);
2188
+ return yyyy + "-" + MM + "-" + dd + "T" + hh + ":" + mm + ":" + ss + "." + SSS;
2189
+ }
2190
+
2191
+ 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, 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, asNumber, canExpand, createSchemaUtils, dataURItoBlob, deepEquals, findSchemaDefinition, getDefaultFormState, getDisplayLabel, getInputProps, getMatchingOption, getSchemaType, getSubmitButtonOptions, getTemplate, getUiOptions, getWidget, guessType, hasWidget, isConstant, isCustomWidget, isFilesArray, isFixedItems, isMultiSelect, isObject, isSelect, localToUTC, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, mergeValidationData, optionsList, orderProperties, pad, parseDateString, processSelectValue, rangeSpec, retrieveSchema, schemaRequiresTrueValue, shouldRender, toConstant, toDateString, toIdSchema, toPathSchema, utcToLocal };
2192
+ //# sourceMappingURL=utils.esm.js.map