{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "table-demo-sort",
  "registryDependencies": [
    "https://ui-three-mu.vercel.app/r/table.json"
  ],
  "files": [
    {
      "path": "registry/preskok/examples/table-demo-sort.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport type { SortDescriptor } from \"react-aria-components/Table\"\n\nimport {\n  Table,\n  TableBody,\n  TableCell,\n  TableColumn,\n  TableHeader,\n  TableRow,\n} from \"@/components/ui/preskok-ui/table\"\n\nconst rows = [\n  {\n    id: 1,\n    account: \"Acme Labs\",\n    owner: \"Maya Chen\",\n    value: 84_000,\n    stage: \"Renewal\",\n  },\n  {\n    id: 2,\n    account: \"Northstar Health\",\n    owner: \"Noah Reed\",\n    value: 128_000,\n    stage: \"Security review\",\n  },\n  {\n    id: 3,\n    account: \"Riverbank Studio\",\n    owner: \"Iris Patel\",\n    value: 42_500,\n    stage: \"Negotiation\",\n  },\n  {\n    id: 4,\n    account: \"Vertex Freight\",\n    owner: \"Sam Ortiz\",\n    value: 96_200,\n    stage: \"Proposal\",\n  },\n  {\n    id: 5,\n    account: \"Bluefield Energy\",\n    owner: \"Lena Park\",\n    value: 152_400,\n    stage: \"Legal\",\n  },\n  {\n    id: 6,\n    account: \"Kite Systems\",\n    owner: \"Owen Brooks\",\n    value: 31_900,\n    stage: \"Discovery\",\n  },\n  {\n    id: 7,\n    account: \"Summit Foods\",\n    owner: \"Ava Stone\",\n    value: 77_300,\n    stage: \"Procurement\",\n  },\n  {\n    id: 8,\n    account: \"Harbor Finance\",\n    owner: \"Theo Miles\",\n    value: 118_600,\n    stage: \"Contracting\",\n  },\n]\n\ntype Row = (typeof rows)[number]\n\nexport function TableDemoSort() {\n  const [sortDescriptor, setSortDescriptor] = useState<SortDescriptor>({\n    column: \"account\",\n    direction: \"ascending\",\n  })\n\n  let sortedRows = rows\n  if (sortDescriptor) {\n    sortedRows = rows.toSorted((a, b) => {\n      const column = sortDescriptor.column as keyof Row\n      const first = a[column]\n      const second = b[column]\n      let cmp = first < second ? -1 : 1\n      if (sortDescriptor.direction === \"descending\") {\n        cmp = -cmp\n      }\n      return cmp\n    })\n  }\n\n  return (\n    <div className=\"w-full max-w-4xl overflow-hidden rounded-xl border bg-background p-4 shadow-sm\">\n      <Table\n        aria-label=\"Sales pipeline\"\n        sortDescriptor={sortDescriptor}\n        onSortChange={setSortDescriptor}\n      >\n        <TableHeader>\n          <TableColumn id=\"id\" allowsSorting>\n            ID\n          </TableColumn>\n          <TableColumn id=\"account\" isRowHeader allowsSorting>\n            Account\n          </TableColumn>\n          <TableColumn id=\"owner\" allowsSorting>\n            Owner\n          </TableColumn>\n          <TableColumn id=\"value\" allowsSorting>\n            Value\n          </TableColumn>\n          <TableColumn id=\"stage\" allowsSorting>\n            Stage\n          </TableColumn>\n        </TableHeader>\n        <TableBody items={sortedRows}>\n          {(item) => (\n            <TableRow id={item.id}>\n              <TableCell className=\"tabular-nums\">{item.id}</TableCell>\n              <TableCell>{item.account}</TableCell>\n              <TableCell>{item.owner}</TableCell>\n              <TableCell className=\"tabular-nums\">\n                ${item.value.toLocaleString()}\n              </TableCell>\n              <TableCell>{item.stage}</TableCell>\n            </TableRow>\n          )}\n        </TableBody>\n      </Table>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}