@rjsf/utils 6.0.1 → 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/index.cjs
CHANGED
|
@@ -1629,12 +1629,12 @@ function computeDefaultBasedOnSchemaTypeAndDefaults(schema, computedDefault) {
|
|
|
1629
1629
|
const shouldReturnNullAsDefault = Array.isArray(type) && type.includes("null") && (0, import_isEmpty4.default)(computedDefault) && schemaDefault === null;
|
|
1630
1630
|
return shouldReturnNullAsDefault ? null : computedDefault;
|
|
1631
1631
|
}
|
|
1632
|
-
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false) {
|
|
1632
|
+
function maybeAddDefaultToObject(obj, key, computedDefault, includeUndefinedValues, isParentRequired, requiredFields = [], experimental_defaultFormStateBehavior = {}, isConst = false, isNullType = false) {
|
|
1633
1633
|
const { emptyObjectFields = "populateAllDefaults" } = experimental_defaultFormStateBehavior;
|
|
1634
1634
|
if (includeUndefinedValues === true || isConst) {
|
|
1635
1635
|
obj[key] = computedDefault;
|
|
1636
1636
|
} else if (includeUndefinedValues === "excludeObjectChildren") {
|
|
1637
|
-
if (!isObject(computedDefault) || !(0, import_isEmpty4.default)(computedDefault)) {
|
|
1637
|
+
if (isNullType && computedDefault !== void 0 || !isObject(computedDefault) || !(0, import_isEmpty4.default)(computedDefault)) {
|
|
1638
1638
|
obj[key] = computedDefault;
|
|
1639
1639
|
}
|
|
1640
1640
|
} else if (emptyObjectFields !== "skipDefaults") {
|
|
@@ -1860,7 +1860,8 @@ function getObjectDefaults(validator, rawSchema, {
|
|
|
1860
1860
|
required,
|
|
1861
1861
|
retrievedSchema.required,
|
|
1862
1862
|
experimental_defaultFormStateBehavior,
|
|
1863
|
-
hasConst
|
|
1863
|
+
hasConst,
|
|
1864
|
+
propertySchema?.type === "null"
|
|
1864
1865
|
);
|
|
1865
1866
|
return acc;
|
|
1866
1867
|
},
|