basalt-ui 2.24.0 → 2.26.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/CHANGELOG.md +55 -0
- package/MIGRATING.md +191 -19
- package/configs/oxlint-basalt.json +1 -1
- package/configs/oxlint-plugin.js +3 -9
- package/configs/oxlint-plugin.test.ts +6 -0
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +4 -1
- package/dist/charts/CartesianChart.d.ts +2 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/ChartCard.d.ts +11 -5
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +11 -3
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +65 -7
- package/dist/charts/chart-box.module.css +50 -7
- package/dist/charts/chart-box.module.css.d.ts +2 -0
- package/dist/charts/chart-card.module.css +34 -0
- package/dist/charts/chart-card.module.css.d.ts +2 -0
- package/dist/charts/chart-legend.module.css +5 -6
- package/dist/charts/compile.d.ts +2 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +45 -1
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +42 -9
- package/dist/charts/sparkline.module.css +13 -9
- package/dist/charts/state.d.ts +3 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +15 -2
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +25 -36
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +16 -2
- package/dist/dashboard/bar-list.module.css +7 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/meter-model.d.ts +2 -0
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +99 -7
- package/dist/dashboard/meter-parts.d.ts +4 -7
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +102 -78
- package/dist/dashboard/meter.d.ts +1 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -7
- package/dist/dashboard/meter.module.css +43 -12
- package/dist/dashboard/meter.module.css.d.ts +1 -2
- package/dist/dashboard/section.d.ts +1 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.module.css +8 -7
- package/dist/dashboard/stat-card.module.css +19 -2
- package/dist/dashboard/stat-strip.d.ts +9 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +32 -6
- package/dist/dashboard/stat-strip.module.css +40 -1
- package/dist/dashboard/stat-strip.module.css.d.ts +3 -0
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.module.css +9 -0
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/src/charts/Bars.tsx +7 -2
- package/src/charts/CartesianChart.tsx +2 -0
- package/src/charts/ChartCard.tsx +30 -7
- package/src/charts/Sparkline.tsx +105 -10
- package/src/charts/chart-box.module.css +50 -7
- package/src/charts/chart-box.module.css.d.ts +2 -0
- package/src/charts/chart-card.module.css +34 -0
- package/src/charts/chart-card.module.css.d.ts +2 -0
- package/src/charts/chart-legend.module.css +5 -6
- package/src/charts/compile.ts +60 -1
- package/src/charts/legend.tsx +64 -16
- package/src/charts/sparkline.module.css +13 -9
- package/src/charts/state.tsx +33 -7
- package/src/cli/shot/detect.ts +26 -40
- package/src/dashboard/bar-list.module.css +7 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +14 -2
- package/src/dashboard/meter-model.ts +147 -12
- package/src/dashboard/meter-parts.tsx +71 -50
- package/src/dashboard/meter.module.css +43 -12
- package/src/dashboard/meter.module.css.d.ts +1 -2
- package/src/dashboard/meter.tsx +22 -9
- package/src/dashboard/section.module.css +8 -7
- package/src/dashboard/section.tsx +1 -2
- package/src/dashboard/stat-card.module.css +19 -2
- package/src/dashboard/stat-strip.module.css +40 -1
- package/src/dashboard/stat-strip.module.css.d.ts +3 -0
- package/src/dashboard/stat-strip.tsx +49 -8
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +9 -0
package/dist/charts/Sparkline.js
CHANGED
|
@@ -244,13 +244,56 @@ function meanOf(rows) {
|
|
|
244
244
|
}
|
|
245
245
|
return sum / n;
|
|
246
246
|
}
|
|
247
|
-
|
|
247
|
+
const CLEAR = 4;
|
|
248
|
+
function lineHits(pts, box) {
|
|
249
|
+
const x0 = box.left - CLEAR;
|
|
250
|
+
const x1 = box.left + box.w + CLEAR;
|
|
251
|
+
const y0 = box.top - CLEAR;
|
|
252
|
+
const y1 = box.top + box.h + CLEAR;
|
|
253
|
+
for (let i = 0; i < pts.length; i += 1) {
|
|
254
|
+
const [ax, ay] = pts[i];
|
|
255
|
+
const next = pts[i + 1];
|
|
256
|
+
if (next === void 0) return ax >= x0 && ax <= x1 && ay >= y0 && ay <= y1;
|
|
257
|
+
const [bx, by] = next;
|
|
258
|
+
if (Math.max(ax, bx) < x0 || Math.min(ax, bx) > x1) continue;
|
|
259
|
+
const yAt = (x) => bx === ax ? ay : ay + (by - ay) * (x - ax) / (bx - ax);
|
|
260
|
+
const ya = yAt(Math.max(Math.min(ax, bx), x0));
|
|
261
|
+
const yb = yAt(Math.min(Math.max(ax, bx), x1));
|
|
262
|
+
if (Math.max(ya, yb) >= y0 && Math.min(ya, yb) <= y1) return true;
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
function placeStacked(node, line, fx) {
|
|
267
|
+
const layer = node.parentElement;
|
|
268
|
+
if (!layer) return;
|
|
269
|
+
const [W, H, w, h] = [layer.clientWidth, layer.clientHeight, node.offsetWidth, node.offsetHeight];
|
|
270
|
+
if (W <= 0 || H <= 0) return;
|
|
271
|
+
const pts = line().map(([x, y]) => [x * W, y * H]);
|
|
272
|
+
const slid = fx * (W - w);
|
|
273
|
+
const room = (left) => Math.min(Math.max(left, 0), Math.max(W - w, 0));
|
|
274
|
+
const lefts = [slid, room(fx * W + CLEAR * 2), room(fx * W - CLEAR * 2 - w)];
|
|
275
|
+
const tops = [0, Math.max(H - h, 0)];
|
|
276
|
+
const fit = lefts.flatMap((left) => tops.map((top) => ({ left, top, w, h }))).find((box) => !lineHits(pts, box));
|
|
277
|
+
if (!fit) {
|
|
278
|
+
node.style.top = `${H + CLEAR}px`;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
node.style.top = `${fit.top}px`;
|
|
282
|
+
node.style.marginLeft = `${fit.left - slid}px`;
|
|
283
|
+
}
|
|
284
|
+
function fitReadout(node, line, fx) {
|
|
248
285
|
const overflows = () => node.scrollWidth > node.clientWidth;
|
|
249
286
|
node.removeAttribute("data-tight");
|
|
250
287
|
node.removeAttribute("data-stacked");
|
|
288
|
+
if (line !== null) {
|
|
289
|
+
node.style.removeProperty("top");
|
|
290
|
+
node.style.removeProperty("margin-left");
|
|
291
|
+
}
|
|
251
292
|
if (!overflows()) return;
|
|
252
293
|
node.setAttribute("data-tight", "");
|
|
253
|
-
if (overflows())
|
|
294
|
+
if (!overflows()) return;
|
|
295
|
+
node.setAttribute("data-stacked", "");
|
|
296
|
+
if (line !== null) placeStacked(node, line, fx);
|
|
254
297
|
}
|
|
255
298
|
function Sparkline(props) {
|
|
256
299
|
const {
|
|
@@ -332,15 +375,30 @@ function Sparkline(props) {
|
|
|
332
375
|
} : null;
|
|
333
376
|
const beside = at === null ? null : at.fx > 0.5 ? "left" : "right";
|
|
334
377
|
const shown = at !== null;
|
|
378
|
+
const fxRef = useRef(0);
|
|
335
379
|
useLayoutEffect(() => {
|
|
336
|
-
|
|
337
|
-
}
|
|
380
|
+
fxRef.current = at?.fx ?? 0;
|
|
381
|
+
});
|
|
382
|
+
const fitRef = useRef(() => {
|
|
383
|
+
});
|
|
384
|
+
useLayoutEffect(() => {
|
|
385
|
+
const line = hosted && mark === "line" && model !== null ? () => model.rows.flatMap(
|
|
386
|
+
(r, i) => r.v === null ? [] : [
|
|
387
|
+
[
|
|
388
|
+
(i - model.frame.x[0]) / (model.frame.x[1] - model.frame.x[0]),
|
|
389
|
+
(model.frame.y[1] - r.v) / (model.frame.y[1] - model.frame.y[0])
|
|
390
|
+
]
|
|
391
|
+
]
|
|
392
|
+
) : null;
|
|
393
|
+
fitRef.current = () => {
|
|
394
|
+
if (readoutRef.current !== null) fitReadout(readoutRef.current, line, fxRef.current);
|
|
395
|
+
};
|
|
396
|
+
fitRef.current();
|
|
397
|
+
}, [active, at?.label, at?.value, beside, hosted, mark, model]);
|
|
338
398
|
useEffect(() => {
|
|
339
399
|
const layer = readoutRef.current?.parentElement;
|
|
340
400
|
if (!shown || !layer || typeof ResizeObserver === "undefined") return;
|
|
341
|
-
const observer = new ResizeObserver(() =>
|
|
342
|
-
if (readoutRef.current !== null) fitReadout(readoutRef.current);
|
|
343
|
-
});
|
|
401
|
+
const observer = new ResizeObserver(() => fitRef.current());
|
|
344
402
|
observer.observe(layer);
|
|
345
403
|
return () => observer.disconnect();
|
|
346
404
|
}, [shown]);
|
|
@@ -93,21 +93,64 @@
|
|
|
93
93
|
min-height: inherit;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/*
|
|
97
|
+
* A pending plot in the loaded shape (`state.tsx`): an axis baseline and a few bar ghosts in a
|
|
98
|
+
* neutral tone, so a loading card reads as the chart it will be rather than a blank plate. Heights
|
|
99
|
+
* are constants, so the server HTML is the client's. 18% ink over the panel is the tone of the
|
|
100
|
+
* facts skeleton (`chart-card.module.css`).
|
|
101
|
+
*/
|
|
102
|
+
.ghost {
|
|
103
|
+
box-sizing: border-box;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: flex-end;
|
|
106
|
+
gap: 5%;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
padding: 12px 4px 0;
|
|
110
|
+
/* The axis baseline: a 1px line painted under the ghosts, not a border (the divider law inventories those). */
|
|
111
|
+
background: linear-gradient(
|
|
112
|
+
color-mix(in srgb, var(--vx-ink) 24%, var(--vx-surface-panel)),
|
|
113
|
+
color-mix(in srgb, var(--vx-ink) 24%, var(--vx-surface-panel))
|
|
114
|
+
)
|
|
115
|
+
bottom / 100% 1px no-repeat;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ghostBar {
|
|
119
|
+
flex: 1 1 0;
|
|
120
|
+
min-width: 0;
|
|
121
|
+
border-radius: 3px 3px 0 0;
|
|
122
|
+
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
123
|
+
}
|
|
124
|
+
|
|
96
125
|
/*
|
|
97
126
|
* The engine paints its tooltip rows as a grid of `.55rem | minmax(0, 1fr) | auto` with inline
|
|
98
127
|
* styles and `overflow-wrap: anywhere` on the card, so a narrow tooltip (a 390 viewport, a pointer
|
|
99
128
|
* near an edge) squeezes the name column to one character per line. The name keeps a floor and
|
|
100
|
-
* never wraps
|
|
101
|
-
* portalled out of the chart's tree, hence the global class names.
|
|
102
|
-
* engine's own values are inline.
|
|
129
|
+
* wraps at word breaks when it must; the figure never wraps and never ends in an ellipsis, it stays
|
|
130
|
+
* right-aligned. The tooltip is portalled out of the chart's tree, hence the global class names.
|
|
131
|
+
* `!important` because the engine's own values are inline.
|
|
103
132
|
*/
|
|
104
133
|
:global(.ts-chart-tooltip__row) {
|
|
105
|
-
grid-template-columns: 0.55rem minmax(6rem,
|
|
134
|
+
grid-template-columns: 0.55rem minmax(6rem, 1fr) auto !important;
|
|
106
135
|
}
|
|
107
136
|
|
|
108
137
|
:global(.ts-chart-tooltip__row > span:nth-child(2)) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
138
|
+
overflow-wrap: break-word;
|
|
139
|
+
white-space: normal;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
:global(.ts-chart-tooltip__row > span:nth-child(3)) {
|
|
112
143
|
white-space: nowrap;
|
|
113
144
|
}
|
|
145
|
+
|
|
146
|
+
/* Opaque in both schemes: `--vx-tooltip-bg` is translucent in dark and the card's footer ghosts
|
|
147
|
+
* through a tooltip that opens over it (a slotted `Bars`). The tint is layered over the elevated
|
|
148
|
+
* surface, so a consumer's `tooltipBg` and `--basalt-tooltip-surface` still colour it. The engine's
|
|
149
|
+
* own value is inline. */
|
|
150
|
+
:global(.ts-chart-tooltip) {
|
|
151
|
+
background: linear-gradient(
|
|
152
|
+
var(--basalt-tooltip-surface, var(--vx-tooltip-bg)),
|
|
153
|
+
var(--basalt-tooltip-surface, var(--vx-tooltip-bg))
|
|
154
|
+
)
|
|
155
|
+
var(--vx-surface-elevated) !important;
|
|
156
|
+
}
|
|
@@ -95,3 +95,37 @@
|
|
|
95
95
|
.factsRow[data-stale] {
|
|
96
96
|
opacity: 0.55;
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
* A pending card keeps its facts footprint: bars as tall as the loaded figure and basis lines (`1lh`
|
|
101
|
+
* at the same font size), painted a little inside the line box so they read as text, not slabs. The
|
|
102
|
+
* tone is the chart ghost's (`chart-box.module.css` `.ghost`).
|
|
103
|
+
*/
|
|
104
|
+
.skeletonFigure,
|
|
105
|
+
.skeletonBasis {
|
|
106
|
+
position: relative;
|
|
107
|
+
display: block;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.skeletonFigure {
|
|
111
|
+
font-size: var(--vx-text-kpi);
|
|
112
|
+
height: 1lh;
|
|
113
|
+
width: 4.5rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.skeletonBasis {
|
|
117
|
+
font-size: var(--vx-text-sm);
|
|
118
|
+
height: 1lh;
|
|
119
|
+
width: 9rem;
|
|
120
|
+
max-width: 100%;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.skeletonFigure::before,
|
|
124
|
+
.skeletonBasis::before {
|
|
125
|
+
content: '';
|
|
126
|
+
position: absolute;
|
|
127
|
+
inset-inline: 0;
|
|
128
|
+
inset-block: 0.2lh;
|
|
129
|
+
border-radius: 3px;
|
|
130
|
+
background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
|
|
131
|
+
}
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
@container (min-width: 240px) {
|
|
18
|
-
/*
|
|
18
|
+
/* `foldLegend` (legend.tsx) folds the zones / references that wrap the row into `+N`; series never fold. */
|
|
19
19
|
.auto {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
--bc-fold: 1;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
22
|
display: flex;
|
|
23
23
|
column-gap: var(--bc-dots-gap);
|
|
24
24
|
--vx-hit-gap: var(--bc-dots-gap);
|
|
@@ -27,8 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
@container (min-width: 480px) {
|
|
29
29
|
.auto {
|
|
30
|
-
|
|
31
|
-
overflow: visible;
|
|
30
|
+
--bc-fold: 0;
|
|
32
31
|
column-gap: var(--bc-legend-gap);
|
|
33
32
|
--vx-hit-gap: var(--bc-legend-gap);
|
|
34
33
|
}
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
/* The compact fold (`foldLegend`, which only folds while
|
|
51
|
+
/* The compact fold (`foldLegend`, which only folds while `--bc-fold` is 1); wide keeps every entry.
|
|
53
52
|
* `!important`: an entry's inline `all: unset` (legend.tsx) would otherwise reset `display`. */
|
|
54
53
|
.auto [data-legend-folded] {
|
|
55
54
|
display: none !important;
|
package/dist/charts/compile.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export type CartesianInput<T, X extends ChartX> = Pick<CartesianChartProps<T, X>
|
|
|
32
32
|
crosshair?: boolean;
|
|
33
33
|
/** The engine's point marker on the focused datum. Default `true`; a bar kind has none (its hover is the bar). */
|
|
34
34
|
focusRing?: boolean;
|
|
35
|
+
/** No axes, grid or margin: the plot is the whole box (a visual slot's bars, as `Sparkline`). */
|
|
36
|
+
bare?: boolean;
|
|
35
37
|
};
|
|
36
38
|
export declare function defaultNumberFormat(v: number): string;
|
|
37
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAGV,aAAa,EAEb,yBAAyB,EACzB,eAAe,IAAI,gBAAgB,EACnC,UAAU,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAO5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEnB,WAAW,EACX,eAAe,EACf,MAAM,EAEN,OAAO,EAEP,QAAQ,EACT,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAE/F,gGAAgG;AAChG,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,IAAI,CACpD,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,MAAM,GACN,GAAG,GACH,QAAQ,GACR,OAAO,GACP,GAAG,GACH,IAAI,GACJ,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ,GACR,UAAU,GACV,aAAa,GACb,kBAAkB,GAClB,SAAS,CACZ,GAAG;IACF,8FAA8F;IAC9F,OAAO,E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AC,SAAS,MAAM,EAClD,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,mBAAmB,CA2HrB"}
|
package/dist/charts/compile.js
CHANGED
|
@@ -492,6 +492,23 @@ const refLineMarks = (input, axes, label) => (input.refLines ?? []).flatMap(
|
|
|
492
492
|
function buildScales(opts) {
|
|
493
493
|
const { input, model, axes, formatX, cls, zoneScale } = opts;
|
|
494
494
|
const { left, right } = axes;
|
|
495
|
+
if (input.bare === true) {
|
|
496
|
+
return {
|
|
497
|
+
x: { scale: model.scale, axis: false },
|
|
498
|
+
y: { scale: yScaleFor(input.y, left.domain), axis: false },
|
|
499
|
+
// A right-axis series still needs its scale, drawn or not.
|
|
500
|
+
...right && {
|
|
501
|
+
y2: {
|
|
502
|
+
channel: "y",
|
|
503
|
+
scale: yScaleFor(input.y2, right.domain),
|
|
504
|
+
axis: false
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
...zoneScale && {
|
|
508
|
+
zx: { channel: "x", scale: scaleLinear().domain([0, 1]), axis: false }
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
}
|
|
495
512
|
return {
|
|
496
513
|
x: {
|
|
497
514
|
scale: model.scale,
|
|
@@ -601,6 +618,32 @@ const barAnchor = (rows) => (points, { plot }) => {
|
|
|
601
618
|
const stepped = x + (toRight ? TIP_SIDE_STEP : -TIP_SIDE_STEP);
|
|
602
619
|
return { x: Math.min(Math.max(stepped, plot.x), plot.x + plot.width), y: floor };
|
|
603
620
|
};
|
|
621
|
+
const TIP_CARD = "[data-basalt-chart-card], [data-strip-cell], .mantine-Card-root";
|
|
622
|
+
const TIP_CARD_AIR = 4;
|
|
623
|
+
const cardPortal = {
|
|
624
|
+
id: portal.id,
|
|
625
|
+
create(context, options) {
|
|
626
|
+
const inner = portal.create(context, options);
|
|
627
|
+
const { element, container } = context;
|
|
628
|
+
const watch = new MutationObserver(() => clampToCard(element, container));
|
|
629
|
+
watch.observe(element, { attributes: true, attributeFilter: ["style"] });
|
|
630
|
+
return {
|
|
631
|
+
...inner,
|
|
632
|
+
destroy() {
|
|
633
|
+
watch.disconnect();
|
|
634
|
+
inner.destroy();
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
function clampToCard(tip, within) {
|
|
640
|
+
const card = within.closest(TIP_CARD)?.getBoundingClientRect();
|
|
641
|
+
const left = Number.parseFloat(tip.style.left);
|
|
642
|
+
const width = tip.offsetWidth;
|
|
643
|
+
if (!card || Number.isNaN(left) || width + 2 * TIP_CARD_AIR > card.width) return;
|
|
644
|
+
const next = Math.min(Math.max(left, card.left + TIP_CARD_AIR), card.right - width - TIP_CARD_AIR);
|
|
645
|
+
if (Math.abs(next - left) > 0.5) tip.style.left = `${next}px`;
|
|
646
|
+
}
|
|
604
647
|
function tooltipSpec(opts) {
|
|
605
648
|
const { input, axes, visible, keys, visibleKeys, formatX, dayOnly } = opts;
|
|
606
649
|
const hidden = input.series.filter((s) => !visibleKeys.has(s.key));
|
|
@@ -610,7 +653,7 @@ function tooltipSpec(opts) {
|
|
|
610
653
|
return {
|
|
611
654
|
use: quietWhileFollowing,
|
|
612
655
|
...followerOptions(input.tooltip, input.cursorGroup, input.chartId),
|
|
613
|
-
portal,
|
|
656
|
+
portal: cardPortal,
|
|
614
657
|
anchor: input.tooltipBelow ? stripAnchor : visible.some((s) => s.mark === "bar") ? barAnchor(rowSeries.length) : "group-center",
|
|
615
658
|
...input.tooltipBelow && { placement: STRIP_TOOLTIP_PLACEMENT, offset: STRIP_TOOLTIP_OFFSET },
|
|
616
659
|
content: (points) => {
|
|
@@ -732,6 +775,7 @@ function compileCartesian(input) {
|
|
|
732
775
|
zoneScale: under.length > 0 || names
|
|
733
776
|
}),
|
|
734
777
|
theme: CHART_THEME,
|
|
778
|
+
...input.bare === true && { guides: false, margin: 0 },
|
|
735
779
|
...gradients.length > 0 && { gradients },
|
|
736
780
|
clip: true
|
|
737
781
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/charts/legend.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AAelD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,CAAC,EAC7B,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EACjC,MAAM,EAAE,OAAO,GACd,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAOpB;
|
|
1
|
+
{"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/charts/legend.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AAelD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,CAAC,EAC7B,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EACjC,MAAM,EAAE,OAAO,GACd,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE,CAOpB;AA+DD;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG;IAAE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAWrF;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;;CAGd,CAAA;AAuDV,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,MAAM,EAAE,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IAClC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,EAAE,OAAO,CAAA;IACf,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IACzC,kGAAkG;IAClG,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AA6ED,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,IAAI,CAuF9E"}
|
package/dist/charts/legend.js
CHANGED
|
@@ -4,10 +4,10 @@ import { VX } from "../tokens/index.js";
|
|
|
4
4
|
import classes from "./chart-legend.module.css";
|
|
5
5
|
const ROLE_ORDER = ["series", "overlay", "reference"];
|
|
6
6
|
const DOTS_GAP = 30;
|
|
7
|
-
const
|
|
7
|
+
const byReferenceLast = (a, b) => Number(a.role === "reference") - Number(b.role === "reference");
|
|
8
8
|
function legendEntries(series, groups) {
|
|
9
9
|
const entries = series.filter((s) => s.legend !== false);
|
|
10
|
-
if (!groups) return entries.length ? [entries.toSorted(
|
|
10
|
+
if (!groups) return entries.length ? [entries.toSorted(byReferenceLast)] : [];
|
|
11
11
|
return ROLE_ORDER.map((role) => entries.filter((s) => (s.role ?? "series") === role)).filter(
|
|
12
12
|
(g) => g.length > 0
|
|
13
13
|
);
|
|
@@ -54,11 +54,17 @@ const buttonStyle = {
|
|
|
54
54
|
border: "1px solid transparent",
|
|
55
55
|
display: "inline-flex",
|
|
56
56
|
alignItems: "center",
|
|
57
|
+
// An entry never wraps inside itself (a threshold stays with its name) and never outgrows the row:
|
|
58
|
+
// the label ellipsizes at the row's width (`labelStyle`), its full name in `title`.
|
|
59
|
+
whiteSpace: "nowrap",
|
|
60
|
+
maxWidth: "100%",
|
|
61
|
+
minWidth: 0,
|
|
57
62
|
gap: 6,
|
|
58
63
|
cursor: "pointer",
|
|
59
64
|
borderRadius: VX.radiusCtrl
|
|
60
65
|
};
|
|
61
|
-
const noteStyle = { color: VX.axis };
|
|
66
|
+
const noteStyle = { color: VX.axis, flex: "none" };
|
|
67
|
+
const labelStyle = { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis" };
|
|
62
68
|
const swatchFill = (s) => s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color;
|
|
63
69
|
const LINE_SWATCH = {
|
|
64
70
|
compact: { width: 14, dash: "4 3" },
|
|
@@ -124,16 +130,34 @@ const VISUALLY_HIDDEN = {
|
|
|
124
130
|
clipPath: "inset(50%)",
|
|
125
131
|
whiteSpace: "nowrap"
|
|
126
132
|
};
|
|
133
|
+
function lineCount(row, more) {
|
|
134
|
+
const shown = [...row.querySelectorAll("[data-legend-key]")].filter(
|
|
135
|
+
(it) => !it.hasAttribute("data-legend-folded")
|
|
136
|
+
);
|
|
137
|
+
if (!more.hidden) shown.push(more);
|
|
138
|
+
const centres = shown.map((it) => {
|
|
139
|
+
const r = it.getBoundingClientRect();
|
|
140
|
+
return r.top + r.height / 2;
|
|
141
|
+
}).toSorted((x, y) => x - y);
|
|
142
|
+
return centres.filter((c, i) => i === 0 || c - (centres[i - 1] ?? c) > 6).length;
|
|
143
|
+
}
|
|
127
144
|
function foldLegend(row) {
|
|
128
145
|
const items = [...row.querySelectorAll("[data-legend-key]")];
|
|
129
146
|
const more = row.querySelector("[data-legend-more]");
|
|
130
147
|
for (const it of items) it.removeAttribute("data-legend-folded");
|
|
131
148
|
more?.setAttribute("hidden", "");
|
|
132
|
-
|
|
133
|
-
|
|
149
|
+
for (const label of row.querySelectorAll("[data-legend-label]")) {
|
|
150
|
+
if (label.scrollWidth > label.clientWidth + 0.5) label.title = label.textContent ?? "";
|
|
151
|
+
else label.removeAttribute("title");
|
|
152
|
+
}
|
|
153
|
+
if (more === null || getComputedStyle(row).getPropertyValue("--bc-fold").trim() !== "1") return;
|
|
154
|
+
const references = items.filter((it) => it.dataset["legendRole"] === "reference");
|
|
155
|
+
for (const r of references) r.setAttribute("data-legend-folded", "");
|
|
156
|
+
const floor = lineCount(row, more);
|
|
157
|
+
for (const r of references) r.removeAttribute("data-legend-folded");
|
|
134
158
|
const folded = [];
|
|
135
|
-
while (
|
|
136
|
-
const last =
|
|
159
|
+
while (folded.length < references.length && lineCount(row, more) > floor) {
|
|
160
|
+
const last = references[references.length - 1 - folded.length];
|
|
137
161
|
if (last === void 0) break;
|
|
138
162
|
last.setAttribute("data-legend-folded", "");
|
|
139
163
|
folded.push(last);
|
|
@@ -146,6 +170,10 @@ function foldLegend(row) {
|
|
|
146
170
|
Object.assign(hiddenNames.style, VISUALLY_HIDDEN);
|
|
147
171
|
more.append(hiddenNames);
|
|
148
172
|
}
|
|
173
|
+
if (folded.length > 0 && lineCount(row, more) > floor) {
|
|
174
|
+
for (const f of folded) f.removeAttribute("data-legend-folded");
|
|
175
|
+
more.setAttribute("hidden", "");
|
|
176
|
+
}
|
|
149
177
|
}
|
|
150
178
|
function ChartLegend(props) {
|
|
151
179
|
const rowRef = useRef(null);
|
|
@@ -159,7 +187,12 @@ function ChartLegend(props) {
|
|
|
159
187
|
if (!auto || row === null || typeof ResizeObserver === "undefined") return;
|
|
160
188
|
const observer = new ResizeObserver(() => foldLegend(row));
|
|
161
189
|
observer.observe(row);
|
|
162
|
-
|
|
190
|
+
let live = true;
|
|
191
|
+
void document.fonts?.ready?.then(() => live && foldLegend(row));
|
|
192
|
+
return () => {
|
|
193
|
+
live = false;
|
|
194
|
+
observer.disconnect();
|
|
195
|
+
};
|
|
163
196
|
}, [auto, signature]);
|
|
164
197
|
const groups = legendEntries(props.series, props.groups);
|
|
165
198
|
if (groups.length === 0) return null;
|
|
@@ -180,7 +213,7 @@ function ChartLegend(props) {
|
|
|
180
213
|
const off = props.hidden.has(s.key);
|
|
181
214
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
182
215
|
/* @__PURE__ */ jsx(Swatch, { s, mode: props.mode }),
|
|
183
|
-
/* @__PURE__ */ jsx("span", { children: s.label }),
|
|
216
|
+
/* @__PURE__ */ jsx("span", { style: labelStyle, "data-legend-label": "", children: s.label }),
|
|
184
217
|
s.note !== void 0 && /* @__PURE__ */ jsx("span", { style: noteStyle, children: s.note })
|
|
185
218
|
] });
|
|
186
219
|
const itemStyle = { ...buttonStyle, opacity: off ? 0.4 : 1 };
|
|
@@ -31,7 +31,13 @@
|
|
|
31
31
|
text-overflow: ellipsis;
|
|
32
32
|
white-space: nowrap;
|
|
33
33
|
pointer-events: none;
|
|
34
|
-
|
|
34
|
+
/* Opaque in both schemes: `--vx-tooltip-bg` is translucent in dark, and a footer under the chip
|
|
35
|
+
* would ghost through it, so the tint is layered over the elevated surface. */
|
|
36
|
+
background: linear-gradient(
|
|
37
|
+
var(--basalt-tooltip-surface, var(--vx-tooltip-bg)),
|
|
38
|
+
var(--basalt-tooltip-surface, var(--vx-tooltip-bg))
|
|
39
|
+
)
|
|
40
|
+
var(--vx-surface-elevated);
|
|
35
41
|
border: 1px solid var(--vx-tooltip-border);
|
|
36
42
|
border-radius: var(--vx-radius-ctrl);
|
|
37
43
|
}
|
|
@@ -54,19 +60,17 @@
|
|
|
54
60
|
white-space: pre;
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
/* A readout that overflows its box first
|
|
63
|
+
/* A readout that overflows its box first shrinks its padding. The separator and the air round it
|
|
64
|
+
* never drop. */
|
|
58
65
|
.readout[data-tight] {
|
|
59
66
|
padding-inline: 2px;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
.readout[data-tight] .sep {
|
|
63
|
-
letter-spacing: -0.15em;
|
|
64
|
-
word-spacing: -0.25em;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
69
|
/* A readout that still overflows stacks (set in `Sparkline.tsx`): the date on its own line, wrapped
|
|
68
|
-
* not clipped. It sits INSIDE the plot
|
|
69
|
-
*
|
|
70
|
+
* not clipped. It sits INSIDE the plot (the lift-0 placement), hosted or bare: a hosted chip grown
|
|
71
|
+
* past the host's one reserved line would cover the figure's delta or qualifier above. A hosted
|
|
72
|
+
* line's chip is then placed by `Sparkline.tsx` where the plotted line is not (`top`/`margin-left`
|
|
73
|
+
* inline); `top: 0` is the fallback. */
|
|
70
74
|
.readout[data-stacked] {
|
|
71
75
|
block-size: auto;
|
|
72
76
|
max-height: none;
|
package/dist/charts/state.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export declare function resolveChartState(state: ChartState | undefined): Resolv
|
|
|
11
11
|
* `<Suspense>` fallback built from one) occupies the final chart's height. */
|
|
12
12
|
export declare function ChartPlaceholder(props: {
|
|
13
13
|
state: ChartState | undefined;
|
|
14
|
-
|
|
14
|
+
/** `'content'`: error and empty end at their content (a list or Meter body, no chart to keep the
|
|
15
|
+
* frame for); the chart height law and a stated height keep D37's box. Pending always keeps a box. */
|
|
16
|
+
height?: ChartBoxHeight | 'content';
|
|
15
17
|
/** Error only: the shared Retry button, the same one `ErrorState` renders. */
|
|
16
18
|
onRetry?: () => void;
|
|
17
19
|
/** A refetch is in flight: Retry is inert and marked busy. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/charts/state.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/charts/state.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,IAAI,CAAA;AAErE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,kBAAkB,CAMnF;AAoED;8EAC8E;AAC9E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;IAC7B;0GACsG;IACtG,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;IACnC,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;2DACuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,YAAY,GAAG,IAAI,CAgEtB"}
|
package/dist/charts/state.js
CHANGED
|
@@ -3,6 +3,7 @@ import { toErrorMessage } from "../common/errors.js";
|
|
|
3
3
|
import { RetryButton } from "../common/retry-button.js";
|
|
4
4
|
import { VX } from "../tokens/index.js";
|
|
5
5
|
import { ChartBox, growClass, stateClass } from "./box.js";
|
|
6
|
+
import boxClasses from "./chart-box.module.css";
|
|
6
7
|
function resolveChartState(state) {
|
|
7
8
|
if (!state) return null;
|
|
8
9
|
if (state.pending) return "pending";
|
|
@@ -25,6 +26,10 @@ const pendingStyle = {
|
|
|
25
26
|
borderRadius: VX.radiusCtrl,
|
|
26
27
|
background: `linear-gradient(90deg, transparent, ${VX.surface.subtle}, transparent)`
|
|
27
28
|
};
|
|
29
|
+
const GHOST_BARS = [38, 52, 44, 66, 58, 74, 62, 48];
|
|
30
|
+
function PlotGhost() {
|
|
31
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": "true", "data-basalt-plot-ghost": "", className: boxClasses.ghost, children: GHOST_BARS.map((h, i) => /* @__PURE__ */ jsx("span", { className: boxClasses.ghostBar, style: { height: `${h}%` } }, i)) });
|
|
32
|
+
}
|
|
28
33
|
const dotStyle = {
|
|
29
34
|
display: "inline-block",
|
|
30
35
|
flex: "none",
|
|
@@ -56,10 +61,18 @@ function ChartPlaceholder(props) {
|
|
|
56
61
|
const kind = resolveChartState(props.state);
|
|
57
62
|
if (kind === null) return null;
|
|
58
63
|
const style = kind === "pending" ? pendingStyle : kind === "error" ? errorStyle : boxStyle;
|
|
59
|
-
const
|
|
64
|
+
const { height } = props;
|
|
65
|
+
const fit = (node) => height === "content" && kind !== "pending" ? node : /* @__PURE__ */ jsx(
|
|
66
|
+
ChartBox,
|
|
67
|
+
{
|
|
68
|
+
height: height === "content" ? void 0 : height,
|
|
69
|
+
...kind === "error" && { className: growClass },
|
|
70
|
+
children: node
|
|
71
|
+
}
|
|
72
|
+
);
|
|
60
73
|
if (kind === "pending")
|
|
61
74
|
return fit(
|
|
62
|
-
/* @__PURE__ */ jsx("output", { "aria-label": "Loading chart", "aria-busy": "true", className: stateClass, style })
|
|
75
|
+
/* @__PURE__ */ jsx("output", { "aria-label": "Loading chart", "aria-busy": "true", className: stateClass, style, children: !props.compact && /* @__PURE__ */ jsx(PlotGhost, {}) })
|
|
63
76
|
);
|
|
64
77
|
const label = kind === "error" ? toErrorMessage(props.state?.error, "The request failed.") : emptyLabel(props.state);
|
|
65
78
|
const body = props.compact ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2014" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/detect.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAwB,WAAW,EAAS,MAAM,SAAS,CAAA;AAEvE,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,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