Line data Source code
1 16 : <template>
2 4 : <RadioGroup
3 : v-model="modelValue"
4 : :name="id"
5 : orientation="horizontal"
6 : class="gap-4"
7 : >
8 24 : <div
9 : v-for="option in normalizedOptions"
10 : :key="option.value"
11 : class="flex items-center"
12 : >
13 : <RadioGroupItem :id="`${id}-${option.value}`" :value="option.value" />
14 : <label :for="`${id}-${option.value}`" class="ml-2 cursor-pointer">
15 : {{ option.text }}
16 : </label>
17 : </div>
18 : </RadioGroup>
19 : </template>
20 :
21 : <script setup lang="ts">
22 : import { computed } from 'vue'
23 :
24 : import RadioGroup from '@comfyorg/design-system/radio-group/RadioGroup'
25 : import RadioGroupItem from '@comfyorg/design-system/radio-group/RadioGroupItem'
26 : import type { SettingOption } from '@comfyorg/settings-core/types'
27 :
28 : const { options = [] } = defineProps<{
29 : options?: (string | SettingOption)[]
30 : id?: string
31 : }>()
32 :
33 4 : const modelValue = defineModel<string | number | null>()
34 :
35 4 : const normalizedOptions = computed(() =>
36 : options.map((option) =>
37 : typeof option === 'string'
38 : ? { text: option, value: option }
39 : : { text: option.text, value: option.value ?? option.text }
40 : )
41 : )
42 : </script>
|