@aereamart/design-system 0.3.6 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/dist/cn.d.ts +2 -1
  2. package/dist/cn.js +4 -2
  3. package/dist/hooks/use-mobile.d.ts +1 -0
  4. package/dist/hooks/use-mobile.js +15 -0
  5. package/dist/index.d.ts +48 -37
  6. package/dist/index.js +48 -37
  7. package/dist/ui/accordion.d.ts +7 -0
  8. package/dist/ui/accordion.js +17 -0
  9. package/dist/ui/alert-dialog.d.ts +18 -0
  10. package/dist/ui/alert-dialog.js +42 -0
  11. package/dist/ui/alert.d.ts +9 -0
  12. package/dist/ui/alert.js +24 -0
  13. package/dist/ui/aspect-ratio.d.ts +3 -0
  14. package/dist/ui/aspect-ratio.js +6 -0
  15. package/dist/ui/avatar.d.ts +11 -0
  16. package/dist/ui/avatar.js +23 -0
  17. package/dist/ui/badge.d.ts +9 -0
  18. package/dist/ui/badge.js +24 -0
  19. package/dist/ui/breadcrumb.d.ts +11 -0
  20. package/dist/ui/breadcrumb.js +27 -0
  21. package/dist/ui/button.d.ts +10 -0
  22. package/dist/ui/button.js +35 -0
  23. package/dist/ui/calendar.d.ts +8 -0
  24. package/dist/ui/calendar.js +75 -0
  25. package/dist/ui/card.d.ts +9 -0
  26. package/dist/ui/card.js +24 -0
  27. package/dist/ui/carousel.d.ts +19 -0
  28. package/dist/ui/carousel.js +91 -0
  29. package/dist/ui/chart.d.ts +44 -0
  30. package/dist/ui/chart.js +132 -0
  31. package/dist/ui/checkbox.d.ts +4 -0
  32. package/dist/ui/checkbox.js +8 -0
  33. package/dist/ui/collapsible.d.ts +5 -0
  34. package/dist/ui/collapsible.js +13 -0
  35. package/dist/ui/command.d.ts +18 -0
  36. package/dist/ui/command.js +34 -0
  37. package/dist/ui/context-menu.d.ts +25 -0
  38. package/dist/ui/context-menu.js +51 -0
  39. package/dist/ui/dialog.d.ts +17 -0
  40. package/dist/ui/dialog.js +36 -0
  41. package/dist/ui/drawer.d.ts +13 -0
  42. package/dist/ui/drawer.js +35 -0
  43. package/dist/ui/dropdown-menu.d.ts +25 -0
  44. package/dist/ui/dropdown-menu.js +50 -0
  45. package/dist/ui/form.d.ts +24 -0
  46. package/dist/ui/form.js +58 -0
  47. package/dist/ui/hover-card.d.ts +6 -0
  48. package/dist/ui/hover-card.js +13 -0
  49. package/dist/ui/input-otp.d.ts +11 -0
  50. package/dist/ui/input-otp.js +21 -0
  51. package/dist/ui/input.d.ts +3 -0
  52. package/dist/ui/input.js +6 -0
  53. package/dist/ui/label.d.ts +4 -0
  54. package/dist/ui/label.js +8 -0
  55. package/dist/ui/menubar.d.ts +26 -0
  56. package/dist/ui/menubar.js +53 -0
  57. package/dist/ui/navigation-menu.d.ts +14 -0
  58. package/dist/ui/navigation-menu.js +31 -0
  59. package/dist/ui/pagination.d.ts +13 -0
  60. package/dist/ui/pagination.js +29 -0
  61. package/dist/ui/popover.d.ts +10 -0
  62. package/dist/ui/popover.js +26 -0
  63. package/dist/ui/progress.d.ts +4 -0
  64. package/dist/ui/progress.js +7 -0
  65. package/dist/ui/radio-group.d.ts +5 -0
  66. package/dist/ui/radio-group.js +12 -0
  67. package/dist/ui/resizable.d.ts +7 -0
  68. package/dist/ui/resizable.js +14 -0
  69. package/dist/ui/scroll-area.d.ts +5 -0
  70. package/dist/ui/scroll-area.js +12 -0
  71. package/dist/ui/select.d.ts +15 -0
  72. package/dist/ui/select.js +38 -0
  73. package/dist/ui/separator.d.ts +4 -0
  74. package/dist/ui/separator.js +7 -0
  75. package/dist/ui/sheet.d.ts +14 -0
  76. package/dist/ui/sheet.js +40 -0
  77. package/dist/ui/sidebar.d.ts +69 -0
  78. package/dist/ui/sidebar.js +211 -0
  79. package/dist/ui/skeleton.d.ts +2 -0
  80. package/dist/ui/skeleton.js +6 -0
  81. package/dist/ui/slider.d.ts +4 -0
  82. package/dist/ui/slider.js +13 -0
  83. package/dist/ui/sonner.d.ts +3 -0
  84. package/dist/ui/sonner.js +21 -0
  85. package/dist/ui/switch.d.ts +6 -0
  86. package/dist/ui/switch.js +7 -0
  87. package/dist/ui/table.d.ts +10 -0
  88. package/dist/ui/table.js +28 -0
  89. package/dist/ui/tabs.d.ts +11 -0
  90. package/dist/ui/tabs.js +28 -0
  91. package/dist/ui/textarea.d.ts +3 -0
  92. package/dist/ui/textarea.js +6 -0
  93. package/dist/ui/toggle-group.d.ts +9 -0
  94. package/dist/ui/toggle-group.js +22 -0
  95. package/dist/ui/toggle.d.ts +9 -0
  96. package/dist/ui/toggle.js +26 -0
  97. package/dist/ui/tooltip.d.ts +7 -0
  98. package/dist/ui/tooltip.js +16 -0
  99. package/package.json +28 -4
  100. package/src/cn.ts +5 -2
  101. package/src/hooks/use-mobile.ts +19 -0
  102. package/src/index.css +158 -0
  103. package/src/index.ts +48 -37
  104. package/src/ui/accordion.tsx +63 -0
  105. package/src/ui/alert-dialog.tsx +196 -0
  106. package/src/ui/alert.tsx +65 -0
  107. package/src/ui/aspect-ratio.tsx +9 -0
  108. package/src/ui/avatar.tsx +108 -0
  109. package/src/ui/badge.tsx +47 -0
  110. package/src/ui/breadcrumb.tsx +108 -0
  111. package/src/ui/button.tsx +63 -0
  112. package/src/ui/calendar.tsx +218 -0
  113. package/src/ui/card.tsx +91 -0
  114. package/src/ui/carousel.tsx +241 -0
  115. package/src/ui/chart.tsx +371 -0
  116. package/src/ui/checkbox.tsx +29 -0
  117. package/src/ui/collapsible.tsx +33 -0
  118. package/src/ui/command.tsx +184 -0
  119. package/src/ui/context-menu.tsx +251 -0
  120. package/src/ui/dialog.tsx +156 -0
  121. package/src/ui/drawer.tsx +134 -0
  122. package/src/ui/dropdown-menu.tsx +254 -0
  123. package/src/ui/form.tsx +165 -0
  124. package/src/ui/hover-card.tsx +41 -0
  125. package/src/ui/input-otp.tsx +76 -0
  126. package/src/ui/input.tsx +20 -0
  127. package/src/ui/label.tsx +23 -0
  128. package/src/ui/menubar.tsx +273 -0
  129. package/src/ui/navigation-menu.tsx +167 -0
  130. package/src/ui/pagination.tsx +127 -0
  131. package/src/ui/popover.tsx +88 -0
  132. package/src/ui/progress.tsx +28 -0
  133. package/src/ui/radio-group.tsx +44 -0
  134. package/src/ui/resizable.tsx +50 -0
  135. package/src/ui/scroll-area.tsx +55 -0
  136. package/src/ui/select.tsx +189 -0
  137. package/src/ui/separator.tsx +25 -0
  138. package/src/ui/sheet.tsx +142 -0
  139. package/src/ui/sidebar.tsx +724 -0
  140. package/src/ui/skeleton.tsx +13 -0
  141. package/src/ui/slider.tsx +60 -0
  142. package/src/ui/sonner.tsx +40 -0
  143. package/src/ui/switch.tsx +32 -0
  144. package/src/ui/table.tsx +115 -0
  145. package/src/ui/tabs.tsx +88 -0
  146. package/src/ui/textarea.tsx +17 -0
  147. package/src/ui/toggle-group.tsx +83 -0
  148. package/src/ui/toggle.tsx +46 -0
  149. package/src/ui/tooltip.tsx +54 -0
  150. package/dist/Accordion.d.ts +0 -10
  151. package/dist/Accordion.js +0 -12
  152. package/dist/AlertBanner.d.ts +0 -9
  153. package/dist/AlertBanner.js +0 -21
  154. package/dist/AppBar.d.ts +0 -7
  155. package/dist/AppBar.js +0 -5
  156. package/dist/Avatar.d.ts +0 -6
  157. package/dist/Avatar.js +0 -20
  158. package/dist/Badge.d.ts +0 -6
  159. package/dist/Badge.js +0 -11
  160. package/dist/BottomSheet.d.ts +0 -8
  161. package/dist/BottomSheet.js +0 -24
  162. package/dist/Breadcrumb.d.ts +0 -8
  163. package/dist/Breadcrumb.js +0 -9
  164. package/dist/Button.d.ts +0 -9
  165. package/dist/Button.js +0 -18
  166. package/dist/Card.d.ts +0 -7
  167. package/dist/Card.js +0 -6
  168. package/dist/Checkbox.d.ts +0 -5
  169. package/dist/Checkbox.js +0 -5
  170. package/dist/Chip.d.ts +0 -7
  171. package/dist/Chip.js +0 -15
  172. package/dist/DataTable.d.ts +0 -15
  173. package/dist/DataTable.js +0 -7
  174. package/dist/DatePicker.d.ts +0 -5
  175. package/dist/DatePicker.js +0 -11
  176. package/dist/Divider.d.ts +0 -5
  177. package/dist/Divider.js +0 -11
  178. package/dist/Drawer.d.ts +0 -10
  179. package/dist/Drawer.js +0 -24
  180. package/dist/EmptyState.d.ts +0 -7
  181. package/dist/EmptyState.js +0 -6
  182. package/dist/Input.d.ts +0 -5
  183. package/dist/Input.js +0 -7
  184. package/dist/Link.d.ts +0 -4
  185. package/dist/Link.js +0 -6
  186. package/dist/Menu.d.ts +0 -14
  187. package/dist/Menu.js +0 -29
  188. package/dist/Modal.d.ts +0 -9
  189. package/dist/Modal.js +0 -24
  190. package/dist/NavigationBar.d.ts +0 -14
  191. package/dist/NavigationBar.js +0 -22
  192. package/dist/Pagination.d.ts +0 -7
  193. package/dist/Pagination.js +0 -24
  194. package/dist/Popover.d.ts +0 -7
  195. package/dist/Popover.js +0 -9
  196. package/dist/Progress.d.ts +0 -8
  197. package/dist/Progress.js +0 -15
  198. package/dist/Radio.d.ts +0 -15
  199. package/dist/Radio.js +0 -8
  200. package/dist/SegmentedControl.d.ts +0 -13
  201. package/dist/SegmentedControl.js +0 -18
  202. package/dist/Select.d.ts +0 -5
  203. package/dist/Select.js +0 -7
  204. package/dist/Sidebar.d.ts +0 -16
  205. package/dist/Sidebar.js +0 -19
  206. package/dist/Slider.d.ts +0 -5
  207. package/dist/Slider.js +0 -5
  208. package/dist/Snackbar.d.ts +0 -12
  209. package/dist/Snackbar.js +0 -20
  210. package/dist/Spinner.d.ts +0 -3
  211. package/dist/Spinner.js +0 -5
  212. package/dist/Switch.d.ts +0 -4
  213. package/dist/Switch.js +0 -5
  214. package/dist/Tabs.d.ts +0 -14
  215. package/dist/Tabs.js +0 -24
  216. package/dist/Tag.d.ts +0 -6
  217. package/dist/Tag.js +0 -11
  218. package/dist/Textarea.d.ts +0 -5
  219. package/dist/Textarea.js +0 -7
  220. package/dist/Tooltip.d.ts +0 -7
  221. package/dist/Tooltip.js +0 -5
  222. package/dist/TreeView.d.ts +0 -12
  223. package/dist/TreeView.js +0 -34
  224. package/src/Accordion.tsx +0 -58
  225. package/src/AlertBanner.tsx +0 -62
  226. package/src/AppBar.tsx +0 -29
  227. package/src/Avatar.tsx +0 -42
  228. package/src/Badge.tsx +0 -27
  229. package/src/BottomSheet.tsx +0 -60
  230. package/src/Breadcrumb.tsx +0 -48
  231. package/src/Button.tsx +0 -54
  232. package/src/Card.tsx +0 -39
  233. package/src/Checkbox.tsx +0 -31
  234. package/src/Chip.tsx +0 -44
  235. package/src/DataTable.tsx +0 -64
  236. package/src/DatePicker.tsx +0 -44
  237. package/src/Divider.tsx +0 -33
  238. package/src/Drawer.tsx +0 -71
  239. package/src/EmptyState.tsx +0 -37
  240. package/src/Input.tsx +0 -30
  241. package/src/Link.tsx +0 -22
  242. package/src/Menu.tsx +0 -73
  243. package/src/Modal.tsx +0 -62
  244. package/src/NavigationBar.tsx +0 -68
  245. package/src/Pagination.tsx +0 -69
  246. package/src/Popover.tsx +0 -34
  247. package/src/Progress.tsx +0 -53
  248. package/src/Radio.tsx +0 -49
  249. package/src/SegmentedControl.tsx +0 -63
  250. package/src/Select.tsx +0 -32
  251. package/src/Sidebar.tsx +0 -73
  252. package/src/Slider.tsx +0 -33
  253. package/src/Snackbar.tsx +0 -72
  254. package/src/Spinner.tsx +0 -19
  255. package/src/Switch.tsx +0 -40
  256. package/src/Tabs.tsx +0 -77
  257. package/src/Tag.tsx +0 -29
  258. package/src/Textarea.tsx +0 -30
  259. package/src/Tooltip.tsx +0 -25
  260. package/src/TreeView.tsx +0 -105
