LCOV - code coverage report
Current view: top level - src/components/boundingbox - WidgetBoundingBox.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 92.9 % 14 13
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2              :   <div class="flex flex-col gap-1" data-testid="bounding-box">
       3              :     <WidgetHistoryButtons
       4              :       v-if="widget"
       5              :       class="self-end"
       6              :       :can-undo
       7              :       :can-redo
       8              :       @undo="undo"
       9              :       @redo="redo"
      10              :     />
      11              :     <div class="grid grid-cols-[auto_1fr] gap-x-2 gap-y-1 text-xs">
      12              :       <label class="content-center">
      13              :         {{ $t('boundingBox.x') }}
      14              :       </label>
      15              :       <ScrubableNumberInput
      16              :         v-model="x"
      17              :         :min="0"
      18              :         :step="1"
      19              :         :disabled
      20              :         data-testid="bounding-box-x"
      21              :       />
      22              :       <label class="content-center">
      23              :         {{ $t('boundingBox.y') }}
      24              :       </label>
      25              :       <ScrubableNumberInput
      26              :         v-model="y"
      27              :         :min="0"
      28              :         :step="1"
      29              :         :disabled
      30              :         data-testid="bounding-box-y"
      31              :       />
      32              :       <label class="content-center">
      33              :         {{ $t('boundingBox.width') }}
      34              :       </label>
      35              :       <ScrubableNumberInput
      36              :         v-model="width"
      37              :         :min="1"
      38              :         :step="1"
      39              :         :disabled
      40              :         data-testid="bounding-box-width"
      41              :       />
      42              :       <label class="content-center">
      43              :         {{ $t('boundingBox.height') }}
      44              :       </label>
      45              :       <ScrubableNumberInput
      46              :         v-model="height"
      47              :         :min="1"
      48              :         :step="1"
      49              :         :disabled
      50              :         data-testid="bounding-box-height"
      51              :       />
      52              :     </div>
      53              :   </div>
      54              : </template>
      55              : 
      56              : <script setup lang="ts">
      57              : import { computed, nextTick } from 'vue'
      58              : 
      59              : import ScrubableNumberInput from '@/components/common/ScrubableNumberInput.vue'
      60              : import WidgetHistoryButtons from '@/components/widgetHistory/WidgetHistoryButtons.vue'
      61              : import { isBoundsObject } from '@/renderer/core/layout/utils/geometry'
      62              : import { useWidgetValueHistory } from '@/composables/useWidgetValueHistory'
      63              : import { widgetHistoryScope } from '@/composables/widgetHistoryScope'
      64              : import type { Bounds } from '@comfyorg/shared-frontend-utils/geometry'
      65              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
      66              : import type { SimplifiedWidget } from '@/types/simplifiedWidget'
      67              : 
      68              : const {
      69              :   disabled = false,
      70              :   widget,
      71              :   nodeId
      72              : } = defineProps<{
      73              :   disabled?: boolean
      74              :   widget?: SimplifiedWidget
      75              :   nodeId?: NodeId
      76              : }>()
      77              : 
      78           49 : const emit = defineEmits<{
      79              :   editEnd: [field: keyof Bounds]
      80              : }>()
      81              : 
      82           49 : const modelValue = defineModel<Bounds>({
      83              :   default: () => ({ x: 0, y: 0, width: 512, height: 512 })
      84              : })
      85              : 
      86           49 : const { canUndo, canRedo, undo, redo, commit } = useWidgetValueHistory({
      87              :   scope: () => (widget ? widgetHistoryScope(widget, nodeId) : null),
      88              :   read: () => modelValue.value,
      89              :   apply: (value) => {
      90            0 :     if (isBoundsObject(value)) modelValue.value = value
      91              :   }
      92              : })
      93              : 
      94          196 : function boundsField(field: keyof Bounds) {
      95          196 :   return computed({
      96              :     get: () => modelValue.value[field],
      97              :     set: (value: number) => {
      98           26 :       modelValue.value = { ...modelValue.value, [field]: value }
      99           26 :       emit('editEnd', field)
     100           26 :       void nextTick(() => commit(field))
     101              :     }
     102              :   })
     103              : }
     104              : 
     105           49 : const x = boundsField('x')
     106           49 : const y = boundsField('y')
     107           49 : const width = boundsField('width')
     108           49 : const height = boundsField('height')
     109              : </script>
        

Generated by: LCOV version 2.0-1