import React from 'react'; import { Card } from '../Card'; import { Button } from '../Button'; import { Badge } from '../Badge'; import { Icon } from '../Icon'; export interface SortableItem { id: string; title: string; subtitle?: string; badge?: string; } export interface SortableListProps extends React.HTMLAttributes { items: SortableItem[]; onReorder?: (items: SortableItem[]) => void; onItemClick?: (item: SortableItem) => void; } export function SortableList({ items, onReorder, onItemClick, className = '', ...props }: SortableListProps) { const handleMoveUp = (index: number) => { if (index <= 0 || !onReorder) return; const updated = [...items]; [updated[index - 1], updated[index]] = [updated[index], updated[index - 1]]; onReorder(updated); }; const handleMoveDown = (index: number) => { if (index >= items.length - 1 || !onReorder) return; const updated = [...items]; [updated[index], updated[index + 1]] = [updated[index + 1], updated[index]]; onReorder(updated); }; return (
{items.map((item, index) => ( {/* Drag Handle */} {/* Content */}
onItemClick?.(item)} role="button" tabIndex={0} >
{item.title}
{item.subtitle && (
{item.subtitle}
)}
{item.badge && {item.badge}} {/* Reorder Controls */}
))}
); }