react-native-tree-multi-select 2.0.13 → 3.0.0-beta.2

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 +104 -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 +288 -33
  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 +683 -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 +22 -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 +13 -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 +40 -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 +9 -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 +94 -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 +114 -0
  49. package/src/components/DropIndicator.tsx +95 -0
  50. package/src/components/NodeList.tsx +327 -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 +835 -0
  55. package/src/index.tsx +19 -2
  56. package/src/store/treeView.store.ts +36 -0
  57. package/src/types/dragDrop.types.ts +23 -0
  58. package/src/types/treeView.types.ts +110 -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,48 @@ function _NodeList(props) {
54
72
  const updatedInnerMostChildrenIds = getInnerMostChildrenIdsInTree(filteredTree);
55
73
  updateInnerMostChildrenIds(updatedInnerMostChildrenIds);
56
74
  }, [filteredTree, updateInnerMostChildrenIds]);
75
+ const effectiveIndentationMultiplier = indentationMultiplier ?? defaultIndentationMultiplier;
76
+
77
+ // --- Drag and drop ---
78
+ const {
79
+ panResponder,
80
+ overlayY,
81
+ overlayX,
82
+ isDragging,
83
+ draggedNode,
84
+ effectiveDropLevel,
85
+ handleNodeTouchStart,
86
+ handleNodeTouchEnd,
87
+ cancelLongPressTimer,
88
+ scrollOffsetRef
89
+ } = useDragDrop({
90
+ storeId,
91
+ flattenedNodes: flattenedFilteredNodes,
92
+ flashListRef,
93
+ containerRef,
94
+ dragEnabled: dragEnabled ?? false,
95
+ onDragEnd,
96
+ longPressDuration,
97
+ autoScrollThreshold,
98
+ autoScrollSpeed,
99
+ internalDataRef,
100
+ measuredItemHeightRef,
101
+ dragOverlayOffset,
102
+ autoExpandDelay,
103
+ indentationMultiplier: effectiveIndentationMultiplier
104
+ });
105
+
106
+ // Combined onScroll handler
107
+ const handleScroll = React.useCallback(event => {
108
+ scrollOffsetRef.current = event.nativeEvent.contentOffset.y;
109
+ // Cancel long press timer if user is scrolling
110
+ cancelLongPressTimer();
111
+ // Forward to user's onScroll
112
+ treeFlashListProps?.onScroll?.(event);
113
+ }, [scrollOffsetRef, cancelLongPressTimer, treeFlashListProps]);
57
114
  const nodeRenderer = React.useCallback(({
58
- item
115
+ item,
116
+ index
59
117
  }) => {
60
118
  return /*#__PURE__*/_jsx(Node, {
61
119
  storeId: storeId,
@@ -66,9 +124,38 @@ function _NodeList(props) {
66
124
  CheckboxComponent: CheckboxComponent,
67
125
  ExpandCollapseIconComponent: ExpandCollapseIconComponent,
68
126
  ExpandCollapseTouchableComponent: ExpandCollapseTouchableComponent,
69
- CustomNodeRowComponent: CustomNodeRowComponent
127
+ CustomNodeRowComponent: CustomNodeRowComponent,
128
+ nodeIndex: index,
129
+ dragEnabled: dragEnabled,
130
+ isDragging: isDragging,
131
+ onNodeTouchStart: dragEnabled ? handleNodeTouchStart : undefined,
132
+ onNodeTouchEnd: dragEnabled ? handleNodeTouchEnd : undefined,
133
+ onItemLayout: dragEnabled ? handleItemLayout : undefined,
134
+ dragDropCustomizations: dragDropCustomizations
70
135
  });
71
- }, [storeId, CheckboxComponent, ExpandCollapseIconComponent, ExpandCollapseTouchableComponent, CustomNodeRowComponent, checkBoxViewStyleProps, indentationMultiplier]);
136
+ }, [storeId, CheckboxComponent, ExpandCollapseIconComponent, ExpandCollapseTouchableComponent, CustomNodeRowComponent, checkBoxViewStyleProps, indentationMultiplier, dragEnabled, isDragging, handleNodeTouchStart, handleNodeTouchEnd, dragDropCustomizations, handleItemLayout]);
137
+
138
+ // Extract FlashList props but exclude onScroll (we provide our own combined handler)
139
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
140
+ const {
141
+ onScroll: _userOnScroll,
142
+ ...restFlashListProps
143
+ } = treeFlashListProps ?? {};
144
+ const flashListElement = /*#__PURE__*/_jsx(FlashList, {
145
+ ref: flashListRef,
146
+ estimatedItemSize: 36,
147
+ initialScrollIndex: initialScrollIndex,
148
+ removeClippedSubviews: true,
149
+ keyboardShouldPersistTaps: "handled",
150
+ drawDistance: 50,
151
+ ListHeaderComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
152
+ ListFooterComponent: /*#__PURE__*/_jsx(HeaderFooterView, {}),
153
+ ...restFlashListProps,
154
+ onScroll: handleScroll,
155
+ scrollEnabled: isDragging ? false : restFlashListProps?.scrollEnabled ?? true,
156
+ data: flattenedFilteredNodes,
157
+ renderItem: nodeRenderer
158
+ });
72
159
  return /*#__PURE__*/_jsxs(_Fragment, {
73
160
  children: [/*#__PURE__*/_jsx(ScrollToNodeHandler, {
74
161
  ref: scrollToNodeHandlerRef,
@@ -77,19 +164,23 @@ function _NodeList(props) {
77
164
  flattenedFilteredNodes: flattenedFilteredNodes,
78
165
  setInitialScrollIndex: setInitialScrollIndex,
79
166
  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
- })]
167
+ }), dragEnabled ? /*#__PURE__*/_jsxs(View, {
168
+ ref: containerRef,
169
+ style: styles.dragContainer,
170
+ ...panResponder.panHandlers,
171
+ children: [flashListElement, isDragging && draggedNode && /*#__PURE__*/_jsx(DragOverlay, {
172
+ overlayY: overlayY,
173
+ overlayX: overlayX,
174
+ node: draggedNode,
175
+ level: effectiveDropLevel,
176
+ indentationMultiplier: effectiveIndentationMultiplier,
177
+ CheckboxComponent: CheckboxComponent,
178
+ ExpandCollapseIconComponent: ExpandCollapseIconComponent,
179
+ CustomNodeRowComponent: CustomNodeRowComponent,
180
+ checkBoxViewStyleProps: checkBoxViewStyleProps,
181
+ dragDropCustomizations: dragDropCustomizations
182
+ })]
183
+ }) : flashListElement]
93
184
  });
