uisv 0.0.7 → 0.0.9
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/package.json +38 -37
- package/dist/components/accordion.svelte +0 -108
- package/dist/components/accordion.svelte.d.ts +0 -58
- package/dist/components/alert.svelte +0 -272
- package/dist/components/alert.svelte.d.ts +0 -24
- package/dist/components/badge.svelte +0 -227
- package/dist/components/badge.svelte.d.ts +0 -19
- package/dist/components/banner.svelte +0 -255
- package/dist/components/banner.svelte.d.ts +0 -24
- package/dist/components/button.svelte +0 -384
- package/dist/components/button.svelte.d.ts +0 -49
- package/dist/components/card.svelte +0 -70
- package/dist/components/card.svelte.d.ts +0 -17
- package/dist/components/checkbox.svelte +0 -175
- package/dist/components/checkbox.svelte.d.ts +0 -27
- package/dist/components/checkboxgroup.svelte +0 -259
- package/dist/components/checkboxgroup.svelte.d.ts +0 -26
- package/dist/components/chip.svelte +0 -82
- package/dist/components/chip.svelte.d.ts +0 -17
- package/dist/components/h1.svelte +0 -28
- package/dist/components/h1.svelte.d.ts +0 -11
- package/dist/components/h2.svelte +0 -30
- package/dist/components/h2.svelte.d.ts +0 -11
- package/dist/components/index.d.ts +0 -34
- package/dist/components/index.js +0 -34
- package/dist/components/kbd.svelte +0 -239
- package/dist/components/kbd.svelte.d.ts +0 -40
- package/dist/components/p.svelte +0 -22
- package/dist/components/p.svelte.d.ts +0 -11
- package/dist/components/pin-input.svelte +0 -162
- package/dist/components/pin-input.svelte.d.ts +0 -25
- package/dist/components/placeholder.svelte +0 -32
- package/dist/components/placeholder.svelte.d.ts +0 -7
- package/dist/components/progress.svelte +0 -124
- package/dist/components/progress.svelte.d.ts +0 -21
- package/dist/components/slider.svelte +0 -172
- package/dist/components/slider.svelte.d.ts +0 -44
- package/dist/components/switch.svelte +0 -180
- package/dist/components/switch.svelte.d.ts +0 -27
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -3
- package/dist/utils/common.d.ts +0 -13
- package/dist/utils/common.js +0 -16
- package/dist/vite.d.ts +0 -38
- package/dist/vite.js +0 -57
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
// import { FORM_LOADING_CONTEXT_KEY } from '../utils/keys.js';
|
|
3
|
-
import { type Component, type Snippet } from 'svelte';
|
|
4
|
-
import { tv } from 'tailwind-variants';
|
|
5
|
-
import { type PropColor, isSnippet } from '../index.js';
|
|
6
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
7
|
-
|
|
8
|
-
export type ButtonProps = {
|
|
9
|
-
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
10
|
-
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
11
|
-
/** Where to display the linked URL, as the name for a browsing context. */
|
|
12
|
-
target?: null | '_blank' | '_parent' | '_self' | '_top' | (string & {});
|
|
13
|
-
/** Force the link to be active independent of the current route. */
|
|
14
|
-
// active?: boolean;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
/** The type of the button when not a link. */
|
|
17
|
-
type?: 'submit' | 'reset' | 'button' | null | undefined;
|
|
18
|
-
/** When true, the icon will be displayed on the right side. */
|
|
19
|
-
loadingicon?: string;
|
|
20
|
-
/** When true, the loading icon will be displayed. */
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
/** The position of the icon, including the loading icon */
|
|
23
|
-
iconposition?: 'left' | 'right';
|
|
24
|
-
/** Icon when `loading` is `false` */
|
|
25
|
-
icon?: string | Snippet | Component;
|
|
26
|
-
/** Route Location the link should navigate to when clicked on. */
|
|
27
|
-
href?: string;
|
|
28
|
-
label?: string;
|
|
29
|
-
/**
|
|
30
|
-
* @defaultValue 'primary'
|
|
31
|
-
*/
|
|
32
|
-
color?: PropColor;
|
|
33
|
-
// activecolor?: PropColor;
|
|
34
|
-
/**
|
|
35
|
-
* @defaultValue 'solid'
|
|
36
|
-
*/
|
|
37
|
-
variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
|
|
38
|
-
// activevariant?: ButtonVariant;
|
|
39
|
-
/**
|
|
40
|
-
* @defaultValue 'md'
|
|
41
|
-
*/
|
|
42
|
-
size?: 'md' | 'xs' | 'sm' | 'lg' | 'xl';
|
|
43
|
-
/** Render the button full width. */
|
|
44
|
-
block?: boolean;
|
|
45
|
-
/** Set loading state automatically based on the `@click` promise state */
|
|
46
|
-
loadingauto?: boolean;
|
|
47
|
-
onclick?: (event: MouseEvent) => void | Promise<void>;
|
|
48
|
-
ui?: {
|
|
49
|
-
base?: ClassNameValue;
|
|
50
|
-
icon?: ClassNameValue;
|
|
51
|
-
};
|
|
52
|
-
children?: Snippet;
|
|
53
|
-
};
|
|
54
|
-
</script>
|
|
55
|
-
|
|
56
|
-
<script lang="ts">
|
|
57
|
-
// let form_loading = getContext<{ value: boolean } | undefined>(FORM_LOADING_CONTEXT_KEY);
|
|
58
|
-
let {
|
|
59
|
-
ref = $bindable(),
|
|
60
|
-
size = 'md',
|
|
61
|
-
variant = 'solid',
|
|
62
|
-
color = 'primary',
|
|
63
|
-
iconposition = 'left',
|
|
64
|
-
children,
|
|
65
|
-
// active,
|
|
66
|
-
// activecolor,
|
|
67
|
-
// activevariant,
|
|
68
|
-
block,
|
|
69
|
-
label,
|
|
70
|
-
loadingauto,
|
|
71
|
-
onclick,
|
|
72
|
-
ui = {},
|
|
73
|
-
disabled,
|
|
74
|
-
href,
|
|
75
|
-
icon,
|
|
76
|
-
loading,
|
|
77
|
-
loadingicon,
|
|
78
|
-
target,
|
|
79
|
-
type
|
|
80
|
-
}: ButtonProps = $props();
|
|
81
|
-
|
|
82
|
-
let internal_loading = $state(false);
|
|
83
|
-
const is_loading = $derived.by(() => {
|
|
84
|
-
if (loading) return true;
|
|
85
|
-
if (loadingauto) return internal_loading;
|
|
86
|
-
return false;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const classes = $derived.by(() =>
|
|
90
|
-
tv({
|
|
91
|
-
slots: {
|
|
92
|
-
icon: '',
|
|
93
|
-
base: 'transition flex-inline items-center font-sans'
|
|
94
|
-
},
|
|
95
|
-
variants: {
|
|
96
|
-
color: {
|
|
97
|
-
primary: '',
|
|
98
|
-
secondary: '',
|
|
99
|
-
error: '',
|
|
100
|
-
success: '',
|
|
101
|
-
info: '',
|
|
102
|
-
warning: ''
|
|
103
|
-
},
|
|
104
|
-
variant: {
|
|
105
|
-
link: '',
|
|
106
|
-
solid: 'text-white',
|
|
107
|
-
outline: 'border',
|
|
108
|
-
soft: '',
|
|
109
|
-
subtle: 'border',
|
|
110
|
-
ghost: ''
|
|
111
|
-
},
|
|
112
|
-
size: {
|
|
113
|
-
xs: {
|
|
114
|
-
base: 'font-medium text-xs px-2 h-6 rounded gap-1',
|
|
115
|
-
icon: 'size-4'
|
|
116
|
-
},
|
|
117
|
-
sm: { base: 'font-medium text-xs px-2 h-7 rounded gap-1', icon: 'size-4' },
|
|
118
|
-
md: { base: 'font-medium text-sm rounded-md px-2 h-8 gap-2', icon: 'size-5' },
|
|
119
|
-
lg: { base: 'font-medium text-sm px-3 h-9 rounded-md gap-2', icon: 'size-6' },
|
|
120
|
-
xl: { base: 'font-medium px-3 h-10 rounded-md gap-2', icon: 'size-6' }
|
|
121
|
-
},
|
|
122
|
-
block: {
|
|
123
|
-
true: 'w-full'
|
|
124
|
-
},
|
|
125
|
-
disabled: {
|
|
126
|
-
true: 'cursor-not-allowed',
|
|
127
|
-
false: 'cursor-pointer'
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
compoundVariants: [
|
|
131
|
-
{
|
|
132
|
-
color: 'primary',
|
|
133
|
-
variant: 'solid',
|
|
134
|
-
class: 'bg-primary-500 hover:(bg-primary-400)'
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
color: 'secondary',
|
|
138
|
-
variant: 'solid',
|
|
139
|
-
class: 'bg-secondary-900 hover:(bg-secondary-800)'
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
color: 'info',
|
|
143
|
-
variant: 'solid',
|
|
144
|
-
class: 'bg-blue-500 hover:(bg-blue-400)'
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
color: 'success',
|
|
148
|
-
variant: 'solid',
|
|
149
|
-
class: 'bg-green-500 hover:(bg-green-400)'
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
color: 'error',
|
|
153
|
-
variant: 'solid',
|
|
154
|
-
class: 'bg-red-500 hover:(bg-red-400)'
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
color: 'warning',
|
|
158
|
-
variant: 'solid',
|
|
159
|
-
class: 'bg-yellow-500 hover:(bg-yellow-400)'
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
{
|
|
163
|
-
color: 'primary',
|
|
164
|
-
variant: 'outline',
|
|
165
|
-
class: 'border-primary-300 text-primary-500 hover:(bg-primary-50)'
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
color: 'secondary',
|
|
169
|
-
variant: 'outline',
|
|
170
|
-
class: 'border-secondary-300 hover:(bg-secondary-100)'
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
color: 'info',
|
|
174
|
-
variant: 'outline',
|
|
175
|
-
class: 'border-blue-300 text-blue-500 hover:(bg-blue-50)'
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
color: 'success',
|
|
179
|
-
variant: 'outline',
|
|
180
|
-
class: 'border-green-300 text-green-500 hover:(bg-green-50)'
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
color: 'error',
|
|
184
|
-
variant: 'outline',
|
|
185
|
-
class: 'border-red-300 text-red-500 hover:(bg-red-50)'
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
color: 'warning',
|
|
189
|
-
variant: 'outline',
|
|
190
|
-
class: 'border-yellow-300 text-yellow-500 hover:(bg-yellow-50)'
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
color: 'primary',
|
|
195
|
-
variant: 'soft',
|
|
196
|
-
class: ' bg-primary-50 text-primary-500 hover:(bg-primary-100)'
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
color: 'secondary',
|
|
200
|
-
variant: 'soft',
|
|
201
|
-
class: 'bg-secondary-100 text-secondary-800 hover:(bg-secondary-200)'
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
color: 'info',
|
|
205
|
-
variant: 'soft',
|
|
206
|
-
class: 'bg-blue-100 text-blue-500 hover:(bg-blue-50)'
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
color: 'success',
|
|
210
|
-
variant: 'soft',
|
|
211
|
-
class: 'bg-green-100 text-green-500 hover:(bg-green-50)'
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
color: 'error',
|
|
215
|
-
variant: 'soft',
|
|
216
|
-
class: 'bg-red-100 text-red-500 hover:(bg-red-50)'
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
color: 'warning',
|
|
220
|
-
variant: 'soft',
|
|
221
|
-
class: 'bg-yellow-100 text-yellow-500 hover:(bg-yellow-50)'
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
{
|
|
225
|
-
color: 'primary',
|
|
226
|
-
variant: 'subtle',
|
|
227
|
-
class: 'bg-primary-50 text-primary-500 border-primary-200 hover:(bg-primary-100)'
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
color: 'secondary',
|
|
231
|
-
variant: 'subtle',
|
|
232
|
-
class: 'bg-secondary-50 text-secondary-800 border-secondary-300 hover:(bg-secondary-100)'
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
color: 'info',
|
|
236
|
-
variant: 'subtle',
|
|
237
|
-
class: 'bg-blue-50 text-blue-600 border-blue-200 hover:(bg-blue-100)'
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
color: 'success',
|
|
241
|
-
variant: 'subtle',
|
|
242
|
-
class: 'bg-green-100 text-green-600 border-green-300 hover:(bg-green-100)'
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
color: 'error',
|
|
246
|
-
variant: 'subtle',
|
|
247
|
-
class: 'bg-red-50 text-red-600 border-red-200 hover:(bg-red-100)'
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
color: 'warning',
|
|
251
|
-
variant: 'subtle',
|
|
252
|
-
class: 'bg-yellow-50 text-yellow-600 border-yellow-300 hover:(bg-yellow-100)'
|
|
253
|
-
},
|
|
254
|
-
|
|
255
|
-
{
|
|
256
|
-
color: 'primary',
|
|
257
|
-
variant: 'ghost',
|
|
258
|
-
class: 'text-primary-500 hover:(bg-primary-100)'
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
color: 'secondary',
|
|
262
|
-
variant: 'ghost',
|
|
263
|
-
class: 'text-secondary-900 hover:(bg-secondary-100)'
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
color: 'info',
|
|
267
|
-
variant: 'ghost',
|
|
268
|
-
class: 'text-blue-600 hover:(bg-blue-100)'
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
color: 'success',
|
|
272
|
-
variant: 'ghost',
|
|
273
|
-
class: 'text-green-600 hover:(bg-green-100)'
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
color: 'error',
|
|
277
|
-
variant: 'ghost',
|
|
278
|
-
class: 'text-red-600 hover:(bg-red-100)'
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
color: 'warning',
|
|
282
|
-
variant: 'ghost',
|
|
283
|
-
class: 'text-yellow-600 hover:(bg-yellow-100)'
|
|
284
|
-
},
|
|
285
|
-
|
|
286
|
-
{
|
|
287
|
-
color: 'primary',
|
|
288
|
-
variant: 'link',
|
|
289
|
-
class: 'text-primary-500 hover:(text-primary-400)'
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
color: 'secondary',
|
|
293
|
-
variant: 'link',
|
|
294
|
-
class: 'text-secondary-500 hover:(text-secondary-700)'
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
color: 'info',
|
|
298
|
-
variant: 'link',
|
|
299
|
-
class: 'text-blue-500 hover:(text-blue-400)'
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
color: 'success',
|
|
303
|
-
variant: 'link',
|
|
304
|
-
class: 'text-green-500 hover:(text-green-400)'
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
color: 'error',
|
|
308
|
-
variant: 'link',
|
|
309
|
-
class: 'text-red-500 hover:(text-red-400)'
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
color: 'warning',
|
|
313
|
-
variant: 'link',
|
|
314
|
-
class: 'text-yellow-500 hover:(text-yellow-400)'
|
|
315
|
-
}
|
|
316
|
-
]
|
|
317
|
-
})({ variant, color, size, block, disabled: disabled || is_loading })
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
async function onClickWrapper(event: MouseEvent) {
|
|
321
|
-
if (!onclick) return;
|
|
322
|
-
internal_loading = true;
|
|
323
|
-
|
|
324
|
-
await onclick(event);
|
|
325
|
-
|
|
326
|
-
internal_loading = false;
|
|
327
|
-
}
|
|
328
|
-
</script>
|
|
329
|
-
|
|
330
|
-
{#if href}
|
|
331
|
-
<a
|
|
332
|
-
{href}
|
|
333
|
-
{target}
|
|
334
|
-
class={classes.base({
|
|
335
|
-
class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
|
|
336
|
-
})}
|
|
337
|
-
onclick={onClickWrapper}
|
|
338
|
-
>
|
|
339
|
-
{@render Content()}
|
|
340
|
-
</a>
|
|
341
|
-
{:else}
|
|
342
|
-
<button
|
|
343
|
-
{type}
|
|
344
|
-
disabled={disabled || is_loading}
|
|
345
|
-
class={classes.base({
|
|
346
|
-
class: [!children && icon ? 'px-0 aspect-square justify-center' : '', ui.base]
|
|
347
|
-
})}
|
|
348
|
-
onclick={onClickWrapper}
|
|
349
|
-
>
|
|
350
|
-
{@render Content()}
|
|
351
|
-
</button>
|
|
352
|
-
{/if}
|
|
353
|
-
|
|
354
|
-
{#snippet Content()}
|
|
355
|
-
{#if iconposition === 'left'}
|
|
356
|
-
{@render Icon()}
|
|
357
|
-
{/if}
|
|
358
|
-
|
|
359
|
-
{#if label}
|
|
360
|
-
{label}
|
|
361
|
-
{:else}
|
|
362
|
-
{@render children?.()}
|
|
363
|
-
{/if}
|
|
364
|
-
|
|
365
|
-
{#if iconposition !== 'left'}
|
|
366
|
-
{@render Icon()}
|
|
367
|
-
{/if}
|
|
368
|
-
{/snippet}
|
|
369
|
-
|
|
370
|
-
{#snippet Icon()}
|
|
371
|
-
{@const IconCom = is_loading ? loadingicon || 'i-lucide-loader-circle' : icon}
|
|
372
|
-
|
|
373
|
-
{#if IconCom}
|
|
374
|
-
{#if typeof IconCom === 'string'}
|
|
375
|
-
<div
|
|
376
|
-
class={classes.icon({ class: ['pi', IconCom, is_loading && 'animate-spin', ui.icon] })}
|
|
377
|
-
></div>
|
|
378
|
-
{:else if isSnippet(IconCom)}
|
|
379
|
-
{@render IconCom()}
|
|
380
|
-
{:else}
|
|
381
|
-
<IconCom />
|
|
382
|
-
{/if}
|
|
383
|
-
{/if}
|
|
384
|
-
{/snippet}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type Component, type Snippet } from 'svelte';
|
|
2
|
-
import { type PropColor } from '../index.js';
|
|
3
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
-
export type ButtonProps = {
|
|
5
|
-
/** The underlying DOM element being rendered. You can bind to this to get a reference to the element. */
|
|
6
|
-
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
7
|
-
/** Where to display the linked URL, as the name for a browsing context. */
|
|
8
|
-
target?: null | '_blank' | '_parent' | '_self' | '_top' | (string & {});
|
|
9
|
-
/** Force the link to be active independent of the current route. */
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
/** The type of the button when not a link. */
|
|
12
|
-
type?: 'submit' | 'reset' | 'button' | null | undefined;
|
|
13
|
-
/** When true, the icon will be displayed on the right side. */
|
|
14
|
-
loadingicon?: string;
|
|
15
|
-
/** When true, the loading icon will be displayed. */
|
|
16
|
-
loading?: boolean;
|
|
17
|
-
/** The position of the icon, including the loading icon */
|
|
18
|
-
iconposition?: 'left' | 'right';
|
|
19
|
-
/** Icon when `loading` is `false` */
|
|
20
|
-
icon?: string | Snippet | Component;
|
|
21
|
-
/** Route Location the link should navigate to when clicked on. */
|
|
22
|
-
href?: string;
|
|
23
|
-
label?: string;
|
|
24
|
-
/**
|
|
25
|
-
* @defaultValue 'primary'
|
|
26
|
-
*/
|
|
27
|
-
color?: PropColor;
|
|
28
|
-
/**
|
|
29
|
-
* @defaultValue 'solid'
|
|
30
|
-
*/
|
|
31
|
-
variant?: 'link' | 'solid' | 'outline' | 'soft' | 'subtle' | 'ghost';
|
|
32
|
-
/**
|
|
33
|
-
* @defaultValue 'md'
|
|
34
|
-
*/
|
|
35
|
-
size?: 'md' | 'xs' | 'sm' | 'lg' | 'xl';
|
|
36
|
-
/** Render the button full width. */
|
|
37
|
-
block?: boolean;
|
|
38
|
-
/** Set loading state automatically based on the `@click` promise state */
|
|
39
|
-
loadingauto?: boolean;
|
|
40
|
-
onclick?: (event: MouseEvent) => void | Promise<void>;
|
|
41
|
-
ui?: {
|
|
42
|
-
base?: ClassNameValue;
|
|
43
|
-
icon?: ClassNameValue;
|
|
44
|
-
};
|
|
45
|
-
children?: Snippet;
|
|
46
|
-
};
|
|
47
|
-
declare const Button: Component<ButtonProps, {}, "ref">;
|
|
48
|
-
type Button = ReturnType<typeof Button>;
|
|
49
|
-
export default Button;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
4
|
-
import { tv } from 'tailwind-variants';
|
|
5
|
-
|
|
6
|
-
export type CardProps = {
|
|
7
|
-
children: Snippet;
|
|
8
|
-
header?: Snippet;
|
|
9
|
-
footer?: Snippet;
|
|
10
|
-
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
11
|
-
ui?: {
|
|
12
|
-
base?: ClassNameValue;
|
|
13
|
-
header?: ClassNameValue;
|
|
14
|
-
content?: ClassNameValue;
|
|
15
|
-
footer?: ClassNameValue;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script lang="ts">
|
|
21
|
-
let { header, children, footer, variant = 'solid', ui = {} }: CardProps = $props();
|
|
22
|
-
|
|
23
|
-
const classes = $derived.by(() =>
|
|
24
|
-
tv({
|
|
25
|
-
slots: {
|
|
26
|
-
base: 'rounded overflow-hidden',
|
|
27
|
-
header: 'p-4 sm:px-6',
|
|
28
|
-
content: 'p-4 sm:p-6',
|
|
29
|
-
footer: 'p-4 sm:px-6'
|
|
30
|
-
},
|
|
31
|
-
variants: {
|
|
32
|
-
variant: {
|
|
33
|
-
solid: {
|
|
34
|
-
base: 'bg-secondary-900 text-secondary-50',
|
|
35
|
-
header: 'border-transparent',
|
|
36
|
-
footer: 'border-transparent'
|
|
37
|
-
},
|
|
38
|
-
outline: {
|
|
39
|
-
base: 'border border-secondary-300 divide-y divide-secondary-300'
|
|
40
|
-
},
|
|
41
|
-
soft: {
|
|
42
|
-
base: 'bg-secondary-50 divide-y divide-secondary-300'
|
|
43
|
-
},
|
|
44
|
-
subtle: {
|
|
45
|
-
base: 'bg-secondary-50 border-secondary-300 border divide-y divide-secondary-300'
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
compoundVariants: []
|
|
50
|
-
})({ variant })
|
|
51
|
-
);
|
|
52
|
-
</script>
|
|
53
|
-
|
|
54
|
-
<div class={classes.base({ class: [ui.base] })}>
|
|
55
|
-
{#if header}
|
|
56
|
-
<div class={classes.header({ class: [ui.header] })}>
|
|
57
|
-
{@render header()}
|
|
58
|
-
</div>
|
|
59
|
-
{/if}
|
|
60
|
-
|
|
61
|
-
<div class={classes.content({ class: ui.content })}>
|
|
62
|
-
{@render children()}
|
|
63
|
-
</div>
|
|
64
|
-
|
|
65
|
-
{#if footer}
|
|
66
|
-
<div class={classes.header({ class: [ui.header] })}>
|
|
67
|
-
{@render footer()}
|
|
68
|
-
</div>
|
|
69
|
-
{/if}
|
|
70
|
-
</div>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
-
export type CardProps = {
|
|
4
|
-
children: Snippet;
|
|
5
|
-
header?: Snippet;
|
|
6
|
-
footer?: Snippet;
|
|
7
|
-
variant?: 'solid' | 'outline' | 'soft' | 'subtle';
|
|
8
|
-
ui?: {
|
|
9
|
-
base?: ClassNameValue;
|
|
10
|
-
header?: ClassNameValue;
|
|
11
|
-
content?: ClassNameValue;
|
|
12
|
-
footer?: ClassNameValue;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
declare const Card: import("svelte").Component<CardProps, {}, "">;
|
|
16
|
-
type Card = ReturnType<typeof Card>;
|
|
17
|
-
export default Card;
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { type PropColor, isComponent, isSnippet } from '../index.js';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
-
import { tv } from 'tailwind-variants';
|
|
6
|
-
import type { Component } from 'vitest-browser-svelte';
|
|
7
|
-
|
|
8
|
-
export type CheckboxProps = {
|
|
9
|
-
value?: boolean | 'intermediate';
|
|
10
|
-
color?: PropColor;
|
|
11
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
icon?: string | Snippet | Component;
|
|
14
|
-
intermediateicon?: string | Snippet | Component;
|
|
15
|
-
label?: string | Snippet;
|
|
16
|
-
description?: string | Snippet;
|
|
17
|
-
required?: boolean;
|
|
18
|
-
indicator?: 'start' | 'end' | 'hidden';
|
|
19
|
-
as?: string;
|
|
20
|
-
ui?: {
|
|
21
|
-
root?: ClassNameValue;
|
|
22
|
-
container?: ClassNameValue;
|
|
23
|
-
icon?: ClassNameValue;
|
|
24
|
-
label?: ClassNameValue;
|
|
25
|
-
description?: ClassNameValue;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<script lang="ts">
|
|
31
|
-
let {
|
|
32
|
-
value = $bindable(false),
|
|
33
|
-
color = 'primary',
|
|
34
|
-
size = 'md',
|
|
35
|
-
disabled,
|
|
36
|
-
icon = 'i-lucide-check',
|
|
37
|
-
intermediateicon = 'i-lucide-minus',
|
|
38
|
-
label,
|
|
39
|
-
description,
|
|
40
|
-
required,
|
|
41
|
-
indicator = 'start',
|
|
42
|
-
as = 'div',
|
|
43
|
-
ui = {}
|
|
44
|
-
}: CheckboxProps = $props();
|
|
45
|
-
const id = $props.id();
|
|
46
|
-
|
|
47
|
-
const classes = $derived.by(() =>
|
|
48
|
-
tv({
|
|
49
|
-
slots: {
|
|
50
|
-
root: 'relative flex-inline gap-2',
|
|
51
|
-
container:
|
|
52
|
-
'rounded-md border border-neutral-200 relative transition m-0.5 mr-0 grid place-items-center',
|
|
53
|
-
icon: 'pi text-white',
|
|
54
|
-
label: 'text-sm font-medium',
|
|
55
|
-
description: 'text-sm text-neutral-500'
|
|
56
|
-
},
|
|
57
|
-
variants: {
|
|
58
|
-
color: {
|
|
59
|
-
primary: {
|
|
60
|
-
container: [value && 'bg-primary-500 border-primary-500 text-primary-500']
|
|
61
|
-
},
|
|
62
|
-
secondary: {
|
|
63
|
-
container: [value && 'bg-neutral-900 border-neutral-900 text-neutral-900']
|
|
64
|
-
},
|
|
65
|
-
info: {
|
|
66
|
-
container: [value && 'bg-info-500 border-info-500 text-info-500']
|
|
67
|
-
},
|
|
68
|
-
success: {
|
|
69
|
-
container: [value && 'bg-success-500 border-success-500 text-success-500']
|
|
70
|
-
},
|
|
71
|
-
warning: {
|
|
72
|
-
container: [value && 'bg-warning-500 border-warning-500 text-warning-500']
|
|
73
|
-
},
|
|
74
|
-
error: {
|
|
75
|
-
container: [value && 'bg-error-500 border-error-500 text-error-500']
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
size: {
|
|
79
|
-
xs: {
|
|
80
|
-
container: 'size-3',
|
|
81
|
-
icon: 'size-3'
|
|
82
|
-
},
|
|
83
|
-
sm: {
|
|
84
|
-
container: 'size-3.5',
|
|
85
|
-
icon: 'size-3.5'
|
|
86
|
-
},
|
|
87
|
-
md: {
|
|
88
|
-
container: 'size-4',
|
|
89
|
-
icon: 'size-4'
|
|
90
|
-
},
|
|
91
|
-
lg: {
|
|
92
|
-
container: 'size-4.5',
|
|
93
|
-
icon: 'size-4.5'
|
|
94
|
-
},
|
|
95
|
-
xl: {
|
|
96
|
-
container: 'size-5',
|
|
97
|
-
icon: 'size-5'
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
indicator: {
|
|
101
|
-
start: '',
|
|
102
|
-
end: {
|
|
103
|
-
root: 'flex-row-reverse'
|
|
104
|
-
},
|
|
105
|
-
hidden: {
|
|
106
|
-
container: 'hidden'
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
compoundVariants: []
|
|
111
|
-
})({ color, size, indicator })
|
|
112
|
-
);
|
|
113
|
-
</script>
|
|
114
|
-
|
|
115
|
-
<svelte:element
|
|
116
|
-
this={as}
|
|
117
|
-
data-state={value ? 'checked' : 'unchecked'}
|
|
118
|
-
class={classes.root({
|
|
119
|
-
class: [disabled && 'opacity-50', ui.root]
|
|
120
|
-
})}
|
|
121
|
-
>
|
|
122
|
-
<button
|
|
123
|
-
{id}
|
|
124
|
-
aria-label="checkbox"
|
|
125
|
-
class={classes.container({ class: [ui.container] })}
|
|
126
|
-
onclick={() => {
|
|
127
|
-
if (disabled) return;
|
|
128
|
-
if (value === 'intermediate') return (value = true);
|
|
129
|
-
value = !value;
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
{@render Icon(icon, [value !== true && 'opacity-0'])}
|
|
133
|
-
{@render Icon(intermediateicon, [value !== 'intermediate' && 'opacity-0'])}
|
|
134
|
-
</button>
|
|
135
|
-
|
|
136
|
-
{#if label}
|
|
137
|
-
<div class="flex flex-col justify-start">
|
|
138
|
-
<label
|
|
139
|
-
for={id}
|
|
140
|
-
class={classes.label({
|
|
141
|
-
class: [required ? 'after:content-["*"] after:text-error-500' : '', ui.label]
|
|
142
|
-
})}
|
|
143
|
-
>
|
|
144
|
-
{#if typeof label === 'string'}
|
|
145
|
-
{label}
|
|
146
|
-
{:else}
|
|
147
|
-
{@render label()}
|
|
148
|
-
{/if}
|
|
149
|
-
</label>
|
|
150
|
-
|
|
151
|
-
{#if description}
|
|
152
|
-
<div class={classes.description({ class: ui.description })}>
|
|
153
|
-
{#if typeof description === 'string'}
|
|
154
|
-
{description}
|
|
155
|
-
{:else}
|
|
156
|
-
{@render description()}
|
|
157
|
-
{/if}
|
|
158
|
-
</div>
|
|
159
|
-
{/if}
|
|
160
|
-
</div>
|
|
161
|
-
{/if}
|
|
162
|
-
</svelte:element>
|
|
163
|
-
|
|
164
|
-
{#snippet Icon(ico?: CheckboxProps['icon'], icon_class?: ClassNameValue)}
|
|
165
|
-
<div class={['absolute', icon_class]}>
|
|
166
|
-
{#if typeof ico === 'string'}
|
|
167
|
-
<div class={classes.icon({ class: [ico, ui.icon] })}></div>
|
|
168
|
-
{:else if isSnippet(ico)}
|
|
169
|
-
{@render ico()}
|
|
170
|
-
{:else if isComponent(ico)}
|
|
171
|
-
{@const Iconn = ico}
|
|
172
|
-
<Iconn />
|
|
173
|
-
{/if}
|
|
174
|
-
</div>
|
|
175
|
-
{/snippet}
|