@deephaven/components 0.22.3-beta.18 → 0.22.3-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/AutoCompleteInput.js +12 -85
  2. package/dist/AutoCompleteInput.js.map +1 -1
  3. package/dist/AutoResizeTextarea.d.ts +5 -5
  4. package/dist/AutoResizeTextarea.d.ts.map +1 -1
  5. package/dist/AutoResizeTextarea.js +8 -23
  6. package/dist/AutoResizeTextarea.js.map +1 -1
  7. package/dist/BasicModal.d.ts +28 -1
  8. package/dist/BasicModal.d.ts.map +1 -1
  9. package/dist/BasicModal.js +2 -8
  10. package/dist/BasicModal.js.map +1 -1
  11. package/dist/Button.js +8 -34
  12. package/dist/Button.js.map +1 -1
  13. package/dist/ButtonGroup.d.ts +6 -6
  14. package/dist/ButtonGroup.d.ts.map +1 -1
  15. package/dist/ButtonGroup.js +2 -4
  16. package/dist/ButtonGroup.js.map +1 -1
  17. package/dist/ButtonOld.js.map +1 -1
  18. package/dist/CardFlip.d.ts +1 -1
  19. package/dist/CardFlip.d.ts.map +1 -1
  20. package/dist/CardFlip.js +2 -7
  21. package/dist/CardFlip.js.map +1 -1
  22. package/dist/Checkbox.js +3 -14
  23. package/dist/Checkbox.js.map +1 -1
  24. package/dist/Collapse.js +0 -15
  25. package/dist/Collapse.js.map +1 -1
  26. package/dist/ComboBox.js +4 -83
  27. package/dist/ComboBox.js.map +1 -1
  28. package/dist/CopyButton.d.ts +1 -1
  29. package/dist/CopyButton.d.ts.map +1 -1
  30. package/dist/CopyButton.js +2 -4
  31. package/dist/CopyButton.js.map +1 -1
  32. package/dist/CustomTimeSelect.js +2 -86
  33. package/dist/CustomTimeSelect.js.map +1 -1
  34. package/dist/DateInput.js.map +1 -1
  35. package/dist/DateInputUtils.js +0 -7
  36. package/dist/DateInputUtils.js.map +1 -1
  37. package/dist/DateTimeInput.js +7 -10
  38. package/dist/DateTimeInput.js.map +1 -1
  39. package/dist/DebouncedSearchInput.js +0 -14
  40. package/dist/DebouncedSearchInput.js.map +1 -1
  41. package/dist/DragUtils.js +4 -16
  42. package/dist/DragUtils.js.map +1 -1
  43. package/dist/DraggableItemList.d.ts.map +1 -1
  44. package/dist/DraggableItemList.js +22 -44
  45. package/dist/DraggableItemList.js.map +1 -1
  46. package/dist/EditableItemList.d.ts +1 -1
  47. package/dist/EditableItemList.d.ts.map +1 -1
  48. package/dist/EditableItemList.js +2 -6
  49. package/dist/EditableItemList.js.map +1 -1
  50. package/dist/HierarchicalCheckboxMenu.js +6 -28
  51. package/dist/HierarchicalCheckboxMenu.js.map +1 -1
  52. package/dist/ItemList.d.ts.map +1 -1
  53. package/dist/ItemList.js +22 -115
  54. package/dist/ItemList.js.map +1 -1
  55. package/dist/ItemListItem.d.ts +0 -1
  56. package/dist/ItemListItem.d.ts.map +1 -1
  57. package/dist/ItemListItem.js +26 -50
  58. package/dist/ItemListItem.js.map +1 -1
  59. package/dist/LoadingOverlay.d.ts +1 -1
  60. package/dist/LoadingOverlay.d.ts.map +1 -1
  61. package/dist/LoadingOverlay.js +3 -5
  62. package/dist/LoadingOverlay.js.map +1 -1
  63. package/dist/LoadingSpinner.d.ts +1 -1
  64. package/dist/LoadingSpinner.d.ts.map +1 -1
  65. package/dist/LoadingSpinner.js +2 -4
  66. package/dist/LoadingSpinner.js.map +1 -1
  67. package/dist/MaskedInput.js +26 -85
  68. package/dist/MaskedInput.js.map +1 -1
  69. package/dist/Option.d.ts +1 -1
  70. package/dist/Option.d.ts.map +1 -1
  71. package/dist/Option.js +2 -4
  72. package/dist/Option.js.map +1 -1
  73. package/dist/RadioGroup.d.ts +1 -1
  74. package/dist/RadioGroup.d.ts.map +1 -1
  75. package/dist/RadioGroup.js +4 -6
  76. package/dist/RadioGroup.js.map +1 -1
  77. package/dist/RadioItem.js +0 -1
  78. package/dist/RadioItem.js.map +1 -1
  79. package/dist/SearchInput.js +2 -13
  80. package/dist/SearchInput.js.map +1 -1
  81. package/dist/Select.d.ts +1 -1
  82. package/dist/Select.d.ts.map +1 -1
  83. package/dist/Select.js +2 -4
  84. package/dist/Select.js.map +1 -1
  85. package/dist/SelectValueList.js +0 -28
  86. package/dist/SelectValueList.js.map +1 -1
  87. package/dist/SocketedButton.js.map +1 -1
  88. package/dist/ThemeExport.js +0 -4
  89. package/dist/ThemeExport.js.map +1 -1
  90. package/dist/TimeInput.js +2 -12
  91. package/dist/TimeInput.js.map +1 -1
  92. package/dist/TimeSlider.d.ts +1 -1
  93. package/dist/TimeSlider.d.ts.map +1 -1
  94. package/dist/TimeSlider.js +19 -33
  95. package/dist/TimeSlider.js.map +1 -1
  96. package/dist/ToastNotification.d.ts +4 -4
  97. package/dist/ToastNotification.d.ts.map +1 -1
  98. package/dist/ToastNotification.js +2 -4
  99. package/dist/ToastNotification.js.map +1 -1
  100. package/dist/UISwitch.d.ts +1 -1
  101. package/dist/UISwitch.d.ts.map +1 -1
  102. package/dist/UISwitch.js +2 -4
  103. package/dist/UISwitch.js.map +1 -1
  104. package/dist/ValidateLabelInput.d.ts.map +1 -1
  105. package/dist/ValidateLabelInput.js +3 -3
  106. package/dist/ValidateLabelInput.js.map +1 -1
  107. package/dist/context-actions/ContextActionUtils.js +9 -40
  108. package/dist/context-actions/ContextActionUtils.js.map +1 -1
  109. package/dist/context-actions/ContextActions.js +1 -34
  110. package/dist/context-actions/ContextActions.js.map +1 -1
  111. package/dist/context-actions/ContextMenu.js +29 -110
  112. package/dist/context-actions/ContextMenu.js.map +1 -1
  113. package/dist/context-actions/ContextMenuItem.d.ts.map +1 -1
  114. package/dist/context-actions/ContextMenuItem.js +3 -19
  115. package/dist/context-actions/ContextMenuItem.js.map +1 -1
  116. package/dist/context-actions/ContextMenuRoot.js +7 -26
  117. package/dist/context-actions/ContextMenuRoot.js.map +1 -1
  118. package/dist/context-actions/GlobalContextAction.js +0 -15
  119. package/dist/context-actions/GlobalContextAction.js.map +1 -1
  120. package/dist/context-actions/GlobalContextActions.js +0 -6
  121. package/dist/context-actions/GlobalContextActions.js.map +1 -1
  122. package/dist/context-actions/index.js.map +1 -1
  123. package/dist/index.js.map +1 -1
  124. package/dist/menu-actions/DropdownMenu.js +4 -32
  125. package/dist/menu-actions/DropdownMenu.js.map +1 -1
  126. package/dist/menu-actions/Menu.js +7 -52
  127. package/dist/menu-actions/Menu.js.map +1 -1
  128. package/dist/menu-actions/index.d.ts +2 -1
  129. package/dist/menu-actions/index.d.ts.map +1 -1
  130. package/dist/menu-actions/index.js +2 -2
  131. package/dist/menu-actions/index.js.map +1 -1
  132. package/dist/modal/Modal.d.ts +2 -2
  133. package/dist/modal/Modal.d.ts.map +1 -1
  134. package/dist/modal/Modal.js +3 -9
  135. package/dist/modal/Modal.js.map +1 -1
  136. package/dist/modal/ModalBody.d.ts +1 -1
  137. package/dist/modal/ModalBody.d.ts.map +1 -1
  138. package/dist/modal/ModalBody.js +2 -4
  139. package/dist/modal/ModalBody.js.map +1 -1
  140. package/dist/modal/ModalFooter.d.ts +1 -1
  141. package/dist/modal/ModalFooter.d.ts.map +1 -1
  142. package/dist/modal/ModalFooter.js +2 -4
  143. package/dist/modal/ModalFooter.js.map +1 -1
  144. package/dist/modal/ModalHeader.d.ts +1 -1
  145. package/dist/modal/ModalHeader.d.ts.map +1 -1
  146. package/dist/modal/ModalHeader.js +2 -4
  147. package/dist/modal/ModalHeader.js.map +1 -1
  148. package/dist/modal/index.js.map +1 -1
  149. package/dist/navigation/Menu.d.ts +1 -1
  150. package/dist/navigation/Menu.d.ts.map +1 -1
  151. package/dist/navigation/Menu.js +2 -2
  152. package/dist/navigation/Menu.js.map +1 -1
  153. package/dist/navigation/MenuItem.d.ts +1 -1
  154. package/dist/navigation/MenuItem.d.ts.map +1 -1
  155. package/dist/navigation/MenuItem.js +4 -7
  156. package/dist/navigation/MenuItem.js.map +1 -1
  157. package/dist/navigation/Page.d.ts +1 -1
  158. package/dist/navigation/Page.d.ts.map +1 -1
  159. package/dist/navigation/Page.js +2 -3
  160. package/dist/navigation/Page.js.map +1 -1
  161. package/dist/navigation/Stack.d.ts +1 -1
  162. package/dist/navigation/Stack.d.ts.map +1 -1
  163. package/dist/navigation/Stack.js +3 -6
  164. package/dist/navigation/Stack.js.map +1 -1
  165. package/dist/navigation/index.js.map +1 -1
  166. package/dist/popper/Popper.d.ts.map +1 -1
  167. package/dist/popper/Popper.js +13 -46
  168. package/dist/popper/Popper.js.map +1 -1
  169. package/dist/popper/Tooltip.js +0 -56
  170. package/dist/popper/Tooltip.js.map +1 -1
  171. package/dist/popper/index.js.map +1 -1
  172. package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
  173. package/dist/shortcuts/Shortcut.js +19 -76
  174. package/dist/shortcuts/Shortcut.js.map +1 -1
  175. package/dist/shortcuts/ShortcutRegistry.js +3 -18
  176. package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
  177. package/dist/shortcuts/index.js.map +1 -1
  178. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenu.js","names":["React","PureComponent","classNames","Log","PromiseUtils","ContextActionUtils","ContextMenuItem","LoadingSpinner","log","module","ContextMenu","handleContextMenu","e","metaKey","stopPropagation","preventDefault","constructor","props","handleBlur","bind","handleCloseSubMenu","handleKeyDown","handleMenuItemClick","handleMenuItemContextMenu","handleMenuItemMouseMove","handleMouseLeave","handleWindowResize","container","createRef","oldFocus","document","activeElement","activeSubMenuRef","subMenuTimer","rAF","initialPosition","top","left","state","menuItems","pendingItems","activeSubMenu","hasOverflow","subMenuTop","subMenuLeft","subMenuParentWidth","subMenuParentHeight","keyboardIndex","mouseIndex","componentDidMount","initMenu","verifyPosition","window","addEventListener","requestAnimationFrame","current","focus","onMenuOpened","componentDidUpdate","prevProps","prevState","actions","setActiveSubMenuPosition","contains","componentWillUnmount","cancelPromises","removeEventListener","cancelAnimationFrame","getKeyboardIndex","options","separateKeyboardMouse","undefined","getMouseIndex","setKeyboardIndex","index","setState","setMouseIndex","initialKeyboardIndex","getMenuItems","nonPromiseItems","i","length","menuItem","Promise","initMenuPromise","push","sortActions","promise","cancellablePromise","makeCancelable","concat","then","resolvedMenuItems","indexOf","slice","splice","error","isCanceled","map","item","cancel","parentRect","getBoundingClientRect","right","height","width","updatePosition","oldTop","oldLeft","doNotVerifyPosition","scrollHeight","innerHeight","innerWidth","closeMenu","warn","relatedTarget","element","isContextMenuChild","hasAttribute","parentElement","isEscapeKey","key","newFocus","openSubMenu","shiftKey","getNextMenuItem","HTMLElement","newSubMenu","closeAll","onMenuClosed","closeSubMenu","closeAllMenus","disabled","action","focusIndex","render","menuItemElements","group","menuItemElement","pendingElement","menuStyle","dataTestId","showSubmenu","verifiedTop","verifiedLeft"],"sources":["../../src/context-actions/ContextMenu.tsx"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport classNames from 'classnames';\nimport Log from '@deephaven/log';\nimport { PromiseUtils, CancelablePromise } from '@deephaven/utils';\nimport ContextActionUtils, {\n ContextAction,\n ResolvableContextAction,\n} from './ContextActionUtils';\nimport ContextMenuItem from './ContextMenuItem';\nimport LoadingSpinner from '../LoadingSpinner';\n\nconst log = Log.module('ContextMenu');\n\ninterface ContextMenuProps {\n top: number;\n left: number;\n updatePosition(top: number, left: number): void;\n // only submenus will have these, defaults to 0 otherwise\n // represents the width height of the parent menu item\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n actions: ResolvableContextAction[];\n closeMenu(closeAll: boolean): void;\n onMenuClosed(menu: ContextMenu): void;\n onMenuOpened(menu: ContextMenu): void;\n options: {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n };\n menuStyle: React.CSSProperties;\n 'data-testid'?: string;\n}\n\ninterface ContextMenuState {\n menuItems: ContextAction[];\n pendingItems: CancelablePromise<ContextAction[]>[];\n activeSubMenu: number | null;\n hasOverflow: boolean;\n subMenuTop: number | null;\n subMenuLeft: number | null;\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n keyboardIndex: number;\n mouseIndex: number;\n}\n\n/** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */\nclass ContextMenu extends PureComponent<ContextMenuProps, ContextMenuState> {\n static defaultProps = {\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n closeMenu(): void {\n // no-op\n },\n onMenuOpened(): void {\n // no-op\n },\n onMenuClosed(): void {\n // no-op\n },\n options: {},\n menuStyle: {},\n 'data-testid': undefined,\n };\n\n static handleContextMenu(e: React.MouseEvent): void {\n if (e.metaKey) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n constructor(props: ContextMenuProps) {\n super(props);\n\n this.handleBlur = this.handleBlur.bind(this);\n this.handleCloseSubMenu = this.handleCloseSubMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemContextMenu = this.handleMenuItemContextMenu.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleWindowResize = this.handleWindowResize.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.activeSubMenuRef = React.createRef();\n this.subMenuTimer = 0;\n this.rAF = 0;\n\n this.initialPosition = { top: props.top, left: props.left };\n\n this.state = {\n menuItems: [],\n pendingItems: [],\n activeSubMenu: null,\n hasOverflow: false,\n subMenuTop: null,\n subMenuLeft: null,\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n keyboardIndex: -1,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.verifyPosition();\n\n window.addEventListener('resize', this.handleWindowResize);\n\n // rAF is needed to wait for a submenus popper to be created before\n // attempting to set focus, however on a quick mount/unmount when\n // mousing past an item, the submenu could be unmounted before the\n // async rAF finishes, so it is cancelled in willUnmount()\n this.rAF = window.requestAnimationFrame(() => {\n this.container.current?.focus();\n\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(\n prevProps: ContextMenuProps,\n prevState: ContextMenuState\n ): void {\n const { actions } = this.props;\n const { activeSubMenu } = this.state;\n\n if (activeSubMenu !== prevState.activeSubMenu) {\n if (activeSubMenu == null) {\n // close sub menu, refocus parent menu\n this.container.current?.focus();\n } else {\n // open sub menu, set its initial position\n this.setActiveSubMenuPosition();\n }\n }\n\n if (prevProps.actions !== actions) {\n this.initMenu();\n\n if (\n this.container.current == null ||\n !this.container.current.contains(document.activeElement)\n ) {\n this.container.current?.focus();\n }\n }\n\n this.verifyPosition();\n }\n\n componentWillUnmount(): void {\n this.cancelPromises();\n window.removeEventListener('resize', this.handleWindowResize);\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n activeSubMenuRef: React.RefObject<HTMLDivElement>;\n\n subMenuTimer: number;\n\n rAF: number;\n\n initialPosition: { top: number; left: number };\n\n getKeyboardIndex(): number {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n const { keyboardIndex } = this.state;\n return keyboardIndex;\n }\n\n return this.getMouseIndex();\n }\n\n setKeyboardIndex(index: number): void {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n this.setState({ keyboardIndex: index });\n } else {\n this.setMouseIndex(index);\n }\n }\n\n getMouseIndex(): number {\n const { mouseIndex } = this.state;\n return mouseIndex;\n }\n\n setMouseIndex(index: number): void {\n this.setState({ mouseIndex: index });\n }\n\n initMenu(): void {\n // cancel any pending close and promises\n this.cancelPromises();\n cancelAnimationFrame(this.rAF);\n\n const { options } = this.props;\n let keyboardIndex = options.initialKeyboardIndex;\n if (keyboardIndex === undefined) {\n keyboardIndex = -1;\n }\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions);\n const nonPromiseItems: ContextAction[] = [];\n for (let i = menuItems.length - 1; i >= 0; i -= 1) {\n const menuItem = menuItems[i];\n if (menuItem instanceof Promise) {\n this.initMenuPromise(menuItem as Promise<ContextAction[]>);\n } else {\n nonPromiseItems.push(menuItem as ContextAction);\n }\n }\n\n this.setState({\n mouseIndex: -1,\n keyboardIndex,\n activeSubMenu: null,\n menuItems: ContextActionUtils.sortActions(nonPromiseItems),\n });\n }\n\n initMenuPromise(promise: Promise<ContextAction[]>): void {\n // make all promises cancellable\n const cancellablePromise = PromiseUtils.makeCancelable(promise);\n\n this.setState(state => ({\n pendingItems: state.pendingItems.concat(cancellablePromise),\n }));\n\n cancellablePromise.then(\n resolvedMenuItems => {\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n\n return {\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(resolvedMenuItems)\n ),\n pendingItems,\n };\n }\n // This item is stale, don't update the menu\n return null;\n });\n },\n error => {\n if (PromiseUtils.isCanceled(error)) {\n return; // Canceled promise is ignored\n }\n\n // remove failed item from pending list\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n return {\n pendingItems,\n };\n }\n return null;\n });\n\n // Log the error\n log.error(error);\n }\n );\n }\n\n cancelPromises(): void {\n const { pendingItems } = this.state;\n pendingItems.map(item => item.cancel());\n }\n\n /**\n * Sets the unverfied start position of a submenu. Submenu then self-verfies\n * its own position and potentially reports back a new position.\n */\n setActiveSubMenuPosition(): void {\n if (this.activeSubMenuRef.current === null) return;\n const parentRect = this.activeSubMenuRef.current.getBoundingClientRect();\n\n // intentionally rect.right, we want the sub menu to start at the right edge of the current menu\n this.setState({\n subMenuTop: parentRect.top,\n subMenuLeft: parentRect.right,\n subMenuParentHeight: parentRect.height,\n subMenuParentWidth: parentRect.width,\n });\n }\n\n /**\n * Verifies the position of this menu in relation to the parent to make sure it's on screen.\n * Will update the top left state (updatePosition) if necessary (causing a re-render)\n * By default it tries to top-align with parent, at the right side of the parent.\n * Because we aren't a native context menu and can't escape window bounds, we also do\n * somethings to better fit on screen, such as the \"nudge\" offset position, and further\n * allow overflow scrolling for large menus in a small window.\n */\n verifyPosition(): void {\n const {\n options,\n updatePosition,\n subMenuParentWidth,\n subMenuParentHeight,\n top: oldTop,\n left: oldLeft,\n } = this.props;\n\n if (\n !this.container.current ||\n (options.doNotVerifyPosition != null && options.doNotVerifyPosition)\n ) {\n return;\n }\n\n // initial position is used rather than current position,\n // as the number of menu items can change (actions can bubble)\n // and menu should always be positioned relative to spawn point\n let { top, left } = this.initialPosition;\n const {\n width,\n height,\n } = this.container.current?.getBoundingClientRect() ?? {\n width: 0,\n height: 0,\n };\n const hasOverflow =\n (this.container.current?.scrollHeight ?? 0) > window.innerHeight;\n\n if (height === 0 || width === 0) {\n // We don't have a height or width yet, don't bother doing anything\n return;\n }\n\n // does it fit below?\n if (top + height > window.innerHeight) {\n // can it be flipped to above? include offset if submenu (defaults to 0 if not submenu)\n if (top - height - subMenuParentHeight > 0) {\n // flip like a native menu would\n top -= height - subMenuParentHeight;\n } else {\n // still doesnt fit? okay, position at bottom edge\n top = window.innerHeight - height;\n }\n }\n\n if (left + width > window.innerWidth) {\n // less picky about left right positioning, just keep it going off to right\n left = left - width - subMenuParentWidth;\n }\n\n if (oldLeft !== left || oldTop !== top) {\n // parent owns positioning as single source of truth, ask to update props\n this.setState({ hasOverflow });\n updatePosition(top, left);\n }\n }\n\n // since window resize doesn't trigger blur, listen and close the menu\n handleWindowResize(): void {\n if (!this.container.current) {\n return;\n }\n this.closeMenu(true);\n }\n\n handleBlur(e: React.FocusEvent<HTMLDivElement>): void {\n if (!this.container.current) {\n log.warn('Container is null!');\n return;\n }\n\n if (!this.container.current.contains(e.relatedTarget as Node)) {\n let element: HTMLElement | null = e.relatedTarget as HTMLElement;\n let isContextMenuChild = false;\n while (element && !isContextMenuChild) {\n isContextMenuChild = element.hasAttribute('data-dh-context-menu');\n element = element.parentElement;\n }\n\n if (!isContextMenuChild) {\n // close all submenus on blur\n this.closeMenu(true);\n }\n }\n }\n\n /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */\n isEscapeKey(key: string): boolean {\n const { left } = this.props;\n return (\n key === 'Escape' ||\n (left < 0 && key === 'ArrowRight') ||\n key === 'ArrowLeft'\n );\n }\n\n handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus: number | null = oldFocus;\n let openSubMenu = false;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(\n menuItems[oldFocus],\n (e as React.SyntheticEvent) as React.MouseEvent\n );\n }\n return;\n }\n\n if (e.key === 'ArrowRight') {\n if (oldFocus >= 0 && oldFocus <= menuItems.length) {\n openSubMenu = true;\n } else {\n newFocus = 0;\n }\n } else if (this.isEscapeKey(e.key)) {\n newFocus = null;\n } else if (e.key === 'ArrowUp' || (e.shiftKey && e.key === 'Tab')) {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, -1, menuItems);\n } else if (e.key === 'ArrowDown' || e.key === 'Tab') {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, 1, menuItems);\n }\n\n if (openSubMenu) {\n this.openSubMenu(oldFocus);\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n if (oldFocus !== newFocus) {\n if (newFocus !== null) {\n this.setKeyboardIndex(newFocus);\n } else {\n this.closeMenu();\n if (this.oldFocus instanceof HTMLElement) {\n this.oldFocus.focus();\n }\n }\n\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n openSubMenu(index: number): void {\n const { menuItems, activeSubMenu } = this.state;\n const newSubMenu = menuItems[index].actions ? index : null;\n if (activeSubMenu === newSubMenu) return;\n this.setState({\n activeSubMenu: newSubMenu,\n subMenuTop: null,\n subMenuLeft: null,\n });\n }\n\n closeMenu(closeAll = false): void {\n const { closeMenu, onMenuClosed } = this.props;\n cancelAnimationFrame(this.rAF);\n this.rAF = window.requestAnimationFrame(() => {\n closeMenu(closeAll);\n onMenuClosed(this);\n });\n }\n\n closeSubMenu(): void {\n this.setState({\n activeSubMenu: null,\n });\n }\n\n handleCloseSubMenu(closeAllMenus: boolean): void {\n if (closeAllMenus) {\n this.closeMenu(true);\n } else {\n this.closeSubMenu();\n }\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n const { menuItems } = this.state;\n if (\n menuItem != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n if (menuItem.actions != null) {\n this.openSubMenu(menuItems.indexOf(menuItem));\n } else if (menuItem.action != null) {\n menuItem.action();\n this.closeMenu(true);\n }\n }\n }\n\n handleMenuItemContextMenu(\n menuItem: ContextAction,\n e: React.MouseEvent\n ): void {\n if (e.metaKey) {\n return;\n }\n\n this.handleMenuItemClick(menuItem, e);\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n\n if (\n focusIndex >= 0 &&\n focusIndex < menuItems.length &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n this.openSubMenu(focusIndex);\n }\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { top, left } = this.props;\n const {\n activeSubMenu,\n hasOverflow,\n keyboardIndex,\n menuItems,\n mouseIndex,\n pendingItems,\n subMenuTop,\n subMenuLeft,\n subMenuParentWidth,\n subMenuParentHeight,\n } = this.state;\n for (let i = 0; i < menuItems.length; i += 1) {\n const menuItem = menuItems[i];\n\n if (i > 0 && menuItem.group !== menuItems[i - 1].group) {\n menuItemElements.push(<hr key={`${i}.separator`} />);\n }\n\n const menuItemElement = (\n <ContextMenuItem\n key={i}\n ref={activeSubMenu === i ? this.activeSubMenuRef : null}\n isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseSubMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={this.handleMenuItemContextMenu}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n let pendingElement = null;\n if (pendingItems.length > 0) {\n pendingElement = (\n <div className=\"loading\">\n <LoadingSpinner />\n </div>\n );\n }\n\n const { menuStyle, 'data-testid': dataTestId } = this.props;\n\n // don't show submenu until it has an position initialized\n const showSubmenu =\n activeSubMenu !== null && subMenuTop !== null && subMenuLeft !== null;\n\n return (\n <>\n <div\n className={classNames(\n { 'has-overflow': hasOverflow },\n 'context-menu-container'\n )}\n style={{ top, left, ...menuStyle }}\n ref={this.container}\n data-dh-context-menu\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n onContextMenu={ContextMenu.handleContextMenu}\n role=\"menuitem\"\n tabIndex={0}\n data-testid={dataTestId}\n >\n {menuItemElements}\n {pendingElement}\n </div>\n {showSubmenu &&\n activeSubMenu !== null &&\n subMenuTop !== null &&\n subMenuLeft !== null && (\n <ContextMenu\n key={`sub-${activeSubMenu}`}\n actions={menuItems[activeSubMenu].actions || []}\n closeMenu={this.handleCloseSubMenu}\n top={subMenuTop}\n left={subMenuLeft}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({\n subMenuTop: verifiedTop,\n subMenuLeft: verifiedLeft,\n });\n }}\n subMenuParentWidth={subMenuParentWidth}\n subMenuParentHeight={subMenuParentHeight}\n />\n )}\n </>\n );\n }\n}\n\nexport default ContextMenu;\n"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,SAASC,YAAT,QAAgD,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KrE,QAAL,CAAc;UACZhC,UAAU,EAAEoG,WADA;UAEZnG,WAAW,EAAEoG;QAFD,CAAd;MAID,CAXH;MAYE,kBAAkB,EAAEnG,kBAZtB;MAaE,mBAAmB,EAAEC;IAbvB,EAxBN,CADF;EA2CD;;AA5lByE;;gBAAtEpC,W,kBACkB;EACpBmC,kBAAkB,EAAE,CADA;EAEpBC,mBAAmB,EAAE,CAFD;;EAGpBmE,SAAS,GAAS,CAChB;EACD,CALmB;;EAMpBxD,YAAY,GAAS,CACnB;EACD,CARmB;;EASpBwE,YAAY,GAAS,CACnB;EACD,CAXmB;;EAYpB5D,OAAO,EAAE,EAZW;EAapBuE,SAAS,EAAE,EAbS;EAcpB,eAAerE;AAdK,C;;AA8lBxB,eAAe7D,WAAf"}
