basalt-ui 2.23.0 → 2.25.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 +63 -0
- package/MIGRATING.md +264 -12
- package/agent/agents/basalt-design-reviewer.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/agent/skills/basalt-design/references/catalogue.md +22 -19
- package/agent/skills/basalt-design/references/states.md +39 -0
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +21 -3
- package/dist/charts/CartesianChart.d.ts +2 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +7 -3
- package/dist/charts/ChartCard.d.ts +6 -2
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +1 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +32 -6
- package/dist/charts/StackedArea.d.ts.map +1 -1
- package/dist/charts/StackedArea.js +5 -1
- package/dist/charts/chart-legend.module.css +16 -0
- package/dist/charts/compile.d.ts +4 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +65 -3
- package/dist/charts/legend.d.ts +0 -6
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +87 -35
- package/dist/charts/sparkline.module.css +59 -6
- package/dist/charts/sparkline.module.css.d.ts +1 -0
- package/dist/charts/state.d.ts +3 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +10 -2
- package/dist/charts/types.d.ts +11 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +25 -36
- package/dist/cli/shot/measure.js +19 -23
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +16 -2
- package/dist/dashboard/bar-list.module.css +10 -17
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +30 -1
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +74 -5
- package/dist/dashboard/meter-parts.d.ts +8 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +64 -21
- package/dist/dashboard/meter.d.ts +8 -1
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +14 -3
- package/dist/dashboard/meter.module.css +42 -2
- package/dist/dashboard/meter.module.css.d.ts +4 -0
- package/dist/dashboard/query-state.d.ts +7 -3
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +14 -6
- package/dist/dashboard/section.d.ts +2 -1
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.module.css +12 -0
- package/dist/dashboard/settings-section.d.ts +1 -1
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +3 -3
- package/dist/dashboard/stat-card.module.css +24 -10
- package/dist/dashboard/stat-group.module.css +8 -0
- package/dist/dashboard/stat-strip.d.ts +3 -2
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +83 -73
- package/dist/dashboard/stat-strip.module.css +24 -39
- package/dist/dashboard/stat-strip.module.css.d.ts +1 -0
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +19 -1
- package/dist/dashboard/widget-header.module.css +6 -0
- package/dist/guard/index.d.ts +2 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +1 -12
- package/dist/table/data-table.js +1 -1
- package/dist/theme/controls.module.css +7 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +7 -5
- package/dist/tokens/palette.d.ts +2 -2
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +2 -2
- package/llms.txt +4 -3
- package/package.json +1 -1
- package/src/charts/Bars.tsx +36 -4
- package/src/charts/CartesianChart.tsx +9 -3
- package/src/charts/ChartCard.tsx +7 -3
- package/src/charts/Sparkline.tsx +66 -21
- package/src/charts/StackedArea.tsx +12 -1
- package/src/charts/chart-legend.module.css +16 -0
- package/src/charts/compile.ts +104 -2
- package/src/charts/legend.tsx +70 -3
- package/src/charts/sparkline.module.css +59 -6
- package/src/charts/sparkline.module.css.d.ts +1 -0
- package/src/charts/state.tsx +16 -7
- package/src/charts/types.ts +9 -0
- package/src/cli/shot/detect.ts +26 -40
- package/src/cli/shot/measure.ts +27 -27
- package/src/dashboard/bar-list.module.css +10 -17
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +14 -2
- package/src/dashboard/empty-state.tsx +4 -2
- package/src/dashboard/meter-model.ts +124 -7
- package/src/dashboard/meter-parts.tsx +127 -31
- package/src/dashboard/meter.module.css +42 -2
- package/src/dashboard/meter.module.css.d.ts +4 -0
- package/src/dashboard/meter.tsx +22 -3
- package/src/dashboard/query-state.tsx +19 -8
- package/src/dashboard/section.module.css +12 -0
- package/src/dashboard/section.tsx +2 -1
- package/src/dashboard/settings-section.tsx +4 -4
- package/src/dashboard/stat-card.module.css +24 -10
- package/src/dashboard/stat-group.module.css +8 -0
- package/src/dashboard/stat-strip.module.css +24 -39
- package/src/dashboard/stat-strip.module.css.d.ts +1 -0
- package/src/dashboard/stat-strip.tsx +63 -43
- package/src/dashboard/widget-header.module.css +6 -0
- package/src/dashboard/widget-header.tsx +28 -1
- package/src/guard/index.ts +3 -14
- package/src/table/data-table.tsx +1 -1
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +6 -6
- package/src/theme/controls.module.css +7 -2
- package/src/theme/index.ts +7 -5
- package/src/tokens/palette.ts +2 -2
|
@@ -7,12 +7,19 @@ import { DeltaBadge } from "./delta-badge.js";
|
|
|
7
7
|
import classes from "./widget-header.module.css";
|
|
8
8
|
const BUBBLE_GAP = 7;
|
|
9
9
|
const BUBBLE_EDGE = 8;
|
|
10
|
+
function cardOf(trigger) {
|
|
11
|
+
for (let el = trigger.parentElement; el !== null; el = el.parentElement) {
|
|
12
|
+
if (getComputedStyle(el).containerName.split(/\s+/).includes("basalt-card")) return el;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
10
16
|
function useBubblePosition(open, triggerRef, bubbleRef) {
|
|
11
17
|
const [pos, setPos] = useState(null);
|
|
12
18
|
useIsomorphicLayoutEffect(() => {
|
|
13
19
|
if (!open) return;
|
|
14
20
|
const bubbleEl = bubbleRef.current;
|
|
15
21
|
if (bubbleEl !== null && typeof bubbleEl.showPopover === "function") bubbleEl.showPopover();
|
|
22
|
+
const card = triggerRef.current === null ? null : cardOf(triggerRef.current);
|
|
16
23
|
const place = () => {
|
|
17
24
|
const trigger = triggerRef.current;
|
|
18
25
|
const bubble = bubbleRef.current;
|
|
@@ -23,7 +30,18 @@ function useBubblePosition(open, triggerRef, bubbleRef) {
|
|
|
23
30
|
const viewH = document.documentElement.clientHeight;
|
|
24
31
|
const below = t.bottom + BUBBLE_GAP;
|
|
25
32
|
const above = t.top - BUBBLE_GAP - b.height;
|
|
26
|
-
const
|
|
33
|
+
const overflows = below + b.height > viewH - BUBBLE_EDGE;
|
|
34
|
+
const viewportFlip = above >= BUBBLE_EDGE ? above : below;
|
|
35
|
+
let top = below;
|
|
36
|
+
if (overflows) {
|
|
37
|
+
const floor = card === null ? BUBBLE_EDGE : Math.max(BUBBLE_EDGE, card.getBoundingClientRect().top);
|
|
38
|
+
if (above >= floor) top = above;
|
|
39
|
+
else if (card !== null) {
|
|
40
|
+
const slid = Math.max(floor, viewH - BUBBLE_EDGE - b.height);
|
|
41
|
+
const covers = slid < t.bottom && slid + b.height > t.top;
|
|
42
|
+
top = covers ? viewportFlip : slid;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
27
45
|
const left = Math.max(BUBBLE_EDGE, Math.min(t.left, viewW - BUBBLE_EDGE - b.width));
|
|
28
46
|
setPos((prev) => prev?.top === top && prev.left === left ? prev : { top, left });
|
|
29
47
|
};
|
|
@@ -230,6 +230,12 @@
|
|
|
230
230
|
color: var(--vx-muted);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/* A Section shell holds three sizes: the title (`md`), this note and the count tag (`xs`), and the
|
|
234
|
+
* body (`sm`). The note steps down to the count tag's rung instead of sitting between them. */
|
|
235
|
+
.root[data-tier='section'] .subtitle {
|
|
236
|
+
font-size: var(--vx-text-xs);
|
|
237
|
+
}
|
|
238
|
+
|
|
233
239
|
/* `data-placement` is read by wave-3 composers wanting a `bleed` layout (docs/CONTROLS-SPEC.md
|
|
234
240
|
* §2.2's `sparklinePlacement` composer mapping) — this primitive only ever sets `right`. */
|
|
235
241
|
.sparkline {
|
package/dist/guard/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export type GraceEntry = {
|
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* Kinds still inside their grace minor — reported, not fatal, until the next minor promotes them.
|
|
34
|
-
* Empty since
|
|
35
|
-
*
|
|
34
|
+
* Empty since 2.24.0: `raw-spacing` and `inline-spacing` (since 2.16.0), the last tenants, promoted.
|
|
35
|
+
* It was empty once before, at 1.36.0, when `unknown-vx-token` promoted.
|
|
36
36
|
* See {@link GuardSeverity} for the doctrine and why basalt-ui in particular needs it.
|
|
37
37
|
*
|
|
38
38
|
* Adding a kind here is part of shipping it; removing the entry IS the promotion, and belongs in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAO7E,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AAgU9D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,E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AAED,kGAAkG;AAClG,eAAO,MAAM,uBAAuB,6BAA6B,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAM9F"}
|
package/dist/guard/index.js
CHANGED
|
@@ -256,18 +256,7 @@ const DEFAULT_GUARD_CONFIG = {
|
|
|
256
256
|
exemptRules: {},
|
|
257
257
|
severity: {}
|
|
258
258
|
};
|
|
259
|
-
const GRACE_PERIOD_KINDS = {
|
|
260
|
-
"raw-spacing": {
|
|
261
|
-
since: "2.16.0",
|
|
262
|
-
promote: "2.24.0",
|
|
263
|
-
why: "The spacing scale moved to 8/12/16/20/24 in 2.16.0: a prop value equal to a NEW step (p={16}) is newly a finding."
|
|
264
|
-
},
|
|
265
|
-
"inline-spacing": {
|
|
266
|
-
since: "2.16.0",
|
|
267
|
-
promote: "2.24.0",
|
|
268
|
-
why: "The scale moved to 8/12/16/20/24 and the CSS micro ceiling dropped 10 \u2192 7 in 2.16.0: a literal 8px/10px in CSS is newly a finding."
|
|
269
|
-
}
|
|
270
|
-
};
|
|
259
|
+
const GRACE_PERIOD_KINDS = {};
|
|
271
260
|
function severityOf(kind, cfg) {
|
|
272
261
|
return cfg.severity?.[kind] ?? (Object.hasOwn(GRACE_PERIOD_KINDS, kind) ? "warn" : "error");
|
|
273
262
|
}
|
package/dist/table/data-table.js
CHANGED
|
@@ -662,7 +662,7 @@ function BasaltDataTable(props) {
|
|
|
662
662
|
ErrorState,
|
|
663
663
|
{
|
|
664
664
|
error: queryError.error,
|
|
665
|
-
title: "Could not load",
|
|
665
|
+
title: "Could not load rows",
|
|
666
666
|
tier: "section",
|
|
667
667
|
retrying: queryError.fetchStatus === "fetching",
|
|
668
668
|
onRetry: () => void queryError.refetch()
|
|
@@ -368,8 +368,13 @@ html .badgeRoot {
|
|
|
368
368
|
|
|
369
369
|
/*
|
|
370
370
|
* Alert: an inline Code inside it sits one nested step (3px) under the Alert's own radius
|
|
371
|
-
* (craft-1/nested-radius-step)
|
|
371
|
+
* (craft-1/nested-radius-step), snapped down onto the radius scale (2, or 0 under a 5px Alert). The Code theme reads
|
|
372
|
+
* `--basalt-code-radius`; the Alert supplies it.
|
|
372
373
|
*/
|
|
373
374
|
.alertRoot {
|
|
374
|
-
--basalt-code-radius:
|
|
375
|
+
--basalt-code-radius: round(
|
|
376
|
+
down,
|
|
377
|
+
min(2px, max(0px, var(--alert-radius, var(--vx-radius-ctrl)) - 3px)),
|
|
378
|
+
2px
|
|
379
|
+
);
|
|
375
380
|
}
|
|
@@ -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;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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.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AG;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
|
@@ -511,9 +511,10 @@ function buildTheme(data, options = {}) {
|
|
|
511
511
|
// The track's padding is `SPACE_FIXED.segmentedTrackInset`, a plain literal — NOT a
|
|
512
512
|
// `--vx-space-*` var — because it is density-EXEMPT (see that constant's doc in
|
|
513
513
|
// `tokens/palette.ts`). The INDICATOR radius is the track's per-instance radius (`--sc-radius`,
|
|
514
|
-
// which Mantine sets on the root from the `radius` prop) minus 3 px
|
|
515
|
-
//
|
|
516
|
-
// and
|
|
514
|
+
// which Mantine sets on the root from the `radius` prop) minus 3 px, snapped DOWN onto the radius
|
|
515
|
+
// scale: `craft-1/nested-radius-step` wants nested surfaces ≥ 3 px apart, SPEC § 8.1 rule 1 wants
|
|
516
|
+
// every radius on a § 5 step, and the only step that satisfies both under a 6 px track is 2
|
|
517
|
+
// (`RADIUS_STEP.scaleXs`; 0 when the track is under 5 px). A custom `radius` therefore nests too.
|
|
517
518
|
SegmentedControl: ext({
|
|
518
519
|
defaultProps: { radius: radius.ctrl },
|
|
519
520
|
classNames: {
|
|
@@ -552,8 +553,9 @@ function buildTheme(data, options = {}) {
|
|
|
552
553
|
// ink-12% fill sat one shade from the track and read as a hover state.
|
|
553
554
|
boxShadow: "var(--vx-shadow-raised)",
|
|
554
555
|
outline: "1px solid color-mix(in srgb, var(--vx-ink) 14%, transparent)",
|
|
555
|
-
//
|
|
556
|
-
|
|
556
|
+
// Nested radius snapped to the scale (SPEC § 8.1 rule 1): 2 when the track leaves a 3 px step, else 0.
|
|
557
|
+
// `--sc-radius` has no fallback: `defaultProps.radius` above guarantees Mantine sets it.
|
|
558
|
+
borderRadius: "round(down,min(2px,max(0px,var(--sc-radius) - 3px)),2px)"
|
|
557
559
|
},
|
|
558
560
|
// Conditionally spread the WHOLE key (never a present `label: undefined`) — the package
|
|
559
561
|
// builds under `exactOptionalPropertyTypes`, which treats a key present-but-`undefined` as
|
package/dist/tokens/palette.d.ts
CHANGED
|
@@ -186,8 +186,8 @@ export declare const RADIUS_STEP: {
|
|
|
186
186
|
/** SegmentedControl's active indicator, Kbd, Code — one step below the control radius. */
|
|
187
187
|
readonly tight: number;
|
|
188
188
|
/** Progress bar, and the Mantine scale's `sm` step — two steps below the control radius. (No
|
|
189
|
-
* longer the SegmentedControl indicator: that is the track radius − 3 px
|
|
190
|
-
*
|
|
189
|
+
* longer the SegmentedControl indicator: that is the track radius − 3 px snapped down onto the
|
|
190
|
+
* scale, set in `theme/index.ts`.) */
|
|
191
191
|
readonly fine: number;
|
|
192
192
|
/** The Mantine `radius` scale's `xs` step — independent of both anchors. */
|
|
193
193
|
readonly scaleXs: 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/tokens/palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;CAgCL,CAAA;AA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;;;;EA+LrD;AAaD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,YAAoC,GAAG,WAAW,CAe1F;AAED,oGAAoG;AACpG,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAMrE;+CAC+C;AAC/C,eAAO,MAAM,QAAQ;;;;CAA+B,CAAA;AAEpD;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;CAA6B,CAAA;AAEhD;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA8B,CAAA;AAElD,0FAA0F;AAC1F,eAAO,MAAM,GAAG;;;;;CAA0B,CAAA;AAE1C,mFAAmF;AACnF,eAAO,MAAM,MAAM;;;;;;CAA6B,CAAA;AAEhD;+BAC+B;AAC/B,eAAO,MAAM,IAAI;;;;;;;;;;;;;CAA2B,CAAA;AAE5C;+CAC+C;AAC/C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;CAA8B,CAAA"}
|
package/dist/tokens/palette.js
CHANGED
|
@@ -122,8 +122,8 @@ const RADIUS_STEP = {
|
|
|
122
122
|
tight: DEFAULT_RADIUS_VALUES.tight,
|
|
123
123
|
// 5
|
|
124
124
|
/** Progress bar, and the Mantine scale's `sm` step — two steps below the control radius. (No
|
|
125
|
-
* longer the SegmentedControl indicator: that is the track radius − 3 px
|
|
126
|
-
*
|
|
125
|
+
* longer the SegmentedControl indicator: that is the track radius − 3 px snapped down onto the
|
|
126
|
+
* scale, set in `theme/index.ts`.) */
|
|
127
127
|
fine: DEFAULT_RADIUS_VALUES.fine,
|
|
128
128
|
// 4
|
|
129
129
|
/** The Mantine `radius` scale's `xs` step — independent of both anchors. */
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.25.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.25.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -111,6 +111,7 @@ Signature: Meter(props: MeterProps): JSX.Element
|
|
|
111
111
|
startCaption?: ReactNode [with segments | zones]
|
|
112
112
|
endCaption?: ReactNode [with segments | zones]
|
|
113
113
|
reading?: boolean [with segments | zones]
|
|
114
|
+
readingAt?: "fill" | "start" [with segments | zones]
|
|
114
115
|
value?: number | null [with zones]
|
|
115
116
|
color?: string
|
|
116
117
|
track?: boolean
|
|
@@ -383,7 +384,7 @@ Signature: ChartCard(props: ChartCardProps): ReactElement<unknown, string | JSXE
|
|
|
383
384
|
count?: number
|
|
384
385
|
actions?: ReactNode
|
|
385
386
|
state?: ChartState
|
|
386
|
-
placeholderHeight?: number | ResponsiveChartHeight
|
|
387
|
+
placeholderHeight?: number | ResponsiveChartHeight | "content"
|
|
387
388
|
stale?: boolean
|
|
388
389
|
stateNoun?: string
|
|
389
390
|
onRetry?: (() => void)
|
package/package.json
CHANGED
package/src/charts/Bars.tsx
CHANGED
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
* `Bars` — bar series on a band x scale (Date, number or string), stacked, grouped or normalized,
|
|
3
3
|
* with line overlays on `y`/`y2` (`docs/V2-SPEC.md` § 9.3). A negative value draws below zero: a
|
|
4
4
|
* stack diverges around the baseline (the 1.x `negativeBars`, now just a signed value). Zones,
|
|
5
|
-
* reference lines, legend, cursor and tooltip are the rung's.
|
|
5
|
+
* reference lines, legend, cursor and tooltip are the rung's. In a visual slot (a `StatCard`
|
|
6
|
+
* `sparkline`, a strip cell's `visual`) it drops both axes, the grid, the margin and the legend and
|
|
7
|
+
* fills the slot like a `Sparkline`: a small histogram, its bins named in the tooltip below it.
|
|
6
8
|
*/
|
|
7
9
|
import { barY } from '@tanstack/charts/bar'
|
|
8
10
|
import { group } from '@tanstack/charts/group'
|
|
9
11
|
import { stack } from '@tanstack/charts/stack'
|
|
10
|
-
import { useCallback, useMemo } from 'react'
|
|
12
|
+
import { useCallback, useContext, useMemo } from 'react'
|
|
11
13
|
import type { ReactElement } from 'react'
|
|
12
14
|
import { CartesianRung } from './CartesianChart'
|
|
15
|
+
import { VisualSlotContext } from '../dashboard/visual-slot'
|
|
16
|
+
import { VX } from '../tokens'
|
|
13
17
|
import { emphasis, lineMark } from './marks'
|
|
14
18
|
import { rowX } from './types'
|
|
15
19
|
import type {
|
|
@@ -62,6 +66,27 @@ export type BarsProps<T, X extends ChartX = ChartX> = Omit<
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
const DEFAULT_BAR_OPACITY = 0.85
|
|
69
|
+
/** The faintest shade told-apart-by-shade series step down to. */
|
|
70
|
+
const SHADE_FLOOR = 0.4
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Series that share one colour and set no opacity of their own would draw identical bars. They step
|
|
74
|
+
* down from full strength to `SHADE_FLOOR` in `bars` order (the first is the strongest), so the legend
|
|
75
|
+
* swatches and the plot tell them apart by more than the label. A bar that sets `fillOpacity`, or a
|
|
76
|
+
* chart with `barOpacity`, keeps its own shades.
|
|
77
|
+
*/
|
|
78
|
+
function shadeSharedColors<T>(
|
|
79
|
+
bars: readonly BarsBar<T>[],
|
|
80
|
+
barOpacity: BarsProps<T>['barOpacity'],
|
|
81
|
+
): readonly BarsBar<T>[] {
|
|
82
|
+
if (barOpacity !== undefined) return bars
|
|
83
|
+
return bars.map((b) => {
|
|
84
|
+
const group = bars.filter((o) => o.color === b.color)
|
|
85
|
+
if (group.length < 2 || group.some((g) => g.fillOpacity !== undefined)) return b
|
|
86
|
+
const step = (1 - SHADE_FLOOR) / (group.length - 1)
|
|
87
|
+
return { ...b, fillOpacity: 1 - group.indexOf(b) * step }
|
|
88
|
+
})
|
|
89
|
+
}
|
|
65
90
|
|
|
66
91
|
const paint = (color: string, opacity: number): string =>
|
|
67
92
|
opacity >= 1 ? color : `color-mix(in srgb, ${color} ${Math.round(opacity * 100)}%, transparent)`
|
|
@@ -80,9 +105,12 @@ function guardLogStack(layout: string, onLog: boolean): void {
|
|
|
80
105
|
}
|
|
81
106
|
|
|
82
107
|
export function Bars<T, X extends ChartX = ChartX>(props: BarsProps<T, X>): ReactElement {
|
|
83
|
-
const { bars, lines, layout = 'stacked', barOpacity, ...rest } = props
|
|
108
|
+
const { bars: given, lines, layout = 'stacked', barOpacity, ...rest } = props
|
|
109
|
+
const bars = useMemo(() => shadeSharedColors(given, barOpacity), [given, barOpacity])
|
|
110
|
+
const sharedColor = bars.some((b, i) => bars.findIndex((o) => o.color === b.color) !== i)
|
|
84
111
|
guardLogStack(layout, bars.length > 0 && rest.y?.scale === 'log')
|
|
85
112
|
const sample = rest.data[0]
|
|
113
|
+
const bare = useContext(VisualSlotContext) !== null
|
|
86
114
|
const series = useMemo<ChartSeries<T>[]>(
|
|
87
115
|
() => [
|
|
88
116
|
// The legend has no datum: its swatch wears the shade the bars draw on the first row, so
|
|
@@ -125,6 +153,9 @@ export function Bars<T, X extends ChartX = ChartX>(props: BarsProps<T, X>): Reac
|
|
|
125
153
|
y: 'y',
|
|
126
154
|
z: 'series',
|
|
127
155
|
fill,
|
|
156
|
+
// Series of one colour differ by shade alone: a surface hairline keeps stacked segments apart.
|
|
157
|
+
...(sharedColor &&
|
|
158
|
+
layout !== 'grouped' && { stroke: VX.surface.panel, strokeWidth: 1 }),
|
|
128
159
|
// The hovered x is its own highlight: the bar reads at full strength (no dimming, no
|
|
129
160
|
// point marker, no crosshair rule: that is line-chart chrome; `focusRing={false}` on the rung).
|
|
130
161
|
states: [{ when: { focus: 'x' }, style: { fill: solid } }],
|
|
@@ -140,7 +171,7 @@ export function Bars<T, X extends ChartX = ChartX>(props: BarsProps<T, X>): Reac
|
|
|
140
171
|
}
|
|
141
172
|
return out
|
|
142
173
|
},
|
|
143
|
-
[bars, layout, barOpacity],
|
|
174
|
+
[bars, layout, barOpacity, sharedColor],
|
|
144
175
|
)
|
|
145
176
|
|
|
146
177
|
return (
|
|
@@ -152,6 +183,7 @@ export function Bars<T, X extends ChartX = ChartX>(props: BarsProps<T, X>): Reac
|
|
|
152
183
|
crosshair={false}
|
|
153
184
|
focusRing={false}
|
|
154
185
|
reverseRows={layout !== 'grouped'}
|
|
186
|
+
{...(bare && { bare, tooltipBelow: true, legend: false as const })}
|
|
155
187
|
{...(layout !== 'grouped' && { stack: layout })}
|
|
156
188
|
/>
|
|
157
189
|
)
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { useCallback, useId, useMemo, useState } from 'react'
|
|
10
10
|
import type { CSSProperties, ReactElement, ReactNode } from 'react'
|
|
11
11
|
import { useInChartCard } from './card-context'
|
|
12
|
-
import { compileCartesian, refLegendSeries } from './compile'
|
|
12
|
+
import { compileCartesian, refLegendSeries, zoneLegendSeries } from './compile'
|
|
13
13
|
import type { CartesianDefinition } from './compile'
|
|
14
14
|
import { samePlots } from './plot-context'
|
|
15
15
|
import type { PlotSizes } from './plot-context'
|
|
@@ -35,6 +35,8 @@ export type RungOptions = {
|
|
|
35
35
|
focusRing?: boolean
|
|
36
36
|
/** The legend goes from the wide class up, where `Lines`' end labels name the series. */
|
|
37
37
|
hideLegendAtWide?: boolean
|
|
38
|
+
/** No axes, grid, margin or legend: the plot is the whole box (`Bars` in a visual slot). */
|
|
39
|
+
bare?: boolean
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
// A size container: the legend picks none/dots/chips from this box's width in CSS, so the server
|
|
@@ -198,8 +200,12 @@ export function CartesianRung<T, X extends ChartX>(
|
|
|
198
200
|
)
|
|
199
201
|
// Reference lines that name themselves join the legend after the series (role `reference`).
|
|
200
202
|
const legendSeries = useMemo(
|
|
201
|
-
() => [
|
|
202
|
-
|
|
203
|
+
() => [
|
|
204
|
+
...stable.series,
|
|
205
|
+
...refLegendSeries<T>(stable.refLines),
|
|
206
|
+
...zoneLegendSeries<T>(stable.zones),
|
|
207
|
+
],
|
|
208
|
+
[stable.series, stable.refLines, stable.zones],
|
|
203
209
|
)
|
|
204
210
|
return (
|
|
205
211
|
<ChartShell
|
package/src/charts/ChartCard.tsx
CHANGED
|
@@ -142,8 +142,12 @@ type ChartCardBaseProps = BasaltProps &
|
|
|
142
142
|
state?: ChartState | undefined
|
|
143
143
|
/** Body height while a placeholder shows. Default: the chart height law, i.e. exactly the box an
|
|
144
144
|
* unsized chart takes — pass the chart's own `height` when it states one, so a `<Suspense
|
|
145
|
-
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size.
|
|
146
|
-
|
|
145
|
+
* fallback={<ChartCard state={{ pending: true }} …/>}>` reserves the final size.
|
|
146
|
+
* `'content'` is for a body that is not a chart (a list, a `Meter`): an error or empty state
|
|
147
|
+
* ends at its content. A pending state renders `children` as they are, so the body must draw
|
|
148
|
+
* its own loading (`BarList loading`, a loading `Meter`); a children-less `<Suspense
|
|
149
|
+
* fallback>` should pass a numeric height instead. */
|
|
150
|
+
placeholderHeight?: number | ResponsiveChartHeight | 'content' | undefined
|
|
147
151
|
/** Placeholder data is showing: the facts row dims with the plot (a strip cell's `stale`). */
|
|
148
152
|
stale?: boolean | undefined
|
|
149
153
|
/** What an errored `state` names: "Could not load {stateNoun}". Default: no noun. */
|
|
@@ -280,7 +284,7 @@ export function ChartCard({
|
|
|
280
284
|
{...(classNames?.body !== undefined && { className: classNames.body })}
|
|
281
285
|
style={bodyClipStyle}
|
|
282
286
|
>
|
|
283
|
-
{resolved === null ? (
|
|
287
|
+
{resolved === null || (resolved === 'pending' && placeholderHeight === 'content') ? (
|
|
284
288
|
children
|
|
285
289
|
) : (
|
|
286
290
|
<ChartPlaceholder
|
package/src/charts/Sparkline.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { ruleY } from '@tanstack/charts/rule'
|
|
|
12
12
|
import { scaleBand } from '@tanstack/charts/scales/band'
|
|
13
13
|
import { scaleLinear } from '@tanstack/charts/scales/linear'
|
|
14
14
|
import { text } from '@tanstack/charts/text'
|
|
15
|
-
import { useId, useMemo, useState } from 'react'
|
|
15
|
+
import { useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react'
|
|
16
16
|
import type { CSSProperties, FocusEvent, KeyboardEvent, PointerEvent, ReactElement } from 'react'
|
|
17
17
|
import { cx } from '../common/props'
|
|
18
18
|
import type { BasaltProps } from '../common/props'
|
|
@@ -20,6 +20,7 @@ import { VX, alpha } from '../tokens'
|
|
|
20
20
|
import type { CartesianDefinition } from './compile'
|
|
21
21
|
import { chartCurve } from './curves'
|
|
22
22
|
import { barMark } from './marks'
|
|
23
|
+
import { VisualSlotContext } from '../dashboard/visual-slot'
|
|
23
24
|
import { bucketDay, dayGranular, defaultNumberFormat } from './compile'
|
|
24
25
|
import { referenceLabelPlacement } from './ref-label'
|
|
25
26
|
import { readoutClock, readoutDay } from './chart-dates'
|
|
@@ -74,7 +75,7 @@ type Point = { i: number; v: number | null }
|
|
|
74
75
|
const LINE_WIDTH = 1.5
|
|
75
76
|
const DOT_R = 2.5
|
|
76
77
|
const BAR_GAP = 0.15
|
|
77
|
-
/** Air between the hovered point and
|
|
78
|
+
/** Air between the hovered point and a bare sparkline's readout chip beside it, px. */
|
|
78
79
|
const READOUT_GAP = 8
|
|
79
80
|
/** Air round a line's plot, px (the engine's plot margin): the end marker stays inside the svg box,
|
|
80
81
|
* so it clears the 2px focus outline round it. A bar plot is flush. */
|
|
@@ -94,7 +95,7 @@ const DAY_MS = 86_400_000
|
|
|
94
95
|
const finite = (v: number): number | null => (Number.isFinite(v) ? v : null)
|
|
95
96
|
|
|
96
97
|
/** The readout's moment per point of `{ at }` data: the day when the points are a day or more apart,
|
|
97
|
-
* else the hour (with the day once they
|
|
98
|
+
* else the hour (with the day once they cross midnight). `undefined` for plain values. */
|
|
98
99
|
function momentsOf(data: SparklineProps['data']): readonly (string | undefined)[] | undefined {
|
|
99
100
|
const dates: (Date | null)[] = []
|
|
100
101
|
for (const d of data) {
|
|
@@ -111,12 +112,14 @@ function momentsOf(data: SparklineProps['data']): readonly (string | undefined)[
|
|
|
111
112
|
if (day < lo) lo = day
|
|
112
113
|
if (day > hi) hi = day
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
+
// Hourly points inside one UTC day name the hour alone; a window that crosses midnight (24 points
|
|
116
|
+
// from 12:00 on, or 25 from 12:00 to 12:00) names the day with each hour, so no clock repeats bare.
|
|
117
|
+
const clockOnly = lo === hi
|
|
115
118
|
const byDay = dayGranular(known)
|
|
116
119
|
return dates.map((d) => {
|
|
117
120
|
if (d === null) return undefined
|
|
118
121
|
if (byDay) return readoutDay(bucketDay(d))
|
|
119
|
-
return
|
|
122
|
+
return clockOnly ? readoutClock(d) : `${readoutDay(d)} ${readoutClock(d)}`
|
|
120
123
|
})
|
|
121
124
|
}
|
|
122
125
|
|
|
@@ -386,6 +389,20 @@ function meanOf(rows: readonly Point[]): number {
|
|
|
386
389
|
return sum / n
|
|
387
390
|
}
|
|
388
391
|
|
|
392
|
+
/**
|
|
393
|
+
* A readout never loses its date to an ellipsis: when the one-line chip overflows its box it first
|
|
394
|
+
* tightens (`data-tight`: no air round the dot), then stacks (`data-stacked`: the date on its own
|
|
395
|
+
* line). Set on the node, so a measure never re-renders.
|
|
396
|
+
*/
|
|
397
|
+
function fitReadout(node: HTMLElement): void {
|
|
398
|
+
const overflows = (): boolean => node.scrollWidth > node.clientWidth
|
|
399
|
+
node.removeAttribute('data-tight')
|
|
400
|
+
node.removeAttribute('data-stacked')
|
|
401
|
+
if (!overflows()) return
|
|
402
|
+
node.setAttribute('data-tight', '')
|
|
403
|
+
if (overflows()) node.setAttribute('data-stacked', '')
|
|
404
|
+
}
|
|
405
|
+
|
|
389
406
|
export function Sparkline(props: SparklineProps): ReactElement {
|
|
390
407
|
const {
|
|
391
408
|
ariaLabel,
|
|
@@ -406,10 +423,12 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
406
423
|
style,
|
|
407
424
|
} = props
|
|
408
425
|
const id = useId()
|
|
426
|
+
const hosted = useContext(VisualSlotContext) !== null
|
|
409
427
|
// Two sources, so a pointer leaving a focused chart hands the readout back to the focused point.
|
|
410
428
|
const [hover, setHover] = useState<number | null>(null)
|
|
411
429
|
const [keyed, setKeyed] = useState<number | null>(null)
|
|
412
430
|
const active = hover ?? keyed
|
|
431
|
+
const readoutRef = useRef<HTMLOutputElement>(null)
|
|
413
432
|
const model = useMemo(() => {
|
|
414
433
|
const rows: Point[] = data.map((d, i) => ({
|
|
415
434
|
i,
|
|
@@ -474,7 +493,7 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
474
493
|
}
|
|
475
494
|
|
|
476
495
|
const inset = mark === 'line' ? LINE_INSET : 0
|
|
477
|
-
const layerStyle: CSSProperties = { inset }
|
|
496
|
+
const layerStyle: CSSProperties = { inset, ['--basalt-spark-inset' as string]: `${inset}px` }
|
|
478
497
|
const value = active === null ? null : (rows?.[active]?.v ?? null)
|
|
479
498
|
const at =
|
|
480
499
|
interactive && active !== null && value !== null
|
|
@@ -488,27 +507,47 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
488
507
|
label: labels?.[active] ?? model.moments?.[active],
|
|
489
508
|
}
|
|
490
509
|
: null
|
|
491
|
-
//
|
|
492
|
-
//
|
|
510
|
+
// Hosted (a host that reserves a line above the plot): the chip slides with the point (`left` and
|
|
511
|
+
// `translate` take one fraction), inside the box at either edge whatever its width, and the
|
|
512
|
+
// stylesheet lifts it above the plot. Bare: beside the point, on the roomier side and on the half of
|
|
513
|
+
// the box away from it, so the chip covers neither the dot nor anything the host draws round it.
|
|
493
514
|
const beside = at === null ? null : at.fx > 0.5 ? 'left' : 'right'
|
|
515
|
+
// The chip's fit depends on its text and (bare) its side, not on the pointer's every tick.
|
|
516
|
+
const shown = at !== null
|
|
517
|
+
useLayoutEffect(() => {
|
|
518
|
+
if (readoutRef.current !== null) fitReadout(readoutRef.current)
|
|
519
|
+
}, [active, at?.label, at?.value, beside])
|
|
520
|
+
// ...and on the box, which a container resize changes without a hover.
|
|
521
|
+
useEffect(() => {
|
|
522
|
+
const layer = readoutRef.current?.parentElement
|
|
523
|
+
if (!shown || !layer || typeof ResizeObserver === 'undefined') return
|
|
524
|
+
const observer = new ResizeObserver(() => {
|
|
525
|
+
if (readoutRef.current !== null) fitReadout(readoutRef.current)
|
|
526
|
+
})
|
|
527
|
+
observer.observe(layer)
|
|
528
|
+
return () => observer.disconnect()
|
|
529
|
+
}, [shown])
|
|
494
530
|
const readoutStyle: CSSProperties | undefined =
|
|
495
531
|
at === null
|
|
496
532
|
? undefined
|
|
497
|
-
:
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
533
|
+
: hosted
|
|
534
|
+
? { left: `${at.fx * 100}%`, translate: `${-at.fx * 100}% 0`, maxWidth: '100%' }
|
|
535
|
+
: {
|
|
536
|
+
...(beside === 'right'
|
|
537
|
+
? {
|
|
538
|
+
left: `calc(${at.fx * 100}% + ${READOUT_GAP}px)`,
|
|
539
|
+
maxWidth: `calc(${(1 - at.fx) * 100}% - ${READOUT_GAP}px)`,
|
|
540
|
+
}
|
|
541
|
+
: {
|
|
542
|
+
right: `calc(${(1 - at.fx) * 100}% + ${READOUT_GAP}px)`,
|
|
543
|
+
maxWidth: `calc(${at.fx * 100}% - ${READOUT_GAP}px)`,
|
|
544
|
+
}),
|
|
545
|
+
...(at.fy > 0.5 ? { top: 0 } : { bottom: 0 }),
|
|
546
|
+
}
|
|
509
547
|
return (
|
|
510
548
|
<div
|
|
511
549
|
data-basalt-sparkline=""
|
|
550
|
+
{...(hosted && { 'data-basalt-hosted': '' })}
|
|
512
551
|
role="presentation"
|
|
513
552
|
className={cx(classes.root, className)}
|
|
514
553
|
style={{ width: width ?? '100%', height, minWidth: 0, ...style }}
|
|
@@ -544,13 +583,19 @@ export function Sparkline(props: SparklineProps): ReactElement {
|
|
|
544
583
|
/>
|
|
545
584
|
)}
|
|
546
585
|
<output
|
|
586
|
+
ref={readoutRef}
|
|
547
587
|
data-basalt-sparkline-readout=""
|
|
548
588
|
aria-live={hover === null ? 'polite' : 'off'}
|
|
549
589
|
className={classes.readout}
|
|
550
590
|
style={readoutStyle}
|
|
551
591
|
>
|
|
552
592
|
{format(at.value)}
|
|
553
|
-
{at.label !== undefined &&
|
|
593
|
+
{at.label !== undefined && (
|
|
594
|
+
<span className={classes.label}>
|
|
595
|
+
<span className={classes.sep}> · </span>
|
|
596
|
+
{at.label}
|
|
597
|
+
</span>
|
|
598
|
+
)}
|
|
554
599
|
</output>
|
|
555
600
|
</span>
|
|
556
601
|
)}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* set is the caller mapping its groups to entries. The y domain is the visible stack total, so a
|
|
5
5
|
* legend toggle shrinks the axis; the tooltip lists the top band first, matching the plot.
|
|
6
6
|
*
|
|
7
|
+
* A band whose every value is `0` is skipped (no band, no legend entry, no tooltip row); `null` is a
|
|
8
|
+
* gap, not a zero, and stays.
|
|
9
|
+
*
|
|
7
10
|
* A stack is only as dense as its sparsest band: a row where ANY visible band is `null` has no
|
|
8
11
|
* total, so every band gaps across it. Reading it as `0` would claim a measured zero.
|
|
9
12
|
*/
|
|
@@ -44,7 +47,15 @@ export type StackedAreaProps<T, X extends ChartX = ChartX> = Omit<
|
|
|
44
47
|
export function StackedArea<T, X extends ChartX = ChartX>(
|
|
45
48
|
props: StackedAreaProps<T, X>,
|
|
46
49
|
): ReactElement {
|
|
47
|
-
const { series:
|
|
50
|
+
const { series: given, fillOpacity, ...rest } = props
|
|
51
|
+
// A band whose every value is 0 draws nothing but a legend entry that names an empty layer: skip it.
|
|
52
|
+
const bands = useMemo(
|
|
53
|
+
() =>
|
|
54
|
+
rest.data.length === 0
|
|
55
|
+
? given
|
|
56
|
+
: given.filter((b) => !rest.data.every((d) => b.getValue(d) === 0)),
|
|
57
|
+
[given, rest.data],
|
|
58
|
+
)
|
|
48
59
|
// `mark: 'bar'` is what the rung sums for the auto domain, and the legend/tooltip swatch.
|
|
49
60
|
const series = useMemo<ChartSeries<T>[]>(
|
|
50
61
|
() =>
|