@instructure/ui-navigation 8.25.1-snapshot-7 → 8.25.1-snapshot-10
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/Item/index.js +39 -38
- package/es/AppNav/index.js +85 -84
- package/es/Navigation/NavigationItem/index.js +20 -19
- package/es/Navigation/index.js +26 -20
- package/lib/AppNav/Item/index.js +39 -38
- package/lib/AppNav/index.js +85 -84
- package/lib/Navigation/NavigationItem/index.js +21 -20
- package/lib/Navigation/index.js +26 -20
- package/package.json +23 -23
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/AppNav/AppNavLocator.d.ts +14 -14
- package/types/AppNav/Item/AppNavItemLocator.d.ts +4 -4
- package/types/Navigation/NavigationItem/NavigationItemLocator.d.ts +4 -4
- package/types/Navigation/NavigationLocator.d.ts +14 -14
package/lib/AppNav/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
35
35
|
|
|
36
36
|
var _props = require("./props");
|
|
37
37
|
|
|
38
|
-
var _dec, _dec2, _class
|
|
38
|
+
var _dec, _dec2, _class;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
---
|
|
@@ -43,88 +43,34 @@ category: components
|
|
|
43
43
|
---
|
|
44
44
|
@tsProps
|
|
45
45
|
**/
|
|
46
|
-
let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
111
|
-
this.handleRef = el => {
|
|
112
|
-
const elementRef = this.props.elementRef;
|
|
113
|
-
this.ref = el;
|
|
114
|
-
|
|
115
|
-
if (typeof elementRef === 'function') {
|
|
116
|
-
elementRef(el);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
46
|
+
let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class AppNav extends _react.Component {
|
|
47
|
+
static displayName = "AppNav";
|
|
48
|
+
static componentId = 'AppNav';
|
|
49
|
+
static allowedProps = _props.allowedProps;
|
|
50
|
+
static propTypes = _props.propTypes;
|
|
51
|
+
static defaultProps = {
|
|
52
|
+
children: null,
|
|
53
|
+
debounce: 300,
|
|
54
|
+
margin: '0',
|
|
55
|
+
renderTruncateLabel: () => 'More',
|
|
56
|
+
visibleItemsCount: 0
|
|
57
|
+
};
|
|
58
|
+
static Item = _Item.Item;
|
|
59
|
+
state = {
|
|
60
|
+
isMeasuring: false
|
|
61
|
+
};
|
|
62
|
+
ref = null;
|
|
63
|
+
_list = null;
|
|
64
|
+
_debounced;
|
|
65
|
+
_resizeListener;
|
|
120
66
|
|
|
121
67
|
componentDidMount() {
|
|
122
68
|
var _this$props$makeStyle, _this$props;
|
|
123
69
|
|
|
124
70
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
125
71
|
|
|
126
|
-
const
|
|
127
|
-
origWidth =
|
|
72
|
+
const _getBoundingClientRec = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
73
|
+
origWidth = _getBoundingClientRec.width;
|
|
128
74
|
|
|
129
75
|
this._debounced = (0, _debounce.debounce)(this.handleResize, this.props.debounce, {
|
|
130
76
|
leading: true,
|
|
@@ -161,6 +107,67 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
161
107
|
}
|
|
162
108
|
}
|
|
163
109
|
|
|
110
|
+
measureItems = () => {
|
|
111
|
+
var _this$props$styles;
|
|
112
|
+
|
|
113
|
+
const menuTriggerWidth = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
|
|
114
|
+
let visibleItemsCount = 0;
|
|
115
|
+
|
|
116
|
+
if (this._list) {
|
|
117
|
+
const _getBoundingClientRec2 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
118
|
+
navWidth = _getBoundingClientRec2.width;
|
|
119
|
+
|
|
120
|
+
const itemWidths = Array.from(this._list.getElementsByTagName('li')).map(item => {
|
|
121
|
+
// Todo: if item's type isn't `unknown`, can remove `Element`
|
|
122
|
+
const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(item),
|
|
123
|
+
width = _getBoundingClientRec3.width;
|
|
124
|
+
|
|
125
|
+
return width;
|
|
126
|
+
});
|
|
127
|
+
let currentWidth = 0;
|
|
128
|
+
|
|
129
|
+
for (let i = 0; i < itemWidths.length; i++) {
|
|
130
|
+
currentWidth += itemWidths[i];
|
|
131
|
+
|
|
132
|
+
if (currentWidth <= navWidth - menuTriggerWidth) {
|
|
133
|
+
visibleItemsCount++;
|
|
134
|
+
} else {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
visibleItemsCount
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
handleResize = () => {
|
|
145
|
+
this.setState({
|
|
146
|
+
isMeasuring: true
|
|
147
|
+
}, () => {
|
|
148
|
+
const _this$measureItems = this.measureItems(),
|
|
149
|
+
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
150
|
+
|
|
151
|
+
if (typeof this.props.onUpdate === 'function') {
|
|
152
|
+
this.props.onUpdate({
|
|
153
|
+
visibleItemsCount
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.setState({
|
|
158
|
+
isMeasuring: false
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
handleRef = el => {
|
|
163
|
+
const elementRef = this.props.elementRef;
|
|
164
|
+
this.ref = el;
|
|
165
|
+
|
|
166
|
+
if (typeof elementRef === 'function') {
|
|
167
|
+
elementRef(el);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
164
171
|
renderListItem(item, isMenuTrigger, key) {
|
|
165
172
|
var _this$props$styles2, _this$props$styles3;
|
|
166
173
|
|
|
@@ -220,13 +227,7 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
220
227
|
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
221
228
|
}
|
|
222
229
|
|
|
223
|
-
}
|
|
224
|
-
children: null,
|
|
225
|
-
debounce: 300,
|
|
226
|
-
margin: '0',
|
|
227
|
-
renderTruncateLabel: () => 'More',
|
|
228
|
-
visibleItemsCount: 0
|
|
229
|
-
}, _class2.Item = _Item.Item, _class2)) || _class) || _class);
|
|
230
|
+
}) || _class) || _class);
|
|
230
231
|
exports.AppNav = AppNav;
|
|
231
232
|
var _default = AppNav;
|
|
232
233
|
exports.default = _default;
|
|
@@ -27,7 +27,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
27
27
|
|
|
28
28
|
var _props = require("./props");
|
|
29
29
|
|
|
30
|
-
var _dec, _dec2, _class
|
|
30
|
+
var _dec, _dec2, _class;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
---
|
|
@@ -36,20 +36,25 @@ id: Navigation.Item
|
|
|
36
36
|
---
|
|
37
37
|
@tsProps
|
|
38
38
|
**/
|
|
39
|
-
let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = class NavigationItem extends _react.Component {
|
|
40
|
+
static displayName = "NavigationItem";
|
|
41
|
+
static componentId = 'Navigation.Item';
|
|
42
|
+
static allowedProps = _props.allowedProps;
|
|
43
|
+
static propTypes = _props.propTypes;
|
|
44
|
+
static defaultProps = {
|
|
45
|
+
as: 'a',
|
|
46
|
+
selected: false,
|
|
47
|
+
minimized: false
|
|
48
|
+
};
|
|
49
|
+
ref = null;
|
|
50
|
+
handleRef = el => {
|
|
51
|
+
const elementRef = this.props.elementRef;
|
|
52
|
+
this.ref = el;
|
|
53
|
+
|
|
54
|
+
if (typeof elementRef === 'function') {
|
|
55
|
+
elementRef(el);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
53
58
|
|
|
54
59
|
componentDidMount() {
|
|
55
60
|
var _this$props$makeStyle, _this$props;
|
|
@@ -105,11 +110,7 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
105
110
|
}, link) : link;
|
|
106
111
|
}
|
|
107
112
|
|
|
108
|
-
}
|
|
109
|
-
as: 'a',
|
|
110
|
-
selected: false,
|
|
111
|
-
minimized: false
|
|
112
|
-
}, _class2)) || _class) || _class);
|
|
113
|
+
}) || _class) || _class);
|
|
113
114
|
exports.NavigationItem = NavigationItem;
|
|
114
115
|
var _default = NavigationItem;
|
|
115
116
|
exports.default = _default;
|
package/lib/Navigation/index.js
CHANGED
|
@@ -40,7 +40,7 @@ var _theme = _interopRequireDefault(require("./theme"));
|
|
|
40
40
|
|
|
41
41
|
var _props = require("./props");
|
|
42
42
|
|
|
43
|
-
var _dec, _dec2, _dec3, _class
|
|
43
|
+
var _dec, _dec2, _dec3, _class;
|
|
44
44
|
|
|
45
45
|
const navMinimized = _ref => {
|
|
46
46
|
let minimized = _ref.minimized;
|
|
@@ -56,21 +56,22 @@ category: components/deprecated
|
|
|
56
56
|
**/
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec3 = (0, _deprecated.deprecated)('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class =
|
|
59
|
+
let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec3 = (0, _deprecated.deprecated)('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = class Navigation extends _react.Component {
|
|
60
|
+
static displayName = "Navigation";
|
|
61
|
+
static componentId = 'Navigation';
|
|
62
|
+
static allowedProps = _props.allowedProps;
|
|
63
|
+
static propTypes = _props.propTypes;
|
|
64
|
+
static defaultProps = {
|
|
65
|
+
children: null,
|
|
66
|
+
defaultMinimized: false,
|
|
67
|
+
// TODO we should investigate later if it used or not
|
|
68
|
+
onClick: function (_e) {}
|
|
69
|
+
};
|
|
70
|
+
static Item = _NavigationItem.NavigationItem;
|
|
71
|
+
ref = null;
|
|
72
|
+
|
|
60
73
|
constructor(props) {
|
|
61
74
|
super(props);
|
|
62
|
-
this.ref = null;
|
|
63
|
-
|
|
64
|
-
this.handleNavToggle = event => {
|
|
65
|
-
if (!this.isControlled()) {
|
|
66
|
-
this.setState(navMinimized);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (typeof this.props.onMinimized === 'function') {
|
|
70
|
-
this.props.onMinimized(event, !this.minimized);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
75
|
this.state = {
|
|
75
76
|
minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
|
|
76
77
|
};
|
|
@@ -105,6 +106,16 @@ let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
105
106
|
return typeof props.minimized === 'boolean';
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
handleNavToggle = event => {
|
|
110
|
+
if (!this.isControlled()) {
|
|
111
|
+
this.setState(navMinimized);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (typeof this.props.onMinimized === 'function') {
|
|
115
|
+
this.props.onMinimized(event, !this.minimized);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
108
119
|
renderChildren() {
|
|
109
120
|
return _react.Children.map(this.props.children, child => {
|
|
110
121
|
var _this$props$styles;
|
|
@@ -148,12 +159,7 @@ let Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default
|
|
|
148
159
|
})));
|
|
149
160
|
}
|
|
150
161
|
|
|
151
|
-
}
|
|
152
|
-
children: null,
|
|
153
|
-
defaultMinimized: false,
|
|
154
|
-
// TODO we should investigate later if it used or not
|
|
155
|
-
onClick: function (_e) {}
|
|
156
|
-
}, _class2.Item = _NavigationItem.NavigationItem, _class2)) || _class) || _class) || _class);
|
|
162
|
+
}) || _class) || _class) || _class);
|
|
157
163
|
exports.Navigation = Navigation;
|
|
158
164
|
var _default = Navigation;
|
|
159
165
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-navigation",
|
|
3
|
-
"version": "8.25.1-snapshot-
|
|
3
|
+
"version": "8.25.1-snapshot-10",
|
|
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,31 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.25.1-snapshot-
|
|
27
|
-
"@instructure/ui-color-utils": "8.25.1-snapshot-
|
|
28
|
-
"@instructure/ui-test-locator": "8.25.1-snapshot-
|
|
29
|
-
"@instructure/ui-test-utils": "8.25.1-snapshot-
|
|
30
|
-
"@instructure/ui-themes": "8.25.1-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "8.25.1-snapshot-10",
|
|
27
|
+
"@instructure/ui-color-utils": "8.25.1-snapshot-10",
|
|
28
|
+
"@instructure/ui-test-locator": "8.25.1-snapshot-10",
|
|
29
|
+
"@instructure/ui-test-utils": "8.25.1-snapshot-10",
|
|
30
|
+
"@instructure/ui-themes": "8.25.1-snapshot-10"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.13.10",
|
|
34
|
-
"@instructure/console": "8.25.1-snapshot-
|
|
35
|
-
"@instructure/debounce": "8.25.1-snapshot-
|
|
36
|
-
"@instructure/emotion": "8.25.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "8.25.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-content": "8.25.1-snapshot-
|
|
39
|
-
"@instructure/ui-a11y-utils": "8.25.1-snapshot-
|
|
40
|
-
"@instructure/ui-badge": "8.25.1-snapshot-
|
|
41
|
-
"@instructure/ui-dom-utils": "8.25.1-snapshot-
|
|
42
|
-
"@instructure/ui-focusable": "8.25.1-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "8.25.1-snapshot-
|
|
44
|
-
"@instructure/ui-menu": "8.25.1-snapshot-
|
|
45
|
-
"@instructure/ui-prop-types": "8.25.1-snapshot-
|
|
46
|
-
"@instructure/ui-react-utils": "8.25.1-snapshot-
|
|
47
|
-
"@instructure/ui-testable": "8.25.1-snapshot-
|
|
48
|
-
"@instructure/ui-tooltip": "8.25.1-snapshot-
|
|
49
|
-
"@instructure/ui-utils": "8.25.1-snapshot-
|
|
50
|
-
"@instructure/ui-view": "8.25.1-snapshot-
|
|
34
|
+
"@instructure/console": "8.25.1-snapshot-10",
|
|
35
|
+
"@instructure/debounce": "8.25.1-snapshot-10",
|
|
36
|
+
"@instructure/emotion": "8.25.1-snapshot-10",
|
|
37
|
+
"@instructure/shared-types": "8.25.1-snapshot-10",
|
|
38
|
+
"@instructure/ui-a11y-content": "8.25.1-snapshot-10",
|
|
39
|
+
"@instructure/ui-a11y-utils": "8.25.1-snapshot-10",
|
|
40
|
+
"@instructure/ui-badge": "8.25.1-snapshot-10",
|
|
41
|
+
"@instructure/ui-dom-utils": "8.25.1-snapshot-10",
|
|
42
|
+
"@instructure/ui-focusable": "8.25.1-snapshot-10",
|
|
43
|
+
"@instructure/ui-icons": "8.25.1-snapshot-10",
|
|
44
|
+
"@instructure/ui-menu": "8.25.1-snapshot-10",
|
|
45
|
+
"@instructure/ui-prop-types": "8.25.1-snapshot-10",
|
|
46
|
+
"@instructure/ui-react-utils": "8.25.1-snapshot-10",
|
|
47
|
+
"@instructure/ui-testable": "8.25.1-snapshot-10",
|
|
48
|
+
"@instructure/ui-tooltip": "8.25.1-snapshot-10",
|
|
49
|
+
"@instructure/ui-utils": "8.25.1-snapshot-10",
|
|
50
|
+
"@instructure/ui-view": "8.25.1-snapshot-10",
|
|
51
51
|
"prop-types": "^15"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|