Skip to content

Commit

Permalink
feat(auto-complete): add slots type (tusen-ai#6599)
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Dec 7, 2024
1 parent 16e0e8b commit 19d637f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/auto-complete/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { autoCompleteProps, default as NAutoComplete } from './src/AutoComplete'
export type { AutoCompleteProps } from './src/AutoComplete'
export type {
AutoCompleteDefaultSlotOptions,
AutoCompleteGroupOption,
AutoCompleteInst,
AutoCompleteOption
Expand Down
12 changes: 11 additions & 1 deletion src/auto-complete/src/AutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
} from '../../select/src/interface'
import type { AutoCompleteTheme } from '../styles'
import type {
AutoCompleteDefaultSlotOptions,
AutoCompleteInst,
AutoCompleteOption,
AutoCompleteOptions,
Expand All @@ -33,6 +34,7 @@ import {
type InputHTMLAttributes,
type PropType,
ref,
type SlotsType,
toRef,
Transition,
watchEffect,
Expand Down Expand Up @@ -114,9 +116,17 @@ export const autoCompleteProps = {

export type AutoCompleteProps = ExtractPublicPropTypes<typeof autoCompleteProps>

export interface AutoCompleteSlots {
default?: AutoCompleteDefaultSlotOptions
empty?: any
prefix?: any
suffix?: any
}

export default defineComponent({
name: 'AutoComplete',
props: autoCompleteProps,
slots: Object as SlotsType<AutoCompleteSlots>,
setup(props) {
if (__DEV__) {
watchEffect(() => {
Expand Down Expand Up @@ -368,7 +378,7 @@ export default defineComponent({
handleFocus: this.handleFocus,
handleBlur: this.handleBlur,
value: this.mergedValue
})
} as AutoCompleteDefaultSlotOptions)
}
const { mergedTheme } = this
return (
Expand Down
8 changes: 8 additions & 0 deletions src/auto-complete/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 19d637f

Please sign in to comment.