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.
Files changed (49) hide show
  1. package/dist/components/Accordion.svelte +35 -15
  2. package/dist/components/Accordion.svelte.d.ts +7 -0
  3. package/dist/components/Avatar.svelte +5 -9
  4. package/dist/components/Badge.svelte +27 -53
  5. package/dist/components/Badge.svelte.d.ts +2 -5
  6. package/dist/components/BottomNav.svelte +2 -2
  7. package/dist/components/BoxPlot.svelte +2 -8
  8. package/dist/components/BumpChart.svelte +2 -8
  9. package/dist/components/Button.svelte +50 -34
  10. package/dist/components/Button.svelte.d.ts +8 -2
  11. package/dist/components/Chart.svelte +2 -8
  12. package/dist/components/DateField.svelte +1 -1
  13. package/dist/components/FileDrop.svelte +1 -1
  14. package/dist/components/Icon.svelte +29 -7
  15. package/dist/components/Icon.svelte.d.ts +14 -2
  16. package/dist/components/Input.svelte +1 -1
  17. package/dist/components/Kbd.svelte +120 -0
  18. package/dist/components/Kbd.svelte.d.ts +30 -0
  19. package/dist/components/LogStream.svelte +3 -3
  20. package/dist/components/Menu.svelte +1 -1
  21. package/dist/components/NumberField.svelte +1 -1
  22. package/dist/components/ScatterPlot.svelte +2 -8
  23. package/dist/components/SearchPalette.svelte +526 -0
  24. package/dist/components/SearchPalette.svelte.d.ts +82 -0
  25. package/dist/components/Select.svelte +1 -1
  26. package/dist/components/ServiceCard.svelte +13 -2
  27. package/dist/components/ShortcutsHelp.svelte +365 -0
  28. package/dist/components/ShortcutsHelp.svelte.d.ts +34 -0
  29. package/dist/components/Sidebar.svelte +1 -1
  30. package/dist/components/Spinner.svelte +26 -19
  31. package/dist/components/Spinner.svelte.d.ts +14 -4
  32. package/dist/components/Switch.svelte +32 -2
  33. package/dist/components/Switch.svelte.d.ts +5 -0
  34. package/dist/components/Textarea.svelte +1 -1
  35. package/dist/components/Topbar.svelte +41 -26
  36. package/dist/components/Topbar.svelte.d.ts +5 -2
  37. package/dist/config.d.ts +44 -3
  38. package/dist/config.js +52 -3
  39. package/dist/dssoca.config.d.ts +39 -2
  40. package/dist/dssoca.config.js +49 -0
  41. package/dist/index.d.ts +10 -5
  42. package/dist/index.js +11 -4
  43. package/dist/palette.d.ts +10 -0
  44. package/dist/palette.js +17 -0
  45. package/dist/shortcuts.svelte.d.ts +192 -0
  46. package/dist/shortcuts.svelte.js +633 -0
  47. package/dist/theme.css +158 -158
  48. package/dist/tokens.css +158 -158
  49. package/package.json +4 -3
