@mdguggenbichler/slugbase-core 0.0.4 → 0.0.6

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 (120) hide show
  1. package/frontend/index.tsx +3 -3
  2. package/frontend/public/favicon.svg +1 -0
  3. package/frontend/public/slugbase_icon_blue.svg +1 -0
  4. package/frontend/public/slugbase_icon_white.png +0 -0
  5. package/frontend/public/slugbase_icon_white.svg +1 -0
  6. package/frontend/src/App.tsx +179 -0
  7. package/frontend/src/api/client.ts +134 -0
  8. package/frontend/src/components/AppSidebar.tsx +214 -0
  9. package/frontend/src/components/EmptyState.tsx +33 -0
  10. package/frontend/src/components/Favicon.tsx +76 -0
  11. package/frontend/src/components/FilterChips.tsx +60 -0
  12. package/frontend/src/components/FolderIcon.tsx +207 -0
  13. package/frontend/src/components/GlobalSearch.tsx +275 -0
  14. package/frontend/src/components/Layout.tsx +60 -0
  15. package/frontend/src/components/PageHeader.tsx +31 -0
  16. package/frontend/src/components/ScopeSegmentedControl.tsx +42 -0
  17. package/frontend/src/components/SentryDebug.tsx +32 -0
  18. package/frontend/src/components/StatCard.tsx +66 -0
  19. package/frontend/src/components/TopBar.tsx +63 -0
  20. package/frontend/src/components/UserDropdown.tsx +86 -0
  21. package/frontend/src/components/admin/AdminAI.tsx +207 -0
  22. package/frontend/src/components/admin/AdminOIDCProviders.tsx +183 -0
  23. package/frontend/src/components/admin/AdminSettings.tsx +413 -0
  24. package/frontend/src/components/admin/AdminTeams.tsx +177 -0
  25. package/frontend/src/components/admin/AdminUsers.tsx +225 -0
  26. package/frontend/src/components/bookmarks/BookmarkCard.tsx +312 -0
  27. package/frontend/src/components/bookmarks/BookmarkListItem.tsx +159 -0
  28. package/frontend/src/components/bookmarks/BookmarkTableView.tsx +419 -0
  29. package/frontend/src/components/bookmarks/BulkActionModals.tsx +162 -0
  30. package/frontend/src/components/bookmarks/FilterChips.tsx +5 -0
  31. package/frontend/src/components/modals/BookmarkModal.tsx +493 -0
  32. package/frontend/src/components/modals/FolderModal.tsx +306 -0
  33. package/frontend/src/components/modals/ImportModal.tsx +232 -0
  34. package/frontend/src/components/modals/OIDCProviderModal.tsx +284 -0
  35. package/frontend/src/components/modals/SharingModal.tsx +96 -0
  36. package/frontend/src/components/modals/TagModal.tsx +101 -0
  37. package/frontend/src/components/modals/TeamAssignmentModal.tsx +354 -0
  38. package/frontend/src/components/modals/TeamModal.tsx +117 -0
  39. package/frontend/src/components/modals/UserModal.tsx +225 -0
  40. package/frontend/src/components/profile/CreateTokenModal.tsx +172 -0
  41. package/frontend/src/components/sharing/ShareResourceDialog.tsx +422 -0
  42. package/frontend/src/components/ui/Autocomplete.tsx +155 -0
  43. package/frontend/src/components/ui/Button.tsx +68 -0
  44. package/frontend/src/components/ui/ConfirmDialog.tsx +79 -0
  45. package/frontend/src/components/ui/FormFieldWrapper.tsx +36 -0
  46. package/frontend/src/components/ui/ModalFooterActions.tsx +49 -0
  47. package/frontend/src/components/ui/ModalSection.tsx +34 -0
  48. package/frontend/src/components/ui/PageLoadingSkeleton.tsx +24 -0
  49. package/frontend/src/components/ui/Select.tsx +61 -0
  50. package/frontend/src/components/ui/SharingField.tsx +298 -0
  51. package/frontend/src/components/ui/Toast.tsx +47 -0
  52. package/frontend/src/components/ui/Tooltip.tsx +21 -0
  53. package/frontend/src/components/ui/alert-dialog.tsx +139 -0
  54. package/frontend/src/components/ui/badge.tsx +36 -0
  55. package/frontend/src/components/ui/button-base.tsx +57 -0
  56. package/frontend/src/components/ui/card.tsx +76 -0
  57. package/frontend/src/components/ui/command.tsx +161 -0
  58. package/frontend/src/components/ui/dialog.tsx +120 -0
  59. package/frontend/src/components/ui/dropdown-menu.tsx +199 -0
  60. package/frontend/src/components/ui/input.tsx +22 -0
  61. package/frontend/src/components/ui/label.tsx +24 -0
  62. package/frontend/src/components/ui/popover.tsx +33 -0
  63. package/frontend/src/components/ui/progress.tsx +26 -0
  64. package/frontend/src/components/ui/scroll-area.tsx +48 -0
  65. package/frontend/src/components/ui/select-base.tsx +159 -0
  66. package/frontend/src/components/ui/separator.tsx +29 -0
  67. package/frontend/src/components/ui/sheet.tsx +140 -0
  68. package/frontend/src/components/ui/sidebar.tsx +783 -0
  69. package/frontend/src/components/ui/skeleton.tsx +15 -0
  70. package/frontend/src/components/ui/sonner.tsx +46 -0
  71. package/frontend/src/components/ui/switch.tsx +28 -0
  72. package/frontend/src/components/ui/table.tsx +120 -0
  73. package/frontend/src/components/ui/tooltip-base.tsx +30 -0
  74. package/frontend/src/config/api.ts +16 -0
  75. package/frontend/src/config/mode.ts +6 -0
  76. package/frontend/src/contexts/AppConfigContext.tsx +39 -0
  77. package/frontend/src/contexts/AuthContext.tsx +137 -0
  78. package/frontend/src/contexts/SearchCommandContext.tsx +28 -0
  79. package/frontend/src/hooks/use-mobile.tsx +19 -0
  80. package/frontend/src/hooks/useConfirmDialog.ts +63 -0
  81. package/frontend/src/hooks/useMarketingTheme.ts +47 -0
  82. package/frontend/src/i18n.ts +39 -0
  83. package/frontend/src/index.css +117 -0
  84. package/frontend/src/instrument.ts +20 -0
  85. package/frontend/src/lib/utils.ts +6 -0
  86. package/frontend/src/locales/de.json +899 -0
  87. package/frontend/src/locales/en.json +937 -0
  88. package/frontend/src/locales/es.json +884 -0
  89. package/frontend/src/locales/fr.json +550 -0
  90. package/frontend/src/locales/it.json +535 -0
  91. package/frontend/src/locales/ja.json +535 -0
  92. package/frontend/src/locales/nl.json +550 -0
  93. package/frontend/src/locales/pl.json +535 -0
  94. package/frontend/src/locales/pt.json +535 -0
  95. package/frontend/src/locales/ru.json +535 -0
  96. package/frontend/src/locales/zh.json +535 -0
  97. package/frontend/src/main.tsx +44 -0
  98. package/frontend/src/pages/Bookmarks.tsx +1004 -0
  99. package/frontend/src/pages/Dashboard.tsx +427 -0
  100. package/frontend/src/pages/Folders.tsx +578 -0
  101. package/frontend/src/pages/GoPreferences.tsx +134 -0
  102. package/frontend/src/pages/Login.tsx +196 -0
  103. package/frontend/src/pages/PasswordReset.tsx +242 -0
  104. package/frontend/src/pages/Profile.tsx +593 -0
  105. package/frontend/src/pages/SearchEngineGuide.tsx +135 -0
  106. package/frontend/src/pages/Setup.tsx +210 -0
  107. package/frontend/src/pages/Signup.tsx +199 -0
  108. package/frontend/src/pages/Tags.tsx +421 -0
  109. package/frontend/src/pages/VerifyEmail.tsx +254 -0
  110. package/frontend/src/pages/admin/AdminAIPage.tsx +5 -0
  111. package/frontend/src/pages/admin/AdminLayout.tsx +40 -0
  112. package/frontend/src/pages/admin/AdminMembersPage.tsx +5 -0
  113. package/frontend/src/pages/admin/AdminOIDCPage.tsx +5 -0
  114. package/frontend/src/pages/admin/AdminSettingsPage.tsx +5 -0
  115. package/frontend/src/pages/admin/AdminTeamsPage.tsx +5 -0
  116. package/frontend/src/utils/favicon.ts +36 -0
  117. package/frontend/src/utils/formatRelativeTime.ts +37 -0
  118. package/frontend/src/utils/safeHref.ts +31 -0
  119. package/frontend/src/vite-env.d.ts +10 -0
  120. package/package.json +9 -1
