basalt-ui 2.21.0 → 2.22.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 (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/MIGRATING.md +277 -12
  3. package/agent/agents/basalt-design-reviewer.md +1 -1
  4. package/agent/rules/basalt-tokens.md +1 -1
  5. package/agent/skills/basalt-design/SKILL.md +1 -1
  6. package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
  7. package/agent/skills/basalt-design/references/catalogue.md +1 -0
  8. package/dist/charts/BandStrip.d.ts.map +1 -1
  9. package/dist/charts/BandStrip.js +27 -3
  10. package/dist/charts/Bars.d.ts.map +1 -1
  11. package/dist/charts/Bars.js +5 -0
  12. package/dist/charts/CartesianChart.d.ts +8 -0
  13. package/dist/charts/CartesianChart.d.ts.map +1 -1
  14. package/dist/charts/CartesianChart.js +8 -5
  15. package/dist/charts/ChartCard.d.ts +12 -3
  16. package/dist/charts/ChartCard.d.ts.map +1 -1
  17. package/dist/charts/ChartCard.js +29 -8
  18. package/dist/charts/DualPanel.d.ts.map +1 -1
  19. package/dist/charts/DualPanel.js +5 -8
  20. package/dist/charts/Heatmap.d.ts +12 -1
  21. package/dist/charts/Heatmap.d.ts.map +1 -1
  22. package/dist/charts/Heatmap.js +34 -5
  23. package/dist/charts/Lines.d.ts +3 -0
  24. package/dist/charts/Lines.d.ts.map +1 -1
  25. package/dist/charts/Lines.js +29 -6
  26. package/dist/charts/MirroredBars.d.ts.map +1 -1
  27. package/dist/charts/MirroredBars.js +4 -6
  28. package/dist/charts/Sparkline.d.ts +7 -1
  29. package/dist/charts/Sparkline.d.ts.map +1 -1
  30. package/dist/charts/Sparkline.js +39 -14
  31. package/dist/charts/StackedArea.d.ts +4 -1
  32. package/dist/charts/StackedArea.d.ts.map +1 -1
  33. package/dist/charts/StackedArea.js +9 -3
  34. package/dist/charts/band-fold.d.ts +20 -1
  35. package/dist/charts/band-fold.d.ts.map +1 -1
  36. package/dist/charts/band-fold.js +9 -0
  37. package/dist/charts/chart-box.module.css +19 -0
  38. package/dist/charts/chart-card.module.css +25 -0
  39. package/dist/charts/chart-legend.module.css +7 -0
  40. package/dist/charts/compile.d.ts +17 -6
  41. package/dist/charts/compile.d.ts.map +1 -1
  42. package/dist/charts/compile.js +145 -74
  43. package/dist/charts/labels.d.ts +15 -4
  44. package/dist/charts/labels.d.ts.map +1 -1
  45. package/dist/charts/labels.js +34 -10
  46. package/dist/charts/legend.d.ts +2 -0
  47. package/dist/charts/legend.d.ts.map +1 -1
  48. package/dist/charts/legend.js +7 -21
  49. package/dist/charts/marks.js +1 -1
  50. package/dist/charts/panel.d.ts +0 -6
  51. package/dist/charts/panel.d.ts.map +1 -1
  52. package/dist/charts/panel.js +1 -10
  53. package/dist/charts/ref-label.d.ts +26 -0
  54. package/dist/charts/ref-label.d.ts.map +1 -0
  55. package/dist/charts/ref-label.js +63 -0
  56. package/dist/charts/scales.d.ts +4 -1
  57. package/dist/charts/scales.d.ts.map +1 -1
  58. package/dist/charts/scales.js +14 -3
  59. package/dist/charts/sparkline.module.css +10 -11
  60. package/dist/charts/sparkline.module.css.d.ts +1 -2
  61. package/dist/charts/state.d.ts +2 -0
  62. package/dist/charts/state.d.ts.map +1 -1
  63. package/dist/charts/state.js +2 -1
  64. package/dist/charts/types.d.ts +14 -5
  65. package/dist/charts/types.d.ts.map +1 -1
  66. package/dist/cli/doctor-upgrade.d.ts +1 -0
  67. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  68. package/dist/cli/doctor-upgrade.js +1 -0
  69. package/dist/cli/init.d.ts +2 -0
  70. package/dist/cli/init.d.ts.map +1 -1
  71. package/dist/cli/init.js +68 -4
  72. package/dist/cli/shot/capture.d.ts +21 -2
  73. package/dist/cli/shot/capture.d.ts.map +1 -1
  74. package/dist/cli/shot/capture.js +194 -32
  75. package/dist/cli/shot/detect.d.ts.map +1 -1
  76. package/dist/cli/shot/detect.js +14 -1
  77. package/dist/cli/shot/playwright.d.ts +5 -2
  78. package/dist/cli/shot/playwright.d.ts.map +1 -1
  79. package/dist/cli/shot/types.d.ts +2 -0
  80. package/dist/cli/shot/types.d.ts.map +1 -1
  81. package/dist/cli/shot/types.js +2 -0
  82. package/dist/controls/controls.module.css +11 -1
  83. package/dist/controls/filter-pill.d.ts.map +1 -1
  84. package/dist/controls/filter-pill.js +1 -0
  85. package/dist/controls/sync-button.d.ts.map +1 -1
  86. package/dist/controls/sync-button.js +22 -3
  87. package/dist/controls/sync-button.module.css +34 -2
  88. package/dist/controls/sync-button.module.css.d.ts +1 -0
  89. package/dist/dashboard/bar-list.d.ts.map +1 -1
  90. package/dist/dashboard/bar-list.js +7 -8
  91. package/dist/dashboard/bar-list.module.css +53 -0
  92. package/dist/dashboard/bar-list.module.css.d.ts +1 -0
  93. package/dist/dashboard/index.d.ts +1 -0
  94. package/dist/dashboard/index.d.ts.map +1 -1
  95. package/dist/dashboard/index.js +2 -0
  96. package/dist/dashboard/meter-model.d.ts +77 -3
  97. package/dist/dashboard/meter-model.d.ts.map +1 -1
  98. package/dist/dashboard/meter-model.js +88 -15
  99. package/dist/dashboard/meter-parts.d.ts +8 -0
  100. package/dist/dashboard/meter-parts.d.ts.map +1 -1
  101. package/dist/dashboard/meter-parts.js +238 -71
  102. package/dist/dashboard/meter.d.ts +43 -60
  103. package/dist/dashboard/meter.d.ts.map +1 -1
  104. package/dist/dashboard/meter.js +20 -3
  105. package/dist/dashboard/meter.module.css +61 -0
  106. package/dist/dashboard/meter.module.css.d.ts +5 -0
  107. package/dist/dashboard/page-summary.d.ts +20 -0
  108. package/dist/dashboard/page-summary.d.ts.map +1 -0
  109. package/dist/dashboard/page-summary.js +28 -0
  110. package/dist/dashboard/page-summary.module.css +89 -0
  111. package/dist/dashboard/page-summary.module.css.d.ts +15 -0
  112. package/dist/dashboard/section.d.ts +25 -2
  113. package/dist/dashboard/section.d.ts.map +1 -1
  114. package/dist/dashboard/section.js +10 -5
  115. package/dist/dashboard/section.module.css +23 -0
  116. package/dist/dashboard/section.module.css.d.ts +1 -0
  117. package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
  118. package/dist/dashboard/stat-card-parts.js +1 -1
  119. package/dist/dashboard/stat-card.d.ts +4 -2
  120. package/dist/dashboard/stat-card.d.ts.map +1 -1
  121. package/dist/dashboard/stat-card.js +7 -5
  122. package/dist/dashboard/stat-card.module.css +17 -0
  123. package/dist/dashboard/stat-strip.d.ts +7 -1
  124. package/dist/dashboard/stat-strip.d.ts.map +1 -1
  125. package/dist/dashboard/stat-strip.js +74 -46
  126. package/dist/dashboard/stat-strip.module.css +67 -20
  127. package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
  128. package/dist/dashboard/visual-slot.d.ts +7 -1
  129. package/dist/dashboard/visual-slot.d.ts.map +1 -1
  130. package/dist/dashboard/visual-slot.js +3 -1
  131. package/dist/guard/vx-names.d.ts.map +1 -1
  132. package/dist/guard/vx-names.js +2 -0
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +3 -1
  136. package/dist/styles.css +34 -2
  137. package/dist/theme/chrome-vars.d.ts +20 -5
  138. package/dist/theme/chrome-vars.d.ts.map +1 -1
  139. package/dist/theme/chrome-vars.js +46 -3
  140. package/dist/theme/controls.module.css +23 -0
  141. package/dist/theme/controls.module.css.d.ts +1 -0
  142. package/dist/theme/index.d.ts.map +1 -1
  143. package/dist/theme/index.js +8 -20
  144. package/dist/tokens/core.d.ts +2 -1
  145. package/dist/tokens/core.d.ts.map +1 -1
  146. package/dist/tokens/core.js +6 -1
  147. package/dist/tokens/derive.d.ts +3 -1
  148. package/dist/tokens/derive.d.ts.map +1 -1
  149. package/dist/tokens/derive.js +16 -1
  150. package/dist/tokens/palette.d.ts +4 -0
  151. package/dist/tokens/palette.d.ts.map +1 -1
  152. package/dist/tokens/palette.js +4 -0
  153. package/dist/tokens/status-text.d.ts.map +1 -1
  154. package/dist/tokens/status-text.js +3 -1
  155. package/llms.txt +38 -20
  156. package/package.json +1 -1
  157. package/src/charts/BandStrip.tsx +33 -3
  158. package/src/charts/Bars.tsx +6 -0
  159. package/src/charts/CartesianChart.tsx +16 -3
  160. package/src/charts/ChartCard.tsx +34 -6
  161. package/src/charts/DualPanel.tsx +3 -6
  162. package/src/charts/Heatmap.tsx +54 -5
  163. package/src/charts/Lines.tsx +56 -10
  164. package/src/charts/MirroredBars.tsx +3 -5
  165. package/src/charts/Sparkline.tsx +50 -13
  166. package/src/charts/StackedArea.tsx +14 -4
  167. package/src/charts/band-fold.ts +31 -1
  168. package/src/charts/chart-box.module.css +19 -0
  169. package/src/charts/chart-card.module.css +25 -0
  170. package/src/charts/chart-legend.module.css +7 -0
  171. package/src/charts/compile.ts +210 -85
  172. package/src/charts/labels.ts +48 -14
  173. package/src/charts/legend.tsx +10 -20
  174. package/src/charts/marks.ts +1 -1
  175. package/src/charts/panel.tsx +1 -16
  176. package/src/charts/ref-label.ts +104 -0
  177. package/src/charts/scales.ts +22 -2
  178. package/src/charts/sparkline.module.css +10 -11
  179. package/src/charts/sparkline.module.css.d.ts +1 -2
  180. package/src/charts/state.tsx +3 -1
  181. package/src/charts/types.ts +14 -5
  182. package/src/cli/doctor-upgrade.ts +1 -1
  183. package/src/cli/init.ts +100 -3
  184. package/src/cli/shot/capture.ts +251 -32
  185. package/src/cli/shot/detect.ts +18 -1
  186. package/src/cli/shot/playwright.ts +2 -2
  187. package/src/cli/shot/types.ts +3 -0
  188. package/src/controls/controls.module.css +11 -1
  189. package/src/controls/filter-pill.tsx +2 -0
  190. package/src/controls/sync-button.module.css +34 -2
  191. package/src/controls/sync-button.module.css.d.ts +1 -0
  192. package/src/controls/sync-button.tsx +40 -4
  193. package/src/dashboard/bar-list.module.css +53 -0
  194. package/src/dashboard/bar-list.module.css.d.ts +1 -0
  195. package/src/dashboard/bar-list.tsx +78 -69
  196. package/src/dashboard/index.ts +1 -0
  197. package/src/dashboard/meter-model.ts +186 -20
  198. package/src/dashboard/meter-parts.tsx +285 -64
  199. package/src/dashboard/meter.module.css +61 -0
  200. package/src/dashboard/meter.module.css.d.ts +5 -0
  201. package/src/dashboard/meter.tsx +60 -10
  202. package/src/dashboard/page-summary.module.css +89 -0
  203. package/src/dashboard/page-summary.module.css.d.ts +15 -0
  204. package/src/dashboard/page-summary.tsx +95 -0
  205. package/src/dashboard/section.module.css +23 -0
  206. package/src/dashboard/section.module.css.d.ts +1 -0
  207. package/src/dashboard/section.tsx +59 -11
  208. package/src/dashboard/stat-card-parts.tsx +5 -1
  209. package/src/dashboard/stat-card.module.css +17 -0
  210. package/src/dashboard/stat-card.tsx +12 -6
  211. package/src/dashboard/stat-strip.module.css +67 -20
  212. package/src/dashboard/stat-strip.module.css.d.ts +4 -0
  213. package/src/dashboard/stat-strip.tsx +118 -72
  214. package/src/dashboard/visual-slot.ts +12 -3
  215. package/src/guard/vx-names.ts +2 -0
  216. package/src/index.ts +2 -0
  217. package/src/styles.css +34 -2
  218. package/src/theme/__snapshots__/plain-theme.test.ts.snap +186 -60
  219. package/src/theme/chrome-vars.ts +77 -8
  220. package/src/theme/controls.module.css +23 -0
  221. package/src/theme/controls.module.css.d.ts +1 -0
  222. package/src/theme/index.ts +12 -25
  223. package/src/tokens/core.ts +4 -1
  224. package/src/tokens/derive.ts +32 -3
  225. package/src/tokens/palette.ts +4 -0
  226. package/src/tokens/status-text.ts +2 -0
@@ -1,4 +1,4 @@
1
- import { dateTickFormat, monthName, pad2, utcAxisDate } from "./date-tick-format.js";
1
+ import { dateTickFormat, utcAxisDate } from "./date-tick-format.js";
2
2
  import { crosshair } from "@tanstack/charts/crosshair";
3
3
  import { decorative } from "@tanstack/charts/mark/decorative";
4
4
  import { rect } from "@tanstack/charts/rect";
@@ -7,13 +7,14 @@ import { ruleX, ruleY } from "@tanstack/charts/rule";
7
7
  import { scaleLinear } from "@tanstack/charts/scales/linear";
8
8
  import { scaleUtc } from "d3-scale";
9
9
  import { portal } from "@tanstack/charts/tooltip/portal";
10
- import { SHORT_CHART_HEIGHT } from "./box.js";
11
10
  import { compact } from "../format/number.js";
11
+ import { NON_FINITE, dateFormat } from "../format/shared.js";
12
12
  import { VX } from "../tokens/index.js";
13
13
  import { cursorBinding, followerOptions, quietWhileFollowing } from "./cursor.js";
14
14
  import { cursorDots } from "./marks.js";
15
15
  import { bucketTicks, strideEvery } from "./ticks.js";
16
16
  import { MAIN_PANE, plotAccess, plotContext } from "./plot-context.js";
17
+ import { refLabelPosition } from "./ref-label.js";
17
18
  import { resolveContainerClass } from "../tokens/size-classes.js";
18
19
  import { resolveYDomain, xScaleFor, xZoneFractions, yScaleFor } from "./scales.js";
19
20
  import { AXIS_LINE, CHART_THEME, CROSSHAIR, DASH, GRID_LINE } from "./theme.js";
@@ -24,18 +25,34 @@ const LADDER = {
24
25
  regular: { xTicks: 5, yTicks: 5 },
25
26
  wide: { xTicks: 6, yTicks: 5 }
26
27
  };
27
- const INSIDE_LABEL_DX = 4;
28
28
  const LEFT_EDGE_SHARE = 0.05;
29
- const INSIDE_LABEL_DY = -6;
30
- const labelsInside = (cls, height) => cls === "compact" && height > 0 && height < SHORT_CHART_HEIGHT;
31
29
  function defaultNumberFormat(v) {
32
30
  return compact(v, { digits: Math.abs(v) >= 1e3 ? 1 : 2 });
33
31
  }
34
- const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
35
- function utcHeaderDate(d) {
36
- const date = `${DAYS[d.getUTCDay()]} ${monthName(d)} ${d.getUTCDate()} ${d.getUTCFullYear()}`;
37
- const ms = d.getTime() % DAY_MS;
38
- return ms === 0 ? date : `${date} ${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}`;
32
+ function bucketDay(d) {
33
+ const local = d.getHours() === 0 && d.getMinutes() === 0 && d.getSeconds() === 0;
34
+ return new Date(
35
+ local ? Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) : Math.floor(d.getTime() / DAY_MS) * DAY_MS
36
+ );
37
+ }
38
+ function utcHeaderDate(d, dayOnly = false) {
39
+ if (!Number.isFinite(d.getTime())) return NON_FINITE;
40
+ const at = dayOnly ? bucketDay(d) : d;
41
+ const date = dateFormat(void 0, {
42
+ weekday: "short",
43
+ day: "numeric",
44
+ month: "short",
45
+ year: "numeric",
46
+ timeZone: "UTC"
47
+ }).format(at);
48
+ if (dayOnly || d.getTime() % DAY_MS === 0) return date;
49
+ const clock = dateFormat(void 0, {
50
+ hour: "2-digit",
51
+ minute: "2-digit",
52
+ hourCycle: "h23",
53
+ timeZone: "UTC"
54
+ }).format(d);
55
+ return `${date} ${clock}`;
39
56
  }
40
57
  const DAY_MS = 864e5;
41
58
  function dateTicks(domain, count, stepMs) {
@@ -103,27 +120,18 @@ function visibleSeries(series, hidden) {
103
120
  );
104
121
  }
105
122
  function yGuide(opts) {
106
- const { cfg, axis, cls, side, grid, height } = opts;
123
+ const { cfg, axis, cls, side, grid } = opts;
107
124
  const ladder = LADDER[cls];
108
125
  const ticks = typeof cfg?.ticks === "object" ? { values: cfg.ticks } : { count: typeof cfg?.ticks === "number" ? cfg.ticks : ladder.yTicks };
109
126
  const gridLine = grid ? { grid: GRID_LINE } : {};
110
127
  if (cls === "micro") return { ...gridLine, axis: false };
111
- const inside = labelsInside(cls, height);
112
128
  return {
113
129
  ...gridLine,
114
130
  ...side === "right" && { side: "right" },
115
131
  axis: {
116
132
  line: false,
117
- ticks: { ...ticks, format: axis.format, line: false, ...inside && { size: 0, padding: 0 } },
118
- tickLabels: {
119
- fontSize: TICK_FONT,
120
- opacity: 1,
121
- ...inside && {
122
- anchor: side === "left" ? "start" : "end",
123
- dx: side === "left" ? INSIDE_LABEL_DX : -INSIDE_LABEL_DX,
124
- dy: INSIDE_LABEL_DY
125
- }
126
- }
133
+ ticks: { ...ticks, format: axis.format, line: false },
134
+ tickLabels: { fontSize: TICK_FONT, opacity: 1 }
127
135
  }
128
136
  };
129
137
  }
@@ -151,13 +159,12 @@ function xTickFormat(consumer, tickValues) {
151
159
  if (consumer) return consumer;
152
160
  if (tickValues.length === 0 || !tickValues.every((v) => v instanceof Date))
153
161
  return defaultFormatX;
154
- const dateFormat = dateTickFormat(tickValues);
155
- return (v) => v instanceof Date ? dateFormat(v) : defaultFormatX(v);
162
+ const dateFormat2 = dateTickFormat(tickValues);
163
+ return (v) => v instanceof Date ? dateFormat2(v) : defaultFormatX(v);
156
164
  }
157
165
  function xGuide(opts) {
158
- const { model, xTicks, cls, height } = opts;
166
+ const { model, xTicks, cls } = opts;
159
167
  const ladder = LADDER[cls];
160
- const inside = labelsInside(cls, height);
161
168
  const ticks = xTickPolicy(model, xTicks ?? ladder.xTicks);
162
169
  const format = xTickFormat(opts.format, "values" in ticks ? ticks.values : []);
163
170
  const [leftEdgeX, spanX] = !model.band && model.extent ? [model.extent[0], model.extent[1] - model.extent[0]] : [Number.NaN, Number.NaN];
@@ -170,13 +177,10 @@ function xGuide(opts) {
170
177
  opacity: 1,
171
178
  thin: true,
172
179
  // A label centred on a tick near the plot's left edge hangs left of it, under the gutter's
173
- // lowest y label (outside labels) or off the plot (inside labels, left margin locked to
174
- // zero): start-anchor it. `+value` is a Date's timestamp, or the number itself.
175
- anchor: ({ index, value }) => {
176
- const pinnedFirst = inside && index === 0;
180
+ // lowest y label: start-anchor it. `+value` is a Date's timestamp, or the number itself.
181
+ anchor: ({ value }) => {
177
182
  const share = (+value - leftEdgeX) / spanX;
178
- const onLeftEdge = share >= 0 && share <= LEFT_EDGE_SHARE;
179
- return pinnedFirst || onLeftEdge ? "start" : void 0;
183
+ return share >= 0 && share <= LEFT_EDGE_SHARE ? "start" : void 0;
180
184
  }
181
185
  }
182
186
  }
@@ -279,30 +283,39 @@ function overlayBounds(input) {
279
283
  for (const l of input.refLines ?? []) bounds[sideOf(l.axis)].push(l.value);
280
284
  return bounds;
281
285
  }
282
- function leftDomain(input, series, bounds) {
286
+ function leftDomain(input, series, bounds, tickCount) {
283
287
  const auto = input.y?.domain === void 0 || input.y.domain === "auto";
284
288
  if (auto && input.stack === "normalized") return normalizedDomain(input.data, series);
285
289
  return resolveYDomain(
286
290
  input.y,
287
291
  input.data,
288
292
  auto && input.stack ? stackedSeries(series) : series,
289
- bounds
293
+ bounds,
294
+ tickCount
290
295
  );
291
296
  }
292
- function resolveAxes(input, visible) {
297
+ function resolveAxes(input, visible, cls) {
293
298
  const hasY2 = input.y2 !== void 0;
299
+ const tickCount = (cfg) => typeof cfg?.ticks === "object" ? 0 : cfg?.ticks ?? LADDER[cls].yTicks;
294
300
  const bounds = overlayBounds(input);
295
301
  const onRight = (s) => hasY2 && s.axis === "right";
296
302
  const left = {
297
303
  domain: leftDomain(
298
304
  input,
299
305
  visible.filter((s) => !onRight(s)),
300
- bounds.left
306
+ bounds.left,
307
+ tickCount(input.y)
301
308
  ),
302
309
  format: input.y?.format ?? defaultNumberFormat
303
310
  };
304
311
  const right = hasY2 ? {
305
- domain: resolveYDomain(input.y2, input.data, visible.filter(onRight), bounds.right),
312
+ domain: resolveYDomain(
313
+ input.y2,
314
+ input.data,
315
+ visible.filter(onRight),
316
+ bounds.right,
317
+ tickCount(input.y2)
318
+ ),
306
319
  format: input.y2?.format ?? defaultNumberFormat
307
320
  } : null;
308
321
  return {
@@ -400,14 +413,24 @@ function underlayMarks(input, model, axes) {
400
413
  });
401
414
  return [...zones, ...xZones];
402
415
  }
403
- const REF_LABEL_TOP_SHARE = 0.12;
404
416
  const REF_LABEL_DX = 6;
405
417
  const REF_LABEL_DY_ABOVE = -5;
406
418
  const REF_LABEL_DY_BELOW = 11;
407
- const refLabelMark = (r, i, axes) => {
408
- const [lo, hi] = axes.axisOf(r.axis).domain;
409
- const nearTop = hi !== lo && (r.value - lo) / (hi - lo) > 1 - REF_LABEL_TOP_SHARE;
410
- const atStart = r.axis === "right" && axes.scaleId(r.axis) === "y2";
419
+ const refLabelMark = (r, i, ctx) => {
420
+ const { axes } = ctx;
421
+ const startFirst = r.axis === "right" && axes.scaleId(r.axis) === "y2";
422
+ const position = refLabelPosition({
423
+ pinned: r.labelPosition,
424
+ startFirst,
425
+ value: r.value,
426
+ domain: axes.axisOf(r.axis).domain,
427
+ plotWidth: ctx.plotWidth,
428
+ plotHeight: ctx.plotHeight,
429
+ label: r.label ?? "",
430
+ fontSize: VX.text.micro,
431
+ series: ctx.lines(r.axis)
432
+ });
433
+ const atStart = position.startsWith("start");
411
434
  return decorative(
412
435
  text([{ f: atStart ? 0 : 1 }], {
413
436
  id: `ref-${i}-label`,
@@ -420,11 +443,11 @@ const refLabelMark = (r, i, axes) => {
420
443
  fontSize: VX.text.micro,
421
444
  anchor: atStart ? "start" : "end",
422
445
  dx: atStart ? REF_LABEL_DX : -REF_LABEL_DX,
423
- dy: nearTop ? REF_LABEL_DY_BELOW : REF_LABEL_DY_ABOVE
446
+ dy: position.endsWith("above") ? REF_LABEL_DY_ABOVE : REF_LABEL_DY_BELOW
424
447
  })
425
448
  );
426
449
  };
427
- const refLineMarks = (input, axes) => (input.refLines ?? []).flatMap(
450
+ const refLineMarks = (input, axes, label) => (input.refLines ?? []).flatMap(
428
451
  (r, i) => (
429
452
  // A line that names itself in the legend can be toggled off there.
430
453
  input.hidden?.has(refLegendKey(i)) ? [] : [
@@ -436,12 +459,12 @@ const refLineMarks = (input, axes) => (input.refLines ?? []).flatMap(
436
459
  yScale: axes.scaleId(r.axis),
437
460
  ...r.dashed && { strokeDasharray: DASH }
438
461
  }),
439
- ...r.label ? [refLabelMark(r, i, axes)] : []
462
+ ...r.label ? [refLabelMark(r, i, label())] : []
440
463
  ]
441
464
  )
442
465
  );
443
466
  function buildScales(opts) {
444
- const { input, model, axes, formatX, cls, height, zoneScale } = opts;
467
+ const { input, model, axes, formatX, cls, zoneScale } = opts;
445
468
  const { left, right } = axes;
446
469
  return {
447
470
  x: {
@@ -450,8 +473,7 @@ function buildScales(opts) {
450
473
  model,
451
474
  xTicks: input.xTicks,
452
475
  format: input.formatX ? formatX : void 0,
453
- cls,
454
- height
476
+ cls
455
477
  })
456
478
  },
457
479
  y: {
@@ -460,7 +482,6 @@ function buildScales(opts) {
460
482
  cfg: input.y,
461
483
  axis: left,
462
484
  cls,
463
- height,
464
485
  side: "left",
465
486
  grid: input.y?.grid ?? true
466
487
  })
@@ -473,7 +494,6 @@ function buildScales(opts) {
473
494
  cfg: input.y2,
474
495
  axis: right,
475
496
  cls,
476
- height,
477
497
  side: "right",
478
498
  grid: input.y2?.grid ?? false
479
499
  })
@@ -484,11 +504,26 @@ function buildScales(opts) {
484
504
  }
485
505
  };
486
506
  }
487
- function tooltipHeader(input, formatX, v, d) {
507
+ function tooltipHeader(input, formatX, dayOnly, v, d) {
488
508
  if (input.tooltip && input.tooltip.formatHeader) return input.tooltip.formatHeader(v, d);
489
- if (v instanceof Date && !input.formatX) return utcHeaderDate(v);
509
+ if (v instanceof Date && !input.formatX) return utcHeaderDate(v, dayOnly);
490
510
  return formatX(v);
491
511
  }
512
+ function dayGranular(values) {
513
+ const times = values.flatMap((v) => v instanceof Date ? [v.getTime()] : []);
514
+ if (times.length === 0 || times.length !== values.length) return false;
515
+ const sorted = times.toSorted((a, b) => a - b);
516
+ if (sorted.length === 1) return sorted[0] % DAY_MS === 0;
517
+ return sorted.every((t, i) => i === 0 || t - sorted[i - 1] >= DAY_MS - HOUR_MS);
518
+ }
519
+ const HOUR_MS = 36e5;
520
+ const stem = (w) => w.toLowerCase().replace(/s$/, "");
521
+ function unitIsName(label, value) {
522
+ const words = value.trim().split(/\s+/);
523
+ const unit = words.at(-1);
524
+ if (words.length < 2 || unit === void 0 || stem(unit) !== stem(label.trim())) return null;
525
+ return words.slice(0, -1).join(" ");
526
+ }
492
527
  function rowsOf(input, visibleKeys) {
493
528
  const seriesBy = new Map(input.series.map((s) => [s.key, s]));
494
529
  return (key) => {
@@ -518,8 +553,14 @@ function cursorDotMarks(input, visible, axes) {
518
553
  return cursorDots(s, rows, axes.onRight(s) ? "y2" : void 0);
519
554
  });
520
555
  }
556
+ const stripAnchor = (points, { plot }) => {
557
+ const xs = points.map((p) => p.x);
558
+ return { x: (Math.min(...xs) + Math.max(...xs)) / 2, y: plot.y + plot.height };
559
+ };
560
+ const STRIP_TOOLTIP_PLACEMENT = ["bottom", "top"];
561
+ const STRIP_TOOLTIP_OFFSET = 8;
521
562
  function tooltipSpec(opts) {
522
- const { input, axes, visible, keys, visibleKeys, formatX } = opts;
563
+ const { input, axes, visible, keys, visibleKeys, formatX, dayOnly } = opts;
523
564
  const hidden = input.series.filter((s) => !visibleKeys.has(s.key));
524
565
  const rowSeries = (input.reverseRows ? visible.toReversed() : visible).filter(
525
566
  (s) => s.tooltip !== false
@@ -528,7 +569,8 @@ function tooltipSpec(opts) {
528
569
  use: quietWhileFollowing,
529
570
  ...followerOptions(input.tooltip, input.cursorGroup, input.chartId),
530
571
  portal,
531
- anchor: "group-center",
572
+ anchor: input.tooltipBelow ? stripAnchor : "group-center",
573
+ ...input.tooltipBelow && { placement: STRIP_TOOLTIP_PLACEMENT, offset: STRIP_TOOLTIP_OFFSET },
532
574
  content: (points) => {
533
575
  const primary = points[0];
534
576
  if (!primary) return { rows: [] };
@@ -539,17 +581,13 @@ function tooltipSpec(opts) {
539
581
  for (const s of rowSeries) {
540
582
  const v = s.getValue(d);
541
583
  if (v === null || !Number.isFinite(v)) continue;
542
- rows.push(
543
- seriesRow(
544
- s,
545
- s.formatValue ? s.formatValue(v, d) : axes.axisOf(axes.onRight(s) ? "right" : "left").format(v),
546
- input.highlighted === s.key
547
- )
548
- );
584
+ const text2 = s.formatValue ? s.formatValue(v, d) : axes.axisOf(axes.onRight(s) ? "right" : "left").format(v);
585
+ const bare = input.series.length === 1 ? unitIsName(s.label, text2) : null;
586
+ rows.push(seriesRow(s, bare ?? text2, input.highlighted === s.key));
549
587
  }
550
588
  const extra = (input.tooltip || void 0)?.rows?.(d, { visible, hidden }) ?? [];
551
589
  return {
552
- title: tooltipHeader(input, formatX, x, d),
590
+ title: tooltipHeader(input, formatX, dayOnly, x, d),
553
591
  rows: [...rows, ...extra.map(engineRow)]
554
592
  };
555
593
  }
@@ -569,18 +607,34 @@ function compileCartesian(input) {
569
607
  const visibleKeys = new Set(visible.map((s) => s.key));
570
608
  const keys = new Set(input.series.map((s) => s.key));
571
609
  const model = xScaleFor(input.data.map(input.x), input.band === true, input.xDomain);
572
- const axes = resolveAxes(input, visible);
573
- const under = underlayMarks(input, model, axes);
574
- const over = refLineMarks(input, axes);
575
- const dots = cursorDotMarks(input, visible, axes);
610
+ const byClass = /* @__PURE__ */ new Map();
611
+ const axesAt = (cls) => {
612
+ const found = byClass.get(cls);
613
+ if (found) return found;
614
+ const made = resolveAxes(input, visible, cls);
615
+ byClass.set(cls, made);
616
+ return made;
617
+ };
618
+ const shared = axesAt("regular");
619
+ const dots = cursorDotMarks(input, visible, shared);
576
620
  const rows = rowsOf(input, visibleKeys);
577
621
  const formatX = (v) => input.formatX ? input.formatX(v) : defaultFormatX(v);
578
622
  const gradients = input.series.flatMap(
579
- (s, i) => s.area ? [seriesAreaGradient(s, i, input, axes)] : []
623
+ (s, i) => s.area ? [seriesAreaGradient(s, i, input, shared)] : []
624
+ );
625
+ const dayOnly = dayGranular(model.values);
626
+ const names = (input.refLines ?? []).some((r) => r.label !== void 0 && r.label !== "");
627
+ const linesOn = (side) => visible.filter((s) => shared.onRight(s) === (side === "right" && shared.right !== null)).map(
628
+ (s) => rows(s.key).flatMap((r) => {
629
+ const fx = model.fraction(r.x);
630
+ return fx === null || r.y === null ? [] : [{ fx, y: r.y }];
631
+ })
580
632
  );
581
633
  const definition = {
582
634
  chart: ({ width, height }) => {
583
635
  const cls = resolveContainerClass(width);
636
+ const axes = axesAt(cls);
637
+ const access = plotAccess(definition, input.plot, MAIN_PANE);
584
638
  const kindMarks = input.marks(
585
639
  plotContext(
586
640
  {
@@ -596,24 +650,40 @@ function compileCartesian(input) {
596
650
  yDomain: axes.left.domain,
597
651
  y2Domain: axes.right?.domain
598
652
  },
599
- plotAccess(definition, input.plot, MAIN_PANE)
653
+ access
600
654
  )
601
655
  );
656
+ const under = underlayMarks(input, model, axes);
657
+ const over = refLineMarks(input, axes, () => {
658
+ access.read();
659
+ const size = access.size();
660
+ return {
661
+ plotWidth: size?.width ?? width,
662
+ plotHeight: size?.height ?? height,
663
+ lines: linesOn,
664
+ axes,
665
+ model
666
+ };
667
+ });
602
668
  return {
603
- marks: [...under, ...kindMarks, ...dots, ...over, crosshair({ x: CROSSHAIR, y: false })],
669
+ marks: [
670
+ ...under,
671
+ ...kindMarks,
672
+ ...dots,
673
+ ...over,
674
+ ...input.crosshair === false ? [] : [crosshair({ x: CROSSHAIR, y: false })]
675
+ ],
604
676
  scales: buildScales({
605
677
  input,
606
678
  model,
607
679
  axes,
608
680
  formatX,
609
681
  cls,
610
- height,
611
- zoneScale: under.length > 0 || (input.refLines ?? []).some((r) => r.label)
682
+ zoneScale: under.length > 0 || names
612
683
  }),
613
684
  theme: CHART_THEME,
614
685
  ...gradients.length > 0 && { gradients },
615
- clip: true,
616
- ...labelsInside(cls, height) && { margin: { left: 0, ...axes.right && { right: 0 } } }
686
+ clip: true
617
687
  };
618
688
  },
619
689
  // Followers resolve the leader's group, so they draw its dots; `quietWhileFollowing` mutes the
@@ -628,7 +698,7 @@ function compileCartesian(input) {
628
698
  mode: input.cursorResolution ?? "nearest",
629
699
  pin: input.coarse === true
630
700
  }),
631
- tooltip: input.tooltip === false ? false : tooltipSpec({ input, axes, visible, keys, visibleKeys, formatX })
701
+ tooltip: input.tooltip === false ? false : tooltipSpec({ input, axes: shared, visible, keys, visibleKeys, formatX, dayOnly })
632
702
  };
633
703
  return definition;
634
704
  }
@@ -638,6 +708,7 @@ export {
638
708
  compileCartesian,
639
709
  dashedSwatch,
640
710
  dateTicks,
711
+ dayGranular,
641
712
  defaultFormatX,
642
713
  defaultNumberFormat,
643
714
  engineRow,
@@ -13,18 +13,29 @@ export declare function endLabelAnchor(opts: {
13
13
  label: string;
14
14
  fontSize: number;
15
15
  }): EndLabelAnchor;
16
+ /** `Lines`' one naming switch: who names the series. */
17
+ export type LinesNaming = 'auto' | 'legend' | 'endLabels';
16
18
  export type EndLabel<T, X extends ChartX> = {
17
19
  series: ChartSeries<T>;
18
20
  row: PlotRow<T, X>;
19
21
  anchor: EndLabelAnchor;
22
+ /** A vertical shift in px (negative is up) that keeps this label clear of its neighbours. */
23
+ nudge: number;
20
24
  };
21
25
  /**
22
- * The end labels to draw: none off the wide class, with a right axis, with more than
23
- * {@link MAX_END_LABELS} lines, or when two would collide in pixels (against the plot's height).
24
- * A series whose last point the plot's own x scale cannot place, or places outside the plot
26
+ * Pushes labels apart: `ys` are the labels' heights in px from the plot's bottom, returned as the
27
+ * shift each needs (positive is up) so no two sit closer than {@link END_LABEL_MIN_GAP} and the
28
+ * topmost stays inside the plot. Order is kept.
29
+ */
30
+ export declare function spreadLabels(ys: readonly number[], plotHeight: number): number[];
31
+ /**
32
+ * The end labels to draw. `auto`: on the wide class only, with ≤ {@link MAX_END_LABELS} lines and
33
+ * no right axis; `endLabels`: at every width and any line count (still no right axis, whose
34
+ * series read another scale); `legend`: none. Labels that would collide are spread apart, never
35
+ * dropped. A series whose last point the plot's own x scale cannot place, or places outside the plot
25
36
  * (`plot.xFraction` outside [0, 1]: clipped by a narrower `xDomain`), has no label.
26
37
  */
27
- export declare function endLabelPlan<T, X extends ChartX>(plot: PlotContext<T, X>, lines: readonly ChartSeries<T>[]): EndLabel<T, X>[];
38
+ export declare function endLabelPlan<T, X extends ChartX>(plot: PlotContext<T, X>, lines: readonly ChartSeries<T>[], naming?: LinesNaming): EndLabel<T, X>[];
28
39
  /** The offset of a label from its point: right of it, level; or left of it and above. */
29
40
  export declare function endLabelOffset(anchor: EndLabelAnchor): {
30
41
  dx: number;
@@ -1 +1 @@
1
- {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/charts/labels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAgBpF,MAAM,M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ts) {
12
12
  const room = (1 - fraction) * plotWidth;
13
13
  return room >= label.length * fontSize * END_LABEL_GLYPH_EM + END_LABEL_DX ? "start" : "end";
14
14
  }
15
- function endLabelPlan(plot, lines) {
16
- if (plot.containerClass !== "wide" || plot.y2 !== void 0) return [];
17
- if (lines.length === 0 || lines.length > MAX_END_LABELS) return [];
15
+ function spreadLabels(ys, plotHeight) {
16
+ const order = ys.map((y, i) => i).toSorted((a, b) => ys[a] - ys[b]);
17
+ const placed = /* @__PURE__ */ new Map();
18
+ let floor = -Infinity;
19
+ for (const i of order) {
20
+ const at = Math.max(ys[i], floor);
21
+ placed.set(i, at);
22
+ floor = at + END_LABEL_MIN_GAP;
23
+ }
24
+ const top = plotHeight - END_LABEL_MIN_GAP / 2;
25
+ let ceiling = Infinity;
26
+ for (const i of order.toReversed()) {
27
+ const at = Math.min(placed.get(i), ceiling, top);
28
+ placed.set(i, at);
29
+ ceiling = at - END_LABEL_MIN_GAP;
30
+ }
31
+ return ys.map((y, i) => placed.get(i) - y);
32
+ }
33
+ function endLabelPlan(plot, lines, naming = "auto") {
34
+ if (naming === "legend" || plot.y2 !== void 0 || lines.length === 0) return [];
35
+ if (naming === "auto" && (plot.containerClass !== "wide" || lines.length > MAX_END_LABELS))
36
+ return [];
18
37
  const last = lines.flatMap((series) => {
19
38
  const row = plot.rows(series.key).findLast((r) => r.y !== null);
20
39
  if (row === void 0 || row.y === null) return [];
@@ -23,9 +42,11 @@ function endLabelPlan(plot, lines) {
23
42
  return [{ series, row, y: row.y, fraction }];
24
43
  });
25
44
  const [lo, hi] = plot.yDomain;
26
- const ys = last.map(({ y }) => (y - lo) / (hi - lo || 1) * plot.plotHeight).toSorted((a, b) => a - b);
27
- if (ys.some((y, i) => i > 0 && y - ys[i - 1] < END_LABEL_MIN_GAP)) return [];
28
- return last.map(({ series, row, fraction }) => ({
45
+ const shifts = spreadLabels(
46
+ last.map(({ y }) => (y - lo) / (hi - lo || 1) * plot.plotHeight),
47
+ plot.plotHeight
48
+ );
49
+ return last.map(({ series, row, fraction }, i) => ({
29
50
  series,
30
51
  row,
31
52
  anchor: endLabelAnchor({
@@ -33,7 +54,8 @@ function endLabelPlan(plot, lines) {
33
54
  plotWidth: plot.plotWidth,
34
55
  label: series.label,
35
56
  fontSize: VX.text.micro
36
- })
57
+ }),
58
+ nudge: 0 - shifts[i]
37
59
  }));
38
60
  }
39
61
  function endLabelOffset(anchor) {
@@ -41,7 +63,7 @@ function endLabelOffset(anchor) {
41
63
  }
42
64
  function endLabelMarks(plan) {
43
65
  return plan.map(
44
- ({ series, row, anchor }) => decorative(
66
+ ({ series, row, anchor, nudge }) => decorative(
45
67
  text([row], {
46
68
  id: `${series.key}-end-label`,
47
69
  x: rowX,
@@ -50,7 +72,8 @@ function endLabelMarks(plan) {
50
72
  fill: series.color,
51
73
  fontSize: VX.text.micro,
52
74
  anchor,
53
- ...endLabelOffset(anchor)
75
+ dx: endLabelOffset(anchor).dx,
76
+ dy: endLabelOffset(anchor).dy + nudge
54
77
  })
55
78
  )
56
79
  );
@@ -59,5 +82,6 @@ export {
59
82
  endLabelAnchor,
60
83
  endLabelMarks,
61
84
  endLabelOffset,
62
- endLabelPlan
85
+ endLabelPlan,
86
+ spreadLabels
63
87
  };
@@ -50,6 +50,8 @@ export type ChartLegendProps<T> = {
50
50
  onHighlight: (key: string | null) => void;
51
51
  /** Keeps the legend's box but shows and offers nothing: a chart with no marks names no series. */
52
52
  concealed?: boolean;
53
+ /** `auto` mode only: gone from the wide class up, where end labels name the lines (CSS). */
54
+ hideAtWide?: boolean;
53
55
  };
54
56
  export declare function ChartLegend<T>(props: ChartLegendProps<T>): ReactElement | null;
55
57
  //# sourceMappingURL=legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/charts/legend.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,KA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and tooltip are one size, so a chart card has at most three.
22
+ fontSize: VX.text.micro,
22
23
  color: VX.ink2,
23
24
  lineHeight: 1.35
24
25
  };
@@ -94,31 +95,15 @@ function Swatch({ s, mode }) {
94
95
  /* @__PURE__ */ jsx(Swatch, { s, mode: "chips" })
95
96
  ] });
96
97
  if ((s.mark ?? "line") === "line") return /* @__PURE__ */ jsx(LineSwatch, { s, compact: mode === "dots" });
97
- if (mode === "dots")
98
- return /* @__PURE__ */ jsx(
99
- "span",
100
- {
101
- "aria-hidden": true,
102
- className: classes.dot,
103
- style: {
104
- width: 8,
105
- height: 8,
106
- // theme-allow raw-surface — a legend dot is a circle, not a surface corner
107
- borderRadius: "50%",
108
- background: swatchFill(s),
109
- opacity: s.fillOpacity ?? 1,
110
- flex: "none"
111
- }
112
- }
113
- );
98
+ const size = mode === "dots" ? 8 : 10;
114
99
  return /* @__PURE__ */ jsx(
115
100
  "span",
116
101
  {
117
102
  "aria-hidden": true,
118
- className: classes.chip,
103
+ className: mode === "dots" ? classes.dot : classes.chip,
119
104
  style: {
120
- width: 10,
121
- height: 10,
105
+ width: size,
106
+ height: size,
122
107
  // theme-allow raw-surface — swatch geometry, not a surface corner
123
108
  borderRadius: 2,
124
109
  background: swatchFill(s),
@@ -139,6 +124,7 @@ function ChartLegend(props) {
139
124
  "data-basalt-chart-legend": props.mode,
140
125
  ...props.concealed && { "aria-hidden": true },
141
126
  ...auto && { className: classes.auto },
127
+ ...auto && props.hideAtWide && { "data-hide-wide": "" },
142
128
  style: rowLayout(props.mode, props.concealed === true),
143
129
  children: groups.map((group, gi) => [
144
130
  gi > 0 && /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: dividerStyle }, `divider-${gi}`),
@@ -26,7 +26,7 @@ function lineMark(plot, s) {
26
26
  stroke: s.color,
27
27
  strokeWidth: s.strokeWidth ?? LINE_STROKE_WIDTH,
28
28
  strokeOpacity: (s.strokeOpacity ?? 1) * emphasis(plot.highlighted, s),
29
- curve: chartCurve(s.curve ?? "monotone"),
29
+ curve: chartCurve(s.curve ?? "linear"),
30
30
  ...s.dash === "dashed" && { strokeDasharray: DASH },
31
31
  ...yScale !== void 0 && { yScale }
32
32
  });
@@ -48,8 +48,6 @@ export declare const paneY: (opts: {
48
48
  format: (v: number) => string;
49
49
  ticks: number;
50
50
  cls: ContainerClass;
51
- /** The whole chart's height ({@link chartHeightOf}). */
52
- height: number;
53
51
  }) => StoredChartSpec["scales"][string];
54
52
  type ChartScale = NonNullable<StoredChartSpec['scales'][string]>['scale'];
55
53
  /** The shared x axis (drawn on the bottom pane only): the rung's ticks and format. */
@@ -59,11 +57,7 @@ export declare const paneX: <X extends ChartX>(opts: {
59
57
  /** A consumer's x format; absent, the span-aware default ({@link xTickFormat}). */
60
58
  format?: ((v: ChartValue) => string) | undefined;
61
59
  cls: ContainerClass;
62
- /** The whole chart's height ({@link chartHeightOf}). */
63
- height: number;
64
60
  }) => StoredChartSpec["scales"][string];
65
- /** The whole chart's height from one pane's: a pane gets `share` of the height less the gap. */
66
- export declare const chartHeightOf: (paneHeight: number, share: number, gap: number) => number;
67
61
  /** One row per datum for a series: a `null` or non-finite value is kept as a gap. */
68
62
  export declare function rowsOf<T, X extends ChartX>(data: readonly T[], x: (d: T) => X, s: ChartSeries<T>): PlotRow<T, X>[];
69
63
  export declare function PanelRung<T, X extends ChartX>(props: PanelRungProps<T, X>): ReactElement;