@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.
Files changed (58) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/css/scrollbar.css +18 -0
  3. package/es/Aside.js +29 -37
  4. package/es/AsideToggler.js +36 -44
  5. package/es/Breadcrumb.js +51 -58
  6. package/es/Breadcrumb2.js +52 -60
  7. package/es/Footer.js +24 -32
  8. package/es/Header.js +23 -35
  9. package/es/HeaderDropdown.js +23 -27
  10. package/es/NavbarBrand.js +32 -39
  11. package/es/Shared/classes.js +0 -3
  12. package/es/Shared/element-closest.js +2 -0
  13. package/es/Shared/index.js +0 -1
  14. package/es/Shared/layout/layout.js +75 -16
  15. package/es/Shared/toggle-classes.js +2 -0
  16. package/es/Sidebar.js +43 -53
  17. package/es/SidebarFooter.js +19 -29
  18. package/es/SidebarForm.js +19 -29
  19. package/es/SidebarHeader.js +19 -29
  20. package/es/SidebarMinimizer.js +30 -35
  21. package/es/SidebarNav.js +128 -162
  22. package/es/SidebarNav2.js +249 -174
  23. package/es/SidebarToggler.js +35 -36
  24. package/es/Switch.js +59 -62
  25. package/lib/Aside.js +51 -60
  26. package/lib/AsideToggler.js +58 -67
  27. package/lib/Breadcrumb.js +71 -77
  28. package/lib/Breadcrumb2.js +72 -79
  29. package/lib/Footer.js +40 -47
  30. package/lib/Header.js +39 -50
  31. package/lib/HeaderDropdown.js +36 -37
  32. package/lib/NavbarBrand.js +50 -56
  33. package/lib/Shared/classes.js +8 -6
  34. package/lib/Shared/element-closest.js +3 -1
  35. package/lib/Shared/index.js +2 -3
  36. package/lib/Shared/layout/layout.js +82 -19
  37. package/lib/Shared/toggle-classes.js +6 -2
  38. package/lib/Sidebar.js +69 -81
  39. package/lib/SidebarFooter.js +33 -42
  40. package/lib/SidebarForm.js +33 -42
  41. package/lib/SidebarHeader.js +33 -42
  42. package/lib/SidebarMinimizer.js +51 -55
  43. package/lib/SidebarNav.js +154 -187
  44. package/lib/SidebarNav2.js +275 -198
  45. package/lib/SidebarToggler.js +56 -58
  46. package/lib/Switch.js +90 -92
  47. package/lib/index.js +36 -55
  48. package/package.json +21 -20
  49. package/umd/main.d0f057e5.css +5 -0
  50. package/umd/main.d0f057e5.css.map +1 -0
  51. package/umd/react.js +6069 -0
  52. package/umd/react.min.js +38 -0
  53. package/umd/react.min.js.map +1 -0
  54. package/umd/@coreui/react.js +0 -11849
  55. package/umd/@coreui/react.min.js +0 -77
  56. package/umd/@coreui/react.min.js.map +0 -1
  57. package/umd/main.a25994ba.css +0 -129
  58. package/umd/main.a25994ba.css.map +0 -1
package/es/SidebarNav2.js CHANGED
@@ -1,14 +1,12 @@
1
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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
- var _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; };
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 _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; }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
8
8
 
9
- 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; }
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
- var propTypes = {
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: { variant: 'info', text: 'NEW' }
37
+ badge: {
38
+ variant: 'info',
39
+ text: 'NEW'
40
+ }
40
41
  }]
41
42
  },
42
43
  isOpen: false,
43
- router: { RsNavLink: RsNavLink }
44
+ router: {
45
+ RsNavLink: RsNavLink
46
+ }
44
47
  };
45
48
 
