1 import type { ReactNode } from 'react';
2 import React, { useRef } from 'react';
4 import { c } from 'ttag';
6 import { Button } from '@proton/atoms';
7 import { FileIcon, Icon, TableRowBusy, Tooltip } from '@proton/components';
8 import clsx from '@proton/utils/clsx';
10 import type { DecryptedLink } from '../../store';
11 import FloatingEllipsis from './FloatingEllipsis';
20 onSelect: (link: DecryptedLink) => void;
21 toggleExpand: (linkId: string) => void;
25 const ExpandableRow = ({
36 const handleSelect = () => {
43 const paddingElement = { width: `${depth * 1.5}em` };
45 const floatingEllipsisVisibilityControlRef = useRef<HTMLDivElement>(null);
50 className={clsx(['folder-tree-list-item', !isDisabled && 'cursor-pointer', isSelected && 'bg-strong'])}
51 onClick={handleSelect}
53 <td className="flex items-center flex-nowrap m-0 pl-custom relative">
56 `folder-tree-list-item-selected flex shrink-0`,
57 !isSelected && 'folder-tree-list-item-selected-hidden',
60 <span className="flex justify-center items-center w-8 h-8 bg-primary rounded-full">
61 <Icon name="checkmark" className="p-1" size={4} />
64 <div className="flex shrink-0 folder-tree-list-item-indent" style={paddingElement}></div>
65 <div className="folder-tree-list-item-expand shrink-0 relative">
68 style={{ visibility: link.isFile ? 'hidden' : 'visible' }}
69 className="folder-tree-list-item-expand-button expand-click-area"
72 e.currentTarget.blur();
73 toggleExpand(link.linkId);
79 alt={isExpanded ? c('Action').t`Collapse` : c('Action').t`Expand`}
80 className={isExpanded ? 'rotateX-180' : undefined}
84 <div key="Name" className="folder-tree-list-item-name flex items-center flex-nowrap w-full">
85 <FileIcon mimeType={link.isFile ? link.mimeType : 'Folder'} className="mr-2" />
86 <Tooltip title={link.name} originalPlacement="bottom">
87 <span ref={floatingEllipsisVisibilityControlRef} className="text-nowrap pr-8">
92 <FloatingEllipsis visibilityControlRef={floatingEllipsisVisibilityControlRef} />
98 {!isLoaded && <TableRowBusy />}
105 export default ExpandableRow;