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
@@ -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';
@@ -10,6 +10,11 @@
10
10
  color?: string
11
11
  }
12
12
  export type ChartVariant = 'line' | 'area' | 'bar'
13
+ /**
14
+ * Fixed stroke-dasharray cycle for line/area series (SVG user units). Series 0 is solid; the
15
+ * rest cycle through distinct dash patterns so series never differ by colour alone (WCAG 1.4.1).
16
+ */
17
+ export const CHART_DASH_CYCLE: readonly string[] = ['', '6 4', '2 3', '10 3 2 3', '1 5', '12 6']
13
18
  </script>
14
19
 
15
20
  <script lang="ts">
@@ -18,6 +23,7 @@
18
23
  import { line as shapeLine, area as shapeArea } from 'd3-shape'
19
24
  import { extent, max } from 'd3-array'
20
25
  import { resolveComponentSize, type Size } from '../config.js'
26
+ import { chartMarkKey, chartTabStop, chartWindowKey } from '../core/chart-nav.js'
21
27
 
22
28
  type XType = 'linear' | 'time' | 'band'
23
29
 
@@ -38,8 +44,15 @@
38
44
  width?: number
39
45
  /** Stretch to the container width via the viewBox (width:100%). */
40
46
  fluid?: boolean
41
- /** Show the series legend (labels + colour swatches). Default true. */
47
+ /** Show the series legend (labels + colour swatches; line/area swatches carry the dash). Default true. */
42
48
  legend?: boolean
49
+ /**
50
+ * Line/area: give each series after the first its own dash pattern (from `CHART_DASH_CYCLE`)
51
+ * so series are told apart without colour. Default true.
52
+ */
53
+ dashes?: boolean
54
+ /** Line/area: print each series' label directly at the end of its line. Default false. */
55
+ endLabels?: boolean
43
56
  /** Show a tooltip on hover/focus of a datum. Default true. */
44
57
  tooltip?: boolean
45
58
  /** SR summary + accessible name; auto-generated when absent. */
@@ -58,6 +71,8 @@
58
71
  width = 480,
59
72
  fluid = false,
60
73
  legend = true,
74
+ dashes = true,
75
+ endLabels = false,
61
76
  tooltip = true,
62
77
  summary,
63
78
  size,
@@ -65,15 +80,29 @@
65
80
 
66
81
  const PALETTE = CHART_PALETTE
67
82
 
68
- const M = { top: 8, right: 12, bottom: 24, left: 40 }
69
-
70
83
  const cleanSeries = $derived((series ?? []).filter((s) => s && Array.isArray(s.data)))
84
+ const isLineish = $derived(variant === 'line' || variant === 'area')
85
+
86
+ // Approximate advance of one mono glyph at the tick font size, in SVG user units; used only to
87
+ // reserve right-hand room for direct end-labels.
88
+ const END_LABEL_CHAR = 7
89
+ const END_LABEL_GAP = 6
90
+ const endLabelRoom = $derived(
91
+ endLabels && isLineish
92
+ ? END_LABEL_GAP + Math.max(0, ...cleanSeries.map((s) => s.label.length)) * END_LABEL_CHAR
93
+ : 0,
94
+ )
95
+ const M = $derived({ top: 8, right: 12 + endLabelRoom, bottom: 24, left: 40 })
71
96
  const allPoints = $derived(cleanSeries.flatMap((s) => s.data))
72
97
  const isEmpty = $derived(allPoints.length === 0)
73
98
 
74
99
  function colorFor(s: ChartSeries, i: number): string {
75
100
  return s.color ?? PALETTE[i % PALETTE.length]
76
101
  }
102
+ /** Dash pattern for series `i` ('' = solid). Only line/area strokes use it. */
103
+ function dashFor(i: number): string {
104
+ return dashes ? CHART_DASH_CYCLE[i % CHART_DASH_CYCLE.length] : ''
105
+ }
77
106
 
