@orsetra/shared-ui 1.0.20 → 1.0.22
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.
|
@@ -5,7 +5,7 @@ import { usePathname } from "next/navigation"
|
|
|
5
5
|
import { MainSidebar, type SidebarMode } from "./sidebar/main-sidebar"
|
|
6
6
|
import { Sidebar, SidebarProvider, useSidebar } from "./sidebar/sidebar"
|
|
7
7
|
import { type SidebarMenus } from "./sidebar/data"
|
|
8
|
-
import { UserMenu, Button } from "../ui"
|
|
8
|
+
import { UserMenu, Button, type UserMenuConfig } from "../ui"
|
|
9
9
|
import { getMenuFromPath } from "../../lib/menu-utils"
|
|
10
10
|
import { useIsMobile } from "../../hooks/use-mobile"
|
|
11
11
|
import { Menu } from "lucide-react"
|
|
@@ -16,9 +16,10 @@ interface LayoutContainerProps {
|
|
|
16
16
|
user?: { profile?: { email?: string; preferred_username?: string } } | null
|
|
17
17
|
onSignOut?: () => void
|
|
18
18
|
mode?: SidebarMode
|
|
19
|
+
userMenuConfig?: UserMenuConfig
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
function LayoutContent({ children, sidebarMenus, user, onSignOut, mode = 'expanded' }: LayoutContainerProps) {
|
|
22
|
+
function LayoutContent({ children, sidebarMenus, user, onSignOut, mode = 'expanded', userMenuConfig }: LayoutContainerProps) {
|
|
22
23
|
const pathname = usePathname()
|
|
23
24
|
const { setOpen } = useSidebar()
|
|
24
25
|
const isMobile = useIsMobile()
|
|
@@ -96,7 +97,8 @@ function LayoutContent({ children, sidebarMenus, user, onSignOut, mode = 'expand
|
|
|
96
97
|
)}
|
|
97
98
|
<UserMenu
|
|
98
99
|
username={user?.profile?.email || user?.profile?.preferred_username}
|
|
99
|
-
onSignOut={onSignOut || (() => {})}
|
|
100
|
+
onSignOut={onSignOut || (() => {})}
|
|
101
|
+
menuConfig={userMenuConfig}
|
|
100
102
|
/>
|
|
101
103
|
</div>
|
|
102
104
|
</header>
|
package/components/ui/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Avatar, AvatarImage, AvatarFallback } from './avatar'
|
|
|
5
5
|
export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from './dropdown-menu'
|
|
6
6
|
export { Separator } from './separator'
|
|
7
7
|
export { Logo } from './logo'
|
|
8
|
-
export { UserMenu } from './user-menu'
|
|
8
|
+
export { UserMenu, type UserMenuItem, type UserMenuConfig } from './user-menu'
|
|
9
9
|
export { Input } from './input'
|
|
10
10
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './tooltip'
|
|
11
11
|
export { PageHeader } from './page-header'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { useRouter } from "next/navigation"
|
|
4
|
-
import { LogOut,
|
|
4
|
+
import { LogOut, ChevronDown, type LucideIcon } from "lucide-react"
|
|
5
5
|
import Avatar from "react-avatar"
|
|
6
6
|
import { Button } from "./button"
|
|
7
7
|
import {
|
|
@@ -12,15 +12,30 @@ import {
|
|
|
12
12
|
DropdownMenuSeparator,
|
|
13
13
|
DropdownMenuTrigger,
|
|
14
14
|
} from "./dropdown-menu"
|
|
15
|
+
|
|
16
|
+
// Type for configurable user menu items
|
|
17
|
+
export interface UserMenuItem {
|
|
18
|
+
id: string
|
|
19
|
+
label: string
|
|
20
|
+
href: string
|
|
21
|
+
icon: LucideIcon
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface UserMenuConfig {
|
|
25
|
+
items: UserMenuItem[]
|
|
26
|
+
}
|
|
27
|
+
|
|
15
28
|
interface UserMenuProps {
|
|
16
29
|
username?: string
|
|
17
30
|
onSignOut: () => void
|
|
31
|
+
menuConfig?: UserMenuConfig
|
|
18
32
|
}
|
|
19
33
|
|
|
20
|
-
export function UserMenu({ username, onSignOut }: UserMenuProps) {
|
|
34
|
+
export function UserMenu({ username, onSignOut, menuConfig }: UserMenuProps) {
|
|
21
35
|
const router = useRouter()
|
|
22
36
|
|
|
23
37
|
const displayName = username || "User"
|
|
38
|
+
const menuItems = menuConfig?.items || []
|
|
24
39
|
|
|
25
40
|
return (
|
|
26
41
|
<DropdownMenu>
|
|
@@ -50,28 +65,24 @@ export function UserMenu({ username, onSignOut }: UserMenuProps) {
|
|
|
50
65
|
<p className="text-sm font-medium leading-none">{displayName}</p>
|
|
51
66
|
</div>
|
|
52
67
|
</DropdownMenuLabel>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
>
|
|
72
|
-
<Settings className="mr-2 h-4 w-4" />
|
|
73
|
-
<span>Settings</span>
|
|
74
|
-
</DropdownMenuItem>
|
|
68
|
+
{menuItems.length > 0 && (
|
|
69
|
+
<>
|
|
70
|
+
<DropdownMenuSeparator />
|
|
71
|
+
{menuItems.map((item) => {
|
|
72
|
+
const Icon = item.icon
|
|
73
|
+
return (
|
|
74
|
+
<DropdownMenuItem
|
|
75
|
+
key={item.id}
|
|
76
|
+
className="cursor-pointer"
|
|
77
|
+
onClick={() => router.push(item.href)}
|
|
78
|
+
>
|
|
79
|
+
<Icon className="mr-2 h-4 w-4" />
|
|
80
|
+
<span>{item.label}</span>
|
|
81
|
+
</DropdownMenuItem>
|
|
82
|
+
)
|
|
83
|
+
})}
|
|
84
|
+
</>
|
|
85
|
+
)}
|
|
75
86
|
<DropdownMenuSeparator />
|
|
76
87
|
<DropdownMenuItem
|
|
77
88
|
className="cursor-pointer text-red-600 focus:text-red-600 focus:bg-red-50"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orsetra/shared-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Shared UI components for Orsetra platform",
|
|
5
5
|
"main": "./index.ts",
|
|
6
6
|
"types": "./index.ts",
|
|
@@ -92,4 +92,4 @@
|
|
|
92
92
|
"next": "^16.0.7",
|
|
93
93
|
"typescript": "^5"
|
|
94
94
|
}
|
|
95
|
-
}
|
|
95
|
+
}
|