dssoca 0.8.2 → 0.10.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 (65) hide show
  1. package/README.md +39 -13
  2. package/dist/components/Accordion.svelte +22 -6
  3. package/dist/components/Accordion.svelte.d.ts +5 -1
  4. package/dist/components/Avatar.svelte +119 -0
  5. package/dist/components/Avatar.svelte.d.ts +18 -0
  6. package/dist/components/Badge.svelte +3 -5
  7. package/dist/components/BottomNav.svelte +57 -19
  8. package/dist/components/BottomNav.svelte.d.ts +2 -0
  9. package/dist/components/Card.svelte +7 -1
  10. package/dist/components/Chart.svelte +527 -0
  11. package/dist/components/Chart.svelte.d.ts +42 -0
  12. package/dist/components/Container.svelte +55 -0
  13. package/dist/components/Container.svelte.d.ts +16 -0
  14. package/dist/components/DateField.svelte +188 -0
  15. package/dist/components/DateField.svelte.d.ts +37 -0
  16. package/dist/components/EmptyState.svelte +9 -3
  17. package/dist/components/EmptyState.svelte.d.ts +6 -0
  18. package/dist/components/FileDrop.svelte +355 -0
  19. package/dist/components/FileDrop.svelte.d.ts +24 -0
  20. package/dist/components/Heading.svelte +83 -0
  21. package/dist/components/Heading.svelte.d.ts +17 -0
  22. package/dist/components/Icon.svelte +32 -23
  23. package/dist/components/Icon.svelte.d.ts +7 -0
  24. package/dist/components/Image.svelte +19 -21
  25. package/dist/components/Input.svelte +2 -3
  26. package/dist/components/Link.svelte +42 -7
  27. package/dist/components/Link.svelte.d.ts +7 -0
  28. package/dist/components/LogStream.svelte +46 -31
  29. package/dist/components/Menu.svelte +59 -6
  30. package/dist/components/Menu.svelte.d.ts +22 -2
  31. package/dist/components/MetricTile.svelte +4 -4
  32. package/dist/components/Modal.svelte +223 -0
  33. package/dist/components/Modal.svelte.d.ts +29 -0
  34. package/dist/components/NumberField.svelte +260 -0
  35. package/dist/components/NumberField.svelte.d.ts +35 -0
  36. package/dist/components/Pagination.svelte +193 -0
  37. package/dist/components/Pagination.svelte.d.ts +22 -0
  38. package/dist/components/SegmentedControl.svelte +16 -4
  39. package/dist/components/SegmentedControl.svelte.d.ts +7 -0
  40. package/dist/components/Select.svelte +224 -0
  41. package/dist/components/Select.svelte.d.ts +42 -0
  42. package/dist/components/ServiceCard.svelte +15 -15
  43. package/dist/components/Sidebar.svelte +47 -21
  44. package/dist/components/Sparkline.svelte +15 -13
  45. package/dist/components/Spinner.svelte +124 -0
  46. package/dist/components/Spinner.svelte.d.ts +74 -0
  47. package/dist/components/Switch.svelte +144 -0
  48. package/dist/components/Switch.svelte.d.ts +22 -0
  49. package/dist/components/Table.svelte +267 -0
  50. package/dist/components/Table.svelte.d.ts +52 -0
  51. package/dist/components/Textarea.svelte +214 -0
  52. package/dist/components/Textarea.svelte.d.ts +38 -0
  53. package/dist/components/Toaster.svelte +20 -4
  54. package/dist/components/Tooltip.svelte +162 -0
  55. package/dist/components/Tooltip.svelte.d.ts +17 -0
  56. package/dist/components/Topbar.svelte +170 -50
  57. package/dist/components/Topbar.svelte.d.ts +30 -3
  58. package/dist/dssoca.config.d.ts +1 -1
  59. package/dist/dssoca.config.js +15 -0
  60. package/dist/index.d.ts +19 -1
  61. package/dist/index.js +19 -1
  62. package/dist/theme.css +177 -37
  63. package/dist/toast.svelte.js +3 -3
  64. package/dist/tokens.css +597 -0
  65. package/package.json +33 -4
