{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retention-03",
  "description": "Day 1, 7 and 30 retention for the latest cohort, with the change against the cohort before written out.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json",
    "https://www.dashboardblocks.com/r/radix/retention.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/retention/retention-03.tsx",
      "content": "'use client'\n\nimport {\n  BlockStateProvider,\n  BlockStateRows,\n  type BlockStateProps,\n  SkeletonText,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { KPIChange } from '@/registry/components/dashboardblocks/kpi'\nimport { RetentionBar } from '@/registry/components/dashboardblocks/retention'\nimport { formatPercent } from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface RetentionMilestone {\n  label: string\n  /** Share of the current cohort still active, 0–1. */\n  current: number\n  /** The same share for the cohort before, 0–1. */\n  previous: number\n}\n\ninterface Retention3Props extends BlockStateProps {\n  description: string\n  /** Leave out, or pass none, to show the empty state. */\n  milestones?: RetentionMilestone[]\n  /** How many milestones to sketch while loading. @default 3 */\n  placeholders?: number\n  previousLabel?: string\n  title: string\n}\n\nconst exampleProps: Retention3Props = {\n  description: 'August signups, compared with July.',\n  milestones: [\n    { current: 0.584, label: 'Day 1', previous: 0.561 },\n    { current: 0.392, label: 'Day 7', previous: 0.366 },\n    { current: 0.247, label: 'Day 30', previous: 0.253 },\n  ],\n  previousLabel: 'July',\n  title: 'Retention milestones',\n}\n\nconst Retention3 = (props: Retention3Props) => {\n  const {\n    description,\n    milestones = [],\n    placeholders = 3,\n    previousLabel = 'the cohort before',\n    errorMessage,\n    status,\n    title,\n  } = props\n  const state = getBlockState(status, milestones)\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 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            </header>\n            {state === 'loading' && (\n              <ul aria-hidden className='flex flex-col gap-4 border-t pt-4'>\n                {Array.from({ length: placeholders }, (_, index) => (\n                  <li key={index} className='flex flex-col gap-2'>\n                    <div className='flex items-baseline justify-between gap-4'>\n                      <span className='text-sm'>\n                        <SkeletonText className='w-14' />\n                      </span>\n                      <span className='text-2xl font-light'>\n                        <SkeletonText className='w-[3em]' />\n                      </span>\n                    </div>\n                    <RetentionBar value={0} />\n                    <span className='text-xs'>\n                      <SkeletonText className='w-1/2' />\n                    </span>\n                  </li>\n                ))}\n              </ul>\n            )}\n            {(state === 'empty' || state === 'error') && (\n              <BlockStateRows className='border-t pt-4' />\n            )}\n            {!state && (\n              <ul className='flex flex-col gap-4 border-t pt-4'>\n                {milestones.map((milestone) => (\n                  <li key={milestone.label} className='flex flex-col gap-2'>\n                    <div className='flex items-baseline justify-between gap-4'>\n                      <span className='text-muted-foreground text-sm'>\n                        {milestone.label}\n                      </span>\n                      <span className='text-2xl font-light tracking-tight tabular-nums'>\n                        {formatPercent(milestone.current)}\n                      </span>\n                    </div>\n                    <RetentionBar value={milestone.current} />\n                    <KPIChange\n                      changeType='points'\n                      className='text-xs'\n                      comparison={`in ${previousLabel}`}\n                      previous={milestone.previous * 100}\n                      value={milestone.current * 100}\n                    />\n                  </li>\n                ))}\n              </ul>\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport {\n  Retention3,\n  exampleProps as retention3ExampleProps,\n  type Retention3Props,\n  type RetentionMilestone,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/retention/retention-03.tsx"
    }
  ],
  "meta": {
    "shows": "Day 1, 7 and 30 retention for the latest cohort, with the change against the cohort before written out.",
    "size": "compact",
    "usedWith": [
      "heatmap-01",
      "retention-01",
      "funnel-01"
    ],
    "component": "Retention3",
    "props": "{ description: string; milestones?: { label: string; current: number; previous: number }[]; placeholders?: number; previousLabel?: string; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
