uisv 0.0.22 → 0.0.24

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.
Files changed (57) hide show
  1. package/dist/components/accordion.svelte +6 -19
  2. package/dist/components/alert.svelte +58 -55
  3. package/dist/components/alert.svelte.d.ts +2 -2
  4. package/dist/components/app.svelte +28 -22
  5. package/dist/components/app.svelte.d.ts +2 -9
  6. package/dist/components/badge.svelte +16 -16
  7. package/dist/components/badge.svelte.d.ts +4 -2
  8. package/dist/components/banner.svelte +11 -15
  9. package/dist/components/banner.svelte.d.ts +2 -2
  10. package/dist/components/breadcrumb.svelte +3 -4
  11. package/dist/components/breadcrumb.svelte.d.ts +1 -1
  12. package/dist/components/button.svelte +10 -8
  13. package/dist/components/card.svelte +1 -1
  14. package/dist/components/checkbox-group.svelte +3 -5
  15. package/dist/components/checkbox-group.svelte.d.ts +3 -3
  16. package/dist/components/checkbox.svelte +12 -22
  17. package/dist/components/checkbox.svelte.d.ts +4 -5
  18. package/dist/components/collapsible.svelte +3 -1
  19. package/dist/components/index.d.ts +5 -0
  20. package/dist/components/index.js +5 -0
  21. package/dist/components/input-number.svelte +3 -2
  22. package/dist/components/input.svelte +9 -18
  23. package/dist/components/kbd.svelte +8 -8
  24. package/dist/components/modal.svelte +2 -2
  25. package/dist/components/navigation-menu.svelte +416 -0
  26. package/dist/components/navigation-menu.svelte.d.ts +20 -0
  27. package/dist/components/progress.svelte +42 -7
  28. package/dist/components/progress.svelte.d.ts +3 -2
  29. package/dist/components/radio-group.svelte +102 -0
  30. package/dist/components/radio-group.svelte.d.ts +27 -0
  31. package/dist/components/select.svelte +19 -11
  32. package/dist/components/select.svelte.d.ts +5 -6
  33. package/dist/components/seperator.svelte +1 -1
  34. package/dist/components/switch.svelte +2 -1
  35. package/dist/components/tabs.svelte +3 -13
  36. package/dist/components/tabs.svelte.d.ts +1 -1
  37. package/dist/components/toast.svelte +173 -0
  38. package/dist/components/toast.svelte.d.ts +8 -0
  39. package/dist/components/toast.svelte.js +11 -0
  40. package/dist/contexts.d.ts +10 -3
  41. package/dist/contexts.js +2 -2
  42. package/dist/index.d.ts +1 -2
  43. package/dist/index.js +1 -2
  44. package/dist/utilities/index.d.ts +5 -0
  45. package/dist/utilities/index.js +5 -0
  46. package/dist/utilities/isComponent.d.ts +7 -0
  47. package/dist/utilities/isComponent.js +10 -0
  48. package/dist/utilities/isSnippet.d.ts +7 -0
  49. package/dist/utilities/isSnippet.js +8 -0
  50. package/dist/utilities/useElementRects.svelte.d.ts +11 -0
  51. package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
  52. package/dist/utilities/useRafFn.svelte.d.ts +43 -0
  53. package/dist/utilities/useRafFn.svelte.js +56 -0
  54. package/dist/utilities/useStyle.svelte.d.ts +8 -0
  55. package/dist/utilities/useStyle.svelte.js +21 -0
  56. package/package.json +37 -27
  57. package/dist/utilities.svelte.d.ts +0 -31
