"use client"; import * as React from "react"; import { cn } from "@/lib/utils"; export type TrendDirection = "up" | "down" | "neutral"; export interface SparklinePoint { value: number; } export interface MetricCardProps extends React.HTMLAttributes { /** 小号大写字母标签(如 "TOTAL JOBS TODAY") */ label: string; /** 主数字/值 */ value: string | number; /** 次要描述,显示在主值下方 */ subValue?: string; /** 趋势方向 */ trend?: TrendDirection; /** 趋势百分比,如 "+18%" */ trendValue?: string; /** 趋势说明文字,如 "vs last month" */ trendLabel?: string; /** sparkline 数据点 */ sparklineData?: SparklinePoint[]; /** 图标(可选的左侧小图标) */ icon?: React.ReactNode; /** 卡片尺寸 */ size?: "sm" | "default" | "lg"; } const MetricCard = React.forwardRef( ( { className, label, value, subValue, trend = "neutral", trendValue, trendLabel, sparklineData, icon, size = "default", ...props }, ref ) => { const paddingClass = { sm: "p-4", default: "p-5", lg: "p-6", }[size]; const valueClass = { sm: "text-2xl", default: "text-3xl", lg: "text-4xl", }[size]; return (
{/* Left color bar */}
{/* Content */}
{/* Label row */}

{label}

{trendValue && ( {trend === "up" && "+"}{trendValue} )}
{/* Value */}

{value}

{/* Trend label */} {trendLabel && (

{trendLabel}

)}
); } ); MetricCard.displayName = "MetricCard"; export { MetricCard };