@instructure/ui-menu 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/Menu/v1/MenuItem/index.js +99 -95
- package/es/Menu/v1/MenuItem/styles.js +4 -2
- package/es/Menu/v1/MenuItem/theme.js +20 -19
- package/es/Menu/v1/MenuItemGroup/index.js +71 -64
- package/es/Menu/v1/MenuItemGroup/theme.js +12 -11
- package/es/Menu/v1/MenuItemSeparator/index.js +13 -16
- package/es/Menu/v1/MenuItemSeparator/theme.js +8 -7
- package/es/Menu/v1/index.js +189 -183
- package/es/Menu/v1/theme.js +13 -12
- package/es/Menu/v2/MenuItem/index.js +128 -122
- package/es/Menu/v2/MenuItem/styles.js +5 -3
- package/es/Menu/v2/MenuItemGroup/index.js +71 -64
- package/es/Menu/v2/MenuItemSeparator/index.js +13 -16
- package/es/Menu/v2/index.js +189 -183
- package/lib/Menu/v1/MenuItem/index.js +100 -96
- package/lib/Menu/v1/MenuItem/styles.js +4 -2
- package/lib/Menu/v1/MenuItem/theme.js +20 -19
- package/lib/Menu/v1/MenuItemGroup/index.js +71 -64
- package/lib/Menu/v1/MenuItemGroup/theme.js +12 -11
- package/lib/Menu/v1/MenuItemSeparator/index.js +13 -16
- package/lib/Menu/v1/MenuItemSeparator/theme.js +8 -7
- package/lib/Menu/v1/index.js +189 -183
- package/lib/Menu/v1/theme.js +13 -12
- package/lib/Menu/v2/MenuItem/index.js +128 -122
- package/lib/Menu/v2/MenuItem/styles.js +5 -3
- package/lib/Menu/v2/MenuItemGroup/index.js +71 -64
- package/lib/Menu/v2/MenuItemSeparator/index.js +13 -16
- package/lib/Menu/v2/index.js +189 -183
- package/package.json +17 -17
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -40,98 +40,17 @@ parent: Menu
|
|
|
40
40
|
id: Menu.Item
|
|
41
41
|
---
|
|
42
42
|
**/
|
|
43
|
-
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class =
|
|
43
|
+
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = class MenuItem extends Component {
|
|
44
|
+
static displayName = "MenuItem";
|
|
45
|
+
static componentId = 'Menu.Item';
|
|
46
|
+
static allowedProps = allowedProps;
|
|
47
|
+
static defaultProps = {
|
|
48
|
+
type: 'button',
|
|
49
|
+
disabled: false
|
|
50
|
+
};
|
|
51
|
+
static contextType = MenuContext;
|
|
44
52
|
constructor(props) {
|
|
45
53
|
super(props);
|
|
46
|
-
this.labelId = void 0;
|
|
47
|
-
this.ref = null;
|
|
48
|
-
this.handleRef = el => {
|
|
49
|
-
this.ref = el;
|
|
50
|
-
};
|
|
51
|
-
this.handleClick = e => {
|
|
52
|
-
const _this$props = this.props,
|
|
53
|
-
onSelect = _this$props.onSelect,
|
|
54
|
-
onClick = _this$props.onClick,
|
|
55
|
-
disabled = _this$props.disabled,
|
|
56
|
-
value = _this$props.value;
|
|
57
|
-
const selected = !this.selected;
|
|
58
|
-
if (disabled) {
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (typeof this.props.selected === 'undefined') {
|
|
63
|
-
this.setState({
|
|
64
|
-
selected
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (typeof onSelect === 'function') {
|
|
68
|
-
e.persist();
|
|
69
|
-
onSelect(e, value, selected, this);
|
|
70
|
-
}
|
|
71
|
-
if (typeof onClick === 'function') {
|
|
72
|
-
onClick(e);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
this.handleKeyDown = e => {
|
|
76
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
77
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
78
|
-
if (spaceKey || enterKey) {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
e.stopPropagation();
|
|
81
|
-
if (enterKey) {
|
|
82
|
-
// handle space key on keyUp for FF
|
|
83
|
-
const refNode = findDOMNode(this.ref);
|
|
84
|
-
refNode.click();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
this.handleKeyUp = e => {
|
|
89
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
90
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
91
|
-
if (spaceKey || enterKey) {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
if (spaceKey) {
|
|
95
|
-
const refNode = findDOMNode(this.ref);
|
|
96
|
-
refNode.click();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
this.handleMouseOver = event => {
|
|
101
|
-
if (!this.focused) {
|
|
102
|
-
this.focus();
|
|
103
|
-
}
|
|
104
|
-
if (typeof this.props.onMouseOver === 'function') {
|
|
105
|
-
this.props.onMouseOver(event, this);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
this.handleMouseEnter = () => {
|
|
109
|
-
this.setState({
|
|
110
|
-
isHovered: true
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
this.handleMouseLeave = () => {
|
|
114
|
-
this.setState({
|
|
115
|
-
isHovered: false
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
this.handleFocusEvent = () => {
|
|
119
|
-
this.setState({
|
|
120
|
-
isFocused: true
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
this.handleBlurEvent = () => {
|
|
124
|
-
this.setState({
|
|
125
|
-
isFocused: false
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
this.getIconColor = () => {
|
|
129
|
-
const type = this.props.type;
|
|
130
|
-
if (type === 'flyout') {
|
|
131
|
-
return 'baseColor';
|
|
132
|
-
}
|
|
133
|
-
return this.selected ? 'inverseColor' : 'baseColor';
|
|
134
|
-
};
|
|
135
54
|
const state = {
|
|
136
55
|
isHovered: false,
|
|
137
56
|
isFocused: false
|
|
@@ -145,17 +64,20 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle),
|
|
|
145
64
|
get _node() {
|
|
146
65
|
return this.ref;
|
|
147
66
|
}
|
|
67
|
+
labelId;
|
|
68
|
+
ref = null;
|
|
69
|
+
handleRef = el => {
|
|
70
|
+
this.ref = el;
|
|
71
|
+
};
|
|
148
72
|
componentDidMount() {
|
|
149
|
-
|
|
150
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
73
|
+
this.props.makeStyles?.();
|
|
151
74
|
const context = this.context;
|
|
152
75
|
if (context && context.registerMenuItem) {
|
|
153
76
|
context.registerMenuItem(this);
|
|
154
77
|
}
|
|
155
78
|
}
|
|
156
79
|
componentDidUpdate() {
|
|
157
|
-
|
|
158
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
80
|
+
this.props.makeStyles?.();
|
|
159
81
|
}
|
|
160
82
|
componentWillUnmount() {
|
|
161
83
|
const context = this.context;
|
|
@@ -163,6 +85,93 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle),
|
|
|
163
85
|
context.removeMenuItem(this);
|
|
164
86
|
}
|
|
165
87
|
}
|
|
88
|
+
handleClick = e => {
|
|
89
|
+
const {
|
|
90
|
+
onSelect,
|
|
91
|
+
onClick,
|
|
92
|
+
disabled,
|
|
93
|
+
value
|
|
94
|
+
} = this.props;
|
|
95
|
+
const selected = !this.selected;
|
|
96
|
+
if (disabled) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (typeof this.props.selected === 'undefined') {
|
|
101
|
+
this.setState({
|
|
102
|
+
selected
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
if (typeof onSelect === 'function') {
|
|
106
|
+
e.persist();
|
|
107
|
+
onSelect(e, value, selected, this);
|
|
108
|
+
}
|
|
109
|
+
if (typeof onClick === 'function') {
|
|
110
|
+
onClick(e);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
handleKeyDown = e => {
|
|
114
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
115
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
116
|
+
if (spaceKey || enterKey) {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
e.stopPropagation();
|
|
119
|
+
if (enterKey) {
|
|
120
|
+
// handle space key on keyUp for FF
|
|
121
|
+
const refNode = findDOMNode(this.ref);
|
|
122
|
+
refNode.click();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
handleKeyUp = e => {
|
|
127
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
128
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
129
|
+
if (spaceKey || enterKey) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
if (spaceKey) {
|
|
133
|
+
const refNode = findDOMNode(this.ref);
|
|
134
|
+
refNode.click();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
handleMouseOver = event => {
|
|
139
|
+
if (!this.focused) {
|
|
140
|
+
this.focus();
|
|
141
|
+
}
|
|
142
|
+
if (typeof this.props.onMouseOver === 'function') {
|
|
143
|
+
this.props.onMouseOver(event, this);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
handleMouseEnter = () => {
|
|
147
|
+
this.setState({
|
|
148
|
+
isHovered: true
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
handleMouseLeave = () => {
|
|
152
|
+
this.setState({
|
|
153
|
+
isHovered: false
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
handleFocusEvent = () => {
|
|
157
|
+
this.setState({
|
|
158
|
+
isFocused: true
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
handleBlurEvent = () => {
|
|
162
|
+
this.setState({
|
|
163
|
+
isFocused: false
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
getIconColor = () => {
|
|
167
|
+
const {
|
|
168
|
+
type
|
|
169
|
+
} = this.props;
|
|
170
|
+
if (type === 'flyout') {
|
|
171
|
+
return 'baseColor';
|
|
172
|
+
}
|
|
173
|
+
return this.selected ? 'inverseColor' : 'baseColor';
|
|
174
|
+
};
|
|
166
175
|
get elementType() {
|
|
167
176
|
return getElementType(MenuItem, this.props);
|
|
168
177
|
}
|
|
@@ -187,46 +196,46 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle),
|
|
|
187
196
|
refNode.focus();
|
|
188
197
|
}
|
|
189
198
|
renderContent() {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
199
|
+
const {
|
|
200
|
+
children,
|
|
201
|
+
type,
|
|
202
|
+
renderLabelInfo
|
|
203
|
+
} = this.props;
|
|
195
204
|
return _jsxs("span", {
|
|
196
205
|
children: [_jsx("span", {
|
|
197
|
-
css:
|
|
206
|
+
css: this.props.styles?.label,
|
|
198
207
|
id: this.labelId,
|
|
199
208
|
children: children
|
|
200
209
|
}), (type === 'checkbox' || type === 'radio') && _jsx("span", {
|
|
201
|
-
css:
|
|
210
|
+
css: this.props.styles?.icon,
|
|
202
211
|
children: this.selected && _jsx(CheckInstUIIcon, {
|
|
203
212
|
size: "md",
|
|
204
213
|
color: this.getIconColor()
|
|
205
214
|
})
|
|
206
215
|
}), type === 'flyout' && _jsx("span", {
|
|
207
|
-
css:
|
|
216
|
+
css: this.props.styles?.icon,
|
|
208
217
|
children: _jsx(ChevronRightInstUIIcon, {
|
|
209
218
|
size: "md",
|
|
210
219
|
color: this.getIconColor()
|
|
211
220
|
})
|
|
212
221
|
}), renderLabelInfo && _jsx("span", {
|
|
213
|
-
css:
|
|
222
|
+
css: this.props.styles?.labelInfo,
|
|
214
223
|
children: callRenderProp(renderLabelInfo)
|
|
215
224
|
})]
|
|
216
225
|
});
|
|
217
226
|
}
|
|
218
227
|
render() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const {
|
|
229
|
+
disabled,
|
|
230
|
+
controls,
|
|
231
|
+
onKeyDown,
|
|
232
|
+
onKeyUp,
|
|
233
|
+
onFocus,
|
|
234
|
+
onBlur,
|
|
235
|
+
type,
|
|
236
|
+
href,
|
|
237
|
+
target
|
|
238
|
+
} = this.props;
|
|
230
239
|
const props = omitProps(this.props, MenuItem.allowedProps);
|
|
231
240
|
const ElementType = this.elementType;
|
|
232
241
|
return _jsx(ElementType, {
|
|
@@ -237,14 +246,14 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle),
|
|
|
237
246
|
target: target,
|
|
238
247
|
role: this.role,
|
|
239
248
|
"aria-labelledby": this.labelId,
|
|
240
|
-
"aria-disabled": disabled ? 'true' :
|
|
249
|
+
"aria-disabled": disabled ? 'true' : undefined,
|
|
241
250
|
"aria-controls": controls,
|
|
242
|
-
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' :
|
|
251
|
+
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : undefined,
|
|
243
252
|
onClick: this.handleClick,
|
|
244
253
|
onKeyUp: createChainedFunction(onKeyUp, this.handleKeyUp),
|
|
245
254
|
onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
|
|
246
255
|
ref: this.handleRef,
|
|
247
|
-
css:
|
|
256
|
+
css: this.props.styles?.menuItem,
|
|
248
257
|
onMouseOver: this.handleMouseOver,
|
|
249
258
|
onMouseEnter: this.handleMouseEnter,
|
|
250
259
|
onMouseLeave: this.handleMouseLeave,
|
|
@@ -254,9 +263,6 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle),
|
|
|
254
263
|
children: this.renderContent()
|
|
255
264
|
});
|
|
256
265
|
}
|
|
257
|
-
}
|
|
258
|
-
type: 'button',
|
|
259
|
-
disabled: false
|
|
260
|
-
}, _MenuItem.contextType = MenuContext, _MenuItem)) || _class) || _class);
|
|
266
|
+
}) || _class) || _class);
|
|
261
267
|
export default MenuItem;
|
|
262
268
|
export { MenuItem };
|
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
* @return {Object} The final style object, which will be used in the component
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const {
|
|
37
|
+
type,
|
|
38
|
+
disabled,
|
|
39
|
+
selected
|
|
40
|
+
} = props;
|
|
39
41
|
const isRadioOrCheckbox = type === 'checkbox' || type === 'radio';
|
|
40
42
|
const flyoutIconStyles = type === 'flyout' ? {
|
|
41
43
|
insetInlineStart: 'auto',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,62 +37,74 @@ parent: Menu
|
|
|
37
37
|
id: Menu.Group
|
|
38
38
|
---
|
|
39
39
|
**/
|
|
40
|
-
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class =
|
|
40
|
+
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = class MenuItemGroup extends Component {
|
|
41
|
+
static displayName = "MenuItemGroup";
|
|
42
|
+
static componentId = 'Menu.Group';
|
|
43
|
+
static allowedProps = allowedProps;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
disabled: false,
|
|
46
|
+
children: null,
|
|
47
|
+
isTabbable: false,
|
|
48
|
+
allowMultiple: false,
|
|
49
|
+
defaultSelected: []
|
|
50
|
+
};
|
|
41
51
|
constructor(props) {
|
|
42
52
|
super(props);
|
|
43
|
-
this.ref = null;
|
|
44
|
-
this.handleRef = el => {
|
|
45
|
-
this.ref = el;
|
|
46
|
-
};
|
|
47
|
-
this.handleSelect = (e, value, selected, item) => {
|
|
48
|
-
if (this.props.disabled) {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (this.props.selected) {
|
|
53
|
-
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
54
|
-
} else {
|
|
55
|
-
this.setState(state => {
|
|
56
|
-
return {
|
|
57
|
-
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
this.updateSelected = (e, value, items, selected, item) => {
|
|
63
|
-
const allowMultiple = this.props.allowMultiple;
|
|
64
|
-
let updated = allowMultiple ? [...items] : [];
|
|
65
|
-
const location = updated.indexOf(value);
|
|
66
|
-
if (selected === true && location < 0) {
|
|
67
|
-
updated.push(value);
|
|
68
|
-
} else if (selected === false && location !== -1) {
|
|
69
|
-
updated.splice(location, 1);
|
|
70
|
-
} else if (!allowMultiple && updated.length < 1) {
|
|
71
|
-
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
72
|
-
updated = [...items];
|
|
73
|
-
}
|
|
74
|
-
if (typeof this.props.onSelect === 'function') {
|
|
75
|
-
this.props.onSelect(e, updated, selected, item);
|
|
76
|
-
}
|
|
77
|
-
return updated;
|
|
78
|
-
};
|
|
79
53
|
if (typeof props.selected === 'undefined') {
|
|
80
54
|
this.state = {
|
|
81
55
|
selected: this.selectedFromChildren(props) || props.defaultSelected
|
|
82
56
|
};
|
|
83
57
|
}
|
|
84
58
|
}
|
|
59
|
+
ref = null;
|
|
60
|
+
handleRef = el => {
|
|
61
|
+
this.ref = el;
|
|
62
|
+
};
|
|
85
63
|
componentDidMount() {
|
|
86
|
-
|
|
87
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
64
|
+
this.props.makeStyles?.();
|
|
88
65
|
}
|
|
89
66
|
componentDidUpdate() {
|
|
90
|
-
|
|
91
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
67
|
+
this.props.makeStyles?.();
|
|
92
68
|
}
|
|
69
|
+
handleSelect = (e, value, selected, item) => {
|
|
70
|
+
if (this.props.disabled) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (this.props.selected) {
|
|
75
|
+
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
76
|
+
} else {
|
|
77
|
+
this.setState(state => {
|
|
78
|
+
return {
|
|
79
|
+
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
updateSelected = (e, value, items, selected, item) => {
|
|
85
|
+
const {
|
|
86
|
+
allowMultiple
|
|
87
|
+
} = this.props;
|
|
88
|
+
let updated = allowMultiple ? [...items] : [];
|
|
89
|
+
const location = updated.indexOf(value);
|
|
90
|
+
if (selected === true && location < 0) {
|
|
91
|
+
updated.push(value);
|
|
92
|
+
} else if (selected === false && location !== -1) {
|
|
93
|
+
updated.splice(location, 1);
|
|
94
|
+
} else if (!allowMultiple && updated.length < 1) {
|
|
95
|
+
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
96
|
+
updated = [...items];
|
|
97
|
+
}
|
|
98
|
+
if (typeof this.props.onSelect === 'function') {
|
|
99
|
+
this.props.onSelect(e, updated, selected, item);
|
|
100
|
+
}
|
|
101
|
+
return updated;
|
|
102
|
+
};
|
|
93
103
|
selectedFromChildren(props) {
|
|
94
|
-
const
|
|
95
|
-
|
|
104
|
+
const {
|
|
105
|
+
children,
|
|
106
|
+
allowMultiple
|
|
107
|
+
} = props;
|
|
96
108
|
const selected = [];
|
|
97
109
|
const items = Children.toArray(children).filter(child => {
|
|
98
110
|
return matchComponentTypes(child, [MenuItem]);
|
|
@@ -112,20 +124,22 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
112
124
|
}
|
|
113
125
|
}
|
|
114
126
|
renderLabel() {
|
|
115
|
-
|
|
116
|
-
|
|
127
|
+
const {
|
|
128
|
+
label
|
|
129
|
+
} = this.props;
|
|
117
130
|
return hasVisibleChildren(label) ? _jsx("span", {
|
|
118
|
-
css:
|
|
131
|
+
css: this.props.styles?.label,
|
|
119
132
|
children: label
|
|
120
133
|
}) : label;
|
|
121
134
|
}
|
|
122
135
|
renderChildren() {
|
|
123
|
-
const
|
|
124
|
-
disabled
|
|
125
|
-
controls
|
|
126
|
-
allowMultiple
|
|
127
|
-
isTabbable
|
|
128
|
-
onMouseOver
|
|
136
|
+
const {
|
|
137
|
+
disabled,
|
|
138
|
+
controls,
|
|
139
|
+
allowMultiple,
|
|
140
|
+
isTabbable,
|
|
141
|
+
onMouseOver
|
|
142
|
+
} = this.props;
|
|
129
143
|
const children = this.props.children;
|
|
130
144
|
let index = -1;
|
|
131
145
|
return Children.map(children, child => {
|
|
@@ -150,26 +164,19 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
150
164
|
});
|
|
151
165
|
}
|
|
152
166
|
render() {
|
|
153
|
-
var _this$props$styles2, _this$props$styles3;
|
|
154
167
|
const props = omitProps(this.props, MenuItemGroup.allowedProps);
|
|
155
168
|
return _jsxs("span", {
|
|
156
169
|
...props,
|
|
157
|
-
css:
|
|
170
|
+
css: this.props.styles?.menuItemGroup,
|
|
158
171
|
ref: this.handleRef,
|
|
159
172
|
"data-cid": "MenuItemGroup",
|
|
160
173
|
children: [this.renderLabel(), _jsx("div", {
|
|
161
|
-
css:
|
|
162
|
-
"aria-disabled": this.props.disabled ? 'true' :
|
|
174
|
+
css: this.props.styles?.items,
|
|
175
|
+
"aria-disabled": this.props.disabled ? 'true' : undefined,
|
|
163
176
|
children: this.renderChildren()
|
|
164
177
|
})]
|
|
165
178
|
});
|
|
166
179
|
}
|
|
167
|
-
}
|
|
168
|
-
disabled: false,
|
|
169
|
-
children: null,
|
|
170
|
-
isTabbable: false,
|
|
171
|
-
allowMultiple: false,
|
|
172
|
-
defaultSelected: []
|
|
173
|
-
}, _MenuItemGroup)) || _class) || _class);
|
|
180
|
+
}) || _class) || _class);
|
|
174
181
|
export default MenuItemGroup;
|
|
175
182
|
export { MenuItemGroup };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -36,35 +36,32 @@ id: Menu.Separator
|
|
|
36
36
|
---
|
|
37
37
|
@module MenuItemSeparator
|
|
38
38
|
**/
|
|
39
|
-
let MenuItemSeparator = (_dec = withStyle(generateStyle), _dec(_class =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
39
|
+
let MenuItemSeparator = (_dec = withStyle(generateStyle), _dec(_class = class MenuItemSeparator extends Component {
|
|
40
|
+
static displayName = "MenuItemSeparator";
|
|
41
|
+
static componentId = 'Menu.Separator';
|
|
42
|
+
static allowedProps = allowedProps;
|
|
43
|
+
ref = null;
|
|
44
|
+
handleRef = el => {
|
|
45
|
+
this.ref = el;
|
|
46
|
+
};
|
|
47
47
|
componentDidMount() {
|
|
48
|
-
|
|
49
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
48
|
+
this.props.makeStyles?.();
|
|
50
49
|
}
|
|
51
50
|
componentDidUpdate() {
|
|
52
|
-
|
|
53
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
51
|
+
this.props.makeStyles?.();
|
|
54
52
|
}
|
|
55
53
|
render() {
|
|
56
|
-
var _this$props$styles;
|
|
57
54
|
const props = omitProps(this.props, MenuItemSeparator.allowedProps);
|
|
58
55
|
// role="separator" would fit better here, but it causes NVDA to stop the
|
|
59
56
|
// MenuItem count after it
|
|
60
57
|
return _jsx("div", {
|
|
61
58
|
...props,
|
|
62
59
|
role: "presentation",
|
|
63
|
-
css:
|
|
60
|
+
css: this.props.styles?.menuItemSeparator,
|
|
64
61
|
ref: this.handleRef,
|
|
65
62
|
"data-cid": "MenuItemSeparator"
|
|
66
63
|
});
|
|
67
64
|
}
|
|
68
|
-
}
|
|
65
|
+
}) || _class);
|
|
69
66
|
export default MenuItemSeparator;
|
|
70
67
|
export { MenuItemSeparator };
|