diff --git a/src/auto-complete/index.ts b/src/auto-complete/index.ts index ae80014a922..34278fd2642 100644 --- a/src/auto-complete/index.ts +++ b/src/auto-complete/index.ts @@ -1,6 +1,7 @@ export { autoCompleteProps, default as NAutoComplete } from './src/AutoComplete' export type { AutoCompleteProps } from './src/AutoComplete' export type { + AutoCompleteDefaultSlotOptions, AutoCompleteGroupOption, AutoCompleteInst, AutoCompleteOption diff --git a/src/auto-complete/src/AutoComplete.tsx b/src/auto-complete/src/AutoComplete.tsx index 506ca0b029b..5d927e03b1f 100644 --- a/src/auto-complete/src/AutoComplete.tsx +++ b/src/auto-complete/src/AutoComplete.tsx @@ -12,6 +12,7 @@ import type { } from '../../select/src/interface' import type { AutoCompleteTheme } from '../styles' import type { + AutoCompleteDefaultSlotOptions, AutoCompleteInst, AutoCompleteOption, AutoCompleteOptions, @@ -33,6 +34,7 @@ import { type InputHTMLAttributes, type PropType, ref, + type SlotsType, toRef, Transition, watchEffect, @@ -114,9 +116,17 @@ export const autoCompleteProps = { export type AutoCompleteProps = ExtractPublicPropTypes +export interface AutoCompleteSlots { + default?: AutoCompleteDefaultSlotOptions + empty?: any + prefix?: any + suffix?: any +} + export default defineComponent({ name: 'AutoComplete', props: autoCompleteProps, + slots: Object as SlotsType, setup(props) { if (__DEV__) { watchEffect(() => { @@ -368,7 +378,7 @@ export default defineComponent({ handleFocus: this.handleFocus, handleBlur: this.handleBlur, value: this.mergedValue - }) + } as AutoCompleteDefaultSlotOptions) } const { mergedTheme } = this return ( diff --git a/src/auto-complete/src/interface.ts b/src/auto-complete/src/interface.ts index 0795ebc2f20..f6b2801739f 100644 --- a/src/auto-complete/src/interface.ts +++ b/src/auto-complete/src/interface.ts @@ -22,3 +22,11 @@ export interface AutoCompleteInst { focus: () => void blur: () => void } + +export interface AutoCompleteDefaultSlotOptions { + handleInput: (value: string) => void + handleFocus: (e: FocusEvent) => void + handleBlur: (e: FocusEvent) => void + value: string + theme: string | null +}