sv5ui 1.1.2 → 1.2.0

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 (155) hide show
  1. package/README.md +6 -0
  2. package/dist/Alert/Alert.svelte +33 -22
  3. package/dist/Alert/Alert.svelte.d.ts +1 -1
  4. package/dist/Alert/alert.types.d.ts +4 -0
  5. package/dist/Avatar/Avatar.svelte +72 -46
  6. package/dist/Avatar/avatar.types.d.ts +36 -3
  7. package/dist/Avatar/avatar.variants.d.ts +138 -0
  8. package/dist/Avatar/avatar.variants.js +23 -12
  9. package/dist/Avatar/index.d.ts +1 -1
  10. package/dist/AvatarGroup/AvatarGroup.svelte +11 -6
  11. package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
  12. package/dist/AvatarGroup/avatar-group.types.d.ts +18 -3
  13. package/dist/AvatarGroup/avatar-group.variants.d.ts +85 -0
  14. package/dist/AvatarGroup/avatar-group.variants.js +19 -29
  15. package/dist/Badge/Badge.svelte +4 -3
  16. package/dist/Badge/Badge.svelte.d.ts +1 -1
  17. package/dist/Badge/badge.types.d.ts +9 -0
  18. package/dist/Breadcrumb/Breadcrumb.svelte +20 -7
  19. package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +1 -1
  20. package/dist/Breadcrumb/breadcrumb.types.d.ts +5 -1
  21. package/dist/Breadcrumb/breadcrumb.variants.d.ts +15 -5
  22. package/dist/Breadcrumb/breadcrumb.variants.js +7 -3
  23. package/dist/Button/Button.svelte +71 -16
  24. package/dist/Button/Button.svelte.d.ts +0 -1
  25. package/dist/Button/button.types.d.ts +61 -2
  26. package/dist/Calendar/Calendar.svelte +4 -0
  27. package/dist/Calendar/Calendar.svelte.d.ts +1 -1
  28. package/dist/Calendar/calendar.types.d.ts +4 -0
  29. package/dist/Card/Card.svelte +5 -4
  30. package/dist/Card/Card.svelte.d.ts +1 -1
  31. package/dist/Card/card.types.d.ts +5 -1
  32. package/dist/Checkbox/Checkbox.svelte +37 -11
  33. package/dist/Checkbox/Checkbox.svelte.d.ts +1 -1
  34. package/dist/Checkbox/checkbox.types.d.ts +16 -1
  35. package/dist/Checkbox/checkbox.variants.d.ts +90 -0
  36. package/dist/Checkbox/checkbox.variants.js +73 -4
  37. package/dist/Chip/Chip.svelte +3 -2
  38. package/dist/Chip/Chip.svelte.d.ts +1 -1
  39. package/dist/Chip/chip.types.d.ts +5 -1
  40. package/dist/Chip/chip.variants.d.ts +135 -45
  41. package/dist/Chip/chip.variants.js +9 -9
  42. package/dist/ContextMenu/ContextMenu.svelte +87 -77
  43. package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
  44. package/dist/ContextMenu/context-menu.types.d.ts +9 -3
  45. package/dist/ContextMenu/context-menu.types.js +1 -1
  46. package/dist/ContextMenu/context-menu.variants.d.ts +74 -160
  47. package/dist/ContextMenu/context-menu.variants.js +63 -95
  48. package/dist/DropdownMenu/DropdownMenu.svelte +37 -43
  49. package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
  50. package/dist/DropdownMenu/dropdown-menu.types.d.ts +9 -3
  51. package/dist/DropdownMenu/dropdown-menu.types.js +1 -1
  52. package/dist/DropdownMenu/dropdown-menu.variants.d.ts +79 -230
  53. package/dist/DropdownMenu/dropdown-menu.variants.js +68 -111
  54. package/dist/DropdownMenu/index.d.ts +1 -1
  55. package/dist/Empty/Empty.svelte +68 -33
  56. package/dist/Empty/Empty.svelte.d.ts +1 -1
  57. package/dist/Empty/empty.types.d.ts +26 -9
  58. package/dist/Empty/empty.variants.d.ts +150 -130
  59. package/dist/Empty/empty.variants.js +33 -324
  60. package/dist/FieldGroup/FieldGroup.svelte +11 -6
  61. package/dist/FieldGroup/FieldGroup.svelte.d.ts +1 -1
  62. package/dist/FieldGroup/field-group.types.d.ts +4 -0
  63. package/dist/FormField/FormField.svelte +17 -18
  64. package/dist/FormField/FormField.svelte.d.ts +1 -1
  65. package/dist/FormField/form-field.types.d.ts +4 -0
  66. package/dist/Icon/Icon.svelte +13 -7
  67. package/dist/Icon/icon.types.d.ts +18 -9
  68. package/dist/Input/Input.svelte +30 -29
  69. package/dist/Kbd/Kbd.svelte +13 -3
  70. package/dist/Kbd/Kbd.svelte.d.ts +1 -1
  71. package/dist/Kbd/index.d.ts +1 -1
  72. package/dist/Kbd/kbd.types.d.ts +15 -1
  73. package/dist/Kbd/kbd.variants.d.ts +92 -30
  74. package/dist/Kbd/kbd.variants.js +55 -35
  75. package/dist/Kbd/useKbd.svelte.d.ts +2 -2
  76. package/dist/Kbd/useKbd.svelte.js +34 -41
  77. package/dist/Link/Link.svelte +69 -24
  78. package/dist/Link/Link.svelte.d.ts +1 -1
  79. package/dist/Link/link.types.d.ts +26 -8
  80. package/dist/Link/link.variants.d.ts +35 -60
  81. package/dist/Link/link.variants.js +8 -110
  82. package/dist/Modal/Modal.svelte +9 -1
  83. package/dist/Modal/modal.types.d.ts +5 -0
  84. package/dist/Modal/modal.variants.d.ts +5 -0
  85. package/dist/Modal/modal.variants.js +1 -0
  86. package/dist/Pagination/Pagination.svelte +143 -94
  87. package/dist/Pagination/Pagination.svelte.d.ts +1 -1
  88. package/dist/Pagination/index.d.ts +1 -1
  89. package/dist/Pagination/pagination.types.d.ts +21 -2
  90. package/dist/Pagination/pagination.variants.d.ts +21 -387
  91. package/dist/Pagination/pagination.variants.js +63 -59
  92. package/dist/Popover/Popover.svelte +9 -12
  93. package/dist/Popover/Popover.svelte.d.ts +1 -1
  94. package/dist/Popover/popover.types.d.ts +4 -0
  95. package/dist/Popover/popover.variants.d.ts +5 -75
  96. package/dist/Popover/popover.variants.js +6 -16
  97. package/dist/Progress/Progress.svelte +58 -30
  98. package/dist/Progress/progress.types.d.ts +9 -1
  99. package/dist/Progress/progress.variants.d.ts +55 -25
  100. package/dist/Progress/progress.variants.js +34 -28
  101. package/dist/RadioGroup/RadioGroup.svelte +105 -61
  102. package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
  103. package/dist/RadioGroup/radio-group.types.d.ts +16 -1
  104. package/dist/RadioGroup/radio-group.variants.d.ts +90 -0
  105. package/dist/RadioGroup/radio-group.variants.js +73 -4
  106. package/dist/Select/Select.svelte +9 -6
  107. package/dist/Select/Select.svelte.d.ts +1 -1
  108. package/dist/Select/select.types.d.ts +4 -0
  109. package/dist/SelectMenu/SelectMenu.svelte +436 -0
  110. package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
  111. package/dist/SelectMenu/index.d.ts +2 -0
  112. package/dist/SelectMenu/index.js +1 -0
  113. package/dist/SelectMenu/select-menu.types.d.ts +262 -0
  114. package/dist/SelectMenu/select-menu.types.js +1 -0
  115. package/dist/SelectMenu/select-menu.variants.d.ts +759 -0
  116. package/dist/SelectMenu/select-menu.variants.js +33 -0
  117. package/dist/Separator/Separator.svelte +1 -2
  118. package/dist/Separator/separator.variants.d.ts +1 -5
  119. package/dist/Separator/separator.variants.js +2 -2
  120. package/dist/Skeleton/Skeleton.svelte +18 -2
  121. package/dist/Skeleton/Skeleton.svelte.d.ts +1 -1
  122. package/dist/Skeleton/skeleton.types.d.ts +10 -1
  123. package/dist/Slideover/Slideover.svelte +9 -1
  124. package/dist/Slideover/slideover.types.d.ts +5 -0
  125. package/dist/Slideover/slideover.variants.d.ts +20 -5
  126. package/dist/Slideover/slideover.variants.js +4 -29
  127. package/dist/Switch/Switch.svelte +32 -31
  128. package/dist/Switch/Switch.svelte.d.ts +1 -1
  129. package/dist/Switch/switch.types.d.ts +6 -1
  130. package/dist/Switch/switch.variants.js +6 -6
  131. package/dist/Tabs/Tabs.svelte +6 -9
  132. package/dist/Tabs/Tabs.svelte.d.ts +1 -1
  133. package/dist/Tabs/tabs.types.d.ts +4 -0
  134. package/dist/Tabs/tabs.variants.js +2 -0
  135. package/dist/Textarea/Textarea.svelte +26 -25
  136. package/dist/ThemeModeButton/theme-mode-button.types.d.ts +7 -2
  137. package/dist/Timeline/Timeline.svelte +62 -19
  138. package/dist/Timeline/Timeline.svelte.d.ts +1 -1
  139. package/dist/Timeline/index.d.ts +1 -1
  140. package/dist/Timeline/timeline.types.d.ts +8 -0
  141. package/dist/Tooltip/Tooltip.svelte +12 -10
  142. package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
  143. package/dist/Tooltip/tooltip.types.d.ts +8 -4
  144. package/dist/Tooltip/tooltip.variants.d.ts +10 -75
  145. package/dist/Tooltip/tooltip.variants.js +8 -17
  146. package/dist/User/User.svelte +13 -9
  147. package/dist/User/User.svelte.d.ts +1 -1
  148. package/dist/User/user.types.d.ts +4 -0
  149. package/dist/User/user.variants.d.ts +60 -0
  150. package/dist/User/user.variants.js +13 -1
  151. package/dist/config.d.ts +4 -0
  152. package/dist/config.js +4 -0
  153. package/dist/index.d.ts +1 -1
  154. package/dist/index.js +1 -1
  155. package/package.json +2 -2
