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
|
@@ -62,6 +62,27 @@ export interface ScrollToNodeHandlerRef<ID> {
|
|
|
62
62
|
scrollToNodeID: (params: ScrollToNodeParams<ID>) => void;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Scroll a just-moved node into view with the `DropAutoScrollOptions` defaults
|
|
67
|
+
* (animated, centered). Deferred a tick so the post-move expand/render settles
|
|
68
|
+
* first. Shared by the interactive drop path and the programmatic `moveNode`.
|
|
69
|
+
*/
|
|
70
|
+
export function scrollMovedNodeIntoView<ID>(
|
|
71
|
+
scrollToNodeHandlerRef: RefObject<ScrollToNodeHandlerRef<ID> | null>,
|
|
72
|
+
nodeId: ID,
|
|
73
|
+
options: boolean | { animated?: boolean; viewPosition?: number; viewOffset?: number; } | undefined
|
|
74
|
+
): void {
|
|
75
|
+
const custom = typeof options === "object" ? options : {};
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
scrollToNodeHandlerRef.current?.scrollToNodeID({
|
|
78
|
+
nodeId,
|
|
79
|
+
animated: custom.animated ?? true,
|
|
80
|
+
viewPosition: custom.viewPosition ?? 0.5,
|
|
81
|
+
viewOffset: custom.viewOffset,
|
|
82
|
+
});
|
|
83
|
+
}, 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
65
86
|
// Enum representing the two milestones needed before scrolling
|
|
66
87
|
enum ExpandQueueAction {
|
|
67
88
|
EXPANDED,
|
|
@@ -155,7 +176,7 @@ export function useScrollToNode<ID>(params: UseScrollToNodeParams<ID>) {
|
|
|
155
176
|
}
|
|
156
177
|
|
|
157
178
|
// Ensure if the parent is expanded before proceeding to scroll to the node.
|
|
158
|
-
// This fires transiently during the milestone system
|
|
179
|
+
// This fires transiently during the milestone system - the layout effect runs
|
|
159
180
|
// before the expansion has propagated to the store, then retries on next render.
|
|
160
181
|
/* istanbul ignore next -- async timing guard: expansion not yet propagated to store */
|
|
161
182
|
if (parentId && !expanded.has(parentId))
|
package/src/index.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
BuiltInCheckBoxViewStyleProps,
|
|
11
11
|
SelectionPropagation,
|
|
12
12
|
DragAndDropOptions,
|
|
13
|
+
DropAutoScrollOptions,
|
|
13
14
|
DragDropCustomizations,
|
|
14
15
|
DragOverlayStyleProps,
|
|
15
16
|
DragOverlayComponentProps,
|
|
@@ -21,7 +22,8 @@ import type {
|
|
|
21
22
|
DragCancelEvent,
|
|
22
23
|
DragEndEvent,
|
|
23
24
|
DragStartEvent,
|
|
24
|
-
DropPosition
|
|
25
|
+
DropPosition,
|
|
26
|
+
MoveResult
|
|
25
27
|
} from "./types/dragDrop.types";
|
|
26
28
|
|
|
27
29
|
export * from "./TreeView";
|
|
@@ -41,10 +43,12 @@ export type {
|
|
|
41
43
|
BuiltInCheckBoxViewStyleProps,
|
|
42
44
|
SelectionPropagation,
|
|
43
45
|
DragAndDropOptions,
|
|
46
|
+
DropAutoScrollOptions,
|
|
44
47
|
DragCancelEvent,
|
|
45
48
|
DragEndEvent,
|
|
46
49
|
DragStartEvent,
|
|
47
50
|
DropPosition,
|
|
51
|
+
MoveResult,
|
|
48
52
|
DragDropCustomizations,
|
|
49
53
|
DragOverlayStyleProps,
|
|
50
54
|
DragOverlayComponentProps,
|
|
@@ -158,6 +158,12 @@ export function deleteTreeViewStore(id: string) {
|
|
|
158
158
|
treeViewStores.delete(id);
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Returns the per-instance bound Zustand store for the given id. The returned
|
|
163
|
+
* store is itself callable as a hook with a selector - e.g.
|
|
164
|
+
* `useTreeViewStore(id)(useShallow(state => ...))` - which is why it keeps the
|
|
165
|
+
* `use` prefix. Internal helper; not part of the public API.
|
|
166
|
+
*/
|
|
161
167
|
export function useTreeViewStore<ID = string>(id: string) {
|
|
162
168
|
return getTreeViewStore<ID>(id);
|
|
163
169
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { TreeNode } from "./treeView.types";
|
|
2
|
-
|
|
3
1
|
/** Where a node is dropped relative to the target: as a sibling above/below, or as a child inside */
|
|
4
2
|
export type DropPosition = "above" | "below" | "inside";
|
|
5
3
|
|
|
@@ -15,19 +13,37 @@ export interface DragCancelEvent<ID = string> {
|
|
|
15
13
|
draggedNodeId: ID;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Lightweight description of a completed move. Returned by the imperative
|
|
18
|
+
* `moveNode` ref method and delivered to the `onDragEnd` callback. It carries
|
|
19
|
+
* only the delta (ids, position, and the moved node's previous/new parent and
|
|
20
|
+
* index) so a consumer can update external state or persist the change without
|
|
21
|
+
* handling a full tree copy. To get the full reordered tree, use the
|
|
22
|
+
* `getTreeData` ref method or reconstruct it with the exported `moveTreeNode`.
|
|
23
|
+
*/
|
|
24
|
+
export interface MoveResult<ID = string> {
|
|
25
|
+
/** The id of the node that was moved */
|
|
21
26
|
draggedNodeId: ID;
|
|
22
|
-
/** The id of the target node
|
|
27
|
+
/** The id of the target node the move was relative to */
|
|
23
28
|
targetNodeId: ID;
|
|
24
29
|
/** Where relative to the target: above/below = sibling, inside = child */
|
|
25
30
|
position: DropPosition;
|
|
26
|
-
/**
|
|
27
|
-
|
|
31
|
+
/** Parent id before the move (null if it was a root-level node) */
|
|
32
|
+
previousParentId: ID | null;
|
|
33
|
+
/** Parent id after the move (null if it is now a root-level node) */
|
|
34
|
+
newParentId: ID | null;
|
|
35
|
+
/** Index within the previous parent's children (or the root array) */
|
|
36
|
+
previousIndex: number;
|
|
37
|
+
/** Index within the new parent's children (or the root array) */
|
|
38
|
+
newIndex: number;
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
/**
|
|
41
|
+
/** Event payload passed to the onDragEnd callback after a successful drop. */
|
|
42
|
+
export type DragEndEvent<ID = string> = MoveResult<ID>;
|
|
43
|
+
|
|
44
|
+
/** Internal representation of the current drop target during a drag operation.
|
|
45
|
+
* Held in a ref and read at commit time; the per-node visual indicator is driven
|
|
46
|
+
* separately by the store (dropTargetNodeId / dropPosition / dropLevel). */
|
|
31
47
|
export interface DropTarget<ID = string> {
|
|
32
48
|
/** The id of the node being hovered over */
|
|
33
49
|
targetNodeId: ID;
|
|
@@ -37,8 +53,4 @@ export interface DropTarget<ID = string> {
|
|
|
37
53
|
position: DropPosition;
|
|
38
54
|
/** Whether this is a valid drop location (e.g. not dropping a node onto itself or its descendants) */
|
|
39
55
|
isValid: boolean;
|
|
40
|
-
/** Nesting level of the target node */
|
|
41
|
-
targetLevel: number;
|
|
42
|
-
/** Y-coordinate for positioning the drop indicator */
|
|
43
|
-
indicatorTop: number;
|
|
44
56
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentType, RefObject } from "react";
|
|
2
2
|
import type {
|
|
3
|
+
GestureResponderEvent,
|
|
3
4
|
StyleProp,
|
|
4
5
|
TextProps,
|
|
5
6
|
TouchableOpacityProps,
|
|
@@ -13,7 +14,7 @@ import type {
|
|
|
13
14
|
import type {
|
|
14
15
|
CheckboxProps as _CheckboxProps
|
|
15
16
|
} from "@futurejj/react-native-checkbox";
|
|
16
|
-
import type { DragCancelEvent, DragEndEvent, DragStartEvent, DropPosition } from "./dragDrop.types";
|
|
17
|
+
import type { DragCancelEvent, DragEndEvent, DragStartEvent, DropPosition, MoveResult } from "./dragDrop.types";
|
|
17
18
|
|
|
18
19
|
/** The tri-state value of a checkbox: checked, unchecked, or indeterminate */
|
|
19
20
|
export type CheckboxValueType = boolean | "indeterminate";
|
|
@@ -85,13 +86,17 @@ export interface NodeRowProps<ID = string> {
|
|
|
85
86
|
|
|
86
87
|
/** Touch handlers to spread on a drag handle element within a custom node row */
|
|
87
88
|
export interface DragHandleProps {
|
|
88
|
-
|
|
89
|
+
/** Arms the long-press timer that initiates a drag. Fires on finger down. */
|
|
90
|
+
onTouchStart: (e: GestureResponderEvent) => void;
|
|
91
|
+
/** Cancels a pending long-press, or ends a drag the PanResponder never
|
|
92
|
+
* captured (finger lifted without movement). Fires on finger up. */
|
|
89
93
|
onTouchEnd: () => void;
|
|
94
|
+
/** Cancels a pending long-press when the system interrupts the touch. */
|
|
90
95
|
onTouchCancel: () => void;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
/** Customization options for tree item appearance and behavior */
|
|
94
|
-
export interface TreeItemCustomizations<ID> {
|
|
99
|
+
export interface TreeItemCustomizations<ID = string> {
|
|
95
100
|
/** Style props for the built-in checkbox view */
|
|
96
101
|
checkBoxViewStyleProps?: BuiltInCheckBoxViewStyleProps;
|
|
97
102
|
|
|
@@ -110,7 +115,7 @@ export interface TreeItemCustomizations<ID> {
|
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
/** Internal props for a single node in the list (extends TreeItemCustomizations) */
|
|
113
|
-
export interface NodeProps<ID> extends TreeItemCustomizations<ID> {
|
|
118
|
+
export interface NodeProps<ID = string> extends TreeItemCustomizations<ID> {
|
|
114
119
|
/** The flattened tree node data */
|
|
115
120
|
node: __FlattenedTreeNode__<ID>;
|
|
116
121
|
/** Nesting depth of this node */
|
|
@@ -133,12 +138,20 @@ export interface NodeProps<ID> extends TreeItemCustomizations<ID> {
|
|
|
133
138
|
) => void;
|
|
134
139
|
/** Callback when a touch ends on this node */
|
|
135
140
|
onNodeTouchEnd?: () => void;
|
|
136
|
-
/** Callback reporting this node's measured height
|
|
137
|
-
|
|
141
|
+
/** Callback reporting this node's measured height, keyed by its stable node id
|
|
142
|
+
* (used for accurate variable-height drop targeting) */
|
|
143
|
+
onItemLayout?: (id: ID, height: number) => void;
|
|
138
144
|
/** Customizations for drag-and-drop visuals */
|
|
139
145
|
dragDropCustomizations?: DragDropCustomizations<ID>;
|
|
140
146
|
}
|
|
141
147
|
|
|
148
|
+
/** Options for auto-scrolling to the dropped node after a successful drop.
|
|
149
|
+
* Uses the same scroll parameters as `scrollToNodeID` (minus internally managed fields). */
|
|
150
|
+
export interface DropAutoScrollOptions extends Omit<ScrollToNodeParams<never>, "nodeId" | "expandScrolledNode"> {
|
|
151
|
+
/** Enable auto-scroll to the dropped node. Default: true */
|
|
152
|
+
enabled?: boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
142
155
|
/** Configuration options for drag-and-drop reordering */
|
|
143
156
|
export interface DragAndDropOptions<ID = string> {
|
|
144
157
|
/** Enable drag-and-drop reordering. Default: true (when dragAndDrop is provided) */
|
|
@@ -155,10 +168,22 @@ export interface DragAndDropOptions<ID = string> {
|
|
|
155
168
|
autoScrollThreshold?: number;
|
|
156
169
|
/** Speed multiplier for auto-scroll during drag. Default: 1.0 */
|
|
157
170
|
autoScrollSpeed?: number;
|
|
158
|
-
/** Offset of the dragged overlay from the finger, in item-height units. Default: -
|
|
171
|
+
/** Offset of the dragged overlay from the finger, in item-height units. Default: -2 (two items above finger) */
|
|
159
172
|
dragOverlayOffset?: number;
|
|
173
|
+
/** Advanced: extra vertical correction for the drag overlay, in item-height units,
|
|
174
|
+
* added on top of `dragOverlayOffset`. Compensates for Android reporting touch
|
|
175
|
+
* `locationY` differently from iOS. Default: -2 on Android, 0 on other platforms.
|
|
176
|
+
* Override only if the overlay sits noticeably off from the finger on a device. */
|
|
177
|
+
overlayYCorrection?: number;
|
|
160
178
|
/** Delay in ms before auto-expanding a collapsed node during drag hover. Default: 800 */
|
|
161
179
|
autoExpandDelay?: number;
|
|
180
|
+
/** Auto-expand a collapsed node while hovering "inside" it during a drag.
|
|
181
|
+
* Default: true. Set false to disable hover-to-expand entirely. */
|
|
182
|
+
autoExpand?: boolean;
|
|
183
|
+
/** Animate the drag overlay with a magnetic "snap" spring when the effective drop
|
|
184
|
+
* level changes. Default: true. Set false to keep the overlay tracking the level
|
|
185
|
+
* without the spring animation (e.g. for reduced-motion preferences). */
|
|
186
|
+
magneticSnap?: boolean;
|
|
162
187
|
/** Customizations for drag-and-drop visuals (overlay, indicator, opacity) */
|
|
163
188
|
customizations?: DragDropCustomizations<ID>;
|
|
164
189
|
|
|
@@ -173,10 +198,15 @@ export interface DragAndDropOptions<ID = string> {
|
|
|
173
198
|
/** Callback to determine if a node can be dragged.
|
|
174
199
|
* Return false to prevent dragging this node. Default: all nodes are draggable. */
|
|
175
200
|
canDrag?: (node: TreeNode<ID>) => boolean;
|
|
201
|
+
/** Auto-scroll to the dropped node after a successful drop, if it ended up
|
|
202
|
+
* outside the viewport (no scroll when the node is already visible).
|
|
203
|
+
* Pass `false` to disable, `true` for defaults, or an object to customize.
|
|
204
|
+
* Default: `{ enabled: true, animated: true, viewPosition: 0.5 }` */
|
|
205
|
+
autoScrollToDroppedNode?: boolean | DropAutoScrollOptions;
|
|
176
206
|
}
|
|
177
207
|
|
|
178
208
|
/** Props for the NodeList component that renders the flattened tree */
|
|
179
|
-
export interface NodeListProps<ID> extends TreeItemCustomizations<ID> {
|
|
209
|
+
export interface NodeListProps<ID = string> extends TreeItemCustomizations<ID> {
|
|
180
210
|
/** Additional props passed to the underlying FlashList */
|
|
181
211
|
treeFlashListProps?: TreeFlatListProps;
|
|
182
212
|
|
|
@@ -287,9 +317,42 @@ export interface TreeViewRef<ID = string> {
|
|
|
287
317
|
/** Get a map of child node IDs to their parent node IDs */
|
|
288
318
|
getChildToParentMap: () => Map<ID, ID>;
|
|
289
319
|
|
|
320
|
+
/** Get the current tree data held by the component (the original `data` prop
|
|
321
|
+
* before any move, or the reordered structure after a drag-and-drop / `moveNode`).
|
|
322
|
+
* Useful for reading the full tree without pushing it through the `onDragEnd` /
|
|
323
|
+
* `moveNode` move delta.
|
|
324
|
+
*
|
|
325
|
+
* NOTE: this returns a LIVE internal reference - treat it as read-only and do
|
|
326
|
+
* NOT mutate it in place. Mutating it desyncs the internal node maps and the
|
|
327
|
+
* reinit-skip diff. Clone it (e.g. with the exported `moveTreeNode`, or
|
|
328
|
+
* `structuredClone`) before modifying. */
|
|
329
|
+
getTreeData: () => TreeNode<ID>[];
|
|
330
|
+
|
|
290
331
|
/** Programmatically move a node to a new position in the tree.
|
|
291
|
-
* Works like a drag-and-drop but without user interaction.
|
|
292
|
-
|
|
332
|
+
* Works like a drag-and-drop but without user interaction.
|
|
333
|
+
* Returns a lightweight {@link MoveResult} describing the move, or `null` if it
|
|
334
|
+
* was a no-op / invalid (e.g. moving a node onto itself or into its own
|
|
335
|
+
* descendant, or - with `{ validate: true }` - blocked by `canDrop`,
|
|
336
|
+
* `maxDepth`, or `canNodeHaveChildren`).
|
|
337
|
+
*
|
|
338
|
+
* `{ validate: true }` enforces the `canDrop` / `maxDepth` / `canNodeHaveChildren`
|
|
339
|
+
* rules - but those rules live on the `dragAndDrop` prop, so validation only runs
|
|
340
|
+
* when a `dragAndDrop` prop is configured. Without it, `validate` is ignored (in
|
|
341
|
+
* dev a warning is logged) and the move proceeds subject only to the structural
|
|
342
|
+
* no-op checks.
|
|
343
|
+
*
|
|
344
|
+
* `{ scrollToNode: true }` scrolls the moved node into view after the move (the
|
|
345
|
+
* interactive drag does this automatically; programmatic moves do not by default).
|
|
346
|
+
* Pass a {@link DropAutoScrollOptions} object to customize the scroll. */
|
|
347
|
+
moveNode: (
|
|
348
|
+
nodeId: ID,
|
|
349
|
+
targetNodeId: ID,
|
|
350
|
+
position: DropPosition,
|
|
351
|
+
options?: {
|
|
352
|
+
validate?: boolean;
|
|
353
|
+
scrollToNode?: boolean | DropAutoScrollOptions;
|
|
354
|
+
}
|
|
355
|
+
) => MoveResult<ID> | null;
|
|
293
356
|
}
|
|
294
357
|
|
|
295
358
|
/** Controls how checkbox selection propagates through the tree hierarchy */
|
|
@@ -324,6 +387,10 @@ export interface DropIndicatorStyleProps {
|
|
|
324
387
|
highlightColor?: string;
|
|
325
388
|
/** Border color of the "inside" highlight. Default: "rgba(0, 120, 255, 0.5)" */
|
|
326
389
|
highlightBorderColor?: string;
|
|
390
|
+
/** Border width of the "inside" highlight box. Default: 2 */
|
|
391
|
+
highlightBorderWidth?: number;
|
|
392
|
+
/** Corner radius of the "inside" highlight box. Default: 4 */
|
|
393
|
+
highlightBorderRadius?: number;
|
|
327
394
|
}
|
|
328
395
|
|
|
329
396
|
/** Style props for customizing the drag overlay (the "lifted" node ghost) */
|
|
@@ -332,12 +399,16 @@ export interface DragOverlayStyleProps {
|
|
|
332
399
|
backgroundColor?: string;
|
|
333
400
|
/** Shadow color. Default: "#000" */
|
|
334
401
|
shadowColor?: string;
|
|
402
|
+
/** Shadow offset (iOS). Default: { width: 0, height: 2 } */
|
|
403
|
+
shadowOffset?: { width: number; height: number; };
|
|
335
404
|
/** Shadow opacity. Default: 0.25 */
|
|
336
405
|
shadowOpacity?: number;
|
|
337
406
|
/** Shadow radius. Default: 4 */
|
|
338
407
|
shadowRadius?: number;
|
|
339
408
|
/** Android elevation. Default: 10 */
|
|
340
409
|
elevation?: number;
|
|
410
|
+
/** Stacking order of the overlay. Default: 9999 */
|
|
411
|
+
zIndex?: number;
|
|
341
412
|
/** Custom style applied to the overlay container */
|
|
342
413
|
style?: StyleProp<ViewStyle>;
|
|
343
414
|
}
|
|
@@ -361,7 +432,7 @@ export interface DragDropCustomizations<ID = string> {
|
|
|
361
432
|
/** Props passed to a custom drag overlay component */
|
|
362
433
|
export interface DragOverlayComponentProps<ID = string> {
|
|
363
434
|
/** The node being dragged */
|
|
364
|
-
node:
|
|
435
|
+
node: TreeNode<ID>;
|
|
365
436
|
/** The nesting level of the dragged node */
|
|
366
437
|
level: number;
|
|
367
438
|
/** The current checkbox value of the dragged node */
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { memo } from "react";
|
|
4
|
-
import { Animated, View, StyleSheet } from "react-native";
|
|
5
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
export const DropIndicator = /*#__PURE__*/memo(function DropIndicator(props) {
|
|
7
|
-
const {
|
|
8
|
-
position,
|
|
9
|
-
overlayY,
|
|
10
|
-
itemHeight,
|
|
11
|
-
targetLevel,
|
|
12
|
-
indentationMultiplier
|
|
13
|
-
} = props;
|
|
14
|
-
const indent = targetLevel * indentationMultiplier;
|
|
15
|
-
if (position === "inside") {
|
|
16
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
17
|
-
pointerEvents: "none",
|
|
18
|
-
style: [styles.highlightIndicator, {
|
|
19
|
-
transform: [{
|
|
20
|
-
translateY: overlayY
|
|
21
|
-
}],
|
|
22
|
-
height: itemHeight,
|
|
23
|
-
left: indent
|
|
24
|
-
}]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// For "above", the line is at the overlay's top edge (offset 0)
|
|
29
|
-
// For "below", the line is at the overlay's bottom edge (offset +itemHeight)
|
|
30
|
-
const lineOffset = position === "above" ? 0 : itemHeight;
|
|
31
|
-
return /*#__PURE__*/_jsxs(Animated.View, {
|
|
32
|
-
pointerEvents: "none",
|
|
33
|
-
style: [styles.lineContainer, {
|
|
34
|
-
transform: [{
|
|
35
|
-
translateY: Animated.add(overlayY, lineOffset - 1)
|
|
36
|
-
}],
|
|
37
|
-
left: indent
|
|
38
|
-
}],
|
|
39
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
40
|
-
style: styles.lineCircle
|
|
41
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
42
|
-
style: styles.line
|
|
43
|
-
})]
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
const styles = StyleSheet.create({
|
|
47
|
-
highlightIndicator: {
|
|
48
|
-
position: "absolute",
|
|
49
|
-
left: 0,
|
|
50
|
-
right: 0,
|
|
51
|
-
backgroundColor: "rgba(0, 200, 0, 0.2)",
|
|
52
|
-
borderWidth: 2,
|
|
53
|
-
borderColor: "rgba(0, 200, 0, 0.6)",
|
|
54
|
-
borderRadius: 4,
|
|
55
|
-
zIndex: 9998
|
|
56
|
-
},
|
|
57
|
-
lineContainer: {
|
|
58
|
-
position: "absolute",
|
|
59
|
-
right: 0,
|
|
60
|
-
flexDirection: "row",
|
|
61
|
-
alignItems: "center",
|
|
62
|
-
height: 3,
|
|
63
|
-
zIndex: 9998
|
|
64
|
-
},
|
|
65
|
-
lineCircle: {
|
|
66
|
-
width: 10,
|
|
67
|
-
height: 10,
|
|
68
|
-
borderRadius: 5,
|
|
69
|
-
backgroundColor: "#00CC00",
|
|
70
|
-
marginLeft: -5,
|
|
71
|
-
marginTop: -4
|
|
72
|
-
},
|
|
73
|
-
line: {
|
|
74
|
-
flex: 1,
|
|
75
|
-
height: 3,
|
|
76
|
-
backgroundColor: "#00CC00"
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
//# sourceMappingURL=DropIndicator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["memo","Animated","View","StyleSheet","jsx","_jsx","jsxs","_jsxs","DropIndicator","props","position","overlayY","itemHeight","targetLevel","indentationMultiplier","indent","pointerEvents","style","styles","highlightIndicator","transform","translateY","height","left","lineOffset","lineContainer","add","children","lineCircle","line","create","right","backgroundColor","borderWidth","borderColor","borderRadius","zIndex","flexDirection","alignItems","width","marginLeft","marginTop","flex"],"sourceRoot":"../../../src","sources":["components/DropIndicator.tsx"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,OAAO;AAC5B,SAASC,QAAQ,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAW1D,OAAO,MAAMC,aAAa,gBAAGR,IAAI,CAAC,SAASQ,aAAaA,CACpDC,KAAyB,EAC3B;EACE,MAAM;IACFC,QAAQ;IACRC,QAAQ;IACRC,UAAU;IACVC,WAAW;IACXC;EACJ,CAAC,GAAGL,KAAK;EAET,MAAMM,MAAM,GAAGF,WAAW,GAAGC,qBAAqB;EAElD,IAAIJ,QAAQ,KAAK,QAAQ,EAAE;IACvB,oBACIL,IAAA,CAACJ,QAAQ,CAACC,IAAI;MACVc,aAAa,EAAC,MAAM;MACpBC,KAAK,EAAE,CACHC,MAAM,CAACC,kBAAkB,EACzB;QACIC,SAAS,EAAE,CAAC;UAAEC,UAAU,EAAEV;QAAS,CAAC,CAAC;QACrCW,MAAM,EAAEV,UAAU;QAClBW,IAAI,EAAER;MACV,CAAC;IACH,CACL,CAAC;EAEV;;EAEA;EACA;EACA,MAAMS,UAAU,GAAGd,QAAQ,KAAK,OAAO,GAAG,CAAC,GAAGE,UAAU;EAExD,oBACIL,KAAA,CAACN,QAAQ,CAACC,IAAI;IACVc,aAAa,EAAC,MAAM;IACpBC,KAAK,EAAE,CACHC,MAAM,CAACO,aAAa,EACpB;MACIL,SAAS,EAAE,CAAC;QAAEC,UAAU,EAAEpB,QAAQ,CAACyB,GAAG,CAACf,QAAQ,EAAEa,UAAU,GAAG,CAAC;MAAE,CAAC,CAAC;MACnED,IAAI,EAAER;IACV,CAAC,CACH;IAAAY,QAAA,gBAEFtB,IAAA,CAACH,IAAI;MAACe,KAAK,EAAEC,MAAM,CAACU;IAAW,CAAE,CAAC,eAClCvB,IAAA,CAACH,IAAI;MAACe,KAAK,EAAEC,MAAM,CAACW;IAAK,CAAE,CAAC;EAAA,CACjB,CAAC;AAExB,CAAC,CAAC;AAEF,MAAMX,MAAM,GAAGf,UAAU,CAAC2B,MAAM,CAAC;EAC7BX,kBAAkB,EAAE;IAChBT,QAAQ,EAAE,UAAU;IACpBa,IAAI,EAAE,CAAC;IACPQ,KAAK,EAAE,CAAC;IACRC,eAAe,EAAE,sBAAsB;IACvCC,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,sBAAsB;IACnCC,YAAY,EAAE,CAAC;IACfC,MAAM,EAAE;EACZ,CAAC;EACDX,aAAa,EAAE;IACXf,QAAQ,EAAE,UAAU;IACpBqB,KAAK,EAAE,CAAC;IACRM,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBhB,MAAM,EAAE,CAAC;IACTc,MAAM,EAAE;EACZ,CAAC;EACDR,UAAU,EAAE;IACRW,KAAK,EAAE,EAAE;IACTjB,MAAM,EAAE,EAAE;IACVa,YAAY,EAAE,CAAC;IACfH,eAAe,EAAE,SAAS;IAC1BQ,UAAU,EAAE,CAAC,CAAC;IACdC,SAAS,EAAE,CAAC;EAChB,CAAC;EACDZ,IAAI,EAAE;IACFa,IAAI,EAAE,CAAC;IACPpB,MAAM,EAAE,CAAC;IACTU,eAAe,EAAE;EACrB;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Animated } from "react-native";
|
|
2
|
-
import type { DropPosition } from "../types/dragDrop.types";
|
|
3
|
-
interface DropIndicatorProps {
|
|
4
|
-
position: DropPosition;
|
|
5
|
-
overlayY: Animated.Value;
|
|
6
|
-
itemHeight: number;
|
|
7
|
-
targetLevel: number;
|
|
8
|
-
indentationMultiplier: number;
|
|
9
|
-
}
|
|
10
|
-
export declare const DropIndicator: import("react").NamedExoticComponent<DropIndicatorProps>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=DropIndicator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DropIndicator.d.ts","sourceRoot":"","sources":["../../../../src/components/DropIndicator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAoB,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,UAAU,kBAAkB;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB,EAAE,MAAM,CAAC;CACjC;AAED,eAAO,MAAM,aAAa,0DAgDxB,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { memo } from "react";
|
|
2
|
-
import { Animated, View, StyleSheet } from "react-native";
|
|
3
|
-
import type { DropPosition } from "../types/dragDrop.types";
|
|
4
|
-
|
|
5
|
-
interface DropIndicatorProps {
|
|
6
|
-
position: DropPosition;
|
|
7
|
-
overlayY: Animated.Value;
|
|
8
|
-
itemHeight: number;
|
|
9
|
-
targetLevel: number;
|
|
10
|
-
indentationMultiplier: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DropIndicator = memo(function DropIndicator(
|
|
14
|
-
props: DropIndicatorProps
|
|
15
|
-
) {
|
|
16
|
-
const {
|
|
17
|
-
position,
|
|
18
|
-
overlayY,
|
|
19
|
-
itemHeight,
|
|
20
|
-
targetLevel,
|
|
21
|
-
indentationMultiplier,
|
|
22
|
-
} = props;
|
|
23
|
-
|
|
24
|
-
const indent = targetLevel * indentationMultiplier;
|
|
25
|
-
|
|
26
|
-
if (position === "inside") {
|
|
27
|
-
return (
|
|
28
|
-
<Animated.View
|
|
29
|
-
pointerEvents="none"
|
|
30
|
-
style={[
|
|
31
|
-
styles.highlightIndicator,
|
|
32
|
-
{
|
|
33
|
-
transform: [{ translateY: overlayY }],
|
|
34
|
-
height: itemHeight,
|
|
35
|
-
left: indent,
|
|
36
|
-
},
|
|
37
|
-
]}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// For "above", the line is at the overlay's top edge (offset 0)
|
|
43
|
-
// For "below", the line is at the overlay's bottom edge (offset +itemHeight)
|
|
44
|
-
const lineOffset = position === "above" ? 0 : itemHeight;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Animated.View
|
|
48
|
-
pointerEvents="none"
|
|
49
|
-
style={[
|
|
50
|
-
styles.lineContainer,
|
|
51
|
-
{
|
|
52
|
-
transform: [{ translateY: Animated.add(overlayY, lineOffset - 1) }],
|
|
53
|
-
left: indent,
|
|
54
|
-
},
|
|
55
|
-
]}
|
|
56
|
-
>
|
|
57
|
-
<View style={styles.lineCircle} />
|
|
58
|
-
<View style={styles.line} />
|
|
59
|
-
</Animated.View>
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const styles = StyleSheet.create({
|
|
64
|
-
highlightIndicator: {
|
|
65
|
-
position: "absolute",
|
|
66
|
-
left: 0,
|
|
67
|
-
right: 0,
|
|
68
|
-
backgroundColor: "rgba(0, 200, 0, 0.2)",
|
|
69
|
-
borderWidth: 2,
|
|
70
|
-
borderColor: "rgba(0, 200, 0, 0.6)",
|
|
71
|
-
borderRadius: 4,
|
|
72
|
-
zIndex: 9998,
|
|
73
|
-
},
|
|
74
|
-
lineContainer: {
|
|
75
|
-
position: "absolute",
|
|
76
|
-
right: 0,
|
|
77
|
-
flexDirection: "row",
|
|
78
|
-
alignItems: "center",
|
|
79
|
-
height: 3,
|
|
80
|
-
zIndex: 9998,
|
|
81
|
-
},
|
|
82
|
-
lineCircle: {
|
|
83
|
-
width: 10,
|
|
84
|
-
height: 10,
|
|
85
|
-
borderRadius: 5,
|
|
86
|
-
backgroundColor: "#00CC00",
|
|
87
|
-
marginLeft: -5,
|
|
88
|
-
marginTop: -4,
|
|
89
|
-
},
|
|
90
|
-
line: {
|
|
91
|
-
flex: 1,
|
|
92
|
-
height: 3,
|
|
93
|
-
backgroundColor: "#00CC00",
|
|
94
|
-
},
|
|
95
|
-
});
|