dssoca 0.19.0 → 0.21.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 (155) hide show
  1. package/README.md +3 -3
  2. package/dist/components/Accordion.svelte +30 -54
  3. package/dist/components/Badge.svelte +12 -7
  4. package/dist/components/Badge.svelte.d.ts +2 -1
  5. package/dist/components/BottomNav.svelte +18 -28
  6. package/dist/components/BoxPlot.svelte +34 -7
  7. package/dist/components/BumpChart.svelte +65 -26
  8. package/dist/components/Button.svelte +23 -1
  9. package/dist/components/Button.svelte.d.ts +5 -1
  10. package/dist/components/Card.svelte +32 -14
  11. package/dist/components/Card.svelte.d.ts +4 -1
  12. package/dist/components/Chart.svelte +166 -32
  13. package/dist/components/Chart.svelte.d.ts +13 -1
  14. package/dist/components/Checkbox.svelte +210 -0
  15. package/dist/components/Checkbox.svelte.d.ts +38 -0
  16. package/dist/components/DateField.svelte +1 -1
  17. package/dist/components/FileDrop.svelte +113 -77
  18. package/dist/components/FileDrop.svelte.d.ts +12 -2
  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/Image.svelte +44 -44
  24. package/dist/components/Input.svelte +11 -6
  25. package/dist/components/Link.svelte +25 -14
  26. package/dist/components/LogStream.svelte +48 -33
  27. package/dist/components/Menu.svelte +81 -102
  28. package/dist/components/Menu.svelte.d.ts +8 -2
  29. package/dist/components/MetricTile.svelte +11 -1
  30. package/dist/components/MetricTile.svelte.d.ts +6 -0
  31. package/dist/components/Modal.svelte +108 -21
  32. package/dist/components/Modal.svelte.d.ts +18 -5
  33. package/dist/components/NumberField.svelte +44 -22
  34. package/dist/components/Pagination.svelte +54 -41
  35. package/dist/components/Pagination.svelte.d.ts +6 -2
  36. package/dist/components/Popover.svelte +247 -0
  37. package/dist/components/Popover.svelte.d.ts +36 -0
  38. package/dist/components/RadioGroup.svelte +227 -0
  39. package/dist/components/RadioGroup.svelte.d.ts +42 -0
  40. package/dist/components/ScatterPlot.svelte +42 -7
  41. package/dist/components/SearchPalette.svelte +216 -136
  42. package/dist/components/SearchPalette.svelte.d.ts +11 -4
  43. package/dist/components/SegmentedControl.svelte +47 -59
  44. package/dist/components/SegmentedControl.svelte.d.ts +7 -2
  45. package/dist/components/Select.svelte +3 -4
  46. package/dist/components/ServiceCard.svelte +105 -68
  47. package/dist/components/ServiceCard.svelte.d.ts +8 -3
  48. package/dist/components/ShortcutsHelp.svelte +49 -48
  49. package/dist/components/Sidebar.svelte +88 -117
  50. package/dist/components/Switch.svelte +24 -18
  51. package/dist/components/Switch.svelte.d.ts +6 -2
  52. package/dist/components/Table.svelte +29 -44
  53. package/dist/components/Table.svelte.d.ts +6 -2
  54. package/dist/components/Tabs.svelte +223 -0
  55. package/dist/components/Tabs.svelte.d.ts +51 -0
  56. package/dist/components/Textarea.svelte +1 -1
  57. package/dist/components/TierList.svelte +45 -49
  58. package/dist/components/TierList.svelte.d.ts +7 -3
  59. package/dist/components/Toaster.svelte +154 -32
  60. package/dist/components/Tooltip.svelte +122 -18
  61. package/dist/components/Tooltip.svelte.d.ts +1 -1
  62. package/dist/components/Topbar.svelte +29 -49
  63. package/dist/core/accordion.d.ts +32 -0
  64. package/dist/core/accordion.js +53 -0
  65. package/dist/core/behaviors/focusable.d.ts +5 -0
  66. package/dist/core/behaviors/focusable.js +14 -0
  67. package/dist/core/behaviors/roving.d.ts +13 -0
  68. package/dist/core/behaviors/roving.js +29 -0
  69. package/dist/core/bottom-nav.d.ts +36 -0
  70. package/dist/core/bottom-nav.js +33 -0
  71. package/dist/core/chart-nav.d.ts +53 -0
  72. package/dist/core/chart-nav.js +62 -0
  73. package/dist/core/checkbox.d.ts +36 -0
  74. package/dist/core/checkbox.js +29 -0
  75. package/dist/core/file-drop.d.ts +75 -0
  76. package/dist/core/file-drop.js +101 -0
  77. package/dist/core/image.d.ts +59 -0
  78. package/dist/core/image.js +64 -0
  79. package/dist/core/input.d.ts +21 -0
  80. package/dist/core/input.js +17 -0
  81. package/dist/core/log-stream.d.ts +51 -0
  82. package/dist/core/log-stream.js +50 -0
  83. package/dist/core/menu.d.ts +70 -0
  84. package/dist/core/menu.js +84 -0
  85. package/dist/core/modal.d.ts +59 -0
  86. package/dist/core/modal.js +44 -0
  87. package/dist/core/number-field.d.ts +47 -0
  88. package/dist/core/number-field.js +64 -0
  89. package/dist/core/pagination.d.ts +59 -0
  90. package/dist/core/pagination.js +65 -0
  91. package/dist/core/popover.d.ts +68 -0
  92. package/dist/core/popover.js +55 -0
  93. package/dist/core/radio.d.ts +36 -0
  94. package/dist/core/radio.js +48 -0
  95. package/dist/core/search-palette.d.ts +124 -0
  96. package/dist/core/search-palette.js +149 -0
  97. package/dist/core/segmented.d.ts +46 -0
  98. package/dist/core/segmented.js +66 -0
  99. package/dist/core/shortcuts-help.d.ts +56 -0
  100. package/dist/core/shortcuts-help.js +50 -0
  101. package/dist/core/sidebar.d.ts +63 -0
  102. package/dist/core/sidebar.js +84 -0
  103. package/dist/core/switch.d.ts +19 -0
  104. package/dist/core/switch.js +11 -0
  105. package/dist/core/table.d.ts +40 -0
  106. package/dist/core/table.js +57 -0
  107. package/dist/core/tabs.d.ts +84 -0
  108. package/dist/core/tabs.js +90 -0
  109. package/dist/{tierlist-core.d.ts → core/tierlist.d.ts} +77 -5
  110. package/dist/{tierlist-core.js → core/tierlist.js} +64 -7
  111. package/dist/core/toast.d.ts +112 -0
  112. package/dist/{toast-core.js → core/toast.js} +48 -2
  113. package/dist/core/tooltip.d.ts +47 -0
  114. package/dist/core/tooltip.js +51 -0
  115. package/dist/core/topbar.d.ts +41 -0
  116. package/dist/core/topbar.js +52 -0
  117. package/dist/dssoca.config.d.ts +1 -1
  118. package/dist/dssoca.config.js +4 -0
  119. package/dist/icons.d.ts +19 -2
  120. package/dist/icons.js +42 -3
  121. package/dist/index.d.ts +15 -2
  122. package/dist/index.js +10 -2
  123. package/dist/theme.css +47 -0
  124. package/dist/toast.svelte.d.ts +2 -2
  125. package/dist/toast.svelte.js +1 -1
  126. package/dist/tokens.css +47 -0
  127. package/dist/vanilla/accordion.js +35 -32
  128. package/dist/vanilla/checkbox.d.ts +8 -0
  129. package/dist/vanilla/checkbox.js +43 -0
  130. package/dist/vanilla/delegate.d.ts +2 -0
  131. package/dist/vanilla/delegate.js +9 -0
  132. package/dist/vanilla/fields.js +46 -28
  133. package/dist/vanilla/index.d.ts +5 -1
  134. package/dist/vanilla/index.js +17 -4
  135. package/dist/vanilla/menu.js +101 -84
  136. package/dist/vanilla/modal.d.ts +7 -1
  137. package/dist/vanilla/modal.js +120 -15
  138. package/dist/vanilla/popover.d.ts +10 -0
  139. package/dist/vanilla/popover.js +129 -0
  140. package/dist/vanilla/radio.d.ts +3 -0
  141. package/dist/vanilla/radio.js +54 -0
  142. package/dist/vanilla/segmented.js +50 -43
  143. package/dist/vanilla/switch.d.ts +2 -1
  144. package/dist/vanilla/switch.js +13 -8
  145. package/dist/vanilla/tabs.d.ts +2 -0
  146. package/dist/vanilla/tabs.js +87 -0
  147. package/dist/vanilla/tierlist.d.ts +1 -1
  148. package/dist/vanilla/tierlist.js +34 -34
  149. package/dist/vanilla/toast.d.ts +13 -5
  150. package/dist/vanilla/toast.js +132 -16
  151. package/dist/vanilla/tooltip.d.ts +5 -1
  152. package/dist/vanilla/tooltip.js +78 -19
  153. package/dist/vanilla.css +675 -160
  154. package/package.json +1 -1
  155. package/dist/toast-core.d.ts +0 -61
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.21/dist/theme.css" />
88
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.21/dist/vanilla.css" />
89
+ <script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.21/dist/vanilla/index.js"></script>
90
90
 
