@aiconstructions/graficos 0.0.0-stage → 0.2.1

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 (267) hide show
  1. package/ALTERACOES.md +53 -0
  2. package/LICENSE-BKLIT +21 -0
  3. package/LICENSE-visx-pattern +21 -0
  4. package/README.md +188 -2
  5. package/dist/aic/cores.js +83 -0
  6. package/dist/aic/index.js +22 -0
  7. package/dist/aic/interacao.js +55 -0
  8. package/dist/charts/animation.js +55 -0
  9. package/dist/charts/arc-geometry.js +58 -0
  10. package/dist/charts/arc-path.js +15 -0
  11. package/dist/charts/area-chart-loading.js +89 -0
  12. package/dist/charts/area-chart.js +149 -0
  13. package/dist/charts/area-gradient-defs.js +90 -0
  14. package/dist/charts/area-value-label-layout.js +70 -0
  15. package/dist/charts/area-value-labels.js +211 -0
  16. package/dist/charts/area.js +272 -0
  17. package/dist/charts/background.js +198 -0
  18. package/dist/charts/band-config.js +82 -0
  19. package/dist/charts/band-geometry.js +186 -0
  20. package/dist/charts/band.js +346 -0
  21. package/dist/charts/bar-chart-loading.js +27 -0
  22. package/dist/charts/bar-chart.js +545 -0
  23. package/dist/charts/bar-depth-geometry.js +18 -0
  24. package/dist/charts/bar-depth.js +608 -0
  25. package/dist/charts/bar-lollipop.js +278 -0
  26. package/dist/charts/bar-squares-layout.js +66 -0
  27. package/dist/charts/bar-squares.js +467 -0
  28. package/dist/charts/bar-value-label-layout.js +42 -0
  29. package/dist/charts/bar-x-axis.js +133 -0
  30. package/dist/charts/bar-y-axis.js +116 -0
  31. package/dist/charts/bar.js +457 -0
  32. package/dist/charts/bollinger.js +49 -0
  33. package/dist/charts/candlestick-chart.js +370 -0
  34. package/dist/charts/candlestick.js +368 -0
  35. package/dist/charts/chart-brush-handle.js +91 -0
  36. package/dist/charts/chart-brush-layout.js +91 -0
  37. package/dist/charts/chart-brush-selection-overlay.js +87 -0
  38. package/dist/charts/chart-brush-state.js +253 -0
  39. package/dist/charts/chart-brush-track-overlay.js +103 -0
  40. package/dist/charts/chart-brush.js +517 -0
  41. package/dist/charts/chart-center-typography.js +8 -0
  42. package/dist/charts/chart-child-passthrough.js +119 -0
  43. package/dist/charts/chart-config-context.js +56 -0
  44. package/dist/charts/chart-context.js +337 -0
  45. package/dist/charts/chart-crosshair.js +262 -0
  46. package/dist/charts/chart-data-override.js +186 -0
  47. package/dist/charts/chart-defs.js +56 -0
  48. package/dist/charts/chart-formatters.js +77 -0
  49. package/dist/charts/chart-legend-hover.js +27 -0
  50. package/dist/charts/chart-legend.js +163 -0
  51. package/dist/charts/chart-loading-label.js +52 -0
  52. package/dist/charts/chart-parent-size.js +138 -0
  53. package/dist/charts/chart-phase.js +29 -0
  54. package/dist/charts/chart-reveal-clip.js +62 -0
  55. package/dist/charts/chart-scale.js +19 -0
  56. package/dist/charts/chart-stat-flow.js +72 -0
  57. package/dist/charts/choropleth/choropleth-background.js +29 -0
  58. package/dist/charts/choropleth/choropleth-camera.js +379 -0
  59. package/dist/charts/choropleth/choropleth-chart.js +644 -0
  60. package/dist/charts/choropleth/choropleth-context.js +152 -0
  61. package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
  62. package/dist/charts/choropleth/choropleth-feature.js +291 -0
  63. package/dist/charts/choropleth/choropleth-graticule.js +40 -0
  64. package/dist/charts/choropleth/choropleth-marker.js +222 -0
  65. package/dist/charts/choropleth/choropleth-projection.js +37 -0
  66. package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
  67. package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
  68. package/dist/charts/choropleth/index.js +44 -0
  69. package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
  70. package/dist/charts/composed-chart.js +346 -0
  71. package/dist/charts/crosshair-store.js +49 -0
  72. package/dist/charts/dash-tail-stroke.js +58 -0
  73. package/dist/charts/date-pill-store.js +50 -0
  74. package/dist/charts/date-ranges.js +131 -0
  75. package/dist/charts/deadline.js +295 -0
  76. package/dist/charts/decimate-time-series.js +112 -0
  77. package/dist/charts/fade-edges.js +171 -0
  78. package/dist/charts/fast-path.js +78 -0
  79. package/dist/charts/filter-data-by-x-domain.js +45 -0
  80. package/dist/charts/funnel-chart.js +773 -0
  81. package/dist/charts/gauge-arc-layers.js +479 -0
  82. package/dist/charts/gauge-dial.js +329 -0
  83. package/dist/charts/gauge-label-layout.js +148 -0
  84. package/dist/charts/gauge.js +946 -0
  85. package/dist/charts/generate-chart-skeleton-data.js +27 -0
  86. package/dist/charts/gradients.js +158 -0
  87. package/dist/charts/grid-lines.js +114 -0
  88. package/dist/charts/grid.js +225 -0
  89. package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
  90. package/dist/charts/heatmap/heatmap-animation.js +128 -0
  91. package/dist/charts/heatmap/heatmap-cells.js +519 -0
  92. package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
  93. package/dist/charts/heatmap/heatmap-chart.js +548 -0
  94. package/dist/charts/heatmap/heatmap-colors.js +127 -0
  95. package/dist/charts/heatmap/heatmap-context.js +107 -0
  96. package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
  97. package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
  98. package/dist/charts/heatmap/heatmap-legend.js +165 -0
  99. package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
  100. package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
  101. package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
  102. package/dist/charts/heatmap/heatmap-separator.js +168 -0
  103. package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
  104. package/dist/charts/heatmap/heatmap-utils.js +633 -0
  105. package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
  106. package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
  107. package/dist/charts/heatmap/index.js +208 -0
  108. package/dist/charts/highlight-segment-bounds.js +34 -0
  109. package/dist/charts/highlight-segment.js +119 -0
  110. package/dist/charts/index.js +944 -0
  111. package/dist/charts/indicator-fade.js +44 -0
  112. package/dist/charts/legend/index.js +22 -0
  113. package/dist/charts/legend/legend-context.js +47 -0
  114. package/dist/charts/legend/legend-item.js +30 -0
  115. package/dist/charts/legend/legend-label.js +14 -0
  116. package/dist/charts/legend/legend-marker.js +18 -0
  117. package/dist/charts/legend/legend-progress.js +39 -0
  118. package/dist/charts/legend/legend-value.js +31 -0
  119. package/dist/charts/legend/legend.js +69 -0
  120. package/dist/charts/line-backdrop.js +129 -0
  121. package/dist/charts/line-chart-loading.js +85 -0
  122. package/dist/charts/line-chart.js +182 -0
  123. package/dist/charts/line-loading-pulse.js +185 -0
  124. package/dist/charts/line-loading-timing.js +12 -0
  125. package/dist/charts/line-path.js +58 -0
  126. package/dist/charts/line-series-terminal-marker.js +75 -0
  127. package/dist/charts/line.js +499 -0
  128. package/dist/charts/live-line-chart.js +494 -0
  129. package/dist/charts/live-line.js +277 -0
  130. package/dist/charts/live-x-axis.js +116 -0
  131. package/dist/charts/live-y-axis.js +164 -0
  132. package/dist/charts/loading-sweep.js +344 -0
  133. package/dist/charts/local-point.js +56 -0
  134. package/dist/charts/markers/chart-markers.js +149 -0
  135. package/dist/charts/markers/index.js +14 -0
  136. package/dist/charts/markers/marker-group.js +411 -0
  137. package/dist/charts/motion-utils.js +29 -0
  138. package/dist/charts/notch-gauge-shared.js +146 -0
  139. package/dist/charts/particle-line.js +1340 -0
  140. package/dist/charts/path-stroke-utils.js +51 -0
  141. package/dist/charts/pattern-area.js +127 -0
  142. package/dist/charts/pattern-preset.js +287 -0
  143. package/dist/charts/pattern-tile.js +31 -0
  144. package/dist/charts/patterns/circles.js +62 -0
  145. package/dist/charts/patterns/constants.js +9 -0
  146. package/dist/charts/patterns/hexagons.js +38 -0
  147. package/dist/charts/patterns/index.js +16 -0
  148. package/dist/charts/patterns/lines.js +65 -0
  149. package/dist/charts/patterns/path.js +37 -0
  150. package/dist/charts/patterns/pattern.js +16 -0
  151. package/dist/charts/patterns/waves.js +40 -0
  152. package/dist/charts/pie-center-shell.js +127 -0
  153. package/dist/charts/pie-center.js +87 -0
  154. package/dist/charts/pie-chart.js +377 -0
  155. package/dist/charts/pie-context.js +116 -0
  156. package/dist/charts/pie-slice.js +394 -0
  157. package/dist/charts/pie-ticks.js +332 -0
  158. package/dist/charts/profit-loss-legend-hover.js +18 -0
  159. package/dist/charts/profit-loss-legend.js +53 -0
  160. package/dist/charts/profit-loss-line.js +162 -0
  161. package/dist/charts/profit-loss-segments.js +88 -0
  162. package/dist/charts/projection-config.js +90 -0
  163. package/dist/charts/projection-line-end-marker.js +50 -0
  164. package/dist/charts/projection-line.js +466 -0
  165. package/dist/charts/projection-utils.js +303 -0
  166. package/dist/charts/radar-area.js +192 -0
  167. package/dist/charts/radar-axis.js +41 -0
  168. package/dist/charts/radar-chart.js +184 -0
  169. package/dist/charts/radar-context.js +104 -0
  170. package/dist/charts/radar-grid.js +121 -0
  171. package/dist/charts/radar-labels.js +62 -0
  172. package/dist/charts/radial-area.js +498 -0
  173. package/dist/charts/radial-axis.js +652 -0
  174. package/dist/charts/radial-bar.js +316 -0
  175. package/dist/charts/radial-center.js +67 -0
  176. package/dist/charts/radial-chart.js +740 -0
  177. package/dist/charts/radial-dot-bar-layout.js +68 -0
  178. package/dist/charts/radial-dot-bar.js +387 -0
  179. package/dist/charts/radial-geometry.js +114 -0
  180. package/dist/charts/radial-legend.js +66 -0
  181. package/dist/charts/radial-line.js +280 -0
  182. package/dist/charts/radial-ring-bar.js +255 -0
  183. package/dist/charts/radial-scrubber.js +120 -0
  184. package/dist/charts/radial-series-color.js +10 -0
  185. package/dist/charts/reference-area-config.js +43 -0
  186. package/dist/charts/reference-area-geometry.js +76 -0
  187. package/dist/charts/reference-area-registration-context.js +10 -0
  188. package/dist/charts/reference-area.js +241 -0
  189. package/dist/charts/responsive-chart-label-count.js +18 -0
  190. package/dist/charts/ring-center.js +78 -0
  191. package/dist/charts/ring-chart.js +362 -0
  192. package/dist/charts/ring-context.js +122 -0
  193. package/dist/charts/ring-grid.js +175 -0
  194. package/dist/charts/ring-labels.js +109 -0
  195. package/dist/charts/ring.js +237 -0
  196. package/dist/charts/sankey/index.js +22 -0
  197. package/dist/charts/sankey/sankey-chart.js +199 -0
  198. package/dist/charts/sankey/sankey-context.js +32 -0
  199. package/dist/charts/sankey/sankey-link.js +232 -0
  200. package/dist/charts/sankey/sankey-node.js +348 -0
  201. package/dist/charts/sankey/sankey-tooltip.js +94 -0
  202. package/dist/charts/scatter-chart-shell.js +279 -0
  203. package/dist/charts/scatter-chart.js +150 -0
  204. package/dist/charts/scatter-jitter.js +86 -0
  205. package/dist/charts/scatter-svg.js +17 -0
  206. package/dist/charts/scatter.js +92 -0
  207. package/dist/charts/segment.js +107 -0
  208. package/dist/charts/series-bar-layout.js +42 -0
  209. package/dist/charts/series-bar.js +241 -0
  210. package/dist/charts/series-dash-tail-overlay.js +53 -0
  211. package/dist/charts/series-highlight-layer.js +43 -0
  212. package/dist/charts/series-hover-dim.js +32 -0
  213. package/dist/charts/series-markers.js +239 -0
  214. package/dist/charts/series-path-utils.js +185 -0
  215. package/dist/charts/series-point-marker.js +150 -0
  216. package/dist/charts/sparkline-geometry.js +197 -0
  217. package/dist/charts/sparkline.js +910 -0
  218. package/dist/charts/static-chart-preview-context.js +16 -0
  219. package/dist/charts/sunburst-breadcrumb.js +33 -0
  220. package/dist/charts/sunburst-center.js +37 -0
  221. package/dist/charts/sunburst-chart.js +408 -0
  222. package/dist/charts/sunburst-context.js +140 -0
  223. package/dist/charts/sunburst-data.js +0 -0
  224. package/dist/charts/sunburst-hint.js +42 -0
  225. package/dist/charts/sunburst-labels.js +130 -0
  226. package/dist/charts/sunburst-segment.js +144 -0
  227. package/dist/charts/sunburst.js +419 -0
  228. package/dist/charts/time-series-chart-shell.js +688 -0
  229. package/dist/charts/tooltip/chart-tooltip.js +516 -0
  230. package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
  231. package/dist/charts/tooltip/date-ticker.js +376 -0
  232. package/dist/charts/tooltip/index.js +32 -0
  233. package/dist/charts/tooltip/liquid-glass.js +142 -0
  234. package/dist/charts/tooltip/tooltip-box.js +502 -0
  235. package/dist/charts/tooltip/tooltip-content.js +59 -0
  236. package/dist/charts/tooltip/tooltip-dot.js +170 -0
  237. package/dist/charts/tooltip/tooltip-indicator.js +175 -0
  238. package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
  239. package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
  240. package/dist/charts/trend-line-utils.js +64 -0
  241. package/dist/charts/trend-line.js +318 -0
  242. package/dist/charts/use-animated-band.js +175 -0
  243. package/dist/charts/use-animated-series-path.js +208 -0
  244. package/dist/charts/use-animated-y-domains.js +192 -0
  245. package/dist/charts/use-category-slots.js +29 -0
  246. package/dist/charts/use-chart-interaction.js +296 -0
  247. package/dist/charts/use-chart-phase-orchestrator.js +183 -0
  248. package/dist/charts/use-enter-complete.js +18 -0
  249. package/dist/charts/use-grid-shimmer.js +88 -0
  250. package/dist/charts/use-highlight-segment.js +65 -0
  251. package/dist/charts/use-mount-progress.js +23 -0
  252. package/dist/charts/use-scatter-chart-interaction.js +364 -0
  253. package/dist/charts/use-scheduled-tooltip.js +84 -0
  254. package/dist/charts/visx-pattern.js +30 -0
  255. package/dist/charts/weekends.js +174 -0
  256. package/dist/charts/x-axis-hover.js +46 -0
  257. package/dist/charts/x-axis.js +523 -0
  258. package/dist/charts/y-axis-scales.js +71 -0
  259. package/dist/charts/y-axis-ticks.js +22 -0
  260. package/dist/charts/y-axis.js +233 -0
  261. package/dist/charts/y-domain-utils.js +189 -0
  262. package/dist/index.d.ts +7346 -0
  263. package/dist/index.js +2 -0
  264. package/dist/lib/utils.js +8 -0
  265. package/dist/shimmering-text.js +54 -0
  266. package/package.json +78 -4
  267. package/tema.css +202 -0
