@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.
- package/CHANGELOG.md +4 -0
- package/es/Menu/MenuItem/index.js +28 -21
- package/es/Menu/MenuItem/props.js +0 -23
- package/es/Menu/MenuItemGroup/index.js +17 -13
- package/es/Menu/MenuItemGroup/props.js +1 -30
- package/es/Menu/MenuItemSeparator/index.js +6 -2
- package/es/Menu/index.js +59 -56
- package/es/Menu/props.js +1 -113
- package/es/MenuContext.js +3 -3
- package/lib/Menu/MenuItem/index.js +28 -21
- package/lib/Menu/MenuItem/props.js +0 -23
- package/lib/Menu/MenuItemGroup/index.js +17 -13
- package/lib/Menu/MenuItemGroup/props.js +1 -30
- package/lib/Menu/MenuItemSeparator/index.js +6 -2
- package/lib/Menu/index.js +61 -56
- package/lib/Menu/props.js +1 -113
- package/lib/MenuContext.js +2 -2
- package/package.json +21 -22
- package/src/Menu/MenuItem/index.tsx +24 -34
- package/src/Menu/MenuItem/props.ts +36 -27
- package/src/Menu/MenuItemGroup/index.tsx +28 -48
- package/src/Menu/MenuItemGroup/props.ts +37 -30
- package/src/Menu/MenuItemSeparator/index.tsx +2 -4
- package/src/Menu/index.tsx +81 -135
- package/src/Menu/props.ts +79 -84
- package/src/MenuContext.ts +3 -2
- package/tsconfig.build.json +25 -2
- package/tsconfig.build.tsbuildinfo +1 -0
- package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
- package/types/Menu/MenuItem/index.d.ts +24 -23
- package/types/Menu/MenuItem/index.d.ts.map +1 -1
- package/types/Menu/MenuItem/props.d.ts +30 -7
- package/types/Menu/MenuItem/props.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
- package/types/Menu/MenuItemGroup/index.d.ts +22 -22
- package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/props.d.ts +33 -8
- package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
- package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
- package/types/Menu/MenuLocator.d.ts +576 -576
- package/types/Menu/index.d.ts +58 -68
- package/types/Menu/index.d.ts.map +1 -1
- package/types/Menu/props.d.ts +94 -16
- package/types/Menu/props.d.ts.map +1 -1
- package/types/MenuContext.d.ts +3 -2
- package/types/MenuContext.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.14.0](https://github.com/instructure/instructure-ui/compare/v8.13.0...v8.14.0) (2021-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-menu
|
|
9
|
+
|
|
6
10
|
# [8.13.0](https://github.com/instructure/instructure-ui/compare/v8.12.0...v8.13.0) (2021-12-01)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-menu
|
|
@@ -44,10 +44,12 @@ import { propTypes, allowedProps } from './props';
|
|
|
44
44
|
parent: Menu
|
|
45
45
|
id: Menu.Item
|
|
46
46
|
---
|
|
47
|
+
@tsProps
|
|
47
48
|
**/
|
|
48
49
|
let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class MenuItem extends Component {
|
|
49
50
|
constructor(props) {
|
|
50
|
-
super();
|
|
51
|
+
super(props);
|
|
52
|
+
this.labelId = void 0;
|
|
51
53
|
this.ref = null;
|
|
52
54
|
|
|
53
55
|
this.handleRef = el => {
|
|
@@ -93,7 +95,8 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
93
95
|
|
|
94
96
|
if (enterKey) {
|
|
95
97
|
// handle space key on keyUp for FF
|
|
96
|
-
findDOMNode(this.ref)
|
|
98
|
+
const refNode = findDOMNode(this.ref);
|
|
99
|
+
refNode.click();
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
102
|
};
|
|
@@ -107,7 +110,8 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
107
110
|
e.stopPropagation();
|
|
108
111
|
|
|
109
112
|
if (spaceKey) {
|
|
110
|
-
findDOMNode(this.ref)
|
|
113
|
+
const refNode = findDOMNode(this.ref);
|
|
114
|
+
refNode.click();
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
};
|
|
@@ -122,7 +126,7 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
122
126
|
|
|
123
127
|
if (typeof props.selected === 'undefined') {
|
|
124
128
|
this.state = {
|
|
125
|
-
selected: props.defaultSelected
|
|
129
|
+
selected: !!props.defaultSelected
|
|
126
130
|
};
|
|
127
131
|
}
|
|
128
132
|
|
|
@@ -134,7 +138,9 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
componentDidMount() {
|
|
137
|
-
|
|
141
|
+
var _this$props$makeStyle, _this$props2;
|
|
142
|
+
|
|
143
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
138
144
|
const context = this.context;
|
|
139
145
|
|
|
140
146
|
if (context && context.registerMenuItem) {
|
|
@@ -143,7 +149,9 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
componentDidUpdate() {
|
|
146
|
-
|
|
152
|
+
var _this$props$makeStyle2, _this$props3;
|
|
153
|
+
|
|
154
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
componentWillUnmount() {
|
|
@@ -183,15 +191,16 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
focus() {
|
|
186
|
-
findDOMNode(this.ref)
|
|
194
|
+
const refNode = findDOMNode(this.ref);
|
|
195
|
+
refNode.focus();
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
renderContent() {
|
|
190
199
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
191
200
|
|
|
192
|
-
const _this$
|
|
193
|
-
children = _this$
|
|
194
|
-
type = _this$
|
|
201
|
+
const _this$props4 = this.props,
|
|
202
|
+
children = _this$props4.children,
|
|
203
|
+
type = _this$props4.type;
|
|
195
204
|
return jsx("span", null, (type === 'checkbox' || type === 'radio') && jsx("span", {
|
|
196
205
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
197
206
|
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = jsx(IconCheckSolid, null)))), jsx("span", {
|
|
@@ -205,17 +214,16 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
205
214
|
render() {
|
|
206
215
|
var _this$props$styles4;
|
|
207
216
|
|
|
208
|
-
const _this$
|
|
209
|
-
disabled = _this$
|
|
210
|
-
controls = _this$
|
|
211
|
-
onKeyDown = _this$
|
|
212
|
-
onKeyUp = _this$
|
|
213
|
-
type = _this$
|
|
214
|
-
href = _this$
|
|
217
|
+
const _this$props5 = this.props,
|
|
218
|
+
disabled = _this$props5.disabled,
|
|
219
|
+
controls = _this$props5.controls,
|
|
220
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
221
|
+
onKeyUp = _this$props5.onKeyUp,
|
|
222
|
+
type = _this$props5.type,
|
|
223
|
+
href = _this$props5.href;
|
|
215
224
|
const props = omitProps(this.props, MenuItem.allowedProps);
|
|
216
225
|
const ElementType = this.elementType;
|
|
217
|
-
return jsx(ElementType
|
|
218
|
-
, Object.assign({
|
|
226
|
+
return jsx(ElementType, Object.assign({
|
|
219
227
|
tabIndex: -1 // note: tabIndex can be overridden by Menu or MenuItemGroup components
|
|
220
228
|
|
|
221
229
|
}, props, {
|
|
@@ -236,8 +244,7 @@ let MenuItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 =
|
|
|
236
244
|
|
|
237
245
|
}, _class2.displayName = "MenuItem", _class2.componentId = 'Menu.Item', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
238
246
|
type: 'button',
|
|
239
|
-
disabled: false
|
|
240
|
-
onSelect: function (e, value, selected, item) {}
|
|
247
|
+
disabled: false
|
|
241
248
|
}, _class2.contextType = MenuContext, _temp)) || _class) || _class);
|
|
242
249
|
export default MenuItem;
|
|
243
250
|
export { MenuItem };
|
|
@@ -24,39 +24,16 @@
|
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
import { controllable } from '@instructure/ui-prop-types';
|
|
26
26
|
const propTypes = {
|
|
27
|
-
/**
|
|
28
|
-
* the menu item label
|
|
29
|
-
*/
|
|
30
27
|
children: PropTypes.node.isRequired,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* whether to set the menu item state to selected or not on initial render
|
|
34
|
-
*/
|
|
35
28
|
defaultSelected: PropTypes.bool,
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* whether the menu item is selected or not (must be accompanied by an `onSelect` prop)
|
|
39
|
-
*/
|
|
40
29
|
selected: controllable(PropTypes.bool, 'onSelect', 'defaultSelected'),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* when used with the `selected` prop, the component will not control its own state
|
|
44
|
-
*/
|
|
45
30
|
onSelect: PropTypes.func,
|
|
46
31
|
onClick: PropTypes.func,
|
|
47
32
|
onKeyDown: PropTypes.func,
|
|
48
33
|
onKeyUp: PropTypes.func,
|
|
49
34
|
onMouseOver: PropTypes.func,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* the id of the element that the menu item will act upon
|
|
53
|
-
*/
|
|
54
35
|
controls: PropTypes.string,
|
|
55
36
|
disabled: PropTypes.bool,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* the element type to render as (will default to `<a>` if href is provided)
|
|
59
|
-
*/
|
|
60
37
|
as: PropTypes.elementType,
|
|
61
38
|
// eslint-disable-line react/require-default-props
|
|
62
39
|
type: PropTypes.oneOf(['button', 'checkbox', 'radio', 'flyout']),
|
|
@@ -41,10 +41,12 @@ import { propTypes, allowedProps } from './props';
|
|
|
41
41
|
parent: Menu
|
|
42
42
|
id: Menu.Group
|
|
43
43
|
---
|
|
44
|
+
@tsProps
|
|
44
45
|
**/
|
|
45
46
|
let MenuItemGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class MenuItemGroup extends Component {
|
|
46
47
|
constructor(props) {
|
|
47
|
-
super();
|
|
48
|
+
super(props);
|
|
49
|
+
this._labelId = void 0;
|
|
48
50
|
this.ref = null;
|
|
49
51
|
|
|
50
52
|
this.handleRef = el => {
|
|
@@ -99,11 +101,15 @@ let MenuItemGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
componentDidMount() {
|
|
102
|
-
|
|
104
|
+
var _this$props$makeStyle, _this$props;
|
|
105
|
+
|
|
106
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
componentDidUpdate() {
|
|
106
|
-
|
|
110
|
+
var _this$props$makeStyle2, _this$props2;
|
|
111
|
+
|
|
112
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
selectedFromChildren(props) {
|
|
@@ -139,13 +145,13 @@ let MenuItemGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
139
145
|
}
|
|
140
146
|
|
|
141
147
|
renderChildren() {
|
|
142
|
-
const _this$
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
const _this$props3 = this.props,
|
|
149
|
+
disabled = _this$props3.disabled,
|
|
150
|
+
controls = _this$props3.controls,
|
|
151
|
+
allowMultiple = _this$props3.allowMultiple,
|
|
152
|
+
isTabbable = _this$props3.isTabbable,
|
|
153
|
+
onMouseOver = _this$props3.onMouseOver;
|
|
154
|
+
const children = this.props.children;
|
|
149
155
|
let index = -1;
|
|
150
156
|
return Children.map(children, child => {
|
|
151
157
|
if (matchComponentTypes(child, [MenuItem])) {
|
|
@@ -193,9 +199,7 @@ let MenuItemGroup = (_dec = withStyle(generateStyle, generateComponentTheme), _d
|
|
|
193
199
|
children: null,
|
|
194
200
|
isTabbable: false,
|
|
195
201
|
allowMultiple: false,
|
|
196
|
-
defaultSelected: []
|
|
197
|
-
itemRef: function (item) {},
|
|
198
|
-
onSelect: function (e, value, selected, item) {}
|
|
202
|
+
defaultSelected: []
|
|
199
203
|
}, _temp)) || _class) || _class);
|
|
200
204
|
export default MenuItemGroup;
|
|
201
205
|
export { MenuItemGroup };
|
|
@@ -28,44 +28,15 @@ import { MenuItemSeparator } from '../MenuItemSeparator';
|
|
|
28
28
|
const propTypes = {
|
|
29
29
|
label: PropTypes.node.isRequired,
|
|
30
30
|
allowMultiple: PropTypes.bool,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* children of type `Menu.Item`, `Menu.Separator`
|
|
34
|
-
*/
|
|
35
31
|
children: ChildrenPropTypes.oneOf([MenuItem, MenuItemSeparator]),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* an array of the values (or indices by default) for the selected items
|
|
39
|
-
*/
|
|
40
32
|
selected: controllable(PropTypes.array, 'onSelect', 'defaultSelected'),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* an array of the values (or indices by default) for the selected items on initial render
|
|
44
|
-
*/
|
|
45
33
|
defaultSelected: PropTypes.array,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* call this function when a menu item is selected
|
|
49
|
-
*/
|
|
50
34
|
onSelect: PropTypes.func,
|
|
51
35
|
onMouseOver: PropTypes.func,
|
|
52
|
-
onKeyDown: PropTypes.func,
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* the id of the element that the menu items will act upon
|
|
56
|
-
*/
|
|
57
36
|
controls: PropTypes.string,
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* returns a reference to the `MenuItem`
|
|
61
|
-
*/
|
|
62
37
|
itemRef: PropTypes.func,
|
|
63
38
|
disabled: PropTypes.bool,
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* should the group appear in the tab order (the first item will have a tabIndex of 0)
|
|
67
|
-
*/
|
|
68
39
|
isTabbable: PropTypes.bool
|
|
69
40
|
};
|
|
70
|
-
const allowedProps = ['label', 'allowMultiple', 'children', 'selected', 'defaultSelected', 'onSelect', 'onMouseOver', '
|
|
41
|
+
const allowedProps = ['label', 'allowMultiple', 'children', 'selected', 'defaultSelected', 'onSelect', 'onMouseOver', 'controls', 'itemRef', 'disabled', 'isTabbable'];
|
|
71
42
|
export { propTypes, allowedProps };
|
|
@@ -51,11 +51,15 @@ let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme)
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
componentDidMount() {
|
|
54
|
-
|
|
54
|
+
var _this$props$makeStyle, _this$props;
|
|
55
|
+
|
|
56
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
componentDidUpdate() {
|
|
58
|
-
|
|
60
|
+
var _this$props$makeStyle2, _this$props2;
|
|
61
|
+
|
|
62
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
render() {
|
package/es/Menu/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import { Children, Component } from 'react';
|
|
28
|
+
import React, { Children, Component } from 'react';
|
|
29
29
|
import keycode from 'keycode';
|
|
30
30
|
import { Popover } from '@instructure/ui-popover';
|
|
31
31
|
import { uid } from '@instructure/uid';
|
|
@@ -46,6 +46,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
46
46
|
---
|
|
47
47
|
category: components
|
|
48
48
|
---
|
|
49
|
+
@tsProps
|
|
49
50
|
**/
|
|
50
51
|
let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Menu extends Component {
|
|
51
52
|
constructor(props) {
|
|
@@ -59,7 +60,8 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
59
60
|
this._trigger = null;
|
|
60
61
|
this._menu = null;
|
|
61
62
|
this._labelId = uid('Menu__label');
|
|
62
|
-
this._activeSubMenu =
|
|
63
|
+
this._activeSubMenu = void 0;
|
|
64
|
+
this._id = void 0;
|
|
63
65
|
this.ref = null;
|
|
64
66
|
|
|
65
67
|
this.handleRef = el => {
|
|
@@ -91,13 +93,13 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
91
93
|
this.handleTriggerKeyDown = event => {
|
|
92
94
|
if (this.props.type === 'flyout' && event.keyCode === keycode.codes.right) {
|
|
93
95
|
event.persist();
|
|
94
|
-
this.show();
|
|
96
|
+
this.show(event);
|
|
95
97
|
}
|
|
96
98
|
};
|
|
97
99
|
|
|
98
|
-
this.handleTriggerMouseOver =
|
|
100
|
+
this.handleTriggerMouseOver = event => {
|
|
99
101
|
if (this.props.type === 'flyout') {
|
|
100
|
-
this.show();
|
|
102
|
+
this.show(event);
|
|
101
103
|
}
|
|
102
104
|
};
|
|
103
105
|
|
|
@@ -112,10 +114,10 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
112
114
|
const _keycode$codes = keycode.codes,
|
|
113
115
|
down = _keycode$codes.down,
|
|
114
116
|
up = _keycode$codes.up,
|
|
115
|
-
pgup = _keycode$codes.pgup,
|
|
116
|
-
pgdn = _keycode$codes.pgdn,
|
|
117
117
|
tab = _keycode$codes.tab,
|
|
118
118
|
left = _keycode$codes.left;
|
|
119
|
+
const pgdn = keycode.codes['page down'];
|
|
120
|
+
const pgup = keycode.codes['page up'];
|
|
119
121
|
|
|
120
122
|
if (key === down || key === pgdn) {
|
|
121
123
|
event.preventDefault();
|
|
@@ -201,11 +203,15 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
201
203
|
}
|
|
202
204
|
|
|
203
205
|
componentDidMount() {
|
|
204
|
-
|
|
206
|
+
var _this$props$makeStyle, _this$props;
|
|
207
|
+
|
|
208
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
205
209
|
}
|
|
206
210
|
|
|
207
|
-
componentDidUpdate(
|
|
208
|
-
|
|
211
|
+
componentDidUpdate() {
|
|
212
|
+
var _this$props$makeStyle2, _this$props2;
|
|
213
|
+
|
|
214
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
get menuItems() {
|
|
@@ -214,11 +220,15 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
214
220
|
|
|
215
221
|
focus() {
|
|
216
222
|
if (this.shown) {
|
|
217
|
-
|
|
223
|
+
var _this$_menu;
|
|
224
|
+
|
|
225
|
+
error(!!((_this$_menu = this._menu) !== null && _this$_menu !== void 0 && _this$_menu.focus), '[Menu] Could not focus the menu.');
|
|
218
226
|
|
|
219
227
|
this._menu.focus();
|
|
220
228
|
} else {
|
|
221
|
-
|
|
229
|
+
var _this$_trigger;
|
|
230
|
+
|
|
231
|
+
error(!!((_this$_trigger = this._trigger) !== null && _this$_trigger !== void 0 && _this$_trigger.focus), '[Menu] Could not focus the trigger.');
|
|
222
232
|
|
|
223
233
|
this._trigger.focus();
|
|
224
234
|
}
|
|
@@ -247,7 +257,7 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
247
257
|
|
|
248
258
|
const current = this.focusedIndex < 0 && step < 0 ? 0 : this.focusedIndex;
|
|
249
259
|
const nextItem = this.menuItems[(current + count + step) % count];
|
|
250
|
-
error(nextItem && nextItem.focus, '[Menu] Could not focus next menu item.');
|
|
260
|
+
error(typeof nextItem !== 'undefined' && typeof nextItem.focus !== 'undefined', '[Menu] Could not focus next menu item.');
|
|
251
261
|
nextItem.focus();
|
|
252
262
|
}
|
|
253
263
|
|
|
@@ -256,9 +266,9 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
256
266
|
}
|
|
257
267
|
|
|
258
268
|
renderChildren() {
|
|
259
|
-
const _this$
|
|
260
|
-
children = _this$
|
|
261
|
-
disabled = _this$
|
|
269
|
+
const _this$props3 = this.props,
|
|
270
|
+
children = _this$props3.children,
|
|
271
|
+
disabled = _this$props3.disabled;
|
|
262
272
|
let count = 0;
|
|
263
273
|
return Children.map(children, child => {
|
|
264
274
|
if (!matchComponentTypes(child, ['MenuItemSeparator', 'MenuItem', 'MenuItemGroup', 'Menu'])) {
|
|
@@ -274,8 +284,8 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
274
284
|
}, child);
|
|
275
285
|
}
|
|
276
286
|
|
|
277
|
-
const
|
|
278
|
-
|
|
287
|
+
const menuItemChild = child;
|
|
288
|
+
const controls = menuItemChild.props['aria-controls'] || menuItemChild.props.controls || this.props['aria-controls'] || this.props.controls;
|
|
279
289
|
|
|
280
290
|
if (matchComponentTypes(child, ['MenuItem'])) {
|
|
281
291
|
return jsx("li", {
|
|
@@ -330,21 +340,21 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
330
340
|
}, child.props.title || child.props.label)
|
|
331
341
|
}));
|
|
332
342
|
}
|
|
343
|
+
|
|
344
|
+
return;
|
|
333
345
|
});
|
|
334
346
|
}
|
|
335
347
|
|
|
336
348
|
renderMenu() {
|
|
337
349
|
var _this$props$styles;
|
|
338
350
|
|
|
339
|
-
const _this$
|
|
340
|
-
disabled = _this$
|
|
341
|
-
label = _this$
|
|
342
|
-
trigger = _this$
|
|
343
|
-
onKeyUp = _this$
|
|
344
|
-
const labelledBy = this.props['aria-labelledby'];
|
|
345
|
-
|
|
346
|
-
const controls = this.props['aria-controls']; // eslint-disable-line react/prop-types
|
|
347
|
-
|
|
351
|
+
const _this$props4 = this.props,
|
|
352
|
+
disabled = _this$props4.disabled,
|
|
353
|
+
label = _this$props4.label,
|
|
354
|
+
trigger = _this$props4.trigger,
|
|
355
|
+
onKeyUp = _this$props4.onKeyUp;
|
|
356
|
+
const labelledBy = this.props['aria-labelledby'];
|
|
357
|
+
const controls = this.props['aria-controls'];
|
|
348
358
|
return jsx(MenuContext.Provider, {
|
|
349
359
|
value: {
|
|
350
360
|
removeMenuItem: this.removeMenuItem,
|
|
@@ -355,7 +365,7 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
355
365
|
"aria-label": label,
|
|
356
366
|
tabIndex: 0,
|
|
357
367
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menu,
|
|
358
|
-
"aria-labelledby": labelledBy || trigger
|
|
368
|
+
"aria-labelledby": labelledBy || (trigger ? this._labelId : void 0),
|
|
359
369
|
"aria-controls": controls,
|
|
360
370
|
"aria-disabled": disabled ? 'true' : void 0,
|
|
361
371
|
onKeyDown: this.handleMenuKeyDown,
|
|
@@ -365,26 +375,30 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
365
375
|
}
|
|
366
376
|
|
|
367
377
|
render() {
|
|
368
|
-
const _this$
|
|
369
|
-
show = _this$
|
|
370
|
-
defaultShow = _this$
|
|
371
|
-
placement = _this$
|
|
372
|
-
withArrow = _this$
|
|
373
|
-
trigger = _this$
|
|
374
|
-
mountNode = _this$
|
|
375
|
-
popoverRef = _this$
|
|
376
|
-
disabled = _this$
|
|
377
|
-
onDismiss = _this$
|
|
378
|
-
onFocus = _this$
|
|
379
|
-
onMouseOver = _this$
|
|
380
|
-
offsetX = _this$
|
|
381
|
-
offsetY = _this$
|
|
378
|
+
const _this$props5 = this.props,
|
|
379
|
+
show = _this$props5.show,
|
|
380
|
+
defaultShow = _this$props5.defaultShow,
|
|
381
|
+
placement = _this$props5.placement,
|
|
382
|
+
withArrow = _this$props5.withArrow,
|
|
383
|
+
trigger = _this$props5.trigger,
|
|
384
|
+
mountNode = _this$props5.mountNode,
|
|
385
|
+
popoverRef = _this$props5.popoverRef,
|
|
386
|
+
disabled = _this$props5.disabled,
|
|
387
|
+
onDismiss = _this$props5.onDismiss,
|
|
388
|
+
onFocus = _this$props5.onFocus,
|
|
389
|
+
onMouseOver = _this$props5.onMouseOver,
|
|
390
|
+
offsetX = _this$props5.offsetX,
|
|
391
|
+
offsetY = _this$props5.offsetY;
|
|
382
392
|
return trigger ? jsx(Popover, {
|
|
383
393
|
isShowingContent: show,
|
|
384
394
|
defaultIsShowingContent: defaultShow,
|
|
385
395
|
onHideContent: (event, _ref) => {
|
|
386
396
|
let documentClick = _ref.documentClick;
|
|
387
|
-
|
|
397
|
+
|
|
398
|
+
if (typeof onDismiss === 'function') {
|
|
399
|
+
onDismiss(event, documentClick);
|
|
400
|
+
}
|
|
401
|
+
|
|
388
402
|
this.handleToggle(false);
|
|
389
403
|
},
|
|
390
404
|
onShowContent: () => this.handleToggle(true),
|
|
@@ -408,7 +422,8 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
408
422
|
},
|
|
409
423
|
renderTrigger: safeCloneElement(trigger, {
|
|
410
424
|
ref: el => {
|
|
411
|
-
this.
|
|
425
|
+
this._trigger = el;
|
|
426
|
+
this.ref = (el === null || el === void 0 ? void 0 : el.ref) || el;
|
|
412
427
|
},
|
|
413
428
|
'aria-haspopup': true,
|
|
414
429
|
id: this._labelId,
|
|
@@ -420,25 +435,13 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
420
435
|
}
|
|
421
436
|
|
|
422
437
|
}, _class2.displayName = "Menu", _class2.componentId = 'Menu', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
423
|
-
children: null,
|
|
424
438
|
label: null,
|
|
425
439
|
disabled: false,
|
|
426
440
|
trigger: null,
|
|
427
441
|
placement: 'bottom center',
|
|
428
442
|
defaultShow: false,
|
|
429
|
-
onToggle: (shown, menu) => {},
|
|
430
|
-
onSelect: (event, value, selected, item) => {},
|
|
431
|
-
onDismiss: (event, documentClick) => {},
|
|
432
|
-
onBlur: event => {},
|
|
433
|
-
onFocus: event => {},
|
|
434
|
-
onMouseOver: event => {},
|
|
435
|
-
onKeyDown: event => {},
|
|
436
|
-
onKeyUp: event => {},
|
|
437
|
-
menuRef: el => {},
|
|
438
|
-
popoverRef: el => {},
|
|
439
443
|
mountNode: null,
|
|
440
444
|
constrain: 'window',
|
|
441
|
-
liveRegion: null,
|
|
442
445
|
shouldHideOnSelect: true,
|
|
443
446
|
shouldFocusTriggerOnClose: true,
|
|
444
447
|
withArrow: true,
|