svelte-incant 0.1.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 (157) hide show
  1. package/README.md +75 -0
  2. package/dist/attachment.svelte.d.ts +8 -0
  3. package/dist/attachment.svelte.js +93 -0
  4. package/dist/combobox-example.svelte +155 -0
  5. package/dist/combobox-example.svelte.d.ts +3 -0
  6. package/dist/components/CodeBlock.svelte +213 -0
  7. package/dist/components/CodeBlock.svelte.d.ts +12 -0
  8. package/dist/components/header.svelte +155 -0
  9. package/dist/components/header.svelte.d.ts +3 -0
  10. package/dist/components/kbds.svelte +31 -0
  11. package/dist/components/kbds.svelte.d.ts +7 -0
  12. package/dist/components/ui/badge/badge.svelte +49 -0
  13. package/dist/components/ui/badge/badge.svelte.d.ts +32 -0
  14. package/dist/components/ui/badge/index.d.ts +2 -0
  15. package/dist/components/ui/badge/index.js +2 -0
  16. package/dist/components/ui/button/button.svelte +82 -0
  17. package/dist/components/ui/button/button.svelte.d.ts +64 -0
  18. package/dist/components/ui/button/index.d.ts +2 -0
  19. package/dist/components/ui/button/index.js +4 -0
  20. package/dist/components/ui/card/card-action.svelte +20 -0
  21. package/dist/components/ui/card/card-action.svelte.d.ts +5 -0
  22. package/dist/components/ui/card/card-content.svelte +15 -0
  23. package/dist/components/ui/card/card-content.svelte.d.ts +5 -0
  24. package/dist/components/ui/card/card-description.svelte +20 -0
  25. package/dist/components/ui/card/card-description.svelte.d.ts +5 -0
  26. package/dist/components/ui/card/card-footer.svelte +20 -0
  27. package/dist/components/ui/card/card-footer.svelte.d.ts +5 -0
  28. package/dist/components/ui/card/card-header.svelte +23 -0
  29. package/dist/components/ui/card/card-header.svelte.d.ts +5 -0
  30. package/dist/components/ui/card/card-title.svelte +20 -0
  31. package/dist/components/ui/card/card-title.svelte.d.ts +5 -0
  32. package/dist/components/ui/card/card.svelte +23 -0
  33. package/dist/components/ui/card/card.svelte.d.ts +5 -0
  34. package/dist/components/ui/card/index.d.ts +8 -0
  35. package/dist/components/ui/card/index.js +10 -0
  36. package/dist/components/ui/command/command-dialog.svelte +40 -0
  37. package/dist/components/ui/command/command-dialog.svelte.d.ts +12 -0
  38. package/dist/components/ui/command/command-empty.svelte +17 -0
  39. package/dist/components/ui/command/command-empty.svelte.d.ts +4 -0
  40. package/dist/components/ui/command/command-group.svelte +30 -0
  41. package/dist/components/ui/command/command-group.svelte.d.ts +7 -0
  42. package/dist/components/ui/command/command-input.svelte +26 -0
  43. package/dist/components/ui/command/command-input.svelte.d.ts +4 -0
  44. package/dist/components/ui/command/command-item.svelte +20 -0
  45. package/dist/components/ui/command/command-item.svelte.d.ts +4 -0
  46. package/dist/components/ui/command/command-link-item.svelte +20 -0
  47. package/dist/components/ui/command/command-link-item.svelte.d.ts +4 -0
  48. package/dist/components/ui/command/command-list.svelte +17 -0
  49. package/dist/components/ui/command/command-list.svelte.d.ts +4 -0
  50. package/dist/components/ui/command/command-loading.svelte +7 -0
  51. package/dist/components/ui/command/command-loading.svelte.d.ts +4 -0
  52. package/dist/components/ui/command/command-separator.svelte +17 -0
  53. package/dist/components/ui/command/command-separator.svelte.d.ts +4 -0
  54. package/dist/components/ui/command/command-shortcut.svelte +20 -0
  55. package/dist/components/ui/command/command-shortcut.svelte.d.ts +5 -0
  56. package/dist/components/ui/command/command.svelte +28 -0
  57. package/dist/components/ui/command/command.svelte.d.ts +8 -0
  58. package/dist/components/ui/command/index.d.ts +12 -0
  59. package/dist/components/ui/command/index.js +14 -0
  60. package/dist/components/ui/dialog/dialog-close.svelte +7 -0
  61. package/dist/components/ui/dialog/dialog-close.svelte.d.ts +4 -0
  62. package/dist/components/ui/dialog/dialog-content.svelte +45 -0
  63. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +13 -0
  64. package/dist/components/ui/dialog/dialog-description.svelte +17 -0
  65. package/dist/components/ui/dialog/dialog-description.svelte.d.ts +4 -0
  66. package/dist/components/ui/dialog/dialog-footer.svelte +20 -0
  67. package/dist/components/ui/dialog/dialog-footer.svelte.d.ts +5 -0
  68. package/dist/components/ui/dialog/dialog-header.svelte +20 -0
  69. package/dist/components/ui/dialog/dialog-header.svelte.d.ts +5 -0
  70. package/dist/components/ui/dialog/dialog-overlay.svelte +20 -0
  71. package/dist/components/ui/dialog/dialog-overlay.svelte.d.ts +4 -0
  72. package/dist/components/ui/dialog/dialog-portal.svelte +7 -0
  73. package/dist/components/ui/dialog/dialog-portal.svelte.d.ts +3 -0
  74. package/dist/components/ui/dialog/dialog-title.svelte +17 -0
  75. package/dist/components/ui/dialog/dialog-title.svelte.d.ts +4 -0
  76. package/dist/components/ui/dialog/dialog-trigger.svelte +7 -0
  77. package/dist/components/ui/dialog/dialog-trigger.svelte.d.ts +4 -0
  78. package/dist/components/ui/dialog/dialog.svelte +7 -0
  79. package/dist/components/ui/dialog/dialog.svelte.d.ts +3 -0
  80. package/dist/components/ui/dialog/index.d.ts +11 -0
  81. package/dist/components/ui/dialog/index.js +13 -0
  82. package/dist/components/ui/input/index.d.ts +2 -0
  83. package/dist/components/ui/input/index.js +4 -0
  84. package/dist/components/ui/input/input.svelte +52 -0
  85. package/dist/components/ui/input/input.svelte.d.ts +13 -0
  86. package/dist/components/ui/kbd/index.d.ts +3 -0
  87. package/dist/components/ui/kbd/index.js +5 -0
  88. package/dist/components/ui/kbd/kbd-group.svelte +20 -0
  89. package/dist/components/ui/kbd/kbd-group.svelte.d.ts +5 -0
  90. package/dist/components/ui/kbd/kbd.svelte +25 -0
  91. package/dist/components/ui/kbd/kbd.svelte.d.ts +5 -0
  92. package/dist/components/ui/popover/index.d.ts +6 -0
  93. package/dist/components/ui/popover/index.js +8 -0
  94. package/dist/components/ui/popover/popover-close.svelte +7 -0
  95. package/dist/components/ui/popover/popover-close.svelte.d.ts +4 -0
  96. package/dist/components/ui/popover/popover-content.svelte +31 -0
  97. package/dist/components/ui/popover/popover-content.svelte.d.ts +10 -0
  98. package/dist/components/ui/popover/popover-portal.svelte +7 -0
  99. package/dist/components/ui/popover/popover-portal.svelte.d.ts +3 -0
  100. package/dist/components/ui/popover/popover-trigger.svelte +17 -0
  101. package/dist/components/ui/popover/popover-trigger.svelte.d.ts +4 -0
  102. package/dist/components/ui/popover/popover.svelte +7 -0
  103. package/dist/components/ui/popover/popover.svelte.d.ts +3 -0
  104. package/dist/components/ui/table/index.d.ts +9 -0
  105. package/dist/components/ui/table/index.js +11 -0
  106. package/dist/components/ui/table/table-body.svelte +20 -0
  107. package/dist/components/ui/table/table-body.svelte.d.ts +5 -0
  108. package/dist/components/ui/table/table-caption.svelte +20 -0
  109. package/dist/components/ui/table/table-caption.svelte.d.ts +5 -0
  110. package/dist/components/ui/table/table-cell.svelte +23 -0
  111. package/dist/components/ui/table/table-cell.svelte.d.ts +5 -0
  112. package/dist/components/ui/table/table-footer.svelte +20 -0
  113. package/dist/components/ui/table/table-footer.svelte.d.ts +5 -0
  114. package/dist/components/ui/table/table-head.svelte +23 -0
  115. package/dist/components/ui/table/table-head.svelte.d.ts +5 -0
  116. package/dist/components/ui/table/table-header.svelte +20 -0
  117. package/dist/components/ui/table/table-header.svelte.d.ts +5 -0
  118. package/dist/components/ui/table/table-row.svelte +23 -0
  119. package/dist/components/ui/table/table-row.svelte.d.ts +5 -0
  120. package/dist/components/ui/table/table.svelte +22 -0
  121. package/dist/components/ui/table/table.svelte.d.ts +5 -0
  122. package/dist/components/ui/tabs/index.d.ts +5 -0
  123. package/dist/components/ui/tabs/index.js +7 -0
  124. package/dist/components/ui/tabs/tabs-content.svelte +17 -0
  125. package/dist/components/ui/tabs/tabs-content.svelte.d.ts +4 -0
  126. package/dist/components/ui/tabs/tabs-list.svelte +20 -0
  127. package/dist/components/ui/tabs/tabs-list.svelte.d.ts +4 -0
  128. package/dist/components/ui/tabs/tabs-trigger.svelte +20 -0
  129. package/dist/components/ui/tabs/tabs-trigger.svelte.d.ts +4 -0
  130. package/dist/components/ui/tabs/tabs.svelte +19 -0
  131. package/dist/components/ui/tabs/tabs.svelte.d.ts +4 -0
  132. package/dist/components/ui/tooltip/index.d.ts +6 -0
  133. package/dist/components/ui/tooltip/index.js +8 -0
  134. package/dist/components/ui/tooltip/tooltip-content.svelte +52 -0
  135. package/dist/components/ui/tooltip/tooltip-content.svelte.d.ts +11 -0
  136. package/dist/components/ui/tooltip/tooltip-portal.svelte +7 -0
  137. package/dist/components/ui/tooltip/tooltip-portal.svelte.d.ts +4 -0
  138. package/dist/components/ui/tooltip/tooltip-provider.svelte +7 -0
  139. package/dist/components/ui/tooltip/tooltip-provider.svelte.d.ts +4 -0
  140. package/dist/components/ui/tooltip/tooltip-trigger.svelte +7 -0
  141. package/dist/components/ui/tooltip/tooltip-trigger.svelte.d.ts +4 -0
  142. package/dist/components/ui/tooltip/tooltip.svelte +7 -0
  143. package/dist/components/ui/tooltip/tooltip.svelte.d.ts +4 -0
  144. package/dist/focus.svelte +56 -0
  145. package/dist/focus.svelte.d.ts +13 -0
  146. package/dist/index.d.ts +5 -0
  147. package/dist/index.js +7 -0
  148. package/dist/overlay-component.svelte +19 -0
  149. package/dist/overlay-component.svelte.d.ts +6 -0
  150. package/dist/palette.svelte +132 -0
  151. package/dist/palette.svelte.d.ts +7 -0
  152. package/dist/palette.svelte.js +177 -0
  153. package/dist/shortcut.svelte +26 -0
  154. package/dist/shortcut.svelte.d.ts +8 -0
  155. package/dist/utils.d.ts +13 -0
  156. package/dist/utils.js +32 -0
  157. package/package.json +87 -0
