Line data Source code
1 16 : <script setup lang="ts">
2 : import Badge from '@comfyorg/design-system/badge/Badge'
3 : import { cn } from '@comfyorg/tailwind-utils'
4 : import { toValue } from 'vue'
5 :
6 : import OverlayIcon from '@comfyorg/design-system/common/OverlayIcon'
7 : import Switch from '@comfyorg/design-system/switch/Switch'
8 :
9 : import type { MenuItem } from './types'
10 :
11 : const { hasSubmenu, item } = defineProps<{
12 : hasSubmenu: boolean
13 : item: MenuItem
14 : }>()
15 : </script>
16 :
17 : <template>
18 2355 : <OverlayIcon v-if="item.overlayIcon" v-bind="item.overlayIcon" />
19 : <i v-else-if="item.icon" :class="item.icon" />
20 : <span class="min-w-0 flex-1">
21 : <span class="block truncate">{{ toValue(item.label) }}</span>
22 : <span
23 : v-if="item.description"
24 : class="block max-w-64 text-xs whitespace-normal text-muted-foreground"
25 : >{{ toValue(item.description) }}</span
26 : >
27 : </span>
28 : <i v-if="item.trailingIcon" :class="cn(item.trailingIcon, 'ml-auto')" />
29 : <Badge
30 : v-if="item.badge"
31 : variant="pill"
32 : severity="default"
33 : class="ml-3 px-1.5 uppercase"
34 : >
35 : {{ item.badge }}
36 : </Badge>
37 : <i
38 : v-if="hasSubmenu"
39 : data-testid="menu-item-submenu-indicator"
40 : class="ml-auto icon-[lucide--chevron-right]"
41 : />
42 : <Switch
43 : v-else-if="item.presentation === 'switch'"
44 : :model-value="toValue(item.checked)"
45 : class="pointer-events-none ml-4"
46 : aria-hidden="true"
47 : readonly
48 : tabindex="-1"
49 : />
50 : <i
51 : v-else-if="item.checked !== undefined"
52 : data-testid="menu-item-indicator"
53 : :class="
54 : cn('ml-auto icon-[lucide--check]', !toValue(item.checked) && 'invisible')
55 : "
56 : />
57 : <span
58 : v-if="!hasSubmenu && toValue(item.shortcut)"
59 : class="ml-auto rounded-sm border bg-secondary p-1 text-xs text-nowrap text-muted-foreground"
60 : >
61 : {{ toValue(item.shortcut) }}
62 : </span>
63 : </template>
|