@rjsf/utils 6.0.0-beta.12 → 6.0.0-beta.13
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 +95 -21
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +95 -21
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +93 -22
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/createSchemaUtils.js +9 -1
- package/lib/createSchemaUtils.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +6 -0
- package/lib/findSchemaDefinition.js +44 -3
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/mergeDefaultsWithFormData.js +2 -2
- package/lib/mergeDefaultsWithFormData.js.map +1 -1
- package/lib/schema/getDefaultFormState.js +10 -2
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/retrieveSchema.js +2 -2
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/shallowEquals.d.ts +8 -0
- package/lib/shallowEquals.js +36 -0
- package/lib/shallowEquals.js.map +1 -0
- package/lib/shouldRender.d.ts +8 -2
- package/lib/shouldRender.js +17 -2
- package/lib/shouldRender.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -0
- package/src/createSchemaUtils.ts +8 -1
- package/src/findSchemaDefinition.ts +51 -3
- package/src/index.ts +4 -0
- package/src/mergeDefaultsWithFormData.ts +1 -1
- package/src/schema/getDefaultFormState.ts +12 -2
- package/src/schema/retrieveSchema.ts +2 -2
- package/src/shallowEquals.ts +41 -0
- package/src/shouldRender.ts +27 -2
- package/src/types.ts +2 -0
package/dist/utils.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/isPlainObject'), require('lodash/isEqualWith'), require('lodash/get'), require('lodash/has'), require('lodash/isEqual'), require('lodash/set'), require('lodash/times'), require('lodash/transform'), require('lodash/merge'), require('lodash/flattenDeep'), require('lodash/uniq'), require('json-schema-merge-allof'), require('jsonpointer'), require('lodash/omit'), require('lodash/isObject'), require('lodash/isEmpty'), require('fast-uri'), require('lodash/isString'), require('lodash/union'), require('lodash/isNumber'), require('lodash/reduce'), require('lodash/isNil'), require('lodash/cloneDeep'), require('lodash/setWith'), require('nanoid'), require('react'), require('react-is'), require('react/jsx-runtime'), require('lodash/toPath'), require('lodash/keys'), require('lodash/pickBy'), require('lodash/difference'), require('lodash/forEach')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'lodash/isPlainObject', 'lodash/isEqualWith', 'lodash/get', 'lodash/has', 'lodash/isEqual', 'lodash/set', 'lodash/times', 'lodash/transform', 'lodash/merge', 'lodash/flattenDeep', 'lodash/uniq', 'json-schema-merge-allof', 'jsonpointer', 'lodash/omit', 'lodash/isObject', 'lodash/isEmpty', 'fast-uri', 'lodash/isString', 'lodash/union', 'lodash/isNumber', 'lodash/reduce', 'lodash/isNil', 'lodash/cloneDeep', 'lodash/setWith', 'nanoid', 'react', 'react-is', 'react/jsx-runtime', 'lodash/toPath', 'lodash/keys', 'lodash/pickBy', 'lodash/difference', 'lodash/forEach'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.isEqualWith, global.get13, global.has5, global.isEqual, global.set, global.times, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.jsonpointer, global.omit, global.
|
|
5
|
-
})(this, (function (exports, isPlainObject4, isEqualWith, get13, has5, isEqual, set, times, transform, merge, flattenDeep, uniq, mergeAllOf, jsonpointer, omit,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/utils"] = {}, global.isPlainObject4, global.isEqualWith, global.get13, global.has5, global.isEqual, global.set, global.times, global.transform, global.merge, global.flattenDeep, global.uniq, global.mergeAllOf, global.jsonpointer, global.omit, global.isObject2, global.isEmpty4, global.UriResolver, global.isString, global.union, global.isNumber, global.reduce, global.isNil, global.cloneDeep, global.setWith, global.nanoid, global.react, global.ReactIs, global.jsxRuntime, global.toPath, global.keys, global.pickBy, global.difference, global.forEach));
|
|
5
|
+
})(this, (function (exports, isPlainObject4, isEqualWith, get13, has5, isEqual, set, times, transform, merge, flattenDeep, uniq, mergeAllOf, jsonpointer, omit, isObject2, isEmpty4, UriResolver, isString, union, isNumber, reduce, isNil, cloneDeep, setWith, nanoid, react, ReactIs, jsxRuntime, toPath, keys, pickBy, difference, forEach) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// src/isObject.ts
|
|
8
8
|
function isObject(thing) {
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
var UI_WIDGET_KEY = "ui:widget";
|
|
82
82
|
var UI_OPTIONS_KEY = "ui:options";
|
|
83
83
|
var UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
|
|
84
|
+
var JSON_SCHEMA_DRAFT_2019_09 = "https://json-schema.org/draft/2019-09/schema";
|
|
84
85
|
var JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
85
86
|
|
|
86
87
|
// src/getUiOptions.ts
|
|
@@ -151,7 +152,16 @@
|
|
|
151
152
|
return schema;
|
|
152
153
|
}
|
|
153
154
|
for (const subSchema of Object.values(schema)) {
|
|
154
|
-
if (
|
|
155
|
+
if (Array.isArray(subSchema)) {
|
|
156
|
+
for (const item of subSchema) {
|
|
157
|
+
if (isObject2(item)) {
|
|
158
|
+
const result = findEmbeddedSchemaRecursive(item, ref);
|
|
159
|
+
if (result !== void 0) {
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
} else if (isObject2(subSchema)) {
|
|
155
165
|
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
156
166
|
if (result !== void 0) {
|
|
157
167
|
return result;
|
|
@@ -160,6 +170,23 @@
|
|
|
160
170
|
}
|
|
161
171
|
return void 0;
|
|
162
172
|
}
|
|
173
|
+
function makeAllReferencesAbsolute(schema, baseURI) {
|
|
174
|
+
const currentURI = get13(schema, ID_KEY, baseURI);
|
|
175
|
+
if (REF_KEY in schema) {
|
|
176
|
+
schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
|
|
177
|
+
}
|
|
178
|
+
for (const [key, subSchema] of Object.entries(schema)) {
|
|
179
|
+
if (Array.isArray(subSchema)) {
|
|
180
|
+
schema = {
|
|
181
|
+
...schema,
|
|
182
|
+
[key]: subSchema.map((item) => isObject2(item) ? makeAllReferencesAbsolute(item, currentURI) : item)
|
|
183
|
+
};
|
|
184
|
+
} else if (isObject2(subSchema)) {
|
|
185
|
+
schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return schema;
|
|
189
|
+
}
|
|
163
190
|
function splitKeyElementFromObject(key, object) {
|
|
164
191
|
const value = object[key];
|
|
165
192
|
const remaining = omit(object, [key]);
|
|
@@ -184,7 +211,7 @@
|
|
|
184
211
|
current = findEmbeddedSchemaRecursive(rootSchema, refId.replace(/\/$/, ""));
|
|
185
212
|
if (current !== void 0) {
|
|
186
213
|
baseURI = current[ID_KEY];
|
|
187
|
-
if (!
|
|
214
|
+
if (!isEmpty4(refAnchor)) {
|
|
188
215
|
current = jsonpointer.get(current, decodeURIComponent(refAnchor.join("#")));
|
|
189
216
|
}
|
|
190
217
|
}
|
|
@@ -205,7 +232,11 @@
|
|
|
205
232
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
206
233
|
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
207
234
|
if (Object.keys(remaining).length > 0) {
|
|
208
|
-
|
|
235
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 || rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
236
|
+
return { [ALL_OF_KEY]: [remaining, subSchema] };
|
|
237
|
+
} else {
|
|
238
|
+
return { ...remaining, ...subSchema };
|
|
239
|
+
}
|
|
209
240
|
}
|
|
210
241
|
return subSchema;
|
|
211
242
|
}
|
|
@@ -571,10 +602,10 @@
|
|
|
571
602
|
}
|
|
572
603
|
if (PATTERN_PROPERTIES_KEY in schema) {
|
|
573
604
|
const matchingProperties = getMatchingPatternProperties(schema, key);
|
|
574
|
-
if (!
|
|
605
|
+
if (!isEmpty4(matchingProperties)) {
|
|
575
606
|
schema.properties[key] = retrieveSchema(
|
|
576
607
|
validator,
|
|
577
|
-
{
|
|
608
|
+
{ [ALL_OF_KEY]: Object.values(matchingProperties) },
|
|
578
609
|
rootSchema,
|
|
579
610
|
get13(formData, [key]),
|
|
580
611
|
experimental_customMergeAllOf
|
|
@@ -589,7 +620,7 @@
|
|
|
589
620
|
if (REF_KEY in schema.additionalProperties) {
|
|
590
621
|
additionalProperties = retrieveSchema(
|
|
591
622
|
validator,
|
|
592
|
-
{
|
|
623
|
+
{ [REF_KEY]: get13(schema.additionalProperties, [REF_KEY]) },
|
|
593
624
|
rootSchema,
|
|
594
625
|
formData,
|
|
595
626
|
experimental_customMergeAllOf
|
|
@@ -679,7 +710,7 @@
|
|
|
679
710
|
resolvedSchema = Object.keys(resolvedSchema.properties).reduce(
|
|
680
711
|
(schema2, key) => {
|
|
681
712
|
const matchingProperties = getMatchingPatternProperties(schema2, key);
|
|
682
|
-
if (!
|
|
713
|
+
if (!isEmpty4(matchingProperties)) {
|
|
683
714
|
schema2.properties[key] = retrieveSchema(
|
|
684
715
|
validator,
|
|
685
716
|
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
@@ -904,7 +935,7 @@
|
|
|
904
935
|
if (has5(schema, REF_KEY)) {
|
|
905
936
|
fieldSchema = retrieveSchema(validator, schema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
906
937
|
}
|
|
907
|
-
if (
|
|
938
|
+
if (isEmpty4(path)) {
|
|
908
939
|
return fieldSchema;
|
|
909
940
|
}
|
|
910
941
|
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
@@ -1026,7 +1057,7 @@
|
|
|
1026
1057
|
function calculateIndexScore(validator, rootSchema, schema, formData, experimental_customMergeAllOf) {
|
|
1027
1058
|
let totalScore = 0;
|
|
1028
1059
|
if (schema) {
|
|
1029
|
-
if (
|
|
1060
|
+
if (isObject2(schema.properties)) {
|
|
1030
1061
|
totalScore += reduce(
|
|
1031
1062
|
schema.properties,
|
|
1032
1063
|
(score, value, key) => {
|
|
@@ -1064,7 +1095,7 @@
|
|
|
1064
1095
|
);
|
|
1065
1096
|
}
|
|
1066
1097
|
if (value.type === "object") {
|
|
1067
|
-
if (
|
|
1098
|
+
if (isObject2(formValue)) {
|
|
1068
1099
|
score += 1;
|
|
1069
1100
|
}
|
|
1070
1101
|
return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
|
|
@@ -1174,7 +1205,7 @@
|
|
|
1174
1205
|
return acc2;
|
|
1175
1206
|
}
|
|
1176
1207
|
acc2[key] = mergeDefaultsWithFormData(
|
|
1177
|
-
get13(defaults, key)
|
|
1208
|
+
get13(defaults, key),
|
|
1178
1209
|
keyValue,
|
|
1179
1210
|
mergeExtraArrayDefaults,
|
|
1180
1211
|
defaultSupercedesUndefined,
|
|
@@ -1328,16 +1359,20 @@
|
|
|
1328
1359
|
}
|
|
1329
1360
|
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
1330
1361
|
const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
|
|
1331
|
-
if (includeUndefinedValues || isConst) {
|
|
1362
|
+
if (includeUndefinedValues === true || isConst) {
|
|
1332
1363
|
obj[key] = computedDefault;
|
|
1364
|
+
} else if (includeUndefinedValues === "excludeObjectChildren") {
|
|
1365
|
+
if (!isObject(computedDefault) || !isEmpty4(computedDefault)) {
|
|
1366
|
+
obj[key] = computedDefault;
|
|
1367
|
+
}
|
|
1333
1368
|
} else if (emptyObjectFields !== "skipDefaults") {
|
|
1334
1369
|
const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
|
|
1335
1370
|
if (isObject(computedDefault)) {
|
|
1336
1371
|
if (emptyObjectFields === "skipEmptyDefaults") {
|
|
1337
|
-
if (!
|
|
1372
|
+
if (!isEmpty4(computedDefault)) {
|
|
1338
1373
|
obj[key] = computedDefault;
|
|
1339
1374
|
}
|
|
1340
|
-
} else if ((!
|
|
1375
|
+
} else if ((!isEmpty4(computedDefault) || requiredFields.includes(key)) && (isSelfOrParentRequired || emptyObjectFields !== "populateRequiredDefaults")) {
|
|
1341
1376
|
obj[key] = computedDefault;
|
|
1342
1377
|
}
|
|
1343
1378
|
} else if (
|
|
@@ -2075,8 +2110,6 @@
|
|
|
2075
2110
|
function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
|
|
2076
2111
|
return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
|
|
2077
2112
|
}
|
|
2078
|
-
|
|
2079
|
-
// src/createSchemaUtils.ts
|
|
2080
2113
|
var SchemaUtils = class {
|
|
2081
2114
|
/** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
|
|
2082
2115
|
*
|
|
@@ -2086,7 +2119,11 @@
|
|
|
2086
2119
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
2087
2120
|
*/
|
|
2088
2121
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
2089
|
-
|
|
2122
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
2123
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get13(rootSchema, ID_KEY, "#"));
|
|
2124
|
+
} else {
|
|
2125
|
+
this.rootSchema = rootSchema;
|
|
2126
|
+
}
|
|
2090
2127
|
this.validator = validator;
|
|
2091
2128
|
this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
|
|
2092
2129
|
this.experimental_customMergeAllOf = experimental_customMergeAllOf;
|
|
@@ -2417,6 +2454,31 @@
|
|
|
2417
2454
|
return options;
|
|
2418
2455
|
}
|
|
2419
2456
|
|
|
2457
|
+
// src/shallowEquals.ts
|
|
2458
|
+
function shallowEquals(a, b) {
|
|
2459
|
+
if (Object.is(a, b)) {
|
|
2460
|
+
return true;
|
|
2461
|
+
}
|
|
2462
|
+
if (a == null || b == null) {
|
|
2463
|
+
return false;
|
|
2464
|
+
}
|
|
2465
|
+
if (typeof a !== "object" || typeof b !== "object") {
|
|
2466
|
+
return false;
|
|
2467
|
+
}
|
|
2468
|
+
const keysA = Object.keys(a);
|
|
2469
|
+
const keysB = Object.keys(b);
|
|
2470
|
+
if (keysA.length !== keysB.length) {
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
2474
|
+
const key = keysA[i];
|
|
2475
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {
|
|
2476
|
+
return false;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
return true;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2420
2482
|
// src/replaceStringParameters.ts
|
|
2421
2483
|
function replaceStringParameters(inputString, params) {
|
|
2422
2484
|
let output = inputString;
|
|
@@ -2945,7 +3007,14 @@
|
|
|
2945
3007
|
}
|
|
2946
3008
|
|
|
2947
3009
|
// src/shouldRender.ts
|
|
2948
|
-
function shouldRender(component, nextProps, nextState) {
|
|
3010
|
+
function shouldRender(component, nextProps, nextState, updateStrategy = "customDeep") {
|
|
3011
|
+
if (updateStrategy === "always") {
|
|
3012
|
+
return true;
|
|
3013
|
+
}
|
|
3014
|
+
if (updateStrategy === "shallow") {
|
|
3015
|
+
const { props: props2, state: state2 } = component;
|
|
3016
|
+
return !shallowEquals(props2, nextProps) || !shallowEquals(state2, nextState);
|
|
3017
|
+
}
|
|
2949
3018
|
const { props, state } = component;
|
|
2950
3019
|
return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
|
|
2951
3020
|
}
|
|
@@ -3039,7 +3108,7 @@
|
|
|
3039
3108
|
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
3040
3109
|
let errors = toErrorList(additionalErrorSchema);
|
|
3041
3110
|
let errorSchema = additionalErrorSchema;
|
|
3042
|
-
if (!
|
|
3111
|
+
if (!isEmpty4(oldErrorSchema)) {
|
|
3043
3112
|
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
|
|
3044
3113
|
errors = [...oldErrors].concat(errors);
|
|
3045
3114
|
}
|
|
@@ -3067,7 +3136,7 @@
|
|
|
3067
3136
|
if (Array.isArray(schemaNode)) {
|
|
3068
3137
|
return withIdRefPrefixArray([...schemaNode]);
|
|
3069
3138
|
}
|
|
3070
|
-
if (
|
|
3139
|
+
if (isObject2(schemaNode)) {
|
|
3071
3140
|
return withIdRefPrefixObject({ ...schemaNode });
|
|
3072
3141
|
}
|
|
3073
3142
|
return schemaNode;
|
|
@@ -3255,6 +3324,7 @@
|
|
|
3255
3324
|
exports.ID_KEY = ID_KEY;
|
|
3256
3325
|
exports.IF_KEY = IF_KEY;
|
|
3257
3326
|
exports.ITEMS_KEY = ITEMS_KEY;
|
|
3327
|
+
exports.JSON_SCHEMA_DRAFT_2019_09 = JSON_SCHEMA_DRAFT_2019_09;
|
|
3258
3328
|
exports.JSON_SCHEMA_DRAFT_2020_12 = JSON_SCHEMA_DRAFT_2020_12;
|
|
3259
3329
|
exports.JUNK_OPTION_ID = JUNK_OPTION_ID;
|
|
3260
3330
|
exports.LOOKUP_MAP_NAME = LOOKUP_MAP_NAME;
|
|
@@ -3342,6 +3412,7 @@
|
|
|
3342
3412
|
exports.sanitizeDataForNewSchema = sanitizeDataForNewSchema;
|
|
3343
3413
|
exports.schemaParser = schemaParser;
|
|
3344
3414
|
exports.schemaRequiresTrueValue = schemaRequiresTrueValue;
|
|
3415
|
+
exports.shallowEquals = shallowEquals;
|
|
3345
3416
|
exports.shouldRender = shouldRender;
|
|
3346
3417
|
exports.sortedJSONStringify = sortedJSONStringify;
|
|
3347
3418
|
exports.titleId = titleId;
|
package/lib/constants.d.ts
CHANGED
|
@@ -44,4 +44,5 @@ export declare const UI_OPTIONS_KEY = "ui:options";
|
|
|
44
44
|
export declare const UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
|
|
45
45
|
/** The JSON Schema version strings
|
|
46
46
|
*/
|
|
47
|
+
export declare const JSON_SCHEMA_DRAFT_2019_09 = "https://json-schema.org/draft/2019-09/schema";
|
|
47
48
|
export declare const JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
package/lib/constants.js
CHANGED
|
@@ -44,5 +44,6 @@ export const UI_OPTIONS_KEY = 'ui:options';
|
|
|
44
44
|
export const UI_GLOBAL_OPTIONS_KEY = 'ui:globalOptions';
|
|
45
45
|
/** The JSON Schema version strings
|
|
46
46
|
*/
|
|
47
|
+
export const JSON_SCHEMA_DRAFT_2019_09 = 'https://json-schema.org/draft/2019-09/schema';
|
|
47
48
|
export const JSON_SCHEMA_DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
|
|
48
49
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAA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Of, getDefaultFormState, getDisplayLabel, getClosestMatchingOption, getFirstMatchingOption, getFromSchema, isFilesArray, isMultiSelect, isSelect, retrieveSchema, sanitizeDataForNewSchema, toIdSchema, toPathSchema, } from './schema/index.js';
|
|
3
|
+
import { makeAllReferencesAbsolute } from './findSchemaDefinition.js';
|
|
4
|
+
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, SCHEMA_KEY } from './constants.js';
|
|
5
|
+
import get from 'lodash-es/get.js';
|
|
3
6
|
/** The `SchemaUtils` class provides a wrapper around the publicly exported APIs in the `utils/schema` directory such
|
|
4
7
|
* that one does not have to explicitly pass the `validator`, `rootSchema`, `experimental_defaultFormStateBehavior` or
|
|
5
8
|
* `experimental_customMergeAllOf` to each method. Since these generally do not change across a `Form`, this allows for
|
|
@@ -15,7 +18,12 @@ class SchemaUtils {
|
|
|
15
18
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
16
19
|
*/
|
|
17
20
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
18
|
-
|
|
21
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
22
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get(rootSchema, ID_KEY, '#'));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.rootSchema = rootSchema;
|
|
26
|
+
}
|
|
19
27
|
this.validator = validator;
|
|
20
28
|
this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
|
|
21
29
|
this.experimental_customMergeAllOf = experimental_customMergeAllOf;
|
|
@@ -1 +1 @@
|
|
|
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,cAAc,EACd,wBAAwB,EACxB,UAAU,EACV,YAAY,GACb,MAAM,UAAU,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,cAAc,EACd,wBAAwB,EACxB,UAAU,EACV,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;IAQf;;;;;;OAMG;IACH,YACE,SAAiC,EACjC,UAAa,EACb,qCAA4E,EAC5E,6BAAgE;QAEhE,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,yBAAyB,EAAE,CAAC;YACzD,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;IAC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AW,CACpB,SAAS,EACT,UAAU,EACV,qCAAqC,EACrC,6BAA6B,CAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { GenericObjectType, RJSFSchema, StrictRJSFSchema } from './types.js';
|
|
2
|
+
/** Parses a JSONSchema and makes all references absolute with respect to
|
|
3
|
+
* the `baseURI` argument
|
|
4
|
+
* @param schema - The schema to be processed
|
|
5
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
6
|
+
*/
|
|
7
|
+
export declare function makeAllReferencesAbsolute<S extends StrictRJSFSchema = RJSFSchema>(schema: S, baseURI: string): S;
|
|
2
8
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
3
9
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
4
10
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import jsonpointer from 'jsonpointer';
|
|
2
2
|
import omit from 'lodash-es/omit.js';
|
|
3
|
-
import { ID_KEY, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY } from './constants.js';
|
|
3
|
+
import { ALL_OF_KEY, ID_KEY, JSON_SCHEMA_DRAFT_2019_09, JSON_SCHEMA_DRAFT_2020_12, REF_KEY, SCHEMA_KEY, } from './constants.js';
|
|
4
4
|
import isObject from 'lodash-es/isObject.js';
|
|
5
5
|
import isEmpty from 'lodash-es/isEmpty.js';
|
|
6
6
|
import UriResolver from 'fast-uri';
|
|
@@ -17,7 +17,17 @@ function findEmbeddedSchemaRecursive(schema, ref) {
|
|
|
17
17
|
return schema;
|
|
18
18
|
}
|
|
19
19
|
for (const subSchema of Object.values(schema)) {
|
|
20
|
-
if (
|
|
20
|
+
if (Array.isArray(subSchema)) {
|
|
21
|
+
for (const item of subSchema) {
|
|
22
|
+
if (isObject(item)) {
|
|
23
|
+
const result = findEmbeddedSchemaRecursive(item, ref);
|
|
24
|
+
if (result !== undefined) {
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (isObject(subSchema)) {
|
|
21
31
|
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
22
32
|
if (result !== undefined) {
|
|
23
33
|
return result;
|
|
@@ -26,6 +36,31 @@ function findEmbeddedSchemaRecursive(schema, ref) {
|
|
|
26
36
|
}
|
|
27
37
|
return undefined;
|
|
28
38
|
}
|
|
39
|
+
/** Parses a JSONSchema and makes all references absolute with respect to
|
|
40
|
+
* the `baseURI` argument
|
|
41
|
+
* @param schema - The schema to be processed
|
|
42
|
+
* @param baseURI - The base URI to be used for resolving relative references
|
|
43
|
+
*/
|
|
44
|
+
export function makeAllReferencesAbsolute(schema, baseURI) {
|
|
45
|
+
const currentURI = get(schema, ID_KEY, baseURI);
|
|
46
|
+
// Make all other references absolute
|
|
47
|
+
if (REF_KEY in schema) {
|
|
48
|
+
schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
|
|
49
|
+
}
|
|
50
|
+
// Look for references in nested subschemas
|
|
51
|
+
for (const [key, subSchema] of Object.entries(schema)) {
|
|
52
|
+
if (Array.isArray(subSchema)) {
|
|
53
|
+
schema = {
|
|
54
|
+
...schema,
|
|
55
|
+
[key]: subSchema.map((item) => (isObject(item) ? makeAllReferencesAbsolute(item, currentURI) : item)),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else if (isObject(subSchema)) {
|
|
59
|
+
schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return schema;
|
|
63
|
+
}
|
|
29
64
|
/** Splits out the value at the `key` in `object` from the `object`, returning an array that contains in the first
|
|
30
65
|
* location, the `object` minus the `key: value` and in the second location the `value`.
|
|
31
66
|
*
|
|
@@ -95,7 +130,13 @@ export function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList
|
|
|
95
130
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
96
131
|
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
97
132
|
if (Object.keys(remaining).length > 0) {
|
|
98
|
-
|
|
133
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 ||
|
|
134
|
+
rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
135
|
+
return { [ALL_OF_KEY]: [remaining, subSchema] };
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return { ...remaining, ...subSchema };
|
|
139
|
+
}
|
|
99
140
|
}
|
|
100
141
|
return subSchema;
|
|
101
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"findSchemaDefinition.js","sourceRoot":"","sources":["../src/findSchemaDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EACL,UAAU,EACV,MAAM,EACN,yBAAyB,EACzB,yBAAyB,EACzB,OAAO,EACP,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,WAAW,MAAM,UAAU,CAAC;AACnC,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B;;;;;;GAMG;AACH,SAAS,2BAA2B,CAA0C,MAAS,EAAE,GAAW;IAClG,IAAI,MAAM,IAAI,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAW,EAAE,GAAG,CAAC,EAAE,CAAC;QACz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,CAAC;YACxC,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,IAAa,EACb,aAAgB,EAAO,EACvB,UAA8B,GAAG,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,OAAO,6BAA6B,CAAC,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -60,4 +61,5 @@ export * from './enums.js';
|
|
|
60
61
|
export * from './constants.js';
|
|
61
62
|
export * from './parser/index.js';
|
|
62
63
|
export * from './schema/index.js';
|
|
63
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
64
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, DateElementFormat, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
65
|
+
export type { ComponentUpdateStrategy } from './shouldRender.js';
|
package/lib/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import createSchemaUtils from './createSchemaUtils.js';
|
|
|
6
6
|
import dataURItoBlob from './dataURItoBlob.js';
|
|
7
7
|
import dateRangeOptions from './dateRangeOptions.js';
|
|
8
8
|
import deepEquals from './deepEquals.js';
|
|
9
|
+
import shallowEquals from './shallowEquals.js';
|
|
9
10
|
import englishStringTranslator from './englishStringTranslator.js';
|
|
10
11
|
import enumOptionsDeselectValue from './enumOptionsDeselectValue.js';
|
|
11
12
|
import enumOptionsIndexForValue from './enumOptionsIndexForValue.js';
|
|
@@ -60,5 +61,5 @@ export * from './enums.js';
|
|
|
60
61
|
export * from './constants.js';
|
|
61
62
|
export * from './parser/index.js';
|
|
62
63
|
export * from './schema/index.js';
|
|
63
|
-
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
64
|
+
export { allowAdditionalItems, ariaDescribedByIds, asNumber, buttonId, canExpand, createErrorHandler, createSchemaUtils, dataURItoBlob, dateRangeOptions, deepEquals, descriptionId, englishStringTranslator, enumOptionsDeselectValue, enumOptionsIndexForValue, enumOptionsIsSelected, enumOptionsSelectValue, enumOptionsValueForIndex, errorId, examplesId, ErrorSchemaBuilder, findSchemaDefinition, getChangedFields, getDateElementProps, getDiscriminatorFieldFromSchema, getInputProps, getOptionMatchingSimpleDiscriminator, getSchemaType, getSubmitButtonOptions, getTemplate, getTestIds, getUiOptions, getWidget, guessType, hasWidget, hashForSchema, hashObject, hashString, helpId, isConstant, isCustomWidget, isFixedItems, isObject, labelValue, localToUTC, lookupFromFormContext, mergeDefaultsWithFormData, mergeObjects, mergeSchemas, optionId, optionsList, orderProperties, pad, parseDateString, rangeSpec, replaceStringParameters, schemaRequiresTrueValue, shallowEquals, shouldRender, sortedJSONStringify, titleId, toConstant, toDateString, toErrorList, toErrorSchema, unwrapErrorHandler, utcToLocal, validationDataMerge, withIdRefPrefix, };
|
|
64
65
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,mBAA+C,MAAM,uBAAuB,CAAC;AACpF,OAAO,+BAA+B,MAAM,mCAAmC,CAAC;AAChF,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,aA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AAC;AACxD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,oCAAoC,MAAM,wCAAwC,CAAC;AAC1F,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAElD,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AAExB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAEjB,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,aAAa,EACb,oCAAoC,EACpC,aAAa,EACb,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,MAAM,EACN,UAAU,EACV,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,UAAU,EACV,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,eAAe,EACf,GAAG,EACH,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,GAChB,CAAC"}
|
|
@@ -46,7 +46,7 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
46
46
|
if (isObject(formData)) {
|
|
47
47
|
const acc = Object.assign({}, defaults); // Prevent mutation of source object.
|
|
48
48
|
return Object.keys(formData).reduce((acc, key) => {
|
|
49
|
-
var _a
|
|
49
|
+
var _a;
|
|
50
50
|
const keyValue = get(formData, key);
|
|
51
51
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
52
52
|
const keyExistsInFormData = key in formData;
|
|
@@ -61,7 +61,7 @@ export default function mergeDefaultsWithFormData(defaults, formData, mergeExtra
|
|
|
61
61
|
};
|
|
62
62
|
return acc;
|
|
63
63
|
}
|
|
64
|
-
acc[key] = mergeDefaultsWithFormData(
|
|
64
|
+
acc[key] = mergeDefaultsWithFormData(get(defaults, key), keyValue, mergeExtraArrayDefaults, defaultSupercedesUndefined,
|
|
65
65
|
// overrideFormDataWithDefaults can be true only when the key value exists in defaults
|
|
66
66
|
// Or if the key value doesn't exist in formData
|
|
67
67
|
overrideFormDataWithDefaults && (keyExistsInDefaults || !keyExistsInFormData));
|
|
@@ -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,uBAAuB,GAAG,KAAK,EAC/B,0BAA0B,GAAG,KAAK,EAClC,4BAA4B,GAAG,KAAK;IAEpC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAE9D,8FAA8F;QAC9F,MAAM,aAAa,GAAG,4BAA4B,CAAC,CAAC,CAAC,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,IAAI,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC/F,CAAC,4BAA4B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAClD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -80,11 +80,19 @@ export function getInnerSchemaForArrayItem(schema, additionalItems = AdditionalI
|
|
|
80
80
|
*/
|
|
81
81
|
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
82
82
|
const { emptyObjectFields = 'populateAllDefaults' } = experimental_defaultFormStateBehavior;
|
|
83
|
-
if (includeUndefinedValues || isConst) {
|
|
84
|
-
// If includeUndefinedValues
|
|
83
|
+
if (includeUndefinedValues === true || isConst) {
|
|
84
|
+
// If includeUndefinedValues is explicitly true
|
|
85
85
|
// Or if the schema has a const property defined, then we should always return the computedDefault since it's coming from the const.
|
|
86
86
|
obj[key] = computedDefault;
|
|
87
87
|
}
|
|
88
|
+
else if (includeUndefinedValues === 'excludeObjectChildren') {
|
|
89
|
+
// Fix for Issue #4709: When in 'excludeObjectChildren' mode, don't set primitive fields to empty objects
|
|
90
|
+
// Only add the computed default if it's not an empty object placeholder for a primitive field
|
|
91
|
+
if (!isObject(computedDefault) || !isEmpty(computedDefault)) {
|
|
92
|
+
obj[key] = computedDefault;
|
|
93
|
+
}
|
|
94
|
+
// If computedDefault is an empty object {}, don't add it - let the field stay undefined
|
|
95
|
+
}
|
|
88
96
|
else if (emptyObjectFields !== 'skipDefaults') {
|
|
89
97
|
// If isParentRequired is undefined, then we are at the root level of the schema so defer to the requiredness of
|
|
90
98
|
// the field key itself in the `requiredField` list
|