@rjsf/utils 6.0.0 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +2 -2
- package/dist/utils.esm.js +4 -3
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +4 -3
- package/lib/schema/getDefaultFormState.js +4 -3
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/schema/getDefaultFormState.ts +4 -1
package/dist/utils.esm.js
CHANGED
|
@@ -1464,12 +1464,12 @@ function computeDefaultBasedOnSchemaTypeAndDefaults(schema, computedDefault) {
|
|
|
1464
1464
|
const shouldReturnNullAsDefault = Array.isArray(type) && type.includes("null") && isEmpty4(computedDefault) && schemaDefault === null;
|
|
1465
1465
|
return shouldReturnNullAsDefault ? null : computedDefault;
|
|
1466
1466
|
}
|
|
1467
|
-
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
1467
|
+
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false, isNullType = false) {
|
|
1468
1468
|
const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
|
|
1469
1469
|
if (includeUndefinedValues === true || isConst) {
|
|
1470
1470
|
obj[key] = computedDefault;
|
|
1471
1471
|
} else if (includeUndefinedValues === "excludeObjectChildren") {
|
|
1472
|
-
if (!isObject(computedDefault) || !isEmpty4(computedDefault)) {
|
|
1472
|
+
if (isNullType && computedDefault !== void 0 || !isObject(computedDefault) || !isEmpty4(computedDefault)) {
|
|
1473
1473
|
obj[key] = computedDefault;
|
|
1474
1474
|
}
|
|
1475
1475
|
} else if (emptyObjectFields !== "skipDefaults") {
|
|
@@ -1695,7 +1695,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1695
1695
|
required,
|
|
1696
1696
|
retrievedSchema.required,
|
|
1697
1697
|
experimental_defaultFormStateBehavior,
|
|
1698
|
-
hasConst
|
|
1698
|
+
hasConst,
|
|
1699
|
+
propertySchema?.type === "null"
|
|
1699
1700
|
);
|
|
1700
1701
|
return acc;
|
|
1701
1702
|
},
|