Line data Source code
1 16 : <script setup lang="ts">
2 : import { reactiveOmit } from '@vueuse/core'
3 : import type { CheckboxRootEmits, CheckboxRootProps } from 'reka-ui'
4 : import { CheckboxIndicator, CheckboxRoot, useForwardPropsEmits } from 'reka-ui'
5 : import type { HTMLAttributes } from 'vue'
6 :
7 : import { cn } from '@comfyorg/tailwind-utils'
8 :
9 367 : const props = defineProps<
10 : CheckboxRootProps & { class?: HTMLAttributes['class'] }
11 : >()
12 367 : const emits = defineEmits<CheckboxRootEmits>()
13 367 : const forwarded = useForwardPropsEmits(reactiveOmit(props, 'class'), emits)
14 : </script>
15 :
16 : <template>
17 : <CheckboxRoot
18 : v-slot="slotProps"
19 : v-bind="forwarded"
20 : data-slot="checkbox"
21 : :class="
22 : cn(
23 : 'inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm border bg-transparent text-background transition-colors outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-foreground data-[state=checked]:bg-foreground data-[state=indeterminate]:border-foreground data-[state=indeterminate]:bg-foreground',
24 : props.class
25 : )
26 : "
27 : >
28 : <CheckboxIndicator class="flex items-center justify-center">
29 : <slot v-bind="slotProps">
30 : <i
31 : :class="
32 : cn(
33 : 'size-3',
34 : slotProps.state === 'indeterminate'
35 : ? 'icon-[lucide--minus]'
36 : : 'icon-[lucide--check]'
37 : )
38 : "
39 : />
40 : </slot>
41 : </CheckboxIndicator>
42 : </CheckboxRoot>
43 : </template>
|