@@ -1,27 +1,38 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
  export const avatarVariants = tv({
3
3
  slots: {
4
- root: 'inline-flex items-center justify-center shrink-0 select-none rounded-full align-middle overflow-hidden bg-surface-container-highest',
4
+ root: 'inline-flex items-center justify-center shrink-0 select-none align-middle bg-surface-container-highest',
5
5
  image: 'h-full w-full rounded-[inherit] object-cover',
6
- fallback: 'font-medium leading-none truncate text-on-surface-variant'
6
+ fallback: 'font-medium leading-none truncate text-on-surface-variant',
7
+ icon: 'text-on-surface-variant'
7
8
  },
8
9
  variants: {
9
10
  size: {
10
- '3xs': { root: 'size-4 text-[8px]' },
11
- '2xs': { root: 'size-5 text-[10px]' },
12
- xs: { root: 'size-6 text-xs' },
13
- sm: { root: 'size-7 text-sm' },
14
- md: { root: 'size-8 text-base' },
15
- lg: { root: 'size-9 text-lg' },
16
- xl: { root: 'size-10 text-xl' },
17
- '2xl': { root: 'size-11 text-[22px]' },
18
- '3xl': { root: 'size-12 text-2xl' }
11
+ '3xs': { root: 'size-4 text-[8px]', icon: 'size-2.5' },
12
+ '2xs': { root: 'size-5 text-[10px]', icon: 'size-3' },
13
+ xs: { root: 'size-6 text-xs', icon: 'size-3.5' },
14
+ sm: { root: 'size-7 text-sm', icon: 'size-4' },
15
+ md: { root: 'size-8 text-base', icon: 'size-5' },
16
+ lg: { root: 'size-9 text-lg', icon: 'size-5' },
17
+ xl: { root: 'size-10 text-xl', icon: 'size-6' },
18
+ '2xl': { root: 'size-11 text-[22px]', icon: 'size-7' },
19
+ '3xl': { root: 'size-12 text-2xl', icon: 'size-8' }
20
+ },
21
+ rounded: {
22
+ full: { root: 'rounded-full' },
23
+ lg: { root: 'rounded-lg' },
24
+ md: { root: 'rounded-md' },
25
+ sm: { root: 'rounded-sm' },
26
+ none: { root: 'rounded-none' }
19
27
  }
20
28
  },
21
29
  defaultVariants: {
22
- size: 'md'
30
+ size: 'md',
31
+ rounded: 'full'
23
32
  }
24
33
  });
