{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pagination",
  "title": "Pagination",
  "description": "Page links with previous and next, an ellipsis, and a helper that works out which page numbers to show.",
  "dependencies": [
    "@radix-ui/react-slot",
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "@corsair-ui/utils",
    "@corsair-ui/button"
  ],
  "files": [
    {
      "path": "registry/default/ui/pagination.tsx",
      "content": "import { Slot, Slottable } from \"@radix-ui/react-slot\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"@/registry/default/lib/utils\";\nimport { buttonVariants } from \"@/registry/default/ui/button\";\n/**\n * Links to the pages of a long list: search results, a blog archive, a\n * table. It is a `<nav>` landmark named \"Pagination\" (change it with\n * `aria-label`) around a list of links, so Tab moves through them and Enter\n * follows one. The current page is announced with `aria-current=\"page\"`.\n * Use `getPaginationRange` to work out which numbers to show. On the first\n * or last page, leave `href` off Previous / Next and pass `aria-disabled`,\n * which dims them and takes them out of the Tab order. Nothing animates.\n *\n * @example\n * <Pagination>\n *   <PaginationContent>\n *     <PaginationItem>\n *       <PaginationPrevious href={`?page=${page - 1}`} />\n *     </PaginationItem>\n *     {getPaginationRange({ page, pageCount }).map((entry, index) => (\n *       <PaginationItem key={entry === \"ellipsis\" ? `ellipsis-${index}` : entry}>\n *         {entry === \"ellipsis\" ? (\n *           <PaginationEllipsis />\n *         ) : (\n *           <PaginationLink href={`?page=${entry}`} isActive={entry === page}>\n *             {entry}\n *           </PaginationLink>\n *         )}\n *       </PaginationItem>\n *     ))}\n *     <PaginationItem>\n *       <PaginationNext href={`?page=${page + 1}`} />\n *     </PaginationItem>\n *   </PaginationContent>\n * </Pagination>\n */\nfunction Pagination({\n  className,\n  \"aria-label\": label = \"Pagination\",\n  ...props\n}: ComponentProps<\"nav\">) {\n  return (\n    <nav\n      data-slot=\"pagination\"\n      aria-label={label}\n      className={cn(\"mx-auto flex w-full justify-center\", className)}\n      {...props}\n    />\n  );\n}\nfunction PaginationContent({ className, ...props }: ComponentProps<\"ul\">) {\n  return (\n    <ul\n      data-slot=\"pagination-content\"\n      className={cn(\"flex flex-row flex-wrap items-center justify-center gap-1\", className)}\n      {...props}\n    />\n  );\n}\nfunction PaginationItem(props: ComponentProps<\"li\">) {\n  return <li data-slot=\"pagination-item\" {...props} />;\n}\ninterface PaginationLinkProps\n  extends ComponentProps<\"a\">, Pick<VariantProps<typeof buttonVariants>, \"size\"> {\n  /** Marks the link as the current page: `aria-current=\"page\"`, `data-active` and the outline style. */\n  isActive?: boolean;\n  /** Render the single child (next/link, a router Link) with the link styles instead. */\n  asChild?: boolean;\n}\n/** A link to one page, styled as a square button. Pass `asChild` to use your framework's link component. */\nfunction PaginationLink({\n  className,\n  isActive = false,\n  size = \"icon\",\n  asChild = false,\n  ...props\n}: PaginationLinkProps) {\n  const Comp = asChild ? Slot : \"a\";\n  // \"outline\" is the button variant name, not the Tailwind utility.\n  // tailwind-compat-ignore-next-line\n  const variant = isActive ? \"outline\" : \"ghost\";\n  return (\n    <Comp\n      data-slot=\"pagination-link\"\n      data-active={isActive}\n      aria-current={isActive ? \"page\" : undefined}\n      className={cn(buttonVariants({ variant, size }), className)}\n      {...props}\n    />\n  );\n}\ninterface PaginationStepProps extends Omit<PaginationLinkProps, \"isActive\"> {\n  /** Visible text next to the arrow, hidden below the `sm` breakpoint. */\n  label?: string;\n}\n/**\n * Link to the previous page. Its accessible name is \"Go to previous page\"\n * (change it with `aria-label`); `label` is the visible text, shown from\n * `sm` up. With `asChild`, the arrow and text go inside your link component.\n */\nfunction PaginationPrevious({\n  label = \"Previous\",\n  \"aria-label\": ariaLabel = \"Go to previous page\",\n  className,\n  children,\n  ...props\n}: PaginationStepProps) {\n  return (\n    <PaginationLink\n      data-slot=\"pagination-previous\"\n      aria-label={ariaLabel}\n      size=\"default\"\n      className={cn(\"gap-1 px-2.5 sm:pl-2.5\", className)}\n      {...props}\n    >\n      <ChevronLeftIcon aria-hidden=\"true\" />\n      <Slottable>{children}</Slottable>\n      <span className=\"hidden sm:block\">{label}</span>\n    </PaginationLink>\n  );\n}\n/**\n * Link to the next page. Its accessible name is \"Go to next page\" (change\n * it with `aria-label`); `label` is the visible text, shown from `sm` up.\n * With `asChild`, the text and arrow go inside your link component.\n */\nfunction PaginationNext({\n  label = \"Next\",\n  \"aria-label\": ariaLabel = \"Go to next page\",\n  className,\n  children,\n  ...props\n}: PaginationStepProps) {\n  return (\n    <PaginationLink\n      data-slot=\"pagination-next\"\n      aria-label={ariaLabel}\n      size=\"default\"\n      className={cn(\"gap-1 px-2.5 sm:pr-2.5\", className)}\n      {...props}\n    >\n      <span className=\"hidden sm:block\">{label}</span>\n      <Slottable>{children}</Slottable>\n      <ChevronRightIcon aria-hidden=\"true\" />\n    </PaginationLink>\n  );\n}\ninterface PaginationEllipsisProps extends ComponentProps<\"span\"> {\n  /** Text for screen readers in place of the dots. */\n  label?: string;\n}\n/** Stands in for the page numbers that are left out. The dots are hidden; `label` is read instead. */\nfunction PaginationEllipsis({\n  label = \"More pages\",\n  className,\n  ...props\n}: PaginationEllipsisProps) {\n  return (\n    <span\n      data-slot=\"pagination-ellipsis\"\n      className={cn(\"flex size-9 items-center justify-center\", className)}\n      {...props}\n    >\n      <MoreHorizontalIcon aria-hidden=\"true\" className=\"size-4\" />\n      <span className=\"sr-only\">{label}</span>\n    </span>\n  );\n}\ninterface PaginationRangeOptions {\n  /** The current page, starting at 1. Clamped to 1 … `pageCount`. */\n  page: number;\n  /** How many pages there are. */\n  pageCount: number;\n  /** Pages shown on each side of the current one. */\n  siblings?: number;\n  /** Pages always shown at the start and at the end. */\n  boundaries?: number;\n}\nfunction range(start: number, end: number) {\n  return Array.from({ length: Math.max(0, end - start + 1) }, (_, index) => start + index);\n}\n/**\n * Works out which page numbers to render: the first and last `boundaries`\n * pages, `siblings` pages either side of the current one, and \"ellipsis\"\n * where pages are left out. An ellipsis only replaces two or more pages, and\n * the result has the same length wherever the current page is, so the\n * links do not shift as you move through them.\n *\n * @example\n * getPaginationRange({ page: 5, pageCount: 10 });\n * // [1, \"ellipsis\", 4, 5, 6, \"ellipsis\", 10]\n */\nfunction getPaginationRange({\n  page,\n  pageCount,\n  siblings = 1,\n  boundaries = 1,\n}: PaginationRangeOptions): (number | \"ellipsis\")[] {\n  const total = Math.max(0, Math.floor(pageCount));\n  if (total === 0) return [];\n  const around = Math.max(0, Math.floor(siblings));\n  const edges = Math.max(0, Math.floor(boundaries));\n  const current = Math.min(total, Math.max(1, Math.floor(page)));\n  // Edges, siblings, the current page and room for two ellipses.\n  const slots = around * 2 + 3 + edges * 2;\n  if (slots >= total) return range(1, total);\n  const left = Math.max(current - around, edges);\n  const right = Math.min(current + around, total - edges);\n  const leftGap = left > edges + 2;\n  const rightGap = right < total - (edges + 1);\n  if (!leftGap && rightGap) {\n    return [...range(1, around * 2 + edges + 2), \"ellipsis\", ...range(total - edges + 1, total)];\n  }\n  if (leftGap && !rightGap) {\n    return [...range(1, edges), \"ellipsis\", ...range(total - (edges + 1 + around * 2), total)];\n  }\n  return [\n    ...range(1, edges),\n    \"ellipsis\",\n    ...range(left, right),\n    \"ellipsis\",\n    ...range(total - edges + 1, total),\n  ];\n}\nexport {\n  getPaginationRange,\n  Pagination,\n  PaginationContent,\n  PaginationEllipsis,\n  PaginationItem,\n  PaginationLink,\n  PaginationNext,\n  PaginationPrevious,\n  type PaginationEllipsisProps,\n  type PaginationLinkProps,\n  type PaginationRangeOptions,\n  type PaginationStepProps,\n};\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}