@instructure/ui-menu 8.56.0 → 8.56.2-pr-snapshot-1721749364069
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 +16 -0
- package/lib/Menu/MenuItem/index.js +16 -20
- package/lib/Menu/MenuItem/props.js +2 -2
- package/lib/Menu/MenuItemGroup/index.js +9 -12
- package/lib/Menu/MenuItemGroup/props.js +3 -4
- package/lib/Menu/MenuItemSeparator/index.js +4 -4
- package/lib/Menu/__new-tests__/Menu.test.js +4 -4
- package/lib/Menu/index.js +17 -19
- package/lib/Menu/props.js +7 -8
- package/package.json +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.56.2-pr-snapshot-1721749364069](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2-pr-snapshot-1721749364069) (2024-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-menu
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [8.56.1](https://github.com/instructure/instructure-ui/compare/v8.56.0...v8.56.1) (2024-06-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-menu
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [8.56.0](https://github.com/instructure/instructure-ui/compare/v8.55.1...v8.56.0) (2024-05-06)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @instructure/ui-menu
|
|
@@ -8,15 +8,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = exports.MenuItem = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
17
|
-
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
18
|
-
var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
|
|
19
|
-
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
11
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
12
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
13
|
+
var _uiUtils = require("@instructure/ui-utils");
|
|
14
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
15
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
20
16
|
var _emotion = require("@instructure/emotion");
|
|
21
17
|
var _MenuContext = require("../../MenuContext");
|
|
22
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
@@ -53,7 +49,7 @@ parent: Menu
|
|
|
53
49
|
id: Menu.Item
|
|
54
50
|
---
|
|
55
51
|
**/
|
|
56
|
-
let MenuItem = exports.MenuItem = (_dec = (0,
|
|
52
|
+
let MenuItem = exports.MenuItem = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class MenuItem extends _react.Component {
|
|
57
53
|
constructor(props) {
|
|
58
54
|
super(props);
|
|
59
55
|
this.labelId = void 0;
|
|
@@ -93,7 +89,7 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
93
89
|
e.stopPropagation();
|
|
94
90
|
if (enterKey) {
|
|
95
91
|
// handle space key on keyUp for FF
|
|
96
|
-
const refNode = (0,
|
|
92
|
+
const refNode = (0, _uiDomUtils.findDOMNode)(this.ref);
|
|
97
93
|
refNode.click();
|
|
98
94
|
}
|
|
99
95
|
}
|
|
@@ -105,7 +101,7 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
105
101
|
e.preventDefault();
|
|
106
102
|
e.stopPropagation();
|
|
107
103
|
if (spaceKey) {
|
|
108
|
-
const refNode = (0,
|
|
104
|
+
const refNode = (0, _uiDomUtils.findDOMNode)(this.ref);
|
|
109
105
|
refNode.click();
|
|
110
106
|
}
|
|
111
107
|
}
|
|
@@ -145,7 +141,7 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
145
141
|
}
|
|
146
142
|
}
|
|
147
143
|
get elementType() {
|
|
148
|
-
return (0,
|
|
144
|
+
return (0, _uiReactUtils.getElementType)(MenuItem, this.props);
|
|
149
145
|
}
|
|
150
146
|
get role() {
|
|
151
147
|
switch (this.props.type) {
|
|
@@ -163,10 +159,10 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
163
159
|
return typeof this.props.selected === 'undefined' ? this.state.selected : this.props.selected;
|
|
164
160
|
}
|
|
165
161
|
get focused() {
|
|
166
|
-
return (0,
|
|
162
|
+
return (0, _uiDomUtils.isActiveElement)(this.ref);
|
|
167
163
|
}
|
|
168
164
|
focus() {
|
|
169
|
-
const refNode = (0,
|
|
165
|
+
const refNode = (0, _uiDomUtils.findDOMNode)(this.ref);
|
|
170
166
|
refNode.focus();
|
|
171
167
|
}
|
|
172
168
|
renderContent() {
|
|
@@ -176,12 +172,12 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
176
172
|
type = _this$props4.type;
|
|
177
173
|
return (0, _emotion.jsx)("span", null, (type === 'checkbox' || type === 'radio') && (0, _emotion.jsx)("span", {
|
|
178
174
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
179
|
-
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = (0, _emotion.jsx)(
|
|
175
|
+
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = (0, _emotion.jsx)(_uiIcons.IconCheckSolid, null)))), (0, _emotion.jsx)("span", {
|
|
180
176
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.label,
|
|
181
177
|
id: this.labelId
|
|
182
178
|
}, children), type === 'flyout' && (0, _emotion.jsx)("span", {
|
|
183
179
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
184
|
-
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(
|
|
180
|
+
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(_uiIcons.IconArrowOpenEndSolid, null))));
|
|
185
181
|
}
|
|
186
182
|
render() {
|
|
187
183
|
var _this$props$styles4;
|
|
@@ -192,7 +188,7 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
192
188
|
onKeyUp = _this$props5.onKeyUp,
|
|
193
189
|
type = _this$props5.type,
|
|
194
190
|
href = _this$props5.href;
|
|
195
|
-
const props = (0,
|
|
191
|
+
const props = (0, _uiReactUtils.omitProps)(this.props, MenuItem.allowedProps);
|
|
196
192
|
const ElementType = this.elementType;
|
|
197
193
|
return (0, _emotion.jsx)(ElementType, Object.assign({
|
|
198
194
|
tabIndex: -1 // note: tabIndex can be overridden by Menu or MenuItemGroup components
|
|
@@ -204,8 +200,8 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
204
200
|
"aria-controls": controls,
|
|
205
201
|
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : void 0,
|
|
206
202
|
onClick: this.handleClick,
|
|
207
|
-
onKeyUp: (0,
|
|
208
|
-
onKeyDown: (0,
|
|
203
|
+
onKeyUp: (0, _uiUtils.createChainedFunction)(onKeyUp, this.handleKeyUp),
|
|
204
|
+
onKeyDown: (0, _uiUtils.createChainedFunction)(onKeyDown, this.handleKeyDown),
|
|
209
205
|
ref: this.handleRef,
|
|
210
206
|
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.menuItem,
|
|
211
207
|
onMouseOver: this.handleMouseOver
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
|
10
10
|
/*
|
|
11
11
|
* The MIT License (MIT)
|
|
12
12
|
*
|
|
@@ -34,7 +34,7 @@ var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
|
34
34
|
const propTypes = exports.propTypes = {
|
|
35
35
|
children: _propTypes.default.node.isRequired,
|
|
36
36
|
defaultSelected: _propTypes.default.bool,
|
|
37
|
-
selected: (0,
|
|
37
|
+
selected: (0, _uiPropTypes.controllable)(_propTypes.default.bool, 'onSelect', 'defaultSelected'),
|
|
38
38
|
onSelect: _propTypes.default.func,
|
|
39
39
|
onClick: _propTypes.default.func,
|
|
40
40
|
onKeyDown: _propTypes.default.func,
|
|
@@ -8,12 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = exports.MenuItemGroup = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _emotion = require("@instructure/emotion");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
15
|
-
var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
|
|
16
|
-
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
11
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
12
|
+
var _uiA11yUtils = require("@instructure/ui-a11y-utils");
|
|
13
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
17
14
|
var _MenuItem = require("../MenuItem");
|
|
18
15
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
16
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
@@ -49,7 +46,7 @@ parent: Menu
|
|
|
49
46
|
id: Menu.Group
|
|
50
47
|
---
|
|
51
48
|
**/
|
|
52
|
-
let MenuItemGroup = exports.MenuItemGroup = (_dec = (0,
|
|
49
|
+
let MenuItemGroup = exports.MenuItemGroup = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class MenuItemGroup extends _react.Component {
|
|
53
50
|
constructor(props) {
|
|
54
51
|
super(props);
|
|
55
52
|
this._labelId = void 0;
|
|
@@ -109,7 +106,7 @@ let MenuItemGroup = exports.MenuItemGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
109
106
|
allowMultiple = props.allowMultiple;
|
|
110
107
|
const selected = [];
|
|
111
108
|
const items = _react.Children.toArray(children).filter(child => {
|
|
112
|
-
return (0,
|
|
109
|
+
return (0, _uiReactUtils.matchComponentTypes)(child, [_MenuItem.MenuItem]);
|
|
113
110
|
});
|
|
114
111
|
items.forEach((item, index) => {
|
|
115
112
|
if ((selected.length === 0 || allowMultiple) && (item.props.selected || item.props.defaultSelected)) {
|
|
@@ -128,7 +125,7 @@ let MenuItemGroup = exports.MenuItemGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
128
125
|
renderLabel() {
|
|
129
126
|
var _this$props$styles;
|
|
130
127
|
const label = this.props.label;
|
|
131
|
-
return (0,
|
|
128
|
+
return (0, _uiA11yUtils.hasVisibleChildren)(label) ? (0, _emotion.jsx)("span", {
|
|
132
129
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.label
|
|
133
130
|
}, label) : label;
|
|
134
131
|
}
|
|
@@ -142,12 +139,12 @@ let MenuItemGroup = exports.MenuItemGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
142
139
|
const children = this.props.children;
|
|
143
140
|
let index = -1;
|
|
144
141
|
return _react.Children.map(children, child => {
|
|
145
|
-
if ((0,
|
|
142
|
+
if ((0, _uiReactUtils.matchComponentTypes)(child, [_MenuItem.MenuItem])) {
|
|
146
143
|
++index;
|
|
147
144
|
const value = child.props.value || index;
|
|
148
145
|
return (0, _emotion.jsx)("li", {
|
|
149
146
|
role: "none"
|
|
150
|
-
}, ' ', (0,
|
|
147
|
+
}, ' ', (0, _uiReactUtils.safeCloneElement)(child, {
|
|
151
148
|
tabIndex: isTabbable && index === 0 ? 0 : -1,
|
|
152
149
|
controls,
|
|
153
150
|
value,
|
|
@@ -166,7 +163,7 @@ let MenuItemGroup = exports.MenuItemGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
166
163
|
}
|
|
167
164
|
render() {
|
|
168
165
|
var _this$props$styles2, _this$props$styles3;
|
|
169
|
-
const props = (0,
|
|
166
|
+
const props = (0, _uiReactUtils.omitProps)(this.props, MenuItemGroup.allowedProps);
|
|
170
167
|
return (0, _emotion.jsx)("span", Object.assign({}, props, {
|
|
171
168
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.menuItemGroup,
|
|
172
169
|
role: "presentation",
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
10
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
|
11
10
|
var _MenuItem = require("../MenuItem");
|
|
12
11
|
var _MenuItemSeparator = require("../MenuItemSeparator");
|
|
13
12
|
/*
|
|
@@ -37,8 +36,8 @@ var _MenuItemSeparator = require("../MenuItemSeparator");
|
|
|
37
36
|
const propTypes = exports.propTypes = {
|
|
38
37
|
label: _propTypes.default.node.isRequired,
|
|
39
38
|
allowMultiple: _propTypes.default.bool,
|
|
40
|
-
children:
|
|
41
|
-
selected: (0,
|
|
39
|
+
children: _uiPropTypes.Children.oneOf([_MenuItem.MenuItem, _MenuItemSeparator.MenuItemSeparator]),
|
|
40
|
+
selected: (0, _uiPropTypes.controllable)(_propTypes.default.array, 'onSelect', 'defaultSelected'),
|
|
42
41
|
defaultSelected: _propTypes.default.array,
|
|
43
42
|
onSelect: _propTypes.default.func,
|
|
44
43
|
onMouseOver: _propTypes.default.func,
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = exports.MenuItemSeparator = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
11
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
12
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
14
14
|
var _props = require("./props");
|
|
@@ -44,7 +44,7 @@ id: Menu.Separator
|
|
|
44
44
|
---
|
|
45
45
|
@module MenuItemSeparator
|
|
46
46
|
**/
|
|
47
|
-
let MenuItemSeparator = exports.MenuItemSeparator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0,
|
|
47
|
+
let MenuItemSeparator = exports.MenuItemSeparator = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = (_class2 = class MenuItemSeparator extends _react.Component {
|
|
48
48
|
constructor(...args) {
|
|
49
49
|
super(...args);
|
|
50
50
|
this.ref = null;
|
|
@@ -62,7 +62,7 @@ let MenuItemSeparator = exports.MenuItemSeparator = (_dec = (0, _emotion.withSty
|
|
|
62
62
|
}
|
|
63
63
|
render() {
|
|
64
64
|
var _this$props$styles;
|
|
65
|
-
const props = (0,
|
|
65
|
+
const props = (0, _uiReactUtils.omitProps)(this.props, MenuItemSeparator.allowedProps);
|
|
66
66
|
return (0, _emotion.jsx)("div", Object.assign({}, props, {
|
|
67
67
|
role: "presentation",
|
|
68
68
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuItemSeparator,
|
|
@@ -5,7 +5,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
5
5
|
var _react2 = require("@testing-library/react");
|
|
6
6
|
var _userEvent = require("@testing-library/user-event");
|
|
7
7
|
require("@testing-library/jest-dom");
|
|
8
|
-
var
|
|
8
|
+
var _uiAxeCheck = require("@instructure/ui-axe-check");
|
|
9
9
|
var _index = require("../index");
|
|
10
10
|
var _Menu, _Menu2, _Menu3, _Menu4, _MenuItem, _MenuItem2, _MenuItem3, _Menu5, _button, _MenuItem4, _Menu6, _button2, _MenuItem5, _MenuItem6, _button3, _MenuItem7, _MenuItem8, _Menu7, _Menu8, _button4, _MenuItem9, _MenuItem10, _button5, _MenuItem11, _MenuItem12, _button6, _MenuItem13, _MenuItem14, _Menu9, _button7, _MenuItem15, _MenuItem16;
|
|
11
11
|
/*
|
|
@@ -47,7 +47,7 @@ describe('<Menu />', () => {
|
|
|
47
47
|
label: "Menu-label-text"
|
|
48
48
|
}, /*#__PURE__*/_react.default.createElement(_index.MenuItem, null, "Menu Item Text")))),
|
|
49
49
|
container = _render.container;
|
|
50
|
-
const axeCheck = await (0,
|
|
50
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
|
51
51
|
expect(axeCheck).toBe(true);
|
|
52
52
|
});
|
|
53
53
|
it('should meet standards when menu is closed', async () => {
|
|
@@ -57,7 +57,7 @@ describe('<Menu />', () => {
|
|
|
57
57
|
disabled: true
|
|
58
58
|
}, "Gradebook")))),
|
|
59
59
|
container = _render2.container;
|
|
60
|
-
const axeCheck = await (0,
|
|
60
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
|
61
61
|
expect(axeCheck).toBe(true);
|
|
62
62
|
});
|
|
63
63
|
it('should meet standards when menu is open', async () => {
|
|
@@ -68,7 +68,7 @@ describe('<Menu />', () => {
|
|
|
68
68
|
disabled: true
|
|
69
69
|
}, "Gradebook")))),
|
|
70
70
|
container = _render3.container;
|
|
71
|
-
const axeCheck = await (0,
|
|
71
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
|
72
72
|
expect(axeCheck).toBe(true);
|
|
73
73
|
});
|
|
74
74
|
it('should call onSelect when menu item is selected', async () => {
|
package/lib/Menu/index.js
CHANGED
|
@@ -27,13 +27,11 @@ Object.defineProperty(exports, "MenuItemSeparator", {
|
|
|
27
27
|
exports.default = void 0;
|
|
28
28
|
var _react = _interopRequireWildcard(require("react"));
|
|
29
29
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
33
|
-
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
30
|
+
var _uiPopover = require("@instructure/ui-popover");
|
|
31
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
34
32
|
var _console = require("@instructure/console");
|
|
35
|
-
var
|
|
36
|
-
var
|
|
33
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
34
|
+
var _uiTestable = require("@instructure/ui-testable");
|
|
37
35
|
var _MenuContext = require("../MenuContext");
|
|
38
36
|
var _MenuItem = require("./MenuItem");
|
|
39
37
|
var _MenuItemGroup = require("./MenuItemGroup");
|
|
@@ -72,7 +70,7 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
72
70
|
category: components
|
|
73
71
|
---
|
|
74
72
|
**/
|
|
75
|
-
let Menu = exports.Menu = (_dec = (0,
|
|
73
|
+
let Menu = exports.Menu = (_dec = (0, _uiReactUtils.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Menu extends _react.Component {
|
|
76
74
|
constructor(props) {
|
|
77
75
|
super(props);
|
|
78
76
|
this.state = {
|
|
@@ -229,9 +227,9 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
229
227
|
}
|
|
230
228
|
focused() {
|
|
231
229
|
if (this.shown) {
|
|
232
|
-
return (0,
|
|
230
|
+
return (0, _uiDomUtils.containsActiveElement)(this._menu) || this.state.hasFocus;
|
|
233
231
|
} else {
|
|
234
|
-
return (0,
|
|
232
|
+
return (0, _uiDomUtils.containsActiveElement)(this._trigger);
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
get focusedIndex() {
|
|
@@ -258,22 +256,22 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
258
256
|
disabled = _this$props3.disabled;
|
|
259
257
|
let count = 0;
|
|
260
258
|
return _react.Children.map(children, child => {
|
|
261
|
-
if (!(0,
|
|
259
|
+
if (!(0, _uiReactUtils.matchComponentTypes)(child, ['MenuItemSeparator', 'MenuItem', 'MenuItemGroup', 'Menu'])) {
|
|
262
260
|
return;
|
|
263
261
|
}
|
|
264
262
|
count += 1;
|
|
265
263
|
const isTabbable = !this.state.hasFocus && count === 1;
|
|
266
|
-
if ((0,
|
|
264
|
+
if ((0, _uiReactUtils.matchComponentTypes)(child, ['MenuItemSeparator'])) {
|
|
267
265
|
return (0, _emotion.jsx)("li", {
|
|
268
266
|
role: "none"
|
|
269
267
|
}, child);
|
|
270
268
|
}
|
|
271
269
|
const menuItemChild = child;
|
|
272
270
|
const controls = menuItemChild.props['aria-controls'] || menuItemChild.props.controls || this.props['aria-controls'] || this.props.controls;
|
|
273
|
-
if ((0,
|
|
271
|
+
if ((0, _uiReactUtils.matchComponentTypes)(child, ['MenuItem'])) {
|
|
274
272
|
return (0, _emotion.jsx)("li", {
|
|
275
273
|
role: "none"
|
|
276
|
-
}, (0,
|
|
274
|
+
}, (0, _uiReactUtils.safeCloneElement)(child, {
|
|
277
275
|
controls,
|
|
278
276
|
children: child.props.children,
|
|
279
277
|
disabled: disabled || child.props.disabled,
|
|
@@ -284,10 +282,10 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
284
282
|
tabIndex: isTabbable ? 0 : -1
|
|
285
283
|
}));
|
|
286
284
|
}
|
|
287
|
-
if ((0,
|
|
285
|
+
if ((0, _uiReactUtils.matchComponentTypes)(child, ['MenuItemGroup'])) {
|
|
288
286
|
return (0, _emotion.jsx)("li", {
|
|
289
287
|
role: "none"
|
|
290
|
-
}, (0,
|
|
288
|
+
}, (0, _uiReactUtils.safeCloneElement)(child, {
|
|
291
289
|
label: child.props.label,
|
|
292
290
|
controls,
|
|
293
291
|
disabled: disabled || child.props.disabled,
|
|
@@ -298,11 +296,11 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
298
296
|
isTabbable
|
|
299
297
|
}));
|
|
300
298
|
}
|
|
301
|
-
if ((0,
|
|
299
|
+
if ((0, _uiReactUtils.matchComponentTypes)(child, ['Menu'])) {
|
|
302
300
|
const submenuDisabled = disabled || child.props.disabled;
|
|
303
301
|
return (0, _emotion.jsx)("li", {
|
|
304
302
|
role: "none"
|
|
305
|
-
}, (0,
|
|
303
|
+
}, (0, _uiReactUtils.safeCloneElement)(child, {
|
|
306
304
|
type: 'flyout',
|
|
307
305
|
controls,
|
|
308
306
|
disabled: submenuDisabled,
|
|
@@ -369,7 +367,7 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
369
367
|
positionContainerDisplay = _this$props5.positionContainerDisplay,
|
|
370
368
|
offsetX = _this$props5.offsetX,
|
|
371
369
|
offsetY = _this$props5.offsetY;
|
|
372
|
-
return trigger ? (0, _emotion.jsx)(
|
|
370
|
+
return trigger ? (0, _emotion.jsx)(_uiPopover.Popover, {
|
|
373
371
|
isShowingContent: show,
|
|
374
372
|
defaultIsShowingContent: defaultShow,
|
|
375
373
|
onHideContent: (event, {
|
|
@@ -402,7 +400,7 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
402
400
|
popoverRef(el);
|
|
403
401
|
}
|
|
404
402
|
},
|
|
405
|
-
renderTrigger: (0,
|
|
403
|
+
renderTrigger: (0, _uiReactUtils.safeCloneElement)(trigger, {
|
|
406
404
|
ref: el => {
|
|
407
405
|
this._trigger = el;
|
|
408
406
|
},
|
package/lib/Menu/props.js
CHANGED
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
9
|
+
var _uiPosition = require("@instructure/ui-position");
|
|
10
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
|
12
11
|
/*
|
|
13
12
|
* The MIT License (MIT)
|
|
14
13
|
*
|
|
@@ -34,13 +33,13 @@ var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
|
34
33
|
*/
|
|
35
34
|
|
|
36
35
|
const propTypes = exports.propTypes = {
|
|
37
|
-
children:
|
|
36
|
+
children: _uiPropTypes.Children.oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu']),
|
|
38
37
|
label: _propTypes.default.string,
|
|
39
38
|
disabled: _propTypes.default.bool,
|
|
40
39
|
trigger: _propTypes.default.node,
|
|
41
|
-
placement:
|
|
40
|
+
placement: _uiPosition.PositionPropTypes.placement,
|
|
42
41
|
defaultShow: _propTypes.default.bool,
|
|
43
|
-
show: (0,
|
|
42
|
+
show: (0, _uiPropTypes.controllable)(_propTypes.default.bool, 'onToggle', 'defaultShow'),
|
|
44
43
|
onToggle: _propTypes.default.func,
|
|
45
44
|
onSelect: _propTypes.default.func,
|
|
46
45
|
onDismiss: _propTypes.default.func,
|
|
@@ -50,8 +49,8 @@ const propTypes = exports.propTypes = {
|
|
|
50
49
|
onKeyUp: _propTypes.default.func,
|
|
51
50
|
menuRef: _propTypes.default.func,
|
|
52
51
|
popoverRef: _propTypes.default.func,
|
|
53
|
-
mountNode:
|
|
54
|
-
constrain:
|
|
52
|
+
mountNode: _uiPosition.PositionPropTypes.mountNode,
|
|
53
|
+
constrain: _uiPosition.PositionPropTypes.constrain,
|
|
55
54
|
shouldHideOnSelect: _propTypes.default.bool,
|
|
56
55
|
shouldFocusTriggerOnClose: _propTypes.default.bool,
|
|
57
56
|
positionContainerDisplay: _propTypes.default.oneOf(['inline-block', 'block']),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-menu",
|
|
3
|
-
"version": "8.56.
|
|
3
|
+
"version": "8.56.2-pr-snapshot-1721749364069",
|
|
4
4
|
"description": "A dropdown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "8.56.
|
|
27
|
-
"@instructure/ui-babel-preset": "8.56.
|
|
28
|
-
"@instructure/ui-color-utils": "8.56.
|
|
29
|
-
"@instructure/ui-test-utils": "8.56.
|
|
30
|
-
"@instructure/ui-themes": "8.56.
|
|
26
|
+
"@instructure/ui-axe-check": "8.56.2-pr-snapshot-1721749364069",
|
|
27
|
+
"@instructure/ui-babel-preset": "8.56.2-pr-snapshot-1721749364069",
|
|
28
|
+
"@instructure/ui-color-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
29
|
+
"@instructure/ui-test-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
30
|
+
"@instructure/ui-themes": "8.56.2-pr-snapshot-1721749364069",
|
|
31
31
|
"@testing-library/jest-dom": "^6.1.4",
|
|
32
32
|
"@testing-library/react": "^14.0.0",
|
|
33
33
|
"@testing-library/user-event": "^14.5.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/runtime": "^7.23.2",
|
|
37
|
-
"@instructure/console": "8.56.
|
|
38
|
-
"@instructure/emotion": "8.56.
|
|
39
|
-
"@instructure/shared-types": "8.56.
|
|
40
|
-
"@instructure/ui-a11y-utils": "8.56.
|
|
41
|
-
"@instructure/ui-dom-utils": "8.56.
|
|
42
|
-
"@instructure/ui-icons": "8.56.
|
|
43
|
-
"@instructure/ui-popover": "8.56.
|
|
44
|
-
"@instructure/ui-position": "8.56.
|
|
45
|
-
"@instructure/ui-prop-types": "8.56.
|
|
46
|
-
"@instructure/ui-react-utils": "8.56.
|
|
47
|
-
"@instructure/ui-testable": "8.56.
|
|
48
|
-
"@instructure/ui-utils": "8.56.
|
|
37
|
+
"@instructure/console": "8.56.2-pr-snapshot-1721749364069",
|
|
38
|
+
"@instructure/emotion": "8.56.2-pr-snapshot-1721749364069",
|
|
39
|
+
"@instructure/shared-types": "8.56.2-pr-snapshot-1721749364069",
|
|
40
|
+
"@instructure/ui-a11y-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
41
|
+
"@instructure/ui-dom-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
42
|
+
"@instructure/ui-icons": "8.56.2-pr-snapshot-1721749364069",
|
|
43
|
+
"@instructure/ui-popover": "8.56.2-pr-snapshot-1721749364069",
|
|
44
|
+
"@instructure/ui-position": "8.56.2-pr-snapshot-1721749364069",
|
|
45
|
+
"@instructure/ui-prop-types": "8.56.2-pr-snapshot-1721749364069",
|
|
46
|
+
"@instructure/ui-react-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
47
|
+
"@instructure/ui-testable": "8.56.2-pr-snapshot-1721749364069",
|
|
48
|
+
"@instructure/ui-utils": "8.56.2-pr-snapshot-1721749364069",
|
|
49
49
|
"keycode": "^2.2.1",
|
|
50
50
|
"prop-types": "^15.8.1"
|
|
51
51
|
},
|