react-native-tree-multi-select 2.0.10 → 3.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 (58) hide show
  1. package/README.md +151 -0
  2. package/lib/module/TreeView.js +32 -2
  3. package/lib/module/TreeView.js.map +1 -1
  4. package/lib/module/components/DragOverlay.js +101 -0
  5. package/lib/module/components/DragOverlay.js.map +1 -0
  6. package/lib/module/components/DropIndicator.js +79 -0
  7. package/lib/module/components/DropIndicator.js.map +1 -0
  8. package/lib/module/components/NodeList.js +258 -32
  9. package/lib/module/components/NodeList.js.map +1 -1
  10. package/lib/module/helpers/index.js +1 -0
  11. package/lib/module/helpers/index.js.map +1 -1
  12. package/lib/module/helpers/moveTreeNode.helper.js +96 -0
  13. package/lib/module/helpers/moveTreeNode.helper.js.map +1 -0
  14. package/lib/module/helpers/toggleCheckbox.helper.js +88 -0
  15. package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -1
  16. package/lib/module/hooks/useDragDrop.js +511 -0
  17. package/lib/module/hooks/useDragDrop.js.map +1 -0
  18. package/lib/module/index.js +1 -1
  19. package/lib/module/index.js.map +1 -1
  20. package/lib/module/store/treeView.store.js +19 -1
  21. package/lib/module/store/treeView.store.js.map +1 -1
  22. package/lib/module/types/dragDrop.types.js +4 -0
  23. package/lib/module/types/dragDrop.types.js.map +1 -0
  24. package/lib/typescript/src/TreeView.d.ts.map +1 -1
  25. package/lib/typescript/src/components/DragOverlay.d.ts +12 -0
  26. package/lib/typescript/src/components/DragOverlay.d.ts.map +1 -0
  27. package/lib/typescript/src/components/DropIndicator.d.ts +13 -0
  28. package/lib/typescript/src/components/DropIndicator.d.ts.map +1 -0
  29. package/lib/typescript/src/components/NodeList.d.ts.map +1 -1
  30. package/lib/typescript/src/helpers/index.d.ts +1 -0
  31. package/lib/typescript/src/helpers/index.d.ts.map +1 -1
  32. package/lib/typescript/src/helpers/moveTreeNode.helper.d.ts +13 -0
  33. package/lib/typescript/src/helpers/moveTreeNode.helper.d.ts.map +1 -0
  34. package/lib/typescript/src/helpers/toggleCheckbox.helper.d.ts +6 -0
  35. package/lib/typescript/src/helpers/toggleCheckbox.helper.d.ts.map +1 -1
  36. package/lib/typescript/src/hooks/useDragDrop.d.ts +35 -0
  37. package/lib/typescript/src/hooks/useDragDrop.d.ts.map +1 -0
  38. package/lib/typescript/src/index.d.ts +4 -2
  39. package/lib/typescript/src/index.d.ts.map +1 -1
  40. package/lib/typescript/src/store/treeView.store.d.ts +8 -0
  41. package/lib/typescript/src/store/treeView.store.d.ts.map +1 -1
  42. package/lib/typescript/src/types/dragDrop.types.d.ts +21 -0
  43. package/lib/typescript/src/types/dragDrop.types.d.ts.map +1 -0
  44. package/lib/typescript/src/types/treeView.types.d.ts +90 -0
  45. package/lib/typescript/src/types/treeView.types.d.ts.map +1 -1
  46. package/package.json +1 -1
  47. package/src/TreeView.tsx +34 -0
  48. package/src/components/DragOverlay.tsx +112 -0
  49. package/src/components/DropIndicator.tsx +95 -0
  50. package/src/components/NodeList.tsx +302 -30
  51. package/src/helpers/index.ts +2 -1
  52. package/src/helpers/moveTreeNode.helper.ts +105 -0
  53. package/src/helpers/toggleCheckbox.helper.ts +96 -0
  54. package/src/hooks/useDragDrop.ts +643 -0
  55. package/src/index.tsx +19 -2
  56. package/src/store/treeView.store.ts +32 -0
  57. package/src/types/dragDrop.types.ts +23 -0
  58. package/src/types/treeView.types.ts +106 -0
@@ -7,11 +7,13 @@ import { useTreeViewStore } from "../store/treeView.store.js";
7
7
  import { getFilteredTreeData, getFlattenedTreeData, getInnerMostChildrenIdsInTree, handleToggleExpand, toggleCheckboxes } from "../helpers/index.js";
8
8
  import { CheckboxView } from "./CheckboxView.js";
9
9
  import { CustomExpandCollapseIcon } from "./CustomExpandCollapseIcon.js";
10
+ import { DragOverlay } from "./DragOverlay.js";
10
11
  import { defaultIndentationMultiplier } from "../constants/treeView.constants.js";
11
12
  import { useShallow } from "zustand/react/shallow";
12
13
  import { typedMemo } from "../utils/typedMemo.js";
13
14
  import { ScrollToNodeHandler } from "../handlers/ScrollToNodeHandler.js";
