@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,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _dec3, _class, _class2, _IconArrowOpenUpSolid, _IconArrowOpenDownSol;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -45,6 +44,7 @@ import { propTypes, allowedProps } from './props';
|
|
|
45
44
|
const navbarStackingDefault = 10000;
|
|
46
45
|
const submenuStacking = navbarStackingDefault + 1;
|
|
47
46
|
const tooltipStacking = navbarStackingDefault + 2;
|
|
47
|
+
|
|
48
48
|
/**
|
|
49
49
|
---
|
|
50
50
|
parent: TopNavBar
|
|
@@ -53,42 +53,34 @@ id: TopNavBar.Item
|
|
|
53
53
|
@module TopNavBarItem
|
|
54
54
|
@tsProps
|
|
55
55
|
**/
|
|
56
|
-
|
|
57
56
|
let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TopNavBarItem extends Component {
|
|
58
57
|
constructor(props) {
|
|
59
58
|
super(props);
|
|
60
59
|
this.ref = null;
|
|
61
60
|
this._itemRef = null;
|
|
62
61
|
this._tooltipContentId = void 0;
|
|
63
|
-
|
|
64
62
|
this.handleRef = el => {
|
|
65
63
|
const elementRef = this.props.elementRef;
|
|
66
64
|
this.ref = el;
|
|
67
|
-
|
|
68
65
|
if (typeof elementRef === 'function') {
|
|
69
66
|
elementRef(el);
|
|
70
67
|
}
|
|
71
68
|
};
|
|
72
|
-
|
|
73
69
|
this.handleItemRef = el => {
|
|
74
70
|
const itemRef = this.props.itemRef;
|
|
75
71
|
this._itemRef = el;
|
|
76
|
-
|
|
77
72
|
if (typeof itemRef === 'function') {
|
|
78
73
|
itemRef(el);
|
|
79
74
|
}
|
|
80
75
|
};
|
|
81
|
-
|
|
82
76
|
this.handleKeyDown = e => {
|
|
83
77
|
if (e.key === 'ArrowDown') {
|
|
84
78
|
if (this.shouldRenderSubmenu && !this.state.isSubmenuOpen || this.shouldRenderPopover && !this.state.isPopoverOpen) {
|
|
85
79
|
var _this$_itemRef;
|
|
86
|
-
|
|
87
80
|
e.preventDefault();
|
|
88
81
|
(_this$_itemRef = this._itemRef) === null || _this$_itemRef === void 0 ? void 0 : _this$_itemRef.click();
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
|
-
|
|
92
84
|
if (e.key === 'Tab') {
|
|
93
85
|
if (this.state.isPopoverOpen && !this.isCustomPopoverControlled) {
|
|
94
86
|
this.setState({
|
|
@@ -97,274 +89,224 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
97
89
|
}
|
|
98
90
|
}
|
|
99
91
|
};
|
|
100
|
-
|
|
101
92
|
this.handleMenuToggle = (event, args) => {
|
|
102
93
|
this.setState({
|
|
103
94
|
isSubmenuOpen: args.shown
|
|
104
95
|
});
|
|
105
|
-
|
|
106
96
|
if (typeof this.props.onSubmenuToggle === 'function') {
|
|
107
97
|
this.props.onSubmenuToggle(event, args);
|
|
108
98
|
}
|
|
109
99
|
};
|
|
110
|
-
|
|
111
100
|
this._tooltipContentId = props.deterministicId('TopNavBarItem-tooltip');
|
|
112
101
|
this.state = {
|
|
113
102
|
isSubmenuOpen: false,
|
|
114
103
|
isPopoverOpen: false
|
|
115
104
|
};
|
|
116
105
|
}
|
|
117
|
-
|
|
118
106
|
componentDidMount() {
|
|
119
107
|
const _this$props = this.props,
|
|
120
|
-
|
|
121
|
-
|
|
108
|
+
makeStyles = _this$props.makeStyles,
|
|
109
|
+
customPopoverConfig = _this$props.customPopoverConfig;
|
|
122
110
|
makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles(this.makeStylesVariables);
|
|
123
|
-
|
|
124
111
|
if (customPopoverConfig && this.isCustomPopoverControlled) {
|
|
125
112
|
this.setState({
|
|
126
113
|
isPopoverOpen: !!customPopoverConfig.isShowingContent
|
|
127
114
|
});
|
|
128
115
|
}
|
|
129
116
|
}
|
|
130
|
-
|
|
131
117
|
componentDidUpdate() {
|
|
132
118
|
const _this$props2 = this.props,
|
|
133
|
-
|
|
134
|
-
|
|
119
|
+
makeStyles = _this$props2.makeStyles,
|
|
120
|
+
customPopoverConfig = _this$props2.customPopoverConfig;
|
|
135
121
|
makeStyles === null || makeStyles === void 0 ? void 0 : makeStyles(this.makeStylesVariables);
|
|
136
|
-
|
|
137
122
|
if (customPopoverConfig && this.isCustomPopoverControlled && customPopoverConfig.isShowingContent !== this.state.isPopoverOpen) {
|
|
138
123
|
this.setState({
|
|
139
124
|
isPopoverOpen: !!customPopoverConfig.isShowingContent
|
|
140
125
|
});
|
|
141
126
|
}
|
|
142
127
|
}
|
|
143
|
-
|
|
144
128
|
get makeStylesVariables() {
|
|
145
129
|
const _this$context = this.context,
|
|
146
|
-
|
|
147
|
-
|
|
130
|
+
layout = _this$context.layout,
|
|
131
|
+
inverseColor = _this$context.inverseColor;
|
|
148
132
|
return {
|
|
149
133
|
layout,
|
|
150
134
|
inverseColor
|
|
151
135
|
};
|
|
152
136
|
}
|
|
153
|
-
|
|
154
137
|
get shouldRenderSubmenu() {
|
|
155
138
|
const renderSubmenu = this.props.renderSubmenu;
|
|
156
139
|
return !!renderSubmenu && matchComponentTypes(renderSubmenu, [Drilldown]);
|
|
157
140
|
}
|
|
158
|
-
|
|
159
141
|
get shouldRenderPopover() {
|
|
160
142
|
const _this$props3 = this.props,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
143
|
+
id = _this$props3.id,
|
|
144
|
+
renderSubmenu = _this$props3.renderSubmenu,
|
|
145
|
+
customPopoverConfig = _this$props3.customPopoverConfig;
|
|
165
146
|
if (!customPopoverConfig) {
|
|
166
147
|
return false;
|
|
167
148
|
}
|
|
168
|
-
|
|
169
149
|
if (!customPopoverConfig.children) {
|
|
170
150
|
warn(false, `Pass the content of the custom Popover as "customPopoverConfig.children" for the item with id: "${id}".`);
|
|
171
151
|
return false;
|
|
172
152
|
}
|
|
173
|
-
|
|
174
153
|
if (customPopoverConfig && renderSubmenu) {
|
|
175
154
|
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.`);
|
|
176
155
|
return false;
|
|
177
156
|
}
|
|
178
|
-
|
|
179
157
|
return true;
|
|
180
158
|
}
|
|
181
|
-
|
|
182
159
|
get isCustomPopoverControlled() {
|
|
183
160
|
const customPopoverConfig = this.props.customPopoverConfig;
|
|
184
161
|
return customPopoverConfig && typeof customPopoverConfig.isShowingContent !== 'undefined';
|
|
185
162
|
}
|
|
186
|
-
|
|
187
163
|
get hasOpenPopover() {
|
|
188
164
|
return this.state.isSubmenuOpen || this.state.isPopoverOpen;
|
|
189
165
|
}
|
|
190
|
-
|
|
191
166
|
get isDefaultVariant() {
|
|
192
167
|
return this.props.variant === 'default';
|
|
193
168
|
}
|
|
194
|
-
|
|
195
169
|
get isButtonVariant() {
|
|
196
170
|
return this.props.variant === 'button';
|
|
197
171
|
}
|
|
198
|
-
|
|
199
172
|
get isIconVariant() {
|
|
200
173
|
return this.props.variant === 'icon';
|
|
201
174
|
}
|
|
202
|
-
|
|
203
175
|
get isAvatarOnlyVariant() {
|
|
204
176
|
return this.props.variant === 'avatar';
|
|
205
177
|
}
|
|
206
|
-
|
|
207
178
|
get hasAvatar() {
|
|
208
179
|
const _this$props4 = this.props,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
180
|
+
id = _this$props4.id,
|
|
181
|
+
renderIcon = _this$props4.renderIcon,
|
|
182
|
+
renderAvatar = _this$props4.renderAvatar,
|
|
183
|
+
variant = _this$props4.variant;
|
|
213
184
|
const hasAvatar = !!renderAvatar;
|
|
214
|
-
|
|
215
185
|
if (this.isAvatarOnlyVariant && !hasAvatar) {
|
|
216
186
|
warn(false, `The "renderAvatar" config is required for the 'variant="avatar"' type <TopNavBar.Item> components, but received none for the item with id "${id}".`);
|
|
217
187
|
return false;
|
|
218
188
|
}
|
|
219
|
-
|
|
220
189
|
if (hasAvatar && (renderIcon || variant === 'icon')) {
|
|
221
190
|
warn(false, `<TopNavBar.Item> components with icons cannot display avatars, so the "renderAvatar" config prop will be ignored for item with id "${id}".`);
|
|
222
191
|
return false;
|
|
223
192
|
}
|
|
224
|
-
|
|
225
193
|
return hasAvatar;
|
|
226
194
|
}
|
|
227
|
-
|
|
228
195
|
get submenuIcon() {
|
|
229
196
|
var _this$props$styles;
|
|
230
|
-
|
|
231
197
|
if (!(this.shouldRenderSubmenu || this.shouldRenderPopover) || !this.props.showSubmenuChevron) {
|
|
232
198
|
return null;
|
|
233
199
|
}
|
|
234
|
-
|
|
235
200
|
return jsx("span", {
|
|
236
201
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.submenuIcon
|
|
237
202
|
}, this.shouldRenderSubmenu && this.state.isSubmenuOpen || this.shouldRenderPopover && this.state.isPopoverOpen ? _IconArrowOpenUpSolid || (_IconArrowOpenUpSolid = jsx(IconArrowOpenUpSolid, null)) : _IconArrowOpenDownSol || (_IconArrowOpenDownSol = jsx(IconArrowOpenDownSolid, null)));
|
|
238
203
|
}
|
|
239
|
-
|
|
240
204
|
get buttonThemeOverride() {
|
|
241
205
|
const styles = this.props.styles;
|
|
242
206
|
const themeOverride = {};
|
|
243
|
-
|
|
244
207
|
if (this.isDefaultVariant || this.hasAvatar) {
|
|
245
208
|
themeOverride.mediumPaddingHorizontal = styles === null || styles === void 0 ? void 0 : styles.itemInlinePadding;
|
|
246
209
|
}
|
|
247
|
-
|
|
248
210
|
if (this.hasAvatar) {
|
|
249
211
|
themeOverride.mediumPaddingTop = '0.125rem';
|
|
250
212
|
themeOverride.mediumPaddingBottom = '0.125rem';
|
|
251
213
|
}
|
|
252
|
-
|
|
253
214
|
if (this.isAvatarOnlyVariant && !this.submenuIcon) {
|
|
254
215
|
themeOverride.mediumPaddingHorizontal = '0';
|
|
255
216
|
themeOverride.mediumPaddingTop = '0';
|
|
256
217
|
themeOverride.mediumPaddingBottom = '0';
|
|
257
218
|
}
|
|
258
|
-
|
|
259
219
|
if (this.size === 'large') {
|
|
260
220
|
// we need a custom 42x42 px icon here,
|
|
261
221
|
// so that the focus ring won't be cut off
|
|
262
222
|
themeOverride.largeHeight = '2.625rem';
|
|
263
223
|
themeOverride.iconSizeLarge = '1.5rem';
|
|
264
224
|
}
|
|
265
|
-
|
|
266
225
|
return Object.keys(themeOverride).length > 0 ? themeOverride : void 0;
|
|
267
226
|
}
|
|
268
|
-
|
|
269
227
|
get colorProps() {
|
|
270
228
|
let color = 'primary-inverse';
|
|
271
229
|
let focusColor = 'inverse';
|
|
272
|
-
|
|
273
230
|
if (this.context.inverseColor) {
|
|
274
231
|
color = 'secondary';
|
|
275
232
|
focusColor = 'info';
|
|
276
|
-
|
|
277
233
|
if (this.isButtonVariant) {
|
|
278
234
|
color = 'primary';
|
|
279
235
|
}
|
|
280
236
|
}
|
|
281
|
-
|
|
282
237
|
return {
|
|
283
238
|
color,
|
|
284
239
|
focusColor
|
|
285
240
|
};
|
|
286
241
|
}
|
|
287
|
-
|
|
288
242
|
get size() {
|
|
289
243
|
return this.isIconVariant && this.context.layout === 'smallViewport' ? 'large' : 'medium';
|
|
290
244
|
}
|
|
291
|
-
|
|
292
245
|
get ariaProps() {
|
|
293
246
|
let hasPopup;
|
|
294
247
|
let expanded;
|
|
295
|
-
|
|
296
248
|
if (this.shouldRenderSubmenu) {
|
|
297
249
|
hasPopup = 'menu';
|
|
298
250
|
expanded = this.state.isSubmenuOpen;
|
|
299
251
|
}
|
|
300
|
-
|
|
301
252
|
if (this.shouldRenderPopover) {
|
|
302
253
|
hasPopup = 'true';
|
|
303
254
|
expanded = this.state.isPopoverOpen;
|
|
304
255
|
}
|
|
305
|
-
|
|
306
256
|
return {
|
|
307
257
|
'aria-haspopup': hasPopup,
|
|
308
258
|
'aria-expanded': expanded
|
|
309
259
|
};
|
|
310
260
|
}
|
|
311
|
-
|
|
312
261
|
get itemProps() {
|
|
313
262
|
const _this$props5 = this.props,
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
263
|
+
id = _this$props5.id,
|
|
264
|
+
variant = _this$props5.variant,
|
|
265
|
+
hrefOriginal = _this$props5.href,
|
|
266
|
+
onClickOriginal = _this$props5.onClick,
|
|
267
|
+
onMouseOver = _this$props5.onMouseOver,
|
|
268
|
+
onMouseOut = _this$props5.onMouseOut,
|
|
269
|
+
onFocus = _this$props5.onFocus,
|
|
270
|
+
onBlur = _this$props5.onBlur,
|
|
271
|
+
onKeyDown = _this$props5.onKeyDown,
|
|
272
|
+
onKeyUp = _this$props5.onKeyUp,
|
|
273
|
+
renderSubmenu = _this$props5.renderSubmenu,
|
|
274
|
+
statusOriginal = _this$props5.status,
|
|
275
|
+
renderAvatar = _this$props5.renderAvatar,
|
|
276
|
+
renderIcon = _this$props5.renderIcon;
|
|
328
277
|
let href = hrefOriginal;
|
|
329
278
|
let onClick = onClickOriginal;
|
|
330
279
|
let status = statusOriginal;
|
|
331
|
-
|
|
332
280
|
if (renderSubmenu) {
|
|
333
281
|
if (href) {
|
|
334
282
|
warn(false, `TopNavBar.Items with submenus are not allowed to have 'href' property, but received href "${href}" for item with the id: "${id}".`);
|
|
335
283
|
href = void 0;
|
|
336
284
|
}
|
|
337
|
-
|
|
338
285
|
if (onClick) {
|
|
339
286
|
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}`);
|
|
340
287
|
onClick = void 0;
|
|
341
288
|
}
|
|
342
289
|
}
|
|
343
|
-
|
|
344
290
|
if (status === 'active' && !this.isDefaultVariant) {
|
|
345
291
|
warn(false, `Only \`variant="default"\` <TopNavBar.Item> components can be set to active, but item with id "${id}" has variant: "${variant}".`);
|
|
346
292
|
status = 'default';
|
|
347
293
|
}
|
|
348
|
-
|
|
349
294
|
if (this.hasAvatar) {
|
|
350
295
|
if (!(renderAvatar !== null && renderAvatar !== void 0 && renderAvatar.avatarName)) {
|
|
351
296
|
error(false, `The "avatarName" prop is required for for <TopNavBar.Item> components with avatar, but the item with id "${id}" is missing it.`);
|
|
352
297
|
return null;
|
|
353
298
|
}
|
|
354
|
-
|
|
355
299
|
if (status === 'active') {
|
|
356
300
|
warn(false, `<TopNavBar.Item> components with avatar cannot have "active" status, so the "active" status on the item with id "${id}" will be ignored.`);
|
|
357
301
|
status = 'default';
|
|
358
302
|
}
|
|
359
303
|
}
|
|
360
|
-
|
|
361
304
|
if (this.isIconVariant) {
|
|
362
305
|
if (!renderIcon) {
|
|
363
306
|
error(false, `The "renderIcon" prop is required for the \`variant="icon"\` type <TopNavBar.Item> components, but the item with id "${id}" is missing it.`);
|
|
364
307
|
return null;
|
|
365
308
|
}
|
|
366
309
|
}
|
|
367
|
-
|
|
368
310
|
return {
|
|
369
311
|
id,
|
|
370
312
|
...this.colorProps,
|
|
@@ -390,27 +332,21 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
390
332
|
}
|
|
391
333
|
};
|
|
392
334
|
}
|
|
393
|
-
|
|
394
335
|
renderContent() {
|
|
395
336
|
var _this$props$styles2;
|
|
396
|
-
|
|
397
337
|
const _this$props6 = this.props,
|
|
398
|
-
|
|
399
|
-
|
|
338
|
+
children = _this$props6.children,
|
|
339
|
+
styles = _this$props6.styles;
|
|
400
340
|
const itemProps = this.itemProps;
|
|
401
|
-
|
|
402
341
|
if (!itemProps) {
|
|
403
342
|
return null;
|
|
404
343
|
}
|
|
405
|
-
|
|
406
344
|
let content = children;
|
|
407
|
-
|
|
408
345
|
if (this.isAvatarOnlyVariant) {
|
|
409
346
|
content = this.renderAvatar();
|
|
410
347
|
} else if (this.isIconVariant) {
|
|
411
348
|
content = jsx(ScreenReaderContent, null, content);
|
|
412
349
|
}
|
|
413
|
-
|
|
414
350
|
const button = jsx(BaseButton, Object.assign({}, itemProps, passthroughProps(omitProps(this.props, allowedProps))), this.isIconVariant && !this.submenuIcon ? content : jsx("div", {
|
|
415
351
|
css: styles === null || styles === void 0 ? void 0 : styles.content
|
|
416
352
|
}, this.hasAvatar && !this.isAvatarOnlyVariant && jsx("span", {
|
|
@@ -420,35 +356,29 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
420
356
|
css: styles === null || styles === void 0 ? void 0 : styles.container
|
|
421
357
|
}, this.props.tooltip ? this.wrapButtonInTooltip(button, children) : button);
|
|
422
358
|
}
|
|
423
|
-
|
|
424
359
|
wrapButtonInTooltip(button, content) {
|
|
425
360
|
const _this$props7 = this.props,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
361
|
+
tooltip = _this$props7.tooltip,
|
|
362
|
+
styles = _this$props7.styles;
|
|
429
363
|
if (!tooltip) {
|
|
430
364
|
return button;
|
|
431
365
|
}
|
|
432
|
-
|
|
433
366
|
let tooltipProps = {
|
|
434
367
|
placement: 'bottom',
|
|
435
368
|
color: this.context.inverseColor ? 'primary' : 'primary-inverse'
|
|
436
369
|
};
|
|
437
|
-
|
|
438
370
|
if (typeof tooltip === 'string') {
|
|
439
371
|
tooltipProps.renderTip = tooltip;
|
|
440
372
|
} else {
|
|
441
|
-
tooltipProps = {
|
|
373
|
+
tooltipProps = {
|
|
374
|
+
...tooltipProps,
|
|
442
375
|
...tooltip
|
|
443
376
|
};
|
|
444
377
|
}
|
|
445
|
-
|
|
446
378
|
const tipContent = callRenderProp(tooltipProps.renderTip);
|
|
447
|
-
|
|
448
379
|
if (!tipContent) {
|
|
449
380
|
return button;
|
|
450
381
|
}
|
|
451
|
-
|
|
452
382
|
const contentAndTooltipIdentical = tipContent === content;
|
|
453
383
|
return jsx(InstUISettingsProvider, {
|
|
454
384
|
theme: {
|
|
@@ -470,26 +400,22 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
470
400
|
'aria-describedby': this._tooltipContentId
|
|
471
401
|
}))));
|
|
472
402
|
}
|
|
473
|
-
|
|
474
403
|
renderAvatar() {
|
|
475
404
|
if (!this.hasAvatar) {
|
|
476
405
|
return null;
|
|
477
406
|
}
|
|
478
|
-
|
|
479
407
|
const _this$props8 = this.props,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
408
|
+
id = _this$props8.id,
|
|
409
|
+
children = _this$props8.children,
|
|
410
|
+
renderAvatar = _this$props8.renderAvatar;
|
|
483
411
|
const _ref = renderAvatar,
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
412
|
+
avatarName = _ref.avatarName,
|
|
413
|
+
avatarSrc = _ref.avatarSrc,
|
|
414
|
+
avatarAlt = _ref.avatarAlt;
|
|
487
415
|
const label = avatarAlt || (typeof children === 'string' ? children : void 0);
|
|
488
|
-
|
|
489
416
|
if (!label) {
|
|
490
417
|
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}".`);
|
|
491
418
|
}
|
|
492
|
-
|
|
493
419
|
return avatarName ? jsx(Avatar, {
|
|
494
420
|
name: avatarName,
|
|
495
421
|
src: avatarSrc,
|
|
@@ -497,28 +423,22 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
497
423
|
size: "small"
|
|
498
424
|
}) : null;
|
|
499
425
|
}
|
|
500
|
-
|
|
501
426
|
renderDropdownMenu() {
|
|
502
427
|
var _renderSubmenu$props, _renderSubmenu$props2, _renderSubmenu$props3;
|
|
503
|
-
|
|
504
428
|
const _this$props9 = this.props,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
429
|
+
id = _this$props9.id,
|
|
430
|
+
renderSubmenu = _this$props9.renderSubmenu,
|
|
431
|
+
status = _this$props9.status,
|
|
432
|
+
styles = _this$props9.styles;
|
|
510
433
|
if (!renderSubmenu || !this.shouldRenderSubmenu) {
|
|
511
434
|
return null;
|
|
512
435
|
}
|
|
513
|
-
|
|
514
436
|
if (typeof renderSubmenu.props.show !== 'undefined') {
|
|
515
437
|
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}".`);
|
|
516
438
|
}
|
|
517
|
-
|
|
518
439
|
if (renderSubmenu.props.trigger) {
|
|
519
440
|
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}".`);
|
|
520
441
|
}
|
|
521
|
-
|
|
522
442
|
return safeCloneElement(renderSubmenu, {
|
|
523
443
|
trigger: jsx("div", {
|
|
524
444
|
css: styles === null || styles === void 0 ? void 0 : styles.submenuTriggerContainer
|
|
@@ -537,22 +457,19 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
537
457
|
})
|
|
538
458
|
});
|
|
539
459
|
}
|
|
540
|
-
|
|
541
460
|
renderPopover() {
|
|
542
461
|
const _this$props10 = this.props,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
462
|
+
id = _this$props10.id,
|
|
463
|
+
customPopoverConfig = _this$props10.customPopoverConfig,
|
|
464
|
+
styles = _this$props10.styles;
|
|
547
465
|
if (!customPopoverConfig || !this.shouldRenderPopover) {
|
|
548
466
|
return null;
|
|
549
|
-
}
|
|
550
|
-
|
|
467
|
+
}
|
|
551
468
|
|
|
469
|
+
// @ts-expect-error throw a warning just in case they pass trigger
|
|
552
470
|
if (customPopoverConfig.renderTrigger) {
|
|
553
471
|
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}".`);
|
|
554
472
|
}
|
|
555
|
-
|
|
556
473
|
const popoverProps = {
|
|
557
474
|
// defaults:
|
|
558
475
|
placement: 'bottom start',
|
|
@@ -588,11 +505,9 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
588
505
|
};
|
|
589
506
|
return jsx(Popover, popoverProps, customPopoverConfig.children);
|
|
590
507
|
}
|
|
591
|
-
|
|
592
508
|
render() {
|
|
593
509
|
const styles = this.props.styles;
|
|
594
510
|
let content;
|
|
595
|
-
|
|
596
511
|
if (this.shouldRenderPopover) {
|
|
597
512
|
content = jsx(InstUISettingsProvider, {
|
|
598
513
|
theme: {
|
|
@@ -618,13 +533,11 @@ let TopNavBarItem = (_dec = withDeterministicId(), _dec2 = withStyle(generateSty
|
|
|
618
533
|
} else {
|
|
619
534
|
content = this.renderContent();
|
|
620
535
|
}
|
|
621
|
-
|
|
622
536
|
return jsx("div", {
|
|
623
537
|
ref: this.handleRef,
|
|
624
538
|
css: styles === null || styles === void 0 ? void 0 : styles.topNavBarItem
|
|
625
539
|
}, content);
|
|
626
540
|
}
|
|
627
|
-
|
|
628
541
|
}, _class2.displayName = "TopNavBarItem", _class2.componentId = 'TopNavBar.Item', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
629
542
|
status: 'default',
|
|
630
543
|
variant: 'default',
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { Drilldown } from '@instructure/ui-drilldown';
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
36
|
const status = props.status,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
variant = props.variant,
|
|
38
|
+
renderSubmenu = props.renderSubmenu,
|
|
39
|
+
renderAvatar = props.renderAvatar,
|
|
40
|
+
customPopoverConfig = props.customPopoverConfig;
|
|
41
41
|
const layout = state.layout,
|
|
42
|
-
|
|
42
|
+
inverseColor = state.inverseColor;
|
|
43
43
|
const isSmallViewport = layout === 'smallViewport';
|
|
44
44
|
const isActive = renderAvatar ? false : status === 'active' && variant === 'default';
|
|
45
45
|
const hasPopover = renderSubmenu || customPopoverConfig;
|
|
@@ -120,5 +120,4 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
120
120
|
itemInlinePadding: componentTheme.itemInlinePadding
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
|
-
|
|
124
123
|
export default generateStyle;
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
spacing = theme.spacing,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
borders = theme.borders;
|
|
35
35
|
const componentVariables = {
|
|
36
36
|
fontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
37
37
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
@@ -47,8 +47,8 @@ const generateComponentTheme = theme => {
|
|
|
47
47
|
activeIndicatorColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
48
48
|
activeIndicatorColorInverse: colors.textDarkest
|
|
49
49
|
};
|
|
50
|
-
return {
|
|
50
|
+
return {
|
|
51
|
+
...componentVariables
|
|
51
52
|
};
|
|
52
53
|
};
|
|
53
|
-
|
|
54
54
|
export default generateComponentTheme;
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
26
|
import { find } from '@instructure/ui-test-utils';
|
|
26
27
|
import { getComputedStyle } from '@instructure/ui-dom-utils';
|
|
@@ -29,34 +30,31 @@ import { TopNavBarMenuItemsLocator } from '../../TopNavBarMenuItems/TopNavBarMen
|
|
|
29
30
|
import { TopNavBarActionItemsLocator } from '../../TopNavBarActionItems/TopNavBarActionItemsLocator';
|
|
30
31
|
import { TopNavBarUserLocator } from '../../TopNavBarUser/TopNavBarUserLocator';
|
|
31
32
|
import { TopNavBarDesktopLayout } from './index';
|
|
32
|
-
export const TopNavBarDesktopLayoutLocator = locator(
|
|
33
|
+
export const TopNavBarDesktopLayoutLocator = locator(
|
|
34
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
33
35
|
TopNavBarDesktopLayout.selector, {
|
|
34
36
|
findBrandContainer: function () {
|
|
35
37
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
38
|
args[_key] = arguments[_key];
|
|
37
39
|
}
|
|
38
|
-
|
|
39
40
|
return find('[class$=-topNavBarDesktopLayout__brandContainer]', ...args);
|
|
40
41
|
},
|
|
41
42
|
findMenuItemsContainer: function () {
|
|
42
43
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
43
44
|
args[_key2] = arguments[_key2];
|
|
44
45
|
}
|
|
45
|
-
|
|
46
46
|
return find('[class$=-topNavBarDesktopLayout__menuItemsContainer]', ...args);
|
|
47
47
|
},
|
|
48
48
|
findActionItemsContainer: function () {
|
|
49
49
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
50
50
|
args[_key3] = arguments[_key3];
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
return find('[class$=-topNavBarDesktopLayout__actionItemsContainer]', ...args);
|
|
54
53
|
},
|
|
55
54
|
findUserContainer: function () {
|
|
56
55
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
57
56
|
args[_key4] = arguments[_key4];
|
|
58
57
|
}
|
|
59
|
-
|
|
60
58
|
return find('[class$=-topNavBarDesktopLayout__userContainer]', ...args);
|
|
61
59
|
},
|
|
62
60
|
findBrand: function () {
|
|
@@ -76,7 +74,6 @@ TopNavBarDesktopLayout.selector, {
|
|
|
76
74
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
77
75
|
args[_key5] = arguments[_key5];
|
|
78
76
|
}
|
|
79
|
-
|
|
80
77
|
const user = await find('[class$=-topNavBarDesktopLayout__userContainer]', ...args);
|
|
81
78
|
return user ? getComputedStyle(user.getDOMNode(), '::before').backgroundColor : 'rgba(0, 0, 0, 0)';
|
|
82
79
|
} catch {
|