basalt-ui 2.25.0 → 2.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/MIGRATING.md +227 -19
  3. package/configs/oxlint-basalt.json +1 -1
  4. package/configs/oxlint-plugin.js +3 -9
  5. package/configs/oxlint-plugin.test.ts +6 -0
  6. package/dist/charts/Bars.d.ts.map +1 -1
  7. package/dist/charts/Bars.js +37 -1
  8. package/dist/charts/ChartCard.d.ts +13 -5
  9. package/dist/charts/ChartCard.d.ts.map +1 -1
  10. package/dist/charts/ChartCard.js +12 -2
  11. package/dist/charts/Sparkline.d.ts.map +1 -1
  12. package/dist/charts/Sparkline.js +106 -10
  13. package/dist/charts/chart-box.module.css +123 -5
  14. package/dist/charts/chart-box.module.css.d.ts +3 -0
  15. package/dist/charts/chart-card.module.css +34 -0
  16. package/dist/charts/chart-card.module.css.d.ts +2 -0
  17. package/dist/charts/chart-legend.module.css +1 -16
  18. package/dist/charts/compile.d.ts +20 -0
  19. package/dist/charts/compile.d.ts.map +1 -1
  20. package/dist/charts/compile.js +99 -3
  21. package/dist/charts/legend.d.ts.map +1 -1
  22. package/dist/charts/legend.js +54 -71
  23. package/dist/charts/sparkline.module.css +13 -9
  24. package/dist/charts/state.d.ts +7 -0
  25. package/dist/charts/state.d.ts.map +1 -1
  26. package/dist/charts/state.js +17 -1
  27. package/dist/cli/shot/capture.d.ts +32 -3
  28. package/dist/cli/shot/capture.d.ts.map +1 -1
  29. package/dist/cli/shot/capture.js +17 -7
  30. package/dist/dashboard/meter-model.d.ts +19 -3
  31. package/dist/dashboard/meter-model.d.ts.map +1 -1
  32. package/dist/dashboard/meter-model.js +155 -13
  33. package/dist/dashboard/meter-parts.d.ts +4 -7
  34. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  35. package/dist/dashboard/meter-parts.js +130 -90
  36. package/dist/dashboard/meter.d.ts +1 -1
  37. package/dist/dashboard/meter.d.ts.map +1 -1
  38. package/dist/dashboard/meter.js +10 -7
  39. package/dist/dashboard/meter.module.css +55 -13
  40. package/dist/dashboard/meter.module.css.d.ts +1 -2
  41. package/dist/dashboard/section.d.ts +1 -2
  42. package/dist/dashboard/section.d.ts.map +1 -1
  43. package/dist/dashboard/section.module.css +8 -7
  44. package/dist/dashboard/stat-card.module.css +17 -0
  45. package/dist/dashboard/stat-strip.d.ts +9 -1
  46. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  47. package/dist/dashboard/stat-strip.js +121 -27
  48. package/dist/dashboard/stat-strip.module.css +51 -3
  49. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  50. package/dist/dashboard/visual-slot.d.ts +4 -0
  51. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  52. package/dist/dashboard/visual-slot.js +2 -0
  53. package/dist/dashboard/widget-header.module.css +9 -0
  54. package/llms.txt +3 -2
  55. package/package.json +1 -1
  56. package/src/charts/Bars.tsx +50 -2
  57. package/src/charts/ChartCard.tsx +32 -5
  58. package/src/charts/Sparkline.tsx +166 -13
  59. package/src/charts/chart-box.module.css +123 -5
  60. package/src/charts/chart-box.module.css.d.ts +3 -0
  61. package/src/charts/chart-card.module.css +34 -0
  62. package/src/charts/chart-card.module.css.d.ts +2 -0
  63. package/src/charts/chart-legend.module.css +1 -16
  64. package/src/charts/compile.ts +153 -3
  65. package/src/charts/legend.tsx +33 -49
  66. package/src/charts/sparkline.module.css +13 -9
  67. package/src/charts/state.tsx +43 -1
  68. package/src/cli/shot/capture.ts +25 -9
  69. package/src/dashboard/meter-model.ts +248 -22
  70. package/src/dashboard/meter-parts.tsx +124 -69
  71. package/src/dashboard/meter.module.css +55 -13
  72. package/src/dashboard/meter.module.css.d.ts +1 -2
  73. package/src/dashboard/meter.tsx +22 -9
  74. package/src/dashboard/section.module.css +8 -7
  75. package/src/dashboard/section.tsx +1 -2
  76. package/src/dashboard/stat-card.module.css +17 -0
  77. package/src/dashboard/stat-strip.module.css +51 -3
  78. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  79. package/src/dashboard/stat-strip.tsx +162 -33
  80. package/src/dashboard/visual-slot.ts +5 -0
  81. package/src/dashboard/widget-header.module.css +9 -0
