basalt-ui 1.14.0 → 1.16.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/AGENTS.md +1 -1
- package/CHANGELOG.md +15 -0
- package/README.md +38 -2
- package/agent/rules/basalt-charts.md +279 -108
- package/agent/rules/basalt-mantine.md +4 -2
- package/agent/skills/basalt-charts/SKILL.md +114 -64
- package/agent/skills/basalt-design/SKILL.md +4 -3
- package/agent/templates/CLAUDE-block.md.tpl +9 -6
- package/configs/oxlint-plugin.js +152 -0
- package/configs/oxlint-plugin.test.ts +107 -0
- package/configs/oxlint.json +2 -0
- package/dist/charts/cursor/resolve.d.ts +33 -0
- package/dist/charts/cursor/resolve.d.ts.map +1 -0
- package/dist/charts/cursor/resolve.js +61 -0
- package/dist/charts/cursor/resolve.test.d.ts +2 -0
- package/dist/charts/cursor/resolve.test.d.ts.map +1 -0
- package/dist/charts/cursor/scope.d.ts +17 -0
- package/dist/charts/cursor/scope.d.ts.map +1 -0
- package/dist/charts/cursor/scope.js +20 -0
- package/dist/charts/cursor/store.d.ts +31 -0
- package/dist/charts/cursor/store.d.ts.map +1 -0
- package/dist/charts/cursor/store.js +25 -0
- package/dist/charts/cursor/store.test.d.ts +2 -0
- package/dist/charts/cursor/store.test.d.ts.map +1 -0
- package/dist/charts/hooks/useChartCursor.d.ts +39 -0
- package/dist/charts/hooks/useChartCursor.d.ts.map +1 -0
- package/dist/charts/hooks/useChartCursor.js +104 -0
- package/dist/charts/hooks/useChartSize.d.ts +8 -4
- package/dist/charts/hooks/useChartSize.d.ts.map +1 -1
- package/dist/charts/index.d.ts +16 -13
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/index.js +38 -19
- package/dist/charts/kinds/Bars.d.ts +45 -54
- package/dist/charts/kinds/Bars.d.ts.map +1 -1
- package/dist/charts/kinds/Bars.js +235 -392
- package/dist/charts/kinds/Bars.test.d.ts +2 -0
- package/dist/charts/kinds/Bars.test.d.ts.map +1 -0
- package/dist/charts/kinds/Donut.d.ts +5 -4
- package/dist/charts/kinds/Donut.d.ts.map +1 -1
- package/dist/charts/kinds/Donut.js +17 -14
- package/dist/charts/kinds/DualPanel.d.ts +13 -0
- package/dist/charts/kinds/DualPanel.d.ts.map +1 -1
- package/dist/charts/kinds/DualPanel.js +185 -92
- package/dist/charts/kinds/DualPanel.test.d.ts +2 -0
- package/dist/charts/kinds/DualPanel.test.d.ts.map +1 -0
- package/dist/charts/kinds/Heatmap.d.ts +15 -11
- package/dist/charts/kinds/Heatmap.d.ts.map +1 -1
- package/dist/charts/kinds/Heatmap.js +38 -22
- package/dist/charts/kinds/MultiLine.d.ts +27 -35
- package/dist/charts/kinds/MultiLine.d.ts.map +1 -1
- package/dist/charts/kinds/MultiLine.js +122 -235
- package/dist/charts/kinds/MultiLine.test.d.ts +2 -0
- package/dist/charts/kinds/MultiLine.test.d.ts.map +1 -0
- package/dist/charts/kinds/StackedArea.d.ts +21 -10
- package/dist/charts/kinds/StackedArea.d.ts.map +1 -1
- package/dist/charts/kinds/StackedArea.js +74 -132
- package/dist/charts/kinds/ZonedLine.d.ts +24 -40
- package/dist/charts/kinds/ZonedLine.d.ts.map +1 -1
- package/dist/charts/kinds/ZonedLine.js +104 -184
- package/dist/charts/kinds/ZonedLine.test.d.ts +2 -0
- package/dist/charts/kinds/ZonedLine.test.d.ts.map +1 -0
- package/dist/charts/layout/auto-margin.d.ts +60 -0
- package/dist/charts/layout/auto-margin.d.ts.map +1 -0
- package/dist/charts/layout/auto-margin.js +37 -0
- package/dist/charts/layout/auto-margin.test.d.ts +2 -0
- package/dist/charts/layout/auto-margin.test.d.ts.map +1 -0
- package/dist/charts/primitives/CartesianChart.d.ts +161 -0
- package/dist/charts/primitives/CartesianChart.d.ts.map +1 -0
- package/dist/charts/primitives/CartesianChart.js +359 -0
- package/dist/charts/primitives/CartesianChart.test.d.ts +2 -0
- package/dist/charts/primitives/CartesianChart.test.d.ts.map +1 -0
- package/dist/charts/primitives/ChartFrame.d.ts +16 -5
- package/dist/charts/primitives/ChartFrame.d.ts.map +1 -1
- package/dist/charts/primitives/ChartFrame.js +17 -2
- package/dist/charts/primitives/ChartLegend.d.ts +15 -1
- package/dist/charts/primitives/ChartLegend.d.ts.map +1 -1
- package/dist/charts/primitives/ChartLegend.js +25 -3
- package/dist/charts/primitives/ChartLegend.test.d.ts +2 -0
- package/dist/charts/primitives/ChartLegend.test.d.ts.map +1 -0
- package/dist/charts/primitives/ChartTooltip.d.ts +16 -16
- package/dist/charts/primitives/ChartTooltip.d.ts.map +1 -1
- package/dist/charts/primitives/ChartTooltip.js +45 -19
- package/dist/charts/primitives/HoverOverlay.d.ts +19 -4
- package/dist/charts/primitives/HoverOverlay.d.ts.map +1 -1
- package/dist/charts/primitives/HoverOverlay.js +22 -1
- package/dist/charts/primitives/XZoneRects.d.ts +54 -0
- package/dist/charts/primitives/XZoneRects.d.ts.map +1 -0
- package/dist/charts/primitives/XZoneRects.js +65 -0
- package/dist/charts/primitives/XZoneRects.test.d.ts +2 -0
- package/dist/charts/primitives/XZoneRects.test.d.ts.map +1 -0
- package/dist/charts/series.d.ts +28 -3
- package/dist/charts/series.d.ts.map +1 -1
- package/dist/charts/series.js +5 -2
- package/dist/charts/series.test.d.ts +2 -0
- package/dist/charts/series.test.d.ts.map +1 -0
- package/dist/charts/utils/measure-text.d.ts +25 -0
- package/dist/charts/utils/measure-text.d.ts.map +1 -0
- package/dist/charts/utils/measure-text.js +64 -0
- package/dist/charts/utils/measure-text.test.d.ts +2 -0
- package/dist/charts/utils/measure-text.test.d.ts.map +1 -0
- package/dist/content/fence-block.d.ts.map +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +1 -1
- package/dist/tokens/chart-margin.test.d.ts +2 -0
- package/dist/tokens/chart-margin.test.d.ts.map +1 -0
- package/dist/tokens/index.d.ts +29 -0
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +10 -0
- package/dist/tokens/palette.d.ts +4 -0
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +3 -0
- package/llms.txt +3 -3
- package/package.json +1 -1
- package/src/charts/cursor/resolve.test.ts +61 -0
- package/src/charts/cursor/resolve.ts +102 -0
- package/src/charts/cursor/scope.tsx +32 -0
- package/src/charts/cursor/store.test.ts +46 -0
- package/src/charts/cursor/store.ts +53 -0
- package/src/charts/hooks/useChartCursor.ts +163 -0
- package/src/charts/hooks/useChartSize.ts +8 -4
- package/src/charts/index.ts +35 -14
- package/src/charts/kinds/Bars.test.tsx +98 -0
- package/src/charts/kinds/Bars.tsx +350 -467
- package/src/charts/kinds/Donut.tsx +31 -23
- package/src/charts/kinds/DualPanel.test.tsx +131 -0
- package/src/charts/kinds/DualPanel.tsx +301 -135
- package/src/charts/kinds/Heatmap.tsx +72 -47
- package/src/charts/kinds/MultiLine.test.tsx +37 -0
- package/src/charts/kinds/MultiLine.tsx +171 -290
- package/src/charts/kinds/StackedArea.tsx +116 -175
- package/src/charts/kinds/ZonedLine.test.tsx +37 -0
- package/src/charts/kinds/ZonedLine.tsx +149 -255
- package/src/charts/layout/auto-margin.test.ts +42 -0
- package/src/charts/layout/auto-margin.ts +110 -0
- package/src/charts/primitives/CartesianChart.test.tsx +160 -0
- package/src/charts/primitives/CartesianChart.tsx +598 -0
- package/src/charts/primitives/ChartFrame.test.tsx +33 -0
- package/src/charts/primitives/ChartFrame.tsx +40 -4
- package/src/charts/primitives/ChartLegend.test.tsx +78 -0
- package/src/charts/primitives/ChartLegend.tsx +52 -2
- package/src/charts/primitives/ChartTooltip.tsx +67 -37
- package/src/charts/primitives/HoverOverlay.tsx +39 -3
- package/src/charts/primitives/XZoneRects.test.tsx +123 -0
- package/src/charts/primitives/XZoneRects.tsx +132 -0
- package/src/charts/series.test.ts +112 -0
- package/src/charts/series.ts +33 -5
- package/src/charts/utils/measure-text.test.ts +36 -0
- package/src/charts/utils/measure-text.ts +109 -0
- package/src/content/fence-block.tsx +2 -3
- package/src/surfaces.ts +2 -1
- package/src/theme/spacing.test.ts +2 -0
- package/src/tokens/chart-margin.test.ts +39 -0
- package/src/tokens/density.test.ts +1 -0
- package/src/tokens/index.ts +36 -0
- package/src/tokens/palette.ts +3 -0
- package/dist/charts/hooks/useChartTooltip.d.ts +0 -13
- package/dist/charts/hooks/useChartTooltip.d.ts.map +0 -1
- package/dist/charts/hooks/useChartTooltip.js +0 -26
- package/dist/charts/hooks/useHoverSync.d.ts +0 -46
- package/dist/charts/hooks/useHoverSync.d.ts.map +0 -1
- package/dist/charts/hooks/useHoverSync.js +0 -75
- package/dist/charts/hover-context.d.ts +0 -21
- package/dist/charts/hover-context.d.ts.map +0 -1
- package/dist/charts/hover-context.js +0 -12
- package/dist/charts/hover-sync.d.ts +0 -14
- package/dist/charts/hover-sync.d.ts.map +0 -1
- package/dist/charts/hover-sync.js +0 -17
- package/dist/charts/primitives/ResponsiveChart.d.ts +0 -45
- package/dist/charts/primitives/ResponsiveChart.d.ts.map +0 -1
- package/dist/charts/primitives/ResponsiveChart.js +0 -24
- package/src/charts/hooks/useChartTooltip.ts +0 -31
- package/src/charts/hooks/useHoverSync.ts +0 -152
- package/src/charts/hover-context.ts +0 -28
- package/src/charts/hover-sync.tsx +0 -37
- package/src/charts/primitives/ResponsiveChart.tsx +0 -64
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
2
3
|
import { createPortal } from "react-dom";
|
|
3
4
|
import { VX } from "../../tokens/index.js";
|
|
4
5
|
import { fmtTooltipDate } from "../utils/format.js";
|
|
@@ -15,22 +16,6 @@ const TOOLTIP_STYLES = {
|
|
|
15
16
|
boxShadow: VX.shadowCard,
|
|
16
17
|
minWidth: 140
|
|
17
18
|
};
|
|
18
|
-
function useTooltipStyles() {
|
|
19
|
-
return TOOLTIP_STYLES;
|
|
20
|
-
}
|
|
21
|
-
function ChartTooltip({
|
|
22
|
-
tip,
|
|
23
|
-
tooltipRef,
|
|
24
|
-
styles,
|
|
25
|
-
children
|
|
26
|
-
}) {
|
|
27
|
-
if (!tip) return null;
|
|
28
|
-
if (typeof document === "undefined") return null;
|
|
29
|
-
return createPortal(
|
|
30
|
-
/* @__PURE__ */ jsx("div", { ref: tooltipRef, style: { ...styles, left: tip.x, top: tip.y }, children }),
|
|
31
|
-
document.body
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
19
|
function TooltipHeader({
|
|
35
20
|
date,
|
|
36
21
|
label,
|
|
@@ -131,10 +116,51 @@ function TooltipRow({
|
|
|
131
116
|
function TooltipBody({ children }) {
|
|
132
117
|
return /* @__PURE__ */ jsx("div", { style: { padding: "5px 0" }, children });
|
|
133
118
|
}
|
|
119
|
+
const TOOLTIP_GAP = 12;
|
|
120
|
+
const VIEWPORT_MARGIN = 8;
|
|
121
|
+
function ChartTooltipFloat({
|
|
122
|
+
anchor,
|
|
123
|
+
children
|
|
124
|
+
}) {
|
|
125
|
+
const ref = useRef(null);
|
|
126
|
+
const [box, setBox] = useState(null);
|
|
127
|
+
useLayoutEffect(() => {
|
|
128
|
+
const el = ref.current;
|
|
129
|
+
if (el === null) return;
|
|
130
|
+
const { offsetWidth, offsetHeight } = el;
|
|
131
|
+
setBox(
|
|
132
|
+
(prev) => prev !== null && prev.width === offsetWidth && prev.height === offsetHeight ? prev : { width: offsetWidth, height: offsetHeight }
|
|
133
|
+
);
|
|
134
|
+
}, [children, anchor]);
|
|
135
|
+
if (anchor === null) return null;
|
|
136
|
+
if (typeof document === "undefined") return null;
|
|
137
|
+
const width = box?.width ?? 0;
|
|
138
|
+
const height = box?.height ?? 0;
|
|
139
|
+
const vw = window.innerWidth;
|
|
140
|
+
const vh = window.innerHeight;
|
|
141
|
+
const flipsLeft = anchor.x + TOOLTIP_GAP + width + VIEWPORT_MARGIN > vw;
|
|
142
|
+
const left = flipsLeft ? Math.max(VIEWPORT_MARGIN, anchor.x - TOOLTIP_GAP - width) : anchor.x + TOOLTIP_GAP;
|
|
143
|
+
const top = Math.min(
|
|
144
|
+
Math.max(VIEWPORT_MARGIN, anchor.y - TOOLTIP_GAP),
|
|
145
|
+
Math.max(VIEWPORT_MARGIN, vh - height - VIEWPORT_MARGIN)
|
|
146
|
+
);
|
|
147
|
+
return createPortal(
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
ref,
|
|
152
|
+
role: "tooltip",
|
|
153
|
+
"aria-live": "polite",
|
|
154
|
+
style: { ...TOOLTIP_STYLES, left, top, visibility: box === null ? "hidden" : "visible" },
|
|
155
|
+
children
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
document.body
|
|
159
|
+
);
|
|
160
|
+
}
|
|
134
161
|
export {
|
|
135
|
-
|
|
162
|
+
ChartTooltipFloat,
|
|
136
163
|
TooltipBody,
|
|
137
164
|
TooltipHeader,
|
|
138
|
-
TooltipRow
|
|
139
|
-
useTooltipStyles
|
|
165
|
+
TooltipRow
|
|
140
166
|
};
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import type { PointerEventHandler } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
1
|
+
import type { FocusEventHandler, KeyboardEventHandler, PointerEventHandler } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Transparent <rect> that captures pointer events (mouse + touch + pen) for tooltip + crosshair
|
|
4
|
+
* sync.
|
|
5
|
+
*
|
|
6
|
+
* With `onKeyDown` it also becomes the chart's keyboard affordance: the rect takes focus and
|
|
7
|
+
* ←/→ scrub the cursor, so a chart's values are reachable without a pointer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function HoverOverlay({ width, height, onMove, onLeave, onKeyDown, onBlur, ariaLabel, valueNow, valueMax, valueText, }: {
|
|
5
10
|
width: number;
|
|
6
11
|
height: number;
|
|
7
12
|
onMove: PointerEventHandler<SVGRectElement>;
|
|
8
13
|
onLeave: PointerEventHandler<SVGRectElement>;
|
|
14
|
+
/** Present = the overlay is focusable and scrubs on ←/→. */
|
|
15
|
+
onKeyDown?: KeyboardEventHandler<SVGRectElement>;
|
|
16
|
+
onBlur?: FocusEventHandler<SVGRectElement>;
|
|
17
|
+
ariaLabel?: string;
|
|
18
|
+
/** Index of the focused point — announced as the slider position. */
|
|
19
|
+
valueNow?: number;
|
|
20
|
+
/** Last index of the domain. */
|
|
21
|
+
valueMax?: number;
|
|
22
|
+
/** Human-readable label for the focused point (the formatted x key). */
|
|
23
|
+
valueText?: string;
|
|
9
24
|
}): import("react").JSX.Element;
|
|
10
25
|
//# sourceMappingURL=HoverOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HoverOverlay.d.ts","sourceRoot":"","sources":["../../../src/charts/primitives/HoverOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"HoverOverlay.d.ts","sourceRoot":"","sources":["../../../src/charts/primitives/HoverOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAEzF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,SAAS,EACT,MAAM,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;IAC3C,OAAO,EAAE,mBAAmB,CAAC,cAAc,CAAC,CAAA;IAC5C,4DAA4D;IAC5D,SAAS,CAAC,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAA;IAChD,MAAM,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,+BA8BA"}
|
|
@@ -3,7 +3,13 @@ function HoverOverlay({
|
|
|
3
3
|
width,
|
|
4
4
|
height,
|
|
5
5
|
onMove,
|
|
6
|
-
onLeave
|
|
6
|
+
onLeave,
|
|
7
|
+
onKeyDown,
|
|
8
|
+
onBlur,
|
|
9
|
+
ariaLabel,
|
|
10
|
+
valueNow,
|
|
11
|
+
valueMax,
|
|
12
|
+
valueText
|
|
7
13
|
}) {
|
|
8
14
|
return /* @__PURE__ */ jsx(
|
|
9
15
|
"rect",
|
|
@@ -11,6 +17,21 @@ function HoverOverlay({
|
|
|
11
17
|
width,
|
|
12
18
|
height,
|
|
13
19
|
fill: "transparent",
|
|
20
|
+
...onKeyDown !== void 0 && {
|
|
21
|
+
tabIndex: 0,
|
|
22
|
+
// `slider`, not `application`: `application` would drop this node out of the screen
|
|
23
|
+
// reader's normal browse mode entirely, which is a far bigger hammer than an arrow-key
|
|
24
|
+
// scrub needs. A slider announces both the affordance and the focused point.
|
|
25
|
+
role: "slider",
|
|
26
|
+
"aria-label": ariaLabel ?? "Chart data \u2014 use arrow keys to scrub",
|
|
27
|
+
"aria-orientation": "horizontal",
|
|
28
|
+
"aria-valuemin": 0,
|
|
29
|
+
...valueMax !== void 0 && { "aria-valuemax": valueMax },
|
|
30
|
+
...valueNow !== void 0 && { "aria-valuenow": valueNow },
|
|
31
|
+
...valueText !== void 0 && { "aria-valuetext": valueText },
|
|
32
|
+
onKeyDown,
|
|
33
|
+
...onBlur !== void 0 && { onBlur }
|
|
34
|
+
},
|
|
14
35
|
style: { touchAction: "pan-y" },
|
|
15
36
|
onPointerMove: onMove,
|
|
16
37
|
onPointerLeave: onLeave,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { scalePoint } from '@visx/scale';
|
|
2
|
+
/**
|
|
3
|
+
* The point-scale instance type, derived from `@visx/scale`'s own `scalePoint` return type.
|
|
4
|
+
* Equivalent to d3's `ScalePoint<string>` but resolved through `@visx/scale` (an installed dep) so
|
|
5
|
+
* it needs no `@types/d3-scale` and stays inside the visx-only-in-charts boundary.
|
|
6
|
+
*/
|
|
7
|
+
type PointScale = ReturnType<typeof scalePoint<string>>;
|
|
8
|
+
export type XZoneSpec = {
|
|
9
|
+
/** Left edge — a domain key produced by the kind's `getX`. Omit for "start of the plot area". */
|
|
10
|
+
from?: string;
|
|
11
|
+
/** Right edge — a domain key produced by the kind's `getX`. Omit for "end of the plot area". */
|
|
12
|
+
to?: string;
|
|
13
|
+
fill: string;
|
|
14
|
+
/**
|
|
15
|
+
* `'center'` (default, unchanged behaviour) resolves a present bound to `xScale(key)` — the
|
|
16
|
+
* point's own center, so a band reads "from this sample to that sample" rather than
|
|
17
|
+
* edge-to-edge. `'edge'` resolves a present `from` to `xScale(from) - step/2` and a present `to`
|
|
18
|
+
* to `xScale(to) + step/2` (`step` read from `xScale.step()`), so the band covers both terminal
|
|
19
|
+
* slots in full — a two-key band widens by exactly one step, and `from === to` renders one step
|
|
20
|
+
* wide instead of being skipped as degenerate. An omitted `from`/`to` still resolves to the plot
|
|
21
|
+
* edge (`xScale.range()[0]`/`[1]`) in both modes, unshifted — omission means "the plot's own
|
|
22
|
+
* edge", not "the first/last sample's edge". A resolved `'edge'` bound is clamped into the plot
|
|
23
|
+
* range so a band anchored at the first or last sample cannot paint outside the plot area.
|
|
24
|
+
*/
|
|
25
|
+
align?: 'center' | 'edge';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Vertical zone backgrounds (x-range overlays — twilight bands, a shaded time window) — one
|
|
29
|
+
* <rect> per zone, spanning y=[0, height] and x=[scale(from), scale(to)]. The x analog of
|
|
30
|
+
* `ZoneRects`, for a `scalePoint` x-axis instead of a `scaleLinear` y-axis.
|
|
31
|
+
*
|
|
32
|
+
* Bound resolution depends on `XZoneSpec.align` (see its JSDoc for the full `'center'`/`'edge'`
|
|
33
|
+
* contract) — default `'center'` resolves a present key to the point's own center; `'edge'`
|
|
34
|
+
* widens by half a step at each present bound so the band covers the terminal slots in full.
|
|
35
|
+
*
|
|
36
|
+
* A key that is not in the scale's domain skips that band entirely (renders nothing for it) —
|
|
37
|
+
* it is NEVER clamped to a plot edge, in either mode. Clamping an unknown key would silently
|
|
38
|
+
* paint a band across the whole chart for a typo'd or stale key, which is the exact class of
|
|
39
|
+
* quiet lie the repo's "nothing to draw is two different states" doctrine rejects: an unknown key
|
|
40
|
+
* must read as "not drawn", not as "the whole plot".
|
|
41
|
+
*
|
|
42
|
+
* A degenerate resolved range (right edge <= left edge, e.g. an inverted `from`/`to` pair) is
|
|
43
|
+
* also skipped — no negative-width rect. In `'center'` mode `from === to` is degenerate (skipped,
|
|
44
|
+
* today's behaviour); in `'edge'` mode it is NOT — the half-step widening on each side always
|
|
45
|
+
* produces a positive-width, one-step-wide rect.
|
|
46
|
+
*/
|
|
47
|
+
export declare function XZoneRects({ zones, height, xScale, }: {
|
|
48
|
+
zones: XZoneSpec[];
|
|
49
|
+
/** Plot-area height (yMax); rects span from 0 to this. */
|
|
50
|
+
height: number;
|
|
51
|
+
xScale: PointScale;
|
|
52
|
+
}): import("react").JSX.Element;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=XZoneRects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XZoneRects.d.ts","sourceRoot":"","sources":["../../../src/charts/primitives/XZoneRects.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;GAIG;AACH,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AAEvD,MAAM,MAAM,SAAS,GAAG;IACtB,iGAAiG;IACjG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gGAAgG;IAChG,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CAC1B,CAAA;AAkCD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,MAAM,EACN,MAAM,GACP,EAAE;IACD,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,UAAU,CAAA;CACnB,+BAyCA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
function clamp(value, min, max) {
|
|
3
|
+
return Math.min(Math.max(value, min), max);
|
|
4
|
+
}
|
|
5
|
+
function resolveBound({
|
|
6
|
+
key,
|
|
7
|
+
omittedEdge,
|
|
8
|
+
xScale,
|
|
9
|
+
align,
|
|
10
|
+
edgeSign,
|
|
11
|
+
rangeMin,
|
|
12
|
+
rangeMax
|
|
13
|
+
}) {
|
|
14
|
+
if (key === void 0) return omittedEdge;
|
|
15
|
+
const center = xScale(key);
|
|
16
|
+
if (center === void 0) return void 0;
|
|
17
|
+
if (align === "center") return center;
|
|
18
|
+
return clamp(center + edgeSign * (xScale.step() / 2), rangeMin, rangeMax);
|
|
19
|
+
}
|
|
20
|
+
function XZoneRects({
|
|
21
|
+
zones,
|
|
22
|
+
height,
|
|
23
|
+
xScale
|
|
24
|
+
}) {
|
|
25
|
+
return /* @__PURE__ */ jsx(Fragment, { children: zones.map((z, i) => {
|
|
26
|
+
const [rangeStart, rangeEnd] = xScale.range();
|
|
27
|
+
const rangeMin = Math.min(rangeStart, rangeEnd);
|
|
28
|
+
const rangeMax = Math.max(rangeStart, rangeEnd);
|
|
29
|
+
const align = z.align ?? "center";
|
|
30
|
+
const xFrom = resolveBound({
|
|
31
|
+
key: z.from,
|
|
32
|
+
omittedEdge: rangeStart,
|
|
33
|
+
xScale,
|
|
34
|
+
align,
|
|
35
|
+
edgeSign: -1,
|
|
36
|
+
rangeMin,
|
|
37
|
+
rangeMax
|
|
38
|
+
});
|
|
39
|
+
const xTo = resolveBound({
|
|
40
|
+
key: z.to,
|
|
41
|
+
omittedEdge: rangeEnd,
|
|
42
|
+
xScale,
|
|
43
|
+
align,
|
|
44
|
+
edgeSign: 1,
|
|
45
|
+
rangeMin,
|
|
46
|
+
rangeMax
|
|
47
|
+
});
|
|
48
|
+
if (xFrom === void 0 || xTo === void 0) return null;
|
|
49
|
+
if (xTo <= xFrom) return null;
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
|
+
"rect",
|
|
52
|
+
{
|
|
53
|
+
x: xFrom,
|
|
54
|
+
y: 0,
|
|
55
|
+
width: xTo - xFrom,
|
|
56
|
+
height,
|
|
57
|
+
fill: z.fill
|
|
58
|
+
},
|
|
59
|
+
`xzone-${i}`
|
|
60
|
+
);
|
|
61
|
+
}) });
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
XZoneRects
|
|
65
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XZoneRects.test.d.ts","sourceRoot":"","sources":["../../../src/charts/primitives/XZoneRects.test.tsx"],"names":[],"mappings":""}
|
package/dist/charts/series.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type ChartLegendConfig = {
|
|
|
36
36
|
groups?: boolean;
|
|
37
37
|
/** Wrap cap → "+N more" rollup at high cardinality. */
|
|
38
38
|
maxRows?: number;
|
|
39
|
+
/** Clicking an entry hides that series. Default: on whenever there is more than one entry. */
|
|
40
|
+
toggle?: boolean;
|
|
39
41
|
};
|
|
40
42
|
/** Visual identity of a series — everything the legend + tooltip swatch need. No accessors, no `T`. */
|
|
41
43
|
export type SeriesStyle = {
|
|
@@ -50,19 +52,41 @@ export type SeriesStyle = {
|
|
|
50
52
|
strokeWidth?: number;
|
|
51
53
|
/** bar/area: the swatch honors this so it cannot lie. */
|
|
52
54
|
fillOpacity?: number;
|
|
55
|
+
/**
|
|
56
|
+
* A MARK property — dims the plotted stroke, e.g. a faint moving-average companion line. The
|
|
57
|
+
* legend swatch honors it too (parity with `fillOpacity`, which it already honors — a swatch
|
|
58
|
+
* that lies is the thing the derived-legend rule exists to prevent). The TOOLTIP ROW swatch and
|
|
59
|
+
* the CROSSHAIR DOT deliberately do NOT honor it: those are 12px value-readout chips where a
|
|
60
|
+
* sub-1 opacity reads as a rendering bug, not as data.
|
|
61
|
+
*/
|
|
62
|
+
strokeOpacity?: number;
|
|
63
|
+
/** Which y-axis this series is measured against. Default 'left'. `'right'` is what makes a
|
|
64
|
+
* chart dual-axis — `CartesianChart` reads it for the crosshair dots and the tooltip. */
|
|
65
|
+
axis?: 'left' | 'right';
|
|
53
66
|
/** Default 'series'. */
|
|
54
67
|
role?: SeriesRole;
|
|
55
68
|
/** Default true; false = companion folded under `parent`. */
|
|
56
69
|
legend?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Default true; false = drawn and legended, but NEVER listed as a tooltip row. The replacement
|
|
72
|
+
* for the per-kind `hideBarTooltipRows` escape the old layer had: it belongs to the series, not to the kind, so
|
|
73
|
+
* one series can opt out without the kind growing a prop for it.
|
|
74
|
+
*/
|
|
75
|
+
tooltip?: boolean;
|
|
57
76
|
/** e.g. an MA line names its parent so hover-dimming keeps the pair. */
|
|
58
77
|
parent?: string;
|
|
78
|
+
/** Short qualifier rendered after the label in muted text — e.g. a flat-at-zero series that is
|
|
79
|
+
* invisible in the plot. */
|
|
80
|
+
note?: string;
|
|
59
81
|
};
|
|
60
82
|
/** Full descriptor = visual identity + data accessors. Generic over the point type. */
|
|
61
83
|
export type ChartSeries<T> = SeriesStyle & {
|
|
62
84
|
/** null = line gap + skipped tooltip row. */
|
|
63
85
|
getValue: (d: T) => number | null;
|
|
64
|
-
/** Per-series override of the shared tooltip/value formatter.
|
|
65
|
-
|
|
86
|
+
/** Per-series override of the shared tooltip/value formatter. Receives the hovered datum
|
|
87
|
+
* alongside the value so a row can read fields beyond the plotted number (e.g. `97.5 kg (92.5 ×
|
|
88
|
+
* 3)`). */
|
|
89
|
+
formatValue?: (v: number, d: T) => string;
|
|
66
90
|
/** PR star / status dot. Return null for no marker at that point. */
|
|
67
91
|
getMarker?: (d: T) => {
|
|
68
92
|
color?: string;
|
|
@@ -92,7 +116,8 @@ export type TooltipRowData = {
|
|
|
92
116
|
export declare function deriveLegend(series: readonly SeriesStyle[]): LegendEntry[];
|
|
93
117
|
/**
|
|
94
118
|
* Derive tooltip rows from a series descriptor array + the hovered datum. Skips rows where
|
|
95
|
-
* `getValue(datum) === null`; honors per-series `formatValue` over the
|
|
119
|
+
* `getValue(datum) === null` or `tooltip === false`; honors per-series `formatValue` over the
|
|
120
|
+
* shared `fallbackFormat`.
|
|
96
121
|
* Kinds pass `series.toReversed()` for stacked charts so the tooltip stack matches the visual stack.
|
|
97
122
|
*/
|
|
98
123
|
export declare function deriveTooltipRows<T>(series: readonly ChartSeries<T>[], datum: T, fallbackFormat: (v: number) => string): TooltipRowData[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"series.d.ts","sourceRoot":"","sources":["../../src/charts/series.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAA;AAE5C,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAA;AAEhD,0CAA0C;AAC1C,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE3C,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,QAAQ,GAA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AK,MAAM,GAAG,IAAI,CAAA;IACjC;;eAEW;IACX,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACzC,qEAAqE;IACrE,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAC5D,CAAA;AAED,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,KAAK,CAAA;IACrB,MAAM,EAAE,OAAO,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAoB1E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EACjC,KAAK,EAAE,CAAC,EACR,cAAc,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GACpC,cAAc,EAAE,CAkBlB"}
|
package/dist/charts/series.js
CHANGED
|
@@ -9,7 +9,9 @@ function legendEntryFor(s) {
|
|
|
9
9
|
dashed: s.dash === "dashed",
|
|
10
10
|
...s.strokeWidth !== void 0 && { strokeWidth: s.strokeWidth },
|
|
11
11
|
...s.fillOpacity !== void 0 && { fillOpacity: s.fillOpacity },
|
|
12
|
-
...s.
|
|
12
|
+
...s.strokeOpacity !== void 0 && { strokeOpacity: s.strokeOpacity },
|
|
13
|
+
...s.role !== void 0 && { role: s.role },
|
|
14
|
+
...s.note !== void 0 && { note: s.note }
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
17
|
function deriveLegend(series) {
|
|
@@ -33,6 +35,7 @@ function deriveLegend(series) {
|
|
|
33
35
|
function deriveTooltipRows(series, datum, fallbackFormat) {
|
|
34
36
|
const rows = [];
|
|
35
37
|
for (const s of series) {
|
|
38
|
+
if (s.tooltip === false) continue;
|
|
36
39
|
const value = s.getValue(datum);
|
|
37
40
|
if (value === null) continue;
|
|
38
41
|
const format = s.formatValue ?? fallbackFormat;
|
|
@@ -40,7 +43,7 @@ function deriveTooltipRows(series, datum, fallbackFormat) {
|
|
|
40
43
|
key: s.key,
|
|
41
44
|
label: s.label,
|
|
42
45
|
color: s.color,
|
|
43
|
-
value: format(value),
|
|
46
|
+
value: format(value, datum),
|
|
44
47
|
shape: shapeFor(s.mark),
|
|
45
48
|
dashed: s.dash === "dashed",
|
|
46
49
|
...s.strokeWidth !== void 0 && { strokeWidth: s.strokeWidth }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"series.test.d.ts","sourceRoot":"","sources":["../../src/charts/series.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text measurement for chart layout — the input to {@link autoMargin}.
|
|
3
|
+
*
|
|
4
|
+
* A static margin token cannot know how wide a tick label is, which is why charts used to have to be
|
|
5
|
+
* hand-nudged whenever a label grew (`docs/CHARTS-SPEC.md` §1). This measures the strings that
|
|
6
|
+
* will actually be painted, via an OFFSCREEN canvas 2D context: no element is attached, so there
|
|
7
|
+
* is no layout thrash and no reflow — unlike an SVG `getBBox()` probe.
|
|
8
|
+
*
|
|
9
|
+
* Mantine-free and dependency-free by construction (`charts/**` boundary).
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The resolved value of `--basalt-font-mono` — canvas needs a concrete family list, it cannot
|
|
13
|
+
* resolve a CSS custom property. Read once from the document element.
|
|
14
|
+
*/
|
|
15
|
+
export declare function monoFontFamily(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Width in px of `text` at `fontPx` in the chart tick font. Memoized per `font|text` — a chart
|
|
18
|
+
* re-measures the same ~10 tick labels on every resize, and the cache turns that into a Map hit.
|
|
19
|
+
*/
|
|
20
|
+
export declare function measureText(text: string, fontPx: number, fontFamily?: string): number;
|
|
21
|
+
/** Widest of `texts` at `fontPx`. Returns 0 for an empty list. */
|
|
22
|
+
export declare function maxTextWidth(texts: readonly string[], fontPx: number, fontFamily?: string): number;
|
|
23
|
+
/** Test seam — drops the memo table (and the resolved family) so a test can change fonts. */
|
|
24
|
+
export declare function resetTextMetrics(): void;
|
|
25
|
+
//# sourceMappingURL=measure-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-text.d.ts","sourceRoot":"","sources":["../../../src/charts/utils/measure-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAuCH;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAWvC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBrF;AAED,kEAAkE;AAClE,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAOR;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const FALLBACK_CHAR_RATIO = 0.6;
|
|
2
|
+
const FALLBACK_MONO = "ui-monospace, SFMono-Regular, Menlo, monospace";
|
|
3
|
+
const CACHE_LIMIT = 2e3;
|
|
4
|
+
const cache = /* @__PURE__ */ new Map();
|
|
5
|
+
let ctx;
|
|
6
|
+
let monoFamily;
|
|
7
|
+
function canvasContext() {
|
|
8
|
+
if (ctx !== void 0) return ctx;
|
|
9
|
+
if (typeof document === "undefined") {
|
|
10
|
+
ctx = null;
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
13
|
+
ctx = document.createElement("canvas").getContext("2d");
|
|
14
|
+
document.fonts?.ready?.then?.(() => cache.clear()).catch(() => {
|
|
15
|
+
});
|
|
16
|
+
return ctx;
|
|
17
|
+
}
|
|
18
|
+
function monoFontFamily() {
|
|
19
|
+
if (monoFamily !== void 0) return monoFamily;
|
|
20
|
+
if (typeof document === "undefined" || typeof getComputedStyle !== "function") {
|
|
21
|
+
monoFamily = FALLBACK_MONO;
|
|
22
|
+
return monoFamily;
|
|
23
|
+
}
|
|
24
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue("--basalt-font-mono").trim();
|
|
25
|
+
monoFamily = value.length > 0 ? value : FALLBACK_MONO;
|
|
26
|
+
return monoFamily;
|
|
27
|
+
}
|
|
28
|
+
function measureText(text, fontPx, fontFamily) {
|
|
29
|
+
const family = fontFamily ?? monoFontFamily();
|
|
30
|
+
const font = `${fontPx}px ${family}`;
|
|
31
|
+
const key = `${font}|${text}`;
|
|
32
|
+
const hit = cache.get(key);
|
|
33
|
+
if (hit !== void 0) return hit;
|
|
34
|
+
const c = canvasContext();
|
|
35
|
+
let width;
|
|
36
|
+
if (c === null) {
|
|
37
|
+
width = text.length * fontPx * FALLBACK_CHAR_RATIO;
|
|
38
|
+
} else {
|
|
39
|
+
c.font = font;
|
|
40
|
+
width = c.measureText(text).width;
|
|
41
|
+
}
|
|
42
|
+
if (cache.size >= CACHE_LIMIT) cache.clear();
|
|
43
|
+
cache.set(key, width);
|
|
44
|
+
return width;
|
|
45
|
+
}
|
|
46
|
+
function maxTextWidth(texts, fontPx, fontFamily) {
|
|
47
|
+
let max = 0;
|
|
48
|
+
for (const text of texts) {
|
|
49
|
+
const width = measureText(text, fontPx, fontFamily);
|
|
50
|
+
if (width > max) max = width;
|
|
51
|
+
}
|
|
52
|
+
return max;
|
|
53
|
+
}
|
|
54
|
+
function resetTextMetrics() {
|
|
55
|
+
cache.clear();
|
|
56
|
+
ctx = void 0;
|
|
57
|
+
monoFamily = void 0;
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
maxTextWidth,
|
|
61
|
+
measureText,
|
|
62
|
+
monoFontFamily,
|
|
63
|
+
resetTextMetrics
|
|
64
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-text.test.d.ts","sourceRoot":"","sources":["../../../src/charts/utils/measure-text.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fence-block.d.ts","sourceRoot":"","sources":["../../src/content/fence-block.tsx"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAOnC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,oGAAoG;IACpG,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,kBAAkB,KAAK,SAAS,CAAA;AAElE,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;AAYpE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAEhE;AAED,uFAAuF;AACvF,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,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,uEAAuE;IACvE,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAA;CACpC,CAAA;AA0HD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,eAAe,sCA2BvE"}
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export declare const SURFACES: {
|
|
|
141
141
|
readonly rule: "charts";
|
|
142
142
|
readonly skill: readonly ["basalt-charts"];
|
|
143
143
|
readonly guardKinds: readonly ["raw-hex", "raw-color-fn", "raw-visx-axis", "unframed-chart"];
|
|
144
|
-
readonly description: "visx chart primitives, sparklines, hooks, and token re-exports (Mantine-free)";
|
|
144
|
+
readonly description: "CartesianChart + visx chart primitives, kinds, sparklines, hooks, and token re-exports (Mantine-free)";
|
|
145
145
|
readonly globs: {
|
|
146
146
|
readonly shipped: readonly ["**/charts/**"];
|
|
147
147
|
readonly repo: readonly ["packages/basalt-ui/src/charts/**"];
|
package/dist/surfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaces.d.ts","sourceRoot":"","sources":["../src/surfaces.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAI9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAChB,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,eAAe,GACf,UAAU,GACV,MAAM,GACN,OAAO,GACP,SAAS,GACT,KAAK,CAAA;AAET;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,CAAA;AAExE;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,iBAAiB,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,CAAA;AAElF;;;;;;GAMG;AACH,M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nG;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACzC,OAAO,CAET"}
|
package/dist/surfaces.js
CHANGED
|
@@ -47,7 +47,7 @@ const SURFACES = {
|
|
|
47
47
|
rule: "charts",
|
|
48
48
|
skill: ["basalt-charts"],
|
|
49
49
|
guardKinds: ["raw-hex", "raw-color-fn", "raw-visx-axis", "unframed-chart"],
|
|
50
|
-
description: "visx chart primitives, sparklines, hooks, and token re-exports (Mantine-free)",
|
|
50
|
+
description: "CartesianChart + visx chart primitives, kinds, sparklines, hooks, and token re-exports (Mantine-free)",
|
|
51
51
|
globs: {
|
|
52
52
|
shipped: ["**/charts/**"],
|
|
53
53
|
repo: ["packages/basalt-ui/src/charts/**"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-margin.test.d.ts","sourceRoot":"","sources":["../../src/tokens/chart-margin.test.ts"],"names":[],"mappings":""}
|
package/dist/tokens/index.d.ts
CHANGED
|
@@ -114,6 +114,35 @@ export declare const VX: {
|
|
|
114
114
|
};
|
|
115
115
|
readonly minPxPerTick: 55;
|
|
116
116
|
};
|
|
117
|
+
/** Resolved chart plot-area margins — the return shape of {@link chartMargin}. */
|
|
118
|
+
export type ChartMargin = {
|
|
119
|
+
top: number;
|
|
120
|
+
right: number;
|
|
121
|
+
bottom: number;
|
|
122
|
+
left: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Chart plot-area margins — `VX.margin` widened for an `AxisRightNumeric`'s tick labels, and/or
|
|
126
|
+
* overridden per side. A token can't express "only when a right axis is rendered", so this is a
|
|
127
|
+
* function, not a second static token — also the seam that could one day track `density`
|
|
128
|
+
* (`VX.margin` itself is frozen at the level-0 snapshot; see `deriveSpacing`'s JSDoc).
|
|
129
|
+
*
|
|
130
|
+
* Law, applied in this order: start from `VX.margin`; when `rightAxis` is true, widen `right` to
|
|
131
|
+
* `Math.max(VX.margin.right, <right-axis minimum>)` (`SPACE_STEP.chartMarginRightAxis`); then any
|
|
132
|
+
* explicitly passed side wins last (including overriding `rightAxis`'s widened `right`).
|
|
133
|
+
* `chartMargin()` with no args deep-equals `VX.margin`.
|
|
134
|
+
*
|
|
135
|
+
* Returns a NEW object every call — memoize at the call site (`useMemo`), the same way `Bars`
|
|
136
|
+
* already memoizes its own margin.
|
|
137
|
+
*/
|
|
138
|
+
export declare function chartMargin(opts?: {
|
|
139
|
+
/** Reserve room for an `AxisRightNumeric`'s tick labels. */
|
|
140
|
+
rightAxis?: boolean;
|
|
141
|
+
top?: number;
|
|
142
|
+
right?: number;
|
|
143
|
+
bottom?: number;
|
|
144
|
+
left?: number;
|
|
145
|
+
}): ChartMargin;
|
|
117
146
|
/**
|
|
118
147
|
* A px number expressed as the plain rem STRING literal (16px base: `pxRem(6)` → `'0.375rem'`) —
|
|
119
148
|
* NOT Mantine's own `rem()` helper, which instead emits a `calc(...)` expression bound to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAMvE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAOjC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAM5D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAO7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE5C,wFAAwF;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AW,GAAG,SAAS,GAAG,MAAM,CAGtE"}
|
package/dist/tokens/index.js
CHANGED
|
@@ -158,6 +158,15 @@ const VX = {
|
|
|
158
158
|
},
|
|
159
159
|
minPxPerTick: 55
|
|
160
160
|
};
|
|
161
|
+
function chartMargin(opts) {
|
|
162
|
+
const widenedRight = opts?.rightAxis ? Math.max(VX.margin.right, SPACE_STEP.chartMarginRightAxis) : VX.margin.right;
|
|
163
|
+
return {
|
|
164
|
+
top: opts?.top ?? VX.margin.top,
|
|
165
|
+
right: opts?.right ?? widenedRight,
|
|
166
|
+
bottom: opts?.bottom ?? VX.margin.bottom,
|
|
167
|
+
left: opts?.left ?? VX.margin.left
|
|
168
|
+
};
|
|
169
|
+
}
|
|
161
170
|
const decl = (name, value) => ` --vx-${name}: ${value};`;
|
|
162
171
|
function pxRem(px) {
|
|
163
172
|
return `${px / 16}rem`;
|
|
@@ -553,6 +562,7 @@ export {
|
|
|
553
562
|
buildFontsCss,
|
|
554
563
|
buildPaletteCss,
|
|
555
564
|
buildRadiusCss,
|
|
565
|
+
chartMargin,
|
|
556
566
|
defineSeries,
|
|
557
567
|
deriveRadius,
|
|
558
568
|
deriveSpacing,
|