@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,65 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getChartGridLineDasharray, getChartAxisTicks, classNames, chartGridLineClasses } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/ChartGrid.tsx
|
|
6
|
+
var ChartGrid = ({
|
|
7
|
+
xScale,
|
|
8
|
+
yScale,
|
|
9
|
+
show = "both",
|
|
10
|
+
xTicks = 5,
|
|
11
|
+
yTicks = 5,
|
|
12
|
+
xTickValues,
|
|
13
|
+
yTickValues,
|
|
14
|
+
lineStyle = "solid",
|
|
15
|
+
strokeWidth = 1,
|
|
16
|
+
x = 0,
|
|
17
|
+
y = 0,
|
|
18
|
+
className,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
21
|
+
const dasharray = useMemo(() => getChartGridLineDasharray(lineStyle), [lineStyle]);
|
|
22
|
+
const resolvedXTicks = useMemo(() => {
|
|
23
|
+
if (!xScale) return [];
|
|
24
|
+
return getChartAxisTicks(xScale, { tickCount: xTicks, tickValues: xTickValues });
|
|
25
|
+
}, [xScale, xTicks, xTickValues]);
|
|
26
|
+
const resolvedYTicks = useMemo(() => {
|
|
27
|
+
if (!yScale) return [];
|
|
28
|
+
return getChartAxisTicks(yScale, { tickCount: yTicks, tickValues: yTickValues });
|
|
29
|
+
}, [yScale, yTicks, yTickValues]);
|
|
30
|
+
const shouldRenderX = show === "both" || show === "x";
|
|
31
|
+
const shouldRenderY = show === "both" || show === "y";
|
|
32
|
+
const xRange = xScale?.range;
|
|
33
|
+
const yRange = yScale?.range;
|
|
34
|
+
return /* @__PURE__ */ jsxs("g", { ...props, className: classNames(className), transform: `translate(${x}, ${y})`, children: [
|
|
35
|
+
shouldRenderX && xScale && yRange ? resolvedXTicks.map((tick) => /* @__PURE__ */ jsx(
|
|
36
|
+
"line",
|
|
37
|
+
{
|
|
38
|
+
x1: tick.position,
|
|
39
|
+
y1: yRange[0],
|
|
40
|
+
x2: tick.position,
|
|
41
|
+
y2: yRange[1],
|
|
42
|
+
className: chartGridLineClasses,
|
|
43
|
+
strokeWidth,
|
|
44
|
+
strokeDasharray: dasharray
|
|
45
|
+
},
|
|
46
|
+
`x-${tick.value}`
|
|
47
|
+
)) : null,
|
|
48
|
+
shouldRenderY && yScale && xRange ? resolvedYTicks.map((tick) => /* @__PURE__ */ jsx(
|
|
49
|
+
"line",
|
|
50
|
+
{
|
|
51
|
+
x1: xRange[0],
|
|
52
|
+
y1: tick.position,
|
|
53
|
+
x2: xRange[1],
|
|
54
|
+
y2: tick.position,
|
|
55
|
+
className: chartGridLineClasses,
|
|
56
|
+
strokeWidth,
|
|
57
|
+
strokeDasharray: dasharray
|
|
58
|
+
},
|
|
59
|
+
`y-${tick.value}`
|
|
60
|
+
)) : null
|
|
61
|
+
] });
|
|
62
|
+
};
|
|
63
|
+
var ChartGrid_default = ChartGrid;
|
|
64
|
+
|
|
65
|
+
export { ChartGrid, ChartGrid_default };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { PieChart } from './chunk-LZNG2HGC.mjs';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { getChartInnerRect, classNames } from '@expcat/tigercat-core';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var DonutChart = ({
|
|
7
|
+
width = 320,
|
|
8
|
+
height = 200,
|
|
9
|
+
padding = 24,
|
|
10
|
+
data,
|
|
11
|
+
innerRadius,
|
|
12
|
+
innerRadiusRatio = 0.6,
|
|
13
|
+
outerRadius,
|
|
14
|
+
startAngle = 0,
|
|
15
|
+
endAngle = Math.PI * 2,
|
|
16
|
+
padAngle = 0,
|
|
17
|
+
colors,
|
|
18
|
+
showLabels = false,
|
|
19
|
+
labelFormatter,
|
|
20
|
+
// Interaction props
|
|
21
|
+
hoverable = false,
|
|
22
|
+
hoveredIndex,
|
|
23
|
+
activeOpacity = 1,
|
|
24
|
+
inactiveOpacity = 0.25,
|
|
25
|
+
selectable = false,
|
|
26
|
+
selectedIndex,
|
|
27
|
+
// Legend props
|
|
28
|
+
showLegend = false,
|
|
29
|
+
legendPosition = "bottom",
|
|
30
|
+
legendMarkerSize = 10,
|
|
31
|
+
legendGap = 8,
|
|
32
|
+
// Tooltip props
|
|
33
|
+
showTooltip = true,
|
|
34
|
+
tooltipFormatter,
|
|
35
|
+
// Accessibility
|
|
36
|
+
title,
|
|
37
|
+
desc,
|
|
38
|
+
className,
|
|
39
|
+
// Callbacks
|
|
40
|
+
onHoveredIndexChange,
|
|
41
|
+
onSelectedIndexChange,
|
|
42
|
+
onSliceClick,
|
|
43
|
+
onSliceHover
|
|
44
|
+
}) => {
|
|
45
|
+
const innerRect = useMemo(
|
|
46
|
+
() => getChartInnerRect(width, height, padding),
|
|
47
|
+
[width, height, padding]
|
|
48
|
+
);
|
|
49
|
+
const resolvedOuterRadius = useMemo(() => {
|
|
50
|
+
if (typeof outerRadius === "number") return Math.max(0, outerRadius);
|
|
51
|
+
return Math.max(0, Math.min(innerRect.width, innerRect.height) / 2);
|
|
52
|
+
}, [outerRadius, innerRect.width, innerRect.height]);
|
|
53
|
+
const resolvedInnerRadius = useMemo(() => {
|
|
54
|
+
if (typeof innerRadius === "number") {
|
|
55
|
+
return Math.min(Math.max(0, innerRadius), resolvedOuterRadius);
|
|
56
|
+
}
|
|
57
|
+
const ratio = Math.min(Math.max(innerRadiusRatio ?? 0.6, 0), 1);
|
|
58
|
+
return resolvedOuterRadius * ratio;
|
|
59
|
+
}, [innerRadius, innerRadiusRatio, resolvedOuterRadius]);
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
PieChart,
|
|
62
|
+
{
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
padding,
|
|
66
|
+
data,
|
|
67
|
+
innerRadius: resolvedInnerRadius,
|
|
68
|
+
outerRadius,
|
|
69
|
+
startAngle,
|
|
70
|
+
endAngle,
|
|
71
|
+
padAngle,
|
|
72
|
+
colors,
|
|
73
|
+
showLabels,
|
|
74
|
+
labelFormatter,
|
|
75
|
+
hoverable,
|
|
76
|
+
hoveredIndex,
|
|
77
|
+
activeOpacity,
|
|
78
|
+
inactiveOpacity,
|
|
79
|
+
selectable,
|
|
80
|
+
selectedIndex,
|
|
81
|
+
showLegend,
|
|
82
|
+
legendPosition,
|
|
83
|
+
legendMarkerSize,
|
|
84
|
+
legendGap,
|
|
85
|
+
showTooltip,
|
|
86
|
+
tooltipFormatter,
|
|
87
|
+
title,
|
|
88
|
+
desc,
|
|
89
|
+
className: classNames(className),
|
|
90
|
+
onHoveredIndexChange,
|
|
91
|
+
onSelectedIndexChange,
|
|
92
|
+
onSliceClick,
|
|
93
|
+
onSliceHover
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
var DonutChart_default = DonutChart;
|
|
98
|
+
|
|
99
|
+
export { DonutChart, DonutChart_default };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/components/ChartLegend.tsx
|
|
8
|
+
var ChartLegend = ({
|
|
9
|
+
items,
|
|
10
|
+
position = "bottom",
|
|
11
|
+
markerSize = 10,
|
|
12
|
+
gap = 8,
|
|
13
|
+
interactive = false,
|
|
14
|
+
className,
|
|
15
|
+
onItemClick,
|
|
16
|
+
onItemHover,
|
|
17
|
+
onItemLeave
|
|
18
|
+
}) => {
|
|
19
|
+
const containerClasses = react.useMemo(
|
|
20
|
+
() => tigercatCore.classNames(
|
|
21
|
+
"flex flex-wrap",
|
|
22
|
+
position === "right" || position === "left" ? "flex-col gap-2" : "flex-row gap-3",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
[position, className]
|
|
26
|
+
);
|
|
27
|
+
const handleClick = react.useCallback(
|
|
28
|
+
(item) => {
|
|
29
|
+
if (!interactive) return;
|
|
30
|
+
onItemClick?.(item.index, item);
|
|
31
|
+
},
|
|
32
|
+
[interactive, onItemClick]
|
|
33
|
+
);
|
|
34
|
+
const handleHover = react.useCallback(
|
|
35
|
+
(item) => {
|
|
36
|
+
if (!interactive) return;
|
|
37
|
+
onItemHover?.(item.index, item);
|
|
38
|
+
},
|
|
39
|
+
[interactive, onItemHover]
|
|
40
|
+
);
|
|
41
|
+
const handleLeave = react.useCallback(() => {
|
|
42
|
+
if (!interactive) return;
|
|
43
|
+
onItemLeave?.();
|
|
44
|
+
}, [interactive, onItemLeave]);
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: containerClasses,
|
|
49
|
+
role: "list",
|
|
50
|
+
"aria-label": "Chart legend",
|
|
51
|
+
"data-chart-legend": "true",
|
|
52
|
+
children: items.map((item) => {
|
|
53
|
+
const ItemComponent = interactive ? "button" : "div";
|
|
54
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
55
|
+
ItemComponent,
|
|
56
|
+
{
|
|
57
|
+
type: interactive ? "button" : void 0,
|
|
58
|
+
className: tigercatCore.classNames(
|
|
59
|
+
"flex items-center gap-2 text-sm",
|
|
60
|
+
"text-[color:var(--tiger-text-secondary,#6b7280)]",
|
|
61
|
+
interactive ? "cursor-pointer hover:text-[color:var(--tiger-text,#374151)] transition-colors" : "cursor-default",
|
|
62
|
+
item.active === false ? "opacity-50" : void 0
|
|
63
|
+
),
|
|
64
|
+
role: "listitem",
|
|
65
|
+
"data-legend-item": "true",
|
|
66
|
+
onClick: interactive ? () => handleClick(item) : void 0,
|
|
67
|
+
onMouseEnter: interactive ? () => handleHover(item) : void 0,
|
|
68
|
+
onMouseLeave: interactive ? handleLeave : void 0,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
className: "inline-block rounded-full shrink-0",
|
|
74
|
+
style: {
|
|
75
|
+
width: `${markerSize}px`,
|
|
76
|
+
height: `${markerSize}px`,
|
|
77
|
+
backgroundColor: item.color
|
|
78
|
+
},
|
|
79
|
+
"aria-hidden": "true",
|
|
80
|
+
"data-legend-marker": "true"
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { marginRight: `${gap}px` }, children: item.label })
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
`legend-${item.index}`
|
|
87
|
+
);
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
var ChartLegend_default = ChartLegend;
|
|
93
|
+
|
|
94
|
+
exports.ChartLegend = ChartLegend;
|
|
95
|
+
exports.ChartLegend_default = ChartLegend_default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DropdownContext } from './chunk-
|
|
1
|
+
import { DropdownContext } from './chunk-7IKJBQQV.mjs';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { classNames, getDropdownItemClasses } from '@expcat/tigercat-core';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { useClickOutside, useEscapeKey } from './chunk-
|
|
1
|
+
import { useClickOutside, useEscapeKey, useFloating } from './chunk-WLIFEALE.mjs';
|
|
2
2
|
import { DropdownMenu } from './chunk-SIVJX7VU.mjs';
|
|
3
|
-
import React, { createContext, useState, useRef, useCallback, useEffect } from 'react';
|
|
4
|
-
import { classNames, getDropdownContainerClasses, getDropdownTriggerClasses,
|
|
3
|
+
import React, { createContext, useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
4
|
+
import { classNames, getDropdownContainerClasses, getDropdownTriggerClasses, getTransformOrigin } from '@expcat/tigercat-core';
|
|
5
5
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
var DropdownContext = createContext(null);
|
|
8
8
|
var Dropdown = ({
|
|
9
9
|
trigger = "hover",
|
|
10
|
-
placement = "bottom-start",
|
|
10
|
+
placement: initialPlacement = "bottom-start",
|
|
11
|
+
offset = 4,
|
|
11
12
|
disabled = false,
|
|
12
13
|
visible: controlledVisible,
|
|
13
14
|
defaultVisible = false,
|
|
@@ -22,6 +23,8 @@ var Dropdown = ({
|
|
|
22
23
|
const [internalVisible, setInternalVisible] = useState(defaultVisible);
|
|
23
24
|
const visible = controlledVisible !== void 0 ? controlledVisible : internalVisible;
|
|
24
25
|
const containerRef = useRef(null);
|
|
26
|
+
const triggerRef = useRef(null);
|
|
27
|
+
const floatingRef = useRef(null);
|
|
25
28
|
const hoverTimerRef = useRef(null);
|
|
26
29
|
const setVisible = useCallback(
|
|
27
30
|
(newVisible) => {
|
|
@@ -69,6 +72,13 @@ var Dropdown = ({
|
|
|
69
72
|
enabled: visible,
|
|
70
73
|
onEscape: () => setVisible(false)
|
|
71
74
|
});
|
|
75
|
+
const { x, y, placement } = useFloating({
|
|
76
|
+
referenceRef: triggerRef,
|
|
77
|
+
floatingRef,
|
|
78
|
+
enabled: visible,
|
|
79
|
+
placement: initialPlacement,
|
|
80
|
+
offset
|
|
81
|
+
});
|
|
72
82
|
useEffect(() => {
|
|
73
83
|
return () => {
|
|
74
84
|
if (hoverTimerRef.current) {
|
|
@@ -82,7 +92,16 @@ var Dropdown = ({
|
|
|
82
92
|
className
|
|
83
93
|
);
|
|
84
94
|
const triggerClasses = getDropdownTriggerClasses(disabled);
|
|
85
|
-
const menuWrapperClasses =
|
|
95
|
+
const menuWrapperClasses = "absolute z-50";
|
|
96
|
+
const menuWrapperStyles = useMemo(
|
|
97
|
+
() => ({
|
|
98
|
+
position: "absolute",
|
|
99
|
+
left: x,
|
|
100
|
+
top: y,
|
|
101
|
+
transformOrigin: getTransformOrigin(placement)
|
|
102
|
+
}),
|
|
103
|
+
[x, y, placement]
|
|
104
|
+
);
|
|
86
105
|
const contextValue = {
|
|
87
106
|
closeOnClick,
|
|
88
107
|
handleItemClick
|
|
@@ -118,6 +137,7 @@ var Dropdown = ({
|
|
|
118
137
|
/* @__PURE__ */ jsx(
|
|
119
138
|
"div",
|
|
120
139
|
{
|
|
140
|
+
ref: triggerRef,
|
|
121
141
|
className: triggerClasses,
|
|
122
142
|
onClick: handleClick,
|
|
123
143
|
onMouseEnter: handleMouseEnter,
|
|
@@ -130,7 +150,9 @@ var Dropdown = ({
|
|
|
130
150
|
/* @__PURE__ */ jsx(
|
|
131
151
|
"div",
|
|
132
152
|
{
|
|
153
|
+
ref: floatingRef,
|
|
133
154
|
className: menuWrapperClasses,
|
|
155
|
+
style: menuWrapperStyles,
|
|
134
156
|
hidden: !visible,
|
|
135
157
|
onMouseEnter: handleMouseEnter,
|
|
136
158
|
onMouseLeave: handleMouseLeave,
|
|
@@ -69,7 +69,7 @@ var NotificationItem = ({ notification: notification2, onClose }) => {
|
|
|
69
69
|
const iconClass = tigercatCore.classNames(tigercatCore.notificationIconClasses, colorScheme.icon);
|
|
70
70
|
const handleClose = () => {
|
|
71
71
|
setIsVisible(false);
|
|
72
|
-
setTimeout(() => onClose(notification2.id),
|
|
72
|
+
setTimeout(() => onClose(notification2.id), tigercatCore.ANIMATION_DURATION_MS);
|
|
73
73
|
};
|
|
74
74
|
const a11yRole = notification2.type === "error" ? "alert" : "status";
|
|
75
75
|
const ariaLive = notification2.type === "error" ? "assertive" : "polite";
|