@rjsf/utils 6.0.0-beta.7 → 6.0.0-beta.8
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 +85 -81
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +85 -81
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +66 -63
- package/lib/canExpand.d.ts +1 -1
- package/lib/findSchemaDefinition.d.ts +1 -1
- package/lib/findSchemaDefinition.js +4 -3
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/schema/getDefaultFormState.js +7 -1
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +1 -1
- package/lib/schema/retrieveSchema.js +3 -3
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +3 -2
- package/package.json +1 -1
- package/src/findSchemaDefinition.ts +4 -3
- package/src/schema/getDefaultFormState.ts +8 -2
- package/src/schema/retrieveSchema.ts +3 -3
- package/src/types.ts +3 -2
package/dist/utils.esm.js
CHANGED
|
@@ -148,15 +148,15 @@ function deepEquals(a, b) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// src/schema/findFieldInSchema.ts
|
|
151
|
-
import
|
|
151
|
+
import get8 from "lodash/get";
|
|
152
152
|
import has3 from "lodash/has";
|
|
153
153
|
|
|
154
154
|
// src/schema/findSelectedOptionInXxxOf.ts
|
|
155
|
-
import
|
|
155
|
+
import get6 from "lodash/get";
|
|
156
156
|
import isEqual from "lodash/isEqual";
|
|
157
157
|
|
|
158
158
|
// src/schema/retrieveSchema.ts
|
|
159
|
-
import
|
|
159
|
+
import get5 from "lodash/get";
|
|
160
160
|
import set from "lodash/set";
|
|
161
161
|
import times from "lodash/times";
|
|
162
162
|
import transform from "lodash/transform";
|
|
@@ -171,6 +171,7 @@ import omit from "lodash/omit";
|
|
|
171
171
|
import isObject2 from "lodash/isObject";
|
|
172
172
|
import isEmpty from "lodash/isEmpty";
|
|
173
173
|
import UriResolver from "fast-uri";
|
|
174
|
+
import get from "lodash/get";
|
|
174
175
|
function findEmbeddedSchemaRecursive(schema, ref) {
|
|
175
176
|
if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY], ref)) {
|
|
176
177
|
return schema;
|
|
@@ -190,7 +191,7 @@ function splitKeyElementFromObject(key, object) {
|
|
|
190
191
|
const remaining = omit(object, [key]);
|
|
191
192
|
return [remaining, value];
|
|
192
193
|
}
|
|
193
|
-
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI =
|
|
194
|
+
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = get(rootSchema, [ID_KEY])) {
|
|
194
195
|
const ref = $ref || "";
|
|
195
196
|
let current = void 0;
|
|
196
197
|
if (ref.startsWith("#")) {
|
|
@@ -236,17 +237,17 @@ function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [],
|
|
|
236
237
|
}
|
|
237
238
|
return current;
|
|
238
239
|
}
|
|
239
|
-
function findSchemaDefinition($ref, rootSchema = {}, baseURI =
|
|
240
|
+
function findSchemaDefinition($ref, rootSchema = {}, baseURI = get(rootSchema, [ID_KEY])) {
|
|
240
241
|
const recurseList = [];
|
|
241
242
|
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
// src/getDiscriminatorFieldFromSchema.ts
|
|
245
|
-
import
|
|
246
|
+
import get2 from "lodash/get";
|
|
246
247
|
import isString from "lodash/isString";
|
|
247
248
|
function getDiscriminatorFieldFromSchema(schema) {
|
|
248
249
|
let discriminator;
|
|
249
|
-
const maybeString =
|
|
250
|
+
const maybeString = get2(schema, DISCRIMINATOR_PATH);
|
|
250
251
|
if (isString(maybeString)) {
|
|
251
252
|
discriminator = maybeString;
|
|
252
253
|
} else if (maybeString !== void 0) {
|
|
@@ -320,21 +321,21 @@ function mergeSchemas(obj1, obj2) {
|
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
// src/schema/getFirstMatchingOption.ts
|
|
323
|
-
import
|
|
324
|
+
import get4 from "lodash/get";
|
|
324
325
|
import has from "lodash/has";
|
|
325
326
|
import isNumber from "lodash/isNumber";
|
|
326
327
|
|
|
327
328
|
// src/getOptionMatchingSimpleDiscriminator.ts
|
|
328
|
-
import
|
|
329
|
+
import get3 from "lodash/get";
|
|
329
330
|
function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
|
|
330
331
|
if (formData && discriminatorField) {
|
|
331
|
-
const value =
|
|
332
|
+
const value = get3(formData, discriminatorField);
|
|
332
333
|
if (value === void 0) {
|
|
333
334
|
return;
|
|
334
335
|
}
|
|
335
336
|
for (let i = 0; i < options.length; i++) {
|
|
336
337
|
const option = options[i];
|
|
337
|
-
const discriminator =
|
|
338
|
+
const discriminator = get3(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
338
339
|
if (discriminator.type === "object" || discriminator.type === "array") {
|
|
339
340
|
continue;
|
|
340
341
|
}
|
|
@@ -361,8 +362,8 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
|
|
|
361
362
|
for (let i = 0; i < options.length; i++) {
|
|
362
363
|
const option = options[i];
|
|
363
364
|
if (discriminatorField && has(option, [PROPERTIES_KEY, discriminatorField])) {
|
|
364
|
-
const value =
|
|
365
|
-
const discriminator =
|
|
365
|
+
const value = get4(formData, discriminatorField);
|
|
366
|
+
const discriminator = get4(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
366
367
|
if (validator.isValid(discriminator, value, rootSchema)) {
|
|
367
368
|
return i;
|
|
368
369
|
}
|
|
@@ -619,7 +620,7 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
619
620
|
validator,
|
|
620
621
|
{ allOf: Object.values(matchingProperties) },
|
|
621
622
|
rootSchema,
|
|
622
|
-
formData,
|
|
623
|
+
get5(formData, [key]),
|
|
623
624
|
experimental_customMergeAllOf
|
|
624
625
|
);
|
|
625
626
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -632,7 +633,7 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
632
633
|
if (REF_KEY in schema.additionalProperties) {
|
|
633
634
|
additionalProperties = retrieveSchema(
|
|
634
635
|
validator,
|
|
635
|
-
{ $ref:
|
|
636
|
+
{ $ref: get5(schema.additionalProperties, [REF_KEY]) },
|
|
636
637
|
rootSchema,
|
|
637
638
|
formData,
|
|
638
639
|
experimental_customMergeAllOf
|
|
@@ -645,10 +646,10 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
645
646
|
...schema.additionalProperties
|
|
646
647
|
};
|
|
647
648
|
} else {
|
|
648
|
-
additionalProperties = { type: guessType(
|
|
649
|
+
additionalProperties = { type: guessType(get5(formData, [key])) };
|
|
649
650
|
}
|
|
650
651
|
} else {
|
|
651
|
-
additionalProperties = { type: guessType(
|
|
652
|
+
additionalProperties = { type: guessType(get5(formData, [key])) };
|
|
652
653
|
}
|
|
653
654
|
schema.properties[key] = additionalProperties;
|
|
654
655
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -727,7 +728,7 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
|
|
|
727
728
|
validator,
|
|
728
729
|
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
729
730
|
rootSchema,
|
|
730
|
-
rawFormData,
|
|
731
|
+
get5(rawFormData, [key]),
|
|
731
732
|
experimental_customMergeAllOf
|
|
732
733
|
);
|
|
733
734
|
}
|
|
@@ -799,7 +800,7 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, r
|
|
|
799
800
|
function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
800
801
|
let schemas = [resolvedSchema];
|
|
801
802
|
for (const dependencyKey in dependencies) {
|
|
802
|
-
if (!expandAllBranches &&
|
|
803
|
+
if (!expandAllBranches && get5(formData, [dependencyKey]) === void 0) {
|
|
803
804
|
continue;
|
|
804
805
|
}
|
|
805
806
|
if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
|
|
@@ -930,11 +931,11 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
|
|
|
930
931
|
const xxxOfs = schema[xxx].map(
|
|
931
932
|
(xxxOf) => retrieveSchema(validator, xxxOf, rootSchema, formData, experimental_customMergeAllOf)
|
|
932
933
|
);
|
|
933
|
-
const data =
|
|
934
|
+
const data = get6(formData, selectorField);
|
|
934
935
|
if (data !== void 0) {
|
|
935
936
|
return xxxOfs.find((xxx2) => {
|
|
936
937
|
return isEqual(
|
|
937
|
-
|
|
938
|
+
get6(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get6(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
938
939
|
data
|
|
939
940
|
);
|
|
940
941
|
});
|
|
@@ -944,7 +945,7 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
|
|
|
944
945
|
}
|
|
945
946
|
|
|
946
947
|
// src/schema/getFromSchema.ts
|
|
947
|
-
import
|
|
948
|
+
import get7 from "lodash/get";
|
|
948
949
|
import has2 from "lodash/has";
|
|
949
950
|
import isEmpty3 from "lodash/isEmpty";
|
|
950
951
|
function getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf) {
|
|
@@ -958,7 +959,7 @@ function getFromSchemaInternal(validator, rootSchema, schema, path, experimental
|
|
|
958
959
|
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
959
960
|
const [part, ...nestedPath] = pathList;
|
|
960
961
|
if (part && has2(fieldSchema, part)) {
|
|
961
|
-
fieldSchema =
|
|
962
|
+
fieldSchema = get7(fieldSchema, part);
|
|
962
963
|
return getFromSchemaInternal(
|
|
963
964
|
validator,
|
|
964
965
|
rootSchema,
|
|
@@ -1000,7 +1001,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1000
1001
|
parentField,
|
|
1001
1002
|
fieldName,
|
|
1002
1003
|
ONE_OF_KEY,
|
|
1003
|
-
|
|
1004
|
+
get8(formData, subPath),
|
|
1004
1005
|
experimental_customMergeAllOf
|
|
1005
1006
|
);
|
|
1006
1007
|
} else if (has3(parentField, ANY_OF_KEY)) {
|
|
@@ -1010,7 +1011,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1010
1011
|
parentField,
|
|
1011
1012
|
fieldName,
|
|
1012
1013
|
ANY_OF_KEY,
|
|
1013
|
-
|
|
1014
|
+
get8(formData, subPath),
|
|
1014
1015
|
experimental_customMergeAllOf
|
|
1015
1016
|
);
|
|
1016
1017
|
}
|
|
@@ -1064,11 +1065,11 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1064
1065
|
}
|
|
1065
1066
|
|
|
1066
1067
|
// src/schema/getDefaultFormState.ts
|
|
1067
|
-
import
|
|
1068
|
+
import get12 from "lodash/get";
|
|
1068
1069
|
import isEmpty4 from "lodash/isEmpty";
|
|
1069
1070
|
|
|
1070
1071
|
// src/schema/getClosestMatchingOption.ts
|
|
1071
|
-
import
|
|
1072
|
+
import get9 from "lodash/get";
|
|
1072
1073
|
import has4 from "lodash/has";
|
|
1073
1074
|
import isNumber2 from "lodash/isNumber";
|
|
1074
1075
|
import isObject3 from "lodash/isObject";
|
|
@@ -1091,7 +1092,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData, experiment
|
|
|
1091
1092
|
totalScore += reduce(
|
|
1092
1093
|
schema.properties,
|
|
1093
1094
|
(score, value, key) => {
|
|
1094
|
-
const formValue =
|
|
1095
|
+
const formValue = get9(formData, key);
|
|
1095
1096
|
if (typeof value === "boolean") {
|
|
1096
1097
|
return score;
|
|
1097
1098
|
}
|
|
@@ -1118,7 +1119,7 @@ function calculateIndexScore(validator, rootSchema, schema, formData, experiment
|
|
|
1118
1119
|
validator,
|
|
1119
1120
|
rootSchema,
|
|
1120
1121
|
formValue,
|
|
1121
|
-
|
|
1122
|
+
get9(value, key2),
|
|
1122
1123
|
-1,
|
|
1123
1124
|
discriminator,
|
|
1124
1125
|
experimental_customMergeAllOf
|
|
@@ -1197,7 +1198,7 @@ function isFixedItems(schema) {
|
|
|
1197
1198
|
}
|
|
1198
1199
|
|
|
1199
1200
|
// src/mergeDefaultsWithFormData.ts
|
|
1200
|
-
import
|
|
1201
|
+
import get10 from "lodash/get";
|
|
1201
1202
|
import isNil from "lodash/isNil";
|
|
1202
1203
|
function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false, defaultSupercedesUndefined = false, overrideFormDataWithDefaults = false) {
|
|
1203
1204
|
if (Array.isArray(formData)) {
|
|
@@ -1224,11 +1225,11 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
|
|
|
1224
1225
|
if (isObject(formData)) {
|
|
1225
1226
|
const acc = Object.assign({}, defaults);
|
|
1226
1227
|
return Object.keys(formData).reduce((acc2, key) => {
|
|
1227
|
-
const keyValue =
|
|
1228
|
+
const keyValue = get10(formData, key);
|
|
1228
1229
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1229
1230
|
const keyExistsInFormData = key in formData;
|
|
1230
1231
|
acc2[key] = mergeDefaultsWithFormData(
|
|
1231
|
-
defaults ?
|
|
1232
|
+
defaults ? get10(defaults, key) : {},
|
|
1232
1233
|
keyValue,
|
|
1233
1234
|
mergeExtraArrayDefaults,
|
|
1234
1235
|
defaultSupercedesUndefined,
|
|
@@ -1307,7 +1308,7 @@ function constIsAjvDataReference(schema) {
|
|
|
1307
1308
|
}
|
|
1308
1309
|
|
|
1309
1310
|
// src/optionsList.ts
|
|
1310
|
-
import
|
|
1311
|
+
import get11 from "lodash/get";
|
|
1311
1312
|
|
|
1312
1313
|
// src/toConstant.ts
|
|
1313
1314
|
function toConstant(schema) {
|
|
@@ -1353,8 +1354,8 @@ function optionsList(schema, uiSchema) {
|
|
|
1353
1354
|
let value;
|
|
1354
1355
|
let label = title;
|
|
1355
1356
|
if (selectorField) {
|
|
1356
|
-
const innerSchema =
|
|
1357
|
-
value =
|
|
1357
|
+
const innerSchema = get11(aSchema, [PROPERTIES_KEY, selectorField], {});
|
|
1358
|
+
value = get11(innerSchema, DEFAULT_KEY, get11(innerSchema, CONST_KEY));
|
|
1358
1359
|
label = label || innerSchema?.title || aSchema.title || String(value);
|
|
1359
1360
|
} else {
|
|
1360
1361
|
value = toConstant(aSchema);
|
|
@@ -1423,7 +1424,7 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
|
1423
1424
|
required,
|
|
1424
1425
|
shouldMergeDefaultsIntoFormData = false
|
|
1425
1426
|
} = computeDefaultsProps;
|
|
1426
|
-
|
|
1427
|
+
let formData = isObject(rawFormData) ? rawFormData : {};
|
|
1427
1428
|
const schema = isObject(rawSchema) ? rawSchema : {};
|
|
1428
1429
|
let defaults = parentDefaults;
|
|
1429
1430
|
let schemaToCompute = null;
|
|
@@ -1444,6 +1445,9 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
|
1444
1445
|
if (schemaToCompute && !defaults) {
|
|
1445
1446
|
defaults = schema.default;
|
|
1446
1447
|
}
|
|
1448
|
+
if (shouldMergeDefaultsIntoFormData && schemaToCompute && !isObject(rawFormData)) {
|
|
1449
|
+
formData = rawFormData;
|
|
1450
|
+
}
|
|
1447
1451
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
1448
1452
|
const defaultFormData = {
|
|
1449
1453
|
...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults),
|
|
@@ -1584,7 +1588,7 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1584
1588
|
const parentConst = retrievedSchema[CONST_KEY];
|
|
1585
1589
|
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1586
1590
|
(acc, key) => {
|
|
1587
|
-
const propertySchema =
|
|
1591
|
+
const propertySchema = get12(retrievedSchema, [PROPERTIES_KEY, key], {});
|
|
1588
1592
|
const hasParentConst = isObject(parentConst) && parentConst[key] !== void 0;
|
|
1589
1593
|
const hasConst = (isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst) && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(propertySchema);
|
|
1590
1594
|
const computedDefault = computeDefaults(validator, propertySchema, {
|
|
@@ -1593,8 +1597,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1593
1597
|
experimental_defaultFormStateBehavior,
|
|
1594
1598
|
experimental_customMergeAllOf,
|
|
1595
1599
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1596
|
-
parentDefaults:
|
|
1597
|
-
rawFormData:
|
|
1600
|
+
parentDefaults: get12(defaults, [key]),
|
|
1601
|
+
rawFormData: get12(formData, [key]),
|
|
1598
1602
|
required: retrievedSchema.required?.includes(key),
|
|
1599
1603
|
shouldMergeDefaultsIntoFormData
|
|
1600
1604
|
});
|
|
@@ -1630,8 +1634,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1630
1634
|
experimental_defaultFormStateBehavior,
|
|
1631
1635
|
experimental_customMergeAllOf,
|
|
1632
1636
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1633
|
-
parentDefaults:
|
|
1634
|
-
rawFormData:
|
|
1637
|
+
parentDefaults: get12(defaults, [key]),
|
|
1638
|
+
rawFormData: get12(formData, [key]),
|
|
1635
1639
|
required: retrievedSchema.required?.includes(key),
|
|
1636
1640
|
shouldMergeDefaultsIntoFormData
|
|
1637
1641
|
});
|
|
@@ -1692,7 +1696,7 @@ function getArrayDefaults(validator, rawSchema, {
|
|
|
1692
1696
|
experimental_defaultFormStateBehavior,
|
|
1693
1697
|
experimental_customMergeAllOf,
|
|
1694
1698
|
rawFormData: item,
|
|
1695
|
-
parentDefaults:
|
|
1699
|
+
parentDefaults: get12(defaults, [idx]),
|
|
1696
1700
|
required,
|
|
1697
1701
|
shouldMergeDefaultsIntoFormData
|
|
1698
1702
|
});
|
|
@@ -1820,7 +1824,7 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
|
|
|
1820
1824
|
}
|
|
1821
1825
|
|
|
1822
1826
|
// src/schema/sanitizeDataForNewSchema.ts
|
|
1823
|
-
import
|
|
1827
|
+
import get13 from "lodash/get";
|
|
1824
1828
|
import has5 from "lodash/has";
|
|
1825
1829
|
var NO_VALUE = Symbol("no Value");
|
|
1826
1830
|
function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
|
|
@@ -1828,19 +1832,19 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1828
1832
|
if (has5(newSchema, PROPERTIES_KEY)) {
|
|
1829
1833
|
const removeOldSchemaData = {};
|
|
1830
1834
|
if (has5(oldSchema, PROPERTIES_KEY)) {
|
|
1831
|
-
const properties =
|
|
1835
|
+
const properties = get13(oldSchema, PROPERTIES_KEY, {});
|
|
1832
1836
|
Object.keys(properties).forEach((key) => {
|
|
1833
1837
|
if (has5(data, key)) {
|
|
1834
1838
|
removeOldSchemaData[key] = void 0;
|
|
1835
1839
|
}
|
|
1836
1840
|
});
|
|
1837
1841
|
}
|
|
1838
|
-
const keys2 = Object.keys(
|
|
1842
|
+
const keys2 = Object.keys(get13(newSchema, PROPERTIES_KEY, {}));
|
|
1839
1843
|
const nestedData = {};
|
|
1840
1844
|
keys2.forEach((key) => {
|
|
1841
|
-
const formValue =
|
|
1842
|
-
let oldKeyedSchema =
|
|
1843
|
-
let newKeyedSchema =
|
|
1845
|
+
const formValue = get13(data, key);
|
|
1846
|
+
let oldKeyedSchema = get13(oldSchema, [PROPERTIES_KEY, key], {});
|
|
1847
|
+
let newKeyedSchema = get13(newSchema, [PROPERTIES_KEY, key], {});
|
|
1844
1848
|
if (has5(oldKeyedSchema, REF_KEY)) {
|
|
1845
1849
|
oldKeyedSchema = retrieveSchema(
|
|
1846
1850
|
validator,
|
|
@@ -1859,8 +1863,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1859
1863
|
experimental_customMergeAllOf
|
|
1860
1864
|
);
|
|
1861
1865
|
}
|
|
1862
|
-
const oldSchemaTypeForKey =
|
|
1863
|
-
const newSchemaTypeForKey =
|
|
1866
|
+
const oldSchemaTypeForKey = get13(oldKeyedSchema, "type");
|
|
1867
|
+
const newSchemaTypeForKey = get13(newKeyedSchema, "type");
|
|
1864
1868
|
if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
|
|
1865
1869
|
if (has5(removeOldSchemaData, key)) {
|
|
1866
1870
|
delete removeOldSchemaData[key];
|
|
@@ -1878,17 +1882,17 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1878
1882
|
nestedData[key] = itemData;
|
|
1879
1883
|
}
|
|
1880
1884
|
} else {
|
|
1881
|
-
const newOptionDefault =
|
|
1882
|
-
const oldOptionDefault =
|
|
1885
|
+
const newOptionDefault = get13(newKeyedSchema, "default", NO_VALUE);
|
|
1886
|
+
const oldOptionDefault = get13(oldKeyedSchema, "default", NO_VALUE);
|
|
1883
1887
|
if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
|
|
1884
1888
|
if (oldOptionDefault === formValue) {
|
|
1885
1889
|
removeOldSchemaData[key] = newOptionDefault;
|
|
1886
|
-
} else if (
|
|
1890
|
+
} else if (get13(newKeyedSchema, "readOnly") === true) {
|
|
1887
1891
|
removeOldSchemaData[key] = void 0;
|
|
1888
1892
|
}
|
|
1889
1893
|
}
|
|
1890
|
-
const newOptionConst =
|
|
1891
|
-
const oldOptionConst =
|
|
1894
|
+
const newOptionConst = get13(newKeyedSchema, "const", NO_VALUE);
|
|
1895
|
+
const oldOptionConst = get13(oldKeyedSchema, "const", NO_VALUE);
|
|
1892
1896
|
if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
|
|
1893
1897
|
removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
|
|
1894
1898
|
}
|
|
@@ -1900,9 +1904,9 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1900
1904
|
...removeOldSchemaData,
|
|
1901
1905
|
...nestedData
|
|
1902
1906
|
};
|
|
1903
|
-
} else if (
|
|
1904
|
-
let oldSchemaItems =
|
|
1905
|
-
let newSchemaItems =
|
|
1907
|
+
} else if (get13(oldSchema, "type") === "array" && get13(newSchema, "type") === "array" && Array.isArray(data)) {
|
|
1908
|
+
let oldSchemaItems = get13(oldSchema, "items");
|
|
1909
|
+
let newSchemaItems = get13(newSchema, "items");
|
|
1906
1910
|
if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
|
|
1907
1911
|
if (has5(oldSchemaItems, REF_KEY)) {
|
|
1908
1912
|
oldSchemaItems = retrieveSchema(
|
|
@@ -1922,10 +1926,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1922
1926
|
experimental_customMergeAllOf
|
|
1923
1927
|
);
|
|
1924
1928
|
}
|
|
1925
|
-
const oldSchemaType =
|
|
1926
|
-
const newSchemaType =
|
|
1929
|
+
const oldSchemaType = get13(oldSchemaItems, "type");
|
|
1930
|
+
const newSchemaType = get13(newSchemaItems, "type");
|
|
1927
1931
|
if (!oldSchemaType || oldSchemaType === newSchemaType) {
|
|
1928
|
-
const maxItems =
|
|
1932
|
+
const maxItems = get13(newSchema, "maxItems", -1);
|
|
1929
1933
|
if (newSchemaType === "object") {
|
|
1930
1934
|
newFormData = data.reduce((newValue, aValue) => {
|
|
1931
1935
|
const itemValue = sanitizeDataForNewSchema(
|
|
@@ -1953,7 +1957,7 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1953
1957
|
}
|
|
1954
1958
|
|
|
1955
1959
|
// src/schema/toIdSchema.ts
|
|
1956
|
-
import
|
|
1960
|
+
import get14 from "lodash/get";
|
|
1957
1961
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1958
1962
|
const $id = id || idPrefix;
|
|
1959
1963
|
const idSchema = { $id };
|
|
@@ -1975,10 +1979,10 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
|
|
|
1975
1979
|
);
|
|
1976
1980
|
}
|
|
1977
1981
|
}
|
|
1978
|
-
if (ITEMS_KEY in schema && !
|
|
1982
|
+
if (ITEMS_KEY in schema && !get14(schema, [ITEMS_KEY, REF_KEY])) {
|
|
1979
1983
|
return toIdSchemaInternal(
|
|
1980
1984
|
validator,
|
|
1981
|
-
|
|
1985
|
+
get14(schema, ITEMS_KEY),
|
|
1982
1986
|
idPrefix,
|
|
1983
1987
|
idSeparator,
|
|
1984
1988
|
id,
|
|
@@ -2001,7 +2005,7 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
|
|
|
2001
2005
|
rootSchema,
|
|
2002
2006
|
// It's possible that formData is not an object -- this can happen if an
|
|
2003
2007
|
// array item has just been added, but not populated with data yet
|
|
2004
|
-
|
|
2008
|
+
get14(formData, [name]),
|
|
2005
2009
|
_recurseList,
|
|
2006
2010
|
experimental_customMergeAllOf
|
|
2007
2011
|
);
|
|
@@ -2025,7 +2029,7 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
|
|
|
2025
2029
|
}
|
|
2026
2030
|
|
|
2027
2031
|
// src/schema/toPathSchema.ts
|
|
2028
|
-
import
|
|
2032
|
+
import get15 from "lodash/get";
|
|
2029
2033
|
import set2 from "lodash/set";
|
|
2030
2034
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
2031
2035
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
@@ -2118,7 +2122,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
|
|
|
2118
2122
|
}
|
|
2119
2123
|
} else if (PROPERTIES_KEY in schema) {
|
|
2120
2124
|
for (const property in schema.properties) {
|
|
2121
|
-
const field =
|
|
2125
|
+
const field = get15(schema, [PROPERTIES_KEY, property], {});
|
|
2122
2126
|
pathSchema[property] = toPathSchemaInternal(
|
|
2123
2127
|
validator,
|
|
2124
2128
|
field,
|
|
@@ -2126,7 +2130,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
|
|
|
2126
2130
|
rootSchema,
|
|
2127
2131
|
// It's possible that formData is not an object -- this can happen if an
|
|
2128
2132
|
// array item has just been added, but not populated with data yet
|
|
2129
|
-
|
|
2133
|
+
get15(formData, [property]),
|
|
2130
2134
|
_recurseList,
|
|
2131
2135
|
experimental_customMergeAllOf
|
|
2132
2136
|
);
|
|
@@ -2544,7 +2548,7 @@ function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
|
2544
2548
|
|
|
2545
2549
|
// src/ErrorSchemaBuilder.ts
|
|
2546
2550
|
import cloneDeep from "lodash/cloneDeep";
|
|
2547
|
-
import
|
|
2551
|
+
import get16 from "lodash/get";
|
|
2548
2552
|
import set3 from "lodash/set";
|
|
2549
2553
|
import setWith from "lodash/setWith";
|
|
2550
2554
|
var ErrorSchemaBuilder = class {
|
|
@@ -2573,7 +2577,7 @@ var ErrorSchemaBuilder = class {
|
|
|
2573
2577
|
*/
|
|
2574
2578
|
getOrCreateErrorBlock(pathOfError) {
|
|
2575
2579
|
const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
|
|
2576
|
-
let errorBlock = hasPath ?
|
|
2580
|
+
let errorBlock = hasPath ? get16(this.errorSchema, pathOfError) : this.errorSchema;
|
|
2577
2581
|
if (!errorBlock && pathOfError) {
|
|
2578
2582
|
errorBlock = {};
|
|
2579
2583
|
setWith(this.errorSchema, pathOfError, errorBlock, Object);
|
|
@@ -2599,7 +2603,7 @@ var ErrorSchemaBuilder = class {
|
|
|
2599
2603
|
*/
|
|
2600
2604
|
addErrors(errorOrList, pathOfError) {
|
|
2601
2605
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
2602
|
-
let errorsList =
|
|
2606
|
+
let errorsList = get16(errorBlock, ERRORS_KEY);
|
|
2603
2607
|
if (!Array.isArray(errorsList)) {
|
|
2604
2608
|
errorsList = [];
|
|
2605
2609
|
errorBlock[ERRORS_KEY] = errorsList;
|
|
@@ -2748,9 +2752,9 @@ function getTemplate(name, registry, uiOptions = {}) {
|
|
|
2748
2752
|
|
|
2749
2753
|
// src/getTestIds.ts
|
|
2750
2754
|
import { nanoid } from "nanoid";
|
|
2751
|
-
import
|
|
2755
|
+
import get17 from "lodash/get";
|
|
2752
2756
|
function getTestIds() {
|
|
2753
|
-
if (typeof process === "undefined" ||
|
|
2757
|
+
if (typeof process === "undefined" || get17(process, "env.NODE_ENV") !== "test") {
|
|
2754
2758
|
return {};
|
|
2755
2759
|
}
|
|
2756
2760
|
const ids = /* @__PURE__ */ new Map();
|
|
@@ -2770,7 +2774,7 @@ function getTestIds() {
|
|
|
2770
2774
|
// src/getWidget.tsx
|
|
2771
2775
|
import { createElement } from "react";
|
|
2772
2776
|
import ReactIs from "react-is";
|
|
2773
|
-
import
|
|
2777
|
+
import get18 from "lodash/get";
|
|
2774
2778
|
import set4 from "lodash/set";
|
|
2775
2779
|
import { jsx } from "react/jsx-runtime";
|
|
2776
2780
|
var widgetMap = {
|
|
@@ -2826,7 +2830,7 @@ var widgetMap = {
|
|
|
2826
2830
|
}
|
|
2827
2831
|
};
|
|
2828
2832
|
function mergeWidgetOptions(AWidget) {
|
|
2829
|
-
let MergedWidget =
|
|
2833
|
+
let MergedWidget = get18(AWidget, "MergedWidget");
|
|
2830
2834
|
if (!MergedWidget) {
|
|
2831
2835
|
const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
|
|
2832
2836
|
MergedWidget = ({ options, ...props }) => {
|
|
@@ -2939,14 +2943,14 @@ function localToUTC(dateString) {
|
|
|
2939
2943
|
}
|
|
2940
2944
|
|
|
2941
2945
|
// src/lookupFromFormContext.ts
|
|
2942
|
-
import
|
|
2946
|
+
import get19 from "lodash/get";
|
|
2943
2947
|
import has6 from "lodash/has";
|
|
2944
2948
|
function lookupFromFormContext(regOrFc, toLookup, fallback) {
|
|
2945
2949
|
const lookupPath = [LOOKUP_MAP_NAME];
|
|
2946
2950
|
if (has6(regOrFc, FORM_CONTEXT_NAME)) {
|
|
2947
2951
|
lookupPath.unshift(FORM_CONTEXT_NAME);
|
|
2948
2952
|
}
|
|
2949
|
-
return
|
|
2953
|
+
return get19(regOrFc, [...lookupPath, toLookup], fallback);
|
|
2950
2954
|
}
|
|
2951
2955
|
|
|
2952
2956
|
// src/orderProperties.ts
|
|
@@ -3174,7 +3178,7 @@ function withIdRefPrefix(schemaNode) {
|
|
|
3174
3178
|
import keys from "lodash/keys";
|
|
3175
3179
|
import pickBy from "lodash/pickBy";
|
|
3176
3180
|
import isPlainObject4 from "lodash/isPlainObject";
|
|
3177
|
-
import
|
|
3181
|
+
import get20 from "lodash/get";
|
|
3178
3182
|
import difference from "lodash/difference";
|
|
3179
3183
|
function getChangedFields(a, b) {
|
|
3180
3184
|
const aIsPlainObject = isPlainObject4(a);
|
|
@@ -3187,7 +3191,7 @@ function getChangedFields(a, b) {
|
|
|
3187
3191
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
3188
3192
|
return keys(b);
|
|
3189
3193
|
} else {
|
|
3190
|
-
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value,
|
|
3194
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get20(b, key))));
|
|
3191
3195
|
const diffFields = difference(keys(b), keys(a));
|
|
3192
3196
|
return [...unequalFields, ...diffFields];
|
|
3193
3197
|
}
|
|
@@ -3232,7 +3236,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
3232
3236
|
import forEach from "lodash/forEach";
|
|
3233
3237
|
|
|
3234
3238
|
// src/parser/ParserValidator.ts
|
|
3235
|
-
import
|
|
3239
|
+
import get21 from "lodash/get";
|
|
3236
3240
|
var ParserValidator = class {
|
|
3237
3241
|
/** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
|
|
3238
3242
|
* first.
|
|
@@ -3258,7 +3262,7 @@ var ParserValidator = class {
|
|
|
3258
3262
|
* @param hash - The hash value at which to map the schema
|
|
3259
3263
|
*/
|
|
3260
3264
|
addSchema(schema, hash) {
|
|
3261
|
-
const key =
|
|
3265
|
+
const key = get21(schema, ID_KEY, hash);
|
|
3262
3266
|
const identifiedSchema = { ...schema, [ID_KEY]: key };
|
|
3263
3267
|
const existing = this.schemaMap[key];
|
|
3264
3268
|
if (!existing) {
|