@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.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', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject, global.
|
|
5
|
-
})(this, (function (exports, isPlainObject,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('fast-equals'), require('lodash/get'), require('lodash/isEmpty'), require('jsonpointer'), require('lodash/omit'), require('lodash/has'), require('lodash/isNumber'), require('lodash/isObject'), require('lodash/isString'), require('lodash/reduce'), require('lodash/times'), require('lodash/set'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('lodash/union'), require('lodash/isNil'), require('lodash/cloneDeep'), 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', 'fast-equals', 'lodash/get', 'lodash/isEmpty', 'jsonpointer', 'lodash/omit', 'lodash/has', 'lodash/isNumber', 'lodash/isObject', 'lodash/isString', 'lodash/reduce', 'lodash/times', 'lodash/set', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'lodash/union', 'lodash/isNil', 'lodash/cloneDeep', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/forEach'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject, global.fastEquals, global.get8, global.isEmpty, global.jsonpointer, global.omit, global.has3, global.isNumber, global.isObject2, global.isString, global.reduce, global.times, global.set3, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.union, global.isNil, global.cloneDeep, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject, fastEquals, get8, isEmpty, jsonpointer, omit, has3, isNumber, isObject2, isString, reduce, times, set3, transform, merge, flattenDeep, uniq, mergeAllOf, union, isNil, cloneDeep, react, ReactIs, jsxRuntime, toPath, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
@@ -129,13 +129,24 @@
|
|
|
129
129
|
}
|
|
130
130
|
return handler;
|
|
131
131
|
}
|
|
132
|
+
function isFunctions(a, b) {
|
|
133
|
+
return typeof a === "function" && typeof b === "function";
|
|
134
|
+
}
|
|
135
|
+
var customDeepEqual = fastEquals.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
|
function splitKeyElementFromObject(key, object) {
|
|
141
152
|
const value = object[key];
|
|
@@ -416,7 +427,10 @@
|
|
|
416
427
|
)
|
|
417
428
|
);
|
|
418
429
|
const allPermutations = getAllPermutationsOfXxxOf(allOfSchemaElements);
|
|
419
|
-
return allPermutations.map((permutation) => ({
|
|
430
|
+
return allPermutations.map((permutation) => ({
|
|
431
|
+
...schema,
|
|
432
|
+
allOf: permutation
|
|
433
|
+
}));
|
|
420
434
|
}
|
|
421
435
|
return [schema];
|
|
422
436
|
}
|
|
@@ -468,7 +482,7 @@
|
|
|
468
482
|
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
469
483
|
};
|
|
470
484
|
}
|
|
471
|
-
return
|
|
485
|
+
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
472
486
|
}
|
|
473
487
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData) {
|
|
474
488
|
const schema = {
|
|
@@ -941,15 +955,16 @@
|
|
|
941
955
|
}
|
|
942
956
|
}
|
|
943
957
|
}
|
|
944
|
-
function computeDefaults(validator, rawSchema, {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
958
|
+
function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
959
|
+
const {
|
|
960
|
+
parentDefaults,
|
|
961
|
+
rawFormData,
|
|
962
|
+
rootSchema = {},
|
|
963
|
+
includeUndefinedValues = false,
|
|
964
|
+
_recurseList = [],
|
|
965
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
966
|
+
required
|
|
967
|
+
} = computeDefaultsProps;
|
|
953
968
|
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
954
969
|
const schema = isObject(rawSchema) ? rawSchema : {};
|
|
955
970
|
let defaults = parentDefaults;
|
|
@@ -966,7 +981,11 @@
|
|
|
966
981
|
schemaToCompute = findSchemaDefinition(refName, rootSchema);
|
|
967
982
|
}
|
|
968
983
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
969
|
-
const
|
|
984
|
+
const defaultFormData = {
|
|
985
|
+
...formData,
|
|
986
|
+
...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults)
|
|
987
|
+
};
|
|
988
|
+
const resolvedSchema = resolveDependencies(validator, schema, rootSchema, false, [], defaultFormData);
|
|
970
989
|
schemaToCompute = resolvedSchema[0];
|
|
971
990
|
} else if (isFixedItems(schema)) {
|
|
972
991
|
defaults = schema.items.map(
|
|
@@ -1025,127 +1044,154 @@
|
|
|
1025
1044
|
if (defaults === void 0) {
|
|
1026
1045
|
defaults = schema.default;
|
|
1027
1046
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
)
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
{}
|
|
1054
|
-
);
|
|
1055
|
-
if (retrievedSchema.additionalProperties) {
|
|
1056
|
-
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1057
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1058
|
-
if (isObject(defaults)) {
|
|
1059
|
-
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys.add(key));
|
|
1060
|
-
}
|
|
1061
|
-
const formDataRequired = [];
|
|
1062
|
-
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1063
|
-
keys.add(key);
|
|
1064
|
-
formDataRequired.push(key);
|
|
1065
|
-
});
|
|
1066
|
-
keys.forEach((key) => {
|
|
1067
|
-
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1068
|
-
rootSchema,
|
|
1069
|
-
_recurseList,
|
|
1070
|
-
experimental_defaultFormStateBehavior,
|
|
1071
|
-
includeUndefinedValues: includeUndefinedValues === true,
|
|
1072
|
-
parentDefaults: get8(defaults, [key]),
|
|
1073
|
-
rawFormData: get8(formData, [key]),
|
|
1074
|
-
required: retrievedSchema.required?.includes(key)
|
|
1075
|
-
});
|
|
1076
|
-
maybeAddDefaultToObject(
|
|
1077
|
-
objectDefaults,
|
|
1078
|
-
key,
|
|
1079
|
-
computedDefault,
|
|
1080
|
-
includeUndefinedValues,
|
|
1081
|
-
required,
|
|
1082
|
-
formDataRequired
|
|
1083
|
-
);
|
|
1047
|
+
const defaultBasedOnSchemaType = getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults);
|
|
1048
|
+
return defaultBasedOnSchemaType ?? defaults;
|
|
1049
|
+
}
|
|
1050
|
+
function getObjectDefaults(validator, rawSchema, {
|
|
1051
|
+
rawFormData,
|
|
1052
|
+
rootSchema = {},
|
|
1053
|
+
includeUndefinedValues = false,
|
|
1054
|
+
_recurseList = [],
|
|
1055
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1056
|
+
required
|
|
1057
|
+
} = {}, defaults) {
|
|
1058
|
+
{
|
|
1059
|
+
const formData = isObject(rawFormData) ? rawFormData : {};
|
|
1060
|
+
const schema = rawSchema;
|
|
1061
|
+
const retrievedSchema = experimental_defaultFormStateBehavior?.allOf === "populateDefaults" && ALL_OF_KEY in schema ? retrieveSchema(validator, schema, rootSchema, formData) : schema;
|
|
1062
|
+
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1063
|
+
(acc, key) => {
|
|
1064
|
+
const computedDefault = computeDefaults(validator, get8(retrievedSchema, [PROPERTIES_KEY, key]), {
|
|
1065
|
+
rootSchema,
|
|
1066
|
+
_recurseList,
|
|
1067
|
+
experimental_defaultFormStateBehavior,
|
|
1068
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1069
|
+
parentDefaults: get8(defaults, [key]),
|
|
1070
|
+
rawFormData: get8(formData, [key]),
|
|
1071
|
+
required: retrievedSchema.required?.includes(key)
|
|
1084
1072
|
});
|
|
1073
|
+
maybeAddDefaultToObject(
|
|
1074
|
+
acc,
|
|
1075
|
+
key,
|
|
1076
|
+
computedDefault,
|
|
1077
|
+
includeUndefinedValues,
|
|
1078
|
+
required,
|
|
1079
|
+
retrievedSchema.required,
|
|
1080
|
+
experimental_defaultFormStateBehavior
|
|
1081
|
+
);
|
|
1082
|
+
return acc;
|
|
1083
|
+
},
|
|
1084
|
+
{}
|
|
1085
|
+
);
|
|
1086
|
+
if (retrievedSchema.additionalProperties) {
|
|
1087
|
+
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1088
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1089
|
+
if (isObject(defaults)) {
|
|
1090
|
+
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys.add(key));
|
|
1085
1091
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
experimental_defaultFormStateBehavior,
|
|
1101
|
-
parentDefaults: item,
|
|
1102
|
-
required
|
|
1103
|
-
});
|
|
1092
|
+
const formDataRequired = [];
|
|
1093
|
+
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1094
|
+
keys.add(key);
|
|
1095
|
+
formDataRequired.push(key);
|
|
1096
|
+
});
|
|
1097
|
+
keys.forEach((key) => {
|
|
1098
|
+
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1099
|
+
rootSchema,
|
|
1100
|
+
_recurseList,
|
|
1101
|
+
experimental_defaultFormStateBehavior,
|
|
1102
|
+
includeUndefinedValues: includeUndefinedValues === true,
|
|
1103
|
+
parentDefaults: get8(defaults, [key]),
|
|
1104
|
+
rawFormData: get8(formData, [key]),
|
|
1105
|
+
required: retrievedSchema.required?.includes(key)
|
|
1104
1106
|
});
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1107
|
+
maybeAddDefaultToObject(
|
|
1108
|
+
objectDefaults,
|
|
1109
|
+
key,
|
|
1110
|
+
computedDefault,
|
|
1111
|
+
includeUndefinedValues,
|
|
1112
|
+
required,
|
|
1113
|
+
formDataRequired
|
|
1114
|
+
);
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
return objectDefaults;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
function getArrayDefaults(validator, rawSchema, {
|
|
1121
|
+
rawFormData,
|
|
1122
|
+
rootSchema = {},
|
|
1123
|
+
_recurseList = [],
|
|
1124
|
+
experimental_defaultFormStateBehavior = void 0,
|
|
1125
|
+
required
|
|
1126
|
+
} = {}, defaults) {
|
|
1127
|
+
const schema = rawSchema;
|
|
1128
|
+
const neverPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "never";
|
|
1129
|
+
const ignoreMinItemsFlagSet = experimental_defaultFormStateBehavior?.arrayMinItems?.populate === "requiredOnly";
|
|
1130
|
+
const isSkipEmptyDefaults = experimental_defaultFormStateBehavior?.emptyObjectFields === "skipEmptyDefaults";
|
|
1131
|
+
const computeSkipPopulate = experimental_defaultFormStateBehavior?.arrayMinItems?.computeSkipPopulate ?? (() => false);
|
|
1132
|
+
const emptyDefault = isSkipEmptyDefaults ? void 0 : [];
|
|
1133
|
+
if (Array.isArray(defaults)) {
|
|
1134
|
+
defaults = defaults.map((item, idx) => {
|
|
1135
|
+
const schemaItem = getInnerSchemaForArrayItem(schema, 2 /* Fallback */, idx);
|
|
1136
|
+
return computeDefaults(validator, schemaItem, {
|
|
1137
|
+
rootSchema,
|
|
1138
|
+
_recurseList,
|
|
1139
|
+
experimental_defaultFormStateBehavior,
|
|
1140
|
+
parentDefaults: item,
|
|
1141
|
+
required
|
|
1142
|
+
});
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
if (Array.isArray(rawFormData)) {
|
|
1146
|
+
const schemaItem = getInnerSchemaForArrayItem(schema);
|
|
1147
|
+
if (neverPopulate) {
|
|
1148
|
+
defaults = rawFormData;
|
|
1149
|
+
} else {
|
|
1150
|
+
defaults = rawFormData.map((item, idx) => {
|
|
1151
|
+
return computeDefaults(validator, schemaItem, {
|
|
1139
1152
|
rootSchema,
|
|
1140
1153
|
_recurseList,
|
|
1141
1154
|
experimental_defaultFormStateBehavior,
|
|
1155
|
+
rawFormData: item,
|
|
1156
|
+
parentDefaults: get8(defaults, [idx]),
|
|
1142
1157
|
required
|
|
1143
|
-
})
|
|
1144
|
-
);
|
|
1145
|
-
|
|
1158
|
+
});
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (neverPopulate) {
|
|
1163
|
+
return defaults ?? emptyDefault;
|
|
1164
|
+
}
|
|
1165
|
+
if (ignoreMinItemsFlagSet && !required) {
|
|
1166
|
+
return defaults ? defaults : void 0;
|
|
1167
|
+
}
|
|
1168
|
+
const defaultsLength = Array.isArray(defaults) ? defaults.length : 0;
|
|
1169
|
+
if (!schema.minItems || isMultiSelect(validator, schema, rootSchema) || computeSkipPopulate(validator, schema, rootSchema) || schema.minItems <= defaultsLength) {
|
|
1170
|
+
return defaults ? defaults : emptyDefault;
|
|
1171
|
+
}
|
|
1172
|
+
const defaultEntries = defaults || [];
|
|
1173
|
+
const fillerSchema = getInnerSchemaForArrayItem(schema, 1 /* Invert */);
|
|
1174
|
+
const fillerDefault = fillerSchema.default;
|
|
1175
|
+
const fillerEntries = new Array(schema.minItems - defaultsLength).fill(
|
|
1176
|
+
computeDefaults(validator, fillerSchema, {
|
|
1177
|
+
parentDefaults: fillerDefault,
|
|
1178
|
+
rootSchema,
|
|
1179
|
+
_recurseList,
|
|
1180
|
+
experimental_defaultFormStateBehavior,
|
|
1181
|
+
required
|
|
1182
|
+
})
|
|
1183
|
+
);
|
|
1184
|
+
return defaultEntries.concat(fillerEntries);
|
|
1185
|
+
}
|
|
1186
|
+
function getDefaultBasedOnSchemaType(validator, rawSchema, computeDefaultsProps = {}, defaults) {
|
|
1187
|
+
switch (getSchemaType(rawSchema)) {
|
|
1188
|
+
case "object": {
|
|
1189
|
+
return getObjectDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1190
|
+
}
|
|
1191
|
+
case "array": {
|
|
1192
|
+
return getArrayDefaults(validator, rawSchema, computeDefaultsProps, defaults);
|
|
1146
1193
|
}
|
|
1147
1194
|
}
|
|
1148
|
-
return defaults;
|
|
1149
1195
|
}
|
|
1150
1196
|
function getDefaultFormState(validator, theSchema, formData, rootSchema, includeUndefinedValues = false, experimental_defaultFormStateBehavior) {
|
|
1151
1197
|
if (!isObject(theSchema)) {
|
|
@@ -1331,7 +1377,7 @@
|
|
|
1331
1377
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = []) {
|
|
1332
1378
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1333
1379
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
1334
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1380
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1335
1381
|
if (sameSchemaIndex === -1) {
|
|
1336
1382
|
return toIdSchemaInternal(
|
|
1337
1383
|
validator,
|
|
@@ -1385,7 +1431,7 @@
|
|
|
1385
1431
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = []) {
|
|
1386
1432
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
1387
1433
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData);
|
|
1388
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1434
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals(item, _schema));
|
|
1389
1435
|
if (sameSchemaIndex === -1) {
|
|
1390
1436
|
return toPathSchemaInternal(
|
|
1391
1437
|
validator,
|
|
@@ -1770,15 +1816,17 @@
|
|
|
1770
1816
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
1771
1817
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
1772
1818
|
if (Array.isArray(selected)) {
|
|
1773
|
-
return selected.filter((v) => !
|
|
1819
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
1774
1820
|
}
|
|
1775
|
-
return
|
|
1821
|
+
return deepEquals(value, selected) ? void 0 : selected;
|
|
1776
1822
|
}
|
|
1823
|
+
|
|
1824
|
+
// src/enumOptionsIsSelected.ts
|
|
1777
1825
|
function enumOptionsIsSelected(value, selected) {
|
|
1778
1826
|
if (Array.isArray(selected)) {
|
|
1779
|
-
return selected.some((sel) =>
|
|
1827
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
1780
1828
|
}
|
|
1781
|
-
return
|
|
1829
|
+
return deepEquals(selected, value);
|
|
1782
1830
|
}
|
|
1783
1831
|
|
|
1784
1832
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2467,7 +2515,7 @@
|
|
|
2467
2515
|
const existing = this.schemaMap[key];
|
|
2468
2516
|
if (!existing) {
|
|
2469
2517
|
this.schemaMap[key] = identifiedSchema;
|
|
2470
|
-
} else if (!
|
|
2518
|
+
} else if (!deepEquals(existing, identifiedSchema)) {
|
|
2471
2519
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
2472
2520
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
2473
2521
|
throw new Error(
|
|
@@ -2489,7 +2537,7 @@
|
|
|
2489
2537
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
2490
2538
|
*/
|
|
2491
2539
|
isValid(schema, _formData, rootSchema) {
|
|
2492
|
-
if (!
|
|
2540
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
2493
2541
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
2494
2542
|
}
|
|
2495
2543
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -2529,7 +2577,7 @@
|
|
|
2529
2577
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
2530
2578
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
2531
2579
|
schemas.forEach((schema2) => {
|
|
2532
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
2580
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals(item, schema2));
|
|
2533
2581
|
if (sameSchemaIndex === -1) {
|
|
2534
2582
|
recurseList.push(schema2);
|
|
2535
2583
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
package/lib/createSchemaUtils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import deepEquals from './deepEquals';
|
|
2
|
-
import { getDefaultFormState, getDisplayLabel,
|
|
2
|
+
import { getClosestMatchingOption, getDefaultFormState, getDisplayLabel, getFirstMatchingOption, getMatchingOption, isFilesArray, isMultiSelect, isSelect, mergeValidationData, retrieveSchema, sanitizeDataForNewSchema, toIdSchema, toPathSchema, } from './schema';
|
|
3
3
|
/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
|
|
4
4
|
* that one does not have to explicitly pass the `validator`, `rootSchema`, or `experimental_defaultFormStateBehavior` to each method.
|
|
5
5
|
* Since these generally do not change across a `Form`, this allows for providing a simplified set of APIs to the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAetC,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAetC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,UAAU,EACV,YAAY,GACb,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,MAAM,WAAW;IAOf;;;;;OAKG;IACH,YACE,SAAiC,EACjC,UAAa,EACb,qCAA4E;QAE5E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,qCAAqC,GAAG,qCAAqC,CAAC;IACrF,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;OAQG;IACH,qBAAqB,CACnB,SAAiC,EACjC,UAAa,EACb,qCAAqC,GAAG,EAAE;QAE1C,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU,EAAE;YAC7B,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CACL,IAAI,CAAC,SAAS,KAAK,SAAS;YAC5B,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;YACxC,CAAC,UAAU,CAAC,IAAI,CAAC,qCAAqC,EAAE,qCAAqC,CAAC,CAC/F,CAAC;IACJ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AAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IACxF,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAKvC,SAAiC,EACjC,UAAa,EACb,qCAAqC,GAAG,EAAE;IAE1C,OAAO,IAAI,WAAW,CAAU,SAAS,EAAE,UAAU,EAAE,qCAAqC,CAAC,CAAC;AAChG,CAAC"}
|
package/lib/deepEquals.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Implements a deep equals using the `
|
|
1
|
+
/** Implements a deep equals using the `fast-equal.createCustomEqual` function, that provides a customized comparator that
|
|
2
2
|
* assumes all functions are equivalent.
|
|
3
3
|
*
|
|
4
4
|
* @param a - The first element to compare
|
package/lib/deepEquals.js
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
1
|
+
import { createCustomEqual } from 'fast-equals';
|
|
2
|
+
/** Check if all parameters are typeof function.
|
|
3
|
+
*
|
|
4
|
+
* @param a - The first element to check typeof
|
|
5
|
+
* @param b - The second element to check typeof
|
|
6
|
+
* @returns - if typeof a and b are equal to function return true, otherwise false
|
|
7
|
+
*/
|
|
8
|
+
function isFunctions(a, b) {
|
|
9
|
+
return typeof a === 'function' && typeof b === 'function';
|
|
10
|
+
}
|
|
11
|
+
/** Implements a deep equals using the `fast-equal.createCustomEqual` function, that provides a customized comparator that
|
|
12
|
+
* assumes all functions in objects are equivalent.
|
|
13
|
+
*
|
|
14
|
+
* @param a - The first element to compare
|
|
15
|
+
* @param b - The second element to compare
|
|
16
|
+
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
const customDeepEqual = createCustomEqual({
|
|
19
|
+
createInternalComparator: (comparator) => {
|
|
20
|
+
return (a, b, _idxA, _idxB, _parentA, _parentB, state) => {
|
|
21
|
+
if (isFunctions(a, b)) {
|
|
22
|
+
// Assume all functions are equivalent
|
|
23
|
+
// see https://github.com/rjsf-team/react-jsonschema-form/issues/255
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return comparator(a, b, state);
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
/** Implements a deep equals using the `fast-equal.createCustomEqual` function, that provides a customized comparator that
|
|
3
31
|
* assumes all functions are equivalent.
|
|
4
32
|
*
|
|
5
33
|
* @param a - The first element to compare
|
|
@@ -7,13 +35,9 @@ import isEqualWith from 'lodash/isEqualWith';
|
|
|
7
35
|
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
8
36
|
*/
|
|
9
37
|
export default function deepEquals(a, b) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return undefined; // fallback to default isEquals behavior
|
|
17
|
-
});
|
|
38
|
+
if (isFunctions(a, b)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return customDeepEqual(a, b);
|
|
18
42
|
}
|
|
19
43
|
//# sourceMappingURL=deepEquals.js.map
|
package/lib/deepEquals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"deepEquals.js","sourceRoot":"","sources":["../src/deepEquals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAS,MAAM,aAAa,CAAC;AAEvD;;;;;GAKG;AACH,SAAS,WAAW,CAAC,CAAM,EAAE,CAAM;IACjC,OAAO,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,KAAK,UAAU,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,iBAAiB,CAAC;IACxC,wBAAwB,EAAE,CAAC,UAA0D,EAAE,EAAE;QACvF,OAAO,CAAC,CAAM,EAAE,CAAM,EAAE,KAAU,EAAE,KAAU,EAAE,QAAa,EAAE,QAAa,EAAE,KAAiB,EAAE,EAAE;YACjG,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;gBACrB,sCAAsC;gBACtC,oEAAoE;gBACpE,OAAO,IAAI,CAAC;aACb;YAED,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,CAAM,EAAE,CAAM;IAC/C,IAAI,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACrB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import isEqual from 'lodash/isEqual';
|
|
2
1
|
import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
2
|
+
import deepEquals from './deepEquals';
|
|
3
3
|
/** Removes the enum option value at the `valueIndex` from the currently `selected` (list of) value(s). If `selected` is
|
|
4
4
|
* a list, then that list is updated to remove the enum option value with the `valueIndex` in `allEnumOptions`. If it is
|
|
5
5
|
* a single value, then if the enum option value with the `valueIndex` in `allEnumOptions` matches `selected`, undefined
|
|
@@ -15,8 +15,8 @@ import enumOptionsValueForIndex from './enumOptionsValueForIndex';
|
|
|
15
15
|
export default function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
16
16
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
17
17
|
if (Array.isArray(selected)) {
|
|
18
|
-
return selected.filter((v) => !
|
|
18
|
+
return selected.filter((v) => !deepEquals(v, value));
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return deepEquals(value, selected) ? undefined : selected;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=enumOptionsDeselectValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsDeselectValue.js","sourceRoot":"","sources":["../src/enumOptionsDeselectValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enumOptionsDeselectValue.js","sourceRoot":"","sources":["../src/enumOptionsDeselectValue.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAA2B,EAC3B,QAAsE,EACtE,iBAAuC,EAAE;IAEzC,MAAM,KAAK,GAAG,wBAAwB,CAAI,UAAU,EAAE,cAAc,CAAC,CAAC;IACtE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;KACtD;IACD,OAAO,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deepEquals from './deepEquals';
|
|
2
2
|
/** Determines whether the given `value` is (one of) the `selected` value(s).
|
|
3
3
|
*
|
|
4
4
|
* @param value - The value being checked to see if it is selected
|
|
@@ -7,8 +7,8 @@ import isEqual from 'lodash/isEqual';
|
|
|
7
7
|
*/
|
|
8
8
|
export default function enumOptionsIsSelected(value, selected) {
|
|
9
9
|
if (Array.isArray(selected)) {
|
|
10
|
-
return selected.some((sel) =>
|
|
10
|
+
return selected.some((sel) => deepEquals(sel, value));
|
|
11
11
|
}
|
|
12
|
-
return
|
|
12
|
+
return deepEquals(selected, value);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=enumOptionsIsSelected.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumOptionsIsSelected.js","sourceRoot":"","sources":["../src/enumOptionsIsSelected.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"enumOptionsIsSelected.js","sourceRoot":"","sources":["../src/enumOptionsIsSelected.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAkC,EAClC,QAAqE;IAErE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;KACvD;IACD,OAAO,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import isEqual from 'lodash/isEqual';
|
|
3
2
|
import { ID_KEY } from '../constants';
|
|
4
3
|
import hashForSchema from '../hashForSchema';
|
|
4
|
+
import deepEquals from '../deepEquals';
|
|
5
5
|
/** An implementation of the `ValidatorType` interface that is designed for use in capturing schemas used by the
|
|
6
6
|
* `isValid()` function. The rest of the implementation of the interface throws errors when it is attempted to be used.
|
|
7
7
|
* An instance of the object allows the caller to capture the schemas used in calls to the `isValid()` function. These
|
|
@@ -40,7 +40,7 @@ export default class ParserValidator {
|
|
|
40
40
|
if (!existing) {
|
|
41
41
|
this.schemaMap[key] = identifiedSchema;
|
|
42
42
|
}
|
|
43
|
-
else if (!
|
|
43
|
+
else if (!deepEquals(existing, identifiedSchema)) {
|
|
44
44
|
console.error('existing schema:', JSON.stringify(existing, null, 2));
|
|
45
45
|
console.error('new schema:', JSON.stringify(identifiedSchema, null, 2));
|
|
46
46
|
throw new Error(`Two different schemas exist with the same key ${key}! What a bad coincidence. If possible, try adding an $id to one of the schemas`);
|
|
@@ -60,7 +60,7 @@ export default class ParserValidator {
|
|
|
60
60
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
61
61
|
*/
|
|
62
62
|
isValid(schema, _formData, rootSchema) {
|
|
63
|
-
if (!
|
|
63
|
+
if (!deepEquals(rootSchema, this.rootSchema)) {
|
|
64
64
|
throw new Error('Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema');
|
|
65
65
|
}
|
|
66
66
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParserValidator.js","sourceRoot":"","sources":["../../src/parser/ParserValidator.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ParserValidator.js","sourceRoot":"","sources":["../../src/parser/ParserValidator.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAa7C,OAAO,UAAU,MAAM,eAAe,CAAC;AAQvC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IASlC;;;;OAIG;IACH,YAAY,UAAa;QARzB,4DAA4D;QAC5D,cAAS,GAAiB,EAAE,CAAC;QAQ3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,aAAa,CAAI,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;OACG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,SAAS,CAAC,MAAS,EAAE,IAAY;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI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