@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,329 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ animate,
5
+ useMotionValue,
6
+ useMotionValueEvent
7
+ } from "motion/react";
8
+ import {
9
+ useEffect,
10
+ useId,
11
+ useLayoutEffect,
12
+ useRef
13
+ } from "react";
14
+ const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
15
+ const DEFAULT_GAUGE_SWEEP_TRANSITION = {
16
+ type: "spring",
17
+ visualDuration: 0.9,
18
+ bounce: 0
19
+ };
20
+ const GAUGE_TRACK_ENTER_TRANSITION = {
21
+ duration: 0.45,
22
+ ease: [0.23, 1, 0.32, 1]
23
+ };
24
+ const clamp01 = (v) => Math.min(1, Math.max(0, v));
25
+ function useGaugeSweep({
26
+ target,
27
+ transition,
28
+ enterDelay,
29
+ instant
30
+ }) {
31
+ const progress = useMotionValue(instant ? target : 0);
32
+ const enteredRef = useRef(false);
33
+ const transitionKey = JSON.stringify(transition);
34
+ useEffect(() => {
35
+ if (instant) {
36
+ progress.jump(target);
37
+ enteredRef.current = true;
38
+ return;
39
+ }
40
+ const delay = enteredRef.current ? 0 : enterDelay;
41
+ enteredRef.current = true;
42
+ const controls = animate(progress, target, { ...transition, delay });
43
+ return () => controls.stop();
44
+ }, [target, instant, transitionKey, enterDelay, progress]);
45
+ return progress;
46
+ }
47
+ function useMotionValueApply(value, apply) {
48
+ const applyRef = useRef(apply);
49
+ applyRef.current = apply;
50
+ useIsoLayoutEffect(() => {
51
+ applyRef.current(value.get());
52
+ });
53
+ useMotionValueEvent(value, "change", (v) => applyRef.current(v));
54
+ }
55
+ const RULER_OPACITY = {
56
+ majorLit: 0.95,
57
+ majorDim: 0.32,
58
+ minorLit: 0.55,
59
+ minorDim: 0.16
60
+ };
61
+ function resolveRulerLabels(labels) {
62
+ if (!labels) {
63
+ return null;
64
+ }
65
+ if (labels === true) {
66
+ return { show: "majors" };
67
+ }
68
+ if (typeof labels === "string") {
69
+ return { show: labels };
70
+ }
71
+ return labels;
72
+ }
73
+ function rulerFontSize(size) {
74
+ return Math.max(9, size * 0.034);
75
+ }
76
+ function rulerOutsideExtent(options, size) {
77
+ const { majorLength = 0.05, gap = 0.028 } = options;
78
+ const labels = resolveRulerLabels(options.labels);
79
+ return size * (gap + majorLength) + (labels ? rulerFontSize(size) * 1.8 : 0);
80
+ }
81
+ function GaugeRuler({
82
+ cx,
83
+ cy,
84
+ size,
85
+ anchorRadius,
86
+ startAngle,
87
+ endAngle,
88
+ progress,
89
+ options
90
+ }) {
91
+ const {
92
+ position = "inside",
93
+ ticks = 50,
94
+ majorEvery = 5,
95
+ color = "var(--chart-foreground)",
96
+ majorLength = 0.05,
97
+ minorLength = 0.028,
98
+ gap = 0.028,
99
+ highlightActive = true
100
+ } = options;
101
+ const labels = resolveRulerLabels(options.labels);
102
+ const intervals = Math.max(1, Math.round(ticks));
103
+ const every = Math.max(1, Math.round(majorEvery));
104
+ const dir = position === "outside" ? 1 : -1;
105
+ const rStart = anchorRadius + dir * size * gap;
106
+ const refs = useRef([]);
107
+ useMotionValueApply(progress, (p) => {
108
+ for (let j = 0; j <= intervals; j++) {
109
+ const el = refs.current[j];
110
+ if (!el) {
111
+ continue;
112
+ }
113
+ const major = j % every === 0;
114
+ const dim = major ? RULER_OPACITY.majorDim : RULER_OPACITY.minorDim;
115
+ const lit = major ? RULER_OPACITY.majorLit : RULER_OPACITY.minorLit;
116
+ const t = highlightActive ? clamp01((p - j / intervals) * intervals * 2 + 1) : 0;
117
+ el.setAttribute("stroke-opacity", String(dim + (lit - dim) * t));
118
+ }
119
+ });
120
+ const sweep = endAngle - startAngle;
121
+ const fontSize = rulerFontSize(size);
122
+ const labelRadius = rStart + dir * (size * majorLength + fontSize * (dir > 0 ? 1 : 1.1));
123
+ const min = labels?.min ?? 0;
124
+ const max = labels?.max ?? 100;
125
+ const format = labels?.format ?? ((v) => String(Math.round(v * 100) / 100));
126
+ return /* @__PURE__ */ jsxs("g", { children: [
127
+ Array.from({ length: intervals + 1 }, (_, j) => {
128
+ const major = j % every === 0;
129
+ const rad = (startAngle + j / intervals * sweep) * Math.PI / 180;
130
+ const len = size * (major ? majorLength : minorLength);
131
+ const cos = Math.cos(rad);
132
+ const sin = Math.sin(rad);
133
+ return /* @__PURE__ */ jsx(
134
+ "line",
135
+ {
136
+ ref: (el) => {
137
+ refs.current[j] = el;
138
+ },
139
+ stroke: color,
140
+ strokeLinecap: "round",
141
+ strokeOpacity: major ? RULER_OPACITY.majorDim : RULER_OPACITY.minorDim,
142
+ strokeWidth: major ? 1.75 : 1,
143
+ x1: cx + cos * rStart,
144
+ x2: cx + cos * (rStart + dir * len),
145
+ y1: cy + sin * rStart,
146
+ y2: cy + sin * (rStart + dir * len)
147
+ },
148
+ j
149
+ );
150
+ }),
151
+ labels ? Array.from({ length: intervals + 1 }, (_, j) => {
152
+ const isEnd = j === 0 || j === intervals;
153
+ const show = labels.show === "ends" ? isEnd : j % every === 0 || isEnd;
154
+ if (!show) {
155
+ return null;
156
+ }
157
+ const t = j / intervals;
158
+ const rad = (startAngle + t * sweep) * Math.PI / 180;
159
+ return /* @__PURE__ */ jsx(
160
+ "text",
161
+ {
162
+ dominantBaseline: "central",
163
+ fill: labels.color ?? "var(--chart-foreground)",
164
+ fillOpacity: labels.color ? 1 : 0.72,
165
+ fontSize,
166
+ style: { fontVariantNumeric: "tabular-nums" },
167
+ textAnchor: "middle",
168
+ x: cx + Math.cos(rad) * labelRadius,
169
+ y: cy + Math.sin(rad) * labelRadius,
170
+ children: format(min + t * (max - min))
171
+ },
172
+ `label-${j}`
173
+ );
174
+ }) : null
175
+ ] });
176
+ }
177
+ const NEEDLE_DEFAULT_WIDTH = {
178
+ line: 2.5,
179
+ gradient: 4,
180
+ triangle: 10,
181
+ polygon: 8
182
+ };
183
+ function resolveNeedleOptions(needle) {
184
+ if (!needle) {
185
+ return null;
186
+ }
187
+ if (needle === true) {
188
+ return {};
189
+ }
190
+ if (typeof needle === "string") {
191
+ return { variant: needle };
192
+ }
193
+ return needle;
194
+ }
195
+ function resolveRulerOptions(ruler) {
196
+ if (!ruler) {
197
+ return null;
198
+ }
199
+ return ruler === true ? {} : ruler;
200
+ }
201
+ function GaugeNeedle({
202
+ cx,
203
+ cy,
204
+ reach,
205
+ startAngle,
206
+ endAngle,
207
+ progress,
208
+ options
209
+ }) {
210
+ const {
211
+ variant = "gradient",
212
+ color = "var(--chart-foreground)",
213
+ width = NEEDLE_DEFAULT_WIDTH[variant],
214
+ length = 0.55,
215
+ pivot = false
216
+ } = options;
217
+ const gradientId = `gauge-needle-${useId().replace(/:/g, "")}`;
218
+ const groupRef = useRef(null);
219
+ const angleAt = (p) => startAngle + p * (endAngle - startAngle);
220
+ const transformAt = (p) => `translate(${cx} ${cy}) rotate(${angleAt(p)})`;
221
+ useMotionValueApply(progress, (p) => {
222
+ groupRef.current?.setAttribute("transform", transformAt(p));
223
+ });
224
+ const tip = reach;
225
+ const base = reach * (1 - Math.min(1, Math.max(0.05, length)));
226
+ const span = tip - base;
227
+ const half = width / 2;
228
+ let shape;
229
+ switch (variant) {
230
+ case "line":
231
+ shape = /* @__PURE__ */ jsx(
232
+ "line",
233
+ {
234
+ stroke: color,
235
+ strokeLinecap: "round",
236
+ strokeWidth: width,
237
+ x1: base + half,
238
+ x2: tip - half,
239
+ y1: 0,
240
+ y2: 0
241
+ }
242
+ );
243
+ break;
244
+ case "gradient":
245
+ shape = /* @__PURE__ */ jsxs(Fragment, { children: [
246
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
247
+ "linearGradient",
248
+ {
249
+ gradientUnits: "userSpaceOnUse",
250
+ id: gradientId,
251
+ x1: base,
252
+ x2: tip,
253
+ y1: 0,
254
+ y2: 0,
255
+ children: [
256
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0 }),
257
+ /* @__PURE__ */ jsx("stop", { offset: "70%", stopColor: color, stopOpacity: 0.7 }),
258
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 1 })
259
+ ]
260
+ }
261
+ ) }),
262
+ /* @__PURE__ */ jsx(
263
+ "path",
264
+ {
265
+ d: `M ${base} ${-half * 0.35} L ${tip - half} ${-half} A ${half} ${half} 0 0 1 ${tip - half} ${half} L ${base} ${half * 0.35} Z`,
266
+ fill: `url(#${gradientId})`
267
+ }
268
+ )
269
+ ] });
270
+ break;
271
+ case "triangle":
272
+ shape = /* @__PURE__ */ jsx(
273
+ "polygon",
274
+ {
275
+ fill: color,
276
+ points: `${base},${-half} ${tip},0 ${base},${half}`,
277
+ stroke: color,
278
+ strokeLinejoin: "round",
279
+ strokeWidth: 1.25
280
+ }
281
+ );
282
+ break;
283
+ case "polygon": {
284
+ const shoulder = base + span * 0.22;
285
+ shape = /* @__PURE__ */ jsx(
286
+ "polygon",
287
+ {
288
+ fill: color,
289
+ points: `${base},0 ${shoulder},${-half} ${tip},0 ${shoulder},${half}`,
290
+ stroke: color,
291
+ strokeLinejoin: "round",
292
+ strokeWidth: 1.25
293
+ }
294
+ );
295
+ break;
296
+ }
297
+ default:
298
+ shape = null;
299
+ }
300
+ return /* @__PURE__ */ jsxs("g", { children: [
301
+ /* @__PURE__ */ jsx("g", { ref: groupRef, transform: transformAt(progress.get()), children: shape }),
302
+ pivot ? /* @__PURE__ */ jsxs(Fragment, { children: [
303
+ /* @__PURE__ */ jsx("circle", { cx, cy, fill: color, r: Math.max(4, width * 0.9) }),
304
+ /* @__PURE__ */ jsx(
305
+ "circle",
306
+ {
307
+ cx,
308
+ cy,
309
+ fill: "var(--chart-background)",
310
+ r: Math.max(1.5, width * 0.35)
311
+ }
312
+ )
313
+ ] }) : null
314
+ ] });
315
+ }
316
+ export {
317
+ DEFAULT_GAUGE_SWEEP_TRANSITION,
318
+ GAUGE_TRACK_ENTER_TRANSITION,
319
+ GaugeNeedle,
320
+ GaugeRuler,
321
+ clamp01,
322
+ resolveNeedleOptions,
323
+ resolveRulerLabels,
324
+ resolveRulerOptions,
325
+ rulerFontSize,
326
+ rulerOutsideExtent,
327
+ useGaugeSweep,
328
+ useMotionValueApply
329
+ };
@@ -0,0 +1,148 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { cn } from "../lib/utils";
4
+ import {
5
+ chartCenterContainerClassName,
6
+ chartCenterLabelClassName,
7
+ chartCenterValueClassName
8
+ } from "./chart-center-typography";
9
+ import {
10
+ ChartStatFlow,
11
+ defaultChartStatFlowFormat
12
+ } from "./chart-stat-flow";
13
+ const labelAlignClass = {
14
+ start: "items-start text-left",
15
+ center: "items-center text-center",
16
+ end: "items-end text-right"
17
+ };
18
+ function GaugeLabelShell({
19
+ centerValue,
20
+ defaultLabel = "Total",
21
+ prefix,
22
+ suffix,
23
+ formatOptions = defaultChartStatFlowFormat,
24
+ align = "center",
25
+ className
26
+ }) {
27
+ return /* @__PURE__ */ jsx(
28
+ "div",
29
+ {
30
+ className: cn(
31
+ chartCenterContainerClassName,
32
+ "flex min-w-0 flex-col",
33
+ labelAlignClass[align],
34
+ className
35
+ ),
36
+ children: /* @__PURE__ */ jsx(
37
+ ChartStatFlow,
38
+ {
39
+ formatOptions,
40
+ label: defaultLabel,
41
+ labelClassName: cn(
42
+ chartCenterLabelClassName,
43
+ "text-[length:var(--chart-foreground-muted)]"
44
+ ),
45
+ prefix,
46
+ suffix,
47
+ value: centerValue,
48
+ valueClassName: cn(
49
+ chartCenterValueClassName,
50
+ "text-[length:var(--chart-foreground)]"
51
+ )
52
+ }
53
+ )
54
+ }
55
+ );
56
+ }
57
+ const crossAxisSelf = {
58
+ start: "self-start",
59
+ center: "self-center",
60
+ end: "self-end"
61
+ };
62
+ const crossAxisAlign = {
63
+ start: "items-start",
64
+ center: "items-center",
65
+ end: "items-end"
66
+ };
67
+ const inlineAxisAlign = {
68
+ start: "justify-start",
69
+ center: "justify-center",
70
+ end: "justify-end"
71
+ };
72
+ function GaugeLabelLayout({
73
+ placement,
74
+ align,
75
+ label,
76
+ children,
77
+ className
78
+ }) {
79
+ if (!label) {
80
+ return /* @__PURE__ */ jsx("div", { className: cn("w-full min-w-0", className), children });
81
+ }
82
+ if (placement === "top") {
83
+ return /* @__PURE__ */ jsxs(
84
+ "div",
85
+ {
86
+ className: cn(
87
+ "flex w-full min-w-0 flex-col gap-3",
88
+ crossAxisAlign[align],
89
+ className
90
+ ),
91
+ children: [
92
+ /* @__PURE__ */ jsx("div", { className: crossAxisSelf[align], children: label }),
93
+ /* @__PURE__ */ jsx("div", { className: "w-full min-w-0", children })
94
+ ]
95
+ }
96
+ );
97
+ }
98
+ if (placement === "bottom") {
99
+ return /* @__PURE__ */ jsxs(
100
+ "div",
101
+ {
102
+ className: cn(
103
+ "flex w-full min-w-0 flex-col gap-3",
104
+ crossAxisAlign[align],
105
+ className
106
+ ),
107
+ children: [
108
+ /* @__PURE__ */ jsx("div", { className: "w-full min-w-0", children }),
109
+ /* @__PURE__ */ jsx("div", { className: crossAxisSelf[align], children: label })
110
+ ]
111
+ }
112
+ );
113
+ }
114
+ if (placement === "left") {
115
+ return /* @__PURE__ */ jsxs(
116
+ "div",
117
+ {
118
+ className: cn(
119
+ "flex w-full min-w-0 items-center gap-4",
120
+ inlineAxisAlign[align],
121
+ className
122
+ ),
123
+ children: [
124
+ /* @__PURE__ */ jsx("div", { className: "shrink-0", children: label }),
125
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children })
126
+ ]
127
+ }
128
+ );
129
+ }
130
+ return /* @__PURE__ */ jsxs(
131
+ "div",
132
+ {
133
+ className: cn(
134
+ "flex w-full min-w-0 items-center gap-4",
135
+ inlineAxisAlign[align],
136
+ className
137
+ ),
138
+ children: [
139
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children }),
140
+ /* @__PURE__ */ jsx("div", { className: "shrink-0", children: label })
141
+ ]
142
+ }
143
+ );
144
+ }
145
+ export {
146
+ GaugeLabelLayout,
147
+ GaugeLabelShell
148
+ };