@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
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [11.7.3-snapshot-
|
|
6
|
+
## [11.7.3-snapshot-26](https://github.com/instructure/instructure-ui/compare/v11.7.2...v11.7.3-snapshot-26) (2026-05-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **many:** update dependencies, remove lots of Babel plugins, remove Webpack 4 support ([f916fca](https://github.com/instructure/instructure-ui/commit/f916fcafdddcb2d7de401f93e8ff92cfdfa47bba))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -41,71 +41,17 @@ parent: Menu
|
|
|
41
41
|
id: Menu.Item
|
|
42
42
|
---
|
|
43
43
|
**/
|
|
44
|
-
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class =
|
|
44
|
+
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class MenuItem extends Component {
|
|
45
|
+
static displayName = "MenuItem";
|
|
46
|
+
static componentId = 'Menu.Item';
|
|
47
|
+
static allowedProps = allowedProps;
|
|
48
|
+
static defaultProps = {
|
|
49
|
+
type: 'button',
|
|
50
|
+
disabled: false
|
|
51
|
+
};
|
|
52
|
+
static contextType = MenuContext;
|
|
45
53
|
constructor(props) {
|
|
46
54
|
super(props);
|
|
47
|
-
this.labelId = void 0;
|
|
48
|
-
this.ref = null;
|
|
49
|
-
this.handleRef = el => {
|
|
50
|
-
this.ref = el;
|
|
51
|
-
};
|
|
52
|
-
this.handleClick = e => {
|
|
53
|
-
const _this$props = this.props,
|
|
54
|
-
onSelect = _this$props.onSelect,
|
|
55
|
-
onClick = _this$props.onClick,
|
|
56
|
-
disabled = _this$props.disabled,
|
|
57
|
-
value = _this$props.value;
|
|
58
|
-
const selected = !this.selected;
|
|
59
|
-
if (disabled) {
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (typeof this.props.selected === 'undefined') {
|
|
64
|
-
this.setState({
|
|
65
|
-
selected
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (typeof onSelect === 'function') {
|
|
69
|
-
e.persist();
|
|
70
|
-
onSelect(e, value, selected, this);
|
|
71
|
-
}
|
|
72
|
-
if (typeof onClick === 'function') {
|
|
73
|
-
onClick(e);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
this.handleKeyDown = e => {
|
|
77
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
78
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
79
|
-
if (spaceKey || enterKey) {
|
|
80
|
-
e.preventDefault();
|
|
81
|
-
e.stopPropagation();
|
|
82
|
-
if (enterKey) {
|
|
83
|
-
// handle space key on keyUp for FF
|
|
84
|
-
const refNode = findDOMNode(this.ref);
|
|
85
|
-
refNode.click();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
this.handleKeyUp = e => {
|
|
90
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
91
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
92
|
-
if (spaceKey || enterKey) {
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
if (spaceKey) {
|
|
96
|
-
const refNode = findDOMNode(this.ref);
|
|
97
|
-
refNode.click();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
this.handleMouseOver = event => {
|
|
102
|
-
if (!this.focused) {
|
|
103
|
-
this.focus();
|
|
104
|
-
}
|
|
105
|
-
if (typeof this.props.onMouseOver === 'function') {
|
|
106
|
-
this.props.onMouseOver(event, this);
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
55
|
if (typeof props.selected === 'undefined') {
|
|
110
56
|
this.state = {
|
|
111
57
|
selected: !!props.defaultSelected
|
|
@@ -116,17 +62,20 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
116
62
|
get _node() {
|
|
117
63
|
return this.ref;
|
|
118
64
|
}
|
|
65
|
+
labelId;
|
|
66
|
+
ref = null;
|
|
67
|
+
handleRef = el => {
|
|
68
|
+
this.ref = el;
|
|
69
|
+
};
|
|
119
70
|
componentDidMount() {
|
|
120
|
-
|
|
121
|
-
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
71
|
+
this.props.makeStyles?.();
|
|
122
72
|
const context = this.context;
|
|
123
73
|
if (context && context.registerMenuItem) {
|
|
124
74
|
context.registerMenuItem(this);
|
|
125
75
|
}
|
|
126
76
|
}
|
|
127
77
|
componentDidUpdate() {
|
|
128
|
-
|
|
129
|
-
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
78
|
+
this.props.makeStyles?.();
|
|
130
79
|
}
|
|
131
80
|
componentWillUnmount() {
|
|
132
81
|
const context = this.context;
|
|
@@ -134,6 +83,64 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
134
83
|
context.removeMenuItem(this);
|
|
135
84
|
}
|
|
136
85
|
}
|
|
86
|
+
handleClick = e => {
|
|
87
|
+
const {
|
|
88
|
+
onSelect,
|
|
89
|
+
onClick,
|
|
90
|
+
disabled,
|
|
91
|
+
value
|
|
92
|
+
} = this.props;
|
|
93
|
+
const selected = !this.selected;
|
|
94
|
+
if (disabled) {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (typeof this.props.selected === 'undefined') {
|
|
99
|
+
this.setState({
|
|
100
|
+
selected
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (typeof onSelect === 'function') {
|
|
104
|
+
e.persist();
|
|
105
|
+
onSelect(e, value, selected, this);
|
|
106
|
+
}
|
|
107
|
+
if (typeof onClick === 'function') {
|
|
108
|
+
onClick(e);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
handleKeyDown = e => {
|
|
112
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
113
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
114
|
+
if (spaceKey || enterKey) {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
if (enterKey) {
|
|
118
|
+
// handle space key on keyUp for FF
|
|
119
|
+
const refNode = findDOMNode(this.ref);
|
|
120
|
+
refNode.click();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
handleKeyUp = e => {
|
|
125
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
126
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
127
|
+
if (spaceKey || enterKey) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
e.stopPropagation();
|
|
130
|
+
if (spaceKey) {
|
|
131
|
+
const refNode = findDOMNode(this.ref);
|
|
132
|
+
refNode.click();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
handleMouseOver = event => {
|
|
137
|
+
if (!this.focused) {
|
|
138
|
+
this.focus();
|
|
139
|
+
}
|
|
140
|
+
if (typeof this.props.onMouseOver === 'function') {
|
|
141
|
+
this.props.onMouseOver(event, this);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
137
144
|
get elementType() {
|
|
138
145
|
return getElementType(MenuItem, this.props);
|
|
139
146
|
}
|
|
@@ -158,38 +165,38 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
158
165
|
refNode.focus();
|
|
159
166
|
}
|
|
160
167
|
renderContent() {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
const {
|
|
169
|
+
children,
|
|
170
|
+
type,
|
|
171
|
+
renderLabelInfo
|
|
172
|
+
} = this.props;
|
|
166
173
|
return _jsxs("span", {
|
|
167
174
|
children: [(type === 'checkbox' || type === 'radio') && _jsx("span", {
|
|
168
|
-
css:
|
|
169
|
-
children: this.selected &&
|
|
175
|
+
css: this.props.styles?.icon,
|
|
176
|
+
children: this.selected && _jsx(IconCheckSolid, {})
|
|
170
177
|
}), _jsx("span", {
|
|
171
|
-
css:
|
|
178
|
+
css: this.props.styles?.label,
|
|
172
179
|
id: this.labelId,
|
|
173
180
|
children: children
|
|
174
181
|
}), type === 'flyout' && _jsx("span", {
|
|
175
|
-
css:
|
|
176
|
-
children:
|
|
182
|
+
css: this.props.styles?.icon,
|
|
183
|
+
children: _jsx(IconArrowOpenEndSolid, {})
|
|
177
184
|
}), renderLabelInfo && _jsx("span", {
|
|
178
|
-
css:
|
|
185
|
+
css: this.props.styles?.labelInfo,
|
|
179
186
|
children: callRenderProp(renderLabelInfo)
|
|
180
187
|
})]
|
|
181
188
|
});
|
|
182
189
|
}
|
|
183
190
|
render() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const {
|
|
192
|
+
disabled,
|
|
193
|
+
controls,
|
|
194
|
+
onKeyDown,
|
|
195
|
+
onKeyUp,
|
|
196
|
+
type,
|
|
197
|
+
href,
|
|
198
|
+
target
|
|
199
|
+
} = this.props;
|
|
193
200
|
const props = omitProps(this.props, MenuItem.allowedProps);
|
|
194
201
|
const ElementType = this.elementType;
|
|
195
202
|
return _jsx(ElementType, {
|
|
@@ -200,22 +207,19 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
200
207
|
target: target,
|
|
201
208
|
role: this.role,
|
|
202
209
|
"aria-labelledby": this.labelId,
|
|
203
|
-
"aria-disabled": disabled ? 'true' :
|
|
210
|
+
"aria-disabled": disabled ? 'true' : undefined,
|
|
204
211
|
"aria-controls": controls,
|
|
205
|
-
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' :
|
|
212
|
+
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : undefined,
|
|
206
213
|
onClick: this.handleClick,
|
|
207
214
|
onKeyUp: createChainedFunction(onKeyUp, this.handleKeyUp),
|
|
208
215
|
onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
|
|
209
216
|
ref: this.handleRef,
|
|
210
|
-
css:
|
|
217
|
+
css: this.props.styles?.menuItem,
|
|
211
218
|
onMouseOver: this.handleMouseOver,
|
|
212
219
|
"data-cid": "MenuItem",
|
|
213
220
|
children: this.renderContent()
|
|
214
221
|
});
|
|
215
222
|
}
|
|
216
|
-
}
|
|
217
|
-
type: 'button',
|
|
218
|
-
disabled: false
|
|
219
|
-
}, _MenuItem.contextType = MenuContext, _MenuItem)) || _class) || _class);
|
|
223
|
+
}) || _class) || _class);
|
|
220
224
|
export default MenuItem;
|
|
221
225
|
export { MenuItem };
|
|
@@ -33,8 +33,10 @@
|
|
|
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
|
-
|
|
36
|
+
const {
|
|
37
|
+
type,
|
|
38
|
+
disabled
|
|
39
|
+
} = props;
|
|
38
40
|
const isRadioOrCheckbox = type === 'checkbox' || type === 'radio';
|
|
39
41
|
const flyoutIconStyles = type === 'flyout' ? {
|
|
40
42
|
insetInlineStart: 'auto',
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
typography
|
|
34
|
-
spacing
|
|
35
|
-
themeName
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
typography,
|
|
34
|
+
spacing,
|
|
35
|
+
key: themeName
|
|
36
|
+
} = theme;
|
|
36
37
|
const themeSpecificStyle = {
|
|
37
38
|
canvas: {
|
|
38
39
|
labelColor: theme['ic-brand-font-color-dark'],
|
|
@@ -41,20 +42,20 @@ const generateComponentTheme = theme => {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
const componentVariables = {
|
|
44
|
-
padding: `${spacing
|
|
45
|
-
fontFamily: typography
|
|
46
|
-
fontWeight: typography
|
|
47
|
-
lineHeight: typography
|
|
48
|
-
fontSize: typography
|
|
49
|
-
labelPadding: spacing
|
|
50
|
-
labelColor: colors
|
|
51
|
-
background: colors
|
|
52
|
-
iconColor: colors
|
|
53
|
-
iconPadding: spacing
|
|
54
|
-
activeBackground: colors
|
|
55
|
-
activeLabelColor: colors
|
|
56
|
-
activeIconColor: colors
|
|
57
|
-
labelInfoColor: colors
|
|
45
|
+
padding: `${spacing?.xSmall} ${spacing?.small}`,
|
|
46
|
+
fontFamily: typography?.fontFamily,
|
|
47
|
+
fontWeight: typography?.fontWeightNormal,
|
|
48
|
+
lineHeight: typography?.lineHeightCondensed,
|
|
49
|
+
fontSize: typography?.fontSizeMedium,
|
|
50
|
+
labelPadding: spacing?.large,
|
|
51
|
+
labelColor: colors?.contrasts?.grey125125,
|
|
52
|
+
background: colors?.contrasts?.white1010,
|
|
53
|
+
iconColor: colors?.contrasts?.grey125125,
|
|
54
|
+
iconPadding: spacing?.small,
|
|
55
|
+
activeBackground: colors?.contrasts?.blue4570,
|
|
56
|
+
activeLabelColor: colors?.contrasts?.white1010,
|
|
57
|
+
activeIconColor: colors?.contrasts?.white1010,
|
|
58
|
+
labelInfoColor: colors?.contrasts?.grey5782
|
|
58
59
|
};
|
|
59
60
|
return {
|
|
60
61
|
...componentVariables,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class
|
|
1
|
+
var _dec, _dec2, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -38,62 +38,74 @@ parent: Menu
|
|
|
38
38
|
id: Menu.Group
|
|
39
39
|
---
|
|
40
40
|
**/
|
|
41
|
-
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class =
|
|
41
|
+
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = class MenuItemGroup extends Component {
|
|
42
|
+
static displayName = "MenuItemGroup";
|
|
43
|
+
static componentId = 'Menu.Group';
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
disabled: false,
|
|
47
|
+
children: null,
|
|
48
|
+
isTabbable: false,
|
|
49
|
+
allowMultiple: false,
|
|
50
|
+
defaultSelected: []
|
|
51
|
+
};
|
|
42
52
|
constructor(props) {
|
|
43
53
|
super(props);
|
|
44
|
-
this.ref = null;
|
|
45
|
-
this.handleRef = el => {
|
|
46
|
-
this.ref = el;
|
|
47
|
-
};
|
|
48
|
-
this.handleSelect = (e, value, selected, item) => {
|
|
49
|
-
if (this.props.disabled) {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (this.props.selected) {
|
|
54
|
-
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
55
|
-
} else {
|
|
56
|
-
this.setState(state => {
|
|
57
|
-
return {
|
|
58
|
-
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
this.updateSelected = (e, value, items, selected, item) => {
|
|
64
|
-
const allowMultiple = this.props.allowMultiple;
|
|
65
|
-
let updated = allowMultiple ? [...items] : [];
|
|
66
|
-
const location = updated.indexOf(value);
|
|
67
|
-
if (selected === true && location < 0) {
|
|
68
|
-
updated.push(value);
|
|
69
|
-
} else if (selected === false && location !== -1) {
|
|
70
|
-
updated.splice(location, 1);
|
|
71
|
-
} else if (!allowMultiple && updated.length < 1) {
|
|
72
|
-
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
73
|
-
updated = [...items];
|
|
74
|
-
}
|
|
75
|
-
if (typeof this.props.onSelect === 'function') {
|
|
76
|
-
this.props.onSelect(e, updated, selected, item);
|
|
77
|
-
}
|
|
78
|
-
return updated;
|
|
79
|
-
};
|
|
80
54
|
if (typeof props.selected === 'undefined') {
|
|
81
55
|
this.state = {
|
|
82
56
|
selected: this.selectedFromChildren(props) || props.defaultSelected
|
|
83
57
|
};
|
|
84
58
|
}
|
|
85
59
|
}
|
|
60
|
+
ref = null;
|
|
61
|
+
handleRef = el => {
|
|
62
|
+
this.ref = el;
|
|
63
|
+
};
|
|
86
64
|
componentDidMount() {
|
|
87
|
-
|
|
88
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
65
|
+
this.props.makeStyles?.();
|
|
89
66
|
}
|
|
90
67
|
componentDidUpdate() {
|
|
91
|
-
|
|
92
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
68
|
+
this.props.makeStyles?.();
|
|
93
69
|
}
|
|
70
|
+
handleSelect = (e, value, selected, item) => {
|
|
71
|
+
if (this.props.disabled) {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (this.props.selected) {
|
|
76
|
+
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
77
|
+
} else {
|
|
78
|
+
this.setState(state => {
|
|
79
|
+
return {
|
|
80
|
+
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
updateSelected = (e, value, items, selected, item) => {
|
|
86
|
+
const {
|
|
87
|
+
allowMultiple
|
|
88
|
+
} = this.props;
|
|
89
|
+
let updated = allowMultiple ? [...items] : [];
|
|
90
|
+
const location = updated.indexOf(value);
|
|
91
|
+
if (selected === true && location < 0) {
|
|
92
|
+
updated.push(value);
|
|
93
|
+
} else if (selected === false && location !== -1) {
|
|
94
|
+
updated.splice(location, 1);
|
|
95
|
+
} else if (!allowMultiple && updated.length < 1) {
|
|
96
|
+
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
97
|
+
updated = [...items];
|
|
98
|
+
}
|
|
99
|
+
if (typeof this.props.onSelect === 'function') {
|
|
100
|
+
this.props.onSelect(e, updated, selected, item);
|
|
101
|
+
}
|
|
102
|
+
return updated;
|
|
103
|
+
};
|
|
94
104
|
selectedFromChildren(props) {
|
|
95
|
-
const
|
|
96
|
-
|
|
105
|
+
const {
|
|
106
|
+
children,
|
|
107
|
+
allowMultiple
|
|
108
|
+
} = props;
|
|
97
109
|
const selected = [];
|
|
98
110
|
const items = Children.toArray(children).filter(child => {
|
|
99
111
|
return matchComponentTypes(child, [MenuItem]);
|
|
@@ -113,20 +125,22 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
113
125
|
}
|
|
114
126
|
}
|
|
115
127
|
renderLabel() {
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
const {
|
|
129
|
+
label
|
|
130
|
+
} = this.props;
|
|
118
131
|
return hasVisibleChildren(label) ? _jsx("span", {
|
|
119
|
-
css:
|
|
132
|
+
css: this.props.styles?.label,
|
|
120
133
|
children: label
|
|
121
134
|
}) : label;
|
|
122
135
|
}
|
|
123
136
|
renderChildren() {
|
|
124
|
-
const
|
|
125
|
-
disabled
|
|
126
|
-
controls
|
|
127
|
-
allowMultiple
|
|
128
|
-
isTabbable
|
|
129
|
-
onMouseOver
|
|
137
|
+
const {
|
|
138
|
+
disabled,
|
|
139
|
+
controls,
|
|
140
|
+
allowMultiple,
|
|
141
|
+
isTabbable,
|
|
142
|
+
onMouseOver
|
|
143
|
+
} = this.props;
|
|
130
144
|
const children = this.props.children;
|
|
131
145
|
let index = -1;
|
|
132
146
|
return Children.map(children, child => {
|
|
@@ -151,26 +165,19 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
render() {
|
|
154
|
-
var _this$props$styles2, _this$props$styles3;
|
|
155
168
|
const props = omitProps(this.props, MenuItemGroup.allowedProps);
|
|
156
169
|
return _jsxs("span", {
|
|
157
170
|
...props,
|
|
158
|
-
css:
|
|
171
|
+
css: this.props.styles?.menuItemGroup,
|
|
159
172
|
ref: this.handleRef,
|
|
160
173
|
"data-cid": "MenuItemGroup",
|
|
161
174
|
children: [this.renderLabel(), _jsx("div", {
|
|
162
|
-
css:
|
|
163
|
-
"aria-disabled": this.props.disabled ? 'true' :
|
|
175
|
+
css: this.props.styles?.items,
|
|
176
|
+
"aria-disabled": this.props.disabled ? 'true' : undefined,
|
|
164
177
|
children: this.renderChildren()
|
|
165
178
|
})]
|
|
166
179
|
});
|
|
167
180
|
}
|
|
168
|
-
}
|
|
169
|
-
disabled: false,
|
|
170
|
-
children: null,
|
|
171
|
-
isTabbable: false,
|
|
172
|
-
allowMultiple: false,
|
|
173
|
-
defaultSelected: []
|
|
174
|
-
}, _MenuItemGroup)) || _class) || _class);
|
|
181
|
+
}) || _class) || _class);
|
|
175
182
|
export default MenuItemGroup;
|
|
176
183
|
export { MenuItemGroup };
|
|
@@ -28,23 +28,24 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spacing
|
|
34
|
-
typography
|
|
35
|
-
themeName
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
spacing,
|
|
34
|
+
typography,
|
|
35
|
+
key: themeName
|
|
36
|
+
} = theme;
|
|
36
37
|
const themeSpecificStyle = {
|
|
37
38
|
canvas: {
|
|
38
39
|
color: theme['ic-brand-font-color-dark']
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
const componentVariables = {
|
|
42
|
-
fontSize: typography
|
|
43
|
-
fontFamily: typography
|
|
44
|
-
fontWeight: typography
|
|
45
|
-
padding: `${spacing
|
|
46
|
-
color: colors
|
|
47
|
-
background: colors
|
|
43
|
+
fontSize: typography?.fontSizeMedium,
|
|
44
|
+
fontFamily: typography?.fontFamily,
|
|
45
|
+
fontWeight: typography?.fontWeightBold,
|
|
46
|
+
padding: `${spacing?.xSmall} ${spacing?.small}`,
|
|
47
|
+
color: colors?.contrasts?.grey125125,
|
|
48
|
+
background: colors?.contrasts?.white1010
|
|
48
49
|
};
|
|
49
50
|
return {
|
|
50
51
|
...componentVariables,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _class
|
|
1
|
+
var _dec, _class;
|
|
2
2
|
/*
|
|
3
3
|
* The MIT License (MIT)
|
|
4
4
|
*
|
|
@@ -37,35 +37,32 @@ id: Menu.Separator
|
|
|
37
37
|
---
|
|
38
38
|
@module MenuItemSeparator
|
|
39
39
|
**/
|
|
40
|
-
let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
40
|
+
let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class MenuItemSeparator extends Component {
|
|
41
|
+
static displayName = "MenuItemSeparator";
|
|
42
|
+
static componentId = 'Menu.Separator';
|
|
43
|
+
static allowedProps = allowedProps;
|
|
44
|
+
ref = null;
|
|
45
|
+
handleRef = el => {
|
|
46
|
+
this.ref = el;
|
|
47
|
+
};
|
|
48
48
|
componentDidMount() {
|
|
49
|
-
|
|
50
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
49
|
+
this.props.makeStyles?.();
|
|
51
50
|
}
|
|
52
51
|
componentDidUpdate() {
|
|
53
|
-
|
|
54
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
52
|
+
this.props.makeStyles?.();
|
|
55
53
|
}
|
|
56
54
|
render() {
|
|
57
|
-
var _this$props$styles;
|
|
58
55
|
const props = omitProps(this.props, MenuItemSeparator.allowedProps);
|
|
59
56
|
// role="separator" would fit better here, but it causes NVDA to stop the
|
|
60
57
|
// MenuItem count after it
|
|
61
58
|
return _jsx("div", {
|
|
62
59
|
...props,
|
|
63
60
|
role: "presentation",
|
|
64
|
-
css:
|
|
61
|
+
css: this.props.styles?.menuItemSeparator,
|
|
65
62
|
ref: this.handleRef,
|
|
66
63
|
"data-cid": "MenuItemSeparator"
|
|
67
64
|
});
|
|
68
65
|
}
|
|
69
|
-
}
|
|
66
|
+
}) || _class);
|
|
70
67
|
export default MenuItemSeparator;
|
|
71
68
|
export { MenuItemSeparator };
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
* @return {Object} The final theme object with the overrides and component variables
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
spacing
|
|
34
|
-
borders
|
|
31
|
+
const {
|
|
32
|
+
colors,
|
|
33
|
+
spacing,
|
|
34
|
+
borders
|
|
35
|
+
} = theme;
|
|
35
36
|
const componentVariables = {
|
|
36
|
-
background: colors
|
|
37
|
-
height: borders
|
|
38
|
-
margin: `0 ${spacing
|
|
37
|
+
background: colors?.contrasts?.grey3045,
|
|
38
|
+
height: borders?.widthSmall,
|
|
39
|
+
margin: `0 ${spacing?.small}`
|
|
39
40
|
};
|
|
40
41
|
return {
|
|
41
42
|
...componentVariables
|