dssoca 0.19.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 (71) hide show
  1. package/README.md +3 -3
  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/BoxPlot.svelte +33 -7
  8. package/dist/components/BumpChart.svelte +68 -26
  9. package/dist/components/Button.svelte +23 -1
  10. package/dist/components/Button.svelte.d.ts +5 -1
  11. package/dist/components/Card.svelte +32 -14
  12. package/dist/components/Card.svelte.d.ts +4 -1
  13. package/dist/components/Chart.svelte +169 -32
  14. package/dist/components/Chart.svelte.d.ts +13 -1
  15. package/dist/components/DateField.svelte +1 -1
  16. package/dist/components/FileDrop.svelte +81 -14
  17. package/dist/components/FileDrop.svelte.d.ts +6 -0
  18. package/dist/components/Heatmap.svelte +128 -50
  19. package/dist/components/Heatmap.svelte.d.ts +2 -1
  20. package/dist/components/Icon.svelte +12 -3
  21. package/dist/components/Icon.svelte.d.ts +4 -0
  22. package/dist/components/Input.svelte +3 -3
  23. package/dist/components/Link.svelte +25 -14
  24. package/dist/components/LogStream.svelte +34 -9
  25. package/dist/components/Menu.svelte +12 -8
  26. package/dist/components/Menu.svelte.d.ts +2 -2
  27. package/dist/components/MetricTile.svelte +11 -1
  28. package/dist/components/MetricTile.svelte.d.ts +6 -0
  29. package/dist/components/Modal.svelte +47 -7
  30. package/dist/components/Modal.svelte.d.ts +11 -3
  31. package/dist/components/NumberField.svelte +33 -10
  32. package/dist/components/Pagination.svelte +7 -4
  33. package/dist/components/ScatterPlot.svelte +44 -7
  34. package/dist/components/SearchPalette.svelte +99 -23
  35. package/dist/components/SearchPalette.svelte.d.ts +5 -0
  36. package/dist/components/SegmentedControl.svelte +14 -5
  37. package/dist/components/Select.svelte +3 -4
  38. package/dist/components/ServiceCard.svelte +105 -68
  39. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  40. package/dist/components/ShortcutsHelp.svelte +1 -1
  41. package/dist/components/Sidebar.svelte +41 -58
  42. package/dist/components/Switch.svelte +4 -8
  43. package/dist/components/Table.svelte +20 -13
  44. package/dist/components/Table.svelte.d.ts +6 -2
  45. package/dist/components/Textarea.svelte +1 -1
  46. package/dist/components/TierList.svelte +9 -13
  47. package/dist/components/Toaster.svelte +143 -21
  48. package/dist/components/Tooltip.svelte +101 -13
  49. package/dist/components/Tooltip.svelte.d.ts +1 -1
  50. package/dist/components/Topbar.svelte +21 -16
  51. package/dist/icons.d.ts +19 -2
  52. package/dist/icons.js +42 -3
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.js +1 -1
  55. package/dist/tierlist-core.d.ts +15 -5
  56. package/dist/tierlist-core.js +30 -7
  57. package/dist/vanilla/accordion.js +7 -3
  58. package/dist/vanilla/fields.js +19 -6
  59. package/dist/vanilla/index.d.ts +1 -1
  60. package/dist/vanilla/index.js +4 -4
  61. package/dist/vanilla/menu.js +12 -1
  62. package/dist/vanilla/modal.d.ts +4 -0
  63. package/dist/vanilla/modal.js +57 -2
  64. package/dist/vanilla/segmented.js +13 -4
  65. package/dist/vanilla/tierlist.js +7 -11
  66. package/dist/vanilla/toast.d.ts +11 -3
  67. package/dist/vanilla/toast.js +124 -10
  68. package/dist/vanilla/tooltip.d.ts +5 -1
  69. package/dist/vanilla/tooltip.js +57 -10
  70. package/dist/vanilla.css +326 -118
  71. package/package.json +1 -1
