@rjsf/utils 5.20.1 → 5.21.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.js +186 -149
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +186 -149
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +191 -143
- package/lib/createSchemaUtils.js +1 -1
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/deepEquals.d.ts +1 -1
- package/lib/deepEquals.js +34 -10
- package/lib/deepEquals.js.map +1 -1
- package/lib/enumOptionsDeselectValue.js +3 -3
- package/lib/enumOptionsDeselectValue.js.map +1 -1
- package/lib/enumOptionsIsSelected.js +3 -3
- package/lib/enumOptionsIsSelected.js.map +1 -1
- package/lib/parser/ParserValidator.js +3 -3
- package/lib/parser/ParserValidator.js.map +1 -1
- package/lib/parser/schemaParser.js +4 -4
- package/lib/parser/schemaParser.js.map +1 -1
- package/lib/schema/getDefaultFormState.d.ts +39 -11
- package/lib/schema/getDefaultFormState.js +160 -125
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/retrieveSchema.js +7 -4
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/schema/toIdSchema.js +2 -2
- package/lib/schema/toIdSchema.js.map +1 -1
- package/lib/schema/toPathSchema.js +3 -3
- package/lib/schema/toPathSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/createSchemaUtils.ts +1 -1
- package/src/deepEquals.ts +37 -10
- package/src/enumOptionsDeselectValue.ts +3 -4
- package/src/enumOptionsIsSelected.ts +3 -4
- package/src/parser/ParserValidator.ts +3 -3
- package/src/parser/schemaParser.ts +4 -4
- package/src/schema/getDefaultFormState.ts +237 -156
- package/src/schema/retrieveSchema.ts +8 -5
- package/src/schema/toIdSchema.ts +2 -2
- package/src/schema/toPathSchema.ts +3 -3
package/dist/utils.esm.js
CHANGED
|
@@ -128,14 +128,25 @@ function createErrorHandler(formData) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
// src/deepEquals.ts
|
|
131
|
-
import
|
|
131
|
+
import { createCustomEqual } from "fast-equals";
|
|
132
|
+
function isFunctions(a, b) {
|
|
133
|
+
return typeof a === "function" && typeof b === "function";
|
|
134
|
+
}
|
|
135
|
+
var customDeepEqual = createCustomEqual({
|
|
136
|
+
createInternalComparator: (comparator) => {
|
|
137
|
+
return (a, b, _idxA, _idxB, _parentA, _parentB, state) => {
|
|
138
|
+
if (isFunctions(a, b)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return comparator(a, b, state);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
132
145
|
function deepEquals(a, b) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return void 0;
|
|
138
|
-
});
|
|
146
|
+
if (isFunctions(a, b)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return customDeepEqual(a, b);
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
// src/schema/getDefaultFormState.ts
|
|
@@ -279,7 +290,6 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
|
|
|
279
290
|
|
|
280
291
|
// src/schema/retrieveSchema.ts
|
|
281
292
|
import get4 from "lodash/get";
|
|
282
|
-
import isEqual from "lodash/isEqual";
|
|
283
293
|
import set from "lodash/set";
|
|
284
294
|
import times from "lodash/times";
|
|
285
295
|
import transform from "lodash/transform";
|
|
@@ -459,7 +469,10 @@ function resolveSchema(validator, schema, rootSchema, expandAllBranches, recurse
|
|
|
459
469
|
)
|
|
460
470
|
);
|
|
461
471
|
const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
|
|
462
|
-
return allPermutations.map((permutation) => ({
|
|
472
|
+
return allPermutations.map((permutation) => ({
|
|
473
|
+
...schema,
|
|
474
|
+
allOf: permutation
|
|
475
|
+
}));
|
|
463
476
|
}
|
|
464
477
|
return [schema];
|
|
465
478
|
}
|
|
@@ -511,7 +524,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
511
524
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
512
525
|
};
|
|
513
526
|
}
|
|
514
|
-
return
|
|
527
|
+
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
515
528
|
}
|
|
516
529
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
|
|
517
530
|
const schema = {
|
|
@@ -987,15 +1000,16 @@ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValu
|
|
|
987
1000
|
}
|
|
988
1001
|
}
|
|
989
1002
|
}
|
|
990
|
-
function computeDefaults(validator, rawSchema, {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1003
|
+
function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
1004
|
+
const {
|
|
1005
|
+
parentDefaults,
|
|
1006
|
+
rawFormData,
|
|
1007
|
+
rootSchema = {},
|
|
1008
|
+
includeUndefinedValues = false,
|
|
1009
|
+
_recurseList = [],
|
|
1010
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1011
|
+
required
|
|
1012
|
+
} = computeDefaultsProps;
|
|
999
1013
|
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
1000
1014
|
const schema = isObject(rawSchema) ? rawSchema : {};
|
|
1001
1015
|
let defaults = parentDefaults;
|
|
@@ -1012,7 +1026,11 @@ function computeDefaults(validator, rawSchema, {
|
|
|
1012
1026
|
schemaToCompute = findSchemaDefinition(refName, rootSchema);
|
|
1013
1027
|
}
|
|
1014
1028
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
1015
|
-
const
|
|
1029
|
+
const defaultFormData = {
|
|
1030
|
+
...formData,
|
|
1031
|
+
...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults)
|
|
1032
|
+
};
|
|
1033
|
+
const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, [], defaultFormData);
|
|
1016
1034
|
schemaToCompute = resolvedSchema[0];
|
|
1017
1035
|
} else if (isFixedItems(schema)) {
|
|
1018
1036
|
defaults = schema.items.map(
|
|
@@ -1071,127 +1089,154 @@ function computeDefaults(validator, rawSchema, {
|
|
|
1071
1089
|
if (defaults === void 0) {
|
|
1072
1090
|
defaults = schema.default;
|
|
1073
1091
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
)
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
{}
|
|
1100
|
-
);
|
|
1101
|
-
if (retrievedSchema.additionalProperties) {
|
|
1102
|
-
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1103
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1104
|
-
if (isObject(defaults)) {
|
|
1105
|
-
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys.add(key));
|
|
1106
|
-
}
|
|
1107
|
-
const formDataRequired = [];
|
|
1108
|
-
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1109
|
-
keys.add(key);
|
|
1110
|
-
formDataRequired.push(key);
|
|
1111
|
-
});
|
|
1112
|
-
keys.forEach((key) => {
|
|
1113
|
-
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1114
|
-
rootSchema,
|
|
1115
|
-
_recurseList,
|
|
1116
|
-
experimental_defaultFormStateBehavior,
|
|
1117
|
-
includeUndefinedValues: includeUndefinedValues === true,
|
|
1118
|
-
parentDefaults: get7(defaults, [key]),
|
|
1119
|
-
rawFormData: get7(formData, [key]),
|
|
1120
|
-
required: retrievedSchema.required?.includes(key)
|
|
1121
|
-
});
|
|
1122
|
-
maybeAddDefaultToObject(
|
|
1123
|
-
objectDefaults,
|
|
1124
|
-
key,
|
|
1125
|
-
computedDefault,
|
|
1126
|
-
includeUndefinedValues,
|
|
1127
|
-
required,
|
|
1128
|
-
formDataRequired
|
|
1129
|
-
);
|
|
1092
|
+
const defaultBasedOnSchemaType = getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults);
|
|
1093
|
+
return defaultBasedOnSchemaType ?? defaults;
|
|
1094
|
+
}
|
|
1095
|
+
function getObjectDefaults(validator, rawSchema, {
|
|
1096
|
+
rawFormData,
|
|
1097
|
+
rootSchema = {},
|
|
1098
|
+
includeUndefinedValues = false,
|
|
1099
|
+
_recurseList = [],
|
|
1100
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1101
|
+
required
|
|
1102
|
+
} = {}, defaults) {
|
|
1103
|
+
{
|
|
1104
|
+
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
1105
|
+
const schema = rawSchema;
|
|
1106
|
+
const retrievedSchema = experimental_defaultFormStateBehavior?.allOf === "populateDefaults" && ALL_OF_KEY in schema ? retrieveSchema(validator, schema, rootSchema, formData) : schema;
|
|
1107
|
+
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1108
|
+
(acc, key) => {
|
|
1109
|
+
const computedDefault = computeDefaults(validator, get7(retrievedSchema, [PROPERTIES_KEY, key]), {
|
|
1110
|
+
rootSchema,
|
|
1111
|
+
_recurseList,
|
|
1112
|
+
experimental_defaultFormStateBehavior,
|
|
1113
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1114
|
+
parentDefaults: get7(defaults, [key]),
|
|
1115
|
+
rawFormData: get7(formData, [key]),
|
|
1116
|
+
required: retrievedSchema.required?.includes(key)
|
|
1130
1117
|
});
|
|
1118
|
+
maybeAddDefaultToObject(
|
|
1119
|
+
acc,
|
|
1120
|
+
key,
|
|
1121
|
+
computedDefault,
|
|
1122
|
+
includeUndefinedValues,
|
|
1123
|
+
required,
|
|
1124
|
+
retrievedSchema.required,
|
|
1125
|
+
experimental_defaultFormStateBehavior
|
|
1126
|
+
);
|
|
1127
|
+
return acc;
|
|
1128
|
+
},
|
|
1129
|
+
{}
|
|
1130
|
+
);
|
|
1131
|
+
if (retrievedSchema.additionalProperties) {
|
|
1132
|
+
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1133
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1134
|
+
if (isObject(defaults)) {
|
|
1135
|
+
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys.add(key));
|
|
1131
1136
|
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
experimental_defaultFormStateBehavior,
|
|
1147
|
-
parentDefaults: item,
|
|
1148
|
-
required
|
|
1149
|
-
});
|
|
1137
|
+
const formDataRequired = [];
|
|
1138
|
+
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1139
|
+
keys.add(key);
|
|
1140
|
+
formDataRequired.push(key);
|
|
1141
|
+
});
|
|
1142
|
+
keys.forEach((key) => {
|
|
1143
|
+
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1144
|
+
rootSchema,
|
|
1145
|
+
_recurseList,
|
|
1146
|
+
experimental_defaultFormStateBehavior,
|
|
1147
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1148
|
+
parentDefaults: get7(defaults, [key]),
|
|
1149
|
+
rawFormData: get7(formData, [key]),
|
|
1150
|
+
required: retrievedSchema.required?.includes(key)
|
|
1150
1151
|
});
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1152
|
+
maybeAddDefaultToObject(
|
|
1153
|
+
objectDefaults,
|
|
1154
|
+
key,
|
|
1155
|
+
computedDefault,
|
|
1156
|
+
includeUndefinedValues,
|
|
1157
|
+
required,
|
|
1158
|
+
formDataRequired
|
|
1159
|
+
);
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
return objectDefaults;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
function getArrayDefaults(validator, rawSchema, {
|
|
1166
|
+
rawFormData,
|
|
1167
|
+
rootSchema = {},
|
|
1168
|
+
_recurseList = [],
|
|
1169
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1170
|
+
required
|
|
1171
|
+
} = {}, defaults) {
|
|
1172
|
+
const schema = rawSchema;
|
|
1173
|
+
const neverPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "never";
|
|
1174
|
+
const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "requiredOnly";
|
|
1175
|
+
const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === "skipEmptyDefaults";
|
|
1176
|
+
const computeSkipPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.computeSkipPopulate ?? (() => false);
|
|
1177
|
+
const emptyDefault = isSkipEmptyDefaults ? void 0 : [];
|
|
1178
|
+
if (Array.isArray(defaults)) {
|
|
1179
|
+
defaults = defaults.map((item, idx) => {
|
|
1180
|
+
const schemaItem = getInnerSchemaForArrayItem(schema, 2 /* Fallback */, idx);
|
|
1181
|
+
return computeDefaults(validator, schemaItem, {
|
|
1182
|
+
rootSchema,
|
|
1183
|
+
_recurseList,
|
|
1184
|
+
experimental_defaultFormStateBehavior,
|
|
1185
|
+
parentDefaults: item,
|
|
1186
|
+
required
|
|
1187
|
+
});
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
if (Array.isArray(rawFormData)) {
|
|
1191
|
+
const schemaItem = getInnerSchemaForArrayItem(schema);
|
|
1192
|
+
if (neverPopulate) {
|
|
1193
|
+
defaults = rawFormData;
|
|
1194
|
+
} else {
|
|
1195
|
+
defaults = rawFormData.map((item, idx) => {
|
|
1196
|
+
return computeDefaults(validator, schemaItem, {
|
|
1185
1197
|
rootSchema,
|
|
1186
1198
|
_recurseList,
|
|
1187
1199
|
experimental_defaultFormStateBehavior,
|
|
1200
|
+
rawFormData: item,
|
|
1201
|
+
parentDefaults: get7(defaults, [idx]),
|
|
1188
1202
|
required
|
|
1189
|
-
})
|
|
1190
|
-
);
|
|
1191
|
-
|
|
1203
|
+
});
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
if (neverPopulate) {
|
|
1208
|
+
return defaults ?? emptyDefault;
|
|
1209
|
+
}
|
|
1210
|
+
if (ignoreMinItemsFlagSet && !required) {
|
|
1211
|
+
return defaults ? defaults : void 0;
|
|
1212
|
+
}
|
|
1213
|
+
const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
|
|
1214
|
+
if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
|
|
1215
|
+
return defaults ? defaults : emptyDefault;
|
|
1216
|
+
}
|
|
1217
|
+
const defaultEntries = defaults || [];
|
|
1218
|
+
const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
|
|
1219
|
+
const fillerDefault = fillerSchema.default;
|
|
1220
|
+
const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
|
|
1221
|
+
computeDefaults(validator, fillerSchema, {
|
|
1222
|
+
parentDefaults: fillerDefault,
|
|
1223
|
+
rootSchema,
|
|
1224
|
+
_recurseList,
|
|
1225
|
+
experimental_defaultFormStateBehavior,
|
|
1226
|
+
required
|
|
1227
|
+
})
|
|
1228
|
+
);
|
|
1229
|
+
return defaultEntries.concat(fillerEntries);
|
|
1230
|
+
}
|
|
1231
|
+
function getDefaultBasedOnSchemaType(validator, rawSchema, computeDefaultsProps = {}, defaults) {
|
|
1232
|
+
switch (getSchemaType(rawSchema)) {
|
|
1233
|
+
case "object": {
|
|
1234
|
+
return getObjectDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1235
|
+
}
|
|
1236
|
+
case "array": {
|
|
1237
|
+
return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1192
1238
|
}
|
|
1193
1239
|
}
|
|
1194
|
-
return defaults;
|
|
1195
1240
|
}
|
|
1196
1241
|
function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior) {
|
|
1197
1242
|
if (!isObject(theSchema)) {
|
|
@@ -1384,11 +1429,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1384
1429
|
|
|
1385
1430
|
// src/schema/toIdSchema.ts
|
|
1386
1431
|
import get9 from "lodash/get";
|
|
1387
|
-
import isEqual2 from "lodash/isEqual";
|
|
1388
1432
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
|
|
1389
1433
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1390
1434
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
1391
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1435
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1392
1436
|
if (sameSchemaIndex === -1) {
|
|
1393
1437
|
return toIdSchemaInternal(
|
|
1394
1438
|
validator,
|
|
@@ -1442,12 +1486,11 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
|
|
|
1442
1486
|
|
|
1443
1487
|
// src/schema/toPathSchema.ts
|
|
1444
1488
|
import get10 from "lodash/get";
|
|
1445
|
-
import isEqual3 from "lodash/isEqual";
|
|
1446
1489
|
import set2 from "lodash/set";
|
|
1447
1490
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
|
|
1448
1491
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1449
1492
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
1450
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1493
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1451
1494
|
if (sameSchemaIndex === -1) {
|
|
1452
1495
|
return toPathSchemaInternal(
|
|
1453
1496
|
validator,
|
|
@@ -1818,9 +1861,6 @@ function englishStringTranslator(stringToTranslate, params) {
|
|
|
1818
1861
|
return replaceStringParameters(stringToTranslate, params);
|
|
1819
1862
|
}
|
|
1820
1863
|
|
|
1821
|
-
// src/enumOptionsDeselectValue.ts
|
|
1822
|
-
import isEqual4 from "lodash/isEqual";
|
|
1823
|
-
|
|
1824
1864
|
// src/enumOptionsValueForIndex.ts
|
|
1825
1865
|
function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
1826
1866
|
if (Array.isArray(valueIndex)) {
|
|
@@ -1835,18 +1875,17 @@ function enumOptionsValueForIndex(valueIndex, allEnumOptions = [], emptyValue) {
|
|
|
1835
1875
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
1836
1876
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
1837
1877
|
if (Array.isArray(selected)) {
|
|
1838
|
-
return selected.filter((v) => !
|
|
1878
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
1839
1879
|
}
|
|
1840
|
-
return
|
|
1880
|
+
return deepEquals(value, selected) ? void 0 : selected;
|
|
1841
1881
|
}
|
|
1842
1882
|
|
|
1843
1883
|
// src/enumOptionsIsSelected.ts
|
|
1844
|
-
import isEqual5 from "lodash/isEqual";
|
|
1845
1884
|
function enumOptionsIsSelected(value, selected) {
|
|
1846
1885
|
if (Array.isArray(selected)) {
|
|
1847
|
-
return selected.some((sel) =>
|
|
1886
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
1848
1887
|
}
|
|
1849
|
-
return
|
|
1888
|
+
return deepEquals(selected, value);
|
|
1850
1889
|
}
|
|
1851
1890
|
|
|
1852
1891
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2541,11 +2580,9 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
2541
2580
|
|
|
2542
2581
|
// src/parser/schemaParser.ts
|
|
2543
2582
|
import forEach from "lodash/forEach";
|
|
2544
|
-
import isEqual7 from "lodash/isEqual";
|
|
2545
2583
|
|
|
2546
2584
|
// src/parser/ParserValidator.ts
|
|
2547
2585
|
import get13 from "lodash/get";
|
|
2548
|
-
import isEqual6 from "lodash/isEqual";
|
|
2549
2586
|
var ParserValidator = class {
|
|
2550
2587
|
/** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
|
|
2551
2588
|
* first.
|
|
@@ -2576,7 +2613,7 @@ var ParserValidator = class {
|
|
|
2576
2613
|
const existing = this.schemaMap[key];
|
|
2577
2614
|
if (!existing) {
|
|
2578
2615
|
this.schemaMap[key] = identifiedSchema;
|
|
2579
|
-
} else if (!
|
|
2616
|
+
} else if (!deepEquals(existing, identifiedSchema)) {
|
|
2580
2617
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
2581
2618
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
2582
2619
|
throw new Error(
|
|
@@ -2598,7 +2635,7 @@ var ParserValidator = class {
|
|
|
2598
2635
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
2599
2636
|
*/
|
|
2600
2637
|
isValid(schema, _formData, rootSchema) {
|
|
2601
|
-
if (!
|
|
2638
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
2602
2639
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
2603
2640
|
}
|
|
2604
2641
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -2638,7 +2675,7 @@ var ParserValidator = class {
|
|
|
2638
2675
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
2639
2676
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
2640
2677
|
schemas.forEach((schema2) => {
|
|
2641
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
2678
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
|
|
2642
2679
|
if (sameSchemaIndex === -1) {
|
|
2643
2680
|
recurseList.push(schema2);
|
|
2644
2681
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|