import type { ConstOrPromise, ContextFunc } from '../generic-types.ts'; import type { BasicOptions } from './basic.ts'; export type SetPageFunction = (context: Context, page: number) => ConstOrPromise; export type GetCurrentPageFunction = ContextFunc; export type GetTotalPagesFunction = ContextFunc; export interface GenericPaginationOptions { /** * Function which is called when the user chooses a new page. * This is used to store the user selection. * * @example * setPage: (ctx, page) => { * ctx.session.page = page * } */ readonly setPage: SetPageFunction; /** * Function which returns the current page. * This is used to get the last user selection from your store. * * Defaults to page 1 when undefined or not a finite number. * * @example * getCurrentPage: ctx => ctx.session.page */ readonly getCurrentPage: GetCurrentPageFunction; } export interface PaginationOptions extends BasicOptions, GenericPaginationOptions { /** * Returns the amount of pages which are available. * * @example * getTotalPages: ctx => amountOfElements / ITEMS_PER_PAGE */ readonly getTotalPages: GetTotalPagesFunction; } /** * Creates Choices for the paginator * @param totalPages total amount of pages. Array.length is a good way to return this one. * @param currentPage current page. Has to be between [1..totalPages] * @return returns the Choices */ export declare function createPaginationChoices(totalPages: number, currentPage: number | undefined): Record;