@brightlocal/ui-components 0.1.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 (320) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/accordion.cjs +1 -0
  4. package/dist/accordion.d.ts +32 -0
  5. package/dist/accordion.d.ts.map +1 -0
  6. package/dist/accordion.js +107 -0
  7. package/dist/alert-dialog.cjs +1 -0
  8. package/dist/alert-dialog.d.ts +15 -0
  9. package/dist/alert-dialog.d.ts.map +1 -0
  10. package/dist/alert-dialog.js +146 -0
  11. package/dist/alert.cjs +1 -0
  12. package/dist/alert.d.ts +16 -0
  13. package/dist/alert.d.ts.map +1 -0
  14. package/dist/alert.js +174 -0
  15. package/dist/aspect-ratio.cjs +1 -0
  16. package/dist/aspect-ratio.d.ts +10 -0
  17. package/dist/aspect-ratio.d.ts.map +1 -0
  18. package/dist/aspect-ratio.js +22 -0
  19. package/dist/avatar.cjs +1 -0
  20. package/dist/avatar.d.ts +11 -0
  21. package/dist/avatar.d.ts.map +1 -0
  22. package/dist/avatar.js +46 -0
  23. package/dist/badge.cjs +1 -0
  24. package/dist/badge.d.ts +19 -0
  25. package/dist/badge.d.ts.map +1 -0
  26. package/dist/badge.js +50 -0
  27. package/dist/blocks/data-table.cjs +1 -0
  28. package/dist/blocks/data-table.d.ts +303 -0
  29. package/dist/blocks/data-table.d.ts.map +1 -0
  30. package/dist/blocks/data-table.js +555 -0
  31. package/dist/blocks/sidebar.cjs +1 -0
  32. package/dist/blocks/sidebar.d.ts +744 -0
  33. package/dist/blocks/sidebar.d.ts.map +1 -0
  34. package/dist/blocks/sidebar.js +839 -0
  35. package/dist/breadcrumb.cjs +1 -0
  36. package/dist/breadcrumb.d.ts +12 -0
  37. package/dist/breadcrumb.d.ts.map +1 -0
  38. package/dist/breadcrumb.js +102 -0
  39. package/dist/button.cjs +1 -0
  40. package/dist/button.d.ts +73 -0
  41. package/dist/button.d.ts.map +1 -0
  42. package/dist/button.js +195 -0
  43. package/dist/calendar.cjs +1 -0
  44. package/dist/calendar.d.ts +28 -0
  45. package/dist/calendar.d.ts.map +1 -0
  46. package/dist/calendar.js +191 -0
  47. package/dist/card.cjs +1 -0
  48. package/dist/card.d.ts +28 -0
  49. package/dist/card.d.ts.map +1 -0
  50. package/dist/card.js +131 -0
  51. package/dist/carousel.cjs +1 -0
  52. package/dist/carousel.d.ts +21 -0
  53. package/dist/carousel.d.ts.map +1 -0
  54. package/dist/carousel.js +185 -0
  55. package/dist/centred-layout.cjs +1 -0
  56. package/dist/centred-layout.d.ts +49 -0
  57. package/dist/centred-layout.d.ts.map +1 -0
  58. package/dist/centred-layout.js +35 -0
  59. package/dist/chart.cjs +10 -0
  60. package/dist/chart.d.ts +83 -0
  61. package/dist/chart.d.ts.map +1 -0
  62. package/dist/chart.js +254 -0
  63. package/dist/checkbox.cjs +1 -0
  64. package/dist/checkbox.d.ts +15 -0
  65. package/dist/checkbox.d.ts.map +1 -0
  66. package/dist/checkbox.js +96 -0
  67. package/dist/collapsible.cjs +1 -0
  68. package/dist/collapsible.d.ts +18 -0
  69. package/dist/collapsible.d.ts.map +1 -0
  70. package/dist/collapsible.js +58 -0
  71. package/dist/combobox.cjs +1 -0
  72. package/dist/combobox.d.ts +65 -0
  73. package/dist/combobox.d.ts.map +1 -0
  74. package/dist/combobox.js +203 -0
  75. package/dist/command.cjs +1 -0
  76. package/dist/command.d.ts +44 -0
  77. package/dist/command.d.ts.map +1 -0
  78. package/dist/command.js +166 -0
  79. package/dist/context-menu.cjs +1 -0
  80. package/dist/context-menu.d.ts +42 -0
  81. package/dist/context-menu.d.ts.map +1 -0
  82. package/dist/context-menu.js +226 -0
  83. package/dist/date-picker.cjs +1 -0
  84. package/dist/date-picker.d.ts +54 -0
  85. package/dist/date-picker.d.ts.map +1 -0
  86. package/dist/date-picker.js +95 -0
  87. package/dist/dialog.cjs +1 -0
  88. package/dist/dialog.d.ts +20 -0
  89. package/dist/dialog.d.ts.map +1 -0
  90. package/dist/dialog.js +130 -0
  91. package/dist/drawer.cjs +1 -0
  92. package/dist/drawer.d.ts +22 -0
  93. package/dist/drawer.d.ts.map +1 -0
  94. package/dist/drawer.js +149 -0
  95. package/dist/dropdown-menu.cjs +1 -0
  96. package/dist/dropdown-menu.d.ts +253 -0
  97. package/dist/dropdown-menu.d.ts.map +1 -0
  98. package/dist/dropdown-menu.js +325 -0
  99. package/dist/field.cjs +1 -0
  100. package/dist/field.d.ts +21 -0
  101. package/dist/field.d.ts.map +1 -0
  102. package/dist/field.js +148 -0
  103. package/dist/global-layout.cjs +1 -0
  104. package/dist/global-layout.d.ts +60 -0
  105. package/dist/global-layout.d.ts.map +1 -0
  106. package/dist/global-layout.js +87 -0
  107. package/dist/hooks/use-mobile.cjs +1 -0
  108. package/dist/hooks/use-mobile.d.ts +2 -0
  109. package/dist/hooks/use-mobile.d.ts.map +1 -0
  110. package/dist/hooks/use-mobile.js +16 -0
  111. package/dist/hover-card.cjs +1 -0
  112. package/dist/hover-card.d.ts +43 -0
  113. package/dist/hover-card.d.ts.map +1 -0
  114. package/dist/hover-card.js +71 -0
  115. package/dist/index.cjs +1 -0
  116. package/dist/index.d.ts +61 -0
  117. package/dist/index.d.ts.map +1 -0
  118. package/dist/index.js +412 -0
  119. package/dist/input-base.cjs +1 -0
  120. package/dist/input-base.d.ts +28 -0
  121. package/dist/input-base.d.ts.map +1 -0
  122. package/dist/input-base.js +56 -0
  123. package/dist/input-group.cjs +1 -0
  124. package/dist/input-group.d.ts +26 -0
  125. package/dist/input-group.d.ts.map +1 -0
  126. package/dist/input-group.js +116 -0
  127. package/dist/input-otp.cjs +1 -0
  128. package/dist/input-otp.d.ts +45 -0
  129. package/dist/input-otp.d.ts.map +1 -0
  130. package/dist/input-otp.js +186 -0
  131. package/dist/input-password.cjs +1 -0
  132. package/dist/input-password.d.ts +38 -0
  133. package/dist/input-password.d.ts.map +1 -0
  134. package/dist/input-password.js +101 -0
  135. package/dist/input.cjs +1 -0
  136. package/dist/input.d.ts +32 -0
  137. package/dist/input.d.ts.map +1 -0
  138. package/dist/input.js +146 -0
  139. package/dist/label.cjs +1 -0
  140. package/dist/label.d.ts +12 -0
  141. package/dist/label.d.ts.map +1 -0
  142. package/dist/label.js +34 -0
  143. package/dist/lib/utils.cjs +1 -0
  144. package/dist/lib/utils.d.ts +3 -0
  145. package/dist/lib/utils.d.ts.map +1 -0
  146. package/dist/lib/utils.js +8 -0
  147. package/dist/link.cjs +1 -0
  148. package/dist/link.d.ts +29 -0
  149. package/dist/link.d.ts.map +1 -0
  150. package/dist/link.figma.d.ts +2 -0
  151. package/dist/link.figma.d.ts.map +1 -0
  152. package/dist/link.js +71 -0
  153. package/dist/logo.cjs +1 -0
  154. package/dist/logo.d.ts +25 -0
  155. package/dist/logo.d.ts.map +1 -0
  156. package/dist/logo.js +71 -0
  157. package/dist/menubar.cjs +1 -0
  158. package/dist/menubar.d.ts +106 -0
  159. package/dist/menubar.d.ts.map +1 -0
  160. package/dist/menubar.js +270 -0
  161. package/dist/navigation-menu.cjs +1 -0
  162. package/dist/navigation-menu.d.ts +108 -0
  163. package/dist/navigation-menu.d.ts.map +1 -0
  164. package/dist/navigation-menu.js +175 -0
  165. package/dist/pagination.cjs +1 -0
  166. package/dist/pagination.d.ts +81 -0
  167. package/dist/pagination.d.ts.map +1 -0
  168. package/dist/pagination.js +216 -0
  169. package/dist/popover.cjs +1 -0
  170. package/dist/popover.d.ts +8 -0
  171. package/dist/popover.d.ts.map +1 -0
  172. package/dist/popover.js +44 -0
  173. package/dist/progress.cjs +1 -0
  174. package/dist/progress.d.ts +29 -0
  175. package/dist/progress.d.ts.map +1 -0
  176. package/dist/progress.js +64 -0
  177. package/dist/radio-group.cjs +1 -0
  178. package/dist/radio-group.d.ts +33 -0
  179. package/dist/radio-group.d.ts.map +1 -0
  180. package/dist/radio-group.js +193 -0
  181. package/dist/rating.cjs +1 -0
  182. package/dist/rating.d.ts +22 -0
  183. package/dist/rating.d.ts.map +1 -0
  184. package/dist/rating.js +51 -0
  185. package/dist/resizable.cjs +1 -0
  186. package/dist/resizable.d.ts +14 -0
  187. package/dist/resizable.d.ts.map +1 -0
  188. package/dist/resizable.js +46 -0
  189. package/dist/scroll-area.cjs +1 -0
  190. package/dist/scroll-area.d.ts +12 -0
  191. package/dist/scroll-area.d.ts.map +1 -0
  192. package/dist/scroll-area.js +67 -0
  193. package/dist/select.cjs +1 -0
  194. package/dist/select.d.ts +77 -0
  195. package/dist/select.d.ts.map +1 -0
  196. package/dist/select.js +259 -0
  197. package/dist/separator.cjs +1 -0
  198. package/dist/separator.d.ts +14 -0
  199. package/dist/separator.d.ts.map +1 -0
  200. package/dist/separator.js +43 -0
  201. package/dist/sheet.cjs +1 -0
  202. package/dist/sheet.d.ts +38 -0
  203. package/dist/sheet.d.ts.map +1 -0
  204. package/dist/sheet.js +190 -0
  205. package/dist/skeleton.cjs +1 -0
  206. package/dist/skeleton.d.ts +5 -0
  207. package/dist/skeleton.d.ts.map +1 -0
  208. package/dist/skeleton.js +15 -0
  209. package/dist/slider.cjs +1 -0
  210. package/dist/slider.d.ts +19 -0
  211. package/dist/slider.d.ts.map +1 -0
  212. package/dist/slider.js +69 -0
  213. package/dist/sonner.cjs +1 -0
  214. package/dist/sonner.d.ts +188 -0
  215. package/dist/sonner.d.ts.map +1 -0
  216. package/dist/sonner.js +150 -0
  217. package/dist/split-layout.cjs +1 -0
  218. package/dist/split-layout.d.ts +42 -0
  219. package/dist/split-layout.d.ts.map +1 -0
  220. package/dist/split-layout.js +108 -0
  221. package/dist/switch.cjs +1 -0
  222. package/dist/switch.d.ts +43 -0
  223. package/dist/switch.d.ts.map +1 -0
  224. package/dist/switch.figma.d.ts +2 -0
  225. package/dist/switch.figma.d.ts.map +1 -0
  226. package/dist/switch.js +110 -0
  227. package/dist/table.cjs +1 -0
  228. package/dist/table.d.ts +95 -0
  229. package/dist/table.d.ts.map +1 -0
  230. package/dist/table.js +164 -0
  231. package/dist/tabs.cjs +1 -0
  232. package/dist/tabs.d.ts +29 -0
  233. package/dist/tabs.d.ts.map +1 -0
  234. package/dist/tabs.js +96 -0
  235. package/dist/textarea.cjs +1 -0
  236. package/dist/textarea.d.ts +23 -0
  237. package/dist/textarea.d.ts.map +1 -0
  238. package/dist/textarea.js +47 -0
  239. package/dist/toggle-group.cjs +1 -0
  240. package/dist/toggle-group.d.ts +25 -0
  241. package/dist/toggle-group.d.ts.map +1 -0
  242. package/dist/toggle-group.js +74 -0
  243. package/dist/toggle.cjs +1 -0
  244. package/dist/toggle.d.ts +44 -0
  245. package/dist/toggle.d.ts.map +1 -0
  246. package/dist/toggle.figma.d.ts +2 -0
  247. package/dist/toggle.figma.d.ts.map +1 -0
  248. package/dist/toggle.js +57 -0
  249. package/dist/tooltip.cjs +1 -0
  250. package/dist/tooltip.d.ts +66 -0
  251. package/dist/tooltip.d.ts.map +1 -0
  252. package/dist/tooltip.js +78 -0
  253. package/package.json +184 -0
  254. package/src/blocks/data-table.tsx +1166 -0
  255. package/src/blocks/sidebar.tsx +1830 -0
  256. package/src/components/.gitkeep +0 -0
  257. package/src/components/accordion.tsx +142 -0
  258. package/src/components/alert-dialog.tsx +157 -0
  259. package/src/components/alert.tsx +199 -0
  260. package/src/components/aspect-ratio.tsx +30 -0
  261. package/src/components/avatar.tsx +56 -0
  262. package/src/components/badge.tsx +72 -0
  263. package/src/components/breadcrumb.tsx +109 -0
  264. package/src/components/button.tsx +296 -0
  265. package/src/components/calendar.tsx +234 -0
  266. package/src/components/card.tsx +158 -0
  267. package/src/components/carousel.tsx +256 -0
  268. package/src/components/centred-layout.tsx +91 -0
  269. package/src/components/chart.tsx +456 -0
  270. package/src/components/checkbox.tsx +132 -0
  271. package/src/components/collapsible.tsx +68 -0
  272. package/src/components/combobox.tsx +321 -0
  273. package/src/components/command.tsx +220 -0
  274. package/src/components/context-menu.tsx +305 -0
  275. package/src/components/date-picker.tsx +155 -0
  276. package/src/components/dialog.tsx +152 -0
  277. package/src/components/drawer.tsx +168 -0
  278. package/src/components/dropdown-menu.tsx +575 -0
  279. package/src/components/field.tsx +155 -0
  280. package/src/components/global-layout.tsx +153 -0
  281. package/src/components/hover-card.tsx +121 -0
  282. package/src/components/input-base.tsx +86 -0
  283. package/src/components/input-group.tsx +158 -0
  284. package/src/components/input-otp.tsx +327 -0
  285. package/src/components/input-password.tsx +191 -0
  286. package/src/components/input.tsx +220 -0
  287. package/src/components/label.tsx +42 -0
  288. package/src/components/link.figma.tsx +71 -0
  289. package/src/components/link.tsx +105 -0
  290. package/src/components/logo.tsx +97 -0
  291. package/src/components/menubar.tsx +379 -0
  292. package/src/components/navigation-menu.tsx +324 -0
  293. package/src/components/pagination.tsx +368 -0
  294. package/src/components/popover.tsx +46 -0
  295. package/src/components/progress.tsx +100 -0
  296. package/src/components/radio-group.tsx +281 -0
  297. package/src/components/rating.tsx +87 -0
  298. package/src/components/resizable.tsx +66 -0
  299. package/src/components/scroll-area.tsx +72 -0
  300. package/src/components/select.tsx +442 -0
  301. package/src/components/separator.tsx +53 -0
  302. package/src/components/sheet.tsx +220 -0
  303. package/src/components/skeleton.tsx +17 -0
  304. package/src/components/slider.tsx +86 -0
  305. package/src/components/sonner.tsx +396 -0
  306. package/src/components/split-layout.tsx +155 -0
  307. package/src/components/switch.figma.tsx +115 -0
  308. package/src/components/switch.tsx +173 -0
  309. package/src/components/table.tsx +277 -0
  310. package/src/components/tabs.tsx +142 -0
  311. package/src/components/textarea.tsx +77 -0
  312. package/src/components/toggle-group.tsx +109 -0
  313. package/src/components/toggle.figma.tsx +81 -0
  314. package/src/components/toggle.tsx +103 -0
  315. package/src/components/tooltip.tsx +156 -0
  316. package/src/hooks/.gitkeep +0 -0
  317. package/src/hooks/use-mobile.ts +21 -0
  318. package/src/index.ts +67 -0
  319. package/src/lib/utils.ts +6 -0
  320. package/src/types/external-modules.d.ts +16 -0