34
+ /** Tailwind size-4 through size-12 → (4 + index) × 4 pixels */
35
+ export const avatarSizePx = Object.fromEntries(Object.keys(avatarVariants.variants.size).map((key, i) => [key, (4 + i) * 4]));
25
36
  export const avatarDefaults = {
26
37
  defaultVariants: avatarVariants.defaultVariants,
27
38
  slots: {}
@@ -1,2 +1,2 @@
1
1
  export { default as Avatar } from './Avatar.svelte';
2
- export type { AvatarProps } from './avatar.types.js';
2
+ export type { AvatarProps, AvatarSize } from './avatar.types.js';
@@ -9,14 +9,16 @@
9
9
  import { getComponentConfig } from '../config.js'
10
10
  import { setContext } from 'svelte'
11
11
  import Avatar from '../Avatar/Avatar.svelte'
12
- import type { AvatarSize } from '../Avatar/avatar.types.js'
12
+ import type { AvatarSize, AvatarRounded } from '../Avatar/avatar.types.js'
13
13
 
14
14
  const config = getComponentConfig('avatarGroup', avatarGroupDefaults)
15
15
 
16
16
  let {
17
+ ref = $bindable(null),
17
18
  as = 'div',
18
19
  ui,
19
20
  size = config.defaultVariants.size ?? 'md',
21
+ rounded = config.defaultVariants.rounded ?? 'full',
20
22
  avatars,
21
23
  max,
22
24
  class: className,
@@ -25,24 +27,27 @@
25
27
  }: Props = $props()
26
28
 
27
29
  const classes = $derived.by(() => {
28
- const slots = avatarGroupVariants({ size })
30
+ const slots = avatarGroupVariants({ size, rounded })
29
31
  return {
30
32
  root: slots.root({ class: [config.slots.root, className, ui?.root] }),
31
33
  base: slots.base({ class: [config.slots.base, ui?.base] })
32
34
  }
33
35
  })
34
36
 
35
- setContext<{ size: AvatarSize; baseClass: string }>('avatarGroup', {
37
+ setContext<{ size: AvatarSize; rounded: AvatarRounded; baseClass: string }>('avatarGroup', {
36
38
  get size() {
37
39
  return size
38
40
  },
41
+ get rounded() {
42
+ return rounded
43
+ },
39
44
  get baseClass() {
40
45
  return classes.base
41
46
  }
42
47
  })
43
48
 
44
49
  const visibleAvatars = $derived(
45
- !avatars ? [] : max && max > 0 && avatars.length > max ? avatars.slice(0, max) : avatars
50
+ !avatars ? [] : max && max > 0 ? avatars.slice(0, max) : avatars
46
51
  )
47
52
 
48
53
  const overflowCount = $derived(
@@ -50,12 +55,12 @@
50
55
  )
51
56
  </script>
52
57
 
53
- <svelte:element this={as} class={classes.root} {...restProps}>
58
+ <svelte:element this={as} bind:this={ref} class={classes.root} {...restProps}>
54
59
  {#if avatars}
55
60
  {#if overflowCount > 0}
56
61
  <Avatar text={`+${overflowCount}`} />
57
62
  {/if}
58
- {#each visibleAvatars as avatar, index (avatar.src ?? index)}
63
+ {#each visibleAvatars as avatar, index (index)}
59
64
  <Avatar {...avatar} />
60
65
  {/each}
61
66
  {:else if children}
@@ -1,5 +1,5 @@
1
1
  import type { AvatarGroupProps } from './avatar-group.types.js';
2
2
  export type Props = AvatarGroupProps;
3
- declare const AvatarGroup: import("svelte").Component<AvatarGroupProps, {}, "">;
3
+ declare const AvatarGroup: import("svelte").Component<AvatarGroupProps, {}, "ref">;
4
4
  type AvatarGroup = ReturnType<typeof AvatarGroup>;
5
5
  export default AvatarGroup;
@@ -1,8 +1,13 @@
1
+ import type { Snippet } from 'svelte';
1
2
  import type { HTMLAttributes } from 'svelte/elements';
2
3
  import type { ClassNameValue } from 'tailwind-merge';
3
4
  import type { AvatarGroupSlots } from './avatar-group.variants.js';
4
- import type { AvatarProps, AvatarSize } from '../Avatar/avatar.types.js';
5
- export type AvatarGroupProps = HTMLAttributes<HTMLDivElement> & {
5
+ import type { AvatarProps, AvatarSize, AvatarRounded } from '../Avatar/avatar.types.js';
6
+ export type AvatarGroupProps = Omit<HTMLAttributes<HTMLDivElement>, 'class'> & {
7
+ /**
8
+ * Bindable reference to the root DOM element.
9
+ */
10
+ ref?: HTMLElement | null;
6
11
  /**
7
12
  * The HTML element to render as.
8
13
  * @default 'div'
@@ -13,11 +18,16 @@ export type AvatarGroupProps = HTMLAttributes<HTMLDivElement> & {
13
18
  * @default 'md'
14
19
  */
15
20
  size?: AvatarSize;
21
+ /**
22
+ * Controls the border radius of all avatars in the group.
23
+ * @default 'full'
24
+ */
25
+ rounded?: AvatarRounded;
16
26
  /**
17
27
  * Array of avatar props to render.
18
28
  * Use with `max` to limit visible count.
19
29
  */
20
- avatars?: Omit<AvatarProps, 'size' | 'children'>[];
30
+ avatars?: Omit<AvatarProps, 'size' | 'rounded' | 'children'>[];
21
31
  /**
22
32
  * Maximum visible avatars.
23
33
  * Excess displayed as a "+N" indicator.
@@ -31,4 +41,9 @@ export type AvatarGroupProps = HTMLAttributes<HTMLDivElement> & {
31
41
  * Override styles for specific avatar group slots.
32
42
  */
33
43
  ui?: Partial<Record<AvatarGroupSlots, ClassNameValue>>;
44
+ /**
45
+ * Custom content to render inside the group.
46
+ * When provided, overrides the `avatars` prop.
47
+ */
48
+ children?: Snippet;
34
49
  };
@@ -29,6 +29,23 @@ export declare const avatarGroupVariants: import("tailwind-variants").TVReturnTy
29
29
  base: string;
30
30
  };
31
31
  };
32
+ rounded: {
33
+ full: {
34
+ base: string;
35
+ };
36
+ lg: {
37
+ base: string;
38
+ };
39
+ md: {
40
+ base: string;
41
+ };
42
+ sm: {
43
+ base: string;
44
+ };
45
+ none: {
46
+ base: string;
47
+ };
48
+ };
32
49
  }, {
33
50
  root: string;
34
51
  base: string;
@@ -62,6 +79,23 @@ export declare const avatarGroupVariants: import("tailwind-variants").TVReturnTy
62
79
  base: string;
63
80
  };
64
81
  };
82
+ rounded: {
83
+ full: {
84
+ base: string;
85
+ };
86
+ lg: {
87
+ base: string;
88
+ };
89
+ md: {
90
+ base: string;
91
+ };
92
+ sm: {
93
+ base: string;
94
+ };
95
+ none: {
96
+ base: string;
97
+ };
98
+ };
65
99
  }, {
66
100
  root: string;
67
101
  base: string;
@@ -95,6 +129,23 @@ export declare const avatarGroupVariants: import("tailwind-variants").TVReturnTy
95
129
  base: string;
96
130
  };
97
131
  };
132
+ rounded: {
133
+ full: {
134
+ base: string;
135
+ };
136
+ lg: {
137
+ base: string;
138
+ };
139
+ md: {
140
+ base: string;
141
+ };
142
+ sm: {
143
+ base: string;
144
+ };
145
+ none: {
146
+ base: string;
147
+ };
148
+ };
98
149
  }, {
99
150
  root: string;
100
151
  base: string;
@@ -132,6 +183,23 @@ export declare const avatarGroupDefaults: {
132
183
  base: string;
133
184
  };
134
185
  };
186
+ rounded: {
187
+ full: {
188
+ base: string;
189
+ };
190
+ lg: {
191
+ base: string;
192
+ };
193
+ md: {
194
+ base: string;
195
+ };
196
+ sm: {
197
+ base: string;
198
+ };
199
+ none: {
200
+ base: string;
201
+ };
202
+ };
135
203
  }, {
136
204
  root: string;
137
205
  base: string;
@@ -165,6 +233,23 @@ export declare const avatarGroupDefaults: {
165
233
  base: string;
166
234
  };
167
235
  };
