@elliemae/ds-treeview 2.2.0 → 2.3.0-alpha.3

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 (214) hide show
  1. package/cjs/TreeView.js +47 -31
  2. package/cjs/TreeView.js.map +7 -0
  3. package/cjs/TreeViewContext.js +55 -43
  4. package/cjs/TreeViewContext.js.map +7 -0
  5. package/cjs/config/cssClassesConstants.js +41 -13
  6. package/cjs/config/cssClassesConstants.js.map +7 -0
  7. package/cjs/config/useTreeview.js +102 -88
  8. package/cjs/config/useTreeview.js.map +7 -0
  9. package/cjs/hoc/DnDTreeContext.js +45 -0
  10. package/cjs/hoc/DnDTreeContext.js.map +7 -0
  11. package/cjs/hoc/SortableItemContext.js +46 -0
  12. package/cjs/hoc/SortableItemContext.js.map +7 -0
  13. package/cjs/hoc/WithConditionalDnDContext.js +128 -0
  14. package/cjs/hoc/WithConditionalDnDContext.js.map +7 -0
  15. package/cjs/hoc/WithDnDSortableItemContext.js +69 -0
  16. package/cjs/hoc/WithDnDSortableItemContext.js.map +7 -0
  17. package/cjs/index.js +37 -27
  18. package/cjs/index.js.map +7 -0
  19. package/cjs/parts/CheckboxSelectable.js +70 -59
  20. package/cjs/parts/CheckboxSelectable.js.map +7 -0
  21. package/cjs/parts/ChildrenCountDisplayer.js +45 -28
  22. package/cjs/parts/ChildrenCountDisplayer.js.map +7 -0
  23. package/cjs/parts/DnDHandle.js +57 -0
  24. package/cjs/parts/DnDHandle.js.map +7 -0
  25. package/cjs/parts/DropIndicator.js +80 -0
  26. package/cjs/parts/DropIndicator.js.map +7 -0
  27. package/cjs/parts/ExpandCaret.js +85 -83
  28. package/cjs/parts/ExpandCaret.js.map +7 -0
  29. package/cjs/parts/Icon.js +46 -31
  30. package/cjs/parts/Icon.js.map +7 -0
  31. package/cjs/parts/NestingSpace.js +43 -35
  32. package/cjs/parts/NestingSpace.js.map +7 -0
  33. package/cjs/parts/RadioSelectable.js +52 -37
  34. package/cjs/parts/RadioSelectable.js.map +7 -0
  35. package/cjs/parts/TreeItem.js +121 -165
  36. package/cjs/parts/TreeItem.js.map +7 -0
  37. package/cjs/parts/TreeItemText.js +88 -95
  38. package/cjs/parts/TreeItemText.js.map +7 -0
  39. package/cjs/parts/TreeList.js +114 -132
  40. package/cjs/parts/TreeList.js.map +7 -0
  41. package/cjs/plugins/dnd/TreeDndPlugin.js +34 -43
  42. package/cjs/plugins/dnd/TreeDndPlugin.js.map +7 -0
  43. package/cjs/plugins/dnd/index.js +28 -10
  44. package/cjs/plugins/dnd/index.js.map +7 -0
  45. package/cjs/plugins/index.js +34 -22
  46. package/cjs/plugins/index.js.map +7 -0
  47. package/cjs/plugins/roving/TreeRovingPlugin.js +35 -7
  48. package/cjs/plugins/roving/TreeRovingPlugin.js.map +7 -0
  49. package/cjs/plugins/roving/index.js +28 -9
  50. package/cjs/plugins/roving/index.js.map +7 -0
  51. package/cjs/plugins/searchable/SearchableTreePlugin.js +35 -7
  52. package/cjs/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  53. package/cjs/plugins/searchable/index.js +28 -9
  54. package/cjs/plugins/searchable/index.js.map +7 -0
  55. package/cjs/plugins/selectable/SelectablePluginTree.js +35 -7
  56. package/cjs/plugins/selectable/SelectablePluginTree.js.map +7 -0
  57. package/cjs/plugins/selectable/index.js +28 -9
  58. package/cjs/plugins/selectable/index.js.map +7 -0
  59. package/cjs/plugins/toolbar/TreeToolbarPlugin.js +35 -7
  60. package/cjs/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  61. package/cjs/plugins/toolbar/index.js +28 -9
  62. package/cjs/plugins/toolbar/index.js.map +7 -0
  63. package/cjs/plugins/tree/TreeDataPlugin.js +35 -7
  64. package/cjs/plugins/tree/TreeDataPlugin.js.map +7 -0
  65. package/cjs/plugins/tree/index.js +28 -9
  66. package/cjs/plugins/tree/index.js.map +7 -0
  67. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js +35 -7
  68. package/cjs/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  69. package/cjs/plugins/virtualization/index.js +28 -9
  70. package/cjs/plugins/virtualization/index.js.map +7 -0
  71. package/cjs/react-desc-prop-types.js +83 -53
  72. package/cjs/react-desc-prop-types.js.map +7 -0
  73. package/cjs/related-components/TreeViewSearchBar.js +42 -40
  74. package/cjs/related-components/TreeViewSearchBar.js.map +7 -0
  75. package/cjs/sharedTypes.js +27 -2
  76. package/cjs/sharedTypes.js.map +7 -0
  77. package/cjs/utils/array-helpers.js +35 -11
  78. package/cjs/utils/array-helpers.js.map +7 -0
  79. package/cjs/utils/group-expands-helpers.js +86 -59
  80. package/cjs/utils/group-expands-helpers.js.map +7 -0
  81. package/cjs/utils/keyboard-helpers.js +86 -90
  82. package/cjs/utils/keyboard-helpers.js.map +7 -0
  83. package/cjs/utils/object-helpers.js +43 -36
  84. package/cjs/utils/object-helpers.js.map +7 -0
  85. package/cjs/utils/refs-helpers.js +43 -22
  86. package/cjs/utils/refs-helpers.js.map +7 -0
  87. package/cjs/utils/selectable-helper.js +61 -53
  88. package/cjs/utils/selectable-helper.js.map +7 -0
  89. package/cjs/utils/string-helpers.js +35 -7
  90. package/cjs/utils/string-helpers.js.map +7 -0
  91. package/cjs/utils/tree-helpers.js +125 -135
  92. package/cjs/utils/tree-helpers.js.map +7 -0
  93. package/cjs/utils/useInstanceRefActions.js +54 -43
  94. package/cjs/utils/useInstanceRefActions.js.map +7 -0
  95. package/cjs/utils/useTree.js +78 -78
  96. package/cjs/utils/useTree.js.map +7 -0
  97. package/esm/TreeView.js +16 -20
  98. package/esm/TreeView.js.map +7 -0
  99. package/esm/TreeViewContext.js +26 -37
  100. package/esm/TreeViewContext.js.map +7 -0
  101. package/esm/config/cssClassesConstants.js +12 -6
  102. package/esm/config/cssClassesConstants.js.map +7 -0
  103. package/esm/config/useTreeview.js +59 -66
  104. package/esm/config/useTreeview.js.map +7 -0
  105. package/esm/hoc/DnDTreeContext.js +16 -0
  106. package/esm/hoc/DnDTreeContext.js.map +7 -0
  107. package/esm/hoc/SortableItemContext.js +17 -0
  108. package/esm/hoc/SortableItemContext.js.map +7 -0
  109. package/esm/hoc/WithConditionalDnDContext.js +99 -0
  110. package/esm/hoc/WithConditionalDnDContext.js.map +7 -0
  111. package/esm/hoc/WithDnDSortableItemContext.js +40 -0
  112. package/esm/hoc/WithDnDSortableItemContext.js.map +7 -0
  113. package/esm/index.js +8 -9
  114. package/esm/index.js.map +7 -0
  115. package/esm/parts/CheckboxSelectable.js +36 -46
  116. package/esm/parts/CheckboxSelectable.js.map +7 -0
  117. package/esm/parts/ChildrenCountDisplayer.js +16 -20
  118. package/esm/parts/ChildrenCountDisplayer.js.map +7 -0
  119. package/esm/parts/DnDHandle.js +28 -0
  120. package/esm/parts/DnDHandle.js.map +7 -0
  121. package/esm/parts/DropIndicator.js +51 -0
  122. package/esm/parts/DropIndicator.js.map +7 -0
  123. package/esm/parts/ExpandCaret.js +54 -72
  124. package/esm/parts/ExpandCaret.js.map +7 -0
  125. package/esm/parts/Icon.js +16 -22
  126. package/esm/parts/Icon.js.map +7 -0
  127. package/esm/parts/NestingSpace.js +14 -27
  128. package/esm/parts/NestingSpace.js.map +7 -0
  129. package/esm/parts/RadioSelectable.js +20 -28
  130. package/esm/parts/RadioSelectable.js.map +7 -0
  131. package/esm/parts/TreeItem.js +89 -150
  132. package/esm/parts/TreeItem.js.map +7 -0
  133. package/esm/parts/TreeItemText.js +58 -85
  134. package/esm/parts/TreeItemText.js.map +7 -0
  135. package/esm/parts/TreeList.js +86 -120
  136. package/esm/parts/TreeList.js.map +7 -0
  137. package/esm/plugins/dnd/TreeDndPlugin.js +5 -34
  138. package/esm/plugins/dnd/TreeDndPlugin.js.map +7 -0
  139. package/esm/plugins/dnd/index.js +3 -1
  140. package/esm/plugins/dnd/index.js.map +7 -0
  141. package/esm/plugins/index.js +9 -7
  142. package/esm/plugins/index.js.map +7 -0
  143. package/esm/plugins/roving/TreeRovingPlugin.js +6 -3
  144. package/esm/plugins/roving/TreeRovingPlugin.js.map +7 -0
  145. package/esm/plugins/roving/index.js +3 -1
  146. package/esm/plugins/roving/index.js.map +7 -0
  147. package/esm/plugins/searchable/SearchableTreePlugin.js +6 -3
  148. package/esm/plugins/searchable/SearchableTreePlugin.js.map +7 -0
  149. package/esm/plugins/searchable/index.js +3 -1
  150. package/esm/plugins/searchable/index.js.map +7 -0
  151. package/esm/plugins/selectable/SelectablePluginTree.js +6 -3
  152. package/esm/plugins/selectable/SelectablePluginTree.js.map +7 -0
  153. package/esm/plugins/selectable/index.js +3 -1
  154. package/esm/plugins/selectable/index.js.map +7 -0
  155. package/esm/plugins/toolbar/TreeToolbarPlugin.js +6 -3
  156. package/esm/plugins/toolbar/TreeToolbarPlugin.js.map +7 -0
  157. package/esm/plugins/toolbar/index.js +3 -1
  158. package/esm/plugins/toolbar/index.js.map +7 -0
  159. package/esm/plugins/tree/TreeDataPlugin.js +6 -3
  160. package/esm/plugins/tree/TreeDataPlugin.js.map +7 -0
  161. package/esm/plugins/tree/index.js +3 -1
  162. package/esm/plugins/tree/index.js.map +7 -0
  163. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js +6 -3
  164. package/esm/plugins/virtualization/TreeVirtualizationPlugin.js.map +7 -0
  165. package/esm/plugins/virtualization/index.js +3 -1
  166. package/esm/plugins/virtualization/index.js.map +7 -0
  167. package/esm/react-desc-prop-types.js +48 -43
  168. package/esm/react-desc-prop-types.js.map +7 -0
  169. package/esm/related-components/TreeViewSearchBar.js +13 -32
  170. package/esm/related-components/TreeViewSearchBar.js.map +7 -0
  171. package/esm/sharedTypes.js +2 -1
  172. package/esm/sharedTypes.js.map +7 -0
  173. package/esm/utils/array-helpers.js +6 -6
  174. package/esm/utils/array-helpers.js.map +7 -0
  175. package/esm/utils/group-expands-helpers.js +56 -46
  176. package/esm/utils/group-expands-helpers.js.map +7 -0
  177. package/esm/utils/keyboard-helpers.js +47 -74
  178. package/esm/utils/keyboard-helpers.js.map +7 -0
  179. package/esm/utils/object-helpers.js +14 -31
  180. package/esm/utils/object-helpers.js.map +7 -0
  181. package/esm/utils/refs-helpers.js +15 -19
  182. package/esm/utils/refs-helpers.js.map +7 -0
  183. package/esm/utils/selectable-helper.js +32 -43
  184. package/esm/utils/selectable-helper.js.map +7 -0
  185. package/esm/utils/string-helpers.js +6 -3
  186. package/esm/utils/string-helpers.js.map +7 -0
  187. package/esm/utils/tree-helpers.js +94 -119
  188. package/esm/utils/tree-helpers.js.map +7 -0
  189. package/esm/utils/useInstanceRefActions.js +21 -35
  190. package/esm/utils/useInstanceRefActions.js.map +7 -0
  191. package/esm/utils/useTree.js +37 -57
  192. package/esm/utils/useTree.js.map +7 -0
  193. package/package.json +34 -18
  194. package/types/hoc/DnDTreeContext.d.ts +14 -0
  195. package/types/hoc/SortableItemContext.d.ts +19 -0
  196. package/types/hoc/WithConditionalDnDContext.d.ts +4 -0
  197. package/types/hoc/WithDnDSortableItemContext.d.ts +4 -0
  198. package/types/parts/DnDHandle.d.ts +6 -0
  199. package/types/parts/DropIndicator.d.ts +10 -0
  200. package/types/parts/TreeItem.d.ts +4 -11
  201. package/types/parts/TreeList.d.ts +0 -4
  202. package/types/plugins/dnd/TreeDndPlugin.d.ts +0 -2
  203. package/types/react-desc-prop-types.d.ts +17 -3
  204. package/types/sharedTypes.d.ts +1 -8
  205. package/types/utils/keyboard-helpers.d.ts +2 -1
  206. package/types/utils/refs-helpers.d.ts +1 -1
  207. package/types/utils/tree-helpers.d.ts +4 -1
  208. package/types/utils/useTree.d.ts +1 -0
  209. package/cjs/utils/dnd-helpers.js +0 -140
  210. package/cjs/utils/useDnDHelpers.js +0 -220
  211. package/esm/utils/dnd-helpers.js +0 -132
  212. package/esm/utils/useDnDHelpers.js +0 -216
  213. package/types/utils/dnd-helpers.d.ts +0 -39
  214. package/types/utils/useDnDHelpers.d.ts +0 -26
