@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.
Files changed (95) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/es/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +4 -2
  3. package/es/TopNavBar/TopNavBarActionItems/index.js +10 -35
  4. package/es/TopNavBar/TopNavBarActionItems/props.js +1 -0
  5. package/es/TopNavBar/TopNavBarActionItems/styles.js +0 -1
  6. package/es/TopNavBar/TopNavBarActionItems/theme.js +4 -4
  7. package/es/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +3 -5
  8. package/es/TopNavBar/TopNavBarBrand/index.js +6 -17
  9. package/es/TopNavBar/TopNavBarBrand/props.js +1 -0
  10. package/es/TopNavBar/TopNavBarBrand/styles.js +1 -2
  11. package/es/TopNavBar/TopNavBarBrand/theme.js +2 -2
  12. package/es/TopNavBar/TopNavBarContext.js +1 -1
  13. package/es/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +12 -15
  14. package/es/TopNavBar/TopNavBarItem/index.js +49 -136
  15. package/es/TopNavBar/TopNavBarItem/props.js +1 -0
  16. package/es/TopNavBar/TopNavBarItem/styles.js +5 -6
  17. package/es/TopNavBar/TopNavBarItem/theme.js +5 -5
  18. package/es/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +3 -6
  19. package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +6 -20
  20. package/es/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +5 -2
  21. package/es/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -4
  22. package/es/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +6 -6
  23. package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +8 -16
  24. package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +25 -83
  25. package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +5 -2
  26. package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +4 -5
  27. package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +6 -6
  28. package/es/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +3 -1
  29. package/es/TopNavBar/TopNavBarLayout/index.js +8 -19
  30. package/es/TopNavBar/TopNavBarLayout/props.js +3 -1
  31. package/es/TopNavBar/TopNavBarLayout/theme.js +6 -4
  32. package/es/TopNavBar/TopNavBarLocator.js +2 -1
  33. package/es/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +4 -4
  34. package/es/TopNavBar/TopNavBarMenuItems/index.js +9 -35
  35. package/es/TopNavBar/TopNavBarMenuItems/props.js +1 -0
  36. package/es/TopNavBar/TopNavBarMenuItems/styles.js +0 -1
  37. package/es/TopNavBar/TopNavBarMenuItems/theme.js +3 -3
  38. package/es/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +3 -1
  39. package/es/TopNavBar/TopNavBarUser/index.js +2 -18
  40. package/es/TopNavBar/TopNavBarUser/props.js +1 -0
  41. package/es/TopNavBar/TopNavBarUser/styles.js +0 -1
  42. package/es/TopNavBar/index.js +4 -12
  43. package/es/TopNavBar/props.js +1 -0
  44. package/es/TopNavBar/utils/exampleHelpers.js +9 -17
  45. package/es/TopNavBar/utils/exampleSvgFiles.js +1 -4
  46. package/es/TopNavBar/utils/mapItemsForDrilldown.js +16 -25
  47. package/es/index.js +1 -0
  48. package/lib/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +3 -6
  49. package/lib/TopNavBar/TopNavBarActionItems/index.js +10 -55
  50. package/lib/TopNavBar/TopNavBarActionItems/props.js +1 -6
  51. package/lib/TopNavBar/TopNavBarActionItems/styles.js +0 -2
  52. package/lib/TopNavBar/TopNavBarActionItems/theme.js +4 -5
  53. package/lib/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +1 -8
  54. package/lib/TopNavBar/TopNavBarBrand/index.js +6 -30
  55. package/lib/TopNavBar/TopNavBarBrand/props.js +1 -3
  56. package/lib/TopNavBar/TopNavBarBrand/styles.js +1 -3
  57. package/lib/TopNavBar/TopNavBarBrand/theme.js +2 -3
  58. package/lib/TopNavBar/TopNavBarContext.js +0 -2
  59. package/lib/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +5 -15
  60. package/lib/TopNavBar/TopNavBarItem/index.js +49 -162
  61. package/lib/TopNavBar/TopNavBarItem/props.js +1 -6
  62. package/lib/TopNavBar/TopNavBarItem/styles.js +5 -7
  63. package/lib/TopNavBar/TopNavBarItem/theme.js +5 -6
  64. package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +3 -15
  65. package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +6 -30
  66. package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +5 -4
  67. package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +3 -5
  68. package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +6 -7
  69. package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +5 -21
  70. package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +25 -111
  71. package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +5 -4
  72. package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +4 -6
  73. package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +6 -7
  74. package/lib/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +1 -5
  75. package/lib/TopNavBar/TopNavBarLayout/index.js +8 -30
  76. package/lib/TopNavBar/TopNavBarLayout/props.js +3 -11
  77. package/lib/TopNavBar/TopNavBarLayout/theme.js +4 -7
  78. package/lib/TopNavBar/TopNavBarLocator.js +1 -3
  79. package/lib/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +1 -7
  80. package/lib/TopNavBar/TopNavBarMenuItems/index.js +9 -52
  81. package/lib/TopNavBar/TopNavBarMenuItems/props.js +1 -5
  82. package/lib/TopNavBar/TopNavBarMenuItems/styles.js +0 -2
  83. package/lib/TopNavBar/TopNavBarMenuItems/theme.js +3 -4
  84. package/lib/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +1 -3
  85. package/lib/TopNavBar/TopNavBarUser/index.js +2 -29
  86. package/lib/TopNavBar/TopNavBarUser/props.js +1 -5
  87. package/lib/TopNavBar/TopNavBarUser/styles.js +0 -2
  88. package/lib/TopNavBar/index.js +3 -27
  89. package/lib/TopNavBar/props.js +1 -3
  90. package/lib/TopNavBar/utils/exampleHelpers.js +9 -39
  91. package/lib/TopNavBar/utils/exampleSvgFiles.js +0 -6
  92. package/lib/TopNavBar/utils/mapItemsForDrilldown.js +16 -37
  93. package/lib/index.js +0 -1
  94. package/package.json +27 -27
  95. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,64 +1,36 @@
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.TopNavBarSmallViewportLayout = void 0;
11
-
12
9
  var _react = _interopRequireWildcard(require("react"));
