@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, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -33,7 +32,6 @@ import { TopNavBarContext } from '../../TopNavBarContext';
|
|
|
33
32
|
import generateStyle from './styles';
|
|
34
33
|
import generateComponentTheme from './theme';
|
|
35
34
|
import { propTypes, allowedProps } from './props';
|
|
36
|
-
|
|
37
35
|
/**
|
|
38
36
|
---
|
|
39
37
|
private: true
|
|
@@ -44,29 +42,22 @@ let TopNavBarDesktopLayout = (_dec = withStyle(generateStyle, generateComponentT
|
|
|
44
42
|
constructor() {
|
|
45
43
|
super(...arguments);
|
|
46
44
|
this.ref = null;
|
|
47
|
-
|
|
48
45
|
this.handleRef = el => {
|
|
49
46
|
const elementRef = this.props.elementRef;
|
|
50
47
|
this.ref = el;
|
|
51
|
-
|
|
52
48
|
if (typeof elementRef === 'function') {
|
|
53
49
|
elementRef(el);
|
|
54
50
|
}
|
|
55
51
|
};
|
|
56
52
|
}
|
|
57
|
-
|
|
58
53
|
componentDidMount() {
|
|
59
54
|
var _this$props$makeStyle, _this$props;
|
|
60
|
-
|
|
61
55
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
|
|
62
56
|
}
|
|
63
|
-
|
|
64
57
|
componentDidUpdate() {
|
|
65
58
|
var _this$props$makeStyle2, _this$props2;
|
|
66
|
-
|
|
67
59
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
|
|
68
60
|
}
|
|
69
|
-
|
|
70
61
|
get makeStylesVariables() {
|
|
71
62
|
return {
|
|
72
63
|
inverseColor: this.context.inverseColor,
|
|
@@ -75,30 +66,26 @@ let TopNavBarDesktopLayout = (_dec = withStyle(generateStyle, generateComponentT
|
|
|
75
66
|
hasUserBlock: this.hasUserBlock
|
|
76
67
|
};
|
|
77
68
|
}
|
|
78
|
-
|
|
79
69
|
get hasBrandBlock() {
|
|
80
70
|
const renderBrand = this.props.renderBrand;
|
|
81
71
|
return !!renderBrand && (!!renderBrand.props.renderName || !!renderBrand.props.renderIcon);
|
|
82
72
|
}
|
|
83
|
-
|
|
84
73
|
get hasActionItemsBlock() {
|
|
85
74
|
const renderActionItems = this.props.renderActionItems;
|
|
86
75
|
return !!renderActionItems && React.Children.count(renderActionItems.props.children) > 0;
|
|
87
76
|
}
|
|
88
|
-
|
|
89
77
|
get hasUserBlock() {
|
|
90
78
|
const renderUser = this.props.renderUser;
|
|
91
79
|
return !!renderUser && React.Children.count(renderUser.props.children) > 0;
|
|
92
80
|
}
|
|
93
|
-
|
|
94
81
|
render() {
|
|
95
82
|
const _this$props3 = this.props,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
renderBrand = _this$props3.renderBrand,
|
|
84
|
+
renderMenuItems = _this$props3.renderMenuItems,
|
|
85
|
+
renderActionItems = _this$props3.renderActionItems,
|
|
86
|
+
renderUser = _this$props3.renderUser,
|
|
87
|
+
navLabel = _this$props3.navLabel,
|
|
88
|
+
styles = _this$props3.styles;
|
|
102
89
|
return jsx("nav", Object.assign({}, omitProps(this.props, allowedProps), {
|
|
103
90
|
ref: this.handleRef,
|
|
104
91
|
css: styles === null || styles === void 0 ? void 0 : styles.topNavBarDesktopLayout,
|
|
@@ -113,7 +100,6 @@ let TopNavBarDesktopLayout = (_dec = withStyle(generateStyle, generateComponentT
|
|
|
113
100
|
css: styles === null || styles === void 0 ? void 0 : styles.userContainer
|
|
114
101
|
}, renderUser));
|
|
115
102
|
}
|
|
116
|
-
|
|
117
103
|
}, _class2.displayName = "TopNavBarDesktopLayout", _class2.componentId = 'TopNavBar.DesktopLayout', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {}, _class2.contextType = TopNavBarContext, _class2)) || _class) || _class);
|
|
118
104
|
export { TopNavBarDesktopLayout };
|
|
119
105
|
export default TopNavBarDesktopLayout;
|
|
@@ -21,11 +21,14 @@
|
|
|
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 { commonPropTypes, commonAllowedProps, desktopPropTypes, desktopAllowedProps } from '../props';
|
|
25
|
-
const propTypes = {
|
|
26
|
+
const propTypes = {
|
|
27
|
+
// Edit PropTypes in TopNabBarLayout/props.ts
|
|
26
28
|
...commonPropTypes,
|
|
27
29
|
...desktopPropTypes
|
|
28
30
|
};
|
|
29
|
-
const allowedProps = [
|
|
31
|
+
const allowedProps = [
|
|
32
|
+
// Edit allowed props in TopNabBarLayout/props.ts
|
|
30
33
|
...commonAllowedProps, ...desktopAllowedProps];
|
|
31
34
|
export { propTypes, allowedProps };
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
const generateStyle = (componentTheme, props, state) => {
|
|
36
36
|
const hideActionsUserSeparator = props.hideActionsUserSeparator;
|
|
37
37
|
const inverseColor = state.inverseColor,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
hasBrandBlock = state.hasBrandBlock,
|
|
39
|
+
hasActionItemsBlock = state.hasActionItemsBlock,
|
|
40
|
+
hasUserBlock = state.hasUserBlock;
|
|
41
41
|
const hasUserSeparator = hasActionItemsBlock && hasUserBlock && !hideActionsUserSeparator;
|
|
42
42
|
return {
|
|
43
43
|
topNavBarDesktopLayout: {
|
|
@@ -111,5 +111,4 @@ const generateStyle = (componentTheme, props, state) => {
|
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
};
|
|
114
|
-
|
|
115
114
|
export default generateStyle;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
stacking = theme.stacking,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
spacing = theme.spacing,
|
|
35
|
+
borders = theme.borders;
|
|
36
36
|
const componentVariables = {
|
|
37
37
|
desktopFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
38
38
|
desktopFontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
@@ -54,8 +54,8 @@ const generateComponentTheme = theme => {
|
|
|
54
54
|
desktopUserSeparatorColor: colors.borderMedium,
|
|
55
55
|
desktopUserSeparatorColorInverse: colors.borderMedium
|
|
56
56
|
};
|
|
57
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
...componentVariables
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
|
-
|
|
61
61
|
export default generateComponentTheme;
|
package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js
CHANGED
|
@@ -21,15 +21,16 @@
|
|
|
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';
|
|
27
|
+
|
|
26
28
|
/* eslint-disable no-restricted-imports */
|
|
27
29
|
// @ts-expect-error bypass no type definition found error
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
import { DrilldownLocator } from '@instructure/ui-drilldown/es/Drilldown/DrilldownLocator';
|
|
31
|
+
// @ts-expect-error bypass no type definition found error
|
|
32
|
+
import { TrayLocator } from '@instructure/ui-tray/es/Tray/TrayLocator';
|
|
33
|
+
// @ts-expect-error bypass no type definition found error
|
|
33
34
|
import { TruncateListLocator } from '@instructure/ui-truncate-list/es/TruncateList/TruncateListLocator';
|
|
34
35
|
/* eslint-enable no-restricted-imports */
|
|
35
36
|
|
|
@@ -37,36 +38,32 @@ import { TopNavBarItemLocator } from '../../TopNavBarItem/TopNavBarItemLocator';
|
|
|
37
38
|
import { TopNavBarBrandLocator } from '../../TopNavBarBrand/TopNavBarBrandLocator';
|
|
38
39
|
import { TopNavBarActionItemsLocator } from '../../TopNavBarActionItems/TopNavBarActionItemsLocator';
|
|
39
40
|
import { TopNavBarSmallViewportLayout } from './index';
|
|
40
|
-
export const TopNavBarSmallViewportLayoutLocator = locator(
|
|
41
|
+
export const TopNavBarSmallViewportLayoutLocator = locator(
|
|
42
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
41
43
|
TopNavBarSmallViewportLayout.selector, {
|
|
42
44
|
findNavBar: function () {
|
|
43
45
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
46
|
args[_key] = arguments[_key];
|
|
45
47
|
}
|
|
46
|
-
|
|
47
48
|
return find('[class$=-topNavBarSmallViewportLayout__navbar]', ...args);
|
|
48
49
|
},
|
|
49
50
|
findDropdownMenuTriggerWrapper: function () {
|
|
50
51
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
51
52
|
args[_key2] = arguments[_key2];
|
|
52
53
|
}
|
|
53
|
-
|
|
54
54
|
return find('[class*=-topNavBarSmallViewportLayout__menuTrigger]', ...args);
|
|
55
55
|
},
|
|
56
56
|
findAlternativeTitleContainer: function () {
|
|
57
57
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
58
58
|
args[_key3] = arguments[_key3];
|
|
59
59
|
}
|
|
60
|
-
|
|
61
60
|
return find('[class*=-topNavBarSmallViewportLayout__alternativeTitleContainer]', ...args);
|
|
62
61
|
},
|
|
63
62
|
findDropdownMenuTriggerItem: async function () {
|
|
64
63
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
65
64
|
args[_key4] = arguments[_key4];
|
|
66
65
|
}
|
|
67
|
-
|
|
68
66
|
const triggerExists = await find('[id^=TopNavBarSmallViewportLayout-menuTrigger_]', ...args);
|
|
69
|
-
|
|
70
67
|
if (triggerExists) {
|
|
71
68
|
return TopNavBarItemLocator.find('[id^=TopNavBarSmallViewportLayout-menuTrigger_]');
|
|
72
69
|
} else {
|
|
@@ -77,9 +74,7 @@ TopNavBarSmallViewportLayout.selector, {
|
|
|
77
74
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
78
75
|
args[_key5] = arguments[_key5];
|
|
79
76
|
}
|
|
80
|
-
|
|
81
77
|
const triggerExists = await find('[id^=TopNavBarSmallViewportLayout-menuTrigger_]', ...args);
|
|
82
|
-
|
|
83
78
|
if (triggerExists) {
|
|
84
79
|
const menuItem = await TopNavBarItemLocator.find('[id^=TopNavBarSmallViewportLayout-menuTrigger_]');
|
|
85
80
|
return menuItem.findButton();
|
|
@@ -91,7 +86,6 @@ TopNavBarSmallViewportLayout.selector, {
|
|
|
91
86
|
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
92
87
|
args[_key6] = arguments[_key6];
|
|
93
88
|
}
|
|
94
|
-
|
|
95
89
|
return find('[class$=-topNavBarSmallViewportLayout__brandContainer]', ...args);
|
|
96
90
|
},
|
|
97
91
|
findBrand: function () {
|
|
@@ -113,14 +107,12 @@ TopNavBarSmallViewportLayout.selector, {
|
|
|
113
107
|
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
114
108
|
args[_key7] = arguments[_key7];
|
|
115
109
|
}
|
|
116
|
-
|
|
117
110
|
return find('[class$=-topNavBarSmallViewportLayout__inPlaceDialogContainer]', ...args);
|
|
118
111
|
},
|
|
119
112
|
findInPlaceDialogCloseButton: function () {
|
|
120
113
|
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
121
114
|
args[_key8] = arguments[_key8];
|
|
122
115
|
}
|
|
123
|
-
|
|
124
116
|
return find('[id^=TopNavBarSmallViewportLayout-inPlaceDialogCloseButton_]', ...args);
|
|
125
117
|
}
|
|
126
118
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _dec3, _class, _class2, _IconXLine, _IconHamburgerLine;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -43,7 +42,6 @@ import { TopNavBarContext } from '../../TopNavBarContext';
|
|
|
43
42
|
import generateStyle from './styles';
|
|
44
43
|
import generateComponentTheme from './theme';
|
|
45
44
|
import { propTypes, allowedProps } from './props';
|
|
46
|
-
|
|
47
45
|
/**
|
|
48
46
|
---
|
|
49
47
|
private: true
|
|
@@ -53,7 +51,6 @@ private: true
|
|
|
53
51
|
let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec3 = testable(), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class TopNavBarSmallViewportLayout extends Component {
|
|
54
52
|
constructor(props) {
|
|
55
53
|
var _props$styles;
|
|
56
|
-
|
|
57
54
|
super(props);
|
|
58
55
|
this.ref = null;
|
|
59
56
|
this._trayContainerId = void 0;
|
|
@@ -65,27 +62,23 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
65
62
|
this._inPlaceDialogCloseButtonId = void 0;
|
|
66
63
|
this._separatorId = void 0;
|
|
67
64
|
this._raf = [];
|
|
68
|
-
|
|
69
65
|
this.handleRef = el => {
|
|
70
66
|
const elementRef = this.props.elementRef;
|
|
71
67
|
this.ref = el;
|
|
72
|
-
|
|
73
68
|
if (typeof elementRef === 'function') {
|
|
74
69
|
elementRef(el);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
77
|
-
|
|
78
72
|
this.renderOptionContent = (children, itemProps) => {
|
|
79
73
|
const styles = this.props.styles;
|
|
80
74
|
const status = itemProps.status,
|
|
81
|
-
|
|
75
|
+
renderAvatar = itemProps.renderAvatar;
|
|
82
76
|
let content = children;
|
|
83
77
|
let optionStyle = status === 'active' ? styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOptionActive : styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOption;
|
|
84
|
-
|
|
85
78
|
if (renderAvatar) {
|
|
86
79
|
const avatarName = renderAvatar.avatarName,
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
avatarSrc = renderAvatar.avatarSrc,
|
|
81
|
+
avatarAlt = renderAvatar.avatarAlt;
|
|
89
82
|
const label = avatarAlt || (typeof children === 'string' ? children : void 0);
|
|
90
83
|
optionStyle = styles === null || styles === void 0 ? void 0 : styles.dropdownMenuOptionWithAvatar;
|
|
91
84
|
content = jsx(React.Fragment, null, jsx(Avatar, {
|
|
@@ -98,12 +91,10 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
98
91
|
"aria-hidden": "true"
|
|
99
92
|
}), children);
|
|
100
93
|
}
|
|
101
|
-
|
|
102
94
|
return jsx("span", {
|
|
103
95
|
css: optionStyle
|
|
104
96
|
}, content);
|
|
105
97
|
};
|
|
106
|
-
|
|
107
98
|
this._trayContainerId = props.deterministicId('TopNavBarSmallViewportLayout-trayContainer');
|
|
108
99
|
this._trayId = props.deterministicId('TopNavBarSmallViewportLayout-tray');
|
|
109
100
|
this._menuId = props.deterministicId('TopNavBarSmallViewportLayout-menu');
|
|
@@ -118,28 +109,21 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
118
109
|
menuBottomPosition: px(((_props$styles = props.styles) === null || _props$styles === void 0 ? void 0 : _props$styles.navbarHeight) || 0)
|
|
119
110
|
};
|
|
120
111
|
}
|
|
121
|
-
|
|
122
112
|
componentDidMount() {
|
|
123
113
|
var _this$props$makeStyle, _this$props;
|
|
124
|
-
|
|
125
114
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.makeStylesVariables);
|
|
126
115
|
this.updateMenuBottomPosition();
|
|
127
116
|
}
|
|
128
|
-
|
|
129
117
|
componentDidUpdate() {
|
|
130
118
|
var _this$props$makeStyle2, _this$props2;
|
|
131
|
-
|
|
132
119
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.makeStylesVariables);
|
|
133
120
|
}
|
|
134
|
-
|
|
135
121
|
componentWillUnmount() {
|
|
136
122
|
this._raf.forEach(request => request.cancel());
|
|
137
|
-
|
|
138
123
|
if (this.state.isDropdownMenuOpen) {
|
|
139
124
|
this.toggleDropdownMenu();
|
|
140
125
|
}
|
|
141
126
|
}
|
|
142
|
-
|
|
143
127
|
get makeStylesVariables() {
|
|
144
128
|
return {
|
|
145
129
|
isDropdownMenuVisible: this.state.isDropdownMenuVisible,
|
|
@@ -149,102 +133,80 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
149
133
|
inverseColor: this.context.inverseColor
|
|
150
134
|
};
|
|
151
135
|
}
|
|
152
|
-
|
|
153
136
|
hasBrandBlock(renderBrand) {
|
|
154
137
|
return !!renderBrand && (!!renderBrand.props.renderName || !!renderBrand.props.renderIcon);
|
|
155
138
|
}
|
|
156
|
-
|
|
157
139
|
hasMenuItemsBlock(renderMenuItems) {
|
|
158
140
|
return !!renderMenuItems && React.Children.count(renderMenuItems.props.children) > 0;
|
|
159
141
|
}
|
|
160
|
-
|
|
161
142
|
hasActionItemsBlock(renderActionItems) {
|
|
162
143
|
return !!renderActionItems && React.Children.count(renderActionItems.props.children) > 0;
|
|
163
144
|
}
|
|
164
|
-
|
|
165
145
|
hasUserBlock(renderUser) {
|
|
166
146
|
return !!renderUser && React.Children.count(renderUser.props.children) > 0;
|
|
167
147
|
}
|
|
168
|
-
|
|
169
148
|
get hasSubmenu() {
|
|
170
149
|
return (this.dropdownMenuContent || []).length > 0;
|
|
171
150
|
}
|
|
172
|
-
|
|
173
151
|
get isInPlaceDialogOpen() {
|
|
174
152
|
var _this$props$renderInP;
|
|
175
|
-
|
|
176
153
|
return (_this$props$renderInP = this.props.renderInPlaceDialogConfig) === null || _this$props$renderInP === void 0 ? void 0 : _this$props$renderInP.open;
|
|
177
154
|
}
|
|
178
|
-
|
|
179
155
|
get mappedUserOptions() {
|
|
180
156
|
const renderUser = this.props.renderUser;
|
|
181
|
-
|
|
182
157
|
if (!this.hasUserBlock(renderUser)) {
|
|
183
158
|
return [];
|
|
184
159
|
}
|
|
185
|
-
|
|
186
160
|
const userChildren = React.Children.toArray(renderUser.props.children);
|
|
187
161
|
return mapItemsForDrilldown(userChildren, {
|
|
188
162
|
renderOptionContent: this.renderOptionContent
|
|
189
163
|
});
|
|
190
164
|
}
|
|
191
|
-
|
|
192
165
|
get mappedMenuItemsOptions() {
|
|
193
166
|
const renderMenuItems = this.props.renderMenuItems;
|
|
194
|
-
|
|
195
167
|
if (!this.hasMenuItemsBlock(renderMenuItems)) {
|
|
196
168
|
return [];
|
|
197
169
|
}
|
|
198
|
-
|
|
199
170
|
const menuItemsChildren = React.Children.toArray(renderMenuItems.props.children);
|
|
200
171
|
return mapItemsForDrilldown(menuItemsChildren, {
|
|
201
172
|
renderOptionContent: this.renderOptionContent,
|
|
202
173
|
currentPageId: renderMenuItems.props.currentPageId
|
|
203
174
|
});
|
|
204
175
|
}
|
|
205
|
-
|
|
206
176
|
get extractDrilldownSubpages() {
|
|
207
177
|
return renderMappedItemDrilldownSubpages([...this.mappedUserOptions, ...this.mappedMenuItemsOptions]);
|
|
208
178
|
}
|
|
209
|
-
|
|
210
179
|
updateMenuBottomPosition() {
|
|
211
180
|
const boundingRect = getBoundingClientRect(this.ref);
|
|
212
181
|
this.setState({
|
|
213
182
|
menuBottomPosition: boundingRect.top + boundingRect.height
|
|
214
183
|
});
|
|
215
184
|
}
|
|
216
|
-
|
|
217
185
|
toggleDropdownMenu() {
|
|
218
186
|
const onDropdownMenuToggle = this.props.onDropdownMenuToggle;
|
|
219
187
|
const isDropdownMenuOpen = this.state.isDropdownMenuOpen;
|
|
220
|
-
|
|
221
188
|
if (!isDropdownMenuOpen) {
|
|
222
189
|
this.updateMenuBottomPosition();
|
|
223
190
|
}
|
|
224
|
-
|
|
225
191
|
if (typeof onDropdownMenuToggle === 'function') {
|
|
226
192
|
onDropdownMenuToggle(!isDropdownMenuOpen);
|
|
227
193
|
}
|
|
228
|
-
|
|
229
194
|
this.setState({
|
|
230
195
|
isDropdownMenuOpen: !isDropdownMenuOpen
|
|
231
196
|
});
|
|
232
197
|
}
|
|
233
|
-
|
|
234
198
|
renderMenuTrigger() {
|
|
235
199
|
const _this$props3 = this.props,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
200
|
+
dropdownMenuToggleButtonLabel = _this$props3.dropdownMenuToggleButtonLabel,
|
|
201
|
+
dropdownMenuToggleButtonTooltip = _this$props3.dropdownMenuToggleButtonTooltip,
|
|
202
|
+
renderBrand = _this$props3.renderBrand,
|
|
203
|
+
alternativeTitle = _this$props3.alternativeTitle,
|
|
204
|
+
styles = _this$props3.styles;
|
|
241
205
|
const isDropdownMenuOpen = this.state.isDropdownMenuOpen;
|
|
242
206
|
let menuTrigger;
|
|
243
207
|
const menuTriggerStyle = [styles === null || styles === void 0 ? void 0 : styles.menuTrigger, ...(alternativeTitle ? [styles === null || styles === void 0 ? void 0 : styles.alternativeTitleContainer] : [])];
|
|
244
|
-
|
|
245
208
|
if (!this.hasSubmenu) {
|
|
246
209
|
menuTrigger = null;
|
|
247
|
-
|
|
248
210
|
if (alternativeTitle) {
|
|
249
211
|
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.');
|
|
250
212
|
}
|
|
@@ -276,25 +238,21 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
276
238
|
renderIcon: isDropdownMenuOpen ? _IconXLine || (_IconXLine = jsx(IconXLine, null)) : _IconHamburgerLine || (_IconHamburgerLine = jsx(IconHamburgerLine, null))
|
|
277
239
|
}), dropdownMenuToggleButtonLabel));
|
|
278
240
|
}
|
|
279
|
-
|
|
280
241
|
return jsx("div", {
|
|
281
242
|
css: styles === null || styles === void 0 ? void 0 : styles.menuTriggerContainer
|
|
282
243
|
}, menuTrigger, this.hasBrandBlock(renderBrand) && !alternativeTitle && jsx("div", {
|
|
283
244
|
css: styles === null || styles === void 0 ? void 0 : styles.brandContainer
|
|
284
245
|
}, renderBrand));
|
|
285
246
|
}
|
|
286
|
-
|
|
287
247
|
get dropdownMenuContent() {
|
|
288
248
|
const _this$props4 = this.props,
|
|
289
|
-
|
|
290
|
-
|
|
249
|
+
renderUser = _this$props4.renderUser,
|
|
250
|
+
renderMenuItems = _this$props4.renderMenuItems;
|
|
291
251
|
const hasMenuItems = this.hasMenuItemsBlock(renderMenuItems);
|
|
292
252
|
const hasUser = this.hasUserBlock(renderUser);
|
|
293
253
|
let pageChildren = [];
|
|
294
|
-
|
|
295
254
|
if (hasUser) {
|
|
296
255
|
pageChildren = renderMappedItemsAsDrilldownOptions(this.mappedUserOptions);
|
|
297
|
-
|
|
298
256
|
if (hasMenuItems) {
|
|
299
257
|
pageChildren.push(jsx(Drilldown.Separator, {
|
|
300
258
|
id: this._separatorId,
|
|
@@ -302,18 +260,15 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
302
260
|
}));
|
|
303
261
|
}
|
|
304
262
|
}
|
|
305
|
-
|
|
306
263
|
if (hasMenuItems) {
|
|
307
264
|
pageChildren = [...pageChildren, ...renderMappedItemsAsDrilldownOptions(this.mappedMenuItemsOptions)];
|
|
308
265
|
}
|
|
309
|
-
|
|
310
266
|
return pageChildren.length ? pageChildren : void 0;
|
|
311
267
|
}
|
|
312
|
-
|
|
313
268
|
renderDropdownMenu() {
|
|
314
269
|
const _this$props5 = this.props,
|
|
315
|
-
|
|
316
|
-
|
|
270
|
+
dropdownMenuLabel = _this$props5.dropdownMenuLabel,
|
|
271
|
+
onDropdownMenuSelect = _this$props5.onDropdownMenuSelect;
|
|
317
272
|
return jsx(Drilldown, {
|
|
318
273
|
id: this._drilldownId,
|
|
319
274
|
rootPageId: this._menuId,
|
|
@@ -324,7 +279,6 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
324
279
|
if (typeof onDropdownMenuSelect === 'function') {
|
|
325
280
|
onDropdownMenuSelect(e, args);
|
|
326
281
|
}
|
|
327
|
-
|
|
328
282
|
if (args.selectedOption.props.href) {
|
|
329
283
|
this.toggleDropdownMenu();
|
|
330
284
|
}
|
|
@@ -334,14 +288,11 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
334
288
|
key: this._menuId
|
|
335
289
|
}, this.dropdownMenuContent), ...this.extractDrilldownSubpages]);
|
|
336
290
|
}
|
|
337
|
-
|
|
338
291
|
renderDropdownMenuTray() {
|
|
339
292
|
const trayMountNode = this.props.trayMountNode;
|
|
340
|
-
|
|
341
293
|
if (!this.hasSubmenu) {
|
|
342
294
|
return null;
|
|
343
295
|
}
|
|
344
|
-
|
|
345
296
|
return jsx(Tray, {
|
|
346
297
|
id: this._trayId,
|
|
347
298
|
label: '',
|
|
@@ -376,39 +327,32 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
376
327
|
}
|
|
377
328
|
}, this.renderDropdownMenu());
|
|
378
329
|
}
|
|
379
|
-
|
|
380
330
|
renderInPlaceDialog() {
|
|
381
331
|
const _this$props6 = this.props,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
332
|
+
renderInPlaceDialogConfig = _this$props6.renderInPlaceDialogConfig,
|
|
333
|
+
styles = _this$props6.styles;
|
|
385
334
|
if (!renderInPlaceDialogConfig) {
|
|
386
335
|
return null;
|
|
387
336
|
}
|
|
388
|
-
|
|
389
337
|
const content = renderInPlaceDialogConfig.content,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
338
|
+
open = renderInPlaceDialogConfig.open,
|
|
339
|
+
onClose = renderInPlaceDialogConfig.onClose,
|
|
340
|
+
closeButtonLabel = renderInPlaceDialogConfig.closeButtonLabel,
|
|
341
|
+
shouldContainFocus = renderInPlaceDialogConfig.shouldContainFocus,
|
|
342
|
+
shouldCloseOnEscape = renderInPlaceDialogConfig.shouldCloseOnEscape,
|
|
343
|
+
shouldCloseOnDocumentClick = renderInPlaceDialogConfig.shouldCloseOnDocumentClick,
|
|
344
|
+
returnFocusElement = renderInPlaceDialogConfig.returnFocusElement;
|
|
398
345
|
const handleClose = () => {
|
|
399
346
|
if (typeof onClose === 'function') {
|
|
400
347
|
onClose();
|
|
401
348
|
}
|
|
402
|
-
|
|
403
349
|
if (returnFocusElement) {
|
|
404
350
|
this._raf.push(requestAnimationFrame(() => {
|
|
405
351
|
var _returnFocusElement;
|
|
406
|
-
|
|
407
352
|
(_returnFocusElement = returnFocusElement()) === null || _returnFocusElement === void 0 ? void 0 : _returnFocusElement.focus();
|
|
408
353
|
}));
|
|
409
354
|
}
|
|
410
355
|
};
|
|
411
|
-
|
|
412
356
|
const dialog = jsx(Dialog, {
|
|
413
357
|
display: "block",
|
|
414
358
|
open: open,
|
|
@@ -433,13 +377,12 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
433
377
|
}, closeButtonLabel))));
|
|
434
378
|
return dialog;
|
|
435
379
|
}
|
|
436
|
-
|
|
437
380
|
render() {
|
|
438
381
|
const _this$props7 = this.props,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
382
|
+
trayMountNode = _this$props7.trayMountNode,
|
|
383
|
+
navLabel = _this$props7.navLabel,
|
|
384
|
+
renderActionItems = _this$props7.renderActionItems,
|
|
385
|
+
styles = _this$props7.styles;
|
|
443
386
|
return jsx("nav", Object.assign({}, omitProps(this.props, allowedProps), {
|
|
444
387
|
ref: this.handleRef,
|
|
445
388
|
"aria-label": navLabel
|
|
@@ -452,7 +395,6 @@ let TopNavBarSmallViewportLayout = (_dec = withDeterministicId(), _dec2 = withSt
|
|
|
452
395
|
id: this._trayContainerId
|
|
453
396
|
}), this.renderDropdownMenuTray());
|
|
454
397
|
}
|
|
455
|
-
|
|
456
398
|
}, _class2.displayName = "TopNavBarSmallViewportLayout", _class2.componentId = 'TopNavBar.SmallViewportLayout', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {}, _class2.contextType = TopNavBarContext, _class2)) || _class) || _class) || _class);
|
|
457
399
|
export { TopNavBarSmallViewportLayout };
|
|
458
400
|
export default TopNavBarSmallViewportLayout;
|
|
@@ -21,11 +21,14 @@
|
|
|
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 { commonAllowedProps, commonPropTypes, smallViewportPropTypes, smallViewportAllowedProps } from '../props';
|
|
25
|
-
const propTypes = {
|
|
26
|
+
const propTypes = {
|
|
27
|
+
// Edit PropTypes in TopNabBarLayout/props.ts
|
|
26
28
|
...commonPropTypes,
|
|
27
29
|
...smallViewportPropTypes
|
|
28
30
|
};
|
|
29
|
-
const allowedProps = [
|
|
31
|
+
const allowedProps = [
|
|
32
|
+
// Edit allowed props in TopNabBarLayout/props.ts
|
|
30
33
|
...commonAllowedProps, ...smallViewportAllowedProps];
|
|
31
34
|
export { propTypes, allowedProps };
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, _props, state) => {
|
|
36
36
|
const isDropdownMenuVisible = state.isDropdownMenuVisible,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
drilldownId = state.drilldownId,
|
|
38
|
+
trayId = state.trayId,
|
|
39
|
+
menuBottomPosition = state.menuBottomPosition,
|
|
40
|
+
inverseColor = state.inverseColor;
|
|
41
41
|
const dropdownMenuTopPosition = componentTheme.smallViewportTrayFixTopPosition || `${menuBottomPosition}px`;
|
|
42
42
|
const dropdownMenuOptionStyle = {
|
|
43
43
|
display: 'inline-block',
|
|
@@ -154,5 +154,4 @@ const generateStyle = (componentTheme, _props, state) => {
|
|
|
154
154
|
navbarHeight: componentTheme.smallViewportHeight
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
|
|
158
157
|
export default generateStyle;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const colors = theme.colors,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
stacking = theme.stacking,
|
|
33
|
+
typography = theme.typography,
|
|
34
|
+
spacing = theme.spacing,
|
|
35
|
+
borders = theme.borders;
|
|
36
36
|
const componentVariables = {
|
|
37
37
|
smallViewportFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeMedium,
|
|
38
38
|
smallViewportFontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
@@ -54,8 +54,8 @@ const generateComponentTheme = theme => {
|
|
|
54
54
|
smallViewportAlternativeTitleInlineMargin: spacing === null || spacing === void 0 ? void 0 : spacing.xxSmall,
|
|
55
55
|
smallViewportAlternativeTitleBlockMargin: '0'
|
|
56
56
|
};
|
|
57
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
...componentVariables
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
|
-
|
|
61
61
|
export default generateComponentTheme;
|
|
@@ -21,11 +21,13 @@
|
|
|
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 { TopNavBarDesktopLayoutLocator } from './DesktopLayout/TopNavBarDesktopLayoutLocator';
|
|
26
27
|
import { TopNavBarSmallViewportLayoutLocator } from './SmallViewportLayout/TopNavBarSmallViewportLayoutLocator';
|
|
27
|
-
import { TopNavBarLayout } from './index';
|
|
28
|
+
import { TopNavBarLayout } from './index';
|
|
28
29
|
|
|
30
|
+
// TODO: this type seems to be too complex, try to fix it later
|
|
29
31
|
export const TopNavBarLayoutLocator = locator(TopNavBarLayout.selector, {
|
|
30
32
|
findDesktopLayout: function () {
|
|
31
33
|
return TopNavBarDesktopLayoutLocator.find(...arguments);
|