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