hazo_auth 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.
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/components.json +22 -0
- package/hazo_auth_config.example.ini +414 -0
- package/hazo_notify_config.example.ini +159 -0
- package/instrumentation.ts +32 -0
- package/migrations/001_add_token_type_to_refresh_tokens.sql +14 -0
- package/migrations/002_add_name_to_hazo_users.sql +7 -0
- package/next.config.mjs +55 -0
- package/package.json +114 -0
- package/postcss.config.mjs +8 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/scripts/apply_migration.ts +118 -0
- package/src/app/api/auth/change_password/route.ts +109 -0
- package/src/app/api/auth/forgot_password/route.ts +107 -0
- package/src/app/api/auth/library_photos/route.ts +70 -0
- package/src/app/api/auth/login/route.ts +155 -0
- package/src/app/api/auth/logout/route.ts +62 -0
- package/src/app/api/auth/me/route.ts +47 -0
- package/src/app/api/auth/profile_picture/[filename]/route.ts +67 -0
- package/src/app/api/auth/register/route.ts +106 -0
- package/src/app/api/auth/remove_profile_picture/route.ts +86 -0
- package/src/app/api/auth/resend_verification/route.ts +107 -0
- package/src/app/api/auth/reset_password/route.ts +107 -0
- package/src/app/api/auth/update_user/route.ts +126 -0
- package/src/app/api/auth/upload_profile_picture/route.ts +268 -0
- package/src/app/api/auth/validate_reset_token/route.ts +80 -0
- package/src/app/api/auth/verify_email/route.ts +85 -0
- package/src/app/api/migrations/apply/route.ts +91 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/fonts/GeistMonoVF.woff +0 -0
- package/src/app/fonts/GeistVF.woff +0 -0
- package/src/app/forgot_password/forgot_password_page_client.tsx +60 -0
- package/src/app/forgot_password/page.tsx +24 -0
- package/src/app/globals.css +89 -0
- package/src/app/hazo_connect/api/sqlite/data/route.ts +197 -0
- package/src/app/hazo_connect/api/sqlite/schema/route.ts +35 -0
- package/src/app/hazo_connect/api/sqlite/tables/route.ts +26 -0
- package/src/app/hazo_connect/sqlite_admin/page.tsx +51 -0
- package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +947 -0
- package/src/app/layout.tsx +43 -0
- package/src/app/login/login_page_client.tsx +71 -0
- package/src/app/login/page.tsx +26 -0
- package/src/app/my_settings/my_settings_page_client.tsx +120 -0
- package/src/app/my_settings/page.tsx +40 -0
- package/src/app/page.tsx +170 -0
- package/src/app/register/page.tsx +26 -0
- package/src/app/register/register_page_client.tsx +72 -0
- package/src/app/reset_password/page.tsx +29 -0
- package/src/app/reset_password/reset_password_page_client.tsx +81 -0
- package/src/app/verify_email/page.tsx +24 -0
- package/src/app/verify_email/verify_email_page_client.tsx +60 -0
- package/src/components/layouts/email_verification/config/email_verification_field_config.ts +86 -0
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +291 -0
- package/src/components/layouts/email_verification/index.tsx +297 -0
- package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +58 -0
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +179 -0
- package/src/components/layouts/forgot_password/index.tsx +168 -0
- package/src/components/layouts/login/config/login_field_config.ts +67 -0
- package/src/components/layouts/login/hooks/use_login_form.ts +281 -0
- package/src/components/layouts/login/index.tsx +224 -0
- package/src/components/layouts/my_settings/components/editable_field.tsx +177 -0
- package/src/components/layouts/my_settings/components/password_change_dialog.tsx +301 -0
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +385 -0
- package/src/components/layouts/my_settings/components/profile_picture_display.tsx +66 -0
- package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +143 -0
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +282 -0
- package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +341 -0
- package/src/components/layouts/my_settings/config/my_settings_field_config.ts +61 -0
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +458 -0
- package/src/components/layouts/my_settings/index.tsx +351 -0
- package/src/components/layouts/register/config/register_field_config.ts +101 -0
- package/src/components/layouts/register/hooks/use_register_form.ts +272 -0
- package/src/components/layouts/register/index.tsx +208 -0
- package/src/components/layouts/reset_password/config/reset_password_field_config.ts +86 -0
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +276 -0
- package/src/components/layouts/reset_password/index.tsx +294 -0
- package/src/components/layouts/shared/components/already_logged_in_guard.tsx +95 -0
- package/src/components/layouts/shared/components/field_error_message.tsx +29 -0
- package/src/components/layouts/shared/components/form_action_buttons.tsx +64 -0
- package/src/components/layouts/shared/components/form_field_wrapper.tsx +44 -0
- package/src/components/layouts/shared/components/form_header.tsx +36 -0
- package/src/components/layouts/shared/components/logout_button.tsx +76 -0
- package/src/components/layouts/shared/components/password_field.tsx +72 -0
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +264 -0
- package/src/components/layouts/shared/components/two_column_auth_layout.tsx +44 -0
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +78 -0
- package/src/components/layouts/shared/components/visual_panel.tsx +41 -0
- package/src/components/layouts/shared/config/layout_customization.ts +95 -0
- package/src/components/layouts/shared/data/layout_data_client.ts +19 -0
- package/src/components/layouts/shared/hooks/use_auth_status.ts +103 -0
- package/src/components/layouts/shared/utils/ip_address.ts +37 -0
- package/src/components/layouts/shared/utils/validation.ts +66 -0
- package/src/components/ui/avatar.tsx +50 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/dialog.tsx +122 -0
- package/src/components/ui/hazo_ui_tooltip.tsx +67 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/sheet.tsx +139 -0
- package/src/components/ui/sidebar.tsx +773 -0
- package/src/components/ui/skeleton.tsx +15 -0
- package/src/components/ui/sonner.tsx +31 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/components/ui/vertical-tabs.tsx +59 -0
- package/src/hooks/use-mobile.tsx +19 -0
- package/src/lib/already_logged_in_config.server.ts +46 -0
- package/src/lib/app_logger.ts +24 -0
- package/src/lib/auth/auth_utils.server.ts +196 -0
- package/src/lib/auth/server_auth.ts +88 -0
- package/src/lib/config/config_loader.server.ts +149 -0
- package/src/lib/email_verification_config.server.ts +32 -0
- package/src/lib/file_types_config.server.ts +25 -0
- package/src/lib/forgot_password_config.server.ts +32 -0
- package/src/lib/hazo_connect_instance.server.ts +77 -0
- package/src/lib/hazo_connect_setup.server.ts +181 -0
- package/src/lib/hazo_connect_setup.ts +54 -0
- package/src/lib/login_config.server.ts +46 -0
- package/src/lib/messages_config.server.ts +45 -0
- package/src/lib/migrations/apply_migration.ts +105 -0
- package/src/lib/my_settings_config.server.ts +135 -0
- package/src/lib/password_requirements_config.server.ts +39 -0
- package/src/lib/profile_picture_config.server.ts +56 -0
- package/src/lib/register_config.server.ts +57 -0
- package/src/lib/reset_password_config.server.ts +75 -0
- package/src/lib/services/email_service.ts +581 -0
- package/src/lib/services/email_verification_service.ts +264 -0
- package/src/lib/services/login_service.ts +118 -0
- package/src/lib/services/password_change_service.ts +154 -0
- package/src/lib/services/password_reset_service.ts +405 -0
- package/src/lib/services/profile_picture_remove_service.ts +120 -0
- package/src/lib/services/profile_picture_service.ts +215 -0
- package/src/lib/services/profile_picture_source_mapper.ts +62 -0
- package/src/lib/services/registration_service.ts +163 -0
- package/src/lib/services/token_service.ts +240 -0
- package/src/lib/services/user_update_service.ts +128 -0
- package/src/lib/ui_sizes_config.server.ts +37 -0
- package/src/lib/user_fields_config.server.ts +31 -0
- package/src/lib/utils/api_route_helpers.ts +60 -0
- package/src/lib/utils.ts +11 -0
- package/src/middleware.ts +91 -0
- package/src/server/config/config_loader.ts +496 -0
- package/src/server/index.ts +38 -0
- package/src/server/logging/logger_service.ts +56 -0
- package/src/server/routes/root_router.ts +16 -0
- package/src/server/server.ts +28 -0
- package/src/server/types/app_types.ts +74 -0
- package/src/server/types/express.d.ts +15 -0
- package/src/stories/email_verification_layout.stories.tsx +137 -0
- package/src/stories/forgot_password_layout.stories.tsx +85 -0
- package/src/stories/login_layout.stories.tsx +85 -0
- package/src/stories/project_overview.stories.tsx +33 -0
- package/src/stories/register_layout.stories.tsx +107 -0
- package/tailwind.config.ts +77 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,773 @@
|
|
|
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 { PanelLeft } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
import { useIsMobile } from "@/hooks/use-mobile"
|
|
9
|
+
import { cn } from "@/lib/utils"
|
|
10
|
+
import { Button } from "@/components/ui/button"
|
|
11
|
+
import { Input } from "@/components/ui/input"
|
|
12
|
+
import { Separator } from "@/components/ui/separator"
|
|
13
|
+
import {
|
|
14
|
+
Sheet,
|
|
15
|
+
SheetContent,
|
|
16
|
+
SheetDescription,
|
|
17
|
+
SheetHeader,
|
|
18
|
+
SheetTitle,
|
|
19
|
+
} from "@/components/ui/sheet"
|
|
20
|
+
import { Skeleton } from "@/components/ui/skeleton"
|
|
21
|
+
import {
|
|
22
|
+
Tooltip,
|
|
23
|
+
TooltipContent,
|
|
24
|
+
TooltipProvider,
|
|
25
|
+
TooltipTrigger,
|
|
26
|
+
} from "@/components/ui/tooltip"
|
|
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 SidebarContextProps = {
|
|
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<SidebarContextProps | 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
|
+
const SidebarProvider = React.forwardRef<
|
|
57
|
+
HTMLDivElement,
|
|
58
|
+
React.ComponentProps<"div"> & {
|
|
59
|
+
defaultOpen?: boolean
|
|
60
|
+
open?: boolean
|
|
61
|
+
onOpenChange?: (open: boolean) => void
|
|
62
|
+
}
|
|
63
|
+
>(
|
|
64
|
+
(
|
|
65
|
+
{
|
|
66
|
+
defaultOpen = true,
|
|
67
|
+
open: openProp,
|
|
68
|
+
onOpenChange: setOpenProp,
|
|
69
|
+
className,
|
|
70
|
+
style,
|
|
71
|
+
children,
|
|
72
|
+
...props
|
|
73
|
+
},
|
|
74
|
+
ref
|
|
75
|
+
) => {
|
|
76
|
+
const isMobile = useIsMobile()
|
|
77
|
+
const [openMobile, setOpenMobile] = React.useState(false)
|
|
78
|
+
|
|
79
|
+
// This is the internal state of the sidebar.
|
|
80
|
+
// We use openProp and setOpenProp for control from outside the component.
|
|
81
|
+
const [_open, _setOpen] = React.useState(defaultOpen)
|
|
82
|
+
const open = openProp ?? _open
|
|
83
|
+
const setOpen = React.useCallback(
|
|
84
|
+
(value: boolean | ((value: boolean) => boolean)) => {
|
|
85
|
+
const openState = typeof value === "function" ? value(open) : value
|
|
86
|
+
if (setOpenProp) {
|
|
87
|
+
setOpenProp(openState)
|
|
88
|
+
} else {
|
|
89
|
+
_setOpen(openState)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// This sets the cookie to keep the sidebar state.
|
|
93
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
|
|
94
|
+
},
|
|
95
|
+
[setOpenProp, open]
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
// Helper to toggle the sidebar.
|
|
99
|
+
const toggleSidebar = React.useCallback(() => {
|
|
100
|
+
return isMobile
|
|
101
|
+
? setOpenMobile((open) => !open)
|
|
102
|
+
: setOpen((open) => !open)
|
|
103
|
+
}, [isMobile, setOpen, setOpenMobile])
|
|
104
|
+
|
|
105
|
+
// Adds a keyboard shortcut to toggle the sidebar.
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
108
|
+
if (
|
|
109
|
+
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
110
|
+
(event.metaKey || event.ctrlKey)
|
|
111
|
+
) {
|
|
112
|
+
event.preventDefault()
|
|
113
|
+
toggleSidebar()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
window.addEventListener("keydown", handleKeyDown)
|
|
118
|
+
return () => window.removeEventListener("keydown", handleKeyDown)
|
|
119
|
+
}, [toggleSidebar])
|
|
120
|
+
|
|
121
|
+
// We add a state so that we can do data-state="expanded" or "collapsed".
|
|
122
|
+
// This makes it easier to style the sidebar with Tailwind classes.
|
|
123
|
+
const state = open ? "expanded" : "collapsed"
|
|
124
|
+
|
|
125
|
+
const contextValue = React.useMemo<SidebarContextProps>(
|
|
126
|
+
() => ({
|
|
127
|
+
state,
|
|
128
|
+
open,
|
|
129
|
+
setOpen,
|
|
130
|
+
isMobile,
|
|
131
|
+
openMobile,
|
|
132
|
+
setOpenMobile,
|
|
133
|
+
toggleSidebar,
|
|
134
|
+
}),
|
|
135
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<SidebarContext.Provider value={contextValue}>
|
|
140
|
+
<TooltipProvider delayDuration={0}>
|
|
141
|
+
<div
|
|
142
|
+
style={
|
|
143
|
+
{
|
|
144
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
145
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
146
|
+
...style,
|
|
147
|
+
} as React.CSSProperties
|
|
148
|
+
}
|
|
149
|
+
className={cn(
|
|
150
|
+
"group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
|
|
151
|
+
className
|
|
152
|
+
)}
|
|
153
|
+
ref={ref}
|
|
154
|
+
{...props}
|
|
155
|
+
>
|
|
156
|
+
{children}
|
|
157
|
+
</div>
|
|
158
|
+
</TooltipProvider>
|
|
159
|
+
</SidebarContext.Provider>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
SidebarProvider.displayName = "SidebarProvider"
|
|
164
|
+
|
|
165
|
+
const Sidebar = React.forwardRef<
|
|
166
|
+
HTMLDivElement,
|
|
167
|
+
React.ComponentProps<"div"> & {
|
|
168
|
+
side?: "left" | "right"
|
|
169
|
+
variant?: "sidebar" | "floating" | "inset"
|
|
170
|
+
collapsible?: "offcanvas" | "icon" | "none"
|
|
171
|
+
}
|
|
172
|
+
>(
|
|
173
|
+
(
|
|
174
|
+
{
|
|
175
|
+
side = "left",
|
|
176
|
+
variant = "sidebar",
|
|
177
|
+
collapsible = "offcanvas",
|
|
178
|
+
className,
|
|
179
|
+
children,
|
|
180
|
+
...props
|
|
181
|
+
},
|
|
182
|
+
ref
|
|
183
|
+
) => {
|
|
184
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
|
185
|
+
|
|
186
|
+
if (collapsible === "none") {
|
|
187
|
+
return (
|
|
188
|
+
<div
|
|
189
|
+
className={cn(
|
|
190
|
+
"flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
|
|
191
|
+
className
|
|
192
|
+
)}
|
|
193
|
+
ref={ref}
|
|
194
|
+
{...props}
|
|
195
|
+
>
|
|
196
|
+
{children}
|
|
197
|
+
</div>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (isMobile) {
|
|
202
|
+
return (
|
|
203
|
+
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
|
204
|
+
<SheetContent
|
|
205
|
+
data-sidebar="sidebar"
|
|
206
|
+
data-mobile="true"
|
|
207
|
+
className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
|
|
208
|
+
style={
|
|
209
|
+
{
|
|
210
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
211
|
+
} as React.CSSProperties
|
|
212
|
+
}
|
|
213
|
+
side={side}
|
|
214
|
+
>
|
|
215
|
+
<SheetHeader className="sr-only">
|
|
216
|
+
<SheetTitle>Sidebar</SheetTitle>
|
|
217
|
+
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
218
|
+
</SheetHeader>
|
|
219
|
+
<div className="flex h-full w-full flex-col">{children}</div>
|
|
220
|
+
</SheetContent>
|
|
221
|
+
</Sheet>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div
|
|
227
|
+
ref={ref}
|
|
228
|
+
className="group peer hidden text-sidebar-foreground md:block"
|
|
229
|
+
data-state={state}
|
|
230
|
+
data-collapsible={state === "collapsed" ? collapsible : ""}
|
|
231
|
+
data-variant={variant}
|
|
232
|
+
data-side={side}
|
|
233
|
+
>
|
|
234
|
+
{/* This is what handles the sidebar gap on desktop */}
|
|
235
|
+
<div
|
|
236
|
+
className={cn(
|
|
237
|
+
"relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear",
|
|
238
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
239
|
+
"group-data-[side=right]:rotate-180",
|
|
240
|
+
variant === "floating" || variant === "inset"
|
|
241
|
+
? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"
|
|
242
|
+
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"
|
|
243
|
+
)}
|
|
244
|
+
/>
|
|
245
|
+
<div
|
|
246
|
+
className={cn(
|
|
247
|
+
"fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
|
|
248
|
+
side === "left"
|
|
249
|
+
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
|
|
250
|
+
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
|
|
251
|
+
// Adjust the padding for floating and inset variants.
|
|
252
|
+
variant === "floating" || variant === "inset"
|
|
253
|
+
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"
|
|
254
|
+
: "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
255
|
+
className
|
|
256
|
+
)}
|
|
257
|
+
{...props}
|
|
258
|
+
>
|
|
259
|
+
<div
|
|
260
|
+
data-sidebar="sidebar"
|
|
261
|
+
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"
|
|
262
|
+
>
|
|
263
|
+
{children}
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
Sidebar.displayName = "Sidebar"
|
|
271
|
+
|
|
272
|
+
const SidebarTrigger = React.forwardRef<
|
|
273
|
+
React.ElementRef<typeof Button>,
|
|
274
|
+
React.ComponentProps<typeof Button>
|
|
275
|
+
>(({ className, onClick, ...props }, ref) => {
|
|
276
|
+
const { toggleSidebar } = useSidebar()
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<Button
|
|
280
|
+
ref={ref}
|
|
281
|
+
data-sidebar="trigger"
|
|
282
|
+
variant="ghost"
|
|
283
|
+
size="icon"
|
|
284
|
+
className={cn("h-7 w-7", className)}
|
|
285
|
+
onClick={(event) => {
|
|
286
|
+
onClick?.(event)
|
|
287
|
+
toggleSidebar()
|
|
288
|
+
}}
|
|
289
|
+
{...props}
|
|
290
|
+
>
|
|
291
|
+
<PanelLeft />
|
|
292
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
293
|
+
</Button>
|
|
294
|
+
)
|
|
295
|
+
})
|
|
296
|
+
SidebarTrigger.displayName = "SidebarTrigger"
|
|
297
|
+
|
|
298
|
+
const SidebarRail = React.forwardRef<
|
|
299
|
+
HTMLButtonElement,
|
|
300
|
+
React.ComponentProps<"button">
|
|
301
|
+
>(({ className, ...props }, ref) => {
|
|
302
|
+
const { toggleSidebar } = useSidebar()
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<button
|
|
306
|
+
ref={ref}
|
|
307
|
+
data-sidebar="rail"
|
|
308
|
+
aria-label="Toggle Sidebar"
|
|
309
|
+
tabIndex={-1}
|
|
310
|
+
onClick={toggleSidebar}
|
|
311
|
+
title="Toggle Sidebar"
|
|
312
|
+
className={cn(
|
|
313
|
+
"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",
|
|
314
|
+
"[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
|
|
315
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
316
|
+
"group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
|
|
317
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
318
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
319
|
+
className
|
|
320
|
+
)}
|
|
321
|
+
{...props}
|
|
322
|
+
/>
|
|
323
|
+
)
|
|
324
|
+
})
|
|
325
|
+
SidebarRail.displayName = "SidebarRail"
|
|
326
|
+
|
|
327
|
+
const SidebarInset = React.forwardRef<
|
|
328
|
+
HTMLDivElement,
|
|
329
|
+
React.ComponentProps<"main">
|
|
330
|
+
>(({ className, ...props }, ref) => {
|
|
331
|
+
return (
|
|
332
|
+
<main
|
|
333
|
+
ref={ref}
|
|
334
|
+
className={cn(
|
|
335
|
+
"relative flex w-full flex-1 flex-col bg-background",
|
|
336
|
+
"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",
|
|
337
|
+
className
|
|
338
|
+
)}
|
|
339
|
+
{...props}
|
|
340
|
+
/>
|
|
341
|
+
)
|
|
342
|
+
})
|
|
343
|
+
SidebarInset.displayName = "SidebarInset"
|
|
344
|
+
|
|
345
|
+
const SidebarInput = React.forwardRef<
|
|
346
|
+
React.ElementRef<typeof Input>,
|
|
347
|
+
React.ComponentProps<typeof Input>
|
|
348
|
+
>(({ className, ...props }, ref) => {
|
|
349
|
+
return (
|
|
350
|
+
<Input
|
|
351
|
+
ref={ref}
|
|
352
|
+
data-sidebar="input"
|
|
353
|
+
className={cn(
|
|
354
|
+
"h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
|
|
355
|
+
className
|
|
356
|
+
)}
|
|
357
|
+
{...props}
|
|
358
|
+
/>
|
|
359
|
+
)
|
|
360
|
+
})
|
|
361
|
+
SidebarInput.displayName = "SidebarInput"
|
|
362
|
+
|
|
363
|
+
const SidebarHeader = React.forwardRef<
|
|
364
|
+
HTMLDivElement,
|
|
365
|
+
React.ComponentProps<"div">
|
|
366
|
+
>(({ className, ...props }, ref) => {
|
|
367
|
+
return (
|
|
368
|
+
<div
|
|
369
|
+
ref={ref}
|
|
370
|
+
data-sidebar="header"
|
|
371
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
372
|
+
{...props}
|
|
373
|
+
/>
|
|
374
|
+
)
|
|
375
|
+
})
|
|
376
|
+
SidebarHeader.displayName = "SidebarHeader"
|
|
377
|
+
|
|
378
|
+
const SidebarFooter = React.forwardRef<
|
|
379
|
+
HTMLDivElement,
|
|
380
|
+
React.ComponentProps<"div">
|
|
381
|
+
>(({ className, ...props }, ref) => {
|
|
382
|
+
return (
|
|
383
|
+
<div
|
|
384
|
+
ref={ref}
|
|
385
|
+
data-sidebar="footer"
|
|
386
|
+
className={cn("flex flex-col gap-2 p-2", className)}
|
|
387
|
+
{...props}
|
|
388
|
+
/>
|
|
389
|
+
)
|
|
390
|
+
})
|
|
391
|
+
SidebarFooter.displayName = "SidebarFooter"
|
|
392
|
+
|
|
393
|
+
const SidebarSeparator = React.forwardRef<
|
|
394
|
+
React.ElementRef<typeof Separator>,
|
|
395
|
+
React.ComponentProps<typeof Separator>
|
|
396
|
+
>(({ className, ...props }, ref) => {
|
|
397
|
+
return (
|
|
398
|
+
<Separator
|
|
399
|
+
ref={ref}
|
|
400
|
+
data-sidebar="separator"
|
|
401
|
+
className={cn("mx-2 w-auto bg-sidebar-border", className)}
|
|
402
|
+
{...props}
|
|
403
|
+
/>
|
|
404
|
+
)
|
|
405
|
+
})
|
|
406
|
+
SidebarSeparator.displayName = "SidebarSeparator"
|
|
407
|
+
|
|
408
|
+
const SidebarContent = React.forwardRef<
|
|
409
|
+
HTMLDivElement,
|
|
410
|
+
React.ComponentProps<"div">
|
|
411
|
+
>(({ className, ...props }, ref) => {
|
|
412
|
+
return (
|
|
413
|
+
<div
|
|
414
|
+
ref={ref}
|
|
415
|
+
data-sidebar="content"
|
|
416
|
+
className={cn(
|
|
417
|
+
"flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
418
|
+
className
|
|
419
|
+
)}
|
|
420
|
+
{...props}
|
|
421
|
+
/>
|
|
422
|
+
)
|
|
423
|
+
})
|
|
424
|
+
SidebarContent.displayName = "SidebarContent"
|
|
425
|
+
|
|
426
|
+
const SidebarGroup = React.forwardRef<
|
|
427
|
+
HTMLDivElement,
|
|
428
|
+
React.ComponentProps<"div">
|
|
429
|
+
>(({ className, ...props }, ref) => {
|
|
430
|
+
return (
|
|
431
|
+
<div
|
|
432
|
+
ref={ref}
|
|
433
|
+
data-sidebar="group"
|
|
434
|
+
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
435
|
+
{...props}
|
|
436
|
+
/>
|
|
437
|
+
)
|
|
438
|
+
})
|
|
439
|
+
SidebarGroup.displayName = "SidebarGroup"
|
|
440
|
+
|
|
441
|
+
const SidebarGroupLabel = React.forwardRef<
|
|
442
|
+
HTMLDivElement,
|
|
443
|
+
React.ComponentProps<"div"> & { asChild?: boolean }
|
|
444
|
+
>(({ className, asChild = false, ...props }, ref) => {
|
|
445
|
+
const Comp = asChild ? Slot : "div"
|
|
446
|
+
|
|
447
|
+
return (
|
|
448
|
+
<Comp
|
|
449
|
+
ref={ref}
|
|
450
|
+
data-sidebar="group-label"
|
|
451
|
+
className={cn(
|
|
452
|
+
"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",
|
|
453
|
+
"group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
454
|
+
className
|
|
455
|
+
)}
|
|
456
|
+
{...props}
|
|
457
|
+
/>
|
|
458
|
+
)
|
|
459
|
+
})
|
|
460
|
+
SidebarGroupLabel.displayName = "SidebarGroupLabel"
|
|
461
|
+
|
|
462
|
+
const SidebarGroupAction = React.forwardRef<
|
|
463
|
+
HTMLButtonElement,
|
|
464
|
+
React.ComponentProps<"button"> & { asChild?: boolean }
|
|
465
|
+
>(({ className, asChild = false, ...props }, ref) => {
|
|
466
|
+
const Comp = asChild ? Slot : "button"
|
|
467
|
+
|
|
468
|
+
return (
|
|
469
|
+
<Comp
|
|
470
|
+
ref={ref}
|
|
471
|
+
data-sidebar="group-action"
|
|
472
|
+
className={cn(
|
|
473
|
+
"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",
|
|
474
|
+
// Increases the hit area of the button on mobile.
|
|
475
|
+
"after:absolute after:-inset-2 after:md:hidden",
|
|
476
|
+
"group-data-[collapsible=icon]:hidden",
|
|
477
|
+
className
|
|
478
|
+
)}
|
|
479
|
+
{...props}
|
|
480
|
+
/>
|
|
481
|
+
)
|
|
482
|
+
})
|
|
483
|
+
SidebarGroupAction.displayName = "SidebarGroupAction"
|
|
484
|
+
|
|
485
|
+
const SidebarGroupContent = React.forwardRef<
|
|
486
|
+
HTMLDivElement,
|
|
487
|
+
React.ComponentProps<"div">
|
|
488
|
+
>(({ className, ...props }, ref) => (
|
|
489
|
+
<div
|
|
490
|
+
ref={ref}
|
|
491
|
+
data-sidebar="group-content"
|
|
492
|
+
className={cn("w-full text-sm", className)}
|
|
493
|
+
{...props}
|
|
494
|
+
/>
|
|
495
|
+
))
|
|
496
|
+
SidebarGroupContent.displayName = "SidebarGroupContent"
|
|
497
|
+
|
|
498
|
+
const SidebarMenu = React.forwardRef<
|
|
499
|
+
HTMLUListElement,
|
|
500
|
+
React.ComponentProps<"ul">
|
|
501
|
+
>(({ className, ...props }, ref) => (
|
|
502
|
+
<ul
|
|
503
|
+
ref={ref}
|
|
504
|
+
data-sidebar="menu"
|
|
505
|
+
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
506
|
+
{...props}
|
|
507
|
+
/>
|
|
508
|
+
))
|
|
509
|
+
SidebarMenu.displayName = "SidebarMenu"
|
|
510
|
+
|
|
511
|
+
const SidebarMenuItem = React.forwardRef<
|
|
512
|
+
HTMLLIElement,
|
|
513
|
+
React.ComponentProps<"li">
|
|
514
|
+
>(({ className, ...props }, ref) => (
|
|
515
|
+
<li
|
|
516
|
+
ref={ref}
|
|
517
|
+
data-sidebar="menu-item"
|
|
518
|
+
className={cn("group/menu-item relative", className)}
|
|
519
|
+
{...props}
|
|
520
|
+
/>
|
|
521
|
+
))
|
|
522
|
+
SidebarMenuItem.displayName = "SidebarMenuItem"
|
|
523
|
+
|
|
524
|
+
const sidebarMenuButtonVariants = cva(
|
|
525
|
+
"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] 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",
|
|
526
|
+
{
|
|
527
|
+
variants: {
|
|
528
|
+
variant: {
|
|
529
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
530
|
+
outline:
|
|
531
|
+
"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))]",
|
|
532
|
+
},
|
|
533
|
+
size: {
|
|
534
|
+
default: "h-8 text-sm",
|
|
535
|
+
sm: "h-7 text-xs",
|
|
536
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
defaultVariants: {
|
|
540
|
+
variant: "default",
|
|
541
|
+
size: "default",
|
|
542
|
+
},
|
|
543
|
+
}
|
|
544
|
+
)
|
|
545
|
+
|
|
546
|
+
const SidebarMenuButton = React.forwardRef<
|
|
547
|
+
HTMLButtonElement,
|
|
548
|
+
React.ComponentProps<"button"> & {
|
|
549
|
+
asChild?: boolean
|
|
550
|
+
isActive?: boolean
|
|
551
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>
|
|
552
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>
|
|
553
|
+
>(
|
|
554
|
+
(
|
|
555
|
+
{
|
|
556
|
+
asChild = false,
|
|
557
|
+
isActive = false,
|
|
558
|
+
variant = "default",
|
|
559
|
+
size = "default",
|
|
560
|
+
tooltip,
|
|
561
|
+
className,
|
|
562
|
+
...props
|
|
563
|
+
},
|
|
564
|
+
ref
|
|
565
|
+
) => {
|
|
566
|
+
const Comp = asChild ? Slot : "button"
|
|
567
|
+
const { isMobile, state } = useSidebar()
|
|
568
|
+
|
|
569
|
+
const button = (
|
|
570
|
+
<Comp
|
|
571
|
+
ref={ref}
|
|
572
|
+
data-sidebar="menu-button"
|
|
573
|
+
data-size={size}
|
|
574
|
+
data-active={isActive}
|
|
575
|
+
className={cn(sidebarMenuButtonVariants({ variant, size }), className)}
|
|
576
|
+
{...props}
|
|
577
|
+
/>
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
if (!tooltip) {
|
|
581
|
+
return button
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (typeof tooltip === "string") {
|
|
585
|
+
tooltip = {
|
|
586
|
+
children: tooltip,
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
return (
|
|
591
|
+
<Tooltip>
|
|
592
|
+
<TooltipTrigger asChild>{button}</TooltipTrigger>
|
|
593
|
+
<TooltipContent
|
|
594
|
+
side="right"
|
|
595
|
+
align="center"
|
|
596
|
+
hidden={state !== "collapsed" || isMobile}
|
|
597
|
+
{...tooltip}
|
|
598
|
+
/>
|
|
599
|
+
</Tooltip>
|
|
600
|
+
)
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
SidebarMenuButton.displayName = "SidebarMenuButton"
|
|
604
|
+
|
|
605
|
+
const SidebarMenuAction = React.forwardRef<
|
|
606
|
+
HTMLButtonElement,
|
|
607
|
+
React.ComponentProps<"button"> & {
|
|
608
|
+
asChild?: boolean
|
|
609
|
+
showOnHover?: boolean
|
|
610
|
+
}
|
|
611
|
+
>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
|
|
612
|
+
const Comp = asChild ? Slot : "button"
|
|
613
|
+
|
|
614
|
+
return (
|
|
615
|
+
<Comp
|
|
616
|
+
ref={ref}
|
|
617
|
+
data-sidebar="menu-action"
|
|
618
|
+
className={cn(
|
|
619
|
+
"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",
|
|
620
|
+
// Increases the hit area of the button on mobile.
|
|
621
|
+
"after:absolute after:-inset-2 after:md:hidden",
|
|
622
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
623
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
624
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
625
|
+
"group-data-[collapsible=icon]:hidden",
|
|
626
|
+
showOnHover &&
|
|
627
|
+
"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",
|
|
628
|
+
className
|
|
629
|
+
)}
|
|
630
|
+
{...props}
|
|
631
|
+
/>
|
|
632
|
+
)
|
|
633
|
+
})
|
|
634
|
+
SidebarMenuAction.displayName = "SidebarMenuAction"
|
|
635
|
+
|
|
636
|
+
const SidebarMenuBadge = React.forwardRef<
|
|
637
|
+
HTMLDivElement,
|
|
638
|
+
React.ComponentProps<"div">
|
|
639
|
+
>(({ className, ...props }, ref) => (
|
|
640
|
+
<div
|
|
641
|
+
ref={ref}
|
|
642
|
+
data-sidebar="menu-badge"
|
|
643
|
+
className={cn(
|
|
644
|
+
"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",
|
|
645
|
+
"peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
|
|
646
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
647
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
648
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
649
|
+
"group-data-[collapsible=icon]:hidden",
|
|
650
|
+
className
|
|
651
|
+
)}
|
|
652
|
+
{...props}
|
|
653
|
+
/>
|
|
654
|
+
))
|
|
655
|
+
SidebarMenuBadge.displayName = "SidebarMenuBadge"
|
|
656
|
+
|
|
657
|
+
const SidebarMenuSkeleton = React.forwardRef<
|
|
658
|
+
HTMLDivElement,
|
|
659
|
+
React.ComponentProps<"div"> & {
|
|
660
|
+
showIcon?: boolean
|
|
661
|
+
}
|
|
662
|
+
>(({ className, showIcon = false, ...props }, ref) => {
|
|
663
|
+
// Random width between 50 to 90%.
|
|
664
|
+
const width = React.useMemo(() => {
|
|
665
|
+
return `${Math.floor(Math.random() * 40) + 50}%`
|
|
666
|
+
}, [])
|
|
667
|
+
|
|
668
|
+
return (
|
|
669
|
+
<div
|
|
670
|
+
ref={ref}
|
|
671
|
+
data-sidebar="menu-skeleton"
|
|
672
|
+
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
|
673
|
+
{...props}
|
|
674
|
+
>
|
|
675
|
+
{showIcon && (
|
|
676
|
+
<Skeleton
|
|
677
|
+
className="size-4 rounded-md"
|
|
678
|
+
data-sidebar="menu-skeleton-icon"
|
|
679
|
+
/>
|
|
680
|
+
)}
|
|
681
|
+
<Skeleton
|
|
682
|
+
className="h-4 max-w-[--skeleton-width] flex-1"
|
|
683
|
+
data-sidebar="menu-skeleton-text"
|
|
684
|
+
style={
|
|
685
|
+
{
|
|
686
|
+
"--skeleton-width": width,
|
|
687
|
+
} as React.CSSProperties
|
|
688
|
+
}
|
|
689
|
+
/>
|
|
690
|
+
</div>
|
|
691
|
+
)
|
|
692
|
+
})
|
|
693
|
+
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton"
|
|
694
|
+
|
|
695
|
+
const SidebarMenuSub = React.forwardRef<
|
|
696
|
+
HTMLUListElement,
|
|
697
|
+
React.ComponentProps<"ul">
|
|
698
|
+
>(({ className, ...props }, ref) => (
|
|
699
|
+
<ul
|
|
700
|
+
ref={ref}
|
|
701
|
+
data-sidebar="menu-sub"
|
|
702
|
+
className={cn(
|
|
703
|
+
"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",
|
|
704
|
+
"group-data-[collapsible=icon]:hidden",
|
|
705
|
+
className
|
|
706
|
+
)}
|
|
707
|
+
{...props}
|
|
708
|
+
/>
|
|
709
|
+
))
|
|
710
|
+
SidebarMenuSub.displayName = "SidebarMenuSub"
|
|
711
|
+
|
|
712
|
+
const SidebarMenuSubItem = React.forwardRef<
|
|
713
|
+
HTMLLIElement,
|
|
714
|
+
React.ComponentProps<"li">
|
|
715
|
+
>(({ ...props }, ref) => <li ref={ref} {...props} />)
|
|
716
|
+
SidebarMenuSubItem.displayName = "SidebarMenuSubItem"
|
|
717
|
+
|
|
718
|
+
const SidebarMenuSubButton = React.forwardRef<
|
|
719
|
+
HTMLAnchorElement,
|
|
720
|
+
React.ComponentProps<"a"> & {
|
|
721
|
+
asChild?: boolean
|
|
722
|
+
size?: "sm" | "md"
|
|
723
|
+
isActive?: boolean
|
|
724
|
+
}
|
|
725
|
+
>(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
|
|
726
|
+
const Comp = asChild ? Slot : "a"
|
|
727
|
+
|
|
728
|
+
return (
|
|
729
|
+
<Comp
|
|
730
|
+
ref={ref}
|
|
731
|
+
data-sidebar="menu-sub-button"
|
|
732
|
+
data-size={size}
|
|
733
|
+
data-active={isActive}
|
|
734
|
+
className={cn(
|
|
735
|
+
"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",
|
|
736
|
+
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
737
|
+
size === "sm" && "text-xs",
|
|
738
|
+
size === "md" && "text-sm",
|
|
739
|
+
"group-data-[collapsible=icon]:hidden",
|
|
740
|
+
className
|
|
741
|
+
)}
|
|
742
|
+
{...props}
|
|
743
|
+
/>
|
|
744
|
+
)
|
|
745
|
+
})
|
|
746
|
+
SidebarMenuSubButton.displayName = "SidebarMenuSubButton"
|
|
747
|
+
|
|
748
|
+
export {
|
|
749
|
+
Sidebar,
|
|
750
|
+
SidebarContent,
|
|
751
|
+
SidebarFooter,
|
|
752
|
+
SidebarGroup,
|
|
753
|
+
SidebarGroupAction,
|
|
754
|
+
SidebarGroupContent,
|
|
755
|
+
SidebarGroupLabel,
|
|
756
|
+
SidebarHeader,
|
|
757
|
+
SidebarInput,
|
|
758
|
+
SidebarInset,
|
|
759
|
+
SidebarMenu,
|
|
760
|
+
SidebarMenuAction,
|
|
761
|
+
SidebarMenuBadge,
|
|
762
|
+
SidebarMenuButton,
|
|
763
|
+
SidebarMenuItem,
|
|
764
|
+
SidebarMenuSkeleton,
|
|
765
|
+
SidebarMenuSub,
|
|
766
|
+
SidebarMenuSubButton,
|
|
767
|
+
SidebarMenuSubItem,
|
|
768
|
+
SidebarProvider,
|
|
769
|
+
SidebarRail,
|
|
770
|
+
SidebarSeparator,
|
|
771
|
+
SidebarTrigger,
|
|
772
|
+
useSidebar,
|
|
773
|
+
}
|