@trackany-device/components 1.0.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 (289) hide show
  1. package/package.json +185 -0
  2. package/src/assets/logo.png +0 -0
  3. package/src/assets/map/arrows/map-arrow-blue.png +0 -0
  4. package/src/assets/map/arrows/map-arrow-green.png +0 -0
  5. package/src/assets/map/arrows/map-arrow-purple.png +0 -0
  6. package/src/assets/map/arrows/map-arrow-red.png +0 -0
  7. package/src/assets/map/flags/flag-blue.png +0 -0
  8. package/src/assets/map/flags/flag-green.png +0 -0
  9. package/src/assets/map/flags/flag-red.png +0 -0
  10. package/src/assets/map/flags/flag-yellow.png +0 -0
  11. package/src/assets/map/pins/map-pin-blue.png +0 -0
  12. package/src/assets/map/pins/map-pin-green.png +0 -0
  13. package/src/assets/map/pins/map-pin-purple.png +0 -0
  14. package/src/assets/map/pins/map-pin-red.png +0 -0
  15. package/src/components/Card.tsx +9 -0
  16. package/src/components/alert-error.tsx +24 -0
  17. package/src/components/app-content.tsx +22 -0
  18. package/src/components/app-header.tsx +153 -0
  19. package/src/components/app-logo-icon.tsx +13 -0
  20. package/src/components/app-logo.tsx +21 -0
  21. package/src/components/app-shell.tsx +19 -0
  22. package/src/components/app-sidebar-header.tsx +68 -0
  23. package/src/components/app-sidebar.tsx +106 -0
  24. package/src/components/appearance-tabs.tsx +46 -0
  25. package/src/components/breadcrumbs.tsx +50 -0
  26. package/src/components/cms/blurred-image.tsx +111 -0
  27. package/src/components/cms/section-bg.tsx +473 -0
  28. package/src/components/cms/section-button.tsx +127 -0
  29. package/src/components/cms/sections/banner-5050-section.tsx +135 -0
  30. package/src/components/cms/sections/blogs-listing-section.tsx +270 -0
  31. package/src/components/cms/sections/cards-grid-section.tsx +185 -0
  32. package/src/components/cms/sections/contact-form-section.tsx +157 -0
  33. package/src/components/cms/sections/cta-section.tsx +101 -0
  34. package/src/components/cms/sections/featured-blog-slider-section.tsx +256 -0
  35. package/src/components/cms/sections/featured-products-grid-section.tsx +173 -0
  36. package/src/components/cms/sections/featured-solutions-grid-section.tsx +183 -0
  37. package/src/components/cms/sections/hero-section.tsx +180 -0
  38. package/src/components/cms/sections/solutions-with-filter-section.tsx +234 -0
  39. package/src/components/cms/sections/text-section.tsx +77 -0
  40. package/src/components/cutout-image.tsx +228 -0
  41. package/src/components/devices/devices-mini-map.tsx +275 -0
  42. package/src/components/docs/docs-shell.tsx +280 -0
  43. package/src/components/fleet-hero-animated.tsx +383 -0
  44. package/src/components/input-error.tsx +17 -0
  45. package/src/components/keenicons/assets/duotone/Read Me.txt +7 -0
  46. package/src/components/keenicons/assets/duotone/demo-files/demo.css +160 -0
  47. package/src/components/keenicons/assets/duotone/demo-files/demo.js +32 -0
  48. package/src/components/keenicons/assets/duotone/demo.html +12424 -0
  49. package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.svg +1109 -0
  50. package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.ttf +0 -0
  51. package/src/components/keenicons/assets/duotone/fonts/keenicons-duotone.woff +0 -0
  52. package/src/components/keenicons/assets/duotone/selection.json +17313 -0
  53. package/src/components/keenicons/assets/duotone/style.css +4931 -0
  54. package/src/components/keenicons/assets/filled/Read Me.txt +7 -0
  55. package/src/components/keenicons/assets/filled/demo-files/demo.css +160 -0
  56. package/src/components/keenicons/assets/filled/demo-files/demo.js +32 -0
  57. package/src/components/keenicons/assets/filled/demo.html +12370 -0
  58. package/src/components/keenicons/assets/filled/fonts/keenicons-filled.svg +1082 -0
  59. package/src/components/keenicons/assets/filled/fonts/keenicons-filled.ttf +0 -0
  60. package/src/components/keenicons/assets/filled/fonts/keenicons-filled.woff +0 -0
  61. package/src/components/keenicons/assets/filled/selection.json +17096 -0
  62. package/src/components/keenicons/assets/filled/style.css +4769 -0
  63. package/src/components/keenicons/assets/outline/Read Me.txt +7 -0
  64. package/src/components/keenicons/assets/outline/demo-files/demo.css +160 -0
  65. package/src/components/keenicons/assets/outline/demo-files/demo.js +32 -0
  66. package/src/components/keenicons/assets/outline/demo.html +11356 -0
  67. package/src/components/keenicons/assets/outline/fonts/keenicons-outline.svg +575 -0
  68. package/src/components/keenicons/assets/outline/fonts/keenicons-outline.ttf +0 -0
  69. package/src/components/keenicons/assets/outline/fonts/keenicons-outline.woff +0 -0
  70. package/src/components/keenicons/assets/outline/selection.json +13054 -0
  71. package/src/components/keenicons/assets/outline/style.css +1721 -0
  72. package/src/components/keenicons/assets/solid/Read Me.txt +7 -0
  73. package/src/components/keenicons/assets/solid/demo-files/demo.css +160 -0
  74. package/src/components/keenicons/assets/solid/demo-files/demo.js +32 -0
  75. package/src/components/keenicons/assets/solid/demo.html +11356 -0
  76. package/src/components/keenicons/assets/solid/fonts/keenicons-solid.svg +575 -0
  77. package/src/components/keenicons/assets/solid/fonts/keenicons-solid.ttf +0 -0
  78. package/src/components/keenicons/assets/solid/fonts/keenicons-solid.woff +0 -0
  79. package/src/components/keenicons/assets/solid/selection.json +13048 -0
  80. package/src/components/keenicons/assets/solid/style.css +1721 -0
  81. package/src/components/keenicons/assets/styles.css +4 -0
  82. package/src/components/keenicons/index.ts +2 -0
  83. package/src/components/keenicons/keenicons.tsx +16 -0
  84. package/src/components/keenicons/types.ts +7 -0
  85. package/src/components/nav-footer.tsx +49 -0
  86. package/src/components/nav-main.tsx +53 -0
  87. package/src/components/nav-user.tsx +59 -0
  88. package/src/components/notification-bell.tsx +190 -0
  89. package/src/components/products/product-card.tsx +159 -0
  90. package/src/components/text-link.tsx +23 -0
  91. package/src/components/ui/accordion-menu.tsx +322 -0
  92. package/src/components/ui/accordion.tsx +133 -0
  93. package/src/components/ui/alert-dialog.tsx +82 -0
  94. package/src/components/ui/alert.tsx +63 -0
  95. package/src/components/ui/avatar-group.tsx +129 -0
  96. package/src/components/ui/avatar.tsx +67 -0
  97. package/src/components/ui/badge.tsx +230 -0
  98. package/src/components/ui/breadcrumb.tsx +88 -0
  99. package/src/components/ui/button.tsx +412 -0
  100. package/src/components/ui/calendar.tsx +56 -0
  101. package/src/components/ui/card.tsx +147 -0
  102. package/src/components/ui/chart.tsx +290 -0
  103. package/src/components/ui/checkbox.tsx +47 -0
  104. package/src/components/ui/code.tsx +45 -0
  105. package/src/components/ui/collapsible.tsx +31 -0
  106. package/src/components/ui/command-palette.tsx +189 -0
  107. package/src/components/ui/command.tsx +138 -0
  108. package/src/components/ui/cookie-banner.tsx +220 -0
  109. package/src/components/ui/copy-button.tsx +60 -0
  110. package/src/components/ui/data-grid-column-filter.tsx +124 -0
  111. package/src/components/ui/data-grid-column-header.tsx +284 -0
  112. package/src/components/ui/data-grid-column-visibility.tsx +38 -0
  113. package/src/components/ui/data-grid-pagination.tsx +206 -0
  114. package/src/components/ui/data-grid-table-dnd-rows.tsx +147 -0
  115. package/src/components/ui/data-grid-table-dnd.tsx +175 -0
  116. package/src/components/ui/data-grid-table.tsx +500 -0
  117. package/src/components/ui/data-grid.tsx +193 -0
  118. package/src/components/ui/data-list.tsx +76 -0
  119. package/src/components/ui/datefield.tsx +91 -0
  120. package/src/components/ui/dialog.tsx +139 -0
  121. package/src/components/ui/divider.tsx +41 -0
  122. package/src/components/ui/drawer.tsx +59 -0
  123. package/src/components/ui/dropdown-menu.tsx +224 -0
  124. package/src/components/ui/empty-state.tsx +54 -0
  125. package/src/components/ui/file-upload.tsx +152 -0
  126. package/src/components/ui/form.tsx +88 -0
  127. package/src/components/ui/icon.tsx +14 -0
  128. package/src/components/ui/input-otp.tsx +71 -0
  129. package/src/components/ui/input.tsx +155 -0
  130. package/src/components/ui/kbd.tsx +26 -0
  131. package/src/components/ui/label.tsx +31 -0
  132. package/src/components/ui/navigation-menu.tsx +168 -0
  133. package/src/components/ui/pagination.tsx +37 -0
  134. package/src/components/ui/placeholder-pattern.tsx +21 -0
  135. package/src/components/ui/popover.tsx +50 -0
  136. package/src/components/ui/progress.tsx +65 -0
  137. package/src/components/ui/radio-group.tsx +73 -0
  138. package/src/components/ui/resizable.tsx +39 -0
  139. package/src/components/ui/scroll-area.tsx +50 -0
  140. package/src/components/ui/select.tsx +234 -0
  141. package/src/components/ui/separator.tsx +24 -0
  142. package/src/components/ui/sheet.tsx +147 -0
  143. package/src/components/ui/sidebar.tsx +721 -0
  144. package/src/components/ui/skeleton.tsx +15 -0
  145. package/src/components/ui/slider.tsx +35 -0
  146. package/src/components/ui/sonner.tsx +28 -0
  147. package/src/components/ui/sortable.tsx +724 -0
  148. package/src/components/ui/spinner.tsx +17 -0
  149. package/src/components/ui/stat-card.tsx +82 -0
  150. package/src/components/ui/stepper.tsx +410 -0
  151. package/src/components/ui/switch.tsx +68 -0
  152. package/src/components/ui/table.tsx +42 -0
  153. package/src/components/ui/tabs.tsx +196 -0
  154. package/src/components/ui/timeline.tsx +90 -0
  155. package/src/components/ui/toggle-group.tsx +73 -0
  156. package/src/components/ui/toggle.tsx +45 -0
  157. package/src/components/ui/tooltip.tsx +55 -0
  158. package/src/components/user-info.tsx +33 -0
  159. package/src/components/user-menu-content.tsx +53 -0
  160. package/src/components/web/SiteFooter.tsx +154 -0
  161. package/src/components/web/SiteHeader.tsx +159 -0
  162. package/src/components/workflows/workflow-canvas.tsx +321 -0
  163. package/src/controls/Blockquote.tsx +25 -0
  164. package/src/controls/Button.tsx +101 -0
  165. package/src/controls/Checkbox.tsx +29 -0
  166. package/src/controls/DateField.tsx +37 -0
  167. package/src/controls/FormField.tsx +20 -0
  168. package/src/controls/Heading.tsx +28 -0
  169. package/src/controls/Input.tsx +21 -0
  170. package/src/controls/Label.tsx +18 -0
  171. package/src/controls/Paragraph.tsx +39 -0
  172. package/src/controls/PasswordInput.tsx +40 -0
  173. package/src/controls/RadioGroup.tsx +70 -0
  174. package/src/controls/Select.tsx +24 -0
  175. package/src/controls/Slider.tsx +33 -0
  176. package/src/controls/Switch.tsx +31 -0
  177. package/src/controls/Textarea.tsx +22 -0
  178. package/src/elements/ConfirmPasswordForm.tsx +43 -0
  179. package/src/elements/DeviceStatusBadge.tsx +38 -0
  180. package/src/elements/DriverCard.tsx +67 -0
  181. package/src/elements/ForgotPasswordForm.tsx +64 -0
  182. package/src/elements/IncidentCard.tsx +67 -0
  183. package/src/elements/LoginForm.tsx +100 -0
  184. package/src/elements/OtpForm.tsx +71 -0
  185. package/src/elements/RegisterForm.tsx +150 -0
  186. package/src/elements/ResetPasswordForm.tsx +72 -0
  187. package/src/elements/SmsChallengeForm.tsx +104 -0
  188. package/src/elements/VehicleCard.tsx +73 -0
  189. package/src/elements/VerifyEmailForm.tsx +39 -0
  190. package/src/hooks/use-appearance.tsx +117 -0
  191. package/src/hooks/use-applied-theme.ts +98 -0
  192. package/src/hooks/use-clipboard.ts +34 -0
  193. package/src/hooks/use-current-url.ts +83 -0
  194. package/src/hooks/use-dark-mode.ts +48 -0
  195. package/src/hooks/use-flash-toast.ts +29 -0
  196. package/src/hooks/use-initials.tsx +24 -0
  197. package/src/hooks/use-mobile-navigation.ts +12 -0
  198. package/src/hooks/use-mobile.tsx +38 -0
  199. package/src/index.ts +408 -0
  200. package/src/layouts/AppLayout.tsx +60 -0
  201. package/src/layouts/AuthLayout.tsx +32 -0
  202. package/src/layouts/SettingsLayout.tsx +21 -0
  203. package/src/layouts/app/AIChatLayout.tsx +73 -0
  204. package/src/layouts/app/AsideSidebarLayout.tsx +3 -0
  205. package/src/layouts/app/CalendarSidebarLayout.tsx +69 -0
  206. package/src/layouts/app/CommunitiesNavbarLayout.tsx +3 -0
  207. package/src/layouts/app/DualNavbarSidebarLayout.tsx +3 -0
  208. package/src/layouts/app/FocusSidebarLayout.tsx +75 -0
  209. package/src/layouts/app/MailLayout.tsx +69 -0
  210. package/src/layouts/app/MegaMenuHeaderLayout.tsx +3 -0
  211. package/src/layouts/app/MegaMenuLayout.tsx +81 -0
  212. package/src/layouts/app/MegaMenuNavbarLayout.tsx +88 -0
  213. package/src/layouts/app/MegaMenuSearchNavbarLayout.tsx +3 -0
  214. package/src/layouts/app/NavbarCollapsibleLayout.tsx +88 -0
  215. package/src/layouts/app/NavbarCollapsibleLinksLayout.tsx +3 -0
  216. package/src/layouts/app/NavbarMinimalLayout.tsx +3 -0
  217. package/src/layouts/app/NavbarMinimalSidebarLayout.tsx +3 -0
  218. package/src/layouts/app/NavbarSidebarDashboardLayout.tsx +3 -0
  219. package/src/layouts/app/NavbarSidebarLayout.tsx +92 -0
  220. package/src/layouts/app/NavbarSimpleSidebarLayout.tsx +3 -0
  221. package/src/layouts/app/NavbarTitledSidebarLayout.tsx +3 -0
  222. package/src/layouts/app/PanelSidebarLayout.tsx +3 -0
  223. package/src/layouts/app/SearchNavbarSidebarLayout.tsx +3 -0
  224. package/src/layouts/app/SidebarBreadcrumbLayout.tsx +3 -0
  225. package/src/layouts/app/SidebarCleanLayout.tsx +3 -0
  226. package/src/layouts/app/SidebarCommunitiesLayout.tsx +3 -0
  227. package/src/layouts/app/SidebarContentLayout.tsx +3 -0
  228. package/src/layouts/app/SidebarDualMenuLayout.tsx +104 -0
  229. package/src/layouts/app/SidebarFixedLayout.tsx +166 -0
  230. package/src/layouts/app/SidebarFooterNavbarLayout.tsx +3 -0
  231. package/src/layouts/app/SidebarHeaderMenuLayout.tsx +3 -0
  232. package/src/layouts/app/SidebarMegaMenuLayout.tsx +4 -0
  233. package/src/layouts/app/SidebarMinimalLayout.tsx +70 -0
  234. package/src/layouts/app/SidebarMobileSearchLayout.tsx +3 -0
  235. package/src/layouts/app/SidebarMultiPanelLayout.tsx +3 -0
  236. package/src/layouts/app/SidebarPrimarySecondaryLayout.tsx +3 -0
  237. package/src/layouts/app/SidebarSearchHeaderLayout.tsx +103 -0
  238. package/src/layouts/app/SidebarSearchToolbarLayout.tsx +3 -0
  239. package/src/layouts/app/SidebarTabsDualLayout.tsx +3 -0
  240. package/src/layouts/app/SidebarTabsLayout.tsx +98 -0
  241. package/src/layouts/app/SidebarTreeLayout.tsx +3 -0
  242. package/src/layouts/app/SplitNavbarLayout.tsx +3 -0
  243. package/src/layouts/app/SplitSidebarDashboardLayout.tsx +3 -0
  244. package/src/layouts/app/SplitSidebarLayout.tsx +99 -0
  245. package/src/layouts/app/TopNavLayout.tsx +105 -0
  246. package/src/layouts/app/TopNavLinksLayout.tsx +3 -0
  247. package/src/layouts/app/WorkspaceBreadcrumbLayout.tsx +3 -0
  248. package/src/layouts/app/WorkspaceCommunitiesLayout.tsx +3 -0
  249. package/src/layouts/app/WorkspaceNavbarLayout.tsx +3 -0
  250. package/src/layouts/app/WorkspaceSidebarLayout.tsx +98 -0
  251. package/src/layouts/app/WorkspaceSidebarTitleLayout.tsx +3 -0
  252. package/src/layouts/app/app-header-layout.tsx +45 -0
  253. package/src/layouts/app/app-sidebar-layout.tsx +56 -0
  254. package/src/layouts/app/layout-context.tsx +44 -0
  255. package/src/layouts/app/layout-types.ts +47 -0
  256. package/src/layouts/app/partials/Footer.tsx +35 -0
  257. package/src/layouts/app/partials/HeaderTopbar.tsx +96 -0
  258. package/src/layouts/app/partials/Navbar.tsx +85 -0
  259. package/src/layouts/app/partials/Toolbar.tsx +47 -0
  260. package/src/layouts/app-layout.tsx +29 -0
  261. package/src/layouts/auth/AuthBrandedLayout.tsx +58 -0
  262. package/src/layouts/auth/AuthCardLayout.tsx +31 -0
  263. package/src/layouts/auth/AuthCenteredLayout.tsx +41 -0
  264. package/src/layouts/auth/AuthClassicLayout.tsx +41 -0
  265. package/src/layouts/auth/AuthSimpleLayout.tsx +33 -0
  266. package/src/layouts/auth/AuthSplitLayout.tsx +89 -0
  267. package/src/layouts/web-app-layout.tsx +162 -0
  268. package/src/layouts/web-layout.tsx +23 -0
  269. package/src/lib/datetime.ts +188 -0
  270. package/src/lib/google-maps-loader.ts +99 -0
  271. package/src/lib/location.ts +127 -0
  272. package/src/lib/lucide-icon-map.ts +132 -0
  273. package/src/lib/map-markers.ts +124 -0
  274. package/src/lib/map-styles.ts +351 -0
  275. package/src/lib/utils.ts +11 -0
  276. package/src/platform/adapters/default.tsx +156 -0
  277. package/src/platform/adapters/inertia.tsx +88 -0
  278. package/src/platform/adapters/nextjs.ts +86 -0
  279. package/src/platform/context.tsx +106 -0
  280. package/src/platform/index.ts +27 -0
  281. package/src/platform/types.ts +105 -0
  282. package/src/styles/layouts/sidebar-fixed.css +161 -0
  283. package/src/styles/themes.css +583 -0
  284. package/src/types/assets.d.ts +5 -0
  285. package/src/types/auth.ts +25 -0
  286. package/src/types/global.d.ts +13 -0
  287. package/src/types/index.ts +9 -0
  288. package/src/types/navigation.ts +15 -0
  289. package/src/types/ui.ts +32 -0
