import { BindingEventService } from '@slickgrid-universal/binding'; import type { BasePubSubService } from '@slickgrid-universal/event-pub-sub'; import { SlickEventHandler, type SlickEventData, type SlickGrid } from '../core/index.js'; import type { CellMenu, Column, ColumnPicker, ColumnPickerOption, ContextMenu, DOMEvent, DOMMouseOrTouchEvent, GridMenu, GridMenuItem, GridMenuOption, GridOption, HeaderButton, HeaderButtonItem, HeaderMenu, MenuCommandItem, MenuOptionItem } from '../interfaces/index.js'; import type { SharedService } from '../services/shared.service.js'; import type { ExtensionUtility } from './extensionUtility.js'; export type ExtractMenuType = T extends 'command' ? A : T extends 'option' ? A : A extends 'divider' ? A : never; export type MenuType = 'command' | 'option'; /** @deprecated will be dropped in v11 */ export type MenuCommandOptionItem = MenuCommandItem | MenuOptionItem; export type ExtendableItemTypes = HeaderButtonItem | MenuCommandItem | MenuOptionItem | 'divider'; export type MenuPlugin = CellMenu | ContextMenu | GridMenu | HeaderMenu; export type itemEventCallback = (e: DOMMouseOrTouchEvent, type: MenuType, item: ExtractMenuType, level: number, columnDef?: Column) => void; export interface KeyboardNavigationOption { onActivate?: (focusedItem: HTMLElement) => void; onEscape?: () => void; onTab?: (evt: KeyboardEvent, focusedItem: HTMLElement) => void; eventServiceKey?: string; allItemsSelector?: string; focusedItemSelector?: string; } export declare class MenuBaseClass { protected readonly extensionUtility: ExtensionUtility; protected readonly pubSubService: BasePubSubService; protected readonly sharedService: SharedService; onColumnsChanged: any; protected _addonOptions: M; protected _areVisibleColumnDifferent: boolean; protected _bindEventService: BindingEventService; protected _camelPluginName: string; protected _columnCheckboxes: HTMLInputElement[]; protected _columns: Column[]; protected _columnTitleElm: HTMLDivElement; protected _commandTitleElm?: HTMLSpanElement; protected _eventHandler: SlickEventHandler; protected _gridUid: string; protected _listElm: HTMLElement; protected _menuElm?: HTMLDivElement | null; protected _menuCssPrefix: string; protected _menuPluginCssPrefix: string; /** @deprecated will be dropped in v11 */ protected _optionTitleElm?: HTMLSpanElement; protected _menuTriggerElement?: HTMLElement; protected _timer?: any; pluginName: string; /** Constructor of the SlickGrid 3rd party plugin, it can optionally receive options */ constructor(extensionUtility: ExtensionUtility, pubSubService: BasePubSubService, sharedService: SharedService); get addonOptions(): M; set addonOptions(newOptions: M); get eventHandler(): SlickEventHandler; get grid(): SlickGrid; get gridOptions(): GridOption; /** Getter for the grid uid */ get gridUid(): string; get gridUidSelector(): string; get menuCssClass(): string; get menuElement(): HTMLDivElement | null; /** Dispose (destroy) of the plugin */ dispose(): void; /** Remove/dispose all parent menus and any sub-menu(s) */ disposeAllMenus(): void; /** * Remove/dispose all previously opened sub-menu(s), * it will first remove all sub-menu listeners then remove sub-menus from the DOM */ disposeSubMenus(): void; setOptions(newOptions: M): void; protected get columnPickerMenuAddonOptions(): ColumnPicker | GridMenu; /** Create a Close button element and add it to the Menu element */ protected addCloseButtomElement(menuElm: HTMLDivElement): void; /** When columnTitle is provided, create a title element for the columns list. */ protected addColumnTitleElementWhenDefined(menuElm: HTMLDivElement): void; /** * Handle column picker item click for both SlickColumnPicker and SlickGridMenu controls. * @param event - input checkbox event */ protected handleColumnPickerItemClick(event: DOMEvent): void; /** * Because columns can be reordered, we have to update the `columns` to reflect the new order, however we can't just take `grid.getColumns()`, * as it does not include columns currently hidden by the picker. We create a new `columns` structure by leaving currently-hidden * columns in their original ordinal position and interleaving the results of the current column sort. */ protected updateColumnPickerOrder(): void; protected populateColumnPicker(addonOptions: ColumnPickerOption | GridMenuOption, defaultExtractor?: (column: Column, gridOptions?: GridOption) => string | HTMLElement | DocumentFragment): void; /** * add Menu Item Command when not found and also make sure that we have an `action` callback * (could be missing when provided by user) if not use built-in `action` callback when missing * @param originalMenuItems * @param builtInMenuItem * @param showCommand - is command hidden from menu option (deprecated) * @returns - returns true when added to the commands array */ protected addMissingCommandOrAction(builtInMenuItem: T | 'divider', hideCommands: string[] | undefined, targetMenuItems: Array, originalMenuItems?: Array): void; /** Focus the first focusable menu item after menu is opened */ protected focusFirstMenuItem(menuElm: HTMLElement): void; /** Set the menu trigger element for focus restoration when menu closes */ protected setMenuTriggerElement(triggerElement: HTMLElement): void; protected togglePickerCheckbox(iconElm: HTMLDivElement | null, checked?: boolean): void; protected generatePickerCheckbox(columnLiElm: HTMLLIElement, inputId: string, inputData: any, checked?: boolean): { inputElm: HTMLInputElement; labelElm: HTMLLabelElement; labelSpanElm: HTMLSpanElement; }; /** * Render slot content using a renderer callback. * The renderer receives the menu item and args for full context access. * @param parentElm - The parent element (LI) to insert the slot content into * @param slotRenderer - A callback function that receives (item, args) and returns string or HTMLElement * @param item - The menu item object (passed to callback) * @param args - The callback args providing access to grid, column, dataContext, etc. */ protected renderSlotRenderer(parentElm: HTMLElement, slotRenderer: (item: any, args: any) => string | HTMLElement, item: any, args: any): void; protected addSubMenuTitleWhenExists(item: ExtractMenuType, commandOrOptionMenu: HTMLDivElement): void; /** * @deprecated * not entirely deprecated, but I just want to rename the function since we'll be deprecating/removing `optionItems` in v11 * Construct the Command/Options Items section. */ protected populateCommandOrOptionItems(itemType: MenuType, menuOptions: M, commandOrOptionMenuElm: HTMLElement, commandOrOptionItems: Array>, args: unknown, triggeredByElm: HTMLElement, itemClickCallback: itemEventCallback, itemMouseoverCallback?: itemEventCallback, keyboardNavOptions?: KeyboardNavigationOption): void; /** @deprecated (same as above and rename the function in v11) Add the Command/Options Title when necessary. */ protected populateCommandOrOptionTitle(itemType: MenuType, menuOptions: M, commandOrOptionMenuElm: HTMLElement, level: number): void; /** @deprecated (same as above and rename the function in v11) Construct the Command/Options Items section. */ protected populateSingleCommandOrOptionItem(itemType: MenuType, menuOptions: M, commandOrOptionMenuElm: HTMLElement | null, item: ExtractMenuType, args: any, triggeredByElm: HTMLElement, itemClickCallback: itemEventCallback, itemMouseoverCallback?: itemEventCallback): HTMLLIElement | null; /** * Wire up keyboard navigation for the menu container using shared utility. * Should be called after menu DOM is created for all non-GridMenu plugins. * Handles sub-menu open/close and focus transfer for a11y. */ protected wireMenuKeyboardNavigation(menuElm: HTMLElement, options?: KeyboardNavigationOption): void; /** * Reposition any of the menu plugins (CellMenu, ContextMenu, GridMenu, HeaderMenu) to where the user clicked, * it will calculate the best position depending on available space in the viewport and the menu type. */ repositionMenu(e: DOMMouseOrTouchEvent | SlickEventData, menuElm: HTMLElement, buttonElm?: HTMLButtonElement, addonOptions?: GridMenu | CellMenu | ContextMenu | HeaderMenu): void; } //# sourceMappingURL=menuBaseClass.d.ts.map