1 import { useState } from 'react';
3 import { c } from 'ttag';
5 import type { HotkeyTuple } from '@proton/components';
6 import { FolderIcon, Icon } from '@proton/components';
7 import { formatFolderName } from '@proton/shared/lib/helpers/folder';
8 import type { Folder, FolderWithSubFolders } from '@proton/shared/lib/interfaces/Folder';
9 import clsx from '@proton/utils/clsx';
11 import type { ApplyLabelsParams } from '../../hooks/actions/label/useApplyLabels';
12 import type { MoveParams } from '../../hooks/actions/move/useMoveToFolder';
13 import SidebarItem from './SidebarItem';
14 import SidebarLabelActions from './SidebarLabelActions';
17 currentLabelID: string;
19 folder: FolderWithSubFolders;
21 onToggle: (folder: FolderWithSubFolders, expanded: boolean) => void;
24 onFocus: (id: string) => void;
27 moveToFolder: (params: MoveParams) => void;
28 applyLabels: (params: ApplyLabelsParams) => void;
31 const SidebarFolder = ({
45 const [isOptionDropdownOpened, setIsOptionDropdownOpened] = useState(false);
47 const shortcutHandlers: HotkeyTuple[] = [
53 onToggle(folder, true);
61 onToggle(folder, false);
67 const noChevron = treeMode ? <span className="navigation-icon-empty shrink-0" /> : null;
71 currentLabelID={currentLabelID}
75 unreadCount={unreadCount}
76 shortcutHandlers={shortcutHandlers}
77 moveToFolder={moveToFolder}
78 applyLabels={applyLabels}
81 isOptionDropdownOpened={isOptionDropdownOpened}
83 <div className="flex flex-nowrap items-center gap-2" data-level={level}>
84 {folder.subfolders?.length ? (
87 className="shrink-0 navigation-link--expand relative interactive-pseudo-inset interactive--no-background"
88 aria-expanded={!!folder.Expanded}
92 onToggle(folder, !expanded);
96 name="chevron-down-filled"
98 'navigation-icon navigation-icon--expand',
99 !folder.Expanded && 'rotateZ-270',
106 <FolderIcon className="navigation-icon shrink-0" alt={c('Info').t`Folder`} folder={folder} />
107 <div className="text-ellipsis">{formatFolderName(level, folder.Name)}</div>
116 onToggleDropdown={setIsOptionDropdownOpened}
123 export default SidebarFolder;