UNPKG

@lobehub/ui

Version:

Lobe UI is an open-source UI component library for building AIGC web apps

18 lines (17 loc) • 719 B
//#region src/base-ui/Pagination/helpers.ts const getPageCount = (total, pageSize) => Math.max(1, Math.ceil(total / pageSize)); const clampPage = (page, pageCount) => Math.min(Math.max(page, 1), pageCount); const getPaginationItems = (current, pageCount) => { if (pageCount <= 1) return [1]; const items = [1]; const start = Math.max(2, current - 2); const end = Math.min(pageCount - 1, current + 2); if (start > 2) items.push("ellipsis-prev"); for (let page = start; page <= end; page += 1) items.push(page); if (end < pageCount - 1) items.push("ellipsis-next"); items.push(pageCount); return items; }; //#endregion export { clampPage, getPageCount, getPaginationItems }; //# sourceMappingURL=helpers.mjs.map