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
@@ -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 { chartNavStep } from '../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,32 @@
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 (chart-nav.ts).
288
+ const markCount = $derived(variant === 'bar' ? flatBars.length : pointMarkers.length)
289
+ let focusIndex = $state(0)
290
+ const tabStop = $derived(Math.min(focusIndex, Math.max(0, markCount - 1)))
291
+ let marksEl = $state<SVGGElement | null>(null)
292
+
293
+ function onMarkKeydown(e: KeyboardEvent, i: number) {
294
+ if (e.key === 'Escape') {
295
+ hide()
296
+ return
297
+ }
298
+ // SVG geometry does not mirror in RTL, so Left/Right stay physical.
299
+ const next = chartNavStep(e.key, i, markCount)
300
+ if (next === null) return
301
+ e.preventDefault()
302
+ focusIndex = next
303
+ marksEl?.querySelector<SVGElement>(`[data-index="${next}"]`)?.focus()
304
+ }
305
+ // Escape also dismisses a hover-opened tooltip (WCAG 1.4.13).
306
+ function onWindowKeydown(e: KeyboardEvent) {
307
+ if (e.key === 'Escape' && active) hide()
308
+ }
309
+
236
310
  // Auto SR summary.
237
311
  const autoSummary = $derived.by(() => {
238
312
  if (isEmpty) return 'No data'
@@ -263,6 +337,8 @@
263
337
  }
264
338
  </script>
265
339
 
340
+ <svelte:window onkeydown={onWindowKeydown} />
341
+
266
342
  <div
267
343
  class="ss-chart"
268
344
  class:fluid
@@ -284,7 +360,7 @@
284
360
  preserveAspectRatio="xMidYMid meet"
285
361
  role="presentation"
286
362
  >
287
- <g transform="translate({M.left},{M.top})">
363
+ <g transform="translate({M.left},{M.top})" bind:this={marksEl}>
288
364
  <!-- gridlines + y axis -->
289
365
  {#each yTicks as t}
290
366
  <line class="grid" x1="0" x2={innerW} y1={yScale(t)} y2={yScale(t)} />
@@ -307,19 +383,35 @@
307
383
 
308
384
  {#if variant === 'line' || variant === 'area'}
309
385
  {#each linePaths as p}
310
- <path class="line" d={p.d} style="stroke:{p.color}" />
386
+ <path
387
+ class="line"
388
+ class:dashed={p.dash !== ''}
389
+ d={p.d}
390
+ style="stroke:{p.color}"
391
+ stroke-dasharray={p.dash || undefined}
392
+ />
311
393
  {/each}
312
- {#each pointMarkers as m}
394
+ {#each endLabelItems as l, k (k)}
395
+ <text class="end-label" x={l.x} y={l.y} dy="0.32em" aria-hidden="true">{l.label}</text
396
+ >
397
+ {/each}
398
+ {#each pointMarkers as m, i (i)}
399
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
313
400
  <circle
314
401
  class="point"
315
402
  cx={m.cx}
316
403
  cy={m.cy}
317
404
  r="4"
318
405
  style="fill:{m.color}"
319
- tabindex="0"
320
- role="button"
406
+ tabindex={i === tabStop ? 0 : -1}
407
+ role="img"
408
+ data-index={i}
321
409
  aria-label={datumLabel(m.label, m.x, m.value)}
322
- onfocus={() => show(m.label, m.x, m.value, m.cx, m.cy)}
410
+ onkeydown={(e) => onMarkKeydown(e, i)}
411
+ onfocus={() => {
412
+ focusIndex = i
413
+ show(m.label, m.x, m.value, m.cx, m.cy)
414
+ }}
323
415
  onblur={hide}
324
416
  onmouseenter={() => show(m.label, m.x, m.value, m.cx, m.cy)}
325
417
  onmouseleave={hide}
@@ -328,24 +420,28 @@
328
420
  {/if}
329
421
 
330
422
  {#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}
423
+ {#each flatBars as b, i (i)}
424
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
425
+ <rect
426
+ class="bar"
427
+ x={b.x}
428
+ y={b.y}
429
+ width={b.w}
430
+ height={b.h}
431
+ style="fill:{b.color}"
432
+ tabindex={i === tabStop ? 0 : -1}
433
+ role="img"
434
+ data-index={i}
435
+ aria-label={datumLabel(b.label, b.cat, b.value)}
436
+ onkeydown={(e) => onMarkKeydown(e, i)}
437
+ onfocus={() => {
438
+ focusIndex = i
439
+ show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)
440
+ }}
441
+ onblur={hide}
442
+ onmouseenter={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
443
+ onmouseleave={hide}
444
+ />
349
445
  {/each}
350
446
  {/if}
351
447
  </g>
@@ -354,7 +450,7 @@
354
450
  {#if tooltip && active}
355
451
  <div
356
452
  class="tooltip"
357
- role="status"
453
+ aria-hidden="true"
358
454
  style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
359
455
  100}%"
360
456
  >
@@ -368,7 +464,26 @@
368
464
  <ul class="legend">
369
465
  {#each cleanSeries as s, i}
370
466
  <li class="legend-item">
371
- <span class="swatch" style="background:{colorFor(s, i)}" aria-hidden="true"></span>
467
+ {#if isLineish}
468
+ <svg
469
+ class="swatch-line"
470
+ viewBox="0 0 24 10"
471
+ preserveAspectRatio="none"
472
+ aria-hidden="true"
473
+ data-dash={dashFor(i) || 'solid'}
474
+ >
475
+ <line
476
+ x1="0"
477
+ x2="24"
478
+ y1="5"
479
+ y2="5"
480
+ style="stroke:{colorFor(s, i)}"
481
+ stroke-dasharray={dashFor(i) || undefined}
482
+ />
483
+ </svg>
484
+ {:else}
485
+ <span class="swatch" style="background:{colorFor(s, i)}" aria-hidden="true"></span>
486
+ {/if}
372
487
  <span class="legend-label">{s.label}</span>
373
488
  </li>
374
489
  {/each}
@@ -446,12 +561,21 @@
446
561
  stroke-linejoin: round;
447
562
  stroke-linecap: round;
448
563
  }
564
+ .ss-chart .line.dashed {
565
+ /* round caps would swallow short dash gaps */
566
+ stroke-linecap: butt;
567
+ }
568
+ .ss-chart .end-label {
569
+ font-family: var(--ss-font-mono);
570
+ font-size: var(--ss-ui-xs);
571
+ fill: var(--ss-fg);
572
+ }
449
573
  .ss-chart .area {
450
574
  opacity: 0.18;
451
575
  stroke: none;
452
576
  }
453
577
  .ss-chart .point {
454
- cursor: pointer;
578
+ cursor: default;
455
579
  transition: r var(--ss-dur-fast) var(--ss-ease);
456
580
  }
457
581
  .ss-chart .point:hover, .ss-chart .point:focus-visible {
@@ -463,7 +587,7 @@
463
587
  stroke-width: 2;
464
588
  }
465
589
  .ss-chart .bar {
466
- cursor: pointer;
590
+ cursor: default;
467
591
  transition: opacity var(--ss-dur-fast) var(--ss-ease);
468
592
  }
469
593
  .ss-chart .bar:hover {
@@ -518,4 +642,17 @@
518
642
  height: 10px;
519
643
  flex: none;
520
644
  display: inline-block;
645
+ }
646
+ .ss-chart {
647
+ /* line/area legend key: a short stroke with the series' dash pattern */
648
+ }
649
+ .ss-chart .swatch-line {
650
+ inline-size: calc(var(--ss-icon) * 1.2);
651
+ block-size: calc(var(--ss-icon) * 0.5);
652
+ flex: none;
653
+ display: inline-block;
654
+ overflow: visible;
655
+ }
656
+ .ss-chart .swatch-line line {
657
+ stroke-width: 2;
521
658
  }</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. */
@@ -112,7 +112,7 @@
112
112
  }
113
113
  .ss-datefield .lbl .req {
114
114
  color: var(--ss-red);
115
- margin-left: 2px;
115
+ margin-inline-start: 2px;
116
116
  }
117
117
  .ss-datefield .control {
118
118
  display: flex;
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { tick } from 'svelte'
2
3
  import { resolveComponentSize, type Size } from '../config.js'
3
4
 
4
5
  interface Props {
@@ -20,6 +21,12 @@
20
21
  files?: File[]
21
22
  /** Fired with the resolved file list whenever the selection changes. */
22
23
  onfiles?: (files: File[]) => void
24
+ /**
25
+ * Fired with the files a selection/drop discarded (wrong type for `accept`,
26
+ * or extras when `multiple` is false). Rejections are also announced
27
+ * through a polite live region.
28
+ */
29
+ onreject?: (files: File[]) => void
23
30
  }
24
31
  let {
25
32
  label,
@@ -31,10 +38,13 @@
31
38
  error,
32
39
  files = $bindable([]),
33
40
  onfiles,
41
+ onreject,
34
42
  }: Props = $props()
35
43
 
36
44
  const uid = $props.id()
37
45
  const inputId = `${uid}-input`
46
+ const labelId = `${uid}-label`
47
+ const titleId = `${uid}-title`
38
48
  const hintId = `${uid}-hint`
39
49
  const errorId = `${uid}-error`
40
50
 
@@ -43,14 +53,17 @@
43
53
  )
44
54
  const resolvedSize = $derived(resolveComponentSize('FileDrop', size))
45
55
 
46
- // The zone's accessible name: explicit label, else a sensible default; hint
47
- // is folded in for extra context when present.
48
- const accName = $derived(
49
- [label || 'Upload files', hint].filter(Boolean).join('. ') || 'Upload files',
50
- )
56
+ // The zone is named by its visible text (label + "Drop files here") so the
57
+ // accessible name matches what speech-input users see (WCAG 2.5.3). The hint
58
+ // stays in aria-describedby only, so it isn't read twice.
59
+ const labelledBy = $derived(label ? `${labelId} ${titleId}` : titleId)
51
60
 
61
+ let rootEl = $state<HTMLDivElement>()
62
+ let zoneEl = $state<HTMLDivElement>()
52
63
  let inputEl = $state<HTMLInputElement>()
53
64
  let dragging = $state(false)
65
+ // Polite live region text; the region is always mounted so updates announce.
66
+ let status = $state('')
54
67
 
55
68
  /** Human-readable byte size (1 KB = 1024 B). */
56
69
  function humanSize(bytes: number): string {
@@ -81,13 +94,35 @@
81
94
  })
82
95
  }
83
96
 
84
- /** Apply accept/multiple, update state, notify. */
97
+ /** Set the live-region text, clearing first so a repeat message re-announces. */
98
+ async function announce(message: string) {
99
+ status = ''
100
+ if (!message) return
101
+ await tick()
102
+ status = message
103
+ }
104
+
105
+ /** Apply accept/multiple, update state, notify (and report rejections). */
85
106
  function applyFiles(list: File[]) {
86
107
  if (disabled) return
87
- let next = list.filter(matchesAccept)
88
- if (!multiple) next = next.slice(0, 1)
108
+ const reasons: string[] = []
109
+ const rejected: File[] = []
110
+ let next: File[] = []
111
+ for (const file of list) {
112
+ if (!matchesAccept(file)) {
113
+ rejected.push(file)
114
+ reasons.push(`${file.name} (file type not accepted)`)
115
+ } else if (!multiple && next.length) {
116
+ rejected.push(file)
117
+ reasons.push(`${file.name} (only one file allowed)`)
118
+ } else {
119
+ next.push(file)
120
+ }
121
+ }
89
122
  files = next
90
123
  onfiles?.(next)
124
+ if (rejected.length) onreject?.(rejected)
125
+ void announce(rejected.length ? `Not added: ${reasons.join(', ')}.` : '')
91
126
  }
92
127
 
93
128
  function openPicker() {
@@ -126,24 +161,37 @@
126
161
  applyFiles(Array.from(e.dataTransfer?.files ?? []))
127
162
  }
128
163
 
129
- function removeAt(index: number) {
164
+ async function removeAt(index: number) {
130
165
  if (disabled) return
131
166
  const next = files.filter((_, i) => i !== index)
132
167
  files = next
133
168
  onfiles?.(next)
169
+ // The focused button just unmounted: land on the next remove button, else
170
+ // the previous one, else the zone (WCAG 2.4.3).
171
+ await tick()
172
+ const buttons = rootEl?.querySelectorAll<HTMLButtonElement>('.files .remove') ?? []
173
+ ;(buttons[index] ?? buttons[index - 1] ?? zoneEl)?.focus()
134
174
  }
135
175
 
136
- function clear() {
176
+ async function clear() {
137
177
  if (disabled) return
138
178
  files = []
139
179
  if (inputEl) inputEl.value = ''
140
180
  onfiles?.([])
181
+ await tick()
182
+ zoneEl?.focus()
141
183
  }
142
184
  </script>
143
185
 
144
- <div class="ss-filedrop" data-size-variant={resolvedSize} class:invalid={!!error} class:disabled>
186
+ <div
187
+ bind:this={rootEl}
188
+ class="ss-filedrop"
189
+ data-size-variant={resolvedSize}
190
+ class:invalid={!!error}
191
+ class:disabled
192
+ >
145
193
  {#if label}
146
- <span class="lbl" id={`${uid}-label`}>{label}</span>
194
+ <span class="lbl" id={labelId}>{label}</span>
147
195
  {/if}
148
196
 
149
197
  <input
@@ -159,11 +207,12 @@
159
207
  onchange={onChange}
160
208
  />
161
209
  <div
210
+ bind:this={zoneEl}
162
211
  class="zone"
163
212
  class:dragging
164
213
  role="button"
165
214
  tabindex={disabled ? -1 : 0}
166
- aria-label={accName}
215
+ aria-labelledby={labelledBy}
167
216
  aria-disabled={disabled || undefined}
168
217
  aria-describedby={describedBy}
169
218
  onclick={openPicker}
@@ -174,7 +223,7 @@
174
223
  ondrop={onDrop}
175
224
  >
176
225
  <span class="prompt">
177
- <span class="title">Drop files here</span>
226
+ <span class="title" id={titleId}>Drop files here</span>
178
227
  <span class="sub">or click to browse</span>
179
228
  </span>
180
229
  </div>
@@ -200,6 +249,7 @@
200
249
 
201
250
  {#if error}<span class="msg error" id={errorId} role="alert">{error}</span>{/if}
202
251
  {#if hint}<span class="msg hint" id={hintId}>{hint}</span>{/if}
252
+ <span class="sr-only" role="status" aria-live="polite">{status}</span>
203
253
  </div>
204
254
 
205
255
  <style>.ss-filedrop {
@@ -247,6 +297,17 @@
247
297
  white-space: nowrap;
248
298
  border: 0;
249
299
  }
300
+ .ss-filedrop .sr-only {
301
+ position: absolute;
302
+ width: 1px;
303
+ height: 1px;
304
+ padding: 0;
305
+ margin: -1px;
306
+ overflow: hidden;
307
+ clip: rect(0 0 0 0);
308
+ white-space: nowrap;
309
+ border: 0;
310
+ }
250
311
  .ss-filedrop .prompt {
251
312
  display: flex;
252
313
  flex-direction: column;
@@ -297,6 +358,11 @@
297
358
  }
298
359
  .ss-filedrop .remove,
299
360
  .ss-filedrop .clear {
361
+ display: inline-flex;
362
+ align-items: center;
363
+ justify-content: center;
364
+ min-inline-size: 24px;
365
+ min-block-size: 24px;
300
366
  font-family: var(--ss-font-body);
301
367
  background: transparent;
302
368
  border: none;
@@ -318,6 +384,7 @@
318
384
  }
319
385
  .ss-filedrop .clear {
320
386
  align-self: flex-start;
387
+ padding-inline: var(--ss-s-1, 4px);
321
388
  font-family: var(--ss-font-mono);
322
389
  font-size: var(--ss-ui-xs);
323
390
  text-transform: uppercase;
@@ -18,6 +18,12 @@ interface Props {
18
18
  files?: File[];
19
19
  /** Fired with the resolved file list whenever the selection changes. */
20
20
  onfiles?: (files: File[]) => void;
21
+ /**
22
+ * Fired with the files a selection/drop discarded (wrong type for `accept`,
23
+ * or extras when `multiple` is false). Rejections are also announced
24
+ * through a polite live region.
25
+ */
26
+ onreject?: (files: File[]) => void;
21
27
  }
22
28
  declare const FileDrop: import("svelte").Component<Props, {}, "files">;
23
29
  type FileDrop = ReturnType<typeof FileDrop>;