import type { HotInstance } from '../../../core/types'; import type { GridSettings } from '../../../core/settings'; import { Positioner } from './positioner'; import EventManager from '../../../eventManager'; interface MenuOptions { parent: Menu | null; name: string | null; className: string; keepInViewport: boolean; standalone: boolean; minWidth: number; container: HTMLElement; } /** * @typedef MenuOptions * @property {Menu} [parent=null] Instance of {@link Menu}. * @property {string} [name=null] Name of the menu. * @property {string} [className=''] Custom class name. * @property {boolean} [keepInViewport=true] Determine if should be kept in viewport. * @property {boolean} [standalone] Enabling closing menu when clicked element is not belongs to menu itself. * @property {number} [minWidth=MIN_WIDTH] The minimum width. * @property {HTMLElement} [container] The container. */ /** * @private * @class Menu */ export declare class Menu { #private; /** * The Handsontable instance. * * @type {Core} */ hot: HotInstance; /** * The Menu options. * * @type {object} */ options: MenuOptions; /** * @type {EventManager} */ eventManager: EventManager; /** * The Menu container element. * * @type {HTMLElement} */ container: HTMLElement; /** * @type {Positioner} */ positioner: Positioner; /** * The instance of the Handsontable that is used as a menu. * * @type {Core} */ hotMenu: HotInstance | null; /** * The collection of the Handsontable instances that are used as sub-menus. * * @type {object} */ hotSubMenus: Record; /** * If the menu acts as the sub-menu then this property contains the reference to the parent menu. * * @type {Menu} */ parentMenu: Menu | null; /** * The menu items entries. * * @type {object[]} */ menuItems: Record[] | null; /** * @type {boolean} */ origOutsideClickDeselects: GridSettings['outsideClickDeselects']; /** * Registers a local hook listener scoped to this instance. Provided by the `localHooks` mixin. */ addLocalHook: (key: string, callback: Function) => object; /** * Executes all local hook listeners registered under the given name. Provided by the `localHooks` mixin. */ runLocalHooks: (key: string, ...args: unknown[]) => void; /** * Removes all local hook listeners and returns this instance. Provided by the `localHooks` mixin. */ clearLocalHooks: () => object; /** * Getter for the table border width. * This getter retrieves the border width of the table used in the menu. * * @returns {number} The border width of the table in pixels. */ get tableBorderWidth(): number | undefined; /** * @param {Core} hotInstance Handsontable instance. * @param {MenuOptions} [options] Menu options. */ constructor(hotInstance: HotInstance, options?: Partial); /** * Register event listeners. * * @private */ registerEvents(): void; /** * Set array of objects which defines menu items. * * @param {Array} menuItems Menu items to display. */ setMenuItems(menuItems: Record[]): void; /** * Gets the controller object that allows modifying the the menu item selection. * * @returns {Paginator | undefined} */ getNavigator(): { setCurrentPage: (index: number) => void; setPageCursorAt: (index: number) => void; getCurrentPage: () => number; toFirstItem: () => void; toLastItem: () => void; toNextItem: () => void; toPreviousItem: () => void; getSize: () => number; clear: () => void; } | null; /** * Gets the controller object that allows extending the keyboard shortcuts of the menu. * * @returns {KeyboardShortcutsMenuController | undefined} */ getKeyboardShortcutsCtrl(): { addCustomShortcuts: (shortcuts: import("../../../shortcuts").Shortcut[], contextName?: string) => void; getCustomShortcuts: () => { shortcuts: import("../../../shortcuts").Shortcut[]; contextName: string; }[]; getContext: (contextName?: string) => import("../../../shortcuts").Context; listen: (contextName?: string) => void; } | null; /** * Returns currently selected menu item. Returns `null` if no item was selected. * * @returns {object|null} */ getSelectedItem(): Record | null; /** * Returns the position (row index) of the menu item identified by the provided `key` within the * currently rendered menu. Before rendering, `filterSeparators()` and the hidden-item filter run * over `menuItems`, so the rendered list can differ from the raw `menuItems` collection - callers * that need an index matching the rendered rows must use this method instead of reading * `menuItems` directly. Falls back to `menuItems` when the menu has not been rendered yet. * * @param {string} key The menu item key to look up. * @returns {number} The item row index, or `-1` when the item is not found. */ getItemPositionByKey(key: string): number; /** * Checks if the menu has selected (highlighted) any item from the menu list. * * @returns {boolean} */ hasSelectedItem(): boolean; /** * Check if menu is using as sub-menu. * * @returns {boolean} */ isSubMenu(): boolean; /** * Open menu. * * @fires Hooks#beforeContextMenuShow * @fires Hooks#afterContextMenuShow */ open(): void; /** * Close menu. * * @param {boolean} [closeParent=false] If `true` try to close parent menu if exists. */ close(closeParent?: boolean): void; /** * Open sub menu at the provided row index. * * @param {number} row Row index. * @returns {Menu|boolean} Returns created menu or `false` if no one menu was created. */ openSubMenu(row: number): false | Menu; /** * Close sub menu at row index. * * @param {number} row Row index. */ closeSubMenu(row: number): void; /** * Close all opened sub menus. */ closeAllSubMenus(): void; /** * Checks if all created and opened sub menus are closed. * * @returns {boolean} */ isAllSubMenusClosed(): boolean; /** * Focus the menu so all keyboard shortcuts become active. */ focus(): void; /** * Destroy instance. */ destroy(): void; /** * Checks if menu was opened. * * @returns {boolean} Returns `true` if menu was opened. */ isOpened(): boolean; /** * Execute menu command. * * The `executeCommand()` method works only for selected cells. * * When no cells are selected, `executeCommand()` doesn't do anything. * * @param {Event} [event] The mouse event object. */ executeCommand(event?: Event): void; /** * Checks if the passed command is passive or not. The command is passive when it's marked as * disabled, the descriptor object contains `isCommand` property set to `false`, command * is a separator, or the item is recognized as submenu. For passive items the menu is not * closed automatically after the user trigger the command through the UI. * * @param {object} commandDescriptor Selected menu item from the menu data source. * @returns {boolean} */ isCommandPassive(commandDescriptor: Record): boolean; /** * Set offset menu position for specified area (`above`, `below`, `left` or `right`). * * @param {string} area Specified area name (`above`, `below`, `left` or `right`). * @param {number} offset Offset value. */ setOffset(area: string, offset?: number): void; /** * Set menu position based on dom event or based on literal object. * * @param {Event|object} coords Event or literal Object with coordinates. */ setPosition(coords: Event | DOMRect | Record): void; /** * Updates the dimensions of the menu based on its content. * This method calculates the real height of the menu by summing up the heights of its items, * and adjusts the width and height of the menu's holder and hider elements accordingly. */ updateMenuDimensions(): void; /** * Create container/wrapper for handsontable. * * @private * @param {string} [name] Class name. * @returns {HTMLElement} */ createContainer(name?: string | null): HTMLElement; /** * On after init listener. * * @private */ onAfterInit(): void; /** * Document mouse down listener. * * @private * @param {Event} event The mouse event object. */ onDocumentMouseDown(event: Event): void; /** * Document's contextmenu listener. * * @private * @param {MouseEvent} event The mouse event object. */ onDocumentContextMenu(event: Event): void; } export {};