@elliemae/ds-treeview 2.2.0-alpha.2 → 2.2.0-next.1

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 (206) hide show
  1. package/cjs/TreeView.js +27 -49
  2. package/cjs/TreeViewContext.js +37 -61
  3. package/cjs/config/cssClassesConstants.js +13 -41
  4. package/cjs/config/useTreeview.js +78 -116
  5. package/cjs/hoc/DnDTreeContext.js +18 -0
  6. package/cjs/hoc/SortableItemContext.js +21 -0
  7. package/cjs/hoc/WithConditionalDnDContext.js +138 -0
  8. package/cjs/hoc/WithDnDSortableItemContext.js +70 -0
  9. package/cjs/index.js +26 -37
  10. package/cjs/parts/CheckboxSelectable.js +59 -70
  11. package/cjs/parts/ChildrenCountDisplayer.js +28 -45
  12. package/cjs/parts/DnDHandle.js +46 -0
  13. package/cjs/parts/DropIndicator.js +75 -0
  14. package/cjs/parts/ExpandCaret.js +83 -85
  15. package/cjs/parts/Icon.js +31 -46
  16. package/cjs/parts/NestingSpace.js +35 -43
  17. package/cjs/parts/RadioSelectable.js +37 -52
  18. package/cjs/parts/TreeItem.js +141 -147
  19. package/cjs/parts/TreeItemText.js +95 -88
  20. package/cjs/parts/TreeList.js +130 -119
  21. package/cjs/plugins/dnd/TreeDndPlugin.js +7 -59
  22. package/cjs/plugins/dnd/index.js +9 -28
  23. package/cjs/plugins/index.js +21 -34
  24. package/cjs/plugins/roving/TreeRovingPlugin.js +7 -35
  25. package/cjs/plugins/roving/index.js +9 -28
  26. package/cjs/plugins/searchable/SearchableTreePlugin.js +7 -35
  27. package/cjs/plugins/searchable/index.js +9 -28
  28. package/cjs/plugins/selectable/SelectablePluginTree.js +7 -35
  29. package/cjs/plugins/selectable/index.js +9 -28
  30. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +7 -35
  31. package/cjs/plugins/toolbar/index.js +9 -28
  32. package/cjs/plugins/tree/TreeDataPlugin.js +7 -35
  33. package/cjs/plugins/tree/index.js +9 -28
  34. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +7 -35
  35. package/cjs/plugins/virtualization/index.js +9 -28
  36. package/cjs/react-desc-prop-types.js +54 -82
  37. package/cjs/related-components/TreeViewSearchBar.js +40 -42
  38. package/cjs/sharedTypes.js +2 -27
  39. package/cjs/utils/array-helpers.js +11 -35
  40. package/cjs/utils/group-expands-helpers.js +59 -86
  41. package/cjs/utils/keyboard-helpers.js +90 -85
  42. package/cjs/utils/object-helpers.js +36 -43
  43. package/cjs/utils/refs-helpers.js +22 -43
  44. package/cjs/utils/selectable-helper.js +53 -61
  45. package/cjs/utils/string-helpers.js +7 -35
  46. package/cjs/utils/tree-helpers.js +161 -105
  47. package/cjs/utils/useInstanceRefActions.js +43 -54
  48. package/cjs/utils/useTree.js +80 -76
  49. package/esm/TreeView.js +16 -18
  50. package/esm/TreeViewContext.js +31 -32
  51. package/esm/config/cssClassesConstants.js +6 -12
  52. package/esm/config/useTreeview.js +56 -73
  53. package/esm/hoc/DnDTreeContext.js +14 -0
  54. package/esm/hoc/SortableItemContext.js +17 -0
  55. package/esm/hoc/WithConditionalDnDContext.js +128 -0
  56. package/esm/hoc/WithDnDSortableItemContext.js +61 -0
  57. package/esm/index.js +9 -8
  58. package/esm/parts/CheckboxSelectable.js +46 -36
  59. package/esm/parts/ChildrenCountDisplayer.js +20 -16
  60. package/esm/parts/DnDHandle.js +38 -0
  61. package/esm/parts/DropIndicator.js +68 -0
  62. package/esm/parts/ExpandCaret.js +72 -54
  63. package/esm/parts/Icon.js +22 -16
  64. package/esm/parts/NestingSpace.js +27 -14
  65. package/esm/parts/RadioSelectable.js +28 -20
  66. package/esm/parts/TreeItem.js +125 -114
  67. package/esm/parts/TreeItemText.js +85 -58
  68. package/esm/parts/TreeList.js +119 -91
  69. package/esm/plugins/dnd/TreeDndPlugin.js +3 -30
  70. package/esm/plugins/dnd/index.js +1 -3
  71. package/esm/plugins/index.js +7 -9
  72. package/esm/plugins/roving/TreeRovingPlugin.js +3 -6
  73. package/esm/plugins/roving/index.js +1 -3
  74. package/esm/plugins/searchable/SearchableTreePlugin.js +3 -6
  75. package/esm/plugins/searchable/index.js +1 -3
  76. package/esm/plugins/selectable/SelectablePluginTree.js +3 -6
  77. package/esm/plugins/selectable/index.js +1 -3
  78. package/esm/plugins/toolbar/TreeToolbarPlugin.js +3 -6
  79. package/esm/plugins/toolbar/index.js +1 -3
  80. package/esm/plugins/tree/TreeDataPlugin.js +3 -6
  81. package/esm/plugins/tree/index.js +1 -3
  82. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +3 -6
  83. package/esm/plugins/virtualization/index.js +1 -3
  84. package/esm/react-desc-prop-types.js +44 -47
  85. package/esm/related-components/TreeViewSearchBar.js +32 -13
  86. package/esm/sharedTypes.js +1 -2
  87. package/esm/utils/array-helpers.js +6 -6
  88. package/esm/utils/group-expands-helpers.js +46 -56
  89. package/esm/utils/keyboard-helpers.js +74 -46
  90. package/esm/utils/object-helpers.js +31 -14
  91. package/esm/utils/refs-helpers.js +19 -15
  92. package/esm/utils/selectable-helper.js +43 -32
  93. package/esm/utils/string-helpers.js +3 -6
  94. package/esm/utils/tree-helpers.js +143 -73
  95. package/esm/utils/useInstanceRefActions.js +35 -21
  96. package/esm/utils/useTree.js +59 -35
  97. package/package.json +35 -19
  98. package/types/hoc/DnDTreeContext.d.ts +14 -0
  99. package/types/hoc/SortableItemContext.d.ts +19 -0
  100. package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
  101. package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
  102. package/types/parts/DnDHandle.d.ts +6 -0
  103. package/types/parts/DropIndicator.d.ts +10 -0
  104. package/types/parts/TreeItem.d.ts +4 -11
  105. package/types/parts/TreeList.d.ts +0 -4
  106. package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
  107. package/types/react-desc-prop-types.d.ts +17 -3
  108. package/types/sharedTypes.d.ts +1 -8
  109. package/types/utils/keyboard-helpers.d.ts +2 -1
  110. package/types/utils/refs-helpers.d.ts +1 -1
  111. package/types/utils/tree-helpers.d.ts +4 -1
  112. package/types/utils/useTree.d.ts +1 -0
  113. package/cjs/TreeView.js.map +0 -7
  114. package/cjs/TreeViewContext.js.map +0 -7
  115. package/cjs/config/cssClassesConstants.js.map +0 -7
  116. package/cjs/config/useTreeview.js.map +0 -7
  117. package/cjs/index.js.map +0 -7
  118. package/cjs/parts/CheckboxSelectable.js.map +0 -7
  119. package/cjs/parts/ChildrenCountDisplayer.js.map +0 -7
  120. package/cjs/parts/ExpandCaret.js.map +0 -7
  121. package/cjs/parts/Icon.js.map +0 -7
  122. package/cjs/parts/NestingSpace.js.map +0 -7
  123. package/cjs/parts/RadioSelectable.js.map +0 -7
  124. package/cjs/parts/TreeItem.js.map +0 -7
  125. package/cjs/parts/TreeItemText.js.map +0 -7
  126. package/cjs/parts/TreeList.js.map +0 -7
  127. package/cjs/plugins/dnd/TreeDndPlugin.js.map +0 -7
  128. package/cjs/plugins/dnd/index.js.map +0 -7
  129. package/cjs/plugins/index.js.map +0 -7
  130. package/cjs/plugins/roving/TreeRovingPlugin.js.map +0 -7
  131. package/cjs/plugins/roving/index.js.map +0 -7
  132. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  133. package/cjs/plugins/searchable/index.js.map +0 -7
  134. package/cjs/plugins/selectable/SelectablePluginTree.js.map +0 -7
  135. package/cjs/plugins/selectable/index.js.map +0 -7
  136. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  137. package/cjs/plugins/toolbar/index.js.map +0 -7
  138. package/cjs/plugins/tree/TreeDataPlugin.js.map +0 -7
  139. package/cjs/plugins/tree/index.js.map +0 -7
  140. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  141. package/cjs/plugins/virtualization/index.js.map +0 -7
  142. package/cjs/react-desc-prop-types.js.map +0 -7
  143. package/cjs/related-components/TreeViewSearchBar.js.map +0 -7
  144. package/cjs/sharedTypes.js.map +0 -7
  145. package/cjs/utils/array-helpers.js.map +0 -7
  146. package/cjs/utils/dnd-helpers.js +0 -146
  147. package/cjs/utils/dnd-helpers.js.map +0 -7
  148. package/cjs/utils/group-expands-helpers.js.map +0 -7
  149. package/cjs/utils/keyboard-helpers.js.map +0 -7
  150. package/cjs/utils/object-helpers.js.map +0 -7
  151. package/cjs/utils/refs-helpers.js.map +0 -7
  152. package/cjs/utils/selectable-helper.js.map +0 -7
  153. package/cjs/utils/string-helpers.js.map +0 -7
  154. package/cjs/utils/tree-helpers.js.map +0 -7
  155. package/cjs/utils/useDnDHelpers.js +0 -199
  156. package/cjs/utils/useDnDHelpers.js.map +0 -7
  157. package/cjs/utils/useInstanceRefActions.js.map +0 -7
  158. package/cjs/utils/useTree.js.map +0 -7
  159. package/esm/TreeView.js.map +0 -7
  160. package/esm/TreeViewContext.js.map +0 -7
  161. package/esm/config/cssClassesConstants.js.map +0 -7
  162. package/esm/config/useTreeview.js.map +0 -7
  163. package/esm/index.js.map +0 -7
  164. package/esm/parts/CheckboxSelectable.js.map +0 -7
  165. package/esm/parts/ChildrenCountDisplayer.js.map +0 -7
  166. package/esm/parts/ExpandCaret.js.map +0 -7
  167. package/esm/parts/Icon.js.map +0 -7
  168. package/esm/parts/NestingSpace.js.map +0 -7
  169. package/esm/parts/RadioSelectable.js.map +0 -7
  170. package/esm/parts/TreeItem.js.map +0 -7
  171. package/esm/parts/TreeItemText.js.map +0 -7
  172. package/esm/parts/TreeList.js.map +0 -7
  173. package/esm/plugins/dnd/TreeDndPlugin.js.map +0 -7
  174. package/esm/plugins/dnd/index.js.map +0 -7
  175. package/esm/plugins/index.js.map +0 -7
  176. package/esm/plugins/roving/TreeRovingPlugin.js.map +0 -7
  177. package/esm/plugins/roving/index.js.map +0 -7
  178. package/esm/plugins/searchable/SearchableTreePlugin.js.map +0 -7
  179. package/esm/plugins/searchable/index.js.map +0 -7
  180. package/esm/plugins/selectable/SelectablePluginTree.js.map +0 -7
  181. package/esm/plugins/selectable/index.js.map +0 -7
  182. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +0 -7
  183. package/esm/plugins/toolbar/index.js.map +0 -7
  184. package/esm/plugins/tree/TreeDataPlugin.js.map +0 -7
  185. package/esm/plugins/tree/index.js.map +0 -7
  186. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +0 -7
  187. package/esm/plugins/virtualization/index.js.map +0 -7
  188. package/esm/react-desc-prop-types.js.map +0 -7
  189. package/esm/related-components/TreeViewSearchBar.js.map +0 -7
  190. package/esm/sharedTypes.js.map +0 -7
  191. package/esm/utils/array-helpers.js.map +0 -7
  192. package/esm/utils/dnd-helpers.js +0 -117
  193. package/esm/utils/dnd-helpers.js.map +0 -7
  194. package/esm/utils/group-expands-helpers.js.map +0 -7
  195. package/esm/utils/keyboard-helpers.js.map +0 -7
  196. package/esm/utils/object-helpers.js.map +0 -7
  197. package/esm/utils/refs-helpers.js.map +0 -7
  198. package/esm/utils/selectable-helper.js.map +0 -7
  199. package/esm/utils/string-helpers.js.map +0 -7
  200. package/esm/utils/tree-helpers.js.map +0 -7
  201. package/esm/utils/useDnDHelpers.js +0 -170
  202. package/esm/utils/useDnDHelpers.js.map +0 -7
  203. package/esm/utils/useInstanceRefActions.js.map +0 -7
  204. package/esm/utils/useTree.js.map +0 -7
  205. package/types/utils/dnd-helpers.d.ts +0 -39
  206. package/types/utils/useDnDHelpers.d.ts +0 -26
