import type { BasicOptions } from '../buttons/basic.ts'; import type { GenericPaginationOptions } from '../buttons/pagination.ts'; import type { ConstOrContextFunc, ConstOrPromise } from '../generic-types.ts'; export type Choice = string | number; export type ChoiceText = string; export type ChoicesArray = readonly Choice[]; export type ChoicesRecord = Readonly>; export type ChoicesMap = Readonly>; export type Choices = ChoicesArray | ChoicesRecord | ChoicesMap; export type ChoiceTextFunc = (context: Context, key: string) => ConstOrPromise; export interface ManyChoicesOptions extends BasicOptions, Partial> { /** * Amount of buttons shown per row (side by side). * * Defaults to 6 */ readonly columns?: number; /** * Maximum rows to be shown. * Consider pagination when you have many buttons rather than increasing the amount of buttons as its more user friendly. * * Defaults to 10 */ readonly maxRows?: number; /** * Per default the action (do or set) is only run when the user selected choice does exist. * For this the choices are queried again and has to contain the user selection. * Normally this is useful: Shop offers some drinks and user should only click existing drinks. If some drink isnt in the offer, the menu will be updated to show the current drinks instead of calling the do / set. * * Sometimes this behaviour is not helpful and can be disabled. */ readonly disableChoiceExistsCheck?: boolean; /** Choices the user can pick from */ readonly choices: ConstOrContextFunc; /** Function which has to return the text the user will see on the button of a given choice */ readonly buttonText?: ChoiceTextFunc; }