@instructure/ui-side-nav-bar 11.6.0 → 11.6.1-snapshot-129

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +34 -290
  2. package/es/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/index.js +2 -2
  3. package/es/SideNavBar/{index.js → v1/index.js} +1 -1
  4. package/es/SideNavBar/v2/SideNavBarItem/index.js +109 -0
  5. package/{src/index.ts → es/SideNavBar/v2/SideNavBarItem/props.js} +2 -4
  6. package/es/SideNavBar/v2/SideNavBarItem/styles.js +101 -0
  7. package/es/SideNavBar/v2/index.js +135 -0
  8. package/es/SideNavBar/v2/props.js +26 -0
  9. package/es/SideNavBar/v2/styles.js +95 -0
  10. package/es/{index.js → exports/a.js} +1 -1
  11. package/es/exports/b.js +24 -0
  12. package/lib/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/index.js +3 -3
  13. package/lib/SideNavBar/{index.js → v1/index.js} +2 -2
  14. package/lib/SideNavBar/v2/SideNavBarItem/index.js +115 -0
  15. package/lib/SideNavBar/v2/SideNavBarItem/props.js +31 -0
  16. package/lib/SideNavBar/v2/SideNavBarItem/styles.js +107 -0
  17. package/lib/SideNavBar/v2/index.js +149 -0
  18. package/lib/SideNavBar/v2/props.js +31 -0
  19. package/lib/SideNavBar/v2/styles.js +100 -0
  20. package/lib/{index.js → exports/a.js} +3 -3
  21. package/lib/exports/b.js +18 -0
  22. package/package.json +43 -21
  23. package/src/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/index.tsx +2 -2
  24. package/src/SideNavBar/{index.tsx → v1/index.tsx} +1 -1
  25. package/src/SideNavBar/v2/README.md +108 -0
  26. package/src/SideNavBar/v2/SideNavBarItem/index.tsx +112 -0
  27. package/src/SideNavBar/v2/SideNavBarItem/props.ts +89 -0
  28. package/src/SideNavBar/v2/SideNavBarItem/styles.ts +111 -0
  29. package/src/SideNavBar/v2/index.tsx +162 -0
  30. package/src/SideNavBar/v2/props.ts +94 -0
  31. package/src/SideNavBar/v2/styles.ts +105 -0
  32. package/src/exports/a.ts +28 -0
  33. package/src/exports/b.ts +28 -0
  34. package/tsconfig.build.tsbuildinfo +1 -1
  35. package/types/SideNavBar/v1/SideNavBarItem/index.d.ts.map +1 -0
  36. package/types/SideNavBar/v1/SideNavBarItem/props.d.ts.map +1 -0
  37. package/types/SideNavBar/v1/SideNavBarItem/styles.d.ts.map +1 -0
  38. package/types/SideNavBar/v1/SideNavBarItem/theme.d.ts.map +1 -0
  39. package/types/SideNavBar/v1/index.d.ts.map +1 -0
  40. package/types/SideNavBar/v1/props.d.ts.map +1 -0
  41. package/types/SideNavBar/v1/styles.d.ts.map +1 -0
  42. package/types/SideNavBar/v1/theme.d.ts.map +1 -0
  43. package/types/SideNavBar/v2/SideNavBarItem/index.d.ts +35 -0
  44. package/types/SideNavBar/v2/SideNavBarItem/index.d.ts.map +1 -0
  45. package/types/SideNavBar/v2/SideNavBarItem/props.d.ts +45 -0
  46. package/types/SideNavBar/v2/SideNavBarItem/props.d.ts.map +1 -0
  47. package/types/SideNavBar/v2/SideNavBarItem/styles.d.ts +16 -0
  48. package/types/SideNavBar/v2/SideNavBarItem/styles.d.ts.map +1 -0
  49. package/types/SideNavBar/v2/index.d.ts +44 -0
  50. package/types/SideNavBar/v2/index.d.ts.map +1 -0
  51. package/types/SideNavBar/v2/props.d.ts +48 -0
  52. package/types/SideNavBar/v2/props.d.ts.map +1 -0
  53. package/types/SideNavBar/v2/styles.d.ts +16 -0
  54. package/types/SideNavBar/v2/styles.d.ts.map +1 -0
  55. package/types/exports/a.d.ts +4 -0
  56. package/types/exports/a.d.ts.map +1 -0
  57. package/types/exports/b.d.ts +4 -0
  58. package/types/exports/b.d.ts.map +1 -0
  59. package/types/SideNavBar/SideNavBarItem/index.d.ts.map +0 -1
  60. package/types/SideNavBar/SideNavBarItem/props.d.ts.map +0 -1
  61. package/types/SideNavBar/SideNavBarItem/styles.d.ts.map +0 -1
  62. package/types/SideNavBar/SideNavBarItem/theme.d.ts.map +0 -1
  63. package/types/SideNavBar/index.d.ts.map +0 -1
  64. package/types/SideNavBar/props.d.ts.map +0 -1
  65. package/types/SideNavBar/styles.d.ts.map +0 -1
  66. package/types/SideNavBar/theme.d.ts.map +0 -1
  67. package/types/index.d.ts +0 -4
  68. package/types/index.d.ts.map +0 -1
  69. /package/es/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/props.js +0 -0
  70. /package/es/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/styles.js +0 -0
  71. /package/es/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/theme.js +0 -0
  72. /package/es/SideNavBar/{props.js → v1/props.js} +0 -0
  73. /package/es/SideNavBar/{styles.js → v1/styles.js} +0 -0
  74. /package/es/SideNavBar/{theme.js → v1/theme.js} +0 -0
  75. /package/lib/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/props.js +0 -0
  76. /package/lib/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/styles.js +0 -0
  77. /package/lib/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/theme.js +0 -0
  78. /package/lib/SideNavBar/{props.js → v1/props.js} +0 -0
  79. /package/lib/SideNavBar/{styles.js → v1/styles.js} +0 -0
  80. /package/lib/SideNavBar/{theme.js → v1/theme.js} +0 -0
  81. /package/src/SideNavBar/{README.md → v1/README.md} +0 -0
  82. /package/src/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/props.ts +0 -0
  83. /package/src/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/styles.ts +0 -0
  84. /package/src/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/theme.ts +0 -0
  85. /package/src/SideNavBar/{props.ts → v1/props.ts} +0 -0
  86. /package/src/SideNavBar/{styles.ts → v1/styles.ts} +0 -0
  87. /package/src/SideNavBar/{theme.ts → v1/theme.ts} +0 -0
  88. /package/types/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/index.d.ts +0 -0
  89. /package/types/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/props.d.ts +0 -0
  90. /package/types/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/styles.d.ts +0 -0
  91. /package/types/SideNavBar/{SideNavBarItem → v1/SideNavBarItem}/theme.d.ts +0 -0
  92. /package/types/SideNavBar/{index.d.ts → v1/index.d.ts} +0 -0
  93. /package/types/SideNavBar/{props.d.ts → v1/props.d.ts} +0 -0
  94. /package/types/SideNavBar/{styles.d.ts → v1/styles.d.ts} +0 -0
  95. /package/types/SideNavBar/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,109 @@
