@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,275 @@
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 { useMemo, useCallback } from 'react';
9
+ import { getChartInnerRect, getNumberExtent, createLinearScale, DEFAULT_CHART_COLORS, getChartElementOpacity, classNames } from '@expcat/tigercat-core';
10
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
+
12
+ var ScatterChart = ({
13
+ width = 320,
14
+ height = 200,
15
+ padding = 24,
16
+ data,
17
+ xScale,
18
+ yScale,
19
+ pointSize = 4,
20
+ pointColor = "var(--tiger-primary,#2563eb)",
21
+ pointOpacity,
22
+ showGrid = true,
23
+ showAxis = true,
24
+ showXAxis = true,
25
+ showYAxis = true,
26
+ includeZero = false,
27
+ xAxisLabel,
28
+ yAxisLabel,
29
+ xTicks = 5,
30
+ yTicks = 5,
31
+ xTickValues,
32
+ yTickValues,
33
+ xTickFormat,
34
+ yTickFormat,
35
+ gridLineStyle = "solid",
36
+ gridStrokeWidth = 1,
37
+ // Interaction props
38
+ hoverable = false,
39
+ hoveredIndex: hoveredIndexProp,
40
+ onHoveredIndexChange,
41
+ activeOpacity = 1,
42
+ inactiveOpacity = 0.25,
43
+ selectable = false,
44
+ selectedIndex: selectedIndexProp,
45
+ onSelectedIndexChange,
46
+ onPointClick,
47
+ onPointHover,
48
+ // Legend props
49
+ showLegend = false,
50
+ legendPosition = "bottom",
51
+ legendMarkerSize = 10,
52
+ legendGap = 8,
53
+ legendFormatter,
54
+ // Tooltip props
55
+ showTooltip = true,
56
+ tooltipFormatter,
57
+ // Other
58
+ colors,
59
+ title,
60
+ desc,
61
+ className
62
+ }) => {
63
+ const {
64
+ tooltipPosition,
65
+ resolvedHoveredIndex,
66
+ activeIndex,
67
+ handleMouseEnter,
68
+ handleMouseMove,
69
+ handleMouseLeave,
70
+ handleClick,
71
+ handleKeyDown,
72
+ handleLegendClick,
73
+ handleLegendHover,
74
+ handleLegendLeave,
75
+ wrapperClasses
76
+ } = useChartInteraction({
77
+ hoverable,
78
+ hoveredIndexProp,
79
+ selectable,
80
+ selectedIndexProp,
81
+ activeOpacity,
82
+ inactiveOpacity,
83
+ legendPosition,
84
+ getData: (index) => data[index],
85
+ onHoveredIndexChange: (index) => {
86
+ onHoveredIndexChange?.(index);
87
+ onPointHover?.(index, index !== null ? data[index] : null);
88
+ },
89
+ onSelectedIndexChange,
90
+ callbacks: {
91
+ onClick: onPointClick
92
+ }
93
+ });
94
+ const innerRect = useMemo(
95
+ () => getChartInnerRect(width, height, padding),
96
+ [width, height, padding]
97
+ );
98
+ const xValues = useMemo(() => data.map((item) => item.x), [data]);
99
+ const yValues = useMemo(() => data.map((item) => item.y), [data]);
100
+ const resolvedXScale = useMemo(() => {
101
+ if (xScale) return xScale;
102
+ const extent = getNumberExtent(xValues, { includeZero });
103
+ return createLinearScale(extent, [0, innerRect.width]);
104
+ }, [xScale, xValues, includeZero, innerRect.width]);
105
+ const resolvedYScale = useMemo(() => {
106
+ if (yScale) return yScale;
107
+ const extent = getNumberExtent(yValues, { includeZero });
108
+ return createLinearScale(extent, [innerRect.height, 0]);
109
+ }, [yScale, yValues, includeZero, innerRect.height]);
110
+ const palette = useMemo(
111
+ () => colors && colors.length > 0 ? colors : pointColor ? [pointColor] : [...DEFAULT_CHART_COLORS],
112
+ [colors, pointColor]
113
+ );
114
+ const points = useMemo(
115
+ () => data.map((item, index) => {
116
+ const color = item.color ?? palette[index % palette.length];
117
+ const opacity = getChartElementOpacity(index, activeIndex, {
118
+ activeOpacity,
119
+ inactiveOpacity
120
+ });
121
+ return {
122
+ cx: resolvedXScale.map(item.x),
123
+ cy: resolvedYScale.map(item.y),
124
+ r: item.size ?? pointSize,
125
+ color,
126
+ opacity: pointOpacity ?? opacity,
127
+ datum: item
128
+ };
129
+ }),
130
+ [
131
+ data,
132
+ palette,
133
+ activeIndex,
134
+ activeOpacity,
135
+ inactiveOpacity,
136
+ resolvedXScale,
137
+ resolvedYScale,
138
+ pointSize,
139
+ pointOpacity
140
+ ]
141
+ );
142
+ const legendItems = useMemo(
143
+ () => data.map((item, index) => ({
144
+ index,
145
+ label: legendFormatter ? legendFormatter(item, index) : item.label ?? `(${item.x}, ${item.y})`,
146
+ color: item.color ?? palette[index % palette.length],
147
+ active: activeIndex === null || activeIndex === index
148
+ })),
149
+ [data, legendFormatter, palette, activeIndex]
150
+ );
151
+ const formatTooltip = useCallback(
152
+ (datum, index) => {
153
+ if (tooltipFormatter) return tooltipFormatter(datum, index);
154
+ const label = datum.label ?? `Point ${index + 1}`;
155
+ return `${label}: (${datum.x}, ${datum.y})`;
156
+ },
157
+ [tooltipFormatter]
158
+ );
159
+ const tooltipContent = useMemo(() => {
160
+ if (resolvedHoveredIndex === null) return "";
161
+ const datum = data[resolvedHoveredIndex];
162
+ return datum ? formatTooltip(datum, resolvedHoveredIndex) : "";
163
+ }, [resolvedHoveredIndex, data, formatTooltip]);
164
+ const shouldShowXAxis = showAxis && showXAxis;
165
+ const shouldShowYAxis = showAxis && showYAxis;
166
+ const chart = /* @__PURE__ */ jsxs(
167
+ ChartCanvas,
168
+ {
169
+ width,
170
+ height,
171
+ padding,
172
+ title,
173
+ desc,
174
+ className: classNames(className),
175
+ children: [
176
+ showGrid && /* @__PURE__ */ jsx(
177
+ ChartGrid,
178
+ {
179
+ xScale: resolvedXScale,
180
+ yScale: resolvedYScale,
181
+ show: "both",
182
+ xTicks,
183
+ yTicks,
184
+ xTickValues,
185
+ yTickValues,
186
+ lineStyle: gridLineStyle,
187
+ strokeWidth: gridStrokeWidth
188
+ }
189
+ ),
190
+ shouldShowXAxis && /* @__PURE__ */ jsx(
191
+ ChartAxis,
192
+ {
193
+ scale: resolvedXScale,
194
+ orientation: "bottom",
195
+ y: innerRect.height,
196
+ ticks: xTicks,
197
+ tickValues: xTickValues,
198
+ tickFormat: xTickFormat,
199
+ label: xAxisLabel
200
+ }
201
+ ),
202
+ shouldShowYAxis && /* @__PURE__ */ jsx(
203
+ ChartAxis,
204
+ {
205
+ scale: resolvedYScale,
206
+ orientation: "left",
207
+ ticks: yTicks,
208
+ tickValues: yTickValues,
209
+ tickFormat: yTickFormat,
210
+ label: yAxisLabel
211
+ }
212
+ ),
213
+ /* @__PURE__ */ jsx(ChartSeries, { data, type: "scatter", children: points.map((point, index) => /* @__PURE__ */ jsx(
214
+ "circle",
215
+ {
216
+ cx: point.cx,
217
+ cy: point.cy,
218
+ r: point.r,
219
+ fill: point.color,
220
+ opacity: point.opacity,
221
+ className: classNames(
222
+ "transition-opacity duration-150",
223
+ (hoverable || selectable) && "cursor-pointer"
224
+ ),
225
+ tabIndex: selectable ? 0 : void 0,
226
+ role: selectable ? "button" : "img",
227
+ "aria-label": point.datum.label ?? `Point ${index + 1}: (${point.datum.x}, ${point.datum.y})`,
228
+ "data-point-index": index,
229
+ onMouseEnter: (e) => handleMouseEnter(index, e),
230
+ onMouseMove: handleMouseMove,
231
+ onMouseLeave: handleMouseLeave,
232
+ onClick: () => handleClick(index),
233
+ onKeyDown: (e) => handleKeyDown(e, index)
234
+ },
235
+ `point-${index}`
236
+ )) })
237
+ ]
238
+ }
239
+ );
240
+ const tooltip = showTooltip && hoverable && /* @__PURE__ */ jsx(
241
+ ChartTooltip,
242
+ {
243
+ content: tooltipContent,
244
+ visible: resolvedHoveredIndex !== null && tooltipContent !== "",
245
+ x: tooltipPosition.x,
246
+ y: tooltipPosition.y
247
+ }
248
+ );
249
+ if (!showLegend) {
250
+ return /* @__PURE__ */ jsxs("div", { className: "inline-block relative", children: [
251
+ chart,
252
+ tooltip
253
+ ] });
254
+ }
255
+ return /* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
256
+ chart,
257
+ /* @__PURE__ */ jsx(
258
+ ChartLegend,
259
+ {
260
+ items: legendItems,
261
+ position: legendPosition,
262
+ markerSize: legendMarkerSize,
263
+ gap: legendGap,
264
+ interactive: hoverable || selectable,
265
+ onItemClick: handleLegendClick,
266
+ onItemHover: handleLegendHover,
267
+ onItemLeave: handleLegendLeave
268
+ }
269
+ ),
270
+ tooltip
271
+ ] });
272
+ };
273
+ var ScatterChart_default = ScatterChart;
274
+
275
+ export { ScatterChart, ScatterChart_default };
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useCallback } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
3
  import { flushSync } from 'react-dom';
