react-native-tree-multi-select 1.9.4 → 2.0.0-beta.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 (144) hide show
  1. package/README.md +6 -5
  2. package/lib/module/TreeView.js +6 -6
  3. package/lib/module/TreeView.js.map +1 -1
  4. package/lib/module/components/CheckboxView.js +4 -4
  5. package/lib/module/components/CheckboxView.js.map +1 -1
  6. package/lib/module/components/CustomExpandCollapseIcon.js +22 -1
  7. package/lib/module/components/CustomExpandCollapseIcon.js.map +1 -1
  8. package/lib/module/components/NodeList.js +7 -7
  9. package/lib/module/components/NodeList.js.map +1 -1
  10. package/lib/module/handlers/ScrollToNodeHandler.js +3 -3
  11. package/lib/module/handlers/ScrollToNodeHandler.js.map +1 -1
  12. package/lib/module/helpers/expandCollapse.helper.js +1 -1
  13. package/lib/module/helpers/expandCollapse.helper.js.map +1 -1
  14. package/lib/module/helpers/flattenTree.helper.js.map +1 -1
  15. package/lib/module/helpers/index.js +6 -6
  16. package/lib/module/helpers/index.js.map +1 -1
  17. package/lib/module/helpers/selectAll.helper.js +2 -2
  18. package/lib/module/helpers/selectAll.helper.js.map +1 -1
  19. package/lib/module/helpers/toggleCheckbox.helper.js +1 -1
  20. package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -1
  21. package/lib/module/helpers/treeNode.helper.js +30 -24
  22. package/lib/module/helpers/treeNode.helper.js.map +1 -1
  23. package/lib/module/index.js +2 -2
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/store/treeView.store.js.map +1 -1
  26. package/lib/typescript/package.json +1 -0
  27. package/lib/typescript/{TreeView.d.ts → src/TreeView.d.ts} +1 -1
  28. package/lib/typescript/src/TreeView.d.ts.map +1 -0
  29. package/lib/typescript/{components → src/components}/CheckboxView.d.ts +1 -1
  30. package/lib/typescript/src/components/CheckboxView.d.ts.map +1 -0
  31. package/lib/typescript/{components → src/components}/CustomExpandCollapseIcon.d.ts +2 -2
  32. package/lib/typescript/src/components/CustomExpandCollapseIcon.d.ts.map +1 -0
  33. package/lib/typescript/src/components/NodeList.d.ts +5 -0
  34. package/lib/typescript/src/components/NodeList.d.ts.map +1 -0
  35. package/lib/typescript/src/constants/tests.constants.d.ts.map +1 -0
  36. package/lib/typescript/src/constants/treeView.constants.d.ts.map +1 -0
  37. package/lib/typescript/{handlers → src/handlers}/ScrollToNodeHandler.d.ts +1 -1
  38. package/lib/typescript/src/handlers/ScrollToNodeHandler.d.ts.map +1 -0
  39. package/lib/typescript/src/helpers/expandCollapse.helper.d.ts.map +1 -0
  40. package/lib/typescript/{helpers → src/helpers}/flattenTree.helper.d.ts +1 -1
  41. package/lib/typescript/src/helpers/flattenTree.helper.d.ts.map +1 -0
  42. package/lib/typescript/src/helpers/index.d.ts.map +1 -0
  43. package/lib/typescript/{helpers → src/helpers}/search.helper.d.ts +1 -1
  44. package/lib/typescript/src/helpers/search.helper.d.ts.map +1 -0
  45. package/lib/typescript/{helpers → src/helpers}/selectAll.helper.d.ts +1 -1
  46. package/lib/typescript/src/helpers/selectAll.helper.d.ts.map +1 -0
  47. package/lib/typescript/src/helpers/toggleCheckbox.helper.d.ts.map +1 -0
  48. package/lib/typescript/{helpers → src/helpers}/treeNode.helper.d.ts +1 -1
  49. package/lib/typescript/src/helpers/treeNode.helper.d.ts.map +1 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/lib/typescript/src/jest.setup.d.ts.map +1 -0
  52. package/lib/typescript/{store → src/store}/treeView.store.d.ts +2 -2
  53. package/lib/typescript/src/store/treeView.store.d.ts.map +1 -0
  54. package/lib/typescript/{types → src/types}/treeView.types.d.ts +3 -3
  55. package/lib/typescript/src/types/treeView.types.d.ts.map +1 -0
  56. package/lib/typescript/src/utils/typedMemo.d.ts.map +1 -0
  57. package/lib/typescript/src/utils/useDeepCompareEffect.d.ts.map +1 -0
  58. package/lib/typescript/src/utils/usePreviousState.d.ts.map +1 -0
  59. package/package.json +28 -23
  60. package/src/TreeView.tsx +1 -1
  61. package/src/components/CheckboxView.tsx +4 -4
  62. package/src/components/CustomExpandCollapseIcon.tsx +25 -2
  63. package/src/handlers/ScrollToNodeHandler.tsx +1 -1
  64. package/src/helpers/flattenTree.helper.ts +4 -1
  65. package/src/helpers/search.helper.ts +1 -1
  66. package/src/helpers/selectAll.helper.ts +1 -1
  67. package/src/helpers/treeNode.helper.ts +32 -38
  68. package/src/store/treeView.store.ts +2 -2
  69. package/src/types/treeView.types.ts +3 -5
  70. package/lib/commonjs/TreeView.js +0 -154
  71. package/lib/commonjs/TreeView.js.map +0 -1
  72. package/lib/commonjs/components/CheckboxView.js +0 -82
  73. package/lib/commonjs/components/CheckboxView.js.map +0 -1
  74. package/lib/commonjs/components/CustomExpandCollapseIcon.js +0 -22
  75. package/lib/commonjs/components/CustomExpandCollapseIcon.js.map +0 -1
  76. package/lib/commonjs/components/NodeList.js +0 -188
  77. package/lib/commonjs/components/NodeList.js.map +0 -1
  78. package/lib/commonjs/constants/tests.constants.js +0 -8
  79. package/lib/commonjs/constants/tests.constants.js.map +0 -1
  80. package/lib/commonjs/constants/treeView.constants.js +0 -8
  81. package/lib/commonjs/constants/treeView.constants.js.map +0 -1
  82. package/lib/commonjs/handlers/ScrollToNodeHandler.js +0 -169
  83. package/lib/commonjs/handlers/ScrollToNodeHandler.js.map +0 -1
  84. package/lib/commonjs/helpers/expandCollapse.helper.js +0 -147
  85. package/lib/commonjs/helpers/expandCollapse.helper.js.map +0 -1
  86. package/lib/commonjs/helpers/flattenTree.helper.js +0 -66
  87. package/lib/commonjs/helpers/flattenTree.helper.js.map +0 -1
  88. package/lib/commonjs/helpers/index.js +0 -72
  89. package/lib/commonjs/helpers/index.js.map +0 -1
  90. package/lib/commonjs/helpers/search.helper.js +0 -65
  91. package/lib/commonjs/helpers/search.helper.js.map +0 -1
  92. package/lib/commonjs/helpers/selectAll.helper.js +0 -117
  93. package/lib/commonjs/helpers/selectAll.helper.js.map +0 -1
  94. package/lib/commonjs/helpers/toggleCheckbox.helper.js +0 -192
  95. package/lib/commonjs/helpers/toggleCheckbox.helper.js.map +0 -1
  96. package/lib/commonjs/helpers/treeNode.helper.js +0 -48
  97. package/lib/commonjs/helpers/treeNode.helper.js.map +0 -1
  98. package/lib/commonjs/index.js +0 -28
  99. package/lib/commonjs/index.js.map +0 -1
  100. package/lib/commonjs/jest.setup.js +0 -4
  101. package/lib/commonjs/jest.setup.js.map +0 -1
  102. package/lib/commonjs/package.json +0 -1
  103. package/lib/commonjs/store/treeView.store.js +0 -86
  104. package/lib/commonjs/store/treeView.store.js.map +0 -1
  105. package/lib/commonjs/types/treeView.types.js +0 -6
  106. package/lib/commonjs/types/treeView.types.js.map +0 -1
  107. package/lib/commonjs/utils/typedMemo.js +0 -11
  108. package/lib/commonjs/utils/typedMemo.js.map +0 -1
  109. package/lib/commonjs/utils/useDeepCompareEffect.js +0 -40
  110. package/lib/commonjs/utils/useDeepCompareEffect.js.map +0 -1
  111. package/lib/commonjs/utils/usePreviousState.js +0 -20
  112. package/lib/commonjs/utils/usePreviousState.js.map +0 -1
  113. package/lib/typescript/TreeView.d.ts.map +0 -1
  114. package/lib/typescript/components/CheckboxView.d.ts.map +0 -1
  115. package/lib/typescript/components/CustomExpandCollapseIcon.d.ts.map +0 -1
  116. package/lib/typescript/components/NodeList.d.ts +0 -6
  117. package/lib/typescript/components/NodeList.d.ts.map +0 -1
  118. package/lib/typescript/constants/tests.constants.d.ts.map +0 -1
  119. package/lib/typescript/constants/treeView.constants.d.ts.map +0 -1
  120. package/lib/typescript/handlers/ScrollToNodeHandler.d.ts.map +0 -1
  121. package/lib/typescript/helpers/expandCollapse.helper.d.ts.map +0 -1
  122. package/lib/typescript/helpers/flattenTree.helper.d.ts.map +0 -1
  123. package/lib/typescript/helpers/index.d.ts.map +0 -1
  124. package/lib/typescript/helpers/search.helper.d.ts.map +0 -1
  125. package/lib/typescript/helpers/selectAll.helper.d.ts.map +0 -1
  126. package/lib/typescript/helpers/toggleCheckbox.helper.d.ts.map +0 -1
  127. package/lib/typescript/helpers/treeNode.helper.d.ts.map +0 -1
  128. package/lib/typescript/index.d.ts.map +0 -1
  129. package/lib/typescript/jest.setup.d.ts.map +0 -1
  130. package/lib/typescript/store/treeView.store.d.ts.map +0 -1
  131. package/lib/typescript/types/treeView.types.d.ts.map +0 -1
  132. package/lib/typescript/utils/typedMemo.d.ts.map +0 -1
  133. package/lib/typescript/utils/useDeepCompareEffect.d.ts.map +0 -1
  134. package/lib/typescript/utils/usePreviousState.d.ts.map +0 -1
  135. /package/lib/typescript/{constants → src/constants}/tests.constants.d.ts +0 -0
  136. /package/lib/typescript/{constants → src/constants}/treeView.constants.d.ts +0 -0
  137. /package/lib/typescript/{helpers → src/helpers}/expandCollapse.helper.d.ts +0 -0
  138. /package/lib/typescript/{helpers → src/helpers}/index.d.ts +0 -0
  139. /package/lib/typescript/{helpers → src/helpers}/toggleCheckbox.helper.d.ts +0 -0
  140. /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
  141. /package/lib/typescript/{jest.setup.d.ts → src/jest.setup.d.ts} +0 -0
  142. /package/lib/typescript/{utils → src/utils}/typedMemo.d.ts +0 -0
  143. /package/lib/typescript/{utils → src/utils}/useDeepCompareEffect.d.ts +0 -0
  144. /package/lib/typescript/{utils → src/utils}/usePreviousState.d.ts +0 -0
