basalt-ui 2.16.0 → 2.18.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 (146) hide show
  1. package/CHANGELOG.md +165 -124
  2. package/MIGRATING.md +133 -15
  3. package/agent/agents/basalt-design-reviewer.md +2 -2
  4. package/agent/skills/basalt-design/SKILL.md +3 -3
  5. package/configs/oxlint-plugin.js +2 -2
  6. package/dist/charts/Donut.d.ts.map +1 -1
  7. package/dist/charts/Donut.js +2 -2
  8. package/dist/charts/DualPanel.js +2 -2
  9. package/dist/charts/Heatmap.d.ts.map +1 -1
  10. package/dist/charts/Heatmap.js +2 -2
  11. package/dist/charts/MirroredBars.js +2 -2
  12. package/dist/charts/Sparkline.d.ts +4 -2
  13. package/dist/charts/Sparkline.d.ts.map +1 -1
  14. package/dist/charts/Sparkline.js +3 -3
  15. package/dist/charts/compile.d.ts +8 -3
  16. package/dist/charts/compile.d.ts.map +1 -1
  17. package/dist/charts/compile.js +19 -9
  18. package/dist/charts/cursor.d.ts +14 -1
  19. package/dist/charts/cursor.d.ts.map +1 -1
  20. package/dist/charts/cursor.js +29 -3
  21. package/dist/charts/date-tick-format.d.ts +17 -0
  22. package/dist/charts/date-tick-format.d.ts.map +1 -0
  23. package/dist/charts/date-tick-format.js +81 -0
  24. package/dist/charts/panel.d.ts +2 -1
  25. package/dist/charts/panel.d.ts.map +1 -1
  26. package/dist/charts/panel.js +3 -2
  27. package/dist/charts/types.d.ts +5 -1
  28. package/dist/charts/types.d.ts.map +1 -1
  29. package/dist/cli/help.d.ts +1 -0
  30. package/dist/cli/help.d.ts.map +1 -1
  31. package/dist/cli/help.js +8 -2
  32. package/dist/cli/shot/capture.d.ts +28 -1
  33. package/dist/cli/shot/capture.d.ts.map +1 -1
  34. package/dist/cli/shot/capture.js +96 -13
  35. package/dist/cli/shot/index.d.ts +10 -1
  36. package/dist/cli/shot/index.d.ts.map +1 -1
  37. package/dist/cli/shot/index.js +40 -5
  38. package/dist/cli/shot/playwright.d.ts +4 -0
  39. package/dist/cli/shot/playwright.d.ts.map +1 -1
  40. package/dist/cli/shot/real-data.d.ts +35 -0
  41. package/dist/cli/shot/real-data.d.ts.map +1 -0
  42. package/dist/cli/shot/real-data.js +120 -0
  43. package/dist/cli/shot/serve.d.ts +2 -2
  44. package/dist/cli/shot/serve.d.ts.map +1 -1
  45. package/dist/cli/shot/serve.js +16 -2
  46. package/dist/dashboard/bar-list.d.ts +29 -0
  47. package/dist/dashboard/bar-list.d.ts.map +1 -0
  48. package/dist/dashboard/bar-list.js +52 -0
  49. package/dist/dashboard/bar-list.module.css +73 -0
  50. package/dist/dashboard/bar-list.module.css.d.ts +16 -0
  51. package/dist/dashboard/delta-badge.d.ts +2 -2
  52. package/dist/dashboard/delta-badge.d.ts.map +1 -1
  53. package/dist/dashboard/delta-badge.js +12 -14
  54. package/dist/dashboard/index.d.ts +2 -0
  55. package/dist/dashboard/index.d.ts.map +1 -1
  56. package/dist/dashboard/index.js +4 -0
  57. package/dist/dashboard/meter-model.d.ts +78 -0
  58. package/dist/dashboard/meter-model.d.ts.map +1 -0
  59. package/dist/dashboard/meter-model.js +91 -0
  60. package/dist/dashboard/meter-parts.d.ts +42 -0
  61. package/dist/dashboard/meter-parts.d.ts.map +1 -0
  62. package/dist/dashboard/meter-parts.js +163 -0
  63. package/dist/dashboard/meter.d.ts +112 -0
  64. package/dist/dashboard/meter.d.ts.map +1 -0
  65. package/dist/dashboard/meter.js +43 -0
  66. package/dist/dashboard/meter.module.css +150 -0
  67. package/dist/dashboard/meter.module.css.d.ts +28 -0
  68. package/dist/dashboard/query-state.d.ts +35 -0
  69. package/dist/dashboard/query-state.d.ts.map +1 -1
  70. package/dist/dashboard/query-state.js +12 -1
  71. package/dist/dashboard/scale.d.ts +9 -0
  72. package/dist/dashboard/scale.d.ts.map +1 -0
  73. package/dist/dashboard/scale.js +10 -0
  74. package/dist/dashboard/stat-card-parts.d.ts +40 -0
  75. package/dist/dashboard/stat-card-parts.d.ts.map +1 -0
  76. package/dist/dashboard/stat-card-parts.js +55 -0
  77. package/dist/dashboard/stat-card.d.ts +46 -34
  78. package/dist/dashboard/stat-card.d.ts.map +1 -1
  79. package/dist/dashboard/stat-card.js +148 -79
  80. package/dist/dashboard/stat-card.module.css +220 -7
  81. package/dist/dashboard/stat-card.module.css.d.ts +20 -0
  82. package/dist/dashboard/widget-header.d.ts.map +1 -1
  83. package/dist/dashboard/widget-header.js +73 -9
  84. package/dist/dashboard/widget-header.module.css +25 -17
  85. package/dist/guard/index.js +2 -2
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +5 -1
  89. package/dist/theme/chrome-vars.d.ts +82 -0
  90. package/dist/theme/chrome-vars.d.ts.map +1 -0
  91. package/dist/theme/chrome-vars.js +36 -0
  92. package/dist/theme/controls.module.css +20 -1
  93. package/dist/theme/controls.module.css.d.ts +1 -0
  94. package/dist/theme/index.d.ts.map +1 -1
  95. package/dist/theme/index.js +30 -33
  96. package/dist/tokens/derive.d.ts +11 -1
  97. package/dist/tokens/derive.d.ts.map +1 -1
  98. package/dist/tokens/derive.js +9 -24
  99. package/dist/tokens/status-text.d.ts +26 -0
  100. package/dist/tokens/status-text.d.ts.map +1 -0
  101. package/dist/tokens/status-text.js +68 -0
  102. package/llms.txt +36 -4
  103. package/package.json +1 -1
  104. package/src/charts/Donut.tsx +2 -2
  105. package/src/charts/DualPanel.tsx +2 -2
  106. package/src/charts/Heatmap.tsx +2 -2
  107. package/src/charts/MirroredBars.tsx +2 -2
  108. package/src/charts/Sparkline.tsx +7 -5
  109. package/src/charts/compile.ts +31 -11
  110. package/src/charts/cursor.ts +48 -3
  111. package/src/charts/date-tick-format.ts +132 -0
  112. package/src/charts/panel.tsx +5 -3
  113. package/src/charts/types.ts +5 -1
  114. package/src/cli/help.ts +22 -2
  115. package/src/cli/shot/capture.ts +133 -12
  116. package/src/cli/shot/index.ts +50 -4
  117. package/src/cli/shot/playwright.ts +1 -1
  118. package/src/cli/shot/real-data.ts +165 -0
  119. package/src/cli/shot/serve.ts +28 -3
  120. package/src/dashboard/bar-list.module.css +73 -0
  121. package/src/dashboard/bar-list.module.css.d.ts +16 -0
  122. package/src/dashboard/bar-list.tsx +112 -0
  123. package/src/dashboard/delta-badge.tsx +24 -18
  124. package/src/dashboard/index.ts +2 -0
  125. package/src/dashboard/meter-model.ts +161 -0
  126. package/src/dashboard/meter-parts.tsx +223 -0
  127. package/src/dashboard/meter.module.css +150 -0
  128. package/src/dashboard/meter.module.css.d.ts +28 -0
  129. package/src/dashboard/meter.tsx +162 -0
  130. package/src/dashboard/query-state.tsx +38 -0
  131. package/src/dashboard/scale.ts +13 -0
  132. package/src/dashboard/stat-card-parts.tsx +108 -0
  133. package/src/dashboard/stat-card.module.css +220 -7
  134. package/src/dashboard/stat-card.module.css.d.ts +20 -0
  135. package/src/dashboard/stat-card.tsx +282 -174
  136. package/src/dashboard/widget-header.module.css +25 -17
  137. package/src/dashboard/widget-header.tsx +103 -7
  138. package/src/guard/index.ts +2 -2
  139. package/src/index.ts +4 -0
  140. package/src/theme/__snapshots__/plain-theme.test.ts.snap +128 -40
  141. package/src/theme/chrome-vars.ts +111 -0
  142. package/src/theme/controls.module.css +20 -1
  143. package/src/theme/controls.module.css.d.ts +1 -0
  144. package/src/theme/index.ts +39 -101
  145. package/src/tokens/derive.ts +19 -26
  146. package/src/tokens/status-text.ts +85 -0