94
185
  }
95
186
  ;
@@ -118,31 +209,95 @@ function _Node(props) {
118
209
  ExpandCollapseIconComponent = CustomExpandCollapseIcon,
119
210
  CheckboxComponent = CheckboxView,
120
211
  ExpandCollapseTouchableComponent = TouchableOpacity,
121
- CustomNodeRowComponent
212
+ CustomNodeRowComponent,
213
+ nodeIndex = 0,
214
+ dragEnabled,
215
+ isDragging: isDraggingGlobal,
216
+ onNodeTouchStart,
217
+ onNodeTouchEnd,
218
+ onItemLayout,
219
+ dragDropCustomizations
122
220
  } = props;
123
221
  const {
124
222
  isExpanded,
125
- value
223
+ value,
224
+ isBeingDragged,
225
+ isDragInvalid,
226
+ isDropTarget,
227
+ nodeDropPosition,
228
+ nodeDropLevel
126
229
  } = useTreeViewStore(storeId)(useShallow(state => ({
127
230
  isExpanded: state.expanded.has(node.id),
128
- value: getValue(state.checked.has(node.id),
129
- // isChecked
130
- state.indeterminate.has(node.id) // isIndeterminate
131
- )
231
+ value: getValue(state.checked.has(node.id), state.indeterminate.has(node.id)),
232
+ isBeingDragged: state.draggedNodeId === node.id,
233
+ isDragInvalid: state.invalidDragTargetIds.has(node.id),
234
+ isDropTarget: state.dropTargetNodeId === node.id,
235
+ nodeDropPosition: state.dropTargetNodeId === node.id ? state.dropPosition : null,
236
+ nodeDropLevel: state.dropTargetNodeId === node.id ? state.dropLevel : null
132
237
  })));
238
+
239
+ // Track when this node was dragged so we can swallow the onPress/onCheck
240
+ // that fires when the user lifts their finger after a long-press-initiated drag.
241
+ // The flag is set during render (synchronous) and cleared on the next touch start.
242
+ const wasDraggedRef = React.useRef(false);
243
+ if (isDraggingGlobal && isBeingDragged) {
244
+ wasDraggedRef.current = true;
245
+ }
133
246
  const _onToggleExpand = React.useCallback(() => {
247
+ if (wasDraggedRef.current) return;
134
248
  handleToggleExpand(storeId, node.id);
135
249
  }, [storeId, node.id]);
