@instructure/ui-menu 8.13.1-snapshot.9 → 8.14.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 (47) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/es/Menu/MenuItem/index.js +28 -21
  3. package/es/Menu/MenuItem/props.js +0 -23
  4. package/es/Menu/MenuItemGroup/index.js +17 -13
  5. package/es/Menu/MenuItemGroup/props.js +1 -30
  6. package/es/Menu/MenuItemSeparator/index.js +6 -2
  7. package/es/Menu/index.js +59 -56
  8. package/es/Menu/props.js +1 -113
  9. package/es/MenuContext.js +3 -3
  10. package/lib/Menu/MenuItem/index.js +28 -21
  11. package/lib/Menu/MenuItem/props.js +0 -23
  12. package/lib/Menu/MenuItemGroup/index.js +17 -13
  13. package/lib/Menu/MenuItemGroup/props.js +1 -30
  14. package/lib/Menu/MenuItemSeparator/index.js +6 -2
  15. package/lib/Menu/index.js +61 -56
  16. package/lib/Menu/props.js +1 -113
  17. package/lib/MenuContext.js +2 -2
  18. package/package.json +21 -22
  19. package/src/Menu/MenuItem/index.tsx +24 -34
  20. package/src/Menu/MenuItem/props.ts +36 -27
  21. package/src/Menu/MenuItemGroup/index.tsx +28 -48
  22. package/src/Menu/MenuItemGroup/props.ts +37 -30
  23. package/src/Menu/MenuItemSeparator/index.tsx +2 -4
  24. package/src/Menu/index.tsx +81 -135
  25. package/src/Menu/props.ts +79 -84
  26. package/src/MenuContext.ts +3 -2
  27. package/tsconfig.build.json +25 -2
  28. package/tsconfig.build.tsbuildinfo +1 -0
  29. package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
  30. package/types/Menu/MenuItem/index.d.ts +24 -23
  31. package/types/Menu/MenuItem/index.d.ts.map +1 -1
  32. package/types/Menu/MenuItem/props.d.ts +30 -7
  33. package/types/Menu/MenuItem/props.d.ts.map +1 -1
  34. package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
  35. package/types/Menu/MenuItemGroup/index.d.ts +22 -22
  36. package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
  37. package/types/Menu/MenuItemGroup/props.d.ts +33 -8
  38. package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
  39. package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
  40. package/types/Menu/MenuLocator.d.ts +576 -576
  41. package/types/Menu/index.d.ts +58 -68
  42. package/types/Menu/index.d.ts.map +1 -1
  43. package/types/Menu/props.d.ts +94 -16
  44. package/types/Menu/props.d.ts.map +1 -1
  45. package/types/MenuContext.d.ts +3 -2
  46. package/types/MenuContext.d.ts.map +1 -1
  47. package/LICENSE.md +0 -27
package/lib/Menu/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
3
5
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
6
 
