Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 03ceb2aa
authored
Mar 21, 2025
by
Netfan
Committed by
GitHub
Mar 21, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: default value for nested fields (#5763)
1 parent
39888ceb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
17 deletions
packages/@core/base/shared/package.json
packages/@core/base/shared/src/utils/index.ts
packages/@core/ui-kit/form-ui/src/use-form-context.ts
pnpm-lock.yaml
pnpm-workspace.yaml
packages/@core/base/shared/package.json
View file @
03ceb2a
...
@@ -88,6 +88,7 @@
...
@@ -88,6 +88,7 @@
"lodash.clonedeep"
:
"catalog:"
,
"lodash.clonedeep"
:
"catalog:"
,
"lodash.get"
:
"catalog:"
,
"lodash.get"
:
"catalog:"
,
"lodash.isequal"
:
"catalog:"
,
"lodash.isequal"
:
"catalog:"
,
"lodash.set"
:
"catalog:"
,
"nprogress"
:
"catalog:"
,
"nprogress"
:
"catalog:"
,
"tailwind-merge"
:
"catalog:"
,
"tailwind-merge"
:
"catalog:"
,
"theme-colors"
:
"catalog:"
"theme-colors"
:
"catalog:"
...
@@ -96,6 +97,7 @@
...
@@ -96,6 +97,7 @@
"@types/lodash.clonedeep"
:
"catalog:"
,
"@types/lodash.clonedeep"
:
"catalog:"
,
"@types/lodash.get"
:
"catalog:"
,
"@types/lodash.get"
:
"catalog:"
,
"@types/lodash.isequal"
:
"catalog:"
,
"@types/lodash.isequal"
:
"catalog:"
,
"@types/lodash.set"
:
"catalog:"
,
"@types/nprogress"
:
"catalog:"
"@types/nprogress"
:
"catalog:"
}
}
}
}
packages/@core/base/shared/src/utils/index.ts
View file @
03ceb2a
...
@@ -17,3 +17,4 @@ export * from './window';
...
@@ -17,3 +17,4 @@ export * from './window';
export
{
default
as
cloneDeep
}
from
'lodash.clonedeep'
;
export
{
default
as
cloneDeep
}
from
'lodash.clonedeep'
;
export
{
default
as
get
}
from
'lodash.get'
;
export
{
default
as
get
}
from
'lodash.get'
;
export
{
default
as
isEqual
}
from
'lodash.isequal'
;
export
{
default
as
isEqual
}
from
'lodash.isequal'
;
export
{
default
as
set
}
from
'lodash.set'
;
packages/@core/ui-kit/form-ui/src/use-form-context.ts
View file @
03ceb2a
...
@@ -7,7 +7,7 @@ import type { ExtendedFormApi, FormActions, VbenFormProps } from './types';
...
@@ -7,7 +7,7 @@ import type { ExtendedFormApi, FormActions, VbenFormProps } from './types';
import
{
computed
,
unref
,
useSlots
}
from
'vue'
;
import
{
computed
,
unref
,
useSlots
}
from
'vue'
;
import
{
createContext
}
from
'@vben-core/shadcn-ui'
;
import
{
createContext
}
from
'@vben-core/shadcn-ui'
;
import
{
isString
}
from
'@vben-core/shared/utils'
;
import
{
isString
,
mergeWithArrayOverride
,
set
}
from
'@vben-core/shared/utils'
;
import
{
useForm
}
from
'vee-validate'
;
import
{
useForm
}
from
'vee-validate'
;
import
{
object
}
from
'zod'
;
import
{
object
}
from
'zod'
;
...
@@ -50,7 +50,7 @@ export function useFormInitial(
...
@@ -50,7 +50,7 @@ export function useFormInitial(
const
zodObject
:
ZodRawShape
=
{};
const
zodObject
:
ZodRawShape
=
{};
(
unref
(
props
).
schema
||
[]).
forEach
((
item
)
=>
{
(
unref
(
props
).
schema
||
[]).
forEach
((
item
)
=>
{
if
(
Reflect
.
has
(
item
,
'defaultValue'
))
{
if
(
Reflect
.
has
(
item
,
'defaultValue'
))
{
initialValues
[
item
.
fieldName
]
=
item
.
defaultValue
;
set
(
initialValues
,
item
.
fieldName
,
item
.
defaultValue
)
;
}
else
if
(
item
.
rules
&&
!
isString
(
item
.
rules
))
{
}
else
if
(
item
.
rules
&&
!
isString
(
item
.
rules
))
{
zodObject
[
item
.
fieldName
]
=
item
.
rules
;
zodObject
[
item
.
fieldName
]
=
item
.
rules
;
}
}
...
@@ -58,7 +58,11 @@ export function useFormInitial(
...
@@ -58,7 +58,11 @@ export function useFormInitial(
const
schemaInitialValues
=
getDefaultsForSchema
(
object
(
zodObject
));
const
schemaInitialValues
=
getDefaultsForSchema
(
object
(
zodObject
));
return
{
...
initialValues
,
...
schemaInitialValues
};
const
zodDefaults
:
Record
<
string
,
any
>
=
{};
for
(
const
key
in
schemaInitialValues
)
{
set
(
zodDefaults
,
key
,
schemaInitialValues
[
key
]);
}
return
mergeWithArrayOverride
(
initialValues
,
zodDefaults
);
}
}
return
{
return
{
...
...
pnpm-lock.yaml
View file @
03ceb2a
...
@@ -96,6 +96,9 @@ catalogs:
...
@@ -96,6 +96,9 @@ catalogs:
'
@types/lodash.isequal'
:
'
@types/lodash.isequal'
:
specifier
:
^4.5.8
specifier
:
^4.5.8
version
:
4.5.8
version
:
4.5.8
'
@types/lodash.set'
:
specifier
:
^4.3.2
version
:
4.3.9
'
@types/node'
:
'
@types/node'
:
specifier
:
^22.13.10
specifier
:
^22.13.10
version
:
22.13.10
version
:
22.13.10
...
@@ -306,6 +309,9 @@ catalogs:
...
@@ -306,6 +309,9 @@ catalogs:
lodash.isequal
:
lodash.isequal
:
specifier
:
^4.5.0
specifier
:
^4.5.0
version
:
4.5.0
version
:
4.5.0
lodash.set
:
specifier
:
^4.3.2
version
:
4.3.2
lucide-vue-next
:
lucide-vue-next
:
specifier
:
^0.469.0
specifier
:
^0.469.0
version
:
0.469.0
version
:
0.469.0
...
@@ -1240,6 +1246,9 @@ importers:
...
@@ -1240,6 +1246,9 @@ importers:
lodash.isequal
:
lodash.isequal
:
specifier
:
'
catalog:'
specifier
:
'
catalog:'
version
:
4.5.0
version
:
4.5.0
lodash.set
:
specifier
:
'
catalog:'
version
:
4.3.2
nprogress
:
nprogress
:
specifier
:
'
catalog:'
specifier
:
'
catalog:'
version
:
0.2.0
version
:
0.2.0
...
@@ -1259,6 +1268,9 @@ importers:
...
@@ -1259,6 +1268,9 @@ importers:
'
@types/lodash.isequal'
:
'
@types/lodash.isequal'
:
specifier
:
'
catalog:'
specifier
:
'
catalog:'
version
:
4.5.8
version
:
4.5.8
'
@types/lodash.set'
:
specifier
:
'
catalog:'
version
:
4.3.9
'
@types/nprogress'
:
'
@types/nprogress'
:
specifier
:
'
catalog:'
specifier
:
'
catalog:'
version
:
0.2.3
version
:
0.2.3
...
@@ -3534,22 +3546,22 @@ packages:
...
@@ -3534,22 +3546,22 @@ packages:
resolution
:
{
integrity
:
sha512-nmG512G8QOABsserleechwHGZxzKSAlggGf9hQX0nltvSwyKNVuB/4o6iFeG2OnjXK253r8p8eSDOZf8PgFdWw==
}
resolution
:
{
integrity
:
sha512-nmG512G8QOABsserleechwHGZxzKSAlggGf9hQX0nltvSwyKNVuB/4o6iFeG2OnjXK253r8p8eSDOZf8PgFdWw==
}
engines
:
{
node
:
'
>=
16'
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/message-compiler@11.0.0-rc.1'
:
resolution
:
{
integrity
:
sha512-TGw2uBfuTFTegZf/BHtUQBEKxl7Q/dVGLoqRIdw8lFsp9g/53sYn5iD+0HxIzdYjbWL6BTJMXCPUHp9PxDTRPw==
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/message-compiler@11.1.2'
:
'
@intlify/message-compiler@11.1.2'
:
resolution
:
{
integrity
:
sha512-T/xbNDzi+Yv0Qn2Dfz2CWCAJiwNgU5d95EhhAEf4YmOgjCKktpfpiUSmLcBvK1CtLpPQ85AMMQk/2NCcXnNj1g==
}
resolution
:
{
integrity
:
sha512-T/xbNDzi+Yv0Qn2Dfz2CWCAJiwNgU5d95EhhAEf4YmOgjCKktpfpiUSmLcBvK1CtLpPQ85AMMQk/2NCcXnNj1g==
}
engines
:
{
node
:
'
>=
16'
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/
shared@11.0.0-rc.1
'
:
'
@intlify/
message-compiler@12.0.0-alpha.2
'
:
resolution
:
{
integrity
:
sha512-
8tR1xe7ZEbkabTuE/tNhzpolygUn9OaYp9yuYAF4MgDNZg06C3Qny80bes2/e9/Wm3aVkPUlCw6WgU7mQd0yE
g==
}
resolution
:
{
integrity
:
sha512-
PD9C+oQbb7BF52hec0+vLnScaFkvnfX+R7zSbODYuRo/E2niAtGmHd0wPvEMsDhf9Z9b8f/qyDsVeZnD/ya9U
g==
}
engines
:
{
node
:
'
>=
16'
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/shared@11.1.2'
:
'
@intlify/shared@11.1.2'
:
resolution
:
{
integrity
:
sha512-dF2iMMy8P9uKVHV/20LA1ulFLL+MKSbfMiixSmn6fpwqzvix38OIc7ebgnFbBqElvghZCW9ACtzKTGKsTGTWGA==
}
resolution
:
{
integrity
:
sha512-dF2iMMy8P9uKVHV/20LA1ulFLL+MKSbfMiixSmn6fpwqzvix38OIc7ebgnFbBqElvghZCW9ACtzKTGKsTGTWGA==
}
engines
:
{
node
:
'
>=
16'
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/shared@12.0.0-alpha.2'
:
resolution
:
{
integrity
:
sha512-P2DULVX9nz3y8zKNqLw9Es1aAgQ1JGC+kgpx5q7yLmrnAKkPR5MybQWoEhxanefNJgUY5ehsgo+GKif59SrncA==
}
engines
:
{
node
:
'
>=
16'
}
'
@intlify/unplugin-vue-i18n@6.0.3'
:
'
@intlify/unplugin-vue-i18n@6.0.3'
:
resolution
:
{
integrity
:
sha512-9ZDjBlhUHtgjRl23TVcgfJttgu8cNepwVhWvOv3mUMRDAhjW0pur1mWKEUKr1I8PNwE4Gvv2IQ1xcl4RL0nG0g==
}
resolution
:
{
integrity
:
sha512-9ZDjBlhUHtgjRl23TVcgfJttgu8cNepwVhWvOv3mUMRDAhjW0pur1mWKEUKr1I8PNwE4Gvv2IQ1xcl4RL0nG0g==
}
engines
:
{
node
:
'
>=
18'
}
engines
:
{
node
:
'
>=
18'
}
...
@@ -4277,6 +4289,9 @@ packages:
...
@@ -4277,6 +4289,9 @@ packages:
'
@types/lodash.isequal@4.5.8'
:
'
@types/lodash.isequal@4.5.8'
:
resolution
:
{
integrity
:
sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==
}
resolution
:
{
integrity
:
sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==
}
'
@types/lodash.set@4.3.9'
:
resolution
:
{
integrity
:
sha512-KOxyNkZpbaggVmqbpr82N2tDVTx05/3/j0f50Es1prxrWB0XYf9p3QNxqcbWb7P1Q9wlvsUSlCFnwlPCIJ46PQ==
}
'
@types/lodash@4.17.16'
:
'
@types/lodash@4.17.16'
:
resolution
:
{
integrity
:
sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==
}
resolution
:
{
integrity
:
sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==
}
...
@@ -7318,6 +7333,9 @@ packages:
...
@@ -7318,6 +7333,9 @@ packages:
lodash.once@4.1.1
:
lodash.once@4.1.1
:
resolution
:
{
integrity
:
sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==
}
resolution
:
{
integrity
:
sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==
}
lodash.set@4.3.2
:
resolution
:
{
integrity
:
sha512-4hNPN5jlm/N/HLMCO43v8BXKq9Z7QdAGc/VGrRD61w8gN9g/6jF9A4L1pbUgBLCffi0w9VsXfTOij5x8iTyFvg==
}
lodash.snakecase@4.1.1
:
lodash.snakecase@4.1.1
:
resolution
:
{
integrity
:
sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==
}
resolution
:
{
integrity
:
sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==
}
...
@@ -12279,8 +12297,8 @@ snapshots:
...
@@ -12279,8 +12297,8 @@ snapshots:
'
@intlify/bundle-utils@10.0.0(vue-i18n@11.1.2(vue@3.5.13(typescript@5.8.2)))'
:
'
@intlify/bundle-utils@10.0.0(vue-i18n@11.1.2(vue@3.5.13(typescript@5.8.2)))'
:
dependencies
:
dependencies
:
'
@intlify/message-compiler'
:
1
1.0.0-rc.1
'
@intlify/message-compiler'
:
1
2.0.0-alpha.2
'
@intlify/shared'
:
1
1.0.0-rc.1
'
@intlify/shared'
:
1
2.0.0-alpha.2
acorn
:
8.14.1
acorn
:
8.14.1
escodegen
:
2.1.0
escodegen
:
2.1.0
estree-walker
:
2.0.2
estree-walker
:
2.0.2
...
@@ -12296,20 +12314,20 @@ snapshots:
...
@@ -12296,20 +12314,20 @@ snapshots:
'
@intlify/message-compiler'
:
11.1.2
'
@intlify/message-compiler'
:
11.1.2
'
@intlify/shared'
:
11.1.2
'
@intlify/shared'
:
11.1.2
'
@intlify/message-compiler@11.0.0-rc.1'
:
dependencies
:
'
@intlify/shared'
:
11.0.0-rc.1
source-map-js
:
1.2.1
'
@intlify/message-compiler@11.1.2'
:
'
@intlify/message-compiler@11.1.2'
:
dependencies
:
dependencies
:
'
@intlify/shared'
:
11.1.2
'
@intlify/shared'
:
11.1.2
source-map-js
:
1.2.1
source-map-js
:
1.2.1
'
@intlify/shared@11.0.0-rc.1'
:
{}
'
@intlify/message-compiler@12.0.0-alpha.2'
:
dependencies
:
'
@intlify/shared'
:
12.0.0-alpha.2
source-map-js
:
1.2.1
'
@intlify/shared@11.1.2'
:
{}
'
@intlify/shared@11.1.2'
:
{}
'
@intlify/shared@12.0.0-alpha.2'
:
{}
'
@intlify/unplugin-vue-i18n@6.0.3(@vue/compiler-dom@3.5.13)(eslint@9.22.0(jiti@2.4.2))(rollup@4.35.0)(typescript@5.8.2)(vue-i18n@11.1.2(vue@3.5.13(typescript@5.8.2)))(vue@3.5.13(typescript@5.8.2))'
:
'
@intlify/unplugin-vue-i18n@6.0.3(@vue/compiler-dom@3.5.13)(eslint@9.22.0(jiti@2.4.2))(rollup@4.35.0)(typescript@5.8.2)(vue-i18n@11.1.2(vue@3.5.13(typescript@5.8.2)))(vue@3.5.13(typescript@5.8.2))'
:
dependencies
:
dependencies
:
'
@eslint-community/eslint-utils'
:
4.4.1(eslint@9.22.0(jiti@2.4.2))
'
@eslint-community/eslint-utils'
:
4.4.1(eslint@9.22.0(jiti@2.4.2))
...
@@ -13103,6 +13121,10 @@ snapshots:
...
@@ -13103,6 +13121,10 @@ snapshots:
dependencies
:
dependencies
:
'
@types/lodash'
:
4.17.16
'
@types/lodash'
:
4.17.16
'
@types/lodash.set@4.3.9'
:
dependencies
:
'
@types/lodash'
:
4.17.16
'
@types/lodash@4.17.16'
:
{}
'
@types/lodash@4.17.16'
:
{}
'
@types/markdown-it@14.1.2'
:
'
@types/markdown-it@14.1.2'
:
...
@@ -16558,6 +16580,8 @@ snapshots:
...
@@ -16558,6 +16580,8 @@ snapshots:
lodash.once@4.1.1
:
{}
lodash.once@4.1.1
:
{}
lodash.set@4.3.2
:
{}
lodash.snakecase@4.1.1
:
{}
lodash.snakecase@4.1.1
:
{}
lodash.sortby@4.7.0
:
{}
lodash.sortby@4.7.0
:
{}
...
...
pnpm-workspace.yaml
View file @
03ceb2a
...
@@ -45,6 +45,7 @@ catalog:
...
@@ -45,6 +45,7 @@ catalog:
'
@types/lodash.clonedeep'
:
^4.5.9
'
@types/lodash.clonedeep'
:
^4.5.9
'
@types/lodash.get'
:
^4.4.9
'
@types/lodash.get'
:
^4.4.9
'
@types/lodash.isequal'
:
^4.5.8
'
@types/lodash.isequal'
:
^4.5.8
'
@types/lodash.set'
:
^4.3.2
'
@types/node'
:
^22.13.10
'
@types/node'
:
^22.13.10
'
@types/nprogress'
:
^0.2.3
'
@types/nprogress'
:
^0.2.3
'
@types/postcss-import'
:
^14.0.3
'
@types/postcss-import'
:
^14.0.3
...
@@ -116,6 +117,7 @@ catalog:
...
@@ -116,6 +117,7 @@ catalog:
lint-staged
:
^15.4.3
lint-staged
:
^15.4.3
lodash.clonedeep
:
^4.5.0
lodash.clonedeep
:
^4.5.0
lodash.get
:
^4.4.2
lodash.get
:
^4.4.2
lodash.set
:
^4.3.2
lodash.isequal
:
^4.5.0
lodash.isequal
:
^4.5.0
lucide-vue-next
:
^0.469.0
lucide-vue-next
:
^0.469.0
medium-zoom
:
^1.1.0
medium-zoom
:
^1.1.0
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment