@rjsf/utils 5.24.9 → 5.24.11
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 +8 -2
- package/dist/index.js.map +2 -2
- package/dist/utils.esm.js +8 -2
- package/dist/utils.esm.js.map +2 -2
- package/dist/utils.umd.js +8 -2
- package/lib/schema/getDefaultFormState.js +13 -2
- package/lib/schema/getDefaultFormState.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -29
- package/src/schema/getDefaultFormState.ts +15 -3
package/package.json
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/utils",
|
|
3
|
-
"version": "5.24.
|
|
3
|
+
"version": "5.24.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"description": "Utility functions for @rjsf/core",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"require": "./dist/index.js",
|
|
11
|
-
"import": "./lib/index.js",
|
|
12
|
-
"types": "./lib/index.d.ts"
|
|
13
|
-
},
|
|
14
|
-
"./lib": {
|
|
15
|
-
"require": "./dist/index.js",
|
|
16
|
-
"import": "./lib/index.js",
|
|
17
|
-
"types": "./lib/index.d.ts"
|
|
18
|
-
},
|
|
19
|
-
"./lib/*.js": {
|
|
20
|
-
"require": "./dist/*.js",
|
|
21
|
-
"import": "./lib/*.js",
|
|
22
|
-
"types": "./lib/*.d.ts"
|
|
23
|
-
},
|
|
24
|
-
"./dist": {
|
|
25
|
-
"require": "./dist/index.js",
|
|
26
|
-
"import": "./lib/index.js",
|
|
27
|
-
"types": "./lib/index.d.ts"
|
|
28
|
-
},
|
|
29
|
-
"./dist/*.js": {
|
|
30
|
-
"require": "./dist/*.js",
|
|
31
|
-
"import": "./lib/*.js",
|
|
32
|
-
"types": "./lib/*.d.ts"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
8
|
"files": [
|
|
36
9
|
"dist",
|
|
37
10
|
"lib",
|
|
@@ -113,5 +86,5 @@
|
|
|
113
86
|
"url": "git+https://github.com/rjsf-team/react-jsonschema-form.git"
|
|
114
87
|
},
|
|
115
88
|
"license": "Apache-2.0",
|
|
116
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "7e80bfedc8884ba68b2832f404eba8e6bd11416f"
|
|
117
90
|
}
|
|
@@ -204,7 +204,7 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
204
204
|
required,
|
|
205
205
|
shouldMergeDefaultsIntoFormData = false,
|
|
206
206
|
} = computeDefaultsProps;
|
|
207
|
-
|
|
207
|
+
let formData: T = (isObject(rawFormData) ? rawFormData : {}) as T;
|
|
208
208
|
const schema: S = isObject(rawSchema) ? rawSchema : ({} as S);
|
|
209
209
|
// Compute the defaults recursively: give highest priority to deepest nodes.
|
|
210
210
|
let defaults: T | T[] | undefined = parentDefaults;
|
|
@@ -212,9 +212,8 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
212
212
|
let schemaToCompute: S | null = null;
|
|
213
213
|
let experimental_dfsb_to_compute = experimental_defaultFormStateBehavior;
|
|
214
214
|
let updatedRecurseList = _recurseList;
|
|
215
|
-
|
|
216
215
|
if (
|
|
217
|
-
schema[CONST_KEY] &&
|
|
216
|
+
schema[CONST_KEY] !== undefined &&
|
|
218
217
|
experimental_defaultFormStateBehavior?.constAsDefaults !== 'never' &&
|
|
219
218
|
!constIsAjvDataReference(schema)
|
|
220
219
|
) {
|
|
@@ -234,6 +233,19 @@ export function computeDefaults<T = any, S extends StrictRJSFSchema = RJSFSchema
|
|
|
234
233
|
updatedRecurseList = _recurseList.concat(refName!);
|
|
235
234
|
schemaToCompute = findSchemaDefinition<S>(refName, rootSchema);
|
|
236
235
|
}
|
|
236
|
+
|
|
237
|
+
// If the referenced schema exists and parentDefaults is not set
|
|
238
|
+
// Then set the defaults from the current schema for the referenced schema
|
|
239
|
+
if (schemaToCompute && !defaults) {
|
|
240
|
+
defaults = schema.default as T | undefined;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// If shouldMergeDefaultsIntoFormData is true
|
|
244
|
+
// And the schemaToCompute is set and the rawFormData is not an object
|
|
245
|
+
// Then set the formData to the rawFormData
|
|
246
|
+
if (shouldMergeDefaultsIntoFormData && schemaToCompute && !isObject(rawFormData)) {
|
|
247
|
+
formData = rawFormData as T;
|
|
248
|
+
}
|
|
237
249
|
} else if (DEPENDENCIES_KEY in schema) {
|
|
238
250
|
// Get the default if set from properties to ensure the dependencies conditions are resolved based on it
|
|
239
251
|
const defaultFormData: T = {
|