basalt-ui 2.18.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/MIGRATING.md +238 -12
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +33 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +28 -3
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +33 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +32 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/commands/notifications/center.d.ts.map +1 -1
- package/dist/commands/notifications/center.js +18 -26
- package/dist/content/callout.d.ts +1 -1
- package/dist/content/callout.d.ts.map +1 -1
- package/dist/content/callout.js +10 -1
- package/dist/content/callout.module.css +15 -3
- package/dist/content/callout.module.css.d.ts +1 -0
- package/dist/controls/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +15 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +56 -19
- package/dist/dashboard/bar-list.module.css +110 -17
- package/dist/dashboard/bar-list.module.css.d.ts +2 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +68 -1
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +65 -4
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +234 -60
- package/dist/dashboard/meter.d.ts +38 -6
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +4 -1
- package/dist/dashboard/meter.module.css +209 -13
- package/dist/dashboard/meter.module.css.d.ts +16 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -9
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.d.ts +3 -1
- package/dist/dashboard/stat-card-parts.d.ts.map +1 -1
- package/dist/dashboard/stat-card-parts.js +18 -3
- package/dist/dashboard/stat-card.d.ts +7 -6
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +51 -83
- package/dist/dashboard/stat-card.module.css +42 -14
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +50 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +85 -0
- package/dist/dashboard/stat-strip.module.css +208 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +28 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +2 -1
- package/dist/dashboard/widget-header.module.css +38 -7
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/chrome-vars.d.ts +29 -17
- package/dist/theme/chrome-vars.d.ts.map +1 -1
- package/dist/theme/chrome-vars.js +18 -8
- package/dist/theme/controls.module.css +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +32 -5
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +7 -0
- package/dist/theme/status-dot.d.ts.map +1 -0
- package/dist/theme/status-dot.js +18 -0
- package/dist/theme/status-dot.module.css +9 -0
- package/dist/theme/status-dot.module.css.d.ts +8 -0
- package/dist/theme/status-verdict.d.ts +10 -0
- package/dist/theme/status-verdict.d.ts.map +1 -0
- package/dist/theme/status-verdict.js +14 -0
- package/dist/theme/status-verdict.module.css +25 -0
- package/dist/theme/status-verdict.module.css.d.ts +9 -0
- package/llms.txt +30 -6
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +70 -4
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +44 -4
- package/src/charts/types.ts +6 -0
- package/src/commands/notifications/center.tsx +29 -32
- package/src/content/callout.module.css +15 -3
- package/src/content/callout.module.css.d.ts +1 -0
- package/src/content/callout.tsx +15 -2
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +110 -17
- package/src/dashboard/bar-list.module.css.d.ts +2 -0
- package/src/dashboard/bar-list.tsx +102 -21
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +132 -4
- package/src/dashboard/meter-parts.tsx +305 -25
- package/src/dashboard/meter.module.css +209 -13
- package/src/dashboard/meter.module.css.d.ts +16 -0
- package/src/dashboard/meter.tsx +42 -7
- package/src/dashboard/query-state.tsx +28 -19
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +22 -2
- package/src/dashboard/stat-card.module.css +42 -14
- package/src/dashboard/stat-card.tsx +23 -60
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +208 -0
- package/src/dashboard/stat-strip.module.css.d.ts +28 -0
- package/src/dashboard/stat-strip.tsx +183 -0
- package/src/dashboard/widget-header.module.css +38 -7
- package/src/dashboard/widget-header.tsx +7 -4
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +1 -1
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +242 -26
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/chrome-vars.ts +48 -23
- package/src/theme/controls.module.css +3 -0
- package/src/theme/index.ts +40 -6
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.module.css +9 -0
- package/src/theme/status-dot.module.css.d.ts +8 -0
- package/src/theme/status-dot.tsx +31 -0
- package/src/theme/status-verdict.module.css +25 -0
- package/src/theme/status-verdict.module.css.d.ts +9 -0
- package/src/theme/status-verdict.tsx +32 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Component `vars` that carry the Wave 33 chrome (`
|
|
2
|
+
* Component `vars` that carry the Wave 33 chrome (`MIGRATING.md` § Light and outline Buttons are ink, D27) and the
|
|
3
3
|
* ON-COLOR re-point they sit beside. Pure functions of theme + props, kept out of `theme/index.ts`
|
|
4
4
|
* so the tests can call them directly.
|
|
5
5
|
*/
|
|
@@ -39,32 +39,43 @@ import type { MantineTheme } from '@mantine/core';
|
|
|
39
39
|
* Stepper / Indicator / Timeline all call Mantine's `getContrastColor` directly) are re-pointed at
|
|
40
40
|
* it too, in `components` below. Regression-locked by `contrast.test.ts`.
|
|
41
41
|
*/
|
|
42
|
-
export declare function onColor(theme: MantineTheme, color: string | undefined): string | undefined;
|
|
42
|
+
export declare function onColor(theme: MantineTheme, color: string | null | undefined): string | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* The on-color for a component that bypasses the variant resolver and calls Mantine's
|
|
45
45
|
* `getContrastColor` directly. `undefined` (autoContrast off, or a hex / indexed color) leaves
|
|
46
46
|
* Mantine's own value in place — `mergeVars` strips undefined before merging.
|
|
47
47
|
*/
|
|
48
48
|
export declare function onColorFor(theme: MantineTheme, props: {
|
|
49
|
-
color?: string | undefined;
|
|
49
|
+
color?: string | null | undefined;
|
|
50
50
|
autoContrast?: boolean | undefined;
|
|
51
51
|
}): string | undefined;
|
|
52
|
-
/** The chrome opt-out: a call site that names a colour (even the primary one) keeps its hue. */
|
|
53
|
-
export declare function hasExplicitColor(color: string | undefined): boolean;
|
|
54
52
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* carries its hue as the whole signal. Mantine hands the variant resolver `color || primaryColor`,
|
|
59
|
-
* so only the component props can tell "unnamed" from "primary" — hence vars, not the resolver.
|
|
53
|
+
* The chrome opt-out: a call site that names a colour (even the primary one) keeps its hue. An
|
|
54
|
+
* empty string and `null` name nothing — Mantine reads `color || primaryColor`, so they fall back to
|
|
55
|
+
* the primary colour too.
|
|
60
56
|
*/
|
|
61
|
-
export declare function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
export declare function hasExplicitColor(color: string | null | undefined): boolean;
|
|
58
|
+
type InkVars = {
|
|
59
|
+
color?: string;
|
|
60
|
+
hover?: string;
|
|
61
|
+
bg?: string;
|
|
62
|
+
border?: string;
|
|
67
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* A `subtle`, `light` or `outline` Button / ActionIcon that names no colour is ink, not the accent
|
|
66
|
+
* (`MIGRATING.md` § Light and outline Buttons are ink, D27). `subtle`: ink label, ink-6% hover
|
|
67
|
+
* (`docs/DESIGN-SPEC.md` §5 ghost idiom). `light`: the subtle surface with an ink label, hover one
|
|
68
|
+
* ink step on top (Mantine's gray-light roles collapse bg and hover to one colour in light). `outline`:
|
|
69
|
+
* the surface border, ink label, subtle-surface hover. An explicit `color=` — the primary one
|
|
70
|
+
* included — keeps Mantine's tinted vars: `color="red"` on a destructive action carries its hue as
|
|
71
|
+
* the whole signal. Mantine hands the variant resolver `color || primaryColor`, so only the
|
|
72
|
+
* component props can tell "unnamed" from "primary" — hence vars, not the resolver. Disabled needs no
|
|
73
|
+
* gate: Mantine's disabled rule sets colour, background and border directly, not through these vars.
|
|
74
|
+
*/
|
|
75
|
+
export declare function inkVars(props: {
|
|
76
|
+
color?: string | null | undefined;
|
|
77
|
+
variant?: string | undefined;
|
|
78
|
+
}): InkVars;
|
|
68
79
|
/**
|
|
69
80
|
* Tabs vars: the on-color re-point plus the active underline in ink (SPEC § 6.12). Only the
|
|
70
81
|
* underline `default` variant takes ink (`pills` fills with the colour); an explicit `color=` opts
|
|
@@ -73,10 +84,11 @@ export declare function subtleInkVars(props: {
|
|
|
73
84
|
* varsResolver writes `--tabs-text-color` (an upstream type gap).
|
|
74
85
|
*/
|
|
75
86
|
export declare function tabsVars(theme: MantineTheme, props: {
|
|
76
|
-
color?: string | undefined;
|
|
87
|
+
color?: string | null | undefined;
|
|
77
88
|
variant?: string | undefined;
|
|
78
89
|
autoContrast?: boolean | undefined;
|
|
79
90
|
}): {
|
|
80
91
|
root: Record<'--tabs-color' | '--tabs-radius' | '--tabs-text-color', string | undefined>;
|
|
81
92
|
};
|
|
93
|
+
export {};
|
|
82
94
|
//# sourceMappingURL=chrome-vars.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome-vars.d.ts","sourceRoot":"","sources":["../../src/theme/chrome-vars.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"chrome-vars.d.ts","sourceRoot":"","sources":["../../src/theme/chrome-vars.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIjG;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,GAC/E,MAAM,GAAG,SAAS,CAGpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE1E;AAED,KAAK,OAAO,GAAG;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAgBD;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B,GAAG,OAAO,CAKV;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE;IACL,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACjC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACnC,GACA;IAAE,IAAI,EAAE,MAAM,CAAC,cAAc,GAAG,eAAe,GAAG,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,CAS9F"}
|
|
@@ -8,14 +8,24 @@ function onColorFor(theme, props) {
|
|
|
8
8
|
return autoContrast ? onColor(theme, props.color) : void 0;
|
|
9
9
|
}
|
|
10
10
|
function hasExplicitColor(color) {
|
|
11
|
-
return color !==
|
|
11
|
+
return typeof color === "string" && color !== "";
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const INK = "var(--vx-ink)";
|
|
14
|
+
const SUBTLE = "var(--vx-surface-subtle)";
|
|
15
|
+
const INK_BY_VARIANT = {
|
|
16
|
+
subtle: { color: INK, hover: "color-mix(in srgb, var(--vx-ink) 6%, transparent)" },
|
|
17
|
+
light: { color: INK, bg: SUBTLE, hover: `color-mix(in srgb, var(--vx-ink) 6%, ${SUBTLE})` },
|
|
18
|
+
outline: {
|
|
19
|
+
color: INK,
|
|
20
|
+
border: "calc(0.0625rem * var(--mantine-scale)) solid var(--vx-surface-border)",
|
|
21
|
+
hover: SUBTLE
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function inkVars(props) {
|
|
25
|
+
const { variant } = props;
|
|
26
|
+
if (hasExplicitColor(props.color) || variant === void 0) return {};
|
|
27
|
+
if (!Object.hasOwn(INK_BY_VARIANT, variant)) return {};
|
|
28
|
+
return INK_BY_VARIANT[variant] ?? {};
|
|
19
29
|
}
|
|
20
30
|
function tabsVars(theme, props) {
|
|
21
31
|
const underline = !hasExplicitColor(props.color) && (props.variant ?? "default") === "default";
|
|
@@ -29,8 +39,8 @@ function tabsVars(theme, props) {
|
|
|
29
39
|
}
|
|
30
40
|
export {
|
|
31
41
|
hasExplicitColor,
|
|
42
|
+
inkVars,
|
|
32
43
|
onColor,
|
|
33
44
|
onColorFor,
|
|
34
|
-
subtleInkVars,
|
|
35
45
|
tabsVars
|
|
36
46
|
};
|
|
@@ -280,6 +280,9 @@ html .accordionItem {
|
|
|
280
280
|
*/
|
|
281
281
|
html[data-mantine-color-scheme] .tabsRoot {
|
|
282
282
|
--tab-border-color: var(--vx-divider);
|
|
283
|
+
/* Mantine's dark hover (dark-6) is the page itself, so a hovered tab read identical to rest. The
|
|
284
|
+
* ink-5% step is NavLink's inactive hover, and resolves per scheme. */
|
|
285
|
+
--tab-hover-color: color-mix(in srgb, var(--vx-ink) 5%, transparent);
|
|
283
286
|
}
|
|
284
287
|
|
|
285
288
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EA0CV,oBAAoB,EAGpB,oBAAoB,EAErB,MAAM,eAAe,CAAA;AAStB,OAAO,KAAK,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAKpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EA0CV,oBAAoB,EAGpB,oBAAoB,EAErB,MAAM,eAAe,CAAA;AAStB,OAAO,KAAK,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAKpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAWvD;;;;;GAKG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAMvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAenE,OAAO,QAAQ,eAAe,CAAC;IAC7B,UAAU,iBAAiB;QACzB,YAAY,CAAC,EAAE,YAAY,CAAA;QAC3B,WAAW,CAAC,EAAE,iBAAiB,CAAA;QAC/B,YAAY,CAAC,EAAE,YAAY,CAAA;QAC3B,aAAa,CAAC,EAAE,WAAW,CAAA;KAC5B;CACF;AA6/BD;+EAC+E;AAC/E,eAAO,MAAM,SAAS,EAAE,oBAAuD,CAAA;AAiR/E,6FAA6F;AAC7F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAE9E,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAsF7D;;8FAE8F;AAC9F,eAAO,MAAM,oBAAoB,EAAE,oBACc,CAAA;AAEjD,kEAAkE;AAClE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAE9B;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAA;IAEzB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAE1B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B,CAAA;AAYD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,EACrD,OAAO,CAAC,EAAE,wBAAwB,GACjC,oBAAoB,CAiCtB"}
|
package/dist/theme/index.js
CHANGED
|
@@ -17,7 +17,8 @@ import { DEFAULT_DERIVE_CONFIG, isDefaultDeriveConfig, resolveDeriveConfig } fro
|
|
|
17
17
|
import { pxRem, TEXT_LINE, VX } from "../tokens/core.js";
|
|
18
18
|
import { CTL_HEIGHT_VARS } from "../tokens/ctl-vars.js";
|
|
19
19
|
import { SIZE_CLASS_BREAKPOINTS } from "../tokens/size-classes.js";
|
|
20
|
-
import { onColor, onColorFor,
|
|
20
|
+
import { onColor, onColorFor, inkVars, tabsVars } from "./chrome-vars.js";
|
|
21
|
+
import cardInsetClasses from "./card-inset.module.css";
|
|
21
22
|
import controlsClasses from "./controls.module.css";
|
|
22
23
|
import floatingClasses from "./floating.module.css";
|
|
23
24
|
import navLinkClasses from "./nav-link.module.css";
|
|
@@ -229,7 +230,11 @@ function buildTheme(data, options = {}) {
|
|
|
229
230
|
// • radius → `--vx-radius-card` (10px).
|
|
230
231
|
// This is the single source the user's "strict surface across components" demands; the
|
|
231
232
|
// `raw-surface` guard then stops consumers re-overriding any of it inline.
|
|
233
|
+
// • inset → `card-inset.module.css`: the density-scaled 12/16 tokens, on Paper too (Mantine
|
|
234
|
+
// gives a bare Paper 0 and a bare Card 16); `variant="flush"` zeroes it and `Card.Section`
|
|
235
|
+
// cancels exactly it. A Card `padding` prop still wins (see the CSS).
|
|
232
236
|
Card: ext({
|
|
237
|
+
classNames: { root: cardInsetClasses.inset, section: cardInsetClasses.section },
|
|
233
238
|
styles: {
|
|
234
239
|
root: {
|
|
235
240
|
backgroundColor: "var(--vx-surface-panel)",
|
|
@@ -239,6 +244,7 @@ function buildTheme(data, options = {}) {
|
|
|
239
244
|
}
|
|
240
245
|
}),
|
|
241
246
|
Paper: ext({
|
|
247
|
+
classNames: { root: cardInsetClasses.inset },
|
|
242
248
|
styles: {
|
|
243
249
|
root: {
|
|
244
250
|
backgroundColor: "var(--vx-surface-panel)",
|
|
@@ -416,12 +422,15 @@ function buildTheme(data, options = {}) {
|
|
|
416
422
|
Button: ext({
|
|
417
423
|
classNames: { root: controlsClasses.buttonRoot },
|
|
418
424
|
vars: (_theme, props) => {
|
|
419
|
-
const ink =
|
|
425
|
+
const ink = inkVars(props);
|
|
420
426
|
return {
|
|
421
427
|
root: {
|
|
422
428
|
"--button-height": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
429
|
+
"--button-padding-x": buttonPaddingX(props.size),
|
|
423
430
|
"--button-color": ink.color,
|
|
424
|
-
"--button-hover": ink.hover
|
|
431
|
+
"--button-hover": ink.hover,
|
|
432
|
+
"--button-bg": ink.bg,
|
|
433
|
+
"--button-bd": ink.border
|
|
425
434
|
}
|
|
426
435
|
};
|
|
427
436
|
}
|
|
@@ -429,12 +438,14 @@ function buildTheme(data, options = {}) {
|
|
|
429
438
|
ActionIcon: ext({
|
|
430
439
|
classNames: { root: controlsClasses.actionIconRoot },
|
|
431
440
|
vars: (_theme, props) => {
|
|
432
|
-
const ink =
|
|
441
|
+
const ink = inkVars(props);
|
|
433
442
|
return {
|
|
434
443
|
root: {
|
|
435
444
|
"--ai-size": props.size === "md" ? "calc(var(--vx-space-control-height) * var(--mantine-scale))" : void 0,
|
|
436
445
|
"--ai-color": ink.color,
|
|
437
|
-
"--ai-hover": ink.hover
|
|
446
|
+
"--ai-hover": ink.hover,
|
|
447
|
+
"--ai-bg": ink.bg,
|
|
448
|
+
"--ai-bd": ink.border
|
|
438
449
|
}
|
|
439
450
|
};
|
|
440
451
|
}
|
|
@@ -890,6 +901,22 @@ function familyBridge(data) {
|
|
|
890
901
|
}
|
|
891
902
|
return vars;
|
|
892
903
|
}
|
|
904
|
+
const BUTTON_PADDING_X = {
|
|
905
|
+
xs: "var(--vx-space-stack-md)",
|
|
906
|
+
sm: "var(--vx-space-stack-lg)",
|
|
907
|
+
md: "var(--vx-space-stack-lg) + var(--vx-space-stack-xs)",
|
|
908
|
+
lg: "var(--vx-space-stack-xl)",
|
|
909
|
+
xl: "var(--vx-space-stack-xl) + var(--vx-space-stack-sm)",
|
|
910
|
+
"compact-xs": "var(--vx-space-stack-sm)",
|
|
911
|
+
"compact-sm": "var(--vx-space-stack-sm)",
|
|
912
|
+
"compact-md": "var(--vx-space-stack-md)",
|
|
913
|
+
"compact-lg": "var(--vx-space-stack-md)",
|
|
914
|
+
"compact-xl": "var(--vx-space-stack-lg)"
|
|
915
|
+
};
|
|
916
|
+
function buttonPaddingX(size) {
|
|
917
|
+
const steps = BUTTON_PADDING_X[typeof size === "string" ? size : "sm"];
|
|
918
|
+
return steps === void 0 ? void 0 : `calc((${steps}) * var(--mantine-scale))`;
|
|
919
|
+
}
|
|
893
920
|
const CTL_PADDING_X = 10;
|
|
894
921
|
const CTL_INPUT_PADDING_Y = 4;
|
|
895
922
|
const CTL_SEGMENT_PADDING_Y = 2.5;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Active nav row =
|
|
3
|
-
* SELECTED rather than merely hovered (docs/DESIGN-SPEC.md §5).
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* an active row is a SELECTED ROW, not a raised control.
|
|
2
|
+
* Active nav row = a NEUTRAL ink fill (10%, twice the 5% inactive hover) plus heavier weight, so the
|
|
3
|
+
* row reads as SELECTED rather than merely hovered (docs/DESIGN-SPEC.md §5). Never the accent
|
|
4
|
+
* (DESIGN-CORE § Accent discipline, SPEC § 6.12): the accent stays on the focus ring, the filled
|
|
5
|
+
* primary and the active ICON below. NO depth: an active row is a SELECTED ROW, not a raised control.
|
|
7
6
|
*
|
|
8
7
|
* `[data-active]` is the ONLY style hook here — `use-nav.ts` already resolves exactly one winner
|
|
9
8
|
* per route and stamps `data-active` on it, so keying these selectors on `aria-current="page"` too
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
* there throws a React warning), so the state selectors live here.
|
|
18
17
|
*/
|
|
19
18
|
.root[data-active] {
|
|
20
|
-
background-color: color-mix(in srgb, var(--vx-
|
|
19
|
+
background-color: color-mix(in srgb, var(--vx-ink) 10%, transparent);
|
|
21
20
|
font-weight: 600;
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
* still reads as feedback rather than as a flat, unresponsive selection. */
|
|
33
32
|
@media (hover: hover) {
|
|
34
33
|
.root[data-active]:hover {
|
|
35
|
-
background-color: color-mix(in srgb, var(--vx-
|
|
34
|
+
background-color: color-mix(in srgb, var(--vx-ink) 14%, transparent);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -61,10 +60,9 @@
|
|
|
61
60
|
|
|
62
61
|
/*
|
|
63
62
|
* Inactive hover — the ink-5% ghost tint + ink text/icon (docs/DESIGN-SPEC.md §5; dropped from 6%
|
|
64
|
-
* so it reads clearly below the active row's
|
|
65
|
-
* ink fill). Lives here (not only in the shell module) so a consumer's `SidebarItem.Anchor` path
|
|
63
|
+
* so it reads clearly below the active row's 10% ink fill). Lives here (not only in the shell module) so a consumer's `SidebarItem.Anchor` path
|
|
66
64
|
* gets the same hover; Mantine's own hover fill uses `:where(scheme) .m_*:hover` (gray-0/dark-6),
|
|
67
|
-
* which this outranks on specificity. Active rows keep their
|
|
65
|
+
* which this outranks on specificity. Active rows keep their ink fill above, untouched here.
|
|
68
66
|
*/
|
|
69
67
|
@media (hover: hover) {
|
|
70
68
|
.root:not([data-active]):hover {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BasaltProps } from '../common/props.js';
|
|
2
|
+
export type StatusDotProps = BasaltProps & {
|
|
3
|
+
/** Any CSS colour; callers pass a `VX.status.*` token so it re-resolves per scheme. */
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function StatusDot({ color, className, style }: StatusDotProps): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=status-dot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-dot.d.ts","sourceRoot":"","sources":["../../src/theme/status-dot.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAGlD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,uFAAuF;IACvF,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAID,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,cAAc,+BAUpE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../common/props.js";
|
|
3
|
+
import classes from "./status-dot.module.css";
|
|
4
|
+
function StatusDot({ color, className, style }) {
|
|
5
|
+
const merged = { ...style, "--basalt-status-dot": color };
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"span",
|
|
8
|
+
{
|
|
9
|
+
className: cx(classes.dot, className),
|
|
10
|
+
"data-basalt-status-dot": "",
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
style: merged
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
StatusDot
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BasaltProps } from '../common/props.js';
|
|
2
|
+
export type StatusVerdictProps = BasaltProps & {
|
|
3
|
+
color: string;
|
|
4
|
+
/** The short visible word ("Over", "Error"). */
|
|
5
|
+
word: string;
|
|
6
|
+
/** A longer phrase for assistive tech, read in place of the word. */
|
|
7
|
+
phrase?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function StatusVerdict({ color, word, phrase, className, style }: StatusVerdictProps): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=status-verdict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-verdict.d.ts","sourceRoot":"","sources":["../../src/theme/status-verdict.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIlD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,kBAAkB,+BAU1F"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../common/props.js";
|
|
3
|
+
import { StatusDot } from "./status-dot.js";
|
|
4
|
+
import classes from "./status-verdict.module.css";
|
|
5
|
+
function StatusVerdict({ color, word, phrase, className, style }) {
|
|
6
|
+
return /* @__PURE__ */ jsxs("span", { className: cx(classes.verdict, className), ...style !== void 0 && { style }, children: [
|
|
7
|
+
/* @__PURE__ */ jsx(StatusDot, { color }),
|
|
8
|
+
/* @__PURE__ */ jsx("span", { "data-verdict-word": "", ...phrase !== void 0 && { "aria-hidden": true }, children: word }),
|
|
9
|
+
phrase !== void 0 && /* @__PURE__ */ jsx("span", { className: classes.hidden, children: phrase })
|
|
10
|
+
] });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
StatusVerdict
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* A status dot plus its word: the dot carries the colour, the word is muted ink. `flex: none` keeps
|
|
2
|
+
* it whole when a neighbouring caption or title truncates. The word is the proportional sans, at the
|
|
3
|
+
* micro size: it is a sentence fragment ("Blocked · Waits on the API change"), not an UPPERCASE
|
|
4
|
+
* caption, so it never takes the mono. */
|
|
5
|
+
.verdict {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
flex: none;
|
|
8
|
+
align-items: center;
|
|
9
|
+
gap: 5px;
|
|
10
|
+
font-family: var(--basalt-font-sans);
|
|
11
|
+
font-size: var(--vx-text-micro);
|
|
12
|
+
color: var(--vx-muted);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Visually hidden, still read by assistive tech. */
|
|
16
|
+
.hidden {
|
|
17
|
+
position: absolute;
|
|
18
|
+
width: 1px;
|
|
19
|
+
height: 1px;
|
|
20
|
+
margin: -1px;
|
|
21
|
+
padding: 0;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
clip-path: inset(50%);
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly verdict: string
|
|
7
|
+
readonly hidden: string
|
|
8
|
+
}
|
|
9
|
+
export default classes
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.20.0
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.
|
|
16
|
+
Version: 2.20.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -25,8 +25,9 @@ Signature: BarList(props: BarListProps): JSX.Element
|
|
|
25
25
|
style?: CSSProperties
|
|
26
26
|
label: string
|
|
27
27
|
items: readonly BarListItem[]
|
|
28
|
-
format?: (value: number) => string
|
|
28
|
+
format?: (value: number, part: "value" | "max") => string
|
|
29
29
|
max?: number
|
|
30
|
+
variant?: "default" | "thin"
|
|
30
31
|
accentLeader?: boolean
|
|
31
32
|
loading?: boolean
|
|
32
33
|
loadingRows?: number
|
|
@@ -82,6 +83,7 @@ Signature: DeltaBadge(props: DeltaBadgeProps): JSX.Element
|
|
|
82
83
|
format?: (value: number) => string
|
|
83
84
|
withGlyph?: boolean
|
|
84
85
|
period?: string
|
|
86
|
+
periodPrefix?: string
|
|
85
87
|
Signature: EmptyState(props: EmptyStateProps): JSX.Element
|
|
86
88
|
className?: string
|
|
87
89
|
style?: CSSProperties
|
|
@@ -102,6 +104,9 @@ Signature: Meter(props: MeterProps): JSX.Element
|
|
|
102
104
|
emptyText?: string
|
|
103
105
|
shape?: "bar" | "ring"
|
|
104
106
|
target?: number [with segments | zones]
|
|
107
|
+
ticks?: readonly MeterTick[] [with segments | zones]
|
|
108
|
+
tone?: "muted" [with segments | zones]
|
|
109
|
+
size?: "row" [with segments | zones]
|
|
105
110
|
startCaption?: ReactNode [with segments | zones]
|
|
106
111
|
endCaption?: ReactNode [with segments | zones]
|
|
107
112
|
value?: number | null [with zones]
|
|
@@ -207,11 +212,26 @@ Signature: StatCard(props: StatCardProps): JSX.Element
|
|
|
207
212
|
actions?: ReactNode
|
|
208
213
|
tone?: Tone
|
|
209
214
|
Signature: StatGroup(props: StatGroupProps): JSX.Element
|
|
215
|
+
one of: variant="grid" | variant="strip"
|
|
210
216
|
className?: string
|
|
211
217
|
style?: CSSProperties
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
variant?: "grid" | "strip"
|
|
219
|
+
cols?: StatGroupCols | 2 | 3 | 4 | 5 | 6
|
|
220
|
+
divided?: boolean [with variant="grid"]
|
|
221
|
+
children: ReactNode [with variant="grid"]
|
|
222
|
+
label: string [with variant="strip"]
|
|
223
|
+
cells: readonly StatStripCell[] [with variant="strip"]
|
|
224
|
+
footer?: readonly { key: string; content: ReactNode; }[] [with variant="strip"]
|
|
225
|
+
Signature: StatusDot(props: StatusDotProps): JSX.Element
|
|
226
|
+
className?: string
|
|
227
|
+
style?: CSSProperties
|
|
228
|
+
color: string
|
|
229
|
+
Signature: StatusVerdict(props: StatusVerdictProps): JSX.Element
|
|
230
|
+
className?: string
|
|
231
|
+
style?: CSSProperties
|
|
232
|
+
color: string
|
|
233
|
+
word: string
|
|
234
|
+
phrase?: string
|
|
215
235
|
Signature: ThemeToggle(props: ThemeToggleProps): JSX.Element
|
|
216
236
|
className?: string
|
|
217
237
|
style?: CSSProperties
|
|
@@ -352,6 +372,7 @@ Signature: ChartCard(props: ChartCardProps): ReactElement<unknown, string | JSXE
|
|
|
352
372
|
placeholderHeight?: number | ResponsiveChartHeight
|
|
353
373
|
stateAction?: ReactNode
|
|
354
374
|
children?: ReactNode
|
|
375
|
+
facts: ChartFact | readonly ChartFact[]
|
|
355
376
|
Signature: Donut(props: DonutProps<K>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
356
377
|
className?: string
|
|
357
378
|
style?: CSSProperties
|
|
@@ -460,6 +481,9 @@ Signature: Sparkline(props: SparklineProps): ReactElement<unknown, string | JSXE
|
|
|
460
481
|
emphasizeLast?: boolean
|
|
461
482
|
emphasisColor?: string
|
|
462
483
|
state?: ChartState
|
|
484
|
+
reference?: number | "mean"
|
|
485
|
+
format?: ((value: number) => string)
|
|
486
|
+
labels?: readonly string[]
|
|
463
487
|
Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
464
488
|
className?: string
|
|
465
489
|
style?: CSSProperties
|
package/package.json
CHANGED
package/src/charts/ChartCard.tsx
CHANGED
|
@@ -87,14 +87,25 @@ const bodyClipStyle: CSSProperties = {
|
|
|
87
87
|
padding: '2px var(--vx-space-card-inset-x, 1rem) var(--vx-space-card-inset-y, 0.75rem)',
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/** One headline figure: the value is the hero, then its unit, a comparison node and the period. */
|
|
91
|
+
export type ChartFact = {
|
|
92
|
+
value: ReactNode
|
|
93
|
+
unit?: string | undefined
|
|
94
|
+
/** Usually a `DeltaBadge`. */
|
|
95
|
+
comparison?: ReactNode
|
|
96
|
+
/** Plain text the figure covers, e.g. `last 30 d`. */
|
|
97
|
+
period?: string | undefined
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/** The three boxes a `ChartCard` paints. */
|
|
91
101
|
export type ChartCardSlot = 'root' | 'header' | 'body'
|
|
92
102
|
|
|
93
|
-
|
|
103
|
+
type ChartCardBaseProps = BasaltProps &
|
|
94
104
|
SlotStylesProps<ChartCardSlot> & {
|
|
95
105
|
title?: string | undefined
|
|
96
106
|
icon?: ReactNode
|
|
97
|
-
/** A muted line below the title row; does not by itself render the header.
|
|
107
|
+
/** A muted line below the title row; does not by itself render the header. With `facts` it is the
|
|
108
|
+
* basis/as-of line after the facts row (always visible, never folded into the info glyph). */
|
|
98
109
|
subtitle?: string | undefined
|
|
99
110
|
/** `WidgetHeader`'s info glyph beside the title. */
|
|
100
111
|
info?: string | undefined
|
|
@@ -118,6 +129,23 @@ export type ChartCardProps = BasaltProps &
|
|
|
118
129
|
children?: ReactNode
|
|
119
130
|
}
|
|
120
131
|
|
|
132
|
+
/**
|
|
133
|
+
* `facts` replaces the legacy `value`/`delta` hero: the two are mutually exclusive in the type. The
|
|
134
|
+
* facts show only at rest: while `state` is pending, errored or empty the figure would sit above a
|
|
135
|
+
* skeleton or a placeholder that contradicts it, so the header keeps its title row alone.
|
|
136
|
+
*/
|
|
137
|
+
export type ChartCardProps = ChartCardBaseProps &
|
|
138
|
+
(
|
|
139
|
+
| {
|
|
140
|
+
/** The headline figure(s) under the title: value, unit, comparison, period. Wraps at half
|
|
141
|
+
* width, never clips. Replaces `value`/`delta`. */
|
|
142
|
+
facts: ChartFact | readonly ChartFact[]
|
|
143
|
+
value?: undefined
|
|
144
|
+
delta?: undefined
|
|
145
|
+
}
|
|
146
|
+
| { facts?: undefined }
|
|
147
|
+
)
|
|
148
|
+
|
|
121
149
|
/** Drops explicit `undefined`s: `WidgetHeader` is exact-optional, this props type is not. */
|
|
122
150
|
const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>
|
|
123
151
|
Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as {
|
|
@@ -127,6 +155,37 @@ const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], u
|
|
|
127
155
|
/** A header renders when one of these is set (a subtitle or delta alone does not). */
|
|
128
156
|
const HEADER_TRIGGERS = ['title', 'info', 'value', 'icon', 'count'] as const
|
|
129
157
|
|
|
158
|
+
function Facts({
|
|
159
|
+
facts,
|
|
160
|
+
basis,
|
|
161
|
+
}: {
|
|
162
|
+
facts: ChartFact | readonly ChartFact[]
|
|
163
|
+
basis?: string | undefined
|
|
164
|
+
}): ReactElement {
|
|
165
|
+
const list: readonly ChartFact[] = Array.isArray(facts) ? facts : [facts as ChartFact]
|
|
166
|
+
return (
|
|
167
|
+
<div data-basalt-facts="" className={classes.facts}>
|
|
168
|
+
<div className={classes.factsRow}>
|
|
169
|
+
{list.map((f, i) => (
|
|
170
|
+
<span key={i} data-basalt-fact="" className={classes.fact}>
|
|
171
|
+
<span data-basalt-fact-value="" className={classes.factValue}>
|
|
172
|
+
{f.value}
|
|
173
|
+
</span>
|
|
174
|
+
{f.unit !== undefined && <span className={classes.factUnit}>{f.unit}</span>}
|
|
175
|
+
{f.comparison}
|
|
176
|
+
{f.period !== undefined && <span className={classes.factPeriod}>{f.period}</span>}
|
|
177
|
+
</span>
|
|
178
|
+
))}
|
|
179
|
+
</div>
|
|
180
|
+
{basis !== undefined && (
|
|
181
|
+
<p data-basalt-facts-basis="" className={classes.factsBasis}>
|
|
182
|
+
{basis}
|
|
183
|
+
</p>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
130
189
|
export function ChartCard({
|
|
131
190
|
actions,
|
|
132
191
|
state,
|
|
@@ -136,11 +195,17 @@ export function ChartCard({
|
|
|
136
195
|
classNames,
|
|
137
196
|
style,
|
|
138
197
|
children,
|
|
198
|
+
facts,
|
|
139
199
|
...header
|
|
140
200
|
}: ChartCardProps): ReactElement {
|
|
141
201
|
const { ref, short } = useShortCard()
|
|
142
202
|
const resolved = resolveChartState(state)
|
|
143
|
-
const
|
|
203
|
+
const showFacts = facts !== undefined && resolved === null
|
|
204
|
+
const hasHeader =
|
|
205
|
+
actions !== undefined || showFacts || HEADER_TRIGGERS.some((k) => header[k] !== undefined)
|
|
206
|
+
// With facts the subtitle is the basis line after them, not WidgetHeader's foldable row.
|
|
207
|
+
const { subtitle, ...rest } = header
|
|
208
|
+
const headerProps = facts === undefined ? header : rest
|
|
144
209
|
|
|
145
210
|
return (
|
|
146
211
|
<ChartCardContext.Provider value>
|
|
@@ -156,12 +221,13 @@ export function ChartCard({
|
|
|
156
221
|
<div className={cx(classes.header, classNames?.header)}>
|
|
157
222
|
<WidgetHeader
|
|
158
223
|
tier="widget"
|
|
159
|
-
{...definedOnly(
|
|
224
|
+
{...definedOnly(headerProps)}
|
|
160
225
|
title={header.title ?? ''}
|
|
161
226
|
{...(actions !== undefined && {
|
|
162
227
|
actions: <span data-basalt-tier="widget">{actions}</span>,
|
|
163
228
|
})}
|
|
164
229
|
/>
|
|
230
|
+
{showFacts && <Facts facts={facts} basis={subtitle} />}
|
|
165
231
|
</div>
|
|
166
232
|
)}
|
|
167
233
|
<div
|
package/src/charts/Donut.tsx
CHANGED
|
@@ -239,7 +239,15 @@ export function Donut<K extends string = string>(props: DonutProps<K>): ReactEle
|
|
|
239
239
|
{resolved === null && (centerLabel !== undefined || centerSubLabel !== undefined) && (
|
|
240
240
|
<div style={centerStyle}>
|
|
241
241
|
{centerLabel !== undefined && (
|
|
242
|
-
<span
|
|
242
|
+
<span
|
|
243
|
+
style={{
|
|
244
|
+
color: VX.ink,
|
|
245
|
+
fontFamily: 'var(--basalt-font-numeral, var(--basalt-font-sans))',
|
|
246
|
+
fontVariantNumeric: 'lining-nums',
|
|
247
|
+
fontSize: VX.text.lg,
|
|
248
|
+
fontWeight: 600,
|
|
249
|
+
}}
|
|
250
|
+
>
|
|
243
251
|
{centerLabel}
|
|
244
252
|
</span>
|
|
245
253
|
)}
|