14
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
15
+ import { useDragDrop } from "../hooks/useDragDrop.js";
16
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
17
  const NodeList = typedMemo(_NodeList);
16
18
  export default NodeList;
17
19
  function _NodeList(props) {
@@ -25,7 +27,15 @@ function _NodeList(props) {
25
27
  CheckboxComponent,
26
28
  ExpandCollapseIconComponent,
27
29
  ExpandCollapseTouchableComponent,
28
- CustomNodeRowComponent
30
+ CustomNodeRowComponent,
31
+ dragEnabled,
32
+ onDragEnd,
33
+ longPressDuration = 400,
34
+ autoScrollThreshold = 60,
35
+ autoScrollSpeed = 1.0,
36
+ dragOverlayOffset = -4,
37
+ autoExpandDelay = 800,
38
+ dragDropCustomizations
29
39
  } = props;
30
40
  const {
31
41
  expanded,
@@ -41,6 +51,14 @@ function _NodeList(props) {
41
51
  searchText: state.searchText
42
52
  })));
43
53
  const flashListRef = React.useRef(null);
54
+ const containerRef = React.useRef(null);
55
+ const internalDataRef = React.useRef(null);
56
+ const measuredItemHeightRef = React.useRef(0);
57
+ const handleItemLayout = React.useCallback(height => {
58
+ if (measuredItemHeightRef.current === 0 && height > 0) {
59
+ measuredItemHeightRef.current = height;
60
+ }
61
+ }, []);
44
62
  const [initialScrollIndex, setInitialScrollIndex] = React.useState(-1);
45
63
 
46
64
  // First we filter the tree as per the search term and keys
@@ -54,8 +72,44 @@ function _NodeList(props) {
54
72
  const updatedInnerMostChildrenIds = getInnerMostChildrenIdsInTree(filteredTree);
55
73
  updateInnerMostChildrenIds(updatedInnerMostChildrenIds);
56
74
  }, [filteredTree, updateInnerMostChildrenIds]);
