import { ComponentView } from '@/components/ComponentView'; import { PanelResizer } from '@/components/PanelResizer'; import { SmartTagsSection } from '@/components/Tags/SmartTagsSection'; import { TagsSection } from '@/components/Tags/TagsSection'; import { toDirective } from '@/components/utils'; import { PanelSide, ResizeFinishCallback, } from '@/directives/views/panelResizer'; import { WebApplication } from '@/ui_models/application'; import { PANEL_NAME_NAVIGATION } from '@/views/constants'; import { PrefKey } from '@standardnotes/snjs'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; import { useCallback, useMemo, useState } from 'preact/hooks'; import { PremiumModalProvider } from './Premium'; type Props = { application: WebApplication; }; const NAVIGATION_SELECTOR = 'navigation'; const useNavigationPanelRef = (): [HTMLDivElement | null, () => void] => { const [panelRef, setPanelRefInternal] = useState(null); const setPanelRefPublic = useCallback(() => { const elem = document.querySelector( NAVIGATION_SELECTOR ) as HTMLDivElement | null; setPanelRefInternal(elem); }, [setPanelRefInternal]); return [panelRef, setPanelRefPublic]; }; export const Navigation: FunctionComponent = observer( ({ application }) => { const appState = useMemo(() => application.getAppState(), [application]); const componentViewer = appState.foldersComponentViewer; const enableNativeSmartTagsFeature = appState.features.enableNativeSmartTagsFeature; const [panelRef, setPanelRef] = useNavigationPanelRef(); const onCreateNewTag = useCallback(() => { appState.tags.createNewTemplate(); }, [appState]); const panelResizeFinishCallback: ResizeFinishCallback = useCallback( (_lastWidth, _lastLeft, _isMaxWidth, isCollapsed) => { appState.noteTags.reloadTagsContainerMaxWidth(); appState.panelDidResize(PANEL_NAME_NAVIGATION, isCollapsed); }, [appState] ); const panelWidthEventCallback = useCallback(() => { appState.noteTags.reloadTagsContainerMaxWidth(); }, [appState]); return ( ); } ); export const NavigationDirective = toDirective(Navigation);