@orsetra/shared-ui 1.1.5 → 1.1.7
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { useState, useEffect } from "react"
|
|
4
|
-
import { usePathname, useSearchParams } from "next/navigation"
|
|
4
|
+
import { usePathname, useSearchParams, useParams } 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, type MainMenuItem, type MenuApiResponse, resolveIcon } from "./sidebar/data"
|
|
@@ -19,7 +19,7 @@ interface LayoutContainerProps {
|
|
|
19
19
|
mode?: SidebarMode
|
|
20
20
|
userMenuConfig?: UserMenuConfig
|
|
21
21
|
fetchMenus?: () => Promise<MenuApiResponse>
|
|
22
|
-
getSidebarMode?: (pathname: string, searchParams: URLSearchParams) => SidebarMode
|
|
22
|
+
getSidebarMode?: (pathname: string,params: Record<string, string>, searchParams: URLSearchParams) => SidebarMode
|
|
23
23
|
getCurrentMenu?: (pathname: string, searchParams: URLSearchParams) => string
|
|
24
24
|
getCurrentMenuItem?: (pathname: string, searchParams: URLSearchParams) => string
|
|
25
25
|
}
|
|
@@ -27,13 +27,14 @@ interface LayoutContainerProps {
|
|
|
27
27
|
function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'expanded', userMenuConfig, main_base_url, fetchMenus, getSidebarMode, getCurrentMenu, getCurrentMenuItem }: LayoutContainerProps) {
|
|
28
28
|
const pathname = usePathname()
|
|
29
29
|
const searchParams = useSearchParams()
|
|
30
|
+
const params = useParams()
|
|
30
31
|
const { setOpen } = useSidebar()
|
|
31
32
|
const isMobile = useIsMobile()
|
|
32
33
|
const [isMainSidebarOpen, setIsMainSidebarOpen] = useState(false)
|
|
33
34
|
const [currentMenu, setCurrentMenu] = useState<string>("overview")
|
|
34
35
|
|
|
35
36
|
// Use custom mode function if provided, otherwise use prop
|
|
36
|
-
const effectiveMode = getSidebarMode ? getSidebarMode(pathname, searchParams) : mode
|
|
37
|
+
const effectiveMode = getSidebarMode ? getSidebarMode(pathname, params as Record<string, string>, searchParams) : mode
|
|
37
38
|
const isMinimized = effectiveMode === 'minimized'
|
|
38
39
|
// Force hidden mode on mobile
|
|
39
40
|
const isHidden = effectiveMode === 'hidden' || isMobile
|