{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dashboard-table",
  "title": "Dashboard table",
  "description": "The counts of one dashboard widget as an accessible table with a total row and the word for how each count was disclosed.",
  "dependencies": [
    "@registrystack/app-runtime@~0.43.0-next.0"
  ],
  "registryDependencies": [
    "@registrystack/dashboard-cells",
    "@registrystack/dashboard-content",
    "@registrystack/lib-content",
    "@registrystack/lib-format",
    "@registrystack/lib-scroll-region"
  ],
  "files": [
    {
      "path": "dashboard/dashboard-table.tsx",
      "content": "import type {\n  DashboardCell,\n  DashboardWidgetResult,\n  DashboardWidgetView,\n} from \"@registrystack/app-runtime\";\nimport { ScrollRegion } from \"@/blocks/lib/scroll-region\";\nimport { fill } from \"@/blocks/lib/format\";\nimport { DashboardCellLink } from \"@/blocks/dashboard/dashboard-cell-link\";\nimport { useDashboardContent } from \"@/blocks/dashboard/dashboard-content\";\nimport { useLocale } from \"@/blocks/lib/content\";\nimport {\n  disclosedValue,\n  minimumCountOf,\n  statusLabel,\n} from \"@/blocks/dashboard/dashboard-values\";\n\n/**\n * The counts of a ready result as an accessible table: one row per category\n * and a total row, each with the count as BReg disclosed it and the word for\n * that disclosure. A chart carries this table as its text equivalent.\n */\nexport function DashboardTable({\n  widget,\n  result,\n}: {\n  widget: DashboardWidgetView;\n  result: DashboardWidgetResult;\n}) {\n  const c = useDashboardContent(),\n    locale = useLocale();\n  const minimum = minimumCountOf(result.context);\n  const rows: { cell: DashboardCell; label: string; total?: true }[] = [\n    ...(result.rows ?? []).map((cell) => ({\n      cell,\n      label: cell.label ?? cell.code ?? \"\",\n    })),\n    ...(result.total\n      ? [{ cell: result.total, label: c.total, total: true as const }]\n      : []),\n  ];\n  const caption = fill(\n    widget.unit ? c.tableCaption : c.tableCaptionWithoutUnit,\n    { widget: widget.title, unit: widget.unit ?? \"\", period: result.period },\n    locale,\n  );\n  return (\n    <>\n      <ScrollRegion className=\"dashboard-table-scroll\" label={caption}>\n        <table className=\"dashboard-table\">\n          <caption>{caption}</caption>\n          <thead>\n            <tr>\n              <th scope=\"col\">{c.category}</th>\n              <th scope=\"col\">{c.count}</th>\n              <th scope=\"col\">{c.status}</th>\n            </tr>\n          </thead>\n          <tbody>\n            {rows.map(({ cell, label, total }) => (\n              <tr\n                key={cell.code}\n                className={total ? \"dashboard-total\" : undefined}\n              >\n                <th scope=\"row\">{label}</th>\n                <td>\n                  <DashboardCellLink\n                    cell={cell}\n                    label={label}\n                    value={disclosedValue(c, locale, cell, minimum)}\n                    period={result.period}\n                  />\n                </td>\n                <td>{statusLabel(c, cell.status)}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </ScrollRegion>\n      {result.subset && <p className=\"dashboard-note\">{c.subsetNote}</p>}\n    </>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/dashboard/dashboard-table.tsx"
    }
  ],
  "type": "registry:block"
}