Line data Source code
1 16 : <script setup lang="ts">
2 : import type { SelectContentEmits, SelectContentProps } from 'reka-ui'
3 : import {
4 : SelectContent,
5 : SelectViewport,
6 : useForwardPropsEmits,
7 : SelectPortal
8 : } from 'reka-ui'
9 : import type { HTMLAttributes } from 'vue'
10 : import { computed } from 'vue'
11 :
12 : import { cn } from '@comfyorg/tailwind-utils'
13 :
14 : import SelectScrollDownButton from './SelectScrollDownButton.vue'
15 : import SelectScrollUpButton from './SelectScrollUpButton.vue'
16 :
17 : defineOptions({
18 : inheritAttrs: false
19 : })
20 :
21 2355 : const {
22 : position = 'popper',
23 : disablePortal = false,
24 : class: className,
25 : ...restProps
26 : } = defineProps<
27 : SelectContentProps & {
28 : class?: HTMLAttributes['class']
29 : disablePortal?: boolean
30 : }
31 : >()
32 143 : const emits = defineEmits<SelectContentEmits>()
33 :
34 143 : const delegatedProps = computed(() => ({
35 : position,
36 : ...restProps
37 : }))
38 :
39 143 : const forwarded = useForwardPropsEmits(delegatedProps, emits)
40 143 : </script>
41 :
42 : <template>
43 183 : <SelectPortal :disabled="disablePortal">
44 : <SelectContent
45 : v-bind="{ ...forwarded, ...$attrs }"
46 : :class="
47 : cn(
48 : 'relative z-overlay max-h-96 min-w-32 overflow-hidden',
49 : 'mt-2 rounded-lg p-2',
50 : 'bg-background text-foreground',
51 : 'border border-solid',
52 : 'shadow-md',
53 : 'data-[state=closed]:animate-out data-[state=open]:animate-in',
54 : 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
55 : 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
56 : 'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2',
57 : 'data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
58 : position === 'popper' &&
59 : 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
60 : className
61 : )
62 : "
63 : >
64 : <slot name="prepend" />
65 : <SelectScrollUpButton />
66 : <SelectViewport
67 : :class="
68 : cn(
69 : 'flex scrollbar-custom flex-col gap-0',
70 : position === 'popper' &&
71 : 'h-(--reka-select-trigger-height) w-full min-w-(--reka-select-trigger-width)'
72 : )
73 : "
74 : >
75 : <slot />
76 : </SelectViewport>
77 : <SelectScrollDownButton />
78 : </SelectContent>
79 : </SelectPortal>
80 : </template>
|