package/README.md CHANGED
@@ -84,9 +84,9 @@ wires the interactive parts (modal, menu, accordion, tooltip, switch, toasts, ic
84
84
  **after** `theme.css`; it needs CSS `@scope` (Chrome/Edge 118+, Safari 17.4+, Firefox 2026+).
85
85
 
86
86
  ```html
87
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/theme.css" />
88
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/vanilla.css" />
89
- <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.19/dist/vanilla/index.js"></script>
87
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/theme.css" />
88
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/vanilla.css" />
89
+ <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.20/dist/vanilla/index.js"></script>
90
90
 
91
91
  <button class="ss-btn primary" type="button" data-ss-modal="#confirm">deploy</button>
92
92
  ```
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared keyboard contract for the chart components (Chart, BoxPlot, BumpChart, ScatterPlot,
3
+ * Heatmap): a chart is ONE tab stop, and the arrow keys move focus between its data marks
4
+ * (roving tabindex). See agile DS-0161.
5
+ *
6
+ * - 1-D (default): ArrowRight/ArrowDown → next mark, ArrowLeft/ArrowUp → previous.
7
+ * - 2-D (`cols` given, e.g. Heatmap): ArrowLeft/ArrowRight move within a row, ArrowUp/ArrowDown
8
+ * move by `cols`.
9
+ * - Home/End → first/last mark. Movement clamps at the edges (no wrap-around).
10
+ *
11
+ * Returns the new index, or `null` when the key is not a navigation key (let it through).
12
+ */
13
+ export declare function chartNavStep(key: string, index: number, count: number, cols?: number): number | null;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared keyboard contract for the chart components (Chart, BoxPlot, BumpChart, ScatterPlot,
3
+ * Heatmap): a chart is ONE tab stop, and the arrow keys move focus between its data marks
4
+ * (roving tabindex). See agile DS-0161.
5
+ *
6
+ * - 1-D (default): ArrowRight/ArrowDown → next mark, ArrowLeft/ArrowUp → previous.
7
+ * - 2-D (`cols` given, e.g. Heatmap): ArrowLeft/ArrowRight move within a row, ArrowUp/ArrowDown
8
+ * move by `cols`.
9
+ * - Home/End → first/last mark. Movement clamps at the edges (no wrap-around).
10
+ *
11
+ * Returns the new index, or `null` when the key is not a navigation key (let it through).
12
+ */
13
+ export function chartNavStep(key, index, count, cols) {
14
+ if (count <= 0)
15
+ return null;
16
+ const last = count - 1;
17
+ const clamp = (i) => Math.min(last, Math.max(0, i));
18
+ const row = cols ?? 1;
19
+ switch (key) {
20
+ case 'ArrowRight':
21
+ return clamp(index + 1);
22
+ case 'ArrowLeft':
23
+ return clamp(index - 1);
24
+ case 'ArrowDown':
25
+ return cols ? (index + row <= last ? index + row : index) : clamp(index + 1);
26
+ case 'ArrowUp':
27
+ return cols ? (index - row >= 0 ? index - row : index) : clamp(index - 1);
28
+ case 'Home':
29
+ return 0;
30
+ case 'End':
31
+ return last;
32
+ default:
33
+ return null;
34
+ }
35
+ }
@@ -195,6 +195,7 @@
195
195
  role="region"
196
196
  aria-labelledby={headerId(item)}
197
197
  hidden={!expanded}
198
+ inert={!expanded}
198
199
  >
199
200
  <div class="panel-clip">
200
201
  <div class="panel-inner">
@@ -249,7 +250,7 @@
249
250
  padding: var(--ss-acc-head-py) var(--ss-acc-head-px);
250
251
  background: none;
251
252
  border: 0;
252
- text-align: left;
253
+ text-align: start;
253
254
  cursor: pointer;
254
255
  color: var(--ss-fg);
255
256
  font: 500 var(--ss-ui-md) var(--ss-font-mono);
@@ -296,14 +297,18 @@
296
297
  .ss-accordion .panel {
297
298
  display: grid;
298
299
  grid-template-rows: 0fr;
299
- transition: grid-template-rows var(--ss-dur) var(--ss-ease);
300
+ visibility: hidden;
301
+ transition: grid-template-rows var(--ss-dur) var(--ss-ease), visibility 0s linear var(--ss-dur);
300
302
  }
301
303
  .ss-accordion .panel[hidden] {
302
304
  display: grid;
303
305
  grid-template-rows: 0fr;
306
+ visibility: hidden;
304
307
  }
305
308
  .ss-accordion .panel:not([hidden]) {
306
309
  grid-template-rows: 1fr;
310
+ visibility: visible;
311
+ transition: grid-template-rows var(--ss-dur) var(--ss-ease), visibility 0s linear 0s;
307
312
  }
308
313
  .ss-accordion .panel-clip {
309
314
  overflow: hidden;
@@ -26,7 +26,8 @@
26
26
  live?: boolean
27
27
  /**
28
28
  * Accessible label. Required for dot-only / label-less badges so the
29
- * status isn't conveyed by colour alone (WCAG 1.4.1).
29
+ * status isn't conveyed by colour alone (WCAG 1.4.1). A count-only badge
30
+ * without it falls back to its visible count text as the name.
30
31
  */
31
32
  label?: string
32
33
  /** Badge text. Optional: omit for a dot-only or count-only badge. */
@@ -50,12 +51,16 @@
50
51
 
51
52
  const hasLabel = $derived(children !== undefined)
52
53
  // Dot-only / count-only badges have no visible text → carry an aria-label so
53
- // the status isn't conveyed by colour alone (WCAG 1.4.1).
54
- const ariaLabel = $derived(!hasLabel ? label : undefined)
55
- // `live` wins (role=status). Otherwise a label-less badge needs a role for
56
- // its aria-label to be valid (a bare span + aria-label is prohibited); use
57
- // `img` so AT announces it as a single named status indicator.
58
- const role = $derived(live ? 'status' : !hasLabel ? 'img' : undefined)
54
+ // the status isn't conveyed by colour alone (WCAG 1.4.1). With no `label`,
55
+ // a count-only badge falls back to its visible count text as the name.
56
+ const ariaLabel = $derived(
57
+ hasLabel ? undefined : label || (showCount ? countText : undefined) || undefined,
58
+ )
59
+ // `live` wins (role=status). Otherwise a label-less badge that HAS a name
60
+ // needs a role for its aria-label to be valid (a bare span + aria-label is
61
+ // prohibited); use `img` so AT announces it as a single named status
62
+ // indicator. With no name at all, stay a plain span rather than an unnamed img.
63
+ const role = $derived(live ? 'status' : ariaLabel !== undefined ? 'img' : undefined)
59
64
  </script>
60
65
 
61
66
  <span
@@ -23,7 +23,8 @@ interface Props {
23
23
  live?: boolean;
24
24
  /**
25
25
  * Accessible label. Required for dot-only / label-less badges so the
26
- * status isn't conveyed by colour alone (WCAG 1.4.1).
26
+ * status isn't conveyed by colour alone (WCAG 1.4.1). A count-only badge
27
+ * without it falls back to its visible count text as the name.
27
28
  */
28
29
  label?: string;
29
30
  /** Badge text. Optional: omit for a dot-only or count-only badge. */
@@ -14,6 +14,7 @@
14
14
  import { scaleBand, scaleLinear } from 'd3-scale'
15
15
  import { extent, quantile } from 'd3-array'
16
16
  import { resolveComponentSize, type Size } from '../config.js'
17
+ import { chartNavStep } from '../chart-nav.js'
17
18
 
18
19
  interface Props {
19
20
  /** One box per group. Each group has a `label`, `values`, and optional `color`. */
@@ -184,10 +185,32 @@
184
185
  active = null
185
186
  }
186
187
  function boxLabel(b: (typeof boxes)[number]): string {
187
- return `${b.label}: median ${fmtY(b.median)} (Q1 ${fmtY(b.q1)}–Q3 ${fmtY(b.q3)})`
188
+ return `${b.label}: median ${fmtY(b.median)} (Q1 ${fmtY(b.q1)}–Q3 ${fmtY(b.q3)}), min ${fmtY(b.lo)}, max ${fmtY(b.hi)}`
189
+ }
190
+
191
+ // Roving tabindex (DS-0161): the chart is ONE tab stop; arrow keys move between boxes.
192
+ let focusIdx = $state(0)
193
+ const tabIdx = $derived(Math.min(focusIdx, Math.max(0, boxes.length - 1)))
194
+ const boxEls: (SVGRectElement | null)[] = $state([])
195
+ function onBoxKeydown(e: KeyboardEvent, i: number) {
196
+ const next = chartNavStep(e.key, i, boxes.length)
197
+ if (next === null) return
198
+ e.preventDefault()
199
+ focusIdx = next
200
+ boxEls[next]?.focus()
201
+ }
202
+ function onBoxFocus(b: (typeof boxes)[number], i: number) {
203
+ focusIdx = i
204
+ show(b)
205
+ }
206
+ // Escape dismisses the tooltip whether it came from hover or focus (WCAG 1.4.13).
207
+ function onWindowKeydown(e: KeyboardEvent) {
208
+ if (e.key === 'Escape' && active) hide()
188
209
  }
189
210
  </script>
190
211
 
212
+ <svelte:window onkeydown={onWindowKeydown} />
213
+
191
214
  <div
192
215
  class="ss-boxplot"
193
216
  class:fluid
@@ -220,24 +243,27 @@
220
243
  <line class="axis" x1="0" x2={innerW} y1={innerH} y2={innerH} />
221
244
 
222
245
  <!-- boxes -->
223
- {#each boxes as b}
246
+ {#each boxes as b, i}
224
247
  <!-- whisker centre line + caps -->
225
248
  <line class="whisker" x1={b.cx} x2={b.cx} y1={b.yLo} y2={b.yHi} />
226
249
  <line class="whisker" x1={b.cx - b.w / 4} x2={b.cx + b.w / 4} y1={b.yLo} y2={b.yLo} />
227
250
  <line class="whisker" x1={b.cx - b.w / 4} x2={b.cx + b.w / 4} y1={b.yHi} y2={b.yHi} />
228
251
 
229
252
  <!-- box (q1..q3) -->
253
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
230
254
  <rect
255
+ bind:this={boxEls[i]}
231
256
  class="box"
232
257
  x={b.x}
233
258
  y={b.yQ3}
234
259
  width={b.w}
235
260
  height={Math.max(0, b.yQ1 - b.yQ3)}
236
261
  style="fill:{b.color};stroke:{b.color}"
237
- tabindex="0"
238
- role="button"
262
+ tabindex={i === tabIdx ? 0 : -1}
263
+ role="img"
239
264
  aria-label={boxLabel(b)}
240
- onfocus={() => show(b)}
265
+ onkeydown={(e) => onBoxKeydown(e, i)}
266
+ onfocus={() => onBoxFocus(b, i)}
241
267
  onblur={hide}
242
268
  onmouseenter={() => show(b)}
243
269
  onmouseleave={hide}
@@ -287,7 +313,7 @@
287
313
  {#if tooltip && active}
288
314
  <div
289
315
  class="tooltip"
290
- role="status"
316
+ aria-hidden="true"
291
317
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
292
318
  100}%"
293
319
  >
@@ -375,7 +401,7 @@
375
401
  shape-rendering: crispEdges;
376
402
  }
377
403
  .ss-boxplot .box {
378
- cursor: pointer;
404
+ cursor: default;
379
405
  fill-opacity: 0.18;
380
406
  stroke-width: 1.5;
381
407
  transition: fill-opacity var(--ss-dur-fast) var(--ss-ease);
@@ -15,6 +15,7 @@
15
15
  import { line as shapeLine } from 'd3-shape'
16
16
  import { max } from 'd3-array'
17
17
  import { resolveComponentSize, type Size } from '../config.js'
18
+ import { chartNavStep } from '../chart-nav.js'
18
19
 
19
20
  interface Props {
20
21
  /** One series per competitor; each carries a `label`, `ranks` and optional `color`. */
@@ -81,10 +82,12 @@
81
82
  Array.from({ length: Math.max(1, Math.round(maxRank)) }, (_, i) => i + 1),
82
83
  )
83
84
 
84
- // One node per (series, stage) where the rank is finite.
85
- const seriesNodes = $derived(
86
- cleanSeries.map((s, i) => {
87
- const color = colorFor(s, i)
85
+ // One node per (series, stage) where the rank is finite. `i` is the series-major flat index
86
+ // used by the roving tabindex (1-D: walking a series' line stage by stage, then the next series).
87
+ const seriesNodes = $derived.by(() => {
88
+ let i = 0
89
+ return cleanSeries.map((s, si) => {
90
+ const color = colorFor(s, si)
88
91
  const nodes = cleanStages
89
92
  .map((stage, j) => {
90
93
  const rank = s.ranks[j]
@@ -99,9 +102,11 @@
99
102
  }
100
103
  })
101
104
  .filter((n): n is NonNullable<typeof n> => n !== null)
105
+ .map((n) => ({ ...n, i: i++ }))
102
106
  return { label: s.label, color, nodes }
103
- }),
104
- )
107
+ })
108
+ })
109
+ const nodeCount = $derived(seriesNodes.reduce((sum, s) => sum + s.nodes.length, 0))
105
110
 
106
111
  const lineGen = $derived(
107
112
  shapeLine<{ cx: number; cy: number }>()
@@ -150,6 +155,34 @@
150
155
  function hide() {
151
156
  active = null
152
157
  }
158
+ // WCAG 1.4.13: Escape dismisses the tooltip even when it was opened by hover (focus elsewhere).
159
+ $effect(() => {
160
+ if (!active) return
161
+ const onKey = (e: KeyboardEvent) => {
162
+ if (e.key === 'Escape') hide()
163
+ }
164
+ window.addEventListener('keydown', onKey)
165
+ return () => window.removeEventListener('keydown', onKey)
166
+ })
167
+
168
+ // Roving tabindex: the whole chart is one tab stop (DS-0161 / chart-nav.ts).
169
+ let focusIndex = $state(0)
170
+ const tabStop = $derived(Math.min(focusIndex, Math.max(0, nodeCount - 1)))
171
+ let nodesEl = $state<SVGGElement | null>(null)
172
+
173
+ function onNodeKeydown(e: KeyboardEvent, i: number) {
174
+ if (e.key === 'Escape') {
175
+ hide()
176
+ return
177
+ }
178
+ // SVG geometry does not mirror in RTL, so Left/Right stay physical.
179
+ const next = chartNavStep(e.key, i, nodeCount)
180
+ if (next === null) return
181
+ e.preventDefault()
182
+ focusIndex = next
183
+ nodesEl?.querySelector<SVGElement>(`[data-index="${next}"]`)?.focus()
184
+ }
185
+
153
186
  function nodeLabel(label: string, stage: string, rank: number): string {
154
187
  return `${label}: ${stage}, rank ${rank}`
155
188
  }
@@ -190,25 +223,34 @@
190
223
  <path class="line" d={p.d} style="stroke:{p.color}" />
191
224
  {/each}
192
225
 
193
- <!-- nodes -->
194
- {#each seriesNodes as s}
195
- {#each s.nodes as n}
196
- <circle
197
- class="node"
198
- cx={n.cx}
199
- cy={n.cy}
200
- r="5"
201
- style="fill:{n.color}"
202
- tabindex="0"
203
- role="button"
204
- aria-label={nodeLabel(n.label, n.stage, n.rank)}
205
- onfocus={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
206
- onblur={hide}
207
- onmouseenter={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
208
- onmouseleave={hide}
209
- />
226
+ <!-- nodes (series-major roving tabindex) -->
227
+ <g class="nodes" bind:this={nodesEl}>
228
+ {#each seriesNodes as s}
229
+ {#each s.nodes as n}
230
+ <!-- role="img" marks with a roving tabindex: the chart is one tab stop (DS-0161) -->
231
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
232
+ <circle
233
+ class="node"
234
+ cx={n.cx}
235
+ cy={n.cy}
236
+ r="5"
237
+ style="fill:{n.color}"
238
+ tabindex={n.i === tabStop ? 0 : -1}
239
+ data-index={n.i}
240
+ role="img"
241
+ aria-label={nodeLabel(n.label, n.stage, n.rank)}
242
+ onfocus={() => {
243
+ focusIndex = n.i
244
+ show(n.label, n.stage, n.rank, n.cx, n.cy)
245
+ }}
246
+ onblur={hide}
247
+ onkeydown={(e) => onNodeKeydown(e, n.i)}
248
+ onmouseenter={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
249
+ onmouseleave={hide}
250
+ />
251
+ {/each}
210
252
  {/each}
211
- {/each}
253
+ </g>
212
254
 
213
255
  <!-- direct series labels -->
214
256
  {#each endLabels as l}
@@ -222,7 +264,7 @@
222
264
  {#if tooltip && active}
223
265
  <div
224
266
  class="tooltip"
225
- role="status"
267
+ aria-hidden="true"
226
268
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
227
269
  100}%"
228
270
  >
@@ -304,7 +346,7 @@
304
346
  stroke-linecap: round;
305
347
  }
306
348
  .ss-bump .node {
307
- cursor: pointer;
349
+ cursor: default;
308
350
  transition: r var(--ss-dur-fast) var(--ss-ease);
309
351
  }
310
352
  .ss-bump .node:hover, .ss-bump .node:focus-visible {
@@ -21,7 +21,11 @@
21
21
  onclick?: (e: MouseEvent) => void
22
22
  /** Token size (sm|md|lg); inherits the global size when unset. */
23
23
  size?: Size
24
- /** Icon-only square button — `label` is required and becomes the aria-label. */
24
+ /**
25
+ * Icon-only square button — `label` is required and becomes the aria-label.
26
+ * Rendering `iconOnly` without `label` (or a forwarded `aria-label` /
27
+ * `aria-labelledby`) logs a console warning: the button would have no name.
28
+ */
25
29
  iconOnly?: boolean
26
30
  /** Accessible name; required for icon-only buttons (→ aria-label). */
27
31
  label?: string
@@ -70,6 +74,24 @@
70
74
  let ariaLabel = $derived(iconOnly ? label : rest['aria-label'])
71
75
  let accessibleName = $derived(isLoading ? (loadingLabel ?? ariaLabel) : ariaLabel)
72
76
 
77
+ // An icon-only button has no text content, so without `label` (or a forwarded
78
+ // aria-label / aria-labelledby) it renders with no accessible name. The prop
79
+ // types can't require `label` without breaking `iconOnly={someBoolean}`
80
+ // callers, so flag the misuse at runtime instead (same pattern as Icon).
81
+ let missingIconOnlyName = $derived(
82
+ iconOnly &&
83
+ !label?.trim() &&
84
+ !String(rest['aria-label'] ?? '').trim() &&
85
+ !String(rest['aria-labelledby'] ?? '').trim(),
86
+ )
87
+ $effect(() => {
88
+ if (missingIconOnlyName && typeof console !== 'undefined') {
89
+ console.warn(
90
+ '[dssoca] Button: `iconOnly` needs a `label` (or aria-label / aria-labelledby); this button has no accessible name.',
91
+ )
92
+ }
93
+ })
94
+
73
95
  function handleClick(e: MouseEvent) {
74
96
  if (isLoading || disabled) {
75
97
  e.preventDefault()
@@ -18,7 +18,11 @@ interface Props extends HTMLButtonAttributes {
18
18
  onclick?: (e: MouseEvent) => void;
19
19
  /** Token size (sm|md|lg); inherits the global size when unset. */
20
20
  size?: Size;
21
- /** Icon-only square button — `label` is required and becomes the aria-label. */
21
+ /**
22
+ * Icon-only square button — `label` is required and becomes the aria-label.
23
+ * Rendering `iconOnly` without `label` (or a forwarded `aria-label` /
24
+ * `aria-labelledby`) logs a console warning: the button would have no name.
25
+ */
22
26
  iconOnly?: boolean;
23
27
  /** Accessible name; required for icon-only buttons (→ aria-label). */
24
28
  label?: string;
@@ -24,7 +24,10 @@
24
24
  * convention.
25
25
  */
26
26
  external?: boolean
27
- /** Makes the whole card clickable; pairs with keyboard activation. */
27
+ /**
28
+ * Makes the whole card clickable via a stretched overlay `<button>` (native Enter/Space).
29
+ * Ignored as the target when `href` is set (it then runs as the link's click handler).
30
+ */
28
31
  onclick?: (e: MouseEvent | KeyboardEvent) => void
29
32
  /** Surface style: outlined (default) or elevated (shadow tokens). */
30
33
  variant?: 'outlined' | 'elevated'
@@ -54,26 +57,21 @@
54
57
 
55
58
  const isTitleSnippet = $derived(typeof title === 'function')
56
59
  const interactive = $derived(Boolean(href || onclick))
57
-
58
- function onKeydown(e: KeyboardEvent) {
59
- if (onclick && !href && (e.key === 'Enter' || e.key === ' ')) {
60
- e.preventDefault()
61
- onclick(e)
62
- }
63
- }
64
60
  </script>
65
61
 
66
- <!-- svelte-ignore a11y_no_noninteractive_tabindex -- role is set to "button" in the same condition -->
62
+ <!--
63
+ The root is never itself interactive (DS-0183): a clickable card renders ONE stretched
64
+ overlay control (an <a> for `href`, a <button> for `onclick`) so the heading and the `action`
65
+ controls keep their own semantics and keyboard handling. A titled card is a named region —
66
+ aria-labelledby is not allowed on a role-less <div>.
67
+ -->
67
68
  <div
68
69
  class="ss-card"
69
70
  class:elevated={variant === 'elevated'}
70
71
  class:interactive
71
72
  data-size-variant={resolveComponentSize('Card', size)}
72
- role={interactive && !href ? 'button' : undefined}
73
- tabindex={interactive && !href ? 0 : undefined}
73
+ role={title ? 'region' : undefined}
74
74
  aria-labelledby={title ? titleId : undefined}
75
- onclick={!href ? onclick : undefined}
76
- onkeydown={!href ? onKeydown : undefined}
77
75
  >
78
76
  {#if media}
79
77
  <div class="media">{@render media()}</div>
@@ -109,13 +107,16 @@
109
107
  target={external ? '_blank' : undefined}
110
108
  rel={external ? 'noopener noreferrer' : undefined}
111
109
  {onclick}
112
- onkeydown={onKeydown}
113
110
  aria-labelledby={title ? titleId : undefined}
114
111
  >
115
112
  <span class="sr-only"
116
113
  >{typeof title === 'string' ? title : 'Open'}{external ? ' (opens in a new tab)' : ''}</span
117
114
  >
118
115
  </a>
116
+ {:else if onclick}
117
+ <button type="button" class="overlay" {onclick} aria-labelledby={title ? titleId : undefined}>
118
+ <span class="sr-only">{typeof title === 'string' ? title : 'Open'}</span>
119
+ </button>
119
120
  {/if}
120
121
  </div>
121
122
 
@@ -217,6 +218,16 @@
217
218
 
218
219
  .overlay {
219
220
  position: static;
221
+ display: block;
222
+ block-size: 0;
223
+ appearance: none;
224
+ margin: 0;
225
+ padding: 0;
226
+ border: 0;
227
+ background: none;
228
+ color: inherit;
229
+ font: inherit;
230
+ cursor: pointer;
220
231
  }
221
232
  .overlay::after {
222
233
  content: "";
@@ -224,6 +235,13 @@
224
235
  inset: 0;
225
236
  z-index: 0;
226
237
  }
238
+ .overlay:focus-visible {
239
+ outline: none;
240
+ }
241
+ .overlay:focus-visible::after {
242
+ outline: 2px solid var(--ss-primary);
243
+ outline-offset: -2px;
244
+ }
227
245
 
228
246
  .sr-only {
229
247
  position: absolute;
@@ -22,7 +22,10 @@ interface Props {
22
22
  * convention.
23
23
  */
24
24
  external?: boolean;
25
- /** Makes the whole card clickable; pairs with keyboard activation. */
25
+ /**
26
+ * Makes the whole card clickable via a stretched overlay `<button>` (native Enter/Space).
27
+ * Ignored as the target when `href` is set (it then runs as the link's click handler).
28
+ */
26
29
  onclick?: (e: MouseEvent | KeyboardEvent) => void;
27
30
  /** Surface style: outlined (default) or elevated (shadow tokens). */
28
31
  variant?: 'outlined' | 'elevated';