75
+
76
+ // --- Drag and drop ---
77
+ const {
78
+ panResponder,
79
+ overlayY,
80
+ isDragging,
81
+ draggedNode,
82
+ handleNodeTouchStart,
83
+ cancelLongPressTimer,
84
+ scrollOffsetRef
85
+ } = useDragDrop({
86
+ storeId,
87
+ flattenedNodes: flattenedFilteredNodes,
88
+ flashListRef,
89
+ containerRef,
90
+ dragEnabled: dragEnabled ?? false,
91
+ onDragEnd,
92
+ longPressDuration,
93
+ autoScrollThreshold,
94
+ autoScrollSpeed,
95
+ internalDataRef,
96
+ measuredItemHeightRef,
97
+ dragOverlayOffset,
98
+ autoExpandDelay
99
+ });
100
+
101
+ // Combined onScroll handler
102
+ const handleScroll = React.useCallback(event => {
103
+ scrollOffsetRef.current = event.nativeEvent.contentOffset.y;
104
+ // Cancel long press timer if user is scrolling
105
+ cancelLongPressTimer();
106
+ // Forward to user's onScroll
107
+ treeFlashListProps?.onScroll?.(event);
108
+ }, [scrollOffsetRef, cancelLongPressTimer, treeFlashListProps]);
109
+ const effectiveIndentationMultiplier = indentationMultiplier ?? defaultIndentationMultiplier;
57
110
  const nodeRenderer = React.useCallback(({
58
- item
111
+ item,
112
+ index
59
113
  }) => {
60
114
  return /*#__PURE__*/_jsx(Node, {
61
115
  storeId: storeId,
@@ -66,9 +120,38 @@ function _NodeList(props) {
66
120
  CheckboxComponent: CheckboxComponent,
67
121
  ExpandCollapseIconComponent: ExpandCollapseIconComponent,
68
122
  ExpandCollapseTouchableComponent: ExpandCollapseTouchableComponent,
69
- CustomNodeRowComponent: CustomNodeRowComponent
123
+ CustomNodeRowComponent: CustomNodeRowComponent,
124
+ nodeIndex: index,
125
+ dragEnabled: dragEnabled,
126
+ isDragging: isDragging,
127
+ onNodeTouchStart: dragEnabled ? handleNodeTouchStart : undefined,
128
+ onNodeTouchEnd: dragEnabled ? cancelLongPressTimer : undefined,
129
+ onItemLayout: dragEnabled ? handleItemLayout : undefined,
130
+ dragDropCustomizations: dragDropCustomizations
70
131
  });
71
- }, [storeId, CheckboxComponent, ExpandCollapseIconComponent, ExpandCollapseTouchableComponent, CustomNodeRowComponent, checkBoxViewStyleProps, indentationMultiplier]);
132
+ }, [storeId, CheckboxComponent, ExpandCollapseIconComponent, ExpandCollapseTouchableComponent, CustomNodeRowComponent, checkBoxViewStyleProps, indentationMultiplier, dragEnabled, isDragging, handleNodeTouchStart, dragDropCustomizations, cancelLongPressTimer, handleItemLayout]);
133
+
134
+ // Extract FlashList props but exclude onScroll (we provide our own combined handler)
135
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
136
+ const {
137
+ onScroll: _userOnScroll,
138
+ ...restFlashListProps
139
+ } = treeFlashListProps ?? {};
140
+ const flashListElement = /*#__PURE__*/_jsx(FlashList, {
141
+ ref: flashListRef,
142
+ estimatedItemSize: 36,
143
+ initialScrollIndex: initialScrollIndex,
144
+ removeClippedSubviews: true,
145
+ keyboardShouldPersistTaps: "handled",
146
+ drawDistance: 50,
147
+ ListHeaderComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
148
+ ListFooterComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
149
+ ...restFlashListProps,
150
+ onScroll: handleScroll,
151
+ scrollEnabled: isDragging ? false : restFlashListProps?.scrollEnabled ?? true,
152
+ data: flattenedFilteredNodes,
153
+ renderItem: nodeRenderer
154
+ });
72
155
  return /*#__PURE__*/_jsxs(_Fragment, {
73
156
  children: [/*#__PURE__*/_jsx(ScrollToNodeHandler, {
74
157
  ref: scrollToNodeHandlerRef,
@@ -77,19 +160,22 @@ function _NodeList(props) {
77
160
  flattenedFilteredNodes: flattenedFilteredNodes,
78
161
  setInitialScrollIndex: setInitialScrollIndex,
79
162
  initialScrollNodeID: initialScrollNodeID
80
- }), /*#__PURE__*/_jsx(FlashList, {
81
- ref: flashListRef,
82
- estimatedItemSize: 36,
83
- initialScrollIndex: initialScrollIndex,
84
- removeClippedSubviews: true,
85
- keyboardShouldPersistTaps: "handled",
86
- drawDistance: 50,
87
- ListHeaderComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
88
- ListFooterComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
89
- ...treeFlashListProps,
90
- data: flattenedFilteredNodes,
91
- renderItem: nodeRenderer
92
- })]
163
+ }), dragEnabled ? /*#__PURE__*/_jsxs(View, {
164
+ ref: containerRef,
165
+ style: styles.dragContainer,
166
+ ...panResponder.panHandlers,
167
+ children: [flashListElement, isDragging && draggedNode && /*#__PURE__*/_jsx(DragOverlay, {
168
+ overlayY: overlayY,
169
+ node: draggedNode,
170
+ level: draggedNode.level ?? 0,
171
+ indentationMultiplier: effectiveIndentationMultiplier,
172
+ CheckboxComponent: CheckboxComponent,
173
+ ExpandCollapseIconComponent: ExpandCollapseIconComponent,
174
+ CustomNodeRowComponent: CustomNodeRowComponent,
175
+ checkBoxViewStyleProps: checkBoxViewStyleProps,
176
+ dragDropCustomizations: dragDropCustomizations
177
+ })]
178
+ }) : flashListElement]
93
179
  });
94
180
  }
95
181
  ;
@@ -118,17 +204,29 @@ function _Node(props) {
118
204
  ExpandCollapseIconComponent = CustomExpandCollapseIcon,
119
205
  CheckboxComponent = CheckboxView,
120
206
  ExpandCollapseTouchableComponent = TouchableOpacity,
121
- CustomNodeRowComponent
207
+ CustomNodeRowComponent,
208
+ nodeIndex = 0,
209
+ dragEnabled,
210
+ isDragging: isDraggingGlobal,
211
+ onNodeTouchStart,
212
+ onNodeTouchEnd,
213
+ onItemLayout,
214
+ dragDropCustomizations
122
215
  } = props;
123
216
  const {
124
217
  isExpanded,
125
- value
218
+ value,
219
+ isBeingDragged,
220
+ isDragInvalid,
221
+ isDropTarget,
222
+ nodeDropPosition
126
223
  } = useTreeViewStore(storeId)(useShallow(state => ({
127
224
  isExpanded: state.expanded.has(node.id),
128
- value: getValue(state.checked.has(node.id),
129
- // isChecked
130
- state.indeterminate.has(node.id) // isIndeterminate
131
- )
225
+ value: getValue(state.checked.has(node.id), state.indeterminate.has(node.id)),
226
+ isBeingDragged: state.draggedNodeId === node.id,
227
+ isDragInvalid: state.invalidDragTargetIds.has(node.id),
228
+ isDropTarget: state.dropTargetNodeId === node.id,
229
+ nodeDropPosition: state.dropTargetNodeId === node.id ? state.dropPosition : null
132
230
  })));
