{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "billing-period-selector",
  "title": "Billing Period Selector",
  "description": "A month grid where only months that have an invoice can be opened, with the others dimmed and explained, and an invoice count for the chosen month. Use this when a customer browses invoices or statements and only some months have one.",
  "registryDependencies": [
    "@tealmac/month-picker",
    "@tealmac/date-time-core"
  ],
  "files": [
    {
      "path": "registry/patterns/billing-period-selector/billing-period-selector.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  monthNames,\n  parseMonth,\n  resolveLocale,\n} from \"@/components/ui/date-time-core\"\nimport { MonthPicker } from \"@/components/ui/month-picker\"\n\nexport interface BillingPeriodSelectorProps {\n  invoices: Record<string, number>\n  onValueChange?: (month: string, count: number) => void\n  today?: string\n  locale?: string\n}\n\nexport function BillingPeriodSelector({\n  invoices,\n  onValueChange,\n  today,\n  locale,\n}: BillingPeriodSelectorProps) {\n  const loc = resolveLocale(locale)\n  const [month, setMonth] = React.useState<string | null>(null)\n  const parsed = parseMonth(month)\n  const count = month ? (invoices[month] ?? 0) : 0\n\n  return (\n    <div className=\"flex flex-col gap-2\">\n      <MonthPicker\n        label=\"Billing month\"\n        locale={loc}\n        today={today}\n        value={month}\n        labelWidth=\"short\"\n        isMonthUnavailable={(m) => !invoices[m]}\n        onValueChange={(m) => {\n          setMonth(m)\n          if (m) onValueChange?.(m, invoices[m] ?? 0)\n        }}\n        className=\"border\"\n      />\n      <p className=\"text-muted-foreground text-xs\">\n        Months without an invoice are dimmed.\n      </p>\n      <p role=\"status\" className=\"text-sm\">\n        {month && parsed\n          ? `${monthNames(loc, \"long\")[parsed.m - 1]} ${parsed.y}: ${count} invoice${count === 1 ? \"\" : \"s\"}`\n          : \"Choose a month.\"}\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}