@instructure/ui-navigation 8.27.1-snapshot-2 → 8.27.1-snapshot-14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -2
- package/es/AppNav/index.js +17 -119
- package/es/AppNav/styles.js +4 -23
- package/lib/AppNav/index.js +19 -123
- package/lib/AppNav/styles.js +4 -23
- package/package.json +24 -23
- package/src/AppNav/index.tsx +39 -133
- package/src/AppNav/props.ts +4 -8
- package/src/AppNav/styles.ts +4 -23
- package/tsconfig.build.json +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/AppNav/index.d.ts +3 -13
- package/types/AppNav/index.d.ts.map +1 -1
- package/types/AppNav/props.d.ts +4 -1
- package/types/AppNav/props.d.ts.map +1 -1
- package/types/AppNav/styles.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.27.1-snapshot-
|
|
6
|
+
## [8.27.1-snapshot-14](https://github.com/instructure/instructure-ui/compare/v8.27.0...v8.27.1-snapshot-14) (2022-08-17)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-tray:** add `position` theme variable to Tray ([375ed68](https://github.com/instructure/instructure-ui/commit/375ed68a6c38c241d45d3a13f5bb757ed68b9ab2))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/AppNav/index.js
CHANGED
|
@@ -25,12 +25,9 @@ var _dec, _dec2, _class, _class2;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import {
|
|
28
|
+
import React, { Component } from 'react';
|
|
29
29
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
30
|
-
import { getBoundingClientRect } from '@instructure/ui-dom-utils';
|
|
31
30
|
import { callRenderProp, omitProps } from '@instructure/ui-react-utils';
|
|
32
|
-
import { px } from '@instructure/ui-utils';
|
|
33
|
-
import { debounce } from '@instructure/debounce';
|
|
34
31
|
import { testable } from '@instructure/ui-testable';
|
|
35
32
|
import { View } from '@instructure/ui-view';
|
|
36
33
|
import { Menu } from '@instructure/ui-menu';
|
|
@@ -38,13 +35,14 @@ import { Item } from './Item';
|
|
|
38
35
|
import generateStyle from './styles';
|
|
39
36
|
import generateComponentTheme from './theme';
|
|
40
37
|
import { allowedProps, propTypes } from './props';
|
|
41
|
-
|
|
38
|
+
import { TruncateList } from '@instructure/ui-truncate-list';
|
|
42
39
|
/**
|
|
43
40
|
---
|
|
44
41
|
category: components
|
|
45
42
|
---
|
|
46
43
|
@tsProps
|
|
47
44
|
**/
|
|
45
|
+
|
|
48
46
|
let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class AppNav extends Component {
|
|
49
47
|
constructor() {
|
|
50
48
|
super(...arguments);
|
|
@@ -52,63 +50,6 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
52
50
|
isMeasuring: false
|
|
53
51
|
};
|
|
54
52
|
this.ref = null;
|
|
55
|
-
this._list = null;
|
|
56
|
-
this._debounced = void 0;
|
|
57
|
-
this._resizeListener = void 0;
|
|
58
|
-
|
|
59
|
-
this.measureItems = () => {
|
|
60
|
-
var _this$props$styles;
|
|
61
|
-
|
|
62
|
-
const menuTriggerWidth = px((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
|
|
63
|
-
let visibleItemsCount = 0;
|
|
64
|
-
|
|
65
|
-
if (this._list) {
|
|
66
|
-
const _getBoundingClientRec = getBoundingClientRect(this._list),
|
|
67
|
-
navWidth = _getBoundingClientRec.width;
|
|
68
|
-
|
|
69
|
-
const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
|
|
70
|
-
// Todo: if item's type isn't `unknown`, can remove `Element`
|
|
71
|
-
const _getBoundingClientRec2 = getBoundingClientRect(item),
|
|
72
|
-
width = _getBoundingClientRec2.width;
|
|
73
|
-
|
|
74
|
-
return width;
|
|
75
|
-
});
|
|
76
|
-
let currentWidth = 0;
|
|
77
|
-
|
|
78
|
-
for (let i = 0; i < itemWidths.length; i++) {
|
|
79
|
-
currentWidth += itemWidths[i];
|
|
80
|
-
|
|
81
|
-
if (currentWidth <= navWidth - menuTriggerWidth) {
|
|
82
|
-
visibleItemsCount++;
|
|
83
|
-
} else {
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
visibleItemsCount
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
this.handleResize = () => {
|
|
95
|
-
this.setState({
|
|
96
|
-
isMeasuring: true
|
|
97
|
-
}, () => {
|
|
98
|
-
const _this$measureItems = this.measureItems(),
|
|
99
|
-
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
100
|
-
|
|
101
|
-
if (typeof this.props.onUpdate === 'function') {
|
|
102
|
-
this.props.onUpdate({
|
|
103
|
-
visibleItemsCount
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.setState({
|
|
108
|
-
isMeasuring: false
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
53
|
|
|
113
54
|
this.handleRef = el => {
|
|
114
55
|
const elementRef = this.props.elementRef;
|
|
@@ -124,27 +65,6 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
124
65
|
var _this$props$makeStyle, _this$props;
|
|
125
66
|
|
|
126
67
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
127
|
-
|
|
128
|
-
const _getBoundingClientRec3 = getBoundingClientRect(this._list),
|
|
129
|
-
origWidth = _getBoundingClientRec3.width;
|
|
130
|
-
|
|
131
|
-
this._debounced = debounce(this.handleResize, this.props.debounce, {
|
|
132
|
-
leading: true,
|
|
133
|
-
trailing: true
|
|
134
|
-
});
|
|
135
|
-
this._resizeListener = new ResizeObserver(entries => {
|
|
136
|
-
for (const entry of entries) {
|
|
137
|
-
const width = entry.contentRect.width;
|
|
138
|
-
|
|
139
|
-
if (origWidth !== width) {
|
|
140
|
-
this._debounced();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
this._resizeListener.observe(this._list);
|
|
146
|
-
|
|
147
|
-
this.handleResize();
|
|
148
68
|
}
|
|
149
69
|
|
|
150
70
|
componentDidUpdate() {
|
|
@@ -153,27 +73,8 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
153
73
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
154
74
|
}
|
|
155
75
|
|
|
156
|
-
componentWillUnmount() {
|
|
157
|
-
if (this._resizeListener) {
|
|
158
|
-
this._resizeListener.disconnect();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (this._debounced) {
|
|
162
|
-
this._debounced.cancel();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
renderListItem(item, isMenuTrigger, key) {
|
|
167
|
-
var _this$props$styles2, _this$props$styles3;
|
|
168
|
-
|
|
169
|
-
return jsx("li", {
|
|
170
|
-
key: key,
|
|
171
|
-
css: isMenuTrigger ? (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.listItemWithMenuTrigger : (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.listItem
|
|
172
|
-
}, item);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
76
|
renderMenu(items) {
|
|
176
|
-
|
|
77
|
+
return jsx(Menu, {
|
|
177
78
|
trigger: jsx(AppNav.Item, {
|
|
178
79
|
renderLabel: callRenderProp(this.props.renderTruncateLabel)
|
|
179
80
|
})
|
|
@@ -184,38 +85,35 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
184
85
|
key: index
|
|
185
86
|
}, callRenderProp(item.props.renderLabel));
|
|
186
87
|
}));
|
|
187
|
-
return this.renderListItem(menu, true);
|
|
188
88
|
}
|
|
189
89
|
|
|
190
90
|
render() {
|
|
191
|
-
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
192
|
-
|
|
193
91
|
const _this$props3 = this.props,
|
|
194
|
-
children = _this$props3.children,
|
|
195
92
|
visibleItemsCount = _this$props3.visibleItemsCount,
|
|
196
93
|
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
197
|
-
margin = _this$props3.margin
|
|
94
|
+
margin = _this$props3.margin,
|
|
95
|
+
debounce = _this$props3.debounce,
|
|
96
|
+
styles = _this$props3.styles;
|
|
198
97
|
const passthroughProps = View.omitViewProps(omitProps(this.props, AppNav.allowedProps), AppNav);
|
|
199
|
-
const isMeasuring = this.state.isMeasuring;
|
|
200
|
-
const childrenArray = Children.toArray(children);
|
|
201
|
-
const visibleChildren = isMeasuring ? childrenArray : childrenArray.splice(0, visibleItemsCount);
|
|
202
|
-
const hiddenChildren = isMeasuring ? [] : childrenArray;
|
|
203
98
|
const renderBeforeItems = callRenderProp(this.props.renderBeforeItems);
|
|
204
99
|
const renderAfterItems = callRenderProp(this.props.renderAfterItems);
|
|
205
100
|
const hasRenderedContent = renderBeforeItems || renderAfterItems;
|
|
206
101
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
207
102
|
as: "nav",
|
|
208
|
-
css: [
|
|
103
|
+
css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
|
|
209
104
|
margin: margin,
|
|
210
105
|
display: hasRenderedContent ? 'flex' : 'block',
|
|
211
106
|
elementRef: this.handleRef
|
|
212
|
-
}), renderBeforeItems && jsx("span", null, renderBeforeItems), jsx(
|
|
213
|
-
|
|
214
|
-
|
|
107
|
+
}), renderBeforeItems && jsx("span", null, renderBeforeItems), jsx(TruncateList, {
|
|
108
|
+
visibleItemsCount: visibleItemsCount,
|
|
109
|
+
debounce: debounce,
|
|
110
|
+
onUpdate: this.props.onUpdate,
|
|
111
|
+
renderHiddenItemMenu: hiddenChildren => this.renderMenu(hiddenChildren),
|
|
112
|
+
itemSpacing: styles === null || styles === void 0 ? void 0 : styles.horizontalMargin,
|
|
113
|
+
fixMenuTriggerWidth: styles === null || styles === void 0 ? void 0 : styles.menuTriggerWidth,
|
|
114
|
+
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
215
115
|
"aria-label": callRenderProp(screenReaderLabel)
|
|
216
|
-
},
|
|
217
|
-
return this.renderListItem(child, false, index);
|
|
218
|
-
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && jsx("span", null, renderAfterItems));
|
|
116
|
+
}, this.props.children), renderAfterItems && jsx("span", null, renderAfterItems));
|
|
219
117
|
}
|
|
220
118
|
|
|
221
119
|
}, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
package/es/AppNav/styles.js
CHANGED
|
@@ -42,36 +42,17 @@ const generateStyle = componentTheme => {
|
|
|
42
42
|
alignCenter: {
|
|
43
43
|
alignItems: 'center'
|
|
44
44
|
},
|
|
45
|
-
listItemWithMenuTrigger: {
|
|
46
|
-
label: 'appNav__listItemWithMenuTrigger',
|
|
47
|
-
minWidth: '0.0625rem',
|
|
48
|
-
marginInlineStart: componentTheme.horizontalMargin,
|
|
49
|
-
marginInlineEnd: '0',
|
|
50
|
-
flexShrink: 0,
|
|
51
|
-
flexBasis: componentTheme.menuTriggerWidth
|
|
52
|
-
},
|
|
53
|
-
listItem: {
|
|
54
|
-
label: 'appNav__listItem',
|
|
55
|
-
minWidth: '0.0625rem',
|
|
56
|
-
marginInlineStart: componentTheme.horizontalMargin,
|
|
57
|
-
marginInlineEnd: '0',
|
|
58
|
-
flexShrink: 0
|
|
59
|
-
},
|
|
60
45
|
list: {
|
|
61
46
|
label: 'appNav__list',
|
|
62
|
-
boxSizing: 'border-box',
|
|
63
|
-
listStyleType: 'none',
|
|
64
47
|
height: componentTheme.height,
|
|
65
|
-
margin: '0',
|
|
66
|
-
padding: '0',
|
|
67
|
-
display: 'flex',
|
|
68
|
-
alignItems: 'center',
|
|
69
48
|
flexGrow: 1,
|
|
70
49
|
flexShrink: 1,
|
|
71
50
|
flexBasis: '0',
|
|
72
|
-
minWidth: '0.0625rem'
|
|
51
|
+
minWidth: '0.0625rem',
|
|
52
|
+
paddingInlineStart: componentTheme.horizontalMargin
|
|
73
53
|
},
|
|
74
|
-
|
|
54
|
+
horizontalMargin: componentTheme.horizontalMargin.toString(),
|
|
55
|
+
menuTriggerWidth: componentTheme.menuTriggerWidth.toString()
|
|
75
56
|
};
|
|
76
57
|
};
|
|
77
58
|
|
package/lib/AppNav/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
3
5
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -7,20 +9,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
9
|
});
|
|
8
10
|
exports.default = exports.AppNav = void 0;
|
|
9
11
|
|
|
10
|
-
var _react = require("react");
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
|
|
12
14
|
var _emotion = require("@instructure/emotion");
|
|
13
15
|
|
|
14
|
-
var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
|
|
15
|
-
|
|
16
16
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
17
17
|
|
|
18
18
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
19
19
|
|
|
20
|
-
var _px = require("@instructure/ui-utils/lib/px.js");
|
|
21
|
-
|
|
22
|
-
var _debounce = require("@instructure/debounce");
|
|
23
|
-
|
|
24
20
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
25
21
|
|
|
26
22
|
var _View = require("@instructure/ui-view/lib/View");
|
|
@@ -35,6 +31,8 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
35
31
|
|
|
36
32
|
var _props = require("./props");
|
|
37
33
|
|
|
34
|
+
var _TruncateList = require("@instructure/ui-truncate-list/lib/TruncateList");
|
|
35
|
+
|
|
38
36
|
var _dec, _dec2, _class, _class2;
|
|
39
37
|
|
|
40
38
|
/**
|
|
@@ -50,63 +48,6 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
50
48
|
isMeasuring: false
|
|
51
49
|
};
|
|
52
50
|
this.ref = null;
|
|
53
|
-
this._list = null;
|
|
54
|
-
this._debounced = void 0;
|
|
55
|
-
this._resizeListener = void 0;
|
|
56
|
-
|
|
57
|
-
this.measureItems = () => {
|
|
58
|
-
var _this$props$styles;
|
|
59
|
-
|
|
60
|
-
const menuTriggerWidth = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
|
|
61
|
-
let visibleItemsCount = 0;
|
|
62
|
-
|
|
63
|
-
if (this._list) {
|
|
64
|
-
const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
65
|
-
navWidth = _getBoundingClientRec.width;
|
|
66
|
-
|
|
67
|
-
const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
|
|
68
|
-
// Todo: if item's type isn't `unknown`, can remove `Element`
|
|
69
|
-
const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
|
|
70
|
-
width = _getBoundingClientRec2.width;
|
|
71
|
-
|
|
72
|
-
return width;
|
|
73
|
-
});
|
|
74
|
-
let currentWidth = 0;
|
|
75
|
-
|
|
76
|
-
for (let i = 0; i < itemWidths.length; i++) {
|
|
77
|
-
currentWidth += itemWidths[i];
|
|
78
|
-
|
|
79
|
-
if (currentWidth <= navWidth - menuTriggerWidth) {
|
|
80
|
-
visibleItemsCount++;
|
|
81
|
-
} else {
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
visibleItemsCount
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
this.handleResize = () => {
|
|
93
|
-
this.setState({
|
|
94
|
-
isMeasuring: true
|
|
95
|
-
}, () => {
|
|
96
|
-
const _this$measureItems = this.measureItems(),
|
|
97
|
-
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
98
|
-
|
|
99
|
-
if (typeof this.props.onUpdate === 'function') {
|
|
100
|
-
this.props.onUpdate({
|
|
101
|
-
visibleItemsCount
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
this.setState({
|
|
106
|
-
isMeasuring: false
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
51
|
|
|
111
52
|
this.handleRef = el => {
|
|
112
53
|
const elementRef = this.props.elementRef;
|
|
@@ -122,27 +63,6 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
122
63
|
var _this$props$makeStyle, _this$props;
|
|
123
64
|
|
|
124
65
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
125
|
-
|
|
126
|
-
const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
127
|
-
origWidth = _getBoundingClientRec3.width;
|
|
128
|
-
|
|
129
|
-
this._debounced = (0, _debounce.debounce)(this.handleResize, this.props.debounce, {
|
|
130
|
-
leading: true,
|
|
131
|
-
trailing: true
|
|
132
|
-
});
|
|
133
|
-
this._resizeListener = new ResizeObserver(entries => {
|
|
134
|
-
for (const entry of entries) {
|
|
135
|
-
const width = entry.contentRect.width;
|
|
136
|
-
|
|
137
|
-
if (origWidth !== width) {
|
|
138
|
-
this._debounced();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
this._resizeListener.observe(this._list);
|
|
144
|
-
|
|
145
|
-
this.handleResize();
|
|
146
66
|
}
|
|
147
67
|
|
|
148
68
|
componentDidUpdate() {
|
|
@@ -151,27 +71,8 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
151
71
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
152
72
|
}
|
|
153
73
|
|
|
154
|
-
componentWillUnmount() {
|
|
155
|
-
if (this._resizeListener) {
|
|
156
|
-
this._resizeListener.disconnect();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (this._debounced) {
|
|
160
|
-
this._debounced.cancel();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
renderListItem(item, isMenuTrigger, key) {
|
|
165
|
-
var _this$props$styles2, _this$props$styles3;
|
|
166
|
-
|
|
167
|
-
return (0, _emotion.jsx)("li", {
|
|
168
|
-
key: key,
|
|
169
|
-
css: isMenuTrigger ? (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.listItemWithMenuTrigger : (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.listItem
|
|
170
|
-
}, item);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
74
|
renderMenu(items) {
|
|
174
|
-
|
|
75
|
+
return (0, _emotion.jsx)(_Menu.Menu, {
|
|
175
76
|
trigger: (0, _emotion.jsx)(AppNav.Item, {
|
|
176
77
|
renderLabel: (0, _callRenderProp.callRenderProp)(this.props.renderTruncateLabel)
|
|
177
78
|
})
|
|
@@ -182,42 +83,37 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
182
83
|
key: index
|
|
183
84
|
}, (0, _callRenderProp.callRenderProp)(item.props.renderLabel));
|
|
184
85
|
}));
|
|
185
|
-
return this.renderListItem(menu, true);
|
|
186
86
|
}
|
|
187
87
|
|
|
188
88
|
render() {
|
|
189
|
-
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
190
|
-
|
|
191
89
|
const _this$props3 = this.props,
|
|
192
|
-
children = _this$props3.children,
|
|
193
90
|
visibleItemsCount = _this$props3.visibleItemsCount,
|
|
194
91
|
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
195
|
-
margin = _this$props3.margin
|
|
92
|
+
margin = _this$props3.margin,
|
|
93
|
+
debounce = _this$props3.debounce,
|
|
94
|
+
styles = _this$props3.styles;
|
|
196
95
|
|
|
197
96
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, AppNav.allowedProps), AppNav);
|
|
198
97
|
|
|
199
|
-
const isMeasuring = this.state.isMeasuring;
|
|
200
|
-
|
|
201
|
-
const childrenArray = _react.Children.toArray(children);
|
|
202
|
-
|
|
203
|
-
const visibleChildren = isMeasuring ? childrenArray : childrenArray.splice(0, visibleItemsCount);
|
|
204
|
-
const hiddenChildren = isMeasuring ? [] : childrenArray;
|
|
205
98
|
const renderBeforeItems = (0, _callRenderProp.callRenderProp)(this.props.renderBeforeItems);
|
|
206
99
|
const renderAfterItems = (0, _callRenderProp.callRenderProp)(this.props.renderAfterItems);
|
|
207
100
|
const hasRenderedContent = renderBeforeItems || renderAfterItems;
|
|
208
101
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
209
102
|
as: "nav",
|
|
210
|
-
css: [
|
|
103
|
+
css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
|
|
211
104
|
margin: margin,
|
|
212
105
|
display: hasRenderedContent ? 'flex' : 'block',
|
|
213
106
|
elementRef: this.handleRef
|
|
214
|
-
}), renderBeforeItems && (0, _emotion.jsx)("span", null, renderBeforeItems), (0, _emotion.jsx)(
|
|
215
|
-
|
|
216
|
-
|
|
107
|
+
}), renderBeforeItems && (0, _emotion.jsx)("span", null, renderBeforeItems), (0, _emotion.jsx)(_TruncateList.TruncateList, {
|
|
108
|
+
visibleItemsCount: visibleItemsCount,
|
|
109
|
+
debounce: debounce,
|
|
110
|
+
onUpdate: this.props.onUpdate,
|
|
111
|
+
renderHiddenItemMenu: hiddenChildren => this.renderMenu(hiddenChildren),
|
|
112
|
+
itemSpacing: styles === null || styles === void 0 ? void 0 : styles.horizontalMargin,
|
|
113
|
+
fixMenuTriggerWidth: styles === null || styles === void 0 ? void 0 : styles.menuTriggerWidth,
|
|
114
|
+
css: styles === null || styles === void 0 ? void 0 : styles.list,
|
|
217
115
|
"aria-label": (0, _callRenderProp.callRenderProp)(screenReaderLabel)
|
|
218
|
-
},
|
|
219
|
-
return this.renderListItem(child, false, index);
|
|
220
|
-
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
116
|
+
}, this.props.children), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
221
117
|
}
|
|
222
118
|
|
|
223
119
|
}, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
package/lib/AppNav/styles.js
CHANGED
|
@@ -49,36 +49,17 @@ const generateStyle = componentTheme => {
|
|
|
49
49
|
alignCenter: {
|
|
50
50
|
alignItems: 'center'
|
|
51
51
|
},
|
|
52
|
-
listItemWithMenuTrigger: {
|
|
53
|
-
label: 'appNav__listItemWithMenuTrigger',
|
|
54
|
-
minWidth: '0.0625rem',
|
|
55
|
-
marginInlineStart: componentTheme.horizontalMargin,
|
|
56
|
-
marginInlineEnd: '0',
|
|
57
|
-
flexShrink: 0,
|
|
58
|
-
flexBasis: componentTheme.menuTriggerWidth
|
|
59
|
-
},
|
|
60
|
-
listItem: {
|
|
61
|
-
label: 'appNav__listItem',
|
|
62
|
-
minWidth: '0.0625rem',
|
|
63
|
-
marginInlineStart: componentTheme.horizontalMargin,
|
|
64
|
-
marginInlineEnd: '0',
|
|
65
|
-
flexShrink: 0
|
|
66
|
-
},
|
|
67
52
|
list: {
|
|
68
53
|
label: 'appNav__list',
|
|
69
|
-
boxSizing: 'border-box',
|
|
70
|
-
listStyleType: 'none',
|
|
71
54
|
height: componentTheme.height,
|
|
72
|
-
margin: '0',
|
|
73
|
-
padding: '0',
|
|
74
|
-
display: 'flex',
|
|
75
|
-
alignItems: 'center',
|
|
76
55
|
flexGrow: 1,
|
|
77
56
|
flexShrink: 1,
|
|
78
57
|
flexBasis: '0',
|
|
79
|
-
minWidth: '0.0625rem'
|
|
58
|
+
minWidth: '0.0625rem',
|
|
59
|
+
paddingInlineStart: componentTheme.horizontalMargin
|
|
80
60
|
},
|
|
81
|
-
|
|
61
|
+
horizontalMargin: componentTheme.horizontalMargin.toString(),
|
|
62
|
+
menuTriggerWidth: componentTheme.menuTriggerWidth.toString()
|
|
82
63
|
};
|
|
83
64
|
};
|
|
84
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-navigation",
|
|
3
|
-
"version": "8.27.1-snapshot-
|
|
3
|
+
"version": "8.27.1-snapshot-14",
|
|
4
4
|
"description": "Main and application level navigational components",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,31 +23,32 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.27.1-snapshot-
|
|
27
|
-
"@instructure/ui-color-utils": "8.27.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-locator": "8.27.1-snapshot-
|
|
29
|
-
"@instructure/ui-test-utils": "8.27.1-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "8.27.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "8.27.1-snapshot-14",
|
|
27
|
+
"@instructure/ui-color-utils": "8.27.1-snapshot-14",
|
|
28
|
+
"@instructure/ui-test-locator": "8.27.1-snapshot-14",
|
|
29
|
+
"@instructure/ui-test-utils": "8.27.1-snapshot-14",
|
|
30
|
+
"@instructure/ui-themes": "8.27.1-snapshot-14"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.13.10",
|
|
34
|
-
"@instructure/console": "8.27.1-snapshot-
|
|
35
|
-
"@instructure/debounce": "8.27.1-snapshot-
|
|
36
|
-
"@instructure/emotion": "8.27.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "8.27.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-content": "8.27.1-snapshot-
|
|
39
|
-
"@instructure/ui-a11y-utils": "8.27.1-snapshot-
|
|
40
|
-
"@instructure/ui-badge": "8.27.1-snapshot-
|
|
41
|
-
"@instructure/ui-dom-utils": "8.27.1-snapshot-
|
|
42
|
-
"@instructure/ui-focusable": "8.27.1-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "8.27.1-snapshot-
|
|
44
|
-
"@instructure/ui-menu": "8.27.1-snapshot-
|
|
45
|
-
"@instructure/ui-prop-types": "8.27.1-snapshot-
|
|
46
|
-
"@instructure/ui-react-utils": "8.27.1-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "8.27.1-snapshot-
|
|
48
|
-
"@instructure/ui-tooltip": "8.27.1-snapshot-
|
|
49
|
-
"@instructure/ui-
|
|
50
|
-
"@instructure/ui-
|
|
34
|
+
"@instructure/console": "8.27.1-snapshot-14",
|
|
35
|
+
"@instructure/debounce": "8.27.1-snapshot-14",
|
|
36
|
+
"@instructure/emotion": "8.27.1-snapshot-14",
|
|
37
|
+
"@instructure/shared-types": "8.27.1-snapshot-14",
|
|
38
|
+
"@instructure/ui-a11y-content": "8.27.1-snapshot-14",
|
|
39
|
+
"@instructure/ui-a11y-utils": "8.27.1-snapshot-14",
|
|
40
|
+
"@instructure/ui-badge": "8.27.1-snapshot-14",
|
|
41
|
+
"@instructure/ui-dom-utils": "8.27.1-snapshot-14",
|
|
42
|
+
"@instructure/ui-focusable": "8.27.1-snapshot-14",
|
|
43
|
+
"@instructure/ui-icons": "8.27.1-snapshot-14",
|
|
44
|
+
"@instructure/ui-menu": "8.27.1-snapshot-14",
|
|
45
|
+
"@instructure/ui-prop-types": "8.27.1-snapshot-14",
|
|
46
|
+
"@instructure/ui-react-utils": "8.27.1-snapshot-14",
|
|
47
|
+
"@instructure/ui-testable": "8.27.1-snapshot-14",
|
|
48
|
+
"@instructure/ui-tooltip": "8.27.1-snapshot-14",
|
|
49
|
+
"@instructure/ui-truncate-list": "8.27.1-snapshot-14",
|
|
50
|
+
"@instructure/ui-utils": "8.27.1-snapshot-14",
|
|
51
|
+
"@instructure/ui-view": "8.27.1-snapshot-14",
|
|
51
52
|
"prop-types": "^15"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|