hazo_auth 1.4.2 → 1.6.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/SETUP_CHECKLIST.md +708 -0
- package/dist/app/api/hazo_auth/change_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/change_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/change_password/route.js +98 -0
- package/dist/app/api/hazo_auth/forgot_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/forgot_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/forgot_password/route.js +78 -0
- package/dist/app/api/hazo_auth/get_auth/route.d.ts +10 -0
- package/dist/app/api/hazo_auth/get_auth/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/get_auth/route.js +63 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.d.ts +14 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/invalidate_cache/route.js +96 -0
- package/dist/app/api/hazo_auth/library_photos/route.d.ts +13 -0
- package/dist/app/api/hazo_auth/library_photos/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/library_photos/route.js +55 -0
- package/dist/app/api/hazo_auth/login/route.d.ts +12 -0
- package/dist/app/api/hazo_auth/login/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/login/route.js +140 -0
- package/dist/app/api/hazo_auth/logout/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/logout/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/logout/route.js +71 -0
- package/dist/app/api/hazo_auth/me/route.d.ts +3 -0
- package/dist/app/api/hazo_auth/me/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/me/route.js +34 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.d.ts +7 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/profile_picture/[filename]/route.js +43 -0
- package/dist/app/api/hazo_auth/register/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/register/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/register/route.js +80 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/remove_profile_picture/route.js +64 -0
- package/dist/app/api/hazo_auth/resend_verification/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/resend_verification/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/resend_verification/route.js +79 -0
- package/dist/app/api/hazo_auth/reset_password/route.d.ts +8 -0
- package/dist/app/api/hazo_auth/reset_password/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/reset_password/route.js +76 -0
- package/dist/app/api/hazo_auth/update_user/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/update_user/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/update_user/route.js +95 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.d.ts +9 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/upload_profile_picture/route.js +204 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.d.ts +6 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/validate_reset_token/route.js +58 -0
- package/dist/app/api/hazo_auth/verify_email/route.d.ts +11 -0
- package/dist/app/api/hazo_auth/verify_email/route.d.ts.map +1 -0
- package/dist/app/api/hazo_auth/verify_email/route.js +63 -0
- package/dist/cli/generate.d.ts +2 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +117 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +120 -0
- package/dist/cli/validate.d.ts +15 -0
- package/dist/cli/validate.d.ts.map +1 -0
- package/dist/cli/validate.js +509 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +45 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -1
- package/dist/hooks/use-mobile.js +17 -3
- package/dist/server/routes/change_password.d.ts +2 -0
- package/dist/server/routes/change_password.d.ts.map +1 -0
- package/dist/server/routes/change_password.js +2 -0
- package/dist/server/routes/forgot_password.d.ts +2 -0
- package/dist/server/routes/forgot_password.d.ts.map +1 -0
- package/dist/server/routes/forgot_password.js +2 -0
- package/dist/server/routes/get_auth.d.ts +2 -0
- package/dist/server/routes/get_auth.d.ts.map +1 -0
- package/dist/server/routes/get_auth.js +2 -0
- package/dist/server/routes/index.d.ts +18 -0
- package/dist/server/routes/index.d.ts.map +1 -0
- package/dist/server/routes/index.js +24 -0
- package/dist/server/routes/invalidate_cache.d.ts +2 -0
- package/dist/server/routes/invalidate_cache.d.ts.map +1 -0
- package/dist/server/routes/invalidate_cache.js +2 -0
- package/dist/server/routes/library_photos.d.ts +2 -0
- package/dist/server/routes/library_photos.d.ts.map +1 -0
- package/dist/server/routes/library_photos.js +2 -0
- package/dist/server/routes/login.d.ts +2 -0
- package/dist/server/routes/login.d.ts.map +1 -0
- package/dist/server/routes/login.js +2 -0
- package/dist/server/routes/logout.d.ts +2 -0
- package/dist/server/routes/logout.d.ts.map +1 -0
- package/dist/server/routes/logout.js +2 -0
- package/dist/server/routes/me.d.ts +2 -0
- package/dist/server/routes/me.d.ts.map +1 -0
- package/dist/server/routes/me.js +2 -0
- package/dist/server/routes/profile_picture_filename.d.ts +2 -0
- package/dist/server/routes/profile_picture_filename.d.ts.map +1 -0
- package/dist/server/routes/profile_picture_filename.js +3 -0
- package/dist/server/routes/register.d.ts +2 -0
- package/dist/server/routes/register.d.ts.map +1 -0
- package/dist/server/routes/register.js +2 -0
- package/dist/server/routes/remove_profile_picture.d.ts +2 -0
- package/dist/server/routes/remove_profile_picture.d.ts.map +1 -0
- package/dist/server/routes/remove_profile_picture.js +2 -0
- package/dist/server/routes/resend_verification.d.ts +2 -0
- package/dist/server/routes/resend_verification.d.ts.map +1 -0
- package/dist/server/routes/resend_verification.js +2 -0
- package/dist/server/routes/reset_password.d.ts +2 -0
- package/dist/server/routes/reset_password.d.ts.map +1 -0
- package/dist/server/routes/reset_password.js +2 -0
- package/dist/server/routes/update_user.d.ts +2 -0
- package/dist/server/routes/update_user.d.ts.map +1 -0
- package/dist/server/routes/update_user.js +2 -0
- package/dist/server/routes/upload_profile_picture.d.ts +2 -0
- package/dist/server/routes/upload_profile_picture.d.ts.map +1 -0
- package/dist/server/routes/upload_profile_picture.js +2 -0
- package/dist/server/routes/validate_reset_token.d.ts +2 -0
- package/dist/server/routes/validate_reset_token.d.ts.map +1 -0
- package/dist/server/routes/validate_reset_token.js +2 -0
- package/dist/server/routes/verify_email.d.ts +2 -0
- package/dist/server/routes/verify_email.d.ts.map +1 -0
- package/dist/server/routes/verify_email.js +2 -0
- package/package.json +12 -17
- package/components.json +0 -22
- package/instrumentation.ts +0 -32
- package/migrations/001_add_token_type_to_refresh_tokens.sql +0 -14
- package/migrations/002_add_name_to_hazo_users.sql +0 -7
- package/migrations/003_add_url_on_logon_to_hazo_users.sql +0 -8
- package/next.config.mjs +0 -67
- package/postcss.config.mjs +0 -8
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/scripts/apply_migration.ts +0 -118
- package/scripts/init_users.ts +0 -378
- package/src/app/api/hazo_auth/auth/upload_profile_picture/route.ts +0 -268
- package/src/app/api/hazo_auth/change_password/route.ts +0 -132
- package/src/app/api/hazo_auth/forgot_password/route.ts +0 -107
- package/src/app/api/hazo_auth/get_auth/route.ts +0 -89
- package/src/app/api/hazo_auth/invalidate_cache/route.ts +0 -139
- package/src/app/api/hazo_auth/library_photos/route.ts +0 -73
- package/src/app/api/hazo_auth/login/route.ts +0 -181
- package/src/app/api/hazo_auth/logout/route.ts +0 -89
- package/src/app/api/hazo_auth/me/route.ts +0 -47
- package/src/app/api/hazo_auth/profile_picture/[filename]/route.ts +0 -67
- package/src/app/api/hazo_auth/register/route.ts +0 -109
- package/src/app/api/hazo_auth/remove_profile_picture/route.ts +0 -86
- package/src/app/api/hazo_auth/resend_verification/route.ts +0 -108
- package/src/app/api/hazo_auth/reset_password/route.ts +0 -107
- package/src/app/api/hazo_auth/update_user/route.ts +0 -126
- package/src/app/api/hazo_auth/upload_profile_picture/route.ts +0 -268
- package/src/app/api/hazo_auth/user_management/permissions/route.ts +0 -367
- package/src/app/api/hazo_auth/user_management/roles/route.ts +0 -442
- package/src/app/api/hazo_auth/user_management/users/roles/route.ts +0 -367
- package/src/app/api/hazo_auth/user_management/users/route.ts +0 -239
- package/src/app/api/hazo_auth/validate_reset_token/route.ts +0 -83
- package/src/app/api/hazo_auth/verify_email/route.ts +0 -88
- package/src/app/api/migrations/apply/route.ts +0 -91
- 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/globals.css +0 -89
- package/src/app/hazo_auth/forgot_password/forgot_password_page_client.tsx +0 -60
- package/src/app/hazo_auth/forgot_password/page.tsx +0 -24
- package/src/app/hazo_auth/login/login_page_client.tsx +0 -86
- package/src/app/hazo_auth/login/page.tsx +0 -38
- package/src/app/hazo_auth/my_settings/my_settings_page_client.tsx +0 -120
- package/src/app/hazo_auth/my_settings/page.tsx +0 -40
- package/src/app/hazo_auth/register/page.tsx +0 -36
- package/src/app/hazo_auth/register/register_page_client.tsx +0 -81
- package/src/app/hazo_auth/reset_password/page.tsx +0 -29
- package/src/app/hazo_auth/reset_password/reset_password_page_client.tsx +0 -81
- package/src/app/hazo_auth/user_management/page.tsx +0 -14
- package/src/app/hazo_auth/user_management/user_management_page_client.tsx +0 -16
- package/src/app/hazo_auth/verify_email/page.tsx +0 -24
- package/src/app/hazo_auth/verify_email/verify_email_page_client.tsx +0 -60
- package/src/app/hazo_connect/api/sqlite/data/route.ts +0 -203
- package/src/app/hazo_connect/api/sqlite/schema/route.ts +0 -45
- package/src/app/hazo_connect/api/sqlite/tables/route.ts +0 -36
- package/src/app/hazo_connect/sqlite_admin/page.tsx +0 -51
- package/src/app/hazo_connect/sqlite_admin/sqlite-admin-client.tsx +0 -984
- package/src/app/layout.tsx +0 -43
- package/src/app/page.tsx +0 -170
- package/src/components/index.ts +0 -7
- package/src/components/layouts/email_verification/config/email_verification_field_config.ts +0 -86
- package/src/components/layouts/email_verification/hooks/use_email_verification.ts +0 -297
- package/src/components/layouts/email_verification/index.tsx +0 -297
- package/src/components/layouts/forgot_password/config/forgot_password_field_config.ts +0 -58
- package/src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts +0 -179
- package/src/components/layouts/forgot_password/index.tsx +0 -168
- package/src/components/layouts/index.ts +0 -26
- package/src/components/layouts/login/config/login_field_config.ts +0 -67
- package/src/components/layouts/login/hooks/use_login_form.ts +0 -286
- package/src/components/layouts/login/index.tsx +0 -252
- package/src/components/layouts/my_settings/components/editable_field.tsx +0 -177
- package/src/components/layouts/my_settings/components/password_change_dialog.tsx +0 -301
- package/src/components/layouts/my_settings/components/profile_picture_dialog.tsx +0 -385
- package/src/components/layouts/my_settings/components/profile_picture_display.tsx +0 -66
- package/src/components/layouts/my_settings/components/profile_picture_gravatar_tab.tsx +0 -143
- package/src/components/layouts/my_settings/components/profile_picture_library_tab.tsx +0 -311
- package/src/components/layouts/my_settings/components/profile_picture_upload_tab.tsx +0 -341
- package/src/components/layouts/my_settings/config/my_settings_field_config.ts +0 -61
- package/src/components/layouts/my_settings/hooks/use_my_settings.ts +0 -458
- package/src/components/layouts/my_settings/index.tsx +0 -351
- package/src/components/layouts/register/config/register_field_config.ts +0 -101
- package/src/components/layouts/register/hooks/use_register_form.ts +0 -275
- package/src/components/layouts/register/index.tsx +0 -226
- package/src/components/layouts/reset_password/config/reset_password_field_config.ts +0 -86
- package/src/components/layouts/reset_password/hooks/use_reset_password_form.ts +0 -276
- package/src/components/layouts/reset_password/index.tsx +0 -294
- package/src/components/layouts/shared/components/already_logged_in_guard.tsx +0 -95
- package/src/components/layouts/shared/components/auth_page_shell.tsx +0 -36
- package/src/components/layouts/shared/components/field_error_message.tsx +0 -29
- package/src/components/layouts/shared/components/form_action_buttons.tsx +0 -64
- package/src/components/layouts/shared/components/form_field_wrapper.tsx +0 -44
- package/src/components/layouts/shared/components/form_header.tsx +0 -36
- package/src/components/layouts/shared/components/logout_button.tsx +0 -76
- package/src/components/layouts/shared/components/password_field.tsx +0 -72
- package/src/components/layouts/shared/components/profile_pic_menu.tsx +0 -321
- package/src/components/layouts/shared/components/profile_pic_menu_wrapper.tsx +0 -40
- package/src/components/layouts/shared/components/sidebar_layout_wrapper.tsx +0 -214
- package/src/components/layouts/shared/components/standalone_layout_wrapper.tsx +0 -53
- package/src/components/layouts/shared/components/two_column_auth_layout.tsx +0 -44
- package/src/components/layouts/shared/components/unauthorized_guard.tsx +0 -78
- package/src/components/layouts/shared/components/visual_panel.tsx +0 -41
- package/src/components/layouts/shared/config/layout_customization.ts +0 -95
- package/src/components/layouts/shared/data/layout_data_client.ts +0 -19
- package/src/components/layouts/shared/hooks/use_auth_status.ts +0 -103
- package/src/components/layouts/shared/hooks/use_hazo_auth.ts +0 -158
- package/src/components/layouts/shared/index.ts +0 -34
- package/src/components/layouts/shared/utils/ip_address.ts +0 -37
- package/src/components/layouts/shared/utils/validation.ts +0 -66
- package/src/components/layouts/user_management/components/roles_matrix.tsx +0 -607
- package/src/components/layouts/user_management/index.tsx +0 -1295
- package/src/components/ui/alert-dialog.tsx +0 -141
- package/src/components/ui/avatar.tsx +0 -50
- package/src/components/ui/button.tsx +0 -57
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/hazo_ui_tooltip.tsx +0 -67
- package/src/components/ui/index.ts +0 -22
- package/src/components/ui/input.tsx +0 -22
- package/src/components/ui/label.tsx +0 -26
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/sheet.tsx +0 -139
- package/src/components/ui/sidebar.tsx +0 -773
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/switch.tsx +0 -29
- package/src/components/ui/table.tsx +0 -120
- package/src/components/ui/tabs.tsx +0 -55
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/components/ui/vertical-tabs.tsx +0 -59
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/index.ts +0 -7
- package/src/lib/already_logged_in_config.server.ts +0 -46
- package/src/lib/app_logger.ts +0 -24
- package/src/lib/auth/auth_cache.ts +0 -220
- package/src/lib/auth/auth_rate_limiter.ts +0 -121
- package/src/lib/auth/auth_types.ts +0 -65
- package/src/lib/auth/auth_utils.server.ts +0 -196
- package/src/lib/auth/hazo_get_auth.server.ts +0 -333
- package/src/lib/auth/index.ts +0 -23
- package/src/lib/auth/server_auth.ts +0 -88
- package/src/lib/auth_utility_config.server.ts +0 -136
- package/src/lib/config/config_loader.server.ts +0 -164
- package/src/lib/email_verification_config.server.ts +0 -32
- package/src/lib/file_types_config.server.ts +0 -25
- package/src/lib/forgot_password_config.server.ts +0 -32
- package/src/lib/hazo_connect_instance.server.ts +0 -101
- package/src/lib/hazo_connect_setup.server.ts +0 -194
- package/src/lib/hazo_connect_setup.ts +0 -54
- package/src/lib/index.ts +0 -44
- package/src/lib/login_config.server.ts +0 -71
- package/src/lib/messages_config.server.ts +0 -45
- package/src/lib/migrations/apply_migration.ts +0 -105
- package/src/lib/my_settings_config.server.ts +0 -135
- package/src/lib/password_requirements_config.server.ts +0 -39
- package/src/lib/profile_pic_menu_config.server.ts +0 -138
- package/src/lib/profile_picture_config.server.ts +0 -56
- package/src/lib/register_config.server.ts +0 -73
- package/src/lib/reset_password_config.server.ts +0 -75
- package/src/lib/services/email_service.ts +0 -581
- package/src/lib/services/email_verification_service.ts +0 -270
- package/src/lib/services/index.ts +0 -15
- package/src/lib/services/login_service.ts +0 -134
- package/src/lib/services/password_change_service.ts +0 -154
- package/src/lib/services/password_reset_service.ts +0 -405
- package/src/lib/services/profile_picture_remove_service.ts +0 -120
- package/src/lib/services/profile_picture_service.ts +0 -215
- package/src/lib/services/profile_picture_source_mapper.ts +0 -62
- package/src/lib/services/registration_service.ts +0 -184
- package/src/lib/services/token_service.ts +0 -240
- package/src/lib/services/user_profiles_service.ts +0 -143
- package/src/lib/services/user_update_service.ts +0 -141
- package/src/lib/ui_shell_config.server.ts +0 -73
- package/src/lib/ui_sizes_config.server.ts +0 -37
- package/src/lib/user_fields_config.server.ts +0 -31
- package/src/lib/user_management_config.server.ts +0 -39
- package/src/lib/utils/api_route_helpers.ts +0 -60
- package/src/lib/utils/error_sanitizer.ts +0 -75
- package/src/lib/utils.ts +0 -11
- package/src/middleware.ts +0 -94
- package/src/routes/index.ts +0 -34
- package/src/server/config/config_loader.ts +0 -496
- package/src/server/index.ts +0 -38
- package/src/server/logging/logger_service.ts +0 -56
- package/src/server/routes/root_router.ts +0 -16
- package/src/server/server.ts +0 -28
- package/src/server/types/app_types.ts +0 -74
- package/src/server/types/express.d.ts +0 -16
- package/src/stories/email_verification_layout.stories.tsx +0 -137
- package/src/stories/forgot_password_layout.stories.tsx +0 -85
- package/src/stories/login_layout.stories.tsx +0 -85
- package/src/stories/project_overview.stories.tsx +0 -33
- package/src/stories/register_layout.stories.tsx +0 -107
- package/tailwind.config.ts +0 -77
- package/tsconfig.build.json +0 -36
- package/tsconfig.json +0 -28
|
@@ -1,773 +0,0 @@
|
|
|
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 "./button"
|
|
11
|
-
import { Input } from "./input"
|
|
12
|
-
import { Separator } from "./separator"
|
|
13
|
-
import {
|
|
14
|
-
Sheet,
|
|
15
|
-
SheetContent,
|
|
16
|
-
SheetDescription,
|
|
17
|
-
SheetHeader,
|
|
18
|
-
SheetTitle,
|
|
19
|
-
} from "./sheet"
|
|
20
|
-
import { Skeleton } from "./skeleton"
|
|
21
|
-
import {
|
|
22
|
-
Tooltip,
|
|
23
|
-
TooltipContent,
|
|
24
|
-
TooltipProvider,
|
|
25
|
-
TooltipTrigger,
|
|
26
|
-
} from "./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
|
-
}
|