uisv 0.0.14 → 0.0.16

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 (56) hide show
  1. package/dist/components/alert.svelte +8 -2
  2. package/dist/components/alert.svelte.d.ts +2 -2
  3. package/dist/components/badge.svelte +18 -18
  4. package/dist/components/badge.svelte.d.ts +2 -2
  5. package/dist/components/banner.svelte +8 -2
  6. package/dist/components/banner.svelte.d.ts +2 -2
  7. package/dist/components/breadcrumb.svelte +75 -0
  8. package/dist/components/breadcrumb.svelte.d.ts +38 -0
  9. package/dist/components/button.svelte +58 -52
  10. package/dist/components/button.svelte.d.ts +6 -2
  11. package/dist/components/calendar.svelte +99 -0
  12. package/dist/components/calendar.svelte.d.ts +16 -0
  13. package/dist/components/card.svelte +11 -10
  14. package/dist/components/card.svelte.d.ts +2 -1
  15. package/dist/components/checkbox-group.svelte +1 -1
  16. package/dist/components/collapsible.svelte +76 -0
  17. package/dist/components/collapsible.svelte.d.ts +15 -0
  18. package/dist/components/h2.svelte +3 -3
  19. package/dist/components/h4.svelte +2 -2
  20. package/dist/components/h5.svelte +2 -2
  21. package/dist/components/h6.svelte +2 -2
  22. package/dist/components/icon.svelte +58 -0
  23. package/dist/components/icon.svelte.d.ts +8 -0
  24. package/dist/components/index.d.ts +14 -2
  25. package/dist/components/index.js +14 -2
  26. package/dist/components/input-number.svelte +175 -0
  27. package/dist/components/input-number.svelte.d.ts +38 -0
  28. package/dist/components/input-time.svelte +4 -5
  29. package/dist/components/input-time.svelte.d.ts +3 -4
  30. package/dist/components/input.svelte +22 -25
  31. package/dist/components/input.svelte.d.ts +7 -7
  32. package/dist/components/kbd.svelte +35 -35
  33. package/dist/components/kbd.svelte.d.ts +2 -2
  34. package/dist/components/pin-input.svelte +21 -21
  35. package/dist/components/pin-input.svelte.d.ts +2 -2
  36. package/dist/components/placeholder.svelte +1 -1
  37. package/dist/components/progress.svelte +17 -17
  38. package/dist/components/select.svelte +333 -58
  39. package/dist/components/select.svelte.d.ts +32 -2
  40. package/dist/components/seperator.svelte +212 -0
  41. package/dist/components/seperator.svelte.d.ts +22 -0
  42. package/dist/components/slider.svelte +25 -25
  43. package/dist/components/switch.svelte +12 -28
  44. package/dist/components/switch.svelte.d.ts +5 -6
  45. package/dist/components/tabs.svelte +2 -2
  46. package/dist/date.d.ts +1 -0
  47. package/dist/date.js +1 -0
  48. package/dist/index.d.ts +1 -2
  49. package/dist/index.js +1 -1
  50. package/dist/types.d.ts +3 -0
  51. package/dist/types.js +1 -0
  52. package/dist/utilities.svelte.d.ts +9 -2
  53. package/dist/utilities.svelte.js +24 -4
  54. package/dist/vite.d.ts +2 -3
  55. package/dist/vite.js +41 -21
  56. package/package.json +18 -23
@@ -1,7 +1,8 @@
1
1
  <script module lang="ts">
2
- import type { PropColor } from '../index.js';
2
+ import type { PropColor, PropVariant } from '../index.js';
3
3
  import { Select } from 'bits-ui';
4
4
  import type { Component, Snippet } from 'svelte';
5
+ import type { ClassNameValue } from 'tailwind-merge';
5
6
  import { tv } from 'tailwind-variants';
6
7
 
7
8
  export type SelectItem<T> =
@@ -18,9 +19,38 @@
18
19
  item?: Snippet<[{ item: SelectItem<T> }]>;
19
20
  color?: PropColor;
