@rjsf/utils 6.5.1 → 6.5.3
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 +40 -40
- package/dist/index.cjs.map +3 -3
- package/dist/utils.esm.js +40 -40
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +43 -40
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/deepEquals.d.ts +5 -3
- package/lib/deepEquals.js +13 -13
- package/lib/deepEquals.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/isRootSchema.js +3 -3
- 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 +1 -1
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +2 -2
- package/lib/schema/findFieldInSchema.js +6 -5
- package/lib/schema/findFieldInSchema.js.map +1 -1
- package/lib/schema/findSelectedOptionInXxxOf.js +2 -2
- package/lib/schema/findSelectedOptionInXxxOf.js.map +1 -1
- package/lib/schema/getDefaultFormState.js +8 -5
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/getFromSchema.d.ts +3 -3
- package/lib/schema/getFromSchema.js +2 -2
- package/lib/schema/getFromSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +13 -4
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/useDeepCompareMemo.js +2 -2
- package/lib/useDeepCompareMemo.js.map +1 -1
- package/package.json +3 -2
- package/src/createSchemaUtils.ts +5 -4
- package/src/deepEquals.ts +14 -13
- package/src/enums.ts +2 -0
- package/src/isRootSchema.ts +3 -3
- package/src/jsonSchemaAugmentation.ts +21 -0
- package/src/mergeDefaultsWithFormData.ts +2 -1
- package/src/schema/findFieldInSchema.ts +8 -6
- package/src/schema/findSelectedOptionInXxxOf.ts +2 -2
- package/src/schema/getDefaultFormState.ts +8 -5
- package/src/schema/getFromSchema.ts +14 -7
- package/src/types.ts +14 -4
- package/src/useDeepCompareMemo.ts +3 -2
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.isPlainObject2, global.
|
|
5
|
-
})(this, (function (exports, isPlainObject2,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('fast-equals'), require('lodash/get'), require('lodash/has'), require('lodash/set'), require('lodash/times'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('lodash/isEmpty'), require('@x0k/json-schema-merge'), require('@x0k/json-schema-merge/lib/array'), require('jsonpointer'), require('lodash/omit'), require('lodash/isObject'), require('fast-uri'), require('lodash/isString'), require('lodash/union'), require('lodash/isNumber'), require('lodash/reduce'), require('lodash/isNil'), require('lodash/pick'), require('lodash/cloneDeep'), require('lodash/setWith'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), 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', 'fast-equals', 'lodash/get', 'lodash/has', 'lodash/set', 'lodash/times', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'lodash/isEmpty', '@x0k/json-schema-merge', '@x0k/json-schema-merge/lib/array', 'jsonpointer', 'lodash/omit', 'lodash/isObject', 'fast-uri', 'lodash/isString', 'lodash/union', 'lodash/isNumber', 'lodash/reduce', 'lodash/isNil', 'lodash/pick', 'lodash/cloneDeep', 'lodash/setWith', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', '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.fastEquals, global.get16, global.has5, global.set, global.times, global.transform, global.merge, global.flattenDeep, global.uniq, global.isEmpty4, global.jsonSchemaMerge, global.array, global.jsonpointer, global.omit, global.isObject2, global.UriResolver, global.isString, global.union, global.isNumber, global.reduce, global.isNil, global.pick, global.cloneDeep, global.setWith, global.keys, global.pickBy, global.difference, global.uniqueId, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject2, fastEquals, get16, has5, set, times, transform, merge, flattenDeep, uniq, isEmpty4, jsonSchemaMerge, array, jsonpointer, omit, isObject2, UriResolver, isString, union, isNumber, reduce, isNil, pick, cloneDeep, setWith, keys, pickBy, difference, uniqueId, react, ReactIs, jsxRuntime, toPath, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
@@ -146,14 +146,15 @@
|
|
|
146
146
|
}
|
|
147
147
|
return handler;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
var deepEquals = fastEquals.createCustomEqual({
|
|
150
|
+
circular: true,
|
|
151
|
+
createCustomConfig: () => ({
|
|
152
|
+
areFunctionsEqual(_a, b) {
|
|
153
|
+
return typeof b === "function";
|
|
153
154
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
var deepEquals_default = deepEquals;
|
|
157
158
|
function findEmbeddedSchemaRecursive(schema, ref) {
|
|
158
159
|
if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY], ref)) {
|
|
159
160
|
return schema;
|
|
@@ -621,7 +622,7 @@
|
|
|
621
622
|
};
|
|
622
623
|
}
|
|
623
624
|
}
|
|
624
|
-
return
|
|
625
|
+
return deepEquals_default(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
625
626
|
}
|
|
626
627
|
function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFormData, experimental_customMergeAllOf) {
|
|
627
628
|
const schema = {
|
|
@@ -959,7 +960,7 @@
|
|
|
959
960
|
const data = get16(formData, selectorField);
|
|
960
961
|
if (data !== void 0) {
|
|
961
962
|
return xxxOfs.find((xxx2) => {
|
|
962
|
-
return
|
|
963
|
+
return deepEquals_default(
|
|
963
964
|
get16(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get16(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
964
965
|
data
|
|
965
966
|
);
|
|
@@ -976,9 +977,9 @@
|
|
|
976
977
|
if (isEmpty4(path)) {
|
|
977
978
|
return fieldSchema;
|
|
978
979
|
}
|
|
979
|
-
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
980
|
+
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
980
981
|
const [part, ...nestedPath] = pathList;
|
|
981
|
-
if (part && has5(fieldSchema, part)) {
|
|
982
|
+
if (part !== void 0 && part !== "" && has5(fieldSchema, part)) {
|
|
982
983
|
fieldSchema = get16(fieldSchema, part);
|
|
983
984
|
return getFromSchemaInternal(
|
|
984
985
|
validator,
|
|
@@ -1004,6 +1005,7 @@
|
|
|
1004
1005
|
const pathList = Array.isArray(path) ? [...path] : path.split(".");
|
|
1005
1006
|
let parentField = schema;
|
|
1006
1007
|
const fieldName = pathList.pop();
|
|
1008
|
+
const fieldNameKey = String(fieldName);
|
|
1007
1009
|
if (pathList.length) {
|
|
1008
1010
|
pathList.forEach((subPath) => {
|
|
1009
1011
|
parentField = getFromSchema(
|
|
@@ -1019,7 +1021,7 @@
|
|
|
1019
1021
|
validator,
|
|
1020
1022
|
rootSchema,
|
|
1021
1023
|
parentField,
|
|
1022
|
-
|
|
1024
|
+
fieldNameKey,
|
|
1023
1025
|
ONE_OF_KEY,
|
|
1024
1026
|
get16(formData, subPath),
|
|
1025
1027
|
experimental_customMergeAllOf
|
|
@@ -1029,7 +1031,7 @@
|
|
|
1029
1031
|
validator,
|
|
1030
1032
|
rootSchema,
|
|
1031
1033
|
parentField,
|
|
1032
|
-
|
|
1034
|
+
fieldNameKey,
|
|
1033
1035
|
ANY_OF_KEY,
|
|
1034
1036
|
get16(formData, subPath),
|
|
1035
1037
|
experimental_customMergeAllOf
|
|
@@ -1042,7 +1044,7 @@
|
|
|
1042
1044
|
validator,
|
|
1043
1045
|
rootSchema,
|
|
1044
1046
|
parentField,
|
|
1045
|
-
|
|
1047
|
+
fieldNameKey,
|
|
1046
1048
|
ONE_OF_KEY,
|
|
1047
1049
|
formData,
|
|
1048
1050
|
experimental_customMergeAllOf
|
|
@@ -1052,7 +1054,7 @@
|
|
|
1052
1054
|
validator,
|
|
1053
1055
|
rootSchema,
|
|
1054
1056
|
parentField,
|
|
1055
|
-
|
|
1057
|
+
fieldNameKey,
|
|
1056
1058
|
ANY_OF_KEY,
|
|
1057
1059
|
formData,
|
|
1058
1060
|
experimental_customMergeAllOf
|
|
@@ -1079,7 +1081,7 @@
|
|
|
1079
1081
|
);
|
|
1080
1082
|
let isRequired;
|
|
1081
1083
|
if (field && Array.isArray(requiredArray)) {
|
|
1082
|
-
isRequired = requiredArray.includes(
|
|
1084
|
+
isRequired = requiredArray.includes(fieldNameKey);
|
|
1083
1085
|
}
|
|
1084
1086
|
return { field, isRequired };
|
|
1085
1087
|
}
|
|
@@ -1232,7 +1234,7 @@
|
|
|
1232
1234
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1233
1235
|
const keyExistsInFormData = key in formData;
|
|
1234
1236
|
const keyDefault = get16(defaults, key) ?? {};
|
|
1235
|
-
const defaultValueIsNestedObject = keyExistsInDefaults && Object.
|
|
1237
|
+
const defaultValueIsNestedObject = keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
|
|
1236
1238
|
const keyDefaultIsObject = keyExistsInDefaults && isObject(get16(defaults, key));
|
|
1237
1239
|
const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
|
|
1238
1240
|
if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
|
|
@@ -1600,7 +1602,7 @@
|
|
|
1600
1602
|
let validFormData = formData;
|
|
1601
1603
|
if (isSelectField) {
|
|
1602
1604
|
const getOptionsList = optionsList(schema);
|
|
1603
|
-
const isValid = getOptionsList?.some((option) =>
|
|
1605
|
+
const isValid = getOptionsList?.some((option) => deepEquals_default(option.value, formData));
|
|
1604
1606
|
validFormData = isValid ? formData : void 0;
|
|
1605
1607
|
}
|
|
1606
1608
|
const constTakesPrecedence = schema[CONST_KEY] && experimental_defaultFormStateBehavior?.constAsDefaults === "always";
|
|
@@ -1661,14 +1663,14 @@
|
|
|
1661
1663
|
if (retrievedSchema.additionalProperties && !initialDefaultsGenerated) {
|
|
1662
1664
|
const additionalPropertiesSchema = isObject(retrievedSchema.additionalProperties) ? retrievedSchema.additionalProperties : {};
|
|
1663
1665
|
const keys2 = /* @__PURE__ */ new Set();
|
|
1664
|
-
if (isObject(defaults)) {
|
|
1665
|
-
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys2.add(key));
|
|
1666
|
-
}
|
|
1667
1666
|
const formDataRequired = [];
|
|
1668
1667
|
Object.keys(formData).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => {
|
|
1669
1668
|
keys2.add(key);
|
|
1670
1669
|
formDataRequired.push(key);
|
|
1671
1670
|
});
|
|
1671
|
+
if (isObject(defaults) && formDataRequired.length === 0) {
|
|
1672
|
+
Object.keys(defaults).filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key]).forEach((key) => keys2.add(key));
|
|
1673
|
+
}
|
|
1672
1674
|
keys2.forEach((key) => {
|
|
1673
1675
|
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|
|
1674
1676
|
rootSchema,
|
|
@@ -1889,7 +1891,7 @@
|
|
|
1889
1891
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1890
1892
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema || IF_KEY in schema) {
|
|
1891
1893
|
const _schema = retrieveSchema(validator, schema, rootSchema, formData, experimental_customMergeAllOf);
|
|
1892
|
-
const sameSchemaIndex = _recurseList.findIndex((item) =>
|
|
1894
|
+
const sameSchemaIndex = _recurseList.findIndex((item) => deepEquals_default(item, _schema));
|
|
1893
1895
|
if (sameSchemaIndex === -1) {
|
|
1894
1896
|
return toPathSchemaInternal(
|
|
1895
1897
|
validator,
|
|
@@ -2234,7 +2236,7 @@
|
|
|
2234
2236
|
if (!validator || !rootSchema) {
|
|
2235
2237
|
return false;
|
|
2236
2238
|
}
|
|
2237
|
-
return this.validator !== validator || !
|
|
2239
|
+
return this.validator !== validator || !deepEquals_default(this.rootSchema, rootSchema) || !deepEquals_default(this.experimental_defaultFormStateBehavior, experimental_defaultFormStateBehavior) || this.experimental_customMergeAllOf !== experimental_customMergeAllOf;
|
|
2238
2240
|
}
|
|
2239
2241
|
/** Finds the field specified by the `path` within the root or recursed `schema`. If there is no field for the specified
|
|
2240
2242
|
* `path`, then the default `{ field: undefined, isRequired: undefined }` is returned. It determines whether a leaf
|
|
@@ -2576,9 +2578,9 @@
|
|
|
2576
2578
|
// src/enumOptionsIsSelected.ts
|
|
2577
2579
|
function enumOptionsIsSelected(value, selected) {
|
|
2578
2580
|
if (Array.isArray(selected)) {
|
|
2579
|
-
return selected.some((sel) =>
|
|
2581
|
+
return selected.some((sel) => deepEquals_default(sel, value));
|
|
2580
2582
|
}
|
|
2581
|
-
return
|
|
2583
|
+
return deepEquals_default(selected, value);
|
|
2582
2584
|
}
|
|
2583
2585
|
|
|
2584
2586
|
// src/enumOptionsIndexForValue.ts
|
|
@@ -2654,9 +2656,9 @@
|
|
|
2654
2656
|
function enumOptionsDeselectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2655
2657
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
2656
2658
|
if (Array.isArray(selected)) {
|
|
2657
|
-
return selected.filter((v) => !
|
|
2659
|
+
return selected.filter((v) => !deepEquals_default(v, value));
|
|
2658
2660
|
}
|
|
2659
|
-
return
|
|
2661
|
+
return deepEquals_default(value, selected) ? void 0 : selected;
|
|
2660
2662
|
}
|
|
2661
2663
|
function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
2662
2664
|
const value = enumOptionsValueForIndex(valueIndex, allEnumOptions);
|
|
@@ -2770,7 +2772,7 @@
|
|
|
2770
2772
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
2771
2773
|
return keys(b);
|
|
2772
2774
|
} else {
|
|
2773
|
-
const unequalFields = keys(pickBy(a, (value, key) => !
|
|
2775
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals_default(value, get16(b, key))));
|
|
2774
2776
|
const diffFields = difference(keys(b), keys(a));
|
|
2775
2777
|
return [...unequalFields, ...diffFields];
|
|
2776
2778
|
}
|
|
@@ -3071,12 +3073,12 @@
|
|
|
3071
3073
|
}
|
|
3072
3074
|
function isRootSchema(registry, schemaToCompare) {
|
|
3073
3075
|
const { rootSchema, schemaUtils } = registry;
|
|
3074
|
-
if (
|
|
3076
|
+
if (deepEquals_default(schemaToCompare, rootSchema)) {
|
|
3075
3077
|
return true;
|
|
3076
3078
|
}
|
|
3077
3079
|
if (REF_KEY in rootSchema) {
|
|
3078
3080
|
const resolvedSchema = schemaUtils.retrieveSchema(rootSchema);
|
|
3079
|
-
return
|
|
3081
|
+
return deepEquals_default(schemaToCompare, omit(resolvedSchema, RJSF_REF_KEY));
|
|
3080
3082
|
}
|
|
3081
3083
|
return false;
|
|
3082
3084
|
}
|
|
@@ -3303,7 +3305,7 @@
|
|
|
3303
3305
|
return !shallowEquals(props2, nextProps) || !shallowEquals(state2, nextState);
|
|
3304
3306
|
}
|
|
3305
3307
|
const { props, state } = component;
|
|
3306
|
-
return !
|
|
3308
|
+
return !deepEquals_default(props, nextProps) || !deepEquals_default(state, nextState);
|
|
3307
3309
|
}
|
|
3308
3310
|
function getSchemaTypesForXxxOf(schemas) {
|
|
3309
3311
|
const allTypes = uniq(
|
|
@@ -3501,7 +3503,7 @@
|
|
|
3501
3503
|
}
|
|
3502
3504
|
function useDeepCompareMemo(newValue) {
|
|
3503
3505
|
const valueRef = react.useRef(newValue);
|
|
3504
|
-
if (!
|
|
3506
|
+
if (!deepEquals_default(newValue, valueRef.current)) {
|
|
3505
3507
|
valueRef.current = newValue;
|
|
3506
3508
|
}
|
|
3507
3509
|
return valueRef.current;
|
|
@@ -3708,6 +3710,7 @@
|
|
|
3708
3710
|
TranslatableString2["OptionPrefix"] = "Option %1";
|
|
3709
3711
|
TranslatableString2["TitleOptionPrefix"] = "%1 option %2";
|
|
3710
3712
|
TranslatableString2["KeyLabel"] = "%1 Key";
|
|
3713
|
+
TranslatableString2["DeprecatedLabel"] = "%1 (deprecated)";
|
|
3711
3714
|
TranslatableString2["InvalidObjectField"] = 'Invalid "%1" object field configuration: _%2_.';
|
|
3712
3715
|
TranslatableString2["UnsupportedField"] = "Unsupported field schema.";
|
|
3713
3716
|
TranslatableString2["UnsupportedFieldWithId"] = "Unsupported field schema for field `%1`.";
|
|
@@ -3746,7 +3749,7 @@
|
|
|
3746
3749
|
const existing = this.schemaMap[key];
|
|
3747
3750
|
if (!existing) {
|
|
3748
3751
|
this.schemaMap[key] = identifiedSchema;
|
|
3749
|
-
} else if (!
|
|
3752
|
+
} else if (!deepEquals_default(existing, identifiedSchema)) {
|
|
3750
3753
|
console.error("existing schema:", JSON.stringify(existing, null, 2));
|
|
3751
3754
|
console.error("new schema:", JSON.stringify(identifiedSchema, null, 2));
|
|
3752
3755
|
throw new Error(
|
|
@@ -3768,7 +3771,7 @@
|
|
|
3768
3771
|
* @throws - Error when the given `rootSchema` differs from the root schema provided during construction
|
|
3769
3772
|
*/
|
|
3770
3773
|
isValid(schema, _formData, rootSchema) {
|
|
3771
|
-
if (!
|
|
3774
|
+
if (!deepEquals_default(rootSchema, this.rootSchema)) {
|
|
3772
3775
|
throw new Error("Unexpectedly calling isValid() with a rootSchema that differs from the construction rootSchema");
|
|
3773
3776
|
}
|
|
3774
3777
|
this.addSchema(schema, hashForSchema(schema));
|
|
@@ -3808,7 +3811,7 @@
|
|
|
3808
3811
|
function parseSchema(validator, recurseList, rootSchema, schema) {
|
|
3809
3812
|
const schemas = retrieveSchemaInternal(validator, schema, rootSchema, void 0, true);
|
|
3810
3813
|
schemas.forEach((schema2) => {
|
|
3811
|
-
const sameSchemaIndex = recurseList.findIndex((item) =>
|
|
3814
|
+
const sameSchemaIndex = recurseList.findIndex((item) => deepEquals_default(item, schema2));
|
|
3812
3815
|
if (sameSchemaIndex === -1) {
|
|
3813
3816
|
recurseList.push(schema2);
|
|
3814
3817
|
const allOptions = resolveAnyOrOneOfSchemas(validator, schema2, rootSchema, true);
|
|
@@ -3883,7 +3886,7 @@
|
|
|
3883
3886
|
exports.createSchemaUtils = createSchemaUtils;
|
|
3884
3887
|
exports.dataURItoBlob = dataURItoBlob;
|
|
3885
3888
|
exports.dateRangeOptions = dateRangeOptions;
|
|
3886
|
-
exports.deepEquals =
|
|
3889
|
+
exports.deepEquals = deepEquals_default;
|
|
3887
3890
|
exports.descriptionId = descriptionId;
|
|
3888
3891
|
exports.dotNotationNameGenerator = dotNotationNameGenerator;
|
|
3889
3892
|
exports.englishStringTranslator = englishStringTranslator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"createSchemaUtils.js","sourceRoot":"","sources":["../src/createSchemaUtils.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAetC,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,WAAW;IAUf;;;;;;OAMG;IACH,YACE,SAAiC,EACjC,UAAa,EACb,qCAA4E,EAC5E,6BAAgE;QAEhE,IAAI,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,yBAAyB,EAAE,CAAC;YACvE,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QACxF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,qCAAqC,GAAG,qCAAqC,CAAC;QACnF,IAAI,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,OAAO,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6BAA6B,CAC9B,CAAC;AACJ,CAAC"}
|
package/lib/deepEquals.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/** Implements a deep equals using
|
|
2
|
-
*
|
|
1
|
+
/** Implements a deep equals using `fast-equals.createCustomEqual`. Functions
|
|
2
|
+
* are always considered equal, and circular references are tracked to avoid
|
|
3
|
+
* infinite recursion on self-referential inputs.
|
|
3
4
|
*
|
|
4
5
|
* @param a - The first element to compare
|
|
5
6
|
* @param b - The second element to compare
|
|
6
7
|
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
declare const deepEquals: <A, B>(a: A, b: B) => boolean;
|
|
10
|
+
export default deepEquals;
|
package/lib/deepEquals.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
/** Implements a deep equals using
|
|
3
|
-
*
|
|
1
|
+
import { createCustomEqual } from 'fast-equals';
|
|
2
|
+
/** Implements a deep equals using `fast-equals.createCustomEqual`. Functions
|
|
3
|
+
* are always considered equal, and circular references are tracked to avoid
|
|
4
|
+
* infinite recursion on self-referential inputs.
|
|
4
5
|
*
|
|
5
6
|
* @param a - The first element to compare
|
|
6
7
|
* @param b - The second element to compare
|
|
7
8
|
* @returns - True if the `a` and `b` are deeply equal, false otherwise
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
10
|
+
const deepEquals = createCustomEqual({
|
|
11
|
+
circular: true,
|
|
12
|
+
createCustomConfig: () => ({
|
|
13
|
+
areFunctionsEqual(_a, b) {
|
|
14
|
+
return typeof b === 'function';
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
export default deepEquals;
|
|
19
19
|
//# 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,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,iBAAiB,CAAC;IACnC,QAAQ,EAAE,IAAI;IACd,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;QACzB,iBAAiB,CAAC,EAAE,EAAE,CAAC;YACrB,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;QACjC,CAAC;KACF,CAAC;CACH,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
package/lib/enums.d.ts
CHANGED
|
@@ -67,6 +67,8 @@ export declare enum TranslatableString {
|
|
|
67
67
|
TitleOptionPrefix = "%1 option %2",
|
|
68
68
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
69
69
|
KeyLabel = "%1 Key",
|
|
70
|
+
/** Deprecated label, where %1 will be replaced by the label as provided by SchemaField */
|
|
71
|
+
DeprecatedLabel = "%1 (deprecated)",
|
|
70
72
|
/** Invalid object field configuration as provided by the ObjectField.
|
|
71
73
|
* NOTE: Use markdown notation rather than html tags.
|
|
72
74
|
*/
|
package/lib/enums.js
CHANGED
|
@@ -69,6 +69,8 @@ export var TranslatableString;
|
|
|
69
69
|
TranslatableString["TitleOptionPrefix"] = "%1 option %2";
|
|
70
70
|
/** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
|
|
71
71
|
TranslatableString["KeyLabel"] = "%1 Key";
|
|
72
|
+
/** Deprecated label, where %1 will be replaced by the label as provided by SchemaField */
|
|
73
|
+
TranslatableString["DeprecatedLabel"] = "%1 (deprecated)";
|
|
72
74
|
// Strings with replaceable parameters AND/OR that support markdown and html
|
|
73
75
|
/** Invalid object field configuration as provided by the ObjectField.
|
|
74
76
|
* NOTE: Use markdown notation rather than html tags.
|
package/lib/enums.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,kBA0FX;AA1FD,WAAY,kBAAkB;IAC5B,0DAA0D;IAC1D,6CAAuB,CAAA;IACvB,+CAA+C;IAC/C,+DAAyC,CAAA;IACzC,8CAA8C;IAC9C,oFAA8D,CAAA;IAC9D,sCAAsC;IACtC,sCAAgB,CAAA;IAChB,qCAAqC;IACrC,oCAAc,CAAA;IACd,qCAAqC;IACrC,0CAAoB,CAAA;IACpB,sCAAsC;IACtC,4CAAsB,CAAA;IACtB,yEAAyE;IACzE,oDAA8B,CAAA;IAC9B,0CAA0C;IAC1C,uCAAiB,CAAA;IACjB,0CAA0C;IAC1C,gDAA0B,CAAA;IAC1B,4CAA4C;IAC5C,yCAAmB,CAAA;IACnB,iDAAiD;IACjD,kDAA4B,CAAA;IAC5B,+CAA+C;IAC/C,8CAAwB,CAAA;IACxB,8CAA8C;IAC9C,6CAAuB,CAAA;IACvB,uCAAuC;IACvC,sCAAgB,CAAA;IAChB,yCAAyC;IACzC,0CAAoB,CAAA;IACpB,0CAA0C;IAC1C,qDAA+B,CAAA;IAC/B,6CAA6C;IAC7C,8CAAwB,CAAA;IACxB,wDAAwD;IACxD,gEAA0C,CAAA;IAC1C,wDAAwD;IACxD,gEAA0C,CAAA;IAC1C,mEAAmE;IACnE,uEAAiD,CAAA;IACjD,sEAAsE;IACtE,6EAAuD,CAAA;IACvD,yFAAyF;IACzF,2EAAqD,CAAA;IACrD,gEAAgE;IAChE,mCAAa,CAAA;IACb,yDAAyD;IACzD,qCAAe,CAAA;IACf,6CAA6C;IAC7C,iDAA2B,CAAA;IAC3B,sCAAsC;IACtC,oGAAoG;IACpG,gEAA0C,CAAA;IAC1C,qGAAqG;IACrG,gDAA0B,CAAA;IAC1B;;OAEG;IACH,wDAAkC,CAAA;IAClC,gGAAgG;IAChG,yCAAmB,CAAA;IACnB,0FAA0F;IAC1F,yDAAmC,CAAA;IACnC,4EAA4E;IAC5E;;OAEG;IACH,6FAAqE,CAAA;IACrE,yDAAyD;IACzD,oEAA8C,CAAA;IAC9C;;OAEG;IACH,yFAAmE,CAAA;IACnE;;OAEG;IACH,oFAA8D,CAAA;IAC9D;;;OAGG;IACH,wGAAkF,CAAA;IAClF;;OAEG;IACH,yDAAmC,CAAA;AACrC,CAAC,EA1FW,kBAAkB,KAAlB,kBAAkB,QA0F7B"}
|
package/lib/isRootSchema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import isEqual from 'lodash-es/isEqual.js';
|
|
2
1
|
import omit from 'lodash-es/omit.js';
|
|
2
|
+
import deepEquals from './deepEquals.js';
|
|
3
3
|
import { REF_KEY, RJSF_REF_KEY } from './constants.js';
|
|
4
4
|
/** Helper to check whether a JSON schema object is the root schema. The schema is a root schema with root `properties`
|
|
5
5
|
* key or a root `$ref` key. If the `schemaToCompare` has a root `oneOf` property, the function will
|
|
@@ -14,12 +14,12 @@ import { REF_KEY, RJSF_REF_KEY } from './constants.js';
|
|
|
14
14
|
*/
|
|
15
15
|
export default function isRootSchema(registry, schemaToCompare) {
|
|
16
16
|
const { rootSchema, schemaUtils } = registry;
|
|
17
|
-
if (
|
|
17
|
+
if (deepEquals(schemaToCompare, rootSchema)) {
|
|
18
18
|
return true;
|
|
19
19
|
}
|
|
20
20
|
if (REF_KEY in rootSchema) {
|
|
21
21
|
const resolvedSchema = schemaUtils.retrieveSchema(rootSchema);
|
|
22
|
-
return
|
|
22
|
+
return deepEquals(schemaToCompare, omit(resolvedSchema, RJSF_REF_KEY));
|
|
23
23
|
}
|
|
24
24
|
return false;
|
|
25
25
|
}
|
package/lib/isRootSchema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isRootSchema.js","sourceRoot":"","sources":["../src/isRootSchema.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"isRootSchema.js","sourceRoot":"","sources":["../src/isRootSchema.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,QAA2B,EAC3B,eAAkB;IAElB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC;IAC7C,IAAI,UAAU,CAAC,eAAe,EAAE,UAAU,CAAC,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC9D,OAAO,UAAU,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
/**
|
|
3
|
+
* This file is used to augment the `json-schema` module with the `deprecated` keyword.
|
|
4
|
+
*
|
|
5
|
+
* It is a dedicated file because `json-schema` is a type-only package. Standard augmentation
|
|
6
|
+
* using `import 'json-schema'` in a file with other imports can cause module resolution
|
|
7
|
+
* errors in certain environments (like Jest). Using `import type` in this dedicated file
|
|
8
|
+
* ensures the augmentation is correctly applied by the TypeScript compiler without
|
|
9
|
+
* confusing runtime module resolvers.
|
|
10
|
+
*/
|
|
11
|
+
declare module 'json-schema' {
|
|
12
|
+
interface JSONSchema7 {
|
|
13
|
+
/** The deprecated keyword is a boolean that indicates that the instance value the keyword applies to should not be
|
|
14
|
+
* used and may be removed in the future.
|
|
15
|
+
*/
|
|
16
|
+
deprecated?: boolean;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export type { JSONSchema7 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonSchemaAugmentation.js","sourceRoot":"","sources":["../src/jsonSchemaAugmentation.ts"],"names":[],"mappings":""}
|
|
@@ -51,7 +51,7 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
51
51
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
52
52
|
const keyExistsInFormData = key in formData;
|
|
53
53
|
const keyDefault = (_a = get(defaults, key)) !== null && _a !== void 0 ? _a : {};
|
|
54
|
-
const defaultValueIsNestedObject = keyExistsInDefaults && Object.
|
|
54
|
+
const defaultValueIsNestedObject = keyExistsInDefaults && isObject(keyDefault) && Object.values(keyDefault).some((v) => isObject(v));
|
|
55
55
|
const keyDefaultIsObject = keyExistsInDefaults && isObject(get(defaults, key));
|
|
56
56
|
const keyHasFormDataObject = keyExistsInFormData && isObject(keyValue);
|
|
57
57
|
if (keyDefaultIsObject && keyHasFormDataObject && !defaultValueIsNestedObject) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeDefaultsWithFormData.js","sourceRoot":"","sources":["../src/mergeDefaultsWithFormData.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAC/C,QAAY,EACZ,QAAY,EACZ,uBAAu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
import { Experimental_CustomMergeAllOf, FormContextType, FoundFieldType, RJSFSchema, StrictRJSFSchema, ValidatorType } from '../types.js';
|
|
1
|
+
import { Experimental_CustomMergeAllOf, FormContextType, FoundFieldType, RJSFSchema, SchemaFieldPath, StrictRJSFSchema, ValidatorType } from '../types.js';
|
|
2
2
|
/** Unique schema that represents no schema was found, exported for testing purposes */
|
|
3
3
|
export declare const NOT_FOUND_SCHEMA: {
|
|
4
4
|
title: string;
|
|
@@ -16,4 +16,4 @@ export declare const NOT_FOUND_SCHEMA: {
|
|
|
16
16
|
* @returns - An object that contains the field and its required state. If no field can be found then
|
|
17
17
|
* `{ field: undefined, isRequired: undefined }` is returned.
|
|
18
18
|
*/
|
|
19
|
-
export default function findFieldInSchema<T = undefined, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path:
|
|
19
|
+
export default function findFieldInSchema<T = undefined, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(validator: ValidatorType<T, S, F>, rootSchema: S, schema: S, path: SchemaFieldPath, formData?: T, experimental_customMergeAllOf?: Experimental_CustomMergeAllOf<S>): FoundFieldType<S>;
|
|
@@ -23,27 +23,28 @@ export default function findFieldInSchema(validator, rootSchema, schema, path, f
|
|
|
23
23
|
let parentField = schema;
|
|
24
24
|
// store the desired field into a variable and removing it from the `pathList`
|
|
25
25
|
const fieldName = pathList.pop();
|
|
26
|
+
const fieldNameKey = String(fieldName);
|
|
26
27
|
if (pathList.length) {
|
|
27
28
|
// drilling into the schema for each sub-path and taking into account of the any/oneOfs
|
|
28
29
|
pathList.forEach((subPath) => {
|
|
29
30
|
parentField = getFromSchema(validator, rootSchema, parentField, [PROPERTIES_KEY, subPath], {}, experimental_customMergeAllOf);
|
|
30
31
|
if (has(parentField, ONE_OF_KEY)) {
|
|
31
32
|
// if this sub-path has a `oneOf` then use the formData to drill into the schema with the selected option
|
|
32
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField,
|
|
33
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ONE_OF_KEY, get(formData, subPath), experimental_customMergeAllOf);
|
|
33
34
|
}
|
|
34
35
|
else if (has(parentField, ANY_OF_KEY)) {
|
|
35
36
|
// if this sub-path has a `anyOf` then use the formData to drill into the schema with the selected option
|
|
36
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField,
|
|
37
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ANY_OF_KEY, get(formData, subPath), experimental_customMergeAllOf);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
if (has(parentField, ONE_OF_KEY)) {
|
|
41
42
|
// When oneOf is in the root schema, use the formData to drill into the schema with the selected option
|
|
42
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField,
|
|
43
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ONE_OF_KEY, formData, experimental_customMergeAllOf);
|
|
43
44
|
}
|
|
44
45
|
else if (has(parentField, ANY_OF_KEY)) {
|
|
45
46
|
// When anyOf is in the root schema, use the formData to drill into the schema with the selected option
|
|
46
|
-
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField,
|
|
47
|
+
parentField = findSelectedOptionInXxxOf(validator, rootSchema, parentField, fieldNameKey, ANY_OF_KEY, formData, experimental_customMergeAllOf);
|
|
47
48
|
}
|
|
48
49
|
// taking the most updated `parentField`, get our desired field
|
|
49
50
|
let field = getFromSchema(validator, rootSchema, parentField, [PROPERTIES_KEY, fieldName], NOT_FOUND_SCHEMA, experimental_customMergeAllOf);
|
|
@@ -54,7 +55,7 @@ export default function findFieldInSchema(validator, rootSchema, schema, path, f
|
|
|
54
55
|
const requiredArray = getFromSchema(validator, rootSchema, parentField, REQUIRED_KEY, [], experimental_customMergeAllOf);
|
|
55
56
|
let isRequired;
|
|
56
57
|
if (field && Array.isArray(requiredArray)) {
|
|
57
|
-
isRequired = requiredArray.includes(
|
|
58
|
+
isRequired = requiredArray.includes(fieldNameKey);
|
|
58
59
|
}
|
|
59
60
|
return { field, isRequired };
|
|
60
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findFieldInSchema.js","sourceRoot":"","sources":["../../src/schema/findFieldInSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AACpE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"findFieldInSchema.js","sourceRoot":"","sources":["../../src/schema/findFieldInSchema.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAC7B,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AACpE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAWpF,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAKvC,SAAiC,EACjC,UAAa,EACb,MAAS,EACT,IAAqB,EACrB,WAAc,EAAO,EACrB,6BAAgE;IAEhE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnE,IAAI,WAAW,G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U,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,6BAA6B,CAC7B,CAAC;IACL,CAAC;IAED,+DAA+D;IAC/D,IAAI,KAAK,GAAkB,aAAa,CACtC,SAAS,EACT,UAAU,EACV,WAAW,EACX,CAAC,cAAc,EAAE,SAAS,CAAC,EAC3B,gBAAqB,EACrB,6BAA6B,CAC9B,CAAC;IACF,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QAC/B,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;IACD,6EAA6E;IAC7E,MAAM,aAAa,GAAG,aAAa,CACjC,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,EAAO,EACP,6BAA6B,CAC9B,CAAC;IACF,IAAI,UAA+B,CAAC;IACpC,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QAC1C,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash-es/get.js';
|
|
2
|
-
import isEqual from 'lodash-es/isEqual.js';
|
|
3
2
|
import { CONST_KEY, DEFAULT_KEY, PROPERTIES_KEY } from '../constants.js';
|
|
3
|
+
import deepEquals from '../deepEquals.js';
|
|
4
4
|
import retrieveSchema from './retrieveSchema.js';
|
|
5
5
|
import getDiscriminatorFieldFromSchema from '../getDiscriminatorFieldFromSchema.js';
|
|
6
6
|
/** Finds the option inside the `schema['any/oneOf']` list which has the `properties[selectorField].default` or
|
|
@@ -25,7 +25,7 @@ export default function findSelectedOptionInXxxOf(validator, rootSchema, schema,
|
|
|
25
25
|
const data = get(formData, selectorField);
|
|
26
26
|
if (data !== undefined) {
|
|
27
27
|
return xxxOfs.find((xxx) => {
|
|
28
|
-
return
|
|
28
|
+
return deepEquals(get(xxx, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get(xxx, [PROPERTIES_KEY, selectorField, CONST_KEY])), data);
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findSelectedOptionInXxxOf.js","sourceRoot":"","sources":["../../src/schema/findSelectedOptionInXxxOf.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"findSelectedOptionInXxxOf.js","sourceRoot":"","sources":["../../src/schema/findSelectedOptionInXxxOf.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,UAAU,MAAM,eAAe,CAAC;AAEvC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,+BAA+B,MAAM,oCAAoC,CAAC;AAEjF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAK/C,SAAiC,EACjC,UAAa,EACb,MAAS,EACT,aAAqB,EACrB,GAAsB,EACtB,WAAc,EAAO,EACrB,6BAAgE;IAEhE,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC/B,MAAM,aAAa,GAAG,+BAA+B,CAAI,MAAM,CAAC,CAAC;QACjE,MAAM,aAAa,GAAG,aAAa,IAAI,aAAa,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACxC,cAAc,CAAU,SAAS,EAAE,KAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,6BAA6B,CAAC,CACpG,CAAC;QACF,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;QAC1C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;gBACzB,OAAO,UAAU,CACf,GAAG,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,EAC5G,IAAI,CACL,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -360,11 +360,6 @@ export function getObjectDefaults(validator, rawSchema, { rawFormData, rootSchem
|
|
|
360
360
|
? retrievedSchema.additionalProperties
|
|
361
361
|
: {};
|
|
362
362
|
const keys = new Set();
|
|
363
|
-
if (isObject(defaults)) {
|
|
364
|
-
Object.keys(defaults)
|
|
365
|
-
.filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])
|
|
366
|
-
.forEach((key) => keys.add(key));
|
|
367
|
-
}
|
|
368
363
|
const formDataRequired = [];
|
|
369
364
|
Object.keys(formData)
|
|
370
365
|
.filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])
|
|
@@ -372,6 +367,14 @@ export function getObjectDefaults(validator, rawSchema, { rawFormData, rootSchem
|
|
|
372
367
|
keys.add(key);
|
|
373
368
|
formDataRequired.push(key);
|
|
374
369
|
});
|
|
370
|
+
// Only seed keys from schema defaults when formData has no additionalProperties of its own.
|
|
371
|
+
// If the user already has data (e.g. after a key rename), injecting default keys would
|
|
372
|
+
// re-add stale entries that no longer exist in formData.
|
|
373
|
+
if (isObject(defaults) && formDataRequired.length === 0) {
|
|
374
|
+
Object.keys(defaults)
|
|
375
|
+
.filter((key) => !retrievedSchema.properties || !retrievedSchema.properties[key])
|
|
376
|
+
.forEach((key) => keys.add(key));
|
|
377
|
+
}
|
|
375
378
|
keys.forEach((key) => {
|
|
376
379
|
var _a;
|
|
377
380
|
const computedDefault = computeDefaults(validator, additionalPropertiesSchema, {
|