@@ -0,0 +1,721 @@
1
+ 'use client';
2
+
3
+ import { Slot } from "@radix-ui/react-slot"
4
+ import type { VariantProps} from "class-variance-authority";
5
+ import { cva } from "class-variance-authority"
6
+ import { PanelLeftCloseIcon, PanelLeftOpenIcon } from "lucide-react"
7
+ import * as React from "react"
8
+
9
+ import { Button } from "./button"
10
+ import { Input } from "./input"
11
+ import { Separator } from "./separator"
12
+ import {
13
+ Sheet,
14
+ SheetContent,
15
+ SheetDescription,
16
+ SheetHeader,
17
+ SheetTitle,
18
+ } from "./sheet"
19
+ import { Skeleton } from "./skeleton"
20
+ import {
21
+ Tooltip,
22
+ TooltipContent,
23
+ TooltipTrigger,
24
+ } from "./tooltip"
25
+ import { useIsMobile } from "../../hooks/use-mobile"
26
+ import { cn } from "../../lib/utils"
27
+
28
+ const SIDEBAR_COOKIE_NAME = "sidebar_state"
29
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
30
+ const SIDEBAR_WIDTH = "16rem"
31
+ const SIDEBAR_WIDTH_MOBILE = "18rem"
32
+ const SIDEBAR_WIDTH_ICON = "3rem"
33
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b"
34
+
35
+ type SidebarContext = {
36
+ state: "expanded" | "collapsed"
37
+ open: boolean
38
+ setOpen: (open: boolean) => void
39
+ openMobile: boolean
40
+ setOpenMobile: (open: boolean) => void
41
+ isMobile: boolean
42
+ toggleSidebar: () => void
43
+ }
44
+
45
+ const SidebarContext = React.createContext<SidebarContext | null>(null)
46
+
47
+ function useSidebar() {
48
+ const context = React.useContext(SidebarContext)
49
+ if (!context) {
50
+ throw new Error("useSidebar must be used within a SidebarProvider.")
51
+ }
52
+
53
+ return context
54
+ }
55
+
56
+ function SidebarProvider({
57
+ defaultOpen = true,
58
+ open: openProp,
59
+ onOpenChange: setOpenProp,
60
+ className,
61
+ style,
62
+ children,
63
+ ...props
64
+ }: React.ComponentProps<"div"> & {
65
+ defaultOpen?: boolean
66
+ open?: boolean
67
+ onOpenChange?: (open: boolean) => void
68
+ }) {
69
+ const isMobile = useIsMobile()
70
+ const [openMobile, setOpenMobile] = React.useState(false)
71
+
72
+ // This is the internal state of the sidebar.
73
+ // We use openProp and setOpenProp for control from outside the component.
74
+ const [_open, _setOpen] = React.useState(defaultOpen)
75
+ const open = openProp ?? _open
76
+ const setOpen = React.useCallback(
77
+ (value: boolean | ((value: boolean) => boolean)) => {
78
+ const openState = typeof value === "function" ? value(open) : value
79
+ if (setOpenProp) {
80
+ setOpenProp(openState)
81
+ } else {
82
+ _setOpen(openState)
83
+ }
84
+
85
+ // This sets the cookie to keep the sidebar state.
86
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
87
+ },
88
+ [setOpenProp, open]
89
+ )
90
+
91
+ // Helper to toggle the sidebar.
92
+ const toggleSidebar = React.useCallback(() => {
93
+ return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
94
+ }, [isMobile, setOpen, setOpenMobile])
95
+
96
+ // Adds a keyboard shortcut to toggle the sidebar.
97
+ React.useEffect(() => {
98
+ const handleKeyDown = (event: KeyboardEvent) => {
99
+ if (
100
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
101
+ (event.metaKey || event.ctrlKey)
102
+ ) {
103
+ event.preventDefault()
104
+ toggleSidebar()
105
+ }
106
+ }
107
+
108
+ window.addEventListener("keydown", handleKeyDown)
109
+ return () => window.removeEventListener("keydown", handleKeyDown)
110
+ }, [toggleSidebar])
111
+
112
+ // We add a state so that we can do data-state="expanded" or "collapsed".
113
+ // This makes it easier to style the sidebar with Tailwind classes.
114
+ const state = open ? "expanded" : "collapsed"
115
+
116
+ const contextValue = React.useMemo<SidebarContext>(
117
+ () => ({
118
+ state,
119
+ open,
120
+ setOpen,
121
+ isMobile,
122
+ openMobile,
123
+ setOpenMobile,
124
+ toggleSidebar,
125
+ }),
126
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
127
+ )
128
+
129
+ return (
130
+ <SidebarContext.Provider value={contextValue}>
131
+ <div
132
+ data-slot="sidebar-wrapper"
133
+ style={
134
+ {
135
+ "--sidebar-width": SIDEBAR_WIDTH,
136
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
137
+ ...style,
138
+ } as React.CSSProperties
139
+ }
140
+ className={cn(
141
+ "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
142
+ className
143
+ )}
144
+ {...props}
145
+ >
146
+ {children}
147
+ </div>
148
+ </SidebarContext.Provider>
149
+ )
150
+ }
151
+
152
+ function Sidebar({
153
+ side = "left",
154
+ variant = "sidebar",
155
+ collapsible = "offcanvas",
156
+ className,
157
+ children,
158
+ ...props
159
+ }: React.ComponentProps<"div"> & {
160
+ side?: "left" | "right"
161
+ variant?: "sidebar" | "floating" | "inset"
162
+ collapsible?: "offcanvas" | "icon" | "none"
163
+ }) {
164
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
165
+
166
+ if (collapsible === "none") {
167
+ return (
168
+ <div
169
+ data-slot="sidebar"
170
+ className={cn(
171
+ "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
172
+ className
173
+ )}
174
+ {...props}
175
+ >
176
+ {children}
177
+ </div>
178
+ )
179
+ }
180
+
181
+ if (isMobile) {
182
+ return (
183
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
184
+ <SheetHeader className="sr-only">
185
+ <SheetTitle>Sidebar</SheetTitle>
186
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
187
+ </SheetHeader>
188
+ <SheetContent
189
+ data-sidebar="sidebar"
190
+ data-slot="sidebar"
191
+ data-mobile="true"
192
+ className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
193
+ style={
194
+ {
195
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
196
+ } as React.CSSProperties
197
+ }
198
+ side={side}
199
+ >
200
+ <div className="flex h-full w-full flex-col">{children}</div>
201
+ </SheetContent>
202
+ </Sheet>
203
+ )
204
+ }
205
+
206
+ return (
207
+ <div
208
+ className="group peer text-sidebar-foreground hidden md:block"
209
+ data-state={state}
210
+ data-collapsible={state === "collapsed" ? collapsible : ""}
211
+ data-variant={variant}
212
+ data-side={side}
213
+ data-slot="sidebar"
214
+ >
215
+ {/* This is what handles the sidebar gap on desktop */}
216
+ <div
217
+ className={cn(
218
+ "relative h-svh w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
219
+ "group-data-[collapsible=offcanvas]:w-0",
220
+ "group-data-[side=right]:rotate-180",
221
+ variant === "floating" || variant === "inset"
222
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
223
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
224
+ )}
225
+ />
226
+ <div
227
+ className={cn(
228
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
229
+ side === "left"
230
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
231
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
232
+ // Adjust the padding for floating and inset variants.
233
+ variant === "floating" || variant === "inset"
234
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
235
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
236
+ className
237
+ )}
238
+ {...props}
239
+ >
240
+ <div
241
+ data-sidebar="sidebar"
242
+ className="bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm"
243
+ >
244
+ {children}
245
+ </div>
246
+ </div>
247
+ </div>
248
+ )
249
+ }
250
+
251
+ function SidebarTrigger({
252
+ className,
253
+ onClick,
254
+ ...props
255
+ }: React.ComponentProps<typeof Button>) {
256
+ const { toggleSidebar, isMobile, state } = useSidebar()
257
+
258
+ return (
259
+ <Button
260
+ data-sidebar="trigger"
261
+ data-slot="sidebar-trigger"
262
+ variant="ghost"
263
+ size="icon"
264
+ className={cn("h-7 w-7", className)}
265
+ onClick={(event) => {
266
+ onClick?.(event)
267
+ toggleSidebar()
268
+ }}
269
+ {...props}
270
+ >
271
+ {isMobile || state === "collapsed" ? <PanelLeftOpenIcon /> : <PanelLeftCloseIcon />}
272
+ <span className="sr-only">Toggle sidebar</span>
273
+ </Button>
274
+ )
275
+ }
276
+
277
+ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
278
+ const { toggleSidebar } = useSidebar()
279
+
280
+ return (
281
+ <button
282
+ data-sidebar="rail"
283
+ data-slot="sidebar-rail"
284
+ aria-label="Toggle sidebar"
285
+ tabIndex={-1}
286
+ onClick={toggleSidebar}
287
+ title="Toggle sidebar"
288
+ className={cn(
289
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
290
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
291
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
292
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
293
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
294
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
295
+ className
296
+ )}
297
+ {...props}
298
+ />
299
+ )
300
+ }
301
+
302
+ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
303
+ return (
304
+ <main
305
+ data-slot="sidebar-inset"
306
+ className={cn(
307
+ "bg-background relative flex max-w-full min-h-svh flex-1 flex-col",
308
+ "peer-data-[variant=inset]:min-h-[calc(100svh-(--spacing(4)))] md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-md md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-0",
309
+ className
310
+ )}
311
+ {...props}
312
+ />
313
+ )
314
+ }
315
+
316
+ function SidebarInput({
317
+ className,
318
+ ...props
319
+ }: React.ComponentProps<typeof Input>) {
320
+ return (
321
+ <Input
322
+ data-slot="sidebar-input"
323
+ data-sidebar="input"
324
+ className={cn("bg-background h-8 w-full shadow-none", className)}
325
+ {...props}
326
+ />
327
+ )
328
+ }
329
+
330
+ function SidebarHeader({ className, ...props }: React.ComponentProps<"div">) {
331
+ return (
332
+ <div
333
+ data-slot="sidebar-header"
334
+ data-sidebar="header"
335
+ className={cn("flex flex-col gap-2 p-2", className)}
336
+ {...props}
337
+ />
338
+ )
339
+ }
340
+
341
+ function SidebarFooter({ className, ...props }: React.ComponentProps<"div">) {
342
+ return (
343
+ <div
344
+ data-slot="sidebar-footer"
345
+ data-sidebar="footer"
346
+ className={cn("flex flex-col gap-2 p-2", className)}
347
+ {...props}
348
+ />
349
+ )
350
+ }
351
+
352
+ function SidebarSeparator({
353
+ className,
354
+ ...props
355
+ }: React.ComponentProps<typeof Separator>) {
356
+ return (
357
+ <Separator
358
+ data-slot="sidebar-separator"
359
+ data-sidebar="separator"
360
+ className={cn("bg-sidebar-border mx-2 w-auto", className)}
361
+ {...props}
362
+ />
363
+ )
364
+ }
365
+
366
+ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
367
+ return (
368
+ <div
369
+ data-slot="sidebar-content"
370
+ data-sidebar="content"
371
+ className={cn(
372
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
373
+ className
374
+ )}
375
+ {...props}
376
+ />
377
+ )
378
+ }
379
+
380
+ function SidebarGroup({ className, ...props }: React.ComponentProps<"div">) {
381
+ return (
382
+ <div
383
+ data-slot="sidebar-group"
384
+ data-sidebar="group"
385
+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
386
+ {...props}
387
+ />
388
+ )
389
+ }
390
+
391
+ function SidebarGroupLabel({
392
+ className,
393
+ asChild = false,
394
+ ...props
395
+ }: React.ComponentProps<"div"> & { asChild?: boolean }) {
396
+ const Comp = asChild ? Slot : "div"
397
+
398
+ return (
399
+ <Comp
400
+ data-slot="sidebar-group-label"
401
+ data-sidebar="group-label"
402
+ className={cn(
403
+ "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
404
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 group-data-[collapsible=icon]:select-none group-data-[collapsible=icon]:pointer-events-none",
405
+ className
406
+ )}
407
+ {...props}
408
+ />
409
+ )
410
+ }
411
+
412
+ function SidebarGroupAction({
413
+ className,
414
+ asChild = false,
415
+ ...props
416
+ }: React.ComponentProps<"button"> & { asChild?: boolean }) {
417
+ const Comp = asChild ? Slot : "button"
418
+
419
+ return (
420
+ <Comp
421
+ data-slot="sidebar-group-action"
422
+ data-sidebar="group-action"
423
+ className={cn(
424
+ "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 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
425
+ // Increases the hit area of the button on mobile.
426
+ "after:absolute after:-inset-2 md:after:hidden",
427
+ "group-data-[collapsible=icon]:hidden",
428
+ className
429
+ )}
430
+ {...props}
431
+ />
432
+ )
433
+ }
434
+
435
+ function SidebarGroupContent({
436
+ className,
437
+ ...props
438
+ }: React.ComponentProps<"div">) {
439
+ return (
440
+ <div
441
+ data-slot="sidebar-group-content"
442
+ data-sidebar="group-content"
443
+ className={cn("w-full text-sm", className)}
444
+ {...props}
445
+ />
446
+ )
447
+ }
448
+
449
+ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
450
+ return (
451
+ <ul
452
+ data-slot="sidebar-menu"
453
+ data-sidebar="menu"
454
+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}
455
+ {...props}
456
+ />
457
+ )
458
+ }
459
+
460
+ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
461
+ return (
462
+ <li
463
+ data-slot="sidebar-menu-item"
464
+ data-sidebar="menu-item"
465
+ className={cn("group/menu-item relative", className)}
466
+ {...props}
467
+ />
468
+ )
469
+ }
470
+
471
+ const sidebarMenuButtonVariants = cva(
472
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden 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 group-has-data-[sidebar=menu-action]/menu-item:pr-8 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! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
473
+ {
474
+ variants: {
475
+ variant: {
476
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
477
+ outline:
478
+ "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",
479
+ },
480
+ size: {
481
+ default: "h-8 text-sm",
482
+ sm: "h-7 text-xs",
483
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!",
484
+ },
485
+ },
486
+ defaultVariants: {
487
+ variant: "default",
488
+ size: "default",
489
+ },
490
+ }
491
+ )
492
+
493
+ function SidebarMenuButton({
494
+ asChild = false,
495
+ isActive = false,
496
+ variant = "default",
497
+ size = "default",
498
+ tooltip,
499
+ className,
500
+ ...props
501
+ }: React.ComponentProps<"button"> & {
502
+ asChild?: boolean
503
+ isActive?: boolean
504
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
505
+ } & VariantProps<typeof sidebarMenuButtonVariants>) {
506
+ const Comp = asChild ? Slot : "button"
507
+ const { isMobile, state } = useSidebar()
508
+
509
+ const button = (
510
+ <Comp
511
+ data-slot="sidebar-menu-button"
512
+ data-sidebar="menu-button"
513
+ data-size={size}
514
+ data-active={isActive}
515
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
516
+ {...props}
517
+ />
518
+ )
519
+
520
+ if (!tooltip) {
521
+ return button
522
+ }
523
+
524
+ if (typeof tooltip === "string") {
525
+ tooltip = {
526
+ children: tooltip,
527
+ }
528
+ }
529
+
530
+ return (
531
+ <Tooltip>
532
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
533
+ <TooltipContent
534
+ side="right"
535
+ align="center"
536
+ hidden={state !== "collapsed" || isMobile}
537
+ {...tooltip}
538
+ />
539
+ </Tooltip>
540
+ )
541
+ }
542
+
543
+ function SidebarMenuAction({
544
+ className,
545
+ asChild = false,
546
+ showOnHover = false,
547
+ ...props
548
+ }: React.ComponentProps<"button"> & {
549
+ asChild?: boolean
550
+ showOnHover?: boolean
551
+ }) {
552
+ const Comp = asChild ? Slot : "button"
553
+
554
+ return (
555
+ <Comp
556
+ data-slot="sidebar-menu-action"
557
+ data-sidebar="menu-action"
558
+ className={cn(
559
+ "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 outline-hidden transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
560
+ // Increases the hit area of the button on mobile.
561
+ "after:absolute after:-inset-2 md:after:hidden",
562
+ "peer-data-[size=sm]/menu-button:top-1",
563
+ "peer-data-[size=default]/menu-button:top-1.5",
564
+ "peer-data-[size=lg]/menu-button:top-2.5",
565
+ "group-data-[collapsible=icon]:hidden",
566
+ showOnHover &&
567
+ "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",
568
+ className
569
+ )}
570
+ {...props}
571
+ />
572
+ )
573
+ }
574
+
575
+ function SidebarMenuBadge({
576
+ className,
577
+ ...props
578
+ }: React.ComponentProps<"div">) {
579
+ return (
580
+ <div
581
+ data-slot="sidebar-menu-badge"
582
+ data-sidebar="menu-badge"
583
+ className={cn(
584
+ "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",
585
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
586
+ "peer-data-[size=sm]/menu-button:top-1",
587
+ "peer-data-[size=default]/menu-button:top-1.5",
588
+ "peer-data-[size=lg]/menu-button:top-2.5",
589
+ "group-data-[collapsible=icon]:hidden",
590
+ className
591
+ )}
592
+ {...props}
593
+ />
594
+ )
595
+ }
596
+
597
+ function SidebarMenuSkeleton({
598
+ className,
599
+ showIcon = false,
600
+ ...props
601
+ }: React.ComponentProps<"div"> & {
602
+ showIcon?: boolean
603
+ }) {
604
+
605
+ // wrapping in useState to ensure the width is stable across renders
606
+ // also ensures we have a stable reference to the style object
607
+ const [skeletonStyle] = React.useState(() => (
608
+ {
609
+ "--skeleton-width": `${Math.floor(Math.random() * 40) + 50}%` // Random width between 50 to 90%.
610
+ } as React.CSSProperties
611
+ ))
612
+
613
+ return (
614
+ <div
615
+ data-slot="sidebar-menu-skeleton"
616
+ data-sidebar="menu-skeleton"
617
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
618
+ {...props}
619
+ >
620
+ {showIcon && (
621
+ <Skeleton
622
+ className="size-4 rounded-md"
623
+ data-sidebar="menu-skeleton-icon"
624
+ />
625
+ )}
626
+ <Skeleton
627
+ className="h-4 max-w-(--skeleton-width) flex-1"
628
+ data-sidebar="menu-skeleton-text"
629
+ style={skeletonStyle}
630
+ />
631
+ </div>
632
+ )
633
+ }
634
+
635
+ function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">) {
636
+ return (
637
+ <ul
638
+ data-slot="sidebar-menu-sub"
639
+ data-sidebar="menu-sub"
640
+ className={cn(
641
+ "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
642
+ "group-data-[collapsible=icon]:hidden",
643
+ className
644
+ )}
645
+ {...props}
646
+ />
647
+ )
648
+ }
649
+
650
+ function SidebarMenuSubItem({
651
+ className,
652
+ ...props
653
+ }: React.ComponentProps<"li">) {
654
+ return (
655
+ <li
656
+ data-slot="sidebar-menu-sub-item"
657
+ data-sidebar="menu-sub-item"
658
+ className={cn("group/menu-sub-item relative", className)}
659
+ {...props}
660
+ />
661
+ )
662
+ }
663
+
664
+ function SidebarMenuSubButton({
665
+ asChild = false,
666
+ size = "md",
667
+ isActive = false,
668
+ className,
669
+ ...props
670
+ }: React.ComponentProps<"a"> & {
671
+ asChild?: boolean
672
+ size?: "sm" | "md"
673
+ isActive?: boolean
674
+ }) {
675
+ const Comp = asChild ? Slot : "a"
676
+
677
+ return (
678
+ <Comp
679
+ data-slot="sidebar-menu-sub-button"
680
+ data-sidebar="menu-sub-button"
681
+ data-size={size}
682
+ data-active={isActive}
683
+ className={cn(
684
+ "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-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden 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",
685
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
686
+ size === "sm" && "text-xs",
687
+ size === "md" && "text-sm",
688
+ "group-data-[collapsible=icon]:hidden",
689
+ className
690
+ )}
691
+ {...props}
692
+ />
693
+ )
694
+ }
695
+
696
+ export {
697
+ Sidebar,
698
+ SidebarContent,
699
+ SidebarFooter,
700
+ SidebarGroup,
701
+ SidebarGroupAction,
702
+ SidebarGroupContent,
703
+ SidebarGroupLabel,
704
+ SidebarHeader,
705
+ SidebarInput,
706
+ SidebarInset,
707
+ SidebarMenu,
708
+ SidebarMenuAction,
709
+ SidebarMenuBadge,
710
+ SidebarMenuButton,
711
+ SidebarMenuItem,
712
+ SidebarMenuSkeleton,
713
+ SidebarMenuSub,
714
+ SidebarMenuSubButton,
715
+ SidebarMenuSubItem,
716
+ SidebarProvider,
717
+ SidebarRail,
718
+ SidebarSeparator,
719
+ SidebarTrigger,
720
+ useSidebar,
721
+ }