dssoca 0.17.0 → 0.20.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 (81) hide show
  1. package/README.md +9 -6
  2. package/dist/chart-nav.d.ts +13 -0
  3. package/dist/chart-nav.js +35 -0
  4. package/dist/components/Accordion.svelte +7 -2
  5. package/dist/components/Badge.svelte +12 -7
  6. package/dist/components/Badge.svelte.d.ts +2 -1
  7. package/dist/components/BottomNav.svelte +4 -0
  8. package/dist/components/BoxPlot.svelte +33 -7
  9. package/dist/components/BumpChart.svelte +68 -26
  10. package/dist/components/Button.svelte +23 -1
  11. package/dist/components/Button.svelte.d.ts +5 -1
  12. package/dist/components/Card.svelte +48 -15
  13. package/dist/components/Card.svelte.d.ts +10 -1
  14. package/dist/components/Chart.svelte +169 -32
  15. package/dist/components/Chart.svelte.d.ts +13 -1
  16. package/dist/components/DateField.svelte +1 -1
  17. package/dist/components/FileDrop.svelte +81 -14
  18. package/dist/components/FileDrop.svelte.d.ts +6 -0
  19. package/dist/components/Heatmap.svelte +128 -50
  20. package/dist/components/Heatmap.svelte.d.ts +2 -1
  21. package/dist/components/Icon.svelte +12 -3
  22. package/dist/components/Icon.svelte.d.ts +4 -0
  23. package/dist/components/Input.svelte +6 -3
  24. package/dist/components/Kbd.svelte +17 -1
  25. package/dist/components/Kbd.svelte.d.ts +9 -0
  26. package/dist/components/Link.svelte +25 -14
  27. package/dist/components/LogStream.svelte +34 -9
  28. package/dist/components/Menu.svelte +12 -8
  29. package/dist/components/Menu.svelte.d.ts +2 -2
  30. package/dist/components/MetricTile.svelte +16 -2
  31. package/dist/components/MetricTile.svelte.d.ts +6 -0
  32. package/dist/components/Modal.svelte +47 -7
  33. package/dist/components/Modal.svelte.d.ts +11 -3
  34. package/dist/components/NumberField.svelte +33 -10
  35. package/dist/components/Pagination.svelte +7 -4
  36. package/dist/components/ScatterPlot.svelte +44 -7
  37. package/dist/components/SearchPalette.svelte +102 -23
  38. package/dist/components/SearchPalette.svelte.d.ts +5 -0
  39. package/dist/components/SegmentedControl.svelte +14 -5
  40. package/dist/components/Select.svelte +3 -4
  41. package/dist/components/ServiceCard.svelte +108 -68
  42. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  43. package/dist/components/ShortcutsHelp.svelte +3 -2
  44. package/dist/components/Sidebar.svelte +84 -59
  45. package/dist/components/Sidebar.svelte.d.ts +5 -0
  46. package/dist/components/Switch.svelte +4 -8
  47. package/dist/components/Table.svelte +20 -13
  48. package/dist/components/Table.svelte.d.ts +6 -2
  49. package/dist/components/Textarea.svelte +1 -1
  50. package/dist/components/TierList.svelte +598 -0
  51. package/dist/components/TierList.svelte.d.ts +37 -0
  52. package/dist/components/Toaster.svelte +144 -21
  53. package/dist/components/Tooltip.svelte +101 -13
  54. package/dist/components/Tooltip.svelte.d.ts +1 -1
  55. package/dist/components/Topbar.svelte +39 -16
  56. package/dist/dssoca.config.d.ts +1 -1
  57. package/dist/dssoca.config.js +1 -0
  58. package/dist/icons.d.ts +20 -2
  59. package/dist/icons.js +43 -3
  60. package/dist/index.d.ts +3 -1
  61. package/dist/index.js +4 -1
  62. package/dist/theme.css +25 -27
  63. package/dist/tierlist-core.d.ts +97 -0
  64. package/dist/tierlist-core.js +206 -0
  65. package/dist/tokens.css +25 -0
  66. package/dist/vanilla/accordion.js +7 -3
  67. package/dist/vanilla/fields.js +19 -6
  68. package/dist/vanilla/index.d.ts +2 -1
  69. package/dist/vanilla/index.js +7 -4
  70. package/dist/vanilla/menu.js +12 -1
  71. package/dist/vanilla/modal.d.ts +4 -0
  72. package/dist/vanilla/modal.js +57 -2
  73. package/dist/vanilla/segmented.js +13 -4
  74. package/dist/vanilla/tierlist.d.ts +8 -0
  75. package/dist/vanilla/tierlist.js +300 -0
  76. package/dist/vanilla/toast.d.ts +11 -3
  77. package/dist/vanilla/toast.js +125 -10
  78. package/dist/vanilla/tooltip.d.ts +5 -1
  79. package/dist/vanilla/tooltip.js +57 -10
  80. package/dist/vanilla.css +581 -158
  81. package/package.json +4 -1
