@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
@@ -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 chunkEQWQXURG_js = require('./chunk-EQWQXURG.js');
5
5
  var React = require('react');
6
6
  var tigercatCore = require('@expcat/tigercat-core');
@@ -13,7 +13,8 @@ var React__default = /*#__PURE__*/_interopDefault(React);
13
13
  var DropdownContext = React.createContext(null);
14
14
  var Dropdown = ({
15
15
  trigger = "hover",
16
- placement = "bottom-start",
16
+ placement: initialPlacement = "bottom-start",
17
+ offset = 4,
17
18
  disabled = false,
18
19
  visible: controlledVisible,
19
20
  defaultVisible = false,
@@ -28,6 +29,8 @@ var Dropdown = ({
28
29
  const [internalVisible, setInternalVisible] = React.useState(defaultVisible);
29
30
  const visible = controlledVisible !== void 0 ? controlledVisible : internalVisible;
30
31
  const containerRef = React.useRef(null);
32
+ const triggerRef = React.useRef(null);
33
+ const floatingRef = React.useRef(null);
31
34
  const hoverTimerRef = React.useRef(null);
32
35
  const setVisible = React.useCallback(
33
36
  (newVisible) => {
@@ -66,15 +69,22 @@ var Dropdown = ({
66
69
  if (trigger !== "click") return;
67
70
  setVisible(!visible);
68
71
  }, [trigger, visible, setVisible]);
69
- chunkNEULKOYJ_js.useClickOutside({
72
+ chunkZYPEO2KY_js.useClickOutside({
70
73
  enabled: trigger === "click" && visible,
71
74
  refs: [containerRef],
72
75
  onOutsideClick: () => setVisible(false)
73
76
  });
74
- chunkNEULKOYJ_js.useEscapeKey({
77
+ chunkZYPEO2KY_js.useEscapeKey({
75
78
  enabled: visible,
76
79
  onEscape: () => setVisible(false)
77
80
  });
81
+ const { x, y, placement } = chunkZYPEO2KY_js.useFloating({
82
+ referenceRef: triggerRef,
83
+ floatingRef,
84
+ enabled: visible,
85
+ placement: initialPlacement,
86
+ offset
87
+ });
78
88
  React.useEffect(() => {
79
89
  return () => {
80
90
  if (hoverTimerRef.current) {
@@ -88,7 +98,16 @@ var Dropdown = ({
88
98
  className
89
99
  );
90
100
  const triggerClasses = tigercatCore.getDropdownTriggerClasses(disabled);
91
- const menuWrapperClasses = tigercatCore.getDropdownMenuWrapperClasses(visible, placement);
101
+ const menuWrapperClasses = "absolute z-50";
102
+ const menuWrapperStyles = React.useMemo(
103
+ () => ({
104
+ position: "absolute",
105
+ left: x,
106
+ top: y,
107
+ transformOrigin: tigercatCore.getTransformOrigin(placement)
108
+ }),
109
+ [x, y, placement]
110
+ );
92
111
  const contextValue = {
93
112
  closeOnClick,
94
113
  handleItemClick
@@ -124,6 +143,7 @@ var Dropdown = ({
124
143
  /* @__PURE__ */ jsxRuntime.jsx(
125
144
  "div",
126
145
  {
146
+ ref: triggerRef,
127
147
  className: triggerClasses,
128
148
  onClick: handleClick,
129
149
  onMouseEnter: handleMouseEnter,
@@ -136,7 +156,9 @@ var Dropdown = ({
136
156
  /* @__PURE__ */ jsxRuntime.jsx(
137
157
  "div",
138
158
  {
159
+ ref: floatingRef,
139
160
  className: menuWrapperClasses,
161
+ style: menuWrapperStyles,
140
162
  hidden: !visible,
141
163
  onMouseEnter: handleMouseEnter,
142
164
  onMouseLeave: handleMouseLeave,
@@ -0,0 +1,72 @@
1
+ import { useRef, useState, useEffect, useMemo } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { classNames } from '@expcat/tigercat-core';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ // src/components/ChartTooltip.tsx
7
+ var ChartTooltip = ({
8
+ content,
9
+ visible = false,
10
+ x = 0,
11
+ y = 0,
12
+ className
13
+ }) => {
14
+ const tooltipRef = useRef(null);
15
+ const [adjustedPosition, setAdjustedPosition] = useState({ x, y });
16
+ useEffect(() => {
17
+ if (!visible) return;
18
+ let newX = x + 12;
19
+ let newY = y - 8;
20
+ requestAnimationFrame(() => {
21
+ if (!tooltipRef.current) return;
22
+ const rect = tooltipRef.current.getBoundingClientRect();
23
+ const viewportWidth = window.innerWidth;
24
+ const viewportHeight = window.innerHeight;
25
+ if (newX + rect.width > viewportWidth - 8) {
26
+ newX = x - rect.width - 12;
27
+ }
28
+ if (newY + rect.height > viewportHeight - 8) {
29
+ newY = y - rect.height - 8;
30
+ }
31
+ newX = Math.max(8, newX);
32
+ newY = Math.max(8, newY);
33
+ setAdjustedPosition({ x: newX, y: newY });
34
+ });
35
+ setAdjustedPosition({ x: newX, y: newY });
36
+ }, [x, y, visible]);
37
+ const tooltipClasses = useMemo(
38
+ () => classNames(
39
+ "fixed z-[9999] pointer-events-none",
40
+ "px-3 py-2 rounded-md shadow-lg",
41
+ "bg-[color:var(--tiger-bg-elevated,#1f2937)]",
42
+ "text-[color:var(--tiger-text-inverse,#f9fafb)]",
43
+ "text-sm whitespace-nowrap",
44
+ "transition-opacity duration-150",
45
+ visible ? "opacity-100" : "opacity-0",
46
+ className
47
+ ),
48
+ [visible, className]
49
+ );
50
+ if (!content) return null;
51
+ const tooltip = /* @__PURE__ */ jsx(
52
+ "div",
53
+ {
54
+ ref: tooltipRef,
55
+ className: tooltipClasses,
56
+ style: {
57
+ left: `${adjustedPosition.x}px`,
58
+ top: `${adjustedPosition.y}px`
59
+ },
60
+ role: "tooltip",
61
+ "data-chart-tooltip": "true",
62
+ children: content
63
+ }
64
+ );
65
+ if (typeof document !== "undefined") {
66
+ return createPortal(tooltip, document.body);
67
+ }
68
+ return null;
69
+ };
70
+ var ChartTooltip_default = ChartTooltip;
71
+
72
+ export { ChartTooltip, ChartTooltip_default };
@@ -0,0 +1,227 @@
1
+ import { useChartInteraction } from './chunk-3CDAG4HD.mjs';
2
+ import { ChartCanvas } from './chunk-IS467WAO.mjs';
3
+ import { ChartLegend } from './chunk-Z6F67MJE.mjs';
4
+ import { ChartTooltip } from './chunk-LVC43YX2.mjs';
5
+ import { useMemo, useCallback } from 'react';
6
+ import { getChartInnerRect, getPieArcs, DEFAULT_CHART_COLORS, classNames, createPieArcPath, getChartElementOpacity, polarToCartesian, chartAxisTickTextClasses } from '@expcat/tigercat-core';
7
+ import { jsxs, jsx } from 'react/jsx-runtime';
8
+
9
+ var PieChart = ({
10
+ width = 320,
11
+ height = 200,
12
+ padding = 24,
13
+ data,
14
+ innerRadius = 0,
15
+ outerRadius,
16
+ startAngle = 0,
17
+ endAngle = Math.PI * 2,
18
+ padAngle = 0,
19
+ colors,
20
+ showLabels = false,
21
+ labelFormatter,
22
+ hoverable = false,
23
+ hoveredIndex: hoveredIndexProp,
24
+ activeOpacity = 1,
25
+ inactiveOpacity = 0.25,
26
+ selectable = false,
27
+ selectedIndex: selectedIndexProp,
28
+ showLegend = false,
29
+ legendPosition = "bottom",
30
+ legendMarkerSize = 10,
31
+ legendGap = 8,
32
+ showTooltip = true,
33
+ tooltipFormatter,
34
+ legendFormatter,
35
+ title,
36
+ desc,
37
+ className,
38
+ onHoveredIndexChange,
39
+ onSelectedIndexChange,
40
+ onSliceClick,
41
+ onSliceHover
42
+ }) => {
43
+ const {
44
+ tooltipPosition,
45
+ resolvedHoveredIndex,
46
+ activeIndex,
47
+ handleMouseEnter,
48
+ handleMouseMove,
49
+ handleMouseLeave,
50
+ handleClick,
51
+ handleKeyDown,
52
+ handleLegendClick,
53
+ handleLegendHover,
54
+ handleLegendLeave,
55
+ wrapperClasses
56
+ } = useChartInteraction({
57
+ hoverable,
58
+ hoveredIndexProp,
59
+ selectable,
60
+ selectedIndexProp,
61
+ activeOpacity,
62
+ inactiveOpacity,
63
+ legendPosition,
64
+ getData: (index) => data[index],
65
+ onHoveredIndexChange: (index) => {
66
+ onHoveredIndexChange?.(index);
67
+ onSliceHover?.(index, index !== null ? data[index] : null);
68
+ },
69
+ onSelectedIndexChange,
70
+ callbacks: {
71
+ onClick: onSliceClick
72
+ }
73
+ });
74
+ const innerRect = useMemo(
75
+ () => getChartInnerRect(width, height, padding),
76
+ [width, height, padding]
77
+ );
78
+ const resolvedOuterRadius = useMemo(() => {
79
+ if (typeof outerRadius === "number") return Math.max(0, outerRadius);
80
+ return Math.max(0, Math.min(innerRect.width, innerRect.height) / 2);
81
+ }, [outerRadius, innerRect.width, innerRect.height]);
82
+ const resolvedInnerRadius = useMemo(
83
+ () => Math.min(Math.max(0, innerRadius ?? 0), resolvedOuterRadius),
84
+ [innerRadius, resolvedOuterRadius]
85
+ );
86
+ const arcs = useMemo(
87
+ () => getPieArcs(data, {
88
+ startAngle,
89
+ endAngle,
90
+ padAngle
91
+ }),
92
+ [data, startAngle, endAngle, padAngle]
93
+ );
94
+ const palette = useMemo(
95
+ () => colors && colors.length > 0 ? colors : [...DEFAULT_CHART_COLORS],
96
+ [colors]
97
+ );
98
+ const cx = innerRect.width / 2;
99
+ const cy = innerRect.height / 2;
100
+ const labelRadius = resolvedInnerRadius + (resolvedOuterRadius - resolvedInnerRadius) / 2;
101
+ const total = useMemo(() => data.reduce((sum, d) => sum + d.value, 0), [data]);
102
+ const formatLabel = labelFormatter ?? ((value, datum) => datum.label ?? `${value}`);
103
+ const legendItems = useMemo(
104
+ () => arcs.map((arc) => ({
105
+ index: arc.index,
106
+ label: legendFormatter ? legendFormatter(arc.data, arc.index) : arc.data.label ?? `${arc.index + 1}`,
107
+ color: arc.data.color ?? palette[arc.index % palette.length],
108
+ active: activeIndex === null || activeIndex === arc.index
109
+ })),
110
+ [arcs, legendFormatter, palette, activeIndex]
111
+ );
112
+ const formatTooltip = useCallback(
113
+ (datum, index) => {
114
+ if (tooltipFormatter) return tooltipFormatter(datum, index);
115
+ const label = datum.label ?? `Slice ${index + 1}`;
116
+ const percentage = total > 0 ? (datum.value / total * 100).toFixed(1) : "0";
117
+ return `${label}: ${datum.value} (${percentage}%)`;
118
+ },
119
+ [tooltipFormatter, total]
120
+ );
121
+ const tooltipContent = useMemo(() => {
122
+ if (resolvedHoveredIndex === null) return "";
123
+ const datum = data[resolvedHoveredIndex];
124
+ return datum ? formatTooltip(datum, resolvedHoveredIndex) : "";
125
+ }, [resolvedHoveredIndex, data, formatTooltip]);
126
+ const chart = /* @__PURE__ */ jsxs(
127
+ ChartCanvas,
128
+ {
129
+ width,
130
+ height,
131
+ padding,
132
+ title,
133
+ desc,
134
+ className: classNames(className),
135
+ children: [
136
+ /* @__PURE__ */ jsx("g", { "data-series-type": "pie", children: arcs.map((arc) => {
137
+ const color = arc.data.color ?? palette[arc.index % palette.length];
138
+ const path = createPieArcPath({
139
+ cx,
140
+ cy,
141
+ innerRadius: resolvedInnerRadius,
142
+ outerRadius: resolvedOuterRadius,
143
+ startAngle: arc.startAngle,
144
+ endAngle: arc.endAngle
145
+ });
146
+ const opacity = getChartElementOpacity(arc.index, activeIndex, {
147
+ activeOpacity,
148
+ inactiveOpacity
149
+ });
150
+ return /* @__PURE__ */ jsx(
151
+ "path",
152
+ {
153
+ d: path,
154
+ fill: color,
155
+ opacity,
156
+ className: classNames(
157
+ "transition-opacity duration-150",
158
+ (hoverable || selectable) && "cursor-pointer"
159
+ ),
160
+ tabIndex: selectable ? 0 : void 0,
161
+ "data-pie-slice": "true",
162
+ "data-index": arc.index,
163
+ onMouseEnter: (e) => handleMouseEnter(arc.index, e),
164
+ onMouseMove: handleMouseMove,
165
+ onMouseLeave: handleMouseLeave,
166
+ onClick: () => handleClick(arc.index),
167
+ onKeyDown: (e) => handleKeyDown(e, arc.index)
168
+ },
169
+ `slice-${arc.index}`
170
+ );
171
+ }) }),
172
+ showLabels && arcs.map((arc) => {
173
+ const angle = (arc.startAngle + arc.endAngle) / 2;
174
+ const { x, y } = polarToCartesian(cx, cy, labelRadius, angle);
175
+ const label = formatLabel(arc.value, arc.data, arc.index);
176
+ return /* @__PURE__ */ jsx(
177
+ "text",
178
+ {
179
+ x,
180
+ y,
181
+ className: chartAxisTickTextClasses,
182
+ textAnchor: "middle",
183
+ dominantBaseline: "middle",
184
+ children: label
185
+ },
186
+ `label-${arc.index}`
187
+ );
188
+ })
189
+ ]
190
+ }
191
+ );
192
+ const tooltip = showTooltip && /* @__PURE__ */ jsx(
193
+ ChartTooltip,
194
+ {
195
+ content: tooltipContent,
196
+ visible: hoverable && resolvedHoveredIndex !== null && tooltipContent !== "",
197
+ x: tooltipPosition.x,
198
+ y: tooltipPosition.y
199
+ }
200
+ );
201
+ if (!showLegend) {
202
+ return /* @__PURE__ */ jsxs("div", { className: "inline-block relative", children: [
203
+ chart,
204
+ tooltip
205
+ ] });
206
+ }
207
+ return /* @__PURE__ */ jsxs("div", { className: wrapperClasses, children: [
208
+ chart,
209
+ /* @__PURE__ */ jsx(
210
+ ChartLegend,
211
+ {
212
+ items: legendItems,
213
+ position: legendPosition,
214
+ markerSize: legendMarkerSize,
215
+ gap: legendGap,
216
+ interactive: hoverable || selectable,
217
+ onItemClick: handleLegendClick,
218
+ onItemHover: handleLegendHover,
219
+ onItemLeave: handleLegendLeave
220
+ }
221
+ ),
222
+ tooltip
223
+ ] });
224
+ };
225
+ var PieChart_default = PieChart;
226
+
227
+ export { PieChart, PieChart_default };
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var reactDom = require('react-dom');
5
+ var tigercatCore = require('@expcat/tigercat-core');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ // src/components/ChartTooltip.tsx
9
+ var ChartTooltip = ({
10
+ content,
11
+ visible = false,
12
+ x = 0,
13
+ y = 0,
14
+ className
15
+ }) => {
16
+ const tooltipRef = react.useRef(null);
17
+ const [adjustedPosition, setAdjustedPosition] = react.useState({ x, y });
18
+ react.useEffect(() => {
19
+ if (!visible) return;
20
+ let newX = x + 12;
21
+ let newY = y - 8;
22
+ requestAnimationFrame(() => {
23
+ if (!tooltipRef.current) return;
24
+ const rect = tooltipRef.current.getBoundingClientRect();
25
+ const viewportWidth = window.innerWidth;
26
+ const viewportHeight = window.innerHeight;
27
+ if (newX + rect.width > viewportWidth - 8) {
28
+ newX = x - rect.width - 12;
29
+ }
30
+ if (newY + rect.height > viewportHeight - 8) {
31
+ newY = y - rect.height - 8;
32
+ }
33
+ newX = Math.max(8, newX);
34
+ newY = Math.max(8, newY);
35
+ setAdjustedPosition({ x: newX, y: newY });
36
+ });
37
+ setAdjustedPosition({ x: newX, y: newY });
38
+ }, [x, y, visible]);
39
+ const tooltipClasses = react.useMemo(
40
+ () => tigercatCore.classNames(
41
+ "fixed z-[9999] pointer-events-none",
42
+ "px-3 py-2 rounded-md shadow-lg",
43
+ "bg-[color:var(--tiger-bg-elevated,#1f2937)]",
44
+ "text-[color:var(--tiger-text-inverse,#f9fafb)]",
45
+ "text-sm whitespace-nowrap",
46
+ "transition-opacity duration-150",
47
+ visible ? "opacity-100" : "opacity-0",
48
+ className
49
+ ),
50
+ [visible, className]
51
+ );
52
+ if (!content) return null;
53
+ const tooltip = /* @__PURE__ */ jsxRuntime.jsx(
54
+ "div",
55
+ {
56
+ ref: tooltipRef,
57
+ className: tooltipClasses,
58
+ style: {
59
+ left: `${adjustedPosition.x}px`,
60
+ top: `${adjustedPosition.y}px`
61
+ },
62
+ role: "tooltip",
63
+ "data-chart-tooltip": "true",
64
+ children: content
65
+ }
66
+ );
67
+ if (typeof document !== "undefined") {
68
+ return reactDom.createPortal(tooltip, document.body);
69
+ }
70
+ return null;
71
+ };
72
+ var ChartTooltip_default = ChartTooltip;
73
+
74
+ exports.ChartTooltip = ChartTooltip;
75
+ exports.ChartTooltip_default = ChartTooltip_default;
@@ -1,7 +1,7 @@
1
- import { useEscapeKey } from './chunk-ZO4XVOHU.mjs';
1
+ import { useEscapeKey } from './chunk-WLIFEALE.mjs';
2
2
  import React, { useEffect, useCallback, useMemo, useId, useRef } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
- import { getModalContentClasses, getModalContainerClasses, resolveLocaleText, captureActiveElement, focusFirst, restoreFocus, classNames, modalMaskClasses, modalHeaderClasses, modalTitleClasses, modalCloseButtonClasses, modalBodyClasses, modalFooterClasses, modalWrapperClasses, closeIconViewBox, closeIconPathD, closeIconPathStrokeWidth, closeIconPathStrokeLinejoin, closeIconPathStrokeLinecap } from '@expcat/tigercat-core';
4
+ import { getModalContentClasses, getModalContainerClasses, resolveLocaleText, captureActiveElement, focusFirst, restoreFocus, getFocusableElements, getFocusTrapNavigation, classNames, modalMaskClasses, modalHeaderClasses, modalTitleClasses, modalCloseButtonClasses, modalBodyClasses, modalFooterClasses, modalWrapperClasses, closeIconViewBox, closeIconPathD, closeIconPathStrokeWidth, closeIconPathStrokeLinejoin, closeIconPathStrokeLinecap } from '@expcat/tigercat-core';
5
5
  import { jsxs, jsx } from 'react/jsx-runtime';
6
6
 
7
7
  var Modal = ({
@@ -86,6 +86,16 @@ var Modal = ({
86
86
  restoreFocus(previousActiveElementRef.current);
87
87
  }, [visible]);
88
88
  useEscapeKey({ enabled: visible, onEscape: handleClose });
89
+ const handleKeyDown = useCallback((event) => {
90
+ if (event.key === "Tab" && dialogRef.current) {
91
+ const focusables = getFocusableElements(dialogRef.current);
92
+ const result = getFocusTrapNavigation(event.nativeEvent, focusables, document.activeElement);
93
+ if (result.shouldHandle && result.next) {
94
+ event.preventDefault();
95
+ result.next.focus();
96
+ }
97
+ }
98
+ }, []);
89
99
  const CloseIcon = /* @__PURE__ */ jsx(
90
100
  "svg",
91
101
  {
@@ -139,6 +149,7 @@ var Modal = ({
139
149
  "aria-labelledby": ariaLabelledby,
140
150
  tabIndex: -1,
141
151
  ref: dialogRef,
152
+ onKeyDown: handleKeyDown,
142
153
  "data-tiger-modal": "",
143
154
  children: [
144
155
  (title || titleContent || closable) && /* @__PURE__ */ jsxs("div", { className: modalHeaderClasses, children: [