91
91
  <button class="ss-btn primary" type="button" data-ss-modal="#confirm">deploy</button>
92
92
  ```
@@ -19,6 +19,13 @@
19
19
  import { untrack, type Snippet } from 'svelte'
20
20
  import { resolveComponentSize, type Size } from '../config.js'
21
21
  import Icon from './Icon.svelte'
22
+ import {
23
+ accordionHeaderAttrs,
24
+ accordionHeaderKey,
25
+ accordionOpenIds,
26
+ accordionToggle,
27
+ accordionValue,
28
+ } from '../core/accordion.js'
22
29
 
23
30
  interface Props {
24
31
  /** The collapsible sections, top to bottom. */
@@ -80,76 +87,41 @@
80
87
  }: Props = $props()
81
88
 
82
89
  // --- open-state model ----------------------------------------------------
83
- // Normalise whatever `value`/`defaultValue` shape we were handed into a Set.
84
- function toSet(v: AccordionValue): Set<string> {
85
- if (v == null) return new Set()
86
- return new Set(Array.isArray(v) ? v : [v])
87
- }
90
+ // The decisions (what a press opens or closes, where a key moves focus) live in
91
+ // `core/accordion.ts`, shared with vanilla/accordion.ts (DS-0197).
88
92
 
89
93
  // Uncontrolled fallback store, seeded once from defaultValue. `untrack`
90
94
  // marks the read as an intentional one-time snapshot (not a live binding),
91
95
  // silencing the "referenced locally" reactivity warning.
92
- let internal = $state<Set<string>>(untrack(() => toSet(defaultValue)))
96
+ let internal = $state<string[]>(untrack(() => accordionOpenIds(defaultValue)))
93
97
 
94
98
  // Controlled when the consumer passes `value` (incl. bound); else internal.
95
99
  const controlled = $derived(value !== undefined)
96
- const open = $derived(controlled ? toSet(value) : internal)
97
-
98
- const isOpen = (item: AccordionItem): boolean => open.has(item.id)
100
+ const open = $derived(controlled ? accordionOpenIds(value) : internal)
99
101
 
100
- /** Project a Set back to the public value shape for `value`/`onChange`. */
101
- function project(next: Set<string>): AccordionValue {
102
- if (multiple) return [...next]
103
- return next.size ? [...next][0] : undefined
104
- }
102
+ const isOpen = (item: AccordionItem): boolean => open.includes(item.id)
105
103
 
106
104
  function toggle(item: AccordionItem) {
107
- if (item.disabled) return
108
- const next = new Set(open)
109
- if (next.has(item.id)) {
110
- next.delete(item.id)
111
- } else {
112
- if (!multiple) next.clear() // single-open: opening one closes others
113
- next.add(item.id)
114
- }
105
+ const next = accordionToggle({ open, multiple }, item.id, item.disabled)
106
+ if (!next) return
107
+ const projected = accordionValue(next, multiple)
115
108
  if (controlled) {
116
- value = project(next) // keep the bound value in sync
109
+ value = projected // keep the bound value in sync
117
110
  } else {
118
111
  internal = next
119
112
  }
120
- onChange?.(project(next))
113
+ onChange?.(projected)
121
114
  }
122
115
 
123
116
  // --- roving keyboard nav across headers (WAI-ARIA Accordion pattern) -----
124
117
  let headerEls = $state<Array<HTMLButtonElement | null>>([])
125
118
 
126
- function focusHeader(index: number) {
127
- const n = items.length
128
- if (n === 0) return
129
- const i = ((index % n) + n) % n // wrap
130
- headerEls[i]?.focus()
131
- }
132
-
133
119
  function onHeaderKeydown(e: KeyboardEvent, index: number) {
134
- switch (e.key) {
135
- case 'ArrowDown':
136
- e.preventDefault()
137
- focusHeader(index + 1)
138
- break
139
- case 'ArrowUp':
140
- e.preventDefault()
141
- focusHeader(index - 1)
142
- break
143
- case 'Home':
144
- e.preventDefault()
145
- focusHeader(0)
146
- break
147
- case 'End':
148
- e.preventDefault()
149
- focusHeader(items.length - 1)
150
- break
151
- // Enter / Space activate the native <button>; no extra handling needed.
152
- }
120
+ // Enter / Space activate the native <button>; the core lets them through.
121
+ const result = accordionHeaderKey(items.length, index, e.key)
122
+ if (!result) return
123
+ if (result.preventDefault) e.preventDefault()
124
+ headerEls[result.focus]?.focus()
153
125
  }
154
126
 
155
127
  const headerId = (item: AccordionItem) => `${idBase}-h-${item.id}`
@@ -172,9 +144,8 @@
172
144
  type="button"
173
145
  class="head"
174
146
  id={headerId(item)}
175
- aria-expanded={expanded}
176
147
  aria-controls={panelId(item)}
177
- aria-disabled={item.disabled || undefined}
148
+ {...accordionHeaderAttrs(expanded, item.disabled)}
178
149
  onclick={() => toggle(item)}
179
150
  onkeydown={(e) => onHeaderKeydown(e, i)}
180
151
  >
@@ -195,6 +166,7 @@
195
166
  role="region"
196
167
  aria-labelledby={headerId(item)}
197
168
  hidden={!expanded}
169
+ inert={!expanded}
198
170
  >
199
171
  <div class="panel-clip">
200
172
  <div class="panel-inner">
@@ -249,7 +221,7 @@
249
221
  padding: var(--ss-acc-head-py) var(--ss-acc-head-px);
250
222
  background: none;
251
223
  border: 0;
252
- text-align: left;
224
+ text-align: start;
253
225
  cursor: pointer;
254
226
  color: var(--ss-fg);
255
227
  font: 500 var(--ss-ui-md) var(--ss-font-mono);
@@ -296,14 +268,18 @@
296
268
  .ss-accordion .panel {
297
269
  display: grid;
298
270
  grid-template-rows: 0fr;
299
- transition: grid-template-rows var(--ss-dur) var(--ss-ease);
271
+ visibility: hidden;
272
+ transition: grid-template-rows var(--ss-dur) var(--ss-ease), visibility 0s linear var(--ss-dur);
300
273
  }
301
274
  .ss-accordion .panel[hidden] {
302
275
  display: grid;
303
276
  grid-template-rows: 0fr;
277
+ visibility: hidden;
304
278
  }
305
279
  .ss-accordion .panel:not([hidden]) {
306
280
  grid-template-rows: 1fr;
281
+ visibility: visible;
282
+ transition: grid-template-rows var(--ss-dur) var(--ss-ease), visibility 0s linear 0s;
307
283
  }
308
284
  .ss-accordion .panel-clip {
309
285
  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. */
@@ -21,6 +21,12 @@
21
21
  <script lang="ts">
22
22
  import Icon from './Icon.svelte'
23
23
  import { resolveComponentSize, type Size } from '../config.js'
24
+ import {
25
+ bottomNavHasBadge,
26
+ bottomNavPress,
27
+ bottomNavTabAttrs,
28
+ bottomNavTabElement,
29
+ } from '../core/bottom-nav.js'
24
30
 
25
31
  interface Props {
26
32
  /** Tabs to render, left → right, in equal-width columns. */
@@ -44,26 +50,12 @@
44
50
 
45
51
  let { items = DEFAULT_ITEMS, active, onSelect, ariaLabel = 'Primary', size }: Props = $props()
46
52
 
47
- const isActive = (item: BottomNavItem): boolean => item.id === active
48
-
49
- const hasBadge = (item: BottomNavItem): boolean => item.badge != null && item.badge !== ''
50
-
51
- /** Fold the count badge into the accessible name so it isn't lost to AT. */
52
- function accessibleName(item: BottomNavItem): string {
53
- return hasBadge(item) ? `${item.label}, ${item.badge}` : item.label
54
- }
55
-
53
+ // Behaviour lives in `core/bottom-nav.ts`: which element a tab is, what a press does and
54
+ // the state attributes are decided there; this file renders the result.
56
55
  function activate(item: BottomNavItem, e: MouseEvent) {
57
- // Disabled tabs are inert (DS-0078): no navigation, no onSelect. The
58
- // <button> branch is natively disabled; this also guards the <a> branch.
59
- if (item.disabled) {
60
- e.preventDefault()
61
- return
62
- }
63
- // Real links navigate natively; intercept only the SPA (no-href) path so a
64
- // plain <button> never submits/scrolls. onSelect fires either way.
65
- if (!item.href) e.preventDefault()
66
- onSelect?.(item.id)
56
+ const press = bottomNavPress(item)
57
+ if (press.preventDefault) e.preventDefault()
58
+ if (press.select) onSelect?.(item.id)
67
59
  }
68
60
 
69
61
  const sizeAttr = $derived(resolveComponentSize('BottomNav', size))
@@ -72,19 +64,19 @@
72
64
  <nav class="ss-bottom-nav" aria-label={ariaLabel} data-size-variant={sizeAttr}>
73
65
  <ul class="list">
74
66
  {#each items as item (item.id)}
75
- {@const current = isActive(item)}
67
+ {@const attrs = bottomNavTabAttrs(item, active)}
68
+ {@const current = attrs['aria-current'] === 'page'}
76
69
  <li class="row">
77
- {#if item.href && !item.disabled}
70
+ {#if bottomNavTabElement(item) === 'a'}
78
71
  <a
79
72
  class="tab {current ? 'active' : ''}"
80
73
  href={item.href}
81
- aria-current={current ? 'page' : undefined}
82
- aria-label={hasBadge(item) ? accessibleName(item) : undefined}
74
+ {...attrs}
83
75
  onclick={(e) => activate(item, e)}
84
76
  >
85
77
  <span class="glyph">
86
78
  <Icon name={item.icon} px={20} />
87
- {#if hasBadge(item)}
79
+ {#if bottomNavHasBadge(item)}
88
80
  <span class="badge" aria-hidden="true">{item.badge}</span>
89
81
  {/if}
90
82
  </span>
@@ -99,14 +91,12 @@
99
91
  class="tab {current ? 'active' : ''}"
100
92
  class:disabled={item.disabled}
101
93
  disabled={item.disabled || undefined}
102
- aria-disabled={item.disabled ? 'true' : undefined}
103
- aria-current={current ? 'page' : undefined}
104
- aria-label={hasBadge(item) ? accessibleName(item) : undefined}
94
+ {...attrs}
105
95
  onclick={(e) => activate(item, e)}
106
96
  >
107
97
  <span class="glyph">
108
98
  <Icon name={item.icon} px={20} />
109
- {#if hasBadge(item)}
99
+ {#if bottomNavHasBadge(item)}
110
100
  <span class="badge" aria-hidden="true">{item.badge}</span>
111
101
  {/if}
112
102
  </span>
@@ -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 { chartMarkKey, chartTabStop, chartWindowKey } from '../core/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,33 @@
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(chartTabStop(focusIdx, boxes.length))
194
+ const boxEls: (SVGRectElement | null)[] = $state([])
195
+ function onBoxKeydown(e: KeyboardEvent, i: number) {
196
+ const result = chartMarkKey({ index: i, count: boxes.length }, e.key)
197
+ if (!result || result.action.type !== 'focus') return
198
+ if (result.preventDefault) e.preventDefault()
199
+ const next = result.action.index
200
+ focusIdx = next
201
+ boxEls[next]?.focus()
202
+ }
203
+ function onBoxFocus(b: (typeof boxes)[number], i: number) {
204
+ focusIdx = i
205
+ show(b)
206
+ }
207
+ // Escape dismisses the tooltip whether it came from hover or focus (WCAG 1.4.13).
208
+ function onWindowKeydown(e: KeyboardEvent) {
209
+ if (chartWindowKey(active !== null, e.key)) hide()
188
210
  }
189
211
  </script>
190
212
 
213
+ <svelte:window onkeydown={onWindowKeydown} />
214
+
191
215
  <div
192
216
  class="ss-boxplot"
193
217
  class:fluid
@@ -220,24 +244,27 @@
220
244
  <line class="axis" x1="0" x2={innerW} y1={innerH} y2={innerH} />
221
245
 
222
246
  <!-- boxes -->
223
- {#each boxes as b}
247
+ {#each boxes as b, i}
224
248
  <!-- whisker centre line + caps -->
225
249
  <line class="whisker" x1={b.cx} x2={b.cx} y1={b.yLo} y2={b.yHi} />
226
250
  <line class="whisker" x1={b.cx - b.w / 4} x2={b.cx + b.w / 4} y1={b.yLo} y2={b.yLo} />
227
251
  <line class="whisker" x1={b.cx - b.w / 4} x2={b.cx + b.w / 4} y1={b.yHi} y2={b.yHi} />
228
252
 
229
253
  <!-- box (q1..q3) -->
254
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
230
255
  <rect
256
+ bind:this={boxEls[i]}
231
257
  class="box"
232
258
  x={b.x}
233
259
  y={b.yQ3}
234
260
  width={b.w}
235
261
  height={Math.max(0, b.yQ1 - b.yQ3)}
236
262
  style="fill:{b.color};stroke:{b.color}"
237
- tabindex="0"
238
- role="button"
263
+ tabindex={i === tabIdx ? 0 : -1}
264
+ role="img"
239
265
  aria-label={boxLabel(b)}
240
- onfocus={() => show(b)}
266
+ onkeydown={(e) => onBoxKeydown(e, i)}
267
+ onfocus={() => onBoxFocus(b, i)}
241
268
  onblur={hide}
242
269
  onmouseenter={() => show(b)}
243
270
  onmouseleave={hide}
@@ -287,7 +314,7 @@
287
314
  {#if tooltip && active}
288
315
  <div
289
316
  class="tooltip"
290
- role="status"
317
+ aria-hidden="true"
291
318
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
292
319
  100}%"
293
320
  >
@@ -375,7 +402,7 @@
375
402
  shape-rendering: crispEdges;
376
403
  }
377
404
  .ss-boxplot .box {
378
- cursor: pointer;
405
+ cursor: default;
379
406
  fill-opacity: 0.18;
380
407
  stroke-width: 1.5;
381
408
  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 { chartMarkKey, chartTabStop, chartWindowKey } from '../core/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,31 @@
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 (chartWindowKey(true, e.key)) 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 / core/chart-nav.ts).
169
+ let focusIndex = $state(0)
170
+ const tabStop = $derived(chartTabStop(focusIndex, nodeCount))
171
+ let nodesEl = $state<SVGGElement | null>(null)
172
+
173
+ function onNodeKeydown(e: KeyboardEvent, i: number) {
174
+ const result = chartMarkKey({ index: i, count: nodeCount, escape: 'dismiss' }, e.key)
175
+ if (!result) return
176
+ if (result.preventDefault) e.preventDefault()
177
+ if (result.action.type === 'dismiss') return hide()
178
+ const next = result.action.index
179
+ focusIndex = next
180
+ nodesEl?.querySelector<SVGElement>(`[data-index="${next}"]`)?.focus()
181
+ }
182
+
153
183
  function nodeLabel(label: string, stage: string, rank: number): string {
154
184
  return `${label}: ${stage}, rank ${rank}`
155
185
  }
@@ -190,25 +220,34 @@
190
220
  <path class="line" d={p.d} style="stroke:{p.color}" />
191
221
  {/each}
192
222
 
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
- />
223
+ <!-- nodes (series-major roving tabindex) -->
224
+ <g class="nodes" bind:this={nodesEl}>
225
+ {#each seriesNodes as s}
226
+ {#each s.nodes as n}
227
+ <!-- role="img" marks with a roving tabindex: the chart is one tab stop (DS-0161) -->
228
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
229
+ <circle
230
+ class="node"
231
+ cx={n.cx}
232
+ cy={n.cy}
233
+ r="5"
234
+ style="fill:{n.color}"
235
+ tabindex={n.i === tabStop ? 0 : -1}
236
+ data-index={n.i}
237
+ role="img"
238
+ aria-label={nodeLabel(n.label, n.stage, n.rank)}
239
+ onfocus={() => {
240
+ focusIndex = n.i
241
+ show(n.label, n.stage, n.rank, n.cx, n.cy)
242
+ }}
243
+ onblur={hide}
244
+ onkeydown={(e) => onNodeKeydown(e, n.i)}
245
+ onmouseenter={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
246
+ onmouseleave={hide}
247
+ />
248
+ {/each}
210
249
  {/each}
211
- {/each}
250
+ </g>
212
251
 
213
252
  <!-- direct series labels -->
214
253
  {#each endLabels as l}
@@ -222,7 +261,7 @@
222
261
  {#if tooltip && active}
223
262
  <div
224
263
  class="tooltip"
225
- role="status"
264
+ aria-hidden="true"
226
265
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
227
266
  100}%"
228
267
  >
@@ -304,7 +343,7 @@
304
343
  stroke-linecap: round;
305
344
  }
306
345
  .ss-bump .node {
307
- cursor: pointer;
346
+ cursor: default;
308
347
  transition: r var(--ss-dur-fast) var(--ss-ease);
309
348
  }
310
349
  .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;