@brdgapp/ui 1.2.0 → 1.2.1
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 +6 -0
- package/components/chart.js +20 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of `@brdgapp/ui`. Versions follow the rules in README.md → Versions.
|
|
4
4
|
|
|
5
|
+
## 1.2.1
|
|
6
|
+
|
|
7
|
+
2026-11-10. A small addition that changes nothing an app relies on.
|
|
8
|
+
|
|
9
|
+
- Chart: Home and End jump to the first or last point, and Esc hides the tooltip (← → and Enter already worked).
|
|
10
|
+
|
|
5
11
|
## 1.2.0
|
|
6
12
|
|
|
7
13
|
2026-11-06. A new component and new tokens. Nothing changes for apps already on 1.1, so they can update
|
package/components/chart.js
CHANGED
|
@@ -23,6 +23,8 @@ function useChart() {
|
|
|
23
23
|
}
|
|
24
24
|
// Keys become CSS variable names and SVG ids, so keep only safe characters.
|
|
25
25
|
const safe = (key) => key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
26
|
+
// The most points Home and End step across: far more than a readable chart has.
|
|
27
|
+
const MAX_POINTS = 500;
|
|
26
28
|
// Where a series sits in `config`; anything not in it goes last.
|
|
27
29
|
const rankIn = (config, key) => {
|
|
28
30
|
const i = Object.keys(config).indexOf(key);
|
|
@@ -53,7 +55,24 @@ function ChartContainer({ config, summary, height = 240, children, className })
|
|
|
53
55
|
const value = React.useMemo(() => ({ config, announce: setAnnouncement, root }), [config]);
|
|
54
56
|
const keys = Object.keys(config);
|
|
55
57
|
const css = keys.map((key) => `--color-${safe(key)}: ${config[key].color}; --fade-${safe(key)}: url(#${id}-fade-${safe(key)});`).join(" ");
|
|
56
|
-
|
|
58
|
+
// Recharts moves the tooltip with ← → and shows or hides it with Enter. Home and End jump to the first or
|
|
59
|
+
// last point by pressing ← or → until it stops (Recharts ignores a press past the end); Esc hides the tooltip.
|
|
60
|
+
const onKeyDown = (e) => {
|
|
61
|
+
const surface = e.target;
|
|
62
|
+
if (!surface.classList?.contains("recharts-surface"))
|
|
63
|
+
return;
|
|
64
|
+
const press = (key) => surface.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true }));
|
|
65
|
+
if (e.key === "Home" || e.key === "End") {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
for (let i = 0; i < MAX_POINTS; i++)
|
|
68
|
+
press(e.key === "Home" ? "ArrowLeft" : "ArrowRight");
|
|
69
|
+
}
|
|
70
|
+
else if (e.key === "Escape" && announcement) {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
press("Enter");
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return (_jsx(ChartContext.Provider, { value: value, children: _jsxs("div", { ref: root, "data-slot": "chart", "data-chart": id, role: "figure", "aria-label": summary, className: cn(CHART_STYLES, className), style: { height }, onKeyDown: onKeyDown, children: [_jsx("style", { children: `[data-chart="${id}"] { ${css} }` }), _jsx("svg", { "aria-hidden": "true", width: "0", height: "0", className: "absolute", children: _jsx("defs", { children: keys.map((key) => (_jsxs("linearGradient", { id: `${id}-fade-${safe(key)}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "0%", stopColor: `var(--color-${safe(key)})`, stopOpacity: 0.3 }), _jsx("stop", { offset: "100%", stopColor: `var(--color-${safe(key)})`, stopOpacity: 0 })] }, key))) }) }), _jsx(Recharts.ResponsiveContainer, { width: "100%", height: "100%", initialDimension: { width: 320, height }, children: children }), _jsx("div", { "aria-live": "polite", className: "sr-only", children: announcement })] }) }));
|
|
57
76
|
}
|
|
58
77
|
/** Horizontal rules only. */
|
|
59
78
|
function ChartGrid(props) {
|
package/package.json
CHANGED