-
Notifications
You must be signed in to change notification settings - Fork 712
/
Copy pathcheckbox.ts
124 lines (123 loc) · 2.93 KB
/
checkbox.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import type { ModuleOptions } from '../module'
export default (options: Required<ModuleOptions>) => ({
slots: {
root: 'relative flex items-start',
container: 'flex items-center',
base: 'rounded-sm ring ring-inset ring-accented overflow-hidden focus-visible:outline-2 focus-visible:outline-offset-2',
indicator: 'flex items-center justify-center size-full text-inverted',
icon: 'shrink-0 size-full',
wrapper: 'w-full',
label: 'block font-medium text-default',
description: 'text-muted'
},
variants: {
color: {
...Object.fromEntries((options.theme.colors || []).map((color: string) => [color, {
base: `focus-visible:outline-${color}`,
indicator: `bg-${color}`
}])),
neutral: {
base: 'focus-visible:outline-inverted',
indicator: 'bg-inverted'
}
},
variant: {
list: {
root: ''
},
card: {
root: 'border border-muted rounded-lg'
}
},
indicator: {
start: {
root: 'flex-row',
wrapper: 'ms-2'
},
end: {
root: 'flex-row-reverse',
wrapper: 'me-2'
},
hidden: {
base: 'sr-only',
wrapper: 'text-center'
}
},
size: {
xs: {
base: 'size-3',
container: 'h-4',
wrapper: 'text-xs'
},
sm: {
base: 'size-3.5',
container: 'h-4',
wrapper: 'text-xs'
},
md: {
base: 'size-4',
container: 'h-5',
wrapper: 'text-sm'
},
lg: {
base: 'size-4.5',
container: 'h-5',
wrapper: 'text-sm'
},
xl: {
base: 'size-5',
container: 'h-6',
wrapper: 'text-base'
}
},
required: {
true: {
label: 'after:content-[\'*\'] after:ms-0.5 after:text-error'
}
},
disabled: {
true: {
base: 'cursor-not-allowed opacity-75',
label: 'cursor-not-allowed opacity-75',
description: 'cursor-not-allowed opacity-75'
}
},
checked: {
true: ''
}
},
compoundVariants: [
{ size: 'xs', variant: 'card', class: { root: 'p-2.5' } },
{ size: 'sm', variant: 'card', class: { root: 'p-3' } },
{ size: 'md', variant: 'card', class: { root: 'p-3.5' } },
{ size: 'lg', variant: 'card', class: { root: 'p-4' } },
{ size: 'xl', variant: 'card', class: { root: 'p-4.5' } },
...(options.theme.colors || []).map((color: string) => ({
color,
variant: 'card',
class: {
root: `has-data-[state=checked]:border-${color}`
}
})),
{
color: 'neutral',
variant: 'card',
class: {
root: 'has-data-[state=checked]:border-inverted'
}
},
{
variant: 'card',
disabled: true,
class: {
root: 'cursor-not-allowed opacity-75'
}
}
],
defaultVariants: {
size: 'md',
color: 'primary',
variant: 'list',
indicator: 'start'
}
})