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

            Line data    Source code
       1           16 : <template>
       2              :   <SearchableSingleSelect
       3              :     v-if="searchable && searchLabel !== undefined && emptyText !== undefined"
       4              :     v-model="selectedItem"
       5              :     v-bind="attrsWithoutClass"
       6              :     :class="attrsClass"
       7              :     :label
       8              :     :accessible-label
       9              :     :search-label
      10              :     :empty-text
      11              :     :options
      12              :     :size
      13              :     :invalid
      14              :     :loading
      15              :     :disabled
      16              :     :search-placeholder
      17              :     :list-max-height
      18              :     :popover-min-width
      19              :     :popover-max-width
      20              :     :content-style
      21              :   >
      22              :     <template #icon><slot name="icon" /></template>
      23              :   </SearchableSingleSelect>
      24              : 
      25              :   <SelectRoot v-else v-model="selectedItem" v-model:open="isOpen" :disabled>
      26              :     <SelectTrigger
      27              :       v-bind="attrsWithoutClass"
      28              :       :aria-label="accessibleLabel"
      29              :       :aria-busy="loading || undefined"
      30              :       :aria-invalid="invalid || undefined"
      31              :       :class="
      32              :         cn(
      33              :           selectTriggerVariants({
      34              :             size,
      35              :             border: invalid ? 'invalid' : 'none'
      36              :           }),
      37              :           attrsClass
      38              :         )
      39              :       "
      40              :     >
      41              :       <div
      42              :         :class="
      43              :           cn(
      44              :             'flex flex-1 items-center gap-2 overflow-hidden py-2 pl-2',
      45              :             size === 'md' ? 'text-xs' : 'text-sm'
      46              :           )
      47              :         "
      48              :       >
      49              :         <i
      50              :           v-if="loading"
      51              :           class="icon-[lucide--loader-circle] animate-spin text-muted-foreground"
      52              :         />
      53              :         <slot v-else name="icon" />
      54              :         <SelectValue :placeholder="label" class="truncate" />
      55              :       </div>
      56              :       <div :class="selectDropdownClass">
      57              :         <i class="icon-[lucide--chevron-down] text-muted-foreground" />
      58              :       </div>
      59              :     </SelectTrigger>
      60              : 
      61              :     <SelectPortal>
      62              :       <SelectContent
      63              :         position="popper"
      64              :         :side-offset="8"
      65              :         align="start"
      66              :         :style="[optionStyle, contentStyle]"
      67              :         :class="cn(selectContentClass, 'min-w-(--reka-select-trigger-width)')"
      68              :         @keydown="onContentKeydown"
      69              :       >
      70              :         <SelectViewport
      71              :           :style="{ maxHeight: `min(${listMaxHeight}, 50vh)` }"
      72              :           class="scrollbar-custom w-full"
      73              :         >
      74              :           <SelectItem
      75              :             v-for="opt in options"
      76              :             :key="opt.value"
      77              :             :value="opt.value"
      78              :             :class="selectItemVariants({ layout: 'single' })"
      79              :           >
      80              :             <SelectItemText class="truncate">
      81              :               {{ opt.name }}
      82              :             </SelectItemText>
      83              :             <SelectItemIndicator
      84              :               class="flex shrink-0 items-center justify-center"
      85              :             >
      86              :               <i
      87              :                 class="icon-[lucide--check] text-foreground"
      88              :                 aria-hidden="true"
      89              :               />
      90              :             </SelectItemIndicator>
      91              :           </SelectItem>
      92              :         </SelectViewport>
      93              :       </SelectContent>
      94              :     </SelectPortal>
      95              :   </SelectRoot>
      96              : </template>
      97              : 
      98              : <script setup lang="ts">
      99              : import {
     100              :   SelectContent,
     101              :   SelectItem,
     102              :   SelectItemIndicator,
     103              :   SelectItemText,
     104              :   SelectRoot,
     105              :   SelectTrigger,
     106              :   SelectValue,
     107              :   SelectViewport,
     108              :   SelectPortal
     109              : } from 'reka-ui'
     110              : import { ref } from 'vue'
     111              : 
     112              : import {
     113              :   selectContentClass,
     114              :   selectDropdownClass,
     115              :   selectItemVariants,
     116              :   selectTriggerVariants,
     117              :   stopEscapeToDocument
     118              : } from '@comfyorg/design-system/select.variants'
     119              : import type { SingleSelectProps } from './types'
     120              : import { useAttrsClass } from '@comfyorg/design-system/lib/composables/useAttrsClass'
     121              : import { usePopoverSizing } from '@comfyorg/design-system/lib/composables/usePopoverSizing'
     122              : import { cn } from '@comfyorg/tailwind-utils'
     123              : 
     124              : import SearchableSingleSelect from './SearchableSingleSelect.vue'
     125              : 
     126              : defineOptions({
     127              :   inheritAttrs: false
     128              : })
     129          991 : const { attrsClass, attrsWithoutClass } = useAttrsClass()
     130              : 
     131              : const {
     132              :   label,
     133              :   accessibleLabel,
     134              :   searchLabel,
     135              :   emptyText,
     136              :   options = [],
     137              :   size = 'lg',
     138              :   invalid = false,
     139              :   loading = false,
     140              :   disabled = false,
     141              :   searchable = false,
     142              :   searchPlaceholder,
     143              :   listMaxHeight = '28rem',
     144              :   popoverMinWidth,
     145              :   popoverMaxWidth,
     146              :   contentStyle
     147              : } = defineProps<SingleSelectProps>()
     148              : 
     149          991 : const selectedItem = defineModel<string | number | undefined>({
     150              :   required: true
     151              : })
     152              : 
     153          991 : const isOpen = ref(false)
     154              : 
     155            0 : function onContentKeydown(event: KeyboardEvent) {
     156            0 :   if (event.key === 'Escape') {
     157            0 :     stopEscapeToDocument(event)
     158            0 :     isOpen.value = false
     159              :   }
     160              : }
     161              : 
     162          991 : const optionStyle = usePopoverSizing({
     163              :   minWidth: popoverMinWidth,
     164              :   maxWidth: popoverMaxWidth
     165              : })
     166              : </script>
        

Generated by: LCOV version 2.0-1