@@ -0,0 +1,416 @@
1
+ <script module lang="ts">
2
+ import { mergeProps, NavigationMenu } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
4
+ import type { ButtonProps } from '../index.js';
5
+ import type { PropColor } from '../types.js';
6
+ import { tv } from 'tailwind-variants';
7
+ import { Button } from './index.js';
8
+
9
+ export type NavigationMenuItem = Omit<ButtonProps, 'value'> & {
10
+ children?: ButtonProps[];
11
+ value?: string;
12
+ };
13
+
14
+ export type NavigationMenuProps = {
15
+ items: NavigationMenuItem[];
16
+ variant?: 'link' | 'pill';
17
+ color?: PropColor;
18
+ [k: `${string}-trailing`]: Snippet;
19
+ [k: `${string}-leading`]: Snippet;
20
+ [k: `${string}-label`]: Snippet;
21
+ [k: `${string}-content`]: Snippet;
22
+ };
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ let { items, variant = 'link', color = 'primary', ...rest }: NavigationMenuProps = $props();
27
+
28
+ const variants = $derived(
29
+ tv({
30
+ slots: {
31
+ root: 'relative flex gap-1.5 [&>div]:min-w-0',
32
+ list: 'isolate min-w-0',
33
+ label:
34
+ 'w-full flex items-center gap-1.5 font-semibold text-xs/5 text-highlighted px-2.5 py-1.5',
35
+ item: 'min-w-0',
36
+ link: 'group relative w-full flex items-center gap-1.5 font-medium text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none focus-visible:before:outline-3',
37
+ link_leading_icon: 'shrink-0 size-5',
38
+ link_leading_avatar: 'shrink-0',
39
+ link_leading_avatar_size: '2xs',
40
+ link_leading_chip_size: 'sm',
41
+ link_trailing: 'group ms-auto inline-flex gap-1.5 items-center',
42
+ link_trailing_badge: 'shrink-0',
43
+ link_trailing_badge_size: 'sm',
44
+ link_trailing_icon:
45
+ 'size-5 transform shrink-0 group-data-[state=open]:rotate-180 transition-transform duration-200',
46
+ link_label: 'truncate',
47
+ link_label_external_icon: 'inline-block size-3 align-top text-dimmed',
48
+ child_list: 'isolate',
49
+ child_label: 'text-xs text-highlighted',
50
+ child_item: '',
51
+ child_link:
52
+ 'group relative size-full flex items-start text-start text-sm before:absolute before:z-[-1] before:rounded-md focus:outline-none focus-visible:outline-none focus-visible:before:outline-3',
53
+ child_link_wrapper: 'min-w-0',
54
+ child_link_icon: 'size-5 shrink-0',
55
+ child_link_label: 'truncate',
56
+ child_link_label_external_icon: 'inline-block size-3 align-top text-dimmed',
57
+ child_link_description: 'text-muted',
58
+ separator: 'px-2 h-px bg-border',
59
+ viewport_wrapper: 'absolute top-full left-0 flex w-full',
60
+ viewport:
61
+ 'relative overflow-hidden bg-default shadow-lg rounded-md ring ring-default h-(--reka-navigation-menu-viewport-height) w-full transition-[width,height,left,right] duration-200 origin-[top_center] data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] z-1',
62
+ content: '',
63
+ indicator:
64
+ 'absolute left-0 data-[state=visible]:animate-[fade-in_100ms_ease-out] data-[state=hidden]:animate-[fade-out_100ms_ease-in] data-[state=hidden]:opacity-0 bottom-0 z-2 w-(--reka-navigation-menu-indicator-size) translate-x-(--reka-navigation-menu-indicator-position) flex h-2.5 items-end justify-center overflow-hidden transition-[translate,width] duration-200',
65
+ arrow:
66
+ 'relative top-[50%] size-2.5 rotate-45 border border-default bg-default z-1 rounded-xs',
67
+ },
68
+ variants: {
69
+ color: {
70
+ primary: {
71
+ link: 'before:outline-primary/25',
72
+ child_link: 'before:outline-primary/25',
73
+ },
74
+ surface: {
75
+ link: 'before:outline-inverted/25',
76
+ child_link: 'before:outline-inverted/25',
77
+ },
78
+ success: {
79
+ link: 'before:outline-success/25',
80
+ child_link: 'before:outline-success/25',
81
+ },
82
+ info: {
83
+ link: 'before:outline-info/25',
84
+ child_link: 'before:outline-info/25',
85
+ },
86
+ warning: {
87
+ link: 'before:outline-warning/25',
88
+ child_link: 'before:outline-warning/25',
89
+ },
90
+ error: {
91
+ link: 'before:outline-error/25',
92
+ child_link: 'before:outline-error/25',
93
+ },
94
+ },
95
+ highlight_color: {
96
+ primary: '',
97
+ surface: '',
98
+ success: '',
99
+ info: '',
100
+ warning: '',
101
+ error: '',
102
+ },
103
+ variant: {
104
+ pill: '',
105
+ link: '',
106
+ },
107
+ orientation: {
108
+ horizontal: {
109
+ root: 'items-center justify-between',
110
+ list: 'flex items-center',
111
+ item: 'py-2',
112
+ link: 'px-2.5 py-1.5 before:inset-x-px before:inset-y-0',
113
+ child_list: 'grid p-2',
114
+ child_link: 'px-3 py-2 gap-2 before:inset-x-px before:inset-y-0',
115
+ child_linkLabel: 'font-medium',
116
+ content: 'absolute top-0 left-0 w-full max-h-[70vh] overflow-y-auto',
117
+ },
118
+ vertical: {
119
+ root: 'flex-col',
120
+ link: 'flex-row px-2.5 py-1.5 before:inset-y-px before:inset-x-0',
121
+ childLabel: 'px-1.5 py-0.5',
122
+ child_link: 'p-1.5 gap-1.5 before:inset-y-px before:inset-x-0',
123
+ },
124
+ },
125
+ content_orientation: {
126
+ horizontal: {
127
+ viewportWrapper: 'justify-center',
128
+ content:
129
+ 'data-[motion=from-start]:animate-[enter-from-left_200ms_ease] data-[motion=from-end]:animate-[enter-from-right_200ms_ease] data-[motion=to-start]:animate-[exit-to-left_200ms_ease] data-[motion=to-end]:animate-[exit-to-right_200ms_ease]',
130
+ },
131
+ vertical: {
132
+ viewport:
133
+ 'sm:w-(--reka-navigation-menu-viewport-width) left-(--reka-navigation-menu-viewport-left) rtl:left-auto rtl:right-[calc(100%-var(--reka-navigation-menu-viewport-left)-var(--reka-navigation-menu-viewport-width))]',
134
+ },
135
+ },
136
+ active: {
137
+ true: {
138
+ child_link: 'before:bg-elevated text-highlighted',
139
+ child_linkIcon: 'text-default',
140
+ },
141
+ false: {
142
+ link: 'text-muted',
143
+ link_leading_icon: 'text-dimmed',
144
+ child_link: [
145
+ 'hover:before:bg-elevated/50 text-default hover:text-highlighted',
146
+ 'transition-colors before:transition-colors',
147
+ ],
148
+ child_linkIcon: ['text-dimmed group-hover:text-default', 'transition-colors'],
149
+ },
150
+ },
151
+ disabled: {
152
+ true: {
153
+ link: 'cursor-not-allowed opacity-75',
154
+ },
155
+ },
156
+ highlight: {
157
+ true: '',
158
+ },
159
+ level: {
160
+ true: '',
161
+ },
162
+ collapsed: {
163
+ true: '',
164
+ },
165
+ },
166
+ compoundVariants: [
167
+ {
168
+ orientation: 'horizontal',
169
+ content_orientation: 'horizontal',
170
+ class: {
171
+ child_list: 'grid-cols-2 gap-2',
172
+ },
173
+ },
174
+ {
175
+ orientation: 'horizontal',
176
+ content_orientation: 'vertical',
177
+ class: {
178
+ child_list: 'gap-1',
179
+ content: 'w-60',
180
+ },
181
+ },
182
+ {
183
+ orientation: 'vertical',
184
+ collapsed: false,
185
+ class: {
186
+ child_list: 'ms-5 border-s border-default',
187
+ child_item: 'ps-1.5 -ms-px',
188
+ content:
189
+ 'data-[state=open]:animate-[collapsible-down_200ms_ease-out] data-[state=closed]:animate-[collapsible-up_200ms_ease-out] data-[state=closed]:overflow-hidden',
190
+ },
191
+ },
192
+ {
193
+ orientation: 'vertical',
194
+ collapsed: true,
195
+ class: {
196
+ link: 'px-1.5',
197
+ link_label: 'hidden',
198
+ link_trailing: 'hidden',
199
+ content: 'shadow-sm rounded-sm min-h-6 p-1',
200
+ },
201
+ },
202
+ {
203
+ orientation: 'horizontal',
204
+ highlight: true,
205
+ class: {
206
+ link: [
207
+ 'after:absolute after:-bottom-2 after:inset-x-2.5 after:block after:h-px after:rounded-full',
208
+ 'after:transition-colors',
209
+ ],
210
+ },
211
+ },
212
+ {
213
+ orientation: 'vertical',
214
+ highlight: true,
215
+ level: true,
216
+ class: {
217
+ link: [
218
+ 'after:absolute after:-start-1.5 after:inset-y-0.5 after:block after:w-px after:rounded-full',
219
+ 'after:transition-colors',
220
+ ],
221
+ },
222
+ },
223
+ {
224
+ disabled: false,
225
+ active: false,
226
+ variant: 'pill',
227
+ class: {
228
+ link: [
229
+ 'hover:text-highlighted hover:before:bg-elevated/50',
230
+ 'transition-colors before:transition-colors',
231
+ ],
232
+ link_leading_icon: ['group-hover:text-default', 'transition-colors'],
233
+ },
234
+ },
235
+ {
236
+ disabled: false,
237
+ active: false,
238
+ variant: 'pill',
239
+ orientation: 'horizontal',
240
+ class: {
241
+ link: 'data-[state=open]:text-highlighted',
242
+ link_leading_icon: 'group-data-[state=open]:text-default',
243
+ },
244
+ },
245
+ {
246
+ disabled: false,
247
+ variant: 'pill',
248
+ highlight: true,
249
+ orientation: 'horizontal',
250
+ class: {
251
+ link: 'data-[state=open]:before:bg-elevated/50',
252
+ },
253
+ },
254
+ {
255
+ disabled: false,
256
+ variant: 'pill',
257
+ highlight: false,
258
+ active: false,
259
+ orientation: 'horizontal',
260
+ class: {
261
+ link: 'data-[state=open]:before:bg-elevated/50',
262
+ },
263
+ },
264
+ {
265
+ color: 'primary',
266
+ variant: 'pill',
267
+ active: true,
268
+ class: {
269
+ link: 'text-primary',
270
+ link_leading_icon: 'text-primary group-data-[state=open]:text-primary',
271
+ },
272
+ },
273
+ {
274
+ color: 'surface',
275
+ variant: 'pill',
276
+ active: true,
277
+ class: {
278
+ link: 'text-highlighted',
279
+ link_leading_icon: 'text-highlighted group-data-[state=open]:text-highlighted',
280
+ },
281
+ },
282
+ {
283
+ variant: 'pill',
284
+ active: true,
285
+ highlight: false,
286
+ class: {
287
+ link: 'before:bg-elevated',
288
+ },
289
+ },
290
+ {
291
+ variant: 'pill',
292
+ active: true,
293
+ highlight: true,
294
+ disabled: false,
295
+ class: {
296
+ link: ['hover:before:bg-elevated/50', 'before:transition-colors'],
297
+ },
298
+ },
299
+ {
300
+ disabled: false,
301
+ active: false,
302
+ variant: 'link',
303
+ class: {
304
+ link: ['hover:text-highlighted', 'transition-colors'],
305
+ link_leading_icon: ['group-hover:text-default', 'transition-colors'],
306
+ },
307
+ },
308
+ {
309
+ disabled: false,
310
+ active: false,
311
+ variant: 'link',
312
+ orientation: 'horizontal',
313
+ class: {
314
+ link: 'data-[state=open]:text-highlighted',
315
+ link_leading_icon: 'group-data-[state=open]:text-default',
316
+ },
317
+ },
318
+ {
319
+ color: 'primary',
320
+ variant: 'link',
321
+ active: true,
322
+ class: {
323
+ link: 'text-primary',
324
+ link_leading_icon: 'text-primary group-data-[state=open]:text-primary',
325
+ },
326
+ },
327
+ {
328
+ color: 'surface',
329
+ variant: 'link',
330
+ active: true,
331
+ class: {
332
+ link: 'text-highlighted',
333
+ link_leading_icon: 'text-highlighted group-data-[state=open]:text-highlighted',
334
+ },
335
+ },
336
+ {
337
+ highlight_color: 'primary',
338
+ highlight: true,
339
+ level: true,
340
+ active: true,
341
+ class: {
342
+ link: 'after:bg-primary',
343
+ },
344
+ },
345
+ {
346
+ highlight_color: 'surface',
347
+ highlight: true,
348
+ level: true,
349
+ active: true,
350
+ class: {
351
+ link: 'after:bg-inverted',
352
+ },
353
+ },
354
+ ],
355
+ })({ color, variant }),
356
+ );
357
+ </script>
358
+
359
+ <NavigationMenu.Root class={variants.root({})}>
360
+ <NavigationMenu.List class={variants.list({})}>
361
+ {#each items as item, idx (idx)}
362
+ {@render item_snippet(item, idx)}
363
+ {/each}
364
+
365
+ <NavigationMenu.Indicator class={variants.indicator({})} />
366
+ </NavigationMenu.List>
367
+
368
+ <NavigationMenu.Viewport class={variants.viewport({})} />
369
+ </NavigationMenu.Root>
370
+
371
+ {#snippet item_snippet(item: NavigationMenuItem, idx: number)}
372
+ <NavigationMenu.Item>
373
+ <NavigationMenu.Trigger />
374
+
375
+ <NavigationMenu.Content />
376
+ </NavigationMenu.Item>
377
+
378
+ <NavigationMenu.Item>
379
+ <NavigationMenu.Trigger />
380
+
381
+ <NavigationMenu.Content>
382
+ <NavigationMenu.Link />
383
+ </NavigationMenu.Content>
384
+ </NavigationMenu.Item>
385
+
386
+ <NavigationMenu.Item></NavigationMenu.Item>
387
+
388
+ <NavigationMenu.Item class={variants.item({})} value={item.value || String(idx)}>
389
+ {#if item.href}
390
+ <NavigationMenu.Link class={variants.link({})}>
391
+ {#snippet child({ props })}
392
+ {@render trigger_snippet({ props, item })}
393
+ {/snippet}
394
+ </NavigationMenu.Link>
395
+ {:else}
396
+ <NavigationMenu.Trigger class={variants.link({})}>
397
+ {#snippet child({ props })}
398
+ {@render trigger_snippet({ props, item })}
399
+ {/snippet}
400
+ </NavigationMenu.Trigger>
401
+ {/if}
402
+
403
+ {#if item.children}
404
+ <NavigationMenu.Content>
405
+ <NavigationMenu.Sub>
406
+ <NavigationMenu.List />
407
+ <NavigationMenu.Viewport />
408
+ </NavigationMenu.Sub>
409
+ </NavigationMenu.Content>
410
+ {/if}
411
+ </NavigationMenu.Item>
412
+ {/snippet}
413
+
414
+ {#snippet trigger_snippet(options: { props?: Record<string, unknown>; item: NavigationMenuItem })}
415
+ <Button {...mergeProps(options.props, options.item)}></Button>
416
+ {/snippet}
@@ -0,0 +1,20 @@
1
+ import { NavigationMenu } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+ import type { ButtonProps } from '../index.js';
4
+ import type { PropColor } from '../types.js';
5
+ export type NavigationMenuItem = Omit<ButtonProps, 'value'> & {
6
+ children?: ButtonProps[];
7
+ value?: string;
8
+ };
9
+ export type NavigationMenuProps = {
10
+ items: NavigationMenuItem[];
11
+ variant?: 'link' | 'pill';
12
+ color?: PropColor;
13
+ [k: `${string}-trailing`]: Snippet;
14
+ [k: `${string}-leading`]: Snippet;
15
+ [k: `${string}-label`]: Snippet;
16
+ [k: `${string}-content`]: Snippet;
17
+ };
18
+ declare const NavigationMenu: import("svelte").Component<NavigationMenuProps, {}, "">;
19
+ type NavigationMenu = ReturnType<typeof NavigationMenu>;
20
+ export default NavigationMenu;
@@ -6,9 +6,9 @@
6
6
  value?: number;
7
7
  max?: number | string[];
8
8
  animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
9
- orientation?: 'horizontal' | 'veritcal';
9
+ orientation?: 'horizontal' | 'vertical';
10
10
  color?: PropColor;
11
- height?: number;
11
+ size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
12
12
  inverted?: boolean;
13
13
  status?: boolean;
14
14
  ui?: {
@@ -16,6 +16,7 @@
16
16
  header?: ClassValue;
17
17
  content?: ClassValue;
18
18
  footer?: ClassValue;
19
+ indicator?: ClassValue;
19
20
  };
20
21
  };
21
22
  </script>
@@ -26,10 +27,10 @@
26
27
  animation,
27
28
  inverted,
28
29
  status,
29
- value,
30
+ value = 0,
30
31
  orientation = 'horizontal',
31
32
  color = 'primary',
32
- height = 8,
33
+ size = 'md',
33
34
  ui = {},
34
35
  }: ProgressProps = $props();
35
36
 
@@ -75,6 +76,19 @@
75
76
  indicator: 'bg-error-500',
76
77
  },
77
78
  },
79
+ size: {
80
+ '2xs': '',
81
+ xs: '',
82
+ sm: '',
83
+ md: '',
84
+ lg: '',
85
+ xl: '',
86
+ '2xl': '',
87
+ },
88
+ orientation: {
89
+ vertical: { indicator: 'w-full top-0 h-(--ui-progress-percentage)' },
90
+ horizontal: { indicator: 'h-full left-0 w-(--ui-progress-percentage)' },
91
+ },
78
92
  animation: {
79
93
  swing: [indeterminate ? 'animate-[swing_2s_ease-in-out_infinite' : ''],
80
94
  carousel: [indeterminate ? '' : ''],
@@ -82,17 +96,38 @@
82
96
  elastic: [indeterminate ? '' : ''],
83
97
  },
84
98
  },
85
- compoundVariants: [],
99
+ compoundVariants: [
100
+ { orientation: 'horizontal', size: '2xs', class: { root: 'h-px' } },
101
+ { orientation: 'horizontal', size: 'xs', class: { root: 'h-0.5' } },
102
+ { orientation: 'horizontal', size: 'sm', class: { root: 'h-1' } },
103
+ { orientation: 'horizontal', size: 'md', class: { root: 'h-2' } },
104
+ { orientation: 'horizontal', size: 'lg', class: { root: 'h-3' } },
105
+ { orientation: 'horizontal', size: 'xl', class: { root: 'h-4' } },
106
+ { orientation: 'horizontal', size: '2xl', class: { root: 'h-5' } },
107
+
108
+ { orientation: 'vertical', size: '2xs', class: { root: 'w-px' } },
109
+ { orientation: 'vertical', size: 'xs', class: { root: 'w-0.5' } },
110
+ { orientation: 'vertical', size: 'sm', class: { root: 'w-1' } },
111
+ { orientation: 'vertical', size: 'md', class: { root: 'w-2' } },
112
+ { orientation: 'vertical', size: 'lg', class: { root: 'w-3' } },
113
+ { orientation: 'vertical', size: 'xl', class: { root: 'w-4' } },
114
+ { orientation: 'vertical', size: '2xl', class: { root: 'w-5' } },
115
+ ],
86
116
  })({
87
117
  color,
88
118
  animation: animation ?? 'swing',
119
+ size,
120
+ orientation,
89
121
  }),
