@instructure/ui-menu 8.25.1-snapshot-10 → 8.25.1-snapshot-13
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 +1 -1
- package/es/Menu/MenuItem/index.js +84 -88
- package/es/Menu/MenuItemGroup/index.js +53 -58
- package/es/Menu/MenuItemSeparator/index.js +11 -11
- package/es/Menu/index.js +169 -163
- package/lib/Menu/MenuItem/index.js +84 -88
- package/lib/Menu/MenuItemGroup/index.js +53 -58
- package/lib/Menu/MenuItemSeparator/index.js +11 -11
- package/lib/Menu/index.js +169 -163
- package/package.json +19 -19
|
@@ -33,7 +33,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
33
33
|
|
|
34
34
|
var _props = require("./props");
|
|
35
35
|
|
|
36
|
-
var _dec, _dec2, _dec3, _class;
|
|
36
|
+
var _dec, _dec2, _dec3, _class, _class2;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
---
|
|
@@ -42,21 +42,53 @@ id: Menu.Group
|
|
|
42
42
|
---
|
|
43
43
|
@tsProps
|
|
44
44
|
**/
|
|
45
|
-
let MenuItemGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = class MenuItemGroup extends _react.Component {
|
|
46
|
-
static displayName = "MenuItemGroup";
|
|
47
|
-
static componentId = 'Menu.Group';
|
|
48
|
-
static propTypes = _props.propTypes;
|
|
49
|
-
static allowedProps = _props.allowedProps;
|
|
50
|
-
static defaultProps = {
|
|
51
|
-
disabled: false,
|
|
52
|
-
children: null,
|
|
53
|
-
isTabbable: false,
|
|
54
|
-
allowMultiple: false,
|
|
55
|
-
defaultSelected: []
|
|
56
|
-
};
|
|
57
|
-
|
|
45
|
+
let MenuItemGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class MenuItemGroup extends _react.Component {
|
|
58
46
|
constructor(props) {
|
|
59
47
|
super(props);
|
|
48
|
+
this._labelId = void 0;
|
|
49
|
+
this.ref = null;
|
|
50
|
+
|
|
51
|
+
this.handleRef = el => {
|
|
52
|
+
this.ref = el;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
this.handleSelect = (e, value, selected, item) => {
|
|
56
|
+
if (this.props.disabled) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (this.props.selected) {
|
|
62
|
+
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
63
|
+
} else {
|
|
64
|
+
this.setState(state => {
|
|
65
|
+
return {
|
|
66
|
+
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
this.updateSelected = (e, value, items, selected, item) => {
|
|
73
|
+
const allowMultiple = this.props.allowMultiple;
|
|
74
|
+
let updated = allowMultiple ? [...items] : [];
|
|
75
|
+
const location = updated.indexOf(value);
|
|
76
|
+
|
|
77
|
+
if (selected === true && location < 0) {
|
|
78
|
+
updated.push(value);
|
|
79
|
+
} else if (selected === false && location !== -1) {
|
|
80
|
+
updated.splice(location, 1);
|
|
81
|
+
} else if (!allowMultiple && updated.length < 1) {
|
|
82
|
+
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
83
|
+
updated = [...items];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (typeof this.props.onSelect === 'function') {
|
|
87
|
+
this.props.onSelect(e, updated, selected, item);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return updated;
|
|
91
|
+
};
|
|
60
92
|
|
|
61
93
|
if (typeof props.selected === 'undefined') {
|
|
62
94
|
this.state = {
|
|
@@ -67,12 +99,6 @@ let MenuItemGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
67
99
|
this._labelId = props.deterministicId('MenuItemGroup');
|
|
68
100
|
}
|
|
69
101
|
|
|
70
|
-
_labelId;
|
|
71
|
-
ref = null;
|
|
72
|
-
handleRef = el => {
|
|
73
|
-
this.ref = el;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
102
|
componentDidMount() {
|
|
77
103
|
var _this$props$makeStyle, _this$props;
|
|
78
104
|
|
|
@@ -85,43 +111,6 @@ let MenuItemGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
85
111
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
86
112
|
}
|
|
87
113
|
|
|
88
|
-
handleSelect = (e, value, selected, item) => {
|
|
89
|
-
if (this.props.disabled) {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.props.selected) {
|
|
95
|
-
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
96
|
-
} else {
|
|
97
|
-
this.setState(state => {
|
|
98
|
-
return {
|
|
99
|
-
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
updateSelected = (e, value, items, selected, item) => {
|
|
105
|
-
const allowMultiple = this.props.allowMultiple;
|
|
106
|
-
let updated = allowMultiple ? [...items] : [];
|
|
107
|
-
const location = updated.indexOf(value);
|
|
108
|
-
|
|
109
|
-
if (selected === true && location < 0) {
|
|
110
|
-
updated.push(value);
|
|
111
|
-
} else if (selected === false && location !== -1) {
|
|
112
|
-
updated.splice(location, 1);
|
|
113
|
-
} else if (!allowMultiple && updated.length < 1) {
|
|
114
|
-
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
115
|
-
updated = [...items];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (typeof this.props.onSelect === 'function') {
|
|
119
|
-
this.props.onSelect(e, updated, selected, item);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return updated;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
114
|
selectedFromChildren(props) {
|
|
126
115
|
const children = props.children,
|
|
127
116
|
allowMultiple = props.allowMultiple;
|
|
@@ -207,7 +196,13 @@ let MenuItemGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
207
196
|
}, this.renderChildren()));
|
|
208
197
|
}
|
|
209
198
|
|
|
210
|
-
}
|
|
199
|
+
}, _class2.displayName = "MenuItemGroup", _class2.componentId = 'Menu.Group', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
200
|
+
disabled: false,
|
|
201
|
+
children: null,
|
|
202
|
+
isTabbable: false,
|
|
203
|
+
allowMultiple: false,
|
|
204
|
+
defaultSelected: []
|
|
205
|
+
}, _class2)) || _class) || _class) || _class);
|
|
211
206
|
exports.MenuItemGroup = MenuItemGroup;
|
|
212
207
|
var _default = MenuItemGroup;
|
|
213
208
|
exports.default = _default;
|
|
@@ -21,7 +21,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
21
21
|
|
|
22
22
|
var _props = require("./props");
|
|
23
23
|
|
|
24
|
-
var _dec, _dec2, _class;
|
|
24
|
+
var _dec, _dec2, _class, _class2;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
---
|
|
@@ -30,15 +30,15 @@ id: Menu.Separator
|
|
|
30
30
|
---
|
|
31
31
|
@module MenuItemSeparator
|
|
32
32
|
**/
|
|
33
|
-
let MenuItemSeparator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class MenuItemSeparator extends _react.Component {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
33
|
+
let MenuItemSeparator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class MenuItemSeparator extends _react.Component {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.ref = null;
|
|
37
|
+
|
|
38
|
+
this.handleRef = el => {
|
|
39
|
+
this.ref = el;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
componentDidMount() {
|
|
44
44
|
var _this$props$makeStyle, _this$props;
|
|
@@ -63,7 +63,7 @@ let MenuItemSeparator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.
|
|
|
63
63
|
}));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
}) || _class) || _class);
|
|
66
|
+
}, _class2.displayName = "MenuItemSeparator", _class2.componentId = 'Menu.Separator', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2)) || _class) || _class);
|
|
67
67
|
exports.MenuItemSeparator = MenuItemSeparator;
|
|
68
68
|
var _default = MenuItemSeparator;
|
|
69
69
|
exports.default = _default;
|
package/lib/Menu/index.js
CHANGED
|
@@ -62,7 +62,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
62
62
|
|
|
63
63
|
var _props = require("./props");
|
|
64
64
|
|
|
65
|
-
var _dec, _dec2, _dec3, _class;
|
|
65
|
+
var _dec, _dec2, _dec3, _class, _class2;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
---
|
|
@@ -70,56 +70,162 @@ category: components
|
|
|
70
70
|
---
|
|
71
71
|
@tsProps
|
|
72
72
|
**/
|
|
73
|
-
let Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = class Menu extends _react.Component {
|
|
74
|
-
static displayName = "Menu";
|
|
75
|
-
static componentId = 'Menu';
|
|
76
|
-
static propTypes = _props.propTypes;
|
|
77
|
-
static allowedProps = _props.allowedProps;
|
|
78
|
-
static defaultProps = {
|
|
79
|
-
label: null,
|
|
80
|
-
disabled: false,
|
|
81
|
-
trigger: null,
|
|
82
|
-
placement: 'bottom center',
|
|
83
|
-
defaultShow: false,
|
|
84
|
-
mountNode: null,
|
|
85
|
-
constrain: 'window',
|
|
86
|
-
shouldHideOnSelect: true,
|
|
87
|
-
shouldFocusTriggerOnClose: true,
|
|
88
|
-
withArrow: true,
|
|
89
|
-
offsetX: 0,
|
|
90
|
-
offsetY: 0
|
|
91
|
-
};
|
|
92
|
-
static Item = _MenuItem.MenuItem;
|
|
93
|
-
static Group = _MenuItemGroup.MenuItemGroup;
|
|
94
|
-
static Separator = _MenuItemSeparator.MenuItemSeparator;
|
|
95
|
-
state = {
|
|
96
|
-
hasFocus: false
|
|
97
|
-
};
|
|
98
|
-
_rootNode = null;
|
|
99
|
-
_menuItems = [];
|
|
100
|
-
_popover = null;
|
|
101
|
-
_trigger = null;
|
|
102
|
-
_menu = null;
|
|
103
|
-
_labelId = this.props.deterministicId('Menu__label');
|
|
104
|
-
_activeSubMenu;
|
|
105
|
-
_id;
|
|
106
|
-
ref = null;
|
|
107
|
-
handleRef = el => {
|
|
108
|
-
const menuRef = this.props.menuRef;
|
|
109
|
-
this._menu = el;
|
|
110
|
-
|
|
111
|
-
if (typeof menuRef === 'function') {
|
|
112
|
-
menuRef(el);
|
|
113
|
-
} // If there is no trigger `<ul>` is the ref, otherwise the trigger
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (!this.props.trigger) {
|
|
117
|
-
this.ref = el;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
73
|
+
let Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Menu extends _react.Component {
|
|
121
74
|
constructor(props) {
|
|
122
75
|
super(props);
|
|
76
|
+
this.state = {
|
|
77
|
+
hasFocus: false
|
|
78
|
+
};
|
|
79
|
+
this._rootNode = null;
|
|
80
|
+
this._menuItems = [];
|
|
81
|
+
this._popover = null;
|
|
82
|
+
this._trigger = null;
|
|
83
|
+
this._menu = null;
|
|
84
|
+
this._labelId = this.props.deterministicId('Menu__label');
|
|
85
|
+
this._activeSubMenu = void 0;
|
|
86
|
+
this._id = void 0;
|
|
87
|
+
this.ref = null;
|
|
88
|
+
|
|
89
|
+
this.handleRef = el => {
|
|
90
|
+
const menuRef = this.props.menuRef;
|
|
91
|
+
this._menu = el;
|
|
92
|
+
|
|
93
|
+
if (typeof menuRef === 'function') {
|
|
94
|
+
menuRef(el);
|
|
95
|
+
} // If there is no trigger `<ul>` is the ref, otherwise the trigger
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if (!this.props.trigger) {
|
|
99
|
+
this.ref = el;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.registerMenuItem = item => {
|
|
104
|
+
this._menuItems.push(item);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
this.removeMenuItem = item => {
|
|
108
|
+
const index = this.getMenuItemIndex(item);
|
|
109
|
+
(0, _console.logError)(index >= 0, '[Menu] Could not find registered menu item.');
|
|
110
|
+
|
|
111
|
+
if (index >= 0) {
|
|
112
|
+
this._menuItems.splice(index, 1);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
this.getMenuItemIndex = item => {
|
|
117
|
+
return this._menuItems.findIndex(i => i === item);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
this.handleTriggerKeyDown = event => {
|
|
121
|
+
if (this.props.type === 'flyout' && event.keyCode === _keycode.default.codes.right) {
|
|
122
|
+
event.persist();
|
|
123
|
+
this.show(event);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
this.handleTriggerMouseOver = event => {
|
|
128
|
+
if (this.props.type === 'flyout') {
|
|
129
|
+
this.show(event);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
this.handleToggle = shown => {
|
|
134
|
+
if (typeof this.props.onToggle === 'function') {
|
|
135
|
+
this.props.onToggle(shown, this);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
this.handleMenuKeyDown = event => {
|
|
140
|
+
const key = event && event.keyCode;
|
|
141
|
+
const _keycode$codes = _keycode.default.codes,
|
|
142
|
+
down = _keycode$codes.down,
|
|
143
|
+
up = _keycode$codes.up,
|
|
144
|
+
tab = _keycode$codes.tab,
|
|
145
|
+
left = _keycode$codes.left;
|
|
146
|
+
const pgdn = _keycode.default.codes['page down'];
|
|
147
|
+
const pgup = _keycode.default.codes['page up'];
|
|
148
|
+
|
|
149
|
+
if (key === down || key === pgdn) {
|
|
150
|
+
event.preventDefault();
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
this.moveFocus(1);
|
|
153
|
+
this.hideActiveSubMenu(event);
|
|
154
|
+
} else if (key === up || key === pgup) {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
event.stopPropagation();
|
|
157
|
+
this.moveFocus(-1);
|
|
158
|
+
this.hideActiveSubMenu(event);
|
|
159
|
+
} else if (key === tab || key === left) {
|
|
160
|
+
event.persist();
|
|
161
|
+
this.hide(event);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (typeof this.props.onKeyDown === 'function') {
|
|
165
|
+
this.props.onKeyDown(event);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
this.handleMenuItemSelect = (event, value, selected, item) => {
|
|
170
|
+
if (this.props.shouldHideOnSelect) {
|
|
171
|
+
this.hide(event);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (typeof this.props.onSelect === 'function') {
|
|
175
|
+
this.props.onSelect(event, value, selected, item);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
this.handleMenuItemFocus = () => {
|
|
180
|
+
this.setState({
|
|
181
|
+
hasFocus: true
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
this.handleMenuItemBlur = () => {
|
|
186
|
+
this.setState({
|
|
187
|
+
hasFocus: this.focusedIndex >= 0
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
this.handleMenuItemMouseOver = (event, menuItem) => {
|
|
192
|
+
if (this._activeSubMenu && menuItem !== this._activeSubMenu._trigger) {
|
|
193
|
+
this.hideActiveSubMenu(event);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
this.hideActiveSubMenu = event => {
|
|
198
|
+
if (this._activeSubMenu) {
|
|
199
|
+
this._activeSubMenu.hide(event);
|
|
200
|
+
|
|
201
|
+
this._activeSubMenu = null;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
this.handleSubMenuToggle = (shown, subMenu) => {
|
|
206
|
+
if (shown) {
|
|
207
|
+
this._activeSubMenu = subMenu;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
this.handleSubMenuDismiss = (event, documentClick) => {
|
|
212
|
+
if (event && event.keyCode === _keycode.default.codes.tab || documentClick) {
|
|
213
|
+
this.hide(event);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
this.hide = event => {
|
|
218
|
+
if (this._popover) {
|
|
219
|
+
this._popover.hide(event);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
this.show = event => {
|
|
224
|
+
if (this._popover) {
|
|
225
|
+
this._popover.show(event);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
123
229
|
this._id = this.props.id || props.deterministicId();
|
|
124
230
|
}
|
|
125
231
|
|
|
@@ -135,123 +241,10 @@ let Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
135
241
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
136
242
|
}
|
|
137
243
|
|
|
138
|
-
static contextType = _MenuContext.MenuContext;
|
|
139
|
-
registerMenuItem = item => {
|
|
140
|
-
this._menuItems.push(item);
|
|
141
|
-
};
|
|
142
|
-
removeMenuItem = item => {
|
|
143
|
-
const index = this.getMenuItemIndex(item);
|
|
144
|
-
(0, _console.logError)(index >= 0, '[Menu] Could not find registered menu item.');
|
|
145
|
-
|
|
146
|
-
if (index >= 0) {
|
|
147
|
-
this._menuItems.splice(index, 1);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
244
|
get menuItems() {
|
|
152
245
|
return this._menuItems;
|
|
153
246
|
}
|
|
154
247
|
|
|
155
|
-
getMenuItemIndex = item => {
|
|
156
|
-
return this._menuItems.findIndex(i => i === item);
|
|
157
|
-
};
|
|
158
|
-
handleTriggerKeyDown = event => {
|
|
159
|
-
if (this.props.type === 'flyout' && event.keyCode === _keycode.default.codes.right) {
|
|
160
|
-
event.persist();
|
|
161
|
-
this.show(event);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
handleTriggerMouseOver = event => {
|
|
165
|
-
if (this.props.type === 'flyout') {
|
|
166
|
-
this.show(event);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
handleToggle = shown => {
|
|
170
|
-
if (typeof this.props.onToggle === 'function') {
|
|
171
|
-
this.props.onToggle(shown, this);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
handleMenuKeyDown = event => {
|
|
175
|
-
const key = event && event.keyCode;
|
|
176
|
-
const _keycode$codes = _keycode.default.codes,
|
|
177
|
-
down = _keycode$codes.down,
|
|
178
|
-
up = _keycode$codes.up,
|
|
179
|
-
tab = _keycode$codes.tab,
|
|
180
|
-
left = _keycode$codes.left;
|
|
181
|
-
const pgdn = _keycode.default.codes['page down'];
|
|
182
|
-
const pgup = _keycode.default.codes['page up'];
|
|
183
|
-
|
|
184
|
-
if (key === down || key === pgdn) {
|
|
185
|
-
event.preventDefault();
|
|
186
|
-
event.stopPropagation();
|
|
187
|
-
this.moveFocus(1);
|
|
188
|
-
this.hideActiveSubMenu(event);
|
|
189
|
-
} else if (key === up || key === pgup) {
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
event.stopPropagation();
|
|
192
|
-
this.moveFocus(-1);
|
|
193
|
-
this.hideActiveSubMenu(event);
|
|
194
|
-
} else if (key === tab || key === left) {
|
|
195
|
-
event.persist();
|
|
196
|
-
this.hide(event);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (typeof this.props.onKeyDown === 'function') {
|
|
200
|
-
this.props.onKeyDown(event);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
handleMenuItemSelect = (event, value, selected, item) => {
|
|
204
|
-
if (this.props.shouldHideOnSelect) {
|
|
205
|
-
this.hide(event);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (typeof this.props.onSelect === 'function') {
|
|
209
|
-
this.props.onSelect(event, value, selected, item);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
handleMenuItemFocus = () => {
|
|
213
|
-
this.setState({
|
|
214
|
-
hasFocus: true
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
handleMenuItemBlur = () => {
|
|
218
|
-
this.setState({
|
|
219
|
-
hasFocus: this.focusedIndex >= 0
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
handleMenuItemMouseOver = (event, menuItem) => {
|
|
223
|
-
if (this._activeSubMenu && menuItem !== this._activeSubMenu._trigger) {
|
|
224
|
-
this.hideActiveSubMenu(event);
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
hideActiveSubMenu = event => {
|
|
228
|
-
if (this._activeSubMenu) {
|
|
229
|
-
this._activeSubMenu.hide(event);
|
|
230
|
-
|
|
231
|
-
this._activeSubMenu = null;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
handleSubMenuToggle = (shown, subMenu) => {
|
|
235
|
-
if (shown) {
|
|
236
|
-
this._activeSubMenu = subMenu;
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
handleSubMenuDismiss = (event, documentClick) => {
|
|
240
|
-
if (event && event.keyCode === _keycode.default.codes.tab || documentClick) {
|
|
241
|
-
this.hide(event);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
hide = event => {
|
|
245
|
-
if (this._popover) {
|
|
246
|
-
this._popover.hide(event);
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
show = event => {
|
|
250
|
-
if (this._popover) {
|
|
251
|
-
this._popover.show(event);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
248
|
focus() {
|
|
256
249
|
if (this.shown) {
|
|
257
250
|
var _this$_menu;
|
|
@@ -472,7 +465,20 @@ let Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0,
|
|
|
472
465
|
}, this.renderMenu()) : this.renderMenu();
|
|
473
466
|
}
|
|
474
467
|
|
|
475
|
-
}
|
|
468
|
+
}, _class2.displayName = "Menu", _class2.componentId = 'Menu', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
469
|
+
label: null,
|
|
470
|
+
disabled: false,
|
|
471
|
+
trigger: null,
|
|
472
|
+
placement: 'bottom center',
|
|
473
|
+
defaultShow: false,
|
|
474
|
+
mountNode: null,
|
|
475
|
+
constrain: 'window',
|
|
476
|
+
shouldHideOnSelect: true,
|
|
477
|
+
shouldFocusTriggerOnClose: true,
|
|
478
|
+
withArrow: true,
|
|
479
|
+
offsetX: 0,
|
|
480
|
+
offsetY: 0
|
|
481
|
+
}, _class2.Item = _MenuItem.MenuItem, _class2.Group = _MenuItemGroup.MenuItemGroup, _class2.Separator = _MenuItemSeparator.MenuItemSeparator, _class2.contextType = _MenuContext.MenuContext, _class2)) || _class) || _class) || _class);
|
|
476
482
|
exports.Menu = Menu;
|
|
477
483
|
var _default = Menu;
|
|
478
484
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-menu",
|
|
3
|
-
"version": "8.25.1-snapshot-
|
|
3
|
+
"version": "8.25.1-snapshot-13",
|
|
4
4
|
"description": "A dropdown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.25.1-snapshot-
|
|
27
|
-
"@instructure/ui-color-utils": "8.25.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-locator": "8.25.1-snapshot-
|
|
29
|
-
"@instructure/ui-test-queries": "8.25.1-snapshot-
|
|
30
|
-
"@instructure/ui-test-utils": "8.25.1-snapshot-
|
|
31
|
-
"@instructure/ui-themes": "8.25.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "8.25.1-snapshot-13",
|
|
27
|
+
"@instructure/ui-color-utils": "8.25.1-snapshot-13",
|
|
28
|
+
"@instructure/ui-test-locator": "8.25.1-snapshot-13",
|
|
29
|
+
"@instructure/ui-test-queries": "8.25.1-snapshot-13",
|
|
30
|
+
"@instructure/ui-test-utils": "8.25.1-snapshot-13",
|
|
31
|
+
"@instructure/ui-themes": "8.25.1-snapshot-13"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.13.10",
|
|
35
|
-
"@instructure/console": "8.25.1-snapshot-
|
|
36
|
-
"@instructure/emotion": "8.25.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "8.25.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-utils": "8.25.1-snapshot-
|
|
39
|
-
"@instructure/ui-dom-utils": "8.25.1-snapshot-
|
|
40
|
-
"@instructure/ui-icons": "8.25.1-snapshot-
|
|
41
|
-
"@instructure/ui-popover": "8.25.1-snapshot-
|
|
42
|
-
"@instructure/ui-position": "8.25.1-snapshot-
|
|
43
|
-
"@instructure/ui-prop-types": "8.25.1-snapshot-
|
|
44
|
-
"@instructure/ui-react-utils": "8.25.1-snapshot-
|
|
45
|
-
"@instructure/ui-testable": "8.25.1-snapshot-
|
|
46
|
-
"@instructure/ui-utils": "8.25.1-snapshot-
|
|
35
|
+
"@instructure/console": "8.25.1-snapshot-13",
|
|
36
|
+
"@instructure/emotion": "8.25.1-snapshot-13",
|
|
37
|
+
"@instructure/shared-types": "8.25.1-snapshot-13",
|
|
38
|
+
"@instructure/ui-a11y-utils": "8.25.1-snapshot-13",
|
|
39
|
+
"@instructure/ui-dom-utils": "8.25.1-snapshot-13",
|
|
40
|
+
"@instructure/ui-icons": "8.25.1-snapshot-13",
|
|
41
|
+
"@instructure/ui-popover": "8.25.1-snapshot-13",
|
|
42
|
+
"@instructure/ui-position": "8.25.1-snapshot-13",
|
|
43
|
+
"@instructure/ui-prop-types": "8.25.1-snapshot-13",
|
|
44
|
+
"@instructure/ui-react-utils": "8.25.1-snapshot-13",
|
|
45
|
+
"@instructure/ui-testable": "8.25.1-snapshot-13",
|
|
46
|
+
"@instructure/ui-utils": "8.25.1-snapshot-13",
|
|
47
47
|
"keycode": "^2",
|
|
48
48
|
"prop-types": "^15"
|
|
49
49
|
},
|