UNPKG

ag-grid-enterprise

Version:

Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue

150 lines (149 loc) 7.41 kB
import type { AgEvent, AgPromise, IComponent, IMenuItem, _AgComponent, _AgCoreBeanCollection, _BaseEvents, _BaseProperties, _IPropertiesService, _StopPropagationCallbacks, _WithoutCommon } from 'ag-grid-community'; import { _AgBeanStub } from 'ag-grid-community'; export interface AgMenuItemLeafDef<TMenuActionParams extends TCommon, TCommon> { /** Name of the menu item. */ name: string; /** Set to `true` to display the menu item as disabled. */ disabled?: boolean; /** * Shortcut text displayed inside menu item. * Setting this doesn’t actually create a keyboard shortcut binding. */ shortcut?: string; /** Function that gets executed when item is chosen. */ action?: (params: TMenuActionParams) => void; /** Set to true to provide a check beside the option. */ checked?: boolean; /** The icon to display, either a DOM element or HTML string. */ icon?: Element | string; /** CSS classes to apply to the menu item. */ cssClasses?: string[]; /** Tooltip text to be displayed for the menu item. */ tooltip?: string; /** * If `true`, will keep the menu open when the item is selected. * Note that if this item has a sub menu, * it will always remain open regardless of this property. */ suppressCloseOnSelect?: boolean; } export interface AgMenuItemDef<TMenuActionParams extends TCommon, TCommon> extends AgMenuItemLeafDef<TMenuActionParams, TCommon> { /** * If this item is a sub menu, contains a list of menu item definitions */ subMenu?: (AgMenuItemDef<TMenuActionParams, TCommon> | string)[]; /** * The aria role for the subMenu * @default 'menu' */ subMenuRole?: 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'; /** * Provide a custom menu item component. * See [Menu Item Component](https://www.ag-grid.com/javascript-data-grid/component-menu-item/#implementing-a-menu-item-component) for framework specific implementation details. */ menuItem?: any; /** * Parameters to be passed to the custom menu item component specified in `menuItem`. */ menuItemParams?: any; } export interface AgCloseMenuEvent extends AgEvent<'closeMenu'> { mouseEvent?: MouseEvent; keyboardEvent?: KeyboardEvent; } export interface AgMenuItemActivatedEvent<TBeanCollection extends _AgCoreBeanCollection<TProperties, TGlobalEvents, TCommon, TPropertiesService>, TProperties extends _BaseProperties, TGlobalEvents extends _BaseEvents, TCommon, TPropertiesService extends _IPropertiesService<TProperties, TCommon>, TComponentSelectorType extends string, TMenuActionParams extends TCommon> extends AgEvent<'menuItemActivated'> { menuItem: AgMenuItemComponent<TBeanCollection, TProperties, TGlobalEvents, TCommon, TPropertiesService, TComponentSelectorType, TMenuActionParams>; } interface AgMenuItemComponentParams<TMenuActionParams extends TCommon, TCommon> { menuItemDef: AgMenuItemDef<TMenuActionParams, TCommon>; isAnotherSubMenuOpen: () => boolean; level: number; childComponent?: IComponent<any>; contextParams: _WithoutCommon<TCommon, TMenuActionParams>; } export type AgMenuItemComponentEvent = 'closeMenu' | 'menuItemActivated'; export interface AgMenuItemParams<TMenuActionParams extends TCommon, TCommon> extends AgMenuItemDef<TMenuActionParams, TCommon> { /** Level within the menu tree (starts at 0). */ level: number; /** Returns `true` if another sub menu is open. */ isAnotherSubMenuOpen: () => boolean; /** * Open the sub menu for this item. * @param activateFirstItem If `true`, activate the first item in the sub menu. */ openSubMenu: (activateFirstItem?: boolean) => void; /** Close the sub menu for this item. */ closeSubMenu: () => void; /** Close the entire menu. */ closeMenu: (event?: KeyboardEvent | MouseEvent) => void; /** * Updates the grid-provided tooltip this component. * @param tooltip The value to be displayed by the tooltip * @param shouldDisplayTooltip A function returning a boolean that allows the tooltip to be displayed conditionally. This option does not work when `enableBrowserTooltips={true}`. */ updateTooltip: (tooltip?: string, shouldDisplayTooltip?: () => boolean) => void; /** * Callback to let the menu know that the current item has become active. * Required if updating the active status within the menu item. */ onItemActivated: () => void; } export interface AgMenuItemCallbacks<TBeanCollection, TMenuActionParams extends TCommon, TCommon> { getMenuItemComp: (beans: TBeanCollection, def: AgMenuItemDef<TMenuActionParams, TCommon>, params: AgMenuItemParams<TMenuActionParams, TCommon>) => AgPromise<(IComponent<AgMenuItemParams<TMenuActionParams, TCommon>> & IMenuItem) | undefined>; getPostProcessPopupParams: (contextParams: _WithoutCommon<TCommon, TMenuActionParams>) => any; preserveRangesWhile: (beans: TBeanCollection, fn: () => void) => void; stopPropagationCallbacks: _StopPropagationCallbacks; warnNoItem?: (menuItem: string) => void; } export declare class AgMenuItemComponent<TBeanCollection extends _AgCoreBeanCollection<TProperties, TGlobalEvents, TCommon, TPropertiesService>, TProperties extends _BaseProperties, TGlobalEvents extends _BaseEvents, TCommon, TPropertiesService extends _IPropertiesService<TProperties, TCommon>, TComponentSelectorType extends string, TMenuActionParams extends TCommon> extends _AgBeanStub<TBeanCollection, TProperties, TGlobalEvents, TCommon, TPropertiesService, AgMenuItemComponentEvent> { private readonly callbacks; private readonly ACTIVATION_DELAY; private eGui; private params; private isAnotherSubMenuOpen; private level; private childComponent?; private contextParams; private menuItemComp; private isActive; private hideSubMenu; private subMenuIsOpen; private subMenuIsOpening; private activateTimeoutId; private deactivateTimeoutId; private parentComponent?; private tooltip?; private tooltipFeature?; private suppressRootStyles; private suppressAria; private suppressFocus; private cssClassPrefix; private eSubMenuGui?; constructor(callbacks: AgMenuItemCallbacks<TBeanCollection, TMenuActionParams, TCommon>); init(params: AgMenuItemComponentParams<TMenuActionParams, TCommon>): AgPromise<void>; private addListeners; isDisabled(): boolean; openSubMenu(activateFirstItem?: boolean, event?: MouseEvent | KeyboardEvent): void; private setAriaExpanded; closeSubMenu(): void; isSubMenuOpen(): boolean; isSubMenuOpening(): boolean; activate(openSubMenu?: boolean, fromKeyNav?: boolean): void; deactivate(): void; getGui(): HTMLElement; getParentComponent(): _AgComponent<TBeanCollection, TProperties, TGlobalEvents, any> | undefined; setParentComponent(component: _AgComponent<TBeanCollection, TProperties, TGlobalEvents, any>): void; getSubMenuGui(): HTMLElement | undefined; private onItemSelected; private closeMenu; private onItemActivated; private cancelActivate; private cancelDeactivate; private onMouseEnter; private onMouseLeave; private refreshRootElementGui; private applyAriaProperties; private configureDefaults; private refreshTooltip; destroy(): void; } export {};