import { Link } from "react-router-dom"; import { cn } from "@/lib/utils"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; /** Stat-tile contract (dataviz skill): label · value · optional delta · * optional context/detail rows. Values are pre-formatted by the caller * (formatAmount etc.) and blur under privacy mode via data-sensitive. */ export interface StatTileProps { label: string; /** Small line under the label, e.g. "Ciclo al 18 jul". */ description?: string; /** Pre-formatted headline value. null renders an em dash. */ value: string | null; loading?: boolean; /** Signed, pre-formatted delta plus whether it's good news (colors it). */ delta?: { text: string; positive: boolean }; /** Muted line(s) or detail rows under the value. */ children?: React.ReactNode; /** Makes the whole tile a link (adds hover border + focus ring). */ to?: string; ariaLabel?: string; /** Set false for non-monetary values that shouldn't blur (counts, dates). */ sensitive?: boolean; className?: string; } export function StatTile({ label, description, value, loading = false, delta, children, to, ariaLabel, sensitive = true, className, }: StatTileProps) { const card = ( {label} {description && (

{description}

)}
{loading ? ( ) : ( {value ?? "—"} )} {!loading && delta && ( {delta.text} )}
{children}
); if (!to) return card; return ( {card} ); }