{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboard",
  "title": "Dashboard",
  "description": "An application page with a collapsible sidebar, a header, stat cards, a line chart and a recent-activity table.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/avatar",
    "@corsair-ui/badge",
    "@corsair-ui/button",
    "@corsair-ui/card",
    "@corsair-ui/data-table",
    "@corsair-ui/line-chart",
    "@corsair-ui/separator",
    "@corsair-ui/sidebar",
    "@corsair-ui/stat"
  ],
  "files": [
    {
      "path": "registry/default/components/blocks/dashboard.tsx",
      "content": "\"use client\";\n\nimport {\n  ChartColumnIcon,\n  CommandIcon,\n  FolderIcon,\n  HouseIcon,\n  InboxIcon,\n  LifeBuoyIcon,\n  PlusIcon,\n  SettingsIcon,\n  UsersIcon,\n} from \"lucide-react\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport { cn } from \"@/registry/default/lib/utils\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/registry/default/ui/avatar\";\nimport { Badge } from \"@/registry/default/ui/badge\";\nimport { Button } from \"@/registry/default/ui/button\";\nimport { Card, CardContent, CardDescription, CardHeader } from \"@/registry/default/ui/card\";\nimport {\n  DataTable,\n  type DataTableColumnDef,\n  type DataTableProps,\n} from \"@/registry/default/ui/data-table\";\nimport { LineChart, type LineChartProps } from \"@/registry/default/ui/line-chart\";\nimport { Separator } from \"@/registry/default/ui/separator\";\nimport {\n  Sidebar,\n  SidebarContent,\n  SidebarFooter,\n  SidebarGroup,\n  SidebarGroupLabel,\n  SidebarHeader,\n  SidebarInset,\n  SidebarMenu,\n  SidebarMenuBadge,\n  SidebarMenuButton,\n  SidebarMenuItem,\n  SidebarProvider,\n  SidebarTrigger,\n  useSidebar,\n  type SidebarProps,\n  type SidebarProviderProps,\n} from \"@/registry/default/ui/sidebar\";\nimport {\n  Stat,\n  StatCaption,\n  StatGroup,\n  StatLabel,\n  StatValue,\n  type StatTrend,\n} from \"@/registry/default/ui/stat\";\n\n/** One link in the sidebar. */\ninterface DashboardNavItem {\n  /** Stable React key. Falls back to `href`. */\n  id?: string;\n  /** Visible text; also the tooltip while the sidebar is collapsed to icons. */\n  label: string;\n  href: string;\n  /** Shown before the label and kept when the sidebar collapses to icons. */\n  icon?: ReactNode;\n  /** A count or status beside the link (\"12\", \"New\"). */\n  badge?: ReactNode;\n  /** Marks the current page: highlighted and announced as `aria-current=\"page\"`. */\n  active?: boolean;\n}\n\n/** A labelled group of sidebar links. */\ninterface DashboardNavGroup {\n  /** Stable React key. Falls back to the index. */\n  id?: string;\n  label: ReactNode;\n  items: DashboardNavItem[];\n}\n\n/** The account shown at the bottom of the sidebar. */\ninterface DashboardUser {\n  name: string;\n  email?: string;\n  /** Image URL for the avatar; initials of `name` show while it loads or when it fails. */\n  avatar?: string;\n}\n\n/** One figure in the row of stat cards. */\ninterface DashboardStat {\n  /** Stable React key. Falls back to the index. */\n  id?: string;\n  label: ReactNode;\n  /** Rendered as is: format numbers before passing them. */\n  value: ReactNode;\n  /** A note under the value: a comparison, a period. */\n  caption?: ReactNode;\n  /** Adds an arrow for the direction of change next to the caption. */\n  trend?: StatTrend;\n}\n\n/** The chart card: a title and any `LineChart` props (`data`, `labels`, `numberFormat`…). */\ninterface DashboardChart extends Omit<LineChartProps, \"title\"> {\n  title: ReactNode;\n  description?: ReactNode;\n  labels: string[];\n}\n\n/** The table card: a title and any `DataTable` props (`columns`, `data`, `pageSize`…). */\ninterface DashboardTable<TData extends object> extends Omit<DataTableProps<TData>, \"title\"> {\n  title: ReactNode;\n  description?: ReactNode;\n}\n\n/** A row of the default recent-activity table. */\ninterface DashboardActivity {\n  id: string;\n  customer: string;\n  email: string;\n  status: \"Paid\" | \"Pending\" | \"Failed\";\n  amount: string;\n  date: string;\n}\n\ninterface DashboardProps<TData extends object = DashboardActivity> extends Omit<\n  ComponentProps<\"div\">,\n  \"title\"\n> {\n  /** Shown at the top of the sidebar: a logo and a name. */\n  brand?: ReactNode;\n  /** Groups of links in the sidebar. */\n  nav?: DashboardNavGroup[];\n  /** The signed-in account at the bottom of the sidebar. Pass `null` to hide it. */\n  user?: DashboardUser | null;\n  /** Page title, rendered as the `<h1>` in the header. */\n  title?: ReactNode;\n  /** Buttons at the end of the header. Pass `null` to hide them. */\n  actions?: ReactNode;\n  /** The row of stat cards. Pass an empty array to hide it. */\n  stats?: DashboardStat[];\n  /** Read to screen readers before a caption with a trend, since the arrow is only a picture. */\n  trendLabels?: Partial<Record<StatTrend, string>>;\n  /** The line chart card. Pass `null` to hide it. */\n  chart?: DashboardChart | null;\n  /** The recent-activity table card. Pass `null` to hide it. */\n  table?: DashboardTable<TData> | null;\n  /** Extra content under the cards. */\n  children?: ReactNode;\n  /** Props for `SidebarProvider`: `defaultOpen`, `open`, `onOpenChange`, `shortcut`, `width`. */\n  providerProps?: Omit<SidebarProviderProps, \"children\">;\n  /** Props for `Sidebar`: `collapsible`, `side`, `aria-label`, `className`. */\n  sidebarProps?: Omit<SidebarProps, \"children\">;\n  /** Props for the `<main>` next to the sidebar. */\n  insetProps?: Omit<ComponentProps<\"main\">, \"children\">;\n}\n\nconst defaultTrendLabels: Record<StatTrend, string> = {\n  up: \"Increase\",\n  down: \"Decrease\",\n  flat: \"No change\",\n};\n\nconst defaultBrand = (\n  <div data-slot=\"dashboard-brand\" className=\"flex items-center gap-2 overflow-hidden\">\n    <span\n      aria-hidden=\"true\"\n      className=\"bg-primary text-primary-foreground flex size-8 shrink-0 items-center justify-center rounded-md\"\n    >\n      <CommandIcon className=\"size-4\" />\n    </span>\n    <span className=\"truncate text-sm font-semibold group-data-[state=collapsed]/sidebar:sr-only\">\n      Acme Inc\n    </span>\n  </div>\n);\n\nconst defaultNav: DashboardNavGroup[] = [\n  {\n    id: \"workspace\",\n    label: \"Workspace\",\n    items: [\n      {\n        label: \"Overview\",\n        href: \"#overview\",\n        icon: <HouseIcon aria-hidden=\"true\" />,\n        active: true,\n      },\n      { label: \"Inbox\", href: \"#inbox\", icon: <InboxIcon aria-hidden=\"true\" />, badge: \"4\" },\n      { label: \"Projects\", href: \"#projects\", icon: <FolderIcon aria-hidden=\"true\" /> },\n      { label: \"Reports\", href: \"#reports\", icon: <ChartColumnIcon aria-hidden=\"true\" /> },\n      { label: \"Customers\", href: \"#customers\", icon: <UsersIcon aria-hidden=\"true\" /> },\n    ],\n  },\n  {\n    id: \"general\",\n    label: \"General\",\n    items: [\n      { label: \"Settings\", href: \"#settings\", icon: <SettingsIcon aria-hidden=\"true\" /> },\n      { label: \"Support\", href: \"#support\", icon: <LifeBuoyIcon aria-hidden=\"true\" /> },\n    ],\n  },\n];\n\nconst defaultUser: DashboardUser = { name: \"Alex Morgan\", email: \"alex@example.com\" };\n\nconst defaultActions = (\n  <Button size=\"sm\">\n    <PlusIcon aria-hidden=\"true\" />\n    New report\n  </Button>\n);\n\nconst defaultStats: DashboardStat[] = [\n  {\n    id: \"revenue\",\n    label: \"Revenue\",\n    value: \"$48,200\",\n    caption: \"12% since last month\",\n    trend: \"up\",\n  },\n  {\n    id: \"customers\",\n    label: \"Customers\",\n    value: \"1,240\",\n    caption: \"86 new this month\",\n    trend: \"up\",\n  },\n  { id: \"orders\", label: \"Orders\", value: \"3,512\", caption: \"4% since last month\", trend: \"down\" },\n  { id: \"uptime\", label: \"Uptime\", value: \"99.9%\", caption: \"Same as last month\", trend: \"flat\" },\n];\n\nconst months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst defaultChart: DashboardChart = {\n  title: \"Revenue\",\n  description: \"Monthly revenue over the last twelve months.\",\n  name: \"Revenue\",\n  data: [18, 22, 21, 26, 30, 28, 34, 37, 35, 41, 44, 48],\n  labels: months,\n  formatValue: (value) => `$${value}k`,\n  formatValueText: (value, index) => `${months[index]}: $${value}k`,\n};\n\nconst statusVariants = {\n  Paid: \"success\",\n  Pending: \"warning\",\n  Failed: \"destructive\",\n} as const;\n\nconst defaultColumns: DataTableColumnDef<DashboardActivity>[] = [\n  {\n    accessorKey: \"customer\",\n    header: \"Customer\",\n    cell: ({ row }) => (\n      <div className=\"flex flex-col\">\n        <span className=\"font-medium\">{row.original.customer}</span>\n        <span className=\"text-muted-foreground text-xs\">{row.original.email}</span>\n      </div>\n    ),\n  },\n  {\n    accessorKey: \"status\",\n    header: \"Status\",\n    cell: ({ row }) => (\n      <Badge variant={statusVariants[row.original.status]}>{row.original.status}</Badge>\n    ),\n  },\n  { accessorKey: \"date\", header: \"Date\" },\n  {\n    accessorKey: \"amount\",\n    header: \"Amount\",\n    cell: ({ row }) => <span className=\"tabular-nums\">{row.original.amount}</span>,\n  },\n];\n\nconst defaultRows: DashboardActivity[] = [\n  {\n    id: \"inv-1024\",\n    customer: \"Jordan Lee\",\n    email: \"jordan@example.com\",\n    status: \"Paid\",\n    amount: \"$250.00\",\n    date: \"Dec 12\",\n  },\n  {\n    id: \"inv-1023\",\n    customer: \"Sam Rivera\",\n    email: \"sam@example.com\",\n    status: \"Pending\",\n    amount: \"$120.00\",\n    date: \"Dec 11\",\n  },\n  {\n    id: \"inv-1022\",\n    customer: \"Taylor Kim\",\n    email: \"taylor@example.com\",\n    status: \"Paid\",\n    amount: \"$980.00\",\n    date: \"Dec 10\",\n  },\n  {\n    id: \"inv-1021\",\n    customer: \"Casey Brooks\",\n    email: \"casey@example.com\",\n    status: \"Failed\",\n    amount: \"$64.00\",\n    date: \"Dec 9\",\n  },\n  {\n    id: \"inv-1020\",\n    customer: \"Morgan Diaz\",\n    email: \"morgan@example.com\",\n    status: \"Paid\",\n    amount: \"$410.00\",\n    date: \"Dec 8\",\n  },\n];\n\nconst defaultTable: DashboardTable<DashboardActivity> = {\n  title: \"Recent activity\",\n  description: \"The latest payments from your customers.\",\n  columns: defaultColumns,\n  data: defaultRows,\n  getRowId: (row) => row.id,\n  filterLabel: \"Filter activity\",\n  pageSize: null,\n};\n\n/** Up to two initials from a name, for the avatar fallback. */\nfunction initials(name: string) {\n  return name\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((part) => part[0])\n    .join(\"\");\n}\n\n/** The sidebar links; closes the mobile sheet after a link is followed. */\nfunction DashboardNav({ nav }: { nav: DashboardNavGroup[] }) {\n  const { isMobile, setOpenMobile } = useSidebar();\n\n  return nav.map((group, groupIndex) => (\n    <SidebarGroup key={group.id ?? groupIndex} data-slot=\"dashboard-nav-group\">\n      <SidebarGroupLabel>{group.label}</SidebarGroupLabel>\n      <SidebarMenu>\n        {group.items.map((item) => (\n          <SidebarMenuItem key={item.id ?? item.href}>\n            <SidebarMenuButton asChild isActive={item.active} tooltip={item.label}>\n              <a\n                href={item.href}\n                onClick={() => {\n                  if (isMobile) setOpenMobile(false);\n                }}\n              >\n                {item.icon}\n                <span>{item.label}</span>\n              </a>\n            </SidebarMenuButton>\n            {item.badge != null ? <SidebarMenuBadge>{item.badge}</SidebarMenuBadge> : null}\n          </SidebarMenuItem>\n        ))}\n      </SidebarMenu>\n    </SidebarGroup>\n  ));\n}\n\n/**\n * An application page: a collapsible sidebar with a brand, groups of links\n * and the signed-in account, next to a `<main>` with a header (sidebar\n * trigger, `<h1>` title, actions), a row of stat cards, a line chart card\n * and a recent-activity table. `<Dashboard />` renders a complete example\n * for a fictional \"Acme\"; every piece is a prop, and `null` hides it.\n *\n * Layout: the root is the `SidebarProvider` wrapper, a flex row that fills\n * the viewport (`min-h-svh`) with a sticky, full-height sidebar. To contain\n * it in a box (a preview, a docs page), give the root a height and clip it,\n * make the sidebar fill that height and let the main area scroll:\n * `className=\"h-[640px] min-h-0 overflow-hidden\"`,\n * `sidebarProps={{ className: \"h-full\" }}` and\n * `insetProps={{ className: \"overflow-auto\" }}`. Below 768px the sidebar\n * opens as a sheet over the viewport.\n *\n * Keyboard and screen readers: the sidebar is a named complementary\n * landmark and the page a `<main>`; ⌘B / Ctrl+B or the trigger toggles the\n * sidebar (set `providerProps.shortcut` to change or disable it). The\n * active link is announced as the current page, and collapsed to icons each\n * link keeps its name and shows a tooltip. Stats are a description list\n * with trend arrows replaced by `trendLabels`; the chart is a slider that\n * the arrow keys move between points; the table has sortable headers and a\n * filter. Motion (sidebar width, chart cursor) stops with\n * `prefers-reduced-motion`.\n *\n * @example\n * <Dashboard\n *   title=\"Overview\"\n *   user={{ name: \"Sam Lee\", email: \"sam@example.com\" }}\n *   providerProps={{ defaultOpen: false }}\n *   stats={[{ label: \"Revenue\", value: \"$12,400\", caption: \"8% up\", trend: \"up\" }]}\n *   chart={{ title: \"Visitors\", data: [4, 6, 5, 9], labels: [\"Q1\", \"Q2\", \"Q3\", \"Q4\"] }}\n *   table={null}\n * />\n */\nfunction Dashboard<TData extends object = DashboardActivity>({\n  brand = defaultBrand,\n  nav = defaultNav,\n  user = defaultUser,\n  title = \"Dashboard\",\n  actions = defaultActions,\n  stats = defaultStats,\n  trendLabels,\n  chart = defaultChart,\n  table = defaultTable as unknown as DashboardTable<TData>,\n  children,\n  providerProps,\n  sidebarProps,\n  insetProps,\n  className,\n  ...props\n}: DashboardProps<TData>) {\n  const labels = { ...defaultTrendLabels, ...trendLabels };\n\n  return (\n    <SidebarProvider\n      data-slot=\"dashboard\"\n      {...providerProps}\n      {...props}\n      className={cn(providerProps?.className, className)}\n    >\n      <Sidebar {...sidebarProps}>\n        {brand != null ? <SidebarHeader>{brand}</SidebarHeader> : null}\n        <SidebarContent>\n          <DashboardNav nav={nav} />\n        </SidebarContent>\n        {user ? (\n          <SidebarFooter>\n            <div data-slot=\"dashboard-user\" className=\"flex items-center gap-2 overflow-hidden\">\n              <Avatar aria-hidden=\"true\">\n                {user.avatar ? <AvatarImage src={user.avatar} alt=\"\" /> : null}\n                <AvatarFallback>{initials(user.name)}</AvatarFallback>\n              </Avatar>\n              <div className=\"grid min-w-0 flex-1 text-sm leading-tight group-data-[state=collapsed]/sidebar:sr-only\">\n                <span data-slot=\"dashboard-user-name\" className=\"truncate font-medium\">\n                  {user.name}\n                </span>\n                {user.email ? (\n                  <span\n                    data-slot=\"dashboard-user-email\"\n                    className=\"text-muted-foreground truncate text-xs\"\n                  >\n                    {user.email}\n                  </span>\n                ) : null}\n              </div>\n            </div>\n          </SidebarFooter>\n        ) : null}\n      </Sidebar>\n      <SidebarInset {...insetProps}>\n        <header\n          data-slot=\"dashboard-header\"\n          className=\"flex h-14 shrink-0 items-center gap-2 border-b px-4 sm:px-6\"\n        >\n          <SidebarTrigger className=\"-ml-1\" />\n          <Separator orientation=\"vertical\" className=\"mr-2 h-4\" />\n          <h1\n            data-slot=\"dashboard-title\"\n            className=\"min-w-0 flex-1 truncate text-base font-semibold\"\n          >\n            {title}\n          </h1>\n          {actions != null ? (\n            <div data-slot=\"dashboard-actions\" className=\"flex items-center gap-2\">\n              {actions}\n            </div>\n          ) : null}\n        </header>\n        <div data-slot=\"dashboard-content\" className=\"flex flex-1 flex-col gap-6 p-4 sm:p-6\">\n          {stats.length > 0 ? (\n            <StatGroup data-slot=\"dashboard-stats\" className=\"gap-4 sm:grid-cols-2 xl:grid-cols-4\">\n              {stats.map((stat, index) => (\n                <Stat\n                  key={stat.id ?? index}\n                  className=\"bg-card min-w-0 gap-2 rounded-xl border p-6\"\n                >\n                  <StatLabel>{stat.label}</StatLabel>\n                  <StatValue className=\"break-words\">{stat.value}</StatValue>\n                  {stat.caption != null || stat.trend ? (\n                    <StatCaption\n                      trend={stat.trend}\n                      trendLabel={stat.trend ? labels[stat.trend] : undefined}\n                    >\n                      {stat.caption}\n                    </StatCaption>\n                  ) : null}\n                </Stat>\n              ))}\n            </StatGroup>\n          ) : null}\n          {chart ? <DashboardChartCard {...chart} /> : null}\n          {table ? <DashboardTableCard {...table} /> : null}\n          {children}\n        </div>\n      </SidebarInset>\n    </SidebarProvider>\n  );\n}\n\nfunction DashboardChartCard({ title, description, name, ...chart }: DashboardChart) {\n  return (\n    <Card data-slot=\"dashboard-chart\" className=\"min-w-0\">\n      <CardHeader>\n        <h2 data-slot=\"dashboard-chart-title\" className=\"leading-none font-semibold\">\n          {title}\n        </h2>\n        {description != null ? <CardDescription>{description}</CardDescription> : null}\n      </CardHeader>\n      <CardContent>\n        <LineChart name={name ?? (typeof title === \"string\" ? title : undefined)} {...chart} />\n      </CardContent>\n    </Card>\n  );\n}\n\nfunction DashboardTableCard<TData extends object>({\n  title,\n  description,\n  caption,\n  ...table\n}: DashboardTable<TData>) {\n  return (\n    <Card data-slot=\"dashboard-table\" className=\"min-w-0\">\n      <CardHeader>\n        <h2 data-slot=\"dashboard-table-title\" className=\"leading-none font-semibold\">\n          {title}\n        </h2>\n        {description != null ? <CardDescription>{description}</CardDescription> : null}\n      </CardHeader>\n      <CardContent>\n        <DataTable\n          caption={caption ?? (typeof title === \"string\" ? title : undefined)}\n          {...table}\n        />\n      </CardContent>\n    </Card>\n  );\n}\n\nexport {\n  Dashboard,\n  type DashboardActivity,\n  type DashboardChart,\n  type DashboardNavGroup,\n  type DashboardNavItem,\n  type DashboardProps,\n  type DashboardStat,\n  type DashboardTable,\n  type DashboardUser,\n};\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:block"
}