1- import { App , defineComponent , inject , provide , Plugin , VNode } from 'vue' ;
1+ import { App , defineComponent , inject , provide , Plugin , VNode , ExtractPropTypes } from 'vue' ;
22import Select , { SelectProps } from '../select' ;
33import Input from '../input' ;
44import InputElement from './InputElement' ;
@@ -7,26 +7,32 @@ import { defaultConfigProvider } from '../config-provider';
77import { getComponent , getOptionProps , isValidElement , getSlot } from '../_util/props-util' ;
88import Omit from 'omit.js' ;
99import warning from '../_util/warning' ;
10-
11- const { Option , OptGroup } = Select ;
10+ import Option from './Option' ;
11+ import OptGroup from './OptGroup' ;
1212
1313function isSelectOptionOrSelectOptGroup ( child : any ) : boolean {
1414 return child ?. type ?. isSelectOption || child ?. type ?. isSelectOptGroup ;
1515}
1616
17- const AutoCompleteProps = {
17+ const autoCompleteProps = {
1818 ...SelectProps ( ) ,
1919 dataSource : PropTypes . array ,
2020 dropdownMenuStyle : PropTypes . style ,
2121 optionLabelProp : PropTypes . string ,
2222 dropdownMatchSelectWidth : PropTypes . looseBool ,
2323} ;
2424
25+ export type AutoCompleteProps = Partial < ExtractPropTypes < typeof autoCompleteProps > > ;
26+
27+ export const AutoCompleteOption = Option ;
28+
29+ export const AutoCompleteOptGroup = OptGroup ;
30+
2531const AutoComplete = defineComponent ( {
2632 name : 'AAutoComplete' ,
2733 inheritAttrs : false ,
2834 props : {
29- ...AutoCompleteProps ,
35+ ...autoCompleteProps ,
3036 prefixCls : PropTypes . string . def ( 'ant-select' ) ,
3137 showSearch : PropTypes . looseBool ,
3238 transitionName : PropTypes . string . def ( 'slide-up' ) ,
@@ -38,8 +44,8 @@ const AutoComplete = defineComponent({
3844 defaultActiveFirstOption : PropTypes . looseBool . def ( true ) ,
3945 } ,
4046 emits : [ 'change' , 'select' , 'focus' , 'blur' ] ,
41- Option : { ... Option , name : 'AAutoCompleteOption' } ,
42- OptGroup : { ... OptGroup , name : 'AAutoCompleteOptGroup' } ,
47+ Option,
48+ OptGroup,
4349 setup ( props , { slots } ) {
4450 warning (
4551 ! ( props . dataSource !== undefined || 'dataSource' in slots ) ,
@@ -142,8 +148,8 @@ const AutoComplete = defineComponent({
142148/* istanbul ignore next */
143149AutoComplete . install = function ( app : App ) {
144150 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 ) ;
147153 return app ;
148154} ;
149155
0 commit comments