basalt-ui 2.21.0 → 2.23.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 +60 -0
- package/MIGRATING.md +452 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/rules/basalt-tokens.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/anti-defaults.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +1 -0
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +73 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +6 -0
- package/dist/charts/CartesianChart.d.ts +10 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +8 -5
- package/dist/charts/ChartCard.d.ts +12 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +39 -8
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +5 -8
- package/dist/charts/Heatmap.d.ts +12 -1
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +34 -5
- package/dist/charts/Lines.d.ts +3 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +29 -6
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +4 -6
- package/dist/charts/Sparkline.d.ts +14 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +101 -22
- package/dist/charts/StackedArea.d.ts +4 -1
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +9 -3
- package/dist/charts/band-fold.d.ts +38 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +18 -1
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +25 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +152 -72
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +21 -6
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +52 -17
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +7 -21
- package/dist/charts/marks.js +1 -1
- package/dist/charts/panel.d.ts +0 -6
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +1 -10
- package/dist/charts/ref-label.d.ts +43 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +75 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +14 -3
- package/dist/charts/sparkline.module.css +13 -17
- package/dist/charts/sparkline.module.css.d.ts +1 -2
- package/dist/charts/state.d.ts +2 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +5 -2
- package/dist/charts/types.d.ts +18 -8
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +1 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +1 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +68 -4
- package/dist/cli/shot/capture.d.ts +21 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +202 -36
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +17 -1
- package/dist/cli/shot/playwright.d.ts +13 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +4 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/controls/controls.module.css +11 -1
- package/dist/controls/filter-pill.d.ts.map +1 -1
- package/dist/controls/filter-pill.js +1 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/controls/sync-button.js +22 -3
- package/dist/controls/sync-button.module.css +34 -2
- package/dist/controls/sync-button.module.css.d.ts +1 -0
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +15 -8
- package/dist/dashboard/bar-list.module.css +83 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/index.d.ts +1 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/index.js +2 -0
- package/dist/dashboard/meter-model.d.ts +84 -5
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +100 -15
- package/dist/dashboard/meter-parts.d.ts +9 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +276 -74
- package/dist/dashboard/meter.d.ts +54 -65
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +21 -4
- package/dist/dashboard/meter.module.css +76 -0
- package/dist/dashboard/meter.module.css.d.ts +6 -0
- package/dist/dashboard/page-summary.d.ts +20 -0
- package/dist/dashboard/page-summary.d.ts.map +1 -0
- package/dist/dashboard/page-summary.js +28 -0
- package/dist/dashboard/page-summary.module.css +89 -0
- package/dist/dashboard/page-summary.module.css.d.ts +15 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/section.d.ts +25 -2
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +10 -5
- package/dist/dashboard/section.module.css +23 -0
- package/dist/dashboard/section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +4 -2
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +7 -5
- package/dist/dashboard/stat-card.module.css +36 -0
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +22 -6
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +104 -60
- package/dist/dashboard/stat-strip.module.css +122 -53
- package/dist/dashboard/stat-strip.module.css.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts +7 -1
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +3 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/styles.css +43 -4
- package/dist/theme/chrome-vars.d.ts +20 -5
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +46 -3
- package/dist/theme/controls.module.css +37 -0
- package/dist/theme/controls.module.css.d.ts +2 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +18 -27
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/core.d.ts +2 -1
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +6 -1
- package/dist/tokens/derive.d.ts +3 -1
- package/dist/tokens/derive.d.ts.map +1 -1
- package/dist/tokens/derive.js +16 -1
- package/dist/tokens/palette.d.ts +11 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +11 -10
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +42 -22
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +83 -3
- package/src/charts/Bars.tsx +7 -0
- package/src/charts/CartesianChart.tsx +18 -3
- package/src/charts/ChartCard.tsx +54 -13
- package/src/charts/DualPanel.tsx +3 -6
- package/src/charts/Heatmap.tsx +54 -5
- package/src/charts/Lines.tsx +56 -10
- package/src/charts/MirroredBars.tsx +3 -5
- package/src/charts/Sparkline.tsx +135 -25
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +50 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +253 -87
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +81 -26
- package/src/charts/legend.tsx +10 -20
- package/src/charts/marks.ts +1 -1
- package/src/charts/panel.tsx +1 -16
- package/src/charts/ref-label.ts +131 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +13 -17
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +9 -4
- package/src/charts/types.ts +18 -8
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +266 -35
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +20 -4
- package/src/cli/shot/types.ts +5 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/controls/controls.module.css +11 -1
- package/src/controls/filter-pill.tsx +2 -0
- package/src/controls/sync-button.module.css +34 -2
- package/src/controls/sync-button.module.css.d.ts +1 -0
- package/src/controls/sync-button.tsx +40 -4
- package/src/dashboard/bar-list.module.css +83 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +107 -69
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +207 -24
- package/src/dashboard/meter-parts.tsx +349 -67
- package/src/dashboard/meter.module.css +76 -0
- package/src/dashboard/meter.module.css.d.ts +6 -0
- package/src/dashboard/meter.tsx +72 -18
- package/src/dashboard/page-summary.module.css +89 -0
- package/src/dashboard/page-summary.module.css.d.ts +15 -0
- package/src/dashboard/page-summary.tsx +95 -0
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/section.module.css +23 -0
- package/src/dashboard/section.module.css.d.ts +1 -0
- package/src/dashboard/section.tsx +59 -11
- package/src/dashboard/stat-card-parts.tsx +5 -1
- package/src/dashboard/stat-card.module.css +36 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +122 -53
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +176 -91
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/index.ts +0 -5
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +43 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +200 -68
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +37 -0
- package/src/theme/controls.module.css.d.ts +2 -0
- package/src/theme/index.ts +22 -32
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +11 -10
- package/src/tokens/status-text.ts +2 -0
|
@@ -6,10 +6,14 @@ import { cx } from "../common/props.js";
|
|
|
6
6
|
import {
|
|
7
7
|
ariaValues,
|
|
8
8
|
modelBar,
|
|
9
|
+
partsFitUnder,
|
|
10
|
+
placeMarkCaptions,
|
|
11
|
+
placeRowLabels,
|
|
9
12
|
ringFraction,
|
|
13
|
+
ringMarks,
|
|
10
14
|
startCaptionText,
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
zoneBand,
|
|
16
|
+
zoneFill
|
|
13
17
|
} from "./meter-model.js";
|
|
14
18
|
import classes from "./meter.module.css";
|
|
15
19
|
import { VisualSlotContext } from "./visual-slot.js";
|
|
@@ -26,7 +30,13 @@ const RING_STROKE = 4;
|
|
|
26
30
|
const RING_RADIUS = (RING_VIEWBOX - RING_STROKE) / 2;
|
|
27
31
|
const RING_LENGTH = 2 * Math.PI * RING_RADIUS;
|
|
28
32
|
const RING_CENTER = RING_VIEWBOX / 2;
|
|
29
|
-
|
|
33
|
+
const RING_TICK_INNER = RING_RADIUS - RING_STROKE / 2 - 0.75;
|
|
34
|
+
const RING_TICK_OUTER = RING_VIEWBOX / 2 - 0.5;
|
|
35
|
+
function RingSvg({
|
|
36
|
+
fraction,
|
|
37
|
+
color,
|
|
38
|
+
marks = []
|
|
39
|
+
}) {
|
|
30
40
|
return /* @__PURE__ */ jsxs("svg", { className: classes.ring, viewBox: `0 0 ${RING_VIEWBOX} ${RING_VIEWBOX}`, "aria-hidden": true, children: [
|
|
31
41
|
/* @__PURE__ */ jsx(
|
|
32
42
|
"circle",
|
|
@@ -49,7 +59,22 @@ function RingSvg({ fraction, color }) {
|
|
|
49
59
|
strokeDasharray: `${fraction * RING_LENGTH} ${RING_LENGTH}`,
|
|
50
60
|
...color !== void 0 && { style: { stroke: color } }
|
|
51
61
|
}
|
|
52
|
-
)
|
|
62
|
+
),
|
|
63
|
+
marks.map((m, i) => (
|
|
64
|
+
// The svg is rotated so 0° is the top: a horizontal line at the rim, turned `angle` clockwise.
|
|
65
|
+
/* @__PURE__ */ jsx("g", { "data-meter-ring-tick": "", children: [classes.ringTickHalo, classes.ringTick].map((cls, n) => /* @__PURE__ */ jsx(
|
|
66
|
+
"line",
|
|
67
|
+
{
|
|
68
|
+
className: cls,
|
|
69
|
+
x1: RING_CENTER + RING_TICK_INNER,
|
|
70
|
+
x2: RING_CENTER + RING_TICK_OUTER,
|
|
71
|
+
y1: RING_CENTER,
|
|
72
|
+
y2: RING_CENTER,
|
|
73
|
+
transform: `rotate(${m.angle} ${RING_CENTER} ${RING_CENTER})`
|
|
74
|
+
},
|
|
75
|
+
n
|
|
76
|
+
)) }, i)
|
|
77
|
+
))
|
|
53
78
|
] });
|
|
54
79
|
}
|
|
55
80
|
const UNITS = "h|d|w|mo|y|s|ms|min|m|km|mi|g|kg|%|\u20AC|pts|bpm|AU|kcal|KB|MB|GB|TB";
|
|
@@ -70,45 +95,52 @@ function MeterLoading({
|
|
|
70
95
|
] })
|
|
71
96
|
] });
|
|
72
97
|
}
|
|
98
|
+
const EMPTY_READING = "\u2014";
|
|
73
99
|
function MeterEmpty(props) {
|
|
74
100
|
const { label, text, ring, shell } = props;
|
|
75
101
|
return /* @__PURE__ */ jsxs("output", { ...rootProps(shell), "aria-label": label, children: [
|
|
76
|
-
ring ? /* @__PURE__ */
|
|
77
|
-
|
|
102
|
+
ring ? /* @__PURE__ */ jsxs("span", { className: classes.ringBox, children: [
|
|
103
|
+
/* @__PURE__ */ jsx(RingSvg, {}),
|
|
104
|
+
/* @__PURE__ */ jsx("span", { className: classes.ringValue, children: EMPTY_READING })
|
|
105
|
+
] }) : /* @__PURE__ */ jsx("div", { className: classes.trackBox, children: /* @__PURE__ */ jsx("div", { className: classes.track, "data-meter-track": true }) }),
|
|
106
|
+
(!ring || text !== void 0) && /* @__PURE__ */ jsx("span", { className: classes.empty, children: text ?? EMPTY_READING })
|
|
78
107
|
] });
|
|
79
108
|
}
|
|
80
109
|
function MeterRing(props) {
|
|
81
110
|
const { label, reading, min, max, color, format, shell } = props;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
const describedId = useId();
|
|
112
|
+
const marks = ringMarks(props.target, props.ticks, min, max, format);
|
|
113
|
+
return /* @__PURE__ */ jsxs("div", { ...rootProps(shell), children: [
|
|
114
|
+
/* @__PURE__ */ jsxs(
|
|
115
|
+
"span",
|
|
116
|
+
{
|
|
117
|
+
className: classes.ringBox,
|
|
118
|
+
"aria-label": label,
|
|
119
|
+
...ariaValues(reading, min, max, format),
|
|
120
|
+
...marks.length > 0 && { "aria-describedby": describedId },
|
|
121
|
+
children: [
|
|
122
|
+
/* @__PURE__ */ jsx(RingSvg, { fraction: ringFraction(reading, min, max), color, marks }),
|
|
123
|
+
/* @__PURE__ */ jsx("span", { className: classes.ringValue, children: format(reading) })
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
marks.length > 0 && /* @__PURE__ */ jsx(VisuallyHidden, { id: describedId, className: classes.summary, children: marks.map((m) => m.text).join("; ") })
|
|
128
|
+
] });
|
|
94
129
|
}
|
|
95
130
|
function fillStyle(p) {
|
|
96
131
|
return { width: `${toPct(p.size)}%`, ...p.color !== void 0 && { background: p.color } };
|
|
97
132
|
}
|
|
98
|
-
const ZONE_STRENGTH_MIN = 15;
|
|
99
|
-
const ZONE_STRENGTH_STEP = 45;
|
|
100
|
-
const ZONE_STRENGTH_SOLO = 40;
|
|
101
133
|
const ZONE_GAP = "1px";
|
|
102
134
|
function zoneStyle(zone, index, count, min, span) {
|
|
103
135
|
const band = zoneBand(zone, min, span);
|
|
104
136
|
const gap = index > 0;
|
|
105
|
-
const strength = count > 1 ? ZONE_STRENGTH_MIN + index / (count - 1) * ZONE_STRENGTH_STEP : ZONE_STRENGTH_SOLO;
|
|
106
137
|
return {
|
|
107
138
|
insetInlineStart: gap ? `calc(${band.start}% + ${ZONE_GAP})` : `${band.start}%`,
|
|
108
139
|
width: gap ? `calc(${band.width}% - ${ZONE_GAP})` : `${band.width}%`,
|
|
109
|
-
background: zone
|
|
140
|
+
background: zoneFill(zone, index, count)
|
|
110
141
|
};
|
|
111
142
|
}
|
|
143
|
+
const columnGapOf = (el) => Number.parseFloat(getComputedStyle(el).columnGap) || 0;
|
|
112
144
|
const sameLayout = (a, b) => a.shown.length === b.shown.length && a.shown.every(
|
|
113
145
|
(v, i) => v === b.shown[i] && a.short[i] === b.short[i] && a.shift[i] === b.shift[i]
|
|
114
146
|
);
|
|
@@ -136,7 +168,8 @@ function useRowLabelLayout(rowRef, slots, shortOf, key) {
|
|
|
136
168
|
return {
|
|
137
169
|
box: { left: r.left - origin.left, right: r.right - origin.left },
|
|
138
170
|
...a !== void 0 && b !== void 0 && { span: { left: Math.min(a, b), right: Math.max(a, b) } },
|
|
139
|
-
...slot?.holding && { holding: true }
|
|
171
|
+
...slot?.holding && { holding: true },
|
|
172
|
+
...slot?.end && { end: true }
|
|
140
173
|
};
|
|
141
174
|
});
|
|
142
175
|
shortOfRef.current.forEach((labelIndex, n) => {
|
|
@@ -144,7 +177,7 @@ function useRowLabelLayout(rowRef, slots, shortOf, key) {
|
|
|
144
177
|
const label = labels[labelIndex];
|
|
145
178
|
if (r && label) label.short = { left: r.left - origin.left, right: r.right - origin.left };
|
|
146
179
|
});
|
|
147
|
-
const placed = placeRowLabels(labels, origin.width);
|
|
180
|
+
const placed = placeRowLabels(labels, origin.width, columnGapOf(row));
|
|
148
181
|
const next = {
|
|
149
182
|
shown: placed.shown,
|
|
150
183
|
short: placed.short,
|
|
@@ -203,7 +236,7 @@ const TICK_LABEL_FLIP_PCT = 50;
|
|
|
203
236
|
function LabelRow({ zones, ticks }) {
|
|
204
237
|
const rowRef = useRef(null);
|
|
205
238
|
const slots = [
|
|
206
|
-
...ticks.map(() =>
|
|
239
|
+
...ticks.map((t) => t.pct <= 0 || t.pct >= 100 ? { end: true } : {}),
|
|
207
240
|
...zones.map((z) => ({
|
|
208
241
|
spanPct: [z.centrePct - z.widthPct / 2, z.centrePct + z.widthPct / 2],
|
|
209
242
|
holding: z.holding
|
|
@@ -272,52 +305,237 @@ function LabelRow({ zones, ticks }) {
|
|
|
272
305
|
}
|
|
273
306
|
);
|
|
274
307
|
}
|
|
308
|
+
function measureItems(row) {
|
|
309
|
+
const kids = [...row.children];
|
|
310
|
+
const widths = kids.map((kid) => {
|
|
311
|
+
const { whiteSpace, flex } = kid.style;
|
|
312
|
+
kid.style.whiteSpace = "nowrap";
|
|
313
|
+
kid.style.flex = "none";
|
|
314
|
+
const width = kid.offsetWidth;
|
|
315
|
+
kid.style.whiteSpace = whiteSpace;
|
|
316
|
+
kid.style.flex = flex;
|
|
317
|
+
return width;
|
|
318
|
+
});
|
|
319
|
+
return { widths, rowWidth: row.clientWidth, gap: columnGapOf(row) };
|
|
320
|
+
}
|
|
321
|
+
function useMeasured(rowRef, measure, key) {
|
|
322
|
+
const measureRef = useRef(measure);
|
|
323
|
+
useIsomorphicLayoutEffect(() => {
|
|
324
|
+
measureRef.current = measure;
|
|
325
|
+
});
|
|
326
|
+
useIsomorphicLayoutEffect(() => {
|
|
327
|
+
const row = rowRef.current;
|
|
328
|
+
if (!row) return;
|
|
329
|
+
const run = () => measureRef.current(row);
|
|
330
|
+
run();
|
|
331
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(run);
|
|
332
|
+
observer?.observe(row);
|
|
333
|
+
for (const kid of row.children) observer?.observe(kid);
|
|
334
|
+
const fonts = typeof document === "undefined" ? void 0 : document.fonts;
|
|
335
|
+
fonts?.addEventListener?.("loadingdone", run);
|
|
336
|
+
return () => {
|
|
337
|
+
observer?.disconnect();
|
|
338
|
+
fonts?.removeEventListener?.("loadingdone", run);
|
|
339
|
+
};
|
|
340
|
+
}, [rowRef, key]);
|
|
341
|
+
}
|
|
342
|
+
const sameStarts = (a, b) => a === b || a !== null && b !== null && a.length === b.length && a.every((v, i) => v === b[i]);
|
|
343
|
+
function CaptionRow({ items }) {
|
|
344
|
+
const rowRef = useRef(null);
|
|
345
|
+
const [starts, setStarts] = useState(null);
|
|
346
|
+
useMeasured(
|
|
347
|
+
rowRef,
|
|
348
|
+
(row) => {
|
|
349
|
+
const { widths, rowWidth, gap } = measureItems(row);
|
|
350
|
+
const marks = items.map((item, i) => ({
|
|
351
|
+
width: widths[i] ?? 0,
|
|
352
|
+
...item.pct !== void 0 && { pct: item.pct },
|
|
353
|
+
...item.edge !== void 0 && { edge: item.edge }
|
|
354
|
+
}));
|
|
355
|
+
const next = placeMarkCaptions(marks, rowWidth, gap);
|
|
356
|
+
setStarts((prev) => sameStarts(prev, next) ? prev : next);
|
|
357
|
+
},
|
|
358
|
+
items.map((i) => `${i.key}@${i.pct ?? i.edge ?? ""}:${typeof i.node === "string" ? i.node : ""}`).join("\0")
|
|
359
|
+
);
|
|
360
|
+
return /* @__PURE__ */ jsx(
|
|
361
|
+
"div",
|
|
362
|
+
{
|
|
363
|
+
ref: rowRef,
|
|
364
|
+
className: cx(classes.captions, starts !== null && classes.captionsAnchored),
|
|
365
|
+
"data-meter-captions": true,
|
|
366
|
+
"data-anchored": starts === null ? void 0 : "",
|
|
367
|
+
children: items.map((item, i) => /* @__PURE__ */ jsx(
|
|
368
|
+
"span",
|
|
369
|
+
{
|
|
370
|
+
className: item.end ? classes.captionEnd : classes.caption,
|
|
371
|
+
...starts?.[i] !== void 0 && { style: { insetInlineStart: `${starts[i]}px` } },
|
|
372
|
+
children: item.node
|
|
373
|
+
},
|
|
374
|
+
item.key
|
|
375
|
+
))
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
function PartCaptions({ captions }) {
|
|
380
|
+
const rowRef = useRef(null);
|
|
381
|
+
const [under, setUnder] = useState(false);
|
|
382
|
+
const [overwide, setOverwide] = useState(false);
|
|
383
|
+
useMeasured(
|
|
384
|
+
rowRef,
|
|
385
|
+
(row) => {
|
|
386
|
+
const { widths, rowWidth, gap } = measureItems(row);
|
|
387
|
+
setOverwide(widths.some((w) => w > rowWidth));
|
|
388
|
+
const fits = partsFitUnder(
|
|
389
|
+
captions.map((c, i) => ({ startPct: c.startPct, width: widths[i] ?? 0 })),
|
|
390
|
+
rowWidth,
|
|
391
|
+
gap
|
|
392
|
+
);
|
|
393
|
+
setUnder(fits);
|
|
394
|
+
},
|
|
395
|
+
captions.map((c) => `${c.label} ${c.text}@${c.startPct}`).join("\0")
|
|
396
|
+
);
|
|
397
|
+
return /* @__PURE__ */ jsx(
|
|
398
|
+
"ul",
|
|
399
|
+
{
|
|
400
|
+
ref: rowRef,
|
|
401
|
+
className: cx(
|
|
402
|
+
classes.partCaptions,
|
|
403
|
+
under && classes.partCaptionsUnder,
|
|
404
|
+
overwide && classes.partCaptionsWrap
|
|
405
|
+
),
|
|
406
|
+
role: "list",
|
|
407
|
+
"data-meter-parts": true,
|
|
408
|
+
"data-anchored": under ? "" : void 0,
|
|
409
|
+
children: captions.map((c) => /* @__PURE__ */ jsxs(
|
|
410
|
+
"li",
|
|
411
|
+
{
|
|
412
|
+
className: classes.partCaption,
|
|
413
|
+
...under && { style: { insetInlineStart: `${c.startPct}%` } },
|
|
414
|
+
children: [
|
|
415
|
+
/* @__PURE__ */ jsx(
|
|
416
|
+
"span",
|
|
417
|
+
{
|
|
418
|
+
className: classes.swatch,
|
|
419
|
+
style: { background: c.color ?? "var(--vx-line)" },
|
|
420
|
+
"aria-hidden": true
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
glueUnits(`${c.label} ${c.text}`)
|
|
424
|
+
]
|
|
425
|
+
},
|
|
426
|
+
c.key
|
|
427
|
+
))
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
275
431
|
function MeterBar(props) {
|
|
276
|
-
const { label,
|
|
432
|
+
const { label, min, max, format, zones, shell } = props;
|
|
277
433
|
const describedId = useId();
|
|
278
434
|
const model = modelBar(props);
|
|
279
435
|
const compact = shell.row;
|
|
280
|
-
const hosted = useContext(VisualSlotContext)
|
|
281
|
-
const
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
const
|
|
436
|
+
const hosted = useContext(VisualSlotContext) !== null;
|
|
437
|
+
const marked = model.markerPct !== void 0;
|
|
438
|
+
const readingOn = props.markerReading ?? (model.zoneLabels.length > 0 && !hosted);
|
|
439
|
+
const start = compact || marked && !readingOn && props.startCaption === void 0 ? null : startCaptionText(model, props.startCaption);
|
|
440
|
+
const anchored = marked && start !== null;
|
|
441
|
+
const trackHidden = props.track === false && model.parts.length === 1 && props.segments === void 0 && props.target === void 0 && model.ticks.length === 0;
|
|
442
|
+
const hasParts = model.partCaptions.length > 0;
|
|
443
|
+
const zoned = zones !== void 0 && zones.length > 0;
|
|
444
|
+
const labelled = model.ticks.filter((t) => t.label !== void 0);
|
|
445
|
+
const startFigure = !compact && !zoned && props.startCaption !== null && (model.ticks.length > 0 || model.targetPct !== void 0) && !labelled.some((t) => t.pct <= 0);
|
|
446
|
+
const tickLabels = compact ? [] : [
|
|
447
|
+
...startFigure ? [
|
|
448
|
+
{
|
|
449
|
+
key: "start",
|
|
450
|
+
pct: 0,
|
|
451
|
+
label: format(min),
|
|
452
|
+
caption: void 0,
|
|
453
|
+
text: ""
|
|
454
|
+
}
|
|
455
|
+
] : [],
|
|
456
|
+
...labelled
|
|
457
|
+
];
|
|
287
458
|
const zoneLabels = compact ? [] : model.zoneLabels;
|
|
288
459
|
const describedBy = model.describedByText === null ? {} : { "aria-describedby": describedId };
|
|
460
|
+
const endOverride = props.endCaption !== void 0;
|
|
461
|
+
const targetHere = !endOverride && model.targetPct !== void 0 && model.endText !== null;
|
|
462
|
+
const end = compact ? null : endOverride ? props.endCaption : model.endText;
|
|
463
|
+
const items = compact ? [] : [
|
|
464
|
+
...start !== null && !anchored ? [{ key: "start", node: glue(start) }] : [],
|
|
465
|
+
...model.forecastText !== null ? [
|
|
466
|
+
{
|
|
467
|
+
key: "forecast",
|
|
468
|
+
node: glue(model.forecastText),
|
|
469
|
+
...model.boundaryPct !== void 0 && { pct: model.boundaryPct }
|
|
470
|
+
}
|
|
471
|
+
] : [],
|
|
472
|
+
...compact ? [] : model.ticks.flatMap(
|
|
473
|
+
(t) => t.caption === void 0 ? [] : [
|
|
474
|
+
{
|
|
475
|
+
key: `tick${t.key}`,
|
|
476
|
+
node: glue(t.caption),
|
|
477
|
+
pct: t.pct
|
|
478
|
+
}
|
|
479
|
+
]
|
|
480
|
+
),
|
|
481
|
+
...end !== null ? [
|
|
482
|
+
{
|
|
483
|
+
key: "end",
|
|
484
|
+
node: glue(end),
|
|
485
|
+
end: true,
|
|
486
|
+
...targetHere && model.targetPct !== void 0 ? { pct: model.targetPct } : { edge: "end" }
|
|
487
|
+
}
|
|
488
|
+
] : []
|
|
489
|
+
];
|
|
289
490
|
const root = rootProps(shell);
|
|
290
491
|
return /* @__PURE__ */ jsxs("div", { ...root, className: root.className, children: [
|
|
291
492
|
tickLabels.length > 0 && zoneLabels.length === 0 && /* @__PURE__ */ jsx(LabelRow, { zones: zoneLabels, ticks: tickLabels }),
|
|
292
493
|
/* @__PURE__ */ jsxs(
|
|
293
494
|
"div",
|
|
294
495
|
{
|
|
295
|
-
className: classes.trackBox,
|
|
496
|
+
className: cx(classes.trackBox, trackHidden && classes.trackHidden),
|
|
497
|
+
"data-meter-track-hidden": trackHidden ? "" : void 0,
|
|
296
498
|
"aria-label": label,
|
|
297
|
-
...ariaValues(reading, min, max, format),
|
|
499
|
+
...ariaValues(props.reading, min, max, format),
|
|
298
500
|
...describedBy,
|
|
299
501
|
children: [
|
|
300
|
-
/* @__PURE__ */ jsxs(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
)),
|
|
310
|
-
model.parts.map((p, i) => /* @__PURE__ */ jsx(
|
|
311
|
-
"div",
|
|
312
|
-
{
|
|
313
|
-
className: cx(classes.fill, p.forecast && classes.forecastFill),
|
|
314
|
-
"data-meter-fill": p.forecast ? "forecast" : "committed",
|
|
315
|
-
"data-tone": props.tone === "muted" && p.color === void 0 && !p.forecast ? "muted" : void 0,
|
|
316
|
-
style: fillStyle(p)
|
|
502
|
+
/* @__PURE__ */ jsxs(
|
|
503
|
+
"div",
|
|
504
|
+
{
|
|
505
|
+
className: classes.track,
|
|
506
|
+
"data-meter-track": true,
|
|
507
|
+
...model.stopsCss !== void 0 && {
|
|
508
|
+
"data-meter-stops": "",
|
|
509
|
+
// theme-allow hidden-inline-style — the gradient is the consumer's colour data
|
|
510
|
+
style: { "--basalt-stops": model.stopsCss }
|
|
317
511
|
},
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
512
|
+
children: [
|
|
513
|
+
zones?.map(
|
|
514
|
+
(z, i) => model.markerPct !== void 0 && /* @__PURE__ */ jsx(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: classes.zone,
|
|
518
|
+
"data-meter-zone": z.label,
|
|
519
|
+
...i > 0 && zones[i - 1]?.tone === "muted" && z.tone === "muted" && { "data-meter-zone-seam": "" },
|
|
520
|
+
style: zoneStyle(z, i, zones.length, min, model.span)
|
|
521
|
+
},
|
|
522
|
+
i
|
|
523
|
+
)
|
|
524
|
+
),
|
|
525
|
+
model.parts.map((p, i) => /* @__PURE__ */ jsx(
|
|
526
|
+
"div",
|
|
527
|
+
{
|
|
528
|
+
className: cx(classes.fill, p.forecast && classes.forecastFill),
|
|
529
|
+
"data-meter-fill": p.forecast ? "forecast" : "committed",
|
|
530
|
+
...p.seam && { "data-meter-seam": "" },
|
|
531
|
+
"data-tone": props.tone === "muted" && p.color === void 0 && !p.forecast ? "muted" : void 0,
|
|
532
|
+
style: fillStyle(p)
|
|
533
|
+
},
|
|
534
|
+
i
|
|
535
|
+
))
|
|
536
|
+
]
|
|
537
|
+
}
|
|
538
|
+
),
|
|
321
539
|
/* @__PURE__ */ jsx(Tick, { kind: "marker", className: classes.marker, pct: model.markerPct }),
|
|
322
540
|
/* @__PURE__ */ jsx(Tick, { kind: "boundary", className: classes.boundaryTick, pct: model.boundaryPct }),
|
|
323
541
|
model.ticks.map((t) => /* @__PURE__ */ jsx(Tick, { kind: "tick", className: classes.tick, pct: t.pct }, t.key)),
|
|
@@ -328,24 +546,8 @@ function MeterBar(props) {
|
|
|
328
546
|
zoneLabels.length > 0 && /* @__PURE__ */ jsx(LabelRow, { zones: zoneLabels, ticks: tickLabels }),
|
|
329
547
|
anchored && /* @__PURE__ */ jsx(ZoneReading, { pct: model.markerPct ?? 0, children: start }),
|
|
330
548
|
model.describedByText !== null && /* @__PURE__ */ jsx(VisuallyHidden, { id: describedId, className: classes.summary, children: model.describedByText }),
|
|
331
|
-
hasParts &&
|
|
332
|
-
|
|
333
|
-
/* @__PURE__ */ jsx("ul", { className: classes.partCaptions, role: "list", "data-meter-parts": true, children: model.partCaptions.map((c) => /* @__PURE__ */ jsxs("li", { className: classes.partCaption, children: [
|
|
334
|
-
/* @__PURE__ */ jsx(
|
|
335
|
-
"span",
|
|
336
|
-
{
|
|
337
|
-
className: classes.swatch,
|
|
338
|
-
style: { background: c.color ?? "var(--vx-line)" },
|
|
339
|
-
"aria-hidden": true
|
|
340
|
-
}
|
|
341
|
-
),
|
|
342
|
-
glueUnits(`${c.label} ${c.text}`)
|
|
343
|
-
] }, c.key)) }),
|
|
344
|
-
hasCaptions && /* @__PURE__ */ jsxs("div", { className: classes.captions, "data-meter-captions": true, children: [
|
|
345
|
-
start !== null && !anchored && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(start) }),
|
|
346
|
-
!compact && model.forecastText !== null && /* @__PURE__ */ jsx("span", { className: classes.caption, children: glue(model.forecastText) }),
|
|
347
|
-
end !== null && /* @__PURE__ */ jsx("span", { className: classes.captionEnd, children: glue(end) })
|
|
348
|
-
] })
|
|
549
|
+
hasParts && /* @__PURE__ */ jsx(PartCaptions, { captions: model.partCaptions }),
|
|
550
|
+
items.length > 0 && /* @__PURE__ */ jsx(CaptionRow, { items })
|
|
349
551
|
] });
|
|
350
552
|
}
|
|
351
553
|
const TICK_WIDTH = "2px";
|
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Meter — one bounded quantity on a track: progress to a target, a committed/forecast split, a
|
|
3
|
-
* part-of-a-whole strip (`segments`), or a single headline ratio as a `ring`. Choose it for "how far
|
|
4
|
-
* along is this against a limit"; choose `BarList` for a ranking and a chart for a trend. An HTML/CSS
|
|
5
|
-
* primitive, not a chart kind (no scale, axis or tooltip).
|
|
6
|
-
*
|
|
7
|
-
* Colour law: a plain `value` bar's fill is neutral (`--vx-muted` at a strength that holds 3:1 on
|
|
8
|
-
* the track; `tone="ink"` for full ink); `segments` and `zones` keep their own fills. `color` is
|
|
9
|
-
* for a VERDICT only (over budget, below target) and is a status colour the consumer passes;
|
|
10
|
-
* categorical `segments` take the consumer's series colours. Committed vs forecast is the same neutral at two strengths — never colour alone: a
|
|
11
|
-
* tick marks the boundary and a caption names the forecast. A value past `max` clamps the fill at the
|
|
12
|
-
* track end; the caption still states the real value.
|
|
13
|
-
*
|
|
14
|
-
* `zones` (bar only) draws the track as contiguous bands (neutral at stepped strengths unless a zone
|
|
15
|
-
* passes a status colour) and the reading becomes a MARKER on the track, not a fill. Each zone is
|
|
16
|
-
* named under the band at its start, the one holding the value (`from` inclusive) in ink and a
|
|
17
|
-
* heavier weight; names that would collide wrap as a list instead. The fit is measured in the
|
|
18
|
-
* browser, so server markup shows the band and the list may appear after mount. Use it for a
|
|
19
|
-
* reading judged against ranges.
|
|
20
|
-
*
|
|
21
|
-
* Every state (bar, ring, empty, loading) carries `data-basalt-meter` on its root. That attribute is
|
|
22
|
-
* the contract with `StatCard`: a Meter passed as its `sparkline` visual makes the slot size to content
|
|
23
|
-
* and keep the card's inline inset (both placements) instead of the sparkline's fixed height and bleed.
|
|
24
|
-
*
|
|
25
|
-
* Categorical `segments` (no `forecast` part) are captioned one per part — swatch, name, value — under
|
|
26
|
-
* the track and the default start caption is dropped (an explicit `startCaption` still shows);
|
|
27
|
-
* committed/forecast keeps the reading plus the forecast caption.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* import { Meter } from 'basalt-ui'
|
|
31
|
-
*
|
|
32
|
-
* // Spend against a budget: past the target the end caption states the overage.
|
|
33
|
-
* <Meter label="Monthly spend" value={512} max={600} target={450} color="var(--vx-status-bad)" format={usd} />
|
|
34
|
-
* // Training load as a zone band with a marker: the zones are named under the band, "Optimal" in ink.
|
|
35
|
-
* <Meter
|
|
36
|
-
* label="Training load"
|
|
37
|
-
* max={1000}
|
|
38
|
-
* value={612}
|
|
39
|
-
* zones={[
|
|
40
|
-
* { from: 0, to: 300, label: 'Low' },
|
|
41
|
-
* { from: 300, to: 750, label: 'Optimal' },
|
|
42
|
-
* { from: 750, to: 1000, label: 'High' },
|
|
43
|
-
* ]}
|
|
44
|
-
* />
|
|
45
|
-
* // A readiness score on its 0–100 scale (its contributors: <BarList max={100} … secondary="Good" />).
|
|
46
|
-
* <Meter label="Recovery" value={72} max={100} />
|
|
47
|
-
* <Meter
|
|
48
|
-
* label="Course progress"
|
|
49
|
-
* max={120}
|
|
50
|
-
* segments={[{ value: 70, label: 'Done' }, { value: 25, label: 'Planned', forecast: true }]}
|
|
51
|
-
* />
|
|
52
|
-
* <Meter shape="ring" label="Cache hit rate" value={87} max={100} format={(v) => `${v}%`} />
|
|
53
|
-
*/
|
|
54
1
|
import type { ReactNode } from 'react';
|
|
55
2
|
import type { BasaltProps } from '../common/props.js';
|
|
56
3
|
import type { MeterSegment, MeterTick, MeterZone } from './meter-model.js';
|
|
@@ -65,7 +12,7 @@ type Common = BasaltProps & {
|
|
|
65
12
|
format?: (value: number) => string;
|
|
66
13
|
/** Renders a skeleton with the meter's footprint. */
|
|
67
14
|
loading?: boolean;
|
|
68
|
-
/** Muted line shown when there is no reading. The track stays so the footprint holds. */
|
|
15
|
+
/** Muted line shown when there is no reading; none by default (the reading is `—`). The track stays so the footprint holds. */
|
|
69
16
|
emptyText?: string;
|
|
70
17
|
};
|
|
71
18
|
type BarCommon = Common & {
|
|
@@ -74,10 +21,13 @@ type BarCommon = Common & {
|
|
|
74
21
|
target?: number;
|
|
75
22
|
/**
|
|
76
23
|
* More marks on the track (cut-offs, a window mean). Each is drawn at `at`; a `label` is captioned
|
|
77
|
-
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends)
|
|
78
|
-
* caption
|
|
79
|
-
*
|
|
80
|
-
* and `target`.
|
|
24
|
+
* above the track, or on a zoned Meter in the zone-name row (the end ticks at the row's ends); a
|
|
25
|
+
* `caption` sits under the track, centred on the mark and clamped inside it. A label that would
|
|
26
|
+
* collide with another hides. A tick outside `[min, max]` is dropped, not clamped. All are listed
|
|
27
|
+
* in the accessible description. Works with `value`, `zones`, `segments` and `target`.
|
|
28
|
+
*
|
|
29
|
+
* Given `ticks` (or a `target`), a plain or segmented bar also labels where its track starts: the
|
|
30
|
+
* start figure `format(min)`, above the track. `startCaption={null}` drops it.
|
|
81
31
|
*/
|
|
82
32
|
ticks?: readonly MeterTick[];
|
|
83
33
|
/**
|
|
@@ -89,27 +39,57 @@ type BarCommon = Common & {
|
|
|
89
39
|
tone?: 'muted' | 'ink';
|
|
90
40
|
/**
|
|
91
41
|
* `'row'`: in-line use — a track one text line tall and no caption rows (reading, target, forecast,
|
|
92
|
-
*
|
|
93
|
-
*
|
|
42
|
+
* zone and tick captions). Categorical `segments` keep their per-part captions (swatch, name, value)
|
|
43
|
+
* so the parts stay named. The label stays as `aria-label`; the described-by text keeps the rest.
|
|
44
|
+
* Put the value beside it in your own layout.
|
|
94
45
|
*/
|
|
95
46
|
size?: 'row';
|
|
96
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Start caption (default: the formatted reading). `null` drops it, and the start figure that
|
|
49
|
+
* `ticks`/`target` add above the track; zone labels stay.
|
|
50
|
+
*/
|
|
97
51
|
startCaption?: ReactNode;
|
|
98
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* End caption (default: `Target <target>` with the Meter's `format`, drawn at the target's tick
|
|
54
|
+
* rather than the track end when it fits). `null` drops it; zone labels stay.
|
|
55
|
+
*/
|
|
99
56
|
endCaption?: ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* The reading printed at the marker of a zoned bar. Default `true`, and `false` inside a basalt host
|
|
59
|
+
* (`StatCard`, a strip cell's `visual`) that already states the value. Pass `false` when YOUR
|
|
60
|
+
* headline states it: the marker stays and keeps its `aria-valuenow` / `aria-valuetext`. Pass `true`
|
|
61
|
+
* to print it inside a host. A `stops` track prints it only when `true`.
|
|
62
|
+
*/
|
|
63
|
+
reading?: boolean;
|
|
100
64
|
};
|
|
101
65
|
/**
|
|
102
66
|
* One of four forms; mixing them is a compile error.
|
|
103
67
|
* - Bar `value` (+ `target`, `color`): one reading on a neutral track.
|
|
104
68
|
* - Bar `segments`: ordered parts that sum to the reading (committed/forecast, part of a whole).
|
|
105
69
|
* - Bar `value` + `zones`: the reading is a marker against contiguous bands.
|
|
106
|
-
* -
|
|
70
|
+
* - Bar `value` + `stops`: the reading is a marker on one gradient track.
|
|
71
|
+
* - Ring (`shape: 'ring'`) `value` (+ `color`, `target`, `ticks`): one headline ratio; no captions,
|
|
72
|
+
* segments or zones.
|
|
107
73
|
*/
|
|
108
74
|
export type MeterProps = (BarCommon & {
|
|
109
75
|
/** The reading. `null`/`undefined` (or non-finite) renders the empty state. */
|
|
110
76
|
value?: number | null | undefined;
|
|
111
77
|
/** A status colour, for a verdict only. Omit for the neutral fill. */
|
|
112
78
|
color?: string;
|
|
79
|
+
/**
|
|
80
|
+
* `false` draws no track for a value with nothing to compare against (no `target`, no `ticks`):
|
|
81
|
+
* the track stays in the accessibility tree and the captions remain. A `target` or `ticks` keep it.
|
|
82
|
+
*/
|
|
83
|
+
track?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Draws the track as ONE gradient through these colours (the consumer's: tokens or its own
|
|
86
|
+
* values, `at` in the reading's units) and the reading as a marker on it. Not a zone: no names,
|
|
87
|
+
* and no labels unless `ticks` are given. Use it for a scale whose hue IS the quantity.
|
|
88
|
+
*/
|
|
89
|
+
stops?: readonly {
|
|
90
|
+
at: number;
|
|
91
|
+
color: string;
|
|
92
|
+
}[];
|
|
113
93
|
segments?: never;
|
|
114
94
|
zones?: never;
|
|
115
95
|
}) | (BarCommon & {
|
|
@@ -120,6 +100,8 @@ export type MeterProps = (BarCommon & {
|
|
|
120
100
|
value?: never;
|
|
121
101
|
color?: never;
|
|
122
102
|
zones?: never;
|
|
103
|
+
stops?: never;
|
|
104
|
+
track?: never;
|
|
123
105
|
}) | (BarCommon & {
|
|
124
106
|
value?: number | null | undefined;
|
|
125
107
|
/**
|
|
@@ -129,19 +111,26 @@ export type MeterProps = (BarCommon & {
|
|
|
129
111
|
zones: readonly MeterZone[];
|
|
130
112
|
segments?: never;
|
|
131
113
|
color?: never;
|
|
114
|
+
stops?: never;
|
|
115
|
+
track?: never;
|
|
132
116
|
}) | (Common & {
|
|
133
117
|
shape: 'ring';
|
|
134
118
|
value?: number | null | undefined;
|
|
135
119
|
/** A status colour, for a verdict only. */
|
|
136
120
|
color?: string;
|
|
121
|
+
/** A short radial mark at this value (a limit to compare the arc against); the value stays centred. */
|
|
122
|
+
target?: number;
|
|
123
|
+
/** More radial marks, each at its `at`; a `label` is for the accessible text only. */
|
|
124
|
+
ticks?: readonly MeterTick[];
|
|
137
125
|
segments?: never;
|
|
138
126
|
zones?: never;
|
|
139
|
-
target?: never;
|
|
140
|
-
ticks?: never;
|
|
141
127
|
tone?: never;
|
|
142
128
|
size?: never;
|
|
143
129
|
startCaption?: never;
|
|
144
130
|
endCaption?: never;
|
|
131
|
+
reading?: never;
|
|
132
|
+
stops?: never;
|
|
133
|
+
track?: never;
|
|
145
134
|
});
|
|
146
135
|
export declare function Meter(props: MeterProps): import("react").JSX.Element;
|
|
147
136
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meter.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter.tsx"],"names":[],"mappings":"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"}
|