uisv 0.0.23 → 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.
- package/dist/components/accordion.svelte +4 -18
- package/dist/components/alert.svelte +57 -54
- package/dist/components/alert.svelte.d.ts +2 -2
- package/dist/components/badge.svelte +16 -16
- package/dist/components/badge.svelte.d.ts +4 -2
- package/dist/components/banner.svelte +9 -13
- package/dist/components/banner.svelte.d.ts +2 -2
- package/dist/components/button.svelte +8 -6
- package/dist/components/card.svelte +1 -1
- package/dist/components/checkbox-group.svelte +3 -5
- package/dist/components/checkbox-group.svelte.d.ts +3 -3
- package/dist/components/checkbox.svelte +9 -20
- package/dist/components/checkbox.svelte.d.ts +4 -5
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/input.svelte +1 -1
- package/dist/components/kbd.svelte +8 -8
- package/dist/components/navigation-menu.svelte +416 -0
- package/dist/components/navigation-menu.svelte.d.ts +20 -0
- package/dist/components/radio-group.svelte +102 -0
- package/dist/components/radio-group.svelte.d.ts +27 -0
- package/dist/components/select.svelte +17 -10
- package/dist/components/select.svelte.d.ts +5 -6
- package/dist/components/tabs.svelte +3 -13
- package/dist/components/tabs.svelte.d.ts +1 -1
- package/package.json +27 -24
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
return navigator.userAgent.match(/Macintosh;/);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
const kbdKeysSpecificMap = $derived({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
const kbdKeysSpecificMap = $derived.by(() => {
|
|
61
|
+
return {
|
|
62
|
+
meta: macOS?.length ? KBD_KEYS.command : 'Ctrl',
|
|
63
|
+
alt: macOS?.length ? KBD_KEYS.command : 'Ctrl',
|
|
64
|
+
ctrl: macOS?.length ? KBD_KEYS.option : 'Alt',
|
|
65
|
+
};
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
function getKey(value
|
|
67
|
-
if (!value)
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
68
|
+
function getKey(value: KbdKey | string | undefined) {
|
|
69
|
+
if (!value) return;
|
|
70
70
|
|
|
71
71
|
if (['meta', 'alt', 'ctrl'].includes(value)) {
|
|
72
72
|
return kbdKeysSpecificMap[value as KbdSpecificKey];
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
export type SelectProps<T> = {
|
|
19
19
|
items: (SelectItem<T> | SelectItem<T>[])[];
|
|
20
|
-
defaultvalue?: T;
|
|
21
20
|
item?: Snippet<[{ item: SelectItem<T> }]>;
|
|
22
21
|
color?: PropColor;
|
|
23
22
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
@@ -57,13 +56,12 @@
|
|
|
57
56
|
);
|
|
58
57
|
</script>
|
|
59
58
|
|
|
60
|
-
<script lang="ts" generics="T
|
|
59
|
+
<script lang="ts" generics="T">
|
|
61
60
|
let {
|
|
62
61
|
value = $bindable(),
|
|
63
62
|
items,
|
|
64
63
|
type = 'single',
|
|
65
|
-
|
|
66
|
-
item,
|
|
64
|
+
item: item_snippet,
|
|
67
65
|
color = 'primary',
|
|
68
66
|
size = 'md',
|
|
69
67
|
variant = 'outline',
|
|
@@ -110,7 +108,7 @@
|
|
|
110
108
|
itemLeadingChip: 'shrink-0',
|
|
111
109
|
itemLeadingChipSize: '',
|
|
112
110
|
itemTrailing: 'ms-auto inline-flex gap-1.5 items-center',
|
|
113
|
-
|
|
111
|
+
itemtrailingicon: 'shrink-0',
|
|
114
112
|
itemWrapper: 'flex-1 flex flex-col min-w-0',
|
|
115
113
|
itemLabel: 'truncate',
|
|
116
114
|
itemDescription: 'truncate text-label-muted',
|
|
@@ -426,11 +424,20 @@
|
|
|
426
424
|
</Select.Group>
|
|
427
425
|
{:else}
|
|
428
426
|
{@const is_object = typeof item === 'object' && item !== null && 'value' in item}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
>
|
|
433
|
-
{
|
|
427
|
+
{@const item_value = is_object ? item.value : item}
|
|
428
|
+
{@const item_selected = item_value === value}
|
|
429
|
+
|
|
430
|
+
<Select.Item class={variants.item({ class: ui.item })} value={item_value as string}>
|
|
431
|
+
{#if item_snippet}
|
|
432
|
+
{@render item_snippet({ item })}
|
|
433
|
+
{:else}
|
|
434
|
+
{item}
|
|
435
|
+
|
|
436
|
+
<Icon
|
|
437
|
+
name={getAppContext().icons.check}
|
|
438
|
+
class={['ml-auto', !item_selected && 'opacity-0']}
|
|
439
|
+
/>
|
|
440
|
+
{/if}
|
|
434
441
|
</Select.Item>
|
|
435
442
|
{/if}
|
|
436
443
|
{/each}
|
|
@@ -10,7 +10,6 @@ export type SelectItem<T> = T | {
|
|
|
10
10
|
};
|
|
11
11
|
export type SelectProps<T> = {
|
|
12
12
|
items: (SelectItem<T> | SelectItem<T>[])[];
|
|
13
|
-
defaultvalue?: T;
|
|
14
13
|
item?: Snippet<[{
|
|
15
14
|
item: SelectItem<T>;
|
|
16
15
|
}]>;
|
|
@@ -47,14 +46,14 @@ export type SelectProps<T> = {
|
|
|
47
46
|
value?: T[];
|
|
48
47
|
type?: 'multiple';
|
|
49
48
|
});
|
|
50
|
-
declare function $$render<T
|
|
49
|
+
declare function $$render<T>(): {
|
|
51
50
|
props: SelectProps<T>;
|
|
52
51
|
exports: {};
|
|
53
52
|
bindings: "value";
|
|
54
53
|
slots: {};
|
|
55
54
|
events: {};
|
|
56
55
|
};
|
|
57
|
-
declare class __sveltets_Render<T
|
|
56
|
+
declare class __sveltets_Render<T> {
|
|
58
57
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
59
58
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
60
59
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -62,12 +61,12 @@ declare class __sveltets_Render<T extends unknown> {
|
|
|
62
61
|
exports(): {};
|
|
63
62
|
}
|
|
64
63
|
interface $$IsomorphicComponent {
|
|
65
|
-
new <T
|
|
64
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
66
65
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
67
66
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
68
|
-
<T
|
|
67
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
69
68
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
70
69
|
}
|
|
71
70
|
declare const Select: $$IsomorphicComponent;
|
|
72
|
-
type Select<T
|
|
71
|
+
type Select<T> = InstanceType<typeof Select<T>>;
|
|
73
72
|
export default Select;
|