@deephaven/components 0.22.3-embed-pandas.11 → 0.23.0

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 (223) 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.d.ts +9 -9
  12. package/dist/Button.d.ts.map +1 -1
  13. package/dist/Button.js +8 -34
  14. package/dist/Button.js.map +1 -1
  15. package/dist/ButtonGroup.d.ts +7 -7
  16. package/dist/ButtonGroup.d.ts.map +1 -1
  17. package/dist/ButtonGroup.js +2 -4
  18. package/dist/ButtonGroup.js.map +1 -1
  19. package/dist/ButtonOld.js.map +1 -1
  20. package/dist/CardFlip.d.ts +2 -2
  21. package/dist/CardFlip.d.ts.map +1 -1
  22. package/dist/CardFlip.js +2 -7
  23. package/dist/CardFlip.js.map +1 -1
  24. package/dist/Checkbox.js +3 -14
  25. package/dist/Checkbox.js.map +1 -1
  26. package/dist/Collapse.d.ts +1 -1
  27. package/dist/Collapse.js +0 -15
  28. package/dist/Collapse.js.map +1 -1
  29. package/dist/ComboBox.js +4 -83
  30. package/dist/ComboBox.js.map +1 -1
  31. package/dist/CopyButton.d.ts +22 -0
  32. package/dist/CopyButton.d.ts.map +1 -0
  33. package/dist/CopyButton.js +30 -0
  34. package/dist/CopyButton.js.map +1 -0
  35. package/dist/CustomTimeSelect.d.ts +3 -3
  36. package/dist/CustomTimeSelect.d.ts.map +1 -1
  37. package/dist/CustomTimeSelect.js +2 -86
  38. package/dist/CustomTimeSelect.js.map +1 -1
  39. package/dist/DateInput.d.ts +1 -1
  40. package/dist/DateInput.d.ts.map +1 -1
  41. package/dist/DateInput.js.map +1 -1
  42. package/dist/DateInputUtils.js +0 -7
  43. package/dist/DateInputUtils.js.map +1 -1
  44. package/dist/DateTimeInput.d.ts +1 -1
  45. package/dist/DateTimeInput.d.ts.map +1 -1
  46. package/dist/DateTimeInput.js +7 -10
  47. package/dist/DateTimeInput.js.map +1 -1
  48. package/dist/DebouncedSearchInput.js +0 -14
  49. package/dist/DebouncedSearchInput.js.map +1 -1
  50. package/dist/DragUtils.d.ts +1 -1
  51. package/dist/DragUtils.d.ts.map +1 -1
  52. package/dist/DragUtils.js +4 -16
  53. package/dist/DragUtils.js.map +1 -1
  54. package/dist/DraggableItemList.d.ts +4 -4
  55. package/dist/DraggableItemList.d.ts.map +1 -1
  56. package/dist/DraggableItemList.js +22 -44
  57. package/dist/DraggableItemList.js.map +1 -1
  58. package/dist/EditableItemList.d.ts +1 -1
  59. package/dist/EditableItemList.d.ts.map +1 -1
  60. package/dist/EditableItemList.js +2 -6
  61. package/dist/EditableItemList.js.map +1 -1
  62. package/dist/HierarchicalCheckboxMenu.d.ts +3 -3
  63. package/dist/HierarchicalCheckboxMenu.d.ts.map +1 -1
  64. package/dist/HierarchicalCheckboxMenu.js +6 -28
  65. package/dist/HierarchicalCheckboxMenu.js.map +1 -1
  66. package/dist/ItemList.d.ts +5 -5
  67. package/dist/ItemList.d.ts.map +1 -1
  68. package/dist/ItemList.js +22 -115
  69. package/dist/ItemList.js.map +1 -1
  70. package/dist/ItemListItem.d.ts +0 -1
  71. package/dist/ItemListItem.d.ts.map +1 -1
  72. package/dist/ItemListItem.js +26 -50
  73. package/dist/ItemListItem.js.map +1 -1
  74. package/dist/LoadingOverlay.d.ts +2 -2
  75. package/dist/LoadingOverlay.d.ts.map +1 -1
  76. package/dist/LoadingOverlay.js +3 -5
  77. package/dist/LoadingOverlay.js.map +1 -1
  78. package/dist/LoadingSpinner.d.ts +2 -2
  79. package/dist/LoadingSpinner.d.ts.map +1 -1
  80. package/dist/LoadingSpinner.js +2 -4
  81. package/dist/LoadingSpinner.js.map +1 -1
  82. package/dist/MaskedInput.d.ts +2 -2
  83. package/dist/MaskedInput.d.ts.map +1 -1
  84. package/dist/MaskedInput.js +26 -85
  85. package/dist/MaskedInput.js.map +1 -1
  86. package/dist/Option.d.ts +2 -2
  87. package/dist/Option.d.ts.map +1 -1
  88. package/dist/Option.js +2 -4
  89. package/dist/Option.js.map +1 -1
  90. package/dist/RadioGroup.d.ts +2 -2
  91. package/dist/RadioGroup.d.ts.map +1 -1
  92. package/dist/RadioGroup.js +4 -6
  93. package/dist/RadioGroup.js.map +1 -1
  94. package/dist/RadioItem.d.ts +1 -1
  95. package/dist/RadioItem.d.ts.map +1 -1
  96. package/dist/RadioItem.js +0 -1
  97. package/dist/RadioItem.js.map +1 -1
  98. package/dist/SearchInput.js +2 -13
  99. package/dist/SearchInput.js.map +1 -1
  100. package/dist/Select.d.ts +2 -2
  101. package/dist/Select.d.ts.map +1 -1
  102. package/dist/Select.js +2 -4
  103. package/dist/Select.js.map +1 -1
  104. package/dist/SelectValueList.d.ts +1 -1
  105. package/dist/SelectValueList.d.ts.map +1 -1
  106. package/dist/SelectValueList.js +0 -28
  107. package/dist/SelectValueList.js.map +1 -1
  108. package/dist/SocketedButton.d.ts +1 -1
  109. package/dist/SocketedButton.d.ts.map +1 -1
  110. package/dist/SocketedButton.js.map +1 -1
  111. package/dist/ThemeExport.d.ts +4 -4
  112. package/dist/ThemeExport.js +0 -4
  113. package/dist/ThemeExport.js.map +1 -1
  114. package/dist/TimeInput.d.ts +2 -2
  115. package/dist/TimeInput.d.ts.map +1 -1
  116. package/dist/TimeInput.js +2 -12
  117. package/dist/TimeInput.js.map +1 -1
  118. package/dist/TimeSlider.d.ts +2 -2
  119. package/dist/TimeSlider.d.ts.map +1 -1
  120. package/dist/TimeSlider.js +19 -33
  121. package/dist/TimeSlider.js.map +1 -1
  122. package/dist/ToastNotification.d.ts +6 -6
  123. package/dist/ToastNotification.d.ts.map +1 -1
  124. package/dist/ToastNotification.js +2 -4
  125. package/dist/ToastNotification.js.map +1 -1
  126. package/dist/UISwitch.d.ts +2 -2
  127. package/dist/UISwitch.d.ts.map +1 -1
  128. package/dist/UISwitch.js +2 -4
  129. package/dist/UISwitch.js.map +1 -1
  130. package/dist/ValidateLabelInput.d.ts +1 -1
  131. package/dist/ValidateLabelInput.d.ts.map +1 -1
  132. package/dist/ValidateLabelInput.js +3 -3
  133. package/dist/ValidateLabelInput.js.map +1 -1
  134. package/dist/context-actions/ContextActionUtils.d.ts +3 -15
  135. package/dist/context-actions/ContextActionUtils.d.ts.map +1 -1
  136. package/dist/context-actions/ContextActionUtils.js +8 -85
  137. package/dist/context-actions/ContextActionUtils.js.map +1 -1
  138. package/dist/context-actions/ContextActions.js +1 -34
  139. package/dist/context-actions/ContextActions.js.map +1 -1
  140. package/dist/context-actions/ContextMenu.js +29 -110
  141. package/dist/context-actions/ContextMenu.js.map +1 -1
  142. package/dist/context-actions/ContextMenuItem.d.ts.map +1 -1
  143. package/dist/context-actions/ContextMenuItem.js +3 -19
  144. package/dist/context-actions/ContextMenuItem.js.map +1 -1
  145. package/dist/context-actions/ContextMenuRoot.d.ts +1 -1
  146. package/dist/context-actions/ContextMenuRoot.d.ts.map +1 -1
  147. package/dist/context-actions/ContextMenuRoot.js +7 -26
  148. package/dist/context-actions/ContextMenuRoot.js.map +1 -1
  149. package/dist/context-actions/GlobalContextAction.js +0 -15
  150. package/dist/context-actions/GlobalContextAction.js.map +1 -1
  151. package/dist/context-actions/GlobalContextActions.js +0 -6
  152. package/dist/context-actions/GlobalContextActions.js.map +1 -1
  153. package/dist/context-actions/index.js.map +1 -1
  154. package/dist/index.d.ts +1 -0
  155. package/dist/index.d.ts.map +1 -1
  156. package/dist/index.js +1 -0
  157. package/dist/index.js.map +1 -1
  158. package/dist/menu-actions/DropdownMenu.d.ts +3 -3
  159. package/dist/menu-actions/DropdownMenu.d.ts.map +1 -1
  160. package/dist/menu-actions/DropdownMenu.js +4 -32
  161. package/dist/menu-actions/DropdownMenu.js.map +1 -1
  162. package/dist/menu-actions/Menu.d.ts +3 -3
  163. package/dist/menu-actions/Menu.d.ts.map +1 -1
  164. package/dist/menu-actions/Menu.js +7 -52
  165. package/dist/menu-actions/Menu.js.map +1 -1
  166. package/dist/menu-actions/index.d.ts +2 -1
  167. package/dist/menu-actions/index.d.ts.map +1 -1
  168. package/dist/menu-actions/index.js +2 -2
  169. package/dist/menu-actions/index.js.map +1 -1
  170. package/dist/modal/Modal.d.ts +2 -2
  171. package/dist/modal/Modal.d.ts.map +1 -1
  172. package/dist/modal/Modal.js +3 -9
  173. package/dist/modal/Modal.js.map +1 -1
  174. package/dist/modal/ModalBody.d.ts +1 -1
  175. package/dist/modal/ModalBody.d.ts.map +1 -1
  176. package/dist/modal/ModalBody.js +2 -4
  177. package/dist/modal/ModalBody.js.map +1 -1
  178. package/dist/modal/ModalFooter.d.ts +1 -1
  179. package/dist/modal/ModalFooter.d.ts.map +1 -1
  180. package/dist/modal/ModalFooter.js +2 -4
  181. package/dist/modal/ModalFooter.js.map +1 -1
  182. package/dist/modal/ModalHeader.d.ts +1 -1
  183. package/dist/modal/ModalHeader.d.ts.map +1 -1
  184. package/dist/modal/ModalHeader.js +2 -4
  185. package/dist/modal/ModalHeader.js.map +1 -1
  186. package/dist/modal/index.js.map +1 -1
  187. package/dist/navigation/Menu.d.ts +3 -3
  188. package/dist/navigation/Menu.d.ts.map +1 -1
  189. package/dist/navigation/Menu.js +2 -2
  190. package/dist/navigation/Menu.js.map +1 -1
  191. package/dist/navigation/MenuItem.d.ts +4 -4
  192. package/dist/navigation/MenuItem.d.ts.map +1 -1
  193. package/dist/navigation/MenuItem.js +4 -7
  194. package/dist/navigation/MenuItem.js.map +1 -1
  195. package/dist/navigation/Page.d.ts +2 -2
  196. package/dist/navigation/Page.d.ts.map +1 -1
  197. package/dist/navigation/Page.js +2 -3
  198. package/dist/navigation/Page.js.map +1 -1
  199. package/dist/navigation/Stack.d.ts +2 -2
  200. package/dist/navigation/Stack.d.ts.map +1 -1
  201. package/dist/navigation/Stack.js +3 -6
  202. package/dist/navigation/Stack.js.map +1 -1
  203. package/dist/navigation/index.js.map +1 -1
  204. package/dist/popper/Popper.d.ts +2 -2
  205. package/dist/popper/Popper.d.ts.map +1 -1
  206. package/dist/popper/Popper.js +13 -46
  207. package/dist/popper/Popper.js.map +1 -1
  208. package/dist/popper/Tooltip.d.ts +1 -1
  209. package/dist/popper/Tooltip.d.ts.map +1 -1
  210. package/dist/popper/Tooltip.js +0 -56
  211. package/dist/popper/Tooltip.js.map +1 -1
  212. package/dist/popper/index.js.map +1 -1
  213. package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
  214. package/dist/shortcuts/Shortcut.d.ts +2 -2
  215. package/dist/shortcuts/Shortcut.d.ts.map +1 -1
  216. package/dist/shortcuts/Shortcut.js +19 -76
  217. package/dist/shortcuts/Shortcut.js.map +1 -1
  218. package/dist/shortcuts/ShortcutRegistry.d.ts +1 -1
  219. package/dist/shortcuts/ShortcutRegistry.d.ts.map +1 -1
  220. package/dist/shortcuts/ShortcutRegistry.js +3 -18
  221. package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
  222. package/dist/shortcuts/index.js.map +1 -1
  223. package/package.json +8 -8
