@instructure/ui-navigation 8.27.1-snapshot-7 → 8.27.1-snapshot-13
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 +1 -1
- package/es/AppNav/index.js +17 -118
- package/es/AppNav/styles.js +4 -23
- package/lib/AppNav/index.js +19 -122
- package/lib/AppNav/styles.js +4 -23
- package/package.json +24 -23
- package/src/AppNav/index.tsx +39 -132
- 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,7 +3,7 @@
|
|
|
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-13](https://github.com/instructure/instructure-ui/compare/v8.27.0...v8.27.1-snapshot-13) (2022-08-17)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Features
|
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,62 +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
|
-
const _getBoundingClientRec2 = getBoundingClientRect(item),
|
|
71
|
-
width = _getBoundingClientRec2.width;
|
|
72
|
-
|
|
73
|
-
return width;
|
|
74
|
-
});
|
|
75
|
-
let currentWidth = 0;
|
|
76
|
-
|
|
77
|
-
for (let i = 0; i < itemWidths.length; i++) {
|
|
78
|
-
currentWidth += itemWidths[i];
|
|
79
|
-
|
|
80
|
-
if (currentWidth <= navWidth - menuTriggerWidth) {
|
|
81
|
-
visibleItemsCount++;
|
|
82
|
-
} else {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
visibleItemsCount
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
this.handleResize = () => {
|
|
94
|
-
this.setState({
|
|
95
|
-
isMeasuring: true
|
|
96
|
-
}, () => {
|
|
97
|
-
const _this$measureItems = this.measureItems(),
|
|
98
|
-
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
99
|
-
|
|
100
|
-
if (typeof this.props.onUpdate === 'function') {
|
|
101
|
-
this.props.onUpdate({
|
|
102
|
-
visibleItemsCount
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.setState({
|
|
107
|
-
isMeasuring: false
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
53
|
|
|
112
54
|
this.handleRef = el => {
|
|
113
55
|
const elementRef = this.props.elementRef;
|
|
@@ -123,27 +65,6 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
123
65
|
var _this$props$makeStyle, _this$props;
|
|
124
66
|
|
|
125
67
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
126
|
-
|
|
127
|
-
const _getBoundingClientRec3 = getBoundingClientRect(this._list),
|
|
128
|
-
origWidth = _getBoundingClientRec3.width;
|
|
129
|
-
|
|
130
|
-
this._debounced = debounce(this.handleResize, this.props.debounce, {
|
|
131
|
-
leading: true,
|
|
132
|
-
trailing: true
|
|
133
|
-
});
|
|
134
|
-
this._resizeListener = new ResizeObserver(entries => {
|
|
135
|
-
for (const entry of entries) {
|
|
136
|
-
const width = entry.contentRect.width;
|
|
137
|
-
|
|
138
|
-
if (origWidth !== width) {
|
|
139
|
-
this._debounced();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
this._resizeListener.observe(this._list);
|
|
145
|
-
|
|
146
|
-
this.handleResize();
|
|
147
68
|
}
|
|
148
69
|
|
|
149
70
|
componentDidUpdate() {
|
|
@@ -152,27 +73,8 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
152
73
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
153
74
|
}
|
|
154
75
|
|
|
155
|
-
componentWillUnmount() {
|
|
156
|
-
if (this._resizeListener) {
|
|
157
|
-
this._resizeListener.disconnect();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (this._debounced) {
|
|
161
|
-
this._debounced.cancel();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
renderListItem(item, isMenuTrigger, key) {
|
|
166
|
-
var _this$props$styles2, _this$props$styles3;
|
|
167
|
-
|
|
168
|
-
return jsx("li", {
|
|
169
|
-
key: key,
|
|
170
|
-
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
|
|
171
|
-
}, item);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
76
|
renderMenu(items) {
|
|
175
|
-
|
|
77
|
+
return jsx(Menu, {
|
|
176
78
|
trigger: jsx(AppNav.Item, {
|
|
177
79
|
renderLabel: callRenderProp(this.props.renderTruncateLabel)
|
|
178
80
|
})
|
|
@@ -183,38 +85,35 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
183
85
|
key: index
|
|
184
86
|
}, callRenderProp(item.props.renderLabel));
|
|
185
87
|
}));
|
|
186
|
-
return this.renderListItem(menu, true);
|
|
187
88
|
}
|
|
188
89
|
|
|
189
90
|
render() {
|
|
190
|
-
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
191
|
-
|
|
192
91
|
const _this$props3 = this.props,
|
|
193
|
-
children = _this$props3.children,
|
|
194
92
|
visibleItemsCount = _this$props3.visibleItemsCount,
|
|
195
93
|
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
196
|
-
margin = _this$props3.margin
|
|
94
|
+
margin = _this$props3.margin,
|
|
95
|
+
debounce = _this$props3.debounce,
|
|
96
|
+
styles = _this$props3.styles;
|
|
197
97
|
const passthroughProps = View.omitViewProps(omitProps(this.props, AppNav.allowedProps), AppNav);
|
|
198
|
-
const isMeasuring = this.state.isMeasuring;
|
|
199
|
-
const childrenArray = Children.toArray(children);
|
|
200
|
-
const visibleChildren = isMeasuring ? childrenArray : childrenArray.splice(0, visibleItemsCount);
|
|
201
|
-
const hiddenChildren = isMeasuring ? [] : childrenArray;
|
|
202
98
|
const renderBeforeItems = callRenderProp(this.props.renderBeforeItems);
|
|
203
99
|
const renderAfterItems = callRenderProp(this.props.renderAfterItems);
|
|
204
100
|
const hasRenderedContent = renderBeforeItems || renderAfterItems;
|
|
205
101
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
206
102
|
as: "nav",
|
|
207
|
-
css: [
|
|
103
|
+
css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
|
|
208
104
|
margin: margin,
|
|
209
105
|
display: hasRenderedContent ? 'flex' : 'block',
|
|
210
106
|
elementRef: this.handleRef
|
|
211
|
-
}), renderBeforeItems && jsx("span", null, renderBeforeItems), jsx(
|
|
212
|
-
|
|
213
|
-
|
|
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,
|
|
214
115
|
"aria-label": callRenderProp(screenReaderLabel)
|
|
215
|
-
},
|
|
216
|
-
return this.renderListItem(child, false, index);
|
|
217
|
-
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && jsx("span", null, renderAfterItems));
|
|
116
|
+
}, this.props.children), renderAfterItems && jsx("span", null, renderAfterItems));
|
|
218
117
|
}
|
|
219
118
|
|
|
220
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,62 +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
|
-
const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
|
|
69
|
-
width = _getBoundingClientRec2.width;
|
|
70
|
-
|
|
71
|
-
return width;
|
|
72
|
-
});
|
|
73
|
-
let currentWidth = 0;
|
|
74
|
-
|
|
75
|
-
for (let i = 0; i < itemWidths.length; i++) {
|
|
76
|
-
currentWidth += itemWidths[i];
|
|
77
|
-
|
|
78
|
-
if (currentWidth <= navWidth - menuTriggerWidth) {
|
|
79
|
-
visibleItemsCount++;
|
|
80
|
-
} else {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
visibleItemsCount
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
this.handleResize = () => {
|
|
92
|
-
this.setState({
|
|
93
|
-
isMeasuring: true
|
|
94
|
-
}, () => {
|
|
95
|
-
const _this$measureItems = this.measureItems(),
|
|
96
|
-
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
97
|
-
|
|
98
|
-
if (typeof this.props.onUpdate === 'function') {
|
|
99
|
-
this.props.onUpdate({
|
|
100
|
-
visibleItemsCount
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
this.setState({
|
|
105
|
-
isMeasuring: false
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
51
|
|
|
110
52
|
this.handleRef = el => {
|
|
111
53
|
const elementRef = this.props.elementRef;
|
|
@@ -121,27 +63,6 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
121
63
|
var _this$props$makeStyle, _this$props;
|
|
122
64
|
|
|
123
65
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
124
|
-
|
|
125
|
-
const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
126
|
-
origWidth = _getBoundingClientRec3.width;
|
|
127
|
-
|
|
128
|
-
this._debounced = (0, _debounce.debounce)(this.handleResize, this.props.debounce, {
|
|
129
|
-
leading: true,
|
|
130
|
-
trailing: true
|
|
131
|
-
});
|
|
132
|
-
this._resizeListener = new ResizeObserver(entries => {
|
|
133
|
-
for (const entry of entries) {
|
|
134
|
-
const width = entry.contentRect.width;
|
|
135
|
-
|
|
136
|
-
if (origWidth !== width) {
|
|
137
|
-
this._debounced();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
this._resizeListener.observe(this._list);
|
|
143
|
-
|
|
144
|
-
this.handleResize();
|
|
145
66
|
}
|
|
146
67
|
|
|
147
68
|
componentDidUpdate() {
|
|
@@ -150,27 +71,8 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
150
71
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
151
72
|
}
|
|
152
73
|
|
|
153
|
-
componentWillUnmount() {
|
|
154
|
-
if (this._resizeListener) {
|
|
155
|
-
this._resizeListener.disconnect();
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this._debounced) {
|
|
159
|
-
this._debounced.cancel();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
renderListItem(item, isMenuTrigger, key) {
|
|
164
|
-
var _this$props$styles2, _this$props$styles3;
|
|
165
|
-
|
|
166
|
-
return (0, _emotion.jsx)("li", {
|
|
167
|
-
key: key,
|
|
168
|
-
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
|
|
169
|
-
}, item);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
74
|
renderMenu(items) {
|
|
173
|
-
|
|
75
|
+
return (0, _emotion.jsx)(_Menu.Menu, {
|
|
174
76
|
trigger: (0, _emotion.jsx)(AppNav.Item, {
|
|
175
77
|
renderLabel: (0, _callRenderProp.callRenderProp)(this.props.renderTruncateLabel)
|
|
176
78
|
})
|
|
@@ -181,42 +83,37 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
181
83
|
key: index
|
|
182
84
|
}, (0, _callRenderProp.callRenderProp)(item.props.renderLabel));
|
|
183
85
|
}));
|
|
184
|
-
return this.renderListItem(menu, true);
|
|
185
86
|
}
|
|
186
87
|
|
|
187
88
|
render() {
|
|
188
|
-
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
189
|
-
|
|
190
89
|
const _this$props3 = this.props,
|
|
191
|
-
children = _this$props3.children,
|
|
192
90
|
visibleItemsCount = _this$props3.visibleItemsCount,
|
|
193
91
|
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
194
|
-
margin = _this$props3.margin
|
|
92
|
+
margin = _this$props3.margin,
|
|
93
|
+
debounce = _this$props3.debounce,
|
|
94
|
+
styles = _this$props3.styles;
|
|
195
95
|
|
|
196
96
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, AppNav.allowedProps), AppNav);
|
|
197
97
|
|
|
198
|
-
const isMeasuring = this.state.isMeasuring;
|
|
199
|
-
|
|
200
|
-
const childrenArray = _react.Children.toArray(children);
|
|
201
|
-
|
|
202
|
-
const visibleChildren = isMeasuring ? childrenArray : childrenArray.splice(0, visibleItemsCount);
|
|
203
|
-
const hiddenChildren = isMeasuring ? [] : childrenArray;
|
|
204
98
|
const renderBeforeItems = (0, _callRenderProp.callRenderProp)(this.props.renderBeforeItems);
|
|
205
99
|
const renderAfterItems = (0, _callRenderProp.callRenderProp)(this.props.renderAfterItems);
|
|
206
100
|
const hasRenderedContent = renderBeforeItems || renderAfterItems;
|
|
207
101
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
208
102
|
as: "nav",
|
|
209
|
-
css: [
|
|
103
|
+
css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
|
|
210
104
|
margin: margin,
|
|
211
105
|
display: hasRenderedContent ? 'flex' : 'block',
|
|
212
106
|
elementRef: this.handleRef
|
|
213
|
-
}), renderBeforeItems && (0, _emotion.jsx)("span", null, renderBeforeItems), (0, _emotion.jsx)(
|
|
214
|
-
|
|
215
|
-
|
|
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,
|
|
216
115
|
"aria-label": (0, _callRenderProp.callRenderProp)(screenReaderLabel)
|
|
217
|
-
},
|
|
218
|
-
return this.renderListItem(child, false, index);
|
|
219
|
-
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
116
|
+
}, this.props.children), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
220
117
|
}
|
|
221
118
|
|
|
222
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-13",
|
|
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-13",
|
|
27
|
+
"@instructure/ui-color-utils": "8.27.1-snapshot-13",
|
|
28
|
+
"@instructure/ui-test-locator": "8.27.1-snapshot-13",
|
|
29
|
+
"@instructure/ui-test-utils": "8.27.1-snapshot-13",
|
|
30
|
+
"@instructure/ui-themes": "8.27.1-snapshot-13"
|
|
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-13",
|
|
35
|
+
"@instructure/debounce": "8.27.1-snapshot-13",
|
|
36
|
+
"@instructure/emotion": "8.27.1-snapshot-13",
|
|
37
|
+
"@instructure/shared-types": "8.27.1-snapshot-13",
|
|
38
|
+
"@instructure/ui-a11y-content": "8.27.1-snapshot-13",
|
|
39
|
+
"@instructure/ui-a11y-utils": "8.27.1-snapshot-13",
|
|
40
|
+
"@instructure/ui-badge": "8.27.1-snapshot-13",
|
|
41
|
+
"@instructure/ui-dom-utils": "8.27.1-snapshot-13",
|
|
42
|
+
"@instructure/ui-focusable": "8.27.1-snapshot-13",
|
|
43
|
+
"@instructure/ui-icons": "8.27.1-snapshot-13",
|
|
44
|
+
"@instructure/ui-menu": "8.27.1-snapshot-13",
|
|
45
|
+
"@instructure/ui-prop-types": "8.27.1-snapshot-13",
|
|
46
|
+
"@instructure/ui-react-utils": "8.27.1-snapshot-13",
|
|
47
|
+
"@instructure/ui-testable": "8.27.1-snapshot-13",
|
|
48
|
+
"@instructure/ui-tooltip": "8.27.1-snapshot-13",
|
|
49
|
+
"@instructure/ui-truncate-list": "8.27.1-snapshot-13",
|
|
50
|
+
"@instructure/ui-utils": "8.27.1-snapshot-13",
|
|
51
|
+
"@instructure/ui-view": "8.27.1-snapshot-13",
|
|
51
52
|
"prop-types": "^15"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|