uisv 0.0.20 → 0.0.22
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 +20 -21
- package/dist/components/accordion.svelte.d.ts +10 -10
- package/dist/components/alert.svelte +22 -28
- package/dist/components/alert.svelte.d.ts +5 -5
- package/dist/components/app.svelte +57 -0
- package/dist/components/app.svelte.d.ts +15 -0
- package/dist/components/badge.svelte +33 -38
- package/dist/components/badge.svelte.d.ts +3 -3
- package/dist/components/banner.svelte +47 -55
- package/dist/components/banner.svelte.d.ts +5 -5
- package/dist/components/breadcrumb.svelte +6 -6
- package/dist/components/breadcrumb.svelte.d.ts +4 -25
- package/dist/components/button.svelte +36 -48
- package/dist/components/button.svelte.d.ts +12 -12
- package/dist/components/calendar.svelte +6 -7
- package/dist/components/calendar.svelte.d.ts +3 -3
- package/dist/components/card.svelte +14 -15
- package/dist/components/card.svelte.d.ts +5 -5
- package/dist/components/checkbox-group.svelte +12 -13
- package/dist/components/checkbox-group.svelte.d.ts +4 -4
- package/dist/components/checkbox.svelte +39 -38
- package/dist/components/checkbox.svelte.d.ts +6 -6
- package/dist/components/chip.svelte +21 -22
- package/dist/components/chip.svelte.d.ts +3 -3
- package/dist/components/collapsible.svelte +4 -5
- package/dist/components/collapsible.svelte.d.ts +4 -4
- package/dist/components/color-picker.svelte +1 -1
- package/dist/components/h1.svelte +8 -7
- package/dist/components/h2.svelte +12 -11
- package/dist/components/h3.svelte +9 -8
- package/dist/components/h4.svelte +12 -11
- package/dist/components/h5.svelte +12 -11
- package/dist/components/h6.svelte +12 -11
- package/dist/components/icon.svelte +0 -2
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.js +6 -0
- package/dist/components/input-number.svelte +5 -7
- package/dist/components/input-number.svelte.d.ts +5 -5
- package/dist/components/input-time.svelte +11 -12
- package/dist/components/input-time.svelte.d.ts +6 -6
- package/dist/components/input.svelte +11 -12
- package/dist/components/input.svelte.d.ts +6 -6
- package/dist/components/kbd.svelte +6 -7
- package/dist/components/kbd.svelte.d.ts +2 -2
- package/dist/components/modal.svelte +189 -0
- package/dist/components/modal.svelte.d.ts +33 -0
- package/dist/components/p.svelte +3 -1
- package/dist/components/pin-input.svelte +10 -11
- package/dist/components/pin-input.svelte.d.ts +3 -3
- package/dist/components/placeholder.svelte +4 -4
- package/dist/components/popover.svelte +33 -61
- package/dist/components/popover.svelte.d.ts +8 -30
- package/dist/components/progress.svelte +22 -21
- package/dist/components/progress.svelte.d.ts +5 -5
- package/dist/components/select.svelte +48 -53
- package/dist/components/select.svelte.d.ts +22 -29
- package/dist/components/seperator.svelte +6 -7
- package/dist/components/seperator.svelte.d.ts +6 -6
- package/dist/components/slider.svelte +13 -14
- package/dist/components/slider.svelte.d.ts +4 -4
- package/dist/components/switch.svelte +17 -22
- package/dist/components/switch.svelte.d.ts +6 -6
- package/dist/components/tabs.svelte +19 -20
- package/dist/components/tabs.svelte.d.ts +7 -7
- package/dist/components/tooltip.svelte +94 -0
- package/dist/components/tooltip.svelte.d.ts +24 -0
- package/dist/contexts.d.ts +47 -0
- package/dist/contexts.js +46 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mode.d.ts +89 -0
- package/dist/mode.js +1 -0
- package/dist/utilities.svelte.d.ts +1 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +32 -37
- package/package.json +31 -26
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
type ButtonProps,
|
|
6
6
|
Button,
|
|
7
7
|
type PropVariant,
|
|
8
|
+
Icon,
|
|
8
9
|
} from '../index.js';
|
|
9
10
|
import type { Component, Snippet } from 'svelte';
|
|
10
|
-
import type
|
|
11
|
-
import { tv } from 'tailwind-variants';
|
|
11
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
12
12
|
import { defu } from 'defu';
|
|
13
|
-
import {
|
|
13
|
+
import { app_icons } from '../contexts.js';
|
|
14
14
|
|
|
15
15
|
export type BannerProps = {
|
|
16
16
|
title: string | Snippet;
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
href?: string;
|
|
23
23
|
target?: string;
|
|
24
24
|
ui?: {
|
|
25
|
-
base?:
|
|
26
|
-
icon?:
|
|
27
|
-
description?:
|
|
28
|
-
title?:
|
|
25
|
+
base?: ClassValue;
|
|
26
|
+
icon?: ClassValue;
|
|
27
|
+
description?: ClassValue;
|
|
28
|
+
title?: ClassValue;
|
|
29
29
|
};
|
|
30
30
|
onclose?: () => void | Promise<void>;
|
|
31
31
|
};
|
|
@@ -44,19 +44,8 @@
|
|
|
44
44
|
ui = {},
|
|
45
45
|
onclose = () => {},
|
|
46
46
|
}: BannerProps = $props();
|
|
47
|
-
const id = useId();
|
|
48
47
|
|
|
49
|
-
const
|
|
50
|
-
return defu(typeof close === 'boolean' ? {} : close, {
|
|
51
|
-
icon: 'i-lucide-x',
|
|
52
|
-
variant: 'link',
|
|
53
|
-
color: variant === 'solid' ? 'surface' : color,
|
|
54
|
-
ui: {
|
|
55
|
-
icon: variant === 'solid' ? 'text-white' : '',
|
|
56
|
-
},
|
|
57
|
-
} as ButtonProps);
|
|
58
|
-
});
|
|
59
|
-
const classes = $derived.by(() =>
|
|
48
|
+
const variants = $derived.by(() =>
|
|
60
49
|
tv({
|
|
61
50
|
slots: {
|
|
62
51
|
base: 'flex items-center gap-2 font-sans p-4',
|
|
@@ -75,8 +64,8 @@
|
|
|
75
64
|
},
|
|
76
65
|
variant: {
|
|
77
66
|
solid: {
|
|
78
|
-
base: 'text-
|
|
79
|
-
description: 'text-
|
|
67
|
+
base: 'text-label-inverted',
|
|
68
|
+
description: 'text-label-inverted/90',
|
|
80
69
|
},
|
|
81
70
|
outline: 'border',
|
|
82
71
|
soft: '',
|
|
@@ -92,7 +81,7 @@
|
|
|
92
81
|
{
|
|
93
82
|
variant: 'solid',
|
|
94
83
|
color: 'surface',
|
|
95
|
-
class: 'bg-surface-
|
|
84
|
+
class: 'bg-surface-inverted',
|
|
96
85
|
},
|
|
97
86
|
{
|
|
98
87
|
variant: 'solid',
|
|
@@ -118,94 +107,94 @@
|
|
|
118
107
|
{
|
|
119
108
|
variant: 'outline',
|
|
120
109
|
color: 'primary',
|
|
121
|
-
class: 'border-primary
|
|
110
|
+
class: 'border-primary/15 text-primary-500',
|
|
122
111
|
},
|
|
123
112
|
{
|
|
124
113
|
variant: 'outline',
|
|
125
114
|
color: 'surface',
|
|
126
|
-
class: 'border-surface
|
|
115
|
+
class: 'border-surface/15',
|
|
127
116
|
},
|
|
128
117
|
{
|
|
129
118
|
variant: 'outline',
|
|
130
119
|
color: 'info',
|
|
131
|
-
class: 'border-info
|
|
120
|
+
class: 'border-info/15 text-info-500',
|
|
132
121
|
},
|
|
133
122
|
{
|
|
134
123
|
variant: 'outline',
|
|
135
124
|
color: 'success',
|
|
136
|
-
class: 'border-success
|
|
125
|
+
class: 'border-success/15 text-success-500',
|
|
137
126
|
},
|
|
138
127
|
{
|
|
139
128
|
variant: 'outline',
|
|
140
129
|
color: 'warning',
|
|
141
|
-
class: 'border-warning
|
|
130
|
+
class: 'border-warning/15 text-warning-500',
|
|
142
131
|
},
|
|
143
132
|
{
|
|
144
133
|
variant: 'outline',
|
|
145
134
|
color: 'error',
|
|
146
|
-
class: 'border-error
|
|
135
|
+
class: 'border-error/15 text-error-500',
|
|
147
136
|
},
|
|
148
137
|
|
|
149
138
|
{
|
|
150
139
|
variant: 'soft',
|
|
151
140
|
color: 'primary',
|
|
152
|
-
class: 'bg-primary
|
|
141
|
+
class: 'bg-primary/10 text-primary-500',
|
|
153
142
|
},
|
|
154
143
|
{
|
|
155
144
|
variant: 'soft',
|
|
156
145
|
color: 'surface',
|
|
157
|
-
class: 'bg-surface
|
|
146
|
+
class: 'bg-surface/10',
|
|
158
147
|
},
|
|
159
148
|
{
|
|
160
149
|
variant: 'soft',
|
|
161
150
|
color: 'info',
|
|
162
|
-
class: 'bg-info
|
|
151
|
+
class: 'bg-info/10 text-info-500',
|
|
163
152
|
},
|
|
164
153
|
{
|
|
165
154
|
variant: 'soft',
|
|
166
155
|
color: 'success',
|
|
167
|
-
class: 'bg-success
|
|
156
|
+
class: 'bg-success/10 text-success-500',
|
|
168
157
|
},
|
|
169
158
|
{
|
|
170
159
|
variant: 'soft',
|
|
171
160
|
color: 'warning',
|
|
172
|
-
class: 'bg-warning
|
|
161
|
+
class: 'bg-warning/10 text-warning-500',
|
|
173
162
|
},
|
|
174
163
|
{
|
|
175
164
|
variant: 'soft',
|
|
176
165
|
color: 'error',
|
|
177
|
-
class: 'bg-error
|
|
166
|
+
class: 'bg-error/10 text-error-500',
|
|
178
167
|
},
|
|
179
168
|
|
|
180
169
|
{
|
|
181
170
|
variant: 'subtle',
|
|
182
171
|
color: 'primary',
|
|
183
|
-
class: 'bg-primary
|
|
172
|
+
class: 'bg-primary/10 text-primary-500 border-primary/15',
|
|
184
173
|
},
|
|
185
174
|
{
|
|
186
175
|
variant: 'subtle',
|
|
187
176
|
color: 'surface',
|
|
188
|
-
class: 'bg-surface
|
|
177
|
+
class: 'bg-surface/10 border-surface/15',
|
|
189
178
|
},
|
|
190
179
|
{
|
|
191
180
|
variant: 'subtle',
|
|
192
181
|
color: 'info',
|
|
193
|
-
class: 'bg-info
|
|
182
|
+
class: 'bg-info/10 text-info-500 border-info/15',
|
|
194
183
|
},
|
|
195
184
|
{
|
|
196
185
|
variant: 'subtle',
|
|
197
186
|
color: 'success',
|
|
198
|
-
class: 'bg-success
|
|
187
|
+
class: 'bg-success/10 text-success-500 border-success/15',
|
|
199
188
|
},
|
|
200
189
|
{
|
|
201
190
|
variant: 'subtle',
|
|
202
191
|
color: 'warning',
|
|
203
|
-
class: 'bg-warning
|
|
192
|
+
class: 'bg-warning/10 text-warning-500 border-warning/15',
|
|
204
193
|
},
|
|
205
194
|
{
|
|
206
195
|
variant: 'subtle',
|
|
207
196
|
color: 'error',
|
|
208
|
-
class: 'bg-error
|
|
197
|
+
class: 'bg-error/10 text-error-500 border-error/15',
|
|
209
198
|
},
|
|
210
199
|
],
|
|
211
200
|
})({ color, variant }),
|
|
@@ -216,23 +205,16 @@
|
|
|
216
205
|
this={href ? 'a' : 'button'}
|
|
217
206
|
{href}
|
|
218
207
|
{target}
|
|
219
|
-
class={
|
|
208
|
+
class={variants.base({ class: [ui.base] })}
|
|
220
209
|
>
|
|
221
|
-
<div class="flex
|
|
222
|
-
{#if icon}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
{:else if isSnippet(icon)}
|
|
227
|
-
{@render icon()}
|
|
228
|
-
{:else}
|
|
229
|
-
{@const Icon = icon}
|
|
230
|
-
<Icon />
|
|
231
|
-
{/if}
|
|
232
|
-
</div>
|
|
210
|
+
<div class="flex grow gap-2 text-sm items-center">
|
|
211
|
+
{#if isSnippet(icon)}
|
|
212
|
+
{@render icon()}
|
|
213
|
+
{:else}
|
|
214
|
+
<Icon name={icon} class={variants.icon({ class: ui.icon })} />
|
|
233
215
|
{/if}
|
|
234
216
|
|
|
235
|
-
<div class={
|
|
217
|
+
<div class={variants.title({ class: [ui.title] })}>
|
|
236
218
|
{#if isSnippet(title)}
|
|
237
219
|
{@render title()}
|
|
238
220
|
{:else}
|
|
@@ -254,7 +236,17 @@
|
|
|
254
236
|
|
|
255
237
|
{#if close}
|
|
256
238
|
<div>
|
|
257
|
-
<Button
|
|
239
|
+
<Button
|
|
240
|
+
{...defu<ButtonProps, [ButtonProps]>(typeof close === 'boolean' ? {} : close, {
|
|
241
|
+
icon: app_icons.get().close,
|
|
242
|
+
variant: 'ghost',
|
|
243
|
+
color: 'surface',
|
|
244
|
+
ui: {
|
|
245
|
+
icon: variant === 'solid' ? 'text-label-inverted' : '',
|
|
246
|
+
},
|
|
247
|
+
})}
|
|
248
|
+
onclick={onclose}
|
|
249
|
+
/>
|
|
258
250
|
</div>
|
|
259
251
|
{/if}
|
|
260
252
|
</svelte:element>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PropColor, type ButtonProps, type PropVariant } from '../index.js';
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type
|
|
3
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
4
4
|
export type BannerProps = {
|
|
5
5
|
title: string | Snippet;
|
|
6
6
|
icon?: string | Snippet | Component;
|
|
@@ -11,10 +11,10 @@ export type BannerProps = {
|
|
|
11
11
|
href?: string;
|
|
12
12
|
target?: string;
|
|
13
13
|
ui?: {
|
|
14
|
-
base?:
|
|
15
|
-
icon?:
|
|
16
|
-
description?:
|
|
17
|
-
title?:
|
|
14
|
+
base?: ClassValue;
|
|
15
|
+
icon?: ClassValue;
|
|
16
|
+
description?: ClassValue;
|
|
17
|
+
title?: ClassValue;
|
|
18
18
|
};
|
|
19
19
|
onclose?: () => void | Promise<void>;
|
|
20
20
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
3
|
import { Button, Icon, type ButtonProps } from './index.js';
|
|
5
4
|
import { tv } from 'tailwind-variants';
|
|
6
5
|
import { isSnippet } from '../utilities.svelte.js';
|
|
6
|
+
import { app_icons } from '../contexts.js';
|
|
7
7
|
|
|
8
8
|
export type BreadcrumbItem = Omit<ButtonProps, 'label'> & {
|
|
9
9
|
label?: string;
|
|
10
10
|
icon?: string | Component;
|
|
11
11
|
snippet?: string;
|
|
12
|
-
[key: string]:
|
|
12
|
+
[key: string]: unknown;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type BreadcrumbProps = {
|
|
16
16
|
items: BreadcrumbItem[];
|
|
17
17
|
seperator?: string | Component | Snippet;
|
|
18
18
|
labelkey?: string;
|
|
19
|
-
[key: string]:
|
|
19
|
+
[key: string]: unknown | Snippet<[BreadcrumbItem]>;
|
|
20
20
|
};
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
|
-
<script lang="ts"
|
|
23
|
+
<script lang="ts">
|
|
24
24
|
let {
|
|
25
25
|
items,
|
|
26
26
|
labelkey = 'label',
|
|
27
|
-
seperator =
|
|
27
|
+
seperator = app_icons.get().chevronright,
|
|
28
28
|
...rest
|
|
29
29
|
}: BreadcrumbProps = $props();
|
|
30
30
|
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
{/if}
|
|
54
54
|
{:else}
|
|
55
55
|
<Button
|
|
56
|
-
label={item[labelkey]}
|
|
56
|
+
label={item[labelkey] as undefined}
|
|
57
57
|
icon={item.icon}
|
|
58
58
|
href={item.href}
|
|
59
59
|
variant="link"
|
|
@@ -4,35 +4,14 @@ export type BreadcrumbItem = Omit<ButtonProps, 'label'> & {
|
|
|
4
4
|
label?: string;
|
|
5
5
|
icon?: string | Component;
|
|
6
6
|
snippet?: string;
|
|
7
|
-
[key: string]:
|
|
7
|
+
[key: string]: unknown;
|
|
8
8
|
};
|
|
9
9
|
export type BreadcrumbProps = {
|
|
10
10
|
items: BreadcrumbItem[];
|
|
11
11
|
seperator?: string | Component | Snippet;
|
|
12
12
|
labelkey?: string;
|
|
13
|
-
[key: string]:
|
|
13
|
+
[key: string]: unknown | Snippet<[BreadcrumbItem]>;
|
|
14
14
|
};
|
|
15
|
-
declare
|
|
16
|
-
|
|
17
|
-
exports: {};
|
|
18
|
-
bindings: "";
|
|
19
|
-
slots: {};
|
|
20
|
-
events: {};
|
|
21
|
-
};
|
|
22
|
-
declare class __sveltets_Render<T extends BreadcrumbItem> {
|
|
23
|
-
props(): ReturnType<typeof $$render<T>>['props'];
|
|
24
|
-
events(): ReturnType<typeof $$render<T>>['events'];
|
|
25
|
-
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
26
|
-
bindings(): "";
|
|
27
|
-
exports(): {};
|
|
28
|
-
}
|
|
29
|
-
interface $$IsomorphicComponent {
|
|
30
|
-
new <T extends BreadcrumbItem>(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']>> & {
|
|
31
|
-
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
32
|
-
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
33
|
-
<T extends BreadcrumbItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
34
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
35
|
-
}
|
|
36
|
-
declare const Breadcrumb: $$IsomorphicComponent;
|
|
37
|
-
type Breadcrumb<T extends BreadcrumbItem> = InstanceType<typeof Breadcrumb<T>>;
|
|
15
|
+
declare const Breadcrumb: Component<BreadcrumbProps, {}, "">;
|
|
16
|
+
type Breadcrumb = ReturnType<typeof Breadcrumb>;
|
|
38
17
|
export default Breadcrumb;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
import { type Component, type Snippet } from 'svelte';
|
|
3
|
-
import {
|
|
4
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
import { type PropColor, type PropVariant, Icon } from '../index.js';
|
|
5
4
|
// import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
|
|
6
|
-
import { isSnippet } from '../index.js';
|
|
7
|
-
import { tv } from 'tailwind-variants';
|
|
8
5
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
9
|
-
import {
|
|
6
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
7
|
+
import { app_icons } from '../contexts.js';
|
|
10
8
|
|
|
11
|
-
export type
|
|
9
|
+
export type ButtonBaseProps = {
|
|
12
10
|
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
13
11
|
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
14
12
|
/** Where to display the linked URL, as the name for a browsing context. */
|
|
@@ -19,15 +17,15 @@
|
|
|
19
17
|
/** The type of the button when not a link. */
|
|
20
18
|
type?: 'submit' | 'reset' | 'button' | null | undefined;
|
|
21
19
|
/** When true, the icon will be displayed on the right side. */
|
|
22
|
-
loadingicon?: string |
|
|
20
|
+
loadingicon?: string | Component;
|
|
23
21
|
/** When true, the loading icon will be displayed. */
|
|
24
22
|
loading?: boolean;
|
|
25
23
|
/** The position of the icon, including the loading icon */
|
|
26
|
-
iconposition?: '
|
|
24
|
+
iconposition?: 'leading' | 'trailing';
|
|
27
25
|
/** Icon when `loading` is `false` */
|
|
28
|
-
icon?: string |
|
|
29
|
-
leadingicon?: string |
|
|
30
|
-
trailingicon?: string |
|
|
26
|
+
icon?: string | Component;
|
|
27
|
+
leadingicon?: string | Component;
|
|
28
|
+
trailingicon?: string | Component;
|
|
31
29
|
/** Route Location the link should navigate to when clicked on. */
|
|
32
30
|
href?: string;
|
|
33
31
|
label?: string;
|
|
@@ -50,13 +48,15 @@
|
|
|
50
48
|
/** Set loading state automatically based on the `@click` promise state */
|
|
51
49
|
loadingauto?: boolean;
|
|
52
50
|
ui?: {
|
|
53
|
-
base?:
|
|
54
|
-
icon?:
|
|
55
|
-
leadingicon?:
|
|
56
|
-
trailingicon?:
|
|
51
|
+
base?: ClassValue;
|
|
52
|
+
icon?: ClassValue;
|
|
53
|
+
leadingicon?: ClassValue;
|
|
54
|
+
trailingicon?: ClassValue;
|
|
57
55
|
};
|
|
58
56
|
children?: Snippet;
|
|
59
57
|
};
|
|
58
|
+
|
|
59
|
+
export type ButtonProps = SvelteHTMLElements['button'] & ButtonBaseProps;
|
|
60
60
|
</script>
|
|
61
61
|
|
|
62
62
|
<script lang="ts">
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
size = 'md',
|
|
67
67
|
variant = 'solid',
|
|
68
68
|
color = 'primary',
|
|
69
|
-
iconposition = '
|
|
69
|
+
iconposition = 'leading',
|
|
70
70
|
children,
|
|
71
71
|
// active,
|
|
72
72
|
// activecolor,
|
|
@@ -80,8 +80,7 @@
|
|
|
80
80
|
href,
|
|
81
81
|
icon,
|
|
82
82
|
loading,
|
|
83
|
-
loadingicon =
|
|
84
|
-
target,
|
|
83
|
+
loadingicon = app_icons.get().loading,
|
|
85
84
|
type,
|
|
86
85
|
trailingicon,
|
|
87
86
|
leadingicon,
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
return false;
|
|
96
95
|
});
|
|
97
96
|
|
|
98
|
-
const
|
|
97
|
+
const classnames = $derived(
|
|
99
98
|
tv({
|
|
100
99
|
slots: {
|
|
101
100
|
icon: '',
|
|
@@ -112,7 +111,7 @@
|
|
|
112
111
|
},
|
|
113
112
|
variant: {
|
|
114
113
|
link: '',
|
|
115
|
-
solid: 'text-inverted',
|
|
114
|
+
solid: 'text-label-inverted',
|
|
116
115
|
outline: 'border',
|
|
117
116
|
soft: '',
|
|
118
117
|
subtle: 'border',
|
|
@@ -145,7 +144,7 @@
|
|
|
145
144
|
{
|
|
146
145
|
color: 'surface',
|
|
147
146
|
variant: 'solid',
|
|
148
|
-
class: 'bg-surface-inverted text-
|
|
147
|
+
class: 'bg-surface-inverted text-label-inverted hover:bg-label-toned',
|
|
149
148
|
},
|
|
150
149
|
{
|
|
151
150
|
color: 'info',
|
|
@@ -179,7 +178,7 @@
|
|
|
179
178
|
color: 'surface',
|
|
180
179
|
variant: 'outline',
|
|
181
180
|
class: {
|
|
182
|
-
base: 'border-surface-
|
|
181
|
+
base: 'border-surface-accented text-label hover:bg-surface-elevated',
|
|
183
182
|
},
|
|
184
183
|
},
|
|
185
184
|
{
|
|
@@ -219,7 +218,7 @@
|
|
|
219
218
|
{
|
|
220
219
|
color: 'surface',
|
|
221
220
|
variant: 'soft',
|
|
222
|
-
class: 'bg-surface/10 text-
|
|
221
|
+
class: 'bg-surface/10 text-label-highlighted hover:bg-surface/15',
|
|
223
222
|
},
|
|
224
223
|
{
|
|
225
224
|
color: 'info',
|
|
@@ -250,7 +249,7 @@
|
|
|
250
249
|
{
|
|
251
250
|
color: 'surface',
|
|
252
251
|
variant: 'subtle',
|
|
253
|
-
class: 'bg-surface/10 text-
|
|
252
|
+
class: 'bg-surface/10 text-label-highlighted border-surface/25 hover:bg-surface/15',
|
|
254
253
|
},
|
|
255
254
|
{
|
|
256
255
|
color: 'info',
|
|
@@ -281,7 +280,7 @@
|
|
|
281
280
|
{
|
|
282
281
|
color: 'surface',
|
|
283
282
|
variant: 'ghost',
|
|
284
|
-
class: 'text-highlighted hover:bg-surface/15',
|
|
283
|
+
class: 'text-label-label-highlighted hover:bg-surface/15',
|
|
285
284
|
},
|
|
286
285
|
{
|
|
287
286
|
color: 'info',
|
|
@@ -312,7 +311,7 @@
|
|
|
312
311
|
{
|
|
313
312
|
color: 'surface',
|
|
314
313
|
variant: 'link',
|
|
315
|
-
class: 'text-muted hover:text-surface-inverted',
|
|
314
|
+
class: 'text-label-muted hover:text-surface-inverted',
|
|
316
315
|
},
|
|
317
316
|
{
|
|
318
317
|
color: 'info',
|
|
@@ -350,13 +349,10 @@
|
|
|
350
349
|
|
|
351
350
|
internal_loading = false;
|
|
352
351
|
}
|
|
353
|
-
|
|
354
|
-
$inspect(children, label, !!icon);
|
|
355
352
|
</script>
|
|
356
353
|
|
|
357
354
|
<svelte:element
|
|
358
355
|
this={href ? 'a' : 'button'}
|
|
359
|
-
data-button-root
|
|
360
356
|
type={href ? undefined : type}
|
|
361
357
|
href={href && !disabled ? href : undefined}
|
|
362
358
|
disabled={disabled || is_loading}
|
|
@@ -364,14 +360,17 @@
|
|
|
364
360
|
role={href && disabled ? 'link' : undefined}
|
|
365
361
|
tabindex={href && disabled ? -1 : 0}
|
|
366
362
|
bind:this={ref}
|
|
367
|
-
class={
|
|
363
|
+
class={classnames.base({
|
|
368
364
|
class: [only_icon && 'px-0 aspect-square justify-center', href && 'cursor-pointer', ui.base],
|
|
369
365
|
})}
|
|
370
366
|
onclick={onClickWrapper}
|
|
371
367
|
{...rest}
|
|
372
368
|
>
|
|
373
|
-
{#if iconposition === '
|
|
374
|
-
|
|
369
|
+
{#if iconposition === 'leading' || leadingicon || loading}
|
|
370
|
+
<Icon
|
|
371
|
+
name={is_loading ? loadingicon : leadingicon || icon}
|
|
372
|
+
class={[ui.leadingicon, loading && 'animate-spin', iconposition === 'leading' && ui.icon]}
|
|
373
|
+
/>
|
|
375
374
|
{/if}
|
|
376
375
|
|
|
377
376
|
{#if label}
|
|
@@ -380,21 +379,10 @@
|
|
|
380
379
|
{@render children?.()}
|
|
381
380
|
{/if}
|
|
382
381
|
|
|
383
|
-
{#if iconposition
|
|
384
|
-
|
|
382
|
+
{#if iconposition === 'trailing' || trailingicon}
|
|
383
|
+
<Icon
|
|
384
|
+
name={trailingicon || icon}
|
|
385
|
+
class={[ui.trailingicon, iconposition === 'trailing' && ui.icon]}
|
|
386
|
+
/>
|
|
385
387
|
{/if}
|
|
386
388
|
</svelte:element>
|
|
387
|
-
|
|
388
|
-
{#snippet Icon(IconProp?: string | Snippet | Component, classvalue?: ClassNameValue)}
|
|
389
|
-
{#if typeof IconProp === 'string'}
|
|
390
|
-
<div
|
|
391
|
-
class={variants.icon({
|
|
392
|
-
class: [is_loading && 'animate-spin', IconProp, ui.icon, classvalue],
|
|
393
|
-
})}
|
|
394
|
-
></div>
|
|
395
|
-
{:else if isSnippet(IconProp)}
|
|
396
|
-
{@render IconProp()}
|
|
397
|
-
{:else if isComponent(IconProp)}
|
|
398
|
-
<IconProp />
|
|
399
|
-
{/if}
|
|
400
|
-
{/snippet}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { type Component, type Snippet } from 'svelte';
|
|
2
2
|
import { type PropColor, type PropVariant } from '../index.js';
|
|
3
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
3
|
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
5
|
-
import {
|
|
6
|
-
export type
|
|
4
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
5
|
+
export type ButtonBaseProps = {
|
|
7
6
|
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
8
7
|
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
9
8
|
/** Where to display the linked URL, as the name for a browsing context. */
|
|
@@ -13,15 +12,15 @@ export type ButtonProps = SvelteHTMLElements['button'] & {
|
|
|
13
12
|
/** The type of the button when not a link. */
|
|
14
13
|
type?: 'submit' | 'reset' | 'button' | null | undefined;
|
|
15
14
|
/** When true, the icon will be displayed on the right side. */
|
|
16
|
-
loadingicon?: string |
|
|
15
|
+
loadingicon?: string | Component;
|
|
17
16
|
/** When true, the loading icon will be displayed. */
|
|
18
17
|
loading?: boolean;
|
|
19
18
|
/** The position of the icon, including the loading icon */
|
|
20
|
-
iconposition?: '
|
|
19
|
+
iconposition?: 'leading' | 'trailing';
|
|
21
20
|
/** Icon when `loading` is `false` */
|
|
22
|
-
icon?: string |
|
|
23
|
-
leadingicon?: string |
|
|
24
|
-
trailingicon?: string |
|
|
21
|
+
icon?: string | Component;
|
|
22
|
+
leadingicon?: string | Component;
|
|
23
|
+
trailingicon?: string | Component;
|
|
25
24
|
/** Route Location the link should navigate to when clicked on. */
|
|
26
25
|
href?: string;
|
|
27
26
|
label?: string;
|
|
@@ -42,13 +41,14 @@ export type ButtonProps = SvelteHTMLElements['button'] & {
|
|
|
42
41
|
/** Set loading state automatically based on the `@click` promise state */
|
|
43
42
|
loadingauto?: boolean;
|
|
44
43
|
ui?: {
|
|
45
|
-
base?:
|
|
46
|
-
icon?:
|
|
47
|
-
leadingicon?:
|
|
48
|
-
trailingicon?:
|
|
44
|
+
base?: ClassValue;
|
|
45
|
+
icon?: ClassValue;
|
|
46
|
+
leadingicon?: ClassValue;
|
|
47
|
+
trailingicon?: ClassValue;
|
|
49
48
|
};
|
|
50
49
|
children?: Snippet;
|
|
51
50
|
};
|
|
51
|
+
export type ButtonProps = SvelteHTMLElements['button'] & ButtonBaseProps;
|
|
52
52
|
declare const Button: Component<ButtonProps, {}, "ref">;
|
|
53
53
|
type Button = ReturnType<typeof Button>;
|
|
54
54
|
export default Button;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { Component, Snippet } from 'svelte';
|
|
3
|
-
import { tv } from 'tailwind-variants';
|
|
3
|
+
import { tv, type ClassValue } from 'tailwind-variants';
|
|
4
4
|
import { type PropColor, type PropVariant, isSnippet } from '../index.js';
|
|
5
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
6
5
|
import { type DateValue, today } from '../date.js';
|
|
7
6
|
import { Calendar, type CalendarRootProps } from 'bits-ui';
|
|
8
7
|
|
|
@@ -11,8 +10,8 @@
|
|
|
11
10
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
12
11
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
13
12
|
ui?: {
|
|
14
|
-
base?:
|
|
15
|
-
icon?:
|
|
13
|
+
base?: ClassValue;
|
|
14
|
+
icon?: ClassValue;
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
17
|
</script>
|
|
@@ -30,7 +29,7 @@
|
|
|
30
29
|
children,
|
|
31
30
|
}: CalendarProps = $props();
|
|
32
31
|
|
|
33
|
-
const
|
|
32
|
+
const variants = $derived.by(() => {
|
|
34
33
|
return tv({
|
|
35
34
|
slots: { icon: '', base: '' },
|
|
36
35
|
variants: {
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
});
|
|
64
63
|
</script>
|
|
65
64
|
|
|
66
|
-
<Calendar.Root type={type as
|
|
65
|
+
<Calendar.Root type={type as 'single'} bind:value={() => value as DateValue, (v) => (value = v)}>
|
|
67
66
|
{#snippet children({ months, weekdays })}
|
|
68
67
|
<Calendar.Header>
|
|
69
68
|
<Calendar.PrevButton />
|
|
@@ -71,7 +70,7 @@
|
|
|
71
70
|
<Calendar.NextButton />
|
|
72
71
|
</Calendar.Header>
|
|
73
72
|
|
|
74
|
-
{#each months as month}
|
|
73
|
+
{#each months as month (month)}
|
|
75
74
|
<Calendar.Grid>
|
|
76
75
|
<Calendar.GridHead>
|
|
77
76
|
<Calendar.GridRow>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
|
+
import { type ClassValue } from 'tailwind-variants';
|
|
2
3
|
import { type PropColor, type PropVariant } from '../index.js';
|
|
3
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
4
|
import { Calendar, type CalendarRootProps } from 'bits-ui';
|
|
5
5
|
export type CalendarProps = CalendarRootProps & {
|
|
6
6
|
color?: PropColor;
|
|
7
7
|
variant?: Exclude<PropVariant, 'none' | 'ghost'>;
|
|
8
8
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
9
|
ui?: {
|
|
10
|
-
base?:
|
|
11
|
-
icon?:
|
|
10
|
+
base?: ClassValue;
|
|
11
|
+
icon?: ClassValue;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
declare const Calendar: Component<CalendarProps, {}, "value">;
|