@@ -1,9 +1,6 @@
1
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
2
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
3
  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; }
6
-
7
4
  import React, { PureComponent } from 'react';
8
5
  import classNames from 'classnames';
9
6
  import Log from '@deephaven/log';
@@ -12,33 +9,23 @@ import ContextActionUtils from "./ContextActionUtils.js";
12
9
  import ContextMenuItem from "./ContextMenuItem.js";
13
10
  import LoadingSpinner from "../LoadingSpinner.js";
14
11
  var log = Log.module('ContextMenu');
15
-
16
12
  /** Do not use this class directly. Use ContextMenuRoot and ContextActions instead. */
17
13
  class ContextMenu extends PureComponent {
18
14
  static handleContextMenu(e) {
19
15
  if (e.metaKey) {
20
16
  return;
21
17
  }
22
-
23
18
  e.stopPropagation();
24
19
  e.preventDefault();
25
20
  }
26
-
27
21
  constructor(props) {
28
22
  super(props);
29
-
30
23
  _defineProperty(this, "container", void 0);
31
-
32
24
  _defineProperty(this, "oldFocus", void 0);
33
-
34
25
  _defineProperty(this, "activeSubMenuRef", void 0);
35
-
36
26
  _defineProperty(this, "subMenuTimer", void 0);
37
-
38
27
  _defineProperty(this, "rAF", void 0);
39
-
40
28
  _defineProperty(this, "initialPosition", void 0);
41
-
42
29
  this.handleBlur = this.handleBlur.bind(this);
43
30
  this.handleCloseSubMenu = this.handleCloseSubMenu.bind(this);
44
31
  this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -69,18 +56,17 @@ class ContextMenu extends PureComponent {
69
56
  mouseIndex: -1
70
57
  };
71
58
  }
72
-
73
59
  componentDidMount() {
74
60
  this.initMenu();
75
61
  this.verifyPosition();
76
- window.addEventListener('resize', this.handleWindowResize); // rAF is needed to wait for a submenus popper to be created before
62
+ window.addEventListener('resize', this.handleWindowResize);
63
+
64
+ // rAF is needed to wait for a submenus popper to be created before
77
65
  // attempting to set focus, however on a quick mount/unmount when
78
66
  // mousing past an item, the submenu could be unmounted before the
79
67
  // async rAF finishes, so it is cancelled in willUnmount()
80
-
81
68
  this.rAF = window.requestAnimationFrame(() => {
82
69
  var _this$container$curre;
83
-
84
70
  (_this$container$curre = this.container.current) === null || _this$container$curre === void 0 ? void 0 : _this$container$curre.focus();
85
71
  var {
86
72
  onMenuOpened
@@ -88,7 +74,6 @@ class ContextMenu extends PureComponent {
88
74
  onMenuOpened(this);
89
75
  });
90
76
  }
91
-
92
77
  componentDidUpdate(prevProps, prevState) {
93
78
  var {
94
79
  actions
@@ -96,11 +81,9 @@ class ContextMenu extends PureComponent {
96
81
  var {
97
82
  activeSubMenu
98
83
  } = this.state;
99
-
100
84
  if (activeSubMenu !== prevState.activeSubMenu) {
101
85
  if (activeSubMenu == null) {
102
86
  var _this$container$curre2;
103
-
104
87
  // close sub menu, refocus parent menu
105
88
  (_this$container$curre2 = this.container.current) === null || _this$container$curre2 === void 0 ? void 0 : _this$container$curre2.focus();
106
89
  } else {
@@ -108,46 +91,36 @@ class ContextMenu extends PureComponent {
108
91
  this.setActiveSubMenuPosition();
109
92
  }
110
93
  }
111
-
112
94
  if (prevProps.actions !== actions) {
113
95
  this.initMenu();
114
-
115
96
  if (this.container.current == null || !this.container.current.contains(document.activeElement)) {
116
97
  var _this$container$curre3;
117
-
118
98
  (_this$container$curre3 = this.container.current) === null || _this$container$curre3 === void 0 ? void 0 : _this$container$curre3.focus();
119
99
  }
120
100
  }
121
-
122
101
  this.verifyPosition();
123
102
  }
124
-
125
103
  componentWillUnmount() {
126
104
  this.cancelPromises();
127
105
  window.removeEventListener('resize', this.handleWindowResize);
128
106
  cancelAnimationFrame(this.rAF);
129
107
  }
130
-
131
108
  getKeyboardIndex() {
132
109
  var {
133
110
  options
134
111
  } = this.props;
135
-
136
112
  if (options.separateKeyboardMouse !== undefined && options.separateKeyboardMouse) {
137
113
  var {
138
114
  keyboardIndex
139
115
  } = this.state;
140
116
  return keyboardIndex;
141
117
  }
142
-
143
118
  return this.getMouseIndex();
144
119
  }
145
-
146
120
  setKeyboardIndex(index) {
147
121
  var {
148
122
  options
149
123
  } = this.props;
150
-
151
124
  if (options.separateKeyboardMouse !== undefined && options.separateKeyboardMouse) {
152
125
  this.setState({
153
126
  keyboardIndex: index
@@ -156,20 +129,17 @@ class ContextMenu extends PureComponent {
156
129
  this.setMouseIndex(index);
157
130
  }
158
131
  }
159
-
160
132
  getMouseIndex() {
161
133
  var {
162
134
  mouseIndex
163
135
  } = this.state;
164
136
  return mouseIndex;
165
137
  }
166
-
167
138
  setMouseIndex(index) {
168
139
  this.setState({
169
140
  mouseIndex: index
170
141
  });
171
142
  }
172
-
173
143
  initMenu() {
174
144
  // cancel any pending close and promises
175
145
  this.cancelPromises();
@@ -178,27 +148,22 @@ class ContextMenu extends PureComponent {
178
148
  options
179
149
  } = this.props;
180
150
  var keyboardIndex = options.initialKeyboardIndex;
181
-
182
151
  if (keyboardIndex === undefined) {
183
152
  keyboardIndex = -1;
184
153
  }
185
-
186
154
  var {
187
155
  actions
188
156
  } = this.props;
189
157
  var menuItems = ContextActionUtils.getMenuItems(actions);
190
158
  var nonPromiseItems = [];
191
-
192
159
  for (var i = menuItems.length - 1; i >= 0; i -= 1) {
193
160
  var menuItem = menuItems[i];
194
-
195
161
  if (menuItem instanceof Promise) {
196
162
  this.initMenuPromise(menuItem);
197
163
  } else {
198
164
  nonPromiseItems.push(menuItem);
199
165
  }
200
166
  }
201
-
202
167
  this.setState({
203
168
  mouseIndex: -1,
204
169
  keyboardIndex,
@@ -206,7 +171,6 @@ class ContextMenu extends PureComponent {
206
171
  menuItems: ContextActionUtils.sortActions(nonPromiseItems)
207
172
  });
208
173
  }
209
-
210
174
  initMenuPromise(promise) {
211
175
  // make all promises cancellable
212
176
  var cancellablePromise = PromiseUtils.makeCancelable(promise);
@@ -216,7 +180,6 @@ class ContextMenu extends PureComponent {
216
180
  cancellablePromise.then(resolvedMenuItems => {
217
181
  this.setState(state => {
218
182
  var index = state.pendingItems.indexOf(cancellablePromise);
219
-
220
183
  if (index >= 0) {
221
184
  var pendingItems = state.pendingItems.slice();
222
185
  pendingItems.splice(index, 1);
@@ -224,20 +187,18 @@ class ContextMenu extends PureComponent {
224
187
  menuItems: ContextActionUtils.sortActions(state.menuItems.concat(resolvedMenuItems)),
225
188
  pendingItems
226
189
  };
227
- } // This item is stale, don't update the menu
228
-
229
-
190
+ }
191
+ // This item is stale, don't update the menu
230
192
  return null;
231
193
  });
232
194
  }, error => {
233
195
  if (PromiseUtils.isCanceled(error)) {
234
196
  return; // Canceled promise is ignored
235
- } // remove failed item from pending list
236
-
197
+ }
237
198
 
199
+ // remove failed item from pending list
238
200
  this.setState(state => {
239
201
  var index = state.pendingItems.indexOf(cancellablePromise);
240
-
241
202
  if (index >= 0) {
242
203
  var pendingItems = state.pendingItems.slice();
243
204
  pendingItems.splice(index, 1);
@@ -245,30 +206,29 @@ class ContextMenu extends PureComponent {
245
206
  pendingItems
246
207
  };
247
208
  }
248
-
249
209
  return null;
250
- }); // Log the error
210
+ });
251
211
 
212
+ // Log the error
252
213
  log.error(error);
253
214
  });
254
215
  }
255
-
256
216
  cancelPromises() {
257
217
  var {
258
218
  pendingItems
259
219
  } = this.state;
260
220
  pendingItems.map(item => item.cancel());
261
221
  }
222
+
262
223
  /**
263
224
  * Sets the unverfied start position of a submenu. Submenu then self-verfies
264
225
  * its own position and potentially reports back a new position.
265
226
  */
266
-
267
-
268
227
  setActiveSubMenuPosition() {
269
228
  if (this.activeSubMenuRef.current === null) return;
270
- var parentRect = this.activeSubMenuRef.current.getBoundingClientRect(); // intentionally rect.right, we want the sub menu to start at the right edge of the current menu
229
+ var parentRect = this.activeSubMenuRef.current.getBoundingClientRect();
271
230
 
231
+ // intentionally rect.right, we want the sub menu to start at the right edge of the current menu
272
232
  this.setState({
273
233
  subMenuTop: parentRect.top,
274
234
  subMenuLeft: parentRect.right,
@@ -276,6 +236,7 @@ class ContextMenu extends PureComponent {
276
236
  subMenuParentWidth: parentRect.width
277
237
  });
278
238
  }
239
+
279
240
  /**
280
241
  * Verifies the position of this menu in relation to the parent to make sure it's on screen.
281
242
  * Will update the top left state (updatePosition) if necessary (causing a re-render)
@@ -284,11 +245,8 @@ class ContextMenu extends PureComponent {
284
245
  * somethings to better fit on screen, such as the "nudge" offset position, and further
285
246
  * allow overflow scrolling for large menus in a small window.
286
247
  */
287
-
288
-
289
248
  verifyPosition() {
290
249
  var _this$container$curre4, _this$container$curre5, _this$container$curre6, _this$container$curre7;
291
-
292
250
  var {
293
251
  options,
294
252
  updatePosition,
@@ -297,14 +255,13 @@ class ContextMenu extends PureComponent {
297
255
  top: oldTop,
298
256
  left: oldLeft
299
257
  } = this.props;
300
-
301
258
  if (!this.container.current || options.doNotVerifyPosition != null && options.doNotVerifyPosition) {
302
259
  return;
303
- } // initial position is used rather than current position,
260
+ }
261
+
262
+ // initial position is used rather than current position,
304
263
  // as the number of menu items can change (actions can bubble)
305
264
  // and menu should always be positioned relative to spawn point
306
-
307
-
308
265
  var {
309
266
  top,
310
267
  left
@@ -317,13 +274,12 @@ class ContextMenu extends PureComponent {
317
274
  height: 0
318
275
  };
319
276
  var hasOverflow = ((_this$container$curre6 = (_this$container$curre7 = this.container.current) === null || _this$container$curre7 === void 0 ? void 0 : _this$container$curre7.scrollHeight) !== null && _this$container$curre6 !== void 0 ? _this$container$curre6 : 0) > window.innerHeight;
320
-
321
277
  if (height === 0 || width === 0) {
322
278
  // We don't have a height or width yet, don't bother doing anything
323
279
  return;
324
- } // does it fit below?
325
-
280
+ }
326
281
 
282
+ // does it fit below?
327
283
  if (top + height > window.innerHeight) {
328
284
  // can it be flipped to above? include offset if submenu (defaults to 0 if not submenu)
329
285
  if (top - height - subMenuParentHeight > 0) {
@@ -334,12 +290,10 @@ class ContextMenu extends PureComponent {
334
290
  top = window.innerHeight - height;
335
291
  }
336
292
  }
337
-
338
293
  if (left + width > window.innerWidth) {
339
294
  // less picky about left right positioning, just keep it going off to right
340
295
  left = left - width - subMenuParentWidth;
341
296
  }
342
-
343
297
  if (oldLeft !== left || oldTop !== top) {
344
298
  // parent owns positioning as single source of truth, ask to update props
345
299
  this.setState({
@@ -347,48 +301,41 @@ class ContextMenu extends PureComponent {
347
301
  });
348
302
  updatePosition(top, left);
349
303
  }
350
- } // since window resize doesn't trigger blur, listen and close the menu
351
-
304
+ }
352
305
 
306
+ // since window resize doesn't trigger blur, listen and close the menu
353
307
  handleWindowResize() {
354
308
  if (!this.container.current) {
355
309
  return;
356
310
  }
357
-
358
311
  this.closeMenu(true);
359
312
  }
360
-
361
313
  handleBlur(e) {
362
314
  if (!this.container.current) {
363
315
  log.warn('Container is null!');
364
316
  return;
365
317
  }
366
-
367
318
  if (!this.container.current.contains(e.relatedTarget)) {
368
319
  var element = e.relatedTarget;
369
320
  var isContextMenuChild = false;
370
-
371
321
  while (element && !isContextMenuChild) {
372
322
  isContextMenuChild = element.hasAttribute('data-dh-context-menu');
373
323
  element = element.parentElement;
374
324
  }
375
-
376
325
  if (!isContextMenuChild) {
377
326
  // close all submenus on blur
378
327
  this.closeMenu(true);
379
328
  }
380
329
  }
381
330
  }
382
- /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */
383
-
384
331
 
332
+ /** Returns whether the specified key should remove the menu. Depends on the side the parent is on. */
385
333
  isEscapeKey(key) {
386
334
  var {
387
335
  left
388
336
  } = this.props;
389
337
  return key === 'Escape' || left < 0 && key === 'ArrowRight' || key === 'ArrowLeft';
390
338
  }
391
-
392
339
  handleKeyDown(e) {
393
340
  var {
394
341
  menuItems
@@ -396,15 +343,12 @@ class ContextMenu extends PureComponent {
396
343
  var oldFocus = this.getKeyboardIndex();
397
344
  var newFocus = oldFocus;
398
345
  var openSubMenu = false;
399
-
400
346
  if (e.key === 'Enter' || e.key === ' ') {
401
347
  if (oldFocus >= 0 && oldFocus < menuItems.length) {
402
348
  this.handleMenuItemClick(menuItems[oldFocus], e);
403
349
  }
404
-
405
350
  return;
406
351
  }
407
-
408
352
  if (e.key === 'ArrowRight') {
409
353
  if (oldFocus >= 0 && oldFocus <= menuItems.length) {
410
354
  openSubMenu = true;
@@ -418,30 +362,25 @@ class ContextMenu extends PureComponent {
418
362
  } else if (e.key === 'ArrowDown' || e.key === 'Tab') {
419
363
  newFocus = ContextActionUtils.getNextMenuItem(newFocus, 1, menuItems);
420
364
  }
421
-
422
365
  if (openSubMenu) {
423
366
  this.openSubMenu(oldFocus);
424
367
  e.preventDefault();
425
368
  e.stopPropagation();
426
369
  return;
427
370
  }
428
-
429
371
  if (oldFocus !== newFocus) {
430
372
  if (newFocus !== null) {
431
373
  this.setKeyboardIndex(newFocus);
432
374
  } else {
433
375
  this.closeMenu();
434
-
435
376
  if (this.oldFocus instanceof HTMLElement) {
436
377
  this.oldFocus.focus();
437
378
  }
438
379
  }
439
-
440
380
  e.preventDefault();
441
381
  e.stopPropagation();
442
382
  }
443
383
  }
444
-
445
384
  openSubMenu(index) {
446
385
  var {
447
386
  menuItems,
@@ -455,7 +394,6 @@ class ContextMenu extends PureComponent {
455
394
  subMenuLeft: null
456
395
  });
457
396
  }
458
-
459
397
  closeMenu() {
460
398
  var closeAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
461
399
  var {
@@ -468,13 +406,11 @@ class ContextMenu extends PureComponent {
468
406
  onMenuClosed(this);
469
407
  });
470
408
  }
471
-
472
409
  closeSubMenu() {
473
410
  this.setState({
474
411
  activeSubMenu: null
475
412
  });
476
413
  }
477
-
478
414
  handleCloseSubMenu(closeAllMenus) {
479
415
  if (closeAllMenus) {
480
416
  this.closeMenu(true);
@@ -482,14 +418,12 @@ class ContextMenu extends PureComponent {
482
418
  this.closeSubMenu();
483
419
  }
484
420
  }
485
-
486
421
  handleMenuItemClick(menuItem, e) {
487
422
  e.preventDefault();
488
423
  e.stopPropagation();
489
424
  var {
490
425
  menuItems
491
426
  } = this.state;
492
-
493
427
  if (menuItem != null && (menuItem.disabled === undefined || !menuItem.disabled)) {
494
428
  if (menuItem.actions != null) {
495
429
  this.openSubMenu(menuItems.indexOf(menuItem));
@@ -499,31 +433,25 @@ class ContextMenu extends PureComponent {
499
433
  }
500
434
  }
501
435
  }
502
-
503
436
  handleMenuItemContextMenu(menuItem, e) {
504
437
  if (e.metaKey) {
505
438
  return;
506
439
  }
507
-
508
440
  this.handleMenuItemClick(menuItem, e);
509
441
  }
510
-
511
442
  handleMenuItemMouseMove(menuItem) {
512
443
  var {
513
444
  menuItems
514
445
  } = this.state;
515
446
  var focusIndex = menuItems.indexOf(menuItem);
516
447
  this.setMouseIndex(focusIndex);
517
-
518
448
  if (focusIndex >= 0 && focusIndex < menuItems.length && (menuItem.disabled === undefined || !menuItem.disabled)) {
519
449
  this.openSubMenu(focusIndex);
520
450
  }
521
451
  }
522
-
523
452
  handleMouseLeave() {
524
453
  this.setMouseIndex(-1);
525
454
  }
526
-
527
455
  render() {
528
456
  var menuItemElements = [];
529
457
  var {
@@ -542,16 +470,13 @@ class ContextMenu extends PureComponent {
542
470
  subMenuParentWidth,
543
471
  subMenuParentHeight
544
472
  } = this.state;
545
-
546
473
  for (var i = 0; i < menuItems.length; i += 1) {
547
474
  var menuItem = menuItems[i];
548
-
549
475
  if (i > 0 && menuItem.group !== menuItems[i - 1].group) {
550
476
  menuItemElements.push( /*#__PURE__*/React.createElement("hr", {
551
477
  key: "".concat(i, ".separator")
552
478
  }));
553
479
  }
554
-
555
480
  var menuItemElement = /*#__PURE__*/React.createElement(ContextMenuItem, {
556
481
  key: i,
557
482
  ref: activeSubMenu === i ? this.activeSubMenuRef : null,
@@ -565,20 +490,18 @@ class ContextMenu extends PureComponent {
565
490
  });
566
491
  menuItemElements.push(menuItemElement);
567
492
  }
568
-
569
493
  var pendingElement = null;
570
-
571
494
  if (pendingItems.length > 0) {
572
495
  pendingElement = /*#__PURE__*/React.createElement("div", {
573
496
  className: "loading"
574
497
  }, /*#__PURE__*/React.createElement(LoadingSpinner, null));
575
498
  }
576
-
577
499
  var {
578
500
  menuStyle,
579
501
  'data-testid': dataTestId
580
- } = this.props; // don't show submenu until it has an position initialized
502
+ } = this.props;
581
503
 
504
+ // don't show submenu until it has an position initialized
582
505
  var showSubmenu = activeSubMenu !== null && subMenuTop !== null && subMenuLeft !== null;
583
506
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
584
507
  className: classNames({
@@ -613,26 +536,22 @@ class ContextMenu extends PureComponent {
613
536
  subMenuParentHeight: subMenuParentHeight
614
537
  }));
615
538
  }
616
-
617
539
  }
618
-
619
540
  _defineProperty(ContextMenu, "defaultProps", {
620
541
  subMenuParentWidth: 0,
621
542
  subMenuParentHeight: 0,
622
-
623
- closeMenu() {// no-op
543
+ closeMenu() {
544
+ // no-op
624
545
  },
625
-
626
- onMenuOpened() {// no-op
546
+ onMenuOpened() {
547
+ // no-op
627
548
  },
628
-
629
- onMenuClosed() {// no-op
549
+ onMenuClosed() {
550
+ // no-op
630
551
  },
631
-
632
552
  options: {},
633
553
  menuStyle: {},
634
554
  'data-testid': undefined
635
555
  });
636
-
637
556
  export default ContextMenu;
638
557
  //# sourceMappingURL=ContextMenu.js.map