API/getPageWindow
getPageWindow
src/utils/get-page-window.tsfunction
getPageWindow()
Section titled “getPageWindow()”getPageWindow(page: number, lastPage: number, options: PageWindowOptions): readonly PageWindowItem[]The places a pagination bar shows: page numbers, with 'gap' where a run
of pages is folded.
The window keeps a constant length — 2 × boundaries + 2 × siblings + 3,
or every page when there are no more than that — so the buttons do not
shift as the user pages. A gap never stands for a single page: that page’s
number is shown instead.
Never throws. A page outside 1–lastPage is clamped; fractional input is
floored; a lastPage below 1, NaN or Infinity — a backend that reports
no count — is treated as 1.
| Parameter | Type | Description |
|---|---|---|
page |
number |
The current page, from 1 |
lastPage |
number |
The number of pages |
options |
PageWindowOptions |
Pages shown at each end and around the current one |
Returns — The numbers and gaps, in order