13
-
14
10
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
15
-
16
11
  var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
17
-
18
12
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
19
-
20
13
  var _px = require("@instructure/ui-utils/lib/px.js");
21
-
22
14
  var _console = require("@instructure/console");
23
-
24
15
  var _testable = require("@instructure/ui-testable/lib/testable.js");
25
-
26
16
  var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
27
-
28
17
  var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
29
-
30
18
  var _emotion = require("@instructure/emotion");
31
-
32
19
  var _Tray = require("@instructure/ui-tray/lib/Tray");
33
-
34
20
  var _IconXLine2 = require("@instructure/ui-icons/lib/IconXLine.js");
35
-
36
21
  var _IconHamburgerLine2 = require("@instructure/ui-icons/lib/IconHamburgerLine.js");
37
-
38
22
  var _IconArrowOpenDownSolid = require("@instructure/ui-icons/lib/IconArrowOpenDownSolid.js");
39
-
40
23
  var _IconArrowOpenUpSolid = require("@instructure/ui-icons/lib/IconArrowOpenUpSolid.js");
41
-
42
24
  var _Avatar = require("@instructure/ui-avatar/lib/Avatar");
43
-
44
25
  var _Dialog = require("@instructure/ui-dialog/lib/Dialog");
45
-
46
26
  var _Drilldown = require("@instructure/ui-drilldown/lib/Drilldown");
47
-
48
27
  var _TopNavBarItem = require("../../TopNavBarItem");
49
-
50
28
  var _mapItemsForDrilldown = require("../../utils/mapItemsForDrilldown");
51
-
52
29
  var _TopNavBarContext = require("../../TopNavBarContext");
53
-
54
30
  var _styles = _interopRequireDefault(require("./styles"));
55
-
56
31
  var _theme = _interopRequireDefault(require("./theme"));
57
-
58
32
  var _props = require("./props");
59
-
60
33
  var _dec, _dec2, _dec3, _class, _class2, _IconXLine, _IconHamburgerLine;
