@instructure/ui-menu 8.13.1-snapshot.2 → 8.13.1-snapshot.27

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 (45) hide show
  1. package/es/Menu/MenuItem/index.js +28 -21
  2. package/es/Menu/MenuItem/props.js +0 -23
  3. package/es/Menu/MenuItemGroup/index.js +17 -13
  4. package/es/Menu/MenuItemGroup/props.js +1 -30
  5. package/es/Menu/MenuItemSeparator/index.js +6 -2
  6. package/es/Menu/index.js +56 -52
  7. package/es/Menu/props.js +1 -113
  8. package/es/MenuContext.js +3 -3
  9. package/lib/Menu/MenuItem/index.js +28 -21
  10. package/lib/Menu/MenuItem/props.js +0 -23
  11. package/lib/Menu/MenuItemGroup/index.js +17 -13
  12. package/lib/Menu/MenuItemGroup/props.js +1 -30
  13. package/lib/Menu/MenuItemSeparator/index.js +6 -2
  14. package/lib/Menu/index.js +58 -52
  15. package/lib/Menu/props.js +1 -113
  16. package/lib/MenuContext.js +2 -2
  17. package/package.json +21 -21
  18. package/src/Menu/MenuItem/index.tsx +24 -34
  19. package/src/Menu/MenuItem/props.ts +36 -27
  20. package/src/Menu/MenuItemGroup/index.tsx +28 -48
  21. package/src/Menu/MenuItemGroup/props.ts +37 -30
  22. package/src/Menu/MenuItemSeparator/index.tsx +2 -4
  23. package/src/Menu/index.tsx +79 -133
  24. package/src/Menu/props.ts +76 -84
  25. package/src/MenuContext.ts +3 -2
  26. package/tsconfig.build.json +25 -2
  27. package/tsconfig.build.tsbuildinfo +1 -0
  28. package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
  29. package/types/Menu/MenuItem/index.d.ts +24 -23
  30. package/types/Menu/MenuItem/index.d.ts.map +1 -1
  31. package/types/Menu/MenuItem/props.d.ts +30 -7
  32. package/types/Menu/MenuItem/props.d.ts.map +1 -1
  33. package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
  34. package/types/Menu/MenuItemGroup/index.d.ts +22 -22
  35. package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
  36. package/types/Menu/MenuItemGroup/props.d.ts +33 -8
  37. package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
  38. package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
  39. package/types/Menu/MenuLocator.d.ts +576 -576
  40. package/types/Menu/index.d.ts +57 -67
  41. package/types/Menu/index.d.ts.map +1 -1
  42. package/types/Menu/props.d.ts +94 -16
  43. package/types/Menu/props.d.ts.map +1 -1
  44. package/types/MenuContext.d.ts +3 -2
  45. package/types/MenuContext.d.ts.map +1 -1
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.2+249897ee7",
3
+ "version": "8.13.1-snapshot.27+37d3bca26",
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.2+249897ee7",
28
- "@instructure/ui-color-utils": "8.13.1-snapshot.2+249897ee7",
29
- "@instructure/ui-test-locator": "8.13.1-snapshot.2+249897ee7",
30
- "@instructure/ui-test-queries": "8.13.1-snapshot.2+249897ee7",
31
- "@instructure/ui-test-utils": "8.13.1-snapshot.2+249897ee7",
32
- "@instructure/ui-themes": "8.13.1-snapshot.2+249897ee7"
27
+ "@instructure/ui-babel-preset": "8.13.1-snapshot.27+37d3bca26",
28
+ "@instructure/ui-color-utils": "8.13.1-snapshot.27+37d3bca26",
29
+ "@instructure/ui-test-locator": "8.13.1-snapshot.27+37d3bca26",
30
+ "@instructure/ui-test-queries": "8.13.1-snapshot.27+37d3bca26",
31
+ "@instructure/ui-test-utils": "8.13.1-snapshot.27+37d3bca26",
32
+ "@instructure/ui-themes": "8.13.1-snapshot.27+37d3bca26"
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.13.10",
36
- "@instructure/console": "8.13.1-snapshot.2+249897ee7",
37
- "@instructure/emotion": "8.13.1-snapshot.2+249897ee7",
38
- "@instructure/shared-types": "8.13.1-snapshot.2+249897ee7",
39
- "@instructure/ui-a11y-utils": "8.13.1-snapshot.2+249897ee7",
40
- "@instructure/ui-dom-utils": "8.13.1-snapshot.2+249897ee7",
41
- "@instructure/ui-icons": "8.13.1-snapshot.2+249897ee7",
42
- "@instructure/ui-popover": "8.13.1-snapshot.2+249897ee7",
43
- "@instructure/ui-position": "8.13.1-snapshot.2+249897ee7",
44
- "@instructure/ui-prop-types": "8.13.1-snapshot.2+249897ee7",
45
- "@instructure/ui-react-utils": "8.13.1-snapshot.2+249897ee7",
46
- "@instructure/ui-testable": "8.13.1-snapshot.2+249897ee7",
47
- "@instructure/ui-utils": "8.13.1-snapshot.2+249897ee7",
48
- "@instructure/uid": "8.13.1-snapshot.2+249897ee7",
36
+ "@instructure/console": "8.13.1-snapshot.27+37d3bca26",
37
+ "@instructure/emotion": "8.13.1-snapshot.27+37d3bca26",
38
+ "@instructure/shared-types": "8.13.1-snapshot.27+37d3bca26",
39
+ "@instructure/ui-a11y-utils": "8.13.1-snapshot.27+37d3bca26",
40
+ "@instructure/ui-dom-utils": "8.13.1-snapshot.27+37d3bca26",
41
+ "@instructure/ui-icons": "8.13.1-snapshot.27+37d3bca26",
42
+ "@instructure/ui-popover": "8.13.1-snapshot.27+37d3bca26",
43
+ "@instructure/ui-position": "8.13.1-snapshot.27+37d3bca26",
44
+ "@instructure/ui-prop-types": "8.13.1-snapshot.27+37d3bca26",
45
+ "@instructure/ui-react-utils": "8.13.1-snapshot.27+37d3bca26",
46
+ "@instructure/ui-testable": "8.13.1-snapshot.27+37d3bca26",
47
+ "@instructure/ui-utils": "8.13.1-snapshot.27+37d3bca26",
48
+ "@instructure/uid": "8.13.1-snapshot.27+37d3bca26",
49
49
  "keycode": "^2",
