LCOV - code coverage report
Current view: top level - src/components/builder - IoItem.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 20 20
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <script setup lang="ts">
       2              : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
       3              : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
       4              : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
       5              : 
       6              : import { computed, ref } from 'vue'
       7              : import { useI18n } from 'vue-i18n'
       8              : 
       9              : import EditableText from '@comfyorg/design-system/common/EditableText'
      10              : import Button from '@comfyorg/design-system/button/Button'
      11              : import Menu from '@comfyorg/design-system/menu/Menu'
      12              : import { cn } from '@comfyorg/tailwind-utils'
      13              : 
      14         2355 : const { t } = useI18n()
      15              : 
      16          122 : const subTitleTooltip = ref<string | null>(null)
      17          122 : const isEditing = ref(false)
      18              : 
      19            4 : function isTruncated(e: MouseEvent): boolean {
      20            4 :   const el = e.currentTarget as HTMLElement
      21            4 :   return el.scrollWidth > el.clientWidth
      22              : }
      23              : const { title, canRename, remove } = defineProps<{
      24              :   title: string
      25              :   subTitle?: string
      26              :   canRename?: boolean
      27              :   remove?: () => void
      28              : }>()
      29              : 
      30          122 : const emit = defineEmits<{
      31              :   rename: [newName: string]
      32              : }>()
      33              : 
      34            2 : function onEditComplete(newName: string) {
      35            2 :   isEditing.value = false
      36            2 :   const trimmed = newName.trim()
      37            2 :   if (trimmed && trimmed !== title) emit('rename', trimmed)
      38              : }
      39              : 
      40          122 : const entries = computed(() => {
      41          164 :   const items = []
      42          164 :   if (canRename)
      43          123 :     items.push({
      44              :       label: t('g.rename'),
      45              :       command: () => (isEditing.value = true),
      46              :       icon: 'icon-[lucide--pencil]'
      47              :     })
      48          164 :   if (remove)
      49          164 :     items.push({
      50              :       label: t('g.delete'),
      51              :       command: remove,
      52              :       icon: 'icon-[lucide--trash-2]'
      53              :     })
      54          164 :   return items
      55              : })
      56          122 : </script>
      57              : <template>
      58          166 :   <div
      59              :     class="my-2 flex items-center-safe gap-2 rounded-lg p-2"
      60              :     data-testid="builder-io-item"
      61              :   >
      62              :     <div class="drag-handle mr-auto flex w-full min-w-0 flex-col gap-1">
      63              :       <EditableText
      64              :         :model-value="title"
      65              :         :is-editing="isEditing"
      66              :         :input-attrs="{ class: 'p-1' }"
      67              :         :class="
      68              :           cn(
      69              :             'drag-handle h-5 text-sm',
      70              :             isEditing && 'relative -top-0.5 -left-1 -mt-px mb-px -ml-px',
      71              :             !isEditing && 'truncate'
      72              :           )
      73              :         "
      74              :         data-testid="builder-io-item-title"
      75              :         label-class="drag-handle"
      76              :         label-type="div"
      77              :         @dblclick="canRename && (isEditing = true)"
      78              :         @edit="onEditComplete"
      79              :         @cancel="isEditing = false"
      80              :       />
      81              :       <Tooltip :disabled="!subTitleTooltip">
      82              :         <TooltipTrigger as-child>
      83              :           <div
      84              :             class="drag-handle truncate text-xs text-muted-foreground"
      85              :             data-testid="builder-io-item-subtitle"
      86              :             @mouseenter="
      87              :               subTitleTooltip = isTruncated($event) ? (subTitle ?? null) : null
      88              :             "
      89              :             v-text="subTitle"
      90              :           />
      91              :         </TooltipTrigger>
      92              :         <TooltipContent side="left">{{ subTitleTooltip }}</TooltipContent>
      93              :       </Tooltip>
      94              :     </div>
      95              :     <Menu
      96              :       :items="entries"
      97              :       @close-auto-focus="isEditing && $event.preventDefault()"
      98              :     >
      99              :       <template #trigger>
     100              :         <Button
     101              :           variant="muted-textonly"
     102              :           data-testid="widget-actions-menu"
     103              :           icon="icon-[lucide--ellipsis]"
     104              :           :aria-label="$t('g.more')"
     105              :         />
     106              :       </template>
     107              :     </Menu>
     108              :   </div>
     109              : </template>
        

Generated by: LCOV version 2.0-1