@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/package.json
CHANGED
|
@@ -121,6 +121,7 @@ export function computeDefaultBasedOnSchemaTypeAndDefaults<T = any, S extends St
|
|
|
121
121
|
* @param experimental_defaultFormStateBehavior - Optional configuration object, if provided, allows users to override
|
|
122
122
|
* default form state behavior
|
|
123
123
|
* @param isConst - Optional flag, if true, indicates that the schema has a const property defined, thus we should always return the computedDefault since it's coming from the const.
|
|
124
|
+
* @param isNullType - The type of the schema is null
|
|
124
125
|
*/
|
|
125
126
|
function maybeAddDefaultToObject<T = any>(
|
|
126
127
|
obj: GenericObjectType,
|
|
@@ -131,6 +132,7 @@ function maybeAddDefaultToObject<T = any>(
|
|
|
131
132
|
requiredFields: string[] = [],
|
|
132
133
|
experimental_defaultFormStateBehavior: Experimental_DefaultFormStateBehavior = {},
|
|
133
134
|
isConst = false,
|
|
135
|
+
isNullType = false,
|
|
134
136
|
) {
|
|
135
137
|
const { emptyObjectFields = 'populateAllDefaults' } = experimental_defaultFormStateBehavior;
|
|
136
138
|
|
|
@@ -141,7 +143,7 @@ function maybeAddDefaultToObject<T = any>(
|
|
|
141
143
|
} else if (includeUndefinedValues === 'excludeObjectChildren') {
|
|
142
144
|
// Fix for Issue #4709: When in 'excludeObjectChildren' mode, don't set primitive fields to empty objects
|
|
143
145
|
// Only add the computed default if it's not an empty object placeholder for a primitive field
|
|
144
|
-
if (!isObject(computedDefault) || !isEmpty(computedDefault)) {
|
|
146
|
+
if ((isNullType && computedDefault !== undefined) || !isObject(computedDefault) || !isEmpty(computedDefault)) {
|
|
145
147
|
obj[key] = computedDefault;
|
|
146
148
|
}
|
|
147
149
|
// If computedDefault is an empty object {}, don't add it - let the field stay undefined
|
|
@@ -517,6 +519,7 @@ export function getObjectDefaults<T = any, S extends StrictRJSFSchema = RJSFSche
|
|
|
517
519
|
retrievedSchema.required,
|
|
518
520
|
experimental_defaultFormStateBehavior,
|
|
519
521
|
hasConst,
|
|
522
|
+
propertySchema?.type === 'null',
|
|
520
523
|
);
|
|
521
524
|
|
|
522
525
|
return acc;
|