dssoca 0.9.0 → 0.11.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/dist/components/Avatar.svelte +119 -0
- package/dist/components/Avatar.svelte.d.ts +18 -0
- package/dist/components/BoxPlot.svelte +427 -0
- package/dist/components/BoxPlot.svelte.d.ts +36 -0
- package/dist/components/BumpChart.svelte +351 -0
- package/dist/components/BumpChart.svelte.d.ts +32 -0
- package/dist/components/Chart.svelte +527 -0
- package/dist/components/Chart.svelte.d.ts +42 -0
- package/dist/components/DateField.svelte +188 -0
- package/dist/components/DateField.svelte.d.ts +37 -0
- package/dist/components/FileDrop.svelte +355 -0
- package/dist/components/FileDrop.svelte.d.ts +24 -0
- package/dist/components/Heatmap.svelte +333 -0
- package/dist/components/Heatmap.svelte.d.ts +30 -0
- package/dist/components/Modal.svelte +223 -0
- package/dist/components/Modal.svelte.d.ts +29 -0
- package/dist/components/NumberField.svelte +260 -0
- package/dist/components/NumberField.svelte.d.ts +35 -0
- package/dist/components/Pagination.svelte +193 -0
- package/dist/components/Pagination.svelte.d.ts +22 -0
- package/dist/components/ScatterPlot.svelte +401 -0
- package/dist/components/ScatterPlot.svelte.d.ts +55 -0
- package/dist/components/Select.svelte +224 -0
- package/dist/components/Select.svelte.d.ts +42 -0
- package/dist/components/Switch.svelte +144 -0
- package/dist/components/Switch.svelte.d.ts +22 -0
- package/dist/components/Table.svelte +267 -0
- package/dist/components/Table.svelte.d.ts +52 -0
- package/dist/components/Tooltip.svelte +162 -0
- package/dist/components/Tooltip.svelte.d.ts +17 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +11 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -0
- package/package.json +9 -1
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface BumpSeries {
|
|
3
|
+
/** Competitor label shown at the last node and in the tooltip / accessible name. */
|
|
4
|
+
label: string
|
|
5
|
+
/** 1-based finishing ranks; `ranks[i]` is the rank at stage `i` (length must match `stages`). */
|
|
6
|
+
ranks: number[]
|
|
7
|
+
/** Optional per-series colour; falls back to the cycling palette. */
|
|
8
|
+
color?: string
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { scalePoint, scaleLinear } from 'd3-scale'
|
|
14
|
+
import { line as shapeLine } from 'd3-shape'
|
|
15
|
+
import { max } from 'd3-array'
|
|
16
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
/** One series per competitor; each carries a `label`, `ranks` and optional `color`. */
|
|
20
|
+
series: BumpSeries[]
|
|
21
|
+
/** Ordered x-axis category labels (e.g. ['G1','G2','G3','G4']). */
|
|
22
|
+
stages: string[]
|
|
23
|
+
/** Draw each series label at its last node (direct labelling). Default true. */
|
|
24
|
+
showLabels?: boolean
|
|
25
|
+
/** Intrinsic drawing height in px. Default 280. */
|
|
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
|
+
/** Reveal a tooltip on hover/focus of a node. Default true. */
|
|
32
|
+
tooltip?: boolean
|
|
33
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
34
|
+
summary?: string
|
|
35
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
36
|
+
size?: Size
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let {
|
|
40
|
+
series,
|
|
41
|
+
stages,
|
|
42
|
+
showLabels = true,
|
|
43
|
+
height = 280,
|
|
44
|
+
width = 480,
|
|
45
|
+
fluid = false,
|
|
46
|
+
tooltip = true,
|
|
47
|
+
summary,
|
|
48
|
+
size,
|
|
49
|
+
}: Props = $props()
|
|
50
|
+
|
|
51
|
+
const PALETTE = [
|
|
52
|
+
'var(--ss-primary)',
|
|
53
|
+
'var(--ss-blue)',
|
|
54
|
+
'var(--ss-purple)',
|
|
55
|
+
'var(--ss-cyan)',
|
|
56
|
+
'var(--ss-yellow)',
|
|
57
|
+
'var(--ss-lime)',
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
const M = { top: 12, right: 56, bottom: 28, left: 32 }
|
|
61
|
+
|
|
62
|
+
const cleanSeries = $derived((series ?? []).filter((s) => s && Array.isArray(s.ranks)))
|
|
63
|
+
const cleanStages = $derived(stages ?? [])
|
|
64
|
+
const isEmpty = $derived(cleanSeries.length === 0 || cleanStages.length === 0)
|
|
65
|
+
|
|
66
|
+
function colorFor(s: BumpSeries, i: number): string {
|
|
67
|
+
return s.color ?? PALETTE[i % PALETTE.length]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const innerW = $derived(Math.max(0, width - M.left - M.right))
|
|
71
|
+
const innerH = $derived(Math.max(0, height - M.top - M.bottom))
|
|
72
|
+
|
|
73
|
+
// Highest rank present across all series; default to the competitor count.
|
|
74
|
+
const maxRank = $derived(
|
|
75
|
+
max(cleanSeries.flatMap((s) => s.ranks.filter((r) => Number.isFinite(r)))) ??
|
|
76
|
+
cleanSeries.length,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
// x over stages; y maps rank 1 → top (0) and maxRank → bottom (innerH).
|
|
80
|
+
const xScaleObj = $derived(
|
|
81
|
+
scalePoint<string>().domain(cleanStages).range([0, innerW]).padding(0.5),
|
|
82
|
+
)
|
|
83
|
+
const yScaleObj = $derived(scaleLinear().domain([1, maxRank]).range([0, innerH]))
|
|
84
|
+
|
|
85
|
+
// Integer rank ticks 1..maxRank.
|
|
86
|
+
const rankTicks = $derived(
|
|
87
|
+
Array.from({ length: Math.max(1, Math.round(maxRank)) }, (_, i) => i + 1),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
// One node per (series, stage) where the rank is finite.
|
|
91
|
+
const seriesNodes = $derived(
|
|
92
|
+
cleanSeries.map((s, i) => {
|
|
93
|
+
const color = colorFor(s, i)
|
|
94
|
+
const nodes = cleanStages
|
|
95
|
+
.map((stage, j) => {
|
|
96
|
+
const rank = s.ranks[j]
|
|
97
|
+
if (!Number.isFinite(rank)) return null
|
|
98
|
+
return {
|
|
99
|
+
cx: xScaleObj(stage) ?? 0,
|
|
100
|
+
cy: yScaleObj(rank),
|
|
101
|
+
stage,
|
|
102
|
+
rank,
|
|
103
|
+
label: s.label,
|
|
104
|
+
color,
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.filter((n): n is NonNullable<typeof n> => n !== null)
|
|
108
|
+
return { label: s.label, color, nodes }
|
|
109
|
+
}),
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
const lineGen = $derived(
|
|
113
|
+
shapeLine<{ cx: number; cy: number }>()
|
|
114
|
+
.x((n) => n.cx)
|
|
115
|
+
.y((n) => n.cy),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const linePaths = $derived(
|
|
119
|
+
seriesNodes.map((s) => ({
|
|
120
|
+
d: lineGen(s.nodes) ?? '',
|
|
121
|
+
color: s.color,
|
|
122
|
+
label: s.label,
|
|
123
|
+
})),
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
// Last node of each series for direct labelling.
|
|
127
|
+
const endLabels = $derived.by(() => {
|
|
128
|
+
if (!showLabels) return [] as { x: number; y: number; color: string; label: string }[]
|
|
129
|
+
return seriesNodes
|
|
130
|
+
.filter((s) => s.nodes.length > 0)
|
|
131
|
+
.map((s) => {
|
|
132
|
+
const last = s.nodes[s.nodes.length - 1]
|
|
133
|
+
return { x: last.cx + 8, y: last.cy, color: s.color, label: s.label }
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
const autoSummary = $derived.by(() => {
|
|
138
|
+
if (isEmpty) return 'No data'
|
|
139
|
+
const stageNames = cleanStages.join(', ')
|
|
140
|
+
return `Bump chart with ${cleanSeries.length} series over ${cleanStages.length} stages (${stageNames}).`
|
|
141
|
+
})
|
|
142
|
+
const srText = $derived(summary ?? autoSummary)
|
|
143
|
+
|
|
144
|
+
const resolvedSize = $derived(resolveComponentSize('Chart', size))
|
|
145
|
+
|
|
146
|
+
let active = $state<{
|
|
147
|
+
label: string
|
|
148
|
+
stage: string
|
|
149
|
+
rank: number
|
|
150
|
+
cx: number
|
|
151
|
+
cy: number
|
|
152
|
+
} | null>(null)
|
|
153
|
+
function show(label: string, stage: string, rank: number, cx: number, cy: number) {
|
|
154
|
+
if (tooltip) active = { label, stage, rank, cx, cy }
|
|
155
|
+
}
|
|
156
|
+
function hide() {
|
|
157
|
+
active = null
|
|
158
|
+
}
|
|
159
|
+
function nodeLabel(label: string, stage: string, rank: number): string {
|
|
160
|
+
return `${label}: ${stage}, rank ${rank}`
|
|
161
|
+
}
|
|
162
|
+
</script>
|
|
163
|
+
|
|
164
|
+
<div class="ss-bump" class:fluid data-size-variant={resolvedSize} role="group" aria-label={srText}>
|
|
165
|
+
{#if isEmpty}
|
|
166
|
+
<span class="empty" aria-hidden="true">—</span>
|
|
167
|
+
<span class="sr-only">No data</span>
|
|
168
|
+
{:else}
|
|
169
|
+
<div class="plot">
|
|
170
|
+
<svg
|
|
171
|
+
class="canvas"
|
|
172
|
+
viewBox="0 0 {width} {height}"
|
|
173
|
+
width={fluid ? undefined : width}
|
|
174
|
+
height={fluid ? undefined : height}
|
|
175
|
+
preserveAspectRatio="xMidYMid meet"
|
|
176
|
+
role="presentation"
|
|
177
|
+
>
|
|
178
|
+
<g transform="translate({M.left},{M.top})">
|
|
179
|
+
<!-- gridlines + y axis (rank ticks) -->
|
|
180
|
+
{#each rankTicks as t}
|
|
181
|
+
<line class="grid" x1="0" x2={innerW} y1={yScaleObj(t)} y2={yScaleObj(t)} />
|
|
182
|
+
<text class="tick y" x="-6" y={yScaleObj(t)} dy="0.32em" text-anchor="end">{t}</text>
|
|
183
|
+
{/each}
|
|
184
|
+
<line class="axis" x1="0" x2="0" y1="0" y2={innerH} />
|
|
185
|
+
<line class="axis" x1="0" x2={innerW} y1={innerH} y2={innerH} />
|
|
186
|
+
|
|
187
|
+
<!-- x axis (stage labels) -->
|
|
188
|
+
{#each cleanStages as stage}
|
|
189
|
+
<text class="tick x" x={xScaleObj(stage)} y={innerH + 16} text-anchor="middle"
|
|
190
|
+
>{stage}</text
|
|
191
|
+
>
|
|
192
|
+
{/each}
|
|
193
|
+
|
|
194
|
+
<!-- connecting lines -->
|
|
195
|
+
{#each linePaths as p}
|
|
196
|
+
<path class="line" d={p.d} style="stroke:{p.color}" />
|
|
197
|
+
{/each}
|
|
198
|
+
|
|
199
|
+
<!-- nodes -->
|
|
200
|
+
{#each seriesNodes as s}
|
|
201
|
+
{#each s.nodes as n}
|
|
202
|
+
<circle
|
|
203
|
+
class="node"
|
|
204
|
+
cx={n.cx}
|
|
205
|
+
cy={n.cy}
|
|
206
|
+
r="5"
|
|
207
|
+
style="fill:{n.color}"
|
|
208
|
+
tabindex="0"
|
|
209
|
+
role="button"
|
|
210
|
+
aria-label={nodeLabel(n.label, n.stage, n.rank)}
|
|
211
|
+
onfocus={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
|
|
212
|
+
onblur={hide}
|
|
213
|
+
onmouseenter={() => show(n.label, n.stage, n.rank, n.cx, n.cy)}
|
|
214
|
+
onmouseleave={hide}
|
|
215
|
+
/>
|
|
216
|
+
{/each}
|
|
217
|
+
{/each}
|
|
218
|
+
|
|
219
|
+
<!-- direct series labels -->
|
|
220
|
+
{#each endLabels as l}
|
|
221
|
+
<text class="series-label" x={l.x} y={l.y} dy="0.32em" style="fill:{l.color}"
|
|
222
|
+
>{l.label}</text
|
|
223
|
+
>
|
|
224
|
+
{/each}
|
|
225
|
+
</g>
|
|
226
|
+
</svg>
|
|
227
|
+
|
|
228
|
+
{#if tooltip && active}
|
|
229
|
+
<div
|
|
230
|
+
class="tooltip"
|
|
231
|
+
role="status"
|
|
232
|
+
style="left:{((active.cx + M.left) / width) * 100}%;top:{((active.cy + M.top) / height) *
|
|
233
|
+
100}%"
|
|
234
|
+
>
|
|
235
|
+
<span class="t-label">{active.label}</span>
|
|
236
|
+
<span class="t-val">{active.stage} · rank {active.rank}</span>
|
|
237
|
+
</div>
|
|
238
|
+
{/if}
|
|
239
|
+
</div>
|
|
240
|
+
{/if}
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<style>.ss-bump {
|
|
244
|
+
display: inline-flex;
|
|
245
|
+
flex-direction: column;
|
|
246
|
+
gap: var(--ss-gap-sm);
|
|
247
|
+
font-family: var(--ss-font-body);
|
|
248
|
+
color: var(--ss-fg);
|
|
249
|
+
max-width: 100%;
|
|
250
|
+
}
|
|
251
|
+
.ss-bump.fluid {
|
|
252
|
+
display: flex;
|
|
253
|
+
width: 100%;
|
|
254
|
+
}
|
|
255
|
+
.ss-bump .plot {
|
|
256
|
+
position: relative;
|
|
257
|
+
width: 100%;
|
|
258
|
+
}
|
|
259
|
+
.ss-bump .canvas {
|
|
260
|
+
display: block;
|
|
261
|
+
max-width: 100%;
|
|
262
|
+
height: auto;
|
|
263
|
+
overflow: visible;
|
|
264
|
+
}
|
|
265
|
+
.ss-bump.fluid .canvas {
|
|
266
|
+
width: 100%;
|
|
267
|
+
}
|
|
268
|
+
.ss-bump .empty {
|
|
269
|
+
align-self: center;
|
|
270
|
+
margin: auto;
|
|
271
|
+
padding: var(--ss-gap-sm);
|
|
272
|
+
color: var(--ss-fg-muted);
|
|
273
|
+
font-family: var(--ss-font-mono);
|
|
274
|
+
line-height: 1;
|
|
275
|
+
min-height: var(--ss-chart-h, 240px);
|
|
276
|
+
display: flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
}
|
|
279
|
+
.ss-bump .sr-only {
|
|
280
|
+
position: absolute;
|
|
281
|
+
width: 1px;
|
|
282
|
+
height: 1px;
|
|
283
|
+
padding: 0;
|
|
284
|
+
margin: -1px;
|
|
285
|
+
overflow: hidden;
|
|
286
|
+
clip: rect(0, 0, 0, 0);
|
|
287
|
+
white-space: nowrap;
|
|
288
|
+
border: 0;
|
|
289
|
+
}
|
|
290
|
+
.ss-bump .grid {
|
|
291
|
+
stroke: var(--ss-line);
|
|
292
|
+
stroke-width: 1;
|
|
293
|
+
opacity: 0.5;
|
|
294
|
+
shape-rendering: crispEdges;
|
|
295
|
+
}
|
|
296
|
+
.ss-bump .axis {
|
|
297
|
+
stroke: var(--ss-line);
|
|
298
|
+
stroke-width: 1;
|
|
299
|
+
shape-rendering: crispEdges;
|
|
300
|
+
}
|
|
301
|
+
.ss-bump .tick {
|
|
302
|
+
font-family: var(--ss-font-mono);
|
|
303
|
+
font-size: var(--ss-ui-xs);
|
|
304
|
+
fill: var(--ss-fg-muted);
|
|
305
|
+
}
|
|
306
|
+
.ss-bump .line {
|
|
307
|
+
fill: none;
|
|
308
|
+
stroke-width: 2;
|
|
309
|
+
stroke-linejoin: round;
|
|
310
|
+
stroke-linecap: round;
|
|
311
|
+
}
|
|
312
|
+
.ss-bump .node {
|
|
313
|
+
cursor: pointer;
|
|
314
|
+
transition: r var(--ss-dur-fast) var(--ss-ease);
|
|
315
|
+
}
|
|
316
|
+
.ss-bump .node:hover, .ss-bump .node:focus-visible {
|
|
317
|
+
outline: none;
|
|
318
|
+
r: 7;
|
|
319
|
+
}
|
|
320
|
+
.ss-bump .node:focus-visible {
|
|
321
|
+
stroke: var(--ss-fg);
|
|
322
|
+
stroke-width: 2;
|
|
323
|
+
}
|
|
324
|
+
.ss-bump .series-label {
|
|
325
|
+
font-family: var(--ss-font-mono);
|
|
326
|
+
font-size: var(--ss-ui-xs);
|
|
327
|
+
pointer-events: none;
|
|
328
|
+
}
|
|
329
|
+
.ss-bump .tooltip {
|
|
330
|
+
position: absolute;
|
|
331
|
+
transform: translate(-50%, calc(-100% - 8px));
|
|
332
|
+
pointer-events: none;
|
|
333
|
+
background: var(--ss-bg-elev);
|
|
334
|
+
border: 1px solid var(--ss-line-strong);
|
|
335
|
+
padding: var(--ss-gap-sm);
|
|
336
|
+
font-size: var(--ss-ui-xs);
|
|
337
|
+
line-height: 1.3;
|
|
338
|
+
white-space: nowrap;
|
|
339
|
+
display: flex;
|
|
340
|
+
flex-direction: column;
|
|
341
|
+
gap: 2px;
|
|
342
|
+
z-index: 2;
|
|
343
|
+
}
|
|
344
|
+
.ss-bump .tooltip .t-label {
|
|
345
|
+
font-family: var(--ss-font-mono);
|
|
346
|
+
color: var(--ss-fg);
|
|
347
|
+
}
|
|
348
|
+
.ss-bump .tooltip .t-val {
|
|
349
|
+
font-family: var(--ss-font-mono);
|
|
350
|
+
color: var(--ss-fg-muted);
|
|
351
|
+
}</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface BumpSeries {
|
|
2
|
+
/** Competitor label shown at the last node and in the tooltip / accessible name. */
|
|
3
|
+
label: string;
|
|
4
|
+
/** 1-based finishing ranks; `ranks[i]` is the rank at stage `i` (length must match `stages`). */
|
|
5
|
+
ranks: number[];
|
|
6
|
+
/** Optional per-series colour; falls back to the cycling palette. */
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
import { type Size } from '../config.js';
|
|
10
|
+
interface Props {
|
|
11
|
+
/** One series per competitor; each carries a `label`, `ranks` and optional `color`. */
|
|
12
|
+
series: BumpSeries[];
|
|
13
|
+
/** Ordered x-axis category labels (e.g. ['G1','G2','G3','G4']). */
|
|
14
|
+
stages: string[];
|
|
15
|
+
/** Draw each series label at its last node (direct labelling). Default true. */
|
|
16
|
+
showLabels?: boolean;
|
|
17
|
+
/** Intrinsic drawing height in px. Default 280. */
|
|
18
|
+
height?: number;
|
|
19
|
+
/** Intrinsic drawing width in px. Default 480. */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** Stretch to the container width via the viewBox (width:100%). */
|
|
22
|
+
fluid?: boolean;
|
|
23
|
+
/** Reveal a tooltip on hover/focus of a node. Default true. */
|
|
24
|
+
tooltip?: boolean;
|
|
25
|
+
/** SR summary + accessible name; auto-generated when absent. */
|
|
26
|
+
summary?: string;
|
|
27
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
28
|
+
size?: Size;
|
|
29
|
+
}
|
|
30
|
+
declare const BumpChart: import("svelte").Component<Props, {}, "">;
|
|
31
|
+
type BumpChart = ReturnType<typeof BumpChart>;
|
|
32
|
+
export default BumpChart;
|