import { ReactElement } from 'react' import DownIcon from 'remixicon-react/ArrowDownSLineIcon' import { useBulkActions } from '../../../hooks/useBulkActions' import { SortDir, SortKey } from '../../../hooks/useSorting' import { capitalizeFirstLetter } from '../../../../../../src/modules/filemanager/utils/common' interface FileBrowserHeaderProps { isSearchMode: boolean bulk: ReturnType sortKey: SortKey sortDir: SortDir onSortName: () => void onSortSize: () => void onSortDate: () => void onSortDrive: () => void onClearSort: () => void } enum AriaSortValue { Ascending = 'ascending', Descending = 'descending', None = 'none', } const Arrow = ({ active, dir }: { active: boolean; dir: SortDir }) => { let title: string | undefined if (active) { const sortValue = dir === SortDir.Asc ? AriaSortValue.Ascending : AriaSortValue.Descending title = capitalizeFirstLetter(sortValue) } else { title = undefined } return (
) } function HeaderCell({ label, isActive, dir, onToggle, onClear, ariaSort, 'data-testid': testId, }: { label: string isActive: boolean dir: SortDir onToggle: () => void onClear: () => void ariaSort: AriaSortValue 'data-testid'?: string }) { return (
{isActive && ( )}
) } export function FileBrowserHeader({ isSearchMode, bulk, sortKey, sortDir, onSortName, onSortSize, onSortDate, onSortDrive, onClearSort, }: FileBrowserHeaderProps): ReactElement { const ariaSort = (thisKey: SortKey): AriaSortValue => { if (sortKey !== thisKey) return AriaSortValue.None return sortDir === SortDir.Asc ? AriaSortValue.Ascending : AriaSortValue.Descending } return (
{ if (el) el.indeterminate = bulk.someChecked }} onChange={e => (e.target.checked ? bulk.selectAll() : bulk.clearAll())} />
{isSearchMode && (
)}
) }