@orsetra/shared-ui 1.1.2 → 1.1.3

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.
@@ -19,17 +19,22 @@ 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
24
  }
23
25
 
24
- function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'expanded', userMenuConfig, main_base_url, fetchMenus }: LayoutContainerProps) {
26
+ function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'expanded', userMenuConfig, main_base_url, fetchMenus, getSidebarMode, getCurrentMenu }: LayoutContainerProps) {
25
27
  const pathname = usePathname()
26
28
  const { setOpen } = useSidebar()
27
29
  const isMobile = useIsMobile()
28
30
  const [isMainSidebarOpen, setIsMainSidebarOpen] = useState(false)
29
31
  const [currentMenu, setCurrentMenu] = useState<string>("overview")
30
- const isMinimized = mode === 'minimized'
32
+
33
+ // Use custom mode function if provided, otherwise use prop
34
+ const effectiveMode = getSidebarMode ? getSidebarMode(pathname) : mode
35
+ const isMinimized = effectiveMode === 'minimized'
31
36
  // Force hidden mode on mobile
32
- const isHidden = mode === 'hidden' || isMobile
37
+ const isHidden = effectiveMode === 'hidden' || isMobile
33
38
 
34
39
  const [mainMenuItems, setMainMenuItems] = useState<MainMenuItem[]>([])
35
40
  const [fetchedSidebarMenus, setFetchedSidebarMenus] = useState<SidebarMenus>({})
@@ -78,9 +83,10 @@ function LayoutContent({ children, sidebarMenus = {}, user, onSignOut, mode = 'e
78
83
  }, [pathname, isMobile])
79
84
 
80
85
  useEffect(() => {
81
- const contextualMenu = getMenuFromPath(pathname)
86
+ // Use custom menu function if provided, otherwise use default getMenuFromPath
87
+ const contextualMenu = getCurrentMenu ? getCurrentMenu(pathname) : getMenuFromPath(pathname)
82
88
  setCurrentMenu(contextualMenu)
83
- }, [pathname])
89
+ }, [pathname, getCurrentMenu])
84
90
 
85
91
  const handleMainSidebarToggle = () => {
86
92
  setIsMainSidebarOpen(!isMainSidebarOpen)
@@ -222,7 +222,7 @@ function Sidebar({ currentMenu, onMainMenuToggle, sidebarMenus = {}, main_base_u
222
222
 
223
223
  {/* En-tête du menu principal sélectionné */}
224
224
  {currentMenu && sectionLabels[currentMenu] && (
225
- <div className="px-4 py-3 border-b border-ui-border">
225
+ <div className="h-14 flex items-center px-4 border-b border-ui-border">
226
226
  <h2 className="text-sm font-semibold text-text-primary">
227
227
  {sectionLabels[currentMenu]}
228
228
  </h2>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",