{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pagination-10",
  "title": "Table footer",
  "description": "Rows per page, the visible row range and arrows to the first and last page.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/label.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/pagination.json",
    "https://ui.ndekocode.dev/r/select.json",
    "https://ui.ndekocode.dev/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/pagination/pagination-10.tsx",
      "content": "'use client';\n\nimport { useId, useState } from 'react';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport {\n  ChevronFirstIcon,\n  ChevronLastIcon,\n  ChevronLeftIcon,\n  ChevronRightIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { Label } from '@/registry/ndeko/ui/label';\nimport {\n  Pagination,\n  PaginationContent,\n  PaginationItem,\n  PaginationLink,\n} from '@/registry/ndeko/ui/pagination';\nimport {\n  Select,\n  SelectContent,\n  SelectItem,\n  SelectTrigger,\n  SelectValue,\n} from '@/registry/ndeko/ui/select';\n\nconst FIRST_PAGE = 1;\nconst TOTAL_ROWS = 100;\n\nconst ROWS_PER_PAGE = [\n  { value: 10, label: '10' },\n  { value: 25, label: '25' },\n  { value: 50, label: '50' },\n  { value: 100, label: '100' },\n];\n\nfunction hrefOf(page: number) {\n  return `#/page/${page}`;\n}\n\nfunction rangeOf(page: number, rowsPerPage: number) {\n  const pagesBefore = page - 1;\n  const rowsBefore = pagesBefore * rowsPerPage;\n  const firstRow = rowsBefore + 1;\n  const lastRowOfPage = page * rowsPerPage;\n  const lastRow = Math.min(TOTAL_ROWS, lastRowOfPage);\n  return { firstRow, lastRow };\n}\n\nexport default function Pagination10() {\n  const id = useId();\n  const [rowsPerPage, setRowsPerPage] = useState(25);\n  const [page, setPage] = useState(FIRST_PAGE);\n  const totalPages = Math.ceil(TOTAL_ROWS / rowsPerPage);\n  const range = rangeOf(page, rowsPerPage);\n  const rangeLabel = `${range.firstRow}-${range.lastRow}`;\n  const previousPage = page - 1;\n  const nextPage = page + 1;\n  const isFirstPage = page === FIRST_PAGE;\n  const isLastPage = page === totalPages;\n\n  function showPage(target: number) {\n    const atLeastFirst = Math.max(FIRST_PAGE, target);\n    const nextCurrent = Math.min(totalPages, atLeastFirst);\n    setPage(nextCurrent);\n  }\n\n  function goToPage(\n    event: React.MouseEvent<HTMLAnchorElement>,\n    target: number\n  ) {\n    event.preventDefault();\n    showPage(target);\n  }\n\n  function changeRowsPerPage(rows: number | null) {\n    if (rows === null) {\n      return;\n    }\n    setRowsPerPage(rows);\n    showPage(FIRST_PAGE);\n  }\n\n  return (\n    <div className='flex flex-wrap items-center justify-between gap-x-8 gap-y-3'>\n      <div className='flex items-center gap-3'>\n        <Label htmlFor={id} className='whitespace-nowrap'>\n          Rows per page\n        </Label>\n        <Select\n          items={ROWS_PER_PAGE}\n          value={rowsPerPage}\n          onValueChange={changeRowsPerPage}\n        >\n          <SelectTrigger id={id} className='w-fit whitespace-nowrap'>\n            <SelectValue />\n          </SelectTrigger>\n          <SelectContent>\n            {ROWS_PER_PAGE.map((option) => (\n              <SelectItem key={option.value} value={option.value}>\n                {option.label}\n              </SelectItem>\n            ))}\n          </SelectContent>\n        </Select>\n      </div>\n      <p\n        className='text-muted-foreground flex grow justify-end text-[13px] whitespace-nowrap tabular-nums'\n        aria-live='polite'\n      >\n        <span className='sr-only'>\n          Rows {rangeLabel} of {TOTAL_ROWS}\n        </span>\n        <span className='inline-flex items-baseline' aria-hidden='true'>\n          <span className='text-foreground inline-flex items-baseline'>\n            <MotionNumber value={range.firstRow} />\n            -\n            <MotionNumber value={range.lastRow} />\n          </span>\n          &nbsp;of&nbsp;\n          <span className='text-foreground'>{TOTAL_ROWS}</span>\n        </span>\n      </p>\n      <Pagination className='mx-0 w-auto'>\n        <PaginationContent>\n          <PaginationItem>\n            <PaginationLink\n              href={hrefOf(FIRST_PAGE)}\n              aria-label='Go to first page'\n              isDisabled={isFirstPage}\n              onClick={(event) => goToPage(event, FIRST_PAGE)}\n              className='rounded-full'\n            >\n              <ChevronFirstIcon />\n            </PaginationLink>\n          </PaginationItem>\n          <PaginationItem>\n            <PaginationLink\n              href={hrefOf(previousPage)}\n              aria-label='Go to previous page'\n              isDisabled={isFirstPage}\n              onClick={(event) => goToPage(event, previousPage)}\n              className='rounded-full'\n            >\n              <ChevronLeftIcon />\n            </PaginationLink>\n          </PaginationItem>\n          <PaginationItem>\n            <PaginationLink\n              href={hrefOf(nextPage)}\n              aria-label='Go to next page'\n              isDisabled={isLastPage}\n              onClick={(event) => goToPage(event, nextPage)}\n              className='rounded-full'\n            >\n              <ChevronRightIcon />\n            </PaginationLink>\n          </PaginationItem>\n          <PaginationItem>\n            <PaginationLink\n              href={hrefOf(totalPages)}\n              aria-label='Go to last page'\n              isDisabled={isLastPage}\n              onClick={(event) => goToPage(event, totalPages)}\n              className='rounded-full'\n            >\n              <ChevronLastIcon />\n            </PaginationLink>\n          </PaginationItem>\n        </PaginationContent>\n      </Pagination>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "pagination"
  ],
  "type": "registry:component"
}