@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,28 +1,21 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/* eslint-disable no-use-before-define */
|
|
4
|
-
import React, { useEffect, useReducer, useRef } from 'react';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useEffect, useReducer, useRef, useState } from 'react';
|
|
6
5
|
import classNames from 'classnames';
|
|
7
6
|
import isNil from 'lodash/fp/isNil';
|
|
8
7
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
9
8
|
import isEqual from 'lodash/fp/isEqual';
|
|
10
9
|
import map from 'lodash/fp/map';
|
|
11
10
|
import find from 'lodash/fp/find';
|
|
12
|
-
import orderBy from 'lodash/fp/orderBy';
|
|
13
|
-
import isObject from 'lodash/fp/isObject';
|
|
14
|
-
import debounce from 'lodash/fp/debounce';
|
|
15
11
|
import cond from 'lodash/fp/cond';
|
|
16
12
|
import without from 'lodash/fp/without';
|
|
17
|
-
import countBy from 'lodash/fp/countBy';
|
|
18
|
-
import getOr from 'lodash/fp/getOr';
|
|
19
13
|
import flow from 'lodash/fp/flow';
|
|
20
14
|
import filter from 'lodash/fp/filter';
|
|
21
15
|
import size from 'lodash/fp/size';
|
|
22
|
-
import
|
|
16
|
+
import otherwise from 'lodash/fp/stubTrue';
|
|
23
17
|
import omit from 'lodash/fp/omit';
|
|
24
|
-
import
|
|
25
|
-
import keys from 'lodash/fp/keys';
|
|
18
|
+
import noop from 'lodash/fp/noop';
|
|
26
19
|
import TreeSearch from './TreeSearch';
|
|
27
20
|
import TreeSelectAll from './TreeSelectAll';
|
|
28
21
|
import TreeSummary from './TreeSummary';
|
|
@@ -33,71 +26,9 @@ import TreeNothingFound from './TreeNothingFound';
|
|
|
33
26
|
import TreeOptions from './TreeOptions';
|
|
34
27
|
import TreeRoot from './TreeRoot';
|
|
35
28
|
import TypeCounter from './TypeCounter';
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
const otherwise = stubTrue;
|
|
40
|
-
const notEqual = negate(isEqual);
|
|
41
|
-
const notEmpty = negate(isEmpty);
|
|
42
|
-
const isNameObject = item => isObject(item.name);
|
|
43
|
-
const getFullName = item => `${item.name.firstName} ${item.name.lastName}`;
|
|
44
|
-
const getName = item => (isNameObject(item) ? getFullName(item) : item.name);
|
|
45
|
-
const getLowerCaseName = item => getOr('', 'name')(item).toLowerCase();
|
|
46
|
-
const getLowerCaseLastName = item => getOr('', 'name.lastName')(item).toLowerCase();
|
|
47
|
-
const orderByName = orderBy([item => (isNameObject(item) ? getLowerCaseLastName(item) : getLowerCaseName(item))], ['asc']);
|
|
48
|
-
const filterEmptyGroups = filter(group => notEmpty(group.items));
|
|
49
|
-
const filterAssetByType = (types = []) => filter(asset => types.includes(asset.type));
|
|
50
|
-
const sortGroupsByName = groups => {
|
|
51
|
-
const fixedGroups = {};
|
|
52
|
-
const sortableGroups = {};
|
|
53
|
-
map(group => {
|
|
54
|
-
if (group.position === 'last') {
|
|
55
|
-
fixedGroups[group.id] = Object.assign({}, group);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
sortableGroups[group.id] = Object.assign({}, group);
|
|
59
|
-
}
|
|
60
|
-
})(groups);
|
|
61
|
-
const sortedGroups = orderByName(sortableGroups);
|
|
62
|
-
return isEmpty(fixedGroups) ? sortedGroups : Object.assign(Object.assign({}, sortedGroups), fixedGroups);
|
|
63
|
-
};
|
|
64
|
-
const sortGroupItemsByName = groups => {
|
|
65
|
-
const sortedGroups = {};
|
|
66
|
-
map(group => {
|
|
67
|
-
sortedGroups[group.id] = Object.assign(Object.assign({}, group), { items: orderByName(group.items) });
|
|
68
|
-
})(groups);
|
|
69
|
-
return sortedGroups;
|
|
70
|
-
};
|
|
71
|
-
const getMappedItemsToGroups = (groups, items) => {
|
|
72
|
-
const mappedGroups = {};
|
|
73
|
-
// build an object for listing the groups by id
|
|
74
|
-
groups.forEach(group => {
|
|
75
|
-
mappedGroups[group.id] = Object.assign(Object.assign({}, group), { items: [] });
|
|
76
|
-
});
|
|
77
|
-
items.forEach(item => {
|
|
78
|
-
// add items to the respective group
|
|
79
|
-
const groupIds = item.groupIds || [];
|
|
80
|
-
groupIds.forEach(groupId => {
|
|
81
|
-
const mappedGroup = mappedGroups[groupId];
|
|
82
|
-
if (mappedGroup) {
|
|
83
|
-
mappedGroup.items.push(item);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
return mappedGroups;
|
|
88
|
-
};
|
|
89
|
-
const filterByName = searchValue => item => {
|
|
90
|
-
if (searchValue) {
|
|
91
|
-
return searchNormalized(getName(item), searchValue);
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
};
|
|
95
|
-
const filterOutByItemId = list => item => !list.includes(item.id);
|
|
96
|
-
const containsItemById = list => item => list.includes(item.id);
|
|
97
|
-
const getFlatItems = (items, searchValue) => flow(filter(filterByName(searchValue)), orderByName)(items);
|
|
98
|
-
const getListIds = list => list.map(listItem => listItem.id);
|
|
99
|
-
const getAssetTypeCounts = items => countBy(item => item.type, items);
|
|
100
|
-
const debounceFn = fn => debounce(SEARCH_DEBOUNCE, fn);
|
|
29
|
+
import { containsItemById, debounceFn, filterAssetByType, filterEmptyGroups, filterOutByItemId, getTypeCounts, getFlatItems, getListIds, notEmpty, notEqual, excludeFromList, getMappedItemsToGroups, sortGroupItemsByName, sortGroupsByName, addOrRemoveFromList, } from './treeUtils';
|
|
30
|
+
import { treeReducer, assetCounted, allCheckedChanged, visibleTypeCountersChanged, searchValueChanged, flatItemsChanged, emptyGroupsChanged, groupedItemsChanged, typeFilterChanged, } from './treeReducer';
|
|
31
|
+
export { getTypeCounts, getSubTypeCounts } from './treeUtils';
|
|
101
32
|
const filterProps = omit([
|
|
102
33
|
'expandedGroups',
|
|
103
34
|
'onExpandGroupsChange',
|
|
@@ -106,38 +37,8 @@ const filterProps = omit([
|
|
|
106
37
|
'treeOptions',
|
|
107
38
|
]);
|
|
108
39
|
const customCompare = (prevProps, nextProps) => isEqual(filterProps(prevProps), filterProps(nextProps));
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const searchValueChanged = payload => ({ type: 'searchValueChanged', payload });
|
|
112
|
-
const flatItemsChanged = payload => ({ type: 'flatItemsChanged', payload });
|
|
113
|
-
const groupedItemsChanged = payload => ({ type: 'groupedItemsChanged', payload });
|
|
114
|
-
const typeFilterChanged = payload => ({ type: 'typeFilterChanged', payload });
|
|
115
|
-
const visibleTypeCountersChanged = payload => ({ type: 'visibleTypeCountersChanged', payload });
|
|
116
|
-
const emptyGroupsChanged = payload => ({ type: 'emptyGroupsChanged', payload });
|
|
117
|
-
const treeReducer = (state, action) => {
|
|
118
|
-
switch (action.type) {
|
|
119
|
-
case 'assetCounted':
|
|
120
|
-
return Object.assign(Object.assign({}, state), { assetCounts: action.payload });
|
|
121
|
-
case 'allCheckedChanged':
|
|
122
|
-
return Object.assign(Object.assign({}, state), { allChecked: action.payload });
|
|
123
|
-
case 'searchValueChanged':
|
|
124
|
-
return Object.assign(Object.assign({}, state), { searchValue: action.payload, allChecked: false });
|
|
125
|
-
case 'flatItemsChanged':
|
|
126
|
-
return Object.assign(Object.assign({}, state), { flatItems: action.payload });
|
|
127
|
-
case 'groupedItemsChanged':
|
|
128
|
-
return Object.assign(Object.assign({}, state), { groupedItems: action.payload });
|
|
129
|
-
case 'typeFilterChanged':
|
|
130
|
-
return Object.assign(Object.assign({}, state), { typeFilter: action.payload });
|
|
131
|
-
case 'visibleTypeCountersChanged':
|
|
132
|
-
return Object.assign(Object.assign({}, state), { visibleTypeCounters: action.payload });
|
|
133
|
-
case 'emptyGroupsChanged':
|
|
134
|
-
return Object.assign(Object.assign({}, state), { emptyGroups: action.payload });
|
|
135
|
-
default:
|
|
136
|
-
throw new Error();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
const Tree = React.memo(props => {
|
|
140
|
-
const { groups, items, selectedGroups, selectedItems, onSelectionChange, hasMultiselect, showRadioButtons, hideSearch, hideTreeHead, summary, hideSummary, search, searchPlaceholder, onSearchChange, className, scrollHeight, expandedGroups, onExpandGroupsChange, showEmptyGroups, treeOptions } = props, remainingProps = __rest(props, ["groups", "items", "selectedGroups", "selectedItems", "onSelectionChange", "hasMultiselect", "showRadioButtons", "hideSearch", "hideTreeHead", "summary", "hideSummary", "search", "searchPlaceholder", "onSearchChange", "className", "scrollHeight", "expandedGroups", "onExpandGroupsChange", "showEmptyGroups", "treeOptions"]);
|
|
40
|
+
const Tree = React.memo((props) => {
|
|
41
|
+
const { groups = [], items = [], selectedGroups = [], selectedItems = [], onSelectionChange = noop, hasMultiselect = true, showRadioButtons = false, hideSearch = false, hideTreeHead, summary, hideSummary = false, search, searchPlaceholder = 'Type here to filter by name', onSearchChange = noop, className, scrollHeight, expandedGroups, onExpandGroupsChange = noop, showEmptyGroups = true, treeOptions = [], disableAnimation = false } = props, remainingProps = __rest(props, ["groups", "items", "selectedGroups", "selectedItems", "onSelectionChange", "hasMultiselect", "showRadioButtons", "hideSearch", "hideTreeHead", "summary", "hideSummary", "search", "searchPlaceholder", "onSearchChange", "className", "scrollHeight", "expandedGroups", "onExpandGroupsChange", "showEmptyGroups", "treeOptions", "disableAnimation"]);
|
|
141
42
|
const [state, dispatch] = useReducer(treeReducer, {
|
|
142
43
|
groupedItems: [],
|
|
143
44
|
flatItems: [],
|
|
@@ -148,7 +49,7 @@ const Tree = React.memo(props => {
|
|
|
148
49
|
visibleTypeCounters: [],
|
|
149
50
|
emptyGroups: [],
|
|
150
51
|
});
|
|
151
|
-
const treeRef = useRef();
|
|
52
|
+
const treeRef = useRef(null);
|
|
152
53
|
const previousItems = useRef();
|
|
153
54
|
const previousGroups = useRef();
|
|
154
55
|
const previousSearchValue = useRef('');
|
|
@@ -158,7 +59,7 @@ const Tree = React.memo(props => {
|
|
|
158
59
|
if (notEqual(previousItems.current, items) || notEqual(previousGroups.current, groups)) {
|
|
159
60
|
previousItems.current = items;
|
|
160
61
|
previousGroups.current = groups;
|
|
161
|
-
const typeCounts =
|
|
62
|
+
const typeCounts = getTypeCounts(items);
|
|
162
63
|
dispatch(assetCounted(typeCounts));
|
|
163
64
|
const allChecked = checkAllSelected({ items, groups, selectedItems, selectedGroups }, state.flatItems);
|
|
164
65
|
dispatch(allCheckedChanged(allChecked));
|
|
@@ -179,7 +80,13 @@ const Tree = React.memo(props => {
|
|
|
179
80
|
useEffect(() => makeTree(groups, items), [state.typeFilter]);
|
|
180
81
|
// Update tree when empty groups are toggled from outside
|
|
181
82
|
useEffect(() => makeTree(groups, items), [showEmptyGroups]);
|
|
182
|
-
// Update
|
|
83
|
+
// Update expanded groups from outside
|
|
84
|
+
const [previousExpandedGroups, setPreviousExpandedGroups] = useState(expandedGroups);
|
|
85
|
+
if (!isEqual(expandedGroups, previousExpandedGroups)) {
|
|
86
|
+
internalExpandedGroups.current = expandedGroups;
|
|
87
|
+
setPreviousExpandedGroups(expandedGroups);
|
|
88
|
+
}
|
|
89
|
+
// Update "select all" state from outside when groups are selected outside programmatically
|
|
183
90
|
// without using the "select all" checkbox
|
|
184
91
|
useEffect(() => {
|
|
185
92
|
const numOfAllGroups = size(groups);
|
|
@@ -187,7 +94,7 @@ const Tree = React.memo(props => {
|
|
|
187
94
|
if (numOfSelectedGroups !== numOfAllGroups && state.allChecked) {
|
|
188
95
|
dispatch(allCheckedChanged(false));
|
|
189
96
|
}
|
|
190
|
-
else if (numOfSelectedGroups === numOfAllGroups && !state.allChecked) {
|
|
97
|
+
else if (numOfSelectedGroups !== 0 && numOfSelectedGroups === numOfAllGroups && !state.allChecked) {
|
|
191
98
|
dispatch(allCheckedChanged(true));
|
|
192
99
|
}
|
|
193
100
|
}, [selectedGroups]);
|
|
@@ -209,26 +116,32 @@ const Tree = React.memo(props => {
|
|
|
209
116
|
const unselectedItems = updatedItems.filter(filterOutByItemId(updatedSelectedItems));
|
|
210
117
|
return isEmpty(unselectedItems);
|
|
211
118
|
};
|
|
212
|
-
const handleToggleNode = nodeId => {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
119
|
+
const handleToggleNode = (nodeId) => {
|
|
120
|
+
const nodeContainer = getNodeContainerDomElementById(nodeId);
|
|
121
|
+
if (!(internalExpandedGroups === null || internalExpandedGroups === void 0 ? void 0 : internalExpandedGroups.current) || !nodeContainer) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const openGroups = internalExpandedGroups.current;
|
|
125
|
+
const newExpandedNodes = openGroups.includes(nodeId)
|
|
126
|
+
? openGroups.filter(item => item !== nodeId)
|
|
127
|
+
: [...openGroups, nodeId];
|
|
216
128
|
// Performance improvement to skip on render cycle and change "open" class directly
|
|
217
|
-
if (
|
|
218
|
-
|
|
129
|
+
if (openGroups.includes(nodeId)) {
|
|
130
|
+
nodeContainer.classList.remove('open');
|
|
219
131
|
}
|
|
220
132
|
else {
|
|
221
|
-
|
|
133
|
+
nodeContainer.classList.add('open');
|
|
222
134
|
}
|
|
223
135
|
internalExpandedGroups.current = newExpandedNodes;
|
|
224
136
|
onExpandGroupsChange(newExpandedNodes);
|
|
225
137
|
};
|
|
226
|
-
const getNodeContainerDomElementById = nodeId => {
|
|
227
|
-
|
|
138
|
+
const getNodeContainerDomElementById = (nodeId) => {
|
|
139
|
+
var _a;
|
|
140
|
+
return (_a = treeRef === null || treeRef === void 0 ? void 0 : treeRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.TreeNodeContainer[data-id="${nodeId}"]`);
|
|
228
141
|
};
|
|
229
|
-
const selectAllSearchResultItems = shouldSelect => selectAllFlatItems(shouldSelect);
|
|
230
|
-
const
|
|
231
|
-
const shouldSelectAll = shouldSelect && !
|
|
142
|
+
const selectAllSearchResultItems = (shouldSelect) => selectAllFlatItems(shouldSelect);
|
|
143
|
+
const handleSelectAll = (shouldSelect, isStateIndeterminate) => {
|
|
144
|
+
const shouldSelectAll = shouldSelect && !isStateIndeterminate;
|
|
232
145
|
dispatch(allCheckedChanged(shouldSelectAll));
|
|
233
146
|
cond([
|
|
234
147
|
[hasNoSearchAndGroups, () => selectAllGroups(shouldSelectAll)],
|
|
@@ -236,22 +149,25 @@ const Tree = React.memo(props => {
|
|
|
236
149
|
[otherwise, () => selectAllFlatItems(shouldSelectAll)],
|
|
237
150
|
])();
|
|
238
151
|
};
|
|
239
|
-
const selectAllGroups = shouldSelect => respondSelection([], shouldSelect ? getListIds(groups) : []);
|
|
240
|
-
const selectAllFlatItems = shouldSelect => respondSelection(shouldSelect ? getListIds(state.flatItems) : [], []);
|
|
241
|
-
const respondSelection = (
|
|
242
|
-
onSelectionChange({
|
|
152
|
+
const selectAllGroups = (shouldSelect) => respondSelection([], shouldSelect ? getListIds(groups) : []);
|
|
153
|
+
const selectAllFlatItems = (shouldSelect) => respondSelection(shouldSelect ? getListIds(state.flatItems) : [], []);
|
|
154
|
+
const respondSelection = (updatedSelectedItemIds, updatedSelectedGroupIds) => {
|
|
155
|
+
onSelectionChange({
|
|
156
|
+
items: updatedSelectedItemIds,
|
|
157
|
+
groups: updatedSelectedGroupIds,
|
|
158
|
+
});
|
|
243
159
|
};
|
|
244
|
-
const handleGroupSelection = (group,
|
|
160
|
+
const handleGroupSelection = (group, isStateIndeterminate) => {
|
|
245
161
|
const groupId = group.id;
|
|
246
162
|
const isSelected = selectedGroups.includes(groupId);
|
|
247
|
-
const shouldSelectGroup = !isSelected && !
|
|
163
|
+
const shouldSelectGroup = !isSelected && !isStateIndeterminate;
|
|
248
164
|
// handle group selection
|
|
249
165
|
const newSelectedGroups = shouldSelectGroup
|
|
250
166
|
? [...selectedGroups, groupId]
|
|
251
167
|
: excludeFromList(selectedGroups, groupId);
|
|
252
168
|
// deselect all items of a node since they will be selected inherently via the group itself
|
|
253
|
-
const itemsInGroup = find(entry => entry.id === groupId)(state.groupedItems);
|
|
254
|
-
const itemIdsOfGroup = map(item => item.id)(itemsInGroup.items);
|
|
169
|
+
const itemsInGroup = find((entry) => entry.id === groupId)(state.groupedItems);
|
|
170
|
+
const itemIdsOfGroup = map((item) => item.id)(itemsInGroup === null || itemsInGroup === void 0 ? void 0 : itemsInGroup.items);
|
|
255
171
|
const updatedSelectedItems = without(itemIdsOfGroup, selectedItems);
|
|
256
172
|
// check if all groups are selected to change the state of TreeSelectAll
|
|
257
173
|
const groupAmount = groups.length;
|
|
@@ -261,16 +177,15 @@ const Tree = React.memo(props => {
|
|
|
261
177
|
dispatch(allCheckedChanged(areAllGroupsChecked));
|
|
262
178
|
respondSelection(updatedSelectedItems, newSelectedGroups);
|
|
263
179
|
};
|
|
264
|
-
const handleSearchChange = updatedSearchValue => {
|
|
180
|
+
const handleSearchChange = (updatedSearchValue) => {
|
|
265
181
|
onSearchChange(updatedSearchValue);
|
|
266
182
|
dispatch(searchValueChanged(updatedSearchValue));
|
|
267
183
|
};
|
|
268
184
|
const hasGroups = () => groups && notEmpty(groups);
|
|
269
185
|
const hasSearchAndGroups = () => hasInternalSearchValue() && hasGroups();
|
|
270
186
|
const hasNoSearchAndGroups = () => !hasInternalSearchValue() && hasGroups();
|
|
271
|
-
const setFlatItemList = (
|
|
272
|
-
const flatItems = getFlatItems(
|
|
273
|
-
dispatch(assetCounted(getAssetTypeCounts(flatItems)));
|
|
187
|
+
const setFlatItemList = (updatedItems, searchValue) => {
|
|
188
|
+
const flatItems = getFlatItems(updatedItems, searchValue);
|
|
274
189
|
dispatch(flatItemsChanged(flatItems));
|
|
275
190
|
};
|
|
276
191
|
const setGroupedItemList = (groupsToProcess, itemsToProcess, considerEmptyGroups) => {
|
|
@@ -280,17 +195,18 @@ const Tree = React.memo(props => {
|
|
|
280
195
|
const groupedItems = considerEmptyGroups ? newGroupedItems : filterEmptyGroups(newGroupedItems);
|
|
281
196
|
// Keep the empty groups in memory for later access in select all, without re-iterating on every
|
|
282
197
|
// group selection
|
|
283
|
-
const emptyGroups = filter(group => isEmpty(group.items))(newGroupedItems);
|
|
198
|
+
const emptyGroups = filter((group) => isEmpty(group.items))(newGroupedItems);
|
|
284
199
|
dispatch(emptyGroupsChanged(emptyGroups));
|
|
285
|
-
dispatch(assetCounted(
|
|
200
|
+
dispatch(assetCounted(getTypeCounts(items)));
|
|
286
201
|
dispatch(groupedItemsChanged(groupedItems));
|
|
202
|
+
// Update expanded groups again
|
|
287
203
|
};
|
|
288
204
|
const makeTree = (updatedGroups, updatedItems) => {
|
|
289
205
|
const internalSearchValue = state.searchValue;
|
|
290
206
|
const internalTypeFilter = state.typeFilter;
|
|
291
207
|
const groupsToProcess = updatedGroups;
|
|
292
208
|
const itemsToProcess = updatedItems;
|
|
293
|
-
const hasGroupList = groupList => groupList && notEmpty(groupList);
|
|
209
|
+
const hasGroupList = (groupList) => groupList && notEmpty(groupList);
|
|
294
210
|
const hasNoInternalSearchAndGroups = () => isEmpty(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
295
211
|
const hasInternalSearchAndGroups = () => notEmpty(internalSearchValue) && hasGroupList(groupsToProcess);
|
|
296
212
|
const filteredItems = isEmpty(internalTypeFilter)
|
|
@@ -309,14 +225,15 @@ const Tree = React.memo(props => {
|
|
|
309
225
|
if (isEmpty(groupedItems)) {
|
|
310
226
|
return _jsx(TreeNothingFound, {});
|
|
311
227
|
}
|
|
312
|
-
const result = map(group => {
|
|
228
|
+
const result = map((group) => {
|
|
229
|
+
var _a, _b;
|
|
313
230
|
const groupId = group.id;
|
|
314
231
|
const groupItems = group.items;
|
|
315
|
-
const isOpen =
|
|
232
|
+
const isOpen = (_b = (_a = internalExpandedGroups.current) === null || _a === void 0 ? void 0 : _a.includes(groupId)) !== null && _b !== void 0 ? _b : false;
|
|
316
233
|
const numSelectedGroupItems = filter(containsItemById(selectedItems))(groupItems).length;
|
|
317
234
|
const isGroupSelected = selectedGroups.includes(groupId);
|
|
318
|
-
const
|
|
319
|
-
return (_jsxs(TreeNodeContainer, Object.assign({ groupId: groupId, isOpen: isOpen }, { children: [_jsx(TreeNode, { node: group, hasMultiselect: hasMultiselect, onToggleNode: handleToggleNode, onSelect: handleGroupSelection, isSelected: isGroupSelected, isIndeterminate:
|
|
235
|
+
const isStateIndeterminate = !isGroupSelected && numSelectedGroupItems > 0;
|
|
236
|
+
return (_jsxs(TreeNodeContainer, Object.assign({ groupId: groupId, isOpen: isOpen, disableAnimation: disableAnimation }, { children: [_jsx(TreeNode, { node: group, hasMultiselect: hasMultiselect, onToggleNode: handleToggleNode, onSelect: handleGroupSelection, isSelected: isGroupSelected, isIndeterminate: isStateIndeterminate }), _jsx(TreeLeafList, { leafList: groupItems, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, selectedItems: selectedItems, selectedGroups: selectedGroups, onSelectionChange: respondSelection })] }), groupId));
|
|
320
237
|
})(groupedItems);
|
|
321
238
|
return result;
|
|
322
239
|
};
|
|
@@ -324,144 +241,41 @@ const Tree = React.memo(props => {
|
|
|
324
241
|
const { flatItems } = state;
|
|
325
242
|
const hasLeafs = isEmpty(flatItems);
|
|
326
243
|
const getLeafs = () => (_jsx(TreeLeafList, { leafList: flatItems, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, selectedItems: selectedItems, selectedGroups: selectedGroups, onSelectionChange: respondSelection }));
|
|
327
|
-
return _jsx(TreeNodeContainer, Object.assign({ isOpen: true }, { children: hasLeafs ? _jsx(TreeNothingFound, {}) : getLeafs() }));
|
|
244
|
+
return (_jsx(TreeNodeContainer, Object.assign({ disableAnimation: disableAnimation, isOpen: true }, { children: hasLeafs ? _jsx(TreeNothingFound, {}) : getLeafs() })));
|
|
328
245
|
};
|
|
329
246
|
const hasExternalGroups = notEmpty(groups);
|
|
330
247
|
const hasInternalSearchValue = () => notEmpty(state.searchValue);
|
|
331
248
|
const hasSelectedAllItems = () => isEqual(size(selectedItems), size(state.flatItems));
|
|
332
|
-
const
|
|
249
|
+
const hasPartiallySelectedItems = () => notEmpty(selectedItems) && !hasSelectedAllItems();
|
|
333
250
|
const hasSelectedAllGroups = () => {
|
|
334
251
|
const emptyGroupAmount = showEmptyGroups ? 0 : state.emptyGroups.length;
|
|
335
252
|
return isEqual(size(selectedGroups), size(groups) - emptyGroupAmount);
|
|
336
253
|
};
|
|
337
|
-
const
|
|
254
|
+
const hasPartiallySelectedGroups = () => hasExternalGroups && notEmpty(selectedGroups) && !hasSelectedAllGroups();
|
|
338
255
|
const hasSearchAndNoItems = hasInternalSearchValue() && isEmpty(state.flatItems);
|
|
339
256
|
const hasSearchAndNoGroups = hasInternalSearchValue() && isEmpty(state.groupedItems) && hasExternalGroups;
|
|
340
257
|
const hideSelectAll = hasSearchAndNoItems || hasSearchAndNoGroups;
|
|
341
|
-
const isIndeterminate =
|
|
342
|
-
const treeClassNames = classNames('Tree', className);
|
|
258
|
+
const isIndeterminate = hasPartiallySelectedGroups() || hasPartiallySelectedItems();
|
|
259
|
+
const treeClassNames = classNames('Tree', 'overflow-x-hidden', className);
|
|
343
260
|
const treeHeadClasses = classNames('TreeHead', 'display-flex gap-5', 'padding-15');
|
|
344
261
|
const shouldRenderTree = () => hasGroups() && !hasInternalSearchValue();
|
|
345
262
|
const content = cond([
|
|
346
263
|
[shouldRenderTree, () => renderTree()],
|
|
347
264
|
[otherwise, () => renderFlatList()],
|
|
348
265
|
])();
|
|
349
|
-
const handleFilterByType = type => {
|
|
350
|
-
|
|
351
|
-
if (currentTypeFilter.has(type)) {
|
|
352
|
-
currentTypeFilter.delete(type);
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
currentTypeFilter.add(type);
|
|
356
|
-
}
|
|
357
|
-
dispatch(typeFilterChanged([...currentTypeFilter]));
|
|
358
|
-
};
|
|
359
|
-
const putItemsFirst = ({ findFunction, array }) => [
|
|
360
|
-
...array.filter(findFunction),
|
|
361
|
-
...array.filter(item => !findFunction(item)),
|
|
362
|
-
];
|
|
363
|
-
const sortVisibleTypeCounters = array => {
|
|
364
|
-
let sortedVisibleTypeCounters = array;
|
|
365
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
366
|
-
array: sortedVisibleTypeCounters,
|
|
367
|
-
findFunction: item => item === 'fuel-netgas',
|
|
368
|
-
});
|
|
369
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
370
|
-
array: sortedVisibleTypeCounters,
|
|
371
|
-
findFunction: item => item === 'fuel-hydrogen',
|
|
372
|
-
});
|
|
373
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
374
|
-
array: sortedVisibleTypeCounters,
|
|
375
|
-
findFunction: item => item === 'fuel-electric',
|
|
376
|
-
});
|
|
377
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
378
|
-
array: sortedVisibleTypeCounters,
|
|
379
|
-
findFunction: item => item === 'fuel-petrol',
|
|
380
|
-
});
|
|
381
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
382
|
-
array: sortedVisibleTypeCounters,
|
|
383
|
-
findFunction: item => item === 'trailer',
|
|
384
|
-
});
|
|
385
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
386
|
-
array: sortedVisibleTypeCounters,
|
|
387
|
-
findFunction: item => item === 'van',
|
|
388
|
-
});
|
|
389
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
390
|
-
array: sortedVisibleTypeCounters,
|
|
391
|
-
findFunction: item => item === 'bus',
|
|
392
|
-
});
|
|
393
|
-
sortedVisibleTypeCounters = putItemsFirst({
|
|
394
|
-
array: sortedVisibleTypeCounters,
|
|
395
|
-
findFunction: item => item === 'truck',
|
|
396
|
-
});
|
|
397
|
-
return sortedVisibleTypeCounters;
|
|
266
|
+
const handleFilterByType = (type) => {
|
|
267
|
+
dispatch(typeFilterChanged(addOrRemoveFromList(state.typeFilter, type)));
|
|
398
268
|
};
|
|
399
|
-
const
|
|
269
|
+
const enableActivity = size(state.visibleTypeCounters) !== 1;
|
|
400
270
|
const isFilterActive = notEmpty(state.typeFilter);
|
|
401
271
|
const showTreeHead = !hideTreeHead;
|
|
402
272
|
const showSelectAll = !hideSelectAll;
|
|
403
273
|
const showSearch = !hideSearch;
|
|
404
274
|
const showSummary = !hideSummary;
|
|
405
275
|
const hasCustomSearch = !isNil(search);
|
|
406
|
-
return (_jsxs("div", Object.assign({}, remainingProps, { className: treeClassNames, ref: treeRef }, { children: [_jsxs("div", Object.assign({ className: 'TreeHeader' }, { children: [showSearch && !hasCustomSearch && (_jsx(TreeSearch, { value: state.searchValue, onChange: handleSearchChange, placeholder: searchPlaceholder })), hasCustomSearch && search, showTreeHead && (_jsxs("div", Object.assign({ className: treeHeadClasses }, { children: [showSelectAll && (_jsx("div", Object.assign({ className: 'border border-right-only hidden-empty padding-right-10 margin-right-2' }, { children: _jsx(TreeSelectAll, { isChecked: state.allChecked, isEnabled: hasMultiselect, isIndeterminate: isIndeterminate, onSelect:
|
|
407
|
-
? summary || (_jsx(TreeSummary, { children: map(typeCounter => (_jsx(TypeCounter, { type: typeCounter, icon: `${typeCounter}`, value: state.assetCounts[typeCounter], onClick: handleFilterByType, isActive: state.typeFilter.includes(typeCounter), hasFilter: isFilterActive, enableActivity:
|
|
408
|
-
: null })), _jsx(TreeOptions, { treeOptions: treeOptions })] })))] })), _jsx(TreeRoot, Object.assign({ maxHeight: scrollHeight }, { children: content }))] })));
|
|
276
|
+
return (_jsxs("div", Object.assign({}, remainingProps, { className: treeClassNames, ref: treeRef }, { children: [_jsxs("div", Object.assign({ className: 'TreeHeader' }, { children: [showSearch && !hasCustomSearch && (_jsx(TreeSearch, { value: state.searchValue, onChange: handleSearchChange, placeholder: searchPlaceholder })), hasCustomSearch && search, showTreeHead && (_jsxs("div", Object.assign({ className: treeHeadClasses }, { children: [showSelectAll && (_jsx("div", Object.assign({ className: 'border border-right-only hidden-empty padding-right-10 margin-right-2' }, { children: _jsx(TreeSelectAll, { isChecked: state.allChecked, isEnabled: hasMultiselect, isIndeterminate: isIndeterminate, onSelect: handleSelectAll }) }))), _jsx("div", Object.assign({ className: 'display-flex justify-content-between align-items-start width-100pct' }, { children: showSummary
|
|
277
|
+
? summary || (_jsx(TreeSummary, { children: map((typeCounter) => (_jsx(TypeCounter, { type: typeCounter, icon: `${typeCounter}`, value: state.assetCounts[typeCounter], onClick: handleFilterByType, isActive: state.typeFilter.includes(typeCounter), hasFilter: isFilterActive, enableActivity: enableActivity }, typeCounter)))(state.visibleTypeCounters) }))
|
|
278
|
+
: null })), _jsx(TreeOptions, { treeOptions: treeOptions })] })))] })), _jsx(TreeRoot, Object.assign({ maxHeight: scrollHeight, disableAnimation: disableAnimation }, { children: content }))] })));
|
|
409
279
|
}, customCompare);
|
|
410
280
|
Tree.displayName = 'Tree';
|
|
411
|
-
Tree.defaultProps = {
|
|
412
|
-
hasMultiselect: true,
|
|
413
|
-
showRadioButtons: false,
|
|
414
|
-
hideSearch: false,
|
|
415
|
-
hideSummary: false,
|
|
416
|
-
showEmptyGroups: true,
|
|
417
|
-
selectedGroups: [],
|
|
418
|
-
selectedItems: [],
|
|
419
|
-
onSelectionChange: () => { },
|
|
420
|
-
onExpandGroupsChange: () => { },
|
|
421
|
-
onSearchChange: () => { },
|
|
422
|
-
searchPlaceholder: 'Type here to filter by name',
|
|
423
|
-
treeOptions: [],
|
|
424
|
-
groups: [],
|
|
425
|
-
};
|
|
426
|
-
Tree.propTypes = {
|
|
427
|
-
groups: PropTypes.arrayOf(PropTypes.shape({
|
|
428
|
-
id: PropTypes.string.isRequired,
|
|
429
|
-
name: PropTypes.string.isRequired,
|
|
430
|
-
icon: PropTypes.string,
|
|
431
|
-
className: PropTypes.string,
|
|
432
|
-
})),
|
|
433
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
434
|
-
id: PropTypes.string.isRequired,
|
|
435
|
-
name: PropTypes.oneOfType([
|
|
436
|
-
PropTypes.string,
|
|
437
|
-
PropTypes.shape({
|
|
438
|
-
firstName: PropTypes.string,
|
|
439
|
-
lastName: PropTypes.string.isRequired,
|
|
440
|
-
}),
|
|
441
|
-
]).isRequired,
|
|
442
|
-
info: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
443
|
-
type: PropTypes.string.isRequired,
|
|
444
|
-
groupIds: PropTypes.arrayOf(PropTypes.string),
|
|
445
|
-
className: PropTypes.string,
|
|
446
|
-
})),
|
|
447
|
-
selectedGroups: PropTypes.arrayOf(PropTypes.string),
|
|
448
|
-
selectedItems: PropTypes.arrayOf(PropTypes.string),
|
|
449
|
-
onSelectionChange: PropTypes.func,
|
|
450
|
-
hasMultiselect: PropTypes.bool,
|
|
451
|
-
showRadioButtons: PropTypes.bool,
|
|
452
|
-
hideSearch: PropTypes.bool,
|
|
453
|
-
summary: PropTypes.node,
|
|
454
|
-
hideSummary: PropTypes.bool,
|
|
455
|
-
hideTreeHead: PropTypes.bool,
|
|
456
|
-
// This defines a custom search component.
|
|
457
|
-
search: PropTypes.node,
|
|
458
|
-
searchPlaceholder: PropTypes.string,
|
|
459
|
-
onSearchChange: PropTypes.func,
|
|
460
|
-
className: PropTypes.string,
|
|
461
|
-
scrollHeight: PropTypes.number,
|
|
462
|
-
expandedGroups: PropTypes.arrayOf(PropTypes.string),
|
|
463
|
-
onExpandGroupsChange: PropTypes.func,
|
|
464
|
-
showEmptyGroups: PropTypes.bool,
|
|
465
|
-
treeOptions: PropTypes.arrayOf(PropTypes.node),
|
|
466
|
-
};
|
|
467
281
|
export 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,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
const TreeCategory = props => props.children || null;
|
|
1
|
+
const TreeCategory = (props) => props.children || null;
|
|
3
2
|
TreeCategory.displayName = 'TreeCategory';
|
|
4
|
-
TreeCategory.propTypes = {
|
|
5
|
-
id: PropTypes.string.isRequired,
|
|
6
|
-
icon: PropTypes.string.isRequired,
|
|
7
|
-
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
8
|
-
hasSelection: PropTypes.bool,
|
|
9
|
-
};
|
|
10
3
|
export default TreeCategory;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// @ts-ignore-next-line importsNotUsedAsValues
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import isObject from 'lodash/fp/isObject';
|
|
@@ -7,7 +8,7 @@ import RadioButton from '../radiobutton/RadioButton';
|
|
|
7
8
|
const TreeLeaf = React.memo((props) => {
|
|
8
9
|
const { item, hasMultiselect, showRadioButtons, isSelected, onSelectItem, onActiveItem } = props;
|
|
9
10
|
const treeNodeClassNames = classNames('TreeLeaf', 'form-group margin-bottom-0', isSelected && 'active', item.className && item.className);
|
|
10
|
-
return (_jsxs("div", Object.assign({ className: treeNodeClassNames, "data-key": item.id }, { children: [hasMultiselect && _jsx(Checkbox, { className: 'TreeCheckbox', checked: isSelected, onClick: onSelectItem }), !hasMultiselect && showRadioButtons && (_jsx(RadioButton, { className: 'TreeRadioButton', checked: isSelected, onChange: onSelectItem })), _jsx("span", Object.assign({ className: 'TreeLabel', onClick: onActiveItem }, { children: _jsxs("span", Object.assign({ className: 'TreeLabelName' }, { children: [_jsx("span", { className: `rioglyph rioglyph-${item.type}` }), _jsxs("span", Object.assign({ className: 'TreeLabelNameText' }, { children: [_jsx("span", Object.assign({ className: 'TreeLabelNameTextHeadline' }, { children: isObject(item.name) ? (_jsxs(
|
|
11
|
+
return (_jsxs("div", Object.assign({ className: treeNodeClassNames, "data-key": item.id }, { children: [hasMultiselect && _jsx(Checkbox, { className: 'TreeCheckbox', checked: isSelected, onClick: onSelectItem }), !hasMultiselect && showRadioButtons && (_jsx(RadioButton, { className: 'TreeRadioButton', checked: isSelected, onChange: onSelectItem })), _jsx("span", Object.assign({ className: 'TreeLabel', onClick: onActiveItem }, { children: _jsxs("span", Object.assign({ className: 'TreeLabelName' }, { children: [!item.subType && _jsx("span", { className: `rioglyph rioglyph-${item.type}` }), item.subType && (_jsxs("span", Object.assign({ className: 'rioglyph-icon-pair' }, { children: [_jsx("span", { className: `rioglyph rioglyph-${item.type}` }), _jsx("span", { className: `rioglyph rioglyph-${item.subType}` })] }))), _jsxs("span", Object.assign({ className: 'TreeLabelNameText' }, { children: [_jsx("span", Object.assign({ className: 'TreeLabelNameTextHeadline' }, { children: isObject(item.name) ? (_jsxs(_Fragment, { children: [_jsx("span", Object.assign({ className: 'text-light margin-right-3' }, { children: item.name.firstName })), _jsx("span", { children: item.name.lastName })] })) : (item.name) })), item.info && _jsx("span", Object.assign({ className: 'TreeLabelNameTextSubline' }, { children: item.info }))] }))] })) }))] })));
|
|
11
12
|
});
|
|
12
13
|
TreeLeaf.displayName = 'TreeLeaf';
|
|
13
14
|
export default TreeLeaf;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { TreeItem } from '
|
|
1
|
+
import type { TreeItem } from './Tree';
|
|
2
2
|
export type TreeLeafListProps = {
|
|
3
3
|
leafList: TreeItem[];
|
|
4
4
|
hasMultiselect: boolean;
|
|
5
5
|
showRadioButtons: boolean;
|
|
6
6
|
selectedItems: string[];
|
|
7
7
|
selectedGroups: string[];
|
|
8
|
-
onSelectionChange: (selectedItems: string[], selectedGroups: string[]) =>
|
|
8
|
+
onSelectionChange: (selectedItems: string[], selectedGroups: string[]) => void;
|
|
9
9
|
};
|
|
10
10
|
declare const TreeLeafList: {
|
|
11
|
-
(props: TreeLeafListProps): import("react/jsx-runtime").JSX.Element
|
|
11
|
+
(props: TreeLeafListProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
displayName: string;
|
|
13
13
|
};
|
|
14
14
|
export default TreeLeafList;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// @ts-ignore-next-line importsNotUsedAsValues
|
|
2
3
|
import 'react';
|
|
3
4
|
import TreeLeaf from './TreeLeaf';
|
|
4
|
-
import { excludeFromList } from './
|
|
5
|
+
import { excludeFromList } from './treeUtils';
|
|
5
6
|
const TreeLeafList = (props) => {
|
|
6
7
|
const { leafList, hasMultiselect, showRadioButtons, selectedItems, selectedGroups, onSelectionChange } = props;
|
|
7
8
|
const handleItemSelection = (itemId) => {
|
|
@@ -12,7 +13,7 @@ const TreeLeafList = (props) => {
|
|
|
12
13
|
onSelectionChange(newSelectedItems, selectedGroups);
|
|
13
14
|
};
|
|
14
15
|
const handleSetItemActive = (itemId) => onSelectionChange([itemId], []);
|
|
15
|
-
return leafList.map(item => (_jsx(TreeLeaf, { item: item, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, isSelected: selectedItems.includes(item.id), onSelectItem: () => handleItemSelection(item.id), onActiveItem: () => handleSetItemActive(item.id) }, item.id)));
|
|
16
|
+
return (_jsx(_Fragment, { children: leafList.map(item => (_jsx(TreeLeaf, { item: item, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, isSelected: selectedItems.includes(item.id), onSelectItem: () => handleItemSelection(item.id), onActiveItem: () => handleSetItemActive(item.id) }, item.id))) }));
|
|
16
17
|
};
|
|
17
18
|
TreeLeafList.displayName = 'TreeLeafList';
|
|
18
19
|
export default TreeLeafList;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { GroupedItem } from './Tree';
|
|
3
|
+
export type TreeNodeProps = {
|
|
4
|
+
node: GroupedItem;
|
|
5
|
+
hasMultiselect?: boolean;
|
|
6
|
+
isSelected?: boolean;
|
|
7
|
+
isIndeterminate?: boolean;
|
|
8
|
+
onToggleNode: (nodeId: string) => void;
|
|
9
|
+
onSelect: (node: GroupedItem, isIndeterminate: boolean) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const TreeNode: React.MemoExoticComponent<(props: TreeNodeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
1
13
|
export default TreeNode;
|
|
2
|
-
declare const TreeNode: React.NamedExoticComponent<object>;
|
|
3
|
-
import React from "react";
|