UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

43 lines (42 loc) 1.67 kB
/** * The number of an available pagination page, or `null`, indicating a gap * between sequential numbered pages. */ type PageNumber = number | null; export type Options = { /** * Number of pages to display at the start and end, including the start/end * page. * * This must be >= 1. */ boundaryCount?: number; /** * Number of pages to display before and after the current page. */ siblingCount?: number; }; /** * Determine the set of (pagination) page numbers that should be provided to * a user. * * The result includes a mixture of page numbers that should be shown, plus * `null` values indicating elided page numbers. The goals of the selection * are: * * - To always provide page numbers for the first, last and current pages. * Additional adjacent pages are provided according to the `boundaryCount` * and `siblingCount` options. * - To try and keep the number of pagination items consistent as the current * page changes. If each item is rendered with approximately the same width, * this keeps the overall width of the pagination component and the location * of child controls consistent as the user navigates. This helps to avoid * mis-clicks due to controls moving around under the cursor. * * @param currentPage - The 1-based currently-visible/-active page number. * @param totalPages - The total number of pages * @param options - Options for the number of pages to show at the boundary and * around the current page. */ export declare function paginationItems(currentPage: number, totalPages: number, { boundaryCount, siblingCount }?: Options): PageNumber[]; export {};