@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.
Files changed (241) hide show
  1. package/AssetTree.d.ts +2 -5
  2. package/AssetTree.js +2 -2
  3. package/ButtonDropdown.d.ts +2 -5
  4. package/ButtonDropdown.js +2 -2
  5. package/DropdownSubmenu.d.ts +2 -5
  6. package/DropdownSubmenu.js +2 -2
  7. package/MenuItem.d.ts +2 -5
  8. package/MenuItem.js +2 -2
  9. package/MenuItemList.d.ts +2 -0
  10. package/MenuItemList.js +2 -0
  11. package/MenuItems.d.ts +2 -0
  12. package/MenuItems.js +2 -0
  13. package/Page.d.ts +2 -0
  14. package/Page.js +2 -0
  15. package/Sidebar.d.ts +1 -0
  16. package/Sidebar.js +1 -0
  17. package/SimpleButtonDropdown.d.ts +2 -5
  18. package/SimpleButtonDropdown.js +2 -2
  19. package/SingleButtonDropdown.d.ts +2 -5
  20. package/SingleButtonDropdown.js +2 -2
  21. package/SplitButtonDropdown.d.ts +2 -5
  22. package/SplitButtonDropdown.js +2 -2
  23. package/Tree.d.ts +2 -5
  24. package/Tree.js +2 -2
  25. package/TreeCategory.d.ts +2 -5
  26. package/TreeCategory.js +2 -2
  27. package/TreeOption.d.ts +2 -5
  28. package/TreeOption.js +2 -2
  29. package/TreeSearch.d.ts +2 -5
  30. package/TreeSearch.js +2 -2
  31. package/TreeSummary.d.ts +2 -5
  32. package/TreeSummary.js +2 -2
  33. package/TreeSummaryRow.d.ts +2 -0
  34. package/TreeSummaryRow.js +2 -0
  35. package/TypeCounter.d.ts +2 -5
  36. package/TypeCounter.js +2 -2
  37. package/components/assetTree/AssetTree.d.ts +84 -2
  38. package/components/assetTree/AssetTree.js +41 -61
  39. package/components/assetTree/Tree.d.ts +195 -2
  40. package/components/assetTree/Tree.js +70 -256
  41. package/components/assetTree/TreeCategory.d.ts +24 -11
  42. package/components/assetTree/TreeCategory.js +1 -8
  43. package/components/assetTree/TreeLeaf.d.ts +1 -1
  44. package/components/assetTree/TreeLeaf.js +3 -2
  45. package/components/assetTree/TreeLeafList.d.ts +3 -3
  46. package/components/assetTree/TreeLeafList.js +4 -3
  47. package/components/assetTree/TreeNode.d.ts +12 -2
  48. package/components/assetTree/TreeNode.js +2 -17
  49. package/components/assetTree/TreeNodeContainer.d.ts +10 -12
  50. package/components/assetTree/TreeNodeContainer.js +9 -8
  51. package/components/assetTree/TreeNothingFound.d.ts +3 -2
  52. package/components/assetTree/TreeNothingFound.js +1 -7
  53. package/components/assetTree/TreeOption.d.ts +27 -17
  54. package/components/assetTree/TreeOption.js +5 -14
  55. package/components/assetTree/TreeOptions.d.ts +9 -13
  56. package/components/assetTree/TreeOptions.js +4 -11
  57. package/components/assetTree/TreeRoot.d.ts +9 -11
  58. package/components/assetTree/TreeRoot.js +8 -8
  59. package/components/assetTree/TreeSearch.d.ts +23 -2
  60. package/components/assetTree/TreeSearch.js +4 -12
  61. package/components/assetTree/TreeSelectAll.d.ts +14 -26
  62. package/components/assetTree/TreeSelectAll.js +7 -22
  63. package/components/assetTree/TreeSidebar.d.ts +10 -2
  64. package/components/assetTree/TreeSidebar.js +4 -35
  65. package/components/assetTree/TreeSidebarCategories.d.ts +11 -0
  66. package/components/assetTree/TreeSidebarCategories.js +34 -0
  67. package/components/assetTree/TreeSummary.d.ts +44 -2
  68. package/components/assetTree/TreeSummary.js +6 -19
  69. package/components/assetTree/TreeSummaryRow.d.ts +15 -0
  70. package/components/assetTree/TreeSummaryRow.js +6 -0
  71. package/components/assetTree/TypeCounter.d.ts +45 -2
  72. package/components/assetTree/TypeCounter.js +14 -23
  73. package/components/assetTree/treeReducer.d.ts +47 -0
  74. package/components/assetTree/treeReducer.js +34 -0
  75. package/components/assetTree/treeUtils.d.ts +20 -0
  76. package/components/assetTree/treeUtils.js +88 -0
  77. package/components/button/Button.d.ts +14 -9
  78. package/components/button/Button.js +7 -7
  79. package/components/button/ToggleButton.d.ts +2 -4
  80. package/components/datepicker/DatePicker.d.ts +9 -9
  81. package/components/datepicker/DatePicker.js +4 -2
  82. package/components/dialog/Dialog.js +6 -2
  83. package/components/dropdown/ButtonDropdown.d.ts +115 -65
  84. package/components/dropdown/ButtonDropdown.js +14 -60
  85. package/components/dropdown/Caret.d.ts +1 -1
  86. package/components/dropdown/Caret.js +2 -1
  87. package/components/dropdown/DropdownSubmenu.d.ts +21 -18
  88. package/components/dropdown/DropdownSubmenu.js +26 -19
  89. package/components/dropdown/DropdownToggleButton.d.ts +14 -2
  90. package/components/dropdown/DropdownToggleButton.js +6 -14
  91. package/components/dropdown/SimpleButtonDropdown.d.ts +3 -1
  92. package/components/dropdown/SimpleButtonDropdown.js +3 -2
  93. package/components/dropdown/SingleButtonDropdown.d.ts +3 -1
  94. package/components/dropdown/SingleButtonDropdown.js +3 -2
  95. package/components/dropdown/SplitButtonDropdown.d.ts +3 -1
  96. package/components/dropdown/SplitButtonDropdown.js +3 -2
  97. package/components/dropdown/SplitCaretButton.d.ts +12 -2
  98. package/components/dropdown/SplitCaretButton.js +6 -11
  99. package/components/menuItems/MenuItem.d.ts +16 -0
  100. package/components/menuItems/MenuItem.js +1 -0
  101. package/components/menuItems/MenuItemList.d.ts +7 -0
  102. package/components/menuItems/MenuItemList.js +10 -0
  103. package/components/menuItems/MenuItems.d.ts +7 -2
  104. package/components/menuItems/MenuItems.js +10 -9
  105. package/components/numberInput/NumberInput.js +1 -1
  106. package/components/page/Page.d.ts +10 -0
  107. package/components/page/Page.js +18 -0
  108. package/components/timepicker/TimePicker.js +2 -1
  109. package/hooks/usePrevious.d.ts +1 -1
  110. package/hooks/usePrevious.js +6 -7
  111. package/index.d.ts +34 -26
  112. package/index.js +34 -26
  113. package/lib/es/AssetTree.d.ts +2 -5
  114. package/lib/es/AssetTree.js +3 -2
  115. package/lib/es/ButtonDropdown.d.ts +2 -5
  116. package/lib/es/ButtonDropdown.js +3 -2
  117. package/lib/es/DropdownSubmenu.d.ts +2 -5
  118. package/lib/es/DropdownSubmenu.js +3 -2
  119. package/lib/es/MenuItem.d.ts +2 -5
  120. package/lib/es/MenuItem.js +3 -2
  121. package/lib/es/MenuItemList.d.ts +2 -0
  122. package/lib/es/MenuItemList.js +7 -0
  123. package/lib/es/MenuItems.d.ts +2 -0
  124. package/lib/es/MenuItems.js +7 -0
  125. package/lib/es/Page.d.ts +2 -0
  126. package/lib/es/Page.js +7 -0
  127. package/lib/es/Sidebar.d.ts +1 -0
  128. package/lib/es/Sidebar.js +3 -4
  129. package/lib/es/SimpleButtonDropdown.d.ts +2 -5
  130. package/lib/es/SimpleButtonDropdown.js +3 -2
  131. package/lib/es/SingleButtonDropdown.d.ts +2 -5
  132. package/lib/es/SingleButtonDropdown.js +3 -2
  133. package/lib/es/SplitButtonDropdown.d.ts +2 -5
  134. package/lib/es/SplitButtonDropdown.js +3 -2
  135. package/lib/es/Tree.d.ts +2 -5
  136. package/lib/es/Tree.js +3 -2
  137. package/lib/es/TreeCategory.d.ts +2 -5
  138. package/lib/es/TreeCategory.js +3 -2
  139. package/lib/es/TreeOption.d.ts +2 -5
  140. package/lib/es/TreeOption.js +3 -2
  141. package/lib/es/TreeSearch.d.ts +2 -5
  142. package/lib/es/TreeSearch.js +3 -2
  143. package/lib/es/TreeSummary.d.ts +2 -5
  144. package/lib/es/TreeSummary.js +3 -2
  145. package/lib/es/TreeSummaryRow.d.ts +2 -0
  146. package/lib/es/TreeSummaryRow.js +7 -0
  147. package/lib/es/TypeCounter.d.ts +2 -5
  148. package/lib/es/TypeCounter.js +3 -2
  149. package/lib/es/components/assetTree/AssetTree.d.ts +84 -2
  150. package/lib/es/components/assetTree/AssetTree.js +40 -60
  151. package/lib/es/components/assetTree/Tree.d.ts +195 -2
  152. package/lib/es/components/assetTree/Tree.js +103 -286
  153. package/lib/es/components/assetTree/TreeCategory.d.ts +24 -11
  154. package/lib/es/components/assetTree/TreeCategory.js +1 -9
  155. package/lib/es/components/assetTree/TreeLeaf.d.ts +1 -1
  156. package/lib/es/components/assetTree/TreeLeaf.js +2 -1
  157. package/lib/es/components/assetTree/TreeLeafList.d.ts +3 -3
  158. package/lib/es/components/assetTree/TreeLeafList.js +4 -3
  159. package/lib/es/components/assetTree/TreeNode.d.ts +12 -2
  160. package/lib/es/components/assetTree/TreeNode.js +2 -17
  161. package/lib/es/components/assetTree/TreeNodeContainer.d.ts +10 -12
  162. package/lib/es/components/assetTree/TreeNodeContainer.js +9 -8
  163. package/lib/es/components/assetTree/TreeNothingFound.d.ts +3 -2
  164. package/lib/es/components/assetTree/TreeNothingFound.js +1 -7
  165. package/lib/es/components/assetTree/TreeOption.d.ts +27 -17
  166. package/lib/es/components/assetTree/TreeOption.js +5 -14
  167. package/lib/es/components/assetTree/TreeOptions.d.ts +9 -13
  168. package/lib/es/components/assetTree/TreeOptions.js +4 -11
  169. package/lib/es/components/assetTree/TreeRoot.d.ts +9 -11
  170. package/lib/es/components/assetTree/TreeRoot.js +8 -8
  171. package/lib/es/components/assetTree/TreeSearch.d.ts +23 -2
  172. package/lib/es/components/assetTree/TreeSearch.js +4 -12
  173. package/lib/es/components/assetTree/TreeSelectAll.d.ts +14 -26
  174. package/lib/es/components/assetTree/TreeSelectAll.js +7 -22
  175. package/lib/es/components/assetTree/TreeSidebar.d.ts +10 -2
  176. package/lib/es/components/assetTree/TreeSidebar.js +5 -36
  177. package/lib/es/components/assetTree/TreeSidebarCategories.d.ts +11 -0
  178. package/lib/es/components/assetTree/TreeSidebarCategories.js +37 -0
  179. package/lib/es/components/assetTree/TreeSummary.d.ts +44 -2
  180. package/lib/es/components/assetTree/TreeSummary.js +6 -19
  181. package/lib/es/components/assetTree/TreeSummaryRow.d.ts +15 -0
  182. package/lib/es/components/assetTree/TreeSummaryRow.js +10 -0
  183. package/lib/es/components/assetTree/TypeCounter.d.ts +45 -2
  184. package/lib/es/components/assetTree/TypeCounter.js +14 -23
  185. package/lib/es/components/assetTree/autoAnimateFrames.d.ts +1 -0
  186. package/lib/es/components/assetTree/autoAnimateFrames.js +55 -0
  187. package/lib/es/components/assetTree/treeReducer.d.ts +47 -0
  188. package/lib/es/components/assetTree/treeReducer.js +47 -0
  189. package/lib/es/components/assetTree/treeUtils.d.ts +20 -0
  190. package/lib/es/components/assetTree/treeUtils.js +106 -0
  191. package/lib/es/components/button/Button.d.ts +14 -9
  192. package/lib/es/components/button/Button.js +12 -11
  193. package/lib/es/components/button/ToggleButton.d.ts +2 -4
  194. package/lib/es/components/datepicker/DatePicker.d.ts +9 -9
  195. package/lib/es/components/datepicker/DatePicker.js +4 -2
  196. package/lib/es/components/dialog/Dialog.js +5 -1
  197. package/lib/es/components/dropdown/ButtonDropdown.d.ts +115 -65
  198. package/lib/es/components/dropdown/ButtonDropdown.js +13 -59
  199. package/lib/es/components/dropdown/Caret.d.ts +1 -1
  200. package/lib/es/components/dropdown/Caret.js +2 -2
  201. package/lib/es/components/dropdown/DropdownSubmenu.d.ts +21 -18
  202. package/lib/es/components/dropdown/DropdownSubmenu.js +26 -19
  203. package/lib/es/components/dropdown/DropdownToggleButton.d.ts +14 -2
  204. package/lib/es/components/dropdown/DropdownToggleButton.js +6 -14
  205. package/lib/es/components/dropdown/SimpleButtonDropdown.d.ts +3 -1
  206. package/lib/es/components/dropdown/SimpleButtonDropdown.js +3 -2
  207. package/lib/es/components/dropdown/SingleButtonDropdown.d.ts +3 -1
  208. package/lib/es/components/dropdown/SingleButtonDropdown.js +3 -2
  209. package/lib/es/components/dropdown/SplitButtonDropdown.d.ts +3 -1
  210. package/lib/es/components/dropdown/SplitButtonDropdown.js +3 -2
  211. package/lib/es/components/dropdown/SplitCaretButton.d.ts +12 -2
  212. package/lib/es/components/dropdown/SplitCaretButton.js +6 -11
  213. package/lib/es/components/menuItems/MenuItem.d.ts +16 -0
  214. package/lib/es/components/menuItems/MenuItem.js +1 -0
  215. package/lib/es/components/menuItems/MenuItemList.d.ts +7 -0
  216. package/lib/es/components/menuItems/MenuItemList.js +12 -0
  217. package/lib/es/components/menuItems/MenuItems.d.ts +7 -2
  218. package/lib/es/components/menuItems/MenuItems.js +9 -7
  219. package/lib/es/components/numberInput/NumberInput.js +1 -1
  220. package/lib/es/components/page/Page.d.ts +10 -0
  221. package/lib/es/components/page/Page.js +21 -0
  222. package/lib/es/components/timepicker/TimePicker.js +2 -1
  223. package/lib/es/hooks/usePrevious.d.ts +1 -1
  224. package/lib/es/hooks/usePrevious.js +5 -6
  225. package/lib/es/index.d.ts +34 -26
  226. package/lib/es/index.js +55 -30
  227. package/lib/es/types.d.ts +1 -140
  228. package/lib/es/utils/init.js +1 -0
  229. package/lib/es/utils/mergeRefs.d.ts +3 -0
  230. package/lib/es/utils/mergeRefs.js +18 -0
  231. package/lib/es/utils/searchNormalized.d.ts +2 -2
  232. package/lib/es/utils/searchNormalized.js +1 -1
  233. package/lib/es/version.json +1 -1
  234. package/package.json +39 -36
  235. package/types.d.ts +1 -140
  236. package/utils/init.js +1 -0
  237. package/utils/mergeRefs.d.ts +3 -0
  238. package/utils/mergeRefs.js +16 -0
  239. package/utils/searchNormalized.d.ts +2 -2
  240. package/utils/searchNormalized.js +1 -1
  241. 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 negate_1 = tslib_1.__importDefault(require("lodash/fp/negate"));
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 searchNormalized_1 = require("../../utils/searchNormalized");
39
- const excludeFromList_1 = require("./excludeFromList");
40
- const SEARCH_DEBOUNCE = 100;
41
- const otherwise = stubTrue_1.default;
42
- const notEqual = (0, negate_1.default)(isEqual_1.default);
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 assetCounted = payload => ({ type: 'assetCounted', payload });
112
- const allCheckedChanged = payload => ({ type: 'allCheckedChanged', payload });
113
- const searchValueChanged = payload => ({ type: 'searchValueChanged', payload });
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 = getAssetTypeCounts(items);
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 "select all" state from outside when groups are selected outside programatically
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 newExpandedNodes = internalExpandedGroups.current.includes(nodeId)
216
- ? internalExpandedGroups.current.filter(item => item !== nodeId)
217
- : [...internalExpandedGroups.current, nodeId];
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 (internalExpandedGroups.current.includes(nodeId)) {
220
- getNodeContainerDomElementById(nodeId).classList.remove('open');
134
+ if (openGroups.includes(nodeId)) {
135
+ nodeContainer.classList.remove('open');
221
136
  }
222
137
  else {
223
- getNodeContainerDomElementById(nodeId).classList.add('open');
138
+ nodeContainer.classList.add('open');
224
139
  }
225
140
  internalExpandedGroups.current = newExpandedNodes;
226
141
  onExpandGroupsChange(newExpandedNodes);
227
142
  };
