import React from 'react'; import { useTranslation } from 'react-i18next'; import { ChevronRight, Folder, FolderOpen, Music } from 'lucide-react'; import type { SubsonicDirectoryEntry } from '@/lib/api/subsonicTypes'; import type { Track } from '@/lib/media/trackTypes'; import { folderBrowserHasKeyModifiers, isFolderBrowserArrowKey, type Column, } from '../../utils/componentHelpers/folderBrowserHelpers'; interface Props { col: Column; colIndex: number; isCompact: boolean; filterValue: string; filterVisible: boolean; filteredItems: SubsonicDirectoryEntry[]; keyboardRowIndex: number | null; contextRowIndex: number | null; currentTrack: Track | null; isPlaying: boolean; isSelectedPathForCurrentTrack: boolean; playingPathIds: string[]; registerFilterInput: (el: HTMLInputElement | null) => void; onFilterFocus: () => void; onFilterBlur: () => void; onFilterEscape: () => void; onFilterArrowDown: () => void; onFilterChange: (value: string) => void; onRowClick: (item: SubsonicDirectoryEntry, rowIndex: number) => void; onRowContextMenu: ( e: React.MouseEvent, rowIndex: number, col: Column, item: SubsonicDirectoryEntry, ) => void; } export default function FolderBrowserColumn({ col, colIndex, isCompact, filterValue, filterVisible, filteredItems, keyboardRowIndex, contextRowIndex, currentTrack, isPlaying, isSelectedPathForCurrentTrack, playingPathIds, registerFilterInput, onFilterFocus, onFilterBlur, onFilterEscape, onFilterArrowDown, onFilterChange, onRowClick, onRowContextMenu, }: Props) { const { t } = useTranslation(); return (
{filterVisible && (
{ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); onFilterEscape(); return; } if (e.key === 'ArrowDown' && !folderBrowserHasKeyModifiers(e)) { e.preventDefault(); e.stopPropagation(); onFilterArrowDown(); } }} onChange={e => onFilterChange(e.target.value)} />
)} {col.loading ? (
) : col.error ? (
{t('folderBrowser.error')}
) : filteredItems.length === 0 ? (
{t('folderBrowser.empty')}
) : ( filteredItems.map((item, rowIndex) => { const isSelected = col.selectedId === item.id; const isContextRow = contextRowIndex === rowIndex; const isKeyboardRow = keyboardRowIndex === rowIndex; const isNowPlayingTrack = !item.isDir && currentTrack?.id === item.id; const isPathPlayingIcon = !!(isSelectedPathForCurrentTrack && playingPathIds.includes(item.id)); return ( ); }) )}
); }