@instructure/ui-top-nav-bar 8.33.1 → 8.33.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 +4 -0
- package/es/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +4 -2
- package/es/TopNavBar/TopNavBarActionItems/index.js +10 -35
- package/es/TopNavBar/TopNavBarActionItems/props.js +1 -0
- package/es/TopNavBar/TopNavBarActionItems/styles.js +0 -1
- package/es/TopNavBar/TopNavBarActionItems/theme.js +4 -4
- package/es/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +3 -5
- package/es/TopNavBar/TopNavBarBrand/index.js +6 -17
- package/es/TopNavBar/TopNavBarBrand/props.js +1 -0
- package/es/TopNavBar/TopNavBarBrand/styles.js +1 -2
- package/es/TopNavBar/TopNavBarBrand/theme.js +2 -2
- package/es/TopNavBar/TopNavBarContext.js +1 -1
- package/es/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +12 -15
- package/es/TopNavBar/TopNavBarItem/index.js +49 -136
- package/es/TopNavBar/TopNavBarItem/props.js +1 -0
- package/es/TopNavBar/TopNavBarItem/styles.js +5 -6
- package/es/TopNavBar/TopNavBarItem/theme.js +5 -5
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +3 -6
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +6 -20
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +5 -2
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -4
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +6 -6
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +8 -16
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +25 -83
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +5 -2
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +4 -5
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +6 -6
- package/es/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +3 -1
- package/es/TopNavBar/TopNavBarLayout/index.js +8 -19
- package/es/TopNavBar/TopNavBarLayout/props.js +3 -1
- package/es/TopNavBar/TopNavBarLayout/theme.js +6 -4
- package/es/TopNavBar/TopNavBarLocator.js +2 -1
- package/es/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +4 -4
- package/es/TopNavBar/TopNavBarMenuItems/index.js +9 -35
- package/es/TopNavBar/TopNavBarMenuItems/props.js +1 -0
- package/es/TopNavBar/TopNavBarMenuItems/styles.js +0 -1
- package/es/TopNavBar/TopNavBarMenuItems/theme.js +3 -3
- package/es/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +3 -1
- package/es/TopNavBar/TopNavBarUser/index.js +2 -18
- package/es/TopNavBar/TopNavBarUser/props.js +1 -0
- package/es/TopNavBar/TopNavBarUser/styles.js +0 -1
- package/es/TopNavBar/index.js +4 -12
- package/es/TopNavBar/props.js +1 -0
- package/es/TopNavBar/utils/exampleHelpers.js +9 -17
- package/es/TopNavBar/utils/exampleSvgFiles.js +1 -4
- package/es/TopNavBar/utils/mapItemsForDrilldown.js +16 -25
- package/es/index.js +1 -0
- package/lib/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +3 -6
- package/lib/TopNavBar/TopNavBarActionItems/index.js +10 -55
- package/lib/TopNavBar/TopNavBarActionItems/props.js +1 -6
- package/lib/TopNavBar/TopNavBarActionItems/styles.js +0 -2
- package/lib/TopNavBar/TopNavBarActionItems/theme.js +4 -5
- package/lib/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +1 -8
- package/lib/TopNavBar/TopNavBarBrand/index.js +6 -30
- package/lib/TopNavBar/TopNavBarBrand/props.js +1 -3
- package/lib/TopNavBar/TopNavBarBrand/styles.js +1 -3
- package/lib/TopNavBar/TopNavBarBrand/theme.js +2 -3
- package/lib/TopNavBar/TopNavBarContext.js +0 -2
- package/lib/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +5 -15
- package/lib/TopNavBar/TopNavBarItem/index.js +49 -162
- package/lib/TopNavBar/TopNavBarItem/props.js +1 -6
- package/lib/TopNavBar/TopNavBarItem/styles.js +5 -7
- package/lib/TopNavBar/TopNavBarItem/theme.js +5 -6
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +3 -15
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +6 -30
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +5 -4
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -5
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +6 -7
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +5 -21
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +25 -111
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +5 -4
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +4 -6
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +6 -7
- package/lib/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +1 -5
- package/lib/TopNavBar/TopNavBarLayout/index.js +8 -30
- package/lib/TopNavBar/TopNavBarLayout/props.js +3 -11
- package/lib/TopNavBar/TopNavBarLayout/theme.js +4 -7
- package/lib/TopNavBar/TopNavBarLocator.js +1 -3
- package/lib/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +1 -7
- package/lib/TopNavBar/TopNavBarMenuItems/index.js +9 -52
- package/lib/TopNavBar/TopNavBarMenuItems/props.js +1 -5
- package/lib/TopNavBar/TopNavBarMenuItems/styles.js +0 -2
- package/lib/TopNavBar/TopNavBarMenuItems/theme.js +3 -4
- package/lib/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +1 -3
- package/lib/TopNavBar/TopNavBarUser/index.js +2 -29
- package/lib/TopNavBar/TopNavBarUser/props.js +1 -5
- package/lib/TopNavBar/TopNavBarUser/styles.js +0 -2
- package/lib/TopNavBar/index.js +3 -27
- package/lib/TopNavBar/props.js +1 -3
- package/lib/TopNavBar/utils/exampleHelpers.js +9 -39
- package/lib/TopNavBar/utils/exampleSvgFiles.js +0 -6
- package/lib/TopNavBar/utils/mapItemsForDrilldown.js +16 -37
- package/lib/index.js +0 -1
- package/package.json +27 -27
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -1,65 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.TopNavBarItem = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
15
|
-
|
|
16
11
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
17
|
-
|
|
18
12
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
19
|
-
|
|
20
13
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
21
|
-
|
|
22
14
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
23
|
-
|
|
24
15
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
25
|
-
|
|
26
16
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
27
|
-
|
|
28
17
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
29
|
-
|
|
30
18
|
var _console = require("@instructure/console");
|
|
31
|
-
|
|
32
19
|
var _emotion = require("@instructure/emotion");
|
|
33
|
-
|
|
34
20
|
var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
|
|
35
|
-
|
|
36
21
|
var _IconArrowOpenUpSolid2 = require("@instructure/ui-icons/lib/IconArrowOpenUpSolid.js");
|
|
37
|
-
|
|
38
22
|
var _Avatar = require("@instructure/ui-avatar/lib/Avatar");
|
|
39
|
-
|
|
40
23
|
var _BaseButton = require("@instructure/ui-buttons/lib/BaseButton");
|
|
41
|
-
|
|
42
24
|
var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
|
|
43
|
-
|
|
44
25
|
var _Popover = require("@instructure/ui-popover/lib/Popover");
|
|
45
|
-
|
|
46
26
|
var _Drilldown = require("@instructure/ui-drilldown/lib/Drilldown");
|
|
47
|
-
|
|
48
27
|
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
49
|
-
|
|
50
28
|
var _TopNavBarContext = require("../TopNavBarContext");
|
|
51
|
-
|
|
52
29
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
53
|
-
|
|
54
30
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
55
|
-
|
|
56
31
|
var _props = require("./props");
|
|
57
|
-
|
|
58
32
|
var _dec, _dec2, _dec3, _class, _class2, _IconArrowOpenUpSolid, _IconArrowOpenDownSol;
|
|
59
|
-
|
|
60
33
|
const navbarStackingDefault = 10000;
|
|
61
34
|
const submenuStacking = navbarStackingDefault + 1;
|
|
62
35
|
const tooltipStacking = navbarStackingDefault + 2;
|
|
36
|
+
|
|
63
37
|
/**
|
|
64
38
|
---
|
|
65
39
|
parent: TopNavBar
|
|
@@ -68,42 +42,34 @@ id: TopNavBar.Item
|
|
|
68
42
|
@module TopNavBarItem
|
|
69
43
|
@tsProps
|
|
70
44
|
**/
|
|
71
|
-
|
|
72
45
|
let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TopNavBarItem extends _react.Component {
|
|
73
46
|
constructor(props) {
|
|
74
47
|
super(props);
|
|
75
48
|
this.ref = null;
|
|
76
49
|
this._itemRef = null;
|
|
77
50
|
this._tooltipContentId = void 0;
|
|
78
|
-
|
|
79
51
|
this.handleRef = el => {
|
|
80
52
|
const elementRef = this.props.elementRef;
|
|
81
53
|
this.ref = el;
|
|
82
|
-
|
|
83
54
|
if (typeof elementRef === 'function') {
|
|
84
55
|
elementRef(el);
|
|
85
56
|
}
|
|
86
57
|
};
|
|
87
|
-
|
|
88
58
|
this.handleItemRef = el => {
|
|
89
59
|
const itemRef = this.props.itemRef;
|
|
90
60
|
this._itemRef = el;
|
|
91
|
-
|
|
92
61
|
if (typeof itemRef === 'function') {
|
|
93
62
|
itemRef(el);
|
|
94
63
|
}
|
|
95
64
|
};
|
|
96
|
-
|
|
97
65
|
this.handleKeyDown = e => {
|
|
98
66
|
if (e.key === 'ArrowDown') {
|
|
99
67
|
if (this.shouldRenderSubmenu && !this.state.isSubmenuOpen || this.shouldRenderPopover && !this.state.isPopoverOpen) {
|
|
100
68
|
var _this$_itemRef;
|
|
101
|
-
|
|
102
69
|
e.preventDefault();
|
|
103
70
|
(_this$_itemRef = this._itemRef) === null || _this$_itemRef === void 0 ? void 0 : _this$_itemRef.click();
|
|
104
71
|
}
|
|
105
72
|
}
|
|
106
|
-
|
|
107
73
|
if (e.key === 'Tab') {
|
|
108
74
|
if (this.state.isPopoverOpen && !this.isCustomPopoverControlled) {
|
|
109
75
|
this.setState({
|
|
@@ -112,274 +78,224 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
112
78
|
}
|
|
113
79
|
}
|
|
114
80
|
};
|
|
115
|
-
|
|
116
81
|
this.handleMenuToggle = (event, args) => {
|
|
117
82
|
this.setState({
|
|
118
83
|
isSubmenuOpen: args.shown
|
|
119
84
|
});
|
|
120
|
-
|
|
121
85
|
if (typeof this.props.onSubmenuToggle === 'function') {
|
|
122
86
|
this.props.onSubmenuToggle(event, args);
|
|
123
87
|
}
|
|
124
88
|
};
|
|
125
|
-
|
|
126
89
|
this._tooltipContentId = props.deterministicId('TopNavBarItem-tooltip');
|
|
127
90
|
this.state = {
|
|
128
91
|
isSubmenuOpen: false,
|
|
129
92
|
isPopoverOpen: false
|
|
130
93
|
};
|
|
131
94
|
}
|
|
132
|
-
|
|
133
95
|
componentDidMount() {
|
|
134
96
|
const _this$props = this.props,
|
|
135
|
-
|
|
136
|
-
|
|
97
|
+
makeStyles = _this$props.makeStyles,
|
|
98
|
+
customPopoverConfig = _this$props.customPopoverConfig;
|
|
137
99
|
makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles(this.makeStylesVariables);
|
|
138
|
-
|
|
139
100
|
if (customPopoverConfig && this.isCustomPopoverControlled) {
|
|
140
101
|
this.setState({
|
|
141
102
|
isPopoverOpen: !!customPopoverConfig.isShowingContent
|
|
142
103
|
});
|
|
143
104
|
}
|
|
144
105
|
}
|
|
145
|
-
|
|
146
106
|
componentDidUpdate() {
|
|
147
107
|
const _this$props2 = this.props,
|
|
148
|
-
|
|
149
|
-
|
|
108
|
+
makeStyles = _this$props2.makeStyles,
|
|
109
|
+
customPopoverConfig = _this$props2.customPopoverConfig;
|
|
150
110
|
makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles(this.makeStylesVariables);
|
|
151
|
-
|
|
152
111
|
if (customPopoverConfig && this.isCustomPopoverControlled && customPopoverConfig.isShowingContent !== this.state.isPopoverOpen) {
|
|
153
112
|
this.setState({
|
|
154
113
|
isPopoverOpen: !!customPopoverConfig.isShowingContent
|
|
155
114
|
});
|
|
156
115
|
}
|
|
157
116
|
}
|
|
158
|
-
|
|
159
117
|
get makeStylesVariables() {
|
|
160
118
|
const _this$context = this.context,
|
|
161
|
-
|
|
162
|
-
|
|
119
|
+
layout = _this$context.layout,
|
|
120
|
+
inverseColor = _this$context.inverseColor;
|
|
163
121
|
return {
|
|
164
122
|
layout,
|
|
165
123
|
inverseColor
|
|
166
124
|
};
|
|
167
125
|
}
|
|
168
|
-
|
|
169
126
|
get shouldRenderSubmenu() {
|
|
170
127
|
const renderSubmenu = this.props.renderSubmenu;
|
|
171
128
|
return !!renderSubmenu && (0, _matchComponentTypes.matchComponentTypes)(renderSubmenu, [_Drilldown.Drilldown]);
|
|
172
129
|
}
|
|
173
|
-
|
|
174
130
|
get shouldRenderPopover() {
|
|
175
131
|
const _this$props3 = this.props,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
132
|
+
id = _this$props3.id,
|
|
133
|
+
renderSubmenu = _this$props3.renderSubmenu,
|
|
134
|
+
customPopoverConfig = _this$props3.customPopoverConfig;
|
|
180
135
|
if (!customPopoverConfig) {
|
|
181
136
|
return false;
|
|
182
137
|
}
|
|
183
|
-
|
|
184
138
|
if (!customPopoverConfig.children) {
|
|
185
139
|
(0, _console.warn)(false, `Pass the content of the custom Popover as "customPopoverConfig.children" for the item with id: "${id}".`);
|
|
186
140
|
return false;
|
|
187
141
|
}
|
|
188
|
-
|
|
189
142
|
if (customPopoverConfig && renderSubmenu) {
|
|
190
143
|
(0, _console.warn)(false, `TopNavBar.Items are not allowed to have both the "renderSubmenu" and "customPopoverConfig" props. For submenus, pass a Drilldown component via the "renderSubmenu" prop, and only use "customPopoverConfig" for custom features. Item with id: "${id}" will ignore the "customPopoverConfig" prop.`);
|
|
191
144
|
return false;
|
|
192
145
|
}
|
|
193
|
-
|
|
194
146
|
return true;
|
|
195
147
|
}
|
|
196
|
-
|
|
197
148
|
get isCustomPopoverControlled() {
|
|
198
149
|
const customPopoverConfig = this.props.customPopoverConfig;
|
|
199
150
|
return customPopoverConfig && typeof customPopoverConfig.isShowingContent !== 'undefined';
|
|
200
151
|
}
|
|
201
|
-
|
|
202
152
|
get hasOpenPopover() {
|
|
203
153
|
return this.state.isSubmenuOpen || this.state.isPopoverOpen;
|
|
204
154
|
}
|
|
205
|
-
|
|
206
155
|
get isDefaultVariant() {
|
|
207
156
|
return this.props.variant === 'default';
|
|
208
157
|
}
|
|
209
|
-
|
|
210
158
|
get isButtonVariant() {
|
|
211
159
|
return this.props.variant === 'button';
|
|
212
160
|
}
|
|
213
|
-
|
|
214
161
|
get isIconVariant() {
|
|
215
162
|
return this.props.variant === 'icon';
|
|
216
163
|
}
|
|
217
|
-
|
|
218
164
|
get isAvatarOnlyVariant() {
|
|
219
165
|
return this.props.variant === 'avatar';
|
|
220
166
|
}
|
|
221
|
-
|
|
222
167
|
get hasAvatar() {
|
|
223
168
|
const _this$props4 = this.props,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
169
|
+
id = _this$props4.id,
|
|
170
|
+
renderIcon = _this$props4.renderIcon,
|
|
171
|
+
renderAvatar = _this$props4.renderAvatar,
|
|
172
|
+
variant = _this$props4.variant;
|
|
228
173
|
const hasAvatar = !!renderAvatar;
|
|
229
|
-
|
|
230
174
|
if (this.isAvatarOnlyVariant && !hasAvatar) {
|
|
231
175
|
(0, _console.warn)(false, `The "renderAvatar" config is required for the 'variant="avatar"' type <TopNavBar.Item> components, but received none for the item with id "${id}".`);
|
|
232
176
|
return false;
|
|
233
177
|
}
|
|
234
|
-
|
|
235
178
|
if (hasAvatar && (renderIcon || variant === 'icon')) {
|
|
236
179
|
(0, _console.warn)(false, `<TopNavBar.Item> components with icons cannot display avatars, so the "renderAvatar" config prop will be ignored for item with id "${id}".`);
|
|
237
180
|
return false;
|
|
238
181
|
}
|
|
239
|
-
|
|
240
182
|
return hasAvatar;
|
|
241
183
|
}
|
|
242
|
-
|
|
243
184
|
get submenuIcon() {
|
|
244
185
|
var _this$props$styles;
|
|
245
|
-
|
|
246
186
|
if (!(this.shouldRenderSubmenu || this.shouldRenderPopover) || !this.props.showSubmenuChevron) {
|
|
247
187
|
return null;
|
|
248
188
|
}
|
|
249
|
-
|
|
250
189
|
return (0, _emotion.jsx)("span", {
|
|
251
190
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.submenuIcon
|
|
252
191
|
}, this.shouldRenderSubmenu && this.state.isSubmenuOpen || this.shouldRenderPopover && this.state.isPopoverOpen ? _IconArrowOpenUpSolid || (_IconArrowOpenUpSolid = (0, _emotion.jsx)(_IconArrowOpenUpSolid2.IconArrowOpenUpSolid, null)) : _IconArrowOpenDownSol || (_IconArrowOpenDownSol = (0, _emotion.jsx)(_IconArrowOpenDownSolid.IconArrowOpenDownSolid, null)));
|
|
253
192
|
}
|
|
254
|
-
|
|
255
193
|
get buttonThemeOverride() {
|
|
256
194
|
const styles = this.props.styles;
|
|
257
195
|
const themeOverride = {};
|
|
258
|
-
|
|
259
196
|
if (this.isDefaultVariant || this.hasAvatar) {
|
|
260
197
|
themeOverride.mediumPaddingHorizontal = styles === null || styles === void 0 ? void 0 : styles.itemInlinePadding;
|
|
261
198
|
}
|
|
262
|
-
|
|
263
199
|
if (this.hasAvatar) {
|
|
264
200
|
themeOverride.mediumPaddingTop = '0.125rem';
|
|
265
201
|
themeOverride.mediumPaddingBottom = '0.125rem';
|
|
266
202
|
}
|
|
267
|
-
|
|
268
203
|
if (this.isAvatarOnlyVariant && !this.submenuIcon) {
|
|
269
204
|
themeOverride.mediumPaddingHorizontal = '0';
|
|
270
205
|
themeOverride.mediumPaddingTop = '0';
|
|
271
206
|
themeOverride.mediumPaddingBottom = '0';
|
|
272
207
|
}
|
|
273
|
-
|
|
274
208
|
if (this.size === 'large') {
|
|
275
209
|
// we need a custom 42x42 px icon here,
|
|
276
210
|
// so that the focus ring won't be cut off
|
|
277
211
|
themeOverride.largeHeight = '2.625rem';
|
|
278
212
|
themeOverride.iconSizeLarge = '1.5rem';
|
|
279
213
|
}
|
|
280
|
-
|
|
281
214
|
return Object.keys(themeOverride).length > 0 ? themeOverride : void 0;
|
|
282
215
|
}
|
|
283
|
-
|
|
284
216
|
get colorProps() {
|
|
285
217
|
let color = 'primary-inverse';
|
|
286
218
|
let focusColor = 'inverse';
|
|
287
|
-
|
|
288
219
|
if (this.context.inverseColor) {
|
|
289
220
|
color = 'secondary';
|
|
290
221
|
focusColor = 'info';
|
|
291
|
-
|
|
292
222
|
if (this.isButtonVariant) {
|
|
293
223
|
color = 'primary';
|
|
294
224
|
}
|
|
295
225
|
}
|
|
296
|
-
|
|
297
226
|
return {
|
|
298
227
|
color,
|
|
299
228
|
focusColor
|
|
300
229
|
};
|
|
301
230
|
}
|
|
302
|
-
|
|
303
231
|
get size() {
|
|
304
232
|
return this.isIconVariant && this.context.layout === 'smallViewport' ? 'large' : 'medium';
|
|
305
233
|
}
|
|
306
|
-
|
|
307
234
|
get ariaProps() {
|
|
308
235
|
let hasPopup;
|
|
309
236
|
let expanded;
|
|
310
|
-
|
|
311
237
|
if (this.shouldRenderSubmenu) {
|
|
312
238
|
hasPopup = 'menu';
|
|
313
239
|
expanded = this.state.isSubmenuOpen;
|
|
314
240
|
}
|
|
315
|
-
|
|
316
241
|
if (this.shouldRenderPopover) {
|
|
317
242
|
hasPopup = 'true';
|
|
318
243
|
expanded = this.state.isPopoverOpen;
|
|
319
244
|
}
|
|
320
|
-
|
|
321
245
|
return {
|
|
322
246
|
'aria-haspopup': hasPopup,
|
|
323
247
|
'aria-expanded': expanded
|
|
324
248
|
};
|
|
325
249
|
}
|
|
326
|
-
|
|
327
250
|
get itemProps() {
|
|
328
251
|
const _this$props5 = this.props,
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
252
|
+
id = _this$props5.id,
|
|
253
|
+
variant = _this$props5.variant,
|
|
254
|
+
hrefOriginal = _this$props5.href,
|
|
255
|
+
onClickOriginal = _this$props5.onClick,
|
|
256
|
+
onMouseOver = _this$props5.onMouseOver,
|
|
257
|
+
onMouseOut = _this$props5.onMouseOut,
|
|
258
|
+
onFocus = _this$props5.onFocus,
|
|
259
|
+
onBlur = _this$props5.onBlur,
|
|
260
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
261
|
+
onKeyUp = _this$props5.onKeyUp,
|
|
262
|
+
renderSubmenu = _this$props5.renderSubmenu,
|
|
263
|
+
statusOriginal = _this$props5.status,
|
|
264
|
+
renderAvatar = _this$props5.renderAvatar,
|
|
265
|
+
renderIcon = _this$props5.renderIcon;
|
|
343
266
|
let href = hrefOriginal;
|
|
344
267
|
let onClick = onClickOriginal;
|
|
345
268
|
let status = statusOriginal;
|
|
346
|
-
|
|
347
269
|
if (renderSubmenu) {
|
|
348
270
|
if (href) {
|
|
349
271
|
(0, _console.warn)(false, `TopNavBar.Items with submenus are not allowed to have 'href' property, but received href "${href}" for item with the id: "${id}".`);
|
|
350
272
|
href = void 0;
|
|
351
273
|
}
|
|
352
|
-
|
|
353
274
|
if (onClick) {
|
|
354
275
|
(0, _console.warn)(false, `TopNavBar.Items with submenus are not allowed to have 'onClick' property, but received onClick for item with the id: "${id}".Use the \`onSubmenuToggle\` prop instead. OnClick: ${onClick}`);
|
|
355
276
|
onClick = void 0;
|
|
356
277
|
}
|
|
357
278
|
}
|
|
358
|
-
|
|
359
279
|
if (status === 'active' && !this.isDefaultVariant) {
|
|
360
280
|
(0, _console.warn)(false, `Only \`variant="default"\` <TopNavBar.Item> components can be set to active, but item with id "${id}" has variant: "${variant}".`);
|
|
361
281
|
status = 'default';
|
|
362
282
|
}
|
|
363
|
-
|
|
364
283
|
if (this.hasAvatar) {
|
|
365
284
|
if (!(renderAvatar !== null && renderAvatar !== void 0 && renderAvatar.avatarName)) {
|
|
366
285
|
(0, _console.error)(false, `The "avatarName" prop is required for for <TopNavBar.Item> components with avatar, but the item with id "${id}" is missing it.`);
|
|
367
286
|
return null;
|
|
368
287
|
}
|
|
369
|
-
|
|
370
288
|
if (status === 'active') {
|
|
371
289
|
(0, _console.warn)(false, `<TopNavBar.Item> components with avatar cannot have "active" status, so the "active" status on the item with id "${id}" will be ignored.`);
|
|
372
290
|
status = 'default';
|
|
373
291
|
}
|
|
374
292
|
}
|
|
375
|
-
|
|
376
293
|
if (this.isIconVariant) {
|
|
377
294
|
if (!renderIcon) {
|
|
378
295
|
(0, _console.error)(false, `The "renderIcon" prop is required for the \`variant="icon"\` type <TopNavBar.Item> components, but the item with id "${id}" is missing it.`);
|
|
379
296
|
return null;
|
|
380
297
|
}
|
|
381
298
|
}
|
|
382
|
-
|
|
383
299
|
return {
|
|
384
300
|
id,
|
|
385
301
|
...this.colorProps,
|
|
@@ -405,27 +321,21 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
405
321
|
}
|
|
406
322
|
};
|
|
407
323
|
}
|
|
408
|
-
|
|
409
324
|
renderContent() {
|
|
410
325
|
var _this$props$styles2;
|
|
411
|
-
|
|
412
326
|
const _this$props6 = this.props,
|
|
413
|
-
|
|
414
|
-
|
|
327
|
+
children = _this$props6.children,
|
|
328
|
+
styles = _this$props6.styles;
|
|
415
329
|
const itemProps = this.itemProps;
|
|
416
|
-
|
|
417
330
|
if (!itemProps) {
|
|
418
331
|
return null;
|
|
419
332
|
}
|
|
420
|
-
|
|
421
333
|
let content = children;
|
|
422
|
-
|
|
423
334
|
if (this.isAvatarOnlyVariant) {
|
|
424
335
|
content = this.renderAvatar();
|
|
425
336
|
} else if (this.isIconVariant) {
|
|
426
337
|
content = (0, _emotion.jsx)(_ScreenReaderContent.ScreenReaderContent, null, content);
|
|
427
338
|
}
|
|
428
|
-
|
|
429
339
|
const button = (0, _emotion.jsx)(_BaseButton.BaseButton, Object.assign({}, itemProps, (0, _passthroughProps.passthroughProps)((0, _omitProps.omitProps)(this.props, _props.allowedProps))), this.isIconVariant && !this.submenuIcon ? content : (0, _emotion.jsx)("div", {
|
|
430
340
|
css: styles === null || styles === void 0 ? void 0 : styles.content
|
|
431
341
|
}, this.hasAvatar && !this.isAvatarOnlyVariant && (0, _emotion.jsx)("span", {
|
|
@@ -435,35 +345,29 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
435
345
|
css: styles === null || styles === void 0 ? void 0 : styles.container
|
|
436
346
|
}, this.props.tooltip ? this.wrapButtonInTooltip(button, children) : button);
|
|
437
347
|
}
|
|
438
|
-
|
|
439
348
|
wrapButtonInTooltip(button, content) {
|
|
440
349
|
const _this$props7 = this.props,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
350
|
+
tooltip = _this$props7.tooltip,
|
|
351
|
+
styles = _this$props7.styles;
|
|
444
352
|
if (!tooltip) {
|
|
445
353
|
return button;
|
|
446
354
|
}
|
|
447
|
-
|
|
448
355
|
let tooltipProps = {
|
|
449
356
|
placement: 'bottom',
|
|
450
357
|
color: this.context.inverseColor ? 'primary' : 'primary-inverse'
|
|
451
358
|
};
|
|
452
|
-
|
|
453
359
|
if (typeof tooltip === 'string') {
|
|
454
360
|
tooltipProps.renderTip = tooltip;
|
|
455
361
|
} else {
|
|
456
|
-
tooltipProps = {
|
|
362
|
+
tooltipProps = {
|
|
363
|
+
...tooltipProps,
|
|
457
364
|
...tooltip
|
|
458
365
|
};
|
|
459
366
|
}
|
|
460
|
-
|
|
461
367
|
const tipContent = (0, _callRenderProp.callRenderProp)(tooltipProps.renderTip);
|
|
462
|
-
|
|
463
368
|
if (!tipContent) {
|
|
464
369
|
return button;
|
|
465
370
|
}
|
|
466
|
-
|
|
467
371
|
const contentAndTooltipIdentical = tipContent === content;
|
|
468
372
|
return (0, _emotion.jsx)(_emotion.InstUISettingsProvider, {
|
|
469
373
|
theme: {
|
|
@@ -485,26 +389,22 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
485
389
|
'aria-describedby': this._tooltipContentId
|
|
486
390
|
}))));
|
|
487
391
|
}
|
|
488
|
-
|
|
489
392
|
renderAvatar() {
|
|
490
393
|
if (!this.hasAvatar) {
|
|
491
394
|
return null;
|
|
492
395
|
}
|
|
493
|
-
|
|
494
396
|
const _this$props8 = this.props,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
397
|
+
id = _this$props8.id,
|
|
398
|
+
children = _this$props8.children,
|
|
399
|
+
renderAvatar = _this$props8.renderAvatar;
|
|
498
400
|
const _ref = renderAvatar,
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
401
|
+
avatarName = _ref.avatarName,
|
|
402
|
+
avatarSrc = _ref.avatarSrc,
|
|
403
|
+
avatarAlt = _ref.avatarAlt;
|
|
502
404
|
const label = avatarAlt || (typeof children === 'string' ? children : void 0);
|
|
503
|
-
|
|
504
405
|
if (!label) {
|
|
505
406
|
(0, _console.warn)(false, `Please supply a label for the avatar with either the "renderAvatar.avatarAlt" or the "children" (as string) prop. It is needed for screen reader support, but missing on the item with the id: "${id}".`);
|
|
506
407
|
}
|
|
507
|
-
|
|
508
408
|
return avatarName ? (0, _emotion.jsx)(_Avatar.Avatar, {
|
|
509
409
|
name: avatarName,
|
|
510
410
|
src: avatarSrc,
|
|
@@ -512,28 +412,22 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
512
412
|
size: "small"
|
|
513
413
|
}) : null;
|
|
514
414
|
}
|
|
515
|
-
|
|
516
415
|
renderDropdownMenu() {
|
|
517
416
|
var _renderSubmenu$props, _renderSubmenu$props2, _renderSubmenu$props3;
|
|
518
|
-
|
|
519
417
|
const _this$props9 = this.props,
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
418
|
+
id = _this$props9.id,
|
|
419
|
+
renderSubmenu = _this$props9.renderSubmenu,
|
|
420
|
+
status = _this$props9.status,
|
|
421
|
+
styles = _this$props9.styles;
|
|
525
422
|
if (!renderSubmenu || !this.shouldRenderSubmenu) {
|
|
526
423
|
return null;
|
|
527
424
|
}
|
|
528
|
-
|
|
529
425
|
if (typeof renderSubmenu.props.show !== 'undefined') {
|
|
530
426
|
(0, _console.warn)(false, `TopNavBar.Item Drilldown submenus are controlled by the component. The "show" prop will be ignored on the submenu of the item with id: "${id}".`);
|
|
531
427
|
}
|
|
532
|
-
|
|
533
428
|
if (renderSubmenu.props.trigger) {
|
|
534
429
|
(0, _console.warn)(false, `TopNavBar.Item submenus have the item itself as their trigger. The "trigger" prop will be ignored on the Drilldown submenu of item with id: "${id}".`);
|
|
535
430
|
}
|
|
536
|
-
|
|
537
431
|
return (0, _safeCloneElement.safeCloneElement)(renderSubmenu, {
|
|
538
432
|
trigger: (0, _emotion.jsx)("div", {
|
|
539
433
|
css: styles === null || styles === void 0 ? void 0 : styles.submenuTriggerContainer
|
|
@@ -552,22 +446,19 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
552
446
|
})
|
|
553
447
|
});
|
|
554
448
|
}
|
|
555
|
-
|
|
556
449
|
renderPopover() {
|
|
557
450
|
const _this$props10 = this.props,
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
451
|
+
id = _this$props10.id,
|
|
452
|
+
customPopoverConfig = _this$props10.customPopoverConfig,
|
|
453
|
+
styles = _this$props10.styles;
|
|
562
454
|
if (!customPopoverConfig || !this.shouldRenderPopover) {
|
|
563
455
|
return null;
|
|
564
|
-
}
|
|
565
|
-
|
|
456
|
+
}
|
|
566
457
|
|
|
458
|
+
// @ts-expect-error throw a warning just in case they pass trigger
|
|
567
459
|
if (customPopoverConfig.renderTrigger) {
|
|
568
460
|
(0, _console.warn)(false, `TopNavBar.Item popovers have the item itself as their trigger. The "renderTrigger" prop will be ignored on the popover of item with id: "${id}".`);
|
|
569
461
|
}
|
|
570
|
-
|
|
571
462
|
const popoverProps = {
|
|
572
463
|
// defaults:
|
|
573
464
|
placement: 'bottom start',
|
|
@@ -603,11 +494,9 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
603
494
|
};
|
|
604
495
|
return (0, _emotion.jsx)(_Popover.Popover, popoverProps, customPopoverConfig.children);
|
|
605
496
|
}
|
|
606
|
-
|
|
607
497
|
render() {
|
|
608
498
|
const styles = this.props.styles;
|
|
609
499
|
let content;
|
|
610
|
-
|
|
611
500
|
if (this.shouldRenderPopover) {
|
|
612
501
|
content = (0, _emotion.jsx)(_emotion.InstUISettingsProvider, {
|
|
613
502
|
theme: {
|
|
@@ -633,13 +522,11 @@ let TopNavBarItem = (_dec = (0, _withDeterministicId.withDeterministicId)(), _de
|
|
|
633
522
|
} else {
|
|
634
523
|
content = this.renderContent();
|
|
635
524
|
}
|
|
636
|
-
|
|
637
525
|
return (0, _emotion.jsx)("div", {
|
|
638
526
|
ref: this.handleRef,
|
|
639
527
|
css: styles === null || styles === void 0 ? void 0 : styles.topNavBarItem
|
|
640
528
|
}, content);
|
|
641
529
|
}
|
|
642
|
-
|
|
643
530
|
}, _class2.displayName = "TopNavBarItem", _class2.componentId = 'TopNavBar.Item', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
644
531
|
status: 'default',
|
|
645
532
|
variant: 'default',
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.topNavBarItemTooltipPropType = exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
-
|
|
14
10
|
var _Drilldown = require("@instructure/ui-drilldown/lib/Drilldown");
|
|
15
|
-
|
|
16
11
|
/*
|
|
17
12
|
* The MIT License (MIT)
|
|
18
13
|
*
|
|
@@ -36,6 +31,7 @@ var _Drilldown = require("@instructure/ui-drilldown/lib/Drilldown");
|
|
|
36
31
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
32
|
* SOFTWARE.
|
|
38
33
|
*/
|
|
34
|
+
|
|
39
35
|
const topNavBarItemTooltipPropType = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.shape({
|
|
40
36
|
renderTip: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
41
37
|
color: _propTypes.default.oneOf(['primary', 'primary-inverse']),
|
|
@@ -45,7 +41,6 @@ const topNavBarItemTooltipPropType = _propTypes.default.oneOfType([_propTypes.de
|
|
|
45
41
|
onShowContent: _propTypes.default.func,
|
|
46
42
|
onHideContent: _propTypes.default.func
|
|
47
43
|
})]);
|
|
48
|
-
|
|
49
44
|
exports.topNavBarItemTooltipPropType = topNavBarItemTooltipPropType;
|
|
50
45
|
const propTypes = {
|
|
51
46
|
id: _propTypes.default.string.isRequired,
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,12 +40,12 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props, state) => {
|
|
43
42
|
const status = props.status,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
variant = props.variant,
|
|
44
|
+
renderSubmenu = props.renderSubmenu,
|
|
45
|
+
renderAvatar = props.renderAvatar,
|
|
46
|
+
customPopoverConfig = props.customPopoverConfig;
|
|
48
47
|
const layout = state.layout,
|
|
49
|
-
|
|
48
|
+
inverseColor = state.inverseColor;
|
|
50
49
|
const isSmallViewport = layout === 'smallViewport';
|
|
51
50
|
const isActive = renderAvatar ? false : status === 'active' && variant === 'default';
|
|
52
51
|
const hasPopover = renderSubmenu || customPopoverConfig;
|
|
@@ -127,6 +126,5 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
127
126
|
itemInlinePadding: componentTheme.itemInlinePadding
|
|
128
127
|
};
|
|
129
128
|
};
|
|
130
|
-
|
|
131
129
|
var _default = generateStyle;
|
|
132
130
|
exports.default = _default;
|