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 0c73cf8d
authored
Sep 18, 2024
by
Vben
Committed by
GitHub
Sep 18, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: fixed the form component componentProps using the function that did not mee…
…t expectations (#4426)
1 parent
834cb4c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
packages/@core/ui-kit/form-ui/src/form-render/form.vue
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
View file @
0c73cf8
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
ZodType
}
from
'zod'
;
import
type
{
ZodType
}
from
'zod'
;
import
type
{
FormSchema
}
from
'../types'
;
import
type
{
FormSchema
,
MaybeComponentProps
}
from
'../types'
;
import
{
computed
}
from
'vue'
;
import
{
computed
}
from
'vue'
;
...
@@ -26,6 +26,7 @@ import { isEventObjectLike } from './helper';
...
@@ -26,6 +26,7 @@ import { isEventObjectLike } from './helper';
interface
Props
extends
FormSchema
{}
interface
Props
extends
FormSchema
{}
const
{
const
{
commonComponentProps
,
component
,
component
,
componentProps
,
componentProps
,
dependencies
,
dependencies
,
...
@@ -38,7 +39,11 @@ const {
...
@@ -38,7 +39,11 @@ const {
labelWidth
,
labelWidth
,
renderComponentContent
,
renderComponentContent
,
rules
,
rules
,
}
=
defineProps
<
Props
>
();
}
=
defineProps
<
{
commonComponentProps
:
MaybeComponentProps
;
}
&
Props
>
();
const
{
componentBindEventMap
,
componentMap
,
isVertical
}
=
useFormContext
();
const
{
componentBindEventMap
,
componentMap
,
isVertical
}
=
useFormContext
();
const
formRenderProps
=
injectRenderFormProps
();
const
formRenderProps
=
injectRenderFormProps
();
...
@@ -133,6 +138,7 @@ const computedProps = computed(() => {
...
@@ -133,6 +138,7 @@ const computedProps = computed(() => {
:
componentProps
;
:
componentProps
;
return
{
return
{
...
commonComponentProps
,
...
finalComponentProps
,
...
finalComponentProps
,
...
dynamicComponentProps
.
value
,
...
dynamicComponentProps
.
value
,
};
};
...
...
packages/@core/ui-kit/form-ui/src/form-render/form.vue
View file @
0c73cf8
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
GenericObject
}
from
'vee-validate'
;
import
type
{
ZodTypeAny
}
from
'zod'
;
import
type
{
ZodTypeAny
}
from
'zod'
;
import
type
{
FormRenderProps
,
FormSchema
,
FormShape
}
from
'../types'
;
import
type
{
FormRenderProps
,
FormSchema
,
FormShape
}
from
'../types'
;
...
@@ -7,7 +6,9 @@ import type { FormRenderProps, FormSchema, FormShape } from '../types';
...
@@ -7,7 +6,9 @@ import type { FormRenderProps, FormSchema, FormShape } from '../types';
import
{
computed
}
from
'vue'
;
import
{
computed
}
from
'vue'
;
import
{
Form
}
from
'@vben-core/shadcn-ui'
;
import
{
Form
}
from
'@vben-core/shadcn-ui'
;
import
{
cn
,
isString
,
merge
}
from
'@vben-core/shared/utils'
;
import
{
cn
,
isString
}
from
'@vben-core/shared/utils'
;
import
{
type
GenericObject
}
from
'vee-validate'
;
import
{
provideFormRenderProps
}
from
'./context'
;
import
{
provideFormRenderProps
}
from
'./context'
;
import
{
useExpandable
}
from
'./expandable'
;
import
{
useExpandable
}
from
'./expandable'
;
...
@@ -70,7 +71,8 @@ const formCollapsed = computed(() => {
...
@@ -70,7 +71,8 @@ const formCollapsed = computed(() => {
return
props
.
collapsed
&&
isCalculated
.
value
;
return
props
.
collapsed
&&
isCalculated
.
value
;
});
});
const
computedSchema
=
computed
(():
FormSchema
[]
=>
{
const
computedSchema
=
computed
(
():
({
commonComponentProps
:
Record
<
string
,
any
>
}
&
FormSchema
)[]
=>
{
const
{
const
{
componentProps
=
{},
componentProps
=
{},
controlClass
=
''
,
controlClass
=
''
,
...
@@ -83,7 +85,7 @@ const computedSchema = computed((): FormSchema[] => {
...
@@ -83,7 +85,7 @@ const computedSchema = computed((): FormSchema[] => {
labelWidth
=
100
,
labelWidth
=
100
,
wrapperClass
=
''
,
wrapperClass
=
''
,
}
=
props
.
commonConfig
;
}
=
props
.
commonConfig
;
return
(
props
.
schema
||
[]).
map
((
schema
,
index
):
FormSchema
=>
{
return
(
props
.
schema
||
[]).
map
((
schema
,
index
)
=>
{
const
keepIndex
=
keepFormItemIndex
.
value
;
const
keepIndex
=
keepFormItemIndex
.
value
;
const
hidden
=
const
hidden
=
...
@@ -99,7 +101,8 @@ const computedSchema = computed((): FormSchema[] => {
...
@@ -99,7 +101,8 @@ const computedSchema = computed((): FormSchema[] => {
labelWidth
,
labelWidth
,
wrapperClass
,
wrapperClass
,
...
schema
,
...
schema
,
componentProps
:
merge
({},
schema
.
componentProps
,
componentProps
),
commonComponentProps
:
componentProps
,
componentProps
:
schema
.
componentProps
,
controlClass
:
cn
(
controlClass
,
schema
.
controlClass
),
controlClass
:
cn
(
controlClass
,
schema
.
controlClass
),
formFieldProps
:
{
formFieldProps
:
{
...
formFieldProps
,
...
formFieldProps
,
...
@@ -114,7 +117,8 @@ const computedSchema = computed((): FormSchema[] => {
...
@@ -114,7 +117,8 @@ const computedSchema = computed((): FormSchema[] => {
labelClass
:
cn
(
labelClass
,
schema
.
labelClass
),
labelClass
:
cn
(
labelClass
,
schema
.
labelClass
),
};
};
});
});
});
},
);
</
script
>
</
script
>
<
template
>
<
template
>
...
...
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