uisv 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/components/accordion.svelte +108 -0
  2. package/dist/components/accordion.svelte.d.ts +58 -0
  3. package/dist/components/alert.svelte +271 -0
  4. package/dist/components/alert.svelte.d.ts +23 -0
  5. package/dist/components/badge.svelte +225 -0
  6. package/dist/components/badge.svelte.d.ts +19 -0
  7. package/dist/components/banner.svelte +254 -0
  8. package/dist/components/banner.svelte.d.ts +23 -0
  9. package/dist/components/button.svelte +409 -0
  10. package/dist/components/button.svelte.d.ts +49 -0
  11. package/dist/components/card.svelte +70 -0
  12. package/dist/components/card.svelte.d.ts +17 -0
  13. package/dist/components/checkbox-group.svelte +258 -0
  14. package/dist/components/checkbox-group.svelte.d.ts +26 -0
  15. package/dist/components/checkbox.svelte +175 -0
  16. package/dist/components/checkbox.svelte.d.ts +27 -0
  17. package/dist/components/chip.svelte +82 -0
  18. package/dist/components/chip.svelte.d.ts +17 -0
  19. package/dist/components/color-picker.svelte +48 -0
  20. package/dist/components/color-picker.svelte.d.ts +10 -0
  21. package/dist/components/h1.svelte +15 -0
  22. package/dist/components/h1.svelte.d.ts +3 -0
  23. package/dist/components/h2.svelte +19 -0
  24. package/dist/components/h2.svelte.d.ts +3 -0
  25. package/dist/components/h3.svelte +16 -0
  26. package/dist/components/h3.svelte.d.ts +3 -0
  27. package/dist/components/h4.svelte +19 -0
  28. package/dist/components/h4.svelte.d.ts +3 -0
  29. package/dist/components/h5.svelte +19 -0
  30. package/dist/components/h5.svelte.d.ts +3 -0
  31. package/dist/components/h6.svelte +19 -0
  32. package/dist/components/h6.svelte.d.ts +3 -0
  33. package/dist/components/index.d.ts +45 -0
  34. package/dist/components/index.js +45 -0
  35. package/dist/components/input-time.svelte +234 -0
  36. package/dist/components/input-time.svelte.d.ts +54 -0
  37. package/dist/components/input.svelte +285 -0
  38. package/dist/components/input.svelte.d.ts +55 -0
  39. package/dist/components/kbd.svelte +239 -0
  40. package/dist/components/kbd.svelte.d.ts +40 -0
  41. package/dist/components/p.svelte +9 -0
  42. package/dist/components/p.svelte.d.ts +3 -0
  43. package/dist/components/pin-input.svelte +162 -0
  44. package/dist/components/pin-input.svelte.d.ts +25 -0
  45. package/dist/components/placeholder.svelte +34 -0
  46. package/dist/components/placeholder.svelte.d.ts +3 -0
  47. package/dist/components/popover.svelte +151 -0
  48. package/dist/components/popover.svelte.d.ts +88 -0
  49. package/dist/components/progress.svelte +124 -0
  50. package/dist/components/progress.svelte.d.ts +21 -0
  51. package/dist/components/select.svelte +171 -0
  52. package/dist/components/select.svelte.d.ts +50 -0
  53. package/dist/components/slider.svelte +172 -0
  54. package/dist/components/slider.svelte.d.ts +44 -0
  55. package/dist/components/switch.svelte +180 -0
  56. package/dist/components/switch.svelte.d.ts +27 -0
  57. package/dist/components/tabs.svelte +245 -0
  58. package/dist/components/tabs.svelte.d.ts +34 -0
  59. package/dist/index.d.ts +4 -0
  60. package/dist/index.js +3 -0
  61. package/dist/utilities.svelte.d.ts +24 -0
  62. package/dist/utilities.svelte.js +47 -0
  63. package/dist/vite.d.ts +52 -0
  64. package/dist/vite.js +132 -0
  65. package/package.json +35 -38
