@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
|
@@ -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 { testable } from '@instructure/ui-testable';
|
|
31
30
|
import { omitProps, getElementType } from '@instructure/ui-react-utils';
|
|
32
31
|
import { Tooltip } from '@instructure/ui-tooltip';
|
|
@@ -34,51 +33,58 @@ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
|
|
|
34
33
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
35
34
|
import generateStyle from './styles';
|
|
36
35
|
import generateComponentTheme from './theme';
|
|
37
|
-
|
|
36
|
+
import { allowedProps, propTypes } from './props';
|
|
38
37
|
/**
|
|
39
38
|
---
|
|
40
39
|
parent: Navigation
|
|
41
40
|
id: Navigation.Item
|
|
42
41
|
---
|
|
43
42
|
**/
|
|
43
|
+
|
|
44
44
|
let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class NavigationItem extends Component {
|
|
45
45
|
componentDidMount() {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
var _this$props$makeStyle, _this$props;
|
|
47
|
+
|
|
48
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
49
|
+
minimized: this.props.minimized
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
componentDidUpdate() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
var _this$props$makeStyle2, _this$props2;
|
|
55
|
+
|
|
56
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
57
|
+
minimized: this.props.minimized
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
renderLink() {
|
|
62
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
63
|
+
|
|
58
64
|
const ElementType = getElementType(NavigationItem, this.props);
|
|
59
|
-
const _this$
|
|
60
|
-
href = _this$
|
|
61
|
-
onClick = _this$
|
|
62
|
-
icon = _this$
|
|
63
|
-
label = _this$
|
|
65
|
+
const _this$props3 = this.props,
|
|
66
|
+
href = _this$props3.href,
|
|
67
|
+
onClick = _this$props3.onClick,
|
|
68
|
+
icon = _this$props3.icon,
|
|
69
|
+
label = _this$props3.label;
|
|
64
70
|
const props = omitProps(this.props, NavigationItem.propTypes);
|
|
65
71
|
return jsx(ElementType, Object.assign({}, props, {
|
|
66
72
|
href: href,
|
|
67
73
|
onClick: onClick,
|
|
68
|
-
css: this.props.styles.navigationItem,
|
|
74
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
|
|
69
75
|
"aria-label": this.props.minimized ? label : void 0
|
|
70
76
|
}), jsx("div", {
|
|
71
|
-
css: this.props.styles.icon,
|
|
77
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
|
|
72
78
|
"aria-hidden": "true"
|
|
73
79
|
}, icon), !this.props.minimized ? jsx("div", {
|
|
74
|
-
css: this.props.styles.label
|
|
80
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.label
|
|
75
81
|
}, label) : null);
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
render() {
|
|
79
|
-
const _this$
|
|
80
|
-
minimized = _this$
|
|
81
|
-
label = _this$
|
|
85
|
+
const _this$props4 = this.props,
|
|
86
|
+
minimized = _this$props4.minimized,
|
|
87
|
+
label = _this$props4.label;
|
|
82
88
|
const link = this.renderLink();
|
|
83
89
|
return minimized && hasVisibleChildren(label) ? jsx(Tooltip, {
|
|
84
90
|
renderTip: label,
|
|
@@ -86,52 +92,11 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
86
92
|
}, link) : link;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
}, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.propTypes = {
|
|
90
|
-
// eslint-disable-next-line react/require-default-props
|
|
91
|
-
makeStyles: PropTypes.func,
|
|
92
|
-
// eslint-disable-next-line react/require-default-props
|
|
93
|
-
styles: PropTypes.object,
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
97
|
-
*/
|
|
98
|
-
icon: PropTypes.node.isRequired,
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* The text to display for the Navigation Link
|
|
102
|
-
*/
|
|
103
|
-
label: PropTypes.node.isRequired,
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
107
|
-
*/
|
|
108
|
-
as: PropTypes.elementType,
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* If the NavigationItem goes to a new page, pass an href
|
|
112
|
-
*/
|
|
113
|
-
href: PropTypes.string,
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* If the NavigationItem does not go to a new page pass an onClick
|
|
117
|
-
*/
|
|
118
|
-
onClick: PropTypes.func,
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Denotes which NavigationItem is currently selected
|
|
122
|
-
*/
|
|
123
|
-
selected: PropTypes.bool,
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 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
|
|
127
|
-
*/
|
|
128
|
-
minimized: PropTypes.bool
|
|
129
|
-
}, _class2.defaultProps = {
|
|
95
|
+
}, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
130
96
|
as: 'a',
|
|
131
97
|
onClick: function (e, selected) {},
|
|
132
98
|
selected: false,
|
|
133
|
-
minimized: false
|
|
134
|
-
href: void 0
|
|
99
|
+
minimized: false
|
|
135
100
|
}, _temp)) || _class) || _class);
|
|
136
101
|
export default NavigationItem;
|
|
137
102
|
export { NavigationItem };
|
|
@@ -21,19 +21,42 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
const propTypes = {
|
|
26
|
+
/**
|
|
27
|
+
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
28
|
+
*/
|
|
29
|
+
icon: PropTypes.node.isRequired,
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The text to display for the Navigation Link
|
|
33
|
+
*/
|
|
34
|
+
label: PropTypes.node.isRequired,
|
|
26
35
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
38
|
+
*/
|
|
39
|
+
as: PropTypes.elementType,
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* If the NavigationItem goes to a new page, pass an href
|
|
43
|
+
*/
|
|
44
|
+
href: PropTypes.string,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If the NavigationItem does not go to a new page pass an onClick
|
|
48
|
+
*/
|
|
49
|
+
onClick: PropTypes.func,
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Denotes which NavigationItem is currently selected
|
|
53
|
+
*/
|
|
54
|
+
selected: PropTypes.bool,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 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
|
|
58
|
+
*/
|
|
59
|
+
minimized: PropTypes.bool
|
|
60
|
+
};
|
|
61
|
+
const allowedProps = ['icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
62
|
+
export { propTypes, allowedProps };
|
package/es/Navigation/index.js
CHANGED
|
@@ -26,9 +26,7 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Component, Children } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
29
|
import { testable } from '@instructure/ui-testable';
|
|
31
|
-
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
32
30
|
import { omitProps, safeCloneElement } from '@instructure/ui-react-utils';
|
|
33
31
|
import { IconMoveStartLine } from '@instructure/ui-icons';
|
|
34
32
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
@@ -36,6 +34,7 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
36
34
|
import { NavigationItem } from './NavigationItem';
|
|
37
35
|
import generateStyle from './styles';
|
|
38
36
|
import generateComponentTheme from './theme';
|
|
37
|
+
import { allowedProps, propTypes } from './props';
|
|
39
38
|
|
|
40
39
|
const navMinimized = ({
|
|
41
40
|
minimized
|
|
@@ -67,13 +66,17 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
componentDidMount() {
|
|
70
|
-
|
|
69
|
+
var _this$props$makeStyle, _this$props;
|
|
70
|
+
|
|
71
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
71
72
|
minimized: this.minimized
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
componentDidUpdate() {
|
|
76
|
-
|
|
77
|
+
var _this$props$makeStyle2, _this$props2;
|
|
78
|
+
|
|
79
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
77
80
|
minimized: this.minimized
|
|
78
81
|
});
|
|
79
82
|
}
|
|
@@ -92,11 +95,13 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
92
95
|
|
|
93
96
|
renderChildren() {
|
|
94
97
|
return Children.map(this.props.children, child => {
|
|
98
|
+
var _this$props$styles;
|
|
99
|
+
|
|
95
100
|
const navItem = safeCloneElement(child, {
|
|
96
101
|
minimized: this.state.minimized
|
|
97
102
|
});
|
|
98
103
|
return jsx("li", {
|
|
99
|
-
css: this.props.styles.list
|
|
104
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.list
|
|
100
105
|
}, navItem);
|
|
101
106
|
});
|
|
102
107
|
}
|
|
@@ -106,77 +111,33 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
render() {
|
|
114
|
+
var _this$props$styles2, _this$props$styles3, _this$props$styles4, _this$props$styles5;
|
|
115
|
+
|
|
109
116
|
const label = this.props.label;
|
|
110
117
|
const props = omitProps(this.props, Navigation.propTypes, ['minimized']);
|
|
111
118
|
return jsx("nav", Object.assign({}, props, {
|
|
112
|
-
css: this.props.styles.navigation,
|
|
119
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.navigation,
|
|
113
120
|
"aria-label": label
|
|
114
121
|
}), jsx("ul", {
|
|
115
|
-
css: this.props.styles.content
|
|
122
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.content
|
|
116
123
|
}, this.renderChildren()), jsx("div", {
|
|
117
|
-
css: this.props.styles.toggle
|
|
124
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle
|
|
118
125
|
}, jsx(NavigationItem, {
|
|
119
126
|
"aria-expanded": !this.minimized,
|
|
120
127
|
onClick: this.handleNavToggle,
|
|
121
128
|
icon: jsx(IconMoveStartLine, {
|
|
122
|
-
css: this.props.styles.toggleIcon,
|
|
129
|
+
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.toggleIcon,
|
|
123
130
|
inline: false
|
|
124
131
|
}),
|
|
125
132
|
label: jsx(ScreenReaderContent, null, this.toggleMessage())
|
|
126
133
|
})));
|
|
127
134
|
}
|
|
128
135
|
|
|
129
|
-
}, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.propTypes = {
|
|
130
|
-
// eslint-disable-next-line react/require-default-props
|
|
131
|
-
makeStyles: PropTypes.func,
|
|
132
|
-
// eslint-disable-next-line react/require-default-props
|
|
133
|
-
styles: PropTypes.object,
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* children of type Navigation.Item
|
|
137
|
-
*/
|
|
138
|
-
children: ChildrenPropTypes.oneOf([NavigationItem]),
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 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
|
|
142
|
-
*/
|
|
143
|
-
minimized: controllable(PropTypes.bool, 'onMinimized', 'defaultMinimized'),
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
147
|
-
*/
|
|
148
|
-
defaultMinimized: PropTypes.bool,
|
|
149
|
-
onMinimized: PropTypes.func,
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Screen reader label for the main Navigation
|
|
153
|
-
*/
|
|
154
|
-
label: PropTypes.string.isRequired,
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Screen reader label for the toggle button expanded/minimized state
|
|
158
|
-
*/
|
|
159
|
-
toggleLabel: PropTypes.shape({
|
|
160
|
-
expandedLabel: PropTypes.string,
|
|
161
|
-
minimizedLabel: PropTypes.string
|
|
162
|
-
}).isRequired,
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
166
|
-
*/
|
|
167
|
-
href: PropTypes.string,
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
171
|
-
*/
|
|
172
|
-
onClick: PropTypes.func
|
|
173
|
-
}, _class2.defaultProps = {
|
|
136
|
+
}, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
174
137
|
children: null,
|
|
175
138
|
defaultMinimized: false,
|
|
176
139
|
onMinimized: function (event, minimized) {},
|
|
177
|
-
onClick: function (e) {}
|
|
178
|
-
href: void 0,
|
|
179
|
-
minimized: void 0
|
|
140
|
+
onClick: function (e) {}
|
|
180
141
|
}, _class2.Item = NavigationItem, _temp)) || _class) || _class);
|
|
181
142
|
export default Navigation;
|
|
182
143
|
export { Navigation, NavigationItem };
|
|
@@ -0,0 +1,68 @@
|
|
|
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 { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
|
+
import { NavigationItem } from './NavigationItem';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
/**
|
|
29
|
+
* children of type Navigation.Item
|
|
30
|
+
*/
|
|
31
|
+
children: ChildrenPropTypes.oneOf([NavigationItem]),
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 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
|
|
35
|
+
*/
|
|
36
|
+
minimized: controllable(PropTypes.bool, 'onMinimized', 'defaultMinimized'),
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
40
|
+
*/
|
|
41
|
+
defaultMinimized: PropTypes.bool,
|
|
42
|
+
onMinimized: PropTypes.func,
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Screen reader label for the main Navigation
|
|
46
|
+
*/
|
|
47
|
+
label: PropTypes.string.isRequired,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Screen reader label for the toggle button expanded/minimized state
|
|
51
|
+
*/
|
|
52
|
+
toggleLabel: PropTypes.shape({
|
|
53
|
+
expandedLabel: PropTypes.string,
|
|
54
|
+
minimizedLabel: PropTypes.string
|
|
55
|
+
}).isRequired,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
59
|
+
*/
|
|
60
|
+
href: PropTypes.string,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
64
|
+
*/
|
|
65
|
+
onClick: PropTypes.func
|
|
66
|
+
};
|
|
67
|
+
const allowedProps = ['children', 'minimized', 'defaultMinimized', 'onMinimized', 'label', 'toggleLabel', 'href', 'onClick'];
|
|
68
|
+
export { propTypes, allowedProps };
|
package/lib/AppNav/Item/index.js
CHANGED
|
@@ -9,8 +9,6 @@ exports.Item = 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 _console = require("@instructure/console");
|
|
15
13
|
|
|
16
14
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
@@ -33,6 +31,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
33
31
|
|
|
34
32
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
35
33
|
|
|
34
|
+
var _props = require("./props");
|
|
35
|
+
|
|
36
36
|
var _dec, _dec2, _class, _class2, _temp;
|
|
37
37
|
|
|
38
38
|
/**
|
|
@@ -61,23 +61,29 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
componentDidMount() {
|
|
64
|
-
|
|
64
|
+
var _this$props$makeStyle, _this$props2;
|
|
65
|
+
|
|
66
|
+
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
componentDidUpdate() {
|
|
68
|
-
|
|
70
|
+
var _this$props$makeStyle2, _this$props3;
|
|
71
|
+
|
|
72
|
+
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
render() {
|
|
76
|
+
var _this$props$styles, _this$props$styles2;
|
|
77
|
+
|
|
72
78
|
const ElementType = (0, _getElementType.getElementType)(Item, this.props);
|
|
73
|
-
const _this$
|
|
74
|
-
renderIcon = _this$
|
|
75
|
-
renderLabel = _this$
|
|
76
|
-
href = _this$
|
|
77
|
-
elementRef = _this$
|
|
78
|
-
renderAfter = _this$
|
|
79
|
-
cursor = _this$
|
|
80
|
-
isDisabled = _this$
|
|
79
|
+
const _this$props4 = this.props,
|
|
80
|
+
renderIcon = _this$props4.renderIcon,
|
|
81
|
+
renderLabel = _this$props4.renderLabel,
|
|
82
|
+
href = _this$props4.href,
|
|
83
|
+
elementRef = _this$props4.elementRef,
|
|
84
|
+
renderAfter = _this$props4.renderAfter,
|
|
85
|
+
cursor = _this$props4.cursor,
|
|
86
|
+
isDisabled = _this$props4.isDisabled;
|
|
81
87
|
const icon = (0, _callRenderProp.callRenderProp)(renderIcon);
|
|
82
88
|
const label = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
83
89
|
const labelIsForScreenReaders = (0, _matchComponentTypes.matchComponentTypes)(label, [_ScreenReaderContent.ScreenReaderContent]);
|
|
@@ -98,78 +104,16 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
98
104
|
onFocus: this.handleFocus,
|
|
99
105
|
onBlur: this.handleBlur,
|
|
100
106
|
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
101
|
-
css: this.props.styles.item
|
|
107
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.item
|
|
102
108
|
}), icon, labelIsForScreenReaders ? label : (0, _emotion.jsx)("span", {
|
|
103
|
-
css: this.props.styles.label
|
|
109
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.label
|
|
104
110
|
}, label), renderAfter && (0, _callRenderProp.callRenderProp)(renderAfter));
|
|
105
111
|
}
|
|
106
112
|
|
|
107
|
-
}, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.propTypes = {
|
|
108
|
-
// eslint-disable-next-line react/require-default-props
|
|
109
|
-
makeStyles: _propTypes.default.func,
|
|
110
|
-
// eslint-disable-next-line react/require-default-props
|
|
111
|
-
styles: _propTypes.default.object,
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* The text to display. If the `icon` prop is used, label text must be wrapped
|
|
115
|
-
* in `ScreenReaderContent`.
|
|
116
|
-
*/
|
|
117
|
-
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Content to display after the renderLabel text, such as a badge
|
|
121
|
-
*/
|
|
122
|
-
renderAfter: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
126
|
-
*/
|
|
127
|
-
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* If the item goes to a new page, pass an href
|
|
131
|
-
*/
|
|
132
|
-
href: _propTypes.default.string,
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* If the item does not go to a new page, pass an onClick
|
|
136
|
-
*/
|
|
137
|
-
onClick: _propTypes.default.func,
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Denotes which item is currently selected
|
|
141
|
-
*/
|
|
142
|
-
isSelected: _propTypes.default.bool,
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* provides a reference to the underlying focusable (`button` or `a`) element
|
|
146
|
-
*/
|
|
147
|
-
elementRef: _propTypes.default.func,
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
151
|
-
*/
|
|
152
|
-
as: _propTypes.default.elementType,
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Specify the mouse cursor to use on :hover.
|
|
156
|
-
* The `pointer` cursor is used by default.
|
|
157
|
-
*/
|
|
158
|
-
cursor: _propTypes.default.string,
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Disables the link or button visually and functionally
|
|
162
|
-
*/
|
|
163
|
-
isDisabled: _propTypes.default.bool
|
|
164
|
-
}, _class2.defaultProps = {
|
|
113
|
+
}, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
165
114
|
children: null,
|
|
166
115
|
onClick: function (event) {},
|
|
167
116
|
isSelected: false,
|
|
168
|
-
href: void 0,
|
|
169
|
-
elementRef: void 0,
|
|
170
|
-
renderIcon: void 0,
|
|
171
|
-
renderAfter: void 0,
|
|
172
|
-
as: void 0,
|
|
173
117
|
cursor: 'pointer',
|
|
174
118
|
isDisabled: false
|
|
175
119
|
}, _temp)) || _class) || _class);
|