{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pagination",
  "title": "Pagination",
  "description": "Page navigation for a long list: Previous, the page numbers with gaps, and Next, with the current page marked `aria-current=\"page\"`.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-refs",
    "@ouro/lib-router-link",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/pagination/pagination.tsx",
      "content": "\"use client\";\n\nimport { useLayoutEffect, useRef, useState, type JSX, type ReactNode, type Ref, type RefObject } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { RouterLink } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/**\n * Props shared by every kind of Pagination (`href` or `onPageChange`, `pageCount` or `hasNextPage`).\n *\n * @claim \"Props shared by every kind of\" registry/ouro/components/ouro/pagination/pagination.test-d.ts verify:fileLine(registry/ouro/components/ouro/pagination/pagination.test-d.ts, /expectTypeOf<\\{\\spage:\\s1;\\spageCount:\\s12;\\shref:\\s\"\\?page=\\{page\\}\"\\s\\}>\\(\\)\\.toExtend<PaginationProps>/)\n * @claim \"Props shared by every kind of\" registry/ouro/components/ouro/pagination/pagination.test-d.ts verify:fileLine(registry/ouro/components/ouro/pagination/pagination.test-d.ts, /expectTypeOf<\\{\\spage:\\s1;\\spageCount:\\s12;\\sonPageChange:/)\n */\nexport interface PaginationBaseProps {\n  /**\n   * The current page, counting from 1.\n   *\n   * @claim \"The current page, counting from 1\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > renders a labelled nav of plain links, with the current page marked)\n   */\n  page: number;\n  /**\n   * How many pages show on each side of the current one before a gap (\"1 … 4 5 6 … 12\" is\n   * `1`). The list keeps the same number of cells on every page, so Next never moves.\n   * @default 1\n   * @claim \"How many pages show on each\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap after the first pages near the start)\n   * @claim \"How many pages show on each\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap on both sides in the middle)\n   * @claim \"How many pages show on each\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap before the last pages near the end)\n   * @claim \"The list keeps the same number\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap after the first pages near the start)\n   * @claim \"The list keeps the same number\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap on both sides in the middle)\n   * @claim \"The list keeps the same number\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap before the last pages near the end)\n   */\n  siblings?: number | undefined;\n  /** Names the navigation for screen readers. @default \"Pagination\" */\n  label?: string | undefined;\n  /** The text of the link to the page before. @default \"Previous\" */\n  previousLabel?: string | undefined;\n  /** The text of the link to the page after. @default \"Next\" */\n  nextLabel?: string | undefined;\n  /**\n   * What a screen reader calls each page number; `{page}` is the number. @default \"Page {page}\"\n   *\n   * @claim \"What a screen reader calls each\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > takes every visible and spoken string as a prop)\n   */\n  pageLabel?: string | undefined;\n  /**\n   * The text between Previous and Next where the page numbers do not fit: below 640px, or in a\n   * container too narrow for them. `{page}` and `{pageCount}` are the numbers. @default \"Page {page} of {pageCount}\"\n   * @claim \"The text between Previous and Next\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows only Previous, the summary and Next below 640px)\n   * @claim \"The text between Previous and Next\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > builds hrefs from a string with {page}, which a Server Component can pass)\n   */\n  summaryLabel?: string | undefined;\n  /** Layout only: margins, width, grid placement (`mt-6`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLElement> | undefined;\n\n  /**\n   * Not a prop. Ouro UI uses `page`, counting from 1: `<Pagination page={1} pageCount={12}>`.\n   *\n   * @claim \"Ouro UI uses `page`, counting from\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > renders a labelled nav of plain links, with the current page marked)\n   */\n  currentPage?: { \"Use <Pagination page={1} pageCount={12}>\": never };\n  /** Not a prop. Ouro UI uses `pageCount`: `<Pagination page={1} pageCount={12}>`. */\n  totalPages?: { \"Use <Pagination page={1} pageCount={12}>\": never };\n  /** Not a prop. Pass the number of pages: `pageCount={Math.ceil(total / pageSize)}`. */\n  total?: { \"Use pageCount={Math.ceil(total / pageSize)}\": never };\n  /** Not a prop. Ouro UI uses `pageCount`: `<Pagination page={1} pageCount={12}>`. */\n  count?: { \"Use <Pagination page={1} pageCount={12}>\": never };\n  /** Not a prop. Ouro UI uses `onPageChange`, which gets the page number: `onPageChange={(page) => …}`. */\n  onChange?: { \"Use <Pagination onPageChange={(page) => ...}>\": never };\n}\n\n/** A Pagination that knows how many pages there are: Previous, the numbers with gaps, and Next. */\nexport interface PaginationCountProps {\n  /** How many pages there are. From a count of rows: `Math.ceil(total / pageSize)`. */\n  pageCount: number;\n  /** Not with `pageCount`, which decides whether there is a next page. */\n  hasNextPage?: never;\n}\n\n/**\n * A Pagination for a list without a count of its rows: Previous and Next only, as a query\n * that fetches one row more than a page can tell (`hasNextPage: rows.length > pageSize`).\n */\nexport interface PaginationPagerProps {\n  /** Leave it out when the list has no count; pass it to show the page numbers. */\n  pageCount?: undefined;\n  /** Whether there is a page after this one, which enables Next. @default false */\n  hasNextPage?: boolean | undefined;\n}\n\n/**\n * A Pagination of links: every page has its own address, so it works before JavaScript loads.\n *\n * @claim \"A Pagination of links: every page\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > works with no JavaScript: the server HTML holds every link)\n */\nexport type PaginationLinkProps = PaginationBaseProps & {\n  /**\n   * The address of a page: a string with `{page}` (`href=\"/recipes?page={page}\"`, which a\n   * Server Component can pass) or a function (`` href={(page) => `/recipes?page=${page}`} ``).\n   * Internal paths go through `OuroProvider`'s `linkComponent`, so your router navigates.\n   */\n  href: string | ((page: number) => string);\n  /** Not with `href`. Remove `href` to render buttons that call `onPageChange`. */\n  onPageChange?: never;\n};\n\n/** A Pagination of buttons, for a list that pages in place without changing the address. */\nexport type PaginationButtonProps = PaginationBaseProps & {\n  /** Called with the page number when the person picks a page. Update `page` in it. */\n  onPageChange: (page: number) => void;\n  /** Not with `onPageChange`. Remove `onPageChange` to render links. */\n  href?: never;\n};\n\n/**\n * Props for {@link Pagination}: `href` for links or `onPageChange` for buttons, and\n * `pageCount` for the numbers or `hasNextPage` for Previous and Next only.\n */\nexport type PaginationProps = (PaginationLinkProps | PaginationButtonProps) & (PaginationCountProps | PaginationPagerProps);\n\n// Class strings are literal so the app's Tailwind finds them when it compiles.\n\n// A cell: 44px with 16px text on a coarse pointer at every width, 36px with 14px text with a fine one.\nconst cell =\n  \"press relative m-0 box-border inline-flex h-11 min-w-11 pointer-fine:h-9 pointer-fine:min-w-9 items-center justify-center gap-1 \" +\n  \"rounded-ouro-md border-0 forced-colors:border forced-colors:border-solid bg-transparent px-2 font-[inherit] text-base pointer-fine:text-sm leading-5 font-medium text-foreground no-underline \" +\n  \"tabular-nums select-none touch-manipulation [-webkit-tap-highlight-color:transparent] \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid\";\nconst live = \"cursor-pointer pointer-fine:hover:bg-accent pointer-fine:hover:text-accent-foreground motion-safe:active:scale-(--ouro-press-scale)\";\n// Forced colours drop the fill, so the current page takes the system's highlight pair, kept as it\n// is (Chromium paints even a system colour behind a link in the canvas colour otherwise).\nconst currentCell =\n  \"aria-[current=page]:bg-secondary aria-[current=page]:text-secondary-foreground \" +\n  \"forced-colors:aria-[current=page]:forced-color-adjust-none forced-colors:aria-[current=page]:bg-[Highlight] forced-colors:aria-[current=page]:text-[HighlightText]\";\nconst off = \"cursor-not-allowed opacity-50\";\n\nfunction fill(template: string, page: number, pageCount?: number): string {\n  const filled = template.replaceAll(\"{page}\", String(page));\n  return pageCount === undefined ? filled : filled.replaceAll(\"{pageCount}\", String(pageCount));\n}\n\n/**\n * The cells of the page list: page numbers, and `0` for a gap. Every page of a long list\n * gets the same number of cells (first, last, the current page with its siblings, two gaps\n * or the pages they would hide), so a gap never stands for a single page.\n * @claim \"Every page of a long list\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap after the first pages near the start)\n * @claim \"Every page of a long list\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap before the last pages near the end)\n * @claim \"Every page of a long list\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows a gap on both sides in the middle)\n */\nfunction cells(page: number, pageCount: number, siblings: number): number[] {\n  const range = (from: number, to: number) => Array.from({ length: to - from + 1 }, (_, index) => from + index);\n  const edge = siblings * 2 + 3;\n  if (pageCount <= edge + 2) return range(1, pageCount);\n  if (page <= siblings + 3) return [...range(1, edge), 0, pageCount];\n  if (page >= pageCount - siblings - 2) return [1, 0, ...range(pageCount - edge + 1, pageCount)];\n  return [1, 0, ...range(page - siblings, page + siblings), 0, pageCount];\n}\n\n/** The room the container gives the nav: its content box, less the nav's own margins. */\nfunction roomFor(nav: HTMLElement): number {\n  const container = nav.parentElement!;\n  const containerStyle = getComputedStyle(container);\n  const navStyle = getComputedStyle(nav);\n  return container.clientWidth - parseFloat(containerStyle.paddingLeft) - parseFloat(containerStyle.paddingRight) - parseFloat(navStyle.marginLeft) - parseFloat(navStyle.marginRight);\n}\n\n/** The width of the page list in full: its shown cells and the gaps between them. */\nfunction fullWidth(list: HTMLElement): number {\n  const items = [...list.children].filter((item) => !item.querySelector(\"[data-ouro-pagination-summary]\"));\n  // Below 640px the sm rule hides the numbers, so the list is not laid out and there is nothing to measure.\n  if (items.some((item) => item.getClientRects().length === 0)) return 0;\n  const gap = parseFloat(getComputedStyle(list).columnGap);\n  return items.reduce((sum, item) => sum + item.getBoundingClientRect().width, 0) + gap * (items.length - 1);\n}\n\n/**\n * Whether the page list fits the room its container gives the nav. It shows unless it would\n * overflow, and then the summary shows instead. A layout effect measures the list before paint,\n * so the first paint is the fitted list. A list the summary replaces is not laid out, so its\n * width is kept for the cells it was measured with, and measured again when those change or\n * when the list shows again.\n *\n * Server HTML and the first paint show the list. The `sm` rule hides the list below its\n * breakpoint, where nothing is measured.\n */\nfunction useListFit(navRef: RefObject<HTMLElement | null>, listRef: RefObject<HTMLUListElement | null>, key: string | undefined): boolean {\n  const [fits, setFits] = useState(true);\n  const measured = useRef<{ key: string; width: number } | null>(null);\n  const measure = useRef<(() => void) | null>(null);\n\n  useLayoutEffect(() => {\n    measure.current = () => {\n      // Stryker disable next-line ConditionalExpression: without a page count the pager has no page numbers or summary, so a fit either way changes no class or focus.\n      if (key === undefined) return;\n      const nav = navRef.current!;\n      const list = listRef.current!;\n      const room = roomFor(nav) + 0.5;\n      if (!fits) {\n        if (measured.current === null || measured.current.key !== key) {\n          setFits(true);\n          return;\n        }\n        setFits(measured.current.width <= room);\n        return;\n      }\n      const width = fullWidth(list);\n      if (width === 0) return;\n      measured.current = { key, width };\n      if (width > room) {\n        // A focused page number moves focus to Next (or Previous on the last page) before the summary replaces it.\n        if (list.querySelector(\"[data-ouro-pagination-page]:focus\")) {\n          const control = (part: string) => list.querySelector<HTMLElement>(`[data-ouro-pagination-${part}]:is(a, button:not([aria-disabled]))`);\n          (control(\"next\") ?? control(\"previous\"))?.focus({ preventScroll: true });\n        }\n        setFits(false);\n      }\n    };\n    measure.current!();\n  }, [fits, key, navRef, listRef]);\n\n  useLayoutEffect(\n    () => {\n      const observer = new ResizeObserver(() => flushSync(() => measure.current!()));\n      observer.observe(navRef.current!.parentElement!);\n      observer.observe(document.documentElement);\n      // Fonts change the cells' widths and may change nothing the observer sees. A font that\n      // finishes loading measures again once it is ready, unless the nav has gone.\n      const fonts = document.fonts;\n      const refit = () =>\n        void fonts.ready.then(() => {\n          if (navRef.current === null) return;\n          measured.current = null;\n          measure.current!();\n        });\n      fonts.addEventListener(\"loading\", refit);\n      refit();\n      return () => {\n        observer.disconnect();\n        fonts.removeEventListener(\"loading\", refit);\n      };\n    },\n    // Stryker disable next-line ArrayDeclaration: the nav's and the list's refs are the same objects for the nav's life, so any constant list runs this effect once, as this one does.\n    [navRef, listRef],\n  );\n\n  return fits;\n}\n\nfunction Chevron({ back }: { back?: boolean }): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" className=\"size-4 shrink-0 rtl:-scale-x-100\">\n      <path d={back ? \"M10 3 5 8l5 5\" : \"m6 3 5 5-5 5\"} />\n    </svg>\n  );\n}\n\n/**\n * Page navigation for a long list: Previous, the page numbers with gaps, and Next, with the\n * current page marked `aria-current=\"page\"`. With `href` every page is a real link, so it\n * works with no JavaScript and through your router; with `onPageChange` the pages are\n * buttons. Below 640px the numbers give way to \"Page 3 of 12\" between Previous and Next.\n * They give way too when they are wider than the space their container gives them, so the\n * list stays inside a narrow column. Without `pageCount`, for a list that is not counted, it\n * shows Previous and Next only, and `hasNextPage` enables Next.\n *\n * Use `ShowMore` instead when the next rows should join the list in place. Use `Tabs` to\n * switch between a few named views.\n *\n * @group Navigation\n * @see https://ui.ouroboros.bot/docs/pagination\n *\n * @example\n * <Pagination page={3} pageCount={12} href=\"/recipes?page={page}\" />\n * <Pagination page={page} pageCount={12} onPageChange={setPage} />\n * <Pagination page={page} hasNextPage={rows.length > pageSize} href=\"?page={page}\" />\n * @claim \"Below 640px the numbers give way\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > shows only Previous, the summary and Next below 640px)\n * @claim \"They give way too when they are wider\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination in a column > shows the summary, not overflowing, in a column too narrow for every page)\n * @claim \"They give way too when they are wider\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination in a column > switches to the summary when the column narrows, and back when it widens)\n * @claim \"With `href` every page is a\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination > works with no JavaScript: the server HTML holds every link)\n * @claim \"With `href` every page is a\" registry/ouro/components/ouro/pagination/pagination.test.tsx verify:testExists(registry/ouro/components/ouro/pagination/pagination.test.tsx::Pagination without a page count > pages in place with onPageChange)\n */\nexport function Pagination(props: PaginationProps): JSX.Element {\n  const {\n    page: pageProp,\n    pageCount: pageCountProp,\n    hasNextPage,\n    siblings = 1,\n    label = \"Pagination\",\n    previousLabel = \"Previous\",\n    nextLabel = \"Next\",\n    pageLabel = \"Page {page}\",\n    summaryLabel = \"Page {page} of {pageCount}\",\n    className,\n    ref,\n    href,\n    onPageChange,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    currentPage,\n    totalPages,\n    total,\n    count,\n    onChange,\n  } = props as PaginationBaseProps & {\n    pageCount?: number;\n    hasNextPage?: boolean;\n    href?: string | ((page: number) => string);\n    onPageChange?: (page: number) => void;\n  };\n\n  if ((href === undefined) === (onPageChange === undefined)) {\n    devThrow(\n      \"Pagination\",\n      href === undefined ? \"needs href or onPageChange\" : \"takes href or onPageChange, not both\",\n      process.env.NODE_ENV !== \"production\"\n        ? 'Pass href=\"?page={page}\" for links, or onPageChange={(page) => …} for buttons'\n        : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n\n  // A count or a page out of range (a bug in the caller) renders the nearest valid state and warns.\n  // Without a count, only Previous and Next show.\n  const pageCount = pageCountProp === undefined ? undefined : Math.max(1, Math.floor(pageCountProp));\n  const page = Math.min(Math.max(1, Math.floor(pageProp)), pageCount ?? Infinity);\n  const hasNext = pageCount === undefined ? Boolean(hasNextPage) : page < pageCount;\n\n  useAppearanceClassNameCheck(\n    \"Pagination\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; Pagination sets its own look`\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Pagination\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          pageCount !== pageCountProp && [`pageCount={${pageCountProp}} is not a count of pages`, `<Pagination page={${page}} pageCount={${pageCount}}>`],\n          pageCount === pageCountProp &&\n            page !== pageProp && [\n              pageCount === undefined ? `page={${pageProp}} is not a page number` : `page={${pageProp}} is outside 1 to ${pageCount}`,\n              pageCount === undefined ? `<Pagination page={${page}}>` : `<Pagination page={${page}} pageCount={${pageCount}}>`,\n            ],\n          pageCount !== undefined &&\n            hasNextPage !== undefined && [\n              \"hasNextPage is for a list without a page count; pageCount decides\",\n              `<Pagination page={${page}} pageCount={${pageCount}}> or <Pagination page={${page}} hasNextPage>`,\n            ],\n          typeof href === \"string\" &&\n            !href.includes(\"{page}\") && [\n              `href=\"${href}\" has no {page}, so every link goes to one address`,\n              `<Pagination href=\"${href}${href.includes(\"?\") ? \"&\" : \"?\"}page={page}\">`,\n            ],\n          currentPage !== undefined && [\"currentPage is not a prop\", \"<Pagination page={1} pageCount={12}>\"],\n          totalPages !== undefined && [\"totalPages is not a prop\", \"<Pagination page={1} pageCount={12}>\"],\n          total !== undefined && [\"total is not a prop; pass the number of pages\", \"<Pagination page={1} pageCount={Math.ceil(total / pageSize)}>\"],\n          count !== undefined && [\"count is not a prop\", \"<Pagination page={1} pageCount={12}>\"],\n          onChange !== undefined && [\"onChange is not a prop\", \"<Pagination onPageChange={(page) => …}>\"],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const pages = pageCount === undefined ? [] : cells(page, pageCount, Math.max(0, Math.floor(siblings)));\n  // What decides the width of the full list: its cells and the two labels. The nav's own classes do not.\n  // Stryker disable next-line ConditionalExpression: without a count there are no page numbers or summary to show or hide, so a fit either way changes no class or focus.\n  const fitKey = pageCount === undefined ? undefined : JSON.stringify([pages, previousLabel, nextLabel]);\n  const navRef = useRef<HTMLElement>(null);\n  const listRef = useRef<HTMLUListElement>(null);\n  const fits = useListFit(navRef, listRef, fitKey);\n  const navigationRef = useMergedRef(ref, navRef);\n  // The summary shows when the list does not fit, and below 640px, where the sm rule hides the list.\n  const pageClass = fits ? \"max-sm:hidden\" : \"hidden\";\n\n  /** One control: a link with `href`, a button with `onPageChange`, or plain text when it leads nowhere. */\n  const control = (target: number, enabled: boolean, attributes: Record<string, string | undefined>, classes: string, children: ReactNode) => {\n    if (href !== undefined) {\n      if (!enabled) {\n        return (\n          <span {...attributes} aria-disabled=\"true\" className={cn(cell, off, classes)}>\n            {children}\n          </span>\n        );\n      }\n      return (\n        <RouterLink {...attributes} href={typeof href === \"string\" ? fill(href, target, pageCount) : href(target)} className={cn(cell, live, classes)}>\n          {children}\n        </RouterLink>\n      );\n    }\n    // A button at an end says it is disabled rather than being disabled, so it keeps focus when\n    // a press takes the reader there (a disabled button would drop focus to the page).\n    return (\n      <button {...attributes} type=\"button\" aria-disabled={enabled ? undefined : true} onClick={enabled ? () => onPageChange!(target) : undefined} className={cn(cell, enabled ? live : off, classes)}>\n        {children}\n      </button>\n    );\n  };\n\n  return (\n    <nav ref={navigationRef} data-ouro=\"pagination\" aria-label={label} className={cn(\"min-w-0\", className)}>\n      <ul ref={listRef} className=\"m-0 flex list-none items-center justify-between gap-1 p-0 sm:justify-center\">\n        <li>\n          {control(\n            page - 1,\n            page > 1,\n            { \"data-ouro-pagination-previous\": \"\", \"data-ouro-control\": \"pagination\", \"data-ouro-part\": \"previous\", rel: href !== undefined && page > 1 ? \"prev\" : undefined },\n            \"px-3\",\n            <>\n              <Chevron back />\n              {previousLabel}\n            </>,\n          )}\n        </li>\n        {pageCount !== undefined && (\n        <li className={fits ? \"sm:hidden\" : undefined}>\n          <span data-ouro-pagination-summary=\"\" aria-current=\"page\" className=\"px-2 text-base leading-5 text-muted-foreground tabular-nums\">\n            {fill(summaryLabel, page, pageCount)}\n          </span>\n        </li>\n        )}\n        {pages.map((target, index) =>\n          target === 0 ? (\n            <li key={`gap${index}`} className={pageClass}>\n              <span data-ouro-pagination-gap=\"\" aria-hidden=\"true\" className=\"inline-flex h-11 min-w-9 pointer-fine:h-9 items-center justify-center text-base text-muted-foreground select-none\">\n                …\n              </span>\n            </li>\n          ) : (\n            <li key={target} className={pageClass}>\n              {control(\n                target,\n                true,\n                { \"data-ouro-pagination-page\": \"\", \"data-ouro-control\": \"pagination\", \"data-ouro-part\": \"page\", \"aria-label\": fill(pageLabel, target, pageCount), \"aria-current\": target === page ? \"page\" : undefined },\n                currentCell,\n                target,\n              )}\n            </li>\n          ),\n        )}\n        <li>\n          {control(\n            page + 1,\n            hasNext,\n            { \"data-ouro-pagination-next\": \"\", \"data-ouro-control\": \"pagination\", \"data-ouro-part\": \"next\", rel: href !== undefined && hasNext ? \"next\" : undefined },\n            \"px-3\",\n            <>\n              {nextLabel}\n              <Chevron />\n            </>,\n          )}\n        </li>\n      </ul>\n    </nav>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/pagination/pagination.tsx"
    }
  ],
  "docs": "Page navigation for a long list: Previous, the page numbers with gaps, and Next, with the current page marked `aria-current=\"page\"`. Import: import { Pagination } from \"@/components/ouro/pagination/pagination\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/pagination.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}