{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pagination",
  "type": "registry:ui",
  "title": "Pagination",
  "description": "Pagination is a paged navigation control with Previous/Next boundaries, numbered pages, and optional ellipsis.",
  "author": "Skrewww",
  "dependencies": [],
  "registryDependencies": [
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/Pagination.tsx",
      "content": "/** @skrewww-component pagination */\nimport { cn } from \"@/lib/cn\";\nimport { RouterAnchor } from \"@/components/ui/router-navigation\";\nimport { getLinkRel, shouldUseNativeAnchor } from \"@/components/ui/internal/link-utils\";\nimport styles from \"@/components/ui/pagination.module.css\";\n\nexport type PaginationItem =\n  | { type: \"page\"; page: number; href?: string; current?: boolean; disabled?: boolean }\n  | { type: \"ellipsis\" }\n  | { type: \"previous\"; href?: string; disabled?: boolean; label?: string; page?: number }\n  | { type: \"next\"; href?: string; disabled?: boolean; label?: string; page?: number };\n\nexport type PaginationProps = {\n  items: PaginationItem[];\n  className?: string;\n  onPageChange?: (page: number) => void;\n  \"aria-label\"?: string;\n};\n\nfunction PageControl({\n  page,\n  href,\n  current = false,\n  disabled = false,\n  onPageChange,\n}: {\n  page: number;\n  href?: string;\n  current?: boolean;\n  disabled?: boolean;\n  onPageChange?: (page: number) => void;\n}) {\n  const label = `Page ${page}`;\n  const className = cn(\n    styles.control,\n    styles.pageItem,\n    current && styles.current,\n    disabled && styles.disabled,\n  );\n\n  if (disabled) {\n    return (\n      <span className={className} aria-disabled=\"true\" aria-label={label}>\n        {page}\n      </span>\n    );\n  }\n\n  if (current) {\n    return (\n      <span className={className} aria-current=\"page\" aria-label={label}>\n        {page}\n      </span>\n    );\n  }\n\n  if (href) {\n    const external = shouldUseNativeAnchor(href);\n    if (external) {\n      return (\n        <a href={href} className={className} aria-label={label}>\n          {page}\n        </a>\n      );\n    }\n    return (\n      <RouterAnchor href={href} className={className} aria-label={label}>\n        {page}\n      </RouterAnchor>\n    );\n  }\n\n  return (\n    <button\n      type=\"button\"\n      className={className}\n      aria-label={label}\n      onClick={() => onPageChange?.(page)}\n    >\n      {page}\n    </button>\n  );\n}\n\nfunction BoundaryControl({\n  kind,\n  href,\n  disabled = false,\n  label,\n  onPageChange,\n  page,\n}: {\n  kind: \"previous\" | \"next\";\n  href?: string;\n  disabled?: boolean;\n  label: string;\n  onPageChange?: (page: number) => void;\n  page?: number;\n}) {\n  const className = cn(styles.control, styles.boundary, disabled && styles.disabled);\n\n  if (disabled) {\n    return (\n      <span className={className} aria-disabled=\"true\" aria-label={label}>\n        {kind === \"previous\" ? \"Previous\" : \"Next\"}\n      </span>\n    );\n  }\n\n  if (href) {\n    const external = shouldUseNativeAnchor(href);\n    if (external) {\n      return (\n        <a href={href} className={className} aria-label={label} rel={getLinkRel()}>\n          {kind === \"previous\" ? \"Previous\" : \"Next\"}\n        </a>\n      );\n    }\n    return (\n      <RouterAnchor href={href} className={className} aria-label={label}>\n        {kind === \"previous\" ? \"Previous\" : \"Next\"}\n      </RouterAnchor>\n    );\n  }\n\n  return (\n    <button\n      type=\"button\"\n      className={className}\n      aria-label={label}\n      onClick={() => {\n        if (typeof page === \"number\") onPageChange?.(page);\n      }}\n    >\n      {kind === \"previous\" ? \"Previous\" : \"Next\"}\n    </button>\n  );\n}\n\nexport function Pagination({\n  items,\n  className,\n  onPageChange,\n  \"aria-label\": ariaLabel = \"Pagination\",\n}: PaginationProps) {\n  return (\n    <nav aria-label={ariaLabel} className={cn(styles.root, className)}>\n      <ul className={styles.list}>\n        {items.map((item, index) => (\n          <li key={`${item.type}-${index}`} className={styles.item}>\n            {item.type === \"page\" ? (\n              <PageControl\n                page={item.page}\n                href={item.href}\n                current={item.current}\n                disabled={item.disabled}\n                onPageChange={onPageChange}\n              />\n            ) : null}\n            {item.type === \"ellipsis\" ? (\n              <span className={styles.ellipsis} aria-hidden=\"true\">\n                …\n                <span className=\"sr-only\">More pages</span>\n              </span>\n            ) : null}\n            {item.type === \"previous\" ? (\n              <BoundaryControl\n                kind=\"previous\"\n                href={item.href}\n                disabled={item.disabled}\n                label={item.label ?? \"Previous page\"}\n                onPageChange={onPageChange}\n                page={item.page}\n              />\n            ) : null}\n            {item.type === \"next\" ? (\n              <BoundaryControl\n                kind=\"next\"\n                href={item.href}\n                disabled={item.disabled}\n                label={item.label ?? \"Next page\"}\n                onPageChange={onPageChange}\n                page={item.page}\n              />\n            ) : null}\n          </li>\n        ))}\n      </ul>\n    </nav>\n  );\n}\n\nexport function buildPaginationRange(options: {\n  currentPage: number;\n  totalPages: number;\n  siblingCount?: number;\n  boundaryCount?: number;\n}): number[] {\n  const { currentPage, totalPages, siblingCount = 1, boundaryCount = 1 } = options;\n  const pages = new Set<number>();\n\n  for (let page = 1; page <= Math.min(boundaryCount, totalPages); page += 1) {\n    pages.add(page);\n  }\n  for (\n    let page = Math.max(1, currentPage - siblingCount);\n    page <= Math.min(totalPages, currentPage + siblingCount);\n    page += 1\n  ) {\n    pages.add(page);\n  }\n  for (let page = Math.max(1, totalPages - boundaryCount + 1); page <= totalPages; page += 1) {\n    pages.add(page);\n  }\n\n  return Array.from(pages).sort((a, b) => a - b);\n}\n\nexport function buildPaginationItems(options: {\n  currentPage: number;\n  totalPages: number;\n  hrefBuilder?: (page: number) => string | undefined;\n  siblingCount?: number;\n  boundaryCount?: number;\n}): PaginationItem[] {\n  const { currentPage, totalPages, hrefBuilder, siblingCount = 1, boundaryCount = 1 } = options;\n  const items: PaginationItem[] = [\n    {\n      type: \"previous\",\n      href: currentPage > 1 ? hrefBuilder?.(currentPage - 1) : undefined,\n      disabled: currentPage <= 1,\n      label: \"Previous page\",\n      page: currentPage - 1,\n    },\n  ];\n\n  const pages = buildPaginationRange({ currentPage, totalPages, siblingCount, boundaryCount });\n  pages.forEach((page, index) => {\n    const previous = pages[index - 1];\n    if (previous !== undefined && page - previous > 1) {\n      items.push({ type: \"ellipsis\" });\n    }\n    items.push({\n      type: \"page\",\n      page,\n      current: page === currentPage,\n      href: hrefBuilder?.(page),\n    });\n  });\n\n  items.push({\n    type: \"next\",\n    href: currentPage < totalPages ? hrefBuilder?.(currentPage + 1) : undefined,\n    disabled: currentPage >= totalPages,\n    label: \"Next page\",\n    page: currentPage + 1,\n  });\n\n  return items;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/Pagination.tsx"
    },
    {
      "path": "components/ui/pagination.module.css",
      "content": ".root {\n  width: 100%;\n}\n\n.list {\n  display: flex;\n  flex-wrap: wrap;\n  align-items: center;\n  gap: var(--pagination-gap);\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n\n.item {\n  display: inline-flex;\n}\n\n.control {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  box-sizing: border-box;\n  font-variant-numeric: tabular-nums;\n  text-decoration: none;\n  cursor: pointer;\n}\n\n.pageItem {\n  flex: 0 0 var(--pagination-control-size);\n  width: var(--pagination-control-size);\n  height: var(--pagination-control-size);\n  padding: 0;\n  border: 0;\n  border-radius: var(--pagination-page-radius);\n  background: transparent;\n  color: var(--pagination-page-content);\n  font-size: var(--pagination-font-size);\n  font-weight: 400;\n  backdrop-filter: none;\n}\n\n.pageItem:hover:not(.current):not(.disabled) {\n  background: var(--pagination-page-hover-surface);\n  color: var(--pagination-page-hover-content);\n}\n\n.control:focus-visible {\n  outline: 2px solid var(--semantic-focus-ring);\n  outline-offset: 2px;\n}\n\n.current {\n  background-color: var(--pagination-current-surface);\n  background-image: var(--component-surface-gradient-overlay);\n  color: var(--pagination-current-text);\n  font-weight: 700;\n  cursor: default;\n}\n\n.disabled {\n  color: var(--pagination-disabled-text);\n  cursor: not-allowed;\n}\n\n.pageItem.disabled {\n  background: transparent;\n  opacity: var(--opacity-disabled);\n}\n\n.boundary {\n  min-width: 2.25rem;\n  min-height: 2.25rem;\n  padding-inline: 0.75rem;\n  border: 1px solid var(--pagination-border);\n  border-radius: min(var(--shape-radius-control), 9999px);\n  background: var(--semantic-surface-default);\n  color: var(--pagination-text);\n  font-size: 0.875rem;\n  font-weight: 500;\n}\n\n.boundary:hover:not(.disabled) {\n  color: var(--semantic-action-primary);\n  border-color: var(--semantic-action-primary);\n}\n\n.boundary.disabled {\n  border-color: var(--semantic-border-disabled);\n}\n\n.ellipsis {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: var(--pagination-ellipsis-width);\n  height: var(--pagination-control-size);\n  color: var(--pagination-ellipsis-content);\n  font-size: var(--pagination-font-size);\n}\n\n[data-skrewww-surface=\"glass\"] .boundary {\n  background: color-mix(in srgb, var(--semantic-surface-default) var(--glass-mix-sm), white);\n  backdrop-filter: var(--glass-backdrop-filter-sm);\n}\n\n@supports not (backdrop-filter: blur(1px)) {\n  [data-skrewww-surface=\"glass\"] .boundary {\n    background: color-mix(in srgb, var(--semantic-surface-default) var(--glass-mix-sm-fallback), white);\n  }\n}\n\n[data-skrewww-surface=\"glass\"] .pageItem:hover:not(.current):not(.disabled) {\n  background: rgb(255 255 255 / 0.2);\n  backdrop-filter: var(--glass-backdrop-filter-lg);\n}\n\n[data-skrewww-surface=\"glass\"] .ellipsis {\n  color: #17181b;\n}\n\n/* Superseded 2026-08-11: .current now matches the approved Figma Page Item\n   Current contract (component set 2024:2894, Current 2024:2892) — Primary/\n   brand family, not the neutral/elevated treatment. */\n[data-skrewww-surface=\"glass\"] .current {\n  background: var(--component-brand-fill-glass);\n  backdrop-filter: var(--glass-backdrop-filter-lg);\n}\n\n[data-skrewww-shape=\"squircle\"] .pageItem {\n  clip-path: var(--squircle-clip-path-control);\n}\n\n@supports not (backdrop-filter: blur(1px)) {\n  [data-skrewww-surface=\"glass\"] .current {\n    background: var(--semantic-action-primary);\n  }\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/pagination.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    },
    {
      "path": "components/ui/internal/link-utils.ts",
      "content": "/**\n * Framework-neutral link classification helpers.\n * No docs-site / repository configuration imports — origin is either passed\n * explicitly or read from the runtime location when available.\n */\n\nfunction normalizeHref(href: string): string {\n  return href.trim();\n}\n\nfunction resolveDefaultOrigin(): string | undefined {\n  if (typeof globalThis === \"undefined\") return undefined;\n  const locationLike = (globalThis as { location?: { origin?: string } }).location;\n  return locationLike?.origin;\n}\n\nexport function isHashHref(href: string): boolean {\n  return normalizeHref(href).startsWith(\"#\");\n}\n\nexport function isSpecialProtocolHref(href: string): boolean {\n  const value = normalizeHref(href).toLowerCase();\n  return value.startsWith(\"mailto:\") || value.startsWith(\"tel:\");\n}\n\nexport function isExternalHref(href: string, origin: string | undefined = resolveDefaultOrigin()): boolean {\n  const value = normalizeHref(href);\n\n  if (!value || isHashHref(value) || value.startsWith(\"/\") || value.startsWith(\"./\") || value.startsWith(\"../\")) {\n    return false;\n  }\n\n  if (isSpecialProtocolHref(value)) {\n    return true;\n  }\n\n  if (value.startsWith(\"//\")) {\n    return true;\n  }\n\n  if (/^https?:\\/\\//i.test(value)) {\n    if (!origin) {\n      // No origin context (SSR without an explicit origin) — treat absolute\n      // http(s) as external so NextLink is not used for foreign hosts.\n      return true;\n    }\n    try {\n      return new URL(value).origin !== origin;\n    } catch {\n      return true;\n    }\n  }\n\n  return false;\n}\n\nexport function shouldUseNativeAnchor(\n  href: string,\n  origin: string | undefined = resolveDefaultOrigin(),\n): boolean {\n  const value = normalizeHref(href);\n  return isSpecialProtocolHref(value) || isExternalHref(value, origin);\n}\n\nexport function getLinkRel(target?: string, rel?: string): string | undefined {\n  if (rel) return rel;\n  if (target === \"_blank\") return \"noopener noreferrer\";\n  return undefined;\n}\n\n/**\n * True only for root-relative internal paths (\"/components/button\"). These are\n * the only hrefs a host router can be asked to navigate to: hash-only links,\n * relative paths, protocol-relative URLs, mailto:/tel: and absolute URLs are\n * left to the browser so native behavior (scrolling, resolution against the\n * current URL, other origins) is never reimplemented.\n */\nexport function isRouterNavigableHref(href: string): boolean {\n  const value = normalizeHref(href);\n  return value.startsWith(\"/\") && !value.startsWith(\"//\");\n}\n\nexport type NavigationInterceptionInput = {\n  href: string;\n  target?: string;\n  download?: unknown;\n  button: number;\n  metaKey: boolean;\n  ctrlKey: boolean;\n  shiftKey: boolean;\n  altKey: boolean;\n  defaultPrevented: boolean;\n};\n\n/**\n * Whether a click on an anchor should be handed to the host router instead of\n * the browser. Only a plain, primary-button, same-window activation of an\n * internal path qualifies; every case where the browser should win returns\n * false.\n */\nexport function shouldInterceptNavigation(input: NavigationInterceptionInput): boolean {\n  if (input.defaultPrevented) return false;\n  if (input.button !== 0) return false;\n  if (input.metaKey || input.ctrlKey || input.shiftKey || input.altKey) return false;\n  if (input.target && input.target !== \"_self\") return false;\n  if (input.download !== undefined && input.download !== false) return false;\n  return isRouterNavigableHref(input.href);\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/link-utils.ts"
    },
    {
      "path": "components/ui/router-navigation.tsx",
      "content": "\"use client\";\n\nimport {\n  createContext,\n  forwardRef,\n  useContext,\n  type AnchorHTMLAttributes,\n  type MouseEvent,\n  type ReactNode,\n} from \"react\";\nimport { shouldInterceptNavigation } from \"@/components/ui/internal/link-utils\";\n\n/**\n * Router integration for link-bearing components (Button, Link, Pagination,\n * List Item). Components always render a native `<a href>`; with no provider\n * a click is ordinary browser navigation. A host application may mount one\n * `SkrewwwRouterProvider` so eligible internal navigations are handed to its\n * own router instead of reloading the page. The contract is navigation\n * intent (\"go to this path\"), not any particular router.\n */\nexport type SkrewwwNavigate = (href: string) => void;\n\nconst SkrewwwNavigateContext = createContext<SkrewwwNavigate | null>(null);\n\nexport type SkrewwwRouterProviderProps = {\n  /**\n   * Called with the root-relative href of a plain, same-window click on an\n   * internal link. Modified or non-primary clicks, `target` other than\n   * `_self`, `download`, prevented events and every non-root-relative href\n   * are never passed to it. Memoize it to avoid re-rendering link consumers.\n   */\n  navigate: SkrewwwNavigate;\n  children: ReactNode;\n};\n\nexport function SkrewwwRouterProvider({ navigate, children }: SkrewwwRouterProviderProps) {\n  return <SkrewwwNavigateContext.Provider value={navigate}>{children}</SkrewwwNavigateContext.Provider>;\n}\n\nexport type RouterAnchorProps = AnchorHTMLAttributes<HTMLAnchorElement> & { href: string };\n\n/** Internal building block — not part of the public package API. */\nexport const RouterAnchor = forwardRef<HTMLAnchorElement, RouterAnchorProps>(function RouterAnchor(\n  { href, target, download, onClick, ...rest },\n  ref,\n) {\n  const navigate = useContext(SkrewwwNavigateContext);\n\n  function handleClick(event: MouseEvent<HTMLAnchorElement>) {\n    onClick?.(event);\n    if (!navigate) return;\n    const intercept = shouldInterceptNavigation({\n      href,\n      target,\n      download,\n      button: event.button,\n      metaKey: event.metaKey,\n      ctrlKey: event.ctrlKey,\n      shiftKey: event.shiftKey,\n      altKey: event.altKey,\n      defaultPrevented: event.defaultPrevented,\n    });\n    if (!intercept) return;\n    event.preventDefault();\n    navigate(href);\n  }\n\n  return <a ref={ref} href={href} target={target} download={download} onClick={handleClick} {...rest} />;\n});\n",
      "type": "registry:ui",
      "target": "~/components/ui/router-navigation.tsx"
    }
  ]
}