4
- import { classNames, messageContainerBaseClasses, messagePositionClasses, getMessageTypeClasses, defaultMessageThemeColors, messageBaseClasses, getMessageIconPath, messageIconClasses, messageContentClasses, messageCloseButtonClasses, messageCloseIconPath, isBrowser, messageLoadingSpinnerClasses, icon24StrokeWidth, icon24ViewBox, icon24PathStrokeLinejoin, icon24PathStrokeLinecap } from '@expcat/tigercat-core';
4
+ import { classNames, messageContainerBaseClasses, messagePositionClasses, getMessageTypeClasses, defaultMessageThemeColors, messageBaseClasses, getMessageIconPath, messageIconClasses, ANIMATION_DURATION_MS, messageContentClasses, messageCloseButtonClasses, messageCloseIconPath, isBrowser, messageLoadingSpinnerClasses, icon24StrokeWidth, icon24ViewBox, icon24PathStrokeLinejoin, icon24PathStrokeLinecap } from '@expcat/tigercat-core';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
6
6
 
7
7
  // src/components/Message.tsx
@@ -54,7 +54,7 @@ var MessageItem = ({ message, onClose }) => {
54
54
  const iconClass = classNames(messageIconClasses, colorScheme.icon);
55
55
  const handleClose = useCallback(() => {
56
56
  setIsVisible(false);
57
- setTimeout(() => onClose(message.id), 300);
57
+ setTimeout(() => onClose(message.id), ANIMATION_DURATION_MS);
58
58
  }, [message.id, onClose]);
59
59
  const a11yRole = message.type === "error" ? "alert" : "status";
60
60
  const ariaLive = message.type === "error" ? "assertive" : "polite";
@@ -1,5 +1,6 @@
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');
@@ -8,7 +9,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
9
10
  var React__default = /*#__PURE__*/_interopDefault(React);
10
11
 
11
- // src/components/Popconfirm.tsx
12
12
  var popconfirmIdCounter = 0;
13
13
  var createPopconfirmId = () => `tiger-popconfirm-${++popconfirmIdCounter}`;
14
14
  var PopconfirmIcon = ({ type }) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -39,7 +39,8 @@ var Popconfirm = ({
39
39
  okText = "\u786E\u5B9A",
40
40
  cancelText = "\u53D6\u6D88",
41
41
  okType = "primary",
42
- placement = "top",
42
+ placement: initialPlacement = "top",
43
+ offset = 8,
43
44
  disabled = false,
44
45
  className,
45
46
  style,
@@ -55,6 +56,8 @@ var Popconfirm = ({
55
56
  const [internalVisible, setInternalVisible] = React.useState(defaultVisible);
56
57
  const currentVisible = isControlled ? visible : internalVisible;
57
58
  const containerRef = React.useRef(null);
59
+ const triggerRef = React.useRef(null);
60
+ const floatingRef = React.useRef(null);
58
61
  const popconfirmIdRef = React.useRef(null);
59
62
  if (!popconfirmIdRef.current) {
60
63
  popconfirmIdRef.current = createPopconfirmId();
@@ -82,40 +85,40 @@ var Popconfirm = ({
82
85
  if (disabled) return;
83
86
  setVisible(!currentVisible);
84
87
  };
85
- React.useEffect(() => {
86
- if (!currentVisible) return;
87
- const handleClickOutside = (event) => {
88
- const target = event.target;
89
- if (!target) return;
90
- if (containerRef.current?.contains(target)) return;
91
- setVisible(false);
92
- };
93
- const timeoutId = window.setTimeout(() => {
94
- document.addEventListener("click", handleClickOutside);
95
- }, 0);
96
- return () => {
97
- clearTimeout(timeoutId);
98
- document.removeEventListener("click", handleClickOutside);
99
- };
100
- }, [currentVisible]);
101
- React.useEffect(() => {
102
- if (!currentVisible) return;
103
- const handleKeyDown = (event) => {
104
- if (event.key !== "Escape") return;
105
- setVisible(false);
106
- };
107
- document.addEventListener("keydown", handleKeyDown);
108
- return () => document.removeEventListener("keydown", handleKeyDown);
109
- }, [currentVisible]);
88
+ const { x, y, placement } = chunkZYPEO2KY_js.useFloating({
89
+ referenceRef: triggerRef,
90
+ floatingRef,
91
+ enabled: currentVisible,
92
+ placement: initialPlacement,
93
+ offset
94
+ });
95
+ const handleOutsideClick = React.useCallback(() => setVisible(false), []);
96
+ const handleEscape = React.useCallback(() => setVisible(false), []);
97
+ chunkZYPEO2KY_js.useClickOutside({
98
+ enabled: currentVisible,
99
+ refs: [containerRef],
100
+ onOutsideClick: handleOutsideClick,
101
+ defer: true
102
+ });
103
+ chunkZYPEO2KY_js.useEscapeKey({
104
+ enabled: currentVisible,
105
+ onEscape: handleEscape
106
+ });
107
+ const contentWrapperStyles = React.useMemo(
108
+ () => ({
109
+ position: "absolute",
110
+ left: x,
111
+ top: y,
112
+ transformOrigin: tigercatCore.getTransformOrigin(placement)
113
+ }),
114
+ [x, y, placement]
115
+ );
110
116
  const containerClasses = React.useMemo(
111
117
  () => tigercatCore.classNames(tigercatCore.getPopconfirmContainerClasses(), className),
112
118
  [className]
113
119
  );
114
120
  const triggerClasses = React.useMemo(() => tigercatCore.getPopconfirmTriggerClasses(disabled), [disabled]);
115
- const contentWrapperClasses = React.useMemo(
116
- () => tigercatCore.getDropdownMenuWrapperClasses(Boolean(currentVisible), placement),
117
- [currentVisible, placement]
118
- );
121
+ const contentWrapperClasses = React.useMemo(() => "absolute z-50", []);
119
122
  const arrowClasses = React.useMemo(() => tigercatCore.getPopconfirmArrowClasses(placement), [placement]);
120
123
  const contentClasses = React.useMemo(() => tigercatCore.getPopconfirmContentClasses(), []);
121
124
  const titleClasses = React.useMemo(() => tigercatCore.getPopconfirmTitleClasses(), []);
@@ -171,34 +174,44 @@ var Popconfirm = ({
171
174
  );
172
175
  })();
173
176
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: containerClasses, style: mergedStyle, ...divProps, children: [
174
- triggerNode,
175
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
176
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowClasses, "aria-hidden": "true" }),
177
- /* @__PURE__ */ jsxRuntime.jsxs(
178
- "div",
179
- {
180
- id: popconfirmId,
181
- role: "dialog",
182
- "aria-modal": "false",
183
- "aria-labelledby": titleId,
184
- "aria-describedby": describedBy,
185
- className: contentClasses,
186
- children: [
187
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
188
- showIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: iconClasses, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PopconfirmIcon, { type: icon }) }),
189
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
190
- /* @__PURE__ */ jsxRuntime.jsx("div", { id: titleId, className: titleClasses, children: titleContent || title }),
191
- (description || descriptionContent) && /* @__PURE__ */ jsxRuntime.jsx("div", { id: descriptionId, className: descriptionClasses, children: descriptionContent || description })
192
- ] })
193
- ] }),
194
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: buttonsClasses, children: [
195
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cancelButtonClasses, onClick: handleCancel, children: cancelText }),
196
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: okButtonClasses, onClick: handleConfirm, children: okText })
197
- ] })
198
- ]
199
- }
200
- )
201
- ] }) })
177
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, children: triggerNode }),
178
+ /* @__PURE__ */ jsxRuntime.jsx(
179
+ "div",
180
+ {
181
+ ref: floatingRef,
182
+ className: contentWrapperClasses,
183
+ style: contentWrapperStyles,
184
+ hidden: !currentVisible,
185
+ "aria-hidden": !currentVisible,
186
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
187
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowClasses, "aria-hidden": "true" }),
188
+ /* @__PURE__ */ jsxRuntime.jsxs(
189
+ "div",
190
+ {
191
+ id: popconfirmId,
192
+ role: "dialog",
193
+ "aria-modal": "false",
194
+ "aria-labelledby": titleId,
195
+ "aria-describedby": describedBy,
196
+ className: contentClasses,
197
+ children: [
198
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
199
+ showIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: iconClasses, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PopconfirmIcon, { type: icon }) }),
200
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
201
+ /* @__PURE__ */ jsxRuntime.jsx("div", { id: titleId, className: titleClasses, children: titleContent || title }),
202
+ (description || descriptionContent) && /* @__PURE__ */ jsxRuntime.jsx("div", { id: descriptionId, className: descriptionClasses, children: descriptionContent || description })
203
+ ] })
204
+ ] }),
205
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: buttonsClasses, children: [
206
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cancelButtonClasses, onClick: handleCancel, children: cancelText }),
207
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: okButtonClasses, onClick: handleConfirm, children: okText })
208
+ ] })
209
+ ]
210
+ }
211
+ )
212
+ ] })
213
+ }
214
+ )
202
215
  ] });
