@momoi-labs/kiso-react 0.19.0 → 0.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/dist/chart-sync.d.ts +12 -0
- package/dist/chart-sync.js +48 -0
- package/dist/chart.d.ts +1 -1
- package/dist/chart.js +111 -16
- package/package.json +2 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ChartSyncState = {
|
|
2
|
+
/** The inspected timestamp and the Chart that inspects it. */
|
|
3
|
+
hover: number | null;
|
|
4
|
+
source: object | null;
|
|
5
|
+
/** A timestamp a click, Enter or Space keeps marked across the group. */
|
|
6
|
+
pinned: number | null;
|
|
7
|
+
};
|
|
8
|
+
export declare function setChartHover(id: string, source: object, timestamp: number | null): void;
|
|
9
|
+
export declare function toggleChartPin(id: string, timestamp: number): void;
|
|
10
|
+
export declare function clearChartPin(id: string): void;
|
|
11
|
+
export declare function chartPinned(id: string): number | null;
|
|
12
|
+
export declare function useChartSync(id: string): ChartSyncState;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
const groups = new Map();
|
|
4
|
+
const idle = { hover: null, source: null, pinned: null };
|
|
5
|
+
function group(id) {
|
|
6
|
+
let found = groups.get(id);
|
|
7
|
+
if (!found)
|
|
8
|
+
groups.set(id, found = { state: idle, listeners: new Set() });
|
|
9
|
+
return found;
|
|
10
|
+
}
|
|
11
|
+
function update(id, next) {
|
|
12
|
+
const found = group(id);
|
|
13
|
+
const state = next(found.state);
|
|
14
|
+
if (state === found.state)
|
|
15
|
+
return;
|
|
16
|
+
found.state = state;
|
|
17
|
+
found.listeners.forEach(listener => listener());
|
|
18
|
+
}
|
|
19
|
+
export function setChartHover(id, source, timestamp) {
|
|
20
|
+
update(id, state => timestamp === null
|
|
21
|
+
? state.source === source ? { ...state, hover: null, source: null } : state
|
|
22
|
+
: state.source === source && state.hover === timestamp ? state : { ...state, hover: timestamp, source });
|
|
23
|
+
}
|
|
24
|
+
/* A click while a timestamp is pinned clears it, so the same gesture undoes
|
|
25
|
+
itself without aiming at the same sample again. */
|
|
26
|
+
export function toggleChartPin(id, timestamp) {
|
|
27
|
+
update(id, state => ({ ...state, pinned: state.pinned === null ? timestamp : null }));
|
|
28
|
+
}
|
|
29
|
+
export function clearChartPin(id) {
|
|
30
|
+
update(id, state => state.pinned === null ? state : { ...state, pinned: null });
|
|
31
|
+
}
|
|
32
|
+
export function chartPinned(id) {
|
|
33
|
+
return groups.get(id)?.state.pinned ?? null;
|
|
34
|
+
}
|
|
35
|
+
export function useChartSync(id) {
|
|
36
|
+
const subscribe = React.useCallback((listener) => {
|
|
37
|
+
const found = group(id);
|
|
38
|
+
found.listeners.add(listener);
|
|
39
|
+
return () => {
|
|
40
|
+
found.listeners.delete(listener);
|
|
41
|
+
// A group that no Chart shows forgets its pin.
|
|
42
|
+
if (!found.listeners.size && groups.get(id) === found)
|
|
43
|
+
groups.delete(id);
|
|
44
|
+
};
|
|
45
|
+
}, [id]);
|
|
46
|
+
const snapshot = React.useCallback(() => groups.get(id)?.state ?? idle, [id]);
|
|
47
|
+
return React.useSyncExternalStore(subscribe, snapshot, () => idle);
|
|
48
|
+
}
|
package/dist/chart.d.ts
CHANGED
|
@@ -28,4 +28,4 @@ export type ChartProps = Omit<React.ComponentProps<"figure">, "children"> & {
|
|
|
28
28
|
timestamp to another. TimeRangeControl stays the keyboard and touch path. */
|
|
29
29
|
onRangeSelect?: (range: TimeRange) => void;
|
|
30
30
|
} & ChartTreatmentProps;
|
|
31
|
-
export declare function Chart({ data, series, label, variant, layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime, formatValue, min, max, onRangeSelect, chartStyle, chartLine, chartFill, ref, className, ...props }: ChartProps): React.JSX.Element;
|
|
31
|
+
export declare function Chart({ data, series, label, variant, layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime, formatValue, min, max, onRangeSelect, chartStyle, chartLine, chartFill, ref, className, onKeyDown, ...props }: ChartProps): React.JSX.Element;
|
package/dist/chart.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { clsx as cn } from "clsx";
|
|
5
|
-
import {
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
import { Area, CartesianGrid, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis, usePlotArea, useXAxisInverseDataSnapScale, useXAxisScale, useYAxisScale } from "recharts";
|
|
6
7
|
import { ChartLegend, ChartSeriesLabel } from "./chart-legend.js";
|
|
7
8
|
import { ChartDot, ChartPattern, pixelCurve, useChartPresentation, useChartStyle } from "./chart-style.js";
|
|
8
9
|
import { useChartFill } from "./chart-fill.js";
|
|
10
|
+
import { chartPinned, clearChartPin, setChartHover, toggleChartPin, useChartSync } from "./chart-sync.js";
|
|
9
11
|
import { chartColor, chartSlot, formatChartTime, formatChartValue, measured, validateChart } from "./chart-data.js";
|
|
10
|
-
export function Chart({ data, series, label, variant = "line", layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime = formatChartTime, formatValue = formatChartValue, min, max, onRangeSelect, chartStyle, chartLine, chartFill, ref, className, ...props }) {
|
|
12
|
+
export function Chart({ data, series, label, variant = "line", layout: layoutProp, legend: legendProp, summary, highlightSeries, onHighlightSeriesChange, height: heightProp, syncId, formatTime = formatChartTime, formatValue = formatChartValue, min, max, onRangeSelect, chartStyle, chartLine, chartFill, ref, className, onKeyDown, ...props }) {
|
|
11
13
|
const id = React.useId();
|
|
12
14
|
const frame = React.useRef(null);
|
|
13
15
|
const { line, fill } = useChartStyle(frame, { chartStyle, chartLine, chartFill });
|
|
@@ -21,7 +23,18 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
21
23
|
const height = heightProp ?? expanded.height ?? defaultHeight;
|
|
22
24
|
const bold = line === "stepped" || line === "curved";
|
|
23
25
|
const [localHighlight, setLocalHighlight] = React.useState(null);
|
|
24
|
-
|
|
26
|
+
// Charts with the same syncId share the inspected and pinned timestamps
|
|
27
|
+
// through a Kiso store, not Recharts' syncId. An expanded Chart, or one
|
|
28
|
+
// without a syncId, keeps a group of its own.
|
|
29
|
+
const group = (expanded.fill ? undefined : syncId) ?? id;
|
|
30
|
+
const [source] = React.useState(() => ({}));
|
|
31
|
+
const inspected = React.useRef(null);
|
|
32
|
+
const pick = React.useRef(null);
|
|
33
|
+
const inspect = React.useCallback((timestamp) => {
|
|
34
|
+
inspected.current = timestamp;
|
|
35
|
+
setChartHover(group, source, timestamp);
|
|
36
|
+
}, [group, source]);
|
|
37
|
+
React.useEffect(() => () => setChartHover(group, source, null), [group, source]);
|
|
25
38
|
// A drag moves the band in the DOM. Rendering the Chart on every pointer
|
|
26
39
|
// move is far too slow for a stack of many series.
|
|
27
40
|
const drag = React.useRef(null);
|
|
@@ -72,10 +85,19 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
72
85
|
}
|
|
73
86
|
const sampleAt = (index) => typeof index === "number" ? plot[index]?.timestamp
|
|
74
87
|
: typeof index === "string" && index !== "" ? plot[Number(index)]?.timestamp : undefined;
|
|
75
|
-
const
|
|
88
|
+
const selectRange = onRangeSelect && plot.length > 1 ? onRangeSelect : undefined;
|
|
89
|
+
// A press that ends on the same sample is a click and pins that timestamp.
|
|
90
|
+
// A press that moves to another sample is a drag and selects a range.
|
|
91
|
+
const pointerHandlers = {
|
|
76
92
|
onMouseDown: (state, event) => {
|
|
77
|
-
const
|
|
78
|
-
|
|
93
|
+
const mouse = event;
|
|
94
|
+
// A tap, or a click right after the pointer arrives, comes before
|
|
95
|
+
// Recharts reads the pointer, so find the sample under it here.
|
|
96
|
+
const active = sampleAt(state.activeTooltipIndex);
|
|
97
|
+
const picked = active === undefined && mouse.currentTarget instanceof Element
|
|
98
|
+
? pick.current?.(mouse.clientX - mouse.currentTarget.getBoundingClientRect().left) : undefined;
|
|
99
|
+
const at = active ?? picked?.at, x = picked ? picked.x : state.activeCoordinate?.x;
|
|
100
|
+
if (at === undefined || x === undefined || mouse.button !== 0)
|
|
79
101
|
return;
|
|
80
102
|
stopDrag.current?.();
|
|
81
103
|
drag.current = { from: at, to: at, x1: x, x2: x };
|
|
@@ -83,8 +105,12 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
83
105
|
const end = () => {
|
|
84
106
|
const range = drag.current;
|
|
85
107
|
stop();
|
|
86
|
-
if (range
|
|
87
|
-
|
|
108
|
+
if (!range)
|
|
109
|
+
return;
|
|
110
|
+
if (range.from === range.to)
|
|
111
|
+
toggleChartPin(group, range.from);
|
|
112
|
+
else
|
|
113
|
+
selectRange?.({ from: Math.min(range.from, range.to), to: Math.max(range.from, range.to) });
|
|
88
114
|
};
|
|
89
115
|
const cancel = (key) => { if (key.key === "Escape") {
|
|
90
116
|
key.preventDefault();
|
|
@@ -106,11 +132,12 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
106
132
|
if (!drag.current || at === undefined || x === undefined || at === drag.current.to)
|
|
107
133
|
return;
|
|
108
134
|
drag.current = { ...drag.current, to: at, x2: x };
|
|
109
|
-
|
|
135
|
+
if (selectRange)
|
|
136
|
+
paintDrag();
|
|
110
137
|
},
|
|
111
|
-
}
|
|
112
|
-
const renderPlot = (indices, lane) => _jsxs("div", { className: "chart-plot", style: { height }, "data-range-select":
|
|
113
|
-
: [min ?? (variant === "stacked-area" ? 0 : "auto"), max ?? "auto"], tickCount: 3, axisLine: false, tickLine: false, tickFormatter: formatValue, tick: { fill: "var(--color-muted-foreground)" }, width: 56 }), _jsx(Tooltip, { filterNull: false, isAnimationActive: false, cursor: { stroke: "var(--color-border-strong)", strokeDasharray: "3 3" }, content: ({ active, label: timestamp }) => _jsx(ChartReadout, { active: active, timestamp: Number(timestamp), data: data, series: series, formatTime: formatTime, displayValue: displayValue, sidebar: legend === "sidebar", onInspect:
|
|
138
|
+
};
|
|
139
|
+
const renderPlot = (indices, lane) => _jsxs("div", { className: "chart-plot", style: { height }, "data-range-select": selectRange ? "" : undefined, children: [_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: plot, syncId: layout === "split" ? id : undefined, syncMethod: "value", accessibilityLayer: true, "aria-label": lane ? `${label}: ${lane.label}` : label, "aria-describedby": `${id}-help`, margin: { top: 8, right: 20, bottom: 0, left: 0 }, ...pointerHandlers, children: [_jsx("defs", { children: indices.map(index => _jsx(ChartPattern, { id: `${id}-fill-${index}`, color: chartColor(chartSlot(series[index], index)), fill: fill }, series[index].key)) }), _jsx(CartesianGrid, { vertical: false, stroke: "var(--color-border)", strokeWidth: 0.5 }), _jsx(XAxis, { dataKey: "timestamp", type: "number", domain: ["dataMin", "dataMax"], scale: "time", axisLine: false, tickLine: false, tickFormatter: formatTime, minTickGap: 48, tick: { fill: "var(--color-muted-foreground)" } }), _jsx(YAxis, { domain: layout === "split" ? [splitMin, splitMax]
|
|
140
|
+
: [min ?? (variant === "stacked-area" ? 0 : "auto"), max ?? "auto"], tickCount: 3, axisLine: false, tickLine: false, tickFormatter: formatValue, tick: { fill: "var(--color-muted-foreground)" }, width: 56 }), _jsx(Tooltip, { filterNull: false, isAnimationActive: false, cursor: { stroke: "var(--color-border-strong)", strokeDasharray: "3 3" }, content: ({ active, label: timestamp }) => _jsx(ChartReadout, { active: active, timestamp: Number(timestamp), data: data, series: series, formatTime: formatTime, displayValue: displayValue, sidebar: legend === "sidebar", onInspect: !lane || indices[0] === 0 ? inspect : undefined }) }), indices.map(index => {
|
|
114
141
|
const item = series[index];
|
|
115
142
|
const slot = chartSlot(item, index);
|
|
116
143
|
const dimmed = highlighted !== null && item.key !== highlighted;
|
|
@@ -131,15 +158,33 @@ export function Chart({ data, series, label, variant = "line", layout: layoutPro
|
|
|
131
158
|
return variant === "stacked-area" || fill !== "none"
|
|
132
159
|
? _jsx(Area, { ...common, type: curve, stackId: variant === "stacked-area" ? "total" : undefined, fill: textured ? `url(#${id}-fill-${index})` : chartColor(slot), fillOpacity: dimmed ? 0.06 : 0.2 }, item.key)
|
|
133
160
|
: _jsx(Line, { ...common, type: curve }, item.key);
|
|
134
|
-
})] }) }),
|
|
135
|
-
const
|
|
161
|
+
}), _jsx(ChartSyncMarker, { group: group, source: source, plot: plot, data: data, series: series, indices: indices, stacked: variant === "stacked-area", line: line, highlighted: highlighted, pick: !lane || indices[0] === 0 ? pick : undefined, readout: legend !== "sidebar" && (!lane || indices[0] === 0), formatTime: formatTime, displayValue: displayValue })] }) }), selectRange && _jsx("div", { className: "chart-range-band", hidden: true, "aria-hidden": "true" })] });
|
|
162
|
+
const legendProps = { data, series, label: `${label}: summary`, variant: legend, summary, formatValue, formatTime,
|
|
163
|
+
highlightSeries: highlighted, onHighlightSeriesChange: highlight };
|
|
164
|
+
// Only a sidebar follows the inspected timestamp, so only it subscribes.
|
|
165
|
+
const legendContent = legend === "sidebar"
|
|
166
|
+
? _jsx(ChartSidebarLegend, { group: group, ...legendProps })
|
|
167
|
+
: _jsx(ChartLegend, { ...legendProps });
|
|
136
168
|
return _jsxs("figure", { ...props, ref: element => {
|
|
137
169
|
frame.current = element;
|
|
138
170
|
if (typeof ref === "function")
|
|
139
171
|
return ref(element);
|
|
140
172
|
if (ref)
|
|
141
173
|
ref.current = element;
|
|
142
|
-
}, "data-slot": "chart", "data-layout": layout, "data-legend": legend, "data-line": line, "data-fill": fill, className: cn("framed-chart", className), "aria-labelledby": `${id}-title`,
|
|
174
|
+
}, "data-slot": "chart", "data-layout": layout, "data-legend": legend, "data-line": line, "data-fill": fill, className: cn("framed-chart", className), "aria-labelledby": `${id}-title`, onKeyDown: event => {
|
|
175
|
+
onKeyDown?.(event);
|
|
176
|
+
if (event.defaultPrevented || drag.current)
|
|
177
|
+
return;
|
|
178
|
+
if (event.key === "Escape" && chartPinned(group) !== null) {
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
clearChartPin(group);
|
|
181
|
+
}
|
|
182
|
+
else if ((event.key === "Enter" || event.key === " ") && inspected.current !== null
|
|
183
|
+
&& event.target instanceof Element && event.target.closest(".chart-plot")) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
toggleChartPin(group, inspected.current);
|
|
186
|
+
}
|
|
187
|
+
}, children: [_jsx("figcaption", { id: `${id}-title`, className: "t-h3", children: label }), _jsx("p", { id: `${id}-help`, className: "chart-help", children: "Focus the chart and use Left and Right to inspect samples. Press Enter to mark the inspected sample in every synchronized chart, and Escape to clear it. Select a series in the legend to highlight it. Exact values are available below." }), _jsxs("div", { className: "chart-body", children: [_jsx("div", { className: "chart-plots", children: hasData ? layout === "split" ? series.map((item, index) => _jsxs("div", { className: "chart-lane", children: [_jsxs("div", { className: "chart-lane-heading", children: [_jsx(ChartSeriesLabel, { series: item, index: index }), _jsx("span", { children: displayValue(data.at(-1)?.values[item.key]) })] }), renderPlot([index], item)] }, item.key)) : renderPlot(series.map((_, index) => index))
|
|
143
188
|
: _jsx("div", { className: "chart-empty hatch", style: { minHeight: height }, children: "No collected samples in this window." }) }), legend === "sidebar" && legendContent] }), legend !== "sidebar" && legendContent, _jsxs("details", { className: "disclosure chart-values", children: [_jsx("summary", { children: "View exact values" }), _jsx("div", { className: "chart-table-scroll", children: _jsxs("table", { className: "chart-table", children: [_jsxs("caption", { children: [label, ": collected samples, timestamps in UTC"] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "Timestamp" }), series.map(item => _jsx("th", { scope: "col", children: item.label }, item.key))] }) }), _jsx("tbody", { children: data.map(sample => _jsxs("tr", { children: [_jsx("th", { scope: "row", children: formatChartTime(sample.timestamp) }), series.map(item => _jsx("td", { children: measured(sample.values[item.key]) ? String(sample.values[item.key]) : "Not collected" }, item.key))] }, sample.timestamp)) })] }) })] })] });
|
|
144
189
|
}
|
|
145
190
|
// Observe Recharts' synchronized tooltip state after render. This keeps the
|
|
@@ -150,5 +195,55 @@ function ChartReadout({ active, timestamp, data, series, formatTime, displayValu
|
|
|
150
195
|
React.useEffect(() => { onInspect?.(inspectedTimestamp); }, [onInspect, inspectedTimestamp]);
|
|
151
196
|
if (!sample || sidebar)
|
|
152
197
|
return null;
|
|
153
|
-
return
|
|
198
|
+
return _jsx(ChartInspection, { role: "status", sample: sample, series: series, formatTime: formatTime, displayValue: displayValue });
|
|
199
|
+
}
|
|
200
|
+
function ChartInspection({ sample, series, formatTime, displayValue, className, ...props }) {
|
|
201
|
+
return _jsxs("div", { ...props, className: cn("chart-inspection", className), children: [_jsx("strong", { children: formatTime(sample.timestamp) }), _jsx("dl", { children: series.map((item, index) => _jsxs(React.Fragment, { children: [_jsx("dt", { children: _jsx(ChartSeriesLabel, { series: item, index: index }) }), _jsx("dd", { children: displayValue(sample.values[item.key]) })] }, item.key)) })] });
|
|
202
|
+
}
|
|
203
|
+
// The other Charts of a group mark the inspected timestamp with a line and
|
|
204
|
+
// dots, and a pinned timestamp with a solid line and its values. This
|
|
205
|
+
// subtree alone renders on hover; the plot, legend, and tables do not.
|
|
206
|
+
function ChartSyncMarker({ group, source, plot, data, series, indices, stacked, line, highlighted, pick, readout, formatTime, displayValue }) {
|
|
207
|
+
const { hover, source: hovering, pinned } = useChartSync(group);
|
|
208
|
+
const xScale = useXAxisScale(), yScale = useYAxisScale(), area = usePlotArea(), snap = useXAxisInverseDataSnapScale();
|
|
209
|
+
React.useLayoutEffect(() => {
|
|
210
|
+
if (!pick)
|
|
211
|
+
return;
|
|
212
|
+
pick.current = x => {
|
|
213
|
+
const at = area && x >= area.x && x <= area.x + area.width ? snap?.(x) : undefined;
|
|
214
|
+
const snapped = typeof at === "number" ? xScale?.(at) : undefined;
|
|
215
|
+
return typeof at === "number" && snapped !== undefined ? { at, x: snapped } : undefined;
|
|
216
|
+
};
|
|
217
|
+
}, [pick, area, snap, xScale]);
|
|
218
|
+
const mark = React.useRef(null);
|
|
219
|
+
const [layer, setLayer] = React.useState(null);
|
|
220
|
+
React.useLayoutEffect(() => setLayer(mark.current?.closest(".chart-plot") ?? null), []);
|
|
221
|
+
const place = (timestamp) => {
|
|
222
|
+
if (timestamp === null || !xScale || !area)
|
|
223
|
+
return undefined;
|
|
224
|
+
const sample = plot.find(item => item.timestamp === timestamp);
|
|
225
|
+
const x = sample && xScale(timestamp);
|
|
226
|
+
return sample && x !== undefined && Number.isFinite(x) ? { sample, x } : undefined;
|
|
227
|
+
};
|
|
228
|
+
const drawn = place(hovering === source ? null : hover), held = place(pinned);
|
|
229
|
+
const marker = (at, dash) => _jsxs("g", { children: [_jsx("line", { x1: at.x, x2: at.x, y1: area.y, y2: area.y + area.height, stroke: "var(--color-border-strong)", strokeWidth: dash ? 1 : 1.5, strokeDasharray: dash }), yScale && indices.map(index => {
|
|
230
|
+
const value = at.sample.values[index];
|
|
231
|
+
if (!measured(value))
|
|
232
|
+
return null;
|
|
233
|
+
const total = stacked ? at.sample.values.slice(0, index + 1).reduce((sum, item) => sum + (item ?? 0), 0) : value;
|
|
234
|
+
const y = yScale(total);
|
|
235
|
+
const item = series[index];
|
|
236
|
+
return y === undefined ? null : _jsx(ChartDot, { cx: at.x, cy: y, line: line, fill: chartColor(chartSlot(item, index)), opacity: highlighted !== null && item.key !== highlighted ? 0.3 : 1 }, item.key);
|
|
237
|
+
})] });
|
|
238
|
+
// The hovered Chart shows its own readout, so its pinned one steps aside.
|
|
239
|
+
const pinnedSample = readout && held && !(hovering === source && hover !== null)
|
|
240
|
+
? data.find(item => item.timestamp === held.sample.timestamp) : undefined;
|
|
241
|
+
const flip = held && area ? held.x > area.x + area.width / 2 : false;
|
|
242
|
+
return _jsxs("g", { ref: mark, className: "chart-sync-marker", pointerEvents: "none", children: [held && marker(held), drawn && marker(drawn, "3 3"), layer && pinnedSample && held && area && createPortal(_jsx(ChartInspection, { className: "chart-pin-readout", sample: pinnedSample, series: series, formatTime: formatTime, displayValue: displayValue, style: { top: area.y, left: flip ? held.x - 12 : held.x + 12, translate: flip ? "-100%" : undefined } }), layer)] });
|
|
243
|
+
}
|
|
244
|
+
function ChartSidebarLegend({ group, data, ...props }) {
|
|
245
|
+
const { hover, pinned } = useChartSync(group);
|
|
246
|
+
const activeTimestamp = [hover, pinned].find(timestamp => timestamp !== null
|
|
247
|
+
&& data.some(sample => sample.timestamp === timestamp)) ?? null;
|
|
248
|
+
return _jsx(ChartLegend, { ...props, data: data, activeTimestamp: activeTimestamp });
|
|
154
249
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momoi-labs/kiso-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Kiso React components built with shadcn/ui and Radix",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepack": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@momoi-labs/kiso": "^0.
|
|
35
|
+
"@momoi-labs/kiso": "^0.25.0",
|
|
36
36
|
"class-variance-authority": "0.7.1",
|
|
37
37
|
"clsx": "2.1.1",
|
|
38
38
|
"radix-ui": "1.6.7",
|