@rio-cloud/rio-uikit 0.16.4-beta.21 → 0.16.4-beta.22
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/AssetTree.d.ts +2 -5
- package/AssetTree.js +2 -2
- package/ButtonDropdown.d.ts +2 -5
- package/ButtonDropdown.js +2 -2
- package/DropdownSubmenu.d.ts +2 -5
- package/DropdownSubmenu.js +2 -2
- package/MenuItem.d.ts +2 -5
- package/MenuItem.js +2 -2
- package/MenuItemList.d.ts +2 -0
- package/MenuItemList.js +2 -0
- package/MenuItems.d.ts +2 -0
- package/MenuItems.js +2 -0
- package/Page.d.ts +2 -0
- package/Page.js +2 -0
- package/Sidebar.d.ts +1 -0
- package/Sidebar.js +1 -0
- package/SimpleButtonDropdown.d.ts +2 -5
- package/SimpleButtonDropdown.js +2 -2
- package/SingleButtonDropdown.d.ts +2 -5
- package/SingleButtonDropdown.js +2 -2
- package/SplitButtonDropdown.d.ts +2 -5
- package/SplitButtonDropdown.js +2 -2
- package/Tree.d.ts +2 -5
- package/Tree.js +2 -2
- package/TreeCategory.d.ts +2 -5
- package/TreeCategory.js +2 -2
- package/TreeOption.d.ts +2 -5
- package/TreeOption.js +2 -2
- package/TreeSearch.d.ts +2 -5
- package/TreeSearch.js +2 -2
- package/TreeSummary.d.ts +2 -5
- package/TreeSummary.js +2 -2
- package/TreeSummaryRow.d.ts +2 -0
- package/TreeSummaryRow.js +2 -0
- package/TypeCounter.d.ts +2 -5
- package/TypeCounter.js +2 -2
- package/components/assetTree/AssetTree.d.ts +84 -2
- package/components/assetTree/AssetTree.js +41 -61
- package/components/assetTree/Tree.d.ts +195 -2
- package/components/assetTree/Tree.js +70 -256
- package/components/assetTree/TreeCategory.d.ts +24 -11
- package/components/assetTree/TreeCategory.js +1 -8
- package/components/assetTree/TreeLeaf.d.ts +1 -1
- package/components/assetTree/TreeLeaf.js +3 -2
- package/components/assetTree/TreeLeafList.d.ts +3 -3
- package/components/assetTree/TreeLeafList.js +4 -3
- package/components/assetTree/TreeNode.d.ts +12 -2
- package/components/assetTree/TreeNode.js +2 -17
- package/components/assetTree/TreeNodeContainer.d.ts +10 -12
- package/components/assetTree/TreeNodeContainer.js +9 -8
- package/components/assetTree/TreeNothingFound.d.ts +3 -2
- package/components/assetTree/TreeNothingFound.js +1 -7
- package/components/assetTree/TreeOption.d.ts +27 -17
- package/components/assetTree/TreeOption.js +5 -14
- package/components/assetTree/TreeOptions.d.ts +9 -13
- package/components/assetTree/TreeOptions.js +4 -11
- package/components/assetTree/TreeRoot.d.ts +9 -11
- package/components/assetTree/TreeRoot.js +8 -8
- package/components/assetTree/TreeSearch.d.ts +23 -2
- package/components/assetTree/TreeSearch.js +4 -12
- package/components/assetTree/TreeSelectAll.d.ts +14 -26
- package/components/assetTree/TreeSelectAll.js +7 -22
- package/components/assetTree/TreeSidebar.d.ts +10 -2
- package/components/assetTree/TreeSidebar.js +4 -35
- package/components/assetTree/TreeSidebarCategories.d.ts +11 -0
- package/components/assetTree/TreeSidebarCategories.js +34 -0
- package/components/assetTree/TreeSummary.d.ts +44 -2
- package/components/assetTree/TreeSummary.js +6 -19
- package/components/assetTree/TreeSummaryRow.d.ts +15 -0
- package/components/assetTree/TreeSummaryRow.js +6 -0
- package/components/assetTree/TypeCounter.d.ts +45 -2
- package/components/assetTree/TypeCounter.js +14 -23
- package/components/assetTree/treeReducer.d.ts +47 -0
- package/components/assetTree/treeReducer.js +34 -0
- package/components/assetTree/treeUtils.d.ts +20 -0
- package/components/assetTree/treeUtils.js +88 -0
- package/components/button/Button.d.ts +14 -9
- package/components/button/Button.js +7 -7
- package/components/button/ToggleButton.d.ts +2 -4
- package/components/datepicker/DatePicker.d.ts +9 -9
- package/components/datepicker/DatePicker.js +4 -2
- package/components/dialog/Dialog.js +6 -2
- package/components/dropdown/ButtonDropdown.d.ts +115 -65
- package/components/dropdown/ButtonDropdown.js +14 -60
- package/components/dropdown/Caret.d.ts +1 -1
- package/components/dropdown/Caret.js +2 -1
- package/components/dropdown/DropdownSubmenu.d.ts +21 -18
- package/components/dropdown/DropdownSubmenu.js +26 -19
- package/components/dropdown/DropdownToggleButton.d.ts +14 -2
- package/components/dropdown/DropdownToggleButton.js +6 -14
- package/components/dropdown/SimpleButtonDropdown.d.ts +3 -1
- package/components/dropdown/SimpleButtonDropdown.js +3 -2
- package/components/dropdown/SingleButtonDropdown.d.ts +3 -1
- package/components/dropdown/SingleButtonDropdown.js +3 -2
- package/components/dropdown/SplitButtonDropdown.d.ts +3 -1
- package/components/dropdown/SplitButtonDropdown.js +3 -2
- package/components/dropdown/SplitCaretButton.d.ts +12 -2
- package/components/dropdown/SplitCaretButton.js +6 -11
- package/components/menuItems/MenuItem.d.ts +16 -0
- package/components/menuItems/MenuItem.js +1 -0
- package/components/menuItems/MenuItemList.d.ts +7 -0
- package/components/menuItems/MenuItemList.js +10 -0
- package/components/menuItems/MenuItems.d.ts +7 -2
- package/components/menuItems/MenuItems.js +10 -9
- package/components/numberInput/NumberInput.js +1 -1
- package/components/page/Page.d.ts +10 -0
- package/components/page/Page.js +18 -0
- package/components/timepicker/TimePicker.js +2 -1
- package/hooks/usePrevious.d.ts +1 -1
- package/hooks/usePrevious.js +6 -7
- package/index.d.ts +34 -26
- package/index.js +34 -26
- package/lib/es/AssetTree.d.ts +2 -5
- package/lib/es/AssetTree.js +3 -2
- package/lib/es/ButtonDropdown.d.ts +2 -5
- package/lib/es/ButtonDropdown.js +3 -2
- package/lib/es/DropdownSubmenu.d.ts +2 -5
- package/lib/es/DropdownSubmenu.js +3 -2
- package/lib/es/MenuItem.d.ts +2 -5
- package/lib/es/MenuItem.js +3 -2
- package/lib/es/MenuItemList.d.ts +2 -0
- package/lib/es/MenuItemList.js +7 -0
- package/lib/es/MenuItems.d.ts +2 -0
- package/lib/es/MenuItems.js +7 -0
- package/lib/es/Page.d.ts +2 -0
- package/lib/es/Page.js +7 -0
- package/lib/es/Sidebar.d.ts +1 -0
- package/lib/es/Sidebar.js +3 -4
- package/lib/es/SimpleButtonDropdown.d.ts +2 -5
- package/lib/es/SimpleButtonDropdown.js +3 -2
- package/lib/es/SingleButtonDropdown.d.ts +2 -5
- package/lib/es/SingleButtonDropdown.js +3 -2
- package/lib/es/SplitButtonDropdown.d.ts +2 -5
- package/lib/es/SplitButtonDropdown.js +3 -2
- package/lib/es/Tree.d.ts +2 -5
- package/lib/es/Tree.js +3 -2
- package/lib/es/TreeCategory.d.ts +2 -5
- package/lib/es/TreeCategory.js +3 -2
- package/lib/es/TreeOption.d.ts +2 -5
- package/lib/es/TreeOption.js +3 -2
- package/lib/es/TreeSearch.d.ts +2 -5
- package/lib/es/TreeSearch.js +3 -2
- package/lib/es/TreeSummary.d.ts +2 -5
- package/lib/es/TreeSummary.js +3 -2
- package/lib/es/TreeSummaryRow.d.ts +2 -0
- package/lib/es/TreeSummaryRow.js +7 -0
- package/lib/es/TypeCounter.d.ts +2 -5
- package/lib/es/TypeCounter.js +3 -2
- package/lib/es/components/assetTree/AssetTree.d.ts +84 -2
- package/lib/es/components/assetTree/AssetTree.js +40 -60
- package/lib/es/components/assetTree/Tree.d.ts +195 -2
- package/lib/es/components/assetTree/Tree.js +103 -286
- package/lib/es/components/assetTree/TreeCategory.d.ts +24 -11
- package/lib/es/components/assetTree/TreeCategory.js +1 -9
- package/lib/es/components/assetTree/TreeLeaf.d.ts +1 -1
- package/lib/es/components/assetTree/TreeLeaf.js +2 -1
- package/lib/es/components/assetTree/TreeLeafList.d.ts +3 -3
- package/lib/es/components/assetTree/TreeLeafList.js +4 -3
- package/lib/es/components/assetTree/TreeNode.d.ts +12 -2
- package/lib/es/components/assetTree/TreeNode.js +2 -17
- package/lib/es/components/assetTree/TreeNodeContainer.d.ts +10 -12
- package/lib/es/components/assetTree/TreeNodeContainer.js +9 -8
- package/lib/es/components/assetTree/TreeNothingFound.d.ts +3 -2
- package/lib/es/components/assetTree/TreeNothingFound.js +1 -7
- package/lib/es/components/assetTree/TreeOption.d.ts +27 -17
- package/lib/es/components/assetTree/TreeOption.js +5 -14
- package/lib/es/components/assetTree/TreeOptions.d.ts +9 -13
- package/lib/es/components/assetTree/TreeOptions.js +4 -11
- package/lib/es/components/assetTree/TreeRoot.d.ts +9 -11
- package/lib/es/components/assetTree/TreeRoot.js +8 -8
- package/lib/es/components/assetTree/TreeSearch.d.ts +23 -2
- package/lib/es/components/assetTree/TreeSearch.js +4 -12
- package/lib/es/components/assetTree/TreeSelectAll.d.ts +14 -26
- package/lib/es/components/assetTree/TreeSelectAll.js +7 -22
- package/lib/es/components/assetTree/TreeSidebar.d.ts +10 -2
- package/lib/es/components/assetTree/TreeSidebar.js +5 -36
- package/lib/es/components/assetTree/TreeSidebarCategories.d.ts +11 -0
- package/lib/es/components/assetTree/TreeSidebarCategories.js +37 -0
- package/lib/es/components/assetTree/TreeSummary.d.ts +44 -2
- package/lib/es/components/assetTree/TreeSummary.js +6 -19
- package/lib/es/components/assetTree/TreeSummaryRow.d.ts +15 -0
- package/lib/es/components/assetTree/TreeSummaryRow.js +10 -0
- package/lib/es/components/assetTree/TypeCounter.d.ts +45 -2
- package/lib/es/components/assetTree/TypeCounter.js +14 -23
- package/lib/es/components/assetTree/autoAnimateFrames.d.ts +1 -0
- package/lib/es/components/assetTree/autoAnimateFrames.js +55 -0
- package/lib/es/components/assetTree/treeReducer.d.ts +47 -0
- package/lib/es/components/assetTree/treeReducer.js +47 -0
- package/lib/es/components/assetTree/treeUtils.d.ts +20 -0
- package/lib/es/components/assetTree/treeUtils.js +106 -0
- package/lib/es/components/button/Button.d.ts +14 -9
- package/lib/es/components/button/Button.js +12 -11
- package/lib/es/components/button/ToggleButton.d.ts +2 -4
- package/lib/es/components/datepicker/DatePicker.d.ts +9 -9
- package/lib/es/components/datepicker/DatePicker.js +4 -2
- package/lib/es/components/dialog/Dialog.js +5 -1
- package/lib/es/components/dropdown/ButtonDropdown.d.ts +115 -65
- package/lib/es/components/dropdown/ButtonDropdown.js +13 -59
- package/lib/es/components/dropdown/Caret.d.ts +1 -1
- package/lib/es/components/dropdown/Caret.js +2 -2
- package/lib/es/components/dropdown/DropdownSubmenu.d.ts +21 -18
- package/lib/es/components/dropdown/DropdownSubmenu.js +26 -19
- package/lib/es/components/dropdown/DropdownToggleButton.d.ts +14 -2
- package/lib/es/components/dropdown/DropdownToggleButton.js +6 -14
- package/lib/es/components/dropdown/SimpleButtonDropdown.d.ts +3 -1
- package/lib/es/components/dropdown/SimpleButtonDropdown.js +3 -2
- package/lib/es/components/dropdown/SingleButtonDropdown.d.ts +3 -1
- package/lib/es/components/dropdown/SingleButtonDropdown.js +3 -2
- package/lib/es/components/dropdown/SplitButtonDropdown.d.ts +3 -1
- package/lib/es/components/dropdown/SplitButtonDropdown.js +3 -2
- package/lib/es/components/dropdown/SplitCaretButton.d.ts +12 -2
- package/lib/es/components/dropdown/SplitCaretButton.js +6 -11
- package/lib/es/components/menuItems/MenuItem.d.ts +16 -0
- package/lib/es/components/menuItems/MenuItem.js +1 -0
- package/lib/es/components/menuItems/MenuItemList.d.ts +7 -0
- package/lib/es/components/menuItems/MenuItemList.js +12 -0
- package/lib/es/components/menuItems/MenuItems.d.ts +7 -2
- package/lib/es/components/menuItems/MenuItems.js +9 -7
- package/lib/es/components/numberInput/NumberInput.js +1 -1
- package/lib/es/components/page/Page.d.ts +10 -0
- package/lib/es/components/page/Page.js +21 -0
- package/lib/es/components/timepicker/TimePicker.js +2 -1
- package/lib/es/hooks/usePrevious.d.ts +1 -1
- package/lib/es/hooks/usePrevious.js +5 -6
- package/lib/es/index.d.ts +34 -26
- package/lib/es/index.js +55 -30
- package/lib/es/types.d.ts +1 -140
- package/lib/es/utils/init.js +1 -0
- package/lib/es/utils/mergeRefs.d.ts +3 -0
- package/lib/es/utils/mergeRefs.js +18 -0
- package/lib/es/utils/searchNormalized.d.ts +2 -2
- package/lib/es/utils/searchNormalized.js +1 -1
- package/lib/es/version.json +1 -1
- package/package.json +39 -36
- package/types.d.ts +1 -140
- package/utils/init.js +1 -0
- package/utils/mergeRefs.d.ts +3 -0
- package/utils/mergeRefs.js +16 -0
- package/utils/searchNormalized.d.ts +2 -2
- package/utils/searchNormalized.js +1 -1
- package/version.json +1 -1
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSubTypeCounts = exports.getTypeCounts = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
/* eslint-disable no-use-before-define */
|
|
6
7
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
7
|
-
const prop_types_1 = tslib_1.__importDefault(require("prop-types"));
|
|
8
8
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
9
9
|
const isNil_1 = tslib_1.__importDefault(require("lodash/fp/isNil"));
|
|
10
10
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/fp/isEmpty"));
|
|
11
11
|
const isEqual_1 = tslib_1.__importDefault(require("lodash/fp/isEqual"));
|
|
12
12
|
const map_1 = tslib_1.__importDefault(require("lodash/fp/map"));
|
|
13
13
|
const find_1 = tslib_1.__importDefault(require("lodash/fp/find"));
|
|
14
|
-
const orderBy_1 = tslib_1.__importDefault(require("lodash/fp/orderBy"));
|
|
15
|
-
const isObject_1 = tslib_1.__importDefault(require("lodash/fp/isObject"));
|
|
16
|
-
const debounce_1 = tslib_1.__importDefault(require("lodash/fp/debounce"));
|
|
17
14
|
const cond_1 = tslib_1.__importDefault(require("lodash/fp/cond"));
|
|
18
15
|
const without_1 = tslib_1.__importDefault(require("lodash/fp/without"));
|
|
19
|
-
const countBy_1 = tslib_1.__importDefault(require("lodash/fp/countBy"));
|
|
20
|
-
const getOr_1 = tslib_1.__importDefault(require("lodash/fp/getOr"));
|
|
21
16
|
const flow_1 = tslib_1.__importDefault(require("lodash/fp/flow"));
|
|
22
17
|
const filter_1 = tslib_1.__importDefault(require("lodash/fp/filter"));
|
|
23
18
|
const size_1 = tslib_1.__importDefault(require("lodash/fp/size"));
|
|
24
19
|
const stubTrue_1 = tslib_1.__importDefault(require("lodash/fp/stubTrue"));
|
|
25
20
|
const omit_1 = tslib_1.__importDefault(require("lodash/fp/omit"));
|
|
26
|
-
const
|
|
27
|
-
const keys_1 = tslib_1.__importDefault(require("lodash/fp/keys"));
|
|
21
|
+
const noop_1 = tslib_1.__importDefault(require("lodash/fp/noop"));
|
|
28
22
|
const TreeSearch_1 = tslib_1.__importDefault(require("./TreeSearch"));
|
|
29
23
|
const TreeSelectAll_1 = tslib_1.__importDefault(require("./TreeSelectAll"));
|
|
30
24
|
const TreeSummary_1 = tslib_1.__importDefault(require("./TreeSummary"));
|
|
@@ -35,71 +29,11 @@ const TreeNothingFound_1 = tslib_1.__importDefault(require("./TreeNothingFound")
|
|
|
35
29
|
const TreeOptions_1 = tslib_1.__importDefault(require("./TreeOptions"));
|
|
36
30
|
const TreeRoot_1 = tslib_1.__importDefault(require("./TreeRoot"));
|
|
37
31
|
const TypeCounter_1 = tslib_1.__importDefault(require("./TypeCounter"));
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const notEmpty = (0, negate_1.default)(isEmpty_1.default);
|
|
44
|
-
const isNameObject = item => (0, isObject_1.default)(item.name);
|
|
45
|
-
const getFullName = item => `${item.name.firstName} ${item.name.lastName}`;
|
|
46
|
-
const getName = item => (isNameObject(item) ? getFullName(item) : item.name);
|
|
47
|
-
const getLowerCaseName = item => (0, getOr_1.default)('', 'name')(item).toLowerCase();
|
|
48
|
-
const getLowerCaseLastName = item => (0, getOr_1.default)('', 'name.lastName')(item).toLowerCase();
|
|
49
|
-
const orderByName = (0, orderBy_1.default)([item => (isNameObject(item) ? getLowerCaseLastName(item) : getLowerCaseName(item))], ['asc']);
|
|
50
|
-
const filterEmptyGroups = (0, filter_1.default)(group => notEmpty(group.items));
|
|
51
|
-
const filterAssetByType = (types = []) => (0, filter_1.default)(asset => types.includes(asset.type));
|
|
52
|
-
const sortGroupsByName = groups => {
|
|
53
|
-
const fixedGroups = {};
|
|
54
|
-
const sortableGroups = {};
|
|
55
|
-
(0, map_1.default)(group => {
|
|
56
|
-
if (group.position === 'last') {
|
|
57
|
-
fixedGroups[group.id] = Object.assign({}, group);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
sortableGroups[group.id] = Object.assign({}, group);
|
|
61
|
-
}
|
|
62
|
-
})(groups);
|
|
63
|
-
const sortedGroups = orderByName(sortableGroups);
|
|
64
|
-
return (0, isEmpty_1.default)(fixedGroups) ? sortedGroups : Object.assign(Object.assign({}, sortedGroups), fixedGroups);
|
|
65
|
-
};
|
|
66
|
-
const sortGroupItemsByName = groups => {
|
|
67
|
-
const sortedGroups = {};
|
|
68
|
-
(0, map_1.default)(group => {
|
|
69
|
-
sortedGroups[group.id] = Object.assign(Object.assign({}, group), { items: orderByName(group.items) });
|
|
70
|
-
})(groups);
|
|
71
|
-
return sortedGroups;
|
|
72
|
-
};
|
|
73
|
-
const getMappedItemsToGroups = (groups, items) => {
|
|
74
|
-
const mappedGroups = {};
|
|
75
|
-
// build an object for listing the groups by id
|
|
76
|
-
groups.forEach(group => {
|
|
77
|
-
mappedGroups[group.id] = Object.assign(Object.assign({}, group), { items: [] });
|
|
78
|
-
});
|
|
79
|
-
items.forEach(item => {
|
|
80
|
-
// add items to the respective group
|
|
81
|
-
const groupIds = item.groupIds || [];
|
|
82
|
-
groupIds.forEach(groupId => {
|
|
83
|
-
const mappedGroup = mappedGroups[groupId];
|
|
84
|
-
if (mappedGroup) {
|
|
85
|
-
mappedGroup.items.push(item);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
return mappedGroups;
|
|
90
|
-
};
|
|
91
|
-
const filterByName = searchValue => item => {
|
|
92
|
-
if (searchValue) {
|
|
93
|
-
return (0, searchNormalized_1.searchNormalized)(getName(item), searchValue);
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
};
|
|
97
|
-
const filterOutByItemId = list => item => !list.includes(item.id);
|
|
98
|
-
const containsItemById = list => item => list.includes(item.id);
|
|
99
|
-
const getFlatItems = (items, searchValue) => (0, flow_1.default)((0, filter_1.default)(filterByName(searchValue)), orderByName)(items);
|
|
100
|
-
const getListIds = list => list.map(listItem => listItem.id);
|
|
101
|
-
const getAssetTypeCounts = items => (0, countBy_1.default)(item => item.type, items);
|
|
102
|
-
const debounceFn = fn => (0, debounce_1.default)(SEARCH_DEBOUNCE, fn);
|
|
32
|
+
const treeUtils_1 = require("./treeUtils");
|
|
33
|
+
const treeReducer_1 = require("./treeReducer");
|
|
34
|
+
var treeUtils_2 = require("./treeUtils");
|
|
35
|
+
Object.defineProperty(exports, "getTypeCounts", { enumerable: true, get: function () { return treeUtils_2.getTypeCounts; } });
|
|
36
|
+
Object.defineProperty(exports, "getSubTypeCounts", { enumerable: true, get: function () { return treeUtils_2.getSubTypeCounts; } });
|
|
103
37
|
const filterProps = (0, omit_1.default)([
|
|
104
38
|
'expandedGroups',
|
|
105
39
|
'onExpandGroupsChange',
|
|
@@ -108,39 +42,9 @@ const filterProps = (0, omit_1.default)([
|
|
|
108
42
|
'treeOptions',
|
|
109
43
|
]);
|
|
110
44
|
const customCompare = (prevProps, nextProps) => (0, isEqual_1.default)(filterProps(prevProps), filterProps(nextProps));
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const flatItemsChanged = payload => ({ type: 'flatItemsChanged', payload });
|
|
115
|
-
const groupedItemsChanged = payload => ({ type: 'groupedItemsChanged', payload });
|
|
116
|
-
const typeFilterChanged = payload => ({ type: 'typeFilterChanged', payload });
|
|
117
|
-
const visibleTypeCountersChanged = payload => ({ type: 'visibleTypeCountersChanged', payload });
|
|
118
|
-
const emptyGroupsChanged = payload => ({ type: 'emptyGroupsChanged', payload });
|
|
119
|
-
const treeReducer = (state, action) => {
|
|
120
|
-
switch (action.type) {
|
|
121
|
-
case 'assetCounted':
|
|
122
|
-
return Object.assign(Object.assign({}, state), { assetCounts: action.payload });
|
|
123
|
-
case 'allCheckedChanged':
|
|
124
|
-
return Object.assign(Object.assign({}, state), { allChecked: action.payload });
|
|
125
|
-
case 'searchValueChanged':
|
|
126
|
-
return Object.assign(Object.assign({}, state), { searchValue: action.payload, allChecked: false });
|
|
127
|
-
case 'flatItemsChanged':
|
|
128
|
-
return Object.assign(Object.assign({}, state), { flatItems: action.payload });
|
|
129
|
-
case 'groupedItemsChanged':
|
|
130
|
-
return Object.assign(Object.assign({}, state), { groupedItems: action.payload });
|
|
131
|
-
case 'typeFilterChanged':
|
|
132
|
-
return Object.assign(Object.assign({}, state), { typeFilter: action.payload });
|
|
133
|
-
case 'visibleTypeCountersChanged':
|
|
134
|
-
return Object.assign(Object.assign({}, state), { visibleTypeCounters: action.payload });
|
|
135
|
-
case 'emptyGroupsChanged':
|
|
136
|
-
return Object.assign(Object.assign({}, state), { emptyGroups: action.payload });
|
|
137
|
-
default:
|
|
138
|
-
throw new Error();
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
const Tree = react_1.default.memo(props => {
|
|
142
|
-
const { groups, items, selectedGroups, selectedItems, onSelectionChange, hasMultiselect, showRadioButtons, hideSearch, hideTreeHead, summary, hideSummary, search, searchPlaceholder, onSearchChange, className, scrollHeight, expandedGroups, onExpandGroupsChange, showEmptyGroups, treeOptions } = props, remainingProps = tslib_1.__rest(props, ["groups", "items", "selectedGroups", "selectedItems", "onSelectionChange", "hasMultiselect", "showRadioButtons", "hideSearch", "hideTreeHead", "summary", "hideSummary", "search", "searchPlaceholder", "onSearchChange", "className", "scrollHeight", "expandedGroups", "onExpandGroupsChange", "showEmptyGroups", "treeOptions"]);
|
|
143
|
-
const [state, dispatch] = (0, react_1.useReducer)(treeReducer, {
|
|
45
|
+
const Tree = react_1.default.memo((props) => {
|
|
46
|
+
const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop_1.default, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop_1.default, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop_1.default, showEmptyGroups = true, treeOptions = [], disableAnimation = false } = props, remainingProps = tslib_1.__rest(props, ["groups", "items", "selectedGroups", "selectedItems", "onSelectionChange", "hasMultiselect", "showRadioButtons", "hideSearch", "hideTreeHead", "summary", "hideSummary", "search", "searchPlaceholder", "onSearchChange", "className", "scrollHeight", "expandedGroups", "onExpandGroupsChange", "showEmptyGroups", "treeOptions", "disableAnimation"]);
|
|
47
|
+
const [state, dispatch] = (0, react_1.useReducer)(treeReducer_1.treeReducer, {
|
|
144
48
|
groupedItems: [],
|
|
145
49
|
flatItems: [],
|
|
146
50
|
allChecked: false,
|
|
@@ -150,30 +54,30 @@ const Tree = react_1.default.memo(props => {
|
|
|
150
54
|
visibleTypeCounters: [],
|
|
151
55
|
emptyGroups: [],
|
|
152
56
|
});
|
|
153
|
-
const treeRef = (0, react_1.useRef)();
|
|
57
|
+
const treeRef = (0, react_1.useRef)(null);
|
|
154
58
|
const previousItems = (0, react_1.useRef)();
|
|
155
59
|
const previousGroups = (0, react_1.useRef)();
|
|
156
60
|
const previousSearchValue = (0, react_1.useRef)('');
|
|
157
61
|
const internalExpandedGroups = (0, react_1.useRef)(expandedGroups);
|
|
158
62
|
(0, react_1.useEffect)(() => {
|
|
159
63
|
// Update Tree when items or groups have changed
|
|
160
|
-
if (notEqual(previousItems.current, items) || notEqual(previousGroups.current, groups)) {
|
|
64
|
+
if ((0, treeUtils_1.notEqual)(previousItems.current, items) || (0, treeUtils_1.notEqual)(previousGroups.current, groups)) {
|
|
161
65
|
previousItems.current = items;
|
|
162
66
|
previousGroups.current = groups;
|
|
163
|
-
const typeCounts =
|
|
164
|
-
dispatch(assetCounted(typeCounts));
|
|
67
|
+
const typeCounts = (0, treeUtils_1.getTypeCounts)(items);
|
|
68
|
+
dispatch((0, treeReducer_1.assetCounted)(typeCounts));
|
|
165
69
|
const allChecked = checkAllSelected({ items, groups, selectedItems, selectedGroups }, state.flatItems);
|
|
166
|
-
dispatch(allCheckedChanged(allChecked));
|
|
70
|
+
dispatch((0, treeReducer_1.allCheckedChanged)(allChecked));
|
|
167
71
|
// Get the distinct asset types from the asset list that is passed into the component
|
|
168
72
|
// to know which asset type counter to render
|
|
169
|
-
dispatch(visibleTypeCountersChanged(Object.keys(typeCounts)));
|
|
73
|
+
dispatch((0, treeReducer_1.visibleTypeCountersChanged)(Object.keys(typeCounts)));
|
|
170
74
|
makeTree(groups, items);
|
|
171
75
|
}
|
|
172
76
|
}, [items, groups]);
|
|
173
|
-
const debouncedMakeTree = debounceFn((losGroupos, losItems) => makeTree(losGroupos, losItems));
|
|
77
|
+
const debouncedMakeTree = (0, treeUtils_1.debounceFn)((losGroupos, losItems) => makeTree(losGroupos, losItems));
|
|
174
78
|
(0, react_1.useEffect)(() => {
|
|
175
79
|
// To prevent executing the effect on first render, use a ref to check previous render values
|
|
176
|
-
if (notEqual(previousSearchValue.current, state.searchValue)) {
|
|
80
|
+
if ((0, treeUtils_1.notEqual)(previousSearchValue.current, state.searchValue)) {
|
|
177
81
|
debouncedMakeTree(groups, items);
|
|
178
82
|
previousSearchValue.current = state.searchValue;
|
|
179
83
|
}
|
|
@@ -181,16 +85,22 @@ const Tree = react_1.default.memo(props => {
|
|
|
181
85
|
(0, react_1.useEffect)(() => makeTree(groups, items), [state.typeFilter]);
|
|
182
86
|
// Update tree when empty groups are toggled from outside
|
|
183
87
|
(0, react_1.useEffect)(() => makeTree(groups, items), [showEmptyGroups]);
|
|
184
|
-
// Update
|
|
88
|
+
// Update expanded groups from outside
|
|
89
|
+
const [previousExpandedGroups, setPreviousExpandedGroups] = (0, react_1.useState)(expandedGroups);
|
|
90
|
+
if (!(0, isEqual_1.default)(expandedGroups, previousExpandedGroups)) {
|
|
91
|
+
internalExpandedGroups.current = expandedGroups;
|
|
92
|
+
setPreviousExpandedGroups(expandedGroups);
|
|
93
|
+
}
|
|
94
|
+
// Update "select all" state from outside when groups are selected outside programmatically
|
|
185
95
|
// without using the "select all" checkbox
|
|
186
96
|
(0, react_1.useEffect)(() => {
|
|
187
97
|
const numOfAllGroups = (0, size_1.default)(groups);
|
|
188
98
|
const numOfSelectedGroups = (0, size_1.default)(selectedGroups);
|
|
189
99
|
if (numOfSelectedGroups !== numOfAllGroups && state.allChecked) {
|
|
190
|
-
dispatch(allCheckedChanged(false));
|
|
100
|
+
dispatch((0, treeReducer_1.allCheckedChanged)(false));
|
|
191
101
|
}
|
|
192
|
-
else if (numOfSelectedGroups === numOfAllGroups && !state.allChecked) {
|
|
193
|
-
dispatch(allCheckedChanged(true));
|
|
102
|
+
else if (numOfSelectedGroups !== 0 && numOfSelectedGroups === numOfAllGroups && !state.allChecked) {
|
|
103
|
+
dispatch((0, treeReducer_1.allCheckedChanged)(true));
|
|
194
104
|
}
|
|
195
105
|
}, [selectedGroups]);
|
|
196
106
|
const checkAllSelected = (updatedProps, flatItems) => {
|
|
@@ -201,109 +111,118 @@ const Tree = react_1.default.memo(props => {
|
|
|
201
111
|
return false;
|
|
202
112
|
}
|
|
203
113
|
if (hasNoSearchAndGroups()) {
|
|
204
|
-
const unselectedGroups = (0, filter_1.default)(filterOutByItemId(updatedSelectedGroups))(updatedGroups);
|
|
114
|
+
const unselectedGroups = (0, filter_1.default)((0, treeUtils_1.filterOutByItemId)(updatedSelectedGroups))(updatedGroups);
|
|
205
115
|
return (0, isEmpty_1.default)(unselectedGroups);
|
|
206
116
|
}
|
|
207
117
|
else if (hasSearchAndGroups()) {
|
|
208
|
-
const unselectedSearchItems = (0, filter_1.default)(filterOutByItemId(updatedSelectedItems))(flatItems);
|
|
118
|
+
const unselectedSearchItems = (0, filter_1.default)((0, treeUtils_1.filterOutByItemId)(updatedSelectedItems))(flatItems);
|
|
209
119
|
return (0, isEmpty_1.default)(unselectedSearchItems);
|
|
210
120
|
}
|
|
211
|
-
const unselectedItems = updatedItems.filter(filterOutByItemId(updatedSelectedItems));
|
|
121
|
+
const unselectedItems = updatedItems.filter((0, treeUtils_1.filterOutByItemId)(updatedSelectedItems));
|
|
212
122
|
return (0, isEmpty_1.default)(unselectedItems);
|
|
213
123
|
};
|
|
214
|
-
const handleToggleNode = nodeId => {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
124
|
+
const handleToggleNode = (nodeId) => {
|
|
125
|
+
const nodeContainer = getNodeContainerDomElementById(nodeId);
|
|
126
|
+
if (!(internalExpandedGroups === null || internalExpandedGroups === void 0 ? void 0 : internalExpandedGroups.current) || !nodeContainer) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const openGroups = internalExpandedGroups.current;
|
|
130
|
+
const newExpandedNodes = openGroups.includes(nodeId)
|
|
131
|
+
? openGroups.filter(item => item !== nodeId)
|
|
132
|
+
: [...openGroups, nodeId];
|
|
218
133
|
// Performance improvement to skip on render cycle and change "open" class directly
|
|
219
|
-
if (
|
|
220
|
-
|
|
134
|
+
if (openGroups.includes(nodeId)) {
|
|
135
|
+
nodeContainer.classList.remove('open');
|
|
221
136
|
}
|
|
222
137
|
else {
|
|
223
|
-
|
|
138
|
+
nodeContainer.classList.add('open');
|
|
224
139
|
}
|
|
225
140
|
internalExpandedGroups.current = newExpandedNodes;
|
|
226
141
|
onExpandGroupsChange(newExpandedNodes);
|
|
227
142
|
};
|
|
228
|
-
const getNodeContainerDomElementById = nodeId => {
|
|
229
|
-
|
|
143
|
+
const getNodeContainerDomElementById = (nodeId) => {
|
|
144
|
+
var _a;
|
|
145
|
+
return (_a = treeRef === null || treeRef === void 0 ? void 0 : treeRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.TreeNodeContainer[data-id="${nodeId}"]`);
|
|
230
146
|
};
|
|
231
|
-
const selectAllSearchResultItems = shouldSelect => selectAllFlatItems(shouldSelect);
|
|
232
|
-
const
|
|
233
|
-
const shouldSelectAll = shouldSelect && !
|
|
234
|
-
dispatch(allCheckedChanged(shouldSelectAll));
|
|
147
|
+
const selectAllSearchResultItems = (shouldSelect) => selectAllFlatItems(shouldSelect);
|
|
148
|
+
const handleSelectAll = (shouldSelect, isStateIndeterminate) => {
|
|
149
|
+
const shouldSelectAll = shouldSelect && !isStateIndeterminate;
|
|
150
|
+
dispatch((0, treeReducer_1.allCheckedChanged)(shouldSelectAll));
|
|
235
151
|
(0, cond_1.default)([
|
|
236
152
|
[hasNoSearchAndGroups, () => selectAllGroups(shouldSelectAll)],
|
|
237
153
|
[hasSearchAndGroups, () => selectAllSearchResultItems(shouldSelectAll)],
|
|
238
|
-
[
|
|
154
|
+
[stubTrue_1.default, () => selectAllFlatItems(shouldSelectAll)],
|
|
239
155
|
])();
|
|
240
156
|
};
|
|
241
|
-
const selectAllGroups = shouldSelect => respondSelection([], shouldSelect ? getListIds(groups) : []);
|
|
242
|
-
const selectAllFlatItems = shouldSelect => respondSelection(shouldSelect ? getListIds(state.flatItems) : [], []);
|
|
243
|
-
const respondSelection = (
|
|
244
|
-
onSelectionChange({
|
|
157
|
+
const selectAllGroups = (shouldSelect) => respondSelection([], shouldSelect ? (0, treeUtils_1.getListIds)(groups) : []);
|
|
158
|
+
const selectAllFlatItems = (shouldSelect) => respondSelection(shouldSelect ? (0, treeUtils_1.getListIds)(state.flatItems) : [], []);
|
|
159
|
+
const respondSelection = (updatedSelectedItemIds, updatedSelectedGroupIds) => {
|
|
160
|
+
onSelectionChange({
|
|
161
|
+
items: updatedSelectedItemIds,
|
|
162
|
+
groups: updatedSelectedGroupIds,
|
|
163
|
+
});
|
|
245
164
|
};
|
|
246
|
-
const handleGroupSelection = (group,
|
|
165
|
+
const handleGroupSelection = (group, isStateIndeterminate) => {
|
|
247
166
|
const groupId = group.id;
|
|
248
167
|
const isSelected = selectedGroups.includes(groupId);
|
|
249
|
-
const shouldSelectGroup = !isSelected && !
|
|
168
|
+
const shouldSelectGroup = !isSelected && !isStateIndeterminate;
|
|
250
169
|
// handle group selection
|
|
251
170
|
const newSelectedGroups = shouldSelectGroup
|
|
252
171
|
? [...selectedGroups, groupId]
|
|
253
|
-
: (0,
|
|
172
|
+
: (0, treeUtils_1.excludeFromList)(selectedGroups, groupId);
|
|
254
173
|
// deselect all items of a node since they will be selected inherently via the group itself
|
|
255
|
-
const itemsInGroup = (0, find_1.default)(entry => entry.id === groupId)(state.groupedItems);
|
|
256
|
-
const itemIdsOfGroup = (0, map_1.default)(item => item.id)(itemsInGroup.items);
|
|
174
|
+
const itemsInGroup = (0, find_1.default)((entry) => entry.id === groupId)(state.groupedItems);
|
|
175
|
+
const itemIdsOfGroup = (0, map_1.default)((item) => item.id)(itemsInGroup === null || itemsInGroup === void 0 ? void 0 : itemsInGroup.items);
|
|
257
176
|
const updatedSelectedItems = (0, without_1.default)(itemIdsOfGroup, selectedItems);
|
|
258
177
|
// check if all groups are selected to change the state of TreeSelectAll
|
|
259
178
|
const groupAmount = groups.length;
|
|
260
179
|
const emptyGroupAmount = showEmptyGroups ? 0 : state.emptyGroups.length;
|
|
261
180
|
const totalGroupAmount = groupAmount - emptyGroupAmount;
|
|
262
181
|
const areAllGroupsChecked = totalGroupAmount === newSelectedGroups.length;
|
|
263
|
-
dispatch(allCheckedChanged(areAllGroupsChecked));
|
|
182
|
+
dispatch((0, treeReducer_1.allCheckedChanged)(areAllGroupsChecked));
|
|
264
183
|
respondSelection(updatedSelectedItems, newSelectedGroups);
|
|
265
184
|
};
|
|
266
|
-
const handleSearchChange = updatedSearchValue => {
|
|
185
|
+
const handleSearchChange = (updatedSearchValue) => {
|
|
267
186
|
onSearchChange(updatedSearchValue);
|
|
268
|
-
dispatch(searchValueChanged(updatedSearchValue));
|
|
187
|
+
dispatch((0, treeReducer_1.searchValueChanged)(updatedSearchValue));
|
|
269
188
|
};
|
|
270
|
-
const hasGroups = () => groups && notEmpty(groups);
|
|
189
|
+
const hasGroups = () => groups && (0, treeUtils_1.notEmpty)(groups);
|
|
271
190
|
const hasSearchAndGroups = () => hasInternalSearchValue() && hasGroups();
|
|
272
191
|
const hasNoSearchAndGroups = () => !hasInternalSearchValue() && hasGroups();
|
|
273
|
-
const setFlatItemList = (
|
|
274
|
-
const flatItems = getFlatItems(
|
|
275
|
-
dispatch(
|
|
276
|
-
dispatch(flatItemsChanged(flatItems));
|
|
192
|
+
const setFlatItemList = (updatedItems, searchValue) => {
|
|
193
|
+
const flatItems = (0, treeUtils_1.getFlatItems)(updatedItems, searchValue);
|
|
194
|
+
dispatch((0, treeReducer_1.flatItemsChanged)(flatItems));
|
|
277
195
|
};
|
|
278
196
|
const setGroupedItemList = (groupsToProcess, itemsToProcess, considerEmptyGroups) => {
|
|
279
197
|
// Map items to groups with filtered items
|
|
280
|
-
const mappedItemsToGroups = getMappedItemsToGroups(groupsToProcess, itemsToProcess);
|
|
281
|
-
const newGroupedItems = (0, flow_1.default)(sortGroupsByName, sortGroupItemsByName)(mappedItemsToGroups);
|
|
282
|
-
const groupedItems = considerEmptyGroups ? newGroupedItems : filterEmptyGroups(newGroupedItems);
|
|
198
|
+
const mappedItemsToGroups = (0, treeUtils_1.getMappedItemsToGroups)(groupsToProcess, itemsToProcess);
|
|
199
|
+
const newGroupedItems = (0, flow_1.default)(treeUtils_1.sortGroupsByName, treeUtils_1.sortGroupItemsByName)(mappedItemsToGroups);
|
|
200
|
+
const groupedItems = considerEmptyGroups ? newGroupedItems : (0, treeUtils_1.filterEmptyGroups)(newGroupedItems);
|
|
283
201
|
// Keep the empty groups in memory for later access in select all, without re-iterating on every
|
|
284
202
|
// group selection
|
|
285
|
-
const emptyGroups = (0, filter_1.default)(group => (0, isEmpty_1.default)(group.items))(newGroupedItems);
|
|
286
|
-
dispatch(emptyGroupsChanged(emptyGroups));
|
|
287
|
-
dispatch(assetCounted(
|
|
288
|
-
dispatch(groupedItemsChanged(groupedItems));
|
|
203
|
+
const emptyGroups = (0, filter_1.default)((group) => (0, isEmpty_1.default)(group.items))(newGroupedItems);
|
|
204
|
+
dispatch((0, treeReducer_1.emptyGroupsChanged)(emptyGroups));
|
|
205
|
+
dispatch((0, treeReducer_1.assetCounted)((0, treeUtils_1.getTypeCounts)(items)));
|
|
206
|
+
dispatch((0, treeReducer_1.groupedItemsChanged)(groupedItems));
|
|
207
|
+
// Update expanded groups again
|
|
289
208
|
};
|
|
290
209
|
const makeTree = (updatedGroups, updatedItems) => {
|
|
291
210
|
const internalSearchValue = state.searchValue;
|
|
292
211
|
const internalTypeFilter = state.typeFilter;
|
|
293
212
|
const groupsToProcess = updatedGroups;
|
|
294
213
|
const itemsToProcess = updatedItems;
|
|
295
|
-
const hasGroupList = groupList => groupList && notEmpty(groupList);
|
|
214
|
+
const hasGroupList = (groupList) => groupList && (0, treeUtils_1.notEmpty)(groupList);
|
|
296
215
|
const hasNoInternalSearchAndGroups = () => (0, isEmpty_1.default)(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
297
|
-
const hasInternalSearchAndGroups = () => notEmpty(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
216
|
+
const hasInternalSearchAndGroups = () => (0, treeUtils_1.notEmpty)(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
298
217
|
const filteredItems = (0, isEmpty_1.default)(internalTypeFilter)
|
|
299
218
|
? itemsToProcess
|
|
300
|
-
: filterAssetByType(internalTypeFilter)(itemsToProcess);
|
|
219
|
+
: (0, treeUtils_1.filterAssetByType)(internalTypeFilter)(itemsToProcess);
|
|
301
220
|
const setGroupedItems = () => setGroupedItemList(groupsToProcess, filteredItems, showEmptyGroups);
|
|
302
221
|
const setFlatItems = () => setFlatItemList(filteredItems, internalSearchValue);
|
|
303
222
|
(0, cond_1.default)([
|
|
304
223
|
[hasNoInternalSearchAndGroups, setGroupedItems],
|
|
305
224
|
[hasInternalSearchAndGroups, setFlatItems],
|
|
306
|
-
[
|
|
225
|
+
[stubTrue_1.default, setFlatItems],
|
|
307
226
|
])();
|
|
308
227
|
};
|
|
309
228
|
const renderTree = () => {
|
|
@@ -311,14 +230,15 @@ const Tree = react_1.default.memo(props => {
|
|
|
311
230
|
if ((0, isEmpty_1.default)(groupedItems)) {
|
|
312
231
|
return (0, jsx_runtime_1.jsx)(TreeNothingFound_1.default, {});
|
|
313
232
|
}
|
|
314
|
-
const result = (0, map_1.default)(group => {
|
|
233
|
+
const result = (0, map_1.default)((group) => {
|
|
234
|
+
var _a, _b;
|
|
315
235
|
const groupId = group.id;
|
|
316
236
|
const groupItems = group.items;
|
|
317
|
-
const isOpen =
|
|
318
|
-
const numSelectedGroupItems = (0, filter_1.default)(containsItemById(selectedItems))(groupItems).length;
|
|
237
|
+
const isOpen = (_b = (_a = internalExpandedGroups.current) === null || _a === void 0 ? void 0 : _a.includes(groupId)) !== null && _b !== void 0 ? _b : false;
|
|
238
|
+
const numSelectedGroupItems = (0, filter_1.default)((0, treeUtils_1.containsItemById)(selectedItems))(groupItems).length;
|
|
319
239
|
const isGroupSelected = selectedGroups.includes(groupId);
|
|
320
|
-
const
|
|
321
|
-
return ((0, jsx_runtime_1.jsxs)(TreeNodeContainer_1.default, Object.assign({ groupId: groupId, isOpen: isOpen }, { children: [(0, jsx_runtime_1.jsx)(TreeNode_1.default, { node: group, hasMultiselect: hasMultiselect, onToggleNode: handleToggleNode, onSelect: handleGroupSelection, isSelected: isGroupSelected, isIndeterminate:
|
|
240
|
+
const isStateIndeterminate = !isGroupSelected && numSelectedGroupItems > 0;
|
|
241
|
+
return ((0, jsx_runtime_1.jsxs)(TreeNodeContainer_1.default, Object.assign({ groupId: groupId, isOpen: isOpen, disableAnimation: disableAnimation }, { children: [(0, jsx_runtime_1.jsx)(TreeNode_1.default, { node: group, hasMultiselect: hasMultiselect, onToggleNode: handleToggleNode, onSelect: handleGroupSelection, isSelected: isGroupSelected, isIndeterminate: isStateIndeterminate }), (0, jsx_runtime_1.jsx)(TreeLeafList_1.default, { leafList: groupItems, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, selectedItems: selectedItems, selectedGroups: selectedGroups, onSelectionChange: respondSelection })] }), groupId));
|
|
322
242
|
})(groupedItems);
|
|
323
243
|
return result;
|
|
324
244
|
};
|
|
@@ -326,144 +246,41 @@ const Tree = react_1.default.memo(props => {
|
|
|
326
246
|
const { flatItems } = state;
|
|
327
247
|
const hasLeafs = (0, isEmpty_1.default)(flatItems);
|
|
328
248
|
const getLeafs = () => ((0, jsx_runtime_1.jsx)(TreeLeafList_1.default, { leafList: flatItems, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, selectedItems: selectedItems, selectedGroups: selectedGroups, onSelectionChange: respondSelection }));
|
|
329
|
-
return (0, jsx_runtime_1.jsx)(TreeNodeContainer_1.default, Object.assign({ isOpen: true }, { children: hasLeafs ? (0, jsx_runtime_1.jsx)(TreeNothingFound_1.default, {}) : getLeafs() }));
|
|
249
|
+
return ((0, jsx_runtime_1.jsx)(TreeNodeContainer_1.default, Object.assign({ disableAnimation: disableAnimation, isOpen: true }, { children: hasLeafs ? (0, jsx_runtime_1.jsx)(TreeNothingFound_1.default, {}) : getLeafs() })));
|
|
330
250
|
};
|
|
331
|
-
const hasExternalGroups = notEmpty(groups);
|
|
332
|
-
const hasInternalSearchValue = () => notEmpty(state.searchValue);
|
|
251
|
+
const hasExternalGroups = (0, treeUtils_1.notEmpty)(groups);
|
|
252
|
+
const hasInternalSearchValue = () => (0, treeUtils_1.notEmpty)(state.searchValue);
|
|
333
253
|
const hasSelectedAllItems = () => (0, isEqual_1.default)((0, size_1.default)(selectedItems), (0, size_1.default)(state.flatItems));
|
|
334
|
-
const
|
|
254
|
+
const hasPartiallySelectedItems = () => (0, treeUtils_1.notEmpty)(selectedItems) && !hasSelectedAllItems();
|
|
335
255
|
const hasSelectedAllGroups = () => {
|
|
336
256
|
const emptyGroupAmount = showEmptyGroups ? 0 : state.emptyGroups.length;
|
|
337
257
|
return (0, isEqual_1.default)((0, size_1.default)(selectedGroups), (0, size_1.default)(groups) - emptyGroupAmount);
|
|
338
258
|
};
|
|
339
|
-
const
|
|
259
|
+
const hasPartiallySelectedGroups = () => hasExternalGroups && (0, treeUtils_1.notEmpty)(selectedGroups) && !hasSelectedAllGroups();
|
|
340
260
|
const hasSearchAndNoItems = hasInternalSearchValue() && (0, isEmpty_1.default)(state.flatItems);
|
|
341
261
|
const hasSearchAndNoGroups = hasInternalSearchValue() && (0, isEmpty_1.default)(state.groupedItems) && hasExternalGroups;
|
|
342
262
|
const hideSelectAll = hasSearchAndNoItems || hasSearchAndNoGroups;
|
|
343
|
-
const isIndeterminate =
|
|
344
|
-
const treeClassNames = (0, classnames_1.default)('Tree', className);
|
|
263
|
+
const isIndeterminate = hasPartiallySelectedGroups() || hasPartiallySelectedItems();
|
|
264
|
+
const treeClassNames = (0, classnames_1.default)('Tree', 'overflow-x-hidden', className);
|
|
345
265
|
const treeHeadClasses = (0, classnames_1.default)('TreeHead', 'display-flex gap-5', 'padding-15');
|
|
346
266
|
const shouldRenderTree = () => hasGroups() && !hasInternalSearchValue();
|
|
347
267
|
const content = (0, cond_1.default)([
|
|
348
268
|
[shouldRenderTree, () => renderTree()],
|
|
349
|
-
[
|
|
269
|
+
[stubTrue_1.default, () => renderFlatList()],
|
|
350
270
|
])();
|
|
351
|
-
const handleFilterByType = type => {
|
|
352
|
-
|
|
353
|
-
if (currentTypeFilter.has(type)) {
|
|
354
|
-
currentTypeFilter.delete(type);
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
currentTypeFilter.add(type);
|
|
358
|
-
}
|
|
359
|
-
dispatch(typeFilterChanged([...currentTypeFilter]));
|
|
360
|
-
};
|
|
361
|
-
const putItemsFirst = ({ findFunction, array }) => [
|
|
362
|
-
...array.filter(findFunction),
|
|
363
|
-
...array.filter(item => !findFunction(item)),
|
|
364
|
-
];
|
|
365
|
-
const sortVisibleTypeCounters = array => {
|
|
366
|
-
let sortedVisibleTypeCounters = array;
|
|
367
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
368
|
-
array: sortedVisibleTypeCounters,
|
|
369
|
-
findFunction: item => item === 'fuel-netgas',
|
|
370
|
-
});
|
|
371
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
372
|
-
array: sortedVisibleTypeCounters,
|
|
373
|
-
findFunction: item => item === 'fuel-hydrogen',
|
|
374
|
-
});
|
|
375
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
376
|
-
array: sortedVisibleTypeCounters,
|
|
377
|
-
findFunction: item => item === 'fuel-electric',
|
|
378
|
-
});
|
|
379
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
380
|
-
array: sortedVisibleTypeCounters,
|
|
381
|
-
findFunction: item => item === 'fuel-petrol',
|
|
382
|
-
});
|
|
383
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
384
|
-
array: sortedVisibleTypeCounters,
|
|
385
|
-
findFunction: item => item === 'trailer',
|
|
386
|
-
});
|
|
387
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
388
|
-
array: sortedVisibleTypeCounters,
|
|
389
|
-
findFunction: item => item === 'van',
|
|
390
|
-
});
|
|
391
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
392
|
-
array: sortedVisibleTypeCounters,
|
|
393
|
-
findFunction: item => item === 'bus',
|
|
394
|
-
});
|
|
395
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
396
|
-
array: sortedVisibleTypeCounters,
|
|
397
|
-
findFunction: item => item === 'truck',
|
|
398
|
-
});
|
|
399
|
-
return sortedVisibleTypeCounters;
|
|
271
|
+
const handleFilterByType = (type) => {
|
|
272
|
+
dispatch((0, treeReducer_1.typeFilterChanged)((0, treeUtils_1.addOrRemoveFromList)(state.typeFilter, type)));
|
|
400
273
|
};
|
|
401
|
-
const
|
|
402
|
-
const isFilterActive = notEmpty(state.typeFilter);
|
|
274
|
+
const enableActivity = (0, size_1.default)(state.visibleTypeCounters) !== 1;
|
|
275
|
+
const isFilterActive = (0, treeUtils_1.notEmpty)(state.typeFilter);
|
|
403
276
|
const showTreeHead = !hideTreeHead;
|
|
404
277
|
const showSelectAll = !hideSelectAll;
|
|
405
278
|
const showSearch = !hideSearch;
|
|
406
279
|
const showSummary = !hideSummary;
|
|
407
280
|
const hasCustomSearch = !(0, isNil_1.default)(search);
|
|
408
|
-
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: treeClassNames, ref: treeRef }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: 'TreeHeader' }, { children: [showSearch && !hasCustomSearch && ((0, jsx_runtime_1.jsx)(TreeSearch_1.default, { value: state.searchValue, onChange: handleSearchChange, placeholder: searchPlaceholder })), hasCustomSearch && search, showTreeHead && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: treeHeadClasses }, { children: [showSelectAll && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'border border-right-only hidden-empty padding-right-10 margin-right-2' }, { children: (0, jsx_runtime_1.jsx)(TreeSelectAll_1.default, { isChecked: state.allChecked, isEnabled: hasMultiselect, isIndeterminate: isIndeterminate, onSelect:
|
|
409
|
-
? summary || ((0, jsx_runtime_1.jsx)(TreeSummary_1.default, { children: (0, map_1.default)(typeCounter => ((0, jsx_runtime_1.jsx)(TypeCounter_1.default, { type: typeCounter, icon: `${typeCounter}`, value: state.assetCounts[typeCounter], onClick: handleFilterByType, isActive: state.typeFilter.includes(typeCounter), hasFilter: isFilterActive, enableActivity:
|
|
410
|
-
: null })), (0, jsx_runtime_1.jsx)(TreeOptions_1.default, { treeOptions: treeOptions })] })))] })), (0, jsx_runtime_1.jsx)(TreeRoot_1.default, Object.assign({ maxHeight: scrollHeight }, { children: content }))] })));
|
|
281
|
+
return ((0, jsx_runtime_1.jsxs)("div", Object.assign({}, remainingProps, { className: treeClassNames, ref: treeRef }, { children: [(0, jsx_runtime_1.jsxs)("div", Object.assign({ className: 'TreeHeader' }, { children: [showSearch && !hasCustomSearch && ((0, jsx_runtime_1.jsx)(TreeSearch_1.default, { value: state.searchValue, onChange: handleSearchChange, placeholder: searchPlaceholder })), hasCustomSearch && search, showTreeHead && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: treeHeadClasses }, { children: [showSelectAll && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'border border-right-only hidden-empty padding-right-10 margin-right-2' }, { children: (0, jsx_runtime_1.jsx)(TreeSelectAll_1.default, { isChecked: state.allChecked, isEnabled: hasMultiselect, isIndeterminate: isIndeterminate, onSelect: handleSelectAll }) }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'display-flex justify-content-between align-items-start width-100pct' }, { children: showSummary
|
|
282
|
+
? summary || ((0, jsx_runtime_1.jsx)(TreeSummary_1.default, { children: (0, map_1.default)((typeCounter) => ((0, jsx_runtime_1.jsx)(TypeCounter_1.default, { type: typeCounter, icon: `${typeCounter}`, value: state.assetCounts[typeCounter], onClick: handleFilterByType, isActive: state.typeFilter.includes(typeCounter), hasFilter: isFilterActive, enableActivity: enableActivity }, typeCounter)))(state.visibleTypeCounters) }))
|
|
283
|
+
: null })), (0, jsx_runtime_1.jsx)(TreeOptions_1.default, { treeOptions: treeOptions })] })))] })), (0, jsx_runtime_1.jsx)(TreeRoot_1.default, Object.assign({ maxHeight: scrollHeight, disableAnimation: disableAnimation }, { children: content }))] })));
|
|
411
284
|
}, customCompare);
|
|
412
285
|
Tree.displayName = 'Tree';
|
|
413
|
-
Tree.defaultProps = {
|
|
414
|
-
hasMultiselect: true,
|
|
415
|
-
showRadioButtons: false,
|
|
416
|
-
hideSearch: false,
|
|
417
|
-
hideSummary: false,
|
|
418
|
-
showEmptyGroups: true,
|
|
419
|
-
selectedGroups: [],
|
|
420
|
-
selectedItems: [],
|
|
421
|
-
onSelectionChange: () => { },
|
|
422
|
-
onExpandGroupsChange: () => { },
|
|
423
|
-
onSearchChange: () => { },
|
|
424
|
-
searchPlaceholder: 'Type here to filter by name',
|
|
425
|
-
treeOptions: [],
|
|
426
|
-
groups: [],
|
|
427
|
-
};
|
|
428
|
-
Tree.propTypes = {
|
|
429
|
-
groups: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
430
|
-
id: prop_types_1.default.string.isRequired,
|
|
431
|
-
name: prop_types_1.default.string.isRequired,
|
|
432
|
-
icon: prop_types_1.default.string,
|
|
433
|
-
className: prop_types_1.default.string,
|
|
434
|
-
})),
|
|
435
|
-
items: prop_types_1.default.arrayOf(prop_types_1.default.shape({
|
|
436
|
-
id: prop_types_1.default.string.isRequired,
|
|
437
|
-
name: prop_types_1.default.oneOfType([
|
|
438
|
-
prop_types_1.default.string,
|
|
439
|
-
prop_types_1.default.shape({
|
|
440
|
-
firstName: prop_types_1.default.string,
|
|
441
|
-
lastName: prop_types_1.default.string.isRequired,
|
|
442
|
-
}),
|
|
443
|
-
]).isRequired,
|
|
444
|
-
info: prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.node]),
|
|
445
|
-
type: prop_types_1.default.string.isRequired,
|
|
446
|
-
groupIds: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
447
|
-
className: prop_types_1.default.string,
|
|
448
|
-
})),
|
|
449
|
-
selectedGroups: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
450
|
-
selectedItems: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
451
|
-
onSelectionChange: prop_types_1.default.func,
|
|
452
|
-
hasMultiselect: prop_types_1.default.bool,
|
|
453
|
-
showRadioButtons: prop_types_1.default.bool,
|
|
454
|
-
hideSearch: prop_types_1.default.bool,
|
|
455
|
-
summary: prop_types_1.default.node,
|
|
456
|
-
hideSummary: prop_types_1.default.bool,
|
|
457
|
-
hideTreeHead: prop_types_1.default.bool,
|
|
458
|
-
// This defines a custom search component.
|
|
459
|
-
search: prop_types_1.default.node,
|
|
460
|
-
searchPlaceholder: prop_types_1.default.string,
|
|
461
|
-
onSearchChange: prop_types_1.default.func,
|
|
462
|
-
className: prop_types_1.default.string,
|
|
463
|
-
scrollHeight: prop_types_1.default.number,
|
|
464
|
-
expandedGroups: prop_types_1.default.arrayOf(prop_types_1.default.string),
|
|
465
|
-
onExpandGroupsChange: prop_types_1.default.func,
|
|
466
|
-
showEmptyGroups: prop_types_1.default.bool,
|
|
467
|
-
treeOptions: prop_types_1.default.arrayOf(prop_types_1.default.node),
|
|
468
|
-
};
|
|
469
286
|
exports.default = Tree;
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
export type TreeCategoryProps = {
|
|
3
|
+
/**
|
|
4
|
+
* A unique identifier for that category.
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* The rioglyph icon name for that category.
|
|
9
|
+
*/
|
|
10
|
+
icon: string;
|
|
11
|
+
/**
|
|
12
|
+
* The optional label for the category which will be shown in a tooltip.
|
|
13
|
+
*/
|
|
14
|
+
label?: string | React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Defines whether or not a selection indicator should be shown.
|
|
17
|
+
*/
|
|
18
|
+
hasSelection?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type TreeCategoryNode = React.ReactElement<TreeCategoryProps>;
|
|
21
|
+
declare const TreeCategory: {
|
|
22
|
+
(props: PropsWithChildren<TreeCategoryProps>): string | number | true | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
1
25
|
export default TreeCategory;
|
|
2
|
-
declare function TreeCategory(props: any): any;
|
|
3
|
-
declare namespace TreeCategory {
|
|
4
|
-
const displayName: string;
|
|
5
|
-
namespace propTypes {
|
|
6
|
-
const id: PropTypes.Validator<string>;
|
|
7
|
-
const icon: PropTypes.Validator<string>;
|
|
8
|
-
const label: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
9
|
-
const hasSelection: PropTypes.Requireable<boolean>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
import PropTypes from "prop-types";
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const prop_types_1 = tslib_1.__importDefault(require("prop-types"));
|
|
5
|
-
const TreeCategory = props => props.children || null;
|
|
3
|
+
const TreeCategory = (props) => props.children || null;
|
|
6
4
|
TreeCategory.displayName = 'TreeCategory';
|
|
7
|
-
TreeCategory.propTypes = {
|
|
8
|
-
id: prop_types_1.default.string.isRequired,
|
|
9
|
-
icon: prop_types_1.default.string.isRequired,
|
|
10
|
-
label: prop_types_1.default.oneOfType([prop_types_1.default.string, prop_types_1.default.node]),
|
|
11
|
-
hasSelection: prop_types_1.default.bool,
|
|
12
|
-
};
|
|
13
5
|
exports.default = TreeCategory;
|