basalt-ui 2.21.0 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/MIGRATING.md +277 -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 +27 -3
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +5 -0
- package/dist/charts/CartesianChart.d.ts +8 -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 +29 -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 +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +39 -14
- 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 +20 -1
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +9 -0
- package/dist/charts/chart-box.module.css +19 -0
- package/dist/charts/chart-card.module.css +25 -0
- package/dist/charts/chart-legend.module.css +7 -0
- package/dist/charts/compile.d.ts +17 -6
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +145 -74
- package/dist/charts/labels.d.ts +15 -4
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +34 -10
- 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 +26 -0
- package/dist/charts/ref-label.d.ts.map +1 -0
- package/dist/charts/ref-label.js +63 -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 +10 -11
- 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 +2 -1
- package/dist/charts/types.d.ts +14 -5
- 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 +194 -32
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +14 -1
- package/dist/cli/shot/playwright.d.ts +5 -2
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/types.d.ts +2 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- 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.map +1 -1
- package/dist/dashboard/bar-list.js +7 -8
- package/dist/dashboard/bar-list.module.css +53 -0
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- 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 +77 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +88 -15
- package/dist/dashboard/meter-parts.d.ts +8 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +238 -71
- package/dist/dashboard/meter.d.ts +43 -60
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +20 -3
- package/dist/dashboard/meter.module.css +61 -0
- package/dist/dashboard/meter.module.css.d.ts +5 -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/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 +17 -0
- package/dist/dashboard/stat-strip.d.ts +7 -1
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +74 -46
- package/dist/dashboard/stat-strip.module.css +67 -20
- 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/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 +34 -2
- 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 +23 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +8 -20
- 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 +4 -0
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +4 -0
- package/dist/tokens/status-text.d.ts.map +1 -1
- package/dist/tokens/status-text.js +3 -1
- package/llms.txt +38 -20
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +33 -3
- package/src/charts/Bars.tsx +6 -0
- package/src/charts/CartesianChart.tsx +16 -3
- package/src/charts/ChartCard.tsx +34 -6
- 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 +50 -13
- package/src/charts/StackedArea.tsx +14 -4
- package/src/charts/band-fold.ts +31 -1
- package/src/charts/chart-box.module.css +19 -0
- package/src/charts/chart-card.module.css +25 -0
- package/src/charts/chart-legend.module.css +7 -0
- package/src/charts/compile.ts +210 -85
- package/src/charts/labels.ts +48 -14
- 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 +104 -0
- package/src/charts/scales.ts +22 -2
- package/src/charts/sparkline.module.css +10 -11
- package/src/charts/sparkline.module.css.d.ts +1 -2
- package/src/charts/state.tsx +3 -1
- package/src/charts/types.ts +14 -5
- package/src/cli/doctor-upgrade.ts +1 -1
- package/src/cli/init.ts +100 -3
- package/src/cli/shot/capture.ts +251 -32
- package/src/cli/shot/detect.ts +18 -1
- package/src/cli/shot/playwright.ts +2 -2
- package/src/cli/shot/types.ts +3 -0
- 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 +53 -0
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +78 -69
- package/src/dashboard/index.ts +1 -0
- package/src/dashboard/meter-model.ts +186 -20
- package/src/dashboard/meter-parts.tsx +285 -64
- package/src/dashboard/meter.module.css +61 -0
- package/src/dashboard/meter.module.css.d.ts +5 -0
- package/src/dashboard/meter.tsx +60 -10
- 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/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 +17 -0
- package/src/dashboard/stat-card.tsx +12 -6
- package/src/dashboard/stat-strip.module.css +67 -20
- package/src/dashboard/stat-strip.module.css.d.ts +4 -0
- package/src/dashboard/stat-strip.tsx +118 -72
- package/src/dashboard/visual-slot.ts +12 -3
- package/src/guard/vx-names.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles.css +34 -2
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +186 -60
- package/src/theme/chrome-vars.ts +77 -8
- package/src/theme/controls.module.css +23 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +12 -25
- package/src/tokens/core.ts +4 -1
- package/src/tokens/derive.ts +32 -3
- package/src/tokens/palette.ts +4 -0
- package/src/tokens/status-text.ts +2 -0
|
@@ -34,8 +34,22 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* The phone form's age (`2 m`): hidden above `sm`, where the long age already sits beside the label.
|
|
38
|
+
* `nowrap` is the whole point of it — a two-token string that wraps inside a 32px button is worse
|
|
39
|
+
* than no age at all.
|
|
40
|
+
*/
|
|
41
|
+
.ageCompact {
|
|
42
|
+
display: none;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
color: var(--vx-muted);
|
|
45
|
+
font-family: var(--basalt-font-mono);
|
|
46
|
+
font-size: var(--vx-text-xs);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* `scope: 'page'` below `sm`: the label and the long age go, the glyph stays, and the button
|
|
51
|
+
* collapses to the square icon form (spec §3) — unless an age exists, in which case the compact age
|
|
52
|
+
* rides beside the glyph and the square pin is released (argo m365 refresh at 390). Hidden, not unmounted — a second
|
|
39
53
|
* mount under `hiddenFrom` is exactly the responsive twin law C9 forbids, which is also why the
|
|
40
54
|
* accessible name lives on `aria-label` rather than in this text.
|
|
41
55
|
*
|
|
@@ -52,6 +66,10 @@
|
|
|
52
66
|
display: none;
|
|
53
67
|
}
|
|
54
68
|
|
|
69
|
+
.ageCompact {
|
|
70
|
+
display: inline;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
.pageButton {
|
|
56
74
|
--button-padding-x: 0;
|
|
57
75
|
|
|
@@ -61,4 +79,18 @@
|
|
|
61
79
|
.pageButton :global(.mantine-Button-section[data-position='left']) {
|
|
62
80
|
margin-inline-end: 0;
|
|
63
81
|
}
|
|
82
|
+
|
|
83
|
+
/* An age beside the glyph: content-width, on the `ctl` inset, glyph and age one control gap apart. */
|
|
84
|
+
.pageButton[data-with-age] {
|
|
85
|
+
--button-padding-x: var(--button-padding-x-ctl);
|
|
86
|
+
|
|
87
|
+
/* Mantine divides the inline-start padding by 1.5 when a left section exists — off the scale. */
|
|
88
|
+
padding-inline: var(--button-padding-x-ctl);
|
|
89
|
+
width: auto;
|
|
90
|
+
flex: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.pageButton[data-with-age] :global(.mantine-Button-section[data-position='left']) {
|
|
94
|
+
margin-inline-end: var(--vx-space-control-gap);
|
|
95
|
+
}
|
|
64
96
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-list.d.ts","sourceRoot":"","sources":["../../src/dashboard/bar-list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bar-list.d.ts","sourceRoot":"","sources":["../../src/dashboard/bar-list.tsx"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIlD,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,6FAA6F;IAC7F,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,KAAK,MAAM,CAAA;IACzD,oGAAoG;IACpG,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC3B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAMD,wBAAgB,OAAO,CAAC,EACtB,KAAK,EACL,KAAK,EACL,MAAe,EACf,GAAG,EACH,OAAgB,EAChB,YAAoB,EACpB,OAAe,EACf,WAAe,EACf,SAAqB,EACrB,SAAS,EACT,KAAK,GACN,EAAE,YAAY,+BAmGd"}
|
|
@@ -18,13 +18,13 @@ function BarList({
|
|
|
18
18
|
style
|
|
19
19
|
}) {
|
|
20
20
|
if (loading) {
|
|
21
|
-
return /* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ jsx("div", { className: cx(classes.frame, className), style, children: /* @__PURE__ */ jsxs("div", { className: classes.root, "aria-busy": "true", children: [
|
|
22
22
|
/* @__PURE__ */ jsx(VisuallyHidden, { children: `Loading ${label}` }),
|
|
23
23
|
Array.from({ length: loadingRows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { className: classes.skeletonRow, "data-bar-skeleton": true }, i))
|
|
24
|
-
] });
|
|
24
|
+
] }) });
|
|
25
25
|
}
|
|
26
26
|
if (items.length === 0) {
|
|
27
|
-
return /* @__PURE__ */ jsx("
|
|
27
|
+
return /* @__PURE__ */ jsx("div", { className: cx(classes.frame, className), style, children: /* @__PURE__ */ jsx("output", { className: classes.root, "aria-label": label, children: /* @__PURE__ */ jsx("span", { className: classes.empty, children: emptyText }) }) });
|
|
28
28
|
}
|
|
29
29
|
const scale = max ?? items.reduce(
|
|
30
30
|
(top, i) => i.max === void 0 && Number.isFinite(i.value) ? Math.max(top, i.value) : top,
|
|
@@ -33,12 +33,11 @@ function BarList({
|
|
|
33
33
|
const thin = variant === "thin";
|
|
34
34
|
const hasSecondary = items.some((i) => hasContent(i.secondary));
|
|
35
35
|
return (
|
|
36
|
-
// The
|
|
37
|
-
/* @__PURE__ */ jsx(
|
|
36
|
+
// The frame is the width container the wide layout keys on (a container cannot restyle its own grid).
|
|
37
|
+
/* @__PURE__ */ jsx("div", { className: cx(classes.frame, className), style, children: /* @__PURE__ */ jsx(
|
|
38
38
|
"ul",
|
|
39
39
|
{
|
|
40
|
-
className:
|
|
41
|
-
style,
|
|
40
|
+
className: classes.root,
|
|
42
41
|
role: "list",
|
|
43
42
|
"aria-label": label,
|
|
44
43
|
"data-secondary": hasSecondary ? "" : void 0,
|
|
@@ -81,7 +80,7 @@ function BarList({
|
|
|
81
80
|
] }, item.key ?? `${item.label}-${i}`);
|
|
82
81
|
})
|
|
83
82
|
}
|
|
84
|
-
)
|
|
83
|
+
) })
|
|
85
84
|
);
|
|
86
85
|
}
|
|
87
86
|
export {
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
* row never wraps: the label truncates, the value is nowrap.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/*
|
|
9
|
+
* The width container the wide layout keys on (a container cannot restyle its own grid), in every
|
|
10
|
+
* state. It is named `basalt-card` because the theme guard permits only the declared names; that
|
|
11
|
+
* shadows an enclosing card's container for the list's descendants only, and the query below measures
|
|
12
|
+
* the LIST's own inline size, not the card's. `inline-size: 100%` keeps it from collapsing to zero in
|
|
13
|
+
* a flex row or an auto track (size containment ignores content width).
|
|
14
|
+
*/
|
|
15
|
+
.frame {
|
|
16
|
+
container: basalt-card / inline-size;
|
|
17
|
+
inline-size: 100%;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
8
21
|
.root {
|
|
9
22
|
display: grid;
|
|
10
23
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
@@ -164,3 +177,43 @@
|
|
|
164
177
|
text-overflow: ellipsis;
|
|
165
178
|
white-space: nowrap;
|
|
166
179
|
}
|
|
180
|
+
|
|
181
|
+
/*
|
|
182
|
+
* Wide (a container of 480px or more): one row, `[label][value][secondary][track]`. The label column fits the
|
|
183
|
+
* longest label (capped at 40% or 14rem, the rest truncates with its `title`), value and secondary are right-
|
|
184
|
+
* aligned and shared by every row, and the track takes the remaining width on the one scale — a
|
|
185
|
+
* full-scale bar ends at the track end, never under a value. Compact keeps the stacked thin layout.
|
|
186
|
+
*/
|
|
187
|
+
@container basalt-card (width >= 480px) {
|
|
188
|
+
.root[data-variant='thin'] {
|
|
189
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto minmax(0, 1fr);
|
|
190
|
+
column-gap: var(--vx-space-stack-md, 0.75rem);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.root[data-variant='thin'][data-secondary] {
|
|
194
|
+
grid-template-columns: fit-content(min(40%, 14rem)) auto fit-content(30%) minmax(0, 1fr);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.root[data-variant='thin'] .row {
|
|
198
|
+
grid-template-rows: auto;
|
|
199
|
+
align-items: center;
|
|
200
|
+
padding-block: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.root[data-variant='thin'] .track {
|
|
204
|
+
grid-column: auto;
|
|
205
|
+
align-self: center;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.root[data-variant='thin'] .label {
|
|
209
|
+
display: block;
|
|
210
|
+
white-space: nowrap;
|
|
211
|
+
text-overflow: ellipsis;
|
|
212
|
+
-webkit-line-clamp: unset;
|
|
213
|
+
line-clamp: unset;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.root[data-variant='thin'] .secondary {
|
|
217
|
+
text-align: end;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { WidgetHeader } from './widget-header.js';
|
|
2
2
|
export { DeltaBadge } from './delta-badge.js';
|
|
3
3
|
export { Section } from './section.js';
|
|
4
|
+
export { PageSummary, type PageSummaryProps } from './page-summary.js';
|
|
4
5
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card.js';
|
|
5
6
|
export { StatGroup } from './stat-group.js';
|
|
6
7
|
export type { StatStripCell, StatStripRow } from './stat-strip.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WidgetHeader } from "./widget-header.js";
|
|
2
2
|
import { DeltaBadge } from "./delta-badge.js";
|
|
3
3
|
import { Section } from "./section.js";
|
|
4
|
+
import { PageSummary } from "./page-summary.js";
|
|
4
5
|
import { StatCard } from "./stat-card.js";
|
|
5
6
|
import { StatGroup } from "./stat-group.js";
|
|
6
7
|
import { EmptyState } from "./empty-state.js";
|
|
@@ -13,6 +14,7 @@ export {
|
|
|
13
14
|
DeltaBadge,
|
|
14
15
|
EmptyState,
|
|
15
16
|
Meter,
|
|
17
|
+
PageSummary,
|
|
16
18
|
Section,
|
|
17
19
|
SettingsRow,
|
|
18
20
|
SettingsSection,
|
|
@@ -7,12 +7,22 @@ export type MeterSegment = {
|
|
|
7
7
|
value: number;
|
|
8
8
|
label: string;
|
|
9
9
|
color?: string;
|
|
10
|
+
/**
|
|
11
|
+
* `'muted'`: the part takes a step of the muted ramp (a lightness step per muted part). A `color`
|
|
12
|
+
* wins. Steps stay ≥15 points apart up to five muted parts; more merge at the cap.
|
|
13
|
+
*/
|
|
14
|
+
tone?: 'muted';
|
|
10
15
|
forecast?: boolean;
|
|
11
16
|
};
|
|
12
17
|
export type MeterZone = {
|
|
13
18
|
from: number;
|
|
14
19
|
to: number;
|
|
15
20
|
label: string;
|
|
21
|
+
/**
|
|
22
|
+
* `'muted'`: the band takes its step of the muted ramp instead of the line ramp. A `color` wins.
|
|
23
|
+
* Steps stay ≥15 points apart up to six zones; more merge at the cap.
|
|
24
|
+
*/
|
|
25
|
+
tone?: 'muted';
|
|
16
26
|
/**
|
|
17
27
|
* A shorter name for a narrow track. The row tries `label`, then `short`, and only then hides the
|
|
18
28
|
* name; the holding zone always shows its full `label`. The described-by text keeps `label`.
|
|
@@ -25,6 +35,33 @@ export type MeterTick = {
|
|
|
25
35
|
at: number;
|
|
26
36
|
label?: string;
|
|
27
37
|
};
|
|
38
|
+
/** A colour of a `stops` gradient at `at` (in the reading's units); the colour is the consumer's. */
|
|
39
|
+
type MeterStop = {
|
|
40
|
+
at: number;
|
|
41
|
+
color: string;
|
|
42
|
+
};
|
|
43
|
+
/** A ramp step's strength in percent of its neutral: from `lo`, spread over `step` across the steps. */
|
|
44
|
+
export declare const RAMP_ZONE: {
|
|
45
|
+
lo: number;
|
|
46
|
+
step: number;
|
|
47
|
+
solo: number;
|
|
48
|
+
};
|
|
49
|
+
export declare const RAMP_PART: {
|
|
50
|
+
lo: number;
|
|
51
|
+
step: number;
|
|
52
|
+
solo: number;
|
|
53
|
+
};
|
|
54
|
+
/** Neighbouring steps stay at least this far apart (the contrast the zone ramp always had), up to `RAMP_MAX`. */
|
|
55
|
+
export declare const RAMP_MIN_STEP = 15;
|
|
56
|
+
export declare const RAMP_MAX = 95;
|
|
57
|
+
/**
|
|
58
|
+
* Step `index` of `count`. The spread is floored at `RAMP_MIN_STEP` per step, so a ramp stays
|
|
59
|
+
* distinguishable by lightness up to six zones (five segments); past that the last steps clamp at
|
|
60
|
+
* `RAMP_MAX` and merge, which is the cue to group parts.
|
|
61
|
+
*/
|
|
62
|
+
export declare function rampStrength(index: number, count: number, ramp: typeof RAMP_ZONE): number;
|
|
63
|
+
/** A zone's fill: its own colour, else its step of the line (or, `tone="muted"`, the muted) ramp. */
|
|
64
|
+
export declare function zoneFill(zone: MeterZone, index: number, count: number): string;
|
|
28
65
|
/** One tick on the track: its percent position and what it says (caption `label`, aria `text`). */
|
|
29
66
|
export type TickMark = {
|
|
30
67
|
key: string;
|
|
@@ -48,6 +85,8 @@ export type PartCaption = {
|
|
|
48
85
|
label: string;
|
|
49
86
|
text: string;
|
|
50
87
|
color: string | undefined;
|
|
88
|
+
/** Where the part starts on the track, in percent: the caption sits under it when they all fit. */
|
|
89
|
+
startPct: number;
|
|
51
90
|
};
|
|
52
91
|
/** One zone's name on the label row: its span's centre and width (percent) and whether it holds the reading. */
|
|
53
92
|
export type ZoneLabel = {
|
|
@@ -70,6 +109,13 @@ type Format = (value: number) => string;
|
|
|
70
109
|
* is DROPPED, never clamped: a mark pinned to the end would state a position it is not at.
|
|
71
110
|
*/
|
|
72
111
|
export declare function tickMarks(ticks: readonly MeterTick[] | undefined, min: number, max: number, format: Format): TickMark[];
|
|
112
|
+
/** A `stops` gradient's colour list, in order along the track; `at` outside `[min, max]` clamps. */
|
|
113
|
+
export declare function stopsGradient(stops: readonly MeterStop[], min: number, span: number): string;
|
|
114
|
+
/** A ring's marks (target, ticks): the angle clockwise from the top, and the accessible text. */
|
|
115
|
+
export declare function ringMarks(target: number | undefined, ticks: readonly MeterTick[] | undefined, min: number, max: number, format: Format): {
|
|
116
|
+
angle: number;
|
|
117
|
+
text: string;
|
|
118
|
+
}[];
|
|
73
119
|
export declare const isReading: (n: number | null | undefined) => n is number;
|
|
74
120
|
/** The track's span. A track that ends at or before its start falls back to 1 and is `valid: false`. */
|
|
75
121
|
export declare function spanOf(min: number, max: number): {
|
|
@@ -107,6 +153,8 @@ export type RowLabel = {
|
|
|
107
153
|
box: LabelBox;
|
|
108
154
|
span?: LabelBox;
|
|
109
155
|
holding?: boolean;
|
|
156
|
+
/** A tick at the track's start or end: it yields to every zone name it would touch. */
|
|
157
|
+
end?: boolean;
|
|
110
158
|
short?: LabelBox;
|
|
111
159
|
};
|
|
112
160
|
/** The placement of the row's labels, index-aligned with the input. */
|
|
@@ -120,11 +168,13 @@ export type RowPlacement = {
|
|
|
120
168
|
/**
|
|
121
169
|
* Which labels of the row show, in input order. The holding zone's name claims its place first (it
|
|
122
170
|
* is the reading's verdict, so it never hides for width: it may spill past its span, shifted inside
|
|
123
|
-
* the row); the
|
|
171
|
+
* the row); the other ticks go next; every other zone name then shows only
|
|
124
172
|
* when it lies inside the row and its own span and clears every label already kept, trying its full
|
|
125
|
-
* name and then its `short` box
|
|
173
|
+
* name and then its `short` box; the end ticks (at the track's start or end) go last, so they yield
|
|
174
|
+
* to any name they would touch. A tick keeps at least `gap` px (one gap step of the host's
|
|
175
|
+
* spacing) from every other label; zone names among themselves only must not touch. A hidden name is still named in the described-by text.
|
|
126
176
|
*/
|
|
127
|
-
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number): RowPlacement;
|
|
177
|
+
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number, gap?: number): RowPlacement;
|
|
128
178
|
/** A zone band as left edge + width in percent, clipped to the track. */
|
|
129
179
|
export declare function zoneBand(zone: MeterZone, min: number, span: number): {
|
|
130
180
|
start: number;
|
|
@@ -137,6 +187,7 @@ export type BarInput = {
|
|
|
137
187
|
format: Format;
|
|
138
188
|
segments?: readonly MeterSegment[] | undefined;
|
|
139
189
|
zones?: readonly MeterZone[] | undefined;
|
|
190
|
+
stops?: readonly MeterStop[] | undefined;
|
|
140
191
|
target?: number | undefined;
|
|
141
192
|
ticks?: readonly MeterTick[] | undefined;
|
|
142
193
|
color?: string | undefined;
|
|
@@ -152,6 +203,8 @@ export type BarModel = {
|
|
|
152
203
|
captionMode: CaptionMode;
|
|
153
204
|
/** Only in `parts` mode: one caption per part, in order. Empty otherwise. */
|
|
154
205
|
partCaptions: readonly PartCaption[];
|
|
206
|
+
/** The `stops` gradient's colour list; absent without `stops`. */
|
|
207
|
+
stopsCss: string | undefined;
|
|
155
208
|
/** Only on a zoned track: every zone's name, in zone order. Empty otherwise. */
|
|
156
209
|
zoneLabels: readonly ZoneLabel[];
|
|
157
210
|
ticks: readonly TickMark[];
|
|
@@ -169,5 +222,26 @@ export declare function startCaptionText(model: BarModel, override: ReactNode |
|
|
|
169
222
|
export declare function modelBar(input: BarInput): BarModel;
|
|
170
223
|
/** The ring's one arc, as a fraction of the circumference. */
|
|
171
224
|
export declare const ringFraction: (reading: number, min: number, max: number) => number;
|
|
225
|
+
/** One caption on the marks row: its natural width and where it is anchored (`pct`), else its edge. */
|
|
226
|
+
export type MarkItem = {
|
|
227
|
+
width: number;
|
|
228
|
+
pct?: number;
|
|
229
|
+
edge?: 'end';
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Where each caption of the marks row starts (px, logical start edge), index-aligned with `items`: an
|
|
233
|
+
* anchored caption is centred on its mark and clamped inside the row, the others sit at the start (or,
|
|
234
|
+
* `edge: 'end'`, the end). `null` when nothing is anchored, the row is unmeasured, a caption is wider
|
|
235
|
+
* than the row, or two captions would sit closer than `gap`: the row then flows and wraps instead.
|
|
236
|
+
*/
|
|
237
|
+
export declare function placeMarkCaptions(items: readonly MarkItem[], rowWidth: number, gap: number): number[] | null;
|
|
238
|
+
/**
|
|
239
|
+
* Whether every categorical part's caption fits under its own segment: left-aligned at the part's
|
|
240
|
+
* start and ending before the next part's start (less `gap`) or the row's end. A zero-width part never fits.
|
|
241
|
+
*/
|
|
242
|
+
export declare function partsFitUnder(parts: readonly {
|
|
243
|
+
startPct: number;
|
|
244
|
+
width: number;
|
|
245
|
+
}[], rowWidth: number, gap: number): boolean;
|
|
172
246
|
export {};
|
|
173
247
|
//# sourceMappingURL=meter-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-model.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,MAAM,YAAY,GAAG;
|
|
1
|
+
{"version":3,"file":"meter-model.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AACD,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtD,qGAAqG;AACrG,KAAK,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,C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4
|
+
const RAMP_MIN_STEP = 15;
|
|
5
|
+
const RAMP_MAX = 95;
|
|
6
|
+
function rampStrength(index, count, ramp) {
|
|
7
|
+
if (count <= 1) return ramp.solo;
|
|
8
|
+
return Math.min(RAMP_MAX, ramp.lo + index * Math.max(RAMP_MIN_STEP, ramp.step / (count - 1)));
|
|
9
|
+
}
|
|
10
|
+
function rampFill(base, index, count, ramp) {
|
|
11
|
+
return `color-mix(in srgb, var(--vx-${base}) ${rampStrength(index, count, ramp)}%, transparent)`;
|
|
12
|
+
}
|
|
13
|
+
function zoneFill(zone, index, count) {
|
|
14
|
+
return zone.color ?? rampFill(zone.tone === "muted" ? "muted" : "line", index, count, RAMP_ZONE);
|
|
15
|
+
}
|
|
2
16
|
function tickMarks(ticks, min, max, format) {
|
|
3
17
|
const { span } = spanOf(min, max);
|
|
4
18
|
return (ticks ?? []).flatMap(
|
|
@@ -12,6 +26,22 @@ function tickMarks(ticks, min, max, format) {
|
|
|
12
26
|
] : []
|
|
13
27
|
);
|
|
14
28
|
}
|
|
29
|
+
function stopsGradient(stops, min, span) {
|
|
30
|
+
return stops.toSorted((a, b) => a.at - b.at).map((s) => `${s.color} ${toPct(clamp01((s.at - min) / span))}%`).join(", ");
|
|
31
|
+
}
|
|
32
|
+
const ringAngle = (pct) => Math.round(pct * 3.6 * 100) / 100;
|
|
33
|
+
function ringMarks(target, ticks, min, max, format) {
|
|
34
|
+
const { span } = spanOf(min, max);
|
|
35
|
+
const marks = tickMarks(ticks, min, max, format).map((t) => ({
|
|
36
|
+
angle: ringAngle(t.pct),
|
|
37
|
+
text: t.text
|
|
38
|
+
}));
|
|
39
|
+
if (target === void 0 || !Number.isFinite(target) || target < min || target > max) return marks;
|
|
40
|
+
return [
|
|
41
|
+
{ angle: ringAngle(toPct((target - min) / span)), text: `Target ${format(target)}` },
|
|
42
|
+
...marks
|
|
43
|
+
];
|
|
44
|
+
}
|
|
15
45
|
const isReading = (n) => typeof n === "number" && Number.isFinite(n);
|
|
16
46
|
function spanOf(min, max) {
|
|
17
47
|
return max > min ? { span: max - min, valid: true } : { span: 1, valid: false };
|
|
@@ -30,13 +60,16 @@ function normalizeSegments(segments) {
|
|
|
30
60
|
}
|
|
31
61
|
function layoutSegments(segments, span) {
|
|
32
62
|
let cursor = 0;
|
|
63
|
+
const isMuted = (s) => s.tone === "muted" && s.color === void 0 && !s.forecast;
|
|
64
|
+
const mutedCount = segments.filter(isMuted).length;
|
|
65
|
+
let muted = 0;
|
|
33
66
|
return segments.map((s) => {
|
|
34
67
|
const size = Math.max(0, Math.min(clamp01(s.value / span), 1 - cursor));
|
|
35
68
|
const forecast = s.forecast === true;
|
|
36
69
|
const part = {
|
|
37
70
|
start: cursor,
|
|
38
71
|
size,
|
|
39
|
-
color: forecast ? void 0 : s.color,
|
|
72
|
+
color: forecast ? void 0 : isMuted(s) ? rampFill("muted", muted++, mutedCount, RAMP_PART) : s.color,
|
|
40
73
|
forecast,
|
|
41
74
|
label: s.label,
|
|
42
75
|
amount: s.value
|
|
@@ -50,35 +83,39 @@ function findHoldingZone(zones, value) {
|
|
|
50
83
|
return zones.find((z) => value >= z.from && (value < z.to || value === z.to && z.to === end));
|
|
51
84
|
}
|
|
52
85
|
const LABEL_SUBPIXEL = 0.5;
|
|
53
|
-
function placeRowLabels(labels, rowWidth) {
|
|
86
|
+
function placeRowLabels(labels, rowWidth, gap = 0) {
|
|
54
87
|
const shown = labels.map(() => false);
|
|
55
88
|
const short = labels.map(() => false);
|
|
56
89
|
const shift = labels.map(() => 0);
|
|
57
90
|
const kept = [];
|
|
58
|
-
const rank = (l) => l.holding ? 0 : l.span ? 2 : 1;
|
|
91
|
+
const rank = (l) => l.holding ? 0 : l.end ? 3 : l.span ? 2 : 1;
|
|
59
92
|
const order = labels.map((_, i) => i).toSorted((a, b) => rank(labels[a]) - rank(labels[b]));
|
|
60
|
-
const clears = (b) => !kept.some((
|
|
93
|
+
const clears = (b, tick) => !kept.some(({ box: k, tick: kTick }) => {
|
|
94
|
+
const pad = tick || kTick ? gap : 0;
|
|
95
|
+
return b.left < k.right + pad - LABEL_SUBPIXEL && k.left < b.right + pad - LABEL_SUBPIXEL;
|
|
96
|
+
});
|
|
61
97
|
for (const i of order) {
|
|
62
98
|
const label = labels[i];
|
|
63
99
|
const { span } = label;
|
|
100
|
+
const tick = span === void 0 && !label.holding;
|
|
64
101
|
let box = label.box;
|
|
65
102
|
if (label.holding) {
|
|
66
103
|
const width = box.right - box.left;
|
|
67
104
|
const left = Math.max(0, Math.min(box.left, rowWidth - width));
|
|
68
105
|
shift[i] = left - box.left;
|
|
69
106
|
box = { left, right: left + width };
|
|
70
|
-
if (!clears(box)) continue;
|
|
107
|
+
if (!clears(box, false)) continue;
|
|
71
108
|
shown[i] = true;
|
|
72
|
-
kept.push(box);
|
|
109
|
+
kept.push({ box, tick: false });
|
|
73
110
|
continue;
|
|
74
111
|
}
|
|
75
|
-
const fits = (b) => b.left >= -LABEL_SUBPIXEL && b.right <= rowWidth + LABEL_SUBPIXEL && (span === void 0 || b.left >= span.left - LABEL_SUBPIXEL && b.right <= span.right + LABEL_SUBPIXEL) && clears(b);
|
|
112
|
+
const fits = (b) => b.left >= -LABEL_SUBPIXEL && b.right <= rowWidth + LABEL_SUBPIXEL && (span === void 0 || b.left >= span.left - LABEL_SUBPIXEL && b.right <= span.right + LABEL_SUBPIXEL) && clears(b, tick);
|
|
76
113
|
const useShort = !fits(box) && label.short !== void 0 && fits(label.short);
|
|
77
114
|
if (useShort) box = label.short;
|
|
78
115
|
else if (!fits(box)) continue;
|
|
79
116
|
shown[i] = true;
|
|
80
117
|
short[i] = useShort;
|
|
81
|
-
kept.push(box);
|
|
118
|
+
kept.push({ box, tick });
|
|
82
119
|
}
|
|
83
120
|
return { shown, short, shift };
|
|
84
121
|
}
|
|
@@ -93,8 +130,8 @@ function endCaptionText(reading, target, format) {
|
|
|
93
130
|
if (reading > target) return `Target ${format(target)} \xB7 ${format(reading - target)} over`;
|
|
94
131
|
return `Target ${format(target)}`;
|
|
95
132
|
}
|
|
96
|
-
function fillParts(input, span,
|
|
97
|
-
if (
|
|
133
|
+
function fillParts(input, span, marked) {
|
|
134
|
+
if (marked) return [];
|
|
98
135
|
if (input.segments !== void 0) return layoutSegments(input.segments, span);
|
|
99
136
|
const fill = { value: input.reading - input.min, label: "" };
|
|
100
137
|
return layoutSegments([input.color === void 0 ? fill : { ...fill, color: input.color }], span);
|
|
@@ -105,7 +142,8 @@ function partCaptionsOf(parts, format) {
|
|
|
105
142
|
key: String(i),
|
|
106
143
|
label: p.label,
|
|
107
144
|
text: format(p.amount),
|
|
108
|
-
color: p.color
|
|
145
|
+
color: p.color,
|
|
146
|
+
startPct: toPct(p.start)
|
|
109
147
|
}));
|
|
110
148
|
}
|
|
111
149
|
function captionModeOf(segments, zoned, firstForecast) {
|
|
@@ -118,12 +156,13 @@ function startCaptionText(model, override) {
|
|
|
118
156
|
return model.captionMode === "parts" ? null : model.startText;
|
|
119
157
|
}
|
|
120
158
|
function modelBar(input) {
|
|
121
|
-
const { reading, min, max, format, segments, zones, target } = input;
|
|
159
|
+
const { reading, min, max, format, segments, zones, target, stops } = input;
|
|
122
160
|
const ticks = tickMarks(input.ticks, min, max, format);
|
|
123
161
|
const { span } = spanOf(min, max);
|
|
124
162
|
const zoned = zones !== void 0 && zones.length > 0;
|
|
125
163
|
const holding = zoned ? findHoldingZone(zones, reading) : void 0;
|
|
126
|
-
const
|
|
164
|
+
const striped = !zoned && stops !== void 0 && stops.length > 0;
|
|
165
|
+
const parts = fillParts(input, span, zoned || striped);
|
|
127
166
|
const firstForecast = parts.findIndex((p) => p.forecast);
|
|
128
167
|
const forecastLabels = segments?.filter((s) => s.forecast === true).map((s) => `${s.label} ${format(s.value)}`) ?? [];
|
|
129
168
|
const captionMode = captionModeOf(segments, zoned, firstForecast);
|
|
@@ -145,6 +184,7 @@ function modelBar(input) {
|
|
|
145
184
|
forecastText: forecastLabels.length === 0 ? null : input.forecastCaption ?? `Forecast: ${forecastLabels.join(", ")}`,
|
|
146
185
|
captionMode,
|
|
147
186
|
partCaptions,
|
|
187
|
+
stopsCss: striped ? stopsGradient(stops, min, span) : void 0,
|
|
148
188
|
zoneLabels: !zoned ? [] : zones.map((z, i) => {
|
|
149
189
|
const band = zoneBand(z, min, span);
|
|
150
190
|
return {
|
|
@@ -157,7 +197,7 @@ function modelBar(input) {
|
|
|
157
197
|
};
|
|
158
198
|
}),
|
|
159
199
|
ticks,
|
|
160
|
-
markerPct: zoned ? toPct((reading - min) / span) : void 0,
|
|
200
|
+
markerPct: zoned || striped ? toPct((reading - min) / span) : void 0,
|
|
161
201
|
targetPct: target === void 0 ? void 0 : toPct((target - min) / span),
|
|
162
202
|
startText: format(reading),
|
|
163
203
|
endText: endCaptionText(reading, target, format),
|
|
@@ -165,19 +205,52 @@ function modelBar(input) {
|
|
|
165
205
|
};
|
|
166
206
|
}
|
|
167
207
|
const ringFraction = (reading, min, max) => clamp01((reading - min) / spanOf(min, max).span);
|
|
208
|
+
function placeMarkCaptions(items, rowWidth, gap) {
|
|
209
|
+
if (rowWidth <= 0 || !items.some((i) => i.pct !== void 0)) return null;
|
|
210
|
+
if (items.some((i) => i.width > rowWidth)) return null;
|
|
211
|
+
const lefts = items.map((i) => {
|
|
212
|
+
if (i.pct === void 0) return i.edge === "end" ? rowWidth - i.width : 0;
|
|
213
|
+
return Math.max(0, Math.min(rowWidth * i.pct / 100 - i.width / 2, rowWidth - i.width));
|
|
214
|
+
});
|
|
215
|
+
const order = lefts.map((_, i) => i).toSorted((a, b) => (lefts[a] ?? 0) - (lefts[b] ?? 0));
|
|
216
|
+
const crowded = order.some((i, n) => {
|
|
217
|
+
const next = order[n + 1];
|
|
218
|
+
return next !== void 0 && (lefts[next] ?? 0) < (lefts[i] ?? 0) + (items[i]?.width ?? 0) + gap - LABEL_SUBPIXEL;
|
|
219
|
+
});
|
|
220
|
+
return crowded ? null : lefts;
|
|
221
|
+
}
|
|
222
|
+
function partsFitUnder(parts, rowWidth, gap) {
|
|
223
|
+
if (rowWidth <= 0) return false;
|
|
224
|
+
return parts.every((p, i) => {
|
|
225
|
+
const left = rowWidth * p.startPct / 100;
|
|
226
|
+
const next = parts[i + 1];
|
|
227
|
+
const limit = next === void 0 ? rowWidth : rowWidth * next.startPct / 100 - gap;
|
|
228
|
+
return left + p.width <= limit + LABEL_SUBPIXEL;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
168
231
|
export {
|
|
169
232
|
LABEL_SUBPIXEL,
|
|
233
|
+
RAMP_MAX,
|
|
234
|
+
RAMP_MIN_STEP,
|
|
235
|
+
RAMP_PART,
|
|
236
|
+
RAMP_ZONE,
|
|
170
237
|
ariaValues,
|
|
171
238
|
findHoldingZone,
|
|
172
239
|
isReading,
|
|
173
240
|
layoutSegments,
|
|
174
241
|
modelBar,
|
|
175
242
|
normalizeSegments,
|
|
243
|
+
partsFitUnder,
|
|
244
|
+
placeMarkCaptions,
|
|
176
245
|
placeRowLabels,
|
|
246
|
+
rampStrength,
|
|
177
247
|
ringFraction,
|
|
248
|
+
ringMarks,
|
|
178
249
|
segmentReading,
|
|
179
250
|
spanOf,
|
|
180
251
|
startCaptionText,
|
|
252
|
+
stopsGradient,
|
|
181
253
|
tickMarks,
|
|
182
|
-
zoneBand
|
|
254
|
+
zoneBand,
|
|
255
|
+
zoneFill
|
|
183
256
|
};
|
|
@@ -23,6 +23,8 @@ export declare function MeterRing(props: {
|
|
|
23
23
|
min: number;
|
|
24
24
|
max: number;
|
|
25
25
|
color: string | undefined;
|
|
26
|
+
target: number | undefined;
|
|
27
|
+
ticks: readonly MeterTick[] | undefined;
|
|
26
28
|
format: (value: number) => string;
|
|
27
29
|
shell: Shell;
|
|
28
30
|
}): import("react").JSX.Element;
|
|
@@ -35,6 +37,12 @@ export declare function MeterBar(props: {
|
|
|
35
37
|
color: string | undefined;
|
|
36
38
|
segments: readonly MeterSegment[] | undefined;
|
|
37
39
|
zones: readonly MeterZone[] | undefined;
|
|
40
|
+
stops: readonly {
|
|
41
|
+
at: number;
|
|
42
|
+
color: string;
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
track: boolean | undefined;
|
|
45
|
+
markerReading: boolean | undefined;
|
|
38
46
|
target: number | undefined;
|
|
39
47
|
ticks: readonly MeterTick[] | undefined;
|
|
40
48
|
tone: 'muted' | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAehE,OAAO,KAAK,EAEV,YAAY,EACZ,SAAS,EACT,SAAS,EAMV,MAAM,eAAe,CAAA;AAKtB,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAA;IAChC,yDAAyD;IACzD,GAAG,EAAE,OAAO,CAAA;CACb,CAAA;AA0FD,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,IAAI,EACJ,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,KAAK,CAAA;CACb,+BAcA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,+BAgB7F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,G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