dssoca 0.11.0 → 0.13.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/dist/components/Accordion.svelte +35 -15
- package/dist/components/Accordion.svelte.d.ts +7 -0
- package/dist/components/Avatar.svelte +5 -9
- package/dist/components/Badge.svelte +27 -53
- package/dist/components/Badge.svelte.d.ts +2 -5
- package/dist/components/BottomNav.svelte +2 -2
- package/dist/components/BoxPlot.svelte +2 -8
- package/dist/components/BumpChart.svelte +2 -8
- package/dist/components/Button.svelte +50 -34
- package/dist/components/Button.svelte.d.ts +8 -2
- package/dist/components/Chart.svelte +2 -8
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +1 -1
- package/dist/components/Icon.svelte +29 -7
- package/dist/components/Icon.svelte.d.ts +14 -2
- package/dist/components/Input.svelte +1 -1
- package/dist/components/Kbd.svelte +120 -0
- package/dist/components/Kbd.svelte.d.ts +30 -0
- package/dist/components/LogStream.svelte +3 -3
- package/dist/components/Menu.svelte +1 -1
- package/dist/components/NumberField.svelte +1 -1
- package/dist/components/ScatterPlot.svelte +2 -8
- package/dist/components/SearchPalette.svelte +526 -0
- package/dist/components/SearchPalette.svelte.d.ts +82 -0
- package/dist/components/Select.svelte +1 -1
- package/dist/components/ServiceCard.svelte +13 -2
- package/dist/components/ShortcutsHelp.svelte +365 -0
- package/dist/components/ShortcutsHelp.svelte.d.ts +34 -0
- package/dist/components/Sidebar.svelte +1 -1
- package/dist/components/Spinner.svelte +26 -19
- package/dist/components/Spinner.svelte.d.ts +14 -4
- package/dist/components/Switch.svelte +32 -2
- package/dist/components/Switch.svelte.d.ts +5 -0
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/Topbar.svelte +41 -26
- package/dist/components/Topbar.svelte.d.ts +5 -2
- package/dist/config.d.ts +44 -3
- package/dist/config.js +52 -3
- package/dist/dssoca.config.d.ts +39 -2
- package/dist/dssoca.config.js +49 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.js +11 -4
- package/dist/palette.d.ts +10 -0
- package/dist/palette.js +17 -0
- package/dist/shortcuts.svelte.d.ts +192 -0
- package/dist/shortcuts.svelte.js +633 -0
- package/dist/theme.css +158 -158
- package/dist/tokens.css +158 -158
- package/package.json +4 -3
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { Attachment } from 'svelte/attachments';
|
|
2
|
+
/** Where a shortcut listens: everywhere, or only while focus is inside the attached element. */
|
|
3
|
+
export type ShortcutScope = 'global' | 'focus';
|
|
4
|
+
/** Modifier rendering family: Apple (⌘/⌥) vs everything else (Ctrl/Alt). */
|
|
5
|
+
export type ShortcutPlatform = 'apple' | 'other';
|
|
6
|
+
/** Presentation style for `formatShortcut`. */
|
|
7
|
+
export type ShortcutFormat = 'glyph' | 'label';
|
|
8
|
+
export interface ShortcutOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Stable unique identifier — the handle for `setEnabled` / `remap` and the
|
|
11
|
+
* key under which overrides persist. dssoca-owned shortcuts use the `ss:*`
|
|
12
|
+
* namespace; apps should pick their own prefix.
|
|
13
|
+
*/
|
|
14
|
+
id: string;
|
|
15
|
+
/** Human-readable action name (shown by ShortcutsHelp, read by AT). */
|
|
16
|
+
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* Key combo(s): `+`-joined modifiers (`mod`|`ctrl`|`alt`|`shift`|`meta`)
|
|
19
|
+
* plus exactly one key (lowercased `event.key`: `k`, `?`, `escape`,
|
|
20
|
+
* `arrowup`, `f1`). `mod` resolves to `meta` on Apple platforms and `ctrl`
|
|
21
|
+
* elsewhere. Comma separates alternatives (`'?, mod+/'`). Space is
|
|
22
|
+
* reserved (sequences are a parse error). Malformed input throws at
|
|
23
|
+
* registration time.
|
|
24
|
+
*/
|
|
25
|
+
keys: string;
|
|
26
|
+
/** Invoked when the shortcut fires (after `preventDefault` unless opted out). */
|
|
27
|
+
onPress: (event: KeyboardEvent) => void;
|
|
28
|
+
/** Optional grouping label for display (ShortcutsHelp sections). */
|
|
29
|
+
group?: string;
|
|
30
|
+
/**
|
|
31
|
+
* `'global'` (default) listens on `window`; `'focus'` only fires while the
|
|
32
|
+
* event target is inside the attached element — use via the `shortcut()`
|
|
33
|
+
* attachment (a focus-scoped shortcut without an element never fires).
|
|
34
|
+
*/
|
|
35
|
+
scope?: ShortcutScope;
|
|
36
|
+
/**
|
|
37
|
+
* Contextual availability gate owned by the registering code. A user-level
|
|
38
|
+
* `setEnabled(id, false)` override additionally silences the shortcut; the
|
|
39
|
+
* shortcut fires only when *both* agree.
|
|
40
|
+
*/
|
|
41
|
+
enabled?: boolean | (() => boolean);
|
|
42
|
+
/** Fire even when typing in inputs/textareas/selects/contenteditable. */
|
|
43
|
+
allowInInputs?: boolean;
|
|
44
|
+
/** Fire on held-key auto-repeat events. */
|
|
45
|
+
allowRepeat?: boolean;
|
|
46
|
+
/** Call `event.preventDefault()` before `onPress`. Default `true`. */
|
|
47
|
+
preventDefault?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** Read-only view of a registered shortcut (feeds ShortcutsHelp). */
|
|
50
|
+
export interface ShortcutInfo {
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
group?: string;
|
|
54
|
+
scope: ShortcutScope;
|
|
55
|
+
/** Effective canonical combo — the remap override when one is set. */
|
|
56
|
+
keys: string;
|
|
57
|
+
/** Canonical combo as registered (what `remap(id, null)` restores). */
|
|
58
|
+
defaultKeys: string;
|
|
59
|
+
/** Effective state: user override AND the registration's own `enabled`. */
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Per-shortcut user override (both fields optional and independent). */
|
|
63
|
+
export interface ShortcutOverride {
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
/** Canonical remapped combo string. */
|
|
66
|
+
keys?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Serializable snapshot of every user-facing shortcut setting — including the
|
|
70
|
+
* global `enabled` / `characterKeys` toggles (WCAG 2.1.4 compliance that
|
|
71
|
+
* resets every visit isn't compliance). Persist it wherever your app keeps
|
|
72
|
+
* preferences and feed it back through `applyOverrides`.
|
|
73
|
+
*/
|
|
74
|
+
export interface ShortcutOverrides {
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
characterKeys?: boolean;
|
|
77
|
+
shortcuts?: Record<string, ShortcutOverride>;
|
|
78
|
+
}
|
|
79
|
+
export interface FormatShortcutOptions {
|
|
80
|
+
/** `'glyph'` (default): `⌘K` / `Ctrl+K`. `'label'`: `Command+K` / `Ctrl+K`. */
|
|
81
|
+
format?: ShortcutFormat;
|
|
82
|
+
/** Defaults to the detected platform. */
|
|
83
|
+
platform?: ShortcutPlatform;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Canonical combo string for a captured keydown — feeds the editable
|
|
87
|
+
* ShortcutsHelp recorder. Modifier-only presses return `null` (the user is
|
|
88
|
+
* mid-chord; keep waiting). Shifted printables keep the produced character
|
|
89
|
+
* (`?`, never `shift+/`), matching the matcher's shift rule. The result may
|
|
90
|
+
* still fail `parseKeys` (e.g. the space key) — recorders validate via
|
|
91
|
+
* `remap`. File-level export — not part of the public barrel surface.
|
|
92
|
+
*/
|
|
93
|
+
export declare function comboFromEvent(event: KeyboardEvent): string | null;
|
|
94
|
+
/**
|
|
95
|
+
* Whether any alternative in `keys` is a combo the browser/OS reserves for
|
|
96
|
+
* tab/window control. Registration merely dev-warns (`warnReservedCombos`);
|
|
97
|
+
* the ShortcutsHelp recorder rejects these outright. Accepts the literal
|
|
98
|
+
* `ctrl+`/`meta+` forms a recorded event produces as well as `mod+`
|
|
99
|
+
* spellings. Throws on malformed input (same grammar as registration).
|
|
100
|
+
* File-level export — not part of the public barrel surface.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isReservedCombo(keys: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Detected modifier-rendering platform. File-level export for `<Kbd>`'s
|
|
105
|
+
* client-side correction effect — not part of the public barrel surface.
|
|
106
|
+
*/
|
|
107
|
+
export declare function detectPlatform(): ShortcutPlatform;
|
|
108
|
+
/**
|
|
109
|
+
* Module-singleton keyboard-shortcut registry (Svelte 5 runes; house pattern
|
|
110
|
+
* of `toast.svelte.ts`). One lazy `window` keydown listener (bubble phase)
|
|
111
|
+
* serves every registration: attached on the first browser-side `add()`,
|
|
112
|
+
* detached when the registry empties. Exactly one shortcut fires per event —
|
|
113
|
+
* focus-scoped beats global, last-registered wins within a tier.
|
|
114
|
+
*
|
|
115
|
+
* The class is intentionally NOT exported: a second instance would break the
|
|
116
|
+
* "exactly one fires" guarantee. Use the `shortcuts` singleton.
|
|
117
|
+
*/
|
|
118
|
+
declare class ShortcutRegistry {
|
|
119
|
+
#private;
|
|
120
|
+
/** Global kill switch (WCAG 2.1.4 "turn off"). */
|
|
121
|
+
enabled: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* When `false`, modifier-less ("character key") bindings never fire — the
|
|
124
|
+
* GitHub-style WCAG 2.1.4 switch. `mod+`/`ctrl+`/`alt+` combos are unaffected.
|
|
125
|
+
*/
|
|
126
|
+
characterKeys: boolean;
|
|
127
|
+
/** Reactive read-only list of registered shortcuts, registration order. */
|
|
128
|
+
readonly items: readonly ShortcutInfo[];
|
|
129
|
+
/**
|
|
130
|
+
* Register a shortcut; returns an idempotent disposer. Throws on a
|
|
131
|
+
* malformed `keys` string. On the server (no `window`) this is a full
|
|
132
|
+
* no-op that returns a working noop disposer.
|
|
133
|
+
*
|
|
134
|
+
* The optional `element` is supplied by the `shortcut()` attachment and
|
|
135
|
+
* anchors `scope: 'focus'` registrations.
|
|
136
|
+
*/
|
|
137
|
+
add(options: ShortcutOptions, element?: Element): () => void;
|
|
138
|
+
/** User-level enable/disable override for one shortcut (persists in overrides). */
|
|
139
|
+
setEnabled(id: string, enabled: boolean): void;
|
|
140
|
+
/**
|
|
141
|
+
* Rebind a shortcut to new keys (parsed/validated immediately — throws on
|
|
142
|
+
* malformed input). `remap(id, null)` removes the override, restoring the
|
|
143
|
+
* registered default.
|
|
144
|
+
*/
|
|
145
|
+
remap(id: string, keys: string | null): void;
|
|
146
|
+
/** Serializable snapshot of the global toggles + every per-id override. */
|
|
147
|
+
getOverrides(): ShortcutOverrides;
|
|
148
|
+
/**
|
|
149
|
+
* Merge a persisted overrides snapshot back in. Overrides for ids that are
|
|
150
|
+
* not (yet) registered are kept and take effect when the shortcut mounts.
|
|
151
|
+
* Malformed persisted combos are skipped with a dev warning (stale storage
|
|
152
|
+
* must not crash the app).
|
|
153
|
+
*/
|
|
154
|
+
applyOverrides(overrides: ShortcutOverrides): void;
|
|
155
|
+
/** Clear every per-id override and restore the global toggles to defaults. */
|
|
156
|
+
resetOverrides(): void;
|
|
157
|
+
}
|
|
158
|
+
/** The one app-wide shortcut registry. */
|
|
159
|
+
export declare const shortcuts: ShortcutRegistry;
|
|
160
|
+
/**
|
|
161
|
+
* `{@attach}` sugar over `shortcuts.add()`: registers on mount, cleans up on
|
|
162
|
+
* unmount, and re-registers reactively when a thunk's dependencies change.
|
|
163
|
+
* The attached element anchors `scope: 'focus'` shortcuts (they only fire
|
|
164
|
+
* while the event target is inside it).
|
|
165
|
+
*
|
|
166
|
+
* ```svelte
|
|
167
|
+
* <section {@attach shortcut(() => ({ id: 'app:save', label: 'Save', keys: 'mod+s', onPress: save }))}>
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export declare function shortcut(options: ShortcutOptions | (() => ShortcutOptions)): Attachment;
|
|
171
|
+
/**
|
|
172
|
+
* Structured form behind `formatShortcut`: one keycap-string array per
|
|
173
|
+
* comma-alternative (`'?, mod+/'` on other → `[['?'], ['Ctrl', '/']]`).
|
|
174
|
+
* File-level export so `<Kbd>` can render one `<kbd>` per key without
|
|
175
|
+
* re-deriving the glyph/label tables — not part of the public barrel surface.
|
|
176
|
+
* Throws on malformed input (same grammar as registration).
|
|
177
|
+
*/
|
|
178
|
+
export declare function formatShortcutParts(keys: string, options?: FormatShortcutOptions): string[][];
|
|
179
|
+
/**
|
|
180
|
+
* Human-readable rendering of a combo string, for `<Kbd>`-style display.
|
|
181
|
+
* Alternatives are joined with ` / `. Apple glyphs concatenate (`⌘K`, the
|
|
182
|
+
* macOS convention); everything else joins with `+` (`Ctrl+K`). Throws on
|
|
183
|
+
* malformed input (same grammar as registration).
|
|
184
|
+
*/
|
|
185
|
+
export declare function formatShortcut(keys: string, options?: FormatShortcutOptions): string;
|
|
186
|
+
/**
|
|
187
|
+
* The combo in `aria-keyshortcuts` spec syntax (`Meta+K`), with `mod`
|
|
188
|
+
* resolved for the given (default: detected) platform. Alternatives are
|
|
189
|
+
* space-separated per the spec. Throws on malformed input.
|
|
190
|
+
*/
|
|
191
|
+
export declare function ariaKeyshortcuts(keys: string, platform?: ShortcutPlatform): string;
|
|
192
|
+
export {};
|