@aiconstructions/graficos 0.0.0-stage → 0.2.2

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 +57 -0
  2. package/LICENSE-BKLIT +21 -0
  3. package/LICENSE-visx-pattern +21 -0
  4. package/README.md +189 -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,519 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ animate,
5
+ useMotionValue,
6
+ useMotionValueEvent
7
+ } from "motion/react";
8
+ import { memo, useCallback, useEffect, useMemo, useRef } from "react";
9
+ import { DEFAULT_CHART_ENTER_TRANSITION } from "../animation";
10
+ import { useIsomorphicLayoutEffect } from "../chart-parent-size";
11
+ import {
12
+ HEATMAP_LOADING_BASE_CELL_OPACITY,
13
+ HEATMAP_LOADING_CONCEAL_MS,
14
+ heatmapLoadingCellParticipates,
15
+ heatmapWaveDelayMs,
16
+ resolveHeatmapWaveTiming
17
+ } from "./heatmap-animation";
18
+ import { heatmapLevelCellFillOpacity } from "./heatmap-colors";
19
+ import {
20
+ useHeatmap,
21
+ useHeatmapInteraction
22
+ } from "./heatmap-context";
23
+ import { heatmapRectCells } from "./heatmap-rect-cells";
24
+ import {
25
+ getHeatmapContributionLevel,
26
+ isHeatmapGhostBin,
27
+ isHeatmapHoverEffectEnabled,
28
+ resolveHeatmapDisplayRange,
29
+ resolveHeatmapHoverStyle,
30
+ resolveHeatmapRowOpacity
31
+ } from "./heatmap-utils";
32
+ const HEATMAP_INACTIVE_OPACITY = 0.3;
33
+ const HEATMAP_ENTER_FROM_TRANSFORM = "translateY(3px) scale(0.86)";
34
+ const HEATMAP_INACTIVE_TRANSITION = {
35
+ duration: 0.22,
36
+ ease: [0.4, 0, 0.2, 1]
37
+ };
38
+ const HEATMAP_CONCEAL_TRANSITION = {
39
+ duration: HEATMAP_LOADING_CONCEAL_MS / 1e3,
40
+ ease: DEFAULT_CHART_ENTER_TRANSITION.ease
41
+ };
42
+ function useMotionValueApply(value, apply) {
43
+ const applyRef = useRef(apply);
44
+ applyRef.current = apply;
45
+ useIsomorphicLayoutEffect(() => {
46
+ applyRef.current(value.get());
47
+ });
48
+ useMotionValueEvent(value, "change", (v) => applyRef.current(v));
49
+ }
50
+ function computeHeatmapCellFaded(isCellHovering, isLevelHovering, hoveredCell, hoveredLegendLevel, cell, count) {
51
+ if (isCellHovering && hoveredCell) {
52
+ const isHighlighted = hoveredCell.column === cell.column && hoveredCell.row === cell.row;
53
+ return { isHighlighted, isDimmed: !isHighlighted };
54
+ }
55
+ if (isLevelHovering && hoveredLegendLevel !== null) {
56
+ const isHighlighted = getHeatmapContributionLevel(count) === hoveredLegendLevel;
57
+ return { isHighlighted, isDimmed: !isHighlighted };
58
+ }
59
+ return { isHighlighted: false, isDimmed: false };
60
+ }
61
+ function syncHeatmapCellLayerOpacities(params) {
62
+ const {
63
+ animateCells,
64
+ chartStatus,
65
+ dataOpacity,
66
+ isAwaitingLoadingConceal,
67
+ isExitingToLoading,
68
+ isLoadingResting,
69
+ isReadyResting,
70
+ isRevealActive,
71
+ participates,
72
+ pulseOpacity,
73
+ readyDataOpacity,
74
+ shimmerOpacity,
75
+ showLoadingCellsLayer,
76
+ showShimmerPulse
77
+ } = params;
78
+ if (!animateCells) {
79
+ if (isReadyResting) {
80
+ dataOpacity.set(readyDataOpacity);
81
+ shimmerOpacity.set(0);
82
+ pulseOpacity.set(0);
83
+ } else if (chartStatus === "loading") {
84
+ dataOpacity.set(0);
85
+ pulseOpacity.set(0);
86
+ shimmerOpacity.set(
87
+ participates && showLoadingCellsLayer ? 0 : HEATMAP_LOADING_BASE_CELL_OPACITY
88
+ );
89
+ }
90
+ return;
91
+ }
92
+ if (isLoadingResting) {
93
+ animate(dataOpacity, 0, { duration: 0 });
94
+ if (!showShimmerPulse) {
95
+ animate(shimmerOpacity, HEATMAP_LOADING_BASE_CELL_OPACITY, {
96
+ duration: 0
97
+ });
98
+ }
99
+ return;
100
+ }
101
+ if (isRevealActive) {
102
+ pulseOpacity.set(0);
103
+ shimmerOpacity.set(0);
104
+ dataOpacity.jump(readyDataOpacity);
105
+ return;
106
+ }
107
+ if (isAwaitingLoadingConceal || isExitingToLoading) {
108
+ animate(dataOpacity, 0, HEATMAP_CONCEAL_TRANSITION);
109
+ animate(shimmerOpacity, 0, { duration: 0 });
110
+ return;
111
+ }
112
+ if (isReadyResting) {
113
+ animate(dataOpacity, readyDataOpacity, HEATMAP_INACTIVE_TRANSITION);
114
+ animate(shimmerOpacity, 0, { duration: 0 });
115
+ pulseOpacity.set(0);
116
+ }
117
+ }
118
+ const HeatmapMotionCell = memo(function HeatmapMotionCell2({
119
+ cell,
120
+ bin,
121
+ cornerRadius,
122
+ fillScale,
123
+ interactive,
124
+ inactiveOpacity,
125
+ inactiveScale,
126
+ activeScale,
127
+ rowOpacity,
128
+ hoverState,
129
+ onEnter,
130
+ onLeave,
131
+ enterDelayMs,
132
+ enterFadeMs,
133
+ enterFadeEasing
134
+ }) {
135
+ const {
136
+ chartStatus,
137
+ chartPhase,
138
+ isLoaded,
139
+ revealMode,
140
+ revealEpoch,
141
+ animateCells,
142
+ showLoadingCells: showLoadingCellsLayer,
143
+ loadingCellMaxOpacity,
144
+ loadingCellRandomness,
145
+ levelStyles
146
+ } = useHeatmap();
147
+ const levelStyle = levelStyles[getHeatmapContributionLevel(bin.count ?? 0)] ?? levelStyles[0];
148
+ const targetFill = fillScale(bin.count);
149
+ const emptyFill = fillScale(0);
150
+ const patternFillOpacity = heatmapLevelCellFillOpacity(levelStyle);
151
+ const dataOpacity = useMotionValue(0);
152
+ const shimmerOpacity = useMotionValue(0);
153
+ const pulseOpacity = useMotionValue(0);
154
+ const wasShimmerPulsingRef = useRef(false);
155
+ const isLoadingResting = chartStatus === "loading" && chartPhase === "loading";
156
+ const isAwaitingLoadingConceal = chartStatus === "loading" && chartPhase === "ready";
157
+ const isExitingToLoading = chartPhase === "exitingReady";
158
+ const isRevealActive = chartPhase === "revealing" && !isLoaded && (revealMode === "fromLoading" || revealMode === "enter");
159
+ const isReadyResting = chartStatus === "ready" && chartPhase === "ready" && isLoaded;
160
+ const participates = useMemo(
161
+ () => heatmapLoadingCellParticipates(
162
+ cell.column,
163
+ cell.row,
164
+ loadingCellRandomness
165
+ ),
166
+ [cell.column, cell.row, loadingCellRandomness]
167
+ );
168
+ const showShimmerPulse = animateCells && showLoadingCellsLayer && participates && isLoadingResting;
169
+ const dataRectRef = useRef(null);
170
+ const shimmerRectRef = useRef(null);
171
+ const groupRef = useRef(null);
172
+ const scale = useMotionValue(1);
173
+ const revealAnimationRef = useRef(null);
174
+ const readyHoverStyle = resolveHeatmapHoverStyle(
175
+ hoverState.isHighlighted,
176
+ hoverState.isDimmed,
177
+ { inactiveOpacity, inactiveScale, activeScale }
178
+ );
179
+ const rowOpacityMultiplier = resolveHeatmapRowOpacity(cell.row, rowOpacity);
180
+ const readyDataOpacity = readyHoverStyle.opacity;
181
+ const readyScale = isReadyResting ? readyHoverStyle.scale : 1;
182
+ const transformOrigin = `${cell.x + cell.width / 2}px ${cell.y + cell.height / 2}px`;
183
+ useEffect(() => {
184
+ if (scale.get() === readyScale && !scale.isAnimating()) {
185
+ return;
186
+ }
187
+ const controls = animate(scale, readyScale, HEATMAP_INACTIVE_TRANSITION);
188
+ return () => controls.stop();
189
+ }, [readyScale, scale]);
190
+ useEffect(() => {
191
+ if (!showShimmerPulse) {
192
+ wasShimmerPulsingRef.current = false;
193
+ pulseOpacity.set(0);
194
+ return;
195
+ }
196
+ const isFreshLoadingPulse = isLoadingResting && !wasShimmerPulsingRef.current;
197
+ wasShimmerPulsingRef.current = true;
198
+ if (isFreshLoadingPulse) {
199
+ pulseOpacity.set(0);
200
+ }
201
+ let cancelled = false;
202
+ let current;
203
+ const pulse = async () => {
204
+ while (!cancelled) {
205
+ const target = Math.random() * loadingCellMaxOpacity;
206
+ const duration = 0.35 + Math.random() * 0.85;
207
+ current = animate(pulseOpacity, target, {
208
+ duration,
209
+ ease: [0.45, 0, 0.55, 1]
210
+ });
211
+ try {
212
+ await current;
213
+ } catch {
214
+ break;
215
+ }
216
+ if (cancelled) {
217
+ break;
218
+ }
219
+ await new Promise((resolve) => {
220
+ window.setTimeout(resolve, 80 + Math.random() * 420);
221
+ });
222
+ }
223
+ };
224
+ pulse().catch(() => void 0);
225
+ return () => {
226
+ cancelled = true;
227
+ current?.stop();
228
+ };
229
+ }, [isLoadingResting, loadingCellMaxOpacity, pulseOpacity, showShimmerPulse]);
230
+ useEffect(() => {
231
+ syncHeatmapCellLayerOpacities({
232
+ animateCells,
233
+ chartStatus,
234
+ dataOpacity,
235
+ isAwaitingLoadingConceal,
236
+ isExitingToLoading,
237
+ isLoadingResting,
238
+ isReadyResting,
239
+ isRevealActive,
240
+ participates,
241
+ pulseOpacity,
242
+ readyDataOpacity,
243
+ shimmerOpacity,
244
+ showLoadingCellsLayer,
245
+ showShimmerPulse
246
+ });
247
+ }, [
248
+ animateCells,
249
+ chartStatus,
250
+ dataOpacity,
251
+ isAwaitingLoadingConceal,
252
+ isExitingToLoading,
253
+ isLoadingResting,
254
+ isReadyResting,
255
+ isRevealActive,
256
+ participates,
257
+ pulseOpacity,
258
+ readyDataOpacity,
259
+ shimmerOpacity,
260
+ showLoadingCellsLayer,
261
+ showShimmerPulse
262
+ ]);
263
+ useIsomorphicLayoutEffect(() => {
264
+ if (!(animateCells && isRevealActive)) {
265
+ if (!animateCells || chartStatus === "loading") {
266
+ revealAnimationRef.current?.cancel();
267
+ revealAnimationRef.current = null;
268
+ }
269
+ return;
270
+ }
271
+ const rect = dataRectRef.current;
272
+ if (!rect || typeof rect.animate !== "function") {
273
+ return;
274
+ }
275
+ revealAnimationRef.current?.cancel();
276
+ const animation = rect.animate(
277
+ [
278
+ {
279
+ offset: 0,
280
+ opacity: 0,
281
+ transform: HEATMAP_ENTER_FROM_TRANSFORM
282
+ }
283
+ ],
284
+ {
285
+ delay: enterDelayMs,
286
+ duration: enterFadeMs,
287
+ easing: enterFadeEasing,
288
+ fill: "backwards"
289
+ }
290
+ );
291
+ animation.onfinish = () => {
292
+ animation.cancel();
293
+ if (revealAnimationRef.current === animation) {
294
+ revealAnimationRef.current = null;
295
+ }
296
+ };
297
+ revealAnimationRef.current = animation;
298
+ }, [
299
+ animateCells,
300
+ chartStatus,
301
+ enterDelayMs,
302
+ enterFadeEasing,
303
+ enterFadeMs,
304
+ isRevealActive,
305
+ revealEpoch
306
+ ]);
307
+ const cellProps = {
308
+ height: cell.height,
309
+ rx: cornerRadius,
310
+ ry: cornerRadius,
311
+ width: cell.width,
312
+ x: cell.x,
313
+ y: cell.y
314
+ };
315
+ useMotionValueApply(scale, (v) => {
316
+ const g = groupRef.current;
317
+ if (g) {
318
+ g.style.transform = v === 1 ? "" : `scale(${v})`;
319
+ }
320
+ });
321
+ useMotionValueApply(dataOpacity, (v) => {
322
+ if (dataRectRef.current) {
323
+ dataRectRef.current.style.opacity = String(v);
324
+ }
325
+ });
326
+ const shimmerSource = showShimmerPulse ? pulseOpacity : shimmerOpacity;
327
+ useMotionValueApply(shimmerSource, (v) => {
328
+ if (shimmerRectRef.current) {
329
+ shimmerRectRef.current.style.opacity = String(v);
330
+ }
331
+ });
332
+ return /* @__PURE__ */ jsxs("g", { ref: groupRef, style: { transformOrigin }, children: [
333
+ /* @__PURE__ */ jsx(
334
+ "rect",
335
+ {
336
+ ...cellProps,
337
+ fill: targetFill,
338
+ fillOpacity: (cell.opacity ?? 1) * patternFillOpacity * rowOpacityMultiplier,
339
+ onPointerEnter: () => onEnter(cell.column, cell.row, bin, cell.x, cell.y),
340
+ onPointerLeave: onLeave,
341
+ ref: dataRectRef,
342
+ style: {
343
+ cursor: interactive ? "pointer" : void 0,
344
+ // Centre in user space (not `transform-box: fill-box`, which makes
345
+ // Chrome re-measure the bbox every frame of the enter animation).
346
+ transformOrigin
347
+ }
348
+ }
349
+ ),
350
+ /* @__PURE__ */ jsx(
351
+ "rect",
352
+ {
353
+ ...cellProps,
354
+ fill: emptyFill,
355
+ pointerEvents: "none",
356
+ ref: shimmerRectRef
357
+ }
358
+ )
359
+ ] });
360
+ });
361
+ const HeatmapCells = memo(function HeatmapCells2({
362
+ cornerRadius = 2,
363
+ colorScale: colorScaleProp,
364
+ inactiveOpacity = HEATMAP_INACTIVE_OPACITY,
365
+ inactiveScale = 1,
366
+ activeScale = 1,
367
+ rowOpacity,
368
+ interactive = true,
369
+ hideGhostCells = true
370
+ }) {
371
+ const {
372
+ data,
373
+ binWidth,
374
+ binHeight,
375
+ gap,
376
+ margin,
377
+ xScale,
378
+ yScale,
379
+ chartStatus,
380
+ colorScale: contextColorScale,
381
+ fillScale: contextFillScale,
382
+ animationDuration,
383
+ enterTransition,
384
+ enterStaggerScale
385
+ } = useHeatmap();
386
+ const colorScale = colorScaleProp ?? contextColorScale;
387
+ const fillScale = contextFillScale;
388
+ const cellsInteractive = interactive && chartStatus !== "loading";
389
+ const {
390
+ hoveredCell,
391
+ hoveredLegendLevel,
392
+ setHoveredCell,
393
+ setHoveredLegendLevel,
394
+ setTooltipData
395
+ } = useHeatmapInteraction();
396
+ const handleCellEnter = useCallback(
397
+ (column, row, bin, x, y) => {
398
+ if (!cellsInteractive) {
399
+ return;
400
+ }
401
+ setHoveredLegendLevel(null);
402
+ setHoveredCell({ column, row });
403
+ setTooltipData({
404
+ column,
405
+ row,
406
+ count: bin.count,
407
+ date: bin.date,
408
+ x: margin.left + x + binWidth / 2,
409
+ y: margin.top + y + binHeight / 2
410
+ });
411
+ },
412
+ [
413
+ binHeight,
414
+ binWidth,
415
+ cellsInteractive,
416
+ margin.left,
417
+ margin.top,
418
+ setHoveredCell,
419
+ setHoveredLegendLevel,
420
+ setTooltipData
421
+ ]
422
+ );
423
+ const handleCellLeave = useCallback(() => {
424
+ if (!cellsInteractive) {
425
+ return;
426
+ }
427
+ setHoveredCell(null);
428
+ setTooltipData(null);
429
+ }, [cellsInteractive, setHoveredCell, setTooltipData]);
430
+ const inactiveEnabled = isHeatmapHoverEffectEnabled({
431
+ inactiveOpacity,
432
+ inactiveScale,
433
+ activeScale
434
+ });
435
+ const isCellHovering = cellsInteractive && hoveredCell !== null && inactiveEnabled;
436
+ const isLevelHovering = cellsInteractive && hoveredLegendLevel !== null && inactiveEnabled;
437
+ const displayRange = useMemo(
438
+ () => hideGhostCells ? resolveHeatmapDisplayRange(data) : null,
439
+ [data, hideGhostCells]
440
+ );
441
+ const cells = useMemo(
442
+ () => heatmapRectCells({
443
+ binHeight,
444
+ bins: (column) => column.bins,
445
+ binWidth,
446
+ colorScale,
447
+ count: (bin) => bin.count,
448
+ data,
449
+ gap,
450
+ xScale,
451
+ yScale
452
+ }),
453
+ [binHeight, binWidth, colorScale, data, gap, xScale, yScale]
454
+ );
455
+ const waveTiming = useMemo(
456
+ () => resolveHeatmapWaveTiming({
457
+ animationDurationMs: animationDuration,
458
+ enterTransition,
459
+ enterStaggerScale,
460
+ columnCount: data.length,
461
+ rowCount: data[0]?.bins.length ?? 7
462
+ }),
463
+ [animationDuration, data, enterStaggerScale, enterTransition]
464
+ );
465
+ return (
466
+ // The wrapper visx's <Group> rendered (minus its class): cells stay one
467
+ // <g> deep, each in its own motion <g>.
468
+ /* @__PURE__ */ jsx("g", { transform: "translate(0, 0)", children: cells.flatMap(
469
+ (column) => column.map((cell) => {
470
+ const bin = data[cell.column]?.bins[cell.row];
471
+ if (!bin) {
472
+ return null;
473
+ }
474
+ if (displayRange && isHeatmapGhostBin(bin, displayRange)) {
475
+ return null;
476
+ }
477
+ const hoverState = computeHeatmapCellFaded(
478
+ isCellHovering,
479
+ isLevelHovering,
480
+ hoveredCell,
481
+ hoveredLegendLevel,
482
+ cell,
483
+ bin.count
484
+ );
485
+ return /* @__PURE__ */ jsx(
486
+ HeatmapMotionCell,
487
+ {
488
+ activeScale,
489
+ bin,
490
+ cell,
491
+ cornerRadius,
492
+ enterDelayMs: heatmapWaveDelayMs(
493
+ cell.column,
494
+ cell.row,
495
+ waveTiming
496
+ ),
497
+ enterFadeEasing: waveTiming.fadeEasing,
498
+ enterFadeMs: waveTiming.fadeMs,
499
+ fillScale,
500
+ hoverState,
501
+ inactiveOpacity,
502
+ inactiveScale,
503
+ interactive: cellsInteractive,
504
+ onEnter: handleCellEnter,
505
+ onLeave: handleCellLeave,
506
+ rowOpacity
507
+ },
508
+ `heatmap-cell-${cell.column}-${cell.row}`
509
+ );
510
+ })
511
+ ) })
512
+ );
513
+ });
514
+ HeatmapCells.displayName = "HeatmapCells";
515
+ var heatmap_cells_default = HeatmapCells;
516
+ export {
517
+ HeatmapCells,
518
+ heatmap_cells_default as default
519
+ };
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { generateHeatmapSkeletonFromTarget } from "./generate-heatmap-skeleton-data";
5
+ import { HeatmapCells } from "./heatmap-cells";
6
+ import { HeatmapChart } from "./heatmap-chart";
7
+ import { HeatmapXAxis } from "./heatmap-x-axis";
8
+ import { HeatmapYAxis } from "./heatmap-y-axis";
9
+ function HeatmapChartLoading({
10
+ data,
11
+ xDomain,
12
+ margin,
13
+ gap = 2,
14
+ cornerRadius = 2,
15
+ label = "Carregando",
16
+ className = ""
17
+ }) {
18
+ const skeletonData = useMemo(
19
+ () => generateHeatmapSkeletonFromTarget(data),
20
+ [data]
21
+ );
22
+ return /* @__PURE__ */ jsxs(
23
+ HeatmapChart,
24
+ {
25
+ className,
26
+ data: skeletonData,
27
+ gap,
28
+ loadingLabel: label,
29
+ margin,
30
+ status: "loading",
31
+ xDomain,
32
+ children: [
33
+ /* @__PURE__ */ jsx(HeatmapCells, { cornerRadius, interactive: false }),
34
+ /* @__PURE__ */ jsx(HeatmapXAxis, {}),
35
+ /* @__PURE__ */ jsx(HeatmapYAxis, {})
36
+ ]
37
+ }
38
+ );
39
+ }
40
+ var heatmap_chart_loading_default = HeatmapChartLoading;
41
+ export {
42
+ HeatmapChartLoading,
43
+ heatmap_chart_loading_default as default
44
+ };