90
122
  );
91
123
  </script>
92
124
 
93
125
  <div data-state-indeterminate={indeterminate}>
94
- <div class={variants.root({ class: [ui.base] })} style:height={`${height}px`}>
95
- <span class={variants.indicator({ class: ['h-full left-0'] })} style:width={`${percentage}%`}>
126
+ <div class={variants.root({ class: [ui.base] })}>
127
+ <span
128
+ class={variants.indicator({ class: ui.indicator })}
129
+ style:--ui-progress-percentage={`${percentage}%`}
130
+ >
96
131
  </span>
97
132
  </div>
98
133
 
@@ -4,9 +4,9 @@ export type ProgressProps = {
4
4
  value?: number;
5
5
  max?: number | string[];
6
6
  animation?: 'swing' | 'carousel' | 'carousel-inverse' | 'elastic';
7
- orientation?: 'horizontal' | 'veritcal';
7
+ orientation?: 'horizontal' | 'vertical';
8
8
  color?: PropColor;
9
- height?: number;
9
+ size?: '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
10
10
  inverted?: boolean;
11
11
  status?: boolean;
12
12
  ui?: {
@@ -14,6 +14,7 @@ export type ProgressProps = {
14
14
  header?: ClassValue;
15
15
  content?: ClassValue;
16
16
  footer?: ClassValue;
17
+ indicator?: ClassValue;
17
18
  };
18
19
  };
19
20
  declare const Progress: import("svelte").Component<ProgressProps, {}, "">;
@@ -0,0 +1,102 @@
1
+ <script module lang="ts">
2
+ import type { PropColor, PropSize, PropVariant } from '../types.js';
3
+ import { RadioGroup } from 'bits-ui';
4
+ import type { Snippet } from 'svelte';
5
+ import { tv } from 'tailwind-variants';
6
+
7
+ export type RadioGroupItem =
8
+ | {
9
+ label?: string;
10
+ description?: string;
11
+ value?: string;
12
+ [k: string | number | symbol]: unknown;
13
+ }
14
+ | string;
15
+
16
+ export type RadioGroupProps = {
17
+ value?: string;
18
+ items: RadioGroupItem[];
19
+ valuekey?: string;
20
+ variant?: 'list' | 'card' | 'table';
21
+ color?: PropColor;
22
+ size?: PropSize;
23
+ orientation?: 'horizontal' | 'vertical';
24
+ indicator?: 'start' | 'end' | 'hidden';
25
+ disabled?: boolean;
26
+ item?: Snippet<[{ item: RadioGroupItem }]>;
27
+ loop?: boolean;
28
+ };
29
+ </script>
30
+
31
+ <script lang="ts">
32
+ let {
33
+ value = $bindable(),
34
+ items,
35
+ valuekey = 'value',
36
+ variant = 'list',
37
+ color = 'primary',
38
+ size = 'md',
39
+ orientation = 'vertical',
40
+ indicator = 'end',
41
+ disabled,
42
+ item: item_snippet,
43
+ loop,
44
+ }: RadioGroupProps = $props();
45
+
46
+ const variants = $derived(
47
+ tv({
48
+ slots: {
49
+ base: 'flex',
50
+ item: '',
51
+ indicator: '',
52
+ wrapper: '',
53
+ },
54
+ variants: {
55
+ color: {},
56
+ variant: {
57
+ list: {},
58
+ card: { item: 'border border-surface-muted rounded-lg' },
59
+ table: { item: 'border border-surface-muted' },
60
+ },
61
+ orientation: {
62
+ horizontal: {
63
+ base: 'flex-row',
64
+ },
65
+ vertical: {
66
+ base: 'flex-col',
67
+ },
68
+ },
69
+ },
70
+ })({}),
71
+ );
72
+ </script>
73
+
74
+ <RadioGroup.Root class={variants.base({})} {orientation} {loop}>
75
+ {#each items as item, idx (idx)}
76
+ {@const is_obj = typeof item === 'object'}
77
+ <div class={variants.item({})}>
78
+ {#if indicator === 'start'}
79
+ {@render indicator_snippet(item)}
80
+ {/if}
81
+
82
+ {#if item_snippet}
83
+ {@render item_snippet({ item })}
84
+ {:else}
85
+ <div class={variants.wrapper({})}>
86
+ <label for="">{is_obj ? item.label : item}</label>
87
+ </div>
88
+ {/if}
89
+
90
+ {#if indicator === 'start'}
91
+ {@render indicator_snippet(item)}
92
+ {/if}
93
+ </div>
94
+ {/each}
95
+ </RadioGroup.Root>
96
+
97
+ {#snippet indicator_snippet(item: RadioGroupItem)}
98
+ <RadioGroup.Item
99
+ value={typeof item === 'string' ? item : (item[valuekey] as string)}
100
+ class={variants.indicator({})}
101
+ />
102
+ {/snippet}
@@ -0,0 +1,27 @@
1
+ import type { PropColor, PropSize } from '../types.js';
2
+ import { RadioGroup } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
4
+ export type RadioGroupItem = {
5
+ label?: string;
6
+ description?: string;
7
+ value?: string;
8
+ [k: string | number | symbol]: unknown;
9
+ } | string;
10
+ export type RadioGroupProps = {
11
+ value?: string;
12
+ items: RadioGroupItem[];
13
+ valuekey?: string;
14
+ variant?: 'list' | 'card' | 'table';
15
+ color?: PropColor;
16
+ size?: PropSize;
17
+ orientation?: 'horizontal' | 'vertical';
18
+ indicator?: 'start' | 'end' | 'hidden';
19
+ disabled?: boolean;
20
+ item?: Snippet<[{
21
+ item: RadioGroupItem;
22
+ }]>;
23
+ loop?: boolean;
24
+ };
25
+ declare const RadioGroup: import("svelte").Component<RadioGroupProps, {}, "value">;
26
+ type RadioGroup = ReturnType<typeof RadioGroup>;
27
+ export default RadioGroup;