@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,633 @@
1
+ const HEATMAP_MONTHS_ONE_YEAR = 12;
2
+ const HEATMAP_MONTHS_SIX = 6;
3
+ const HEATMAP_WEEKS_ONE_YEAR = 52;
4
+ const MS_PER_DAY = 24 * 60 * 60 * 1e3;
5
+ const MS_PER_WEEK = MS_PER_DAY * 7;
6
+ function getHeatmapCalendarRangeStart(today, months) {
7
+ const monthOffset = months === HEATMAP_MONTHS_SIX ? months : months - 1;
8
+ const start = new Date(
9
+ today.getFullYear(),
10
+ today.getMonth() - monthOffset,
11
+ 1
12
+ );
13
+ start.setHours(0, 0, 0, 0);
14
+ return start;
15
+ }
16
+ function getHeatmapYearStartMonth(today) {
17
+ return getHeatmapCalendarRangeStart(today, HEATMAP_MONTHS_ONE_YEAR);
18
+ }
19
+ function getHeatmapWeekStartSunday(date) {
20
+ const sunday = new Date(date);
21
+ sunday.setDate(sunday.getDate() - sunday.getDay());
22
+ sunday.setHours(0, 0, 0, 0);
23
+ return sunday;
24
+ }
25
+ function getHeatmapWeekCount(startSunday, endDate) {
26
+ const endSunday = getHeatmapWeekStartSunday(endDate);
27
+ return Math.floor((endSunday.getTime() - startSunday.getTime()) / MS_PER_WEEK) + 1;
28
+ }
29
+ function countHeatmapWeekDaysOnOrAfter(weekStart, threshold) {
30
+ const day = new Date(weekStart);
31
+ day.setHours(0, 0, 0, 0);
32
+ const cutoff = new Date(threshold);
33
+ cutoff.setHours(0, 0, 0, 0);
34
+ let count = 0;
35
+ for (let i = 0; i < 7; i++) {
36
+ if (day >= cutoff) {
37
+ count++;
38
+ }
39
+ day.setDate(day.getDate() + 1);
40
+ }
41
+ return count;
42
+ }
43
+ function getHeatmapWeekStartAlignedToRange(rangeStart, minDaysInFirstWeek = 4) {
44
+ const startDate = getHeatmapWeekStartSunday(rangeStart);
45
+ const weekEnd = new Date(startDate);
46
+ weekEnd.setDate(weekEnd.getDate() + 6);
47
+ if (rangeStart >= startDate && rangeStart <= weekEnd) {
48
+ return startDate;
49
+ }
50
+ while (countHeatmapWeekDaysOnOrAfter(startDate, rangeStart) < minDaysInFirstWeek) {
51
+ startDate.setDate(startDate.getDate() + 7);
52
+ }
53
+ return startDate;
54
+ }
55
+ function getHeatmapMonthLabelColumnIndex(columnIndex, separatorLayout) {
56
+ if (!separatorLayout?.atColumns.length) {
57
+ return columnIndex;
58
+ }
59
+ return getHeatmapSeparatorGroupStartColumn(
60
+ columnIndex,
61
+ separatorLayout.atColumns
62
+ );
63
+ }
64
+ function resolveHeatmapWeekRange(today, weeks = HEATMAP_WEEKS_ONE_YEAR) {
65
+ const endDate = new Date(today);
66
+ endDate.setHours(0, 0, 0, 0);
67
+ if (weeks === HEATMAP_WEEKS_ONE_YEAR) {
68
+ const rangeStart = getHeatmapYearStartMonth(endDate);
69
+ const startDate2 = getHeatmapWeekStartAlignedToRange(rangeStart);
70
+ return {
71
+ startDate: startDate2,
72
+ weekCount: getHeatmapWeekCount(startDate2, endDate),
73
+ rangeStart
74
+ };
75
+ }
76
+ const startDate = new Date(endDate);
77
+ startDate.setDate(startDate.getDate() - (weeks - 1) * 7);
78
+ startDate.setDate(startDate.getDate() - startDate.getDay());
79
+ startDate.setHours(0, 0, 0, 0);
80
+ return {
81
+ startDate,
82
+ weekCount: weeks,
83
+ rangeStart: null
84
+ };
85
+ }
86
+ function getHeatmapColumnMonthAnchor(column) {
87
+ for (const bin of column.bins) {
88
+ if (bin.date && bin.date.getDate() === 1) {
89
+ return bin.date;
90
+ }
91
+ }
92
+ const firstDate = column.bins[0]?.date;
93
+ if (!firstDate) {
94
+ return null;
95
+ }
96
+ return new Date(firstDate.getFullYear(), firstDate.getMonth(), 1);
97
+ }
98
+ function getHeatmapColumnStartDate(column) {
99
+ return column.bins[0]?.date ?? null;
100
+ }
101
+ function getHeatmapColumnEndDate(column) {
102
+ const lastBin = column.bins.at(-1);
103
+ return lastBin?.date ?? null;
104
+ }
105
+ function getHeatmapTimeExtent(columns) {
106
+ if (columns.length === 0) {
107
+ return null;
108
+ }
109
+ const firstColumn = columns[0];
110
+ if (!firstColumn) {
111
+ return null;
112
+ }
113
+ const start = getHeatmapColumnStartDate(firstColumn);
114
+ const lastColumn = columns.at(-1);
115
+ if (!lastColumn) {
116
+ return null;
117
+ }
118
+ const end = getHeatmapColumnEndDate(lastColumn);
119
+ if (!(start && end)) {
120
+ return null;
121
+ }
122
+ return [start, end];
123
+ }
124
+ function filterHeatmapColumns(columns, xDomain) {
125
+ if (!xDomain) {
126
+ return columns;
127
+ }
128
+ const start = Math.min(xDomain[0].getTime(), xDomain[1].getTime());
129
+ const end = Math.max(xDomain[0].getTime(), xDomain[1].getTime());
130
+ return columns.filter((column) => {
131
+ const weekStart = getHeatmapColumnStartDate(column)?.getTime();
132
+ const weekEnd = getHeatmapColumnEndDate(column)?.getTime();
133
+ if (weekStart == null || weekEnd == null) {
134
+ return false;
135
+ }
136
+ return weekEnd >= start && weekStart <= end;
137
+ });
138
+ }
139
+ const heatmapTooltipMonthFmt = new Intl.DateTimeFormat("pt-BR", {
140
+ month: "long"
141
+ });
142
+ const heatmapTooltipWeekdayFmt = new Intl.DateTimeFormat("pt-BR", {
143
+ weekday: "long"
144
+ });
145
+ function formatHeatmapOrdinalDay(day) {
146
+ if (day >= 11 && day <= 13) {
147
+ return `${day}th`;
148
+ }
149
+ switch (day % 10) {
150
+ case 1:
151
+ return `${day}st`;
152
+ case 2:
153
+ return `${day}nd`;
154
+ case 3:
155
+ return `${day}rd`;
156
+ default:
157
+ return `${day}th`;
158
+ }
159
+ }
160
+ function formatHeatmapTooltipDate(date) {
161
+ const month = heatmapTooltipMonthFmt.format(date);
162
+ return `${date.getDate()} de ${month} de ${date.getFullYear()}`;
163
+ }
164
+ function formatHeatmapTooltipWeekday(date) {
165
+ return heatmapTooltipWeekdayFmt.format(date);
166
+ }
167
+ function formatHeatmapContributionLabel(count, _date) {
168
+ const word = count === 1 ? "registro" : "registros";
169
+ return `${count} ${word}`;
170
+ }
171
+ const HEATMAP_DAY_LABELS = [
172
+ "Dom",
173
+ "Seg",
174
+ "Ter",
175
+ "Qua",
176
+ "Qui",
177
+ "Sex",
178
+ "S\xE1b"
179
+ ];
180
+ function getHeatmapDayLabels(weekStartDay = 0) {
181
+ if (weekStartDay === 0) {
182
+ return HEATMAP_DAY_LABELS;
183
+ }
184
+ return [
185
+ ...HEATMAP_DAY_LABELS.slice(weekStartDay),
186
+ ...HEATMAP_DAY_LABELS.slice(0, weekStartDay)
187
+ ];
188
+ }
189
+ function rotateHeatmapColumnBins(columns, weekStartDay = 0) {
190
+ if (weekStartDay === 0) {
191
+ return columns;
192
+ }
193
+ return columns.map((column) => ({
194
+ ...column,
195
+ bins: [
196
+ ...column.bins.slice(weekStartDay),
197
+ ...column.bins.slice(0, weekStartDay)
198
+ ]
199
+ }));
200
+ }
201
+ function formatHeatmapYAxisLabel(label, labelFormat) {
202
+ return labelFormat === "initial" ? label.charAt(0) : label;
203
+ }
204
+ function shouldShowHeatmapYAxisTick(row, tickFilter) {
205
+ switch (tickFilter) {
206
+ case "all":
207
+ return true;
208
+ case "odd":
209
+ return row % 2 === 1;
210
+ case "even":
211
+ return row % 2 === 0;
212
+ default:
213
+ return row % 2 === 1;
214
+ }
215
+ }
216
+ function buildHeatmapSeparatorGradientStops(gradient, strokeOpacity = 1) {
217
+ const scaleOpacity = (value, fallback = 1) => (value ?? fallback) * strokeOpacity;
218
+ if (gradient.via != null) {
219
+ return [
220
+ {
221
+ offset: "0%",
222
+ color: gradient.from,
223
+ opacity: scaleOpacity(gradient.fromOpacity)
224
+ },
225
+ {
226
+ offset: "50%",
227
+ color: gradient.via,
228
+ opacity: scaleOpacity(gradient.viaOpacity)
229
+ },
230
+ {
231
+ offset: "100%",
232
+ color: gradient.to,
233
+ opacity: scaleOpacity(gradient.toOpacity)
234
+ }
235
+ ];
236
+ }
237
+ return [
238
+ {
239
+ offset: "0%",
240
+ color: gradient.from,
241
+ opacity: scaleOpacity(gradient.fromOpacity)
242
+ },
243
+ {
244
+ offset: "100%",
245
+ color: gradient.to,
246
+ opacity: scaleOpacity(gradient.toOpacity)
247
+ }
248
+ ];
249
+ }
250
+ function resolveHeatmapSeparatorStrokeDasharray(strokeStyle = "solid", strokeDasharray) {
251
+ if (strokeStyle !== "dashed") {
252
+ return void 0;
253
+ }
254
+ return strokeDasharray ?? "4,4";
255
+ }
256
+ function getCalendarQuarter(date) {
257
+ return Math.floor(date.getMonth() / 3) + 1;
258
+ }
259
+ const CALENDAR_QUARTER_START_MONTHS = [0, 3, 6, 9];
260
+ function getCalendarQuarterStartDatesBetween(gridStart, gridEnd) {
261
+ const startTime = gridStart.getTime();
262
+ const endTime = gridEnd.getTime();
263
+ const dates = [];
264
+ for (let year = gridStart.getFullYear(); year <= gridEnd.getFullYear(); year++) {
265
+ for (const month of CALENDAR_QUARTER_START_MONTHS) {
266
+ const date = new Date(year, month, 1);
267
+ date.setHours(0, 0, 0, 0);
268
+ const time = date.getTime();
269
+ if (time > startTime && time <= endTime) {
270
+ dates.push(date);
271
+ }
272
+ }
273
+ }
274
+ return dates;
275
+ }
276
+ function findHeatmapColumnIndexForDate(columns, date) {
277
+ const target = new Date(date);
278
+ target.setHours(0, 0, 0, 0);
279
+ const targetTime = target.getTime();
280
+ for (let columnIndex = 0; columnIndex < columns.length; columnIndex++) {
281
+ const column = columns[columnIndex];
282
+ if (!column) {
283
+ continue;
284
+ }
285
+ const weekStart = getHeatmapColumnStartDate(column);
286
+ const weekEnd = getHeatmapColumnEndDate(column);
287
+ if (!(weekStart && weekEnd)) {
288
+ continue;
289
+ }
290
+ weekStart.setHours(0, 0, 0, 0);
291
+ weekEnd.setHours(0, 0, 0, 0);
292
+ if (targetTime >= weekStart.getTime() && targetTime <= weekEnd.getTime()) {
293
+ return columnIndex;
294
+ }
295
+ }
296
+ return null;
297
+ }
298
+ function getHeatmapColumnQuarterAnchor(column) {
299
+ for (const bin of column.bins) {
300
+ if (!bin.date) {
301
+ continue;
302
+ }
303
+ const month = bin.date.getMonth();
304
+ if (bin.date.getDate() === 1 && month % 3 === 0) {
305
+ return {
306
+ quarter: month / 3 + 1,
307
+ year: bin.date.getFullYear(),
308
+ date: bin.date
309
+ };
310
+ }
311
+ }
312
+ const firstDate = column.bins[0]?.date;
313
+ if (!firstDate) {
314
+ return null;
315
+ }
316
+ const quarter = getCalendarQuarter(firstDate);
317
+ return {
318
+ quarter,
319
+ year: firstDate.getFullYear(),
320
+ date: new Date(firstDate.getFullYear(), (quarter - 1) * 3, 1)
321
+ };
322
+ }
323
+ function getHeatmapSeparatorGroupStartColumn(columnIndex, atColumns) {
324
+ let groupStart = 0;
325
+ for (const start of atColumns) {
326
+ if (start <= columnIndex) {
327
+ groupStart = start;
328
+ } else {
329
+ break;
330
+ }
331
+ }
332
+ return groupStart;
333
+ }
334
+ function getHeatmapSeparatorColumnIndices(columnCount, every) {
335
+ if (every <= 0 || columnCount <= every) {
336
+ return [];
337
+ }
338
+ const indices = [];
339
+ for (let columnIndex = every; columnIndex < columnCount; columnIndex += every) {
340
+ indices.push(columnIndex);
341
+ }
342
+ return indices;
343
+ }
344
+ function inferHeatmapCalendarRangeStart(columns) {
345
+ const firstColumn = columns[0];
346
+ if (!firstColumn) {
347
+ return null;
348
+ }
349
+ const gridStart = getHeatmapColumnStartDate(firstColumn);
350
+ if (!gridStart) {
351
+ return null;
352
+ }
353
+ const today = /* @__PURE__ */ new Date();
354
+ today.setHours(0, 0, 0, 0);
355
+ for (const months of [HEATMAP_MONTHS_SIX, HEATMAP_MONTHS_ONE_YEAR]) {
356
+ const rangeStart = getHeatmapCalendarRangeStart(today, months);
357
+ const alignedStart = getHeatmapWeekStartAlignedToRange(rangeStart);
358
+ if (gridStart.getTime() === alignedStart.getTime()) {
359
+ return rangeStart;
360
+ }
361
+ }
362
+ return null;
363
+ }
364
+ function buildHeatmapQuarterSeparatorGroups(columns) {
365
+ if (columns.length === 0) {
366
+ return [];
367
+ }
368
+ const extent = getHeatmapTimeExtent(columns);
369
+ if (!extent) {
370
+ return [];
371
+ }
372
+ const [extentStart, gridEnd] = extent;
373
+ const displayRange = resolveHeatmapDisplayRange(columns);
374
+ const quarterRangeStart = displayRange.start ?? inferHeatmapCalendarRangeStart(columns) ?? extentStart;
375
+ const firstQuarter = getCalendarQuarter(quarterRangeStart);
376
+ const groups = [
377
+ {
378
+ startColumnIndex: 0,
379
+ quarter: firstQuarter,
380
+ year: quarterRangeStart.getFullYear(),
381
+ startDate: quarterRangeStart,
382
+ label: `Q${firstQuarter}`
383
+ }
384
+ ];
385
+ const usedColumns = /* @__PURE__ */ new Set([0]);
386
+ const quarterStarts = getCalendarQuarterStartDatesBetween(
387
+ quarterRangeStart,
388
+ gridEnd
389
+ );
390
+ for (const quarterStart of quarterStarts) {
391
+ const columnIndex = findHeatmapColumnIndexForDate(columns, quarterStart);
392
+ if (columnIndex == null || columnIndex === 0 || usedColumns.has(columnIndex)) {
393
+ continue;
394
+ }
395
+ usedColumns.add(columnIndex);
396
+ const quarter = getCalendarQuarter(quarterStart);
397
+ groups.push({
398
+ startColumnIndex: columnIndex,
399
+ quarter,
400
+ year: quarterStart.getFullYear(),
401
+ startDate: quarterStart,
402
+ label: `Q${quarter}`
403
+ });
404
+ }
405
+ groups.sort((a, b) => a.startColumnIndex - b.startColumnIndex);
406
+ return groups;
407
+ }
408
+ function resolveHeatmapSeparatorLayout(config, columns) {
409
+ if (!config) {
410
+ return null;
411
+ }
412
+ if (config.groupBy === "quarter") {
413
+ const groups = buildHeatmapQuarterSeparatorGroups(columns);
414
+ if (groups.length === 0) {
415
+ return null;
416
+ }
417
+ return {
418
+ spacing: config.spacing,
419
+ atColumns: groups.map((group) => group.startColumnIndex).filter((columnIndex) => columnIndex > 0),
420
+ groups
421
+ };
422
+ }
423
+ if (!config.every || config.every <= 0) {
424
+ return null;
425
+ }
426
+ const atColumns = getHeatmapSeparatorColumnIndices(
427
+ columns.length,
428
+ config.every
429
+ );
430
+ return {
431
+ spacing: config.spacing,
432
+ atColumns,
433
+ groups: []
434
+ };
435
+ }
436
+ function getHeatmapSeparatorCount(separator) {
437
+ return separator?.atColumns.length ?? 0;
438
+ }
439
+ function getHeatmapColumnXOffset(columnIndex, separator) {
440
+ if (!separator || separator.spacing <= 0) {
441
+ return 0;
442
+ }
443
+ if (columnIndex <= 0) {
444
+ return 0;
445
+ }
446
+ const separatorCount = separator.atColumns.filter(
447
+ (atColumn) => atColumn <= columnIndex
448
+ ).length;
449
+ return separatorCount * separator.spacing;
450
+ }
451
+ function getHeatmapPlotInnerWidth(columnCount, binWidth, separator) {
452
+ const separatorCount = separator ? getHeatmapSeparatorCount(separator) : 0;
453
+ return columnCount * binWidth + separatorCount * (separator?.spacing ?? 0);
454
+ }
455
+ function getHeatmapSeparatorLineY({
456
+ innerHeight,
457
+ marginTop,
458
+ startOffset,
459
+ paddingY = 0
460
+ }) {
461
+ const resolvedStart = startOffset ?? marginTop;
462
+ const y1 = resolvedStart - marginTop + paddingY;
463
+ const y2 = Math.max(innerHeight - paddingY, y1);
464
+ return { y1, y2 };
465
+ }
466
+ function getHeatmapSeparatorX(columnIndex, gap, separator, xScale) {
467
+ if (separator.spacing > 0) {
468
+ return xScale(columnIndex) - separator.spacing / 2;
469
+ }
470
+ return xScale(columnIndex) - gap / 2;
471
+ }
472
+ function isHeatmapGhostBin(bin, range) {
473
+ const time = bin.date.getTime();
474
+ if (range.end && time > range.end.getTime()) {
475
+ return true;
476
+ }
477
+ if (range.start && time < range.start.getTime()) {
478
+ return true;
479
+ }
480
+ return false;
481
+ }
482
+ function resolveHeatmapDisplayRange(columns) {
483
+ if (columns.length === 0) {
484
+ return { start: null, end: null };
485
+ }
486
+ const extent = getHeatmapTimeExtent(columns);
487
+ if (!extent) {
488
+ return { start: null, end: null };
489
+ }
490
+ const today = /* @__PURE__ */ new Date();
491
+ today.setHours(0, 0, 0, 0);
492
+ const firstColumn = columns[0];
493
+ if (!firstColumn) {
494
+ return { start: null, end: null };
495
+ }
496
+ const gridStart = getHeatmapColumnStartDate(firstColumn);
497
+ if (!gridStart) {
498
+ return { start: null, end: null };
499
+ }
500
+ const inferredStart = inferHeatmapCalendarRangeStart(columns);
501
+ if (inferredStart && extent[1].getTime() >= today.getTime()) {
502
+ return { start: inferredStart, end: today };
503
+ }
504
+ return { start: null, end: null };
505
+ }
506
+ function getHeatmapContributionLevel(count) {
507
+ if (count <= 0) {
508
+ return 0;
509
+ }
510
+ if (count === 1) {
511
+ return 1;
512
+ }
513
+ if (count === 2) {
514
+ return 2;
515
+ }
516
+ if (count === 3) {
517
+ return 3;
518
+ }
519
+ return 4;
520
+ }
521
+ function isHeatmapHoverEffectEnabled(params) {
522
+ return params.inactiveOpacity !== 1 || params.inactiveScale !== 1 || params.activeScale !== 1;
523
+ }
524
+ function isHeatmapInactiveEffectEnabled(inactiveOpacity, inactiveScale) {
525
+ return isHeatmapHoverEffectEnabled({
526
+ inactiveOpacity,
527
+ inactiveScale,
528
+ activeScale: 1
529
+ });
530
+ }
531
+ function resolveHeatmapHoverStyle(isHighlighted, isDimmed, params) {
532
+ if (isHighlighted && params.activeScale !== 1) {
533
+ return { opacity: 1, scale: params.activeScale };
534
+ }
535
+ if (isDimmed) {
536
+ return {
537
+ opacity: params.inactiveOpacity,
538
+ scale: params.inactiveScale
539
+ };
540
+ }
541
+ return { opacity: 1, scale: 1 };
542
+ }
543
+ function resolveHeatmapInactiveStyle(isInactive, inactiveOpacity, inactiveScale) {
544
+ return resolveHeatmapHoverStyle(false, isInactive, {
545
+ inactiveOpacity,
546
+ inactiveScale,
547
+ activeScale: 1
548
+ });
549
+ }
550
+ function resolveHeatmapRowOpacity(row, rowOpacity) {
551
+ if (rowOpacity == null) {
552
+ return 1;
553
+ }
554
+ if (typeof rowOpacity === "number") {
555
+ return rowOpacity;
556
+ }
557
+ return rowOpacity[row] ?? 1;
558
+ }
559
+ function buildHeatmapRowOpacity(match, fadedOpacity = 0.35, activeOpacity = 1, rowCount = 7) {
560
+ if (typeof match === "function") {
561
+ return Array.from(
562
+ { length: rowCount },
563
+ (_, row) => match(row) ? fadedOpacity : activeOpacity
564
+ );
565
+ }
566
+ const opacity = new Array(rowCount).fill(activeOpacity);
567
+ for (const row of match) {
568
+ if (row >= 0 && row < rowCount) {
569
+ opacity[row] = fadedOpacity;
570
+ }
571
+ }
572
+ return opacity;
573
+ }
574
+ function buildHeatmapLegendGradient(levelStyles) {
575
+ const lastIndex = levelStyles.length - 1;
576
+ const stops = levelStyles.map((style, index) => {
577
+ const offset = lastIndex === 0 ? 0 : index / lastIndex * 100;
578
+ return `${style.color} ${offset}%`;
579
+ });
580
+ return `linear-gradient(to right, ${stops.join(", ")})`;
581
+ }
582
+ export {
583
+ HEATMAP_DAY_LABELS,
584
+ HEATMAP_MONTHS_ONE_YEAR,
585
+ HEATMAP_MONTHS_SIX,
586
+ HEATMAP_WEEKS_ONE_YEAR,
587
+ buildHeatmapLegendGradient,
588
+ buildHeatmapQuarterSeparatorGroups,
589
+ buildHeatmapRowOpacity,
590
+ buildHeatmapSeparatorGradientStops,
591
+ countHeatmapWeekDaysOnOrAfter,
592
+ filterHeatmapColumns,
593
+ findHeatmapColumnIndexForDate,
594
+ formatHeatmapContributionLabel,
595
+ formatHeatmapTooltipDate,
596
+ formatHeatmapTooltipWeekday,
597
+ formatHeatmapYAxisLabel,
598
+ getCalendarQuarter,
599
+ getCalendarQuarterStartDatesBetween,
600
+ getHeatmapCalendarRangeStart,
601
+ getHeatmapColumnEndDate,
602
+ getHeatmapColumnMonthAnchor,
603
+ getHeatmapColumnQuarterAnchor,
604
+ getHeatmapColumnStartDate,
605
+ getHeatmapColumnXOffset,
606
+ getHeatmapContributionLevel,
607
+ getHeatmapDayLabels,
608
+ getHeatmapMonthLabelColumnIndex,
609
+ getHeatmapPlotInnerWidth,
610
+ getHeatmapSeparatorColumnIndices,
611
+ getHeatmapSeparatorCount,
612
+ getHeatmapSeparatorGroupStartColumn,
613
+ getHeatmapSeparatorLineY,
614
+ getHeatmapSeparatorX,
615
+ getHeatmapTimeExtent,
616
+ getHeatmapWeekCount,
617
+ getHeatmapWeekStartAlignedToRange,
618
+ getHeatmapWeekStartSunday,
619
+ getHeatmapYearStartMonth,
620
+ inferHeatmapCalendarRangeStart,
621
+ isHeatmapGhostBin,
622
+ isHeatmapHoverEffectEnabled,
623
+ isHeatmapInactiveEffectEnabled,
624
+ resolveHeatmapDisplayRange,
625
+ resolveHeatmapHoverStyle,
626
+ resolveHeatmapInactiveStyle,
627
+ resolveHeatmapRowOpacity,
628
+ resolveHeatmapSeparatorLayout,
629
+ resolveHeatmapSeparatorStrokeDasharray,
630
+ resolveHeatmapWeekRange,
631
+ rotateHeatmapColumnBins,
632
+ shouldShowHeatmapYAxisTick
633
+ };
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { memo, useEffect, useMemo, useState } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { cn } from "../../lib/utils";
6
+ import { useHeatmap } from "./heatmap-context";
7
+ import { getHeatmapColumnMonthAnchor } from "./heatmap-utils";
8
+ const monthFmt = new Intl.DateTimeFormat("pt-BR", { month: "short" });
9
+ const HeatmapXAxis = memo(function HeatmapXAxis2({
10
+ className
11
+ }) {
12
+ const { containerRef, data, margin, xScale } = useHeatmap();
13
+ const [mounted, setMounted] = useState(false);
14
+ useEffect(() => {
15
+ setMounted(true);
16
+ }, []);
17
+ const labels = useMemo(() => {
18
+ const ticks = [];
19
+ let lastMonthKey = "";
20
+ for (let columnIndex = 0; columnIndex < data.length; columnIndex++) {
21
+ const column = data[columnIndex];
22
+ if (!column) {
23
+ continue;
24
+ }
25
+ const monthAnchor = getHeatmapColumnMonthAnchor(column);
26
+ if (!monthAnchor) {
27
+ continue;
28
+ }
29
+ const monthKey = `${monthAnchor.getFullYear()}-${monthAnchor.getMonth()}`;
30
+ if (monthKey === lastMonthKey) {
31
+ continue;
32
+ }
33
+ ticks.push({
34
+ label: monthFmt.format(monthAnchor),
35
+ x: margin.left + xScale(columnIndex),
36
+ key: monthKey
37
+ });
38
+ lastMonthKey = monthKey;
39
+ }
40
+ return ticks;
41
+ }, [data, margin.left, xScale]);
42
+ const container = containerRef.current;
43
+ if (!(mounted && container)) {
44
+ return null;
45
+ }
46
+ return createPortal(
47
+ labels.map((tick) => /* @__PURE__ */ jsx(
48
+ "div",
49
+ {
50
+ className: "pointer-events-none absolute",
51
+ style: {
52
+ top: 0,
53
+ left: tick.x,
54
+ width: 0,
55
+ display: "flex",
56
+ justifyContent: "flex-start"
57
+ },
58
+ children: /* @__PURE__ */ jsx(
59
+ "span",
60
+ {
61
+ className: cn(
62
+ "whitespace-nowrap text-chart-label text-xs",
63
+ className
64
+ ),
65
+ children: tick.label
66
+ }
67
+ )
68
+ },
69
+ tick.key
70
+ )),
71
+ container
72
+ );
73
+ });
74
+ HeatmapXAxis.displayName = "HeatmapXAxis";
75
+ var heatmap_x_axis_default = HeatmapXAxis;
76
+ export {
77
+ HeatmapXAxis,
78
+ heatmap_x_axis_default as default
79
+ };