Problem
Build a pagination bar for a data table with 500 items and pageSize = 10.
Requirements
- Show page numbers with ellipsis for large ranges (e.g.
1 … 4 5 6 … 50). - Prev/Next disabled at boundaries.
onPageChange(page)callback (1-based).- Highlight current page;
aria-current="page". - (Bonus) page size selector, jump-to-page input.
Hints / Approach
- Compute
totalPages = Math.ceil(total / pageSize). - Generate visible page array with sliding window algorithm around current page.
- Keep pagination controlled — parent owns
currentPage.