Line data Source code
1 : <script setup lang="ts">
2 : import { computed } from 'vue'
3 :
4 : import Button from '@comfyorg/design-system/button/Button'
5 : import { cn } from '@comfyorg/tailwind-utils'
6 : import type { ClassValue } from '@comfyorg/tailwind-utils'
7 :
8 : const {
9 : nodeTitle,
10 : widgetName,
11 : isDraggable = false,
12 : isPhysical = false,
13 : isShown = false,
14 : class: className
15 : } = defineProps<{
16 : nodeTitle: string
17 : widgetName: string
18 : isDraggable?: boolean
19 : isPhysical?: boolean
20 : isShown?: boolean
21 : class?: ClassValue
22 : }>()
23 : defineEmits<{ toggleVisibility: [] }>()
24 :
25 2355 : const icon = computed(() =>
26 : isPhysical
27 : ? 'icon-[lucide--link]'
28 : : isShown
29 : ? 'icon-[lucide--eye]'
30 : : 'icon-[lucide--eye-off]'
31 : )
32 86 : </script>
33 :
34 : <template>
35 86 : <div
36 : :class="
37 : cn(
38 : 'flex items-center gap-1 rounded-sm px-2 py-1 break-all',
39 : 'bg-node',
40 : isDraggable && 'ring-accent hover:ring-1',
41 : className
42 : )
43 : "
44 : data-testid="subgraph-widget-item"
45 : >
46 : <div class="pointer-events-none flex-1">
47 : <div
48 : class="line-clamp-1 text-xs text-muted-foreground"
49 : data-testid="subgraph-widget-node-name"
50 : >
51 : {{ nodeTitle }}
52 : </div>
53 : <div class="line-clamp-1 text-sm/8" data-testid="subgraph-widget-label">
54 : {{ widgetName }}
55 : </div>
56 : </div>
57 : <Button
58 : variant="muted-textonly"
59 : size="sm"
60 : data-testid="subgraph-widget-toggle"
61 : :disabled="isPhysical"
62 : @click.stop="$emit('toggleVisibility')"
63 : >
64 : <i :class="icon" :data-testid="isPhysical ? 'icon-link' : 'icon-eye'" />
65 : </Button>
66 : <i
67 : v-if="isDraggable"
68 : aria-hidden="true"
69 : data-testid="subgraph-widget-drag-handle"
70 : class="pointer-events-none icon-[lucide--grip-vertical]"
71 : />
72 : </div>
73 : </template>
|