@@ -0,0 +1,1830 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import { cva, type VariantProps } from "class-variance-authority";
6
+ import {
7
+ ChevronRight,
8
+ ChevronDown,
9
+ ChevronsUpDown,
10
+ Plus,
11
+ Minus,
12
+ PanelLeft,
13
+ Ellipsis,
14
+ } from "lucide-react";
15
+
16
+ import { cn } from "@brightlocal/ui-components/lib/utils";
17
+ import {
18
+ Button,
19
+ ButtonSize,
20
+ ButtonVariant,
21
+ } from "../components/button";
22
+ import { Input } from "../components/input";
23
+ import { Separator } from "../components/separator";
24
+ import {
25
+ Sheet,
26
+ SheetContent,
27
+ SheetSide,
28
+ } from "../components/sheet";
29
+ import { Skeleton } from "../components/skeleton";
30
+ import {
31
+ Tooltip,
32
+ TooltipContent,
33
+ TooltipProvider,
34
+ TooltipTrigger,
35
+ } from "../components/tooltip";
36
+ import { useIsMobile } from "../hooks/use-mobile";
37
+
38
+ /**
39
+ * Sidebar position variants
40
+ */
41
+ export enum SidebarSide {
42
+ /** Sidebar positioned on the left */
43
+ LEFT = "left",
44
+ }
45
+
46
+ /**
47
+ * Sidebar visual variants
48
+ */
49
+ export enum SidebarVariant {
50
+ /** Standard sidebar attached to edge */
51
+ SIDEBAR = "sidebar",
52
+ }
53
+
54
+ /**
55
+ * Sidebar collapsible behavior variants
56
+ */
57
+ export enum SidebarCollapsible {
58
+ /** Slides off canvas when collapsed */
59
+ OFFCANVAS = "offcanvas",
60
+ /** Collapses to icon-only mode */
61
+ ICON = "icon",
62
+ /** Non-collapsible sidebar */
63
+ NONE = "none",
64
+ }
65
+
66
+ /**
67
+ * Sidebar group label size variants
68
+ */
69
+ export enum SidebarGroupLabelSize {
70
+ /** Default size */
71
+ DEFAULT = "default",
72
+ /** Small size */
73
+ SM = "sm",
74
+ /** Extra small size */
75
+ XS = "xs",
76
+ }
77
+
78
+ /**
79
+ * Sidebar group label variants
80
+ */
81
+ export enum SidebarGroupLabelVariant {
82
+ /** Static label */
83
+ DEFAULT = "default",
84
+ /** Collapsible label with chevron */
85
+ COLLAPSIBLE = "collapsible",
86
+ /** Action label with plus icon */
87
+ ACTION = "action",
88
+ }
89
+
90
+ /**
91
+ * Sidebar menu button variants
92
+ */
93
+ export enum SidebarMenuButtonVariant {
94
+ /** Basic menu item with icon and text */
95
+ SIMPLE = "simple",
96
+ /** Has a chevron indicator that rotates when open */
97
+ COLLAPSIBLE = "collapsible",
98
+ /** Has action menu (dots) on hover */
99
+ DROPDOWN = "dropdown",
100
+ /** Has a chevron for tree navigation */
101
+ TREE = "tree",
102
+ /** Has a number badge on the right */
103
+ BADGE = "badge",
104
+ /** Larger icon with title and subtitle */
105
+ BIG_ICON = "bigIcon",
106
+ /** Has a checkbox indicator */
107
+ CHECKBOX = "checkbox",
108
+ }
109
+
110
+ /**
111
+ * Sidebar menu button size variants
112
+ */
113
+ export enum SidebarMenuButtonSize {
114
+ /** Default size (32px height) */
115
+ DEFAULT = "default",
116
+ /** Small size (28px height) */
117
+ SM = "sm",
118
+ /** Large size (48px height) */
119
+ LG = "lg",
120
+ }
121
+
122
+ /**
123
+ * Sidebar menu sub variants
124
+ */
125
+ export enum SidebarMenuSubVariant {
126
+ /** No border styling */
127
+ DEFAULT = "default",
128
+ /** Left border indicator */
129
+ BORDER = "border",
130
+ /** Indented without border */
131
+ INDENT = "indent",
132
+ }
133
+
134
+ /**
135
+ * Sidebar menu sub button size variants
136
+ */
137
+ export enum SidebarMenuSubButtonSize {
138
+ /** Small size */
139
+ SM = "sm",
140
+ /** Medium size */
141
+ MD = "md",
142
+ }
143
+
144
+ /**
145
+ * Sidebar collapse icon type variants
146
+ */
147
+ export enum SidebarCollapseIconType {
148
+ /** Caret/chevron right icon */
149
+ CARET = "caret",
150
+ /** Horizontal chevron */
151
+ HORIZONTAL = "horizontal",
152
+ /** Vertical chevron */
153
+ VERTICAL = "vertical",
154
+ /** Up/down chevrons */
155
+ UP_DOWN = "upDown",
156
+ /** Plus/minus icons */
157
+ PLUS_MINUS = "plusMinus",
158
+ /** Ellipsis/dots icon */
159
+ DOTS = "dots",
160
+ }
161
+
162
+ const SIDEBAR_COOKIE_NAME = "sidebar:state";
163
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
164
+ const SIDEBAR_WIDTH = "256px";
165
+ const SIDEBAR_WIDTH_MOBILE = "288px";
166
+ const SIDEBAR_WIDTH_ICON = "48px";
167
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
168
+
169
+ type SidebarContext = {
170
+ state: "expanded" | "collapsed";
171
+ open: boolean;
172
+ setOpen: (open: boolean) => void;
173
+ openMobile: boolean;
174
+ setOpenMobile: (open: boolean) => void;
175
+ isMobile: boolean;
176
+ toggleSidebar: () => void;
177
+ };
178
+
179
+ const SidebarContext = React.createContext<SidebarContext | null>(null);
180
+
181
+ function useSidebar() {
182
+ const context = React.useContext(SidebarContext);
183
+ if (!context) {
184
+ throw new Error("useSidebar must be used within a SidebarProvider.");
185
+ }
186
+
187
+ return context;
188
+ }
189
+
190
+ /**
191
+ * Props for the SidebarProvider component
192
+ */
193
+ interface SidebarProviderProps extends React.ComponentProps<"div"> {
194
+ /**
195
+ * Data hook for automated testing (REQUIRED)
196
+ * Used to identify component in tests and E2E automation
197
+ */
198
+ dataHook: string;
199
+ /**
200
+ * Tracking element identifier for analytics
201
+ * Defaults to "sidebar-provider" if not provided
202
+ */
203
+ trackingEl?: string;
204
+ /**
205
+ * Tracking label for analytics context
206
+ */
207
+ trackingLabel?: string;
208
+ /**
209
+ * Default open state for uncontrolled usage
210
+ * @default true
211
+ */
212
+ defaultOpen?: boolean;
213
+ /**
214
+ * Controlled open state
215
+ */
216
+ open?: boolean;
217
+ /**
218
+ * Callback when open state changes
219
+ */
220
+ onOpenChange?: (open: boolean) => void;
221
+ }
222
+
223
+ const SidebarProvider = React.forwardRef<HTMLDivElement, SidebarProviderProps>(
224
+ (
225
+ {
226
+ dataHook,
227
+ trackingEl,
228
+ trackingLabel,
229
+ defaultOpen = true,
230
+ open: openProp,
231
+ onOpenChange: setOpenProp,
232
+ className,
233
+ style,
234
+ children,
235
+ ...props
236
+ },
237
+ ref
238
+ ) => {
239
+ const isMobile = useIsMobile();
240
+ const [openMobile, setOpenMobile] = React.useState(false);
241
+
242
+ // Internal state for uncontrolled usage
243
+ const [_open, _setOpen] = React.useState(defaultOpen);
244
+ const open = openProp ?? _open;
245
+ const setOpen = React.useCallback(
246
+ (value: boolean | ((value: boolean) => boolean)) => {
247
+ const openState = typeof value === "function" ? value(open) : value;
248
+ if (setOpenProp) {
249
+ setOpenProp(openState);
250
+ } else {
251
+ _setOpen(openState);
252
+ }
253
+
254
+ // Store state in cookie
255
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
256
+ },
257
+ [setOpenProp, open]
258
+ );
259
+
260
+ // Toggle sidebar
261
+ const toggleSidebar = React.useCallback(() => {
262
+ return isMobile
263
+ ? setOpenMobile((open) => !open)
264
+ : setOpen((open) => !open);
265
+ }, [isMobile, setOpen, setOpenMobile]);
266
+
267
+ // Handle keyboard shortcut
268
+ React.useEffect(() => {
269
+ const handleKeyDown = (event: KeyboardEvent) => {
270
+ if (
271
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
272
+ (event.metaKey || event.ctrlKey)
273
+ ) {
274
+ event.preventDefault();
275
+ toggleSidebar();
276
+ }
277
+ };
278
+
279
+ window.addEventListener("keydown", handleKeyDown);
280
+ return () => window.removeEventListener("keydown", handleKeyDown);
281
+ }, [toggleSidebar]);
282
+
283
+ // Store state
284
+ const state = open ? "expanded" : "collapsed";
285
+
286
+ const contextValue = React.useMemo<SidebarContext>(
287
+ () => ({
288
+ state,
289
+ open,
290
+ setOpen,
291
+ isMobile,
292
+ openMobile,
293
+ setOpenMobile,
294
+ toggleSidebar,
295
+ }),
296
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
297
+ );
298
+
299
+ return (
300
+ <SidebarContext.Provider value={contextValue}>
301
+ <TooltipProvider delayDuration={0}>
302
+ <div
303
+ ref={ref}
304
+ className={cn(
305
+ "group/sidebar-wrapper flex min-h-svh w-full",
306
+ className
307
+ )}
308
+ data-hook={dataHook}
309
+ data-slot="sidebar-provider"
310
+ data-tracking-el={trackingEl || "sidebar-provider"}
311
+ data-tracking-label={trackingLabel}
312
+ style={
313
+ {
314
+ "--sidebar-width": SIDEBAR_WIDTH,
315
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
316
+ ...style,
317
+ } as React.CSSProperties
318
+ }
319
+ {...props}
320
+ >
321
+ {children}
322
+ </div>
323
+ </TooltipProvider>
324
+ </SidebarContext.Provider>
325
+ );
326
+ }
327
+ );
328
+ SidebarProvider.displayName = "SidebarProvider";
329
+
330
+ /**
331
+ * Props for the Sidebar component
332
+ */
333
+ interface SidebarProps extends React.ComponentProps<"div"> {
334
+ /**
335
+ * Data hook for automated testing (REQUIRED)
336
+ * Used to identify component in tests and E2E automation
337
+ */
338
+ dataHook: string;
339
+ /**
340
+ * Tracking element identifier for analytics
341
+ * Defaults to "sidebar" if not provided
342
+ */
343
+ trackingEl?: string;
344
+ /**
345
+ * Tracking label for analytics context
346
+ */
347
+ trackingLabel?: string;
348
+ /**
349
+ * Position of the sidebar
350
+ * @default SidebarSide.LEFT
351
+ */
352
+ side?: SidebarSide;
353
+ /**
354
+ * Visual variant of the sidebar
355
+ * @default SidebarVariant.SIDEBAR
356
+ */
357
+ variant?: SidebarVariant;
358
+ /**
359
+ * Collapsible behavior
360
+ * @default SidebarCollapsible.OFFCANVAS
361
+ */
362
+ collapsible?: SidebarCollapsible;
363
+ }
364
+
365
+ const Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>(
366
+ (
367
+ {
368
+ dataHook,
369
+ trackingEl,
370
+ trackingLabel,
371
+ side = SidebarSide.LEFT,
372
+ variant = SidebarVariant.SIDEBAR,
373
+ collapsible = SidebarCollapsible.OFFCANVAS,
374
+ className,
375
+ children,
376
+ ...props
377
+ },
378
+ ref
379
+ ) => {
380
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
381
+
382
+ if (collapsible === SidebarCollapsible.NONE) {
383
+ return (
384
+ <div
385
+ ref={ref}
386
+ className={cn(
387
+ "bg-sidebar text-sidebar-foreground flex h-full w-[var(--sidebar-width)] flex-col",
388
+ className
389
+ )}
390
+ data-hook={dataHook}
391
+ data-slot="sidebar"
392
+ data-tracking-el={trackingEl || "sidebar"}
393
+ data-tracking-label={trackingLabel}
394
+ {...props}
395
+ >
396
+ {children}
397
+ </div>
398
+ );
399
+ }
400
+
401
+ if (isMobile) {
402
+ return (
403
+ <Sheet open={openMobile} onOpenChange={setOpenMobile}>
404
+ <SheetContent
405
+ className="bg-sidebar text-sidebar-foreground w-[var(--sidebar-width)] p-0 [&>button]:hidden"
406
+ data-hook={`${dataHook}-mobile-content`}
407
+ data-mobile="true"
408
+ data-sidebar="sidebar"
409
+ side={SheetSide.LEFT}
410
+ style={
411
+ {
412
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
413
+ } as React.CSSProperties
414
+ }
415
+ >
416
+ <div className="flex h-full w-full flex-col">{children}</div>
417
+ </SheetContent>
418
+ </Sheet>
419
+ );
420
+ }
421
+
422
+ return (
423
+ <div
424
+ ref={ref}
425
+ className="group peer text-sidebar-foreground hidden md:block"
426
+ data-collapsible={state === "collapsed" ? collapsible : ""}
427
+ data-hook={dataHook}
428
+ data-side={side}
429
+ data-slot="sidebar"
430
+ data-state={state}
431
+ data-tracking-el={trackingEl || "sidebar"}
432
+ data-tracking-label={trackingLabel}
433
+ data-variant={variant}
434
+ >
435
+ {/* Desktop sidebar */}
436
+ <div
437
+ className={cn(
438
+ "relative h-svh w-[var(--sidebar-width)] bg-transparent transition-[width] duration-200 ease-linear",
439
+ "group-data-[collapsible=offcanvas]:w-0",
440
+ "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]"
441
+ )}
442
+ />
443
+ <div
444
+ className={cn(
445
+ "fixed inset-y-0 z-10 hidden h-svh w-[var(--sidebar-width)] transition-[left,right,width] duration-200 ease-linear md:flex",
446
+ "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]",
447
+ "group-data-[collapsible=icon]:w-[var(--sidebar-width-icon)]",
448
+ className
449
+ )}
450
+ {...props}
451
+ >
452
+ <div
453
+ className="bg-sidebar flex h-full w-full flex-col"
454
+ data-sidebar="sidebar"
455
+ >
456
+ {children}
457
+ </div>
458
+ </div>
459
+ </div>
460
+ );
461
+ }
462
+ );
463
+ Sidebar.displayName = "Sidebar";
464
+
465
+ /**
466
+ * Props for the SidebarTrigger component
467
+ */
468
+ interface SidebarTriggerProps extends React.ComponentProps<typeof Button> {
469
+ /**
470
+ * Data hook for automated testing (REQUIRED)
471
+ * Used to identify component in tests and E2E automation
472
+ */
473
+ dataHook: string;
474
+ /**
475
+ * Tracking element identifier for analytics
476
+ * Defaults to "sidebar-trigger" if not provided
477
+ */
478
+ trackingEl?: string;
479
+ /**
480
+ * Tracking label for analytics context
481
+ */
482
+ trackingLabel?: string;
483
+ }
484
+
485
+ const SidebarTrigger = React.forwardRef<
486
+ React.ElementRef<typeof Button>,
487
+ SidebarTriggerProps
488
+ >(
489
+ (
490
+ { dataHook, trackingEl, trackingLabel, className, onClick, ...props },
491
+ ref
492
+ ) => {
493
+ const { toggleSidebar } = useSidebar();
494
+
495
+ return (
496
+ <Button
497
+ ref={ref}
498
+ aria-label="Toggle Sidebar"
499
+ className={cn("h-7 w-7", className)}
500
+ data-slot="sidebar-trigger"
501
+ data-tracking-el={trackingEl || "sidebar-trigger"}
502
+ data-tracking-label={trackingLabel}
503
+ dataHook={dataHook}
504
+ size={ButtonSize.SM}
505
+ variant={ButtonVariant.GHOST}
506
+ onClick={(event) => {
507
+ onClick?.(event);
508
+ toggleSidebar();
509
+ }}
510
+ {...props}
511
+ >
512
+ <PanelLeft />
513
+ <span className="sr-only">Toggle Sidebar</span>
514
+ </Button>
515
+ );
516
+ }
517
+ );
518
+ SidebarTrigger.displayName = "SidebarTrigger";
519
+
520
+ /**
521
+ * Props for the SidebarRail component
522
+ */
523
+ interface SidebarRailProps extends React.ComponentProps<"button"> {
524
+ /**
525
+ * Data hook for automated testing (REQUIRED)
526
+ * Used to identify component in tests and E2E automation
527
+ */
528
+ dataHook: string;
529
+ /**
530
+ * Tracking element identifier for analytics
531
+ * Defaults to "sidebar-rail" if not provided
532
+ */
533
+ trackingEl?: string;
534
+ /**
535
+ * Tracking label for analytics context
536
+ */
537
+ trackingLabel?: string;
538
+ }
539
+
540
+ const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
541
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
542
+ const { toggleSidebar } = useSidebar();
543
+
544
+ return (
545
+ <button
546
+ ref={ref}
547
+ aria-label="Toggle Sidebar"
548
+ className={cn(
549
+ "hover:after:bg-sidebar-border absolute inset-y-0 -right-4 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
550
+ "cursor-w-resize",
551
+ "[[data-state=collapsed]_&]:cursor-e-resize",
552
+ "group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
553
+ "[[data-collapsible=offcanvas]_&]:-right-2",
554
+ className
555
+ )}
556
+ data-hook={dataHook}
557
+ data-slot="sidebar-rail"
558
+ data-tracking-el={trackingEl || "sidebar-rail"}
559
+ data-tracking-label={trackingLabel}
560
+ tabIndex={-1}
561
+ title="Toggle Sidebar"
562
+ onClick={toggleSidebar}
563
+ {...props}
564
+ />
565
+ );
566
+ }
567
+ );
568
+ SidebarRail.displayName = "SidebarRail";
569
+
570
+ /**
571
+ * Props for the SidebarInset component
572
+ */
573
+ interface SidebarInsetProps extends React.ComponentProps<"main"> {
574
+ /**
575
+ * Data hook for automated testing (REQUIRED)
576
+ * Used to identify component in tests and E2E automation
577
+ */
578
+ dataHook: string;
579
+ /**
580
+ * Tracking element identifier for analytics
581
+ * Defaults to "sidebar-inset" if not provided
582
+ */
583
+ trackingEl?: string;
584
+ /**
585
+ * Tracking label for analytics context
586
+ */
587
+ trackingLabel?: string;
588
+ }
589
+
590
+ const SidebarInset = React.forwardRef<HTMLDivElement, SidebarInsetProps>(
591
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
592
+ return (
593
+ <main
594
+ ref={ref}
595
+ className={cn(
596
+ "bg-background relative flex min-h-svh flex-1 flex-col",
597
+ className
598
+ )}
599
+ data-hook={dataHook}
600
+ data-slot="sidebar-inset"
601
+ data-tracking-el={trackingEl || "sidebar-inset"}
602
+ data-tracking-label={trackingLabel}
603
+ {...props}
604
+ />
605
+ );
606
+ }
607
+ );
608
+ SidebarInset.displayName = "SidebarInset";
609
+
610
+ /**
611
+ * Props for the SidebarInput component
612
+ */
613
+ interface SidebarInputProps extends React.ComponentProps<typeof Input> {
614
+ /**
615
+ * Data hook for automated testing (REQUIRED)
616
+ * Used to identify component in tests and E2E automation
617
+ */
618
+ dataHook: string;
619
+ /**
620
+ * Tracking element identifier for analytics
621
+ * Defaults to "sidebar-input" if not provided
622
+ */
623
+ trackingEl?: string;
624
+ /**
625
+ * Tracking label for analytics context
626
+ */
627
+ trackingLabel?: string;
628
+ }
629
+
630
+ const SidebarInput = React.forwardRef<
631
+ React.ElementRef<typeof Input>,
632
+ SidebarInputProps
633
+ >(({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
634
+ return (
635
+ <Input
636
+ ref={ref}
637
+ className={cn(
638
+ "bg-background focus-visible:ring-sidebar-ring h-8 w-full shadow-none focus-visible:ring-2",
639
+ className
640
+ )}
641
+ data-slot="sidebar-input"
642
+ data-tracking-el={trackingEl || "sidebar-input"}
643
+ data-tracking-label={trackingLabel}
644
+ dataHook={dataHook}
645
+ {...props}
646
+ />
647
+ );
648
+ });
649
+ SidebarInput.displayName = "SidebarInput";
650
+
651
+ /**
652
+ * Props for the SidebarHeader component
653
+ */
654
+ interface SidebarHeaderProps extends React.ComponentProps<"div"> {
655
+ /**
656
+ * Data hook for automated testing (REQUIRED)
657
+ * Used to identify component in tests and E2E automation
658
+ */
659
+ dataHook: string;
660
+ /**
661
+ * Tracking element identifier for analytics
662
+ * Defaults to "sidebar-header" if not provided
663
+ */
664
+ trackingEl?: string;
665
+ /**
666
+ * Tracking label for analytics context
667
+ */
668
+ trackingLabel?: string;
669
+ }
670
+
671
+ const SidebarHeader = React.forwardRef<HTMLDivElement, SidebarHeaderProps>(
672
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
673
+ return (
674
+ <div
675
+ ref={ref}
676
+ className={cn("flex flex-col gap-2 p-2", className)}
677
+ data-hook={dataHook}
678
+ data-slot="sidebar-header"
679
+ data-tracking-el={trackingEl || "sidebar-header"}
680
+ data-tracking-label={trackingLabel}
681
+ {...props}
682
+ />
683
+ );
684
+ }
685
+ );
686
+ SidebarHeader.displayName = "SidebarHeader";
687
+
688
+ /**
689
+ * Props for the SidebarFooter component
690
+ */
691
+ interface SidebarFooterProps extends React.ComponentProps<"div"> {
692
+ /**
693
+ * Data hook for automated testing (REQUIRED)
694
+ * Used to identify component in tests and E2E automation
695
+ */
696
+ dataHook: string;
697
+ /**
698
+ * Tracking element identifier for analytics
699
+ * Defaults to "sidebar-footer" if not provided
700
+ */
701
+ trackingEl?: string;
702
+ /**
703
+ * Tracking label for analytics context
704
+ */
705
+ trackingLabel?: string;
706
+ }
707
+
708
+ const SidebarFooter = React.forwardRef<HTMLDivElement, SidebarFooterProps>(
709
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
710
+ return (
711
+ <div
712
+ ref={ref}
713
+ className={cn("flex flex-col gap-2 p-2", className)}
714
+ data-hook={dataHook}
715
+ data-slot="sidebar-footer"
716
+ data-tracking-el={trackingEl || "sidebar-footer"}
717
+ data-tracking-label={trackingLabel}
718
+ {...props}
719
+ />
720
+ );
721
+ }
722
+ );
723
+ SidebarFooter.displayName = "SidebarFooter";
724
+
725
+ /**
726
+ * Props for the SidebarSeparator component
727
+ */
728
+ interface SidebarSeparatorProps extends React.ComponentProps<typeof Separator> {
729
+ /**
730
+ * Data hook for automated testing (REQUIRED)
731
+ * Used to identify component in tests and E2E automation
732
+ */
733
+ dataHook: string;
734
+ /**
735
+ * Tracking element identifier for analytics
736
+ * Defaults to "sidebar-separator" if not provided
737
+ */
738
+ trackingEl?: string;
739
+ /**
740
+ * Tracking label for analytics context
741
+ */
742
+ trackingLabel?: string;
743
+ }
744
+
745
+ const SidebarSeparator = React.forwardRef<
746
+ React.ElementRef<typeof Separator>,
747
+ SidebarSeparatorProps
748
+ >(({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
749
+ return (
750
+ <Separator
751
+ ref={ref}
752
+ className={cn(
753
+ "bg-sidebar-border mx-2 w-auto group-data-[collapsible=icon]:mx-0",
754
+ className
755
+ )}
756
+ data-hook={dataHook}
757
+ data-slot="sidebar-separator"
758
+ data-tracking-el={trackingEl || "sidebar-separator"}
759
+ data-tracking-label={trackingLabel}
760
+ {...props}
761
+ />
762
+ );
763
+ });
764
+ SidebarSeparator.displayName = "SidebarSeparator";
765
+
766
+ /**
767
+ * Props for the SidebarContent component
768
+ */
769
+ interface SidebarContentProps extends React.ComponentProps<"div"> {
770
+ /**
771
+ * Data hook for automated testing (REQUIRED)
772
+ * Used to identify component in tests and E2E automation
773
+ */
774
+ dataHook: string;
775
+ /**
776
+ * Tracking element identifier for analytics
777
+ * Defaults to "sidebar-content" if not provided
778
+ */
779
+ trackingEl?: string;
780
+ /**
781
+ * Tracking label for analytics context
782
+ */
783
+ trackingLabel?: string;
784
+ }
785
+
786
+ const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
787
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
788
+ return (
789
+ <div
790
+ ref={ref}
791
+ className={cn(
792
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
793
+ className
794
+ )}
795
+ data-hook={dataHook}
796
+ data-slot="sidebar-content"
797
+ data-tracking-el={trackingEl || "sidebar-content"}
798
+ data-tracking-label={trackingLabel}
799
+ {...props}
800
+ />
801
+ );
802
+ }
803
+ );
804
+ SidebarContent.displayName = "SidebarContent";
805
+
806
+ /**
807
+ * Props for the SidebarGroup component
808
+ */
809
+ interface SidebarGroupProps extends React.ComponentProps<"div"> {
810
+ /**
811
+ * Data hook for automated testing (REQUIRED)
812
+ * Used to identify component in tests and E2E automation
813
+ */
814
+ dataHook: string;
815
+ /**
816
+ * Tracking element identifier for analytics
817
+ * Defaults to "sidebar-group" if not provided
818
+ */
819
+ trackingEl?: string;
820
+ /**
821
+ * Tracking label for analytics context
822
+ */
823
+ trackingLabel?: string;
824
+ }
825
+
826
+ const SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(
827
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => {
828
+ return (
829
+ <div
830
+ ref={ref}
831
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
832
+ data-hook={dataHook}
833
+ data-slot="sidebar-group"
834
+ data-tracking-el={trackingEl || "sidebar-group"}
835
+ data-tracking-label={trackingLabel}
836
+ {...props}
837
+ />
838
+ );
839
+ }
840
+ );
841
+ SidebarGroup.displayName = "SidebarGroup";
842
+
843
+ const sidebarGroupLabelVariants = cva(
844
+ "flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
845
+ {
846
+ variants: {
847
+ size: {
848
+ default: "text-sm",
849
+ sm: "text-sm",
850
+ xs: "text-xs",
851
+ },
852
+ variant: {
853
+ default: "",
854
+ collapsible:
855
+ "w-full justify-between cursor-pointer hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
856
+ action:
857
+ "w-full justify-between cursor-pointer hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
858
+ },
859
+ },
860
+ defaultVariants: {
861
+ size: "sm",
862
+ variant: "default",
863
+ },
864
+ }
865
+ );
866
+
867
+ /**
868
+ * Props for the SidebarGroupLabel component
869
+ */
870
+ interface SidebarGroupLabelProps
871
+ extends
872
+ React.ComponentProps<"div">,
873
+ VariantProps<typeof sidebarGroupLabelVariants> {
874
+ /**
875
+ * Data hook for automated testing (REQUIRED)
876
+ * Used to identify component in tests and E2E automation
877
+ */
878
+ dataHook: string;
879
+ /**
880
+ * Tracking element identifier for analytics
881
+ * Defaults to "sidebar-group-label" if not provided
882
+ */
883
+ trackingEl?: string;
884
+ /**
885
+ * Tracking label for analytics context
886
+ */
887
+ trackingLabel?: string;
888
+ /**
889
+ * Render as a different element (Radix Slot pattern)
890
+ */
891
+ asChild?: boolean;
892
+ /**
893
+ * Size variant
894
+ * @default SidebarGroupLabelSize.SM
895
+ */
896
+ size?: SidebarGroupLabelSize;
897
+ /**
898
+ * Visual/behavior variant
899
+ * @default SidebarGroupLabelVariant.DEFAULT
900
+ */
901
+ variant?: SidebarGroupLabelVariant;
902
+ /**
903
+ * Whether the collapsible section is open
904
+ */
905
+ isOpen?: boolean;
906
+ /**
907
+ * Callback when collapsible is toggled
908
+ */
909
+ onToggle?: () => void;
910
+ /**
911
+ * Callback when action is triggered
912
+ */
913
+ onAction?: () => void;
914
+ }
915
+
916
+ const SidebarGroupLabel = React.forwardRef<
917
+ HTMLDivElement,
918
+ SidebarGroupLabelProps
919
+ >(
920
+ (
921
+ {
922
+ dataHook,
923
+ trackingEl,
924
+ trackingLabel,
925
+ className,
926
+ asChild = false,
927
+ size = SidebarGroupLabelSize.SM,
928
+ variant = SidebarGroupLabelVariant.DEFAULT,
929
+ isOpen = false,
930
+ onToggle,
931
+ onAction,
932
+ children,
933
+ ...props
934
+ },
935
+ ref
936
+ ) => {
937
+ const Comp = asChild ? Slot : "div";
938
+
939
+ const handleClick = () => {
940
+ if (variant === SidebarGroupLabelVariant.COLLAPSIBLE && onToggle) {
941
+ onToggle();
942
+ } else if (variant === SidebarGroupLabelVariant.ACTION && onAction) {
943
+ onAction();
944
+ }
945
+ };
946
+
947
+ const handleKeyDown = (e: React.KeyboardEvent) => {
948
+ if (e.key === "Enter" || e.key === " ") {
949
+ e.preventDefault();
950
+ handleClick();
951
+ }
952
+ };
953
+
954
+ return (
955
+ <Comp
956
+ ref={ref}
957
+ className={cn(sidebarGroupLabelVariants({ size, variant }), className)}
958
+ data-hook={dataHook}
959
+ data-slot="sidebar-group-label"
960
+ data-tracking-el={trackingEl || "sidebar-group-label"}
961
+ data-tracking-label={trackingLabel}
962
+ data-variant={variant}
963
+ role={
964
+ variant !== SidebarGroupLabelVariant.DEFAULT ? "button" : undefined
965
+ }
966
+ tabIndex={variant !== SidebarGroupLabelVariant.DEFAULT ? 0 : undefined}
967
+ onClick={
968
+ variant !== SidebarGroupLabelVariant.DEFAULT ? handleClick : undefined
969
+ }
970
+ onKeyDown={
971
+ variant !== SidebarGroupLabelVariant.DEFAULT
972
+ ? handleKeyDown
973
+ : undefined
974
+ }
975
+ {...props}
976
+ >
977
+ <span>{children}</span>
978
+ {variant === SidebarGroupLabelVariant.COLLAPSIBLE && (
979
+ <ChevronDown
980
+ className={cn(
981
+ "size-4 shrink-0 transition-transform duration-200",
982
+ isOpen && "rotate-180"
983
+ )}
984
+ />
985
+ )}
986
+ {variant === SidebarGroupLabelVariant.ACTION && (
987
+ <Plus className="size-4 shrink-0" />
988
+ )}
989
+ </Comp>
990
+ );
991
+ }
992
+ );
993
+ SidebarGroupLabel.displayName = "SidebarGroupLabel";
994
+
995
+ /**
996
+ * Props for the SidebarGroupAction component
997
+ */
998
+ interface SidebarGroupActionProps extends React.ComponentProps<"button"> {
999
+ /**
1000
+ * Data hook for automated testing (REQUIRED)
1001
+ * Used to identify component in tests and E2E automation
1002
+ */
1003
+ dataHook: string;
1004
+ /**
1005
+ * Tracking element identifier for analytics
1006
+ * Defaults to "sidebar-group-action" if not provided
1007
+ */
1008
+ trackingEl?: string;
1009
+ /**
1010
+ * Tracking label for analytics context
1011
+ */
1012
+ trackingLabel?: string;
1013
+ /**
1014
+ * Render as a different element (Radix Slot pattern)
1015
+ */
1016
+ asChild?: boolean;
1017
+ }
1018
+
1019
+ const SidebarGroupAction = React.forwardRef<
1020
+ HTMLButtonElement,
1021
+ SidebarGroupActionProps
1022
+ >(
1023
+ (
1024
+ {
1025
+ dataHook,
1026
+ trackingEl,
1027
+ trackingLabel,
1028
+ className,
1029
+ asChild = false,
1030
+ ...props
1031
+ },
1032
+ ref
1033
+ ) => {
1034
+ const Comp = asChild ? Slot : "button";
1035
+
1036
+ return (
1037
+ <Comp
1038
+ ref={ref}
1039
+ className={cn(
1040
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
1041
+ // Increases the hit area of the button on mobile.
1042
+ "after:absolute after:-inset-2 after:md:hidden",
1043
+ "group-data-[collapsible=icon]:hidden",
1044
+ className
1045
+ )}
1046
+ data-hook={dataHook}
1047
+ data-slot="sidebar-group-action"
1048
+ data-tracking-el={trackingEl || "sidebar-group-action"}
1049
+ data-tracking-label={trackingLabel}
1050
+ {...props}
1051
+ />
1052
+ );
1053
+ }
1054
+ );
1055
+ SidebarGroupAction.displayName = "SidebarGroupAction";
1056
+
1057
+ /**
1058
+ * Props for the SidebarGroupContent component
1059
+ */
1060
+ interface SidebarGroupContentProps extends React.ComponentProps<"div"> {
1061
+ /**
1062
+ * Data hook for automated testing (REQUIRED)
1063
+ * Used to identify component in tests and E2E automation
1064
+ */
1065
+ dataHook: string;
1066
+ /**
1067
+ * Tracking element identifier for analytics
1068
+ * Defaults to "sidebar-group-content" if not provided
1069
+ */
1070
+ trackingEl?: string;
1071
+ /**
1072
+ * Tracking label for analytics context
1073
+ */
1074
+ trackingLabel?: string;
1075
+ }
1076
+
1077
+ const SidebarGroupContent = React.forwardRef<
1078
+ HTMLDivElement,
1079
+ SidebarGroupContentProps
1080
+ >(({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => (
1081
+ <div
1082
+ ref={ref}
1083
+ className={cn("w-full text-sm", className)}
1084
+ data-hook={dataHook}
1085
+ data-slot="sidebar-group-content"
1086
+ data-tracking-el={trackingEl || "sidebar-group-content"}
1087
+ data-tracking-label={trackingLabel}
1088
+ {...props}
1089
+ />
1090
+ ));
1091
+ SidebarGroupContent.displayName = "SidebarGroupContent";
1092
+
1093
+ /**
1094
+ * Props for the SidebarMenu component
1095
+ */
1096
+ interface SidebarMenuProps extends React.ComponentProps<"ul"> {
1097
+ /**
1098
+ * Data hook for automated testing (REQUIRED)
1099
+ * Used to identify component in tests and E2E automation
1100
+ */
1101
+ dataHook: string;
1102
+ /**
1103
+ * Tracking element identifier for analytics
1104
+ * Defaults to "sidebar-menu" if not provided
1105
+ */
1106
+ trackingEl?: string;
1107
+ /**
1108
+ * Tracking label for analytics context
1109
+ */
1110
+ trackingLabel?: string;
1111
+ }
1112
+
1113
+ const SidebarMenu = React.forwardRef<HTMLUListElement, SidebarMenuProps>(
1114
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => (
1115
+ <ul
1116
+ ref={ref}
1117
+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}
1118
+ data-hook={dataHook}
1119
+ data-slot="sidebar-menu"
1120
+ data-tracking-el={trackingEl || "sidebar-menu"}
1121
+ data-tracking-label={trackingLabel}
1122
+ {...props}
1123
+ />
1124
+ )
1125
+ );
1126
+ SidebarMenu.displayName = "SidebarMenu";
1127
+
1128
+ /**
1129
+ * Props for the SidebarMenuItem component
1130
+ */
1131
+ interface SidebarMenuItemProps extends React.ComponentProps<"li"> {
1132
+ /**
1133
+ * Data hook for automated testing (REQUIRED)
1134
+ * Used to identify component in tests and E2E automation
1135
+ */
1136
+ dataHook: string;
1137
+ /**
1138
+ * Tracking element identifier for analytics
1139
+ * Defaults to "sidebar-menu-item" if not provided
1140
+ */
1141
+ trackingEl?: string;
1142
+ /**
1143
+ * Tracking label for analytics context
1144
+ */
1145
+ trackingLabel?: string;
1146
+ }
1147
+
1148
+ const SidebarMenuItem = React.forwardRef<HTMLLIElement, SidebarMenuItemProps>(
1149
+ ({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => (
1150
+ <li
1151
+ ref={ref}
1152
+ className={cn("group/menu-item relative", className)}
1153
+ data-hook={dataHook}
1154
+ data-slot="sidebar-menu-item"
1155
+ data-tracking-el={trackingEl || "sidebar-menu-item"}
1156
+ data-tracking-label={trackingLabel}
1157
+ {...props}
1158
+ />
1159
+ )
1160
+ );
1161
+ SidebarMenuItem.displayName = "SidebarMenuItem";
1162
+
1163
+ /**
1164
+ * Props for the SidebarCollapseIcon component
1165
+ */
1166
+ interface SidebarCollapseIconProps extends React.ComponentProps<"svg"> {
1167
+ /**
1168
+ * Data hook for automated testing (REQUIRED)
1169
+ * Used to identify component in tests and E2E automation
1170
+ */
1171
+ dataHook: string;
1172
+ /**
1173
+ * Tracking element identifier for analytics
1174
+ * Defaults to "sidebar-collapse-icon" if not provided
1175
+ */
1176
+ trackingEl?: string;
1177
+ /**
1178
+ * Tracking label for analytics context
1179
+ */
1180
+ trackingLabel?: string;
1181
+ /**
1182
+ * Icon type variant
1183
+ * @default SidebarCollapseIconType.CARET
1184
+ */
1185
+ type?: SidebarCollapseIconType;
1186
+ /**
1187
+ * Whether the icon is in active/open state
1188
+ */
1189
+ isActive?: boolean;
1190
+ }
1191
+
1192
+ const SidebarCollapseIcon = React.forwardRef<
1193
+ SVGSVGElement,
1194
+ SidebarCollapseIconProps
1195
+ >(
1196
+ (
1197
+ {
1198
+ dataHook,
1199
+ trackingEl,
1200
+ trackingLabel,
1201
+ type = SidebarCollapseIconType.CARET,
1202
+ isActive = false,
1203
+ className,
1204
+ ...props
1205
+ },
1206
+ ref
1207
+ ) => {
1208
+ const iconProps = {
1209
+ ref,
1210
+ className: cn(
1211
+ "size-4 shrink-0 transition-transform",
1212
+ isActive && type === SidebarCollapseIconType.CARET && "rotate-90",
1213
+ className
1214
+ ),
1215
+ "data-hook": dataHook,
1216
+ "data-slot": "sidebar-collapse-icon",
1217
+ "data-tracking-el": trackingEl || "sidebar-collapse-icon",
1218
+ "data-tracking-label": trackingLabel,
1219
+ ...props,
1220
+ };
1221
+
1222
+ switch (type) {
1223
+ case SidebarCollapseIconType.HORIZONTAL:
1224
+ return <ChevronRight {...iconProps} />;
1225
+ case SidebarCollapseIconType.VERTICAL:
1226
+ return <ChevronDown {...iconProps} />;
1227
+ case SidebarCollapseIconType.UP_DOWN:
1228
+ return <ChevronsUpDown {...iconProps} />;
1229
+ case SidebarCollapseIconType.PLUS_MINUS:
1230
+ return isActive ? <Minus {...iconProps} /> : <Plus {...iconProps} />;
1231
+ case SidebarCollapseIconType.DOTS:
1232
+ return <Ellipsis {...iconProps} />;
1233
+ case SidebarCollapseIconType.CARET:
1234
+ default:
1235
+ return <ChevronRight {...iconProps} />;
1236
+ }
1237
+ }
1238
+ );
1239
+ SidebarCollapseIcon.displayName = "SidebarCollapseIcon";
1240
+
1241
+ const sidebarMenuButtonVariants = cva(
1242
+ "peer/menu-button flex w-full items-center gap-3 overflow-hidden rounded-full px-6 py-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:rounded-md [&>span:last-child]:truncate [&>svg]:size-4.5 [&>svg]:shrink-0 [&>svg]:stroke-2 [&>svg]:opacity-70 data-[active=true]:[&>svg]:opacity-100 group-data-[collapsible=icon]:[&>span]:hidden group-data-[collapsible=icon]:[&>div]:hidden",
1243
+ {
1244
+ variants: {
1245
+ variant: {
1246
+ // Simple - basic menu item with icon and text
1247
+ simple: "",
1248
+ // Collapsible - has a chevron indicator that rotates when open
1249
+ collapsible:
1250
+ "[&>[data-collapse-icon]]:ml-auto [&>[data-collapse-icon]]:transition-transform data-[state=open]:[&>[data-collapse-icon]]:rotate-90",
1251
+ // Dropdown - has action menu (dots) on hover
1252
+ dropdown: "group-has-[[data-sidebar=menu-action]]/menu-item:pr-8",
1253
+ // Tree - has a chevron for tree navigation
1254
+ tree: "[&>[data-tree-icon]]:size-4 [&>[data-tree-icon]]:shrink-0 [&>[data-tree-icon]]:opacity-70 [&>[data-tree-icon]]:transition-transform data-[state=open]:[&>[data-tree-icon]]:rotate-90 group-data-[collapsible=icon]:[&>[data-tree-icon]]:hidden",
1255
+ // Badge - has a number badge on the right (handled via SidebarMenuBadge)
1256
+ badge: "group-has-[[data-sidebar=menu-badge]]/menu-item:pr-8",
1257
+ // Big Icon - larger icon with title and subtitle
1258
+ bigIcon:
1259
+ "h-auto flex-col items-start gap-1 rounded-lg p-3 [&>svg]:size-6 [&>svg]:rounded-md [&>svg]:bg-sidebar-foreground [&>svg]:p-1 [&>svg]:text-sidebar [&>svg]:opacity-100 hover:[&>svg]:bg-sidebar-foreground hover:[&>svg]:text-sidebar group-data-[collapsible=icon]:!size-10 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:[&>svg]:size-6",
1260
+ // Checkbox - has a checkbox indicator
1261
+ checkbox:
1262
+ "[&>[data-checkbox]]:size-4 [&>[data-checkbox]]:shrink-0 [&>[data-checkbox]]:rounded [&>[data-checkbox]]:border [&>[data-checkbox]]:border-sidebar-foreground/30 data-[checked=true]:[&>[data-checkbox]]:bg-primary data-[checked=true]:[&>[data-checkbox]]:border-primary data-[checked=true]:[&>[data-checkbox]]:text-primary-foreground",
1263
+ },
1264
+ size: {
1265
+ default: "h-8 text-sm",
1266
+ sm: "h-7 text-xs",
1267
+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
1268
+ },
1269
+ },
1270
+ defaultVariants: {
1271
+ variant: "simple",
1272
+ size: "default",
1273
+ },
1274
+ }
1275
+ );
1276
+
1277
+ /**
1278
+ * Props for the SidebarMenuButton component
1279
+ */
1280
+ interface SidebarMenuButtonProps
1281
+ extends
1282
+ React.ComponentProps<"button">,
1283
+ VariantProps<typeof sidebarMenuButtonVariants> {
1284
+ /**
1285
+ * Data hook for automated testing (REQUIRED)
1286
+ * Used to identify component in tests and E2E automation
1287
+ */
1288
+ dataHook: string;
1289
+ /**
1290
+ * Tracking element identifier for analytics
1291
+ * Defaults to "sidebar-menu-button" if not provided
1292
+ */
1293
+ trackingEl?: string;
1294
+ /**
1295
+ * Tracking label for analytics context
1296
+ */
1297
+ trackingLabel?: string;
1298
+ /**
1299
+ * Render as a different element (Radix Slot pattern)
1300
+ */
1301
+ asChild?: boolean;
1302
+ /**
1303
+ * Whether the button is in active state
1304
+ */
1305
+ isActive?: boolean;
1306
+ /**
1307
+ * Tooltip content to show when sidebar is collapsed
1308
+ */
1309
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;
1310
+ /**
1311
+ * Visual/behavior variant
1312
+ * @default SidebarMenuButtonVariant.SIMPLE
1313
+ */
1314
+ variant?: SidebarMenuButtonVariant;
1315
+ /**
1316
+ * Size variant
1317
+ * @default SidebarMenuButtonSize.DEFAULT
1318
+ */
1319
+ size?: SidebarMenuButtonSize;
1320
+ }
1321
+
1322
+ const SidebarMenuButton = React.forwardRef<
1323
+ HTMLButtonElement,
1324
+ SidebarMenuButtonProps
1325
+ >(
1326
+ (
1327
+ {
1328
+ dataHook,
1329
+ trackingEl,
1330
+ trackingLabel,
1331
+ asChild = false,
1332
+ isActive = false,
1333
+ variant = SidebarMenuButtonVariant.SIMPLE,
1334
+ size = SidebarMenuButtonSize.DEFAULT,
1335
+ tooltip,
1336
+ className,
1337
+ ...props
1338
+ },
1339
+ ref
1340
+ ) => {
1341
+ const Comp = asChild ? Slot : "button";
1342
+ const { isMobile, state } = useSidebar();
1343
+
1344
+ const button = (
1345
+ <Comp
1346
+ ref={ref}
1347
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
1348
+ data-active={isActive}
1349
+ data-hook={dataHook}
1350
+ data-size={size}
1351
+ data-slot="sidebar-menu-button"
1352
+ data-tracking-el={trackingEl || "sidebar-menu-button"}
1353
+ data-tracking-label={trackingLabel}
1354
+ data-variant={variant}
1355
+ {...props}
1356
+ />
1357
+ );
1358
+
1359
+ if (!tooltip) {
1360
+ return button;
1361
+ }
1362
+
1363
+ if (typeof tooltip === "string") {
1364
+ tooltip = {
1365
+ children: tooltip,
1366
+ dataHook: `${dataHook}-tooltip`,
1367
+ };
1368
+ }
1369
+
1370
+ return (
1371
+ <Tooltip>
1372
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
1373
+ <TooltipContent
1374
+ hideArrow
1375
+ {...tooltip}
1376
+ align="center"
1377
+ className={cn(
1378
+ "bg-foreground text-background border-none",
1379
+ tooltip.className
1380
+ )}
1381
+ hidden={state !== "collapsed" || isMobile}
1382
+ side="right"
1383
+ sideOffset={8}
1384
+ />
1385
+ </Tooltip>
1386
+ );
1387
+ }
1388
+ );
1389
+ SidebarMenuButton.displayName = "SidebarMenuButton";
1390
+
1391
+ /**
1392
+ * Props for the SidebarMenuAction component
1393
+ */
1394
+ interface SidebarMenuActionProps extends React.ComponentProps<"button"> {
1395
+ /**
1396
+ * Data hook for automated testing (REQUIRED)
1397
+ * Used to identify component in tests and E2E automation
1398
+ */
1399
+ dataHook: string;
1400
+ /**
1401
+ * Tracking element identifier for analytics
1402
+ * Defaults to "sidebar-menu-action" if not provided
1403
+ */
1404
+ trackingEl?: string;
1405
+ /**
1406
+ * Tracking label for analytics context
1407
+ */
1408
+ trackingLabel?: string;
1409
+ /**
1410
+ * Render as a different element (Radix Slot pattern)
1411
+ */
1412
+ asChild?: boolean;
1413
+ /**
1414
+ * Show action only on hover
1415
+ */
1416
+ showOnHover?: boolean;
1417
+ }
1418
+
1419
+ const SidebarMenuAction = React.forwardRef<
1420
+ HTMLButtonElement,
1421
+ SidebarMenuActionProps
1422
+ >(
1423
+ (
1424
+ {
1425
+ dataHook,
1426
+ trackingEl,
1427
+ trackingLabel,
1428
+ className,
1429
+ asChild = false,
1430
+ showOnHover = false,
1431
+ ...props
1432
+ },
1433
+ ref
1434
+ ) => {
1435
+ const Comp = asChild ? Slot : "button";
1436
+
1437
+ return (
1438
+ <Comp
1439
+ ref={ref}
1440
+ className={cn(
1441
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
1442
+ // Increases the hit area of the button on mobile.
1443
+ "after:absolute after:-inset-2 after:md:hidden",
1444
+ "peer-data-[size=sm]/menu-button:top-1",
1445
+ "peer-data-[size=default]/menu-button:top-1.5",
1446
+ "peer-data-[size=lg]/menu-button:top-2.5",
1447
+ "peer-data-[size=bigIcon]/menu-button:top-2.5",
1448
+ "peer-data-[size=tree]/menu-button:top-1.5",
1449
+ "group-data-[collapsible=icon]:hidden",
1450
+ showOnHover &&
1451
+ "peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
1452
+ className
1453
+ )}
1454
+ data-hook={dataHook}
1455
+ data-slot="sidebar-menu-action"
1456
+ data-tracking-el={trackingEl || "sidebar-menu-action"}
1457
+ data-tracking-label={trackingLabel}
1458
+ {...props}
1459
+ />
1460
+ );
1461
+ }
1462
+ );
1463
+ SidebarMenuAction.displayName = "SidebarMenuAction";
1464
+
1465
+ /**
1466
+ * Props for the SidebarMenuBadge component
1467
+ */
1468
+ interface SidebarMenuBadgeProps extends React.ComponentProps<"div"> {
1469
+ /**
1470
+ * Data hook for automated testing (REQUIRED)
1471
+ * Used to identify component in tests and E2E automation
1472
+ */
1473
+ dataHook: string;
1474
+ /**
1475
+ * Tracking element identifier for analytics
1476
+ * Defaults to "sidebar-menu-badge" if not provided
1477
+ */
1478
+ trackingEl?: string;
1479
+ /**
1480
+ * Tracking label for analytics context
1481
+ */
1482
+ trackingLabel?: string;
1483
+ }
1484
+
1485
+ const SidebarMenuBadge = React.forwardRef<
1486
+ HTMLDivElement,
1487
+ SidebarMenuBadgeProps
1488
+ >(({ dataHook, trackingEl, trackingLabel, className, ...props }, ref) => (
1489
+ <div
1490
+ ref={ref}
1491
+ className={cn(
1492
+ "text-sidebar-foreground pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums select-none",
1493
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
1494
+ "peer-data-[size=sm]/menu-button:top-1",
1495
+ "peer-data-[size=default]/menu-button:top-1.5",
1496
+ "peer-data-[size=lg]/menu-button:top-2.5",
1497
+ "peer-data-[size=bigIcon]/menu-button:top-2.5",
1498
+ "peer-data-[size=tree]/menu-button:top-1.5",
1499
+ "group-data-[collapsible=icon]:hidden",
1500
+ className
1501
+ )}
1502
+ data-hook={dataHook}
1503
+ data-slot="sidebar-menu-badge"
1504
+ data-tracking-el={trackingEl || "sidebar-menu-badge"}
1505
+ data-tracking-label={trackingLabel}
1506
+ {...props}
1507
+ />
1508
+ ));
1509
+ SidebarMenuBadge.displayName = "SidebarMenuBadge";
1510
+
1511
+ /**
1512
+ * Props for the SidebarMenuSkeleton component
1513
+ */
1514
+ interface SidebarMenuSkeletonProps extends React.ComponentProps<"div"> {
1515
+ /**
1516
+ * Data hook for automated testing (REQUIRED)
1517
+ * Used to identify component in tests and E2E automation
1518
+ */
1519
+ dataHook: string;
1520
+ /**
1521
+ * Tracking element identifier for analytics
1522
+ * Defaults to "sidebar-menu-skeleton" if not provided
1523
+ */
1524
+ trackingEl?: string;
1525
+ /**
1526
+ * Tracking label for analytics context
1527
+ */
1528
+ trackingLabel?: string;
1529
+ /**
1530
+ * Show icon skeleton placeholder
1531
+ */
1532
+ showIcon?: boolean;
1533
+ }
1534
+
1535
+ const SidebarMenuSkeleton = React.forwardRef<
1536
+ HTMLDivElement,
1537
+ SidebarMenuSkeletonProps
1538
+ >(
1539
+ (
1540
+ {
1541
+ dataHook,
1542
+ trackingEl,
1543
+ trackingLabel,
1544
+ className,
1545
+ showIcon = false,
1546
+ ...props
1547
+ },
1548
+ ref
1549
+ ) => {
1550
+ // Generate a stable random-looking width using useId
1551
+ const id = React.useId();
1552
+ const width = React.useMemo(() => {
1553
+ // Simple hash from id to get a deterministic "random" width between 50-90%
1554
+ let hash = 0;
1555
+ for (let i = 0; i < id.length; i++) {
1556
+ hash = (hash << 5) - hash + id.charCodeAt(i);
1557
+ hash |= 0;
1558
+ }
1559
+ return `${(Math.abs(hash) % 40) + 50}%`;
1560
+ }, [id]);
1561
+
1562
+ return (
1563
+ <div
1564
+ ref={ref}
1565
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
1566
+ data-hook={dataHook}
1567
+ data-slot="sidebar-menu-skeleton"
1568
+ data-tracking-el={trackingEl || "sidebar-menu-skeleton"}
1569
+ data-tracking-label={trackingLabel}
1570
+ {...props}
1571
+ >
1572
+ {showIcon && (
1573
+ <Skeleton
1574
+ className="size-4 rounded-md"
1575
+ data-hook={`${dataHook}-icon`}
1576
+ data-slot="sidebar-menu-skeleton-icon"
1577
+ />
1578
+ )}
1579
+ <Skeleton
1580
+ className="h-4 max-w-[--skeleton-width] flex-1"
1581
+ data-hook={`${dataHook}-text`}
1582
+ data-slot="sidebar-menu-skeleton-text"
1583
+ style={
1584
+ {
1585
+ "--skeleton-width": width,
1586
+ } as React.CSSProperties
1587
+ }
1588
+ />
1589
+ </div>
1590
+ );
1591
+ }
1592
+ );
1593
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
1594
+
1595
+ const sidebarMenuSubVariants = cva(
1596
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
1597
+ {
1598
+ variants: {
1599
+ variant: {
1600
+ default: "",
1601
+ border: "border-l border-sidebar-border",
1602
+ indent: "ml-0 border-l-0",
1603
+ },
1604
+ },
1605
+ defaultVariants: {
1606
+ variant: "border",
1607
+ },
1608
+ }
1609
+ );
1610
+
1611
+ /**
1612
+ * Props for the SidebarMenuSub component
1613
+ */
1614
+ interface SidebarMenuSubProps
1615
+ extends
1616
+ React.ComponentProps<"ul">,
1617
+ VariantProps<typeof sidebarMenuSubVariants> {
1618
+ /**
1619
+ * Data hook for automated testing (REQUIRED)
1620
+ * Used to identify component in tests and E2E automation
1621
+ */
1622
+ dataHook: string;
1623
+ /**
1624
+ * Tracking element identifier for analytics
1625
+ * Defaults to "sidebar-menu-sub" if not provided
1626
+ */
1627
+ trackingEl?: string;
1628
+ /**
1629
+ * Tracking label for analytics context
1630
+ */
1631
+ trackingLabel?: string;
1632
+ /**
1633
+ * Visual variant
1634
+ * @default SidebarMenuSubVariant.BORDER
1635
+ */
1636
+ variant?: SidebarMenuSubVariant;
1637
+ }
1638
+
1639
+ const SidebarMenuSub = React.forwardRef<HTMLUListElement, SidebarMenuSubProps>(
1640
+ (
1641
+ {
1642
+ dataHook,
1643
+ trackingEl,
1644
+ trackingLabel,
1645
+ className,
1646
+ variant = SidebarMenuSubVariant.BORDER,
1647
+ ...props
1648
+ },
1649
+ ref
1650
+ ) => (
1651
+ <ul
1652
+ ref={ref}
1653
+ className={cn(sidebarMenuSubVariants({ variant }), className)}
1654
+ data-hook={dataHook}
1655
+ data-slot="sidebar-menu-sub"
1656
+ data-tracking-el={trackingEl || "sidebar-menu-sub"}
1657
+ data-tracking-label={trackingLabel}
1658
+ {...props}
1659
+ />
1660
+ )
1661
+ );
1662
+ SidebarMenuSub.displayName = "SidebarMenuSub";
1663
+
1664
+ /**
1665
+ * Props for the SidebarMenuSubItem component
1666
+ */
1667
+ interface SidebarMenuSubItemProps extends React.ComponentProps<"li"> {
1668
+ /**
1669
+ * Data hook for automated testing (REQUIRED)
1670
+ * Used to identify component in tests and E2E automation
1671
+ */
1672
+ dataHook: string;
1673
+ /**
1674
+ * Tracking element identifier for analytics
1675
+ * Defaults to "sidebar-menu-sub-item" if not provided
1676
+ */
1677
+ trackingEl?: string;
1678
+ /**
1679
+ * Tracking label for analytics context
1680
+ */
1681
+ trackingLabel?: string;
1682
+ }
1683
+
1684
+ const SidebarMenuSubItem = React.forwardRef<
1685
+ HTMLLIElement,
1686
+ SidebarMenuSubItemProps
1687
+ >(({ dataHook, trackingEl, trackingLabel, ...props }, ref) => (
1688
+ <li
1689
+ ref={ref}
1690
+ data-hook={dataHook}
1691
+ data-slot="sidebar-menu-sub-item"
1692
+ data-tracking-el={trackingEl || "sidebar-menu-sub-item"}
1693
+ data-tracking-label={trackingLabel}
1694
+ {...props}
1695
+ />
1696
+ ));
1697
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
1698
+
1699
+ /**
1700
+ * Props for the SidebarMenuSubButton component
1701
+ */
1702
+ interface SidebarMenuSubButtonProps extends React.ComponentProps<"a"> {
1703
+ /**
1704
+ * Data hook for automated testing (REQUIRED)
1705
+ * Used to identify component in tests and E2E automation
1706
+ */
1707
+ dataHook: string;
1708
+ /**
1709
+ * Tracking element identifier for analytics
1710
+ * Defaults to "sidebar-menu-sub-button" if not provided
1711
+ */
1712
+ trackingEl?: string;
1713
+ /**
1714
+ * Tracking label for analytics context
1715
+ */
1716
+ trackingLabel?: string;
1717
+ /**
1718
+ * Render as a different element (Radix Slot pattern)
1719
+ */
1720
+ asChild?: boolean;
1721
+ /**
1722
+ * Size variant
1723
+ * @default SidebarMenuSubButtonSize.MD
1724
+ */
1725
+ size?: SidebarMenuSubButtonSize;
1726
+ /**
1727
+ * Whether the button is in active state
1728
+ */
1729
+ isActive?: boolean;
1730
+ }
1731
+
1732
+ const SidebarMenuSubButton = React.forwardRef<
1733
+ HTMLAnchorElement,
1734
+ SidebarMenuSubButtonProps
1735
+ >(
1736
+ (
1737
+ {
1738
+ dataHook,
1739
+ trackingEl,
1740
+ trackingLabel,
1741
+ asChild = false,
1742
+ size = SidebarMenuSubButtonSize.MD,
1743
+ isActive,
1744
+ className,
1745
+ ...props
1746
+ },
1747
+ ref
1748
+ ) => {
1749
+ const Comp = asChild ? Slot : "a";
1750
+
1751
+ return (
1752
+ <Comp
1753
+ ref={ref}
1754
+ className={cn(
1755
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
1756
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
1757
+ size === SidebarMenuSubButtonSize.SM && "text-xs",
1758
+ size === SidebarMenuSubButtonSize.MD && "text-sm",
1759
+ "group-data-[collapsible=icon]:hidden",
1760
+ className
1761
+ )}
1762
+ data-active={isActive}
1763
+ data-hook={dataHook}
1764
+ data-size={size}
1765
+ data-slot="sidebar-menu-sub-button"
1766
+ data-tracking-el={trackingEl || "sidebar-menu-sub-button"}
1767
+ data-tracking-label={trackingLabel}
1768
+ {...props}
1769
+ />
1770
+ );
1771
+ }
1772
+ );
1773
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
1774
+
1775
+ // Component exports
1776
+ export {
1777
+ Sidebar,
1778
+ SidebarCollapseIcon,
1779
+ SidebarContent,
1780
+ SidebarFooter,
1781
+ SidebarGroup,
1782
+ SidebarGroupAction,
1783
+ SidebarGroupContent,
1784
+ SidebarGroupLabel,
1785
+ SidebarHeader,
1786
+ SidebarInput,
1787
+ SidebarInset,
1788
+ SidebarMenu,
1789
+ SidebarMenuAction,
1790
+ SidebarMenuBadge,
1791
+ SidebarMenuButton,
1792
+ SidebarMenuItem,
1793
+ SidebarMenuSkeleton,
1794
+ SidebarMenuSub,
1795
+ SidebarMenuSubButton,
1796
+ SidebarMenuSubItem,
1797
+ SidebarProvider,
1798
+ SidebarRail,
1799
+ SidebarSeparator,
1800
+ SidebarTrigger,
1801
+ useSidebar,
1802
+ };
1803
+
1804
+ // Type exports
1805
+ export type {
1806
+ SidebarProviderProps,
1807
+ SidebarProps,
1808
+ SidebarTriggerProps,
1809
+ SidebarRailProps,
1810
+ SidebarInsetProps,
1811
+ SidebarInputProps,
1812
+ SidebarHeaderProps,
1813
+ SidebarFooterProps,
1814
+ SidebarSeparatorProps,
1815
+ SidebarContentProps,
1816
+ SidebarGroupProps,
1817
+ SidebarGroupLabelProps,
1818
+ SidebarGroupActionProps,
1819
+ SidebarGroupContentProps,
1820
+ SidebarMenuProps,
1821
+ SidebarMenuItemProps,
1822
+ SidebarCollapseIconProps,
1823
+ SidebarMenuButtonProps,
1824
+ SidebarMenuActionProps,
1825
+ SidebarMenuBadgeProps,
1826
+ SidebarMenuSkeletonProps,
1827
+ SidebarMenuSubProps,
1828
+ SidebarMenuSubItemProps,
1829
+ SidebarMenuSubButtonProps,
1830
+ };