LCOV - code coverage report
Current view: top level - src/renderer/extensions/vueNodes/widgets/components - WidgetInputNumberGradientSlider.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 13 13
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2           10 :   <WidgetLayoutField :widget :input-id fill-width>
       3              :     <template #between><slot name="between" /></template>
       4              :     <div
       5              :       :class="
       6              :         cn(
       7              :           WidgetInputBaseClass,
       8              :           'flex items-center gap-2 pr-2 pl-3 not-disabled:bg-transparent',
       9              :           useWidgetHeight()
      10              :         )
      11              :       "
      12              :     >
      13              :       <GradientSlider
      14              :         v-model="modelValue"
      15              :         :stops="gradientStops"
      16              :         :min="widget.options?.min ?? 0"
      17              :         :max="widget.options?.max ?? 100"
      18              :         :step
      19              :         :disabled="widget.options?.disabled"
      20              :         :aria-label="widget.name"
      21              :         class="min-w-0 flex-1"
      22              :       />
      23              :       <NumberField
      24              :         v-model="modelValue"
      25              :         :step
      26              :         :min="widget.options?.min"
      27              :         :max="widget.options?.max"
      28              :         :disabled="widget.options?.disabled"
      29              :         :format-options="{
      30              :           minimumFractionDigits: precision,
      31              :           maximumFractionDigits: precision
      32              :         }"
      33              :         class="h-auto w-auto shrink-0 bg-transparent focus-within:ring-0 hover:bg-transparent"
      34              :       >
      35              :         <NumberFieldInput
      36              :           :id="inputId"
      37              :           :aria-label="widget.name"
      38              :           class="field-sizing-content w-auto max-w-16 flex-none text-right text-xs"
      39              :         />
      40              :       </NumberField>
      41              :     </div>
      42              :   </WidgetLayoutField>
      43              : </template>
      44              : 
      45              : <script setup lang="ts">
      46              : import { computed, useId } from 'vue'
      47              : 
      48              : import GradientSlider from '@comfyorg/design-system/slider/GradientSlider'
      49              : import NumberField from '@comfyorg/design-system/number-field/NumberField'
      50              : import NumberFieldInput from '@comfyorg/design-system/number-field/NumberFieldInput'
      51              : import type { ColorStop } from '@comfyorg/graph-model/interfaces'
      52              : import type { IWidgetGradientSliderOptions } from '@comfyorg/graph-model/widgets'
      53              : import type { SimplifiedWidget } from '@/types/simplifiedWidget'
      54              : import { useWidgetHeight } from '@/types/widgetTypes'
      55              : import { cn } from '@comfyorg/tailwind-utils'
      56              : 
      57              : import { useNumberStepCalculation } from '@/renderer/extensions/vueNodes/widgets/composables/useNumberStepCalculation'
      58              : import { WidgetInputBaseClass } from './layout'
      59              : import WidgetLayoutField from './layout/WidgetLayoutField.vue'
      60              : 
      61            1 : const DEFAULT_GRADIENT_STOPS: ColorStop[] = [
      62              :   { offset: 0, color: [0, 0, 0] },
      63              :   { offset: 1, color: [255, 255, 255] }
      64              : ]
      65              : 
      66              : const { widget } = defineProps<{
      67              :   widget: SimplifiedWidget<number, IWidgetGradientSliderOptions>
      68              : }>()
      69              : 
      70            1 : const modelValue = defineModel<number>({ default: 0 })
      71            1 : const inputId = useId()
      72              : 
      73            1 : const gradientStops = computed<ColorStop[]>(() => {
      74           10 :   const stops = widget.options?.gradient_stops
      75           10 :   if (stops && stops.length >= 2) return stops
      76           10 :   return DEFAULT_GRADIENT_STOPS
      77              : })
      78              : 
      79            1 : const precision = computed(() => {
      80           10 :   const p = widget.options?.precision
      81           10 :   return typeof p === 'number' && p >= 0 ? p : undefined
      82              : })
      83              : 
      84            1 : const step = useNumberStepCalculation(widget.options, precision, true)
      85              : </script>
        

Generated by: LCOV version 2.0-1