@@ -52,8 +52,8 @@ interface Props {
52
52
  /** Vertical side the panel opens toward. */
53
53
  side?: Side;
54
54
  /**
55
- * Accessible label for the panel (`role="menu"`). Falls back to the
56
- * trigger's text when omitted.
55
+ * Accessible label for the panel (`role="menu"`). When omitted the
56
+ * panel is named by the trigger's text via `aria-labelledby`.
57
57
  */
58
58
  label?: string;
59
59
  /** Token size (sm|md|lg); inherits the global size when unset. */
@@ -26,6 +26,12 @@
26
26
  emphasis?: boolean
27
27
  /** Skeleton/loading state: hides the real value behind aria-hidden bars. */
28
28
  loading?: boolean
29
+ /**
30
+ * Announce updates to assistive tech. When `true` the whole tile is one polite, atomic
31
+ * live region, so a change is read as "label value delta" rather than a bare number.
32
+ * Off by default: a grid of always-live tiles would talk over each other (DS-0191).
33
+ */
34
+ live?: boolean
29
35
  /** Snippet slot below the delta — drop in a <Sparkline> here. */
30
36
  chart?: Snippet
31
37
  /** Token size (sm|md|lg); inherits the global size when unset. */
@@ -42,6 +48,7 @@
42
48
  deltaLabel,
43
49
  emphasis = false,
44
50
  loading = false,
51
+ live = false,
45
52
  chart,
46
53
  size,
47
54
  }: Props = $props()
@@ -59,6 +66,9 @@
59
66
  class="ss-metric"
60
67
  data-size-variant={resolveComponentSize('MetricTile', size)}
61
68
  aria-busy={loading ? 'true' : undefined}
69
+ role={live ? 'status' : undefined}
70
+ aria-live={live ? 'polite' : undefined}
71
+ aria-atomic={live ? 'true' : undefined}
62
72
  >
63
73
  <div class="label">{label}</div>
64
74
 
@@ -66,7 +76,7 @@
66
76
  <div class="skeleton skeleton-val" aria-hidden="true"></div>
