@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.
Files changed (169) hide show
  1. package/dist/{chunk-TBIEWDY5.js → chunk-36RRHNZD.js} +13 -2
  2. package/dist/chunk-3CDAG4HD.mjs +151 -0
  3. package/dist/chunk-3QFHVAZT.js +68 -0
  4. package/dist/{chunk-ALP3KYYY.mjs → chunk-3XKBDV2Q.mjs} +5 -5
  5. package/dist/chunk-42UKIFFQ.js +278 -0
  6. package/dist/{chunk-K7ZMB2TH.mjs → chunk-5XKYWZZZ.mjs} +16 -22
  7. package/dist/chunk-677VSTPW.mjs +65 -0
  8. package/dist/chunk-6DYS4PJT.mjs +99 -0
  9. package/dist/chunk-6PBNFLM7.js +95 -0
  10. package/dist/{chunk-DCRVIDMY.mjs → chunk-6ZC7H22S.mjs} +1 -1
  11. package/dist/{chunk-WSCSDSV7.mjs → chunk-7IKJBQQV.mjs} +27 -5
  12. package/dist/{chunk-OTRGVENC.js → chunk-7SLNHUGJ.js} +1 -1
  13. package/dist/chunk-A2UW5OKX.mjs +415 -0
  14. package/dist/{chunk-NOOPXNR4.mjs → chunk-AGUPZEUL.mjs} +2 -3
  15. package/dist/chunk-AX5XRD2Q.js +35 -0
  16. package/dist/{chunk-BJU5N7WU.mjs → chunk-BAPR7UUR.mjs} +7 -7
  17. package/dist/chunk-CBALIFPW.mjs +275 -0
  18. package/dist/{chunk-BIWO5KB4.mjs → chunk-CJJ56NVL.mjs} +2 -2
  19. package/dist/{chunk-ENR3RIMM.js → chunk-DGBYGBLR.js} +72 -59
  20. package/dist/chunk-DUWAV47E.js +42 -0
  21. package/dist/chunk-E5GD3H7L.js +94 -0
  22. package/dist/chunk-EJLJYOO7.js +367 -0
  23. package/dist/{chunk-FQ6UHRAO.js → chunk-GQMYCYZ4.js} +6 -27
  24. package/dist/{chunk-G6FSHN2I.mjs → chunk-GW4EWT2K.mjs} +45 -31
  25. package/dist/{chunk-AQQRWISY.js → chunk-GXTBCX3M.js} +1 -1
  26. package/dist/{chunk-HQXZVTP4.mjs → chunk-HGF2EL25.mjs} +74 -61
  27. package/dist/{chunk-R5BQHZWB.js → chunk-HRYBEBZC.js} +15 -21
  28. package/dist/{chunk-PAD2DX5M.mjs → chunk-IIVRVCCP.mjs} +6 -24
  29. package/dist/chunk-IS467WAO.mjs +39 -0
  30. package/dist/{chunk-CTAMMQBC.mjs → chunk-IS7YOBR7.mjs} +16 -13
  31. package/dist/{chunk-ADOPAXPG.mjs → chunk-JI7SFMUT.mjs} +2 -2
  32. package/dist/chunk-KBGURVTD.mjs +282 -0
  33. package/dist/{chunk-O3EUFIOS.mjs → chunk-KELLYJZY.mjs} +36 -30
  34. package/dist/{chunk-XZDJ5FRB.js → chunk-KPZTGRNA.js} +5 -23
  35. package/dist/chunk-KQZ4F7FZ.js +153 -0
  36. package/dist/{chunk-XDKXL2BP.mjs → chunk-KV4LLPAY.mjs} +14 -3
  37. package/dist/{chunk-LNKI6HQ3.js → chunk-LIJLFLYE.js} +27 -5
  38. package/dist/chunk-LVC43YX2.mjs +72 -0
  39. package/dist/chunk-LZNG2HGC.mjs +227 -0
  40. package/dist/chunk-M375I56K.js +75 -0
  41. package/dist/{chunk-7OLWGHUR.mjs → chunk-MF3H7WWW.mjs} +13 -2
  42. package/dist/chunk-N32MAX4A.js +230 -0
  43. package/dist/{chunk-YYKJ63LD.mjs → chunk-NMDNLB3C.mjs} +7 -28
  44. package/dist/{chunk-77D7VQMG.js → chunk-OD2NNQD2.js} +2 -2
  45. package/dist/chunk-OONM7FO7.js +418 -0
  46. package/dist/{chunk-Q5Q7FG4U.js → chunk-OZLGNWET.js} +7 -7
  47. package/dist/{chunk-LAZGEMA2.mjs → chunk-P4EFJIXU.mjs} +1 -1
  48. package/dist/chunk-QI6WAP6Y.js +285 -0
  49. package/dist/{chunk-WK5HN4OH.js → chunk-QY6I7LU5.js} +43 -29
  50. package/dist/{chunk-KSW5JDIV.js → chunk-R7TOQU3U.js} +1 -1
  51. package/dist/chunk-RQSQXQN6.mjs +91 -0
  52. package/dist/chunk-SDLMB34Y.mjs +32 -0
  53. package/dist/chunk-UG3I4PCY.js +102 -0
  54. package/dist/chunk-VBSK4TGO.mjs +364 -0
  55. package/dist/{chunk-DZJUFU55.js → chunk-VXHBQTZS.js} +14 -11
  56. package/dist/chunk-WLIFEALE.mjs +111 -0
  57. package/dist/{chunk-AQ6DHCP6.js → chunk-XRFK2IXM.js} +4 -4
  58. package/dist/{chunk-5FRENLDC.js → chunk-Y2JOJ4D6.js} +14 -3
  59. package/dist/chunk-YER7IQF4.mjs +429 -0
  60. package/dist/{chunk-NI2WNZRT.js → chunk-YESS6YKC.js} +1 -2
  61. package/dist/chunk-Z6F67MJE.mjs +92 -0
  62. package/dist/{chunk-QORSSZX4.js → chunk-ZPFZMXA6.js} +34 -28
  63. package/dist/chunk-ZUUG3WOL.js +432 -0
  64. package/dist/chunk-ZYPEO2KY.js +115 -0
  65. package/dist/components/AreaChart.d.mts +19 -0
  66. package/dist/components/AreaChart.d.ts +19 -0
  67. package/dist/components/AreaChart.js +23 -0
  68. package/dist/components/AreaChart.mjs +8 -0
  69. package/dist/components/BarChart.d.mts +16 -0
  70. package/dist/components/BarChart.d.ts +16 -0
  71. package/dist/components/BarChart.js +23 -0
  72. package/dist/components/BarChart.mjs +8 -0
  73. package/dist/components/ChartAxis.d.mts +10 -0
  74. package/dist/components/ChartAxis.d.ts +10 -0
  75. package/dist/components/ChartAxis.js +16 -0
  76. package/dist/components/ChartAxis.mjs +1 -0
  77. package/dist/components/ChartCanvas.d.mts +9 -0
  78. package/dist/components/ChartCanvas.d.ts +9 -0
  79. package/dist/components/ChartCanvas.js +16 -0
  80. package/dist/components/ChartCanvas.mjs +1 -0
  81. package/dist/components/ChartGrid.d.mts +11 -0
  82. package/dist/components/ChartGrid.d.ts +11 -0
  83. package/dist/components/ChartGrid.js +16 -0
  84. package/dist/components/ChartGrid.mjs +1 -0
  85. package/dist/components/ChartLegend.d.mts +17 -0
  86. package/dist/components/ChartLegend.d.ts +17 -0
  87. package/dist/components/ChartLegend.js +16 -0
  88. package/dist/components/ChartLegend.mjs +1 -0
  89. package/dist/components/ChartSeries.d.mts +18 -0
  90. package/dist/components/ChartSeries.d.ts +18 -0
  91. package/dist/components/ChartSeries.js +16 -0
  92. package/dist/components/ChartSeries.mjs +1 -0
  93. package/dist/components/ChartTooltip.d.mts +12 -0
  94. package/dist/components/ChartTooltip.d.ts +12 -0
  95. package/dist/components/ChartTooltip.js +16 -0
  96. package/dist/components/ChartTooltip.mjs +1 -0
  97. package/dist/components/DonutChart.d.mts +14 -0
  98. package/dist/components/DonutChart.d.ts +14 -0
  99. package/dist/components/DonutChart.js +21 -0
  100. package/dist/components/DonutChart.mjs +6 -0
  101. package/dist/components/Drawer.js +3 -3
  102. package/dist/components/Drawer.mjs +2 -2
  103. package/dist/components/Dropdown.d.mts +12 -2
  104. package/dist/components/Dropdown.d.ts +12 -2
  105. package/dist/components/Dropdown.js +4 -4
  106. package/dist/components/Dropdown.mjs +2 -2
  107. package/dist/components/DropdownItem.js +4 -4
  108. package/dist/components/DropdownItem.mjs +3 -3
  109. package/dist/components/Icon.js +2 -2
  110. package/dist/components/Icon.mjs +1 -1
  111. package/dist/components/LineChart.d.mts +19 -0
  112. package/dist/components/LineChart.d.ts +19 -0
  113. package/dist/components/LineChart.js +23 -0
  114. package/dist/components/LineChart.mjs +8 -0
  115. package/dist/components/List.js +3 -3
  116. package/dist/components/List.mjs +2 -2
  117. package/dist/components/Message.js +4 -4
  118. package/dist/components/Message.mjs +1 -1
  119. package/dist/components/Modal.js +3 -3
  120. package/dist/components/Modal.mjs +2 -2
  121. package/dist/components/Notification.js +4 -4
  122. package/dist/components/Notification.mjs +1 -1
  123. package/dist/components/Pagination.d.mts +5 -1
  124. package/dist/components/Pagination.d.ts +5 -1
  125. package/dist/components/Pagination.js +3 -3
  126. package/dist/components/Pagination.mjs +1 -1
  127. package/dist/components/PieChart.d.mts +14 -0
  128. package/dist/components/PieChart.d.ts +14 -0
  129. package/dist/components/PieChart.js +20 -0
  130. package/dist/components/PieChart.mjs +5 -0
  131. package/dist/components/Popconfirm.d.mts +12 -2
  132. package/dist/components/Popconfirm.d.ts +12 -2
  133. package/dist/components/Popconfirm.js +3 -2
  134. package/dist/components/Popconfirm.mjs +2 -1
  135. package/dist/components/Popover.d.mts +12 -2
  136. package/dist/components/Popover.d.ts +12 -2
  137. package/dist/components/Popover.js +3 -2
  138. package/dist/components/Popover.mjs +2 -1
  139. package/dist/components/RadarChart.d.mts +20 -0
  140. package/dist/components/RadarChart.d.ts +20 -0
  141. package/dist/components/RadarChart.js +20 -0
  142. package/dist/components/RadarChart.mjs +5 -0
  143. package/dist/components/ScatterChart.d.mts +32 -0
  144. package/dist/components/ScatterChart.d.ts +32 -0
  145. package/dist/components/ScatterChart.js +23 -0
  146. package/dist/components/ScatterChart.mjs +8 -0
  147. package/dist/components/Select.js +2 -2
  148. package/dist/components/Select.mjs +1 -1
  149. package/dist/components/Slider.js +2 -2
  150. package/dist/components/Slider.mjs +1 -1
  151. package/dist/components/Space.js +2 -2
  152. package/dist/components/Space.mjs +1 -1
  153. package/dist/components/Steps.js +3 -3
  154. package/dist/components/Steps.mjs +1 -1
  155. package/dist/components/StepsItem.js +2 -2
  156. package/dist/components/StepsItem.mjs +1 -1
  157. package/dist/components/Table.js +2 -2
  158. package/dist/components/Table.mjs +1 -1
  159. package/dist/components/Tooltip.d.mts +12 -2
  160. package/dist/components/Tooltip.d.ts +12 -2
  161. package/dist/components/Tooltip.js +3 -2
  162. package/dist/components/Tooltip.mjs +2 -1
  163. package/dist/index.d.mts +97 -1
  164. package/dist/index.d.ts +97 -1
  165. package/dist/index.js +178 -108
  166. package/dist/index.mjs +41 -27
  167. package/package.json +2 -2
  168. package/dist/chunk-NEULKOYJ.js +0 -48
  169. package/dist/chunk-ZO4XVOHU.mjs +0 -45
