UNPKG

@clubmed/trident-ui

Version:

Shared ClubMed React UI components

49 lines (48 loc) 2.1 kB
export type Page = { type: 'pageNumber'; value: number; } | { type: 'ellipsis'; } | { type: 'previousButton'; disabled: boolean; } | { type: 'nextButton'; disabled: boolean; }; /** * Checks for mobile devices only whether a page number should be followed by an ellipsis in a pagination component, * based on the active page number. * * @param page {number} - The number of the current page. * @param activePage {number} - The number of the active page. * @param lastPage {number} - The last page. * @returns {boolean} - Returns `true` if the page number should be followed by an ellipsis, otherwise returns `false`. */ export declare const showMobileEllipsis: (page: number, activePage: number, lastPage: number) => boolean; /** * Get the active page number index from an array of pagination items. * * @param activePage - The active page number. * @param paginationItems - An array of pagination objects containing items of "page" type or sometimes "ellipsis" type. * @returns {number} - The index of the active page number in the paginationItems array, or -1 if not found. */ export declare const getActivePageIndex: (activePage: number, pagination: Page[]) => number; /** * Generates a pagination object based on the current page and total page number. * * @param {number} activePage - The active page number. * @param {number} totalPage - The total number of pages. * @returns {PageArray} - An array of pagination items. */ export declare const generatePagination: (activePage: number, totalPage: number) => Page[]; /** * Determines whether a page button should be hidden on mobile devices in a pagination component * based on the active page number. * * @param page - The page number currently being evaluated. * @param activePage - The number of the currently active page. * @param lastPage - The largest page number. * @returns {boolean} - Returns `true` if the page button should be hidden, otherwise returns `false`. */ export declare const hidePageButtonForMobile: (page: number, activePage: number, lastPage: number) => boolean;