{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lists-08",
  "type": "registry:block",
  "description": "Sortable package list with clickable column headers and download bars.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/designali/blocks/lists/lists-08.tsx",
      "content": "\"use client\"\n\nimport { useMemo, useState } from \"react\"\nimport {\n  ArrowDown,\n  ArrowUp,\n  ArrowUpDown,\n} from \"@designali/icons\"\n\nconst packages = [\n  { name: \"@designali/icons\", version: \"4.2.1\", size: 18.4, downloads: 1_240_000, updated: 2 },\n  { name: \"@designali/logos\", version: \"4.2.0\", size: 9.1, downloads: 980_400, updated: 5 },\n  { name: \"@designali/vectors\", version: \"2.8.3\", size: 142.6, downloads: 612_900, updated: 12 },\n  { name: \"designali/marquee\", version: \"1.4.0\", size: 22.7, downloads: 301_250, updated: 1 },\n  { name: \"designali/number-counter\", version: \"3.0.5\", size: 14.2, downloads: 288_700, updated: 21 },\n  { name: \"designali/gauge\", version: \"0.9.2\", size: 64.0, downloads: 97_430, updated: 34 },\n  { name: \"designali/dot-pattern\", version: \"2.1.7\", size: 3.8, downloads: 54_100, updated: 9 },\n]\n\ntype Key = \"name\" | \"size\" | \"downloads\" | \"updated\"\n\nconst columns: { key: Key; label: string; align: string }[] = [\n  { key: \"name\", label: \"Package\", align: \"text-left\" },\n  { key: \"size\", label: \"Size\", align: \"text-right\" },\n  { key: \"downloads\", label: \"Weekly\", align: \"text-right\" },\n  { key: \"updated\", label: \"Updated\", align: \"text-right\" },\n]\n\nfunction compact(n: number) {\n  return n >= 1_000_000 ? `${(n / 1_000_000).toFixed(2)}M` : `${(n / 1000).toFixed(1)}k`\n}\n\nexport default function Lists08() {\n  const [sort, setSort] = useState<{ key: Key; dir: \"asc\" | \"desc\" }>({ key: \"downloads\", dir: \"desc\" })\n\n  const rows = useMemo(() => {\n    const sorted = [...packages].sort((a, b) => {\n      const av = a[sort.key]\n      const bv = b[sort.key]\n      const result = typeof av === \"string\" ? av.localeCompare(bv as string) : av - (bv as number)\n      return sort.dir === \"asc\" ? result : -result\n    })\n    return sorted\n  }, [sort])\n\n  const onSort = (key: Key) =>\n    setSort((current) =>\n      current.key === key ? { key, dir: current.dir === \"asc\" ? \"desc\" : \"asc\" } : { key, dir: key === \"name\" ? \"asc\" : \"desc\" }\n    )\n\n  const maxDownloads = Math.max(...packages.map((p) => p.downloads))\n\n  return (\n    <section className=\"w-full bg-background py-24\">\n      <div className=\"mx-auto max-w-4xl px-6\">\n        <h2 className=\"text-3xl font-semibold tracking-tight\">Packages</h2>\n        <p className=\"mt-2 text-sm text-muted-foreground\">\n          Designali packages and components, all in one monorepo. Sort by any column.\n        </p>\n\n        <div className=\"mt-8 border border-border\">\n          <div className=\"grid grid-cols-[1fr_auto_auto] gap-4 border-b border-border bg-muted/50 px-4 py-2 sm:grid-cols-[1fr_80px_120px_90px]\">\n            {columns.map((column) => {\n              const active = sort.key === column.key\n              const Icon = !active ? ArrowUpDown : sort.dir === \"asc\" ? ArrowUp : ArrowDown\n              return (\n                <button\n                  key={column.key}\n                  type=\"button\"\n                  onClick={() => onSort(column.key)}\n                  className={`inline-flex items-center gap-1 text-xs font-medium ${column.align === \"text-right\" ? \"justify-end\" : \"\"} ${\n                    active ? \"text-foreground\" : \"text-muted-foreground hover:text-foreground\"\n                  } ${column.key === \"size\" ? \"hidden sm:inline-flex\" : \"\"}`}\n                >\n                  {column.label}\n                  <Icon className=\"size-3\" />\n                </button>\n              )\n            })}\n          </div>\n          <ul className=\"divide-y divide-border\">\n            {rows.map((pkg) => (\n              <li\n                key={pkg.name}\n                className=\"grid grid-cols-[1fr_auto_auto] items-center gap-4 px-4 py-3.5 hover:bg-muted/40 sm:grid-cols-[1fr_80px_120px_90px]\"\n              >\n                <div className=\"min-w-0\">\n                  <p className=\"truncate font-sans text-sm\">{pkg.name}</p>\n                  <p className=\"text-xs text-muted-foreground\">v{pkg.version}</p>\n                </div>\n                <span className=\"hidden text-right font-sans text-xs text-muted-foreground sm:block\">{pkg.size} kB</span>\n                <div className=\"flex items-center justify-end gap-2\">\n                  <div className=\"hidden h-1 w-12 bg-muted sm:block\">\n                    <div className=\"h-full bg-foreground\" style={{ width: `${(pkg.downloads / maxDownloads) * 100}%` }} />\n                  </div>\n                  <span className=\"font-sans text-xs\">{compact(pkg.downloads)}</span>\n                </div>\n                <span className=\"text-right font-sans text-xs text-muted-foreground\">{pkg.updated}d ago</span>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "650px"
  },
  "categories": [
    "lists"
  ]
}