@coreui/react 2.5.7 → 2.5.8
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 +18 -0
- package/es/Aside.js +29 -37
- package/es/AsideToggler.js +36 -44
- package/es/Breadcrumb.js +51 -58
- package/es/Breadcrumb2.js +52 -60
- package/es/Footer.js +24 -32
- package/es/Header.js +23 -35
- package/es/HeaderDropdown.js +23 -27
- package/es/NavbarBrand.js +32 -39
- package/es/Shared/classes.js +0 -3
- package/es/Shared/element-closest.js +2 -0
- package/es/Shared/index.js +0 -1
- package/es/Shared/layout/layout.js +24 -16
- package/es/Shared/toggle-classes.js +2 -0
- package/es/Sidebar.js +43 -53
- package/es/SidebarFooter.js +19 -29
- package/es/SidebarForm.js +19 -29
- package/es/SidebarHeader.js +19 -29
- package/es/SidebarMinimizer.js +30 -35
- package/es/SidebarNav.js +128 -162
- package/es/SidebarNav2.js +178 -202
- package/es/SidebarToggler.js +35 -36
- package/es/Switch.js +59 -62
- package/lib/Aside.js +51 -60
- package/lib/AsideToggler.js +58 -67
- package/lib/Breadcrumb.js +71 -77
- package/lib/Breadcrumb2.js +72 -79
- package/lib/Footer.js +40 -47
- package/lib/Header.js +39 -50
- package/lib/HeaderDropdown.js +36 -37
- package/lib/NavbarBrand.js +50 -56
- package/lib/Shared/classes.js +8 -6
- package/lib/Shared/element-closest.js +3 -1
- package/lib/Shared/index.js +2 -3
- package/lib/Shared/layout/layout.js +31 -19
- package/lib/Shared/toggle-classes.js +6 -2
- package/lib/Sidebar.js +69 -81
- package/lib/SidebarFooter.js +33 -42
- package/lib/SidebarForm.js +33 -42
- package/lib/SidebarHeader.js +33 -42
- package/lib/SidebarMinimizer.js +51 -55
- package/lib/SidebarNav.js +154 -187
- package/lib/SidebarNav2.js +211 -236
- package/lib/SidebarToggler.js +56 -58
- package/lib/Switch.js +90 -92
- package/lib/index.js +36 -55
- package/package.json +14 -14
- package/umd/main.d0f057e5.css +5 -0
- package/umd/main.d0f057e5.css.map +1 -0
- package/umd/{@coreui/react.js → react.js} +918 -1076
- package/umd/react.min.js +38 -0
- package/umd/react.min.js.map +1 -0
- package/umd/@coreui/react.min.js +0 -44
- package/umd/@coreui/react.min.js.map +0 -1
- package/umd/main.a93373b7.css +0 -148
- package/umd/main.a93373b7.css.map +0 -1
package/lib/SidebarNav2.js
CHANGED
|
@@ -1,59 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
4
5
|
|
|
5
|
-
var
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
6
7
|
|
|
7
|
-
var
|
|
8
|
+
var _reactstrap = require("reactstrap");
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
11
|
|
|
11
|
-
var
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
13
|
|
|
13
|
-
var
|
|
14
|
+
var _reactPerfectScrollbar = _interopRequireDefault(require("react-perfect-scrollbar"));
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
require("react-perfect-scrollbar/dist/css/styles.css");
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
require("../css/scrollbar.css");
|
|
18
19
|
|
|
19
|
-
var
|
|
20
|
+
var _layout = _interopRequireDefault(require("./Shared/layout/layout"));
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
23
|
|
|
23
|
-
var
|
|
24
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
24
25
|
|
|
25
|
-
var
|
|
26
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
34
35
|
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
38
|
-
|
|
39
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
40
|
-
|
|
41
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
42
|
-
|
|
43
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
44
|
-
|
|
45
|
-
var propTypes = {
|
|
46
|
-
children: _propTypes2.default.node,
|
|
47
|
-
className: _propTypes2.default.string,
|
|
48
|
-
navConfig: _propTypes2.default.any,
|
|
49
|
-
navFunc: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]),
|
|
50
|
-
isOpen: _propTypes2.default.bool,
|
|
51
|
-
staticContext: _propTypes2.default.any,
|
|
52
|
-
tag: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.string]),
|
|
53
|
-
router: _propTypes2.default.any,
|
|
54
|
-
props: _propTypes2.default.any
|
|
55
|
-
};
|
|
36
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
56
37
|
|
|
38
|
+
var propTypes = process.env.NODE_ENV !== "production" ? {
|
|
39
|
+
children: _propTypes["default"].node,
|
|
40
|
+
className: _propTypes["default"].string,
|
|
41
|
+
navConfig: _propTypes["default"].any,
|
|
42
|
+
navFunc: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]),
|
|
43
|
+
isOpen: _propTypes["default"].bool,
|
|
44
|
+
staticContext: _propTypes["default"].any,
|
|
45
|
+
tag: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].string]),
|
|
46
|
+
router: _propTypes["default"].any,
|
|
47
|
+
props: _propTypes["default"].any
|
|
48
|
+
} : {};
|
|
57
49
|
var defaultProps = {
|
|
58
50
|
tag: 'nav',
|
|
59
51
|
navConfig: {
|
|
@@ -61,174 +53,165 @@ var defaultProps = {
|
|
|
61
53
|
name: 'Dashboard',
|
|
62
54
|
url: '/dashboard',
|
|
63
55
|
icon: 'icon-speedometer',
|
|
64
|
-
badge: {
|
|
56
|
+
badge: {
|
|
57
|
+
variant: 'info',
|
|
58
|
+
text: 'NEW'
|
|
59
|
+
}
|
|
65
60
|
}]
|
|
66
61
|
},
|
|
67
62
|
isOpen: false,
|
|
68
|
-
router: {
|
|
63
|
+
router: {
|
|
64
|
+
RsNavLink: _reactstrap.NavLink
|
|
65
|
+
}
|
|
69
66
|
};
|
|
70
67
|
|
|
71
|
-
var AppSidebarNav2 = function (_Component) {
|
|
72
|
-
|
|
68
|
+
var AppSidebarNav2 = /*#__PURE__*/function (_Component) {
|
|
69
|
+
_inheritsLoose(AppSidebarNav2, _Component);
|
|
73
70
|
|
|
74
71
|
function AppSidebarNav2(props) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
|
72
|
+
var _this;
|
|
78
73
|
|
|
79
|
-
_this
|
|
74
|
+
_this = _Component.call(this, props) || this;
|
|
80
75
|
|
|
76
|
+
_defineProperty(_assertThisInitialized(_this), "_scrollBarRef", null);
|
|
81
77
|
|
|
82
|
-
_this.handleClick = _this.handleClick.bind(_this);
|
|
83
|
-
_this.activeRoute = _this.activeRoute.bind(_this);
|
|
84
|
-
_this.hideMobile = _this.hideMobile.bind(_this);
|
|
85
|
-
|
|
78
|
+
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
|
|
79
|
+
_this.activeRoute = _this.activeRoute.bind(_assertThisInitialized(_this));
|
|
80
|
+
_this.hideMobile = _this.hideMobile.bind(_assertThisInitialized(_this));
|
|
86
81
|
_this.changes = null;
|
|
87
|
-
_this.state = {
|
|
82
|
+
_this.state = {
|
|
83
|
+
sidebarMinimized: false
|
|
84
|
+
};
|
|
88
85
|
return _this;
|
|
89
86
|
}
|
|
90
87
|
|
|
91
|
-
AppSidebarNav2.prototype
|
|
88
|
+
var _proto = AppSidebarNav2.prototype;
|
|
89
|
+
|
|
90
|
+
_proto.handleClick = function handleClick(e, item) {
|
|
92
91
|
if (item.attributes && typeof item.attributes.onClick === 'function' && !this.isActiveRoute(item.url, this.props)) {
|
|
93
92
|
item.attributes.onClick(e, item);
|
|
94
93
|
} else {
|
|
95
94
|
e.preventDefault();
|
|
96
95
|
}
|
|
96
|
+
|
|
97
97
|
e.currentTarget.parentElement.classList.toggle('open');
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
_proto.isActiveRoute = function isActiveRoute(routeName, props) {
|
|
101
101
|
return props.location.pathname.indexOf(routeName) > -1;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
_proto.activeRoute = function activeRoute(routeName, props) {
|
|
105
105
|
return this.isActiveRoute(routeName, props) ? 'nav-item nav-dropdown open' : 'nav-item nav-dropdown';
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
_proto.hideMobile = function hideMobile() {
|
|
109
109
|
if (document.body.classList.contains('sidebar-show')) {
|
|
110
110
|
document.body.classList.toggle('sidebar-show');
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
_proto.getAttribs = function getAttribs(attributes) {
|
|
115
115
|
return _extends({}, attributes);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// nav list
|
|
119
|
-
|
|
116
|
+
} // nav list
|
|
117
|
+
;
|
|
120
118
|
|
|
121
|
-
|
|
119
|
+
_proto.navList = function navList(items) {
|
|
122
120
|
var _this2 = this;
|
|
123
121
|
|
|
124
122
|
return items.map(function (item, index) {
|
|
125
123
|
return _this2.navType(item, index);
|
|
126
124
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// nav type
|
|
125
|
+
} // nav type
|
|
126
|
+
;
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
AppSidebarNav2.prototype.navType = function navType(item, idx) {
|
|
128
|
+
_proto.navType = function navType(item, idx) {
|
|
133
129
|
return item.title ? this.navTitle(item, idx) : item.divider ? this.navDivider(item, idx) : item.label ? this.navLabel(item, idx) : item.children ? this.navDropdown(item, idx) : this.navItem(item, idx);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
AppSidebarNav2.prototype.navDivider = function navDivider(divider, key) {
|
|
160
|
-
var classes = (0, _classnames2.default)('divider', divider.class, divider.className);
|
|
161
|
-
return _react2.default.createElement('li', { key: key, className: classes });
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// nav label with nav link
|
|
165
|
-
|
|
130
|
+
} // nav list section title
|
|
131
|
+
;
|
|
132
|
+
|
|
133
|
+
_proto.navTitle = function navTitle(title, key) {
|
|
134
|
+
var classes = (0, _classnames["default"])('nav-title', title["class"], title.className);
|
|
135
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
136
|
+
key: key,
|
|
137
|
+
className: classes
|
|
138
|
+
}, this.navWrapper(title), " ");
|
|
139
|
+
} // simple wrapper for nav-title item
|
|
140
|
+
;
|
|
141
|
+
|
|
142
|
+
_proto.navWrapper = function navWrapper(item) {
|
|
143
|
+
return item.wrapper && item.wrapper.element ? _react["default"].createElement(item.wrapper.element, item.wrapper.attributes, item.name) : item.name;
|
|
144
|
+
} // nav list divider
|
|
145
|
+
;
|
|
146
|
+
|
|
147
|
+
_proto.navDivider = function navDivider(divider, key) {
|
|
148
|
+
var classes = (0, _classnames["default"])('divider', divider["class"], divider.className);
|
|
149
|
+
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
150
|
+
key: key,
|
|
151
|
+
className: classes
|
|
152
|
+
});
|
|
153
|
+
} // nav label with nav link
|
|
154
|
+
;
|
|
166
155
|
|
|
167
|
-
|
|
156
|
+
_proto.navLabel = function navLabel(item, key) {
|
|
168
157
|
var classes = {
|
|
169
|
-
item: (0,
|
|
170
|
-
link: (0,
|
|
171
|
-
icon: (0,
|
|
158
|
+
item: (0, _classnames["default"])('hidden-cn', item["class"]),
|
|
159
|
+
link: (0, _classnames["default"])('nav-label', item["class"] ? item["class"] : ''),
|
|
160
|
+
icon: (0, _classnames["default"])('nav-icon', !item.icon ? 'fa fa-circle' : item.icon, item.label.variant ? "text-" + item.label.variant : '', item.label["class"] ? item.label["class"] : '')
|
|
172
161
|
};
|
|
173
162
|
return this.navLink(item, key, classes);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// nav dropdown
|
|
163
|
+
} // nav dropdown
|
|
164
|
+
;
|
|
177
165
|
|
|
178
|
-
|
|
179
|
-
AppSidebarNav2.prototype.navDropdown = function navDropdown(item, key) {
|
|
166
|
+
_proto.navDropdown = function navDropdown(item, key) {
|
|
180
167
|
var _this3 = this;
|
|
181
168
|
|
|
182
169
|
var itemIcon = this.navIcon(item);
|
|
183
170
|
var attributes = this.getAttribs(item.attributes);
|
|
184
|
-
var classes = (0,
|
|
185
|
-
delete attributes
|
|
171
|
+
var classes = (0, _classnames["default"])('nav-link', 'nav-dropdown-toggle', item["class"], attributes["class"], attributes.className);
|
|
172
|
+
delete attributes["class"];
|
|
186
173
|
delete attributes.className;
|
|
187
174
|
var itemAttr = this.getAttribs(item.itemAttr);
|
|
188
|
-
var liClasses = (0,
|
|
189
|
-
delete itemAttr
|
|
175
|
+
var liClasses = (0, _classnames["default"])('nav-item', 'nav-dropdown', itemAttr["class"], itemAttr.className);
|
|
176
|
+
delete itemAttr["class"];
|
|
190
177
|
delete itemAttr.className;
|
|
191
178
|
var NavLink = this.props.router.NavLink || _reactstrap.NavLink;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.navList(item.children)
|
|
213
|
-
)
|
|
214
|
-
);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
// nav item with nav link
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
AppSidebarNav2.prototype.navItem = function navItem(item, key) {
|
|
179
|
+
return /*#__PURE__*/_react["default"].createElement("li", _extends({
|
|
180
|
+
key: key,
|
|
181
|
+
className: (0, _classnames["default"])(liClasses, {
|
|
182
|
+
'open': this.isActiveRoute(item.url, this.props)
|
|
183
|
+
})
|
|
184
|
+
}, itemAttr), /*#__PURE__*/_react["default"].createElement(NavLink, _extends({
|
|
185
|
+
activeClassName: "open",
|
|
186
|
+
className: classes,
|
|
187
|
+
to: item.url || ''
|
|
188
|
+
}, attributes, {
|
|
189
|
+
onClick: function onClick(e) {
|
|
190
|
+
return _this3.handleClick(e, item);
|
|
191
|
+
}
|
|
192
|
+
}), itemIcon, item.name, this.navBadge(item.badge)), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
193
|
+
className: "nav-dropdown-items"
|
|
194
|
+
}, this.navList(item.children)));
|
|
195
|
+
} // nav item with nav link
|
|
196
|
+
;
|
|
197
|
+
|
|
198
|
+
_proto.navItem = function navItem(item, key) {
|
|
221
199
|
var classes = {
|
|
222
|
-
item: (0,
|
|
223
|
-
link: (0,
|
|
224
|
-
icon: (0,
|
|
200
|
+
item: (0, _classnames["default"])(item["class"]),
|
|
201
|
+
link: (0, _classnames["default"])('nav-link', item.variant ? "nav-link-" + item.variant : ''),
|
|
202
|
+
icon: (0, _classnames["default"])('nav-icon', item.icon)
|
|
225
203
|
};
|
|
226
204
|
return this.navLink(item, key, classes);
|
|
227
205
|
};
|
|
228
206
|
|
|
229
|
-
|
|
207
|
+
_proto.navIcon = function navIcon(item) {
|
|
230
208
|
var icon = item.icon;
|
|
231
|
-
var iconObject =
|
|
209
|
+
var iconObject = typeof icon === 'object' && icon !== null ? _extends({
|
|
210
|
+
iconClass: icon["class"],
|
|
211
|
+
iconClassName: icon.className
|
|
212
|
+
}, icon) : {
|
|
213
|
+
iconClass: icon
|
|
214
|
+
};
|
|
232
215
|
var iconClass = iconObject.iconClass,
|
|
233
216
|
iconClassName = iconObject.iconClassName,
|
|
234
217
|
innerText = iconObject.innerText,
|
|
@@ -236,99 +219,93 @@ var AppSidebarNav2 = function (_Component) {
|
|
|
236
219
|
attributes = iconObject.attributes;
|
|
237
220
|
|
|
238
221
|
var iconAttr = _extends({}, attributes);
|
|
239
|
-
|
|
222
|
+
|
|
223
|
+
delete iconAttr["class"];
|
|
240
224
|
delete iconAttr.className;
|
|
241
225
|
delete iconAttr.img;
|
|
242
226
|
var iconImg = img && img.src ? img : null;
|
|
243
227
|
var iconInner = innerText || null;
|
|
244
|
-
var classIcon = (0,
|
|
245
|
-
var iconComponent = iconImg ?
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
228
|
+
var classIcon = (0, _classnames["default"])('nav-icon', iconClass, iconClassName);
|
|
229
|
+
var iconComponent = iconImg ? /*#__PURE__*/_react["default"].createElement("img", _extends({}, iconAttr, {
|
|
230
|
+
className: classIcon,
|
|
231
|
+
src: iconImg.src
|
|
232
|
+
})) : /*#__PURE__*/_react["default"].createElement("i", _extends({}, iconAttr, {
|
|
233
|
+
className: classIcon
|
|
234
|
+
}), iconInner);
|
|
250
235
|
return iconComponent;
|
|
251
|
-
}
|
|
236
|
+
} // nav link
|
|
237
|
+
;
|
|
252
238
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
AppSidebarNav2.prototype.navLink = function navLink(item, key, classes) {
|
|
239
|
+
_proto.navLink = function navLink(item, key, classes) {
|
|
257
240
|
var _this4 = this;
|
|
258
241
|
|
|
259
|
-
var ref =
|
|
242
|
+
var ref = _react["default"].createRef();
|
|
243
|
+
|
|
260
244
|
var url = item.url || '';
|
|
261
245
|
var itemIcon = this.navIcon(item);
|
|
262
246
|
var itemBadge = this.navBadge(item.badge);
|
|
263
247
|
var attributes = this.getAttribs(item.attributes);
|
|
264
|
-
classes.link = (0,
|
|
265
|
-
delete attributes
|
|
248
|
+
classes.link = (0, _classnames["default"])(classes.link, attributes["class"], attributes.className);
|
|
249
|
+
delete attributes["class"];
|
|
266
250
|
delete attributes.className;
|
|
267
251
|
var itemAttr = this.getAttribs(item.itemAttr);
|
|
268
|
-
classes.item = (0,
|
|
269
|
-
delete itemAttr
|
|
252
|
+
classes.item = (0, _classnames["default"])(classes.item, itemAttr["class"], itemAttr.className);
|
|
253
|
+
delete itemAttr["class"];
|
|
270
254
|
delete itemAttr.className;
|
|
271
255
|
var NavLink = this.props.router.NavLink || _reactstrap.NavLink;
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
)
|
|
296
|
-
);
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// badge addon to NavItem
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
AppSidebarNav2.prototype.navBadge = function navBadge(badge) {
|
|
256
|
+
return /*#__PURE__*/_react["default"].createElement(_reactstrap.NavItem, _extends({
|
|
257
|
+
key: key,
|
|
258
|
+
className: classes.item
|
|
259
|
+
}, itemAttr), attributes.disabled ? /*#__PURE__*/_react["default"].createElement(_reactstrap.NavLink, _extends({
|
|
260
|
+
href: '',
|
|
261
|
+
className: classes.link
|
|
262
|
+
}, attributes), itemIcon, item.name, itemBadge) : this.isExternal(url, this.props) || NavLink === _reactstrap.NavLink ? /*#__PURE__*/_react["default"].createElement(_reactstrap.NavLink, _extends({
|
|
263
|
+
href: url,
|
|
264
|
+
className: classes.link,
|
|
265
|
+
active: true
|
|
266
|
+
}, attributes), itemIcon, item.name, itemBadge) : /*#__PURE__*/_react["default"].createElement(NavLink, _extends({
|
|
267
|
+
to: url,
|
|
268
|
+
className: classes.link,
|
|
269
|
+
activeClassName: "active",
|
|
270
|
+
onClick: function onClick() {
|
|
271
|
+
return _this4.hideMobile(ref);
|
|
272
|
+
},
|
|
273
|
+
ref: ref
|
|
274
|
+
}, attributes), itemIcon, item.name, itemBadge));
|
|
275
|
+
} // badge addon to NavItem
|
|
276
|
+
;
|
|
277
|
+
|
|
278
|
+
_proto.navBadge = function navBadge(badge) {
|
|
303
279
|
if (badge) {
|
|
304
|
-
var classes = (0,
|
|
305
|
-
return
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
);
|
|
280
|
+
var classes = (0, _classnames["default"])(badge["class"], badge.className);
|
|
281
|
+
return /*#__PURE__*/_react["default"].createElement(_reactstrap.Badge, {
|
|
282
|
+
className: classes,
|
|
283
|
+
color: badge.variant
|
|
284
|
+
}, badge.text);
|
|
310
285
|
}
|
|
286
|
+
|
|
311
287
|
return null;
|
|
312
288
|
};
|
|
313
289
|
|
|
314
|
-
|
|
315
|
-
var linkType = typeof url
|
|
316
|
-
var link = linkType === 'string' ? url : linkType === 'object' && url.pathname ? url.pathname : linkType === 'function' && typeof url(props.location) === 'string' ? url(props.location) : linkType === 'function' &&
|
|
290
|
+
_proto.isExternal = function isExternal(url, props) {
|
|
291
|
+
var linkType = typeof url;
|
|
292
|
+
var link = linkType === 'string' ? url : linkType === 'object' && url.pathname ? url.pathname : linkType === 'function' && typeof url(props.location) === 'string' ? url(props.location) : linkType === 'function' && typeof url(props.location) === 'object' ? url(props.location).pathname : '';
|
|
317
293
|
return link.substring(0, 4) === 'http';
|
|
318
294
|
};
|
|
319
295
|
|
|
320
|
-
|
|
296
|
+
_proto.observeDomMutations = function observeDomMutations() {
|
|
321
297
|
var _this5 = this;
|
|
322
298
|
|
|
323
299
|
if (window.MutationObserver) {
|
|
324
|
-
|
|
325
300
|
// eslint-disable-next-line
|
|
326
301
|
this.changes = new MutationObserver(function (mutations) {
|
|
327
|
-
|
|
328
302
|
var isSidebarMinimized = document.body.classList.contains('sidebar-minimized') || false;
|
|
329
|
-
_this5.setState({ sidebarMinimized: isSidebarMinimized });
|
|
330
303
|
|
|
331
|
-
|
|
304
|
+
_this5.setState({
|
|
305
|
+
sidebarMinimized: isSidebarMinimized
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
_layout["default"].sidebarPSToggle(!isSidebarMinimized);
|
|
332
309
|
});
|
|
333
310
|
var element = document.body;
|
|
334
311
|
this.changes.observe(element, {
|
|
@@ -336,18 +313,19 @@ var AppSidebarNav2 = function (_Component) {
|
|
|
336
313
|
attributeFilter: ['class']
|
|
337
314
|
});
|
|
338
315
|
}
|
|
316
|
+
|
|
339
317
|
window.addEventListener('resize', this.onResize);
|
|
340
318
|
};
|
|
341
319
|
|
|
342
|
-
|
|
343
|
-
|
|
320
|
+
_proto.onResize = function onResize() {
|
|
321
|
+
_layout["default"].sidebarPSToggle(true);
|
|
344
322
|
};
|
|
345
323
|
|
|
346
|
-
|
|
324
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
347
325
|
this.observeDomMutations();
|
|
348
326
|
};
|
|
349
327
|
|
|
350
|
-
|
|
328
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
351
329
|
try {
|
|
352
330
|
this.changes.disconnect();
|
|
353
331
|
window.removeEventListener('resize', this.onResize);
|
|
@@ -357,36 +335,33 @@ var AppSidebarNav2 = function (_Component) {
|
|
|
357
335
|
}
|
|
358
336
|
};
|
|
359
337
|
|
|
360
|
-
|
|
338
|
+
_proto.render = function render() {
|
|
361
339
|
var _this6 = this;
|
|
362
340
|
|
|
363
|
-
var
|
|
364
|
-
className =
|
|
365
|
-
children =
|
|
366
|
-
navConfig =
|
|
367
|
-
attributes =
|
|
341
|
+
var _this$props = this.props,
|
|
342
|
+
className = _this$props.className,
|
|
343
|
+
children = _this$props.children,
|
|
344
|
+
navConfig = _this$props.navConfig,
|
|
345
|
+
attributes = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "navConfig"]);
|
|
368
346
|
|
|
369
347
|
delete attributes.isOpen;
|
|
370
348
|
delete attributes.staticContext;
|
|
371
349
|
delete attributes.Tag;
|
|
372
350
|
delete attributes.router;
|
|
373
|
-
|
|
374
|
-
var
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
children || this.navList(navConfig.items)
|
|
388
|
-
)
|
|
389
|
-
);
|
|
351
|
+
var navClasses = (0, _classnames["default"])(className, 'sidebar-nav');
|
|
352
|
+
var options = Object.assign({}, {
|
|
353
|
+
suppressScrollX: true,
|
|
354
|
+
suppressScrollY: this.state.sidebarMinimized
|
|
355
|
+
}); // sidebar-nav root
|
|
356
|
+
|
|
357
|
+
return /*#__PURE__*/_react["default"].createElement(_reactPerfectScrollbar["default"], _extends({
|
|
358
|
+
className: navClasses
|
|
359
|
+
}, attributes, {
|
|
360
|
+
options: options,
|
|
361
|
+
ref: function ref(_ref) {
|
|
362
|
+
_this6._scrollBarRef = _ref;
|
|
363
|
+
}
|
|
364
|
+
}), /*#__PURE__*/_react["default"].createElement(_reactstrap.Nav, null, children || this.navList(navConfig.items)));
|
|
390
365
|
};
|
|
391
366
|
|
|
392
367
|
return AppSidebarNav2;
|
|
@@ -394,6 +369,6 @@ var AppSidebarNav2 = function (_Component) {
|
|
|
394
369
|
|
|
395
370
|
AppSidebarNav2.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
396
371
|
AppSidebarNav2.defaultProps = defaultProps;
|
|
397
|
-
|
|
398
|
-
exports
|
|
399
|
-
module.exports = exports
|
|
372
|
+
var _default = AppSidebarNav2;
|
|
373
|
+
exports["default"] = _default;
|
|
374
|
+
module.exports = exports.default;
|