@@ -1,169 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ScrollToNodeHandler = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _expandCollapse = require("../helpers/expandCollapse.helper");
9
- var _treeView = require("../store/treeView.store");
10
- var _shallow = require("zustand/react/shallow");
11
- var _typedMemo = require("../utils/typedMemo");
12
- var _fastIsEqual = require("fast-is-equal");
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- /**
15
- * ScrollToNodeHandler Component
16
- *
17
- * This component provides an imperative handle to scroll to a specified node within a tree view.
18
- * The scrolling action is orchestrated via a two-step "milestone" mechanism that ensures the target
19
- * node is both expanded in the tree and that the rendered list reflects this expansion before the scroll
20
- * is performed.
21
- *
22
- * The two key milestones tracked by the `expandAndScrollToNodeQueue` state are:
23
- * 1. EXPANDED: Indicates that the expansion logic for the target node has been initiated.
24
- * 2. RENDERED: Indicates that the list has re-rendered with the expanded node included.
25
- *
26
- * When the `scrollToNodeID` method is called:
27
- * - The scroll parameters (target node ID, animation preferences, view offset/position) are stored in a ref.
28
- * - The target node's expansion is triggered via the `expandNodes` helper.
29
- * - The `expandAndScrollToNodeQueue` state is updated to mark that expansion has begun.
30
- *
31
- * As the component re-renders (e.g., after the node expansion changes the rendered list):
32
- * - A useEffect monitors changes to the list, and once it detects the expansion has occurred,
33
- * it updates the queue to include the RENDERED milestone.
34
- *
35
- * A layout effect then waits for both conditions to be met:
36
- * - The target node is confirmed to be in the expanded set.
37
- * - The `expandAndScrollToNodeQueue` exactly matches the expected milestones ([EXPANDED, RENDERED]).
38
- *
39
- * Once both conditions are satisfied:
40
- * - The index of the target node is determined within the latest flattened node list.
41
- * - The flash list is scrolled to that index.
42
- * - The queued scroll parameters and milestone queue are reset.
43
- *
44
- * This design ensures that the scroll action is performed only after the target node is fully present
45
- * in the UI, thus preventing issues with attempting to scroll to an element that does not exist yet.
46
- */
47
- // Enum representing the two milestones needed before scrolling
48
- var ExpandQueueAction = /*#__PURE__*/function (ExpandQueueAction) {
49
- ExpandQueueAction[ExpandQueueAction["EXPANDED"] = 0] = "EXPANDED";
50
- ExpandQueueAction[ExpandQueueAction["RENDERED"] = 1] = "RENDERED";
51
- return ExpandQueueAction;
52
- }(ExpandQueueAction || {});
53
- function _innerScrollToNodeHandler(props, ref) {
54
- const {
55
- storeId,
56
- flashListRef,
57
- flattenedFilteredNodes,
58
- setInitialScrollIndex,
59
- initialScrollNodeID
60
- } = props;
61
- const {
62
- expanded,
63
- childToParentMap
64
- } = (0, _treeView.useTreeViewStore)(storeId)((0, _shallow.useShallow)(state => ({
65
- expanded: state.expanded,
66
- childToParentMap: state.childToParentMap
67
- })));
68
- _react.default.useImperativeHandle(ref, () => ({
69
- scrollToNodeID: params => {
70
- queuedScrollToNodeParams.current = params;
71
- // Mark that expansion is initiated.
72
- setExpandAndScrollToNodeQueue([ExpandQueueAction.EXPANDED]);
73
- // Trigger expansion logic (this may update the store and subsequently re-render the list).
74
- (0, _expandCollapse.expandNodes)(storeId, [queuedScrollToNodeParams.current.nodeId], !queuedScrollToNodeParams.current.expandScrolledNode);
75
- }
76
- }), [storeId]);
77
-
78
- // Ref to store the scroll parameters for the queued action.
79
- const queuedScrollToNodeParams = _react.default.useRef(null);
80
-
81
- // State to track progression: first the expansion is triggered, then the list is rendered.
82
- const [expandAndScrollToNodeQueue, setExpandAndScrollToNodeQueue] = _react.default.useState([]);
83
- const latestFlattenedFilteredNodesRef = _react.default.useRef(flattenedFilteredNodes);
84
-
85
- /* When the rendered node list changes, update the ref.
86
- If an expansion was triggered, mark that the list is now rendered. */
87
- _react.default.useEffect(() => {
88
- setExpandAndScrollToNodeQueue(prevQueue => {
89
- if (prevQueue.includes(ExpandQueueAction.EXPANDED)) {
90
- latestFlattenedFilteredNodesRef.current = flattenedFilteredNodes;
91
- return [ExpandQueueAction.EXPANDED, ExpandQueueAction.RENDERED];
92
- } else {
93
- return prevQueue;
94
- }
95
- });
96
- }, [flattenedFilteredNodes]);
97
-
98
- /* Once the target node is expanded and the list is updated (milestones reached),
99
- perform the scroll using the latest node list. */
100
- _react.default.useLayoutEffect(() => {
101
- if (queuedScrollToNodeParams.current === null) return;
102
- if (!(0, _fastIsEqual.fastIsEqual)(expandAndScrollToNodeQueue, [ExpandQueueAction.EXPANDED, ExpandQueueAction.RENDERED])) {
103
- return;
104
- }
105
-
106
- // If node is set to not expand
107
- if (!queuedScrollToNodeParams.current.expandScrolledNode) {
108
- let parentId;
109
- // Get the parent's id of the node to scroll to
110
- if (childToParentMap.has(queuedScrollToNodeParams.current.nodeId)) {
111
- parentId = childToParentMap.get(queuedScrollToNodeParams.current.nodeId);
112
- }
113
-
114
- // Ensure if the parent is expanded before proceeding to scroll to the node
115
- if (parentId && !expanded.has(parentId)) return;
116
- }
117
- // If node is set to expand
118
- else {
119
- if (!expanded.has(queuedScrollToNodeParams.current.nodeId)) return;
120
- }
121
- const {
122
- nodeId,
123
- animated,
124
- viewOffset,
125
- viewPosition
126
- } = queuedScrollToNodeParams.current;
127
- function scrollToItem() {
128
- const index = latestFlattenedFilteredNodesRef.current.findIndex(item => item.id === nodeId);
129
- if (index !== -1 && flashListRef.current) {
130
- // Scroll to the target index.
131
- flashListRef.current.scrollToIndex({
132
- index,
133
- animated,
134
- viewOffset,
135
- viewPosition
136
- });
137
- } else {
138
- if (__DEV__) {
139
- console.info("Cannot find the item of the mentioned id to scroll in the rendered tree view list data!");
140
- }
141
- }
142
-
143
- // Clear the queued parameters and reset the expansion/render queue.
144
- queuedScrollToNodeParams.current = null;
145
- setExpandAndScrollToNodeQueue([]);
146
- }
147
- scrollToItem();
148
- }, [childToParentMap, expanded, flashListRef, expandAndScrollToNodeQueue]);
149
-
150
- ////////////////////////////// Handle Initial Scroll /////////////////////////////
151
- /* On first render, if an initial scroll target is provided, determine its index.
152
- This is done only once. */
153
- const initialScrollDone = _react.default.useRef(false);
154
- _react.default.useLayoutEffect(() => {
155
- if (initialScrollDone.current) return;
156
- const index = flattenedFilteredNodes.findIndex(item => item.id === initialScrollNodeID);
157
- setInitialScrollIndex(index);
158
- if (index !== -1) {
159
- initialScrollDone.current = true;
160
- }
161
- // eslint-disable-next-line react-hooks/exhaustive-deps
162
- }, [flattenedFilteredNodes, initialScrollNodeID]);
163
- /////////////////////////////////////////////////////////////////////////////////
164
-
165
- return null;
166
- }
167
- const _ScrollToNodeHandler = /*#__PURE__*/_react.default.forwardRef(_innerScrollToNodeHandler);
168
- const ScrollToNodeHandler = exports.ScrollToNodeHandler = (0, _typedMemo.typedMemo)(_ScrollToNodeHandler);
169
- //# sourceMappingURL=ScrollToNodeHandler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_expandCollapse","_treeView","_shallow","_typedMemo","_fastIsEqual","e","__esModule","default","ExpandQueueAction","_innerScrollToNodeHandler","props","ref","storeId","flashListRef","flattenedFilteredNodes","setInitialScrollIndex","initialScrollNodeID","expanded","childToParentMap","useTreeViewStore","useShallow","state","React","useImperativeHandle","scrollToNodeID","params","queuedScrollToNodeParams","current","setExpandAndScrollToNodeQueue","EXPANDED","expandNodes","nodeId","expandScrolledNode","useRef","expandAndScrollToNodeQueue","useState","latestFlattenedFilteredNodesRef","useEffect","prevQueue","includes","RENDERED","useLayoutEffect","fastIsEqual","parentId","has","get","animated","viewOffset","viewPosition","scrollToItem","index","findIndex","item","id","scrollToIndex","__DEV__","console","info","initialScrollDone","_ScrollToNodeHandler","forwardRef","ScrollToNodeHandler","exports","typedMemo"],"sourceRoot":"../../../src","sources":["handlers/ScrollToNodeHandler.tsx"],"mappings":";;;;;;AAkCA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAA4C,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAxC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA2BA;AAAA,IACKG,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA,EAAjB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AO,EAAE;QACxC;QACAd,YAAY,CAACc,OAAO,CAAC2B,aAAa,CAAC;UACjCJ,KAAK;UACLJ,QAAQ;UACRC,UAAU;UACVC;QACF,CAAC,CAAC;MACJ,CAAC,MAAM;QACL,IAAIO,OAAO,EAAE;UACXC,OAAO,CAACC,IAAI,CAAC,yFAAyF,CAAC;QACzG;MACF;;MAEA;MACA/B,wBAAwB,CAACC,OAAO,GAAG,IAAI;MACvCC,6BAA6B,CAAC,EAAE,CAAC;IACnC;IAEAqB,YAAY,CAAC,CAAC;EAChB,CAAC,EAAE,CAAC/B,gBAAgB,EAAED,QAAQ,EAAEJ,YAAY,EAAEqB,0BAA0B,CAAC,CAAC;;EAE1E;EACA;AACF;EACE,MAAMwB,iBAAiB,GAAGpC,cAAK,CAACW,MAAM,CAAC,KAAK,CAAC;EAC7CX,cAAK,CAACmB,eAAe,CAAC,MAAM;IAC1B,IAAIiB,iBAAiB,CAAC/B,OAAO,EAAE;IAE/B,MAAMuB,KAAK,GAAGpC,sBAAsB,CAACqC,SAAS,CAC5CC,IAAI,IAAIA,IAAI,CAACC,EAAE,KAAKrC,mBACtB,CAAC;IAEDD,qBAAqB,CAACmC,KAAK,CAAC;IAE5B,IAAIA,KAAK,KAAK,CAAC,CAAC,EAAE;MAChBQ,iBAAiB,CAAC/B,OAAO,GAAG,IAAI;IAClC;IACA;EACF,CAAC,EAAE,CAACb,sBAAsB,EAAEE,mBAAmB,CAAC,CAAC;EACjD;;EAEA,OAAO,IAAI;AACb;AAEA,MAAM2C,oBAAoB,gBAAGrC,cAAK,CAACsC,UAAU,CAACnD,yBAAyB,CAEtB;AAE1C,MAAMoD,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,IAAAE,oBAAS,EAE1CJ,oBAAoB,CAAC","ignoreList":[]}
@@ -1,147 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.collapseAll = collapseAll;
7
- exports.collapseNodes = collapseNodes;
8
- exports.expandAll = expandAll;
9
- exports.expandNodes = expandNodes;
10
- exports.handleToggleExpand = handleToggleExpand;
11
- var _treeView = require("../store/treeView.store");
12
- /**
13
- * Toggle the expanded state of a tree node by its ID.
14
- *
15
- * If the node is currently expanded, it and its descendants will be collapsed.
16
- * If it is currently collapsed, it will be expanded.
17
- *
18
- * @param id - The ID of the tree node to toggle.
19
- */
20
- function handleToggleExpand(storeId, id) {
21
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
22
- const {
23
- expanded,
24
- updateExpanded,
25
- nodeMap
26
- } = treeViewStore.getState();
27
-
28
- // Create a new Set based on the current expanded state
29
- const newExpanded = new Set(expanded);
30
- if (expanded.has(id)) {
31
- // If the node is currently expanded, collapse it and its descendants
32
- newExpanded.delete(id);
33
-
34
- // Use an iterative approach to remove all descendants from the expanded set
35
- const stack = [id];
36
- while (stack.length > 0) {
37
- const currentId = stack.pop();
38
- const node = nodeMap.get(currentId);
39
- if (node && node.children) {
40
- for (const child of node.children) {
41
- newExpanded.delete(child.id);
42
- stack.push(child.id);
43
- }
44
- }
45
- }
46
- } else {
47
- // If the node is currently collapsed, expand it
48
- newExpanded.add(id);
49
- }
50
-
51
- // Update the expanded state
52
- updateExpanded(newExpanded);
53
- }
54
-
55
- /**
56
- * Expand all nodes in the tree.
57
- */
58
- function expandAll(storeId) {
59
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
60
- const {
61
- nodeMap,
62
- updateExpanded
63
- } = treeViewStore.getState();
64
- // Create a new Set containing the IDs of all nodes
65
- const newExpanded = new Set(nodeMap.keys());
66
- updateExpanded(newExpanded);
67
- }
68
-
69
- /**
70
- * Collapse all nodes in the tree.
71
- */
72
- function collapseAll(storeId) {
73
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
74
- const {
75
- updateExpanded
76
- } = treeViewStore.getState();
77
- // Clear the expanded state
78
- updateExpanded(new Set());
79
- }
80
-
81
- /**
82
- * Expand tree nodes of given ids. If the id is of a child, it also expands
83
- * its ancestors up to the root.
84
- * @param ids - Ids of nodes to expand.
85
- * @param _doNotExpandToShowChildren - If true, the function will not expand the ids to prevent
86
- * from showing their children.
87
- */
88
- function expandNodes(storeId, ids, _doNotExpandToShowChildren = false) {
89
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
90
- const {
91
- expanded,
92
- updateExpanded,
93
- childToParentMap
94
- } = treeViewStore.getState();
95
- const newExpanded = new Set(expanded);
96
- const processedIds = new Set();
97
- ids.forEach(id => {
98
- if (_doNotExpandToShowChildren) {
99
- const parentId = childToParentMap.get(id);
100
- if (parentId === undefined) return;else id = parentId;
101
- }
102
- let currentId = id;
103
- while (currentId && !processedIds.has(currentId)) {
104
- newExpanded.add(currentId);
105
- processedIds.add(currentId);
106
- currentId = childToParentMap.get(currentId);
107
- }
108
- });
109
- updateExpanded(newExpanded);
110
- }
111
-
112
- /**
113
- * Collapse tree nodes of given ids. If the id is of a parent, it also collapses
114
- * its descendants.
115
- * @param ids - Ids of nodes to collapse.
116
- */
117
- function collapseNodes(storeId, ids) {
118
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
119
- const {
120
- expanded,
121
- updateExpanded,
122
- nodeMap
123
- } = treeViewStore.getState();
124
- const newExpanded = new Set(expanded);
125
-
126
- // Use an iterative approach to remove all descendants from the expanded set
127
- const deleteChildrenFromExpanded = nodeId => {
128
- const stack = [nodeId];
129
- while (stack.length > 0) {
130
- const currentId = stack.pop();
131
- const node = nodeMap.get(currentId);
132
- if (node && node.children) {
133
- for (const child of node.children) {
134
- newExpanded.delete(child.id);
135
- stack.push(child.id);
136
- }
137
- }
138
- }
139
- };
140
- ids.forEach(id => {
141
- // Remove the node ID from the set and all its descendants
142
- newExpanded.delete(id);
143
- deleteChildrenFromExpanded(id);
144
- });
145
- updateExpanded(newExpanded);
146
- }
147
- //# sourceMappingURL=expandCollapse.helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_treeView","require","handleToggleExpand","storeId","id","treeViewStore","getTreeViewStore","expanded","updateExpanded","nodeMap","getState","newExpanded","Set","has","delete","stack","length","currentId","pop","node","get","children","child","push","add","expandAll","keys","collapseAll","expandNodes","ids","_doNotExpandToShowChildren","childToParentMap","processedIds","forEach","parentId","undefined","collapseNodes","deleteChildrenFromExpanded","nodeId"],"sourceRoot":"../../../src","sources":["helpers/expandCollapse.helper.ts"],"mappings":";;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAKC,OAAe,EAAEC,EAAM,EAAE;EAC5D,MAAMC,aAAa,GAAG,IAAAC,0BAAgB,EAAKH,OAAO,CAAC;EACnD,MAAM;IACFI,QAAQ;IACRC,cAAc;IACdC;EACJ,CAAC,GAAGJ,aAAa,CAACK,QAAQ,CAAC,CAAC;;EAE5B;EACA,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAACL,QAAQ,CAAC;EAErC,IAAIA,QAAQ,CAACM,GAAG,CAACT,EAAE,CAAC,EAAE;IAClB;IACAO,WAAW,CAACG,MAAM,CAACV,EAAE,CAAC;;IAEtB;IACA,MAAMW,KAAK,GAAG,CAACX,EAAE,CAAC;IAElB,OAAOW,KAAK,CAACC,MAAM,GAAG,CAAC,EAAE;MACrB,MAAMC,SAAS,GAAGF,KAAK,CAACG,GAAG,CAAC,CAAE;MAC9B,MAAMC,IAAI,GAAGV,OAAO,CAACW,GAAG,CAACH,SAAS,CAAC;MAEnC,IAAIE,IAAI,IAAIA,IAAI,CAACE,QAAQ,EAAE;QACvB,KAAK,MAAMC,KAAK,IAAIH,IAAI,CAACE,QAAQ,EAAE;UAC/BV,WAAW,CAACG,MAAM,CAACQ,KAAK,CAAClB,EAAE,CAAC;UAC5BW,KAAK,CAACQ,IAAI,CAACD,KAAK,CAAClB,EAAE,CAAC;QACxB;MACJ;IACJ;EACJ,CAAC,MAAM;IACH;IACAO,WAAW,CAACa,GAAG,CAACpB,EAAE,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AM,CAACV,EAAE,CAAC;IACtBiC,0BAA0B,CAACjC,EAAE,CAAC;EAClC,CAAC,CAAC;EAEFI,cAAc,CAACG,WAAW,CAAC;AAC/B","ignoreList":[]}
@@ -1,66 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFlattenedTreeData = getFlattenedTreeData;
7
- /**
8
- * Flatten the tree and attach a "level" key to object to indicate it's depth. This
9
- * returns the flattened tree data of expanded ids only. We do not prune the tree off the
10
- * children after the flattening as it would be unnecessary computation.
11
- *
12
- * @param nodes - Input recursive tree
13
- * @param expandedIds - ids of currently expanded nodes
14
- * @param __level__ - (optional) for internal recursive use only
15
- * @returns Flattened tree data with expanded ids only
16
- */
17
- function getFlattenedTreeData(nodes, expandedIds) {
18
- const flattened = [];
19
- const stack = [];
20
-
21
- // Initialize stack with the root nodes and level 0
22
- for (let i = nodes.length - 1; i >= 0; i--) {
23
- const node = nodes[i];
24
- /* istanbul ignore next */
25
- if (node) {
26
- // Ensure node is not undefined - redundant safety
27
- stack.push({
28
- node,
29
- level: 0
30
- });
31
- }
32
- }
33
- while (stack.length > 0) {
34
- const item = stack.pop();
35
- /* istanbul ignore next */
36
- if (!item) continue; // Redundant safety check
37
-
38
- const {
39
- node,
40
- level
41
- } = item;
42
-
43
- // Push current node into the flattened array
44
- flattened.push({
45
- ...node,
46
- level
47
- });
48
-
49
- // Add children nodes to the stack if the node is expanded
50
- if (node.children && expandedIds.has(node.id)) {
51
- for (let i = node.children.length - 1; i >= 0; i--) {
52
- const childNode = node.children[i];
53
- /* istanbul ignore next */
54
- if (childNode) {
55
- // Ensure childNode is not undefined - redundant safety
56
- stack.push({
57
- node: childNode,
58
- level: level + 1
59
- });
60
- }
61
- }
62
- }
63
- }
64
- return flattened;
65
- }
66
- //# sourceMappingURL=flattenTree.helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getFlattenedTreeData","nodes","expandedIds","flattened","stack","i","length","node","push","level","item","pop","children","has","id","childNode"],"sourceRoot":"../../../src","sources":["helpers/flattenTree.helper.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,oBAAoBA,CAChCC,KAAqB,EACrBC,WAAoB,EACO;EAC3B,MAAMC,SAAsC,GAAG,EAAE;EACjD,MAAMC,KAA+C,GAAG,EAAE;;EAE1D;EACA,KAAK,IAAIC,CAAC,GAAGJ,KAAK,CAACK,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACxC,MAAME,IAAI,GAAGN,KAAK,CAACI,CAAC,CAAC;IACrB;IACA,IAAIE,IAAI,EAAE;MAAE;MACRH,KAAK,CAACI,IAAI,CAAC;QAAED,IAAI;QAAEE,KAAK,EAAE;MAAE,CAAC,CAAC;IAClC;EACJ;EAEA,OAAOL,KAAK,CAACE,MAAM,GAAG,CAAC,EAAE;IACrB,MAAMI,IAAI,GAAGN,KAAK,CAACO,GAAG,CAAC,CAAC;IACxB;IACA,IAAI,CAACD,IAAI,EAAE,SAAS,CAAC;;IAErB,MAAM;MAAEH,IAAI;MAAEE;IAAM,CAAC,GAAGC,IAAI;;IAE5B;IACAP,SAAS,CAACK,IAAI,CAAC;MAAE,GAAGD,IAAI;MAAEE;IAAM,CAAC,CAAC;;IAElC;IACA,IAAIF,IAAI,CAACK,QAAQ,IAAIV,WAAW,CAACW,GAAG,CAACN,IAAI,CAACO,EAAE,CAAC,EAAE;MAC3C,KAAK,IAAIT,CAAC,GAAGE,IAAI,CAACK,QAAQ,CAACN,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;QAChD,MAAMU,SAAS,GAAGR,IAAI,CAACK,QAAQ,CAACP,CAAC,CAAC;QAClC;QACA,IAAIU,SAAS,EAAE;UAAE;UACbX,KAAK,CAACI,IAAI,CAAC;YAAED,IAAI,EAAEQ,SAAS;YAAEN,KAAK,EAAEA,KAAK,GAAG;UAAE,CAAC,CAAC;QACrD;MACJ;IACJ;EACJ;EAEA,OAAON,SAAS;AACpB","ignoreList":[]}
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _expandCollapse = require("./expandCollapse.helper");
7
- Object.keys(_expandCollapse).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _expandCollapse[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _expandCollapse[key];
14
- }
15
- });
16
- });
17
- var _treeNode = require("./treeNode.helper");
18
- Object.keys(_treeNode).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _treeNode[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _treeNode[key];
25
- }
26
- });
27
- });
28
- var _selectAll = require("./selectAll.helper");
29
- Object.keys(_selectAll).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _selectAll[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _selectAll[key];
36
- }
37
- });
38
- });
39
- var _toggleCheckbox = require("./toggleCheckbox.helper");
40
- Object.keys(_toggleCheckbox).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _toggleCheckbox[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _toggleCheckbox[key];
47
- }
48
- });
49
- });
50
- var _search = require("./search.helper");
51
- Object.keys(_search).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _search[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _search[key];
58
- }
59
- });
60
- });
61
- var _flattenTree = require("./flattenTree.helper");
62
- Object.keys(_flattenTree).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _flattenTree[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _flattenTree[key];
69
- }
70
- });
71
- });
72
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_expandCollapse","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_treeNode","_selectAll","_toggleCheckbox","_search","_flattenTree"],"sourceRoot":"../../../src","sources":["helpers/index.ts"],"mappings":";;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,SAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,SAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,SAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,SAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,UAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,UAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAA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AAK,YAAA,CAAAT,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,65 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFilteredTreeData = getFilteredTreeData;
7
- /**
8
- * Get filtered tree data based on the search term and the search keys
9
- * If any of the parent contains the search term, the tree will also contain
10
- * it's children.
11
- *
12
- * If only one of the innermost children contains the search term then it's siblings
13
- * won't be included in the search. But all it's ancestor nodes will be included
14
- *
15
- * @param nodes Input tree data
16
- * @param trimmedSearchTerm search term
17
- * @param searchKeys search key
18
- * @returns filtered tree data
19
- */
20
- function getFilteredTreeData(nodes, trimmedSearchTerm, searchKeys) {
21
- let filtered = [];
22
- for (let node of nodes) {
23
- const isSearchTermInNode = doesNodeContainSearchTerm(node, trimmedSearchTerm, searchKeys);
24
- if (!trimmedSearchTerm || isSearchTermInNode) {
25
- // If node itself matches, include it and all its descendants
26
- filtered.push(node);
27
- } else if (node.children) {
28
- // If node does not match, check its children and include them if they match
29
- const childMatches = getFilteredTreeData(node.children, trimmedSearchTerm, searchKeys);
30
- if (childMatches.length > 0) {
31
- // If any children match, include the node, replacing its children with the matching ones
32
- filtered.push({
33
- ...node,
34
- children: childMatches
35
- });
36
- }
37
- }
38
- }
39
- return filtered;
40
- }
41
- ;
42
-
43
- /**
44
- * Checks if a given tree node contains a specific search term in any of its specified keys.
45
- *
46
- * This function will check each of the specified keys in the tree node, convert the key's value to a string,
47
- * and check if it includes the search term.
48
- *
49
- * @param node - The tree node to search through.
50
- * @param searchTerm - The term to search for.
51
- * @param searchKeys - The keys in the tree node to search in.
52
- * @returns True if the search term is found in any of the specified keys, false otherwise.
53
- */
54
- function doesNodeContainSearchTerm(node, searchTerm, searchKeys) {
55
- // We're using the `some` method on the array of keys to check each one
56
- return searchKeys.some(key => {
57
- // Get the value of the key in the tree node
58
- const nodeValue = node[key];
59
- // Check if the string representation of the key's value includes the search term
60
- // If the value is undefined or null, `nodeValue?.toString()` will return undefined,
61
- // and the call to `toLowerCase().includes(searchTerm)` will return false.
62
- return nodeValue?.toString().toLowerCase().includes(searchTerm);
63
- });
64
- }
65
- //# sourceMappingURL=search.helper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["getFilteredTreeData","nodes","trimmedSearchTerm","searchKeys","filtered","node","isSearchTermInNode","doesNodeContainSearchTerm","push","children","childMatches","length","searchTerm","some","key","nodeValue","toString","toLowerCase","includes"],"sourceRoot":"../../../src","sources":["helpers/search.helper.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAC/BC,KAAqB,EACrBC,iBAAyB,EACzBC,UAAoB,EACN;EACd,IAAIC,QAAwB,GAAG,EAAE;EAEjC,KAAK,IAAIC,IAAI,IAAIJ,KAAK,EAAE;IACpB,MAAMK,kBAAkB,GAAGC,yBAAyB,CAChDF,IAAI,EACJH,iBAAiB,EACjBC,UACJ,CAAC;IAED,IAAI,CAACD,iBAAiB,IAAII,kBAAkB,EAAE;MAC1C;MACAF,QAAQ,CAACI,IAAI,CAACH,IAAI,CAAC;IACvB,CAAC,MAAM,IAAIA,IAAI,CAACI,QAAQ,EAAE;MACtB;MACA,MAAMC,YAAY,GAAGV,mBAAmB,CACpCK,IAAI,CAACI,QAAQ,EACbP,iBAAiB,EACjBC,UACJ,CAAC;MAED,IAAIO,YAAY,CAACC,MAAM,GAAG,CAAC,EAAE;QACzB;QACAP,QAAQ,CAACI,IAAI,CAAC;UAAE,GAAGH,IAAI;UAAEI,QAAQ,EAAEC;QAAa,CAAC,CAAC;MACtD;IACJ;EACJ;EAEA,OAAON,QAAQ;AACnB;AAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,yBAAyBA,CAC9BF,IAAkB,EAClBO,UAAkB,EAClBT,UAAoB,EACb;EACP;EACA,OAAOA,UAAU,CAACU,IAAI,CAACC,GAAG,IAAI;IAC1B;IACA,MAAMC,SAAS,GAAGV,IAAI,CAACS,GAAG,CAAC;IAC3B;IACA;IACA;IACA,OAAQC,SAAS,EAAEC,QAAQ,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAACN,UAAU,CAAC;EACpE,CAAC,CAAC;AACN","ignoreList":[]}
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getInnerMostChildrenIdsInTree = getInnerMostChildrenIdsInTree;
7
- exports.selectAll = selectAll;
8
- exports.selectAllFiltered = selectAllFiltered;
9
- exports.unselectAll = unselectAll;
10
- exports.unselectAllFiltered = unselectAllFiltered;
11
- var _treeView = require("../store/treeView.store");
12
- var _toggleCheckbox = require("./toggleCheckbox.helper");
13
- /**
14
- * Selects all nodes that are currently visible due to the applied filter.
15
- *
16
- * If there is no search text, then it selects all nodes; otherwise, it selects all visible nodes.
17
- */
18
- function selectAllFiltered(storeId) {
19
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
20
- const {
21
- searchText,
22
- innerMostChildrenIds
23
- } = treeViewStore.getState();
24
-
25
- // If there's no search text, select all nodes
26
- if (!searchText) {
27
- selectAll(storeId);
28
- } else {
29
- // If there's search text, only select the visible nodes
30
- (0, _toggleCheckbox.toggleCheckboxes)(storeId, innerMostChildrenIds, true);
31
- }
32
- }
33
- ;
34
-
35
- /**
36
- * Unselects all nodes that are currently visible due to the applied filter.
37
- *
38
- * If there is no search text, then it unselects all nodes; otherwise, it unselects all visible nodes.
39
- */
40
- function unselectAllFiltered(storeId) {
41
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
42
- const {
43
- searchText,
44
- innerMostChildrenIds
45
- } = treeViewStore.getState();
46
-
47
- // If there's no search text, unselect all nodes
48
- if (!searchText) {
49
- unselectAll(storeId);
50
- } else {
51
- // If there's search text, only unselect the visible nodes
52
- (0, _toggleCheckbox.toggleCheckboxes)(storeId, innerMostChildrenIds, false);
53
- }
54
- }
55
- ;
56
-
57
- /**
58
- * Selects all nodes in the tree.
59
- *
60
- * This function selects all nodes by adding all node ids to the checked set and clearing the indeterminate set.
61
- */
62
- function selectAll(storeId) {
63
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
64
- const {
65
- nodeMap,
66
- updateChecked,
67
- updateIndeterminate
68
- } = treeViewStore.getState();
69
-
70
- // Create a new set containing the ids of all nodes
71
- const newChecked = new Set(nodeMap.keys());
72
- // Update the state to mark all nodes as checked
73
-
74
- updateChecked(newChecked);
75
- updateIndeterminate(new Set());
76
- }
77
- ;
78
-
79
- /**
80
- * Unselects all nodes in the tree.
81
- *
82
- * This function unselects all nodes by clearing both the checked and indeterminate sets.
83
- */
84
- function unselectAll(storeId) {
85
- const treeViewStore = (0, _treeView.getTreeViewStore)(storeId);
86
- const {
87
- updateChecked,
88
- updateIndeterminate
89
- } = treeViewStore.getState();
90
- // Update the state to mark all nodes as unchecked
91
-
92
- updateChecked(new Set());
93
- updateIndeterminate(new Set());
94
- }
95
- ;
96
-
97
- /**
98
- * Get the ids of the innermost children in the tree
99
- *
100
- * @param filteredTreeNodes - The filtered tree data
101
- * @returns - array of ids of the inner most children only
102
- */
103
- function getInnerMostChildrenIdsInTree(filteredTreeNodes) {
104
- const allLeafIds = [];
105
- const getLeafNodes = _nodes => {
106
- for (let node of _nodes) {
107
- if (node.children) {
108
- getLeafNodes(node.children);
109
- } else {
110
- allLeafIds.push(node.id);
111
- }
112
- }
113
- };
114
- getLeafNodes(filteredTreeNodes);
115
- return allLeafIds;
116
- }
117
- //# sourceMappingURL=selectAll.helper.js.map