@arolariu/components 0.2.0 → 0.3.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 (281) hide show
  1. package/changelog.md +15 -0
  2. package/dist/components/ui/accordion.d.ts +4 -4
  3. package/dist/components/ui/accordion.d.ts.map +1 -1
  4. package/dist/components/ui/accordion.js +19 -27
  5. package/dist/components/ui/accordion.js.map +1 -1
  6. package/dist/components/ui/alert-dialog.d.ts +17 -11
  7. package/dist/components/ui/alert-dialog.d.ts.map +1 -1
  8. package/dist/components/ui/alert-dialog.js +38 -61
  9. package/dist/components/ui/alert-dialog.js.map +1 -1
  10. package/dist/components/ui/alert.d.ts +4 -5
  11. package/dist/components/ui/alert.d.ts.map +1 -1
  12. package/dist/components/ui/alert.js +17 -20
  13. package/dist/components/ui/alert.js.map +1 -1
  14. package/dist/components/ui/aspect-ratio.d.ts +1 -2
  15. package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
  16. package/dist/components/ui/aspect-ratio.js +1 -8
  17. package/dist/components/ui/aspect-ratio.js.map +1 -1
  18. package/dist/components/ui/avatar.d.ts +3 -3
  19. package/dist/components/ui/avatar.d.ts.map +1 -1
  20. package/dist/components/ui/avatar.js +16 -19
  21. package/dist/components/ui/avatar.js.map +1 -1
  22. package/dist/components/ui/badge.d.ts +3 -3
  23. package/dist/components/ui/badge.d.ts.map +1 -1
  24. package/dist/components/ui/badge.js +7 -10
  25. package/dist/components/ui/badge.js.map +1 -1
  26. package/dist/components/ui/breadcrumb.d.ts +16 -8
  27. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  28. package/dist/components/ui/breadcrumb.js +28 -35
  29. package/dist/components/ui/breadcrumb.js.map +1 -1
  30. package/dist/components/ui/button-group.d.ts +13 -0
  31. package/dist/components/ui/button-group.d.ts.map +1 -0
  32. package/dist/components/ui/button-group.js +47 -0
  33. package/dist/components/ui/button-group.js.map +1 -0
  34. package/dist/components/ui/button.d.ts +3 -2
  35. package/dist/components/ui/button.d.ts.map +1 -1
  36. package/dist/components/ui/button.js +15 -14
  37. package/dist/components/ui/button.js.map +1 -1
  38. package/dist/components/ui/calendar.js +20 -20
  39. package/dist/components/ui/calendar.js.map +1 -1
  40. package/dist/components/ui/card.d.ts +7 -8
  41. package/dist/components/ui/card.d.ts.map +1 -1
  42. package/dist/components/ui/card.js +31 -44
  43. package/dist/components/ui/card.js.map +1 -1
  44. package/dist/components/ui/carousel.d.ts +5 -6
  45. package/dist/components/ui/carousel.d.ts.map +1 -1
  46. package/dist/components/ui/carousel.js +29 -20
  47. package/dist/components/ui/carousel.js.map +1 -1
  48. package/dist/components/ui/chart.d.ts +35 -27
  49. package/dist/components/ui/chart.d.ts.map +1 -1
  50. package/dist/components/ui/chart.js +28 -26
  51. package/dist/components/ui/chart.js.map +1 -1
  52. package/dist/components/ui/checkbox.d.ts +1 -1
  53. package/dist/components/ui/checkbox.d.ts.map +1 -1
  54. package/dist/components/ui/checkbox.js +10 -12
  55. package/dist/components/ui/checkbox.js.map +1 -1
  56. package/dist/components/ui/collapsible.d.ts +2 -4
  57. package/dist/components/ui/collapsible.d.ts.map +1 -1
  58. package/dist/components/ui/collapsible.js +31 -20
  59. package/dist/components/ui/collapsible.js.map +1 -1
  60. package/dist/components/ui/command.d.ts +78 -16
  61. package/dist/components/ui/command.d.ts.map +1 -1
  62. package/dist/components/ui/command.js +47 -72
  63. package/dist/components/ui/command.js.map +1 -1
  64. package/dist/components/ui/context-menu.d.ts +21 -19
  65. package/dist/components/ui/context-menu.d.ts.map +1 -1
  66. package/dist/components/ui/context-menu.js +57 -101
  67. package/dist/components/ui/context-menu.js.map +1 -1
  68. package/dist/components/ui/dialog.d.ts +16 -12
  69. package/dist/components/ui/dialog.d.ts.map +1 -1
  70. package/dist/components/ui/dialog.js +36 -64
  71. package/dist/components/ui/dialog.js.map +1 -1
  72. package/dist/components/ui/drawer.d.ts +19 -10
  73. package/dist/components/ui/drawer.d.ts.map +1 -1
  74. package/dist/components/ui/drawer.js +32 -57
  75. package/dist/components/ui/drawer.js.map +1 -1
  76. package/dist/components/ui/dropdown-menu.d.ts +21 -19
  77. package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
  78. package/dist/components/ui/dropdown-menu.js +64 -108
  79. package/dist/components/ui/dropdown-menu.js.map +1 -1
  80. package/dist/components/ui/dropdrawer.d.ts +1 -1
  81. package/dist/components/ui/dropdrawer.d.ts.map +1 -1
  82. package/dist/components/ui/dropdrawer.js +2 -5
  83. package/dist/components/ui/dropdrawer.js.map +1 -1
  84. package/dist/components/ui/empty.d.ts +13 -0
  85. package/dist/components/ui/empty.d.ts.map +1 -0
  86. package/dist/components/ui/empty.js +65 -0
  87. package/dist/components/ui/empty.js.map +1 -0
  88. package/dist/components/ui/field.d.ts +26 -0
  89. package/dist/components/ui/field.d.ts.map +1 -0
  90. package/dist/components/ui/field.js +135 -0
  91. package/dist/components/ui/field.js.map +1 -0
  92. package/dist/components/ui/form.d.ts +5 -6
  93. package/dist/components/ui/form.d.ts.map +1 -1
  94. package/dist/components/ui/form.js +29 -28
  95. package/dist/components/ui/form.js.map +1 -1
  96. package/dist/components/ui/hover-card.d.ts +3 -3
  97. package/dist/components/ui/hover-card.d.ts.map +1 -1
  98. package/dist/components/ui/hover-card.js +11 -25
  99. package/dist/components/ui/hover-card.js.map +1 -1
  100. package/dist/components/ui/input-group.d.ts +17 -0
  101. package/dist/components/ui/input-group.d.ts.map +1 -0
  102. package/dist/components/ui/input-group.js +91 -0
  103. package/dist/components/ui/input-group.js.map +1 -0
  104. package/dist/components/ui/input-otp.d.ts +30 -7
  105. package/dist/components/ui/input-otp.d.ts.map +1 -1
  106. package/dist/components/ui/input-otp.js +22 -25
  107. package/dist/components/ui/input-otp.js.map +1 -1
  108. package/dist/components/ui/input.d.ts +1 -1
  109. package/dist/components/ui/input.d.ts.map +1 -1
  110. package/dist/components/ui/input.js +6 -7
  111. package/dist/components/ui/input.js.map +1 -1
  112. package/dist/components/ui/item.d.ts +24 -0
  113. package/dist/components/ui/item.d.ts.map +1 -0
  114. package/dist/components/ui/item.js +122 -0
  115. package/dist/components/ui/item.js.map +1 -0
  116. package/dist/components/ui/kbd.d.ts +5 -0
  117. package/dist/components/ui/kbd.d.ts.map +1 -0
  118. package/dist/components/ui/kbd.js +21 -0
  119. package/dist/components/ui/kbd.js.map +1 -0
  120. package/dist/components/ui/label.d.ts +2 -1
  121. package/dist/components/ui/label.d.ts.map +1 -1
  122. package/dist/components/ui/label.js +8 -7
  123. package/dist/components/ui/label.js.map +1 -1
  124. package/dist/components/ui/menubar.d.ts +18 -16
  125. package/dist/components/ui/menubar.d.ts.map +1 -1
  126. package/dist/components/ui/menubar.js +73 -93
  127. package/dist/components/ui/menubar.js.map +1 -1
  128. package/dist/components/ui/navigation-menu.d.ts +8 -10
  129. package/dist/components/ui/navigation-menu.d.ts.map +1 -1
  130. package/dist/components/ui/navigation-menu.js +36 -55
  131. package/dist/components/ui/navigation-menu.js.map +1 -1
  132. package/dist/components/ui/pagination.d.ts +24 -9
  133. package/dist/components/ui/pagination.d.ts.map +1 -1
  134. package/dist/components/ui/pagination.js +33 -45
  135. package/dist/components/ui/pagination.js.map +1 -1
  136. package/dist/components/ui/popover.d.ts +4 -4
  137. package/dist/components/ui/popover.d.ts.map +1 -1
  138. package/dist/components/ui/popover.js +9 -25
  139. package/dist/components/ui/popover.js.map +1 -1
  140. package/dist/components/ui/progress.d.ts +1 -1
  141. package/dist/components/ui/progress.d.ts.map +1 -1
  142. package/dist/components/ui/progress.js +5 -7
  143. package/dist/components/ui/progress.js.map +1 -1
  144. package/dist/components/ui/radio-group.d.ts +2 -2
  145. package/dist/components/ui/radio-group.d.ts.map +1 -1
  146. package/dist/components/ui/radio-group.js +16 -19
  147. package/dist/components/ui/radio-group.js.map +1 -1
  148. package/dist/components/ui/resizable.d.ts +20 -4
  149. package/dist/components/ui/resizable.d.ts.map +1 -1
  150. package/dist/components/ui/resizable.js +8 -19
  151. package/dist/components/ui/resizable.js.map +1 -1
  152. package/dist/components/ui/scroll-area.d.ts +2 -2
  153. package/dist/components/ui/scroll-area.d.ts.map +1 -1
  154. package/dist/components/ui/scroll-area.js +12 -16
  155. package/dist/components/ui/scroll-area.js.map +1 -1
  156. package/dist/components/ui/select.d.ts +10 -12
  157. package/dist/components/ui/select.d.ts.map +1 -1
  158. package/dist/components/ui/select.js +54 -77
  159. package/dist/components/ui/select.js.map +1 -1
  160. package/dist/components/ui/separator.d.ts +1 -1
  161. package/dist/components/ui/separator.d.ts.map +1 -1
  162. package/dist/components/ui/separator.js +6 -7
  163. package/dist/components/ui/separator.js.map +1 -1
  164. package/dist/components/ui/sheet.d.ts +23 -11
  165. package/dist/components/ui/sheet.d.ts.map +1 -1
  166. package/dist/components/ui/sheet.js +54 -66
  167. package/dist/components/ui/sheet.js.map +1 -1
  168. package/dist/components/ui/sidebar.d.ts +34 -38
  169. package/dist/components/ui/sidebar.d.ts.map +1 -1
  170. package/dist/components/ui/sidebar.js +116 -124
  171. package/dist/components/ui/sidebar.js.map +1 -1
  172. package/dist/components/ui/skeleton.d.ts +1 -1
  173. package/dist/components/ui/skeleton.d.ts.map +1 -1
  174. package/dist/components/ui/skeleton.js +1 -2
  175. package/dist/components/ui/skeleton.js.map +1 -1
  176. package/dist/components/ui/slider.d.ts +1 -1
  177. package/dist/components/ui/slider.d.ts.map +1 -1
  178. package/dist/components/ui/slider.js +11 -30
  179. package/dist/components/ui/slider.js.map +1 -1
  180. package/dist/components/ui/sonner.d.ts +4 -2
  181. package/dist/components/ui/sonner.d.ts.map +1 -1
  182. package/dist/components/ui/sonner.js +7 -4
  183. package/dist/components/ui/sonner.js.map +1 -1
  184. package/dist/components/ui/spinner.d.ts +4 -0
  185. package/dist/components/ui/spinner.d.ts.map +1 -0
  186. package/dist/components/ui/spinner.js +16 -0
  187. package/dist/components/ui/spinner.js.map +1 -0
  188. package/dist/components/ui/switch.d.ts +2 -2
  189. package/dist/components/ui/switch.d.ts.map +1 -1
  190. package/dist/components/ui/switch.js +7 -9
  191. package/dist/components/ui/switch.js.map +1 -1
  192. package/dist/components/ui/table.d.ts +8 -8
  193. package/dist/components/ui/table.d.ts.map +1 -1
  194. package/dist/components/ui/table.js +36 -45
  195. package/dist/components/ui/table.js.map +1 -1
  196. package/dist/components/ui/tabs.d.ts +4 -4
  197. package/dist/components/ui/tabs.d.ts.map +1 -1
  198. package/dist/components/ui/tabs.js +17 -26
  199. package/dist/components/ui/tabs.js.map +1 -1
  200. package/dist/components/ui/textarea.d.ts +1 -1
  201. package/dist/components/ui/textarea.d.ts.map +1 -1
  202. package/dist/components/ui/textarea.js +6 -7
  203. package/dist/components/ui/textarea.js.map +1 -1
  204. package/dist/components/ui/toggle-group.d.ts +8 -3
  205. package/dist/components/ui/toggle-group.d.ts.map +1 -1
  206. package/dist/components/ui/toggle-group.js +11 -15
  207. package/dist/components/ui/toggle-group.js.map +1 -1
  208. package/dist/components/ui/toggle.d.ts +4 -1
  209. package/dist/components/ui/toggle.d.ts.map +1 -1
  210. package/dist/components/ui/toggle.js +7 -8
  211. package/dist/components/ui/toggle.js.map +1 -1
  212. package/dist/components/ui/tooltip.d.ts +4 -4
  213. package/dist/components/ui/tooltip.d.ts.map +1 -1
  214. package/dist/components/ui/tooltip.js +13 -38
  215. package/dist/components/ui/tooltip.js.map +1 -1
  216. package/dist/components/ui/typewriter.d.ts.map +1 -1
  217. package/dist/components/ui/typewriter.js +2 -6
  218. package/dist/components/ui/typewriter.js.map +1 -1
  219. package/dist/index.css +839 -1126
  220. package/dist/index.css.map +1 -1
  221. package/dist/index.d.ts +9 -3
  222. package/dist/index.d.ts.map +1 -1
  223. package/dist/index.js +9 -3
  224. package/package.json +37 -2
  225. package/src/components/ui/accordion.tsx +43 -44
  226. package/src/components/ui/alert-dialog.tsx +88 -99
  227. package/src/components/ui/alert.tsx +24 -25
  228. package/src/components/ui/aspect-ratio.tsx +1 -9
  229. package/src/components/ui/avatar.tsx +33 -27
  230. package/src/components/ui/badge.tsx +8 -16
  231. package/src/components/ui/breadcrumb.tsx +70 -73
  232. package/src/components/ui/button-group.tsx +69 -0
  233. package/src/components/ui/button.tsx +18 -24
  234. package/src/components/ui/calendar.tsx +20 -20
  235. package/src/components/ui/card.tsx +52 -71
  236. package/src/components/ui/carousel.tsx +145 -133
  237. package/src/components/ui/chart.tsx +174 -182
  238. package/src/components/ui/checkbox.tsx +18 -18
  239. package/src/components/ui/collapsible.tsx +2 -26
  240. package/src/components/ui/command.tsx +101 -99
  241. package/src/components/ui/context-menu.tsx +150 -193
  242. package/src/components/ui/dialog.tsx +75 -110
  243. package/src/components/ui/drawer.tsx +74 -102
  244. package/src/components/ui/dropdown-menu.tsx +153 -200
  245. package/src/components/ui/dropdrawer.tsx +0 -5
  246. package/src/components/ui/empty.tsx +86 -0
  247. package/src/components/ui/field.tsx +199 -0
  248. package/src/components/ui/form.tsx +49 -50
  249. package/src/components/ui/hover-card.tsx +18 -37
  250. package/src/components/ui/input-group.tsx +145 -0
  251. package/src/components/ui/input-otp.tsx +49 -59
  252. package/src/components/ui/input.tsx +5 -6
  253. package/src/components/ui/item.tsx +163 -0
  254. package/src/components/ui/kbd.tsx +31 -0
  255. package/src/components/ui/label.tsx +14 -12
  256. package/src/components/ui/menubar.tsx +178 -201
  257. package/src/components/ui/navigation-menu.tsx +84 -100
  258. package/src/components/ui/pagination.tsx +75 -85
  259. package/src/components/ui/popover.tsx +19 -38
  260. package/src/components/ui/progress.tsx +15 -14
  261. package/src/components/ui/radio-group.tsx +19 -13
  262. package/src/components/ui/resizable.tsx +23 -36
  263. package/src/components/ui/scroll-area.tsx +32 -35
  264. package/src/components/ui/select.tsx +112 -127
  265. package/src/components/ui/separator.tsx +17 -19
  266. package/src/components/ui/sheet.tsx +87 -108
  267. package/src/components/ui/sidebar.tsx +276 -279
  268. package/src/components/ui/skeleton.tsx +2 -3
  269. package/src/components/ui/slider.tsx +15 -40
  270. package/src/components/ui/sonner.tsx +15 -9
  271. package/src/components/ui/spinner.tsx +18 -0
  272. package/src/components/ui/switch.tsx +18 -17
  273. package/src/components/ui/table.tsx +66 -71
  274. package/src/components/ui/tabs.tsx +36 -36
  275. package/src/components/ui/textarea.tsx +5 -4
  276. package/src/components/ui/toggle-group.tsx +21 -34
  277. package/src/components/ui/toggle.tsx +14 -16
  278. package/src/components/ui/tooltip.tsx +19 -43
  279. package/src/components/ui/typewriter.tsx +3 -4
  280. package/src/index.css +6 -6
  281. package/src/index.ts +43 -4
