@rjsf/utils 6.0.0-alpha.0 → 6.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.
- package/dist/index.js +1281 -625
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +1254 -598
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +1201 -570
- package/lib/ErrorSchemaBuilder.d.ts +8 -4
- package/lib/ErrorSchemaBuilder.js +10 -8
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/allowAdditionalItems.d.ts +1 -1
- package/lib/allowAdditionalItems.js +1 -1
- package/lib/allowAdditionalItems.js.map +1 -1
- package/lib/asNumber.js.map +1 -1
- package/lib/canExpand.d.ts +1 -1
- package/lib/canExpand.js +2 -2
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.d.ts +9 -0
- package/lib/constIsAjvDataReference.js +15 -0
- package/lib/constIsAjvDataReference.js.map +1 -0
- package/lib/constants.d.ts +11 -3
- package/lib/constants.js +11 -3
- package/lib/constants.js.map +1 -1
- package/lib/createErrorHandler.d.ts +1 -1
- package/lib/createErrorHandler.js +2 -2
- package/lib/createErrorHandler.js.map +1 -1
- package/lib/createSchemaUtils.d.ts +3 -2
- package/lib/createSchemaUtils.js +56 -46
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/dataURItoBlob.js.map +1 -1
- package/lib/dateRangeOptions.d.ts +1 -1
- package/lib/dateRangeOptions.js +1 -1
- package/lib/dateRangeOptions.js.map +1 -1
- package/lib/deepEquals.js +1 -1
- package/lib/deepEquals.js.map +1 -1
- package/lib/englishStringTranslator.d.ts +1 -1
- package/lib/englishStringTranslator.js +1 -1
- package/lib/enumOptionsDeselectValue.d.ts +1 -1
- package/lib/enumOptionsDeselectValue.js +4 -4
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.d.ts +1 -1
- package/lib/enumOptionsIndexForValue.js +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.d.ts +1 -1
- package/lib/enumOptionsIsSelected.js +3 -3
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.d.ts +1 -1
- package/lib/enumOptionsSelectValue.js +2 -2
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.d.ts +1 -1
- package/lib/enumOptionsValueForIndex.js.map +1 -1
- package/lib/enums.d.ts +2 -0
- package/lib/enums.js +2 -0
- package/lib/enums.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +1 -1
- package/lib/findSchemaDefinition.js +2 -2
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.d.ts +17 -0
- package/lib/getChangedFields.js +42 -0
- package/lib/getChangedFields.js.map +1 -0
- package/lib/getDateElementProps.d.ts +1 -1
- package/lib/getDateElementProps.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.d.ts +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js +4 -3
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getInputProps.d.ts +1 -1
- package/lib/getInputProps.js +4 -1
- package/lib/getInputProps.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.d.ts +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js +2 -2
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getSchemaType.d.ts +2 -1
- package/lib/getSchemaType.js +3 -2
- package/lib/getSchemaType.js.map +1 -1
- package/lib/getSubmitButtonOptions.d.ts +1 -1
- package/lib/getSubmitButtonOptions.js +2 -2
- package/lib/getSubmitButtonOptions.js.map +1 -1
- package/lib/getTemplate.d.ts +1 -1
- package/lib/getTemplate.js +9 -0
- package/lib/getTemplate.js.map +1 -1
- package/lib/getTestIds.d.ts +17 -0
- package/lib/getTestIds.js +34 -0
- package/lib/getTestIds.js.map +1 -0
- package/lib/getUiOptions.d.ts +1 -1
- package/lib/getUiOptions.js +2 -2
- package/lib/getUiOptions.js.map +1 -1
- package/lib/getWidget.d.ts +1 -1
- package/lib/getWidget.js +3 -3
- package/lib/getWidget.js.map +1 -1
- package/lib/guessType.d.ts +1 -1
- package/lib/guessType.js.map +1 -1
- package/lib/hasWidget.d.ts +1 -1
- package/lib/hasWidget.js +1 -1
- package/lib/hasWidget.js.map +1 -1
- package/lib/hashForSchema.d.ts +23 -1
- package/lib/hashForSchema.js +24 -6
- package/lib/hashForSchema.js.map +1 -1
- package/lib/idGenerators.d.ts +8 -1
- package/lib/idGenerators.js +11 -2
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +63 -60
- package/lib/index.js +63 -60
- package/lib/index.js.map +1 -1
- package/lib/isConstant.d.ts +1 -1
- package/lib/isConstant.js +1 -1
- package/lib/isCustomWidget.d.ts +1 -1
- package/lib/isCustomWidget.js +1 -1
- package/lib/isFixedItems.d.ts +1 -1
- package/lib/isFixedItems.js +1 -1
- package/lib/isObject.d.ts +2 -2
- package/lib/isObject.js +11 -4
- package/lib/isObject.js.map +1 -1
- package/lib/lookupFromFormContext.d.ts +11 -0
- package/lib/lookupFromFormContext.js +20 -0
- package/lib/lookupFromFormContext.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.d.ts +8 -2
- package/lib/mergeDefaultsWithFormData.js +39 -10
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/mergeObjects.d.ts +1 -1
- package/lib/mergeObjects.js +1 -1
- package/lib/mergeObjects.js.map +1 -1
- package/lib/mergeSchemas.d.ts +1 -1
- package/lib/mergeSchemas.js +4 -4
- package/lib/mergeSchemas.js.map +1 -1
- package/lib/optionsList.d.ts +9 -7
- package/lib/optionsList.js +30 -19
- package/lib/optionsList.js.map +1 -1
- package/lib/orderProperties.js.map +1 -1
- package/lib/pad.js.map +1 -1
- package/lib/parseDateString.d.ts +1 -1
- package/lib/parseDateString.js +1 -1
- package/lib/parseDateString.js.map +1 -1
- package/lib/parser/ParserValidator.d.ts +1 -1
- package/lib/parser/ParserValidator.js +6 -6
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +2 -2
- package/lib/parser/index.js +1 -1
- package/lib/parser/schemaParser.d.ts +2 -2
- package/lib/parser/schemaParser.js +6 -6
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/rangeSpec.d.ts +2 -2
- package/lib/rangeSpec.js.map +1 -1
- package/lib/replaceStringParameters.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +19 -0
- package/lib/schema/findFieldInSchema.js +61 -0
- package/lib/schema/findFieldInSchema.js.map +1 -0
- package/lib/schema/findSelectedOptionInXxxOf.d.ts +16 -0
- package/lib/schema/findSelectedOptionInXxxOf.js +34 -0
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -0
- package/lib/schema/getClosestMatchingOption.d.ts +5 -3
- package/lib/schema/getClosestMatchingOption.js +28 -20
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +60 -13
- package/lib/schema/getDefaultFormState.js +304 -166
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getDisplayLabel.d.ts +3 -2
- package/lib/schema/getDisplayLabel.js +10 -9
- package/lib/schema/getDisplayLabel.js.map +1 -1
- package/lib/schema/getFirstMatchingOption.d.ts +1 -1
- package/lib/schema/getFirstMatchingOption.js +70 -2
- package/lib/schema/getFirstMatchingOption.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +14 -0
- package/lib/schema/getFromSchema.js +39 -0
- package/lib/schema/getFromSchema.js.map +1 -0
- package/lib/schema/index.d.ts +15 -14
- package/lib/schema/index.js +15 -14
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isFilesArray.d.ts +3 -2
- package/lib/schema/isFilesArray.js +5 -4
- package/lib/schema/isFilesArray.js.map +1 -1
- package/lib/schema/isMultiSelect.d.ts +3 -2
- package/lib/schema/isMultiSelect.js +4 -3
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/isSelect.d.ts +3 -2
- package/lib/schema/isSelect.js +5 -4
- package/lib/schema/isSelect.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +28 -11
- package/lib/schema/retrieveSchema.js +142 -66
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.d.ts +3 -2
- package/lib/schema/sanitizeDataForNewSchema.js +12 -11
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/toIdSchema.d.ts +3 -2
- package/lib/schema/toIdSchema.js +30 -27
- package/lib/schema/toIdSchema.js.map +1 -1
- package/lib/schema/toPathSchema.d.ts +3 -2
- package/lib/schema/toPathSchema.js +22 -20
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/schemaRequiresTrueValue.d.ts +1 -1
- package/lib/schemaRequiresTrueValue.js.map +1 -1
- package/lib/shouldRender.js +1 -1
- package/lib/toConstant.d.ts +1 -1
- package/lib/toConstant.js +1 -1
- package/lib/toConstant.js.map +1 -1
- package/lib/toDateString.d.ts +1 -1
- package/lib/toErrorList.d.ts +1 -1
- package/lib/toErrorList.js +2 -2
- package/lib/toErrorList.js.map +1 -1
- package/lib/toErrorSchema.d.ts +1 -1
- package/lib/toErrorSchema.js +2 -2
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +160 -131
- package/lib/unwrapErrorHandler.d.ts +1 -1
- package/lib/unwrapErrorHandler.js +1 -1
- package/lib/unwrapErrorHandler.js.map +1 -1
- package/lib/utcToLocal.js +1 -1
- package/lib/utcToLocal.js.map +1 -1
- package/lib/validationDataMerge.d.ts +1 -1
- package/lib/validationDataMerge.js +3 -3
- package/lib/validationDataMerge.js.map +1 -1
- package/lib/withIdRefPrefix.d.ts +1 -1
- package/lib/withIdRefPrefix.js +2 -2
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +36 -26
- package/src/ErrorSchemaBuilder.ts +15 -8
- package/src/canExpand.ts +2 -2
- package/src/constIsAjvDataReference.ts +17 -0
- package/src/constants.ts +12 -3
- package/src/createSchemaUtils.ts +140 -50
- package/src/dataURItoBlob.ts +1 -1
- package/src/dateRangeOptions.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +4 -5
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +4 -5
- package/src/enumOptionsSelectValue.ts +1 -1
- package/src/enumOptionsValueForIndex.ts +1 -1
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +2 -2
- package/src/getChangedFields.ts +40 -0
- package/src/getDateElementProps.ts +2 -2
- package/src/getDiscriminatorFieldFromSchema.ts +2 -1
- package/src/getInputProps.ts +6 -2
- package/src/getOptionMatchingSimpleDiscriminator.ts +2 -2
- package/src/getSchemaType.ts +3 -2
- package/src/getSubmitButtonOptions.ts +1 -1
- package/src/getTemplate.ts +12 -1
- package/src/getTestIds.ts +40 -0
- package/src/getUiOptions.ts +2 -2
- package/src/getWidget.tsx +2 -2
- package/src/hasWidget.ts +1 -1
- package/src/hashForSchema.ts +26 -6
- package/src/idGenerators.ts +10 -0
- package/src/index.ts +21 -2
- package/src/isCustomWidget.ts +1 -1
- package/src/isObject.ts +12 -5
- package/src/labelValue.ts +2 -2
- package/src/lookupFromFormContext.ts +26 -0
- package/src/mergeDefaultsWithFormData.ts +54 -9
- package/src/mergeObjects.ts +24 -21
- package/src/optionsList.ts +31 -22
- package/src/parser/ParserValidator.ts +5 -5
- package/src/parser/schemaParser.ts +6 -6
- package/src/schema/findFieldInSchema.ts +138 -0
- package/src/schema/findSelectedOptionInXxxOf.ts +53 -0
- package/src/schema/getClosestMatchingOption.ts +38 -11
- package/src/schema/getDefaultFormState.ts +447 -191
- package/src/schema/getDisplayLabel.ts +7 -4
- package/src/schema/getFirstMatchingOption.ts +79 -4
- package/src/schema/getFromSchema.ts +100 -0
- package/src/schema/index.ts +6 -4
- package/src/schema/isFilesArray.ts +18 -3
- package/src/schema/isMultiSelect.ts +10 -4
- package/src/schema/isSelect.ts +5 -3
- package/src/schema/retrieveSchema.ts +256 -75
- package/src/schema/sanitizeDataForNewSchema.ts +52 -11
- package/src/schema/toIdSchema.ts +69 -43
- package/src/schema/toPathSchema.ts +49 -16
- package/src/toErrorList.ts +2 -2
- package/src/types.ts +266 -174
- package/src/validationDataMerge.ts +1 -1
- package/src/withIdRefPrefix.ts +1 -1
- package/LICENSE.md +0 -201
- package/lib/schema/getMatchingOption.d.ts +0 -14
- package/lib/schema/getMatchingOption.js +0 -85
- package/lib/schema/getMatchingOption.js.map +0 -1
- package/lib/schema/mergeValidationData.d.ts +0 -14
- package/lib/schema/mergeValidationData.js +0 -28
- package/lib/schema/mergeValidationData.js.map +0 -1
- package/src/schema/getMatchingOption.ts +0 -103
- package/src/schema/mergeValidationData.ts +0 -38
package/dist/utils.umd.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/has'), require('lodash/isEqual'), require('lodash/set'), require('lodash/times'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('jsonpointer'), require('lodash/omit'), require('lodash/isString'), require('lodash/union'), require('lodash/isNumber'), require('lodash/isEmpty'), require('lodash/isObject'), require('lodash/reduce'), require('lodash/isNil'), require('lodash/cloneDeep'), require('lodash/setWith'), require('nanoid'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), require('lodash/forEach')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/has', 'lodash/isEqual', 'lodash/set', 'lodash/times', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'jsonpointer', 'lodash/omit', 'lodash/isString', 'lodash/union', 'lodash/isNumber', 'lodash/isEmpty', 'lodash/isObject', 'lodash/reduce', 'lodash/isNil', 'lodash/cloneDeep', 'lodash/setWith', 'nanoid', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', 'lodash/forEach'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.isEqualWith, global.get12, global.has5, global.isEqual, global.set, global.times, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.jsonpointer, global.omit, global.isString, global.union, global.isNumber, global.isEmpty, global.isObject2, global.reduce, global.isNil, global.cloneDeep, global.setWith, global.nanoid, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.keys, global.pickBy, global.difference, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject4, isEqualWith, get12, has5, isEqual, set, times, transform, merge, flattenDeep, uniq, mergeAllOf, jsonpointer, omit, isString, union, isNumber, isEmpty, isObject2, reduce, isNil, cloneDeep, setWith, nanoid, react, ReactIs, jsxRuntime, toPath, keys, pickBy, difference, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
9
|
-
if (typeof
|
|
9
|
+
if (typeof thing !== "object" || thing === null) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
|
-
if (typeof
|
|
12
|
+
if (typeof thing.lastModified === "number" && typeof File !== "undefined" && thing instanceof File) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
if (typeof thing.getMonth === "function" && typeof Date !== "undefined" && thing instanceof Date) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return !Array.isArray(thing);
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
// src/allowAdditionalItems.ts
|
|
@@ -62,11 +65,15 @@
|
|
|
62
65
|
var JUNK_OPTION_ID = "_$junk_option_schema_id$_";
|
|
63
66
|
var NAME_KEY = "$name";
|
|
64
67
|
var ONE_OF_KEY = "oneOf";
|
|
68
|
+
var PATTERN_PROPERTIES_KEY = "patternProperties";
|
|
65
69
|
var PROPERTIES_KEY = "properties";
|
|
70
|
+
var READONLY_KEY = "readonly";
|
|
66
71
|
var REQUIRED_KEY = "required";
|
|
67
72
|
var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
|
|
68
73
|
var REF_KEY = "$ref";
|
|
69
|
-
var
|
|
74
|
+
var DISCRIMINATOR_PATH = ["discriminator", "propertyName"];
|
|
75
|
+
var FORM_CONTEXT_NAME = "formContext";
|
|
76
|
+
var LOOKUP_MAP_NAME = "layoutGridLookupMap";
|
|
70
77
|
var RJSF_ADDITIONAL_PROPERTIES_FLAG = "__rjsf_additionalProperties";
|
|
71
78
|
var ROOT_SCHEMA_PREFIX = "__rjsf_rootSchema";
|
|
72
79
|
var UI_FIELD_KEY = "ui:field";
|
|
@@ -94,7 +101,7 @@
|
|
|
94
101
|
|
|
95
102
|
// src/canExpand.ts
|
|
96
103
|
function canExpand(schema, uiSchema = {}, formData) {
|
|
97
|
-
if (!schema.additionalProperties) {
|
|
104
|
+
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
98
105
|
return false;
|
|
99
106
|
}
|
|
100
107
|
const { expandable = true } = getUiOptions(uiSchema);
|
|
@@ -121,7 +128,7 @@
|
|
|
121
128
|
return { ...acc, [key]: createErrorHandler(value) };
|
|
122
129
|
}, handler);
|
|
123
130
|
}
|
|
124
|
-
if (
|
|
131
|
+
if (isPlainObject4(formData)) {
|
|
125
132
|
const formObject = formData;
|
|
126
133
|
return Object.keys(formObject).reduce((acc, key) => {
|
|
127
134
|
return { ...acc, [key]: createErrorHandler(formObject[key]) };
|
|
@@ -177,83 +184,9 @@
|
|
|
177
184
|
const recurseList = [];
|
|
178
185
|
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList);
|
|
179
186
|
}
|
|
180
|
-
function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
|
|
181
|
-
if (formData && discriminatorField) {
|
|
182
|
-
const value = get8(formData, discriminatorField);
|
|
183
|
-
if (value === void 0) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
for (let i = 0; i < options.length; i++) {
|
|
187
|
-
const option = options[i];
|
|
188
|
-
const discriminator = get8(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
189
|
-
if (discriminator.type === "object" || discriminator.type === "array") {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
if (discriminator.const === value) {
|
|
193
|
-
return i;
|
|
194
|
-
}
|
|
195
|
-
if (discriminator.enum?.includes(value)) {
|
|
196
|
-
return i;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// src/schema/getMatchingOption.ts
|
|
204
|
-
function getMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
|
|
205
|
-
if (formData === void 0) {
|
|
206
|
-
return 0;
|
|
207
|
-
}
|
|
208
|
-
const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);
|
|
209
|
-
if (isNumber(simpleDiscriminatorMatch)) {
|
|
210
|
-
return simpleDiscriminatorMatch;
|
|
211
|
-
}
|
|
212
|
-
for (let i = 0; i < options.length; i++) {
|
|
213
|
-
const option = options[i];
|
|
214
|
-
if (discriminatorField && has3(option, [PROPERTIES_KEY, discriminatorField])) {
|
|
215
|
-
const value = get8(formData, discriminatorField);
|
|
216
|
-
const discriminator = get8(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
217
|
-
if (validator.isValid(discriminator, value, rootSchema)) {
|
|
218
|
-
return i;
|
|
219
|
-
}
|
|
220
|
-
} else if (option[PROPERTIES_KEY]) {
|
|
221
|
-
const requiresAnyOf = {
|
|
222
|
-
anyOf: Object.keys(option[PROPERTIES_KEY]).map((key) => ({
|
|
223
|
-
required: [key]
|
|
224
|
-
}))
|
|
225
|
-
};
|
|
226
|
-
let augmentedSchema;
|
|
227
|
-
if (option.anyOf) {
|
|
228
|
-
const { ...shallowClone } = option;
|
|
229
|
-
if (!shallowClone.allOf) {
|
|
230
|
-
shallowClone.allOf = [];
|
|
231
|
-
} else {
|
|
232
|
-
shallowClone.allOf = shallowClone.allOf.slice();
|
|
233
|
-
}
|
|
234
|
-
shallowClone.allOf.push(requiresAnyOf);
|
|
235
|
-
augmentedSchema = shallowClone;
|
|
236
|
-
} else {
|
|
237
|
-
augmentedSchema = Object.assign({}, option, requiresAnyOf);
|
|
238
|
-
}
|
|
239
|
-
delete augmentedSchema.required;
|
|
240
|
-
if (validator.isValid(augmentedSchema, formData, rootSchema)) {
|
|
241
|
-
return i;
|
|
242
|
-
}
|
|
243
|
-
} else if (validator.isValid(option, formData, rootSchema)) {
|
|
244
|
-
return i;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return 0;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/schema/getFirstMatchingOption.ts
|
|
251
|
-
function getFirstMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
|
|
252
|
-
return getMatchingOption(validator, formData, options, rootSchema, discriminatorField);
|
|
253
|
-
}
|
|
254
187
|
function getDiscriminatorFieldFromSchema(schema) {
|
|
255
188
|
let discriminator;
|
|
256
|
-
const maybeString =
|
|
189
|
+
const maybeString = get12(schema, DISCRIMINATOR_PATH);
|
|
257
190
|
if (isString(maybeString)) {
|
|
258
191
|
discriminator = maybeString;
|
|
259
192
|
} else if (maybeString !== void 0) {
|
|
@@ -294,7 +227,7 @@
|
|
|
294
227
|
if (!type && schema.enum) {
|
|
295
228
|
return "string";
|
|
296
229
|
}
|
|
297
|
-
if (!type && (schema.properties || schema.additionalProperties)) {
|
|
230
|
+
if (!type && (schema.properties || schema.additionalProperties || schema.patternProperties)) {
|
|
298
231
|
return "object";
|
|
299
232
|
}
|
|
300
233
|
if (Array.isArray(type)) {
|
|
@@ -322,12 +255,87 @@
|
|
|
322
255
|
return acc2;
|
|
323
256
|
}, acc);
|
|
324
257
|
}
|
|
258
|
+
function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
|
|
259
|
+
if (formData && discriminatorField) {
|
|
260
|
+
const value = get12(formData, discriminatorField);
|
|
261
|
+
if (value === void 0) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
for (let i = 0; i < options.length; i++) {
|
|
265
|
+
const option = options[i];
|
|
266
|
+
const discriminator = get12(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
267
|
+
if (discriminator.type === "object" || discriminator.type === "array") {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (discriminator.const === value) {
|
|
271
|
+
return i;
|
|
272
|
+
}
|
|
273
|
+
if (discriminator.enum?.includes(value)) {
|
|
274
|
+
return i;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
325
280
|
|
|
326
|
-
// src/schema/
|
|
327
|
-
function
|
|
328
|
-
|
|
281
|
+
// src/schema/getFirstMatchingOption.ts
|
|
282
|
+
function getFirstMatchingOption(validator, formData, options, rootSchema, discriminatorField) {
|
|
283
|
+
if (formData === void 0) {
|
|
284
|
+
return 0;
|
|
285
|
+
}
|
|
286
|
+
const simpleDiscriminatorMatch = getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField);
|
|
287
|
+
if (isNumber(simpleDiscriminatorMatch)) {
|
|
288
|
+
return simpleDiscriminatorMatch;
|
|
289
|
+
}
|
|
290
|
+
for (let i = 0; i < options.length; i++) {
|
|
291
|
+
const option = options[i];
|
|
292
|
+
if (discriminatorField && has5(option, [PROPERTIES_KEY, discriminatorField])) {
|
|
293
|
+
const value = get12(formData, discriminatorField);
|
|
294
|
+
const discriminator = get12(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
295
|
+
if (validator.isValid(discriminator, value, rootSchema)) {
|
|
296
|
+
return i;
|
|
297
|
+
}
|
|
298
|
+
} else if (option[PROPERTIES_KEY]) {
|
|
299
|
+
const requiresAnyOf = {
|
|
300
|
+
anyOf: Object.keys(option[PROPERTIES_KEY]).map((key) => ({
|
|
301
|
+
required: [key]
|
|
302
|
+
}))
|
|
303
|
+
};
|
|
304
|
+
let augmentedSchema;
|
|
305
|
+
if (option.anyOf) {
|
|
306
|
+
const { ...shallowClone } = option;
|
|
307
|
+
if (!shallowClone.allOf) {
|
|
308
|
+
shallowClone.allOf = [];
|
|
309
|
+
} else {
|
|
310
|
+
shallowClone.allOf = shallowClone.allOf.slice();
|
|
311
|
+
}
|
|
312
|
+
shallowClone.allOf.push(requiresAnyOf);
|
|
313
|
+
augmentedSchema = shallowClone;
|
|
314
|
+
} else {
|
|
315
|
+
augmentedSchema = Object.assign({}, option, requiresAnyOf);
|
|
316
|
+
}
|
|
317
|
+
delete augmentedSchema.required;
|
|
318
|
+
if (validator.isValid(augmentedSchema, formData, rootSchema)) {
|
|
319
|
+
return i;
|
|
320
|
+
}
|
|
321
|
+
} else if (validator.isValid(option, formData, rootSchema)) {
|
|
322
|
+
return i;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return 0;
|
|
329
326
|
}
|
|
330
|
-
function
|
|
327
|
+
function retrieveSchema(validator, schema, rootSchema = {}, rawFormData, experimental_customMergeAllOf) {
|
|
328
|
+
return retrieveSchemaInternal(
|
|
329
|
+
validator,
|
|
330
|
+
schema,
|
|
331
|
+
rootSchema,
|
|
332
|
+
rawFormData,
|
|
333
|
+
void 0,
|
|
334
|
+
void 0,
|
|
335
|
+
experimental_customMergeAllOf
|
|
336
|
+
)[0];
|
|
337
|
+
}
|
|
338
|
+
function resolveCondition(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
331
339
|
const { if: expression, then, else: otherwise, ...resolvedSchemaLessConditional } = schema;
|
|
332
340
|
const conditionValue = validator.isValid(expression, formData || {}, rootSchema);
|
|
333
341
|
let resolvedSchemas = [resolvedSchemaLessConditional];
|
|
@@ -335,12 +343,28 @@
|
|
|
335
343
|
if (expandAllBranches) {
|
|
336
344
|
if (then && typeof then !== "boolean") {
|
|
337
345
|
schemas = schemas.concat(
|
|
338
|
-
retrieveSchemaInternal(
|
|
346
|
+
retrieveSchemaInternal(
|
|
347
|
+
validator,
|
|
348
|
+
then,
|
|
349
|
+
rootSchema,
|
|
350
|
+
formData,
|
|
351
|
+
expandAllBranches,
|
|
352
|
+
recurseList,
|
|
353
|
+
experimental_customMergeAllOf
|
|
354
|
+
)
|
|
339
355
|
);
|
|
340
356
|
}
|
|
341
357
|
if (otherwise && typeof otherwise !== "boolean") {
|
|
342
358
|
schemas = schemas.concat(
|
|
343
|
-
retrieveSchemaInternal(
|
|
359
|
+
retrieveSchemaInternal(
|
|
360
|
+
validator,
|
|
361
|
+
otherwise,
|
|
362
|
+
rootSchema,
|
|
363
|
+
formData,
|
|
364
|
+
expandAllBranches,
|
|
365
|
+
recurseList,
|
|
366
|
+
experimental_customMergeAllOf
|
|
367
|
+
)
|
|
344
368
|
);
|
|
345
369
|
}
|
|
346
370
|
} else {
|
|
@@ -353,7 +377,8 @@
|
|
|
353
377
|
rootSchema,
|
|
354
378
|
formData,
|
|
355
379
|
expandAllBranches,
|
|
356
|
-
recurseList
|
|
380
|
+
recurseList,
|
|
381
|
+
experimental_customMergeAllOf
|
|
357
382
|
)
|
|
358
383
|
);
|
|
359
384
|
}
|
|
@@ -362,7 +387,15 @@
|
|
|
362
387
|
resolvedSchemas = schemas.map((s) => mergeSchemas(resolvedSchemaLessConditional, s));
|
|
363
388
|
}
|
|
364
389
|
return resolvedSchemas.flatMap(
|
|
365
|
-
(s) => retrieveSchemaInternal(
|
|
390
|
+
(s) => retrieveSchemaInternal(
|
|
391
|
+
validator,
|
|
392
|
+
s,
|
|
393
|
+
rootSchema,
|
|
394
|
+
formData,
|
|
395
|
+
expandAllBranches,
|
|
396
|
+
recurseList,
|
|
397
|
+
experimental_customMergeAllOf
|
|
398
|
+
)
|
|
366
399
|
);
|
|
367
400
|
}
|
|
368
401
|
function getAllPermutationsOfXxxOf(listOfLists) {
|
|
@@ -379,7 +412,16 @@
|
|
|
379
412
|
);
|
|
380
413
|
return allPermutations;
|
|
381
414
|
}
|
|
382
|
-
function
|
|
415
|
+
function getMatchingPatternProperties(schema, key) {
|
|
416
|
+
return Object.keys(schema.patternProperties).filter((pattern) => RegExp(pattern).test(key)).reduce(
|
|
417
|
+
(obj, pattern) => {
|
|
418
|
+
set(obj, [pattern], schema.patternProperties[pattern]);
|
|
419
|
+
return obj;
|
|
420
|
+
},
|
|
421
|
+
{}
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
383
425
|
const updatedSchemas = resolveReference(
|
|
384
426
|
validator,
|
|
385
427
|
schema,
|
|
@@ -401,7 +443,15 @@
|
|
|
401
443
|
formData
|
|
402
444
|
);
|
|
403
445
|
return resolvedSchemas.flatMap((s) => {
|
|
404
|
-
return retrieveSchemaInternal(
|
|
446
|
+
return retrieveSchemaInternal(
|
|
447
|
+
validator,
|
|
448
|
+
s,
|
|
449
|
+
rootSchema,
|
|
450
|
+
formData,
|
|
451
|
+
expandAllBranches,
|
|
452
|
+
recurseList,
|
|
453
|
+
experimental_customMergeAllOf
|
|
454
|
+
);
|
|
405
455
|
});
|
|
406
456
|
}
|
|
407
457
|
if (ALL_OF_KEY in schema && Array.isArray(schema.allOf)) {
|
|
@@ -412,15 +462,19 @@
|
|
|
412
462
|
rootSchema,
|
|
413
463
|
formData,
|
|
414
464
|
expandAllBranches,
|
|
415
|
-
recurseList
|
|
465
|
+
recurseList,
|
|
466
|
+
experimental_customMergeAllOf
|
|
416
467
|
)
|
|
417
468
|
);
|
|
418
469
|
const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
|
|
419
|
-
return allPermutations.map((permutation) => ({
|
|
470
|
+
return allPermutations.map((permutation) => ({
|
|
471
|
+
...schema,
|
|
472
|
+
allOf: permutation
|
|
473
|
+
}));
|
|
420
474
|
}
|
|
421
475
|
return [schema];
|
|
422
476
|
}
|
|
423
|
-
function resolveReference(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
|
|
477
|
+
function resolveReference(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
424
478
|
const updatedSchema = resolveAllReferences(schema, rootSchema, recurseList);
|
|
425
479
|
if (updatedSchema !== schema) {
|
|
426
480
|
return retrieveSchemaInternal(
|
|
@@ -429,7 +483,8 @@
|
|
|
429
483
|
rootSchema,
|
|
430
484
|
formData,
|
|
431
485
|
expandAllBranches,
|
|
432
|
-
recurseList
|
|
486
|
+
recurseList,
|
|
487
|
+
experimental_customMergeAllOf
|
|
433
488
|
);
|
|
434
489
|
}
|
|
435
490
|
return [schema];
|
|
@@ -468,9 +523,9 @@
|
|
|
468
523
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
469
524
|
};
|
|
470
525
|
}
|
|
471
|
-
return
|
|
526
|
+
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
472
527
|
}
|
|
473
|
-
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
|
|
528
|
+
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
474
529
|
const schema = {
|
|
475
530
|
...theSchema,
|
|
476
531
|
properties: { ...theSchema.properties }
|
|
@@ -480,34 +535,54 @@
|
|
|
480
535
|
if (key in schema.properties) {
|
|
481
536
|
return;
|
|
482
537
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if (
|
|
486
|
-
|
|
538
|
+
if (PATTERN_PROPERTIES_KEY in schema) {
|
|
539
|
+
const matchingProperties = getMatchingPatternProperties(schema, key);
|
|
540
|
+
if (!isEmpty(matchingProperties)) {
|
|
541
|
+
schema.properties[key] = retrieveSchema(
|
|
487
542
|
validator,
|
|
488
|
-
{
|
|
543
|
+
{ allOf: Object.values(matchingProperties) },
|
|
489
544
|
rootSchema,
|
|
490
|
-
formData
|
|
545
|
+
formData,
|
|
546
|
+
experimental_customMergeAllOf
|
|
491
547
|
);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
548
|
+
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (ADDITIONAL_PROPERTIES_KEY in schema && schema.additionalProperties !== false) {
|
|
553
|
+
let additionalProperties = {};
|
|
554
|
+
if (typeof schema.additionalProperties !== "boolean") {
|
|
555
|
+
if (REF_KEY in schema.additionalProperties) {
|
|
556
|
+
additionalProperties = retrieveSchema(
|
|
557
|
+
validator,
|
|
558
|
+
{ $ref: get12(schema.additionalProperties, [REF_KEY]) },
|
|
559
|
+
rootSchema,
|
|
560
|
+
formData,
|
|
561
|
+
experimental_customMergeAllOf
|
|
562
|
+
);
|
|
563
|
+
} else if ("type" in schema.additionalProperties) {
|
|
564
|
+
additionalProperties = { ...schema.additionalProperties };
|
|
565
|
+
} else if (ANY_OF_KEY in schema.additionalProperties || ONE_OF_KEY in schema.additionalProperties) {
|
|
566
|
+
additionalProperties = {
|
|
567
|
+
type: "object",
|
|
568
|
+
...schema.additionalProperties
|
|
569
|
+
};
|
|
570
|
+
} else {
|
|
571
|
+
additionalProperties = { type: guessType(get12(formData, [key])) };
|
|
572
|
+
}
|
|
499
573
|
} else {
|
|
500
|
-
additionalProperties = { type: guessType(
|
|
574
|
+
additionalProperties = { type: guessType(get12(formData, [key])) };
|
|
501
575
|
}
|
|
576
|
+
schema.properties[key] = additionalProperties;
|
|
577
|
+
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
502
578
|
} else {
|
|
503
|
-
|
|
579
|
+
schema.properties[key] = { type: "null" };
|
|
580
|
+
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
504
581
|
}
|
|
505
|
-
schema.properties[key] = additionalProperties;
|
|
506
|
-
set3(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
507
582
|
});
|
|
508
583
|
return schema;
|
|
509
584
|
}
|
|
510
|
-
function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false, recurseList = []) {
|
|
585
|
+
function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false, recurseList = [], experimental_customMergeAllOf) {
|
|
511
586
|
if (!isObject(schema)) {
|
|
512
587
|
return [{}];
|
|
513
588
|
}
|
|
@@ -517,7 +592,8 @@
|
|
|
517
592
|
rootSchema,
|
|
518
593
|
expandAllBranches,
|
|
519
594
|
recurseList,
|
|
520
|
-
rawFormData
|
|
595
|
+
rawFormData,
|
|
596
|
+
experimental_customMergeAllOf
|
|
521
597
|
);
|
|
522
598
|
return resolvedSchemas.flatMap((s) => {
|
|
523
599
|
let resolvedSchema = s;
|
|
@@ -528,7 +604,8 @@
|
|
|
528
604
|
rootSchema,
|
|
529
605
|
expandAllBranches,
|
|
530
606
|
recurseList,
|
|
531
|
-
rawFormData
|
|
607
|
+
rawFormData,
|
|
608
|
+
experimental_customMergeAllOf
|
|
532
609
|
);
|
|
533
610
|
}
|
|
534
611
|
if (ALL_OF_KEY in resolvedSchema) {
|
|
@@ -537,18 +614,60 @@
|
|
|
537
614
|
return [...allOf, restOfSchema];
|
|
538
615
|
}
|
|
539
616
|
try {
|
|
540
|
-
|
|
617
|
+
const withContainsSchemas = [];
|
|
618
|
+
const withoutContainsSchemas = [];
|
|
619
|
+
resolvedSchema.allOf?.forEach((s2) => {
|
|
620
|
+
if (typeof s2 === "object" && s2.contains) {
|
|
621
|
+
withContainsSchemas.push(s2);
|
|
622
|
+
} else {
|
|
623
|
+
withoutContainsSchemas.push(s2);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
if (withContainsSchemas.length) {
|
|
627
|
+
resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };
|
|
628
|
+
}
|
|
629
|
+
resolvedSchema = experimental_customMergeAllOf ? experimental_customMergeAllOf(resolvedSchema) : mergeAllOf(resolvedSchema, {
|
|
541
630
|
deep: false
|
|
542
631
|
});
|
|
632
|
+
if (withContainsSchemas.length) {
|
|
633
|
+
resolvedSchema.allOf = withContainsSchemas;
|
|
634
|
+
}
|
|
543
635
|
} catch (e) {
|
|
544
636
|
console.warn("could not merge subschemas in allOf:\n", e);
|
|
545
637
|
const { allOf, ...resolvedSchemaWithoutAllOf } = resolvedSchema;
|
|
546
638
|
return resolvedSchemaWithoutAllOf;
|
|
547
639
|
}
|
|
548
640
|
}
|
|
549
|
-
|
|
641
|
+
if (PROPERTIES_KEY in resolvedSchema && PATTERN_PROPERTIES_KEY in resolvedSchema) {
|
|
642
|
+
resolvedSchema = Object.keys(resolvedSchema.properties).reduce(
|
|
643
|
+
(schema2, key) => {
|
|
644
|
+
const matchingProperties = getMatchingPatternProperties(schema2, key);
|
|
645
|
+
if (!isEmpty(matchingProperties)) {
|
|
646
|
+
schema2.properties[key] = retrieveSchema(
|
|
647
|
+
validator,
|
|
648
|
+
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
649
|
+
rootSchema,
|
|
650
|
+
rawFormData,
|
|
651
|
+
experimental_customMergeAllOf
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
return schema2;
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
...resolvedSchema,
|
|
658
|
+
properties: { ...resolvedSchema.properties }
|
|
659
|
+
}
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
const hasAdditionalProperties = PATTERN_PROPERTIES_KEY in resolvedSchema || ADDITIONAL_PROPERTIES_KEY in resolvedSchema && resolvedSchema.additionalProperties !== false;
|
|
550
663
|
if (hasAdditionalProperties) {
|
|
551
|
-
return stubExistingAdditionalProperties(
|
|
664
|
+
return stubExistingAdditionalProperties(
|
|
665
|
+
validator,
|
|
666
|
+
resolvedSchema,
|
|
667
|
+
rootSchema,
|
|
668
|
+
rawFormData,
|
|
669
|
+
experimental_customMergeAllOf
|
|
670
|
+
);
|
|
552
671
|
}
|
|
553
672
|
return resolvedSchema;
|
|
554
673
|
});
|
|
@@ -575,7 +694,7 @@
|
|
|
575
694
|
}
|
|
576
695
|
return [schema];
|
|
577
696
|
}
|
|
578
|
-
function resolveDependencies(validator, schema, rootSchema, expandAllBranches, recurseList, formData) {
|
|
697
|
+
function resolveDependencies(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
579
698
|
const { dependencies, ...remainingSchema } = schema;
|
|
580
699
|
const resolvedSchemas = resolveAnyOrOneOfSchemas(
|
|
581
700
|
validator,
|
|
@@ -592,14 +711,15 @@
|
|
|
592
711
|
rootSchema,
|
|
593
712
|
expandAllBranches,
|
|
594
713
|
recurseList,
|
|
595
|
-
formData
|
|
714
|
+
formData,
|
|
715
|
+
experimental_customMergeAllOf
|
|
596
716
|
)
|
|
597
717
|
);
|
|
598
718
|
}
|
|
599
|
-
function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData) {
|
|
719
|
+
function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
600
720
|
let schemas = [resolvedSchema];
|
|
601
721
|
for (const dependencyKey in dependencies) {
|
|
602
|
-
if (!expandAllBranches &&
|
|
722
|
+
if (!expandAllBranches && get12(formData, [dependencyKey]) === void 0) {
|
|
603
723
|
continue;
|
|
604
724
|
}
|
|
605
725
|
if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
|
|
@@ -620,7 +740,8 @@
|
|
|
620
740
|
dependencyValue,
|
|
621
741
|
expandAllBranches,
|
|
622
742
|
recurseList,
|
|
623
|
-
formData
|
|
743
|
+
formData,
|
|
744
|
+
experimental_customMergeAllOf
|
|
624
745
|
);
|
|
625
746
|
}
|
|
626
747
|
return schemas.flatMap(
|
|
@@ -631,7 +752,8 @@
|
|
|
631
752
|
rootSchema,
|
|
632
753
|
expandAllBranches,
|
|
633
754
|
recurseList,
|
|
634
|
-
formData
|
|
755
|
+
formData,
|
|
756
|
+
experimental_customMergeAllOf
|
|
635
757
|
)
|
|
636
758
|
);
|
|
637
759
|
}
|
|
@@ -644,14 +766,15 @@
|
|
|
644
766
|
const required = Array.isArray(schema.required) ? Array.from(/* @__PURE__ */ new Set([...schema.required, ...additionallyRequired])) : additionallyRequired;
|
|
645
767
|
return { ...schema, required };
|
|
646
768
|
}
|
|
647
|
-
function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, recurseList, formData) {
|
|
769
|
+
function withDependentSchema(validator, schema, rootSchema, dependencyKey, dependencyValue, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
648
770
|
const dependentSchemas = retrieveSchemaInternal(
|
|
649
771
|
validator,
|
|
650
772
|
dependencyValue,
|
|
651
773
|
rootSchema,
|
|
652
774
|
formData,
|
|
653
775
|
expandAllBranches,
|
|
654
|
-
recurseList
|
|
776
|
+
recurseList,
|
|
777
|
+
experimental_customMergeAllOf
|
|
655
778
|
);
|
|
656
779
|
return dependentSchemas.flatMap((dependent) => {
|
|
657
780
|
const { oneOf, ...dependentSchema } = dependent;
|
|
@@ -675,12 +798,13 @@
|
|
|
675
798
|
resolvedOneOf,
|
|
676
799
|
expandAllBranches,
|
|
677
800
|
recurseList,
|
|
678
|
-
formData
|
|
801
|
+
formData,
|
|
802
|
+
experimental_customMergeAllOf
|
|
679
803
|
)
|
|
680
804
|
);
|
|
681
805
|
});
|
|
682
806
|
}
|
|
683
|
-
function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, recurseList, formData) {
|
|
807
|
+
function withExactlyOneSubschema(validator, schema, rootSchema, dependencyKey, oneOf, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
684
808
|
const validSubschemas = oneOf.filter((subschema) => {
|
|
685
809
|
if (typeof subschema === "boolean" || !subschema || !subschema.properties) {
|
|
686
810
|
return false;
|
|
@@ -711,13 +835,148 @@
|
|
|
711
835
|
rootSchema,
|
|
712
836
|
formData,
|
|
713
837
|
expandAllBranches,
|
|
714
|
-
recurseList
|
|
838
|
+
recurseList,
|
|
839
|
+
experimental_customMergeAllOf
|
|
715
840
|
);
|
|
716
841
|
return schemas.map((s2) => mergeSchemas(schema, s2));
|
|
717
842
|
});
|
|
718
843
|
}
|
|
719
844
|
|
|
720
|
-
// src/schema/
|
|
845
|
+
// src/schema/findSelectedOptionInXxxOf.ts
|
|
846
|
+
function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField, xxx, formData = {}, experimental_customMergeAllOf) {
|
|
847
|
+
if (Array.isArray(schema[xxx])) {
|
|
848
|
+
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
849
|
+
const selectorField = discriminator || fallbackField;
|
|
850
|
+
const xxxOfs = schema[xxx].map(
|
|
851
|
+
(xxxOf) => retrieveSchema(validator, xxxOf, rootSchema, formData, experimental_customMergeAllOf)
|
|
852
|
+
);
|
|
853
|
+
const data = get12(formData, selectorField);
|
|
854
|
+
if (data !== void 0) {
|
|
855
|
+
return xxxOfs.find((xxx2) => {
|
|
856
|
+
return isEqual(
|
|
857
|
+
get12(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get12(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
858
|
+
data
|
|
859
|
+
);
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return void 0;
|
|
864
|
+
}
|
|
865
|
+
function getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf) {
|
|
866
|
+
let fieldSchema = schema;
|
|
867
|
+
if (has5(schema, REF_KEY)) {
|
|
868
|
+
fieldSchema = retrieveSchema(validator, schema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
869
|
+
}
|
|
870
|
+
if (isEmpty(path)) {
|
|
871
|
+
return fieldSchema;
|
|
872
|
+
}
|
|
873
|
+
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
874
|
+
const [part, ...nestedPath] = pathList;
|
|
875
|
+
if (part && has5(fieldSchema, part)) {
|
|
876
|
+
fieldSchema = get12(fieldSchema, part);
|
|
877
|
+
return getFromSchemaInternal(
|
|
878
|
+
validator,
|
|
879
|
+
rootSchema,
|
|
880
|
+
fieldSchema,
|
|
881
|
+
nestedPath,
|
|
882
|
+
experimental_customMergeAllOf
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
return void 0;
|
|
886
|
+
}
|
|
887
|
+
function getFromSchema(validator, rootSchema, schema, path, defaultValue, experimental_customMergeAllOf) {
|
|
888
|
+
const result = getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf);
|
|
889
|
+
if (result === void 0) {
|
|
890
|
+
return defaultValue;
|
|
891
|
+
}
|
|
892
|
+
return result;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// src/schema/findFieldInSchema.ts
|
|
896
|
+
var NOT_FOUND_SCHEMA = { title: "!@#$_UNKNOWN_$#@!" };
|
|
897
|
+
function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, experimental_customMergeAllOf) {
|
|
898
|
+
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
899
|
+
let parentField = schema;
|
|
900
|
+
const fieldName = pathList.pop();
|
|
901
|
+
if (pathList.length) {
|
|
902
|
+
pathList.forEach((subPath) => {
|
|
903
|
+
parentField = getFromSchema(
|
|
904
|
+
validator,
|
|
905
|
+
rootSchema,
|
|
906
|
+
parentField,
|
|
907
|
+
[PROPERTIES_KEY, subPath],
|
|
908
|
+
{},
|
|
909
|
+
experimental_customMergeAllOf
|
|
910
|
+
);
|
|
911
|
+
if (has5(parentField, ONE_OF_KEY)) {
|
|
912
|
+
parentField = findSelectedOptionInXxxOf(
|
|
913
|
+
validator,
|
|
914
|
+
rootSchema,
|
|
915
|
+
parentField,
|
|
916
|
+
fieldName,
|
|
917
|
+
ONE_OF_KEY,
|
|
918
|
+
get12(formData, subPath),
|
|
919
|
+
experimental_customMergeAllOf
|
|
920
|
+
);
|
|
921
|
+
} else if (has5(parentField, ANY_OF_KEY)) {
|
|
922
|
+
parentField = findSelectedOptionInXxxOf(
|
|
923
|
+
validator,
|
|
924
|
+
rootSchema,
|
|
925
|
+
parentField,
|
|
926
|
+
fieldName,
|
|
927
|
+
ANY_OF_KEY,
|
|
928
|
+
get12(formData, subPath),
|
|
929
|
+
experimental_customMergeAllOf
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
if (has5(parentField, ONE_OF_KEY)) {
|
|
935
|
+
parentField = findSelectedOptionInXxxOf(
|
|
936
|
+
validator,
|
|
937
|
+
rootSchema,
|
|
938
|
+
parentField,
|
|
939
|
+
fieldName,
|
|
940
|
+
ONE_OF_KEY,
|
|
941
|
+
formData,
|
|
942
|
+
experimental_customMergeAllOf
|
|
943
|
+
);
|
|
944
|
+
} else if (has5(parentField, ANY_OF_KEY)) {
|
|
945
|
+
parentField = findSelectedOptionInXxxOf(
|
|
946
|
+
validator,
|
|
947
|
+
rootSchema,
|
|
948
|
+
parentField,
|
|
949
|
+
fieldName,
|
|
950
|
+
ANY_OF_KEY,
|
|
951
|
+
formData,
|
|
952
|
+
experimental_customMergeAllOf
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
let field = getFromSchema(
|
|
956
|
+
validator,
|
|
957
|
+
rootSchema,
|
|
958
|
+
parentField,
|
|
959
|
+
[PROPERTIES_KEY, fieldName],
|
|
960
|
+
NOT_FOUND_SCHEMA,
|
|
961
|
+
experimental_customMergeAllOf
|
|
962
|
+
);
|
|
963
|
+
if (field === NOT_FOUND_SCHEMA) {
|
|
964
|
+
field = void 0;
|
|
965
|
+
}
|
|
966
|
+
const requiredArray = getFromSchema(
|
|
967
|
+
validator,
|
|
968
|
+
rootSchema,
|
|
969
|
+
parentField,
|
|
970
|
+
REQUIRED_KEY,
|
|
971
|
+
[],
|
|
972
|
+
experimental_customMergeAllOf
|
|
973
|
+
);
|
|
974
|
+
let isRequired;
|
|
975
|
+
if (field && Array.isArray(requiredArray)) {
|
|
976
|
+
isRequired = requiredArray.includes(fieldName);
|
|
977
|
+
}
|
|
978
|
+
return { field, isRequired };
|
|
979
|
+
}
|
|
721
980
|
var JUNK_OPTION = {
|
|
722
981
|
type: "object",
|
|
723
982
|
$id: JUNK_OPTION_ID,
|
|
@@ -727,35 +986,51 @@
|
|
|
727
986
|
}
|
|
728
987
|
}
|
|
729
988
|
};
|
|
730
|
-
function calculateIndexScore(validator, rootSchema, schema, formData
|
|
989
|
+
function calculateIndexScore(validator, rootSchema, schema, formData, experimental_customMergeAllOf) {
|
|
731
990
|
let totalScore = 0;
|
|
732
991
|
if (schema) {
|
|
733
992
|
if (isObject2(schema.properties)) {
|
|
734
993
|
totalScore += reduce(
|
|
735
994
|
schema.properties,
|
|
736
995
|
(score, value, key) => {
|
|
737
|
-
const formValue =
|
|
996
|
+
const formValue = get12(formData, key);
|
|
738
997
|
if (typeof value === "boolean") {
|
|
739
998
|
return score;
|
|
740
999
|
}
|
|
741
|
-
if (
|
|
742
|
-
const newSchema = retrieveSchema(
|
|
743
|
-
|
|
1000
|
+
if (has5(value, REF_KEY)) {
|
|
1001
|
+
const newSchema = retrieveSchema(
|
|
1002
|
+
validator,
|
|
1003
|
+
value,
|
|
1004
|
+
rootSchema,
|
|
1005
|
+
formValue,
|
|
1006
|
+
experimental_customMergeAllOf
|
|
1007
|
+
);
|
|
1008
|
+
return score + calculateIndexScore(
|
|
1009
|
+
validator,
|
|
1010
|
+
rootSchema,
|
|
1011
|
+
newSchema,
|
|
1012
|
+
formValue || {},
|
|
1013
|
+
experimental_customMergeAllOf
|
|
1014
|
+
);
|
|
744
1015
|
}
|
|
745
|
-
if ((
|
|
746
|
-
const key2 =
|
|
1016
|
+
if ((has5(value, ONE_OF_KEY) || has5(value, ANY_OF_KEY)) && formValue) {
|
|
1017
|
+
const key2 = has5(value, ONE_OF_KEY) ? ONE_OF_KEY : ANY_OF_KEY;
|
|
747
1018
|
const discriminator = getDiscriminatorFieldFromSchema(value);
|
|
748
1019
|
return score + getClosestMatchingOption(
|
|
749
1020
|
validator,
|
|
750
1021
|
rootSchema,
|
|
751
1022
|
formValue,
|
|
752
|
-
|
|
1023
|
+
get12(value, key2),
|
|
753
1024
|
-1,
|
|
754
|
-
discriminator
|
|
1025
|
+
discriminator,
|
|
1026
|
+
experimental_customMergeAllOf
|
|
755
1027
|
);
|
|
756
1028
|
}
|
|
757
1029
|
if (value.type === "object") {
|
|
758
|
-
|
|
1030
|
+
if (isObject2(formValue)) {
|
|
1031
|
+
score += 1;
|
|
1032
|
+
}
|
|
1033
|
+
return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
|
|
759
1034
|
}
|
|
760
1035
|
if (value.type === guessType(formValue)) {
|
|
761
1036
|
let newScore = score + 1;
|
|
@@ -776,7 +1051,7 @@
|
|
|
776
1051
|
}
|
|
777
1052
|
return totalScore;
|
|
778
1053
|
}
|
|
779
|
-
function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField) {
|
|
1054
|
+
function getClosestMatchingOption(validator, rootSchema, formData, options, selectedOption = -1, discriminatorField, experimental_customMergeAllOf) {
|
|
780
1055
|
const resolvedOptions = options.map((option) => {
|
|
781
1056
|
return resolveAllReferences(option, rootSchema, []);
|
|
782
1057
|
});
|
|
@@ -803,7 +1078,7 @@
|
|
|
803
1078
|
(scoreData, index) => {
|
|
804
1079
|
const { bestScore } = scoreData;
|
|
805
1080
|
const option = resolvedOptions[index];
|
|
806
|
-
const score = calculateIndexScore(validator, rootSchema, option, formData);
|
|
1081
|
+
const score = calculateIndexScore(validator, rootSchema, option, formData, experimental_customMergeAllOf);
|
|
807
1082
|
scoreCount.add(score);
|
|
808
1083
|
if (score > bestScore) {
|
|
809
1084
|
return { bestIndex: index, bestScore: score };
|
|
@@ -822,56 +1097,77 @@
|
|
|
822
1097
|
function isFixedItems(schema) {
|
|
823
1098
|
return Array.isArray(schema.items) && schema.items.length > 0 && schema.items.every((item) => isObject(item));
|
|
824
1099
|
}
|
|
825
|
-
function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false) {
|
|
1100
|
+
function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false, defaultSupercedesUndefined = false, overrideFormDataWithDefaults = false) {
|
|
826
1101
|
if (Array.isArray(formData)) {
|
|
827
1102
|
const defaultsArray = Array.isArray(defaults) ? defaults : [];
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
|
|
1103
|
+
const overrideArray = overrideFormDataWithDefaults ? defaultsArray : formData;
|
|
1104
|
+
const overrideOppositeArray = overrideFormDataWithDefaults ? formData : defaultsArray;
|
|
1105
|
+
const mapped = overrideArray.map((value, idx) => {
|
|
1106
|
+
if (overrideOppositeArray[idx] !== void 0) {
|
|
1107
|
+
return mergeDefaultsWithFormData(
|
|
1108
|
+
defaultsArray[idx],
|
|
1109
|
+
formData[idx],
|
|
1110
|
+
mergeExtraArrayDefaults,
|
|
1111
|
+
defaultSupercedesUndefined,
|
|
1112
|
+
overrideFormDataWithDefaults
|
|
1113
|
+
);
|
|
831
1114
|
}
|
|
832
1115
|
return value;
|
|
833
1116
|
});
|
|
834
|
-
if (mergeExtraArrayDefaults && mapped.length <
|
|
835
|
-
mapped.push(...
|
|
1117
|
+
if ((mergeExtraArrayDefaults || overrideFormDataWithDefaults) && mapped.length < overrideOppositeArray.length) {
|
|
1118
|
+
mapped.push(...overrideOppositeArray.slice(mapped.length));
|
|
836
1119
|
}
|
|
837
1120
|
return mapped;
|
|
838
1121
|
}
|
|
839
1122
|
if (isObject(formData)) {
|
|
840
1123
|
const acc = Object.assign({}, defaults);
|
|
841
1124
|
return Object.keys(formData).reduce((acc2, key) => {
|
|
1125
|
+
const keyValue = get12(formData, key);
|
|
1126
|
+
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1127
|
+
const keyExistsInFormData = key in formData;
|
|
842
1128
|
acc2[key] = mergeDefaultsWithFormData(
|
|
843
|
-
defaults ?
|
|
844
|
-
|
|
845
|
-
mergeExtraArrayDefaults
|
|
1129
|
+
defaults ? get12(defaults, key) : {},
|
|
1130
|
+
keyValue,
|
|
1131
|
+
mergeExtraArrayDefaults,
|
|
1132
|
+
defaultSupercedesUndefined,
|
|
1133
|
+
// overrideFormDataWithDefaults can be true only when the key value exists in defaults
|
|
1134
|
+
// Or if the key value doesn't exist in formData
|
|
1135
|
+
overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData)
|
|
846
1136
|
);
|
|
847
1137
|
return acc2;
|
|
848
1138
|
}, acc);
|
|
849
1139
|
}
|
|
1140
|
+
if (defaultSupercedesUndefined && (!isNil(defaults) && isNil(formData) || typeof formData === "number" && isNaN(formData)) || overrideFormDataWithDefaults && !isNil(formData)) {
|
|
1141
|
+
return defaults;
|
|
1142
|
+
}
|
|
850
1143
|
return formData;
|
|
851
1144
|
}
|
|
852
1145
|
|
|
853
1146
|
// src/mergeObjects.ts
|
|
854
1147
|
function mergeObjects(obj1, obj2, concatArrays = false) {
|
|
855
|
-
return Object.keys(obj2).reduce(
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1148
|
+
return Object.keys(obj2).reduce(
|
|
1149
|
+
(acc, key) => {
|
|
1150
|
+
const left = obj1 ? obj1[key] : {}, right = obj2[key];
|
|
1151
|
+
if (obj1 && key in obj1 && isObject(right)) {
|
|
1152
|
+
acc[key] = mergeObjects(left, right, concatArrays);
|
|
1153
|
+
} else if (concatArrays && Array.isArray(left) && Array.isArray(right)) {
|
|
1154
|
+
let toMerge = right;
|
|
1155
|
+
if (concatArrays === "preventDuplicates") {
|
|
1156
|
+
toMerge = right.reduce((result, value) => {
|
|
1157
|
+
if (!left.includes(value)) {
|
|
1158
|
+
result.push(value);
|
|
1159
|
+
}
|
|
1160
|
+
return result;
|
|
1161
|
+
}, []);
|
|
1162
|
+
}
|
|
1163
|
+
acc[key] = left.concat(toMerge);
|
|
1164
|
+
} else {
|
|
1165
|
+
acc[key] = right;
|
|
868
1166
|
}
|
|
869
|
-
acc
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
return acc;
|
|
874
|
-
}, Object.assign({}, obj1));
|
|
1167
|
+
return acc;
|
|
1168
|
+
},
|
|
1169
|
+
Object.assign({}, obj1)
|
|
1170
|
+
);
|
|
875
1171
|
}
|
|
876
1172
|
|
|
877
1173
|
// src/isConstant.ts
|
|
@@ -880,8 +1176,8 @@
|
|
|
880
1176
|
}
|
|
881
1177
|
|
|
882
1178
|
// src/schema/isSelect.ts
|
|
883
|
-
function isSelect(validator, theSchema, rootSchema = {}) {
|
|
884
|
-
const schema = retrieveSchema(validator, theSchema, rootSchema, void 0);
|
|
1179
|
+
function isSelect(validator, theSchema, rootSchema = {}, experimental_customMergeAllOf) {
|
|
1180
|
+
const schema = retrieveSchema(validator, theSchema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
885
1181
|
const altSchemas = schema.oneOf || schema.anyOf;
|
|
886
1182
|
if (Array.isArray(schema.enum)) {
|
|
887
1183
|
return true;
|
|
@@ -893,14 +1189,79 @@
|
|
|
893
1189
|
}
|
|
894
1190
|
|
|
895
1191
|
// src/schema/isMultiSelect.ts
|
|
896
|
-
function isMultiSelect(validator, schema, rootSchema) {
|
|
1192
|
+
function isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) {
|
|
897
1193
|
if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
|
|
898
1194
|
return false;
|
|
899
1195
|
}
|
|
900
|
-
return isSelect(validator, schema.items, rootSchema);
|
|
1196
|
+
return isSelect(validator, schema.items, rootSchema, experimental_customMergeAllOf);
|
|
1197
|
+
}
|
|
1198
|
+
function constIsAjvDataReference(schema) {
|
|
1199
|
+
const schemaConst = schema[CONST_KEY];
|
|
1200
|
+
const schemaType = getSchemaType(schema);
|
|
1201
|
+
return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== "object" && schemaType !== "array";
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
// src/toConstant.ts
|
|
1205
|
+
function toConstant(schema) {
|
|
1206
|
+
if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
|
|
1207
|
+
return schema.enum[0];
|
|
1208
|
+
}
|
|
1209
|
+
if (CONST_KEY in schema) {
|
|
1210
|
+
return schema.const;
|
|
1211
|
+
}
|
|
1212
|
+
throw new Error("schema cannot be inferred as a constant");
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// src/optionsList.ts
|
|
1216
|
+
function optionsList(schema, uiSchema) {
|
|
1217
|
+
if (schema.enum) {
|
|
1218
|
+
let enumNames;
|
|
1219
|
+
if (uiSchema) {
|
|
1220
|
+
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
1221
|
+
enumNames = uiEnumNames;
|
|
1222
|
+
}
|
|
1223
|
+
return schema.enum.map((value, i) => {
|
|
1224
|
+
const label = enumNames?.[i] || String(value);
|
|
1225
|
+
return { label, value };
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
let altSchemas = void 0;
|
|
1229
|
+
let altUiSchemas = void 0;
|
|
1230
|
+
if (schema.anyOf) {
|
|
1231
|
+
altSchemas = schema.anyOf;
|
|
1232
|
+
altUiSchemas = uiSchema?.anyOf;
|
|
1233
|
+
} else if (schema.oneOf) {
|
|
1234
|
+
altSchemas = schema.oneOf;
|
|
1235
|
+
altUiSchemas = uiSchema?.oneOf;
|
|
1236
|
+
}
|
|
1237
|
+
let selectorField = getDiscriminatorFieldFromSchema(schema);
|
|
1238
|
+
if (uiSchema) {
|
|
1239
|
+
const { optionsSchemaSelector = selectorField } = getUiOptions(uiSchema);
|
|
1240
|
+
selectorField = optionsSchemaSelector;
|
|
1241
|
+
}
|
|
1242
|
+
return altSchemas && altSchemas.map((aSchemaDef, index) => {
|
|
1243
|
+
const { title } = getUiOptions(altUiSchemas?.[index]);
|
|
1244
|
+
const aSchema = aSchemaDef;
|
|
1245
|
+
let value;
|
|
1246
|
+
let label = title;
|
|
1247
|
+
if (selectorField) {
|
|
1248
|
+
const innerSchema = get12(aSchema, [PROPERTIES_KEY, selectorField], {});
|
|
1249
|
+
value = get12(innerSchema, DEFAULT_KEY, get12(innerSchema, CONST_KEY));
|
|
1250
|
+
label = label || innerSchema?.title || aSchema.title || String(value);
|
|
1251
|
+
} else {
|
|
1252
|
+
value = toConstant(aSchema);
|
|
1253
|
+
label = label || aSchema.title || String(value);
|
|
1254
|
+
}
|
|
1255
|
+
return {
|
|
1256
|
+
schema: aSchema,
|
|
1257
|
+
label,
|
|
1258
|
+
value
|
|
1259
|
+
};
|
|
1260
|
+
});
|
|
901
1261
|
}
|
|
902
1262
|
|
|
903
1263
|
// src/schema/getDefaultFormState.ts
|
|
1264
|
+
var PRIMITIVE_TYPES = ["string", "number", "integer", "boolean", "null"];
|
|
904
1265
|
function getInnerSchemaForArrayItem(schema, additionalItems = 0 /* Ignore */, idx = -1) {
|
|
905
1266
|
if (idx >= 0) {
|
|
906
1267
|
if (Array.isArray(schema.items) && idx < schema.items.length) {
|
|
@@ -917,13 +1278,13 @@
|
|
|
917
1278
|
}
|
|
918
1279
|
return {};
|
|
919
1280
|
}
|
|
920
|
-
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}) {
|
|
1281
|
+
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
921
1282
|
const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
|
|
922
|
-
if (includeUndefinedValues) {
|
|
1283
|
+
if (includeUndefinedValues || isConst) {
|
|
923
1284
|
obj[key] = computedDefault;
|
|
924
1285
|
} else if (emptyObjectFields !== "skipDefaults") {
|
|
1286
|
+
const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
|
|
925
1287
|
if (isObject(computedDefault)) {
|
|
926
|
-
const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
|
|
927
1288
|
if (emptyObjectFields === "skipEmptyDefaults") {
|
|
928
1289
|
if (!isEmpty(computedDefault)) {
|
|
929
1290
|
obj[key] = computedDefault;
|
|
@@ -934,30 +1295,37 @@
|
|
|
934
1295
|
} else if (
|
|
935
1296
|
// Store computedDefault if it's a defined primitive (e.g., true) and satisfies certain conditions
|
|
936
1297
|
// Condition 1: computedDefault is not undefined
|
|
937
|
-
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults)
|
|
938
|
-
|
|
1298
|
+
// Condition 2: If emptyObjectFields is 'populateAllDefaults' or 'skipEmptyDefaults)
|
|
1299
|
+
// Or if isSelfOrParentRequired is 'true' and the key is a required field
|
|
1300
|
+
computedDefault !== void 0 && (emptyObjectFields === "populateAllDefaults" || emptyObjectFields === "skipEmptyDefaults" || isSelfOrParentRequired && requiredFields.includes(key))
|
|
939
1301
|
) {
|
|
940
1302
|
obj[key] = computedDefault;
|
|
941
1303
|
}
|
|
942
1304
|
}
|
|
943
1305
|
}
|
|
944
|
-
function computeDefaults(validator, rawSchema, {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1306
|
+
function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
1307
|
+
const {
|
|
1308
|
+
parentDefaults,
|
|
1309
|
+
rawFormData,
|
|
1310
|
+
rootSchema = {},
|
|
1311
|
+
includeUndefinedValues = false,
|
|
1312
|
+
_recurseList = [],
|
|
1313
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1314
|
+
experimental_customMergeAllOf = void 0,
|
|
1315
|
+
required,
|
|
1316
|
+
shouldMergeDefaultsIntoFormData = false
|
|
1317
|
+
} = computeDefaultsProps;
|
|
953
1318
|
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
954
1319
|
const schema = isObject(rawSchema) ? rawSchema : {};
|
|
955
1320
|
let defaults = parentDefaults;
|
|
956
1321
|
let schemaToCompute = null;
|
|
1322
|
+
let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;
|
|
957
1323
|
let updatedRecurseList = _recurseList;
|
|
958
|
-
if (
|
|
1324
|
+
if (schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(schema)) {
|
|
1325
|
+
defaults = schema[CONST_KEY];
|
|
1326
|
+
} else if (isObject(defaults) && isObject(schema.default)) {
|
|
959
1327
|
defaults = mergeObjects(defaults, schema.default);
|
|
960
|
-
} else if (DEFAULT_KEY in schema) {
|
|
1328
|
+
} else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY]) {
|
|
961
1329
|
defaults = schema.default;
|
|
962
1330
|
} else if (REF_KEY in schema) {
|
|
963
1331
|
const refName = schema[REF_KEY];
|
|
@@ -966,7 +1334,19 @@
|
|
|
966
1334
|
schemaToCompute = findSchemaDefinition(refName, rootSchema);
|
|
967
1335
|
}
|
|
968
1336
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
969
|
-
const
|
|
1337
|
+
const defaultFormData = {
|
|
1338
|
+
...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults),
|
|
1339
|
+
...formData
|
|
1340
|
+
};
|
|
1341
|
+
const resolvedSchema = resolveDependencies(
|
|
1342
|
+
validator,
|
|
1343
|
+
schema,
|
|
1344
|
+
rootSchema,
|
|
1345
|
+
false,
|
|
1346
|
+
[],
|
|
1347
|
+
defaultFormData,
|
|
1348
|
+
experimental_customMergeAllOf
|
|
1349
|
+
);
|
|
970
1350
|
schemaToCompute = resolvedSchema[0];
|
|
971
1351
|
} else if (isFixedItems(schema)) {
|
|
972
1352
|
defaults = schema.items.map(
|
|
@@ -975,9 +1355,11 @@
|
|
|
975
1355
|
includeUndefinedValues,
|
|
976
1356
|
_recurseList,
|
|
977
1357
|
experimental_defaultFormStateBehavior,
|
|
1358
|
+
experimental_customMergeAllOf,
|
|
978
1359
|
parentDefaults: Array.isArray(parentDefaults) ? parentDefaults[idx] : void 0,
|
|
979
1360
|
rawFormData: formData,
|
|
980
|
-
required
|
|
1361
|
+
required,
|
|
1362
|
+
shouldMergeDefaultsIntoFormData
|
|
981
1363
|
})
|
|
982
1364
|
);
|
|
983
1365
|
} else if (ONE_OF_KEY in schema) {
|
|
@@ -986,13 +1368,21 @@
|
|
|
986
1368
|
return void 0;
|
|
987
1369
|
}
|
|
988
1370
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
1371
|
+
const { type = "null" } = remaining;
|
|
1372
|
+
if (!Array.isArray(type) && PRIMITIVE_TYPES.includes(type) && experimental_dfsb_to_compute?.constAsDefaults === "skipOneOf") {
|
|
1373
|
+
experimental_dfsb_to_compute = {
|
|
1374
|
+
...experimental_dfsb_to_compute,
|
|
1375
|
+
constAsDefaults: "never"
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
989
1378
|
schemaToCompute = oneOf[getClosestMatchingOption(
|
|
990
1379
|
validator,
|
|
991
1380
|
rootSchema,
|
|
992
|
-
|
|
1381
|
+
rawFormData ?? schema.default,
|
|
993
1382
|
oneOf,
|
|
994
1383
|
0,
|
|
995
|
-
discriminator
|
|
1384
|
+
discriminator,
|
|
1385
|
+
experimental_customMergeAllOf
|
|
996
1386
|
)];
|
|
997
1387
|
schemaToCompute = mergeSchemas(remaining, schemaToCompute);
|
|
998
1388
|
} else if (ANY_OF_KEY in schema) {
|
|
@@ -1004,171 +1394,270 @@
|
|
|
1004
1394
|
schemaToCompute = anyOf[getClosestMatchingOption(
|
|
1005
1395
|
validator,
|
|
1006
1396
|
rootSchema,
|
|
1007
|
-
|
|
1397
|
+
rawFormData ?? schema.default,
|
|
1008
1398
|
anyOf,
|
|
1009
1399
|
0,
|
|
1010
|
-
discriminator
|
|
1400
|
+
discriminator,
|
|
1401
|
+
experimental_customMergeAllOf
|
|
1011
1402
|
)];
|
|
1012
1403
|
schemaToCompute = mergeSchemas(remaining, schemaToCompute);
|
|
1013
1404
|
}
|
|
1014
|
-
if (schemaToCompute) {
|
|
1015
|
-
return computeDefaults(validator, schemaToCompute, {
|
|
1405
|
+
if (schemaToCompute) {
|
|
1406
|
+
return computeDefaults(validator, schemaToCompute, {
|
|
1407
|
+
rootSchema,
|
|
1408
|
+
includeUndefinedValues,
|
|
1409
|
+
_recurseList: updatedRecurseList,
|
|
1410
|
+
experimental_defaultFormStateBehavior: experimental_dfsb_to_compute,
|
|
1411
|
+
experimental_customMergeAllOf,
|
|
1412
|
+
parentDefaults: defaults,
|
|
1413
|
+
rawFormData: formData,
|
|
1414
|
+
required,
|
|
1415
|
+
shouldMergeDefaultsIntoFormData
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
if (defaults === void 0) {
|
|
1419
|
+
defaults = schema.default;
|
|
1420
|
+
}
|
|
1421
|
+
const defaultBasedOnSchemaType = getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults);
|
|
1422
|
+
let defaultsWithFormData = defaultBasedOnSchemaType ?? defaults;
|
|
1423
|
+
if (shouldMergeDefaultsIntoFormData) {
|
|
1424
|
+
const { arrayMinItems = {} } = experimental_defaultFormStateBehavior || {};
|
|
1425
|
+
const { mergeExtraDefaults } = arrayMinItems;
|
|
1426
|
+
const matchingFormData = ensureFormDataMatchingSchema(
|
|
1427
|
+
validator,
|
|
1428
|
+
schema,
|
|
1429
|
+
rootSchema,
|
|
1430
|
+
rawFormData,
|
|
1431
|
+
experimental_defaultFormStateBehavior,
|
|
1432
|
+
experimental_customMergeAllOf
|
|
1433
|
+
);
|
|
1434
|
+
if (!isObject(rawFormData) || ALL_OF_KEY in schema) {
|
|
1435
|
+
defaultsWithFormData = mergeDefaultsWithFormData(
|
|
1436
|
+
defaultsWithFormData,
|
|
1437
|
+
matchingFormData,
|
|
1438
|
+
mergeExtraDefaults,
|
|
1439
|
+
true
|
|
1440
|
+
);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
return defaultsWithFormData;
|
|
1444
|
+
}
|
|
1445
|
+
function ensureFormDataMatchingSchema(validator, schema, rootSchema, formData, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
1446
|
+
const isSelectField = !isConstant(schema) && isSelect(validator, schema, rootSchema, experimental_customMergeAllOf);
|
|
1447
|
+
let validFormData = formData;
|
|
1448
|
+
if (isSelectField) {
|
|
1449
|
+
const getOptionsList = optionsList(schema);
|
|
1450
|
+
const isValid = getOptionsList?.some((option) => deepEquals(option.value, formData));
|
|
1451
|
+
validFormData = isValid ? formData : void 0;
|
|
1452
|
+
}
|
|
1453
|
+
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
1454
|
+
if (constTakesPrecedence) {
|
|
1455
|
+
validFormData = schema.const;
|
|
1456
|
+
}
|
|
1457
|
+
return validFormData;
|
|
1458
|
+
}
|
|
1459
|
+
function getObjectDefaults(validator, rawSchema, {
|
|
1460
|
+
rawFormData,
|
|
1461
|
+
rootSchema = {},
|
|
1462
|
+
includeUndefinedValues = false,
|
|
1463
|
+
_recurseList = [],
|
|
1464
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1465
|
+
experimental_customMergeAllOf = void 0,
|
|
1466
|
+
required,
|
|
1467
|
+
shouldMergeDefaultsIntoFormData
|
|
1468
|
+
} = {}, defaults) {
|
|
1469
|
+
{
|
|
1470
|
+
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
1471
|
+
const schema = rawSchema;
|
|
1472
|
+
const retrievedSchema = experimental_defaultFormStateBehavior?.allOf === "populateDefaults" && ALL_OF_KEY in schema ? retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf) : schema;
|
|
1473
|
+
const parentConst = retrievedSchema[CONST_KEY];
|
|
1474
|
+
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1475
|
+
(acc, key) => {
|
|
1476
|
+
const propertySchema = get12(retrievedSchema, [PROPERTIES_KEY, key], {});
|
|
1477
|
+
const hasParentConst = isObject(parentConst) && parentConst[key] !== void 0;
|
|
1478
|
+
const hasConst = (isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst) && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(propertySchema);
|
|
1479
|
+
const computedDefault = computeDefaults(validator, propertySchema, {
|
|
1480
|
+
rootSchema,
|
|
1481
|
+
_recurseList,
|
|
1482
|
+
experimental_defaultFormStateBehavior,
|
|
1483
|
+
experimental_customMergeAllOf,
|
|
1484
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1485
|
+
parentDefaults: get12(defaults, [key]),
|
|
1486
|
+
rawFormData: get12(formData, [key]),
|
|
1487
|
+
required: retrievedSchema.required?.includes(key),
|
|
1488
|
+
shouldMergeDefaultsIntoFormData
|
|
1489
|
+
});
|
|
1490
|
+
maybeAddDefaultToObject(
|
|
1491
|
+
acc,
|
|
1492
|
+
key,
|
|
1493
|
+
computedDefault,
|
|
1494
|
+
includeUndefinedValues,
|
|
1495
|
+
required,
|
|
1496
|
+
retrievedSchema.required,
|
|
1497
|
+
experimental_defaultFormStateBehavior,
|
|
1498
|
+
hasConst
|
|
1499
|
+
);
|
|
1500
|
+
return acc;
|
|
1501
|
+
},
|
|
1502
|
+
{}
|
|
1503
|
+
);
|
|
1504
|
+
if (retrievedSchema.additionalProperties) {
|
|
1505
|
+
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1506
|
+
const keys2 = /* @__PURE__ */ new Set();
|
|
1507
|
+
if (isObject(defaults)) {
|
|
1508
|
+
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys2.add(key));
|
|
1509
|
+
}
|
|
1510
|
+
const formDataRequired = [];
|
|
1511
|
+
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1512
|
+
keys2.add(key);
|
|
1513
|
+
formDataRequired.push(key);
|
|
1514
|
+
});
|
|
1515
|
+
keys2.forEach((key) => {
|
|
1516
|
+
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1517
|
+
rootSchema,
|
|
1518
|
+
_recurseList,
|
|
1519
|
+
experimental_defaultFormStateBehavior,
|
|
1520
|
+
experimental_customMergeAllOf,
|
|
1521
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1522
|
+
parentDefaults: get12(defaults, [key]),
|
|
1523
|
+
rawFormData: get12(formData, [key]),
|
|
1524
|
+
required: retrievedSchema.required?.includes(key),
|
|
1525
|
+
shouldMergeDefaultsIntoFormData
|
|
1526
|
+
});
|
|
1527
|
+
maybeAddDefaultToObject(
|
|
1528
|
+
objectDefaults,
|
|
1529
|
+
key,
|
|
1530
|
+
computedDefault,
|
|
1531
|
+
includeUndefinedValues,
|
|
1532
|
+
required,
|
|
1533
|
+
formDataRequired
|
|
1534
|
+
);
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
return objectDefaults;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function getArrayDefaults(validator, rawSchema, {
|
|
1541
|
+
rawFormData,
|
|
1542
|
+
rootSchema = {},
|
|
1543
|
+
_recurseList = [],
|
|
1544
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1545
|
+
experimental_customMergeAllOf = void 0,
|
|
1546
|
+
required,
|
|
1547
|
+
shouldMergeDefaultsIntoFormData
|
|
1548
|
+
} = {}, defaults) {
|
|
1549
|
+
const schema = rawSchema;
|
|
1550
|
+
const arrayMinItemsStateBehavior = experimental_defaultFormStateBehavior?.arrayMinItems ?? {};
|
|
1551
|
+
const { populate: arrayMinItemsPopulate, mergeExtraDefaults: arrayMergeExtraDefaults } = arrayMinItemsStateBehavior;
|
|
1552
|
+
const neverPopulate = arrayMinItemsPopulate === "never";
|
|
1553
|
+
const ignoreMinItemsFlagSet = arrayMinItemsPopulate === "requiredOnly";
|
|
1554
|
+
const isPopulateAll = arrayMinItemsPopulate === "all" || !neverPopulate && !ignoreMinItemsFlagSet;
|
|
1555
|
+
const computeSkipPopulate = arrayMinItemsStateBehavior?.computeSkipPopulate ?? (() => false);
|
|
1556
|
+
const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === "skipEmptyDefaults";
|
|
1557
|
+
const emptyDefault = isSkipEmptyDefaults ? void 0 : [];
|
|
1558
|
+
if (Array.isArray(defaults)) {
|
|
1559
|
+
defaults = defaults.map((item, idx) => {
|
|
1560
|
+
const schemaItem = getInnerSchemaForArrayItem(schema, 2 /* Fallback */, idx);
|
|
1561
|
+
return computeDefaults(validator, schemaItem, {
|
|
1562
|
+
rootSchema,
|
|
1563
|
+
_recurseList,
|
|
1564
|
+
experimental_defaultFormStateBehavior,
|
|
1565
|
+
experimental_customMergeAllOf,
|
|
1566
|
+
parentDefaults: item,
|
|
1567
|
+
required,
|
|
1568
|
+
shouldMergeDefaultsIntoFormData
|
|
1569
|
+
});
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
if (Array.isArray(rawFormData)) {
|
|
1573
|
+
const schemaItem = getInnerSchemaForArrayItem(schema);
|
|
1574
|
+
if (neverPopulate) {
|
|
1575
|
+
defaults = rawFormData;
|
|
1576
|
+
} else {
|
|
1577
|
+
const itemDefaults = rawFormData.map((item, idx) => {
|
|
1578
|
+
return computeDefaults(validator, schemaItem, {
|
|
1579
|
+
rootSchema,
|
|
1580
|
+
_recurseList,
|
|
1581
|
+
experimental_defaultFormStateBehavior,
|
|
1582
|
+
experimental_customMergeAllOf,
|
|
1583
|
+
rawFormData: item,
|
|
1584
|
+
parentDefaults: get12(defaults, [idx]),
|
|
1585
|
+
required,
|
|
1586
|
+
shouldMergeDefaultsIntoFormData
|
|
1587
|
+
});
|
|
1588
|
+
});
|
|
1589
|
+
const mergeExtraDefaults = (ignoreMinItemsFlagSet && required || isPopulateAll) && arrayMergeExtraDefaults;
|
|
1590
|
+
defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
const hasConst = isObject(schema) && CONST_KEY in schema && experimental_defaultFormStateBehavior?.constAsDefaults !== "never";
|
|
1594
|
+
if (hasConst === false) {
|
|
1595
|
+
if (neverPopulate) {
|
|
1596
|
+
return defaults ?? emptyDefault;
|
|
1597
|
+
}
|
|
1598
|
+
if (ignoreMinItemsFlagSet && !required) {
|
|
1599
|
+
return defaults ? defaults : void 0;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
|
|
1603
|
+
if (!schema.minItems || isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
|
|
1604
|
+
return defaults ? defaults : emptyDefault;
|
|
1605
|
+
}
|
|
1606
|
+
const defaultEntries = defaults || [];
|
|
1607
|
+
const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
|
|
1608
|
+
const fillerDefault = fillerSchema.default;
|
|
1609
|
+
const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
|
|
1610
|
+
computeDefaults(validator, fillerSchema, {
|
|
1611
|
+
parentDefaults: fillerDefault,
|
|
1016
1612
|
rootSchema,
|
|
1017
|
-
|
|
1018
|
-
_recurseList: updatedRecurseList,
|
|
1613
|
+
_recurseList,
|
|
1019
1614
|
experimental_defaultFormStateBehavior,
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
})
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
switch (getSchemaType(
|
|
1615
|
+
experimental_customMergeAllOf,
|
|
1616
|
+
required,
|
|
1617
|
+
shouldMergeDefaultsIntoFormData
|
|
1618
|
+
})
|
|
1619
|
+
);
|
|
1620
|
+
return defaultEntries.concat(fillerEntries);
|
|
1621
|
+
}
|
|
1622
|
+
function getDefaultBasedOnSchemaType(validator, rawSchema, computeDefaultsProps = {}, defaults) {
|
|
1623
|
+
switch (getSchemaType(rawSchema)) {
|
|
1624
|
+
// We need to recurse for object schema inner default values.
|
|
1029
1625
|
case "object": {
|
|
1030
|
-
|
|
1031
|
-
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1032
|
-
(acc, key) => {
|
|
1033
|
-
const computedDefault = computeDefaults(validator, get8(retrievedSchema, [PROPERTIES_KEY, key]), {
|
|
1034
|
-
rootSchema,
|
|
1035
|
-
_recurseList,
|
|
1036
|
-
experimental_defaultFormStateBehavior,
|
|
1037
|
-
includeUndefinedValues: includeUndefinedValues === true,
|
|
1038
|
-
parentDefaults: get8(defaults, [key]),
|
|
1039
|
-
rawFormData: get8(formData, [key]),
|
|
1040
|
-
required: retrievedSchema.required?.includes(key)
|
|
1041
|
-
});
|
|
1042
|
-
maybeAddDefaultToObject(
|
|
1043
|
-
acc,
|
|
1044
|
-
key,
|
|
1045
|
-
computedDefault,
|
|
1046
|
-
includeUndefinedValues,
|
|
1047
|
-
required,
|
|
1048
|
-
retrievedSchema.required,
|
|
1049
|
-
experimental_defaultFormStateBehavior
|
|
1050
|
-
);
|
|
1051
|
-
return acc;
|
|
1052
|
-
},
|
|
1053
|
-
{}
|
|
1054
|
-
);
|
|
1055
|
-
if (retrievedSchema.additionalProperties) {
|
|
1056
|
-
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1057
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1058
|
-
if (isObject(defaults)) {
|
|
1059
|
-
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys.add(key));
|
|
1060
|
-
}
|
|
1061
|
-
const formDataRequired = [];
|
|
1062
|
-
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1063
|
-
keys.add(key);
|
|
1064
|
-
formDataRequired.push(key);
|
|
1065
|
-
});
|
|
1066
|
-
keys.forEach((key) => {
|
|
1067
|
-
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1068
|
-
rootSchema,
|
|
1069
|
-
_recurseList,
|
|
1070
|
-
experimental_defaultFormStateBehavior,
|
|
1071
|
-
includeUndefinedValues: includeUndefinedValues === true,
|
|
1072
|
-
parentDefaults: get8(defaults, [key]),
|
|
1073
|
-
rawFormData: get8(formData, [key]),
|
|
1074
|
-
required: retrievedSchema.required?.includes(key)
|
|
1075
|
-
});
|
|
1076
|
-
maybeAddDefaultToObject(
|
|
1077
|
-
objectDefaults,
|
|
1078
|
-
key,
|
|
1079
|
-
computedDefault,
|
|
1080
|
-
includeUndefinedValues,
|
|
1081
|
-
required,
|
|
1082
|
-
formDataRequired
|
|
1083
|
-
);
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
return objectDefaults;
|
|
1626
|
+
return getObjectDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1087
1627
|
}
|
|
1088
1628
|
case "array": {
|
|
1089
|
-
|
|
1090
|
-
const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "requiredOnly";
|
|
1091
|
-
const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === "skipEmptyDefaults";
|
|
1092
|
-
const computeSkipPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.computeSkipPopulate ?? (() => false);
|
|
1093
|
-
const emptyDefault = isSkipEmptyDefaults ? void 0 : [];
|
|
1094
|
-
if (Array.isArray(defaults)) {
|
|
1095
|
-
defaults = defaults.map((item, idx) => {
|
|
1096
|
-
const schemaItem = getInnerSchemaForArrayItem(schema, 2 /* Fallback */, idx);
|
|
1097
|
-
return computeDefaults(validator, schemaItem, {
|
|
1098
|
-
rootSchema,
|
|
1099
|
-
_recurseList,
|
|
1100
|
-
experimental_defaultFormStateBehavior,
|
|
1101
|
-
parentDefaults: item,
|
|
1102
|
-
required
|
|
1103
|
-
});
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
if (Array.isArray(rawFormData)) {
|
|
1107
|
-
const schemaItem = getInnerSchemaForArrayItem(schema);
|
|
1108
|
-
if (neverPopulate) {
|
|
1109
|
-
defaults = rawFormData;
|
|
1110
|
-
} else {
|
|
1111
|
-
defaults = rawFormData.map((item, idx) => {
|
|
1112
|
-
return computeDefaults(validator, schemaItem, {
|
|
1113
|
-
rootSchema,
|
|
1114
|
-
_recurseList,
|
|
1115
|
-
experimental_defaultFormStateBehavior,
|
|
1116
|
-
rawFormData: item,
|
|
1117
|
-
parentDefaults: get8(defaults, [idx]),
|
|
1118
|
-
required
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
if (neverPopulate) {
|
|
1124
|
-
return defaults ?? emptyDefault;
|
|
1125
|
-
}
|
|
1126
|
-
if (ignoreMinItemsFlagSet && !required) {
|
|
1127
|
-
return defaults ? defaults : void 0;
|
|
1128
|
-
}
|
|
1129
|
-
const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
|
|
1130
|
-
if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
|
|
1131
|
-
return defaults ? defaults : emptyDefault;
|
|
1132
|
-
}
|
|
1133
|
-
const defaultEntries = defaults || [];
|
|
1134
|
-
const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
|
|
1135
|
-
const fillerDefault = fillerSchema.default;
|
|
1136
|
-
const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
|
|
1137
|
-
computeDefaults(validator, fillerSchema, {
|
|
1138
|
-
parentDefaults: fillerDefault,
|
|
1139
|
-
rootSchema,
|
|
1140
|
-
_recurseList,
|
|
1141
|
-
experimental_defaultFormStateBehavior,
|
|
1142
|
-
required
|
|
1143
|
-
})
|
|
1144
|
-
);
|
|
1145
|
-
return defaultEntries.concat(fillerEntries);
|
|
1629
|
+
return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1146
1630
|
}
|
|
1147
1631
|
}
|
|
1148
|
-
return defaults;
|
|
1149
1632
|
}
|
|
1150
|
-
function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior) {
|
|
1633
|
+
function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
1151
1634
|
if (!isObject(theSchema)) {
|
|
1152
1635
|
throw new Error("Invalid schema: " + theSchema);
|
|
1153
1636
|
}
|
|
1154
|
-
const schema = retrieveSchema(validator, theSchema, rootSchema, formData);
|
|
1637
|
+
const schema = retrieveSchema(validator, theSchema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1155
1638
|
const defaults = computeDefaults(validator, schema, {
|
|
1156
1639
|
rootSchema,
|
|
1157
1640
|
includeUndefinedValues,
|
|
1158
1641
|
experimental_defaultFormStateBehavior,
|
|
1159
|
-
|
|
1642
|
+
experimental_customMergeAllOf,
|
|
1643
|
+
rawFormData: formData,
|
|
1644
|
+
shouldMergeDefaultsIntoFormData: true
|
|
1160
1645
|
});
|
|
1161
|
-
if (formData
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1646
|
+
if (isObject(formData) || Array.isArray(formData)) {
|
|
1647
|
+
const { mergeDefaultsIntoFormData } = experimental_defaultFormStateBehavior || {};
|
|
1648
|
+
const defaultSupercedesUndefined = mergeDefaultsIntoFormData === "useDefaultIfFormDataUndefined";
|
|
1649
|
+
const result = mergeDefaultsWithFormData(
|
|
1650
|
+
defaults,
|
|
1651
|
+
formData,
|
|
1652
|
+
true,
|
|
1653
|
+
// set to true to add any additional default array entries.
|
|
1654
|
+
defaultSupercedesUndefined,
|
|
1655
|
+
true
|
|
1656
|
+
// set to true to override formData with defaults if they exist.
|
|
1657
|
+
);
|
|
1658
|
+
return result;
|
|
1170
1659
|
}
|
|
1171
|
-
return
|
|
1660
|
+
return defaults;
|
|
1172
1661
|
}
|
|
1173
1662
|
|
|
1174
1663
|
// src/isCustomWidget.ts
|
|
@@ -1181,25 +1670,31 @@
|
|
|
1181
1670
|
}
|
|
1182
1671
|
|
|
1183
1672
|
// src/schema/isFilesArray.ts
|
|
1184
|
-
function isFilesArray(validator, schema, uiSchema = {}, rootSchema) {
|
|
1673
|
+
function isFilesArray(validator, schema, uiSchema = {}, rootSchema, experimental_customMergeAllOf) {
|
|
1185
1674
|
if (uiSchema[UI_WIDGET_KEY] === "files") {
|
|
1186
1675
|
return true;
|
|
1187
1676
|
}
|
|
1188
1677
|
if (schema.items) {
|
|
1189
|
-
const itemsSchema = retrieveSchema(
|
|
1678
|
+
const itemsSchema = retrieveSchema(
|
|
1679
|
+
validator,
|
|
1680
|
+
schema.items,
|
|
1681
|
+
rootSchema,
|
|
1682
|
+
void 0,
|
|
1683
|
+
experimental_customMergeAllOf
|
|
1684
|
+
);
|
|
1190
1685
|
return itemsSchema.type === "string" && itemsSchema.format === "data-url";
|
|
1191
1686
|
}
|
|
1192
1687
|
return false;
|
|
1193
1688
|
}
|
|
1194
1689
|
|
|
1195
1690
|
// src/schema/getDisplayLabel.ts
|
|
1196
|
-
function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions) {
|
|
1691
|
+
function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOptions, experimental_customMergeAllOf) {
|
|
1197
1692
|
const uiOptions = getUiOptions(uiSchema, globalOptions);
|
|
1198
1693
|
const { label = true } = uiOptions;
|
|
1199
1694
|
let displayLabel = !!label;
|
|
1200
1695
|
const schemaType = getSchemaType(schema);
|
|
1201
1696
|
if (schemaType === "array") {
|
|
1202
|
-
displayLabel = isMultiSelect(validator, schema, rootSchema) || isFilesArray(validator, schema, uiSchema, rootSchema) || isCustomWidget(uiSchema);
|
|
1697
|
+
displayLabel = isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || isFilesArray(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) || isCustomWidget(uiSchema);
|
|
1203
1698
|
}
|
|
1204
1699
|
if (schemaType === "object") {
|
|
1205
1700
|
displayLabel = false;
|
|
@@ -1212,48 +1707,47 @@
|
|
|
1212
1707
|
}
|
|
1213
1708
|
return displayLabel;
|
|
1214
1709
|
}
|
|
1215
|
-
function mergeValidationData(validator, validationData, additionalErrorSchema) {
|
|
1216
|
-
if (!additionalErrorSchema) {
|
|
1217
|
-
return validationData;
|
|
1218
|
-
}
|
|
1219
|
-
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
1220
|
-
let errors = validator.toErrorList(additionalErrorSchema);
|
|
1221
|
-
let errorSchema = additionalErrorSchema;
|
|
1222
|
-
if (!isEmpty(oldErrorSchema)) {
|
|
1223
|
-
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
|
|
1224
|
-
errors = [...oldErrors].concat(errors);
|
|
1225
|
-
}
|
|
1226
|
-
return { errorSchema, errors };
|
|
1227
|
-
}
|
|
1228
1710
|
var NO_VALUE = Symbol("no Value");
|
|
1229
|
-
function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}) {
|
|
1711
|
+
function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
|
|
1230
1712
|
let newFormData;
|
|
1231
|
-
if (
|
|
1713
|
+
if (has5(newSchema, PROPERTIES_KEY)) {
|
|
1232
1714
|
const removeOldSchemaData = {};
|
|
1233
|
-
if (
|
|
1234
|
-
const properties =
|
|
1715
|
+
if (has5(oldSchema, PROPERTIES_KEY)) {
|
|
1716
|
+
const properties = get12(oldSchema, PROPERTIES_KEY, {});
|
|
1235
1717
|
Object.keys(properties).forEach((key) => {
|
|
1236
|
-
if (
|
|
1718
|
+
if (has5(data, key)) {
|
|
1237
1719
|
removeOldSchemaData[key] = void 0;
|
|
1238
1720
|
}
|
|
1239
1721
|
});
|
|
1240
1722
|
}
|
|
1241
|
-
const
|
|
1723
|
+
const keys2 = Object.keys(get12(newSchema, PROPERTIES_KEY, {}));
|
|
1242
1724
|
const nestedData = {};
|
|
1243
|
-
|
|
1244
|
-
const formValue =
|
|
1245
|
-
let oldKeyedSchema =
|
|
1246
|
-
let newKeyedSchema =
|
|
1247
|
-
if (
|
|
1248
|
-
oldKeyedSchema = retrieveSchema(
|
|
1725
|
+
keys2.forEach((key) => {
|
|
1726
|
+
const formValue = get12(data, key);
|
|
1727
|
+
let oldKeyedSchema = get12(oldSchema, [PROPERTIES_KEY, key], {});
|
|
1728
|
+
let newKeyedSchema = get12(newSchema, [PROPERTIES_KEY, key], {});
|
|
1729
|
+
if (has5(oldKeyedSchema, REF_KEY)) {
|
|
1730
|
+
oldKeyedSchema = retrieveSchema(
|
|
1731
|
+
validator,
|
|
1732
|
+
oldKeyedSchema,
|
|
1733
|
+
rootSchema,
|
|
1734
|
+
formValue,
|
|
1735
|
+
experimental_customMergeAllOf
|
|
1736
|
+
);
|
|
1249
1737
|
}
|
|
1250
|
-
if (
|
|
1251
|
-
newKeyedSchema = retrieveSchema(
|
|
1738
|
+
if (has5(newKeyedSchema, REF_KEY)) {
|
|
1739
|
+
newKeyedSchema = retrieveSchema(
|
|
1740
|
+
validator,
|
|
1741
|
+
newKeyedSchema,
|
|
1742
|
+
rootSchema,
|
|
1743
|
+
formValue,
|
|
1744
|
+
experimental_customMergeAllOf
|
|
1745
|
+
);
|
|
1252
1746
|
}
|
|
1253
|
-
const oldSchemaTypeForKey =
|
|
1254
|
-
const newSchemaTypeForKey =
|
|
1747
|
+
const oldSchemaTypeForKey = get12(oldKeyedSchema, "type");
|
|
1748
|
+
const newSchemaTypeForKey = get12(newKeyedSchema, "type");
|
|
1255
1749
|
if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
|
|
1256
|
-
if (
|
|
1750
|
+
if (has5(removeOldSchemaData, key)) {
|
|
1257
1751
|
delete removeOldSchemaData[key];
|
|
1258
1752
|
}
|
|
1259
1753
|
if (newSchemaTypeForKey === "object" || newSchemaTypeForKey === "array" && Array.isArray(formValue)) {
|
|
@@ -1262,23 +1756,24 @@
|
|
|
1262
1756
|
rootSchema,
|
|
1263
1757
|
newKeyedSchema,
|
|
1264
1758
|
oldKeyedSchema,
|
|
1265
|
-
formValue
|
|
1759
|
+
formValue,
|
|
1760
|
+
experimental_customMergeAllOf
|
|
1266
1761
|
);
|
|
1267
1762
|
if (itemData !== void 0 || newSchemaTypeForKey === "array") {
|
|
1268
1763
|
nestedData[key] = itemData;
|
|
1269
1764
|
}
|
|
1270
1765
|
} else {
|
|
1271
|
-
const newOptionDefault =
|
|
1272
|
-
const oldOptionDefault =
|
|
1766
|
+
const newOptionDefault = get12(newKeyedSchema, "default", NO_VALUE);
|
|
1767
|
+
const oldOptionDefault = get12(oldKeyedSchema, "default", NO_VALUE);
|
|
1273
1768
|
if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
|
|
1274
1769
|
if (oldOptionDefault === formValue) {
|
|
1275
1770
|
removeOldSchemaData[key] = newOptionDefault;
|
|
1276
|
-
} else if (
|
|
1771
|
+
} else if (get12(newKeyedSchema, "readOnly") === true) {
|
|
1277
1772
|
removeOldSchemaData[key] = void 0;
|
|
1278
1773
|
}
|
|
1279
1774
|
}
|
|
1280
|
-
const newOptionConst =
|
|
1281
|
-
const oldOptionConst =
|
|
1775
|
+
const newOptionConst = get12(newKeyedSchema, "const", NO_VALUE);
|
|
1776
|
+
const oldOptionConst = get12(oldKeyedSchema, "const", NO_VALUE);
|
|
1282
1777
|
if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
|
|
1283
1778
|
removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
|
|
1284
1779
|
}
|
|
@@ -1290,20 +1785,32 @@
|
|
|
1290
1785
|
...removeOldSchemaData,
|
|
1291
1786
|
...nestedData
|
|
1292
1787
|
};
|
|
1293
|
-
} else if (
|
|
1294
|
-
let oldSchemaItems =
|
|
1295
|
-
let newSchemaItems =
|
|
1788
|
+
} else if (get12(oldSchema, "type") === "array" && get12(newSchema, "type") === "array" && Array.isArray(data)) {
|
|
1789
|
+
let oldSchemaItems = get12(oldSchema, "items");
|
|
1790
|
+
let newSchemaItems = get12(newSchema, "items");
|
|
1296
1791
|
if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
|
|
1297
|
-
if (
|
|
1298
|
-
oldSchemaItems = retrieveSchema(
|
|
1792
|
+
if (has5(oldSchemaItems, REF_KEY)) {
|
|
1793
|
+
oldSchemaItems = retrieveSchema(
|
|
1794
|
+
validator,
|
|
1795
|
+
oldSchemaItems,
|
|
1796
|
+
rootSchema,
|
|
1797
|
+
data,
|
|
1798
|
+
experimental_customMergeAllOf
|
|
1799
|
+
);
|
|
1299
1800
|
}
|
|
1300
|
-
if (
|
|
1301
|
-
newSchemaItems = retrieveSchema(
|
|
1801
|
+
if (has5(newSchemaItems, REF_KEY)) {
|
|
1802
|
+
newSchemaItems = retrieveSchema(
|
|
1803
|
+
validator,
|
|
1804
|
+
newSchemaItems,
|
|
1805
|
+
rootSchema,
|
|
1806
|
+
data,
|
|
1807
|
+
experimental_customMergeAllOf
|
|
1808
|
+
);
|
|
1302
1809
|
}
|
|
1303
|
-
const oldSchemaType =
|
|
1304
|
-
const newSchemaType =
|
|
1810
|
+
const oldSchemaType = get12(oldSchemaItems, "type");
|
|
1811
|
+
const newSchemaType = get12(newSchemaItems, "type");
|
|
1305
1812
|
if (!oldSchemaType || oldSchemaType === newSchemaType) {
|
|
1306
|
-
const maxItems =
|
|
1813
|
+
const maxItems = get12(newSchema, "maxItems", -1);
|
|
1307
1814
|
if (newSchemaType === "object") {
|
|
1308
1815
|
newFormData = data.reduce((newValue, aValue) => {
|
|
1309
1816
|
const itemValue = sanitizeDataForNewSchema(
|
|
@@ -1311,7 +1818,8 @@
|
|
|
1311
1818
|
rootSchema,
|
|
1312
1819
|
newSchemaItems,
|
|
1313
1820
|
oldSchemaItems,
|
|
1314
|
-
aValue
|
|
1821
|
+
aValue,
|
|
1822
|
+
experimental_customMergeAllOf
|
|
1315
1823
|
);
|
|
1316
1824
|
if (itemValue !== void 0 && (maxItems < 0 || newValue.length < maxItems)) {
|
|
1317
1825
|
newValue.push(itemValue);
|
|
@@ -1328,64 +1836,79 @@
|
|
|
1328
1836
|
}
|
|
1329
1837
|
return newFormData;
|
|
1330
1838
|
}
|
|
1331
|
-
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
if (
|
|
1839
|
+
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1840
|
+
const $id = id || idPrefix;
|
|
1841
|
+
const idSchema = { $id };
|
|
1842
|
+
if (typeof schema === "object") {
|
|
1843
|
+
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1844
|
+
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1845
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1846
|
+
if (sameSchemaIndex === -1) {
|
|
1847
|
+
return toIdSchemaInternal(
|
|
1848
|
+
validator,
|
|
1849
|
+
_schema,
|
|
1850
|
+
idPrefix,
|
|
1851
|
+
idSeparator,
|
|
1852
|
+
id,
|
|
1853
|
+
rootSchema,
|
|
1854
|
+
formData,
|
|
1855
|
+
_recurseList.concat(_schema),
|
|
1856
|
+
experimental_customMergeAllOf
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
if (ITEMS_KEY in schema && !get12(schema, [ITEMS_KEY, REF_KEY])) {
|
|
1336
1861
|
return toIdSchemaInternal(
|
|
1337
1862
|
validator,
|
|
1338
|
-
|
|
1863
|
+
get12(schema, ITEMS_KEY),
|
|
1339
1864
|
idPrefix,
|
|
1340
1865
|
idSeparator,
|
|
1341
1866
|
id,
|
|
1342
1867
|
rootSchema,
|
|
1343
1868
|
formData,
|
|
1344
|
-
_recurseList
|
|
1869
|
+
_recurseList,
|
|
1870
|
+
experimental_customMergeAllOf
|
|
1345
1871
|
);
|
|
1346
1872
|
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
const fieldId = idSchema[ID_KEY] + idSeparator + name;
|
|
1366
|
-
idSchema[name] = toIdSchemaInternal(
|
|
1367
|
-
validator,
|
|
1368
|
-
isObject(field) ? field : {},
|
|
1369
|
-
idPrefix,
|
|
1370
|
-
idSeparator,
|
|
1371
|
-
fieldId,
|
|
1372
|
-
rootSchema,
|
|
1373
|
-
// It's possible that formData is not an object -- this can happen if an
|
|
1374
|
-
// array item has just been added, but not populated with data yet
|
|
1375
|
-
get8(formData, [name]),
|
|
1376
|
-
_recurseList
|
|
1377
|
-
);
|
|
1873
|
+
if (getSchemaType(schema) === "object" && PROPERTIES_KEY in schema) {
|
|
1874
|
+
for (const name in schema.properties) {
|
|
1875
|
+
const field = schema[PROPERTIES_KEY][name];
|
|
1876
|
+
const fieldId = idSchema[ID_KEY] + idSeparator + name;
|
|
1877
|
+
idSchema[name] = toIdSchemaInternal(
|
|
1878
|
+
validator,
|
|
1879
|
+
field,
|
|
1880
|
+
idPrefix,
|
|
1881
|
+
idSeparator,
|
|
1882
|
+
fieldId,
|
|
1883
|
+
rootSchema,
|
|
1884
|
+
// It's possible that formData is not an object -- this can happen if an
|
|
1885
|
+
// array item has just been added, but not populated with data yet
|
|
1886
|
+
get12(formData, [name]),
|
|
1887
|
+
_recurseList,
|
|
1888
|
+
experimental_customMergeAllOf
|
|
1889
|
+
);
|
|
1890
|
+
}
|
|
1378
1891
|
}
|
|
1379
1892
|
}
|
|
1380
1893
|
return idSchema;
|
|
1381
1894
|
}
|
|
1382
|
-
function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "root", idSeparator = "_") {
|
|
1383
|
-
return toIdSchemaInternal(
|
|
1895
|
+
function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "root", idSeparator = "_", experimental_customMergeAllOf) {
|
|
1896
|
+
return toIdSchemaInternal(
|
|
1897
|
+
validator,
|
|
1898
|
+
schema,
|
|
1899
|
+
idPrefix,
|
|
1900
|
+
idSeparator,
|
|
1901
|
+
id,
|
|
1902
|
+
rootSchema,
|
|
1903
|
+
formData,
|
|
1904
|
+
void 0,
|
|
1905
|
+
experimental_customMergeAllOf
|
|
1906
|
+
);
|
|
1384
1907
|
}
|
|
1385
|
-
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
|
|
1908
|
+
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1386
1909
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1387
|
-
const _schema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
1388
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1910
|
+
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1911
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1389
1912
|
if (sameSchemaIndex === -1) {
|
|
1390
1913
|
return toPathSchemaInternal(
|
|
1391
1914
|
validator,
|
|
@@ -1393,7 +1916,8 @@
|
|
|
1393
1916
|
name,
|
|
1394
1917
|
rootSchema,
|
|
1395
1918
|
formData,
|
|
1396
|
-
_recurseList.concat(_schema)
|
|
1919
|
+
_recurseList.concat(_schema),
|
|
1920
|
+
experimental_customMergeAllOf
|
|
1397
1921
|
);
|
|
1398
1922
|
}
|
|
1399
1923
|
}
|
|
@@ -1403,15 +1927,31 @@
|
|
|
1403
1927
|
if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
|
|
1404
1928
|
const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
|
|
1405
1929
|
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
1406
|
-
const index = getClosestMatchingOption(
|
|
1930
|
+
const index = getClosestMatchingOption(
|
|
1931
|
+
validator,
|
|
1932
|
+
rootSchema,
|
|
1933
|
+
formData,
|
|
1934
|
+
xxxOf,
|
|
1935
|
+
0,
|
|
1936
|
+
discriminator,
|
|
1937
|
+
experimental_customMergeAllOf
|
|
1938
|
+
);
|
|
1407
1939
|
const _schema = xxxOf[index];
|
|
1408
1940
|
pathSchema = {
|
|
1409
1941
|
...pathSchema,
|
|
1410
|
-
...toPathSchemaInternal(
|
|
1942
|
+
...toPathSchemaInternal(
|
|
1943
|
+
validator,
|
|
1944
|
+
_schema,
|
|
1945
|
+
name,
|
|
1946
|
+
rootSchema,
|
|
1947
|
+
formData,
|
|
1948
|
+
_recurseList,
|
|
1949
|
+
experimental_customMergeAllOf
|
|
1950
|
+
)
|
|
1411
1951
|
};
|
|
1412
1952
|
}
|
|
1413
1953
|
if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
|
|
1414
|
-
|
|
1954
|
+
set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
|
|
1415
1955
|
}
|
|
1416
1956
|
if (ITEMS_KEY in schema && Array.isArray(formData)) {
|
|
1417
1957
|
const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;
|
|
@@ -1424,7 +1964,8 @@
|
|
|
1424
1964
|
`${name}.${i}`,
|
|
1425
1965
|
rootSchema,
|
|
1426
1966
|
element,
|
|
1427
|
-
_recurseList
|
|
1967
|
+
_recurseList,
|
|
1968
|
+
experimental_customMergeAllOf
|
|
1428
1969
|
);
|
|
1429
1970
|
} else if (schemaAdditionalItems) {
|
|
1430
1971
|
pathSchema[i] = toPathSchemaInternal(
|
|
@@ -1433,7 +1974,8 @@
|
|
|
1433
1974
|
`${name}.${i}`,
|
|
1434
1975
|
rootSchema,
|
|
1435
1976
|
element,
|
|
1436
|
-
_recurseList
|
|
1977
|
+
_recurseList,
|
|
1978
|
+
experimental_customMergeAllOf
|
|
1437
1979
|
);
|
|
1438
1980
|
} else {
|
|
1439
1981
|
console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
|
|
@@ -1447,13 +1989,14 @@
|
|
|
1447
1989
|
`${name}.${i}`,
|
|
1448
1990
|
rootSchema,
|
|
1449
1991
|
element,
|
|
1450
|
-
_recurseList
|
|
1992
|
+
_recurseList,
|
|
1993
|
+
experimental_customMergeAllOf
|
|
1451
1994
|
);
|
|
1452
1995
|
});
|
|
1453
1996
|
}
|
|
1454
1997
|
} else if (PROPERTIES_KEY in schema) {
|
|
1455
1998
|
for (const property in schema.properties) {
|
|
1456
|
-
const field =
|
|
1999
|
+
const field = get12(schema, [PROPERTIES_KEY, property], {});
|
|
1457
2000
|
pathSchema[property] = toPathSchemaInternal(
|
|
1458
2001
|
validator,
|
|
1459
2002
|
field,
|
|
@@ -1461,15 +2004,16 @@
|
|
|
1461
2004
|
rootSchema,
|
|
1462
2005
|
// It's possible that formData is not an object -- this can happen if an
|
|
1463
2006
|
// array item has just been added, but not populated with data yet
|
|
1464
|
-
|
|
1465
|
-
_recurseList
|
|
2007
|
+
get12(formData, [property]),
|
|
2008
|
+
_recurseList,
|
|
2009
|
+
experimental_customMergeAllOf
|
|
1466
2010
|
);
|
|
1467
2011
|
}
|
|
1468
2012
|
}
|
|
1469
2013
|
return pathSchema;
|
|
1470
2014
|
}
|
|
1471
|
-
function toPathSchema(validator, schema, name = "", rootSchema, formData) {
|
|
1472
|
-
return toPathSchemaInternal(validator, schema, name, rootSchema, formData);
|
|
2015
|
+
function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
|
|
2016
|
+
return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
|
|
1473
2017
|
}
|
|
1474
2018
|
|
|
1475
2019
|
// src/createSchemaUtils.ts
|
|
@@ -1479,11 +2023,13 @@
|
|
|
1479
2023
|
* @param validator - An implementation of the `ValidatorType` interface that will be forwarded to all the APIs
|
|
1480
2024
|
* @param rootSchema - The root schema that will be forwarded to all the APIs
|
|
1481
2025
|
* @param experimental_defaultFormStateBehavior - Configuration flags to allow users to override default form state behavior
|
|
2026
|
+
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
1482
2027
|
*/
|
|
1483
|
-
constructor(validator, rootSchema, experimental_defaultFormStateBehavior) {
|
|
2028
|
+
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
1484
2029
|
this.rootSchema = rootSchema;
|
|
1485
2030
|
this.validator = validator;
|
|
1486
2031
|
this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
|
|
2032
|
+
this.experimental_customMergeAllOf = experimental_customMergeAllOf;
|
|
1487
2033
|
}
|
|
1488
2034
|
/** Returns the `ValidatorType` in the `SchemaUtilsType`
|
|
1489
2035
|
*
|
|
@@ -1499,13 +2045,55 @@
|
|
|
1499
2045
|
* @param validator - An implementation of the `ValidatorType` interface that will be compared against the current one
|
|
1500
2046
|
* @param rootSchema - The root schema that will be compared against the current one
|
|
1501
2047
|
* @param [experimental_defaultFormStateBehavior] Optional configuration object, if provided, allows users to override default form state behavior
|
|
2048
|
+
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
1502
2049
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
1503
2050
|
*/
|
|
1504
|
-
doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
|
|
2051
|
+
doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
|
|
1505
2052
|
if (!validator || !rootSchema) {
|
|
1506
2053
|
return false;
|
|
1507
2054
|
}
|
|
1508
|
-
return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior);
|
|
2055
|
+
return this.validator !== validator || !deepEquals(this.rootSchema, rootSchema) || !deepEquals(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
2056
|
+
}
|
|
2057
|
+
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
2058
|
+
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
2059
|
+
* field is in the `required` list for its parent and if so, it is marked as required on return.
|
|
2060
|
+
*
|
|
2061
|
+
* @param schema - The current node within the JSON schema
|
|
2062
|
+
* @param path - The remaining keys in the path to the desired field
|
|
2063
|
+
* @param [formData] - The form data that is used to determine which oneOf option
|
|
2064
|
+
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
2065
|
+
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
2066
|
+
*/
|
|
2067
|
+
findFieldInSchema(schema, path, formData) {
|
|
2068
|
+
return findFieldInSchema(
|
|
2069
|
+
this.validator,
|
|
2070
|
+
this.rootSchema,
|
|
2071
|
+
schema,
|
|
2072
|
+
path,
|
|
2073
|
+
formData,
|
|
2074
|
+
this.experimental_customMergeAllOf
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
/** Finds the oneOf option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` that
|
|
2078
|
+
* matches the `formData[selectorField]` value. For the purposes of this function, `selectorField` is either
|
|
2079
|
+
* `schema.discriminator.propertyName` or `fallbackField`.
|
|
2080
|
+
*
|
|
2081
|
+
* @param schema - The schema element in which to search for the selected oneOf option
|
|
2082
|
+
* @param fallbackField - The field to use as a backup selector field if the schema does not have a required field
|
|
2083
|
+
* @param xxx - Either `oneOf` or `anyOf`, defines which value is being sought
|
|
2084
|
+
* @param [formData={}] - The form data that is used to determine which oneOf option
|
|
2085
|
+
* @returns - The anyOf/oneOf option that matches the selector field in the schema or undefined if nothing is selected
|
|
2086
|
+
*/
|
|
2087
|
+
findSelectedOptionInXxxOf(schema, fallbackField, xxx, formData) {
|
|
2088
|
+
return findSelectedOptionInXxxOf(
|
|
2089
|
+
this.validator,
|
|
2090
|
+
this.rootSchema,
|
|
2091
|
+
schema,
|
|
2092
|
+
fallbackField,
|
|
2093
|
+
xxx,
|
|
2094
|
+
formData,
|
|
2095
|
+
this.experimental_customMergeAllOf
|
|
2096
|
+
);
|
|
1509
2097
|
}
|
|
1510
2098
|
/** Returns the superset of `formData` that includes the given set updated to include any missing fields that have
|
|
1511
2099
|
* computed to have defaults provided in the `schema`.
|
|
@@ -1524,7 +2112,8 @@
|
|
|
1524
2112
|
formData,
|
|
1525
2113
|
this.rootSchema,
|
|
1526
2114
|
includeUndefinedValues,
|
|
1527
|
-
this.experimental_defaultFormStateBehavior
|
|
2115
|
+
this.experimental_defaultFormStateBehavior,
|
|
2116
|
+
this.experimental_customMergeAllOf
|
|
1528
2117
|
);
|
|
1529
2118
|
}
|
|
1530
2119
|
/** Determines whether the combination of `schema` and `uiSchema` properties indicates that the label for the `schema`
|
|
@@ -1536,7 +2125,14 @@
|
|
|
1536
2125
|
* @returns - True if the label should be displayed or false if it should not
|
|
1537
2126
|
*/
|
|
1538
2127
|
getDisplayLabel(schema, uiSchema, globalOptions) {
|
|
1539
|
-
return getDisplayLabel(
|
|
2128
|
+
return getDisplayLabel(
|
|
2129
|
+
this.validator,
|
|
2130
|
+
schema,
|
|
2131
|
+
uiSchema,
|
|
2132
|
+
this.rootSchema,
|
|
2133
|
+
globalOptions,
|
|
2134
|
+
this.experimental_customMergeAllOf
|
|
2135
|
+
);
|
|
1540
2136
|
}
|
|
1541
2137
|
/** Determines which of the given `options` provided most closely matches the `formData`.
|
|
1542
2138
|
* Returns the index of the option that is valid and is the closest match, or 0 if there is no match.
|
|
@@ -1558,7 +2154,8 @@
|
|
|
1558
2154
|
formData,
|
|
1559
2155
|
options,
|
|
1560
2156
|
selectedOption,
|
|
1561
|
-
discriminatorField
|
|
2157
|
+
discriminatorField,
|
|
2158
|
+
this.experimental_customMergeAllOf
|
|
1562
2159
|
);
|
|
1563
2160
|
}
|
|
1564
2161
|
/** Given the `formData` and list of `options`, attempts to find the index of the first option that matches the data.
|
|
@@ -1573,18 +2170,16 @@
|
|
|
1573
2170
|
getFirstMatchingOption(formData, options, discriminatorField) {
|
|
1574
2171
|
return getFirstMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
|
|
1575
2172
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
getMatchingOption(formData, options, discriminatorField) {
|
|
1587
|
-
return getMatchingOption(this.validator, formData, options, this.rootSchema, discriminatorField);
|
|
2173
|
+
getFromSchema(schema, path, defaultValue) {
|
|
2174
|
+
return getFromSchema(
|
|
2175
|
+
this.validator,
|
|
2176
|
+
this.rootSchema,
|
|
2177
|
+
schema,
|
|
2178
|
+
path,
|
|
2179
|
+
// @ts-expect-error TS2769: No overload matches this call
|
|
2180
|
+
defaultValue,
|
|
2181
|
+
this.experimental_customMergeAllOf
|
|
2182
|
+
);
|
|
1588
2183
|
}
|
|
1589
2184
|
/** Checks to see if the `schema` and `uiSchema` combination represents an array of files
|
|
1590
2185
|
*
|
|
@@ -1593,7 +2188,7 @@
|
|
|
1593
2188
|
* @returns - True if schema/uiSchema contains an array of files, otherwise false
|
|
1594
2189
|
*/
|
|
1595
2190
|
isFilesArray(schema, uiSchema) {
|
|
1596
|
-
return isFilesArray(this.validator, schema, uiSchema, this.rootSchema);
|
|
2191
|
+
return isFilesArray(this.validator, schema, uiSchema, this.rootSchema, this.experimental_customMergeAllOf);
|
|
1597
2192
|
}
|
|
1598
2193
|
/** Checks to see if the `schema` combination represents a multi-select
|
|
1599
2194
|
*
|
|
@@ -1601,7 +2196,7 @@
|
|
|
1601
2196
|
* @returns - True if schema contains a multi-select, otherwise false
|
|
1602
2197
|
*/
|
|
1603
2198
|
isMultiSelect(schema) {
|
|
1604
|
-
return isMultiSelect(this.validator, schema, this.rootSchema);
|
|
2199
|
+
return isMultiSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
|
|
1605
2200
|
}
|
|
1606
2201
|
/** Checks to see if the `schema` combination represents a select
|
|
1607
2202
|
*
|
|
@@ -1609,21 +2204,7 @@
|
|
|
1609
2204
|
* @returns - True if schema contains a select, otherwise false
|
|
1610
2205
|
*/
|
|
1611
2206
|
isSelect(schema) {
|
|
1612
|
-
return isSelect(this.validator, schema, this.rootSchema);
|
|
1613
|
-
}
|
|
1614
|
-
/** Merges the errors in `additionalErrorSchema` into the existing `validationData` by combining the hierarchies in
|
|
1615
|
-
* the two `ErrorSchema`s and then appending the error list from the `additionalErrorSchema` obtained by calling
|
|
1616
|
-
* `getValidator().toErrorList()` onto the `errors` in the `validationData`. If no `additionalErrorSchema` is passed,
|
|
1617
|
-
* then `validationData` is returned.
|
|
1618
|
-
*
|
|
1619
|
-
* @param validationData - The current `ValidationData` into which to merge the additional errors
|
|
1620
|
-
* @param [additionalErrorSchema] - The additional set of errors
|
|
1621
|
-
* @returns - The `validationData` with the additional errors from `additionalErrorSchema` merged into it, if provided.
|
|
1622
|
-
* @deprecated - Use the `validationDataMerge()` function exported from `@rjsf/utils` instead. This function will be
|
|
1623
|
-
* removed in the next major release.
|
|
1624
|
-
*/
|
|
1625
|
-
mergeValidationData(validationData, additionalErrorSchema) {
|
|
1626
|
-
return mergeValidationData(this.validator, validationData, additionalErrorSchema);
|
|
2207
|
+
return isSelect(this.validator, schema, this.rootSchema, this.experimental_customMergeAllOf);
|
|
1627
2208
|
}
|
|
1628
2209
|
/** Retrieves an expanded schema that has had all of its conditions, additional properties, references and
|
|
1629
2210
|
* dependencies resolved and merged into the `schema` given a `rawFormData` that is used to do the potentially
|
|
@@ -1634,7 +2215,13 @@
|
|
|
1634
2215
|
* @returns - The schema having its conditions, additional properties, references and dependencies resolved
|
|
1635
2216
|
*/
|
|
1636
2217
|
retrieveSchema(schema, rawFormData) {
|
|
1637
|
-
return retrieveSchema(
|
|
2218
|
+
return retrieveSchema(
|
|
2219
|
+
this.validator,
|
|
2220
|
+
schema,
|
|
2221
|
+
this.rootSchema,
|
|
2222
|
+
rawFormData,
|
|
2223
|
+
this.experimental_customMergeAllOf
|
|
2224
|
+
);
|
|
1638
2225
|
}
|
|
1639
2226
|
/** Sanitize the `data` associated with the `oldSchema` so it is considered appropriate for the `newSchema`. If the
|
|
1640
2227
|
* new schema does not contain any properties, then `undefined` is returned to clear all the form data. Due to the
|
|
@@ -1648,7 +2235,14 @@
|
|
|
1648
2235
|
* to `undefined`. Will return `undefined` if the new schema is not an object containing properties.
|
|
1649
2236
|
*/
|
|
1650
2237
|
sanitizeDataForNewSchema(newSchema, oldSchema, data) {
|
|
1651
|
-
return sanitizeDataForNewSchema(
|
|
2238
|
+
return sanitizeDataForNewSchema(
|
|
2239
|
+
this.validator,
|
|
2240
|
+
this.rootSchema,
|
|
2241
|
+
newSchema,
|
|
2242
|
+
oldSchema,
|
|
2243
|
+
data,
|
|
2244
|
+
this.experimental_customMergeAllOf
|
|
2245
|
+
);
|
|
1652
2246
|
}
|
|
1653
2247
|
/** Generates an `IdSchema` object for the `schema`, recursively
|
|
1654
2248
|
*
|
|
@@ -1660,7 +2254,16 @@
|
|
|
1660
2254
|
* @returns - The `IdSchema` object for the `schema`
|
|
1661
2255
|
*/
|
|
1662
2256
|
toIdSchema(schema, id, formData, idPrefix = "root", idSeparator = "_") {
|
|
1663
|
-
return toIdSchema(
|
|
2257
|
+
return toIdSchema(
|
|
2258
|
+
this.validator,
|
|
2259
|
+
schema,
|
|
2260
|
+
id,
|
|
2261
|
+
this.rootSchema,
|
|
2262
|
+
formData,
|
|
2263
|
+
idPrefix,
|
|
2264
|
+
idSeparator,
|
|
2265
|
+
this.experimental_customMergeAllOf
|
|
2266
|
+
);
|
|
1664
2267
|
}
|
|
1665
2268
|
/** Generates an `PathSchema` object for the `schema`, recursively
|
|
1666
2269
|
*
|
|
@@ -1670,11 +2273,23 @@
|
|
|
1670
2273
|
* @returns - The `PathSchema` object for the `schema`
|
|
1671
2274
|
*/
|
|
1672
2275
|
toPathSchema(schema, name, formData) {
|
|
1673
|
-
return toPathSchema(
|
|
2276
|
+
return toPathSchema(
|
|
2277
|
+
this.validator,
|
|
2278
|
+
schema,
|
|
2279
|
+
name,
|
|
2280
|
+
this.rootSchema,
|
|
2281
|
+
formData,
|
|
2282
|
+
this.experimental_customMergeAllOf
|
|
2283
|
+
);
|
|
1674
2284
|
}
|
|
1675
2285
|
};
|
|
1676
|
-
function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}) {
|
|
1677
|
-
return new SchemaUtils(
|
|
2286
|
+
function createSchemaUtils(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
|
|
2287
|
+
return new SchemaUtils(
|
|
2288
|
+
validator,
|
|
2289
|
+
rootSchema,
|
|
2290
|
+
experimental_defaultFormStateBehavior,
|
|
2291
|
+
experimental_customMergeAllOf
|
|
2292
|
+
);
|
|
1678
2293
|
}
|
|
1679
2294
|
|
|
1680
2295
|
// src/dataURItoBlob.ts
|
|
@@ -1770,15 +2385,17 @@
|
|
|
1770
2385
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
1771
2386
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
1772
2387
|
if (Array.isArray(selected)) {
|
|
1773
|
-
return selected.filter((v) => !
|
|
2388
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
1774
2389
|
}
|
|
1775
|
-
return
|
|
2390
|
+
return deepEquals(value, selected) ? void 0 : selected;
|
|
1776
2391
|
}
|
|
2392
|
+
|
|
2393
|
+
// src/enumOptionsIsSelected.ts
|
|
1777
2394
|
function enumOptionsIsSelected(value, selected) {
|
|
1778
2395
|
if (Array.isArray(selected)) {
|
|
1779
|
-
return selected.some((sel) =>
|
|
2396
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
1780
2397
|
}
|
|
1781
|
-
return
|
|
2398
|
+
return deepEquals(selected, value);
|
|
1782
2399
|
}
|
|
1783
2400
|
|
|
1784
2401
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -1825,10 +2442,10 @@
|
|
|
1825
2442
|
*/
|
|
1826
2443
|
getOrCreateErrorBlock(pathOfError) {
|
|
1827
2444
|
const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
|
|
1828
|
-
let errorBlock = hasPath ?
|
|
2445
|
+
let errorBlock = hasPath ? get12(this.errorSchema, pathOfError) : this.errorSchema;
|
|
1829
2446
|
if (!errorBlock && pathOfError) {
|
|
1830
2447
|
errorBlock = {};
|
|
1831
|
-
|
|
2448
|
+
setWith(this.errorSchema, pathOfError, errorBlock, Object);
|
|
1832
2449
|
}
|
|
1833
2450
|
return errorBlock;
|
|
1834
2451
|
}
|
|
@@ -1851,15 +2468,15 @@
|
|
|
1851
2468
|
*/
|
|
1852
2469
|
addErrors(errorOrList, pathOfError) {
|
|
1853
2470
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
1854
|
-
let errorsList =
|
|
2471
|
+
let errorsList = get12(errorBlock, ERRORS_KEY);
|
|
1855
2472
|
if (!Array.isArray(errorsList)) {
|
|
1856
2473
|
errorsList = [];
|
|
1857
2474
|
errorBlock[ERRORS_KEY] = errorsList;
|
|
1858
2475
|
}
|
|
1859
2476
|
if (Array.isArray(errorOrList)) {
|
|
1860
|
-
|
|
2477
|
+
set(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, ...errorOrList])]);
|
|
1861
2478
|
} else {
|
|
1862
|
-
errorsList
|
|
2479
|
+
set(errorBlock, ERRORS_KEY, [.../* @__PURE__ */ new Set([...errorsList, errorOrList])]);
|
|
1863
2480
|
}
|
|
1864
2481
|
return this;
|
|
1865
2482
|
}
|
|
@@ -1873,8 +2490,8 @@
|
|
|
1873
2490
|
*/
|
|
1874
2491
|
setErrors(errorOrList, pathOfError) {
|
|
1875
2492
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
1876
|
-
const listToAdd = Array.isArray(errorOrList) ? [...errorOrList] : [errorOrList];
|
|
1877
|
-
|
|
2493
|
+
const listToAdd = Array.isArray(errorOrList) ? [.../* @__PURE__ */ new Set([...errorOrList])] : [errorOrList];
|
|
2494
|
+
set(errorBlock, ERRORS_KEY, listToAdd);
|
|
1878
2495
|
return this;
|
|
1879
2496
|
}
|
|
1880
2497
|
/** Clears the error(s) in the `ErrorSchema` at either the root level or the location within the schema described by
|
|
@@ -1886,7 +2503,7 @@
|
|
|
1886
2503
|
*/
|
|
1887
2504
|
clearErrors(pathOfError) {
|
|
1888
2505
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
1889
|
-
|
|
2506
|
+
set(errorBlock, ERRORS_KEY, []);
|
|
1890
2507
|
return this;
|
|
1891
2508
|
}
|
|
1892
2509
|
};
|
|
@@ -1958,6 +2575,9 @@
|
|
|
1958
2575
|
if (options.autocomplete) {
|
|
1959
2576
|
inputProps.autoComplete = options.autocomplete;
|
|
1960
2577
|
}
|
|
2578
|
+
if (options.accept) {
|
|
2579
|
+
inputProps.accept = options.accept;
|
|
2580
|
+
}
|
|
1961
2581
|
return inputProps;
|
|
1962
2582
|
}
|
|
1963
2583
|
|
|
@@ -1984,12 +2604,33 @@
|
|
|
1984
2604
|
if (name === "ButtonTemplates") {
|
|
1985
2605
|
return templates[name];
|
|
1986
2606
|
}
|
|
2607
|
+
if (Object.hasOwn(uiOptions, name) && typeof uiOptions[name] === "string" && Object.hasOwn(templates, uiOptions[name])) {
|
|
2608
|
+
const key = uiOptions[name];
|
|
2609
|
+
return templates[key];
|
|
2610
|
+
}
|
|
1987
2611
|
return (
|
|
1988
2612
|
// Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
|
|
1989
2613
|
// To avoid that, we cast uiOptions to `any` before accessing the name field
|
|
1990
2614
|
uiOptions[name] || templates[name]
|
|
1991
2615
|
);
|
|
1992
2616
|
}
|
|
2617
|
+
function getTestIds() {
|
|
2618
|
+
if (typeof process === "undefined" || get12(process, "env.NODE_ENV") !== "test") {
|
|
2619
|
+
return {};
|
|
2620
|
+
}
|
|
2621
|
+
const ids = /* @__PURE__ */ new Map();
|
|
2622
|
+
return new Proxy(
|
|
2623
|
+
{},
|
|
2624
|
+
{
|
|
2625
|
+
get(_obj, prop) {
|
|
2626
|
+
if (!ids.has(prop)) {
|
|
2627
|
+
ids.set(prop, nanoid.nanoid());
|
|
2628
|
+
}
|
|
2629
|
+
return ids.get(prop);
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
);
|
|
2633
|
+
}
|
|
1993
2634
|
var widgetMap = {
|
|
1994
2635
|
boolean: {
|
|
1995
2636
|
checkbox: "CheckboxWidget",
|
|
@@ -2043,13 +2684,13 @@
|
|
|
2043
2684
|
}
|
|
2044
2685
|
};
|
|
2045
2686
|
function mergeWidgetOptions(AWidget) {
|
|
2046
|
-
let MergedWidget =
|
|
2687
|
+
let MergedWidget = get12(AWidget, "MergedWidget");
|
|
2047
2688
|
if (!MergedWidget) {
|
|
2048
2689
|
const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
|
|
2049
2690
|
MergedWidget = ({ options, ...props }) => {
|
|
2050
2691
|
return /* @__PURE__ */ jsxRuntime.jsx(AWidget, { options: { ...defaultOptions, ...options }, ...props });
|
|
2051
2692
|
};
|
|
2052
|
-
|
|
2693
|
+
set(AWidget, "MergedWidget", MergedWidget);
|
|
2053
2694
|
}
|
|
2054
2695
|
return MergedWidget;
|
|
2055
2696
|
}
|
|
@@ -2087,10 +2728,16 @@
|
|
|
2087
2728
|
}
|
|
2088
2729
|
return hash.toString(16);
|
|
2089
2730
|
}
|
|
2090
|
-
function
|
|
2731
|
+
function sortedJSONStringify(object) {
|
|
2091
2732
|
const allKeys = /* @__PURE__ */ new Set();
|
|
2092
|
-
JSON.stringify(
|
|
2093
|
-
return
|
|
2733
|
+
JSON.stringify(object, (key, value) => (allKeys.add(key), value));
|
|
2734
|
+
return JSON.stringify(object, Array.from(allKeys).sort());
|
|
2735
|
+
}
|
|
2736
|
+
function hashObject(object) {
|
|
2737
|
+
return hashString(sortedJSONStringify(object));
|
|
2738
|
+
}
|
|
2739
|
+
function hashForSchema(schema) {
|
|
2740
|
+
return hashObject(schema);
|
|
2094
2741
|
}
|
|
2095
2742
|
|
|
2096
2743
|
// src/hasWidget.ts
|
|
@@ -2132,6 +2779,9 @@
|
|
|
2132
2779
|
function optionId(id, optionIndex) {
|
|
2133
2780
|
return `${id}-${optionIndex}`;
|
|
2134
2781
|
}
|
|
2782
|
+
function buttonId(id, btn) {
|
|
2783
|
+
return idGenerator(id, btn);
|
|
2784
|
+
}
|
|
2135
2785
|
|
|
2136
2786
|
// src/labelValue.ts
|
|
2137
2787
|
function labelValue(label, hideLabel, fallback) {
|
|
@@ -2142,60 +2792,12 @@
|
|
|
2142
2792
|
function localToUTC(dateString) {
|
|
2143
2793
|
return dateString ? new Date(dateString).toJSON() : void 0;
|
|
2144
2794
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
return schema.enum[0];
|
|
2150
|
-
}
|
|
2151
|
-
if (CONST_KEY in schema) {
|
|
2152
|
-
return schema.const;
|
|
2153
|
-
}
|
|
2154
|
-
throw new Error("schema cannot be inferred as a constant");
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
// src/optionsList.ts
|
|
2158
|
-
function optionsList(schema, uiSchema) {
|
|
2159
|
-
const schemaWithEnumNames = schema;
|
|
2160
|
-
if (schema.enum) {
|
|
2161
|
-
let enumNames;
|
|
2162
|
-
if (uiSchema) {
|
|
2163
|
-
const { enumNames: uiEnumNames } = getUiOptions(uiSchema);
|
|
2164
|
-
enumNames = uiEnumNames;
|
|
2165
|
-
}
|
|
2166
|
-
if (!enumNames && schemaWithEnumNames.enumNames) {
|
|
2167
|
-
{
|
|
2168
|
-
console.warn(
|
|
2169
|
-
'The "enumNames" property in the schema is deprecated and will be removed in a future major release. Use the "ui:enumNames" property in the uiSchema instead.'
|
|
2170
|
-
);
|
|
2171
|
-
}
|
|
2172
|
-
enumNames = schemaWithEnumNames.enumNames;
|
|
2173
|
-
}
|
|
2174
|
-
return schema.enum.map((value, i) => {
|
|
2175
|
-
const label = enumNames?.[i] || String(value);
|
|
2176
|
-
return { label, value };
|
|
2177
|
-
});
|
|
2178
|
-
}
|
|
2179
|
-
let altSchemas = void 0;
|
|
2180
|
-
let altUiSchemas = void 0;
|
|
2181
|
-
if (schema.anyOf) {
|
|
2182
|
-
altSchemas = schema.anyOf;
|
|
2183
|
-
altUiSchemas = uiSchema?.anyOf;
|
|
2184
|
-
} else if (schema.oneOf) {
|
|
2185
|
-
altSchemas = schema.oneOf;
|
|
2186
|
-
altUiSchemas = uiSchema?.oneOf;
|
|
2795
|
+
function lookupFromFormContext(regOrFc, toLookup, fallback) {
|
|
2796
|
+
const lookupPath = [LOOKUP_MAP_NAME];
|
|
2797
|
+
if (has5(regOrFc, FORM_CONTEXT_NAME)) {
|
|
2798
|
+
lookupPath.unshift(FORM_CONTEXT_NAME);
|
|
2187
2799
|
}
|
|
2188
|
-
return
|
|
2189
|
-
const { title } = getUiOptions(altUiSchemas?.[index]);
|
|
2190
|
-
const aSchema = aSchemaDef;
|
|
2191
|
-
const value = toConstant(aSchema);
|
|
2192
|
-
const label = title || aSchema.title || String(value);
|
|
2193
|
-
return {
|
|
2194
|
-
schema: aSchema,
|
|
2195
|
-
label,
|
|
2196
|
-
value
|
|
2197
|
-
};
|
|
2198
|
-
});
|
|
2800
|
+
return get12(regOrFc, [...lookupPath, toLookup], fallback);
|
|
2199
2801
|
}
|
|
2200
2802
|
|
|
2201
2803
|
// src/orderProperties.ts
|
|
@@ -2308,7 +2910,7 @@
|
|
|
2308
2910
|
return Object.keys(errorSchema).reduce((acc, key) => {
|
|
2309
2911
|
if (key !== ERRORS_KEY) {
|
|
2310
2912
|
const childSchema = errorSchema[key];
|
|
2311
|
-
if (
|
|
2913
|
+
if (isPlainObject4(childSchema)) {
|
|
2312
2914
|
acc = acc.concat(toErrorList(childSchema, [...fieldPath, key]));
|
|
2313
2915
|
}
|
|
2314
2916
|
}
|
|
@@ -2337,7 +2939,7 @@
|
|
|
2337
2939
|
return acc;
|
|
2338
2940
|
} else {
|
|
2339
2941
|
const childSchema = errorHandler[key];
|
|
2340
|
-
if (
|
|
2942
|
+
if (isPlainObject4(childSchema)) {
|
|
2341
2943
|
return {
|
|
2342
2944
|
...acc,
|
|
2343
2945
|
[key]: unwrapErrorHandler(childSchema)
|
|
@@ -2403,11 +3005,28 @@
|
|
|
2403
3005
|
}
|
|
2404
3006
|
return schemaNode;
|
|
2405
3007
|
}
|
|
3008
|
+
function getChangedFields(a, b) {
|
|
3009
|
+
const aIsPlainObject = isPlainObject4(a);
|
|
3010
|
+
const bIsPlainObject = isPlainObject4(b);
|
|
3011
|
+
if (a === b || !aIsPlainObject && !bIsPlainObject) {
|
|
3012
|
+
return [];
|
|
3013
|
+
}
|
|
3014
|
+
if (aIsPlainObject && !bIsPlainObject) {
|
|
3015
|
+
return keys(a);
|
|
3016
|
+
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
3017
|
+
return keys(b);
|
|
3018
|
+
} else {
|
|
3019
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get12(b, key))));
|
|
3020
|
+
const diffFields = difference(keys(b), keys(a));
|
|
3021
|
+
return [...unequalFields, ...diffFields];
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
2406
3024
|
|
|
2407
3025
|
// src/enums.ts
|
|
2408
3026
|
var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
2409
3027
|
TranslatableString2["ArrayItemTitle"] = "Item";
|
|
2410
3028
|
TranslatableString2["MissingItems"] = "Missing items definition";
|
|
3029
|
+
TranslatableString2["EmptyArray"] = "No items yet. Use the button below to add some.";
|
|
2411
3030
|
TranslatableString2["YesLabel"] = "Yes";
|
|
2412
3031
|
TranslatableString2["NoLabel"] = "No";
|
|
2413
3032
|
TranslatableString2["CloseLabel"] = "Close";
|
|
@@ -2462,12 +3081,12 @@
|
|
|
2462
3081
|
* @param hash - The hash value at which to map the schema
|
|
2463
3082
|
*/
|
|
2464
3083
|
addSchema(schema, hash) {
|
|
2465
|
-
const key =
|
|
3084
|
+
const key = get12(schema, ID_KEY, hash);
|
|
2466
3085
|
const identifiedSchema = { ...schema, [ID_KEY]: key };
|
|
2467
3086
|
const existing = this.schemaMap[key];
|
|
2468
3087
|
if (!existing) {
|
|
2469
3088
|
this.schemaMap[key] = identifiedSchema;
|
|
2470
|
-
} else if (!
|
|
3089
|
+
} else if (!deepEquals(existing, identifiedSchema)) {
|
|
2471
3090
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
2472
3091
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
2473
3092
|
throw new Error(
|
|
@@ -2489,7 +3108,7 @@
|
|
|
2489
3108
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
2490
3109
|
*/
|
|
2491
3110
|
isValid(schema, _formData, rootSchema) {
|
|
2492
|
-
if (!
|
|
3111
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
2493
3112
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
2494
3113
|
}
|
|
2495
3114
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -2529,7 +3148,7 @@
|
|
|
2529
3148
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
2530
3149
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
2531
3150
|
schemas.forEach((schema2) => {
|
|
2532
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
3151
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
|
|
2533
3152
|
if (sameSchemaIndex === -1) {
|
|
2534
3153
|
recurseList.push(schema2);
|
|
2535
3154
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
@@ -2561,20 +3180,24 @@
|
|
|
2561
3180
|
exports.DEFAULT_KEY = DEFAULT_KEY;
|
|
2562
3181
|
exports.DEFINITIONS_KEY = DEFINITIONS_KEY;
|
|
2563
3182
|
exports.DEPENDENCIES_KEY = DEPENDENCIES_KEY;
|
|
3183
|
+
exports.DISCRIMINATOR_PATH = DISCRIMINATOR_PATH;
|
|
2564
3184
|
exports.ENUM_KEY = ENUM_KEY;
|
|
2565
3185
|
exports.ERRORS_KEY = ERRORS_KEY;
|
|
2566
3186
|
exports.ErrorSchemaBuilder = ErrorSchemaBuilder;
|
|
3187
|
+
exports.FORM_CONTEXT_NAME = FORM_CONTEXT_NAME;
|
|
2567
3188
|
exports.ID_KEY = ID_KEY;
|
|
2568
3189
|
exports.IF_KEY = IF_KEY;
|
|
2569
3190
|
exports.ITEMS_KEY = ITEMS_KEY;
|
|
2570
3191
|
exports.JUNK_OPTION_ID = JUNK_OPTION_ID;
|
|
3192
|
+
exports.LOOKUP_MAP_NAME = LOOKUP_MAP_NAME;
|
|
2571
3193
|
exports.NAME_KEY = NAME_KEY;
|
|
2572
3194
|
exports.ONE_OF_KEY = ONE_OF_KEY;
|
|
3195
|
+
exports.PATTERN_PROPERTIES_KEY = PATTERN_PROPERTIES_KEY;
|
|
2573
3196
|
exports.PROPERTIES_KEY = PROPERTIES_KEY;
|
|
3197
|
+
exports.READONLY_KEY = READONLY_KEY;
|
|
2574
3198
|
exports.REF_KEY = REF_KEY;
|
|
2575
3199
|
exports.REQUIRED_KEY = REQUIRED_KEY;
|
|
2576
3200
|
exports.RJSF_ADDITIONAL_PROPERTIES_FLAG = RJSF_ADDITIONAL_PROPERTIES_FLAG;
|
|
2577
|
-
exports.RJSF_ADDITONAL_PROPERTIES_FLAG = RJSF_ADDITONAL_PROPERTIES_FLAG;
|
|
2578
3201
|
exports.ROOT_SCHEMA_PREFIX = ROOT_SCHEMA_PREFIX;
|
|
2579
3202
|
exports.SUBMIT_BTN_OPTIONS_KEY = SUBMIT_BTN_OPTIONS_KEY;
|
|
2580
3203
|
exports.TranslatableString = TranslatableString;
|
|
@@ -2585,6 +3208,7 @@
|
|
|
2585
3208
|
exports.allowAdditionalItems = allowAdditionalItems;
|
|
2586
3209
|
exports.ariaDescribedByIds = ariaDescribedByIds;
|
|
2587
3210
|
exports.asNumber = asNumber;
|
|
3211
|
+
exports.buttonId = buttonId;
|
|
2588
3212
|
exports.canExpand = canExpand;
|
|
2589
3213
|
exports.createErrorHandler = createErrorHandler;
|
|
2590
3214
|
exports.createSchemaUtils = createSchemaUtils;
|
|
@@ -2600,24 +3224,30 @@
|
|
|
2600
3224
|
exports.enumOptionsValueForIndex = enumOptionsValueForIndex;
|
|
2601
3225
|
exports.errorId = errorId;
|
|
2602
3226
|
exports.examplesId = examplesId;
|
|
3227
|
+
exports.findFieldInSchema = findFieldInSchema;
|
|
2603
3228
|
exports.findSchemaDefinition = findSchemaDefinition;
|
|
3229
|
+
exports.findSelectedOptionInXxxOf = findSelectedOptionInXxxOf;
|
|
3230
|
+
exports.getChangedFields = getChangedFields;
|
|
2604
3231
|
exports.getClosestMatchingOption = getClosestMatchingOption;
|
|
2605
3232
|
exports.getDateElementProps = getDateElementProps;
|
|
2606
3233
|
exports.getDefaultFormState = getDefaultFormState;
|
|
2607
3234
|
exports.getDiscriminatorFieldFromSchema = getDiscriminatorFieldFromSchema;
|
|
2608
3235
|
exports.getDisplayLabel = getDisplayLabel;
|
|
2609
3236
|
exports.getFirstMatchingOption = getFirstMatchingOption;
|
|
3237
|
+
exports.getFromSchema = getFromSchema;
|
|
2610
3238
|
exports.getInputProps = getInputProps;
|
|
2611
|
-
exports.getMatchingOption = getMatchingOption;
|
|
2612
3239
|
exports.getOptionMatchingSimpleDiscriminator = getOptionMatchingSimpleDiscriminator;
|
|
2613
3240
|
exports.getSchemaType = getSchemaType;
|
|
2614
3241
|
exports.getSubmitButtonOptions = getSubmitButtonOptions;
|
|
2615
3242
|
exports.getTemplate = getTemplate;
|
|
3243
|
+
exports.getTestIds = getTestIds;
|
|
2616
3244
|
exports.getUiOptions = getUiOptions;
|
|
2617
3245
|
exports.getWidget = getWidget;
|
|
2618
3246
|
exports.guessType = guessType;
|
|
2619
3247
|
exports.hasWidget = hasWidget;
|
|
2620
3248
|
exports.hashForSchema = hashForSchema;
|
|
3249
|
+
exports.hashObject = hashObject;
|
|
3250
|
+
exports.hashString = hashString;
|
|
2621
3251
|
exports.helpId = helpId;
|
|
2622
3252
|
exports.isConstant = isConstant;
|
|
2623
3253
|
exports.isCustomWidget = isCustomWidget;
|
|
@@ -2628,10 +3258,10 @@
|
|
|
2628
3258
|
exports.isSelect = isSelect;
|
|
2629
3259
|
exports.labelValue = labelValue;
|
|
2630
3260
|
exports.localToUTC = localToUTC;
|
|
3261
|
+
exports.lookupFromFormContext = lookupFromFormContext;
|
|
2631
3262
|
exports.mergeDefaultsWithFormData = mergeDefaultsWithFormData;
|
|
2632
3263
|
exports.mergeObjects = mergeObjects;
|
|
2633
3264
|
exports.mergeSchemas = mergeSchemas;
|
|
2634
|
-
exports.mergeValidationData = mergeValidationData;
|
|
2635
3265
|
exports.optionId = optionId;
|
|
2636
3266
|
exports.optionsList = optionsList;
|
|
2637
3267
|
exports.orderProperties = orderProperties;
|
|
@@ -2644,6 +3274,7 @@
|
|
|
2644
3274
|
exports.schemaParser = schemaParser;
|
|
2645
3275
|
exports.schemaRequiresTrueValue = schemaRequiresTrueValue;
|
|
2646
3276
|
exports.shouldRender = shouldRender;
|
|
3277
|
+
exports.sortedJSONStringify = sortedJSONStringify;
|
|
2647
3278
|
exports.titleId = titleId;
|
|
2648
3279
|
exports.toConstant = toConstant;
|
|
2649
3280
|
exports.toDateString = toDateString;
|