@xeonr/platform-ui 1.11.0 → 1.12.1
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/auth/AuthCode.d.ts +48 -0
- package/dist/auth/AuthCode.d.ts.map +1 -0
- package/dist/auth/AuthCode.js +197 -0
- package/dist/auth/AuthCode.js.map +1 -0
- package/dist/auth/AuthConsent.d.ts +69 -0
- package/dist/auth/AuthConsent.d.ts.map +1 -0
- package/dist/auth/AuthConsent.js +155 -0
- package/dist/auth/AuthConsent.js.map +1 -0
- package/dist/auth/AuthControls.d.ts +133 -0
- package/dist/auth/AuthControls.d.ts.map +1 -0
- package/dist/auth/AuthControls.js +379 -0
- package/dist/auth/AuthControls.js.map +1 -0
- package/dist/auth/AuthPanel.d.ts +106 -0
- package/dist/auth/AuthPanel.d.ts.map +1 -0
- package/dist/auth/AuthPanel.js +317 -0
- package/dist/auth/AuthPanel.js.map +1 -0
- package/dist/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +15 -0
- package/dist/auth.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/Anchored.js +109 -109
- package/dist/kit/Anchored.js.map +1 -1
- package/dist/kit/ApiKeyForm.js +73 -73
- package/dist/kit/ApiKeyForm.js.map +1 -1
- package/dist/kit/ApiKeys.js +144 -144
- package/dist/kit/ApiKeys.js.map +1 -1
- package/dist/kit/Badge.js +45 -45
- package/dist/kit/Badge.js.map +1 -1
- package/dist/kit/Blocks.d.ts.map +1 -1
- package/dist/kit/Blocks.js +103 -102
- package/dist/kit/Blocks.js.map +1 -1
- package/dist/kit/Board.js +54 -54
- package/dist/kit/Board.js.map +1 -1
- package/dist/kit/Button.d.ts +3 -3
- package/dist/kit/Button.d.ts.map +1 -1
- package/dist/kit/Button.js +55 -50
- package/dist/kit/Button.js.map +1 -1
- package/dist/kit/Card.d.ts.map +1 -1
- package/dist/kit/Card.js +41 -31
- package/dist/kit/Card.js.map +1 -1
- package/dist/kit/ChartFrame.js +54 -54
- package/dist/kit/ChartFrame.js.map +1 -1
- package/dist/kit/ChartTypes.js +215 -215
- package/dist/kit/ChartTypes.js.map +1 -1
- package/dist/kit/Charts.js +605 -605
- package/dist/kit/Charts.js.map +1 -1
- package/dist/kit/Checkbox.js +16 -16
- package/dist/kit/Checkbox.js.map +1 -1
- package/dist/kit/Chip.js +21 -21
- package/dist/kit/Chip.js.map +1 -1
- package/dist/kit/Choice.js +24 -24
- package/dist/kit/Choice.js.map +1 -1
- package/dist/kit/CodeEditor.js +25 -25
- package/dist/kit/CodeEditor.js.map +1 -1
- package/dist/kit/Color.js +74 -74
- package/dist/kit/Color.js.map +1 -1
- package/dist/kit/Combobox.js +67 -67
- package/dist/kit/Combobox.js.map +1 -1
- package/dist/kit/CommandPalette.d.ts.map +1 -1
- package/dist/kit/CommandPalette.js +96 -86
- package/dist/kit/CommandPalette.js.map +1 -1
- package/dist/kit/Comment.js +7 -7
- package/dist/kit/Comment.js.map +1 -1
- package/dist/kit/Controls.js +122 -122
- package/dist/kit/Controls.js.map +1 -1
- package/dist/kit/DataGrid.js +97 -97
- package/dist/kit/DataGrid.js.map +1 -1
- package/dist/kit/DataTable.d.ts.map +1 -1
- package/dist/kit/DataTable.js +196 -195
- package/dist/kit/DataTable.js.map +1 -1
- package/dist/kit/DatePicker.js +242 -242
- package/dist/kit/DatePicker.js.map +1 -1
- package/dist/kit/Drawer.d.ts.map +1 -1
- package/dist/kit/Drawer.js +15 -14
- package/dist/kit/Drawer.js.map +1 -1
- package/dist/kit/Dropzone.js +80 -80
- package/dist/kit/Dropzone.js.map +1 -1
- package/dist/kit/Editable.d.ts.map +1 -1
- package/dist/kit/Editable.js +130 -129
- package/dist/kit/Editable.js.map +1 -1
- package/dist/kit/EmptyState.d.ts.map +1 -1
- package/dist/kit/EmptyState.js +14 -13
- package/dist/kit/EmptyState.js.map +1 -1
- package/dist/kit/EntityHeader.d.ts.map +1 -1
- package/dist/kit/EntityHeader.js +17 -16
- package/dist/kit/EntityHeader.js.map +1 -1
- package/dist/kit/Facet.js +52 -52
- package/dist/kit/Facet.js.map +1 -1
- package/dist/kit/FacetRail.js +91 -91
- package/dist/kit/FacetRail.js.map +1 -1
- package/dist/kit/Forbidden.js +7 -7
- package/dist/kit/Forbidden.js.map +1 -1
- package/dist/kit/Form.d.ts.map +1 -1
- package/dist/kit/Form.js +157 -143
- package/dist/kit/Form.js.map +1 -1
- package/dist/kit/Graph.js +429 -429
- package/dist/kit/Graph.js.map +1 -1
- package/dist/kit/GroupedMultiSelect.js +115 -115
- package/dist/kit/GroupedMultiSelect.js.map +1 -1
- package/dist/kit/Icon.d.ts +2 -0
- package/dist/kit/Icon.d.ts.map +1 -1
- package/dist/kit/Icon.js +3 -1
- package/dist/kit/Icon.js.map +1 -1
- package/dist/kit/JumpList.js +11 -11
- package/dist/kit/JumpList.js.map +1 -1
- package/dist/kit/KV.js +6 -6
- package/dist/kit/KV.js.map +1 -1
- package/dist/kit/Layout.js +5 -5
- package/dist/kit/Layout.js.map +1 -1
- package/dist/kit/List.js +74 -74
- package/dist/kit/List.js.map +1 -1
- package/dist/kit/LogView.js +68 -68
- package/dist/kit/LogView.js.map +1 -1
- package/dist/kit/Markdown.js +37 -37
- package/dist/kit/Markdown.js.map +1 -1
- package/dist/kit/Marker.js +42 -42
- package/dist/kit/Marker.js.map +1 -1
- package/dist/kit/Menu.js +128 -128
- package/dist/kit/Menu.js.map +1 -1
- package/dist/kit/Modal.d.ts.map +1 -1
- package/dist/kit/Modal.js +86 -75
- package/dist/kit/Modal.js.map +1 -1
- package/dist/kit/MultiCombobox.js +157 -157
- package/dist/kit/MultiCombobox.js.map +1 -1
- package/dist/kit/PageHeader.d.ts.map +1 -1
- package/dist/kit/PageHeader.js +8 -7
- package/dist/kit/PageHeader.js.map +1 -1
- package/dist/kit/Panel.d.ts.map +1 -1
- package/dist/kit/Panel.js +33 -14
- package/dist/kit/Panel.js.map +1 -1
- package/dist/kit/Picker.js +159 -159
- package/dist/kit/Picker.js.map +1 -1
- package/dist/kit/PipelineFlow.js +86 -86
- package/dist/kit/PipelineFlow.js.map +1 -1
- package/dist/kit/Popover.js +67 -67
- package/dist/kit/Popover.js.map +1 -1
- package/dist/kit/Range.js +76 -76
- package/dist/kit/Range.js.map +1 -1
- package/dist/kit/Reorder.js +95 -95
- package/dist/kit/Reorder.js.map +1 -1
- package/dist/kit/Search.js +27 -27
- package/dist/kit/Search.js.map +1 -1
- package/dist/kit/Secret.js +26 -26
- package/dist/kit/Secret.js.map +1 -1
- package/dist/kit/Skeleton.js +14 -14
- package/dist/kit/Skeleton.js.map +1 -1
- package/dist/kit/Sparkline.js +51 -51
- package/dist/kit/Sparkline.js.map +1 -1
- package/dist/kit/Spectrum.js +163 -163
- package/dist/kit/Spectrum.js.map +1 -1
- package/dist/kit/Splash.js +3 -3
- package/dist/kit/Splash.js.map +1 -1
- package/dist/kit/Split.js +13 -13
- package/dist/kit/Split.js.map +1 -1
- package/dist/kit/SplitButton.d.ts.map +1 -1
- package/dist/kit/SplitButton.js +8 -6
- package/dist/kit/SplitButton.js.map +1 -1
- package/dist/kit/Stat.d.ts.map +1 -1
- package/dist/kit/Stat.js +74 -60
- package/dist/kit/Stat.js.map +1 -1
- package/dist/kit/Stepper.js +22 -22
- package/dist/kit/Stepper.js.map +1 -1
- package/dist/kit/TabStrip.js +68 -68
- package/dist/kit/TabStrip.js.map +1 -1
- package/dist/kit/Text.js +63 -63
- package/dist/kit/Text.js.map +1 -1
- package/dist/kit/Toast.js +29 -29
- package/dist/kit/Toast.js.map +1 -1
- package/dist/kit/Tooltip.js +83 -83
- package/dist/kit/Tooltip.js.map +1 -1
- package/dist/kit/Trace.js +33 -33
- package/dist/kit/Trace.js.map +1 -1
- package/dist/kit/Upload.js +88 -88
- package/dist/kit/Upload.js.map +1 -1
- package/dist/kit/identity.d.ts +8 -1
- package/dist/kit/identity.d.ts.map +1 -1
- package/dist/kit/identity.js +9 -2
- package/dist/kit/identity.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +17 -1
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +40 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/ThemeScope.d.ts +9 -1
- package/dist/theme/ThemeScope.d.ts.map +1 -1
- package/dist/theme/ThemeScope.js +11 -4
- package/dist/theme/ThemeScope.js.map +1 -1
- package/dist/theme/tokens.d.ts +63 -0
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +189 -3
- package/dist/theme/tokens.js.map +1 -1
- package/package.json +8 -2
- package/scripts/stable-styled-ids.mjs +75 -0
package/dist/kit/ChartTypes.js
CHANGED
|
@@ -7,45 +7,45 @@ import { fmtCount } from "./Facet.js";
|
|
|
7
7
|
import { Tooltip } from "./Tooltip.js";
|
|
8
8
|
import { Sparkline } from "./Sparkline.js";
|
|
9
9
|
import { LegendNote } from "./ChartFrame.js";
|
|
10
|
-
import { CHART_SIZES, TONE_COLOUR, niceTicks, percentileToken, spaced, timeDetail, timeTicks, useChartSize
|
|
10
|
+
import { CHART_SIZES, TONE_COLOUR, niceTicks, percentileToken, spaced, timeDetail, timeTicks, useChartSize } from "./chartScale.js";
|
|
11
11
|
// The chart types that are not a line over time (board 33): a value
|
|
12
12
|
// distribution, a ranked list, a heatmap, a single value and a state timeline.
|
|
13
13
|
// Each shares the anatomy — the frame's title row and states, the sizes, the
|
|
14
14
|
// ramp and the tones — and each has one job.
|
|
15
15
|
/** Measures an element's width for a chart drawn at its real size; 600 where there is no ResizeObserver. */
|
|
16
16
|
function useWidth(dep) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const [width, setWidth] = useState(600);
|
|
19
|
+
useLayoutEffect(() => {
|
|
20
|
+
const el = ref.current;
|
|
21
|
+
if (!el || typeof ResizeObserver === "undefined")
|
|
22
|
+
return;
|
|
23
|
+
const measure = () => {const w = el.getBoundingClientRect().width;if (w > 0)
|
|
24
|
+
setWidth(Math.max(120, Math.round(w)));};
|
|
25
|
+
measure();
|
|
26
|
+
const ro = new ResizeObserver(measure);
|
|
27
|
+
ro.observe(el);
|
|
28
|
+
return () => ro.disconnect();
|
|
29
|
+
}, [dep]);
|
|
30
|
+
return [ref, width];
|
|
31
31
|
}
|
|
32
|
-
const Box = styled.div `position: relative; min-width: 0;`;
|
|
33
|
-
const Svg = styled.svg `
|
|
32
|
+
const Box = styled.div.withConfig({ componentId: "sc-okcwj3-0" })`position: relative; min-width: 0;`;
|
|
33
|
+
const Svg = styled.svg.withConfig({ componentId: "sc-okcwj3-1" })`
|
|
34
34
|
display: block; width: 100%; overflow: visible; user-select: none;
|
|
35
35
|
text { font-family: ${v.mono}; font-variant-numeric: tabular-nums; }
|
|
36
36
|
&:focus { outline: none; }
|
|
37
|
-
&:focus-visible { outline: 2px solid ${v.brand55}; outline-offset: 2px; border-radius: 4px; }
|
|
37
|
+
&:focus-visible { outline: 2px solid ${v.brand55}; outline-offset: 2px; border-radius: min(4px, ${v.rCtl}); }
|
|
38
38
|
`;
|
|
39
|
-
const Empty = styled.div `
|
|
39
|
+
const Empty = styled.div.withConfig({ componentId: "sc-okcwj3-2" })`
|
|
40
40
|
height: ${(p) => p.$h}px; display: grid; place-items: center; color: ${v.faint}; font-size: 12px;
|
|
41
41
|
`;
|
|
42
|
-
const Readout = styled.div `
|
|
42
|
+
const Readout = styled.div.withConfig({ componentId: "sc-okcwj3-3" })`
|
|
43
43
|
position: absolute; top: 4px; pointer-events: none; z-index: ${v.zPop};
|
|
44
|
-
padding: 5px 8px; border: 1px solid ${v.line2}; border-radius: 8px; background: ${v.surface2}; box-shadow: ${v.elev};
|
|
44
|
+
padding: 5px 8px; border: 1px solid ${v.line2}; border-radius: min(8px, ${v.rCtl}); background: ${v.surface2}; box-shadow: ${v.elev};
|
|
45
45
|
font-family: ${v.mono}; font-size: 11px; color: ${v.text}; white-space: nowrap;
|
|
46
46
|
.d { color: ${v.faint}; }
|
|
47
47
|
`;
|
|
48
|
-
const Notes = styled.div `display: flex; flex-wrap: wrap; gap: 2px 4px; padding-top: 4px;`;
|
|
48
|
+
const Notes = styled.div.withConfig({ componentId: "sc-okcwj3-4" })`display: flex; flex-wrap: wrap; gap: 2px 4px; padding-top: 4px;`;
|
|
49
49
|
/**
|
|
50
50
|
* DistributionChart: a histogram of values (latency over a window) with the
|
|
51
51
|
* percentiles marked — p50 light to p99 hot. The point of this shape over
|
|
@@ -58,123 +58,123 @@ const Notes = styled.div `display: flex; flex-wrap: wrap; gap: 2px 4px; padding-
|
|
|
58
58
|
* percentile lines are placed within their bucket on the same scale. A click
|
|
59
59
|
* on a bar is `onBucketClick` (its traces); a drag is `onSelectRange`.
|
|
60
60
|
*/
|
|
61
|
-
export function DistributionChart({ buckets, percentiles = [], formatValue = (n) => String(Number(n.toPrecision(3))), formatCount = fmtCount, size: sizeProp, height, label = "Distribution", empty = "No observations in this window.", onBucketClick, onSelectRange, legend, testId
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
}
|
|
61
|
+
export function DistributionChart({ buckets, percentiles = [], formatValue = (n) => String(Number(n.toPrecision(3))), formatCount = fmtCount, size: sizeProp, height, label = "Distribution", empty = "No observations in this window.", onBucketClick, onSelectRange, legend, testId }) {
|
|
62
|
+
const size = useChartSize(sizeProp);
|
|
63
|
+
const spec = CHART_SIZES[size];
|
|
64
|
+
const H = height ?? spec.height;
|
|
65
|
+
const axes = spec.yTicks > 0;
|
|
66
|
+
const [ref, width] = useWidth(buckets.length > 0);
|
|
67
|
+
const [hover, setHover] = useState(null);
|
|
68
|
+
const [drag, setDrag] = useState(null);
|
|
69
|
+
const downX = useRef(null);
|
|
70
|
+
if (buckets.length === 0)
|
|
71
|
+
return _jsx(Box, { ref: ref, "data-testid": testId, children: _jsx(Empty, { "$h": H, children: empty }) });
|
|
72
|
+
const n = buckets.length;
|
|
73
|
+
const maxCount = Math.max(1, ...buckets.map((b) => b.count));
|
|
74
|
+
const yt = axes ? niceTicks(0, maxCount, Math.max(2, spec.yTicks - 1)) : { ticks: [0, maxCount], max: maxCount, min: 0 };
|
|
75
|
+
const yLabels = yt.ticks.map((t) => formatCount(t));
|
|
76
|
+
const padL = axes ? Math.max(26, Math.ceil(Math.max(...yLabels.map((s) => s.length)) * 6.2) + 10) : 0;
|
|
77
|
+
const padR = axes ? 10 : 0;
|
|
78
|
+
const padT = axes ? 16 : 2;
|
|
79
|
+
const padB = axes ? 20 : 2;
|
|
80
|
+
const plotW = Math.max(10, width - padL - padR);
|
|
81
|
+
const plotH = Math.max(10, H - padT - padB);
|
|
82
|
+
const bottom = padT + plotH;
|
|
83
|
+
const bw = plotW / n;
|
|
84
|
+
const y = (c) => bottom - c / yt.max * plotH;
|
|
85
|
+
// A value's place on the bucket axis: its bucket, then within it (log when both bounds are positive).
|
|
86
|
+
const pos = (val) => {
|
|
87
|
+
let i = buckets.findIndex((b) => val <= b.upper);
|
|
88
|
+
if (i < 0)
|
|
89
|
+
i = n - 1;
|
|
90
|
+
const b = buckets[i];
|
|
91
|
+
const within = b.upper <= b.lower ? 0 :
|
|
92
|
+
b.lower > 0 ? (Math.log(Math.max(val, b.lower)) - Math.log(b.lower)) / (Math.log(b.upper) - Math.log(b.lower)) :
|
|
93
|
+
(val - b.lower) / (b.upper - b.lower);
|
|
94
|
+
return padL + (i + Math.min(1, Math.max(0, within))) * bw;
|
|
95
|
+
};
|
|
96
|
+
const valueAt = (px) => {
|
|
97
|
+
const i = Math.min(n - 1, Math.max(0, Math.floor((px - padL) / bw)));
|
|
98
|
+
const b = buckets[i];
|
|
99
|
+
const within = Math.min(1, Math.max(0, (px - padL) / bw - i));
|
|
100
|
+
return b.lower > 0 ? Math.exp(Math.log(b.lower) + within * (Math.log(b.upper) - Math.log(b.lower))) : b.lower + within * (b.upper - b.lower);
|
|
101
|
+
};
|
|
102
|
+
const lo = buckets[0].lower;
|
|
103
|
+
const hi = buckets[n - 1].upper;
|
|
104
|
+
// Ticks at 1 · 3 × 10ⁿ on a positive axis — from the first positive bound
|
|
105
|
+
// when the first bucket starts at zero — spaced so their labels never touch.
|
|
106
|
+
const xTicks = [];
|
|
107
|
+
const firstPositive = lo > 0 ? lo : buckets.find((b) => b.upper > 0)?.upper ?? 0;
|
|
108
|
+
const geometric = hi > 0 && firstPositive > 0 && hi / firstPositive >= 20;
|
|
109
|
+
if (axes) {
|
|
110
|
+
if (geometric) {
|
|
111
|
+
if (lo <= 0)
|
|
112
|
+
xTicks.push(lo);
|
|
113
|
+
for (let e = Math.floor(Math.log10(firstPositive)); e <= Math.ceil(Math.log10(hi)); e++) {
|
|
114
|
+
for (const m of [1, 3]) {
|
|
115
|
+
const t = m * 10 ** e;
|
|
116
|
+
if (t >= firstPositive && t <= hi)
|
|
117
|
+
xTicks.push(t);
|
|
120
118
|
}
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
}
|
|
120
|
+
} else
|
|
121
|
+
|
|
122
|
+
xTicks.push(...niceTicks(lo, hi, 5).ticks.filter((t) => t >= lo && t <= hi));
|
|
123
|
+
}
|
|
124
|
+
const tickPx = xTicks.map((t) => pos(t));
|
|
125
|
+
const keepTick = spaced(tickPx, xTicks.map((t) => formatValue(t).length * 6.2 + 12));
|
|
126
|
+
const xMarks = xTicks.map((t, i) => ({ t, px: tickPx[i] })).filter((_m, i) => keepTick[i]);
|
|
127
|
+
const byValue = [...percentiles].sort((a, b) => a.value - b.value);
|
|
128
|
+
const markPx = byValue.map((p) => pos(p.value));
|
|
129
|
+
const markLabel = (p) => `p${p.p} ${formatValue(p.value)}`;
|
|
130
|
+
const keepMark = spaced(markPx, byValue.map((p) => markLabel(p).length * 6.2 + 8));
|
|
131
|
+
const marks = byValue.map((p, i) => ({ ...p, px: markPx[i], show: keepMark[i] }));
|
|
132
|
+
const toLocal = (clientX, el) => {
|
|
133
|
+
const r = el.getBoundingClientRect();
|
|
134
|
+
return (clientX - r.left) / Math.max(1, r.width) * width;
|
|
135
|
+
};
|
|
136
|
+
const idxOf = (px) => Math.min(n - 1, Math.max(0, Math.floor((px - padL) / bw)));
|
|
137
|
+
const interactive = !!onBucketClick || !!onSelectRange;
|
|
138
|
+
const handlers = {
|
|
139
|
+
onPointerMove: (e) => {
|
|
140
|
+
const px = toLocal(e.clientX, e.currentTarget);
|
|
141
|
+
setHover(px >= padL && px <= padL + plotW ? idxOf(px) : null);
|
|
142
|
+
if (drag)
|
|
143
|
+
setDrag({ from: drag.from, to: px });
|
|
144
|
+
},
|
|
145
|
+
onPointerLeave: () => {setHover(null);setDrag(null);},
|
|
146
|
+
onPointerDown: (e) => {
|
|
147
|
+
const px = toLocal(e.clientX, e.currentTarget);
|
|
148
|
+
downX.current = px;
|
|
149
|
+
if (onSelectRange)
|
|
150
|
+
setDrag({ from: px, to: px });
|
|
151
|
+
},
|
|
152
|
+
onPointerUp: (e) => {
|
|
153
|
+
const px = toLocal(e.clientX, e.currentTarget);
|
|
154
|
+
const start = downX.current;
|
|
155
|
+
downX.current = null;
|
|
156
|
+
setDrag(null);
|
|
157
|
+
if (onSelectRange && start !== null && Math.abs(px - start) > 6) {
|
|
158
|
+
const [a, b] = [start, px].sort((p, q) => p - q);
|
|
159
|
+
onSelectRange(valueAt(a), valueAt(b));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (onBucketClick && start !== null) {
|
|
163
|
+
const i = idxOf(px);
|
|
164
|
+
onBucketClick(buckets[i], i);
|
|
165
|
+
}
|
|
123
166
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const marks = byValue.map((p, i) => ({ ...p, px: markPx[i], show: keepMark[i] }));
|
|
132
|
-
const toLocal = (clientX, el) => {
|
|
133
|
-
const r = el.getBoundingClientRect();
|
|
134
|
-
return ((clientX - r.left) / Math.max(1, r.width)) * width;
|
|
135
|
-
};
|
|
136
|
-
const idxOf = (px) => Math.min(n - 1, Math.max(0, Math.floor((px - padL) / bw)));
|
|
137
|
-
const interactive = !!onBucketClick || !!onSelectRange;
|
|
138
|
-
const handlers = {
|
|
139
|
-
onPointerMove: (e) => {
|
|
140
|
-
const px = toLocal(e.clientX, e.currentTarget);
|
|
141
|
-
setHover(px >= padL && px <= padL + plotW ? idxOf(px) : null);
|
|
142
|
-
if (drag)
|
|
143
|
-
setDrag({ from: drag.from, to: px });
|
|
144
|
-
},
|
|
145
|
-
onPointerLeave: () => { setHover(null); setDrag(null); },
|
|
146
|
-
onPointerDown: (e) => {
|
|
147
|
-
const px = toLocal(e.clientX, e.currentTarget);
|
|
148
|
-
downX.current = px;
|
|
149
|
-
if (onSelectRange)
|
|
150
|
-
setDrag({ from: px, to: px });
|
|
151
|
-
},
|
|
152
|
-
onPointerUp: (e) => {
|
|
153
|
-
const px = toLocal(e.clientX, e.currentTarget);
|
|
154
|
-
const start = downX.current;
|
|
155
|
-
downX.current = null;
|
|
156
|
-
setDrag(null);
|
|
157
|
-
if (onSelectRange && start !== null && Math.abs(px - start) > 6) {
|
|
158
|
-
const [a, b] = [start, px].sort((p, q) => p - q);
|
|
159
|
-
onSelectRange(valueAt(a), valueAt(b));
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (onBucketClick && start !== null) {
|
|
163
|
-
const i = idxOf(px);
|
|
164
|
-
onBucketClick(buckets[i], i);
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
const hb = hover !== null ? buckets[hover] : undefined;
|
|
169
|
-
const showLegend = (legend ?? spec.legend) && marks.length > 0;
|
|
170
|
-
return (_jsxs(Box, { "data-testid": testId, children: [_jsxs("div", { ref: ref, style: { position: "relative" }, children: [_jsxs(Svg, { width: "100%", height: H, viewBox: `0 0 ${width} ${H}`, preserveAspectRatio: "none", role: "img", "aria-label": label, style: { cursor: interactive ? "pointer" : "default" }, ...handlers, children: [axes ? yt.ticks.map((t, i) => (_jsxs("g", { children: [t > 0 ? _jsx("line", { x1: padL, x2: padL + plotW, y1: y(t), y2: y(t), stroke: v.line }) : null, _jsx("text", { x: padL - 6, y: y(t) + 3.5, textAnchor: "end", fontSize: 10, fill: v.faint, children: yLabels[i] })] }, `y${t}`))) : null, buckets.map((b, i) => {
|
|
171
|
-
const h = b.count > 0 ? Math.max(1.5, bottom - y(b.count)) : 0;
|
|
172
|
-
return (_jsx("rect", { x: padL + i * bw + 0.5, y: bottom - h, width: Math.max(0.5, bw - 1), height: h, fill: v.chartInfo, opacity: hover === i ? 1 : 0.7, "data-testid": testId ? `${testId}-bar` : undefined, children: _jsx("title", { children: `${formatValue(b.lower)} – ${formatValue(b.upper)}: ${formatCount(b.count)}` }) }, i));
|
|
173
|
-
}), axes ? _jsx("line", { x1: padL, x2: padL + plotW, y1: bottom, y2: bottom, stroke: v.line2 }) : null, xMarks.map((m) => (_jsx("text", { x: m.px, y: H - 5, fontSize: 10, fill: v.faint, textAnchor: m.px - padL < 16 ? "start" : "middle", children: formatValue(m.t) }, m.t))), marks.map((m) => (_jsxs("g", { children: [_jsx("line", { x1: m.px, x2: m.px, y1: padT, y2: bottom, stroke: percentileToken(m.p), strokeDasharray: "4 3" }), m.show && axes ? _jsx("text", { x: m.px + 3, y: padT - 4, fontSize: 10, fill: percentileToken(m.p), children: markLabel(m) }) : null] }, m.p))), drag && Math.abs(drag.to - drag.from) > 2 ? (_jsx("rect", { x: Math.min(drag.from, drag.to), width: Math.abs(drag.to - drag.from), y: padT, height: plotH, fill: v.brand16, stroke: v.brand55 })) : null] }), hb && !drag && size !== "s" ? (_jsxs(Readout, { style: hover > n / 2 ? { right: width - (padL + hover * bw) + 6 } : { left: padL + (hover + 1) * bw + 6 }, children: [formatValue(hb.lower), " \u2013 ", formatValue(hb.upper), " ", _jsx("span", { className: "d", children: "\u00B7" }), " ", formatCount(hb.count), onBucketClick ? _jsx("span", { className: "d", children: " \u00B7 click for its traces" }) : null] })) : null] }), showLegend ? (_jsx(Notes, { "aria-label": "Percentiles", children: marks.map((m) => _jsx(LegendNote, { colour: percentileToken(m.p), dashed: true, children: `p${m.p} ${formatValue(m.value)}` }, m.p)) })) : null] }));
|
|
167
|
+
};
|
|
168
|
+
const hb = hover !== null ? buckets[hover] : undefined;
|
|
169
|
+
const showLegend = (legend ?? spec.legend) && marks.length > 0;
|
|
170
|
+
return _jsxs(Box, { "data-testid": testId, children: [_jsxs("div", { ref: ref, style: { position: "relative" }, children: [_jsxs(Svg, { width: "100%", height: H, viewBox: `0 0 ${width} ${H}`, preserveAspectRatio: "none", role: "img", "aria-label": label, style: { cursor: interactive ? "pointer" : "default" }, ...handlers, children: [axes ? yt.ticks.map((t, i) => _jsxs("g", { children: [t > 0 ? _jsx("line", { x1: padL, x2: padL + plotW, y1: y(t), y2: y(t), stroke: v.line }) : null, _jsx("text", { x: padL - 6, y: y(t) + 3.5, textAnchor: "end", fontSize: 10, fill: v.faint, children: yLabels[i] })] }, `y${t}`)) : null, buckets.map((b, i) => {
|
|
171
|
+
const h = b.count > 0 ? Math.max(1.5, bottom - y(b.count)) : 0;
|
|
172
|
+
return _jsx("rect", { x: padL + i * bw + 0.5, y: bottom - h, width: Math.max(0.5, bw - 1), height: h, fill: v.chartInfo, opacity: hover === i ? 1 : 0.7, "data-testid": testId ? `${testId}-bar` : undefined, children: _jsx("title", { children: `${formatValue(b.lower)} – ${formatValue(b.upper)}: ${formatCount(b.count)}` }) }, i);
|
|
173
|
+
}), axes ? _jsx("line", { x1: padL, x2: padL + plotW, y1: bottom, y2: bottom, stroke: v.line2 }) : null, xMarks.map((m) => _jsx("text", { x: m.px, y: H - 5, fontSize: 10, fill: v.faint, textAnchor: m.px - padL < 16 ? "start" : "middle", children: formatValue(m.t) }, m.t)), marks.map((m) => _jsxs("g", { children: [_jsx("line", { x1: m.px, x2: m.px, y1: padT, y2: bottom, stroke: percentileToken(m.p), strokeDasharray: "4 3" }), m.show && axes ? _jsx("text", { x: m.px + 3, y: padT - 4, fontSize: 10, fill: percentileToken(m.p), children: markLabel(m) }) : null] }, m.p)), drag && Math.abs(drag.to - drag.from) > 2 ? _jsx("rect", { x: Math.min(drag.from, drag.to), width: Math.abs(drag.to - drag.from), y: padT, height: plotH, fill: v.brand16, stroke: v.brand55 }) : null] }), hb && !drag && size !== "s" ? _jsxs(Readout, { style: hover > n / 2 ? { right: width - (padL + hover * bw) + 6 } : { left: padL + (hover + 1) * bw + 6 }, children: [formatValue(hb.lower), " \u2013 ", formatValue(hb.upper), " ", _jsx("span", { className: "d", children: "\u00B7" }), " ", formatCount(hb.count), onBucketClick ? _jsx("span", { className: "d", children: " \u00B7 click for its traces" }) : null] }) : null] }), showLegend ? _jsx(Notes, { "aria-label": "Percentiles", children: marks.map((m) => _jsx(LegendNote, { colour: percentileToken(m.p), dashed: true, children: `p${m.p} ${formatValue(m.value)}` }, m.p)) }) : null] });
|
|
174
174
|
}
|
|
175
|
-
const Rows = styled.ol `list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-width: 0;`;
|
|
176
|
-
const RowItem = styled.li `min-width: 0;`;
|
|
177
|
-
const RowBody = styled.div `
|
|
175
|
+
const Rows = styled.ol.withConfig({ componentId: "sc-okcwj3-5" })`list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-width: 0;`;
|
|
176
|
+
const RowItem = styled.li.withConfig({ componentId: "sc-okcwj3-6" })`min-width: 0;`;
|
|
177
|
+
const RowBody = styled.div.withConfig({ componentId: "sc-okcwj3-7" })`
|
|
178
178
|
position: relative;
|
|
179
179
|
display: grid;
|
|
180
180
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
@@ -182,15 +182,15 @@ const RowBody = styled.div `
|
|
|
182
182
|
gap: 10px;
|
|
183
183
|
min-height: 24px;
|
|
184
184
|
padding: 3px 8px;
|
|
185
|
-
border-radius: 6px;
|
|
185
|
+
border-radius: min(6px, ${v.rCtl});
|
|
186
186
|
color: ${v.text};
|
|
187
187
|
text-decoration: none;
|
|
188
188
|
font-size: 12px;
|
|
189
|
-
cursor: ${(p) =>
|
|
190
|
-
.bar { position: absolute; inset: 2px auto 2px 0; border-radius: 5px; opacity: 0.18; pointer-events: none; }
|
|
189
|
+
cursor: ${(p) => p.$link ? "pointer" : "default"};
|
|
190
|
+
.bar { position: absolute; inset: 2px auto 2px 0; border-radius: min(5px, ${v.rCtl}); opacity: 0.18; pointer-events: none; }
|
|
191
191
|
.l { position: relative; font-family: ${v.mono}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
192
192
|
.v { position: relative; font-family: ${v.mono}; font-variant-numeric: tabular-nums; color: ${v.text}; font-weight: 600; }
|
|
193
|
-
&:hover { background: ${(p) =>
|
|
193
|
+
&:hover { background: ${(p) => p.$link ? v.hover : "transparent"}; }
|
|
194
194
|
&:focus-visible { outline: none; box-shadow: ${v.ring}; }
|
|
195
195
|
`;
|
|
196
196
|
const BUTTON_RESET = { width: "100%", border: 0, background: "none", font: "inherit", fontSize: 12, textAlign: "left" };
|
|
@@ -201,16 +201,16 @@ const BUTTON_RESET = { width: "100%", border: 0, background: "none", font: "inhe
|
|
|
201
201
|
* or `onSelect` opens the thing it ranks.
|
|
202
202
|
*/
|
|
203
203
|
export function TopList({ rows, formatValue = fmtCount, max = 10, order = "desc", label = "Top list", empty = "Nothing to rank in this window.", testId }) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
const sorted = useMemo(() => [...rows].sort((a, b) => order === "asc" ? a.value - b.value : b.value - a.value).slice(0, max), [rows, max, order]);
|
|
205
|
+
if (sorted.length === 0)
|
|
206
|
+
return _jsx(Empty, { "$h": 80, "data-testid": testId, children: empty });
|
|
207
|
+
const top = Math.max(...sorted.map((r) => Math.abs(r.value)), 1e-12);
|
|
208
|
+
return _jsx(Rows, { "aria-label": label, "data-testid": testId, children: sorted.map((r) => {
|
|
209
|
+
const inner = _jsxs(_Fragment, { children: [_jsx("span", { className: "bar", style: { width: `${Math.max(1, Math.abs(r.value) / top * 100)}%`, background: r.colour ?? (r.tone ? TONE_COLOUR[r.tone] : v.series1) } }), _jsx("span", { className: "l", title: r.title ?? (typeof r.label === "string" ? r.label : undefined), children: r.label }), _jsx("span", { className: "v", children: r.display ?? formatValue(r.value) })] });
|
|
210
|
+
return _jsx(RowItem, { children: r.to ? _jsx(RowBody, { as: Link, to: r.to, "$link": true, children: inner }) :
|
|
211
|
+
r.onSelect ? _jsx(RowBody, { as: "button", type: "button", "$link": true, onClick: r.onSelect, style: BUTTON_RESET, children: inner }) :
|
|
212
|
+
_jsx(RowBody, { "$link": false, children: inner }) }, r.key);
|
|
213
|
+
}) });
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
216
|
* Heatmap: value buckets × time, intensity = count — the shape of a latency
|
|
@@ -219,65 +219,65 @@ export function TopList({ rows, formatValue = fmtCount, max = 10, order = "desc"
|
|
|
219
219
|
* so one busy cell does not wash out the rest.
|
|
220
220
|
*/
|
|
221
221
|
export function Heatmap({ columns, bounds, formatValue = (n) => String(Number(n.toPrecision(3))), formatTime, size: sizeProp, height, label = "Heatmap", empty = "No samples in range", onCellClick, testId }) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
222
|
+
const size = useChartSize(sizeProp);
|
|
223
|
+
const spec = CHART_SIZES[size];
|
|
224
|
+
const H = height ?? spec.height;
|
|
225
|
+
const axes = spec.yTicks > 0;
|
|
226
|
+
const [ref, width] = useWidth(columns.length > 0);
|
|
227
|
+
const [hover, setHover] = useState(null);
|
|
228
|
+
const sorted = useMemo(() => [...columns].sort((a, b) => a.t - b.t), [columns]);
|
|
229
|
+
if (sorted.length === 0 || bounds.length < 2)
|
|
230
|
+
return _jsx(Box, { ref: ref, "data-testid": testId, children: _jsx(Empty, { "$h": H, children: empty }) });
|
|
231
|
+
const rowsN = bounds.length - 1;
|
|
232
|
+
const step = sorted.length > 1 ? sorted[1].t - sorted[0].t : 60_000;
|
|
233
|
+
const from = sorted[0].t;
|
|
234
|
+
const to = sorted[sorted.length - 1].t + step;
|
|
235
|
+
const maxC = Math.max(1, ...sorted.flatMap((c) => c.counts));
|
|
236
|
+
const yLabelsAll = bounds.map((b) => formatValue(b));
|
|
237
|
+
const padL = axes ? Math.max(30, Math.ceil(Math.max(...yLabelsAll.map((s) => s.length)) * 6.2) + 10) : 0;
|
|
238
|
+
const padR = axes ? 10 : 0;
|
|
239
|
+
const padT = axes ? 6 : 1;
|
|
240
|
+
const padB = axes ? 20 : 1;
|
|
241
|
+
const plotW = Math.max(10, width - padL - padR);
|
|
242
|
+
const plotH = Math.max(10, H - padT - padB);
|
|
243
|
+
const cw = plotW / sorted.length;
|
|
244
|
+
const rh = plotH / rowsN;
|
|
245
|
+
const x = (t) => padL + (t - from) / (to - from) * plotW;
|
|
246
|
+
const intensity = (c) => c <= 0 ? 0 : 0.12 + 0.88 * (Math.log1p(c) / Math.log1p(maxC));
|
|
247
|
+
// Value labels at about four bounds, bottom to top.
|
|
248
|
+
const every = Math.max(1, Math.ceil(rowsN / 4));
|
|
249
|
+
const xMarks = axes ? timeTicks(from, to, Math.min(spec.xTicks, Math.max(2, Math.floor(plotW / 70))), formatTime) : [];
|
|
250
|
+
const detail = formatTime ?? timeDetail(step);
|
|
251
|
+
const cell = hover ? { col: sorted[hover.c], r: hover.r } : null;
|
|
252
|
+
return _jsx(Box, { "data-testid": testId, children: _jsxs("div", { ref: ref, style: { position: "relative" }, children: [_jsxs(Svg, { width: "100%", height: H, viewBox: `0 0 ${width} ${H}`, preserveAspectRatio: "none", role: "img", "aria-label": label, onPointerMove: (e) => {
|
|
253
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
254
|
+
const px = (e.clientX - r.left) / Math.max(1, r.width) * width;
|
|
255
|
+
const py = (e.clientY - r.top) / Math.max(1, r.height) * H;
|
|
256
|
+
const c = Math.floor((px - padL) / cw);
|
|
257
|
+
const row = rowsN - 1 - Math.floor((py - padT) / rh);
|
|
258
|
+
setHover(c >= 0 && c < sorted.length && row >= 0 && row < rowsN ? { c, r: row } : null);
|
|
259
|
+
}, onPointerLeave: () => setHover(null), onClick: onCellClick ? () => {
|
|
260
|
+
if (!cell)
|
|
261
|
+
return;
|
|
262
|
+
onCellClick({ t: cell.col.t, lower: bounds[cell.r], upper: bounds[cell.r + 1], count: cell.col.counts[cell.r] ?? 0 });
|
|
263
|
+
} : undefined, style: { cursor: onCellClick ? "pointer" : "default" }, children: [sorted.map((col, ci) => col.counts.map((c, ri) => {
|
|
264
|
+
const a = intensity(c);
|
|
265
|
+
if (a === 0)
|
|
266
|
+
return null;
|
|
267
|
+
return _jsx("rect", { x: padL + ci * cw, y: padT + (rowsN - 1 - ri) * rh, width: Math.max(0.5, cw - 0.5), height: Math.max(0.5, rh - 0.5), fill: v.pct99, opacity: a }, `${ci}-${ri}`);
|
|
268
|
+
})), axes ? bounds.map((_b, i) => i % every === 0 ? _jsx("text", { x: padL - 6, y: padT + (rowsN - i) * rh + 3.5, textAnchor: "end", fontSize: 10, fill: v.faint, children: yLabelsAll[i] }, `y${i}`) : null) : null, axes ? _jsx("line", { x1: padL, x2: padL + plotW, y1: padT + plotH, y2: padT + plotH, stroke: v.line2 }) : null, xMarks.map((tk, i) => _jsx("text", { x: x(tk.t), y: H - 5, fontSize: 10, fill: v.faint, opacity: tk.dim ? 0.6 : 1, textAnchor: "middle", children: tk.label }, `x${i}`)), hover ? _jsx("rect", { x: padL + hover.c * cw, y: padT + (rowsN - 1 - hover.r) * rh, width: cw, height: rh, fill: "none", stroke: v.text, strokeWidth: 1 }) : null] }), cell && size !== "s" ? _jsxs(Readout, { style: hover.c > sorted.length / 2 ? { right: width - (padL + hover.c * cw) + 6 } : { left: padL + (hover.c + 1) * cw + 6 }, children: [detail(cell.col.t), " ", _jsx("span", { className: "d", children: "\u00B7" }), " ", formatValue(bounds[cell.r]), " \u2013 ", formatValue(bounds[cell.r + 1]), " ", _jsx("span", { className: "d", children: "\u00B7" }), " ", fmtCount(cell.col.counts[cell.r] ?? 0)] }) : null] }) });
|
|
269
269
|
}
|
|
270
270
|
// ---------------------------------------------------------------------------
|
|
271
271
|
// SingleValue
|
|
272
272
|
// ---------------------------------------------------------------------------
|
|
273
|
-
const SV = styled.div `
|
|
273
|
+
const SV = styled.div.withConfig({ componentId: "sc-okcwj3-8" })`
|
|
274
274
|
display: grid;
|
|
275
275
|
gap: 4px;
|
|
276
276
|
min-width: 0;
|
|
277
|
-
align-content: ${(p) =>
|
|
278
|
-
min-height: ${(p) =>
|
|
277
|
+
align-content: ${(p) => p.$size === "s" ? "start" : "center"};
|
|
278
|
+
min-height: ${(p) => p.$size === "s" ? 0 : CHART_SIZES[p.$size].height * 0.6}px;
|
|
279
279
|
.num {
|
|
280
|
-
font-size: ${(p) =>
|
|
280
|
+
font-size: ${(p) => p.$size === "s" ? 20 : p.$size === "m" ? 32 : 44}px;
|
|
281
281
|
font-weight: 650; letter-spacing: -0.02em; color: ${v.text}; line-height: 1.1;
|
|
282
282
|
font-variant-numeric: tabular-nums; white-space: nowrap;
|
|
283
283
|
}
|
|
@@ -292,21 +292,21 @@ const SV = styled.div `
|
|
|
292
292
|
* is a tile's body; at M and up it fills a widget cell.
|
|
293
293
|
*/
|
|
294
294
|
export function SingleValue({ value, unit, label, delta, points, tone, size: sizeProp, testId }) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
295
|
+
const size = useChartSize(sizeProp);
|
|
296
|
+
const [ref, width] = useWidth(null);
|
|
297
|
+
const arrow = delta?.direction === "up" ? "↑ " : delta?.direction === "down" ? "↓ " : delta?.direction === "flat" ? "→ " : "";
|
|
298
|
+
return _jsxs(SV, { "$size": size, "data-testid": testId, ref: ref, children: [_jsxs("span", { className: "num", style: tone ? { color: TONE_COLOUR[tone] } : undefined, children: [value, unit !== undefined ? _jsx("span", { className: "u", children: unit }) : null] }), label !== undefined || delta ? _jsxs("span", { className: "sub", children: [label, label !== undefined && delta ? " · " : null, delta ? _jsxs("span", { className: `d ${delta.tone ?? ""}`, children: [arrow, delta.text] }) : null] }) : null, points && points.length > 1 ? _jsx(Sparkline, { points: points, width: Math.max(60, width), height: size === "s" ? 24 : 32, tone: tone, lastDot: true, zeroBased: false }) : null] });
|
|
299
299
|
}
|
|
300
|
-
const Track = styled.div `
|
|
300
|
+
const Track = styled.div.withConfig({ componentId: "sc-okcwj3-9" })`
|
|
301
301
|
display: flex;
|
|
302
302
|
height: ${(p) => p.$h}px;
|
|
303
|
-
width: ${(p) =>
|
|
304
|
-
border-radius: 3px;
|
|
303
|
+
width: ${(p) => p.$w ? `${p.$w}px` : "100%"};
|
|
304
|
+
border-radius: min(3px, ${v.rCtl});
|
|
305
305
|
overflow: hidden;
|
|
306
306
|
background: ${v.field};
|
|
307
307
|
`;
|
|
308
|
-
const Seg = styled.div `min-width: 1px; flex: 1;`;
|
|
309
|
-
const Ticks = styled.div `
|
|
308
|
+
const Seg = styled.div.withConfig({ componentId: "sc-okcwj3-10" })`min-width: 1px; flex: 1;`;
|
|
309
|
+
const Ticks = styled.div.withConfig({ componentId: "sc-okcwj3-11" })`
|
|
310
310
|
position: relative; height: 16px; margin-top: 3px;
|
|
311
311
|
font-family: ${v.mono}; font-size: 10px; color: ${v.faint};
|
|
312
312
|
span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
|
|
@@ -319,9 +319,9 @@ const Ticks = styled.div `
|
|
|
319
319
|
* draws the time ticks under it (at L, under a chart it does not sit beside).
|
|
320
320
|
*/
|
|
321
321
|
export function StateTimeline({ segments, range, height = 10, width, label = "State over time", axis = false, formatTime, testId = "state-timeline" }) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
const span = Math.max(1, range.to - range.from);
|
|
323
|
+
const detail = formatTime ?? timeDetail(60_000);
|
|
324
|
+
const ticks = axis ? timeTicks(range.from, range.to, 6, formatTime) : [];
|
|
325
|
+
return _jsxs("div", { style: { minWidth: 0, width: width ? `${width}px` : undefined }, children: [_jsx(Track, { "$h": height, "$w": width, role: "img", "aria-label": label, "data-testid": testId, children: segments.map((s, i) => _jsx(Tooltip, { label: s.label ?? `${s.state} · ${detail(s.from)} → ${detail(s.to)}`, style: { display: "flex", width: `${Math.max(0, Math.min(s.to, range.to) - Math.max(s.from, range.from)) / span * 100}%` }, children: _jsx(Seg, { style: { background: s.colour ?? TONE_COLOUR[s.tone ?? "mut"] }, "data-state": s.state }) }, i)) }), axis ? _jsx(Ticks, { "aria-hidden": true, children: ticks.map((t) => _jsx("span", { className: t.dim ? "dim" : undefined, style: { left: `${(t.t - range.from) / span * 100}%` }, children: t.label }, t.t)) }) : null] });
|
|
326
326
|
}
|
|
327
|
-
//# sourceMappingURL=ChartTypes.js.map
|
|
327
|
+
//# sourceMappingURL=ChartTypes.js.map
|