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