export interface UsePaginationOptions { /** * Total number of items. * * @defaultValue Number.POSITIVE_INFINITY */ total?: number; /** * The number of items to display per page. * * @defaultValue 10 */ pageSize?: number; /** * The current page number. * * @defaultValue 1 */ page?: number; /** * The original list to be paginated. */ list?: T[]; /** * Callback when the `page` change. * * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @param {number} lastPage - `number`, the last page * @returns {void} `void` */ onPageChange?: (pagination: UsePaginationReturnsState, lastPage: number) => void; /** * Callback when the `pageSize` change. * * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @param {number} lastPageSize - `number`, the last page size * @returns {void} `void` */ onPageSizeChange?: (pagination: UsePaginationReturnsState, lastPageSize: number) => void; /** * Callback when the `pageCount` change. * * @param {PaginationInfo} pagination - `PaginationInfo`, the pagination info * @param {number} lastPageCount - `number`, the last page count * @returns {void} `void` */ onPageCountChange?: (pagination: UsePaginationReturnsState, lastPageCount: number) => void; } export interface UsePaginationReturnsState { /** * Total number of items. */ total: number; /** * The current page number. * * @deprecated Use `page` instead. */ currentPage: number; /** * The number of items to display per page. * * @deprecated Use `pageSize` instead. */ currentPageSize: number; /** * The current page number. * * @since 1.7.0 */ page: number; /** * The number of items to display per page. * * @since 1.7.0 */ pageSize: number; /** * The total number of pages. */ pageCount: number; /** * The start index of the displayed list (helpful to slice the list). */ indexStart: number; /** * The end index of the displayed list (helpful to slice the list). */ indexEnd: number; /** * The start count of the displayed list. * * @since 1.7.0 */ countStart: number; /** * The end count of the displayed list. * * @since 1.7.0 */ countEnd: number; /** * Whether the current page is the first page. */ isFirstPage: boolean; /** * Whether the current page is the last page. */ isLastPage: boolean; /** * The sliced list to display. */ list: T[]; } export interface UsePaginationReturnsActions { /** * Go to the previous page. * * @returns {void} `void` */ prev(): void; /** * Go to the next page. * * @returns {void} `void` */ next(): void; /** * Go to the specified page. * * @param {number} page - `number`, the page number * @returns {void} `void` */ go: (page: number) => void; /** * Set the number of items to display per page. * * @param {number} size - `number`, the number of items to display per page * @returns {void} `void` */ setPageSize: (size: number) => void; } export type UsePaginationReturns = readonly [UsePaginationReturnsState, UsePaginationReturnsActions]; /** * A React Hook that manage pagination state. */ export declare function usePagination(options?: UsePaginationOptions): UsePaginationReturns;