@instructure/ui-menu 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es/Menu/v1/MenuItem/index.js +184 -223
  3. package/es/Menu/v1/MenuItem/props.js +19 -26
  4. package/es/Menu/v1/MenuItem/styles.js +90 -133
  5. package/es/Menu/v1/MenuItem/theme.js +30 -64
  6. package/es/Menu/v1/MenuItemGroup/index.js +145 -166
  7. package/es/Menu/v1/MenuItemGroup/props.js +14 -26
  8. package/es/Menu/v1/MenuItemGroup/styles.js +25 -59
  9. package/es/Menu/v1/MenuItemGroup/theme.js +20 -54
  10. package/es/Menu/v1/MenuItemSeparator/index.js +38 -61
  11. package/es/Menu/v1/MenuItemSeparator/props.js +1 -28
  12. package/es/Menu/v1/MenuItemSeparator/styles.js +11 -45
  13. package/es/Menu/v1/MenuItemSeparator/theme.js +11 -44
  14. package/es/Menu/v1/index.js +324 -378
  15. package/es/Menu/v1/props.js +31 -26
  16. package/es/Menu/v1/styles.js +40 -74
  17. package/es/Menu/v1/theme.js +16 -49
  18. package/es/Menu/v2/MenuItem/index.js +203 -252
  19. package/es/Menu/v2/MenuItem/props.js +19 -26
  20. package/es/Menu/v2/MenuItem/styles.js +103 -147
  21. package/es/Menu/v2/MenuItemGroup/index.js +145 -166
  22. package/es/Menu/v2/MenuItemGroup/props.js +14 -26
  23. package/es/Menu/v2/MenuItemGroup/styles.js +25 -59
  24. package/es/Menu/v2/MenuItemSeparator/index.js +38 -61
  25. package/es/Menu/v2/MenuItemSeparator/props.js +1 -28
  26. package/es/Menu/v2/MenuItemSeparator/styles.js +11 -45
  27. package/es/Menu/v2/index.js +324 -378
  28. package/es/Menu/v2/props.js +31 -26
  29. package/es/Menu/v2/styles.js +22 -57
  30. package/es/exports/a.js +1 -24
  31. package/es/exports/b.js +1 -24
  32. package/es/utils/v1/MenuContext.js +4 -36
  33. package/package.json +18 -24
  34. package/tsconfig.build.json +0 -1
  35. package/tsconfig.build.tsbuildinfo +1 -1
  36. package/lib/Menu/v1/MenuItem/index.js +0 -247
  37. package/lib/Menu/v1/MenuItem/props.js +0 -31
  38. package/lib/Menu/v1/MenuItem/styles.js +0 -142
  39. package/lib/Menu/v1/MenuItem/theme.js +0 -71
  40. package/lib/Menu/v1/MenuItemGroup/index.js +0 -191
  41. package/lib/Menu/v1/MenuItemGroup/props.js +0 -31
  42. package/lib/Menu/v1/MenuItemGroup/styles.js +0 -66
  43. package/lib/Menu/v1/MenuItemGroup/theme.js +0 -61
  44. package/lib/Menu/v1/MenuItemSeparator/index.js +0 -73
  45. package/lib/Menu/v1/MenuItemSeparator/props.js +0 -34
  46. package/lib/Menu/v1/MenuItemSeparator/styles.js +0 -52
  47. package/lib/Menu/v1/MenuItemSeparator/theme.js +0 -51
  48. package/lib/Menu/v1/index.js +0 -438
  49. package/lib/Menu/v1/props.js +0 -31
  50. package/lib/Menu/v1/styles.js +0 -82
  51. package/lib/Menu/v1/theme.js +0 -56
  52. package/lib/Menu/v2/MenuItem/index.js +0 -286
  53. package/lib/Menu/v2/MenuItem/props.js +0 -31
  54. package/lib/Menu/v2/MenuItem/styles.js +0 -154
  55. package/lib/Menu/v2/MenuItemGroup/index.js +0 -190
  56. package/lib/Menu/v2/MenuItemGroup/props.js +0 -31
  57. package/lib/Menu/v2/MenuItemGroup/styles.js +0 -66
  58. package/lib/Menu/v2/MenuItemSeparator/index.js +0 -72
  59. package/lib/Menu/v2/MenuItemSeparator/props.js +0 -34
  60. package/lib/Menu/v2/MenuItemSeparator/styles.js +0 -52
  61. package/lib/Menu/v2/index.js +0 -437
  62. package/lib/Menu/v2/props.js +0 -31
  63. package/lib/Menu/v2/styles.js +0 -64
  64. package/lib/exports/a.js +0 -30
  65. package/lib/exports/b.js +0 -30
  66. package/lib/package.json +0 -1
  67. package/lib/utils/v1/MenuContext.js +0 -43
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
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.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-menu
@@ -1,28 +1,5 @@
1
- var _dec, _dec2, _class;
2
- /*
3
- * The MIT License (MIT)
4
- *
5
- * Copyright (c) 2015 - present Instructure, Inc.
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all
15
- * copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- * SOFTWARE.
24
- */
25
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Component } from 'react';
27
4
  import keycode from 'keycode';