@@ -0,0 +1,285 @@
1
+ 'use strict';
2
+
3
+ var chunkKQZ4F7FZ_js = require('./chunk-KQZ4F7FZ.js');
4
+ var chunkE5GD3H7L_js = require('./chunk-E5GD3H7L.js');
5
+ var chunkDUWAV47E_js = require('./chunk-DUWAV47E.js');
6
+ var chunk3QFHVAZT_js = require('./chunk-3QFHVAZT.js');
7
+ var chunk6PBNFLM7_js = require('./chunk-6PBNFLM7.js');
8
+ var chunkAX5XRD2Q_js = require('./chunk-AX5XRD2Q.js');
9
+ var chunkM375I56K_js = require('./chunk-M375I56K.js');
10
+ var react = require('react');
11
+ var tigercatCore = require('@expcat/tigercat-core');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+
14
+ var BarChart = ({
15
+ width = 320,
16
+ height = 200,
17
+ padding = 24,
18
+ data,
19
+ xScale,
20
+ yScale,
21
+ barColor = "var(--tiger-primary,#2563eb)",
22
+ barRadius = 4,
23
+ barPaddingInner = 0.2,
24
+ barPaddingOuter = 0.1,
25
+ showGrid = true,
26
+ showAxis = true,
27
+ showXAxis = true,
28
+ showYAxis = true,
29
+ xAxisLabel,
30
+ yAxisLabel,
31
+ xTicks = 5,
32
+ yTicks = 5,
33
+ xTickValues,
34
+ yTickValues,
35
+ xTickFormat,
36
+ yTickFormat,
37
+ gridLineStyle = "solid",
38
+ gridStrokeWidth = 1,
39
+ colors,
40
+ hoverable = false,
41
+ hoveredIndex: hoveredIndexProp,
42
+ activeOpacity = 1,
43
+ inactiveOpacity = 0.25,
44
+ selectable = false,
45
+ selectedIndex: selectedIndexProp,
46
+ showLegend = false,
47
+ legendPosition = "bottom",
48
+ legendMarkerSize = 10,
49
+ legendGap = 8,
50
+ showTooltip = true,
51
+ tooltipFormatter,
52
+ legendFormatter,
53
+ title,
54
+ desc,
55
+ className,
56
+ onHoveredIndexChange,
57
+ onSelectedIndexChange,
58
+ onBarClick,
59
+ onBarHover
60
+ }) => {
61
+ const {
62
+ tooltipPosition,
63
+ resolvedHoveredIndex,
64
+ activeIndex,
65
+ handleMouseEnter,
66
+ handleMouseMove,
67
+ handleMouseLeave,
68
+ handleClick,
69
+ handleKeyDown,
70
+ handleLegendClick,
71
+ handleLegendHover,
72
+ handleLegendLeave,
73
+ wrapperClasses
74
+ } = chunkKQZ4F7FZ_js.useChartInteraction({
75
+ hoverable,
76
+ hoveredIndexProp,
77
+ selectable,
78
+ selectedIndexProp,
79
+ activeOpacity,
80
+ inactiveOpacity,
81
+ legendPosition,
82
+ getData: (index) => data[index],
83
+ onHoveredIndexChange: (index) => {
84
+ onHoveredIndexChange?.(index);
85
+ onBarHover?.(index, index !== null ? data[index] : null);
86
+ },
87
+ onSelectedIndexChange,
88
+ callbacks: {
89
+ onClick: onBarClick
90
+ }
91
+ });
92
+ const innerRect = react.useMemo(
93
+ () => tigercatCore.getChartInnerRect(width, height, padding),
94
+ [width, height, padding]
95
+ );
96
+ const xDomain = react.useMemo(() => data.map((item) => String(item.x)), [data]);
97
+ const yValues = react.useMemo(() => data.map((item) => item.y), [data]);
98
+ const resolvedXScale = react.useMemo(() => {
99
+ if (xScale) return xScale;
100
+ return tigercatCore.createBandScale(xDomain, [0, innerRect.width], {
101
+ paddingInner: barPaddingInner,
102
+ paddingOuter: barPaddingOuter
103
+ });
104
+ }, [xScale, xDomain, innerRect.width, barPaddingInner, barPaddingOuter]);
105
+ const resolvedYScale = react.useMemo(() => {
106
+ if (yScale) return yScale;
107
+ const extent = tigercatCore.getNumberExtent(yValues, { includeZero: true });
108
+ return tigercatCore.createLinearScale(extent, [innerRect.height, 0]);
109
+ }, [yScale, yValues, innerRect.height]);
110
+ const palette = react.useMemo(
111
+ () => colors && colors.length > 0 ? colors : barColor ? [barColor] : [...tigercatCore.DEFAULT_CHART_COLORS],
112
+ [colors, barColor]
113
+ );
114
+ const bars = react.useMemo(() => {
115
+ const scale = resolvedXScale;
116
+ const bandWidth = scale.bandwidth ?? (scale.step ? scale.step * 0.7 : innerRect.width / Math.max(1, data.length) * 0.8);
117
+ const baseline = resolvedYScale.map(0);
118
+ return data.map((item, index) => {
119
+ const xKey = scale.type === "linear" ? Number(item.x) : String(item.x);
120
+ const xPos = scale.map(xKey);
121
+ const barX = scale.bandwidth ? xPos : xPos - bandWidth / 2;
122
+ const barYValue = resolvedYScale.map(item.y);
123
+ const barHeight = Math.abs(baseline - barYValue);
124
+ const barY = Math.min(baseline, barYValue);
125
+ const color = item.color ?? palette[index % palette.length];
126
+ const opacity = tigercatCore.getChartElementOpacity(index, activeIndex, {
127
+ activeOpacity,
128
+ inactiveOpacity
129
+ });
130
+ return {
131
+ x: barX,
132
+ y: barY,
133
+ width: bandWidth,
134
+ height: barHeight,
135
+ color,
136
+ opacity,
137
+ datum: item,
138
+ index
139
+ };
140
+ });
141
+ }, [
142
+ resolvedXScale,
143
+ resolvedYScale,
144
+ data,
145
+ innerRect.width,
146
+ palette,
147
+ activeIndex,
148
+ activeOpacity,
149
+ inactiveOpacity
150
+ ]);
151
+ const legendItems = react.useMemo(
152
+ () => data.map((item, index) => ({
153
+ index,
154
+ label: legendFormatter ? legendFormatter(item, index) : item.label ?? String(item.x),
155
+ color: item.color ?? palette[index % palette.length],
156
+ active: activeIndex === null || activeIndex === index
157
+ })),
158
+ [data, legendFormatter, palette, activeIndex]
159
+ );
160
+ const formatTooltip = react.useCallback(
161
+ (datum, index) => {
162
+ if (tooltipFormatter) return tooltipFormatter(datum, index);
163
+ const label = datum.label ?? String(datum.x);
164
+ return `${label}: ${datum.y}`;
165
+ },
166
+ [tooltipFormatter]
167
+ );
168
+ const tooltipContent = react.useMemo(() => {
169
+ if (resolvedHoveredIndex === null) return "";
170
+ const datum = data[resolvedHoveredIndex];
171
+ return datum ? formatTooltip(datum, resolvedHoveredIndex) : "";
172
+ }, [resolvedHoveredIndex, data, formatTooltip]);
173
+ const shouldShowXAxis = showAxis && showXAxis;
174
+ const shouldShowYAxis = showAxis && showYAxis;
175
+ const chart = /* @__PURE__ */ jsxRuntime.jsxs(
176
+ chunkDUWAV47E_js.ChartCanvas,
177
+ {
178
+ width,
179
+ height,
180
+ padding,
181
+ title,
182
+ desc,
183
+ className: tigercatCore.classNames(className),
184
+ children: [
185
+ showGrid && /* @__PURE__ */ jsxRuntime.jsx(
186
+ chunk3QFHVAZT_js.ChartGrid,
187
+ {
188
+ xScale: resolvedXScale,
189
+ yScale: resolvedYScale,
190
+ show: "both",
191
+ xTicks,
192
+ yTicks,
193
+ xTickValues,
194
+ yTickValues,
195
+ lineStyle: gridLineStyle,
196
+ strokeWidth: gridStrokeWidth
197
+ }
198
+ ),
199
+ shouldShowXAxis && /* @__PURE__ */ jsxRuntime.jsx(
200
+ chunkE5GD3H7L_js.ChartAxis,
201
+ {
202
+ scale: resolvedXScale,
203
+ orientation: "bottom",
204
+ y: innerRect.height,
205
+ ticks: xTicks,
206
+ tickValues: xTickValues,
207
+ tickFormat: xTickFormat,
208
+ label: xAxisLabel
209
+ }
210
+ ),
211
+ shouldShowYAxis && /* @__PURE__ */ jsxRuntime.jsx(
212
+ chunkE5GD3H7L_js.ChartAxis,
213
+ {
214
+ scale: resolvedYScale,
215
+ orientation: "left",
216
+ ticks: yTicks,
217
+ tickValues: yTickValues,
218
+ tickFormat: yTickFormat,
219
+ label: yAxisLabel
220
+ }
221
+ ),
222
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAX5XRD2Q_js.ChartSeries, { data, type: "bar", children: bars.map((bar) => /* @__PURE__ */ jsxRuntime.jsx(
223
+ "rect",
224
+ {
225
+ x: bar.x,
226
+ y: bar.y,
227
+ width: bar.width,
228
+ height: bar.height,
229
+ rx: barRadius,
230
+ ry: barRadius,
231
+ fill: bar.color,
232
+ opacity: bar.opacity,
233
+ className: tigercatCore.classNames(
234
+ "transition-opacity duration-150",
235
+ (hoverable || selectable) && "cursor-pointer"
236
+ ),
237
+ tabIndex: selectable ? 0 : void 0,
238
+ onMouseEnter: (e) => handleMouseEnter(bar.index, e),
239
+ onMouseMove: handleMouseMove,
240
+ onMouseLeave: handleMouseLeave,
241
+ onClick: () => handleClick(bar.index),
242
+ onKeyDown: (e) => handleKeyDown(e, bar.index)
243
+ },
244
+ `bar-${bar.index}`
245
+ )) })
246
+ ]
247
+ }
248
+ );
249
+ const tooltip = showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
250
+ chunkM375I56K_js.ChartTooltip,
251
+ {
252
+ content: tooltipContent,
253
+ visible: hoverable && resolvedHoveredIndex !== null && tooltipContent !== "",
254
+ x: tooltipPosition.x,
255
+ y: tooltipPosition.y
256
+ }
257
+ );
258
+ if (!showLegend) {
259
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block relative", children: [
260
+ chart,
261
+ tooltip
262
+ ] });
263
+ }
264
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClasses, children: [
265
+ chart,
266
+ /* @__PURE__ */ jsxRuntime.jsx(
267
+ chunk6PBNFLM7_js.ChartLegend,
268
+ {
269
+ items: legendItems,
270
+ position: legendPosition,
271
+ markerSize: legendMarkerSize,
272
+ gap: legendGap,
273
+ interactive: hoverable || selectable,
274
+ onItemClick: handleLegendClick,
275
+ onItemHover: handleLegendHover,
276
+ onItemLeave: handleLegendLeave
277
+ }
278
+ ),
279
+ tooltip
280
+ ] });
281
+ };
282
+ var BarChart_default = BarChart;
283
+
284
+ exports.BarChart = BarChart;
285
+ exports.BarChart_default = BarChart_default;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var chunkZYPEO2KY_js = require('./chunk-ZYPEO2KY.js');
3
4
  var react = require('react');
