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.
- package/dist/components/accordion.svelte +6 -19
- package/dist/components/alert.svelte +58 -55
- package/dist/components/alert.svelte.d.ts +2 -2
- package/dist/components/app.svelte +28 -22
- package/dist/components/app.svelte.d.ts +2 -9
- package/dist/components/badge.svelte +16 -16
- package/dist/components/badge.svelte.d.ts +4 -2
- package/dist/components/banner.svelte +11 -15
- package/dist/components/banner.svelte.d.ts +2 -2
- package/dist/components/breadcrumb.svelte +3 -4
- package/dist/components/breadcrumb.svelte.d.ts +1 -1
- package/dist/components/button.svelte +10 -8
- 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 +12 -22
- package/dist/components/checkbox.svelte.d.ts +4 -5
- package/dist/components/collapsible.svelte +3 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/input-number.svelte +3 -2
- package/dist/components/input.svelte +9 -18
- package/dist/components/kbd.svelte +8 -8
- package/dist/components/modal.svelte +2 -2
- package/dist/components/navigation-menu.svelte +416 -0
- package/dist/components/navigation-menu.svelte.d.ts +20 -0
- package/dist/components/progress.svelte +42 -7
- package/dist/components/progress.svelte.d.ts +3 -2
- package/dist/components/radio-group.svelte +102 -0
- package/dist/components/radio-group.svelte.d.ts +27 -0
- package/dist/components/select.svelte +19 -11
- package/dist/components/select.svelte.d.ts +5 -6
- package/dist/components/seperator.svelte +1 -1
- package/dist/components/switch.svelte +2 -1
- package/dist/components/tabs.svelte +3 -13
- package/dist/components/tabs.svelte.d.ts +1 -1
- package/dist/components/toast.svelte +173 -0
- package/dist/components/toast.svelte.d.ts +8 -0
- package/dist/components/toast.svelte.js +11 -0
- package/dist/contexts.d.ts +10 -3
- package/dist/contexts.js +2 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/utilities/index.d.ts +5 -0
- package/dist/utilities/index.js +5 -0
- package/dist/utilities/isComponent.d.ts +7 -0
- package/dist/utilities/isComponent.js +10 -0
- package/dist/utilities/isSnippet.d.ts +7 -0
- package/dist/utilities/isSnippet.js +8 -0
- package/dist/utilities/useElementRects.svelte.d.ts +11 -0
- package/dist/{utilities.svelte.js → utilities/useElementRects.svelte.js} +0 -38
- package/dist/utilities/useRafFn.svelte.d.ts +43 -0
- package/dist/utilities/useRafFn.svelte.js +56 -0
- package/dist/utilities/useStyle.svelte.d.ts +8 -0
- package/dist/utilities/useStyle.svelte.js +21 -0
- package/package.json +37 -27
- package/dist/utilities.svelte.d.ts +0 -31
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
+
import { getAppContext } from '../contexts.js';
|
|
2
3
|
import { Accordion } from 'bits-ui';
|
|
3
4
|
import type { Component, Snippet } from 'svelte';
|
|
4
5
|
import { tv, type ClassValue } from 'tailwind-variants';
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
collapsible = true,
|
|
45
46
|
disabled,
|
|
46
47
|
type = 'single',
|
|
47
|
-
trailingicon =
|
|
48
|
+
trailingicon = getAppContext().icons.chevrondown,
|
|
48
49
|
leading,
|
|
49
50
|
default: defau,
|
|
50
51
|
trailing,
|
|
@@ -63,8 +64,8 @@
|
|
|
63
64
|
content:
|
|
64
65
|
'data-[state=open]:animate-[accordion-down_200ms_ease-out] data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none',
|
|
65
66
|
body: 'text-sm pb-3.5',
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
leadingicon: 'shrink-0 size-5',
|
|
68
|
+
trailingicon:
|
|
68
69
|
'shrink-0 size-5 ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200',
|
|
69
70
|
label: 'text-start break-words',
|
|
70
71
|
},
|
|
@@ -81,23 +82,9 @@
|
|
|
81
82
|
);
|
|
82
83
|
</script>
|
|
83
84
|
|
|
84
|
-
<Accordion.Root
|
|
85
|
-
class={variants.root({ class: ui.root })}
|
|
86
|
-
type="multiple"
|
|
87
|
-
bind:value={
|
|
88
|
-
() => {
|
|
89
|
-
if (!value) return;
|
|
90
|
-
if (Array.isArray(value)) return value;
|
|
91
|
-
return [value];
|
|
92
|
-
},
|
|
93
|
-
(val) => {
|
|
94
|
-
if (!val) return (value = val);
|
|
95
|
-
value = type === 'single' ? val[0] : val;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
>
|
|
85
|
+
<Accordion.Root class={variants.root({ class: ui.root })} {type} bind:value>
|
|
99
86
|
{#each items as item, idx (idx)}
|
|
100
|
-
<Accordion.Item value="item-
|
|
87
|
+
<Accordion.Item value="item-{idx}">
|
|
101
88
|
<Accordion.Header>
|
|
102
89
|
<Accordion.Trigger>{item.label}</Accordion.Trigger>
|
|
103
90
|
</Accordion.Header>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import type { Component, Snippet } from 'svelte';
|
|
11
11
|
import { tv, type ClassValue } from 'tailwind-variants';
|
|
12
12
|
import { defu } from 'defu';
|
|
13
|
-
import {
|
|
13
|
+
import { getAppContext } from '../contexts.js';
|
|
14
14
|
|
|
15
15
|
export type AlertProps = {
|
|
16
16
|
title?: string | Snippet;
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
icon?: string | Snippet | Component;
|
|
19
19
|
color?: PropColor;
|
|
20
20
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
21
|
-
position?: 'bottom' | 'right';
|
|
22
21
|
actions?: ButtonProps[];
|
|
23
22
|
close?: boolean | ButtonProps;
|
|
24
23
|
ui?: {
|
|
@@ -27,7 +26,8 @@
|
|
|
27
26
|
description?: ClassValue;
|
|
28
27
|
title?: ClassValue;
|
|
29
28
|
};
|
|
30
|
-
onclose?: () =>
|
|
29
|
+
onclose?: () => unknown | Promise<() => unknown>;
|
|
30
|
+
orientation?: 'horizontal' | 'vertical';
|
|
31
31
|
};
|
|
32
32
|
</script>
|
|
33
33
|
|
|
@@ -40,29 +40,19 @@
|
|
|
40
40
|
actions = [],
|
|
41
41
|
color = 'primary',
|
|
42
42
|
variant = 'solid',
|
|
43
|
-
position = 'bottom',
|
|
44
43
|
ui = {},
|
|
45
44
|
onclose = () => {},
|
|
45
|
+
orientation = 'vertical',
|
|
46
46
|
}: AlertProps = $props();
|
|
47
47
|
|
|
48
|
-
const close_props = $derived.by(() => {
|
|
49
|
-
return defu(typeof close === 'boolean' ? {} : close, {
|
|
50
|
-
icon: app_icons.get().close,
|
|
51
|
-
variant: 'link',
|
|
52
|
-
color: variant === 'solid' ? 'surface' : color,
|
|
53
|
-
ui: {
|
|
54
|
-
icon: variant === 'solid' ? 'text-white' : '',
|
|
55
|
-
},
|
|
56
|
-
} as ButtonProps);
|
|
57
|
-
});
|
|
58
48
|
const variants = $derived.by(() =>
|
|
59
49
|
tv({
|
|
60
50
|
slots: {
|
|
61
51
|
base: 'flex gap-2 font-sans p-4 rounded-lg',
|
|
62
|
-
icon: 'pi size-
|
|
63
|
-
actions: '',
|
|
64
|
-
description: '
|
|
65
|
-
title: 'font-medium',
|
|
52
|
+
icon: 'pi size-5',
|
|
53
|
+
actions: 'flex flex-wrap gap-1.5 shrink-0',
|
|
54
|
+
description: 'opacity-90 mt-1 text-sm',
|
|
55
|
+
title: 'font-medium font-sm',
|
|
66
56
|
},
|
|
67
57
|
variants: {
|
|
68
58
|
color: {
|
|
@@ -75,20 +65,16 @@
|
|
|
75
65
|
},
|
|
76
66
|
variant: {
|
|
77
67
|
solid: {
|
|
78
|
-
base: 'text-
|
|
79
|
-
description: 'text-
|
|
68
|
+
base: 'text-surface-base',
|
|
69
|
+
description: 'text-surface-base/90',
|
|
80
70
|
},
|
|
81
|
-
outline: '
|
|
71
|
+
outline: 'ring ring-inset',
|
|
82
72
|
soft: '',
|
|
83
|
-
subtle: '
|
|
73
|
+
subtle: 'ring ring-inset',
|
|
84
74
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
89
|
-
bottom: {
|
|
90
|
-
base: 'flex-col',
|
|
91
|
-
},
|
|
75
|
+
orientation: {
|
|
76
|
+
horizontal: '',
|
|
77
|
+
vertical: 'flex-col',
|
|
92
78
|
},
|
|
93
79
|
},
|
|
94
80
|
compoundVariants: [
|
|
@@ -126,38 +112,38 @@
|
|
|
126
112
|
{
|
|
127
113
|
variant: 'outline',
|
|
128
114
|
color: 'primary',
|
|
129
|
-
class: '
|
|
115
|
+
class: 'ring-primary/50 text-primary-500',
|
|
130
116
|
},
|
|
131
117
|
{
|
|
132
118
|
variant: 'outline',
|
|
133
119
|
color: 'surface',
|
|
134
|
-
class: '
|
|
120
|
+
class: 'ring-surface-accented text-surface-inverted',
|
|
135
121
|
},
|
|
136
122
|
{
|
|
137
123
|
variant: 'outline',
|
|
138
124
|
color: 'info',
|
|
139
|
-
class: '
|
|
125
|
+
class: 'ring-info/50 text-info-500',
|
|
140
126
|
},
|
|
141
127
|
{
|
|
142
128
|
variant: 'outline',
|
|
143
129
|
color: 'success',
|
|
144
|
-
class: '
|
|
130
|
+
class: 'ring-success/50 text-success-500',
|
|
145
131
|
},
|
|
146
132
|
{
|
|
147
133
|
variant: 'outline',
|
|
148
134
|
color: 'warning',
|
|
149
|
-
class: '
|
|
135
|
+
class: 'ring-warning/50 text-warning-500',
|
|
150
136
|
},
|
|
151
137
|
{
|
|
152
138
|
variant: 'outline',
|
|
153
139
|
color: 'error',
|
|
154
|
-
class: '
|
|
140
|
+
class: 'ring-error/50 text-error-500',
|
|
155
141
|
},
|
|
156
142
|
|
|
157
143
|
{
|
|
158
144
|
variant: 'soft',
|
|
159
145
|
color: 'primary',
|
|
160
|
-
class: 'bg-primary
|
|
146
|
+
class: 'bg-primary/10 text-primary-500',
|
|
161
147
|
},
|
|
162
148
|
{
|
|
163
149
|
variant: 'soft',
|
|
@@ -167,61 +153,61 @@
|
|
|
167
153
|
{
|
|
168
154
|
variant: 'soft',
|
|
169
155
|
color: 'info',
|
|
170
|
-
class: 'bg-info
|
|
156
|
+
class: 'bg-info/10 text-info-500',
|
|
171
157
|
},
|
|
172
158
|
{
|
|
173
159
|
variant: 'soft',
|
|
174
160
|
color: 'success',
|
|
175
|
-
class: 'bg-success
|
|
161
|
+
class: 'bg-success/10 text-success-500',
|
|
176
162
|
},
|
|
177
163
|
{
|
|
178
164
|
variant: 'soft',
|
|
179
165
|
color: 'warning',
|
|
180
|
-
class: 'bg-warning
|
|
166
|
+
class: 'bg-warning/10 text-warning-500',
|
|
181
167
|
},
|
|
182
168
|
{
|
|
183
169
|
variant: 'soft',
|
|
184
170
|
color: 'error',
|
|
185
|
-
class: 'bg-error
|
|
171
|
+
class: 'bg-error/10 text-error-500',
|
|
186
172
|
},
|
|
187
173
|
|
|
188
174
|
{
|
|
189
175
|
variant: 'subtle',
|
|
190
176
|
color: 'primary',
|
|
191
|
-
class: 'bg-primary
|
|
177
|
+
class: 'bg-primary/10 text-primary/50 ring-primary-300',
|
|
192
178
|
},
|
|
193
179
|
{
|
|
194
180
|
variant: 'subtle',
|
|
195
181
|
color: 'surface',
|
|
196
|
-
class: 'bg-surface-muted text-surface-inverted
|
|
182
|
+
class: 'bg-surface-muted text-surface-inverted ring-surface-accented',
|
|
197
183
|
},
|
|
198
184
|
{
|
|
199
185
|
variant: 'subtle',
|
|
200
186
|
color: 'info',
|
|
201
|
-
class: 'bg-info
|
|
187
|
+
class: 'bg-info/10 text-info-500 ring-info/50',
|
|
202
188
|
},
|
|
203
189
|
{
|
|
204
190
|
variant: 'subtle',
|
|
205
191
|
color: 'success',
|
|
206
|
-
class: 'bg-success
|
|
192
|
+
class: 'bg-success/10 text-success-500 ring-success/50',
|
|
207
193
|
},
|
|
208
194
|
{
|
|
209
195
|
variant: 'subtle',
|
|
210
196
|
color: 'warning',
|
|
211
|
-
class: 'bg-warning
|
|
197
|
+
class: 'bg-warning/10 text-warning-500 ring-warning/50',
|
|
212
198
|
},
|
|
213
199
|
{
|
|
214
200
|
variant: 'subtle',
|
|
215
201
|
color: 'error',
|
|
216
|
-
class: 'bg-error
|
|
202
|
+
class: 'bg-error/10 text-error-500 ring-error/50',
|
|
217
203
|
},
|
|
218
204
|
],
|
|
219
|
-
})({ color, variant,
|
|
205
|
+
})({ color, variant, orientation }),
|
|
220
206
|
);
|
|
221
207
|
</script>
|
|
222
208
|
|
|
223
|
-
<div class={variants.base({ class: [
|
|
224
|
-
<div class="flex gap-2
|
|
209
|
+
<div class={variants.base({ class: [ui.base] })}>
|
|
210
|
+
<div class="flex gap-2 flex-1">
|
|
225
211
|
{#if isSnippet(icon)}
|
|
226
212
|
{@render icon()}
|
|
227
213
|
{:else}
|
|
@@ -250,22 +236,39 @@
|
|
|
250
236
|
{/if}
|
|
251
237
|
</div>
|
|
252
238
|
|
|
239
|
+
{#if orientation === 'horizontal'}
|
|
240
|
+
{@render actions_snippet()}
|
|
241
|
+
{/if}
|
|
242
|
+
|
|
253
243
|
{#if close}
|
|
254
244
|
<div>
|
|
255
|
-
<Button
|
|
245
|
+
<Button
|
|
246
|
+
{...defu(typeof close === 'boolean' ? {} : close, {
|
|
247
|
+
icon: getAppContext().icons.close,
|
|
248
|
+
variant: 'link',
|
|
249
|
+
color: 'surface',
|
|
250
|
+
onclick: onclose,
|
|
251
|
+
} as ButtonProps)}
|
|
252
|
+
/>
|
|
256
253
|
</div>
|
|
257
254
|
{/if}
|
|
258
255
|
</div>
|
|
259
256
|
|
|
260
|
-
{#if
|
|
257
|
+
{#if orientation === 'vertical'}
|
|
258
|
+
{@render actions_snippet()}
|
|
259
|
+
{/if}
|
|
260
|
+
</div>
|
|
261
|
+
|
|
262
|
+
{#snippet actions_snippet()}
|
|
263
|
+
{#if actions.length}
|
|
261
264
|
<div class="flex gap-2 items-center pl-8">
|
|
262
|
-
{#each actions as action (
|
|
265
|
+
{#each actions as action, idx (idx)}
|
|
263
266
|
<Button
|
|
264
|
-
{...defu(action, {
|
|
267
|
+
{...defu(action, <ButtonProps>{
|
|
265
268
|
size: 'xs',
|
|
266
|
-
}
|
|
269
|
+
})}
|
|
267
270
|
/>
|
|
268
271
|
{/each}
|
|
269
272
|
</div>
|
|
270
273
|
{/if}
|
|
271
|
-
|
|
274
|
+
{/snippet}
|
|
@@ -7,7 +7,6 @@ export type AlertProps = {
|
|
|
7
7
|
icon?: string | Snippet | Component;
|
|
8
8
|
color?: PropColor;
|
|
9
9
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
10
|
-
position?: 'bottom' | 'right';
|
|
11
10
|
actions?: ButtonProps[];
|
|
12
11
|
close?: boolean | ButtonProps;
|
|
13
12
|
ui?: {
|
|
@@ -16,7 +15,8 @@ export type AlertProps = {
|
|
|
16
15
|
description?: ClassValue;
|
|
17
16
|
title?: ClassValue;
|
|
18
17
|
};
|
|
19
|
-
onclose?: () =>
|
|
18
|
+
onclose?: () => unknown | Promise<() => unknown>;
|
|
19
|
+
orientation?: 'horizontal' | 'vertical';
|
|
20
20
|
};
|
|
21
21
|
declare const Alert: Component<AlertProps, {}, "">;
|
|
22
22
|
type Alert = ReturnType<typeof Alert>;
|
|
@@ -1,57 +1,63 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DEFAULT_ICONS, setAppContext, type AppContext } from '../contexts.js';
|
|
3
|
+
import { mode, ModeWatcher } from '../mode.js';
|
|
4
4
|
import { Tooltip } from 'bits-ui';
|
|
5
5
|
import defu from 'defu';
|
|
6
6
|
import { type Snippet } from 'svelte';
|
|
7
|
-
import { Toaster
|
|
7
|
+
import { Toaster } from 'svelte-sonner';
|
|
8
8
|
import { boxWith } from 'svelte-toolbelt';
|
|
9
9
|
import { Icon } from './index.js';
|
|
10
10
|
|
|
11
|
-
export type AppProps = {
|
|
11
|
+
export type AppProps = Partial<AppContext> & {
|
|
12
12
|
children?: Snippet;
|
|
13
|
-
modewatcher?: ModeWatcherProps;
|
|
14
|
-
toaster?: ToasterProps;
|
|
15
|
-
tooltip?: Tooltip.ProviderProps;
|
|
16
|
-
icons?: Partial<Record<AppIcons, `i-${string}:${string}`>>;
|
|
17
13
|
};
|
|
18
14
|
</script>
|
|
19
15
|
|
|
20
16
|
<script lang="ts">
|
|
21
|
-
let { children, modewatcher, toaster, tooltip, icons = {} }: AppProps = $props();
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
let { children, modewatcher = {}, toaster = {}, tooltip = {}, icons = {} }: AppProps = $props();
|
|
18
|
+
|
|
19
|
+
const context = boxWith(() =>
|
|
20
|
+
defu({ icons, toaster, modewatcher, tooltip }, <AppContext>{
|
|
21
|
+
icons: DEFAULT_ICONS,
|
|
22
|
+
toaster: {
|
|
23
|
+
visibleToasts: 5,
|
|
24
|
+
duration: 6000,
|
|
25
|
+
theme: mode.current,
|
|
26
|
+
},
|
|
27
|
+
modewatcher: {},
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
30
|
+
setAppContext(context.current);
|
|
26
31
|
</script>
|
|
27
32
|
|
|
28
|
-
<ModeWatcher {...modewatcher} />
|
|
29
|
-
|
|
33
|
+
<ModeWatcher {...context.current.modewatcher} />
|
|
34
|
+
|
|
35
|
+
<Toaster {...context.current.toaster}>
|
|
30
36
|
{#snippet infoIcon()}
|
|
31
|
-
<Icon name={
|
|
37
|
+
<Icon name={context.current.icons.info} />
|
|
32
38
|
{/snippet}
|
|
33
39
|
|
|
34
40
|
{#snippet closeIcon()}
|
|
35
|
-
<Icon name={
|
|
41
|
+
<Icon name={context.current.icons.close} />
|
|
36
42
|
{/snippet}
|
|
37
43
|
|
|
38
44
|
{#snippet errorIcon()}
|
|
39
|
-
<Icon name={
|
|
45
|
+
<Icon name={context.current.icons.error} />
|
|
40
46
|
{/snippet}
|
|
41
47
|
|
|
42
48
|
{#snippet loadingIcon()}
|
|
43
|
-
<Icon name={
|
|
49
|
+
<Icon name={context.current.icons.loading} />
|
|
44
50
|
{/snippet}
|
|
45
51
|
|
|
46
52
|
{#snippet successIcon()}
|
|
47
|
-
<Icon name={
|
|
53
|
+
<Icon name={context.current.icons.success} />
|
|
48
54
|
{/snippet}
|
|
49
55
|
|
|
50
56
|
{#snippet warningIcon()}
|
|
51
|
-
<Icon name={
|
|
57
|
+
<Icon name={context.current.icons.warning} />
|
|
52
58
|
{/snippet}
|
|
53
59
|
</Toaster>
|
|
54
60
|
|
|
55
|
-
<Tooltip.Provider {...tooltip}>
|
|
61
|
+
<Tooltip.Provider {...context.current.tooltip}>
|
|
56
62
|
{@render children?.()}
|
|
57
63
|
</Tooltip.Provider>
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type ModeWatcherProps } from '../mode.js';
|
|
3
|
-
import { Tooltip } from 'bits-ui';
|
|
1
|
+
import { type AppContext } from '../contexts.js';
|
|
4
2
|
import { type Snippet } from 'svelte';
|
|
5
|
-
|
|
6
|
-
export type AppProps = {
|
|
3
|
+
export type AppProps = Partial<AppContext> & {
|
|
7
4
|
children?: Snippet;
|
|
8
|
-
modewatcher?: ModeWatcherProps;
|
|
9
|
-
toaster?: ToasterProps;
|
|
10
|
-
tooltip?: Tooltip.ProviderProps;
|
|
11
|
-
icons?: Partial<Record<AppIcons, `i-${string}:${string}`>>;
|
|
12
5
|
};
|
|
13
6
|
declare const App: import("svelte").Component<AppProps, {}, "">;
|
|
14
7
|
type App = ReturnType<typeof App>;
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
color?: PropColor;
|
|
10
10
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
11
11
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
-
icon?: string |
|
|
13
|
-
|
|
12
|
+
icon?: string | Component;
|
|
13
|
+
iconposition?: 'leading' | 'trailing';
|
|
14
14
|
children?: Snippet;
|
|
15
|
+
leading?: Snippet;
|
|
16
|
+
trailing?: Snippet;
|
|
15
17
|
ui?: {
|
|
16
18
|
base?: ClassValue;
|
|
17
19
|
icon?: ClassValue;
|
|
@@ -23,12 +25,14 @@
|
|
|
23
25
|
let {
|
|
24
26
|
icon,
|
|
25
27
|
label,
|
|
26
|
-
|
|
28
|
+
iconposition = 'leading',
|
|
27
29
|
color = 'primary',
|
|
28
30
|
size = 'md',
|
|
29
31
|
variant = 'solid',
|
|
30
32
|
ui = {},
|
|
31
33
|
children,
|
|
34
|
+
leading,
|
|
35
|
+
trailing,
|
|
32
36
|
}: BadgeProps = $props();
|
|
33
37
|
|
|
34
38
|
const variants = $derived.by(() => {
|
|
@@ -45,7 +49,7 @@
|
|
|
45
49
|
},
|
|
46
50
|
variant: {
|
|
47
51
|
link: '',
|
|
48
|
-
solid: 'text-
|
|
52
|
+
solid: 'text-label-inverted',
|
|
49
53
|
outline: 'border',
|
|
50
54
|
soft: '',
|
|
51
55
|
subtle: 'border',
|
|
@@ -196,12 +200,10 @@
|
|
|
196
200
|
class: [icon && !(children || label) ? 'px-0 aspect-square justify-center' : '', ui.base],
|
|
197
201
|
})}
|
|
198
202
|
>
|
|
199
|
-
{#if
|
|
200
|
-
{
|
|
201
|
-
|
|
202
|
-
{:
|
|
203
|
-
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
204
|
-
{/if}
|
|
203
|
+
{#if leading}
|
|
204
|
+
{@render leading()}
|
|
205
|
+
{:else if iconposition === 'leading'}
|
|
206
|
+
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
205
207
|
{/if}
|
|
206
208
|
|
|
207
209
|
{#if label}
|
|
@@ -210,11 +212,9 @@
|
|
|
210
212
|
{@render children?.()}
|
|
211
213
|
{/if}
|
|
212
214
|
|
|
213
|
-
{#if
|
|
214
|
-
{
|
|
215
|
-
|
|
216
|
-
{:
|
|
217
|
-
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
218
|
-
{/if}
|
|
215
|
+
{#if trailing}
|
|
216
|
+
{@render trailing()}
|
|
217
|
+
{:else if iconposition === 'trailing'}
|
|
218
|
+
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
219
219
|
{/if}
|
|
220
220
|
</span>
|
|
@@ -6,9 +6,11 @@ export type BadgeProps = {
|
|
|
6
6
|
color?: PropColor;
|
|
7
7
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
8
8
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
-
icon?: string |
|
|
10
|
-
|
|
9
|
+
icon?: string | Component;
|
|
10
|
+
iconposition?: 'leading' | 'trailing';
|
|
11
11
|
children?: Snippet;
|
|
12
|
+
leading?: Snippet;
|
|
13
|
+
trailing?: Snippet;
|
|
12
14
|
ui?: {
|
|
13
15
|
base?: ClassValue;
|
|
14
16
|
icon?: ClassValue;
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
import type { Component, Snippet } from 'svelte';
|
|
11
11
|
import { tv, type ClassValue } from 'tailwind-variants';
|
|
12
12
|
import { defu } from 'defu';
|
|
13
|
-
import {
|
|
13
|
+
import { getAppContext } from '../contexts.js';
|
|
14
14
|
|
|
15
15
|
export type BannerProps = {
|
|
16
16
|
title: string | Snippet;
|
|
17
|
-
icon?: string |
|
|
17
|
+
icon?: string | Component;
|
|
18
18
|
color?: PropColor;
|
|
19
19
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
20
20
|
actions?: ButtonProps[];
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
description?: ClassValue;
|
|
28
28
|
title?: ClassValue;
|
|
29
29
|
};
|
|
30
|
-
onclose?: () => void | Promise<void>;
|
|
30
|
+
onclose?: () => void | Promise<() => void>;
|
|
31
31
|
};
|
|
32
32
|
</script>
|
|
33
33
|
|
|
@@ -208,11 +208,7 @@
|
|
|
208
208
|
class={variants.base({ class: [ui.base] })}
|
|
209
209
|
>
|
|
210
210
|
<div class="flex grow gap-2 text-sm items-center">
|
|
211
|
-
{
|
|
212
|
-
{@render icon()}
|
|
213
|
-
{:else}
|
|
214
|
-
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
215
|
-
{/if}
|
|
211
|
+
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
216
212
|
|
|
217
213
|
<div class={variants.title({ class: [ui.title] })}>
|
|
218
214
|
{#if isSnippet(title)}
|
|
@@ -222,13 +218,13 @@
|
|
|
222
218
|
{/if}
|
|
223
219
|
</div>
|
|
224
220
|
|
|
225
|
-
{#if actions.length
|
|
226
|
-
{#each actions as action (
|
|
221
|
+
{#if actions.length}
|
|
222
|
+
{#each actions as action, idx (idx)}
|
|
227
223
|
<Button
|
|
228
|
-
{...defu(action, {
|
|
224
|
+
{...defu(action, <ButtonProps>{
|
|
229
225
|
size: 'xs',
|
|
230
226
|
color: 'surface',
|
|
231
|
-
}
|
|
227
|
+
})}
|
|
232
228
|
/>
|
|
233
229
|
{/each}
|
|
234
230
|
{/if}
|
|
@@ -237,15 +233,15 @@
|
|
|
237
233
|
{#if close}
|
|
238
234
|
<div>
|
|
239
235
|
<Button
|
|
240
|
-
{...defu
|
|
241
|
-
icon:
|
|
236
|
+
{...defu(typeof close === 'boolean' ? {} : close, <ButtonProps>{
|
|
237
|
+
icon: getAppContext().icons.close,
|
|
242
238
|
variant: 'ghost',
|
|
243
239
|
color: 'surface',
|
|
244
240
|
ui: {
|
|
245
241
|
icon: variant === 'solid' ? 'text-label-inverted' : '',
|
|
246
242
|
},
|
|
243
|
+
onclick: onclose,
|
|
247
244
|
})}
|
|
248
|
-
onclick={onclose}
|
|
249
245
|
/>
|
|
250
246
|
</div>
|
|
251
247
|
{/if}
|
|
@@ -3,7 +3,7 @@ import type { Component, Snippet } from 'svelte';
|
|
|
3
3
|
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
export type BannerProps = {
|
|
5
5
|
title: string | Snippet;
|
|
6
|
-
icon?: string |
|
|
6
|
+
icon?: string | Component;
|
|
7
7
|
color?: PropColor;
|
|
8
8
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
9
9
|
actions?: ButtonProps[];
|
|
@@ -16,7 +16,7 @@ export type BannerProps = {
|
|
|
16
16
|
description?: ClassValue;
|
|
17
17
|
title?: ClassValue;
|
|
18
18
|
};
|
|
19
|
-
onclose?: () => void | Promise<void>;
|
|
19
|
+
onclose?: () => void | Promise<() => void>;
|
|
20
20
|
};
|
|
21
21
|
declare const Banner: Component<BannerProps, {}, "">;
|
|
22
22
|
type Banner = ReturnType<typeof Banner>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import { Button, Icon, type ButtonProps } from '
|
|
3
|
+
import { Button, Icon, type ButtonProps, isSnippet } from '../index.js';
|
|
4
4
|
import { tv } from 'tailwind-variants';
|
|
5
|
-
import {
|
|
6
|
-
import { app_icons } from '../contexts.js';
|
|
5
|
+
import { getAppContext } from '../contexts.js';
|
|
7
6
|
|
|
8
7
|
export type BreadcrumbItem = Omit<ButtonProps, 'label'> & {
|
|
9
8
|
label?: string;
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
let {
|
|
25
24
|
items,
|
|
26
25
|
labelkey = 'label',
|
|
27
|
-
seperator =
|
|
26
|
+
seperator = getAppContext().icons.chevronright,
|
|
28
27
|
...rest
|
|
29
28
|
}: BreadcrumbProps = $props();
|
|
30
29
|
|