@expcat/tigercat-react 0.1.8 → 0.2.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/{chunk-TBIEWDY5.js → chunk-36RRHNZD.js} +13 -2
- package/dist/chunk-3CDAG4HD.mjs +151 -0
- package/dist/chunk-3QFHVAZT.js +68 -0
- package/dist/{chunk-ALP3KYYY.mjs → chunk-3XKBDV2Q.mjs} +5 -5
- package/dist/chunk-42UKIFFQ.js +278 -0
- package/dist/{chunk-K7ZMB2TH.mjs → chunk-5XKYWZZZ.mjs} +16 -22
- package/dist/chunk-677VSTPW.mjs +65 -0
- package/dist/chunk-6DYS4PJT.mjs +99 -0
- package/dist/chunk-6PBNFLM7.js +95 -0
- package/dist/{chunk-DCRVIDMY.mjs → chunk-6ZC7H22S.mjs} +1 -1
- package/dist/{chunk-WSCSDSV7.mjs → chunk-7IKJBQQV.mjs} +27 -5
- package/dist/{chunk-OTRGVENC.js → chunk-7SLNHUGJ.js} +1 -1
- package/dist/chunk-A2UW5OKX.mjs +415 -0
- package/dist/{chunk-NOOPXNR4.mjs → chunk-AGUPZEUL.mjs} +2 -3
- package/dist/chunk-AX5XRD2Q.js +35 -0
- package/dist/{chunk-BJU5N7WU.mjs → chunk-BAPR7UUR.mjs} +7 -7
- package/dist/chunk-CBALIFPW.mjs +275 -0
- package/dist/{chunk-BIWO5KB4.mjs → chunk-CJJ56NVL.mjs} +2 -2
- package/dist/{chunk-ENR3RIMM.js → chunk-DGBYGBLR.js} +72 -59
- package/dist/chunk-DUWAV47E.js +42 -0
- package/dist/chunk-E5GD3H7L.js +94 -0
- package/dist/chunk-EJLJYOO7.js +367 -0
- package/dist/{chunk-FQ6UHRAO.js → chunk-GQMYCYZ4.js} +6 -27
- package/dist/{chunk-G6FSHN2I.mjs → chunk-GW4EWT2K.mjs} +45 -31
- package/dist/{chunk-AQQRWISY.js → chunk-GXTBCX3M.js} +1 -1
- package/dist/{chunk-HQXZVTP4.mjs → chunk-HGF2EL25.mjs} +74 -61
- package/dist/{chunk-R5BQHZWB.js → chunk-HRYBEBZC.js} +15 -21
- package/dist/{chunk-PAD2DX5M.mjs → chunk-IIVRVCCP.mjs} +6 -24
- package/dist/chunk-IS467WAO.mjs +39 -0
- package/dist/{chunk-CTAMMQBC.mjs → chunk-IS7YOBR7.mjs} +16 -13
- package/dist/{chunk-ADOPAXPG.mjs → chunk-JI7SFMUT.mjs} +2 -2
- package/dist/chunk-KBGURVTD.mjs +282 -0
- package/dist/{chunk-O3EUFIOS.mjs → chunk-KELLYJZY.mjs} +36 -30
- package/dist/{chunk-XZDJ5FRB.js → chunk-KPZTGRNA.js} +5 -23
- package/dist/chunk-KQZ4F7FZ.js +153 -0
- package/dist/{chunk-XDKXL2BP.mjs → chunk-KV4LLPAY.mjs} +14 -3
- package/dist/{chunk-LNKI6HQ3.js → chunk-LIJLFLYE.js} +27 -5
- package/dist/chunk-LVC43YX2.mjs +72 -0
- package/dist/chunk-LZNG2HGC.mjs +227 -0
- package/dist/chunk-M375I56K.js +75 -0
- package/dist/{chunk-7OLWGHUR.mjs → chunk-MF3H7WWW.mjs} +13 -2
- package/dist/chunk-N32MAX4A.js +230 -0
- package/dist/{chunk-YYKJ63LD.mjs → chunk-NMDNLB3C.mjs} +7 -28
- package/dist/{chunk-77D7VQMG.js → chunk-OD2NNQD2.js} +2 -2
- package/dist/chunk-OONM7FO7.js +418 -0
- package/dist/{chunk-Q5Q7FG4U.js → chunk-OZLGNWET.js} +7 -7
- package/dist/{chunk-LAZGEMA2.mjs → chunk-P4EFJIXU.mjs} +1 -1
- package/dist/chunk-QI6WAP6Y.js +285 -0
- package/dist/{chunk-WK5HN4OH.js → chunk-QY6I7LU5.js} +43 -29
- package/dist/{chunk-KSW5JDIV.js → chunk-R7TOQU3U.js} +1 -1
- package/dist/chunk-RQSQXQN6.mjs +91 -0
- package/dist/chunk-SDLMB34Y.mjs +32 -0
- package/dist/chunk-UG3I4PCY.js +102 -0
- package/dist/chunk-VBSK4TGO.mjs +364 -0
- package/dist/{chunk-DZJUFU55.js → chunk-VXHBQTZS.js} +14 -11
- package/dist/chunk-WLIFEALE.mjs +111 -0
- package/dist/{chunk-AQ6DHCP6.js → chunk-XRFK2IXM.js} +4 -4
- package/dist/{chunk-5FRENLDC.js → chunk-Y2JOJ4D6.js} +14 -3
- package/dist/chunk-YER7IQF4.mjs +429 -0
- package/dist/{chunk-NI2WNZRT.js → chunk-YESS6YKC.js} +1 -2
- package/dist/chunk-Z6F67MJE.mjs +92 -0
- package/dist/{chunk-QORSSZX4.js → chunk-ZPFZMXA6.js} +34 -28
- package/dist/chunk-ZUUG3WOL.js +432 -0
- package/dist/chunk-ZYPEO2KY.js +115 -0
- package/dist/components/AreaChart.d.mts +19 -0
- package/dist/components/AreaChart.d.ts +19 -0
- package/dist/components/AreaChart.js +23 -0
- package/dist/components/AreaChart.mjs +8 -0
- package/dist/components/BarChart.d.mts +16 -0
- package/dist/components/BarChart.d.ts +16 -0
- package/dist/components/BarChart.js +23 -0
- package/dist/components/BarChart.mjs +8 -0
- package/dist/components/ChartAxis.d.mts +10 -0
- package/dist/components/ChartAxis.d.ts +10 -0
- package/dist/components/ChartAxis.js +16 -0
- package/dist/components/ChartAxis.mjs +1 -0
- package/dist/components/ChartCanvas.d.mts +9 -0
- package/dist/components/ChartCanvas.d.ts +9 -0
- package/dist/components/ChartCanvas.js +16 -0
- package/dist/components/ChartCanvas.mjs +1 -0
- package/dist/components/ChartGrid.d.mts +11 -0
- package/dist/components/ChartGrid.d.ts +11 -0
- package/dist/components/ChartGrid.js +16 -0
- package/dist/components/ChartGrid.mjs +1 -0
- package/dist/components/ChartLegend.d.mts +17 -0
- package/dist/components/ChartLegend.d.ts +17 -0
- package/dist/components/ChartLegend.js +16 -0
- package/dist/components/ChartLegend.mjs +1 -0
- package/dist/components/ChartSeries.d.mts +18 -0
- package/dist/components/ChartSeries.d.ts +18 -0
- package/dist/components/ChartSeries.js +16 -0
- package/dist/components/ChartSeries.mjs +1 -0
- package/dist/components/ChartTooltip.d.mts +12 -0
- package/dist/components/ChartTooltip.d.ts +12 -0
- package/dist/components/ChartTooltip.js +16 -0
- package/dist/components/ChartTooltip.mjs +1 -0
- package/dist/components/DonutChart.d.mts +14 -0
- package/dist/components/DonutChart.d.ts +14 -0
- package/dist/components/DonutChart.js +21 -0
- package/dist/components/DonutChart.mjs +6 -0
- package/dist/components/Drawer.js +3 -3
- package/dist/components/Drawer.mjs +2 -2
- package/dist/components/Dropdown.d.mts +12 -2
- package/dist/components/Dropdown.d.ts +12 -2
- package/dist/components/Dropdown.js +4 -4
- package/dist/components/Dropdown.mjs +2 -2
- package/dist/components/DropdownItem.js +4 -4
- package/dist/components/DropdownItem.mjs +3 -3
- package/dist/components/Icon.js +2 -2
- package/dist/components/Icon.mjs +1 -1
- package/dist/components/LineChart.d.mts +19 -0
- package/dist/components/LineChart.d.ts +19 -0
- package/dist/components/LineChart.js +23 -0
- package/dist/components/LineChart.mjs +8 -0
- package/dist/components/List.js +3 -3
- package/dist/components/List.mjs +2 -2
- package/dist/components/Message.js +4 -4
- package/dist/components/Message.mjs +1 -1
- package/dist/components/Modal.js +3 -3
- package/dist/components/Modal.mjs +2 -2
- package/dist/components/Notification.js +4 -4
- package/dist/components/Notification.mjs +1 -1
- package/dist/components/Pagination.d.mts +5 -1
- package/dist/components/Pagination.d.ts +5 -1
- package/dist/components/Pagination.js +3 -3
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/PieChart.d.mts +14 -0
- package/dist/components/PieChart.d.ts +14 -0
- package/dist/components/PieChart.js +20 -0
- package/dist/components/PieChart.mjs +5 -0
- package/dist/components/Popconfirm.d.mts +12 -2
- package/dist/components/Popconfirm.d.ts +12 -2
- package/dist/components/Popconfirm.js +3 -2
- package/dist/components/Popconfirm.mjs +2 -1
- package/dist/components/Popover.d.mts +12 -2
- package/dist/components/Popover.d.ts +12 -2
- package/dist/components/Popover.js +3 -2
- package/dist/components/Popover.mjs +2 -1
- package/dist/components/RadarChart.d.mts +20 -0
- package/dist/components/RadarChart.d.ts +20 -0
- package/dist/components/RadarChart.js +20 -0
- package/dist/components/RadarChart.mjs +5 -0
- package/dist/components/ScatterChart.d.mts +32 -0
- package/dist/components/ScatterChart.d.ts +32 -0
- package/dist/components/ScatterChart.js +23 -0
- package/dist/components/ScatterChart.mjs +8 -0
- package/dist/components/Select.js +2 -2
- package/dist/components/Select.mjs +1 -1
- package/dist/components/Slider.js +2 -2
- package/dist/components/Slider.mjs +1 -1
- package/dist/components/Space.js +2 -2
- package/dist/components/Space.mjs +1 -1
- package/dist/components/Steps.js +3 -3
- package/dist/components/Steps.mjs +1 -1
- package/dist/components/StepsItem.js +2 -2
- package/dist/components/StepsItem.mjs +1 -1
- package/dist/components/Table.js +2 -2
- package/dist/components/Table.mjs +1 -1
- package/dist/components/Tooltip.d.mts +12 -2
- package/dist/components/Tooltip.d.ts +12 -2
- package/dist/components/Tooltip.js +3 -2
- package/dist/components/Tooltip.mjs +2 -1
- package/dist/index.d.mts +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.js +178 -108
- package/dist/index.mjs +41 -27
- package/package.json +2 -2
- package/dist/chunk-NEULKOYJ.js +0 -48
- package/dist/chunk-ZO4XVOHU.mjs +0 -45
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { useChartInteraction } from './chunk-3CDAG4HD.mjs';
|
|
2
|
+
import { ChartAxis } from './chunk-RQSQXQN6.mjs';
|
|
3
|
+
import { ChartCanvas } from './chunk-IS467WAO.mjs';
|
|
4
|
+
import { ChartGrid } from './chunk-677VSTPW.mjs';
|
|
5
|
+
import { ChartLegend } from './chunk-Z6F67MJE.mjs';
|
|
6
|
+
import { ChartSeries } from './chunk-SDLMB34Y.mjs';
|
|
7
|
+
import { ChartTooltip } from './chunk-LVC43YX2.mjs';
|
|
8
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
9
|
+
import { getChartInnerRect, getNumberExtent, createLinearScale, createPointScale, DEFAULT_CHART_COLORS, createLinePath, getChartElementOpacity, classNames } from '@expcat/tigercat-core';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
var LineChart = ({
|
|
13
|
+
width = 320,
|
|
14
|
+
height = 200,
|
|
15
|
+
padding = 24,
|
|
16
|
+
data,
|
|
17
|
+
series,
|
|
18
|
+
xScale: xScaleProp,
|
|
19
|
+
yScale: yScaleProp,
|
|
20
|
+
lineColor: _lineColor = "var(--tiger-primary,#2563eb)",
|
|
21
|
+
strokeWidth = 2,
|
|
22
|
+
curve = "linear",
|
|
23
|
+
showPoints = true,
|
|
24
|
+
pointSize = 4,
|
|
25
|
+
pointColor: _pointColor,
|
|
26
|
+
showGrid = true,
|
|
27
|
+
showAxis = true,
|
|
28
|
+
showXAxis = true,
|
|
29
|
+
showYAxis = true,
|
|
30
|
+
includeZero = false,
|
|
31
|
+
xAxisLabel,
|
|
32
|
+
yAxisLabel,
|
|
33
|
+
xTicks = 5,
|
|
34
|
+
yTicks = 5,
|
|
35
|
+
xTickValues,
|
|
36
|
+
yTickValues,
|
|
37
|
+
xTickFormat,
|
|
38
|
+
yTickFormat,
|
|
39
|
+
gridLineStyle = "solid",
|
|
40
|
+
gridStrokeWidth = 1,
|
|
41
|
+
colors,
|
|
42
|
+
hoverable = false,
|
|
43
|
+
hoveredIndex: hoveredIndexProp,
|
|
44
|
+
activeOpacity = 1,
|
|
45
|
+
inactiveOpacity = 0.25,
|
|
46
|
+
selectable = false,
|
|
47
|
+
selectedIndex: selectedIndexProp,
|
|
48
|
+
showLegend = false,
|
|
49
|
+
legendPosition = "bottom",
|
|
50
|
+
legendMarkerSize = 10,
|
|
51
|
+
legendGap = 8,
|
|
52
|
+
showTooltip = true,
|
|
53
|
+
tooltipFormatter,
|
|
54
|
+
legendFormatter,
|
|
55
|
+
title,
|
|
56
|
+
desc,
|
|
57
|
+
className,
|
|
58
|
+
onHoveredIndexChange,
|
|
59
|
+
onSelectedIndexChange,
|
|
60
|
+
onSeriesClick,
|
|
61
|
+
onSeriesHover,
|
|
62
|
+
onPointClick,
|
|
63
|
+
onPointHover
|
|
64
|
+
}) => {
|
|
65
|
+
const [hoveredPointInfo, setHoveredPointInfo] = useState(null);
|
|
66
|
+
const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 });
|
|
67
|
+
const innerRect = useMemo(
|
|
68
|
+
() => getChartInnerRect(width, height, padding),
|
|
69
|
+
[width, height, padding]
|
|
70
|
+
);
|
|
71
|
+
const resolvedSeries = useMemo(() => {
|
|
72
|
+
if (series && series.length > 0) return series;
|
|
73
|
+
if (data && data.length > 0) return [{ data }];
|
|
74
|
+
return [];
|
|
75
|
+
}, [series, data]);
|
|
76
|
+
const {
|
|
77
|
+
activeIndex,
|
|
78
|
+
handleMouseEnter: handleSeriesHoverEnter,
|
|
79
|
+
handleMouseLeave: handleSeriesHoverLeave,
|
|
80
|
+
handleClick: handleSeriesSelect,
|
|
81
|
+
handleLegendClick,
|
|
82
|
+
handleLegendHover,
|
|
83
|
+
handleLegendLeave,
|
|
84
|
+
wrapperClasses
|
|
85
|
+
} = useChartInteraction({
|
|
86
|
+
hoverable,
|
|
87
|
+
hoveredIndexProp,
|
|
88
|
+
selectable,
|
|
89
|
+
selectedIndexProp,
|
|
90
|
+
activeOpacity,
|
|
91
|
+
inactiveOpacity,
|
|
92
|
+
legendPosition,
|
|
93
|
+
getData: (index) => resolvedSeries[index],
|
|
94
|
+
onHoveredIndexChange: (index) => {
|
|
95
|
+
onHoveredIndexChange?.(index);
|
|
96
|
+
onSeriesHover?.(index, index !== null ? resolvedSeries[index] : null);
|
|
97
|
+
},
|
|
98
|
+
onSelectedIndexChange: (index) => {
|
|
99
|
+
onSelectedIndexChange?.(index);
|
|
100
|
+
if (index !== null) {
|
|
101
|
+
onSeriesClick?.(index, resolvedSeries[index]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
const allData = useMemo(() => resolvedSeries.flatMap((s) => s.data), [resolvedSeries]);
|
|
106
|
+
const xValues = useMemo(() => allData.map((d) => d.x), [allData]);
|
|
107
|
+
const yValues = useMemo(() => allData.map((d) => d.y), [allData]);
|
|
108
|
+
const isXNumeric = useMemo(() => xValues.every((v) => typeof v === "number"), [xValues]);
|
|
109
|
+
const resolvedXScale = useMemo(() => {
|
|
110
|
+
if (xScaleProp) return xScaleProp;
|
|
111
|
+
if (isXNumeric) {
|
|
112
|
+
const extent = getNumberExtent(xValues, { includeZero: false });
|
|
113
|
+
return createLinearScale(extent, [0, innerRect.width]);
|
|
114
|
+
} else {
|
|
115
|
+
const categories = [...new Set(xValues.map(String))];
|
|
116
|
+
return createPointScale(categories, [0, innerRect.width], { padding: 0.1 });
|
|
117
|
+
}
|
|
118
|
+
}, [xScaleProp, isXNumeric, xValues, innerRect.width]);
|
|
119
|
+
const resolvedYScale = useMemo(() => {
|
|
120
|
+
if (yScaleProp) return yScaleProp;
|
|
121
|
+
const extent = getNumberExtent(yValues, { includeZero });
|
|
122
|
+
return createLinearScale(extent, [innerRect.height, 0]);
|
|
123
|
+
}, [yScaleProp, yValues, includeZero, innerRect.height]);
|
|
124
|
+
const resolvedShowXAxis = showAxis && showXAxis;
|
|
125
|
+
const resolvedShowYAxis = showAxis && showYAxis;
|
|
126
|
+
const palette = useMemo(
|
|
127
|
+
() => colors && colors.length > 0 ? colors : [...DEFAULT_CHART_COLORS],
|
|
128
|
+
[colors]
|
|
129
|
+
);
|
|
130
|
+
const seriesData = useMemo(
|
|
131
|
+
() => resolvedSeries.map((s, seriesIndex) => {
|
|
132
|
+
const color = s.color ?? palette[seriesIndex % palette.length];
|
|
133
|
+
const points = s.data.map((datum, pointIndex) => ({
|
|
134
|
+
x: resolvedXScale.map(datum.x),
|
|
135
|
+
y: resolvedYScale.map(datum.y),
|
|
136
|
+
datum,
|
|
137
|
+
pointIndex
|
|
138
|
+
}));
|
|
139
|
+
const linePath = createLinePath(points, curve);
|
|
140
|
+
const opacity = getChartElementOpacity(seriesIndex, activeIndex, {
|
|
141
|
+
activeOpacity,
|
|
142
|
+
inactiveOpacity
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
series: s,
|
|
146
|
+
seriesIndex,
|
|
147
|
+
color,
|
|
148
|
+
linePath,
|
|
149
|
+
points,
|
|
150
|
+
opacity,
|
|
151
|
+
strokeWidth: s.strokeWidth ?? strokeWidth,
|
|
152
|
+
strokeDasharray: s.strokeDasharray,
|
|
153
|
+
showPoints: s.showPoints ?? showPoints,
|
|
154
|
+
pointSize: s.pointSize ?? pointSize,
|
|
155
|
+
pointColor: s.pointColor ?? color
|
|
156
|
+
};
|
|
157
|
+
}),
|
|
158
|
+
[
|
|
159
|
+
resolvedSeries,
|
|
160
|
+
palette,
|
|
161
|
+
resolvedXScale,
|
|
162
|
+
resolvedYScale,
|
|
163
|
+
curve,
|
|
164
|
+
activeIndex,
|
|
165
|
+
activeOpacity,
|
|
166
|
+
inactiveOpacity,
|
|
167
|
+
strokeWidth,
|
|
168
|
+
showPoints,
|
|
169
|
+
pointSize
|
|
170
|
+
]
|
|
171
|
+
);
|
|
172
|
+
const legendItems = useMemo(
|
|
173
|
+
() => resolvedSeries.map((s, index) => ({
|
|
174
|
+
index,
|
|
175
|
+
label: legendFormatter ? legendFormatter(s, index) : s.name ?? `Series ${index + 1}`,
|
|
176
|
+
color: s.color ?? palette[index % palette.length],
|
|
177
|
+
active: activeIndex === null || activeIndex === index
|
|
178
|
+
})),
|
|
179
|
+
[resolvedSeries, legendFormatter, palette, activeIndex]
|
|
180
|
+
);
|
|
181
|
+
const formatTooltip = useCallback(
|
|
182
|
+
(datum, seriesIndex, _pointIndex, s) => {
|
|
183
|
+
if (tooltipFormatter) return tooltipFormatter(datum, seriesIndex, _pointIndex, s);
|
|
184
|
+
const seriesName = s?.name ?? `Series ${seriesIndex + 1}`;
|
|
185
|
+
const label = datum.label ?? String(datum.x);
|
|
186
|
+
return `${seriesName} \xB7 ${label}: ${datum.y}`;
|
|
187
|
+
},
|
|
188
|
+
[tooltipFormatter]
|
|
189
|
+
);
|
|
190
|
+
const tooltipContent = useMemo(() => {
|
|
191
|
+
if (!hoveredPointInfo) return "";
|
|
192
|
+
const { seriesIndex, pointIndex } = hoveredPointInfo;
|
|
193
|
+
const s = resolvedSeries[seriesIndex];
|
|
194
|
+
const datum = s?.data[pointIndex];
|
|
195
|
+
return datum ? formatTooltip(datum, seriesIndex, pointIndex, s) : "";
|
|
196
|
+
}, [hoveredPointInfo, resolvedSeries, formatTooltip]);
|
|
197
|
+
const handlePointMouseEnter = useCallback(
|
|
198
|
+
(seriesIndex, pointIndex, event) => {
|
|
199
|
+
setHoveredPointInfo({ seriesIndex, pointIndex });
|
|
200
|
+
setTooltipPosition({ x: event.clientX, y: event.clientY });
|
|
201
|
+
onPointHover?.(seriesIndex, pointIndex, resolvedSeries[seriesIndex]?.data[pointIndex]);
|
|
202
|
+
},
|
|
203
|
+
[onPointHover, resolvedSeries]
|
|
204
|
+
);
|
|
205
|
+
const handlePointMouseMove = useCallback((event) => {
|
|
206
|
+
setTooltipPosition({ x: event.clientX, y: event.clientY });
|
|
207
|
+
}, []);
|
|
208
|
+
const handlePointMouseLeave = useCallback(() => {
|
|
209
|
+
setHoveredPointInfo(null);
|
|
210
|
+
onPointHover?.(null, null, null);
|
|
211
|
+
}, [onPointHover]);
|
|
212
|
+
const handlePointClick = useCallback(
|
|
213
|
+
(seriesIndex, pointIndex) => {
|
|
214
|
+
onPointClick?.(seriesIndex, pointIndex, resolvedSeries[seriesIndex]?.data[pointIndex]);
|
|
215
|
+
handleSeriesSelect(seriesIndex);
|
|
216
|
+
},
|
|
217
|
+
[onPointClick, resolvedSeries, handleSeriesSelect]
|
|
218
|
+
);
|
|
219
|
+
const handleKeyDown = useCallback(
|
|
220
|
+
(event, seriesIndex) => {
|
|
221
|
+
if (!selectable) return;
|
|
222
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
handleSeriesSelect(seriesIndex);
|
|
225
|
+
},
|
|
226
|
+
[selectable, handleSeriesSelect]
|
|
227
|
+
);
|
|
228
|
+
const chart = /* @__PURE__ */ jsxs(
|
|
229
|
+
ChartCanvas,
|
|
230
|
+
{
|
|
231
|
+
width,
|
|
232
|
+
height,
|
|
233
|
+
padding,
|
|
234
|
+
title,
|
|
235
|
+
desc,
|
|
236
|
+
className: classNames(className),
|
|
237
|
+
children: [
|
|
238
|
+
showGrid && /* @__PURE__ */ jsx(
|
|
239
|
+
ChartGrid,
|
|
240
|
+
{
|
|
241
|
+
xScale: resolvedXScale,
|
|
242
|
+
yScale: resolvedYScale,
|
|
243
|
+
show: "both",
|
|
244
|
+
xTicks,
|
|
245
|
+
yTicks,
|
|
246
|
+
xTickValues,
|
|
247
|
+
yTickValues,
|
|
248
|
+
lineStyle: gridLineStyle,
|
|
249
|
+
strokeWidth: gridStrokeWidth
|
|
250
|
+
}
|
|
251
|
+
),
|
|
252
|
+
resolvedShowXAxis && /* @__PURE__ */ jsx(
|
|
253
|
+
ChartAxis,
|
|
254
|
+
{
|
|
255
|
+
scale: resolvedXScale,
|
|
256
|
+
orientation: "bottom",
|
|
257
|
+
y: innerRect.height,
|
|
258
|
+
ticks: xTicks,
|
|
259
|
+
tickValues: xTickValues,
|
|
260
|
+
tickFormat: xTickFormat,
|
|
261
|
+
label: xAxisLabel
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
resolvedShowYAxis && /* @__PURE__ */ jsx(
|
|
265
|
+
ChartAxis,
|
|
266
|
+
{
|
|
267
|
+
scale: resolvedYScale,
|
|
268
|
+
orientation: "left",
|
|
269
|
+
ticks: yTicks,
|
|
270
|
+
tickValues: yTickValues,
|
|
271
|
+
tickFormat: yTickFormat,
|
|
272
|
+
label: yAxisLabel
|
|
273
|
+
}
|
|
274
|
+
),
|
|
275
|
+
seriesData.map((sd) => /* @__PURE__ */ jsxs(
|
|
276
|
+
ChartSeries,
|
|
277
|
+
{
|
|
278
|
+
data: sd.series.data,
|
|
279
|
+
name: sd.series.name,
|
|
280
|
+
type: "line",
|
|
281
|
+
opacity: sd.opacity,
|
|
282
|
+
className: classNames(sd.series.className, (hoverable || selectable) && "cursor-pointer"),
|
|
283
|
+
onMouseEnter: (e) => handleSeriesHoverEnter(sd.seriesIndex, e),
|
|
284
|
+
onMouseLeave: handleSeriesHoverLeave,
|
|
285
|
+
onClick: () => handleSeriesSelect(sd.seriesIndex),
|
|
286
|
+
tabIndex: selectable ? 0 : void 0,
|
|
287
|
+
onKeyDown: (e) => handleKeyDown(e, sd.seriesIndex),
|
|
288
|
+
children: [
|
|
289
|
+
/* @__PURE__ */ jsx(
|
|
290
|
+
"path",
|
|
291
|
+
{
|
|
292
|
+
d: sd.linePath,
|
|
293
|
+
fill: "none",
|
|
294
|
+
stroke: sd.color,
|
|
295
|
+
strokeWidth: sd.strokeWidth,
|
|
296
|
+
strokeDasharray: sd.strokeDasharray,
|
|
297
|
+
strokeLinecap: "round",
|
|
298
|
+
strokeLinejoin: "round",
|
|
299
|
+
className: "transition-opacity duration-150",
|
|
300
|
+
"data-line-series": sd.seriesIndex
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
sd.showPoints && sd.points.map((point) => /* @__PURE__ */ jsx(
|
|
304
|
+
"circle",
|
|
305
|
+
{
|
|
306
|
+
cx: point.x,
|
|
307
|
+
cy: point.y,
|
|
308
|
+
r: sd.pointSize,
|
|
309
|
+
fill: sd.pointColor,
|
|
310
|
+
className: "transition-all duration-150",
|
|
311
|
+
"data-point-index": point.pointIndex,
|
|
312
|
+
onMouseEnter: (e) => handlePointMouseEnter(sd.seriesIndex, point.pointIndex, e),
|
|
313
|
+
onMouseMove: handlePointMouseMove,
|
|
314
|
+
onMouseLeave: handlePointMouseLeave,
|
|
315
|
+
onClick: (e) => {
|
|
316
|
+
e.stopPropagation();
|
|
317
|
+
handlePointClick(sd.seriesIndex, point.pointIndex);
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
`point-${sd.seriesIndex}-${point.pointIndex}`
|
|
321
|
+
))
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
`series-${sd.seriesIndex}`
|
|
325
|
+
))
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
const tooltip = showTooltip && /* @__PURE__ */ jsx(
|
|
330
|
+
ChartTooltip,
|
|
331
|
+
{
|
|
332
|
+
content: tooltipContent,
|
|
333
|
+
visible: hoveredPointInfo !== null && tooltipContent !== "",
|
|
334
|
+
x: tooltipPosition.x,
|
|
335
|
+
y: tooltipPosition.y
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
if (!showLegend) {
|
|
339
|
+
return /* @__PURE__ */ jsxs("div", { className: "inline-block relative", children: [
|
|
340
|
+
chart,
|
|
341
|
+
tooltip
|
|
342
|
+
] });
|
|
343
|
+
}
|
|
344
|
+
return /* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
|
|
345
|
+
chart,
|
|
346
|
+
/* @__PURE__ */ jsx(
|
|
347
|
+
ChartLegend,
|
|
348
|
+
{
|
|
349
|
+
items: legendItems,
|
|
350
|
+
position: legendPosition,
|
|
351
|
+
markerSize: legendMarkerSize,
|
|
352
|
+
gap: legendGap,
|
|
353
|
+
interactive: hoverable || selectable,
|
|
354
|
+
onItemClick: handleLegendClick,
|
|
355
|
+
onItemHover: handleLegendHover,
|
|
356
|
+
onItemLeave: handleLegendLeave
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
tooltip
|
|
360
|
+
] });
|
|
361
|
+
};
|
|
362
|
+
var LineChart_default = LineChart;
|
|
363
|
+
|
|
364
|
+
export { LineChart, LineChart_default };
|
|
@@ -26,9 +26,11 @@ var Pagination = ({
|
|
|
26
26
|
style,
|
|
27
27
|
onChange,
|
|
28
28
|
onPageSizeChange,
|
|
29
|
+
locale,
|
|
29
30
|
...props
|
|
30
31
|
}) => {
|
|
31
32
|
const { "aria-label": ariaLabelProp, ...navProps } = props;
|
|
33
|
+
const labels = react.useMemo(() => tigercatCore.getPaginationLabels(locale), [locale]);
|
|
32
34
|
const [internalCurrent, setInternalCurrent] = react.useState(defaultCurrent);
|
|
33
35
|
const [internalPageSize, setInternalPageSize] = react.useState(defaultPageSize);
|
|
34
36
|
const [quickJumperValue, setQuickJumperValue] = react.useState("");
|
|
@@ -116,7 +118,7 @@ var Pagination = ({
|
|
|
116
118
|
className: tigercatCore.getPaginationButtonBaseClasses(size),
|
|
117
119
|
disabled: prevDisabled,
|
|
118
120
|
onClick: () => handlePageChange(validatedCurrentPage - 1),
|
|
119
|
-
"aria-label":
|
|
121
|
+
"aria-label": labels.prevPageAriaLabel,
|
|
120
122
|
children: "\u2039"
|
|
121
123
|
},
|
|
122
124
|
"prev"
|
|
@@ -147,7 +149,7 @@ var Pagination = ({
|
|
|
147
149
|
className: tigercatCore.getPaginationButtonBaseClasses(size),
|
|
148
150
|
disabled: nextDisabled,
|
|
149
151
|
onClick: () => handlePageChange(validatedCurrentPage + 1),
|
|
150
|
-
"aria-label":
|
|
152
|
+
"aria-label": labels.nextPageAriaLabel,
|
|
151
153
|
children: "\u203A"
|
|
152
154
|
},
|
|
153
155
|
"next"
|
|
@@ -164,7 +166,7 @@ var Pagination = ({
|
|
|
164
166
|
className: tigercatCore.getPaginationButtonBaseClasses(size),
|
|
165
167
|
disabled: prevDisabled,
|
|
166
168
|
onClick: () => handlePageChange(validatedCurrentPage - 1),
|
|
167
|
-
"aria-label":
|
|
169
|
+
"aria-label": labels.prevPageAriaLabel,
|
|
168
170
|
children: "\u2039"
|
|
169
171
|
},
|
|
170
172
|
"prev"
|
|
@@ -197,7 +199,7 @@ var Pagination = ({
|
|
|
197
199
|
),
|
|
198
200
|
disabled,
|
|
199
201
|
onClick: () => handlePageChange(pageNum),
|
|
200
|
-
"aria-label":
|
|
202
|
+
"aria-label": tigercatCore.formatPageAriaLabel(labels.pageAriaLabel, pageNum),
|
|
201
203
|
"aria-current": isActive ? "page" : void 0,
|
|
202
204
|
children: String(pageNum)
|
|
203
205
|
},
|
|
@@ -214,7 +216,7 @@ var Pagination = ({
|
|
|
214
216
|
className: tigercatCore.getPaginationButtonBaseClasses(size),
|
|
215
217
|
disabled: nextDisabled,
|
|
216
218
|
onClick: () => handlePageChange(validatedCurrentPage + 1),
|
|
217
|
-
"aria-label":
|
|
219
|
+
"aria-label": labels.nextPageAriaLabel,
|
|
218
220
|
children: "\u203A"
|
|
219
221
|
},
|
|
220
222
|
"next"
|
|
@@ -230,10 +232,11 @@ var Pagination = ({
|
|
|
230
232
|
disabled,
|
|
231
233
|
value: currentPageSize,
|
|
232
234
|
onChange: (e) => handlePageSizeChange(parseInt(e.target.value, 10)),
|
|
233
|
-
"aria-label":
|
|
235
|
+
"aria-label": labels.itemsPerPageText,
|
|
234
236
|
children: pageSizeOptions.map((sizeOption) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: sizeOption, children: [
|
|
235
237
|
sizeOption,
|
|
236
|
-
"
|
|
238
|
+
" ",
|
|
239
|
+
labels.itemsPerPageText
|
|
237
240
|
] }, sizeOption))
|
|
238
241
|
},
|
|
239
242
|
"size-changer"
|
|
@@ -249,7 +252,7 @@ var Pagination = ({
|
|
|
249
252
|
"ml-2",
|
|
250
253
|
size === "small" ? "text-sm" : size === "large" ? "text-lg" : "text-base"
|
|
251
254
|
),
|
|
252
|
-
children:
|
|
255
|
+
children: labels.jumpToText
|
|
253
256
|
},
|
|
254
257
|
"jumper-label-start"
|
|
255
258
|
)
|
|
@@ -266,7 +269,7 @@ var Pagination = ({
|
|
|
266
269
|
onKeyDown: handleQuickJumperKeyPress,
|
|
267
270
|
min: 1,
|
|
268
271
|
max: totalPages,
|
|
269
|
-
"aria-label":
|
|
272
|
+
"aria-label": labels.jumpToText
|
|
270
273
|
},
|
|
271
274
|
"jumper-input"
|
|
272
275
|
)
|
|
@@ -276,7 +279,7 @@ var Pagination = ({
|
|
|
276
279
|
"span",
|
|
277
280
|
{
|
|
278
281
|
className: size === "small" ? "text-sm" : size === "large" ? "text-lg" : "text-base",
|
|
279
|
-
children:
|
|
282
|
+
children: labels.pageText
|
|
280
283
|
},
|
|
281
284
|
"jumper-label-end"
|
|
282
285
|
)
|
|
@@ -288,7 +291,7 @@ var Pagination = ({
|
|
|
288
291
|
className: containerClasses,
|
|
289
292
|
...navProps,
|
|
290
293
|
role: "navigation",
|
|
291
|
-
"aria-label": ariaLabelProp ?? "
|
|
294
|
+
"aria-label": ariaLabelProp ?? "Pagination",
|
|
292
295
|
style,
|
|
293
296
|
children: elements
|
|
294
297
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { useEffect, useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { computeFloatingPosition, autoUpdateFloating, isEscapeKey, isEventOutside } from '@expcat/tigercat-core';
|
|
3
|
+
|
|
4
|
+
// src/utils/overlay.ts
|
|
5
|
+
function useClickOutside({
|
|
6
|
+
enabled,
|
|
7
|
+
refs,
|
|
8
|
+
onOutsideClick,
|
|
9
|
+
defer = false
|
|
10
|
+
}) {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!enabled) return;
|
|
13
|
+
const handler = (event) => {
|
|
14
|
+
const elements = refs.map((ref) => ref?.current);
|
|
15
|
+
if (isEventOutside(event, elements)) {
|
|
16
|
+
onOutsideClick();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const attach = () => document.addEventListener("click", handler);
|
|
20
|
+
const detach = () => document.removeEventListener("click", handler);
|
|
21
|
+
if (!defer) {
|
|
22
|
+
attach();
|
|
23
|
+
return () => detach();
|
|
24
|
+
}
|
|
25
|
+
const timer = window.setTimeout(() => attach(), 0);
|
|
26
|
+
return () => {
|
|
27
|
+
window.clearTimeout(timer);
|
|
28
|
+
detach();
|
|
29
|
+
};
|
|
30
|
+
}, [enabled, refs, onOutsideClick, defer]);
|
|
31
|
+
}
|
|
32
|
+
function useEscapeKey({ enabled, onEscape }) {
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!enabled) return;
|
|
35
|
+
const handler = (event) => {
|
|
36
|
+
if (event.defaultPrevented) return;
|
|
37
|
+
if (!isEscapeKey(event)) return;
|
|
38
|
+
onEscape();
|
|
39
|
+
};
|
|
40
|
+
document.addEventListener("keydown", handler);
|
|
41
|
+
return () => document.removeEventListener("keydown", handler);
|
|
42
|
+
}, [enabled, onEscape]);
|
|
43
|
+
}
|
|
44
|
+
function useFloating(options) {
|
|
45
|
+
const {
|
|
46
|
+
referenceRef,
|
|
47
|
+
floatingRef,
|
|
48
|
+
enabled,
|
|
49
|
+
placement: initialPlacement = "bottom",
|
|
50
|
+
offset: offsetDistance = 8,
|
|
51
|
+
arrowRef,
|
|
52
|
+
onPlacementChange
|
|
53
|
+
} = options;
|
|
54
|
+
const [x, setX] = useState(0);
|
|
55
|
+
const [y, setY] = useState(0);
|
|
56
|
+
const [placement, setPlacement] = useState(initialPlacement);
|
|
57
|
+
const [arrowX, setArrowX] = useState(void 0);
|
|
58
|
+
const [arrowY, setArrowY] = useState(void 0);
|
|
59
|
+
const onPlacementChangeRef = useRef(onPlacementChange);
|
|
60
|
+
onPlacementChangeRef.current = onPlacementChange;
|
|
61
|
+
const update = useCallback(async () => {
|
|
62
|
+
const reference = referenceRef.current;
|
|
63
|
+
const floating = floatingRef.current;
|
|
64
|
+
if (!reference || !floating) return;
|
|
65
|
+
const floatingOptions = {
|
|
66
|
+
placement: initialPlacement,
|
|
67
|
+
offset: offsetDistance,
|
|
68
|
+
flip: true,
|
|
69
|
+
shift: true,
|
|
70
|
+
arrowElement: arrowRef?.current
|
|
71
|
+
};
|
|
72
|
+
const result = await computeFloatingPosition(
|
|
73
|
+
reference,
|
|
74
|
+
floating,
|
|
75
|
+
floatingOptions
|
|
76
|
+
);
|
|
77
|
+
setX(result.x);
|
|
78
|
+
setY(result.y);
|
|
79
|
+
setPlacement((prev) => {
|
|
80
|
+
if (prev !== result.placement) {
|
|
81
|
+
onPlacementChangeRef.current?.(result.placement);
|
|
82
|
+
return result.placement;
|
|
83
|
+
}
|
|
84
|
+
return prev;
|
|
85
|
+
});
|
|
86
|
+
if (result.arrow) {
|
|
87
|
+
setArrowX(result.arrow.x);
|
|
88
|
+
setArrowY(result.arrow.y);
|
|
89
|
+
}
|
|
90
|
+
}, [referenceRef, floatingRef, initialPlacement, offsetDistance, arrowRef]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const reference = referenceRef.current;
|
|
93
|
+
const floating = floatingRef.current;
|
|
94
|
+
if (!enabled || !reference || !floating) return;
|
|
95
|
+
update();
|
|
96
|
+
const cleanup = autoUpdateFloating(reference, floating, update);
|
|
97
|
+
return () => {
|
|
98
|
+
cleanup();
|
|
99
|
+
};
|
|
100
|
+
}, [enabled, referenceRef, floatingRef, update]);
|
|
101
|
+
return {
|
|
102
|
+
x,
|
|
103
|
+
y,
|
|
104
|
+
placement,
|
|
105
|
+
arrowX,
|
|
106
|
+
arrowY,
|
|
107
|
+
update
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { useClickOutside, useEscapeKey, useFloating };
|
|
@@ -29,10 +29,10 @@ var Icon = ({
|
|
|
29
29
|
return React__default.default.cloneElement(child, {
|
|
30
30
|
...svgProps,
|
|
31
31
|
className: tigercatCore.classNames(tigercatCore.iconSvgBaseClasses, tigercatCore.iconSizeClasses[size], svgProps.className),
|
|
32
|
-
xmlns: svgProps.xmlns ??
|
|
33
|
-
viewBox: svgProps.viewBox ??
|
|
34
|
-
fill: svgProps.fill ??
|
|
35
|
-
stroke: svgProps.stroke ??
|
|
32
|
+
xmlns: svgProps.xmlns ?? tigercatCore.SVG_DEFAULT_XMLNS,
|
|
33
|
+
viewBox: svgProps.viewBox ?? tigercatCore.SVG_DEFAULT_VIEWBOX_24,
|
|
34
|
+
fill: svgProps.fill ?? tigercatCore.SVG_DEFAULT_FILL,
|
|
35
|
+
stroke: svgProps.stroke ?? tigercatCore.SVG_DEFAULT_STROKE,
|
|
36
36
|
strokeWidth: svgProps.strokeWidth ?? 2,
|
|
37
37
|
strokeLinecap: svgProps.strokeLinecap ?? "round",
|
|
38
38
|
strokeLinejoin: svgProps.strokeLinejoin ?? "round"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkZYPEO2KY_js = require('./chunk-ZYPEO2KY.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactDom = require('react-dom');
|
|
6
6
|
var tigercatCore = require('@expcat/tigercat-core');
|
|
@@ -69,7 +69,7 @@ var Drawer = ({
|
|
|
69
69
|
},
|
|
70
70
|
[maskClosable, handleClose]
|
|
71
71
|
);
|
|
72
|
-
|
|
72
|
+
chunkZYPEO2KY_js.useEscapeKey({ enabled: visible, onEscape: handleClose });
|
|
73
73
|
const previousVisible = React.useRef(false);
|
|
74
74
|
React.useEffect(() => {
|
|
75
75
|
if (visible === previousVisible.current) return;
|
|
@@ -80,7 +80,7 @@ var Drawer = ({
|
|
|
80
80
|
} else {
|
|
81
81
|
onAfterLeave?.();
|
|
82
82
|
}
|
|
83
|
-
},
|
|
83
|
+
}, tigercatCore.ANIMATION_DURATION_MS);
|
|
84
84
|
return () => window.clearTimeout(timer);
|
|
85
85
|
}, [visible, onAfterEnter, onAfterLeave]);
|
|
86
86
|
const reactId = React.useId();
|
|
@@ -114,6 +114,16 @@ var Drawer = ({
|
|
|
114
114
|
if (visible) return;
|
|
115
115
|
tigercatCore.restoreFocus(previousActiveElementRef.current);
|
|
116
116
|
}, [visible]);
|
|
117
|
+
const handleKeyDown = React.useCallback((event) => {
|
|
118
|
+
if (event.key === "Tab" && dialogRef.current) {
|
|
119
|
+
const focusables = tigercatCore.getFocusableElements(dialogRef.current);
|
|
120
|
+
const result = tigercatCore.getFocusTrapNavigation(event.nativeEvent, focusables, document.activeElement);
|
|
121
|
+
if (result.shouldHandle && result.next) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
result.next.focus();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, []);
|
|
117
127
|
const containerClasses = tigercatCore.classNames(
|
|
118
128
|
tigercatCore.getDrawerContainerClasses(zIndex),
|
|
119
129
|
!visible && "pointer-events-none"
|
|
@@ -161,6 +171,7 @@ var Drawer = ({
|
|
|
161
171
|
"aria-labelledby": ariaLabelledby,
|
|
162
172
|
tabIndex: -1,
|
|
163
173
|
ref: dialogRef,
|
|
174
|
+
onKeyDown: handleKeyDown,
|
|
164
175
|
"data-tiger-drawer": "",
|
|
165
176
|
children: [
|
|
166
177
|
(title || header || closable) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: headerClasses, children: [
|