@rio-cloud/rio-uikit 0.16.1-beta-4 → 0.16.1-beta-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/lib/components/applicationHeader/ApplicationHeader.js +6 -6
- package/lib/components/applicationHeader/NavItems.js +8 -8
- package/lib/components/applicationLayout/ApplicationLayout.js +5 -8
- package/lib/components/applicationLayout/ApplicationLayoutBody.js +1 -3
- package/lib/components/applicationLayout/SubNavigation.js +60 -0
- package/lib/components/assetTree/Tree.js +151 -35
- package/lib/components/assetTree/TreeSelectAll.js +1 -1
- package/lib/components/assetTree/TreeSummary.js +11 -6
- package/lib/components/assetTree/TypeCounter.js +47 -8
- package/lib/components/navigation/AppNavigationBar.js +64 -0
- package/lib/components/selects/BaseDropdownMenu.js +29 -23
- package/lib/components/selects/Select.js +11 -5
- package/lib/es/AppNavigationBar.d.ts +5 -0
- package/lib/es/AppNavigationBar.js +15 -0
- package/lib/es/DeviceUtils.d.ts +6 -0
- package/lib/es/SubNavigation.d.ts +5 -0
- package/lib/es/SubNavigation.js +15 -0
- package/lib/es/deviceUtils.js +36 -0
- package/lib/es/useResizeObserver.d.ts +4 -0
- package/lib/es/useResizeObserver.js +15 -0
- package/lib/hooks/useClickOutside.js +2 -1
- package/lib/hooks/useResizeObserver.js +54 -0
- package/lib/hooks/useWindowResize.js +8 -5
- package/lib/style/css/_exports/rio-website.less +76 -7
- package/lib/style/css/_exports/vw-uikit.less +1 -1
- package/lib/style/css/animations/_imports.less +1 -0
- package/lib/style/css/animations/pulsing.less +5 -0
- package/lib/style/css/components/ApplicationHeader.less +242 -245
- package/lib/style/css/components/ApplicationLayout.less +10 -6
- package/lib/style/css/components/AssetTree.less +0 -4
- package/lib/style/css/design/buttons.less +4 -1
- package/lib/style/css/design/rioglyph.less +1 -12
- package/lib/types.ts +23 -1
- package/lib/utils/deviceUtils.js +19 -2
- package/lib/version.json +1 -1
- package/package.json +4 -2
|
@@ -46,7 +46,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
46
46
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
47
|
|
|
48
48
|
var RESIZE_THROTTELING = 10;
|
|
49
|
-
var MOBILE_MAX_WIDTH = 580; //const COLLAPSED_DROPDOWN_WIDTH = 50;
|
|
49
|
+
var MOBILE_MAX_WIDTH = 580; // const COLLAPSED_DROPDOWN_WIDTH = 50;
|
|
50
50
|
|
|
51
51
|
var ApplicationHeader = /*#__PURE__*/function (_PureComponent) {
|
|
52
52
|
(0, _inherits2.default)(ApplicationHeader, _PureComponent);
|
|
@@ -71,10 +71,10 @@ var ApplicationHeader = /*#__PURE__*/function (_PureComponent) {
|
|
|
71
71
|
(0, _createClass2.default)(ApplicationHeader, [{
|
|
72
72
|
key: "isMobile",
|
|
73
73
|
value: function isMobile() {
|
|
74
|
-
//const node = this.navRef;
|
|
74
|
+
// const node = this.navRef;
|
|
75
75
|
// FIXME: collision check need to be done after second rendering of NavItems
|
|
76
76
|
|
|
77
|
-
/*let isColliding = false;
|
|
77
|
+
/* let isColliding = false;
|
|
78
78
|
// check for collision of NavItems and ActionBar
|
|
79
79
|
if (this.refNavItems && this.refActionBar) {
|
|
80
80
|
const navItemsNode = ReactDOM.findDOMNode(this.refNavItems);
|
|
@@ -92,14 +92,14 @@ var ApplicationHeader = /*#__PURE__*/function (_PureComponent) {
|
|
|
92
92
|
}
|
|
93
93
|
}*/
|
|
94
94
|
return (
|
|
95
|
-
/*isColliding || */
|
|
95
|
+
/* isColliding || */
|
|
96
96
|
this.getContainerWidth() < MOBILE_MAX_WIDTH && this.props.label
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
}, {
|
|
100
100
|
key: "getContainerWidth",
|
|
101
101
|
value: function getContainerWidth() {
|
|
102
|
-
//return this.navRef.clientWidth;
|
|
102
|
+
// return this.navRef.clientWidth;
|
|
103
103
|
return window.innerWidth;
|
|
104
104
|
}
|
|
105
105
|
}, {
|
|
@@ -152,7 +152,7 @@ var ApplicationHeader = /*#__PURE__*/function (_PureComponent) {
|
|
|
152
152
|
appMenuItems = _this$props.appMenuItems,
|
|
153
153
|
navItems = _this$props.navItems,
|
|
154
154
|
actionBarItems = _this$props.actionBarItems;
|
|
155
|
-
var classNames = (0, _classnames.default)('ApplicationHeader', '
|
|
155
|
+
var classNames = (0, _classnames.default)('ApplicationHeader', 'user-select-none', this.state.isMobile && 'mobile', className && className);
|
|
156
156
|
|
|
157
157
|
var renderNavItems = /*#__PURE__*/_react.default.createElement(_NavItems.default, {
|
|
158
158
|
key: "NavItems",
|
|
@@ -234,11 +234,11 @@ var NavItems = /*#__PURE__*/function (_Component) {
|
|
|
234
234
|
|
|
235
235
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
236
236
|
className: "CollapsedDropdown dropdown ".concat(collapsedDropdownClass),
|
|
237
|
-
key:
|
|
237
|
+
key: "collapsed-dropdown"
|
|
238
238
|
}, /*#__PURE__*/_react.default.createElement("a", {
|
|
239
239
|
id: "basic-nav-dropdown",
|
|
240
240
|
role: "button",
|
|
241
|
-
className: "dropdown-toggle",
|
|
241
|
+
className: "dropdown-toggle text-color-gray",
|
|
242
242
|
"aria-haspopup": "true",
|
|
243
243
|
"aria-expanded": "true",
|
|
244
244
|
onClick: this.handleCollapsedDropdown
|
|
@@ -246,16 +246,16 @@ var NavItems = /*#__PURE__*/function (_Component) {
|
|
|
246
246
|
className: "rioglyph rioglyph-option-horizontal",
|
|
247
247
|
"aria-hidden": "true"
|
|
248
248
|
})), /*#__PURE__*/_react.default.createElement("ul", {
|
|
249
|
-
className:
|
|
249
|
+
className: "dropdown-menu",
|
|
250
250
|
role: "menu",
|
|
251
251
|
"aria-labelledby": "basic-nav-dropdown",
|
|
252
252
|
style: inlineStyle
|
|
253
|
-
}, /*#__PURE__*/_react.default.createElement(_ApplicationActionBar.ApplicationActionBar, {
|
|
253
|
+
}, isMobile && /*#__PURE__*/_react.default.createElement(_ApplicationActionBar.ApplicationActionBar, {
|
|
254
254
|
items: this.props.actionBarItems
|
|
255
255
|
}), collapsedNavItems.map(function (navItem) {
|
|
256
256
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
257
257
|
key: navItem.key,
|
|
258
|
-
className:
|
|
258
|
+
className: "submodule",
|
|
259
259
|
onClick: _this3.handleCollapsedNavItemSelected,
|
|
260
260
|
"data-nav-item-key": navItem.key
|
|
261
261
|
}, navItem.route);
|
|
@@ -266,7 +266,7 @@ var NavItems = /*#__PURE__*/function (_Component) {
|
|
|
266
266
|
value: function renderNavItem(navItem, isOffscreen) {
|
|
267
267
|
return /*#__PURE__*/_react.default.createElement("li", {
|
|
268
268
|
key: navItem.key,
|
|
269
|
-
className: "submodule
|
|
269
|
+
className: "submodule ".concat(isOffscreen ? 'offscreen' : ''),
|
|
270
270
|
"data-nav-item-key": navItem.key
|
|
271
271
|
}, navItem.route);
|
|
272
272
|
}
|
|
@@ -286,7 +286,7 @@ var NavItems = /*#__PURE__*/function (_Component) {
|
|
|
286
286
|
if (isMobile) {
|
|
287
287
|
return !hasNavItems && hasSingleActionItem ? /*#__PURE__*/_react.default.createElement(_ApplicationActionBar.ApplicationActionBar, {
|
|
288
288
|
items: actionBarItems,
|
|
289
|
-
className:
|
|
289
|
+
className: "position-relative"
|
|
290
290
|
}) : this.renderCollapsedNavItem(navItems);
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -310,7 +310,7 @@ var NavItems = /*#__PURE__*/function (_Component) {
|
|
|
310
310
|
// As all navItems need to be added to the DOM first in order to get their real size
|
|
311
311
|
// the computation wheather a navItem need to be shown under the collapsed dropdown or not
|
|
312
312
|
// needs to be done after the component did mount to the DOM.
|
|
313
|
-
var classes = (0, _classnames.default)('SubmoduleNavigation', '
|
|
313
|
+
var classes = (0, _classnames.default)('SubmoduleNavigation', 'nav');
|
|
314
314
|
return /*#__PURE__*/_react.default.createElement("ul", {
|
|
315
315
|
className: classes,
|
|
316
316
|
ref: function ref(node) {
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.ApplicationLayout = void 0;
|
|
11
9
|
|
|
12
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
11
|
|
|
14
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
13
|
|
|
@@ -23,18 +21,16 @@ var _ApplicationLayoutBody = _interopRequireDefault(require("./ApplicationLayout
|
|
|
23
21
|
|
|
24
22
|
var _init = require("../../utils/init");
|
|
25
23
|
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
29
|
-
|
|
30
24
|
// initializes document bootstrapping - keep the import to avoid being tree-shaked
|
|
31
25
|
_init.initDocumentBootstrapping;
|
|
32
26
|
|
|
33
27
|
var ApplicationLayout = function ApplicationLayout(_ref) {
|
|
34
28
|
var className = _ref.className,
|
|
29
|
+
layoutRef = _ref.layoutRef,
|
|
35
30
|
children = _ref.children;
|
|
36
31
|
var classes = (0, _classnames.default)('ApplicationLayout', className);
|
|
37
32
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
33
|
+
ref: layoutRef,
|
|
38
34
|
className: classes
|
|
39
35
|
}, children);
|
|
40
36
|
};
|
|
@@ -44,7 +40,8 @@ ApplicationLayout.Header = _ApplicationLayoutHeader.default;
|
|
|
44
40
|
ApplicationLayout.Sidebar = _ApplicationLayoutSidebar.default;
|
|
45
41
|
ApplicationLayout.Body = _ApplicationLayoutBody.default;
|
|
46
42
|
ApplicationLayout.propTypes = {
|
|
47
|
-
className: _propTypes.default.string
|
|
43
|
+
className: _propTypes.default.string,
|
|
44
|
+
layoutRef: _propTypes.default.func
|
|
48
45
|
};
|
|
49
46
|
var _default = ApplicationLayout;
|
|
50
47
|
exports.default = _default;
|
|
@@ -19,8 +19,6 @@ var _debounce = _interopRequireDefault(require("lodash/fp/debounce"));
|
|
|
19
19
|
|
|
20
20
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
21
|
|
|
22
|
-
var _ApplicationLayoutBodyBottomBar = require("./ApplicationLayoutBodyBottomBar");
|
|
23
|
-
|
|
24
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
23
|
|
|
26
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -71,7 +69,7 @@ var ApplicationLayoutBody = function ApplicationLayoutBody(props) {
|
|
|
71
69
|
className: classes
|
|
72
70
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
73
71
|
className: "module-content-wrapper"
|
|
74
|
-
},
|
|
72
|
+
}, navigation && navigation, banner && banner, /*#__PURE__*/_react.default.createElement("div", {
|
|
75
73
|
className: innerClasses,
|
|
76
74
|
onScroll: handleScroll,
|
|
77
75
|
ref: moduleContentRef
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = exports.SubNavigation = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
|
+
|
|
22
|
+
var _excluded = ["className", "navItems", "right"];
|
|
23
|
+
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
27
|
+
|
|
28
|
+
var SubNavigation = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
29
|
+
var className = props.className,
|
|
30
|
+
navItems = props.navItems,
|
|
31
|
+
right = props.right,
|
|
32
|
+
remainingProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
33
|
+
var navigationClasses = (0, _classnames.default)('SubNavigation', 'width-100pct display-flex align-items-center justify-content-between overflow-auto', className);
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
35
|
+
ref: ref
|
|
36
|
+
}, remainingProps, {
|
|
37
|
+
className: navigationClasses
|
|
38
|
+
}), /*#__PURE__*/_react.default.createElement("ul", {
|
|
39
|
+
className: "SubmoduleNavigation nav"
|
|
40
|
+
}, navItems.map(function (navItem) {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement("li", {
|
|
42
|
+
className: "submodule",
|
|
43
|
+
key: navItem.key,
|
|
44
|
+
"data-nav-item-key": navItem.key
|
|
45
|
+
}, navItem.route);
|
|
46
|
+
})));
|
|
47
|
+
});
|
|
48
|
+
exports.SubNavigation = SubNavigation;
|
|
49
|
+
SubNavigation.defaultProps = {
|
|
50
|
+
navItems: []
|
|
51
|
+
};
|
|
52
|
+
SubNavigation.propTypes = {
|
|
53
|
+
navItems: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
54
|
+
key: _propTypes.default.string.isRequired,
|
|
55
|
+
route: _propTypes.default.node.isRequired
|
|
56
|
+
})),
|
|
57
|
+
className: _propTypes.default.string
|
|
58
|
+
};
|
|
59
|
+
var _default = SubNavigation;
|
|
60
|
+
exports.default = _default;
|
|
@@ -21,6 +21,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
21
21
|
|
|
22
22
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
23
|
|
|
24
|
+
var _isNil = _interopRequireDefault(require("lodash/fp/isNil"));
|
|
25
|
+
|
|
24
26
|
var _isEmpty = _interopRequireDefault(require("lodash/fp/isEmpty"));
|
|
25
27
|
|
|
26
28
|
var _isEqual = _interopRequireDefault(require("lodash/fp/isEqual"));
|
|
@@ -55,6 +57,8 @@ var _omit = _interopRequireDefault(require("lodash/fp/omit"));
|
|
|
55
57
|
|
|
56
58
|
var _negate = _interopRequireDefault(require("lodash/fp/negate"));
|
|
57
59
|
|
|
60
|
+
var _keys = _interopRequireDefault(require("lodash/fp/keys"));
|
|
61
|
+
|
|
58
62
|
var _TreeSearch = _interopRequireDefault(require("./TreeSearch"));
|
|
59
63
|
|
|
60
64
|
var _TreeSelectAll = _interopRequireDefault(require("./TreeSelectAll"));
|
|
@@ -73,6 +77,8 @@ var _TreeOptions = _interopRequireDefault(require("./TreeOptions"));
|
|
|
73
77
|
|
|
74
78
|
var _TreeRoot = _interopRequireDefault(require("./TreeRoot"));
|
|
75
79
|
|
|
80
|
+
var _TypeCounter = _interopRequireDefault(require("./TypeCounter"));
|
|
81
|
+
|
|
76
82
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
77
83
|
|
|
78
84
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
@@ -86,6 +92,12 @@ var otherwise = _stubTrue.default;
|
|
|
86
92
|
var notEqual = (0, _negate.default)(_isEqual.default);
|
|
87
93
|
var notEmpty = (0, _negate.default)(_isEmpty.default);
|
|
88
94
|
|
|
95
|
+
var Divider = function Divider() {
|
|
96
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
+
className: 'TreeSelectAllDivider bg-light width-2 height-15 ' + 'margin-top-2 margin-bottom-0 margin-left-10 margin-right-10'
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
89
101
|
var isNameObject = function isNameObject(item) {
|
|
90
102
|
return (0, _isObject.default)(item.name);
|
|
91
103
|
};
|
|
@@ -113,6 +125,13 @@ var filterEmptyGroups = (0, _filter.default)(function (group) {
|
|
|
113
125
|
return notEmpty(group.items);
|
|
114
126
|
});
|
|
115
127
|
|
|
128
|
+
var filterAssetByType = function filterAssetByType() {
|
|
129
|
+
var types = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
130
|
+
return (0, _filter.default)(function (asset) {
|
|
131
|
+
return types.includes(asset.type);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
116
135
|
var sortGroupsByName = function sortGroupsByName(groups) {
|
|
117
136
|
var fixedGroups = {};
|
|
118
137
|
var sortableGroups = {};
|
|
@@ -222,9 +241,9 @@ var assetCounted = function assetCounted(payload) {
|
|
|
222
241
|
};
|
|
223
242
|
};
|
|
224
243
|
|
|
225
|
-
var
|
|
244
|
+
var allCheckedChanged = function allCheckedChanged(payload) {
|
|
226
245
|
return {
|
|
227
|
-
type: '
|
|
246
|
+
type: 'allCheckedChanged',
|
|
228
247
|
payload: payload
|
|
229
248
|
};
|
|
230
249
|
};
|
|
@@ -250,6 +269,27 @@ var groupedItemsChanged = function groupedItemsChanged(payload) {
|
|
|
250
269
|
};
|
|
251
270
|
};
|
|
252
271
|
|
|
272
|
+
var typeFilterChanged = function typeFilterChanged(payload) {
|
|
273
|
+
return {
|
|
274
|
+
type: 'typeFilterChanged',
|
|
275
|
+
payload: payload
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
var visibleTypeCountersChanged = function visibleTypeCountersChanged(payload) {
|
|
280
|
+
return {
|
|
281
|
+
type: 'visibleTypeCountersChanged',
|
|
282
|
+
payload: payload
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
var emptyGroupsChanged = function emptyGroupsChanged(payload) {
|
|
287
|
+
return {
|
|
288
|
+
type: 'emptyGroupsChanged',
|
|
289
|
+
payload: payload
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
|
|
253
293
|
var treeReducer = function treeReducer(state, action) {
|
|
254
294
|
switch (action.type) {
|
|
255
295
|
case 'assetCounted':
|
|
@@ -257,7 +297,7 @@ var treeReducer = function treeReducer(state, action) {
|
|
|
257
297
|
assetCounts: action.payload
|
|
258
298
|
});
|
|
259
299
|
|
|
260
|
-
case '
|
|
300
|
+
case 'allCheckedChanged':
|
|
261
301
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
262
302
|
allChecked: action.payload
|
|
263
303
|
});
|
|
@@ -278,6 +318,21 @@ var treeReducer = function treeReducer(state, action) {
|
|
|
278
318
|
groupedItems: action.payload
|
|
279
319
|
});
|
|
280
320
|
|
|
321
|
+
case 'typeFilterChanged':
|
|
322
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
323
|
+
typeFilter: action.payload
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
case 'visibleTypeCountersChanged':
|
|
327
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
328
|
+
visibleTypeCounters: action.payload
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
case 'emptyGroupsChanged':
|
|
332
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
333
|
+
emptyGroups: action.payload
|
|
334
|
+
});
|
|
335
|
+
|
|
281
336
|
default:
|
|
282
337
|
throw new Error();
|
|
283
338
|
}
|
|
@@ -310,7 +365,10 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
310
365
|
flatItems: [],
|
|
311
366
|
allChecked: false,
|
|
312
367
|
searchValue: '',
|
|
313
|
-
assetCounts: {}
|
|
368
|
+
assetCounts: {},
|
|
369
|
+
typeFilter: [],
|
|
370
|
+
visibleTypeCounters: [],
|
|
371
|
+
emptyGroups: []
|
|
314
372
|
}),
|
|
315
373
|
_useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
|
|
316
374
|
state = _useReducer2[0],
|
|
@@ -326,18 +384,23 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
326
384
|
if (notEqual(previousItems.current, items) || notEqual(previousGroups.current, groups)) {
|
|
327
385
|
previousItems.current = items;
|
|
328
386
|
previousGroups.current = groups;
|
|
329
|
-
|
|
330
|
-
dispatch(
|
|
387
|
+
var typeCounts = getAssetTypeCounts(items);
|
|
388
|
+
dispatch(assetCounted(typeCounts));
|
|
389
|
+
var allChecked = checkAllSelected({
|
|
331
390
|
items: items,
|
|
332
391
|
groups: groups,
|
|
333
392
|
selectedItems: selectedItems,
|
|
334
393
|
selectedGroups: selectedGroups
|
|
335
|
-
}, state.flatItems)
|
|
394
|
+
}, state.flatItems);
|
|
395
|
+
dispatch(allCheckedChanged(allChecked)); // Get the distinct asset types from the asset list that is passed into the component
|
|
396
|
+
// to know which asset type counter to render
|
|
397
|
+
|
|
398
|
+
dispatch(visibleTypeCountersChanged(Object.keys(typeCounts)));
|
|
336
399
|
makeTree(groups, items);
|
|
337
400
|
}
|
|
338
401
|
}, [items, groups]);
|
|
339
|
-
var debouncedMakeTree = debounceFn(function (
|
|
340
|
-
return makeTree(
|
|
402
|
+
var debouncedMakeTree = debounceFn(function (losGroupos, losItems) {
|
|
403
|
+
return makeTree(losGroupos, losItems);
|
|
341
404
|
});
|
|
342
405
|
(0, _react.useEffect)(function () {
|
|
343
406
|
// To prevent executing the effect on first render, use a ref to check previous render values
|
|
@@ -347,21 +410,37 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
347
410
|
}
|
|
348
411
|
}, [state.searchValue]);
|
|
349
412
|
(0, _react.useEffect)(function () {
|
|
350
|
-
makeTree(groups, items);
|
|
351
|
-
}, [
|
|
413
|
+
return makeTree(groups, items);
|
|
414
|
+
}, [state.typeFilter]); // Update tree when empty groups are toggled from outside
|
|
415
|
+
|
|
416
|
+
(0, _react.useEffect)(function () {
|
|
417
|
+
return makeTree(groups, items);
|
|
418
|
+
}, [showEmptyGroups]); // Update "select all" state from outside when groups are selected outside programatically
|
|
419
|
+
// without using the "select all" checkbox
|
|
420
|
+
|
|
421
|
+
(0, _react.useEffect)(function () {
|
|
422
|
+
var numOfAllGroups = (0, _size.default)(groups);
|
|
423
|
+
var numOfSelectedGroups = (0, _size.default)(selectedGroups);
|
|
424
|
+
|
|
425
|
+
if (numOfSelectedGroups !== numOfAllGroups && state.allChecked) {
|
|
426
|
+
dispatch(allCheckedChanged(false));
|
|
427
|
+
} else if (numOfSelectedGroups === numOfAllGroups && !state.allChecked) {
|
|
428
|
+
dispatch(allCheckedChanged(true));
|
|
429
|
+
}
|
|
430
|
+
}, [selectedGroups]);
|
|
352
431
|
|
|
353
432
|
var checkAllSelected = function checkAllSelected(updatedProps, flatItems) {
|
|
354
433
|
var updatedItems = updatedProps.items,
|
|
355
434
|
updatedGroups = updatedProps.groups,
|
|
356
435
|
updatedSelectedItems = updatedProps.selectedItems,
|
|
357
|
-
|
|
436
|
+
updatedSelectedGroups = updatedProps.selectedGroups;
|
|
358
437
|
|
|
359
|
-
if (!hasGroups() && (0, _isEmpty.default)(updatedSelectedItems) || hasNoSearchAndGroups() && (0, _isEmpty.default)(
|
|
438
|
+
if (!hasGroups() && (0, _isEmpty.default)(updatedSelectedItems) || hasNoSearchAndGroups() && (0, _isEmpty.default)(updatedSelectedGroups) || hasSearchAndGroups() && (0, _isEmpty.default)(updatedSelectedItems)) {
|
|
360
439
|
return false;
|
|
361
440
|
}
|
|
362
441
|
|
|
363
442
|
if (hasNoSearchAndGroups()) {
|
|
364
|
-
var unselectedGroups = (0, _filter.default)(filterOutByItemId(
|
|
443
|
+
var unselectedGroups = (0, _filter.default)(filterOutByItemId(updatedSelectedGroups))(updatedGroups);
|
|
365
444
|
return (0, _isEmpty.default)(unselectedGroups);
|
|
366
445
|
} else if (hasSearchAndGroups()) {
|
|
367
446
|
var unselectedSearchItems = (0, _filter.default)(filterOutByItemId(updatedSelectedItems))(flatItems);
|
|
@@ -397,7 +476,7 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
397
476
|
|
|
398
477
|
var handeSelectAll = function handeSelectAll(shouldSelect, isIndeterminate) {
|
|
399
478
|
var shouldSelectAll = shouldSelect && !isIndeterminate;
|
|
400
|
-
dispatch(
|
|
479
|
+
dispatch(allCheckedChanged(shouldSelectAll));
|
|
401
480
|
(0, _cond.default)([[hasNoSearchAndGroups, function () {
|
|
402
481
|
return selectAllGroups(shouldSelectAll);
|
|
403
482
|
}], [hasSearchAndGroups, function () {
|
|
@@ -435,7 +514,13 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
435
514
|
var itemIdsOfGroup = (0, _map.default)(function (item) {
|
|
436
515
|
return item.id;
|
|
437
516
|
})(itemsInGroup.items);
|
|
438
|
-
var updatedSelectedItems = (0, _without.default)(itemIdsOfGroup, selectedItems);
|
|
517
|
+
var updatedSelectedItems = (0, _without.default)(itemIdsOfGroup, selectedItems); // check if all groups are selected to change the state of TreeSelectAll
|
|
518
|
+
|
|
519
|
+
var groupAmount = groups.length;
|
|
520
|
+
var emptyGroupAmount = showEmptyGroups ? 0 : state.emptyGroups.length;
|
|
521
|
+
var totalGroupAmount = groupAmount - emptyGroupAmount;
|
|
522
|
+
var areAllGroupsChecked = totalGroupAmount === newSelectedGroups.length;
|
|
523
|
+
dispatch(allCheckedChanged(areAllGroupsChecked));
|
|
439
524
|
respondSelection(updatedSelectedItems, newSelectedGroups);
|
|
440
525
|
};
|
|
441
526
|
|
|
@@ -466,13 +551,20 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
466
551
|
// Map items to groups with filtered items
|
|
467
552
|
var mappedItemsToGroups = getMappedItemsToGroups(groupsToProcess, itemsToProcess);
|
|
468
553
|
var newGroupedItems = (0, _flow.default)(sortGroupsByName, sortGroupItemsByName)(mappedItemsToGroups);
|
|
469
|
-
var groupedItems = considerEmptyGroups ? newGroupedItems : filterEmptyGroups(newGroupedItems);
|
|
554
|
+
var groupedItems = considerEmptyGroups ? newGroupedItems : filterEmptyGroups(newGroupedItems); // Keep the empty groups in memory for later access in select all, without re-iterating on every
|
|
555
|
+
// group selection
|
|
556
|
+
|
|
557
|
+
var emptyGroups = (0, _filter.default)(function (group) {
|
|
558
|
+
return (0, _isEmpty.default)(group.items);
|
|
559
|
+
})(newGroupedItems);
|
|
560
|
+
dispatch(emptyGroupsChanged(emptyGroups));
|
|
470
561
|
dispatch(assetCounted(getAssetTypeCounts(items)));
|
|
471
562
|
dispatch(groupedItemsChanged(groupedItems));
|
|
472
563
|
};
|
|
473
564
|
|
|
474
565
|
var makeTree = function makeTree(updatedGroups, updatedItems) {
|
|
475
566
|
var internalSearchValue = state.searchValue;
|
|
567
|
+
var internalTypeFilter = state.typeFilter;
|
|
476
568
|
var groupsToProcess = updatedGroups;
|
|
477
569
|
var itemsToProcess = updatedItems;
|
|
478
570
|
|
|
@@ -488,12 +580,14 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
488
580
|
return notEmpty(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
489
581
|
};
|
|
490
582
|
|
|
583
|
+
var filteredItems = (0, _isEmpty.default)(internalTypeFilter) ? itemsToProcess : filterAssetByType(internalTypeFilter)(itemsToProcess);
|
|
584
|
+
|
|
491
585
|
var setGroupedItems = function setGroupedItems() {
|
|
492
|
-
return setGroupedItemList(groupsToProcess,
|
|
586
|
+
return setGroupedItemList(groupsToProcess, filteredItems, showEmptyGroups);
|
|
493
587
|
};
|
|
494
588
|
|
|
495
589
|
var setFlatItems = function setFlatItems() {
|
|
496
|
-
return setFlatItemList(
|
|
590
|
+
return setFlatItemList(filteredItems, internalSearchValue);
|
|
497
591
|
};
|
|
498
592
|
|
|
499
593
|
(0, _cond.default)([[hasNoInternalSearchAndGroups, setGroupedItems], [hasInternalSearchAndGroups, setFlatItems], [otherwise, setFlatItems]])();
|
|
@@ -556,16 +650,6 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
556
650
|
}, hasLeafs ? /*#__PURE__*/_react.default.createElement(_TreeNothingFound.default, null) : getLeafs());
|
|
557
651
|
};
|
|
558
652
|
|
|
559
|
-
var renderSummary = function renderSummary() {
|
|
560
|
-
if (hideSummary) {
|
|
561
|
-
return null;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
return summary || /*#__PURE__*/_react.default.createElement(_TreeSummary.default, {
|
|
565
|
-
assetCounts: state.assetCounts
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
|
|
569
653
|
var hasExternalGroups = notEmpty(groups);
|
|
570
654
|
|
|
571
655
|
var hasInternalSearchValue = function hasInternalSearchValue() {
|
|
@@ -581,7 +665,8 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
581
665
|
};
|
|
582
666
|
|
|
583
667
|
var hasSelectedAllGroups = function hasSelectedAllGroups() {
|
|
584
|
-
|
|
668
|
+
var emptyGroupAmount = showEmptyGroups ? 0 : state.emptyGroups.length;
|
|
669
|
+
return (0, _isEqual.default)((0, _size.default)(selectedGroups), (0, _size.default)(groups) - emptyGroupAmount);
|
|
585
670
|
};
|
|
586
671
|
|
|
587
672
|
var hasPartialySelectedGroups = function hasPartialySelectedGroups() {
|
|
@@ -604,25 +689,56 @@ var Tree = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
604
689
|
}], [otherwise, function () {
|
|
605
690
|
return renderFlatList();
|
|
606
691
|
}]])();
|
|
692
|
+
|
|
693
|
+
var handleFilterByType = function handleFilterByType(type) {
|
|
694
|
+
var currentTypeFilter = new Set(state.typeFilter);
|
|
695
|
+
|
|
696
|
+
if (currentTypeFilter.has(type)) {
|
|
697
|
+
currentTypeFilter.delete(type);
|
|
698
|
+
} else {
|
|
699
|
+
currentTypeFilter.add(type);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
dispatch(typeFilterChanged((0, _toConsumableArray2.default)(currentTypeFilter)));
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
var isClickable = (0, _size.default)((0, _keys.default)(state.assetCounts)) > 1;
|
|
706
|
+
var isFilterActive = notEmpty(state.typeFilter);
|
|
707
|
+
var showTreeHead = !hideTreeHead;
|
|
708
|
+
var showSelectAll = !hideSelectAll;
|
|
709
|
+
var showSearch = !hideSearch;
|
|
710
|
+
var showSummary = !hideSummary;
|
|
711
|
+
var hasCustomSearch = !(0, _isNil.default)(search);
|
|
607
712
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
608
713
|
className: treeClassNames,
|
|
609
714
|
ref: treeRef
|
|
610
715
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
611
716
|
className: "TreeHeader"
|
|
612
|
-
},
|
|
717
|
+
}, showSearch && !hasCustomSearch && /*#__PURE__*/_react.default.createElement(_TreeSearch.default, {
|
|
613
718
|
value: state.searchValue,
|
|
614
719
|
onChange: handleSearchChange,
|
|
615
720
|
placeholder: searchPlaceholder
|
|
616
|
-
}),
|
|
721
|
+
}), hasCustomSearch && search, showTreeHead && /*#__PURE__*/_react.default.createElement("div", {
|
|
617
722
|
className: treeHeadClasses
|
|
618
|
-
},
|
|
723
|
+
}, showSelectAll && /*#__PURE__*/_react.default.createElement(_TreeSelectAll.default, {
|
|
619
724
|
isChecked: state.allChecked,
|
|
620
725
|
isEnabled: hasMultiselect,
|
|
621
726
|
isIndeterminate: isIndeterminate,
|
|
622
727
|
onSelect: handeSelectAll
|
|
623
|
-
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
728
|
+
}), showSelectAll && hasMultiselect && showSummary && /*#__PURE__*/_react.default.createElement(Divider, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
624
729
|
className: "display-flex justify-content-between align-items-center width-100pct"
|
|
625
|
-
},
|
|
730
|
+
}, showSummary ? summary || /*#__PURE__*/_react.default.createElement(_TreeSummary.default, null, (0, _map.default)(function (typeCounter) {
|
|
731
|
+
return /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
732
|
+
key: typeCounter,
|
|
733
|
+
type: typeCounter,
|
|
734
|
+
icon: "".concat(typeCounter),
|
|
735
|
+
value: state.assetCounts[typeCounter],
|
|
736
|
+
onClick: handleFilterByType,
|
|
737
|
+
isActive: state.typeFilter.includes(typeCounter),
|
|
738
|
+
hasFilter: isFilterActive,
|
|
739
|
+
enableActivity: isClickable
|
|
740
|
+
});
|
|
741
|
+
})(state.visibleTypeCounters)) : null, /*#__PURE__*/_react.default.createElement(_TreeOptions.default, {
|
|
626
742
|
treeOptions: treeOptions
|
|
627
743
|
})))), /*#__PURE__*/_react.default.createElement(_TreeRoot.default, {
|
|
628
744
|
maxHeight: scrollHeight
|
|
@@ -25,7 +25,7 @@ var TreeSelectAll = function TreeSelectAll(props) {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
return isEnabled ? /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
-
className:
|
|
28
|
+
className: "TreeSelectAll display-flex align-items-center"
|
|
29
29
|
}, /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
|
|
30
30
|
checked: isChecked,
|
|
31
31
|
onClick: handleSelectAll,
|
|
@@ -23,21 +23,26 @@ var DefaultAssetCounts = function DefaultAssetCounts(_ref) {
|
|
|
23
23
|
trailer = assetCounts.trailer,
|
|
24
24
|
driver = assetCounts.driver;
|
|
25
25
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
26
|
-
className:
|
|
26
|
+
className: "display-flex"
|
|
27
27
|
}, /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
28
|
-
|
|
28
|
+
hideOnZero: true,
|
|
29
|
+
icon: "truck-baseline",
|
|
29
30
|
value: truck
|
|
30
31
|
}), /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
31
|
-
|
|
32
|
+
hideOnZero: true,
|
|
33
|
+
icon: "trailer-baseline",
|
|
32
34
|
value: trailer
|
|
33
35
|
}), /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
34
|
-
|
|
36
|
+
hideOnZero: true,
|
|
37
|
+
icon: "bus-baseline",
|
|
35
38
|
value: bus
|
|
36
39
|
}), /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
37
|
-
|
|
40
|
+
hideOnZero: true,
|
|
41
|
+
icon: "van-baseline",
|
|
38
42
|
value: van
|
|
39
43
|
}), /*#__PURE__*/_react.default.createElement(_TypeCounter.default, {
|
|
40
|
-
|
|
44
|
+
hideOnZero: true,
|
|
45
|
+
icon: "driver",
|
|
41
46
|
value: driver
|
|
42
47
|
}));
|
|
43
48
|
};
|