@@ -5,11 +5,6 @@
5
5
  import * as React from "react";
6
6
  import * as RechartsPrimitive from "recharts";
7
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
8
  import {cn} from "@/lib/utilities";
14
9
 
15
10
  // Format: { THEME_NAME: CSS_SELECTOR }
@@ -26,36 +21,6 @@ type ChartContextProps = {
26
21
  config: ChartConfig;
27
22
  };
28
23
 
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
24
  const ChartContext = React.createContext<ChartContextProps | null>(null);
60
25
 
61
26
  function useChart() {
@@ -68,26 +33,23 @@ function useChart() {
68
33
  return context;
69
34
  }
70
35
 
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
- }) {
36
+ const ChartContainer = React.forwardRef<
37
+ HTMLDivElement,
38
+ React.ComponentProps<"div"> & {
39
+ config: ChartConfig;
40
+ children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
41
+ }
42
+ >(({id, className, children, config, ...props}, ref) => {
81
43
  const uniqueId = React.useId();
82
44
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
83
45
 
84
46
  return (
85
47
  <ChartContext.Provider value={{config}}>
86
48
  <div
87
- data-slot='chart'
88
49
  data-chart={chartId}
50
+ ref={ref}
89
51
  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",
52
+ "[&_.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-none [&_.recharts-sector]:outline-none [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-none",
91
53
  className,
92
54
  )}
93
55
  {...props}>
@@ -99,7 +61,8 @@ function ChartContainer({
99
61
  </div>
100
62
  </ChartContext.Provider>
101
63
  );
102
- }
64
+ });
65
+ ChartContainer.displayName = "Chart";
103
66
 
