1
- import type { App , VNode , ExtractPropTypes } from 'vue' ;
1
+ import type { App , VNode , ExtractPropTypes , CSSProperties , PropType } from 'vue' ;
2
2
import { defineComponent , ref } from 'vue' ;
3
3
import Select , { selectProps } from '../select' ;
4
- import PropTypes from '../_util/vue-types' ;
5
4
import { isValidElement , flattenChildren } from '../_util/props-util' ;
6
5
import warning from '../_util/warning' ;
7
6
import Option from './Option' ;
@@ -13,15 +12,27 @@ function isSelectOptionOrSelectOptGroup(child: any): boolean {
13
12
return child ?. type ?. isSelectOption || child ?. type ?. isSelectOptGroup ;
14
13
}
15
14
16
- export const autoCompleteProps = {
15
+ export const autoCompleteProps = ( ) => ( {
17
16
...omit ( selectProps ( ) , [ 'loading' , 'mode' , 'optionLabelProp' , 'labelInValue' ] ) ,
18
- dataSource : PropTypes . array ,
19
- dropdownMenuStyle : PropTypes . style ,
20
- // optionLabelProp: PropTypes.string,
17
+ dataSource : Array as PropType < { value : any ; text : any } [ ] | string [ ] > ,
18
+ dropdownMenuStyle : {
19
+ type : Object as PropType < CSSProperties > ,
20
+ default : undefined as CSSProperties ,
21
+ } ,
22
+ // optionLabelProp: String,
21
23
dropdownMatchSelectWidth : { type : [ Number , Boolean ] , default : true } ,
22
- } ;
24
+ prefixCls : String ,
25
+ showSearch : { type : Boolean , default : undefined } ,
26
+ transitionName : String ,
27
+ choiceTransitionName : { type : String , default : 'zoom' } ,
28
+ autofocus : { type : Boolean , default : undefined } ,
29
+ backfill : { type : Boolean , default : undefined } ,
30
+ // optionLabelProp: PropTypes.string.def('children'),
31
+ filterOption : { type : [ Boolean , Function ] , default : false } ,
32
+ defaultActiveFirstOption : { type : Boolean , default : true } ,
33
+ } ) ;
23
34
24
- export type AutoCompleteProps = Partial < ExtractPropTypes < typeof autoCompleteProps > > ;
35
+ export type AutoCompleteProps = Partial < ExtractPropTypes < ReturnType < typeof autoCompleteProps > > > ;
25
36
26
37
export const AutoCompleteOption = Option ;
27
38
@@ -30,19 +41,8 @@ export const AutoCompleteOptGroup = OptGroup;
30
41
const AutoComplete = defineComponent ( {
31
42
name : 'AAutoComplete' ,
32
43
inheritAttrs : false ,
33
- props : {
34
- ...autoCompleteProps ,
35
- prefixCls : PropTypes . string ,
36
- showSearch : PropTypes . looseBool ,
37
- transitionName : PropTypes . string ,
38
- choiceTransitionName : PropTypes . string . def ( 'zoom' ) ,
39
- autofocus : PropTypes . looseBool ,
40
- backfill : PropTypes . looseBool ,
41
- // optionLabelProp: PropTypes.string.def('children'),
42
- filterOption : PropTypes . oneOfType ( [ PropTypes . looseBool , PropTypes . func ] ) . def ( false ) ,
43
- defaultActiveFirstOption : PropTypes . looseBool . def ( true ) ,
44
- } ,
45
- emits : [ 'change' , 'select' , 'focus' , 'blur' ] ,
44
+ props : autoCompleteProps ( ) ,
45
+ // emits: ['change', 'select', 'focus', 'blur'],
46
46
slots : [ 'option' ] ,
47
47
setup ( props , { slots, attrs, expose } ) {
48
48
warning (
0 commit comments