sv5ui 1.1.2 → 1.2.0
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/README.md +6 -0
- package/dist/Alert/Alert.svelte +33 -22
- package/dist/Alert/Alert.svelte.d.ts +1 -1
- package/dist/Alert/alert.types.d.ts +4 -0
- package/dist/Avatar/Avatar.svelte +72 -46
- package/dist/Avatar/avatar.types.d.ts +36 -3
- package/dist/Avatar/avatar.variants.d.ts +138 -0
- package/dist/Avatar/avatar.variants.js +23 -12
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.svelte +11 -6
- package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
- package/dist/AvatarGroup/avatar-group.types.d.ts +18 -3
- package/dist/AvatarGroup/avatar-group.variants.d.ts +85 -0
- package/dist/AvatarGroup/avatar-group.variants.js +19 -29
- package/dist/Badge/Badge.svelte +4 -3
- package/dist/Badge/Badge.svelte.d.ts +1 -1
- package/dist/Badge/badge.types.d.ts +9 -0
- package/dist/Breadcrumb/Breadcrumb.svelte +20 -7
- package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +1 -1
- package/dist/Breadcrumb/breadcrumb.types.d.ts +5 -1
- package/dist/Breadcrumb/breadcrumb.variants.d.ts +15 -5
- package/dist/Breadcrumb/breadcrumb.variants.js +7 -3
- package/dist/Button/Button.svelte +71 -16
- package/dist/Button/Button.svelte.d.ts +0 -1
- package/dist/Button/button.types.d.ts +61 -2
- package/dist/Calendar/Calendar.svelte +4 -0
- package/dist/Calendar/Calendar.svelte.d.ts +1 -1
- package/dist/Calendar/calendar.types.d.ts +4 -0
- package/dist/Card/Card.svelte +5 -4
- package/dist/Card/Card.svelte.d.ts +1 -1
- package/dist/Card/card.types.d.ts +5 -1
- package/dist/Checkbox/Checkbox.svelte +37 -11
- package/dist/Checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/Checkbox/checkbox.types.d.ts +16 -1
- package/dist/Checkbox/checkbox.variants.d.ts +90 -0
- package/dist/Checkbox/checkbox.variants.js +73 -4
- package/dist/Chip/Chip.svelte +3 -2
- package/dist/Chip/Chip.svelte.d.ts +1 -1
- package/dist/Chip/chip.types.d.ts +5 -1
- package/dist/Chip/chip.variants.d.ts +135 -45
- package/dist/Chip/chip.variants.js +9 -9
- package/dist/ContextMenu/ContextMenu.svelte +87 -77
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
- package/dist/ContextMenu/context-menu.types.d.ts +9 -3
- package/dist/ContextMenu/context-menu.types.js +1 -1
- package/dist/ContextMenu/context-menu.variants.d.ts +74 -160
- package/dist/ContextMenu/context-menu.variants.js +63 -95
- package/dist/DropdownMenu/DropdownMenu.svelte +37 -43
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
- package/dist/DropdownMenu/dropdown-menu.types.d.ts +9 -3
- package/dist/DropdownMenu/dropdown-menu.types.js +1 -1
- package/dist/DropdownMenu/dropdown-menu.variants.d.ts +79 -230
- package/dist/DropdownMenu/dropdown-menu.variants.js +68 -111
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/Empty/Empty.svelte +68 -33
- package/dist/Empty/Empty.svelte.d.ts +1 -1
- package/dist/Empty/empty.types.d.ts +26 -9
- package/dist/Empty/empty.variants.d.ts +150 -130
- package/dist/Empty/empty.variants.js +33 -324
- package/dist/FieldGroup/FieldGroup.svelte +11 -6
- package/dist/FieldGroup/FieldGroup.svelte.d.ts +1 -1
- package/dist/FieldGroup/field-group.types.d.ts +4 -0
- package/dist/FormField/FormField.svelte +17 -18
- package/dist/FormField/FormField.svelte.d.ts +1 -1
- package/dist/FormField/form-field.types.d.ts +4 -0
- package/dist/Icon/Icon.svelte +13 -7
- package/dist/Icon/icon.types.d.ts +18 -9
- package/dist/Input/Input.svelte +30 -29
- package/dist/Kbd/Kbd.svelte +13 -3
- package/dist/Kbd/Kbd.svelte.d.ts +1 -1
- package/dist/Kbd/index.d.ts +1 -1
- package/dist/Kbd/kbd.types.d.ts +15 -1
- package/dist/Kbd/kbd.variants.d.ts +92 -30
- package/dist/Kbd/kbd.variants.js +55 -35
- package/dist/Kbd/useKbd.svelte.d.ts +2 -2
- package/dist/Kbd/useKbd.svelte.js +34 -41
- package/dist/Link/Link.svelte +69 -24
- package/dist/Link/Link.svelte.d.ts +1 -1
- package/dist/Link/link.types.d.ts +26 -8
- package/dist/Link/link.variants.d.ts +35 -60
- package/dist/Link/link.variants.js +8 -110
- package/dist/Modal/Modal.svelte +9 -1
- package/dist/Modal/modal.types.d.ts +5 -0
- package/dist/Modal/modal.variants.d.ts +5 -0
- package/dist/Modal/modal.variants.js +1 -0
- package/dist/Pagination/Pagination.svelte +143 -94
- package/dist/Pagination/Pagination.svelte.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/pagination.types.d.ts +21 -2
- package/dist/Pagination/pagination.variants.d.ts +21 -387
- package/dist/Pagination/pagination.variants.js +63 -59
- package/dist/Popover/Popover.svelte +9 -12
- package/dist/Popover/Popover.svelte.d.ts +1 -1
- package/dist/Popover/popover.types.d.ts +4 -0
- package/dist/Popover/popover.variants.d.ts +5 -75
- package/dist/Popover/popover.variants.js +6 -16
- package/dist/Progress/Progress.svelte +58 -30
- package/dist/Progress/progress.types.d.ts +9 -1
- package/dist/Progress/progress.variants.d.ts +55 -25
- package/dist/Progress/progress.variants.js +34 -28
- package/dist/RadioGroup/RadioGroup.svelte +105 -61
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
- package/dist/RadioGroup/radio-group.types.d.ts +16 -1
- package/dist/RadioGroup/radio-group.variants.d.ts +90 -0
- package/dist/RadioGroup/radio-group.variants.js +73 -4
- package/dist/Select/Select.svelte +9 -6
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/select.types.d.ts +4 -0
- package/dist/SelectMenu/SelectMenu.svelte +436 -0
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
- package/dist/SelectMenu/index.d.ts +2 -0
- package/dist/SelectMenu/index.js +1 -0
- package/dist/SelectMenu/select-menu.types.d.ts +262 -0
- package/dist/SelectMenu/select-menu.types.js +1 -0
- package/dist/SelectMenu/select-menu.variants.d.ts +759 -0
- package/dist/SelectMenu/select-menu.variants.js +33 -0
- package/dist/Separator/Separator.svelte +1 -2
- package/dist/Separator/separator.variants.d.ts +1 -5
- package/dist/Separator/separator.variants.js +2 -2
- package/dist/Skeleton/Skeleton.svelte +18 -2
- package/dist/Skeleton/Skeleton.svelte.d.ts +1 -1
- package/dist/Skeleton/skeleton.types.d.ts +10 -1
- package/dist/Slideover/Slideover.svelte +9 -1
- package/dist/Slideover/slideover.types.d.ts +5 -0
- package/dist/Slideover/slideover.variants.d.ts +20 -5
- package/dist/Slideover/slideover.variants.js +4 -29
- package/dist/Switch/Switch.svelte +32 -31
- package/dist/Switch/Switch.svelte.d.ts +1 -1
- package/dist/Switch/switch.types.d.ts +6 -1
- package/dist/Switch/switch.variants.js +6 -6
- package/dist/Tabs/Tabs.svelte +6 -9
- package/dist/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/Tabs/tabs.types.d.ts +4 -0
- package/dist/Tabs/tabs.variants.js +2 -0
- package/dist/Textarea/Textarea.svelte +26 -25
- package/dist/ThemeModeButton/theme-mode-button.types.d.ts +7 -2
- package/dist/Timeline/Timeline.svelte +62 -19
- package/dist/Timeline/Timeline.svelte.d.ts +1 -1
- package/dist/Timeline/index.d.ts +1 -1
- package/dist/Timeline/timeline.types.d.ts +8 -0
- package/dist/Tooltip/Tooltip.svelte +12 -10
- package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/Tooltip/tooltip.types.d.ts +8 -4
- package/dist/Tooltip/tooltip.variants.d.ts +10 -75
- package/dist/Tooltip/tooltip.variants.js +8 -17
- package/dist/User/User.svelte +13 -9
- package/dist/User/User.svelte.d.ts +1 -1
- package/dist/User/user.types.d.ts +4 -0
- package/dist/User/user.variants.d.ts +60 -0
- package/dist/User/user.variants.js +13 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -64,27 +64,32 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
64
64
|
};
|
|
65
65
|
step: {
|
|
66
66
|
active: {
|
|
67
|
-
|
|
67
|
+
step: string;
|
|
68
|
+
};
|
|
69
|
+
first: {
|
|
70
|
+
step: string;
|
|
68
71
|
};
|
|
69
|
-
first: string;
|
|
70
72
|
other: {
|
|
71
|
-
|
|
73
|
+
step: string;
|
|
74
|
+
};
|
|
75
|
+
last: {
|
|
76
|
+
step: string;
|
|
72
77
|
};
|
|
73
|
-
last: string;
|
|
74
78
|
};
|
|
75
79
|
orientation: {
|
|
76
80
|
horizontal: {
|
|
77
81
|
root: string;
|
|
78
82
|
base: string;
|
|
83
|
+
status: string;
|
|
79
84
|
};
|
|
80
85
|
vertical: {
|
|
81
86
|
root: string;
|
|
82
87
|
base: string;
|
|
88
|
+
status: string;
|
|
83
89
|
};
|
|
84
90
|
};
|
|
85
91
|
inverted: {
|
|
86
92
|
true: {
|
|
87
|
-
root: string;
|
|
88
93
|
status: string;
|
|
89
94
|
};
|
|
90
95
|
};
|
|
@@ -94,6 +99,7 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
94
99
|
indicator: string;
|
|
95
100
|
status: string;
|
|
96
101
|
steps: string;
|
|
102
|
+
step: string;
|
|
97
103
|
}, undefined, {
|
|
98
104
|
animation: {
|
|
99
105
|
carousel: string;
|
|
@@ -159,27 +165,32 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
159
165
|
};
|
|
160
166
|
step: {
|
|
161
167
|
active: {
|
|
162
|
-
|
|
168
|
+
step: string;
|
|
169
|
+
};
|
|
170
|
+
first: {
|
|
171
|
+
step: string;
|
|
163
172
|
};
|
|
164
|
-
first: string;
|
|
165
173
|
other: {
|
|
166
|
-
|
|
174
|
+
step: string;
|
|
175
|
+
};
|
|
176
|
+
last: {
|
|
177
|
+
step: string;
|
|
167
178
|
};
|
|
168
|
-
last: string;
|
|
169
179
|
};
|
|
170
180
|
orientation: {
|
|
171
181
|
horizontal: {
|
|
172
182
|
root: string;
|
|
173
183
|
base: string;
|
|
184
|
+
status: string;
|
|
174
185
|
};
|
|
175
186
|
vertical: {
|
|
176
187
|
root: string;
|
|
177
188
|
base: string;
|
|
189
|
+
status: string;
|
|
178
190
|
};
|
|
179
191
|
};
|
|
180
192
|
inverted: {
|
|
181
193
|
true: {
|
|
182
|
-
root: string;
|
|
183
194
|
status: string;
|
|
184
195
|
};
|
|
185
196
|
};
|
|
@@ -189,6 +200,7 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
189
200
|
indicator: string;
|
|
190
201
|
status: string;
|
|
191
202
|
steps: string;
|
|
203
|
+
step: string;
|
|
192
204
|
}, import("tailwind-variants").TVReturnType<{
|
|
193
205
|
animation: {
|
|
194
206
|
carousel: string;
|
|
@@ -254,27 +266,32 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
254
266
|
};
|
|
255
267
|
step: {
|
|
256
268
|
active: {
|
|
257
|
-
|
|
269
|
+
step: string;
|
|
270
|
+
};
|
|
271
|
+
first: {
|
|
272
|
+
step: string;
|
|
258
273
|
};
|
|
259
|
-
first: string;
|
|
260
274
|
other: {
|
|
261
|
-
|
|
275
|
+
step: string;
|
|
276
|
+
};
|
|
277
|
+
last: {
|
|
278
|
+
step: string;
|
|
262
279
|
};
|
|
263
|
-
last: string;
|
|
264
280
|
};
|
|
265
281
|
orientation: {
|
|
266
282
|
horizontal: {
|
|
267
283
|
root: string;
|
|
268
284
|
base: string;
|
|
285
|
+
status: string;
|
|
269
286
|
};
|
|
270
287
|
vertical: {
|
|
271
288
|
root: string;
|
|
272
289
|
base: string;
|
|
290
|
+
status: string;
|
|
273
291
|
};
|
|
274
292
|
};
|
|
275
293
|
inverted: {
|
|
276
294
|
true: {
|
|
277
|
-
root: string;
|
|
278
295
|
status: string;
|
|
279
296
|
};
|
|
280
297
|
};
|
|
@@ -284,6 +301,7 @@ export declare const progressVariants: import("tailwind-variants").TVReturnType<
|
|
|
284
301
|
indicator: string;
|
|
285
302
|
status: string;
|
|
286
303
|
steps: string;
|
|
304
|
+
step: string;
|
|
287
305
|
}, undefined, unknown, unknown, undefined>>;
|
|
288
306
|
export type ProgressVariantProps = VariantProps<typeof progressVariants>;
|
|
289
307
|
export type ProgressSlots = keyof ReturnType<typeof progressVariants>;
|
|
@@ -353,27 +371,32 @@ export declare const progressDefaults: {
|
|
|
353
371
|
};
|
|
354
372
|
step: {
|
|
355
373
|
active: {
|
|
356
|
-
|
|
374
|
+
step: string;
|
|
375
|
+
};
|
|
376
|
+
first: {
|
|
377
|
+
step: string;
|
|
357
378
|
};
|
|
358
|
-
first: string;
|
|
359
379
|
other: {
|
|
360
|
-
|
|
380
|
+
step: string;
|
|
381
|
+
};
|
|
382
|
+
last: {
|
|
383
|
+
step: string;
|
|
361
384
|
};
|
|
362
|
-
last: string;
|
|
363
385
|
};
|
|
364
386
|
orientation: {
|
|
365
387
|
horizontal: {
|
|
366
388
|
root: string;
|
|
367
389
|
base: string;
|
|
390
|
+
status: string;
|
|
368
391
|
};
|
|
369
392
|
vertical: {
|
|
370
393
|
root: string;
|
|
371
394
|
base: string;
|
|
395
|
+
status: string;
|
|
372
396
|
};
|
|
373
397
|
};
|
|
374
398
|
inverted: {
|
|
375
399
|
true: {
|
|
376
|
-
root: string;
|
|
377
400
|
status: string;
|
|
378
401
|
};
|
|
379
402
|
};
|
|
@@ -383,6 +406,7 @@ export declare const progressDefaults: {
|
|
|
383
406
|
indicator: string;
|
|
384
407
|
status: string;
|
|
385
408
|
steps: string;
|
|
409
|
+
step: string;
|
|
386
410
|
}, {
|
|
387
411
|
animation: {
|
|
388
412
|
carousel: string;
|
|
@@ -448,27 +472,32 @@ export declare const progressDefaults: {
|
|
|
448
472
|
};
|
|
449
473
|
step: {
|
|
450
474
|
active: {
|
|
451
|
-
|
|
475
|
+
step: string;
|
|
476
|
+
};
|
|
477
|
+
first: {
|
|
478
|
+
step: string;
|
|
452
479
|
};
|
|
453
|
-
first: string;
|
|
454
480
|
other: {
|
|
455
|
-
|
|
481
|
+
step: string;
|
|
482
|
+
};
|
|
483
|
+
last: {
|
|
484
|
+
step: string;
|
|
456
485
|
};
|
|
457
|
-
last: string;
|
|
458
486
|
};
|
|
459
487
|
orientation: {
|
|
460
488
|
horizontal: {
|
|
461
489
|
root: string;
|
|
462
490
|
base: string;
|
|
491
|
+
status: string;
|
|
463
492
|
};
|
|
464
493
|
vertical: {
|
|
465
494
|
root: string;
|
|
466
495
|
base: string;
|
|
496
|
+
status: string;
|
|
467
497
|
};
|
|
468
498
|
};
|
|
469
499
|
inverted: {
|
|
470
500
|
true: {
|
|
471
|
-
root: string;
|
|
472
501
|
status: string;
|
|
473
502
|
};
|
|
474
503
|
};
|
|
@@ -478,6 +507,7 @@ export declare const progressDefaults: {
|
|
|
478
507
|
indicator: string;
|
|
479
508
|
status: string;
|
|
480
509
|
steps: string;
|
|
510
|
+
step: string;
|
|
481
511
|
}>;
|
|
482
512
|
slots: Partial<Record<ProgressSlots, string>>;
|
|
483
513
|
};
|
|
@@ -4,8 +4,9 @@ export const progressVariants = tv({
|
|
|
4
4
|
root: 'gap-2',
|
|
5
5
|
base: 'relative overflow-hidden rounded-full bg-surface-container-highest',
|
|
6
6
|
indicator: 'rounded-full size-full transition-transform duration-200 ease-out',
|
|
7
|
-
status: 'text-
|
|
8
|
-
steps: '
|
|
7
|
+
status: 'flex text-on-surface-variant transition-[width] duration-200',
|
|
8
|
+
steps: 'grid items-end',
|
|
9
|
+
step: 'truncate text-end row-start-1 col-start-1 transition-opacity'
|
|
9
10
|
},
|
|
10
11
|
variants: {
|
|
11
12
|
animation: {
|
|
@@ -72,32 +73,53 @@ export const progressVariants = tv({
|
|
|
72
73
|
},
|
|
73
74
|
step: {
|
|
74
75
|
active: {
|
|
75
|
-
|
|
76
|
+
step: 'opacity-100'
|
|
77
|
+
},
|
|
78
|
+
first: {
|
|
79
|
+
step: 'opacity-100 text-on-surface-variant'
|
|
76
80
|
},
|
|
77
|
-
first: '',
|
|
78
81
|
other: {
|
|
79
|
-
|
|
82
|
+
step: 'opacity-0'
|
|
80
83
|
},
|
|
81
|
-
last:
|
|
84
|
+
last: {
|
|
85
|
+
step: ''
|
|
86
|
+
}
|
|
82
87
|
},
|
|
83
88
|
orientation: {
|
|
84
89
|
horizontal: {
|
|
85
|
-
root: 'flex flex-col',
|
|
86
|
-
base: 'w-full'
|
|
90
|
+
root: 'w-full flex flex-col',
|
|
91
|
+
base: 'w-full',
|
|
92
|
+
status: 'flex-row items-center justify-end min-w-fit'
|
|
87
93
|
},
|
|
88
94
|
vertical: {
|
|
89
|
-
root: 'flex flex-row-reverse
|
|
90
|
-
base: 'h-full'
|
|
95
|
+
root: 'h-full flex flex-row-reverse',
|
|
96
|
+
base: 'h-full',
|
|
97
|
+
status: 'flex-col justify-end min-h-fit'
|
|
91
98
|
}
|
|
92
99
|
},
|
|
93
100
|
inverted: {
|
|
94
101
|
true: {
|
|
95
|
-
|
|
96
|
-
status: 'text-start'
|
|
102
|
+
status: 'self-end'
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
},
|
|
100
106
|
compoundVariants: [
|
|
107
|
+
{
|
|
108
|
+
inverted: true,
|
|
109
|
+
orientation: 'horizontal',
|
|
110
|
+
class: {
|
|
111
|
+
step: 'text-start',
|
|
112
|
+
status: 'flex-row-reverse'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
inverted: true,
|
|
117
|
+
orientation: 'vertical',
|
|
118
|
+
class: {
|
|
119
|
+
steps: 'items-start',
|
|
120
|
+
status: 'flex-col-reverse'
|
|
121
|
+
}
|
|
122
|
+
},
|
|
101
123
|
{ orientation: 'horizontal', size: '2xs', class: { base: 'h-px' } },
|
|
102
124
|
{ orientation: 'horizontal', size: 'xs', class: { base: 'h-0.5' } },
|
|
103
125
|
{ orientation: 'horizontal', size: 'sm', class: { base: 'h-1' } },
|
|
@@ -167,22 +189,6 @@ export const progressVariants = tv({
|
|
|
167
189
|
class: {
|
|
168
190
|
indicator: 'data-[state=indeterminate]:animate-[elastic-vertical_2s_ease-in-out_infinite]'
|
|
169
191
|
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
inverted: true,
|
|
173
|
-
orientation: 'horizontal',
|
|
174
|
-
class: {
|
|
175
|
-
step: 'text-start',
|
|
176
|
-
status: 'flex-row-reverse'
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
inverted: true,
|
|
181
|
-
orientation: 'vertical',
|
|
182
|
-
class: {
|
|
183
|
-
steps: 'items-start',
|
|
184
|
-
status: 'flex-col-reverse'
|
|
185
|
-
}
|
|
186
192
|
}
|
|
187
193
|
],
|
|
188
194
|
defaultVariants: {
|
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
import { getContext } from 'svelte'
|
|
12
12
|
import Icon from '../Icon/Icon.svelte'
|
|
13
13
|
import type { FormFieldProps } from '../FormField/form-field.types.js'
|
|
14
|
+
import type { RadioGroupItem } from './radio-group.types.js'
|
|
14
15
|
|
|
15
16
|
const config = getComponentConfig('radioGroup', radioGroupDefaults)
|
|
16
17
|
const icons = getComponentConfig('icons', iconsDefaults)
|
|
17
18
|
|
|
18
19
|
let {
|
|
20
|
+
ref = $bindable(null),
|
|
19
21
|
value = $bindable(''),
|
|
20
22
|
onValueChange,
|
|
21
23
|
items = [],
|
|
@@ -24,9 +26,12 @@
|
|
|
24
26
|
name,
|
|
25
27
|
color = config.defaultVariants.color,
|
|
26
28
|
size,
|
|
29
|
+
variant = config.defaultVariants.variant,
|
|
30
|
+
indicator = config.defaultVariants.indicator,
|
|
27
31
|
orientation = config.defaultVariants.orientation,
|
|
28
32
|
disabled = false,
|
|
29
33
|
required = false,
|
|
34
|
+
readonly = false,
|
|
30
35
|
loop = true,
|
|
31
36
|
loading = false,
|
|
32
37
|
loadingIcon = icons.loading,
|
|
@@ -34,7 +39,8 @@
|
|
|
34
39
|
legendSlot,
|
|
35
40
|
labelSlot,
|
|
36
41
|
descriptionSlot,
|
|
37
|
-
class: className
|
|
42
|
+
class: className,
|
|
43
|
+
...restProps
|
|
38
44
|
}: Props = $props()
|
|
39
45
|
|
|
40
46
|
const formFieldContext = getContext<
|
|
@@ -57,16 +63,20 @@
|
|
|
57
63
|
const resolvedName = $derived(name ?? formFieldContext?.name)
|
|
58
64
|
const isDisabled = $derived(disabled || loading)
|
|
59
65
|
|
|
60
|
-
const ariaDescribedBy = $derived
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
const ariaDescribedBy = $derived(
|
|
67
|
+
!formFieldContext
|
|
68
|
+
? undefined
|
|
69
|
+
: hasError
|
|
70
|
+
? `${formFieldContext.ariaId}-error`
|
|
71
|
+
: `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
|
|
72
|
+
)
|
|
65
73
|
|
|
66
74
|
const slots = $derived(
|
|
67
75
|
radioGroupVariants({
|
|
68
76
|
color: resolvedColor,
|
|
69
77
|
size: resolvedSize,
|
|
78
|
+
variant,
|
|
79
|
+
indicator,
|
|
70
80
|
orientation,
|
|
71
81
|
loading,
|
|
72
82
|
required,
|
|
@@ -90,9 +100,75 @@
|
|
|
90
100
|
label: slots.label({ class: [config.slots.label, ui?.label] }),
|
|
91
101
|
description: slots.description({ class: [config.slots.description, ui?.description] })
|
|
92
102
|
}))
|
|
103
|
+
|
|
104
|
+
function handleCardItemClick(e: MouseEvent, btnId: string, itemDisabled: boolean) {
|
|
105
|
+
if (itemDisabled) return
|
|
106
|
+
if ((e.target as Element).closest('button')) return
|
|
107
|
+
document.getElementById(btnId)?.click()
|
|
108
|
+
}
|
|
93
109
|
</script>
|
|
94
110
|
|
|
95
|
-
|
|
111
|
+
{#snippet itemContent(radioItem: RadioGroupItem)}
|
|
112
|
+
{@const itemId = `${resolvedId}-${radioItem.value}`}
|
|
113
|
+
{@const itemDisabled = isDisabled || !!radioItem.disabled}
|
|
114
|
+
<div class={layoutClasses.container}>
|
|
115
|
+
<RadioGroup.Item
|
|
116
|
+
value={radioItem.value}
|
|
117
|
+
disabled={itemDisabled}
|
|
118
|
+
id={itemId}
|
|
119
|
+
class={elementClasses.base}
|
|
120
|
+
>
|
|
121
|
+
{#snippet children({ checked })}
|
|
122
|
+
{#if checked}
|
|
123
|
+
<span class={elementClasses.indicator}>
|
|
124
|
+
{#if loading}
|
|
125
|
+
<Icon name={loadingIcon} class={elementClasses.loadingIcon} />
|
|
126
|
+
{/if}
|
|
127
|
+
</span>
|
|
128
|
+
{/if}
|
|
129
|
+
{/snippet}
|
|
130
|
+
</RadioGroup.Item>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
{#if radioItem.label || radioItem.description || labelSlot || descriptionSlot}
|
|
134
|
+
<div class={layoutClasses.wrapper}>
|
|
135
|
+
{#if labelSlot}
|
|
136
|
+
{@render labelSlot({ item: radioItem })}
|
|
137
|
+
{:else if radioItem.label}
|
|
138
|
+
{#if variant === 'card'}
|
|
139
|
+
<span
|
|
140
|
+
class={[elementClasses.label, itemDisabled && 'cursor-not-allowed']
|
|
141
|
+
.filter(Boolean)
|
|
142
|
+
.join(' ')}>{radioItem.label}</span
|
|
143
|
+
>
|
|
144
|
+
{:else}
|
|
145
|
+
<Label.Root
|
|
146
|
+
for={itemId}
|
|
147
|
+
class={[elementClasses.label, itemDisabled && 'cursor-not-allowed']
|
|
148
|
+
.filter(Boolean)
|
|
149
|
+
.join(' ')}
|
|
150
|
+
>
|
|
151
|
+
{radioItem.label}
|
|
152
|
+
</Label.Root>
|
|
153
|
+
{/if}
|
|
154
|
+
{/if}
|
|
155
|
+
|
|
156
|
+
{#if descriptionSlot}
|
|
157
|
+
{@render descriptionSlot({ item: radioItem })}
|
|
158
|
+
{:else if radioItem.description}
|
|
159
|
+
<p
|
|
160
|
+
class={[elementClasses.description, itemDisabled && 'cursor-not-allowed']
|
|
161
|
+
.filter(Boolean)
|
|
162
|
+
.join(' ')}
|
|
163
|
+
>
|
|
164
|
+
{radioItem.description}
|
|
165
|
+
</p>
|
|
166
|
+
{/if}
|
|
167
|
+
</div>
|
|
168
|
+
{/if}
|
|
169
|
+
{/snippet}
|
|
170
|
+
|
|
171
|
+
<div {...restProps} bind:this={ref} class={layoutClasses.root}>
|
|
96
172
|
<RadioGroup.Root
|
|
97
173
|
bind:value
|
|
98
174
|
{onValueChange}
|
|
@@ -100,6 +176,7 @@
|
|
|
100
176
|
name={resolvedName}
|
|
101
177
|
disabled={isDisabled}
|
|
102
178
|
{required}
|
|
179
|
+
{readonly}
|
|
103
180
|
{loop}
|
|
104
181
|
{orientation}
|
|
105
182
|
aria-describedby={ariaDescribedBy}
|
|
@@ -115,61 +192,28 @@
|
|
|
115
192
|
{/if}
|
|
116
193
|
|
|
117
194
|
{#each items as radioItem (radioItem.value)}
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
<span class={elementClasses.indicator}>
|
|
132
|
-
{#if loading}
|
|
133
|
-
<Icon
|
|
134
|
-
name={loadingIcon}
|
|
135
|
-
class={elementClasses.loadingIcon}
|
|
136
|
-
/>
|
|
137
|
-
{/if}
|
|
138
|
-
</span>
|
|
139
|
-
{/if}
|
|
140
|
-
{/snippet}
|
|
141
|
-
</RadioGroup.Item>
|
|
195
|
+
{#if variant === 'card'}
|
|
196
|
+
<div
|
|
197
|
+
role="none"
|
|
198
|
+
class={layoutClasses.item}
|
|
199
|
+
class:opacity-75={radioItem.disabled && !isDisabled}
|
|
200
|
+
onclick={(e) =>
|
|
201
|
+
handleCardItemClick(
|
|
202
|
+
e,
|
|
203
|
+
`${resolvedId}-${radioItem.value}`,
|
|
204
|
+
isDisabled || !!radioItem.disabled
|
|
205
|
+
)}
|
|
206
|
+
>
|
|
207
|
+
{@render itemContent(radioItem)}
|
|
142
208
|
</div>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
class="{elementClasses.label}{itemDisabled
|
|
152
|
-
? ' cursor-not-allowed'
|
|
153
|
-
: ''}"
|
|
154
|
-
>
|
|
155
|
-
{radioItem.label}
|
|
156
|
-
</Label.Root>
|
|
157
|
-
{/if}
|
|
158
|
-
|
|
159
|
-
{#if descriptionSlot}
|
|
160
|
-
{@render descriptionSlot({ item: radioItem })}
|
|
161
|
-
{:else if radioItem.description}
|
|
162
|
-
<p
|
|
163
|
-
class="{elementClasses.description}{itemDisabled
|
|
164
|
-
? ' cursor-not-allowed'
|
|
165
|
-
: ''}"
|
|
166
|
-
>
|
|
167
|
-
{radioItem.description}
|
|
168
|
-
</p>
|
|
169
|
-
{/if}
|
|
170
|
-
</div>
|
|
171
|
-
{/if}
|
|
172
|
-
</div>
|
|
209
|
+
{:else}
|
|
210
|
+
<div
|
|
211
|
+
class={layoutClasses.item}
|
|
212
|
+
class:opacity-75={radioItem.disabled && !isDisabled}
|
|
213
|
+
>
|
|
214
|
+
{@render itemContent(radioItem)}
|
|
215
|
+
</div>
|
|
216
|
+
{/if}
|
|
173
217
|
{/each}
|
|
174
218
|
</RadioGroup.Root>
|
|
175
219
|
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RadioGroupProps } from './radio-group.types.js';
|
|
2
2
|
export type Props = RadioGroupProps;
|
|
3
3
|
import { RadioGroup } from 'bits-ui';
|
|
4
|
-
declare const RadioGroup: import("svelte").Component<RadioGroupProps, {}, "value">;
|
|
4
|
+
declare const RadioGroup: import("svelte").Component<RadioGroupProps, {}, "ref" | "value">;
|
|
5
5
|
type RadioGroup = ReturnType<typeof RadioGroup>;
|
|
6
6
|
export default RadioGroup;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { RadioGroup as RadioGroupPrimitive } from 'bits-ui';
|
|
3
3
|
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
5
|
import type { RadioGroupVariantProps, RadioGroupSlots } from './radio-group.variants.js';
|
|
5
6
|
export type RadioGroupItem = {
|
|
6
7
|
/**
|
|
@@ -21,7 +22,11 @@ export type RadioGroupItem = {
|
|
|
21
22
|
*/
|
|
22
23
|
disabled?: boolean;
|
|
23
24
|
};
|
|
24
|
-
export type RadioGroupProps = Pick<RadioGroupPrimitive.RootProps, 'disabled' | 'name' | 'required' | 'loop'> & {
|
|
25
|
+
export type RadioGroupProps = Pick<RadioGroupPrimitive.RootProps, 'disabled' | 'name' | 'required' | 'loop' | 'readonly'> & Omit<HTMLAttributes<HTMLElement>, 'class'> & {
|
|
26
|
+
/**
|
|
27
|
+
* Bindable reference to the root DOM element.
|
|
28
|
+
*/
|
|
29
|
+
ref?: HTMLElement | null;
|
|
25
30
|
/**
|
|
26
31
|
* The selected value. Supports two-way binding with `bind:value`.
|
|
27
32
|
*/
|
|
@@ -44,6 +49,16 @@ export type RadioGroupProps = Pick<RadioGroupPrimitive.RootProps, 'disabled' | '
|
|
|
44
49
|
* @default 'md'
|
|
45
50
|
*/
|
|
46
51
|
size?: NonNullable<RadioGroupVariantProps['size']>;
|
|
52
|
+
/**
|
|
53
|
+
* Controls the visual style of each radio item.
|
|
54
|
+
* @default 'list'
|
|
55
|
+
*/
|
|
56
|
+
variant?: NonNullable<RadioGroupVariantProps['variant']>;
|
|
57
|
+
/**
|
|
58
|
+
* Controls the position of the radio indicator.
|
|
59
|
+
* @default 'start'
|
|
60
|
+
*/
|
|
61
|
+
indicator?: NonNullable<RadioGroupVariantProps['indicator']>;
|
|
47
62
|
/**
|
|
48
63
|
* Controls the layout direction.
|
|
49
64
|
* @default 'vertical'
|