'use client'; import * as React from 'react'; import { cn } from '@djangocfg/ui-core/lib'; import { ScrollArea } from '@djangocfg/ui-core/components'; import type { KanbanColumn as KanbanColumnType } from '../types'; import { useKanbanContext } from '../context/KanbanContext'; import { KanbanCard } from './KanbanCard'; interface KanbanColumnProps { column: KanbanColumnType; } export function KanbanColumn({ column }: KanbanColumnProps) { const { renderColumnHeader, emptyColumnMessage, dragState, setDragState, moveCard, reorderCard } = useKanbanContext(); const handlePointerEnter = React.useCallback(() => { if (dragState.activeCardId && dragState.activeColumnId !== column.id) { setDragState((prev) => ({ ...prev, overColumnId: column.id })); } }, [dragState.activeCardId, dragState.activeColumnId, column.id, setDragState]); const handlePointerUp = React.useCallback(() => { if ( dragState.activeCardId && dragState.activeColumnId && dragState.overColumnId === column.id && dragState.activeColumnId !== column.id ) { const toIndex = column.cards.length; moveCard(dragState.activeCardId, dragState.activeColumnId, column.id, toIndex); } setDragState({ activeCardId: null, activeColumnId: null, overColumnId: null, overCardId: null, }); }, [dragState, column.id, column.cards.length, moveCard, setDragState]); const isOver = dragState.overColumnId === column.id && dragState.activeColumnId !== column.id; return (
{renderColumnHeader ? ( renderColumnHeader(column) ) : (

{column.title}

)} {column.cards.length} cards
{column.cards.length === 0 ? (
{emptyColumnMessage}
) : ( column.cards.map((card, index) => ( )) )}
); } KanbanColumn.displayName = 'KanbanColumn';