@arolariu/components 0.1.1 → 0.2.0

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 (326) hide show
  1. package/DEBUGGING.md +396 -396
  2. package/LICENSE.md +21 -21
  3. package/changelog.md +109 -118
  4. package/dist/components/ui/accordion.d.ts +2 -2
  5. package/dist/components/ui/accordion.d.ts.map +1 -1
  6. package/dist/components/ui/accordion.js +4 -4
  7. package/dist/components/ui/accordion.js.map +1 -1
  8. package/dist/components/ui/alert-dialog.d.ts +13 -13
  9. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  10. package/dist/components/ui/alert-dialog.js +4 -4
  11. package/dist/components/ui/alert-dialog.js.map +1 -1
  12. package/dist/components/ui/alert.d.ts +5 -5
  13. package/dist/components/ui/alert.d.ts.map +1 -1
  14. package/dist/components/ui/alert.js +3 -3
  15. package/dist/components/ui/alert.js.map +1 -1
  16. package/dist/components/ui/aspect-ratio.d.ts +1 -1
  17. package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
  18. package/dist/components/ui/aspect-ratio.js +1 -1
  19. package/dist/components/ui/aspect-ratio.js.map +1 -1
  20. package/dist/components/ui/avatar.d.ts +2 -2
  21. package/dist/components/ui/avatar.d.ts.map +1 -1
  22. package/dist/components/ui/avatar.js +3 -3
  23. package/dist/components/ui/avatar.js.map +1 -1
  24. package/dist/components/ui/background-beams.d.ts.map +1 -1
  25. package/dist/components/ui/background-beams.js +6 -6
  26. package/dist/components/ui/background-beams.js.map +1 -1
  27. package/dist/components/ui/badge.d.ts +4 -4
  28. package/dist/components/ui/badge.d.ts.map +1 -1
  29. package/dist/components/ui/badge.js +2 -2
  30. package/dist/components/ui/badge.js.map +1 -1
  31. package/dist/components/ui/breadcrumb.d.ts +6 -6
  32. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  33. package/dist/components/ui/breadcrumb.js +5 -5
  34. package/dist/components/ui/breadcrumb.js.map +1 -1
  35. package/dist/components/ui/bubble-background.d.ts +1 -1
  36. package/dist/components/ui/bubble-background.d.ts.map +1 -1
  37. package/dist/components/ui/bubble-background.js +13 -13
  38. package/dist/components/ui/bubble-background.js.map +1 -1
  39. package/dist/components/ui/button.d.ts +5 -5
  40. package/dist/components/ui/button.d.ts.map +1 -1
  41. package/dist/components/ui/button.js +2 -2
  42. package/dist/components/ui/button.js.map +1 -1
  43. package/dist/components/ui/calendar.d.ts.map +1 -1
  44. package/dist/components/ui/calendar.js +4 -4
  45. package/dist/components/ui/calendar.js.map +1 -1
  46. package/dist/components/ui/card.d.ts +1 -1
  47. package/dist/components/ui/card.d.ts.map +1 -1
  48. package/dist/components/ui/card.js +3 -3
  49. package/dist/components/ui/card.js.map +1 -1
  50. package/dist/components/ui/carousel.d.ts +2 -2
  51. package/dist/components/ui/carousel.d.ts.map +1 -1
  52. package/dist/components/ui/carousel.js +3 -3
  53. package/dist/components/ui/carousel.js.map +1 -1
  54. package/dist/components/ui/chart.d.ts +4 -4
  55. package/dist/components/ui/chart.d.ts.map +1 -1
  56. package/dist/components/ui/chart.js +1 -1
  57. package/dist/components/ui/chart.js.map +1 -1
  58. package/dist/components/ui/checkbox.d.ts +1 -1
  59. package/dist/components/ui/checkbox.d.ts.map +1 -1
  60. package/dist/components/ui/checkbox.js +3 -3
  61. package/dist/components/ui/checkbox.js.map +1 -1
  62. package/dist/components/ui/collapsible.d.ts +2 -2
  63. package/dist/components/ui/collapsible.d.ts.map +1 -1
  64. package/dist/components/ui/collapsible.js +1 -1
  65. package/dist/components/ui/collapsible.js.map +1 -1
  66. package/dist/components/ui/command.d.ts +2 -2
  67. package/dist/components/ui/command.d.ts.map +1 -1
  68. package/dist/components/ui/command.js +9 -9
  69. package/dist/components/ui/command.js.map +1 -1
  70. package/dist/components/ui/context-menu.d.ts +2 -2
  71. package/dist/components/ui/context-menu.d.ts.map +1 -1
  72. package/dist/components/ui/context-menu.js +11 -11
  73. package/dist/components/ui/context-menu.js.map +1 -1
  74. package/dist/components/ui/counting-number.d.ts +1 -1
  75. package/dist/components/ui/counting-number.d.ts.map +1 -1
  76. package/dist/components/ui/counting-number.js +4 -3
  77. package/dist/components/ui/counting-number.js.map +1 -1
  78. package/dist/components/ui/dialog.d.ts +1 -1
  79. package/dist/components/ui/dialog.d.ts.map +1 -1
  80. package/dist/components/ui/dialog.js +6 -6
  81. package/dist/components/ui/dialog.js.map +1 -1
  82. package/dist/components/ui/dot-background.d.ts +10 -17
  83. package/dist/components/ui/dot-background.d.ts.map +1 -1
  84. package/dist/components/ui/dot-background.js +2 -2
  85. package/dist/components/ui/dot-background.js.map +1 -1
  86. package/dist/components/ui/drawer.d.ts +1 -1
  87. package/dist/components/ui/drawer.d.ts.map +1 -1
  88. package/dist/components/ui/drawer.js +5 -5
  89. package/dist/components/ui/drawer.js.map +1 -1
  90. package/dist/components/ui/dropdown-menu.d.ts +2 -2
  91. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  92. package/dist/components/ui/dropdown-menu.js +10 -10
  93. package/dist/components/ui/dropdown-menu.js.map +1 -1
  94. package/dist/components/ui/dropdrawer.d.ts +2 -2
  95. package/dist/components/ui/dropdrawer.d.ts.map +1 -1
  96. package/dist/components/ui/dropdrawer.js +13 -13
  97. package/dist/components/ui/dropdrawer.js.map +1 -1
  98. package/dist/components/ui/fireworks-background.d.ts.map +1 -1
  99. package/dist/components/ui/fireworks-background.js +1 -1
  100. package/dist/components/ui/fireworks-background.js.map +1 -1
  101. package/dist/components/ui/flip-button.d.ts +1 -1
  102. package/dist/components/ui/flip-button.d.ts.map +1 -1
  103. package/dist/components/ui/flip-button.js +3 -3
  104. package/dist/components/ui/flip-button.js.map +1 -1
  105. package/dist/components/ui/form.d.ts +3 -3
  106. package/dist/components/ui/form.d.ts.map +1 -1
  107. package/dist/components/ui/form.js +4 -4
  108. package/dist/components/ui/form.js.map +1 -1
  109. package/dist/components/ui/gradient-background.d.ts +1 -1
  110. package/dist/components/ui/gradient-background.d.ts.map +1 -1
  111. package/dist/components/ui/gradient-background.js +2 -2
  112. package/dist/components/ui/gradient-background.js.map +1 -1
  113. package/dist/components/ui/gradient-text.d.ts +1 -1
  114. package/dist/components/ui/gradient-text.d.ts.map +1 -1
  115. package/dist/components/ui/gradient-text.js +5 -5
  116. package/dist/components/ui/gradient-text.js.map +1 -1
  117. package/dist/components/ui/highlight-text.d.ts +1 -1
  118. package/dist/components/ui/highlight-text.d.ts.map +1 -1
  119. package/dist/components/ui/highlight-text.js +3 -3
  120. package/dist/components/ui/highlight-text.js.map +1 -1
  121. package/dist/components/ui/hole-background.d.ts.map +1 -1
  122. package/dist/components/ui/hole-background.js +11 -10
  123. package/dist/components/ui/hole-background.js.map +1 -1
  124. package/dist/components/ui/hover-card.d.ts +2 -2
  125. package/dist/components/ui/hover-card.d.ts.map +1 -1
  126. package/dist/components/ui/hover-card.js +3 -3
  127. package/dist/components/ui/hover-card.js.map +1 -1
  128. package/dist/components/ui/input-otp.d.ts +2 -2
  129. package/dist/components/ui/input-otp.d.ts.map +1 -1
  130. package/dist/components/ui/input-otp.js +5 -5
  131. package/dist/components/ui/input-otp.js.map +1 -1
  132. package/dist/components/ui/input.d.ts.map +1 -1
  133. package/dist/components/ui/input.js +2 -2
  134. package/dist/components/ui/input.js.map +1 -1
  135. package/dist/components/ui/label.d.ts +1 -1
  136. package/dist/components/ui/label.d.ts.map +1 -1
  137. package/dist/components/ui/label.js +2 -2
  138. package/dist/components/ui/label.js.map +1 -1
  139. package/dist/components/ui/menubar.d.ts +2 -2
  140. package/dist/components/ui/menubar.d.ts.map +1 -1
  141. package/dist/components/ui/menubar.js +12 -12
  142. package/dist/components/ui/menubar.js.map +1 -1
  143. package/dist/components/ui/navigation-menu.d.ts +3 -3
  144. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  145. package/dist/components/ui/navigation-menu.js +6 -7
  146. package/dist/components/ui/navigation-menu.js.map +1 -1
  147. package/dist/components/ui/pagination.d.ts +2 -2
  148. package/dist/components/ui/pagination.d.ts.map +1 -1
  149. package/dist/components/ui/pagination.js +8 -4
  150. package/dist/components/ui/pagination.js.map +1 -1
  151. package/dist/components/ui/popover.d.ts +2 -2
  152. package/dist/components/ui/popover.d.ts.map +1 -1
  153. package/dist/components/ui/popover.js +3 -3
  154. package/dist/components/ui/popover.js.map +1 -1
  155. package/dist/components/ui/progress.d.ts +1 -1
  156. package/dist/components/ui/progress.d.ts.map +1 -1
  157. package/dist/components/ui/progress.js +4 -4
  158. package/dist/components/ui/progress.js.map +1 -1
  159. package/dist/components/ui/radio-group.d.ts +1 -1
  160. package/dist/components/ui/radio-group.d.ts.map +1 -1
  161. package/dist/components/ui/radio-group.js +3 -3
  162. package/dist/components/ui/radio-group.js.map +1 -1
  163. package/dist/components/ui/resizable.d.ts +1 -1
  164. package/dist/components/ui/resizable.d.ts.map +1 -1
  165. package/dist/components/ui/resizable.js +5 -5
  166. package/dist/components/ui/resizable.js.map +1 -1
  167. package/dist/components/ui/ripple-button.d.ts +1 -1
  168. package/dist/components/ui/ripple-button.d.ts.map +1 -1
  169. package/dist/components/ui/ripple-button.js +4 -4
  170. package/dist/components/ui/ripple-button.js.map +1 -1
  171. package/dist/components/ui/scratcher.d.ts.map +1 -1
  172. package/dist/components/ui/scratcher.js +7 -5
  173. package/dist/components/ui/scratcher.js.map +1 -1
  174. package/dist/components/ui/scroll-area.d.ts +1 -1
  175. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  176. package/dist/components/ui/scroll-area.js +4 -4
  177. package/dist/components/ui/scroll-area.js.map +1 -1
  178. package/dist/components/ui/select.d.ts +1 -1
  179. package/dist/components/ui/select.d.ts.map +1 -1
  180. package/dist/components/ui/select.js +7 -7
  181. package/dist/components/ui/select.js.map +1 -1
  182. package/dist/components/ui/separator.d.ts +1 -1
  183. package/dist/components/ui/separator.d.ts.map +1 -1
  184. package/dist/components/ui/separator.js +3 -3
  185. package/dist/components/ui/separator.js.map +1 -1
  186. package/dist/components/ui/sheet.d.ts +2 -2
  187. package/dist/components/ui/sheet.d.ts.map +1 -1
  188. package/dist/components/ui/sheet.js +6 -6
  189. package/dist/components/ui/sheet.js.map +1 -1
  190. package/dist/components/ui/sidebar.d.ts +5 -5
  191. package/dist/components/ui/sidebar.d.ts.map +1 -1
  192. package/dist/components/ui/sidebar.js +5 -5
  193. package/dist/components/ui/sidebar.js.map +1 -1
  194. package/dist/components/ui/skeleton.d.ts.map +1 -1
  195. package/dist/components/ui/skeleton.js +2 -2
  196. package/dist/components/ui/skeleton.js.map +1 -1
  197. package/dist/components/ui/slider.d.ts +1 -1
  198. package/dist/components/ui/slider.d.ts.map +1 -1
  199. package/dist/components/ui/slider.js +5 -5
  200. package/dist/components/ui/slider.js.map +1 -1
  201. package/dist/components/ui/sonner.d.ts +1 -1
  202. package/dist/components/ui/sonner.d.ts.map +1 -1
  203. package/dist/components/ui/sonner.js +1 -1
  204. package/dist/components/ui/sonner.js.map +1 -1
  205. package/dist/components/ui/switch.d.ts +1 -1
  206. package/dist/components/ui/switch.d.ts.map +1 -1
  207. package/dist/components/ui/switch.js +4 -4
  208. package/dist/components/ui/switch.js.map +1 -1
  209. package/dist/components/ui/table.d.ts +1 -1
  210. package/dist/components/ui/table.d.ts.map +1 -1
  211. package/dist/components/ui/table.js +5 -5
  212. package/dist/components/ui/table.js.map +1 -1
  213. package/dist/components/ui/tabs.d.ts +2 -2
  214. package/dist/components/ui/tabs.d.ts.map +1 -1
  215. package/dist/components/ui/tabs.js +4 -4
  216. package/dist/components/ui/tabs.js.map +1 -1
  217. package/dist/components/ui/textarea.d.ts +1 -1
  218. package/dist/components/ui/textarea.d.ts.map +1 -1
  219. package/dist/components/ui/textarea.js +2 -2
  220. package/dist/components/ui/textarea.js.map +1 -1
  221. package/dist/components/ui/toggle-group.d.ts +3 -3
  222. package/dist/components/ui/toggle-group.d.ts.map +1 -1
  223. package/dist/components/ui/toggle-group.js +2 -2
  224. package/dist/components/ui/toggle-group.js.map +1 -1
  225. package/dist/components/ui/toggle.d.ts +6 -6
  226. package/dist/components/ui/toggle.d.ts.map +1 -1
  227. package/dist/components/ui/toggle.js +2 -2
  228. package/dist/components/ui/toggle.js.map +1 -1
  229. package/dist/components/ui/tooltip.d.ts +6 -6
  230. package/dist/components/ui/tooltip.d.ts.map +1 -1
  231. package/dist/components/ui/tooltip.js +4 -4
  232. package/dist/components/ui/tooltip.js.map +1 -1
  233. package/dist/components/ui/typewriter.d.ts.map +1 -1
  234. package/dist/components/ui/typewriter.js +15 -11
  235. package/dist/components/ui/typewriter.js.map +1 -1
  236. package/dist/hooks/{use-mobile.d.ts → useIsMobile.d.ts} +3 -6
  237. package/dist/hooks/useIsMobile.d.ts.map +1 -0
  238. package/dist/hooks/useIsMobile.js +19 -0
  239. package/dist/hooks/useIsMobile.js.map +1 -0
  240. package/dist/hooks/useWindowSize.d.ts +29 -0
  241. package/dist/hooks/useWindowSize.d.ts.map +1 -0
  242. package/dist/hooks/useWindowSize.js +28 -0
  243. package/dist/hooks/useWindowSize.js.map +1 -0
  244. package/dist/index.css +2 -2
  245. package/dist/index.css.map +1 -1
  246. package/dist/index.d.ts +39 -38
  247. package/dist/index.d.ts.map +1 -1
  248. package/dist/index.js +5 -4
  249. package/dist/lib/utilities.d.ts +9 -0
  250. package/dist/lib/utilities.d.ts.map +1 -0
  251. package/dist/lib/{utils.js → utilities.js} +1 -1
  252. package/dist/lib/utilities.js.map +1 -0
  253. package/package.json +95 -94
  254. package/{README.md → readme.md} +627 -627
  255. package/src/components/ui/accordion.tsx +56 -66
  256. package/src/components/ui/alert-dialog.tsx +135 -160
  257. package/src/components/ui/alert.tsx +58 -69
  258. package/src/components/ui/aspect-ratio.tsx +15 -12
  259. package/src/components/ui/avatar.tsx +38 -53
  260. package/src/components/ui/background-beams.tsx +145 -142
  261. package/src/components/ui/badge.tsx +47 -48
  262. package/src/components/ui/breadcrumb.tsx +97 -117
  263. package/src/components/ui/bubble-background.tsx +170 -189
  264. package/src/components/ui/button.tsx +61 -61
  265. package/src/components/ui/calendar.tsx +177 -216
  266. package/src/components/ui/card.tsx +83 -97
  267. package/src/components/ui/carousel.tsx +204 -241
  268. package/src/components/ui/chart.tsx +303 -385
  269. package/src/components/ui/checkbox.tsx +27 -32
  270. package/src/components/ui/collapsible.tsx +33 -34
  271. package/src/components/ui/command.tsx +137 -184
  272. package/src/components/ui/context-menu.tsx +229 -255
  273. package/src/components/ui/counting-number.tsx +92 -108
  274. package/src/components/ui/dialog.tsx +141 -146
  275. package/src/components/ui/dot-background.tsx +153 -158
  276. package/src/components/ui/drawer.tsx +133 -141
  277. package/src/components/ui/dropdown-menu.tsx +235 -260
  278. package/src/components/ui/dropdrawer.tsx +870 -973
  279. package/src/components/ui/fireworks-background.tsx +325 -378
  280. package/src/components/ui/flip-button.tsx +89 -110
  281. package/src/components/ui/form.tsx +145 -174
  282. package/src/components/ui/gradient-background.tsx +30 -43
  283. package/src/components/ui/gradient-text.tsx +62 -65
  284. package/src/components/ui/highlight-text.tsx +54 -71
  285. package/src/components/ui/hole-background.tsx +326 -361
  286. package/src/components/ui/hover-card.tsx +48 -44
  287. package/src/components/ui/input-otp.tsx +76 -77
  288. package/src/components/ui/input.tsx +22 -22
  289. package/src/components/ui/label.tsx +21 -24
  290. package/src/components/ui/menubar.tsx +256 -279
  291. package/src/components/ui/navigation-menu.tsx +135 -171
  292. package/src/components/ui/pagination.tsx +103 -129
  293. package/src/components/ui/popover.tsx +52 -48
  294. package/src/components/ui/progress.tsx +23 -31
  295. package/src/components/ui/radio-group.tsx +37 -45
  296. package/src/components/ui/resizable.tsx +52 -56
  297. package/src/components/ui/ripple-button.tsx +90 -111
  298. package/src/components/ui/scratcher.tsx +167 -171
  299. package/src/components/ui/scroll-area.tsx +45 -58
  300. package/src/components/ui/select.tsx +160 -191
  301. package/src/components/ui/separator.tsx +28 -28
  302. package/src/components/ui/sheet.tsx +133 -145
  303. package/src/components/ui/sidebar.tsx +673 -729
  304. package/src/components/ui/skeleton.tsx +16 -19
  305. package/src/components/ui/slider.tsx +49 -63
  306. package/src/components/ui/sonner.tsx +30 -26
  307. package/src/components/ui/switch.tsx +27 -31
  308. package/src/components/ui/table.tsx +98 -119
  309. package/src/components/ui/tabs.tsx +54 -66
  310. package/src/components/ui/textarea.tsx +20 -20
  311. package/src/components/ui/toggle-group.tsx +66 -73
  312. package/src/components/ui/toggle.tsx +46 -47
  313. package/src/components/ui/tooltip.tsx +56 -61
  314. package/src/components/ui/typewriter.tsx +174 -188
  315. package/src/hooks/{use-mobile.tsx → useIsMobile.tsx} +42 -44
  316. package/src/hooks/useWindowSize.tsx +66 -0
  317. package/src/index.css +73 -73
  318. package/src/index.ts +303 -407
  319. package/src/lib/utilities.ts +12 -0
  320. package/dist/hooks/use-mobile.d.ts.map +0 -1
  321. package/dist/hooks/use-mobile.js +0 -18
  322. package/dist/hooks/use-mobile.js.map +0 -1
  323. package/dist/lib/utils.d.ts +0 -7
  324. package/dist/lib/utils.d.ts.map +0 -1
  325. package/dist/lib/utils.js.map +0 -1
  326. package/src/lib/utils.ts +0 -10
