@refraction-ui/astro 0.4.6 → 0.4.7
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/dist/app-shell/app-shell.ts +4 -1
- package/dist/app-shell/auth-shell.ts +4 -1
- package/dist/app-shell/page-shell.ts +4 -1
- package/dist/astro-file-tree/index.ts +1 -1
- package/dist/astro-icon-system/index.ts +1 -1
- package/dist/astro-theme/index.ts +2 -1
- package/dist/callout/index.ts +1 -1
- package/dist/card-grid/index.ts +1 -1
- package/dist/code-block/index.ts +1 -1
- package/dist/command-input/index.ts +1 -1
- package/dist/dropdown-menu/dropdown-menu.ts +6 -6
- package/dist/keyboard-shortcut/index.ts +5 -0
- package/dist/keyboard-shortcut/keyboard-shortcut.ts +87 -2
- package/dist/link-card/index.ts +1 -1
- package/dist/payment/index.ts +1 -1
- package/dist/skip-to-content/index.ts +1 -1
- package/dist/slider/index.ts +1 -1
- package/dist/steps/index.ts +1 -1
- package/dist/table-of-contents/index.ts +1 -1
- package/package.json +1 -1
|
@@ -131,7 +131,10 @@ function makeState(
|
|
|
131
131
|
// ---------------------------------------------------------------------------
|
|
132
132
|
|
|
133
133
|
export function createAppShell(config?: AppShellConfig): AppShellAPI {
|
|
134
|
-
const resolved: Required<AppShellConfig> = {
|
|
134
|
+
const resolved: Required<AppShellConfig> = {
|
|
135
|
+
...DEFAULTS,
|
|
136
|
+
...(config ? Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined)) : {})
|
|
137
|
+
} as Required<AppShellConfig>
|
|
135
138
|
|
|
136
139
|
// Internal mutable state
|
|
137
140
|
let sidebarOpen = false
|
|
@@ -47,7 +47,10 @@ const MAX_WIDTH_CLASSES: Record<AuthShellConfig['maxWidth'] & string, string> =
|
|
|
47
47
|
// ---------------------------------------------------------------------------
|
|
48
48
|
|
|
49
49
|
export function createAuthShell(config?: AuthShellConfig): AuthShellAPI {
|
|
50
|
-
const resolved: Required<AuthShellConfig> = {
|
|
50
|
+
const resolved: Required<AuthShellConfig> = {
|
|
51
|
+
...DEFAULTS,
|
|
52
|
+
...(config ? Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined)) : {})
|
|
53
|
+
} as Required<AuthShellConfig>
|
|
51
54
|
|
|
52
55
|
const containerParts: string[] = ['min-h-screen', 'flex', 'w-full']
|
|
53
56
|
|
|
@@ -67,7 +67,10 @@ const BACKGROUND_CLASSES: Record<NonNullable<SectionConfig['background']>, strin
|
|
|
67
67
|
// ---------------------------------------------------------------------------
|
|
68
68
|
|
|
69
69
|
export function createPageShell(config?: PageShellConfig): PageShellAPI {
|
|
70
|
-
const resolved: Required<PageShellConfig> = {
|
|
70
|
+
const resolved: Required<PageShellConfig> = {
|
|
71
|
+
...DEFAULTS,
|
|
72
|
+
...(config ? Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined)) : {})
|
|
73
|
+
} as Required<PageShellConfig>
|
|
71
74
|
|
|
72
75
|
function getSectionClasses(sectionConfig?: SectionConfig): string {
|
|
73
76
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as FileTree } from './astro-file-tree.astro';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as IconSystem } from './astro-icon-system.astro';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export { default as ThemeScript } from './ThemeScript.astro'
|
|
2
|
+
export { default as ThemeToggle } from './ThemeToggle.astro'
|
package/dist/callout/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './callout';
|
|
1
|
+
export * from './callout.ts';
|
package/dist/card-grid/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './card-grid.
|
|
1
|
+
export * from './card-grid.ts'
|
package/dist/code-block/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './code-block';
|
|
1
|
+
export * from './code-block.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './command-input'
|
|
1
|
+
export * from './command-input.ts'
|
|
@@ -90,23 +90,23 @@ export function createDropdownMenu(props: DropdownMenuProps = {}): DropdownMenuA
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const keyboardHandlers: KeyboardHandlerMap = {
|
|
93
|
-
[Keys.Escape]: (e) => {
|
|
93
|
+
[Keys.Escape]: (e: KeyboardEvent) => {
|
|
94
94
|
e.preventDefault()
|
|
95
95
|
closeMenu()
|
|
96
96
|
},
|
|
97
|
-
[Keys.ArrowDown]: (e) => {
|
|
97
|
+
[Keys.ArrowDown]: (e: KeyboardEvent) => {
|
|
98
98
|
e.preventDefault()
|
|
99
99
|
},
|
|
100
|
-
[Keys.ArrowUp]: (e) => {
|
|
100
|
+
[Keys.ArrowUp]: (e: KeyboardEvent) => {
|
|
101
101
|
e.preventDefault()
|
|
102
102
|
},
|
|
103
|
-
[Keys.Enter]: (e) => {
|
|
103
|
+
[Keys.Enter]: (e: KeyboardEvent) => {
|
|
104
104
|
e.preventDefault()
|
|
105
105
|
},
|
|
106
|
-
[Keys.Home]: (e) => {
|
|
106
|
+
[Keys.Home]: (e: KeyboardEvent) => {
|
|
107
107
|
e.preventDefault()
|
|
108
108
|
},
|
|
109
|
-
[Keys.End]: (e) => {
|
|
109
|
+
[Keys.End]: (e: KeyboardEvent) => {
|
|
110
110
|
e.preventDefault()
|
|
111
111
|
},
|
|
112
112
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AccessibilityProps } from '../shared/index.ts'
|
|
2
|
-
|
|
3
1
|
export interface ShortcutProps {
|
|
4
2
|
/** Key combination (e.g., ['Ctrl', 'K'] or ['Meta', 'Shift', 'P']) */
|
|
5
3
|
keys: string[]
|
|
@@ -151,3 +149,90 @@ export function createKeyboardShortcut(props: ShortcutProps): KeyboardShortcutAP
|
|
|
151
149
|
badgeAriaProps,
|
|
152
150
|
}
|
|
153
151
|
}
|
|
152
|
+
|
|
153
|
+
export const SANE_DEFAULTS: Record<string, string[]> = {
|
|
154
|
+
save: ['Meta', 's'],
|
|
155
|
+
search: ['Meta', 'k'],
|
|
156
|
+
close: ['Escape'],
|
|
157
|
+
submit: ['Meta', 'Enter'],
|
|
158
|
+
undo: ['Meta', 'z'],
|
|
159
|
+
redo: ['Meta', 'Shift', 'z'],
|
|
160
|
+
copy: ['Meta', 'c'],
|
|
161
|
+
paste: ['Meta', 'v'],
|
|
162
|
+
cut: ['Meta', 'x'],
|
|
163
|
+
new: ['Meta', 'n'],
|
|
164
|
+
print: ['Meta', 'p'],
|
|
165
|
+
help: ['?'],
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export class ShortcutRegistry {
|
|
169
|
+
private shortcuts: Map<string, () => void> = new Map();
|
|
170
|
+
|
|
171
|
+
register(keys: string[], handler: () => void) {
|
|
172
|
+
const keyStr = keys.map(k => k.toLowerCase()).sort().join('+');
|
|
173
|
+
if (this.shortcuts.has(keyStr)) {
|
|
174
|
+
console.warn(`Shortcut ${keyStr} is already registered.`);
|
|
175
|
+
}
|
|
176
|
+
this.shortcuts.set(keyStr, handler);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
unregister(keys: string[]) {
|
|
180
|
+
const keyStr = keys.map(k => k.toLowerCase()).sort().join('+');
|
|
181
|
+
this.shortcuts.delete(keyStr);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const globalShortcutRegistry = new ShortcutRegistry();
|
|
186
|
+
|
|
187
|
+
export class AltHintState {
|
|
188
|
+
private showHints = false;
|
|
189
|
+
private listeners: Set<(show: boolean) => void> = new Set();
|
|
190
|
+
private initialized = false;
|
|
191
|
+
|
|
192
|
+
init() {
|
|
193
|
+
if (this.initialized || typeof window === 'undefined') return;
|
|
194
|
+
this.initialized = true;
|
|
195
|
+
|
|
196
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
197
|
+
if (e.key === 'Alt') {
|
|
198
|
+
this.setShowHints(true);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const handleKeyUp = (e: KeyboardEvent) => {
|
|
203
|
+
if (e.key === 'Alt') {
|
|
204
|
+
this.setShowHints(false);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const handleBlur = () => {
|
|
209
|
+
this.setShowHints(false);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
213
|
+
window.addEventListener('keyup', handleKeyUp);
|
|
214
|
+
window.addEventListener('blur', handleBlur);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
private setShowHints(value: boolean) {
|
|
218
|
+
if (this.showHints !== value) {
|
|
219
|
+
this.showHints = value;
|
|
220
|
+
this.listeners.forEach((listener) => listener(value));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
subscribe(listener: (show: boolean) => void) {
|
|
225
|
+
this.listeners.add(listener);
|
|
226
|
+
listener(this.showHints);
|
|
227
|
+
return () => {
|
|
228
|
+
this.listeners.delete(listener);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
get snapshot() {
|
|
233
|
+
return this.showHints;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const altHintState = new AltHintState();
|
|
238
|
+
|
package/dist/link-card/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './link-card.
|
|
1
|
+
export * from './link-card.ts'
|
package/dist/payment/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './payment.
|
|
1
|
+
export * from './payment.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './skip-to-content';
|
|
1
|
+
export * from './skip-to-content.ts';
|
package/dist/slider/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './slider.
|
|
1
|
+
export * from './slider.ts'
|
package/dist/steps/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './steps';
|
|
1
|
+
export * from './steps.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './table-of-contents'
|
|
1
|
+
export * from './table-of-contents.ts'
|