basalt-ui 2.19.0 → 2.21.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 +89 -0
- package/MIGRATING.md +291 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +48 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +34 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +33 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +37 -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 +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +34 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +396 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -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 +18 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +39 -15
- package/dist/dashboard/bar-list.module.css +77 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -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 +53 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +62 -14
- 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 +140 -68
- package/dist/dashboard/meter.d.ts +29 -4
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +8 -1
- package/dist/dashboard/meter.module.css +74 -43
- package/dist/dashboard/meter.module.css.d.ts +4 -4
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +16 -10
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +1 -1
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +5 -7
- package/dist/dashboard/stat-card.module.css +15 -7
- 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 +67 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +115 -0
- package/dist/dashboard/stat-strip.module.css +291 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +32 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.module.css +10 -6
- 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 +16 -3
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +15 -1
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +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/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/controls.module.css +13 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +41 -0
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +3 -2
- package/dist/theme/status-dot.d.ts.map +1 -1
- package/dist/theme/status-dot.js +12 -3
- package/dist/theme/status-verdict.d.ts +3 -2
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +3 -2
- package/dist/theme/status-verdict.module.css +4 -2
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +33 -7
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +79 -5
- 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 +53 -4
- package/src/charts/types.ts +6 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +77 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +89 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +126 -20
- package/src/dashboard/meter-parts.tsx +224 -88
- package/src/dashboard/meter.module.css +74 -43
- package/src/dashboard/meter.module.css.d.ts +4 -4
- package/src/dashboard/meter.tsx +39 -5
- package/src/dashboard/query-state.tsx +26 -20
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +15 -7
- package/src/dashboard/stat-card.tsx +9 -9
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +291 -0
- package/src/dashboard/stat-strip.module.css.d.ts +32 -0
- package/src/dashboard/stat-strip.tsx +263 -0
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/dashboard/widget-header.module.css +10 -6
- package/src/dashboard/widget-header.tsx +3 -3
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +17 -5
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +202 -24
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/controls.module.css +13 -0
- package/src/theme/index.ts +56 -0
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.tsx +17 -5
- package/src/theme/status-verdict.module.css +4 -2
- package/src/theme/status-verdict.tsx +9 -4
- package/src/tokens/oklab.ts +97 -0
|
@@ -21,6 +21,9 @@ export type SyncButtonProps = BasaltProps & {
|
|
|
21
21
|
/** How often the relative age re-renders. One interval, only while mounted. */
|
|
22
22
|
export declare const AGE_REFRESH_MS = 30000;
|
|
23
23
|
/**
|
|
24
|
+
* The age label follows the `BasaltProvider` / `defineFormat` locale. It is read when the label is
|
|
25
|
+
* formatted, so a locale switch shows on the next age tick or re-render (no new subscription).
|
|
26
|
+
*
|
|
24
27
|
* @example
|
|
25
28
|
* // page scope — the page's own data
|
|
26
29
|
* <PageBar sync={{ syncing, lastCompletedAt, onSync: refetch }} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-button.d.ts","sourceRoot":"","sources":["../../src/controls/sync-button.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IACtC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB;sEACkE;IAClE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;IACxB;yBACqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,cAAc,QAAS,CAAA;AAmCpC
|
|
1
|
+
{"version":3,"file":"sync-button.d.ts","sourceRoot":"","sources":["../../src/controls/sync-button.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IACtC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB;sEACkE;IAClE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;IACxB;yBACqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,cAAc,QAAS,CAAA;AAmCpC;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,eAAe,EACf,MAAM,EACN,KAAK,EACL,KAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,GACN,EAAE,eAAe,GAAG,SAAS,CAkE7B"}
|
|
@@ -5,16 +5,30 @@ type BarListItem = {
|
|
|
5
5
|
value: number;
|
|
6
6
|
secondary?: ReactNode;
|
|
7
7
|
key?: string;
|
|
8
|
+
/** This row's own scale end: the bar fills value / max and the value reads "value / max". */
|
|
9
|
+
max?: number;
|
|
10
|
+
/** A hairline mark at this position on the row's scale (a threshold). */
|
|
11
|
+
tick?: number;
|
|
12
|
+
/** Names the tick for assistive tech (visually hidden text in the track). Default "Threshold". */
|
|
13
|
+
tickLabel?: string;
|
|
8
14
|
};
|
|
9
15
|
export type BarListProps = BasaltProps & {
|
|
10
16
|
/** Accessible name of the list. Required. */
|
|
11
17
|
label: string;
|
|
12
18
|
/** Rows in display order (sort them yourself; the list does not reorder). */
|
|
13
19
|
items: readonly BarListItem[];
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Formats each number. `part` is `'max'` for a row's denominator, `'value'` otherwise (the value and
|
|
22
|
+
* the tick), so a unit can sit on one side only: `'32 / 40 pts'`. Default: the number as written.
|
|
23
|
+
*/
|
|
24
|
+
format?: (value: number, part: 'value' | 'max') => string;
|
|
25
|
+
/** Scale end shared by rows without their own `max`. Default: the largest of those rows' values. */
|
|
17
26
|
max?: number;
|
|
27
|
+
/**
|
|
28
|
+
* `thin` (default): label on its own line above a thin bar, value right-aligned on that line.
|
|
29
|
+
* `inline`: the label sits inside a heavier track, the value outside it.
|
|
30
|
+
*/
|
|
31
|
+
variant?: 'thin' | 'inline';
|
|
18
32
|
/** The first row's bar takes the accent. Off by default. */
|
|
19
33
|
accentLeader?: boolean;
|
|
20
34
|
/** Renders row-shaped skeletons. */
|
|
@@ -24,6 +38,6 @@ export type BarListProps = BasaltProps & {
|
|
|
24
38
|
/** Muted line shown when `items` is empty. */
|
|
25
39
|
emptyText?: string;
|
|
26
40
|
};
|
|
27
|
-
export declare function BarList({ label, items, format, max, accentLeader, loading, loadingRows, emptyText, className, style, }: BarListProps): import("react").JSX.Element;
|
|
41
|
+
export declare function BarList({ label, items, format, max, variant, accentLeader, loading, loadingRows, emptyText, className, style, }: BarListProps): import("react").JSX.Element;
|
|
28
42
|
export {};
|
|
29
43
|
//# sourceMappingURL=bar-list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bar-list.d.ts","sourceRoot":"","sources":["../../src/dashboard/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B,EACpB,OAAe,EACf,WAAe,EACf,SAAqB,EACrB,SAAS,EACT,KAAK,GACN,EAAE,YAAY,+BA6Fd"}
|
|
@@ -9,6 +9,7 @@ function BarList({
|
|
|
9
9
|
items,
|
|
10
10
|
format = asText,
|
|
11
11
|
max,
|
|
12
|
+
variant = "thin",
|
|
12
13
|
accentLeader = false,
|
|
13
14
|
loading = false,
|
|
14
15
|
loadingRows = 5,
|
|
@@ -25,7 +26,11 @@ function BarList({
|
|
|
25
26
|
if (items.length === 0) {
|
|
26
27
|
return /* @__PURE__ */ jsx("output", { className: cx(classes.root, className), style, "aria-label": label, children: /* @__PURE__ */ jsx("span", { className: classes.empty, children: emptyText }) });
|
|
27
28
|
}
|
|
28
|
-
const scale = max ?? items.reduce(
|
|
29
|
+
const scale = max ?? items.reduce(
|
|
30
|
+
(top, i) => i.max === void 0 && Number.isFinite(i.value) ? Math.max(top, i.value) : top,
|
|
31
|
+
0
|
|
32
|
+
);
|
|
33
|
+
const thin = variant === "thin";
|
|
29
34
|
const hasSecondary = items.some((i) => hasContent(i.secondary));
|
|
30
35
|
return (
|
|
31
36
|
// The explicit role is deliberate: `list-style: none` makes Safari/VoiceOver drop the implicit one.
|
|
@@ -37,23 +42,42 @@ function BarList({
|
|
|
37
42
|
role: "list",
|
|
38
43
|
"aria-label": label,
|
|
39
44
|
"data-secondary": hasSecondary ? "" : void 0,
|
|
45
|
+
"data-variant": variant,
|
|
40
46
|
children: items.map((item, i) => {
|
|
41
47
|
const isLeader = accentLeader && i === 0;
|
|
48
|
+
const rowScale = item.max ?? scale;
|
|
49
|
+
const labelNode = /* @__PURE__ */ jsx("span", { className: classes.label, title: item.label, children: item.label });
|
|
50
|
+
const tickName = item.tick === void 0 ? "" : `${item.tickLabel ?? "Threshold"} ${format(item.tick, "value")}`;
|
|
51
|
+
const track = /* @__PURE__ */ jsxs("span", { className: classes.track, "data-bar-track": true, children: [
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
"span",
|
|
54
|
+
{
|
|
55
|
+
className: cx(classes.bar, isLeader && classes.leader),
|
|
56
|
+
style: { width: `${barPercent(item.value, rowScale)}%` },
|
|
57
|
+
"data-bar-fill": "",
|
|
58
|
+
"data-bar-leader": isLeader ? "" : void 0,
|
|
59
|
+
"aria-hidden": true
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
item.tick !== void 0 && // theme-allow hidden-inline-style — the position is the row's data (a % of its scale)
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
"span",
|
|
65
|
+
{
|
|
66
|
+
className: classes.tick,
|
|
67
|
+
style: { insetInlineStart: `${barPercent(item.tick, rowScale)}%` },
|
|
68
|
+
"data-bar-tick": "",
|
|
69
|
+
"aria-hidden": true
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
!thin && labelNode,
|
|
73
|
+
item.tick !== void 0 && /* @__PURE__ */ jsx(VisuallyHidden, { children: tickName })
|
|
74
|
+
] });
|
|
42
75
|
return /* @__PURE__ */ jsxs("li", { className: classes.row, children: [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
style: { width: `${barPercent(item.value, scale)}%` },
|
|
49
|
-
"data-bar-leader": isLeader ? "" : void 0,
|
|
50
|
-
"aria-hidden": true
|
|
51
|
-
}
|
|
52
|
-
),
|
|
53
|
-
/* @__PURE__ */ jsx("span", { className: classes.label, title: item.label, children: item.label })
|
|
54
|
-
] }),
|
|
55
|
-
/* @__PURE__ */ jsx("span", { className: classes.value, children: Number.isFinite(item.value) ? format(item.value) : "\u2014" }),
|
|
56
|
-
hasSecondary && /* @__PURE__ */ jsx("span", { className: classes.secondary, children: item.secondary })
|
|
76
|
+
thin && labelNode,
|
|
77
|
+
!thin && track,
|
|
78
|
+
/* @__PURE__ */ jsx("span", { className: classes.value, children: Number.isFinite(item.value) ? item.max === void 0 ? format(item.value, "value") : `${format(item.value, "value")} / ${format(item.max, "max")}` : "\u2014" }),
|
|
79
|
+
hasSecondary && /* @__PURE__ */ jsx("span", { className: classes.secondary, children: item.secondary }),
|
|
80
|
+
thin && track
|
|
57
81
|
] }, item.key ?? `${item.label}-${i}`);
|
|
58
82
|
})
|
|
59
83
|
}
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
.value {
|
|
65
|
-
font-family: var(--basalt-font-
|
|
65
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
66
|
+
font-variant-numeric: lining-nums;
|
|
66
67
|
text-align: end;
|
|
67
68
|
white-space: nowrap;
|
|
68
69
|
}
|
|
@@ -73,7 +74,8 @@
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
.secondary {
|
|
76
|
-
font-family: var(--basalt-font-
|
|
77
|
+
font-family: var(--basalt-font-numeral, var(--basalt-font-sans));
|
|
78
|
+
font-variant-numeric: lining-nums;
|
|
77
79
|
font-size: var(--vx-text-sm);
|
|
78
80
|
color: var(--vx-muted);
|
|
79
81
|
white-space: nowrap;
|
|
@@ -89,3 +91,76 @@
|
|
|
89
91
|
grid-column: 1 / -1;
|
|
90
92
|
height: calc(var(--vx-space-control-height-widget, 1.5rem) * var(--mantine-scale, 1));
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
/* A row's threshold: a hairline across the bar at a position on the row's own scale. */
|
|
96
|
+
.tick {
|
|
97
|
+
position: absolute;
|
|
98
|
+
inset-block: 0;
|
|
99
|
+
inline-size: 0;
|
|
100
|
+
border-inline-start: 1px solid var(--vx-ink);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Thin: label and value share the first line, the bar is a thin rail on the second spanning every
|
|
105
|
+
* column. The label column is still shared (subgrid), so the value columns stay aligned.
|
|
106
|
+
*/
|
|
107
|
+
.root[data-variant='thin'] .row {
|
|
108
|
+
grid-template-rows: auto auto;
|
|
109
|
+
row-gap: var(--vx-space-stack-xs, 0.25rem);
|
|
110
|
+
align-items: baseline;
|
|
111
|
+
padding-block: var(--vx-space-stack-xs, 0.25rem);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.root[data-variant='thin'] .track {
|
|
115
|
+
grid-column: 1 / -1;
|
|
116
|
+
align-self: auto;
|
|
117
|
+
block-size: 0.25rem;
|
|
118
|
+
padding-inline: 0;
|
|
119
|
+
border-radius: var(--vx-radius-fine);
|
|
120
|
+
background: color-mix(in srgb, var(--vx-line) 20%, transparent);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.root[data-variant='thin'] .bar {
|
|
124
|
+
background: color-mix(in srgb, var(--vx-line) 80%, transparent);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.root[data-variant='thin'] .bar.leader {
|
|
128
|
+
background: var(--vx-accent);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* The mark outgrows the rail so a 1px line stays visible against a 4px bar. */
|
|
132
|
+
.root[data-variant='thin'] .tick {
|
|
133
|
+
inset-block: calc(var(--vx-space-stack-xs, 0.25rem) * -1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
* Thin rows get a phone's width: the label wraps up to two lines, then truncates (its `title` carries
|
|
138
|
+
* the whole text), and the secondary column takes at most 40% of the list, clipped, so a long status
|
|
139
|
+
* never squeezes the title down to a few characters.
|
|
140
|
+
*/
|
|
141
|
+
.root[data-variant='thin'][data-secondary] {
|
|
142
|
+
grid-template-columns: minmax(0, 1fr) auto fit-content(40%);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.root[data-variant='thin'] .label {
|
|
146
|
+
display: -webkit-box;
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
white-space: normal;
|
|
149
|
+
overflow-wrap: anywhere;
|
|
150
|
+
-webkit-box-orient: vertical;
|
|
151
|
+
-webkit-line-clamp: 2;
|
|
152
|
+
line-clamp: 2;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.root[data-variant='thin'] .secondary {
|
|
156
|
+
min-width: 0;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.root[data-variant='thin'] .secondary [data-verdict-word] {
|
|
162
|
+
min-width: 0;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
text-overflow: ellipsis;
|
|
165
|
+
white-space: nowrap;
|
|
166
|
+
}
|
|
@@ -11,9 +11,14 @@ export type DeltaBadgeProps = {
|
|
|
11
11
|
format?: (value: number) => string;
|
|
12
12
|
/** Render the ▲/▼ direction glyph. Defaults to `true`; a zero value never shows a glyph. */
|
|
13
13
|
withGlyph?: boolean;
|
|
14
|
-
/** Optional comparison
|
|
15
|
-
* `
|
|
14
|
+
/** Optional comparison period rendered after the value, muted, as `<periodPrefix> <period>`
|
|
15
|
+
* (`period="last week"` → "vs last week"). One rule: the prefix is prepended unless the period
|
|
16
|
+
* already starts with it (case-insensitive, optional trailing dot: "vs", "VS", "vs."), so a caller
|
|
17
|
+
* still writing "vs last week" renders it once. Other words ("versus") are not detected. */
|
|
16
18
|
period?: string | undefined;
|
|
19
|
+
/** The word composed before `period`. Defaults to `'vs'`; pass your locale's word, or `''` to
|
|
20
|
+
* render `period` raw. */
|
|
21
|
+
periodPrefix?: string;
|
|
17
22
|
};
|
|
18
|
-
export declare function DeltaBadge({ value, polarity, format, withGlyph, period, }: DeltaBadgeProps): import("react").JSX.Element;
|
|
23
|
+
export declare function DeltaBadge({ value, polarity, format, withGlyph, period, periodPrefix, }: DeltaBadgeProps): import("react").JSX.Element;
|
|
19
24
|
//# sourceMappingURL=delta-badge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delta-badge.d.ts","sourceRoot":"","sources":["../../src/dashboard/delta-badge.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"delta-badge.d.ts","sourceRoot":"","sources":["../../src/dashboard/delta-badge.tsx"],"names":[],"mappings":"AA8BA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAA;IACb;;;kCAG8B;IAC9B,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;IAClC,4FAA4F;IAC5F,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;gGAG4F;IAC5F,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;8BAC0B;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAwBD,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAoB,EACpB,MAAsB,EACtB,SAAgB,EAChB,MAAM,EACN,YAAmB,GACpB,EAAE,eAAe,+BAejB"}
|
|
@@ -2,6 +2,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { VX } from "../tokens/index.js";
|
|
3
3
|
import classes from "./widget-header.module.css";
|
|
4
4
|
const defaultFormat = (value) => `${Math.abs(value).toFixed(1)}%`;
|
|
5
|
+
function composePeriod(period, prefix) {
|
|
6
|
+
if (prefix === "") return period;
|
|
7
|
+
const escaped = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8
|
+
return new RegExp(`^${escaped}\\.?(\\s|$)`, "i").test(period) ? period : `${prefix} ${period}`;
|
|
9
|
+
}
|
|
5
10
|
function resolveTone(value, polarity) {
|
|
6
11
|
if (value === 0 || polarity === "neutral") return VX.faint;
|
|
7
12
|
const rose = value > 0;
|
|
@@ -18,7 +23,8 @@ function DeltaBadge({
|
|
|
18
23
|
polarity = "up-good",
|
|
19
24
|
format = defaultFormat,
|
|
20
25
|
withGlyph = true,
|
|
21
|
-
period
|
|
26
|
+
period,
|
|
27
|
+
periodPrefix = "vs"
|
|
22
28
|
}) {
|
|
23
29
|
const tone = resolveTone(value, polarity);
|
|
24
30
|
const glyph = directionGlyph(value);
|
|
@@ -26,7 +32,8 @@ function DeltaBadge({
|
|
|
26
32
|
return /* @__PURE__ */ jsxs("span", { className: classes.deltaBadge, style: { color: tone }, children: [
|
|
27
33
|
showGlyph && /* @__PURE__ */ jsx("span", { className: classes.deltaGlyph, children: glyph }),
|
|
28
34
|
format(value),
|
|
29
|
-
period !== void 0 &&
|
|
35
|
+
period !== void 0 && " ",
|
|
36
|
+
period !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.deltaPeriod, children: composePeriod(period, periodPrefix) })
|
|
30
37
|
] });
|
|
31
38
|
}
|
|
32
39
|
export {
|
|
@@ -3,8 +3,10 @@ export { DeltaBadge } from './delta-badge.js';
|
|
|
3
3
|
export { Section } from './section.js';
|
|
4
4
|
export { StatCard, type StatCardBreakdownRow, type StatCardSparklineSize } from './stat-card.js';
|
|
5
5
|
export { StatGroup } from './stat-group.js';
|
|
6
|
+
export type { StatStripCell, StatStripRow } from './stat-strip.js';
|
|
6
7
|
export { EmptyState } from './empty-state.js';
|
|
7
8
|
export { SettingsSection, SettingsRow, DangerZone } from './settings-section.js';
|
|
8
9
|
export { Meter, type MeterProps } from './meter.js';
|
|
10
|
+
export type { MeterSegment, MeterTick, MeterZone } from './meter-model.js';
|
|
9
11
|
export { BarList, type BarListProps } from './bar-list.js';
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,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,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,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"}
|
|
@@ -13,8 +13,25 @@ export type MeterZone = {
|
|
|
13
13
|
from: number;
|
|
14
14
|
to: number;
|
|
15
15
|
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* A shorter name for a narrow track. The row tries `label`, then `short`, and only then hides the
|
|
18
|
+
* name; the holding zone always shows its full `label`. The described-by text keeps `label`.
|
|
19
|
+
*/
|
|
20
|
+
short?: string;
|
|
16
21
|
color?: string;
|
|
17
22
|
};
|
|
23
|
+
/** A mark on the track at `at` (in the reading's units). A label is captioned beside it. */
|
|
24
|
+
export type MeterTick = {
|
|
25
|
+
at: number;
|
|
26
|
+
label?: string;
|
|
27
|
+
};
|
|
28
|
+
/** One tick on the track: its percent position and what it says (caption `label`, aria `text`). */
|
|
29
|
+
export type TickMark = {
|
|
30
|
+
key: string;
|
|
31
|
+
pct: number;
|
|
32
|
+
label: string | undefined;
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
18
35
|
/** A fill on the track, as fractions (0–1) of the span, with the segment it was laid out from. */
|
|
19
36
|
export type Part = {
|
|
20
37
|
readonly start: number;
|
|
@@ -32,11 +49,14 @@ export type PartCaption = {
|
|
|
32
49
|
text: string;
|
|
33
50
|
color: string | undefined;
|
|
34
51
|
};
|
|
35
|
-
/** One zone's name on the
|
|
52
|
+
/** One zone's name on the label row: its span's centre and width (percent) and whether it holds the reading. */
|
|
36
53
|
export type ZoneLabel = {
|
|
37
54
|
key: string;
|
|
38
55
|
label: string;
|
|
39
|
-
|
|
56
|
+
/** The fallback name, when the zone has one. */
|
|
57
|
+
short?: string;
|
|
58
|
+
centrePct: number;
|
|
59
|
+
widthPct: number;
|
|
40
60
|
holding: boolean;
|
|
41
61
|
};
|
|
42
62
|
/**
|
|
@@ -45,6 +65,11 @@ export type ZoneLabel = {
|
|
|
45
65
|
*/
|
|
46
66
|
export type CaptionMode = 'reading' | 'parts' | 'forecast';
|
|
47
67
|
type Format = (value: number) => string;
|
|
68
|
+
/**
|
|
69
|
+
* The ticks that sit on the track, in the order given. A tick outside `[min, max]` (or not a number)
|
|
70
|
+
* is DROPPED, never clamped: a mark pinned to the end would state a position it is not at.
|
|
71
|
+
*/
|
|
72
|
+
export declare function tickMarks(ticks: readonly MeterTick[] | undefined, min: number, max: number, format: Format): TickMark[];
|
|
48
73
|
export declare const isReading: (n: number | null | undefined) => n is number;
|
|
49
74
|
/** The track's span. A track that ends at or before its start falls back to 1 and is `valid: false`. */
|
|
50
75
|
export declare function spanOf(min: number, max: number): {
|
|
@@ -75,11 +100,31 @@ export type LabelBox = {
|
|
|
75
100
|
right: number;
|
|
76
101
|
};
|
|
77
102
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
103
|
+
* A label on the shared row: its measured box and, for a zone name, the span it must stay inside.
|
|
104
|
+
* The holding zone's name never hides for width: it ignores its span and is shifted into the row.
|
|
105
|
+
*/
|
|
106
|
+
export type RowLabel = {
|
|
107
|
+
box: LabelBox;
|
|
108
|
+
span?: LabelBox;
|
|
109
|
+
holding?: boolean;
|
|
110
|
+
short?: LabelBox;
|
|
111
|
+
};
|
|
112
|
+
/** The placement of the row's labels, index-aligned with the input. */
|
|
113
|
+
export type RowPlacement = {
|
|
114
|
+
shown: boolean[];
|
|
115
|
+
/** Index-aligned with `shown`: the label shows as its `short` box rather than the full one. */
|
|
116
|
+
short: boolean[];
|
|
117
|
+
/** Pixels a shown label moves along the row's physical x axis to stay inside it (0 unless clamped). */
|
|
118
|
+
shift: number[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Which labels of the row show, in input order. The holding zone's name claims its place first (it
|
|
122
|
+
* is the reading's verdict, so it never hides for width: it may spill past its span, shifted inside
|
|
123
|
+
* the row); the labels without a span (the end ticks) go next; every other zone name then shows only
|
|
124
|
+
* 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. A hidden name is still named in the described-by text.
|
|
81
126
|
*/
|
|
82
|
-
export declare function
|
|
127
|
+
export declare function placeRowLabels(labels: readonly RowLabel[], rowWidth: number): RowPlacement;
|
|
83
128
|
/** A zone band as left edge + width in percent, clipped to the track. */
|
|
84
129
|
export declare function zoneBand(zone: MeterZone, min: number, span: number): {
|
|
85
130
|
start: number;
|
|
@@ -93,6 +138,7 @@ export type BarInput = {
|
|
|
93
138
|
segments?: readonly MeterSegment[] | undefined;
|
|
94
139
|
zones?: readonly MeterZone[] | undefined;
|
|
95
140
|
target?: number | undefined;
|
|
141
|
+
ticks?: readonly MeterTick[] | undefined;
|
|
96
142
|
color?: string | undefined;
|
|
97
143
|
forecastCaption?: string | undefined;
|
|
98
144
|
};
|
|
@@ -108,6 +154,7 @@ export type BarModel = {
|
|
|
108
154
|
partCaptions: readonly PartCaption[];
|
|
109
155
|
/** Only on a zoned track: every zone's name, in zone order. Empty otherwise. */
|
|
110
156
|
zoneLabels: readonly ZoneLabel[];
|
|
157
|
+
ticks: readonly TickMark[];
|
|
111
158
|
markerPct: number | undefined;
|
|
112
159
|
targetPct: number | undefined;
|
|
113
160
|
/** The default start caption (the zone is named on the band, so it is the bare reading); `startCaption` decides whether it shows. */
|
|
@@ -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;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAC/F,MAAM,MAAM,SAAS,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;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CA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Q,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,uDAAuD;IACvD,KAAK,EAAE,SAAS,IAAI,EAAE,CAAA;IACtB,8FAA8F;IAC9F,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,EAAE,WAAW,CAAA;IACxB,6EAA6E;IAC7E,YAAY,EAAE,SAAS,WAAW,EAAE,CAAA;IACpC,gFAAgF;IAChF,UAAU,EAAE,SAAS,SAAS,EAAE,CAAA;IAChC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;IAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,qIAAqI;IACrI,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,CAAA;AAeD,2FAA2F;AAC3F,eAAO,MAAM,cAAc,GAAI,UAAU,SAAS,YAAY,EAAE,EAAE,KAAK,MAAM,KAAG,MAC/B,CAAA;AA0BjD,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAG5F;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CA4DlD;AAED,8DAA8D;AAC9D,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MACvB,CAAA"}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { clamp01, toPct } from "./scale.js";
|
|
2
|
+
function tickMarks(ticks, min, max, format) {
|
|
3
|
+
const { span } = spanOf(min, max);
|
|
4
|
+
return (ticks ?? []).flatMap(
|
|
5
|
+
(t, i) => Number.isFinite(t.at) && t.at >= min && t.at <= max ? [
|
|
6
|
+
{
|
|
7
|
+
key: String(i),
|
|
8
|
+
pct: toPct((t.at - min) / span),
|
|
9
|
+
label: t.label,
|
|
10
|
+
text: `${t.label ?? "Tick"} ${format(t.at)}`
|
|
11
|
+
}
|
|
12
|
+
] : []
|
|
13
|
+
);
|
|
14
|
+
}
|
|
2
15
|
const isReading = (n) => typeof n === "number" && Number.isFinite(n);
|
|
3
16
|
function spanOf(min, max) {
|
|
4
17
|
return max > min ? { span: max - min, valid: true } : { span: 1, valid: false };
|
|
@@ -37,11 +50,37 @@ function findHoldingZone(zones, value) {
|
|
|
37
50
|
return zones.find((z) => value >= z.from && (value < z.to || value === z.to && z.to === end));
|
|
38
51
|
}
|
|
39
52
|
const LABEL_SUBPIXEL = 0.5;
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
function placeRowLabels(labels, rowWidth) {
|
|
54
|
+
const shown = labels.map(() => false);
|
|
55
|
+
const short = labels.map(() => false);
|
|
56
|
+
const shift = labels.map(() => 0);
|
|
57
|
+
const kept = [];
|
|
58
|
+
const rank = (l) => l.holding ? 0 : l.span ? 2 : 1;
|
|
59
|
+
const order = labels.map((_, i) => i).toSorted((a, b) => rank(labels[a]) - rank(labels[b]));
|
|
60
|
+
const clears = (b) => !kept.some((k) => b.left < k.right - LABEL_SUBPIXEL && k.left < b.right - LABEL_SUBPIXEL);
|
|
61
|
+
for (const i of order) {
|
|
62
|
+
const label = labels[i];
|
|
63
|
+
const { span } = label;
|
|
64
|
+
let box = label.box;
|
|
65
|
+
if (label.holding) {
|
|
66
|
+
const width = box.right - box.left;
|
|
67
|
+
const left = Math.max(0, Math.min(box.left, rowWidth - width));
|
|
68
|
+
shift[i] = left - box.left;
|
|
69
|
+
box = { left, right: left + width };
|
|
70
|
+
if (!clears(box)) continue;
|
|
71
|
+
shown[i] = true;
|
|
72
|
+
kept.push(box);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
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);
|
|
76
|
+
const useShort = !fits(box) && label.short !== void 0 && fits(label.short);
|
|
77
|
+
if (useShort) box = label.short;
|
|
78
|
+
else if (!fits(box)) continue;
|
|
79
|
+
shown[i] = true;
|
|
80
|
+
short[i] = useShort;
|
|
81
|
+
kept.push(box);
|
|
82
|
+
}
|
|
83
|
+
return { shown, short, shift };
|
|
45
84
|
}
|
|
46
85
|
function zoneBand(zone, min, span) {
|
|
47
86
|
const lo = clamp01((zone.from - min) / span);
|
|
@@ -80,6 +119,7 @@ function startCaptionText(model, override) {
|
|
|
80
119
|
}
|
|
81
120
|
function modelBar(input) {
|
|
82
121
|
const { reading, min, max, format, segments, zones, target } = input;
|
|
122
|
+
const ticks = tickMarks(input.ticks, min, max, format);
|
|
83
123
|
const { span } = spanOf(min, max);
|
|
84
124
|
const zoned = zones !== void 0 && zones.length > 0;
|
|
85
125
|
const holding = zoned ? findHoldingZone(zones, reading) : void 0;
|
|
@@ -95,7 +135,8 @@ function modelBar(input) {
|
|
|
95
135
|
const describedBy = [
|
|
96
136
|
...segments?.map((s) => segmentText(s, format)) ?? [],
|
|
97
137
|
...zoneText,
|
|
98
|
-
...target === void 0 ? [] : [`Target ${format(target)}`]
|
|
138
|
+
...target === void 0 ? [] : [`Target ${format(target)}`],
|
|
139
|
+
...ticks.map((t) => t.text)
|
|
99
140
|
];
|
|
100
141
|
return {
|
|
101
142
|
span,
|
|
@@ -104,12 +145,18 @@ function modelBar(input) {
|
|
|
104
145
|
forecastText: forecastLabels.length === 0 ? null : input.forecastCaption ?? `Forecast: ${forecastLabels.join(", ")}`,
|
|
105
146
|
captionMode,
|
|
106
147
|
partCaptions,
|
|
107
|
-
zoneLabels: !zoned ? [] : zones.map((z, i) =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
148
|
+
zoneLabels: !zoned ? [] : zones.map((z, i) => {
|
|
149
|
+
const band = zoneBand(z, min, span);
|
|
150
|
+
return {
|
|
151
|
+
key: String(i),
|
|
152
|
+
label: z.label,
|
|
153
|
+
...z.short !== void 0 && { short: z.short },
|
|
154
|
+
centrePct: band.start + band.width / 2,
|
|
155
|
+
widthPct: band.width,
|
|
156
|
+
holding: z === holding
|
|
157
|
+
};
|
|
158
|
+
}),
|
|
159
|
+
ticks,
|
|
113
160
|
markerPct: zoned ? toPct((reading - min) / span) : void 0,
|
|
114
161
|
targetPct: target === void 0 ? void 0 : toPct((target - min) / span),
|
|
115
162
|
startText: format(reading),
|
|
@@ -126,10 +173,11 @@ export {
|
|
|
126
173
|
layoutSegments,
|
|
127
174
|
modelBar,
|
|
128
175
|
normalizeSegments,
|
|
176
|
+
placeRowLabels,
|
|
129
177
|
ringFraction,
|
|
130
178
|
segmentReading,
|
|
131
179
|
spanOf,
|
|
132
180
|
startCaptionText,
|
|
133
|
-
|
|
134
|
-
|
|
181
|
+
tickMarks,
|
|
182
|
+
zoneBand
|
|
135
183
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import type { MeterSegment, MeterZone } from './meter-model.js';
|
|
2
|
+
import type { MeterSegment, MeterTick, MeterZone } from './meter-model.js';
|
|
3
3
|
export type Shell = {
|
|
4
4
|
className: string | undefined;
|
|
5
5
|
style: CSSProperties | undefined;
|
|
6
|
+
/** `size="row"`: one text line tall, no caption rows. */
|
|
7
|
+
row: boolean;
|
|
6
8
|
};
|
|
7
9
|
export declare function MeterLoading({ label, ring, shell, }: {
|
|
8
10
|
label: string;
|
|
@@ -34,6 +36,8 @@ export declare function MeterBar(props: {
|
|
|
34
36
|
segments: readonly MeterSegment[] | undefined;
|
|
35
37
|
zones: readonly MeterZone[] | undefined;
|
|
36
38
|
target: number | undefined;
|
|
39
|
+
ticks: readonly MeterTick[] | undefined;
|
|
40
|
+
tone: 'muted' | undefined;
|
|
37
41
|
forecastCaption: string | undefined;
|
|
38
42
|
startCaption: ReactNode;
|
|
39
43
|
endCaption: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meter-parts.d.ts","sourceRoot":"","sources":["../../src/dashboard/meter-parts.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,
|
|
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;AAWhE,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACT,SAAS,EAKV,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;AA8DD,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,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA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