@expcat/tigercat-react 0.1.8 → 0.2.10

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 (170) hide show
  1. package/README.md +59 -0
  2. package/dist/{chunk-TBIEWDY5.js → chunk-36RRHNZD.js} +13 -2
  3. package/dist/chunk-3CDAG4HD.mjs +151 -0
  4. package/dist/chunk-3QFHVAZT.js +68 -0
  5. package/dist/{chunk-ALP3KYYY.mjs → chunk-3XKBDV2Q.mjs} +5 -5
  6. package/dist/chunk-42UKIFFQ.js +278 -0
  7. package/dist/{chunk-K7ZMB2TH.mjs → chunk-5XKYWZZZ.mjs} +16 -22
  8. package/dist/chunk-677VSTPW.mjs +65 -0
  9. package/dist/chunk-6DYS4PJT.mjs +99 -0
  10. package/dist/chunk-6PBNFLM7.js +95 -0
  11. package/dist/{chunk-DCRVIDMY.mjs → chunk-6ZC7H22S.mjs} +1 -1
  12. package/dist/{chunk-WSCSDSV7.mjs → chunk-7IKJBQQV.mjs} +27 -5
  13. package/dist/{chunk-OTRGVENC.js → chunk-7SLNHUGJ.js} +1 -1
  14. package/dist/chunk-A2UW5OKX.mjs +415 -0
  15. package/dist/{chunk-NOOPXNR4.mjs → chunk-AGUPZEUL.mjs} +2 -3
  16. package/dist/chunk-AX5XRD2Q.js +35 -0
  17. package/dist/{chunk-BJU5N7WU.mjs → chunk-BAPR7UUR.mjs} +7 -7
  18. package/dist/chunk-CBALIFPW.mjs +275 -0
  19. package/dist/{chunk-BIWO5KB4.mjs → chunk-CJJ56NVL.mjs} +2 -2
  20. package/dist/{chunk-ENR3RIMM.js → chunk-DGBYGBLR.js} +72 -59
  21. package/dist/chunk-DUWAV47E.js +42 -0
  22. package/dist/chunk-E5GD3H7L.js +94 -0
  23. package/dist/chunk-EJLJYOO7.js +367 -0
  24. package/dist/{chunk-FQ6UHRAO.js → chunk-GQMYCYZ4.js} +6 -27
  25. package/dist/{chunk-G6FSHN2I.mjs → chunk-GW4EWT2K.mjs} +45 -31
  26. package/dist/{chunk-AQQRWISY.js → chunk-GXTBCX3M.js} +1 -1
  27. package/dist/{chunk-HQXZVTP4.mjs → chunk-HGF2EL25.mjs} +74 -61
  28. package/dist/{chunk-R5BQHZWB.js → chunk-HRYBEBZC.js} +15 -21
  29. package/dist/{chunk-PAD2DX5M.mjs → chunk-IIVRVCCP.mjs} +6 -24
  30. package/dist/chunk-IS467WAO.mjs +39 -0
  31. package/dist/{chunk-CTAMMQBC.mjs → chunk-IS7YOBR7.mjs} +16 -13
  32. package/dist/{chunk-ADOPAXPG.mjs → chunk-JI7SFMUT.mjs} +2 -2
  33. package/dist/chunk-KBGURVTD.mjs +282 -0
  34. package/dist/{chunk-O3EUFIOS.mjs → chunk-KELLYJZY.mjs} +36 -30
  35. package/dist/{chunk-XZDJ5FRB.js → chunk-KPZTGRNA.js} +5 -23
  36. package/dist/chunk-KQZ4F7FZ.js +153 -0
  37. package/dist/{chunk-XDKXL2BP.mjs → chunk-KV4LLPAY.mjs} +14 -3
  38. package/dist/{chunk-LNKI6HQ3.js → chunk-LIJLFLYE.js} +27 -5
  39. package/dist/chunk-LVC43YX2.mjs +72 -0
  40. package/dist/chunk-LZNG2HGC.mjs +227 -0
  41. package/dist/chunk-M375I56K.js +75 -0
  42. package/dist/{chunk-7OLWGHUR.mjs → chunk-MF3H7WWW.mjs} +13 -2
  43. package/dist/chunk-N32MAX4A.js +230 -0
  44. package/dist/{chunk-YYKJ63LD.mjs → chunk-NMDNLB3C.mjs} +7 -28
  45. package/dist/{chunk-77D7VQMG.js → chunk-OD2NNQD2.js} +2 -2
  46. package/dist/chunk-OONM7FO7.js +418 -0
  47. package/dist/{chunk-Q5Q7FG4U.js → chunk-OZLGNWET.js} +7 -7
  48. package/dist/{chunk-LAZGEMA2.mjs → chunk-P4EFJIXU.mjs} +1 -1
  49. package/dist/chunk-QI6WAP6Y.js +285 -0
  50. package/dist/{chunk-WK5HN4OH.js → chunk-QY6I7LU5.js} +43 -29
  51. package/dist/{chunk-KSW5JDIV.js → chunk-R7TOQU3U.js} +1 -1
  52. package/dist/chunk-RQSQXQN6.mjs +91 -0
  53. package/dist/chunk-SDLMB34Y.mjs +32 -0
  54. package/dist/chunk-UG3I4PCY.js +102 -0
  55. package/dist/chunk-VBSK4TGO.mjs +364 -0
  56. package/dist/{chunk-DZJUFU55.js → chunk-VXHBQTZS.js} +14 -11
  57. package/dist/chunk-WLIFEALE.mjs +111 -0
  58. package/dist/{chunk-AQ6DHCP6.js → chunk-XRFK2IXM.js} +4 -4
  59. package/dist/{chunk-5FRENLDC.js → chunk-Y2JOJ4D6.js} +14 -3
  60. package/dist/chunk-YER7IQF4.mjs +429 -0
  61. package/dist/{chunk-NI2WNZRT.js → chunk-YESS6YKC.js} +1 -2
  62. package/dist/chunk-Z6F67MJE.mjs +92 -0
  63. package/dist/{chunk-QORSSZX4.js → chunk-ZPFZMXA6.js} +34 -28
  64. package/dist/chunk-ZUUG3WOL.js +432 -0
  65. package/dist/chunk-ZYPEO2KY.js +115 -0
  66. package/dist/components/AreaChart.d.mts +19 -0
  67. package/dist/components/AreaChart.d.ts +19 -0
  68. package/dist/components/AreaChart.js +23 -0
  69. package/dist/components/AreaChart.mjs +8 -0
  70. package/dist/components/BarChart.d.mts +16 -0
  71. package/dist/components/BarChart.d.ts +16 -0
  72. package/dist/components/BarChart.js +23 -0
  73. package/dist/components/BarChart.mjs +8 -0
  74. package/dist/components/ChartAxis.d.mts +10 -0
  75. package/dist/components/ChartAxis.d.ts +10 -0
  76. package/dist/components/ChartAxis.js +16 -0
  77. package/dist/components/ChartAxis.mjs +1 -0
  78. package/dist/components/ChartCanvas.d.mts +9 -0
  79. package/dist/components/ChartCanvas.d.ts +9 -0
  80. package/dist/components/ChartCanvas.js +16 -0
  81. package/dist/components/ChartCanvas.mjs +1 -0
  82. package/dist/components/ChartGrid.d.mts +11 -0
  83. package/dist/components/ChartGrid.d.ts +11 -0
  84. package/dist/components/ChartGrid.js +16 -0
  85. package/dist/components/ChartGrid.mjs +1 -0
  86. package/dist/components/ChartLegend.d.mts +17 -0
  87. package/dist/components/ChartLegend.d.ts +17 -0
  88. package/dist/components/ChartLegend.js +16 -0
  89. package/dist/components/ChartLegend.mjs +1 -0
  90. package/dist/components/ChartSeries.d.mts +18 -0
  91. package/dist/components/ChartSeries.d.ts +18 -0
  92. package/dist/components/ChartSeries.js +16 -0
  93. package/dist/components/ChartSeries.mjs +1 -0
  94. package/dist/components/ChartTooltip.d.mts +12 -0
  95. package/dist/components/ChartTooltip.d.ts +12 -0
  96. package/dist/components/ChartTooltip.js +16 -0
  97. package/dist/components/ChartTooltip.mjs +1 -0
  98. package/dist/components/DonutChart.d.mts +14 -0
  99. package/dist/components/DonutChart.d.ts +14 -0
  100. package/dist/components/DonutChart.js +21 -0
  101. package/dist/components/DonutChart.mjs +6 -0
  102. package/dist/components/Drawer.js +3 -3
  103. package/dist/components/Drawer.mjs +2 -2
  104. package/dist/components/Dropdown.d.mts +12 -2
  105. package/dist/components/Dropdown.d.ts +12 -2
  106. package/dist/components/Dropdown.js +4 -4
  107. package/dist/components/Dropdown.mjs +2 -2
  108. package/dist/components/DropdownItem.js +4 -4
  109. package/dist/components/DropdownItem.mjs +3 -3
  110. package/dist/components/Icon.js +2 -2
  111. package/dist/components/Icon.mjs +1 -1
  112. package/dist/components/LineChart.d.mts +19 -0
  113. package/dist/components/LineChart.d.ts +19 -0
  114. package/dist/components/LineChart.js +23 -0
  115. package/dist/components/LineChart.mjs +8 -0
  116. package/dist/components/List.js +3 -3
  117. package/dist/components/List.mjs +2 -2
  118. package/dist/components/Message.js +4 -4
  119. package/dist/components/Message.mjs +1 -1
  120. package/dist/components/Modal.js +3 -3
  121. package/dist/components/Modal.mjs +2 -2
  122. package/dist/components/Notification.js +4 -4
  123. package/dist/components/Notification.mjs +1 -1
  124. package/dist/components/Pagination.d.mts +5 -1
  125. package/dist/components/Pagination.d.ts +5 -1
  126. package/dist/components/Pagination.js +3 -3
  127. package/dist/components/Pagination.mjs +1 -1
  128. package/dist/components/PieChart.d.mts +14 -0
  129. package/dist/components/PieChart.d.ts +14 -0
  130. package/dist/components/PieChart.js +20 -0
  131. package/dist/components/PieChart.mjs +5 -0
  132. package/dist/components/Popconfirm.d.mts +12 -2
  133. package/dist/components/Popconfirm.d.ts +12 -2
  134. package/dist/components/Popconfirm.js +3 -2
  135. package/dist/components/Popconfirm.mjs +2 -1
  136. package/dist/components/Popover.d.mts +12 -2
  137. package/dist/components/Popover.d.ts +12 -2
  138. package/dist/components/Popover.js +3 -2
  139. package/dist/components/Popover.mjs +2 -1
  140. package/dist/components/RadarChart.d.mts +20 -0
  141. package/dist/components/RadarChart.d.ts +20 -0
  142. package/dist/components/RadarChart.js +20 -0
  143. package/dist/components/RadarChart.mjs +5 -0
  144. package/dist/components/ScatterChart.d.mts +32 -0
  145. package/dist/components/ScatterChart.d.ts +32 -0
  146. package/dist/components/ScatterChart.js +23 -0
  147. package/dist/components/ScatterChart.mjs +8 -0
  148. package/dist/components/Select.js +2 -2
  149. package/dist/components/Select.mjs +1 -1
  150. package/dist/components/Slider.js +2 -2
  151. package/dist/components/Slider.mjs +1 -1
  152. package/dist/components/Space.js +2 -2
  153. package/dist/components/Space.mjs +1 -1
  154. package/dist/components/Steps.js +3 -3
  155. package/dist/components/Steps.mjs +1 -1
  156. package/dist/components/StepsItem.js +2 -2
  157. package/dist/components/StepsItem.mjs +1 -1
  158. package/dist/components/Table.js +2 -2
  159. package/dist/components/Table.mjs +1 -1
  160. package/dist/components/Tooltip.d.mts +12 -2
  161. package/dist/components/Tooltip.d.ts +12 -2
  162. package/dist/components/Tooltip.js +3 -2
  163. package/dist/components/Tooltip.mjs +2 -1
  164. package/dist/index.d.mts +97 -1
  165. package/dist/index.d.ts +97 -1
  166. package/dist/index.js +178 -108
  167. package/dist/index.mjs +41 -27
  168. package/package.json +6 -2
  169. package/dist/chunk-NEULKOYJ.js +0 -48
  170. package/dist/chunk-ZO4XVOHU.mjs +0 -45
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @expcat/tigercat-react
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@expcat/tigercat-react.svg)](https://www.npmjs.com/package/@expcat/tigercat-react)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ React UI components for [Tigercat](https://github.com/expcats/Tigercat) - A Tailwind CSS based component library.
7
+
8
+ ## 📖 Documentation
9
+
10
+ **[Live Demo & Docs →](https://expcat.github.io/Tigercat/react/)**
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @expcat/tigercat-react
16
+ # or
17
+ npm install @expcat/tigercat-react
18
+ ```
19
+
20
+ **Requirements:** React ≥19, Tailwind CSS ≥3.4
21
+
22
+ ## Quick Start
23
+
24
+ ```tsx
25
+ import { ConfigProvider, Button } from '@expcat/tigercat-react'
26
+
27
+ function App() {
28
+ return (
29
+ <ConfigProvider>
30
+ <Button variant="primary">Click me</Button>
31
+ </ConfigProvider>
32
+ )
33
+ }
34
+ ```
35
+
36
+ ## Components
37
+
38
+ | Category | Components |
39
+ | -------------- | ------------------------------------------------------------------------------------- |
40
+ | **Basic** | Alert, Avatar, Badge, Button, Code, Divider, Icon, Link, Tag, Text |
41
+ | **Form** | Input, Select, Checkbox, Radio, Switch, Slider, DatePicker, TimePicker, Upload, Form |
42
+ | **Layout** | Card, Container, Grid (Row/Col), Layout, List, Descriptions, Skeleton, Space |
43
+ | **Navigation** | Menu, Tabs, Breadcrumb, Pagination, Steps, Dropdown, Tree |
44
+ | **Feedback** | Modal, Drawer, Message, Notification, Loading, Popconfirm, Popover, Tooltip, Progress |
45
+ | **Data** | Table, Timeline |
46
+ | **Charts** | BarChart, LineChart, AreaChart, PieChart, DonutChart, RadarChart, ScatterChart |
47
+
48
+ ## Hooks
49
+
50
+ - `useChartInteraction` - Chart interaction utilities
51
+ - `useFormContext` - Form state management
52
+ - `useMenuContext` - Menu state access
53
+ - `useTabsContext` - Tabs state access
54
+ - `useBreadcrumbContext` - Breadcrumb navigation
55
+ - `useStepsContext` - Steps state access
56
+
57
+ ## License
58
+
59
+ [MIT](https://opensource.org/licenses/MIT)
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkNEULKOYJ_js = require('./chunk-NEULKOYJ.js');
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');
@@ -91,7 +91,17 @@ var Modal = ({
91
91
  if (visible) return;
92
92
  tigercatCore.restoreFocus(previousActiveElementRef.current);
93
93
  }, [visible]);
94
- chunkNEULKOYJ_js.useEscapeKey({ enabled: visible, onEscape: handleClose });
94
+ chunkZYPEO2KY_js.useEscapeKey({ enabled: visible, onEscape: handleClose });
95
+ const handleKeyDown = React.useCallback((event) => {
96
+ if (event.key === "Tab" && dialogRef.current) {
97
+ const focusables = tigercatCore.getFocusableElements(dialogRef.current);
98
+ const result = tigercatCore.getFocusTrapNavigation(event.nativeEvent, focusables, document.activeElement);
99
+ if (result.shouldHandle && result.next) {
100
+ event.preventDefault();
101
+ result.next.focus();
102
+ }
103
+ }
104
+ }, []);
95
105
  const CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
96
106
  "svg",
97
107
  {
@@ -145,6 +155,7 @@ var Modal = ({
145
155
  "aria-labelledby": ariaLabelledby,
146
156
  tabIndex: -1,
147
157
  ref: dialogRef,
158
+ onKeyDown: handleKeyDown,
148
159
  "data-tiger-modal": "",
149
160
  children: [
150
161
  (title || titleContent || closable) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: tigercatCore.modalHeaderClasses, children: [
@@ -0,0 +1,151 @@
1
+ import { useState, useMemo, useCallback } from 'react';
2
+ import { getChartElementOpacity, classNames } from '@expcat/tigercat-core';
3
+
4
+ // src/hooks/useChartInteraction.ts
5
+ function useChartInteraction(options) {
6
+ const {
7
+ hoverable,
8
+ hoveredIndexProp,
9
+ selectable,
10
+ selectedIndexProp,
11
+ activeOpacity,
12
+ inactiveOpacity,
13
+ legendPosition = "bottom",
14
+ onHoveredIndexChange,
15
+ onSelectedIndexChange,
16
+ getData,
17
+ callbacks
18
+ } = options;
19
+ const [localHoveredIndex, setLocalHoveredIndex] = useState(null);
20
+ const [localSelectedIndex, setLocalSelectedIndex] = useState(null);
21
+ const [tooltipPosition, setTooltipPosition] = useState({ x: 0, y: 0 });
22
+ const resolvedHoveredIndex = hoveredIndexProp !== void 0 ? hoveredIndexProp : localHoveredIndex;
23
+ const resolvedSelectedIndex = selectedIndexProp !== void 0 ? selectedIndexProp : localSelectedIndex;
24
+ const activeIndex = useMemo(() => {
25
+ if (resolvedSelectedIndex !== null) return resolvedSelectedIndex;
26
+ if (hoverable && resolvedHoveredIndex !== null) return resolvedHoveredIndex;
27
+ return null;
28
+ }, [resolvedSelectedIndex, hoverable, resolvedHoveredIndex]);
29
+ const getElementOpacity = useCallback(
30
+ (index) => {
31
+ return getChartElementOpacity(index, activeIndex, {
32
+ activeOpacity,
33
+ inactiveOpacity
34
+ });
35
+ },
36
+ [activeIndex, activeOpacity, inactiveOpacity]
37
+ );
38
+ const handleMouseEnter = useCallback(
39
+ (index, event) => {
40
+ if (!hoverable) return;
41
+ if (hoveredIndexProp === void 0) {
42
+ setLocalHoveredIndex(index);
43
+ }
44
+ setTooltipPosition({ x: event.clientX, y: event.clientY });
45
+ onHoveredIndexChange?.(index);
46
+ if (callbacks?.onHover && getData) {
47
+ callbacks.onHover(index, getData(index) ?? null);
48
+ }
49
+ },
50
+ [hoverable, hoveredIndexProp, onHoveredIndexChange, callbacks, getData]
51
+ );
52
+ const handleMouseMove = useCallback((event) => {
53
+ setTooltipPosition({ x: event.clientX, y: event.clientY });
54
+ }, []);
55
+ const handleMouseLeave = useCallback(() => {
56
+ if (!hoverable) return;
57
+ if (hoveredIndexProp === void 0) {
58
+ setLocalHoveredIndex(null);
59
+ }
60
+ onHoveredIndexChange?.(null);
61
+ callbacks?.onHover?.(null, null);
62
+ }, [hoverable, hoveredIndexProp, onHoveredIndexChange, callbacks]);
63
+ const handleClick = useCallback(
64
+ (index) => {
65
+ if (!selectable) return;
66
+ const nextIndex = resolvedSelectedIndex === index ? null : index;
67
+ if (selectedIndexProp === void 0) {
68
+ setLocalSelectedIndex(nextIndex);
69
+ }
70
+ onSelectedIndexChange?.(nextIndex);
71
+ if (callbacks?.onClick && getData) {
72
+ const datum = getData(index);
73
+ if (datum) callbacks.onClick(index, datum);
74
+ }
75
+ },
76
+ [
77
+ selectable,
78
+ resolvedSelectedIndex,
79
+ selectedIndexProp,
80
+ onSelectedIndexChange,
81
+ callbacks,
82
+ getData
83
+ ]
84
+ );
85
+ const handleKeyDown = useCallback(
86
+ (event, index) => {
87
+ if (!selectable) return;
88
+ if (event.key !== "Enter" && event.key !== " ") return;
89
+ event.preventDefault();
90
+ handleClick(index);
91
+ },
92
+ [selectable, handleClick]
93
+ );
94
+ const handleLegendClick = useCallback(
95
+ (index) => {
96
+ handleClick(index);
97
+ },
98
+ [handleClick]
99
+ );
100
+ const handleLegendHover = useCallback(
101
+ (index) => {
102
+ if (!hoverable) return;
103
+ if (hoveredIndexProp === void 0) {
104
+ setLocalHoveredIndex(index);
105
+ }
106
+ onHoveredIndexChange?.(index);
107
+ },
108
+ [hoverable, hoveredIndexProp, onHoveredIndexChange]
109
+ );
110
+ const handleLegendLeave = useCallback(() => {
111
+ handleMouseLeave();
112
+ }, [handleMouseLeave]);
113
+ const wrapperClasses = useMemo(() => {
114
+ return classNames(
115
+ "inline-flex",
116
+ legendPosition === "right" ? "flex-row items-start gap-4" : legendPosition === "left" ? "flex-row-reverse items-start gap-4" : legendPosition === "top" ? "flex-col-reverse gap-2" : "flex-col gap-2"
117
+ );
118
+ }, [legendPosition]);
119
+ const createLegendItems = useCallback(
120
+ (items, palette, labelFormatter) => {
121
+ return items.map((item, index) => ({
122
+ index,
123
+ label: labelFormatter ? labelFormatter(item, index) : item.label ?? String(item.x ?? index),
124
+ color: item.color ?? palette[index % palette.length],
125
+ active: activeIndex === null || activeIndex === index
126
+ }));
127
+ },
128
+ [activeIndex]
129
+ );
130
+ return {
131
+ localHoveredIndex,
132
+ localSelectedIndex,
133
+ tooltipPosition,
134
+ resolvedHoveredIndex,
135
+ resolvedSelectedIndex,
136
+ activeIndex,
137
+ getElementOpacity,
138
+ handleMouseEnter,
139
+ handleMouseMove,
140
+ handleMouseLeave,
141
+ handleClick,
142
+ handleKeyDown,
143
+ handleLegendClick,
144
+ handleLegendHover,
145
+ handleLegendLeave,
146
+ wrapperClasses,
147
+ createLegendItems
148
+ };
149
+ }
150
+
151
+ export { useChartInteraction };
@@ -0,0 +1,68 @@
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/ChartGrid.tsx
8
+ var ChartGrid = ({
9
+ xScale,
10
+ yScale,
11
+ show = "both",
12
+ xTicks = 5,
13
+ yTicks = 5,
14
+ xTickValues,
15
+ yTickValues,
16
+ lineStyle = "solid",
17
+ strokeWidth = 1,
18
+ x = 0,
19
+ y = 0,
20
+ className,
21
+ ...props
22
+ }) => {
23
+ const dasharray = react.useMemo(() => tigercatCore.getChartGridLineDasharray(lineStyle), [lineStyle]);
24
+ const resolvedXTicks = react.useMemo(() => {
25
+ if (!xScale) return [];
26
+ return tigercatCore.getChartAxisTicks(xScale, { tickCount: xTicks, tickValues: xTickValues });
27
+ }, [xScale, xTicks, xTickValues]);
28
+ const resolvedYTicks = react.useMemo(() => {
29
+ if (!yScale) return [];
30
+ return tigercatCore.getChartAxisTicks(yScale, { tickCount: yTicks, tickValues: yTickValues });
31
+ }, [yScale, yTicks, yTickValues]);
32
+ const shouldRenderX = show === "both" || show === "x";
33
+ const shouldRenderY = show === "both" || show === "y";
34
+ const xRange = xScale?.range;
35
+ const yRange = yScale?.range;
36
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { ...props, className: tigercatCore.classNames(className), transform: `translate(${x}, ${y})`, children: [
37
+ shouldRenderX && xScale && yRange ? resolvedXTicks.map((tick) => /* @__PURE__ */ jsxRuntime.jsx(
38
+ "line",
39
+ {
40
+ x1: tick.position,
41
+ y1: yRange[0],
42
+ x2: tick.position,
43
+ y2: yRange[1],
44
+ className: tigercatCore.chartGridLineClasses,
45
+ strokeWidth,
46
+ strokeDasharray: dasharray
47
+ },
48
+ `x-${tick.value}`
49
+ )) : null,
50
+ shouldRenderY && yScale && xRange ? resolvedYTicks.map((tick) => /* @__PURE__ */ jsxRuntime.jsx(
51
+ "line",
52
+ {
53
+ x1: xRange[0],
54
+ y1: tick.position,
55
+ x2: xRange[1],
56
+ y2: tick.position,
57
+ className: tigercatCore.chartGridLineClasses,
58
+ strokeWidth,
59
+ strokeDasharray: dasharray
60
+ },
61
+ `y-${tick.value}`
62
+ )) : null
63
+ ] });
64
+ };
65
+ var ChartGrid_default = ChartGrid;
66
+
67
+ exports.ChartGrid = ChartGrid;
68
+ exports.ChartGrid_default = ChartGrid_default;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { classNames, iconWrapperClasses, iconSvgBaseClasses, iconSizeClasses } from '@expcat/tigercat-core';
2
+ import { classNames, iconWrapperClasses, SVG_DEFAULT_STROKE, SVG_DEFAULT_FILL, SVG_DEFAULT_VIEWBOX_24, SVG_DEFAULT_XMLNS, iconSvgBaseClasses, iconSizeClasses } from '@expcat/tigercat-core';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
5
5
  // src/components/Icon.tsx
@@ -23,10 +23,10 @@ var Icon = ({
23
23
  return React.cloneElement(child, {
24
24
  ...svgProps,
25
25
  className: classNames(iconSvgBaseClasses, iconSizeClasses[size], svgProps.className),
26
- xmlns: svgProps.xmlns ?? "http://www.w3.org/2000/svg",
27
- viewBox: svgProps.viewBox ?? "0 0 24 24",
28
- fill: svgProps.fill ?? "none",
29
- stroke: svgProps.stroke ?? "currentColor",
26
+ xmlns: svgProps.xmlns ?? SVG_DEFAULT_XMLNS,
27
+ viewBox: svgProps.viewBox ?? SVG_DEFAULT_VIEWBOX_24,
28
+ fill: svgProps.fill ?? SVG_DEFAULT_FILL,
29
+ stroke: svgProps.stroke ?? SVG_DEFAULT_STROKE,
30
30
  strokeWidth: svgProps.strokeWidth ?? 2,
31
31
  strokeLinecap: svgProps.strokeLinecap ?? "round",
32
32
  strokeLinejoin: svgProps.strokeLinejoin ?? "round"
@@ -0,0 +1,278 @@
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 ScatterChart = ({
15
+ width = 320,
16
+ height = 200,
17
+ padding = 24,
18
+ data,
19
+ xScale,
20
+ yScale,
21
+ pointSize = 4,
22
+ pointColor = "var(--tiger-primary,#2563eb)",
23
+ pointOpacity,
24
+ showGrid = true,
25
+ showAxis = true,
26
+ showXAxis = true,
27
+ showYAxis = true,
28
+ includeZero = false,
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
+ // Interaction props
40
+ hoverable = false,
41
+ hoveredIndex: hoveredIndexProp,
42
+ onHoveredIndexChange,
43
+ activeOpacity = 1,
44
+ inactiveOpacity = 0.25,
45
+ selectable = false,
46
+ selectedIndex: selectedIndexProp,
47
+ onSelectedIndexChange,
48
+ onPointClick,
49
+ onPointHover,
50
+ // Legend props
51
+ showLegend = false,
52
+ legendPosition = "bottom",
53
+ legendMarkerSize = 10,
54
+ legendGap = 8,
55
+ legendFormatter,
56
+ // Tooltip props
57
+ showTooltip = true,
58
+ tooltipFormatter,
59
+ // Other
60
+ colors,
61
+ title,
62
+ desc,
63
+ className
64
+ }) => {
65
+ const {
66
+ tooltipPosition,
67
+ resolvedHoveredIndex,
68
+ activeIndex,
69
+ handleMouseEnter,
70
+ handleMouseMove,
71
+ handleMouseLeave,
72
+ handleClick,
73
+ handleKeyDown,
74
+ handleLegendClick,
75
+ handleLegendHover,
76
+ handleLegendLeave,
77
+ wrapperClasses
78
+ } = chunkKQZ4F7FZ_js.useChartInteraction({
79
+ hoverable,
80
+ hoveredIndexProp,
81
+ selectable,
82
+ selectedIndexProp,
83
+ activeOpacity,
84
+ inactiveOpacity,
85
+ legendPosition,
86
+ getData: (index) => data[index],
87
+ onHoveredIndexChange: (index) => {
88
+ onHoveredIndexChange?.(index);
89
+ onPointHover?.(index, index !== null ? data[index] : null);
90
+ },
91
+ onSelectedIndexChange,
92
+ callbacks: {
93
+ onClick: onPointClick
94
+ }
95
+ });
96
+ const innerRect = react.useMemo(
97
+ () => tigercatCore.getChartInnerRect(width, height, padding),
98
+ [width, height, padding]
99
+ );
100
+ const xValues = react.useMemo(() => data.map((item) => item.x), [data]);
101
+ const yValues = react.useMemo(() => data.map((item) => item.y), [data]);
102
+ const resolvedXScale = react.useMemo(() => {
103
+ if (xScale) return xScale;
104
+ const extent = tigercatCore.getNumberExtent(xValues, { includeZero });
105
+ return tigercatCore.createLinearScale(extent, [0, innerRect.width]);
106
+ }, [xScale, xValues, includeZero, innerRect.width]);
107
+ const resolvedYScale = react.useMemo(() => {
108
+ if (yScale) return yScale;
109
+ const extent = tigercatCore.getNumberExtent(yValues, { includeZero });
110
+ return tigercatCore.createLinearScale(extent, [innerRect.height, 0]);
111
+ }, [yScale, yValues, includeZero, innerRect.height]);
112
+ const palette = react.useMemo(
113
+ () => colors && colors.length > 0 ? colors : pointColor ? [pointColor] : [...tigercatCore.DEFAULT_CHART_COLORS],
114
+ [colors, pointColor]
115
+ );
116
+ const points = react.useMemo(
117
+ () => data.map((item, index) => {
118
+ const color = item.color ?? palette[index % palette.length];
119
+ const opacity = tigercatCore.getChartElementOpacity(index, activeIndex, {
120
+ activeOpacity,
121
+ inactiveOpacity
122
+ });
123
+ return {
124
+ cx: resolvedXScale.map(item.x),
125
+ cy: resolvedYScale.map(item.y),
126
+ r: item.size ?? pointSize,
127
+ color,
128
+ opacity: pointOpacity ?? opacity,
129
+ datum: item
130
+ };
131
+ }),
132
+ [
133
+ data,
134
+ palette,
135
+ activeIndex,
136
+ activeOpacity,
137
+ inactiveOpacity,
138
+ resolvedXScale,
139
+ resolvedYScale,
140
+ pointSize,
141
+ pointOpacity
142
+ ]
143
+ );
144
+ const legendItems = react.useMemo(
145
+ () => data.map((item, index) => ({
146
+ index,
147
+ label: legendFormatter ? legendFormatter(item, index) : item.label ?? `(${item.x}, ${item.y})`,
148
+ color: item.color ?? palette[index % palette.length],
149
+ active: activeIndex === null || activeIndex === index
150
+ })),
151
+ [data, legendFormatter, palette, activeIndex]
152
+ );
153
+ const formatTooltip = react.useCallback(
154
+ (datum, index) => {
155
+ if (tooltipFormatter) return tooltipFormatter(datum, index);
156
+ const label = datum.label ?? `Point ${index + 1}`;
157
+ return `${label}: (${datum.x}, ${datum.y})`;
158
+ },
159
+ [tooltipFormatter]
160
+ );
161
+ const tooltipContent = react.useMemo(() => {
162
+ if (resolvedHoveredIndex === null) return "";
163
+ const datum = data[resolvedHoveredIndex];
164
+ return datum ? formatTooltip(datum, resolvedHoveredIndex) : "";
165
+ }, [resolvedHoveredIndex, data, formatTooltip]);
166
+ const shouldShowXAxis = showAxis && showXAxis;
167
+ const shouldShowYAxis = showAxis && showYAxis;
168
+ const chart = /* @__PURE__ */ jsxRuntime.jsxs(
169
+ chunkDUWAV47E_js.ChartCanvas,
170
+ {
171
+ width,
172
+ height,
173
+ padding,
174
+ title,
175
+ desc,
176
+ className: tigercatCore.classNames(className),
177
+ children: [
178
+ showGrid && /* @__PURE__ */ jsxRuntime.jsx(
179
+ chunk3QFHVAZT_js.ChartGrid,
180
+ {
181
+ xScale: resolvedXScale,
182
+ yScale: resolvedYScale,
183
+ show: "both",
184
+ xTicks,
185
+ yTicks,
186
+ xTickValues,
187
+ yTickValues,
188
+ lineStyle: gridLineStyle,
189
+ strokeWidth: gridStrokeWidth
190
+ }
191
+ ),
192
+ shouldShowXAxis && /* @__PURE__ */ jsxRuntime.jsx(
193
+ chunkE5GD3H7L_js.ChartAxis,
194
+ {
195
+ scale: resolvedXScale,
196
+ orientation: "bottom",
197
+ y: innerRect.height,
198
+ ticks: xTicks,
199
+ tickValues: xTickValues,
200
+ tickFormat: xTickFormat,
201
+ label: xAxisLabel
202
+ }
203
+ ),
204
+ shouldShowYAxis && /* @__PURE__ */ jsxRuntime.jsx(
205
+ chunkE5GD3H7L_js.ChartAxis,
206
+ {
207
+ scale: resolvedYScale,
208
+ orientation: "left",
209
+ ticks: yTicks,
210
+ tickValues: yTickValues,
211
+ tickFormat: yTickFormat,
212
+ label: yAxisLabel
213
+ }
214
+ ),
215
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAX5XRD2Q_js.ChartSeries, { data, type: "scatter", children: points.map((point, index) => /* @__PURE__ */ jsxRuntime.jsx(
216
+ "circle",
217
+ {
218
+ cx: point.cx,
219
+ cy: point.cy,
220
+ r: point.r,
221
+ fill: point.color,
222
+ opacity: point.opacity,
223
+ className: tigercatCore.classNames(
224
+ "transition-opacity duration-150",
225
+ (hoverable || selectable) && "cursor-pointer"
226
+ ),
227
+ tabIndex: selectable ? 0 : void 0,
228
+ role: selectable ? "button" : "img",
229
+ "aria-label": point.datum.label ?? `Point ${index + 1}: (${point.datum.x}, ${point.datum.y})`,
230
+ "data-point-index": index,
231
+ onMouseEnter: (e) => handleMouseEnter(index, e),
232
+ onMouseMove: handleMouseMove,
233
+ onMouseLeave: handleMouseLeave,
234
+ onClick: () => handleClick(index),
235
+ onKeyDown: (e) => handleKeyDown(e, index)
236
+ },
237
+ `point-${index}`
238
+ )) })
239
+ ]
240
+ }
241
+ );
242
+ const tooltip = showTooltip && hoverable && /* @__PURE__ */ jsxRuntime.jsx(
243
+ chunkM375I56K_js.ChartTooltip,
244
+ {
245
+ content: tooltipContent,
246
+ visible: resolvedHoveredIndex !== null && tooltipContent !== "",
247
+ x: tooltipPosition.x,
248
+ y: tooltipPosition.y
249
+ }
250
+ );
251
+ if (!showLegend) {
252
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-block relative", children: [
253
+ chart,
254
+ tooltip
255
+ ] });
256
+ }
257
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClasses, children: [
258
+ chart,
259
+ /* @__PURE__ */ jsxRuntime.jsx(
260
+ chunk6PBNFLM7_js.ChartLegend,
261
+ {
262
+ items: legendItems,
263
+ position: legendPosition,
264
+ markerSize: legendMarkerSize,
265
+ gap: legendGap,
266
+ interactive: hoverable || selectable,
267
+ onItemClick: handleLegendClick,
268
+ onItemHover: handleLegendHover,
269
+ onItemLeave: handleLegendLeave
270
+ }
271
+ ),
272
+ tooltip
273
+ ] });
274
+ };
275
+ var ScatterChart_default = ScatterChart;
276
+
277
+ exports.ScatterChart = ScatterChart;
278
+ exports.ScatterChart_default = ScatterChart_default;