@@ -0,0 +1,517 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ Fragment,
5
+ memo,
6
+ useCallback,
7
+ useEffect,
8
+ useLayoutEffect,
9
+ useMemo,
10
+ useRef,
11
+ useState
12
+ } from "react";
13
+ import {
14
+ ChartBrushHandleOverlay,
15
+ renderChartBrushHandle
16
+ } from "./chart-brush-handle";
17
+ import {
18
+ ChartBrushSelectionOverlay
19
+ } from "./chart-brush-selection-overlay";
20
+ import {
21
+ beginBrushDrag,
22
+ beginBrushSelect,
23
+ brushExtentToDomain,
24
+ brushHandleRects,
25
+ brushSelectionRect,
26
+ createBrushState,
27
+ dragBrush,
28
+ endBrush,
29
+ idleBrushState
30
+ } from "./chart-brush-state";
31
+ import {
32
+ ChartBrushTrackOverlay
33
+ } from "./chart-brush-track-overlay";
34
+ import { chartCssVars, useChartStable } from "./chart-context";
35
+ import { localPoint } from "./local-point";
36
+ const ZERO_MARGIN = { top: 0, left: 0, right: 0, bottom: 0 };
37
+ const DEFAULT_SELECTED_BOX_STYLE = {
38
+ fill: "transparent",
39
+ fillOpacity: 0,
40
+ stroke: chartCssVars.brushBorder,
41
+ strokeWidth: 1
42
+ };
43
+ const WINDOW_MOVE_DEBOUNCE_MS = 1;
44
+ function scaleInverter(scale) {
45
+ const invert = scale?.invert;
46
+ return typeof invert === "function" ? (value) => invert.call(scale, value) : () => Number.NaN;
47
+ }
48
+ function toDomain(state, scale) {
49
+ return brushExtentToDomain(state.extent, scaleInverter(scale));
50
+ }
51
+ const ChartBrushInteraction = memo(function ChartBrushInteraction2({
52
+ xScale,
53
+ width,
54
+ height,
55
+ brushDirection,
56
+ handleSize,
57
+ initialBrushPosition,
58
+ startMargin,
59
+ moveMode,
60
+ selectedBoxStyle,
61
+ onChange,
62
+ onBrushEnd
63
+ }) {
64
+ const stage = useMemo(
65
+ () => ({ width, height, direction: brushDirection }),
66
+ [width, height, brushDirection]
67
+ );
68
+ const [state, setState] = useState(
69
+ () => createBrushState(stage, initialBrushPosition)
70
+ );
71
+ const stateRef = useRef(state);
72
+ const dragRef = useRef(null);
73
+ const moveTimerRef = useRef(null);
74
+ const pendingMoveRef = useRef(null);
75
+ const latestRef = useRef({ stage, xScale, onChange });
76
+ useLayoutEffect(() => {
77
+ latestRef.current = { stage, xScale, onChange };
78
+ });
79
+ useEffect(
80
+ () => () => {
81
+ if (moveTimerRef.current) {
82
+ clearTimeout(moveTimerRef.current);
83
+ }
84
+ },
85
+ []
86
+ );
87
+ const commitState = useCallback((next) => {
88
+ stateRef.current = next;
89
+ setState(next);
90
+ }, []);
91
+ const startDrag = useCallback(
92
+ (event, next, local) => {
93
+ const target = event.target;
94
+ try {
95
+ target.setPointerCapture(event.pointerId);
96
+ } catch {
97
+ }
98
+ dragRef.current = {
99
+ pointerId: event.pointerId,
100
+ target,
101
+ pageX: event.pageX,
102
+ pageY: event.pageY,
103
+ local
104
+ };
105
+ commitState(next);
106
+ onChange(toDomain(next, xScale));
107
+ },
108
+ [commitState, onChange, xScale]
109
+ );
110
+ const handleOverlayPointerDown = useCallback(
111
+ (event) => {
112
+ if (dragRef.current) {
113
+ return;
114
+ }
115
+ const point = localPoint(event) ?? { x: 0, y: 0 };
116
+ const next = beginBrushSelect(stateRef.current, {
117
+ x: point.x - startMargin.left,
118
+ y: point.y - startMargin.top
119
+ });
120
+ startDrag(event, next, point);
121
+ },
122
+ [startDrag, startMargin.left, startMargin.top]
123
+ );
124
+ const handleDragPointerDown = useCallback(
125
+ (type, event) => {
126
+ if (dragRef.current) {
127
+ return;
128
+ }
129
+ const point = localPoint(event) ?? { x: 0, y: 0 };
130
+ startDrag(event, beginBrushDrag(stateRef.current, type), point);
131
+ },
132
+ [startDrag]
133
+ );
134
+ const applyOffset = useCallback(
135
+ (offset) => {
136
+ const latest = latestRef.current;
137
+ const current = stateRef.current;
138
+ if (!current.isBrushing) {
139
+ return;
140
+ }
141
+ const next = dragBrush(current, offset, latest.stage, moveMode);
142
+ commitState(next);
143
+ latest.onChange(toDomain(next, latest.xScale));
144
+ },
145
+ [commitState, moveMode]
146
+ );
147
+ const handlePointerMove = useCallback(
148
+ (event) => {
149
+ const drag = dragRef.current;
150
+ if (!drag || event.pointerId !== drag.pointerId) {
151
+ return;
152
+ }
153
+ if (moveMode === "local") {
154
+ const point = localPoint(event) ?? { x: 0, y: 0 };
155
+ applyOffset({ x: point.x - drag.local.x, y: point.y - drag.local.y });
156
+ return;
157
+ }
158
+ pendingMoveRef.current = { pageX: event.pageX, pageY: event.pageY };
159
+ if (moveTimerRef.current) {
160
+ clearTimeout(moveTimerRef.current);
161
+ }
162
+ moveTimerRef.current = setTimeout(() => {
163
+ moveTimerRef.current = null;
164
+ const pending = pendingMoveRef.current;
165
+ const active = dragRef.current;
166
+ if (!(pending && active)) {
167
+ return;
168
+ }
169
+ applyOffset({
170
+ x: pending.pageX - active.pageX,
171
+ y: pending.pageY - active.pageY
172
+ });
173
+ }, WINDOW_MOVE_DEBOUNCE_MS);
174
+ },
175
+ [applyOffset, moveMode]
176
+ );
177
+ const handlePointerEnd = useCallback(
178
+ (event) => {
179
+ const drag = dragRef.current;
180
+ if (!drag || event.pointerId !== drag.pointerId) {
181
+ return;
182
+ }
183
+ if (moveTimerRef.current) {
184
+ clearTimeout(moveTimerRef.current);
185
+ moveTimerRef.current = null;
186
+ }
187
+ const result = endBrush(stateRef.current, moveMode);
188
+ if (result) {
189
+ commitState(result.state);
190
+ }
191
+ dragRef.current = null;
192
+ try {
193
+ if (drag.target.hasPointerCapture(drag.pointerId)) {
194
+ drag.target.releasePointerCapture(drag.pointerId);
195
+ }
196
+ } catch {
197
+ }
198
+ if (!result) {
199
+ return;
200
+ }
201
+ onBrushEnd(toDomain(result.state, xScale));
202
+ for (let i = 0; i < result.changeCount; i++) {
203
+ onChange(toDomain(result.state, xScale));
204
+ }
205
+ },
206
+ [commitState, moveMode, onBrushEnd, onChange, xScale]
207
+ );
208
+ const handleOverlayDoubleClick = useCallback(() => {
209
+ const next = idleBrushState();
210
+ commitState(next);
211
+ onChange(toDomain(next, xScale));
212
+ }, [commitState, onChange, xScale]);
213
+ const selection = brushSelectionRect(state.extent);
214
+ const isBrushActive = state.extent.x0 !== -1 && state.extent.x1 !== -1;
215
+ const { brushingType } = state;
216
+ const selectionLocked = state.isBrushing || state.activeHandle !== null;
217
+ const fill = "transparent";
218
+ return /* @__PURE__ */ jsxs(
219
+ "g",
220
+ {
221
+ className: "visx-group visx-brush",
222
+ onLostPointerCapture: handlePointerEnd,
223
+ onPointerCancel: handlePointerEnd,
224
+ onPointerMove: handlePointerMove,
225
+ onPointerUp: handlePointerEnd,
226
+ transform: "translate(0, 0)",
227
+ children: [
228
+ brushingType === "select" ? /* @__PURE__ */ jsx("rect", { ...{ width, height, fill } }) : null,
229
+ /* @__PURE__ */ jsx(
230
+ "rect",
231
+ {
232
+ ...{
233
+ className: "visx-bar visx-brush-overlay",
234
+ fill,
235
+ x: 0,
236
+ y: 0,
237
+ width,
238
+ height,
239
+ onDoubleClick: handleOverlayDoubleClick,
240
+ onPointerDown: handleOverlayPointerDown,
241
+ style: { cursor: "crosshair" }
242
+ }
243
+ }
244
+ ),
245
+ brushingType === "move" ? /* @__PURE__ */ jsx("rect", { ...{ width: selection.width, height: selection.height, fill } }) : null,
246
+ /* @__PURE__ */ jsxs("g", { children: [
247
+ brushingType === "move" ? /* @__PURE__ */ jsx("rect", { ...{ width, height, fill, style: { cursor: "move" } } }) : null,
248
+ /* @__PURE__ */ jsx(
249
+ "rect",
250
+ {
251
+ ...{
252
+ ...selection,
253
+ className: "visx-brush-selection",
254
+ onPointerDown: (event) => handleDragPointerDown("move", event),
255
+ style: {
256
+ pointerEvents: selectionLocked ? "none" : "all",
257
+ cursor: "move"
258
+ },
259
+ ...selectedBoxStyle
260
+ }
261
+ }
262
+ )
263
+ ] }),
264
+ brushHandleRects(state.extent, handleSize, height).map((handle) => /* @__PURE__ */ jsxs(Fragment, { children: [
265
+ brushingType === handle.type ? /* @__PURE__ */ jsx("rect", { ...{ width, height, fill } }) : null,
266
+ /* @__PURE__ */ jsxs("g", { children: [
267
+ brushingType === handle.type ? /* @__PURE__ */ jsx(
268
+ "rect",
269
+ {
270
+ ...{ fill, width, height, style: { cursor: "ew-resize" } }
271
+ }
272
+ ) : null,
273
+ /* @__PURE__ */ jsx(
274
+ "g",
275
+ {
276
+ onPointerDown: (event) => handleDragPointerDown(handle.type, event),
277
+ children: renderChartBrushHandle({
278
+ x: handle.x,
279
+ y: handle.y,
280
+ width: handle.width,
281
+ height: handle.height,
282
+ className: `visx-brush-handle-${handle.type}`,
283
+ isBrushActive
284
+ })
285
+ }
286
+ )
287
+ ] })
288
+ ] }, `handle-${handle.type}`))
289
+ ]
290
+ }
291
+ );
292
+ });
293
+ function toDate(value) {
294
+ if (value instanceof Date) {
295
+ return value;
296
+ }
297
+ if (typeof value === "number") {
298
+ return new Date(value);
299
+ }
300
+ return new Date(Number(value));
301
+ }
302
+ function boundsToPixelExtent(bounds, xScale, innerWidth) {
303
+ if (!bounds || typeof bounds.x0 === "undefined" || typeof bounds.x1 === "undefined") {
304
+ return null;
305
+ }
306
+ const start = toDate(bounds.x0);
307
+ const end = toDate(bounds.x1);
308
+ const xScaleFn = xScale;
309
+ const x0 = Math.max(0, xScaleFn(start < end ? start : end) ?? 0);
310
+ const x1 = Math.min(
311
+ innerWidth,
312
+ xScaleFn(end > start ? end : start) ?? innerWidth
313
+ );
314
+ if (x1 <= x0) {
315
+ return null;
316
+ }
317
+ return { x0, x1 };
318
+ }
319
+ const ChartBrushInner = memo(function ChartBrushInner2({
320
+ brushDirection = "horizontal",
321
+ selectedBoxStyle,
322
+ initialSelection,
323
+ useWindowMoveEvents = true,
324
+ xScale,
325
+ innerWidth,
326
+ innerHeight,
327
+ margin,
328
+ onBrushPreview,
329
+ onBrushCommit,
330
+ blurPx,
331
+ fadeOuterEdges,
332
+ selectionPattern
333
+ }) {
334
+ const initialBrushPosition = useMemo(() => {
335
+ if (!initialSelection || innerWidth <= 0 || innerHeight <= 0) {
336
+ return void 0;
337
+ }
338
+ const xScaleFn = xScale;
339
+ const x0 = Math.max(0, xScaleFn(initialSelection.start) ?? 0);
340
+ const x1 = Math.min(
341
+ innerWidth,
342
+ xScaleFn(initialSelection.end) ?? innerWidth
343
+ );
344
+ if (x1 <= x0) {
345
+ return void 0;
346
+ }
347
+ return {
348
+ start: { x: x0, y: 0 },
349
+ end: { x: x1, y: innerHeight }
350
+ };
351
+ }, [initialSelection, xScale, innerWidth, innerHeight]);
352
+ const [pixelExtent, setPixelExtent] = useState(() => ({
353
+ x0: initialBrushPosition?.start.x ?? 0,
354
+ x1: initialBrushPosition?.end.x ?? innerWidth
355
+ }));
356
+ const [extentSource, setExtentSource] = useState({
357
+ initialBrushPosition,
358
+ innerWidth
359
+ });
360
+ if (extentSource.initialBrushPosition !== initialBrushPosition || extentSource.innerWidth !== innerWidth) {
361
+ setExtentSource({ initialBrushPosition, innerWidth });
362
+ setPixelExtent({
363
+ x0: initialBrushPosition?.start.x ?? 0,
364
+ x1: initialBrushPosition?.end.x ?? innerWidth
365
+ });
366
+ }
367
+ const updatePixelExtent = useCallback(
368
+ (bounds) => {
369
+ const pixels = boundsToPixelExtent(bounds, xScale, innerWidth);
370
+ if (pixels) {
371
+ setPixelExtent(pixels);
372
+ }
373
+ },
374
+ [innerWidth, xScale]
375
+ );
376
+ const handleBrushPreview = useCallback(
377
+ (bounds) => {
378
+ updatePixelExtent(bounds);
379
+ onBrushPreview?.(bounds);
380
+ },
381
+ [onBrushPreview, updatePixelExtent]
382
+ );
383
+ const handleBrushCommit = useCallback(
384
+ (bounds) => {
385
+ updatePixelExtent(bounds);
386
+ onBrushCommit(bounds);
387
+ },
388
+ [onBrushCommit, updatePixelExtent]
389
+ );
390
+ return /* @__PURE__ */ jsxs("g", { className: "chart-brush", children: [
391
+ /* @__PURE__ */ jsx(
392
+ ChartBrushTrackOverlay,
393
+ {
394
+ blurPx,
395
+ fadeOuterEdges,
396
+ innerHeight,
397
+ innerWidth,
398
+ selectionX0: pixelExtent.x0,
399
+ selectionX1: pixelExtent.x1
400
+ }
401
+ ),
402
+ /* @__PURE__ */ jsx(
403
+ ChartBrushSelectionOverlay,
404
+ {
405
+ innerHeight,
406
+ innerWidth,
407
+ pattern: selectionPattern,
408
+ selectionX0: pixelExtent.x0,
409
+ selectionX1: pixelExtent.x1
410
+ }
411
+ ),
412
+ /* @__PURE__ */ jsx(
413
+ ChartBrushHandleOverlay,
414
+ {
415
+ innerHeight,
416
+ innerWidth,
417
+ selectionX0: pixelExtent.x0,
418
+ selectionX1: pixelExtent.x1
419
+ }
420
+ ),
421
+ /* @__PURE__ */ jsx(
422
+ ChartBrushInteraction,
423
+ {
424
+ brushDirection,
425
+ handleSize: 8,
426
+ height: innerHeight,
427
+ initialBrushPosition,
428
+ moveMode: useWindowMoveEvents ? "window" : "local",
429
+ onBrushEnd: handleBrushCommit,
430
+ onChange: handleBrushPreview,
431
+ selectedBoxStyle: selectedBoxStyle ?? DEFAULT_SELECTED_BOX_STYLE,
432
+ startMargin: useWindowMoveEvents ? margin : ZERO_MARGIN,
433
+ width: innerWidth,
434
+ xScale
435
+ },
436
+ `brush-${innerWidth}-${innerHeight}`
437
+ )
438
+ ] });
439
+ });
440
+ function ChartBrush({
441
+ onSelectionChange,
442
+ brushDirection = "horizontal",
443
+ selectedBoxStyle,
444
+ initialSelection,
445
+ selection: _selection,
446
+ useWindowMoveEvents = true,
447
+ blurPx,
448
+ fadeOuterEdges,
449
+ selectionPattern
450
+ }) {
451
+ const { xScale, innerWidth, innerHeight, margin, isLoaded } = useChartStable();
452
+ const boundsToSelection = useCallback(
453
+ (bounds) => {
454
+ if (!bounds || typeof bounds.x0 === "undefined" || typeof bounds.x1 === "undefined") {
455
+ return null;
456
+ }
457
+ const start = toDate(bounds.x0);
458
+ const end = toDate(bounds.x1);
459
+ if (start.getTime() === end.getTime()) {
460
+ return null;
461
+ }
462
+ return {
463
+ start: start < end ? start : end,
464
+ end: end > start ? end : start
465
+ };
466
+ },
467
+ []
468
+ );
469
+ const notifySelectionChange = useCallback(
470
+ (bounds) => {
471
+ if (!onSelectionChange) {
472
+ return;
473
+ }
474
+ onSelectionChange(boundsToSelection(bounds));
475
+ },
476
+ [onSelectionChange, boundsToSelection]
477
+ );
478
+ const handleBrushPreview = useCallback(
479
+ (bounds) => {
480
+ notifySelectionChange(bounds);
481
+ },
482
+ [notifySelectionChange]
483
+ );
484
+ const handleBrushCommit = useCallback(
485
+ (bounds) => {
486
+ notifySelectionChange(bounds);
487
+ },
488
+ [notifySelectionChange]
489
+ );
490
+ if (!isLoaded || innerWidth <= 0 || innerHeight <= 0) {
491
+ return null;
492
+ }
493
+ return /* @__PURE__ */ jsx(
494
+ ChartBrushInner,
495
+ {
496
+ blurPx,
497
+ brushDirection,
498
+ fadeOuterEdges,
499
+ initialSelection,
500
+ innerHeight,
501
+ innerWidth,
502
+ margin,
503
+ onBrushCommit: handleBrushCommit,
504
+ onBrushPreview: handleBrushPreview,
505
+ selectedBoxStyle,
506
+ selectionPattern,
507
+ useWindowMoveEvents,
508
+ xScale
509
+ }
510
+ );
511
+ }
512
+ ChartBrush.displayName = "ChartBrush";
513
+ var chart_brush_default = ChartBrush;
514
+ export {
515
+ ChartBrush,
516
+ chart_brush_default as default
517
+ };
@@ -0,0 +1,8 @@
1
+ const chartCenterContainerClassName = "@container/chart-center size-full min-w-0";
2
+ const chartCenterValueClassName = "font-bold tabular-nums leading-none text-[clamp(0.75rem,22cqw,1.875rem)]";
3
+ const chartCenterLabelClassName = "max-w-full truncate leading-tight text-[clamp(0.625rem,9cqw,0.75rem)]";
4
+ export {
5
+ chartCenterContainerClassName,
6
+ chartCenterLabelClassName,
7
+ chartCenterValueClassName
8
+ };
@@ -0,0 +1,119 @@
1
+ import {
2
+ Children,
3
+ cloneElement,
4
+ createElement,
5
+ Fragment,
6
+ isValidElement
7
+ } from "react";
8
+ const CHART_CLIP_PASSTHROUGH = "__chartClipPassthrough";
9
+ function isChartClipPassthrough(type) {
10
+ return typeof type === "function" && type[CHART_CLIP_PASSTHROUGH] === true;
11
+ }
12
+ const REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
13
+ function isLazyComponentType(type) {
14
+ return typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE && typeof type._init === "function";
15
+ }
16
+ function resolveLazyChartChild(child) {
17
+ const type = child.type;
18
+ if (!isLazyComponentType(type)) {
19
+ return child;
20
+ }
21
+ let resolved;
22
+ try {
23
+ resolved = type._init(type._payload);
24
+ } catch {
25
+ return child;
26
+ }
27
+ if (typeof resolved !== "function" && !(typeof resolved === "object" && resolved !== null)) {
28
+ return child;
29
+ }
30
+ return createElement(resolved, {
31
+ ...child.props,
32
+ ...child.key == null ? {} : { key: child.key }
33
+ });
34
+ }
35
+ function isUnresolvedLazyChartChild(child) {
36
+ return isLazyComponentType(child.type);
37
+ }
38
+ function resolveChartChildElement(child) {
39
+ const element = resolveLazyChartChild(child);
40
+ if (isChartClipPassthrough(element.type)) {
41
+ const inner = element.props.children;
42
+ if (isValidElement(inner)) {
43
+ return resolveChartChildElement(inner);
44
+ }
45
+ }
46
+ return element;
47
+ }
48
+ function renderableChartChild(child) {
49
+ return resolveLazyChartChild(child);
50
+ }
51
+ function forEachChartChild(children, callback) {
52
+ let index = 0;
53
+ const visit = (nodes) => {
54
+ Children.forEach(nodes, (child) => {
55
+ if (!isValidElement(child)) {
56
+ return;
57
+ }
58
+ if (child.type === Fragment) {
59
+ visit(child.props.children);
60
+ return;
61
+ }
62
+ callback(resolveLazyChartChild(child), index);
63
+ index += 1;
64
+ });
65
+ };
66
+ visit(children);
67
+ }
68
+ const CLIP_EXCLUDED_COMPONENT_NAMES = /* @__PURE__ */ new Set([
69
+ "Background",
70
+ "Grid",
71
+ "XAxis",
72
+ "YAxis",
73
+ "BarXAxis",
74
+ "BarYAxis",
75
+ "LiveXAxis",
76
+ "LiveYAxis"
77
+ ]);
78
+ const UNDERLAY_COMPONENT_NAMES = /* @__PURE__ */ new Set([
79
+ "ReferenceArea",
80
+ "BarColumnTrack",
81
+ "Weekends",
82
+ "Deadline"
83
+ ]);
84
+ function isPostOverlayComponent(child) {
85
+ const childType = child.type;
86
+ if (childType.__isChartMarkers || childType.__isPostOverlay) {
87
+ return true;
88
+ }
89
+ const componentName = typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
90
+ return componentName === "ChartMarkers" || componentName === "MarkerGroup" || componentName === "ChartBrush";
91
+ }
92
+ function isUnderlayComponent(child) {
93
+ const childType = child.type;
94
+ const componentName = typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
95
+ return UNDERLAY_COMPONENT_NAMES.has(componentName);
96
+ }
97
+ function isClipExcludedComponent(child) {
98
+ const childType = child.type;
99
+ const componentName = typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
100
+ return CLIP_EXCLUDED_COMPONENT_NAMES.has(componentName);
101
+ }
102
+ function renderKeyedChartLayers(children) {
103
+ return children.map(
104
+ (child, index) => cloneElement(child, { key: child.key ?? `chart-layer-${index}` })
105
+ );
106
+ }
107
+ export {
108
+ CHART_CLIP_PASSTHROUGH,
109
+ forEachChartChild,
110
+ isChartClipPassthrough,
111
+ isClipExcludedComponent,
112
+ isPostOverlayComponent,
113
+ isUnderlayComponent,
114
+ isUnresolvedLazyChartChild,
115
+ renderKeyedChartLayers,
116
+ renderableChartChild,
117
+ resolveChartChildElement,
118
+ resolveLazyChartChild
119
+ };
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ const DEFAULT_CHART_CONFIG = {
5
+ tooltipSpring: { stiffness: 300, damping: 30 },
6
+ tooltipBoxSpring: { stiffness: 100, damping: 20 },
7
+ highlightSpring: { stiffness: 180, damping: 28 }
8
+ };
9
+ const ChartConfigContext = createContext(null);
10
+ function ChartConfigProvider({
11
+ value,
12
+ children
13
+ }) {
14
+ const merged = useMemo(
15
+ () => ({
16
+ ...DEFAULT_CHART_CONFIG,
17
+ ...value
18
+ }),
19
+ [value]
20
+ );
21
+ return /* @__PURE__ */ jsx(ChartConfigContext.Provider, { value: merged, children });
22
+ }
23
+ function useChartConfig() {
24
+ return useContext(ChartConfigContext) ?? DEFAULT_CHART_CONFIG;
25
+ }
26
+ const DEFAULT_TOOLTIP_BOX_DAMPING = DEFAULT_CHART_CONFIG.tooltipBoxSpring.damping;
27
+ function resolveTooltipBoxMotion(damping) {
28
+ if (damping === 0) {
29
+ return {
30
+ animate: false,
31
+ springConfig: DEFAULT_CHART_CONFIG.tooltipBoxSpring
32
+ };
33
+ }
34
+ const effectiveDamping = damping ?? DEFAULT_TOOLTIP_BOX_DAMPING;
35
+ let stiffness = DEFAULT_CHART_CONFIG.tooltipBoxSpring.stiffness;
36
+ if (effectiveDamping < DEFAULT_TOOLTIP_BOX_DAMPING) {
37
+ const t = (DEFAULT_TOOLTIP_BOX_DAMPING - effectiveDamping) / DEFAULT_TOOLTIP_BOX_DAMPING;
38
+ stiffness += t * 400;
39
+ } else if (effectiveDamping > DEFAULT_TOOLTIP_BOX_DAMPING) {
40
+ const t = (effectiveDamping - DEFAULT_TOOLTIP_BOX_DAMPING) / (100 - DEFAULT_TOOLTIP_BOX_DAMPING);
41
+ stiffness -= t * 85;
42
+ }
43
+ return {
44
+ animate: true,
45
+ springConfig: {
46
+ stiffness: Math.max(12, Math.round(stiffness)),
47
+ damping: effectiveDamping
48
+ }
49
+ };
50
+ }
51
+ export {
52
+ ChartConfigProvider,
53
+ DEFAULT_CHART_CONFIG,
54
+ resolveTooltipBoxMotion,
55
+ useChartConfig
56
+ };