import * as React from 'react'; import { useCallback } from 'react'; import { _ } from '@joplin/lib/locale'; import CommandService from '@joplin/lib/services/CommandService'; import SyncButton from '../SyncButton'; interface Props { selectedIndex: number; onKeyDown: React.KeyboardEventHandler; allFoldersCollapsed: boolean; hasSubFolders: boolean; } const onAddFolderButtonClick = () => { void CommandService.instance().execute('newFolder'); }; const onToggleAllFolders = (allFoldersCollapsed: boolean) => { void CommandService.instance().execute('toggleAllFolders', !allFoldersCollapsed); }; interface CollapseExpandAllButtonProps { allFoldersCollapsed: boolean; hasSubFolders: boolean; } const CollapseExpandAllButton = (props: CollapseExpandAllButtonProps) => { // To allow it to be accessed by accessibility tools, the toggle button // is not included in the portion of the list with role='tree'. const icon = props.allFoldersCollapsed ? 'far fa-caret-square-right' : 'far fa-caret-square-down'; const label = props.allFoldersCollapsed ? _('Expand all notebooks') : _('Collapse all notebooks'); return ; }; const ToggleNoteListButton = () => { // Visible one-click switch for the note list pane (mirrors View > Toggle note list), // so hiding/showing the middle pane doesn't require a menu or shortcut. const label = _('Toggle note list'); return ; }; const NewFolderButton = () => { // To allow it to be accessed by accessibility tools, the new folder button // is not included in the portion of the list with role='tree'. const label = _('New notebook'); return ; }; const useOnRenderListWrapper = (props: Props) => { return useCallback((listItems: React.ReactNode[]) => { const listHasValidSelection = props.selectedIndex >= 0; const allowContainerFocus = !listHasValidSelection; return <>
{...listItems}
; }, [props.selectedIndex, props.onKeyDown, props.allFoldersCollapsed, props.hasSubFolders]); }; export default useOnRenderListWrapper;