@@ -1,385 +1,303 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import * as RechartsPrimitive from "recharts";
5
-
6
- import type { LegendPayload } from "recharts/types/component/DefaultLegendContent";
7
- import {
8
- NameType,
9
- Payload,
10
- ValueType,
11
- } from "recharts/types/component/DefaultTooltipContent";
12
- import type { Props as LegendProps } from "recharts/types/component/Legend";
13
- import { TooltipContentProps } from "recharts/types/component/Tooltip";
14
-
15
- import { cn } from "@/lib/utils";
16
-
17
- // Format: { THEME_NAME: CSS_SELECTOR }
18
- const THEMES = { light: "", dark: ".dark" } as const;
19
-
20
- export type ChartConfig = {
21
- [k in string]: {
22
- label?: React.ReactNode;
23
- icon?: React.ComponentType;
24
- } & (
25
- | { color?: string; theme?: never }
26
- | { color?: never; theme: Record<keyof typeof THEMES, string> }
27
- );
28
- };
29
-
30
- type ChartContextProps = {
31
- config: ChartConfig;
32
- };
33
-
34
- export type CustomTooltipProps = TooltipContentProps<ValueType, NameType> & {
35
- className?: string;
36
- hideLabel?: boolean;
37
- hideIndicator?: boolean;
38
- indicator?: "line" | "dot" | "dashed";
39
- nameKey?: string;
40
- labelKey?: string;
41
- labelFormatter?: (
42
- label: TooltipContentProps<number, string>["label"],
43
- payload: TooltipContentProps<number, string>["payload"],
44
- ) => React.ReactNode;
45
- formatter?: (
46
- value: number | string,
47
- name: string,
48
- item: Payload<number | string, string>,
49
- index: number,
50
- payload: ReadonlyArray<Payload<number | string, string>>,
51
- ) => React.ReactNode;
52
- labelClassName?: string;
53
- color?: string;
54
- };
55
-
56
- export type ChartLegendContentProps = {
57
- className?: string;
58
- hideIcon?: boolean;
59
- verticalAlign?: LegendProps["verticalAlign"];
60
- payload?: LegendPayload[];
61
- nameKey?: string;
62
- };
63
-
64
- const ChartContext = React.createContext<ChartContextProps | null>(null);
65
-
66
- function useChart() {
67
- const context = React.useContext(ChartContext);
68
-
69
- if (!context) {
70
- throw new Error("useChart must be used within a <ChartContainer />");
71
- }
72
-
73
- return context;
74
- }
75
-
76
- function ChartContainer({
77
- id,
78
- className,
79
- children,
80
- config,
81
- ...props
82
- }: React.ComponentProps<"div"> & {
83
- config: ChartConfig;
84
- children: React.ComponentProps<
85
- typeof RechartsPrimitive.ResponsiveContainer
86
- >["children"];
87
- }) {
88
- const uniqueId = React.useId();
89
- const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
90
-
91
- return (
92
- <ChartContext.Provider value={{ config }}>
93
- <div
94
- data-slot="chart"
95
- data-chart={chartId}
96
- className={cn(
97
- "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
98
- className,
99
- )}
100
- {...props}
101
- >
102
- <ChartStyle id={chartId} config={config} />
103
- <RechartsPrimitive.ResponsiveContainer>
104
- {children}
105
- </RechartsPrimitive.ResponsiveContainer>
106
- </div>
107
- </ChartContext.Provider>
108
- );
109
- }
110
-
111
- const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
112
- const colorConfig = Object.entries(config).filter(
113
- ([, config]) => config.theme || config.color,
114
- );
115
-
116
- if (!colorConfig.length) {
117
- return null;
118
- }
119
-
120
- return (
121
- <style
122
- dangerouslySetInnerHTML={{
123
- __html: Object.entries(THEMES)
124
- .map(
125
- ([theme, prefix]) => `
126
- ${prefix} [data-chart=${id}] {
127
- ${colorConfig
128
- .map(([key, itemConfig]) => {
129
- const color =
130
- itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ||
131
- itemConfig.color;
132
- return color ? ` --color-${key}: ${color};` : null;
133
- })
134
- .join("\n")}
135
- }
136
- `,
137
- )
138
- .join("\n"),
139
- }}
140
- />
141
- );
142
- };
143
-
144
- const ChartTooltip = RechartsPrimitive.Tooltip;
145
-
146
- function ChartTooltipContent({
147
- active,
148
- payload,
149
- label,
150
- className,
151
- indicator = "dot",
152
- hideLabel = false,
153
- hideIndicator = false,
154
- labelFormatter,
155
- formatter,
156
- labelClassName,
157
- color,
158
- nameKey,
159
- labelKey,
160
- }: CustomTooltipProps) {
161
- const { config } = useChart();
162
-
163
- const tooltipLabel = React.useMemo(() => {
164
- if (hideLabel || !payload?.length) {
165
- return null;
166
- }
167
-
168
- const [item] = payload;
169
- const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
170
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
171
- const value = (() => {
172
- const v =
173
- !labelKey && typeof label === "string"
174
- ? (config[label as keyof typeof config]?.label ?? label)
175
- : itemConfig?.label;
176
-
177
- return typeof v === "string" || typeof v === "number" ? v : undefined;
178
- })();
179
-
180
- if (labelFormatter) {
181
- return (
182
- <div className={cn("font-medium", labelClassName)}>
183
- {labelFormatter(value, payload)}
184
- </div>
185
- );
186
- }
187
-
188
- if (!value) {
189
- return null;
190
- }
191
-
192
- return <div className={cn("font-medium", labelClassName)}>{value}</div>;
193
- }, [
194
- label,
195
- labelFormatter,
196
- payload,
197
- hideLabel,
198
- labelClassName,
199
- config,
200
- labelKey,
201
- ]);
202
-
203
- if (!active || !payload?.length) {
204
- return null;
205
- }
206
-
207
- const nestLabel = payload.length === 1 && indicator !== "dot";
208
-
209
- return (
210
- <div
211
- className={cn(
212
- "border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
213
- className,
214
- )}
215
- >
216
- {!nestLabel ? tooltipLabel : null}
217
- <div className="grid gap-1.5">
218
- {payload.map((item, index) => {
219
- const key = `${nameKey || item.name || item.dataKey || "value"}`;
220
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
221
- const indicatorColor = color || item.payload.fill || item.color;
222
-
223
- return (
224
- <div
225
- key={item.dataKey}
226
- className={cn(
227
- "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
228
- indicator === "dot" && "items-center",
229
- )}
230
- >
231
- {formatter && item?.value !== undefined && item.name ? (
232
- formatter(item.value, item.name, item, index, item.payload)
233
- ) : (
234
- <>
235
- {itemConfig?.icon ? (
236
- <itemConfig.icon />
237
- ) : (
238
- !hideIndicator && (
239
- <div
240
- className={cn(
241
- "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
242
- {
243
- "h-2.5 w-2.5": indicator === "dot",
244
- "w-1": indicator === "line",
245
- "w-0 border-[1.5px] border-dashed bg-transparent":
246
- indicator === "dashed",
247
- "my-0.5": nestLabel && indicator === "dashed",
248
- },
249
- )}
250
- style={
251
- {
252
- "--color-bg": indicatorColor,
253
- "--color-border": indicatorColor,
254
- } as React.CSSProperties
255
- }
256
- />
257
- )
258
- )}
259
- <div
260
- className={cn(
261
- "flex flex-1 justify-between leading-none",
262
- nestLabel ? "items-end" : "items-center",
263
- )}
264
- >
265
- <div className="grid gap-1.5">
266
- {nestLabel ? tooltipLabel : null}
267
- <span className="text-muted-foreground">
268
- {itemConfig?.label || item.name}
269
- </span>
270
- </div>
271
- {item.value && (
272
- <span className="text-foreground font-mono font-medium tabular-nums">
273
- {item.value.toLocaleString()}
274
- </span>
275
- )}
276
- </div>
277
- </>
278
- )}
279
- </div>
280
- );
281
- })}
282
- </div>
283
- </div>
284
- );
285
- }
286
-
287
- const ChartLegend = RechartsPrimitive.Legend;
288
-
289
- function ChartLegendContent({
290
- className,
291
- hideIcon = false,
292
- payload,
293
- verticalAlign = "bottom",
294
- nameKey,
295
- }: ChartLegendContentProps) {
296
- const { config } = useChart();
297
-
298
- if (!payload?.length) {
299
- return null;
300
- }
301
-
302
- return (
303
- <div
304
- className={cn(
305
- "flex items-center justify-center gap-4",
306
- verticalAlign === "top" ? "pb-3" : "pt-3",
307
- className,
308
- )}
309
- >
310
- {payload.map((item) => {
311
- const key = `${nameKey || item.dataKey || "value"}`;
312
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
313
-
314
- return (
315
- <div
316
- key={item.value}
317
- className={cn(
318
- "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3",
319
- )}
320
- >
321
- {itemConfig?.icon && !hideIcon ? (
322
- <itemConfig.icon />
323
- ) : (
324
- <div
325
- className="h-2 w-2 shrink-0 rounded-[2px]"
326
- style={{
327
- backgroundColor: item.color,
328
- }}
329
- />
330
- )}
331
- {itemConfig?.label}
332
- </div>
333
- );
334
- })}
335
- </div>
336
- );
337
- }
338
-
339
- // Helper to extract item config from a payload.
340
- function getPayloadConfigFromPayload(
341
- config: ChartConfig,
342
- payload: unknown,
343
- key: string,
344
- ) {
345
- if (typeof payload !== "object" || payload === null) {
346
- return undefined;
347
- }
348
-
349
- const payloadPayload =
350
- "payload" in payload &&
351
- typeof payload.payload === "object" &&
352
- payload.payload !== null
353
- ? payload.payload
354
- : undefined;
355
-
356
- let configLabelKey: string = key;
357
-
358
- if (
359
- key in payload &&
360
- typeof payload[key as keyof typeof payload] === "string"
361
- ) {
362
- configLabelKey = payload[key as keyof typeof payload] as string;
363
- } else if (
364
- payloadPayload &&
365
- key in payloadPayload &&
366
- typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
367
- ) {
368
- configLabelKey = payloadPayload[
369
- key as keyof typeof payloadPayload
370
- ] as string;
371
- }
372
-
373
- return configLabelKey in config
374
- ? config[configLabelKey]
375
- : config[key as keyof typeof config];
376
- }
377
-
378
- export {
379
- ChartContainer,
380
- ChartTooltip,
381
- ChartTooltipContent,
382
- ChartLegend,
383
- ChartLegendContent,
384
- ChartStyle,
385
- };
1
+ "use client";
2
+
3
+ /* eslint-disable */
4
+
5
+ import * as React from "react";
6
+ import * as RechartsPrimitive from "recharts";
7
+
8
+ import type {LegendPayload} from "recharts/types/component/DefaultLegendContent";
9
+ import {NameType, Payload, ValueType} from "recharts/types/component/DefaultTooltipContent";
10
+ import type {Props as LegendProps} from "recharts/types/component/Legend";
11
+ import {TooltipContentProps} from "recharts/types/component/Tooltip";
12
+
13
+ import {cn} from "@/lib/utilities";
14
+
15
+ // Format: { THEME_NAME: CSS_SELECTOR }
16
+ const THEMES = {light: "", dark: ".dark"} as const;
17
+
18
+ export type ChartConfig = {
19
+ [k in string]: {
20
+ label?: React.ReactNode;
21
+ icon?: React.ComponentType;
22
+ } & ({color?: string; theme?: never} | {color?: never; theme: Record<keyof typeof THEMES, string>});
23
+ };
24
+
25
+ type ChartContextProps = {
26
+ config: ChartConfig;
27
+ };
28
+
29
+ export type CustomTooltipProps = TooltipContentProps<ValueType, NameType> & {
30
+ className?: string;
31
+ hideLabel?: boolean;
32
+ hideIndicator?: boolean;
33
+ indicator?: "line" | "dot" | "dashed";
34
+ nameKey?: string;
35
+ labelKey?: string;
36
+ labelFormatter?: (
37
+ label: TooltipContentProps<number, string>["label"],
38
+ payload: TooltipContentProps<number, string>["payload"],
39
+ ) => React.ReactNode;
40
+ formatter?: (
41
+ value: number | string,
42
+ name: string,
43
+ item: Payload<number | string, string>,
44
+ index: number,
45
+ payload: ReadonlyArray<Payload<number | string, string>>,
46
+ ) => React.ReactNode;
47
+ labelClassName?: string;
48
+ color?: string;
49
+ };
50
+
51
+ export type ChartLegendContentProps = {
52
+ className?: string;
53
+ hideIcon?: boolean;
54
+ verticalAlign?: LegendProps["verticalAlign"];
55
+ payload?: LegendPayload[];
56
+ nameKey?: string;
57
+ };
58
+
59
+ const ChartContext = React.createContext<ChartContextProps | null>(null);
60
+
61
+ function useChart() {
62
+ const context = React.useContext(ChartContext);
63
+
64
+ if (!context) {
65
+ throw new Error("useChart must be used within a <ChartContainer />");
66
+ }
67
+
68
+ return context;
69
+ }
70
+
71
+ function ChartContainer({
72
+ id,
73
+ className,
74
+ children,
75
+ config,
76
+ ...props
77
+ }: React.ComponentProps<"div"> & {
78
+ config: ChartConfig;
79
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
80
+ }) {
81
+ const uniqueId = React.useId();
82
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
83
+
84
+ return (
85
+ <ChartContext.Provider value={{config}}>
86
+ <div
87
+ data-slot='chart'
88
+ data-chart={chartId}
89
+ className={cn(
90
+ "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
91
+ className,
92
+ )}
93
+ {...props}>
94
+ <ChartStyle
95
+ id={chartId}
96
+ config={config}
97
+ />
98
+ <RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
99
+ </div>
100
+ </ChartContext.Provider>
101
+ );
102
+ }
103
+
104
+ const ChartStyle = ({id, config}: {id: string; config: ChartConfig}) => {
105
+ const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
106
+
107
+ if (!colorConfig.length) {
108
+ return null;
109
+ }
110
+
111
+ return (
112
+ <style
113
+ dangerouslySetInnerHTML={{
114
+ __html: Object.entries(THEMES)
115
+ .map(
116
+ ([theme, prefix]) => `
117
+ ${prefix} [data-chart=${id}] {
118
+ ${colorConfig
119
+ .map(([key, itemConfig]) => {
120
+ const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
121
+ return color ? ` --color-${key}: ${color};` : null;
122
+ })
123
+ .join("\n")}
124
+ }
125
+ `,
126
+ )
127
+ .join("\n"),
128
+ }}
129
+ />
130
+ );
131
+ };
132
+
133
+ const ChartTooltip = RechartsPrimitive.Tooltip;
134
+
135
+ function ChartTooltipContent({
136
+ active,
137
+ payload,
138
+ label,
139
+ className,
140
+ indicator = "dot",
141
+ hideLabel = false,
142
+ hideIndicator = false,
143
+ labelFormatter,
144
+ formatter,
145
+ labelClassName,
146
+ color,
147
+ nameKey,
148
+ labelKey,
149
+ }: CustomTooltipProps) {
150
+ const {config} = useChart();
151
+
152
+ const tooltipLabel = React.useMemo(() => {
153
+ if (hideLabel || !payload?.length) {
154
+ return null;
155
+ }
156
+
157
+ const [item] = payload;
158
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
159
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
160
+ const value = (() => {
161
+ const v = !labelKey && typeof label === "string" ? (config[label as keyof typeof config]?.label ?? label) : itemConfig?.label;
162
+
163
+ return typeof v === "string" || typeof v === "number" ? v : undefined;
164
+ })();
165
+
166
+ if (labelFormatter) {
167
+ return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
168
+ }
169
+
170
+ if (!value) {
171
+ return null;
172
+ }
173
+
174
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
175
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
176
+
177
+ if (!active || !payload?.length) {
178
+ return null;
179
+ }
180
+
181
+ const nestLabel = payload.length === 1 && indicator !== "dot";
182
+
183
+ return (
184
+ <div
185
+ className={cn(
186
+ "border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
187
+ className,
188
+ )}>
189
+ {!nestLabel ? tooltipLabel : null}
190
+ <div className='grid gap-1.5'>
191
+ {payload.map((item, index) => {
192
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
193
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
194
+ const indicatorColor = color || item.payload.fill || item.color;
195
+
196
+ return (
197
+ <div
198
+ key={item.dataKey}
199
+ className={cn(
200
+ "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
201
+ indicator === "dot" && "items-center",
202
+ )}>
203
+ {formatter && item?.value !== undefined && item.name ? (
204
+ formatter(item.value, item.name, item, index, item.payload)
205
+ ) : (
206
+ <>
207
+ {itemConfig?.icon ? (
208
+ <itemConfig.icon />
209
+ ) : (
210
+ !hideIndicator && (
211
+ <div
212
+ className={cn("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", {
213
+ "h-2.5 w-2.5": indicator === "dot",
214
+ "w-1": indicator === "line",
215
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
216
+ "my-0.5": nestLabel && indicator === "dashed",
217
+ })}
218
+ style={
219
+ {
220
+ "--color-bg": indicatorColor,
221
+ "--color-border": indicatorColor,
222
+ } as React.CSSProperties
223
+ }
224
+ />
225
+ )
226
+ )}
227
+ <div className={cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center")}>
228
+ <div className='grid gap-1.5'>
229
+ {nestLabel ? tooltipLabel : null}
230
+ <span className='text-muted-foreground'>{itemConfig?.label || item.name}</span>
231
+ </div>
232
+ {item.value && (
233
+ <span className='text-foreground font-mono font-medium tabular-nums'>{item.value.toLocaleString()}</span>
234
+ )}
235
+ </div>
236
+ </>
237
+ )}
238
+ </div>
239
+ );
240
+ })}
241
+ </div>
242
+ </div>
243
+ );
244
+ }
245
+
246
+ const ChartLegend = RechartsPrimitive.Legend;
247
+
248
+ function ChartLegendContent({className, hideIcon = false, payload, verticalAlign = "bottom", nameKey}: ChartLegendContentProps) {
249
+ const {config} = useChart();
250
+
251
+ if (!payload?.length) {
252
+ return null;
253
+ }
254
+
255
+ return (
256
+ <div className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}>
257
+ {payload.map((item) => {
258
+ const key = `${nameKey || item.dataKey || "value"}`;
259
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
260
+
261
+ return (
262
+ <div
263
+ key={item.value}
264
+ className={cn("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3")}>
265
+ {itemConfig?.icon && !hideIcon ? (
266
+ <itemConfig.icon />
267
+ ) : (
268
+ <div
269
+ className='h-2 w-2 shrink-0 rounded-[2px]'
270
+ style={{
271
+ backgroundColor: item.color,
272
+ }}
273
+ />
274
+ )}
275
+ {itemConfig?.label}
276
+ </div>
277
+ );
278
+ })}
279
+ </div>
280
+ );
281
+ }
282
+
283
+ // Helper to extract item config from a payload.
284
+ function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
285
+ if (typeof payload !== "object" || payload === null) {
286
+ return undefined;
287
+ }
288
+
289
+ const payloadPayload =
290
+ "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : undefined;
291
+
292
+ let configLabelKey: string = key;
293
+
294
+ if (key in payload && typeof payload[key as keyof typeof payload] === "string") {
295
+ configLabelKey = payload[key as keyof typeof payload] as string;
296
+ } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key as keyof typeof payloadPayload] === "string") {
297
+ configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
298
+ }
299
+
300
+ return configLabelKey in config ? config[configLabelKey] : config[key as keyof typeof config];
301
+ }
302
+
303
+ export {ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent};