LCOV - code coverage report
Current view: top level - packages/design-system/src/components/switch - Switch.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 5 5
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <script setup lang="ts">
       2              : import { SwitchRoot, SwitchThumb } from 'reka-ui'
       3              : import type { HTMLAttributes } from 'vue'
       4              : 
       5              : import { cn } from '@comfyorg/tailwind-utils'
       6              : 
       7              : const {
       8              :   class: customClass = '',
       9              :   disabled = false,
      10              :   readonly = false
      11              : } = defineProps<{
      12              :   class?: HTMLAttributes['class']
      13              :   disabled?: boolean
      14              :   readonly?: boolean
      15              : }>()
      16              : 
      17         3966 : const modelValue = defineModel<boolean>({ default: false })
      18              : 
      19           21 : function updateModelValue(value: boolean) {
      20           21 :   if (readonly) return
      21           21 :   modelValue.value = value
      22              : }
      23              : </script>
      24              : 
      25              : <template>
      26              :   <SwitchRoot
      27              :     :model-value
      28              :     :disabled
      29              :     :aria-readonly="readonly || undefined"
      30              :     :class="
      31              :       cn(
      32              :         'group inline-flex h-6 w-10 shrink-0 cursor-pointer touch-manipulation items-center justify-center rounded-full border-0 bg-transparent p-0 transition-shadow outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-readonly:cursor-default',
      33              :         customClass
      34              :       )
      35              :     "
      36              :     @update:model-value="updateModelValue"
      37              :   >
      38              :     <span
      39              :       class="pointer-events-none inline-flex h-5 w-9 items-center rounded-full border border-transparent bg-border px-0.5 transition-colors group-data-[state=checked]:bg-foreground"
      40              :     >
      41              :       <SwitchThumb
      42              :         class="pointer-events-none block size-4 rounded-full bg-background shadow-sm transition-transform data-[state=checked]:translate-x-3.5 data-[state=unchecked]:translate-x-0"
      43              :       />
      44              :     </span>
      45              :   </SwitchRoot>
      46              : </template>
        

Generated by: LCOV version 2.0-1