import React from 'react'; import type { PageRef } from '../../pdf/pdfTypes'; import DropIndicator from './DropIndicator'; import PageCard from './PageCard'; interface PageGridProps { pages: PageRef[]; thumbnails: Record; selectedPageIds: string[]; isBusy: boolean; draggingIndex: number | null; dropIndex: number | null; draggingSelectionActive: boolean; isCopyDragging: boolean; dropIndicatorColor: string; onDragStart: (visualIndex: number) => React.DragEventHandler; onDragEnd: React.DragEventHandler; onCardDragOver: ( visualIndex: number ) => React.DragEventHandler; onEndSlotDragOver: React.DragEventHandler; onDrop: React.DragEventHandler; onOpenPreview: (pageId: string) => void; onToggleSelect: ( pageId: string, visualIndex: number ) => React.MouseEventHandler; onRotateClockwise: (pageId: string) => void; onRotateCounterclockwise: (pageId: string) => void; onDelete: (pageId: string) => void; } const PageGrid: React.FC = ({ pages, thumbnails, selectedPageIds, isBusy, draggingIndex, dropIndex, draggingSelectionActive, isCopyDragging, dropIndicatorColor, onDragStart, onDragEnd, onCardDragOver, onEndSlotDragOver, onDrop, onOpenPreview, onToggleSelect, onRotateClockwise, onRotateCounterclockwise, onDelete, }) => { const isSelected = (pageId: string) => selectedPageIds.includes(pageId); const showLeftLine = (visualIndex: number) => dropIndex !== null && dropIndex === visualIndex && draggingIndex !== null; const showRightLine = (visualIndex: number) => dropIndex !== null && dropIndex === visualIndex + 1 && draggingIndex !== null; const showEndLine = () => dropIndex !== null && dropIndex === pages.length && draggingIndex !== null; return (
{pages.map((page, visualIndex) => { const selected = isSelected(page.id); const isDraggingCard = draggingIndex != null && ((draggingSelectionActive && selected) || (!draggingSelectionActive && visualIndex === draggingIndex)); return ( onOpenPreview(page.id)} onToggleSelect={onToggleSelect(page.id, visualIndex)} onRotateClockwise={() => onRotateClockwise(page.id)} onRotateCounterclockwise={() => onRotateCounterclockwise(page.id)} onDelete={() => onDelete(page.id)} /> ); })} {pages.length > 0 && (
{showEndLine() && ( )}
)}
); }; export default PageGrid;