{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-card-stat-progress",
  "title": "Card Stat Progress",
  "description": "A statistical card with an embedded progress bar for showing completion or attainment levels.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/card-stat-shared",
    "@lema-ds/card",
    "@lema-ds/progress",
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider",
    "@lema-ds/tokens"
  ],
  "files": [
    {
      "path": "components/ds/ds-card-stat-progress.tsx",
      "content": "import * as React from \"react\"\nimport { cva } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useOptionalUILocale } from \"@/components/ui/ds-locale-provider\"\nimport { Card, CardAction, CardContent, CardHeader } from \"@/components/ui/card\"\nimport { Progress } from \"@/components/ui/progress\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\n\nimport {\n  type CardStatSize,\n  type FormatOptions,\n  applyFormat,\n  formatValue,\n  cardStatLabelVariants,\n  cardStatValueVariants,\n  cardStatDescriptionVariants,\n  cardStatHeaderIconVariants,\n  cardStatContentGapVariants,\n} from \"@/lib/card-stats-shared\"\n\n// ── Variants ──\nexport const cardStatTrackHVariants = cva(\"\", {\n  variants: {\n    size: {\n      sm: \"h-2\",\n      md: \"h-3\",\n      lg: \"h-4\",\n    },\n  },\n  defaultVariants: { size: \"sm\" },\n})\n\nexport interface CardStatProgressProps extends FormatOptions {\n  label: string\n  value: number\n  goal: number\n  description?: string\n  icon?: React.ElementType\n  showPercent?: boolean\n  size?: CardStatSize\n  className?: string\n  loading?: boolean\n  empty?: boolean\n}\n\nexport function CardStatProgress({\n  label,\n  value,\n  goal,\n  description,\n  icon: Icon,\n  showPercent = true,\n  size = \"sm\",\n  className,\n  loading,\n  empty,\n  locale: pctLocaleProp,\n  ...fmt\n}: CardStatProgressProps) {\n  const pctLocale = useOptionalUILocale(pctLocaleProp)\n  if (loading) {\n    return (\n      <Card size=\"sm\" className={className} data-slot=\"card-stat-progress\">\n        <CardHeader className=\"flex flex-row items-center justify-between\">\n          <Skeleton className=\"h-3 w-28 rounded-md\" />\n          <Skeleton\n            className={cn(cardStatHeaderIconVariants({ size }), \"rounded-md\")}\n          />\n        </CardHeader>\n        <CardContent\n          className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n        >\n          <div className=\"flex items-baseline justify-between gap-2\">\n            <Skeleton className=\"h-7 w-24\" />\n            <Skeleton className=\"h-4 w-16 rounded-md\" />\n          </div>\n          <Skeleton\n            className={cn(cardStatTrackHVariants({ size }), \"rounded-full\")}\n          />\n          <div className=\"flex items-center justify-between\">\n            <Skeleton className=\"h-3 w-32 rounded-md\" />\n            <Skeleton className=\"h-3 w-8 rounded-md\" />\n          </div>\n        </CardContent>\n      </Card>\n    )\n  }\n\n  if (empty) {\n    return (\n      <Card size=\"sm\" className={className} data-slot=\"card-stat-progress\">\n        <CardHeader className=\"flex flex-row items-center justify-between\">\n          <span\n            className={cn(\n              \"truncate text-muted-foreground\",\n              cardStatLabelVariants({ size })\n            )}\n          >\n            {label}\n          </span>\n          {Icon && (\n            <CardAction className=\"text-muted-foreground\">\n              <Icon\n                className={cardStatHeaderIconVariants({ size })}\n                aria-hidden\n              />\n            </CardAction>\n          )}\n        </CardHeader>\n        <CardContent\n          className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n        >\n          <div className=\"flex items-baseline justify-between gap-2\">\n            <p\n              className={cn(\n                cardStatValueVariants({ size }),\n                \"text-muted-foreground/25\"\n              )}\n            >\n              —\n            </p>\n            <span\n              className={cn(\n                \"shrink-0 text-muted-foreground/25\",\n                cardStatDescriptionVariants({ size })\n              )}\n            >\n              / —\n            </span>\n          </div>\n          <div\n            className={cn(\n              cardStatTrackHVariants({ size }),\n              \"w-full rounded-full border border-dashed border-muted-foreground/20\"\n            )}\n          />\n          <p\n            className={cn(\n              \"text-center text-muted-foreground/50\",\n              cardStatDescriptionVariants({ size })\n            )}\n          >\n            {pctLocale\n              ? UI_I18N[pctLocale as UILocale].cardStatProgress.noGoalSet\n              : \"No goal set yet\"}\n          </p>\n        </CardContent>\n      </Card>\n    )\n  }\n\n  const displayValue = applyFormat(value, { locale: pctLocale, ...fmt })\n  const displayGoal = applyFormat(goal, { locale: pctLocale, ...fmt })\n  const pct = Math.min(100, Math.round((value / goal) * 100))\n\n  const pctColor =\n    pct >= 100\n      ? \"text-success\"\n      : pct >= 75\n        ? \"text-highlight-sky\"\n        : pct >= 50\n          ? \"text-warning\"\n          : \"text-muted-foreground\"\n\n  const barColor =\n    pct >= 100\n      ? \"[&>[data-slot=progress-indicator]]:bg-success\"\n      : pct >= 75\n        ? \"[&>[data-slot=progress-indicator]]:bg-highlight-sky\"\n        : pct >= 50\n          ? \"[&>[data-slot=progress-indicator]]:bg-warning\"\n          : \"\"\n\n  return (\n    <Card size=\"sm\" className={className} data-slot=\"card-stat-progress\">\n      <CardHeader className=\"flex flex-row items-center justify-between\">\n        <span\n          className={cn(\n            \"truncate text-muted-foreground\",\n            cardStatLabelVariants({ size })\n          )}\n        >\n          {label}\n        </span>\n        {Icon && (\n          <CardAction className=\"text-muted-foreground\">\n            <Icon\n              className={cardStatHeaderIconVariants({ size })}\n              aria-hidden\n            />\n          </CardAction>\n        )}\n      </CardHeader>\n      <CardContent\n        className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n      >\n        <div className=\"flex items-baseline justify-between gap-2\">\n          <p className={cardStatValueVariants({ size })}>{displayValue}</p>\n          <span\n            className={cn(\n              \"shrink-0 text-muted-foreground\",\n              cardStatDescriptionVariants({ size })\n            )}\n          >\n            / {displayGoal}\n          </span>\n        </div>\n        <Progress\n          value={pct}\n          aria-label={`${label}: ${pct}%`}\n          className={cn(cardStatTrackHVariants({ size }), barColor)}\n        />\n        <div className=\"flex items-center justify-between\">\n          {description && (\n            <p\n              className={cn(\n                \"text-muted-foreground\",\n                cardStatDescriptionVariants({ size })\n              )}\n            >\n              {description}\n            </p>\n          )}\n          {showPercent && (\n            <p\n              className={cn(\n                \"ml-auto font-semibold tabular-nums\",\n                cardStatDescriptionVariants({ size }),\n                pctColor\n              )}\n            >\n              {formatValue(pct / 100, \"percent\", {\n                decimals: 0,\n                locale: pctLocale,\n              })}\n            </p>\n          )}\n        </div>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