50
50
  "prop-types": "^15"
51
51
  },
@@ -56,5 +56,5 @@
56
56
  "access": "public"
57
57
  },
58
58
  "sideEffects": false,
59
- "gitHead": "249897ee75a61c9436fca89f11473c0ece4c3e15"
59
+ "gitHead": "37d3bca26e420d33639ba518b2443e450ec3df3b"
60
60
  }
@@ -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}
@@ -24,7 +24,7 @@
24
24
 
25
25
  import React from 'react'
26
26
  import PropTypes from 'prop-types'
27
-
27
+ import MenuItem from '../MenuItem'
28
28
  import { controllable } from '@instructure/ui-prop-types'
29
29
 
30
30
  import type {
@@ -35,17 +35,42 @@ import type {
35
35
  } from '@instructure/shared-types'
36
36
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
37
37
 
38
+ type OnMenuItemSelect = (
39
+ e: React.MouseEvent,
40
+ value: MenuItemOwnProps['value'],
41
+ selected: MenuItemOwnProps['selected'],
42
+ args: MenuItem
43
+ ) => void
44
+
38
45
  type MenuItemOwnProps = {
46
+ /**
47
+ * the menu item label
48
+ */
39
49
  children: React.ReactNode
50
+ /**
51
+ * whether to set the menu item state to selected or not on initial render
52
+ */
40
53
  defaultSelected?: boolean
41
- selected?: any // TODO: controllable(PropTypes.bool, 'onSelect', 'defaultSelected')
42
- onSelect?: (...args: any[]) => any
43
- onClick?: (...args: any[]) => any
44
- onKeyDown?: (...args: any[]) => any
45
- onKeyUp?: (...args: any[]) => any
46
- onMouseOver?: (...args: any[]) => any
54
+ /**
55
+ * whether the menu item is selected or not (must be accompanied by an `onSelect` prop)
56
+ */
57
+ selected?: boolean // TODO: controllable(PropTypes.bool, 'onSelect', 'defaultSelected')
58
+ /**
59
+ * when used with the `selected` prop, the component will not control its own state
60
+ */
61
+ onSelect?: OnMenuItemSelect
62
+ onClick?: (e: React.MouseEvent) => void
63
+ onKeyDown?: (e: React.KeyboardEvent) => void
64
+ onKeyUp?: (e: React.KeyboardEvent) => void
65
+ onMouseOver?: (e: React.MouseEvent, args: MenuItem) => void
66
+ /**
67
+ * the id of the element that the menu item will act upon
68
+ */
47
69
  controls?: string
48
70
  disabled?: boolean
71
+ /**
72
+ * the element type to render as (will default to `<a>` if href is provided)
73
+ */
49
74
  as?: AsElementType
50
75
  type?: 'button' | 'checkbox' | 'radio' | 'flyout'
51
76
  value?: string | number
@@ -63,34 +88,16 @@ type MenuItemProps = MenuItemOwnProps &
63
88
  type MenuItemStyle = ComponentStyle<'menuItem' | 'icon' | 'label'>
64
89
 
65
90
  const propTypes: PropValidators<PropKeys> = {
66
- /**
67
- * the menu item label
68
- */
69
91
  children: PropTypes.node.isRequired,
70
- /**
71
- * whether to set the menu item state to selected or not on initial render
72
- */
73
92
  defaultSelected: PropTypes.bool,
74
- /**
75
- * whether the menu item is selected or not (must be accompanied by an `onSelect` prop)
76
- */
77
93
  selected: controllable(PropTypes.bool, 'onSelect', 'defaultSelected'),
78
- /**
79
- * when used with the `selected` prop, the component will not control its own state
80
- */
81
94
  onSelect: PropTypes.func,
82
95
  onClick: PropTypes.func,
83
96
  onKeyDown: PropTypes.func,
84
97
  onKeyUp: PropTypes.func,
85
98
  onMouseOver: PropTypes.func,
86
- /**
87
- * the id of the element that the menu item will act upon
88
- */
89
99
  controls: PropTypes.string,
90
100
  disabled: PropTypes.bool,
91
- /**
92
- * the element type to render as (will default to `<a>` if href is provided)
93
- */
94
101
  as: PropTypes.elementType, // eslint-disable-line react/require-default-props
95
102
  type: PropTypes.oneOf(['button', 'checkbox', 'radio', 'flyout']),
96
103
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -113,6 +120,8 @@ const allowedProps: AllowedPropKeys = [
113
120
  'value',
114
121
  'href'
115
122
  ]
116
-
117
- export type { MenuItemProps, MenuItemStyle }
123
+ type MenuItemState = {
124
+ selected: boolean
125
+ }
126
+ export type { MenuItemProps, MenuItemStyle, MenuItemState, OnMenuItemSelect }
118
127
  export { propTypes, allowedProps }