46
- var AppSidebarNav2 = function (_Component) {
47
- _inherits(AppSidebarNav2, _Component);
49
+ var AppSidebarNav2 = /*#__PURE__*/function (_Component) {
50
+ _inheritsLoose(AppSidebarNav2, _Component);
48
51
 
49
52
  function AppSidebarNav2(props) {
50
- _classCallCheck(this, AppSidebarNav2);
53
+ var _this;
54
+
55
+ _this = _Component.call(this, props) || this;
51
56
 
52
- var _this = _possibleConstructorReturn(this, _Component.call(this, props));
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.handleClick = function handleClick(e) {
61
- e.preventDefault();
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
- AppSidebarNav2.prototype.activeRoute = function activeRoute(routeName, props) {
66
- return props.location.pathname.indexOf(routeName) > -1 ? 'nav-item nav-dropdown open' : 'nav-item nav-dropdown';
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
- AppSidebarNav2.prototype.hideMobile = function hideMobile() {
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
- AppSidebarNav2.prototype.getAttribs = function getAttribs(attributes) {
76
- return JSON.parse(JSON.stringify(attributes || {}));
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
- // nav type
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
- // nav list section title
98
-
99
-
100
- AppSidebarNav2.prototype.navTitle = function navTitle(title, key) {
101
- var classes = classNames('nav-title', title.class, title.className);
102
- return React.createElement(
103
- 'li',
104
- { key: key, className: classes },
105
- this.navWrapper(title),
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
- // nav list divider
118
-
119
-
120
- AppSidebarNav2.prototype.navDivider = function navDivider(divider, key) {
121
- var classes = classNames('divider', divider.class, divider.className);
122
- return React.createElement('li', { key: key, className: classes });
123
- };
124
-
125
- // nav label with nav link
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
- AppSidebarNav2.prototype.navLabel = function navLabel(item, key) {
137
+ _proto.navLabel = function navLabel(item, key) {
129
138
  var classes = {
130
- item: classNames('hidden-cn', item.class),
131
- link: classNames('nav-label', item.class ? item.class : ''),
132
- icon: classNames('nav-icon', !item.icon ? 'fa fa-circle' : item.icon, item.label.variant ? 'text-' + item.label.variant : '', item.label.class ? item.label.class : '')
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
- AppSidebarNav2.prototype.navDropdown = function navDropdown(item, key) {
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.class, attributes.class, attributes.className);
144
- delete attributes.class;
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(this.activeRoute(item.url, this.props), itemAttr.class, itemAttr.className);
148
- delete itemAttr.class;
156
+ var liClasses = classNames('nav-item', 'nav-dropdown', itemAttr["class"], itemAttr.className);
157
+ delete itemAttr["class"];
149
158
  delete itemAttr.className;
150
- return React.createElement(
151
- 'li',
152
- _extends({ key: key, className: liClasses }, itemAttr),
153
- React.createElement(
154
- 'a',
155
- _extends({ className: classes, href: '#', onClick: this.handleClick }, attributes),
156
- React.createElement('i', { className: classIcon }),
157
- item.name,
158
- this.navBadge(item.badge)
159
- ),
160
- React.createElement(
161
- 'ul',
162
- { className: 'nav-dropdown-items' },
163
- this.navList(item.children)
164
- )
165
- );
166
- };
167
-
168
- // nav item with nav link
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.class),
174
- link: classNames('nav-link', item.variant ? '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
- // nav link
181
-
182
-
183
- AppSidebarNav2.prototype.navLink = function navLink(item, key, classes) {
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 = React.createElement('i', { className: classes.icon });
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.class, attributes.className);
189
- delete attributes.class;
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.class, itemAttr.className);
193
- delete itemAttr.class;
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
- NavItem,
198
- _extends({ key: key, className: classes.item }, itemAttr),
199
- attributes.disabled ? React.createElement(
200
- RsNavLink,
201
- _extends({ href: '', className: classes.link }, attributes),
202
- itemIcon,
203
- item.name,
204
- itemBadge
205
- ) : this.isExternal(url, this.props) || NavLink === RsNavLink ? React.createElement(
206
- RsNavLink,
207
- _extends({ href: url, className: classes.link, active: true }, attributes),
208
- itemIcon,
209
- item.name,
210
- itemBadge
211
- ) : React.createElement(
212
- NavLink,
213
- _extends({ to: url, className: classes.link, activeClassName: 'active', onClick: this.hideMobile }, attributes),
214
- itemIcon,
215
- item.name,
216
- itemBadge
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.class, badge.className);
227
- return React.createElement(
228
- Badge,
229
- { className: classes, color: badge.variant },
230
- badge.text
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
- AppSidebarNav2.prototype.isExternal = function isExternal(url, props) {
237
- var linkType = typeof url === 'undefined' ? 'undefined' : _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' && _typeof(url(props.location)) === 'object' ? url(props.location).pathname : '';
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
- AppSidebarNav2.prototype.render = function render() {
243
- var _props = this.props,
244
- className = _props.className,
245
- children = _props.children,
246
- navConfig = _props.navConfig,
247
- attributes = _objectWithoutProperties(_props, ['className', 'children', 'navConfig']);
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
- // ToDo: find better rtl fix
257
- var isRtl = getComputedStyle(document.documentElement).direction === 'rtl';
258
-
259
- // sidebar-nav root
260
- return React.createElement(
261
- PerfectScrollbar,
262
- _extends({ className: navClasses }, attributes, { options: { suppressScrollX: !isRtl } }),
263
- React.createElement(
264
- Nav,
265
- null,
266
- children || this.navList(navConfig.items)
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;
@@ -1,28 +1,24 @@
1
- var _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; };
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 _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; }
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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 _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; }
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
- _inherits(AppSidebarToggler, _Component);
29
+ var AppSidebarToggler = /*#__PURE__*/function (_Component) {
30
+ _inheritsLoose(AppSidebarToggler, _Component);
35
31
 
36
32
  function AppSidebarToggler(props) {
37
- _classCallCheck(this, AppSidebarToggler);
38
-
39
- var _this = _possibleConstructorReturn(this, _Component.call(this, props));
33
+ var _this;
40
34
 
41
- _this.sidebarToggle = _this.sidebarToggle.bind(_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.sidebarToggle = function sidebarToggle(e) {
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
- AppSidebarToggler.prototype.toggle = function toggle(force) {
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 = 'sidebar-' + display + '-show';
54
+ cssClass = "sidebar-" + display + "-show";
58
55
  }
56
+
59
57
  toggleClasses(cssClass, sidebarCssClasses, force);
60
58
  };
61
59
 
62
- AppSidebarToggler.prototype.render = function render() {
60
+ _proto.render = function render() {
63
61
  var _this2 = this;
64
62
 
65
- var _props = this.props,
66
- className = _props.className,
67
- children = _props.children,
68
- Tag = _props.tag,
69
- attributes = _objectWithoutProperties(_props, ['className', 'children', 'tag']);
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
- return React.createElement(
77
- Tag,
78
- _extends({ type: 'button', className: classes }, attributes, { onClick: function onClick(event) {
79
- return _this2.sidebarToggle(event);
80
- }, 'data-sidebar-toggler': true }),
81
- children || React.createElement('span', { className: 'navbar-toggler-icon' })
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;