104
67
  const ChartStyle = ({id, config}: {id: string; config: ChartConfig}) => {
105
68
  const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
@@ -114,17 +77,17 @@ const ChartStyle = ({id, config}: {id: string; config: ChartConfig}) => {
114
77
  __html: Object.entries(THEMES)
115
78
  .map(
116
79
  ([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
- `,
80
+ ${prefix} [data-chart=${id}] {
81
+ ${colorConfig
82
+ .map(([key, itemConfig]) => {
83
+ const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] || itemConfig.color;
84
+ return color ? ` --color-${key}: ${color};` : null;
85
+ })
86
+ .join("")}
87
+ }
88
+ `,
126
89
  )
127
- .join("\n"),
90
+ .join(""),
128
91
  }}
129
92
  />
130
93
  );
@@ -132,158 +95,187 @@ const ChartStyle = ({id, config}: {id: string; config: ChartConfig}) => {
132
95
 
133
96
  const ChartTooltip = RechartsPrimitive.Tooltip;
134
97
 
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) {
98
+ const ChartTooltipContent = React.forwardRef<
99
+ HTMLDivElement,
100
+ React.ComponentProps<typeof RechartsPrimitive.Tooltip>
101
+ & React.ComponentProps<"div"> & {
102
+ hideLabel?: boolean;
103
+ hideIndicator?: boolean;
104
+ indicator?: "line" | "dot" | "dashed";
105
+ nameKey?: string;
106
+ labelKey?: string;
107
+ }
108
+ >(
109
+ (
110
+ {
111
+ active,
112
+ payload,
113
+ className,
114
+ indicator = "dot",
115
+ hideLabel = false,
116
+ hideIndicator = false,
117
+ label,
118
+ labelFormatter,
119
+ labelClassName,
120
+ formatter,
121
+ color,
122
+ nameKey,
123
+ labelKey,
124
+ },
125
+ ref,
126
+ ) => {
127
+ const {config} = useChart();
128
+
129
+ const tooltipLabel = React.useMemo(() => {
130
+ if (hideLabel || !payload?.length) {
131
+ return null;
132
+ }
133
+
134
+ const [item] = payload;
135
+ const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
136
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
137
+ const value = !labelKey && typeof label === "string" ? config[label as keyof typeof config]?.label || label : itemConfig?.label;
138
+
139
+ if (labelFormatter) {
140
+ return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
141
+ }
142
+
143
+ if (!value) {
144
+ return null;
145
+ }
146
+
147
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
148
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
149
+
150
+ if (!active || !payload?.length) {
154
151
  return null;
155
152
  }
156
153
 
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;
154
+ const nestLabel = payload.length === 1 && indicator !== "dot";
162
155
 
163
- return typeof v === "string" || typeof v === "number" ? v : undefined;
164
- })();
156
+ return (
157
+ <div
158
+ ref={ref}
159
+ className={cn(
160
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-neutral-200 border-neutral-200/50 bg-white px-2.5 py-1.5 text-xs shadow-xl dark:border-neutral-800 dark:border-neutral-800/50 dark:bg-neutral-950",
161
+ className,
162
+ )}>
163
+ {!nestLabel ? tooltipLabel : null}
164
+ <div className='grid gap-1.5'>
165
+ {payload
166
+ .filter((item) => item.type !== "none")
167
+ .map((item, index) => {
168
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
169
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
170
+ const indicatorColor = color || item.payload.fill || item.color;
171
+
172
+ return (
173
+ <div
174
+ key={item.dataKey}
175
+ className={cn(
176
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-neutral-500 dark:[&>svg]:text-neutral-400",
177
+ indicator === "dot" && "items-center",
178
+ )}>
179
+ {formatter && item?.value !== undefined && item.name ? (
180
+ formatter(item.value, item.name, item, index, item.payload)
181
+ ) : (
182
+ <>
183
+ {itemConfig?.icon ? (
184
+ <itemConfig.icon />
185
+ ) : (
186
+ !hideIndicator && (
187
+ <div
188
+ className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
189
+ "h-2.5 w-2.5": indicator === "dot",
190
+ "w-1": indicator === "line",
191
+ "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
192
+ "my-0.5": nestLabel && indicator === "dashed",
193
+ })}
194
+ style={
195
+ {
196
+ "--color-bg": indicatorColor,
197
+ "--color-border": indicatorColor,
198
+ } as React.CSSProperties
199
+ }
200
+ />
201
+ )
202
+ )}
203
+ <div className={cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center")}>
204
+ <div className='grid gap-1.5'>
205
+ {nestLabel ? tooltipLabel : null}
206
+ <span className='text-neutral-500 dark:text-neutral-400'>{itemConfig?.label || item.name}</span>
207
+ </div>
208
+ {item.value && (
209
+ <span className='font-mono font-medium text-neutral-950 tabular-nums dark:text-neutral-50'>
210
+ {item.value.toLocaleString()}
211
+ </span>
212
+ )}
213
+ </div>
214
+ </>
215
+ )}
216
+ </div>
217
+ );
218
+ })}
219
+ </div>
220
+ </div>
221
+ );
222
+ },
223
+ );
224
+ ChartTooltipContent.displayName = "ChartTooltip";
165
225
 