@@ -0,0 +1,155 @@
1
+ <script lang="ts">
2
+ import { shortcut } from '..';
3
+ import { Button } from './ui/button/index.js';
4
+ import * as Kbd from './ui/kbd/index.js';
5
+ import GithubIcon from '@lucide/svelte/icons/github';
6
+ import { useInterval } from 'runed';
7
+
8
+ // All keyboard keys for the decorative background
9
+ const allKeys = [
10
+ 'A',
11
+ 'B',
12
+ 'C',
13
+ 'D',
14
+ 'E',
15
+ 'F',
16
+ 'G',
17
+ 'H',
18
+ 'I',
19
+ 'J',
20
+ 'K',
21
+ 'L',
22
+ 'M',
23
+ 'N',
24
+ 'O',
25
+ 'P',
26
+ 'Q',
27
+ 'R',
28
+ 'S',
29
+ 'T',
30
+ 'U',
31
+ 'V',
32
+ 'W',
33
+ 'X',
34
+ 'Y',
35
+ 'Z',
36
+ '1',
37
+ '2',
38
+ '3',
39
+ '4',
40
+ '5',
41
+ '6',
42
+ '7',
43
+ '8',
44
+ '9',
45
+ '0',
46
+ '⌘',
47
+ '⌥',
48
+ '⌃',
49
+ '⇧',
50
+ '⇥',
51
+ '↵',
52
+ '⌫',
53
+ '⎋',
54
+ '←',
55
+ '→',
56
+ '↑',
57
+ '↓',
58
+ '/',
59
+ '?',
60
+ '.',
61
+ ',',
62
+ ';',
63
+ "'",
64
+ '[',
65
+ ']'
66
+ ];
67
+
68
+ // Total number of keys to display
69
+ const totalKeys = 500;
70
+
71
+ // Helper to get a random key
72
+ function getRandomKey() {
73
+ return allKeys[Math.floor(Math.random() * allKeys.length)] ?? 'A';
74
+ }
75
+
76
+ // Helper to get random unique indices
77
+ function getRandomIndices(count: number, max: number): number[] {
78
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
79
+ const indices = new Set<number>();
80
+ while (indices.size < count) {
81
+ indices.add(Math.floor(Math.random() * max));
82
+ }
83
+ return Array.from(indices);
84
+ }
85
+
86
+ // Key cell type with unique id for transitions
87
+ type KeyCell = { id: number; key: string };
88
+
89
+ // Initialize with random keys as a flat array
90
+ let nextId = 0;
91
+ let keyboardKeys = $state<KeyCell[]>(
92
+ Array.from({ length: totalKeys }, () => ({ id: nextId++, key: getRandomKey() }))
93
+ );
94
+
95
+ useInterval(500, {
96
+ callback: () => {
97
+ const keysToChange = 7 + Math.floor(Math.random() * 4);
98
+ const indices = getRandomIndices(keysToChange, totalKeys);
99
+
100
+ for (const index of indices) {
101
+ keyboardKeys[index] = { id: nextId++, key: getRandomKey() };
102
+ }
103
+ }
104
+ });
105
+ </script>
106
+
107
+ <!-- Hero section with keyboard background -->
108
+ <header class="relative flex flex-col items-center justify-center overflow-hidden">
109
+ <!-- Decorative keyboard background -->
110
+ <!-- class="pointer-events-none absolute inset-0 grid place-content-center gap-1.5 p-1 select-none" -->
111
+ <div
112
+ class="pointer-events-none grid max-h-[40vh] w-full place-content-center gap-1.5 p-1 select-none"
113
+ style="grid-template-columns: repeat(auto-fit, 2rem); justify-content: center;"
114
+ aria-hidden="true"
115
+ >
116
+ {#each keyboardKeys as cell (cell.id)}
117
+ <span
118
+ class="inline-flex h-8 w-8 items-center justify-center rounded-sm border border-border/20 bg-muted/30 font-sans text-sm font-medium text-muted-foreground/30"
119
+ >
120
+ {cell.key}
121
+ </span>
122
+ {/each}
123
+ </div>
124
+
125
+ <!-- Gradient fade to white -->
126
+ <div
127
+ class="pointer-events-none absolute inset-0"
128
+ style="background: linear-gradient(to bottom, transparent 0%, transparent 40%, var(--background) 100%);"
129
+ ></div>
130
+
131
+ <!-- Header content -->
132
+ <div class="absolute bottom-16 z-10 space-y-4 px-4 text-center">
133
+ <h1 class="text-4xl font-bold tracking-tight">Svelte Incant</h1>
134
+ <p class="text-lg text-muted-foreground">
135
+ A keyboard shortcut management library for Svelte.
136
+ <br />
137
+ Press <Kbd.Root>?</Kbd.Root> to see it in action. Or hold <Kbd.Root>Alt</Kbd.Root> to see the shortcut
138
+ hints.
139
+ </p>
140
+ <div class="flex items-center justify-center gap-3 pt-4">
141
+ <Button
142
+ variant="outline"
143
+ href="https://github.com/mastermakrela/svelte-incant"
144
+ target="_blank"
145
+ {@attach shortcut({
146
+ keys: 'G',
147
+ description: 'Open GitHub'
148
+ })}
149
+ >
150
+ <GithubIcon class="mr-2 h-4 w-4" />
151
+ GitHub
152
+ </Button>
153
+ </div>
154
+ </div>
155
+ </header>
@@ -0,0 +1,3 @@
1
+ declare const Header: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type Header = ReturnType<typeof Header>;
3
+ export default Header;
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import * as Kbd from './ui/kbd/index.js';
3
+ import { keyToSymbol } from '../utils.js';
4
+
5
+ let {
6
+ keys,
7
+ separator = 'or'
8
+ }: {
9
+ keys: string | string[] | string[][];
10
+ separator?: string;
11
+ } = $props();
12
+
13
+ type KeyCombination = string[];
14
+
15
+ let keyGroups: KeyCombination[] = $derived(
16
+ typeof keys === 'string'
17
+ ? [[keys]]
18
+ : Array.isArray(keys) && keys.length > 0 && typeof keys[0] === 'string'
19
+ ? [keys as string[]]
20
+ : (keys as KeyCombination[])
21
+ );
22
+ </script>
23
+
24
+ <Kbd.Group class="text-xs">
25
+ {#each keyGroups as group, index (index)}
26
+ {#if index > 0}
27
+ <span class="mx-1 text-muted-foreground">{separator}</span>
28
+ {/if}
29
+ <Kbd.Root>{group.map(keyToSymbol).join(' ')}</Kbd.Root>
30
+ {/each}
31
+ </Kbd.Group>
@@ -0,0 +1,7 @@
1
+ type $$ComponentProps = {
2
+ keys: string | string[] | string[][];
3
+ separator?: string;
4
+ };
5
+ declare const Kbds: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type Kbds = ReturnType<typeof Kbds>;
7
+ export default Kbds;
@@ -0,0 +1,49 @@
1
+ <script lang="ts" module>
2
+ import { type VariantProps, tv } from 'tailwind-variants';
3
+
4
+ export const badgeVariants = tv({
5
+ base: 'focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3',
6
+ variants: {
7
+ variant: {
8
+ default: 'bg-primary text-primary-foreground [a&]:hover:bg-primary/90 border-transparent',
9
+ secondary:
10
+ 'bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90 border-transparent',
11
+ destructive:
12
+ 'bg-destructive [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/70 border-transparent text-white',
13
+ outline: 'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground'
14
+ }
15
+ },
16
+ defaultVariants: {
17
+ variant: 'default'
18
+ }
19
+ });
20
+
21
+ export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
26
+ import { cn, type WithElementRef } from '../../../utils.js';
27
+
28
+ let {
29
+ ref = $bindable(null),
30
+ href,
31
+ class: className,
32
+ variant = 'default',
33
+ children,
34
+ ...restProps
35
+ }: WithElementRef<HTMLAnchorAttributes> & {
36
+ variant?: BadgeVariant;
37
+ } = $props();
38
+ </script>
39
+
40
+ <svelte:element
41
+ this={href ? 'a' : 'span'}
42
+ bind:this={ref}
43
+ data-slot="badge"
44
+ {href}
45
+ class={cn(badgeVariants({ variant }), className)}
46
+ {...restProps}
47
+ >
48
+ {@render children?.()}
49
+ </svelte:element>
@@ -0,0 +1,32 @@
1
+ import { type VariantProps } from 'tailwind-variants';
2
+ export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
3
+ variant: {
4
+ default: string;
5
+ secondary: string;
6
+ destructive: string;
7
+ outline: string;
8
+ };
9
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3", {
10
+ variant: {
11
+ default: string;
12
+ secondary: string;
13
+ destructive: string;
14
+ outline: string;
15
+ };
16
+ }, undefined, import("tailwind-variants").TVReturnType<{
17
+ variant: {
18
+ default: string;
19
+ secondary: string;
20
+ destructive: string;
21
+ outline: string;
22
+ };
23
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3", unknown, unknown, undefined>>;
24
+ export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
25
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
26
+ import { type WithElementRef } from '../../../utils.js';
27
+ type $$ComponentProps = WithElementRef<HTMLAnchorAttributes> & {
28
+ variant?: BadgeVariant;
29
+ };
30
+ declare const Badge: import("svelte").Component<$$ComponentProps, {}, "ref">;
31
+ type Badge = ReturnType<typeof Badge>;
32
+ export default Badge;
@@ -0,0 +1,2 @@
1
+ export { default as Badge } from './badge.svelte';
2
+ export { badgeVariants, type BadgeVariant } from './badge.svelte';
@@ -0,0 +1,2 @@
1
+ export { default as Badge } from './badge.svelte';
2
+ export { badgeVariants } from './badge.svelte';
@@ -0,0 +1,82 @@
1
+ <script lang="ts" module>
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
4
+ import { type VariantProps, tv } from 'tailwind-variants';
5
+
6
+ export const buttonVariants = tv({
7
+ base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ variants: {
9
+ variant: {
10
+ default: 'bg-primary text-primary-foreground hover:bg-primary/90 shadow-xs',
11
+ destructive:
12
+ 'bg-destructive hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white shadow-xs',
13
+ outline:
14
+ 'bg-background hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border shadow-xs',
15
+ secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-xs',
16
+ ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
17
+ link: 'text-primary underline-offset-4 hover:underline'
18
+ },
19
+ size: {
20
+ default: 'h-9 px-4 py-2 has-[>svg]:px-3',
21
+ sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
22
+ lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
23
+ icon: 'size-9',
24
+ 'icon-sm': 'size-8',
25
+ 'icon-lg': 'size-10'
26
+ }
27
+ },
28
+ defaultVariants: {
29
+ variant: 'default',
30
+ size: 'default'
31
+ }
32
+ });
33
+
34
+ export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
35
+ export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
36
+
37
+ export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
38
+ WithElementRef<HTMLAnchorAttributes> & {
39
+ variant?: ButtonVariant;
40
+ size?: ButtonSize;
41
+ };
42
+ </script>
43
+
44
+ <script lang="ts">
45
+ let {
46
+ class: className,
47
+ variant = 'default',
48
+ size = 'default',
49
+ ref = $bindable(null),
50
+ href = undefined,
51
+ type = 'button',
52
+ disabled,
53
+ children,
54
+ ...restProps
55
+ }: ButtonProps = $props();
56
+ </script>
57
+
58
+ {#if href}
59
+ <a
60
+ bind:this={ref}
61
+ data-slot="button"
62
+ class={cn(buttonVariants({ variant, size }), className)}
63
+ href={disabled ? undefined : href}
64
+ aria-disabled={disabled}
65
+ role={disabled ? 'link' : undefined}
66
+ tabindex={disabled ? -1 : undefined}
67
+ {...restProps}
68
+ >
69
+ {@render children?.()}
70
+ </a>
71
+ {:else}
72
+ <button
73
+ bind:this={ref}
74
+ data-slot="button"
75
+ class={cn(buttonVariants({ variant, size }), className)}
76
+ {type}
77
+ {disabled}
78
+ {...restProps}
79
+ >
80
+ {@render children?.()}
81
+ </button>
82
+ {/if}
@@ -0,0 +1,64 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
3
+ import { type VariantProps } from 'tailwind-variants';
4
+ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
5
+ variant: {
6
+ default: string;
7
+ destructive: string;
8
+ outline: string;
9
+ secondary: string;
10
+ ghost: string;
11
+ link: string;
12
+ };
13
+ size: {
14
+ default: string;
15
+ sm: string;
16
+ lg: string;
17
+ icon: string;
18
+ 'icon-sm': string;
19
+ 'icon-lg': string;
20
+ };
21
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
22
+ variant: {
23
+ default: string;
24
+ destructive: string;
25
+ outline: string;
26
+ secondary: string;
27
+ ghost: string;
28
+ link: string;
29
+ };
30
+ size: {
31
+ default: string;
32
+ sm: string;
33
+ lg: string;
34
+ icon: string;
35
+ 'icon-sm': string;
36
+ 'icon-lg': string;
37
+ };
38
+ }, undefined, import("tailwind-variants").TVReturnType<{
39
+ variant: {
40
+ default: string;
41
+ destructive: string;
42
+ outline: string;
43
+ secondary: string;
44
+ ghost: string;
45
+ link: string;
46
+ };
47
+ size: {
48
+ default: string;
49
+ sm: string;
50
+ lg: string;
51
+ icon: string;
52
+ 'icon-sm': string;
53
+ 'icon-lg': string;
54
+ };
55
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", unknown, unknown, undefined>>;
56
+ export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
57
+ export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
58
+ export type ButtonProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
59
+ variant?: ButtonVariant;
60
+ size?: ButtonSize;
61
+ };
62
+ declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
63
+ type Button = ReturnType<typeof Button>;
64
+ export default Button;
@@ -0,0 +1,2 @@
1
+ import Root, { type ButtonProps, type ButtonSize, type ButtonVariant, buttonVariants } from './button.svelte';
2
+ export { Root, type ButtonProps as Props, Root as Button, buttonVariants, type ButtonProps, type ButtonSize, type ButtonVariant };
@@ -0,0 +1,4 @@
1
+ import Root, { buttonVariants } from './button.svelte';
2
+ export { Root,
3
+ //
4
+ Root as Button, buttonVariants };
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="card-action"
16
+ class={cn('col-start-2 row-span-2 row-start-1 self-start justify-self-end', className)}
17
+ {...restProps}
18
+ >
19
+ {@render children?.()}
20
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const CardAction: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CardAction = ReturnType<typeof CardAction>;
5
+ export default CardAction;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div bind:this={ref} data-slot="card-content" class={cn('px-6', className)} {...restProps}>
14
+ {@render children?.()}
15
+ </div>
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ declare const CardContent: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CardContent = ReturnType<typeof CardContent>;
5
+ export default CardContent;
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLParagraphElement>> = $props();
11
+ </script>
12
+
13
+ <p
14
+ bind:this={ref}
15
+ data-slot="card-description"
16
+ class={cn('text-sm text-muted-foreground', className)}
17
+ {...restProps}
18
+ >
19
+ {@render children?.()}
20
+ </p>
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ declare const CardDescription: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLParagraphElement>>, {}, "ref">;
4
+ type CardDescription = ReturnType<typeof CardDescription>;
5
+ export default CardDescription;
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="card-footer"
16
+ class={cn('flex items-center px-6 [.border-t]:pt-6', className)}
17
+ {...restProps}
18
+ >
19
+ {@render children?.()}
20
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const CardFooter: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CardFooter = ReturnType<typeof CardFooter>;
5
+ export default CardFooter;
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="card-header"
16
+ class={cn(
17
+ '@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6',
18
+ className
19
+ )}
20
+ {...restProps}
21
+ >
22
+ {@render children?.()}
23
+ </div>
@@ -0,0 +1,5 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ declare const CardHeader: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CardHeader = ReturnType<typeof CardHeader>;
5
+ export default CardHeader;
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="card-title"
16
+ class={cn('leading-none font-semibold', className)}
17
+ {...restProps}
18
+ >
19
+ {@render children?.()}
20
+ </div>
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ declare const CardTitle: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type CardTitle = ReturnType<typeof CardTitle>;
5
+ export default CardTitle;
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { cn, type WithElementRef } from '../../../utils.js';
4
+
5
+ let {
6
+ ref = $bindable(null),
7
+ class: className,
8
+ children,
9
+ ...restProps
10
+ }: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
11
+ </script>
12
+
13
+ <div
14
+ bind:this={ref}
15
+ data-slot="card"
16
+ class={cn(
17
+ 'flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm',
18
+ className
19
+ )}
20
+ {...restProps}
21
+ >
22
+ {@render children?.()}
23
+ </div>
@@ -0,0 +1,5 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import { type WithElementRef } from '../../../utils.js';
3
+ declare const Card: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
4
+ type Card = ReturnType<typeof Card>;
5
+ export default Card;
@@ -0,0 +1,8 @@
1
+ import Root from './card.svelte';
2
+ import Content from './card-content.svelte';
3
+ import Description from './card-description.svelte';
4
+ import Footer from './card-footer.svelte';
5
+ import Header from './card-header.svelte';
6
+ import Title from './card-title.svelte';
7
+ import Action from './card-action.svelte';
8
+ export { Root, Content, Description, Footer, Header, Title, Action, Root as Card, Content as CardContent, Description as CardDescription, Footer as CardFooter, Header as CardHeader, Title as CardTitle, Action as CardAction };