20
21
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
21
- variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
22
+ variant?: Exclude<PropVariant, 'solid'>;
22
23
  highlight?: boolean;
23
24
  placeholder?: string;
25
+ ui?: {
26
+ base?: ClassNameValue;
27
+ leading?: ClassNameValue;
28
+ leadingIcon?: ClassNameValue;
29
+ leadingAvatar?: ClassNameValue;
30
+ leadingAvatarSize?: ClassNameValue;
31
+ trailing?: ClassNameValue;
32
+ trailingIcon?: ClassNameValue;
33
+ value?: ClassNameValue;
34
+ placeholder?: ClassNameValue;
35
+ arrow?: ClassNameValue;
36
+ content?: ClassNameValue;
37
+ viewport?: ClassNameValue;
38
+ group?: ClassNameValue;
39
+ empty?: ClassNameValue;
40
+ label?: ClassNameValue;
41
+ separator?: ClassNameValue;
42
+ item?: ClassNameValue;
43
+ itemLeadingIcon?: ClassNameValue;
44
+ itemLeadingAvatar?: ClassNameValue;
45
+ itemLeadingAvatarSize?: ClassNameValue;
46
+ itemLeadingChip?: ClassNameValue;
47
+ itemLeadingChipSize?: ClassNameValue;
48
+ itemTrailing?: ClassNameValue;
49
+ itemTrailingIcon?: ClassNameValue;
50
+ itemWrapper?: ClassNameValue;
51
+ itemLabel?: ClassNameValue;
52
+ itemDescription?: ClassNameValue;
53
+ };
24
54
  } & (
25
55
  | {
26
56
  value?: T;
@@ -45,86 +75,324 @@
45
75
  variant = 'outline',
46
76
  highlight,
47
77
  placeholder,
78
+ ui = {},
48
79
  }: SelectProps<T> = $props();
49
80
 
50
81
  const classes = $derived(
51
82
  tv({
52
83
  slots: {
53
- trigger: 'transition-all rounded w-48 flex items-center justify-between',
84
+ base: [
85
+ 'relative group rounded-md inline-flex items-center focus:outline-none disabled:cursor-not-allowed disabled:opacity-75',
86
+ 'transition-colors',
87
+ ],
88
+ leading: 'absolute inset-y-0 start-0 flex items-center',
89
+ leadingIcon: 'shrink-0 text-dimmed',
90
+ leadingAvatar: 'shrink-0',
91
+ leadingAvatarSize: '',
92
+ trailing: 'absolute inset-y-0 end-0 flex items-center',
93
+ trailingIcon: 'shrink-0 text-dimmed',
94
+ value: 'truncate pointer-events-none',
95
+ placeholder: 'truncate text-dimmed',
96
+ arrow: 'fill-bg stroke-default',
97
+ content:
98
+ 'max-h-60 w-(--bits-select-anchor-width) bg-inverted shadow-lg rounded-md ring ring-surface-accented overflow-hidden data-[state=open]:animate-[scale-in_100ms_ease-out] data-[state=closed]:animate-[scale-out_100ms_ease-in] origin-(--bits-select-content-transform-origin) pointer-events-auto flex flex-col',
99
+ viewport: 'relative divide-y divide-base scroll-py-1 overflow-y-auto flex-1',
100
+ group: 'p-1 isolate',
101
+ empty: 'text-center text-muted',
102
+ label: 'font-semibold text-highlighted',
103
+ separator: '-mx-1 my-1 h-px bg-border',
104
+ item: [
105
+ 'group relative w-full flex items-start select-none outline-none before:absolute before:content-[""] before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-[data-disabled]:before:bg-surface-elevated/50',
106
+ 'transition-colors before:transition-colors',
107
+ ],
108
+ itemLeadingIcon: [
109
+ 'shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default',
110
+ 'transition-colors',
111
+ ],
112
+ itemLeadingAvatar: 'shrink-0',
113
+ itemLeadingAvatarSize: '',
114
+ itemLeadingChip: 'shrink-0',
115
+ itemLeadingChipSize: '',
116
+ itemTrailing: 'ms-auto inline-flex gap-1.5 items-center',
117
+ itemTrailingIcon: 'shrink-0',
118
+ itemWrapper: 'flex-1 flex flex-col min-w-0',
119
+ itemLabel: 'truncate',
120
+ itemDescription: 'truncate text-muted',
54
121
  },
55
122
  variants: {
56
- color: {
57
- primary: {
58
- trigger: 'outline-primary focus:(border-primary)',
59
- },
60
- surface: {
61
- trigger: 'outline-surface focus:(border-surface)',
62
- },
63
- info: {
64
- trigger: 'outline-info focus:(border-info)',
65
- },
66
- success: {
67
- trigger: 'outline-success focus:(border-success)',
68
- },
69
- warning: {
70
- trigger: 'outline-warning focus:(border-warning)',
71
- },
72
- error: {
73
- trigger: 'outline-error focus:(border-error)',
74
- },
123
+ fieldGroup: {
124
+ horizontal:
125
+ 'not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]',
126
+ vertical:
127
+ 'not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]',
75
128
  },
76
129
  size: {
77
130
  xs: {
78
- trigger: 'h-6 px-1 text-xs gap-1',
131
+ base: 'px-2 py-1 text-xs gap-1',
132
+ leading: 'ps-2',
133
+ trailing: 'pe-2',
134
+ leadingIcon: 'size-4',
135
+ leadingAvatarSize: '3xs',
136
+ trailingIcon: 'size-4',
137
+ label: 'p-1 text-[10px]/3 gap-1',
138
+ item: 'p-1 text-xs gap-1',
139
+ itemLeadingIcon: 'size-4',
140
+ itemLeadingAvatarSize: '3xs',
141
+ itemLeadingChip: 'size-4',
142
+ itemLeadingChipSize: 'sm',
143
+ itemTrailingIcon: 'size-4',
144
+ empty: 'p-2 text-xs',
79
145
  },
80
146
  sm: {
81
- trigger: 'h-7 px-2 text-xs gap-1',
147
+ base: 'px-2.5 py-1.5 text-xs gap-1.5',
148
+ leading: 'ps-2.5',
149
+ trailing: 'pe-2.5',
150
+ leadingIcon: 'size-4',
151
+ leadingAvatarSize: '3xs',
152
+ trailingIcon: 'size-4',
153
+ label: 'p-1.5 text-[10px]/3 gap-1.5',
154
+ item: 'p-1.5 text-xs gap-1.5',
155
+ itemLeadingIcon: 'size-4',
156
+ itemLeadingAvatarSize: '3xs',
157
+ itemLeadingChip: 'size-4',
158
+ itemLeadingChipSize: 'sm',
159
+ itemTrailingIcon: 'size-4',
160
+ empty: 'p-2.5 text-xs',
82
161
  },
83
162
  md: {
84
- trigger: 'h-8 px-2 text-sm gap-2 ',
163
+ base: 'px-2.5 py-1.5 text-sm gap-1.5',
164
+ leading: 'ps-2.5',
165
+ trailing: 'pe-2.5',
166
+ leadingIcon: 'size-5',
167
+ leadingAvatarSize: '2xs',
168
+ trailingIcon: 'size-5',
169
+ label: 'p-1.5 text-xs gap-1.5',
170
+ item: 'p-1.5 text-sm gap-1.5',
171
+ itemLeadingIcon: 'size-5',
172
+ itemLeadingAvatarSize: '2xs',
173
+ itemLeadingChip: 'size-5',
174
+ itemLeadingChipSize: 'md',
175
+ itemTrailingIcon: 'size-5',
176
+ empty: 'p-2.5 text-sm',
85
177
  },
86
178
  lg: {
87
- trigger: 'h-9 px-3 text-sm gap-3',
179
+ base: 'px-3 py-2 text-sm gap-2',
180
+ leading: 'ps-3',
181
+ trailing: 'pe-3',
182
+ leadingIcon: 'size-5',
183
+ leadingAvatarSize: '2xs',
184
+ trailingIcon: 'size-5',
185
+ label: 'p-2 text-xs gap-2',
186
+ item: 'p-2 text-sm gap-2',
187
+ itemLeadingIcon: 'size-5',
188
+ itemLeadingAvatarSize: '2xs',
189
+ itemLeadingChip: 'size-5',
190
+ itemLeadingChipSize: 'md',
191
+ itemTrailingIcon: 'size-5',
192
+ empty: 'p-3 text-sm',
88
193
  },
89
194
  xl: {
90
- trigger: 'h-10 px-3 gap-4',
195
+ base: 'px-3 py-2 text-base gap-2',
196
+ leading: 'ps-3',
197
+ trailing: 'pe-3',
198
+ leadingIcon: 'size-6',
199
+ leadingAvatarSize: 'xs',
200
+ trailingIcon: 'size-6',
201
+ label: 'p-2 text-sm gap-2',
202
+ item: 'p-2 text-base gap-2',
203
+ itemLeadingIcon: 'size-6',
204
+ itemLeadingAvatarSize: 'xs',
205
+ itemLeadingChip: 'size-6',
206
+ itemLeadingChipSize: 'lg',
207
+ itemTrailingIcon: 'size-6',
208
+ empty: 'p-3 text-base',
91
209
  },
92
210
  },
93
211
  variant: {
94
- outline: {
95
- trigger: 'border border-surface-accented focus:(outline)',
96
- },
97
- soft: {
98
- trigger: 'bg-surface-elevated',
99
- },
100
- subtle: {
101
- trigger: 'bg-surface-elevated border border-surface-accented focus:(outline)',
102
- },
103
- ghost: {
104
- trigger: 'hover:bg-surface-elevated',
105
- },
106
- none: {},
212
+ outline:
213
+ 'text-highlighted bg-default ring ring-inset ring-surface-accented hover:bg-surface-elevated disabled:bg-surface-default',
214
+ soft: 'text-highlighted bg-surface-elevated/50 hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-surface-elevated/50',
215
+ subtle:
216
+ 'text-highlighted bg-surface-elevated ring ring-inset ring-accented hover:bg-surface-accented/75 disabled:bg-surface-elevated',
217
+ ghost:
218
+ 'text-highlighted bg-transparent hover:bg-surface-elevated focus:bg-surface-elevated disabled:bg-transparent dark:disabled:bg-transparent',
219
+ none: 'text-highlighted bg-transparent',
220
+ },
221
+ color: {
222
+ primary: '',
223
+ surface: '',
224
+ success: '',
225
+ info: '',
226
+ warning: '',
227
+ error: '',
228
+ },
229
+ leading: {
230
+ true: '',
231
+ },
232
+ trailing: {
233
+ true: '',
107
234
  },
108
- placeholder: {
109
- true: { trigger: 'text-muted' },
110
- false: {},
235
+ loading: {
236
+ true: '',
111
237
  },
112
238
  highlight: {
113
- true: {
114
- trigger: 'border',
115
- },
116
- false: {},
239
+ true: '',
240
+ },
241
+ fixed: {
242
+ false: '',
243
+ },
244
+ type: {
245
+ file: 'file:me-1.5 file:font-medium file:text-muted file:outline-none',
117
246
  },
118
247
  },
119
248
  compoundVariants: [
120
- { color: 'primary', highlight: true, class: { trigger: 'border-primary-500' } },
121
- { color: 'surface', highlight: true, class: { trigger: 'border-surface-500' } },
122
- { color: 'info', highlight: true, class: { trigger: 'border-info-500' } },
123
- { color: 'success', highlight: true, class: { trigger: 'border-success-500' } },
124
- { color: 'warning', highlight: true, class: { trigger: 'border-warning-500' } },
125
- { color: 'error', highlight: true, class: { trigger: 'border-error-500' } },
249
+ {
250
+ color: 'primary',
251
+ variant: ['outline', 'subtle'],
252
+ class: 'focus:ring-2 focus:ring-inset focus:ring-primary',
253
+ },
254
+ {
255
+ color: 'primary',
256
+ highlight: true,
257
+ class: 'ring ring-inset ring-primary',
258
+ },
259
+ {
260
+ color: 'surface',
261
+ variant: ['outline', 'subtle'],
262
+ class: 'focus:ring-2 focus:ring-inset focus:ring-surface-inverted',
263
+ },
264
+ {
265
+ color: 'surface',
266
+ highlight: true,
267
+ class: 'ring ring-inset ring-surface-inverted',
268
+ },
269
+ {
270
+ color: 'error',
271
+ variant: ['outline', 'subtle'],
272
+ class: 'focus:ring-2 focus:ring-inset focus:ring-error',
273
+ },
274
+ {
275
+ color: 'error',
276
+ highlight: true,
277
+ class: 'ring ring-inset ring-error',
278
+ },
279
+ {
280
+ color: 'info',
281
+ variant: ['outline', 'subtle'],
282
+ class: 'focus:ring-2 focus:ring-inset focus:ring-info',
283
+ },
284
+ {
285
+ color: 'info',
286
+ highlight: true,
287
+ class: 'ring ring-inset ring-info',
288
+ },
289
+ {
290
+ color: 'success',
291
+ variant: ['outline', 'subtle'],
292
+ class: 'focus:ring-2 focus:ring-inset focus:ring-success',
293
+ },
294
+ {
295
+ color: 'success',
296
+ highlight: true,
297
+ class: 'ring ring-inset ring-success',
298
+ },
299
+ {
300
+ color: 'warning',
301
+ variant: ['outline', 'subtle'],
302
+ class: 'focus:ring-2 focus:ring-inset focus:ring-warning',
303
+ },
304
+ {
305
+ color: 'warning',
306
+ highlight: true,
307
+ class: 'ring ring-inset ring-warning',
308
+ },
309
+ {
310
+ leading: true,
311
+ size: 'xs',
312
+ class: 'ps-7',
313
+ },
314
+ {
315
+ leading: true,
316
+ size: 'sm',
317
+ class: 'ps-8',
318
+ },
319
+ {
320
+ leading: true,
321
+ size: 'md',
322
+ class: 'ps-9',
323
+ },
324
+ {
325
+ leading: true,
326
+ size: 'lg',
327
+ class: 'ps-10',
328
+ },
329
+ {
330
+ leading: true,
331
+ size: 'xl',
332
+ class: 'ps-11',
333
+ },
334
+ {
335
+ trailing: true,
336
+ size: 'xs',
337
+ class: 'pe-7',
338
+ },
339
+ {
340
+ trailing: true,
341
+ size: 'sm',
342
+ class: 'pe-8',
343
+ },
344
+ {
345
+ trailing: true,
346
+ size: 'md',
347
+ class: 'pe-9',
348
+ },
349
+ {
350
+ trailing: true,
351
+ size: 'lg',
352
+ class: 'pe-10',
353
+ },
354
+ {
355
+ trailing: true,
356
+ size: 'xl',
357
+ class: 'pe-11',
358
+ },
359
+ {
360
+ loading: true,
361
+ leading: true,
362
+ class: {
363
+ leadingIcon: 'animate-spin',
364
+ },
365
+ },
366
+ {
367
+ loading: true,
368
+ leading: false,
369
+ trailing: true,
370
+ class: {
371
+ trailingIcon: 'animate-spin',
372
+ },
373
+ },
374
+ {
375
+ fixed: false,
376
+ size: 'xs',
377
+ class: 'md:text-xs',
378
+ },
379
+ {
380
+ fixed: false,
381
+ size: 'sm',
382
+ class: 'md:text-xs',
383
+ },
384
+ {
385
+ fixed: false,
386
+ size: 'md',
387
+ class: 'md:text-sm',
388
+ },
389
+ {
390
+ fixed: false,
391
+ size: 'lg',
392
+ class: 'md:text-sm',
393
+ },
126
394
  ],
127
- })({ size, color, variant, placeholder: !!placeholder, highlight }),
395
+ })({ size, color, variant, highlight }),
128
396
  );
129
397
  </script>
130
398
 
@@ -139,12 +407,16 @@
139
407
  (v) => (value = v as T | T[] | undefined)
140
408
  }
