@deephaven/components 0.5.2-beta.0 → 0.6.1-demo.10

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 (119) hide show
  1. package/dist/AutoCompleteInput.js +410 -448
  2. package/dist/AutoCompleteInput.js.map +1 -1
  3. package/dist/AutoResizeTextarea.js +17 -46
  4. package/dist/AutoResizeTextarea.js.map +1 -1
  5. package/dist/BasicModal.js +18 -19
  6. package/dist/BasicModal.js.map +1 -1
  7. package/dist/Button.js +30 -21
  8. package/dist/Button.js.map +1 -1
  9. package/dist/ButtonGroup.js +6 -4
  10. package/dist/ButtonGroup.js.map +1 -1
  11. package/dist/ButtonOld.js +10 -8
  12. package/dist/ButtonOld.js.map +1 -1
  13. package/dist/CardFlip.js +10 -8
  14. package/dist/CardFlip.js.map +1 -1
  15. package/dist/Checkbox.js +18 -31
  16. package/dist/Checkbox.js.map +1 -1
  17. package/dist/Collapse.js +65 -105
  18. package/dist/Collapse.js.map +1 -1
  19. package/dist/ComboBox.js +432 -460
  20. package/dist/ComboBox.js.map +1 -1
  21. package/dist/CustomTimeSelect.js +485 -517
  22. package/dist/CustomTimeSelect.js.map +1 -1
  23. package/dist/DebouncedSearchInput.js +61 -91
  24. package/dist/DebouncedSearchInput.js.map +1 -1
  25. package/dist/DeephavenSpinner.js +6 -6
  26. package/dist/DeephavenSpinner.js.map +1 -1
  27. package/dist/DragUtils.js +65 -113
  28. package/dist/DragUtils.js.map +1 -1
  29. package/dist/DraggableItemList.d.ts +1 -0
  30. package/dist/DraggableItemList.d.ts.map +1 -1
  31. package/dist/DraggableItemList.js +219 -257
  32. package/dist/DraggableItemList.js.map +1 -1
  33. package/dist/HierarchicalCheckboxMenu.js +160 -227
  34. package/dist/HierarchicalCheckboxMenu.js.map +1 -1
  35. package/dist/ItemList.d.ts +4 -2
  36. package/dist/ItemList.d.ts.map +1 -1
  37. package/dist/ItemList.js +595 -598
  38. package/dist/ItemList.js.map +1 -1
  39. package/dist/ItemListItem.js +194 -215
  40. package/dist/ItemListItem.js.map +1 -1
  41. package/dist/LoadingOverlay.js +9 -10
  42. package/dist/LoadingOverlay.js.map +1 -1
  43. package/dist/LoadingSpinner.js +4 -3
  44. package/dist/LoadingSpinner.js.map +1 -1
  45. package/dist/MaskedInput.js +59 -70
  46. package/dist/MaskedInput.js.map +1 -1
  47. package/dist/Option.js +5 -3
  48. package/dist/Option.js.map +1 -1
  49. package/dist/RadioGroup.js +16 -34
  50. package/dist/RadioGroup.js.map +1 -1
  51. package/dist/RadioItem.js +14 -33
  52. package/dist/RadioItem.js.map +1 -1
  53. package/dist/SearchInput.js +42 -75
  54. package/dist/SearchInput.js.map +1 -1
  55. package/dist/Select.js +10 -8
  56. package/dist/Select.js.map +1 -1
  57. package/dist/SelectValueList.js +97 -134
  58. package/dist/SelectValueList.js.map +1 -1
  59. package/dist/SocketedButton.js +13 -11
  60. package/dist/SocketedButton.js.map +1 -1
  61. package/dist/ThemeExport.js.map +1 -1
  62. package/dist/TimeInput.js +16 -53
  63. package/dist/TimeInput.js.map +1 -1
  64. package/dist/TimeSlider.js +62 -88
  65. package/dist/TimeSlider.js.map +1 -1
  66. package/dist/ToastNotification.js +14 -13
  67. package/dist/ToastNotification.js.map +1 -1
  68. package/dist/UISwitch.js +9 -8
  69. package/dist/UISwitch.js.map +1 -1
  70. package/dist/context-actions/ContextActionUtils.js +173 -231
  71. package/dist/context-actions/ContextActionUtils.js.map +1 -1
  72. package/dist/context-actions/ContextActions.js +135 -177
  73. package/dist/context-actions/ContextActions.js.map +1 -1
  74. package/dist/context-actions/ContextMenu.js +509 -543
  75. package/dist/context-actions/ContextMenu.js.map +1 -1
  76. package/dist/context-actions/ContextMenuItem.js +32 -22
  77. package/dist/context-actions/ContextMenuItem.js.map +1 -1
  78. package/dist/context-actions/ContextMenuRoot.js +112 -152
  79. package/dist/context-actions/ContextMenuRoot.js.map +1 -1
  80. package/dist/context-actions/GlobalContextAction.js +49 -84
  81. package/dist/context-actions/GlobalContextAction.js.map +1 -1
  82. package/dist/context-actions/GlobalContextActions.js +25 -57
  83. package/dist/context-actions/GlobalContextActions.js.map +1 -1
  84. package/dist/context-actions/index.js +4 -4
  85. package/dist/context-actions/index.js.map +1 -1
  86. package/dist/index.js +39 -39
  87. package/dist/index.js.map +1 -1
  88. package/dist/menu-actions/DropdownMenu.js +126 -159
  89. package/dist/menu-actions/DropdownMenu.js.map +1 -1
  90. package/dist/menu-actions/Menu.js +215 -245
  91. package/dist/menu-actions/Menu.js.map +1 -1
  92. package/dist/menu-actions/index.js +1 -1
  93. package/dist/menu-actions/index.js.map +1 -1
  94. package/dist/navigation/Menu.js +14 -18
  95. package/dist/navigation/Menu.js.map +1 -1
  96. package/dist/navigation/MenuItem.js +15 -14
  97. package/dist/navigation/MenuItem.js.map +1 -1
  98. package/dist/navigation/Page.js +7 -5
  99. package/dist/navigation/Page.js.map +1 -1
  100. package/dist/navigation/Stack.js +14 -39
  101. package/dist/navigation/Stack.js.map +1 -1
  102. package/dist/navigation/index.js +4 -4
  103. package/dist/navigation/index.js.map +1 -1
  104. package/dist/popper/Popper.js +209 -235
  105. package/dist/popper/Popper.js.map +1 -1
  106. package/dist/popper/Tooltip.js +227 -257
  107. package/dist/popper/Tooltip.js.map +1 -1
  108. package/dist/popper/index.js +2 -2
  109. package/dist/popper/index.js.map +1 -1
  110. package/dist/shortcuts/GlobalShortcuts.js +2 -2
  111. package/dist/shortcuts/GlobalShortcuts.js.map +1 -1
  112. package/dist/shortcuts/Shortcut.js +263 -291
  113. package/dist/shortcuts/Shortcut.js.map +1 -1
  114. package/dist/shortcuts/ShortcutRegistry.js +48 -71
  115. package/dist/shortcuts/ShortcutRegistry.js.map +1 -1
  116. package/dist/shortcuts/index.js +4 -4
  117. package/dist/shortcuts/index.js.map +1 -1
  118. package/dist/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +30 -54
