1
- import { App , defineComponent , inject , provide , Plugin , VNode } from 'vue' ;
1
+ import { App , defineComponent , inject , provide , Plugin , VNode , ExtractPropTypes } from 'vue' ;
2
2
import Select , { SelectProps } from '../select' ;
3
3
import Input from '../input' ;
4
4
import InputElement from './InputElement' ;
@@ -7,26 +7,32 @@ import { defaultConfigProvider } from '../config-provider';
7
7
import { getComponent , getOptionProps , isValidElement , getSlot } from '../_util/props-util' ;
8
8
import Omit from 'omit.js' ;
9
9
import warning from '../_util/warning' ;
10
-
11
- const { Option , OptGroup } = Select ;
10
+ import Option from './Option' ;
11
+ import OptGroup from './OptGroup' ;
12
12
13
13
function isSelectOptionOrSelectOptGroup ( child : any ) : boolean {
14
14
return child ?. type ?. isSelectOption || child ?. type ?. isSelectOptGroup ;
15
15
}
16
16
17
- const AutoCompleteProps = {
17
+ const autoCompleteProps = {
18
18
...SelectProps ( ) ,
19
19
dataSource : PropTypes . array ,
20
20
dropdownMenuStyle : PropTypes . style ,
21
21
optionLabelProp : PropTypes . string ,
22
22
dropdownMatchSelectWidth : PropTypes . looseBool ,
23
23
} ;
24
24
25
+ export type AutoCompleteProps = Partial < ExtractPropTypes < typeof autoCompleteProps > > ;
26
+
27
+ export const AutoCompleteOption = Option ;
28
+
29
+ export const AutoCompleteOptGroup = OptGroup ;
30
+
25
31
const AutoComplete = defineComponent ( {
26
32
name : 'AAutoComplete' ,
27
33
inheritAttrs : false ,
28
34
props : {
29
- ...AutoCompleteProps ,
35
+ ...autoCompleteProps ,
30
36
prefixCls : PropTypes . string . def ( 'ant-select' ) ,
31
37
showSearch : PropTypes . looseBool ,
32
38
transitionName : PropTypes . string . def ( 'slide-up' ) ,
@@ -38,8 +44,8 @@ const AutoComplete = defineComponent({
38
44
defaultActiveFirstOption : PropTypes . looseBool . def ( true ) ,
39
45
} ,
40
46
emits : [ 'change' , 'select' , 'focus' , 'blur' ] ,
41
- Option : { ... Option , name : 'AAutoCompleteOption' } ,
42
- OptGroup : { ... OptGroup , name : 'AAutoCompleteOptGroup' } ,
47
+ Option,
48
+ OptGroup,
43
49
setup ( props , { slots } ) {
44
50
warning (
45
51
! ( props . dataSource !== undefined || 'dataSource' in slots ) ,
@@ -142,8 +148,8 @@ const AutoComplete = defineComponent({
142
148
/* istanbul ignore next */
143
149
AutoComplete . install = function ( app : App ) {
144
150
app . component ( AutoComplete . name , AutoComplete ) ;
145
- app . component ( AutoComplete . Option . name , AutoComplete . Option ) ;
146
- app . component ( AutoComplete . OptGroup . name , AutoComplete . OptGroup ) ;
151
+ app . component ( AutoComplete . Option . displayName , AutoComplete . Option ) ;
152
+ app . component ( AutoComplete . OptGroup . displayName , AutoComplete . OptGroup ) ;
147
153
return app ;
148
154
} ;
149
155
0 commit comments