@rjsf/utils 6.0.0-beta.12 → 6.0.0-beta.14
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 +100 -23
- package/dist/index.js.map +4 -4
- package/dist/utils.esm.js +100 -23
- package/dist/utils.esm.js.map +4 -4
- package/dist/utils.umd.js +98 -24
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/createSchemaUtils.js +11 -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/getUiOptions.js +4 -0
- package/lib/getUiOptions.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/getDisplayLabel.js +2 -2
- package/lib/schema/getDisplayLabel.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 +20 -3
- package/package.json +5 -5
- package/src/constants.ts +1 -0
- package/src/createSchemaUtils.ts +11 -1
- package/src/findSchemaDefinition.ts +51 -3
- package/src/getUiOptions.ts +4 -0
- package/src/index.ts +4 -0
- package/src/mergeDefaultsWithFormData.ts +1 -1
- package/src/schema/getDefaultFormState.ts +12 -2
- package/src/schema/getDisplayLabel.ts +2 -2
- package/src/schema/retrieveSchema.ts +2 -2
- package/src/shallowEquals.ts +41 -0
- package/src/shouldRender.ts +27 -2
- package/src/types.ts +23 -3
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,10 +81,14 @@
|
|
|
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
|
|
87
88
|
function getUiOptions(uiSchema = {}, globalOptions = {}) {
|
|
89
|
+
if (!uiSchema) {
|
|
90
|
+
return { ...globalOptions };
|
|
91
|
+
}
|
|
88
92
|
return Object.keys(uiSchema).filter((key) => key.indexOf("ui:") === 0).reduce(
|
|
89
93
|
(options, key) => {
|
|
90
94
|
const value = uiSchema[key];
|
|
@@ -151,7 +155,16 @@
|
|
|
151
155
|
return schema;
|
|
152
156
|
}
|
|
153
157
|
for (const subSchema of Object.values(schema)) {
|
|
154
|
-
if (
|
|
158
|
+
if (Array.isArray(subSchema)) {
|
|
159
|
+
for (const item of subSchema) {
|
|
160
|
+
if (isObject2(item)) {
|
|
161
|
+
const result = findEmbeddedSchemaRecursive(item, ref);
|
|
162
|
+
if (result !== void 0) {
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else if (isObject2(subSchema)) {
|
|
155
168
|
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
156
169
|
if (result !== void 0) {
|
|
157
170
|
return result;
|
|
@@ -160,6 +173,23 @@
|
|
|
160
173
|
}
|
|
161
174
|
return void 0;
|
|
162
175
|
}
|
|
176
|
+
function makeAllReferencesAbsolute(schema, baseURI) {
|
|
177
|
+
const currentURI = get13(schema, ID_KEY, baseURI);
|
|
178
|
+
if (REF_KEY in schema) {
|
|
179
|
+
schema = { ...schema, [REF_KEY]: UriResolver.resolve(currentURI, schema[REF_KEY]) };
|
|
180
|
+
}
|
|
181
|
+
for (const [key, subSchema] of Object.entries(schema)) {
|
|
182
|
+
if (Array.isArray(subSchema)) {
|
|
183
|
+
schema = {
|
|
184
|
+
...schema,
|
|
185
|
+
[key]: subSchema.map((item) => isObject2(item) ? makeAllReferencesAbsolute(item, currentURI) : item)
|
|
186
|
+
};
|
|
187
|
+
} else if (isObject2(subSchema)) {
|
|
188
|
+
schema = { ...schema, [key]: makeAllReferencesAbsolute(subSchema, currentURI) };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return schema;
|
|
192
|
+
}
|
|
163
193
|
function splitKeyElementFromObject(key, object) {
|
|
164
194
|
const value = object[key];
|
|
165
195
|
const remaining = omit(object, [key]);
|
|
@@ -184,7 +214,7 @@
|
|
|
184
214
|
current = findEmbeddedSchemaRecursive(rootSchema, refId.replace(/\/$/, ""));
|
|
185
215
|
if (current !== void 0) {
|
|
186
216
|
baseURI = current[ID_KEY];
|
|
187
|
-
if (!
|
|
217
|
+
if (!isEmpty4(refAnchor)) {
|
|
188
218
|
current = jsonpointer.get(current, decodeURIComponent(refAnchor.join("#")));
|
|
189
219
|
}
|
|
190
220
|
}
|
|
@@ -205,7 +235,11 @@
|
|
|
205
235
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
206
236
|
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
207
237
|
if (Object.keys(remaining).length > 0) {
|
|
208
|
-
|
|
238
|
+
if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2019_09 || rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
239
|
+
return { [ALL_OF_KEY]: [remaining, subSchema] };
|
|
240
|
+
} else {
|
|
241
|
+
return { ...remaining, ...subSchema };
|
|
242
|
+
}
|
|
209
243
|
}
|
|
210
244
|
return subSchema;
|
|
211
245
|
}
|
|
@@ -571,10 +605,10 @@
|
|
|
571
605
|
}
|
|
572
606
|
if (PATTERN_PROPERTIES_KEY in schema) {
|
|
573
607
|
const matchingProperties = getMatchingPatternProperties(schema, key);
|
|
574
|
-
if (!
|
|
608
|
+
if (!isEmpty4(matchingProperties)) {
|
|
575
609
|
schema.properties[key] = retrieveSchema(
|
|
576
610
|
validator,
|
|
577
|
-
{
|
|
611
|
+
{ [ALL_OF_KEY]: Object.values(matchingProperties) },
|
|
578
612
|
rootSchema,
|
|
579
613
|
get13(formData, [key]),
|
|
580
614
|
experimental_customMergeAllOf
|
|
@@ -589,7 +623,7 @@
|
|
|
589
623
|
if (REF_KEY in schema.additionalProperties) {
|
|
590
624
|
additionalProperties = retrieveSchema(
|
|
591
625
|
validator,
|
|
592
|
-
{
|
|
626
|
+
{ [REF_KEY]: get13(schema.additionalProperties, [REF_KEY]) },
|
|
593
627
|
rootSchema,
|
|
594
628
|
formData,
|
|
595
629
|
experimental_customMergeAllOf
|
|
@@ -679,7 +713,7 @@
|
|
|
679
713
|
resolvedSchema = Object.keys(resolvedSchema.properties).reduce(
|
|
680
714
|
(schema2, key) => {
|
|
681
715
|
const matchingProperties = getMatchingPatternProperties(schema2, key);
|
|
682
|
-
if (!
|
|
716
|
+
if (!isEmpty4(matchingProperties)) {
|
|
683
717
|
schema2.properties[key] = retrieveSchema(
|
|
684
718
|
validator,
|
|
685
719
|
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
@@ -904,7 +938,7 @@
|
|
|
904
938
|
if (has5(schema, REF_KEY)) {
|
|
905
939
|
fieldSchema = retrieveSchema(validator, schema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
906
940
|
}
|
|
907
|
-
if (
|
|
941
|
+
if (isEmpty4(path)) {
|
|
908
942
|
return fieldSchema;
|
|
909
943
|
}
|
|
910
944
|
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
@@ -1026,7 +1060,7 @@
|
|
|
1026
1060
|
function calculateIndexScore(validator, rootSchema, schema, formData, experimental_customMergeAllOf) {
|
|
1027
1061
|
let totalScore = 0;
|
|
1028
1062
|
if (schema) {
|
|
1029
|
-
if (
|
|
1063
|
+
if (isObject2(schema.properties)) {
|
|
1030
1064
|
totalScore += reduce(
|
|
1031
1065
|
schema.properties,
|
|
1032
1066
|
(score, value, key) => {
|
|
@@ -1064,7 +1098,7 @@
|
|
|
1064
1098
|
);
|
|
1065
1099
|
}
|
|
1066
1100
|
if (value.type === "object") {
|
|
1067
|
-
if (
|
|
1101
|
+
if (isObject2(formValue)) {
|
|
1068
1102
|
score += 1;
|
|
1069
1103
|
}
|
|
1070
1104
|
return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
|
|
@@ -1174,7 +1208,7 @@
|
|
|
1174
1208
|
return acc2;
|
|
1175
1209
|
}
|
|
1176
1210
|
acc2[key] = mergeDefaultsWithFormData(
|
|
1177
|
-
get13(defaults, key)
|
|
1211
|
+
get13(defaults, key),
|
|
1178
1212
|
keyValue,
|
|
1179
1213
|
mergeExtraArrayDefaults,
|
|
1180
1214
|
defaultSupercedesUndefined,
|
|
@@ -1328,16 +1362,20 @@
|
|
|
1328
1362
|
}
|
|
1329
1363
|
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
1330
1364
|
const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
|
|
1331
|
-
if (includeUndefinedValues || isConst) {
|
|
1365
|
+
if (includeUndefinedValues === true || isConst) {
|
|
1332
1366
|
obj[key] = computedDefault;
|
|
1367
|
+
} else if (includeUndefinedValues === "excludeObjectChildren") {
|
|
1368
|
+
if (!isObject(computedDefault) || !isEmpty4(computedDefault)) {
|
|
1369
|
+
obj[key] = computedDefault;
|
|
1370
|
+
}
|
|
1333
1371
|
} else if (emptyObjectFields !== "skipDefaults") {
|
|
1334
1372
|
const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
|
|
1335
1373
|
if (isObject(computedDefault)) {
|
|
1336
1374
|
if (emptyObjectFields === "skipEmptyDefaults") {
|
|
1337
|
-
if (!
|
|
1375
|
+
if (!isEmpty4(computedDefault)) {
|
|
1338
1376
|
obj[key] = computedDefault;
|
|
1339
1377
|
}
|
|
1340
|
-
} else if ((!
|
|
1378
|
+
} else if ((!isEmpty4(computedDefault) || requiredFields.includes(key)) && (isSelfOrParentRequired || emptyObjectFields !== "populateRequiredDefaults")) {
|
|
1341
1379
|
obj[key] = computedDefault;
|
|
1342
1380
|
}
|
|
1343
1381
|
} else if (
|
|
@@ -1759,10 +1797,10 @@
|
|
|
1759
1797
|
if (schemaType === "object") {
|
|
1760
1798
|
displayLabel = false;
|
|
1761
1799
|
}
|
|
1762
|
-
if (schemaType === "boolean" && !uiSchema[UI_WIDGET_KEY]) {
|
|
1800
|
+
if (schemaType === "boolean" && uiSchema && !uiSchema[UI_WIDGET_KEY]) {
|
|
1763
1801
|
displayLabel = false;
|
|
1764
1802
|
}
|
|
1765
|
-
if (uiSchema[UI_FIELD_KEY]) {
|
|
1803
|
+
if (uiSchema && uiSchema[UI_FIELD_KEY]) {
|
|
1766
1804
|
displayLabel = false;
|
|
1767
1805
|
}
|
|
1768
1806
|
return displayLabel;
|
|
@@ -2075,8 +2113,6 @@
|
|
|
2075
2113
|
function toPathSchema(validator, schema, name = "", rootSchema, formData, experimental_customMergeAllOf) {
|
|
2076
2114
|
return toPathSchemaInternal(validator, schema, name, rootSchema, formData, void 0, experimental_customMergeAllOf);
|
|
2077
2115
|
}
|
|
2078
|
-
|
|
2079
|
-
// src/createSchemaUtils.ts
|
|
2080
2116
|
var SchemaUtils = class {
|
|
2081
2117
|
/** Constructs the `SchemaUtils` instance with the given `validator` and `rootSchema` stored as instance variables
|
|
2082
2118
|
*
|
|
@@ -2086,7 +2122,11 @@
|
|
|
2086
2122
|
* @param [experimental_customMergeAllOf] - Optional function that allows for custom merging of `allOf` schemas
|
|
2087
2123
|
*/
|
|
2088
2124
|
constructor(validator, rootSchema, experimental_defaultFormStateBehavior, experimental_customMergeAllOf) {
|
|
2089
|
-
|
|
2125
|
+
if (rootSchema && rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
2126
|
+
this.rootSchema = makeAllReferencesAbsolute(rootSchema, get13(rootSchema, ID_KEY, "#"));
|
|
2127
|
+
} else {
|
|
2128
|
+
this.rootSchema = rootSchema;
|
|
2129
|
+
}
|
|
2090
2130
|
this.validator = validator;
|
|
2091
2131
|
this.experimental_defaultFormStateBehavior = experimental_defaultFormStateBehavior;
|
|
2092
2132
|
this.experimental_customMergeAllOf = experimental_customMergeAllOf;
|
|
@@ -2417,6 +2457,31 @@
|
|
|
2417
2457
|
return options;
|
|
2418
2458
|
}
|
|
2419
2459
|
|
|
2460
|
+
// src/shallowEquals.ts
|
|
2461
|
+
function shallowEquals(a, b) {
|
|
2462
|
+
if (Object.is(a, b)) {
|
|
2463
|
+
return true;
|
|
2464
|
+
}
|
|
2465
|
+
if (a == null || b == null) {
|
|
2466
|
+
return false;
|
|
2467
|
+
}
|
|
2468
|
+
if (typeof a !== "object" || typeof b !== "object") {
|
|
2469
|
+
return false;
|
|
2470
|
+
}
|
|
2471
|
+
const keysA = Object.keys(a);
|
|
2472
|
+
const keysB = Object.keys(b);
|
|
2473
|
+
if (keysA.length !== keysB.length) {
|
|
2474
|
+
return false;
|
|
2475
|
+
}
|
|
2476
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
2477
|
+
const key = keysA[i];
|
|
2478
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) || !Object.is(a[key], b[key])) {
|
|
2479
|
+
return false;
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
return true;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2420
2485
|
// src/replaceStringParameters.ts
|
|
2421
2486
|
function replaceStringParameters(inputString, params) {
|
|
2422
2487
|
let output = inputString;
|
|
@@ -2945,7 +3010,14 @@
|
|
|
2945
3010
|
}
|
|
2946
3011
|
|
|
2947
3012
|
// src/shouldRender.ts
|
|
2948
|
-
function shouldRender(component, nextProps, nextState) {
|
|
3013
|
+
function shouldRender(component, nextProps, nextState, updateStrategy = "customDeep") {
|
|
3014
|
+
if (updateStrategy === "always") {
|
|
3015
|
+
return true;
|
|
3016
|
+
}
|
|
3017
|
+
if (updateStrategy === "shallow") {
|
|
3018
|
+
const { props: props2, state: state2 } = component;
|
|
3019
|
+
return !shallowEquals(props2, nextProps) || !shallowEquals(state2, nextState);
|
|
3020
|
+
}
|
|
2949
3021
|
const { props, state } = component;
|
|
2950
3022
|
return !deepEquals(props, nextProps) || !deepEquals(state, nextState);
|
|
2951
3023
|
}
|
|
@@ -3039,7 +3111,7 @@
|
|
|
3039
3111
|
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
3040
3112
|
let errors = toErrorList(additionalErrorSchema);
|
|
3041
3113
|
let errorSchema = additionalErrorSchema;
|
|
3042
|
-
if (!
|
|
3114
|
+
if (!isEmpty4(oldErrorSchema)) {
|
|
3043
3115
|
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
|
|
3044
3116
|
errors = [...oldErrors].concat(errors);
|
|
3045
3117
|
}
|
|
@@ -3067,7 +3139,7 @@
|
|
|
3067
3139
|
if (Array.isArray(schemaNode)) {
|
|
3068
3140
|
return withIdRefPrefixArray([...schemaNode]);
|
|
3069
3141
|
}
|
|
3070
|
-
if (
|
|
3142
|
+
if (isObject2(schemaNode)) {
|
|
3071
3143
|
return withIdRefPrefixObject({ ...schemaNode });
|
|
3072
3144
|
}
|
|
3073
3145
|
return schemaNode;
|
|
@@ -3255,6 +3327,7 @@
|
|
|
3255
3327
|
exports.ID_KEY = ID_KEY;
|
|
3256
3328
|
exports.IF_KEY = IF_KEY;
|
|
3257
3329
|
exports.ITEMS_KEY = ITEMS_KEY;
|
|
3330
|
+
exports.JSON_SCHEMA_DRAFT_2019_09 = JSON_SCHEMA_DRAFT_2019_09;
|
|
3258
3331
|
exports.JSON_SCHEMA_DRAFT_2020_12 = JSON_SCHEMA_DRAFT_2020_12;
|
|
3259
3332
|
exports.JUNK_OPTION_ID = JUNK_OPTION_ID;
|
|
3260
3333
|
exports.LOOKUP_MAP_NAME = LOOKUP_MAP_NAME;
|
|
@@ -3342,6 +3415,7 @@
|
|
|
3342
3415
|
exports.sanitizeDataForNewSchema = sanitizeDataForNewSchema;
|
|
3343
3416
|
exports.schemaParser = schemaParser;
|
|
3344
3417
|
exports.schemaRequiresTrueValue = schemaRequiresTrueValue;
|
|
3418
|
+
exports.shallowEquals = shallowEquals;
|
|
3345
3419
|
exports.shouldRender = shouldRender;
|
|
3346
3420
|
exports.sortedJSONStringify = sortedJSONStringify;
|
|
3347
3421
|
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,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAChE,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAC/C,MAAM,CAAC,MAAM,QAAQ,GAAG,M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AC;AAC9B,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;AACpE;GACG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAE/C;GACG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AACrD,MAAM,CAAC,MAAM,+BAA+B,GAAG,6BAA6B,CAAC;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD;GACG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,8CAA8C,CAAC;AACxF,MAAM,CAAC,MAAM,yBAAyB,GAAG,8CAA8C,CAAC"}
|
package/lib/createSchemaUtils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import deepEquals from './deepEquals.js';
|
|
2
2
|
import { findFieldInSchema, findSelectedOptionInXxxOf, 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 && 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;
|
|
@@ -45,6 +53,8 @@ class SchemaUtils {
|
|
|
45
53
|
* @returns - True if the `SchemaUtilsType` differs from the given `validator` or `rootSchema`
|
|
46
54
|
*/
|
|
47
55
|
doesSchemaUtilsDiffer(validator, rootSchema, experimental_defaultFormStateBehavior = {}, experimental_customMergeAllOf) {
|
|
56
|
+
// If either validator or rootSchema are falsy, return false to prevent the creation
|
|
57
|
+
// of a new SchemaUtilsType with incomplete properties.
|
|
48
58
|
if (!validator || !rootSchema) {
|
|
49
59
|
return false;
|
|
50
60
|
}
|
|
@@ -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,wBA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,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;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,K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O,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/getUiOptions.js
CHANGED
|
@@ -8,6 +8,10 @@ import isObject from './isObject.js';
|
|
|
8
8
|
* @returns - An object containing all the `ui:xxx` options with the `ui:` stripped off along with all `globalOptions`
|
|
9
9
|
*/
|
|
10
10
|
export default function getUiOptions(uiSchema = {}, globalOptions = {}) {
|
|
11
|
+
// Handle null or undefined uiSchema
|
|
12
|
+
if (!uiSchema) {
|
|
13
|
+
return { ...globalOptions };
|
|
14
|
+
}
|
|
11
15
|
return Object.keys(uiSchema)
|
|
12
16
|
.filter((key) => key.indexOf('ui:') === 0)
|
|
13
17
|
.reduce((options, key) => {
|
package/lib/getUiOptions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUiOptions.js","sourceRoot":"","sources":["../src/getUiOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA8B,EAAE,EAChC,gBAAuC,EAAE;IAEzC,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;SACzB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACzC,MAAM,CACL,CAAC,OAAO,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I,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,CAAC,qFAAqF,CAAC,CAAC;YACrG,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,IAAI,GAAG,KAAK,cAAc,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;IACnD,CAAC,EACD,EAAE,GAAG,aAAa,EAAE,CACrB,CAAC;AACN,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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,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;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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KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,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
|