@@ -1,34 +1,12 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
1
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
2
 
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
4
 
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
-
9
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
10
-
11
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
12
-
13
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
14
-
15
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
-
17
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
-
19
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
20
-
21
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
22
-
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
-
25
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
-
27
5
  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; }
28
6
 
29
7
  import React, { PureComponent } from 'react';
30
- import ContextActionUtils from '../context-actions/ContextActionUtils';
31
- import ContextMenuItem from '../context-actions/ContextMenuItem';
8
+ import ContextActionUtils from "../context-actions/ContextActionUtils.js";
9
+ import ContextMenuItem from "../context-actions/ContextMenuItem.js";
32
10
 
33
11
  /**
34
12
  * Do not use this class directly. Use DropdownMenu instead.
@@ -38,272 +16,264 @@ import ContextMenuItem from '../context-actions/ContextMenuItem';
38
16
  * but still re-uses styling from context-menu. Depending on how usage evolves, may get split further.
39
17
  *
40
18
  */
41
- var Menu = /*#__PURE__*/function (_PureComponent) {
42
- _inherits(Menu, _PureComponent);
43
-
44
- var _super = _createSuper(Menu);
45
-
46
- function Menu(props) {
19
+ class Menu extends PureComponent {
20
+ constructor(props) {
47
21
  var _options$initialKeybo;
48
22
 
49
- var _this;
50
-
51
- _classCallCheck(this, Menu);
52
-
53
- _this = _super.call(this, props);
23
+ super(props);
54
24
 
55
- _defineProperty(_assertThisInitialized(_this), "container", void 0);
25
+ _defineProperty(this, "container", void 0);
56
26
 
57
- _defineProperty(_assertThisInitialized(_this), "oldFocus", void 0);
27
+ _defineProperty(this, "oldFocus", void 0);
58
28
 
59
- _defineProperty(_assertThisInitialized(_this), "rAF", void 0);
29
+ _defineProperty(this, "rAF", void 0);
60
30
 
61
- _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
62
- _this.handleMenuItemClick = _this.handleMenuItemClick.bind(_assertThisInitialized(_this));
63
- _this.handleMenuItemMouseMove = _this.handleMenuItemMouseMove.bind(_assertThisInitialized(_this));
64
- _this.handleMouseLeave = _this.handleMouseLeave.bind(_assertThisInitialized(_this));
65
- _this.handleCloseMenu = _this.handleCloseMenu.bind(_assertThisInitialized(_this));
66
- _this.container = /*#__PURE__*/React.createRef();
67
- _this.oldFocus = document.activeElement;
68
- _this.rAF = 0;
69
- var options = props.options;
31
+ this.handleKeyDown = this.handleKeyDown.bind(this);
32
+ this.handleMenuItemClick = this.handleMenuItemClick.bind(this);
33
+ this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);
34
+ this.handleMouseLeave = this.handleMouseLeave.bind(this);
35
+ this.handleCloseMenu = this.handleCloseMenu.bind(this);
36
+ this.container = /*#__PURE__*/React.createRef();
37
+ this.oldFocus = document.activeElement;
38
+ this.rAF = 0;
39
+ var {
40
+ options
41
+ } = props;
70
42
  var keyboardIndex = (_options$initialKeybo = options.initialKeyboardIndex) !== null && _options$initialKeybo !== void 0 ? _options$initialKeybo : -1;
71
- _this.state = {
43
+ this.state = {
72
44
  menuItems: [],
73
- keyboardIndex: keyboardIndex,
45
+ keyboardIndex,
74
46
  mouseIndex: -1
75
47
  };
76
- return _this;
77
48
  }
78
49
 
79
- _createClass(Menu, [{
80
- key: "componentDidMount",
81
- value: function componentDidMount() {
82
- var _this2 = this;
50
+ componentDidMount() {
51
+ this.initMenu();
52
+ this.rAF = window.requestAnimationFrame(() => {
53
+ var _this$container$curre;
54
+
55
+ // set initial focus to container so keyboard navigation works
56
+ // components can still override focus in onMenuOpened callback
57
+ (_this$container$curre = this.container.current) === null || _this$container$curre === void 0 ? void 0 : _this$container$curre.focus();
58
+ var {
59
+ onMenuOpened
60
+ } = this.props;
61
+ onMenuOpened(this);
62
+ });
63
+ }
64
+
65
+ componentDidUpdate(prevProps) {
66
+ var {
67
+ actions
68
+ } = this.props;
83
69
 
70
+ if (prevProps.actions !== actions) {
84
71
  this.initMenu();
85
- this.rAF = window.requestAnimationFrame(function () {
86
- var _this2$container$curr;
87
-
88
- // set initial focus to container so keyboard navigation works
89
- // components can still override focus in onMenuOpened callback
90
- (_this2$container$curr = _this2.container.current) === null || _this2$container$curr === void 0 ? void 0 : _this2$container$curr.focus();
91
- var onMenuOpened = _this2.props.onMenuOpened;
92
- onMenuOpened(_this2);
93
- });
94
72
  }
95
- }, {
96
- key: "componentDidUpdate",
97
- value: function componentDidUpdate(prevProps) {
98
- var actions = this.props.actions;
73
+ }
99
74
 
100
- if (prevProps.actions !== actions) {
101
- this.initMenu();
102
- }
103
- }
104
- }, {
105
- key: "componentWillUnmount",
106
- value: function componentWillUnmount() {
107
- cancelAnimationFrame(this.rAF);
108
- }
109
- }, {
110
- key: "getKeyboardIndex",
111
- value: function getKeyboardIndex() {
112
- var options = this.props.options;
113
-
114
- if (options.separateKeyboardMouse) {
115
- var keyboardIndex = this.state.keyboardIndex;
116
- return keyboardIndex;
117
- }
75
+ componentWillUnmount() {
76
+ cancelAnimationFrame(this.rAF);
77
+ }
118
78
 
119
- return this.getMouseIndex();
120
- }
121
- }, {
122
- key: "setKeyboardIndex",
123
- value: function setKeyboardIndex(index) {
124
- var options = this.props.options;
125
-
126
- if (options.separateKeyboardMouse) {
127
- this.setState({
128
- keyboardIndex: index
129
- });
130
- } else {
131
- this.setMouseIndex(index);
132
- }
133
- }
134
- }, {
135
- key: "getMouseIndex",
136
- value: function getMouseIndex() {
137
- var mouseIndex = this.state.mouseIndex;
138
- return mouseIndex;
79
+ getKeyboardIndex() {
80
+ var {
81
+ options
82
+ } = this.props;
83
+
84
+ if (options.separateKeyboardMouse) {
85
+ var {
86
+ keyboardIndex
87
+ } = this.state;
88
+ return keyboardIndex;
139
89
  }
140
- }, {
141
- key: "setMouseIndex",
142
- value: function setMouseIndex(index) {
90
+
91
+ return this.getMouseIndex();
92
+ }
93
+
94
+ setKeyboardIndex(index) {
95
+ var {
96
+ options
97
+ } = this.props;
98
+
99
+ if (options.separateKeyboardMouse) {
143
100
  this.setState({
144
- mouseIndex: index
101
+ keyboardIndex: index
145
102
  });
103
+ } else {
104
+ this.setMouseIndex(index);
146
105
  }
147
- }, {
148
- key: "initMenu",
149
- value: function initMenu() {
150
- // cancel any pending close
151
- cancelAnimationFrame(this.rAF);
152
- this.setState({
153
- menuItems: []
154
- });
155
- var actions = this.props.actions;
156
- var menuItems = ContextActionUtils.getMenuItems(actions, false);
157
-
158
- if (menuItems.length > 0) {
159
- this.setState(function (state) {
160
- return {
161
- menuItems: ContextActionUtils.sortActions(state.menuItems.concat(menuItems))
162
- };
163
- });
164
- }
106
+ }
107
+
108
+ getMouseIndex() {
109
+ var {
110
+ mouseIndex
111
+ } = this.state;
112
+ return mouseIndex;
113
+ }
114
+
115
+ setMouseIndex(index) {
116
+ this.setState({
117
+ mouseIndex: index
118
+ });
119
+ }
120
+
121
+ initMenu() {
122
+ // cancel any pending close
123
+ cancelAnimationFrame(this.rAF);
124
+ this.setState({
125
+ menuItems: []
126
+ });
127
+ var {
128
+ actions
129
+ } = this.props;
130
+ var menuItems = ContextActionUtils.getMenuItems(actions, false);
131
+
132
+ if (menuItems.length > 0) {
133
+ this.setState(state => ({
134
+ menuItems: ContextActionUtils.sortActions(state.menuItems.concat(menuItems))
135
+ }));
165
136
  }
166
- }, {
167
- key: "handleKeyDown",
168
- value: function handleKeyDown(e) {
169
- var menuItems = this.state.menuItems;
170
- var oldFocus = this.getKeyboardIndex();
171
- var newFocus = oldFocus;
172
-
173
- if (e.key === 'Enter' || e.key === ' ') {
174
- if (oldFocus != null && oldFocus >= 0 && oldFocus < menuItems.length) {
175
- this.handleMenuItemClick(menuItems[oldFocus], e);
176
- }
137
+ }
177
138
 
178
- return;
139
+ handleKeyDown(e) {
140
+ var {
141
+ menuItems
142
+ } = this.state;
143
+ var oldFocus = this.getKeyboardIndex();
144
+ var newFocus = oldFocus;
145
+
146
+ if (e.key === 'Enter' || e.key === ' ') {
147
+ if (oldFocus != null && oldFocus >= 0 && oldFocus < menuItems.length) {
148
+ this.handleMenuItemClick(menuItems[oldFocus], e);
179
149
  }
180
150
 
181
- if (e.key === 'Escape') {
182
- newFocus = null;
183
- } else if (e.key === 'ArrowUp' || e.key === 'Tab' && e.shiftKey === true) {
184
- var _newFocus;
151
+ return;
152
+ }
185
153
 
186
- newFocus = ContextActionUtils.getNextMenuItem((_newFocus = newFocus) !== null && _newFocus !== void 0 ? _newFocus : 0, -1, menuItems);
187
- } else if (e.key === 'ArrowDown' || e.key === 'Tab' && e.shiftKey === false) {
188
- var _newFocus2;
154
+ if (e.key === 'Escape') {
155
+ newFocus = null;
156
+ } else if (e.key === 'ArrowUp' || e.key === 'Tab' && e.shiftKey === true) {
157
+ var _newFocus;
189
158
 
190
- newFocus = ContextActionUtils.getNextMenuItem((_newFocus2 = newFocus) !== null && _newFocus2 !== void 0 ? _newFocus2 : 0, 1, menuItems);
191
- }
159
+ newFocus = ContextActionUtils.getNextMenuItem((_newFocus = newFocus) !== null && _newFocus !== void 0 ? _newFocus : 0, -1, menuItems);
160
+ } else if (e.key === 'ArrowDown' || e.key === 'Tab' && e.shiftKey === false) {
161
+ var _newFocus2;
192
162
 
193
- if (oldFocus !== newFocus) {
194
- if (newFocus !== null) {
195
- this.setKeyboardIndex(newFocus);
196
- } else {
197
- this.closeMenu();
163
+ newFocus = ContextActionUtils.getNextMenuItem((_newFocus2 = newFocus) !== null && _newFocus2 !== void 0 ? _newFocus2 : 0, 1, menuItems);
164
+ }
198
165
 
199
- if (this.oldFocus instanceof HTMLElement) {
200
- this.oldFocus.focus();
201
- }
202
- }
166
+ if (oldFocus !== newFocus) {
167
+ if (newFocus !== null) {
168
+ this.setKeyboardIndex(newFocus);
169
+ } else {
170
+ this.closeMenu();
203
171
 
204
- e.preventDefault();
205
- e.stopPropagation();
172
+ if (this.oldFocus instanceof HTMLElement) {
173
+ this.oldFocus.focus();
174
+ }
206
175
  }
207
- }
208
- }, {
209
- key: "closeMenu",
210
- value: function closeMenu() {
211
- var _this3 = this;
212
-
213
- var closeAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
214
- var _this$props = this.props,
215
- closeMenu = _this$props.closeMenu,
216
- onMenuClosed = _this$props.onMenuClosed;
217
- cancelAnimationFrame(this.rAF);
218
- this.rAF = window.requestAnimationFrame(function () {
219
- closeMenu(closeAll);
220
- onMenuClosed(_this3);
221
- });
222
- }
223
- }, {
224
- key: "handleCloseMenu",
225
- value: function handleCloseMenu() {
226
- this.closeMenu();
227
- }
228
- }, {
229
- key: "handleMenuItemClick",
230
- value: function handleMenuItemClick(menuItem, e) {
176
+
231
177
  e.preventDefault();
232
178
  e.stopPropagation();
233
-
234
- if (menuItem != null && !menuItem.disabled && menuItem.action != null) {
235
- menuItem.action();
236
- this.closeMenu(true);
237
- }
238
- }
239
- }, {
240
- key: "handleMenuItemMouseMove",
241
- value: function handleMenuItemMouseMove(menuItem) {
242
- var menuItems = this.state.menuItems;
243
- var focusIndex = menuItems.indexOf(menuItem);
244
- this.setMouseIndex(focusIndex);
245
179
  }
246
- }, {
247
- key: "handleMouseLeave",
248
- value: function handleMouseLeave() {
249
- this.setMouseIndex(-1);
180
+ }
181
+
182
+ closeMenu() {
183
+ var closeAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
184
+ var {
185
+ closeMenu,
186
+ onMenuClosed
187
+ } = this.props;
188
+ cancelAnimationFrame(this.rAF);
189
+ this.rAF = window.requestAnimationFrame(() => {
190
+ closeMenu(closeAll);
191
+ onMenuClosed(this);
192
+ });
193
+ }
194
+
195
+ handleCloseMenu() {
196
+ this.closeMenu();
197
+ }
198
+
199
+ handleMenuItemClick(menuItem, e) {
200
+ e.preventDefault();
201
+ e.stopPropagation();
202
+
203
+ if (menuItem != null && !menuItem.disabled && menuItem.action != null) {
204
+ menuItem.action();
205
+ this.closeMenu(true);
250
206
  }
251
- }, {
252
- key: "render",
253
- value: function render() {
254
- var menuItemElements = [];
255
- var _this$state = this.state,
256
- keyboardIndex = _this$state.keyboardIndex,
257
- menuItems = _this$state.menuItems,
258
- mouseIndex = _this$state.mouseIndex;
259
-
260
- for (var i = 0; i < menuItems.length; i += 1) {
261
- var menuItem = menuItems[i];
262
-
263
- if (i > 0 && menuItem.group !== menuItems[i - 1].group) {
264
- menuItemElements.push( /*#__PURE__*/React.createElement("hr", {
265
- key: "".concat(i, ".separator")
266
- }));
267
- }
207
+ }
268
208
 
269
- var menuItemElement = /*#__PURE__*/React.createElement(ContextMenuItem, {
270
- key: i,
271
- isKeyboardSelected: keyboardIndex === i,
272
- isMouseSelected: mouseIndex === i,
273
- menuItem: menuItem,
274
- closeMenu: this.handleCloseMenu,
275
- onMenuItemClick: this.handleMenuItemClick,
276
- onMenuItemMouseMove: this.handleMenuItemMouseMove,
277
- onMenuItemContextMenu: function onMenuItemContextMenu() {
278
- return false;
279
- }
280
- });
281
- menuItemElements.push(menuItemElement);
209
+ handleMenuItemMouseMove(menuItem) {
210
+ var {
211
+ menuItems
212
+ } = this.state;
213
+ var focusIndex = menuItems.indexOf(menuItem);
214
+ this.setMouseIndex(focusIndex);
215
+ }
216
+
217
+ handleMouseLeave() {
218
+ this.setMouseIndex(-1);
219
+ }
220
+
221
+ render() {
222
+ var menuItemElements = [];
223
+ var {
224
+ keyboardIndex,
225
+ menuItems,
226
+ mouseIndex
227
+ } = this.state;
228
+
229
+ for (var i = 0; i < menuItems.length; i += 1) {
230
+ var menuItem = menuItems[i];
231
+
232
+ if (i > 0 && menuItem.group !== menuItems[i - 1].group) {
233
+ menuItemElements.push( /*#__PURE__*/React.createElement("hr", {
234
+ key: "".concat(i, ".separator")
235
+ }));
282
236
  }
283
237
 
284
- var menuStyle = this.props.menuStyle;
285
- return /*#__PURE__*/React.createElement("div", {
286
- className: "context-menu-container",
287
- style: _objectSpread({}, menuStyle),
288
- ref: this.container,
289
- onKeyDown: this.handleKeyDown,
290
- onMouseLeave: this.handleMouseLeave,
291
- role: "menuitem",
292
- tabIndex: 0
293
- }, menuItemElements);
238
+ var menuItemElement = /*#__PURE__*/React.createElement(ContextMenuItem, {
239
+ key: i,
240
+ isKeyboardSelected: keyboardIndex === i,
241
+ isMouseSelected: mouseIndex === i,
242
+ menuItem: menuItem,
243
+ closeMenu: this.handleCloseMenu,
244
+ onMenuItemClick: this.handleMenuItemClick,
245
+ onMenuItemMouseMove: this.handleMenuItemMouseMove,
246
+ onMenuItemContextMenu: () => false
247
+ });
248
+ menuItemElements.push(menuItemElement);
294
249
  }
295
- }]);
296
250
 
297
- return Menu;
298
- }(PureComponent);
251
+ var {
252
+ menuStyle
253
+ } = this.props;
254
+ return /*#__PURE__*/React.createElement("div", {
255
+ className: "context-menu-container",
256
+ style: _objectSpread({}, menuStyle),
257
+ ref: this.container,
258
+ onKeyDown: this.handleKeyDown,
259
+ onMouseLeave: this.handleMouseLeave,
260
+ role: "menuitem",
261
+ tabIndex: 0
262
+ }, menuItemElements);
263
+ }
264
+
265
+ }
299
266
 
300
267
  _defineProperty(Menu, "defaultProps", {
301
- closeMenu: function closeMenu() {// no-op
268
+ closeMenu() {// no-op
302
269
  },
303
- onMenuOpened: function onMenuOpened() {// no-op
270
+
271
+ onMenuOpened() {// no-op
304
272
  },
305
- onMenuClosed: function onMenuClosed() {// no-op
273
+
274
+ onMenuClosed() {// no-op
306
275
  },
276
+
307
277
  options: {},
308
278
  menuStyle: {}
309
279
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu-actions/Menu.tsx"],"names":["React","PureComponent","ContextActionUtils","ContextMenuItem","Menu","props","handleKeyDown","bind","handleMenuItemClick","handleMenuItemMouseMove","handleMouseLeave","handleCloseMenu","container","createRef","oldFocus","document","activeElement","rAF","options","keyboardIndex","initialKeyboardIndex","state","menuItems","mouseIndex","initMenu","window","requestAnimationFrame","current","focus","onMenuOpened","prevProps","actions","cancelAnimationFrame","separateKeyboardMouse","getMouseIndex","index","setState","setMouseIndex","getMenuItems","length","sortActions","concat","e","getKeyboardIndex","newFocus","key","shiftKey","getNextMenuItem","setKeyboardIndex","closeMenu","HTMLElement","preventDefault","stopPropagation","closeAll","onMenuClosed","menuItem","disabled","action","focusIndex","indexOf","menuItemElements","i","group","push","menuItemElement","menuStyle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;AACA,OAAOC,kBAAP,MAEO,uCAFP;AAGA,OAAOC,eAAP,MAA4B,oCAA5B;;AAuBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAEMC,I;;;;;AAeJ,gBAAYC,KAAZ,EAA8B;AAAA;;AAAA;;AAAA;;AAC5B,8BAAMA,KAAN;;AAD4B;;AAAA;;AAAA;;AAG5B,UAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,IAAnB,+BAArB;AACA,UAAKC,mBAAL,GAA2B,MAAKA,mBAAL,CAAyBD,IAAzB,+BAA3B;AACA,UAAKE,uBAAL,GAA+B,MAAKA,uBAAL,CAA6BF,IAA7B,+BAA/B;AACA,UAAKG,gBAAL,GAAwB,MAAKA,gBAAL,CAAsBH,IAAtB,+BAAxB;AACA,UAAKI,eAAL,GAAuB,MAAKA,eAAL,CAAqBJ,IAArB,+BAAvB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 'react';\nimport ContextActionUtils, {\n ContextAction,\n} from '../context-actions/ContextActionUtils';\nimport ContextMenuItem from '../context-actions/ContextMenuItem';\n\nexport type MenuOptions = {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n};\n\ntype MenuProps = {\n actions: ContextAction | ContextAction[];\n closeMenu(closeAll: boolean): void;\n onMenuClosed(menu: Menu): void;\n onMenuOpened(menu: Menu): void;\n options: MenuOptions;\n menuStyle: React.CSSProperties;\n};\n\ntype MenuState = {\n menuItems: ContextAction[];\n keyboardIndex: number;\n mouseIndex: number;\n};\n\n/**\n * Do not use this class directly. Use DropdownMenu instead.\n *\n * Generates list from actions for use by DropdownMenu.\n * It has beem split from the context-actions component, due to divergering requirements,\n * but still re-uses styling from context-menu. Depending on how usage evolves, may get split further.\n *\n */\n\nclass Menu extends PureComponent<MenuProps, MenuState> {\n static defaultProps = {\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 };\n\n constructor(props: MenuProps) {\n super(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleCloseMenu = this.handleCloseMenu.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.rAF = 0;\n\n const { options } = props;\n const keyboardIndex = options.initialKeyboardIndex ?? -1;\n\n this.state = {\n menuItems: [],\n keyboardIndex,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.rAF = window.requestAnimationFrame(() => {\n // set initial focus to container so keyboard navigation works\n // components can still override focus in onMenuOpened callback\n this.container.current?.focus();\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(prevProps: MenuProps): void {\n const { actions } = this.props;\n if (prevProps.actions !== actions) {\n this.initMenu();\n }\n }\n\n componentWillUnmount(): void {\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n rAF: number;\n\n getKeyboardIndex(): number | null {\n const { options } = this.props;\n if (options.separateKeyboardMouse) {\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 (options.separateKeyboardMouse) {\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\n cancelAnimationFrame(this.rAF);\n\n this.setState({\n menuItems: [],\n });\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions, false);\n\n if (menuItems.length > 0) {\n this.setState(state => ({\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(menuItems)\n ),\n }));\n }\n }\n\n handleKeyDown(e: React.KeyboardEvent): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus = oldFocus;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus != null && oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(menuItems[oldFocus], e);\n }\n return;\n }\n\n if (e.key === 'Escape') {\n newFocus = null;\n } else if (\n e.key === 'ArrowUp' ||\n (e.key === 'Tab' && e.shiftKey === true)\n ) {\n newFocus = ContextActionUtils.getNextMenuItem(\n newFocus ?? 0,\n -1,\n menuItems\n );\n } else if (\n e.key === 'ArrowDown' ||\n (e.key === 'Tab' && e.shiftKey === false)\n ) {\n newFocus = ContextActionUtils.getNextMenuItem(\n newFocus ?? 0,\n 1,\n menuItems\n );\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 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 handleCloseMenu(): void {\n this.closeMenu();\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.SyntheticEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n if (menuItem != null && !menuItem.disabled && menuItem.action != null) {\n menuItem.action();\n this.closeMenu(true);\n }\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { keyboardIndex, menuItems, mouseIndex } = 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 isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={() => false}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n const { menuStyle } = this.props;\n\n return (\n <div\n className=\"context-menu-container\"\n style={{ ...menuStyle }}\n ref={this.container}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n role=\"menuitem\"\n tabIndex={0}\n >\n {menuItemElements}\n </div>\n );\n }\n}\n\nexport default Menu;\n"],"file":"Menu.js"}
1
+ {"version":3,"sources":["../../src/menu-actions/Menu.tsx"],"names":["React","PureComponent","ContextActionUtils","ContextMenuItem","Menu","constructor","props","handleKeyDown","bind","handleMenuItemClick","handleMenuItemMouseMove","handleMouseLeave","handleCloseMenu","container","createRef","oldFocus","document","activeElement","rAF","options","keyboardIndex","initialKeyboardIndex","state","menuItems","mouseIndex","componentDidMount","initMenu","window","requestAnimationFrame","current","focus","onMenuOpened","componentDidUpdate","prevProps","actions","componentWillUnmount","cancelAnimationFrame","getKeyboardIndex","separateKeyboardMouse","getMouseIndex","setKeyboardIndex","index","setState","setMouseIndex","getMenuItems","length","sortActions","concat","e","newFocus","key","shiftKey","getNextMenuItem","closeMenu","HTMLElement","preventDefault","stopPropagation","closeAll","onMenuClosed","menuItem","disabled","action","focusIndex","indexOf","render","menuItemElements","i","group","push","menuItemElement","menuStyle"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,aAAhB,QAAqC,OAArC;OACOC,kB;OAGAC,e;;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAMC,IAAN,SAAmBH,aAAnB,CAAuD;AAerDI,EAAAA,WAAW,CAACC,KAAD,EAAmB;AAAA;;AAC5B,UAAMA,KAAN;;AAD4B;;AAAA;;AAAA;;AAG5B,SAAKC,aAAL,GAAqB,KAAKA,aAAL,CAAmBC,IAAnB,CAAwB,IAAxB,CAArB;AACA,SAAKC,mBAAL,GAA2B,KAAKA,mBAAL,CAAyBD,IAAzB,CAA8B,IAA9B,CAA3B;AACA,SAAKE,uBAAL,GAA+B,KAAKA,uBAAL,CAA6BF,IAA7B,CAAkC,IAAlC,CAA/B;AACA,SAAKG,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBH,IAAtB,CAA2B,IAA3B,CAAxB;AACA,SAAKI,eAAL,GAAuB,KAAKA,eAAL,CAAqBJ,IAArB,CAA0B,IAA1B,CAAvB;AAEA,SAAKK,SAAL,gBAAiBb,KAAK,CAACc,SAA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\nimport ContextActionUtils, {\n ContextAction,\n} from '../context-actions/ContextActionUtils';\nimport ContextMenuItem from '../context-actions/ContextMenuItem';\n\nexport type MenuOptions = {\n doNotVerifyPosition?: boolean;\n separateKeyboardMouse?: boolean;\n initialKeyboardIndex?: number;\n};\n\ntype MenuProps = {\n actions: ContextAction | ContextAction[];\n closeMenu(closeAll: boolean): void;\n onMenuClosed(menu: Menu): void;\n onMenuOpened(menu: Menu): void;\n options: MenuOptions;\n menuStyle: React.CSSProperties;\n};\n\ntype MenuState = {\n menuItems: ContextAction[];\n keyboardIndex: number;\n mouseIndex: number;\n};\n\n/**\n * Do not use this class directly. Use DropdownMenu instead.\n *\n * Generates list from actions for use by DropdownMenu.\n * It has beem split from the context-actions component, due to divergering requirements,\n * but still re-uses styling from context-menu. Depending on how usage evolves, may get split further.\n *\n */\n\nclass Menu extends PureComponent<MenuProps, MenuState> {\n static defaultProps = {\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 };\n\n constructor(props: MenuProps) {\n super(props);\n\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleMenuItemClick = this.handleMenuItemClick.bind(this);\n this.handleMenuItemMouseMove = this.handleMenuItemMouseMove.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleCloseMenu = this.handleCloseMenu.bind(this);\n\n this.container = React.createRef();\n this.oldFocus = document.activeElement;\n this.rAF = 0;\n\n const { options } = props;\n const keyboardIndex = options.initialKeyboardIndex ?? -1;\n\n this.state = {\n menuItems: [],\n keyboardIndex,\n mouseIndex: -1,\n };\n }\n\n componentDidMount(): void {\n this.initMenu();\n\n this.rAF = window.requestAnimationFrame(() => {\n // set initial focus to container so keyboard navigation works\n // components can still override focus in onMenuOpened callback\n this.container.current?.focus();\n const { onMenuOpened } = this.props;\n onMenuOpened(this);\n });\n }\n\n componentDidUpdate(prevProps: MenuProps): void {\n const { actions } = this.props;\n if (prevProps.actions !== actions) {\n this.initMenu();\n }\n }\n\n componentWillUnmount(): void {\n cancelAnimationFrame(this.rAF);\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n oldFocus: Element | null;\n\n rAF: number;\n\n getKeyboardIndex(): number | null {\n const { options } = this.props;\n if (options.separateKeyboardMouse) {\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 (options.separateKeyboardMouse) {\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\n cancelAnimationFrame(this.rAF);\n\n this.setState({\n menuItems: [],\n });\n\n const { actions } = this.props;\n const menuItems = ContextActionUtils.getMenuItems(actions, false);\n\n if (menuItems.length > 0) {\n this.setState(state => ({\n menuItems: ContextActionUtils.sortActions(\n state.menuItems.concat(menuItems)\n ),\n }));\n }\n }\n\n handleKeyDown(e: React.KeyboardEvent): void {\n const { menuItems } = this.state;\n const oldFocus = this.getKeyboardIndex();\n let newFocus = oldFocus;\n\n if (e.key === 'Enter' || e.key === ' ') {\n if (oldFocus != null && oldFocus >= 0 && oldFocus < menuItems.length) {\n this.handleMenuItemClick(menuItems[oldFocus], e);\n }\n return;\n }\n\n if (e.key === 'Escape') {\n newFocus = null;\n } else if (\n e.key === 'ArrowUp' ||\n (e.key === 'Tab' && e.shiftKey === true)\n ) {\n newFocus = ContextActionUtils.getNextMenuItem(\n newFocus ?? 0,\n -1,\n menuItems\n );\n } else if (\n e.key === 'ArrowDown' ||\n (e.key === 'Tab' && e.shiftKey === false)\n ) {\n newFocus = ContextActionUtils.getNextMenuItem(\n newFocus ?? 0,\n 1,\n menuItems\n );\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 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 handleCloseMenu(): void {\n this.closeMenu();\n }\n\n handleMenuItemClick(menuItem: ContextAction, e: React.SyntheticEvent): void {\n e.preventDefault();\n e.stopPropagation();\n\n if (menuItem != null && !menuItem.disabled && menuItem.action != null) {\n menuItem.action();\n this.closeMenu(true);\n }\n }\n\n handleMenuItemMouseMove(menuItem: ContextAction): void {\n const { menuItems } = this.state;\n const focusIndex = menuItems.indexOf(menuItem);\n this.setMouseIndex(focusIndex);\n }\n\n handleMouseLeave(): void {\n this.setMouseIndex(-1);\n }\n\n render(): JSX.Element {\n const menuItemElements = [];\n const { keyboardIndex, menuItems, mouseIndex } = 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 isKeyboardSelected={keyboardIndex === i}\n isMouseSelected={mouseIndex === i}\n menuItem={menuItem}\n closeMenu={this.handleCloseMenu}\n onMenuItemClick={this.handleMenuItemClick}\n onMenuItemMouseMove={this.handleMenuItemMouseMove}\n onMenuItemContextMenu={() => false}\n />\n );\n\n menuItemElements.push(menuItemElement);\n }\n\n const { menuStyle } = this.props;\n\n return (\n <div\n className=\"context-menu-container\"\n style={{ ...menuStyle }}\n ref={this.container}\n onKeyDown={this.handleKeyDown}\n onMouseLeave={this.handleMouseLeave}\n role=\"menuitem\"\n tabIndex={0}\n >\n {menuItemElements}\n </div>\n );\n }\n}\n\nexport default Menu;\n"],"file":"Menu.js"}
@@ -1,3 +1,3 @@
1
1
  // Note this exports as the default for this module
2
- export { default } from './DropdownMenu';
2
+ export { default } from "./DropdownMenu.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/menu-actions/index.ts"],"names":["default"],"mappings":"AAAA;AACA,SAASA,OAAT,QAAwB,gBAAxB","sourcesContent":["// Note this exports as the default for this module\nexport { default } from './DropdownMenu';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/menu-actions/index.ts"],"names":["default"],"mappings":"AAAA;SACSA,O","sourcesContent":["// Note this exports as the default for this module\nexport { default } from './DropdownMenu';\n"],"file":"index.js"}
@@ -1,27 +1,23 @@
1
1
  import React from 'react';
2
- import MenuItem from './MenuItem';
2
+ import MenuItem from "./MenuItem.js";
3
3
  import "./Menu.css";
4
- export var Menu = function Menu(_ref) {
5
- var items = _ref.items,
6
- _ref$onSelect = _ref.onSelect,
7
- _onSelect = _ref$onSelect === void 0 ? function () {
8
- return undefined;
9
- } : _ref$onSelect;
10
-
4
+ export var Menu = (_ref) => {
5
+ var {
6
+ items,
7
+ onSelect: _onSelect = () => undefined
8
+ } = _ref;
11
9
  return /*#__PURE__*/React.createElement("div", {
12
10
  className: "navigation-menu-view"
13
11
  }, /*#__PURE__*/React.createElement("ul", {
14
12
  className: "navigation-menu-list"
15
- }, items.map(function (item, itemIndex) {
16
- return /*#__PURE__*/React.createElement("li", {
17
- key: item.title
18
- }, /*#__PURE__*/React.createElement(MenuItem, {
19
- item: item,
20
- onSelect: function onSelect() {
21
- _onSelect(itemIndex);
22
- }
23
- }));
24
- })));
13
+ }, items.map((item, itemIndex) => /*#__PURE__*/React.createElement("li", {
14
+ key: item.title
15
+ }, /*#__PURE__*/React.createElement(MenuItem, {
16
+ item: item,
17
+ onSelect: () => {
18
+ _onSelect(itemIndex);
19
+ }
20
+ })))));
25
21
  };
26
22
  export default Menu;
27
23
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/navigation/Menu.tsx"],"names":["React","MenuItem","Menu","items","onSelect","undefined","map","item","itemIndex","title"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,QAAP,MAAsC,YAAtC;AACA;AASA,OAAO,IAAMC,IAAI,GAAG,SAAPA,IAAO;AAAA,MAClBC,KADkB,QAClBA,KADkB;AAAA,2BAElBC,QAFkB;AAAA,MAElBA,SAFkB,8BAEP;AAAA,WAAMC,SAAN;AAAA,GAFO;;AAAA,sBAIlB;AAAK,IAAA,SAAS,EAAC;AAAf,kBACE;AAAI,IAAA,SAAS,EAAC;AAAd,KACGF,KAAK,CAACG,GAAN,CAAU,UAACC,IAAD,EAAOC,SAAP;AAAA,wBACT;AAAI,MAAA,GAAG,EAAED,IAAI,CAACE;AAAd,oBACE,oBAAC,QAAD;AACE,MAAA,IAAI,EAAEF,IADR;AAEE,MAAA,QAAQ,EAAE,oBAAM;AACdH,QAAAA,SAAQ,CAACI,SAAD,CAAR;AACD;AAJH,MADF,CADS;AAAA,GAAV,CADH,CADF,CAJkB;AAAA,CAAb;AAoBP,eAAeN,IAAf","sourcesContent":["import React from 'react';\nimport MenuItem, { MenuItemDef } from './MenuItem';\nimport './Menu.scss';\n\nexport type MenuSelectCallback = (itemIndex: number) => void;\n\nexport type MenuProps = {\n items: MenuItemDef[];\n onSelect?: MenuSelectCallback;\n};\n\nexport const Menu = ({\n items,\n onSelect = () => undefined,\n}: MenuProps): JSX.Element => (\n <div className=\"navigation-menu-view\">\n <ul className=\"navigation-menu-list\">\n {items.map((item, itemIndex) => (\n <li key={item.title}>\n <MenuItem\n item={item}\n onSelect={() => {\n onSelect(itemIndex);\n }}\n />\n </li>\n ))}\n </ul>\n </div>\n);\n\nexport default Menu;\n"],"file":"Menu.js"}
1
+ {"version":3,"sources":["../../src/navigation/Menu.tsx"],"names":["React","MenuItem","Menu","items","onSelect","undefined","map","item","itemIndex","title"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;OACOC,Q;;AAUP,OAAO,IAAMC,IAAI,GAAG;AAAA,MAAC;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,QAAQ,EAARA,SAAQ,GAAG,MAAMC;AAFE,GAAD;AAAA,sBAIlB;AAAK,IAAA,SAAS,EAAC;AAAf,kBACE;AAAI,IAAA,SAAS,EAAC;AAAd,KACGF,KAAK,CAACG,GAAN,CAAU,CAACC,IAAD,EAAOC,SAAP,kBACT;AAAI,IAAA,GAAG,EAAED,IAAI,CAACE;AAAd,kBACE,oBAAC,QAAD;AACE,IAAA,IAAI,EAAEF,IADR;AAEE,IAAA,QAAQ,EAAE,MAAM;AACdH,MAAAA,SAAQ,CAACI,SAAD,CAAR;AACD;AAJH,IADF,CADD,CADH,CADF,CAJkB;AAAA,CAAb;AAoBP,eAAeN,IAAf","sourcesContent":["import React from 'react';\nimport MenuItem, { MenuItemDef } from './MenuItem';\nimport './Menu.scss';\n\nexport type MenuSelectCallback = (itemIndex: number) => void;\n\nexport type MenuProps = {\n items: MenuItemDef[];\n onSelect?: MenuSelectCallback;\n};\n\nexport const Menu = ({\n items,\n onSelect = () => undefined,\n}: MenuProps): JSX.Element => (\n <div className=\"navigation-menu-view\">\n <ul className=\"navigation-menu-list\">\n {items.map((item, itemIndex) => (\n <li key={item.title}>\n <MenuItem\n item={item}\n onSelect={() => {\n onSelect(itemIndex);\n }}\n />\n </li>\n ))}\n </ul>\n </div>\n);\n\nexport default Menu;\n"],"file":"Menu.js"}