@rjsf/utils 6.5.2 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +628 -441
- package/dist/index.cjs.map +4 -4
- package/dist/utils.esm.js +624 -437
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +632 -445
- package/lib/ErrorSchemaBuilder.js.map +1 -1
- package/lib/canExpand.js.map +1 -1
- package/lib/constIsAjvDataReference.js +1 -1
- package/lib/constIsAjvDataReference.js.map +1 -1
- package/lib/createSchemaUtils.js +3 -3
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/enumOptionSelectedValue.js.map +1 -1
- package/lib/enumOptionValueDecoder.js.map +1 -1
- package/lib/enumOptionsDeselectValue.js +1 -1
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIndexForValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/enumOptionsSelectValue.js +1 -1
- package/lib/enumOptionsSelectValue.js.map +1 -1
- package/lib/enumOptionsValueForIndex.js +2 -2
- 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.js +4 -4
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/getChangedFields.js +3 -3
- package/lib/getChangedFields.js.map +1 -1
- package/lib/getDiscriminatorFieldFromSchema.js.map +1 -1
- package/lib/getOptionMatchingSimpleDiscriminator.js.map +1 -1
- package/lib/getTestIds.d.ts +1 -1
- package/lib/getTestIds.js +4 -3
- package/lib/getTestIds.js.map +1 -1
- package/lib/getWidget.js +1 -1
- package/lib/getWidget.js.map +1 -1
- package/lib/idGenerators.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/isFormDataAvailable.js +1 -1
- package/lib/isFormDataAvailable.js.map +1 -1
- package/lib/isRootSchema.js +1 -1
- package/lib/isRootSchema.js.map +1 -1
- package/lib/jsonSchemaAugmentation.d.ts +19 -0
- package/lib/jsonSchemaAugmentation.js +2 -0
- package/lib/jsonSchemaAugmentation.js.map +1 -0
- package/lib/mergeDefaultsWithFormData.js +2 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/parser/ParserValidator.js +1 -1
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/index.d.ts +1 -1
- package/lib/parser/index.js.map +1 -1
- package/lib/parser/schemaParser.js +2 -2
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/removeOptionalEmptyObjects.d.ts +2 -0
- package/lib/removeOptionalEmptyObjects.js +8 -29
- package/lib/removeOptionalEmptyObjects.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +2 -2
- package/lib/schema/findFieldInSchema.js +7 -6
- package/lib/schema/findFieldInSchema.js.map +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
- package/lib/schema/getClosestMatchingOption.js +3 -3
- package/lib/schema/getClosestMatchingOption.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +4 -4
- package/lib/schema/getDefaultFormState.js +17 -22
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +3 -3
- package/lib/schema/getFromSchema.js +3 -3
- package/lib/schema/getFromSchema.js.map +1 -1
- package/lib/schema/index.d.ts +4 -4
- package/lib/schema/index.js +4 -4
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/isMultiSelect.js.map +1 -1
- package/lib/schema/omitExtraData.d.ts +18 -8
- package/lib/schema/omitExtraData.js +352 -16
- package/lib/schema/omitExtraData.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +15 -0
- package/lib/schema/retrieveSchema.js +36 -13
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/sanitizeDataForNewSchema.js.map +1 -1
- package/lib/schema/shallowAllOfMerge.d.ts +11 -0
- package/lib/schema/shallowAllOfMerge.js +18 -0
- package/lib/schema/shallowAllOfMerge.js.map +1 -0
- package/lib/schema/toPathSchema.d.ts +1 -0
- package/lib/schema/toPathSchema.js +2 -1
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/shouldRenderOptionalField.js +1 -1
- package/lib/shouldRenderOptionalField.js.map +1 -1
- package/lib/toErrorSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +17 -5
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/useFileWidgetProps.d.ts +1 -1
- package/lib/useFileWidgetProps.js +9 -10
- package/lib/useFileWidgetProps.js.map +1 -1
- package/lib/withIdRefPrefix.js +1 -1
- package/lib/withIdRefPrefix.js.map +1 -1
- package/package.json +11 -11
- package/src/ErrorSchemaBuilder.ts +1 -1
- package/src/canExpand.ts +1 -1
- package/src/constIsAjvDataReference.ts +3 -2
- package/src/createSchemaUtils.ts +22 -20
- package/src/enumOptionSelectedValue.ts +1 -1
- package/src/enumOptionValueDecoder.ts +1 -1
- package/src/enumOptionsDeselectValue.ts +2 -2
- package/src/enumOptionsIndexForValue.ts +1 -1
- package/src/enumOptionsIsSelected.ts +1 -1
- package/src/enumOptionsSelectValue.ts +3 -2
- package/src/enumOptionsValueForIndex.ts +2 -2
- package/src/enums.ts +2 -0
- package/src/findSchemaDefinition.ts +4 -4
- package/src/getChangedFields.ts +4 -3
- package/src/getDiscriminatorFieldFromSchema.ts +1 -1
- package/src/getOptionMatchingSimpleDiscriminator.ts +1 -0
- package/src/getTestIds.ts +4 -3
- package/src/getWidget.tsx +2 -2
- package/src/idGenerators.ts +1 -1
- package/src/index.ts +6 -6
- package/src/isFormDataAvailable.ts +1 -1
- package/src/isRootSchema.ts +1 -1
- package/src/jsonSchemaAugmentation.ts +21 -0
- package/src/mergeDefaultsWithFormData.ts +4 -3
- package/src/parser/ParserValidator.ts +1 -1
- package/src/parser/index.ts +1 -1
- package/src/parser/schemaParser.ts +3 -3
- package/src/removeOptionalEmptyObjects.ts +8 -30
- package/src/schema/findFieldInSchema.ts +10 -8
- package/src/schema/findSelectedOptionInXxxOf.ts +1 -1
- package/src/schema/getClosestMatchingOption.ts +4 -4
- package/src/schema/getDefaultFormState.ts +18 -24
- package/src/schema/getFromSchema.ts +15 -8
- package/src/schema/index.ts +5 -3
- package/src/schema/isMultiSelect.ts +0 -1
- package/src/schema/omitExtraData.ts +398 -19
- package/src/schema/retrieveSchema.ts +41 -15
- package/src/schema/sanitizeDataForNewSchema.ts +1 -1
- package/src/schema/shallowAllOfMerge.ts +19 -0
- package/src/schema/toPathSchema.ts +2 -1
- package/src/shouldRenderOptionalField.ts +2 -2
- package/src/toErrorSchema.ts +1 -1
- package/src/tsconfig.json +0 -1
- package/src/types.ts +18 -5
- package/src/useFileWidgetProps.ts +9 -10
- package/src/withIdRefPrefix.ts +2 -1
package/dist/utils.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'fast-equals', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject2, global.
|
|
5
|
-
})(this, (function (exports, isPlainObject2,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/get'), require('fast-equals'), require('fast-uri'), require('jsonpointer'), require('lodash/isEmpty'), require('lodash/isObject'), require('lodash/omit'), require('lodash/has'), require('lodash/isString'), require('lodash/flattenDeep'), require('lodash/merge'), require('lodash/set'), require('lodash/times'), require('lodash/transform'), require('lodash/uniq'), require('lodash/union'), require('lodash/isNumber'), require('@x0k/json-schema-merge'), require('@x0k/json-schema-merge/lib/array'), require('lodash/reduce'), require('lodash/isNil'), require('lodash/pick'), require('lodash/cloneDeep'), require('lodash/setWith'), require('lodash/difference'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/uniqueId'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/forEach')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/get', 'fast-equals', 'fast-uri', 'jsonpointer', 'lodash/isEmpty', 'lodash/isObject', 'lodash/omit', 'lodash/has', 'lodash/isString', 'lodash/flattenDeep', 'lodash/merge', 'lodash/set', 'lodash/times', 'lodash/transform', 'lodash/uniq', 'lodash/union', 'lodash/isNumber', '@x0k/json-schema-merge', '@x0k/json-schema-merge/lib/array', 'lodash/reduce', 'lodash/isNil', 'lodash/pick', 'lodash/cloneDeep', 'lodash/setWith', 'lodash/difference', 'lodash/keys', 'lodash/pickBy', 'lodash/uniqueId', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/forEach'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject2, global.get15, global.fastEquals, global.UriResolver, global.jsonpointer, global.isEmpty4, global.isObject2, global.omit, global.has5, global.isString, global.flattenDeep, global.merge, global.set, global.times, global.transform, global.uniq, global.union, global.isNumber, global.jsonSchemaMerge, global.array, global.reduce, global.isNil, global.pick, global.cloneDeep, global.setWith, global.difference, global.keys, global.pickBy, global.uniqueId, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject2, get15, fastEquals, UriResolver, jsonpointer, isEmpty4, isObject2, omit, has5, isString, flattenDeep, merge, set, times, transform, uniq, union, isNumber, jsonSchemaMerge, array, reduce, isNil, pick, cloneDeep, setWith, difference, keys, pickBy, uniqueId, react, ReactIs, jsxRuntime, toPath, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
return void 0;
|
|
180
180
|
}
|
|
181
181
|
function makeAllReferencesAbsolute(schema, baseURI) {
|
|
182
|
-
const currentURI =
|
|
182
|
+
const currentURI = get15(schema, ID_KEY, baseURI);
|
|
183
183
|
if (REF_KEY in schema) {
|
|
184
184
|
schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
|
|
185
185
|
}
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
const remaining = omit(object, [key]);
|
|
201
201
|
return [remaining, value];
|
|
202
202
|
}
|
|
203
|
-
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI =
|
|
203
|
+
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = get15(rootSchema, [ID_KEY])) {
|
|
204
204
|
const ref = $ref || "";
|
|
205
205
|
let current = void 0;
|
|
206
206
|
if (ref.startsWith("#")) {
|
|
@@ -250,13 +250,13 @@
|
|
|
250
250
|
}
|
|
251
251
|
return current;
|
|
252
252
|
}
|
|
253
|
-
function findSchemaDefinition($ref, rootSchema = {}, baseURI =
|
|
253
|
+
function findSchemaDefinition($ref, rootSchema = {}, baseURI = get15(rootSchema, [ID_KEY])) {
|
|
254
254
|
const recurseList = [];
|
|
255
255
|
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|
|
256
256
|
}
|
|
257
257
|
function getDiscriminatorFieldFromSchema(schema) {
|
|
258
258
|
let discriminator;
|
|
259
|
-
const maybeString =
|
|
259
|
+
const maybeString = get15(schema, DISCRIMINATOR_PATH);
|
|
260
260
|
if (isString(maybeString)) {
|
|
261
261
|
discriminator = maybeString;
|
|
262
262
|
} else if (maybeString !== void 0) {
|
|
@@ -327,13 +327,13 @@
|
|
|
327
327
|
}
|
|
328
328
|
function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
|
|
329
329
|
if (formData && discriminatorField) {
|
|
330
|
-
const value =
|
|
330
|
+
const value = get15(formData, discriminatorField);
|
|
331
331
|
if (value === void 0) {
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
for (let i = 0; i < options.length; i++) {
|
|
335
335
|
const option = options[i];
|
|
336
|
-
const discriminator =
|
|
336
|
+
const discriminator = get15(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
337
337
|
if (discriminator.type === "object" || discriminator.type === "array") {
|
|
338
338
|
continue;
|
|
339
339
|
}
|
|
@@ -360,8 +360,8 @@
|
|
|
360
360
|
for (let i = 0; i < options.length; i++) {
|
|
361
361
|
const option = options[i];
|
|
362
362
|
if (discriminatorField && has5(option, [PROPERTIES_KEY, discriminatorField])) {
|
|
363
|
-
const value =
|
|
364
|
-
const discriminator =
|
|
363
|
+
const value = get15(formData, discriminatorField);
|
|
364
|
+
const discriminator = get15(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
365
365
|
if (validator.isValid(discriminator, value, rootSchema)) {
|
|
366
366
|
return i;
|
|
367
367
|
}
|
|
@@ -394,6 +394,12 @@
|
|
|
394
394
|
}
|
|
395
395
|
return 0;
|
|
396
396
|
}
|
|
397
|
+
var { compareSchemaDefinitions, compareSchemaValues } = jsonSchemaMerge.createComparator();
|
|
398
|
+
var { mergeArrayOfSchemaDefinitions } = jsonSchemaMerge.createMerger({
|
|
399
|
+
intersectJson: array.createIntersector(compareSchemaValues),
|
|
400
|
+
deduplicateJsonSchemaDef: array.createDeduplicator(compareSchemaDefinitions)
|
|
401
|
+
});
|
|
402
|
+
var shallowAllOfMerge_default = jsonSchemaMerge.createShallowAllOfMerge(mergeArrayOfSchemaDefinitions);
|
|
397
403
|
|
|
398
404
|
// src/schema/retrieveSchema.ts
|
|
399
405
|
function retrieveSchema(validator, schema, rootSchema = {}, rawFormData, experimental_customMergeAllOf, resolveAnyOfOrOneOfRefs = false) {
|
|
@@ -641,7 +647,7 @@
|
|
|
641
647
|
validator,
|
|
642
648
|
{ [ALL_OF_KEY]: Object.values(matchingProperties) },
|
|
643
649
|
rootSchema,
|
|
644
|
-
|
|
650
|
+
get15(formData, [key]),
|
|
645
651
|
experimental_customMergeAllOf
|
|
646
652
|
);
|
|
647
653
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -654,7 +660,7 @@
|
|
|
654
660
|
if (REF_KEY in schema.additionalProperties) {
|
|
655
661
|
additionalProperties = retrieveSchema(
|
|
656
662
|
validator,
|
|
657
|
-
{ [REF_KEY]:
|
|
663
|
+
{ [REF_KEY]: get15(schema.additionalProperties, [REF_KEY]) },
|
|
658
664
|
rootSchema,
|
|
659
665
|
formData,
|
|
660
666
|
experimental_customMergeAllOf
|
|
@@ -667,10 +673,10 @@
|
|
|
667
673
|
...schema.additionalProperties
|
|
668
674
|
};
|
|
669
675
|
} else {
|
|
670
|
-
additionalProperties = { type: guessType(
|
|
676
|
+
additionalProperties = { type: guessType(get15(formData, [key])) };
|
|
671
677
|
}
|
|
672
678
|
} else {
|
|
673
|
-
additionalProperties = { type: guessType(
|
|
679
|
+
additionalProperties = { type: guessType(get15(formData, [key])) };
|
|
674
680
|
}
|
|
675
681
|
schema.properties[key] = additionalProperties;
|
|
676
682
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -681,14 +687,8 @@
|
|
|
681
687
|
});
|
|
682
688
|
return schema;
|
|
683
689
|
}
|
|
684
|
-
var { compareSchemaDefinitions, compareSchemaValues } = jsonSchemaMerge.createComparator();
|
|
685
|
-
var { mergeArrayOfSchemaDefinitions } = jsonSchemaMerge.createMerger({
|
|
686
|
-
intersectJson: array.createIntersector(compareSchemaValues),
|
|
687
|
-
deduplicateJsonSchemaDef: array.createDeduplicator(compareSchemaDefinitions)
|
|
688
|
-
});
|
|
689
|
-
var shallowAllOfMerge = jsonSchemaMerge.createShallowAllOfMerge(mergeArrayOfSchemaDefinitions);
|
|
690
690
|
function mergeAllOf(schema) {
|
|
691
|
-
return
|
|
691
|
+
return shallowAllOfMerge_default(schema);
|
|
692
692
|
}
|
|
693
693
|
function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expandAllBranches = false, recurseList = [], experimental_customMergeAllOf, resolveAnyOfOrOneOfRefs) {
|
|
694
694
|
if (!isObject(schema)) {
|
|
@@ -754,7 +754,7 @@
|
|
|
754
754
|
validator,
|
|
755
755
|
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
756
756
|
rootSchema,
|
|
757
|
-
|
|
757
|
+
get15(rawFormData, [key]),
|
|
758
758
|
experimental_customMergeAllOf
|
|
759
759
|
);
|
|
760
760
|
}
|
|
@@ -795,12 +795,23 @@
|
|
|
795
795
|
});
|
|
796
796
|
const option = getFirstMatchingOption(validator, formData, anyOrOneOf, rootSchema, discriminator);
|
|
797
797
|
if (expandAllBranches) {
|
|
798
|
+
const relaxed = relaxOptionsForScoring(anyOrOneOf, false, rootSchema);
|
|
799
|
+
getFirstMatchingOption(validator, formData, relaxed, rootSchema, discriminator);
|
|
798
800
|
return anyOrOneOf.map((item) => mergeSchemas(remaining, item));
|
|
799
801
|
}
|
|
800
802
|
schema = mergeSchemas(remaining, anyOrOneOf[option]);
|
|
801
803
|
}
|
|
802
804
|
return [schema];
|
|
803
805
|
}
|
|
806
|
+
function relaxOptionsForScoring(options, resolveRefs = false, rootSchema) {
|
|
807
|
+
return options.map((d) => {
|
|
808
|
+
if (!isObject(d)) {
|
|
809
|
+
return d ? {} : { not: {} };
|
|
810
|
+
}
|
|
811
|
+
const schema = resolveRefs && rootSchema ? resolveAllReferences(d, rootSchema, []) : d;
|
|
812
|
+
return schema.additionalProperties === false ? { ...schema, additionalProperties: true } : schema;
|
|
813
|
+
});
|
|
814
|
+
}
|
|
804
815
|
function resolveDependencies(validator, schema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
805
816
|
const { dependencies, ...remainingSchema } = schema;
|
|
806
817
|
const resolvedSchemas = resolveAnyOrOneOfSchemas(
|
|
@@ -826,7 +837,7 @@
|
|
|
826
837
|
function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
827
838
|
let schemas = [resolvedSchema];
|
|
828
839
|
for (const dependencyKey in dependencies) {
|
|
829
|
-
if (!expandAllBranches &&
|
|
840
|
+
if (!expandAllBranches && get15(formData, [dependencyKey]) === void 0) {
|
|
830
841
|
continue;
|
|
831
842
|
}
|
|
832
843
|
if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
|
|
@@ -957,11 +968,11 @@
|
|
|
957
968
|
const xxxOfs = schema[xxx].map(
|
|
958
969
|
(xxxOf) => retrieveSchema(validator, xxxOf, rootSchema, formData, experimental_customMergeAllOf)
|
|
959
970
|
);
|
|
960
|
-
const data =
|
|
971
|
+
const data = get15(formData, selectorField);
|
|
961
972
|
if (data !== void 0) {
|
|
962
973
|
return xxxOfs.find((xxx2) => {
|
|
963
974
|
return deepEquals_default(
|
|
964
|
-
|
|
975
|
+
get15(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get15(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
965
976
|
data
|
|
966
977
|
);
|
|
967
978
|
});
|
|
@@ -977,10 +988,10 @@
|
|
|
977
988
|
if (isEmpty4(path)) {
|
|
978
989
|
return fieldSchema;
|
|
979
990
|
}
|
|
980
|
-
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
991
|
+
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
981
992
|
const [part, ...nestedPath] = pathList;
|
|
982
|
-
if (part && has5(fieldSchema, part)) {
|
|
983
|
-
fieldSchema =
|
|
993
|
+
if (part !== void 0 && part !== "" && has5(fieldSchema, part)) {
|
|
994
|
+
fieldSchema = get15(fieldSchema, part);
|
|
984
995
|
return getFromSchemaInternal(
|
|
985
996
|
validator,
|
|
986
997
|
rootSchema,
|
|
@@ -1005,6 +1016,7 @@
|
|
|
1005
1016
|
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
1006
1017
|
let parentField = schema;
|
|
1007
1018
|
const fieldName = pathList.pop();
|
|
1019
|
+
const fieldNameKey = String(fieldName);
|
|
1008
1020
|
if (pathList.length) {
|
|
1009
1021
|
pathList.forEach((subPath) => {
|
|
1010
1022
|
parentField = getFromSchema(
|
|
@@ -1020,9 +1032,9 @@
|
|
|
1020
1032
|
validator,
|
|
1021
1033
|
rootSchema,
|
|
1022
1034
|
parentField,
|
|
1023
|
-
|
|
1035
|
+
fieldNameKey,
|
|
1024
1036
|
ONE_OF_KEY,
|
|
1025
|
-
|
|
1037
|
+
get15(formData, subPath),
|
|
1026
1038
|
experimental_customMergeAllOf
|
|
1027
1039
|
);
|
|
1028
1040
|
} else if (has5(parentField, ANY_OF_KEY)) {
|
|
@@ -1030,9 +1042,9 @@
|
|
|
1030
1042
|
validator,
|
|
1031
1043
|
rootSchema,
|
|
1032
1044
|
parentField,
|
|
1033
|
-
|
|
1045
|
+
fieldNameKey,
|
|
1034
1046
|
ANY_OF_KEY,
|
|
1035
|
-
|
|
1047
|
+
get15(formData, subPath),
|
|
1036
1048
|
experimental_customMergeAllOf
|
|
1037
1049
|
);
|
|
1038
1050
|
}
|
|
@@ -1043,7 +1055,7 @@
|
|
|
1043
1055
|
validator,
|
|
1044
1056
|
rootSchema,
|
|
1045
1057
|
parentField,
|
|
1046
|
-
|
|
1058
|
+
fieldNameKey,
|
|
1047
1059
|
ONE_OF_KEY,
|
|
1048
1060
|
formData,
|
|
1049
1061
|
experimental_customMergeAllOf
|
|
@@ -1053,7 +1065,7 @@
|
|
|
1053
1065
|
validator,
|
|
1054
1066
|
rootSchema,
|
|
1055
1067
|
parentField,
|
|
1056
|
-
|
|
1068
|
+
fieldNameKey,
|
|
1057
1069
|
ANY_OF_KEY,
|
|
1058
1070
|
formData,
|
|
1059
1071
|
experimental_customMergeAllOf
|
|
@@ -1080,7 +1092,7 @@
|
|
|
1080
1092
|
);
|
|
1081
1093
|
let isRequired;
|
|
1082
1094
|
if (field && Array.isArray(requiredArray)) {
|
|
1083
|
-
isRequired = requiredArray.includes(
|
|
1095
|
+
isRequired = requiredArray.includes(fieldNameKey);
|
|
1084
1096
|
}
|
|
1085
1097
|
return { field, isRequired };
|
|
1086
1098
|
}
|
|
@@ -1100,7 +1112,7 @@
|
|
|
1100
1112
|
totalScore += reduce(
|
|
1101
1113
|
schema.properties,
|
|
1102
1114
|
(score, value, key) => {
|
|
1103
|
-
const formValue =
|
|
1115
|
+
const formValue = get15(formData, key);
|
|
1104
1116
|
if (typeof value === "boolean") {
|
|
1105
1117
|
return score;
|
|
1106
1118
|
}
|
|
@@ -1127,7 +1139,7 @@
|
|
|
1127
1139
|
validator,
|
|
1128
1140
|
rootSchema,
|
|
1129
1141
|
formValue,
|
|
1130
|
-
|
|
1142
|
+
get15(value, key2),
|
|
1131
1143
|
-1,
|
|
1132
1144
|
discriminator,
|
|
1133
1145
|
experimental_customMergeAllOf
|
|
@@ -1199,6 +1211,16 @@
|
|
|
1199
1211
|
}
|
|
1200
1212
|
return bestIndex;
|
|
1201
1213
|
}
|
|
1214
|
+
function constIsAjvDataReference(schema) {
|
|
1215
|
+
const schemaConst = schema[CONST_KEY];
|
|
1216
|
+
const schemaType = getSchemaType(schema);
|
|
1217
|
+
return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== "object" && schemaType !== "array";
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// src/isConstant.ts
|
|
1221
|
+
function isConstant(schema) {
|
|
1222
|
+
return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
|
|
1223
|
+
}
|
|
1202
1224
|
|
|
1203
1225
|
// src/isFixedItems.ts
|
|
1204
1226
|
function isFixedItems(schema) {
|
|
@@ -1229,22 +1251,22 @@
|
|
|
1229
1251
|
if (isObject(formData)) {
|
|
1230
1252
|
const acc = Object.assign({}, defaults);
|
|
1231
1253
|
return Object.keys(formData).reduce((acc2, key) => {
|
|
1232
|
-
const keyValue =
|
|
1254
|
+
const keyValue = get15(formData, key);
|
|
1233
1255
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1234
1256
|
const keyExistsInFormData = key in formData;
|
|
1235
|
-
const keyDefault =
|
|
1236
|
-
const defaultValueIsNestedObject = keyExistsInDefaults && Object.
|
|
1237
|
-
const keyDefaultIsObject = keyExistsInDefaults && isObject(
|
|
1257
|
+
const keyDefault = get15(defaults, key) ?? {};
|
|
1258
|
+
const defaultValueIsNestedObject = keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
|
|
1259
|
+
const keyDefaultIsObject = keyExistsInDefaults && isObject(get15(defaults, key));
|
|
1238
1260
|
const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
|
|
1239
1261
|
if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
|
|
1240
1262
|
acc2[key] = {
|
|
1241
|
-
...
|
|
1263
|
+
...get15(defaults, key),
|
|
1242
1264
|
...keyValue
|
|
1243
1265
|
};
|
|
1244
1266
|
return acc2;
|
|
1245
1267
|
}
|
|
1246
1268
|
acc2[key] = mergeDefaultsWithFormData(
|
|
1247
|
-
|
|
1269
|
+
get15(defaults, key),
|
|
1248
1270
|
keyValue,
|
|
1249
1271
|
mergeExtraArrayDefaults,
|
|
1250
1272
|
defaultSupercedesUndefined,
|
|
@@ -1288,37 +1310,6 @@
|
|
|
1288
1310
|
);
|
|
1289
1311
|
}
|
|
1290
1312
|
|
|
1291
|
-
// src/isConstant.ts
|
|
1292
|
-
function isConstant(schema) {
|
|
1293
|
-
return Array.isArray(schema.enum) && schema.enum.length === 1 || CONST_KEY in schema;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
// src/schema/isSelect.ts
|
|
1297
|
-
function isSelect(validator, theSchema, rootSchema = {}, experimental_customMergeAllOf) {
|
|
1298
|
-
const schema = retrieveSchema(validator, theSchema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
1299
|
-
const altSchemas = schema.oneOf || schema.anyOf;
|
|
1300
|
-
if (Array.isArray(schema.enum)) {
|
|
1301
|
-
return true;
|
|
1302
|
-
}
|
|
1303
|
-
if (Array.isArray(altSchemas)) {
|
|
1304
|
-
return altSchemas.every((altSchemas2) => typeof altSchemas2 !== "boolean" && isConstant(altSchemas2));
|
|
1305
|
-
}
|
|
1306
|
-
return false;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
// src/schema/isMultiSelect.ts
|
|
1310
|
-
function isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) {
|
|
1311
|
-
if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
|
|
1312
|
-
return false;
|
|
1313
|
-
}
|
|
1314
|
-
return isSelect(validator, schema.items, rootSchema, experimental_customMergeAllOf);
|
|
1315
|
-
}
|
|
1316
|
-
function constIsAjvDataReference(schema) {
|
|
1317
|
-
const schemaConst = schema[CONST_KEY];
|
|
1318
|
-
const schemaType = getSchemaType(schema);
|
|
1319
|
-
return isObject(schemaConst) && isString(schemaConst?.$data) && schemaType !== "object" && schemaType !== "array";
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
1313
|
// src/toConstant.ts
|
|
1323
1314
|
function toConstant(schema) {
|
|
1324
1315
|
if (ENUM_KEY in schema && Array.isArray(schema.enum) && schema.enum.length === 1) {
|
|
@@ -1381,8 +1372,8 @@
|
|
|
1381
1372
|
let value;
|
|
1382
1373
|
let label = title;
|
|
1383
1374
|
if (selectorField) {
|
|
1384
|
-
const innerSchema =
|
|
1385
|
-
value =
|
|
1375
|
+
const innerSchema = get15(aSchema, [PROPERTIES_KEY, selectorField], {});
|
|
1376
|
+
value = get15(innerSchema, DEFAULT_KEY, get15(innerSchema, CONST_KEY));
|
|
1386
1377
|
label = label || innerSchema?.title || aSchema.title || String(value);
|
|
1387
1378
|
} else {
|
|
1388
1379
|
value = toConstant(aSchema);
|
|
@@ -1396,6 +1387,27 @@
|
|
|
1396
1387
|
});
|
|
1397
1388
|
}
|
|
1398
1389
|
|
|
1390
|
+
// src/schema/isSelect.ts
|
|
1391
|
+
function isSelect(validator, theSchema, rootSchema = {}, experimental_customMergeAllOf) {
|
|
1392
|
+
const schema = retrieveSchema(validator, theSchema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
1393
|
+
const altSchemas = schema.oneOf || schema.anyOf;
|
|
1394
|
+
if (Array.isArray(schema.enum)) {
|
|
1395
|
+
return true;
|
|
1396
|
+
}
|
|
1397
|
+
if (Array.isArray(altSchemas)) {
|
|
1398
|
+
return altSchemas.every((altSchemas2) => typeof altSchemas2 !== "boolean" && isConstant(altSchemas2));
|
|
1399
|
+
}
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// src/schema/isMultiSelect.ts
|
|
1404
|
+
function isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) {
|
|
1405
|
+
if (!schema.uniqueItems || !schema.items || typeof schema.items === "boolean") {
|
|
1406
|
+
return false;
|
|
1407
|
+
}
|
|
1408
|
+
return isSelect(validator, schema.items, rootSchema, experimental_customMergeAllOf);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1399
1411
|
// src/schema/getDefaultFormState.ts
|
|
1400
1412
|
var PRIMITIVE_TYPES = ["string", "number", "integer", "boolean", "null"];
|
|
1401
1413
|
function getInnerSchemaForArrayItem(schema, additionalItems = 0 /* Ignore */, idx = -1) {
|
|
@@ -1629,7 +1641,7 @@
|
|
|
1629
1641
|
const parentConst = retrievedSchema[CONST_KEY];
|
|
1630
1642
|
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1631
1643
|
(acc, key) => {
|
|
1632
|
-
const propertySchema =
|
|
1644
|
+
const propertySchema = get15(retrievedSchema, [PROPERTIES_KEY, key], {});
|
|
1633
1645
|
const hasParentConst = isObject(parentConst) && parentConst[key] !== void 0;
|
|
1634
1646
|
const hasConst = (isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst) && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(propertySchema);
|
|
1635
1647
|
const computedDefault = computeDefaults(validator, propertySchema, {
|
|
@@ -1638,8 +1650,8 @@
|
|
|
1638
1650
|
experimental_defaultFormStateBehavior,
|
|
1639
1651
|
experimental_customMergeAllOf,
|
|
1640
1652
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1641
|
-
parentDefaults:
|
|
1642
|
-
rawFormData:
|
|
1653
|
+
parentDefaults: get15(defaults, [key]),
|
|
1654
|
+
rawFormData: get15(formData, [key]),
|
|
1643
1655
|
required: retrievedSchema.required?.includes(key),
|
|
1644
1656
|
shouldMergeDefaultsIntoFormData,
|
|
1645
1657
|
initialDefaultsGenerated
|
|
@@ -1677,8 +1689,8 @@
|
|
|
1677
1689
|
experimental_defaultFormStateBehavior,
|
|
1678
1690
|
experimental_customMergeAllOf,
|
|
1679
1691
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1680
|
-
parentDefaults:
|
|
1681
|
-
rawFormData:
|
|
1692
|
+
parentDefaults: get15(defaults, [key]),
|
|
1693
|
+
rawFormData: get15(formData, [key]),
|
|
1682
1694
|
required: retrievedSchema.required?.includes(key),
|
|
1683
1695
|
shouldMergeDefaultsIntoFormData,
|
|
1684
1696
|
initialDefaultsGenerated
|
|
@@ -1745,7 +1757,7 @@
|
|
|
1745
1757
|
experimental_defaultFormStateBehavior,
|
|
1746
1758
|
experimental_customMergeAllOf,
|
|
1747
1759
|
rawFormData: item,
|
|
1748
|
-
parentDefaults:
|
|
1760
|
+
parentDefaults: get15(defaults, [idx]),
|
|
1749
1761
|
required,
|
|
1750
1762
|
shouldMergeDefaultsIntoFormData,
|
|
1751
1763
|
initialDefaultsGenerated
|
|
@@ -1755,14 +1767,11 @@
|
|
|
1755
1767
|
defaults = mergeDefaultsWithFormData(defaults, itemDefaults, mergeExtraDefaults);
|
|
1756
1768
|
}
|
|
1757
1769
|
}
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
if (ignoreMinItemsFlagSet && !required) {
|
|
1764
|
-
return defaults ? defaults : void 0;
|
|
1765
|
-
}
|
|
1770
|
+
if (neverPopulate) {
|
|
1771
|
+
return defaults ?? emptyDefault;
|
|
1772
|
+
}
|
|
1773
|
+
if (ignoreMinItemsFlagSet && !required) {
|
|
1774
|
+
return defaults ? defaults : void 0;
|
|
1766
1775
|
}
|
|
1767
1776
|
let arrayDefault;
|
|
1768
1777
|
const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
|
|
@@ -1871,7 +1880,7 @@
|
|
|
1871
1880
|
let displayLabel = Boolean(label);
|
|
1872
1881
|
if (displayLabel) {
|
|
1873
1882
|
const schemaType = getSchemaType(schema);
|
|
1874
|
-
const addedByAdditionalProperty =
|
|
1883
|
+
const addedByAdditionalProperty = get15(schema, ADDITIONAL_PROPERTY_FLAG, false);
|
|
1875
1884
|
if (schemaType === "array") {
|
|
1876
1885
|
displayLabel = addedByAdditionalProperty || isMultiSelect(validator, schema, rootSchema, experimental_customMergeAllOf) || isFilesArray(validator, schema, uiSchema, rootSchema, experimental_customMergeAllOf) || isCustomWidget(uiSchema);
|
|
1877
1886
|
}
|
|
@@ -1887,133 +1896,6 @@
|
|
|
1887
1896
|
}
|
|
1888
1897
|
return displayLabel;
|
|
1889
1898
|
}
|
|
1890
|
-
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1891
|
-
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
|
|
1892
|
-
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1893
|
-
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
1894
|
-
if (sameSchemaIndex === -1) {
|
|
1895
|
-
return toPathSchemaInternal(
|
|
1896
|
-
validator,
|
|
1897
|
-
_schema,
|
|
1898
|
-
name,
|
|
1899
|
-
rootSchema,
|
|
1900
|
-
formData,
|
|
1901
|
-
_recurseList.concat(_schema),
|
|
1902
|
-
experimental_customMergeAllOf
|
|
1903
|
-
);
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
let pathSchema = {
|
|
1907
|
-
[NAME_KEY]: name.replace(/^\./, "")
|
|
1908
|
-
};
|
|
1909
|
-
if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
|
|
1910
|
-
const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
|
|
1911
|
-
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
1912
|
-
const index = getClosestMatchingOption(
|
|
1913
|
-
validator,
|
|
1914
|
-
rootSchema,
|
|
1915
|
-
formData,
|
|
1916
|
-
xxxOf,
|
|
1917
|
-
0,
|
|
1918
|
-
discriminator,
|
|
1919
|
-
experimental_customMergeAllOf
|
|
1920
|
-
);
|
|
1921
|
-
const _schema = xxxOf[index];
|
|
1922
|
-
pathSchema = {
|
|
1923
|
-
...pathSchema,
|
|
1924
|
-
...toPathSchemaInternal(
|
|
1925
|
-
validator,
|
|
1926
|
-
_schema,
|
|
1927
|
-
name,
|
|
1928
|
-
rootSchema,
|
|
1929
|
-
formData,
|
|
1930
|
-
_recurseList,
|
|
1931
|
-
experimental_customMergeAllOf
|
|
1932
|
-
)
|
|
1933
|
-
};
|
|
1934
|
-
}
|
|
1935
|
-
if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
|
|
1936
|
-
set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
|
|
1937
|
-
const additionalSchema = isObject2(schema[ADDITIONAL_PROPERTIES_KEY]) ? schema[ADDITIONAL_PROPERTIES_KEY] : {};
|
|
1938
|
-
const definedProperties = get16(schema, PROPERTIES_KEY, {});
|
|
1939
|
-
for (const key of Object.keys(formData ?? {})) {
|
|
1940
|
-
if (!(key in definedProperties)) {
|
|
1941
|
-
pathSchema[key] = toPathSchemaInternal(
|
|
1942
|
-
validator,
|
|
1943
|
-
additionalSchema,
|
|
1944
|
-
`${name}.${key}`,
|
|
1945
|
-
rootSchema,
|
|
1946
|
-
get16(formData, [key]),
|
|
1947
|
-
_recurseList,
|
|
1948
|
-
experimental_customMergeAllOf
|
|
1949
|
-
);
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
if (ITEMS_KEY in schema && Array.isArray(formData)) {
|
|
1954
|
-
const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;
|
|
1955
|
-
if (Array.isArray(schemaItems)) {
|
|
1956
|
-
formData.forEach((element, i) => {
|
|
1957
|
-
if (schemaItems[i]) {
|
|
1958
|
-
pathSchema[i] = toPathSchemaInternal(
|
|
1959
|
-
validator,
|
|
1960
|
-
schemaItems[i],
|
|
1961
|
-
`${name}.${i}`,
|
|
1962
|
-
rootSchema,
|
|
1963
|
-
element,
|
|
1964
|
-
_recurseList,
|
|
1965
|
-
experimental_customMergeAllOf
|
|
1966
|
-
);
|
|
1967
|
-
} else if (schemaAdditionalItems) {
|
|
1968
|
-
pathSchema[i] = toPathSchemaInternal(
|
|
1969
|
-
validator,
|
|
1970
|
-
schemaAdditionalItems,
|
|
1971
|
-
`${name}.${i}`,
|
|
1972
|
-
rootSchema,
|
|
1973
|
-
element,
|
|
1974
|
-
_recurseList,
|
|
1975
|
-
experimental_customMergeAllOf
|
|
1976
|
-
);
|
|
1977
|
-
} else {
|
|
1978
|
-
console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
} else {
|
|
1982
|
-
formData.forEach((element, i) => {
|
|
1983
|
-
pathSchema[i] = toPathSchemaInternal(
|
|
1984
|
-
validator,
|
|
1985
|
-
schemaItems,
|
|
1986
|
-
`${name}.${i}`,
|
|
1987
|
-
rootSchema,
|
|
1988
|
-
element,
|
|
1989
|
-
_recurseList,
|
|
1990
|
-
experimental_customMergeAllOf
|
|
1991
|
-
);
|
|
1992
|
-
});
|
|
1993
|
-
}
|
|
1994
|
-
} else if (PROPERTIES_KEY in schema) {
|
|
1995
|
-
for (const property in schema.properties) {
|
|
1996
|
-
const field = get16(schema, [PROPERTIES_KEY, property], {});
|
|
1997
|
-
pathSchema[property] = toPathSchemaInternal(
|
|
1998
|
-
validator,
|
|
1999
|
-
field,
|
|
2000
|
-
`${name}.${property}`,
|
|
2001
|
-
rootSchema,
|
|
2002
|
-
// It's possible that formData is not an object -- this can happen if an
|
|
2003
|
-
// array item has just been added, but not populated with data yet
|
|
2004
|
-
get16(formData, [property]),
|
|
2005
|
-
_recurseList,
|
|
2006
|
-
experimental_customMergeAllOf
|
|
2007
|
-
);
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
return pathSchema;
|
|
2011
|
-
}
|
|
2012
|
-
function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
|
|
2013
|
-
return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
|
|
2014
|
-
}
|
|
2015
|
-
|
|
2016
|
-
// src/schema/omitExtraData.ts
|
|
2017
1899
|
function getUsedFormData(formData, fields) {
|
|
2018
1900
|
if (fields.length === 0 && typeof formData !== "object") {
|
|
2019
1901
|
return formData;
|
|
@@ -2039,7 +1921,7 @@
|
|
|
2039
1921
|
}
|
|
2040
1922
|
} else if (key === NAME_KEY && data !== "") {
|
|
2041
1923
|
paths.forEach((path) => {
|
|
2042
|
-
const formValue =
|
|
1924
|
+
const formValue = get15(formData, path);
|
|
2043
1925
|
const isLeaf = objKeys.length === 1;
|
|
2044
1926
|
if (formValueHasData(formValue, isLeaf) || Array.isArray(formValue) && formValue.every((val) => formValueHasData(val, isLeaf))) {
|
|
2045
1927
|
acc.push(path);
|
|
@@ -2051,82 +1933,272 @@
|
|
|
2051
1933
|
};
|
|
2052
1934
|
return getAllPaths(pathSchema);
|
|
2053
1935
|
}
|
|
2054
|
-
function
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
1936
|
+
function isValueEmpty(value) {
|
|
1937
|
+
if (isNil(value) || value === "") {
|
|
1938
|
+
return true;
|
|
1939
|
+
}
|
|
1940
|
+
if (Array.isArray(value)) {
|
|
1941
|
+
return value.length === 0;
|
|
1942
|
+
}
|
|
1943
|
+
if (isObject(value)) {
|
|
1944
|
+
return Object.values(value).every(isValueEmpty);
|
|
1945
|
+
}
|
|
1946
|
+
return false;
|
|
2062
1947
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
1948
|
+
function doMergeAllOf(schema, experimental_customMergeAllOf) {
|
|
1949
|
+
return experimental_customMergeAllOf ? experimental_customMergeAllOf(schema) : shallowAllOfMerge_default(schema);
|
|
1950
|
+
}
|
|
1951
|
+
function omitExtraData(validator, schema, rootSchema = {}, formData, experimental_customMergeAllOf) {
|
|
1952
|
+
function isObjectValue(value) {
|
|
1953
|
+
return isObject(value);
|
|
1954
|
+
}
|
|
1955
|
+
function isSchemaObj(schemaDef) {
|
|
1956
|
+
return isObject(schemaDef);
|
|
1957
|
+
}
|
|
1958
|
+
function handleObject(schema2, source, target) {
|
|
1959
|
+
const { properties, additionalProperties, patternProperties, propertyNames } = schema2;
|
|
1960
|
+
const requiredSet = new Set(schema2.required ?? []);
|
|
1961
|
+
function setProperty(key, schemaDef, value, required = false) {
|
|
1962
|
+
const v = omit3(schemaDef, value, target[key]);
|
|
1963
|
+
if (!required && isObject(v)) {
|
|
1964
|
+
let sd = isSchemaObj(schemaDef) ? schemaDef : {};
|
|
1965
|
+
if (sd.$ref !== void 0) {
|
|
1966
|
+
sd = findSchemaDefinition(sd.$ref, rootSchema);
|
|
2073
1967
|
}
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
const nestedData = {};
|
|
2078
|
-
keys2.forEach((key) => {
|
|
2079
|
-
const formValue = get16(data, key);
|
|
2080
|
-
let oldKeyedSchema = get16(oldSchema, [PROPERTIES_KEY, key], {});
|
|
2081
|
-
let newKeyedSchema = get16(newSchema, [PROPERTIES_KEY, key], {});
|
|
2082
|
-
if (has5(oldKeyedSchema, REF_KEY)) {
|
|
2083
|
-
oldKeyedSchema = retrieveSchema(
|
|
2084
|
-
validator,
|
|
2085
|
-
oldKeyedSchema,
|
|
2086
|
-
rootSchema,
|
|
2087
|
-
formValue,
|
|
2088
|
-
experimental_customMergeAllOf
|
|
1968
|
+
const innerRequired = new Set(sd.required ?? []);
|
|
1969
|
+
const shouldDrop = Object.entries(v).every(
|
|
1970
|
+
([k, val]) => !innerRequired.has(k) && isValueEmpty(val)
|
|
2089
1971
|
);
|
|
1972
|
+
if (shouldDrop) {
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
2090
1975
|
}
|
|
2091
|
-
if (
|
|
2092
|
-
|
|
2093
|
-
validator,
|
|
2094
|
-
newKeyedSchema,
|
|
2095
|
-
rootSchema,
|
|
2096
|
-
formValue,
|
|
2097
|
-
experimental_customMergeAllOf
|
|
2098
|
-
);
|
|
1976
|
+
if (v !== void 0) {
|
|
1977
|
+
target[key] = v;
|
|
2099
1978
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
1979
|
+
}
|
|
1980
|
+
if (properties !== void 0) {
|
|
1981
|
+
for (const [key, schemaDef] of Object.entries(properties)) {
|
|
1982
|
+
setProperty(key, schemaDef, source[key], requiredSet.has(key));
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
let patternPropertiesRest;
|
|
1986
|
+
if (patternProperties !== void 0) {
|
|
1987
|
+
patternPropertiesRest = [];
|
|
1988
|
+
const patterns = Object.entries(patternProperties).map(([pattern, schemaDef]) => [
|
|
1989
|
+
new RegExp(pattern),
|
|
1990
|
+
schemaDef
|
|
1991
|
+
]);
|
|
1992
|
+
const knownProperties = new Set(Object.keys(properties ?? {}));
|
|
1993
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1994
|
+
if (knownProperties.has(key)) {
|
|
1995
|
+
continue;
|
|
2105
1996
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
1997
|
+
const matched = patterns.find(([re]) => re.test(key));
|
|
1998
|
+
if (matched === void 0) {
|
|
1999
|
+
patternPropertiesRest.push(key);
|
|
2000
|
+
continue;
|
|
2001
|
+
}
|
|
2002
|
+
setProperty(key, matched[1], value);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
if (additionalProperties !== void 0 && additionalProperties !== false) {
|
|
2006
|
+
const addlSchema = additionalProperties;
|
|
2007
|
+
if (patternPropertiesRest !== void 0) {
|
|
2008
|
+
for (const key of patternPropertiesRest) {
|
|
2009
|
+
setProperty(key, addlSchema, source[key]);
|
|
2010
|
+
}
|
|
2011
|
+
} else {
|
|
2012
|
+
const knownProperties = new Set(Object.keys(properties ?? {}));
|
|
2013
|
+
for (const [key, value] of Object.entries(source)) {
|
|
2014
|
+
if (knownProperties.has(key)) {
|
|
2015
|
+
continue;
|
|
2016
|
+
}
|
|
2017
|
+
setProperty(key, addlSchema, value);
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
if (propertyNames !== void 0) {
|
|
2022
|
+
for (const [key, value] of Object.entries(source)) {
|
|
2023
|
+
target[key] = value;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return target;
|
|
2027
|
+
}
|
|
2028
|
+
function handleArray(schema2, source, target) {
|
|
2029
|
+
const { items, additionalItems } = schema2;
|
|
2030
|
+
if (items !== void 0) {
|
|
2031
|
+
if (Array.isArray(items)) {
|
|
2032
|
+
for (let i = 0; i < items.length; i++) {
|
|
2033
|
+
target.push(omit3(items[i], source[i]));
|
|
2034
|
+
}
|
|
2035
|
+
} else {
|
|
2036
|
+
for (let i = 0; i < source.length; i++) {
|
|
2037
|
+
target.push(omit3(items, source[i]));
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
if (additionalItems) {
|
|
2042
|
+
for (let i = target.length; i < source.length; i++) {
|
|
2043
|
+
target.push(omit3(additionalItems, source[i]));
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
return target;
|
|
2047
|
+
}
|
|
2048
|
+
function handleConditions(schema2, source, target) {
|
|
2049
|
+
const { if: condition, then, else: otherwise } = schema2;
|
|
2050
|
+
if (condition === void 0) {
|
|
2051
|
+
return target;
|
|
2052
|
+
}
|
|
2053
|
+
const isThenBranch = isSchemaObj(condition) ? validator.isValid(condition, source, rootSchema) : condition;
|
|
2054
|
+
const branch = isThenBranch ? then : otherwise;
|
|
2055
|
+
return branch === void 0 ? target : omit3(branch, source, target);
|
|
2056
|
+
}
|
|
2057
|
+
function handleOneOf(oneOf, schema2, source, target) {
|
|
2058
|
+
if (!Array.isArray(oneOf) || isSelect(validator, schema2, rootSchema, experimental_customMergeAllOf)) {
|
|
2059
|
+
return target;
|
|
2060
|
+
}
|
|
2061
|
+
const scoringOptions = relaxOptionsForScoring(oneOf, true, rootSchema);
|
|
2062
|
+
const bestIndex = getClosestMatchingOption(
|
|
2063
|
+
validator,
|
|
2064
|
+
rootSchema,
|
|
2065
|
+
source,
|
|
2066
|
+
scoringOptions,
|
|
2067
|
+
0,
|
|
2068
|
+
getDiscriminatorFieldFromSchema(schema2),
|
|
2069
|
+
experimental_customMergeAllOf
|
|
2070
|
+
);
|
|
2071
|
+
const winning = oneOf[bestIndex];
|
|
2072
|
+
const resolved = isObject(winning) ? resolveAllReferences(winning, rootSchema, []) : scoringOptions[bestIndex];
|
|
2073
|
+
return omit3(resolved, source, target);
|
|
2074
|
+
}
|
|
2075
|
+
function handleAnyOf(schema2, source, target) {
|
|
2076
|
+
const { anyOf } = schema2;
|
|
2077
|
+
if (!Array.isArray(anyOf)) {
|
|
2078
|
+
return target;
|
|
2079
|
+
}
|
|
2080
|
+
if (source === void 0 || Array.isArray(source) && source.length === 0 || isObject(source) && Object.keys(source).length === 0) {
|
|
2081
|
+
for (const branch of anyOf) {
|
|
2082
|
+
target = omit3(branch, source, target);
|
|
2083
|
+
}
|
|
2084
|
+
return target;
|
|
2085
|
+
}
|
|
2086
|
+
return handleOneOf(anyOf, schema2, source, target);
|
|
2087
|
+
}
|
|
2088
|
+
function handleDependencies(schema2, source, target) {
|
|
2089
|
+
const { dependencies } = schema2;
|
|
2090
|
+
if (dependencies === void 0 || !isObjectValue(source)) {
|
|
2091
|
+
return target;
|
|
2092
|
+
}
|
|
2093
|
+
for (const [key, deps] of Object.entries(dependencies)) {
|
|
2094
|
+
if (!(key in source) || Array.isArray(deps)) {
|
|
2095
|
+
continue;
|
|
2096
|
+
}
|
|
2097
|
+
target = omit3(deps, source, target);
|
|
2098
|
+
}
|
|
2099
|
+
return target;
|
|
2100
|
+
}
|
|
2101
|
+
function omit3(schemaDef, source, target) {
|
|
2102
|
+
if (source === void 0 || schemaDef === false) {
|
|
2103
|
+
return void 0;
|
|
2104
|
+
}
|
|
2105
|
+
if (schemaDef === true || isEmpty4(schemaDef)) {
|
|
2106
|
+
return source;
|
|
2107
|
+
}
|
|
2108
|
+
let schema2 = schemaDef;
|
|
2109
|
+
const { $ref: ref, allOf } = schema2;
|
|
2110
|
+
if (ref !== void 0) {
|
|
2111
|
+
return omit3(findSchemaDefinition(ref, rootSchema), source, target);
|
|
2112
|
+
}
|
|
2113
|
+
if (allOf) {
|
|
2114
|
+
schema2 = doMergeAllOf(schema2, experimental_customMergeAllOf);
|
|
2115
|
+
}
|
|
2116
|
+
target = handleAnyOf(schema2, source, handleOneOf(schema2.oneOf, schema2, source, target));
|
|
2117
|
+
const type = getSchemaType(schema2);
|
|
2118
|
+
if (type === "object") {
|
|
2119
|
+
if (!isObjectValue(source)) {
|
|
2120
|
+
return void 0;
|
|
2121
|
+
}
|
|
2122
|
+
target = handleObject(schema2, source, isObjectValue(target) ? target : {});
|
|
2123
|
+
} else if (type === "array") {
|
|
2124
|
+
if (!Array.isArray(source)) {
|
|
2125
|
+
return void 0;
|
|
2126
|
+
}
|
|
2127
|
+
target = handleArray(schema2, source, Array.isArray(target) ? target : []);
|
|
2128
|
+
} else if (target === void 0) {
|
|
2129
|
+
target = source;
|
|
2130
|
+
}
|
|
2131
|
+
return handleDependencies(schema2, source, handleConditions(schema2, source, target));
|
|
2132
|
+
}
|
|
2133
|
+
return omit3(schema, formData);
|
|
2134
|
+
}
|
|
2135
|
+
var NO_VALUE = /* @__PURE__ */ Symbol("no Value");
|
|
2136
|
+
function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
|
|
2137
|
+
let newFormData;
|
|
2138
|
+
if (has5(newSchema, PROPERTIES_KEY)) {
|
|
2139
|
+
const removeOldSchemaData = {};
|
|
2140
|
+
if (has5(oldSchema, PROPERTIES_KEY)) {
|
|
2141
|
+
const properties = get15(oldSchema, PROPERTIES_KEY, {});
|
|
2142
|
+
Object.keys(properties).forEach((key) => {
|
|
2143
|
+
if (has5(data, key)) {
|
|
2144
|
+
removeOldSchemaData[key] = void 0;
|
|
2145
|
+
}
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
const keys2 = Object.keys(get15(newSchema, PROPERTIES_KEY, {}));
|
|
2149
|
+
const nestedData = {};
|
|
2150
|
+
keys2.forEach((key) => {
|
|
2151
|
+
const formValue = get15(data, key);
|
|
2152
|
+
let oldKeyedSchema = get15(oldSchema, [PROPERTIES_KEY, key], {});
|
|
2153
|
+
let newKeyedSchema = get15(newSchema, [PROPERTIES_KEY, key], {});
|
|
2154
|
+
if (has5(oldKeyedSchema, REF_KEY)) {
|
|
2155
|
+
oldKeyedSchema = retrieveSchema(
|
|
2156
|
+
validator,
|
|
2157
|
+
oldKeyedSchema,
|
|
2158
|
+
rootSchema,
|
|
2159
|
+
formValue,
|
|
2160
|
+
experimental_customMergeAllOf
|
|
2161
|
+
);
|
|
2162
|
+
}
|
|
2163
|
+
if (has5(newKeyedSchema, REF_KEY)) {
|
|
2164
|
+
newKeyedSchema = retrieveSchema(
|
|
2165
|
+
validator,
|
|
2166
|
+
newKeyedSchema,
|
|
2167
|
+
rootSchema,
|
|
2168
|
+
formValue,
|
|
2169
|
+
experimental_customMergeAllOf
|
|
2170
|
+
);
|
|
2171
|
+
}
|
|
2172
|
+
const oldSchemaTypeForKey = get15(oldKeyedSchema, "type");
|
|
2173
|
+
const newSchemaTypeForKey = get15(newKeyedSchema, "type");
|
|
2174
|
+
if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
|
|
2175
|
+
if (has5(removeOldSchemaData, key)) {
|
|
2176
|
+
delete removeOldSchemaData[key];
|
|
2177
|
+
}
|
|
2178
|
+
if (newSchemaTypeForKey === "object" || newSchemaTypeForKey === "array" && Array.isArray(formValue)) {
|
|
2179
|
+
const itemData = sanitizeDataForNewSchema(
|
|
2180
|
+
validator,
|
|
2181
|
+
rootSchema,
|
|
2182
|
+
newKeyedSchema,
|
|
2183
|
+
oldKeyedSchema,
|
|
2184
|
+
formValue,
|
|
2185
|
+
experimental_customMergeAllOf
|
|
2186
|
+
);
|
|
2115
2187
|
if (itemData !== void 0 || newSchemaTypeForKey === "array") {
|
|
2116
2188
|
nestedData[key] = itemData;
|
|
2117
2189
|
}
|
|
2118
2190
|
} else {
|
|
2119
|
-
const newOptionDefault =
|
|
2120
|
-
const oldOptionDefault =
|
|
2191
|
+
const newOptionDefault = get15(newKeyedSchema, "default", NO_VALUE);
|
|
2192
|
+
const oldOptionDefault = get15(oldKeyedSchema, "default", NO_VALUE);
|
|
2121
2193
|
if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
|
|
2122
2194
|
if (oldOptionDefault === formValue) {
|
|
2123
2195
|
removeOldSchemaData[key] = newOptionDefault;
|
|
2124
|
-
} else if (
|
|
2196
|
+
} else if (get15(newKeyedSchema, "readOnly") === true) {
|
|
2125
2197
|
removeOldSchemaData[key] = void 0;
|
|
2126
2198
|
}
|
|
2127
2199
|
}
|
|
2128
|
-
const newOptionConst =
|
|
2129
|
-
const oldOptionConst =
|
|
2200
|
+
const newOptionConst = get15(newKeyedSchema, "const", NO_VALUE);
|
|
2201
|
+
const oldOptionConst = get15(oldKeyedSchema, "const", NO_VALUE);
|
|
2130
2202
|
if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
|
|
2131
2203
|
removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
|
|
2132
2204
|
}
|
|
@@ -2138,9 +2210,9 @@
|
|
|
2138
2210
|
...removeOldSchemaData,
|
|
2139
2211
|
...nestedData
|
|
2140
2212
|
};
|
|
2141
|
-
} else if (
|
|
2142
|
-
let oldSchemaItems =
|
|
2143
|
-
let newSchemaItems =
|
|
2213
|
+
} else if (get15(oldSchema, "type") === "array" && get15(newSchema, "type") === "array" && Array.isArray(data)) {
|
|
2214
|
+
let oldSchemaItems = get15(oldSchema, "items");
|
|
2215
|
+
let newSchemaItems = get15(newSchema, "items");
|
|
2144
2216
|
if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
|
|
2145
2217
|
if (has5(oldSchemaItems, REF_KEY)) {
|
|
2146
2218
|
oldSchemaItems = retrieveSchema(
|
|
@@ -2160,10 +2232,10 @@
|
|
|
2160
2232
|
experimental_customMergeAllOf
|
|
2161
2233
|
);
|
|
2162
2234
|
}
|
|
2163
|
-
const oldSchemaType =
|
|
2164
|
-
const newSchemaType =
|
|
2235
|
+
const oldSchemaType = get15(oldSchemaItems, "type");
|
|
2236
|
+
const newSchemaType = get15(newSchemaItems, "type");
|
|
2165
2237
|
if (!oldSchemaType || oldSchemaType === newSchemaType) {
|
|
2166
|
-
const maxItems =
|
|
2238
|
+
const maxItems = get15(newSchema, "maxItems", -1);
|
|
2167
2239
|
if (newSchemaType === "object") {
|
|
2168
2240
|
newFormData = data.reduce((newValue, aValue) => {
|
|
2169
2241
|
const itemValue = sanitizeDataForNewSchema(
|
|
@@ -2189,6 +2261,133 @@
|
|
|
2189
2261
|
}
|
|
2190
2262
|
return newFormData;
|
|
2191
2263
|
}
|
|
2264
|
+
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
2265
|
+
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
|
|
2266
|
+
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
2267
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
2268
|
+
if (sameSchemaIndex === -1) {
|
|
2269
|
+
return toPathSchemaInternal(
|
|
2270
|
+
validator,
|
|
2271
|
+
_schema,
|
|
2272
|
+
name,
|
|
2273
|
+
rootSchema,
|
|
2274
|
+
formData,
|
|
2275
|
+
_recurseList.concat(_schema),
|
|
2276
|
+
experimental_customMergeAllOf
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
let pathSchema = {
|
|
2281
|
+
[NAME_KEY]: name.replace(/^\./, "")
|
|
2282
|
+
};
|
|
2283
|
+
if (ONE_OF_KEY in schema || ANY_OF_KEY in schema) {
|
|
2284
|
+
const xxxOf = ONE_OF_KEY in schema ? schema.oneOf : schema.anyOf;
|
|
2285
|
+
const discriminator = getDiscriminatorFieldFromSchema(schema);
|
|
2286
|
+
const index = getClosestMatchingOption(
|
|
2287
|
+
validator,
|
|
2288
|
+
rootSchema,
|
|
2289
|
+
formData,
|
|
2290
|
+
xxxOf,
|
|
2291
|
+
0,
|
|
2292
|
+
discriminator,
|
|
2293
|
+
experimental_customMergeAllOf
|
|
2294
|
+
);
|
|
2295
|
+
const _schema = xxxOf[index];
|
|
2296
|
+
pathSchema = {
|
|
2297
|
+
...pathSchema,
|
|
2298
|
+
...toPathSchemaInternal(
|
|
2299
|
+
validator,
|
|
2300
|
+
_schema,
|
|
2301
|
+
name,
|
|
2302
|
+
rootSchema,
|
|
2303
|
+
formData,
|
|
2304
|
+
_recurseList,
|
|
2305
|
+
experimental_customMergeAllOf
|
|
2306
|
+
)
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
if (ADDITIONAL_PROPERTIES_KEY in schema && schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
|
|
2310
|
+
set(pathSchema, RJSF_ADDITIONAL_PROPERTIES_FLAG, true);
|
|
2311
|
+
const additionalSchema = isObject2(schema[ADDITIONAL_PROPERTIES_KEY]) ? schema[ADDITIONAL_PROPERTIES_KEY] : {};
|
|
2312
|
+
const definedProperties = get15(schema, PROPERTIES_KEY, {});
|
|
2313
|
+
for (const key of Object.keys(formData ?? {})) {
|
|
2314
|
+
if (!(key in definedProperties)) {
|
|
2315
|
+
pathSchema[key] = toPathSchemaInternal(
|
|
2316
|
+
validator,
|
|
2317
|
+
additionalSchema,
|
|
2318
|
+
`${name}.${key}`,
|
|
2319
|
+
rootSchema,
|
|
2320
|
+
get15(formData, [key]),
|
|
2321
|
+
_recurseList,
|
|
2322
|
+
experimental_customMergeAllOf
|
|
2323
|
+
);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
if (ITEMS_KEY in schema && Array.isArray(formData)) {
|
|
2328
|
+
const { items: schemaItems, additionalItems: schemaAdditionalItems } = schema;
|
|
2329
|
+
if (Array.isArray(schemaItems)) {
|
|
2330
|
+
formData.forEach((element, i) => {
|
|
2331
|
+
if (schemaItems[i]) {
|
|
2332
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
2333
|
+
validator,
|
|
2334
|
+
schemaItems[i],
|
|
2335
|
+
`${name}.${i}`,
|
|
2336
|
+
rootSchema,
|
|
2337
|
+
element,
|
|
2338
|
+
_recurseList,
|
|
2339
|
+
experimental_customMergeAllOf
|
|
2340
|
+
);
|
|
2341
|
+
} else if (schemaAdditionalItems) {
|
|
2342
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
2343
|
+
validator,
|
|
2344
|
+
schemaAdditionalItems,
|
|
2345
|
+
`${name}.${i}`,
|
|
2346
|
+
rootSchema,
|
|
2347
|
+
element,
|
|
2348
|
+
_recurseList,
|
|
2349
|
+
experimental_customMergeAllOf
|
|
2350
|
+
);
|
|
2351
|
+
} else {
|
|
2352
|
+
console.warn(`Unable to generate path schema for "${name}.${i}". No schema defined for it`);
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
2355
|
+
} else {
|
|
2356
|
+
formData.forEach((element, i) => {
|
|
2357
|
+
pathSchema[i] = toPathSchemaInternal(
|
|
2358
|
+
validator,
|
|
2359
|
+
schemaItems,
|
|
2360
|
+
`${name}.${i}`,
|
|
2361
|
+
rootSchema,
|
|
2362
|
+
element,
|
|
2363
|
+
_recurseList,
|
|
2364
|
+
experimental_customMergeAllOf
|
|
2365
|
+
);
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
} else if (PROPERTIES_KEY in schema) {
|
|
2369
|
+
for (const property in schema.properties) {
|
|
2370
|
+
const field = get15(schema, [PROPERTIES_KEY, property], {});
|
|
2371
|
+
pathSchema[property] = toPathSchemaInternal(
|
|
2372
|
+
validator,
|
|
2373
|
+
field,
|
|
2374
|
+
`${name}.${property}`,
|
|
2375
|
+
rootSchema,
|
|
2376
|
+
// It's possible that formData is not an object -- this can happen if an
|
|
2377
|
+
// array item has just been added, but not populated with data yet
|
|
2378
|
+
get15(formData, [property]),
|
|
2379
|
+
_recurseList,
|
|
2380
|
+
experimental_customMergeAllOf
|
|
2381
|
+
);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
return pathSchema;
|
|
2385
|
+
}
|
|
2386
|
+
function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
|
|
2387
|
+
return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// src/createSchemaUtils.ts
|
|
2192
2391
|
var SchemaUtils = class {
|
|
2193
2392
|
/** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
|
|
2194
2393
|
*
|
|
@@ -2199,7 +2398,7 @@
|
|
|
2199
2398
|
*/
|
|
2200
2399
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
2201
2400
|
if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
2202
|
-
this.rootSchema = makeAllReferencesAbsolute(rootSchema,
|
|
2401
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get15(rootSchema, ID_KEY, "#"));
|
|
2203
2402
|
} else {
|
|
2204
2403
|
this.rootSchema = rootSchema;
|
|
2205
2404
|
}
|
|
@@ -2528,31 +2727,6 @@
|
|
|
2528
2727
|
return options;
|
|
2529
2728
|
}
|
|
2530
2729
|
|
|
2531
|
-
// src/shallowEquals.ts
|
|
2532
|
-
function shallowEquals(a, b) {
|
|
2533
|
-
if (Object.is(a, b)) {
|
|
2534
|
-
return true;
|
|
2535
|
-
}
|
|
2536
|
-
if (a == null || b == null) {
|
|
2537
|
-
return false;
|
|
2538
|
-
}
|
|
2539
|
-
if (typeof a !== "object" || typeof b !== "object") {
|
|
2540
|
-
return false;
|
|
2541
|
-
}
|
|
2542
|
-
const keysA = Object.keys(a);
|
|
2543
|
-
const keysB = Object.keys(b);
|
|
2544
|
-
if (keysA.length !== keysB.length) {
|
|
2545
|
-
return false;
|
|
2546
|
-
}
|
|
2547
|
-
for (let i = 0; i < keysA.length; i++) {
|
|
2548
|
-
const key = keysA[i];
|
|
2549
|
-
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {
|
|
2550
|
-
return false;
|
|
2551
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
return true;
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
2730
|
// src/replaceStringParameters.ts
|
|
2557
2731
|
function replaceStringParameters(inputString, params) {
|
|
2558
2732
|
let output = inputString;
|
|
@@ -2574,6 +2748,25 @@
|
|
|
2574
2748
|
return replaceStringParameters(stringToTranslate, params);
|
|
2575
2749
|
}
|
|
2576
2750
|
|
|
2751
|
+
// src/enumOptionsValueForIndex.ts
|
|
2752
|
+
function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
2753
|
+
if (Array.isArray(valueIndex)) {
|
|
2754
|
+
return valueIndex.map((index2) => enumOptionsValueForIndex(index2, allEnumOptions)).filter((val) => val !== void 0);
|
|
2755
|
+
}
|
|
2756
|
+
const index = valueIndex === "" || valueIndex === null ? -1 : Number(valueIndex);
|
|
2757
|
+
const option = allEnumOptions[index];
|
|
2758
|
+
return option ? option.value : emptyValue;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
// src/enumOptionsDeselectValue.ts
|
|
2762
|
+
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2763
|
+
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2764
|
+
if (Array.isArray(selected)) {
|
|
2765
|
+
return selected.filter((v) => !deepEquals_default(v, value));
|
|
2766
|
+
}
|
|
2767
|
+
return deepEquals_default(value, selected) ? void 0 : selected;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2577
2770
|
// src/enumOptionsIsSelected.ts
|
|
2578
2771
|
function enumOptionsIsSelected(value, selected) {
|
|
2579
2772
|
if (Array.isArray(selected)) {
|
|
@@ -2603,15 +2796,15 @@
|
|
|
2603
2796
|
const indexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
2604
2797
|
return typeof indexes === "undefined" ? emptyValue : indexes;
|
|
2605
2798
|
}
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2799
|
+
function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2800
|
+
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2801
|
+
if (!isNil(value)) {
|
|
2802
|
+
const index = allEnumOptions.findIndex((opt) => value === opt.value);
|
|
2803
|
+
const all = allEnumOptions.map(({ value: val }) => val);
|
|
2804
|
+
const updated = selected.slice(0, index).concat(value, selected.slice(index));
|
|
2805
|
+
return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));
|
|
2611
2806
|
}
|
|
2612
|
-
|
|
2613
|
-
const option = allEnumOptions[index];
|
|
2614
|
-
return option ? option.value : emptyValue;
|
|
2807
|
+
return selected;
|
|
2615
2808
|
}
|
|
2616
2809
|
|
|
2617
2810
|
// src/enumOptionValueDecoder.ts
|
|
@@ -2650,25 +2843,6 @@
|
|
|
2650
2843
|
}
|
|
2651
2844
|
return String(value);
|
|
2652
2845
|
}
|
|
2653
|
-
|
|
2654
|
-
// src/enumOptionsDeselectValue.ts
|
|
2655
|
-
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2656
|
-
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2657
|
-
if (Array.isArray(selected)) {
|
|
2658
|
-
return selected.filter((v) => !deepEquals_default(v, value));
|
|
2659
|
-
}
|
|
2660
|
-
return deepEquals_default(value, selected) ? void 0 : selected;
|
|
2661
|
-
}
|
|
2662
|
-
function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2663
|
-
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2664
|
-
if (!isNil(value)) {
|
|
2665
|
-
const index = allEnumOptions.findIndex((opt) => value === opt.value);
|
|
2666
|
-
const all = allEnumOptions.map(({ value: val }) => val);
|
|
2667
|
-
const updated = selected.slice(0, index).concat(value, selected.slice(index));
|
|
2668
|
-
return updated.sort((a, b) => Number(all.indexOf(a) > all.indexOf(b)));
|
|
2669
|
-
}
|
|
2670
|
-
return selected;
|
|
2671
|
-
}
|
|
2672
2846
|
var ErrorSchemaBuilder = class {
|
|
2673
2847
|
/** Construct an `ErrorSchemaBuilder` with an optional initial set of errors in an `ErrorSchema`.
|
|
2674
2848
|
*
|
|
@@ -2695,7 +2869,7 @@
|
|
|
2695
2869
|
*/
|
|
2696
2870
|
getOrCreateErrorBlock(pathOfError) {
|
|
2697
2871
|
const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
|
|
2698
|
-
let errorBlock = hasPath ?
|
|
2872
|
+
let errorBlock = hasPath ? get15(this.errorSchema, pathOfError) : this.errorSchema;
|
|
2699
2873
|
if (!errorBlock && pathOfError) {
|
|
2700
2874
|
errorBlock = {};
|
|
2701
2875
|
setWith(this.errorSchema, pathOfError, errorBlock, Object);
|
|
@@ -2721,7 +2895,7 @@
|
|
|
2721
2895
|
*/
|
|
2722
2896
|
addErrors(errorOrList, pathOfError) {
|
|
2723
2897
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
2724
|
-
let errorsList =
|
|
2898
|
+
let errorsList = get15(errorBlock, ERRORS_KEY);
|
|
2725
2899
|
if (!Array.isArray(errorsList)) {
|
|
2726
2900
|
errorsList = [];
|
|
2727
2901
|
errorBlock[ERRORS_KEY] = errorsList;
|
|
@@ -2771,7 +2945,7 @@
|
|
|
2771
2945
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
2772
2946
|
return keys(b);
|
|
2773
2947
|
} else {
|
|
2774
|
-
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value,
|
|
2948
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get15(b, key))));
|
|
2775
2949
|
const diffFields = difference(keys(b), keys(a));
|
|
2776
2950
|
return [...unequalFields, ...diffFields];
|
|
2777
2951
|
}
|
|
@@ -2897,7 +3071,7 @@
|
|
|
2897
3071
|
);
|
|
2898
3072
|
}
|
|
2899
3073
|
function getTestIds() {
|
|
2900
|
-
if (
|
|
3074
|
+
if (get15(globalThis, "process.env.NODE_ENV") !== "test") {
|
|
2901
3075
|
return {};
|
|
2902
3076
|
}
|
|
2903
3077
|
const ids = /* @__PURE__ */ new Map();
|
|
@@ -2966,7 +3140,7 @@
|
|
|
2966
3140
|
}
|
|
2967
3141
|
};
|
|
2968
3142
|
function mergeWidgetOptions(AWidget) {
|
|
2969
|
-
let MergedWidget =
|
|
3143
|
+
let MergedWidget = get15(AWidget, "MergedWidget");
|
|
2970
3144
|
if (!MergedWidget) {
|
|
2971
3145
|
const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
|
|
2972
3146
|
MergedWidget = ({ options, ...props }) => {
|
|
@@ -3096,80 +3270,28 @@
|
|
|
3096
3270
|
if (has5(regOrFc, FORM_CONTEXT_NAME)) {
|
|
3097
3271
|
lookupPath.unshift(FORM_CONTEXT_NAME);
|
|
3098
3272
|
}
|
|
3099
|
-
return
|
|
3100
|
-
}
|
|
3101
|
-
function isValueEmpty(value) {
|
|
3102
|
-
if (isNil(value) || value === "") {
|
|
3103
|
-
return true;
|
|
3104
|
-
}
|
|
3105
|
-
if (Array.isArray(value)) {
|
|
3106
|
-
return value.length === 0;
|
|
3107
|
-
}
|
|
3108
|
-
if (isObject(value)) {
|
|
3109
|
-
const obj = value;
|
|
3110
|
-
const keys2 = Object.keys(obj);
|
|
3111
|
-
return keys2.every((key) => isValueEmpty(obj[key]));
|
|
3112
|
-
}
|
|
3113
|
-
return false;
|
|
3273
|
+
return get15(regOrFc, [...lookupPath, toLookup], fallback);
|
|
3114
3274
|
}
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
if (Array.isArray(formData)) {
|
|
3121
|
-
const itemsSchema = resolvedSchema.items;
|
|
3122
|
-
if (!itemsSchema) {
|
|
3123
|
-
return formData;
|
|
3124
|
-
}
|
|
3125
|
-
let hasChanges = false;
|
|
3126
|
-
const mapped = formData.map((item, index) => {
|
|
3127
|
-
let itemSchema = itemsSchema;
|
|
3128
|
-
if (Array.isArray(itemsSchema)) {
|
|
3129
|
-
itemSchema = itemsSchema[index] || resolvedSchema.additionalItems || {};
|
|
3130
|
-
}
|
|
3131
|
-
const cleaned = removeOptionalEmptyObjects(validator, itemSchema, rootSchema, item);
|
|
3132
|
-
if (cleaned !== item) {
|
|
3133
|
-
hasChanges = true;
|
|
3134
|
-
}
|
|
3135
|
-
return cleaned === void 0 ? {} : cleaned;
|
|
3136
|
-
});
|
|
3137
|
-
return hasChanges ? mapped : formData;
|
|
3138
|
-
}
|
|
3139
|
-
const { properties, required: requiredFields = [] } = resolvedSchema;
|
|
3140
|
-
if (!isObject(formData) || !properties) {
|
|
3141
|
-
return formData;
|
|
3275
|
+
|
|
3276
|
+
// src/nameGenerators.ts
|
|
3277
|
+
var bracketNameGenerator = (path, idPrefix, isMultiValue) => {
|
|
3278
|
+
if (!path || path.length === 0) {
|
|
3279
|
+
return idPrefix;
|
|
3142
3280
|
}
|
|
3143
|
-
const
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
for (const key of Object.keys(data)) {
|
|
3147
|
-
const value = data[key];
|
|
3148
|
-
const propertySchema = properties[key] || {};
|
|
3149
|
-
const isRequired = requiredFields.includes(key);
|
|
3150
|
-
const isObj = isObject(value);
|
|
3151
|
-
const isArr = Array.isArray(value);
|
|
3152
|
-
if ((isObj || isArr) && properties[key]) {
|
|
3153
|
-
const cleaned = removeOptionalEmptyObjects(validator, propertySchema, rootSchema, value);
|
|
3154
|
-
if (!isRequired && isValueEmpty(cleaned)) {
|
|
3155
|
-
continue;
|
|
3156
|
-
}
|
|
3157
|
-
result[key] = cleaned;
|
|
3158
|
-
hasAnyValue = true;
|
|
3159
|
-
} else if (!isRequired && isValueEmpty(value) && properties[key]) {
|
|
3160
|
-
continue;
|
|
3161
|
-
} else {
|
|
3162
|
-
result[key] = value;
|
|
3163
|
-
if (!isValueEmpty(value)) {
|
|
3164
|
-
hasAnyValue = true;
|
|
3165
|
-
}
|
|
3281
|
+
const baseName = path.reduce((acc, pathUnit, index) => {
|
|
3282
|
+
if (index === 0) {
|
|
3283
|
+
return `${idPrefix}[${String(pathUnit)}]`;
|
|
3166
3284
|
}
|
|
3285
|
+
return `${acc}[${String(pathUnit)}]`;
|
|
3286
|
+
}, "");
|
|
3287
|
+
return isMultiValue ? `${baseName}[]` : baseName;
|
|
3288
|
+
};
|
|
3289
|
+
var dotNotationNameGenerator = (path, idPrefix, _isMultiValue) => {
|
|
3290
|
+
if (!path || path.length === 0) {
|
|
3291
|
+
return idPrefix;
|
|
3167
3292
|
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
}
|
|
3171
|
-
return result;
|
|
3172
|
-
}
|
|
3293
|
+
return `${idPrefix}.${path.map(String).join(".")}`;
|
|
3294
|
+
};
|
|
3173
3295
|
|
|
3174
3296
|
// src/orderProperties.ts
|
|
3175
3297
|
function orderProperties(properties, order) {
|
|
@@ -3226,6 +3348,64 @@
|
|
|
3226
3348
|
second: includeTime ? date.getUTCSeconds() : 0
|
|
3227
3349
|
};
|
|
3228
3350
|
}
|
|
3351
|
+
|
|
3352
|
+
// src/removeOptionalEmptyObjects.ts
|
|
3353
|
+
function removeOptionalEmptyObjects(validator, schema, rootSchema, formData) {
|
|
3354
|
+
if (!isObject(schema)) {
|
|
3355
|
+
return formData;
|
|
3356
|
+
}
|
|
3357
|
+
const resolvedSchema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
3358
|
+
if (Array.isArray(formData)) {
|
|
3359
|
+
const itemsSchema = resolvedSchema.items;
|
|
3360
|
+
if (!itemsSchema) {
|
|
3361
|
+
return formData;
|
|
3362
|
+
}
|
|
3363
|
+
let hasChanges = false;
|
|
3364
|
+
const mapped = formData.map((item, index) => {
|
|
3365
|
+
let itemSchema = itemsSchema;
|
|
3366
|
+
if (Array.isArray(itemsSchema)) {
|
|
3367
|
+
itemSchema = itemsSchema[index] || resolvedSchema.additionalItems || {};
|
|
3368
|
+
}
|
|
3369
|
+
const cleaned = removeOptionalEmptyObjects(validator, itemSchema, rootSchema, item);
|
|
3370
|
+
if (cleaned !== item) {
|
|
3371
|
+
hasChanges = true;
|
|
3372
|
+
}
|
|
3373
|
+
return cleaned === void 0 ? {} : cleaned;
|
|
3374
|
+
});
|
|
3375
|
+
return hasChanges ? mapped : formData;
|
|
3376
|
+
}
|
|
3377
|
+
const { properties, required: requiredFields = [] } = resolvedSchema;
|
|
3378
|
+
if (!isObject(formData) || !properties) {
|
|
3379
|
+
return formData;
|
|
3380
|
+
}
|
|
3381
|
+
const result = {};
|
|
3382
|
+
const data = formData;
|
|
3383
|
+
let hasAnyValue = false;
|
|
3384
|
+
for (const key of Object.keys(data)) {
|
|
3385
|
+
const value = data[key];
|
|
3386
|
+
const propertySchema = properties[key] || {};
|
|
3387
|
+
const isRequired = requiredFields.includes(key);
|
|
3388
|
+
const isObj = isObject(value);
|
|
3389
|
+
const isArr = Array.isArray(value);
|
|
3390
|
+
if ((isObj || isArr) && properties[key]) {
|
|
3391
|
+
const cleaned = removeOptionalEmptyObjects(validator, propertySchema, rootSchema, value);
|
|
3392
|
+
if (!isRequired && isValueEmpty(cleaned)) {
|
|
3393
|
+
continue;
|
|
3394
|
+
}
|
|
3395
|
+
result[key] = cleaned;
|
|
3396
|
+
hasAnyValue = true;
|
|
3397
|
+
} else if (isRequired || !isValueEmpty(value) || !properties[key]) {
|
|
3398
|
+
result[key] = value;
|
|
3399
|
+
if (!isValueEmpty(value)) {
|
|
3400
|
+
hasAnyValue = true;
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
if (!hasAnyValue && Object.keys(result).length === 0) {
|
|
3405
|
+
return void 0;
|
|
3406
|
+
}
|
|
3407
|
+
return result;
|
|
3408
|
+
}
|
|
3229
3409
|
function resolveUiSchema(schema, localUiSchema, registry) {
|
|
3230
3410
|
const ref = schema[RJSF_REF_KEY] ?? schema[REF_KEY];
|
|
3231
3411
|
const definitions = registry.uiSchemaDefinitions;
|
|
@@ -3294,6 +3474,31 @@
|
|
|
3294
3474
|
return false;
|
|
3295
3475
|
}
|
|
3296
3476
|
|
|
3477
|
+
// src/shallowEquals.ts
|
|
3478
|
+
function shallowEquals(a, b) {
|
|
3479
|
+
if (Object.is(a, b)) {
|
|
3480
|
+
return true;
|
|
3481
|
+
}
|
|
3482
|
+
if (a == null || b == null) {
|
|
3483
|
+
return false;
|
|
3484
|
+
}
|
|
3485
|
+
if (typeof a !== "object" || typeof b !== "object") {
|
|
3486
|
+
return false;
|
|
3487
|
+
}
|
|
3488
|
+
const keysA = Object.keys(a);
|
|
3489
|
+
const keysB = Object.keys(b);
|
|
3490
|
+
if (keysA.length !== keysB.length) {
|
|
3491
|
+
return false;
|
|
3492
|
+
}
|
|
3493
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
3494
|
+
const key = keysA[i];
|
|
3495
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {
|
|
3496
|
+
return false;
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
return true;
|
|
3500
|
+
}
|
|
3501
|
+
|
|
3297
3502
|
// src/shouldRender.ts
|
|
3298
3503
|
function shouldRender(component, nextProps, nextState, updateStrategy = "customDeep") {
|
|
3299
3504
|
if (updateStrategy === "always") {
|
|
@@ -3571,15 +3776,14 @@
|
|
|
3571
3776
|
[value]
|
|
3572
3777
|
);
|
|
3573
3778
|
const handleChange = react.useCallback(
|
|
3574
|
-
(files) => {
|
|
3575
|
-
processFiles(files)
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
});
|
|
3779
|
+
async (files) => {
|
|
3780
|
+
const filesInfoEvent = await processFiles(files);
|
|
3781
|
+
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL || null);
|
|
3782
|
+
if (multiple) {
|
|
3783
|
+
onChange(values.concat(...newValue));
|
|
3784
|
+
} else {
|
|
3785
|
+
onChange(newValue[0]);
|
|
3786
|
+
}
|
|
3583
3787
|
},
|
|
3584
3788
|
[values, multiple, onChange]
|
|
3585
3789
|
);
|
|
@@ -3657,26 +3861,6 @@
|
|
|
3657
3861
|
return schemaNode;
|
|
3658
3862
|
}
|
|
3659
3863
|
|
|
3660
|
-
// src/nameGenerators.ts
|
|
3661
|
-
var bracketNameGenerator = (path, idPrefix, isMultiValue) => {
|
|
3662
|
-
if (!path || path.length === 0) {
|
|
3663
|
-
return idPrefix;
|
|
3664
|
-
}
|
|
3665
|
-
const baseName = path.reduce((acc, pathUnit, index) => {
|
|
3666
|
-
if (index === 0) {
|
|
3667
|
-
return `${idPrefix}[${String(pathUnit)}]`;
|
|
3668
|
-
}
|
|
3669
|
-
return `${acc}[${String(pathUnit)}]`;
|
|
3670
|
-
}, "");
|
|
3671
|
-
return isMultiValue ? `${baseName}[]` : baseName;
|
|
3672
|
-
};
|
|
3673
|
-
var dotNotationNameGenerator = (path, idPrefix, _isMultiValue) => {
|
|
3674
|
-
if (!path || path.length === 0) {
|
|
3675
|
-
return idPrefix;
|
|
3676
|
-
}
|
|
3677
|
-
return `${idPrefix}.${path.map(String).join(".")}`;
|
|
3678
|
-
};
|
|
3679
|
-
|
|
3680
3864
|
// src/enums.ts
|
|
3681
3865
|
var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
3682
3866
|
TranslatableString2["ArrayItemTitle"] = "Item";
|
|
@@ -3709,6 +3893,7 @@
|
|
|
3709
3893
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
3710
3894
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
3711
3895
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
3896
|
+
TranslatableString2["DeprecatedLabel"] = "%1 (deprecated)";
|
|
3712
3897
|
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
3713
3898
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
3714
3899
|
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
@@ -3742,7 +3927,7 @@
|
|
|
3742
3927
|
* @param hash - The hash value at which to map the schema
|
|
3743
3928
|
*/
|
|
3744
3929
|
addSchema(schema, hash) {
|
|
3745
|
-
const key =
|
|
3930
|
+
const key = get15(schema, ID_KEY, hash);
|
|
3746
3931
|
const identifiedSchema = { ...schema, [ID_KEY]: key };
|
|
3747
3932
|
const existing = this.schemaMap[key];
|
|
3748
3933
|
if (!existing) {
|
|
@@ -3935,6 +4120,7 @@
|
|
|
3935
4120
|
exports.isObject = isObject;
|
|
3936
4121
|
exports.isRootSchema = isRootSchema;
|
|
3937
4122
|
exports.isSelect = isSelect;
|
|
4123
|
+
exports.isValueEmpty = isValueEmpty;
|
|
3938
4124
|
exports.labelValue = labelValue;
|
|
3939
4125
|
exports.localToUTC = localToUTC;
|
|
3940
4126
|
exports.lookupFromFormContext = lookupFromFormContext;
|
|
@@ -3949,6 +4135,7 @@
|
|
|
3949
4135
|
exports.pad = pad;
|
|
3950
4136
|
exports.parseDateString = parseDateString;
|
|
3951
4137
|
exports.rangeSpec = rangeSpec;
|
|
4138
|
+
exports.relaxOptionsForScoring = relaxOptionsForScoring;
|
|
3952
4139
|
exports.removeOptionalEmptyObjects = removeOptionalEmptyObjects;
|
|
3953
4140
|
exports.replaceStringParameters = replaceStringParameters;
|
|
3954
4141
|
exports.resolveUiSchema = resolveUiSchema;
|