@@ -42,33 +42,55 @@ export interface PanelSideBarContextProps<TPanelItem, TMenuItem> {
4242 */
4343 userDropDownMenu ?: ReactNode ;
4444 /**
45- * The other menu content.
45+ * The menu content on the right .
4646 */
47- topBarCustomItems ?: ReactNode [ ] ;
47+ topBarRightCustomItems ?: ReactNode [ ] ;
48+ /**
49+ * The menu content on the left.
50+ */
51+ topBarLeftCustomItems ?: ReactNode [ ] ;
4852}
4953
5054export const PanelSideBarContext = createContext < PanelSideBarContextProps < any , any > | null > ( null ) ;
5155
5256export interface PanelSideBarMenuProviderProps < TPanelItem , TMenuItem >
53- extends Pick < PanelSideBarContextProps < TPanelItem , TMenuItem > , "globalItems" | "LinkRenderer" | "brand" | "footer" | "userDropDownMenu" | "userDropDownMenuToggle" | "topBarCustomItems" | "localItems" > {
57+ extends Pick <
58+ PanelSideBarContextProps < TPanelItem , TMenuItem > ,
59+ "globalItems" | "LinkRenderer" | "brand" | "footer" | "userDropDownMenu" | "userDropDownMenuToggle" | "topBarRightCustomItems" | "topBarLeftCustomItems" | "localItems"
60+ > {
5461 /**
5562 * The children elements.
5663 */
5764 children : React . ReactNode ;
5865}
5966
6067export const PanelSideBarProvider = < TPanelItem , TMenuItem > ( props : PanelSideBarMenuProviderProps < TPanelItem , TMenuItem > ) => {
61- const { children, globalItems, localItems = [ ] , LinkRenderer, brand = null , footer = null , userDropDownMenu, userDropDownMenuToggle, topBarCustomItems } = props ;
62-
63- const activePanel = globalItems . find ( x => x . children ?. find ( y => y . children ? y . children . find ( s => s . active ) : y . active ) ) ;
64- const firstActivePanel = activePanel ?? globalItems . find ( x => x . id ) ;
68+ const {
69+ children,
70+ globalItems,
71+ localItems = [ ] ,
72+ LinkRenderer,
73+ brand = null ,
74+ footer = null ,
75+ userDropDownMenu,
76+ userDropDownMenuToggle,
77+ topBarRightCustomItems,
78+ topBarLeftCustomItems,
79+ } = props ;
80+
81+ const activePanel = globalItems . find ( ( x ) => x . children ?. find ( ( y ) => ( y . children ? y . children . find ( ( s ) => s . active ) : y . active ) ) ) ;
82+ const firstActivePanel = activePanel ?? globalItems . find ( ( x ) => x . id ) ;
6583
6684 const getActivePanelId = ( ) => localItems ?. at ( 0 ) ?. id ?? firstActivePanel ?. id ?? "" ;
6785
6886 const [ activePanelId , setActivePanelId ] = useState ( getActivePanelId ( ) ) ;
6987
70- const [ toggledMenuItemIds , setToggledMenuItemIds ] = useState < string [ ] > ( [ ( firstActivePanel ?. children ?
71- firstActivePanel . children ?. find ( ( x ) => x . children ?. find ( s => s . active ) ) : firstActivePanel ?. children ?. find ( ( x ) => x . active ) ) ?. id ?? "" ] ) ;
88+ const [ toggledMenuItemIds , setToggledMenuItemIds ] = useState < string [ ] > ( [
89+ ( firstActivePanel ?. children
90+ ? firstActivePanel . children ?. find ( ( x ) => x . children ?. find ( ( s ) => s . active ) )
91+ : firstActivePanel ?. children ?. find ( ( x ) => x . active )
92+ ) ?. id ?? "" ,
93+ ] ) ;
7294
7395 const setActivePanel = ( panelId : string ) => setActivePanelId ( panelId ) ;
7496
@@ -97,7 +119,8 @@ export const PanelSideBarProvider = <TPanelItem, TMenuItem>(props: PanelSideBarM
97119 footer,
98120 userDropDownMenu,
99121 userDropDownMenuToggle,
100- topBarCustomItems,
122+ topBarRightCustomItems,
123+ topBarLeftCustomItems,
101124 brand,
102125 } }
103126 >
0 commit comments