61
-
62
34
  /**
63
35
  ---
64
36
  private: true
@@ -68,7 +40,6 @@ private: true
68
40
  let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec3 = (0, _testable.testable)(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TopNavBarSmallViewportLayout extends _react.Component {
69
41
  constructor(props) {
70
42
  var _props$styles;
71
-
72
43
  super(props);
73
44
  this.ref = null;
74
45
  this._trayContainerId = void 0;
@@ -80,27 +51,23 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
80
51
  this._inPlaceDialogCloseButtonId = void 0;
81
52
  this._separatorId = void 0;
82
53
  this._raf = [];
83
-
84
54
  this.handleRef = el => {
85
55
  const elementRef = this.props.elementRef;
86
56
  this.ref = el;
87
-
88
57
  if (typeof elementRef === 'function') {
89
58
  elementRef(el);
90
59
  }
91
60
  };
92
-
93
61
  this.renderOptionContent = (children, itemProps) => {
94
62
  const styles = this.props.styles;
95
63
  const status = itemProps.status,
96
- renderAvatar = itemProps.renderAvatar;
64
+ renderAvatar = itemProps.renderAvatar;
97
65
  let content = children;
98
66
  let optionStyle = status === 'active' ? styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOptionActive : styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOption;
99
-
100
67
  if (renderAvatar) {
101
68
  const avatarName = renderAvatar.avatarName,
102
- avatarSrc = renderAvatar.avatarSrc,
103
- avatarAlt = renderAvatar.avatarAlt;
69
+ avatarSrc = renderAvatar.avatarSrc,
70
+ avatarAlt = renderAvatar.avatarAlt;
104
71
  const label = avatarAlt || (typeof children === 'string' ? children : void 0);
105
72
  optionStyle = styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOptionWithAvatar;
106
73
  content = (0, _emotion.jsx)(_react.default.Fragment, null, (0, _emotion.jsx)(_Avatar.Avatar, {
@@ -113,12 +80,10 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
113
80
  "aria-hidden": "true"
114
81
  }), children);
115
82
  }
116
-
117
83
  return (0, _emotion.jsx)("span", {
118
84
  css: optionStyle
119
85
  }, content);
120
86
  };
121
-
122
87
  this._trayContainerId = props.deterministicId('TopNavBarSmallViewportLayout-trayContainer');
123
88
  this._trayId = props.deterministicId('TopNavBarSmallViewportLayout-tray');
124
89
  this._menuId = props.deterministicId('TopNavBarSmallViewportLayout-menu');
@@ -133,28 +98,21 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
133
98
  menuBottomPosition: (0, _px.px)(((_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.navbarHeight) || 0)
134
99
  };
135
100
  }
136
-
137
101
  componentDidMount() {
138
102
  var _this$props$makeStyle, _this$props;
139
-
140
103
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
141
104
  this.updateMenuBottomPosition();
142
105
  }
143
-
144
106
  componentDidUpdate() {
145
107
  var _this$props$makeStyle2, _this$props2;
146
-
147
108
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
148
109
  }
149
-
150
110
  componentWillUnmount() {
151
111
  this._raf.forEach(request => request.cancel());
152
-
153
112
  if (this.state.isDropdownMenuOpen) {
154
113
  this.toggleDropdownMenu();
155
114
  }
156
115
  }
157
-
158
116
  get makeStylesVariables() {
159
117
  return {
160
118
  isDropdownMenuVisible: this.state.isDropdownMenuVisible,
@@ -164,104 +122,80 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
164
122
  inverseColor: this.context.inverseColor
165
123
  };
166
124
  }
167
-
168
125
  hasBrandBlock(renderBrand) {
169
126
  return !!renderBrand && (!!renderBrand.props.renderName || !!renderBrand.props.renderIcon);
170
127
  }
171
-
172
128
  hasMenuItemsBlock(renderMenuItems) {
173
129
  return !!renderMenuItems && _react.default.Children.count(renderMenuItems.props.children) > 0;
174
130
  }
175
-
176
131
  hasActionItemsBlock(renderActionItems) {
177
132
  return !!renderActionItems && _react.default.Children.count(renderActionItems.props.children) > 0;
178
133
  }
179
-
180
134
  hasUserBlock(renderUser) {
181
135
  return !!renderUser && _react.default.Children.count(renderUser.props.children) > 0;
182
136
  }
183
-
184
137
  get hasSubmenu() {
185
138
  return (this.dropdownMenuContent || []).length > 0;
186
139
  }
187
-
188
140
  get isInPlaceDialogOpen() {
189
141
  var _this$props$renderInP;
190
-
191
142
  return (_this$props$renderInP = this.props.renderInPlaceDialogConfig) === null || _this$props$renderInP === void 0 ? void 0 : _this$props$renderInP.open;
192
143
  }
193
-
194
144
  get mappedUserOptions() {
195
145
  const renderUser = this.props.renderUser;
196
-
197
146
  if (!this.hasUserBlock(renderUser)) {
198
147
  return [];
199
148
  }
200
-
201
149
  const userChildren = _react.default.Children.toArray(renderUser.props.children);
202
-
203
150
  return (0, _mapItemsForDrilldown.mapItemsForDrilldown)(userChildren, {
204
151
  renderOptionContent: this.renderOptionContent
205
152
  });
206
153
  }
207
-
208
154
  get mappedMenuItemsOptions() {
209
155
  const renderMenuItems = this.props.renderMenuItems;
210
-
211
156
  if (!this.hasMenuItemsBlock(renderMenuItems)) {
212
157
  return [];
213
158
  }
214
-
215
159
  const menuItemsChildren = _react.default.Children.toArray(renderMenuItems.props.children);
216
-
217
160
  return (0, _mapItemsForDrilldown.mapItemsForDrilldown)(menuItemsChildren, {
218
161
  renderOptionContent: this.renderOptionContent,
219
162
  currentPageId: renderMenuItems.props.currentPageId
220
163
  });
221
164
  }
222
-
223
165
  get extractDrilldownSubpages() {
224
166
  return (0, _mapItemsForDrilldown.renderMappedItemDrilldownSubpages)([...this.mappedUserOptions, ...this.mappedMenuItemsOptions]);
225
167
  }
226
-
227
168
  updateMenuBottomPosition() {
228
169
  const boundingRect = (0, _getBoundingClientRect.getBoundingClientRect)(this.ref);
229
170
  this.setState({
230
171
  menuBottomPosition: boundingRect.top + boundingRect.height
231
172
  });
232
173
  }
233
-
234
174
  toggleDropdownMenu() {
235
175
  const onDropdownMenuToggle = this.props.onDropdownMenuToggle;
236
176
  const isDropdownMenuOpen = this.state.isDropdownMenuOpen;
237
-
238
177
  if (!isDropdownMenuOpen) {
239
178
  this.updateMenuBottomPosition();
240
179
  }
241
-
242
180
  if (typeof onDropdownMenuToggle === 'function') {
243
181
  onDropdownMenuToggle(!isDropdownMenuOpen);
244
182
  }
245
-
246
183
  this.setState({
247
184
  isDropdownMenuOpen: !isDropdownMenuOpen
248
185
  });
249
186
  }
250
-
251
187
  renderMenuTrigger() {
252
188
  const _this$props3 = this.props,
253
- dropdownMenuToggleButtonLabel = _this$props3.dropdownMenuToggleButtonLabel,
254
- dropdownMenuToggleButtonTooltip = _this$props3.dropdownMenuToggleButtonTooltip,
255
- renderBrand = _this$props3.renderBrand,
256
- alternativeTitle = _this$props3.alternativeTitle,
257
- styles = _this$props3.styles;
189
+ dropdownMenuToggleButtonLabel = _this$props3.dropdownMenuToggleButtonLabel,
190
+ dropdownMenuToggleButtonTooltip = _this$props3.dropdownMenuToggleButtonTooltip,
191
+ renderBrand = _this$props3.renderBrand,
192
+ alternativeTitle = _this$props3.alternativeTitle,
193
+ styles = _this$props3.styles;
258
194
  const isDropdownMenuOpen = this.state.isDropdownMenuOpen;
259
195
  let menuTrigger;
260
196
  const menuTriggerStyle = [styles === null || styles === void 0 ? void 0 : styles.menuTrigger, ...(alternativeTitle ? [styles === null || styles === void 0 ? void 0 : styles.alternativeTitleContainer] : [])];
261
-
262
197
  if (!this.hasSubmenu) {
263
198
  menuTrigger = null;
264
-
265
199
  if (alternativeTitle) {
266
200
  (0, _console.warn)(false, 'There are no menu items or user menu to display in the <TopNavBar> dropdown menu! The menu trigger and the alternative title will not display.');
267
201
  }
@@ -293,25 +227,21 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
293
227
  renderIcon: isDropdownMenuOpen ? _IconXLine || (_IconXLine = (0, _emotion.jsx)(_IconXLine2.IconXLine, null)) : _IconHamburgerLine || (_IconHamburgerLine = (0, _emotion.jsx)(_IconHamburgerLine2.IconHamburgerLine, null))
294
228
  }), dropdownMenuToggleButtonLabel));
295
229
  }
296
-
297
230
  return (0, _emotion.jsx)("div", {
298
231
  css: styles === null || styles === void 0 ? void 0 : styles.menuTriggerContainer
299
232
  }, menuTrigger, this.hasBrandBlock(renderBrand) && !alternativeTitle && (0, _emotion.jsx)("div", {
300
233
  css: styles === null || styles === void 0 ? void 0 : styles.brandContainer
301
234
  }, renderBrand));
302
235
  }
303
-
304
236
  get dropdownMenuContent() {
305
237
  const _this$props4 = this.props,
306
- renderUser = _this$props4.renderUser,
307
- renderMenuItems = _this$props4.renderMenuItems;
238
+ renderUser = _this$props4.renderUser,
239
+ renderMenuItems = _this$props4.renderMenuItems;
308
240
  const hasMenuItems = this.hasMenuItemsBlock(renderMenuItems);
309
241
  const hasUser = this.hasUserBlock(renderUser);
310
242
  let pageChildren = [];
311
-
312
243
  if (hasUser) {
313
244
  pageChildren = (0, _mapItemsForDrilldown.renderMappedItemsAsDrilldownOptions)(this.mappedUserOptions);
314
-
315
245
  if (hasMenuItems) {
316
246
  pageChildren.push((0, _emotion.jsx)(_Drilldown.Drilldown.Separator, {
317
247
  id: this._separatorId,
@@ -319,18 +249,15 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
319
249
  }));
320
250
  }
321
251
  }
322
-
323
252
  if (hasMenuItems) {
324
253
  pageChildren = [...pageChildren, ...(0, _mapItemsForDrilldown.renderMappedItemsAsDrilldownOptions)(this.mappedMenuItemsOptions)];
325
254
  }
326
-
327
255
  return pageChildren.length ? pageChildren : void 0;
328
256
  }
329
-
330
257
  renderDropdownMenu() {
331
258
  const _this$props5 = this.props,
332
- dropdownMenuLabel = _this$props5.dropdownMenuLabel,
333
- onDropdownMenuSelect = _this$props5.onDropdownMenuSelect;
259
+ dropdownMenuLabel = _this$props5.dropdownMenuLabel,
260
+ onDropdownMenuSelect = _this$props5.onDropdownMenuSelect;
334
261
  return (0, _emotion.jsx)(_Drilldown.Drilldown, {
335
262
  id: this._drilldownId,
336
263
  rootPageId: this._menuId,
@@ -341,7 +268,6 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
341
268
  if (typeof onDropdownMenuSelect === 'function') {
342
269
  onDropdownMenuSelect(e, args);
343
270
  }
344
-
345
271
  if (args.selectedOption.props.href) {
346
272
  this.toggleDropdownMenu();
347
273
  }
@@ -351,14 +277,11 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
351
277
  key: this._menuId
352
278
  }, this.dropdownMenuContent), ...this.extractDrilldownSubpages]);
353
279
  }
354
-
355
280
  renderDropdownMenuTray() {
356
281
  const trayMountNode = this.props.trayMountNode;
357
-
358
282
  if (!this.hasSubmenu) {
359
283
  return null;
360
284
  }
361
-
362
285
  return (0, _emotion.jsx)(_Tray.Tray, {
363
286
  id: this._trayId,
364
287
  label: '',
@@ -393,39 +316,32 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
393
316
  }
394
317
  }, this.renderDropdownMenu());
395
318
  }
396
-
397
319
  renderInPlaceDialog() {
398
320
  const _this$props6 = this.props,
399
- renderInPlaceDialogConfig = _this$props6.renderInPlaceDialogConfig,
400
- styles = _this$props6.styles;
401
-
321
+ renderInPlaceDialogConfig = _this$props6.renderInPlaceDialogConfig,
322
+ styles = _this$props6.styles;
402
323
  if (!renderInPlaceDialogConfig) {
403
324
  return null;
404
325
  }
405
-
406
326
  const content = renderInPlaceDialogConfig.content,
407
- open = renderInPlaceDialogConfig.open,
408
- onClose = renderInPlaceDialogConfig.onClose,
409
- closeButtonLabel = renderInPlaceDialogConfig.closeButtonLabel,
410
- shouldContainFocus = renderInPlaceDialogConfig.shouldContainFocus,
411
- shouldCloseOnEscape = renderInPlaceDialogConfig.shouldCloseOnEscape,
412
- shouldCloseOnDocumentClick = renderInPlaceDialogConfig.shouldCloseOnDocumentClick,
413
- returnFocusElement = renderInPlaceDialogConfig.returnFocusElement;
414
-
327
+ open = renderInPlaceDialogConfig.open,
328
+ onClose = renderInPlaceDialogConfig.onClose,
329
+ closeButtonLabel = renderInPlaceDialogConfig.closeButtonLabel,
330
+ shouldContainFocus = renderInPlaceDialogConfig.shouldContainFocus,
331
+ shouldCloseOnEscape = renderInPlaceDialogConfig.shouldCloseOnEscape,
332
+ shouldCloseOnDocumentClick = renderInPlaceDialogConfig.shouldCloseOnDocumentClick,
333
+ returnFocusElement = renderInPlaceDialogConfig.returnFocusElement;
415
334
  const handleClose = () => {
416
335
  if (typeof onClose === 'function') {
417
336
  onClose();
418
337
  }
419
-
420
338
  if (returnFocusElement) {
421
339
  this._raf.push((0, _requestAnimationFrame.requestAnimationFrame)(() => {
422
340
  var _returnFocusElement;
423
-
424
341
  (_returnFocusElement = returnFocusElement()) === null || _returnFocusElement === void 0 ? void 0 : _returnFocusElement.focus();
425
342
  }));
426
343
  }
427
344
  };
428
-
429
345
  const dialog = (0, _emotion.jsx)(_Dialog.Dialog, {
430
346
  display: "block",
431
347
  open: open,
@@ -450,13 +366,12 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
450
366
  }, closeButtonLabel))));
451
367
  return dialog;
452
368
  }
453
-
454
369
  render() {
455
370
  const _this$props7 = this.props,
456
- trayMountNode = _this$props7.trayMountNode,
457
- navLabel = _this$props7.navLabel,
458
- renderActionItems = _this$props7.renderActionItems,
459
- styles = _this$props7.styles;
371
+ trayMountNode = _this$props7.trayMountNode,
372
+ navLabel = _this$props7.navLabel,
373
+ renderActionItems = _this$props7.renderActionItems,
374
+ styles = _this$props7.styles;
460
375
  return (0, _emotion.jsx)("nav", Object.assign({}, (0, _omitProps.omitProps)(this.props, _props.allowedProps), {
461
376
  ref: this.handleRef,
462
377
  "aria-label": navLabel
@@ -469,7 +384,6 @@ let TopNavBarSmallViewportLayout = (_dec = (0, _withDeterministicId.withDetermin
469
384
  id: this._trayContainerId
470
385
  }), this.renderDropdownMenuTray());
471
386
  }
472
-
473
387
  }, _class2.displayName = "TopNavBarSmallViewportLayout", _class2.componentId = 'TopNavBar.SmallViewportLayout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {}, _class2.contextType = _TopNavBarContext.TopNavBarContext, _class2)) || _class) || _class) || _class);
474
388
  exports.TopNavBarSmallViewportLayout = TopNavBarSmallViewportLayout;
475
389
  var _default = TopNavBarSmallViewportLayout;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.propTypes = exports.allowedProps = void 0;
7
-
8
7
  var _props = require("../props");
9
-
10
8
  /*
11
9
  * The MIT License (MIT)
12
10
  *
@@ -30,11 +28,14 @@ var _props = require("../props");
30
28
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
29
  * SOFTWARE.
32
30
  */