@@ -1,20 +1,26 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Box, Card, VisuallyHidden } from "@mantine/core";
3
- import { useEffect, useRef, useState } from "react";
4
- import { WidgetHeader } from "./widget-header.js";
5
- import { CtlSlot } from "../theme/index.js";
3
+ import { useEffect, useState } from "react";
4
+ import {
5
+ BreakdownSkeleton,
6
+ CaptionRow,
7
+ FooterSkeleton,
8
+ Foot,
9
+ ValueSkeleton,
10
+ VisualSkeleton,
11
+ rightSlotStyle
12
+ } from "./stat-card-parts.js";
13
+ import { DeltaBadge } from "./delta-badge.js";
6
14
  import { VX } from "../tokens/index.js";
7
15
  import { cx } from "../common/props.js";
8
- import { QueryState } from "./query-state.js";
9
- import { assertQueryStateLike } from "../common/query-state-like.js";
16
+ import { ErrorState, QueryState, resolveQueryBranch } from "./query-state.js";
10
17
  import classes from "./stat-card.module.css";
11
18
  const SPARKLINE_RIGHT_WIDTH = 72;
12
- const SPARKLINE_RIGHT_HEIGHT = 26;
19
+ const SPARKLINE_HEIGHT = 22;
13
20
  function useSlotWidth(active) {
14
21
  const [width, setWidth] = useState(0);
15
- const nodeRef = useRef(null);
22
+ const [node, setNode] = useState(null);
16
23
  useEffect(() => {
17
- const node = nodeRef.current;
18
24
  if (!active || node === null) return;
19
25
  const measure = () => {
20
26
  setWidth(node.getBoundingClientRect().width);
@@ -26,20 +32,8 @@ function useSlotWidth(active) {
26
32
  return () => {
27
33
  observer.disconnect();
28
34
  };
29
- }, [active]);
30
- return {
31
- ref: (node) => {
32
- nodeRef.current = node;
33
- },
34
- width
35
- };
36
- }
37
- function sparklineState(query) {
38
- if (query === void 0) return void 0;
39
- assertQueryStateLike("StatCard", query);
40
- if (query.data !== void 0) return void 0;
41
- if (query.isError) return { error: query.error ?? true };
42
- return query.fetchStatus === "idle" ? void 0 : { pending: true };
35
+ }, [active, node]);
36
+ return { ref: setNode, width };
43
37
  }