@@ -0,0 +1,365 @@
1
+ <script lang="ts">
2
+ // ─────────────────────────────────────────────────────────────────────────
3
+ // ShortcutsHelp (DS-0138). The GitHub/Slack/Linear "?" discovery overlay.
4
+ // Composes Modal — the native <dialog> hands us the focus trap, Esc-close,
5
+ // backdrop and focus return (SC 2.1.2 / 2.4.3) — and renders the LIVE
6
+ // registry state: groups, labels, effective bindings after remaps, and
7
+ // disabled shortcuts struck through with a visible "(off)" (SC 2.1.4 truth,
8
+ // never hidden).
9
+ //
10
+ // Its own hotkey goes through the registry like any consumer shortcut
11
+ // (id `ss:shortcuts-help`), so it lists itself and is disable-able and
12
+ // remappable. The default `'?, mod+/'` keeps discovery alive when the
13
+ // `characterKeys` kill switch is off ('?' dies, mod+/ survives) and under
14
+ // screen-reader browse mode.
15
+ // ─────────────────────────────────────────────────────────────────────────
16
+ import type { Snippet } from 'svelte'
17
+ import Modal from './Modal.svelte'
18
+ import Kbd from './Kbd.svelte'
19
+ import Button from './Button.svelte'
20
+ import Switch from './Switch.svelte'
21
+ import EmptyState from './EmptyState.svelte'
22
+ import {
23
+ shortcuts,
24
+ comboFromEvent,
25
+ isReservedCombo,
26
+ formatShortcut,
27
+ type ShortcutInfo,
28
+ } from '../shortcuts.svelte.js'
29
+
30
+ interface Props {
31
+ /** Whether the overlay is shown. Bindable — control it, or let the hotkey manage it. */
32
+ open?: boolean
33
+ /** Dialog title (wires the dialog's accessible name). @default 'Keyboard shortcuts' */
34
+ title?: string
35
+ /**
36
+ * Combo(s) that open the overlay, self-registered through the registry
37
+ * (id `ss:shortcuts-help`, group "General") — it appears in its own list
38
+ * and is itself disable-able/remappable. `null` registers nothing
39
+ * (wire your own visible trigger). @default '?, mod+/'
40
+ */
41
+ hotkey?: string | null
42
+ /**
43
+ * Explicit section order (group names). Unlisted groups follow in
44
+ * registration order; by default "General" (also the bucket for
45
+ * ungrouped shortcuts) comes last.
46
+ */
47
+ groupOrder?: string[]
48
+ /**
49
+ * Built-in WCAG 2.1.4 settings UI: every row gains an enable Switch
50
+ * (`setEnabled`), a Change button that records the next keydown as the
51
+ * new binding (`remap`; Esc cancels), and a Reset once remapped
52
+ * (`remap(id, null)`); a footer adds the global single-key kill switch
53
+ * (`characterKeys`) and Restore defaults (`resetOverrides`). Persistence
54
+ * stays app policy — see `getOverrides`/`applyOverrides`. @default false
55
+ */
56
+ editable?: boolean
57
+ /** Extra content rendered below the shortcut list. */
58
+ children?: Snippet
59
+ }
60
+
61
+ let {
62
+ open = $bindable(false),
63
+ title = 'Keyboard shortcuts',
64
+ hotkey = '?, mod+/',
65
+ groupOrder,
66
+ editable = false,
67
+ children,
68
+ }: Props = $props()
69
+
70
+ const FALLBACK_GROUP = 'General'
71
+
72
+ // Self-registration. `add()` returns the disposer, which doubles as the
73
+ // effect's cleanup: unmount unregisters, a `hotkey` change re-registers.
74
+ // Effects never run on the server, so SSR stays registration-free.
75
+ $effect(() => {
76
+ if (hotkey === null) return
77
+ return shortcuts.add({
78
+ id: 'ss:shortcuts-help',
79
+ label: 'Show keyboard shortcuts',
80
+ group: FALLBACK_GROUP,
81
+ keys: hotkey,
82
+ onPress: () => {
83
+ open = true
84
+ },
85
+ })
86
+ })
87
+
88
+ interface Group {
89
+ name: string
90
+ items: ShortcutInfo[]
91
+ }
92
+
93
+ // Live grouping of the registry: buckets in first-appearance order with
94
+ // "General" forced last; an explicit `groupOrder` lists its named groups
95
+ // first and the rest keep the default order.
96
+ const groups: Group[] = $derived.by(() => {
97
+ const buckets: Group[] = []
98
+ for (const item of shortcuts.items) {
99
+ const name = item.group ?? FALLBACK_GROUP
100
+ const bucket = buckets.find((g) => g.name === name)
101
+ if (bucket) bucket.items.push(item)
102
+ else buckets.push({ name, items: [item] })
103
+ }
104
+ let ordered = buckets.filter((g) => g.name !== FALLBACK_GROUP)
105
+ const general = buckets.find((g) => g.name === FALLBACK_GROUP)
106
+ if (general) ordered.push(general)
107
+ if (groupOrder?.length) {
108
+ const explicit = groupOrder
109
+ .map((n) => ordered.find((g) => g.name === n))
110
+ .filter((g): g is Group => g !== undefined)
111
+ ordered = [...explicit, ...ordered.filter((g) => !explicit.includes(g))]
112
+ }
113
+ return ordered
114
+ })
115
+
116
+ // ── Editable mode (DS-0141) — remap recorder + live announcements ────────
117
+ // One shortcut records at a time; `status` feeds the visible role="status"
118
+ // line, so prompts, results and rejections are both shown and announced.
119
+ let recordingId = $state<string | null>(null)
120
+ let status = $state('')
121
+
122
+ // Announcement-friendly words ("Control+Shift+S"), not glyphs.
123
+ const spoken = (keys: string) => formatShortcut(keys, { format: 'label' })
124
+
125
+ function startRecording(item: ShortcutInfo) {
126
+ recordingId = item.id
127
+ status = `Press the new shortcut for "${item.label}" — Escape cancels.`
128
+ }
129
+
130
+ function cancelRecording() {
131
+ recordingId = null
132
+ status = 'Shortcut change cancelled.'
133
+ }
134
+
135
+ function resetRow(item: ShortcutInfo) {
136
+ shortcuts.remap(item.id, null)
137
+ status = `"${item.label}" restored to ${spoken(item.defaultKeys)}.`
138
+ }
139
+
140
+ function restoreDefaults() {
141
+ recordingId = null
142
+ shortcuts.resetOverrides()
143
+ status = 'All shortcuts restored to their defaults.'
144
+ }
145
+
146
+ // While recording, a window-capture listener owns every keydown: it runs
147
+ // before anything else for keys pressed inside the dialog, and its
148
+ // preventDefault doubles as registry suppression (the matcher skips
149
+ // defaultPrevented events; the open modal already suppresses globals —
150
+ // SC 2.1.2). Modifier-only presses are a chord in progress; bare Escape
151
+ // cancels; everything else is validated through the registry parser via
152
+ // `remap` — reserved browser combos and unparseable keys are rejected with
153
+ // feedback and recording stays live for another try.
154
+ $effect(() => {
155
+ if (recordingId === null) return
156
+ const id = recordingId
157
+ const onKeydown = (event: KeyboardEvent) => {
158
+ event.preventDefault()
159
+ event.stopPropagation()
160
+ const combo = comboFromEvent(event)
161
+ if (combo === null) return
162
+ if (combo === 'escape') {
163
+ cancelRecording()
164
+ return
165
+ }
166
+ const label = shortcuts.items.find((i) => i.id === id)?.label ?? id
167
+ let reserved: boolean
168
+ try {
169
+ reserved = isReservedCombo(combo)
170
+ } catch {
171
+ status = 'That key cannot be used — try another combination.'
172
+ return
173
+ }
174
+ if (reserved) {
175
+ status = `${spoken(combo)} is reserved by the browser — try another combination.`
176
+ return
177
+ }
178
+ shortcuts.remap(id, combo)
179
+ recordingId = null
180
+ status = `"${label}" is now ${spoken(combo)}.`
181
+ }
182
+ window.addEventListener('keydown', onKeydown, true)
183
+ return () => window.removeEventListener('keydown', onKeydown, true)
184
+ })
185
+
186
+ // Closing the dialog (Esc, backdrop, trigger) abandons any recording and
187
+ // clears the status line so a reopen starts clean.
188
+ $effect(() => {
189
+ if (open) return
190
+ recordingId = null
191
+ status = ''
192
+ })
193
+ </script>
194
+
195
+ <Modal bind:open {title}>
196
+ <div class="ss-shortcuts-help">
197
+ {#if groups.length === 0}
198
+ <EmptyState
199
+ compact
200
+ icon="⌨"
201
+ headingLevel={3}
202
+ title="No shortcuts registered"
203
+ message="Shortcuts added through the dssoca registry will show up here."
204
+ />
205
+ {:else}
206
+ {#each groups as group (group.name)}
207
+ <section class="group">
208
+ <h3 class="gname">{group.name}</h3>
209
+ <dl class="rows">
210
+ <!-- Key by position too: duplicate ids are a dev warning in the
211
+ registry, not a render crash here. -->
212
+ {#each group.items as item, i (`${item.id}:${i}`)}
213
+ <div class="row" class:off={!item.enabled} class:recording={recordingId === item.id}>
214
+ <dt class="label">
215
+ <span class="txt">{item.label}</span>
216
+ {#if !item.enabled}<span class="off-tag">(off)</span>{/if}
217
+ </dt>
218
+ <dd class="keys">
219
+ {#if recordingId === item.id}
220
+ <span class="prompt">Press keys…</span>
221
+ {:else}
222
+ <Kbd keys={item.keys} />
223
+ {/if}
224
+ </dd>
225
+ {#if editable}
226
+ <dd class="controls">
227
+ {#if item.keys !== item.defaultKeys}
228
+ <Button
229
+ variant="ghost"
230
+ size="sm"
231
+ aria-label={`Reset the shortcut for "${item.label}" to its default`}
232
+ onclick={() => resetRow(item)}>Reset</Button
233
+ >
234
+ {/if}
235
+ <Button
236
+ variant="ghost"
237
+ size="sm"
238
+ aria-label={recordingId === item.id
239
+ ? `Recording a new shortcut for "${item.label}" — press keys, Escape cancels`
240
+ : `Change the shortcut for "${item.label}"`}
241
+ onclick={() =>
242
+ recordingId === item.id ? cancelRecording() : startRecording(item)}
243
+ >
244
+ {recordingId === item.id ? 'Cancel' : 'Change'}
245
+ </Button>
246
+ <Switch
247
+ size="sm"
248
+ labelHidden
249
+ label={`Enable the "${item.label}" shortcut`}
250
+ checked={item.enabled}
251
+ onchange={(on) => shortcuts.setEnabled(item.id, on)}
252
+ />
253
+ </dd>
254
+ {/if}
255
+ </div>
256
+ {/each}
257
+ </dl>
258
+ </section>
259
+ {/each}
260
+ {/if}
261
+ {#if editable}
262
+ <!-- WCAG 2.1.4 global remedies: the character-key kill switch and a
263
+ one-click way back. Persistence stays app policy (getOverrides). -->
264
+ <div class="globals">
265
+ <Switch
266
+ size="sm"
267
+ label="Single-key shortcuts"
268
+ checked={shortcuts.characterKeys}
269
+ onchange={(on) => (shortcuts.characterKeys = on)}
270
+ />
271
+ <Button variant="ghost" size="sm" onclick={restoreDefaults}>Restore defaults</Button>
272
+ </div>
273
+ <!-- Always-rendered live region: recording prompts, results and
274
+ rejections are announced as well as shown. -->
275
+ <p class="status" role="status">{status}</p>
276
+ {/if}
277
+ {#if children}
278
+ <div class="extra">{@render children()}</div>
279
+ {/if}
280
+ </div>
281
+ </Modal>
282
+
283
+ <style>.ss-shortcuts-help {
284
+ display: flex;
285
+ flex-direction: column;
286
+ gap: var(--ss-gap-sm);
287
+ font-size: var(--ss-size-sm);
288
+ }
289
+ .ss-shortcuts-help .group {
290
+ min-width: 0;
291
+ }
292
+ .ss-shortcuts-help .gname {
293
+ margin: 0;
294
+ font-family: var(--ss-font-mono);
295
+ font-size: var(--ss-ui-sm);
296
+ font-weight: 400;
297
+ color: var(--ss-fg-faint);
298
+ text-transform: uppercase;
299
+ letter-spacing: 0.06em;
300
+ }
301
+ .ss-shortcuts-help .rows {
302
+ margin: 0;
303
+ }
304
+ .ss-shortcuts-help .row {
305
+ display: flex;
306
+ align-items: center;
307
+ justify-content: space-between;
308
+ gap: var(--ss-gap-sm);
309
+ padding: var(--ss-s-2) 0;
310
+ border-bottom: 1px solid var(--ss-line);
311
+ }
312
+ .ss-shortcuts-help .row:last-child {
313
+ border-bottom: 0;
314
+ }
315
+ .ss-shortcuts-help .label {
316
+ margin: 0;
317
+ min-width: 0;
318
+ color: var(--ss-fg);
319
+ }
320
+ .ss-shortcuts-help .keys {
321
+ margin: 0;
322
+ flex: none;
323
+ }
324
+ .ss-shortcuts-help .controls {
325
+ margin: 0;
326
+ flex: none;
327
+ display: flex;
328
+ align-items: center;
329
+ gap: var(--ss-s-1);
330
+ }
331
+ .ss-shortcuts-help .row.recording {
332
+ background: var(--ss-primary-soft);
333
+ }
334
+ .ss-shortcuts-help .prompt {
335
+ font-family: var(--ss-font-mono);
336
+ font-size: var(--ss-ui-sm);
337
+ color: var(--ss-primary);
338
+ }
339
+ .ss-shortcuts-help .row.off .label {
340
+ color: var(--ss-fg-muted);
341
+ }
342
+ .ss-shortcuts-help .row.off .txt {
343
+ text-decoration: line-through;
344
+ }
345
+ .ss-shortcuts-help .off-tag {
346
+ margin-left: var(--ss-s-1);
347
+ color: var(--ss-fg-muted);
348
+ }
349
+ .ss-shortcuts-help .extra {
350
+ color: var(--ss-fg-muted);
351
+ }
352
+ .ss-shortcuts-help .globals {
353
+ display: flex;
354
+ align-items: center;
355
+ justify-content: space-between;
356
+ gap: var(--ss-gap-sm);
357
+ padding-top: var(--ss-s-2);
358
+ border-top: 1px solid var(--ss-line);
359
+ }
360
+ .ss-shortcuts-help .status {
361
+ margin: 0;
362
+ min-height: 1.4em;
363
+ font-size: var(--ss-ui-sm);
364
+ color: var(--ss-fg-muted);
365
+ }</style>
@@ -0,0 +1,34 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ /** Whether the overlay is shown. Bindable — control it, or let the hotkey manage it. */
4
+ open?: boolean;
5
+ /** Dialog title (wires the dialog's accessible name). @default 'Keyboard shortcuts' */
6
+ title?: string;
7
+ /**
8
+ * Combo(s) that open the overlay, self-registered through the registry
9
+ * (id `ss:shortcuts-help`, group "General") — it appears in its own list
10
+ * and is itself disable-able/remappable. `null` registers nothing
11
+ * (wire your own visible trigger). @default '?, mod+/'
12
+ */
13
+ hotkey?: string | null;
14
+ /**
15
+ * Explicit section order (group names). Unlisted groups follow in
16
+ * registration order; by default "General" (also the bucket for
17
+ * ungrouped shortcuts) comes last.
18
+ */
19
+ groupOrder?: string[];
20
+ /**
21
+ * Built-in WCAG 2.1.4 settings UI: every row gains an enable Switch
22
+ * (`setEnabled`), a Change button that records the next keydown as the
23
+ * new binding (`remap`; Esc cancels), and a Reset once remapped
24
+ * (`remap(id, null)`); a footer adds the global single-key kill switch
25
+ * (`characterKeys`) and Restore defaults (`resetOverrides`). Persistence
26
+ * stays app policy — see `getOverrides`/`applyOverrides`. @default false
27
+ */
28
+ editable?: boolean;
29
+ /** Extra content rendered below the shortcut list. */
30
+ children?: Snippet;
31
+ }
32
+ declare const ShortcutsHelp: import("svelte").Component<Props, {}, "open">;
33
+ type ShortcutsHelp = ReturnType<typeof ShortcutsHelp>;
34
+ export default ShortcutsHelp;
@@ -380,7 +380,7 @@
380
380
  }
381
381
  .ss-side .item.active {
382
382
  color: var(--ss-fg);
383
- background: rgba(var(--ss-primary-rgb), 0.06);
383
+ background: color-mix(in srgb, var(--ss-accent) 6%, transparent);
384
384
  border-left-color: var(--ss-primary);
385
385
  }
386
386
  .ss-side .item .label {
@@ -1,9 +1,22 @@
1
1
  <script module lang="ts">
2
+ import { type SpinnerVariant as SpinnerVariantName } from '../dssoca.config.js'
3
+
4
+ // Surfaced for backward compatibility (consumers importing from this component
5
+ // path); the source of truth is `dssoca.config.ts` (DS-0108). The const is a
6
+ // plain re-export; the type is aliased so it doesn't collide with the import.
7
+ export { SPINNER_VARIANT_NAMES } from '../dssoca.config.js'
8
+ export type SpinnerVariant = SpinnerVariantName
9
+
2
10
  /**
3
11
  * Text-frame spinner variants. Frames + intervals are embedded verbatim from
4
12
  * sindresorhus/cli-spinners (MIT — https://github.com/sindresorhus/cli-spinners),
5
13
  * curated for the squared/blocky glyphs that fit the DS's zero-radius look.
6
14
  * No runtime fetch, no dependency — just data.
15
+ *
16
+ * The *variant names* are owned by `dssoca.config.ts` (`SpinnerVariant`,
17
+ * derived from the `spinner` manifest axis — DS-0108); this object holds the
18
+ * frame data and is pinned to that union via `satisfies Record<SpinnerVariant,
19
+ * …>`, so the two cannot drift.
7
20
  */
8
21
  export interface SpinnerFrames {
9
22
  /** Milliseconds between frames (cli-spinners' recommended cadence). */
@@ -26,19 +39,19 @@
26
39
  interval: 120,
27
40
  frames: ['▏', '▎', '▍', '▌', '▋', '▊', '▉', '▊', '▋', '▌', '▍', '▎'],
28
41
  },
29
- } as const satisfies Record<string, SpinnerFrames>
30
-
31
- export type SpinnerVariant = keyof typeof SPINNER_VARIANTS
32
-
33
- export const SPINNER_VARIANT_NAMES = Object.keys(SPINNER_VARIANTS) as SpinnerVariant[]
42
+ } as const satisfies Record<SpinnerVariantName, SpinnerFrames>
34
43
  </script>
35
44
 
36
45
  <script lang="ts">
37
- import { resolveComponentSize, type Size } from '../config.js'
46
+ import { resolveComponentSize, resolveSpinnerVariant, type Size } from '../config.js'
38
47
 
39
48
  interface Props {
40
- /** Which frame set to animate (curated from cli-spinners, MIT). */
41
- variant?: SpinnerVariant
49
+ /**
50
+ * Which frame set to animate (curated from cli-spinners, MIT). When unset,
51
+ * falls back to the configured global default (`spinnerVariant`, default
52
+ * `boxBounce2`); an explicit value here always wins (DS-0108).
53
+ */
54
+ variant?: SpinnerVariantName
42
55
  /** Token size (sm|md|lg); inherits the global size when unset. */
43
56
  size?: Size
44
57
  /** Accessible name announced via role="status". */
@@ -50,19 +63,13 @@
50
63
  /** Any remaining native attributes are forwarded to the root span. */
51
64
  [key: string]: unknown
52
65
  }
53
- let {
54
- variant = 'boxBounce2',
55
- size,
56
- label = 'Loading',
57
- showLabel = false,
58
- speed,
59
- ...rest
60
- }: Props = $props()
66
+ let { variant, size, label = 'Loading', showLabel = false, speed, ...rest }: Props = $props()
61
67
 
62
- const spinner = $derived(SPINNER_VARIANTS[variant])
68
+ // An explicit `variant` prop wins; otherwise fall back to the configured
69
+ // house default (`spinnerVariant`, from the manifest) — DS-0108.
70
+ const resolvedVariant = $derived(resolveSpinnerVariant(variant))
71
+ const spinner = $derived(SPINNER_VARIANTS[resolvedVariant])
63
72
  const interval = $derived(speed ?? spinner.interval)
64
- // 'Spinner' is not in the ComponentName union yet (manifest is owned by the
65
- // integration step) — cast until dssoca.config.ts registers it.
66
73
  const resolvedSize = $derived(resolveComponentSize('Spinner', size))
67
74
 
68
75
  // Under prefers-reduced-motion the first frame renders statically — no cycling.
@@ -1,8 +1,16 @@
1
+ import { type SpinnerVariant as SpinnerVariantName } from '../dssoca.config.js';
2
+ export { SPINNER_VARIANT_NAMES } from '../dssoca.config.js';
3
+ export type SpinnerVariant = SpinnerVariantName;
1
4
  /**
2
5
  * Text-frame spinner variants. Frames + intervals are embedded verbatim from
3
6
  * sindresorhus/cli-spinners (MIT — https://github.com/sindresorhus/cli-spinners),
4
7
  * curated for the squared/blocky glyphs that fit the DS's zero-radius look.
5
8
  * No runtime fetch, no dependency — just data.
9
+ *
10
+ * The *variant names* are owned by `dssoca.config.ts` (`SpinnerVariant`,
11
+ * derived from the `spinner` manifest axis — DS-0108); this object holds the
12
+ * frame data and is pinned to that union via `satisfies Record<SpinnerVariant,
13
+ * …>`, so the two cannot drift.
6
14
  */
7
15
  export interface SpinnerFrames {
8
16
  /** Milliseconds between frames (cli-spinners' recommended cadence). */
@@ -52,12 +60,14 @@ export declare const SPINNER_VARIANTS: {
52
60
  readonly frames: readonly ["▏", "▎", "▍", "▌", "▋", "▊", "▉", "▊", "▋", "▌", "▍", "▎"];
53
61
  };
54
62
  };
55
- export type SpinnerVariant = keyof typeof SPINNER_VARIANTS;
56
- export declare const SPINNER_VARIANT_NAMES: SpinnerVariant[];
57
63
  import { type Size } from '../config.js';
58
64
  interface Props {
59
- /** Which frame set to animate (curated from cli-spinners, MIT). */
60
- variant?: SpinnerVariant;
65
+ /**
66
+ * Which frame set to animate (curated from cli-spinners, MIT). When unset,
67
+ * falls back to the configured global default (`spinnerVariant`, default
68
+ * `boxBounce2`); an explicit value here always wins (DS-0108).
69
+ */
70
+ variant?: SpinnerVariantName;
61
71
  /** Token size (sm|md|lg); inherits the global size when unset. */
62
72
  size?: Size;
63
73
  /** Accessible name announced via role="status". */
@@ -14,6 +14,11 @@
14
14
  checked?: boolean
15
15
  /** Visible label rendered adjacent to the track; becomes the accessible name. */
16
16
  label?: string
17
+ /**
18
+ * Visually hide the label while keeping it as the accessible name — for
19
+ * dense rows (settings lists) where the visible context sits elsewhere.
20
+ */
21
+ labelHidden?: boolean
17
22
  /** Id for the underlying button (label `for`-style association uses it). */
18
23
  id?: string
19
24
  /** Form field name (mirrored onto a data attribute for form integration). */
@@ -31,6 +36,7 @@
31
36
  let {
32
37
  checked = $bindable(false),
33
38
  label,
39
+ labelHidden = false,
34
40
  id,
35
41
  name,
36
42
  disabled = false,
@@ -55,7 +61,11 @@
55
61
  const sizeAttr = $derived(resolveComponentSize('Switch', size))
56
62
  </script>
57
63
 
58
- <span class="ss-switch" class:has-label={label != null} data-size-variant={sizeAttr}>
64
+ <span
65
+ class="ss-switch"
66
+ class:has-label={label != null && !labelHidden}
67
+ data-size-variant={sizeAttr}
68
+ >
59
69
  <button
60
70
  id={buttonId}
61
71
  type="button"
@@ -73,13 +83,22 @@
73
83
  </button>
74
84
  {#if label != null}
75
85
  <!-- Clicking the label toggles the switch (a11y: same target as the control). -->
76
- <span id={labelId} class="label" onclick={toggle} role="presentation">{label}</span>
86
+ <span
87
+ id={labelId}
88
+ class="label"
89
+ class:sr-only={labelHidden}
90
+ onclick={toggle}
91
+ role="presentation">{label}</span
92
+ >
77
93
  {/if}
78
94
  </span>
79
95
 
80
96
  <style>.ss-switch {
97
+ position: relative;
81
98
  display: inline-flex;
82
99
  align-items: center;
100
+ }
101
+ .ss-switch.has-label {
83
102
  gap: var(--ss-switch-gap, var(--ss-gap-sm));
84
103
  }
85
104
  .ss-switch .track {
@@ -131,6 +150,17 @@
131
150
  cursor: pointer;
132
151
  user-select: none;
133
152
  }
153
+ .ss-switch .label.sr-only {
154
+ position: absolute;
155
+ width: 1px;
156
+ height: 1px;
157
+ padding: 0;
158
+ margin: -1px;
159
+ overflow: hidden;
160
+ clip: rect(0, 0, 0, 0);
161
+ white-space: nowrap;
162
+ border: 0;
163
+ }
134
164
  .ss-switch:has(.track:disabled) .label {
135
165
  cursor: not-allowed;
136
166
  opacity: 0.45;
@@ -4,6 +4,11 @@ interface Props {
4
4
  checked?: boolean;
5
5
  /** Visible label rendered adjacent to the track; becomes the accessible name. */
6
6
  label?: string;
7
+ /**
8
+ * Visually hide the label while keeping it as the accessible name — for
9
+ * dense rows (settings lists) where the visible context sits elsewhere.
10
+ */
11
+ labelHidden?: boolean;
7
12
  /** Id for the underlying button (label `for`-style association uses it). */
8
13
  id?: string;
9
14
  /** Form field name (mirrored onto a data attribute for form integration). */
@@ -158,7 +158,7 @@
158
158
  }
159
159
  .ss-textarea.invalid .control:focus-within {
160
160
  border-color: var(--ss-red);
161
- box-shadow: 0 0 0 3px rgba(var(--ss-red-rgb), 0.22);
161
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--ss-danger) 22%, transparent);
162
162
  }
163
163
  .ss-textarea.disabled .control {
164
164
  border-color: var(--ss-line);