33
- const propTypes = { // Edit PropTypes in TopNabBarLayout/props.ts
31
+
32
+ const propTypes = {
33
+ // Edit PropTypes in TopNabBarLayout/props.ts
34
34
  ..._props.commonPropTypes,
35
35
  ..._props.smallViewportPropTypes
36
36
  };
37
37
  exports.propTypes = propTypes;
38
- const allowedProps = [// Edit allowed props in TopNabBarLayout/props.ts
38
+ const allowedProps = [
39
+ // Edit allowed props in TopNabBarLayout/props.ts
39
40
  ..._props.commonAllowedProps, ..._props.smallViewportAllowedProps];
40
41
  exports.allowedProps = allowedProps;
@@ -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,10 +40,10 @@ exports.default = void 0;
41
40
  */
42
41
  const generateStyle = (componentTheme, _props, state) => {
43
42
  const isDropdownMenuVisible = state.isDropdownMenuVisible,
44
- drilldownId = state.drilldownId,
45
- trayId = state.trayId,
46
- menuBottomPosition = state.menuBottomPosition,
47
- inverseColor = state.inverseColor;
43
+ drilldownId = state.drilldownId,
44
+ trayId = state.trayId,
45
+ menuBottomPosition = state.menuBottomPosition,
46
+ inverseColor = state.inverseColor;
48
47
  const dropdownMenuTopPosition = componentTheme.smallViewportTrayFixTopPosition || `${menuBottomPosition}px`;
49
48
  const dropdownMenuOptionStyle = {
50
49
  display: 'inline-block',
@@ -161,6 +160,5 @@ const generateStyle = (componentTheme, _props, state) => {
161
160
  navbarHeight: componentTheme.smallViewportHeight
162
161
  };
163
162
  };
164
-
165
163
  var _default = generateStyle;
166
164
  exports.default = _default;
@@ -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
  *
@@ -36,10 +35,10 @@ exports.default = void 0;
36
35
  */
37
36
  const generateComponentTheme = theme => {
38
37
  const colors = theme.colors,
39
- stacking = theme.stacking,
40
- typography = theme.typography,
41
- spacing = theme.spacing,
42
- borders = theme.borders;
38
+ stacking = theme.stacking,
39
+ typography = theme.typography,
40
+ spacing = theme.spacing,
41
+ borders = theme.borders;
43
42
  const componentVariables = {
44
43
  smallViewportFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
45
44
  smallViewportFontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
@@ -61,9 +60,9 @@ const generateComponentTheme = theme => {
61
60
  smallViewportAlternativeTitleInlineMargin: spacing === null || spacing === void 0 ? void 0 : spacing.xxSmall,
62
61
  smallViewportAlternativeTitleBlockMargin: '0'
63
62
  };
64
- return { ...componentVariables
63
+ return {
64
+ ...componentVariables
65
65
  };
66
66
  };
67
-
68
67
  var _default = generateComponentTheme;
69
68
  exports.default = _default;
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TopNavBarLayoutLocator = void 0;
7
-
8
7
  var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
9
-
10
8
  var _TopNavBarDesktopLayoutLocator = require("./DesktopLayout/TopNavBarDesktopLayoutLocator");
11
-
12
9
  var _TopNavBarSmallViewportLayoutLocator = require("./SmallViewportLayout/TopNavBarSmallViewportLayoutLocator");
13
-
14
10
  var _index = require("./index");
15
-
16
11
  /*
17
12
  * The MIT License (MIT)
18
13
  *
@@ -36,6 +31,7 @@ var _index = require("./index");
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
  // TODO: this type seems to be too complex, try to fix it later
40
36
  const TopNavBarLayoutLocator = (0, _locator.locator)(_index.TopNavBarLayout.selector, {
41
37
  findDesktopLayout: function () {
@@ -1,36 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = exports.TopNavBarLayout = void 0;
11
-
12
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
10
  var _react = _interopRequireWildcard(require("react"));
15
-
16
11
  var _testable = require("@instructure/ui-testable/lib/testable.js");
17
-
18
12
  var _emotion = require("@instructure/emotion");
19
-
20
13
  var _TopNavBarContext = require("../TopNavBarContext");
21
-
22
14
  var _theme = _interopRequireDefault(require("./theme"));
23
-
24
15
  var _SmallViewportLayout = require("./SmallViewportLayout");
25
-
26
16
  var _DesktopLayout = require("./DesktopLayout");
27
-
28
17
  var _props = require("./props");
29
-
30
18
  const _excluded = ["desktopConfig", "smallViewportConfig", "styles", "makeStyles"];
31
-
32
19
  var _dec, _dec2, _class, _class2;
33
-
34
20
  /**
35
21
  ---
36
22
  parent: TopNavBar
@@ -43,19 +29,18 @@ let TopNavBarLayout = (_dec = (0, _emotion.withStyle)(null, _theme.default), _de
43
29
  constructor() {
44
30
  super(...arguments);
45
31
  this.ref = null;
46
-
47
32
  this.handleRef = el => {
48
33
  const elementRef = this.props.elementRef;
49
34
  this.ref = el;
50
-
51
35
  if (typeof elementRef === 'function') {
52
36
  elementRef(el);
53
37
  }
54
38
  };
55
39
  }
56
-
57
40
  get sortedThemeOverride() {
58
- const themeOverride = this.props.themeOverride; // TODO: try to type better, the themeOverride types are not prepared to be inherited and sorted
41
+ const themeOverride = this.props.themeOverride;
42
+
43
+ // TODO: try to type better, the themeOverride types are not prepared to be inherited and sorted
59
44
 
60
45
  if (!themeOverride || typeof themeOverride === 'function') {
61
46
  return {
@@ -63,10 +48,8 @@ let TopNavBarLayout = (_dec = (0, _emotion.withStyle)(null, _theme.default), _de
63
48
  smallViewportThemeOverride: themeOverride
64
49
  };
65
50
  }
66
-
67
51
  const desktopThemeOverride = {};
68
52
  const smallViewportThemeOverride = {};
69
-
70
53
  for (const key in themeOverride) {
71
54
  if (key.startsWith('smallViewport')) {
72
55
  const variable = key;
@@ -76,34 +59,29 @@ let TopNavBarLayout = (_dec = (0, _emotion.withStyle)(null, _theme.default), _de
76
59
  desktopThemeOverride[variable] = themeOverride[variable];
77
60
  }
78
61
  }
79
-
80
62
  return {
81
63
  desktopThemeOverride,
82
64
  smallViewportThemeOverride
83
65
  };
84
66
  }
85
-
86
67
  render() {
87
68
  const _this$props = this.props,
88
- desktopConfig = _this$props.desktopConfig,
89
- smallViewportConfig = _this$props.smallViewportConfig,
90
- styles = _this$props.styles,
91
- makeStyles = _this$props.makeStyles,
92
- restProps = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
93
-
69
+ desktopConfig = _this$props.desktopConfig,
70
+ smallViewportConfig = _this$props.smallViewportConfig,
71
+ styles = _this$props.styles,
72
+ makeStyles = _this$props.makeStyles,
73
+ restProps = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
94
74
  if (this.context.layout === 'smallViewport') {
95
75
  return (0, _emotion.jsx)(_SmallViewportLayout.TopNavBarSmallViewportLayout, Object.assign({}, smallViewportConfig, restProps, {
96
76
  themeOverride: this.sortedThemeOverride.smallViewportThemeOverride,
97
77
  elementRef: this.handleRef
98
78
  }));
99
79
  }
100
-
101
80
  return (0, _emotion.jsx)(_DesktopLayout.TopNavBarDesktopLayout, Object.assign({}, desktopConfig, restProps, {
102
81
  themeOverride: this.sortedThemeOverride.desktopThemeOverride,
103
82
  elementRef: this.handleRef
104
83
  }));
105
84
  }
106
-
107
85
  }, _class2.displayName = "TopNavBarLayout", _class2.componentId = 'TopNavBar.Layout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
108
86
  desktopConfig: {},
109
87
  smallViewportConfig: {}
@@ -1,28 +1,18 @@
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.smallViewportPropTypes = exports.smallViewportAllowedProps = exports.propTypes = exports.desktopPropTypes = exports.desktopAllowedProps = exports.commonPropTypes = exports.commonAllowedProps = 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 _element = require("@instructure/ui-prop-types/lib/element.js");
15
-
16
11
  var _TopNavBarActionItems = require("../TopNavBarActionItems");
17
-
18
12
  var _TopNavBarBrand = require("../TopNavBarBrand");
19
-
20
13
  var _TopNavBarMenuItems = require("../TopNavBarMenuItems");
21
-
22
14
  var _TopNavBarUser = require("../TopNavBarUser");
23
-
24
15
  var _props = require("../TopNavBarItem/props");
25
-
26
16
  /*
27
17
  * The MIT License (MIT)
28
18
  *
@@ -46,6 +36,7 @@ var _props = require("../TopNavBarItem/props");
46
36
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47
37
  * SOFTWARE.
48
38
  */
39
+
49
40
  const commonPropTypes = {
50
41
  renderBrand: _Children.Children.oneOf([_TopNavBarBrand.TopNavBarBrand]),
51
42
  renderMenuItems: _Children.Children.oneOf([_TopNavBarMenuItems.TopNavBarMenuItems]),
@@ -79,7 +70,8 @@ const smallViewportPropTypes = {
79
70
  onDropdownMenuSelect: _propTypes.default.func
80
71
  };
81
72
  exports.smallViewportPropTypes = smallViewportPropTypes;
82
- const propTypes = { ...commonPropTypes,
73
+ const propTypes = {
74
+ ...commonPropTypes,
83
75
  desktopConfig: _propTypes.default.shape(desktopPropTypes),
84
76
  smallViewportConfig: _propTypes.default.shape(smallViewportPropTypes).isRequired
85
77
  };