1
1
import { defineComponent , type App , DefineComponent , Plugin , PropType , ExtractPropTypes } from 'vue' ;
2
+ import type { VueNode } from '@ant-design-vue/pro-utils' ;
2
3
import { omit , pick } from 'lodash-es' ;
3
4
import { proFieldProps } from '@ant-design-vue/pro-field' ;
4
- import type { SelectProps } from 'ant-design-vue/es/select' ;
5
+ import type { SelectProps , DefaultOptionType } from 'ant-design-vue/es/select' ;
5
6
import ProFormField from '../Field' ;
6
7
import { proFormGridConfig , extendsProps } from '../../typings' ;
7
8
import { proFormItemProps } from '../FormItem' ;
@@ -17,6 +18,9 @@ const props = {
17
18
options : {
18
19
type : Array as PropType < SelectProps [ 'options' ] > ,
19
20
} ,
21
+ option : {
22
+ type : Function as PropType < ( props : DefaultOptionType ) => VueNode > ,
23
+ } ,
20
24
} ;
21
25
22
26
export type ProFormSelectProps = Partial < ExtractPropTypes < typeof props > > ;
@@ -26,7 +30,7 @@ export const ProFormSelect = defineComponent({
26
30
inheritAttrs : false ,
27
31
props,
28
32
slots : [ 'option' ] ,
29
- setup ( props ) {
33
+ setup ( props , { slots } ) {
30
34
const formItemProps = {
31
35
...props . formItemProps ,
32
36
...pick ( props , Object . keys ( proFormItemProps ) ) ,
@@ -38,6 +42,7 @@ export const ProFormSelect = defineComponent({
38
42
fieldProps = { {
39
43
...props . fieldProps ,
40
44
options : props . options ,
45
+ option : props . option || slots . option ,
41
46
} }
42
47
filedConfig = { { valueType : 'select' } }
43
48
colProps = { props . colProps }
0 commit comments