1- import type { App , VNode , ExtractPropTypes } from 'vue' ;
1+ import type { App , VNode , ExtractPropTypes , CSSProperties , PropType } from 'vue' ;
22import { defineComponent , ref } from 'vue' ;
33import Select , { selectProps } from '../select' ;
4- import PropTypes from '../_util/vue-types' ;
54import { isValidElement , flattenChildren } from '../_util/props-util' ;
65import warning from '../_util/warning' ;
76import Option from './Option' ;
@@ -13,15 +12,27 @@ function isSelectOptionOrSelectOptGroup(child: any): boolean {
1312 return child ?. type ?. isSelectOption || child ?. type ?. isSelectOptGroup ;
1413}
1514
16- export const autoCompleteProps = {
15+ export const autoCompleteProps = ( ) => ( {
1716 ...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,
2123 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+ } ) ;
2334
24- export type AutoCompleteProps = Partial < ExtractPropTypes < typeof autoCompleteProps > > ;
35+ export type AutoCompleteProps = Partial < ExtractPropTypes < ReturnType < typeof autoCompleteProps > > > ;
2536
2637export const AutoCompleteOption = Option ;
2738
@@ -30,19 +41,8 @@ export const AutoCompleteOptGroup = OptGroup;
3041const AutoComplete = defineComponent ( {
3142 name : 'AAutoComplete' ,
3243 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'],
4646 slots : [ 'option' ] ,
4747 setup ( props , { slots, attrs, expose } ) {
4848 warning (
0 commit comments