import { ReactNode } from 'react'; import { WorkspacePaginationProps } from '../../workspace/workspace-pagination.js'; export interface PaginationSummaryInfo { endIndex: number; page: number; pageSize: number; startIndex: number; totalItems: number; } export interface UseDataTablePaginationOptions { /** Controls how many boundary page numbers are always shown (passed through to WorkspacePagination). */ boundaryCount?: number; /** Items received on the current page. Used for hasMore mode and end-index math. */ currentPageItemCount?: number; /** * Provide the full dataset for client-side pagination. * When passed, `totalItems` defaults to `data.length` (unless you explicitly pass totalItems), * and the hook will return `pagedItems` (the slice for the current page). */ data?: readonly unknown[]; /** Alias for initialPageSize. Used when callers configure tables by rows-per-page wording. */ defaultRowsPerPage?: number; /** * When the backend only returns "has more data after this page" (no count). * Must be paired with currentPageItemCount for accurate synthetic totals. */ hasMore?: boolean; /** * If true (default in many client-side cases), the returned `pagination` will be `undefined` * when there is only a single page of data (no need to show controls). */ hidePaginationIfSinglePage?: boolean; initialPage?: number; initialPageSize?: number; onPageChange?: (page: number) => void; onPageSizeChange?: (pageSize: number) => void; page?: number; pageSize?: number; /** Options for the rows-per-page selector in WorkspacePagination. */ pageSizeOptions?: readonly number[]; /** * Opt-in rows-per-page selector (off by default). * Requires `pageSizeOptions` when enabled. */ showPageSizeSelector?: boolean; /** * Opt-in range summary (`Showing x–y of z results`) on the pagination footer. * Off by default. When true, uses `summary` when provided, otherwise the * default range text from `totalItems`. */ showSummary?: boolean; /** Controls how many sibling pages are shown around the current page. */ siblingCount?: number; /** * Custom summary for the pagination footer. * Can be a static node or a function that receives the current range info. * Only rendered when `showSummary` is true. */ summary?: ReactNode | ((info: PaginationSummaryInfo) => ReactNode); /** * Exact total when known (preferred). * If omitted and hasMore is used, a synthetic total will be derived. */ totalItems?: number; } export interface UseDataTablePaginationResult { endIndex: number; /** Forwarded when the hasMore input was used */ hasMore?: boolean; hasNextPage: boolean; hasPreviousPage: boolean; /** Whether a total count was known vs synthesized from hasMore */ isTotalExact: boolean; limit: number; offset: number; page: number; /** The sliced subset of `data` for the current page (only present when `data` option was passed). */ pagedItems?: readonly T[]; pageSize: number; /** * Ready-to-use pagination props for AthenaTable / WorkspacePagination. * Will be undefined when hidePaginationIfSinglePage is true and there's only one page. */ pagination: (Pick & { boundaryCount?: number; siblingCount?: number; summary?: ReactNode; }) | undefined; setPage: (page: number) => void; setPageSize: (pageSize: number) => void; startIndex: number; totalItems: number; totalPages: number; } export declare function useDataTablePagination({ initialPage, initialPageSize, defaultRowsPerPage, totalItems: explicitTotalItems, hasMore, currentPageItemCount, data, boundaryCount, siblingCount, summary, hidePaginationIfSinglePage, page: controlledPage, pageSize: controlledPageSize, pageSizeOptions, showPageSizeSelector, showSummary, onPageChange, onPageSizeChange }: UseDataTablePaginationOptions): UseDataTablePaginationResult; /** * Convenience hook for **client-side** pagination of an in-memory array. * * This is the recommended way when you already have all the data (e.g. a small * list fetched from Athena SDK without server pagination, or admin data). * * Automatically: * - Uses the array length as total * - Returns the correctly sliced `pagedItems` * - Returns a ready `pagination` object (or `undefined` when not needed) * - Supports custom summary, boundary/sibling counts, etc. * * @example * const { pagedItems, pagination } = useClientPagination(allTasks, { * initialPageSize: 25, * summary: ({ startIndex, endIndex, totalItems }) => * `Showing ${startIndex}-${endIndex} · ${totalItems} tasks`, * boundaryCount: 1, * siblingCount: 0, * hidePaginationIfSinglePage: true, * }) * * */ export declare function useClientPagination(data: readonly T[] | undefined | null, options?: Omit): { pagedItems: readonly T[]; pagination: (Pick & { boundaryCount?: number; siblingCount?: number; summary?: ReactNode; }) | undefined; page: number; pageSize: number; startIndex: number; endIndex: number; setPage: (page: number) => void; setPageSize: (size: number) => void; };