@instructure/ui-navigation 8.56.0 → 9.0.0
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 +11 -0
- package/README.md +2 -23
- package/es/index.js +1 -2
- package/lib/index.js +1 -14
- package/package.json +24 -24
- package/src/index.ts +0 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +1 -1
- package/es/Navigation/NavigationItem/NavigationItemLocator.js +0 -33
- package/es/Navigation/NavigationItem/index.js +0 -106
- package/es/Navigation/NavigationItem/locator.js +0 -26
- package/es/Navigation/NavigationItem/props.js +0 -36
- package/es/Navigation/NavigationItem/styles.js +0 -93
- package/es/Navigation/NavigationItem/theme.js +0 -73
- package/es/Navigation/NavigationLocator.js +0 -37
- package/es/Navigation/index.js +0 -129
- package/es/Navigation/locator.js +0 -27
- package/es/Navigation/props.js +0 -42
- package/es/Navigation/styles.js +0 -77
- package/es/Navigation/theme.js +0 -61
- package/lib/Navigation/NavigationItem/NavigationItemLocator.js +0 -40
- package/lib/Navigation/NavigationItem/index.js +0 -112
- package/lib/Navigation/NavigationItem/locator.js +0 -37
- package/lib/Navigation/NavigationItem/props.js +0 -43
- package/lib/Navigation/NavigationItem/styles.js +0 -99
- package/lib/Navigation/NavigationItem/theme.js +0 -79
- package/lib/Navigation/NavigationLocator.js +0 -48
- package/lib/Navigation/index.js +0 -145
- package/lib/Navigation/locator.js +0 -43
- package/lib/Navigation/props.js +0 -49
- package/lib/Navigation/styles.js +0 -83
- package/lib/Navigation/theme.js +0 -67
- package/src/Navigation/NavigationItem/NavigationItemLocator.ts +0 -34
- package/src/Navigation/NavigationItem/index.tsx +0 -117
- package/src/Navigation/NavigationItem/locator.ts +0 -27
- package/src/Navigation/NavigationItem/props.ts +0 -102
- package/src/Navigation/NavigationItem/styles.ts +0 -103
- package/src/Navigation/NavigationItem/theme.ts +0 -82
- package/src/Navigation/NavigationLocator.ts +0 -40
- package/src/Navigation/README.md +0 -85
- package/src/Navigation/index.tsx +0 -168
- package/src/Navigation/locator.ts +0 -29
- package/src/Navigation/props.ts +0 -118
- package/src/Navigation/styles.ts +0 -83
- package/src/Navigation/theme.ts +0 -66
- package/types/Navigation/NavigationItem/NavigationItemLocator.d.ts +0 -576
- package/types/Navigation/NavigationItem/NavigationItemLocator.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/index.d.ts +0 -47
- package/types/Navigation/NavigationItem/index.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/locator.d.ts +0 -4
- package/types/Navigation/NavigationItem/locator.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/props.d.ts +0 -46
- package/types/Navigation/NavigationItem/props.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/styles.d.ts +0 -15
- package/types/Navigation/NavigationItem/styles.d.ts.map +0 -1
- package/types/Navigation/NavigationItem/theme.d.ts +0 -10
- package/types/Navigation/NavigationItem/theme.d.ts.map +0 -1
- package/types/Navigation/NavigationLocator.d.ts +0 -1983
- package/types/Navigation/NavigationLocator.d.ts.map +0 -1
- package/types/Navigation/index.d.ts +0 -58
- package/types/Navigation/index.d.ts.map +0 -1
- package/types/Navigation/locator.d.ts +0 -5
- package/types/Navigation/locator.d.ts.map +0 -1
- package/types/Navigation/props.d.ts +0 -49
- package/types/Navigation/props.d.ts.map +0 -1
- package/types/Navigation/styles.d.ts +0 -15
- package/types/Navigation/styles.d.ts.map +0 -1
- package/types/Navigation/theme.d.ts +0 -10
- package/types/Navigation/theme.d.ts.map +0 -1
package/lib/Navigation/index.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Navigation = void 0;
|
|
9
|
-
Object.defineProperty(exports, "NavigationItem", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return _NavigationItem.NavigationItem;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
exports.default = void 0;
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
18
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
19
|
-
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
20
|
-
var _deprecated = require("@instructure/ui-react-utils/lib/deprecated.js");
|
|
21
|
-
var _IconMoveStartLine = require("@instructure/ui-icons/lib/IconMoveStartLine.js");
|
|
22
|
-
var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
|
|
23
|
-
var _emotion = require("@instructure/emotion");
|
|
24
|
-
var _NavigationItem = require("./NavigationItem");
|
|
25
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
26
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
27
|
-
var _props = require("./props");
|
|
28
|
-
var _dec, _dec2, _dec3, _class, _class2;
|
|
29
|
-
/*
|
|
30
|
-
* The MIT License (MIT)
|
|
31
|
-
*
|
|
32
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
33
|
-
*
|
|
34
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
35
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
36
|
-
* in the Software without restriction, including without limitation the rights
|
|
37
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
38
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
39
|
-
* furnished to do so, subject to the following conditions:
|
|
40
|
-
*
|
|
41
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
42
|
-
* copies or substantial portions of the Software.
|
|
43
|
-
*
|
|
44
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
45
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
46
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
47
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
48
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
49
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
50
|
-
* SOFTWARE.
|
|
51
|
-
*/
|
|
52
|
-
/** @jsx jsx */
|
|
53
|
-
const navMinimized = ({
|
|
54
|
-
minimized
|
|
55
|
-
}) => ({
|
|
56
|
-
minimized: !minimized
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
---
|
|
61
|
-
category: components/deprecated
|
|
62
|
-
---
|
|
63
|
-
**/
|
|
64
|
-
let Navigation = exports.Navigation = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec3 = (0, _deprecated.deprecated)('9.0.0', null, 'This component is deprecated and will be removed in a later version. Use <SideNavBar /> instead.'), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Navigation extends _react.Component {
|
|
65
|
-
constructor(props) {
|
|
66
|
-
super(props);
|
|
67
|
-
this.ref = null;
|
|
68
|
-
this.handleNavToggle = event => {
|
|
69
|
-
if (!this.isControlled()) {
|
|
70
|
-
this.setState(navMinimized);
|
|
71
|
-
}
|
|
72
|
-
if (typeof this.props.onMinimized === 'function') {
|
|
73
|
-
this.props.onMinimized(event, !this.minimized);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
this.state = {
|
|
77
|
-
minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
componentDidMount() {
|
|
81
|
-
var _this$props$makeStyle, _this$props;
|
|
82
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
|
|
83
|
-
minimized: this.minimized
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
componentDidUpdate() {
|
|
87
|
-
var _this$props$makeStyle2, _this$props2;
|
|
88
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
|
|
89
|
-
minimized: this.minimized
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
get minimized() {
|
|
93
|
-
if (this.isControlled()) {
|
|
94
|
-
return !!this.props.minimized;
|
|
95
|
-
}
|
|
96
|
-
return !!this.state.minimized;
|
|
97
|
-
}
|
|
98
|
-
isControlled(props = this.props) {
|
|
99
|
-
return typeof props.minimized === 'boolean';
|
|
100
|
-
}
|
|
101
|
-
renderChildren() {
|
|
102
|
-
return _react.Children.map(this.props.children, child => {
|
|
103
|
-
var _this$props$styles;
|
|
104
|
-
const navItem = (0, _safeCloneElement.safeCloneElement)(child, {
|
|
105
|
-
minimized: this.state.minimized
|
|
106
|
-
});
|
|
107
|
-
return (0, _emotion.jsx)("li", {
|
|
108
|
-
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.list
|
|
109
|
-
}, navItem);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
toggleMessage() {
|
|
113
|
-
return this.state.minimized ? this.props.toggleLabel.minimizedLabel : this.props.toggleLabel.expandedLabel;
|
|
114
|
-
}
|
|
115
|
-
render() {
|
|
116
|
-
var _this$props$styles2, _this$props$styles3, _this$props$styles4, _this$props$styles5;
|
|
117
|
-
const label = this.props.label;
|
|
118
|
-
const props = (0, _omitProps.omitProps)(this.props, Navigation.allowedProps, ['minimized']);
|
|
119
|
-
return (0, _emotion.jsx)("nav", Object.assign({}, props, {
|
|
120
|
-
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.navigation,
|
|
121
|
-
"aria-label": label,
|
|
122
|
-
ref: element => {
|
|
123
|
-
this.ref = element;
|
|
124
|
-
}
|
|
125
|
-
}), (0, _emotion.jsx)("ul", {
|
|
126
|
-
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.content
|
|
127
|
-
}, this.renderChildren()), (0, _emotion.jsx)("div", {
|
|
128
|
-
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.toggle
|
|
129
|
-
}, (0, _emotion.jsx)(_NavigationItem.NavigationItem, {
|
|
130
|
-
"aria-expanded": !this.minimized,
|
|
131
|
-
onClick: this.handleNavToggle,
|
|
132
|
-
icon: (0, _emotion.jsx)(_IconMoveStartLine.IconMoveStartLine, {
|
|
133
|
-
css: (_this$props$styles5 = this.props.styles) === null || _this$props$styles5 === void 0 ? void 0 : _this$props$styles5.toggleIcon,
|
|
134
|
-
inline: false
|
|
135
|
-
}),
|
|
136
|
-
label: (0, _emotion.jsx)(_ScreenReaderContent.ScreenReaderContent, null, this.toggleMessage())
|
|
137
|
-
})));
|
|
138
|
-
}
|
|
139
|
-
}, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
140
|
-
children: null,
|
|
141
|
-
defaultMinimized: false,
|
|
142
|
-
// TODO we should investigate later if it used or not
|
|
143
|
-
onClick: function (_e) {}
|
|
144
|
-
}, _class2.Item = _NavigationItem.NavigationItem, _class2)) || _class) || _class) || _class);
|
|
145
|
-
var _default = exports.default = Navigation;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "NavigationItemLocator", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _NavigationLocator.NavigationItemLocator;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "NavigationLocator", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _NavigationLocator.NavigationLocator;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
exports.default = void 0;
|
|
19
|
-
var _NavigationLocator = require("./NavigationLocator");
|
|
20
|
-
/*
|
|
21
|
-
* The MIT License (MIT)
|
|
22
|
-
*
|
|
23
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
24
|
-
*
|
|
25
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
26
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
27
|
-
* in the Software without restriction, including without limitation the rights
|
|
28
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
29
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
30
|
-
* furnished to do so, subject to the following conditions:
|
|
31
|
-
*
|
|
32
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
33
|
-
* copies or substantial portions of the Software.
|
|
34
|
-
*
|
|
35
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
36
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
37
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
38
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
39
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
40
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
|
-
* SOFTWARE.
|
|
42
|
-
*/
|
|
43
|
-
var _default = exports.default = _NavigationLocator.NavigationLocator;
|
package/lib/Navigation/props.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.propTypes = exports.allowedProps = void 0;
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
10
|
-
var _Children = require("@instructure/ui-prop-types/lib/Children.js");
|
|
11
|
-
var _NavigationItem = require("./NavigationItem");
|
|
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
|
-
|
|
36
|
-
const propTypes = exports.propTypes = {
|
|
37
|
-
children: _Children.Children.oneOf([_NavigationItem.NavigationItem]),
|
|
38
|
-
minimized: (0, _controllable.controllable)(_propTypes.default.bool, 'onMinimized', 'defaultMinimized'),
|
|
39
|
-
defaultMinimized: _propTypes.default.bool,
|
|
40
|
-
onMinimized: _propTypes.default.func,
|
|
41
|
-
label: _propTypes.default.string.isRequired,
|
|
42
|
-
toggleLabel: _propTypes.default.shape({
|
|
43
|
-
expandedLabel: _propTypes.default.string,
|
|
44
|
-
minimizedLabel: _propTypes.default.string
|
|
45
|
-
}).isRequired,
|
|
46
|
-
href: _propTypes.default.string,
|
|
47
|
-
onClick: _propTypes.default.func
|
|
48
|
-
};
|
|
49
|
-
const allowedProps = exports.allowedProps = ['children', 'minimized', 'defaultMinimized', 'onMinimized', 'label', 'toggleLabel', 'href', 'onClick'];
|
package/lib/Navigation/styles.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* ---
|
|
33
|
-
* private: true
|
|
34
|
-
* ---
|
|
35
|
-
* Generates the style object from the theme and provided additional information
|
|
36
|
-
* @param {Object} componentTheme The theme variable object.
|
|
37
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
-
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
-
* @return {Object} The final style object, which will be used in the component
|
|
40
|
-
*/
|
|
41
|
-
const generateStyle = (componentTheme, props, state) => {
|
|
42
|
-
const minimized = state.minimized;
|
|
43
|
-
return {
|
|
44
|
-
navigation: {
|
|
45
|
-
label: 'navigation',
|
|
46
|
-
color: componentTheme.fontColor,
|
|
47
|
-
backgroundColor: componentTheme.backgroundColor,
|
|
48
|
-
boxSizing: 'border-box',
|
|
49
|
-
display: 'flex',
|
|
50
|
-
flexDirection: 'column',
|
|
51
|
-
width: componentTheme.width,
|
|
52
|
-
height: '100%',
|
|
53
|
-
overflowY: 'auto',
|
|
54
|
-
...(minimized ? {
|
|
55
|
-
width: componentTheme.minimizedWidth
|
|
56
|
-
} : {})
|
|
57
|
-
},
|
|
58
|
-
list: {
|
|
59
|
-
label: 'navigation__list',
|
|
60
|
-
padding: 0,
|
|
61
|
-
margin: 0
|
|
62
|
-
},
|
|
63
|
-
content: {
|
|
64
|
-
label: 'navigation__content',
|
|
65
|
-
listStyleType: 'none',
|
|
66
|
-
margin: '0',
|
|
67
|
-
padding: '0',
|
|
68
|
-
flex: '1 0 auto'
|
|
69
|
-
},
|
|
70
|
-
toggle: {
|
|
71
|
-
transform: 'translate3d(0, 0, 0)',
|
|
72
|
-
transition: `all ${componentTheme.toggleTransition}`,
|
|
73
|
-
...(minimized ? {
|
|
74
|
-
transform: 'rotate3d(0, 1, 0, -180deg)'
|
|
75
|
-
} : {})
|
|
76
|
-
},
|
|
77
|
-
toggleIcon: {
|
|
78
|
-
fill: componentTheme.fill,
|
|
79
|
-
margin: '0 auto'
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
var _default = exports.default = generateStyle;
|
package/lib/Navigation/theme.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
33
|
-
* @param {Object} theme The actual theme object.
|
|
34
|
-
* @return {Object} The final theme object with the overrides and component variables
|
|
35
|
-
*/
|
|
36
|
-
const generateComponentTheme = theme => {
|
|
37
|
-
const colors = theme.colors,
|
|
38
|
-
spacing = theme.spacing,
|
|
39
|
-
borders = theme.borders,
|
|
40
|
-
transitions = theme.transitions,
|
|
41
|
-
themeName = theme.key;
|
|
42
|
-
const themeSpecificStyle = {
|
|
43
|
-
canvas: {
|
|
44
|
-
backgroundColor: theme['ic-brand-global-nav-bgd'],
|
|
45
|
-
fontColor: theme['ic-brand-global-nav-menu-item__text-color'],
|
|
46
|
-
fill: theme['ic-brand-global-nav-ic-icon-svg-fill']
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const componentVariables = {
|
|
50
|
-
fontColor: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
51
|
-
backgroundColor: colors === null || colors === void 0 ? void 0 : colors.backgroundBrandSecondary,
|
|
52
|
-
width: '5.25rem',
|
|
53
|
-
minimizedWidth: '3.375rem',
|
|
54
|
-
fill: colors === null || colors === void 0 ? void 0 : colors.textLightest,
|
|
55
|
-
focusOutlineInnerWidth: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
56
|
-
focusOutlineOuterWidth: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
57
|
-
focusOutlineInnerColor: colors === null || colors === void 0 ? void 0 : colors.borderBrand,
|
|
58
|
-
focusOutlineOuterColor: colors === null || colors === void 0 ? void 0 : colors.borderLightest,
|
|
59
|
-
marginBottom: spacing === null || spacing === void 0 ? void 0 : spacing.small,
|
|
60
|
-
toggleTransition: transitions === null || transitions === void 0 ? void 0 : transitions.duration
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
...componentVariables,
|
|
64
|
-
...themeSpecificStyle[themeName]
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
var _default = exports.default = generateComponentTheme;
|
|
@@ -1,34 +0,0 @@
|
|
|
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 { locator } from '@instructure/ui-test-locator'
|
|
25
|
-
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
26
|
-
// eslint-disable-next-line no-restricted-imports
|
|
27
|
-
import { TooltipLocator } from '@instructure/ui-tooltip/es/Tooltip/TooltipLocator'
|
|
28
|
-
|
|
29
|
-
import { NavigationItem } from './index'
|
|
30
|
-
|
|
31
|
-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
32
|
-
export const NavigationItemLocator = locator(NavigationItem.selector, {
|
|
33
|
-
findTooltipContent: (...args: any[]) => TooltipLocator.findContent(...args)
|
|
34
|
-
})
|
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
/** @jsx jsx */
|
|
25
|
-
import { Component } from 'react'
|
|
26
|
-
|
|
27
|
-
import { testable } from '@instructure/ui-testable'
|
|
28
|
-
import { omitProps, getElementType } from '@instructure/ui-react-utils'
|
|
29
|
-
import { Tooltip } from '@instructure/ui-tooltip'
|
|
30
|
-
import { hasVisibleChildren } from '@instructure/ui-a11y-utils'
|
|
31
|
-
import { withStyle, jsx } from '@instructure/emotion'
|
|
32
|
-
|
|
33
|
-
import generateStyle from './styles'
|
|
34
|
-
import generateComponentTheme from './theme'
|
|
35
|
-
import type { NavigationItemProps } from './props'
|
|
36
|
-
import { allowedProps, propTypes } from './props'
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
---
|
|
40
|
-
parent: Navigation
|
|
41
|
-
id: Navigation.Item
|
|
42
|
-
---
|
|
43
|
-
**/
|
|
44
|
-
@withStyle(generateStyle, generateComponentTheme)
|
|
45
|
-
@testable()
|
|
46
|
-
class NavigationItem extends Component<NavigationItemProps> {
|
|
47
|
-
static readonly componentId = 'Navigation.Item'
|
|
48
|
-
|
|
49
|
-
static allowedProps = allowedProps
|
|
50
|
-
static propTypes = propTypes
|
|
51
|
-
|
|
52
|
-
static defaultProps = {
|
|
53
|
-
as: 'a',
|
|
54
|
-
selected: false,
|
|
55
|
-
minimized: false
|
|
56
|
-
} as const
|
|
57
|
-
|
|
58
|
-
ref: Element | null = null
|
|
59
|
-
|
|
60
|
-
handleRef = (el: Element | null) => {
|
|
61
|
-
const { elementRef } = this.props
|
|
62
|
-
this.ref = el
|
|
63
|
-
if (typeof elementRef === 'function') {
|
|
64
|
-
elementRef(el)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
componentDidMount() {
|
|
69
|
-
this.props.makeStyles?.({ minimized: this.props.minimized })
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
componentDidUpdate() {
|
|
73
|
-
this.props.makeStyles?.({ minimized: this.props.minimized })
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
renderLink(addRef: boolean) {
|
|
77
|
-
const ElementType = getElementType(NavigationItem, this.props)
|
|
78
|
-
|
|
79
|
-
const { href, onClick, icon, label } = this.props
|
|
80
|
-
|
|
81
|
-
const props = omitProps(this.props, NavigationItem.allowedProps)
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<ElementType
|
|
85
|
-
{...props}
|
|
86
|
-
href={href}
|
|
87
|
-
onClick={onClick}
|
|
88
|
-
ref={addRef ? this.handleRef : undefined}
|
|
89
|
-
css={this.props.styles?.navigationItem}
|
|
90
|
-
aria-label={this.props.minimized ? (label as string) : undefined}
|
|
91
|
-
>
|
|
92
|
-
<div css={this.props.styles?.icon} aria-hidden="true">
|
|
93
|
-
{icon}
|
|
94
|
-
</div>
|
|
95
|
-
{!this.props.minimized ? (
|
|
96
|
-
<div css={this.props.styles?.label}>{label}</div>
|
|
97
|
-
) : null}
|
|
98
|
-
</ElementType>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
render() {
|
|
103
|
-
const { minimized, label } = this.props
|
|
104
|
-
const hasTooltip: boolean = minimized! && hasVisibleChildren(label)
|
|
105
|
-
const link = this.renderLink(!hasTooltip)
|
|
106
|
-
return hasTooltip ? (
|
|
107
|
-
<Tooltip renderTip={label} placement="end" elementRef={this.handleRef}>
|
|
108
|
-
{link}
|
|
109
|
-
</Tooltip>
|
|
110
|
-
) : (
|
|
111
|
-
link
|
|
112
|
-
)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export default NavigationItem
|
|
117
|
-
export { NavigationItem }
|
|
@@ -1,27 +0,0 @@
|
|
|
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 { NavigationItemLocator } from './NavigationItemLocator'
|
|
25
|
-
|
|
26
|
-
export { NavigationItemLocator }
|
|
27
|
-
export default NavigationItemLocator
|
|
@@ -1,102 +0,0 @@
|
|
|
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 React from 'react'
|
|
26
|
-
import type {
|
|
27
|
-
AsElementType,
|
|
28
|
-
PropValidators,
|
|
29
|
-
NavigationItemTheme,
|
|
30
|
-
OtherHTMLAttributes
|
|
31
|
-
} from '@instructure/shared-types'
|
|
32
|
-
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
33
|
-
|
|
34
|
-
type NavigationItemOwnProps = {
|
|
35
|
-
/**
|
|
36
|
-
* The reference to the underlying HTML element
|
|
37
|
-
*/
|
|
38
|
-
elementRef?: (el: Element | null) => void
|
|
39
|
-
/**
|
|
40
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
41
|
-
*/
|
|
42
|
-
icon: React.ReactNode
|
|
43
|
-
/**
|
|
44
|
-
* The text to display for the Navigation Link
|
|
45
|
-
*/
|
|
46
|
-
label: React.ReactNode
|
|
47
|
-
/**
|
|
48
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
49
|
-
*/
|
|
50
|
-
as?: AsElementType
|
|
51
|
-
/**
|
|
52
|
-
* If the NavigationItem goes to a new page, pass an href
|
|
53
|
-
*/
|
|
54
|
-
href?: string
|
|
55
|
-
/**
|
|
56
|
-
* If the NavigationItem does not go to a new page pass an onClick
|
|
57
|
-
*/
|
|
58
|
-
onClick?: (event: React.MouseEvent) => void
|
|
59
|
-
/**
|
|
60
|
-
* Denotes which NavigationItem is currently selected
|
|
61
|
-
*/
|
|
62
|
-
selected?: boolean
|
|
63
|
-
/**
|
|
64
|
-
* 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
|
|
65
|
-
*/
|
|
66
|
-
minimized?: boolean
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
type PropKeys = keyof NavigationItemOwnProps
|
|
70
|
-
|
|
71
|
-
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
72
|
-
|
|
73
|
-
type NavigationItemProps = NavigationItemOwnProps &
|
|
74
|
-
WithStyleProps<NavigationItemTheme, NavigationItemStyle> &
|
|
75
|
-
OtherHTMLAttributes<NavigationItemOwnProps>
|
|
76
|
-
|
|
77
|
-
type NavigationItemStyle = ComponentStyle<'navigationItem' | 'icon' | 'label'>
|
|
78
|
-
|
|
79
|
-
const propTypes: PropValidators<PropKeys> = {
|
|
80
|
-
elementRef: PropTypes.func,
|
|
81
|
-
icon: PropTypes.node.isRequired,
|
|
82
|
-
label: PropTypes.node.isRequired,
|
|
83
|
-
as: PropTypes.elementType,
|
|
84
|
-
href: PropTypes.string,
|
|
85
|
-
onClick: PropTypes.func,
|
|
86
|
-
selected: PropTypes.bool,
|
|
87
|
-
minimized: PropTypes.bool
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const allowedProps: AllowedPropKeys = [
|
|
91
|
-
'elementRef',
|
|
92
|
-
'icon',
|
|
93
|
-
'label',
|
|
94
|
-
'as',
|
|
95
|
-
'href',
|
|
96
|
-
'onClick',
|
|
97
|
-
'selected',
|
|
98
|
-
'minimized'
|
|
99
|
-
]
|
|
100
|
-
|
|
101
|
-
export type { NavigationItemProps, NavigationItemStyle }
|
|
102
|
-
export { propTypes, allowedProps }
|