@instructure/ui-menu 8.25.1-snapshot-7 → 8.25.1-snapshot-10

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 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-7](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-7) (2022-06-13)
6
+ ## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
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, _class2, _IconCheckSolid, _IconArrowOpenEndSoli;
1
+ var _dec, _dec2, _dec3, _class, _IconCheckSolid, _IconArrowOpenEndSoli;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -25,7 +25,7 @@ var _dec, _dec2, _dec3, _class, _class2, _IconCheckSolid, _IconArrowOpenEndSoli;
25
25
  */
26
26
 
27
27
  /** @jsx jsx */
28
- import { Component } from 'react';
28
+ import React, { Component } from 'react';
29
29
  import keycode from 'keycode';
30
30
  import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons';
31
31
  import { omitProps, getElementType, withDeterministicId } from '@instructure/ui-react-utils';
@@ -45,83 +45,19 @@ 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 = (_class2 = class MenuItem extends Component {
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
+
49
59
  constructor(props) {
50
60
  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
- };
125
61
 
126
62
  if (typeof props.selected === 'undefined') {
127
63
  this.state = {
@@ -136,10 +72,16 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
136
72
  return this.ref;
137
73
  }
138
74
 
75
+ labelId;
76
+ ref = null;
77
+ handleRef = el => {
78
+ this.ref = el;
79
+ };
80
+
139
81
  componentDidMount() {
140
- var _this$props$makeStyle, _this$props2;
82
+ var _this$props$makeStyle, _this$props;
141
83
 
142
- (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
84
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
143
85
  const context = this.context;
144
86
 
145
87
  if (context && context.registerMenuItem) {
@@ -148,9 +90,9 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
148
90
  }
149
91
 
150
92
  componentDidUpdate() {
151
- var _this$props$makeStyle2, _this$props3;
93
+ var _this$props$makeStyle2, _this$props2;
152
94
 
153
- (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
95
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
154
96
  }
155
97
 
156
98
  componentWillUnmount() {
@@ -161,6 +103,71 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
161
103
  }
162
104
  }
163
105
 
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
+
164
171
  get elementType() {
165
172
  return getElementType(MenuItem, this.props);
166
173
  }
@@ -241,9 +248,6 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
241
248
  }), this.renderContent());
242
249
  }
243
250
 
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);
251
+ }) || _class) || _class) || _class);
248
252
  export default MenuItem;
249
253
  export { MenuItem };
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _dec3, _class, _class2;
1
+ var _dec, _dec2, _dec3, _class;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -42,53 +42,21 @@ 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 = (_class2 = class MenuItemGroup extends Component {
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
+
46
58
  constructor(props) {
47
59
  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
- };
92
60
 
93
61
  if (typeof props.selected === 'undefined') {
94
62
  this.state = {
@@ -99,6 +67,12 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
99
67
  this._labelId = props.deterministicId('MenuItemGroup');
100
68
  }
101
69
 
70
+ _labelId;
71
+ ref = null;
72
+ handleRef = el => {
73
+ this.ref = el;
74
+ };
75
+
102
76
  componentDidMount() {
103
77
  var _this$props$makeStyle, _this$props;
104
78
 
@@ -111,6 +85,43 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
111
85
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
112
86
  }
113
87
 
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
+
114
125
  selectedFromChildren(props) {
115
126
  const children = props.children,
116
127
  allowMultiple = props.allowMultiple;
@@ -194,12 +205,6 @@ let MenuItemGroup = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
194
205
  }, this.renderChildren()));
195
206
  }
196
207
 
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);
208
+ }) || _class) || _class) || _class);
204
209
  export default MenuItemGroup;
205
210
  export { MenuItemGroup };
@@ -1,4 +1,4 @@
1
- var _dec, _dec2, _class, _class2;
1
+ var _dec, _dec2, _class;
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 = (_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
- }
43
+ let MenuItemSeparator = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class MenuItemSeparator extends Component {
44
+ static displayName = "MenuItemSeparator";
45
+ static componentId = 'Menu.Separator';
46
+ static propTypes = propTypes;
47
+ static allowedProps = allowedProps;
48
+ ref = null;
49
+ handleRef = el => {
50
+ this.ref = el;
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
- }, _class2.displayName = "MenuItemSeparator", _class2.componentId = 'Menu.Separator', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2)) || _class) || _class);
76
+ }) || _class) || _class);
77
77
  export default MenuItemSeparator;
78
78
  export { MenuItemSeparator };