{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-panel",
  "title": "Chart Panel",
  "description": "Primitives for full-size chart panels: tooltip, legend, axis defaults and an accessible data table.",
  "dependencies": [
    "recharts"
  ],
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/chart.json",
    "https://www.dashboardblocks.com/r/radix/table.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/chart-panel.tsx",
      "content": "'use client'\n\nimport { useBlockState } from '@/registry/components/dashboardblocks/block-state'\nimport {\n  chartHatchFill,\n  ChartPlaceholder,\n  type ChartValueFormatter,\n} from '@/registry/components/dashboardblocks/chart'\nimport {\n  DataTable,\n  DataTableBody,\n  DataTableCell,\n  DataTableHead,\n  DataTableHeader,\n  DataTableRow,\n  DataTableRowHead,\n} from '@/registry/components/dashboardblocks/table'\nimport type { ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ntype ChartPanelKeyShape = 'dashed' | 'hatched' | 'line' | 'outline' | 'rect'\n\ninterface ChartPanelKeyProps {\n  className?: string\n  color: string\n  shape?: ChartPanelKeyShape\n}\n\nfunction ChartPanelKey({ className, color, shape = 'rect' }: ChartPanelKeyProps) {\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        'inline-block shrink-0',\n        shape === 'dashed'\n          ? 'h-0.5 w-4'\n          : shape === 'line'\n            ? 'h-0.5 w-3 rounded-full'\n            : shape === 'outline'\n              ? 'size-2.5 rounded-[3px] border border-dashed'\n              : 'size-2.5 rounded-[3px]',\n        className,\n      )}\n      style={\n        shape === 'dashed'\n          ? {\n              backgroundImage: `repeating-linear-gradient(to right, ${color} 0 3px, transparent 3px 5px)`,\n            }\n          : shape === 'outline'\n            ? { borderColor: color }\n            : shape === 'hatched'\n              ? { backgroundImage: chartHatchFill(color) }\n              : { backgroundColor: color }\n      }\n    />\n  )\n}\n\ninterface ChartPanelLegendItem {\n  color: string\n  label: string\n  shape?: ChartPanelKeyShape\n}\n\ninterface ChartPanelLegendProps {\n  className?: string\n  items: ChartPanelLegendItem[]\n}\n\nfunction ChartPanelLegend({ className, items }: ChartPanelLegendProps) {\n  const state = useBlockState()\n  if (state === 'empty' || state === 'error') return null\n\n  return (\n    <ul\n      className={cn(\n        'text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 text-xs',\n        className,\n      )}\n    >\n      {items.map((item) => (\n        <li key={item.label} className='flex items-center gap-1.5'>\n          <ChartPanelKey color={item.color} shape={item.shape} />\n          {item.label}\n        </li>\n      ))}\n    </ul>\n  )\n}\n\ninterface ChartPanelTableColumn {\n  format?: ChartValueFormatter\n  key: string\n  label: string\n}\n\ninterface ChartPanelTableProps<T extends object> {\n  caption: string\n  columns: ChartPanelTableColumn[]\n  rows: T[]\n}\n\nfunction ChartPanelTable<T extends object>({\n  caption,\n  columns,\n  rows,\n}: ChartPanelTableProps<T>) {\n  const state = useBlockState()\n  if (state) return null\n\n  return (\n    <div className='sr-only'>\n      <DataTable caption={caption} scroll={false}>\n        <DataTableHeader>\n          <DataTableRow>\n            {columns.map((column) => (\n              <DataTableHead key={column.key}>{column.label}</DataTableHead>\n            ))}\n          </DataTableRow>\n        </DataTableHeader>\n        <DataTableBody>\n          {rows.map((row, rowIndex) => (\n            <DataTableRow key={rowIndex}>\n              {columns.map((column, columnIndex) => {\n                const value = (row as Record<string, unknown>)[column.key]\n                const content =\n                  column.format && typeof value === 'number'\n                    ? column.format(value)\n                    : String(value)\n                return columnIndex === 0 ? (\n                  <DataTableRowHead key={column.key}>{content}</DataTableRowHead>\n                ) : (\n                  <DataTableCell key={column.key}>{content}</DataTableCell>\n                )\n              })}\n            </DataTableRow>\n          ))}\n        </DataTableBody>\n      </DataTable>\n    </div>\n  )\n}\n\ninterface ChartPanelFigureProps {\n  children: ReactNode\n  className?: string\n}\n\nfunction ChartPanelFigure({ children, className }: ChartPanelFigureProps) {\n  const state = useBlockState()\n\n  return (\n    <div\n      className={cn('w-full tabular-nums [&_.recharts-tooltip-wrapper]:z-10', className)}\n    >\n      {state ? <ChartPlaceholder height='100%' /> : children}\n    </div>\n  )\n}\n\nexport { ChartPanelFigure, ChartPanelKey, ChartPanelLegend, ChartPanelTable }\n\nexport type { ChartPanelKeyShape, ChartPanelLegendItem, ChartPanelTableColumn }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/chart-panel.tsx"
    }
  ],
  "type": "registry:component"
}