133
231
  const _onToggleExpand = React.useCallback(() => {
134
232
  handleToggleExpand(storeId, node.id);
@@ -136,13 +234,47 @@ function _Node(props) {
136
234
  const _onCheck = React.useCallback(() => {
137
235
  toggleCheckboxes(storeId, [node.id]);
138
236
  }, [storeId, node.id]);
237
+ const handleTouchStart = React.useCallback(e => {
238
+ if (!onNodeTouchStart) return;
239
+ const {
240
+ pageY,
241
+ locationY
242
+ } = e.nativeEvent;
243
+ onNodeTouchStart(node.id, pageY, locationY, nodeIndex);
244
+ }, [node.id, nodeIndex, onNodeTouchStart]);
245
+ const handleTouchEnd = React.useCallback(() => {
246
+ onNodeTouchEnd?.();
247
+ }, [onNodeTouchEnd]);
248
+
249
+ // Determine opacity for drag state
250
+ const dragOpacity = dragDropCustomizations?.draggedNodeOpacity ?? 0.3;
251
+ const nodeOpacity = isDraggingGlobal && (isBeingDragged || isDragInvalid) ? dragOpacity : 1.0;
252
+ const handleLayout = React.useCallback(e => {
253
+ onItemLayout?.(e.nativeEvent.layout.height);
254
+ }, [onItemLayout]);
255
+ const touchHandlers = dragEnabled ? {
256
+ onTouchStart: handleTouchStart,
257
+ onTouchEnd: handleTouchEnd,
258
+ onTouchCancel: handleTouchEnd
259
+ } : undefined;
260
+ const CustomDropIndicator = dragDropCustomizations?.CustomDropIndicatorComponent;
261
+ const dropIndicator = isDropTarget && nodeDropPosition ? CustomDropIndicator ? /*#__PURE__*/_jsx(CustomDropIndicator, {
262
+ position: nodeDropPosition
263
+ }) : /*#__PURE__*/_jsx(NodeDropIndicator, {
264
+ position: nodeDropPosition,
265
+ styleProps: dragDropCustomizations?.dropIndicatorStyleProps
266
+ }) : null;
139
267
  if (!CustomNodeRowComponent) {
140
268
  return /*#__PURE__*/_jsxs(View, {
141
269
  testID: `node_row_${node.id}`,
270
+ ...touchHandlers,
271
+ onLayout: onItemLayout ? handleLayout : undefined,
142
272
  style: [styles.nodeCheckboxAndArrowRow, {
143
273
  paddingStart: level * indentationMultiplier
274
+ }, {
275
+ opacity: nodeOpacity
144
276
  }],
145
- children: [/*#__PURE__*/_jsx(CheckboxComponent, {
277
+ children: [dropIndicator, /*#__PURE__*/_jsx(CheckboxComponent, {
146
278
  text: node.name,
147
279
  onValueChange: _onCheck,
148
280
  value: value,
@@ -158,17 +290,67 @@ function _Node(props) {
158
290
  }) : null]
159
291
  });
160
292
  } else {
161
- return /*#__PURE__*/_jsx(CustomNodeRowComponent, {
162
- node: node,
163
- level: level,
164
- checkedValue: value,
165
- isExpanded: isExpanded,
166
- onCheck: _onCheck,
167
- onExpand: _onToggleExpand
293
+ return /*#__PURE__*/_jsxs(View, {
294
+ ...touchHandlers,
295
+ onLayout: onItemLayout ? handleLayout : undefined,
296
+ style: {
297
+ opacity: nodeOpacity
298
+ },
299
+ children: [dropIndicator, /*#__PURE__*/_jsx(CustomNodeRowComponent, {
300
+ node: node,
301
+ level: level,
302
+ checkedValue: value,
303
+ isExpanded: isExpanded,
304
+ onCheck: _onCheck,
305
+ onExpand: _onToggleExpand,
306
+ isDragTarget: isDragInvalid,
307
+ isDragging: isDraggingGlobal,
308
+ isDraggedNode: isBeingDragged
309
+ })]
168
310
  });
169
311
  }
170
312
  }
171
313
  ;
314
+ function NodeDropIndicator({
315
+ position,
316
+ styleProps
317
+ }) {
318
+ const lineColor = styleProps?.lineColor ?? "#0078FF";
319
+ const lineThickness = styleProps?.lineThickness ?? 3;
320
+ const circleSize = styleProps?.circleSize ?? 10;
321
+ const highlightColor = styleProps?.highlightColor ?? "rgba(0, 120, 255, 0.15)";
322
+ const highlightBorderColor = styleProps?.highlightBorderColor ?? "rgba(0, 120, 255, 0.5)";
323
+ if (position === "inside") {
324
+ return /*#__PURE__*/_jsx(View, {
325
+ pointerEvents: "none",
326
+ style: [styles.dropHighlight, {
327
+ backgroundColor: highlightColor,
328
+ borderColor: highlightBorderColor
329
+ }]
330
+ });
331
+ }
332
+ return /*#__PURE__*/_jsxs(View, {
333
+ pointerEvents: "none",
334
+ style: [styles.dropLineContainer, {
335
+ height: lineThickness
336
+ }, position === "above" ? styles.dropLineTop : styles.dropLineBottom],
337
+ children: [/*#__PURE__*/_jsx(View, {
338
+ style: [styles.dropLineCircle, {
339
+ width: circleSize,
340
+ height: circleSize,
341
+ borderRadius: circleSize / 2,
342
+ backgroundColor: lineColor,
343
+ marginLeft: -(circleSize / 2),
344
+ marginTop: -(circleSize / 2 - lineThickness / 2)
345
+ }]
346
+ }), /*#__PURE__*/_jsx(View, {
347
+ style: [styles.dropLine, {
348
+ height: lineThickness,
349
+ backgroundColor: lineColor
350
+ }]
351
+ })]
352
+ });
353
+ }
172
354
  const styles = StyleSheet.create({
173
355
  defaultHeaderFooter: {
174
356
  padding: 5
@@ -181,6 +363,50 @@ const styles = StyleSheet.create({
181
363
  flexDirection: "row",
182
364
  alignItems: "center",
183
365
  minWidth: "100%"
366
+ },
367
+ dragContainer: {
368
+ flex: 1
369
+ },
370
+ // Drop indicator styles (rendered by each node)
371
+ dropHighlight: {
372
+ position: "absolute",
373
+ top: 0,
374
+ bottom: 0,
375
+ left: 0,
376
+ right: 0,
377
+ backgroundColor: "rgba(0, 120, 255, 0.15)",
378
+ borderWidth: 2,
379
+ borderColor: "rgba(0, 120, 255, 0.5)",
380
+ borderRadius: 4,
381
+ zIndex: 10
382
+ },
383
+ dropLineContainer: {
384
+ position: "absolute",
385
+ left: 0,
386
+ right: 0,
387
+ flexDirection: "row",
388
+ alignItems: "center",
389
+ height: 3,
390
+ zIndex: 10
391
+ },
392
+ dropLineTop: {
393
+ top: 0
394
+ },
395
+ dropLineBottom: {
396
+ bottom: 0
397
+ },
398
+ dropLineCircle: {
399
+ width: 10,
400
+ height: 10,
401
+ borderRadius: 5,
402
+ backgroundColor: "#0078FF",
403
+ marginLeft: -5,
404
+ marginTop: -4
405
+ },
406
+ dropLine: {
407
+ flex: 1,
408
+ height: 3,
409
+ backgroundColor: "#0078FF"
184
410
  }
185
411
  });
186
412
  //# sourceMappingURL=NodeList.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","View","StyleSheet","TouchableOpacity","FlashList","useTreeViewStore","getFilteredTreeData","getFlattenedTreeData","getInnerMostChildrenIdsInTree","handleToggleExpand","toggleCheckboxes","CheckboxView","CustomExpandCollapseIcon","defaultIndentationMultiplier","useShallow","typedMemo","ScrollToNodeHandler","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","NodeList","_NodeList","props","storeId","scrollToNodeHandlerRef","initialScrollNodeID","treeFlashListProps","checkBoxViewStyleProps","indentationMultiplier","CheckboxComponent","ExpandCollapseIconComponent","ExpandCollapseTouchableComponent","CustomNodeRowComponent","expanded","initialTreeViewData","updateInnerMostChildrenIds","searchKeys","searchText","state","flashListRef","useRef","initialScrollIndex","setInitialScrollIndex","useState","filteredTree","useMemo","trim","toLowerCase","flattenedFilteredNodes","useEffect","updatedInnerMostChildrenIds","nodeRenderer","useCallback","item","Node","node","level","children","ref","estimatedItemSize","removeClippedSubviews","keyboardShouldPersistTaps","drawDistance","ListHeaderComponent","HeaderFooterView","ListFooterComponent","data","renderItem","style","styles","defaultHeaderFooter","getValue","isChecked","isIndeterminate","_Node","isExpanded","value","has","id","checked","indeterminate","_onToggleExpand","_onCheck","testID","nodeCheckboxAndArrowRow","paddingStart","text","name","onValueChange","length","nodeExpandableArrowTouchable","onPress","checkedValue","onCheck","onExpand","create","padding","flex","flexDirection","alignItems","minWidth"],"sourceRoot":"../../../src","sources":["components/NodeList.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACIC,IAAI,EACJC,UAAU,EAEVC,gBAAgB,QACb,cAAc;AACrB,SAASC,SAAS,QAAQ,qBAAqB;AAS/C,SAASC,gBAAgB,QAAQ,4BAAyB;AAC1D,SACIC,mBAAmB,EACnBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,kBAAkB,EAClBC,gBAAgB,QACb,qBAAY;AACnB,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,S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QAAQ,EAAEgC,MAAM,gBAClB1E,IAAA,CAACgB,gCAAgC;QAC7BoD,MAAM,EAAE,oBAAoB5B,IAAI,CAACuB,EAAE,EAAG;QACtCV,KAAK,EAAEC,MAAM,CAACqB,4BAA6B;QAC3CC,OAAO,EAAEV,eAAgB;QAAAxB,QAAA,eACzB1C,IAAA,CAACe,2BAA2B;UACxB6C,UAAU,EAAEA;QAAW,CAC1B;MAAC,CAC4B,CAAC,GACnC,IAAI;IAAA,CACN,CAAC;EAEf,CAAC,MACI;IACD,oBACI5D,IAAA,CAACiB,sBAAsB;MACnBuB,IAAI,EAAEA,IAAK;MACXC,KAAK,EAAEA,KAAM;MACboC,YAAY,EAAEhB,KAAM;MACpBD,UAAU,EAAEA,UAAW;MACvBkB,OAAO,EAAEX,QAAS;MAClBY,QAAQ,EAAEb;IAAgB,CAAE,CAAC;EAEzC;AACJ;AAAC;AAED,MAAMZ,MAAM,GAAGtE,UAAU,CAACgG,MAAM,CAAC;EAC7BzB,mBAAmB,EAAE;IACjB0B,OAAO,EAAE;EACb,CAAC;EACDN,4BAA4B,EAAE;IAC1BO,IAAI,EAAE;EACV,CAAC;EACDb,uBAAuB,EAAE;IACrBa,IAAI,EAAE,CAAC;IACPC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,QAAQ,EAAE;EACd;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","View","StyleSheet","TouchableOpacity","FlashList","useTreeViewStore","getFilteredTreeData","getFlattenedTreeData","getInnerMostChildrenIdsInTree","handleToggleExpand","toggleCheckboxes","CheckboxView","CustomExpandCollapseIcon","DragOverlay","defaultIndentationMultiplier","useShallow","typedMemo","ScrollToNodeHandler","useDragDrop","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","NodeList","_NodeList","props","storeId","scrollToNodeHandlerRef","initialScrollNodeID","treeFlashListProps","checkBoxViewStyleProps","indentationMultiplier","CheckboxComponent","ExpandCollapseIconComponent","ExpandCollapseTouchableComponent","CustomNodeRowComponent","dragEnabled","onDragEnd","longPressDuration","autoScrollThreshold","autoScrollSpeed","dragOverlayOffset","autoExpandDelay","dragDropCustomizations","expanded","initialTreeViewData","updateInnerMostChildrenIds","searchKeys","searchText","state","flashListRef","useRef","containerRef","internalDataRef","measuredItemHeightRef","handleItemLayout","useCallback","height","current","initialScrollIndex","setInitialScrollIndex","useState","filteredTree","useMemo","trim","toLowerCase","flattenedFilteredNodes","useEffect","updatedInnerMostChildrenIds","panResponder","overlayY","isDragging","draggedNode","handleNodeTouchStart","cancelLongPressTimer","scrollOffsetRef","flattenedNodes","handleScroll","event","nativeEvent","contentOffset","y","onScroll","effectiveIndentationMultiplier","nodeRenderer","item","index","Node","node","level","nodeIndex","onNodeTouchStart","undefined","onNodeTouchEnd","onItemLayout","_userOnScroll","restFlashListProps","flashListElement","ref","estimatedItemSize","removeClippedSubviews","keyboardShouldPersistTaps","drawDistance","ListHeaderComponent","HeaderFooterView","ListFooterComponent","scrollEnabled","data","renderItem","children","style","styles","dragContainer","panHandlers","defaultHeaderFooter","getValue","isChecked","isIndeterminate","_Node","isDraggingGlobal","isExpanded","value","isBeingDragged","isDragInvalid","isDropTarget","nodeDropPosition","has","id","checked","indeterminate","draggedNodeId","invalidDragTargetIds","dropTargetNodeId","dropPosition","_onToggleExpand","_onCheck","handleTouchStart","e","pageY","locationY","handleTouchEnd","dragOpacity","draggedNodeOpacity","nodeOpacity","handleLayout","layout","touchHandlers","onTouchStart","onTouchEnd","onTouchCancel","CustomDropIndicator","CustomDropIndicatorComponent","dropIndicator","position","NodeDropIndicator","styleProps","dropIndicatorStyleProps","testID","onLayout","nodeCheckboxAndArrowRow","paddingStart","opacity","text","name","onValueChange","length","nodeExpandableArrowTouchable","onPress","checkedValue","onCheck","onExpand","isDragTarget","isDraggedNode","lineColor","lineThickness","circleSize","highlightColor","highlightBorderColor","pointerEvents","dropHighlight","backgroundColor","borderColor","dropLineContainer","dropLineTop","dropLineBottom","dropLineCircle","width","borderRadius","marginLeft","marginTop","dropLine","create","padding","flex","flexDirection","alignItems","minWidth","top","bottom","left","right","borderWidth","zIndex"],"sourceRoot":"../../../src","sources":["components/NodeList.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACIC,IAAI,EACJC,UAAU,EACVC,gBAAgB,QAGb,cAAc;AACrB,SAASC,SAAS,QAAQ,qBAAqB;AAW/C,SAASC,gBAAgB,QAAQ,4BAAyB;AAC1D,SACIC,mBAAmB,EACnBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,kBAAkB,EAClBC,gBAAgB,QACb,qBAAY;AACnB,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,wBAAwB,QAAQ,+BAA4B;AACrE,SAASC,WAAW,QAAQ,kBAAe;AAE3C,SAASC,4BAA4B,QAAQ,oCAAiC;AAC9E,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SAASC,mBAAmB,QAAQ,oCAAiC;AACrE,SAASC,WAAW,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAEnD,MAAMC,QAAQ,GAAGT,SAAS,CAACU,SAAS,CAAC;AACrC,eAAeD,QAAQ;AAEvB,SAASC,SAASA,CAAKC,KAAwB,EAAE;EAC7C,MAAM;IACFC,OAAO;IAEPC,sBAAsB;IACtBC,mBAAmB;IAEnBC,kBAAkB;IAClBC,sBAAsB;IACtBC,qBAAqB;IAErBC,iBAAiB;IACjBC,2BAA2B;IAC3BC,gCAAgC;IAChCC,sBAAsB;IAEtBC,WAAW;IACXC,SAAS;IACTC,iBAAiB,GAAG,GAAG;IACvBC,mBAAmB,GAAG,EAAE;IACxBC,eAAe,GAAG,GAAG;IACrBC,iBAAiB,GAAG,CAAC,CAAC;IACtBC,eAAe,GAAG,GAAG;IACrBC;EACJ,CAAC,GAAGlB,K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.js";
9
9
  export * from "./search.helper.js";
10
10
  export * from "./flattenTree.helper.js";
11
+ export * from "./moveTreeNode.helper.js";
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["helpers/index.ts"],"mappings":";;AAAA;;AAEA,cAAc,4BAAyB;AACvC,cAAc,sBAAmB;AACjC,cAAc,uBAAoB;AAClC,cAAc,4BAAyB;AACvC,cAAc,oBAAiB;AAC/B,cAAc,yBAAsB","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["helpers/index.ts"],"mappings":";;AAAA;;AAEA,cAAc,4BAAyB;AACvC,cAAc,sBAAmB;AACjC,cAAc,uBAAoB;AAClC,cAAc,4BAAyB;AACvC,cAAc,oBAAiB;AAC/B,cAAc,yBAAsB;AACpC,cAAc,0BAAuB","ignoreList":[]}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Move a node within a tree structure. Returns a new tree (no mutation).
5
+ *
6
+ * @param data - The current tree data
7
+ * @param draggedNodeId - The ID of the node to move
8
+ * @param targetNodeId - The ID of the target node
9
+ * @param position - Where to place relative to target: "above", "below", or "inside"
10
+ * @returns New tree data with the node moved, or the original data if the move is invalid
11
+ */
12
+ export function moveTreeNode(data, draggedNodeId, targetNodeId, position) {
13
+ if (draggedNodeId === targetNodeId) return data;
14
+
15
+ // Step 1: Deep clone the tree
16
+ const cloned = deepCloneTree(data);
17
+
18
+ // Step 2: Remove the dragged node
19
+ const removedNode = removeNodeById(cloned, draggedNodeId);
20
+ if (!removedNode) return data;
21
+
22
+ // Step 3: Insert at the new position
23
+ const inserted = insertNode(cloned, removedNode, targetNodeId, position);
24
+ if (!inserted) return data;
25
+ return cloned;
26
+ }
27
+ function deepCloneTree(nodes) {
28
+ return nodes.map(node => ({
29
+ ...node,
30
+ children: node.children ? deepCloneTree(node.children) : undefined
31
+ }));
32
+ }
33
+
34
+ /**
35
+ * Remove a node by ID from the tree. Mutates the cloned tree in-place.
36
+ * Returns the removed node, or null if not found.
37
+ */
38
+ function removeNodeById(nodes, nodeId) {
39
+ for (let i = 0; i < nodes.length; i++) {
40
+ if (nodes[i].id === nodeId) {
41
+ const [removed] = nodes.splice(i, 1);
42
+ return removed;
43
+ }
44
+ const children = nodes[i].children;
45
+ if (children) {
46
+ const removed = removeNodeById(children, nodeId);
47
+ if (removed) {
48
+ // Clean up empty children arrays
49
+ if (children.length === 0) {
50
+ nodes[i] = {
51
+ ...nodes[i],
52
+ children: undefined
53
+ };
54
+ }
55
+ return removed;
56
+ }
57
+ }
58
+ }
59
+ return null;
60
+ }
61
+
62
+ /**
63
+ * Insert a node relative to a target node. Mutates the cloned tree in-place.
64
+ * Returns true if insertion was successful.
65
+ */
66
+ function insertNode(nodes, nodeToInsert, targetId, position) {
67
+ for (let i = 0; i < nodes.length; i++) {
68
+ if (nodes[i].id === targetId) {
69
+ if (position === "above") {
70
+ nodes.splice(i, 0, nodeToInsert);
71
+ } else if (position === "below") {
72
+ nodes.splice(i + 1, 0, nodeToInsert);
73
+ } else {
74
+ // "inside" - add as first child
75
+ const target = nodes[i];
76
+ if (target.children) {
77
+ target.children.unshift(nodeToInsert);
78
+ } else {
79
+ nodes[i] = {
80
+ ...target,
81
+ children: [nodeToInsert]
82
+ };
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+ const children = nodes[i].children;
88
+ if (children) {
89
+ if (insertNode(children, nodeToInsert, targetId, position)) {
90
+ return true;
91
+ }
92
+ }
93
+ }
94
+ return false;
95
+ }
96
+ //# sourceMappingURL=moveTreeNode.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["moveTreeNode","data","draggedNodeId","targetNodeId","position","cloned","deepCloneTree","removedNode","removeNodeById","inserted","insertNode","nodes","map","node","children","undefined","nodeId","i","length","id","removed","splice","nodeToInsert","targetId","target","unshift"],"sourceRoot":"../../../src","sources":["helpers/moveTreeNode.helper.ts"],"mappings":";;AAGA;AACA;AACA;A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,YAAY,EAAEC,QAAQ,EAAEnB,QAAQ,CAAC,EAAE;QACxD,OAAO,IAAI;MACf;IACJ;EACJ;EACA,OAAO,KAAK;AAChB","ignoreList":[]}
@@ -186,4 +186,92 @@ export function toggleCheckboxes(storeId, ids, forceCheck) {
186
186
  updateChecked(tempChecked);
187
187
  updateIndeterminate(tempIndeterminate);
188
188
  }
189
+
190
+ /**
191
+ * Recalculates checked/indeterminate state for all parent nodes bottom-up.
192
+ * Should be called after tree structure changes (e.g., drag-drop moves) to ensure
193
+ * parent states correctly reflect their children's checked states.
194
+ */
195
+ export function recalculateCheckedStates(storeId) {
196
+ const treeViewStore = getTreeViewStore(storeId);
197
+ const {
198
+ checked,
199
+ updateChecked,
200
+ indeterminate,
201
+ updateIndeterminate,
202
+ nodeMap,
203
+ childToParentMap,
204
+ selectionPropagation
205
+ } = treeViewStore.getState();
206
+
207
+ // Only recalculate if parent propagation is enabled
208
+ if (!selectionPropagation.toParents) return;
209
+ const tempChecked = new Set(checked);
210
+ const tempIndeterminate = new Set(indeterminate);
211
+
212
+ // Collect parent nodes and clean up leaf nodes that shouldn't be indeterminate.
213
+ // A leaf node (no children) can never be indeterminate — this can happen when
214
+ // all children of a formerly-indeterminate parent are dragged away.
215
+ const parentNodes = [];
216
+ for (const [id, node] of nodeMap) {
217
+ if (node.children && node.children.length > 0) {
218
+ parentNodes.push(id);
219
+ } else {
220
+ tempIndeterminate.delete(id);
221
+ }
222
+ }
223
+
224
+ // Sort by depth descending (deepest first) for correct bottom-up propagation
225
+ const nodeDepths = new Map();
226
+ function getDepth(nodeId) {
227
+ if (nodeDepths.has(nodeId)) return nodeDepths.get(nodeId);
228
+ let depth = 0;
229
+ let currentId = nodeId;
230
+ while (currentId) {
231
+ const parentId = childToParentMap.get(currentId);
232
+ if (parentId) {
233
+ depth++;
234
+ currentId = parentId;
235
+ } else {
236
+ break;
237
+ }
238
+ }
239
+ nodeDepths.set(nodeId, depth);
240
+ return depth;
241
+ }
242
+ parentNodes.sort((a, b) => getDepth(b) - getDepth(a));
243
+
244
+ // Update each parent based on its children's current state
245
+ for (const parentId of parentNodes) {
246
+ const node = nodeMap.get(parentId);
247
+ if (!node?.children?.length) continue;
248
+ let allChecked = true;
249
+ let anyCheckedOrIndeterminate = false;
250
+ for (const child of node.children) {
251
+ const isChecked = tempChecked.has(child.id);
252
+ const isIndeterminate = tempIndeterminate.has(child.id);
253
+ if (isChecked) {
254
+ anyCheckedOrIndeterminate = true;
255
+ } else if (isIndeterminate) {
256
+ anyCheckedOrIndeterminate = true;
257
+ allChecked = false;
258
+ } else {
259
+ allChecked = false;
260
+ }
261
+ if (!allChecked && anyCheckedOrIndeterminate) break;
262
+ }
263
+ if (allChecked) {
264
+ tempChecked.add(parentId);
265
+ tempIndeterminate.delete(parentId);
266
+ } else if (anyCheckedOrIndeterminate) {
267
+ tempChecked.delete(parentId);
268
+ tempIndeterminate.add(parentId);
269
+ } else {
270
+ tempChecked.delete(parentId);
271
+ tempIndeterminate.delete(parentId);
272
+ }
273
+ }
274
+ updateChecked(tempChecked);
275
+ updateIndeterminate(tempIndeterminate);
276
+ }
189
277
  //# sourceMappingURL=toggleCheckbox.helper.js.map