141
409
  >
142
- <Select.Trigger class={classes.trigger()}>
410
+ <Select.Trigger class={classes.base({ class: ui.base })}>
143
411
  {value || placeholder}
144
412
  <div class="i-lucide-chevron-down size-4"></div>
145
413
  </Select.Trigger>
146
414
  <Select.Portal>
147
- <Select.Content class="bg-red">
415
+ <Select.Content
416
+ class={classes.content({ class: ui.content })}
417
+ preventScroll={true}
418
+ sideOffset={8}
419
+ >
148
420
  <Select.ScrollUpButton />
149
421
  <Select.Viewport>
150
422
  {#each items as item, idx (idx)}
@@ -153,12 +425,15 @@
153
425
  <Select.GroupHeading />
154
426
 
155
427
  {#each item as group_item, gidx (gidx)}
156
- <Select.Item value=""></Select.Item>
428
+ <Select.Item class={classes.item({ class: ui.item })} value=""></Select.Item>
157
429
  {/each}
158
430
  </Select.Group>
159
431
  {:else}
160
432
  {@const is_object = typeof item === 'object' && item !== null && 'value' in item}
161
- <Select.Item value={(is_object ? item.value : item) as string}>
433
+ <Select.Item
434
+ class={classes.item({ class: ui.item })}
435
+ value={(is_object ? item.value : item) as string}
436
+ >
162
437
  {item}
163
438
  </Select.Item>
164
439
  {/if}
@@ -1,6 +1,7 @@
1
- import type { PropColor } from '../index.js';
1
+ import type { PropColor, PropVariant } from '../index.js';
2
2
  import { Select } from 'bits-ui';
3
3
  import type { Component, Snippet } from 'svelte';
4
+ import type { ClassNameValue } from 'tailwind-merge';
4
5
  export type SelectItem<T> = T | {
5
6
  icon?: string | Component;
6
7
  label: string | Component;
@@ -14,9 +15,38 @@ export type SelectProps<T> = {
14
15
  }]>;
15
16
  color?: PropColor;
16
17
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
17
- variant?: 'outline' | 'soft' | 'subtle' | 'ghost' | 'none';
18
+ variant?: Exclude<PropVariant, 'solid'>;
18
19
  highlight?: boolean;
19
20
  placeholder?: string;
21
+ ui?: {
22
+ base?: ClassNameValue;
23
+ leading?: ClassNameValue;
24
+ leadingIcon?: ClassNameValue;
25
+ leadingAvatar?: ClassNameValue;
26
+ leadingAvatarSize?: ClassNameValue;
27
+ trailing?: ClassNameValue;
28
+ trailingIcon?: ClassNameValue;
29
+ value?: ClassNameValue;
30
+ placeholder?: ClassNameValue;
31
+ arrow?: ClassNameValue;
32
+ content?: ClassNameValue;
33
+ viewport?: ClassNameValue;
34
+ group?: ClassNameValue;
35
+ empty?: ClassNameValue;
36
+ label?: ClassNameValue;
37
+ separator?: ClassNameValue;
38
+ item?: ClassNameValue;
39
+ itemLeadingIcon?: ClassNameValue;
40
+ itemLeadingAvatar?: ClassNameValue;
41
+ itemLeadingAvatarSize?: ClassNameValue;
42
+ itemLeadingChip?: ClassNameValue;
43
+ itemLeadingChipSize?: ClassNameValue;
44
+ itemTrailing?: ClassNameValue;
45
+ itemTrailingIcon?: ClassNameValue;
46
+ itemWrapper?: ClassNameValue;
47
+ itemLabel?: ClassNameValue;
48
+ itemDescription?: ClassNameValue;
49
+ };
20
50
  } & ({
21
51
  value?: T;
22
52
  type?: 'single';