svelte-incant 0.2.0 → 0.3.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.
- package/README.md +112 -57
- package/dist/combobox-example.svelte +6 -4
- package/dist/components/header.svelte +1 -1
- package/dist/components/ui/badge/badge.svelte +2 -2
- package/dist/components/ui/badge/badge.svelte.d.ts +1 -1
- package/dist/components/ui/badge/index.d.ts +1 -2
- package/dist/components/ui/badge/index.js +1 -2
- package/dist/components/ui/button/index.d.ts +1 -1
- package/dist/components/ui/button/index.js +2 -2
- package/dist/components/ui/card/index.d.ts +3 -3
- package/dist/components/ui/card/index.js +4 -4
- package/dist/components/ui/command/command-dialog.svelte +1 -1
- package/dist/components/ui/command/index.d.ts +5 -5
- package/dist/components/ui/command/index.js +6 -6
- package/dist/components/ui/input/index.d.ts +1 -1
- package/dist/components/ui/input/index.js +2 -2
- package/dist/components/ui/popover/index.d.ts +3 -3
- package/dist/components/ui/popover/index.js +4 -4
- package/dist/components/ui/tabs/index.d.ts +2 -2
- package/dist/components/ui/tabs/index.js +3 -3
- package/dist/index.d.ts +1 -5
- package/dist/index.js +1 -7
- package/dist/{attachment.svelte.js → package/attachment.svelte.js} +12 -6
- package/dist/{components → package/components}/kbds.svelte +9 -2
- package/dist/package/components/ui/dialog/dialog-close.svelte +32 -0
- package/dist/package/components/ui/dialog/dialog-content.svelte +138 -0
- package/dist/{components → package/components}/ui/dialog/dialog-content.svelte.d.ts +1 -1
- package/dist/{components → package/components}/ui/dialog/dialog-description.svelte +8 -2
- package/dist/package/components/ui/dialog/dialog-footer.svelte +35 -0
- package/dist/{components → package/components}/ui/dialog/dialog-footer.svelte.d.ts +1 -1
- package/dist/package/components/ui/dialog/dialog-header.svelte +35 -0
- package/dist/{components → package/components}/ui/dialog/dialog-header.svelte.d.ts +1 -1
- package/dist/package/components/ui/dialog/dialog-overlay.svelte +48 -0
- package/dist/{components → package/components}/ui/dialog/dialog-title.svelte +9 -2
- package/dist/{components → package/components}/ui/dialog/index.d.ts +7 -7
- package/dist/{components → package/components}/ui/dialog/index.js +8 -8
- package/dist/{components → package/components}/ui/kbd/index.d.ts +2 -2
- package/dist/{components → package/components}/ui/kbd/index.js +3 -3
- package/dist/package/components/ui/kbd/kbd-group.svelte +23 -0
- package/dist/package/components/ui/kbd/kbd.svelte +55 -0
- package/dist/{components → package/components}/ui/table/index.d.ts +2 -2
- package/dist/{components → package/components}/ui/table/index.js +2 -2
- package/dist/{components → package/components}/ui/table/table-body.svelte +8 -2
- package/dist/{components → package/components}/ui/table/table-body.svelte.d.ts +1 -1
- package/dist/{components → package/components}/ui/table/table-caption.svelte +10 -2
- package/dist/{components → package/components}/ui/table/table-caption.svelte.d.ts +1 -1
- package/dist/package/components/ui/table/table-cell.svelte +28 -0
- package/dist/{components → package/components}/ui/table/table-cell.svelte.d.ts +1 -1
- package/dist/package/components/ui/table/table-footer.svelte +32 -0
- package/dist/{components → package/components}/ui/table/table-footer.svelte.d.ts +1 -1
- package/dist/package/components/ui/table/table-head.svelte +32 -0
- package/dist/{components → package/components}/ui/table/table-head.svelte.d.ts +1 -1
- package/dist/{components → package/components}/ui/table/table-header.svelte +8 -2
- package/dist/{components → package/components}/ui/table/table-header.svelte.d.ts +1 -1
- package/dist/package/components/ui/table/table-row.svelte +35 -0
- package/dist/{components → package/components}/ui/table/table-row.svelte.d.ts +1 -1
- package/dist/package/components/ui/table/table.svelte +31 -0
- package/dist/{components → package/components}/ui/table/table.svelte.d.ts +1 -1
- package/dist/{components → package/components}/ui/tooltip/index.d.ts +4 -4
- package/dist/{components → package/components}/ui/tooltip/index.js +5 -5
- package/dist/package/components/ui/tooltip/tooltip-content.svelte +116 -0
- package/dist/{focus.svelte → package/focus.svelte} +17 -2
- package/dist/package/index.d.ts +6 -0
- package/dist/package/index.js +5 -0
- package/dist/package/overlay-component.svelte +47 -0
- package/dist/package/palette.svelte +272 -0
- package/dist/{palette.svelte.js → package/palette.svelte.js} +51 -33
- package/dist/package/utils.d.ts +11 -0
- package/dist/package/utils.js +31 -0
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -26
- package/package.json +20 -17
- package/dist/components/ui/dialog/dialog-close.svelte +0 -7
- package/dist/components/ui/dialog/dialog-content.svelte +0 -45
- package/dist/components/ui/dialog/dialog-footer.svelte +0 -20
- package/dist/components/ui/dialog/dialog-header.svelte +0 -20
- package/dist/components/ui/dialog/dialog-overlay.svelte +0 -20
- package/dist/components/ui/kbd/kbd-group.svelte +0 -20
- package/dist/components/ui/kbd/kbd.svelte +0 -25
- package/dist/components/ui/table/table-cell.svelte +0 -23
- package/dist/components/ui/table/table-footer.svelte +0 -20
- package/dist/components/ui/table/table-head.svelte +0 -23
- package/dist/components/ui/table/table-row.svelte +0 -23
- package/dist/components/ui/table/table.svelte +0 -22
- package/dist/components/ui/tooltip/tooltip-content.svelte +0 -52
- package/dist/overlay-component.svelte +0 -19
- package/dist/palette.svelte +0 -132
- package/dist/{attachment.svelte.d.ts → package/attachment.svelte.d.ts} +1 -1
- package/dist/{components → package/components}/kbds.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-close.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-description.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-overlay.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-portal.svelte +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-portal.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-title.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-trigger.svelte +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog-trigger.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog.svelte +0 -0
- package/dist/{components → package/components}/ui/dialog/dialog.svelte.d.ts +0 -0
- package/dist/{components → package/components}/ui/kbd/kbd-group.svelte.d.ts +1 -1
- package/dist/{components → package/components}/ui/kbd/kbd.svelte.d.ts +1 -1
- /package/dist/{components → package/components}/ui/tooltip/tooltip-content.svelte.d.ts +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-portal.svelte +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-portal.svelte.d.ts +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-provider.svelte +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-provider.svelte.d.ts +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-trigger.svelte +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip-trigger.svelte.d.ts +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip.svelte +0 -0
- /package/dist/{components → package/components}/ui/tooltip/tooltip.svelte.d.ts +0 -0
- /package/dist/{focus.svelte.d.ts → package/focus.svelte.d.ts} +0 -0
- /package/dist/{overlay-component.svelte.d.ts → package/overlay-component.svelte.d.ts} +0 -0
- /package/dist/{palette.svelte.d.ts → package/palette.svelte.d.ts} +0 -0
- /package/dist/{shortcut.svelte → package/shortcut.svelte} +0 -0
- /package/dist/{shortcut.svelte.d.ts → package/shortcut.svelte.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,42 +4,15 @@ A keyboard shortcut management library for Svelte 5.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Install the package:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
1. **Install and configure Tailwind CSS** (if not already):
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
bunx sv add tailwind
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
2. **Initialize shadcn-svelte** (if not already):
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
bunx shadcn-svelte@latest init
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Follow the official [shadcn-svelte installation guide](https://shadcn-svelte.com/docs/installation) for detailed instructions.
|
|
26
|
-
|
|
27
|
-
3. **Install the package** (peer dependencies are installed automatically):
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
bun add svelte-incant
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
4. **Add @source directive** to your CSS file where Tailwind is configured (e.g., `src/app.css` or similar):
|
|
34
|
-
|
|
35
|
-
```css
|
|
36
|
-
@import 'tailwindcss';
|
|
9
|
+
```bash
|
|
10
|
+
bun add svelte-incant
|
|
11
|
+
```
|
|
37
12
|
|
|
38
|
-
|
|
39
|
-
@source '../../node_modules/svelte-incant/**/*.{svelte,js,ts}';
|
|
13
|
+
Peer dependencies (`svelte`, `bits-ui`) will be installed automatically.
|
|
40
14
|
|
|
41
|
-
|
|
42
|
-
```
|
|
15
|
+
The package uses CSS custom properties (CSS variables) for styling, which work with any CSS framework or plain CSS.
|
|
43
16
|
|
|
44
17
|
## Usage
|
|
45
18
|
|
|
@@ -47,7 +20,7 @@ Add `Palette` component to your root layout to enable the shortcut overlay:
|
|
|
47
20
|
|
|
48
21
|
```svelte
|
|
49
22
|
<script>
|
|
50
|
-
|
|
23
|
+
import { Palette } from 'svelte-incant';
|
|
51
24
|
</script>
|
|
52
25
|
|
|
53
26
|
<Palette />
|
|
@@ -59,13 +32,13 @@ Register keyboard shortcuts with the `Shortcut` component:
|
|
|
59
32
|
|
|
60
33
|
```svelte
|
|
61
34
|
<script>
|
|
62
|
-
|
|
35
|
+
import { Shortcut } from 'svelte-incant';
|
|
63
36
|
</script>
|
|
64
37
|
|
|
65
38
|
<Shortcut
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
39
|
+
keys={['control', 's']}
|
|
40
|
+
description="Save document"
|
|
41
|
+
action={() => console.log('Save document')}
|
|
69
42
|
/>
|
|
70
43
|
```
|
|
71
44
|
|
|
@@ -73,11 +46,11 @@ For focusing elements (like inputs), use the `Focus` component:
|
|
|
73
46
|
|
|
74
47
|
```svelte
|
|
75
48
|
<script>
|
|
76
|
-
|
|
49
|
+
import { Focus } from 'svelte-incant';
|
|
77
50
|
</script>
|
|
78
51
|
|
|
79
52
|
<Focus keys={['control', 'e']} description="Focus search input">
|
|
80
|
-
|
|
53
|
+
<input type="text" placeholder="Search..." />
|
|
81
54
|
</Focus>
|
|
82
55
|
```
|
|
83
56
|
|
|
@@ -85,16 +58,16 @@ Or attach shortcuts directly to an element using the `@attach` directive:
|
|
|
85
58
|
|
|
86
59
|
```svelte
|
|
87
60
|
<script>
|
|
88
|
-
|
|
61
|
+
import { shortcut } from 'svelte-incant';
|
|
89
62
|
</script>
|
|
90
63
|
|
|
91
64
|
<input
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
type="text"
|
|
66
|
+
placeholder="Type something..."
|
|
67
|
+
{@attach shortcut({
|
|
68
|
+
keys: ['meta', 'i'],
|
|
69
|
+
description: 'Focus text input'
|
|
70
|
+
})}
|
|
98
71
|
/>
|
|
99
72
|
```
|
|
100
73
|
|
|
@@ -106,23 +79,77 @@ The `@attach` directive focuses the element it attaches to directly, as opposed
|
|
|
106
79
|
- **Route-specific Shortcuts**: Shortcuts only run when their component is mounted, allowing different shortcuts in different routes
|
|
107
80
|
- **Focus Management**: Easily manage focus states with keyboard shortcuts
|
|
108
81
|
- **Component-based**: Use components or directives to register shortcuts
|
|
109
|
-
- **
|
|
82
|
+
- **Framework Agnostic**: Works with any CSS framework or plain CSS using CSS custom properties
|
|
83
|
+
|
|
84
|
+
## Customization
|
|
85
|
+
|
|
86
|
+
The package uses CSS custom properties (CSS variables) for styling. You can override these in your global CSS to customize the appearance:
|
|
87
|
+
|
|
88
|
+
```css
|
|
89
|
+
/* Example: Customize colors */
|
|
90
|
+
:root {
|
|
91
|
+
--incant-colors-primary: hsl(210 100% 50%);
|
|
92
|
+
--incant-colors-primary-foreground: hsl(0 0% 100%);
|
|
93
|
+
--incant-kbd-bg: #1e293b;
|
|
94
|
+
--incant-kbd-color: #e2e8f0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Dark mode support */
|
|
98
|
+
.dark {
|
|
99
|
+
--incant-colors-background: hsl(240 10% 3.9%);
|
|
100
|
+
--incant-colors-foreground: hsl(0 0% 98%);
|
|
101
|
+
--incant-colors-primary: hsl(0 0% 98%);
|
|
102
|
+
--incant-colors-primary-foreground: hsl(240 5.9% 10%);
|
|
103
|
+
--incant-colors-muted: hsl(240 3.7% 15.9%);
|
|
104
|
+
--incant-colors-muted-foreground: hsl(240 5% 64.9%);
|
|
105
|
+
--incant-colors-border: hsl(240 3.7% 15.9%);
|
|
106
|
+
--incant-colors-overlay: hsla(0 0% 0% / 0.8);
|
|
107
|
+
--incant-kbd-bg: #374151;
|
|
108
|
+
--incant-kbd-color: #9ca3af;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
### Available CSS Variables
|
|
113
|
+
|
|
114
|
+
**Colors:**
|
|
115
|
+
|
|
116
|
+
- `--incant-colors-background`: Main background color
|
|
117
|
+
- `--incant-colors-foreground`: Main text color
|
|
118
|
+
- `--incant-colors-primary`: Primary button background
|
|
119
|
+
- `--incant-colors-primary-foreground`: Primary button text
|
|
120
|
+
- `--incant-colors-muted`: Muted background
|
|
121
|
+
- `--incant-colors-muted-foreground`: Muted text
|
|
122
|
+
- `--incant-colors-border`: Border color
|
|
123
|
+
- `--incant-colors-overlay`: Dialog overlay
|
|
124
|
+
- `--incant-kbd-bg`: Keyboard key background
|
|
125
|
+
- `--incant-kbd-color`: Keyboard key text
|
|
112
126
|
|
|
113
|
-
|
|
127
|
+
**Spacing:**
|
|
114
128
|
|
|
115
|
-
1
|
|
129
|
+
- `--incant-spacing-1`: 0.25rem
|
|
130
|
+
- `--incant-spacing-2`: 0.5rem
|
|
131
|
+
- `--incant-spacing-3`: 0.75rem
|
|
132
|
+
- `--incant-spacing-4`: 1rem
|
|
133
|
+
- `--incant-spacing-6`: 1.5rem
|
|
116
134
|
|
|
117
|
-
|
|
135
|
+
**Typography:**
|
|
118
136
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
- `--incant-font-size-xs`: 0.75rem
|
|
138
|
+
- `--incant-font-size-sm`: 0.875rem
|
|
139
|
+
- `--incant-font-size-lg`: 1.125rem
|
|
122
140
|
|
|
123
|
-
|
|
141
|
+
**Border Radius:**
|
|
124
142
|
|
|
125
|
-
|
|
143
|
+
- `--incant-radius-sm`: 0.25rem
|
|
144
|
+
- `--incant-radius-md`: 0.375rem
|
|
145
|
+
- `--incant-radius-lg`: 0.5rem
|
|
146
|
+
|
|
147
|
+
**Shadows:**
|
|
148
|
+
|
|
149
|
+
- `--incant-shadow-xs`: 0 1px 2px 0 rgba(0, 0, 0, 0.05)
|
|
150
|
+
- `--incant-shadow-lg`: 0 10px 15px -3px rgba(0, 0, 0, 0.1)
|
|
151
|
+
|
|
152
|
+
## Troubleshooting
|
|
126
153
|
|
|
127
154
|
### Peer dependency errors
|
|
128
155
|
|
|
@@ -135,3 +162,31 @@ bun list | grep -E "(bits-ui|runed|@lucide/svelte)"
|
|
|
135
162
|
# If missing, install them manually
|
|
136
163
|
bun add bits-ui runed @lucide/svelte
|
|
137
164
|
```
|
|
165
|
+
|
|
166
|
+
### Styles are missing
|
|
167
|
+
|
|
168
|
+
If components appear unstyled:
|
|
169
|
+
|
|
170
|
+
1. **Check CSS imports**: Make sure you have a CSS file that includes your styles.
|
|
171
|
+
2. **CSS variables**: The package relies on CSS custom properties. Make sure you're not overriding them unintentionally.
|
|
172
|
+
3. **Build your project**: Sometimes you need to restart your development server for changes to take effect.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Migration from v0.1.x
|
|
177
|
+
|
|
178
|
+
**v0.2.0 introduced a major change**: The library no longer requires Tailwind CSS and now uses CSS custom properties for styling. This makes the library more lightweight and framework-agnostic.
|
|
179
|
+
|
|
180
|
+
### What changed:
|
|
181
|
+
|
|
182
|
+
- **Removed dependency** on Tailwind CSS and shadcn-svelte
|
|
183
|
+
- **Replaced with** CSS custom properties for all styling
|
|
184
|
+
- **Improved compatibility** with any CSS framework or plain CSS
|
|
185
|
+
|
|
186
|
+
### If you're upgrading from v0.1.x:
|
|
187
|
+
|
|
188
|
+
1. **No code changes needed** - your components and shortcuts will work the same
|
|
189
|
+
2. **Optional**: If you want to customize appearance, use the CSS variables shown in the [Customization](#customization) section
|
|
190
|
+
3. **Optional**: Remove any Tailwind-specific configurations that were only needed for this library
|
|
191
|
+
|
|
192
|
+
The API remains identical, so existing code will continue to work without modification.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import { shortcut } from './attachment.svelte.js';
|
|
2
|
+
import CodeBlock from './components/CodeBlock.svelte';
|
|
4
3
|
import { Button } from './components/ui/button/index.js';
|
|
4
|
+
import * as Card from './components/ui/card';
|
|
5
5
|
import * as Command from './components/ui/command/index.js';
|
|
6
6
|
import * as Popover from './components/ui/popover/index.js';
|
|
7
7
|
import * as Tabs from './components/ui/tabs/index.js';
|
|
8
|
-
import
|
|
8
|
+
import { shortcut } from './package/attachment.svelte.js';
|
|
9
9
|
|
|
10
10
|
import { cn } from './utils.js';
|
|
11
11
|
import CheckIcon from '@lucide/svelte/icons/check';
|
|
@@ -121,7 +121,9 @@
|
|
|
121
121
|
closeAndFocusTrigger();
|
|
122
122
|
}}
|
|
123
123
|
>
|
|
124
|
-
<CheckIcon
|
|
124
|
+
<CheckIcon
|
|
125
|
+
class={cn(value !== framework.value ? 'text-transparent' : undefined)}
|
|
126
|
+
/>
|
|
125
127
|
{framework.label}
|
|
126
128
|
</Command.Item>
|
|
127
129
|
{/each}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { shortcut } from '..';
|
|
3
3
|
import { Button } from './ui/button/index.js';
|
|
4
|
-
import * as Kbd from '
|
|
4
|
+
import * as Kbd from '../package/components/ui/kbd/index.js';
|
|
5
5
|
import GithubIcon from '@lucide/svelte/icons/github';
|
|
6
6
|
import { useInterval } from 'runed';
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import { type VariantProps
|
|
2
|
+
import { tv, type VariantProps } from 'tailwind-variants';
|
|
3
3
|
|
|
4
4
|
export const badgeVariants = tv({
|
|
5
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',
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<script lang="ts">
|
|
25
|
-
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
26
25
|
import { cn, type WithElementRef } from '../../../utils.js';
|
|
26
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
27
27
|
|
|
28
28
|
let {
|
|
29
29
|
ref = $bindable(null),
|
|
@@ -22,8 +22,8 @@ export declare const badgeVariants: import("tailwind-variants").TVReturnType<{
|
|
|
22
22
|
};
|
|
23
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
24
|
export type BadgeVariant = VariantProps<typeof badgeVariants>['variant'];
|
|
25
|
-
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
26
25
|
import { type WithElementRef } from '../../../utils.js';
|
|
26
|
+
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
27
27
|
type $$ComponentProps = WithElementRef<HTMLAnchorAttributes> & {
|
|
28
28
|
variant?: BadgeVariant;
|
|
29
29
|
};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as Badge } from './badge.svelte';
|
|
2
|
-
export { badgeVariants, type BadgeVariant } from './badge.svelte';
|
|
1
|
+
export { default as Badge, badgeVariants, type BadgeVariant } from './badge.svelte';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { default as Badge } from './badge.svelte';
|
|
2
|
-
export { badgeVariants } from './badge.svelte';
|
|
1
|
+
export { default as Badge, badgeVariants } from './badge.svelte';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import Root, { type ButtonProps, type ButtonSize, type ButtonVariant, buttonVariants } from './button.svelte';
|
|
2
|
-
export { Root
|
|
2
|
+
export { Root as Button, buttonVariants, Root, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonProps as Props };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Action from './card-action.svelte';
|
|
2
2
|
import Content from './card-content.svelte';
|
|
3
3
|
import Description from './card-description.svelte';
|
|
4
4
|
import Footer from './card-footer.svelte';
|
|
5
5
|
import Header from './card-header.svelte';
|
|
6
6
|
import Title from './card-title.svelte';
|
|
7
|
-
import
|
|
8
|
-
export {
|
|
7
|
+
import Root from './card.svelte';
|
|
8
|
+
export { Action, Root as Card, Action as CardAction, Content as CardContent, Description as CardDescription, Footer as CardFooter, Header as CardHeader, Title as CardTitle, Content, Description, Footer, Header, Root, Title };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Action from './card-action.svelte';
|
|
2
2
|
import Content from './card-content.svelte';
|
|
3
3
|
import Description from './card-description.svelte';
|
|
4
4
|
import Footer from './card-footer.svelte';
|
|
5
5
|
import Header from './card-header.svelte';
|
|
6
6
|
import Title from './card-title.svelte';
|
|
7
|
-
import
|
|
8
|
-
export {
|
|
7
|
+
import Root from './card.svelte';
|
|
8
|
+
export { Action,
|
|
9
9
|
//
|
|
10
|
-
Root as Card, Content as CardContent, Description as CardDescription, Footer as CardFooter, Header as CardHeader, Title as CardTitle,
|
|
10
|
+
Root as Card, Action as CardAction, Content as CardContent, Description as CardDescription, Footer as CardFooter, Header as CardHeader, Title as CardTitle, Content, Description, Footer, Header, Root, Title };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { Command as CommandPrimitive, Dialog as DialogPrimitive } from 'bits-ui';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import Command from './command.svelte';
|
|
5
|
-
import * as Dialog from '
|
|
5
|
+
import * as Dialog from '../../../package/components/ui/dialog/index.js';
|
|
6
6
|
import type { WithoutChildrenOrChild } from '../../../utils.js';
|
|
7
7
|
|
|
8
8
|
let {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import Root from './command.svelte';
|
|
2
|
-
import Loading from './command-loading.svelte';
|
|
3
1
|
import Dialog from './command-dialog.svelte';
|
|
4
2
|
import Empty from './command-empty.svelte';
|
|
5
3
|
import Group from './command-group.svelte';
|
|
6
|
-
import Item from './command-item.svelte';
|
|
7
4
|
import Input from './command-input.svelte';
|
|
5
|
+
import Item from './command-item.svelte';
|
|
6
|
+
import LinkItem from './command-link-item.svelte';
|
|
8
7
|
import List from './command-list.svelte';
|
|
8
|
+
import Loading from './command-loading.svelte';
|
|
9
9
|
import Separator from './command-separator.svelte';
|
|
10
10
|
import Shortcut from './command-shortcut.svelte';
|
|
11
|
-
import
|
|
12
|
-
export { Root
|
|
11
|
+
import Root from './command.svelte';
|
|
12
|
+
export { Root as Command, Dialog as CommandDialog, Empty as CommandEmpty, Group as CommandGroup, Input as CommandInput, Item as CommandItem, LinkItem as CommandLinkItem, List as CommandList, Loading as CommandLoading, Separator as CommandSeparator, Shortcut as CommandShortcut, Dialog, Empty, Group, Input, Item, LinkItem, List, Loading, Root, Separator, Shortcut };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import Root from './command.svelte';
|
|
2
|
-
import Loading from './command-loading.svelte';
|
|
3
1
|
import Dialog from './command-dialog.svelte';
|
|
4
2
|
import Empty from './command-empty.svelte';
|
|
5
3
|
import Group from './command-group.svelte';
|
|
6
|
-
import Item from './command-item.svelte';
|
|
7
4
|
import Input from './command-input.svelte';
|
|
5
|
+
import Item from './command-item.svelte';
|
|
6
|
+
import LinkItem from './command-link-item.svelte';
|
|
8
7
|
import List from './command-list.svelte';
|
|
8
|
+
import Loading from './command-loading.svelte';
|
|
9
9
|
import Separator from './command-separator.svelte';
|
|
10
10
|
import Shortcut from './command-shortcut.svelte';
|
|
11
|
-
import
|
|
12
|
-
export {
|
|
11
|
+
import Root from './command.svelte';
|
|
12
|
+
export {
|
|
13
13
|
//
|
|
14
|
-
Root as Command, Dialog as CommandDialog, Empty as CommandEmpty, Group as CommandGroup, Item as CommandItem, LinkItem as CommandLinkItem,
|
|
14
|
+
Root as Command, Dialog as CommandDialog, Empty as CommandEmpty, Group as CommandGroup, Input as CommandInput, Item as CommandItem, LinkItem as CommandLinkItem, List as CommandList, Loading as CommandLoading, Separator as CommandSeparator, Shortcut as CommandShortcut, Dialog, Empty, Group, Input, Item, LinkItem, List, Loading, Root, Separator, Shortcut };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import Root from './input.svelte';
|
|
2
|
-
export { Root
|
|
2
|
+
export { Root as Input, Root };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Root from './popover.svelte';
|
|
2
1
|
import Close from './popover-close.svelte';
|
|
3
2
|
import Content from './popover-content.svelte';
|
|
4
|
-
import Trigger from './popover-trigger.svelte';
|
|
5
3
|
import Portal from './popover-portal.svelte';
|
|
6
|
-
|
|
4
|
+
import Trigger from './popover-trigger.svelte';
|
|
5
|
+
import Root from './popover.svelte';
|
|
6
|
+
export { Close, Content, Root as Popover, Close as PopoverClose, Content as PopoverContent, Portal as PopoverPortal, Trigger as PopoverTrigger, Portal, Root, Trigger };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import Root from './popover.svelte';
|
|
2
1
|
import Close from './popover-close.svelte';
|
|
3
2
|
import Content from './popover-content.svelte';
|
|
4
|
-
import Trigger from './popover-trigger.svelte';
|
|
5
3
|
import Portal from './popover-portal.svelte';
|
|
6
|
-
|
|
4
|
+
import Trigger from './popover-trigger.svelte';
|
|
5
|
+
import Root from './popover.svelte';
|
|
6
|
+
export { Close, Content,
|
|
7
7
|
//
|
|
8
|
-
Root as Popover, Content as PopoverContent,
|
|
8
|
+
Root as Popover, Close as PopoverClose, Content as PopoverContent, Portal as PopoverPortal, Trigger as PopoverTrigger, Portal, Root, Trigger };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Root from './tabs.svelte';
|
|
2
1
|
import Content from './tabs-content.svelte';
|
|
3
2
|
import List from './tabs-list.svelte';
|
|
4
3
|
import Trigger from './tabs-trigger.svelte';
|
|
5
|
-
|
|
4
|
+
import Root from './tabs.svelte';
|
|
5
|
+
export { Content, List, Root, Root as Tabs, Content as TabsContent, List as TabsList, Trigger as TabsTrigger, Trigger };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Root from './tabs.svelte';
|
|
2
1
|
import Content from './tabs-content.svelte';
|
|
3
2
|
import List from './tabs-list.svelte';
|
|
4
3
|
import Trigger from './tabs-trigger.svelte';
|
|
5
|
-
|
|
4
|
+
import Root from './tabs.svelte';
|
|
5
|
+
export { Content, List, Root,
|
|
6
6
|
//
|
|
7
|
-
Root as Tabs, Content as TabsContent, List as TabsList, Trigger as TabsTrigger };
|
|
7
|
+
Root as Tabs, Content as TabsContent, List as TabsList, Trigger as TabsTrigger, Trigger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { default as Shortcut } from './shortcut.svelte';
|
|
3
|
-
export { default as Focus } from './focus.svelte';
|
|
4
|
-
export { shortcut } from './attachment.svelte.js';
|
|
5
|
-
export { shortcuts } from './palette.svelte.js';
|
|
1
|
+
export * from './package/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { default as Palette } from './palette.svelte';
|
|
3
|
-
export { default as Shortcut } from './shortcut.svelte';
|
|
4
|
-
export { default as Focus } from './focus.svelte';
|
|
5
|
-
// Export functions
|
|
6
|
-
export { shortcut } from './attachment.svelte.js';
|
|
7
|
-
export { shortcuts } from './palette.svelte.js';
|
|
1
|
+
export * from './package/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { PressedKeys, watch } from 'runed';
|
|
1
2
|
import { mount, unmount } from 'svelte';
|
|
2
|
-
import { add_shortcut, remove_shortcut } from './palette.svelte.js';
|
|
3
3
|
import OverlayComponent from './overlay-component.svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { add_shortcut, remove_shortcut, shortcuts, slugify } from './palette.svelte.js';
|
|
5
5
|
const pressed_keys = new PressedKeys();
|
|
6
6
|
const voidElements = new Set([
|
|
7
7
|
'area',
|
|
@@ -47,10 +47,16 @@ function setupAnchor(element, targetNode, isVoidElement, keys) {
|
|
|
47
47
|
targetNode.appendChild(anchor);
|
|
48
48
|
return { anchor, instance };
|
|
49
49
|
}
|
|
50
|
-
function setupOutline(element) {
|
|
50
|
+
function setupOutline(element, keys) {
|
|
51
51
|
element.style.transition = 'outline 0s, outline-offset 0s';
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const slug = slugify(keys);
|
|
53
|
+
watch(() => {
|
|
54
|
+
const altPressed = pressed_keys.has('alt');
|
|
55
|
+
const shortcut = shortcuts[slug];
|
|
56
|
+
const isEnabled = shortcut?.enabled ?? true;
|
|
57
|
+
return altPressed && isEnabled;
|
|
58
|
+
}, (should_show_outline) => {
|
|
59
|
+
if (should_show_outline) {
|
|
54
60
|
element.style.outline = '2px dotted currentColor';
|
|
55
61
|
element.style.outlineOffset = '2px';
|
|
56
62
|
}
|
|
@@ -83,7 +89,7 @@ export function shortcut(shortcut) {
|
|
|
83
89
|
return () => { };
|
|
84
90
|
}
|
|
85
91
|
const { anchor, instance } = setupAnchor(element, targetNode, isVoidElement, shortcut.keys);
|
|
86
|
-
setupOutline(element);
|
|
92
|
+
setupOutline(element, shortcut.keys);
|
|
87
93
|
return () => {
|
|
88
94
|
unmount(instance);
|
|
89
95
|
anchor.remove();
|
|
@@ -31,12 +31,19 @@
|
|
|
31
31
|
});
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
|
-
<Kbd.Group class="
|
|
34
|
+
<Kbd.Group class="incant-kbds-container">
|
|
35
35
|
{#each formattedParts as part (part)}
|
|
36
36
|
{#if part.type === 'element'}
|
|
37
37
|
<Kbd.Root>{part.value}</Kbd.Root>
|
|
38
38
|
{:else}
|
|
39
|
-
<span class="
|
|
39
|
+
<span class="incant-kbds-separator">{part.value}</span>
|
|
40
40
|
{/if}
|
|
41
41
|
{/each}
|
|
42
42
|
</Kbd.Group>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.incant-kbds-separator {
|
|
46
|
+
margin: 0 var(--incant-spacing-1, 0.25rem);
|
|
47
|
+
color: var(--incant-colors-muted-foreground, hsl(240 3.8% 46.1%));
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Dialog as DialogPrimitive } from 'bits-ui';
|
|
3
|
+
|
|
4
|
+
let { ref = $bindable(null), ...restProps }: DialogPrimitive.CloseProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<DialogPrimitive.Close
|
|
8
|
+
bind:ref
|
|
9
|
+
data-slot="dialog-close"
|
|
10
|
+
class={['incant-dialog-close-button', restProps.class]}
|
|
11
|
+
{...restProps}
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
:global([data-slot='dialog-close']) {
|
|
16
|
+
border-radius: var(--incant-radius-sm, 0.25rem);
|
|
17
|
+
background: transparent;
|
|
18
|
+
border: none;
|
|
19
|
+
padding: 0.25rem;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
transition: opacity 0.2s;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:global([data-slot='dialog-close']:hover) {
|
|
25
|
+
opacity: 0.8;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:global([data-slot='dialog-close']:focus) {
|
|
29
|
+
outline: 2px solid var(--incant-colors-ring, hsl(240 5.9% 10%));
|
|
30
|
+
outline-offset: 2px;
|
|
31
|
+
}
|
|
32
|
+
</style>
|