@thehappycoder/react-responsive-pagination
Version:
React component for responsive pagination
16 lines (15 loc) • 589 B
JavaScript
export function createItemWidthCalculator(_a) {
var getPageWidth = _a.getPageWidth, getNavWidth = _a.getNavWidth, ellipsisWidth = _a.ellipsisWidth;
return function itemWidthCalculator(item) {
if (item.type === 'page') {
return getPageWidth(item.page, item.active);
}
if (item.type === 'previous' || item.type === 'next') {
return getNavWidth(item.type, item.page !== undefined);
}
if (item.type === 'ellipsis') {
return ellipsisWidth;
}
throw Error("unknown item: " + item.type);
};
}