@rjsf/utils 6.0.0-beta.1 → 6.0.0-beta.10
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 +158 -109
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +158 -109
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +132 -87
- package/lib/canExpand.d.ts +1 -1
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +4 -0
- package/lib/constants.js.map +1 -1
- package/lib/findSchemaDefinition.d.ts +4 -2
- package/lib/findSchemaDefinition.js +53 -10
- package/lib/findSchemaDefinition.js.map +1 -1
- package/lib/schema/findFieldInSchema.d.ts +1 -1
- package/lib/schema/findFieldInSchema.js +1 -1
- package/lib/schema/getDefaultFormState.js +13 -2
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/schema/retrieveSchema.d.ts +2 -1
- package/lib/schema/retrieveSchema.js +14 -7
- package/lib/schema/retrieveSchema.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +13 -12
- package/package.json +2 -1
- package/src/constants.ts +5 -0
- package/src/findSchemaDefinition.ts +53 -8
- package/src/schema/findFieldInSchema.ts +1 -1
- package/src/schema/getDefaultFormState.ts +15 -3
- package/src/schema/retrieveSchema.ts +14 -5
- package/src/types.ts +13 -11
package/dist/utils.esm.js
CHANGED
|
@@ -65,6 +65,7 @@ var READONLY_KEY = "readonly";
|
|
|
65
65
|
var REQUIRED_KEY = "required";
|
|
66
66
|
var SUBMIT_BTN_OPTIONS_KEY = "submitButtonOptions";
|
|
67
67
|
var REF_KEY = "$ref";
|
|
68
|
+
var SCHEMA_KEY = "$schema";
|
|
68
69
|
var DISCRIMINATOR_PATH = ["discriminator", "propertyName"];
|
|
69
70
|
var FORM_CONTEXT_NAME = "formContext";
|
|
70
71
|
var LOOKUP_MAP_NAME = "layoutGridLookupMap";
|
|
@@ -74,6 +75,7 @@ var UI_FIELD_KEY = "ui:field";
|
|
|
74
75
|
var UI_WIDGET_KEY = "ui:widget";
|
|
75
76
|
var UI_OPTIONS_KEY = "ui:options";
|
|
76
77
|
var UI_GLOBAL_OPTIONS_KEY = "ui:globalOptions";
|
|
78
|
+
var JSON_SCHEMA_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
77
79
|
|
|
78
80
|
// src/getUiOptions.ts
|
|
79
81
|
function getUiOptions(uiSchema = {}, globalOptions = {}) {
|
|
@@ -146,15 +148,15 @@ function deepEquals(a, b) {
|
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
// src/schema/findFieldInSchema.ts
|
|
149
|
-
import
|
|
151
|
+
import get8 from "lodash/get";
|
|
150
152
|
import has3 from "lodash/has";
|
|
151
153
|
|
|
152
154
|
// src/schema/findSelectedOptionInXxxOf.ts
|
|
153
|
-
import
|
|
155
|
+
import get6 from "lodash/get";
|
|
154
156
|
import isEqual from "lodash/isEqual";
|
|
155
157
|
|
|
156
158
|
// src/schema/retrieveSchema.ts
|
|
157
|
-
import
|
|
159
|
+
import get5 from "lodash/get";
|
|
158
160
|
import set from "lodash/set";
|
|
159
161
|
import times from "lodash/times";
|
|
160
162
|
import transform from "lodash/transform";
|
|
@@ -166,20 +168,53 @@ import mergeAllOf from "json-schema-merge-allof";
|
|
|
166
168
|
// src/findSchemaDefinition.ts
|
|
167
169
|
import jsonpointer from "jsonpointer";
|
|
168
170
|
import omit from "lodash/omit";
|
|
171
|
+
import isObject2 from "lodash/isObject";
|
|
172
|
+
import isEmpty from "lodash/isEmpty";
|
|
173
|
+
import UriResolver from "fast-uri";
|
|
174
|
+
import get from "lodash/get";
|
|
175
|
+
function findEmbeddedSchemaRecursive(schema, ref) {
|
|
176
|
+
if (ID_KEY in schema && UriResolver.equal(schema[ID_KEY], ref)) {
|
|
177
|
+
return schema;
|
|
178
|
+
}
|
|
179
|
+
for (const subSchema of Object.values(schema)) {
|
|
180
|
+
if (isObject2(subSchema)) {
|
|
181
|
+
const result = findEmbeddedSchemaRecursive(subSchema, ref);
|
|
182
|
+
if (result !== void 0) {
|
|
183
|
+
return result;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return void 0;
|
|
188
|
+
}
|
|
169
189
|
function splitKeyElementFromObject(key, object) {
|
|
170
190
|
const value = object[key];
|
|
171
191
|
const remaining = omit(object, [key]);
|
|
172
192
|
return [remaining, value];
|
|
173
193
|
}
|
|
174
|
-
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = []) {
|
|
194
|
+
function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [], baseURI = get(rootSchema, [ID_KEY])) {
|
|
175
195
|
const ref = $ref || "";
|
|
176
|
-
let
|
|
196
|
+
let current = void 0;
|
|
177
197
|
if (ref.startsWith("#")) {
|
|
178
|
-
decodedRef = decodeURIComponent(ref.substring(1));
|
|
179
|
-
|
|
180
|
-
|
|
198
|
+
const decodedRef = decodeURIComponent(ref.substring(1));
|
|
199
|
+
if (baseURI === void 0 || ID_KEY in rootSchema && rootSchema[ID_KEY] === baseURI) {
|
|
200
|
+
current = jsonpointer.get(rootSchema, decodedRef);
|
|
201
|
+
} else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
202
|
+
current = findEmbeddedSchemaRecursive(rootSchema, baseURI.replace(/\/$/, ""));
|
|
203
|
+
if (current !== void 0) {
|
|
204
|
+
current = jsonpointer.get(current, decodedRef);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else if (rootSchema[SCHEMA_KEY] === JSON_SCHEMA_DRAFT_2020_12) {
|
|
208
|
+
const resolvedRef = baseURI ? UriResolver.resolve(baseURI, ref) : ref;
|
|
209
|
+
const [refId, ...refAnchor] = resolvedRef.replace(/#\/?$/, "").split("#");
|
|
210
|
+
current = findEmbeddedSchemaRecursive(rootSchema, refId.replace(/\/$/, ""));
|
|
211
|
+
if (current !== void 0) {
|
|
212
|
+
baseURI = current[ID_KEY];
|
|
213
|
+
if (!isEmpty(refAnchor)) {
|
|
214
|
+
current = jsonpointer.get(current, decodeURIComponent(refAnchor.join("#")));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
181
217
|
}
|
|
182
|
-
const current = jsonpointer.get(rootSchema, decodedRef);
|
|
183
218
|
if (current === void 0) {
|
|
184
219
|
throw new Error(`Could not find a definition for ${$ref}.`);
|
|
185
220
|
}
|
|
@@ -194,7 +229,7 @@ function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [])
|
|
|
194
229
|
throw new Error(`Definition for ${firstRef} contains a circular reference through ${circularPath}`);
|
|
195
230
|
}
|
|
196
231
|
const [remaining, theRef] = splitKeyElementFromObject(REF_KEY, current);
|
|
197
|
-
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref]);
|
|
232
|
+
const subSchema = findSchemaDefinitionRecursive(theRef, rootSchema, [...recurseList, ref], baseURI);
|
|
198
233
|
if (Object.keys(remaining).length > 0) {
|
|
199
234
|
return { ...remaining, ...subSchema };
|
|
200
235
|
}
|
|
@@ -202,17 +237,17 @@ function findSchemaDefinitionRecursive($ref, rootSchema = {}, recurseList = [])
|
|
|
202
237
|
}
|
|
203
238
|
return current;
|
|
204
239
|
}
|
|
205
|
-
function findSchemaDefinition($ref, rootSchema = {}) {
|
|
240
|
+
function findSchemaDefinition($ref, rootSchema = {}, baseURI = get(rootSchema, [ID_KEY])) {
|
|
206
241
|
const recurseList = [];
|
|
207
|
-
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList);
|
|
242
|
+
return findSchemaDefinitionRecursive($ref, rootSchema, recurseList, baseURI);
|
|
208
243
|
}
|
|
209
244
|
|
|
210
245
|
// src/getDiscriminatorFieldFromSchema.ts
|
|
211
|
-
import
|
|
246
|
+
import get2 from "lodash/get";
|
|
212
247
|
import isString from "lodash/isString";
|
|
213
248
|
function getDiscriminatorFieldFromSchema(schema) {
|
|
214
249
|
let discriminator;
|
|
215
|
-
const maybeString =
|
|
250
|
+
const maybeString = get2(schema, DISCRIMINATOR_PATH);
|
|
216
251
|
if (isString(maybeString)) {
|
|
217
252
|
discriminator = maybeString;
|
|
218
253
|
} else if (maybeString !== void 0) {
|
|
@@ -286,21 +321,21 @@ function mergeSchemas(obj1, obj2) {
|
|
|
286
321
|
}
|
|
287
322
|
|
|
288
323
|
// src/schema/getFirstMatchingOption.ts
|
|
289
|
-
import
|
|
324
|
+
import get4 from "lodash/get";
|
|
290
325
|
import has from "lodash/has";
|
|
291
326
|
import isNumber from "lodash/isNumber";
|
|
292
327
|
|
|
293
328
|
// src/getOptionMatchingSimpleDiscriminator.ts
|
|
294
|
-
import
|
|
329
|
+
import get3 from "lodash/get";
|
|
295
330
|
function getOptionMatchingSimpleDiscriminator(formData, options, discriminatorField) {
|
|
296
331
|
if (formData && discriminatorField) {
|
|
297
|
-
const value =
|
|
332
|
+
const value = get3(formData, discriminatorField);
|
|
298
333
|
if (value === void 0) {
|
|
299
334
|
return;
|
|
300
335
|
}
|
|
301
336
|
for (let i = 0; i < options.length; i++) {
|
|
302
337
|
const option = options[i];
|
|
303
|
-
const discriminator =
|
|
338
|
+
const discriminator = get3(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
304
339
|
if (discriminator.type === "object" || discriminator.type === "array") {
|
|
305
340
|
continue;
|
|
306
341
|
}
|
|
@@ -327,8 +362,8 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
|
|
|
327
362
|
for (let i = 0; i < options.length; i++) {
|
|
328
363
|
const option = options[i];
|
|
329
364
|
if (discriminatorField && has(option, [PROPERTIES_KEY, discriminatorField])) {
|
|
330
|
-
const value =
|
|
331
|
-
const discriminator =
|
|
365
|
+
const value = get4(formData, discriminatorField);
|
|
366
|
+
const discriminator = get4(option, [PROPERTIES_KEY, discriminatorField], {});
|
|
332
367
|
if (validator.isValid(discriminator, value, rootSchema)) {
|
|
333
368
|
return i;
|
|
334
369
|
}
|
|
@@ -363,7 +398,7 @@ function getFirstMatchingOption(validator, formData, options, rootSchema, discri
|
|
|
363
398
|
}
|
|
364
399
|
|
|
365
400
|
// src/schema/retrieveSchema.ts
|
|
366
|
-
import
|
|
401
|
+
import isEmpty2 from "lodash/isEmpty";
|
|
367
402
|
function retrieveSchema(validator, schema, rootSchema = {}, rawFormData, experimental_customMergeAllOf) {
|
|
368
403
|
return retrieveSchemaInternal(
|
|
369
404
|
validator,
|
|
@@ -529,7 +564,7 @@ function resolveReference(validator, schema, rootSchema, expandAllBranches, recu
|
|
|
529
564
|
}
|
|
530
565
|
return [schema];
|
|
531
566
|
}
|
|
532
|
-
function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
567
|
+
function resolveAllReferences(schema, rootSchema, recurseList, baseURI) {
|
|
533
568
|
if (!isObject(schema)) {
|
|
534
569
|
return schema;
|
|
535
570
|
}
|
|
@@ -540,8 +575,11 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
540
575
|
return resolvedSchema;
|
|
541
576
|
}
|
|
542
577
|
recurseList.push($ref);
|
|
543
|
-
const refSchema = findSchemaDefinition($ref, rootSchema);
|
|
578
|
+
const refSchema = findSchemaDefinition($ref, rootSchema, baseURI);
|
|
544
579
|
resolvedSchema = { ...refSchema, ...localSchema };
|
|
580
|
+
if (ID_KEY in resolvedSchema) {
|
|
581
|
+
baseURI = resolvedSchema[ID_KEY];
|
|
582
|
+
}
|
|
545
583
|
}
|
|
546
584
|
if (PROPERTIES_KEY in resolvedSchema) {
|
|
547
585
|
const childrenLists = [];
|
|
@@ -549,7 +587,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
549
587
|
resolvedSchema[PROPERTIES_KEY],
|
|
550
588
|
(result, value, key) => {
|
|
551
589
|
const childList = [...recurseList];
|
|
552
|
-
result[key] = resolveAllReferences(value, rootSchema, childList);
|
|
590
|
+
result[key] = resolveAllReferences(value, rootSchema, childList, baseURI);
|
|
553
591
|
childrenLists.push(childList);
|
|
554
592
|
},
|
|
555
593
|
{}
|
|
@@ -560,7 +598,7 @@ function resolveAllReferences(schema, rootSchema, recurseList) {
|
|
|
560
598
|
if (ITEMS_KEY in resolvedSchema && !Array.isArray(resolvedSchema.items) && typeof resolvedSchema.items !== "boolean") {
|
|
561
599
|
resolvedSchema = {
|
|
562
600
|
...resolvedSchema,
|
|
563
|
-
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList)
|
|
601
|
+
items: resolveAllReferences(resolvedSchema.items, rootSchema, recurseList, baseURI)
|
|
564
602
|
};
|
|
565
603
|
}
|
|
566
604
|
return deepEquals(schema, resolvedSchema) ? schema : resolvedSchema;
|
|
@@ -577,12 +615,12 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
577
615
|
}
|
|
578
616
|
if (PATTERN_PROPERTIES_KEY in schema) {
|
|
579
617
|
const matchingProperties = getMatchingPatternProperties(schema, key);
|
|
580
|
-
if (!
|
|
618
|
+
if (!isEmpty2(matchingProperties)) {
|
|
581
619
|
schema.properties[key] = retrieveSchema(
|
|
582
620
|
validator,
|
|
583
621
|
{ allOf: Object.values(matchingProperties) },
|
|
584
622
|
rootSchema,
|
|
585
|
-
formData,
|
|
623
|
+
get5(formData, [key]),
|
|
586
624
|
experimental_customMergeAllOf
|
|
587
625
|
);
|
|
588
626
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -595,7 +633,7 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
595
633
|
if (REF_KEY in schema.additionalProperties) {
|
|
596
634
|
additionalProperties = retrieveSchema(
|
|
597
635
|
validator,
|
|
598
|
-
{ $ref:
|
|
636
|
+
{ $ref: get5(schema.additionalProperties, [REF_KEY]) },
|
|
599
637
|
rootSchema,
|
|
600
638
|
formData,
|
|
601
639
|
experimental_customMergeAllOf
|
|
@@ -608,10 +646,10 @@ function stubExistingAdditionalProperties(validator, theSchema, rootSchema, aFor
|
|
|
608
646
|
...schema.additionalProperties
|
|
609
647
|
};
|
|
610
648
|
} else {
|
|
611
|
-
additionalProperties = { type: guessType(
|
|
649
|
+
additionalProperties = { type: guessType(get5(formData, [key])) };
|
|
612
650
|
}
|
|
613
651
|
} else {
|
|
614
|
-
additionalProperties = { type: guessType(
|
|
652
|
+
additionalProperties = { type: guessType(get5(formData, [key])) };
|
|
615
653
|
}
|
|
616
654
|
schema.properties[key] = additionalProperties;
|
|
617
655
|
set(schema.properties, [key, ADDITIONAL_PROPERTY_FLAG], true);
|
|
@@ -667,7 +705,10 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
|
|
|
667
705
|
resolvedSchema = { ...resolvedSchema, allOf: withoutContainsSchemas };
|
|
668
706
|
}
|
|
669
707
|
resolvedSchema = experimental_customMergeAllOf ? experimental_customMergeAllOf(resolvedSchema) : mergeAllOf(resolvedSchema, {
|
|
670
|
-
deep: false
|
|
708
|
+
deep: false,
|
|
709
|
+
resolvers: {
|
|
710
|
+
$defs: mergeAllOf.options.resolvers.definitions
|
|
711
|
+
}
|
|
671
712
|
});
|
|
672
713
|
if (withContainsSchemas.length) {
|
|
673
714
|
resolvedSchema.allOf = withContainsSchemas;
|
|
@@ -682,12 +723,12 @@ function retrieveSchemaInternal(validator, schema, rootSchema, rawFormData, expa
|
|
|
682
723
|
resolvedSchema = Object.keys(resolvedSchema.properties).reduce(
|
|
683
724
|
(schema2, key) => {
|
|
684
725
|
const matchingProperties = getMatchingPatternProperties(schema2, key);
|
|
685
|
-
if (!
|
|
726
|
+
if (!isEmpty2(matchingProperties)) {
|
|
686
727
|
schema2.properties[key] = retrieveSchema(
|
|
687
728
|
validator,
|
|
688
729
|
{ allOf: [schema2.properties[key], ...Object.values(matchingProperties)] },
|
|
689
730
|
rootSchema,
|
|
690
|
-
rawFormData,
|
|
731
|
+
get5(rawFormData, [key]),
|
|
691
732
|
experimental_customMergeAllOf
|
|
692
733
|
);
|
|
693
734
|
}
|
|
@@ -759,7 +800,7 @@ function resolveDependencies(validator, schema, rootSchema, expandAllBranches, r
|
|
|
759
800
|
function processDependencies(validator, dependencies, resolvedSchema, rootSchema, expandAllBranches, recurseList, formData, experimental_customMergeAllOf) {
|
|
760
801
|
let schemas = [resolvedSchema];
|
|
761
802
|
for (const dependencyKey in dependencies) {
|
|
762
|
-
if (!expandAllBranches &&
|
|
803
|
+
if (!expandAllBranches && get5(formData, [dependencyKey]) === void 0) {
|
|
763
804
|
continue;
|
|
764
805
|
}
|
|
765
806
|
if (resolvedSchema.properties && !(dependencyKey in resolvedSchema.properties)) {
|
|
@@ -890,11 +931,11 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
|
|
|
890
931
|
const xxxOfs = schema[xxx].map(
|
|
891
932
|
(xxxOf) => retrieveSchema(validator, xxxOf, rootSchema, formData, experimental_customMergeAllOf)
|
|
892
933
|
);
|
|
893
|
-
const data =
|
|
934
|
+
const data = get6(formData, selectorField);
|
|
894
935
|
if (data !== void 0) {
|
|
895
936
|
return xxxOfs.find((xxx2) => {
|
|
896
937
|
return isEqual(
|
|
897
|
-
|
|
938
|
+
get6(xxx2, [PROPERTIES_KEY, selectorField, DEFAULT_KEY], get6(xxx2, [PROPERTIES_KEY, selectorField, CONST_KEY])),
|
|
898
939
|
data
|
|
899
940
|
);
|
|
900
941
|
});
|
|
@@ -904,21 +945,21 @@ function findSelectedOptionInXxxOf(validator, rootSchema, schema, fallbackField,
|
|
|
904
945
|
}
|
|
905
946
|
|
|
906
947
|
// src/schema/getFromSchema.ts
|
|
907
|
-
import
|
|
948
|
+
import get7 from "lodash/get";
|
|
908
949
|
import has2 from "lodash/has";
|
|
909
|
-
import
|
|
950
|
+
import isEmpty3 from "lodash/isEmpty";
|
|
910
951
|
function getFromSchemaInternal(validator, rootSchema, schema, path, experimental_customMergeAllOf) {
|
|
911
952
|
let fieldSchema = schema;
|
|
912
953
|
if (has2(schema, REF_KEY)) {
|
|
913
954
|
fieldSchema = retrieveSchema(validator, schema, rootSchema, void 0, experimental_customMergeAllOf);
|
|
914
955
|
}
|
|
915
|
-
if (
|
|
956
|
+
if (isEmpty3(path)) {
|
|
916
957
|
return fieldSchema;
|
|
917
958
|
}
|
|
918
959
|
const pathList = Array.isArray(path) ? path : path.split(".");
|
|
919
960
|
const [part, ...nestedPath] = pathList;
|
|
920
961
|
if (part && has2(fieldSchema, part)) {
|
|
921
|
-
fieldSchema =
|
|
962
|
+
fieldSchema = get7(fieldSchema, part);
|
|
922
963
|
return getFromSchemaInternal(
|
|
923
964
|
validator,
|
|
924
965
|
rootSchema,
|
|
@@ -960,7 +1001,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
960
1001
|
parentField,
|
|
961
1002
|
fieldName,
|
|
962
1003
|
ONE_OF_KEY,
|
|
963
|
-
|
|
1004
|
+
get8(formData, subPath),
|
|
964
1005
|
experimental_customMergeAllOf
|
|
965
1006
|
);
|
|
966
1007
|
} else if (has3(parentField, ANY_OF_KEY)) {
|
|
@@ -970,7 +1011,7 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
970
1011
|
parentField,
|
|
971
1012
|
fieldName,
|
|
972
1013
|
ANY_OF_KEY,
|
|
973
|
-
|
|
1014
|
+
get8(formData, subPath),
|
|
974
1015
|
experimental_customMergeAllOf
|
|
975
1016
|
);
|
|
976
1017
|
}
|
|
@@ -1024,14 +1065,14 @@ function findFieldInSchema(validator, rootSchema, schema, path, formData = {}, e
|
|
|
1024
1065
|
}
|
|
1025
1066
|
|
|
1026
1067
|
// src/schema/getDefaultFormState.ts
|
|
1027
|
-
import
|
|
1028
|
-
import
|
|
1068
|
+
import get12 from "lodash/get";
|
|
1069
|
+
import isEmpty4 from "lodash/isEmpty";
|
|
1029
1070
|
|
|
1030
1071
|
// src/schema/getClosestMatchingOption.ts
|
|
1031
|
-
import
|
|
1072
|
+
import get9 from "lodash/get";
|
|
1032
1073
|
import has4 from "lodash/has";
|
|
1033
1074
|
import isNumber2 from "lodash/isNumber";
|
|
1034
|
-
import
|
|
1075
|
+
import isObject3 from "lodash/isObject";
|
|
1035
1076
|
import isString2 from "lodash/isString";
|
|
1036
1077
|
import reduce from "lodash/reduce";
|
|
1037
1078
|
import times2 from "lodash/times";
|
|
@@ -1047,11 +1088,11 @@ var JUNK_OPTION = {
|
|
|
1047
1088
|
function calculateIndexScore(validator, rootSchema, schema, formData, experimental_customMergeAllOf) {
|
|
1048
1089
|
let totalScore = 0;
|
|
1049
1090
|
if (schema) {
|
|
1050
|
-
if (
|
|
1091
|
+
if (isObject3(schema.properties)) {
|
|
1051
1092
|
totalScore += reduce(
|
|
1052
1093
|
schema.properties,
|
|
1053
1094
|
(score, value, key) => {
|
|
1054
|
-
const formValue =
|
|
1095
|
+
const formValue = get9(formData, key);
|
|
1055
1096
|
if (typeof value === "boolean") {
|
|
1056
1097
|
return score;
|
|
1057
1098
|
}
|
|
@@ -1078,14 +1119,14 @@ function calculateIndexScore(validator, rootSchema, schema, formData, experiment
|
|
|
1078
1119
|
validator,
|
|
1079
1120
|
rootSchema,
|
|
1080
1121
|
formValue,
|
|
1081
|
-
|
|
1122
|
+
get9(value, key2),
|
|
1082
1123
|
-1,
|
|
1083
1124
|
discriminator,
|
|
1084
1125
|
experimental_customMergeAllOf
|
|
1085
1126
|
);
|
|
1086
1127
|
}
|
|
1087
1128
|
if (value.type === "object") {
|
|
1088
|
-
if (
|
|
1129
|
+
if (isObject3(formValue)) {
|
|
1089
1130
|
score += 1;
|
|
1090
1131
|
}
|
|
1091
1132
|
return score + calculateIndexScore(validator, rootSchema, value, formValue, experimental_customMergeAllOf);
|
|
@@ -1157,7 +1198,7 @@ function isFixedItems(schema) {
|
|
|
1157
1198
|
}
|
|
1158
1199
|
|
|
1159
1200
|
// src/mergeDefaultsWithFormData.ts
|
|
1160
|
-
import
|
|
1201
|
+
import get10 from "lodash/get";
|
|
1161
1202
|
import isNil from "lodash/isNil";
|
|
1162
1203
|
function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults = false, defaultSupercedesUndefined = false, overrideFormDataWithDefaults = false) {
|
|
1163
1204
|
if (Array.isArray(formData)) {
|
|
@@ -1184,11 +1225,11 @@ function mergeDefaultsWithFormData(defaults, formData, mergeExtraArrayDefaults =
|
|
|
1184
1225
|
if (isObject(formData)) {
|
|
1185
1226
|
const acc = Object.assign({}, defaults);
|
|
1186
1227
|
return Object.keys(formData).reduce((acc2, key) => {
|
|
1187
|
-
const keyValue =
|
|
1228
|
+
const keyValue = get10(formData, key);
|
|
1188
1229
|
const keyExistsInDefaults = isObject(defaults) && key in defaults;
|
|
1189
1230
|
const keyExistsInFormData = key in formData;
|
|
1190
1231
|
acc2[key] = mergeDefaultsWithFormData(
|
|
1191
|
-
defaults ?
|
|
1232
|
+
defaults ? get10(defaults, key) : {},
|
|
1192
1233
|
keyValue,
|
|
1193
1234
|
mergeExtraArrayDefaults,
|
|
1194
1235
|
defaultSupercedesUndefined,
|
|
@@ -1267,7 +1308,7 @@ function constIsAjvDataReference(schema) {
|
|
|
1267
1308
|
}
|
|
1268
1309
|
|
|
1269
1310
|
// src/optionsList.ts
|
|
1270
|
-
import
|
|
1311
|
+
import get11 from "lodash/get";
|
|
1271
1312
|
|
|
1272
1313
|
// src/toConstant.ts
|
|
1273
1314
|
function toConstant(schema) {
|
|
@@ -1313,8 +1354,8 @@ function optionsList(schema, uiSchema) {
|
|
|
1313
1354
|
let value;
|
|
1314
1355
|
let label = title;
|
|
1315
1356
|
if (selectorField) {
|
|
1316
|
-
const innerSchema =
|
|
1317
|
-
value =
|
|
1357
|
+
const innerSchema = get11(aSchema, [PROPERTIES_KEY, selectorField], {});
|
|
1358
|
+
value = get11(innerSchema, DEFAULT_KEY, get11(innerSchema, CONST_KEY));
|
|
1318
1359
|
label = label || innerSchema?.title || aSchema.title || String(value);
|
|
1319
1360
|
} else {
|
|
1320
1361
|
value = toConstant(aSchema);
|
|
@@ -1354,10 +1395,10 @@ function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValu
|
|
|
1354
1395
|
const isSelfOrParentRequired = isParentRequired === void 0 ? requiredFields.includes(key) : isParentRequired;
|
|
1355
1396
|
if (isObject(computedDefault)) {
|
|
1356
1397
|
if (emptyObjectFields === "skipEmptyDefaults") {
|
|
1357
|
-
if (!
|
|
1398
|
+
if (!isEmpty4(computedDefault)) {
|
|
1358
1399
|
obj[key] = computedDefault;
|
|
1359
1400
|
}
|
|
1360
|
-
} else if ((!
|
|
1401
|
+
} else if ((!isEmpty4(computedDefault) || requiredFields.includes(key)) && (isSelfOrParentRequired || emptyObjectFields !== "populateRequiredDefaults")) {
|
|
1361
1402
|
obj[key] = computedDefault;
|
|
1362
1403
|
}
|
|
1363
1404
|
} else if (
|
|
@@ -1383,7 +1424,7 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
|
1383
1424
|
required,
|
|
1384
1425
|
shouldMergeDefaultsIntoFormData = false
|
|
1385
1426
|
} = computeDefaultsProps;
|
|
1386
|
-
|
|
1427
|
+
let formData = isObject(rawFormData) ? rawFormData : {};
|
|
1387
1428
|
const schema = isObject(rawSchema) ? rawSchema : {};
|
|
1388
1429
|
let defaults = parentDefaults;
|
|
1389
1430
|
let schemaToCompute = null;
|
|
@@ -1393,7 +1434,7 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
|
1393
1434
|
defaults = schema[CONST_KEY];
|
|
1394
1435
|
} else if (isObject(defaults) && isObject(schema.default)) {
|
|
1395
1436
|
defaults = mergeObjects(defaults, schema.default);
|
|
1396
|
-
} else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY]) {
|
|
1437
|
+
} else if (DEFAULT_KEY in schema && !schema[ANY_OF_KEY] && !schema[ONE_OF_KEY] && !schema[REF_KEY]) {
|
|
1397
1438
|
defaults = schema.default;
|
|
1398
1439
|
} else if (REF_KEY in schema) {
|
|
1399
1440
|
const refName = schema[REF_KEY];
|
|
@@ -1401,6 +1442,12 @@ function computeDefaults(validator, rawSchema, computeDefaultsProps = {}) {
|
|
|
1401
1442
|
updatedRecurseList = _recurseList.concat(refName);
|
|
1402
1443
|
schemaToCompute = findSchemaDefinition(refName, rootSchema);
|
|
1403
1444
|
}
|
|
1445
|
+
if (schemaToCompute && !defaults) {
|
|
1446
|
+
defaults = schema.default;
|
|
1447
|
+
}
|
|
1448
|
+
if (shouldMergeDefaultsIntoFormData && schemaToCompute && !isObject(rawFormData)) {
|
|
1449
|
+
formData = rawFormData;
|
|
1450
|
+
}
|
|
1404
1451
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
1405
1452
|
const defaultFormData = {
|
|
1406
1453
|
...getDefaultBasedOnSchemaType(validator, schema, computeDefaultsProps, defaults),
|
|
@@ -1541,7 +1588,7 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1541
1588
|
const parentConst = retrievedSchema[CONST_KEY];
|
|
1542
1589
|
const objectDefaults = Object.keys(retrievedSchema.properties || {}).reduce(
|
|
1543
1590
|
(acc, key) => {
|
|
1544
|
-
const propertySchema =
|
|
1591
|
+
const propertySchema = get12(retrievedSchema, [PROPERTIES_KEY, key], {});
|
|
1545
1592
|
const hasParentConst = isObject(parentConst) && parentConst[key] !== void 0;
|
|
1546
1593
|
const hasConst = (isObject(propertySchema) && CONST_KEY in propertySchema || hasParentConst) && experimental_defaultFormStateBehavior?.constAsDefaults !== "never" && !constIsAjvDataReference(propertySchema);
|
|
1547
1594
|
const computedDefault = computeDefaults(validator, propertySchema, {
|
|
@@ -1550,8 +1597,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1550
1597
|
experimental_defaultFormStateBehavior,
|
|
1551
1598
|
experimental_customMergeAllOf,
|
|
1552
1599
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1553
|
-
parentDefaults:
|
|
1554
|
-
rawFormData:
|
|
1600
|
+
parentDefaults: get12(defaults, [key]),
|
|
1601
|
+
rawFormData: get12(formData, [key]),
|
|
1555
1602
|
required: retrievedSchema.required?.includes(key),
|
|
1556
1603
|
shouldMergeDefaultsIntoFormData
|
|
1557
1604
|
});
|
|
@@ -1587,8 +1634,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1587
1634
|
experimental_defaultFormStateBehavior,
|
|
1588
1635
|
experimental_customMergeAllOf,
|
|
1589
1636
|
includeUndefinedValues: includeUndefinedValues === true,
|
|
1590
|
-
parentDefaults:
|
|
1591
|
-
rawFormData:
|
|
1637
|
+
parentDefaults: get12(defaults, [key]),
|
|
1638
|
+
rawFormData: get12(formData, [key]),
|
|
1592
1639
|
required: retrievedSchema.required?.includes(key),
|
|
1593
1640
|
shouldMergeDefaultsIntoFormData
|
|
1594
1641
|
});
|
|
@@ -1649,7 +1696,7 @@ function getArrayDefaults(validator, rawSchema, {
|
|
|
1649
1696
|
experimental_defaultFormStateBehavior,
|
|
1650
1697
|
experimental_customMergeAllOf,
|
|
1651
1698
|
rawFormData: item,
|
|
1652
|
-
parentDefaults:
|
|
1699
|
+
parentDefaults: get12(defaults, [idx]),
|
|
1653
1700
|
required,
|
|
1654
1701
|
shouldMergeDefaultsIntoFormData
|
|
1655
1702
|
});
|
|
@@ -1777,7 +1824,7 @@ function getDisplayLabel(validator, schema, uiSchema = {}, rootSchema, globalOpt
|
|
|
1777
1824
|
}
|
|
1778
1825
|
|
|
1779
1826
|
// src/schema/sanitizeDataForNewSchema.ts
|
|
1780
|
-
import
|
|
1827
|
+
import get13 from "lodash/get";
|
|
1781
1828
|
import has5 from "lodash/has";
|
|
1782
1829
|
var NO_VALUE = Symbol("no Value");
|
|
1783
1830
|
function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, data = {}, experimental_customMergeAllOf) {
|
|
@@ -1785,19 +1832,19 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1785
1832
|
if (has5(newSchema, PROPERTIES_KEY)) {
|
|
1786
1833
|
const removeOldSchemaData = {};
|
|
1787
1834
|
if (has5(oldSchema, PROPERTIES_KEY)) {
|
|
1788
|
-
const properties =
|
|
1835
|
+
const properties = get13(oldSchema, PROPERTIES_KEY, {});
|
|
1789
1836
|
Object.keys(properties).forEach((key) => {
|
|
1790
1837
|
if (has5(data, key)) {
|
|
1791
1838
|
removeOldSchemaData[key] = void 0;
|
|
1792
1839
|
}
|
|
1793
1840
|
});
|
|
1794
1841
|
}
|
|
1795
|
-
const keys2 = Object.keys(
|
|
1842
|
+
const keys2 = Object.keys(get13(newSchema, PROPERTIES_KEY, {}));
|
|
1796
1843
|
const nestedData = {};
|
|
1797
1844
|
keys2.forEach((key) => {
|
|
1798
|
-
const formValue =
|
|
1799
|
-
let oldKeyedSchema =
|
|
1800
|
-
let newKeyedSchema =
|
|
1845
|
+
const formValue = get13(data, key);
|
|
1846
|
+
let oldKeyedSchema = get13(oldSchema, [PROPERTIES_KEY, key], {});
|
|
1847
|
+
let newKeyedSchema = get13(newSchema, [PROPERTIES_KEY, key], {});
|
|
1801
1848
|
if (has5(oldKeyedSchema, REF_KEY)) {
|
|
1802
1849
|
oldKeyedSchema = retrieveSchema(
|
|
1803
1850
|
validator,
|
|
@@ -1816,8 +1863,8 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1816
1863
|
experimental_customMergeAllOf
|
|
1817
1864
|
);
|
|
1818
1865
|
}
|
|
1819
|
-
const oldSchemaTypeForKey =
|
|
1820
|
-
const newSchemaTypeForKey =
|
|
1866
|
+
const oldSchemaTypeForKey = get13(oldKeyedSchema, "type");
|
|
1867
|
+
const newSchemaTypeForKey = get13(newKeyedSchema, "type");
|
|
1821
1868
|
if (!oldSchemaTypeForKey || oldSchemaTypeForKey === newSchemaTypeForKey) {
|
|
1822
1869
|
if (has5(removeOldSchemaData, key)) {
|
|
1823
1870
|
delete removeOldSchemaData[key];
|
|
@@ -1835,17 +1882,17 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1835
1882
|
nestedData[key] = itemData;
|
|
1836
1883
|
}
|
|
1837
1884
|
} else {
|
|
1838
|
-
const newOptionDefault =
|
|
1839
|
-
const oldOptionDefault =
|
|
1885
|
+
const newOptionDefault = get13(newKeyedSchema, "default", NO_VALUE);
|
|
1886
|
+
const oldOptionDefault = get13(oldKeyedSchema, "default", NO_VALUE);
|
|
1840
1887
|
if (newOptionDefault !== NO_VALUE && newOptionDefault !== formValue) {
|
|
1841
1888
|
if (oldOptionDefault === formValue) {
|
|
1842
1889
|
removeOldSchemaData[key] = newOptionDefault;
|
|
1843
|
-
} else if (
|
|
1890
|
+
} else if (get13(newKeyedSchema, "readOnly") === true) {
|
|
1844
1891
|
removeOldSchemaData[key] = void 0;
|
|
1845
1892
|
}
|
|
1846
1893
|
}
|
|
1847
|
-
const newOptionConst =
|
|
1848
|
-
const oldOptionConst =
|
|
1894
|
+
const newOptionConst = get13(newKeyedSchema, "const", NO_VALUE);
|
|
1895
|
+
const oldOptionConst = get13(oldKeyedSchema, "const", NO_VALUE);
|
|
1849
1896
|
if (newOptionConst !== NO_VALUE && newOptionConst !== formValue) {
|
|
1850
1897
|
removeOldSchemaData[key] = oldOptionConst === formValue ? newOptionConst : void 0;
|
|
1851
1898
|
}
|
|
@@ -1857,9 +1904,9 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1857
1904
|
...removeOldSchemaData,
|
|
1858
1905
|
...nestedData
|
|
1859
1906
|
};
|
|
1860
|
-
} else if (
|
|
1861
|
-
let oldSchemaItems =
|
|
1862
|
-
let newSchemaItems =
|
|
1907
|
+
} else if (get13(oldSchema, "type") === "array" && get13(newSchema, "type") === "array" && Array.isArray(data)) {
|
|
1908
|
+
let oldSchemaItems = get13(oldSchema, "items");
|
|
1909
|
+
let newSchemaItems = get13(newSchema, "items");
|
|
1863
1910
|
if (typeof oldSchemaItems === "object" && typeof newSchemaItems === "object" && !Array.isArray(oldSchemaItems) && !Array.isArray(newSchemaItems)) {
|
|
1864
1911
|
if (has5(oldSchemaItems, REF_KEY)) {
|
|
1865
1912
|
oldSchemaItems = retrieveSchema(
|
|
@@ -1879,10 +1926,10 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1879
1926
|
experimental_customMergeAllOf
|
|
1880
1927
|
);
|
|
1881
1928
|
}
|
|
1882
|
-
const oldSchemaType =
|
|
1883
|
-
const newSchemaType =
|
|
1929
|
+
const oldSchemaType = get13(oldSchemaItems, "type");
|
|
1930
|
+
const newSchemaType = get13(newSchemaItems, "type");
|
|
1884
1931
|
if (!oldSchemaType || oldSchemaType === newSchemaType) {
|
|
1885
|
-
const maxItems =
|
|
1932
|
+
const maxItems = get13(newSchema, "maxItems", -1);
|
|
1886
1933
|
if (newSchemaType === "object") {
|
|
1887
1934
|
newFormData = data.reduce((newValue, aValue) => {
|
|
1888
1935
|
const itemValue = sanitizeDataForNewSchema(
|
|
@@ -1910,7 +1957,7 @@ function sanitizeDataForNewSchema(validator, rootSchema, newSchema, oldSchema, d
|
|
|
1910
1957
|
}
|
|
1911
1958
|
|
|
1912
1959
|
// src/schema/toIdSchema.ts
|
|
1913
|
-
import
|
|
1960
|
+
import get14 from "lodash/get";
|
|
1914
1961
|
function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1915
1962
|
const $id = id || idPrefix;
|
|
1916
1963
|
const idSchema = { $id };
|
|
@@ -1932,10 +1979,10 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
|
|
|
1932
1979
|
);
|
|
1933
1980
|
}
|
|
1934
1981
|
}
|
|
1935
|
-
if (ITEMS_KEY in schema && !
|
|
1982
|
+
if (ITEMS_KEY in schema && !get14(schema, [ITEMS_KEY, REF_KEY])) {
|
|
1936
1983
|
return toIdSchemaInternal(
|
|
1937
1984
|
validator,
|
|
1938
|
-
|
|
1985
|
+
get14(schema, ITEMS_KEY),
|
|
1939
1986
|
idPrefix,
|
|
1940
1987
|
idSeparator,
|
|
1941
1988
|
id,
|
|
@@ -1958,7 +2005,7 @@ function toIdSchemaInternal(validator, schema, idPrefix, idSeparator, id, rootSc
|
|
|
1958
2005
|
rootSchema,
|
|
1959
2006
|
// It's possible that formData is not an object -- this can happen if an
|
|
1960
2007
|
// array item has just been added, but not populated with data yet
|
|
1961
|
-
|
|
2008
|
+
get14(formData, [name]),
|
|
1962
2009
|
_recurseList,
|
|
1963
2010
|
experimental_customMergeAllOf
|
|
1964
2011
|
);
|
|
@@ -1982,7 +2029,7 @@ function toIdSchema(validator, schema, id, rootSchema, formData, idPrefix = "roo
|
|
|
1982
2029
|
}
|
|
1983
2030
|
|
|
1984
2031
|
// src/schema/toPathSchema.ts
|
|
1985
|
-
import
|
|
2032
|
+
import get15 from "lodash/get";
|
|
1986
2033
|
import set2 from "lodash/set";
|
|
1987
2034
|
function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _recurseList = [], experimental_customMergeAllOf) {
|
|
1988
2035
|
if (REF_KEY in schema || DEPENDENCIES_KEY in schema || ALL_OF_KEY in schema) {
|
|
@@ -2075,7 +2122,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
|
|
|
2075
2122
|
}
|
|
2076
2123
|
} else if (PROPERTIES_KEY in schema) {
|
|
2077
2124
|
for (const property in schema.properties) {
|
|
2078
|
-
const field =
|
|
2125
|
+
const field = get15(schema, [PROPERTIES_KEY, property], {});
|
|
2079
2126
|
pathSchema[property] = toPathSchemaInternal(
|
|
2080
2127
|
validator,
|
|
2081
2128
|
field,
|
|
@@ -2083,7 +2130,7 @@ function toPathSchemaInternal(validator, schema, name, rootSchema, formData, _re
|
|
|
2083
2130
|
rootSchema,
|
|
2084
2131
|
// It's possible that formData is not an object -- this can happen if an
|
|
2085
2132
|
// array item has just been added, but not populated with data yet
|
|
2086
|
-
|
|
2133
|
+
get15(formData, [property]),
|
|
2087
2134
|
_recurseList,
|
|
2088
2135
|
experimental_customMergeAllOf
|
|
2089
2136
|
);
|
|
@@ -2501,7 +2548,7 @@ function enumOptionsSelectValue(valueIndex, selected, allEnumOptions = []) {
|
|
|
2501
2548
|
|
|
2502
2549
|
// src/ErrorSchemaBuilder.ts
|
|
2503
2550
|
import cloneDeep from "lodash/cloneDeep";
|
|
2504
|
-
import
|
|
2551
|
+
import get16 from "lodash/get";
|
|
2505
2552
|
import set3 from "lodash/set";
|
|
2506
2553
|
import setWith from "lodash/setWith";
|
|
2507
2554
|
var ErrorSchemaBuilder = class {
|
|
@@ -2530,7 +2577,7 @@ var ErrorSchemaBuilder = class {
|
|
|
2530
2577
|
*/
|
|
2531
2578
|
getOrCreateErrorBlock(pathOfError) {
|
|
2532
2579
|
const hasPath = Array.isArray(pathOfError) && pathOfError.length > 0 || typeof pathOfError === "string";
|
|
2533
|
-
let errorBlock = hasPath ?
|
|
2580
|
+
let errorBlock = hasPath ? get16(this.errorSchema, pathOfError) : this.errorSchema;
|
|
2534
2581
|
if (!errorBlock && pathOfError) {
|
|
2535
2582
|
errorBlock = {};
|
|
2536
2583
|
setWith(this.errorSchema, pathOfError, errorBlock, Object);
|
|
@@ -2556,7 +2603,7 @@ var ErrorSchemaBuilder = class {
|
|
|
2556
2603
|
*/
|
|
2557
2604
|
addErrors(errorOrList, pathOfError) {
|
|
2558
2605
|
const errorBlock = this.getOrCreateErrorBlock(pathOfError);
|
|
2559
|
-
let errorsList =
|
|
2606
|
+
let errorsList = get16(errorBlock, ERRORS_KEY);
|
|
2560
2607
|
if (!Array.isArray(errorsList)) {
|
|
2561
2608
|
errorsList = [];
|
|
2562
2609
|
errorBlock[ERRORS_KEY] = errorsList;
|
|
@@ -2705,9 +2752,9 @@ function getTemplate(name, registry, uiOptions = {}) {
|
|
|
2705
2752
|
|
|
2706
2753
|
// src/getTestIds.ts
|
|
2707
2754
|
import { nanoid } from "nanoid";
|
|
2708
|
-
import
|
|
2755
|
+
import get17 from "lodash/get";
|
|
2709
2756
|
function getTestIds() {
|
|
2710
|
-
if (typeof process === "undefined" ||
|
|
2757
|
+
if (typeof process === "undefined" || get17(process, "env.NODE_ENV") !== "test") {
|
|
2711
2758
|
return {};
|
|
2712
2759
|
}
|
|
2713
2760
|
const ids = /* @__PURE__ */ new Map();
|
|
@@ -2727,7 +2774,7 @@ function getTestIds() {
|
|
|
2727
2774
|
// src/getWidget.tsx
|
|
2728
2775
|
import { createElement } from "react";
|
|
2729
2776
|
import ReactIs from "react-is";
|
|
2730
|
-
import
|
|
2777
|
+
import get18 from "lodash/get";
|
|
2731
2778
|
import set4 from "lodash/set";
|
|
2732
2779
|
import { jsx } from "react/jsx-runtime";
|
|
2733
2780
|
var widgetMap = {
|
|
@@ -2783,7 +2830,7 @@ var widgetMap = {
|
|
|
2783
2830
|
}
|
|
2784
2831
|
};
|
|
2785
2832
|
function mergeWidgetOptions(AWidget) {
|
|
2786
|
-
let MergedWidget =
|
|
2833
|
+
let MergedWidget = get18(AWidget, "MergedWidget");
|
|
2787
2834
|
if (!MergedWidget) {
|
|
2788
2835
|
const defaultOptions = AWidget.defaultProps && AWidget.defaultProps.options || {};
|
|
2789
2836
|
MergedWidget = ({ options, ...props }) => {
|
|
@@ -2896,14 +2943,14 @@ function localToUTC(dateString) {
|
|
|
2896
2943
|
}
|
|
2897
2944
|
|
|
2898
2945
|
// src/lookupFromFormContext.ts
|
|
2899
|
-
import
|
|
2946
|
+
import get19 from "lodash/get";
|
|
2900
2947
|
import has6 from "lodash/has";
|
|
2901
2948
|
function lookupFromFormContext(regOrFc, toLookup, fallback) {
|
|
2902
2949
|
const lookupPath = [LOOKUP_MAP_NAME];
|
|
2903
2950
|
if (has6(regOrFc, FORM_CONTEXT_NAME)) {
|
|
2904
2951
|
lookupPath.unshift(FORM_CONTEXT_NAME);
|
|
2905
2952
|
}
|
|
2906
|
-
return
|
|
2953
|
+
return get19(regOrFc, [...lookupPath, toLookup], fallback);
|
|
2907
2954
|
}
|
|
2908
2955
|
|
|
2909
2956
|
// src/orderProperties.ts
|
|
@@ -3082,7 +3129,7 @@ function utcToLocal(jsonDate) {
|
|
|
3082
3129
|
}
|
|
3083
3130
|
|
|
3084
3131
|
// src/validationDataMerge.ts
|
|
3085
|
-
import
|
|
3132
|
+
import isEmpty5 from "lodash/isEmpty";
|
|
3086
3133
|
function validationDataMerge(validationData, additionalErrorSchema) {
|
|
3087
3134
|
if (!additionalErrorSchema) {
|
|
3088
3135
|
return validationData;
|
|
@@ -3090,7 +3137,7 @@ function validationDataMerge(validationData, additionalErrorSchema) {
|
|
|
3090
3137
|
const { errors: oldErrors, errorSchema: oldErrorSchema } = validationData;
|
|
3091
3138
|
let errors = toErrorList(additionalErrorSchema);
|
|
3092
3139
|
let errorSchema = additionalErrorSchema;
|
|
3093
|
-
if (!
|
|
3140
|
+
if (!isEmpty5(oldErrorSchema)) {
|
|
3094
3141
|
errorSchema = mergeObjects(oldErrorSchema, additionalErrorSchema, true);
|
|
3095
3142
|
errors = [...oldErrors].concat(errors);
|
|
3096
3143
|
}
|
|
@@ -3098,7 +3145,7 @@ function validationDataMerge(validationData, additionalErrorSchema) {
|
|
|
3098
3145
|
}
|
|
3099
3146
|
|
|
3100
3147
|
// src/withIdRefPrefix.ts
|
|
3101
|
-
import
|
|
3148
|
+
import isObject4 from "lodash/isObject";
|
|
3102
3149
|
function withIdRefPrefixObject(node) {
|
|
3103
3150
|
for (const key in node) {
|
|
3104
3151
|
const realObj = node;
|
|
@@ -3121,7 +3168,7 @@ function withIdRefPrefix(schemaNode) {
|
|
|
3121
3168
|
if (Array.isArray(schemaNode)) {
|
|
3122
3169
|
return withIdRefPrefixArray([...schemaNode]);
|
|
3123
3170
|
}
|
|
3124
|
-
if (
|
|
3171
|
+
if (isObject4(schemaNode)) {
|
|
3125
3172
|
return withIdRefPrefixObject({ ...schemaNode });
|
|
3126
3173
|
}
|
|
3127
3174
|
return schemaNode;
|
|
@@ -3131,7 +3178,7 @@ function withIdRefPrefix(schemaNode) {
|
|
|
3131
3178
|
import keys from "lodash/keys";
|
|
3132
3179
|
import pickBy from "lodash/pickBy";
|
|
3133
3180
|
import isPlainObject4 from "lodash/isPlainObject";
|
|
3134
|
-
import
|
|
3181
|
+
import get20 from "lodash/get";
|
|
3135
3182
|
import difference from "lodash/difference";
|
|
3136
3183
|
function getChangedFields(a, b) {
|
|
3137
3184
|
const aIsPlainObject = isPlainObject4(a);
|
|
@@ -3144,7 +3191,7 @@ function getChangedFields(a, b) {
|
|
|
3144
3191
|
} else if (!aIsPlainObject && bIsPlainObject) {
|
|
3145
3192
|
return keys(b);
|
|
3146
3193
|
} else {
|
|
3147
|
-
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value,
|
|
3194
|
+
const unequalFields = keys(pickBy(a, (value, key) => !deepEquals(value, get20(b, key))));
|
|
3148
3195
|
const diffFields = difference(keys(b), keys(a));
|
|
3149
3196
|
return [...unequalFields, ...diffFields];
|
|
3150
3197
|
}
|
|
@@ -3189,7 +3236,7 @@ var TranslatableString = /* @__PURE__ */ ((TranslatableString2) => {
|
|
|
3189
3236
|
import forEach from "lodash/forEach";
|
|
3190
3237
|
|
|
3191
3238
|
// src/parser/ParserValidator.ts
|
|
3192
|
-
import
|
|
3239
|
+
import get21 from "lodash/get";
|
|
3193
3240
|
var ParserValidator = class {
|
|
3194
3241
|
/** Construct the ParserValidator for the given `rootSchema`. This `rootSchema` will be stashed in the `schemaMap`
|
|
3195
3242
|
* first.
|
|
@@ -3215,7 +3262,7 @@ var ParserValidator = class {
|
|
|
3215
3262
|
* @param hash - The hash value at which to map the schema
|
|
3216
3263
|
*/
|
|
3217
3264
|
addSchema(schema, hash) {
|
|
3218
|
-
const key =
|
|
3265
|
+
const key = get21(schema, ID_KEY, hash);
|
|
3219
3266
|
const identifiedSchema = { ...schema, [ID_KEY]: key };
|
|
3220
3267
|
const existing = this.schemaMap[key];
|
|
3221
3268
|
if (!existing) {
|
|
@@ -3322,6 +3369,7 @@ export {
|
|
|
3322
3369
|
ID_KEY,
|
|
3323
3370
|
IF_KEY,
|
|
3324
3371
|
ITEMS_KEY,
|
|
3372
|
+
JSON_SCHEMA_DRAFT_2020_12,
|
|
3325
3373
|
JUNK_OPTION_ID,
|
|
3326
3374
|
LOOKUP_MAP_NAME,
|
|
3327
3375
|
NAME_KEY,
|
|
@@ -3333,6 +3381,7 @@ export {
|
|
|
3333
3381
|
REQUIRED_KEY,
|
|
3334
3382
|
RJSF_ADDITIONAL_PROPERTIES_FLAG,
|
|
3335
3383
|
ROOT_SCHEMA_PREFIX,
|
|
3384
|
+
SCHEMA_KEY,
|
|
3336
3385
|
SUBMIT_BTN_OPTIONS_KEY,
|
|
3337
3386
|
TranslatableString,
|
|
3338
3387
|
UI_FIELD_KEY,
|