5
7
  Object.defineProperty(exports, "__esModule", {
@@ -26,7 +28,7 @@ Object.defineProperty(exports, "MenuItemSeparator", {
26
28
  });
27
29
  exports.default = void 0;
28
30
 
29
- var _react = require("react");
31
+ var _react = _interopRequireWildcard(require("react"));
30
32
 
31
33
  var _keycode = _interopRequireDefault(require("keycode"));
32
34
 
@@ -66,6 +68,7 @@ var _dec, _dec2, _class, _class2, _temp;
66
68
  ---
67
69
  category: components
68
70
  ---
71
+ @tsProps
69
72
  **/
70
73
  let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class Menu extends _react.Component {
71
74
  constructor(props) {
@@ -79,7 +82,8 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
79
82
  this._trigger = null;
80
83
  this._menu = null;
81
84
  this._labelId = (0, _uid.uid)('Menu__label');
82
- this._activeSubMenu = null;
85
+ this._activeSubMenu = void 0;
86
+ this._id = void 0;
83
87
  this.ref = null;
84
88
 
85
89
  this.handleRef = el => {
@@ -111,13 +115,13 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
111
115
  this.handleTriggerKeyDown = event => {
112
116
  if (this.props.type === 'flyout' && event.keyCode === _keycode.default.codes.right) {
113
117
  event.persist();
114
- this.show();
118
+ this.show(event);
115
119
  }
116
120
  };
117
121
 
118
- this.handleTriggerMouseOver = () => {
122
+ this.handleTriggerMouseOver = event => {
119
123
  if (this.props.type === 'flyout') {
120
- this.show();
124
+ this.show(event);
121
125
  }
122
126
  };
123
127
 
@@ -132,10 +136,10 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
132
136
  const _keycode$codes = _keycode.default.codes,
133
137
  down = _keycode$codes.down,
134
138
  up = _keycode$codes.up,
135
- pgup = _keycode$codes.pgup,
136
- pgdn = _keycode$codes.pgdn,
137
139
  tab = _keycode$codes.tab,
138
140
  left = _keycode$codes.left;
141
+ const pgdn = _keycode.default.codes['page down'];
142
+ const pgup = _keycode.default.codes['page up'];
139
143
 
140
144
  if (key === down || key === pgdn) {
141
145
  event.preventDefault();
@@ -221,11 +225,15 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
221
225
  }
222
226
 
223
227
  componentDidMount() {
224
- this.props.makeStyles();
228
+ var _this$props$makeStyle, _this$props;
229
+
230
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
225
231
  }
226
232
 
227
- componentDidUpdate(prevProps) {
228
- this.props.makeStyles();
233
+ componentDidUpdate() {
234
+ var _this$props$makeStyle2, _this$props2;
235
+
236
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
229
237
  }
230
238
 
231
239
  get menuItems() {
@@ -234,11 +242,15 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
234
242
 
235
243
  focus() {
236
244
  if (this.shown) {
237
- (0, _console.logError)(this._menu && this._menu.focus, '[Menu] Could not focus the menu.');
245
+ var _this$_menu;
246
+
247
+ (0, _console.logError)(!!((_this$_menu = this._menu) !== null && _this$_menu !== void 0 && _this$_menu.focus), '[Menu] Could not focus the menu.');
238
248
 
239
249
  this._menu.focus();
240
250
  } else {
241
- (0, _console.logError)(this._trigger && this._trigger.focus, '[Menu] Could not focus the trigger.');
251
+ var _this$_trigger;
252
+
253
+ (0, _console.logError)(!!((_this$_trigger = this._trigger) !== null && _this$_trigger !== void 0 && _this$_trigger.focus), '[Menu] Could not focus the trigger.');
242
254
 
243
255
  this._trigger.focus();
244
256
  }
@@ -267,7 +279,7 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
267
279
 
268
280
  const current = this.focusedIndex < 0 && step < 0 ? 0 : this.focusedIndex;
269
281
  const nextItem = this.menuItems[(current + count + step) % count];
270
- (0, _console.logError)(nextItem && nextItem.focus, '[Menu] Could not focus next menu item.');
282
+ (0, _console.logError)(typeof nextItem !== 'undefined' && typeof nextItem.focus !== 'undefined', '[Menu] Could not focus next menu item.');
271
283
  nextItem.focus();
272
284
  }
273
285
 
@@ -276,9 +288,9 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
276
288
  }
277
289
 
278
290
  renderChildren() {
279
- const _this$props = this.props,
280
- children = _this$props.children,
281
- disabled = _this$props.disabled;
291
+ const _this$props3 = this.props,
292
+ children = _this$props3.children,
293
+ disabled = _this$props3.disabled;
282
294
  let count = 0;
283
295
  return _react.Children.map(children, child => {
284
296
  if (!(0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItemSeparator', 'MenuItem', 'MenuItemGroup', 'Menu'])) {
@@ -294,8 +306,8 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
294
306
  }, child);
295
307
  }
296
308
 
297
- const controls = child.props['aria-controls'] || child.props.controls || this.props['aria-controls'] || // eslint-disable-line react/prop-types
298
- this.props.controls; // eslint-disable-line react/prop-types
309
+ const menuItemChild = child;
310
+ const controls = menuItemChild.props['aria-controls'] || menuItemChild.props.controls || this.props['aria-controls'] || this.props.controls;
299
311
 
300
312
  if ((0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItem'])) {
301
313
  return (0, _emotion.jsx)("li", {
@@ -350,21 +362,21 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
350
362
  }, child.props.title || child.props.label)
351
363
  }));
352
364
  }
365
+
366
+ return;
353
367
  });
354
368
  }
355
369
 
356
370
  renderMenu() {
357
371
  var _this$props$styles;
358
372
 
359
- const _this$props2 = this.props,
360
- disabled = _this$props2.disabled,
361
- label = _this$props2.label,
362
- trigger = _this$props2.trigger,
363
- onKeyUp = _this$props2.onKeyUp;
364
- const labelledBy = this.props['aria-labelledby']; // eslint-disable-line react/prop-types
365
-
366
- const controls = this.props['aria-controls']; // eslint-disable-line react/prop-types
367
-
373
+ const _this$props4 = this.props,
374
+ disabled = _this$props4.disabled,
375
+ label = _this$props4.label,
376
+ trigger = _this$props4.trigger,
377
+ onKeyUp = _this$props4.onKeyUp;
378
+ const labelledBy = this.props['aria-labelledby'];
379
+ const controls = this.props['aria-controls'];
368
380
  return (0, _emotion.jsx)(_MenuContext.MenuContext.Provider, {
369
381
  value: {
370
382
  removeMenuItem: this.removeMenuItem,
@@ -375,7 +387,7 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
375
387
  "aria-label": label,
376
388
  tabIndex: 0,
377
389
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menu,
378
- "aria-labelledby": labelledBy || trigger && this._labelId,
390
+ "aria-labelledby": labelledBy || (trigger ? this._labelId : void 0),
379
391
  "aria-controls": controls,
380
392
  "aria-disabled": disabled ? 'true' : void 0,
381
393
  onKeyDown: this.handleMenuKeyDown,
@@ -385,26 +397,30 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
385
397
  }
386
398
 
387
399
  render() {
388
- const _this$props3 = this.props,
389
- show = _this$props3.show,
390
- defaultShow = _this$props3.defaultShow,
391
- placement = _this$props3.placement,
392
- withArrow = _this$props3.withArrow,
393
- trigger = _this$props3.trigger,
394
- mountNode = _this$props3.mountNode,
395
- popoverRef = _this$props3.popoverRef,
396
- disabled = _this$props3.disabled,
397
- onDismiss = _this$props3.onDismiss,
398
- onFocus = _this$props3.onFocus,
399
- onMouseOver = _this$props3.onMouseOver,
400
- offsetX = _this$props3.offsetX,
401
- offsetY = _this$props3.offsetY;
400
+ const _this$props5 = this.props,
401
+ show = _this$props5.show,
402
+ defaultShow = _this$props5.defaultShow,
403
+ placement = _this$props5.placement,
404
+ withArrow = _this$props5.withArrow,
405
+ trigger = _this$props5.trigger,
406
+ mountNode = _this$props5.mountNode,
407
+ popoverRef = _this$props5.popoverRef,
408
+ disabled = _this$props5.disabled,
409
+ onDismiss = _this$props5.onDismiss,
410
+ onFocus = _this$props5.onFocus,
411
+ onMouseOver = _this$props5.onMouseOver,
412
+ offsetX = _this$props5.offsetX,
413
+ offsetY = _this$props5.offsetY;
402
414
  return trigger ? (0, _emotion.jsx)(_Popover.Popover, {
403
415
  isShowingContent: show,
404
416
  defaultIsShowingContent: defaultShow,
405
417
  onHideContent: (event, _ref) => {
406
418
  let documentClick = _ref.documentClick;
407
- onDismiss(event, documentClick);
419
+
420
+ if (typeof onDismiss === 'function') {
421
+ onDismiss(event, documentClick);
422
+ }
423
+
408
424
  this.handleToggle(false);
409
425
  },
410
426
  onShowContent: () => this.handleToggle(true),
@@ -428,7 +444,8 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
428
444
  },
429
445
  renderTrigger: (0, _safeCloneElement.safeCloneElement)(trigger, {
430
446
  ref: el => {
431
- this.ref = el;
447
+ this._trigger = el;
448
+ this.ref = (el === null || el === void 0 ? void 0 : el.ref) || el;
432
449
  },
433
450
  'aria-haspopup': true,
434
451
  id: this._labelId,
@@ -440,25 +457,13 @@ let Menu = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
440
457
  }
441
458
 
442
459
  }, _class2.displayName = "Menu", _class2.componentId = 'Menu', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
443
- children: null,
444
460
  label: null,
445
461
  disabled: false,
446
462
  trigger: null,
447
463
  placement: 'bottom center',
448
464
  defaultShow: false,
449
- onToggle: (shown, menu) => {},
450
- onSelect: (event, value, selected, item) => {},
451
- onDismiss: (event, documentClick) => {},
452
- onBlur: event => {},
453
- onFocus: event => {},
454
- onMouseOver: event => {},
455
- onKeyDown: event => {},
456
- onKeyUp: event => {},
457
- menuRef: el => {},
458
- popoverRef: el => {},
459
465
  mountNode: null,
460
466
  constrain: 'window',
461
- liveRegion: null,
462
467
  shouldHideOnSelect: true,
463
468
  shouldFocusTriggerOnClose: true,
464
469
  withArrow: true,
package/lib/Menu/props.js CHANGED
@@ -39,144 +39,32 @@ var _Children = require("@instructure/ui-prop-types/lib/Children.js");
39
39
  * SOFTWARE.
40
40
  */
41
41
  const propTypes = {
42
- /**
43
- * Children of type `Menu.Item`, `Menu.Group`, `Menu.Separator`, or `Menu`
44
- */
45
42
  children: _Children.Children.oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu']),
46
-
47
- /**
48
- * Description of the `<Menu />`
49
- */
50
43
  label: _propTypes.default.string,
51
-
52
- /**
53
- * Is the `<Menu />` disabled
54
- */
55
44
  disabled: _propTypes.default.bool,
56
-
57
- /**
58
- * The trigger element, if the `<Menu />` is to render as a popover
59
- */
60
45
  trigger: _propTypes.default.node,
61
-
62
- /**
63
- * If a trigger is supplied, where should the `<Menu />` be placed (relative to the trigger)
64
- */
65
46
  placement: _PositionPropTypes.PositionPropTypes.placement,
66
-
67
- /**
68
- * Should the `<Menu />` be open for the initial render
69
- */
70
47
  defaultShow: _propTypes.default.bool,
71
-
72
- /**
73
- * Is the `<Menu />` open (should be accompanied by `onToggle`)
74
- */
75
48
  show: (0, _controllable.controllable)(_propTypes.default.bool, 'onToggle', 'defaultShow'),
76
-
77
- /**
78
- * Callback fired when the `<Menu />` is toggled open/closed. When used with `show`,
79
- * the component will not control its own state.
80
- */
81
49
  onToggle: _propTypes.default.func,
82
-
83
- /**
84
- * Callback fired when an item within the `<Menu />` is selected
85
- */
86
50
  onSelect: _propTypes.default.func,
87
-
88
- /**
89
- * If a trigger is supplied, callback fired when the `<Menu />` is closed
90
- */
91
51
  onDismiss: _propTypes.default.func,
92
-
93
- /**
94
- * If a trigger is supplied, callback fired when the `<Menu />` trigger is blurred
95
- */
96
- onBlur: _propTypes.default.func,
97
-
98
- /**
99
- * If a trigger is supplied, callback fired when the `<Menu />` trigger is focused
100
- */
101
52
  onFocus: _propTypes.default.func,
102
-
103
- /**
104
- * If a trigger is supplied, callback fired onMouseOver for the `<Menu />` trigger
105
- */
106
53
  onMouseOver: _propTypes.default.func,
107
-
108
- /**
109
- * Callback fired on the onKeyDown of the `<Menu />`
110
- */
111
54
  onKeyDown: _propTypes.default.func,
112
-
113
- /**
114
- * Callback fired on the onKeyUp of the `<Menu />`
115
- */
116
55
  onKeyUp: _propTypes.default.func,
117
-
118
- /**
119
- * A function that returns a reference to the `<Menu />`
120
- */
121
56
  menuRef: _propTypes.default.func,
122
-
123
- /**
124
- * A function that returns a reference to the `<Popover />`
125
- */
126
57
  popoverRef: _propTypes.default.func,
127
-
128
- /**
129
- * If a trigger is supplied, an element or a function returning an element to use as the mount node
130
- * for the `<Menu />` (defaults to `document.body`)
131
- */
132
58
  mountNode: _PositionPropTypes.PositionPropTypes.mountNode,
133
-
134
- /**
135
- * The parent in which to constrain the menu.
136
- * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
137
- * or a function returning an element
138
- */
139
59
  constrain: _PositionPropTypes.PositionPropTypes.constrain,
140
-
141
- /**
142
- * If a trigger is supplied, an element, function returning an element, or array of elements that will not
143
- * be hidden from the screen reader when the `<Menu />` is open
144
- */
145
- liveRegion: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.element), _propTypes.default.element, _propTypes.default.func]),
146
-
147
- /**
148
- * If a trigger is supplied, should the `<Menu />` hide when an item is selected
149
- */
150
60
  shouldHideOnSelect: _propTypes.default.bool,
151
-
152
- /**
153
- * If a trigger is supplied, should the `<Menu />` focus the trigger on after closing
154
- */
155
61
  shouldFocusTriggerOnClose: _propTypes.default.bool,
156
-
157
- /**
158
- * The type of `<Menu />`
159
- */
160
62
  type: _propTypes.default.oneOf(['flyout']),
161
63
  id: _propTypes.default.string,
162
-
163
- /**
164
- * Whether or not an arrow pointing to the trigger should be rendered
165
- */
166
64
  withArrow: _propTypes.default.bool,
167
-
168
- /**
169
- * The horizontal offset for the positioned content.
170
- * Works only if `trigger` is provided.
171
- */
172
65
  offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
173
-
174
- /**
175
- * The vertical offset for the positioned content.
176
- * Works only if `trigger` is provided.
177
- */
178
66
  offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
179
67
  };
180
68
  exports.propTypes = propTypes;
181
- const allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onBlur', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'liveRegion', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'type', 'id', 'withArrow', 'offsetX', 'offsetY'];
69
+ const allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'type', 'id', 'withArrow', 'offsetX', 'offsetY'];
182
70
  exports.allowedProps = allowedProps;
@@ -38,8 +38,8 @@ private: true
38
38
  @module MenuContext
39
39
  **/
40
40
  const MenuContext = /*#__PURE__*/(0, _react.createContext)({
41
- registerMenuItem: () => {},
42
- removeMenuItem: () => {}
41
+ registerMenuItem: _value => {},
42
+ removeMenuItem: _value => {}
43
43
  });
44
44
  exports.MenuContext = MenuContext;
45
45
  var _default = MenuContext;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-menu",
3
- "version": "8.13.1-snapshot.9+f32ba918e",
3
+ "version": "8.14.0",
4
4
  "description": "A dropdown menu component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -24,28 +24,28 @@
24
24
  },
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@instructure/ui-babel-preset": "8.13.1-snapshot.9+f32ba918e",
28
- "@instructure/ui-color-utils": "8.13.1-snapshot.9+f32ba918e",
29
- "@instructure/ui-test-locator": "8.13.1-snapshot.9+f32ba918e",
30
- "@instructure/ui-test-queries": "8.13.1-snapshot.9+f32ba918e",
31
- "@instructure/ui-test-utils": "8.13.1-snapshot.9+f32ba918e",
32
- "@instructure/ui-themes": "8.13.1-snapshot.9+f32ba918e"
27
+ "@instructure/ui-babel-preset": "8.14.0",
28
+ "@instructure/ui-color-utils": "8.14.0",
29
+ "@instructure/ui-test-locator": "8.14.0",
30
+ "@instructure/ui-test-queries": "8.14.0",
31
+ "@instructure/ui-test-utils": "8.14.0",
32
+ "@instructure/ui-themes": "8.14.0"
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.13.10",
36
- "@instructure/console": "8.13.1-snapshot.9+f32ba918e",
37
- "@instructure/emotion": "8.13.1-snapshot.9+f32ba918e",
38
- "@instructure/shared-types": "8.13.1-snapshot.9+f32ba918e",
39
- "@instructure/ui-a11y-utils": "8.13.1-snapshot.9+f32ba918e",
40
- "@instructure/ui-dom-utils": "8.13.1-snapshot.9+f32ba918e",
41
- "@instructure/ui-icons": "8.13.1-snapshot.9+f32ba918e",
42
- "@instructure/ui-popover": "8.13.1-snapshot.9+f32ba918e",
43
- "@instructure/ui-position": "8.13.1-snapshot.9+f32ba918e",
44
- "@instructure/ui-prop-types": "8.13.1-snapshot.9+f32ba918e",
45
- "@instructure/ui-react-utils": "8.13.1-snapshot.9+f32ba918e",
46
- "@instructure/ui-testable": "8.13.1-snapshot.9+f32ba918e",
47
- "@instructure/ui-utils": "8.13.1-snapshot.9+f32ba918e",
48
- "@instructure/uid": "8.13.1-snapshot.9+f32ba918e",
36
+ "@instructure/console": "8.14.0",
37
+ "@instructure/emotion": "8.14.0",
38
+ "@instructure/shared-types": "8.14.0",
39
+ "@instructure/ui-a11y-utils": "8.14.0",
40
+ "@instructure/ui-dom-utils": "8.14.0",
41
+ "@instructure/ui-icons": "8.14.0",
42
+ "@instructure/ui-popover": "8.14.0",
43
+ "@instructure/ui-position": "8.14.0",
44
+ "@instructure/ui-prop-types": "8.14.0",
45
+ "@instructure/ui-react-utils": "8.14.0",
46
+ "@instructure/ui-testable": "8.14.0",
47
+ "@instructure/ui-utils": "8.14.0",
48
+ "@instructure/uid": "8.14.0",
49
49
  "keycode": "^2",
50
50
  "prop-types": "^15"
51
51
  },
@@ -55,6 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "sideEffects": false,
59
- "gitHead": "f32ba918e4d3ce76c6ee95c856584d00a9d80958"
58
+ "sideEffects": false
60
59
  }
@@ -39,42 +39,38 @@ import generateStyle from './styles'
39
39
  import generateComponentTheme from './theme'
40
40
 
41
41
  import { propTypes, allowedProps } from './props'
42
- import type { MenuItemProps } from './props'
42
+ import type { MenuItemProps, MenuItemState } from './props'
43
43
 
44
44
  /**
45
45
  ---
46
46
  parent: Menu
47
47
  id: Menu.Item
48
48
  ---
49
+ @tsProps
49
50
  **/
50
51
  @withStyle(generateStyle, generateComponentTheme)
51
52
  @testable()
52
- class MenuItem extends Component<MenuItemProps> {
53
+ class MenuItem extends Component<MenuItemProps, MenuItemState> {
53
54
  static readonly componentId = 'Menu.Item'
54
55
 
55
56
  static propTypes = propTypes
56
57
  static allowedProps = allowedProps
57
58
  static defaultProps = {
58
59
  type: 'button',
59
- disabled: false,
60
- // @ts-expect-error ts-migrate(6133) FIXME: 'e' is declared but its value is never read.
61
- onSelect: function (e, value, selected, item) {}
60
+ disabled: false
62
61
  } as const
63
62
 
64
63
  static contextType = MenuContext
65
64
 
66
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
67
- constructor(props) {
68
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 1-2 arguments, but got 0.
69
- super()
65
+ constructor(props: MenuItemProps) {
66
+ super(props)
70
67
 
71
68
  if (typeof props.selected === 'undefined') {
72
69
  this.state = {
73
- selected: props.defaultSelected
70
+ selected: !!props.defaultSelected
74
71
  }
75
72
  }
76
73
 
77
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'labelId' does not exist on type 'MenuIte... Remove this comment to see the full error message
78
74
  this.labelId = uid('MenuItem__label')
79
75
  }
80
76
 
@@ -85,14 +81,16 @@ class MenuItem extends Component<MenuItemProps> {
85
81
 
86
82
  return this.ref
87
83
  }
84
+
85
+ labelId: string
88
86
  ref: Element | null = null
87
+
89
88
  handleRef = (el: Element | null) => {
90
89
  this.ref = el
91
90
  }
92
91
 
93
92
  componentDidMount() {
94
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
95
- this.props.makeStyles()
93
+ this.props.makeStyles?.()
96
94
  const context = this.context
97
95
 
98
96
  if (context && context.registerMenuItem) {
@@ -101,8 +99,7 @@ class MenuItem extends Component<MenuItemProps> {
101
99
  }
102
100
 
103
101
  componentDidUpdate() {
104
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
105
- this.props.makeStyles()
102
+ this.props.makeStyles?.()
106
103
  }
107
104
 
108
105
  componentWillUnmount() {
@@ -113,8 +110,7 @@ class MenuItem extends Component<MenuItemProps> {
113
110
  }
114
111
  }
115
112
 
116
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'e' implicitly has an 'any' type.
117
- handleClick = (e) => {
113
+ handleClick = (e: React.MouseEvent) => {
118
114
  const { onSelect, onClick, disabled, value } = this.props
119
115
  const selected = !this.selected
120
116
 
@@ -137,8 +133,7 @@ class MenuItem extends Component<MenuItemProps> {
137
133
  }
138
134
  }
139
135
 
140
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'e' implicitly has an 'any' type.
141
- handleKeyDown = (e) => {
136
+ handleKeyDown = (e: React.KeyboardEvent) => {
142
137
  const spaceKey = e.keyCode === keycode.codes.space
143
138
  const enterKey = e.keyCode === keycode.codes.enter
144
139
 
@@ -148,14 +143,13 @@ class MenuItem extends Component<MenuItemProps> {
148
143
 
149
144
  if (enterKey) {
150
145
  // handle space key on keyUp for FF
151
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'ref' does not exist on type 'MenuItem'... Remove this comment to see the full error message
152
- findDOMNode(this.ref).click() // eslint-disable-line react/no-find-dom-node
146
+ const refNode = findDOMNode(this.ref) as HTMLElement
147
+ refNode.click()
153
148
  }
154
149
  }
155
150
  }
156
151
 
157
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'e' implicitly has an 'any' type.
158
- handleKeyUp = (e) => {
152
+ handleKeyUp = (e: React.KeyboardEvent) => {
159
153
  const spaceKey = e.keyCode === keycode.codes.space
160
154
  const enterKey = e.keyCode === keycode.codes.enter
161
155
 
@@ -164,14 +158,13 @@ class MenuItem extends Component<MenuItemProps> {
164
158
  e.stopPropagation()
165
159
 
166
160
  if (spaceKey) {
167
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'ref' does not exist on type 'MenuItem'... Remove this comment to see the full error message
168
- findDOMNode(this.ref).click() // eslint-disable-line react/no-find-dom-node
161
+ const refNode = findDOMNode(this.ref) as HTMLElement
162
+ refNode.click()
169
163
  }
170
164
  }
171
165
  }
172
166
 
173
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
174
- handleMouseOver = (event) => {
167
+ handleMouseOver = (event: React.MouseEvent) => {
175
168
  this.focus()
176
169
 
177
170
  if (typeof this.props.onMouseOver === 'function') {
@@ -198,8 +191,7 @@ class MenuItem extends Component<MenuItemProps> {
198
191
 
199
192
  get selected() {
200
193
  return typeof this.props.selected === 'undefined'
201
- ? // @ts-expect-error ts-migrate(2339) FIXME: Property 'selected' does not exist on type 'Readon... Remove this comment to see the full error message
202
- this.state.selected
194
+ ? this.state.selected
203
195
  : this.props.selected
204
196
  }
205
197
 
@@ -208,8 +200,8 @@ class MenuItem extends Component<MenuItemProps> {
208
200
  }
209
201
 
210
202
  focus() {
211
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'ref' does not exist on type 'MenuItem'... Remove this comment to see the full error message
212
- findDOMNode(this.ref).focus() // eslint-disable-line react/no-find-dom-node
203
+ const refNode = findDOMNode(this.ref) as HTMLElement
204
+ refNode.focus()
213
205
  }
214
206
 
215
207
  renderContent() {
@@ -222,7 +214,6 @@ class MenuItem extends Component<MenuItemProps> {
222
214
  {this.selected && <IconCheckSolid />}
223
215
  </span>
224
216
  )}
225
- {/* @ts-expect-error ts-migrate(2339) FIXME: Property 'labelId' does not exist on type 'MenuIte... Remove this comment to see the full error message */}
226
217
  <span css={this.props.styles?.label} id={this.labelId}>
227
218
  {children}
228
219
  </span>
@@ -242,13 +233,12 @@ class MenuItem extends Component<MenuItemProps> {
242
233
  const ElementType = this.elementType
243
234
 
244
235
  return (
245
- <ElementType // eslint-disable-line jsx-a11y/mouse-events-have-key-events
236
+ <ElementType
246
237
  // @ts-expect-error TODO: `ref` prop causes: "Expression produces a union type that is too complex to represent.ts(2590)"
247
238
  tabIndex={-1} // note: tabIndex can be overridden by Menu or MenuItemGroup components
248
239
  {...props}
249
240
  href={href}
250
241
  role={this.role}
251
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'labelId' does not exist on type 'MenuIte... Remove this comment to see the full error message
252
242
  aria-labelledby={this.labelId}
253
243
  aria-disabled={disabled ? 'true' : undefined}
254
244
  aria-controls={controls}