sv5ui 0.0.1

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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/Alert/Alert.svelte +120 -0
  4. package/dist/Alert/Alert.svelte.d.ts +5 -0
  5. package/dist/Alert/alert.types.d.ts +99 -0
  6. package/dist/Alert/alert.types.js +1 -0
  7. package/dist/Alert/alert.variants.d.ts +213 -0
  8. package/dist/Alert/alert.variants.js +293 -0
  9. package/dist/Alert/index.d.ts +2 -0
  10. package/dist/Alert/index.js +1 -0
  11. package/dist/Avatar/Avatar.svelte +70 -0
  12. package/dist/Avatar/Avatar.svelte.d.ts +6 -0
  13. package/dist/Avatar/avatar.types.d.ts +40 -0
  14. package/dist/Avatar/avatar.types.js +1 -0
  15. package/dist/Avatar/avatar.variants.d.ts +178 -0
  16. package/dist/Avatar/avatar.variants.js +28 -0
  17. package/dist/Avatar/index.d.ts +2 -0
  18. package/dist/Avatar/index.js +1 -0
  19. package/dist/AvatarGroup/AvatarGroup.svelte +66 -0
  20. package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +5 -0
  21. package/dist/AvatarGroup/avatar-group.types.d.ts +34 -0
  22. package/dist/AvatarGroup/avatar-group.types.js +1 -0
  23. package/dist/AvatarGroup/avatar-group.variants.d.ts +173 -0
  24. package/dist/AvatarGroup/avatar-group.variants.js +45 -0
  25. package/dist/AvatarGroup/index.d.ts +2 -0
  26. package/dist/AvatarGroup/index.js +1 -0
  27. package/dist/Badge/Badge.svelte +74 -0
  28. package/dist/Badge/Badge.svelte.d.ts +5 -0
  29. package/dist/Badge/badge.types.d.ts +74 -0
  30. package/dist/Badge/badge.types.js +1 -0
  31. package/dist/Badge/badge.variants.d.ts +303 -0
  32. package/dist/Badge/badge.variants.js +245 -0
  33. package/dist/Badge/index.d.ts +2 -0
  34. package/dist/Badge/index.js +1 -0
  35. package/dist/Button/Button.svelte +103 -0
  36. package/dist/Button/Button.svelte.d.ts +6 -0
  37. package/dist/Button/button.types.d.ts +97 -0
  38. package/dist/Button/button.types.js +1 -0
  39. package/dist/Button/button.variants.d.ts +388 -0
  40. package/dist/Button/button.variants.js +461 -0
  41. package/dist/Button/index.d.ts +2 -0
  42. package/dist/Button/index.js +1 -0
  43. package/dist/Card/Card.svelte +53 -0
  44. package/dist/Card/Card.svelte.d.ts +5 -0
  45. package/dist/Card/card.types.d.ts +32 -0
  46. package/dist/Card/card.types.js +1 -0
  47. package/dist/Card/card.variants.d.ts +108 -0
  48. package/dist/Card/card.variants.js +32 -0
  49. package/dist/Card/index.d.ts +2 -0
  50. package/dist/Card/index.js +1 -0
  51. package/dist/Chip/Chip.svelte +50 -0
  52. package/dist/Chip/Chip.svelte.d.ts +5 -0
  53. package/dist/Chip/chip.types.d.ts +62 -0
  54. package/dist/Chip/chip.types.js +1 -0
  55. package/dist/Chip/chip.variants.d.ts +328 -0
  56. package/dist/Chip/chip.variants.js +58 -0
  57. package/dist/Chip/index.d.ts +2 -0
  58. package/dist/Chip/index.js +1 -0
  59. package/dist/Container/Container.svelte +27 -0
  60. package/dist/Container/Container.svelte.d.ts +5 -0
  61. package/dist/Container/container.types.d.ts +19 -0
  62. package/dist/Container/container.types.js +1 -0
  63. package/dist/Container/container.variants.d.ts +29 -0
  64. package/dist/Container/container.variants.js +9 -0
  65. package/dist/Container/index.d.ts +2 -0
  66. package/dist/Container/index.js +1 -0
  67. package/dist/Empty/Empty.svelte +83 -0
  68. package/dist/Empty/Empty.svelte.d.ts +5 -0
  69. package/dist/Empty/empty.types.d.ts +74 -0
  70. package/dist/Empty/empty.types.js +1 -0
  71. package/dist/Empty/empty.variants.d.ts +288 -0
  72. package/dist/Empty/empty.variants.js +364 -0
  73. package/dist/Empty/index.d.ts +2 -0
  74. package/dist/Empty/index.js +1 -0
  75. package/dist/Icon/Icon.svelte +40 -0
  76. package/dist/Icon/Icon.svelte.d.ts +6 -0
  77. package/dist/Icon/icon.types.d.ts +37 -0
  78. package/dist/Icon/icon.types.js +1 -0
  79. package/dist/Icon/index.d.ts +2 -0
  80. package/dist/Icon/index.js +1 -0
  81. package/dist/Kbd/Kbd.svelte +35 -0
  82. package/dist/Kbd/Kbd.svelte.d.ts +5 -0
  83. package/dist/Kbd/index.d.ts +3 -0
  84. package/dist/Kbd/index.js +2 -0
  85. package/dist/Kbd/kbd.types.d.ts +77 -0
  86. package/dist/Kbd/kbd.types.js +1 -0
  87. package/dist/Kbd/kbd.variants.d.ts +118 -0
  88. package/dist/Kbd/kbd.variants.js +96 -0
  89. package/dist/Kbd/useKbd.svelte.d.ts +29 -0
  90. package/dist/Kbd/useKbd.svelte.js +245 -0
  91. package/dist/Link/Link.svelte +117 -0
  92. package/dist/Link/Link.svelte.d.ts +5 -0
  93. package/dist/Link/index.d.ts +2 -0
  94. package/dist/Link/index.js +1 -0
  95. package/dist/Link/link.types.d.ts +68 -0
  96. package/dist/Link/link.types.js +1 -0
  97. package/dist/Link/link.variants.d.ts +138 -0
  98. package/dist/Link/link.variants.js +145 -0
  99. package/dist/Progress/Progress.svelte +89 -0
  100. package/dist/Progress/Progress.svelte.d.ts +6 -0
  101. package/dist/Progress/index.d.ts +2 -0
  102. package/dist/Progress/index.js +1 -0
  103. package/dist/Progress/progress.types.d.ts +63 -0
  104. package/dist/Progress/progress.types.js +1 -0
  105. package/dist/Progress/progress.variants.d.ts +483 -0
  106. package/dist/Progress/progress.variants.js +190 -0
  107. package/dist/Separator/Separator.svelte +67 -0
  108. package/dist/Separator/Separator.svelte.d.ts +6 -0
  109. package/dist/Separator/index.d.ts +2 -0
  110. package/dist/Separator/index.js +1 -0
  111. package/dist/Separator/separator.types.d.ts +48 -0
  112. package/dist/Separator/separator.types.js +1 -0
  113. package/dist/Separator/separator.variants.d.ts +488 -0
  114. package/dist/Separator/separator.variants.js +104 -0
  115. package/dist/Skeleton/Skeleton.svelte +31 -0
  116. package/dist/Skeleton/Skeleton.svelte.d.ts +5 -0
  117. package/dist/Skeleton/index.d.ts +2 -0
  118. package/dist/Skeleton/index.js +1 -0
  119. package/dist/Skeleton/skeleton.types.d.ts +18 -0
  120. package/dist/Skeleton/skeleton.types.js +1 -0
  121. package/dist/Skeleton/skeleton.variants.d.ts +18 -0
  122. package/dist/Skeleton/skeleton.variants.js +12 -0
  123. package/dist/Timeline/Timeline.svelte +106 -0
  124. package/dist/Timeline/Timeline.svelte.d.ts +5 -0
  125. package/dist/Timeline/index.d.ts +2 -0
  126. package/dist/Timeline/index.js +1 -0
  127. package/dist/Timeline/timeline.types.d.ts +130 -0
  128. package/dist/Timeline/timeline.types.js +1 -0
  129. package/dist/Timeline/timeline.variants.d.ts +413 -0
  130. package/dist/Timeline/timeline.variants.js +121 -0
  131. package/dist/User/User.svelte +94 -0
  132. package/dist/User/User.svelte.d.ts +5 -0
  133. package/dist/User/index.d.ts +2 -0
  134. package/dist/User/index.js +1 -0
  135. package/dist/User/user.types.d.ts +74 -0
  136. package/dist/User/user.types.js +1 -0
  137. package/dist/User/user.variants.d.ts +308 -0
  138. package/dist/User/user.variants.js +73 -0
  139. package/dist/config.d.ts +59 -0
  140. package/dist/config.js +94 -0
  141. package/dist/index.d.ts +19 -0
  142. package/dist/index.js +20 -0
  143. package/dist/theme.css +410 -0
  144. package/package.json +104 -0