78
107
  function toNum(x: ChartXValue): number {
79
108
  if (x instanceof Date) return x.getTime()
@@ -176,9 +205,28 @@
176
205
  return cleanSeries.map((s, i) => ({
177
206
  d: lineGen(s.data) ?? '',
178
207
  color: colorFor(s, i),
208
+ dash: dashFor(i),
179
209
  label: s.label,
180
210
  }))
181
211
  })
212
+
213
+ // Direct end-labels: one per series at its last datum, nudged apart vertically so they
214
+ // never overlap.
215
+ const END_LABEL_MIN_GAP = 12
216
+ const endLabelItems = $derived.by(() => {
217
+ if (!endLabels || !isLineish) return []
218
+ const items = cleanSeries
219
+ .filter((s) => s.data.length > 0)
220
+ .map((s) => {
221
+ const last = s.data[s.data.length - 1]
222
+ return { label: s.label, x: xPos(last.x) + END_LABEL_GAP, y: yScale(last.y) }
223
+ })
224
+ .sort((a, b) => a.y - b.y)
225
+ for (let k = 1; k < items.length; k++) {
226
+ items[k].y = Math.max(items[k].y, items[k - 1].y + END_LABEL_MIN_GAP)
227
+ }
228
+ return items
229
+ })
182
230
  const areaPaths = $derived.by(() => {
183
231
  if (variant !== 'area') return []
184
232
  return cleanSeries.map((s, i) => ({
@@ -218,7 +266,7 @@
218
266
  })
219
267
  })
220
268
 
221
- // Focusable point markers (line/area datums).
269
+ // Point markers (line/area datums); one roving tab stop across all of them.
222
270
  const pointMarkers = $derived.by(() => {
223
271
  if (variant !== 'line' && variant !== 'area') return []
224
272
  return cleanSeries.flatMap((s, i) =>
@@ -233,6 +281,29 @@
233
281
  )
234
282
  })
235
283
 
284
+ // Bars flattened in render order (category, then series) for the roving tabindex.
285
+ const flatBars = $derived(barGroups.flatMap((g) => g.bars))
286
+
287
+ // Roving tabindex: the chart is ONE tab stop; arrow keys move between marks (core/chart-nav.ts).
288
+ const markCount = $derived(variant === 'bar' ? flatBars.length : pointMarkers.length)
289
+ let focusIndex = $state(0)
290
+ const tabStop = $derived(chartTabStop(focusIndex, markCount))
291
+ let marksEl = $state<SVGGElement | null>(null)
292
+
293
+ function onMarkKeydown(e: KeyboardEvent, i: number) {
294
+ const result = chartMarkKey({ index: i, count: markCount, escape: 'dismiss' }, e.key)
295
+ if (!result) return
296
+ if (result.preventDefault) e.preventDefault()
297
+ if (result.action.type === 'dismiss') return hide()
298
+ const next = result.action.index
299
+ focusIndex = next
300
+ marksEl?.querySelector<SVGElement>(`[data-index="${next}"]`)?.focus()
301
+ }
302
+ // Escape also dismisses a hover-opened tooltip (WCAG 1.4.13).
303
+ function onWindowKeydown(e: KeyboardEvent) {
304
+ if (chartWindowKey(active !== null, e.key)) hide()
305
+ }
306
+
236
307
  // Auto SR summary.
237
308
  const autoSummary = $derived.by(() => {
238
309
  if (isEmpty) return 'No data'
@@ -263,6 +334,8 @@
263
334
  }
264
335
  </script>
265
336
 
337
+ <svelte:window onkeydown={onWindowKeydown} />
338
+
266
339
  <div
267
340
  class="ss-chart"
268
341
  class:fluid
@@ -284,7 +357,7 @@
284
357
  preserveAspectRatio="xMidYMid meet"
285
358
  role="presentation"
286
359
  >
287
- <g transform="translate({M.left},{M.top})">
360
+ <g transform="translate({M.left},{M.top})" bind:this={marksEl}>
288
361
  <!-- gridlines + y axis -->
289
362
  {#each yTicks as t}
290
363
  <line class="grid" x1="0" x2={innerW} y1={yScale(t)} y2={yScale(t)} />
@@ -307,19 +380,35 @@
307
380
 
308
381
  {#if variant === 'line' || variant === 'area'}
309
382
  {#each linePaths as p}
310
- <path class="line" d={p.d} style="stroke:{p.color}" />
383
+ <path
384
+ class="line"
385
+ class:dashed={p.dash !== ''}
386
+ d={p.d}
387
+ style="stroke:{p.color}"
388
+ stroke-dasharray={p.dash || undefined}
389
+ />
311
390
  {/each}
312
- {#each pointMarkers as m}
391
+ {#each endLabelItems as l, k (k)}
392
+ <text class="end-label" x={l.x} y={l.y} dy="0.32em" aria-hidden="true">{l.label}</text
393
+ >
394
+ {/each}
395
+ {#each pointMarkers as m, i (i)}
396
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
313
397
  <circle
314
398
  class="point"
315
399
  cx={m.cx}
316
400
  cy={m.cy}
317
401
  r="4"
318
402
  style="fill:{m.color}"
319
- tabindex="0"
320
- role="button"
403
+ tabindex={i === tabStop ? 0 : -1}
404
+ role="img"
405
+ data-index={i}
321
406
  aria-label={datumLabel(m.label, m.x, m.value)}
322
- onfocus={() => show(m.label, m.x, m.value, m.cx, m.cy)}
407
+ onkeydown={(e) => onMarkKeydown(e, i)}
408
+ onfocus={() => {
409
+ focusIndex = i
410
+ show(m.label, m.x, m.value, m.cx, m.cy)
411
+ }}
323
412
  onblur={hide}
324
413
  onmouseenter={() => show(m.label, m.x, m.value, m.cx, m.cy)}
325
414
  onmouseleave={hide}
@@ -328,24 +417,28 @@
328
417
  {/if}
329
418
 
330
419
  {#if variant === 'bar'}
331
- {#each barGroups as g}
332
- {#each g.bars as b}
333
- <rect
334
- class="bar"
335
- x={b.x}
336
- y={b.y}
337
- width={b.w}
338
- height={b.h}
339
- style="fill:{b.color}"
340
- tabindex="0"
341
- role="button"
342
- aria-label={datumLabel(b.label, b.cat, b.value)}
343
- onfocus={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
344
- onblur={hide}
345
- onmouseenter={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
346
- onmouseleave={hide}
347
- />
348
- {/each}
420
+ {#each flatBars as b, i (i)}
421
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
422
+ <rect
423
+ class="bar"
424
+ x={b.x}
425
+ y={b.y}
426
+ width={b.w}
427
+ height={b.h}
428
+ style="fill:{b.color}"
429
+ tabindex={i === tabStop ? 0 : -1}
430
+ role="img"
431
+ data-index={i}
432
+ aria-label={datumLabel(b.label, b.cat, b.value)}
433
+ onkeydown={(e) => onMarkKeydown(e, i)}
434
+ onfocus={() => {
435
+ focusIndex = i
436
+ show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)
437
+ }}
438
+ onblur={hide}
439
+ onmouseenter={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
440
+ onmouseleave={hide}
441
+ />
349
442
  {/each}
350
443
  {/if}
351
444
  </g>
@@ -354,7 +447,7 @@
354
447
  {#if tooltip && active}
355
448
  <div
356
449
  class="tooltip"
357
- role="status"
450
+ aria-hidden="true"
358
451
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
359
452
  100}%"
360
453
  >
@@ -368,7 +461,26 @@
368
461
  <ul class="legend">
369
462
  {#each cleanSeries as s, i}
370
463
  <li class="legend-item">
371
- <span class="swatch" style="background:{colorFor(s, i)}" aria-hidden="true"></span>
464
+ {#if isLineish}
465
+ <svg
466
+ class="swatch-line"
467
+ viewBox="0 0 24 10"
468
+ preserveAspectRatio="none"
469
+ aria-hidden="true"
470
+ data-dash={dashFor(i) || 'solid'}
471
+ >
472
+ <line
473
+ x1="0"
474
+ x2="24"
475
+ y1="5"
476
+ y2="5"
477
+ style="stroke:{colorFor(s, i)}"
478
+ stroke-dasharray={dashFor(i) || undefined}
479
+ />
480
+ </svg>
481
+ {:else}
482
+ <span class="swatch" style="background:{colorFor(s, i)}" aria-hidden="true"></span>
483
+ {/if}
372
484
  <span class="legend-label">{s.label}</span>
373
485
  </li>
374
486
  {/each}
@@ -446,12 +558,21 @@
446
558
  stroke-linejoin: round;
447
559
  stroke-linecap: round;
448
560
  }
561
+ .ss-chart .line.dashed {
562
+ /* round caps would swallow short dash gaps */
563
+ stroke-linecap: butt;
564
+ }
565
+ .ss-chart .end-label {
566
+ font-family: var(--ss-font-mono);
567
+ font-size: var(--ss-ui-xs);
568
+ fill: var(--ss-fg);
569
+ }
449
570
  .ss-chart .area {
450
571
  opacity: 0.18;
451
572
  stroke: none;
452
573
  }
453
574
  .ss-chart .point {
454
- cursor: pointer;
575
+ cursor: default;
455
576
  transition: r var(--ss-dur-fast) var(--ss-ease);
456
577
  }
457
578
  .ss-chart .point:hover, .ss-chart .point:focus-visible {
@@ -463,7 +584,7 @@
463
584
  stroke-width: 2;
464
585
  }
465
586
  .ss-chart .bar {
466
- cursor: pointer;
587
+ cursor: default;
467
588
  transition: opacity var(--ss-dur-fast) var(--ss-ease);
468
589
  }
469
590
  .ss-chart .bar:hover {
@@ -518,4 +639,17 @@
518
639
  height: 10px;
519
640
  flex: none;
520
641
  display: inline-block;
642
+ }
643
+ .ss-chart {
644
+ /* line/area legend key: a short stroke with the series' dash pattern */
645
+ }
646
+ .ss-chart .swatch-line {
647
+ inline-size: calc(var(--ss-icon) * 1.2);
648
+ block-size: calc(var(--ss-icon) * 0.5);
649
+ flex: none;
650
+ display: inline-block;
651
+ overflow: visible;
652
+ }
653
+ .ss-chart .swatch-line line {
654
+ stroke-width: 2;
521
655
  }</style>
@@ -9,6 +9,11 @@ export interface ChartSeries {
9
9
  color?: string;
10
10
  }
11
11
  export type ChartVariant = 'line' | 'area' | 'bar';
12
+ /**
13
+ * Fixed stroke-dasharray cycle for line/area series (SVG user units). Series 0 is solid; the
14
+ * rest cycle through distinct dash patterns so series never differ by colour alone (WCAG 1.4.1).
15
+ */
16
+ export declare const CHART_DASH_CYCLE: readonly string[];
12
17
  import { type Size } from '../config.js';
13
18
  type XType = 'linear' | 'time' | 'band';
14
19
  interface Props {
@@ -28,8 +33,15 @@ interface Props {
28
33
  width?: number;
29
34
  /** Stretch to the container width via the viewBox (width:100%). */
30
35
  fluid?: boolean;
31
- /** Show the series legend (labels + colour swatches). Default true. */
36
+ /** Show the series legend (labels + colour swatches; line/area swatches carry the dash). Default true. */
32
37
  legend?: boolean;
38
+ /**
39
+ * Line/area: give each series after the first its own dash pattern (from `CHART_DASH_CYCLE`)
40
+ * so series are told apart without colour. Default true.
41
+ */
42
+ dashes?: boolean;
43
+ /** Line/area: print each series' label directly at the end of its line. Default false. */
44
+ endLabels?: boolean;
33
45
  /** Show a tooltip on hover/focus of a datum. Default true. */
34
46
  tooltip?: boolean;
35
47
  /** SR summary + accessible name; auto-generated when absent. */
@@ -0,0 +1,210 @@
1
+ <script lang="ts">
2
+ // ─────────────────────────────────────────────────────────────────────────
3
+ // Checkbox — DS-0197. A native `<input type="checkbox">` restyled as a square
4
+ // box (house rule: zero radius), so Space, label presses, form submission and
5
+ // the checked / unchecked / mixed semantics all come from the platform. The
6
+ // input itself IS the box (`appearance: none`), which is why the base focus
7
+ // ring lands on it; the check glyph and the indeterminate dash sit on top.
8
+ // ─────────────────────────────────────────────────────────────────────────
9
+ import Icon from './Icon.svelte'
10
+ import { resolveComponentSize, type Size } from '../config.js'
11
+ import { checkboxInputAttrs, checkboxToggle } from '../core/checkbox.js'
12
+
13
+ interface Props {
14
+ /** Checked state (bindable). */
15
+ checked?: boolean
16
+ /**
17
+ * Mixed state (bindable): shown as a dash and announced as "mixed". A user
18
+ * toggle always clears it and lands on checked.
19
+ */
20
+ indeterminate?: boolean
21
+ /** Visible label next to the box; becomes the accessible name. */
22
+ label?: string
23
+ /**
24
+ * Visually hide the label while keeping it as the accessible name — for
25
+ * dense rows (table row selection) where the visible context sits elsewhere.
26
+ */
27
+ labelHidden?: boolean
28
+ /** Id for the underlying input. */
29
+ id?: string
30
+ /** Form field name: the checkbox is submitted with its form when checked. */
31
+ name?: string
32
+ /** Submitted value when checked (the browser default is `on`). */
33
+ value?: string
34
+ /** Disable the checkbox: inert + non-toggling, not submitted. */
35
+ disabled?: boolean
36
+ /** Token size (sm|md|lg); inherits the global size when unset. */
37
+ size?: Size
38
+ /** Id of an element that further describes the checkbox (→ aria-describedby). */
39
+ describedby?: string
40
+ /**
41
+ * Fired after `checked` changes, with the new value. There is no
42
+ * `details.reason`: the native input reports a press on the box, a press on
43
+ * the label and Space as the same event.
44
+ */
45
+ onchange?: (checked: boolean) => void
46
+ }
47
+
48
+ let {
49
+ checked = $bindable(false),
50
+ indeterminate = $bindable(false),
51
+ label,
52
+ labelHidden = false,
53
+ id,
54
+ name,
55
+ value,
56
+ disabled = false,
57
+ size,
58
+ describedby,
59
+ onchange,
60
+ }: Props = $props()
61
+
62
+ const uid = $props.id()
63
+ const inputId = $derived(id ?? uid)
64
+
65
+ let input = $state<HTMLInputElement>()
66
+
67
+ // `indeterminate` exists only as a DOM property (no HTML attribute).
68
+ $effect(() => {
69
+ if (input) input.indeterminate = indeterminate
70
+ })
71
+
72
+ // The browser has already toggled the input; the decision is still the core's
73
+ // (shared with vanilla/checkbox.ts), so its result is written back.
74
+ function onInputChange() {
75
+ if (!input) return
76
+ const next = checkboxToggle({ checked, indeterminate, disabled })
77
+ if (next === null) {
78
+ input.checked = checked
79
+ input.indeterminate = indeterminate
80
+ return
81
+ }
82
+ checked = next.checked
83
+ indeterminate = next.indeterminate
84
+ input.checked = next.checked
85
+ onchange?.(next.checked)
86
+ }
87
+
88
+ const sizeAttr = $derived(resolveComponentSize('Checkbox', size))
89
+ </script>
90
+
91
+ <label
92
+ class="ss-checkbox"
93
+ class:has-label={label != null && !labelHidden}
94
+ data-size-variant={sizeAttr}
95
+ >
96
+ <span class="control">
97
+ <input
98
+ bind:this={input}
99
+ id={inputId}
100
+ class="input"
101
+ type="checkbox"
102
+ {name}
103
+ {value}
104
+ {checked}
105
+ {disabled}
106
+ aria-describedby={describedby}
107
+ {...checkboxInputAttrs(indeterminate)}
108
+ onchange={onInputChange}
109
+ />
110
+ <!-- Both marks are always in the DOM; the input's own state picks one in CSS. -->
111
+ <span class="glyph" aria-hidden="true">
112
+ <span class="check"><Icon name="check" strokeWidth={3} /></span>
113
+ <span class="dash"></span>
114
+ </span>
115
+ </span>
116
+ {#if label != null}
117
+ <span class="label" class:sr-only={labelHidden}>{label}</span>
118
+ {/if}
119
+ </label>
120
+
121
+ <style>.ss-checkbox {
122
+ position: relative;
123
+ display: inline-flex;
124
+ align-items: center;
125
+ min-inline-size: var(--ss-s-6);
126
+ min-block-size: var(--ss-s-6);
127
+ cursor: pointer;
128
+ }
129
+ .ss-checkbox.has-label {
130
+ gap: var(--ss-checkbox-gap, var(--ss-gap-sm));
131
+ }
132
+ .ss-checkbox .control {
133
+ position: relative;
134
+ flex: 0 0 auto;
135
+ display: inline-grid;
136
+ inline-size: var(--ss-checkbox-size, calc(var(--ss-control-font) + 4px));
137
+ block-size: var(--ss-checkbox-size, calc(var(--ss-control-font) + 4px));
138
+ }
139
+ .ss-checkbox .input {
140
+ grid-area: 1/1;
141
+ appearance: none;
142
+ box-sizing: border-box;
143
+ inline-size: 100%;
144
+ block-size: 100%;
145
+ margin: 0;
146
+ border-radius: 0;
147
+ border: 1px solid var(--ss-fg-faint);
148
+ background: var(--ss-bg);
149
+ cursor: inherit;
150
+ transition: background var(--ss-dur-fast) var(--ss-ease), border-color var(--ss-dur-fast) var(--ss-ease);
151
+ }
152
+ .ss-checkbox .input:not(:disabled):hover {
153
+ border-color: var(--ss-fg);
154
+ }
155
+ .ss-checkbox .input:checked, .ss-checkbox .input:indeterminate {
156
+ background: var(--ss-primary);
157
+ border-color: var(--ss-primary);
158
+ }
159
+ .ss-checkbox .glyph {
160
+ grid-area: 1/1;
161
+ display: grid;
162
+ place-items: center;
163
+ pointer-events: none;
164
+ color: var(--ss-fg-on-primary);
165
+ --ss-icon: calc(var(--ss-checkbox-size, calc(var(--ss-control-font) + 4px)) - 6px);
166
+ }
167
+ .ss-checkbox .check,
168
+ .ss-checkbox .dash {
169
+ display: none;
170
+ }
171
+ .ss-checkbox .dash {
172
+ inline-size: calc(var(--ss-checkbox-size, calc(var(--ss-control-font) + 4px)) - 8px);
173
+ block-size: 2px;
174
+ background: currentColor;
175
+ }
176
+ .ss-checkbox .input:checked:not(:indeterminate) + .glyph .check {
177
+ display: grid;
178
+ }
179
+ .ss-checkbox .input:indeterminate + .glyph .dash {
180
+ display: block;
181
+ }
182
+ .ss-checkbox .label {
183
+ font: 500 var(--ss-control-font)/1.3 var(--ss-font-body);
184
+ color: var(--ss-fg);
185
+ user-select: none;
186
+ }
187
+ .ss-checkbox .label.sr-only {
188
+ position: absolute;
189
+ width: 1px;
190
+ height: 1px;
191
+ padding: 0;
192
+ margin: -1px;
193
+ overflow: hidden;
194
+ clip: rect(0, 0, 0, 0);
195
+ white-space: nowrap;
196
+ border: 0;
197
+ }
198
+ .ss-checkbox:has(.input:disabled) {
199
+ cursor: not-allowed;
200
+ }
201
+ .ss-checkbox:has(.input:disabled) .control,
202
+ .ss-checkbox:has(.input:disabled) .label {
203
+ opacity: 0.45;
204
+ }
205
+
206
+ @media (prefers-reduced-motion: reduce) {
207
+ .ss-checkbox .input {
208
+ transition: none;
209
+ }
210
+ }</style>