166
- if (labelFormatter) {
167
- return <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>;
168
- }
226
+ const ChartLegend = RechartsPrimitive.Legend;
169
227
 
170
- if (!value) {
171
- return null;
228
+ const ChartLegendContent = React.forwardRef<
229
+ HTMLDivElement,
230
+ React.ComponentProps<"div">
231
+ & Pick<RechartsPrimitive.LegendProps, "payload" | "verticalAlign"> & {
232
+ hideIcon?: boolean;
233
+ nameKey?: string;
172
234
  }
235
+ >(({className, hideIcon = false, payload, verticalAlign = "bottom", nameKey}, ref) => {
236
+ const {config} = useChart();
173
237
 
174
- return <div className={cn("font-medium", labelClassName)}>{value}</div>;
175
- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
176
-
177
- if (!active || !payload?.length) {
238
+ if (!payload?.length) {
178
239
  return null;
179
240
  }
180
241
 
181
- const nestLabel = payload.length === 1 && indicator !== "dot";
182
-
183
242
  return (
184
243
  <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"}`;
244
+ ref={ref}
245
+ className={cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className)}>
246
+ {payload
247
+ .filter((item) => item.type !== "none")
248
+ .map((item) => {
249
+ const key = `${nameKey || item.dataKey || "value"}`;
193
250
  const itemConfig = getPayloadConfigFromPayload(config, item, key);
194
- const indicatorColor = color || item.payload.fill || item.color;
195
251
 
196
252
  return (
197
253
  <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)
254
+ key={item.value}
255
+ className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-neutral-500 dark:[&>svg]:text-neutral-400")}>
256
+ {itemConfig?.icon && !hideIcon ? (
257
+ <itemConfig.icon />
205
258
  ) : (
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
- </>
259
+ <div
260
+ className='h-2 w-2 shrink-0 rounded-[2px]'
261
+ style={{
262
+ backgroundColor: item.color,
263
+ }}
264
+ />
237
265
  )}
266
+ {itemConfig?.label}
238
267
  </div>
239
268
  );
240
269
  })}
241
- </div>
242
270
  </div>
243
271
  );
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
- }
272
+ });
273
+ ChartLegendContent.displayName = "ChartLegend";
282
274
 
