@coreui/react 2.5.4 → 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 +32 -0
- package/css/scrollbar.css +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 +75 -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 +249 -174
- 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 +82 -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 +275 -198
- package/lib/SidebarToggler.js +56 -58
- package/lib/Switch.js +90 -92
- package/lib/index.js +36 -55
- package/package.json +21 -20
- package/umd/main.d0f057e5.css +5 -0
- package/umd/main.d0f057e5.css.map +1 -0
- package/umd/react.js +6069 -0
- package/umd/react.min.js +38 -0
- package/umd/react.min.js.map +1 -0
- package/umd/@coreui/react.js +0 -11849
- package/umd/@coreui/react.min.js +0 -77
- package/umd/@coreui/react.min.js.map +0 -1
- package/umd/main.a25994ba.css +0 -129
- package/umd/main.a25994ba.css.map +0 -1
package/es/SidebarNav2.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
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; }
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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); }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
8
8
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
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; }
|
|
9
|
+
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; }
|
|
12
10
|
|
|
13
11
|
import React, { Component } from 'react';
|
|
14
12
|
import { Badge, Nav, NavItem, NavLink as RsNavLink } from 'reactstrap';
|
|
@@ -16,8 +14,9 @@ import classNames from 'classnames';
|
|
|
16
14
|
import PropTypes from 'prop-types';
|
|
17
15
|
import PerfectScrollbar from 'react-perfect-scrollbar';
|
|
18
16
|
import 'react-perfect-scrollbar/dist/css/styles.css';
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
import '../css/scrollbar.css';
|
|
18
|
+
import LayoutHelper from './Shared/layout/layout';
|
|
19
|
+
var propTypes = process.env.NODE_ENV !== "production" ? {
|
|
21
20
|
children: PropTypes.node,
|
|
22
21
|
className: PropTypes.string,
|
|
23
22
|
navConfig: PropTypes.any,
|
|
@@ -27,8 +26,7 @@ var propTypes = {
|
|
|
27
26
|
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
28
27
|
router: PropTypes.any,
|
|
29
28
|
props: PropTypes.any
|
|
30
|
-
};
|
|
31
|
-
|
|
29
|
+
} : {};
|
|
32
30
|
var defaultProps = {
|
|
33
31
|
tag: 'nav',
|
|
34
32
|
navConfig: {
|
|
@@ -36,236 +34,314 @@ var defaultProps = {
|
|
|
36
34
|
name: 'Dashboard',
|
|
37
35
|
url: '/dashboard',
|
|
38
36
|
icon: 'icon-speedometer',
|
|
39
|
-
badge: {
|
|
37
|
+
badge: {
|
|
38
|
+
variant: 'info',
|
|
39
|
+
text: 'NEW'
|
|
40
|
+
}
|
|
40
41
|
}]
|
|
41
42
|
},
|
|
42
43
|
isOpen: false,
|
|
43
|
-
router: {
|
|
44
|
+
router: {
|
|
45
|
+
RsNavLink: RsNavLink
|
|
46
|
+
}
|
|
44
47
|
};
|
|
45
48
|
|
|
46
|
-
var AppSidebarNav2 = function (_Component) {
|
|
47
|
-
|
|
49
|
+
var AppSidebarNav2 = /*#__PURE__*/function (_Component) {
|
|
50
|
+
_inheritsLoose(AppSidebarNav2, _Component);
|
|
48
51
|
|
|
49
52
|
function AppSidebarNav2(props) {
|
|
50
|
-
|
|
53
|
+
var _this;
|
|
54
|
+
|
|
55
|
+
_this = _Component.call(this, props) || this;
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "_scrollBarRef", null);
|
|
53
58
|
|
|
54
|
-
_this.handleClick = _this.handleClick.bind(_this);
|
|
55
|
-
_this.activeRoute = _this.activeRoute.bind(_this);
|
|
56
|
-
_this.hideMobile = _this.hideMobile.bind(_this);
|
|
59
|
+
_this.handleClick = _this.handleClick.bind(_assertThisInitialized(_this));
|
|
60
|
+
_this.activeRoute = _this.activeRoute.bind(_assertThisInitialized(_this));
|
|
61
|
+
_this.hideMobile = _this.hideMobile.bind(_assertThisInitialized(_this));
|
|
62
|
+
_this.changes = null;
|
|
63
|
+
_this.state = {
|
|
64
|
+
sidebarMinimized: false
|
|
65
|
+
};
|
|
57
66
|
return _this;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
|
-
AppSidebarNav2.prototype
|
|
61
|
-
|
|
69
|
+
var _proto = AppSidebarNav2.prototype;
|
|
70
|
+
|
|
71
|
+
_proto.handleClick = function handleClick(e, item) {
|
|
72
|
+
if (item.attributes && typeof item.attributes.onClick === 'function' && !this.isActiveRoute(item.url, this.props)) {
|
|
73
|
+
item.attributes.onClick(e, item);
|
|
74
|
+
} else {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
e.currentTarget.parentElement.classList.toggle('open');
|
|
63
79
|
};
|
|
64
80
|
|
|
65
|
-
|
|
66
|
-
return props.location.pathname.indexOf(routeName) > -1
|
|
81
|
+
_proto.isActiveRoute = function isActiveRoute(routeName, props) {
|
|
82
|
+
return props.location.pathname.indexOf(routeName) > -1;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
_proto.activeRoute = function activeRoute(routeName, props) {
|
|
86
|
+
return this.isActiveRoute(routeName, props) ? 'nav-item nav-dropdown open' : 'nav-item nav-dropdown';
|
|
67
87
|
};
|
|
68
88
|
|
|
69
|
-
|
|
89
|
+
_proto.hideMobile = function hideMobile() {
|
|
70
90
|
if (document.body.classList.contains('sidebar-show')) {
|
|
71
91
|
document.body.classList.toggle('sidebar-show');
|
|
72
92
|
}
|
|
73
93
|
};
|
|
74
94
|
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// nav list
|
|
95
|
+
_proto.getAttribs = function getAttribs(attributes) {
|
|
96
|
+
return _extends({}, attributes);
|
|
97
|
+
} // nav list
|
|
98
|
+
;
|
|
80
99
|
|
|
81
|
-
|
|
82
|
-
AppSidebarNav2.prototype.navList = function navList(items) {
|
|
100
|
+
_proto.navList = function navList(items) {
|
|
83
101
|
var _this2 = this;
|
|
84
102
|
|
|
85
103
|
return items.map(function (item, index) {
|
|
86
104
|
return _this2.navType(item, index);
|
|
87
105
|
});
|
|
88
|
-
}
|
|
106
|
+
} // nav type
|
|
107
|
+
;
|
|
89
108
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
AppSidebarNav2.prototype.navType = function navType(item, idx) {
|
|
109
|
+
_proto.navType = function navType(item, idx) {
|
|
94
110
|
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);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// simple wrapper for nav-title item
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
AppSidebarNav2.prototype.navWrapper = function navWrapper(item) {
|
|
111
|
+
} // nav list section title
|
|
112
|
+
;
|
|
113
|
+
|
|
114
|
+
_proto.navTitle = function navTitle(title, key) {
|
|
115
|
+
var classes = classNames('nav-title', title["class"], title.className);
|
|
116
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
117
|
+
key: key,
|
|
118
|
+
className: classes
|
|
119
|
+
}, this.navWrapper(title), " ");
|
|
120
|
+
} // simple wrapper for nav-title item
|
|
121
|
+
;
|
|
122
|
+
|
|
123
|
+
_proto.navWrapper = function navWrapper(item) {
|
|
114
124
|
return item.wrapper && item.wrapper.element ? React.createElement(item.wrapper.element, item.wrapper.attributes, item.name) : item.name;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
} // nav list divider
|
|
126
|
+
;
|
|
127
|
+
|
|
128
|
+
_proto.navDivider = function navDivider(divider, key) {
|
|
129
|
+
var classes = classNames('divider', divider["class"], divider.className);
|
|
130
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
131
|
+
key: key,
|
|
132
|
+
className: classes
|
|
133
|
+
});
|
|
134
|
+
} // nav label with nav link
|
|
135
|
+
;
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
_proto.navLabel = function navLabel(item, key) {
|
|
129
138
|
var classes = {
|
|
130
|
-
item: classNames('hidden-cn', item
|
|
131
|
-
link: classNames('nav-label', item
|
|
132
|
-
icon: classNames('nav-icon', !item.icon ? 'fa fa-circle' : item.icon, item.label.variant ?
|
|
139
|
+
item: classNames('hidden-cn', item["class"]),
|
|
140
|
+
link: classNames('nav-label', item["class"] ? item["class"] : ''),
|
|
141
|
+
icon: classNames('nav-icon', !item.icon ? 'fa fa-circle' : item.icon, item.label.variant ? "text-" + item.label.variant : '', item.label["class"] ? item.label["class"] : '')
|
|
133
142
|
};
|
|
134
143
|
return this.navLink(item, key, classes);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// nav dropdown
|
|
144
|
+
} // nav dropdown
|
|
145
|
+
;
|
|
138
146
|
|
|
147
|
+
_proto.navDropdown = function navDropdown(item, key) {
|
|
148
|
+
var _this3 = this;
|
|
139
149
|
|
|
140
|
-
|
|
141
|
-
var classIcon = classNames('nav-icon', item.icon);
|
|
150
|
+
var itemIcon = this.navIcon(item);
|
|
142
151
|
var attributes = this.getAttribs(item.attributes);
|
|
143
|
-
var classes = classNames('nav-link', 'nav-dropdown-toggle', item
|
|
144
|
-
delete attributes
|
|
152
|
+
var classes = classNames('nav-link', 'nav-dropdown-toggle', item["class"], attributes["class"], attributes.className);
|
|
153
|
+
delete attributes["class"];
|
|
145
154
|
delete attributes.className;
|
|
146
155
|
var itemAttr = this.getAttribs(item.itemAttr);
|
|
147
|
-
var liClasses = classNames(
|
|
148
|
-
delete itemAttr
|
|
156
|
+
var liClasses = classNames('nav-item', 'nav-dropdown', itemAttr["class"], itemAttr.className);
|
|
157
|
+
delete itemAttr["class"];
|
|
149
158
|
delete itemAttr.className;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
'
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
AppSidebarNav2.prototype.navItem = function navItem(item, key) {
|
|
159
|
+
var NavLink = this.props.router.NavLink || RsNavLink;
|
|
160
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
|
161
|
+
key: key,
|
|
162
|
+
className: classNames(liClasses, {
|
|
163
|
+
'open': this.isActiveRoute(item.url, this.props)
|
|
164
|
+
})
|
|
165
|
+
}, itemAttr), /*#__PURE__*/React.createElement(NavLink, _extends({
|
|
166
|
+
activeClassName: "open",
|
|
167
|
+
className: classes,
|
|
168
|
+
to: item.url || ''
|
|
169
|
+
}, attributes, {
|
|
170
|
+
onClick: function onClick(e) {
|
|
171
|
+
return _this3.handleClick(e, item);
|
|
172
|
+
}
|
|
173
|
+
}), itemIcon, item.name, this.navBadge(item.badge)), /*#__PURE__*/React.createElement("ul", {
|
|
174
|
+
className: "nav-dropdown-items"
|
|
175
|
+
}, this.navList(item.children)));
|
|
176
|
+
} // nav item with nav link
|
|
177
|
+
;
|
|
178
|
+
|
|
179
|
+
_proto.navItem = function navItem(item, key) {
|
|
172
180
|
var classes = {
|
|
173
|
-
item: classNames(item
|
|
174
|
-
link: classNames('nav-link', item.variant ?
|
|
181
|
+
item: classNames(item["class"]),
|
|
182
|
+
link: classNames('nav-link', item.variant ? "nav-link-" + item.variant : ''),
|
|
175
183
|
icon: classNames('nav-icon', item.icon)
|
|
176
184
|
};
|
|
177
185
|
return this.navLink(item, key, classes);
|
|
178
186
|
};
|
|
179
187
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
_proto.navIcon = function navIcon(item) {
|
|
189
|
+
var icon = item.icon;
|
|
190
|
+
var iconObject = typeof icon === 'object' && icon !== null ? _extends({
|
|
191
|
+
iconClass: icon["class"],
|
|
192
|
+
iconClassName: icon.className
|
|
193
|
+
}, icon) : {
|
|
194
|
+
iconClass: icon
|
|
195
|
+
};
|
|
196
|
+
var iconClass = iconObject.iconClass,
|
|
197
|
+
iconClassName = iconObject.iconClassName,
|
|
198
|
+
innerText = iconObject.innerText,
|
|
199
|
+
img = iconObject.img,
|
|
200
|
+
attributes = iconObject.attributes;
|
|
201
|
+
|
|
202
|
+
var iconAttr = _extends({}, attributes);
|
|
203
|
+
|
|
204
|
+
delete iconAttr["class"];
|
|
205
|
+
delete iconAttr.className;
|
|
206
|
+
delete iconAttr.img;
|
|
207
|
+
var iconImg = img && img.src ? img : null;
|
|
208
|
+
var iconInner = innerText || null;
|
|
209
|
+
var classIcon = classNames('nav-icon', iconClass, iconClassName);
|
|
210
|
+
var iconComponent = iconImg ? /*#__PURE__*/React.createElement("img", _extends({}, iconAttr, {
|
|
211
|
+
className: classIcon,
|
|
212
|
+
src: iconImg.src
|
|
213
|
+
})) : /*#__PURE__*/React.createElement("i", _extends({}, iconAttr, {
|
|
214
|
+
className: classIcon
|
|
215
|
+
}), iconInner);
|
|
216
|
+
return iconComponent;
|
|
217
|
+
} // nav link
|
|
218
|
+
;
|
|
219
|
+
|
|
220
|
+
_proto.navLink = function navLink(item, key, classes) {
|
|
221
|
+
var _this4 = this;
|
|
222
|
+
|
|
223
|
+
var ref = React.createRef();
|
|
184
224
|
var url = item.url || '';
|
|
185
|
-
var itemIcon =
|
|
225
|
+
var itemIcon = this.navIcon(item);
|
|
186
226
|
var itemBadge = this.navBadge(item.badge);
|
|
187
227
|
var attributes = this.getAttribs(item.attributes);
|
|
188
|
-
classes.link = classNames(classes.link, attributes
|
|
189
|
-
delete attributes
|
|
228
|
+
classes.link = classNames(classes.link, attributes["class"], attributes.className);
|
|
229
|
+
delete attributes["class"];
|
|
190
230
|
delete attributes.className;
|
|
191
231
|
var itemAttr = this.getAttribs(item.itemAttr);
|
|
192
|
-
classes.item = classNames(classes.item, itemAttr
|
|
193
|
-
delete itemAttr
|
|
232
|
+
classes.item = classNames(classes.item, itemAttr["class"], itemAttr.className);
|
|
233
|
+
delete itemAttr["class"];
|
|
194
234
|
delete itemAttr.className;
|
|
195
235
|
var NavLink = this.props.router.NavLink || RsNavLink;
|
|
196
|
-
return React.createElement(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// badge addon to NavItem
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
AppSidebarNav2.prototype.navBadge = function navBadge(badge) {
|
|
236
|
+
return /*#__PURE__*/React.createElement(NavItem, _extends({
|
|
237
|
+
key: key,
|
|
238
|
+
className: classes.item
|
|
239
|
+
}, itemAttr), attributes.disabled ? /*#__PURE__*/React.createElement(RsNavLink, _extends({
|
|
240
|
+
href: '',
|
|
241
|
+
className: classes.link
|
|
242
|
+
}, attributes), itemIcon, item.name, itemBadge) : this.isExternal(url, this.props) || NavLink === RsNavLink ? /*#__PURE__*/React.createElement(RsNavLink, _extends({
|
|
243
|
+
href: url,
|
|
244
|
+
className: classes.link,
|
|
245
|
+
active: true
|
|
246
|
+
}, attributes), itemIcon, item.name, itemBadge) : /*#__PURE__*/React.createElement(NavLink, _extends({
|
|
247
|
+
to: url,
|
|
248
|
+
className: classes.link,
|
|
249
|
+
activeClassName: "active",
|
|
250
|
+
onClick: function onClick() {
|
|
251
|
+
return _this4.hideMobile(ref);
|
|
252
|
+
},
|
|
253
|
+
ref: ref
|
|
254
|
+
}, attributes), itemIcon, item.name, itemBadge));
|
|
255
|
+
} // badge addon to NavItem
|
|
256
|
+
;
|
|
257
|
+
|
|
258
|
+
_proto.navBadge = function navBadge(badge) {
|
|
225
259
|
if (badge) {
|
|
226
|
-
var classes = classNames(badge
|
|
227
|
-
return React.createElement(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
);
|
|
260
|
+
var classes = classNames(badge["class"], badge.className);
|
|
261
|
+
return /*#__PURE__*/React.createElement(Badge, {
|
|
262
|
+
className: classes,
|
|
263
|
+
color: badge.variant
|
|
264
|
+
}, badge.text);
|
|
232
265
|
}
|
|
266
|
+
|
|
233
267
|
return null;
|
|
234
268
|
};
|
|
235
269
|
|
|
236
|
-
|
|
237
|
-
var linkType = typeof url
|
|
238
|
-
var link = linkType === 'string' ? url : linkType === 'object' && url.pathname ? url.pathname : linkType === 'function' && typeof url(props.location) === 'string' ? url(props.location) : linkType === 'function' &&
|
|
270
|
+
_proto.isExternal = function isExternal(url, props) {
|
|
271
|
+
var linkType = typeof url;
|
|
272
|
+
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 : '';
|
|
239
273
|
return link.substring(0, 4) === 'http';
|
|
240
274
|
};
|
|
241
275
|
|
|
242
|
-
|
|
243
|
-
var
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
276
|
+
_proto.observeDomMutations = function observeDomMutations() {
|
|
277
|
+
var _this5 = this;
|
|
278
|
+
|
|
279
|
+
if (window.MutationObserver) {
|
|
280
|
+
// eslint-disable-next-line
|
|
281
|
+
this.changes = new MutationObserver(function (mutations) {
|
|
282
|
+
var isSidebarMinimized = document.body.classList.contains('sidebar-minimized') || false;
|
|
283
|
+
|
|
284
|
+
_this5.setState({
|
|
285
|
+
sidebarMinimized: isSidebarMinimized
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
LayoutHelper.sidebarPSToggle(!isSidebarMinimized);
|
|
289
|
+
});
|
|
290
|
+
var element = document.body;
|
|
291
|
+
this.changes.observe(element, {
|
|
292
|
+
attributes: true,
|
|
293
|
+
attributeFilter: ['class']
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
window.addEventListener('resize', this.onResize);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
_proto.onResize = function onResize() {
|
|
301
|
+
LayoutHelper.sidebarPSToggle(true);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
305
|
+
this.observeDomMutations();
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
309
|
+
try {
|
|
310
|
+
this.changes.disconnect();
|
|
311
|
+
window.removeEventListener('resize', this.onResize);
|
|
312
|
+
} catch (ignore) {
|
|
313
|
+
// eslint-disable-next-line
|
|
314
|
+
console.warn('CoreUI SidebarNav failed to disconnect from MutationObserver', ignore);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
_proto.render = function render() {
|
|
319
|
+
var _this6 = this;
|
|
320
|
+
|
|
321
|
+
var _this$props = this.props,
|
|
322
|
+
className = _this$props.className,
|
|
323
|
+
children = _this$props.children,
|
|
324
|
+
navConfig = _this$props.navConfig,
|
|
325
|
+
attributes = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "navConfig"]);
|
|
248
326
|
|
|
249
327
|
delete attributes.isOpen;
|
|
250
328
|
delete attributes.staticContext;
|
|
251
329
|
delete attributes.Tag;
|
|
252
330
|
delete attributes.router;
|
|
253
|
-
|
|
254
331
|
var navClasses = classNames(className, 'sidebar-nav');
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return React.createElement(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
);
|
|
332
|
+
var options = Object.assign({}, {
|
|
333
|
+
suppressScrollX: true,
|
|
334
|
+
suppressScrollY: this.state.sidebarMinimized
|
|
335
|
+
}); // sidebar-nav root
|
|
336
|
+
|
|
337
|
+
return /*#__PURE__*/React.createElement(PerfectScrollbar, _extends({
|
|
338
|
+
className: navClasses
|
|
339
|
+
}, attributes, {
|
|
340
|
+
options: options,
|
|
341
|
+
ref: function ref(_ref) {
|
|
342
|
+
_this6._scrollBarRef = _ref;
|
|
343
|
+
}
|
|
344
|
+
}), /*#__PURE__*/React.createElement(Nav, null, children || this.navList(navConfig.items)));
|
|
269
345
|
};
|
|
270
346
|
|
|
271
347
|
return AppSidebarNav2;
|
|
@@ -273,5 +349,4 @@ var AppSidebarNav2 = function (_Component) {
|
|
|
273
349
|
|
|
274
350
|
AppSidebarNav2.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
275
351
|
AppSidebarNav2.defaultProps = defaultProps;
|
|
276
|
-
|
|
277
352
|
export default AppSidebarNav2;
|
package/es/SidebarToggler.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
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); }
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
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; }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
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; }
|
|
7
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
10
8
|
|
|
11
9
|
import React, { Component } from 'react';
|
|
12
10
|
import PropTypes from 'prop-types';
|
|
13
11
|
import classNames from 'classnames';
|
|
14
12
|
import { sidebarCssClasses, validBreakpoints, checkBreakpoint } from './Shared/index';
|
|
15
13
|
import toggleClasses from './Shared/toggle-classes';
|
|
16
|
-
|
|
17
|
-
var propTypes = {
|
|
14
|
+
var propTypes = process.env.NODE_ENV !== "production" ? {
|
|
18
15
|
children: PropTypes.node,
|
|
19
16
|
className: PropTypes.string,
|
|
20
17
|
display: PropTypes.any,
|
|
21
18
|
mobile: PropTypes.bool,
|
|
22
19
|
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
23
20
|
type: PropTypes.string
|
|
24
|
-
};
|
|
25
|
-
|
|
21
|
+
} : {};
|
|
26
22
|
var defaultProps = {
|
|
27
23
|
display: 'lg',
|
|
28
24
|
mobile: false,
|
|
@@ -30,56 +26,60 @@ var defaultProps = {
|
|
|
30
26
|
type: 'button'
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
var AppSidebarToggler = function (_Component) {
|
|
34
|
-
|
|
29
|
+
var AppSidebarToggler = /*#__PURE__*/function (_Component) {
|
|
30
|
+
_inheritsLoose(AppSidebarToggler, _Component);
|
|
35
31
|
|
|
36
32
|
function AppSidebarToggler(props) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
|
33
|
+
var _this;
|
|
40
34
|
|
|
41
|
-
_this
|
|
35
|
+
_this = _Component.call(this, props) || this;
|
|
36
|
+
_this.sidebarToggle = _this.sidebarToggle.bind(_assertThisInitialized(_this));
|
|
42
37
|
return _this;
|
|
43
38
|
}
|
|
44
39
|
|
|
45
|
-
AppSidebarToggler.prototype
|
|
40
|
+
var _proto = AppSidebarToggler.prototype;
|
|
41
|
+
|
|
42
|
+
_proto.sidebarToggle = function sidebarToggle(e) {
|
|
46
43
|
e.preventDefault();
|
|
47
44
|
this.toggle();
|
|
48
45
|
};
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
_proto.toggle = function toggle(force) {
|
|
51
48
|
var _ref = [this.props.display, this.props.mobile],
|
|
52
49
|
display = _ref[0],
|
|
53
50
|
mobile = _ref[1];
|
|
54
|
-
|
|
55
51
|
var cssClass = sidebarCssClasses[0];
|
|
52
|
+
|
|
56
53
|
if (!mobile && display && checkBreakpoint(display, validBreakpoints)) {
|
|
57
|
-
cssClass =
|
|
54
|
+
cssClass = "sidebar-" + display + "-show";
|
|
58
55
|
}
|
|
56
|
+
|
|
59
57
|
toggleClasses(cssClass, sidebarCssClasses, force);
|
|
60
58
|
};
|
|
61
59
|
|
|
62
|
-
|
|
60
|
+
_proto.render = function render() {
|
|
63
61
|
var _this2 = this;
|
|
64
62
|
|
|
65
|
-
var
|
|
66
|
-
className =
|
|
67
|
-
children =
|
|
68
|
-
Tag =
|
|
69
|
-
attributes =
|
|
63
|
+
var _this$props = this.props,
|
|
64
|
+
className = _this$props.className,
|
|
65
|
+
children = _this$props.children,
|
|
66
|
+
Tag = _this$props.tag,
|
|
67
|
+
attributes = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "tag"]);
|
|
70
68
|
|
|
71
69
|
delete attributes.mobile;
|
|
72
70
|
delete attributes.display;
|
|
73
|
-
|
|
74
71
|
var classes = classNames(className, 'navbar-toggler');
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
return /*#__PURE__*/React.createElement(Tag, _extends({
|
|
73
|
+
type: "button",
|
|
74
|
+
className: classes
|
|
75
|
+
}, attributes, {
|
|
76
|
+
onClick: function onClick(event) {
|
|
77
|
+
return _this2.sidebarToggle(event);
|
|
78
|
+
},
|
|
79
|
+
"data-sidebar-toggler": true
|
|
80
|
+
}), children || /*#__PURE__*/React.createElement("span", {
|
|
81
|
+
className: "navbar-toggler-icon"
|
|
82
|
+
}));
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
return AppSidebarToggler;
|
|
@@ -87,5 +87,4 @@ var AppSidebarToggler = function (_Component) {
|
|
|
87
87
|
|
|
88
88
|
AppSidebarToggler.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
|
|
89
89
|
AppSidebarToggler.defaultProps = defaultProps;
|
|
90
|
-
|
|
91
90
|
export default AppSidebarToggler;
|