import React, { PureComponent } from 'react'; import { type CancelablePromise } from '@deephaven/utils'; import { type ContextAction, type ResolvableContextAction } from './ContextActionUtils'; interface ContextMenuProps { top: number; left: number; updatePosition: (top: number, left: number) => void; subMenuParentWidth: number; subMenuParentHeight: number; actions: ResolvableContextAction[]; closeMenu: (closeAll: boolean) => void; onMenuClosed: (menu: ContextMenu) => void; onMenuOpened: (menu: ContextMenu) => void; options: { doNotVerifyPosition?: boolean; separateKeyboardMouse?: boolean; initialKeyboardIndex?: number; }; menuStyle: React.CSSProperties; 'data-testid'?: string; } interface ContextMenuState { menuItems: ContextAction[]; pendingItems: CancelablePromise[]; activeSubMenu: number | null; hasOverflow: boolean; subMenuTop: number | null; subMenuLeft: number | null; subMenuParentWidth: number; subMenuParentHeight: number; keyboardIndex: number; mouseIndex: number; } /** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */ declare class ContextMenu extends PureComponent { static defaultProps: { subMenuParentWidth: number; subMenuParentHeight: number; closeMenu(): void; onMenuOpened(): void; onMenuClosed(): void; options: {}; menuStyle: {}; 'data-testid': undefined; }; static handleContextMenu(e: React.MouseEvent): void; constructor(props: ContextMenuProps); componentDidMount(): void; componentDidUpdate(prevProps: ContextMenuProps, prevState: ContextMenuState): void; componentWillUnmount(): void; container: React.RefObject; oldFocus: Element | null; activeSubMenuRef: React.RefObject; subMenuTimer: number; rAF: number; initialPosition: { top: number; left: number; }; getKeyboardIndex(): number; setKeyboardIndex(index: number): void; getMouseIndex(): number; setMouseIndex(index: number): void; initMenu(): void; initMenuPromise(promise: Promise): void; cancelPromises(): void; /** * Sets the unverfied start position of a submenu. Submenu then self-verfies * its own position and potentially reports back a new position. */ setActiveSubMenuPosition(): void; /** * Verifies the position of this menu in relation to the parent to make sure it's on screen. * Will update the top left state (updatePosition) if necessary (causing a re-render) * By default it tries to top-align with parent, at the right side of the parent. * Because we aren't a native context menu and can't escape window bounds, we also do * somethings to better fit on screen, such as the "nudge" offset position, and further * allow overflow scrolling for large menus in a small window. */ verifyPosition(): void; handleWindowResize(): void; handleBlur(e: React.FocusEvent): void; /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */ isEscapeKey(key: string): boolean; handleKeyDown(e: React.KeyboardEvent): void; openSubMenu(index: number): void; closeMenu(closeAll?: boolean): void; closeSubMenu(): void; handleCloseSubMenu(closeAllMenus: boolean): void; handleMenuItemClick(menuItem: ContextAction, e: React.MouseEvent): void; handleMenuItemContextMenu(menuItem: ContextAction, e: React.MouseEvent): void; handleMenuItemMouseMove(menuItem: ContextAction): void; handleMouseLeave(): void; render(): JSX.Element; } export default ContextMenu; //# sourceMappingURL=ContextMenu.d.ts.map