Line data Source code
1 : <script setup lang="ts">
2 : import { useI18n } from 'vue-i18n'
3 :
4 : import MultiSelect from '@comfyorg/design-system/multi-select/MultiSelect'
5 : import type { MultiSelectProps } from '@comfyorg/design-system/lib/multi-select/types'
6 : import type { SelectOption } from '@comfyorg/design-system/lib/select/types'
7 :
8 : type TranslatedProps =
9 : | 'accessibleLabel'
10 : | 'searchLabel'
11 : | 'emptyText'
12 : | 'clearAllLabel'
13 : | 'formatSelectedCount'
14 :
15 2356 : const {
16 : label,
17 : accessibleLabel,
18 : searchLabel,
19 : searchPlaceholder,
20 : emptyText,
21 : clearAllLabel,
22 : formatSelectedCount,
23 : ...restProps
24 : } = defineProps<
25 : Omit<MultiSelectProps, TranslatedProps> &
26 : Partial<Pick<MultiSelectProps, TranslatedProps>>
27 : >()
28 :
29 156 : const selectedItems = defineModel<SelectOption[]>({
30 : required: true
31 : })
32 156 : const searchQuery = defineModel<string>('searchQuery', {
33 : default: ''
34 : })
35 156 : const { t } = useI18n()
36 156 : </script>
37 :
38 : <template>
39 522 : <MultiSelect
40 : v-bind="restProps"
41 : v-model="selectedItems"
42 : v-model:search-query="searchQuery"
43 : :label
44 : :accessible-label="accessibleLabel ?? (label || t('g.multiSelectDropdown'))"
45 : :search-label="searchLabel ?? t('g.search')"
46 : :search-placeholder="searchPlaceholder ?? t('g.search')"
47 : :empty-text="emptyText ?? t('g.noResultsFound')"
48 : :clear-all-label="clearAllLabel ?? t('g.clearAll')"
49 : :format-selected-count="
50 : formatSelectedCount ?? ((count) => t('g.itemsSelected', { count }))
51 : "
52 : >
53 : <template v-if="$slots.value" #value="{ selected }">
54 : <slot name="value" :selected />
55 : </template>
56 : </MultiSelect>
57 : </template>
|