283
275
  // Helper to extract item config from a payload.
284
276
  function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
285
277
  if (typeof payload !== "object" || payload === null) {
286
- return undefined;
278
+ return;
287
279
  }
288
280
 
289
281
  const payloadPayload =
@@ -1,27 +1,27 @@
1
1
  "use client";
2
2
 
3
3
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
4
- import {CheckIcon} from "lucide-react";
4
+ import {Check} from "lucide-react";
5
5
  import * as React from "react";
6
6
 
7
7
  import {cn} from "@/lib/utilities";
8
8
 
9
- function Checkbox({className, ...props}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
10
- return (
11
- <CheckboxPrimitive.Root
12
- data-slot='checkbox'
13
- className={cn(
14
- "peer size-4 shrink-0 rounded-[4px] border border-neutral-200 shadow-xs transition-shadow outline-none focus-visible:border-neutral-950 focus-visible:ring-[3px] focus-visible:ring-neutral-950/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-red-500 aria-invalid:ring-red-500/20 data-[state=checked]:border-neutral-900 data-[state=checked]:bg-neutral-900 data-[state=checked]:text-neutral-50 dark:border-neutral-800 dark:bg-neutral-200/30 dark:dark:bg-neutral-800/30 dark:focus-visible:border-neutral-300 dark:focus-visible:ring-neutral-300/50 dark:aria-invalid:border-red-900 dark:aria-invalid:ring-red-500/40 dark:aria-invalid:ring-red-900/20 dark:dark:aria-invalid:ring-red-900/40 dark:data-[state=checked]:border-neutral-50 dark:dark:data-[state=checked]:bg-neutral-50 dark:data-[state=checked]:bg-neutral-50 dark:data-[state=checked]:bg-neutral-900 dark:data-[state=checked]:text-neutral-900",
15
- className,
16
- )}
17
- {...props}>
18
- <CheckboxPrimitive.Indicator
19
- data-slot='checkbox-indicator'
20
- className='flex items-center justify-center text-current transition-none'>
21
- <CheckIcon className='size-3.5' />
22
- </CheckboxPrimitive.Indicator>
23
- </CheckboxPrimitive.Root>
24
- );
25
- }
9
+ const Checkbox = React.forwardRef<
10
+ React.ComponentRef<typeof CheckboxPrimitive.Root>,
11
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
12
+ >(({className, ...props}, ref) => (
13
+ <CheckboxPrimitive.Root
14
+ ref={ref}
15
+ className={cn(
16
+ "peer h-4 w-4 shrink-0 rounded-sm border border-neutral-200 border-neutral-900 shadow focus-visible:ring-1 focus-visible:ring-neutral-950 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-neutral-900 data-[state=checked]:text-neutral-50 dark:border-neutral-50 dark:border-neutral-800 dark:focus-visible:ring-neutral-300 dark:data-[state=checked]:bg-neutral-50 dark:data-[state=checked]:text-neutral-900",
17
+ className,
18
+ )}
19
+ {...props}>
20
+ <CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}>
21
+ <Check className='h-4 w-4' />
22
+ </CheckboxPrimitive.Indicator>
23
+ </CheckboxPrimitive.Root>
24
+ ));
25
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
26
26
 
27
27
  export {Checkbox};
@@ -1,33 +1,9 @@
1
1
  "use client";
2
2
 
3
3
  import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
4
- import * as React from "react";
5
4
 
6
- function Collapsible({...props}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
7
- return (
8
- <CollapsiblePrimitive.Root
9
- data-slot='collapsible'
10
- {...props}
11
- />
12
- );
13
- }
5
+ const Collapsible = CollapsiblePrimitive.Root;
14
6
 
15
- function CollapsibleTrigger({...props}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
16
- return (
17
- <CollapsiblePrimitive.CollapsibleTrigger
18
- data-slot='collapsible-trigger'
19
- {...props}
20
- />
21
- );
22
- }
23
-
24
- function CollapsibleContent({...props}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25
- return (
26
- <CollapsiblePrimitive.CollapsibleContent
27
- data-slot='collapsible-content'
28
- {...props}
29
- />
30
- );
31
- }
7
+ const {CollapsibleTrigger, CollapsibleContent} = CollapsiblePrimitive;
32
8
 
33
9
  export {Collapsible, CollapsibleContent, CollapsibleTrigger};