@@ -0,0 +1,49 @@
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 | Snippet | Component;
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;
@@ -0,0 +1,70 @@
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-surface-900 text-surface-50',
35
+ header: 'border-transparent',
36
+ footer: 'border-transparent'
37
+ },
38
+ outline: {
39
+ base: 'border border-surface-300 divide-y divide-surface-300'
40
+ },
41
+ soft: {
42
+ base: 'bg-surface-50 divide-y divide-surface-300'
43
+ },
44
+ subtle: {
45
+ base: 'bg-surface-50 border-surface-300 border divide-y divide-surface-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>
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,258 @@
1
+ <script module lang="ts">
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ import { tv } from 'tailwind-variants';
4
+ import type { Component, Snippet } from 'svelte';
5
+ import { type PropColor, isComponent, isSnippet, Checkbox } from '../index.js';
6
+
7
+ /* eslint @typescript-eslint/no-explicit-any: 0 */
8
+
9
+ export type CheckboxGroupProps = {
10
+ color?: PropColor;
11
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
12
+ icon?: string | Snippet | Component;
13
+ required?: boolean;
14
+ indicator?: 'start' | 'end' | 'hidden';
15
+ value?: any[];
16
+ valuekey?: string;
17
+ variant?: 'list' | 'card' | 'table';
18
+ items: Array<any>;
19
+ labelkey?: string;
20
+ descriptionkey?: string;
21
+ legend?: string | Snippet | Component;
22
+ orientation?: 'horizontal' | 'vertical';
23
+ ui?: {
24
+ root?: ClassNameValue;
25
+ container?: ClassNameValue;
26
+ checkbox?: ClassNameValue;
27
+ };
28
+ };
29
+ </script>
30
+
31
+ <script lang="ts">
32
+ let {
33
+ value = $bindable([]),
34
+ valuekey = 'value',
35
+ color = 'primary',
36
+ size = 'md',
37
+ variant = 'list',
38
+ items = [],
39
+ labelkey = 'label',
40
+ descriptionkey = 'description',
41
+ legend,
42
+ orientation = 'horizontal',
43
+ ui = {},
44
+ ...props
45
+ }: CheckboxGroupProps = $props();
46
+
47
+ const classes = $derived.by(() =>
48
+ tv({
49
+ slots: {
50
+ root: '',
51
+ container: 'flex',
52
+ checkbox: '',
53
+ },
54
+ variants: {
55
+ color: {
56
+ primary: {
57
+ container: [],
58
+ },
59
+ surface: {
60
+ container: [],
61
+ },
62
+ info: {
63
+ container: [],
64
+ },
65
+ success: {
66
+ container: [],
67
+ },
68
+ warning: {
69
+ container: [],
70
+ },
71
+ error: {
72
+ container: [],
73
+ },
74
+ },
75
+ size: {
76
+ xs: {
77
+ container: '',
78
+ icon: 'size-3',
79
+ },
80
+ sm: {
81
+ container: '',
82
+ icon: 'size-3.5',
83
+ },
84
+ md: {
85
+ container: '',
86
+ icon: 'size-4',
87
+ },
88
+ lg: {
89
+ container: '',
90
+ icon: 'size-4.5',
91
+ },
92
+ xl: {
93
+ container: '',
94
+ icon: 'size-5',
95
+ },
96
+ },
97
+ variant: {
98
+ list: { container: 'gap-2' },
99
+ card: { container: 'gap-2', checkbox: 'p-4 rounded-lg border border-neutral-200' },
100
+ table: {
101
+ container: 'gap-0 ',
102
+ checkbox: 'border border-neutral-200 p-4 data-[state=checked]:z-1',
103
+ },
104
+ },
105
+ orientation: {
106
+ horizontal: {
107
+ container: 'flex-row',
108
+ checkbox:
109
+ '[&:not(:last-child)]:(-me-px ms-0) first-of-type:rounded-s-lg last-of-type:rounded-e-lg',
110
+ },
111
+ vertical: {
112
+ container: 'flex-col -space-y-px',
113
+ },
114
+ },
115
+ selected: { true: '', false: '' },
116
+ },
117
+ compoundVariants: [
118
+ {
119
+ color: 'primary',
120
+ selected: true,
121
+ variant: ['table', 'card'],
122
+ class: {
123
+ checkbox: 'border-primary-500',
124
+ },
125
+ },
126
+ {
127
+ color: 'surface',
128
+ selected: true,
129
+ variant: ['table', 'card'],
130
+ class: {
131
+ checkbox: 'border-surface-500',
132
+ },
133
+ },
134
+ {
135
+ color: 'info',
136
+ selected: true,
137
+ variant: ['table', 'card'],
138
+ class: {
139
+ checkbox: 'border-info-500',
140
+ },
141
+ },
142
+ {
143
+ color: 'success',
144
+ selected: true,
145
+ variant: ['table', 'card'],
146
+ class: {
147
+ checkbox: 'border-success-500',
148
+ },
149
+ },
150
+ {
151
+ color: 'warning',
152
+ selected: true,
153
+ variant: ['table', 'card'],
154
+ class: {
155
+ checkbox: 'border-warning-500',
156
+ },
157
+ },
158
+ {
159
+ color: 'error',
160
+ selected: true,
161
+ variant: ['table', 'card'],
162
+ class: {
163
+ checkbox: 'border-error-500',
164
+ },
165
+ },
166
+
167
+ {
168
+ color: 'primary',
169
+ selected: true,
170
+ variant: ['table'],
171
+ class: {
172
+ checkbox: 'bg-primary-100',
173
+ },
174
+ },
175
+ {
176
+ color: 'surface',
177
+ selected: true,
178
+ variant: ['table'],
179
+ class: {
180
+ checkbox: 'bg-surface-100',
181
+ },
182
+ },
183
+ {
184
+ color: 'info',
185
+ selected: true,
186
+ variant: ['table'],
187
+ class: {
188
+ checkbox: 'bg-info-100',
189
+ },
190
+ },
191
+ {
192
+ color: 'success',
193
+ selected: true,
194
+ variant: ['table'],
195
+ class: {
196
+ checkbox: 'bg-success-100',
197
+ },
198
+ },
199
+ {
200
+ color: 'warning',
201
+ selected: true,
202
+ variant: ['table'],
203
+ class: {
204
+ checkbox: 'bg-warning-100',
205
+ },
206
+ },
207
+ {
208
+ color: 'error',
209
+ selected: true,
210
+ variant: ['table'],
211
+ class: {
212
+ checkbox: 'bg-error-100',
213
+ },
214
+ },
215
+ ],
216
+ })({ color, size, variant, orientation }),
217
+ );
218
+ </script>
219
+
220
+ <div class={classes.root({ class: [ui.root] })}>
221
+ {#if typeof legend === 'string'}
222
+ <legend>{legend}</legend>
223
+ {:else if isSnippet(legend)}
224
+ {@render legend()}
225
+ {:else if isComponent(legend)}
226
+ {@const Legend = legend}
227
+ <Legend />
228
+ {/if}
229
+
230
+ <fieldset class={classes.container({ class: [ui.container] })}>
231
+ {#each items as item, index (index)}
232
+ {@const key = typeof item === 'object' ? item[valuekey] : item}
233
+
234
+ <Checkbox
235
+ {...props}
236
+ {color}
237
+ as={variant === 'list' ? 'div' : 'label'}
238
+ ui={{
239
+ root: classes.checkbox({
240
+ class: [ui.checkbox],
241
+ selected: value.includes(key),
242
+ }),
243
+ }}
244
+ bind:value={
245
+ () => value.includes(key),
246
+ (v) => {
247
+ if (v) return value.push(key);
248
+ const index = value.findIndex((x) => x === key);
249
+ if (index < 0) return;
250
+ value.splice(index, 1);
251
+ }
252
+ }
253
+ description={typeof item === 'object' ? item[descriptionkey] : undefined}
254
+ label={typeof item === 'object' ? item[labelkey] : item}
255
+ />
256
+ {/each}
257
+ </fieldset>
258
+ </div>
@@ -0,0 +1,26 @@
1
+ import type { ClassNameValue } from 'tailwind-merge';
2
+ import type { Component, Snippet } from 'svelte';
3
+ import { type PropColor } from '../index.js';
4
+ export type CheckboxGroupProps = {
5
+ color?: PropColor;
6
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
7
+ icon?: string | Snippet | Component;
8
+ required?: boolean;
9
+ indicator?: 'start' | 'end' | 'hidden';
10
+ value?: any[];
11
+ valuekey?: string;
12
+ variant?: 'list' | 'card' | 'table';
13
+ items: Array<any>;
14
+ labelkey?: string;
15
+ descriptionkey?: string;
16
+ legend?: string | Snippet | Component;
17
+ orientation?: 'horizontal' | 'vertical';
18
+ ui?: {
19
+ root?: ClassNameValue;
20
+ container?: ClassNameValue;
21
+ checkbox?: ClassNameValue;
22
+ };
23
+ };
24
+ declare const CheckboxGroup: Component<CheckboxGroupProps, {}, "value">;
25
+ type CheckboxGroup = ReturnType<typeof CheckboxGroup>;
26
+ export default CheckboxGroup;
@@ -0,0 +1,175 @@
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
+ surface: {
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}
@@ -0,0 +1,27 @@
1
+ import { type PropColor } from '../index.js';
2
+ import type { Snippet } from 'svelte';
3
+ import type { ClassNameValue } from 'tailwind-merge';
4
+ import type { Component } from 'vitest-browser-svelte';
5
+ export type CheckboxProps = {
6
+ value?: boolean | 'intermediate';
7
+ color?: PropColor;
8
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
9
+ disabled?: boolean;
10
+ icon?: string | Snippet | Component;
11
+ intermediateicon?: string | Snippet | Component;
12
+ label?: string | Snippet;
13
+ description?: string | Snippet;
14
+ required?: boolean;
15
+ indicator?: 'start' | 'end' | 'hidden';
16
+ as?: string;
17
+ ui?: {
18
+ root?: ClassNameValue;
19
+ container?: ClassNameValue;
20
+ icon?: ClassNameValue;
21
+ label?: ClassNameValue;
22
+ description?: ClassNameValue;
23
+ };
24
+ };
25
+ declare const Checkbox: import("svelte").Component<CheckboxProps, {}, "value">;
26
+ type Checkbox = ReturnType<typeof Checkbox>;
27
+ export default Checkbox;
@@ -0,0 +1,82 @@
1
+ <script module lang="ts">
2
+ import type { PropColor } from '../index.js';
3
+ import type { Snippet } from 'svelte';
4
+ import type { ClassNameValue } from 'tailwind-merge';
5
+ import { tv } from 'tailwind-variants';
6
+
7
+ export type ChipProps = {
8
+ children: Snippet;
9
+ text?: string;
10
+ color?: PropColor;
11
+ position?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left';
12
+ size?: number;
13
+ ui?: {
14
+ base?: ClassNameValue;
15
+ chip?: ClassNameValue;
16
+ };
17
+ };
18
+ </script>
19
+
20
+ <script lang="ts">
21
+ let {
22
+ children,
23
+ text,
24
+ color = 'primary',
25
+ position = 'top-right',
26
+ size = 8,
27
+ ui = {}
28
+ }: ChipProps = $props();
29
+
30
+ const classes = $derived.by(() =>
31
+ tv({
32
+ slots: {
33
+ base: 'relative inline-flex items-center justify-center shrink-0',
34
+ chip: [
35
+ 'absolute rounded-full ring ring-white flex items-center justify-center text-white font-medium whitespace-nowrap',
36
+ '-translate-y-1/2 translate-x-1/2 px-0.5'
37
+ ]
38
+ },
39
+ variants: {
40
+ color: {
41
+ primary: {
42
+ chip: 'bg-primary'
43
+ },
44
+ surface: {
45
+ chip: 'bg-surface'
46
+ },
47
+ success: {
48
+ chip: 'bg-success'
49
+ },
50
+ info: {
51
+ chip: 'bg-info'
52
+ },
53
+ warning: {
54
+ chip: 'bg-warning'
55
+ },
56
+ error: {
57
+ chip: 'bg-error'
58
+ }
59
+ },
60
+ position: {
61
+ 'top-right': { chip: 'top-0 right-0' },
62
+ 'bottom-right': { chip: 'bottom-0 right-0' },
63
+ 'top-left': { chip: 'top-0 left-0' },
64
+ 'bottom-left': { chip: 'bottom-0 left-0' }
65
+ }
66
+ }
67
+ })({ color, position })
68
+ );
69
+ </script>
70
+
71
+ <div class={classes.base({ class: [ui.base] })}>
72
+ {@render children()}
73
+
74
+ <span
75
+ class={classes.chip({ class: ui.chip })}
76
+ style:height="{size}px"
77
+ style:min-width="{size}px"
78
+ style:font-size="{size}px"
79
+ >
80
+ {text}
81
+ </span>
82
+ </div>