1
+ {"version":3,"file":"ContextMenu.js","names":["React","PureComponent","classNames","Log","PromiseUtils","ContextActionUtils","ContextMenuItem","LoadingSpinner","log","module","ContextMenu","handleContextMenu","e","metaKey","stopPropagation","preventDefault","constructor","props","handleBlur","bind","handleCloseSubMenu","handleKeyDown","handleMenuItemClick","handleMenuItemContextMenu","handleMenuItemMouseMove","handleMouseLeave","handleWindowResize","container","createRef","oldFocus","document","activeElement","activeSubMenuRef","subMenuTimer","rAF","initialPosition","top","left","state","menuItems","pendingItems","activeSubMenu","hasOverflow","subMenuTop","subMenuLeft","subMenuParentWidth","subMenuParentHeight","keyboardIndex","mouseIndex","componentDidMount","initMenu","verifyPosition","window","addEventListener","requestAnimationFrame","current","focus","onMenuOpened","componentDidUpdate","prevProps","prevState","actions","setActiveSubMenuPosition","contains","componentWillUnmount","cancelPromises","removeEventListener","cancelAnimationFrame","getKeyboardIndex","options","separateKeyboardMouse","undefined","getMouseIndex","setKeyboardIndex","index","setState","setMouseIndex","initialKeyboardIndex","getMenuItems","nonPromiseItems","i","length","menuItem","Promise","initMenuPromise","push","sortActions","promise","cancellablePromise","makeCancelable","concat","then","resolvedMenuItems","indexOf","slice","splice","error","isCanceled","map","item","cancel","parentRect","getBoundingClientRect","right","height","width","updatePosition","oldTop","oldLeft","doNotVerifyPosition","scrollHeight","innerHeight","innerWidth","closeMenu","warn","relatedTarget","element","isContextMenuChild","hasAttribute","parentElement","isEscapeKey","key","newFocus","openSubMenu","shiftKey","getNextMenuItem","HTMLElement","newSubMenu","closeAll","onMenuClosed","closeSubMenu","closeAllMenus","disabled","action","focusIndex","render","menuItemElements","group","menuItemElement","pendingElement","menuStyle","dataTestId","showSubmenu","verifiedTop","verifiedLeft"],"sources":["../../src/context-actions/ContextMenu.tsx"],"sourcesContent":["import React, { PureComponent } from 'react';\nimport classNames from 'classnames';\nimport Log from '@deephaven/log';\nimport { PromiseUtils, CancelablePromise } from '@deephaven/utils';\nimport ContextActionUtils, {\n ContextAction,\n ResolvableContextAction,\n} from './ContextActionUtils';\nimport ContextMenuItem from './ContextMenuItem';\nimport LoadingSpinner from '../LoadingSpinner';\n\nconst log = Log.module('ContextMenu');\n\ninterface ContextMenuProps {\n top: number;\n left: number;\n updatePosition(top: number, left: number): void;\n // only submenus will have these, defaults to 0 otherwise\n // represents the width height of the parent menu item\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n actions: ResolvableContextAction[];\n closeMenu(closeAll: boolean): void;\n onMenuClosed(menu: ContextMenu): void;\n onMenuOpened(menu: ContextMenu): void;\n options: {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n };\n menuStyle: React.CSSProperties;\n 'data-testid'?: string;\n}\n\ninterface ContextMenuState {\n menuItems: ContextAction[];\n pendingItems: CancelablePromise<ContextAction[]>[];\n activeSubMenu: number | null;\n hasOverflow: boolean;\n subMenuTop: number | null;\n subMenuLeft: number | null;\n subMenuParentWidth: number;\n subMenuParentHeight: number;\n keyboardIndex: number;\n mouseIndex: number;\n}\n\n/** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */\nclass ContextMenu extends PureComponent<ContextMenuProps, ContextMenuState> {\n static defaultProps = {\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n closeMenu(): void {\n // no-op\n },\n onMenuOpened(): void {\n // no-op\n },\n onMenuClosed(): void {\n // no-op\n },\n options: {},\n menuStyle: {},\n 'data-testid': undefined,\n };\n\n static handleContextMenu(e: React.MouseEvent): void {\n if (e.metaKey) {\n return;\n }\n\n e.stopPropagation();\n e.preventDefault();\n }\n\n constructor(props: ContextMenuProps) {\n super(props);\n\n this.handleBlur = this.handleBlur.bind(this);\n this.handleCloseSubMenu = this.handleCloseSubMenu.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemContextMenu = this.handleMenuItemContextMenu.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleWindowResize = this.handleWindowResize.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.activeSubMenuRef = React.createRef();\n this.subMenuTimer = 0;\n this.rAF = 0;\n\n this.initialPosition = { top: props.top, left: props.left };\n\n this.state = {\n menuItems: [],\n pendingItems: [],\n activeSubMenu: null,\n hasOverflow: false,\n subMenuTop: null,\n subMenuLeft: null,\n subMenuParentWidth: 0,\n subMenuParentHeight: 0,\n keyboardIndex: -1,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.verifyPosition();\n\n window.addEventListener('resize', this.handleWindowResize);\n\n // rAF is needed to wait for a submenus popper to be created before\n // attempting to set focus, however on a quick mount/unmount when\n // mousing past an item, the submenu could be unmounted before the\n // async rAF finishes, so it is cancelled in willUnmount()\n this.rAF = window.requestAnimationFrame(() => {\n this.container.current?.focus();\n\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(\n prevProps: ContextMenuProps,\n prevState: ContextMenuState\n ): void {\n const { actions } = this.props;\n const { activeSubMenu } = this.state;\n\n if (activeSubMenu !== prevState.activeSubMenu) {\n if (activeSubMenu == null) {\n // close sub menu, refocus parent menu\n this.container.current?.focus();\n } else {\n // open sub menu, set its initial position\n this.setActiveSubMenuPosition();\n }\n }\n\n if (prevProps.actions !== actions) {\n this.initMenu();\n\n if (\n this.container.current == null ||\n !this.container.current.contains(document.activeElement)\n ) {\n this.container.current?.focus();\n }\n }\n\n this.verifyPosition();\n }\n\n componentWillUnmount(): void {\n this.cancelPromises();\n window.removeEventListener('resize', this.handleWindowResize);\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n activeSubMenuRef: React.RefObject<HTMLDivElement>;\n\n subMenuTimer: number;\n\n rAF: number;\n\n initialPosition: { top: number; left: number };\n\n getKeyboardIndex(): number {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n const { keyboardIndex } = this.state;\n return keyboardIndex;\n }\n\n return this.getMouseIndex();\n }\n\n setKeyboardIndex(index: number): void {\n const { options } = this.props;\n if (\n options.separateKeyboardMouse !== undefined &&\n options.separateKeyboardMouse\n ) {\n this.setState({ keyboardIndex: index });\n } else {\n this.setMouseIndex(index);\n }\n }\n\n getMouseIndex(): number {\n const { mouseIndex } = this.state;\n return mouseIndex;\n }\n\n setMouseIndex(index: number): void {\n this.setState({ mouseIndex: index });\n }\n\n initMenu(): void {\n // cancel any pending close and promises\n this.cancelPromises();\n cancelAnimationFrame(this.rAF);\n\n const { options } = this.props;\n let keyboardIndex = options.initialKeyboardIndex;\n if (keyboardIndex === undefined) {\n keyboardIndex = -1;\n }\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions);\n const nonPromiseItems: ContextAction[] = [];\n for (let i = menuItems.length - 1; i >= 0; i -= 1) {\n const menuItem = menuItems[i];\n if (menuItem instanceof Promise) {\n this.initMenuPromise(menuItem as Promise<ContextAction[]>);\n } else {\n nonPromiseItems.push(menuItem as ContextAction);\n }\n }\n\n this.setState({\n mouseIndex: -1,\n keyboardIndex,\n activeSubMenu: null,\n menuItems: ContextActionUtils.sortActions(nonPromiseItems),\n });\n }\n\n initMenuPromise(promise: Promise<ContextAction[]>): void {\n // make all promises cancellable\n const cancellablePromise = PromiseUtils.makeCancelable(promise);\n\n this.setState(state => ({\n pendingItems: state.pendingItems.concat(cancellablePromise),\n }));\n\n cancellablePromise.then(\n resolvedMenuItems => {\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n\n return {\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(resolvedMenuItems)\n ),\n pendingItems,\n };\n }\n // This item is stale, don't update the menu\n return null;\n });\n },\n error => {\n if (PromiseUtils.isCanceled(error)) {\n return; // Canceled promise is ignored\n }\n\n // remove failed item from pending list\n this.setState(state => {\n const index = state.pendingItems.indexOf(cancellablePromise);\n if (index >= 0) {\n const pendingItems = state.pendingItems.slice();\n pendingItems.splice(index, 1);\n return {\n pendingItems,\n };\n }\n return null;\n });\n\n // Log the error\n log.error(error);\n }\n );\n }\n\n cancelPromises(): void {\n const { pendingItems } = this.state;\n pendingItems.map(item => item.cancel());\n }\n\n /**\n * Sets the unverfied start position of a submenu. Submenu then self-verfies\n * its own position and potentially reports back a new position.\n */\n setActiveSubMenuPosition(): void {\n if (this.activeSubMenuRef.current === null) return;\n const parentRect = this.activeSubMenuRef.current.getBoundingClientRect();\n\n // intentionally rect.right, we want the sub menu to start at the right edge of the current menu\n this.setState({\n subMenuTop: parentRect.top,\n subMenuLeft: parentRect.right,\n subMenuParentHeight: parentRect.height,\n subMenuParentWidth: parentRect.width,\n });\n }\n\n /**\n * Verifies the position of this menu in relation to the parent to make sure it's on screen.\n * Will update the top left state (updatePosition) if necessary (causing a re-render)\n * By default it tries to top-align with parent, at the right side of the parent.\n * Because we aren't a native context menu and can't escape window bounds, we also do\n * somethings to better fit on screen, such as the \"nudge\" offset position, and further\n * allow overflow scrolling for large menus in a small window.\n */\n verifyPosition(): void {\n const {\n options,\n updatePosition,\n subMenuParentWidth,\n subMenuParentHeight,\n top: oldTop,\n left: oldLeft,\n } = this.props;\n\n if (\n !this.container.current ||\n (options.doNotVerifyPosition != null && options.doNotVerifyPosition)\n ) {\n return;\n }\n\n // initial position is used rather than current position,\n // as the number of menu items can change (actions can bubble)\n // and menu should always be positioned relative to spawn point\n let { top, left } = this.initialPosition;\n const {\n width,\n height,\n } = this.container.current?.getBoundingClientRect() ?? {\n width: 0,\n height: 0,\n };\n const hasOverflow =\n (this.container.current?.scrollHeight ?? 0) > window.innerHeight;\n\n if (height === 0 || width === 0) {\n // We don't have a height or width yet, don't bother doing anything\n return;\n }\n\n // does it fit below?\n if (top + height > window.innerHeight) {\n // can it be flipped to above? include offset if submenu (defaults to 0 if not submenu)\n if (top - height - subMenuParentHeight > 0) {\n // flip like a native menu would\n top -= height - subMenuParentHeight;\n } else {\n // still doesnt fit? okay, position at bottom edge\n top = window.innerHeight - height;\n }\n }\n\n if (left + width > window.innerWidth) {\n // less picky about left right positioning, just keep it going off to right\n left = left - width - subMenuParentWidth;\n }\n\n if (oldLeft !== left || oldTop !== top) {\n // parent owns positioning as single source of truth, ask to update props\n this.setState({ hasOverflow });\n updatePosition(top, left);\n }\n }\n\n // since window resize doesn't trigger blur, listen and close the menu\n handleWindowResize(): void {\n if (!this.container.current) {\n return;\n }\n this.closeMenu(true);\n }\n\n handleBlur(e: React.FocusEvent<HTMLDivElement>): void {\n if (!this.container.current) {\n log.warn('Container is null!');\n return;\n }\n\n if (!this.container.current.contains(e.relatedTarget as Node)) {\n let element: HTMLElement | null = e.relatedTarget as HTMLElement;\n let isContextMenuChild = false;\n while (element && !isContextMenuChild) {\n isContextMenuChild = element.hasAttribute('data-dh-context-menu');\n element = element.parentElement;\n }\n\n if (!isContextMenuChild) {\n // close all submenus on blur\n this.closeMenu(true);\n }\n }\n }\n\n /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */\n isEscapeKey(key: string): boolean {\n const { left } = this.props;\n return (\n key === 'Escape' ||\n (left < 0 && key === 'ArrowRight') ||\n key === 'ArrowLeft'\n );\n }\n\n handleKeyDown(e: React.KeyboardEvent<HTMLDivElement>): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus: number | null = oldFocus;\n let openSubMenu = false;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(\n menuItems[oldFocus],\n (e as React.SyntheticEvent) as React.MouseEvent\n );\n }\n return;\n }\n\n if (e.key === 'ArrowRight') {\n if (oldFocus >= 0 && oldFocus <= menuItems.length) {\n openSubMenu = true;\n } else {\n newFocus = 0;\n }\n } else if (this.isEscapeKey(e.key)) {\n newFocus = null;\n } else if (e.key === 'ArrowUp' || (e.shiftKey && e.key === 'Tab')) {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, -1, menuItems);\n } else if (e.key === 'ArrowDown' || e.key === 'Tab') {\n newFocus = ContextActionUtils.getNextMenuItem(newFocus, 1, menuItems);\n }\n\n if (openSubMenu) {\n this.openSubMenu(oldFocus);\n e.preventDefault();\n e.stopPropagation();\n return;\n }\n\n if (oldFocus !== newFocus) {\n if (newFocus !== null) {\n this.setKeyboardIndex(newFocus);\n } else {\n this.closeMenu();\n if (this.oldFocus instanceof HTMLElement) {\n this.oldFocus.focus();\n }\n }\n\n e.preventDefault();\n e.stopPropagation();\n }\n }\n\n openSubMenu(index: number): void {\n const { menuItems, activeSubMenu } = this.state;\n const newSubMenu = menuItems[index].actions ? index : null;\n if (activeSubMenu === newSubMenu) return;\n this.setState({\n activeSubMenu: newSubMenu,\n subMenuTop: null,\n subMenuLeft: null,\n });\n }\n\n closeMenu(closeAll = false): void {\n const { closeMenu, onMenuClosed } = this.props;\n cancelAnimationFrame(this.rAF);\n this.rAF = window.requestAnimationFrame(() => {\n closeMenu(closeAll);\n onMenuClosed(this);\n });\n }\n\n closeSubMenu(): void {\n this.setState({\n activeSubMenu: null,\n });\n }\n\n handleCloseSubMenu(closeAllMenus: boolean): void {\n if (closeAllMenus) {\n this.closeMenu(true);\n } else {\n this.closeSubMenu();\n }\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.MouseEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n const { menuItems } = this.state;\n if (\n menuItem != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n if (menuItem.actions != null) {\n this.openSubMenu(menuItems.indexOf(menuItem));\n } else if (menuItem.action != null) {\n menuItem.action();\n this.closeMenu(true);\n }\n }\n }\n\n handleMenuItemContextMenu(\n menuItem: ContextAction,\n e: React.MouseEvent\n ): void {\n if (e.metaKey) {\n return;\n }\n\n this.handleMenuItemClick(menuItem, e);\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n\n if (\n focusIndex >= 0 &&\n focusIndex < menuItems.length &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n this.openSubMenu(focusIndex);\n }\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { top, left } = this.props;\n const {\n activeSubMenu,\n hasOverflow,\n keyboardIndex,\n menuItems,\n mouseIndex,\n pendingItems,\n subMenuTop,\n subMenuLeft,\n subMenuParentWidth,\n subMenuParentHeight,\n } = this.state;\n for (let i = 0; i < menuItems.length; i += 1) {\n const menuItem = menuItems[i];\n\n if (i > 0 && menuItem.group !== menuItems[i - 1].group) {\n menuItemElements.push(<hr key={`${i}.separator`} />);\n }\n\n const menuItemElement = (\n <ContextMenuItem\n key={i}\n ref={activeSubMenu === i ? this.activeSubMenuRef : null}\n isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseSubMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={this.handleMenuItemContextMenu}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n let pendingElement = null;\n if (pendingItems.length > 0) {\n pendingElement = (\n <div className=\"loading\">\n <LoadingSpinner />\n </div>\n );\n }\n\n const { menuStyle, 'data-testid': dataTestId } = this.props;\n\n // don't show submenu until it has an position initialized\n const showSubmenu =\n activeSubMenu !== null && subMenuTop !== null && subMenuLeft !== null;\n\n return (\n <>\n <div\n className={classNames(\n { 'has-overflow': hasOverflow },\n 'context-menu-container'\n )}\n style={{ top, left, ...menuStyle }}\n ref={this.container}\n data-dh-context-menu\n onBlur={this.handleBlur}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n onContextMenu={ContextMenu.handleContextMenu}\n role=\"menuitem\"\n tabIndex={0}\n data-testid={dataTestId}\n >\n {menuItemElements}\n {pendingElement}\n </div>\n {showSubmenu &&\n activeSubMenu !== null &&\n subMenuTop !== null &&\n subMenuLeft !== null && (\n <ContextMenu\n key={`sub-${activeSubMenu}`}\n actions={menuItems[activeSubMenu].actions || []}\n closeMenu={this.handleCloseSubMenu}\n top={subMenuTop}\n left={subMenuLeft}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({\n subMenuTop: verifiedTop,\n subMenuLeft: verifiedLeft,\n });\n }}\n subMenuParentWidth={subMenuParentWidth}\n subMenuParentHeight={subMenuParentHeight}\n />\n )}\n </>\n );\n }\n}\n\nexport default ContextMenu;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAC5C,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,YAAY,QAA2B,kBAAkB;AAAC,OAC5DC,kBAAkB;AAAA,OAIlBC,eAAe;AAAA,OACfC,cAAc;AAErB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,aAA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,IAAI,CAACjH,SAAU;MACpB,4BAAoB;MACpB,MAAM,EAAE,IAAI,CAACT,UAAW;MACxB,SAAS,EAAE,IAAI,CAACG,aAAc;MAC9B,YAAY,EAAE,IAAI,CAACI,gBAAiB;MACpC,aAAa,EAAEf,WAAW,CAACC,iBAAkB;MAC7C,IAAI,EAAC,UAAU;MACf,QAAQ,EAAE,CAAE;MACZ,eAAakI;IAAW,GAEvBL,gBAAgB,EAChBG,cAAc,CACX,EACLG,WAAW,IACVrG,aAAa,KAAK,IAAI,IACtBE,UAAU,KAAK,IAAI,IACnBC,WAAW,KAAK,IAAI,iBAClB,oBAAC,WAAW;MACV,GAAG,gBAASH,aAAa,CAAG;MAC5B,OAAO,EAAEF,SAAS,CAACE,aAAa,CAAC,CAACoB,OAAO,IAAI,EAAG;MAChD,SAAS,EAAE,IAAI,CAACzC,kBAAmB;MACnC,GAAG,EAAEuB,UAAW;MAChB,IAAI,EAAEC,WAAY;MAClB,cAAc,EAAE,CAACmG,WAAW,EAAEC,YAAY,KAAK;QAC7C,IAAI,CAACrE,QAAQ,CAAC;UACZhC,UAAU,EAAEoG,WAAW;UACvBnG,WAAW,EAAEoG;QACf,CAAC,CAAC;MACJ,CAAE;MACF,kBAAkB,EAAEnG,kBAAmB;MACvC,mBAAmB,EAAEC;IAAoB,EAE5C,CACF;EAEP;AACF;AAAC,gBA7lBKpC,WAAW,kBACO;EACpBmC,kBAAkB,EAAE,CAAC;EACrBC,mBAAmB,EAAE,CAAC;EACtBmE,SAAS,GAAS;IAChB;EAAA,CACD;EACDxD,YAAY,GAAS;IACnB;EAAA,CACD;EACDwE,YAAY,GAAS;IACnB;EAAA,CACD;EACD5D,OAAO,EAAE,CAAC,CAAC;EACXuE,SAAS,EAAE,CAAC,CAAC;EACb,aAAa,EAAErE;AACjB,CAAC;AA+kBH,eAAe7D,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.d.ts","sourceRoot":"","sources":["../../src/context-actions/ContextMenuItem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,IAAI,CAAC;IAChE,mBAAmB,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;IACpE,qBAAqB,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,eAAe,6FA2IpB,CAAC;AAWF,eAAe,eAAe,CAAC"}
@@ -4,7 +4,6 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
4
  import { vsChevronRight } from '@deephaven/icons';
5
5
  var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
6
6
  var _menuItem$shortcut;
7
-
8
7
  function handleMenuItemClick(e) {
9
8
  var {
10
9
  menuItem,
@@ -12,7 +11,6 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
12
11
  } = props;
13
12
  onMenuItemClick(menuItem, e);
14
13
  }
15
-
16
14
  function handleMenuItemMouseMove(e) {
17
15
  var {
18
16
  menuItem,
@@ -20,7 +18,6 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
20
18
  } = props;
21
19
  onMenuItemMouseMove(menuItem, e);
22
20
  }
23
-
24
21
  function handleMenuItemContextMenu(e) {
25
22
  var {
26
23
  menuItem,
@@ -28,13 +25,11 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
28
25
  } = props;
29
26
  onMenuItemContextMenu(menuItem, e);
30
27
  }
31
-
32
28
  function renderCustomMenuElement(element, iconElement, displayShortcut) {
33
29
  // Don't pass forwardedProps if menuElement is a native DOM node
34
30
  if (typeof element.type === 'string') {
35
31
  return element;
36
32
  }
37
-
38
33
  var {
39
34
  closeMenu,
40
35
  menuItem,
@@ -55,49 +50,40 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
55
50
  forwardedProps
56
51
  });
57
52
  }
58
-
59
53
  var {
60
54
  children,
61
55
  menuItem,
62
- isKeyboardSelected,
63
- isMouseSelected,
56
+ isKeyboardSelected = false,
57
+ isMouseSelected = false,
64
58
  'data-testid': dataTestId
65
59
  } = props;
66
60
  var displayShortcut = (_menuItem$shortcut = menuItem.shortcut) === null || _menuItem$shortcut === void 0 ? void 0 : _menuItem$shortcut.getDisplayText();
67
61
  var icon = null;
68
-
69
62
  if (menuItem.icon) {
70
63
  var menuItemIcon = menuItem.icon;
71
-
72
64
  if ( /*#__PURE__*/React.isValidElement(menuItemIcon)) {
73
65
  icon = menuItemIcon;
74
66
  } else {
75
67
  var style;
76
-
77
68
  if (menuItem.iconColor != null && (menuItem.disabled === undefined || !menuItem.disabled)) {
78
69
  style = {
79
70
  color: menuItem.iconColor
80
71
  };
81
72
  }
82
-
83
73
  icon = /*#__PURE__*/React.createElement(FontAwesomeIcon, {
84
74
  icon: menuItemIcon,
85
75
  style: style
86
76
  });
87
77
  }
88
78
  }
89
-
90
79
  var subMenuIndicator = null;
91
80
  var isSubMenuActive = Boolean(children);
92
-
93
81
  if (menuItem.actions) {
94
82
  subMenuIndicator = /*#__PURE__*/React.createElement(FontAwesomeIcon, {
95
83
  icon: vsChevronRight
96
84
  });
97
85
  }
98
-
99
86
  var content = null;
100
-
101
87
  if (menuItem.menuElement) {
102
88
  content = /*#__PURE__*/React.createElement("div", {
103
89
  className: "custom-menu-item",
@@ -105,7 +91,6 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
105
91
  }, renderCustomMenuElement(menuItem.menuElement, icon, displayShortcut));
106
92
  } else {
107
93
  var _menuItem$description;
108
-
109
94
  var menuItemDisabled = menuItem.disabled;
110
95
  var iconHasOutline = menuItem.iconOutline;
111
96
  content = /*#__PURE__*/React.createElement("button", {
@@ -115,7 +100,7 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
115
100
  }, {
116
101
  active: (isSubMenuActive || isMouseSelected) && (menuItemDisabled === undefined || !menuItemDisabled)
117
102
  }, {
118
- 'keyboard-active': isKeyboardSelected !== undefined && isKeyboardSelected && (menuItemDisabled === undefined || !menuItemDisabled)
103
+ 'keyboard-active': isKeyboardSelected && (menuItemDisabled === undefined || !menuItemDisabled)
119
104
  }),
120
105
  onClick: handleMenuItemClick,
121
106
  onMouseMove: handleMenuItemMouseMove,
@@ -137,7 +122,6 @@ var ContextMenuItem = /*#__PURE__*/React.forwardRef((props, ref) => {
137
122
  })
138
123
  }, subMenuIndicator)));
