Line data Source code
1 16 : <script setup lang="ts">
2 : import type { TagsInputRootProps } from 'reka-ui'
3 : import type { HTMLAttributes } from 'vue'
4 : import { useI18n } from 'vue-i18n'
5 :
6 : import TagsInput from '@comfyorg/design-system/tags-input/TagsInput'
7 : import TagsInputInput from '@comfyorg/design-system/tags-input/TagsInputInput'
8 : import TagsInputItem from '@comfyorg/design-system/tags-input/TagsInputItem'
9 : import TagsInputItemDelete from '@comfyorg/design-system/tags-input/TagsInputItemDelete'
10 : import TagsInputItemText from '@comfyorg/design-system/tags-input/TagsInputItemText'
11 :
12 32 : const { placeholder, itemClass, ...rootProps } = defineProps<
13 : Omit<TagsInputRootProps<string>, 'modelValue' | 'defaultValue'> & {
14 : alwaysEditing?: boolean
15 : placeholder?: string
16 : itemClass?:
17 : | HTMLAttributes['class']
18 : | ((value: string) => HTMLAttributes['class'])
19 : }
20 : >()
21 32 : const tags = defineModel<string[]>({ default: () => [] })
22 32 : const { t } = useI18n()
23 : </script>
24 :
25 : <template>
26 : <TagsInput v-slot="{ isEmpty }" v-model="tags" v-bind="rootProps">
27 1 : <TagsInputItem
28 : v-for="tag in tags"
29 : :key="tag"
30 : :value="tag"
31 : :class="typeof itemClass === 'function' ? itemClass(tag) : itemClass"
32 : >
33 : <TagsInputItemText />
34 : <TagsInputItemDelete
35 : :aria-label="t('g.removeTagNamed', { tag }, { escapeParameter: false })"
36 : />
37 : </TagsInputItem>
38 : <slot name="input" :is-empty>
39 : <TagsInputInput :is-empty :placeholder />
40 : </slot>
41 : </TagsInput>
42 : </template>
|