@orsetra/shared-ui 1.1.3 → 1.1.4

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 } from "next/navigation"
4
+ import { usePathname, useSearchParams } 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,19 +19,20 @@ interface LayoutContainerProps {
19
19
  mode?: SidebarMode
20
20
  userMenuConfig?: UserMenuConfig
21
21
  fetchMenus?: () => Promise<MenuApiResponse>
22
- getSidebarMode?: (pathname: string) => SidebarMode
23
- getCurrentMenu?: (pathname: string) => string
22
+ getSidebarMode?: (pathname: string, searchParams: URLSearchParams) => SidebarMode
23
+ getCurrentMenu?: (pathname: string, searchParams: URLSearchParams) => string
24
24
  }
25
25
 
26
26
  function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'expanded', userMenuConfig, main_base_url, fetchMenus, getSidebarMode, getCurrentMenu }: LayoutContainerProps) {
27
27
  const pathname = usePathname()
28
+ const searchParams = useSearchParams()
28
29
  const { setOpen } = useSidebar()
29
30
  const isMobile = useIsMobile()
30
31
  const [isMainSidebarOpen, setIsMainSidebarOpen] = useState(false)
31
32
  const [currentMenu, setCurrentMenu] = useState<string>("overview")
32
33
 
33
34
  // Use custom mode function if provided, otherwise use prop
34
- const effectiveMode = getSidebarMode ? getSidebarMode(pathname) : mode
35
+ const effectiveMode = getSidebarMode ? getSidebarMode(pathname, searchParams) : mode
35
36
  const isMinimized = effectiveMode === 'minimized'
36
37
  // Force hidden mode on mobile
37
38
  const isHidden = effectiveMode === 'hidden' || isMobile
@@ -84,9 +85,9 @@ function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'e
84
85
 
85
86
  useEffect(() => {
86
87
  // Use custom menu function if provided, otherwise use default getMenuFromPath
87
- const contextualMenu = getCurrentMenu ? getCurrentMenu(pathname) : getMenuFromPath(pathname)
88
+ const contextualMenu = getCurrentMenu ? getCurrentMenu(pathname, searchParams) : getMenuFromPath(pathname)
88
89
  setCurrentMenu(contextualMenu)
89
- }, [pathname, getCurrentMenu])
90
+ }, [pathname, searchParams, getCurrentMenu])
90
91
 
91
92
  const handleMainSidebarToggle = () => {
92
93
  setIsMainSidebarOpen(!isMainSidebarOpen)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",