139
124
  }
140
-
141
125
  return /*#__PURE__*/React.createElement("div", {
142
126
  className: "context-menu-item",
143
127
  ref: ref,
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuItem.js","names":["React","classNames","FontAwesomeIcon","vsChevronRight","ContextMenuItem","forwardRef","props","ref","handleMenuItemClick","e","menuItem","onMenuItemClick","handleMenuItemMouseMove","onMenuItemMouseMove","handleMenuItemContextMenu","onMenuItemContextMenu","renderCustomMenuElement","element","iconElement","displayShortcut","type","closeMenu","isKeyboardSelected","isMouseSelected","dataTestId","forwardedProps","cloneElement","children","shortcut","getDisplayText","icon","menuItemIcon","isValidElement","style","iconColor","disabled","undefined","color","subMenuIndicator","isSubMenuActive","Boolean","actions","content","menuElement","menuItemDisabled","iconHasOutline","iconOutline","active","description","outline","title","displayName","defaultProps"],"sources":["../../src/context-actions/ContextMenuItem.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { vsChevronRight, IconDefinition } from '@deephaven/icons';\nimport type { ContextAction } from './ContextActionUtils';\n\ninterface ContextMenuItemProps {\n children?: React.ReactNode;\n closeMenu(closeAll: boolean): void;\n isKeyboardSelected?: boolean;\n isMouseSelected?: boolean;\n menuItem: ContextAction;\n onMenuItemClick(item: ContextAction, e: React.MouseEvent): void;\n onMenuItemMouseMove(item: ContextAction, e: React.MouseEvent): void;\n onMenuItemContextMenu(item: ContextAction, e: React.MouseEvent): void;\n 'data-testid'?: string;\n}\n\nconst ContextMenuItem = React.forwardRef<HTMLDivElement, ContextMenuItemProps>(\n (props: ContextMenuItemProps, ref) => {\n function handleMenuItemClick(e: React.MouseEvent) {\n const { menuItem, onMenuItemClick } = props;\n onMenuItemClick(menuItem, e);\n }\n\n function handleMenuItemMouseMove(e: React.MouseEvent) {\n const { menuItem, onMenuItemMouseMove } = props;\n onMenuItemMouseMove(menuItem, e);\n }\n\n function handleMenuItemContextMenu(e: React.MouseEvent) {\n const { menuItem, onMenuItemContextMenu } = props;\n onMenuItemContextMenu(menuItem, e);\n }\n\n function renderCustomMenuElement(\n element: React.ReactElement,\n iconElement: IconDefinition | React.ReactElement | null,\n displayShortcut: string | undefined\n ): JSX.Element {\n // Don't pass forwardedProps if menuElement is a native DOM node\n if (typeof element.type === 'string') {\n return element;\n }\n const {\n closeMenu,\n menuItem,\n isKeyboardSelected,\n isMouseSelected,\n 'data-testid': dataTestId,\n } = props;\n const forwardedProps = {\n menuItem,\n closeMenu,\n isKeyboardSelected,\n isMouseSelected,\n iconElement,\n displayShortcut,\n 'data-testid': dataTestId,\n };\n return React.cloneElement(element, {\n forwardedProps,\n });\n }\n\n const {\n children,\n menuItem,\n isKeyboardSelected,\n isMouseSelected,\n 'data-testid': dataTestId,\n } = props;\n\n const displayShortcut = menuItem.shortcut?.getDisplayText();\n let icon: IconDefinition | React.ReactElement | null = null;\n if (menuItem.icon) {\n const menuItemIcon = menuItem.icon;\n if (React.isValidElement(menuItemIcon)) {\n icon = menuItemIcon;\n } else {\n let style: React.CSSProperties | undefined;\n if (\n menuItem.iconColor != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n style = { color: menuItem.iconColor };\n }\n icon = <FontAwesomeIcon icon={menuItemIcon} style={style} />;\n }\n }\n\n let subMenuIndicator = null;\n const isSubMenuActive = Boolean(children);\n if (menuItem.actions) {\n subMenuIndicator = <FontAwesomeIcon icon={vsChevronRight} />;\n }\n let content = null;\n if (menuItem.menuElement) {\n content = (\n <div className=\"custom-menu-item\" onMouseMove={handleMenuItemMouseMove}>\n {renderCustomMenuElement(menuItem.menuElement, icon, displayShortcut)}\n </div>\n );\n } else {\n const menuItemDisabled = menuItem.disabled;\n const iconHasOutline = menuItem.iconOutline;\n content = (\n <button\n type=\"button\"\n className={classNames(\n 'btn-context-menu',\n { disabled: menuItemDisabled },\n {\n active:\n (isSubMenuActive || isMouseSelected) &&\n (menuItemDisabled === undefined || !menuItemDisabled),\n },\n {\n 'keyboard-active':\n isKeyboardSelected !== undefined &&\n isKeyboardSelected &&\n (menuItemDisabled === undefined || !menuItemDisabled),\n }\n )}\n onClick={handleMenuItemClick}\n onMouseMove={handleMenuItemMouseMove}\n onContextMenu={handleMenuItemContextMenu}\n title={menuItem.description ?? ''}\n >\n <div className=\"btn-context-menu-wrapper\">\n <span className={classNames('icon', { outline: iconHasOutline })}>\n {icon}\n </span>\n <span className=\"title\">{menuItem.title}</span>\n {displayShortcut !== undefined && (\n <span className=\"shortcut\">{displayShortcut}</span>\n )}\n {subMenuIndicator && (\n <span\n className={classNames('submenu-indicator', {\n disabled: menuItemDisabled,\n })}\n >\n {subMenuIndicator}\n </span>\n )}\n </div>\n </button>\n );\n }\n\n return (\n <div className=\"context-menu-item\" ref={ref} data-testid={dataTestId}>\n {children}\n {content}\n </div>\n );\n }\n);\n\nContextMenuItem.displayName = 'ContextMenuItem';\n\nContextMenuItem.defaultProps = {\n children: null,\n isKeyboardSelected: false,\n isMouseSelected: false,\n 'data-testid': undefined,\n};\n\nexport default ContextMenuItem;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,eAAT,QAAgC,gCAAhC;AACA,SAASC,cAAT,QAA+C,kBAA/C;AAeA,IAAMC,eAAe,gBAAGJ,KAAK,CAACK,UAAN,CACtB,CAACC,KAAD,EAA8BC,GAA9B,KAAsC;EAAA;;EACpC,SAASC,mBAAT,CAA6BC,CAA7B,EAAkD;I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c,SAAvB,IACAd,kBADA,KAECsB,gBAAgB,KAAKR,SAArB,IAAkC,CAACQ,gBAFpC;MAFJ,CARmB,CAFvB;MAiBE,OAAO,EAAEpC,mBAjBX;MAkBE,WAAW,EAAEI,uBAlBf;MAmBE,aAAa,EAAEE,yBAnBjB;MAoBE,KAAK,2BAAEJ,QAAQ,CAACsC,WAAX,yEAA0B;IApBjC,gBAsBE;MAAK,SAAS,EAAC;IAAf,gBACE;MAAM,SAAS,EAAE/C,UAAU,CAAC,MAAD,EAAS;QAAEgD,OAAO,EAAEJ;MAAX,CAAT;IAA3B,GACGf,IADH,CADF,eAIE;MAAM,SAAS,EAAC;IAAhB,GAAyBpB,QAAQ,CAACwC,KAAlC,CAJF,EAKG/B,eAAe,KAAKiB,SAApB,iBACC;MAAM,SAAS,EAAC;IAAhB,GAA4BjB,eAA5B,CANJ,EAQGmB,gBAAgB,iBACf;MACE,SAAS,EAAErC,UAAU,CAAC,mBAAD,EAAsB;QACzCkC,QAAQ,EAAES;MAD+B,CAAtB;IADvB,GAKGN,gBALH,CATJ,CAtBF,CADF;EA2CD;;EAED,oBACE;IAAK,SAAS,EAAC,mBAAf;IAAmC,GAAG,EAAE/B,GAAxC;IAA6C,eAAaiB;EAA1D,GACGG,QADH,EAEGe,OAFH,CADF;AAMD,CA3IqB,CAAxB;AA8IAtC,eAAe,CAAC+C,WAAhB,GAA8B,iBAA9B;AAEA/C,eAAe,CAACgD,YAAhB,GAA+B;EAC7BzB,QAAQ,EAAE,IADmB;EAE7BL,kBAAkB,EAAE,KAFS;EAG7BC,eAAe,EAAE,KAHY;EAI7B,eAAea;AAJc,CAA/B;AAOA,eAAehC,eAAf"}
1
+ {"version":3,"file":"ContextMenuItem.js","names":["React","classNames","FontAwesomeIcon","vsChevronRight","ContextMenuItem","forwardRef","props","ref","handleMenuItemClick","e","menuItem","onMenuItemClick","handleMenuItemMouseMove","onMenuItemMouseMove","handleMenuItemContextMenu","onMenuItemContextMenu","renderCustomMenuElement","element","iconElement","displayShortcut","type","closeMenu","isKeyboardSelected","isMouseSelected","dataTestId","forwardedProps","cloneElement","children","shortcut","getDisplayText","icon","menuItemIcon","isValidElement","style","iconColor","disabled","undefined","color","subMenuIndicator","isSubMenuActive","Boolean","actions","content","menuElement","menuItemDisabled","iconHasOutline","iconOutline","active","description","outline","title","displayName","defaultProps"],"sources":["../../src/context-actions/ContextMenuItem.tsx"],"sourcesContent":["import React from 'react';\nimport classNames from 'classnames';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { vsChevronRight, IconDefinition } from '@deephaven/icons';\nimport type { ContextAction } from './ContextActionUtils';\n\ninterface ContextMenuItemProps {\n children?: React.ReactNode;\n closeMenu(closeAll: boolean): void;\n isKeyboardSelected?: boolean;\n isMouseSelected?: boolean;\n menuItem: ContextAction;\n onMenuItemClick(item: ContextAction, e: React.MouseEvent): void;\n onMenuItemMouseMove(item: ContextAction, e: React.MouseEvent): void;\n onMenuItemContextMenu(item: ContextAction, e: React.MouseEvent): void;\n 'data-testid'?: string;\n}\n\nconst ContextMenuItem = React.forwardRef<HTMLDivElement, ContextMenuItemProps>(\n (props: ContextMenuItemProps, ref) => {\n function handleMenuItemClick(e: React.MouseEvent) {\n const { menuItem, onMenuItemClick } = props;\n onMenuItemClick(menuItem, e);\n }\n\n function handleMenuItemMouseMove(e: React.MouseEvent) {\n const { menuItem, onMenuItemMouseMove } = props;\n onMenuItemMouseMove(menuItem, e);\n }\n\n function handleMenuItemContextMenu(e: React.MouseEvent) {\n const { menuItem, onMenuItemContextMenu } = props;\n onMenuItemContextMenu(menuItem, e);\n }\n\n function renderCustomMenuElement(\n element: React.ReactElement,\n iconElement: IconDefinition | React.ReactElement | null,\n displayShortcut: string | undefined\n ): JSX.Element {\n // Don't pass forwardedProps if menuElement is a native DOM node\n if (typeof element.type === 'string') {\n return element;\n }\n const {\n closeMenu,\n menuItem,\n isKeyboardSelected,\n isMouseSelected,\n 'data-testid': dataTestId,\n } = props;\n const forwardedProps = {\n menuItem,\n closeMenu,\n isKeyboardSelected,\n isMouseSelected,\n iconElement,\n displayShortcut,\n 'data-testid': dataTestId,\n };\n return React.cloneElement(element, {\n forwardedProps,\n });\n }\n\n const {\n children,\n menuItem,\n isKeyboardSelected = false,\n isMouseSelected = false,\n 'data-testid': dataTestId,\n } = props;\n\n const displayShortcut = menuItem.shortcut?.getDisplayText();\n let icon: IconDefinition | React.ReactElement | null = null;\n if (menuItem.icon) {\n const menuItemIcon = menuItem.icon;\n if (React.isValidElement(menuItemIcon)) {\n icon = menuItemIcon;\n } else {\n let style: React.CSSProperties | undefined;\n if (\n menuItem.iconColor != null &&\n (menuItem.disabled === undefined || !menuItem.disabled)\n ) {\n style = { color: menuItem.iconColor };\n }\n icon = <FontAwesomeIcon icon={menuItemIcon} style={style} />;\n }\n }\n\n let subMenuIndicator = null;\n const isSubMenuActive = Boolean(children);\n if (menuItem.actions) {\n subMenuIndicator = <FontAwesomeIcon icon={vsChevronRight} />;\n }\n let content = null;\n if (menuItem.menuElement) {\n content = (\n <div className=\"custom-menu-item\" onMouseMove={handleMenuItemMouseMove}>\n {renderCustomMenuElement(menuItem.menuElement, icon, displayShortcut)}\n </div>\n );\n } else {\n const menuItemDisabled = menuItem.disabled;\n const iconHasOutline = menuItem.iconOutline;\n content = (\n <button\n type=\"button\"\n className={classNames(\n 'btn-context-menu',\n { disabled: menuItemDisabled },\n {\n active:\n (isSubMenuActive || isMouseSelected) &&\n (menuItemDisabled === undefined || !menuItemDisabled),\n },\n {\n 'keyboard-active':\n isKeyboardSelected &&\n (menuItemDisabled === undefined || !menuItemDisabled),\n }\n )}\n onClick={handleMenuItemClick}\n onMouseMove={handleMenuItemMouseMove}\n onContextMenu={handleMenuItemContextMenu}\n title={menuItem.description ?? ''}\n >\n <div className=\"btn-context-menu-wrapper\">\n <span className={classNames('icon', { outline: iconHasOutline })}>\n {icon}\n </span>\n <span className=\"title\">{menuItem.title}</span>\n {displayShortcut !== undefined && (\n <span className=\"shortcut\">{displayShortcut}</span>\n )}\n {subMenuIndicator && (\n <span\n className={classNames('submenu-indicator', {\n disabled: menuItemDisabled,\n })}\n >\n {subMenuIndicator}\n </span>\n )}\n </div>\n </button>\n );\n }\n\n return (\n <div className=\"context-menu-item\" ref={ref} data-testid={dataTestId}>\n {children}\n {content}\n </div>\n );\n }\n);\n\nContextMenuItem.displayName = 'ContextMenuItem';\n\nContextMenuItem.defaultProps = {\n children: null,\n isKeyboardSelected: false,\n isMouseSelected: false,\n 'data-testid': undefined,\n};\n\nexport default ContextMenuItem;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,cAAc,QAAwB,kBAAkB;AAejE,IAAMC,eAAe,gBAAGJ,KAAK,CAACK,UAAU,CACtC,CAACC,KAA2B,EAAEC,GAAG,KAAK;EAAA;EACpC,SAASC,mBAAmB,CAACC,CAAmB,EAAE;IAChD,IAAM;MAAEC,QAAQ;MAAEC;IAAgB,CAAC,GAAGL,KAAK;IAC3CK,eAAe,CAACD,QAAQ,EAAED,CAAC,CAAC;EAC9B;EAEA,SAASG,uBAAuB,CAACH,CAAmB,EAAE;IACpD,IAAM;MAAEC,QAAQ;MAAEG;IAAoB,CAAC,GAAGP,KAAK;IAC/CO,mBAAmB,CAACH,QAAQ,EAAED,CAAC,CAAC;EAClC;EAEA,SAASK,yBAAyB,CAACL,CAAmB,EAAE;IACtD,IAAM;MAAEC,QAAQ;MAAEK;IAAsB,CAAC,GAAGT,KAAK;IACjDS,qBAAqB,CAACL,QAAQ,EAAED,CAAC,CAAC;EACpC;EAEA,SAASO,uBAAuB,CAC9BC,OAA2B,EAC3BC,WAAuD,EACvDC,eAAmC,EACtB;IACb;IACA,IAAI,OAAOF,OAAO,CAACG,IAAI,KAAK,QAAQ,EAAE;MACpC,OAAOH,OAAO;IAChB;IACA,IAAM;MACJI,SAAS;MACTX,QAAQ;MACR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kC,QAAQ,EAAES;MACZ,CAAC;IAAE,GAEFN,gBAAgB,CAEpB,CACG,CAET;EACH;EAEA,oBACE;IAAK,SAAS,EAAC,mBAAmB;IAAC,GAAG,EAAE/B,GAAI;IAAC,eAAaiB;EAAW,GAClEG,QAAQ,EACRe,OAAO,CACJ;AAEV,CAAC,CACF;AAEDtC,eAAe,CAAC+C,WAAW,GAAG,iBAAiB;AAE/C/C,eAAe,CAACgD,YAAY,GAAG;EAC7BzB,QAAQ,EAAE,IAAI;EACdL,kBAAkB,EAAE,KAAK;EACzBC,eAAe,EAAE,KAAK;EACtB,aAAa,EAAEa;AACjB,CAAC;AAED,eAAehC,eAAe"}
@@ -1,21 +1,16 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
-
3
2
  import React, { Component } from 'react';
4
3
  import classNames from 'classnames';
5
4
  import ContextMenu from "./ContextMenu.js";
6
5
  import ContextActionUtils from "./ContextActionUtils.js";
7
-
8
6
  /**
9
7
  * Put at your root container, any contextmenu events that are unhandled in the root container will be handled by this
10
8
  */
11
9
  class ContextMenuRoot extends Component {
12
10
  constructor(props) {
13
11
  super(props);
14
-
15
12
  _defineProperty(this, "container", void 0);
16
-
17
13
  _defineProperty(this, "openMenu", void 0);
18
-
19
14
  this.handleMenuClose = this.handleMenuClose.bind(this);
20
15
  this.handleContextMenu = this.handleContextMenu.bind(this);
21
16
  this.container = /*#__PURE__*/React.createRef();
@@ -26,53 +21,45 @@ class ContextMenuRoot extends Component {
26
21
  top: 0
27
22
  };
28
23
  }
29
-
30
24
  componentDidMount() {
31
25
  var _this$container$curre;
32
-
33
26
  if ((_this$container$curre = this.container.current) !== null && _this$container$curre !== void 0 && _this$container$curre.parentElement) {
34
27
  this.container.current.parentElement.addEventListener('contextmenu', this.handleContextMenu);
35
28
  }
36
29
  }
37
-
38
30
  componentWillUnmount() {
39
31
  var _this$container$curre2;
40
-
41
32
  if ((_this$container$curre2 = this.container.current) !== null && _this$container$curre2 !== void 0 && _this$container$curre2.parentElement) {
42
33
  this.container.current.parentElement.removeEventListener('contextmenu', this.handleContextMenu);
43
34
  }
44
35
  }
45
-
46
36
  handleContextMenu(e) {
47
37
  if (!ContextActionUtils.isContextActionEvent(e)) {
48
38
  return;
49
39
  }
50
-
51
40
  if (!this.container.current) {
52
41
  return;
53
42
  }
54
-
55
43
  if (e.metaKey || e.ctrlKey) {
56
44
  // debug escape hatch to native menu
57
45
  return;
58
46
  }
59
-
60
47
  var contextActions = ContextActionUtils.getMenuItems(e.contextActions);
61
48
  var parentRect = this.container.current.getBoundingClientRect();
62
49
  var top = e.clientY - parentRect.top;
63
50
  var left = e.clientX - parentRect.left;
64
-
65
51
  if (contextActions.length === 0) {
66
52
  // This code path seems to only exist for Chrome on Mac
67
53
  // Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows
68
54
  // Mouseup on Windows triggers blur before contextmenu which effectively does what this path does
69
55
  if (e.target === this.container.current) {
70
56
  // re-emit right clicks that hit the context-root blocking layer
71
- e.preventDefault(); // Set actions to null removes the menu
57
+ e.preventDefault();
58
+
59
+ // Set actions to null removes the menu
72
60
  // That allows a new menu to be opened on a different element so initial position is set properly
73
61
  // Otherwise the instance of this menu may be reused
74
62
  // A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer
75
-
76
63
  this.setState({
77
64
  actions: null
78
65
  }, () => {
@@ -87,13 +74,13 @@ class ContextMenuRoot extends Component {
87
74
  element === null || element === void 0 ? void 0 : element.dispatchEvent(mouseEvent);
88
75
  });
89
76
  return;
90
- } // target was a menu item
91
-
77
+ }
92
78
 
79
+ // target was a menu item
93
80
  return;
94
- } // new clicks, set actions
95
-
81
+ }
96
82
 
83
+ // new clicks, set actions
97
84
  e.preventDefault();
98
85
  this.setState({
99
86
  actions: contextActions,
@@ -101,7 +88,6 @@ class ContextMenuRoot extends Component {
101
88
  left
102
89
  });
103
90
  }
104
-
105
91
  handleMenuClose(menu) {
106
92
  if (menu === this.openMenu.current) {
107
93
  this.setState({
@@ -109,7 +95,6 @@ class ContextMenuRoot extends Component {
109
95
  });
110
96
  }
111
97
  }
112
-
113
98
  render() {
114
99
  var menu = null;
115
100
  var {
@@ -120,7 +105,6 @@ class ContextMenuRoot extends Component {
120
105
  top,
121
106
  left
122
107
  } = this.state;
123
-
124
108
  if (actions) {
125
109
  menu = /*#__PURE__*/React.createElement(ContextMenu, {
126
110
  ref: this.openMenu,
@@ -137,7 +121,6 @@ class ContextMenuRoot extends Component {
137
121
  "data-testid": dataTestId
138
122
  });
139
123
  }
140
-
141
124
  return /*#__PURE__*/React.createElement("div", {
142
125
  className: classNames('context-menu-root', {
143
126
  active: actions
@@ -145,8 +128,6 @@ class ContextMenuRoot extends Component {
145
128
  ref: this.container
146
129
  }, menu);
147
130
  }
148
-
149
131
  }
150
-
151
132
  export default ContextMenuRoot;
152
133
  //# sourceMappingURL=ContextMenuRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextMenuRoot.js","names":["React","Component","classNames","ContextMenu","ContextActionUtils","ContextMenuRoot","constructor","props","handleMenuClose","bind","handleContextMenu","container","createRef","openMenu","state","actions","left","top","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","isContextActionEvent","metaKey","ctrlKey","contextActions","getMenuItems","parentRect","getBoundingClientRect","clientY","clientX","length","target","preventDefault","setState","element","document","elementFromPoint","mouseEvent","MouseEvent","bubbles","cancelable","dispatchEvent","menu","render","dataTestId","verifiedTop","verifiedLeft","active"],"sources":["../../src/context-actions/ContextMenuRoot.tsx"],"sourcesContent":["import React, { Component } from 'react';\nimport classNames from 'classnames';\nimport ContextMenu from './ContextMenu';\nimport ContextActionUtils, { MenuItem } from './ContextActionUtils';\n\ntype ContextMenuRootProps = Record<string, never> & {\n 'data-testid'?: string;\n};\n\ninterface ContextMenuRootState {\n actions: MenuItem[] | null;\n left: number;\n top: number;\n}\n\n/**\n * Put at your root container, any contextmenu events that are unhandled in the root container will be handled by this\n */\nclass ContextMenuRoot extends Component<\n ContextMenuRootProps,\n ContextMenuRootState\n> {\n constructor(props: ContextMenuRootProps) {\n super(props);\n\n this.handleMenuClose = this.handleMenuClose.bind(this);\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.container = React.createRef();\n this.openMenu = React.createRef();\n\n this.state = {\n actions: null,\n left: 0,\n top: 0,\n };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n openMenu: React.RefObject<ContextMenu>;\n\n handleContextMenu(e: MouseEvent): void {\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n if (!this.container.current) {\n return;\n }\n\n if (e.metaKey || e.ctrlKey) {\n // debug escape hatch to native menu\n return;\n }\n\n const contextActions = ContextActionUtils.getMenuItems(e.contextActions);\n\n const parentRect = this.container.current.getBoundingClientRect();\n const top = e.clientY - parentRect.top;\n const left = e.clientX - parentRect.left;\n\n if (contextActions.length === 0) {\n // This code path seems to only exist for Chrome on Mac\n // Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows\n // Mouseup on Windows triggers blur before contextmenu which effectively does what this path does\n if (e.target === this.container.current) {\n // re-emit right clicks that hit the context-root blocking layer\n e.preventDefault();\n\n // Set actions to null removes the menu\n // That allows a new menu to be opened on a different element so initial position is set properly\n // Otherwise the instance of this menu may be reused\n // A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer\n this.setState({ actions: null }, () => {\n const element = document.elementFromPoint(left, top); // x y\n\n const mouseEvent = new MouseEvent('contextmenu', {\n clientX: e.clientX,\n clientY: e.clientY,\n bubbles: true,\n cancelable: true,\n });\n\n element?.dispatchEvent(mouseEvent);\n });\n return;\n }\n\n // target was a menu item\n return;\n }\n\n // new clicks, set actions\n e.preventDefault();\n this.setState({\n actions: contextActions,\n top,\n left,\n });\n }\n\n handleMenuClose(menu: ContextMenu): void {\n if (menu === this.openMenu.current) {\n this.setState({ actions: null });\n }\n }\n\n render(): JSX.Element {\n let menu = null;\n const { 'data-testid': dataTestId } = this.props;\n const { actions, top, left } = this.state;\n if (actions) {\n menu = (\n <ContextMenu\n ref={this.openMenu}\n actions={actions}\n onMenuClosed={this.handleMenuClose}\n top={top}\n left={left}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({ top: verifiedTop, left: verifiedLeft });\n }}\n data-testid={dataTestId}\n />\n );\n }\n return (\n <div\n className={classNames('context-menu-root', { active: actions })}\n ref={this.container}\n >\n {menu}\n </div>\n );\n }\n}\n\nexport default ContextMenuRoot;\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,OAAOC,UAAP,MAAuB,YAAvB;OACOC,W;OACAC,kB;;AAYP;AACA;AACA;AACA,MAAMC,eAAN,SAA8BJ,SAA9B,CAGE;EACAK,WAAW,CAACC,KAAD,EAA8B;IACvC,MAAMA,KAAN;;IADuC;;IAAA;;IAGvC,KAAKC,eAAL,GAAuB,KAAKA,eAAL,CAAqBC,IAArB,CAA0B,IAA1B,CAAvB;IACA,KAAKC,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBD,IAAvB,CAA4B,IAA5B,CAAzB;IACA,KAAKE,SAAL,gBAAiBX,KAAK,CAACY,SAAN,EAAjB;IACA,KAAKC,QAAL,gBAAgBb,KAAK,CAACY,SAAN,EAAhB;IAEA,KAAKE,KAAL,GAAa;MACXC,OAAO,EAAE,IADE;MAEXC,IAAI,EAAE,CAFK;MAGXC,GAAG,EAAE;IAHM,CAAb;EAKD;;EAEDC,iBAAiB,GAAS;IAAA;;IACxB,6BAAI,KAAKP,SAAL,CAAeQ,OAAnB,kDAAI,sBAAwBC,aAA5B,EAA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D,oBACE;MACE,SAAS,EAAE9C,UAAU,CAAC,mBAAD,EAAsB;QAAEiD,MAAM,EAAEpC;MAAV,CAAtB,CADvB;MAEE,GAAG,EAAE,KAAKJ;IAFZ,GAIGmC,IAJH,CADF;EAQD;;AAnID;;AAsIF,eAAezC,eAAf"}
1
+ {"version":3,"file":"ContextMenuRoot.js","names":["React","Component","classNames","ContextMenu","ContextActionUtils","ContextMenuRoot","constructor","props","handleMenuClose","bind","handleContextMenu","container","createRef","openMenu","state","actions","left","top","componentDidMount","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","isContextActionEvent","metaKey","ctrlKey","contextActions","getMenuItems","parentRect","getBoundingClientRect","clientY","clientX","length","target","preventDefault","setState","element","document","elementFromPoint","mouseEvent","MouseEvent","bubbles","cancelable","dispatchEvent","menu","render","dataTestId","verifiedTop","verifiedLeft","active"],"sources":["../../src/context-actions/ContextMenuRoot.tsx"],"sourcesContent":["import React, { Component } from 'react';\nimport classNames from 'classnames';\nimport ContextMenu from './ContextMenu';\nimport ContextActionUtils, { MenuItem } from './ContextActionUtils';\n\ntype ContextMenuRootProps = Record<string, never> & {\n 'data-testid'?: string;\n};\n\ninterface ContextMenuRootState {\n actions: MenuItem[] | null;\n left: number;\n top: number;\n}\n\n/**\n * Put at your root container, any contextmenu events that are unhandled in the root container will be handled by this\n */\nclass ContextMenuRoot extends Component<\n ContextMenuRootProps,\n ContextMenuRootState\n> {\n constructor(props: ContextMenuRootProps) {\n super(props);\n\n this.handleMenuClose = this.handleMenuClose.bind(this);\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.container = React.createRef();\n this.openMenu = React.createRef();\n\n this.state = {\n actions: null,\n left: 0,\n top: 0,\n };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n openMenu: React.RefObject<ContextMenu>;\n\n handleContextMenu(e: MouseEvent): void {\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n if (!this.container.current) {\n return;\n }\n\n if (e.metaKey || e.ctrlKey) {\n // debug escape hatch to native menu\n return;\n }\n\n const contextActions = ContextActionUtils.getMenuItems(e.contextActions);\n\n const parentRect = this.container.current.getBoundingClientRect();\n const top = e.clientY - parentRect.top;\n const left = e.clientX - parentRect.left;\n\n if (contextActions.length === 0) {\n // This code path seems to only exist for Chrome on Mac\n // Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows\n // Mouseup on Windows triggers blur before contextmenu which effectively does what this path does\n if (e.target === this.container.current) {\n // re-emit right clicks that hit the context-root blocking layer\n e.preventDefault();\n\n // Set actions to null removes the menu\n // That allows a new menu to be opened on a different element so initial position is set properly\n // Otherwise the instance of this menu may be reused\n // A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer\n this.setState({ actions: null }, () => {\n const element = document.elementFromPoint(left, top); // x y\n\n const mouseEvent = new MouseEvent('contextmenu', {\n clientX: e.clientX,\n clientY: e.clientY,\n bubbles: true,\n cancelable: true,\n });\n\n element?.dispatchEvent(mouseEvent);\n });\n return;\n }\n\n // target was a menu item\n return;\n }\n\n // new clicks, set actions\n e.preventDefault();\n this.setState({\n actions: contextActions,\n top,\n left,\n });\n }\n\n handleMenuClose(menu: ContextMenu): void {\n if (menu === this.openMenu.current) {\n this.setState({ actions: null });\n }\n }\n\n render(): JSX.Element {\n let menu = null;\n const { 'data-testid': dataTestId } = this.props;\n const { actions, top, left } = this.state;\n if (actions) {\n menu = (\n <ContextMenu\n ref={this.openMenu}\n actions={actions}\n onMenuClosed={this.handleMenuClose}\n top={top}\n left={left}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({ top: verifiedTop, left: verifiedLeft });\n }}\n data-testid={dataTestId}\n />\n );\n }\n return (\n <div\n className={classNames('context-menu-root', { active: actions })}\n ref={this.container}\n >\n {menu}\n </div>\n );\n }\n}\n\nexport default ContextMenuRoot;\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,OAAOC,UAAU,MAAM,YAAY;AAAC,OAC7BC,WAAW;AAAA,OACXC,kBAAkB;AAYzB;AACA;AACA;AACA,MAAMC,eAAe,SAASJ,SAAS,CAGrC;EACAK,WAAW,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;IAAC;IAAA;IAEb,IAAI,CAACC,eAAe,GAAG,IAAI,CAACA,eAAe,CAACC,IAAI,CAAC,IAAI,CAAC;IACtD,IAAI,CAACC,iBAAiB,GAAG,IAAI,CAACA,iBAAiB,CAACD,IAAI,CAAC,IAAI,CAAC;IAC1D,IAAI,CAACE,SAAS,gBAAGX,KAAK,CAACY,SAAS,EAAE;IAClC,IAAI,CAACC,QAAQ,gBAAGb,KAAK,CAACY,SAAS,EAAE;IAEjC,IAAI,CAACE,KAAK,GAAG;MACXC,OAAO,EAAE,IAAI;MACbC,IAAI,EAAE,CAAC;MACPC,GAAG,EAAE;IACP,CAAC;EACH;EAEAC,iBAAiB,GAAS;IAAA;IACxB,6BAAI,IAAI,CAACP,SAAS,CAACQ,OAAO,kDAAtB,sBAAwBC,aAAa,EAAE;MACzC,IAAI,CAACT,SAAS,CAACQ,OAAO,CAACC,aAAa,CAACC,gBAAgB,CACnD,aAAa,EACb,IAAI,CAACX,iBAAiB,CACvB;IACH;EACF;EAEAY,oBAAoB,GAAS;IAAA;IAC3B,8BAAI,IAAI,CAACX,SAAS,CAACQ,OAAO,mDAAtB,uBAAwBC,aAAa,EAAE;MACzC,IAAI,CAACT,SAAS,CAACQ,OAAO,CAACC,aAAa,CAACG,mBAAmB,CACtD,aAAa,EACb,IAAI,CAACb,iBAAiB,CACvB;IACH;EACF;EAMAA,iBAAiB,CAACc,CAAa,EAAQ;IACrC,IAAI,CAACpB,kB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AI,CAACC,QAAQ,CAAC;MACZtB,OAAO,EAAEa,cAAc;MACvBX,GAAG;MACHD;IACF,CAAC,CAAC;EACJ;EAEAR,eAAe,CAACsC,IAAiB,EAAQ;IACvC,IAAIA,IAAI,KAAK,IAAI,CAACjC,QAAQ,CAACM,OAAO,EAAE;MAClC,IAAI,CAACkB,QAAQ,CAAC;QAAEtB,OAAO,EAAE;MAAK,CAAC,CAAC;IAClC;EACF;EAEAgC,MAAM,GAAgB;IACpB,IAAID,IAAI,GAAG,IAAI;IACf,IAAM;MAAE,aAAa,EAAEE;IAAW,CAAC,GAAG,IAAI,CAACzC,KAAK;IAChD,IAAM;MAAEQ,OAAO;MAAEE,GAAG;MAAED;IAAK,CAAC,GAAG,IAAI,CAACF,KAAK;IACzC,IAAIC,OAAO,EAAE;MACX+B,IAAI,gBACF,oBAAC,WAAW;QACV,GAAG,EAAE,IAAI,CAACjC,QAAS;QACnB,OAAO,EAAEE,OAAQ;QACjB,YAAY,EAAE,IAAI,CAACP,eAAgB;QACnC,GAAG,EAAES,GAAI;QACT,IAAI,EAAED,IAAK;QACX,cAAc,EAAE,CAACiC,WAAW,EAAEC,YAAY,KAAK;UAC7C,IAAI,CAACb,QAAQ,CAAC;YAAEpB,GAAG,EAAEgC,WAAW;YAAEjC,IAAI,EAAEkC;UAAa,CAAC,CAAC;QACzD,CAAE;QACF,eAAaF;MAAW,EAE3B;IACH;IACA,oBACE;MACE,SAAS,EAAE9C,UAAU,CAAC,mBAAmB,EAAE;QAAEiD,MAAM,EAAEpC;MAAQ,CAAC,CAAE;MAChE,GAAG,EAAE,IAAI,CAACJ;IAAU,GAEnBmC,IAAI,CACD;EAEV;AACF;AAEA,eAAezC,eAAe"}
@@ -2,67 +2,52 @@ import { Component } from 'react';
2
2
  import Log from '@deephaven/log';
3
3
  import ContextActionUtils from "./ContextActionUtils.js";
4
4
  var log = Log.module('GlobalContextAction');
5
-
6
5
  class GlobalContextAction extends Component {
7
6
  constructor(props) {
8
7
  super(props);
9
8
  this.handleContextMenu = this.handleContextMenu.bind(this);
10
9
  this.handleKeyDown = this.handleKeyDown.bind(this);
11
10
  }
12
-
13
11
  componentDidMount() {
14
12
  document.body.addEventListener('contextmenu', this.handleContextMenu);
15
13
  document.body.addEventListener('keydown', this.handleKeyDown);
16
14
  }
17
-
18
15
  componentWillUnmount() {
19
16
  document.body.removeEventListener('contextmenu', this.handleContextMenu);
20
17
  document.body.removeEventListener('keydown', this.handleKeyDown);
21
18
  }
22
-
23
19
  handleContextMenu(evt) {
24
20
  var e = evt;
25
-
26
21
  if (e.contextActions == null) {
27
22
  e.contextActions = [];
28
23
  }
29
-
30
24
  var {
31
25
  action
32
26
  } = this.props;
33
-
34
27
  if (action.title == null && !action.menuElement) {
35
28
  return;
36
29
  }
37
-
38
30
  if (e.contextActions == null) {
39
31
  e.contextActions = [];
40
32
  }
41
-
42
33
  e.contextActions.push(action);
43
34
  log.debug('Received context menu event at global action! Menu items are now: ', e.contextActions);
44
35
  }
45
-
46
36
  handleKeyDown(e) {
47
37
  var {
48
38
  action
49
39
  } = this.props;
50
-
51
40
  if (!ContextActionUtils.actionsDisabled && action.shortcut !== undefined && action.shortcut.matchesEvent(e)) {
52
41
  var _action$action;
53
-
54
42
  log.debug('Global hotkey matched!', e);
55
43
  (_action$action = action.action) === null || _action$action === void 0 ? void 0 : _action$action.call(action, e);
56
44
  e.preventDefault();
57
45
  e.stopPropagation();
58
46
  }
59
47
  }
60
-
61
48
  render() {
62
49
  return null;
63
50
  }
64
-
65
51
  }
66
-
67
52
  export default GlobalContextAction;
68
53
  //# sourceMappingURL=GlobalContextAction.js.map