react-native-tree-multi-select 3.0.0-beta.4 → 3.0.0-beta.6
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.
- package/README.md +64 -30
- package/lib/module/TreeView.js +130 -24
- package/lib/module/TreeView.js.map +1 -1
- package/lib/module/components/DragOverlay.js +19 -2
- package/lib/module/components/DragOverlay.js.map +1 -1
- package/lib/module/components/NodeList.js +83 -31
- package/lib/module/components/NodeList.js.map +1 -1
- package/lib/module/constants/treeView.constants.js +5 -0
- package/lib/module/constants/treeView.constants.js.map +1 -1
- package/lib/module/helpers/moveTreeNode.helper.js +175 -47
- package/lib/module/helpers/moveTreeNode.helper.js.map +1 -1
- package/lib/module/helpers/toggleCheckbox.helper.js +6 -13
- package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -1
- package/lib/module/helpers/treeNode.helper.js +49 -0
- package/lib/module/helpers/treeNode.helper.js.map +1 -1
- package/lib/module/hooks/useDragDrop.js +486 -216
- package/lib/module/hooks/useDragDrop.js.map +1 -1
- package/lib/module/hooks/useScrollToNode.js +18 -1
- package/lib/module/hooks/useScrollToNode.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/store/treeView.store.js +7 -0
- package/lib/module/store/treeView.store.js.map +1 -1
- package/lib/module/types/dragDrop.types.js +0 -2
- package/lib/typescript/src/TreeView.d.ts.map +1 -1
- package/lib/typescript/src/components/DragOverlay.d.ts.map +1 -1
- package/lib/typescript/src/components/NodeList.d.ts.map +1 -1
- package/lib/typescript/src/constants/treeView.constants.d.ts +4 -0
- package/lib/typescript/src/constants/treeView.constants.d.ts.map +1 -1
- package/lib/typescript/src/helpers/moveTreeNode.helper.d.ts +32 -0
- package/lib/typescript/src/helpers/moveTreeNode.helper.d.ts.map +1 -1
- package/lib/typescript/src/helpers/toggleCheckbox.helper.d.ts.map +1 -1
- package/lib/typescript/src/helpers/treeNode.helper.d.ts +15 -0
- package/lib/typescript/src/helpers/treeNode.helper.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useDragDrop.d.ts +30 -7
- package/lib/typescript/src/hooks/useDragDrop.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useScrollToNode.d.ts +10 -0
- package/lib/typescript/src/hooks/useScrollToNode.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/store/treeView.store.d.ts +6 -0
- package/lib/typescript/src/store/treeView.store.d.ts.map +1 -1
- package/lib/typescript/src/types/dragDrop.types.d.ts +24 -12
- package/lib/typescript/src/types/dragDrop.types.d.ts.map +1 -1
- package/lib/typescript/src/types/treeView.types.d.ts +78 -12
- package/lib/typescript/src/types/treeView.types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/TreeView.tsx +158 -26
- package/src/components/DragOverlay.tsx +32 -3
- package/src/components/NodeList.tsx +84 -29
- package/src/constants/treeView.constants.ts +6 -1
- package/src/helpers/moveTreeNode.helper.ts +160 -43
- package/src/helpers/toggleCheckbox.helper.ts +6 -13
- package/src/helpers/treeNode.helper.ts +52 -1
- package/src/hooks/useDragDrop.ts +597 -250
- package/src/hooks/useScrollToNode.ts +22 -1
- package/src/index.tsx +5 -1
- package/src/store/treeView.store.ts +6 -0
- package/src/types/dragDrop.types.ts +25 -13
- package/src/types/treeView.types.ts +82 -11
- package/lib/module/components/DropIndicator.js +0 -79
- package/lib/module/components/DropIndicator.js.map +0 -1
- package/lib/typescript/src/components/DropIndicator.d.ts +0 -12
- package/lib/typescript/src/components/DropIndicator.d.ts.map +0 -1
- package/src/components/DropIndicator.tsx +0 -95
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Make sure to follow the native-related installation instructions for these depen
|
|
|
47
47
|
- 🔀 **Drag-and-Drop**: Long-press to drag nodes and reorder or nest them anywhere in the tree.
|
|
48
48
|
- 💻 **Cross-Platform**: Works seamlessly across iOS, Android, and web (with React Native Web).
|
|
49
49
|
|
|
50
|
-
> **Note**: Drag-and-drop is
|
|
50
|
+
> **Note**: Drag-and-drop is fully supported on iOS and Android. Web support is a work in progress, so drag-and-drop is **disabled by default on web** - pass `dragAndDrop={{ enabled: true }}` to opt in there.
|
|
51
51
|
|
|
52
52
|
## Usage
|
|
53
53
|
|
|
@@ -120,6 +120,7 @@ export function TreeViewUsageExample(){
|
|
|
120
120
|
```tsx
|
|
121
121
|
import {
|
|
122
122
|
TreeView,
|
|
123
|
+
moveTreeNode,
|
|
123
124
|
type TreeNode,
|
|
124
125
|
type TreeViewRef,
|
|
125
126
|
type DragEndEvent
|
|
@@ -132,8 +133,12 @@ export function DragDropExample(){
|
|
|
132
133
|
const treeViewRef = React.useRef<TreeViewRef | null>(null);
|
|
133
134
|
|
|
134
135
|
const handleDragEnd = (event: DragEndEvent) => {
|
|
135
|
-
// event
|
|
136
|
-
|
|
136
|
+
// `event` is a lightweight move delta (draggedNodeId, targetNodeId, position,
|
|
137
|
+
// previous/new parent + index) - not the whole tree. For a controlled tree,
|
|
138
|
+
// reconstruct it with the exported `moveTreeNode` helper:
|
|
139
|
+
setData(prev => moveTreeNode(prev, event.draggedNodeId, event.targetNodeId, event.position));
|
|
140
|
+
// Or, if you keep the tree inside the component, read it on demand:
|
|
141
|
+
// setData(treeViewRef.current?.getTreeData() ?? prev);
|
|
137
142
|
};
|
|
138
143
|
|
|
139
144
|
return(
|
|
@@ -152,7 +157,9 @@ export function DragDropExample(){
|
|
|
152
157
|
|
|
153
158
|
Long-press a node to start dragging. Drag over other nodes to see drop indicators. Drop above/below to reorder as siblings, or drop inside a parent node to nest it. The tree auto-scrolls when dragging near the edges.
|
|
154
159
|
|
|
155
|
-
**Search + drag**: Drag-and-drop
|
|
160
|
+
**Search + drag**: Drag-and-drop is disabled while a search filter is active (long-press does not initiate a drag). The filtered view hides nodes that still exist in the full tree, so a drop position that looks unambiguous on screen could land the node next to hidden siblings. Clear the search to reorder interactively, or use the imperative [`moveNode`](#treeviewrefid) ref method, which works regardless of the active filter.
|
|
161
|
+
|
|
162
|
+
**Accessibility**: When a screen reader is active, picking up, moving, and cancelling a drag are announced (via `AccessibilityInfo`). For a fully assistive-tech-driven reorder (without the long-press gesture), wire your own accessibility actions to the imperative [`moveNode`](#treeviewrefid) ref method.
|
|
156
163
|
|
|
157
164
|
For visual customizations (overlay styles, indicator colors, or fully custom components), see the [`dragAndDrop.customizations`](#dragdropcustomizationsid) option.
|
|
158
165
|
|
|
@@ -186,20 +193,24 @@ For visual customizations (overlay styles, indicator colors, or fully custom com
|
|
|
186
193
|
|
|
187
194
|
| Property | Type | Required | Description |
|
|
188
195
|
| --------------------- | ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
|
|
189
|
-
| `enabled` | `boolean` | No | Enable drag-and-drop reordering
|
|
196
|
+
| `enabled` | `boolean` | No | Enable drag-and-drop reordering. Default: `true` on iOS/Android when `dragAndDrop` is provided, `false` on web (WIP). Set explicitly to override per platform. |
|
|
190
197
|
| `onDragStart` | `(event: `[DragStartEvent](#dragstarteventid--string)`<ID>) => void` | No | Callback fired when a drag operation begins |
|
|
191
198
|
| `onDragEnd` | `(event: `[DragEndEvent](#dragendeventid--string)`<ID>) => void` | No | Callback fired after a node is successfully dropped at a new position |
|
|
192
199
|
| `onDragCancel` | `(event: `[DragCancelEvent](#dragcanceleventid--string)`<ID>) => void` | No | Callback fired when a drag is cancelled without a successful drop |
|
|
193
200
|
| `longPressDuration` | `number` | No | Long press duration in ms to start drag (default: 400) |
|
|
194
201
|
| `autoScrollThreshold` | `number` | No | Distance from edge (px) to trigger auto-scroll (default: 60) |
|
|
195
202
|
| `autoScrollSpeed` | `number` | No | Speed multiplier for auto-scroll (default: 1.0) |
|
|
196
|
-
| `dragOverlayOffset` | `number` | No | Overlay offset from the finger, in item-height units (default: -
|
|
203
|
+
| `dragOverlayOffset` | `number` | No | Overlay offset from the finger, in item-height units (default: -2, i.e. two rows above finger) |
|
|
204
|
+
| `overlayYCorrection` | `number` | No | Advanced: extra vertical correction for the overlay, in item-height units, added on top of `dragOverlayOffset`. Compensates for Android reporting touch `locationY` differently from iOS. Default: -2 on Android, 0 elsewhere. |
|
|
197
205
|
| `autoExpandDelay` | `number` | No | Delay in ms before auto-expanding a collapsed node during drag hover (default: 800) |
|
|
206
|
+
| `autoExpand` | `boolean` | No | Auto-expand a collapsed node while hovering "inside" it during a drag (default: `true`). Set `false` to disable hover-to-expand. |
|
|
207
|
+
| `magneticSnap` | `boolean` | No | Animate the overlay with a magnetic "snap" spring when the drop level changes (default: `true`). Set `false` to keep the overlay tracking the level without the spring (e.g. for reduced-motion). |
|
|
198
208
|
| `customizations` | [DragDropCustomizations](#dragdropcustomizationsid)`<ID>` | No | Customizations for drag-and-drop visuals (overlay, indicator, opacity) |
|
|
199
209
|
| `canDrop` | `(draggedNode, targetNode, position) => boolean` | No | Callback to determine if a node can be dropped on a specific target |
|
|
200
|
-
| `maxDepth` | `number` | No | Maximum nesting depth allowed. Drops
|
|
210
|
+
| `maxDepth` | `number` | No | Maximum nesting depth allowed, as a 0-based level index (e.g. `maxDepth: 2` permits levels 0, 1, and 2 - three visible depths). Drops that would exceed it are suppressed. |
|
|
201
211
|
| `canNodeHaveChildren` | `(node: TreeNode<ID>) => boolean` | No | Callback to determine if a node can accept children |
|
|
202
212
|
| `canDrag` | `(node: TreeNode<ID>) => boolean` | No | Callback to determine if a node can be dragged (default: all nodes) |
|
|
213
|
+
| `autoScrollToDroppedNode` | `boolean \| DropAutoScrollOptions` | No | Auto-scroll to the dropped node after a successful drop, if it ended up outside the viewport (no scroll happens when the node is already visible). Pass `false` to disable, `true` for defaults, or an object to customize. Default: `{ enabled: true, animated: true, viewPosition: 0.5 }` |
|
|
203
214
|
|
|
204
215
|
##### Notes
|
|
205
216
|
|
|
@@ -211,7 +222,7 @@ For visual customizations (overlay styles, indicator colors, or fully custom com
|
|
|
211
222
|
1. `BuiltInCheckBoxViewStyleProps`
|
|
212
223
|
1. `ExpandCollapseIconComponent`
|
|
213
224
|
1. `ExpandCollapseTouchableComponent`
|
|
214
|
-
1. `dragAndDrop.customizations.draggedNodeOpacity` / `invalidTargetOpacity`
|
|
225
|
+
1. `dragAndDrop.customizations.draggedNodeOpacity` / `invalidTargetOpacity` - the custom component receives `isDraggedNode`, `isInvalidDropTarget`, and `isDragging` props and is responsible for its own drag-state visuals.
|
|
215
226
|
|
|
216
227
|
- ⚠️ If the tree view doesn't scroll if rendered in a complex nested scroll view/s then try setting the `renderScrollComponent` value in `treeFlashListProps` to `ScrollView` from `react-native-gesture-handler`.
|
|
217
228
|
|
|
@@ -249,7 +260,8 @@ For visual customizations (overlay styles, indicator colors, or fully custom com
|
|
|
249
260
|
| `setSearchText` | `(searchText: string, searchKeys?: string[]) => void` | Set the search text and optionally the search keys. Default search key is "name"<br /><br />Recommended to call this inside a debounced function if you find any performance issue otherwise. |
|
|
250
261
|
| `scrollToNodeID` | `(params: `[ScrollToNodeParams](#scrolltonodeparams)`<ID>) => void;` | Scrolls the tree view to the node of the specified ID. |
|
|
251
262
|
| `getChildToParentMap` | `() => Map<ID, ID>` | Get the child to parent tree view map. |
|
|
252
|
-
| `
|
|
263
|
+
| `getTreeData` | `() => `[TreeNode](#treenodeid--string)`<ID>[]` | Get the current (live, reordered) tree data held by the component. Handy after a drag or `moveNode` to read the full tree without it being pushed through a move event. **Returns a live internal reference - treat it as read-only; clone it (e.g. via the exported `moveTreeNode` or `structuredClone`) before mutating, or you will desync the internal maps.** |
|
|
264
|
+
| `moveNode` | `(nodeId: ID, targetNodeId: ID, position: `[DropPosition](#dropposition)`, options?: { validate?: boolean; scrollToNode?: boolean \| DropAutoScrollOptions }) => `[MoveResult](#moveresultid--string)`<ID> \| null` | Programmatically move a node. Returns a lightweight `MoveResult` delta, or `null` if the move was a no-op / invalid (e.g. onto itself or, with `{ validate: true }`, blocked by `canDrop` / `maxDepth` / `canNodeHaveChildren`). `{ validate: true }` only enforces those rules when a `dragAndDrop` prop is configured (they live on it); without one, `validate` is ignored (a dev warning is logged) and the move proceeds. Pass `{ scrollToNode: true }` to scroll the moved node into view. Does **not** fire `onDragEnd`. Useful for undo/redo or external state management. |
|
|
253
265
|
|
|
254
266
|
#### ScrollToNodeParams
|
|
255
267
|
| Property | Type | Required | Description |
|
|
@@ -343,11 +355,11 @@ Type: `boolean` OR `"indeterminate"`
|
|
|
343
355
|
|
|
344
356
|
*Touch handlers to spread on a drag handle element within a custom node row.*
|
|
345
357
|
|
|
346
|
-
| Property | Type
|
|
347
|
-
| -------------- |
|
|
348
|
-
| `onTouchStart` | `(e:
|
|
349
|
-
| `onTouchEnd` | `() => void`
|
|
350
|
-
| `onTouchCancel`| `() => void`
|
|
358
|
+
| Property | Type | Required | Description |
|
|
359
|
+
| -------------- | ------------------------------------ | -------- | ------------------------------ |
|
|
360
|
+
| `onTouchStart` | `(e: GestureResponderEvent) => void` | Yes | Touch start handler for drag |
|
|
361
|
+
| `onTouchEnd` | `() => void` | Yes | Touch end handler |
|
|
362
|
+
| `onTouchCancel`| `() => void` | Yes | Touch cancel handler |
|
|
351
363
|
|
|
352
364
|
---
|
|
353
365
|
|
|
@@ -361,16 +373,25 @@ Type: `boolean` OR `"indeterminate"`
|
|
|
361
373
|
|
|
362
374
|
---
|
|
363
375
|
|
|
364
|
-
####
|
|
376
|
+
#### MoveResult`<ID = string>`
|
|
365
377
|
|
|
366
|
-
*
|
|
378
|
+
*A lightweight description of a completed move. Returned by the `moveNode` ref method and passed to the `onDragEnd` callback (i.e. `DragEndEvent` is an alias of `MoveResult`). It carries only the move delta - not a full tree copy - so you can update external state or persist the change cheaply. To get the full reordered tree, call the `getTreeData` ref method or reconstruct it with the exported `moveTreeNode` helper.*
|
|
367
379
|
|
|
368
|
-
| Property
|
|
369
|
-
|
|
|
370
|
-
| `draggedNodeId`
|
|
371
|
-
| `targetNodeId`
|
|
372
|
-
| `position`
|
|
373
|
-
| `
|
|
380
|
+
| Property | Type | Description |
|
|
381
|
+
| ------------------ | ----------------------------- | ------------------------------------------------------------ |
|
|
382
|
+
| `draggedNodeId` | `ID` | The id of the node that was moved |
|
|
383
|
+
| `targetNodeId` | `ID` | The id of the target node the move was relative to |
|
|
384
|
+
| `position` | [DropPosition](#dropposition) | Where relative to the target: `above`/`below` = sibling, `inside` = child |
|
|
385
|
+
| `previousParentId` | `ID \| null` | Parent id before the move (`null` if it was a root-level node) |
|
|
386
|
+
| `newParentId` | `ID \| null` | Parent id after the move (`null` if it is now a root-level node) |
|
|
387
|
+
| `previousIndex` | `number` | Index within the previous parent's children (or the root array) |
|
|
388
|
+
| `newIndex` | `number` | Index within the new parent's children (or the root array) |
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
#### DragEndEvent`<ID = string>`
|
|
393
|
+
|
|
394
|
+
*The event object passed to the `onDragEnd` callback after a successful drop. This is an alias of [`MoveResult`](#moveresultid--string)`<ID>` - see its fields above.*
|
|
374
395
|
|
|
375
396
|
#### DragCancelEvent`<ID = string>`
|
|
376
397
|
|
|
@@ -386,6 +407,19 @@ Type: `"above"` | `"below"` | `"inside"`
|
|
|
386
407
|
|
|
387
408
|
---
|
|
388
409
|
|
|
410
|
+
#### DropAutoScrollOptions
|
|
411
|
+
|
|
412
|
+
*Options for auto-scrolling to the dropped node after a successful drop. Uses the same scroll parameters as [`scrollToNodeID`](#scrolltonodeparams).*
|
|
413
|
+
|
|
414
|
+
| Property | Type | Required | Description |
|
|
415
|
+
| -------------- | --------- | -------- | --------------------------------------------------------------- |
|
|
416
|
+
| `enabled` | `boolean` | No | Enable auto-scroll to the dropped node (default: true) |
|
|
417
|
+
| `animated` | `boolean` | No | Whether the scroll should be animated (default: true) |
|
|
418
|
+
| `viewOffset` | `number` | No | Fixed offset from the target position (in pixels) |
|
|
419
|
+
| `viewPosition` | `number` | No | Position in the viewport: 0 = top, 0.5 = center, 1 = bottom (default: 0.5) |
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
389
423
|
#### DragDropCustomizations`<ID>`
|
|
390
424
|
|
|
391
425
|
*Customizations for drag-and-drop visuals.*
|
|
@@ -412,6 +446,8 @@ Type: `"above"` | `"below"` | `"inside"`
|
|
|
412
446
|
| `circleSize` | `number` | No | Diameter of the circle at the line's start (default: 10) |
|
|
413
447
|
| `highlightColor` | `string` | No | Background color of the "inside" highlight (default: `"rgba(0, 120, 255, 0.15)"`) |
|
|
414
448
|
| `highlightBorderColor`| `string` | No | Border color of the "inside" highlight (default: `"rgba(0, 120, 255, 0.5)"`) |
|
|
449
|
+
| `highlightBorderWidth`| `number` | No | Border width of the "inside" highlight box (default: 2) |
|
|
450
|
+
| `highlightBorderRadius`| `number`| No | Corner radius of the "inside" highlight box (default: 4) |
|
|
415
451
|
|
|
416
452
|
---
|
|
417
453
|
|
|
@@ -423,9 +459,11 @@ Type: `"above"` | `"below"` | `"inside"`
|
|
|
423
459
|
| --------------- | ---------------------- | -------- | ------------------------------------------------ |
|
|
424
460
|
| `backgroundColor`| `string` | No | Background color (default: `"rgba(255, 255, 255, 0.95)"`) |
|
|
425
461
|
| `shadowColor` | `string` | No | Shadow color (default: `"#000"`) |
|
|
462
|
+
| `shadowOffset` | `{ width: number; height: number }` | No | Shadow offset, iOS (default: `{ width: 0, height: 2 }`) |
|
|
426
463
|
| `shadowOpacity` | `number` | No | Shadow opacity (default: 0.25) |
|
|
427
464
|
| `shadowRadius` | `number` | No | Shadow radius (default: 4) |
|
|
428
465
|
| `elevation` | `number` | No | Android elevation (default: 10) |
|
|
466
|
+
| `zIndex` | `number` | No | Stacking order of the overlay (default: 9999) |
|
|
429
467
|
| `style` | `StyleProp<ViewStyle>` | No | Custom style applied to the overlay container |
|
|
430
468
|
|
|
431
469
|
---
|
|
@@ -504,14 +542,6 @@ MIT
|
|
|
504
542
|
## 🙏 Support the project
|
|
505
543
|
|
|
506
544
|
<p align="center" valign="center">
|
|
507
|
-
<a href="https://liberapay.com/FutureJJ/donate">
|
|
508
|
-
<img src="https://liberapay.com/assets/widgets/donate.svg" alt="LiberPay_Donation_Button" height="50" >
|
|
509
|
-
</a>
|
|
510
|
-
|
|
511
|
-
<a href=".github/assets/Jairaj_Jangle_Google_Pay_UPI_QR_Code.jpg">
|
|
512
|
-
<img src=".github/assets/upi.png" alt="Paypal_Donation_Button" height="50" >
|
|
513
|
-
</a>
|
|
514
|
-
|
|
515
545
|
<a href="https://www.paypal.com/paypalme/jairajjangle001/usd">
|
|
516
546
|
<img src=".github/assets/paypal_donate.png" alt="Paypal_Donation_Button" height="50" >
|
|
517
547
|
</a>
|
|
@@ -519,6 +549,10 @@ MIT
|
|
|
519
549
|
<a href="https://github.com/sponsors/JairajJangle">
|
|
520
550
|
<img src=".github/assets/github_sponsor.svg" alt="GitHub_Sponsor_Button" height="50" >
|
|
521
551
|
</a>
|
|
552
|
+
|
|
553
|
+
<a href="https://liberapay.com/FutureJJ/donate">
|
|
554
|
+
<img src=".github/assets/liberapay_donate.svg" alt="Liberapay_Donation_Button" height="50" >
|
|
555
|
+
</a>
|
|
522
556
|
</p>
|
|
523
557
|
|
|
524
558
|
|
package/lib/module/TreeView.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { forwardRef, startTransition, useCallback, useEffect, useId, useImperativeHandle, useRef } from "react";
|
|
3
|
+
import { forwardRef, startTransition, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef } from "react";
|
|
4
4
|
import NodeList from "./components/NodeList.js";
|
|
5
|
-
import { selectAll, selectAllFiltered, unselectAll, unselectAllFiltered, initializeNodeMaps, expandAll, collapseAll, toggleCheckboxes, expandNodes, collapseNodes,
|
|
5
|
+
import { selectAll, selectAllFiltered, unselectAll, unselectAllFiltered, initializeNodeMaps, expandAll, collapseAll, toggleCheckboxes, expandNodes, collapseNodes, moveTreeNode, applyMoveToStore, findNodePosition, findNodePositionFromMaps, getSubtreeDepthFromMap, getNodeDepthFromParentMap } from "./helpers/index.js";
|
|
6
6
|
import { deleteTreeViewStore, getTreeViewStore, useTreeViewStore } from "./store/treeView.store.js";
|
|
7
7
|
import usePreviousState from "./utils/usePreviousState.js";
|
|
8
8
|
import { useShallow } from "zustand/react/shallow";
|
|
9
9
|
import useDeepCompareEffect from "./utils/useDeepCompareEffect.js";
|
|
10
10
|
import { typedMemo } from "./utils/typedMemo.js";
|
|
11
|
+
import { scrollMovedNodeIntoView } from "./hooks/useScrollToNode.js";
|
|
11
12
|
import { fastIsEqual } from "fast-is-equal";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
function _innerTreeView(props, ref) {
|
|
@@ -41,7 +42,8 @@ function _innerTreeView(props, ref) {
|
|
|
41
42
|
checked,
|
|
42
43
|
indeterminate,
|
|
43
44
|
setSelectionPropagation,
|
|
44
|
-
cleanUpTreeViewStore
|
|
45
|
+
cleanUpTreeViewStore,
|
|
46
|
+
draggedNodeId
|
|
45
47
|
} = useTreeViewStore(storeId)(useShallow(state => ({
|
|
46
48
|
expanded: state.expanded,
|
|
47
49
|
updateExpanded: state.updateExpanded,
|
|
@@ -53,7 +55,8 @@ function _innerTreeView(props, ref) {
|
|
|
53
55
|
checked: state.checked,
|
|
54
56
|
indeterminate: state.indeterminate,
|
|
55
57
|
setSelectionPropagation: state.setSelectionPropagation,
|
|
56
|
-
cleanUpTreeViewStore: state.cleanUpTreeViewStore
|
|
58
|
+
cleanUpTreeViewStore: state.cleanUpTreeViewStore,
|
|
59
|
+
draggedNodeId: state.draggedNodeId
|
|
57
60
|
})));
|
|
58
61
|
useImperativeHandle(ref, () => ({
|
|
59
62
|
selectAll: () => selectAll(storeId),
|
|
@@ -69,35 +72,69 @@ function _innerTreeView(props, ref) {
|
|
|
69
72
|
setSearchText,
|
|
70
73
|
scrollToNodeID,
|
|
71
74
|
getChildToParentMap,
|
|
75
|
+
getTreeData,
|
|
72
76
|
moveNode
|
|
73
77
|
}));
|
|
74
78
|
const scrollToNodeHandlerRef = useRef(null);
|
|
75
79
|
const prevSearchText = usePreviousState(searchText);
|
|
76
80
|
const internalDataRef = useRef(null);
|
|
81
|
+
// Holds a `data` prop change that arrived mid-drag; applied once the drag ends so
|
|
82
|
+
// the destructive reinit never swaps the node maps out from under an active drag.
|
|
83
|
+
const pendingDataRef = useRef(null);
|
|
77
84
|
|
|
78
|
-
// Wrap onDragEnd to
|
|
85
|
+
// Wrap onDragEnd to capture the post-move tree before calling the consumer's
|
|
86
|
+
// callback. The reordered tree lives in the store (the event only carries the
|
|
87
|
+
// lightweight move delta); snapshotting it here lets a controlled consumer feed
|
|
88
|
+
// an equal tree back into `data` and skip re-initialization.
|
|
79
89
|
const wrappedOnDragEnd = useCallback(event => {
|
|
80
|
-
internalDataRef.current =
|
|
90
|
+
internalDataRef.current = getTreeViewStore(storeId).getState().initialTreeViewData;
|
|
91
|
+
// A `data` change deferred during this drag predates the move that just
|
|
92
|
+
// committed; applying it would silently undo the drop after onDragEnd
|
|
93
|
+
// already told the consumer it happened. Discard it - a controlled
|
|
94
|
+
// consumer reacts to onDragEnd with fresh data anyway.
|
|
95
|
+
pendingDataRef.current = null;
|
|
81
96
|
onDragEnd?.(event);
|
|
82
|
-
}, [onDragEnd]);
|
|
83
|
-
|
|
97
|
+
}, [onDragEnd, storeId]);
|
|
98
|
+
|
|
99
|
+
// Reinitialize the store from a tree. Held in a ref so the value stays stable
|
|
100
|
+
// (no dep churn) while always capturing the latest props/store actions.
|
|
101
|
+
const applyDataRef = useRef(() => {});
|
|
102
|
+
applyDataRef.current = nextData => {
|
|
84
103
|
// If data matches what was set internally from a drag-drop, skip reinitialize
|
|
85
|
-
if (internalDataRef.current !== null && fastIsEqual(
|
|
104
|
+
if (internalDataRef.current !== null && fastIsEqual(nextData, internalDataRef.current)) {
|
|
86
105
|
internalDataRef.current = null;
|
|
87
106
|
return;
|
|
88
107
|
}
|
|
89
108
|
internalDataRef.current = null;
|
|
90
109
|
cleanUpTreeViewStore();
|
|
91
|
-
updateInitialTreeViewData(
|
|
110
|
+
updateInitialTreeViewData(nextData);
|
|
92
111
|
if (selectionPropagation) setSelectionPropagation(selectionPropagation);
|
|
93
|
-
initializeNodeMaps(storeId,
|
|
112
|
+
initializeNodeMaps(storeId, nextData);
|
|
94
113
|
|
|
95
114
|
// Check any pre-selected nodes
|
|
96
115
|
toggleCheckboxes(storeId, preselectedIds, true);
|
|
97
116
|
|
|
98
117
|
// Expand pre-expanded nodes
|
|
99
118
|
expandNodes(storeId, [...preExpandedIds, ...(initialScrollNodeID ? [initialScrollNodeID] : [])]);
|
|
119
|
+
};
|
|
120
|
+
useDeepCompareEffect(() => {
|
|
121
|
+
// A reinit while a drag is in flight would replace nodeMap/childToParentMap
|
|
122
|
+
// under the drag's feet and corrupt the commit. Defer it until the drag ends.
|
|
123
|
+
if (getTreeViewStore(storeId).getState().draggedNodeId !== null) {
|
|
124
|
+
pendingDataRef.current = data;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
applyDataRef.current(data);
|
|
100
128
|
}, [data]);
|
|
129
|
+
|
|
130
|
+
// Apply any data change that was deferred during a drag, once the drag ends.
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (draggedNodeId === null && pendingDataRef.current !== null) {
|
|
133
|
+
const pending = pendingDataRef.current;
|
|
134
|
+
pendingDataRef.current = null;
|
|
135
|
+
applyDataRef.current(pending);
|
|
136
|
+
}
|
|
137
|
+
}, [draggedNodeId]);
|
|
101
138
|
function selectNodes(ids) {
|
|
102
139
|
toggleCheckboxes(storeId, ids, true);
|
|
103
140
|
}
|
|
@@ -115,18 +152,76 @@ function _innerTreeView(props, ref) {
|
|
|
115
152
|
const treeViewStore = getTreeViewStore(storeId);
|
|
116
153
|
return treeViewStore.getState().childToParentMap;
|
|
117
154
|
}
|
|
118
|
-
function
|
|
155
|
+
function getTreeData() {
|
|
156
|
+
return getTreeViewStore(storeId).getState().initialTreeViewData;
|
|
157
|
+
}
|
|
158
|
+
function moveNode(nodeId, targetNodeId, position, options) {
|
|
119
159
|
const store = getTreeViewStore(storeId);
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
160
|
+
const {
|
|
161
|
+
initialTreeViewData: currentData,
|
|
162
|
+
nodeMap,
|
|
163
|
+
childToParentMap
|
|
164
|
+
} = store.getState();
|
|
165
|
+
|
|
166
|
+
// A programmatic move during an in-flight drag would reinitialize
|
|
167
|
+
// nodeMap/childToParentMap under the drag's feet and corrupt the pending
|
|
168
|
+
// commit (same guard as the deferred data-prop reinit above).
|
|
169
|
+
if (store.getState().draggedNodeId !== null) {
|
|
170
|
+
if (__DEV__) {
|
|
171
|
+
console.warn("[react-native-tree-multi-select] moveNode() ignored: a drag is in progress.");
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Validation rules (canDrop / maxDepth / canNodeHaveChildren) live on the
|
|
177
|
+
// dragAndDrop prop, so `validate` only has rules to enforce when that prop is
|
|
178
|
+
// configured. Warn in dev if the caller asked to validate but nothing can.
|
|
179
|
+
if (__DEV__ && options?.validate && !(dragAndDrop?.canDrop || dragAndDrop?.maxDepth !== undefined || dragAndDrop?.canNodeHaveChildren)) {
|
|
180
|
+
console.warn("[react-native-tree-multi-select] moveNode({ validate: true }) was called, " + "but no validation rules are configured. canDrop / maxDepth / " + "canNodeHaveChildren are read from the `dragAndDrop` prop; without them the " + "move proceeds unvalidated.");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Optional validation mirrors the interactive drag constraints so a
|
|
184
|
+
// programmatic move can't silently build a tree the drag UI would reject.
|
|
185
|
+
if (options?.validate && dragAndDrop) {
|
|
186
|
+
const draggedNode = nodeMap.get(nodeId);
|
|
187
|
+
const targetNode = nodeMap.get(targetNodeId);
|
|
188
|
+
if (!draggedNode || !targetNode) return null;
|
|
189
|
+
if (position === "inside" && dragAndDrop.canNodeHaveChildren && !dragAndDrop.canNodeHaveChildren(targetNode)) return null;
|
|
190
|
+
if (dragAndDrop.canDrop && !dragAndDrop.canDrop(draggedNode, targetNode, position)) return null;
|
|
191
|
+
if (dragAndDrop.maxDepth !== undefined) {
|
|
192
|
+
const targetLevel = getNodeDepthFromParentMap(childToParentMap, targetNodeId);
|
|
193
|
+
const subtreeDepth = getSubtreeDepthFromMap(nodeMap, nodeId);
|
|
194
|
+
const baseLevel = position === "inside" ? targetLevel + 1 : targetLevel;
|
|
195
|
+
if (baseLevel + subtreeDepth > dragAndDrop.maxDepth) return null;
|
|
196
|
+
}
|
|
127
197
|
}
|
|
128
|
-
|
|
198
|
+
|
|
199
|
+
// The maps still describe the pre-move tree here, so the O(depth) lookup applies.
|
|
200
|
+
const previousPosition = findNodePositionFromMaps(currentData, nodeMap, childToParentMap, nodeId);
|
|
201
|
+
const newData = moveTreeNode(currentData, nodeId, targetNodeId, position);
|
|
202
|
+
// moveTreeNode returns the original array reference on a no-op / invalid move
|
|
203
|
+
// (same node, dropping into own descendant, or node/target not found).
|
|
204
|
+
if (newData === currentData) return null;
|
|
205
|
+
|
|
206
|
+
// Same commit pipeline as the interactive drag path.
|
|
207
|
+
applyMoveToStore(storeId, newData, nodeId, targetNodeId, position);
|
|
129
208
|
internalDataRef.current = newData;
|
|
209
|
+
|
|
210
|
+
// Optionally scroll the moved node into view (the interactive drag does this
|
|
211
|
+
// automatically; programmatic moves opt in). Deferred so the expand/render settles.
|
|
212
|
+
if (options?.scrollToNode) {
|
|
213
|
+
scrollMovedNodeIntoView(scrollToNodeHandlerRef, nodeId, options.scrollToNode);
|
|
214
|
+
}
|
|
215
|
+
const newPosition = findNodePosition(newData, nodeId);
|
|
216
|
+
return {
|
|
217
|
+
draggedNodeId: nodeId,
|
|
218
|
+
targetNodeId,
|
|
219
|
+
position,
|
|
220
|
+
previousParentId: previousPosition?.parentId ?? null,
|
|
221
|
+
previousIndex: previousPosition?.index ?? -1,
|
|
222
|
+
newParentId: newPosition?.parentId ?? null,
|
|
223
|
+
newIndex: newPosition?.index ?? -1
|
|
224
|
+
};
|
|
130
225
|
}
|
|
131
226
|
const getIds = useCallback(node => {
|
|
132
227
|
if (!node.children || node.children.length === 0) {
|
|
@@ -160,6 +255,20 @@ function _innerTreeView(props, ref) {
|
|
|
160
255
|
deleteTreeViewStore(storeId);
|
|
161
256
|
};
|
|
162
257
|
}, [cleanUpTreeViewStore, storeId]);
|
|
258
|
+
|
|
259
|
+
// Consumers routinely pass `dragAndDrop` as an inline object literal, so its
|
|
260
|
+
// identity changes every render even when nothing differs. Stabilize by deep
|
|
261
|
+
// equality (callbacks compare by reference) so NodeList's memo - and with it
|
|
262
|
+
// the drag overlay - isn't churned by unrelated re-renders mid-drag.
|
|
263
|
+
const stableDragAndDropRef = useRef(dragAndDrop);
|
|
264
|
+
if (!fastIsEqual(stableDragAndDropRef.current, dragAndDrop)) {
|
|
265
|
+
stableDragAndDropRef.current = dragAndDrop;
|
|
266
|
+
}
|
|
267
|
+
const stableDragAndDrop = stableDragAndDropRef.current;
|
|
268
|
+
const dragAndDropWithWrappedEnd = useMemo(() => stableDragAndDrop && {
|
|
269
|
+
...stableDragAndDrop,
|
|
270
|
+
onDragEnd: wrappedOnDragEnd
|
|
271
|
+
}, [stableDragAndDrop, wrappedOnDragEnd]);
|
|
163
272
|
return /*#__PURE__*/_jsx(NodeList, {
|
|
164
273
|
storeId: storeId,
|
|
165
274
|
scrollToNodeHandlerRef: scrollToNodeHandlerRef,
|
|
@@ -171,10 +280,7 @@ function _innerTreeView(props, ref) {
|
|
|
171
280
|
ExpandCollapseIconComponent: ExpandCollapseIconComponent,
|
|
172
281
|
ExpandCollapseTouchableComponent: ExpandCollapseTouchableComponent,
|
|
173
282
|
CustomNodeRowComponent: CustomNodeRowComponent,
|
|
174
|
-
dragAndDrop:
|
|
175
|
-
...dragAndDrop,
|
|
176
|
-
onDragEnd: wrappedOnDragEnd
|
|
177
|
-
}
|
|
283
|
+
dragAndDrop: dragAndDropWithWrappedEnd
|
|
178
284
|
});
|
|
179
285
|
}
|
|
180
286
|
const _TreeView = /*#__PURE__*/forwardRef(_innerTreeView);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","startTransition","useCallback","useEffect","useId","useImperativeHandle","useRef","NodeList","selectAll","selectAllFiltered","unselectAll","unselectAllFiltered","initializeNodeMaps","expandAll","collapseAll","toggleCheckboxes","expandNodes","collapseNodes","recalculateCheckedStates","moveTreeNode","deleteTreeViewStore","getTreeViewStore","useTreeViewStore","usePreviousState","useShallow","useDeepCompareEffect","typedMemo","fastIsEqual","jsx","_jsx","_innerTreeView","props","ref","data","onCheck","onExpand","selectionPropagation","preselectedIds","preExpandedIds","initialScrollNodeID","treeFlashListProps","checkBoxViewStyleProps","indentationMultiplier","CheckboxComponent","ExpandCollapseIconComponent","ExpandCollapseTouchableComponent","CustomNodeRowComponent","dragAndDrop","onDragEnd","storeId","expanded","updateExpanded","initialTreeViewData","updateInitialTreeViewData","searchText","updateSearchText","updateSearchKeys","checked","indeterminate","setSelectionPropagation","cleanUpTreeViewStore","state","ids","selectNodes","unselectNodes","setSearchText","scrollToNodeID","getChildToParentMap","moveNode","scrollToNodeHandlerRef","prevSearchText","internalDataRef","wrappedOnDragEnd","event","current","newTreeData","text","keys","params","treeViewStore","getState","childToParentMap","nodeId","targetNodeId","position","store","currentData","newData","getIds","node","children","length","id","flatMap","item","Array","from","Set","_TreeView","TreeView"],"sourceRoot":"../../src","sources":["TreeView.tsx"],"mappings":";;AAAA,SACCA,UAAU,EACVC,eAAe,EACfC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,mBAAmB,EACnBC,MAAM,QAEA,OAAO;AAMd,OAAOC,QAAQ,MAAM,0BAAuB;AAC5C,SACCC,SAAS,EACTC,iBAAiB,EACjBC,WAAW,EACXC,mBAAmB,EACnBC,kBAAkB,EAClBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,aAAa,EACbC,wBAAwB,EACxBC,YAAY,QACN,oBAAW;AAClB,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,gBAA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,EAAEA,2BAA4B;IACzDC,gCAAgC,EAAEA,gCAAiC;IAEnEC,sBAAsB,EAAEA,sBAAuB;IAE/CC,WAAW,EAAEA,WAAW,IAAI;MAC3B,GAAGA,WAAW;MACdC,SAAS,EAAEwB;IACZ;EAAE,CACF,CAAC;AAEJ;AAEA,MAAM0B,SAAS,gBAAGlG,UAAU,CAAC8B,cAAc,CAEL;AAEtC,OAAO,MAAMqE,QAAQ,GAAGzE,SAAS,CAAmBwE,SAAS,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["forwardRef","startTransition","useCallback","useEffect","useId","useImperativeHandle","useMemo","useRef","NodeList","selectAll","selectAllFiltered","unselectAll","unselectAllFiltered","initializeNodeMaps","expandAll","collapseAll","toggleCheckboxes","expandNodes","collapseNodes","moveTreeNode","applyMoveToStore","findNodePosition","findNodePositionFromMaps","getSubtreeDepthFromMap","getNodeDepthFromParentMap","deleteTreeViewStore","getTreeViewStore","useTreeViewStore","usePreviousState","useShallow","useDeepCompareEffect","typedMemo","scrollMovedNodeIntoView","fastIsEqual","jsx","_jsx","_innerTreeView","props","ref","data","onCheck","onExpand","selectionPropagation","preselectedIds","preExpandedIds","initialScrollNodeID","treeFlashListProps","checkBoxViewStyleProps","indentationMultiplier","CheckboxComponent","ExpandCollapseIconComponent","ExpandCollapseTouchableComponent","CustomNodeRowComponent","dragAndDrop","onDragEnd","storeId","expanded","updateExpanded","initialTreeViewData","updateInitialTreeViewData","searchText","updateSearchText","updateSearchKeys","checked","indeterminate","setSelectionPropagation","cleanUpTreeViewStore","draggedNodeId","state","ids","selectNodes","unselectNodes","setSearchText","scrollToNodeID","getChildToParentMap","getTreeData","moveNode","scrollToNodeHandlerRef","prevSearchText","internalDataRef","pendingDataRef","wrappedOnDragEnd","event","current","getState","applyDataRef","nextData","pending","text","keys","params","treeViewStore","childToParentMap","nodeId","targetNodeId","position","options","store","currentData","nodeMap","__DEV__","console","warn","validate","canDrop","maxDepth","undefined","canNodeHaveChildren","draggedNode","get","targetNode","targetLevel","subtreeDepth","baseLevel","previousPosition","newData","scrollToNode","newPosition","previousParentId","parentId","previousIndex","index","newParentId","newIndex","getIds","node","children","length","id","flatMap","item","Array","from","Set","stableDragAndDropRef","stableDragAndDrop","dragAndDropWithWrappedEnd","_TreeView","TreeView"],"sourceRoot":"../../src","sources":["TreeView.tsx"],"mappings":";;AAAA,SACCA,UAAU,EACVC,eAAe,EACfC,WAAW,EACXC,SAAS,EACTC,KAAK,EACLC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QAEA,OAAO;AAOd,OAAOC,QAAQ,MAAM,0BAAuB;AAC5C,SACCC,SAAS,EACTC,iBAAiB,EACjBC,WAAW,EACXC,mBAAmB,EACnBC,kBAAkB,EAClBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,WAAW,EACXC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,gBAAgB,EAChBC,wBAAwB,EACxBC,sBAAsB,EACtBC,yBAAyB,QACnB,oBAAW;AAClB,SAASC,mBAAmB,EAAEC,gBAAgB,EAAEC,gBAAgB,QAAQ,2BAAwB;AAChG,OAAOC,gBAAgB,MAAM,6BAA0B;AACvD,SAASC,UAAU,QAAQ,uBAAuB;AAClD,OAAOC,oBAAoB,MAAM,iCAA8B;AAC/D,SAASC,SAAS,QAAQ,sBAAmB;AAC7C,SACCC,uBAAuB,QAGjB,4BAAyB;AAEhC,SAASC,WAAW,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE5C,SAASC,cAAcA,CACtBC,KAAwB,EACxBC,GAAkC,EACjC;EACD,MAAM;IACLC,IAAI;IAEJC,OAAO;IACPC,QAAQ;IAERC,oBAAoB;IAEpBC,cAAc,GAAG,EAAE;IAEnBC,cAAc,GAAG,EAAE;IAEnBC,mBAAmB;IAEnBC,kBAAkB;IAClBC,sBAAsB;IACtBC,qBAAqB;IAErBC,iBAAiB;IACjBC,2BAA2B;IAC3BC,gCAAgC;IAEhCC,sBA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;IAC1B,GAAGA,iBAAiB;IACpBjF,SAAS,EAAE2B;EACZ,CAAC,EACD,CAACsD,iBAAiB,EAAEtD,gBAAgB,CACrC,CAAC;EAED,oBACC9C,IAAA,CAAC3B,QAAQ;IACR+C,OAAO,EAAEA,OAAQ;IAEjBsB,sBAAsB,EAAEA,sBAAuB;IAC/ChC,mBAAmB,EAAEA,mBAAoB;IAEzCC,kBAAkB,EAAEA,kBAAmB;IACvCC,sBAAsB,EAAEA,sBAAuB;IAC/CC,qBAAqB,EAAEA,qBAAsB;IAE7CC,iBAAiB,EAAEA,iBAAkB;IACrCC,2BAA2B,EAAEA,2BAA4B;IACzDC,gCAAgC,EAAEA,gCAAiC;IAEnEC,sBAAsB,EAAEA,sBAAuB;IAE/CC,WAAW,EAAEmF;EAA0B,CACvC,CAAC;AAEJ;AAEA,MAAMC,SAAS,gBAAGzI,UAAU,CAACoC,cAAc,CAEL;AAEtC,OAAO,MAAMsG,QAAQ,GAAG3G,SAAS,CAAmB0G,SAAS,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { memo } from "react";
|
|
3
4
|
import { Animated, StyleSheet, View } from "react-native";
|
|
5
|
+
import { fastIsEqual } from "fast-is-equal";
|
|
4
6
|
import { CheckboxView } from "./CheckboxView.js";
|
|
5
7
|
import { CustomExpandCollapseIcon } from "./CustomExpandCollapseIcon.js";
|
|
6
8
|
import { defaultIndentationMultiplier } from "../constants/treeView.constants.js";
|
|
7
9
|
import { getTreeViewStore } from "../store/treeView.store.js";
|
|
8
10
|
import { getCheckboxValue } from "../helpers/index.js";
|
|
9
|
-
import { typedMemo } from "../utils/typedMemo.js";
|
|
10
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
12
|
function _DragOverlay(props) {
|
|
12
13
|
const {
|
|
@@ -41,6 +42,9 @@ function _DragOverlay(props) {
|
|
|
41
42
|
...(overlayStyleProps.shadowColor != null && {
|
|
42
43
|
shadowColor: overlayStyleProps.shadowColor
|
|
43
44
|
}),
|
|
45
|
+
...(overlayStyleProps.shadowOffset != null && {
|
|
46
|
+
shadowOffset: overlayStyleProps.shadowOffset
|
|
47
|
+
}),
|
|
44
48
|
...(overlayStyleProps.shadowOpacity != null && {
|
|
45
49
|
shadowOpacity: overlayStyleProps.shadowOpacity
|
|
46
50
|
}),
|
|
@@ -49,6 +53,9 @@ function _DragOverlay(props) {
|
|
|
49
53
|
}),
|
|
50
54
|
...(overlayStyleProps.elevation != null && {
|
|
51
55
|
elevation: overlayStyleProps.elevation
|
|
56
|
+
}),
|
|
57
|
+
...(overlayStyleProps.zIndex != null && {
|
|
58
|
+
zIndex: overlayStyleProps.zIndex
|
|
52
59
|
})
|
|
53
60
|
}, overlayStyleProps?.style, {
|
|
54
61
|
transform: [{
|
|
@@ -86,7 +93,17 @@ function _DragOverlay(props) {
|
|
|
86
93
|
})
|
|
87
94
|
});
|
|
88
95
|
}
|
|
89
|
-
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Re-rendering the overlay mid-drag makes React Native re-bind the Animated
|
|
99
|
+
* transform, which can flash the overlay at its un-translated position for a
|
|
100
|
+
* frame (visible when e.g. auto-expand re-renders the tree while dragging).
|
|
101
|
+
* Nothing the overlay renders can change mid-drag, so block re-renders unless
|
|
102
|
+
* a prop meaningfully differs - style/customization objects are compared by
|
|
103
|
+
* value because consumers routinely pass fresh (but equal) literals per render.
|
|
104
|
+
*/
|
|
105
|
+
const overlayPropsAreEqual = (prev, next) => prev.storeId === next.storeId && prev.overlayY === next.overlayY && prev.overlayX === next.overlayX && prev.node === next.node && prev.level === next.level && prev.indentationMultiplier === next.indentationMultiplier && prev.CheckboxComponent === next.CheckboxComponent && prev.ExpandCollapseIconComponent === next.ExpandCollapseIconComponent && prev.CustomNodeRowComponent === next.CustomNodeRowComponent && fastIsEqual(prev.checkBoxViewStyleProps, next.checkBoxViewStyleProps) && fastIsEqual(prev.dragDropCustomizations, next.dragDropCustomizations);
|
|
106
|
+
export const DragOverlay = /*#__PURE__*/memo(_DragOverlay, overlayPropsAreEqual);
|
|
90
107
|
const styles = StyleSheet.create({
|
|
91
108
|
overlay: {
|
|
92
109
|
position: "absolute",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Animated","StyleSheet","View","CheckboxView","CustomExpandCollapseIcon","defaultIndentationMultiplier","getTreeViewStore","getCheckboxValue","
|
|
1
|
+
{"version":3,"names":["memo","Animated","StyleSheet","View","fastIsEqual","CheckboxView","CustomExpandCollapseIcon","defaultIndentationMultiplier","getTreeViewStore","getCheckboxValue","jsx","_jsx","jsxs","_jsxs","_DragOverlay","props","storeId","overlayY","overlayX","node","level","indentationMultiplier","CheckboxComponent","ExpandCollapseIconComponent","CustomNodeRowComponent","checkBoxViewStyleProps","dragDropCustomizations","store","checked","indeterminate","getState","checkedValue","has","id","overlayStyleProps","dragOverlayStyleProps","CustomOverlay","CustomDragOverlayComponent","pointerEvents","style","styles","overlay","backgroundColor","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation","zIndex","transform","translateX","translateY","children","isExpanded","onCheck","onExpand","nodeRow","paddingStart","text","name","onValueChange","value","length","expandArrow","overlayPropsAreEqual","prev","next","DragOverlay","create","position","left","right","width","height","flex","flexDirection","alignItems","minWidth"],"sourceRoot":"../../../src","sources":["components/DragOverlay.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAA4B,OAAO;AAChD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACzD,SAASC,WAAW,QAAQ,eAAe;AAQ3C,SAASC,YAAY,QAAQ,mBAAgB;AAC7C,SAASC,wBAAwB,QAAQ,+BAA4B;AACrE,SAASC,4BAA4B,QAAQ,oCAAiC;AAC9E,SAASC,gBAAgB,QAAQ,4BAAyB;AAC1D,SAASC,gBAAgB,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,I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