import * as React from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { StatusDot, type StatusDotTone } from "./status-dot" import { cn } from "@/lib/utils" export type StatusLegendTone = "default" | "success" | "warning" | "danger" | "info" | "muted" export type StatusLegendOrientation = "vertical" | "horizontal" | "grid" export type StatusLegendItem = { key: string label: React.ReactNode description?: React.ReactNode count?: React.ReactNode tone?: StatusLegendTone icon?: React.ReactNode hidden?: boolean className?: string } export type StatusLegendProps = Omit, "orientation"> & { title?: React.ReactNode description?: React.ReactNode actions?: React.ReactNode items: StatusLegendItem[] orientation?: StatusLegendOrientation compact?: boolean showCounts?: boolean contentClassName?: string itemClassName?: string } const statusDotTone: Record = { default: "neutral", success: "success", warning: "warning", danger: "danger", info: "info", muted: "muted", } function StatusLegend({ title, description, actions, items, orientation = "vertical", compact = false, showCounts = true, contentClassName, itemClassName, className, ...props }: StatusLegendProps) { const visibleItems = items.filter((item) => !item.hidden) const hasHeader = Boolean(title || description || actions) const layoutClassName: Record = { vertical: "grid", horizontal: "flex flex-wrap", grid: "grid sm:grid-cols-2", } return ( {hasHeader && (
{title && {title}} {description && {description}}
{actions &&
{actions}
}
)} {visibleItems.map((item) => (
{item.icon ? ( {item.icon} ) : ( )}
{item.label}
{item.description &&
{item.description}
}
{showCounts && item.count !== undefined && ( {item.count} )}
))}
) } export { StatusLegend }