{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "funnel-01",
  "description": "Each stage as a bar sized against the first, with the conversion at each step and overall.",
  "registryDependencies": [
    "card",
    "button",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/funnel.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/link.json",
    "https://www.dashboardblocks.com/r/radix/table.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/funnel/funnel-01.tsx",
      "content": "'use client'\n\nimport {\n  BlockReady,\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport {\n  FunnelBar,\n  type FunnelStage,\n  formatRate,\n  getFunnelSteps,\n} from '@/registry/components/dashboardblocks/funnel'\nimport { KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport { Link } from '@/registry/components/dashboardblocks/link'\nimport {\n  DataTable,\n  DataTableBody,\n  DataTableCell,\n  DataTableHead,\n  DataTableHeader,\n  DataTableRow,\n  DataTableRowHead,\n} from '@/registry/components/dashboardblocks/table'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatNumber } from '@/registry/lib/dashboardblocks/format'\nimport { Fragment } from 'react'\n\nimport { buttonVariants } from '@/components/ui/button'\nimport { Card, CardContent } from '@/components/ui/card'\n\nimport { cn } from '@/lib/utils'\n\ninterface Funnel1Props extends BlockStateProps {\n  description: string\n  /** Where the chart opens in full, such as the explorer it was saved from. */\n  link?: { href: string; label: string }\n  /** Leave out, or pass none, to show the empty state. */\n  stages?: FunnelStage[]\n  title: string\n}\n\nconst exampleProps: Funnel1Props = {\n  description: 'Visitors to paid customers, last 30 days.',\n  link: { href: '/dashboard/funnels', label: 'Open in Funnels' },\n  stages: [\n    { label: 'Visited site', value: 48_210 },\n    { label: 'Signed up', value: 9_870 },\n    { label: 'Activated', value: 5_430 },\n    { label: 'Started trial', value: 2_160 },\n    { label: 'Became customer', value: 812 },\n  ],\n  title: 'Signup funnel',\n}\n\nconst Funnel1 = (props: Funnel1Props) => {\n  const { description, errorMessage, link, stages = [], status, title } = props\n  const state = getBlockState(status, stages)\n  const steps = getFunnelSteps(stages)\n  const first = steps[0]\n  const last = steps.at(-1)\n\n  return (\n    <BlockStateProvider errorMessage={errorMessage} state={state}>\n      <Card>\n        <CardContent>\n          <section className='@container flex flex-col gap-4'>\n            <header className='flex items-start justify-between gap-3'>\n              <div className='flex min-w-0 flex-col gap-0.5'>\n                <h2 className='font-semibold tracking-tight'>{title}</h2>\n                <p className='text-muted-foreground text-sm'>{description}</p>\n              </div>\n              {link && (\n                <Link\n                  href={link.href}\n                  className={cn(\n                    buttonVariants({ size: 'xs', variant: 'outline' }),\n                    'group/open shrink-0',\n                  )}\n                >\n                  {link.label}\n                  <IconPlaceholder\n                    lucide='ArrowRightIcon'\n                    tabler='IconArrowRight'\n                    hugeicons='ArrowRight01Icon'\n                    phosphor='ArrowRightIcon'\n                    remixicon='RiArrowRightLine'\n                    className='transition-transform group-hover/open:translate-x-0.5 motion-reduce:transition-none'\n                    data-icon='inline-end'\n                    aria-hidden\n                  />\n                </Link>\n              )}\n            </header>\n            <dl className='flex flex-col gap-1 border-t pt-4'>\n              <dt className='text-muted-foreground text-sm'>Overall conversion</dt>\n              <dd>\n                <KPIValue\n                  value={last?.fromStart}\n                  format={(value) => formatRate(value, 2)}\n                />\n              </dd>\n              <BlockReady className='text-xs'>\n                {first && last && (\n                  <dd className='text-muted-foreground text-xs tabular-nums'>\n                    {formatNumber(last.value)} of {formatNumber(first.value)}\n                  </dd>\n                )}\n              </BlockReady>\n            </dl>\n            {state === 'loading' && <BlockStateRows rows={5} />}\n            {!state && (\n              <DataTable density='compact' caption={`${title}: ${description}`}>\n                <DataTableHeader>\n                  <DataTableRow>\n                    <DataTableHead>Stage</DataTableHead>\n                    <DataTableHead align='end'>Users</DataTableHead>\n                    <DataTableHead align='end'>\n                      Conversion<span className='sr-only'> from previous step</span>\n                    </DataTableHead>\n                  </DataTableRow>\n                </DataTableHeader>\n                <DataTableBody>\n                  {steps.map((step, index) => (\n                    <Fragment key={step.label}>\n                      <DataTableRow className='border-b-0'>\n                        <DataTableRowHead className='pb-1.5'>\n                          {step.label}\n                        </DataTableRowHead>\n                        <DataTableCell align='end' className='w-20 pb-1.5 font-medium'>\n                          {formatNumber(step.value)}\n                        </DataTableCell>\n                        <DataTableCell\n                          align='end'\n                          className='text-muted-foreground w-24 pb-1.5'\n                        >\n                          {index === 0 ? '—' : formatRate(step.fromPrevious)}\n                        </DataTableCell>\n                      </DataTableRow>\n                      <DataTableRow aria-hidden>\n                        <DataTableCell colSpan={3} className='pt-0'>\n                          <FunnelBar delay={index * 80} value={step.fromStart * 100} />\n                        </DataTableCell>\n                      </DataTableRow>\n                    </Fragment>\n                  ))}\n                </DataTableBody>\n              </DataTable>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Funnel1, exampleProps as funnel1ExampleProps, type Funnel1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/funnel/funnel-01.tsx"
    }
  ],
  "meta": {
    "shows": "Each stage as a bar sized against the first, with the conversion at each step and overall.",
    "size": "half",
    "usedWith": [
      "stat-group-02",
      "data-table-02",
      "chart-panel-01"
    ],
    "component": "Funnel1",
    "props": "{ description: string; link?: { href: string; label: string }; stages?: { label: string; value: number }[]; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
