basalt-ui 2.18.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/MIGRATING.md +238 -12
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +33 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +28 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +32 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/commands/notifications/center.d.ts.map +1 -1
- package/dist/commands/notifications/center.js +18 -26
- package/dist/content/callout.d.ts +1 -1
- package/dist/content/callout.d.ts.map +1 -1
- package/dist/content/callout.js +10 -1
- package/dist/content/callout.module.css +15 -3
- package/dist/content/callout.module.css.d.ts +1 -0
- package/dist/controls/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +15 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +56 -19
- package/dist/dashboard/bar-list.module.css +110 -17
- package/dist/dashboard/bar-list.module.css.d.ts +2 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +68 -1
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +65 -4
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +234 -60
- package/dist/dashboard/meter.d.ts +38 -6
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +4 -1
- package/dist/dashboard/meter.module.css +209 -13
- package/dist/dashboard/meter.module.css.d.ts +16 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -9
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.d.ts +3 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +18 -3
- package/dist/dashboard/stat-card.d.ts +7 -6
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +51 -83
- package/dist/dashboard/stat-card.module.css +42 -14
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +50 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +85 -0
- package/dist/dashboard/stat-strip.module.css +208 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +28 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +2 -1
- package/dist/dashboard/widget-header.module.css +38 -7
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/chrome-vars.d.ts +29 -17
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +18 -8
- package/dist/theme/controls.module.css +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +32 -5
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +7 -0
- package/dist/theme/status-dot.d.ts.map +1 -0
- package/dist/theme/status-dot.js +18 -0
- package/dist/theme/status-dot.module.css +9 -0
- package/dist/theme/status-dot.module.css.d.ts +8 -0
- package/dist/theme/status-verdict.d.ts +10 -0
- package/dist/theme/status-verdict.d.ts.map +1 -0
- package/dist/theme/status-verdict.js +14 -0
- package/dist/theme/status-verdict.module.css +25 -0
- package/dist/theme/status-verdict.module.css.d.ts +9 -0
- package/llms.txt +30 -6
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +70 -4
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +44 -4
- package/src/charts/types.ts +6 -0
- package/src/commands/notifications/center.tsx +29 -32
- package/src/content/callout.module.css +15 -3
- package/src/content/callout.module.css.d.ts +1 -0
- package/src/content/callout.tsx +15 -2
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +110 -17
- package/src/dashboard/bar-list.module.css.d.ts +2 -0
- package/src/dashboard/bar-list.tsx +102 -21
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +132 -4
- package/src/dashboard/meter-parts.tsx +305 -25
- package/src/dashboard/meter.module.css +209 -13
- package/src/dashboard/meter.module.css.d.ts +16 -0
- package/src/dashboard/meter.tsx +42 -7
- package/src/dashboard/query-state.tsx +28 -19
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +22 -2
- package/src/dashboard/stat-card.module.css +42 -14
- package/src/dashboard/stat-card.tsx +23 -60
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +208 -0
- package/src/dashboard/stat-strip.module.css.d.ts +28 -0
- package/src/dashboard/stat-strip.tsx +183 -0
- package/src/dashboard/widget-header.module.css +38 -7
- package/src/dashboard/widget-header.tsx +7 -4
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +1 -1
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +242 -26
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/chrome-vars.ts +48 -23
- package/src/theme/controls.module.css +3 -0
- package/src/theme/index.ts +40 -6
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.module.css +9 -0
- package/src/theme/status-dot.module.css.d.ts +8 -0
- package/src/theme/status-dot.tsx +31 -0
- package/src/theme/status-verdict.module.css +25 -0
- package/src/theme/status-verdict.module.css.d.ts +9 -0
- package/src/theme/status-verdict.tsx +32 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Card, VisuallyHidden } from "@mantine/core";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import {
|
|
5
5
|
BreakdownSkeleton,
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
rightSlotStyle
|
|
12
12
|
} from "./stat-card-parts.js";
|
|
13
13
|
import { DeltaBadge } from "./delta-badge.js";
|
|
14
|
-
import { VX } from "../tokens/index.js";
|
|
15
14
|
import { cx } from "../common/props.js";
|
|
16
15
|
import { ErrorState, QueryState, resolveQueryBranch } from "./query-state.js";
|
|
17
16
|
import classes from "./stat-card.module.css";
|
|
@@ -35,12 +34,6 @@ function useSlotWidth(active) {
|
|
|
35
34
|
}, [active, node]);
|
|
36
35
|
return { ref: setNode, width };
|
|
37
36
|
}
|
|
38
|
-
const TONE_RAIL_WIDTH = 3;
|
|
39
|
-
const TONE_LABEL = {
|
|
40
|
-
good: "Within the good threshold",
|
|
41
|
-
warn: "Past the warning threshold",
|
|
42
|
-
bad: "Past the severe threshold"
|
|
43
|
-
};
|
|
44
37
|
function renderValueBody({
|
|
45
38
|
pending,
|
|
46
39
|
resolved,
|
|
@@ -169,16 +162,14 @@ function StatCard({
|
|
|
169
162
|
const hasBleedVisual = sparkline !== void 0 && bleeds;
|
|
170
163
|
const visualNode = renderVisualNode({ show: hasBleedVisual, pending, slot: sparklineSlot });
|
|
171
164
|
const footerNode = renderFooterNode({ subtitle, pending });
|
|
172
|
-
return /* @__PURE__ */
|
|
165
|
+
return /* @__PURE__ */ jsx(
|
|
173
166
|
Card,
|
|
174
167
|
{
|
|
175
168
|
className: cx(classNames?.root, className),
|
|
176
169
|
style: {
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
// the responsive half of the ladder lives in `spaceMobileDecls` (`tokens/index.ts`), which
|
|
181
|
-
// is the only home that can reach an inline style like this one.
|
|
170
|
+
// The inset is the theme's (`card-inset.module.css`: the `cardInsetY`/`cardInsetX` tokens, 12/16
|
|
171
|
+
// at level 0, stepping the horizontal one down a rung below `sm`), so it is NOT restated here —
|
|
172
|
+
// an inline copy would bypass `variant="flush"`.
|
|
182
173
|
//
|
|
183
174
|
// `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
|
|
184
175
|
// element's own `box-shadow` renders outside its border box and is NOT clipped by its own
|
|
@@ -186,10 +177,8 @@ function StatCard({
|
|
|
186
177
|
//
|
|
187
178
|
// NO `minHeight`: the content states the height (the foot reserves its own), and cards in a
|
|
188
179
|
// grid row stretch to the tallest.
|
|
189
|
-
padding: "var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)",
|
|
190
180
|
overflow: "hidden",
|
|
191
|
-
//
|
|
192
|
-
// depending on whether it happens to have crossed a threshold this render.
|
|
181
|
+
// Consumers may anchor overlays (badges, menus) to the card, so it stays a positioned box.
|
|
193
182
|
position: "relative",
|
|
194
183
|
// The card's own width drives its chrome (`stat-card.module.css`).
|
|
195
184
|
containerType: "inline-size",
|
|
@@ -197,76 +186,55 @@ function StatCard({
|
|
|
197
186
|
...style
|
|
198
187
|
},
|
|
199
188
|
"data-tone": tone,
|
|
200
|
-
children:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
insetBlock: 0,
|
|
210
|
-
insetInlineStart: 0,
|
|
211
|
-
width: TONE_RAIL_WIDTH,
|
|
212
|
-
// `Tone`'s members are `VX.status` keys by construction, so the rail reads the
|
|
213
|
-
// per-scheme `--vx-status-*` solid directly — never a hex, so it re-resolves in both
|
|
214
|
-
// schemes and under a consumer's `derive` retune. Contrast against
|
|
215
|
-
// `--vx-surface-panel` is measured in `theme/contrast.test.ts`.
|
|
216
|
-
background: VX.status[tone]
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
] }),
|
|
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
|
-
] }) }),
|
|
189
|
+
children: /* @__PURE__ */ jsxs(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: cx(classes.body, classNames?.body),
|
|
193
|
+
"data-placement": sparklinePlacement,
|
|
194
|
+
...pending && { "aria-busy": true },
|
|
195
|
+
children: [
|
|
196
|
+
pending && /* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${title}` }),
|
|
197
|
+
/* @__PURE__ */ jsxs("div", { className: cx(classes.header, classNames?.header), children: [
|
|
257
198
|
/* @__PURE__ */ jsx(
|
|
258
|
-
|
|
199
|
+
CaptionRow,
|
|
259
200
|
{
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
201
|
+
title,
|
|
202
|
+
...icon !== void 0 && { icon },
|
|
203
|
+
...info !== void 0 && { info },
|
|
204
|
+
...qualifier !== void 0 && { qualifier },
|
|
205
|
+
...tone !== void 0 && { tone },
|
|
206
|
+
...actions !== void 0 && { actions }
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
valueBody,
|
|
210
|
+
bleeds && (pending ? hasBreakdown && /* @__PURE__ */ jsx(BreakdownSkeleton, { rows: breakdownCount }) : ready && breakdownContent)
|
|
211
|
+
] }),
|
|
212
|
+
rightRow && /* @__PURE__ */ jsx("div", { className: classes.metricsRow, children: ready ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
213
|
+
breakdownContent,
|
|
214
|
+
sparklineSlot
|
|
215
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
216
|
+
hasBreakdown && /* @__PURE__ */ jsx(BreakdownSkeleton, { rows: breakdownCount }),
|
|
217
|
+
sparkline !== void 0 && /* @__PURE__ */ jsx(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: classes.sparklineRight,
|
|
221
|
+
style: rightSlotStyle(SPARKLINE_RIGHT_WIDTH, SPARKLINE_HEIGHT),
|
|
222
|
+
children: /* @__PURE__ */ jsx(VisualSkeleton, {})
|
|
264
223
|
}
|
|
265
224
|
)
|
|
266
|
-
]
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
225
|
+
] }) }),
|
|
226
|
+
/* @__PURE__ */ jsx(
|
|
227
|
+
Foot,
|
|
228
|
+
{
|
|
229
|
+
reserve: hasBleedVisual || subtitle !== void 0,
|
|
230
|
+
visualBand: bleeds,
|
|
231
|
+
visualNode,
|
|
232
|
+
footerNode
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
)
|
|
270
238
|
}
|
|
271
239
|
);
|
|
272
240
|
}
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
--basalt-stat-visual-h: 1.375rem;
|
|
13
13
|
--basalt-stat-footer-h: 1.25rem;
|
|
14
14
|
--basalt-stat-foot-gap: 0.25rem;
|
|
15
|
+
/* The line a Sparkline's hover readout takes above its plot (`charts/sparkline.module.css` reads
|
|
16
|
+
* it too). A slot that cannot spare it reserves it as padding, so the chip never covers the hero. */
|
|
17
|
+
--basalt-spark-readout-h: 1.125rem;
|
|
15
18
|
/* The figure's size and line box, in one place: `.value`, the empty line and the pending skeleton
|
|
16
19
|
* all read them, so nothing moves when a reading lands. */
|
|
17
20
|
--basalt-stat-figure-size: var(--vx-text-kpi);
|
|
@@ -86,7 +89,6 @@
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
.qualifier {
|
|
89
|
-
font-family: var(--basalt-font-mono);
|
|
90
92
|
font-size: var(--vx-text-micro);
|
|
91
93
|
color: var(--vx-muted);
|
|
92
94
|
/* Wraps before it is ever cut: a qualifier too long for the row on its own line breaks its words. */
|
|
@@ -128,7 +130,8 @@
|
|
|
128
130
|
.value {
|
|
129
131
|
min-width: 0;
|
|
130
132
|
overflow-wrap: anywhere;
|
|
131
|
-
font-family: var(--basalt-font-
|
|
133
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
134
|
+
font-variant-numeric: lining-nums;
|
|
132
135
|
font-size: var(--basalt-stat-figure-size);
|
|
133
136
|
line-height: var(--basalt-stat-figure-line);
|
|
134
137
|
font-weight: 500;
|
|
@@ -136,11 +139,12 @@
|
|
|
136
139
|
color: var(--vx-ink);
|
|
137
140
|
}
|
|
138
141
|
|
|
139
|
-
/*
|
|
142
|
+
/* Sans like the number it qualifies, `sm` and muted: the SMALL half of the pair. Never shrinks — a
|
|
140
143
|
* unit clipped to `TS…` would state nothing. */
|
|
141
144
|
.unit {
|
|
142
145
|
flex-shrink: 0;
|
|
143
|
-
font-family: var(--basalt-font-
|
|
146
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
147
|
+
font-variant-numeric: lining-nums;
|
|
144
148
|
font-size: var(--vx-text-sm);
|
|
145
149
|
font-weight: 500;
|
|
146
150
|
color: var(--vx-muted);
|
|
@@ -173,15 +177,15 @@
|
|
|
173
177
|
height: var(--basalt-stat-figure-h);
|
|
174
178
|
}
|
|
175
179
|
|
|
180
|
+
/* Inset on both sides, unlike the sparkline at rest (which bleeds): a placeholder that touches one
|
|
181
|
+
* card edge and stops short of the other reads as misaligned, and a Meter in the slot is inset anyway. */
|
|
176
182
|
.skeletonVisual {
|
|
177
183
|
--skeleton-radius: 0;
|
|
178
184
|
height: var(--basalt-stat-visual-h);
|
|
179
|
-
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
180
185
|
}
|
|
181
186
|
|
|
182
187
|
.sparklineRight .skeletonVisual {
|
|
183
188
|
flex: 1 1 auto;
|
|
184
|
-
margin-inline: 0;
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
.skeletonRowBox {
|
|
@@ -306,23 +310,24 @@
|
|
|
306
310
|
color: var(--vx-muted);
|
|
307
311
|
}
|
|
308
312
|
|
|
309
|
-
/*
|
|
313
|
+
/* Sans and ink — a breakdown value is a number, and it is the half of the row worth reading. Never
|
|
310
314
|
* shrinks: the LABEL is the prose half and the one that may ellipsize. */
|
|
311
315
|
.breakdownValue {
|
|
312
316
|
flex-shrink: 0;
|
|
313
317
|
margin: 0;
|
|
314
|
-
font-family: var(--basalt-font-
|
|
318
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
319
|
+
font-variant-numeric: lining-nums;
|
|
315
320
|
font-size: var(--vx-text-sm);
|
|
316
321
|
font-weight: 500;
|
|
317
322
|
color: var(--vx-ink);
|
|
318
323
|
}
|
|
319
324
|
|
|
320
325
|
/*
|
|
321
|
-
* A row past a threshold. Same vocabulary and the same per-scheme solids as the card's own tone
|
|
322
|
-
* (`
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
+
* A row past a threshold. Same vocabulary and the same per-scheme solids as the card's own tone dot
|
|
327
|
+
* (`VX.status[tone]`), so a row saying `bad` and a dot saying `bad` are one claim at two scales.
|
|
328
|
+
* Colour is not the only carrier at the CARD level (the dot ships a word); at
|
|
329
|
+
* the ROW level the label is the carrier — a row reading `Paid · 1,204` states its own subject
|
|
330
|
+
* either way, and the tint only ranks it.
|
|
326
331
|
*/
|
|
327
332
|
.breakdownRow[data-tone='good'] .breakdownValue {
|
|
328
333
|
color: var(--vx-status-good);
|
|
@@ -341,6 +346,23 @@
|
|
|
341
346
|
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
342
347
|
}
|
|
343
348
|
|
|
349
|
+
/* A Meter in the visual slot is a block, not a chart: it sizes to its content and keeps the card's
|
|
350
|
+
* inline inset instead of the sparkline's fixed 22px and side bleed. */
|
|
351
|
+
.sparklineBleed:has(> [data-basalt-meter]) {
|
|
352
|
+
height: auto;
|
|
353
|
+
margin-inline: 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* The `right` placement: the fixed basis, 22px height and clip are a sparkline's box. A Meter takes the
|
|
357
|
+
* row's remaining width and its own height, unclipped. */
|
|
358
|
+
.sparklineRight:has(> [data-basalt-meter]) {
|
|
359
|
+
flex: 1 1 auto;
|
|
360
|
+
height: auto;
|
|
361
|
+
padding-top: 0;
|
|
362
|
+
overflow: visible;
|
|
363
|
+
align-items: stretch;
|
|
364
|
+
}
|
|
365
|
+
|
|
344
366
|
/* Asks for `StatCard`'s `SPARKLINE_RIGHT_WIDTH`/`_HEIGHT` (handed down as custom properties, so this
|
|
345
367
|
* rule and the narrow-card reset below can both reach them). `align-self: flex-end` is the one alignment
|
|
346
368
|
* this restructure keeps at the SPARKLINE's own level rather than the row's: `.metricsRow` does not
|
|
@@ -351,7 +373,9 @@
|
|
|
351
373
|
display: flex;
|
|
352
374
|
flex: 0 1 var(--basalt-stat-sparkline-w, 4.5rem);
|
|
353
375
|
min-width: 0;
|
|
354
|
-
|
|
376
|
+
/* The slot clips, so it holds the Sparkline's readout line inside its own box (padding-top). */
|
|
377
|
+
height: calc(var(--basalt-stat-sparkline-h, 1.375rem) + var(--basalt-spark-readout-h));
|
|
378
|
+
padding-top: var(--basalt-spark-readout-h);
|
|
355
379
|
align-items: flex-end;
|
|
356
380
|
align-self: flex-end;
|
|
357
381
|
overflow: hidden;
|
|
@@ -375,4 +399,8 @@
|
|
|
375
399
|
margin-top: auto;
|
|
376
400
|
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
377
401
|
}
|
|
402
|
+
|
|
403
|
+
.metricsRow .sparklineRight:has(> [data-basalt-meter], > .skeletonVisual) {
|
|
404
|
+
margin-inline: 0;
|
|
405
|
+
}
|
|
378
406
|
}
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* rule on the GROUP, so the cells stay whatever they are; on `StatCard`s (which carry their own
|
|
22
22
|
* panel and shadow ring) the rail reads as a second frame, so pair it with unadorned children.
|
|
23
23
|
*
|
|
24
|
+
* `variant="strip"` is the joined-surface form with typed cells and a footer row (`stat-strip.tsx`).
|
|
25
|
+
*
|
|
24
26
|
* @example
|
|
25
27
|
* import { StatCard, StatGroup } from 'basalt-ui'
|
|
26
28
|
*
|
|
@@ -32,9 +34,11 @@
|
|
|
32
34
|
*/
|
|
33
35
|
import type { ReactNode } from 'react';
|
|
34
36
|
import type { BasaltProps } from '../common/props.js';
|
|
37
|
+
import type { StatStripProps } from './stat-strip.js';
|
|
35
38
|
/** The desktop KPI column count. */
|
|
36
39
|
export type StatGroupCols = 2 | 3 | 4 | 5;
|
|
37
|
-
export type
|
|
40
|
+
export type StatGridProps = BasaltProps & {
|
|
41
|
+
variant?: 'grid';
|
|
38
42
|
/** The DESKTOP column count (`lg` and up). Default `4`. `sm` gets `min(cols, 3)` — except `4`, which gets 2 rather than an orphan row. A phone gets 2.
|
|
39
43
|
* Never a responsive object — the law is basalt's, see the module docblock. */
|
|
40
44
|
cols?: StatGroupCols;
|
|
@@ -43,5 +47,10 @@ export type StatGroupProps = BasaltProps & {
|
|
|
43
47
|
/** The KPI cells — normally `StatCard`s. */
|
|
44
48
|
children: ReactNode;
|
|
45
49
|
};
|
|
46
|
-
|
|
50
|
+
/** `variant="strip"`: one joined surface of typed `cells` split by hairlines, plus an optional
|
|
51
|
+
* `footer` row — see `StatStripProps`. `cols` here may be 6 (the strip's desktop count). */
|
|
52
|
+
export type StatGroupProps = StatGridProps | ({
|
|
53
|
+
variant: 'strip';
|
|
54
|
+
} & StatStripProps);
|
|
55
|
+
export declare function StatGroup(props: StatGroupProps): import("react").JSX.Element;
|
|
47
56
|
//# sourceMappingURL=stat-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stat-group.d.ts","sourceRoot":"","sources":["../../src/dashboard/stat-group.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"stat-group.d.ts","sourceRoot":"","sources":["../../src/dashboard/stat-group.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGlD,oCAAoC;AACpC,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEzC,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG;IACxC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;mFAC+E;IAC/E,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,4CAA4C;IAC5C,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED;4FAC4F;AAC5F,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,cAAc,CAAC,CAAA;AAEpF,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,+BAM9C"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../common/props.js";
|
|
3
|
+
import { StatStrip } from "./stat-strip.js";
|
|
3
4
|
import classes from "./stat-group.module.css";
|
|
4
|
-
function StatGroup({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
function StatGroup(props) {
|
|
6
|
+
if (props.variant === "strip") {
|
|
7
|
+
const { variant: _variant, ...strip } = props;
|
|
8
|
+
return /* @__PURE__ */ jsx(StatStrip, { ...strip });
|
|
9
|
+
}
|
|
10
|
+
return /* @__PURE__ */ jsx(StatGrid, { ...props });
|
|
11
|
+
}
|
|
12
|
+
function StatGrid({ cols = 4, divided = false, children, className, style }) {
|
|
11
13
|
const smCols = cols === 4 ? 2 : Math.min(cols, 3);
|
|
12
14
|
return (
|
|
13
15
|
// Two boxes, and the outer one is not decoration: a size container is a container for its
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { BasaltProps, Tone } from '../common/props.js';
|
|
3
|
+
export type StatStripRow = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** `null` = no reading, printed as `—`. Pre-join the unit (`'48 ms'`). */
|
|
7
|
+
value: string | null;
|
|
8
|
+
visual?: ReactNode;
|
|
9
|
+
/** A `DeltaBadge`. */
|
|
10
|
+
delta?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export type StatStripCell = {
|
|
13
|
+
key: string;
|
|
14
|
+
caption: string;
|
|
15
|
+
/** Muted, on the caption line: `CAPTION · qualifier`. */
|
|
16
|
+
qualifier?: string;
|
|
17
|
+
/** The definition behind the caption, in the info-glyph tooltip. */
|
|
18
|
+
info?: string;
|
|
19
|
+
/** `null` = no reading, printed as `—`. Omit only when `rows` carries the cell. */
|
|
20
|
+
value?: string | null;
|
|
21
|
+
unit?: string;
|
|
22
|
+
/** A `DeltaBadge`. */
|
|
23
|
+
delta?: ReactNode;
|
|
24
|
+
/** The micro-visual slot (Meter / Sparkline / BandStrip). */
|
|
25
|
+
visual?: ReactNode;
|
|
26
|
+
/** A muted line pinned to the cell foot. */
|
|
27
|
+
footer?: ReactNode;
|
|
28
|
+
/** Aligned signals under the hero (or alone when `value` is omitted). */
|
|
29
|
+
rows?: readonly StatStripRow[];
|
|
30
|
+
/** Inks the value only — set it when the reading is a verdict. */
|
|
31
|
+
tone?: Tone;
|
|
32
|
+
/** Skeleton in place of the readings. */
|
|
33
|
+
loading?: boolean;
|
|
34
|
+
/** Dims the cell while placeholder data shows. */
|
|
35
|
+
stale?: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type StatStripProps = BasaltProps & {
|
|
38
|
+
/** The strip's accessible name. */
|
|
39
|
+
label: string;
|
|
40
|
+
cells: readonly StatStripCell[];
|
|
41
|
+
/** Wider cells under the cells. */
|
|
42
|
+
footer?: readonly {
|
|
43
|
+
key: string;
|
|
44
|
+
content: ReactNode;
|
|
45
|
+
}[];
|
|
46
|
+
/** The DESKTOP column count. Default: the cell count, capped at 6. */
|
|
47
|
+
cols?: 2 | 3 | 4 | 5 | 6;
|
|
48
|
+
};
|
|
49
|
+
export declare function StatStrip({ label, cells, footer, cols, className, style }: StatStripProps): import("react").JSX.Element;
|
|
50
|
+
//# sourceMappingURL=stat-strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stat-strip.d.ts","sourceRoot":"","sources":["../../src/dashboard/stat-strip.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAKxD,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,sBAAsB;IACtB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,yEAAyE;IACzE,IAAI,CAAC,EAAE,SAAS,YAAY,EAAE,CAAA;IAC9B,kEAAkE;IAClE,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,yCAAyC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,SAAS,aAAa,EAAE,CAAA;IAC/B,mCAAmC;IACnC,MAAM,CAAC,EAAE,SAAS;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,CAAA;KAAE,EAAE,CAAA;IACvD,sEAAsE;IACtE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;CACzB,CAAA;AAuED,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,cAAc,+BAyCzF"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, Skeleton } from "@mantine/core";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { cx } from "../common/props.js";
|
|
5
|
+
import { VX } from "../tokens/index.js";
|
|
6
|
+
import { InfoGlyph } from "./widget-header.js";
|
|
7
|
+
import classes from "./stat-strip.module.css";
|
|
8
|
+
const EMPTY = "\u2014";
|
|
9
|
+
function StripCell({ cell }) {
|
|
10
|
+
const captionId = useId();
|
|
11
|
+
const { rows, loading } = cell;
|
|
12
|
+
const hasHero = cell.value !== void 0 || rows === void 0;
|
|
13
|
+
return /* @__PURE__ */ jsxs(
|
|
14
|
+
"article",
|
|
15
|
+
{
|
|
16
|
+
className: classes.cell,
|
|
17
|
+
"data-strip-cell": cell.key,
|
|
18
|
+
"data-shot": `strip-${cell.key}`,
|
|
19
|
+
"aria-labelledby": captionId,
|
|
20
|
+
...cell.stale && { "data-stale": "true" },
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: classes.captionLine, children: [
|
|
23
|
+
/* @__PURE__ */ jsxs("span", { className: classes.lead, children: [
|
|
24
|
+
/* @__PURE__ */ jsx("span", { className: classes.caption, id: captionId, title: cell.caption, "data-strip-caption": true, children: cell.caption }),
|
|
25
|
+
cell.info !== void 0 && /* @__PURE__ */ jsx(InfoGlyph, { text: cell.info })
|
|
26
|
+
] }),
|
|
27
|
+
cell.qualifier !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.qualifier, children: cell.qualifier })
|
|
28
|
+
] }),
|
|
29
|
+
hasHero && (loading ? /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonValue, radius: "sm" }) : /* @__PURE__ */ jsxs("div", { className: classes.valueRow, children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
"span",
|
|
32
|
+
{
|
|
33
|
+
className: classes.value,
|
|
34
|
+
"data-strip-value": true,
|
|
35
|
+
style: cell.tone !== void 0 ? { color: VX.status[cell.tone] } : void 0,
|
|
36
|
+
children: cell.value ?? EMPTY
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
cell.value !== void 0 && cell.value !== null && cell.unit !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.unit, children: cell.unit }),
|
|
40
|
+
cell.delta
|
|
41
|
+
] })),
|
|
42
|
+
cell.visual !== void 0 && /* @__PURE__ */ jsx("div", { className: classes.visual, children: cell.visual }),
|
|
43
|
+
rows !== void 0 && (loading ? /* @__PURE__ */ jsx("div", { className: classes.rows, "aria-hidden": "true", children: rows.map((row) => /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonRow, radius: "sm" }, row.key)) }) : /* @__PURE__ */ jsx("ul", { className: classes.rows, children: rows.map((row) => /* @__PURE__ */ jsxs("li", { className: classes.row, "data-strip-row": row.key, children: [
|
|
44
|
+
/* @__PURE__ */ jsx("span", { className: classes.rowLabel, children: row.label }),
|
|
45
|
+
/* @__PURE__ */ jsx("span", { className: classes.visual, children: row.visual }),
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: classes.rowValue, children: row.value ?? EMPTY }),
|
|
47
|
+
/* @__PURE__ */ jsx("span", { children: row.delta })
|
|
48
|
+
] }, row.key)) })),
|
|
49
|
+
cell.footer !== void 0 && /* @__PURE__ */ jsx("div", { className: classes.footer, children: cell.footer })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function StatStrip({ label, cells, footer, cols, className, style }) {
|
|
55
|
+
const desktop = cols ?? Math.min(Math.max(cells.length, 2), 6);
|
|
56
|
+
const mid = desktop === 4 ? 2 : Math.min(desktop, 3);
|
|
57
|
+
return /* @__PURE__ */ jsx("div", { className: cx(classes.container, className), style, children: /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(
|
|
58
|
+
Card.Section,
|
|
59
|
+
{
|
|
60
|
+
component: "section",
|
|
61
|
+
"aria-label": label,
|
|
62
|
+
className: classes.clip,
|
|
63
|
+
style: {
|
|
64
|
+
"--basalt-strip-cols": desktop,
|
|
65
|
+
"--basalt-strip-cols-sm": mid
|
|
66
|
+
},
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx("div", { className: classes.cells, children: cells.map((cell) => /* @__PURE__ */ jsx(StripCell, { cell }, cell.key)) }),
|
|
69
|
+
footer !== void 0 && footer.length > 0 && /* @__PURE__ */ jsx("div", { className: classes.footerRow, children: footer.map((entry) => /* @__PURE__ */ jsx(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
className: classes.footerCell,
|
|
73
|
+
"data-strip-footer-cell": entry.key,
|
|
74
|
+
"data-shot": `strip-footer-${entry.key}`,
|
|
75
|
+
children: entry.content
|
|
76
|
+
},
|
|
77
|
+
entry.key
|
|
78
|
+
)) })
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
) }) });
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
StatStrip
|
|
85
|
+
};
|