import { ColumnLayout, ContentObjectItem } from "@vertesia/common"; import { Table, TBody, THead } from "@vertesia/ui/core"; import { useUITranslation } from '../../../../i18n/index.js'; import { CheckIcon } from "lucide-react"; import { ChangeEvent } from "react"; import { DocumentIcon, DocumentIconSkeleton } from "../components/DocumentIcon"; import { DocumentSelection } from "../DocumentSelectionProvider"; import { DocumentTableColumn } from "./DocumentTableColumn"; interface ViewProps { objects: ContentObjectItem[]; isLoading: boolean; layout?: ColumnLayout[]; onRowClick?: (object: ContentObjectItem) => void; highlightRow?: (item: ContentObjectItem) => boolean; previewObject?: (objectId: string) => void; selectedObject?: ContentObjectItem | null; onSelectionChange: ((object: ContentObjectItem, ev: ChangeEvent) => void); selection: DocumentSelection; toggleAll?: (ev: ChangeEvent) => void; columns: DocumentTableColumn[]; } export function DocumentTableView({ objects, selection, isLoading, columns, onRowClick, highlightRow, selectedObject, toggleAll, onSelectionChange }: ViewProps) { const { t } = useUITranslation(); return ( {selection && } {columns.map((col) => ( ))} { objects?.map((obj: ContentObjectItem) => { const isHighlighted = highlightRow?.(obj); return ( { onRowClick && onRowClick(obj) }}> {selection && } {columns.map((col, index) => col.render(obj, index))} ) }) } {objects.length === 0 && }
{col.name}
ev.stopPropagation()}> ) => onSelectionChange(obj, ev)} /> {isHighlighted && ( )}
{t('store.noObjectsDragAndDrop')}
) } export function DocumentGridView({ objects, selection, isLoading, onSelectionChange, onRowClick, highlightRow, previewObject, selectedObject }: ViewProps) { return ( <>
{ objects.map((document) => ( )) }
) }