@@ -1,109 +1,99 @@
1
- import * as React from "react";
2
- import { useCallback, useEffect } from "react";
1
+ import { useCallback, useEffect } from 'react';
2
+
3
+ /* eslint-disable max-params */
3
4
  const updateExpandedState = (treeRoot, onExpandChange) => {
4
5
  const shouldContinueWalking = true;
5
- const newExpandedHashMap = { __ds_tree_root: true };
6
- treeRoot.walk((node) => {
6
+ const newExpandedHashMap = {
7
+ __ds_tree_root: true
8
+ };
9
+ treeRoot.walk(node => {
7
10
  if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {
8
11
  newExpandedHashMap[node.model.id] = true;
9
12
  }
13
+
10
14
  return shouldContinueWalking;
11
15
  });
12
- if (onExpandChange)
13
- onExpandChange(newExpandedHashMap, null);
16
+ if (onExpandChange) onExpandChange(newExpandedHashMap, null);
14
17
  };
15
- const toggleItemExpand = (itemToToggle, triggerTreeRerender, updateUserExpandedState, scrollTo = () => {
16
- }) => {
18
+ const toggleItemExpand = function (itemToToggle, triggerTreeRerender, updateUserExpandedState) {
19
+ let scrollTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
17
20
  const {
18
21
  node: {
19
- model: { isExpanded }
22
+ model: {
23
+ isExpanded
24
+ }
20
25
  },
21
26
  virtualIndex
22
27
  } = itemToToggle;
28
+
23
29
  if (itemToToggle.node.model.isGroup) {
24
30
  itemToToggle.node.model.isExpanded = !isExpanded;
25
31
  triggerTreeRerender();
26
32
  updateUserExpandedState();
27
33
  setTimeout(() => {
28
- if (typeof virtualIndex === "number")
29
- scrollTo(virtualIndex, { align: "start" });
34
+ if (typeof virtualIndex === 'number') scrollTo(virtualIndex, {
35
+ align: 'start'
36
+ });
30
37
  });
31
38
  }
32
39
  };
33
- const expandItemModel = (modelToExpand) => {
34
- if (modelToExpand.isGroup)
35
- modelToExpand.isExpanded = true;
40
+ const expandItemModel = modelToExpand => {
41
+ if (modelToExpand.isGroup) modelToExpand.isExpanded = true;
36
42
  };
37
- const collapseItemModel = (modelToCollapse) => {
38
- if (modelToCollapse.isGroup)
39
- modelToCollapse.isExpanded = false;
43
+ const collapseItemModel = modelToCollapse => {
44
+ if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;
40
45
  };
41
46
  const expandAll = (treeRoot, triggerTreeRerender) => {
42
47
  const shouldContinueWalking = true;
43
- treeRoot.walk((node) => {
44
- if (!node.isRoot())
45
- expandItemModel(node.model);
48
+ treeRoot.walk(node => {
49
+ if (!node.isRoot()) expandItemModel(node.model);
46
50
  return shouldContinueWalking;
47
51
  });
48
52
  triggerTreeRerender();
49
53
  };
50
54
  const collapseAll = (treeRoot, triggerTreeRerender) => {
51
- const shouldContinueWalking = true;
52
- treeRoot.walk((node) => {
53
- if (!node.isRoot())
54
- collapseItemModel(node.model);
55
+ const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
56
+
57
+ treeRoot.walk(node => {
58
+ if (!node.isRoot()) collapseItemModel(node.model);
55
59
  return shouldContinueWalking;
56
60
  });
57
61
  triggerTreeRerender();
58
62
  };
59
- const getToggleExpandShouldExpand = (treeRoot) => {
63
+ const getToggleExpandShouldExpand = treeRoot => {
60
64
  let shouldExpand = false;
61
- const shouldContinueWalking = true;
62
- treeRoot.walk((node) => {
65
+ const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
66
+
67
+ treeRoot.walk(node => {
63
68
  if (!node.isRoot()) {
64
69
  if (!node.model.isExpanded && node.model.isGroup) {
65
- shouldExpand = true;
70
+ shouldExpand = true; // eslint-disable-next-line no-useless-return
71
+
66
72
  return shouldContinueWalking;
67
73
  }
68
74
  }
75
+
69
76
  return shouldContinueWalking;
70
77
  });
71
78
  return shouldExpand;
72
79
  };
73
80
  const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
74
- if (isExpand === true)
75
- expandAll(treeRoot, triggerTreeRerender);
76
- else if (isExpand === false)
77
- collapseAll(treeRoot, triggerTreeRerender);
78
- else {
81
+ if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);else {
79
82
  const shouldExpand = getToggleExpandShouldExpand(treeRoot);
80
- if (shouldExpand === true)
81
- expandAll(treeRoot, triggerTreeRerender);
82
- else
83
- collapseAll(treeRoot, triggerTreeRerender);
83
+ if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);else collapseAll(treeRoot, triggerTreeRerender);
84
84
  }
85
85
  setLatestToggledItem(null);
86
86
  updateUserExpandedState();
87
87
  };
88
- const useNotifyExpandedChange = (propsWithDefaults, {
89
- latestToggledItem,
90
- expandedGroups
91
- }) => {
92
- const notifyExpandedChange = useCallback((expandedGroupHashmap) => propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
88
+ const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
89
+ let {
90
+ latestToggledItem,
91
+ expandedGroups
92
+ } = _ref;
93
+ const notifyExpandedChange = useCallback(expandedGroupHashmap => propsWithDefaults === null || propsWithDefaults === void 0 ? void 0 : propsWithDefaults.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
93
94
  useEffect(() => {
94
- if (!propsWithDefaults.expanded)
95
- notifyExpandedChange(expandedGroups);
95
+ if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
96
96
  }, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
97
97
  };
98
- export {
99
- collapseAll,
100
- collapseItemModel,
101
- expandAll,
102
- expandItemModel,
103
- getToggleExpandShouldExpand,
104
- toggleExpandAllHelper,
105
- toggleItemExpand,
106
- updateExpandedState,
107
- useNotifyExpandedChange
108
- };
109
- //# sourceMappingURL=group-expands-helpers.js.map
98
+
99
+ export { collapseAll, collapseItemModel, expandAll, expandItemModel, getToggleExpandShouldExpand, toggleExpandAllHelper, toggleItemExpand, updateExpandedState, useNotifyExpandedChange };
@@ -1,55 +1,91 @@
1
- import * as React from "react";
2
- import { useCallback, useContext, useEffect } from "react";
3
- import TreeViewContext from "../TreeViewContext";
4
- import { focusItem } from "./tree-helpers";
5
- import { toggleExpandAllHelper, toggleItemExpand } from "./group-expands-helpers";
6
- const useOnItemKeyDown = (item) => {
1
+ import { useContext, useCallback, useEffect } from 'react';
2
+ import TreeViewContext from '../TreeViewContext.js';
3
+ import { focusItem } from './tree-helpers.js';
4
+ import { toggleItemExpand, toggleExpandAllHelper } from './group-expands-helpers.js';
5
+
6
+ /* eslint-disable max-params */
7
+ // 9 tab
8
+ // 13 enter
9
+ // 32 space
10
+ // 37 left arrow
11
+ // 38 up arrow
12
+ // 39 right arrow
13
+ // 40 down arrow
14
+ // 35 end
15
+ // 36 home
16
+ // 56 number 8
17
+ // 106 (NumPad) *
18
+ const useOnItemKeyDown = (item, draggableProps) => {
7
19
  const ctx = useContext(TreeViewContext);
8
20
  const {
9
- props: { onItemFocus },
21
+ props: {
22
+ onItemFocus
23
+ },
10
24
  triggerTreeRerender,
11
- isDragging,
12
25
  visibleItems,
13
26
  setFocusedItem,
14
27
  setSelectedItem,
15
28
  setLatestToggledItem,
16
29
  updateUserExpandedState,
17
- virtualListHelpers: { scrollToIndex }
30
+ virtualListHelpers: {
31
+ scrollToIndex
32
+ }
18
33
  } = ctx;
19
- const { isGroup, isExpanded } = item;
20
- const onItemFocusCurry = useCallback((newFocusItem) => onItemFocus({
34
+ const {
35
+ isGroup,
36
+ isExpanded
37
+ } = item;
38
+ const onItemFocusCurry = useCallback(newFocusItem => onItemFocus({
21
39
  itemIndex: newFocusItem.virtualIndex,
22
- scrollToItem: (opts = { align: "start" }) => scrollToIndex(newFocusItem.virtualIndex, opts),
40
+ scrollToItem: function () {
41
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
42
+ align: 'start'
43
+ };
44
+ return scrollToIndex(newFocusItem.virtualIndex, opts);
45
+ },
23
46
  item: newFocusItem
24
47
  }), [onItemFocus, scrollToIndex]);
25
- const onItemKeyDown = useCallback((e) => {
26
- const { keyCode } = e;
27
- if (!isDragging) {
28
- if (keyCode !== 9)
29
- e.preventDefault();
30
- if (keyCode === 13 || keyCode === 32)
48
+ const onItemKeyDown = useCallback(e => {
49
+ const {
50
+ keyCode
51
+ } = e;
52
+
53
+ if (!(draggableProps && draggableProps.active)) {
54
+ if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab
55
+
56
+ if ((keyCode === 13 || keyCode === 32) && e.target.tagName === 'LI') {
31
57
  setSelectedItem(item);
58
+ }
59
+
32
60
  if (keyCode === 37) {
33
61
  if (isGroup && isExpanded) {
34
62
  toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
35
63
  setLatestToggledItem(item);
36
64
  }
37
65
  }
66
+
38
67
  if (keyCode === 39) {
39
68
  if (isGroup && !isExpanded) {
40
69
  toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
41
70
  setLatestToggledItem(item);
42
71
  }
43
72
  }
44
- const { virtualIndex } = item;
45
- if (typeof virtualIndex === "number") {
73
+
74
+ const {
75
+ virtualIndex
76
+ } = item;
77
+
78
+ if (typeof virtualIndex === 'number') {
46
79
  const lastItemIndex = visibleItems.length - 1;
80
+
47
81
  if (keyCode === 38) {
48
82
  const isLoopedFocus = virtualIndex === 0;
49
83
  const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;
50
84
  const newFocusItem = visibleItems[newFocusIndex];
51
85
  scrollToIndex(newFocusIndex);
86
+
52
87
  if (isLoopedFocus) {
88
+ // when looping the list from start to end we need to wait a bit before focusing
53
89
  setTimeout(() => {
54
90
  setFocusedItem(newFocusItem);
55
91
  focusItem(newFocusItem);
@@ -61,12 +97,15 @@ const useOnItemKeyDown = (item) => {
61
97
  focusItem(newFocusItem);
62
98
  }
63
99
  }
100
+
64
101
  if (keyCode === 40) {
65
102
  const isLoopedFocus = virtualIndex === lastItemIndex;
66
103
  const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;
67
104
  const newFocusItem = visibleItems[newFocusIndex];
68
105
  scrollToIndex(newFocusIndex);
106
+
69
107
  if (isLoopedFocus) {
108
+ // when looping the list from start to end we need to wait a bit before focusing
70
109
  setTimeout(() => {
71
110
  setFocusedItem(newFocusItem);
72
111
  onItemFocusCurry(newFocusItem);
@@ -78,6 +117,7 @@ const useOnItemKeyDown = (item) => {
78
117
  focusItem(newFocusItem);
79
118
  }
80
119
  }
120
+
81
121
  if (keyCode === 35) {
82
122
  if (virtualIndex !== lastItemIndex) {
83
123
  const newFocusItem = visibleItems[lastItemIndex];
@@ -89,6 +129,7 @@ const useOnItemKeyDown = (item) => {
89
129
  }, 300);
90
130
  }
91
131
  }
132
+
92
133
  if (keyCode === 36) {
93
134
  if (virtualIndex !== 0) {
94
135
  const newFocusItem = visibleItems[0];
@@ -102,40 +143,27 @@ const useOnItemKeyDown = (item) => {
102
143
  }
103
144
  }
104
145
  }
105
- }, [
106
- isDragging,
107
- setSelectedItem,
108
- item,
109
- isGroup,
110
- isExpanded,
111
- triggerTreeRerender,
112
- scrollToIndex,
113
- setLatestToggledItem,
114
- visibleItems,
115
- setFocusedItem,
116
- onItemFocusCurry,
117
- updateUserExpandedState
118
- ]);
146
+ }, [draggableProps, setSelectedItem, item, isGroup, isExpanded, triggerTreeRerender, updateUserExpandedState, scrollToIndex, setLatestToggledItem, visibleItems, setFocusedItem, onItemFocusCurry]);
119
147
  return onItemKeyDown;
120
148
  };
121
- const useGlobalKeyboardListener = (func) => {
149
+ const useGlobalKeyboardListener = func => {
122
150
  useEffect(() => {
123
- document.addEventListener("keydown", func);
124
- return () => document.removeEventListener("keydown", func);
151
+ document.addEventListener('keydown', func);
152
+ return () => document.removeEventListener('keydown', func);
125
153
  }, [func]);
126
154
  };
127
155
  const useGlobalToggleAllExpandShortcut = (treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
128
- const memoizedToggleAllKeyboardShortcut = useCallback((e) => {
129
- const { shiftKey, keyCode } = e;
156
+ const memoizedToggleAllKeyboardShortcut = useCallback(e => {
157
+ const {
158
+ shiftKey,
159
+ keyCode
160
+ } = e;
161
+
130
162
  if (shiftKey && keyCode === 56) {
131
- toggleExpandAllHelper("toggle", treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
163
+ toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
132
164
  }
133
165
  }, [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState]);
134
166
  return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);
135
167
  };
136
- export {
137
- useGlobalKeyboardListener,
138
- useGlobalToggleAllExpandShortcut,
139
- useOnItemKeyDown
140
- };
141
- //# sourceMappingURL=keyboard-helpers.js.map
168
+
169
+ export { useGlobalKeyboardListener, useGlobalToggleAllExpandShortcut, useOnItemKeyDown };
@@ -1,47 +1,64 @@
1
- import * as React from "react";
1
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.for-each.js';
4
+ import 'core-js/modules/esnext.async-iterator.reduce.js';
5
+ import 'core-js/modules/esnext.iterator.reduce.js';
6
+
7
+ /* eslint-disable no-sequences */
8
+
9
+ /* eslint-disable no-return-assign */
10
+
11
+ /* eslint-disable no-restricted-syntax */
12
+
13
+ /* eslint-disable guard-for-in */
2
14
  function isObjectADate(o) {
3
- return o?.constructor?.name === "Date";
15
+ var _o$constructor;
16
+
17
+ return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
4
18
  }
19
+
5
20
  function isObjectAnArray(o) {
6
21
  return Array.isArray(o);
7
22
  }
23
+
8
24
  function isObjectAString(o) {
9
- return typeof o === "object";
25
+ return typeof o === 'object';
10
26
  }
11
- const unfreeze = (o) => {
27
+
28
+ const unfreeze = o => {
12
29
  let oo;
30
+
13
31
  if (o === null) {
14
32
  oo = null;
15
- } else if (o === void 0) {
16
- oo = void 0;
33
+ } else if (o === undefined) {
34
+ oo = undefined;
17
35
  } else if (isObjectADate(o)) {
18
36
  oo = new Date(o);
19
37
  } else if (isObjectAnArray(o)) {
20
38
  oo = [];
21
- o.forEach((v) => {
39
+ o.forEach(v => {
22
40
  oo.push(v);
23
41
  });
24
42
  } else if (isObjectAString(o)) {
25
43
  oo = String(o);
26
44
  } else if (isObjectAString(o)) {
27
45
  oo = {};
46
+
28
47
  for (const property in o) {
29
48
  oo[property] = o[property];
30
49
  }
31
50
  } else {
32
51
  oo = o;
33
52
  }
53
+
34
54
  return oo;
35
55
  };
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
57
  function filterObject(obj, predicate) {
37
58
  return Object.keys(obj).reduce((res, key) => {
38
- if (predicate(obj[key]))
39
- res[key] = obj[key];
59
+ if (predicate(obj[key])) res[key] = obj[key];
40
60
  return res;
41
61
  }, {});
42
62
  }
43
- export {
44
- filterObject,
45
- unfreeze
46
- };
47
- //# sourceMappingURL=object-helpers.js.map
63
+
64
+ export { filterObject, unfreeze };
@@ -1,15 +1,21 @@
1
- import * as React from "react";
2
- const setMultipleRefs = (...refs) => {
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+
7
+ // allow multiple refs to be set to point to the same DOM element
8
+ const setMultipleRefs = function () {
9
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ refs[_key] = arguments[_key];
11
+ }
12
+
3
13
  const filteredRefs = refs.filter(Boolean);
4
- if (!filteredRefs.length)
5
- return () => {
6
- };
7
- if (filteredRefs.length === 0)
8
- return () => {
9
- };
10
- return (newRef) => {
11
- filteredRefs.forEach((refToBeUpdated) => {
12
- if (typeof refToBeUpdated === "function") {
14
+ if (!filteredRefs.length) return () => {};
15
+ if (filteredRefs.length === 0) return () => {};
16
+ return newRef => {
17
+ filteredRefs.forEach(refToBeUpdated => {
18
+ if (typeof refToBeUpdated === 'function') {
13
19
  refToBeUpdated(newRef);
14
20
  } else if (refToBeUpdated) {
15
21
  refToBeUpdated.current = newRef;
@@ -17,7 +23,5 @@ const setMultipleRefs = (...refs) => {
17
23
  });
18
24
  };
19
25
  };
20
- export {
21
- setMultipleRefs
22
- };
23
- //# sourceMappingURL=refs-helpers.js.map
26
+
27
+ export { setMultipleRefs };
@@ -1,59 +1,70 @@
1
- import * as React from "react";
2
- import { walkParents, walkAllNodeChildren } from "./tree-helpers";
3
- const getGroupCheckState = (node) => {
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import { walkAllNodeChildren, walkParents } from './tree-helpers.js';
8
+
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ const getGroupCheckState = node => {
4
13
  let childAllChecked = true;
5
14
  let anyChildChecked = false;
6
- walkAllNodeChildren(node, (childNode) => {
15
+ walkAllNodeChildren(node, childNode => {
7
16
  const {
8
- model: { isChecked }
17
+ model: {
18
+ isChecked
19
+ }
9
20
  } = childNode;
10
- if (isChecked === "mixed" || isChecked === true)
11
- anyChildChecked = true;
12
- else
13
- childAllChecked = false;
21
+ if (isChecked === 'mixed' || isChecked === true) anyChildChecked = true;else childAllChecked = false;
14
22
  });
15
- if (childAllChecked)
16
- return true;
17
- if (anyChildChecked)
18
- return "mixed";
23
+ if (childAllChecked) return true;
24
+ if (anyChildChecked) return 'mixed';
19
25
  return false;
20
26
  };
21
- const selectCheckboxItemModelParentsTillRoot = (modelToCheck, triggerTreeRerender = null) => {
27
+ const selectCheckboxItemModelParentsTillRoot = function (modelToCheck) {
28
+ let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
22
29
  const newSelections = {};
23
- const { nodePath } = modelToCheck;
24
- walkParents(nodePath, (parentNode) => {
30
+ const {
31
+ nodePath
32
+ } = modelToCheck;
33
+ walkParents(nodePath, parentNode => {
25
34
  const nextState = getGroupCheckState(parentNode);
26
35
  parentNode.model.isChecked = nextState;
27
36
  newSelections[parentNode.model.id] = nextState;
28
37
  });
29
- if (triggerTreeRerender)
30
- triggerTreeRerender();
38
+ if (triggerTreeRerender) triggerTreeRerender();
31
39
  return newSelections;
32
40
  };
33
- const toggleCheckboxItem = (itemToSelect, triggerTreeRerender = null) => {
41
+ const toggleCheckboxItem = function (itemToSelect) {
42
+ let triggerTreeRerender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
34
43
  const {
35
44
  node: {
36
- model: { id, isChecked, children = [] }
45
+ model: {
46
+ id,
47
+ isChecked,
48
+ children = []
49
+ }
37
50
  }
38
51
  } = itemToSelect;
39
- const newSelections = {};
40
- const nextState = isChecked === "mixed" ? true : !isChecked;
52
+ const newSelections = {}; // 'mixed' -> true -> false -> true [...->false -> true]
53
+
54
+ const nextState = isChecked === 'mixed' ? true : !isChecked;
41
55
  itemToSelect.node.model.isChecked = nextState;
42
56
  newSelections[id] = nextState;
57
+
43
58
  if (children.length > 0 && (nextState === true || nextState === false)) {
44
- walkAllNodeChildren(itemToSelect.node, (childNode) => {
59
+ walkAllNodeChildren(itemToSelect.node, childNode => {
45
60
  childNode.model.isChecked = nextState;
46
61
  newSelections[childNode.model.id] = nextState;
47
62
  });
48
63
  }
64
+
49
65
  const parentsNewSelections = selectCheckboxItemModelParentsTillRoot(itemToSelect);
50
- if (triggerTreeRerender)
51
- triggerTreeRerender();
52
- return { ...parentsNewSelections, ...newSelections };
53
- };
54
- export {
55
- getGroupCheckState,
56
- selectCheckboxItemModelParentsTillRoot,
57
- toggleCheckboxItem
66
+ if (triggerTreeRerender) triggerTreeRerender();
67
+ return _objectSpread(_objectSpread({}, parentsNewSelections), newSelections);
58
68
  };
59
- //# sourceMappingURL=selectable-helper.js.map
69
+
70
+ export { getGroupCheckState, selectCheckboxItemModelParentsTillRoot, toggleCheckboxItem };
@@ -1,6 +1,3 @@
1
- import * as React from "react";
2
- const standardizeSearchQueryString = (input) => input.trim().toLowerCase();
3
- export {
4
- standardizeSearchQueryString
5
- };
6
- //# sourceMappingURL=string-helpers.js.map
1
+ const standardizeSearchQueryString = input => input.trim().toLowerCase();
2
+
3
+ export { standardizeSearchQueryString };