strata-react 1.0.32 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/UPGRADING.md +1 -0
- package/dist/components/cursor.d.ts +44 -0
- package/dist/components/line-chart.d.ts +92 -3
- package/dist/components/media.d.ts +6 -1
- package/dist/{geo-C0jcFp4q.js → cursor-DplHNzj3.js} +173 -3
- package/dist/cursor-DplHNzj3.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +505 -176
- package/dist/index.js.map +1 -1
- package/dist/lib/geo.d.ts +17 -1
- package/dist/map/fan.d.ts +15 -0
- package/dist/map/index.d.ts +3 -1
- package/dist/map/markers.d.ts +60 -0
- package/dist/map/route-map.d.ts +53 -1
- package/dist/map.js +624 -40
- package/dist/map.js.map +1 -1
- package/package.json +1 -1
- package/dist/geo-C0jcFp4q.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as cn, a as useColorScheme, c as ChoiceGroup, d as NativeSelect, f as Textarea, g as KeyText, h as Tooltip, i as colorSchemeScript, l as Field, m as controlHeight, n as ColorSchemeChoice, o as useSystemColorScheme, p as useFieldControl, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY, u as Input, v as typeSteps } from "./theme-BgTOESmN.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as NBSP, c as toDate, i as MISSING, n as useSharedCursor, o as createFormat, r as geo, s as format, t as CursorScope } from "./cursor-DplHNzj3.js";
|
|
3
3
|
import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-DgJMyXTT.js";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
@@ -2671,13 +2671,33 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
|
|
|
2671
2671
|
});
|
|
2672
2672
|
}
|
|
2673
2673
|
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
2674
|
-
function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, className }) {
|
|
2674
|
+
function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, cursor: cursorProp, className }) {
|
|
2675
2675
|
const duration = known && Number.isFinite(known) && known > 0 ? known : 0;
|
|
2676
2676
|
const disabled = off || duration === 0;
|
|
2677
2677
|
const track = React.useRef(null);
|
|
2678
2678
|
const input = React.useRef(null);
|
|
2679
2679
|
const frac = duration > 0 ? clamp$2(time / duration, 0, 1) : 0;
|
|
2680
2680
|
const seekTo = (t) => onSeek(clamp$2(t, 0, duration));
|
|
2681
|
+
const shared = useSharedCursor();
|
|
2682
|
+
const joined = Boolean(cursorProp) && shared !== null;
|
|
2683
|
+
const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
|
|
2684
|
+
const toCursor = mapping?.toCursor ?? ((t) => t);
|
|
2685
|
+
const setPlayback = shared?.setPlayback;
|
|
2686
|
+
const setPointer = shared?.setPointer;
|
|
2687
|
+
const playbackAt = joined && mapping?.playback !== false && duration > 0 ? toCursor(time) : null;
|
|
2688
|
+
React.useEffect(() => {
|
|
2689
|
+
if (!joined) return;
|
|
2690
|
+
setPlayback?.(playbackAt);
|
|
2691
|
+
}, [
|
|
2692
|
+
joined,
|
|
2693
|
+
setPlayback,
|
|
2694
|
+
playbackAt
|
|
2695
|
+
]);
|
|
2696
|
+
React.useEffect(() => () => {
|
|
2697
|
+
setPlayback?.(null);
|
|
2698
|
+
setPointer?.(null);
|
|
2699
|
+
}, [setPlayback, setPointer]);
|
|
2700
|
+
const otherTime = joined && shared.other !== null && duration > 0 ? (mapping?.fromCursor ?? ((c) => c))(shared.other) : null;
|
|
2681
2701
|
const timeText = React.useMemo(() => {
|
|
2682
2702
|
const say = (t) => timecode(t, {
|
|
2683
2703
|
precision,
|
|
@@ -2732,7 +2752,14 @@ function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffe
|
|
|
2732
2752
|
...groupProps,
|
|
2733
2753
|
className: cn("relative flex h-(--control-h) min-w-0 flex-1 items-center", disabled && "cursor-not-allowed opacity-50", className),
|
|
2734
2754
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2735
|
-
...trackProps,
|
|
2755
|
+
...mergeProps(trackProps, {
|
|
2756
|
+
onPointerMove: (e) => {
|
|
2757
|
+
if (!joined || duration === 0) return;
|
|
2758
|
+
const box = e.currentTarget.getBoundingClientRect();
|
|
2759
|
+
shared.setPointer(toCursor(clamp$2((e.clientX - box.left) / (box.width || 1) * duration, 0, duration)));
|
|
2760
|
+
},
|
|
2761
|
+
onPointerLeave: () => shared?.setPointer(null)
|
|
2762
|
+
}),
|
|
2736
2763
|
ref: track,
|
|
2737
2764
|
className: cn("relative flex h-full w-full cursor-pointer touch-none items-center", disabled && "cursor-not-allowed"),
|
|
2738
2765
|
children: [
|
|
@@ -2750,6 +2777,12 @@ function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffe
|
|
|
2750
2777
|
className: "absolute left-0 h-1.5 rounded-pill bg-primary",
|
|
2751
2778
|
style: { width: `${frac * 100}%` }
|
|
2752
2779
|
}),
|
|
2780
|
+
otherTime !== null && otherTime >= 0 && otherTime <= duration && /* @__PURE__ */ jsx("span", {
|
|
2781
|
+
"aria-hidden": true,
|
|
2782
|
+
"data-cursor": "",
|
|
2783
|
+
className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-foreground/60",
|
|
2784
|
+
style: { left: `${otherTime / duration * 100}%` }
|
|
2785
|
+
}),
|
|
2753
2786
|
duration > 0 && marks.map((m) => /* @__PURE__ */ jsx("button", {
|
|
2754
2787
|
type: "button",
|
|
2755
2788
|
tabIndex: -1,
|
|
@@ -5285,6 +5318,13 @@ function InfiniteList({ state, label, children, skeleton, empty, moreLabel, more
|
|
|
5285
5318
|
});
|
|
5286
5319
|
}
|
|
5287
5320
|
// src/components/line-chart.tsx
|
|
5321
|
+
var TONE_FILL = {
|
|
5322
|
+
neutral: "var(--muted)",
|
|
5323
|
+
info: "var(--info-subtle)",
|
|
5324
|
+
success: "var(--success-subtle)",
|
|
5325
|
+
warning: "var(--warning-subtle)",
|
|
5326
|
+
danger: "var(--danger-subtle)"
|
|
5327
|
+
};
|
|
5288
5328
|
function useWidth$1() {
|
|
5289
5329
|
const ref = React.useRef(null);
|
|
5290
5330
|
const [width, setWidth] = React.useState(0);
|
|
@@ -5352,6 +5392,66 @@ function yScale(values, pin = {}) {
|
|
|
5352
5392
|
].map((i) => min + (max - min) * i / 4)
|
|
5353
5393
|
};
|
|
5354
5394
|
}
|
|
5395
|
+
var linearScale = (values, pin) => {
|
|
5396
|
+
const y = yScale(values, pin);
|
|
5397
|
+
return {
|
|
5398
|
+
...y,
|
|
5399
|
+
at: (v) => (v - y.min) / (y.max - y.min),
|
|
5400
|
+
log: false
|
|
5401
|
+
};
|
|
5402
|
+
};
|
|
5403
|
+
/** The 1, 2, 5 × 10ⁿ values in `[lo, hi]`. */
|
|
5404
|
+
function decadeTicks(lo, hi, mantissas = [
|
|
5405
|
+
1,
|
|
5406
|
+
2,
|
|
5407
|
+
5
|
|
5408
|
+
]) {
|
|
5409
|
+
const out = [];
|
|
5410
|
+
for (let e = Math.floor(Math.log10(lo)) - 1; e <= Math.ceil(Math.log10(hi)) + 1; e++) for (const m of mantissas) out.push(Number((m * 10 ** e).toPrecision(12)));
|
|
5411
|
+
return out;
|
|
5412
|
+
}
|
|
5413
|
+
/**
|
|
5414
|
+
* A logarithmic y axis over the positive values: the ends are the nearest 1, 2, 5 steps outside the
|
|
5415
|
+
* data, the ticks are those steps, thinned to whole decades and then every k-th decade when there are
|
|
5416
|
+
* more than seven. Values at or below zero are ignored (the chart reports them). A pinned end is used as
|
|
5417
|
+
* given when it is positive and does not cut a reading off.
|
|
5418
|
+
*/
|
|
5419
|
+
function logScale(values, pin = {}) {
|
|
5420
|
+
const positive = values.filter((v) => Number.isFinite(v) && v > 0);
|
|
5421
|
+
const dMin = positive.length ? Math.min(...positive) : 1;
|
|
5422
|
+
const dMax = positive.length ? Math.max(...positive) : 10;
|
|
5423
|
+
const grid = decadeTicks(dMin, dMax);
|
|
5424
|
+
const pinMin = pin.min !== void 0 && pin.min > 0 && pin.min <= dMin ? pin.min : void 0;
|
|
5425
|
+
const pinMax = pin.max !== void 0 && pin.max > 0 && pin.max >= dMax ? pin.max : void 0;
|
|
5426
|
+
let min = pinMin ?? Math.max(...grid.filter((t) => t <= dMin * (1 + 1e-9)));
|
|
5427
|
+
let max = pinMax ?? Math.min(...grid.filter((t) => t >= dMax * (1 - 1e-9)));
|
|
5428
|
+
if (!(max > min)) max = min * 10;
|
|
5429
|
+
let ticks = decadeTicks(min, max).filter((t) => t >= min * (1 - 1e-9) && t <= max * (1 + 1e-9));
|
|
5430
|
+
if (ticks.length > 7) ticks = decadeTicks(min, max, [1]).filter((t) => t >= min * (1 - 1e-9) && t <= max * (1 + 1e-9));
|
|
5431
|
+
if (ticks.length > 7) {
|
|
5432
|
+
const k = Math.ceil(ticks.length / 6);
|
|
5433
|
+
ticks = ticks.filter((_, i) => i % k === 0);
|
|
5434
|
+
}
|
|
5435
|
+
const span = Math.log10(max) - Math.log10(min);
|
|
5436
|
+
return {
|
|
5437
|
+
min,
|
|
5438
|
+
max,
|
|
5439
|
+
ticks,
|
|
5440
|
+
at: (v) => (Math.log10(v) - Math.log10(min)) / span,
|
|
5441
|
+
log: true
|
|
5442
|
+
};
|
|
5443
|
+
}
|
|
5444
|
+
/** The value of a series at x, read between the two readings either side (flat beyond the ends). Series need not be sorted. */
|
|
5445
|
+
function valueAt(series, x) {
|
|
5446
|
+
const sorted = [...series].sort((p, q) => p.x - q.x);
|
|
5447
|
+
if (!sorted.length) return 0;
|
|
5448
|
+
if (x <= sorted[0].x) return sorted[0].y;
|
|
5449
|
+
for (let i = 1; i < sorted.length; i++) if (x <= sorted[i].x) {
|
|
5450
|
+
const [p0, p1] = [sorted[i - 1], sorted[i]];
|
|
5451
|
+
return p0.y + (p1.y - p0.y) * (x - p0.x) / (p1.x - p0.x || 1);
|
|
5452
|
+
}
|
|
5453
|
+
return sorted[sorted.length - 1].y;
|
|
5454
|
+
}
|
|
5355
5455
|
/** Roughly how wide a 12px caption label is, in px. jsdom cannot measure text, so the chart estimates. */
|
|
5356
5456
|
var labelWidth = (text) => text.length * 7;
|
|
5357
5457
|
/**
|
|
@@ -5368,42 +5468,74 @@ function fitTicks(ticks, scale, widthOf, gap = 12) {
|
|
|
5368
5468
|
return sorted.slice(0, 1);
|
|
5369
5469
|
}
|
|
5370
5470
|
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
5371
|
-
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5471
|
+
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, xDomain, xAxis = "labels", yScale: yMode = "linear", yInvert = false, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5372
5472
|
const [ref, width] = useWidth$1();
|
|
5473
|
+
const shared = useSharedCursor();
|
|
5474
|
+
const joined = Boolean(cursorProp) && shared !== null;
|
|
5475
|
+
const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
|
|
5373
5476
|
const gradientId = `heat-${React.useId().replace(/[^\w-]/g, "")}`;
|
|
5374
5477
|
const all = [...series, ...planned ?? []];
|
|
5375
|
-
const xMin = Math.min(...all.map((p) => p.x));
|
|
5376
|
-
const xMax = Math.max(...all.map((p) => p.x));
|
|
5377
|
-
const
|
|
5478
|
+
const xMin = xDomain ? xDomain[0] : Math.min(...all.map((p) => p.x));
|
|
5479
|
+
const xMax = xDomain ? xDomain[1] : Math.max(...all.map((p) => p.x));
|
|
5480
|
+
const log = yMode === "log";
|
|
5481
|
+
const y = log ? logScale(all.map((p) => p.y), {
|
|
5482
|
+
min: yMin,
|
|
5483
|
+
max: yMax
|
|
5484
|
+
}) : linearScale(all.map((p) => p.y), {
|
|
5378
5485
|
min: yMin,
|
|
5379
5486
|
max: yMax
|
|
5380
5487
|
});
|
|
5488
|
+
const undrawn = log ? series.filter((p) => !(p.y > 0)).length : 0;
|
|
5381
5489
|
const pad = {
|
|
5382
5490
|
top: 16,
|
|
5383
5491
|
right: 16,
|
|
5384
|
-
bottom: 28,
|
|
5492
|
+
bottom: xAxis === "none" ? 8 : 28,
|
|
5385
5493
|
left: 56
|
|
5386
5494
|
};
|
|
5387
5495
|
const w = Math.max(0, width - pad.left - pad.right);
|
|
5388
5496
|
const h = height - pad.top - pad.bottom;
|
|
5389
5497
|
const sx = (x) => pad.left + (x - xMin) / (xMax - xMin || 1) * w;
|
|
5390
|
-
const sy = (v) =>
|
|
5498
|
+
const sy = (v) => {
|
|
5499
|
+
const f = y.at(v);
|
|
5500
|
+
return pad.top + (yInvert ? f : 1 - f) * h;
|
|
5501
|
+
};
|
|
5391
5502
|
const xLabelWidth = (t) => labelWidth(formatX(t));
|
|
5392
5503
|
const xLabelAt = (t) => {
|
|
5393
5504
|
const half = xLabelWidth(t) / 2;
|
|
5394
5505
|
return Math.min(Math.max(sx(t), half), Math.max(half, width - half));
|
|
5395
5506
|
};
|
|
5396
|
-
const
|
|
5507
|
+
const tickList = React.useMemo(() => typeof xTicks === "function" ? xTicks({
|
|
5508
|
+
min: xMin,
|
|
5509
|
+
max: xMax
|
|
5510
|
+
}) : xTicks, [
|
|
5397
5511
|
xTicks,
|
|
5512
|
+
xMin,
|
|
5513
|
+
xMax
|
|
5514
|
+
]);
|
|
5515
|
+
const shownXTicks = React.useMemo(() => xAxis === "none" ? [] : fitTicks(tickList, xLabelAt, xLabelWidth), [
|
|
5516
|
+
tickList,
|
|
5398
5517
|
width,
|
|
5399
5518
|
xMin,
|
|
5400
5519
|
xMax,
|
|
5401
|
-
formatX
|
|
5520
|
+
formatX,
|
|
5521
|
+
xAxis
|
|
5402
5522
|
]);
|
|
5403
|
-
const path = (pts) =>
|
|
5523
|
+
const path = (pts) => {
|
|
5524
|
+
let pen = false;
|
|
5525
|
+
return pts.map((p) => {
|
|
5526
|
+
if (log && !(p.y > 0)) {
|
|
5527
|
+
pen = false;
|
|
5528
|
+
return "";
|
|
5529
|
+
}
|
|
5530
|
+
const cmd = `${pen ? "L" : "M"}${sx(p.x).toFixed(1)},${sy(p.y).toFixed(1)}`;
|
|
5531
|
+
pen = true;
|
|
5532
|
+
return cmd;
|
|
5533
|
+
}).join("");
|
|
5534
|
+
};
|
|
5404
5535
|
const last = series[series.length - 1];
|
|
5405
5536
|
const showEnd = (end ?? (current === void 0 ? "now" : "none")) === "now";
|
|
5406
5537
|
const peak = series.reduce((a, b) => b.y > a.y ? b : a, series[0]);
|
|
5538
|
+
const peakShown = !log || peak.y > 0;
|
|
5407
5539
|
const stops = colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [];
|
|
5408
5540
|
/** The colour a value lands on: the highest stop at or below it. Used for the labelled points. */
|
|
5409
5541
|
const colourAt = (y) => stops.length ? [...stops].reverse().find((s) => s.at <= y)?.colour ?? stops[0].colour : colour;
|
|
@@ -5417,19 +5549,29 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5417
5549
|
y1: sy(y.min),
|
|
5418
5550
|
y2: sy(y.max),
|
|
5419
5551
|
children: stops.map((s) => /* @__PURE__ */ jsx("stop", {
|
|
5420
|
-
offset: Math.min(1, Math.max(0,
|
|
5552
|
+
offset: Math.min(1, Math.max(0, s.at > 0 || !log ? y.at(s.at) : 0)),
|
|
5421
5553
|
stopColor: s.colour
|
|
5422
5554
|
}, s.at))
|
|
5423
5555
|
}) }),
|
|
5556
|
+
spans?.map((sp) => {
|
|
5557
|
+
const [a, b] = [Math.max(sx(Math.min(sp.from, sp.to)), pad.left), Math.min(sx(Math.max(sp.from, sp.to)), pad.left + w)];
|
|
5558
|
+
return b > a ? /* @__PURE__ */ jsx("rect", {
|
|
5559
|
+
x: a,
|
|
5560
|
+
y: pad.top,
|
|
5561
|
+
width: b - a,
|
|
5562
|
+
height: h,
|
|
5563
|
+
fill: TONE_FILL[sp.tone ?? "neutral"]
|
|
5564
|
+
}, `${sp.from}-${sp.to}-${sp.label}`) : null;
|
|
5565
|
+
}),
|
|
5424
5566
|
band && band.below > y.min && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
|
|
5425
5567
|
x: pad.left,
|
|
5426
|
-
y: sy(Math.min(band.below, y.max)),
|
|
5568
|
+
y: Math.min(sy(y.min), sy(Math.min(band.below, y.max))),
|
|
5427
5569
|
width: w,
|
|
5428
|
-
height: sy(y.min) - sy(Math.min(band.below, y.max)),
|
|
5570
|
+
height: Math.abs(sy(y.min) - sy(Math.min(band.below, y.max))),
|
|
5429
5571
|
fill: "var(--success-subtle)"
|
|
5430
5572
|
}), /* @__PURE__ */ jsx("text", {
|
|
5431
5573
|
x: pad.left + 8,
|
|
5432
|
-
y: sy(Math.min(band.below, y.max)) + 16,
|
|
5574
|
+
y: Math.min(sy(y.min), sy(Math.min(band.below, y.max))) + 16,
|
|
5433
5575
|
className: "fill-success type-caption",
|
|
5434
5576
|
children: band.label
|
|
5435
5577
|
})] }),
|
|
@@ -5476,19 +5618,18 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5476
5618
|
strokeLinejoin: "round",
|
|
5477
5619
|
strokeLinecap: "round"
|
|
5478
5620
|
}),
|
|
5479
|
-
/* @__PURE__ */ jsx("circle", {
|
|
5621
|
+
peakShown && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
|
|
5480
5622
|
cx: sx(peak.x),
|
|
5481
5623
|
cy: sy(peak.y),
|
|
5482
5624
|
r: 3,
|
|
5483
5625
|
fill: colourAt(peak.y)
|
|
5484
|
-
}),
|
|
5485
|
-
/* @__PURE__ */ jsxs("text", {
|
|
5626
|
+
}), /* @__PURE__ */ jsxs("text", {
|
|
5486
5627
|
x: sx(peak.x) + 8,
|
|
5487
5628
|
y: sy(peak.y) - 8,
|
|
5488
5629
|
className: "fill-foreground type-caption tabular-nums",
|
|
5489
5630
|
children: [formatY(peak.y), " peak"]
|
|
5490
|
-
}),
|
|
5491
|
-
showEnd && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5631
|
+
})] }),
|
|
5632
|
+
showEnd && (!log || last.y > 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5492
5633
|
/* @__PURE__ */ jsx("line", {
|
|
5493
5634
|
x1: sx(last.x),
|
|
5494
5635
|
x2: sx(last.x),
|
|
@@ -5517,7 +5658,13 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5517
5658
|
series,
|
|
5518
5659
|
planned,
|
|
5519
5660
|
band,
|
|
5520
|
-
|
|
5661
|
+
tickList,
|
|
5662
|
+
xMin,
|
|
5663
|
+
xMax,
|
|
5664
|
+
yMode,
|
|
5665
|
+
yInvert,
|
|
5666
|
+
xAxis,
|
|
5667
|
+
spans,
|
|
5521
5668
|
yMin,
|
|
5522
5669
|
yMax,
|
|
5523
5670
|
colour,
|
|
@@ -5527,29 +5674,41 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5527
5674
|
area,
|
|
5528
5675
|
showEnd
|
|
5529
5676
|
]);
|
|
5530
|
-
const tableEl = React.useMemo(() => /* @__PURE__ */
|
|
5677
|
+
const tableEl = React.useMemo(() => /* @__PURE__ */ jsxs("div", {
|
|
5531
5678
|
className: "sr-only",
|
|
5532
|
-
children:
|
|
5533
|
-
/* @__PURE__ */
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5679
|
+
children: [
|
|
5680
|
+
/* @__PURE__ */ jsxs("table", { children: [
|
|
5681
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
5682
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
5683
|
+
scope: "col",
|
|
5684
|
+
children: xLabel
|
|
5685
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
5686
|
+
scope: "col",
|
|
5687
|
+
children: seriesLabel
|
|
5688
|
+
})] }) }),
|
|
5689
|
+
/* @__PURE__ */ jsx("tbody", { children: series.map((p) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: formatX(p.x) }), /* @__PURE__ */ jsx("td", { children: formatY(p.y) })] }, p.x)) })
|
|
5690
|
+
] }),
|
|
5691
|
+
spans && spans.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
5692
|
+
"aria-label": "Shaded stretches",
|
|
5693
|
+
children: spans.map((sp) => /* @__PURE__ */ jsx("li", { children: `${sp.label}: ${formatX(sp.from)} to ${formatX(sp.to)}` }, `${sp.from}-${sp.to}-${sp.label}`))
|
|
5694
|
+
}),
|
|
5695
|
+
marks && marks.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
5696
|
+
"aria-label": "Marks",
|
|
5697
|
+
children: marks.map((m) => /* @__PURE__ */ jsx("li", { children: `${m.label}: ${formatX(m.x)}${m.selected ? ", selected" : ""}` }, `${m.x}-${m.label}`))
|
|
5698
|
+
})
|
|
5699
|
+
]
|
|
5543
5700
|
}), [
|
|
5544
5701
|
label,
|
|
5545
5702
|
seriesLabel,
|
|
5546
5703
|
series,
|
|
5547
5704
|
formatX,
|
|
5548
5705
|
formatY,
|
|
5549
|
-
xLabel
|
|
5706
|
+
xLabel,
|
|
5707
|
+
spans,
|
|
5708
|
+
marks
|
|
5550
5709
|
]);
|
|
5551
5710
|
const sorted = React.useMemo(() => [...series].sort((p, q) => p.x - q.x), [series]);
|
|
5552
|
-
const interactive = Boolean(readout || onPick);
|
|
5711
|
+
const interactive = Boolean(readout || onPick || joined);
|
|
5553
5712
|
const [hover, setHover] = React.useState(null);
|
|
5554
5713
|
const [kbd, setKbd] = React.useState(null);
|
|
5555
5714
|
const [focused, setFocused] = React.useState(false);
|
|
@@ -5578,6 +5737,22 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5578
5737
|
const heldIdx = kbd === null ? fallbackIdx : Math.min(kbd, Math.max(sorted.length - 1, 0));
|
|
5579
5738
|
const selectedIdx = hover === null ? heldIdx : Math.min(hover, Math.max(sorted.length - 1, 0));
|
|
5580
5739
|
const active = (hover !== null || focused) && sorted.length ? sorted[selectedIdx] : null;
|
|
5740
|
+
const setPointer = shared?.setPointer;
|
|
5741
|
+
const writeAt = active ? (mapping?.toCursor ?? ((x) => x))(active.x) : null;
|
|
5742
|
+
React.useEffect(() => {
|
|
5743
|
+
if (!joined || !setPointer) return;
|
|
5744
|
+
setPointer(writeAt);
|
|
5745
|
+
}, [
|
|
5746
|
+
joined,
|
|
5747
|
+
setPointer,
|
|
5748
|
+
writeAt
|
|
5749
|
+
]);
|
|
5750
|
+
React.useEffect(() => () => setPointer?.(null), [setPointer]);
|
|
5751
|
+
const otherX = joined && shared.other !== null ? (mapping?.fromCursor ?? ((c) => c))(shared.other) : null;
|
|
5752
|
+
const otherAt = otherX !== null && otherX >= xMin && otherX <= xMax ? {
|
|
5753
|
+
x: otherX,
|
|
5754
|
+
y: yAt(otherX)
|
|
5755
|
+
} : null;
|
|
5581
5756
|
const onKey = (e) => {
|
|
5582
5757
|
const at = selectedIdx;
|
|
5583
5758
|
let next = at;
|
|
@@ -5607,120 +5782,210 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5607
5782
|
/* @__PURE__ */ jsxs("div", {
|
|
5608
5783
|
ref,
|
|
5609
5784
|
className: "relative min-w-0",
|
|
5610
|
-
children: [
|
|
5611
|
-
width,
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
"
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5785
|
+
children: [
|
|
5786
|
+
width > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
5787
|
+
width,
|
|
5788
|
+
height,
|
|
5789
|
+
role: "img",
|
|
5790
|
+
"aria-label": label,
|
|
5791
|
+
className: "block overflow-visible",
|
|
5792
|
+
children: [
|
|
5793
|
+
plot,
|
|
5794
|
+
currentAt && /* @__PURE__ */ jsxs("g", {
|
|
5795
|
+
"aria-hidden": true,
|
|
5796
|
+
children: [
|
|
5797
|
+
/* @__PURE__ */ jsx("line", {
|
|
5798
|
+
x1: sx(currentAt.x),
|
|
5799
|
+
x2: sx(currentAt.x),
|
|
5800
|
+
y1: pad.top,
|
|
5801
|
+
y2: pad.top + h,
|
|
5802
|
+
stroke: "var(--primary)",
|
|
5803
|
+
strokeWidth: 1.5
|
|
5804
|
+
}),
|
|
5805
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5806
|
+
cx: sx(currentAt.x),
|
|
5807
|
+
cy: sy(currentAt.y),
|
|
5808
|
+
r: 4,
|
|
5809
|
+
fill: "var(--background)",
|
|
5810
|
+
stroke: "var(--primary)",
|
|
5811
|
+
strokeWidth: 2
|
|
5812
|
+
}),
|
|
5813
|
+
(() => {
|
|
5814
|
+
const text = formatCurrent ? formatCurrent(currentAt) : `${formatX(currentAt.x)}: ${formatY(currentAt.y)}`;
|
|
5815
|
+
const at = flip(sx(currentAt.x), text);
|
|
5816
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5817
|
+
x: at.x,
|
|
5818
|
+
y: pad.top + 12,
|
|
5819
|
+
textAnchor: at.anchor,
|
|
5820
|
+
className: "fill-foreground type-caption tabular-nums",
|
|
5821
|
+
children: text
|
|
5822
|
+
});
|
|
5823
|
+
})()
|
|
5824
|
+
]
|
|
5825
|
+
}),
|
|
5826
|
+
otherAt && (!log || otherAt.y > 0) && /* @__PURE__ */ jsxs("g", {
|
|
5827
|
+
"aria-hidden": true,
|
|
5828
|
+
children: [
|
|
5829
|
+
/* @__PURE__ */ jsx("line", {
|
|
5830
|
+
x1: sx(otherAt.x),
|
|
5831
|
+
x2: sx(otherAt.x),
|
|
5832
|
+
y1: pad.top,
|
|
5833
|
+
y2: pad.top + h,
|
|
5834
|
+
stroke: "var(--muted-foreground)",
|
|
5835
|
+
strokeWidth: 1,
|
|
5836
|
+
strokeDasharray: "2 3"
|
|
5837
|
+
}),
|
|
5838
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5839
|
+
cx: sx(otherAt.x),
|
|
5840
|
+
cy: sy(otherAt.y),
|
|
5841
|
+
r: 4,
|
|
5842
|
+
fill: "var(--background)",
|
|
5843
|
+
stroke: "var(--foreground)",
|
|
5844
|
+
strokeWidth: 2
|
|
5845
|
+
}),
|
|
5846
|
+
(() => {
|
|
5847
|
+
const text = `${formatX(otherAt.x)}: ${formatY(otherAt.y)}`;
|
|
5848
|
+
const at = flip(sx(otherAt.x), text);
|
|
5849
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5850
|
+
x: at.x,
|
|
5851
|
+
y: sy(otherAt.y) - 10,
|
|
5852
|
+
textAnchor: at.anchor,
|
|
5853
|
+
className: "fill-foreground type-caption tabular-nums",
|
|
5854
|
+
paintOrder: "stroke",
|
|
5855
|
+
stroke: "var(--background)",
|
|
5856
|
+
strokeWidth: 3,
|
|
5857
|
+
children: text
|
|
5858
|
+
});
|
|
5859
|
+
})()
|
|
5860
|
+
]
|
|
5861
|
+
}),
|
|
5862
|
+
active && /* @__PURE__ */ jsxs("g", {
|
|
5863
|
+
"aria-hidden": true,
|
|
5864
|
+
children: [
|
|
5865
|
+
/* @__PURE__ */ jsx("line", {
|
|
5866
|
+
x1: sx(active.x),
|
|
5867
|
+
x2: sx(active.x),
|
|
5868
|
+
y1: pad.top,
|
|
5869
|
+
y2: pad.top + h,
|
|
5870
|
+
stroke: "var(--muted-foreground)",
|
|
5871
|
+
strokeWidth: 1,
|
|
5872
|
+
strokeDasharray: "2 3"
|
|
5873
|
+
}),
|
|
5874
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5875
|
+
cx: sx(active.x),
|
|
5876
|
+
cy: sy(active.y),
|
|
5877
|
+
r: 4,
|
|
5878
|
+
fill: "var(--foreground)"
|
|
5879
|
+
}),
|
|
5880
|
+
(() => {
|
|
5881
|
+
const text = readoutText(active);
|
|
5882
|
+
const at = flip(sx(active.x), text);
|
|
5883
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5884
|
+
x: at.x,
|
|
5885
|
+
y: sy(active.y) - 10,
|
|
5886
|
+
textAnchor: at.anchor,
|
|
5887
|
+
className: "fill-foreground type-label tabular-nums",
|
|
5888
|
+
paintOrder: "stroke",
|
|
5889
|
+
stroke: "var(--background)",
|
|
5890
|
+
strokeWidth: 3,
|
|
5891
|
+
children: text
|
|
5892
|
+
});
|
|
5893
|
+
})()
|
|
5894
|
+
]
|
|
5895
|
+
})
|
|
5896
|
+
]
|
|
5897
|
+
}),
|
|
5898
|
+
width > 0 && interactive && sorted.length > 0 && /* @__PURE__ */ jsx(ReadingSlider, {
|
|
5899
|
+
label: `${label}: read values`,
|
|
5900
|
+
sorted,
|
|
5901
|
+
selected: selectedIdx,
|
|
5902
|
+
text: readoutText,
|
|
5903
|
+
onSelect: (i) => {
|
|
5904
|
+
setHover(null);
|
|
5905
|
+
setKbd(i);
|
|
5906
|
+
},
|
|
5907
|
+
onPick,
|
|
5908
|
+
onKeyDownCapture: onKey,
|
|
5909
|
+
onHover: (px) => setHover(px === null ? null : nearest(px)),
|
|
5910
|
+
onFocusChange: setFocused,
|
|
5911
|
+
domain: [xMin, xMax],
|
|
5912
|
+
box: {
|
|
5913
|
+
left: pad.left,
|
|
5914
|
+
top: pad.top,
|
|
5915
|
+
width: w,
|
|
5916
|
+
height: h
|
|
5917
|
+
}
|
|
5918
|
+
}),
|
|
5919
|
+
width > 0 && marks && marks.length > 0 && /* @__PURE__ */ jsx(MarkButtons, {
|
|
5920
|
+
marks: marks.filter((m) => m.x >= xMin && m.x <= xMax && (!log || yAt(m.x) > 0)),
|
|
5921
|
+
place: (m) => ({
|
|
5922
|
+
left: sx(m.x),
|
|
5923
|
+
top: sy(yAt(m.x))
|
|
5649
5924
|
}),
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
x2: sx(active.x),
|
|
5656
|
-
y1: pad.top,
|
|
5657
|
-
y2: pad.top + h,
|
|
5658
|
-
stroke: "var(--muted-foreground)",
|
|
5659
|
-
strokeWidth: 1,
|
|
5660
|
-
strokeDasharray: "2 3"
|
|
5661
|
-
}),
|
|
5662
|
-
/* @__PURE__ */ jsx("circle", {
|
|
5663
|
-
cx: sx(active.x),
|
|
5664
|
-
cy: sy(active.y),
|
|
5665
|
-
r: 4,
|
|
5666
|
-
fill: "var(--foreground)"
|
|
5667
|
-
}),
|
|
5668
|
-
(() => {
|
|
5669
|
-
const text = readoutText(active);
|
|
5670
|
-
const at = flip(sx(active.x), text);
|
|
5671
|
-
return /* @__PURE__ */ jsx("text", {
|
|
5672
|
-
x: at.x,
|
|
5673
|
-
y: sy(active.y) - 10,
|
|
5674
|
-
textAnchor: at.anchor,
|
|
5675
|
-
className: "fill-foreground type-label tabular-nums",
|
|
5676
|
-
paintOrder: "stroke",
|
|
5677
|
-
stroke: "var(--background)",
|
|
5678
|
-
strokeWidth: 3,
|
|
5679
|
-
children: text
|
|
5680
|
-
});
|
|
5681
|
-
})()
|
|
5682
|
-
]
|
|
5683
|
-
})
|
|
5684
|
-
]
|
|
5685
|
-
}), width > 0 && interactive && sorted.length > 0 && /* @__PURE__ */ jsx(ReadingSlider, {
|
|
5686
|
-
label: `${label}: read values`,
|
|
5687
|
-
sorted,
|
|
5688
|
-
selected: selectedIdx,
|
|
5689
|
-
text: readoutText,
|
|
5690
|
-
onSelect: (i) => {
|
|
5691
|
-
setHover(null);
|
|
5692
|
-
setKbd(i);
|
|
5693
|
-
},
|
|
5694
|
-
onPick,
|
|
5695
|
-
onKeyDownCapture: onKey,
|
|
5696
|
-
onHover: (px) => setHover(px === null ? null : nearest(px)),
|
|
5697
|
-
onFocusChange: setFocused,
|
|
5698
|
-
box: {
|
|
5699
|
-
left: pad.left,
|
|
5700
|
-
top: pad.top,
|
|
5701
|
-
width: w,
|
|
5702
|
-
height: h
|
|
5703
|
-
}
|
|
5704
|
-
})]
|
|
5925
|
+
formatX,
|
|
5926
|
+
onSelect: onMarkSelect,
|
|
5927
|
+
card: renderMarkCard
|
|
5928
|
+
})
|
|
5929
|
+
]
|
|
5705
5930
|
}),
|
|
5706
5931
|
/* @__PURE__ */ jsxs("figcaption", {
|
|
5707
5932
|
className: "flex flex-wrap gap-x-5 gap-y-1 type-caption text-muted-foreground",
|
|
5708
|
-
children: [
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5933
|
+
children: [
|
|
5934
|
+
/* @__PURE__ */ jsxs("span", {
|
|
5935
|
+
className: "inline-flex items-center gap-2",
|
|
5936
|
+
children: [
|
|
5937
|
+
stops.length ? /* @__PURE__ */ jsx("svg", {
|
|
5938
|
+
width: stops.length * 8,
|
|
5939
|
+
height: "3",
|
|
5940
|
+
"aria-hidden": true,
|
|
5941
|
+
children: stops.map((s, i) => /* @__PURE__ */ jsx("line", {
|
|
5942
|
+
x1: i * 8,
|
|
5943
|
+
x2: i * 8 + 8,
|
|
5944
|
+
y1: "1.5",
|
|
5945
|
+
y2: "1.5",
|
|
5946
|
+
stroke: s.colour,
|
|
5947
|
+
strokeWidth: 3
|
|
5948
|
+
}, s.at))
|
|
5949
|
+
}) : /* @__PURE__ */ jsx("svg", {
|
|
5950
|
+
width: "16",
|
|
5951
|
+
height: "2",
|
|
5952
|
+
"aria-hidden": true,
|
|
5953
|
+
children: /* @__PURE__ */ jsx("line", {
|
|
5954
|
+
x1: "0",
|
|
5955
|
+
x2: "16",
|
|
5956
|
+
y1: "1",
|
|
5957
|
+
y2: "1",
|
|
5958
|
+
stroke: colour,
|
|
5959
|
+
strokeWidth: 2
|
|
5960
|
+
})
|
|
5961
|
+
}),
|
|
5962
|
+
seriesLabel,
|
|
5963
|
+
stops.length > 0 && colourScaleLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5964
|
+
"(",
|
|
5965
|
+
colourScaleLabel,
|
|
5966
|
+
")"
|
|
5967
|
+
] })
|
|
5968
|
+
]
|
|
5969
|
+
}),
|
|
5970
|
+
spans?.map((sp) => /* @__PURE__ */ jsxs("span", {
|
|
5971
|
+
className: "inline-flex items-center gap-2",
|
|
5972
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
5973
|
+
width: "14",
|
|
5974
|
+
height: "10",
|
|
5714
5975
|
"aria-hidden": true,
|
|
5715
|
-
children:
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
stroke:
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5976
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
5977
|
+
width: "14",
|
|
5978
|
+
height: "10",
|
|
5979
|
+
rx: "2",
|
|
5980
|
+
fill: TONE_FILL[sp.tone ?? "neutral"],
|
|
5981
|
+
stroke: "var(--border)"
|
|
5982
|
+
})
|
|
5983
|
+
}), sp.label]
|
|
5984
|
+
}, `${sp.from}-${sp.to}-${sp.label}`)),
|
|
5985
|
+
undrawn > 0 && /* @__PURE__ */ jsx("span", { children: undrawn === 1 ? "1 reading at or below zero is not drawn" : `${undrawn} readings at or below zero are not drawn` }),
|
|
5986
|
+
planned && plannedLabel && /* @__PURE__ */ jsxs("span", {
|
|
5987
|
+
className: "inline-flex items-center gap-2",
|
|
5988
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
5724
5989
|
width: "16",
|
|
5725
5990
|
height: "2",
|
|
5726
5991
|
"aria-hidden": true,
|
|
@@ -5729,45 +5994,71 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5729
5994
|
x2: "16",
|
|
5730
5995
|
y1: "1",
|
|
5731
5996
|
y2: "1",
|
|
5732
|
-
stroke:
|
|
5733
|
-
strokeWidth:
|
|
5997
|
+
stroke: "var(--muted-foreground)",
|
|
5998
|
+
strokeWidth: 1.5,
|
|
5999
|
+
strokeDasharray: "4 4"
|
|
5734
6000
|
})
|
|
5735
|
-
}),
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
"(",
|
|
5739
|
-
colourScaleLabel,
|
|
5740
|
-
")"
|
|
5741
|
-
] })
|
|
5742
|
-
]
|
|
5743
|
-
}), planned && plannedLabel && /* @__PURE__ */ jsxs("span", {
|
|
5744
|
-
className: "inline-flex items-center gap-2",
|
|
5745
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
5746
|
-
width: "16",
|
|
5747
|
-
height: "2",
|
|
5748
|
-
"aria-hidden": true,
|
|
5749
|
-
children: /* @__PURE__ */ jsx("line", {
|
|
5750
|
-
x1: "0",
|
|
5751
|
-
x2: "16",
|
|
5752
|
-
y1: "1",
|
|
5753
|
-
y2: "1",
|
|
5754
|
-
stroke: "var(--muted-foreground)",
|
|
5755
|
-
strokeWidth: 1.5,
|
|
5756
|
-
strokeDasharray: "4 4"
|
|
5757
|
-
})
|
|
5758
|
-
}), plannedLabel]
|
|
5759
|
-
})]
|
|
6001
|
+
}), plannedLabel]
|
|
6002
|
+
})
|
|
6003
|
+
]
|
|
5760
6004
|
}),
|
|
5761
6005
|
tableEl
|
|
5762
6006
|
]
|
|
5763
6007
|
});
|
|
5764
6008
|
}
|
|
6009
|
+
/** The marks as controls: one tab stop for the group, arrows, Home and End between them, each named by its label and x. */
|
|
6010
|
+
function MarkButtons({ marks, place, formatX, onSelect, card }) {
|
|
6011
|
+
const [active, setActive] = React.useState(0);
|
|
6012
|
+
const refs = React.useRef([]);
|
|
6013
|
+
const at = Math.min(active, marks.length - 1);
|
|
6014
|
+
const move = (i) => {
|
|
6015
|
+
const next = Math.max(0, Math.min(marks.length - 1, i));
|
|
6016
|
+
setActive(next);
|
|
6017
|
+
refs.current[next]?.focus();
|
|
6018
|
+
};
|
|
6019
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6020
|
+
role: "group",
|
|
6021
|
+
"aria-label": "Marks",
|
|
6022
|
+
onKeyDown: (e) => {
|
|
6023
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") move(at + 1);
|
|
6024
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowUp") move(at - 1);
|
|
6025
|
+
else if (e.key === "Home") move(0);
|
|
6026
|
+
else if (e.key === "End") move(marks.length - 1);
|
|
6027
|
+
else return;
|
|
6028
|
+
e.preventDefault();
|
|
6029
|
+
},
|
|
6030
|
+
children: marks.map((m, i) => {
|
|
6031
|
+
const pos = place(m);
|
|
6032
|
+
const name = `${m.label}, ${formatX(m.x)}`;
|
|
6033
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
6034
|
+
label: card ? card(m) : name,
|
|
6035
|
+
side: "top",
|
|
6036
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
6037
|
+
ref: (el) => {
|
|
6038
|
+
refs.current[i] = el;
|
|
6039
|
+
},
|
|
6040
|
+
"aria-label": name,
|
|
6041
|
+
"aria-pressed": m.selected ?? false,
|
|
6042
|
+
excludeFromTabOrder: i !== at,
|
|
6043
|
+
onFocus: () => setActive(i),
|
|
6044
|
+
onPress: () => onSelect?.(m),
|
|
6045
|
+
className: cn("absolute z-10 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-pill border-2 border-background outline-offset-2 transition-state focus-visible:outline-2 focus-visible:outline-ring", m.selected ? "size-4 ring-2 ring-foreground" : "size-3"),
|
|
6046
|
+
style: {
|
|
6047
|
+
left: pos.left,
|
|
6048
|
+
top: pos.top,
|
|
6049
|
+
background: m.colour ?? "var(--foreground)"
|
|
6050
|
+
}
|
|
6051
|
+
})
|
|
6052
|
+
}, `${m.x}-${m.label}`);
|
|
6053
|
+
})
|
|
6054
|
+
});
|
|
6055
|
+
}
|
|
5765
6056
|
/** The slider over the plot: React Aria's hooks, snapped to the readings, with the reading as its spoken value. */
|
|
5766
|
-
function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyDownCapture, onHover, onFocusChange, box }) {
|
|
6057
|
+
function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyDownCapture, onHover, onFocusChange, domain, box }) {
|
|
5767
6058
|
const track = React.useRef(null);
|
|
5768
6059
|
const input = React.useRef(null);
|
|
5769
|
-
const lo =
|
|
5770
|
-
const hi = Math.max(
|
|
6060
|
+
const lo = domain[0];
|
|
6061
|
+
const hi = Math.max(domain[1], lo + 1e-9);
|
|
5771
6062
|
const indexAt = (x) => {
|
|
5772
6063
|
let best = 0;
|
|
5773
6064
|
for (let i = 1; i < sorted.length; i++) if (Math.abs(sorted[i].x - x) < Math.abs(sorted[best].x - x)) best = i;
|
|
@@ -5828,6 +6119,44 @@ function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyD
|
|
|
5828
6119
|
})
|
|
5829
6120
|
});
|
|
5830
6121
|
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Charts stacked on one x axis: one shared range, labels on the last chart only, and one cursor, so
|
|
6124
|
+
* hovering or arrowing in any chart puts a rule and that chart's own reading in all of them (read
|
|
6125
|
+
* together, and announced as one sentence, politely, at most once a second). Inside a `CursorScope`
|
|
6126
|
+
* already, it joins that scope (a map beside the charts moves with them); otherwise it makes its own.
|
|
6127
|
+
*/
|
|
6128
|
+
function LineChartGroup({ label, charts, formatX, xLabel, xTicks, spans, marks, onMarkSelect, renderMarkCard, current, onPick, className }) {
|
|
6129
|
+
const inScope = useSharedCursor() !== null;
|
|
6130
|
+
const xs = charts.flatMap((c) => [...c.series, ...c.planned ?? []].map((p) => p.x));
|
|
6131
|
+
const domain = [Math.min(...xs), Math.max(...xs)];
|
|
6132
|
+
const say = (x) => `${formatX(x)}: ${charts.map((c) => `${c.label ?? c.seriesLabel} ${c.formatY(valueAt(c.series, x))}`).join(", ")}`;
|
|
6133
|
+
const stack = /* @__PURE__ */ jsx("div", {
|
|
6134
|
+
role: "group",
|
|
6135
|
+
"aria-label": label,
|
|
6136
|
+
className: cn("grid min-w-0 gap-1", className),
|
|
6137
|
+
children: charts.map((c, i) => /* @__PURE__ */ jsx(LineChart, {
|
|
6138
|
+
spans,
|
|
6139
|
+
marks,
|
|
6140
|
+
onMarkSelect,
|
|
6141
|
+
renderMarkCard,
|
|
6142
|
+
...c,
|
|
6143
|
+
label: c.label ?? c.seriesLabel,
|
|
6144
|
+
formatX,
|
|
6145
|
+
xLabel,
|
|
6146
|
+
xTicks,
|
|
6147
|
+
xDomain: domain,
|
|
6148
|
+
xAxis: i === charts.length - 1 ? "labels" : "none",
|
|
6149
|
+
current,
|
|
6150
|
+
onPick,
|
|
6151
|
+
cursor: true,
|
|
6152
|
+
readout: true
|
|
6153
|
+
}, c.label ?? c.seriesLabel))
|
|
6154
|
+
});
|
|
6155
|
+
return inScope ? stack : /* @__PURE__ */ jsx(CursorScope, {
|
|
6156
|
+
format: say,
|
|
6157
|
+
children: stack
|
|
6158
|
+
});
|
|
6159
|
+
}
|
|
5831
6160
|
// src/components/page-header.tsx
|
|
5832
6161
|
/** The top of an Operate screen: a noun title, its scope, the main action, and the finding (the one fact in today's data that most needs attention). */
|
|
5833
6162
|
function PageHeader({ title, scope, actions, finding, as: Heading = "h1" }) {
|
|
@@ -9828,6 +10157,6 @@ function SaveStatus({ state, onRetry, className }) {
|
|
|
9828
10157
|
]
|
|
9829
10158
|
});
|
|
9830
10159
|
}
|
|
9831
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, boxViewport, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, diffWords, differences, fetchJson, fieldErrorsOf, format, formatChord, gainToVolume, geo, isReservedChord, isTypingTarget, labelOf, loudnessOf, matchGains, matchesAccept, matchesChord, measureLoudness, noOverlap, parseChord, parseSort, readErrorBody, readPixels, regionShares, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
|
|
10160
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, CompositionBar, ContextMenu, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, boxViewport, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, diffWords, differences, fetchJson, fieldErrorsOf, format, formatChord, gainToVolume, geo, isReservedChord, isTypingTarget, labelOf, logScale, loudnessOf, matchGains, matchesAccept, matchesChord, measureLoudness, noOverlap, parseChord, parseSort, readErrorBody, readPixels, regionShares, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, valueAt, zoomAt };
|
|
9832
10161
|
|
|
9833
10162
|
//# sourceMappingURL=index.js.map
|