@instructure/ui-menu 10.2.3-snapshot-0 → 10.2.3-snapshot-2
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/MenuItem/index.js +9 -6
- package/es/Menu/MenuItem/props.js +3 -2
- package/es/Menu/MenuItem/styles.js +7 -0
- package/es/Menu/index.js +2 -1
- package/es/Menu/props.js +3 -2
- package/lib/Menu/MenuItem/index.js +9 -5
- package/lib/Menu/MenuItem/props.js +3 -2
- package/lib/Menu/MenuItem/styles.js +7 -0
- package/lib/Menu/index.js +2 -1
- package/lib/Menu/props.js +3 -2
- package/package.json +19 -19
- package/src/Menu/MenuItem/index.tsx +8 -2
- package/src/Menu/MenuItem/props.ts +9 -3
- package/src/Menu/MenuItem/styles.ts +7 -0
- package/src/Menu/index.tsx +1 -0
- package/src/Menu/props.ts +8 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Menu/MenuItem/index.d.ts +2 -0
- package/types/Menu/MenuItem/index.d.ts.map +1 -1
- package/types/Menu/MenuItem/props.d.ts +5 -1
- package/types/Menu/MenuItem/props.d.ts.map +1 -1
- package/types/Menu/MenuItem/styles.d.ts.map +1 -1
- package/types/Menu/index.d.ts +2 -0
- package/types/Menu/index.d.ts.map +1 -1
- package/types/Menu/props.d.ts +4 -0
- package/types/Menu/props.d.ts.map +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
|
-
## [10.2.3-snapshot-
|
|
6
|
+
## [10.2.3-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.2.2...v10.2.3-snapshot-2) (2024-09-20)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-menu:** add renderLabelInfo to Menu ([2bc8554](https://github.com/instructure/instructure-ui/commit/2bc85544b5c51aba4a98bc5082b98b8e2e08b06e))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -26,7 +26,7 @@ var _dec, _dec2, _dec3, _class, _MenuItem, _IconCheckSolid, _IconArrowOpenEndSol
|
|
|
26
26
|
import React, { Component } from 'react';
|
|
27
27
|
import keycode from 'keycode';
|
|
28
28
|
import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons';
|
|
29
|
-
import { omitProps, getElementType, withDeterministicId } from '@instructure/ui-react-utils';
|
|
29
|
+
import { omitProps, getElementType, withDeterministicId, callRenderProp } from '@instructure/ui-react-utils';
|
|
30
30
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
31
31
|
import { isActiveElement, findDOMNode } from '@instructure/ui-dom-utils';
|
|
32
32
|
import { testable } from '@instructure/ui-testable';
|
|
@@ -158,10 +158,11 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
158
158
|
refNode.focus();
|
|
159
159
|
}
|
|
160
160
|
renderContent() {
|
|
161
|
-
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
161
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
162
162
|
const _this$props4 = this.props,
|
|
163
163
|
children = _this$props4.children,
|
|
164
|
-
type = _this$props4.type
|
|
164
|
+
type = _this$props4.type,
|
|
165
|
+
renderLabelInfo = _this$props4.renderLabelInfo;
|
|
165
166
|
return jsx("span", null, (type === 'checkbox' || type === 'radio') && jsx("span", {
|
|
166
167
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
167
168
|
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = jsx(IconCheckSolid, null)))), jsx("span", {
|
|
@@ -169,10 +170,12 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
169
170
|
id: this.labelId
|
|
170
171
|
}, children), type === 'flyout' && jsx("span", {
|
|
171
172
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
172
|
-
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = jsx(IconArrowOpenEndSolid, null)))
|
|
173
|
+
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = jsx(IconArrowOpenEndSolid, null))), renderLabelInfo && jsx("span", {
|
|
174
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.labelInfo
|
|
175
|
+
}, callRenderProp(renderLabelInfo)));
|
|
173
176
|
}
|
|
174
177
|
render() {
|
|
175
|
-
var _this$props$
|
|
178
|
+
var _this$props$styles5;
|
|
176
179
|
const _this$props5 = this.props,
|
|
177
180
|
disabled = _this$props5.disabled,
|
|
178
181
|
controls = _this$props5.controls,
|
|
@@ -195,7 +198,7 @@ let MenuItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
195
198
|
onKeyUp: createChainedFunction(onKeyUp, this.handleKeyUp),
|
|
196
199
|
onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
|
|
197
200
|
ref: this.handleRef,
|
|
198
|
-
css: (_this$props$
|
|
201
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.menuItem,
|
|
199
202
|
onMouseOver: this.handleMouseOver
|
|
200
203
|
}), this.renderContent());
|
|
201
204
|
}
|
|
@@ -39,7 +39,8 @@ const propTypes = {
|
|
|
39
39
|
type: PropTypes.oneOf(['button', 'checkbox', 'radio', 'flyout']),
|
|
40
40
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
41
41
|
href: PropTypes.string,
|
|
42
|
-
target: PropTypes.string
|
|
42
|
+
target: PropTypes.string,
|
|
43
|
+
renderLabelInfo: PropTypes.node
|
|
43
44
|
};
|
|
44
|
-
const allowedProps = ['children', 'defaultSelected', 'selected', 'onSelect', 'onClick', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'controls', 'disabled', 'as', 'type', 'value', 'href', 'target'];
|
|
45
|
+
const allowedProps = ['children', 'defaultSelected', 'selected', 'onSelect', 'onClick', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'controls', 'disabled', 'as', 'type', 'value', 'href', 'target', 'renderLabelInfo'];
|
|
45
46
|
export { propTypes, allowedProps };
|
|
@@ -118,6 +118,13 @@ const generateStyle = (componentTheme, props) => {
|
|
|
118
118
|
...roleIconStyles,
|
|
119
119
|
...flyoutIconStyles
|
|
120
120
|
},
|
|
121
|
+
labelInfo: {
|
|
122
|
+
label: 'menuItem__labelInfo',
|
|
123
|
+
height: '100%',
|
|
124
|
+
float: 'right',
|
|
125
|
+
clear: 'right',
|
|
126
|
+
paddingRight: '1.75rem'
|
|
127
|
+
},
|
|
121
128
|
label: {
|
|
122
129
|
label: 'menuItem__label',
|
|
123
130
|
color: componentTheme.labelColor
|
package/es/Menu/index.js
CHANGED
|
@@ -290,7 +290,8 @@ let Menu = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, gener
|
|
|
290
290
|
onBlur: this.handleMenuItemBlur,
|
|
291
291
|
tabIndex: isTabbable ? 0 : -1,
|
|
292
292
|
type: "flyout",
|
|
293
|
-
disabled: submenuDisabled
|
|
293
|
+
disabled: submenuDisabled,
|
|
294
|
+
renderLabelInfo: child.props.renderLabelInfo
|
|
294
295
|
}, child.props.title || child.props.label)
|
|
295
296
|
}));
|
|
296
297
|
}
|
package/es/Menu/props.js
CHANGED
|
@@ -52,7 +52,8 @@ const propTypes = {
|
|
|
52
52
|
withArrow: PropTypes.bool,
|
|
53
53
|
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
54
54
|
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
55
|
-
maxHeight: PropTypes.string
|
|
55
|
+
maxHeight: PropTypes.string,
|
|
56
|
+
renderLabelInfo: PropTypes.node
|
|
56
57
|
};
|
|
57
|
-
const allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'positionContainerDisplay', 'type', 'id', 'withArrow', 'offsetX', 'offsetY', 'maxHeight'];
|
|
58
|
+
const allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'positionContainerDisplay', 'type', 'id', 'withArrow', 'offsetX', 'offsetY', 'maxHeight', 'renderLabelInfo'];
|
|
58
59
|
export { propTypes, allowedProps };
|
|
@@ -13,6 +13,7 @@ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEnd
|
|
|
13
13
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
14
14
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
15
15
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
16
|
+
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
16
17
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
17
18
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
18
19
|
var _findDOMNode = require("@instructure/ui-dom-utils/lib/findDOMNode.js");
|
|
@@ -170,10 +171,11 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
170
171
|
refNode.focus();
|
|
171
172
|
}
|
|
172
173
|
renderContent() {
|
|
173
|
-
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
174
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3, _this$props$styles4;
|
|
174
175
|
const _this$props4 = this.props,
|
|
175
176
|
children = _this$props4.children,
|
|
176
|
-
type = _this$props4.type
|
|
177
|
+
type = _this$props4.type,
|
|
178
|
+
renderLabelInfo = _this$props4.renderLabelInfo;
|
|
177
179
|
return (0, _emotion.jsx)("span", null, (type === 'checkbox' || type === 'radio') && (0, _emotion.jsx)("span", {
|
|
178
180
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
179
181
|
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = (0, _emotion.jsx)(_IconCheckSolid2.IconCheckSolid, null)))), (0, _emotion.jsx)("span", {
|
|
@@ -181,10 +183,12 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
181
183
|
id: this.labelId
|
|
182
184
|
}, children), type === 'flyout' && (0, _emotion.jsx)("span", {
|
|
183
185
|
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
184
|
-
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, null))))
|
|
186
|
+
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, null))), renderLabelInfo && (0, _emotion.jsx)("span", {
|
|
187
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.labelInfo
|
|
188
|
+
}, (0, _callRenderProp.callRenderProp)(renderLabelInfo)));
|
|
185
189
|
}
|
|
186
190
|
render() {
|
|
187
|
-
var _this$props$
|
|
191
|
+
var _this$props$styles5;
|
|
188
192
|
const _this$props5 = this.props,
|
|
189
193
|
disabled = _this$props5.disabled,
|
|
190
194
|
controls = _this$props5.controls,
|
|
@@ -207,7 +211,7 @@ let MenuItem = exports.MenuItem = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
207
211
|
onKeyUp: (0, _createChainedFunction.createChainedFunction)(onKeyUp, this.handleKeyUp),
|
|
208
212
|
onKeyDown: (0, _createChainedFunction.createChainedFunction)(onKeyDown, this.handleKeyDown),
|
|
209
213
|
ref: this.handleRef,
|
|
210
|
-
css: (_this$props$
|
|
214
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.menuItem,
|
|
211
215
|
onMouseOver: this.handleMouseOver
|
|
212
216
|
}), this.renderContent());
|
|
213
217
|
}
|
|
@@ -46,6 +46,7 @@ const propTypes = exports.propTypes = {
|
|
|
46
46
|
type: _propTypes.default.oneOf(['button', 'checkbox', 'radio', 'flyout']),
|
|
47
47
|
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
48
48
|
href: _propTypes.default.string,
|
|
49
|
-
target: _propTypes.default.string
|
|
49
|
+
target: _propTypes.default.string,
|
|
50
|
+
renderLabelInfo: _propTypes.default.node
|
|
50
51
|
};
|
|
51
|
-
const allowedProps = exports.allowedProps = ['children', 'defaultSelected', 'selected', 'onSelect', 'onClick', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'controls', 'disabled', 'as', 'type', 'value', 'href', 'target'];
|
|
52
|
+
const allowedProps = exports.allowedProps = ['children', 'defaultSelected', 'selected', 'onSelect', 'onClick', 'onKeyDown', 'onKeyUp', 'onMouseOver', 'controls', 'disabled', 'as', 'type', 'value', 'href', 'target', 'renderLabelInfo'];
|
|
@@ -124,6 +124,13 @@ const generateStyle = (componentTheme, props) => {
|
|
|
124
124
|
...roleIconStyles,
|
|
125
125
|
...flyoutIconStyles
|
|
126
126
|
},
|
|
127
|
+
labelInfo: {
|
|
128
|
+
label: 'menuItem__labelInfo',
|
|
129
|
+
height: '100%',
|
|
130
|
+
float: 'right',
|
|
131
|
+
clear: 'right',
|
|
132
|
+
paddingRight: '1.75rem'
|
|
133
|
+
},
|
|
127
134
|
label: {
|
|
128
135
|
label: 'menuItem__label',
|
|
129
136
|
color: componentTheme.labelColor
|
package/lib/Menu/index.js
CHANGED
|
@@ -319,7 +319,8 @@ let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(
|
|
|
319
319
|
onBlur: this.handleMenuItemBlur,
|
|
320
320
|
tabIndex: isTabbable ? 0 : -1,
|
|
321
321
|
type: "flyout",
|
|
322
|
-
disabled: submenuDisabled
|
|
322
|
+
disabled: submenuDisabled,
|
|
323
|
+
renderLabelInfo: child.props.renderLabelInfo
|
|
323
324
|
}, child.props.title || child.props.label)
|
|
324
325
|
}));
|
|
325
326
|
}
|
package/lib/Menu/props.js
CHANGED
|
@@ -60,6 +60,7 @@ const propTypes = exports.propTypes = {
|
|
|
60
60
|
withArrow: _propTypes.default.bool,
|
|
61
61
|
offsetX: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
62
62
|
offsetY: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
63
|
-
maxHeight: _propTypes.default.string
|
|
63
|
+
maxHeight: _propTypes.default.string,
|
|
64
|
+
renderLabelInfo: _propTypes.default.node
|
|
64
65
|
};
|
|
65
|
-
const allowedProps = exports.allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'positionContainerDisplay', 'type', 'id', 'withArrow', 'offsetX', 'offsetY', 'maxHeight'];
|
|
66
|
+
const allowedProps = exports.allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'positionContainerDisplay', 'type', 'id', 'withArrow', 'offsetX', 'offsetY', 'maxHeight', 'renderLabelInfo'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-menu",
|
|
3
|
-
"version": "10.2.3-snapshot-
|
|
3
|
+
"version": "10.2.3-snapshot-2",
|
|
4
4
|
"description": "A dropdown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "10.2.3-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "10.2.3-snapshot-
|
|
28
|
-
"@instructure/ui-color-utils": "10.2.3-snapshot-
|
|
29
|
-
"@instructure/ui-test-utils": "10.2.3-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "10.2.3-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "10.2.3-snapshot-2",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.2.3-snapshot-2",
|
|
28
|
+
"@instructure/ui-color-utils": "10.2.3-snapshot-2",
|
|
29
|
+
"@instructure/ui-test-utils": "10.2.3-snapshot-2",
|
|
30
|
+
"@instructure/ui-themes": "10.2.3-snapshot-2",
|
|
31
31
|
"@testing-library/jest-dom": "^6.4.6",
|
|
32
32
|
"@testing-library/react": "^15.0.7",
|
|
33
33
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.24.5",
|
|
38
|
-
"@instructure/console": "10.2.3-snapshot-
|
|
39
|
-
"@instructure/emotion": "10.2.3-snapshot-
|
|
40
|
-
"@instructure/shared-types": "10.2.3-snapshot-
|
|
41
|
-
"@instructure/ui-a11y-utils": "10.2.3-snapshot-
|
|
42
|
-
"@instructure/ui-dom-utils": "10.2.3-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "10.2.3-snapshot-
|
|
44
|
-
"@instructure/ui-popover": "10.2.3-snapshot-
|
|
45
|
-
"@instructure/ui-position": "10.2.3-snapshot-
|
|
46
|
-
"@instructure/ui-prop-types": "10.2.3-snapshot-
|
|
47
|
-
"@instructure/ui-react-utils": "10.2.3-snapshot-
|
|
48
|
-
"@instructure/ui-testable": "10.2.3-snapshot-
|
|
49
|
-
"@instructure/ui-utils": "10.2.3-snapshot-
|
|
50
|
-
"@instructure/ui-view": "10.2.3-snapshot-
|
|
38
|
+
"@instructure/console": "10.2.3-snapshot-2",
|
|
39
|
+
"@instructure/emotion": "10.2.3-snapshot-2",
|
|
40
|
+
"@instructure/shared-types": "10.2.3-snapshot-2",
|
|
41
|
+
"@instructure/ui-a11y-utils": "10.2.3-snapshot-2",
|
|
42
|
+
"@instructure/ui-dom-utils": "10.2.3-snapshot-2",
|
|
43
|
+
"@instructure/ui-icons": "10.2.3-snapshot-2",
|
|
44
|
+
"@instructure/ui-popover": "10.2.3-snapshot-2",
|
|
45
|
+
"@instructure/ui-position": "10.2.3-snapshot-2",
|
|
46
|
+
"@instructure/ui-prop-types": "10.2.3-snapshot-2",
|
|
47
|
+
"@instructure/ui-react-utils": "10.2.3-snapshot-2",
|
|
48
|
+
"@instructure/ui-testable": "10.2.3-snapshot-2",
|
|
49
|
+
"@instructure/ui-utils": "10.2.3-snapshot-2",
|
|
50
|
+
"@instructure/ui-view": "10.2.3-snapshot-2",
|
|
51
51
|
"keycode": "^2",
|
|
52
52
|
"prop-types": "^15.8.1"
|
|
53
53
|
},
|
|
@@ -29,7 +29,8 @@ import { IconCheckSolid, IconArrowOpenEndSolid } from '@instructure/ui-icons'
|
|
|
29
29
|
import {
|
|
30
30
|
omitProps,
|
|
31
31
|
getElementType,
|
|
32
|
-
withDeterministicId
|
|
32
|
+
withDeterministicId,
|
|
33
|
+
callRenderProp
|
|
33
34
|
} from '@instructure/ui-react-utils'
|
|
34
35
|
import { createChainedFunction } from '@instructure/ui-utils'
|
|
35
36
|
import { isActiveElement, findDOMNode } from '@instructure/ui-dom-utils'
|
|
@@ -209,7 +210,7 @@ class MenuItem extends Component<MenuItemProps, MenuItemState> {
|
|
|
209
210
|
}
|
|
210
211
|
|
|
211
212
|
renderContent() {
|
|
212
|
-
const { children, type } = this.props
|
|
213
|
+
const { children, type, renderLabelInfo } = this.props
|
|
213
214
|
|
|
214
215
|
return (
|
|
215
216
|
<span>
|
|
@@ -226,6 +227,11 @@ class MenuItem extends Component<MenuItemProps, MenuItemState> {
|
|
|
226
227
|
<IconArrowOpenEndSolid />
|
|
227
228
|
</span>
|
|
228
229
|
)}
|
|
230
|
+
{renderLabelInfo && (
|
|
231
|
+
<span css={this.props.styles?.labelInfo}>
|
|
232
|
+
{callRenderProp(renderLabelInfo)}
|
|
233
|
+
</span>
|
|
234
|
+
)}
|
|
229
235
|
</span>
|
|
230
236
|
)
|
|
231
237
|
}
|
|
@@ -92,6 +92,10 @@ type MenuItemOwnProps = {
|
|
|
92
92
|
* Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).
|
|
93
93
|
*/
|
|
94
94
|
target?: string
|
|
95
|
+
/**
|
|
96
|
+
* Content to render in the label's info region
|
|
97
|
+
*/
|
|
98
|
+
renderLabelInfo?: React.ReactNode | (() => React.ReactNode)
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
type PropKeys = keyof MenuItemOwnProps
|
|
@@ -103,7 +107,7 @@ type MenuItemProps = MenuItemOwnProps &
|
|
|
103
107
|
OtherHTMLAttributes<MenuItemOwnProps> &
|
|
104
108
|
WithDeterministicIdProps
|
|
105
109
|
|
|
106
|
-
type MenuItemStyle = ComponentStyle<'menuItem' | 'icon' | 'label'>
|
|
110
|
+
type MenuItemStyle = ComponentStyle<'menuItem' | 'icon' | 'labelInfo' | 'label'>
|
|
107
111
|
|
|
108
112
|
const propTypes: PropValidators<PropKeys> = {
|
|
109
113
|
children: PropTypes.node.isRequired,
|
|
@@ -120,7 +124,8 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
120
124
|
type: PropTypes.oneOf(['button', 'checkbox', 'radio', 'flyout']),
|
|
121
125
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
122
126
|
href: PropTypes.string,
|
|
123
|
-
target: PropTypes.string
|
|
127
|
+
target: PropTypes.string,
|
|
128
|
+
renderLabelInfo: PropTypes.node
|
|
124
129
|
}
|
|
125
130
|
|
|
126
131
|
const allowedProps: AllowedPropKeys = [
|
|
@@ -138,7 +143,8 @@ const allowedProps: AllowedPropKeys = [
|
|
|
138
143
|
'type',
|
|
139
144
|
'value',
|
|
140
145
|
'href',
|
|
141
|
-
'target'
|
|
146
|
+
'target',
|
|
147
|
+
'renderLabelInfo'
|
|
142
148
|
]
|
|
143
149
|
type MenuItemState = {
|
|
144
150
|
selected: boolean
|
|
@@ -138,6 +138,13 @@ const generateStyle = (
|
|
|
138
138
|
...roleIconStyles,
|
|
139
139
|
...flyoutIconStyles
|
|
140
140
|
},
|
|
141
|
+
labelInfo: {
|
|
142
|
+
label: 'menuItem__labelInfo',
|
|
143
|
+
height: '100%',
|
|
144
|
+
float: 'right',
|
|
145
|
+
clear: 'right',
|
|
146
|
+
paddingRight: '1.75rem'
|
|
147
|
+
},
|
|
141
148
|
label: {
|
|
142
149
|
label: 'menuItem__label',
|
|
143
150
|
color: componentTheme.labelColor
|
package/src/Menu/index.tsx
CHANGED
package/src/Menu/props.ts
CHANGED
|
@@ -171,6 +171,10 @@ type MenuOwnProps = {
|
|
|
171
171
|
* scroll and will be as tall as the content requires
|
|
172
172
|
*/
|
|
173
173
|
maxHeight?: string | number
|
|
174
|
+
/**
|
|
175
|
+
* Content to render in the label's info region. It is only visible on nested Menus.
|
|
176
|
+
*/
|
|
177
|
+
renderLabelInfo?: React.ReactNode | (() => React.ReactNode)
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
type PropKeys = keyof MenuOwnProps
|
|
@@ -218,7 +222,8 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
218
222
|
withArrow: PropTypes.bool,
|
|
219
223
|
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
220
224
|
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
221
|
-
maxHeight: PropTypes.string
|
|
225
|
+
maxHeight: PropTypes.string,
|
|
226
|
+
renderLabelInfo: PropTypes.node
|
|
222
227
|
}
|
|
223
228
|
|
|
224
229
|
const allowedProps: AllowedPropKeys = [
|
|
@@ -248,7 +253,8 @@ const allowedProps: AllowedPropKeys = [
|
|
|
248
253
|
'withArrow',
|
|
249
254
|
'offsetX',
|
|
250
255
|
'offsetY',
|
|
251
|
-
'maxHeight'
|
|
256
|
+
'maxHeight',
|
|
257
|
+
'renderLabelInfo'
|
|
252
258
|
]
|
|
253
259
|
|
|
254
260
|
export type { MenuProps, MenuStyle }
|