import type { JSX } from 'react'; import { ViewListIcon, ViewGridIcon, IconFileStack, RefreshIcon, MinusVerticalIcon, FoldersIcon, FoldersOffIcon, SortAscendingLettersIcon, SortDescendingLettersIcon, } from '../../ui/icons'; import SortFieldQuickMenu from './SortFieldQuickMenu'; type ViewMode = 'list' | 'grid' | 'desk' | (string & {}); type SortDirection = 'asc' | 'desc' | (string & {}); interface DocumentsTableHeaderActionOptions { viewMode?: ViewMode; onViewModeChange?: (mode: ViewMode) => void; onRefresh: () => void; sortField?: string; onSortFieldChange?: (field: string) => void; sortDirection?: SortDirection; onSortDirectionToggle?: () => void; isFilterActive?: boolean; includeDescendants?: boolean; onToggleIncludeDescendants?: () => void; } export const createDocumentsTableHeaderActions = ({ viewMode = 'list', onViewModeChange, onRefresh, sortField = 'title', onSortFieldChange, sortDirection = 'asc', onSortDirectionToggle, isFilterActive = false, includeDescendants = true, onToggleIncludeDescendants, }: DocumentsTableHeaderActionOptions): JSX.Element => { const isListView = viewMode === 'list'; const isGridView = viewMode === 'grid'; const isDeskView = viewMode === 'desk'; const sortDirectionIsDesc = sortDirection === 'desc'; const sortDirectionTitle = sortDirectionIsDesc ? 'Sorting Z → A. Click to switch to ascending.' : 'Sorting A → Z. Click to switch to descending.'; const includeDescendantsToggle = isFilterActive && onToggleIncludeDescendants ? ( ) : null; const sortControls = onSortFieldChange ? (
{onSortDirectionToggle ? ( ) : null}
) : null; return ( <> {includeDescendantsToggle ? ( <> {includeDescendantsToggle} ) : null} {sortControls ? ( <> {sortControls} ) : null}
); }; export default createDocumentsTableHeaderActions;