228
- const getNodeContainerDomElementById = nodeId => {
229
- return treeRef.current.querySelector(`.TreeNodeContainer[data-id="${nodeId}"]`);
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 handeSelectAll = (shouldSelect, isIndeterminate) => {
233
- const shouldSelectAll = shouldSelect && !isIndeterminate;
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
- [otherwise, () => selectAllFlatItems(shouldSelectAll)],
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 = (updatedSelectedItems, updatedSelectedGroups) => {
244
- onSelectionChange({ items: updatedSelectedItems, groups: updatedSelectedGroups });
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, isIndeterminate) => {
165
+ const handleGroupSelection = (group, isStateIndeterminate) => {
247
166
  const groupId = group.id;
248
167
  const isSelected = selectedGroups.includes(groupId);
249
- const shouldSelectGroup = !isSelected && !isIndeterminate;
168
+ const shouldSelectGroup = !isSelected && !isStateIndeterminate;
250
169
  // handle group selection
251
170
  const newSelectedGroups = shouldSelectGroup
252
171
  ? [...selectedGroups, groupId]
253
- : (0, excludeFromList_1.excludeFromList)(selectedGroups, groupId);
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 = (updtedItems, searchValue) => {
274
- const flatItems = getFlatItems(updtedItems, searchValue);
275
- dispatch(assetCounted(getAssetTypeCounts(flatItems)));
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(getAssetTypeCounts(items)));
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
- [otherwise, setFlatItems],
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 = expandedGroups.includes(groupId);
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 isIndeterminate = !isGroupSelected && numSelectedGroupItems > 0;
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: isIndeterminate }), (0, jsx_runtime_1.jsx)(TreeLeafList_1.default, { leafList: groupItems, hasMultiselect: hasMultiselect, showRadioButtons: showRadioButtons, selectedItems: selectedItems, selectedGroups: selectedGroups, onSelectionChange: respondSelection })] }), groupId));
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 hasPartialySelectedItems = () => notEmpty(selectedItems) && !hasSelectedAllItems();
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 hasPartialySelectedGroups = () => hasExternalGroups && notEmpty(selectedGroups) && !hasSelectedAllGroups();
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 = hasPartialySelectedGroups() || hasPartialySelectedItems();
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
- [otherwise, () => renderFlatList()],
269
+ [stubTrue_1.default, () => renderFlatList()],
350
270
  ])();
351
- const handleFilterByType = type => {
352
- const currentTypeFilter = new Set(state.typeFilter);
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 isClickable = (0, size_1.default)((0, keys_1.default)(state.assetCounts)) > 1;
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: handeSelectAll }) }))), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: 'display-flex justify-content-between align-items-start width-100pct' }, { children: showSummary
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: isClickable }, typeCounter)))(sortVisibleTypeCounters(state.visibleTypeCounters)) }))
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 tslib_1 = require("tslib");
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;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { TreeItem } from '../../types';
2
+ import type { TreeItem } from './Tree';
3
3
  export type TreeLeafProps = {
4
4
  item: TreeItem;
5
5
  hasMultiselect: boolean;