import { useObjectRef } from '@cloudbeaver/core-blocks' ; import { useService } from '@cloudbeaver/core-di' ; import type { NavNode } from '../shared/NodesManager/EntityTypes' ; import { NavigationTreeService } from './NavigationTreeService' ; interface INavigationTree { navigationTreeService : NavigationTreeService ; handleOpen : ( node : NavNode ) => Promise < void > ; handleSelect : ( node : NavNode , state : boolean ) => void ; } const bindActions = [ 'handleOpen' , 'handleSelect' ] ; export function useNavigationTree ( ) { const navigationTreeService = useService ( NavigationTreeService ) ; return useObjectRef < INavigationTree > ( ( ) => ( { navigationTreeService , handleOpen ( node ) { return this . navigationTreeService . navToNode ( node . id , node . parentId ) ; } , handleSelect ( node , state ) { return this . navigationTreeService . selectNode ( node . id , state ) ; } , } ) , { navigationTreeService } , bindActions ) ; }