"use client"; import * as React from "react"; import { closestCenter, DndContext, type DragEndEvent, } from "@dnd-kit/core"; import { SortableContext, useSortable, verticalListSortingStrategy, } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; import { PaperclipIcon, XIcon } from "@phosphor-icons/react"; import { cn } from "../../../lib/utils"; import { Button } from "../../primitives"; import { FileDropPlusGlyph } from "./file-drop-presentation"; import type { FileDropPresentationEntry, FileDropPresentationItem, } from "./file-drop-types"; type SortableFileRowProps = { entry: FileDropPresentationEntry; isSortable: boolean; onItemActivate?: () => void; onItemRemove?: (item: FileDropPresentationItem, index: number) => void; }; function SortableFileRow({ entry, isSortable, onItemActivate, onItemRemove, }: SortableFileRowProps): React.JSX.Element { const { item, key: itemKey, sourceIndex } = entry; const { attributes, isDragging, listeners, setNodeRef, transform, transition } = useSortable({ disabled: !isSortable, id: itemKey, }); const style: React.CSSProperties = { transform: transform ? CSS.Transform.toString(transform) : undefined, transition, }; const fileName = item.fileName ?? item.alt ?? "Untitled file"; const content = ( <>