203
216
  };
204
217
 
@@ -0,0 +1,42 @@
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/ChartCanvas.tsx
8
+ var ChartCanvas = ({
9
+ width = 320,
10
+ height = 200,
11
+ padding = 24,
12
+ className,
13
+ title,
14
+ desc,
15
+ children,
16
+ ...props
17
+ }) => {
18
+ const innerRect = react.useMemo(
19
+ () => tigercatCore.getChartInnerRect(width, height, padding),
20
+ [width, height, padding]
21
+ );
22
+ const svgClasses = react.useMemo(() => tigercatCore.classNames(tigercatCore.chartCanvasBaseClasses, className), [className]);
23
+ return /* @__PURE__ */ jsxRuntime.jsxs(
24
+ "svg",
25
+ {
26
+ ...props,
27
+ width,
28
+ height,
29
+ viewBox: `0 0 ${width} ${height}`,
30
+ className: svgClasses,
31
+ children: [
32
+ title ? /* @__PURE__ */ jsxRuntime.jsx("title", { children: title }) : null,
33
+ desc ? /* @__PURE__ */ jsxRuntime.jsx("desc", { children: desc }) : null,
34
+ /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${innerRect.x}, ${innerRect.y})`, children })
35
+ ]
36
+ }
37
+ );
38
+ };
39
+ var ChartCanvas_default = ChartCanvas;
40
+
41
+ exports.ChartCanvas = ChartCanvas;
42
+ exports.ChartCanvas_default = ChartCanvas_default;
@@ -0,0 +1,94 @@
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/ChartAxis.tsx
8
+ var ChartAxis = ({
9
+ orientation = "bottom",
10
+ scale,
11
+ ticks = 5,
12
+ tickValues,
13
+ tickFormat,
14
+ tickSize = 6,
15
+ tickPadding = 4,
16
+ label,
17
+ labelOffset = 28,
18
+ x = 0,
19
+ y = 0,
20
+ className,
21
+ ...props
22
+ }) => {
23
+ const axisTicks = react.useMemo(
24
+ () => tigercatCore.getChartAxisTicks(scale, {
25
+ tickCount: ticks,
26
+ tickValues,
27
+ tickFormat
28
+ }),
29
+ [scale, ticks, tickValues, tickFormat]
30
+ );
31
+ const isHorizontal = orientation === "top" || orientation === "bottom";
32
+ const isTopOrLeft = orientation === "top" || orientation === "left";
33
+ const rangeStart = scale.range[0];
34
+ const rangeEnd = scale.range[1];
35
+ const axisLine = isHorizontal ? { x1: rangeStart, y1: 0, x2: rangeEnd, y2: 0 } : { x1: 0, y1: rangeStart, x2: 0, y2: rangeEnd };
36
+ const tickDirection = isTopOrLeft ? -1 : 1;
37
+ const labelBase = tickSize + tickPadding + labelOffset;
38
+ const labelPosition = (rangeStart + rangeEnd) / 2;
39
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { ...props, className: tigercatCore.classNames(className), transform: `translate(${x}, ${y})`, children: [
40
+ /* @__PURE__ */ jsxRuntime.jsx("line", { ...axisLine, className: tigercatCore.chartAxisLineClasses, "data-axis-line": "true" }),
41
+ axisTicks.map((tick) => {
42
+ const textAnchor = isHorizontal ? "middle" : isTopOrLeft ? "end" : "start";
43
+ const tickLine = isHorizontal ? {
44
+ x1: tick.position,
45
+ y1: 0,
46
+ x2: tick.position,
47
+ y2: tickSize * tickDirection
48
+ } : {
49
+ x1: 0,
50
+ y1: tick.position,
51
+ x2: tickSize * tickDirection,
52
+ y2: tick.position
53
+ };
54
+ const textProps = isHorizontal ? {
55
+ x: tick.position,
56
+ y: tickSize * tickDirection + tickPadding * tickDirection,
57
+ textAnchor,
58
+ dy: isTopOrLeft ? "-0.32em" : "0.71em"
59
+ } : {
60
+ x: (tickSize + tickPadding) * tickDirection,
61
+ y: tick.position,
62
+ textAnchor,
63
+ dy: "0.32em"
64
+ };
65
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { "data-axis-tick": "true", children: [
66
+ /* @__PURE__ */ jsxRuntime.jsx("line", { ...tickLine, className: tigercatCore.chartAxisTickLineClasses }),
67
+ /* @__PURE__ */ jsxRuntime.jsx("text", { ...textProps, className: tigercatCore.chartAxisTickTextClasses, children: tick.label })
68
+ ] }, `${tick.value}`);
69
+ }),
70
+ label ? /* @__PURE__ */ jsxRuntime.jsx(
71
+ "text",
72
+ {
73
+ className: tigercatCore.chartAxisLabelClasses,
74
+ "data-axis-label": "true",
75
+ ...isHorizontal ? {
76
+ x: labelPosition,
77
+ y: labelBase * tickDirection,
78
+ textAnchor: "middle",
79
+ dy: isTopOrLeft ? "-0.32em" : "0.71em"
80
+ } : {
81
+ x: labelBase * tickDirection,
82
+ y: labelPosition,
83
+ textAnchor: "middle",
84
+ transform: `rotate(${isTopOrLeft ? -90 : 90} ${labelBase * tickDirection} ${labelPosition})`
85
+ },
86
+ children: label
87
+ }
88
+ ) : null
89
+ ] });
90
+ };
91
+ var ChartAxis_default = ChartAxis;
92
+
93
+ exports.ChartAxis = ChartAxis;
94
+ exports.ChartAxis_default = ChartAxis_default;