{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "billing-01",
  "description": "Starting to ending monthly recurring revenue as a waterfall chart, with ending MRR against the start of the month, net new revenue and net revenue retention.",
  "registryDependencies": [
    "card",
    "https://www.dashboardblocks.com/r/radix/billing.json",
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/chart.json",
    "https://www.dashboardblocks.com/r/radix/chart-panel.json",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/kpi.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/billing/billing-01.tsx",
      "content": "'use client'\n\nimport {\n  type MrrMovementInput,\n  MrrWaterfall,\n  getMrrMovement,\n  getNetRevenueRetention,\n} from '@/registry/components/dashboardblocks/billing'\nimport {\n  BlockStateProvider,\n  type BlockStateProps,\n  getBlockState,\n} from '@/registry/components/dashboardblocks/block-state'\nimport { ChartPlaceholder } from '@/registry/components/dashboardblocks/chart'\nimport { ChartPanelTable } from '@/registry/components/dashboardblocks/chart-panel'\nimport { KPIChange, KPIValue } from '@/registry/components/dashboardblocks/kpi'\nimport {\n  formatCurrency,\n  formatPercent,\n  formatSigned,\n} from '@/registry/lib/dashboardblocks/format'\n\nimport { Card, CardContent } from '@/components/ui/card'\n\ninterface Billing1Props extends BlockStateProps {\n  /** @default 'USD' */\n  currency?: string\n  description: string\n  /** Leave out to show the empty state. */\n  movement?: MrrMovementInput\n  title: string\n}\n\nconst exampleProps: Billing1Props = {\n  description:\n    'September 2026. New business and expansion added $27,330, and contraction and churn took $8,200 back.',\n  movement: {\n    churn: 5_260,\n    contraction: 2_940,\n    expansion: 12_480,\n    newBusiness: 14_850,\n    starting: 182_400,\n  },\n  title: 'MRR movement',\n}\n\nconst Billing1 = (props: Billing1Props) => {\n  const {\n    currency = 'USD',\n    description,\n    movement = { churn: 0, contraction: 0, expansion: 0, newBusiness: 0, starting: 0 },\n    errorMessage,\n    status,\n    title,\n  } = props\n  const state = getBlockState(status, props.movement)\n  const { ending, net, steps } = getMrrMovement(movement)\n  const retention = getNetRevenueRetention(movement)\n  const format = (value: number) => formatCurrency(value, { currency })\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            <dl className='grid grid-cols-2 gap-x-6 gap-y-4 border-t pt-4 @lg:grid-cols-3 @lg:items-start'>\n              <div className='col-span-2 flex flex-col gap-1 @lg:col-span-1'>\n                <dt className='text-muted-foreground text-sm'>Ending MRR</dt>\n                <dd>\n                  <KPIValue\n                    className='whitespace-nowrap'\n                    value={ending}\n                    format={format}\n                  />\n                </dd>\n                <dd>\n                  <KPIChange\n                    inline\n                    comparison='at the start of the month'\n                    previous={movement.starting}\n                    value={ending}\n                  />\n                </dd>\n              </div>\n              {state !== 'empty' && state !== 'error' && (\n                <>\n                  <div className='flex flex-col gap-1'>\n                    <dt className='text-muted-foreground text-sm'>Net new MRR</dt>\n                    <dd>\n                      <KPIValue\n                        className='text-2xl'\n                        value={net}\n                        format={(value) => formatSigned(value, format)}\n                      />\n                    </dd>\n                  </div>\n                  <div className='flex flex-col gap-1'>\n                    <dt className='text-muted-foreground text-sm'>\n                      Net revenue retention\n                    </dt>\n                    <dd>\n                      <KPIValue\n                        className='text-2xl'\n                        value={retention}\n                        format={(value) => formatPercent(value)}\n                      />\n                    </dd>\n                  </div>\n                </>\n              )}\n            </dl>\n            {state ? (\n              <ChartPlaceholder height={256} />\n            ) : (\n              <MrrWaterfall\n                className='h-64'\n                formatter={(value) => formatCurrency(value, { compact: true, currency })}\n                label={`${title}: ${description}`}\n                steps={steps}\n                tooltipFormatter={format}\n              />\n            )}\n            {!state && (\n              <ChartPanelTable\n                caption={`${title}: ${description}`}\n                columns={[\n                  { key: 'label', label: 'Step' },\n                  { key: 'change', label: 'Change' },\n                  { key: 'total', label: 'MRR' },\n                ]}\n                rows={steps.map((step) => ({\n                  change: step.kind === 'total' ? '—' : formatSigned(step.value, format),\n                  label: step.label,\n                  total: format(step.to),\n                }))}\n              />\n            )}\n          </section>\n        </CardContent>\n      </Card>\n    </BlockStateProvider>\n  )\n}\n\nexport { Billing1, exampleProps as billing1ExampleProps, type Billing1Props }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/billing/billing-01.tsx"
    }
  ],
  "meta": {
    "shows": "Starting to ending monthly recurring revenue as a waterfall chart, with ending MRR against the start of the month, net new revenue and net revenue retention.",
    "size": "full",
    "usedWith": [
      "billing-04",
      "chart-panel-01",
      "retention-03"
    ],
    "component": "Billing1",
    "props": "{ currency?: string; description: string; movement?: { contraction: number; churn: number; expansion: number; newBusiness: number; starting: number }; title: string; errorMessage?: string; status?: \"loading\" | \"error\" }"
  },
  "type": "registry:component"
}
