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.
- package/README.md +9 -6
- package/dist/chart-nav.d.ts +13 -0
- package/dist/chart-nav.js +35 -0
- package/dist/components/Accordion.svelte +7 -2
- package/dist/components/Badge.svelte +12 -7
- package/dist/components/Badge.svelte.d.ts +2 -1
- package/dist/components/BottomNav.svelte +4 -0
- package/dist/components/BoxPlot.svelte +33 -7
- package/dist/components/BumpChart.svelte +68 -26
- package/dist/components/Button.svelte +23 -1
- package/dist/components/Button.svelte.d.ts +5 -1
- package/dist/components/Card.svelte +48 -15
- package/dist/components/Card.svelte.d.ts +10 -1
- package/dist/components/Chart.svelte +169 -32
- package/dist/components/Chart.svelte.d.ts +13 -1
- package/dist/components/DateField.svelte +1 -1
- package/dist/components/FileDrop.svelte +81 -14
- package/dist/components/FileDrop.svelte.d.ts +6 -0
- package/dist/components/Heatmap.svelte +128 -50
- package/dist/components/Heatmap.svelte.d.ts +2 -1
- package/dist/components/Icon.svelte +12 -3
- package/dist/components/Icon.svelte.d.ts +4 -0
- package/dist/components/Input.svelte +6 -3
- package/dist/components/Kbd.svelte +17 -1
- package/dist/components/Kbd.svelte.d.ts +9 -0
- package/dist/components/Link.svelte +25 -14
- package/dist/components/LogStream.svelte +34 -9
- package/dist/components/Menu.svelte +12 -8
- package/dist/components/Menu.svelte.d.ts +2 -2
- package/dist/components/MetricTile.svelte +16 -2
- package/dist/components/MetricTile.svelte.d.ts +6 -0
- package/dist/components/Modal.svelte +47 -7
- package/dist/components/Modal.svelte.d.ts +11 -3
- package/dist/components/NumberField.svelte +33 -10
- package/dist/components/Pagination.svelte +7 -4
- package/dist/components/ScatterPlot.svelte +44 -7
- package/dist/components/SearchPalette.svelte +102 -23
- package/dist/components/SearchPalette.svelte.d.ts +5 -0
- package/dist/components/SegmentedControl.svelte +14 -5
- package/dist/components/Select.svelte +3 -4
- package/dist/components/ServiceCard.svelte +108 -68
- package/dist/components/ServiceCard.svelte.d.ts +8 -3
- package/dist/components/ShortcutsHelp.svelte +3 -2
- package/dist/components/Sidebar.svelte +84 -59
- package/dist/components/Sidebar.svelte.d.ts +5 -0
- package/dist/components/Switch.svelte +4 -8
- package/dist/components/Table.svelte +20 -13
- package/dist/components/Table.svelte.d.ts +6 -2
- package/dist/components/Textarea.svelte +1 -1
- package/dist/components/TierList.svelte +598 -0
- package/dist/components/TierList.svelte.d.ts +37 -0
- package/dist/components/Toaster.svelte +144 -21
- package/dist/components/Tooltip.svelte +101 -13
- package/dist/components/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Topbar.svelte +39 -16
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +1 -0
- package/dist/icons.d.ts +20 -2
- package/dist/icons.js +43 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/theme.css +25 -27
- package/dist/tierlist-core.d.ts +97 -0
- package/dist/tierlist-core.js +206 -0
- package/dist/tokens.css +25 -0
- package/dist/vanilla/accordion.js +7 -3
- package/dist/vanilla/fields.js +19 -6
- package/dist/vanilla/index.d.ts +2 -1
- package/dist/vanilla/index.js +7 -4
- package/dist/vanilla/menu.js +12 -1
- package/dist/vanilla/modal.d.ts +4 -0
- package/dist/vanilla/modal.js +57 -2
- package/dist/vanilla/segmented.js +13 -4
- package/dist/vanilla/tierlist.d.ts +8 -0
- package/dist/vanilla/tierlist.js +300 -0
- package/dist/vanilla/toast.d.ts +11 -3
- package/dist/vanilla/toast.js +125 -10
- package/dist/vanilla/tooltip.d.ts +5 -1
- package/dist/vanilla/tooltip.js +57 -10
- package/dist/vanilla.css +581 -158
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -84,22 +84,25 @@ 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.
|
|
88
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
89
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/dssoca@0.
|
|
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
|
```
|
|
93
93
|
|
|
94
94
|
Every component page in the docs has an **HTML** section with copy-paste markup; the full contract
|
|
95
|
-
is in the _Plain HTML & CSS_ guide.
|
|
95
|
+
is in the _Plain HTML & CSS_ guide. For whole pages, see **[Inspirations](https://dssoca.vercel.app/inspirations/)**
|
|
96
|
+
(standalone site: <https://httpassoca.github.io/dssoca/>)
|
|
97
|
+
— twelve example websites (dashboard, social feed, chat, storefront, blog, …) written in plain
|
|
98
|
+
HTML on this path, deployed from `inspirations/` to GitHub Pages.
|
|
96
99
|
|
|
97
100
|
## What's in the box
|
|
98
101
|
|
|
99
|
-
**Components (
|
|
102
|
+
**Components (24):** `Icon`, `Badge`, `Button`, `Input`, `Textarea`, `Card`, `Sparkline`,
|
|
100
103
|
`ServiceCard`, `MetricTile`, `Topbar`, `Sidebar`, `BottomNav`, `Menu`, `Link`,
|
|
101
104
|
`SegmentedControl`, `Accordion`, `LogStream`, `Toaster`, `EmptyState`, `Image`,
|
|
102
|
-
`Heading`, `Container`, `Spinner`.
|
|
105
|
+
`Heading`, `Container`, `Spinner`, `TierList`.
|
|
103
106
|
|
|
104
107
|
**Toasts:** `toast` (`.success` / `.error` / `.info` / `.loading` / `.promise`) + the `toasts`
|
|
105
108
|
store (`update` / `dismiss` / `pause` / `resume` / `clear`, `max` cap) — render once with
|
|
@@ -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:
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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=
|
|
238
|
-
role="
|
|
262
|
+
tabindex={i === tabIdx ? 0 : -1}
|
|
263
|
+
role="img"
|
|
239
264
|
aria-label={boxLabel(b)}
|
|
240
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
195
|
-
{#each
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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;
|
|
@@ -18,7 +18,16 @@
|
|
|
18
18
|
children: Snippet
|
|
19
19
|
/** Makes the whole card a primary link to this href. */
|
|
20
20
|
href?: string
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Off-site `href` (DS-0158): the overlay link opens in a new tab with
|
|
23
|
+
* `rel="noopener noreferrer"` and announces "(opens in a new tab)" — Sidebar's `external`
|
|
24
|
+
* convention.
|
|
25
|
+
*/
|
|
26
|
+
external?: boolean
|
|
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
|
+
*/
|
|
22
31
|
onclick?: (e: MouseEvent | KeyboardEvent) => void
|
|
23
32
|
/** Surface style: outlined (default) or elevated (shadow tokens). */
|
|
24
33
|
variant?: 'outlined' | 'elevated'
|
|
@@ -36,6 +45,7 @@
|
|
|
36
45
|
footer,
|
|
37
46
|
children,
|
|
38
47
|
href,
|
|
48
|
+
external = false,
|
|
39
49
|
onclick,
|
|
40
50
|
variant = 'outlined',
|
|
41
51
|
size,
|
|
@@ -47,26 +57,21 @@
|
|
|
47
57
|
|
|
48
58
|
const isTitleSnippet = $derived(typeof title === 'function')
|
|
49
59
|
const interactive = $derived(Boolean(href || onclick))
|
|
50
|
-
|
|
51
|
-
function onKeydown(e: KeyboardEvent) {
|
|
52
|
-
if (onclick && !href && (e.key === 'Enter' || e.key === ' ')) {
|
|
53
|
-
e.preventDefault()
|
|
54
|
-
onclick(e)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
60
|
</script>
|
|
58
61
|
|
|
59
|
-
<!--
|
|
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
|
+
-->
|
|
60
68
|
<div
|
|
61
69
|
class="ss-card"
|
|
62
70
|
class:elevated={variant === 'elevated'}
|
|
63
71
|
class:interactive
|
|
64
72
|
data-size-variant={resolveComponentSize('Card', size)}
|
|
65
|
-
role={
|
|
66
|
-
tabindex={interactive && !href ? 0 : undefined}
|
|
73
|
+
role={title ? 'region' : undefined}
|
|
67
74
|
aria-labelledby={title ? titleId : undefined}
|
|
68
|
-
onclick={!href ? onclick : undefined}
|
|
69
|
-
onkeydown={!href ? onKeydown : undefined}
|
|
70
75
|
>
|
|
71
76
|
{#if media}
|
|
72
77
|
<div class="media">{@render media()}</div>
|
|
@@ -99,12 +104,19 @@
|
|
|
99
104
|
<a
|
|
100
105
|
class="overlay"
|
|
101
106
|
{href}
|
|
107
|
+
target={external ? '_blank' : undefined}
|
|
108
|
+
rel={external ? 'noopener noreferrer' : undefined}
|
|
102
109
|
{onclick}
|
|
103
|
-
onkeydown={onKeydown}
|
|
104
110
|
aria-labelledby={title ? titleId : undefined}
|
|
105
111
|
>
|
|
106
|
-
<span class="sr-only"
|
|
112
|
+
<span class="sr-only"
|
|
113
|
+
>{typeof title === 'string' ? title : 'Open'}{external ? ' (opens in a new tab)' : ''}</span
|
|
114
|
+
>
|
|
107
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>
|
|
108
120
|
{/if}
|
|
109
121
|
</div>
|
|
110
122
|
|
|
@@ -206,6 +218,16 @@
|
|
|
206
218
|
|
|
207
219
|
.overlay {
|
|
208
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;
|
|
209
231
|
}
|
|
210
232
|
.overlay::after {
|
|
211
233
|
content: "";
|
|
@@ -213,6 +235,13 @@
|
|
|
213
235
|
inset: 0;
|
|
214
236
|
z-index: 0;
|
|
215
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
|
+
}
|
|
216
245
|
|
|
217
246
|
.sr-only {
|
|
218
247
|
position: absolute;
|
|
@@ -224,4 +253,8 @@
|
|
|
224
253
|
clip: rect(0 0 0 0);
|
|
225
254
|
white-space: nowrap;
|
|
226
255
|
border: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.overlay::before {
|
|
259
|
+
content: none;
|
|
227
260
|
}</style>
|
|
@@ -16,7 +16,16 @@ interface Props {
|
|
|
16
16
|
children: Snippet;
|
|
17
17
|
/** Makes the whole card a primary link to this href. */
|
|
18
18
|
href?: string;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Off-site `href` (DS-0158): the overlay link opens in a new tab with
|
|
21
|
+
* `rel="noopener noreferrer"` and announces "(opens in a new tab)" — Sidebar's `external`
|
|
22
|
+
* convention.
|
|
23
|
+
*/
|
|
24
|
+
external?: boolean;
|
|
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
|
+
*/
|
|
20
29
|
onclick?: (e: MouseEvent | KeyboardEvent) => void;
|
|
21
30
|
/** Surface style: outlined (default) or elevated (shadow tokens). */
|
|
22
31
|
variant?: 'outlined' | 'elevated';
|