236
+ rounded: {
237
+ full: {
238
+ base: string;
239
+ };
240
+ lg: {
241
+ base: string;
242
+ };
243
+ md: {
244
+ base: string;
245
+ };
246
+ sm: {
247
+ base: string;
248
+ };
249
+ none: {
250
+ base: string;
251
+ };
252
+ };
168
253
  }, {
169
254
  root: string;
170
255
  base: string;
@@ -2,41 +2,31 @@ import { tv } from 'tailwind-variants';
2
2
  export const avatarGroupVariants = tv({
3
3
  slots: {
4
4
  root: 'inline-flex flex-row-reverse justify-end',
5
- base: 'relative rounded-full ring-surface first:me-0'
5
+ base: 'relative ring-surface first:me-0'
6
6
  },
7
7
  variants: {
8
8
  size: {
9
- '3xs': {
10
- base: 'ring -me-0.5'
11
- },
12
- '2xs': {
13
- base: 'ring -me-0.5'
14
- },
15
- xs: {
16
- base: 'ring -me-0.5'
17
- },
18
- sm: {
19
- base: 'ring-2 -me-1.5'
20
- },
21
- md: {
22
- base: 'ring-2 -me-1.5'
23
- },
24
- lg: {
25
- base: 'ring-2 -me-1.5'
26
- },
27
- xl: {
28
- base: 'ring-3 -me-2'
29
- },
30
- '2xl': {
31
- base: 'ring-3 -me-2'
32
- },
33
- '3xl': {
34
- base: 'ring-3 -me-2'
35
- }
9
+ '3xs': { base: 'ring -me-0.5' },
10
+ '2xs': { base: 'ring -me-0.5' },
11
+ xs: { base: 'ring -me-0.5' },
12
+ sm: { base: 'ring-2 -me-1.5' },
13
+ md: { base: 'ring-2 -me-1.5' },
14
+ lg: { base: 'ring-2 -me-1.5' },
15
+ xl: { base: 'ring-3 -me-2' },
16
+ '2xl': { base: 'ring-3 -me-2' },
17
+ '3xl': { base: 'ring-3 -me-2' }
18
+ },
19
+ rounded: {
20
+ full: { base: 'rounded-full' },
21
+ lg: { base: 'rounded-lg' },
22
+ md: { base: 'rounded-md' },
23
+ sm: { base: 'rounded-sm' },
24
+ none: { base: 'rounded-none' }
36
25
  }
37
26
  },
38
27
  defaultVariants: {
39
- size: 'md'
28
+ size: 'md',
29
+ rounded: 'full'
40
30
  }
41
31
  });
42
32
  export const avatarGroupDefaults = {
@@ -14,6 +14,7 @@
14
14
  const config = getComponentConfig('badge', badgeDefaults)
15
15
 
16
16
  let {
17
+ ref = $bindable(null),
17
18
  as = 'span',
18
19
  ui,
19
20
  label,
@@ -32,7 +33,7 @@
32
33
  ...restProps
33
34
  }: Props = $props()
34
35
 
35
- const isIconOnly = $derived(!!icon || (square && !label && !children))
36
+ const isIconOnly = $derived(!!icon || (square && label === undefined && !children))
36
37
 
37
38
  const classes = $derived.by(() => {
38
39
  const slots = badgeVariants({ variant, color, size, square: isIconOnly || square })
@@ -51,7 +52,7 @@
51
52
  })
52
53
  </script>
53
54
 
54
- <svelte:element this={as} class={classes.base} {...restProps}>
55
+ <svelte:element this={as} bind:this={ref} class={classes.base} {...restProps}>
55
56
  {#if leading}
56
57
  {@render leading()}
57
58
  {:else if avatar}
@@ -63,7 +64,7 @@
63
64
  {#if icon}
64
65
  <Icon name={icon} class={classes.leadingIcon} />
65
66
  {:else if !isIconOnly}
66
- {#if label !== null}
67
+ {#if label !== undefined}
67
68
  <span class={classes.label}>{label}</span>
68
69
  {:else if children}
69
70
  <span class={classes.label}>{@render children()}</span>
@@ -1,5 +1,5 @@
1
1
  import type { BadgeProps } from './badge.types.js';
2
2
  export type Props = BadgeProps;
3
- declare const Badge: import("svelte").Component<BadgeProps, {}, "">;
3
+ declare const Badge: import("svelte").Component<BadgeProps, {}, "ref">;
4
4
  type Badge = ReturnType<typeof Badge>;
5
5
  export default Badge;
@@ -4,6 +4,10 @@ import type { ClassNameValue } from 'tailwind-merge';
4
4
  import type { BadgeVariantProps, BadgeSlots } from './badge.variants.js';
5
5
  import type { AvatarProps } from '../Avatar/avatar.types.js';
6
6
  export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'class'> & {
7
+ /**
8
+ * Bindable reference to the root DOM element.
9
+ */
10
+ ref?: HTMLElement | null;
7
11
  /**
8
12
  * Sets the HTML element type to render.
9
13
  * @default 'span'
@@ -66,6 +70,11 @@ export type BadgeProps = Omit<HTMLAttributes<HTMLSpanElement>, 'class'> & {
66
70
  * Takes precedence over avatar and leadingIcon.
67
71
  */
68
72
  leading?: Snippet;
73
+ /**
74
+ * Default content slot.
75
+ * Takes precedence over label when no label is provided.
76
+ */
77
+ children?: Snippet;
69
78
  /**
70
79
  * Custom trailing content slot.
71
80
  * Takes precedence over trailingIcon.
@@ -14,28 +14,35 @@
14
14
  const config = getComponentConfig('breadcrumb', breadcrumbDefaults)
15
15
 
16
16
  let {
17
+ ref = $bindable(null),
17
18
  as = 'nav',
18
19
  items,
19
20
  separatorIcon = 'lucide:chevron-right',
20
21
  class: className,
21
22
  ui,
22
23
  item: itemSnippet,
23
- separator: separatorSnippet
24
+ separator: separatorSnippet,
25
+ ...restProps
24
26
  }: Props = $props()
25
27
 
26
28
  const variantSlots = $derived(breadcrumbVariants(config.defaultVariants))
27
29
 
28
- const classes = $derived.by(() => ({
30
+ const classes = $derived({
29
31
  root: variantSlots.root({ class: [config.slots.root, className, ui?.root] }),
30
32
  list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
31
33
  separator: variantSlots.separator({ class: [config.slots.separator, ui?.separator] }),
32
34
  separatorIcon: variantSlots.separatorIcon({
33
35
  class: [config.slots.separatorIcon, ui?.separatorIcon]
34
36
  })
35
- }))
37
+ })
36
38
 
37
- function getLinkClasses(active: boolean, disabled: boolean, itemClass?: ClassNameValue) {
38
- const slots = breadcrumbVariants({ ...config.defaultVariants, active, disabled })
39
+ function getLinkClasses(
40
+ active: boolean,
41
+ disabled: boolean,
42
+ to: boolean,
43
+ itemClass?: ClassNameValue
44
+ ) {
45
+ const slots = breadcrumbVariants({ ...config.defaultVariants, active, disabled, to })
39
46
  return {
40
47
  item: slots.item({ class: [config.slots.item, ui?.item] }),
41
48
  link: slots.link({ class: [config.slots.link, itemClass, ui?.link] }),
@@ -47,12 +54,18 @@
47
54
  }
48
55
  </script>
49
56
 
50
- <svelte:element this={as} aria-label={as === 'nav' ? 'Breadcrumb' : undefined} class={classes.root}>
57
+ <svelte:element
58
+ this={as}
59
+ bind:this={ref}
60
+ aria-label={as === 'nav' ? 'Breadcrumb' : undefined}
61
+ class={classes.root}
62
+ {...restProps}
63
+ >
51
64
  <ol class={classes.list}>
52
65
  {#each items as item, index (item.label ?? index)}
53
66
  {@const active = index === items.length - 1}
54
67
  {@const disabled = item.disabled ?? false}
55
- {@const itemClasses = getLinkClasses(active, disabled, item.class)}
68
+ {@const itemClasses = getLinkClasses(active, disabled, !!item.href, item.class)}
56
69
 
57
70
  <li class={itemClasses.item}>
58
71
  {#if itemSnippet}
@@ -1,5 +1,5 @@
1
1
  import type { BreadcrumbProps } from './breadcrumb.types.js';
2
2
  export type Props = BreadcrumbProps;
3
- declare const Breadcrumb: import("svelte").Component<BreadcrumbProps, {}, "">;
3
+ declare const Breadcrumb: import("svelte").Component<BreadcrumbProps, {}, "ref">;
4
4
  type Breadcrumb = ReturnType<typeof Breadcrumb>;
5
5
  export default Breadcrumb;
@@ -25,11 +25,15 @@ export interface BreadcrumbItem {
25
25
  class?: ClassNameValue;
26
26
  }
27
27
  export interface BreadcrumbProps {
28
+ /**
29
+ * Bindable reference to the root DOM element.
30
+ */
31
+ ref?: HTMLElement | null;
28
32
  /**
29
33
  * The HTML element to render as the root wrapper.
30
34
  * @default 'nav'
31
35
  */
32
- as?: string;
36
+ as?: keyof HTMLElementTagNameMap;
33
37
  /**
34
38
  * Array of breadcrumb items to render.
35
39
  */
@@ -12,7 +12,9 @@ export declare const breadcrumbVariants: import("tailwind-variants").TVReturnTyp
12
12
  true: {
13
13
  link: string;
14
14
  };
15
- false: string;
15
+ };
16
+ to: {
17
+ true: string;
16
18
  };
17
19
  }, {
18
20
  root: string;
@@ -36,7 +38,9 @@ export declare const breadcrumbVariants: import("tailwind-variants").TVReturnTyp
36
38
  true: {
37
39
  link: string;
38
40
  };
39
- false: string;
41
+ };
42
+ to: {
43
+ true: string;
40
44
  };
41
45
  }, {
42
46
  root: string;
@@ -60,7 +64,9 @@ export declare const breadcrumbVariants: import("tailwind-variants").TVReturnTyp
60
64
  true: {
61
65
  link: string;
62
66
  };
63
- false: string;
67
+ };
68
+ to: {
69
+ true: string;
64
70
  };
65
71
  }, {
66
72
  root: string;
@@ -88,7 +94,9 @@ export declare const breadcrumbDefaults: {
88
94
  true: {
89
95
  link: string;
90
96
  };
91
- false: string;
97
+ };
98
+ to: {
99
+ true: string;
92
100
  };
93
101
  }, {
94
102
  root: string;
@@ -112,7 +120,9 @@ export declare const breadcrumbDefaults: {
112
120
  true: {
113
121
  link: string;
114
122
  };
115
- false: string;
123
+ };
124
+ to: {
125
+ true: string;
116
126
  };
117
127
  }, {
118
128
  root: string;
@@ -25,14 +25,17 @@ export const breadcrumbVariants = tv({
25
25
  disabled: {
26
26
  true: {
27
27
  link: 'cursor-not-allowed opacity-75'
28
- },
29
- false: ''
28
+ }
29
+ },
30
+ to: {
31
+ true: ''
30
32
  }
31
33
  },
32
34
  compoundVariants: [
33
35
  {
34
36
  active: false,
35
37
  disabled: false,
38
+ to: true,
36
39
  class: {
37
40
  link: 'hover:text-on-surface transition-colors'
38
41
  }
@@ -40,7 +43,8 @@ export const breadcrumbVariants = tv({
40
43
  ],
41
44
  defaultVariants: {
42
45
  active: false,
43
- disabled: false
46
+ disabled: false,
47
+ to: false
44
48
  }
45
49
  });
46
50
  export const breadcrumbDefaults = {