@@ -0,0 +1,783 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+ import { PanelLeft } from "lucide-react"
5
+
6
+ import { useIsMobile } from "@/hooks/use-mobile"
7
+ import { cn } from "@/lib/utils"
8
+ import { Button } from "@/components/ui/button-base"
9
+ import { Input } from "@/components/ui/input"
10
+ import { Separator } from "@/components/ui/separator"
11
+ import {
12
+ Sheet,
13
+ SheetContent,
14
+ SheetDescription,
15
+ SheetHeader,
16
+ SheetTitle,
17
+ } from "@/components/ui/sheet"
18
+ import { Skeleton } from "@/components/ui/skeleton"
19
+ import {
20
+ Tooltip,
21
+ TooltipContent,
22
+ TooltipProvider,
23
+ TooltipTrigger,
24
+ } from "@/components/ui/tooltip-base"
25
+
26
+ const SIDEBAR_COOKIE_NAME = "sidebar_state"
27
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
28
+ const SIDEBAR_WIDTH = "16rem"
29
+ const SIDEBAR_WIDTH_MOBILE = "18rem"
30
+ const SIDEBAR_WIDTH_ICON = "3rem"
31
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b"
32
+
33
+ type SidebarContextProps = {
34
+ state: "expanded" | "collapsed"
35
+ open: boolean
36
+ setOpen: (open: boolean) => void
37
+ openMobile: boolean
38
+ setOpenMobile: (open: boolean) => void
39
+ isMobile: boolean
40
+ toggleSidebar: () => void
41
+ }
42
+
43
+ const SidebarContext = React.createContext<SidebarContextProps | null>(null)
44
+
45
+ function useSidebar() {
46
+ const context = React.useContext(SidebarContext)
47
+ if (!context) {
48
+ throw new Error("useSidebar must be used within a SidebarProvider.")
49
+ }
50
+
51
+ return context
52
+ }
53
+
54
+ const SidebarProvider = React.forwardRef<
55
+ HTMLDivElement,
56
+ React.ComponentProps<"div"> & {
57
+ defaultOpen?: boolean
58
+ open?: boolean
59
+ onOpenChange?: (open: boolean) => void
60
+ }
61
+ >(
62
+ (
63
+ {
64
+ defaultOpen = true,
65
+ open: openProp,
66
+ onOpenChange: setOpenProp,
67
+ className,
68
+ style,
69
+ children,
70
+ ...props
71
+ },
72
+ ref
73
+ ) => {
74
+ const isMobile = useIsMobile()
75
+ const [openMobile, setOpenMobile] = React.useState(false)
76
+
77
+ // This is the internal state of the sidebar.
78
+ // We use openProp and setOpenProp for control from outside the component.
79
+ const [_open, _setOpen] = React.useState(defaultOpen)
80
+ const open = openProp ?? _open
81
+ const setOpen = React.useCallback(
82
+ (value: boolean | ((value: boolean) => boolean)) => {
83
+ const openState = typeof value === "function" ? value(open) : value
84
+ if (setOpenProp) {
85
+ setOpenProp(openState)
86
+ } else {
87
+ _setOpen(openState)
88
+ }
89
+
90
+ // This sets the cookie to keep the sidebar state.
91
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
92
+ },
93
+ [setOpenProp, open]
94
+ )
95
+
96
+ // Helper to toggle the sidebar.
97
+ const toggleSidebar = React.useCallback(() => {
98
+ return isMobile
99
+ ? setOpenMobile((open) => !open)
100
+ : setOpen((open) => !open)
101
+ }, [isMobile, setOpen, setOpenMobile])
102
+
103
+ // Adds a keyboard shortcut to toggle the sidebar.
104
+ React.useEffect(() => {
105
+ const handleKeyDown = (event: KeyboardEvent) => {
106
+ if (
107
+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
108
+ (event.metaKey || event.ctrlKey)
109
+ ) {
110
+ event.preventDefault()
111
+ toggleSidebar()
112
+ }
113
+ }
114
+
115
+ window.addEventListener("keydown", handleKeyDown)
116
+ return () => window.removeEventListener("keydown", handleKeyDown)
117
+ }, [toggleSidebar])
118
+
119
+ // We add a state so that we can do data-state="expanded" or "collapsed".
120
+ // This makes it easier to style the sidebar with Tailwind classes.
121
+ const state = open ? "expanded" : "collapsed"
122
+
123
+ const contextValue = React.useMemo<SidebarContextProps>(
124
+ () => ({
125
+ state,
126
+ open,
127
+ setOpen,
128
+ isMobile,
129
+ openMobile,
130
+ setOpenMobile,
131
+ toggleSidebar,
132
+ }),
133
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
134
+ )
135
+
136
+ return (
137
+ <SidebarContext.Provider value={contextValue}>
138
+ <TooltipProvider delayDuration={0}>
139
+ <div
140
+ style={
141
+ {
142
+ "--sidebar-width": SIDEBAR_WIDTH,
143
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
144
+ ...style,
145
+ } as React.CSSProperties
146
+ }
147
+ className={cn(
148
+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
149
+ className
150
+ )}
151
+ ref={ref}
152
+ {...props}
153
+ >
154
+ {children}
155
+ </div>
156
+ </TooltipProvider>
157
+ </SidebarContext.Provider>
158
+ )
159
+ }
160
+ )
161
+ SidebarProvider.displayName = "SidebarProvider"
162
+
163
+ const Sidebar = React.forwardRef<
164
+ HTMLDivElement,
165
+ React.ComponentProps<"div"> & {
166
+ side?: "left" | "right"
167
+ variant?: "sidebar" | "floating" | "inset"
168
+ collapsible?: "offcanvas" | "icon" | "none"
169
+ }
170
+ >(
171
+ (
172
+ {
173
+ side = "left",
174
+ variant = "sidebar",
175
+ collapsible = "offcanvas",
176
+ className,
177
+ children,
178
+ ...props
179
+ },
180
+ ref
181
+ ) => {
182
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
183
+
184
+ if (collapsible === "none") {
185
+ return (
186
+ <div
187
+ className={cn(
188
+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
189
+ className
190
+ )}
191
+ ref={ref}
192
+ {...props}
193
+ >
194
+ {children}
195
+ </div>
196
+ )
197
+ }
198
+
199
+ if (isMobile) {
200
+ return (
201
+ <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
202
+ <SheetContent
203
+ data-sidebar="sidebar"
204
+ data-mobile="true"
205
+ className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
206
+ style={
207
+ {
208
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
209
+ } as React.CSSProperties
210
+ }
211
+ side={side}
212
+ >
213
+ <SheetHeader className="sr-only">
214
+ <SheetTitle>Sidebar</SheetTitle>
215
+ <SheetDescription>Displays the mobile sidebar.</SheetDescription>
216
+ </SheetHeader>
217
+ <div className="flex h-full w-full flex-col">{children}</div>
218
+ </SheetContent>
219
+ </Sheet>
220
+ )
221
+ }
222
+
223
+ return (
224
+ <div
225
+ ref={ref}
226
+ className="group peer hidden text-sidebar-foreground md:block"
227
+ data-state={state}
228
+ data-collapsible={state === "collapsed" ? collapsible : ""}
229
+ data-variant={variant}
230
+ data-side={side}
231
+ >
232
+ {/* This is what handles the sidebar gap on desktop */}
233
+ <div
234
+ className={cn(
235
+ "relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
236
+ "group-data-[collapsible=offcanvas]:w-0",
237
+ "group-data-[side=right]:rotate-180",
238
+ variant === "floating" || variant === "inset"
239
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
240
+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
241
+ )}
242
+ />
243
+ <div
244
+ className={cn(
245
+ "fixed top-14 h-[calc(100svh-3.5rem)] lg:top-16 lg:h-[calc(100svh-4rem)] z-10 hidden w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
246
+ side === "left"
247
+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
248
+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
249
+ // Adjust the padding for floating and inset variants.
250
+ variant === "floating" || variant === "inset"
251
+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
252
+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
253
+ className
254
+ )}
255
+ {...props}
256
+ >
257
+ <div
258
+ data-sidebar="sidebar"
259
+ className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
260
+ >
261
+ {children}
262
+ </div>
263
+ </div>
264
+ </div>
265
+ )
266
+ }
267
+ )
268
+ Sidebar.displayName = "Sidebar"
269
+
270
+ const SidebarTrigger = React.forwardRef<
271
+ React.ElementRef<typeof Button>,
272
+ React.ComponentProps<typeof Button>
273
+ >(({ className, onClick, ...props }, ref) => {
274
+ const { toggleSidebar } = useSidebar()
275
+
276
+ return (
277
+ <Button
278
+ ref={ref}
279
+ data-sidebar="trigger"
280
+ variant="ghost"
281
+ size="icon"
282
+ className={cn("h-7 w-7", className)}
283
+ onClick={(event) => {
284
+ onClick?.(event)
285
+ toggleSidebar()
286
+ }}
287
+ {...props}
288
+ >
289
+ <PanelLeft />
290
+ <span className="sr-only">Toggle Sidebar</span>
291
+ </Button>
292
+ )
293
+ })
294
+ SidebarTrigger.displayName = "SidebarTrigger"
295
+
296
+ const SidebarRail = React.forwardRef<
297
+ HTMLButtonElement,
298
+ React.ComponentProps<"button">
299
+ >(({ className, ...props }, ref) => {
300
+ const { toggleSidebar } = useSidebar()
301
+
302
+ return (
303
+ <button
304
+ ref={ref}
305
+ data-sidebar="rail"
306
+ aria-label="Toggle Sidebar"
307
+ tabIndex={-1}
308
+ onClick={toggleSidebar}
309
+ title="Toggle Sidebar"
310
+ className={cn(
311
+ "absolute inset-y-0 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] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",
312
+ "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
313
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
314
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
315
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
316
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
317
+ className
318
+ )}
319
+ {...props}
320
+ />
321
+ )
322
+ })
323
+ SidebarRail.displayName = "SidebarRail"
324
+
325
+ const SidebarInset = React.forwardRef<
326
+ HTMLDivElement,
327
+ React.ComponentProps<"main">
328
+ >(({ className, ...props }, ref) => {
329
+ return (
330
+ <main
331
+ ref={ref}
332
+ className={cn(
333
+ "relative flex w-full flex-1 flex-col bg-background",
334
+ "md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
335
+ className
336
+ )}
337
+ {...props}
338
+ />
339
+ )
340
+ })
341
+ SidebarInset.displayName = "SidebarInset"
342
+
343
+ const SidebarInput = React.forwardRef<
344
+ React.ElementRef<typeof Input>,
345
+ React.ComponentProps<typeof Input>
346
+ >(({ className, ...props }, ref) => {
347
+ return (
348
+ <Input
349
+ ref={ref}
350
+ data-sidebar="input"
351
+ className={cn(
352
+ "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
353
+ className
354
+ )}
355
+ {...props}
356
+ />
357
+ )
358
+ })
359
+ SidebarInput.displayName = "SidebarInput"
360
+
361
+ const SidebarHeader = React.forwardRef<
362
+ HTMLDivElement,
363
+ React.ComponentProps<"div">
364
+ >(({ className, ...props }, ref) => {
365
+ return (
366
+ <div
367
+ ref={ref}
368
+ data-sidebar="header"
369
+ className={cn("flex flex-col gap-2 p-2", className)}
370
+ {...props}
371
+ />
372
+ )
373
+ })
374
+ SidebarHeader.displayName = "SidebarHeader"
375
+
376
+ const SidebarFooter = React.forwardRef<
377
+ HTMLDivElement,
378
+ React.ComponentProps<"div">
379
+ >(({ className, ...props }, ref) => {
380
+ return (
381
+ <div
382
+ ref={ref}
383
+ data-sidebar="footer"
384
+ className={cn(
385
+ "flex flex-col gap-2 p-2",
386
+ "group-data-[collapsible=icon]:items-center group-data-[collapsible=icon]:!px-2",
387
+ className
388
+ )}
389
+ {...props}
390
+ />
391
+ )
392
+ })
393
+ SidebarFooter.displayName = "SidebarFooter"
394
+
395
+ const SidebarSeparator = React.forwardRef<
396
+ React.ElementRef<typeof Separator>,
397
+ React.ComponentProps<typeof Separator>
398
+ >(({ className, ...props }, ref) => {
399
+ return (
400
+ <Separator
401
+ ref={ref}
402
+ data-sidebar="separator"
403
+ className={cn("mx-2 w-auto bg-sidebar-border", className)}
404
+ {...props}
405
+ />
406
+ )
407
+ })
408
+ SidebarSeparator.displayName = "SidebarSeparator"
409
+
410
+ const SidebarContent = React.forwardRef<
411
+ HTMLDivElement,
412
+ React.ComponentProps<"div">
413
+ >(({ className, ...props }, ref) => {
414
+ return (
415
+ <div
416
+ ref={ref}
417
+ data-sidebar="content"
418
+ className={cn(
419
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
420
+ className
421
+ )}
422
+ {...props}
423
+ />
424
+ )
425
+ })
426
+ SidebarContent.displayName = "SidebarContent"
427
+
428
+ const SidebarGroup = React.forwardRef<
429
+ HTMLDivElement,
430
+ React.ComponentProps<"div">
431
+ >(({ className, ...props }, ref) => {
432
+ return (
433
+ <div
434
+ ref={ref}
435
+ data-sidebar="group"
436
+ className={cn(
437
+ "relative flex w-full min-w-0 flex-col p-2",
438
+ "group-data-[collapsible=icon]:!px-0 group-data-[collapsible=icon]:items-center",
439
+ className
440
+ )}
441
+ {...props}
442
+ />
443
+ )
444
+ })
445
+ SidebarGroup.displayName = "SidebarGroup"
446
+
447
+ const SidebarGroupLabel = React.forwardRef<
448
+ HTMLDivElement,
449
+ React.ComponentProps<"div"> & { asChild?: boolean }
450
+ >(({ className, asChild = false, ...props }, ref) => {
451
+ const Comp = asChild ? Slot : "div"
452
+
453
+ return (
454
+ <Comp
455
+ ref={ref}
456
+ data-sidebar="group-label"
457
+ className={cn(
458
+ "flex h-8 shrink-0 items-center rounded-md px-2 text-xs 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",
459
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
460
+ className
461
+ )}
462
+ {...props}
463
+ />
464
+ )
465
+ })
466
+ SidebarGroupLabel.displayName = "SidebarGroupLabel"
467
+
468
+ const SidebarGroupAction = React.forwardRef<
469
+ HTMLButtonElement,
470
+ React.ComponentProps<"button"> & { asChild?: boolean }
471
+ >(({ className, asChild = false, ...props }, ref) => {
472
+ const Comp = asChild ? Slot : "button"
473
+
474
+ return (
475
+ <Comp
476
+ ref={ref}
477
+ data-sidebar="group-action"
478
+ className={cn(
479
+ "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
480
+ // Increases the hit area of the button on mobile.
481
+ "after:absolute after:-inset-2 after:md:hidden",
482
+ "group-data-[collapsible=icon]:hidden",
483
+ className
484
+ )}
485
+ {...props}
486
+ />
487
+ )
488
+ })
489
+ SidebarGroupAction.displayName = "SidebarGroupAction"
490
+
491
+ const SidebarGroupContent = React.forwardRef<
492
+ HTMLDivElement,
493
+ React.ComponentProps<"div">
494
+ >(({ className, ...props }, ref) => (
495
+ <div
496
+ ref={ref}
497
+ data-sidebar="group-content"
498
+ className={cn("w-full text-sm", className)}
499
+ {...props}
500
+ />
501
+ ))
502
+ SidebarGroupContent.displayName = "SidebarGroupContent"
503
+
504
+ const SidebarMenu = React.forwardRef<
505
+ HTMLUListElement,
506
+ React.ComponentProps<"ul">
507
+ >(({ className, ...props }, ref) => (
508
+ <ul
509
+ ref={ref}
510
+ data-sidebar="menu"
511
+ className={cn(
512
+ "flex w-full min-w-0 flex-col gap-1",
513
+ "group-data-[collapsible=icon]:items-center",
514
+ className
515
+ )}
516
+ {...props}
517
+ />
518
+ ))
519
+ SidebarMenu.displayName = "SidebarMenu"
520
+
521
+ const SidebarMenuItem = React.forwardRef<
522
+ HTMLLIElement,
523
+ React.ComponentProps<"li">
524
+ >(({ className, ...props }, ref) => (
525
+ <li
526
+ ref={ref}
527
+ data-sidebar="menu-item"
528
+ className={cn("group/menu-item relative", className)}
529
+ {...props}
530
+ />
531
+ ))
532
+ SidebarMenuItem.displayName = "SidebarMenuItem"
533
+
534
+ const sidebarMenuButtonVariants = cva(
535
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] border-l-2 border-transparent 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-primary/10 data-[active=true]:text-primary data-[active=true]:font-medium data-[active=true]:border-l-primary 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-lg [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
536
+ {
537
+ variants: {
538
+ variant: {
539
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
540
+ outline:
541
+ "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))]",
542
+ },
543
+ size: {
544
+ default: "h-8 text-sm",
545
+ sm: "h-7 text-xs",
546
+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
547
+ },
548
+ },
549
+ defaultVariants: {
550
+ variant: "default",
551
+ size: "default",
552
+ },
553
+ }
554
+ )
555
+
556
+ const SidebarMenuButton = React.forwardRef<
557
+ HTMLButtonElement,
558
+ React.ComponentProps<"button"> & {
559
+ asChild?: boolean
560
+ isActive?: boolean
561
+ tooltip?: string | React.ComponentProps<typeof TooltipContent>
562
+ } & VariantProps<typeof sidebarMenuButtonVariants>
563
+ >(
564
+ (
565
+ {
566
+ asChild = false,
567
+ isActive = false,
568
+ variant = "default",
569
+ size = "default",
570
+ tooltip,
571
+ className,
572
+ ...props
573
+ },
574
+ ref
575
+ ) => {
576
+ const Comp = asChild ? Slot : "button"
577
+ const { isMobile, state } = useSidebar()
578
+
579
+ const button = (
580
+ <Comp
581
+ ref={ref}
582
+ data-sidebar="menu-button"
583
+ data-size={size}
584
+ data-active={isActive}
585
+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
586
+ {...props}
587
+ />
588
+ )
589
+
590
+ if (!tooltip) {
591
+ return button
592
+ }
593
+
594
+ if (typeof tooltip === "string") {
595
+ tooltip = {
596
+ children: tooltip,
597
+ }
598
+ }
599
+
600
+ return (
601
+ <Tooltip>
602
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
603
+ <TooltipContent
604
+ side="right"
605
+ align="center"
606
+ hidden={state !== "collapsed" || isMobile}
607
+ {...tooltip}
608
+ />
609
+ </Tooltip>
610
+ )
611
+ }
612
+ )
613
+ SidebarMenuButton.displayName = "SidebarMenuButton"
614
+
615
+ const SidebarMenuAction = React.forwardRef<
616
+ HTMLButtonElement,
617
+ React.ComponentProps<"button"> & {
618
+ asChild?: boolean
619
+ showOnHover?: boolean
620
+ }
621
+ >(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
622
+ const Comp = asChild ? Slot : "button"
623
+
624
+ return (
625
+ <Comp
626
+ ref={ref}
627
+ data-sidebar="menu-action"
628
+ className={cn(
629
+ "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
630
+ // Increases the hit area of the button on mobile.
631
+ "after:absolute after:-inset-2 after:md:hidden",
632
+ "peer-data-[size=sm]/menu-button:top-1",
633
+ "peer-data-[size=default]/menu-button:top-1.5",
634
+ "peer-data-[size=lg]/menu-button:top-2.5",
635
+ "group-data-[collapsible=icon]:hidden",
636
+ showOnHover &&
637
+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",
638
+ className
639
+ )}
640
+ {...props}
641
+ />
642
+ )
643
+ })
644
+ SidebarMenuAction.displayName = "SidebarMenuAction"
645
+
646
+ const SidebarMenuBadge = React.forwardRef<
647
+ HTMLDivElement,
648
+ React.ComponentProps<"div">
649
+ >(({ className, ...props }, ref) => (
650
+ <div
651
+ ref={ref}
652
+ data-sidebar="menu-badge"
653
+ className={cn(
654
+ "pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground",
655
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
656
+ "peer-data-[size=sm]/menu-button:top-1",
657
+ "peer-data-[size=default]/menu-button:top-1.5",
658
+ "peer-data-[size=lg]/menu-button:top-2.5",
659
+ "group-data-[collapsible=icon]:hidden",
660
+ className
661
+ )}
662
+ {...props}
663
+ />
664
+ ))
665
+ SidebarMenuBadge.displayName = "SidebarMenuBadge"
666
+
667
+ const SidebarMenuSkeleton = React.forwardRef<
668
+ HTMLDivElement,
669
+ React.ComponentProps<"div"> & {
670
+ showIcon?: boolean
671
+ }
672
+ >(({ className, showIcon = false, ...props }, ref) => {
673
+ // Random width between 50 to 90%.
674
+ const width = React.useMemo(() => {
675
+ return `${Math.floor(Math.random() * 40) + 50}%`
676
+ }, [])
677
+
678
+ return (
679
+ <div
680
+ ref={ref}
681
+ data-sidebar="menu-skeleton"
682
+ className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
683
+ {...props}
684
+ >
685
+ {showIcon && (
686
+ <Skeleton
687
+ className="size-4 rounded-md"
688
+ data-sidebar="menu-skeleton-icon"
689
+ />
690
+ )}
691
+ <Skeleton
692
+ className="h-4 max-w-[--skeleton-width] flex-1"
693
+ data-sidebar="menu-skeleton-text"
694
+ style={
695
+ {
696
+ "--skeleton-width": width,
697
+ } as React.CSSProperties
698
+ }
699
+ />
700
+ </div>
701
+ )
702
+ })
703
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton"
704
+
705
+ const SidebarMenuSub = React.forwardRef<
706
+ HTMLUListElement,
707
+ React.ComponentProps<"ul">
708
+ >(({ className, ...props }, ref) => (
709
+ <ul
710
+ ref={ref}
711
+ data-sidebar="menu-sub"
712
+ className={cn(
713
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
714
+ "group-data-[collapsible=icon]:hidden",
715
+ className
716
+ )}
717
+ {...props}
718
+ />
719
+ ))
720
+ SidebarMenuSub.displayName = "SidebarMenuSub"
721
+
722
+ const SidebarMenuSubItem = React.forwardRef<
723
+ HTMLLIElement,
724
+ React.ComponentProps<"li">
725
+ >(({ ...props }, ref) => <li ref={ref} {...props} />)
726
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem"
727
+
728
+ const SidebarMenuSubButton = React.forwardRef<
729
+ HTMLAnchorElement,
730
+ React.ComponentProps<"a"> & {
731
+ asChild?: boolean
732
+ size?: "sm" | "md"
733
+ isActive?: boolean
734
+ }
735
+ >(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
736
+ const Comp = asChild ? Slot : "a"
737
+
738
+ return (
739
+ <Comp
740
+ ref={ref}
741
+ data-sidebar="menu-sub-button"
742
+ data-size={size}
743
+ data-active={isActive}
744
+ className={cn(
745
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring 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 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
746
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
747
+ size === "sm" && "text-xs",
748
+ size === "md" && "text-sm",
749
+ "group-data-[collapsible=icon]:hidden",
750
+ className
751
+ )}
752
+ {...props}
753
+ />
754
+ )
755
+ })
756
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton"
757
+
758
+ export {
759
+ Sidebar,
760
+ SidebarContent,
761
+ SidebarFooter,
762
+ SidebarGroup,
763
+ SidebarGroupAction,
764
+ SidebarGroupContent,
765
+ SidebarGroupLabel,
766
+ SidebarHeader,
767
+ SidebarInput,
768
+ SidebarInset,
769
+ SidebarMenu,
770
+ SidebarMenuAction,
771
+ SidebarMenuBadge,
772
+ SidebarMenuButton,
773
+ SidebarMenuItem,
774
+ SidebarMenuSkeleton,
775
+ SidebarMenuSub,
776
+ SidebarMenuSubButton,
777
+ SidebarMenuSubItem,
778
+ SidebarProvider,
779
+ SidebarRail,
780
+ SidebarSeparator,
781
+ SidebarTrigger,
782
+ useSidebar,
783
+ }