Skip to content

Commit

Permalink
feat(dynamic-tags): 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 373732c commit e5fab2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dynamic-tags/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export { dynamicTagsProps, default as NDynamicTags } from './src/DynamicTags'
export type { DynamicTagsProps } from './src/DynamicTags'
export type { DynamicTagsOption } from './src/interface'
export type { DynamicTagsProps, DynamicTagsSlots } from './src/DynamicTags'
export type {
DynamicTagsInputSlotOptions,
DynamicTagsOption,
DynamicTagsTriggerSlotOptions
} from './src/interface'
10 changes: 10 additions & 0 deletions src/dynamic-tags/src/DynamicTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import type { InputInst, InputProps } from '../../input'
import type { DynamicTagsTheme } from '../styles'
import type {
DynamicTagsInputSlotOptions,
DynamicTagsOption,
DynamicTagsTriggerSlotOptions,
OnCreate,
OnUpdateValue,
OnUpdateValueImpl
Expand All @@ -17,6 +19,7 @@ import {
nextTick,
type PropType,
ref,
type SlotsType,
toRef,
type VNodeChild,
watchEffect
Expand Down Expand Up @@ -77,9 +80,16 @@ export const dynamicTagsProps = {

export type DynamicTagsProps = ExtractPublicPropTypes<typeof dynamicTagsProps>

export interface DynamicTagsSlots {
input?: (info: DynamicTagsInputSlotOptions) => any
trigger?: (info: DynamicTagsTriggerSlotOptions) => any
default?: any
}

export default defineComponent({
name: 'DynamicTags',
props: dynamicTagsProps,
slots: Object as SlotsType<DynamicTagsSlots>,
setup(props) {
if (__DEV__) {
watchEffect(() => {
Expand Down
10 changes: 10 additions & 0 deletions src/dynamic-tags/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ export interface DynamicTagsOption {
label: string
value: string
}

export interface DynamicTagsInputSlotOptions {
submit: (value: any) => void
deactivate: () => void
}

export interface DynamicTagsTriggerSlotOptions {
activate: () => void
disabled: boolean
}

0 comments on commit e5fab2c

Please sign in to comment.