1
+ var _dec, _class, _SideNavBarItem;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { omitProps, getElementType } from '@instructure/ui-react-utils';
28
+ import { Tooltip } from '@instructure/ui-tooltip/latest';
29
+ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
30
+ import { withStyle } from '@instructure/emotion';
31
+ import generateStyle from "./styles.js";
32
+ import { allowedProps } from "./props.js";
33
+ /**
34
+ ---
35
+ parent: SideNavBar
36
+ id: SideNavBar.Item
37
+ ---
38
+ **/
39
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
40
+ let SideNavBarItem = (_dec = withStyle(generateStyle, 'SideNavBarItem'), _dec(_class = (_SideNavBarItem = class SideNavBarItem extends Component {
41
+ constructor(...args) {
42
+ super(...args);
43
+ this.ref = null;
44
+ this.handleRef = el => {
45
+ const elementRef = this.props.elementRef;
46
+ this.ref = el;
47
+ if (typeof elementRef === 'function') {
48
+ elementRef(el);
49
+ }
50
+ };
51
+ }
52
+ componentDidMount() {
53
+ var _this$props$makeStyle, _this$props;
54
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
55
+ minimized: this.props.minimized
56
+ });
57
+ }
58
+ componentDidUpdate() {
59
+ var _this$props$makeStyle2, _this$props2;
60
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
61
+ minimized: this.props.minimized
62
+ });
63
+ }
64
+ renderLink(addRef) {
65
+ var _this$props$styles, _this$props$styles2, _this$props$styles3;
66
+ const ElementType = getElementType(SideNavBarItem, this.props);
67
+ const _this$props3 = this.props,
68
+ href = _this$props3.href,
69
+ onClick = _this$props3.onClick,
70
+ icon = _this$props3.icon,
71
+ label = _this$props3.label;
72
+ const props = omitProps(this.props, SideNavBarItem.allowedProps);
73
+ return _jsxs(ElementType, {
74
+ ...props,
75
+ href: href,
76
+ onClick: onClick,
77
+ ref: addRef ? this.handleRef : void 0,
78
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
79
+ "aria-label": this.props.minimized ? label : void 0,
80
+ "data-cid": "SideNavBarItem",
81
+ children: [_jsx("div", {
82
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
83
+ children: icon
84
+ }), !this.props.minimized ? _jsx("div", {
85
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.label,
86
+ children: label
87
+ }) : null]
88
+ });
89
+ }
90
+ render() {
91
+ const _this$props4 = this.props,
92
+ minimized = _this$props4.minimized,
93
+ label = _this$props4.label;
94
+ const hasTooltip = minimized && hasVisibleChildren(label);
95
+ const link = this.renderLink(!hasTooltip);
96
+ return hasTooltip ? _jsx(Tooltip, {
97
+ renderTip: label,
98
+ placement: "end",
99
+ elementRef: this.handleRef,
100
+ children: link
101
+ }) : link;
102
+ }
103
+ }, _SideNavBarItem.displayName = "SideNavBarItem", _SideNavBarItem.componentId = 'SideNavBar.Item', _SideNavBarItem.allowedProps = allowedProps, _SideNavBarItem.defaultProps = {
104
+ as: 'a',
105
+ selected: false,
106
+ minimized: false
107
+ }, _SideNavBarItem)) || _class);
108
+ export default SideNavBarItem;
109
+ export { SideNavBarItem };
@@ -22,7 +22,5 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export { SideNavBar, SideNavBarItem } from './SideNavBar'
26
-
27
- export type { SideNavBarProps } from './SideNavBar/props'
28
- export type { SideNavBarItemProps } from './SideNavBar/SideNavBarItem/props'
25
+ const allowedProps = ['elementRef', 'icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
26
+ export { allowedProps };
@@ -0,0 +1,101 @@
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
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} sharedTokens Shared theme token object
33
+ * @param {Object} state the state of the component, the style is applied to
34
+ * @return {Object} The final style object, which will be used in the component
35
+ */
36
+ const generateStyle = (componentTheme, props) => {
37
+ const selected = props.selected;
38
+ return {
39
+ navigationItem: {
40
+ borderRadius: componentTheme.borderRadius,
41
+ label: 'navigationItem',
42
+ fontFamily: componentTheme.fontFamily,
43
+ fontWeight: componentTheme.fontWeight,
44
+ display: 'block',
45
+ width: '100%',
46
+ textAlign: 'center',
47
+ padding: componentTheme.contentPadding,
48
+ cursor: 'pointer',
49
+ border: 'none',
50
+ boxSizing: 'border-box',
51
+ textDecoration: componentTheme.linkTextDecoration,
52
+ overflowWrap: 'break-word',
53
+ wordWrap: 'break-word',
54
+ hyphens: 'auto',
55
+ ...(selected ? {
56
+ backgroundColor: componentTheme.selectedBackgroundColor,
57
+ color: componentTheme.selectedFontColor,
58
+ '&:active, &:hover': {
59
+ backgroundColor: componentTheme.selectedBackgroundColor,
60
+ color: componentTheme.selectedFontColor,
61
+ textDecoration: componentTheme.linkTextDecoration
62
+ },
63
+ '&:focus': {
64
+ backgroundColor: componentTheme.selectedBackgroundColor,
65
+ boxShadow: `${componentTheme.selectedOuterFocusOutlineColor}, ${componentTheme.selectedInnerFocusOutlineColor}`,
66
+ outline: 'none'
67
+ }
68
+ } : {
69
+ backgroundColor: componentTheme.backgroundColor,
70
+ color: componentTheme.fontColor,
71
+ '&:active': {
72
+ backgroundColor: componentTheme.hoverBackgroundColor
73
+ },
74
+ '&:hover': {
75
+ transition: 'background-color .3s',
76
+ backgroundColor: componentTheme.hoverBackgroundColor,
77
+ color: componentTheme.fontColor,
78
+ textDecoration: componentTheme.linkTextDecoration
79
+ },
80
+ '&:focus': {
81
+ backgroundColor: componentTheme.hoverBackgroundColor,
82
+ boxShadow: `inset 0 0 0 0.125rem ${componentTheme.outerFocusOutlineColor}, inset 0 0 0 0.25rem ${componentTheme.innerFocusOutlineColor}`,
83
+ outline: 'none'
84
+ }
85
+ })
86
+ },
87
+ icon: {
88
+ label: 'navigationItem__icon',
89
+ height: componentTheme.iconWrapperHeight,
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ justifyContent: 'center'
93
+ },
94
+ label: {
95
+ label: 'navigationItem__label',
96
+ fontSize: componentTheme.fontSize,
97
+ lineHeight: componentTheme.lineHeight
98
+ }
99
+ };
100
+ };
101
+ export default generateStyle;
@@ -0,0 +1,135 @@
1
+ var _dec, _class, _SideNavBar;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import { Component, Children, isValidElement } from 'react';
26
+ import { omitProps, safeCloneElement } from '@instructure/ui-react-utils';
27
+ import { PanelLeftCloseInstUIIcon, PanelLeftOpenInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
28
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content';
29
+ import { withStyle } from '@instructure/emotion';
30
+ import { SideNavBarItem } from "./SideNavBarItem/index.js";
31
+ import generateStyle from "./styles.js";
32
+ import { allowedProps } from "./props.js";
33
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
34
+ const navMinimized = ({
35
+ minimized
36
+ }) => ({
37
+ minimized: !minimized
38
+ });
39
+
40
+ /**
41
+ ---
42
+ category: components
43
+ ---
44
+ **/
45
+ let SideNavBar = (_dec = withStyle(generateStyle), _dec(_class = (_SideNavBar = class SideNavBar extends Component {
46
+ constructor(props) {
47
+ super(props);
48
+ this.ref = null;
49
+ this.handleNavToggle = event => {
50
+ if (!this.isControlled()) {
51
+ this.setState(navMinimized);
52
+ }
53
+ if (typeof this.props.onMinimized === 'function') {
54
+ this.props.onMinimized(event, !this.minimized);
55
+ }
56
+ };
57
+ this.state = {
58
+ minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
59
+ };
60
+ }
61
+ componentDidMount() {
62
+ var _this$props$makeStyle, _this$props;
63
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
64
+ minimized: this.minimized
65
+ });
66
+ }
67
+ componentDidUpdate() {
68
+ var _this$props$makeStyle2, _this$props2;
69
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
70
+ minimized: this.minimized
71
+ });
72
+ }
73
+ get minimized() {
74
+ if (this.isControlled()) {
75
+ return !!this.props.minimized;
76
+ }
77
+ return !!this.state.minimized;
78
+ }
79
+ isControlled(props = this.props) {
80
+ return typeof props.minimized === 'boolean';
81
+ }
82
+ renderChildren() {
83
+ return Children.map(this.props.children, child => {
84
+ var _this$props$styles;
85
+ if (! /*#__PURE__*/isValidElement(child)) return null;
86
+ const navItem = safeCloneElement(child, {
87
+ minimized: this.state.minimized
88
+ });
89
+ return _jsx("li", {
90
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.list,
91
+ children: navItem
92
+ });
93
+ });
94
+ }
95
+ renderIcon() {
96
+ const icon = this.minimized ? PanelLeftOpenInstUIIcon : PanelLeftCloseInstUIIcon;
97
+ const iconColor = this.props.selected ? 'sideNavActiveColor' : 'sideNavColor';
98
+ return renderIconWithProps(icon, 'lg', iconColor); //TODO-rework remove after merging into v12
99
+ }
100
+ toggleMessage() {
101
+ return this.state.minimized ? this.props.toggleLabel.minimizedLabel : this.props.toggleLabel.expandedLabel;
102
+ }
103
+ render() {
104
+ var _this$props$styles2, _this$props$styles3;
105
+ const label = this.props.label;
106
+ const props = omitProps(this.props, SideNavBar.allowedProps, ['minimized']);
107
+ return _jsxs("nav", {
108
+ ...props,
109
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.navigation,
110
+ "data-cid": "SideNavBar",
111
+ "aria-label": label,
112
+ ref: element => {
113
+ this.ref = element;
114
+ },
115
+ children: [_jsx("ul", {
116
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.content,
117
+ children: this.renderChildren()
118
+ }), _jsx(SideNavBarItem, {
119
+ "aria-expanded": !this.minimized,
120
+ onClick: this.handleNavToggle,
121
+ icon: this.renderIcon(),
122
+ label: _jsx(ScreenReaderContent, {
123
+ children: this.toggleMessage()
124
+ })
125
+ })]
126
+ });
127
+ }
128
+ }, _SideNavBar.displayName = "SideNavBar", _SideNavBar.componentId = 'SideNavBar', _SideNavBar.allowedProps = allowedProps, _SideNavBar.defaultProps = {
129
+ children: null,
130
+ defaultMinimized: false,
131
+ // TODO we should investigate later if it used or not
132
+ onClick: function (_e) {}
133
+ }, _SideNavBar.Item = SideNavBarItem, _SideNavBar)) || _class);
134
+ export default SideNavBar;
135
+ export { SideNavBar, SideNavBarItem };
@@ -0,0 +1,26 @@
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
+
25
+ const allowedProps = ['children', 'minimized', 'defaultMinimized', 'onMinimized', 'label', 'toggleLabel', 'href', 'onClick'];
26
+ export { allowedProps };
@@ -0,0 +1,95 @@
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
+
25
+ import { boxShadowObjectsToCSSString } from '@instructure/ui-themes';
26
+
27
+ /**
28
+ * ---
29
+ * private: true
30
+ * ---
31
+ * Generates the style object from the theme and provided additional information
32
+ * @param {Object} componentTheme The theme variable object.
33
+ * @param {Object} props the props of the component, the style is applied to
34
+ * @param {Object} sharedTokens Shared theme token object
35
+ * @param {Object} state the state of the component, the style is applied to
36
+ * @return {Object} The final style object, which will be used in the component
37
+ */
38
+ const generateStyle = (componentTheme, _props, _sharedTokens, state) => {
39
+ const minimized = state.minimized;
40
+ const layoutVariants = {
41
+ minimized: {
42
+ width: componentTheme.minimizedWidth,
43
+ margin: componentTheme.minimizedMargin,
44
+ borderRadius: componentTheme.minimizedBorderRadius
45
+ },
46
+ expanded: {
47
+ width: componentTheme.width,
48
+ margin: componentTheme.margin,
49
+ borderRadius: componentTheme.borderRadius
50
+ }
51
+ };
52
+ return {
53
+ navigation: {
54
+ label: 'navigation',
55
+ color: componentTheme.fontColor,
56
+ backgroundColor: componentTheme.backgroundColor,
57
+ boxSizing: 'border-box',
58
+ display: 'flex',
59
+ flexDirection: 'column',
60
+ height: '100%',
61
+ overflowY: 'auto',
62
+ boxShadow: boxShadowObjectsToCSSString(componentTheme.boxShadow),
63
+ ...layoutVariants[minimized ? 'minimized' : 'expanded'],
64
+ // The layout toggle button needs the nav's border radius to visually match the container corners.
65
+ '& > [data-cid="SideNavBarItem"]': {
66
+ borderRadius: minimized ? componentTheme.minimizedBorderRadius : componentTheme.borderRadius
67
+ }
68
+ },
69
+ list: {
70
+ label: 'navigation__list',
71
+ padding: 0,
72
+ margin: 0
73
+ },
74
+ content: {
75
+ label: 'navigation__content',
76
+ listStyleType: 'none',
77
+ margin: componentTheme.contentMargin,
78
+ padding: 0,
79
+ display: 'flex',
80
+ flex: '1 0 auto',
81
+ flexDirection: 'column',
82
+ gap: componentTheme.contentGap
83
+ },
84
+ toggleIcon: {
85
+ fill: componentTheme.fill,
86
+ margin: '0 auto',
87
+ transform: 'translate3d(0, 0, 0)',
88
+ transition: `all ${componentTheme.toggleTransition}`,
89
+ ...(minimized ? {
90
+ transform: 'rotate3d(0, 1, 0, -180deg)'
91
+ } : {})
92
+ }
93
+ };
94
+ };
95
+ export default generateStyle;
@@ -21,4 +21,4 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- export { SideNavBar, SideNavBarItem } from "./SideNavBar/index.js";
24
+ export { SideNavBar, SideNavBarItem } from "../SideNavBar/v1/index.js";
@@ -0,0 +1,24 @@
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
+ export { SideNavBar, SideNavBarItem } from "../SideNavBar/v2/index.js";
@@ -8,7 +8,7 @@ exports.default = exports.SideNavBarItem = void 0;
8
8
  var _react = require("react");
