@instructure/ui-navigation 8.8.1-snapshot.8 → 8.9.1
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 +10 -0
- package/es/AppNav/Item/index.js +21 -77
- package/es/AppNav/Item/props.js +79 -0
- package/es/AppNav/index.js +26 -80
- package/es/AppNav/props.js +87 -0
- package/es/Navigation/NavigationItem/index.js +25 -60
- package/{src/AppNav/types.ts → es/Navigation/NavigationItem/props.js} +37 -14
- package/es/Navigation/index.js +18 -57
- package/es/Navigation/props.js +68 -0
- package/lib/AppNav/Item/index.js +21 -77
- package/lib/AppNav/Item/props.js +90 -0
- package/lib/AppNav/index.js +25 -80
- package/lib/AppNav/props.js +101 -0
- package/lib/Navigation/NavigationItem/index.js +25 -60
- package/lib/Navigation/NavigationItem/props.js +73 -0
- package/lib/Navigation/index.js +19 -61
- package/lib/Navigation/props.js +83 -0
- package/package.json +24 -25
- package/src/AppNav/Item/index.tsx +8 -62
- package/src/AppNav/Item/props.ts +107 -0
- package/src/AppNav/Item/styles.ts +1 -1
- package/src/AppNav/index.tsx +13 -69
- package/src/AppNav/props.ts +118 -0
- package/src/Navigation/NavigationItem/index.tsx +10 -45
- package/src/Navigation/NavigationItem/props.ts +87 -0
- package/src/Navigation/NavigationItem/styles.ts +1 -1
- package/src/Navigation/index.tsx +13 -56
- package/src/Navigation/props.ts +108 -0
- package/src/Navigation/styles.ts +1 -1
- package/src/index.ts +4 -4
- package/types/AppNav/Item/index.d.ts +25 -53
- package/types/AppNav/Item/index.d.ts.map +1 -1
- package/types/AppNav/Item/props.d.ts +23 -0
- package/types/AppNav/Item/props.d.ts.map +1 -0
- package/types/AppNav/Item/styles.d.ts +1 -1
- package/types/AppNav/index.d.ts +25 -58
- package/types/AppNav/index.d.ts.map +1 -1
- package/types/AppNav/props.d.ts +23 -0
- package/types/AppNav/props.d.ts.map +1 -0
- package/types/Navigation/NavigationItem/index.d.ts +19 -35
- package/types/Navigation/NavigationItem/index.d.ts.map +1 -1
- package/types/Navigation/NavigationItem/props.d.ts +20 -0
- package/types/Navigation/NavigationItem/props.d.ts.map +1 -0
- package/types/Navigation/NavigationItem/styles.d.ts +1 -1
- package/types/Navigation/index.d.ts +26 -42
- package/types/Navigation/index.d.ts.map +1 -1
- package/types/Navigation/props.d.ts +27 -0
- package/types/Navigation/props.d.ts.map +1 -0
- package/types/Navigation/styles.d.ts +1 -1
- package/types/index.d.ts +4 -4
- package/LICENSE.md +0 -27
- package/es/AppNav/Item/types.js +0 -1
- package/es/AppNav/types.js +0 -1
- package/es/Navigation/NavigationItem/types.js +0 -1
- package/es/Navigation/types.js +0 -1
- package/lib/AppNav/Item/types.js +0 -1
- package/lib/AppNav/types.js +0 -1
- package/lib/Navigation/NavigationItem/types.js +0 -1
- package/lib/Navigation/types.js +0 -1
- package/src/AppNav/Item/types.ts +0 -40
- package/src/Navigation/NavigationItem/types.ts +0 -37
- package/src/Navigation/types.ts +0 -42
- package/types/AppNav/Item/types.d.ts +0 -17
- package/types/AppNav/Item/types.d.ts.map +0 -1
- package/types/AppNav/types.d.ts +0 -16
- package/types/AppNav/types.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/types.d.ts +0 -14
- package/types/Navigation/NavigationItem/types.d.ts.map +0 -1
- package/types/Navigation/types.d.ts +0 -18
- package/types/Navigation/types.d.ts.map +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
const propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* The text to display. If the `icon` prop is used, label text must be wrapped
|
|
38
|
+
* in `ScreenReaderContent`.
|
|
39
|
+
*/
|
|
40
|
+
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Content to display after the renderLabel text, such as a badge
|
|
44
|
+
*/
|
|
45
|
+
renderAfter: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
49
|
+
*/
|
|
50
|
+
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* If the item goes to a new page, pass an href
|
|
54
|
+
*/
|
|
55
|
+
href: _propTypes.default.string,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If the item does not go to a new page, pass an onClick
|
|
59
|
+
*/
|
|
60
|
+
onClick: _propTypes.default.func,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Denotes which item is currently selected
|
|
64
|
+
*/
|
|
65
|
+
isSelected: _propTypes.default.bool,
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* provides a reference to the underlying focusable (`button` or `a`) element
|
|
69
|
+
*/
|
|
70
|
+
elementRef: _propTypes.default.func,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
74
|
+
*/
|
|
75
|
+
as: _propTypes.default.elementType,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Specify the mouse cursor to use on :hover.
|
|
79
|
+
* The `pointer` cursor is used by default.
|
|
80
|
+
*/
|
|
81
|
+
cursor: _propTypes.default.string,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Disables the link or button visually and functionally
|
|
85
|
+
*/
|
|
86
|
+
isDisabled: _propTypes.default.bool
|
|
87
|
+
};
|
|
88
|
+
exports.propTypes = propTypes;
|
|
89
|
+
const allowedProps = ['renderLabel', 'renderAfter', 'renderIcon', 'href', 'onClick', 'isSelected', 'elementRef', 'as', 'cursor', 'isDisabled'];
|
|
90
|
+
exports.allowedProps = allowedProps;
|
package/lib/AppNav/index.js
CHANGED
|
@@ -9,12 +9,8 @@ exports.default = exports.AppNav = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _emotion = require("@instructure/emotion");
|
|
15
13
|
|
|
16
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
17
|
-
|
|
18
14
|
var _getBoundingClientRect = require("@instructure/ui-dom-utils/lib/getBoundingClientRect.js");
|
|
19
15
|
|
|
20
16
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
@@ -37,6 +33,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
37
33
|
|
|
38
34
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
39
35
|
|
|
36
|
+
var _props = require("./props");
|
|
37
|
+
|
|
40
38
|
var _dec, _dec2, _class, _class2, _temp;
|
|
41
39
|
|
|
42
40
|
/**
|
|
@@ -53,7 +51,9 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
53
51
|
this._list = null;
|
|
54
52
|
|
|
55
53
|
this.measureItems = () => {
|
|
56
|
-
|
|
54
|
+
var _this$props$styles;
|
|
55
|
+
|
|
56
|
+
const menuTriggerWidth = (0, _px.px)((_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menuTriggerWidth);
|
|
57
57
|
let visibleItemsCount = 0;
|
|
58
58
|
|
|
59
59
|
if (this._list) {
|
|
@@ -103,7 +103,9 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
componentDidMount() {
|
|
106
|
-
|
|
106
|
+
var _this$props$makeStyle, _this$props;
|
|
107
|
+
|
|
108
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
107
109
|
|
|
108
110
|
const _getBoundingClientRec3 = (0, _getBoundingClientRect.getBoundingClientRect)(this._list),
|
|
109
111
|
origWidth = _getBoundingClientRec3.width;
|
|
@@ -128,7 +130,9 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
componentDidUpdate() {
|
|
131
|
-
|
|
133
|
+
var _this$props$makeStyle2, _this$props2;
|
|
134
|
+
|
|
135
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
132
136
|
}
|
|
133
137
|
|
|
134
138
|
componentWillUnmount() {
|
|
@@ -142,9 +146,11 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
renderListItem(item, isMenuTrigger, key) {
|
|
149
|
+
var _this$props$styles2, _this$props$styles3;
|
|
150
|
+
|
|
145
151
|
return (0, _emotion.jsx)("li", {
|
|
146
152
|
key: key,
|
|
147
|
-
css: isMenuTrigger ? this.props.styles.listItemWithMenuTrigger : this.props.styles.listItem
|
|
153
|
+
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
|
|
148
154
|
}, item);
|
|
149
155
|
}
|
|
150
156
|
|
|
@@ -166,12 +172,14 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
166
172
|
}
|
|
167
173
|
|
|
168
174
|
render() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
var _this$props$styles4, _this$props$styles5, _this$props$styles6;
|
|
176
|
+
|
|
177
|
+
const _this$props3 = this.props,
|
|
178
|
+
children = _this$props3.children,
|
|
179
|
+
visibleItemsCount = _this$props3.visibleItemsCount,
|
|
180
|
+
screenReaderLabel = _this$props3.screenReaderLabel,
|
|
181
|
+
margin = _this$props3.margin,
|
|
182
|
+
elementRef = _this$props3.elementRef;
|
|
175
183
|
|
|
176
184
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, AppNav.propTypes), AppNav);
|
|
177
185
|
|
|
@@ -186,86 +194,23 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
186
194
|
const hasRenderedContent = renderBeforeItems || renderAfterItems;
|
|
187
195
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
188
196
|
as: "nav",
|
|
189
|
-
css: [this.props.styles.appNav, hasRenderedContent ? this.props.styles.alignCenter : ''],
|
|
197
|
+
css: [(_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.appNav, hasRenderedContent ? (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.alignCenter : ''],
|
|
190
198
|
margin: margin,
|
|
191
199
|
display: hasRenderedContent ? 'flex' : 'block',
|
|
192
200
|
elementRef: elementRef
|
|
193
201
|
}), renderBeforeItems && (0, _emotion.jsx)("span", null, renderBeforeItems), (0, _emotion.jsx)("ul", {
|
|
194
202
|
ref: el => this._list = el,
|
|
195
|
-
css: this.props.styles.list,
|
|
203
|
+
css: (_this$props$styles6 = this.props.styles) === null || _this$props$styles6 === void 0 ? void 0 : _this$props$styles6.list,
|
|
196
204
|
"aria-label": (0, _callRenderProp.callRenderProp)(screenReaderLabel)
|
|
197
205
|
}, visibleChildren.map((child, index) => {
|
|
198
206
|
return this.renderListItem(child, false, index);
|
|
199
207
|
}), hiddenChildren.length > 0 && this.renderMenu(hiddenChildren)), renderAfterItems && (0, _emotion.jsx)("span", null, renderAfterItems));
|
|
200
208
|
}
|
|
201
209
|
|
|
202
|
-
}, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.propTypes = {
|
|
203
|
-
/**
|
|
204
|
-
* Screenreader label for the overall navigation
|
|
205
|
-
*/
|
|
206
|
-
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Only accepts `AppNav.Item` as children
|
|
210
|
-
*/
|
|
211
|
-
children: _Children.Children.oneOf([_Item.Item]),
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* The rate (in ms) the component responds to container resizing or
|
|
215
|
-
* an update to one of its child items
|
|
216
|
-
*/
|
|
217
|
-
debounce: _propTypes.default.number,
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Content to display before the navigation items, such as a logo
|
|
221
|
-
*/
|
|
222
|
-
renderBeforeItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Content to display after the navigation items, aligned to the far end
|
|
226
|
-
* of the navigation
|
|
227
|
-
*/
|
|
228
|
-
renderAfterItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
232
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
233
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
234
|
-
*/
|
|
235
|
-
margin: _emotion.ThemeablePropTypes.spacing,
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Provides a reference to the underlying nav element
|
|
239
|
-
*/
|
|
240
|
-
elementRef: _propTypes.default.func,
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Customize the text displayed in the menu trigger when links overflow
|
|
244
|
-
* the overall nav width.
|
|
245
|
-
*/
|
|
246
|
-
renderTruncateLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Called whenever the navigation items are updated or the size of
|
|
250
|
-
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
251
|
-
* a parameter.
|
|
252
|
-
*/
|
|
253
|
-
onUpdate: _propTypes.default.func,
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Sets the number of navigation items that are visible.
|
|
257
|
-
*/
|
|
258
|
-
visibleItemsCount: _propTypes.default.number,
|
|
259
|
-
// eslint-disable-next-line react/require-default-props
|
|
260
|
-
makeStyles: _propTypes.default.func,
|
|
261
|
-
// eslint-disable-next-line react/require-default-props
|
|
262
|
-
styles: _propTypes.default.object
|
|
263
|
-
}, _class2.defaultProps = {
|
|
210
|
+
}, _class2.displayName = "AppNav", _class2.componentId = 'AppNav', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
264
211
|
children: null,
|
|
265
212
|
debounce: 300,
|
|
266
213
|
margin: '0',
|
|
267
|
-
renderBeforeItems: void 0,
|
|
268
|
-
renderAfterItems: void 0,
|
|
269
214
|
elementRef: el => {},
|
|
270
215
|
renderTruncateLabel: () => 'More',
|
|
271
216
|
onUpdate: () => {},
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.allowedProps = exports.propTypes = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
13
|
+
|
|
14
|
+
var _emotion = require("@instructure/emotion");
|
|
15
|
+
|
|
16
|
+
var _Item = require("./Item");
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* The MIT License (MIT)
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
22
|
+
*
|
|
23
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
* in the Software without restriction, including without limitation the rights
|
|
26
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
* furnished to do so, subject to the following conditions:
|
|
29
|
+
*
|
|
30
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
* copies or substantial portions of the Software.
|
|
32
|
+
*
|
|
33
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
* SOFTWARE.
|
|
40
|
+
*/
|
|
41
|
+
const propTypes = {
|
|
42
|
+
/**
|
|
43
|
+
* Screenreader label for the overall navigation
|
|
44
|
+
*/
|
|
45
|
+
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Only accepts `AppNav.Item` as children
|
|
49
|
+
*/
|
|
50
|
+
children: _Children.Children.oneOf([_Item.Item]),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The rate (in ms) the component responds to container resizing or
|
|
54
|
+
* an update to one of its child items
|
|
55
|
+
*/
|
|
56
|
+
debounce: _propTypes.default.number,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Content to display before the navigation items, such as a logo
|
|
60
|
+
*/
|
|
61
|
+
renderBeforeItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Content to display after the navigation items, aligned to the far end
|
|
65
|
+
* of the navigation
|
|
66
|
+
*/
|
|
67
|
+
renderAfterItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
73
|
+
*/
|
|
74
|
+
margin: _emotion.ThemeablePropTypes.spacing,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Provides a reference to the underlying nav element
|
|
78
|
+
*/
|
|
79
|
+
elementRef: _propTypes.default.func,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Customize the text displayed in the menu trigger when links overflow
|
|
83
|
+
* the overall nav width.
|
|
84
|
+
*/
|
|
85
|
+
renderTruncateLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Called whenever the navigation items are updated or the size of
|
|
89
|
+
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
90
|
+
* a parameter.
|
|
91
|
+
*/
|
|
92
|
+
onUpdate: _propTypes.default.func,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Sets the number of navigation items that are visible.
|
|
96
|
+
*/
|
|
97
|
+
visibleItemsCount: _propTypes.default.number
|
|
98
|
+
};
|
|
99
|
+
exports.propTypes = propTypes;
|
|
100
|
+
const allowedProps = ['screenReaderLabel', 'children', 'debounce', 'renderBeforeItems', 'renderAfterItems', 'margin', 'elementRef', 'renderTruncateLabel', 'onUpdate', 'visibleItemsCount'];
|
|
101
|
+
exports.allowedProps = allowedProps;
|
|
@@ -9,8 +9,6 @@ exports.NavigationItem = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
15
13
|
|
|
16
14
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
@@ -27,6 +25,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
27
25
|
|
|
28
26
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
29
27
|
|
|
28
|
+
var _props = require("./props");
|
|
29
|
+
|
|
30
30
|
var _dec, _dec2, _class, _class2, _temp;
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -37,42 +37,48 @@ id: Navigation.Item
|
|
|
37
37
|
**/
|
|
38
38
|
let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_temp = _class2 = class NavigationItem extends _react.Component {
|
|
39
39
|
componentDidMount() {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
var _this$props$makeStyle, _this$props;
|
|
41
|
+
|
|
42
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
43
|
+
minimized: this.props.minimized
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
componentDidUpdate() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
var _this$props$makeStyle2, _this$props2;
|
|
49
|
+
|
|
50
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
51
|
+
minimized: this.props.minimized
|
|
48
52
|
});
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
renderLink() {
|
|
56
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
57
|
+
|
|
52
58
|
const ElementType = (0, _getElementType.getElementType)(NavigationItem, this.props);
|
|
53
|
-
const _this$
|
|
54
|
-
href = _this$
|
|
55
|
-
onClick = _this$
|
|
56
|
-
icon = _this$
|
|
57
|
-
label = _this$
|
|
59
|
+
const _this$props3 = this.props,
|
|
60
|
+
href = _this$props3.href,
|
|
61
|
+
onClick = _this$props3.onClick,
|
|
62
|
+
icon = _this$props3.icon,
|
|
63
|
+
label = _this$props3.label;
|
|
58
64
|
const props = (0, _omitProps.omitProps)(this.props, NavigationItem.propTypes);
|
|
59
65
|
return (0, _emotion.jsx)(ElementType, Object.assign({}, props, {
|
|
60
66
|
href: href,
|
|
61
67
|
onClick: onClick,
|
|
62
|
-
css: this.props.styles.navigationItem,
|
|
68
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
|
|
63
69
|
"aria-label": this.props.minimized ? label : void 0
|
|
64
70
|
}), (0, _emotion.jsx)("div", {
|
|
65
|
-
css: this.props.styles.icon,
|
|
71
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
|
|
66
72
|
"aria-hidden": "true"
|
|
67
73
|
}, icon), !this.props.minimized ? (0, _emotion.jsx)("div", {
|
|
68
|
-
css: this.props.styles.label
|
|
74
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.label
|
|
69
75
|
}, label) : null);
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
render() {
|
|
73
|
-
const _this$
|
|
74
|
-
minimized = _this$
|
|
75
|
-
label = _this$
|
|
79
|
+
const _this$props4 = this.props,
|
|
80
|
+
minimized = _this$props4.minimized,
|
|
81
|
+
label = _this$props4.label;
|
|
76
82
|
const link = this.renderLink();
|
|
77
83
|
return minimized && (0, _hasVisibleChildren.hasVisibleChildren)(label) ? (0, _emotion.jsx)(_Tooltip.Tooltip, {
|
|
78
84
|
renderTip: label,
|
|
@@ -80,52 +86,11 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
80
86
|
}, link) : link;
|
|
81
87
|
}
|
|
82
88
|
|
|
83
|
-
}, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.propTypes = {
|
|
84
|
-
// eslint-disable-next-line react/require-default-props
|
|
85
|
-
makeStyles: _propTypes.default.func,
|
|
86
|
-
// eslint-disable-next-line react/require-default-props
|
|
87
|
-
styles: _propTypes.default.object,
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
91
|
-
*/
|
|
92
|
-
icon: _propTypes.default.node.isRequired,
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The text to display for the Navigation Link
|
|
96
|
-
*/
|
|
97
|
-
label: _propTypes.default.node.isRequired,
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
101
|
-
*/
|
|
102
|
-
as: _propTypes.default.elementType,
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* If the NavigationItem goes to a new page, pass an href
|
|
106
|
-
*/
|
|
107
|
-
href: _propTypes.default.string,
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* If the NavigationItem does not go to a new page pass an onClick
|
|
111
|
-
*/
|
|
112
|
-
onClick: _propTypes.default.func,
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Denotes which NavigationItem is currently selected
|
|
116
|
-
*/
|
|
117
|
-
selected: _propTypes.default.bool,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* When minimized is set to true, the `<Navigation />` shows icons only while the text becomes a tooltip. When it is set to false, the `<Navigation />` shows text in addition to the icons
|
|
121
|
-
*/
|
|
122
|
-
minimized: _propTypes.default.bool
|
|
123
|
-
}, _class2.defaultProps = {
|
|
89
|
+
}, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
124
90
|
as: 'a',
|
|
125
91
|
onClick: function (e, selected) {},
|
|
126
92
|
selected: false,
|
|
127
|
-
minimized: false
|
|
128
|
-
href: void 0
|
|
93
|
+
minimized: false
|
|
129
94
|
}, _temp)) || _class) || _class);
|
|
130
95
|
exports.NavigationItem = NavigationItem;
|
|
131
96
|
var _default = NavigationItem;
|