4
5
  var tigercatCore = require('@expcat/tigercat-core');
5
6
  var jsxRuntime = require('react/jsx-runtime');
6
7
 
7
- // src/components/Tooltip.tsx
8
8
  var tooltipIdCounter = 0;
9
9
  var createTooltipId = () => `tiger-tooltip-${++tooltipIdCounter}`;
10
10
  var Tooltip = ({
@@ -14,6 +14,7 @@ var Tooltip = ({
14
14
  trigger = "hover",
15
15
  placement = "top",
16
16
  disabled = false,
17
+ offset = 8,
17
18
  className,
18
19
  style,
19
20
  children,
@@ -25,6 +26,8 @@ var Tooltip = ({
25
26
  const [internalVisible, setInternalVisible] = react.useState(defaultVisible);
26
27
  const currentVisible = isControlled ? visible : internalVisible;
27
28
  const containerRef = react.useRef(null);
29
+ const triggerRef = react.useRef(null);
30
+ const floatingRef = react.useRef(null);
28
31
  const tooltipIdRef = react.useRef(null);
29
32
  if (!tooltipIdRef.current) {
30
33
  tooltipIdRef.current = createTooltipId();
@@ -32,6 +35,17 @@ var Tooltip = ({
32
35
  const tooltipId = tooltipIdRef.current;
33
36
  const tooltipContent = contentContent ?? content;
34
37
  const describedBy = tooltipContent != null ? tooltipId : void 0;
38
+ const {
39
+ x,
40
+ y,
41
+ placement: actualPlacement
42
+ } = chunkZYPEO2KY_js.useFloating({
43
+ referenceRef: triggerRef,
44
+ floatingRef,
45
+ enabled: currentVisible,
46
+ placement,
47
+ offset
48
+ });
35
49
  const setVisible = react.useCallback(
36
50
  (newVisible) => {
37
51
  if (disabled && newVisible) return;
@@ -62,35 +76,26 @@ var Tooltip = ({
62
76
  if (disabled || trigger !== "focus") return;
63
77
  setVisible(false);
64
78
  };
65
- react.useEffect(() => {
66
- if (!currentVisible || trigger !== "click") return;
67
- const handleClickOutside = (event) => {
68
- const target = event.target;
69
- if (!target) return;
70
- if (containerRef.current?.contains(target)) return;
71
- setVisible(false);
72
- };
73
- const timeoutId = setTimeout(() => {
74
- document.addEventListener("click", handleClickOutside);
75
- }, 0);
76
- return () => {
77
- clearTimeout(timeoutId);
78
- document.removeEventListener("click", handleClickOutside);
79
- };
80
- }, [currentVisible, trigger, setVisible]);
81
- react.useEffect(() => {
82
- if (!currentVisible) return;
83
- const handleKeyDown = (event) => {
84
- if (event.key !== "Escape") return;
85
- setVisible(false);
86
- };
87
- document.addEventListener("keydown", handleKeyDown);
88
- return () => document.removeEventListener("keydown", handleKeyDown);
89
- }, [currentVisible, setVisible]);
79
+ chunkZYPEO2KY_js.useClickOutside({
80
+ enabled: currentVisible && trigger === "click",
81
+ refs: [containerRef],
82
+ onOutsideClick: () => setVisible(false),
83
+ defer: true
84
+ });
85
+ chunkZYPEO2KY_js.useEscapeKey({
86
+ enabled: currentVisible,
87
+ onEscape: () => setVisible(false)
88
+ });
90
89
  const containerClasses = tigercatCore.classNames(tigercatCore.getTooltipContainerClasses(), className);
91
90
  const triggerClasses = tigercatCore.getTooltipTriggerClasses(disabled);
92
- const contentWrapperClasses = tigercatCore.getDropdownMenuWrapperClasses(currentVisible, placement);
93
91
  const contentClasses = tigercatCore.getTooltipContentClasses();
92
+ const floatingStyles = {
93
+ position: "absolute",
94
+ left: x,
95
+ top: y,
96
+ transformOrigin: tigercatCore.getTransformOrigin(actualPlacement),
97
+ zIndex: 1e3
98
+ };
94
99
  const triggerHandlers = {};
95
100
  if (trigger === "click") {
96
101
  triggerHandlers.onClick = handleTriggerClick;
@@ -105,8 +110,17 @@ var Tooltip = ({
105
110
  return null;
106
111
  }
107
112
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: containerClasses, style, ...divProps, children: [
108
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: triggerClasses, "aria-describedby": describedBy, ...triggerHandlers, children }),
109
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxRuntime.jsx("div", { id: tooltipId, role: "tooltip", className: contentClasses, children: tooltipContent }) })
113
+ /* @__PURE__ */ jsxRuntime.jsx(
114
+ "div",
115
+ {
116
+ ref: triggerRef,
117
+ className: triggerClasses,
118
+ "aria-describedby": describedBy,
119
+ ...triggerHandlers,
120
+ children
121
+ }
122
+ ),
123
+ currentVisible && /* @__PURE__ */ jsxRuntime.jsx("div", { ref: floatingRef, style: floatingStyles, "aria-hidden": false, children: /* @__PURE__ */ jsxRuntime.jsx("div", { id: tooltipId, role: "tooltip", className: contentClasses, children: tooltipContent }) })
110
124
  ] });
111
125
  };
112
126
 
@@ -56,7 +56,7 @@ var MessageItem = ({ message, onClose }) => {
56
56
  const iconClass = tigercatCore.classNames(tigercatCore.messageIconClasses, colorScheme.icon);
57
57
  const handleClose = react.useCallback(() => {
58
58
  setIsVisible(false);
59
- setTimeout(() => onClose(message.id), 300);
59
+ setTimeout(() => onClose(message.id), tigercatCore.ANIMATION_DURATION_MS);
60
60
  }, [message.id, onClose]);
61
61
  const a11yRole = message.type === "error" ? "alert" : "status";
62
62
  const ariaLive = message.type === "error" ? "assertive" : "polite";
@@ -0,0 +1,91 @@
1
+ import { useMemo } from 'react';
2
+ import { getChartAxisTicks, classNames, chartAxisLineClasses, chartAxisTickLineClasses, chartAxisTickTextClasses, chartAxisLabelClasses } from '@expcat/tigercat-core';
3
+ import { jsxs, jsx } from 'react/jsx-runtime';
4
+
5
+ // src/components/ChartAxis.tsx
6
+ var ChartAxis = ({
7
+ orientation = "bottom",
8
+ scale,
9
+ ticks = 5,
10
+ tickValues,
11
+ tickFormat,
12
+ tickSize = 6,
13
+ tickPadding = 4,
14
+ label,
15
+ labelOffset = 28,
16
+ x = 0,
17
+ y = 0,
18
+ className,
19
+ ...props
20
+ }) => {
21
+ const axisTicks = useMemo(
22
+ () => getChartAxisTicks(scale, {
23
+ tickCount: ticks,
24
+ tickValues,
25
+ tickFormat
26
+ }),
27
+ [scale, ticks, tickValues, tickFormat]
28
+ );
29
+ const isHorizontal = orientation === "top" || orientation === "bottom";
30
+ const isTopOrLeft = orientation === "top" || orientation === "left";
31
+ const rangeStart = scale.range[0];
32
+ const rangeEnd = scale.range[1];
33
+ const axisLine = isHorizontal ? { x1: rangeStart, y1: 0, x2: rangeEnd, y2: 0 } : { x1: 0, y1: rangeStart, x2: 0, y2: rangeEnd };
34
+ const tickDirection = isTopOrLeft ? -1 : 1;
35
+ const labelBase = tickSize + tickPadding + labelOffset;
36
+ const labelPosition = (rangeStart + rangeEnd) / 2;
37
+ return /* @__PURE__ */ jsxs("g", { ...props, className: classNames(className), transform: `translate(${x}, ${y})`, children: [
38
+ /* @__PURE__ */ jsx("line", { ...axisLine, className: chartAxisLineClasses, "data-axis-line": "true" }),
39
+ axisTicks.map((tick) => {
40
+ const textAnchor = isHorizontal ? "middle" : isTopOrLeft ? "end" : "start";
41
+ const tickLine = isHorizontal ? {
42
+ x1: tick.position,
43
+ y1: 0,
44
+ x2: tick.position,
45
+ y2: tickSize * tickDirection
46
+ } : {
47
+ x1: 0,
48
+ y1: tick.position,
49
+ x2: tickSize * tickDirection,
50
+ y2: tick.position
51
+ };
52
+ const textProps = isHorizontal ? {
53
+ x: tick.position,
54
+ y: tickSize * tickDirection + tickPadding * tickDirection,
55
+ textAnchor,
56
+ dy: isTopOrLeft ? "-0.32em" : "0.71em"
57
+ } : {
58
+ x: (tickSize + tickPadding) * tickDirection,
59
+ y: tick.position,
60
+ textAnchor,
61
+ dy: "0.32em"
62
+ };
63
+ return /* @__PURE__ */ jsxs("g", { "data-axis-tick": "true", children: [
64
+ /* @__PURE__ */ jsx("line", { ...tickLine, className: chartAxisTickLineClasses }),
65
+ /* @__PURE__ */ jsx("text", { ...textProps, className: chartAxisTickTextClasses, children: tick.label })
66
+ ] }, `${tick.value}`);
67
+ }),
68
+ label ? /* @__PURE__ */ jsx(
69
+ "text",
70
+ {
71
+ className: chartAxisLabelClasses,
72
+ "data-axis-label": "true",
73
+ ...isHorizontal ? {
74
+ x: labelPosition,
75
+ y: labelBase * tickDirection,
76
+ textAnchor: "middle",
77
+ dy: isTopOrLeft ? "-0.32em" : "0.71em"
78
+ } : {
79
+ x: labelBase * tickDirection,
80
+ y: labelPosition,
81
+ textAnchor: "middle",
82
+ transform: `rotate(${isTopOrLeft ? -90 : 90} ${labelBase * tickDirection} ${labelPosition})`
83
+ },
84
+ children: label
85
+ }
86
+ ) : null
87
+ ] });
88
+ };
89
+ var ChartAxis_default = ChartAxis;
90
+
91
+ export { ChartAxis, ChartAxis_default };
@@ -0,0 +1,32 @@
1
+ import { classNames } from '@expcat/tigercat-core';
2
+ import { jsx } from 'react/jsx-runtime';
3
+
4
+ // src/components/ChartSeries.tsx
5
+ var ChartSeries = ({
6
+ data,
7
+ name,
8
+ color,
9
+ opacity,
10
+ type,
11
+ className,
12
+ children,
13
+ ...props
14
+ }) => {
15
+ const content = typeof children === "function" ? children({ data, name, color, opacity, type }) : children;
16
+ return /* @__PURE__ */ jsx(
17
+ "g",
18
+ {
19
+ ...props,
20
+ className: classNames(className),
21
+ "data-series-name": name,
22
+ "data-series-type": type,
23
+ fill: color,
24
+ stroke: color,
25
+ opacity,
26
+ children: content
27
+ }
28
+ );
29
+ };
30
+ var ChartSeries_default = ChartSeries;
31
+
32
+ export { ChartSeries, ChartSeries_default };
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ var chunkN32MAX4A_js = require('./chunk-N32MAX4A.js');
4
+ var react = require('react');
5
+ var tigercatCore = require('@expcat/tigercat-core');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ var DonutChart = ({
9
+ width = 320,
10
+ height = 200,
11
+ padding = 24,
12
+ data,
13
+ innerRadius,
14
+ innerRadiusRatio = 0.6,
15
+ outerRadius,
16
+ startAngle = 0,
17
+ endAngle = Math.PI * 2,
18
+ padAngle = 0,
19
+ colors,
20
+ showLabels = false,
21
+ labelFormatter,
22
+ // Interaction props
23
+ hoverable = false,
24
+ hoveredIndex,
25
+ activeOpacity = 1,
26
+ inactiveOpacity = 0.25,
27
+ selectable = false,
28
+ selectedIndex,
29
+ // Legend props
30
+ showLegend = false,
31
+ legendPosition = "bottom",
32
+ legendMarkerSize = 10,
33
+ legendGap = 8,
34
+ // Tooltip props
35
+ showTooltip = true,
36
+ tooltipFormatter,
37
+ // Accessibility
38
+ title,
39
+ desc,
40
+ className,
41
+ // Callbacks
42
+ onHoveredIndexChange,
43
+ onSelectedIndexChange,
44
+ onSliceClick,
45
+ onSliceHover
46
+ }) => {
47
+ const innerRect = react.useMemo(
48
+ () => tigercatCore.getChartInnerRect(width, height, padding),
49
+ [width, height, padding]
50
+ );
51
+ const resolvedOuterRadius = react.useMemo(() => {
52
+ if (typeof outerRadius === "number") return Math.max(0, outerRadius);
53
+ return Math.max(0, Math.min(innerRect.width, innerRect.height) / 2);
54
+ }, [outerRadius, innerRect.width, innerRect.height]);
55
+ const resolvedInnerRadius = react.useMemo(() => {
56
+ if (typeof innerRadius === "number") {
57
+ return Math.min(Math.max(0, innerRadius), resolvedOuterRadius);
58
+ }
59
+ const ratio = Math.min(Math.max(innerRadiusRatio ?? 0.6, 0), 1);
60
+ return resolvedOuterRadius * ratio;
61
+ }, [innerRadius, innerRadiusRatio, resolvedOuterRadius]);
62
+ return /* @__PURE__ */ jsxRuntime.jsx(
63
+ chunkN32MAX4A_js.PieChart,
64
+ {
65
+ width,
66
+ height,
67
+ padding,
68
+ data,
69
+ innerRadius: resolvedInnerRadius,
70
+ outerRadius,
71
+ startAngle,
72
+ endAngle,
73
+ padAngle,
74
+ colors,
75
+ showLabels,
76
+ labelFormatter,
77
+ hoverable,
78
+ hoveredIndex,
79
+ activeOpacity,
80
+ inactiveOpacity,
81
+ selectable,
82
+ selectedIndex,
83
+ showLegend,
84
+ legendPosition,
85
+ legendMarkerSize,
86
+ legendGap,
87
+ showTooltip,
88
+ tooltipFormatter,
89
+ title,
90
+ desc,
91
+ className: tigercatCore.classNames(className),
92
+ onHoveredIndexChange,
93
+ onSelectedIndexChange,
94
+ onSliceClick,
95
+ onSliceHover
96
+ }
97
+ );
98
+ };
99
+ var DonutChart_default = DonutChart;
100
+
101
+ exports.DonutChart = DonutChart;
102
+ exports.DonutChart_default = DonutChart_default;