28
5
  import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons';
@@ -34,203 +11,187 @@ import { MenuContext } from '../../../utils/v1/MenuContext.js';
34
11
  import generateStyle from './styles.js';
35
12
  import generateComponentTheme from './theme.js';
36
13
  import { allowedProps } from './props.js';
37
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
38
- /**
39
- ---
40
- parent: Menu
41
- id: Menu.Item
42
- ---
43
- **/
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;
53
- constructor(props) {
54
- super(props);
55
- if (typeof props.selected === 'undefined') {
56
- this.state = {
57
- selected: !!props.defaultSelected
58
- };
59
- }
60
- this.labelId = props.deterministicId('MenuItem__label');
61
- }
62
- get _node() {
63
- return this.ref;
64
- }
65
- labelId;
66
- ref = null;
67
- handleRef = el => {
68
- this.ref = el;
69
- };
70
- componentDidMount() {
71
- this.props.makeStyles?.();
72
- const context = this.context;
73
- if (context && context.registerMenuItem) {
74
- context.registerMenuItem(this);
75
- }
76
- }
77
- componentDidUpdate() {
78
- this.props.makeStyles?.();
79
- }
80
- componentWillUnmount() {
81
- const context = this.context;
82
- if (context && context.removeMenuItem) {
83
- context.removeMenuItem(this);
84
- }
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) {
14
+ class MenuItem extends Component {
15
+ static{
16
+ this.displayName = 'MenuItem';
17
+ }
18
+ static{
19
+ this.componentId = 'Menu.Item';
20
+ }
21
+ static{
22
+ this.allowedProps = allowedProps;
23
+ }
24
+ static{
25
+ this.defaultProps = {
26
+ type: 'button',
27
+ disabled: false
28
+ };
29
+ }
30
+ static{
31
+ this.contextType = MenuContext;
32
+ }
33
+ constructor(props){
34
+ super(props), this.ref = null, this.handleRef = (el)=>{
35
+ this.ref = el;
36
+ }, this.handleClick = (e)=>{
37
+ const { onSelect, onClick, disabled, value } = this.props;
38
+ const selected = !this.selected;
39
+ if (disabled) {
40
+ e.preventDefault();
41
+ return;
42
+ }
43
+ if (typeof this.props.selected === 'undefined') {
44
+ this.setState({
45
+ selected
46
+ });
47
+ }
48
+ if (typeof onSelect === 'function') {
49
+ e.persist();
50
+ onSelect(e, value, selected, this);
51
+ }
52
+ if (typeof onClick === 'function') {
53
+ onClick(e);
54
+ }
55
+ }, this.handleKeyDown = (e)=>{
56
+ const spaceKey = e.keyCode === keycode.codes.space;
57
+ const enterKey = e.keyCode === keycode.codes.enter;
58
+ if (spaceKey || enterKey) {
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ if (enterKey) {
62
+ const refNode = findDOMNode(this.ref);
63
+ refNode.click();
64
+ }
65
+ }
66
+ }, this.handleKeyUp = (e)=>{
67
+ const spaceKey = e.keyCode === keycode.codes.space;
68
+ const enterKey = e.keyCode === keycode.codes.enter;
69
+ if (spaceKey || enterKey) {
70
+ e.preventDefault();
71
+ e.stopPropagation();
72
+ if (spaceKey) {
73
+ const refNode = findDOMNode(this.ref);
74
+ refNode.click();
75
+ }
76
+ }
77
+ }, this.handleMouseOver = (event)=>{
78
+ if (!this.focused) {
79
+ this.focus();
80
+ }
81
+ if (typeof this.props.onMouseOver === 'function') {
82
+ this.props.onMouseOver(event, this);
83
+ }
84
+ };
85
+ if (typeof props.selected === 'undefined') {
86
+ this.state = {
87
+ selected: !!props.defaultSelected
88
+ };
89
+ }
90
+ this.labelId = props.deterministicId('MenuItem__label');
91
+ }
92
+ get _node() {
93
+ void 0;
94
+ return this.ref;
95
+ }
96
+ componentDidMount() {
97
+ this.props.makeStyles?.();
98
+ const context = this.context;
99
+ if (context && context.registerMenuItem) {
100
+ context.registerMenuItem(this);
101
+ }
102
+ }
103
+ componentDidUpdate() {
104
+ this.props.makeStyles?.();
105
+ }
106
+ componentWillUnmount() {
107
+ const context = this.context;
108
+ if (context && context.removeMenuItem) {
109
+ context.removeMenuItem(this);
110
+ }
111
+ }
112
+ get elementType() {
113
+ return getElementType(MenuItem, this.props);
114
+ }
115
+ get role() {
116
+ switch(this.props.type){
117
+ case 'checkbox':
118
+ return 'menuitemcheckbox';
119
+ case 'radio':
120
+ return 'menuitemradio';
121
+ default:
122
+ return 'menuitem';
123
+ }
124
+ }
125
+ get selected() {
126
+ return typeof this.props.selected === 'undefined' ? this.state.selected : this.props.selected;
127
+ }
128
+ get focused() {
129
+ return isActiveElement(this.ref);
130
+ }
131
+ focus() {
131
132
  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
- };
144
- get elementType() {
145
- return getElementType(MenuItem, this.props);
146
- }
147
- get role() {
148
- switch (this.props.type) {
149
- case 'checkbox':
150
- return 'menuitemcheckbox';
151
- case 'radio':
152
- return 'menuitemradio';
153
- default:
154
- return 'menuitem';
155
- }
156
- }
157
- get selected() {
158
- return typeof this.props.selected === 'undefined' ? this.state.selected : this.props.selected;
159
- }
160
- get focused() {
161
- return isActiveElement(this.ref);
162
- }
163
- focus() {
164
- const refNode = findDOMNode(this.ref);
165
- refNode.focus();
166
- }
167
- renderContent() {
168
- const {
169
- children,
170
- type,
171
- renderLabelInfo
172
- } = this.props;
173
- return _jsxs("span", {
174
- children: [(type === 'checkbox' || type === 'radio') && _jsx("span", {
175
- css: this.props.styles?.icon,
176
- children: this.selected && _jsx(IconCheckSolid, {})
177
- }), _jsx("span", {
178
- css: this.props.styles?.label,
179
- id: this.labelId,
180
- children: children
181
- }), type === 'flyout' && _jsx("span", {
182
- css: this.props.styles?.icon,
183
- children: _jsx(IconArrowOpenEndSolid, {})
184
- }), renderLabelInfo && _jsx("span", {
185
- css: this.props.styles?.labelInfo,
186
- children: callRenderProp(renderLabelInfo)
187
- })]
188
- });
189
- }
190
- render() {
191
- const {
192
- disabled,
193
- controls,
194
- onKeyDown,
195
- onKeyUp,
196
- type,
197
- href: rawHref,
198
- target
199
- } = this.props;
200
- const props = omitProps(this.props, MenuItem.allowedProps);
201
- const ElementType = this.elementType;
202
- const {
203
- href,
204
- rel
205
- } = safeLinkProps({
206
- tag: typeof ElementType === 'string' ? ElementType : 'a',
207
- attr: 'href',
208
- href: rawHref,
209
- target,
210
- rel: this.props.rel
211
- });
212
- return _jsx(ElementType, {
213
- tabIndex: -1 // note: tabIndex can be overridden by Menu or MenuItemGroup components
214
- ,
215
- ...props,
216
- href: href,
217
- target: target,
218
- rel: rel,
219
- role: this.role,
220
- "aria-labelledby": this.labelId,
221
- "aria-disabled": disabled ? 'true' : undefined,
222
- "aria-controls": controls,
223
- "aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : undefined,
224
- onClick: this.handleClick,
225
- onKeyUp: createChainedFunction(onKeyUp, this.handleKeyUp),
226
- onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
227
- ref: this.handleRef,
228
- css: this.props.styles?.menuItem,
229
- onMouseOver: this.handleMouseOver,
230
- "data-cid": "MenuItem",
231
- children: this.renderContent()
232
- });
233
- }
234
- }) || _class) || _class);
133
+ refNode.focus();
134
+ }
135
+ renderContent() {
136
+ const { children, type, renderLabelInfo } = this.props;
137
+ return /*#__PURE__*/ _jsxs("span", {
138
+ children: [
139
+ (type === 'checkbox' || type === 'radio') && /*#__PURE__*/ _jsx("span", {
140
+ css: this.props.styles?.icon,
141
+ children: this.selected && /*#__PURE__*/ _jsx(IconCheckSolid, {})
142
+ }),
143
+ /*#__PURE__*/ _jsx("span", {
144
+ css: this.props.styles?.label,
145
+ id: this.labelId,
146
+ children: children
147
+ }),
148
+ type === 'flyout' && /*#__PURE__*/ _jsx("span", {
149
+ css: this.props.styles?.icon,
150
+ children: /*#__PURE__*/ _jsx(IconArrowOpenEndSolid, {})
151
+ }),
152
+ renderLabelInfo && /*#__PURE__*/ _jsx("span", {
153
+ css: this.props.styles?.labelInfo,
154
+ children: callRenderProp(renderLabelInfo)
155
+ })
156
+ ]
157
+ });
158
+ }
159
+ render() {
160
+ const { disabled, controls, onKeyDown, onKeyUp, type, href: rawHref, target } = this.props;
161
+ const props = omitProps(this.props, MenuItem.allowedProps);
162
+ const ElementType = this.elementType;
163
+ const { href, rel } = safeLinkProps({
164
+ tag: typeof ElementType === 'string' ? ElementType : 'a',
165
+ attr: 'href',
166
+ href: rawHref,
167
+ target,
168
+ rel: this.props.rel
169
+ });
170
+ return /*#__PURE__*/ _jsx(ElementType, {
171
+ tabIndex: -1,
172
+ ...props,
173
+ href: href,
174
+ target: target,
175
+ rel: rel,
176
+ role: this.role,
177
+ "aria-labelledby": this.labelId,
178
+ "aria-disabled": disabled ? 'true' : undefined,
179
+ "aria-controls": controls,
180
+ "aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : undefined,
181
+ onClick: this.handleClick,
182
+ onKeyUp: createChainedFunction(onKeyUp, this.handleKeyUp),
183
+ onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
184
+ ref: this.handleRef,
185
+ css: this.props.styles?.menuItem,
186
+ onMouseOver: this.handleMouseOver,
187
+ "data-cid": "MenuItem",
188
+ children: this.renderContent()
189
+ });
190
+ }
191
+ }
192
+ MenuItem = _ts_decorate([
193
+ withDeterministicId(),
194
+ withStyle(generateStyle, generateComponentTheme)
195
+ ], MenuItem);
235
196
  export default MenuItem;
236
- export { MenuItem };
197
+ export { MenuItem };
@@ -1,26 +1,19 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- const allowedProps = ['children', 'defaultSelected', 'selected', 'onSelect', 'onClick', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'controls', 'disabled', 'as', 'type', 'value', 'href', 'target', 'renderLabelInfo'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'children',
3
+ 'defaultSelected',
4
+ 'selected',
5
+ 'onSelect',
6
+ 'onClick',
7
+ 'onKeyDown',
8
+ 'onKeyUp',
9
+ 'onMouseOver',
10
+ 'controls',
11
+ 'disabled',
12
+ 'as',
13
+ 'type',
14
+ 'value',
15
+ 'href',
16
+ 'target',
17
+ 'renderLabelInfo'
18
+ ];
19
+ export { allowedProps };