@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,346 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { domAnimation, LazyMotion } from "motion/react";
4
+ import {
5
+ Children,
6
+ Fragment,
7
+ isValidElement,
8
+ useCallback,
9
+ useMemo,
10
+ useRef,
11
+ useState
12
+ } from "react";
13
+ import { cn } from "../lib/utils";
14
+ import { Area } from "./area";
15
+ import { Candlestick } from "./candlestick";
16
+ import { resolveChartChildElement } from "./chart-child-passthrough";
17
+ import {
18
+ defaultScatterColors,
19
+ useStableMargin
20
+ } from "./chart-context";
21
+ import { useChartDataOverride } from "./chart-data-override";
22
+ import { ChartLoadingLabel } from "./chart-loading-label";
23
+ import { ParentSize } from "./chart-parent-size";
24
+ import {
25
+ DEFAULT_CHART_STATUS,
26
+ DEFAULT_Y_DOMAIN_TWEEN_MS,
27
+ resolveRestingChartPhase
28
+ } from "./chart-phase";
29
+ import { Line } from "./line";
30
+ import {
31
+ PROFIT_LOSS_POSITIVE_COLOR,
32
+ ProfitLossLine
33
+ } from "./profit-loss-line";
34
+ import { Scatter } from "./scatter";
35
+ import { SeriesBar } from "./series-bar";
36
+ import {
37
+ TimeSeriesChartInner,
38
+ timeSeriesChartHasRoom
39
+ } from "./time-series-chart-shell";
40
+ import { normalizeYAxisId } from "./y-axis-scales";
41
+ const DEFAULT_MARGIN = { top: 40, right: 40, bottom: 40, left: 40 };
42
+ const FALLBACK_STROKE = "var(--chart-line-primary)";
43
+ function getChildComponentName(child) {
44
+ const childType = child.type;
45
+ return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
46
+ }
47
+ function isComponent(child, component, name) {
48
+ return child.type === component || getChildComponentName(child) === name;
49
+ }
50
+ function upsertLineConfig(lines, config) {
51
+ const index = lines.findIndex((line) => line.dataKey === config.dataKey);
52
+ if (index === -1) {
53
+ lines.push(config);
54
+ return;
55
+ }
56
+ lines[index] = config;
57
+ }
58
+ function addExtraDomainKeys(byAxis, axisId, keys) {
59
+ const existing = byAxis[axisId] ?? [];
60
+ for (const key of keys) {
61
+ if (!existing.includes(key)) {
62
+ existing.push(key);
63
+ }
64
+ }
65
+ byAxis[axisId] = existing;
66
+ }
67
+ const SERIES_REGISTRARS = [
68
+ {
69
+ component: SeriesBar,
70
+ name: "SeriesBar",
71
+ register: (rawProps, series) => {
72
+ const props = rawProps;
73
+ if (!props.dataKey) {
74
+ return;
75
+ }
76
+ series.barDataKeys.push(props.dataKey);
77
+ upsertLineConfig(series.lines, {
78
+ dataKey: props.dataKey,
79
+ stroke: props.stroke || props.fill || FALLBACK_STROKE,
80
+ strokeWidth: 0,
81
+ yAxisId: props.yAxisId
82
+ });
83
+ }
84
+ },
85
+ {
86
+ component: Line,
87
+ name: "Line",
88
+ register: (rawProps, series) => {
89
+ const props = rawProps;
90
+ if (!props.dataKey) {
91
+ return;
92
+ }
93
+ upsertLineConfig(series.lines, {
94
+ dataKey: props.dataKey,
95
+ stroke: props.stroke || FALLBACK_STROKE,
96
+ strokeWidth: props.strokeWidth ?? 2.5,
97
+ yAxisId: props.yAxisId
98
+ });
99
+ }
100
+ },
101
+ {
102
+ component: Area,
103
+ name: "Area",
104
+ register: (rawProps, series) => {
105
+ const props = rawProps;
106
+ if (!props.dataKey) {
107
+ return;
108
+ }
109
+ upsertLineConfig(series.lines, {
110
+ dataKey: props.dataKey,
111
+ stroke: props.stroke || props.fill || FALLBACK_STROKE,
112
+ strokeWidth: props.strokeWidth ?? 2,
113
+ yAxisId: props.yAxisId
114
+ });
115
+ }
116
+ },
117
+ {
118
+ component: Scatter,
119
+ name: "Scatter",
120
+ register: (rawProps, series, walk) => {
121
+ const props = rawProps;
122
+ if (!props.dataKey) {
123
+ return;
124
+ }
125
+ const fallback = defaultScatterColors[walk.scatterCount % defaultScatterColors.length] ?? FALLBACK_STROKE;
126
+ walk.scatterCount += 1;
127
+ upsertLineConfig(series.lines, {
128
+ dataKey: props.dataKey,
129
+ stroke: props.fill || props.stroke || fallback,
130
+ strokeWidth: props.radius ?? 5,
131
+ yAxisId: props.yAxisId
132
+ });
133
+ }
134
+ },
135
+ {
136
+ component: ProfitLossLine,
137
+ name: "ProfitLossLine",
138
+ register: (rawProps, series) => {
139
+ const props = rawProps;
140
+ if (!props.dataKey) {
141
+ return;
142
+ }
143
+ upsertLineConfig(series.lines, {
144
+ dataKey: props.dataKey,
145
+ stroke: props.positiveColor || PROFIT_LOSS_POSITIVE_COLOR,
146
+ strokeWidth: props.strokeWidth ?? 2.5
147
+ });
148
+ }
149
+ },
150
+ {
151
+ component: Candlestick,
152
+ name: "Candlestick",
153
+ register: (rawProps, series) => {
154
+ const props = rawProps;
155
+ const axisId = normalizeYAxisId(props.yAxisId);
156
+ upsertLineConfig(series.lines, {
157
+ dataKey: "close",
158
+ stroke: "var(--chart-positive, var(--chart-positive))",
159
+ strokeWidth: 0,
160
+ yAxisId: props.yAxisId
161
+ });
162
+ addExtraDomainKeys(series.extraDomainKeysByAxis, axisId, [
163
+ "high",
164
+ "low",
165
+ "open"
166
+ ]);
167
+ if (!series.floatingYAxisIds.includes(axisId)) {
168
+ series.floatingYAxisIds.push(axisId);
169
+ }
170
+ }
171
+ }
172
+ ];
173
+ function extractComposedSeries(children) {
174
+ const series = {
175
+ lines: [],
176
+ barDataKeys: [],
177
+ extraDomainKeysByAxis: {},
178
+ floatingYAxisIds: []
179
+ };
180
+ const walk = { scatterCount: 0 };
181
+ const visit = (node) => {
182
+ Children.forEach(node, (rawChild) => {
183
+ if (!isValidElement(rawChild)) {
184
+ return;
185
+ }
186
+ if (rawChild.type === Fragment) {
187
+ visit(rawChild.props.children);
188
+ return;
189
+ }
190
+ const child = resolveChartChildElement(rawChild);
191
+ const registrar = SERIES_REGISTRARS.find(
192
+ (entry) => isComponent(child, entry.component, entry.name)
193
+ );
194
+ registrar?.register(child.props, series, walk);
195
+ });
196
+ };
197
+ visit(children);
198
+ return series;
199
+ }
200
+ function computeStackOffsets(data, barDataKeys) {
201
+ const offsets = /* @__PURE__ */ new Map();
202
+ for (let i = 0; i < data.length; i++) {
203
+ const d = data[i];
204
+ if (!d) {
205
+ continue;
206
+ }
207
+ const pointOffsets = /* @__PURE__ */ new Map();
208
+ let cumulative = 0;
209
+ for (const key of barDataKeys) {
210
+ pointOffsets.set(key, cumulative);
211
+ const v = d[key];
212
+ if (typeof v === "number") {
213
+ cumulative += v;
214
+ }
215
+ }
216
+ offsets.set(i, pointOffsets);
217
+ }
218
+ return offsets;
219
+ }
220
+ function ComposedChart({
221
+ data: dataProp,
222
+ xDataKey = "date",
223
+ margin: marginProp,
224
+ animationDuration = 1100,
225
+ animationEasing,
226
+ enterTransition,
227
+ revealSignature,
228
+ aspectRatio = "2 / 1",
229
+ className = "",
230
+ style,
231
+ children,
232
+ barSize,
233
+ maxBarSize,
234
+ barGap = 4,
235
+ stacked = false,
236
+ stackGap = 0,
237
+ barEdgeInset = true,
238
+ status = DEFAULT_CHART_STATUS,
239
+ loadingLabel,
240
+ yDomainTweenDuration = DEFAULT_Y_DOMAIN_TWEEN_MS,
241
+ yDomainTween = true,
242
+ xDomain,
243
+ xDomainSlotCount,
244
+ tweenYDomainOnXDomainChange = false,
245
+ yScaleDomainMax,
246
+ yDomains,
247
+ onPhaseChange
248
+ }) {
249
+ const { data } = useChartDataOverride("ComposedChart", {
250
+ data: dataProp
251
+ });
252
+ const containerRef = useRef(null);
253
+ const margin = useStableMargin({ ...DEFAULT_MARGIN, ...marginProp });
254
+ const seriesSignature = useMemo(
255
+ () => JSON.stringify(extractComposedSeries(children)),
256
+ [children]
257
+ );
258
+ const { lines, barDataKeys, extraDomainKeysByAxis, floatingYAxisIds } = useMemo(
259
+ () => JSON.parse(seriesSignature),
260
+ [seriesSignature]
261
+ );
262
+ const [chartPhase, setChartPhase] = useState(
263
+ () => resolveRestingChartPhase(status)
264
+ );
265
+ const handlePhaseChange = useCallback(
266
+ (phase) => {
267
+ setChartPhase(phase);
268
+ onPhaseChange?.(phase);
269
+ },
270
+ [onPhaseChange]
271
+ );
272
+ const composedStackOffsets = useMemo(
273
+ () => stacked && barDataKeys.length > 0 ? computeStackOffsets(data, barDataKeys) : void 0,
274
+ [data, barDataKeys, stacked]
275
+ );
276
+ const hasExtraDomainKeys = Object.keys(extraDomainKeysByAxis).length > 0;
277
+ const showLoadingLabel = Boolean(
278
+ loadingLabel?.trim() && (chartPhase === "loading" || chartPhase === "exiting" || chartPhase === "gridTweenReady" || chartPhase === "revealingLoading")
279
+ );
280
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsxs(
281
+ "div",
282
+ {
283
+ className: cn("relative w-full", className),
284
+ ref: containerRef,
285
+ style: {
286
+ ...aspectRatio ? { aspectRatio } : void 0,
287
+ touchAction: "none",
288
+ ...style
289
+ },
290
+ children: [
291
+ /* @__PURE__ */ jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => timeSeriesChartHasRoom(width, height) ? /* @__PURE__ */ jsx(
292
+ TimeSeriesChartInner,
293
+ {
294
+ animationDuration,
295
+ animationEasing,
296
+ chartStatus: status,
297
+ clipPathId: "composed-chart-grow-clip",
298
+ composedBarDataKeys: barDataKeys.length > 0 ? barDataKeys : void 0,
299
+ composedBarEdgeInset: barEdgeInset,
300
+ composedBarGap: barGap,
301
+ composedBarSize: barSize,
302
+ composedMaxBarSize: maxBarSize,
303
+ composedStacked: stacked,
304
+ composedStackGap: stackGap,
305
+ composedStackOffsets,
306
+ containerRef,
307
+ data,
308
+ enterTransition,
309
+ extraDomainKeysByAxis: hasExtraDomainKeys ? extraDomainKeysByAxis : void 0,
310
+ floatingYAxisIds: floatingYAxisIds.length > 0 ? floatingYAxisIds : void 0,
311
+ height,
312
+ lines,
313
+ loadingLabel,
314
+ margin,
315
+ onPhaseChange: handlePhaseChange,
316
+ revealSignature,
317
+ tweenYDomainOnXDomainChange,
318
+ width,
319
+ xDataKey,
320
+ xDomain,
321
+ xDomainSlotCount,
322
+ yDomainOverrides: yDomains,
323
+ yDomainTween,
324
+ yDomainTweenDuration,
325
+ yScaleDomainMax,
326
+ children
327
+ }
328
+ ) : null }),
329
+ showLoadingLabel ? /* @__PURE__ */ jsx(
330
+ ChartLoadingLabel,
331
+ {
332
+ exiting: chartPhase !== "loading",
333
+ text: loadingLabel
334
+ }
335
+ ) : null
336
+ ]
337
+ }
338
+ ) });
339
+ }
340
+ ComposedChart.displayName = "ComposedChart";
341
+ var composed_chart_default = ComposedChart;
342
+ export {
343
+ ComposedChart,
344
+ composed_chart_default as default,
345
+ extractComposedSeries
346
+ };
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ const stores = /* @__PURE__ */ new WeakMap();
3
+ function getStore(container) {
4
+ let store = stores.get(container);
5
+ if (!store) {
6
+ store = { state: null, listeners: /* @__PURE__ */ new Set() };
7
+ stores.set(container, store);
8
+ }
9
+ return store;
10
+ }
11
+ function setCrosshairY(container, state) {
12
+ const store = getStore(container);
13
+ const prev = store.state;
14
+ if (prev === state || prev && state && prev.y === state.y && prev.axisId === state.axisId) {
15
+ return;
16
+ }
17
+ store.state = state;
18
+ for (const listener of store.listeners) {
19
+ listener();
20
+ }
21
+ }
22
+ function subscribeCrosshair(container, listener) {
23
+ const store = getStore(container);
24
+ const notify = () => listener(store.state);
25
+ store.listeners.add(notify);
26
+ notify();
27
+ return () => {
28
+ store.listeners.delete(notify);
29
+ };
30
+ }
31
+ const TICK_FADE_BUFFER = 20;
32
+ function crosshairTickOpacity(state, axisId, tickY, pillHalfHeight) {
33
+ if (!state || state.axisId !== axisId) {
34
+ return 1;
35
+ }
36
+ const distance = Math.abs(tickY - state.y);
37
+ if (distance < pillHalfHeight) {
38
+ return 0;
39
+ }
40
+ if (distance < pillHalfHeight + TICK_FADE_BUFFER) {
41
+ return (distance - pillHalfHeight) / TICK_FADE_BUFFER;
42
+ }
43
+ return 1;
44
+ }
45
+ export {
46
+ crosshairTickOpacity,
47
+ setCrosshairY,
48
+ subscribeCrosshair
49
+ };
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useId } from "react";
4
+ function DashTailStroke({
5
+ pathD,
6
+ pathLength,
7
+ dashStartLength,
8
+ dashStartX,
9
+ innerWidth,
10
+ innerHeight,
11
+ stroke,
12
+ strokeWidth,
13
+ dashArray
14
+ }) {
15
+ const clipPathId = useId().replace(/:/g, "");
16
+ if (!pathD || pathLength <= 0 || dashStartLength >= pathLength) {
17
+ return null;
18
+ }
19
+ const pad = strokeWidth * 2;
20
+ const tailWidth = Math.max(0, innerWidth - dashStartX + pad);
21
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
22
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: clipPathId, children: /* @__PURE__ */ jsx(
23
+ "rect",
24
+ {
25
+ height: innerHeight + pad,
26
+ width: tailWidth,
27
+ x: dashStartX - strokeWidth,
28
+ y: -strokeWidth
29
+ }
30
+ ) }) }),
31
+ /* @__PURE__ */ jsx(
32
+ "path",
33
+ {
34
+ d: pathD,
35
+ fill: "none",
36
+ stroke,
37
+ strokeDasharray: `${dashStartLength} ${Math.max(1, pathLength - dashStartLength)}`,
38
+ strokeLinecap: "round",
39
+ strokeWidth
40
+ }
41
+ ),
42
+ /* @__PURE__ */ jsx(
43
+ "path",
44
+ {
45
+ clipPath: `url(#${clipPathId})`,
46
+ d: pathD,
47
+ fill: "none",
48
+ stroke,
49
+ strokeDasharray: dashArray,
50
+ strokeLinecap: "round",
51
+ strokeWidth
52
+ }
53
+ )
54
+ ] });
55
+ }
56
+ export {
57
+ DashTailStroke
58
+ };
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { useCallback, useSyncExternalStore } from "react";
3
+ const stores = /* @__PURE__ */ new WeakMap();
4
+ function getStore(container) {
5
+ let store = stores.get(container);
6
+ if (!store) {
7
+ store = { count: 0, listeners: /* @__PURE__ */ new Set() };
8
+ stores.set(container, store);
9
+ }
10
+ return store;
11
+ }
12
+ function registerDatePill(container) {
13
+ const store = getStore(container);
14
+ store.count += 1;
15
+ for (const listener of store.listeners) {
16
+ listener();
17
+ }
18
+ return () => {
19
+ store.count -= 1;
20
+ for (const listener of store.listeners) {
21
+ listener();
22
+ }
23
+ };
24
+ }
25
+ const noopUnsubscribe = () => void 0;
26
+ const serverSnapshot = () => false;
27
+ function useDatePillPresent(container) {
28
+ const subscribe = useCallback(
29
+ (listener) => {
30
+ if (!container) {
31
+ return noopUnsubscribe;
32
+ }
33
+ const store = getStore(container);
34
+ store.listeners.add(listener);
35
+ return () => {
36
+ store.listeners.delete(listener);
37
+ };
38
+ },
39
+ [container]
40
+ );
41
+ const getSnapshot = useCallback(
42
+ () => container ? getStore(container).count > 0 : false,
43
+ [container]
44
+ );
45
+ return useSyncExternalStore(subscribe, getSnapshot, serverSnapshot);
46
+ }
47
+ export {
48
+ registerDatePill,
49
+ useDatePillPresent
50
+ };
@@ -0,0 +1,131 @@
1
+ const DEFAULT_WEEKEND_DAYS = [6, 0];
2
+ const HALF_DAY_MS = 12 * 60 * 60 * 1e3;
3
+ const DAY_MS = 24 * 60 * 60 * 1e3;
4
+ function startOfDay(date, utc) {
5
+ return utc ? new Date(
6
+ Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())
7
+ ) : new Date(date.getFullYear(), date.getMonth(), date.getDate());
8
+ }
9
+ function addDays(date, days, utc) {
10
+ return utc ? new Date(
11
+ Date.UTC(
12
+ date.getUTCFullYear(),
13
+ date.getUTCMonth(),
14
+ date.getUTCDate() + days
15
+ )
16
+ ) : new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
17
+ }
18
+ function isWeekendDate(date, weekendDays = DEFAULT_WEEKEND_DAYS, utc = false) {
19
+ const day = utc ? date.getUTCDay() : date.getDay();
20
+ return weekendDays.includes(day);
21
+ }
22
+ function computeWeekendRanges(domainStart, domainEnd, options = {}) {
23
+ const {
24
+ weekendDays = DEFAULT_WEEKEND_DAYS,
25
+ utc = false,
26
+ align = "calendar",
27
+ maxDays = 2e4
28
+ } = options;
29
+ let lo = domainStart.getTime();
30
+ let hi = domainEnd.getTime();
31
+ if (!(Number.isFinite(lo) && Number.isFinite(hi))) {
32
+ return [];
33
+ }
34
+ if (lo > hi) {
35
+ [lo, hi] = [hi, lo];
36
+ }
37
+ if (weekendDays.length === 0 || (hi - lo) / DAY_MS > maxDays) {
38
+ return [];
39
+ }
40
+ const shift = align === "centered" ? HALF_DAY_MS : 0;
41
+ const ranges = [];
42
+ let runStart = null;
43
+ let day = addDays(startOfDay(new Date(lo + shift), utc), -1, utc);
44
+ while (day.getTime() - shift <= hi) {
45
+ const next = addDays(day, 1, utc);
46
+ if (isWeekendDate(day, weekendDays, utc)) {
47
+ if (runStart === null) {
48
+ runStart = day.getTime() - shift;
49
+ }
50
+ } else if (runStart !== null) {
51
+ pushClipped(ranges, runStart, day.getTime() - shift, lo, hi);
52
+ runStart = null;
53
+ }
54
+ day = next;
55
+ }
56
+ if (runStart !== null) {
57
+ pushClipped(ranges, runStart, day.getTime() - shift, lo, hi);
58
+ }
59
+ return ranges;
60
+ }
61
+ function pushClipped(ranges, start, end, lo, hi) {
62
+ const s = Math.max(start, lo);
63
+ const e = Math.min(end, hi);
64
+ if (e > s) {
65
+ ranges.push({ start: new Date(s), end: new Date(e) });
66
+ }
67
+ }
68
+ function computeWeekendIndexRuns(dates, options = {}) {
69
+ const { weekendDays = DEFAULT_WEEKEND_DAYS, utc = false } = options;
70
+ const runs = [];
71
+ let runStart = -1;
72
+ dates.forEach((date, index) => {
73
+ const weekend = date != null && !Number.isNaN(date.getTime()) && isWeekendDate(date, weekendDays, utc);
74
+ if (weekend) {
75
+ if (runStart < 0) {
76
+ runStart = index;
77
+ }
78
+ } else if (runStart >= 0) {
79
+ runs.push([runStart, index - 1]);
80
+ runStart = -1;
81
+ }
82
+ });
83
+ if (runStart >= 0) {
84
+ runs.push([runStart, dates.length - 1]);
85
+ }
86
+ return runs;
87
+ }
88
+ const ISO_DATE_ONLY = /^(\d{4})-(\d{2})-(\d{2})$/;
89
+ function toValidDate(value) {
90
+ if (value instanceof Date) {
91
+ return Number.isNaN(value.getTime()) ? null : value;
92
+ }
93
+ if (typeof value === "string") {
94
+ const match = ISO_DATE_ONLY.exec(value.trim());
95
+ if (match) {
96
+ return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
97
+ }
98
+ }
99
+ if (typeof value === "number" || typeof value === "string") {
100
+ const date = new Date(value);
101
+ return Number.isNaN(date.getTime()) ? null : date;
102
+ }
103
+ return null;
104
+ }
105
+ function detectDateKey(row) {
106
+ if (!row) {
107
+ return null;
108
+ }
109
+ for (const [key, value] of Object.entries(row)) {
110
+ if (value instanceof Date) {
111
+ return key;
112
+ }
113
+ if (typeof value === "string" && ISO_DATE_ONLY.test(value.trim())) {
114
+ return key;
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ function firstIndexOnOrAfter(dates, target) {
120
+ const t = target.getTime();
121
+ return dates.findIndex((date) => date != null && date.getTime() >= t);
122
+ }
123
+ export {
124
+ DEFAULT_WEEKEND_DAYS,
125
+ computeWeekendIndexRuns,
126
+ computeWeekendRanges,
127
+ detectDateKey,
128
+ firstIndexOnOrAfter,
129
+ isWeekendDate,
130
+ toValidDate
131
+ };