Line data Source code
1 : <template>
2 524 : <ComboboxRoot
3 : v-model="selectedItems"
4 : v-model:open="isOpen"
5 : multiple
6 : by="value"
7 : :disabled
8 : ignore-filter
9 : :reset-search-term-on-select="false"
10 : >
11 : <MultiSelectTrigger
12 : v-bind="attrsWithoutClass"
13 : :class="attrsClass"
14 : :label
15 : :accessible-label
16 : :selected-items="selectedItems"
17 : :size
18 : >
19 : <template v-if="$slots.value" #default="{ selected }">
20 : <slot name="value" :selected />
21 : </template>
22 : </MultiSelectTrigger>
23 :
24 : <MultiSelectContent
25 : v-model="selectedItems"
26 : v-model:search-query="searchQuery"
27 : :options
28 : :show-search-box
29 : :show-clear-button
30 : :actions-placement
31 : :search-placeholder
32 : :search-label
33 : :empty-text
34 : :clear-all-label
35 : :format-selected-count="
36 : showSelectedCount ? formatSelectedCount : undefined
37 : "
38 : :list-max-height
39 : :popover-style
40 : :content-style
41 : @escape="isOpen = false"
42 : />
43 : </ComboboxRoot>
44 : </template>
45 :
46 : <script setup lang="ts">
47 : import { ComboboxRoot } from 'reka-ui'
48 : import { ref } from 'vue'
49 :
50 : import MultiSelectContent from './MultiSelectContent.vue'
51 : import MultiSelectTrigger from './MultiSelectTrigger.vue'
52 : import type { MultiSelectProps } from './types'
53 :
54 : import type { SelectOption } from '@comfyorg/design-system/lib/select/types'
55 : import { useAttrsClass } from '@comfyorg/design-system/lib/composables/useAttrsClass'
56 : import { usePopoverSizing } from '@comfyorg/design-system/lib/composables/usePopoverSizing'
57 :
58 : defineOptions({
59 : inheritAttrs: false
60 : })
61 :
62 156 : const { attrsClass, attrsWithoutClass } = useAttrsClass()
63 :
64 : const {
65 : label,
66 : accessibleLabel,
67 : searchLabel,
68 : emptyText,
69 : clearAllLabel,
70 : formatSelectedCount,
71 : options = [],
72 : size = 'lg',
73 : disabled = false,
74 : showSearchBox = false,
75 : showSelectedCount = false,
76 : showClearButton = false,
77 : actionsPlacement = 'header',
78 : searchPlaceholder,
79 : listMaxHeight = '28rem',
80 : popoverMinWidth,
81 : popoverMaxWidth,
82 : contentStyle
83 : } = defineProps<MultiSelectProps>()
84 :
85 156 : const selectedItems = defineModel<SelectOption[]>({
86 : required: true
87 : })
88 156 : const searchQuery = defineModel<string>('searchQuery', { default: '' })
89 :
90 156 : const isOpen = ref(false)
91 :
92 156 : const popoverStyle = usePopoverSizing({
93 : minWidth: popoverMinWidth,
94 : maxWidth: popoverMaxWidth
95 : })
96 : </script>
|