Line data Source code
1 16 : <script setup lang="ts">
2 : import type {
3 : DropdownMenuContentEmits,
4 : DropdownMenuContentProps
5 : } from 'reka-ui'
6 : import {
7 : DropdownMenuContent,
8 : DropdownMenuPortal,
9 : injectDropdownMenuRootContext,
10 : useForwardPropsEmits
11 : } from 'reka-ui'
12 : import type { HTMLAttributes } from 'vue'
13 :
14 : import { cn } from '@comfyorg/tailwind-utils'
15 :
16 : import { menuContentClass } from './menuStyles'
17 :
18 : defineOptions({ inheritAttrs: false })
19 :
20 11746 : const {
21 : class: className,
22 : to,
23 : width = 'default',
24 : maxHeight = 'available',
25 : ...restProps
26 : } = defineProps<
27 : DropdownMenuContentProps & {
28 : class?: HTMLAttributes['class']
29 : to?: string | HTMLElement
30 : width?: 'default' | 'trigger' | 'compact'
31 : maxHeight?: 'available' | 'compact' | 'viewport'
32 : }
33 : >()
34 : const emits = defineEmits<DropdownMenuContentEmits>()
35 11746 : const forwarded = useForwardPropsEmits(restProps, emits)
36 11746 : const rootContext = injectDropdownMenuRootContext()
37 11746 : </script>
38 :
39 : <template>
40 14683 : <DropdownMenuPortal :key="Number(rootContext.open.value)" :to>
41 : <DropdownMenuContent
42 : v-bind="{ ...forwarded, ...$attrs }"
43 : :class="
44 : cn(
45 : menuContentClass,
46 : width === 'trigger' &&
47 : 'w-(--reka-dropdown-menu-trigger-width) min-w-0 overflow-hidden',
48 : width === 'compact' && 'w-max min-w-46.5',
49 : maxHeight === 'available' &&
50 : 'max-h-(--reka-dropdown-menu-content-available-height)',
51 : maxHeight === 'compact' && 'max-h-64',
52 : maxHeight === 'viewport' &&
53 : 'max-h-[min(40vh,var(--reka-dropdown-menu-content-available-height))]',
54 : className
55 : )
56 : "
57 : >
58 : <slot />
59 : </DropdownMenuContent>
60 : </DropdownMenuPortal>
61 : </template>
|