Line data Source code
1 16 : <script setup lang="ts">
2 : import { useI18n } from 'vue-i18n'
3 :
4 : import SingleSelect from '@comfyorg/design-system/single-select/SingleSelect'
5 : import type { SingleSelectProps } from '@comfyorg/design-system/lib/single-select/types'
6 :
7 : type TranslatedProps = 'accessibleLabel' | 'searchLabel' | 'emptyText'
8 :
9 991 : const {
10 : label,
11 : accessibleLabel,
12 : searchLabel,
13 : searchPlaceholder,
14 : emptyText,
15 : ...restProps
16 : } = defineProps<
17 : Omit<SingleSelectProps, TranslatedProps> &
18 : Partial<Pick<SingleSelectProps, TranslatedProps>>
19 : >()
20 :
21 991 : const selectedItem = defineModel<string | number | undefined>({
22 : required: true
23 : })
24 991 : const { t } = useI18n()
25 : </script>
26 :
27 : <template>
28 : <SingleSelect
29 : v-bind="restProps"
30 : v-model="selectedItem"
31 : :label
32 : :accessible-label="
33 : accessibleLabel ?? (label || t('g.singleSelectDropdown'))
34 : "
35 : :search-label="searchLabel ?? t('g.search')"
36 : :search-placeholder="searchPlaceholder ?? t('g.search')"
37 : :empty-text="emptyText ?? t('g.noResultsFound')"
38 : >
39 : <template v-if="$slots.icon" #icon>
40 : <slot name="icon" />
41 : </template>
42 : </SingleSelect>
43 : </template>
|