67
77
  {#if delta}<div class="skeleton skeleton-delta" aria-hidden="true"></div>{/if}
68
78
  {:else}
69
- <div class="val" role="status" aria-live="polite">
79
+ <div class="val">
70
80
  {#if prefix}<span class="small">{prefix}</span>{/if}{value}{#if suffix}<span class="small"
71
81
  >{suffix}</span
72
82
  >{/if}
@@ -107,7 +117,7 @@
107
117
  }
108
118
  .ss-metric .val .small {
109
119
  font-size: 0.5em;
110
- opacity: 0.5;
120
+ color: var(--ss-fg-muted);
111
121
  }
112
122
  .ss-metric .delta {
113
123
  font-family: var(--ss-font-mono);
@@ -138,10 +148,14 @@
138
148
  }
139
149
  .ss-metric .delta.emphasis.negative {
140
150
  background: var(--ss-danger-soft);
151
+ color: color-mix(in oklab, var(--ss-danger) 70%, var(--ss-fg));
141
152
  }
142
153
  .ss-metric .delta.emphasis.neutral {
143
154
  background: var(--ss-hover);
144
155
  }
156
+ .ss-metric .delta.emphasis .period {
157
+ color: inherit;
158
+ }
145
159
  .ss-metric .chart {
146
160
  margin-top: var(--ss-s-1);
147
161
  }
@@ -23,6 +23,12 @@ interface Props {
23
23
  emphasis?: boolean;
24
24
  /** Skeleton/loading state: hides the real value behind aria-hidden bars. */
25
25
  loading?: boolean;
26
+ /**
27
+ * Announce updates to assistive tech. When `true` the whole tile is one polite, atomic
28
+ * live region, so a change is read as "label value delta" rather than a bare number.
29
+ * Off by default: a grid of always-live tiles would talk over each other (DS-0191).
30
+ */
31
+ live?: boolean;
26
32
  /** Snippet slot below the delta — drop in a <Sparkline> here. */
27
33
  chart?: Snippet;
28
34
  /** Token size (sm|md|lg); inherits the global size when unset. */
@@ -11,17 +11,27 @@
11
11
  // dialog itself (the inner .panel covers the dialog's content box, so any
12
12
  // hit on the dialog element is the surrounding backdrop area).
13
13
  //
14
+ // Naming (DS-0178): a custom `header` snippet receives the title id so it can
15
+ // put `id={titleId}` on its heading; the dialog stays aria-labelledby that id.
16
+ // While open, page scroll is locked on <html> (ref-counted helper shared with
17
+ // the vanilla layer) and .body uses overscroll-behavior: contain.
18
+ //
14
19
  // Zero radius; surface = --ss-bg-elev, border = --ss-line; tinted ::backdrop.
15
20
  // Component metrics are inline var(--ss-modal-*, fallback) so no global SCSS
16
21
  // is touched (DS-0094).
17
22
  // ─────────────────────────────────────────────────────────────────────────
18
23
  import type { Snippet } from 'svelte'
19
24
  import { resolveComponentSize, type Size } from '../config.js'
25
+ import { lockScroll, unlockScroll } from '../vanilla/modal.js'
20
26
 
21
27
  interface Props {
22
28
  /** Whether the modal is shown. Bindable — sync it from caller state. */
23
29
  open?: boolean
24
- /** Title rendered in the header; also wires `aria-labelledby`. */
30
+ /**
31
+ * Title rendered in the header; also wires `aria-labelledby`. With a custom `header`
32
+ * snippet the title is not rendered but still names the dialog (as `aria-label`) unless
33
+ * the snippet labels it via the `titleId` it receives.
34
+ */
25
35
  title?: string
26
36
  /** Token size (sm|md|lg); controls max-width. Inherits the global size when unset. */
27
37
  size?: Size
@@ -43,8 +53,12 @@
43
53
  'aria-label'?: string
44
54
  /** Called after the dialog has closed (any reason: Esc, backdrop, button). */
45
55
  onclose?: () => void
46
- /** Header content; replaces the default title row when provided. */
47
- header?: Snippet
56
+ /**
57
+ * Header content; replaces the default title row when provided. Receives the id the
58
+ * dialog's `aria-labelledby` points at — put it on your heading (`id={titleId}`) so the
59
+ * dialog keeps its accessible name.
60
+ */
61
+ header?: Snippet<[string]>
48
62
  /** Footer content (typically action buttons). */
49
63
  footer?: Snippet
50
64
  /** Body content. */
@@ -72,6 +86,31 @@
72
86
  const uid = $props.id()
73
87
  const titleId = $derived(`${uid}-title`)
74
88
 
89
+ // Naming. Default header: the <h2> carries titleId (no redundant aria-label).
90
+ // Custom header: aria-labelledby points at titleId (the snippet is handed it);
91
+ // `title` / `aria-label` ride along as aria-label, which accessible-name
92
+ // computation falls back to if the snippet never renders that id.
93
+ const labelledBy = $derived(title || (header && !ariaLabel) ? titleId : undefined)
94
+ const labelAttr = $derived(header ? (ariaLabel ?? title) : title ? undefined : ariaLabel)
95
+
96
+ // Dev aid: a custom header that neither uses titleId nor has a title/aria-label
97
+ // fallback leaves the dialog unnamed (same warn pattern as Button/Icon).
98
+ $effect(() => {
99
+ if (!open || !header || title || ariaLabel || !dialog) return
100
+ if (!dialog.querySelector(`[id="${titleId}"]`) && typeof console !== 'undefined') {
101
+ console.warn(
102
+ '[dssoca] Modal: a custom `header` must put the `titleId` it receives on its heading (or pass `title` / `aria-label`); this dialog has no accessible name.',
103
+ )
104
+ }
105
+ })
106
+
107
+ // Lock the page behind the dialog while it is open; release on close/unmount.
108
+ $effect(() => {
109
+ if (!open) return
110
+ lockScroll()
111
+ return unlockScroll
112
+ })
113
+
75
114
  // Mirror `open` onto the native dialog. showModal()/close() throw if called
76
115
  // in the wrong state, so guard on dialog.open before flipping it.
77
116
  $effect(() => {
@@ -107,8 +146,8 @@
107
146
  class:danger
108
147
  data-size-variant={resolveComponentSize('Modal', size)}
109
148
  data-fullscreen={fullscreen ? '' : undefined}
110
- aria-labelledby={title ? titleId : undefined}
111
- aria-label={title ? undefined : ariaLabel}
149
+ aria-labelledby={labelledBy}
150
+ aria-label={labelAttr}
112
151
  onclose={onDialogClose}
113
152
  oncancel={onCancel}
114
153
  onpointerdown={onPointerDown}
@@ -116,7 +155,7 @@
116
155
  <div class="panel">
117
156
  <header class="head">
118
157
  {#if header}
119
- {@render header()}
158
+ {@render header(titleId)}
120
159
  {:else if title}
121
160
  <h2 class="title" id={titleId}>{title}</h2>
122
161
  {/if}
@@ -218,7 +257,7 @@
218
257
 
219
258
  .close {
220
259
  flex: none;
221
- margin-left: auto;
260
+ margin-inline-start: auto;
222
261
  appearance: none;
223
262
  display: inline-flex;
224
263
  align-items: center;
@@ -247,6 +286,7 @@
247
286
  .body {
248
287
  padding: var(--ss-modal-pad-y, var(--ss-s-4)) var(--ss-modal-pad-x, var(--ss-s-5));
249
288
  overflow: auto;
289
+ overscroll-behavior: contain;
250
290
  color: var(--ss-fg);
251
291
  font-family: var(--ss-font-body);
252
292
  line-height: var(--ss-leading, 1.5);
@@ -3,7 +3,11 @@ import { type Size } from '../config.js';
3
3
  interface Props {
4
4
  /** Whether the modal is shown. Bindable — sync it from caller state. */
5
5
  open?: boolean;
6
- /** Title rendered in the header; also wires `aria-labelledby`. */
6
+ /**
7
+ * Title rendered in the header; also wires `aria-labelledby`. With a custom `header`
8
+ * snippet the title is not rendered but still names the dialog (as `aria-label`) unless
9
+ * the snippet labels it via the `titleId` it receives.
10
+ */
7
11
  title?: string;
8
12
  /** Token size (sm|md|lg); controls max-width. Inherits the global size when unset. */
9
13
  size?: Size;
@@ -25,8 +29,12 @@ interface Props {
25
29
  'aria-label'?: string;
26
30
  /** Called after the dialog has closed (any reason: Esc, backdrop, button). */
27
31
  onclose?: () => void;
28
- /** Header content; replaces the default title row when provided. */
29
- header?: Snippet;
32
+ /**
33
+ * Header content; replaces the default title row when provided. Receives the id the
34
+ * dialog's `aria-labelledby` points at — put it on your heading (`id={titleId}`) so the
35
+ * dialog keeps its accessible name.
36
+ */
37
+ header?: Snippet<[string]>;
30
38
  /** Footer content (typically action buttons). */
31
39
  footer?: Snippet;
32
40
  /** Body content. */
@@ -65,11 +65,16 @@
65
65
  const isInvalid = $derived(invalid || Boolean(error) || undefined)
66
66
  const resolvedSize = $derived(resolveComponentSize('NumberField', size))
67
67
 
68
- // Steppers are inert at the bounds (and when the field can't be edited).
68
+ // Steppers are natively disabled only when the whole field can't be edited. At a bound
69
+ // they stay focusable and become `aria-disabled` no-ops, so a keyboard user who presses
70
+ // − down to `min` keeps focus on the button instead of dropping to <body>.
71
+ const locked = $derived(disabled || readonly)
69
72
  const atMin = $derived(value != null && min != null && value <= min)
70
73
  const atMax = $derived(value != null && max != null && value >= max)
71
- const decDisabled = $derived(disabled || readonly || atMin)
72
- const incDisabled = $derived(disabled || readonly || atMax)
74
+
75
+ // Polite live region text: set only by the steppers (typing in the input is already
76
+ // voiced by AT). The region itself is always rendered so updates are announced.
77
+ let announcement = $state('')
73
78
 
74
79
  function clamp(n: number): number {
75
80
  if (min != null && n < min) return min
@@ -84,8 +89,10 @@
84
89
  }
85
90
 
86
91
  function nudge(dir: 1 | -1) {
92
+ if (locked || (dir < 0 ? atMin : atMax)) return
87
93
  const base = value ?? (dir > 0 ? (min ?? 0) : (max ?? 0))
88
94
  value = clamp(base + dir * step)
95
+ announcement = String(value)
89
96
  }
90
97
  </script>
91
98
 
@@ -107,7 +114,9 @@
107
114
  type="button"
108
115
  class="step dec"
109
116
  aria-label="Decrease"
110
- disabled={decDisabled}
117
+ aria-controls={inputId}
118
+ disabled={locked}
119
+ aria-disabled={!locked && atMin ? 'true' : undefined}
111
120
  onclick={() => nudge(-1)}
112
121
  >
113
122
  −
@@ -136,12 +145,15 @@
136
145
  type="button"
137
146
  class="step inc"
138
147
  aria-label="Increase"
139
- disabled={incDisabled}
148
+ aria-controls={inputId}
149
+ disabled={locked}
150
+ aria-disabled={!locked && atMax ? 'true' : undefined}
140
151
  onclick={() => nudge(1)}
141
152
  >
142
153
  +
143
154
  </button>
144
155
  </div>
156
+ <span class="live" aria-live="polite" aria-atomic="true">{announcement}</span>
145
157
 
146
158
  {#if error}<span class="msg error" id={errorId} role="alert">{error}</span>{/if}
147
159
  {#if hint}<span class="msg hint" id={hintId}>{hint}</span>{/if}
@@ -161,7 +173,7 @@
161
173
  }
162
174
  .ss-numberfield .lbl .req {
163
175
  color: var(--ss-red);
164
- margin-left: 2px;
176
+ margin-inline-start: 2px;
165
177
  }
166
178
  .ss-numberfield .control {
167
179
  display: flex;
@@ -200,18 +212,29 @@
200
212
  cursor: pointer;
201
213
  transition: color var(--ss-dur-fast) var(--ss-ease);
202
214
  }
203
- .ss-numberfield .step:hover:not(:disabled) {
215
+ .ss-numberfield .step:hover:not(:disabled, [aria-disabled=true]) {
204
216
  color: var(--ss-fg);
205
217
  }
206
218
  .ss-numberfield .step:focus-visible {
207
- outline: none;
219
+ outline: 2px solid var(--ss-primary);
220
+ outline-offset: -2px;
208
221
  color: var(--ss-fg);
209
- box-shadow: 0 0 0 2px var(--ss-primary-soft);
210
222
  }
211
- .ss-numberfield .step:disabled {
223
+ .ss-numberfield .step:disabled, .ss-numberfield .step[aria-disabled=true] {
212
224
  color: var(--ss-fg-faint);
213
225
  cursor: not-allowed;
214
226
  }
227
+ .ss-numberfield .live {
228
+ position: absolute;
229
+ width: 1px;
230
+ height: 1px;
231
+ padding: 0;
232
+ margin: -1px;
233
+ overflow: hidden;
234
+ clip: rect(0 0 0 0);
235
+ white-space: nowrap;
236
+ border: 0;
237
+ }
215
238
  .ss-numberfield .msg {
216
239
  font-family: var(--ss-font-mono);
217
240
  font-size: var(--ss-ui-xs);
@@ -91,6 +91,9 @@
91
91
  disabled={disabled || atFirst}
92
92
  onclick={() => go(current - 1)}
93
93
  >
94
+ <!-- ‹ › are Bidi_Mirrored (UAX #9, rule L4): in an RTL context the browser
95
+ already draws them flipped, so no transform is needed (one would
96
+ double-mirror them back). -->
94
97
  <span aria-hidden="true">‹</span>
95
98
  </button>
96
99
 
@@ -142,14 +145,14 @@
142
145
  color: var(--ss-fg-muted);
143
146
  background: transparent;
144
147
  border: 0;
145
- border-left: 1px solid var(--ss-line);
148
+ border-inline-start: 1px solid var(--ss-line);
146
149
  padding: var(--ss-pagination-py, 0.5em) var(--ss-pagination-px, 0.625em);
147
150
  cursor: pointer;
148
151
  white-space: nowrap;
149
152
  transition: color var(--ss-dur-fast) var(--ss-ease), background var(--ss-dur-fast) var(--ss-ease);
150
153
  }
151
154
  .ss-pagination .page:first-child {
152
- border-left: 0;
155
+ border-inline-start: 0;
153
156
  }
154
157
  .ss-pagination .page:hover:not(.active):not(:disabled) {
155
158
  color: var(--ss-fg);
@@ -162,7 +165,7 @@
162
165
  }
163
166
  .ss-pagination .page:focus-visible {
164
167
  outline: none;
165
- box-shadow: inset 0 0 0 2px var(--ss-primary-soft);
168
+ box-shadow: inset 0 0 0 2px var(--ss-primary);
166
169
  z-index: 1;
167
170
  }
168
171
  .ss-pagination .page.active:focus-visible {
@@ -185,7 +188,7 @@
185
188
  justify-content: center;
186
189
  min-width: var(--ss-pagination-min, 2.25em);
187
190
  padding: var(--ss-pagination-py, 0.5em) var(--ss-pagination-px, 0.625em);
188
- border-left: 1px solid var(--ss-line);
191
+ border-inline-start: 1px solid var(--ss-line);
189
192
  color: var(--ss-fg-muted);
190
193
  font-family: var(--ss-font-mono);
191
194
  line-height: 1;
@@ -16,6 +16,7 @@
16
16
  import { scaleLinear, scaleSqrt } from 'd3-scale'
17
17
  import { extent, max } from 'd3-array'
18
18
  import { resolveComponentSize, type Size } from '../config.js'
19
+ import { chartNavStep } from '../chart-nav.js'
19
20
 
20
21
  interface Props {
21
22
  /** One dot per datum. Two encoded axes (x, y), optional `size` and `color`. */
@@ -165,11 +166,39 @@
165
166
  function hide() {
166
167
  active = null
167
168
  }
169
+
170
+ // Roving tabindex (DS-0161): the chart is ONE tab stop; arrow keys / Home / End move focus
171
+ // between points. The last-focused point keeps tabindex 0 (the first by default).
172
+ let focusIndex = $state(0)
173
+ const tabIndex = $derived(Math.min(focusIndex, Math.max(0, marks.length - 1)))
174
+ let pointEls: (SVGCircleElement | null)[] = $state([])
175
+
176
+ function onPointKeydown(e: KeyboardEvent, i: number) {
177
+ if (e.key === 'Escape') {
178
+ if (active) {
179
+ hide()
180
+ e.preventDefault()
181
+ }
182
+ return
183
+ }
184
+ const next = chartNavStep(e.key, i, marks.length)
185
+ if (next === null) return
186
+ e.preventDefault()
187
+ focusIndex = next
188
+ pointEls[next]?.focus()
189
+ }
190
+
191
+ // WCAG 1.4.13: Escape dismisses a hover-opened tooltip too, wherever focus is.
192
+ function onWindowKeydown(e: KeyboardEvent) {
193
+ if (e.key === 'Escape' && active) hide()
194
+ }
168
195
  function datumLabel(label: string, x: number, y: number): string {
169
196
  return `${label}: ${fmtX(x)}, ${fmtY(y)}`
170
197
  }
171
198
  </script>
172
199
 
200
+ <svelte:window onkeydown={onWindowKeydown} />
201
+
173
202
  <div
174
203
  class="ss-scatter"
175
204
  class:fluid
@@ -220,23 +249,31 @@
220
249
  {/each}
221
250
 
222
251
  <!-- points -->
223
- {#each marks as m}
252
+ {#each marks as m, i}
253
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
224
254
  <circle
255
+ bind:this={pointEls[i]}
225
256
  class="point"
226
257
  cx={m.cx}
227
258
  cy={m.cy}
228
259
  r={m.r}
229
260
  style="fill:{m.color}"
230
- tabindex="0"
231
- role="button"
261
+ tabindex={i === tabIndex ? 0 : -1}
262
+ role="img"
232
263
  aria-label={datumLabel(m.label, m.x, m.y)}
233
- onfocus={() => show(m.label, m.x, m.y, m.cx, m.cy)}
264
+ onkeydown={(e) => onPointKeydown(e, i)}
265
+ onfocus={() => {
266
+ focusIndex = i
267
+ show(m.label, m.x, m.y, m.cx, m.cy)
268
+ }}
234
269
  onblur={hide}
235
270
  onmouseenter={() => show(m.label, m.x, m.y, m.cx, m.cy)}
236
271
  onmouseleave={hide}
237
272
  />
238
273
  {#if showLabels}
239
- <text class="point-label" x={m.cx + m.r + 4} y={m.cy} dy="0.32em">{m.label}</text>
274
+ <text class="point-label" aria-hidden="true" x={m.cx + m.r + 4} y={m.cy} dy="0.32em"
275
+ >{m.label}</text
276
+ >
240
277
  {/if}
241
278
  {/each}
242
279
 
@@ -259,7 +296,7 @@
259
296
  {#if tooltip && active}
260
297
  <div
261
298
  class="tooltip"
262
- role="status"
299
+ aria-hidden="true"
263
300
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
264
301
  100}%"
265
302
  >
@@ -352,7 +389,7 @@
352
389
  fill: var(--ss-fg-muted);
353
390
  }
354
391
  .ss-scatter .point {
355
- cursor: pointer;
392
+ cursor: default;
356
393
  fill-opacity: 0.85;
357
394
  transition: fill-opacity var(--ss-dur-fast) var(--ss-ease);
358
395
  }
@@ -37,6 +37,7 @@
37
37
  import { tick, type Snippet } from 'svelte'
38
38
  import { resolveComponentSize, type Size } from '../config.js'
39
39
  import { shortcuts } from '../shortcuts.svelte.js'
40
+ import { lockScroll, unlockScroll } from '../vanilla/modal.js'
40
41
 
41
42
  interface Props {
42
43
  /** Whether the palette is shown. Bindable — sync it from caller state. */
@@ -58,6 +59,11 @@
58
59
  'aria-label'?: string
59
60
  /** No-results text (used when the `empty` snippet is absent). @default 'No results' */
60
61
  emptyText?: string
62
+ /** Screen-reader announcement of the result count while a query is typed.
63
+ * @default (n) => `${n} result(s)` */
64
+ resultsText?: (count: number) => string
65
+ /** Accessible name of the close button (shown on small, full-screen viewports). @default 'Close' */
66
+ closeLabel?: string
61
67
  /** Footer hint row; false hides it. A `footer` snippet replaces it. @default '↑↓ navigate · ↵ open · esc close' */
62
68
  footerText?: string | false
63
69
  /** Clear the query and selection when the palette closes. @default true */
@@ -87,6 +93,8 @@
87
93
  placeholder = 'Search…',
88
94
  'aria-label': ariaLabel = 'Search',
89
95
  emptyText = 'No results',
96
+ resultsText = (n: number) => `${n} ${n === 1 ? 'result' : 'results'}`,
97
+ closeLabel = 'Close',
90
98
  footerText = '↑↓ navigate · ↵ open · esc close',
91
99
  resetOnClose = true,
92
100
  size,
@@ -167,6 +175,19 @@
167
175
  }
168
176
  })
169
177
 
178
+ // Lock the page behind the palette while open (the dialog's own .results
179
+ // already has overscroll-behavior: contain). Shares Modal's reference-counted
180
+ // lock, so a palette opened over a modal (or vice versa) unwinds correctly.
181
+ $effect(() => {
182
+ if (!open) return
183
+ lockScroll()
184
+ return unlockScroll
185
+ })
186
+
187
+ // Polite live text for the always-rendered status node: silent until the
188
+ // user types, then the result count (or the no-results text).
189
+ const status = $derived(query.trim() ? (flat.length ? resultsText(flat.length) : emptyText) : '')
190
+
170
191
  // Native `close` (Esc, .close()) → sync state, optionally reset, notify.
171
192
  function onDialogClose() {
172
193
  if (open) open = false
@@ -287,23 +308,32 @@
287
308
  onpointerdown={onPointerDown}
288
309
  >
289
310
  <div class="panel">
290
- <input
291
- bind:this={input}
292
- bind:value={query}
293
- oninput={onQueryInput}
294
- onkeydown={onInputKeydown}
295
- class="input"
296
- type="text"
297
- {placeholder}
298
- spellcheck="false"
299
- autocomplete="off"
300
- role="combobox"
301
- aria-label={ariaLabel}
302
- aria-autocomplete="list"
303
- aria-expanded={flat.length > 0}
304
- aria-controls={listId}
305
- aria-activedescendant={flat.length ? optionId(active) : undefined}
306
- />
311
+ <div class="bar">
312
+ <input
313
+ bind:this={input}
314
+ bind:value={query}
315
+ oninput={onQueryInput}
316
+ onkeydown={onInputKeydown}
317
+ class="input"
318
+ type="text"
319
+ {placeholder}
320
+ spellcheck="false"
321
+ autocomplete="off"
322
+ role="combobox"
323
+ aria-label={ariaLabel}
324
+ aria-autocomplete="list"
325
+ aria-expanded={flat.length > 0}
326
+ aria-controls={listId}
327
+ aria-activedescendant={flat.length ? optionId(active) : undefined}
328
+ />
329
+ <!-- Touch exit for the full-screen small-viewport layout (no backdrop to
330
+ tap there); hidden on wider screens, where Esc/backdrop close it. -->
331
+ <button type="button" class="close" aria-label={closeLabel} onclick={() => (open = false)}
332
+ >×</button
333
+ >
334
+ </div>
335
+
336
+ <p class="sr-only" role="status">{status}</p>
307
337
 
308
338
  <div class="results" bind:this={list}>
309
339
  {#if flat.length === 0}
@@ -416,24 +446,67 @@
416
446
  flex-direction: column;
417
447
  }
418
448
 
449
+ .bar {
450
+ display: flex;
451
+ align-items: center;
452
+ border-bottom: 1px solid var(--ss-line);
453
+ }
454
+ .bar:focus-within {
455
+ border-bottom-color: var(--ss-primary);
456
+ }
457
+
419
458
  .input {
459
+ flex: 1;
460
+ min-width: 0;
420
461
  width: 100%;
421
462
  padding: var(--ss-search-palette-input-pad, var(--ss-s-4)) var(--ss-s-4);
422
463
  background: transparent;
423
464
  border: none;
424
- border-bottom: 1px solid var(--ss-line);
425
465
  color: var(--ss-fg);
426
466
  font-family: inherit;
427
467
  font-size: var(--ss-search-palette-input-size, var(--ss-ui-lg, var(--ss-size-body)));
428
468
  }
429
469
  .input:focus {
430
470
  outline: none;
431
- border-bottom-color: var(--ss-primary);
432
471
  }
433
472
  .input::placeholder {
434
473
  color: var(--ss-fg-muted);
435
474
  }
436
475
 
476
+ .close {
477
+ display: none;
478
+ flex: none;
479
+ align-items: center;
480
+ justify-content: center;
481
+ min-inline-size: var(--ss-s-10);
482
+ min-block-size: var(--ss-s-10);
483
+ margin-inline-end: var(--ss-s-2);
484
+ padding: 0;
485
+ background: transparent;
486
+ border: 1px solid transparent;
487
+ color: var(--ss-fg-muted);
488
+ font-family: inherit;
489
+ font-size: var(--ss-size-h3);
490
+ line-height: 1;
491
+ cursor: pointer;
492
+ }
493
+ .close:hover {
494
+ color: var(--ss-fg);
495
+ border-color: var(--ss-line-strong);
496
+ }
497
+
498
+ .sr-only {
499
+ position: absolute;
500
+ width: 1px;
501
+ height: 1px;
502
+ padding: 0;
503
+ margin: -1px;
504
+ overflow: hidden;
505
+ clip: rect(0, 0, 0, 0);
506
+ white-space: nowrap;
507
+ border: 0;
508
+ }
509
+
437
510
  .results {
438
511
  overflow-y: auto;
439
512
  max-height: var(--ss-search-palette-list-h, 60vh);
@@ -467,18 +540,18 @@ ul {
467
540
  width: 100%;
468
541
  padding: var(--ss-s-2) var(--ss-s-4);
469
542
  border: none;
470
- border-left: 2px solid transparent;
471
- padding-left: calc(var(--ss-s-4) - 2px);
543
+ border-inline-start: 2px solid transparent;
544
+ padding-inline-start: calc(var(--ss-s-4) - 2px);
472
545
  background: transparent;
473
546
  color: var(--ss-fg);
474
547
  font-family: inherit;
475
- text-align: left;
548
+ text-align: start;
476
549
  text-decoration: none;
477
550
  cursor: pointer;
478
551
  }
479
552
  .row.active {
480
553
  background: var(--ss-primary-soft);
481
- border-left-color: var(--ss-primary);
554
+ border-inline-start-color: var(--ss-primary);
482
555
  }
483
556
  .row.disabled {
484
557
  color: var(--ss-fg-faint, var(--ss-fg-muted));
@@ -523,4 +596,10 @@ ul {
523
596
  flex: 1;
524
597
  max-height: none;
525
598
  }
599
+ .close {
600
+ display: inline-flex;
601
+ }
602
+ }
603
+ .row::before {
604
+ content: none;
526
605
  }</style>