{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "conversion-funnel",
  "type": "registry:component",
  "title": "Conversion funnel",
  "description": "A readable journey through conversion stages, including overall and step conversion rates.",
  "categories": [
    "charts"
  ],
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/conversion-funnel.tsx",
      "type": "registry:component",
      "target": "components/overtrue/conversion-funnel.tsx",
      "content": "import { cn } from \"@/lib/utils\";\n\nexport interface FunnelStage {\n  id: string;\n  label: string;\n  value: number;\n}\nexport interface ConversionFunnelProps {\n  stages: FunnelStage[];\n  label: string;\n  formatValue?: (value: number) => string;\n  className?: string;\n}\n\nconst keyframes =\n  \"@keyframes conversion-funnel-grow{from{transform:scaleX(0)}to{transform:scaleX(1)}}\";\n\nexport function ConversionFunnel({\n  stages,\n  label,\n  formatValue = (value) => value.toLocaleString(\"en-US\"),\n  className,\n}: ConversionFunnelProps) {\n  const rows = stages.map((stage) => ({\n    ...stage,\n    value: Number.isFinite(stage.value) ? Math.max(0, stage.value) : 0,\n  }));\n  const first = rows[0]?.value ?? 0;\n  const maximum = rows.reduce((max, stage) => Math.max(max, stage.value), 0);\n  return (\n    <ol\n      data-slot=\"conversion-funnel\"\n      aria-label={label}\n      className={cn(\"m-0 list-none space-y-5 p-0\", className)}\n    >\n      <style href=\"overtrue-conversion-funnel\" precedence=\"default\">\n        {keyframes}\n      </style>\n      {!rows.length && (\n        <li className=\"py-8 text-center text-sm text-muted-foreground\">\n          No conversion data for this period.\n        </li>\n      )}\n      {rows.map((stage, index) => {\n        const previous = rows[index - 1]?.value;\n        const width = maximum ? (stage.value / maximum) * 100 : 0;\n        const previousWidth =\n          maximum && previous !== undefined ? (previous / maximum) * 100 : 0;\n        return (\n          <li key={stage.id} data-slot=\"conversion-funnel-stage\">\n            <div className=\"mb-2 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 text-sm\">\n              <span className=\"min-w-0 wrap-anywhere text-foreground\">\n                <span className=\"mr-2 font-mono text-xs tabular-nums text-muted-foreground\">\n                  {String(index + 1).padStart(2, \"0\")}\n                </span>\n                {stage.label}\n              </span>\n              <span className=\"font-semibold tracking-[-0.01em] tabular-nums text-foreground\">\n                {formatValue(stage.value)}\n              </span>\n            </div>\n            <div\n              aria-hidden=\"true\"\n              data-slot=\"conversion-funnel-track\"\n              className=\"relative h-2 overflow-hidden rounded-full bg-muted\"\n            >\n              {previousWidth > width && (\n                <div\n                  data-slot=\"conversion-funnel-loss\"\n                  className=\"absolute inset-y-0 transition-[left,width] duration-500 motion-reduce:transition-none\"\n                  style={{\n                    left: `${width}%`,\n                    width: `${previousWidth - width}%`,\n                    backgroundImage:\n                      \"repeating-linear-gradient(-45deg, color-mix(in oklab, var(--color-primary) 24%, transparent) 0 1px, transparent 1px 4px)\",\n                  }}\n                />\n              )}\n              <div\n                data-slot=\"conversion-funnel-bar\"\n                className=\"relative h-full origin-left rounded-full transition-[width] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] motion-safe:animate-[conversion-funnel-grow_700ms_cubic-bezier(0.22,1,0.36,1)_both] motion-reduce:transition-none\"\n                style={{\n                  width: `${width}%`,\n                  opacity: 1 - Math.min(index, 4) * 0.1,\n                  backgroundImage:\n                    \"linear-gradient(90deg, color-mix(in oklab, var(--color-primary) 72%, transparent), var(--color-primary))\",\n                  animationDelay: `${Math.min(index, 8) * 60}ms`,\n                }}\n              />\n            </div>\n            <p className=\"mt-1.5 flex flex-wrap justify-between gap-x-3 text-xs tabular-nums text-muted-foreground\">\n              <span>\n                {first\n                  ? `${((stage.value / first) * 100).toFixed(1)}% of ${rows[0].label.toLowerCase()}`\n                  : \"Conversion unavailable\"}\n              </span>\n              {index > 0 && (\n                <span>\n                  {previous\n                    ? `${((stage.value / previous) * 100).toFixed(1)}% from previous`\n                    : \"No previous entries\"}\n                </span>\n              )}\n            </p>\n          </li>\n        );\n      })}\n    </ol>\n  );\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/conversion-funnel. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
