@instructure/ui-menu 8.25.1-snapshot-10 → 8.25.1-snapshot-13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/es/Menu/MenuItem/index.js +84 -88
- package/es/Menu/MenuItemGroup/index.js +53 -58
- package/es/Menu/MenuItemSeparator/index.js +11 -11
- package/es/Menu/index.js +169 -163
- package/lib/Menu/MenuItem/index.js +84 -88
- package/lib/Menu/MenuItemGroup/index.js +53 -58
- package/lib/Menu/MenuItemSeparator/index.js +11 -11
- package/lib/Menu/index.js +169 -163
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.25.1-snapshot-
|
|
6
|
+
## [8.25.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-13) (2022-06-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-menu
|
|
9
9
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _dec3, _class, _IconCheckSolid, _IconArrowOpenEndSoli;
|
|
1
|
+
var _dec, _dec2, _dec3, _class, _class2, _IconCheckSolid, _IconArrowOpenEndSoli;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -45,19 +45,83 @@ id: Menu.Item
|
|
|
45
45
|
---
|
|
46
46
|
@tsProps
|
|
47
47
|
**/
|
|
48
|
-
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = class MenuItem extends Component {
|
|
49
|
-
static displayName = "MenuItem";
|
|
50
|
-
static componentId = 'Menu.Item';
|
|
51
|
-
static propTypes = propTypes;
|
|
52
|
-
static allowedProps = allowedProps;
|
|
53
|
-
static defaultProps = {
|
|
54
|
-
type: 'button',
|
|
55
|
-
disabled: false
|
|
56
|
-
};
|
|
57
|
-
static contextType = MenuContext;
|
|
58
|
-
|
|
48
|
+
let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class MenuItem extends Component {
|
|
59
49
|
constructor(props) {
|
|
60
50
|
super(props);
|
|
51
|
+
this.labelId = void 0;
|
|
52
|
+
this.ref = null;
|
|
53
|
+
|
|
54
|
+
this.handleRef = el => {
|
|
55
|
+
this.ref = el;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.handleClick = e => {
|
|
59
|
+
const _this$props = this.props,
|
|
60
|
+
onSelect = _this$props.onSelect,
|
|
61
|
+
onClick = _this$props.onClick,
|
|
62
|
+
disabled = _this$props.disabled,
|
|
63
|
+
value = _this$props.value;
|
|
64
|
+
const selected = !this.selected;
|
|
65
|
+
|
|
66
|
+
if (disabled) {
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (typeof this.props.selected === 'undefined') {
|
|
72
|
+
this.setState({
|
|
73
|
+
selected
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (typeof onSelect === 'function') {
|
|
78
|
+
e.persist();
|
|
79
|
+
onSelect(e, value, selected, this);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (typeof onClick === 'function') {
|
|
83
|
+
onClick(e);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
this.handleKeyDown = e => {
|
|
88
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
89
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
90
|
+
|
|
91
|
+
if (spaceKey || enterKey) {
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
|
|
95
|
+
if (enterKey) {
|
|
96
|
+
// handle space key on keyUp for FF
|
|
97
|
+
const refNode = findDOMNode(this.ref);
|
|
98
|
+
refNode.click();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
this.handleKeyUp = e => {
|
|
104
|
+
const spaceKey = e.keyCode === keycode.codes.space;
|
|
105
|
+
const enterKey = e.keyCode === keycode.codes.enter;
|
|
106
|
+
|
|
107
|
+
if (spaceKey || enterKey) {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
e.stopPropagation();
|
|
110
|
+
|
|
111
|
+
if (spaceKey) {
|
|
112
|
+
const refNode = findDOMNode(this.ref);
|
|
113
|
+
refNode.click();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
this.handleMouseOver = event => {
|
|
119
|
+
this.focus();
|
|
120
|
+
|
|
121
|
+
if (typeof this.props.onMouseOver === 'function') {
|
|
122
|
+
this.props.onMouseOver(event, this);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
61
125
|
|
|
62
126
|
if (typeof props.selected === 'undefined') {
|
|
63
127
|
this.state = {
|
|
@@ -72,16 +136,10 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
72
136
|
return this.ref;
|
|
73
137
|
}
|
|
74
138
|
|
|
75
|
-
labelId;
|
|
76
|
-
ref = null;
|
|
77
|
-
handleRef = el => {
|
|
78
|
-
this.ref = el;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
139
|
componentDidMount() {
|
|
82
|
-
var _this$props$makeStyle, _this$
|
|
140
|
+
var _this$props$makeStyle, _this$props2;
|
|
83
141
|
|
|
84
|
-
(_this$props$makeStyle = (_this$
|
|
142
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
85
143
|
const context = this.context;
|
|
86
144
|
|
|
87
145
|
if (context && context.registerMenuItem) {
|
|
@@ -90,9 +148,9 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
90
148
|
}
|
|
91
149
|
|
|
92
150
|
componentDidUpdate() {
|
|
93
|
-
var _this$props$makeStyle2, _this$
|
|
151
|
+
var _this$props$makeStyle2, _this$props3;
|
|
94
152
|
|
|
95
|
-
(_this$props$makeStyle2 = (_this$
|
|
153
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
96
154
|
}
|
|
97
155
|
|
|
98
156
|
componentWillUnmount() {
|
|
@@ -103,71 +161,6 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
103
161
|
}
|
|
104
162
|
}
|
|
105
163
|
|
|
106
|
-
handleClick = e => {
|
|
107
|
-
const _this$props3 = this.props,
|
|
108
|
-
onSelect = _this$props3.onSelect,
|
|
109
|
-
onClick = _this$props3.onClick,
|
|
110
|
-
disabled = _this$props3.disabled,
|
|
111
|
-
value = _this$props3.value;
|
|
112
|
-
const selected = !this.selected;
|
|
113
|
-
|
|
114
|
-
if (disabled) {
|
|
115
|
-
e.preventDefault();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (typeof this.props.selected === 'undefined') {
|
|
120
|
-
this.setState({
|
|
121
|
-
selected
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (typeof onSelect === 'function') {
|
|
126
|
-
e.persist();
|
|
127
|
-
onSelect(e, value, selected, this);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof onClick === 'function') {
|
|
131
|
-
onClick(e);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
handleKeyDown = e => {
|
|
135
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
136
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
137
|
-
|
|
138
|
-
if (spaceKey || enterKey) {
|
|
139
|
-
e.preventDefault();
|
|
140
|
-
e.stopPropagation();
|
|
141
|
-
|
|
142
|
-
if (enterKey) {
|
|
143
|
-
// handle space key on keyUp for FF
|
|
144
|
-
const refNode = findDOMNode(this.ref);
|
|
145
|
-
refNode.click();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
handleKeyUp = e => {
|
|
150
|
-
const spaceKey = e.keyCode === keycode.codes.space;
|
|
151
|
-
const enterKey = e.keyCode === keycode.codes.enter;
|
|
152
|
-
|
|
153
|
-
if (spaceKey || enterKey) {
|
|
154
|
-
e.preventDefault();
|
|
155
|
-
e.stopPropagation();
|
|
156
|
-
|
|
157
|
-
if (spaceKey) {
|
|
158
|
-
const refNode = findDOMNode(this.ref);
|
|
159
|
-
refNode.click();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
handleMouseOver = event => {
|
|
164
|
-
this.focus();
|
|
165
|
-
|
|
166
|
-
if (typeof this.props.onMouseOver === 'function') {
|
|
167
|
-
this.props.onMouseOver(event, this);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
164
|
get elementType() {
|
|
172
165
|
return getElementType(MenuItem, this.props);
|
|
173
166
|
}
|
|
@@ -248,6 +241,9 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
248
241
|
}), this.renderContent());
|
|
249
242
|
}
|
|
250
243
|
|
|
251
|
-
}
|
|
244
|
+
}, _class2.displayName = "MenuItem", _class2.componentId = 'Menu.Item', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
245
|
+
type: 'button',
|
|
246
|
+
disabled: false
|
|
247
|
+
}, _class2.contextType = MenuContext, _class2)) || _class) || _class) || _class);
|
|
252
248
|
export default MenuItem;
|
|
253
249
|
export { MenuItem };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _dec3, _class;
|
|
1
|
+
var _dec, _dec2, _dec3, _class, _class2;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -42,21 +42,53 @@ id: Menu.Group
|
|
|
42
42
|
---
|
|
43
43
|
@tsProps
|
|
44
44
|
**/
|
|
45
|
-
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = class MenuItemGroup extends Component {
|
|
46
|
-
static displayName = "MenuItemGroup";
|
|
47
|
-
static componentId = 'Menu.Group';
|
|
48
|
-
static propTypes = propTypes;
|
|
49
|
-
static allowedProps = allowedProps;
|
|
50
|
-
static defaultProps = {
|
|
51
|
-
disabled: false,
|
|
52
|
-
children: null,
|
|
53
|
-
isTabbable: false,
|
|
54
|
-
allowMultiple: false,
|
|
55
|
-
defaultSelected: []
|
|
56
|
-
};
|
|
57
|
-
|
|
45
|
+
let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class MenuItemGroup extends Component {
|
|
58
46
|
constructor(props) {
|
|
59
47
|
super(props);
|
|
48
|
+
this._labelId = void 0;
|
|
49
|
+
this.ref = null;
|
|
50
|
+
|
|
51
|
+
this.handleRef = el => {
|
|
52
|
+
this.ref = el;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
this.handleSelect = (e, value, selected, item) => {
|
|
56
|
+
if (this.props.disabled) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (this.props.selected) {
|
|
62
|
+
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
63
|
+
} else {
|
|
64
|
+
this.setState(state => {
|
|
65
|
+
return {
|
|
66
|
+
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
this.updateSelected = (e, value, items, selected, item) => {
|
|
73
|
+
const allowMultiple = this.props.allowMultiple;
|
|
74
|
+
let updated = allowMultiple ? [...items] : [];
|
|
75
|
+
const location = updated.indexOf(value);
|
|
76
|
+
|
|
77
|
+
if (selected === true && location < 0) {
|
|
78
|
+
updated.push(value);
|
|
79
|
+
} else if (selected === false && location !== -1) {
|
|
80
|
+
updated.splice(location, 1);
|
|
81
|
+
} else if (!allowMultiple && updated.length < 1) {
|
|
82
|
+
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
83
|
+
updated = [...items];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (typeof this.props.onSelect === 'function') {
|
|
87
|
+
this.props.onSelect(e, updated, selected, item);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return updated;
|
|
91
|
+
};
|
|
60
92
|
|
|
61
93
|
if (typeof props.selected === 'undefined') {
|
|
62
94
|
this.state = {
|
|
@@ -67,12 +99,6 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
67
99
|
this._labelId = props.deterministicId('MenuItemGroup');
|
|
68
100
|
}
|
|
69
101
|
|
|
70
|
-
_labelId;
|
|
71
|
-
ref = null;
|
|
72
|
-
handleRef = el => {
|
|
73
|
-
this.ref = el;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
102
|
componentDidMount() {
|
|
77
103
|
var _this$props$makeStyle, _this$props;
|
|
78
104
|
|
|
@@ -85,43 +111,6 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
85
111
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
86
112
|
}
|
|
87
113
|
|
|
88
|
-
handleSelect = (e, value, selected, item) => {
|
|
89
|
-
if (this.props.disabled) {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.props.selected) {
|
|
95
|
-
this.updateSelected(e, value, this.props.selected, selected, item);
|
|
96
|
-
} else {
|
|
97
|
-
this.setState(state => {
|
|
98
|
-
return {
|
|
99
|
-
selected: this.updateSelected(e, value, state.selected, selected, item)
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
updateSelected = (e, value, items, selected, item) => {
|
|
105
|
-
const allowMultiple = this.props.allowMultiple;
|
|
106
|
-
let updated = allowMultiple ? [...items] : [];
|
|
107
|
-
const location = updated.indexOf(value);
|
|
108
|
-
|
|
109
|
-
if (selected === true && location < 0) {
|
|
110
|
-
updated.push(value);
|
|
111
|
-
} else if (selected === false && location !== -1) {
|
|
112
|
-
updated.splice(location, 1);
|
|
113
|
-
} else if (!allowMultiple && updated.length < 1) {
|
|
114
|
-
// don't allow nothing selected if it's not allowMultiple/checkbox
|
|
115
|
-
updated = [...items];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (typeof this.props.onSelect === 'function') {
|
|
119
|
-
this.props.onSelect(e, updated, selected, item);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return updated;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
114
|
selectedFromChildren(props) {
|
|
126
115
|
const children = props.children,
|
|
127
116
|
allowMultiple = props.allowMultiple;
|
|
@@ -205,6 +194,12 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
205
194
|
}, this.renderChildren()));
|
|
206
195
|
}
|
|
207
196
|
|
|
208
|
-
}
|
|
197
|
+
}, _class2.displayName = "MenuItemGroup", _class2.componentId = 'Menu.Group', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
198
|
+
disabled: false,
|
|
199
|
+
children: null,
|
|
200
|
+
isTabbable: false,
|
|
201
|
+
allowMultiple: false,
|
|
202
|
+
defaultSelected: []
|
|
203
|
+
}, _class2)) || _class) || _class) || _class);
|
|
209
204
|
export default MenuItemGroup;
|
|
210
205
|
export { MenuItemGroup };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _dec, _dec2, _class;
|
|
1
|
+
var _dec, _dec2, _class, _class2;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* The MIT License (MIT)
|
|
@@ -40,15 +40,15 @@ id: Menu.Separator
|
|
|
40
40
|
---
|
|
41
41
|
@module MenuItemSeparator
|
|
42
42
|
**/
|
|
43
|
-
let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class MenuItemSeparator extends Component {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
43
|
+
let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class MenuItemSeparator extends Component {
|
|
44
|
+
constructor() {
|
|
45
|
+
super(...arguments);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
|
|
48
|
+
this.handleRef = el => {
|
|
49
|
+
this.ref = el;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
componentDidMount() {
|
|
54
54
|
var _this$props$makeStyle, _this$props;
|
|
@@ -73,6 +73,6 @@ let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme)
|
|
|
73
73
|
}));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
}) || _class) || _class);
|
|
76
|
+
}, _class2.displayName = "MenuItemSeparator", _class2.componentId = 'Menu.Separator', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2)) || _class) || _class);
|
|
77
77
|
export default MenuItemSeparator;
|
|
78
78
|
export { MenuItemSeparator };
|