import { ChevronRight, ChevronDown, Folder, File, Link, Loader2 } from 'lucide-react'; import type { FileEntry } from '@/lib/stackFilesApi'; import { cn } from '@/lib/utils'; import { FileTreeContextMenu } from './FileTreeContextMenu'; interface FileTreeNodeProps { entry: FileEntry; relPath: string; depth: number; isSelected: boolean; isExpanded?: boolean; isLoading?: boolean; onClick: () => void; // Context menu wiring canEdit: boolean; isPaid: boolean; onContextMenuRename: (relPath: string) => void; onContextMenuNewFile: (dirRelPath: string) => void; onContextMenuNewFolder: (dirRelPath: string) => void; onContextMenuDelete: (relPath: string, entry: FileEntry) => void; onContextMenuPermissions: (relPath: string, entry: FileEntry) => void; } export function FileTreeNode({ entry, relPath, depth, isSelected, isExpanded, isLoading, onClick, canEdit, isPaid, onContextMenuRename, onContextMenuNewFile, onContextMenuNewFolder, onContextMenuDelete, onContextMenuPermissions, }: FileTreeNodeProps) { const isDir = entry.type === 'directory'; return (
{ if (e.key === 'Enter' || e.key === ' ') onClick(); }} aria-expanded={isDir ? isExpanded : undefined} className={cn( 'flex items-center gap-1.5 py-0.5 cursor-pointer select-none rounded-sm', isSelected ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/50 text-foreground' )} style={{ paddingLeft: depth * 16 + 8 }} > {isDir && ( isLoading ? : isExpanded ? : )} {isDir ? : entry.type === 'symlink' ? : } {entry.name} {entry.isProtected && ( )}
); }