@@ -1,111 +1,138 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
-
7
- /* eslint-disable max-params */
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var group_expands_helpers_exports = {};
29
+ __export(group_expands_helpers_exports, {
30
+ collapseAll: () => collapseAll,
31
+ collapseItemModel: () => collapseItemModel,
32
+ expandAll: () => expandAll,
33
+ expandItemModel: () => expandItemModel,
34
+ getToggleExpandShouldExpand: () => getToggleExpandShouldExpand,
35
+ toggleExpandAllHelper: () => toggleExpandAllHelper,
36
+ toggleItemExpand: () => toggleItemExpand,
37
+ updateExpandedState: () => updateExpandedState,
38
+ useNotifyExpandedChange: () => useNotifyExpandedChange
39
+ });
40
+ var React = __toESM(require("react"));
41
+ var import_react = require("react");
8
42
  const updateExpandedState = (treeRoot, onExpandChange) => {
9
43
  const shouldContinueWalking = true;
10
- const newExpandedHashMap = {
11
- __ds_tree_root: true
12
- };
13
- treeRoot.walk(node => {
44
+ const newExpandedHashMap = { __ds_tree_root: true };
45
+ treeRoot.walk((node) => {
14
46
  if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {
15
47
  newExpandedHashMap[node.model.id] = true;
16
48
  }
17
-
18
49
  return shouldContinueWalking;
19
50
  });
20
- if (onExpandChange) onExpandChange(newExpandedHashMap, null);
51
+ if (onExpandChange)
52
+ onExpandChange(newExpandedHashMap, null);
21
53
  };
22
- const toggleItemExpand = function (itemToToggle, triggerTreeRerender, updateUserExpandedState) {
23
- let scrollTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : () => {};
54
+ const toggleItemExpand = (itemToToggle, triggerTreeRerender, updateUserExpandedState, scrollTo = () => {
55
+ }) => {
24
56
  const {
25
57
  node: {
26
- model: {
27
- isExpanded
28
- }
58
+ model: { isExpanded }
29
59
  },
30
60
  virtualIndex
31
61
  } = itemToToggle;
32
-
33
62
  if (itemToToggle.node.model.isGroup) {
34
63
  itemToToggle.node.model.isExpanded = !isExpanded;
35
64
  triggerTreeRerender();
36
65
  updateUserExpandedState();
37
66
  setTimeout(() => {
38
- if (typeof virtualIndex === 'number') scrollTo(virtualIndex, {
39
- align: 'start'
40
- });
67
+ if (typeof virtualIndex === "number")
68
+ scrollTo(virtualIndex, { align: "start" });
41
69
  });
42
70
  }
43
71
  };
44
- const expandItemModel = modelToExpand => {
45
- if (modelToExpand.isGroup) modelToExpand.isExpanded = true;
72
+ const expandItemModel = (modelToExpand) => {
73
+ if (modelToExpand.isGroup)
74
+ modelToExpand.isExpanded = true;
46
75
  };
47
- const collapseItemModel = modelToCollapse => {
48
- if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;
76
+ const collapseItemModel = (modelToCollapse) => {
77
+ if (modelToCollapse.isGroup)
78
+ modelToCollapse.isExpanded = false;
49
79
  };
50
80
  const expandAll = (treeRoot, triggerTreeRerender) => {
51
81
  const shouldContinueWalking = true;
52
- treeRoot.walk(node => {
53
- if (!node.isRoot()) expandItemModel(node.model);
82
+ treeRoot.walk((node) => {
83
+ if (!node.isRoot())
84
+ expandItemModel(node.model);
54
85
  return shouldContinueWalking;
55
86
  });
56
87
  triggerTreeRerender();
57
88
  };
58
89
  const collapseAll = (treeRoot, triggerTreeRerender) => {
59
- const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
60
-
61
- treeRoot.walk(node => {
62
- if (!node.isRoot()) collapseItemModel(node.model);
90
+ const shouldContinueWalking = true;
91
+ treeRoot.walk((node) => {
92
+ if (!node.isRoot())
93
+ collapseItemModel(node.model);
63
94
  return shouldContinueWalking;
64
95
  });
65
96
  triggerTreeRerender();
66
97
  };
67
- const getToggleExpandShouldExpand = treeRoot => {
98
+ const getToggleExpandShouldExpand = (treeRoot) => {
68
99
  let shouldExpand = false;
69
- const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking
70
-
71
- treeRoot.walk(node => {
100
+ const shouldContinueWalking = true;
101
+ treeRoot.walk((node) => {
72
102
  if (!node.isRoot()) {
73
103
  if (!node.model.isExpanded && node.model.isGroup) {
74
- shouldExpand = true; // eslint-disable-next-line no-useless-return
75
-
104
+ shouldExpand = true;
76
105
  return shouldContinueWalking;
77
106
  }
78
107
  }
79
-
80
108
  return shouldContinueWalking;
81
109
  });
82
110
  return shouldExpand;
83
111
  };
84
112
  const toggleExpandAllHelper = (isExpand, treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
85
- if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);else {
113
+ if (isExpand === true)
114
+ expandAll(treeRoot, triggerTreeRerender);
115
+ else if (isExpand === false)
116
+ collapseAll(treeRoot, triggerTreeRerender);
117
+ else {
86
118
  const shouldExpand = getToggleExpandShouldExpand(treeRoot);
87
- if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);else collapseAll(treeRoot, triggerTreeRerender);
119
+ if (shouldExpand === true)
120
+ expandAll(treeRoot, triggerTreeRerender);
121
+ else
122
+ collapseAll(treeRoot, triggerTreeRerender);
88
123
  }
89
124
  setLatestToggledItem(null);
90
125
  updateUserExpandedState();
91
126
  };
92
- const useNotifyExpandedChange = (propsWithDefaults, _ref) => {
93
- let {
94
- latestToggledItem,
95
- expandedGroups
96
- } = _ref;
97
- const notifyExpandedChange = React.useCallback(expandedGroupHashmap => propsWithDefaults === null || propsWithDefaults === void 0 ? void 0 : propsWithDefaults.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
98
- React.useEffect(() => {
99
- if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);
127
+ const useNotifyExpandedChange = (propsWithDefaults, {
128
+ latestToggledItem,
129
+ expandedGroups
130
+ }) => {
131
+ const notifyExpandedChange = (0, import_react.useCallback)((expandedGroupHashmap) => propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem), [propsWithDefaults, latestToggledItem]);
132
+ (0, import_react.useEffect)(() => {
133
+ if (!propsWithDefaults.expanded)
134
+ notifyExpandedChange(expandedGroups);
100
135
  }, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);
101
136
  };
102
-
103
- exports.collapseAll = collapseAll;
104
- exports.collapseItemModel = collapseItemModel;
105
- exports.expandAll = expandAll;
106
- exports.expandItemModel = expandItemModel;
107
- exports.getToggleExpandShouldExpand = getToggleExpandShouldExpand;
108
- exports.toggleExpandAllHelper = toggleExpandAllHelper;
109
- exports.toggleItemExpand = toggleItemExpand;
110
- exports.updateExpandedState = updateExpandedState;
111
- exports.useNotifyExpandedChange = useNotifyExpandedChange;
137
+ module.exports = __toCommonJS(group_expands_helpers_exports);
138
+ //# sourceMappingURL=group-expands-helpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/group-expands-helpers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable max-params */\nimport { useCallback, useEffect } from 'react';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\n\nexport const updateExpandedState = (\n treeRoot: DSTreeviewT.Item['node'],\n onExpandChange: DSTreeviewT.Props['onExpandChange'] | null | undefined,\n) => {\n const shouldContinueWalking = true;\n const newExpandedHashMap: DSTreeviewT.ExpandedItems = { __ds_tree_root: true };\n treeRoot.walk((node) => {\n if (!node.isRoot() && node.model.isGroup && node.model.isExpanded) {\n newExpandedHashMap[node.model.id] = true;\n }\n return shouldContinueWalking;\n });\n if (onExpandChange) onExpandChange(newExpandedHashMap, null);\n};\n\nexport const toggleItemExpand = (\n itemToToggle: DSTreeviewT.Item,\n triggerTreeRerender: () => void,\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n scrollTo: DSTreeviewT.ScrollToFunc = () => {},\n) => {\n const {\n node: {\n model: { isExpanded },\n },\n virtualIndex,\n } = itemToToggle;\n if (itemToToggle.node.model.isGroup) {\n itemToToggle.node.model.isExpanded = !isExpanded;\n triggerTreeRerender();\n updateUserExpandedState();\n setTimeout(() => {\n if (typeof virtualIndex === 'number') scrollTo(virtualIndex, { align: 'start' });\n });\n }\n};\n\nexport const expandItemModel = (modelToExpand: DSTreeviewT.Item['model']) => {\n if (modelToExpand.isGroup) modelToExpand.isExpanded = true;\n};\n\nexport const collapseItemModel = (modelToCollapse: DSTreeviewT.Item['model']) => {\n if (modelToCollapse.isGroup) modelToCollapse.isExpanded = false;\n};\n\nexport const expandAll = (treeRoot: DSTreeviewT.Item['node'], triggerTreeRerender: () => void) => {\n const shouldContinueWalking = true;\n treeRoot.walk((node) => {\n if (!node.isRoot()) expandItemModel(node.model);\n return shouldContinueWalking;\n });\n triggerTreeRerender();\n};\n\nexport const collapseAll = (treeRoot: DSTreeviewT.Item['node'], triggerTreeRerender: () => void) => {\n const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking\n treeRoot.walk((node) => {\n if (!node.isRoot()) collapseItemModel(node.model);\n return shouldContinueWalking;\n });\n triggerTreeRerender();\n};\n\nexport const getToggleExpandShouldExpand = (treeRoot: DSTreeviewT.Item['node']) => {\n let shouldExpand = false;\n const shouldContinueWalking = true; // tree-model ask we return true if we want to continue walking\n treeRoot.walk((node) => {\n if (!node.isRoot()) {\n if (!node.model.isExpanded && node.model.isGroup) {\n shouldExpand = true;\n // eslint-disable-next-line no-useless-return\n return shouldContinueWalking;\n }\n }\n return shouldContinueWalking;\n });\n return shouldExpand;\n};\n\nexport const toggleExpandAllHelper = (\n isExpand: boolean | 'toggle',\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n if (isExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else if (isExpand === false) collapseAll(treeRoot, triggerTreeRerender);\n else {\n const shouldExpand = getToggleExpandShouldExpand(treeRoot);\n if (shouldExpand === true) expandAll(treeRoot, triggerTreeRerender);\n else collapseAll(treeRoot, triggerTreeRerender);\n }\n setLatestToggledItem(null);\n updateUserExpandedState();\n};\n\nexport const useNotifyExpandedChange = (\n propsWithDefaults: DSTreeviewT.Props,\n {\n latestToggledItem,\n expandedGroups,\n }: {\n latestToggledItem?: DSTreeviewInternalsT.CTX['latestToggledItem'];\n expandedGroups?: DSTreeviewInternalsT.CTX['expandedGroups'];\n },\n) => {\n const notifyExpandedChange = useCallback(\n (expandedGroupHashmap?: DSTreeviewInternalsT.CTX['expandedGroups']) =>\n propsWithDefaults?.onExpandChange(expandedGroupHashmap || {}, latestToggledItem),\n [propsWithDefaults, latestToggledItem],\n );\n\n useEffect(() => {\n if (!propsWithDefaults.expanded) notifyExpandedChange(expandedGroups);\n }, [expandedGroups, notifyExpandedChange, propsWithDefaults.expanded]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAuC;AAIhC,MAAM,sBAAsB,CACjC,UACA,mBACG;AACH,QAAM,wBAAwB;AAC9B,QAAM,qBAAgD,EAAE,gBAAgB;AACxE,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK,YAAY,KAAK,MAAM,WAAW,KAAK,MAAM,YAAY;AACjE,yBAAmB,KAAK,MAAM,MAAM;AAAA;AAEtC,WAAO;AAAA;AAET,MAAI;AAAgB,mBAAe,oBAAoB;AAAA;AAGlD,MAAM,mBAAmB,CAC9B,cACA,qBACA,yBACA,WAAqC,MAAM;AAAA,MACxC;AACH,QAAM;AAAA,IACJ,MAAM;AAAA,MACJ,OAAO,EAAE;AAAA;AAAA,IAEX;AAAA,MACE;AACJ,MAAI,aAAa,KAAK,MAAM,SAAS;AACnC,iBAAa,KAAK,MAAM,aAAa,CAAC;AACtC;AACA;AACA,eAAW,MAAM;AACf,UAAI,OAAO,iBAAiB;AAAU,iBAAS,cAAc,EAAE,OAAO;AAAA;AAAA;AAAA;AAKrE,MAAM,kBAAkB,CAAC,kBAA6C;AAC3E,MAAI,cAAc;AAAS,kBAAc,aAAa;AAAA;AAGjD,MAAM,oBAAoB,CAAC,oBAA+C;AAC/E,MAAI,gBAAgB;AAAS,oBAAgB,aAAa;AAAA;AAGrD,MAAM,YAAY,CAAC,UAAoC,wBAAoC;AAChG,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK;AAAU,sBAAgB,KAAK;AACzC,WAAO;AAAA;AAET;AAAA;AAGK,MAAM,cAAc,CAAC,UAAoC,wBAAoC;AAClG,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK;AAAU,wBAAkB,KAAK;AAC3C,WAAO;AAAA;AAET;AAAA;AAGK,MAAM,8BAA8B,CAAC,aAAuC;AACjF,MAAI,eAAe;AACnB,QAAM,wBAAwB;AAC9B,WAAS,KAAK,CAAC,SAAS;AACtB,QAAI,CAAC,KAAK,UAAU;AAClB,UAAI,CAAC,KAAK,MAAM,cAAc,KAAK,MAAM,SAAS;AAChD,uBAAe;AAEf,eAAO;AAAA;AAAA;AAGX,WAAO;AAAA;AAET,SAAO;AAAA;AAGF,MAAM,wBAAwB,CACnC,UACA,UACA,qBACA,sBACA,4BACG;AACH,MAAI,aAAa;AAAM,cAAU,UAAU;AAAA,WAClC,aAAa;AAAO,gBAAY,UAAU;AAAA,OAC9C;AACH,UAAM,eAAe,4BAA4B;AACjD,QAAI,iBAAiB;AAAM,gBAAU,UAAU;AAAA;AAC1C,kBAAY,UAAU;AAAA;AAE7B,uBAAqB;AACrB;AAAA;AAGK,MAAM,0BAA0B,CACrC,mBACA;AAAA,EACE;AAAA,EACA;AAAA,MAKC;AACH,QAAM,uBAAuB,8BAC3B,CAAC,yBACC,mBAAmB,eAAe,wBAAwB,IAAI,oBAChE,CAAC,mBAAmB;AAGtB,8BAAU,MAAM;AACd,QAAI,CAAC,kBAAkB;AAAU,2BAAqB;AAAA,KACrD,CAAC,gBAAgB,sBAAsB,kBAAkB;AAAA;",
6
+ "names": []
7
+ }
@@ -1,126 +1,116 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var TreeViewContext = require('../TreeViewContext.js');
7
- var treeHelpers = require('./tree-helpers.js');
8
- var groupExpandsHelpers = require('./group-expands-helpers.js');
9
-
10
- /* eslint-disable max-params */
11
- // 9 tab
12
- // 13 enter
13
- // 32 space
14
- // 37 left arrow
15
- // 38 up arrow
16
- // 39 right arrow
17
- // 40 down arrow
18
- // 35 end
19
- // 36 home
20
- // 56 number 8
21
- // 106 (NumPad) *
22
- const useOnItemKeyDown = item => {
23
- const ctx = React.useContext(TreeViewContext["default"]);
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var keyboard_helpers_exports = {};
29
+ __export(keyboard_helpers_exports, {
30
+ useGlobalKeyboardListener: () => useGlobalKeyboardListener,
31
+ useGlobalToggleAllExpandShortcut: () => useGlobalToggleAllExpandShortcut,
32
+ useOnItemKeyDown: () => useOnItemKeyDown
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_react = require("react");
36
+ var import_TreeViewContext = __toESM(require("../TreeViewContext"));
37
+ var import_tree_helpers = require("./tree-helpers");
38
+ var import_group_expands_helpers = require("./group-expands-helpers");
39
+ const useOnItemKeyDown = (item, draggableProps) => {
40
+ const ctx = (0, import_react.useContext)(import_TreeViewContext.default);
24
41
  const {
25
- props: {
26
- onItemFocus
27
- },
42
+ props: { onItemFocus },
28
43
  triggerTreeRerender,
29
- isDragging,
30
44
  visibleItems,
31
45
  setFocusedItem,
32
46
  setSelectedItem,
33
47
  setLatestToggledItem,
34
48
  updateUserExpandedState,
35
- virtualListHelpers: {
36
- scrollToIndex
37
- }
49
+ virtualListHelpers: { scrollToIndex }
38
50
  } = ctx;
39
- const {
40
- isGroup,
41
- isExpanded
42
- } = item;
43
- const onItemFocusCurry = React.useCallback(newFocusItem => onItemFocus({
51
+ const { isGroup, isExpanded } = item;
52
+ const onItemFocusCurry = (0, import_react.useCallback)((newFocusItem) => onItemFocus({
44
53
  itemIndex: newFocusItem.virtualIndex,
45
- scrollToItem: function () {
46
- let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
47
- align: 'start'
48
- };
49
- return scrollToIndex(newFocusItem.virtualIndex, opts);
50
- },
54
+ scrollToItem: (opts = { align: "start" }) => scrollToIndex(newFocusItem.virtualIndex, opts),
51
55
  item: newFocusItem
52
56
  }), [onItemFocus, scrollToIndex]);
53
- const onItemKeyDown = React.useCallback(e => {
54
- const {
55
- keyCode
56
- } = e;
57
-
58
- if (!isDragging) {
59
- if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab
60
-
61
- if (keyCode === 13 || keyCode === 32) setSelectedItem(item);
62
-
57
+ const onItemKeyDown = (0, import_react.useCallback)((e) => {
58
+ const { keyCode } = e;
59
+ if (!(draggableProps && draggableProps.active)) {
60
+ if (keyCode !== 9)
61
+ e.preventDefault();
62
+ if ((keyCode === 13 || keyCode === 32) && e.target.tagName === "LI") {
63
+ setSelectedItem(item);
64
+ }
63
65
  if (keyCode === 37) {
64
66
  if (isGroup && isExpanded) {
65
- groupExpandsHelpers.toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
67
+ (0, import_group_expands_helpers.toggleItemExpand)(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
66
68
  setLatestToggledItem(item);
67
69
  }
68
70
  }
69
-
70
71
  if (keyCode === 39) {
71
72
  if (isGroup && !isExpanded) {
72
- groupExpandsHelpers.toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
73
+ (0, import_group_expands_helpers.toggleItemExpand)(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);
73
74
  setLatestToggledItem(item);
74
75
  }
75
76
  }
76
-
77
- const {
78
- virtualIndex
79
- } = item;
80
-
81
- if (typeof virtualIndex === 'number') {
77
+ const { virtualIndex } = item;
78
+ if (typeof virtualIndex === "number") {
82
79
  const lastItemIndex = visibleItems.length - 1;
83
-
84
80
  if (keyCode === 38) {
85
81
  const isLoopedFocus = virtualIndex === 0;
86
82
  const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;
87
83
  const newFocusItem = visibleItems[newFocusIndex];
88
84
  scrollToIndex(newFocusIndex);
89
-
90
85
  if (isLoopedFocus) {
91
- // when looping the list from start to end we need to wait a bit before focusing
92
86
  setTimeout(() => {
93
87
  setFocusedItem(newFocusItem);
94
- treeHelpers.focusItem(newFocusItem);
88
+ (0, import_tree_helpers.focusItem)(newFocusItem);
95
89
  onItemFocusCurry(newFocusItem);
96
90
  }, 300);
97
91
  } else {
98
92
  setFocusedItem(newFocusItem);
99
93
  onItemFocusCurry(newFocusItem);
100
- treeHelpers.focusItem(newFocusItem);
94
+ (0, import_tree_helpers.focusItem)(newFocusItem);
101
95
  }
102
96
  }
103
-
104
97
  if (keyCode === 40) {
105
98
  const isLoopedFocus = virtualIndex === lastItemIndex;
106
99
  const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;
107
100
  const newFocusItem = visibleItems[newFocusIndex];
108
101
  scrollToIndex(newFocusIndex);
109
-
110
102
  if (isLoopedFocus) {
111
- // when looping the list from start to end we need to wait a bit before focusing
112
103
  setTimeout(() => {
113
104
  setFocusedItem(newFocusItem);
114
105
  onItemFocusCurry(newFocusItem);
115
- treeHelpers.focusItem(newFocusItem);
106
+ (0, import_tree_helpers.focusItem)(newFocusItem);
116
107
  }, 300);
117
108
  } else {
118
109
  setFocusedItem(newFocusItem);
119
110
  onItemFocusCurry(newFocusItem);
120
- treeHelpers.focusItem(newFocusItem);
111
+ (0, import_tree_helpers.focusItem)(newFocusItem);
121
112
  }
122
113
  }
123
-
124
114
  if (keyCode === 35) {
125
115
  if (virtualIndex !== lastItemIndex) {
126
116
  const newFocusItem = visibleItems[lastItemIndex];
@@ -128,11 +118,10 @@ const useOnItemKeyDown = item => {
128
118
  setTimeout(() => {
129
119
  setFocusedItem(newFocusItem);
130
120
  onItemFocusCurry(newFocusItem);
131
- treeHelpers.focusItem(newFocusItem);
121
+ (0, import_tree_helpers.focusItem)(newFocusItem);
132
122
  }, 300);
133
123
  }
134
124
  }
135
-
136
125
  if (keyCode === 36) {
137
126
  if (virtualIndex !== 0) {
138
127
  const newFocusItem = visibleItems[0];
@@ -140,35 +129,42 @@ const useOnItemKeyDown = item => {
140
129
  setTimeout(() => {
141
130
  setFocusedItem(newFocusItem);
142
131
  onItemFocusCurry(newFocusItem);
143
- treeHelpers.focusItem(newFocusItem);
132
+ (0, import_tree_helpers.focusItem)(newFocusItem);
144
133
  }, 300);
145
134
  }
146
135
  }
147
136
  }
148
137
  }
149
- }, [isDragging, setSelectedItem, item, isGroup, isExpanded, triggerTreeRerender, scrollToIndex, setLatestToggledItem, visibleItems, setFocusedItem, onItemFocusCurry, updateUserExpandedState]);
138
+ }, [
139
+ draggableProps,
140
+ setSelectedItem,
141
+ item,
142
+ isGroup,
143
+ isExpanded,
144
+ triggerTreeRerender,
145
+ updateUserExpandedState,
146
+ scrollToIndex,
147
+ setLatestToggledItem,
148
+ visibleItems,
149
+ setFocusedItem,
150
+ onItemFocusCurry
151
+ ]);
150
152
  return onItemKeyDown;
151
153
  };
152
- const useGlobalKeyboardListener = func => {
153
- React.useEffect(() => {
154
- document.addEventListener('keydown', func);
155
- return () => document.removeEventListener('keydown', func);
154
+ const useGlobalKeyboardListener = (func) => {
155
+ (0, import_react.useEffect)(() => {
156
+ document.addEventListener("keydown", func);
157
+ return () => document.removeEventListener("keydown", func);
156
158
  }, [func]);
157
159
  };
158
160
  const useGlobalToggleAllExpandShortcut = (treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState) => {
159
- const memoizedToggleAllKeyboardShortcut = React.useCallback(e => {
160
- const {
161
- shiftKey,
162
- keyCode
163
- } = e;
164
-
161
+ const memoizedToggleAllKeyboardShortcut = (0, import_react.useCallback)((e) => {
162
+ const { shiftKey, keyCode } = e;
165
163
  if (shiftKey && keyCode === 56) {
166
- groupExpandsHelpers.toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
164
+ (0, import_group_expands_helpers.toggleExpandAllHelper)("toggle", treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);
167
165
  }
168
166
  }, [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState]);
169
167
  return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);
170
168
  };
171
-
172
- exports.useGlobalKeyboardListener = useGlobalKeyboardListener;
173
- exports.useGlobalToggleAllExpandShortcut = useGlobalToggleAllExpandShortcut;
174
- exports.useOnItemKeyDown = useOnItemKeyDown;
169
+ module.exports = __toCommonJS(keyboard_helpers_exports);
170
+ //# sourceMappingURL=keyboard-helpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/keyboard-helpers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable max-params */\n/* eslint-disable max-lines */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext, useEffect } from 'react';\nimport TreeViewContext from '../TreeViewContext';\nimport { focusItem } from './tree-helpers';\nimport { toggleExpandAllHelper, toggleItemExpand } from './group-expands-helpers';\nimport type { DSTreeviewT } from '../react-desc-prop-types';\nimport type { DSTreeviewInternalsT } from '../sharedTypes';\nimport { SortableItemContextType } from '../hoc/SortableItemContext';\n\n// 9 tab\n// 13 enter\n// 32 space\n// 37 left arrow\n// 38 up arrow\n// 39 right arrow\n// 40 down arrow\n// 35 end\n// 36 home\n\n// 56 number 8\n// 106 (NumPad) *\n\nexport const useOnItemKeyDown = (item: DSTreeviewT.Item, draggableProps: SortableItemContextType['draggableProps']) => {\n const ctx = useContext(TreeViewContext);\n const {\n props: { onItemFocus },\n triggerTreeRerender,\n visibleItems,\n setFocusedItem,\n setSelectedItem,\n setLatestToggledItem,\n updateUserExpandedState,\n virtualListHelpers: { scrollToIndex },\n } = ctx;\n const { isGroup, isExpanded } = item;\n const onItemFocusCurry = useCallback(\n (newFocusItem: DSTreeviewT.Item) =>\n onItemFocus({\n itemIndex: newFocusItem.virtualIndex as number,\n scrollToItem: (opts = { align: 'start' }) => scrollToIndex(newFocusItem.virtualIndex as number, opts),\n item: newFocusItem,\n }),\n [onItemFocus, scrollToIndex],\n );\n\n const onItemKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLLIElement>) => {\n const { keyCode } = e;\n if (!(draggableProps && draggableProps.active)) {\n if (keyCode !== 9) e.preventDefault(); // allow tab/shift+tab\n if ((keyCode === 13 || keyCode === 32) && (e.target as HTMLElement).tagName === 'LI') {\n setSelectedItem(item);\n }\n\n if (keyCode === 37) {\n if (isGroup && isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n if (keyCode === 39) {\n if (isGroup && !isExpanded) {\n toggleItemExpand(item, triggerTreeRerender, updateUserExpandedState, scrollToIndex);\n setLatestToggledItem(item);\n }\n }\n\n const { virtualIndex } = item;\n if (typeof virtualIndex === 'number') {\n const lastItemIndex = visibleItems.length - 1;\n if (keyCode === 38) {\n const isLoopedFocus = virtualIndex === 0;\n const newFocusIndex = isLoopedFocus ? lastItemIndex : virtualIndex - 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n focusItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 40) {\n const isLoopedFocus = virtualIndex === lastItemIndex;\n const newFocusIndex = isLoopedFocus ? 0 : virtualIndex + 1;\n const newFocusItem = visibleItems[newFocusIndex];\n scrollToIndex(newFocusIndex);\n if (isLoopedFocus) {\n // when looping the list from start to end we need to wait a bit before focusing\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n } else {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }\n }\n if (keyCode === 35) {\n if (virtualIndex !== lastItemIndex) {\n const newFocusItem = visibleItems[lastItemIndex];\n scrollToIndex(lastItemIndex);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n if (keyCode === 36) {\n if (virtualIndex !== 0) {\n const newFocusItem = visibleItems[0];\n scrollToIndex(0);\n setTimeout(() => {\n setFocusedItem(newFocusItem);\n onItemFocusCurry(newFocusItem);\n focusItem(newFocusItem);\n }, 300);\n }\n }\n }\n }\n },\n [\n draggableProps,\n setSelectedItem,\n item,\n isGroup,\n isExpanded,\n triggerTreeRerender,\n updateUserExpandedState,\n scrollToIndex,\n setLatestToggledItem,\n visibleItems,\n setFocusedItem,\n onItemFocusCurry,\n ],\n );\n\n return onItemKeyDown;\n};\n\nexport const useGlobalKeyboardListener = (func: (e: KeyboardEvent) => void) => {\n useEffect(() => {\n document.addEventListener('keydown', func);\n return () => document.removeEventListener('keydown', func);\n }, [func]);\n};\n\nexport const useGlobalToggleAllExpandShortcut = (\n treeRoot: DSTreeviewT.Item['node'],\n triggerTreeRerender: () => void,\n setLatestToggledItem: DSTreeviewInternalsT.CTX['setLatestToggledItem'],\n updateUserExpandedState: DSTreeviewInternalsT.CTX['updateUserExpandedState'],\n) => {\n const memoizedToggleAllKeyboardShortcut = useCallback(\n (e: KeyboardEvent) => {\n const { shiftKey, keyCode } = e;\n if (shiftKey && keyCode === 56) {\n toggleExpandAllHelper('toggle', treeRoot, triggerTreeRerender, setLatestToggledItem, updateUserExpandedState);\n }\n },\n [setLatestToggledItem, treeRoot, triggerTreeRerender, updateUserExpandedState],\n );\n\n return useGlobalKeyboardListener(memoizedToggleAllKeyboardShortcut);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -1,69 +1,76 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- require('core-js/modules/esnext.async-iterator.for-each.js');
6
- require('core-js/modules/esnext.iterator.constructor.js');
7
- require('core-js/modules/esnext.iterator.for-each.js');
8
- require('core-js/modules/esnext.async-iterator.reduce.js');
9
- require('core-js/modules/esnext.iterator.reduce.js');
10
-
11
- /* eslint-disable no-sequences */
12
-
13
- /* eslint-disable no-return-assign */
14
-
15
- /* eslint-disable no-restricted-syntax */
16
-
17
- /* eslint-disable guard-for-in */
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var object_helpers_exports = {};
29
+ __export(object_helpers_exports, {
30
+ filterObject: () => filterObject,
31
+ unfreeze: () => unfreeze
32
+ });
33
+ var React = __toESM(require("react"));
18
34
  function isObjectADate(o) {
19
- var _o$constructor;
20
-
21
- return (o === null || o === void 0 ? void 0 : (_o$constructor = o.constructor) === null || _o$constructor === void 0 ? void 0 : _o$constructor.name) === 'Date';
35
+ return o?.constructor?.name === "Date";
22
36
  }
23
-
24
37
  function isObjectAnArray(o) {
25
38
  return Array.isArray(o);
26
39
  }
27
-
28
40
  function isObjectAString(o) {
29
- return typeof o === 'object';
41
+ return typeof o === "object";
30
42
  }
31
-
32
- const unfreeze = o => {
43
+ const unfreeze = (o) => {
33
44
  let oo;
34
-
35
45
  if (o === null) {
36
46
  oo = null;
37
- } else if (o === undefined) {
38
- oo = undefined;
47
+ } else if (o === void 0) {
48
+ oo = void 0;
39
49
  } else if (isObjectADate(o)) {
40
50
  oo = new Date(o);
41
51
  } else if (isObjectAnArray(o)) {
42
52
  oo = [];
43
- o.forEach(v => {
53
+ o.forEach((v) => {
44
54
  oo.push(v);
45
55
  });
46
56
  } else if (isObjectAString(o)) {
47
57
  oo = String(o);
48
58
  } else if (isObjectAString(o)) {
49
59
  oo = {};
50
-
51
60
  for (const property in o) {
52
61
  oo[property] = o[property];
53
62
  }
54
63
  } else {
55
64
  oo = o;
56
65
  }
57
-
58
66
  return oo;
59
67
  };
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
68
  function filterObject(obj, predicate) {
62
69
  return Object.keys(obj).reduce((res, key) => {
63
- if (predicate(obj[key])) res[key] = obj[key];
70
+ if (predicate(obj[key]))
71
+ res[key] = obj[key];
64
72
  return res;
65
73
  }, {});
66
74
  }
67
-
68
- exports.filterObject = filterObject;
69
- exports.unfreeze = unfreeze;
75
+ module.exports = __toCommonJS(object_helpers_exports);
76
+ //# sourceMappingURL=object-helpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/object-helpers.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable no-sequences */\n/* eslint-disable no-return-assign */\n/* eslint-disable no-restricted-syntax */\n/* eslint-disable guard-for-in */\n\nfunction isObjectADate(o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>): o is Date {\n return o?.constructor?.name === 'Date';\n}\nfunction isObjectAnArray(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is unknown[] {\n return Array.isArray(o);\n}\nfunction isObjectAString(\n o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>,\n): o is Record<string, unknown> {\n return typeof o === 'object';\n}\n\nexport const unfreeze = (o: string | number | unknown[] | Date | null | undefined | Record<string, unknown>) => {\n let oo: string | number | unknown[] | Date | null | undefined | Record<string, unknown>;\n if (o === null) {\n oo = null;\n } else if (o === undefined) {\n oo = undefined;\n } else if (isObjectADate(o)) {\n oo = new Date(o);\n } else if (isObjectAnArray(o)) {\n oo = [];\n o.forEach((v) => {\n (oo as unknown[]).push(v);\n });\n } else if (isObjectAString(o)) {\n oo = String(o);\n } else if (isObjectAString(o)) {\n oo = {};\n for (const property in o) {\n oo[property] = o[property];\n }\n } else {\n oo = o;\n }\n return oo;\n};\n\ntype GenericItemT<T = unknown> = { [key: string]: T };\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function filterObject<T = unknown>(obj: GenericItemT<T>, predicate: (val: T) => boolean) {\n return Object.keys(obj).reduce<GenericItemT<T>>((res, key) => {\n if (predicate(obj[key])) res[key] = obj[key];\n return res;\n }, {} as GenericItemT<T>);\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,uBAAuB,GAA+F;AACpH,SAAO,GAAG,aAAa,SAAS;AAAA;AAElC,yBACE,GACgB;AAChB,SAAO,MAAM,QAAQ;AAAA;AAEvB,yBACE,GAC8B;AAC9B,SAAO,OAAO,MAAM;AAAA;AAGf,MAAM,WAAW,CAAC,MAAuF;AAC9G,MAAI;AACJ,MAAI,MAAM,MAAM;AACd,SAAK;AAAA,aACI,MAAM,QAAW;AAC1B,SAAK;AAAA,aACI,cAAc,IAAI;AAC3B,SAAK,IAAI,KAAK;AAAA,aACL,gBAAgB,IAAI;AAC7B,SAAK;AACL,MAAE,QAAQ,CAAC,MAAM;AACf,MAAC,GAAiB,KAAK;AAAA;AAAA,aAEhB,gBAAgB,IAAI;AAC7B,SAAK,OAAO;AAAA,aACH,gBAAgB,IAAI;AAC7B,SAAK;AACL,eAAW,YAAY,GAAG;AACxB,SAAG,YAAY,EAAE;AAAA;AAAA,SAEd;AACL,SAAK;AAAA;AAEP,SAAO;AAAA;AAKF,sBAAmC,KAAsB,WAAgC;AAC9F,SAAO,OAAO,KAAK,KAAK,OAAwB,CAAC,KAAK,QAAQ;AAC5D,QAAI,UAAU,IAAI;AAAO,UAAI,OAAO,IAAI;AACxC,WAAO;AAAA,KACN;AAAA;",
6
+ "names": []
7
+ }