9
9
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
10
  var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
11
- var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
11
+ var _v11_ = require("@instructure/ui-tooltip/v11_6");
12
12
  var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
13
13
  var _emotion = require("@instructure/emotion");
14
14
  var _styles = _interopRequireDefault(require("./styles"));
@@ -45,7 +45,7 @@ parent: SideNavBar
45
45
  id: SideNavBar.Item
46
46
  ---
47
47
  **/
48
- let SideNavBarItem = exports.SideNavBarItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_SideNavBarItem = class SideNavBarItem extends _react.Component {
48
+ let SideNavBarItem = exports.SideNavBarItem = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_SideNavBarItem = class SideNavBarItem extends _react.Component {
49
49
  constructor(...args) {
50
50
  super(...args);
51
51
  this.ref = null;
@@ -101,7 +101,7 @@ let SideNavBarItem = exports.SideNavBarItem = (_dec = (0, _emotion.withStyle)(_s
101
101
  label = _this$props4.label;
102
102
  const hasTooltip = minimized && (0, _hasVisibleChildren.hasVisibleChildren)(label);
103
103
  const link = this.renderLink(!hasTooltip);
104
- return hasTooltip ? (0, _jsxRuntime.jsx)(_Tooltip.Tooltip, {
104
+ return hasTooltip ? (0, _jsxRuntime.jsx)(_v11_.Tooltip, {
105
105
  renderTip: label,
106
106
  placement: "end",
107
107
  elementRef: this.handleRef,
@@ -15,7 +15,7 @@ exports.default = void 0;
15
15
  var _react = require("react");
16
16
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
17
17
  var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
18
- var _IconMoveStartLine = require("@instructure/ui-icons/lib/IconMoveStartLine.js");
18
+ var _IconMoveStartLine = require("@instructure/ui-icons/lib/generated/IconMoveStartLine.js");
19
19
  var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
20
20
  var _emotion = require("@instructure/emotion");
21
21
  var _SideNavBarItem = require("./SideNavBarItem");
@@ -58,7 +58,7 @@ const navMinimized = ({
58
58
  category: components
59
59
  ---
60
60
  **/
61
- let SideNavBar = exports.SideNavBar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_SideNavBar = class SideNavBar extends _react.Component {
61
+ let SideNavBar = exports.SideNavBar = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_SideNavBar = class SideNavBar extends _react.Component {
62
62
  constructor(props) {
63
63
  super(props);
64
64
  this.ref = null;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.SideNavBarItem = void 0;
8
+ var _react = require("react");
9
+ var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
10
+ var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
11
+ var _latest = require("@instructure/ui-tooltip/latest");
12
+ var _hasVisibleChildren = require("@instructure/ui-a11y-utils/lib/hasVisibleChildren.js");
13
+ var _emotion = require("@instructure/emotion");
14
+ var _styles = _interopRequireDefault(require("./styles"));
15
+ var _props = require("./props");
16
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
+ var _dec, _class, _SideNavBarItem;
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
+ /**
42
+ ---
43
+ parent: SideNavBar
44
+ id: SideNavBar.Item
45
+ ---
46
+ **/
47
+ let SideNavBarItem = exports.SideNavBarItem = (_dec = (0, _emotion.withStyle)(_styles.default, 'SideNavBarItem'), _dec(_class = (_SideNavBarItem = class SideNavBarItem extends _react.Component {
48
+ constructor(...args) {
49
+ super(...args);
50
+ this.ref = null;
51
+ this.handleRef = el => {
52
+ const elementRef = this.props.elementRef;
53
+ this.ref = el;
54
+ if (typeof elementRef === 'function') {
55
+ elementRef(el);
56
+ }
57
+ };
58
+ }
59
+ componentDidMount() {
60
+ var _this$props$makeStyle, _this$props;
61
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
62
+ minimized: this.props.minimized
63
+ });
64
+ }
65
+ componentDidUpdate() {
66
+ var _this$props$makeStyle2, _this$props2;
67
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
68
+ minimized: this.props.minimized
69
+ });
70
+ }
71
+ renderLink(addRef) {
72
+ var _this$props$styles, _this$props$styles2, _this$props$styles3;
73
+ const ElementType = (0, _getElementType.getElementType)(SideNavBarItem, this.props);
74
+ const _this$props3 = this.props,
75
+ href = _this$props3.href,
76
+ onClick = _this$props3.onClick,
77
+ icon = _this$props3.icon,
78
+ label = _this$props3.label;
79
+ const props = (0, _omitProps.omitProps)(this.props, SideNavBarItem.allowedProps);
80
+ return (0, _jsxRuntime.jsxs)(ElementType, {
81
+ ...props,
82
+ href: href,
83
+ onClick: onClick,
84
+ ref: addRef ? this.handleRef : void 0,
85
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
86
+ "aria-label": this.props.minimized ? label : void 0,
87
+ "data-cid": "SideNavBarItem",
88
+ children: [(0, _jsxRuntime.jsx)("div", {
89
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
90
+ children: icon
91
+ }), !this.props.minimized ? (0, _jsxRuntime.jsx)("div", {
92
+ css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.label,
93
+ children: label
94
+ }) : null]
95
+ });
96
+ }
97
+ render() {
98
+ const _this$props4 = this.props,
99
+ minimized = _this$props4.minimized,
100
+ label = _this$props4.label;
101
+ const hasTooltip = minimized && (0, _hasVisibleChildren.hasVisibleChildren)(label);
102
+ const link = this.renderLink(!hasTooltip);
103
+ return hasTooltip ? (0, _jsxRuntime.jsx)(_latest.Tooltip, {
104
+ renderTip: label,
105
+ placement: "end",
106
+ elementRef: this.handleRef,
107
+ children: link
108
+ }) : link;
109
+ }
110
+ }, _SideNavBarItem.displayName = "SideNavBarItem", _SideNavBarItem.componentId = 'SideNavBar.Item', _SideNavBarItem.allowedProps = _props.allowedProps, _SideNavBarItem.defaultProps = {
111
+ as: 'a',
112
+ selected: false,
113
+ minimized: false
114
+ }, _SideNavBarItem)) || _class);
115
+ var _default = exports.default = SideNavBarItem;