@@ -0,0 +1,371 @@
1
+ import * as React from "react"
2
+ import { cn } from "../cn"
3
+ import * as RechartsPrimitive from "recharts"
4
+ import type { TooltipValueType } from "recharts"
5
+
6
+ // Format: { THEME_NAME: CSS_SELECTOR }
7
+ const THEMES = { light: "", dark: ".dark" } as const
8
+
9
+ const INITIAL_DIMENSION = { width: 320, height: 200 } as const
10
+ type TooltipNameType = number | string
11
+
12
+ export type ChartConfig = Record<
13
+ string,
14
+ {
15
+ label?: React.ReactNode
16
+ icon?: React.ComponentType
17
+ } & (
18
+ | { color?: string; theme?: never }
19
+ | { color?: never; theme: Record<keyof typeof THEMES, string> }
20
+ )
21
+ >
22
+
23
+ type ChartContextProps = {
24
+ config: ChartConfig
25
+ }
26
+
27
+ const ChartContext = React.createContext<ChartContextProps | null>(null)
28
+
29
+ function useChart() {
30
+ const context = React.useContext(ChartContext)
31
+
32
+ if (!context) {
33
+ throw new Error("useChart must be used within a <ChartContainer />")
34
+ }
35
+
36
+ return context
37
+ }
38
+
39
+ function ChartContainer({
40
+ id,
41
+ className,
42
+ children,
43
+ config,
44
+ initialDimension = INITIAL_DIMENSION,
45
+ ...props
46
+ }: React.ComponentProps<"div"> & {
47
+ config: ChartConfig
48
+ children: React.ComponentProps<
49
+ typeof RechartsPrimitive.ResponsiveContainer
50
+ >["children"]
51
+ initialDimension?: {
52
+ width: number
53
+ height: number
54
+ }
55
+ }) {
56
+ const uniqueId = React.useId()
57
+ const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`
58
+
59
+ return (
60
+ <ChartContext.Provider value={{ config }}>
61
+ <div
62
+ data-slot="chart"
63
+ data-chart={chartId}
64
+ className={cn(
65
+ "flex aspect-video justify-center text-xs [&_.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-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.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 [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
66
+ className
67
+ )}
68
+ {...props}
69
+ >
70
+ <ChartStyle id={chartId} config={config} />
71
+ <RechartsPrimitive.ResponsiveContainer
72
+ initialDimension={initialDimension}
73
+ >
74
+ {children}
75
+ </RechartsPrimitive.ResponsiveContainer>
76
+ </div>
77
+ </ChartContext.Provider>
78
+ )
79
+ }
80
+
81
+ const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
82
+ const colorConfig = Object.entries(config).filter(
83
+ ([, config]) => config.theme ?? config.color
84
+ )
85
+
86
+ if (!colorConfig.length) {
87
+ return null
88
+ }
89
+
90
+ return (
91
+ <style
92
+ dangerouslySetInnerHTML={{
93
+ __html: Object.entries(THEMES)
94
+ .map(
95
+ ([theme, prefix]) => `
96
+ ${prefix} [data-chart=${id}] {
97
+ ${colorConfig
98
+ .map(([key, itemConfig]) => {
99
+ const color =
100
+ itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??
101
+ itemConfig.color
102
+ return color ? ` --color-${key}: ${color};` : null
103
+ })
104
+ .join("\n")}
105
+ }
106
+ `
107
+ )
108
+ .join("\n"),
109
+ }}
110
+ />
111
+ )
112
+ }
113
+
114
+ const ChartTooltip = RechartsPrimitive.Tooltip
115
+
116
+ function ChartTooltipContent({
117
+ active,
118
+ payload,
119
+ className,
120
+ indicator = "dot",
121
+ hideLabel = false,
122
+ hideIndicator = false,
123
+ label,
124
+ labelFormatter,
125
+ labelClassName,
126
+ formatter,
127
+ color,
128
+ nameKey,
129
+ labelKey,
130
+ }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
131
+ React.ComponentProps<"div"> & {
132
+ hideLabel?: boolean
133
+ hideIndicator?: boolean
134
+ indicator?: "line" | "dot" | "dashed"
135
+ nameKey?: string
136
+ labelKey?: string
137
+ } & Omit<
138
+ RechartsPrimitive.DefaultTooltipContentProps<
139
+ TooltipValueType,
140
+ TooltipNameType
141
+ >,
142
+ "accessibilityLayer"
143
+ >) {
144
+ const { config } = useChart()
145
+
146
+ const tooltipLabel = React.useMemo(() => {
147
+ if (hideLabel || !payload?.length) {
148
+ return null
149
+ }
150
+
151
+ const [item] = payload
152
+ const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`
153
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
154
+ const value =
155
+ !labelKey && typeof label === "string"
156
+ ? (config[label]?.label ?? label)
157
+ : itemConfig?.label
158
+
159
+ if (labelFormatter) {
160
+ return (
161
+ <div className={cn("font-medium", labelClassName)}>
162
+ {labelFormatter(value, payload)}
163
+ </div>
164
+ )
165
+ }
166
+
167
+ if (!value) {
168
+ return null
169
+ }
170
+
171
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>
172
+ }, [
173
+ label,
174
+ labelFormatter,
175
+ payload,
176
+ hideLabel,
177
+ labelClassName,
178
+ config,
179
+ labelKey,
180
+ ])
181
+
182
+ if (!active || !payload?.length) {
183
+ return null
184
+ }
185
+
186
+ const nestLabel = payload.length === 1 && indicator !== "dot"
187
+
188
+ return (
189
+ <div
190
+ className={cn(
191
+ "grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
192
+ className
193
+ )}
194
+ >
195
+ {!nestLabel ? tooltipLabel : null}
196
+ <div className="grid gap-1.5">
197
+ {payload
198
+ .filter((item) => item.type !== "none")
199
+ .map((item, index) => {
200
+ const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`
201
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
202
+ const indicatorColor = color ?? item.payload?.fill ?? item.color
203
+
204
+ return (
205
+ <div
206
+ key={index}
207
+ className={cn(
208
+ "flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
209
+ indicator === "dot" && "items-center"
210
+ )}
211
+ >
212
+ {formatter && item?.value !== undefined && item.name ? (
213
+ formatter(item.value, item.name, item, index, item.payload)
214
+ ) : (
215
+ <>
216
+ {itemConfig?.icon ? (
217
+ <itemConfig.icon />
218
+ ) : (
219
+ !hideIndicator && (
220
+ <div
221
+ className={cn(
222
+ "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
223
+ {
224
+ "h-2.5 w-2.5": indicator === "dot",
225
+ "w-1": indicator === "line",
226
+ "w-0 border-[1.5px] border-dashed bg-transparent":
227
+ indicator === "dashed",
228
+ "my-0.5": nestLabel && indicator === "dashed",
229
+ }
230
+ )}
231
+ style={
232
+ {
233
+ "--color-bg": indicatorColor,
234
+ "--color-border": indicatorColor,
235
+ } as React.CSSProperties
236
+ }
237
+ />
238
+ )
239
+ )}
240
+ <div
241
+ className={cn(
242
+ "flex flex-1 justify-between leading-none",
243
+ nestLabel ? "items-end" : "items-center"
244
+ )}
245
+ >
246
+ <div className="grid gap-1.5">
247
+ {nestLabel ? tooltipLabel : null}
248
+ <span className="text-muted-foreground">
249
+ {itemConfig?.label ?? item.name}
250
+ </span>
251
+ </div>
252
+ {item.value != null && (
253
+ <span className="font-mono font-medium text-foreground tabular-nums">
254
+ {typeof item.value === "number"
255
+ ? item.value.toLocaleString()
256
+ : String(item.value)}
257
+ </span>
258
+ )}
259
+ </div>
260
+ </>
261
+ )}
262
+ </div>
263
+ )
264
+ })}
265
+ </div>
266
+ </div>
267
+ )
268
+ }
269
+
270
+ const ChartLegend = RechartsPrimitive.Legend
271
+
272
+ function ChartLegendContent({
273
+ className,
274
+ hideIcon = false,
275
+ payload,
276
+ verticalAlign = "bottom",
277
+ nameKey,
278
+ }: React.ComponentProps<"div"> & {
279
+ hideIcon?: boolean
280
+ nameKey?: string
281
+ } & RechartsPrimitive.DefaultLegendContentProps) {
282
+ const { config } = useChart()
283
+
284
+ if (!payload?.length) {
285
+ return null
286
+ }
287
+
288
+ return (
289
+ <div
290
+ className={cn(
291
+ "flex items-center justify-center gap-4",
292
+ verticalAlign === "top" ? "pb-3" : "pt-3",
293
+ className
294
+ )}
295
+ >
296
+ {payload
297
+ .filter((item) => item.type !== "none")
298
+ .map((item, index) => {
299
+ const key = `${nameKey ?? item.dataKey ?? "value"}`
300
+ const itemConfig = getPayloadConfigFromPayload(config, item, key)
301
+
302
+ return (
303
+ <div
304
+ key={index}
305
+ className={cn(
306
+ "flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"
307
+ )}
308
+ >
309
+ {itemConfig?.icon && !hideIcon ? (
310
+ <itemConfig.icon />
311
+ ) : (
312
+ <div
313
+ className="h-2 w-2 shrink-0 rounded-[2px]"
314
+ style={{
315
+ backgroundColor: item.color,
316
+ }}
317
+ />
318
+ )}
319
+ {itemConfig?.label}
320
+ </div>
321
+ )
322
+ })}
323
+ </div>
324
+ )
325
+ }
326
+
327
+ // Helper to extract item config from a payload.
328
+ function getPayloadConfigFromPayload(
329
+ config: ChartConfig,
330
+ payload: unknown,
331
+ key: string
332
+ ) {
333
+ if (typeof payload !== "object" || payload === null) {
334
+ return undefined
335
+ }
336
+
337
+ const payloadPayload =
338
+ "payload" in payload &&
339
+ typeof payload.payload === "object" &&
340
+ payload.payload !== null
341
+ ? payload.payload
342
+ : undefined
343
+
344
+ let configLabelKey: string = key
345
+
346
+ if (
347
+ key in payload &&
348
+ typeof payload[key as keyof typeof payload] === "string"
349
+ ) {
350
+ configLabelKey = payload[key as keyof typeof payload] as string
351
+ } else if (
352
+ payloadPayload &&
353
+ key in payloadPayload &&
354
+ typeof payloadPayload[key as keyof typeof payloadPayload] === "string"
355
+ ) {
356
+ configLabelKey = payloadPayload[
357
+ key as keyof typeof payloadPayload
358
+ ] as string
359
+ }
360
+
361
+ return configLabelKey in config ? config[configLabelKey] : config[key]
362
+ }
363
+
364
+ export {
365
+ ChartContainer,
366
+ ChartTooltip,
367
+ ChartTooltipContent,
368
+ ChartLegend,
369
+ ChartLegendContent,
370
+ ChartStyle,
371
+ }
@@ -0,0 +1,29 @@
1
+ import * as React from "react"
2
+ import { cn } from "../cn"
3
+ import { CheckIcon } from "lucide-react"
4
+ import { Checkbox as CheckboxPrimitive } from "radix-ui"
5
+
6
+ function Checkbox({
7
+ className,
8
+ ...props
9
+ }: 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-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",
15
+ className
16
+ )}
17
+ {...props}
18
+ >
19
+ <CheckboxPrimitive.Indicator
20
+ data-slot="checkbox-indicator"
21
+ className="grid place-content-center text-current transition-none"
22
+ >
23
+ <CheckIcon className="size-3.5" />
24
+ </CheckboxPrimitive.Indicator>
25
+ </CheckboxPrimitive.Root>
26
+ )
27
+ }
28
+
29
+ export { Checkbox }
@@ -0,0 +1,33 @@
1
+ "use client"
2
+
3
+ import { Collapsible as CollapsiblePrimitive } from "radix-ui"
4
+
5
+ function Collapsible({
6
+ ...props
7
+ }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
8
+ return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />
9
+ }
10
+
11
+ function CollapsibleTrigger({
12
+ ...props
13
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
14
+ return (
15
+ <CollapsiblePrimitive.CollapsibleTrigger
16
+ data-slot="collapsible-trigger"
17
+ {...props}
18
+ />
19
+ )
20
+ }
21
+
22
+ function CollapsibleContent({
23
+ ...props
24
+ }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25
+ return (
26
+ <CollapsiblePrimitive.CollapsibleContent
27
+ data-slot="collapsible-content"
28
+ {...props}
29
+ />
30
+ )
31
+ }
32
+
33
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent }
@@ -0,0 +1,184 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Command as CommandPrimitive } from "cmdk"
5
+ import { cn } from "../cn"
6
+ import { SearchIcon } from "lucide-react"
7
+
8
+ import {
9
+ Dialog,
10
+ DialogContent,
11
+ DialogDescription,
12
+ DialogHeader,
13
+ DialogTitle,
14
+ } from "./dialog"
15
+
16
+ function Command({
17
+ className,
18
+ ...props
19
+ }: React.ComponentProps<typeof CommandPrimitive>) {
20
+ return (
21
+ <CommandPrimitive
22
+ data-slot="command"
23
+ className={cn(
24
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
25
+ className
26
+ )}
27
+ {...props}
28
+ />
29
+ )
30
+ }
31
+
32
+ function CommandDialog({
33
+ title = "Command Palette",
34
+ description = "Search for a command to run...",
35
+ children,
36
+ className,
37
+ showCloseButton = true,
38
+ ...props
39
+ }: React.ComponentProps<typeof Dialog> & {
40
+ title?: string
41
+ description?: string
42
+ className?: string
43
+ showCloseButton?: boolean
44
+ }) {
45
+ return (
46
+ <Dialog {...props}>
47
+ <DialogHeader className="sr-only">
48
+ <DialogTitle>{title}</DialogTitle>
49
+ <DialogDescription>{description}</DialogDescription>
50
+ </DialogHeader>
51
+ <DialogContent
52
+ className={cn("overflow-hidden p-0", className)}
53
+ showCloseButton={showCloseButton}
54
+ >
55
+ <Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
56
+ {children}
57
+ </Command>
58
+ </DialogContent>
59
+ </Dialog>
60
+ )
61
+ }
62
+
63
+ function CommandInput({
64
+ className,
65
+ ...props
66
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
67
+ return (
68
+ <div
69
+ data-slot="command-input-wrapper"
70
+ className="flex h-9 items-center gap-2 border-b px-3"
71
+ >
72
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
73
+ <CommandPrimitive.Input
74
+ data-slot="command-input"
75
+ className={cn(
76
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
77
+ className
78
+ )}
79
+ {...props}
80
+ />
81
+ </div>
82
+ )
83
+ }
84
+
85
+ function CommandList({
86
+ className,
87
+ ...props
88
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
89
+ return (
90
+ <CommandPrimitive.List
91
+ data-slot="command-list"
92
+ className={cn(
93
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
94
+ className
95
+ )}
96
+ {...props}
97
+ />
98
+ )
99
+ }
100
+
101
+ function CommandEmpty({
102
+ ...props
103
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
104
+ return (
105
+ <CommandPrimitive.Empty
106
+ data-slot="command-empty"
107
+ className="py-6 text-center text-sm"
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function CommandGroup({
114
+ className,
115
+ ...props
116
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
117
+ return (
118
+ <CommandPrimitive.Group
119
+ data-slot="command-group"
120
+ className={cn(
121
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
122
+ className
123
+ )}
124
+ {...props}
125
+ />
126
+ )
127
+ }
128
+
129
+ function CommandSeparator({
130
+ className,
131
+ ...props
132
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
133
+ return (
134
+ <CommandPrimitive.Separator
135
+ data-slot="command-separator"
136
+ className={cn("-mx-1 h-px bg-border", className)}
137
+ {...props}
138
+ />
139
+ )
140
+ }
141
+
142
+ function CommandItem({
143
+ className,
144
+ ...props
145
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
146
+ return (
147
+ <CommandPrimitive.Item
148
+ data-slot="command-item"
149
+ className={cn(
150
+ "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
151
+ className
152
+ )}
153
+ {...props}
154
+ />
155
+ )
156
+ }
157
+
158
+ function CommandShortcut({
159
+ className,
160
+ ...props
161
+ }: React.ComponentProps<"span">) {
162
+ return (
163
+ <span
164
+ data-slot="command-shortcut"
165
+ className={cn(
166
+ "ml-auto text-xs tracking-widest text-muted-foreground",
167
+ className
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ export {
175
+ Command,
176
+ CommandDialog,
177
+ CommandInput,
178
+ CommandList,
179
+ CommandEmpty,
180
+ CommandGroup,
181
+ CommandItem,
182
+ CommandShortcut,
183
+ CommandSeparator,
184
+ }