import type * as React from 'react'; import type { PrimitivePropsWithRef } from '../utils/primitive.js'; import type { PaginationLabels, ResolvedPaginationLabels } from './labels.js'; import type { PaginationRangeEntry } from './pages.js'; /** @internal Shared state distributed from {@link Pagination} to its parts via context. Not part of the public API. */ export interface PaginationContextValue { page: number; pageCount: number; pages: PaginationRangeEntry[]; onPageChange: (page: number) => void; /** Every string the strip speaks, with the consumer's overrides already merged over the defaults. */ labels: ResolvedPaginationLabels; /** Whether the whole strip is disabled; each link ORs it with its own `disabled`. */ disabled: boolean; } /** Props for the {@link Pagination} root. */ export interface PaginationProps extends Omit, 'onChange'> { /** * Manual parts for full control; omitted, strip derives anatomy from page/sibling/boundary counts. * @default undefined — the strip derives its anatomy. */ children?: React.ReactNode | undefined; /** Total number of pages, used to disable `PaginationNext` on the last page. */ pageCount: number; /** * Current page (1-based), for controlled usage. Pair with `onPageChange`. * @default undefined — uncontrolled, tracks its own current page internally. */ page?: number | undefined; /** * Initial page (1-based), for uncontrolled usage. * @default 1 */ defaultPage?: number | undefined; /** * Fires with the new page number whenever it changes, controlled or not. * @default undefined — no-op if omitted. */ onPageChange?: ((page: number) => void) | undefined; /** * Strings for nav landmark and controls. Each key optional, falls back to * built-in English; part's own `aria-label` still wins. * @default undefined — the built-in English strings. */ labels?: PaginationLabels | undefined; /** * Pages shown either side of the current one in the `pages` model. * @default 1 */ siblingCount?: number | undefined; /** * Pages always shown at each end of the `pages` model, however far away the * current page is. * @default 1 */ boundaryCount?: number | undefined; /** * Disable strip-wide navigation; each control ORs with its own `disabled`. * Set this while page loads, not `disabled` per item. * @default false */ disabled?: boolean | undefined; /** * Show First/Last buttons at strip ends. Ignored when `children` is given. * @default false */ showFirstLast?: boolean | undefined; /** * Show status announcing `"Page {page} of {pageCount}"`. Ignored when `children` is given. * @default false */ showStatus?: boolean | undefined; /** * Spacing rung the skin packs the pager by, mirrored to `data-density`. * @default undefined — the skin's own default spacing. */ density?: 'comfortable' | (string & {}) | undefined; /** * Size rung the skin scales the pager by, mirrored to `data-size`. * @default undefined — the skin's own default size. */ size?: 'md' | 'lg' | (string & {}) | undefined; } /** Props for {@link PaginationList}, the container for `PaginationItem`s. */ export interface PaginationListProps extends PrimitivePropsWithRef<'ul'> { } /** Props for a single {@link PaginationItem} wrapper. */ export interface PaginationItemProps extends PrimitivePropsWithRef<'li'> { } /** Props for a {@link PaginationPage} page button. */ export interface PaginationPageProps extends PrimitivePropsWithRef<'button'> { /** Page number this button navigates to when clicked. */ page: number; /** * Marks this page as the currently selected one (sets `aria-current="page"` and `data-state="active"`). * @default undefined — derived: true when this link's `page` is the root's current page. */ isActive?: boolean | undefined; /** * Disables button; when set, ORs with root's `disabled` for strip-wide control. * @default false */ disabled?: boolean | undefined; } /** Props for {@link PaginationPrevious}, a `PaginationPage` bound to `page - 1`. */ export interface PaginationPreviousProps extends Omit, 'children'> { /** * Custom label content, replacing the default "Previous" text. * @default 'Previous' */ children?: React.ReactNode | undefined; } /** Props for {@link PaginationNext}, a `PaginationPage` bound to `page + 1`. */ export interface PaginationNextProps extends Omit, 'children'> { /** * Custom label content, replacing the default "Next" text. * @default 'Next' */ children?: React.ReactNode | undefined; } /** Props for {@link PaginationFirst}, a `PaginationPage` bound to page 1. */ export interface PaginationFirstProps extends Omit, 'children'> { /** * Custom label content, replacing the default "First" text. * @default 'First' */ children?: React.ReactNode | undefined; } /** Props for {@link PaginationLast}, a `PaginationPage` bound to `pageCount`. */ export interface PaginationLastProps extends Omit, 'children'> { /** * Custom label content, replacing the default "Last" text. * @default 'Last' */ children?: React.ReactNode | undefined; } /** Props for {@link PaginationEllipsis}, a collapsed-pages placeholder. */ export interface PaginationEllipsisProps extends PrimitivePropsWithRef<'span'> { } /** Props for {@link PaginationStatus}, the optional page-change live region. */ export interface PaginationStatusProps extends PrimitivePropsWithRef<'div'> { /** * Builds the announcement from the root's current page and page count. * Ignored when `children` are given. * @default undefined — announces `Page N of M` in English. */ format?: ((page: number, pageCount: number) => string) | undefined; }