"use client"; import * as React from "react"; import { useDroppable } from "@dnd-kit/core"; import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable"; import { Plus } from "lucide-react"; import { ScrollArea } from "@/components/ui/scroll-area"; import type { ViewObject } from "@/lib/hooks/use-view-data"; import { cn } from "@/lib/utils"; import { BoardCard } from "./board-card"; export interface BoardColumnInlineCreate { isCreating: boolean; newTitle: string; onNewTitleChange: (value: string) => void; onOpen: () => void; onSubmit: () => void; onCancel: () => void; isPending: boolean; } export interface BoardColumnProps { columnId: string; label: string; items: ViewObject[]; dotClass: string; borderTopClass: string; inlineCreate: BoardColumnInlineCreate; } function formatColumnLabel(id: string): string { return id.replace(/_/g, " "); } export function BoardColumn({ columnId, label, items, dotClass, borderTopClass, inlineCreate, }: BoardColumnProps) { const { setNodeRef, isOver } = useDroppable({ id: columnId, data: { type: "column", columnId }, }); const ids = items.map((i) => i.id); const displayLabel = label || formatColumnLabel(columnId); const showEmptyDropLine = items.length === 0 && isOver; return (

{displayLabel}

{items.length}
{showEmptyDropLine && (
)}
    {items.map((object) => (
  • ))}
{inlineCreate.isCreating ? (
inlineCreate.onNewTitleChange(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter" && inlineCreate.newTitle.trim()) { e.preventDefault(); inlineCreate.onSubmit(); } if (e.key === "Escape") { inlineCreate.onCancel(); } }} onBlur={() => { if (inlineCreate.isPending) return; if (inlineCreate.newTitle.trim()) { inlineCreate.onSubmit(); } else { inlineCreate.onCancel(); } }} />
) : ( )}
); }