import type { HotInstance } from '../../core/types'; import { BasePlugin } from '../base'; import { CommandExecutor } from '../contextMenu/commandExecutor'; import { ItemsFactory } from '../contextMenu/itemsFactory'; import { Menu } from '../contextMenu/menu'; export declare const PLUGIN_KEY = "dropdownMenu"; export declare const PLUGIN_PRIORITY = 230; /** * @plugin DropdownMenu * @class DropdownMenu * * @description * This plugin creates the Handsontable Dropdown Menu. It allows to create a new column at any place in the grid * among [other features](@/guides/accessories-and-menus/context-menu/context-menu.md#context-menu-with-specific-options). * Possible values: * * `true` (to enable default options), * * `false` (to disable completely). * * or array of any available strings: * * `["col_left", "col_right", "remove_col", "---------", "undo", "redo"]`. * * See [the dropdown menu demo](@/guides/columns/column-menu/column-menu.md) for examples. * * @example * ::: only-for javascript * ```js * const container = document.getElementById('example'); * const hot = new Handsontable(container, { * data: data, * colHeaders: true, * // enable dropdown menu * dropdownMenu: true * }); * * // or * const hot = new Handsontable(container, { * data: data, * colHeaders: true, * // enable and configure dropdown menu * dropdownMenu: ['remove_col', '---------', 'make_read_only', 'alignment'] * }); * ``` * ::: * * ::: only-for react * ```jsx * * ``` * ::: * * ::: only-for angular * ```ts * settings = { * data: data, * comments: true, * // enable and configure dropdown menu * dropdownMenu: ["remove_col", "---------", "make_read_only", "alignment"], * }; * ``` * * ```html * * ``` * ::: */ export declare class DropdownMenu extends BasePlugin { #private; /** * Returns the plugin key used to identify this plugin in Handsontable settings. */ static get PLUGIN_KEY(): string; /** * Returns the priority order used to determine the order in which plugins are initialized. */ static get PLUGIN_PRIORITY(): number; /** * Returns the list of plugin dependencies required before this plugin can be initialized. */ static get PLUGIN_DEPS(): string[]; /** * Default menu items order when `dropdownMenu` is enabled by setting the config item to `true`. * * @returns {Array} */ static get DEFAULT_ITEMS(): string[]; /** * Instance of {@link CommandExecutor}. * * @private * @type {CommandExecutor} */ commandExecutor: CommandExecutor; /** * Instance of {@link ItemsFactory}. * * @private * @type {ItemsFactory} */ itemsFactory: ItemsFactory | null; /** * Instance of {@link Menu}. * * @private * @type {Menu} */ menu: Menu | null; /** * Initializes the plugin and registers the column header hook needed to inject the dropdown button. */ constructor(hotInstance: HotInstance); /** * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit} * hook and if it returns `true` then the {@link DropdownMenu#enablePlugin} method is called. * * @returns {boolean} */ isEnabled(): boolean; /** * Enables the plugin functionality for this Handsontable instance. * * @fires Hooks#afterDropdownMenuDefaultOptions * @fires Hooks#beforeDropdownMenuSetItems */ enablePlugin(): void; /** * Updates the plugin's state. * * This method is executed when [`updateSettings()`](@/api/core.md#updatesettings) is invoked with any of the following configuration options: * - [`dropdownMenu`](@/api/options.md#dropdownmenu) */ updatePlugin(): void; /** * Disables the plugin functionality for this Handsontable instance. */ disablePlugin(): void; /** * Register shortcuts responsible for toggling dropdown menu. * * @private */ registerShortcuts(): void; /** * Unregister shortcuts responsible for toggling dropdown menu. * * @private */ unregisterShortcuts(): void; /** * Registers the DOM listeners. * * @private */ registerEvents(): void; /** * Opens the menu and positions it based on the passed coordinates. * * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties * (coordinates relative to the browser viewport, without scroll offsets), or a native browser * `Event` instance (e.g., a `MouseEvent`). * @param {{ above: number, below: number, left: number, right: number }} offset An object that applies * an offset to the menu position. * @fires Hooks#beforeDropdownMenuShow * @fires Hooks#afterDropdownMenuShow * @example * ```js * const menu = hot.getPlugin('dropdownMenu'); * * hot.selectCell(0, 0); * menu.open({ top: 50, left: 50 }); * ``` */ open(position: Record | Event, offset?: Record): void; /** * Closes dropdown menu. */ close(): void; /** * Executes context menu command. * * The `executeCommand()` method works only for selected cells. * * When no cells are selected, `executeCommand()` doesn't do anything. * * You can execute all predefined commands: * * `'col_left'` - Insert column left * * `'col_right'` - Insert column right * * `'clear_column'` - Clear selected column * * `'remove_col'` - Remove column * * `'undo'` - Undo last action * * `'redo'` - Redo last action * * `'make_read_only'` - Make cell read only * * `'alignment:left'` - Alignment to the left * * `'alignment:top'` - Alignment to the top * * `'alignment:right'` - Alignment to the right * * `'alignment:bottom'` - Alignment to the bottom * * `'alignment:middle'` - Alignment to the middle * * `'alignment:center'` - Alignment to the center (justify). * * Or you can execute command registered in settings where `key` is your command name. * * @param {string} commandName Command name to execute. * @param {*} params Additional parameters passed to the command executor. */ executeCommand(commandName: string, ...params: unknown[]): void; /** * Turns on / off listening on dropdown menu. * * @private * @param {boolean} listen Turn on listening when value is set to true, otherwise turn it off. */ setListening(listen?: boolean): void; /** * Destroys the plugin instance. */ destroy(): void; }