import React from "react"; import { GripVertical, MoreVertical } from "lucide-react"; import { cn } from "@/lib/utils"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./dropdown-menu"; /** * A selectable scenario card used in the Borrowing Capacity left sidebar. * * Displays a scenario name and description. Supports selected state (right * border accent), an optional drag handle for reordering, and an optional * kebab menu with "Update Scenario" and "Delete Scenario" options. */ export interface ScenarioItemProps { /** Scenario display name (e.g. "Default Scenario") */ name: string; /** Secondary descriptor (e.g. "Owner Occupier") */ description?: string; /** Highlights the item with a left border accent */ isSelected?: boolean; /** Shows the drag grip handle and marks the root as draggable */ isDraggable?: boolean; /** Visual drag-over highlight (consumer-controlled) */ isDragOver?: boolean; /** Click handler — typically selects this scenario */ onSelect?: () => void; /** Called when "Update Scenario" is clicked in the kebab menu */ onEdit?: () => void; /** Called when "Delete Scenario" is clicked in the kebab menu */ onDelete?: () => void; /** HTML5 drag events forwarded from parent (ScenarioList) */ onDragStart?: (e: React.DragEvent) => void; onDragOver?: (e: React.DragEvent) => void; onDragLeave?: (e: React.DragEvent) => void; onDrop?: (e: React.DragEvent) => void; onDragEnd?: (e: React.DragEvent) => void; className?: string; } export function ScenarioItem({ name, description, isSelected = false, isDraggable = false, isDragOver = false, onSelect, onEdit, onDelete, onDragStart, onDragOver, onDragLeave, onDrop, onDragEnd, className, }: ScenarioItemProps) { return (
{ if (e.key === "Enter" || e.key === " ") onSelect?.(); }} onDragStart={onDragStart} onDragOver={onDragOver} onDragLeave={onDragLeave} onDrop={onDrop} onDragEnd={onDragEnd} className={cn( "flex cursor-pointer items-center gap-2 border border-border bg-background px-3 py-3 transition-colors hover:bg-muted/50", isSelected && "border-r-2 border-r-primary bg-primary/5", isDragOver && "bg-primary/10", className, )} > {isDraggable && ( )}

{name}

{description && (

{description}

)}
{(onEdit || onDelete) && ( e.stopPropagation()} className="shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground" > } /> {onEdit && ( { e.stopPropagation(); onEdit(); }} > Update Scenario )} {onDelete && ( { e.stopPropagation(); onDelete(); }} className="text-destructive focus:text-destructive" > Delete Scenario )} )}
); }