uisv 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion.svelte +108 -0
- package/dist/components/accordion.svelte.d.ts +58 -0
- package/dist/components/alert.svelte +271 -0
- package/dist/components/alert.svelte.d.ts +23 -0
- package/dist/components/badge.svelte +225 -0
- package/dist/components/badge.svelte.d.ts +19 -0
- package/dist/components/banner.svelte +254 -0
- package/dist/components/banner.svelte.d.ts +23 -0
- package/dist/components/button/button.svelte +105 -0
- package/dist/components/button/button.svelte.d.ts +4 -0
- package/dist/components/button/index.d.ts +48 -0
- package/dist/components/button/index.js +4 -0
- package/dist/components/button/style.d.ts +148 -0
- package/dist/components/button/style.js +248 -0
- package/dist/components/card.svelte +70 -0
- package/dist/components/card.svelte.d.ts +17 -0
- package/dist/components/checkbox-group.svelte +258 -0
- package/dist/components/checkbox-group.svelte.d.ts +26 -0
- package/dist/components/checkbox.svelte +175 -0
- package/dist/components/checkbox.svelte.d.ts +27 -0
- package/dist/components/chip.svelte +82 -0
- package/dist/components/chip.svelte.d.ts +17 -0
- package/dist/components/color-picker.svelte +48 -0
- package/dist/components/color-picker.svelte.d.ts +10 -0
- package/dist/components/h1.svelte +15 -0
- package/dist/components/h1.svelte.d.ts +3 -0
- package/dist/components/h2.svelte +19 -0
- package/dist/components/h2.svelte.d.ts +3 -0
- package/dist/components/h3.svelte +16 -0
- package/dist/components/h3.svelte.d.ts +3 -0
- package/dist/components/h4.svelte +19 -0
- package/dist/components/h4.svelte.d.ts +3 -0
- package/dist/components/h5.svelte +19 -0
- package/dist/components/h5.svelte.d.ts +3 -0
- package/dist/components/h6.svelte +19 -0
- package/dist/components/h6.svelte.d.ts +3 -0
- package/dist/components/index.d.ts +42 -0
- package/dist/components/index.js +42 -0
- package/dist/components/input/index.d.ts +54 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/input.svelte +103 -0
- package/dist/components/input/input.svelte.d.ts +4 -0
- package/dist/components/input/style.d.ts +316 -0
- package/dist/components/input/style.js +128 -0
- package/dist/components/input-time/index.d.ts +375 -0
- package/dist/components/input-time/index.js +144 -0
- package/dist/components/input-time/input-time.svelte +39 -0
- package/dist/components/input-time/input-time.svelte.d.ts +4 -0
- package/dist/components/kbd.svelte +239 -0
- package/dist/components/kbd.svelte.d.ts +40 -0
- package/dist/components/p.svelte +9 -0
- package/dist/components/p.svelte.d.ts +3 -0
- package/dist/components/pin-input.svelte +162 -0
- package/dist/components/pin-input.svelte.d.ts +25 -0
- package/dist/components/placeholder.svelte +34 -0
- package/dist/components/placeholder.svelte.d.ts +3 -0
- package/dist/components/popover.svelte +151 -0
- package/dist/components/popover.svelte.d.ts +88 -0
- package/dist/components/progress.svelte +124 -0
- package/dist/components/progress.svelte.d.ts +21 -0
- package/dist/components/select.svelte +171 -0
- package/dist/components/select.svelte.d.ts +50 -0
- package/dist/components/slider.svelte +172 -0
- package/dist/components/slider.svelte.d.ts +44 -0
- package/dist/components/switch.svelte +180 -0
- package/dist/components/switch.svelte.d.ts +27 -0
- package/dist/components/tabs.svelte +246 -0
- package/dist/components/tabs.svelte.d.ts +34 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/utilities.svelte.d.ts +24 -0
- package/dist/utilities.svelte.js +47 -0
- package/dist/vite.d.ts +51 -0
- package/dist/vite.js +157 -0
- package/package.json +2 -2
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const BUTTON_VARIANTS = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
icon: '',
|
|
5
|
+
base: 'transition flex-inline items-center font-sans',
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
color: {
|
|
9
|
+
primary: '',
|
|
10
|
+
surface: '',
|
|
11
|
+
error: '',
|
|
12
|
+
success: '',
|
|
13
|
+
info: '',
|
|
14
|
+
warning: '',
|
|
15
|
+
},
|
|
16
|
+
variant: {
|
|
17
|
+
link: '',
|
|
18
|
+
solid: 'text-inverted',
|
|
19
|
+
outline: 'border',
|
|
20
|
+
soft: '',
|
|
21
|
+
subtle: 'border',
|
|
22
|
+
ghost: '',
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
xs: {
|
|
26
|
+
base: 'font-medium text-xs px-2 h-6 rounded gap-1',
|
|
27
|
+
icon: 'size-4',
|
|
28
|
+
},
|
|
29
|
+
sm: { base: 'font-medium text-xs px-2 h-7 rounded gap-1', icon: 'size-4' },
|
|
30
|
+
md: { base: 'font-medium text-sm rounded-md px-2 h-8 gap-2', icon: 'size-5' },
|
|
31
|
+
lg: { base: 'font-medium text-sm px-3 h-9 rounded-md gap-2', icon: 'size-6' },
|
|
32
|
+
xl: { base: 'font-medium px-3 h-10 rounded-md gap-2', icon: 'size-6' },
|
|
33
|
+
},
|
|
34
|
+
block: {
|
|
35
|
+
true: 'w-full',
|
|
36
|
+
},
|
|
37
|
+
disabled: {
|
|
38
|
+
true: 'cursor-not-allowed',
|
|
39
|
+
false: 'cursor-default',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
compoundVariants: [
|
|
43
|
+
{
|
|
44
|
+
color: 'primary',
|
|
45
|
+
variant: 'solid',
|
|
46
|
+
class: 'bg-primary-500 hover:(bg-primary-400)',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
color: 'surface',
|
|
50
|
+
variant: 'solid',
|
|
51
|
+
class: 'bg-surface-inverted text-inverted hover:(bg-toned)',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
color: 'info',
|
|
55
|
+
variant: 'solid',
|
|
56
|
+
class: 'bg-info-500 hover:(bg-info-400)',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
color: 'success',
|
|
60
|
+
variant: 'solid',
|
|
61
|
+
class: 'bg-success-500 hover:(bg-success-400)',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
color: 'error',
|
|
65
|
+
variant: 'solid',
|
|
66
|
+
class: 'bg-error-500 hover:(bg-error-400)',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
color: 'warning',
|
|
70
|
+
variant: 'solid',
|
|
71
|
+
class: 'bg-warning-500 hover:(bg-warning-400)',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
color: 'primary',
|
|
75
|
+
variant: 'outline',
|
|
76
|
+
class: {
|
|
77
|
+
base: [
|
|
78
|
+
'border-primary/50 text-primary-500 hover:(bg-primary-50)',
|
|
79
|
+
'dark:hover:bg-primary-950',
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
color: 'surface',
|
|
85
|
+
variant: 'outline',
|
|
86
|
+
class: {
|
|
87
|
+
base: [
|
|
88
|
+
'border-surface-accented text-surface-inverted hover:bg-surface/10',
|
|
89
|
+
'dark:hover:bg-surface-800',
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
color: 'info',
|
|
95
|
+
variant: 'outline',
|
|
96
|
+
class: {
|
|
97
|
+
base: ['border-info/50 text-blue-500 hover:bg-info/10', 'dark:hover:bg-info-950'],
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
color: 'success',
|
|
102
|
+
variant: 'outline',
|
|
103
|
+
class: {
|
|
104
|
+
base: [
|
|
105
|
+
'border-success/50 text-success-500 hover:bg-success/10',
|
|
106
|
+
'dark:hover:bg-success-950',
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
color: 'error',
|
|
112
|
+
variant: 'outline',
|
|
113
|
+
class: {
|
|
114
|
+
base: ['border-red/50 text-red-500 hover:bg-red/10', 'dark:hover:bg-red-950'],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
color: 'warning',
|
|
119
|
+
variant: 'outline',
|
|
120
|
+
class: {
|
|
121
|
+
base: [
|
|
122
|
+
'border-warning/50 text-warning-500 hover:(bg-warning/10)',
|
|
123
|
+
'dark:hover:bg-warning-950',
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
color: 'primary',
|
|
129
|
+
variant: 'soft',
|
|
130
|
+
class: 'bg-primary-50 text-primary-500 hover:(bg-primary-100)',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
color: 'surface',
|
|
134
|
+
variant: 'soft',
|
|
135
|
+
class: 'bg-surface-100 text-surface-800 hover:(bg-surface-200)',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
color: 'info',
|
|
139
|
+
variant: 'soft',
|
|
140
|
+
class: 'bg-blue-100 text-blue-500 hover:(bg-blue-50)',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
color: 'success',
|
|
144
|
+
variant: 'soft',
|
|
145
|
+
class: 'bg-green-100 text-green-500 hover:(bg-green-50)',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
color: 'error',
|
|
149
|
+
variant: 'soft',
|
|
150
|
+
class: 'bg-red-100 text-red-500 hover:(bg-red-50)',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
color: 'warning',
|
|
154
|
+
variant: 'soft',
|
|
155
|
+
class: 'bg-yellow-100 text-yellow-500 hover:(bg-yellow-50)',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
color: 'primary',
|
|
159
|
+
variant: 'subtle',
|
|
160
|
+
class: 'bg-primary-50 text-primary-500 border-primary-200 hover:(bg-primary-100)',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
color: 'surface',
|
|
164
|
+
variant: 'subtle',
|
|
165
|
+
class: 'bg-surface-50 text-surface-800 border-surface-300 hover:(bg-surface-100)',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
color: 'info',
|
|
169
|
+
variant: 'subtle',
|
|
170
|
+
class: 'bg-blue-50 text-blue-600 border-blue-200 hover:(bg-blue-100)',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
color: 'success',
|
|
174
|
+
variant: 'subtle',
|
|
175
|
+
class: 'bg-green-100 text-green-600 border-green-300 hover:(bg-green-100)',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
color: 'error',
|
|
179
|
+
variant: 'subtle',
|
|
180
|
+
class: 'bg-red-50 text-red-600 border-red-200 hover:(bg-red-100)',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
color: 'warning',
|
|
184
|
+
variant: 'subtle',
|
|
185
|
+
class: 'bg-yellow-50 text-yellow-600 border-yellow-300 hover:(bg-yellow-100)',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
color: 'primary',
|
|
189
|
+
variant: 'ghost',
|
|
190
|
+
class: 'text-primary-500 hover:(bg-primary-100)',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
color: 'surface',
|
|
194
|
+
variant: 'ghost',
|
|
195
|
+
class: 'text-surface-inverted hover:(bg-surface-elevated text-surface-inverted)',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
color: 'info',
|
|
199
|
+
variant: 'ghost',
|
|
200
|
+
class: 'text-blue-600 hover:(bg-blue-100)',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
color: 'success',
|
|
204
|
+
variant: 'ghost',
|
|
205
|
+
class: 'text-green-600 hover:(bg-green-100)',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
color: 'error',
|
|
209
|
+
variant: 'ghost',
|
|
210
|
+
class: 'text-red-600 hover:(bg-red-100)',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
color: 'warning',
|
|
214
|
+
variant: 'ghost',
|
|
215
|
+
class: 'text-yellow-600 hover:(bg-yellow-100)',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
color: 'primary',
|
|
219
|
+
variant: 'link',
|
|
220
|
+
class: 'text-primary-500 hover:(text-primary-400)',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
color: 'surface',
|
|
224
|
+
variant: 'link',
|
|
225
|
+
class: 'text-muted hover:(text-surface-inverted)',
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
color: 'info',
|
|
229
|
+
variant: 'link',
|
|
230
|
+
class: 'text-blue-500 hover:(text-blue-400)',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
color: 'success',
|
|
234
|
+
variant: 'link',
|
|
235
|
+
class: 'text-green-500 hover:(text-green-400)',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
color: 'error',
|
|
239
|
+
variant: 'link',
|
|
240
|
+
class: 'text-red-500 hover:(text-red-400)',
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
color: 'warning',
|
|
244
|
+
variant: 'link',
|
|
245
|
+
class: 'text-yellow-500 hover:(text-yellow-400)',
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import { tv } from 'tailwind-variants';
|
|
5
|
+
|
|
6
|
+
export type CardProps = {
|
|
7
|
+
children: Snippet;
|
|
8
|
+
header?: Snippet;
|
|
9
|
+
footer?: Snippet;
|
|
10
|
+
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
11
|
+
ui?: {
|
|
12
|
+
base?: ClassNameValue;
|
|
13
|
+
header?: ClassNameValue;
|
|
14
|
+
content?: ClassNameValue;
|
|
15
|
+
footer?: ClassNameValue;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
let { header, children, footer, variant = 'solid', ui = {} }: CardProps = $props();
|
|
22
|
+
|
|
23
|
+
const classes = $derived.by(() =>
|
|
24
|
+
tv({
|
|
25
|
+
slots: {
|
|
26
|
+
base: 'rounded overflow-hidden',
|
|
27
|
+
header: 'p-4 sm:px-6',
|
|
28
|
+
content: 'p-4 sm:p-6',
|
|
29
|
+
footer: 'p-4 sm:px-6'
|
|
30
|
+
},
|
|
31
|
+
variants: {
|
|
32
|
+
variant: {
|
|
33
|
+
solid: {
|
|
34
|
+
base: 'bg-surface-900 text-surface-50',
|
|
35
|
+
header: 'border-transparent',
|
|
36
|
+
footer: 'border-transparent'
|
|
37
|
+
},
|
|
38
|
+
outline: {
|
|
39
|
+
base: 'border border-surface-300 divide-y divide-surface-300'
|
|
40
|
+
},
|
|
41
|
+
soft: {
|
|
42
|
+
base: 'bg-surface-50 divide-y divide-surface-300'
|
|
43
|
+
},
|
|
44
|
+
subtle: {
|
|
45
|
+
base: 'bg-surface-50 border-surface-300 border divide-y divide-surface-300'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
compoundVariants: []
|
|
50
|
+
})({ variant })
|
|
51
|
+
);
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<div class={classes.base({ class: [ui.base] })}>
|
|
55
|
+
{#if header}
|
|
56
|
+
<div class={classes.header({ class: [ui.header] })}>
|
|
57
|
+
{@render header()}
|
|
58
|
+
</div>
|
|
59
|
+
{/if}
|
|
60
|
+
|
|
61
|
+
<div class={classes.content({ class: ui.content })}>
|
|
62
|
+
{@render children()}
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
{#if footer}
|
|
66
|
+
<div class={classes.header({ class: [ui.header] })}>
|
|
67
|
+
{@render footer()}
|
|
68
|
+
</div>
|
|
69
|
+
{/if}
|
|
70
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export type CardProps = {
|
|
4
|
+
children: Snippet;
|
|
5
|
+
header?: Snippet;
|
|
6
|
+
footer?: Snippet;
|
|
7
|
+
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
8
|
+
ui?: {
|
|
9
|
+
base?: ClassNameValue;
|
|
10
|
+
header?: ClassNameValue;
|
|
11
|
+
content?: ClassNameValue;
|
|
12
|
+
footer?: ClassNameValue;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const Card: import("svelte").Component<CardProps, {}, "">;
|
|
16
|
+
type Card = ReturnType<typeof Card>;
|
|
17
|
+
export default Card;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
import { tv } from 'tailwind-variants';
|
|
4
|
+
import type { Component, Snippet } from 'svelte';
|
|
5
|
+
import { type PropColor, isComponent, isSnippet, Checkbox } from '../index.js';
|
|
6
|
+
|
|
7
|
+
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
8
|
+
|
|
9
|
+
export type CheckboxGroupProps = {
|
|
10
|
+
color?: PropColor;
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
icon?: string | Snippet | Component;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
15
|
+
value?: any[];
|
|
16
|
+
valuekey?: string;
|
|
17
|
+
variant?: 'list' | 'card' | 'table';
|
|
18
|
+
items: Array<any>;
|
|
19
|
+
labelkey?: string;
|
|
20
|
+
descriptionkey?: string;
|
|
21
|
+
legend?: string | Snippet | Component;
|
|
22
|
+
orientation?: 'horizontal' | 'vertical';
|
|
23
|
+
ui?: {
|
|
24
|
+
root?: ClassNameValue;
|
|
25
|
+
container?: ClassNameValue;
|
|
26
|
+
checkbox?: ClassNameValue;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script lang="ts">
|
|
32
|
+
let {
|
|
33
|
+
value = $bindable([]),
|
|
34
|
+
valuekey = 'value',
|
|
35
|
+
color = 'primary',
|
|
36
|
+
size = 'md',
|
|
37
|
+
variant = 'list',
|
|
38
|
+
items = [],
|
|
39
|
+
labelkey = 'label',
|
|
40
|
+
descriptionkey = 'description',
|
|
41
|
+
legend,
|
|
42
|
+
orientation = 'horizontal',
|
|
43
|
+
ui = {},
|
|
44
|
+
...props
|
|
45
|
+
}: CheckboxGroupProps = $props();
|
|
46
|
+
|
|
47
|
+
const classes = $derived.by(() =>
|
|
48
|
+
tv({
|
|
49
|
+
slots: {
|
|
50
|
+
root: '',
|
|
51
|
+
container: 'flex',
|
|
52
|
+
checkbox: '',
|
|
53
|
+
},
|
|
54
|
+
variants: {
|
|
55
|
+
color: {
|
|
56
|
+
primary: {
|
|
57
|
+
container: [],
|
|
58
|
+
},
|
|
59
|
+
surface: {
|
|
60
|
+
container: [],
|
|
61
|
+
},
|
|
62
|
+
info: {
|
|
63
|
+
container: [],
|
|
64
|
+
},
|
|
65
|
+
success: {
|
|
66
|
+
container: [],
|
|
67
|
+
},
|
|
68
|
+
warning: {
|
|
69
|
+
container: [],
|
|
70
|
+
},
|
|
71
|
+
error: {
|
|
72
|
+
container: [],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
size: {
|
|
76
|
+
xs: {
|
|
77
|
+
container: '',
|
|
78
|
+
icon: 'size-3',
|
|
79
|
+
},
|
|
80
|
+
sm: {
|
|
81
|
+
container: '',
|
|
82
|
+
icon: 'size-3.5',
|
|
83
|
+
},
|
|
84
|
+
md: {
|
|
85
|
+
container: '',
|
|
86
|
+
icon: 'size-4',
|
|
87
|
+
},
|
|
88
|
+
lg: {
|
|
89
|
+
container: '',
|
|
90
|
+
icon: 'size-4.5',
|
|
91
|
+
},
|
|
92
|
+
xl: {
|
|
93
|
+
container: '',
|
|
94
|
+
icon: 'size-5',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
variant: {
|
|
98
|
+
list: { container: 'gap-2' },
|
|
99
|
+
card: { container: 'gap-2', checkbox: 'p-4 rounded-lg border border-neutral-200' },
|
|
100
|
+
table: {
|
|
101
|
+
container: 'gap-0 ',
|
|
102
|
+
checkbox: 'border border-neutral-200 p-4 data-[state=checked]:z-1',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
orientation: {
|
|
106
|
+
horizontal: {
|
|
107
|
+
container: 'flex-row',
|
|
108
|
+
checkbox:
|
|
109
|
+
'[&:not(:last-child)]:(-me-px ms-0) first-of-type:rounded-s-lg last-of-type:rounded-e-lg',
|
|
110
|
+
},
|
|
111
|
+
vertical: {
|
|
112
|
+
container: 'flex-col -space-y-px',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
selected: { true: '', false: '' },
|
|
116
|
+
},
|
|
117
|
+
compoundVariants: [
|
|
118
|
+
{
|
|
119
|
+
color: 'primary',
|
|
120
|
+
selected: true,
|
|
121
|
+
variant: ['table', 'card'],
|
|
122
|
+
class: {
|
|
123
|
+
checkbox: 'border-primary-500',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
color: 'surface',
|
|
128
|
+
selected: true,
|
|
129
|
+
variant: ['table', 'card'],
|
|
130
|
+
class: {
|
|
131
|
+
checkbox: 'border-surface-500',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
color: 'info',
|
|
136
|
+
selected: true,
|
|
137
|
+
variant: ['table', 'card'],
|
|
138
|
+
class: {
|
|
139
|
+
checkbox: 'border-info-500',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
color: 'success',
|
|
144
|
+
selected: true,
|
|
145
|
+
variant: ['table', 'card'],
|
|
146
|
+
class: {
|
|
147
|
+
checkbox: 'border-success-500',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
color: 'warning',
|
|
152
|
+
selected: true,
|
|
153
|
+
variant: ['table', 'card'],
|
|
154
|
+
class: {
|
|
155
|
+
checkbox: 'border-warning-500',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
color: 'error',
|
|
160
|
+
selected: true,
|
|
161
|
+
variant: ['table', 'card'],
|
|
162
|
+
class: {
|
|
163
|
+
checkbox: 'border-error-500',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
{
|
|
168
|
+
color: 'primary',
|
|
169
|
+
selected: true,
|
|
170
|
+
variant: ['table'],
|
|
171
|
+
class: {
|
|
172
|
+
checkbox: 'bg-primary-100',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
color: 'surface',
|
|
177
|
+
selected: true,
|
|
178
|
+
variant: ['table'],
|
|
179
|
+
class: {
|
|
180
|
+
checkbox: 'bg-surface-100',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
color: 'info',
|
|
185
|
+
selected: true,
|
|
186
|
+
variant: ['table'],
|
|
187
|
+
class: {
|
|
188
|
+
checkbox: 'bg-info-100',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
color: 'success',
|
|
193
|
+
selected: true,
|
|
194
|
+
variant: ['table'],
|
|
195
|
+
class: {
|
|
196
|
+
checkbox: 'bg-success-100',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
color: 'warning',
|
|
201
|
+
selected: true,
|
|
202
|
+
variant: ['table'],
|
|
203
|
+
class: {
|
|
204
|
+
checkbox: 'bg-warning-100',
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
color: 'error',
|
|
209
|
+
selected: true,
|
|
210
|
+
variant: ['table'],
|
|
211
|
+
class: {
|
|
212
|
+
checkbox: 'bg-error-100',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
})({ color, size, variant, orientation }),
|
|
217
|
+
);
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<div class={classes.root({ class: [ui.root] })}>
|
|
221
|
+
{#if typeof legend === 'string'}
|
|
222
|
+
<legend>{legend}</legend>
|
|
223
|
+
{:else if isSnippet(legend)}
|
|
224
|
+
{@render legend()}
|
|
225
|
+
{:else if isComponent(legend)}
|
|
226
|
+
{@const Legend = legend}
|
|
227
|
+
<Legend />
|
|
228
|
+
{/if}
|
|
229
|
+
|
|
230
|
+
<fieldset class={classes.container({ class: [ui.container] })}>
|
|
231
|
+
{#each items as item, index (index)}
|
|
232
|
+
{@const key = typeof item === 'object' ? item[valuekey] : item}
|
|
233
|
+
|
|
234
|
+
<Checkbox
|
|
235
|
+
{...props}
|
|
236
|
+
{color}
|
|
237
|
+
as={variant === 'list' ? 'div' : 'label'}
|
|
238
|
+
ui={{
|
|
239
|
+
root: classes.checkbox({
|
|
240
|
+
class: [ui.checkbox],
|
|
241
|
+
selected: value.includes(key),
|
|
242
|
+
}),
|
|
243
|
+
}}
|
|
244
|
+
bind:value={
|
|
245
|
+
() => value.includes(key),
|
|
246
|
+
(v) => {
|
|
247
|
+
if (v) return value.push(key);
|
|
248
|
+
const index = value.findIndex((x) => x === key);
|
|
249
|
+
if (index < 0) return;
|
|
250
|
+
value.splice(index, 1);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
description={typeof item === 'object' ? item[descriptionkey] : undefined}
|
|
254
|
+
label={typeof item === 'object' ? item[labelkey] : item}
|
|
255
|
+
/>
|
|
256
|
+
{/each}
|
|
257
|
+
</fieldset>
|
|
258
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import { type PropColor } from '../index.js';
|
|
4
|
+
export type CheckboxGroupProps = {
|
|
5
|
+
color?: PropColor;
|
|
6
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
|
+
icon?: string | Snippet | Component;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
indicator?: 'start' | 'end' | 'hidden';
|
|
10
|
+
value?: any[];
|
|
11
|
+
valuekey?: string;
|
|
12
|
+
variant?: 'list' | 'card' | 'table';
|
|
13
|
+
items: Array<any>;
|
|
14
|
+
labelkey?: string;
|
|
15
|
+
descriptionkey?: string;
|
|
16
|
+
legend?: string | Snippet | Component;
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
ui?: {
|
|
19
|
+
root?: ClassNameValue;
|
|
20
|
+
container?: ClassNameValue;
|
|
21
|
+
checkbox?: ClassNameValue;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare const CheckboxGroup: Component<CheckboxGroupProps, {}, "value">;
|
|
25
|
+
type CheckboxGroup = ReturnType<typeof CheckboxGroup>;
|
|
26
|
+
export default CheckboxGroup;
|