@@ -100,6 +100,12 @@ function Facts({
100
100
  basis !== void 0 && /* @__PURE__ */ jsx("p", { "data-basalt-facts-basis": "", className: classes.factsBasis, children: basis })
101
101
  ] });
102
102
  }
103
+ function FactsSkeleton({ basis }) {
104
+ return /* @__PURE__ */ jsxs("div", { "data-basalt-facts-skeleton": "", "aria-hidden": "true", className: classes.facts, children: [
105
+ /* @__PURE__ */ jsx("div", { className: classes.factsRow, children: /* @__PURE__ */ jsx("span", { className: classes.skeletonFigure }) }),
106
+ basis && /* @__PURE__ */ jsx("p", { className: cx(classes.factsBasis, classes.skeletonBasis) })
107
+ ] });
108
+ }
103
109
  function ChartCard({
104
110
  actions,
105
111
  state,
@@ -107,6 +113,7 @@ function ChartCard({
107
113
  stateAction,
108
114
  stale,
109
115
  stateNoun,
116
+ ghost,
110
117
  onRetry,
111
118
  retrying,
112
119
  className,
@@ -119,7 +126,8 @@ function ChartCard({
119
126
  const { ref, short } = useShortCard();
120
127
  const resolved = resolveChartState(state);
121
128
  const showFacts = facts !== void 0 && resolved === null;
122
- const hasHeader = actions !== void 0 || showFacts || HEADER_TRIGGERS.some((k) => header[k] !== void 0);
129
+ const skeletonFacts = facts !== void 0 && resolved === "pending";
130
+ const hasHeader = actions !== void 0 || showFacts || skeletonFacts || HEADER_TRIGGERS.some((k) => header[k] !== void 0);
123
131
  const { subtitle, ...rest } = header;
124
132
  const headerProps = facts === void 0 ? header : rest;
125
133
  return /* @__PURE__ */ jsx(ChartCardContext.Provider, { value: true, children: /* @__PURE__ */ jsxs(
@@ -144,7 +152,8 @@ function ChartCard({
144
152
  }
145
153
  }
146
154
  ),
147
- showFacts && /* @__PURE__ */ jsx(Facts, { facts, basis: subtitle, stale })
155
+ showFacts && /* @__PURE__ */ jsx(Facts, { facts, basis: subtitle, stale }),
156
+ skeletonFacts && /* @__PURE__ */ jsx(FactsSkeleton, { basis: subtitle !== void 0 })
148
157
  ] }),
149
158
  /* @__PURE__ */ jsx(
150
159
  "div",
@@ -157,6 +166,7 @@ function ChartCard({
157
166
  state,
158
167
  ...placeholderHeight !== void 0 && { height: placeholderHeight },
159
168
  ...stateNoun !== void 0 && { noun: stateNoun },
169
+ ...ghost !== void 0 && { ghost },
160
170
  ...onRetry !== void 0 && { onRetry },
161
171
  ...retrying !== void 0 && { retrying },
162
172
  action: stateAction
@@ -1 +1 @@
1
- {"version":3,"file":"Sparkline.d.ts","sourceRoot":"","sources":["../../src/charts/Sparkline.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAA0D,YAAY,EAAE,MAAM,OAAO,CAAA;AAEjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAclD,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAA;IACjB;yFACqF;IACrF,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS;QAAE,EAAE,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAClF,oBAAoB;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAAA;IACjC,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,4FAA4F;IAC5F,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B;uDACmD;IACnD,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAA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}
@@ -25,6 +25,7 @@ const DOT_R = 2.5;
25
25
  const BAR_GAP = 0.15;
26
26
  const READOUT_GAP = 8;
27
27
  const LINE_INSET = 3;
28
+ const SHORT_BOX = 36;
28
29
  const MUTED_LINE = alpha(VX.muted, 0.35);
29
30
  const REFERENCE_LABEL_DX = 3;
30
31
  const LINE_PX_PER_POINT = 1;
@@ -244,13 +245,92 @@ function meanOf(rows) {
244
245
  }
245
246
  return sum / n;
246
247
  }
247
- function fitReadout(node) {
248
+ const CLEAR = 4;
249
+ function lineHits(pts, box) {
250
+ const x0 = box.left - CLEAR;
251
+ const x1 = box.left + box.w + CLEAR;
252
+ const y0 = box.top - CLEAR;
253
+ const y1 = box.top + box.h + CLEAR;
254
+ for (let i = 0; i < pts.length; i += 1) {
255
+ const [ax, ay] = pts[i];
256
+ const next = pts[i + 1];
257
+ if (next === void 0) return ax >= x0 && ax <= x1 && ay >= y0 && ay <= y1;
258
+ const [bx, by] = next;
259
+ if (Math.max(ax, bx) < x0 || Math.min(ax, bx) > x1) continue;
260
+ const yAt = (x) => bx === ax ? ay : ay + (by - ay) * (x - ax) / (bx - ax);
261
+ const ya = yAt(Math.max(Math.min(ax, bx), x0));
262
+ const yb = yAt(Math.min(Math.max(ax, bx), x1));
263
+ if (Math.max(ya, yb) >= y0 && Math.min(ya, yb) <= y1) return true;
264
+ }
265
+ return false;
266
+ }
267
+ function placeStacked(node, line, fx) {
268
+ const layer = node.parentElement;
269
+ if (!layer) return;
270
+ const [W, H, w, h] = [layer.clientWidth, layer.clientHeight, node.offsetWidth, node.offsetHeight];
271
+ if (W <= 0 || H <= 0) return;
272
+ const pts = line().map(([x, y]) => [x * W, y * H]);
273
+ const slid = fx * (W - w);
274
+ const room = (left) => Math.min(Math.max(left, 0), Math.max(W - w, 0));
275
+ const lefts = [slid, room(fx * W + CLEAR * 2), room(fx * W - CLEAR * 2 - w)];
276
+ const tops = [0, Math.max(H - h, 0)];
277
+ const fit = lefts.flatMap((left) => tops.map((top) => ({ left, top, w, h }))).find((box) => !lineHits(pts, box));
278
+ if (!fit) {
279
+ node.style.top = `${H + CLEAR}px`;
280
+ return;
281
+ }
282
+ node.style.top = `${fit.top}px`;
283
+ node.style.marginLeft = `${fit.left - slid}px`;
284
+ }
285
+ function lineYAt(pts, x) {
286
+ for (let i = 0; i + 1 < pts.length; i += 1) {
287
+ const [ax, ay] = pts[i];
288
+ const [bx, by] = pts[i + 1];
289
+ if (x >= Math.min(ax, bx) && x <= Math.max(ax, bx))
290
+ return bx === ax ? ay : ay + (by - ay) * (x - ax) / (bx - ax);
291
+ }
292
+ return null;
293
+ }
294
+ function placeInBand(node, line, fx) {
295
+ const layer = node.parentElement;
296
+ if (!layer) return;
297
+ const [W, H, w, h] = [layer.clientWidth, layer.clientHeight, node.offsetWidth, node.offsetHeight];
298
+ if (W <= 0 || H <= 0) return;
299
+ const pts = line().map(([x, y]) => [x * W, y * H]);
300
+ const slid = fx * (W - w);
301
+ const room = (left) => Math.min(Math.max(left, 0), Math.max(W - w, 0));
302
+ const lefts = [slid, room(fx * W + CLEAR * 2), room(fx * W - CLEAR * 2 - w)];
303
+ const bands = [0, Math.max(H - h, 0)];
304
+ const dotY = lineYAt(pts, fx * W);
305
+ const score = (left, top) => {
306
+ const covers = dotY !== null && fx * W + CLEAR > left && fx * W - CLEAR < left + w && dotY + CLEAR > top && dotY - CLEAR < top + h;
307
+ let nearest = Number.POSITIVE_INFINITY;
308
+ for (let x = left; x <= left + w; x += 2) {
309
+ const y = lineYAt(pts, x);
310
+ if (y === null) continue;
311
+ nearest = Math.min(nearest, y < top ? top - y : y > top + h ? y - (top + h) : 0);
312
+ }
313
+ return (covers ? -1e3 : 0) + Math.min(nearest, 999);
314
+ };
315
+ const fit = lefts.flatMap((left) => bands.map((top) => ({ left, top, s: score(left, top) }))).reduce((a, b) => b.s > a.s ? b : a);
316
+ node.style.top = `${fit.top}px`;
317
+ node.style.marginLeft = `${fit.left - slid}px`;
318
+ }
319
+ function fitReadout(node, line, fx, band) {
248
320
  const overflows = () => node.scrollWidth > node.clientWidth;
249
321
  node.removeAttribute("data-tight");
250
322
  node.removeAttribute("data-stacked");
251
- if (!overflows()) return;
252
- node.setAttribute("data-tight", "");
253
- if (overflows()) node.setAttribute("data-stacked", "");
323
+ if (line !== null) {
324
+ node.style.removeProperty("top");
325
+ node.style.removeProperty("margin-left");
326
+ }
327
+ if (overflows()) {
328
+ node.setAttribute("data-tight", "");
329
+ if (overflows() && !band) node.setAttribute("data-stacked", "");
330
+ }
331
+ if (line === null) return;
332
+ if (band) placeInBand(node, line, fx);
333
+ else if (node.hasAttribute("data-stacked")) placeStacked(node, line, fx);
254
334
  }
255
335
  function Sparkline(props) {
256
336
  const {
@@ -330,21 +410,37 @@ function Sparkline(props) {
330
410
  fy: (model.frame.y[1] - value) / (model.frame.y[1] - model.frame.y[0]),
331
411
  label: labels?.[active] ?? model.moments?.[active]
332
412
  } : null;
413
+ const short = !hosted && mark === "line" && height < SHORT_BOX;
333
414
  const beside = at === null ? null : at.fx > 0.5 ? "left" : "right";
334
415
  const shown = at !== null;
416
+ const fxRef = useRef(0);
417
+ useLayoutEffect(() => {
418
+ fxRef.current = at?.fx ?? 0;
419
+ });
420
+ const fitRef = useRef(() => {
421
+ });
335
422
  useLayoutEffect(() => {
336
- if (readoutRef.current !== null) fitReadout(readoutRef.current);
337
- }, [active, at?.label, at?.value, beside]);
423
+ const line = (hosted || short) && mark === "line" && model !== null ? () => model.rows.flatMap(
424
+ (r, i) => r.v === null ? [] : [
425
+ [
426
+ (i - model.frame.x[0]) / (model.frame.x[1] - model.frame.x[0]),
427
+ (model.frame.y[1] - r.v) / (model.frame.y[1] - model.frame.y[0])
428
+ ]
429
+ ]
430
+ ) : null;
431
+ fitRef.current = () => {
432
+ if (readoutRef.current !== null) fitReadout(readoutRef.current, line, fxRef.current, short);
433
+ };
434
+ fitRef.current();
435
+ }, [active, at?.label, at?.value, beside, hosted, short, mark, model]);
338
436
  useEffect(() => {
339
437
  const layer = readoutRef.current?.parentElement;
340
438
  if (!shown || !layer || typeof ResizeObserver === "undefined") return;
341
- const observer = new ResizeObserver(() => {
342
- if (readoutRef.current !== null) fitReadout(readoutRef.current);
343
- });
439
+ const observer = new ResizeObserver(() => fitRef.current());
344
440
  observer.observe(layer);
345
441
  return () => observer.disconnect();
346
442
  }, [shown]);
347
- const readoutStyle = at === null ? void 0 : hosted ? { left: `${at.fx * 100}%`, translate: `${-at.fx * 100}% 0`, maxWidth: "100%" } : {
443
+ const readoutStyle = at === null ? void 0 : hosted || short ? { left: `${at.fx * 100}%`, translate: `${-at.fx * 100}% 0`, maxWidth: "100%" } : {
348
444
  ...beside === "right" ? {
349
445
  left: `calc(${at.fx * 100}% + ${READOUT_GAP}px)`,
350
446
  maxWidth: `calc(${(1 - at.fx) * 100}% - ${READOUT_GAP}px)`
@@ -93,21 +93,139 @@
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
+ .ghostLine {
119
+ width: 100%;
120
+ height: 100%;
121
+ fill: none;
122
+ stroke: color-mix(in srgb, var(--vx-ink) 24%, var(--vx-surface-panel));
123
+ stroke-width: 2px;
124
+ stroke-linecap: round;
125
+ stroke-linejoin: round;
126
+ }
127
+
128
+ .ghostBar {
129
+ flex: 1 1 0;
130
+ min-width: 0;
131
+ border-radius: 3px 3px 0 0;
132
+ background: color-mix(in srgb, var(--vx-ink) 18%, var(--vx-surface-panel));
133
+ }
134
+
96
135
  /*
97
136
  * The engine paints its tooltip rows as a grid of `.55rem | minmax(0, 1fr) | auto` with inline
98
137
  * styles and `overflow-wrap: anywhere` on the card, so a narrow tooltip (a 390 viewport, a pointer
99
138
  * near an edge) squeezes the name column to one character per line. The name keeps a floor and
100
- * never wraps; a long name ends in an ellipsis, the value stays right-aligned. The tooltip is
101
- * portalled out of the chart's tree, hence the global class names. `!important` because the
102
- * engine's own values are inline.
139
+ * wraps at word breaks when it must; the figure never wraps and never ends in an ellipsis, it stays
140
+ * right-aligned. The tooltip is portalled out of the chart's tree, hence the global class names.
141
+ * `!important` because the engine's own values are inline.
103
142
  */
104
143
  :global(.ts-chart-tooltip__row) {
105
- grid-template-columns: 0.55rem minmax(6rem, max-content) auto !important;
144
+ grid-template-columns: 0.55rem minmax(6rem, 1fr) auto !important;
106
145
  }
107
146
 
108
147
  :global(.ts-chart-tooltip__row > span:nth-child(2)) {
109
- max-width: 14rem;
148
+ /* Words wrap, tokens do not: the engine's `anywhere` on the card would split `Load (7)` as
149
+ * `Load` / `7)` and `TE 2.1/0.4` mid-figure. A single token wider than the card overflows it. */
150
+ overflow-wrap: normal;
151
+ white-space: normal;
152
+ }
153
+
154
+ :global(.ts-chart-tooltip__row > span:nth-child(3)) {
155
+ white-space: nowrap;
156
+ }
157
+
158
+ /* Opaque in both schemes: `--vx-tooltip-bg` is translucent in dark and the card's footer ghosts
159
+ * through a tooltip that opens over it (a slotted `Bars`). The tint is layered over the elevated
160
+ * surface, so a consumer's `tooltipBg` and `--basalt-tooltip-surface` still colour it. The engine's
161
+ * own value is inline. */
162
+ :global(.ts-chart-tooltip) {
163
+ background: linear-gradient(
164
+ var(--basalt-tooltip-surface, var(--vx-tooltip-bg)),
165
+ var(--basalt-tooltip-surface, var(--vx-tooltip-bg))
166
+ )
167
+ var(--vx-surface-elevated) !important;
168
+ }
169
+
170
+ /*
171
+ * A slotted `Bars` (`data-basalt-slot`, set by `compile.ts`) is a micro-visual: its tooltip is the
172
+ * Sparkline's one-line chip, `<value> · <x label>` in the line the host reserves above the plot. The
173
+ * first row's figure leads, the header follows it, further rows are hidden (a chart that needs rows
174
+ * lives in a `ChartCard`); an overlong header ends in an ellipsis. Height, type and edge are the
175
+ * chip's (`sparkline.module.css`); the tooltip is portalled out of the host, so its fallbacks stand.
176
+ */
177
+ :global(.ts-chart-tooltip[data-basalt-slot]) {
178
+ display: flex !important;
179
+ align-items: center;
180
+ box-sizing: border-box;
181
+ width: max-content;
182
+ block-size: 1.125rem;
183
+ padding: 0 4px !important;
184
+ overflow: hidden;
185
+ font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
186
+ font-variant-numeric: lining-nums;
187
+ font-size: var(--vx-text-xs);
188
+ line-height: calc(1.125rem - 2px);
189
+ white-space: nowrap !important;
190
+ border-radius: var(--vx-radius-ctrl) !important;
191
+ /* theme-allow css-raw-surface — the chip is flat, like the Sparkline's, not a floating panel */
192
+ box-shadow: none !important;
193
+ }
194
+
195
+ :global(.ts-chart-tooltip[data-basalt-slot]:is([hidden], [popover]:not(:popover-open))) {
196
+ /* The flex above must not beat the engine's own hide. */
197
+ display: none !important;
198
+ }
199
+
200
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__rows) {
201
+ flex: none;
202
+ order: 0;
203
+ }
204
+
205
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__row) {
206
+ display: block !important;
207
+ }
208
+
209
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__row:not(:first-child)),
210
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__row > span:not(:last-child)) {
211
+ display: none;
212
+ }
213
+
214
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__title) {
215
+ display: block !important;
216
+ flex: 0 1 auto;
217
+ min-width: 0;
218
+ order: 1;
219
+ margin: 0 !important;
110
220
  overflow: hidden;
221
+ font-weight: inherit !important;
111
222
  text-overflow: ellipsis;
112
223
  white-space: nowrap;
224
+ overflow-wrap: normal;
225
+ opacity: 0.7;
226
+ }
227
+
228
+ :global(.ts-chart-tooltip[data-basalt-slot] .ts-chart-tooltip__title::before) {
229
+ content: ' · ';
230
+ white-space: pre;
113
231
  }
@@ -9,5 +9,8 @@ declare const classes: {
9
9
  readonly fill: string
10
10
  readonly state: string
11
11
  readonly grow: string
12
+ readonly ghost: string
13
+ readonly ghostLine: string
14
+ readonly ghostBar: string
12
15
  }
13
16
  export default classes
@@ -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
+ }
@@ -11,5 +11,7 @@ declare const classes: {
11
11
  readonly factValue: string
12
12
  readonly factUnit: string
13
13
  readonly factPeriod: string
14
+ readonly skeletonFigure: string
15
+ readonly skeletonBasis: string
14
16
  }
15
17
  export default classes
@@ -15,10 +15,8 @@
15
15
  }
16
16
 
17
17
  @container (min-width: 240px) {
18
- /* One row: `foldLegend` (legend.tsx) folds what does not fit into `+N`; zones lead the series. */
19
18
  .auto {
20
- flex-wrap: nowrap;
21
- overflow: hidden;
19
+ flex-wrap: wrap;
22
20
  display: flex;
23
21
  column-gap: var(--bc-dots-gap);
24
22
  --vx-hit-gap: var(--bc-dots-gap);
@@ -27,8 +25,6 @@
27
25
 
28
26
  @container (min-width: 480px) {
29
27
  .auto {
30
- flex-wrap: wrap;
31
- overflow: visible;
32
28
  column-gap: var(--bc-legend-gap);
33
29
  --vx-hit-gap: var(--bc-legend-gap);
34
30
  }
@@ -48,14 +44,3 @@
48
44
  display: none;
49
45
  }
50
46
  }
51
-
52
- /* The compact fold (`foldLegend`, which only folds while the row is `nowrap`); wide keeps every entry.
53
- * `!important`: an entry's inline `all: unset` (legend.tsx) would otherwise reset `display`. */
54
- .auto [data-legend-folded] {
55
- display: none !important;
56
- }
57
-
58
- .auto [data-legend-more] {
59
- order: 1;
60
- flex: none;
61
- }
@@ -1,3 +1,4 @@
1
+ import type { ChartTooltipPortalPositionContext } from '@tanstack/charts/tooltip/portal';
1
2
  import type { ChartGradient, ChartPositionScaleOptions, ChartTooltipRow as EngineTooltipRow, ChartValue, ResponsiveChartDefinition } from '@tanstack/charts/types/core';
2
3
  import type { ContainerClass } from '../tokens/size-classes.js';
3
4
  import type { PlotSizes } from './plot-context.js';
@@ -121,6 +122,25 @@ export declare function zoneAreaGradient(index: number, zones: readonly ZoneSpec
121
122
  * a clock time (a bucket keyed by local midnight is `22:00` UTC in a UTC+2 zone).
122
123
  */
123
124
  export declare function dayGranular(values: readonly ChartX[]): boolean;
125
+ /**
126
+ * The engine places a portalled tooltip against the viewport, so it opens past the card's edge, over
127
+ * the neighbouring card or the section heading above. Its placements (a hover, and its own resize /
128
+ * scroll repositions, which never pass through `position`) all write the element's inline `left` and
129
+ * `top`, so each write is followed by a settle inside the card (`settleInCard`).
130
+ */
131
+ /** What a card clamp does: `card` a chart tooltip (both axes, the card's width), `slot` a slotted
132
+ * `Bars` chip (flush above its plot), `strip` a `BandStrip`'s (sideways only, as before Wave 39). */
133
+ type TipMode = 'card' | 'slot' | 'strip';
134
+ /**
135
+ * Keeps a tooltip inside its card on both axes. A card with room lets the tooltip grow up to its
136
+ * width before a label wraps, and re-centres it on the anchor at that width. A tooltip that would
137
+ * cross the card's top or bottom flips to the other side of its anchor when that side fits; neither
138
+ * fitting, it slides in; taller than the card, it aligns to the card's top (the only overflow).
139
+ * A `slot` tooltip (a slotted `Bars`, one line) keeps its place above the plot, centred on the
140
+ * anchor, capped at the card's width and held inside the card sideways and at its top. A hidden or unmeasured tooltip is left alone, and an unchanged position
141
+ * is not written back (a write re-runs this).
142
+ */
143
+ export declare function settleInCard(tip: HTMLElement, within: Element, ctx: ChartTooltipPortalPositionContext, mode?: TipMode): void;
124
144
  export declare function compileCartesian<T, X extends ChartX>(input: CartesianInput<T, X>): CartesianDefinition;
125
145
  export {};
126
146
  //# sourceMappingURL=compile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"AAiBA,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,C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AAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GACjC,aAAa,GAAG,IAAI,CAuBtB;AA0aD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAO9D;AAgID;;;;;GAKG;AACH;qGACqG;AACrG,KAAK,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AA2BxC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,iCAAiC,EACtC,IAAI,GAAE,OAAgB,GACrB,IAAI,CAmEN;AA0ED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAClD,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAC1B,mBAAmB,CA2HrB"}
@@ -602,6 +602,11 @@ const stripAnchor = (points, { plot }) => {
602
602
  };
603
603
  const STRIP_TOOLTIP_PLACEMENT = ["bottom", "top"];
604
604
  const STRIP_TOOLTIP_OFFSET = 8;
605
+ const slotAnchor = (points, { plot }) => {
606
+ const xs = points.map((p) => p.x);
607
+ return { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: plot.y };
608
+ };
609
+ const SLOT_TOOLTIP_PLACEMENT = ["top"];
605
610
  const TIP_CHROME = 30;
606
611
  const TIP_ROW = 18;
607
612
  const TIP_TOP_AIR = 4;
@@ -618,18 +623,108 @@ const barAnchor = (rows) => (points, { plot }) => {
618
623
  const stepped = x + (toRight ? TIP_SIDE_STEP : -TIP_SIDE_STEP);
619
624
  return { x: Math.min(Math.max(stepped, plot.x), plot.x + plot.width), y: floor };
620
625
  };
626
+ const TIP_CARD = "[data-basalt-chart-card], [data-strip-cell], .mantine-Card-root";
627
+ const TIP_CARD_AIR = 4;
628
+ const TIP_CARD_ROOMY = 192;
629
+ const cardPortal = (mode) => ({
630
+ id: portal.id,
631
+ create(context, options) {
632
+ const inner = portal.create(context, options);
633
+ const { element, container } = context;
634
+ if (mode === "slot") element.dataset["basaltSlot"] = "";
635
+ let last;
636
+ const watch = new MutationObserver(() => {
637
+ if (last) settleInCard(element, container, last, mode);
638
+ });
639
+ watch.observe(element, { attributes: true, attributeFilter: ["style"] });
640
+ return {
641
+ ...inner,
642
+ position(next) {
643
+ last = next;
644
+ return inner.position(next);
645
+ },
646
+ destroy() {
647
+ watch.disconnect();
648
+ inner.destroy();
649
+ }
650
+ };
651
+ }
652
+ });
653
+ function settleInCard(tip, within, ctx, mode = "card") {
654
+ const slot = mode === "slot";
655
+ if (tip.hidden || tip.offsetHeight === 0) return;
656
+ const card = within.closest(TIP_CARD)?.getBoundingClientRect();
657
+ const surface = ctx.surface.element.getBoundingClientRect();
658
+ const { width: sceneW, height: sceneH } = ctx.scene;
659
+ let left = Number.parseFloat(tip.style.left);
660
+ let top = Number.parseFloat(tip.style.top);
661
+ if (!card || Number.isNaN(left) || Number.isNaN(top) || !surface.width || !sceneW || !sceneH)
662
+ return;
663
+ const w0 = tip.offsetWidth;
664
+ const toClient = (p) => ({
665
+ x: surface.left + p.x / sceneW * surface.width,
666
+ y: surface.top + p.y / sceneH * surface.height
667
+ });
668
+ if (mode === "strip") {
669
+ if (w0 + 2 * TIP_CARD_AIR <= card.width)
670
+ left = Math.min(Math.max(left, card.left + TIP_CARD_AIR), card.right - w0 - TIP_CARD_AIR);
671
+ if (Math.abs(left - Number.parseFloat(tip.style.left)) > 0.5) tip.style.left = `${left}px`;
672
+ return;
673
+ }
674
+ const roomy = card.width >= TIP_CARD_ROOMY;
675
+ const grown = roomy || slot;
676
+ if (!grown) {
677
+ if (tip.dataset["basaltMax"] !== void 0) {
678
+ tip.style.maxWidth = tip.dataset["basaltMax"];
679
+ tip.style.removeProperty("width");
680
+ delete tip.dataset["basaltMax"];
681
+ }
682
+ } else {
683
+ tip.dataset["basaltMax"] ??= tip.style.maxWidth;
684
+ const cap = `${card.width - 2 * TIP_CARD_AIR}px`;
685
+ if (tip.style.maxWidth !== cap) tip.style.maxWidth = cap;
686
+ if (tip.style.width !== "max-content") tip.style.width = "max-content";
687
+ }
688
+ const [w, h] = [tip.offsetWidth, tip.offsetHeight];
689
+ const anchor = toClient(ctx.anchor);
690
+ const gap = Math.max(0, Number.isFinite(ctx.offset) ? ctx.offset ?? 10 : 10);
691
+ const minTop = card.top + TIP_CARD_AIR;
692
+ const maxTop = card.bottom - TIP_CARD_AIR - h;
693
+ const side = tip.dataset["placement"];
694
+ if (slot) {
695
+ top = Math.max(anchor.y - gap - h, card.top);
696
+ left = anchor.x - w / 2;
697
+ } else if (side === "top" || side === "bottom") {
698
+ const above = anchor.y - gap - h;
699
+ const below = anchor.y + gap;
700
+ const order = side === "top" ? [above, below] : [below, above];
701
+ const fits = order.findIndex((t) => t >= minTop && t <= maxTop);
702
+ top = order[Math.max(fits, 0)] ?? top;
703
+ if (fits > 0) tip.dataset["placement"] = side === "top" ? "bottom" : "top";
704
+ if (roomy) left = anchor.x - w / 2;
705
+ }
706
+ if (!slot) top = maxTop < minTop ? minTop : Math.min(Math.max(top, minTop), maxTop);
707
+ if (grown || w + 2 * TIP_CARD_AIR <= card.width)
708
+ left = Math.min(
709
+ Math.max(left, card.left + TIP_CARD_AIR),
710
+ Math.max(card.right - w - TIP_CARD_AIR, card.left + TIP_CARD_AIR)
711
+ );
712
+ if (Math.abs(left - Number.parseFloat(tip.style.left)) > 0.5) tip.style.left = `${left}px`;
713
+ if (Math.abs(top - Number.parseFloat(tip.style.top)) > 0.5) tip.style.top = `${top}px`;
714
+ }
621
715
  function tooltipSpec(opts) {
622
716
  const { input, axes, visible, keys, visibleKeys, formatX, dayOnly } = opts;
623
717
  const hidden = input.series.filter((s) => !visibleKeys.has(s.key));
718
+ const slot = input.tooltipBelow === true && input.bare === true;
624
719
  const rowSeries = (input.reverseRows ? visible.toReversed() : visible).filter(
625
720
  (s) => s.tooltip !== false
626
721
  );
627
722
  return {
628
723
  use: quietWhileFollowing,
629
724
  ...followerOptions(input.tooltip, input.cursorGroup, input.chartId),
630
- portal,
631
- anchor: input.tooltipBelow ? stripAnchor : visible.some((s) => s.mark === "bar") ? barAnchor(rowSeries.length) : "group-center",
632
- ...input.tooltipBelow && { placement: STRIP_TOOLTIP_PLACEMENT, offset: STRIP_TOOLTIP_OFFSET },
725
+ portal: cardPortal(slot ? "slot" : input.tooltipBelow === true ? "strip" : "card"),
726
+ anchor: input.tooltipBelow ? slot ? slotAnchor : stripAnchor : visible.some((s) => s.mark === "bar") ? barAnchor(rowSeries.length) : "group-center",
727
+ ...input.tooltipBelow && (slot ? { placement: SLOT_TOOLTIP_PLACEMENT, offset: 0 } : { placement: STRIP_TOOLTIP_PLACEMENT, offset: STRIP_TOOLTIP_OFFSET }),
633
728
  content: (points) => {
634
729
  const primary = points[0];
635
730
  if (!primary) return { rows: [] };
@@ -784,6 +879,7 @@ export {
784
879
  engineRow,
785
880
  refLegendSeries,
786
881
  seriesRow,
882
+ settleInCard,
787
883
  strideTicks,
788
884
  utcHeaderDate,
789
885
  visibleSeries,
@@ -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;AAyDD;;;;GAIG;AACH,MAAM,MAAM,YAAY,CA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