44
38
  const TONE_RAIL_WIDTH = 3;
45
39
  const TONE_LABEL = {
@@ -47,15 +41,65 @@ const TONE_LABEL = {
47
41
  warn: "Past the warning threshold",
48
42
  bad: "Past the severe threshold"
49
43
  };
44
+ function renderValueBody({
45
+ pending,
46
+ resolved,
47
+ figure,
48
+ emptyText
49
+ }) {
50
+ if (resolved === void 0) return pending ? /* @__PURE__ */ jsx(ValueSkeleton, {}) : figure;
51
+ if (pending && resolved.kind !== "error") return /* @__PURE__ */ jsx(ValueSkeleton, {});
52
+ switch (resolved.kind) {
53
+ case "pending":
54
+ return /* @__PURE__ */ jsx(ValueSkeleton, {});
55
+ case "error":
56
+ return /* @__PURE__ */ jsx(
57
+ ErrorState,
58
+ {
59
+ error: resolved.error,
60
+ title: "Could not load this figure",
61
+ tier: "section",
62
+ onRetry: () => void resolved.query.refetch(),
63
+ retrying: resolved.query.fetchStatus === "fetching"
64
+ }
65
+ );
66
+ case "empty":
67
+ return /* @__PURE__ */ jsx("p", { className: classes.empty, children: emptyText });
68
+ case "ready":
69
+ return figure;
70
+ default:
71
+ return resolved;
72
+ }
73
+ }
74
+ function renderVisualNode({
75
+ show,
76
+ pending,
77
+ slot
78
+ }) {
79
+ if (!show) return null;
80
+ if (pending) return /* @__PURE__ */ jsx(VisualSkeleton, {});
81
+ return slot;
82
+ }
83
+ function renderFooterNode({
84
+ subtitle,
85
+ pending
86
+ }) {
87
+ if (subtitle === void 0) return null;
88
+ if (pending) return /* @__PURE__ */ jsx(FooterSkeleton, {});
89
+ return /* @__PURE__ */ jsx("p", { className: classes.footer, title: subtitle, children: subtitle });
90
+ }
50
91
  function StatCard({
51
92
  title,
52
93
  icon,
53
- subtitle,
54
94
  info,
95
+ qualifier,
96
+ subtitle,
55
97
  value,
56
98
  unit,
57
99
  breakdown,
58
100
  query,
101
+ loading = false,
102
+ emptyText = "No data for this period",
59
103
  delta,
60
104
  deltaPeriod,
61
105
  deltaPolarity,
@@ -72,12 +116,11 @@ function StatCard({
72
116
  const isRender = typeof sparkline === "function";
73
117
  const bleeds = sparklinePlacement === "bleed";
74
118
  const { ref: slotRef, width: slotWidth } = useSlotWidth(isRender);
75
- const state = sparklineState(query);
76
- const measured = {
77
- width: slotWidth,
78
- height: SPARKLINE_RIGHT_HEIGHT,
79
- ...state !== void 0 && { state }
80
- };
119
+ const resolved = query === void 0 ? void 0 : resolveQueryBranch(query, "StatCard");
120
+ const kind = resolved?.kind ?? "ready";
121
+ const pending = loading || kind === "pending";
122
+ const ready = !pending && kind === "ready";
123
+ const measured = { width: slotWidth, height: SPARKLINE_HEIGHT };
81
124
  const breakdownRows = breakdown === void 0 || breakdown.length === 0 ? null : /* @__PURE__ */ jsx("dl", { className: classes.breakdown, children: breakdown.map((row) => /* @__PURE__ */ jsxs(
82
125
  "div",
83
126
  {
@@ -91,7 +134,7 @@ function StatCard({
91
134
  row.label
92
135
  )) });
93
136
  const breakdownContent = query === void 0 ? breakdownRows : /* @__PURE__ */ jsx(QueryState, { query, tier: "section", children: breakdownRows });
94
- const sparklineNode = sparkline === void 0 ? null : /* @__PURE__ */ jsx(
137
+ const sparklineSlot = !ready || sparkline === void 0 ? null : /* @__PURE__ */ jsx(
95
138
  "div",
96
139
  {
97
140
  ref: slotRef,
@@ -99,21 +142,33 @@ function StatCard({
99
142
  bleeds ? classes.sparklineBleed : classes.sparklineRight,
100
143
  classNames?.sparkline
101
144
  ),
102
- ...!bleeds && {
103
- // CUSTOM PROPERTIES, not `flexBasis`/`height` directly. A React inline style beats every
104
- // stylesheet rule, so an inline `flexBasis: 72` also applied in a narrow card — where `'right'`
105
- // collapses `.metricsRow` to a COLUMN and flex-basis is therefore the main-axis HEIGHT.
106
- // The mobile sparkline rendered in a 72px-tall box holding 26px of bars, which is the dead
107
- // band under every KPI value on a phone. Handed to CSS as values instead, the media query
108
- // can reset the box and the numbers still live in one place.
109
- style: {
110
- "--basalt-stat-sparkline-w": `${SPARKLINE_RIGHT_WIDTH}px`,
111
- "--basalt-stat-sparkline-h": `${SPARKLINE_RIGHT_HEIGHT}px`
112
- }
113
- },
145
+ ...!bleeds && { style: rightSlotStyle(SPARKLINE_RIGHT_WIDTH, SPARKLINE_HEIGHT) },
114
146
  children: isRender ? measured.width > 0 && sparkline(measured) : sparkline
115
147
  }
116
148
  );
149
+ const figure = /* @__PURE__ */ jsxs("div", { className: classes.valueRow, children: [
150
+ /* @__PURE__ */ jsxs("span", { className: classes.figure, children: [
151
+ /* @__PURE__ */ jsx("span", { className: classes.value, children: value }),
152
+ unit !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.unit, children: unit })
153
+ ] }),
154
+ delta !== void 0 && /* @__PURE__ */ jsx(
155
+ DeltaBadge,
156
+ {
157
+ value: delta,
158
+ period: deltaPeriod,
159
+ ...deltaPolarity !== void 0 && { polarity: deltaPolarity },
160
+ ...deltaFormat !== void 0 && { format: deltaFormat },
161
+ ...deltaGlyph !== void 0 && { withGlyph: deltaGlyph }
162
+ }
163
+ )
164
+ ] });
165
+ const valueBody = renderValueBody({ pending, resolved, figure, emptyText });
166
+ const breakdownCount = breakdown?.length ?? 0;
167
+ const hasBreakdown = breakdownCount > 0;
168
+ const rightRow = !bleeds && (ready ? breakdownContent !== null || sparklineSlot !== null : pending && (hasBreakdown || sparkline !== void 0));
169
+ const hasBleedVisual = sparkline !== void 0 && bleeds;
170
+ const visualNode = renderVisualNode({ show: hasBleedVisual, pending, slot: sparklineSlot });
171
+ const footerNode = renderFooterNode({ subtitle, pending });
117
172
  return /* @__PURE__ */ jsxs(
118
173
  Card,
119
174
  {
@@ -127,21 +182,16 @@ function StatCard({
127
182
  //
128
183
  // `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
129
184
  // element's own `box-shadow` renders outside its border box and is NOT clipped by its own
130
- // `overflow`, so the shadow-card ring is unaffected (verified — only an ANCESTOR's overflow
131
- // clips a descendant's shadow). Mantine's Card root already sets `overflow: hidden`; this
132
- // is explicit for intent.
185
+ // `overflow`, so the shadow-card ring is unaffected.
133
186
  //
134
- // NO `minHeight`. It was 118px, which is ~25px of dead space under a card holding a title
135
- // row, a hero row and a 26px trend — and it was dead space the card could not use, since the
136
- // body is `height: 100%` and the sparkline is `margin-top: auto`. The content is what states
137
- // the height now (~88-96px), and four cards in a `SimpleGrid` still match because a grid row
138
- // stretches its items.
187
+ // NO `minHeight`: the content states the height (the foot reserves its own), and cards in a
188
+ // grid row stretch to the tallest.
139
189
  padding: "var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)",
140
190
  overflow: "hidden",
141
191
  // Anchors the tone rail. Set unconditionally so a card's stacking context does not change
142
192
  // depending on whether it happens to have crossed a threshold this render.
143
193
  position: "relative",
144
- // The card's own width drives its chrome (`widget-header.module.css`, `.metricsRow`).
194
+ // The card's own width drives its chrome (`stat-card.module.css`).
145
195
  containerType: "inline-size",
146
196
  containerName: "basalt-card",
147
197
  ...style
@@ -168,35 +218,54 @@ function StatCard({
168
218
  }
169
219
  )
170
220
  ] }),
171
- /* @__PURE__ */ jsxs("div", { className: cx(classes.body, classNames?.body), "data-placement": sparklinePlacement, children: [
172
- /* @__PURE__ */ jsxs("div", { className: cx(classes.header, classNames?.header), children: [
173
- /* @__PURE__ */ jsx(
174
- WidgetHeader,
175
- {
176
- tier: "widget",
177
- title,
178
- ...icon !== void 0 && { icon },
179
- ...subtitle !== void 0 && { subtitle },
180
- ...info !== void 0 && { info },
181
- value,
182
- ...unit !== void 0 && { unit },
183
- ...delta !== void 0 && { delta },
184
- ...deltaPeriod !== void 0 && { deltaPeriod },
185
- ...deltaPolarity !== void 0 && { deltaPolarity },
186
- ...deltaFormat !== void 0 && { deltaFormat },
187
- ...deltaGlyph !== void 0 && { deltaGlyph },
188
- ...actions !== void 0 && {
189
- actions: /* @__PURE__ */ jsx(CtlSlot, { tier: "widget", children: actions })
221
+ /* @__PURE__ */ jsxs(
222
+ "div",
223
+ {
224
+ className: cx(classes.body, classNames?.body),
225
+ "data-placement": sparklinePlacement,
226
+ ...pending && { "aria-busy": true },
227
+ children: [
228
+ pending && /* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${title}` }),
229
+ /* @__PURE__ */ jsxs("div", { className: cx(classes.header, classNames?.header), children: [
230
+ /* @__PURE__ */ jsx(
231
+ CaptionRow,
232
+ {
233
+ title,
234
+ ...icon !== void 0 && { icon },
235
+ ...info !== void 0 && { info },
236
+ ...qualifier !== void 0 && { qualifier },
237
+ ...actions !== void 0 && { actions }
238
+ }
239
+ ),
240
+ valueBody,
241
+ bleeds && (pending ? hasBreakdown && /* @__PURE__ */ jsx(BreakdownSkeleton, { rows: breakdownCount }) : ready && breakdownContent)
242
+ ] }),
243
+ rightRow && /* @__PURE__ */ jsx("div", { className: classes.metricsRow, children: ready ? /* @__PURE__ */ jsxs(Fragment, { children: [
244
+ breakdownContent,
245
+ sparklineSlot
246
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
247
+ hasBreakdown && /* @__PURE__ */ jsx(BreakdownSkeleton, { rows: breakdownCount }),
248
+ sparkline !== void 0 && /* @__PURE__ */ jsx(
249
+ "div",
250
+ {
251
+ className: classes.sparklineRight,
252
+ style: rightSlotStyle(SPARKLINE_RIGHT_WIDTH, SPARKLINE_HEIGHT),
253
+ children: /* @__PURE__ */ jsx(VisualSkeleton, {})
254
+ }
255
+ )
256
+ ] }) }),
257
+ /* @__PURE__ */ jsx(
258
+ Foot,
259
+ {
260
+ reserve: hasBleedVisual || subtitle !== void 0,
261
+ visualBand: bleeds,
262
+ visualNode,
263
+ footerNode
190
264
  }
191
- }
192
- ),
193
- bleeds && breakdownContent
194
- ] }),
195
- bleeds ? sparklineNode : (breakdownContent !== null || sparklineNode !== null) && /* @__PURE__ */ jsxs("div", { className: classes.metricsRow, children: [
196
- breakdownContent,
197
- sparklineNode
198
- ] })
199
- ] })
265
+ )
266
+ ]
267
+ }
268
+ )
200
269
  ]
201
270
  }
202
271
  );
@@ -5,7 +5,18 @@
5
5
  * than 480px (`container: basalt-card`, set on the Card root in `stat-card.tsx`).
6
6
  */
7
7
 
8
+ /* Foot geometry, single-sourced: the visual slot (SPEC § 6.2: 22), one `sm` footer line (20) and the
9
+ * 4px between them. The foot reserves all three whenever it exists (`.foot`), which is what keeps a
10
+ * card with a sparkline and one without a footer the same height. */
8
11
  .body {
12
+ --basalt-stat-visual-h: 1.375rem;
13
+ --basalt-stat-footer-h: 1.25rem;
14
+ --basalt-stat-foot-gap: 0.25rem;
15
+ /* The figure's size and line box, in one place: `.value`, the empty line and the pending skeleton
16
+ * all read them, so nothing moves when a reading lands. */
17
+ --basalt-stat-figure-size: var(--vx-text-kpi);
18
+ --basalt-stat-figure-line: 1.25;
19
+ --basalt-stat-figure-h: calc(var(--basalt-stat-figure-size) * var(--basalt-stat-figure-line));
9
20
  display: flex;
10
21
  flex-direction: column;
11
22
  gap: var(--vx-space-stat-card-gap);
@@ -16,6 +27,210 @@
16
27
  min-width: 0;
17
28
  }
18
29
 
30
+ /* ── caption row ─────────────────────────────────────────────────────────────────────────────── */
31
+
32
+ /* `captionMain` takes the row; the actions slot sits at its end. The row is 24px (the widget control
33
+ * step) so a card with a kebab is the same height as one without. */
34
+ .captionRow {
35
+ display: flex;
36
+ align-items: flex-start;
37
+ gap: var(--vx-space-control-gap, 0.375rem);
38
+ min-height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
39
+ }
40
+
41
+ /* Wraps on purpose: when caption + info + qualifier do not fit, the qualifier drops UNDER the caption
42
+ * instead of truncating either — the container's width decides, never the viewport's. */
43
+ .captionMain {
44
+ display: flex;
45
+ flex: 1 1 0;
46
+ flex-wrap: wrap;
47
+ align-items: center;
48
+ /* Caption left, qualifier right; a qualifier that wraps is alone on its line, so it sits at the start. */
49
+ justify-content: space-between;
50
+ column-gap: var(--vx-space-control-gap, 0.375rem);
51
+ min-width: 0;
52
+ min-height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
53
+ }
54
+
55
+ /* Caption and info glyph travel together: the pair is the first item of the row. */
56
+ .lead {
57
+ display: inline-flex;
58
+ align-items: center;
59
+ column-gap: var(--vx-space-control-gap, 0.375rem);
60
+ min-width: 0;
61
+ }
62
+
63
+ .caption {
64
+ display: inline-flex;
65
+ align-items: center;
66
+ gap: 5px;
67
+ margin: 0;
68
+ min-width: 0;
69
+ font-family: var(--basalt-font-mono);
70
+ font-size: var(--vx-text-micro);
71
+ font-weight: 500;
72
+ text-transform: uppercase;
73
+ letter-spacing: 0.06em;
74
+ color: var(--vx-faint);
75
+ }
76
+
77
+ .captionText {
78
+ overflow: hidden;
79
+ text-overflow: ellipsis;
80
+ white-space: nowrap;
81
+ }
82
+
83
+ .icon {
84
+ color: var(--vx-faint);
85
+ --vx-space-icon-size: 0.875rem;
86
+ }
87
+
88
+ .qualifier {
89
+ font-family: var(--basalt-font-mono);
90
+ font-size: var(--vx-text-micro);
91
+ color: var(--vx-muted);
92
+ /* Wraps before it is ever cut: a qualifier too long for the row on its own line breaks its words. */
93
+ overflow-wrap: anywhere;
94
+ min-width: 0;
95
+ }
96
+
97
+ /* Law C15: the shared hit overlay; `--vx-hit-gap` caps the expansion at the control gap. */
98
+ .actions {
99
+ --vx-hit-gap: var(--vx-space-control-gap);
100
+ display: inline-flex;
101
+ flex: none;
102
+ align-items: center;
103
+ gap: var(--vx-space-control-gap, 0.375rem);
104
+ }
105
+
106
+ /* ── value row ───────────────────────────────────────────────────────────────────────────────── */
107
+
108
+ /* The figure and its unit share a baseline; the delta follows them, on the same baseline, and wraps
109
+ * under when the card is too narrow for all three. Three sizes only: micro, sm, hero. */
110
+ .valueRow {
111
+ display: flex;
112
+ flex-wrap: wrap;
113
+ align-items: baseline;
114
+ column-gap: var(--vx-space-stack-sm);
115
+ row-gap: 2px;
116
+ min-width: 0;
117
+ }
118
+
119
+ .figure {
120
+ display: inline-flex;
121
+ align-items: baseline;
122
+ gap: 4px;
123
+ min-width: 0;
124
+ }
125
+
126
+ /* NEVER truncated: the numeral IS the content. It shrinks with the card's own width instead (the
127
+ * `cqi` clamp below), and `overflow-wrap` breaks a pathological string rather than clipping it. */
128
+ .value {
129
+ min-width: 0;
130
+ overflow-wrap: anywhere;
131
+ font-family: var(--basalt-font-mono);
132
+ font-size: var(--basalt-stat-figure-size);
133
+ line-height: var(--basalt-stat-figure-line);
134
+ font-weight: 500;
135
+ letter-spacing: -0.02em;
136
+ color: var(--vx-ink);
137
+ }
138
+
139
+ /* Mono like the number it qualifies, `sm` and muted: the SMALL half of the pair. Never shrinks — a
140
+ * unit clipped to `TS…` would state nothing. */
141
+ .unit {
142
+ flex-shrink: 0;
143
+ font-family: var(--basalt-font-mono);
144
+ font-size: var(--vx-text-sm);
145
+ font-weight: 500;
146
+ color: var(--vx-muted);
147
+ }
148
+
149
+ /* The numeral shrinks with its card (`cqi` resolves against the card's container wherever the var is
150
+ * read). `(width >= 0px)` is always true but only inside a `basalt-card` container. */
151
+ @container basalt-card (width >= 0px) {
152
+ .body {
153
+ --basalt-stat-figure-size: clamp(var(--vx-text-lg), 8cqi, var(--vx-text-kpi));
154
+ }
155
+ }
156
+
157
+ /* ── states ──────────────────────────────────────────────────────────────────────────────────── */
158
+
159
+ /* The empty branch: one muted line in the figure's place, at the figure row's height. */
160
+ .empty {
161
+ display: flex;
162
+ align-items: center;
163
+ margin: 0;
164
+ min-height: var(--basalt-stat-figure-h);
165
+ font-size: var(--vx-text-sm);
166
+ color: var(--vx-muted);
167
+ }
168
+
169
+ /* The pending skeleton holds the card's own footprint: a value bar at the figure's height, the
170
+ * visual slot at 22, the footer at one `sm` line. */
171
+ .skeletonValue {
172
+ width: 45%;
173
+ height: var(--basalt-stat-figure-h);
174
+ }
175
+
176
+ .skeletonVisual {
177
+ --skeleton-radius: 0;
178
+ height: var(--basalt-stat-visual-h);
179
+ margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
180
+ }
181
+
182
+ .sparklineRight .skeletonVisual {
183
+ flex: 1 1 auto;
184
+ margin-inline: 0;
185
+ }
186
+
187
+ .skeletonRowBox {
188
+ display: flex;
189
+ align-items: center;
190
+ min-height: var(--vx-space-control-height-tag);
191
+ }
192
+
193
+ .skeletonRow {
194
+ width: 60%;
195
+ height: 0.625rem;
196
+ }
197
+
198
+ .skeletonFooter {
199
+ width: 55%;
200
+ height: 0.75rem;
201
+ margin-block: 0.25rem;
202
+ }
203
+
204
+ /* ── foot: the visual and its footer line ────────────────────────────────────────────────────── */
205
+
206
+ /* Pinned to the card's bottom (`margin-top: auto`) and reserving visual + gap + footer whenever it
207
+ * exists, bottom-aligned, so the visual and the footer never move when one of them is absent. */
208
+ .foot {
209
+ display: flex;
210
+ flex-direction: column;
211
+ justify-content: flex-end;
212
+ gap: var(--basalt-stat-foot-gap);
213
+ margin-top: auto;
214
+ min-width: 0;
215
+ min-height: calc(
216
+ var(--basalt-stat-visual-h) + var(--basalt-stat-foot-gap) + var(--basalt-stat-footer-h)
217
+ );
218
+ }
219
+
220
+ .foot[data-band='false'] {
221
+ min-height: var(--basalt-stat-footer-h);
222
+ }
223
+
224
+ .footer {
225
+ margin: 0;
226
+ overflow: hidden;
227
+ text-overflow: ellipsis;
228
+ white-space: nowrap;
229
+ font-size: var(--vx-text-sm);
230
+ line-height: var(--basalt-stat-footer-h);
231
+ color: var(--vx-muted);
232
+ }
233
+
19
234
  /*
20
235
  * `right` placement's second row (measured defect: the "···" actions trigger, and the "Data"
21
236
  * select, sat ~74-88px in from the card's right edge — a phone-only 13px is correct). The cause was
@@ -122,9 +337,8 @@
122
337
  }
123
338
 
124
339
  .sparklineBleed {
125
- margin-top: auto;
340
+ height: var(--basalt-stat-visual-h);
126
341
  margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
127
- margin-bottom: calc(-1 * var(--vx-space-card-inset-y, 0.75rem));
128
342
  }
129
343
 
130
344
  /* Asks for `StatCard`'s `SPARKLINE_RIGHT_WIDTH`/`_HEIGHT` (handed down as custom properties, so this
@@ -132,12 +346,12 @@
132
346
  * this restructure keeps at the SPARKLINE's own level rather than the row's: `.metricsRow` does not
133
347
  * set `align-items: flex-end` itself, because a card with no breakdown would then need nothing to
134
348
  * anchor against — only the sparkline opts into sitting at the row's bottom edge, which matters once
135
- * a breakdown taller than the trend's own 26px is the row's other child. */
349
+ * a breakdown taller than the trend's own 22px is the row's other child. */
136
350
  .sparklineRight {
137
351
  display: flex;
138
352
  flex: 0 1 var(--basalt-stat-sparkline-w, 4.5rem);
139
353
  min-width: 0;
140
- height: var(--basalt-stat-sparkline-h, 1.625rem);
354
+ height: var(--basalt-stat-sparkline-h, 1.375rem);
141
355
  align-items: flex-end;
142
356
  align-self: flex-end;
143
357
  overflow: hidden;
@@ -151,8 +365,8 @@
151
365
  }
152
366
 
153
367
  /* The row became a COLUMN, so `flex-basis` is now the main-axis HEIGHT — the 72px width would
154
- * become a 72px-tall box around 26px of bars. `flex: none` + the height keeps the bled trend the
155
- * same 26px it is beside a hero row. `align-self: stretch` resets the row-only `flex-end` above:
368
+ * become a 72px-tall box around 22px of bars. `flex: none` + the height keeps the bled trend the
369
+ * same 22px it is beside a hero row. `align-self: stretch` resets the row-only `flex-end` above:
156
370
  * the cross axis is horizontal now, and this slot must fill the card's width like `.sparklineBleed`
157
371
  * does, not shrink to its content and sit flush right. */
158
372
  .metricsRow .sparklineRight {
@@ -160,6 +374,5 @@
160
374
  align-self: stretch;
161
375
  margin-top: auto;
162
376
  margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
163
- margin-bottom: calc(-1 * var(--vx-space-card-inset-y, 0.75rem));
164
377
  }
165
378
  }
@@ -4,6 +4,26 @@
4
4
  */
5
5
  declare const classes: {
6
6
  readonly body: string
7
+ readonly captionRow: string
8
+ readonly captionMain: string
9
+ readonly lead: string
10
+ readonly caption: string
11
+ readonly captionText: string
12
+ readonly icon: string
13
+ readonly qualifier: string
14
+ readonly actions: string
15
+ readonly valueRow: string
16
+ readonly figure: string
17
+ readonly value: string
18
+ readonly unit: string
19
+ readonly empty: string
20
+ readonly skeletonValue: string
21
+ readonly skeletonVisual: string
22
+ readonly skeletonFooter: string
23
+ readonly skeletonRowBox: string
24
+ readonly skeletonRow: string
25
+ readonly foot: string
26
+ readonly footer: string
7
27
  readonly header: string
8
28
  readonly metricsRow: string
9
29
  readonly breakdown: string
@@ -1 +1 @@
1
- {"version":3,"file":"widget-header.d.ts","sourceRoot":"","sources":["../../src/dashboard/widget-header.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAA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