@@ -0,0 +1,364 @@
1
+ import { tv } from 'tailwind-variants';
2
+ export const emptyVariants = tv({
3
+ slots: {
4
+ root: 'flex flex-col items-center justify-center rounded-lg text-center',
5
+ icon: 'shrink-0',
6
+ avatar: 'shrink-0',
7
+ title: 'font-medium',
8
+ description: '',
9
+ actions: 'flex flex-wrap items-center justify-center gap-2'
10
+ },
11
+ variants: {
12
+ variant: {
13
+ solid: '',
14
+ outline: '',
15
+ soft: '',
16
+ subtle: ''
17
+ },
18
+ color: {
19
+ primary: '',
20
+ secondary: '',
21
+ tertiary: '',
22
+ success: '',
23
+ warning: '',
24
+ error: '',
25
+ info: '',
26
+ surface: ''
27
+ },
28
+ size: {
29
+ xs: {
30
+ root: 'gap-2 p-4',
31
+ icon: 'size-8',
32
+ title: 'text-sm',
33
+ description: 'text-xs'
34
+ },
35
+ sm: {
36
+ root: 'gap-2.5 p-5',
37
+ icon: 'size-10',
38
+ title: 'text-sm',
39
+ description: 'text-xs'
40
+ },
41
+ md: {
42
+ root: 'gap-3 p-6',
43
+ icon: 'size-12',
44
+ title: 'text-base',
45
+ description: 'text-sm'
46
+ },
47
+ lg: {
48
+ root: 'gap-4 p-8',
49
+ icon: 'size-14',
50
+ title: 'text-lg',
51
+ description: 'text-sm'
52
+ },
53
+ xl: {
54
+ root: 'gap-5 p-10',
55
+ icon: 'size-16',
56
+ title: 'text-xl',
57
+ description: 'text-base'
58
+ }
59
+ }
60
+ },
61
+ compoundVariants: [
62
+ // ========== SOLID VARIANTS ==========
63
+ {
64
+ variant: 'solid',
65
+ color: 'primary',
66
+ class: {
67
+ root: 'bg-primary text-on-primary',
68
+ icon: 'text-on-primary/70',
69
+ description: 'text-on-primary/80'
70
+ }
71
+ },
72
+ {
73
+ variant: 'solid',
74
+ color: 'secondary',
75
+ class: {
76
+ root: 'bg-secondary text-on-secondary',
77
+ icon: 'text-on-secondary/70',
78
+ description: 'text-on-secondary/80'
79
+ }
80
+ },
81
+ {
82
+ variant: 'solid',
83
+ color: 'tertiary',
84
+ class: {
85
+ root: 'bg-tertiary text-on-tertiary',
86
+ icon: 'text-on-tertiary/70',
87
+ description: 'text-on-tertiary/80'
88
+ }
89
+ },
90
+ {
91
+ variant: 'solid',
92
+ color: 'success',
93
+ class: {
94
+ root: 'bg-success text-on-success',
95
+ icon: 'text-on-success/70',
96
+ description: 'text-on-success/80'
97
+ }
98
+ },
99
+ {
100
+ variant: 'solid',
101
+ color: 'warning',
102
+ class: {
103
+ root: 'bg-warning text-on-warning',
104
+ icon: 'text-on-warning/70',
105
+ description: 'text-on-warning/80'
106
+ }
107
+ },
108
+ {
109
+ variant: 'solid',
110
+ color: 'error',
111
+ class: {
112
+ root: 'bg-error text-on-error',
113
+ icon: 'text-on-error/70',
114
+ description: 'text-on-error/80'
115
+ }
116
+ },
117
+ {
118
+ variant: 'solid',
119
+ color: 'info',
120
+ class: {
121
+ root: 'bg-info text-on-info',
122
+ icon: 'text-on-info/70',
123
+ description: 'text-on-info/80'
124
+ }
125
+ },
126
+ {
127
+ variant: 'solid',
128
+ color: 'surface',
129
+ class: {
130
+ root: 'bg-inverse-surface text-inverse-on-surface',
131
+ icon: 'text-inverse-on-surface/70',
132
+ description: 'text-inverse-on-surface/80'
133
+ }
134
+ },
135
+ // ========== OUTLINE VARIANTS ==========
136
+ {
137
+ variant: 'outline',
138
+ color: 'primary',
139
+ class: {
140
+ root: 'ring ring-inset ring-primary/25 text-primary',
141
+ icon: 'text-primary/70',
142
+ description: 'text-primary/80'
143
+ }
144
+ },
145
+ {
146
+ variant: 'outline',
147
+ color: 'secondary',
148
+ class: {
149
+ root: 'ring ring-inset ring-secondary/25 text-secondary',
150
+ icon: 'text-secondary/70',
151
+ description: 'text-secondary/80'
152
+ }
153
+ },
154
+ {
155
+ variant: 'outline',
156
+ color: 'tertiary',
157
+ class: {
158
+ root: 'ring ring-inset ring-tertiary/25 text-tertiary',
159
+ icon: 'text-tertiary/70',
160
+ description: 'text-tertiary/80'
161
+ }
162
+ },
163
+ {
164
+ variant: 'outline',
165
+ color: 'success',
166
+ class: {
167
+ root: 'ring ring-inset ring-success/25 text-success',
168
+ icon: 'text-success/70',
169
+ description: 'text-success/80'
170
+ }
171
+ },
172
+ {
173
+ variant: 'outline',
174
+ color: 'warning',
175
+ class: {
176
+ root: 'ring ring-inset ring-warning/25 text-warning',
177
+ icon: 'text-warning/70',
178
+ description: 'text-warning/80'
179
+ }
180
+ },
181
+ {
182
+ variant: 'outline',
183
+ color: 'error',
184
+ class: {
185
+ root: 'ring ring-inset ring-error/25 text-error',
186
+ icon: 'text-error/70',
187
+ description: 'text-error/80'
188
+ }
189
+ },
190
+ {
191
+ variant: 'outline',
192
+ color: 'info',
193
+ class: {
194
+ root: 'ring ring-inset ring-info/25 text-info',
195
+ icon: 'text-info/70',
196
+ description: 'text-info/80'
197
+ }
198
+ },
199
+ {
200
+ variant: 'outline',
201
+ color: 'surface',
202
+ class: {
203
+ root: 'ring ring-inset ring-outline-variant text-on-surface',
204
+ icon: 'text-on-surface-variant',
205
+ description: 'text-on-surface-variant'
206
+ }
207
+ },
208
+ // ========== SOFT VARIANTS ==========
209
+ {
210
+ variant: 'soft',
211
+ color: 'primary',
212
+ class: {
213
+ root: 'bg-primary-container text-on-primary-container',
214
+ icon: 'text-on-primary-container/70',
215
+ description: 'text-on-primary-container/80'
216
+ }
217
+ },
218
+ {
219
+ variant: 'soft',
220
+ color: 'secondary',
221
+ class: {
222
+ root: 'bg-secondary-container text-on-secondary-container',
223
+ icon: 'text-on-secondary-container/70',
224
+ description: 'text-on-secondary-container/80'
225
+ }
226
+ },
227
+ {
228
+ variant: 'soft',
229
+ color: 'tertiary',
230
+ class: {
231
+ root: 'bg-tertiary-container text-on-tertiary-container',
232
+ icon: 'text-on-tertiary-container/70',
233
+ description: 'text-on-tertiary-container/80'
234
+ }
235
+ },
236
+ {
237
+ variant: 'soft',
238
+ color: 'success',
239
+ class: {
240
+ root: 'bg-success-container text-on-success-container',
241
+ icon: 'text-on-success-container/70',
242
+ description: 'text-on-success-container/80'
243
+ }
244
+ },
245
+ {
246
+ variant: 'soft',
247
+ color: 'warning',
248
+ class: {
249
+ root: 'bg-warning-container text-on-warning-container',
250
+ icon: 'text-on-warning-container/70',
251
+ description: 'text-on-warning-container/80'
252
+ }
253
+ },
254
+ {
255
+ variant: 'soft',
256
+ color: 'error',
257
+ class: {
258
+ root: 'bg-error-container text-on-error-container',
259
+ icon: 'text-on-error-container/70',
260
+ description: 'text-on-error-container/80'
261
+ }
262
+ },
263
+ {
264
+ variant: 'soft',
265
+ color: 'info',
266
+ class: {
267
+ root: 'bg-info-container text-on-info-container',
268
+ icon: 'text-on-info-container/70',
269
+ description: 'text-on-info-container/80'
270
+ }
271
+ },
272
+ {
273
+ variant: 'soft',
274
+ color: 'surface',
275
+ class: {
276
+ root: 'bg-surface-container-highest text-on-surface',
277
+ icon: 'text-on-surface-variant',
278
+ description: 'text-on-surface-variant'
279
+ }
280
+ },
281
+ // ========== SUBTLE VARIANTS ==========
282
+ {
283
+ variant: 'subtle',
284
+ color: 'primary',
285
+ class: {
286
+ root: 'bg-primary-container text-on-primary-container ring ring-inset ring-primary/25',
287
+ icon: 'text-on-primary-container/70',
288
+ description: 'text-on-primary-container/80'
289
+ }
290
+ },
291
+ {
292
+ variant: 'subtle',
293
+ color: 'secondary',
294
+ class: {
295
+ root: 'bg-secondary-container text-on-secondary-container ring ring-inset ring-secondary/25',
296
+ icon: 'text-on-secondary-container/70',
297
+ description: 'text-on-secondary-container/80'
298
+ }
299
+ },
300
+ {
301
+ variant: 'subtle',
302
+ color: 'tertiary',
303
+ class: {
304
+ root: 'bg-tertiary-container text-on-tertiary-container ring ring-inset ring-tertiary/25',
305
+ icon: 'text-on-tertiary-container/70',
306
+ description: 'text-on-tertiary-container/80'
307
+ }
308
+ },
309
+ {
310
+ variant: 'subtle',
311
+ color: 'success',
312
+ class: {
313
+ root: 'bg-success-container text-on-success-container ring ring-inset ring-success/25',
314
+ icon: 'text-on-success-container/70',
315
+ description: 'text-on-success-container/80'
316
+ }
317
+ },
318
+ {
319
+ variant: 'subtle',
320
+ color: 'warning',
321
+ class: {
322
+ root: 'bg-warning-container text-on-warning-container ring ring-inset ring-warning/25',
323
+ icon: 'text-on-warning-container/70',
324
+ description: 'text-on-warning-container/80'
325
+ }
326
+ },
327
+ {
328
+ variant: 'subtle',
329
+ color: 'error',
330
+ class: {
331
+ root: 'bg-error-container text-on-error-container ring ring-inset ring-error/25',
332
+ icon: 'text-on-error-container/70',
333
+ description: 'text-on-error-container/80'
334
+ }
335
+ },
336
+ {
337
+ variant: 'subtle',
338
+ color: 'info',
339
+ class: {
340
+ root: 'bg-info-container text-on-info-container ring ring-inset ring-info/25',
341
+ icon: 'text-on-info-container/70',
342
+ description: 'text-on-info-container/80'
343
+ }
344
+ },
345
+ {
346
+ variant: 'subtle',
347
+ color: 'surface',
348
+ class: {
349
+ root: 'bg-surface-container-highest text-on-surface ring ring-inset ring-outline-variant',
350
+ icon: 'text-on-surface-variant',
351
+ description: 'text-on-surface-variant'
352
+ }
353
+ }
354
+ ],
355
+ defaultVariants: {
356
+ variant: 'outline',
357
+ color: 'surface',
358
+ size: 'md'
359
+ }
360
+ });
361
+ export const emptyDefaults = {
362
+ defaultVariants: emptyVariants.defaultVariants,
363
+ slots: {}
364
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Empty } from './Empty.svelte';
2
+ export type { EmptyProps } from './empty.types.js';
@@ -0,0 +1 @@
1
+ export { default as Empty } from './Empty.svelte';
@@ -0,0 +1,40 @@
1
+ <script lang="ts" module>
2
+ import type { IconProps } from './icon.types.js'
3
+
4
+ export type Props = IconProps
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import Icon from '@iconify/svelte'
9
+
10
+ let {
11
+ name,
12
+ size = 24,
13
+ color,
14
+ flipH = false,
15
+ flipV = false,
16
+ rotate = 0,
17
+ class: className,
18
+ ...restProps
19
+ }: Props = $props()
20
+
21
+ const flip = $derived.by(() => {
22
+ if (flipH && flipV) return 'horizontal,vertical'
23
+ if (flipH) return 'horizontal'
24
+ if (flipV) return 'vertical'
25
+ return undefined
26
+ })
27
+
28
+ const rotateValue = $derived(rotate ? rotate / 90 : undefined)
29
+ </script>
30
+
31
+ <Icon
32
+ icon={name}
33
+ width={size}
34
+ height={size}
35
+ {color}
36
+ {flip}
37
+ rotate={rotateValue}
38
+ class="shrink-0 {className ?? ''}"
39
+ {...restProps}
40
+ />
@@ -0,0 +1,6 @@
1
+ import type { IconProps } from './icon.types.js';
2
+ export type Props = IconProps;
3
+ import Icon from '@iconify/svelte';
4
+ declare const Icon: import("svelte").Component<IconProps, {}, "">;
5
+ type Icon = ReturnType<typeof Icon>;
6
+ export default Icon;
@@ -0,0 +1,37 @@
1
+ import type { IconProps as IconifyProps } from '@iconify/svelte';
2
+ export interface IconProps extends Omit<IconifyProps, 'icon' | 'width' | 'height' | 'rotate' | 'flip' | 'class'> {
3
+ /** Additional CSS classes */
4
+ class?: string;
5
+ /**
6
+ * Icon name in Iconify format: "collection:icon-name"
7
+ * @example "lucide:home", "mdi:account", "heroicons:star"
8
+ * @see https://icon-sets.iconify.design/
9
+ */
10
+ name: string;
11
+ /**
12
+ * Icon size (applied to both width and height)
13
+ * @default "1em"
14
+ * @example 24, "1.5rem", "20px"
15
+ */
16
+ size?: number | string;
17
+ /**
18
+ * Icon color (CSS color value)
19
+ * @example "red", "#ff0000", "rgb(255, 0, 0)", "currentColor"
20
+ */
21
+ color?: string;
22
+ /**
23
+ * Flip icon horizontally
24
+ * @default false
25
+ */
26
+ flipH?: boolean;
27
+ /**
28
+ * Flip icon vertically
29
+ * @default false
30
+ */
31
+ flipV?: boolean;
32
+ /**
33
+ * Rotate icon by specified degrees
34
+ * @default 0
35
+ */
36
+ rotate?: 0 | 90 | 180 | 270;
37
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as Icon } from './Icon.svelte';
2
+ export type { IconProps } from './icon.types.js';
@@ -0,0 +1 @@
1
+ export { default as Icon } from './Icon.svelte';
@@ -0,0 +1,35 @@
1
+ <script lang="ts" module>
2
+ import type { KbdProps } from './kbd.types.js'
3
+ import { resolveKey } from './useKbd.svelte.js'
4
+
5
+ export type Props = KbdProps
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import { kbdVariants, kbdDefaults } from './kbd.variants.js'
10
+ import { getComponentConfig } from '../config.js'
11
+
12
+ const config = getComponentConfig('kbd', kbdDefaults)
13
+
14
+ let {
15
+ as = 'kbd',
16
+ value,
17
+ color = config.defaultVariants.color,
18
+ size = config.defaultVariants.size,
19
+ variant = config.defaultVariants.variant,
20
+ class: className,
21
+ children,
22
+ ...restProps
23
+ }: Props = $props()
24
+
25
+ const displayValue = $derived(resolveKey(value))
26
+ const kbdClass = $derived(kbdVariants({ color, size, variant, class: className }))
27
+ </script>
28
+
29
+ <svelte:element this={as} class={kbdClass} {...restProps}>
30
+ {#if children}
31
+ {@render children()}
32
+ {:else if displayValue}
33
+ {displayValue}
34
+ {/if}
35
+ </svelte:element>
@@ -0,0 +1,5 @@
1
+ import type { KbdProps } from './kbd.types.js';
2
+ export type Props = KbdProps;
3
+ declare const Kbd: import("svelte").Component<KbdProps, {}, "">;
4
+ type Kbd = ReturnType<typeof Kbd>;
5
+ export default Kbd;
@@ -0,0 +1,3 @@
1
+ export { default as Kbd } from './Kbd.svelte';
2
+ export type { KbdProps } from './kbd.types.js';
3
+ export { formatShortcut, useKbd } from './useKbd.svelte.js';
@@ -0,0 +1,2 @@
1
+ export { default as Kbd } from './Kbd.svelte';
2
+ export { formatShortcut, useKbd } from './useKbd.svelte.js';
@@ -0,0 +1,77 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { ClassNameValue } from 'tailwind-merge';
3
+ import type { KbdVariantProps } from './kbd.variants.js';
4
+ export type KeyboardShortcutCallback = (event: KeyboardEvent) => void;
5
+ export interface UseKbdOptions {
6
+ /**
7
+ * Map of shortcut strings to callbacks. Supports getter for reactive shortcuts.
8
+ * @example { 'ctrl+k': () => openSearch(), 'escape': () => close() }
9
+ * @example () => mode === 'edit' ? editShortcuts : viewShortcuts
10
+ */
11
+ shortcuts?: Record<string, KeyboardShortcutCallback> | (() => Record<string, KeyboardShortcutCallback>);
12
+ /**
13
+ * Target element to attach listeners to. Supports getter for reactivity.
14
+ * @default window
15
+ */
16
+ target?: HTMLElement | Window | null | (() => HTMLElement | Window | null);
17
+ /**
18
+ * Whether the hook is active. Supports getter for reactivity.
19
+ * @default true
20
+ */
21
+ enabled?: boolean | (() => boolean);
22
+ /**
23
+ * Whether to call preventDefault() on matched shortcuts.
24
+ * @default true
25
+ */
26
+ preventDefault?: boolean;
27
+ /**
28
+ * Prevent modifier keys (Alt, Meta) from triggering browser default behavior
29
+ * (e.g., Alt activating browser menu on Windows). Enables reliable modifier tracking.
30
+ * @default false
31
+ */
32
+ captureModifiers?: boolean;
33
+ /**
34
+ * Whether shortcut callbacks should fire repeatedly when a key is held down.
35
+ * @default false
36
+ */
37
+ repeat?: boolean;
38
+ }
39
+ export interface UseKbdReturn {
40
+ /** Check if a specific key is currently pressed (case-insensitive) */
41
+ isPressed: (key: string) => boolean;
42
+ /** Reactive set of currently pressed key names (lowercase) */
43
+ readonly pressedKeys: ReadonlySet<string>;
44
+ }
45
+ export type KbdProps = Omit<HTMLAttributes<HTMLElement>, 'class'> & {
46
+ /**
47
+ * Sets the HTML element type to render.
48
+ * @default 'kbd'
49
+ */
50
+ as?: keyof HTMLElementTagNameMap;
51
+ /**
52
+ * Key value to display. Supports special keys that auto-convert to symbols.
53
+ * On macOS: meta → ⌘, ctrl → ⌃, alt → ⌥, shift → ⇧
54
+ * On other OS: meta → Ctrl, ctrl → Ctrl, alt → Alt, shift → Shift
55
+ * @example "meta", "shift", "K", "enter", "escape"
56
+ */
57
+ value?: string;
58
+ /**
59
+ * Sets the color scheme applied to the kbd.
60
+ * @default 'surface'
61
+ */
62
+ color?: NonNullable<KbdVariantProps['color']>;
63
+ /**
64
+ * Controls the dimensions and text size of the kbd.
65
+ * @default 'md'
66
+ */
67
+ size?: NonNullable<KbdVariantProps['size']>;
68
+ /**
69
+ * Controls the visual style of the kbd.
70
+ * @default 'outline'
71
+ */
72
+ variant?: NonNullable<KbdVariantProps['variant']>;
73
+ /**
74
+ * Additional CSS classes for the root element.
75
+ */
76
+ class?: ClassNameValue;
77
+ };
@@ -0,0 +1 @@
1
+ export {};