@@ -0,0 +1,527 @@
1
+ <script module lang="ts">
2
+ export type ChartXValue = number | string | Date
3
+ export interface ChartPoint {
4
+ x: ChartXValue
5
+ y: number
6
+ }
7
+ export interface ChartSeries {
8
+ label: string
9
+ data: ChartPoint[]
10
+ color?: string
11
+ }
12
+ export type ChartVariant = 'line' | 'area' | 'bar'
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ import { scaleLinear, scaleTime, scaleBand } from 'd3-scale'
17
+ import { line as shapeLine, area as shapeArea } from 'd3-shape'
18
+ import { extent, max } from 'd3-array'
19
+ import { resolveComponentSize, type Size } from '../config.js'
20
+
21
+ type XType = 'linear' | 'time' | 'band'
22
+
23
+ interface Props {
24
+ /** One or more data series; each is drawn in the cycling palette unless `color` is set. */
25
+ series: ChartSeries[]
26
+ /** Rendering style. `bar` groups bars per x-category across series. Default `line`. */
27
+ variant?: ChartVariant
28
+ /** X scale kind. Defaults to `band` for bars, else `time` for Date x-values, else `linear`. */
29
+ xType?: XType
30
+ /** Format an x value for axis ticks + tooltip. */
31
+ xFormat?: (x: ChartXValue) => string
32
+ /** Format a y value for axis ticks + tooltip. */
33
+ yFormat?: (y: number) => string
34
+ /** Intrinsic drawing height in px. Default 240. */
35
+ height?: number
36
+ /** Intrinsic drawing width in px. Default 480. */
37
+ width?: number
38
+ /** Stretch to the container width via the viewBox (width:100%). */
39
+ fluid?: boolean
40
+ /** Show the series legend (labels + colour swatches). Default true. */
41
+ legend?: boolean
42
+ /** Show a tooltip on hover/focus of a datum. Default true. */
43
+ tooltip?: boolean
44
+ /** SR summary + accessible name; auto-generated when absent. */
45
+ summary?: string
46
+ /** Token size (sm|md|lg); inherits the global size when unset. */
47
+ size?: Size
48
+ }
49
+
50
+ let {
51
+ series,
52
+ variant = 'line',
53
+ xType,
54
+ xFormat,
55
+ yFormat,
56
+ height = 240,
57
+ width = 480,
58
+ fluid = false,
59
+ legend = true,
60
+ tooltip = true,
61
+ summary,
62
+ size,
63
+ }: Props = $props()
64
+
65
+ const PALETTE = [
66
+ 'var(--ss-primary)',
67
+ 'var(--ss-blue)',
68
+ 'var(--ss-purple)',
69
+ 'var(--ss-cyan)',
70
+ 'var(--ss-yellow)',
71
+ 'var(--ss-lime)',
72
+ ]
73
+
74
+ const M = { top: 8, right: 12, bottom: 24, left: 40 }
75
+
76
+ const cleanSeries = $derived((series ?? []).filter((s) => s && Array.isArray(s.data)))
77
+ const allPoints = $derived(cleanSeries.flatMap((s) => s.data))
78
+ const isEmpty = $derived(allPoints.length === 0)
79
+
80
+ function colorFor(s: ChartSeries, i: number): string {
81
+ return s.color ?? PALETTE[i % PALETTE.length]
82
+ }
83
+
84
+ function toNum(x: ChartXValue): number {
85
+ if (x instanceof Date) return x.getTime()
86
+ return typeof x === 'number' ? x : Number(x)
87
+ }
88
+ function xKey(x: ChartXValue): string {
89
+ return x instanceof Date ? String(x.getTime()) : String(x)
90
+ }
91
+
92
+ // Resolve the x scale kind.
93
+ const xIsDate = $derived(allPoints.some((p) => p.x instanceof Date))
94
+ const resolvedXType = $derived<XType>(
95
+ xType ?? (variant === 'bar' ? 'band' : xIsDate ? 'time' : 'linear'),
96
+ )
97
+
98
+ const innerW = $derived(Math.max(0, width - M.left - M.right))
99
+ const innerH = $derived(Math.max(0, height - M.top - M.bottom))
100
+
101
+ const fmtX = $derived(
102
+ xFormat ?? ((x: ChartXValue) => (x instanceof Date ? x.toLocaleDateString() : String(x))),
103
+ )
104
+ const fmtY = $derived(yFormat ?? ((y: number) => String(y)))
105
+
106
+ // Distinct x categories (band scale + grouped bars), in first-seen order.
107
+ const categories = $derived.by(() => {
108
+ const seen = new Map<string, ChartXValue>()
109
+ for (const p of allPoints) {
110
+ const k = xKey(p.x)
111
+ if (!seen.has(k)) seen.set(k, p.x)
112
+ }
113
+ return [...seen.values()]
114
+ })
115
+ const categoryKeys = $derived(categories.map(xKey))
116
+
117
+ // ── d3 scales ─────────────────────────────────────────────────────────────
118
+ // Linear y scale [0..max] → [innerH..0], rounded to nice tick bounds.
119
+ const yScaleObj = $derived(
120
+ scaleLinear()
121
+ .domain([0, max(allPoints, (p) => p.y) ?? 1])
122
+ .nice()
123
+ .range([innerH, 0]),
124
+ )
125
+ function yScale(y: number): number {
126
+ return yScaleObj(y)
127
+ }
128
+
129
+ // Band scale across the distinct categories (drives bars + categorical x).
130
+ const xBand = $derived(scaleBand<string>().domain(categoryKeys).range([0, innerW]).padding(0.2))
131
+
132
+ // Continuous x scales for line/area (time for Date values, else linear).
133
+ const xLinear = $derived(
134
+ scaleLinear()
135
+ .domain((extent(allPoints, (p) => toNum(p.x)) as [number, number]) ?? [0, 1])
136
+ .range([0, innerW]),
137
+ )
138
+ const xTime = $derived(
139
+ scaleTime()
140
+ .domain(
141
+ (extent(allPoints, (p) => (p.x instanceof Date ? p.x : new Date(toNum(p.x)))) as [
142
+ Date,
143
+ Date,
144
+ ]) ?? [new Date(0), new Date(1)],
145
+ )
146
+ .range([0, innerW]),
147
+ )
148
+
149
+ function xPos(x: ChartXValue): number {
150
+ if (resolvedXType === 'band') return (xBand(xKey(x)) ?? 0) + xBand.bandwidth() / 2
151
+ if (resolvedXType === 'time') return xTime(x instanceof Date ? x : new Date(toNum(x)))
152
+ return xLinear(toNum(x))
153
+ }
154
+
155
+ // Axis ticks via the d3 scales.
156
+ const yTicks = $derived(yScaleObj.ticks(5))
157
+ const xTicks = $derived.by<{ x: number; label: string }[]>(() => {
158
+ if (resolvedXType === 'band') {
159
+ return categories.map((c) => ({ x: xPos(c), label: fmtX(c) }))
160
+ }
161
+ if (resolvedXType === 'time') {
162
+ return xTime.ticks(5).map((v) => ({ x: xTime(v), label: fmtX(v) }))
163
+ }
164
+ return xLinear.ticks(5).map((v) => ({ x: xLinear(v), label: fmtX(v) }))
165
+ })
166
+
167
+ // ── path generators (d3-shape) ─────────────────────────────────────────────
168
+ const lineGen = $derived(
169
+ shapeLine<ChartPoint>()
170
+ .x((p) => xPos(p.x))
171
+ .y((p) => yScale(p.y)),
172
+ )
173
+ const areaGen = $derived(
174
+ shapeArea<ChartPoint>()
175
+ .x((p) => xPos(p.x))
176
+ .y0(innerH)
177
+ .y1((p) => yScale(p.y)),
178
+ )
179
+
180
+ const linePaths = $derived.by(() => {
181
+ if (variant !== 'line' && variant !== 'area') return []
182
+ return cleanSeries.map((s, i) => ({
183
+ d: lineGen(s.data) ?? '',
184
+ color: colorFor(s, i),
185
+ label: s.label,
186
+ }))
187
+ })
188
+ const areaPaths = $derived.by(() => {
189
+ if (variant !== 'area') return []
190
+ return cleanSeries.map((s, i) => ({
191
+ d: areaGen(s.data) ?? '',
192
+ color: colorFor(s, i),
193
+ label: s.label,
194
+ }))
195
+ })
196
+
197
+ // Grouped bars: each x-category holds one bar per series, packed across the band.
198
+ const barGroups = $derived.by(() => {
199
+ if (variant !== 'bar') return []
200
+ const inner = scaleBand<number>()
201
+ .domain(cleanSeries.map((_, i) => i))
202
+ .range([0, xBand.bandwidth()])
203
+ .padding(0.1)
204
+ return categories.map((cat) => {
205
+ const left = xBand(xKey(cat)) ?? 0
206
+ const bars = cleanSeries
207
+ .map((s, i) => {
208
+ const pt = s.data.find((p) => xKey(p.x) === xKey(cat))
209
+ if (!pt) return null
210
+ const y = yScale(pt.y)
211
+ return {
212
+ x: left + (inner(i) ?? 0),
213
+ y,
214
+ w: inner.bandwidth(),
215
+ h: Math.max(0, innerH - y),
216
+ color: colorFor(s, i),
217
+ label: s.label,
218
+ value: pt.y,
219
+ cat,
220
+ }
221
+ })
222
+ .filter((b): b is NonNullable<typeof b> => b !== null)
223
+ return { bars }
224
+ })
225
+ })
226
+
227
+ // Focusable point markers (line/area datums).
228
+ const pointMarkers = $derived.by(() => {
229
+ if (variant !== 'line' && variant !== 'area') return []
230
+ return cleanSeries.flatMap((s, i) =>
231
+ s.data.map((p) => ({
232
+ cx: xPos(p.x),
233
+ cy: yScale(p.y),
234
+ color: colorFor(s, i),
235
+ label: s.label,
236
+ x: p.x,
237
+ value: p.y,
238
+ })),
239
+ )
240
+ })
241
+
242
+ // Auto SR summary.
243
+ const autoSummary = $derived.by(() => {
244
+ if (isEmpty) return 'No data'
245
+ const kind = variant === 'bar' ? 'Bar chart' : variant === 'area' ? 'Area chart' : 'Line chart'
246
+ const names = cleanSeries.map((s) => s.label).join(', ')
247
+ return `${kind} with ${cleanSeries.length} series (${names}); ${allPoints.length} data points.`
248
+ })
249
+ const srText = $derived(summary ?? autoSummary)
250
+
251
+ const resolvedSize = $derived(resolveComponentSize('Chart', size))
252
+
253
+ // Tooltip state.
254
+ let active = $state<{
255
+ label: string
256
+ x: ChartXValue
257
+ y: number
258
+ cx: number
259
+ cy: number
260
+ } | null>(null)
261
+ function show(label: string, x: ChartXValue, y: number, cx: number, cy: number) {
262
+ if (tooltip) active = { label, x, y, cx, cy }
263
+ }
264
+ function hide() {
265
+ active = null
266
+ }
267
+ function datumLabel(label: string, x: ChartXValue, y: number): string {
268
+ return `${label}: ${fmtX(x)}, ${fmtY(y)}`
269
+ }
270
+ </script>
271
+
272
+ <div
273
+ class="ss-chart"
274
+ class:fluid
275
+ data-variant={variant}
276
+ data-size-variant={resolvedSize}
277
+ role="group"
278
+ aria-label={srText}
279
+ >
280
+ {#if isEmpty}
281
+ <span class="empty" aria-hidden="true">—</span>
282
+ <span class="sr-only">No data</span>
283
+ {:else}
284
+ <div class="plot">
285
+ <svg
286
+ class="canvas"
287
+ viewBox="0 0 {width} {height}"
288
+ width={fluid ? undefined : width}
289
+ height={fluid ? undefined : height}
290
+ preserveAspectRatio="xMidYMid meet"
291
+ role="presentation"
292
+ >
293
+ <g transform="translate({M.left},{M.top})">
294
+ <!-- gridlines + y axis -->
295
+ {#each yTicks as t}
296
+ <line class="grid" x1="0" x2={innerW} y1={yScale(t)} y2={yScale(t)} />
297
+ <text class="tick y" x="-6" y={yScale(t)} dy="0.32em" text-anchor="end">{fmtY(t)}</text>
298
+ {/each}
299
+ <line class="axis" x1="0" x2="0" y1="0" y2={innerH} />
300
+
301
+ <!-- x axis -->
302
+ <line class="axis" x1="0" x2={innerW} y1={innerH} y2={innerH} />
303
+ {#each xTicks as t}
304
+ <text class="tick x" x={t.x} y={innerH + 16} text-anchor="middle">{t.label}</text>
305
+ {/each}
306
+
307
+ <!-- series -->
308
+ {#if variant === 'area'}
309
+ {#each areaPaths as p}
310
+ <path class="area" d={p.d} style="fill:{p.color}" />
311
+ {/each}
312
+ {/if}
313
+
314
+ {#if variant === 'line' || variant === 'area'}
315
+ {#each linePaths as p}
316
+ <path class="line" d={p.d} style="stroke:{p.color}" />
317
+ {/each}
318
+ {#each pointMarkers as m}
319
+ <circle
320
+ class="point"
321
+ cx={m.cx}
322
+ cy={m.cy}
323
+ r="4"
324
+ style="fill:{m.color}"
325
+ tabindex="0"
326
+ role="button"
327
+ aria-label={datumLabel(m.label, m.x, m.value)}
328
+ onfocus={() => show(m.label, m.x, m.value, m.cx, m.cy)}
329
+ onblur={hide}
330
+ onmouseenter={() => show(m.label, m.x, m.value, m.cx, m.cy)}
331
+ onmouseleave={hide}
332
+ />
333
+ {/each}
334
+ {/if}
335
+
336
+ {#if variant === 'bar'}
337
+ {#each barGroups as g}
338
+ {#each g.bars as b}
339
+ <rect
340
+ class="bar"
341
+ x={b.x}
342
+ y={b.y}
343
+ width={b.w}
344
+ height={b.h}
345
+ style="fill:{b.color}"
346
+ tabindex="0"
347
+ role="button"
348
+ aria-label={datumLabel(b.label, b.cat, b.value)}
349
+ onfocus={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
350
+ onblur={hide}
351
+ onmouseenter={() => show(b.label, b.cat, b.value, b.x + b.w / 2, b.y)}
352
+ onmouseleave={hide}
353
+ />
354
+ {/each}
355
+ {/each}
356
+ {/if}
357
+ </g>
358
+ </svg>
359
+
360
+ {#if tooltip && active}
361
+ <div
362
+ class="tooltip"
363
+ role="status"
364
+ style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
365
+ 100}%"
366
+ >
367
+ <span class="t-label">{active.label}</span>
368
+ <span class="t-val">{fmtX(active.x)} · {fmtY(active.y)}</span>
369
+ </div>
370
+ {/if}
371
+ </div>
372
+
373
+ {#if legend}
374
+ <ul class="legend">
375
+ {#each cleanSeries as s, i}
376
+ <li class="legend-item">
377
+ <span class="swatch" style="background:{colorFor(s, i)}" aria-hidden="true"></span>
378
+ <span class="legend-label">{s.label}</span>
379
+ </li>
380
+ {/each}
381
+ </ul>
382
+ {/if}
383
+ {/if}
384
+ </div>
385
+
386
+ <style>.ss-chart {
387
+ display: inline-flex;
388
+ flex-direction: column;
389
+ gap: var(--ss-gap-sm);
390
+ font-family: var(--ss-font-body);
391
+ color: var(--ss-fg);
392
+ max-width: 100%;
393
+ }
394
+ .ss-chart.fluid {
395
+ display: flex;
396
+ width: 100%;
397
+ }
398
+ .ss-chart .plot {
399
+ position: relative;
400
+ width: 100%;
401
+ }
402
+ .ss-chart .canvas {
403
+ display: block;
404
+ max-width: 100%;
405
+ height: auto;
406
+ overflow: visible;
407
+ }
408
+ .ss-chart.fluid .canvas {
409
+ width: 100%;
410
+ }
411
+ .ss-chart .empty {
412
+ align-self: center;
413
+ margin: auto;
414
+ padding: var(--ss-gap-sm);
415
+ color: var(--ss-fg-muted);
416
+ font-family: var(--ss-font-mono);
417
+ line-height: 1;
418
+ min-height: var(--ss-chart-h, 240px);
419
+ display: flex;
420
+ align-items: center;
421
+ }
422
+ .ss-chart .sr-only {
423
+ position: absolute;
424
+ width: 1px;
425
+ height: 1px;
426
+ padding: 0;
427
+ margin: -1px;
428
+ overflow: hidden;
429
+ clip: rect(0, 0, 0, 0);
430
+ white-space: nowrap;
431
+ border: 0;
432
+ }
433
+ .ss-chart .grid {
434
+ stroke: var(--ss-line);
435
+ stroke-width: 1;
436
+ opacity: 0.5;
437
+ shape-rendering: crispEdges;
438
+ }
439
+ .ss-chart .axis {
440
+ stroke: var(--ss-line);
441
+ stroke-width: 1;
442
+ shape-rendering: crispEdges;
443
+ }
444
+ .ss-chart .tick {
445
+ font-family: var(--ss-font-mono);
446
+ font-size: var(--ss-ui-xs);
447
+ fill: var(--ss-fg-muted);
448
+ }
449
+ .ss-chart .line {
450
+ fill: none;
451
+ stroke-width: 2;
452
+ stroke-linejoin: round;
453
+ stroke-linecap: round;
454
+ }
455
+ .ss-chart .area {
456
+ opacity: 0.18;
457
+ stroke: none;
458
+ }
459
+ .ss-chart .point {
460
+ cursor: pointer;
461
+ transition: r var(--ss-dur-fast) var(--ss-ease);
462
+ }
463
+ .ss-chart .point:hover, .ss-chart .point:focus-visible {
464
+ outline: none;
465
+ r: 6;
466
+ }
467
+ .ss-chart .point:focus-visible {
468
+ stroke: var(--ss-fg);
469
+ stroke-width: 2;
470
+ }
471
+ .ss-chart .bar {
472
+ cursor: pointer;
473
+ transition: opacity var(--ss-dur-fast) var(--ss-ease);
474
+ }
475
+ .ss-chart .bar:hover {
476
+ opacity: 0.85;
477
+ }
478
+ .ss-chart .bar:focus-visible {
479
+ outline: none;
480
+ stroke: var(--ss-fg);
481
+ stroke-width: 2;
482
+ }
483
+ .ss-chart .tooltip {
484
+ position: absolute;
485
+ transform: translate(-50%, calc(-100% - 8px));
486
+ pointer-events: none;
487
+ background: var(--ss-bg-elev);
488
+ border: 1px solid var(--ss-line-strong);
489
+ padding: var(--ss-gap-sm);
490
+ font-size: var(--ss-ui-xs);
491
+ line-height: 1.3;
492
+ white-space: nowrap;
493
+ display: flex;
494
+ flex-direction: column;
495
+ gap: 2px;
496
+ z-index: 2;
497
+ }
498
+ .ss-chart .tooltip .t-label {
499
+ font-family: var(--ss-font-mono);
500
+ color: var(--ss-fg);
501
+ }
502
+ .ss-chart .tooltip .t-val {
503
+ font-family: var(--ss-font-mono);
504
+ color: var(--ss-fg-muted);
505
+ }
506
+ .ss-chart .legend {
507
+ display: flex;
508
+ flex-wrap: wrap;
509
+ gap: var(--ss-gap-sm);
510
+ list-style: none;
511
+ margin: 0;
512
+ padding: 0;
513
+ }
514
+ .ss-chart .legend-item {
515
+ display: inline-flex;
516
+ align-items: center;
517
+ gap: 6px;
518
+ font-size: var(--ss-ui-xs);
519
+ font-family: var(--ss-font-mono);
520
+ color: var(--ss-fg-muted);
521
+ }
522
+ .ss-chart .swatch {
523
+ width: 10px;
524
+ height: 10px;
525
+ flex: none;
526
+ display: inline-block;
527
+ }</style>
@@ -0,0 +1,42 @@
1
+ export type ChartXValue = number | string | Date;
2
+ export interface ChartPoint {
3
+ x: ChartXValue;
4
+ y: number;
5
+ }
6
+ export interface ChartSeries {
7
+ label: string;
8
+ data: ChartPoint[];
9
+ color?: string;
10
+ }
11
+ export type ChartVariant = 'line' | 'area' | 'bar';
12
+ import { type Size } from '../config.js';
13
+ type XType = 'linear' | 'time' | 'band';
14
+ interface Props {
15
+ /** One or more data series; each is drawn in the cycling palette unless `color` is set. */
16
+ series: ChartSeries[];
17
+ /** Rendering style. `bar` groups bars per x-category across series. Default `line`. */
18
+ variant?: ChartVariant;
19
+ /** X scale kind. Defaults to `band` for bars, else `time` for Date x-values, else `linear`. */
20
+ xType?: XType;
21
+ /** Format an x value for axis ticks + tooltip. */
22
+ xFormat?: (x: ChartXValue) => string;
23
+ /** Format a y value for axis ticks + tooltip. */
24
+ yFormat?: (y: number) => string;
25
+ /** Intrinsic drawing height in px. Default 240. */
26
+ height?: number;
27
+ /** Intrinsic drawing width in px. Default 480. */
28
+ width?: number;
29
+ /** Stretch to the container width via the viewBox (width:100%). */
30
+ fluid?: boolean;
31
+ /** Show the series legend (labels + colour swatches). Default true. */
32
+ legend?: boolean;
33
+ /** Show a tooltip on hover/focus of a datum. Default true. */
34
+ tooltip?: boolean;
35
+ /** SR summary + accessible name; auto-generated when absent. */
36
+ summary?: string;
37
+ /** Token size (sm|md|lg); inherits the global size when unset. */
38
+ size?: Size;
39
+ }
40
+ declare const Chart: import("svelte").Component<Props, {}, "">;
41
+ type Chart = ReturnType<typeof Chart>;
42
+ export default Chart;
@@ -0,0 +1,55 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import { resolveComponentSize, type Size } from '../config.js'
4
+
5
+ interface Props {
6
+ /**
7
+ * Page mode — behaves like a route page: fills the viewport height and
8
+ * adds vertical page padding on top of the horizontal gutters.
9
+ */
10
+ page?: boolean
11
+ /** Token size (sm|md|lg); inherits the global size when unset. */
12
+ size?: Size
13
+ /** Page content. */
14
+ children?: Snippet
15
+ }
16
+
17
+ let { page = false, size, children }: Props = $props()
18
+ </script>
19
+
20
+ <!--
21
+ Centered, max-width page-content wrapper (DS-0085) — the DS-owned version of
22
+ the per-site "AppContent" wrappers. Full-bleed at narrow viewports (the
23
+ max-width simply stops binding); gutters stay via the inline padding.
24
+ -->
25
+ <div class="ss-container" class:page data-size-variant={resolveComponentSize('Container', size)}>
26
+ {@render children?.()}
27
+ </div>
28
+
29
+ <style>.ss-container {
30
+ --ss-container-max-w: 875px;
31
+ --ss-container-px: var(--ss-main-px);
32
+ --ss-container-page-py: var(--ss-s-10);
33
+ }
34
+ .ss-container[data-size-variant=sm] {
35
+ --ss-container-max-w: 760px;
36
+ --ss-container-px: var(--ss-s-5);
37
+ --ss-container-page-py: var(--ss-s-8);
38
+ }
39
+ .ss-container[data-size-variant=lg] {
40
+ --ss-container-max-w: 1000px;
41
+ --ss-container-px: var(--ss-s-12);
42
+ --ss-container-page-py: var(--ss-s-12);
43
+ }
44
+ .ss-container {
45
+ box-sizing: border-box;
46
+ width: 100%;
47
+ max-width: var(--ss-container-max-w);
48
+ margin-inline: auto;
49
+ padding-inline: var(--ss-container-px);
50
+ }
51
+ .ss-container.page {
52
+ min-height: 100vh;
53
+ min-height: 100svh;
54
+ padding-block: var(--ss-container-page-py);
55
+ }</style>
@@ -0,0 +1,16 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
3
+ interface Props {
4
+ /**
5
+ * Page mode — behaves like a route page: fills the viewport height and
6
+ * adds vertical page padding on top of the horizontal gutters.
7
+ */
8
+ page?: boolean;
9
+ /** Token size (sm|md|lg); inherits the global size when unset. */
10
+ size?: Size;
11
+ /** Page content. */
12
+ children?: Snippet;
13
+ }
14
+ declare const Container: import("svelte").Component<Props, {}, "">;
15
+ type Container = ReturnType<typeof Container>;
16
+ export default Container;