136
250
  const _onCheck = React.useCallback(() => {
251
+ if (wasDraggedRef.current) return;
137
252
  toggleCheckboxes(storeId, [node.id]);
138
253
  }, [storeId, node.id]);
254
+ const handleTouchStart = React.useCallback(e => {
255
+ wasDraggedRef.current = false;
256
+ if (!onNodeTouchStart) return;
257
+ const {
258
+ pageY,
259
+ locationY
260
+ } = e.nativeEvent;
261
+ onNodeTouchStart(node.id, pageY, locationY, nodeIndex);
262
+ }, [node.id, nodeIndex, onNodeTouchStart]);
263
+ const handleTouchEnd = React.useCallback(() => {
264
+ onNodeTouchEnd?.();
265
+ }, [onNodeTouchEnd]);
266
+
267
+ // Determine opacity for drag state
268
+ const dragOpacity = dragDropCustomizations?.draggedNodeOpacity ?? 0.3;
269
+ const nodeOpacity = isDraggingGlobal && (isBeingDragged || isDragInvalid) ? dragOpacity : 1.0;
270
+ const handleLayout = React.useCallback(e => {
271
+ onItemLayout?.(e.nativeEvent.layout.height);
272
+ }, [onItemLayout]);
273
+ const touchHandlers = dragEnabled ? {
274
+ onTouchStart: handleTouchStart,
275
+ onTouchEnd: handleTouchEnd,
276
+ onTouchCancel: handleTouchEnd
277
+ } : undefined;
278
+ const CustomDropIndicator = dragDropCustomizations?.CustomDropIndicatorComponent;
279
+ const indicatorLevel = nodeDropLevel ?? level;
280
+ const dropIndicator = isDropTarget && nodeDropPosition ? CustomDropIndicator ? /*#__PURE__*/_jsx(CustomDropIndicator, {
281
+ position: nodeDropPosition,
282
+ level: indicatorLevel,
283
+ indentationMultiplier: indentationMultiplier
284
+ }) : /*#__PURE__*/_jsx(NodeDropIndicator, {
285
+ position: nodeDropPosition,
286
+ level: indicatorLevel,
287
+ indentationMultiplier: indentationMultiplier,
288
+ styleProps: dragDropCustomizations?.dropIndicatorStyleProps
289
+ }) : null;
139
290
  if (!CustomNodeRowComponent) {
140
291
  return /*#__PURE__*/_jsxs(View, {
141
292
  testID: `node_row_${node.id}`,
293
+ ...touchHandlers,
294
+ onLayout: onItemLayout ? handleLayout : undefined,
142
295
  style: [styles.nodeCheckboxAndArrowRow, {
143
296
  paddingStart: level * indentationMultiplier
144
- }],
145
- children: [/*#__PURE__*/_jsx(CheckboxComponent, {
297
+ }, {
298
+ opacity: nodeOpacity
299
+ }, dropIndicator ? styles.nodeOverflowVisible : undefined],
300
+ children: [dropIndicator, /*#__PURE__*/_jsx(CheckboxComponent, {
146
301
  text: node.name,
147
302
  onValueChange: _onCheck,
148
303
  value: value,
@@ -158,17 +313,77 @@ function _Node(props) {
158
313
  }) : null]
159
314
  });
160
315
  } else {
161
- return /*#__PURE__*/_jsx(CustomNodeRowComponent, {
162
- node: node,
163
- level: level,
164
- checkedValue: value,
165
- isExpanded: isExpanded,
166
- onCheck: _onCheck,
167
- onExpand: _onToggleExpand
316
+ return /*#__PURE__*/_jsxs(View, {
317
+ ...touchHandlers,
318
+ onLayout: onItemLayout ? handleLayout : undefined,
319
+ style: [{
320
+ opacity: nodeOpacity
321
+ }, dropIndicator ? styles.nodeOverflowVisible : undefined],
322
+ children: [dropIndicator, /*#__PURE__*/_jsx(CustomNodeRowComponent, {
323
+ node: node,
324
+ level: level,
325
+ checkedValue: value,
326
+ isExpanded: isExpanded,
327
+ onCheck: _onCheck,
328
+ onExpand: _onToggleExpand,
329
+ isDragTarget: isDragInvalid,
330
+ isDragging: isDraggingGlobal,
331
+ isDraggedNode: isBeingDragged
332
+ })]
168
333
  });
169
334
  }
170
335
  }
171
336
  ;
337
+ function NodeDropIndicator({
338
+ position,
339
+ level,
340
+ indentationMultiplier,
341
+ styleProps
342
+ }) {
343
+ const lineColor = styleProps?.lineColor ?? "#0078FF";
344
+ const lineThickness = styleProps?.lineThickness ?? 3;
345
+ const circleSize = styleProps?.circleSize ?? 10;
346
+ const highlightColor = styleProps?.highlightColor ?? "rgba(0, 120, 255, 0.15)";
347
+ const highlightBorderColor = styleProps?.highlightBorderColor ?? "rgba(0, 120, 255, 0.5)";
348
+
349
+ // Indent the line to match the node's nesting level so users can
350
+ // visually distinguish drops at different tree depths.
351
+ const leftOffset = level * indentationMultiplier;
352
+ if (position === "inside") {
353
+ return /*#__PURE__*/_jsx(View, {
354
+ pointerEvents: "none",
355
+ style: [styles.dropHighlight, {
356
+ left: leftOffset,
357
+ backgroundColor: highlightColor,
358
+ borderColor: highlightBorderColor
359
+ }]
360
+ });
361
+ }
362
+
363
+ // Ensure the circle isn't clipped at shallow indent levels
364
+ const safeLeftOffset = Math.max(leftOffset, circleSize / 2);
365
+ return /*#__PURE__*/_jsxs(View, {
366
+ pointerEvents: "none",
367
+ style: [styles.dropLineContainer, {
368
+ height: lineThickness,
369
+ left: safeLeftOffset
370
+ }, position === "above" ? styles.dropLineTop : styles.dropLineBottom],
371
+ children: [/*#__PURE__*/_jsx(View, {
372
+ style: {
373
+ width: circleSize,
374
+ height: circleSize,
375
+ borderRadius: circleSize / 2,
376
+ backgroundColor: lineColor,
377
+ marginLeft: -(circleSize / 2)
378
+ }
379
+ }), /*#__PURE__*/_jsx(View, {
380
+ style: [styles.dropLine, {
381
+ height: lineThickness,
382
+ backgroundColor: lineColor
383
+ }]
384
+ })]
385
+ });
386
+ }
172
387
  const styles = StyleSheet.create({
173
388
  defaultHeaderFooter: {
174
389
  padding: 5
@@ -181,6 +396,46 @@ const styles = StyleSheet.create({
181
396
  flexDirection: "row",
182
397
  alignItems: "center",
183
398
  minWidth: "100%"
399
+ },
400
+ dragContainer: {
401
+ flex: 1
402
+ },
403
+ // Drop indicator styles (rendered by each node)
404
+ dropHighlight: {
405
+ position: "absolute",
406
+ top: 0,
407
+ bottom: 0,
408
+ left: 0,
409
+ right: 0,
410
+ backgroundColor: "rgba(0, 120, 255, 0.15)",
411
+ borderWidth: 2,
412
+ borderColor: "rgba(0, 120, 255, 0.5)",
413
+ borderRadius: 4,
414
+ zIndex: 10
415
+ },
416
+ dropLineContainer: {
417
+ position: "absolute",
418
+ left: 0,
419
+ right: 0,
420
+ flexDirection: "row",
421
+ alignItems: "center",
422
+ height: 3,
423
+ zIndex: 10,
424
+ overflow: "visible"
425
+ },
426
+ dropLineTop: {
427
+ top: 0
428
+ },
429
+ dropLineBottom: {
430
+ bottom: 0
431
+ },
432
+ dropLine: {
433
+ flex: 1,
434
+ height: 3,
435
+ backgroundColor: "#0078FF"
436
+ },
437
+ nodeOverflowVisible: {
438
+ overflow: "visible"
184
439
  }
185
440
  });
186
441
  //# 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,SAASC,wBAAwB,QAAQ,+BAA4B;AACrE,SAASC,4BAA4B,QAAQ,oCAAiC;AAC9E,SAASC,UAAU,QAAQ,uBAAuB;AAClD,SAASC,SAAS,QAAQ,uBAAoB;AAC9C,SAASC,mBAAmB,QAAQ,oCAAiC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtE,MAAMC,QAAQ,GAAGR,SAAS,CAACS,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;IACjB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AClBY,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","effectiveIndentationMultiplier","panResponder","overlayY","overlayX","isDragging","draggedNode","effectiveDropLevel","handleNodeTouchStart","handleNodeTouchEnd","cancelLongPressTimer","scrollOffsetRef","flattenedNodes","handleScroll","event","nativeEvent","contentOffset","y","onScroll","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","nodeDropLevel","has","id","checked","indeterminate","draggedNodeId","invalidDragTargetIds","dropTargetNodeId","dropPosition","dropLevel","wasDraggedRef","_onToggleExpand","_onCheck","handleTouchStart","e","pageY","locationY","handleTouchEnd","dragOpacity","draggedNodeOpacity","nodeOpacity","handleLayout","layout","touchHandlers","onTouchStart","onTouchEnd","onTouchCancel","CustomDropIndicator","CustomDropIndicatorComponent","indicatorLevel","dropIndicator","position","NodeDropIndicator","styleProps","dropIndicatorStyleProps","testID","onLayout","nodeCheckboxAndArrowRow","paddingStart","opacity","nodeOverflowVisible","text","name","onValueChange","length","nodeExpandableArrowTouchable","onPress","checkedValue","onCheck","onExpand","isDragTarget","isDraggedNode","lineColor","lineThickness","circleSize","highlightColor","highlightBorderColor","leftOffset","pointerEvents","dropHighlight","left","backgroundColor","borderColor","safeLeftOffset","Math","max","dropLineContainer","dropLineTop","dropLineBottom","width","borderRadius","marginLeft","dropLine","create","padding","flex","flexDirection","alignItems","minWidth","top","bottom","right","borderWidth","zIndex","overflow"],"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,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rJ,MAAM,EAAE,CAAC;IACT2J,MAAM,EAAE,EAAE;IACVC,QAAQ,EAAE;EACd,CAAC;EACDjB,WAAW,EAAE;IACTY,GAAG,EAAE;EACT,CAAC;EACDX,cAAc,EAAE;IACZY,MAAM,EAAE;EACZ,CAAC;EACDR,QAAQ,EAAE;IACNG,IAAI,EAAE,CAAC;IACPnJ,MAAM,EAAE,CAAC;IACTqI,eAAe,EAAE;EACrB,CAAC;EACDrB,mBAAmB,EAAE;IACjB4C,QAAQ,EAAE;EACd;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -8,4 +8,5 @@ export * from "./selectAll.helper.js";
8
8
  export * from "./toggleCheckbox.helper.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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CACxBC,IAAoB,EACpBC,aAAiB,EACjBC,YAAgB,EAChBC,QAAsB,EACR;EACd,IAAIF,aAAa,KAAKC,YAAY,EAAE,OAAOF,IAAI;;EAE/C;EACA,MAAMI,MAAM,GAAGC,aAAa,CAACL,IAAI,CAAC;;EAElC;EACA,MAAMM,WAAW,GAAGC,cAAc,CAACH,MAAM,EAAEH,aAAa,CAAC;EACzD,IAAI,CAACK,WAAW,EAAE,OAAON,IAAI;;EAE7B;EACA,MAAMQ,QAAQ,GAAGC,UAAU,CAACL,MAAM,EAAEE,WAAW,EAAEJ,YAAY,EAAEC,QAAQ,CAAC;EACxE,IAAI,CAACK,QAAQ,EAAE,OAAOR,IAAI;EAE1B,OAAOI,MAAM;AACjB;AAEA,SAASC,aAAaA,CAAKK,KAAqB,EAAkB;EAC9D,OAAOA,KAAK,CAACC,GAAG,CAACC,IAAI,KAAK;IACtB,GAAGA,IAAI;IACPC,QAAQ,EAAED,IAAI,CAACC,QAAQ,GAAGR,aAAa,CAACO,IAAI,CAACC,QAAQ,CAAC,GAAGC;EAC7D,CAAC,CAAC,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA,SAASP,cAAcA,CACnBG,KAAqB,EACrBK,MAAU,EACS;EACn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,MAAM,GAAGb,KAAK,CAACM,CAAC,CAAE;QACxB,IAAIO,MAAM,CAACV,QAAQ,EAAE;UACjBU,MAAM,CAACV,QAAQ,CAACW,OAAO,CAACH,YAAY,CAAC;QACzC,CAAC,MAAM;UACHX,KAAK,CAACM,CAAC,CAAC,GAAG;YAAE,GAAGO,MAAM;YAAEV,QAAQ,EAAE,CAACQ,YAAY;UAAE,CAAC;QACtD;MACJ;MACA,OAAO,IAAI;IACf;IACA,MAAMR,QAAQ,GAAGH,KAAK,CAACM,CAAC,CAAC,CAAEH,QAAQ;IACnC,IAAIA,QAAQ,EAAE;MACV,IAAIJ,UAAU,CAACI,QAAQ,EAAEQ,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