"use client" import { useState } from "react" import { FileThumbnail } from "@/components/drive/file-thumbnail" import { DriveFileContextMenu } from "@/components/drive/drive-file-context-menu" import { DriveFileMenuButton } from "@/components/drive/drive-file-actions-menu" import type { DriveFileInfo } from "@/lib/api/types" import { displayFileName } from "@/lib/drive/display-file-name" import type { useDriveMutations } from "@/lib/api/hooks/use-drive-queries" import type { PublicShareThumbContext } from "@/lib/api/hooks/use-public-share-preview-thumb" import { DriveFileTypeIcon } from "@/lib/drive/drive-file-icon" import { cn } from "@/lib/utils" const GRID_TITLE_CLASS = "min-w-0 flex-1 truncate text-left text-xs font-normal text-[#3c4043] dark:text-[#e8eaed]" export function DriveGridCard({ file, allItems, inSharedView, isSelected, isTrash, allowShare = true, writable = true, hideFavorite = false, disableDnd = false, mutations, onDownloadItem, publicShare, onOpen, onItemClick, registerRef, }: { file: DriveFileInfo allItems: DriveFileInfo[] inSharedView?: boolean isSelected: boolean isTrash?: boolean allowShare?: boolean writable?: boolean hideFavorite?: boolean disableDnd?: boolean mutations?: ReturnType onDownloadItem?: (file: DriveFileInfo) => void publicShare?: PublicShareThumbContext onOpen: () => void onItemClick: (file: DriveFileInfo, e: React.MouseEvent) => void registerRef?: (path: string, el: HTMLDivElement | null) => void }) { const [menuActive, setMenuActive] = useState(false) const [contextMenuActive, setContextMenuActive] = useState(false) const label = displayFileName(file.name) const highlighted = isSelected || menuActive || contextMenuActive return ( onDownloadItem(file) : undefined} onOpen={onOpen} variant="grid" registerRef={registerRef ? (el) => registerRef(file.path, el) : undefined} onItemClick={onItemClick} onContextMenuActiveChange={setContextMenuActive} className={cn( "flex cursor-pointer flex-col overflow-hidden rounded-xl transition-colors", highlighted ? "bg-mail-active" : "bg-mail-surface-muted hover:bg-mail-nav-hover" )} >
{label} onDownloadItem(file) : undefined} onOpen={onOpen} onActiveChange={setMenuActive} />
) }