@rjsf/utils 5.0.0-beta.5 → 5.0.0-beta.8
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/README.md +11 -9
- package/dist/index.d.ts +37 -3
- package/dist/utils.cjs.development.js +5 -5
- package/dist/utils.cjs.development.js.map +1 -1
- package/dist/utils.cjs.production.min.js +1 -1
- package/dist/utils.cjs.production.min.js.map +1 -1
- package/dist/utils.esm.js +4 -4
- package/dist/utils.esm.js.map +1 -1
- package/dist/utils.umd.development.js +8 -8
- package/dist/utils.umd.development.js.map +1 -1
- package/dist/utils.umd.production.min.js +1 -1
- package/dist/utils.umd.production.min.js.map +1 -1
- package/package.json +2 -2
package/dist/utils.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import isEqualWith from 'lodash-es/isEqualWith';
|
|
2
2
|
import get from 'lodash-es/get';
|
|
3
|
+
import isEmpty from 'lodash-es/isEmpty';
|
|
3
4
|
import jsonpointer from 'jsonpointer';
|
|
4
5
|
import omit from 'lodash-es/omit';
|
|
5
6
|
import set from 'lodash-es/set';
|
|
6
7
|
import mergeAllOf from 'json-schema-merge-allof';
|
|
7
8
|
import union from 'lodash-es/union';
|
|
8
|
-
import isEmpty from 'lodash-es/isEmpty';
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import ReactIs from 'react-is';
|
|
11
11
|
|
|
@@ -974,7 +974,7 @@ function getInnerSchemaForArrayItem(schema, additionalItems, idx) {
|
|
|
974
974
|
return {};
|
|
975
975
|
}
|
|
976
976
|
/** Computes the defaults for the current `schema` given the `rawFormData` and `parentDefaults` if any. This drills into
|
|
977
|
-
*
|
|
977
|
+
* each level of the schema, recursively, to fill out every level of defaults provided by the schema.
|
|
978
978
|
*
|
|
979
979
|
* @param validator - an implementation of the `ValidatorType` interface that will be used when necessary
|
|
980
980
|
* @param schema - The schema for which the default state is desired
|
|
@@ -1014,9 +1014,9 @@ function computeDefaults(validator, schema, parentDefaults, rootSchema, rawFormD
|
|
|
1014
1014
|
} else if (isFixedItems(schema)) {
|
|
1015
1015
|
defaults = schema.items.map((itemSchema, idx) => computeDefaults(validator, itemSchema, Array.isArray(parentDefaults) ? parentDefaults[idx] : undefined, rootSchema, formData, includeUndefinedValues));
|
|
1016
1016
|
} else if (ONE_OF_KEY in schema) {
|
|
1017
|
-
schema = schema.oneOf[getMatchingOption(validator, undefined, schema.oneOf, rootSchema)];
|
|
1017
|
+
schema = schema.oneOf[getMatchingOption(validator, isEmpty(formData) ? undefined : formData, schema.oneOf, rootSchema)];
|
|
1018
1018
|
} else if (ANY_OF_KEY in schema) {
|
|
1019
|
-
schema = schema.anyOf[getMatchingOption(validator, undefined, schema.anyOf, rootSchema)];
|
|
1019
|
+
schema = schema.anyOf[getMatchingOption(validator, isEmpty(formData) ? undefined : formData, schema.anyOf, rootSchema)];
|
|
1020
1020
|
} // Not defaults defined for this node, fallback to generic typed ones.
|
|
1021
1021
|
|
|
1022
1022
|
|