import { Dispatch } from 'react'; import MenuEntryDescription from './MenuEntryDescription'; /** * The state managed by the menu. */ export interface State { menu: MenuEntryDescription[][]; pendingAction?: string | (() => void); } /** * Type of actions which can be applied to the state. */ declare const enum ActionType { SelectEntry = 0, AddEntry = 1, RemoveEntry = 2, CleanAction = 3 } /** * Select menu entry action. */ interface SelectEntryAction { type: ActionType.SelectEntry; target: EventTarget & HTMLElement; payload: MenuEntryDescription['action']; } /** * Build an action to select a menu entry. * * @param target - The target of the menu event. * @param action - The action to be executed by the menu entry. * @returns The corresponding action. */ export declare function selectEntry(target: EventTarget & HTMLElement, action: MenuEntryDescription['action']): SelectEntryAction; /** * Add menu entry action. */ interface AddEntryAction { type: ActionType.AddEntry; payload: MenuEntryDescription; } /** * Build an action to add a menu entry. * * @param description - The menu entry description. * @returns The corresponding action. */ export declare function addEntry(description: MenuEntryDescription): AddEntryAction; /** * Remove menu entry action. */ interface RemoveEntryAction { type: ActionType.RemoveEntry; payload: MenuEntryDescription; } /** * Build an action to remove a menu entry. * * @param reference - The reference on the entry to remove (must be the same object as used to add the menu * entry). * @returns The corresponding action. */ export declare function removeEntry(reference: MenuEntryDescription): RemoveEntryAction; /** * Clean the pending action action. */ interface CleanActionAction { type: ActionType.CleanAction; } /** * Build an action to clean the pending action. * * @returns The corresponding action. */ export declare function cleanAction(): CleanActionAction; /** * The reducer actions. */ export declare type Action = SelectEntryAction | AddEntryAction | RemoveEntryAction | CleanActionAction; /** * The reducer function. Treat all actions to update the state. * * @param state - The initial state. * @param action - The action to be executed. * @returns The new state. */ export declare function reducer(state: State, action: Action): State; export declare const context: import("react").Context<[State, Dispatch] | undefined>; export {};