react-native-tree-multi-select 3.0.0-beta.1 → 3.0.0-beta.3
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 +1 -1
- package/lib/module/components/DragOverlay.js +3 -0
- package/lib/module/components/DragOverlay.js.map +1 -1
- package/lib/module/components/NodeList.js +61 -25
- package/lib/module/components/NodeList.js.map +1 -1
- package/lib/module/helpers/toggleCheckbox.helper.js +1 -1
- package/lib/module/hooks/useDragDrop.js +214 -30
- package/lib/module/hooks/useDragDrop.js.map +1 -1
- package/lib/module/store/treeView.store.js +6 -3
- package/lib/module/store/treeView.store.js.map +1 -1
- package/lib/typescript/src/components/DragOverlay.d.ts +1 -0
- 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/hooks/useDragDrop.d.ts +5 -0
- package/lib/typescript/src/hooks/useDragDrop.d.ts.map +1 -1
- package/lib/typescript/src/store/treeView.store.d.ts +2 -1
- package/lib/typescript/src/store/treeView.store.d.ts.map +1 -1
- package/lib/typescript/src/types/dragDrop.types.d.ts +9 -0
- package/lib/typescript/src/types/dragDrop.types.d.ts.map +1 -1
- package/lib/typescript/src/types/treeView.types.d.ts +94 -4
- package/lib/typescript/src/types/treeView.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/DragOverlay.tsx +3 -1
- package/src/components/NodeList.tsx +62 -29
- package/src/helpers/toggleCheckbox.helper.ts +1 -1
- package/src/hooks/useDragDrop.ts +237 -31
- package/src/store/treeView.store.ts +6 -2
- package/src/types/dragDrop.types.ts +9 -0
- package/src/types/treeView.types.ts +94 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeView.store.d.ts","sourceRoot":"","sources":["../../../../src/store/treeView.store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AA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AAoB,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,0BAA0B,EAAE,CAAC,oBAAoB,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAGpE,gBAAgB,EAAE,EAAE,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAGpG,oBAAoB,EAAE,MAAM,IAAI,CAAC;CACpC,CAAC;AAOF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAqF3F;AAED,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,8CAEvD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { TreeNode } from "./treeView.types";
|
|
2
|
+
/** Where a node is dropped relative to the target: as a sibling above/below, or as a child inside */
|
|
2
3
|
export type DropPosition = "above" | "below" | "inside";
|
|
4
|
+
/** Event payload passed to the onDragEnd callback after a successful drop */
|
|
3
5
|
export interface DragEndEvent<ID = string> {
|
|
4
6
|
/** The id of the node that was dragged */
|
|
5
7
|
draggedNodeId: ID;
|
|
@@ -10,12 +12,19 @@ export interface DragEndEvent<ID = string> {
|
|
|
10
12
|
/** The reordered tree data after the move */
|
|
11
13
|
newTreeData: TreeNode<ID>[];
|
|
12
14
|
}
|
|
15
|
+
/** Internal representation of the current drop target during a drag operation */
|
|
13
16
|
export interface DropTarget<ID = string> {
|
|
17
|
+
/** The id of the node being hovered over */
|
|
14
18
|
targetNodeId: ID;
|
|
19
|
+
/** Index of the target node in the flattened list */
|
|
15
20
|
targetIndex: number;
|
|
21
|
+
/** Where the drop would occur relative to the target */
|
|
16
22
|
position: DropPosition;
|
|
23
|
+
/** Whether this is a valid drop location (e.g. not dropping a node onto itself or its descendants) */
|
|
17
24
|
isValid: boolean;
|
|
25
|
+
/** Nesting level of the target node */
|
|
18
26
|
targetLevel: number;
|
|
27
|
+
/** Y-coordinate for positioning the drop indicator */
|
|
19
28
|
indicatorTop: number;
|
|
20
29
|
}
|
|
21
30
|
//# sourceMappingURL=dragDrop.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragDrop.types.d.ts","sourceRoot":"","sources":["../../../../src/types/dragDrop.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD,MAAM,WAAW,YAAY,CAAC,EAAE,GAAG,MAAM;IACrC,0CAA0C;IAC1C,aAAa,EAAE,EAAE,CAAC;IAClB,mEAAmE;IACnE,YAAY,EAAE,EAAE,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,YAAY,CAAC;IACvB,6CAA6C;IAC7C,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU,CAAC,EAAE,GAAG,MAAM;IACnC,YAAY,EAAE,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"dragDrop.types.d.ts","sourceRoot":"","sources":["../../../../src/types/dragDrop.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,qGAAqG;AACrG,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD,6EAA6E;AAC7E,MAAM,WAAW,YAAY,CAAC,EAAE,GAAG,MAAM;IACrC,0CAA0C;IAC1C,aAAa,EAAE,EAAE,CAAC;IAClB,mEAAmE;IACnE,YAAY,EAAE,EAAE,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,YAAY,CAAC;IACvB,6CAA6C;IAC7C,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;CAC/B;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU,CAAC,EAAE,GAAG,MAAM;IACnC,4CAA4C;IAC5C,YAAY,EAAE,EAAE,CAAC;IACjB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,QAAQ,EAAE,YAAY,CAAC;IACvB,sGAAsG;IACtG,OAAO,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,YAAY,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -3,61 +3,111 @@ import type { FlashListProps } from "@shopify/flash-list";
|
|
|
3
3
|
import type { ScrollToNodeHandlerRef, ScrollToNodeParams } from "../handlers/ScrollToNodeHandler";
|
|
4
4
|
import type { CheckboxProps as _CheckboxProps } from "@futurejj/react-native-checkbox";
|
|
5
5
|
import type { DragEndEvent, DropPosition } from "./dragDrop.types";
|
|
6
|
+
/** The tri-state value of a checkbox: checked, unchecked, or indeterminate */
|
|
6
7
|
export type CheckboxValueType = boolean | "indeterminate";
|
|
8
|
+
/** Props passed to a custom expand/collapse icon component */
|
|
7
9
|
export interface ExpandIconProps {
|
|
10
|
+
/** Whether the node is currently expanded */
|
|
8
11
|
isExpanded: boolean;
|
|
9
12
|
}
|
|
13
|
+
/** A single node in the tree data structure */
|
|
10
14
|
export interface TreeNode<ID = string> {
|
|
15
|
+
/** Unique identifier for this node */
|
|
11
16
|
id: ID;
|
|
17
|
+
/** Display name for this node */
|
|
12
18
|
name: string;
|
|
19
|
+
/** Child nodes (omit or empty array for leaf nodes) */
|
|
13
20
|
children?: TreeNode<ID>[];
|
|
21
|
+
/** Additional custom data fields */
|
|
14
22
|
[key: string]: any;
|
|
15
23
|
}
|
|
24
|
+
/** Internal flattened representation of a tree node with its nesting level */
|
|
16
25
|
export interface __FlattenedTreeNode__<ID = string> extends TreeNode<ID> {
|
|
26
|
+
/** Nesting depth of this node (0 = root level) */
|
|
17
27
|
level?: number;
|
|
18
28
|
}
|
|
29
|
+
/** FlashList props available for customization (excludes `data` and `renderItem`) */
|
|
19
30
|
export type TreeFlatListProps<ItemT = any> = Omit<FlashListProps<ItemT>, "data" | "renderItem">;
|
|
31
|
+
/** Props passed to a custom node row component */
|
|
20
32
|
export interface NodeRowProps<ID = string> {
|
|
33
|
+
/** The tree node to render */
|
|
21
34
|
node: TreeNode<ID>;
|
|
35
|
+
/** Nesting depth of this node (0 = root level) */
|
|
22
36
|
level: number;
|
|
37
|
+
/** Current checkbox state of this node */
|
|
23
38
|
checkedValue: CheckboxValueType;
|
|
39
|
+
/** Whether this node's children are currently visible */
|
|
24
40
|
isExpanded: boolean;
|
|
41
|
+
/** Callback to toggle this node's checked state */
|
|
25
42
|
onCheck: () => void;
|
|
43
|
+
/** Callback to toggle this node's expanded/collapsed state */
|
|
26
44
|
onExpand: () => void;
|
|
45
|
+
/** Whether this node is an invalid drop target during a drag operation */
|
|
27
46
|
isDragTarget?: boolean;
|
|
47
|
+
/** Whether a drag operation is currently in progress */
|
|
28
48
|
isDragging?: boolean;
|
|
49
|
+
/** Whether this node is the one being dragged */
|
|
29
50
|
isDraggedNode?: boolean;
|
|
30
51
|
}
|
|
52
|
+
/** Customization options for tree item appearance and behavior */
|
|
31
53
|
export interface TreeItemCustomizations<ID> {
|
|
54
|
+
/** Style props for the built-in checkbox view */
|
|
32
55
|
checkBoxViewStyleProps?: BuiltInCheckBoxViewStyleProps;
|
|
56
|
+
/** Pixels of indentation per nesting level. Default: 15 */
|
|
33
57
|
indentationMultiplier?: number;
|
|
58
|
+
/** Custom checkbox component replacing the built-in checkbox */
|
|
34
59
|
CheckboxComponent?: React.ComponentType<CheckBoxViewProps>;
|
|
60
|
+
/** Custom expand/collapse icon component */
|
|
35
61
|
ExpandCollapseIconComponent?: React.ComponentType<ExpandIconProps>;
|
|
62
|
+
/** Custom touchable component wrapping the expand/collapse icon */
|
|
36
63
|
ExpandCollapseTouchableComponent?: React.ComponentType<TouchableOpacityProps>;
|
|
64
|
+
/** Fully custom node row component replacing the entire built-in row */
|
|
37
65
|
CustomNodeRowComponent?: React.ComponentType<NodeRowProps<ID>>;
|
|
38
66
|
}
|
|
67
|
+
/** Internal props for a single node in the list (extends TreeItemCustomizations) */
|
|
39
68
|
export interface NodeProps<ID> extends TreeItemCustomizations<ID> {
|
|
69
|
+
/** The flattened tree node data */
|
|
40
70
|
node: __FlattenedTreeNode__<ID>;
|
|
71
|
+
/** Nesting depth of this node */
|
|
41
72
|
level: number;
|
|
73
|
+
/** Internal store identifier */
|
|
42
74
|
storeId: string;
|
|
75
|
+
/** Index of this node in the flattened list */
|
|
43
76
|
nodeIndex?: number;
|
|
77
|
+
/** Whether drag-and-drop is enabled */
|
|
44
78
|
dragEnabled?: boolean;
|
|
79
|
+
/** Whether a drag operation is currently in progress */
|
|
45
80
|
isDragging?: boolean;
|
|
81
|
+
/** Callback when a touch starts on this node (used for drag initiation) */
|
|
46
82
|
onNodeTouchStart?: (nodeId: ID, pageY: number, locationY: number, nodeIndex: number) => void;
|
|
83
|
+
/** Callback when a touch ends on this node */
|
|
47
84
|
onNodeTouchEnd?: () => void;
|
|
85
|
+
/** Long press duration in ms to start drag */
|
|
48
86
|
longPressDuration?: number;
|
|
87
|
+
/** Callback reporting this node's measured height */
|
|
49
88
|
onItemLayout?: (height: number) => void;
|
|
89
|
+
/** Customizations for drag-and-drop visuals */
|
|
50
90
|
dragDropCustomizations?: DragDropCustomizations<ID>;
|
|
51
91
|
}
|
|
92
|
+
/** Props for the NodeList component that renders the flattened tree */
|
|
52
93
|
export interface NodeListProps<ID> extends TreeItemCustomizations<ID> {
|
|
94
|
+
/** Additional props passed to the underlying FlashList */
|
|
53
95
|
treeFlashListProps?: TreeFlatListProps;
|
|
96
|
+
/** Ref for programmatic scroll-to-node functionality */
|
|
54
97
|
scrollToNodeHandlerRef: React.RefObject<ScrollToNodeHandlerRef<ID>>;
|
|
98
|
+
/** Node ID to scroll to on initial render */
|
|
55
99
|
initialScrollNodeID?: ID;
|
|
100
|
+
/** Internal store identifier */
|
|
56
101
|
storeId: string;
|
|
102
|
+
/** Enable drag-and-drop reordering */
|
|
57
103
|
dragEnabled?: boolean;
|
|
104
|
+
/** Callback fired after a node is dropped at a new position */
|
|
58
105
|
onDragEnd?: (event: DragEndEvent<ID>) => void;
|
|
106
|
+
/** Long press duration in ms to start drag. Default: 400 */
|
|
59
107
|
longPressDuration?: number;
|
|
108
|
+
/** Distance from edge (px) to trigger auto-scroll during drag. Default: 60 */
|
|
60
109
|
autoScrollThreshold?: number;
|
|
110
|
+
/** Speed multiplier for auto-scroll during drag. Default: 1.0 */
|
|
61
111
|
autoScrollSpeed?: number;
|
|
62
112
|
/** Offset of the dragged overlay from the finger, in item-height units. Default: -1 (one item above finger) */
|
|
63
113
|
dragOverlayOffset?: number;
|
|
@@ -66,12 +116,19 @@ export interface NodeListProps<ID> extends TreeItemCustomizations<ID> {
|
|
|
66
116
|
/** Customizations for drag-and-drop visuals (overlay, indicator, opacity) */
|
|
67
117
|
dragDropCustomizations?: DragDropCustomizations<ID>;
|
|
68
118
|
}
|
|
119
|
+
/** Props for the TreeView component */
|
|
69
120
|
export interface TreeViewProps<ID = string> extends Omit<NodeListProps<ID>, "storeId" | "scrollToNodeHandlerRef"> {
|
|
121
|
+
/** The tree data to render */
|
|
70
122
|
data: TreeNode<ID>[];
|
|
123
|
+
/** Callback fired when checked nodes change. Receives checked and indeterminate node IDs. */
|
|
71
124
|
onCheck?: (checkedIds: ID[], indeterminateIds: ID[]) => void;
|
|
125
|
+
/** Callback fired when expanded nodes change. Receives all currently expanded node IDs. */
|
|
72
126
|
onExpand?: (expandedIds: ID[]) => void;
|
|
127
|
+
/** Node IDs that should be checked on initial render */
|
|
73
128
|
preselectedIds?: ID[];
|
|
129
|
+
/** Node IDs that should be expanded on initial render */
|
|
74
130
|
preExpandedIds?: ID[];
|
|
131
|
+
/** Controls whether checking a node propagates to its children and/or parents */
|
|
75
132
|
selectionPropagation?: SelectionPropagation;
|
|
76
133
|
/** Enable drag-and-drop reordering */
|
|
77
134
|
dragEnabled?: boolean;
|
|
@@ -79,9 +136,9 @@ export interface TreeViewProps<ID = string> extends Omit<NodeListProps<ID>, "sto
|
|
|
79
136
|
onDragEnd?: (event: DragEndEvent<ID>) => void;
|
|
80
137
|
/** Long press duration in ms to start drag. Default: 400 */
|
|
81
138
|
longPressDuration?: number;
|
|
82
|
-
/** Distance from edge (px) to trigger auto-scroll. Default: 60 */
|
|
139
|
+
/** Distance from edge (px) to trigger auto-scroll during drag. Default: 60 */
|
|
83
140
|
autoScrollThreshold?: number;
|
|
84
|
-
/** Speed multiplier for auto-scroll. Default: 1.0 */
|
|
141
|
+
/** Speed multiplier for auto-scroll during drag. Default: 1.0 */
|
|
85
142
|
autoScrollSpeed?: number;
|
|
86
143
|
/** Offset of the dragged overlay from the finger, in item-height units. Default: -1 (one item above finger) */
|
|
87
144
|
dragOverlayOffset?: number;
|
|
@@ -89,43 +146,76 @@ export interface TreeViewProps<ID = string> extends Omit<NodeListProps<ID>, "sto
|
|
|
89
146
|
autoExpandDelay?: number;
|
|
90
147
|
}
|
|
91
148
|
type CheckboxProps = Omit<_CheckboxProps, "onPress" | "status">;
|
|
149
|
+
/** Props for the checkbox view component */
|
|
92
150
|
export interface CheckBoxViewProps {
|
|
151
|
+
/** Current checkbox state */
|
|
93
152
|
value: CheckboxValueType;
|
|
153
|
+
/** Callback when the checkbox value changes */
|
|
94
154
|
onValueChange: (value: boolean) => void;
|
|
155
|
+
/** Label text displayed next to the checkbox */
|
|
95
156
|
text: string;
|
|
157
|
+
/** Test ID for testing frameworks */
|
|
96
158
|
testID?: string;
|
|
97
159
|
}
|
|
160
|
+
/** Style props for customizing the built-in checkbox view */
|
|
98
161
|
export interface BuiltInCheckBoxViewStyleProps {
|
|
162
|
+
/** Style for the outermost container wrapping the checkbox and text */
|
|
99
163
|
outermostParentViewStyle?: StyleProp<ViewStyle>;
|
|
164
|
+
/** Style for the view wrapping the checkbox itself */
|
|
100
165
|
checkboxParentViewStyle?: StyleProp<ViewStyle>;
|
|
166
|
+
/** Style for the touchable area wrapping the label text */
|
|
101
167
|
textTouchableStyle?: StyleProp<ViewStyle>;
|
|
168
|
+
/** Additional props passed to the underlying Checkbox component */
|
|
102
169
|
checkboxProps?: CheckboxProps;
|
|
170
|
+
/** Props passed to the label Text component */
|
|
103
171
|
textProps?: TextProps;
|
|
104
172
|
}
|
|
173
|
+
/** Combined props for the built-in checkbox view (CheckBoxViewProps + style props) */
|
|
105
174
|
export type BuiltInCheckBoxViewProps = CheckBoxViewProps & BuiltInCheckBoxViewStyleProps;
|
|
175
|
+
/** Ref handle exposed by the TreeView component for imperative operations */
|
|
106
176
|
export interface TreeViewRef<ID = string> {
|
|
177
|
+
/** Select (check) all nodes in the tree */
|
|
107
178
|
selectAll: () => void;
|
|
179
|
+
/** Unselect (uncheck) all nodes in the tree */
|
|
108
180
|
unselectAll: () => void;
|
|
181
|
+
/** Select all nodes that match the current search filter */
|
|
109
182
|
selectAllFiltered: () => void;
|
|
183
|
+
/** Unselect all nodes that match the current search filter */
|
|
110
184
|
unselectAllFiltered: () => void;
|
|
185
|
+
/** Expand all nodes in the tree */
|
|
111
186
|
expandAll: () => void;
|
|
187
|
+
/** Collapse all nodes in the tree */
|
|
112
188
|
collapseAll: () => void;
|
|
189
|
+
/** Expand specific nodes by their IDs */
|
|
113
190
|
expandNodes: (ids: ID[]) => void;
|
|
191
|
+
/** Collapse specific nodes by their IDs */
|
|
114
192
|
collapseNodes: (ids: ID[]) => void;
|
|
193
|
+
/** Select (check) specific nodes by their IDs */
|
|
115
194
|
selectNodes: (ids: ID[]) => void;
|
|
195
|
+
/** Unselect (uncheck) specific nodes by their IDs */
|
|
116
196
|
unselectNodes: (ids: ID[]) => void;
|
|
197
|
+
/** Set the search text and optionally specify which node fields to search */
|
|
117
198
|
setSearchText: (searchText: string, searchKeys?: string[]) => void;
|
|
199
|
+
/** Programmatically scroll to a specific node by its ID */
|
|
118
200
|
scrollToNodeID: (scrollToNodeParams: ScrollToNodeParams<ID>) => void;
|
|
201
|
+
/** Get a map of child node IDs to their parent node IDs */
|
|
119
202
|
getChildToParentMap: () => Map<ID, ID>;
|
|
120
203
|
}
|
|
204
|
+
/** Controls how checkbox selection propagates through the tree hierarchy */
|
|
121
205
|
export interface SelectionPropagation {
|
|
206
|
+
/** Whether checking a parent node automatically checks all its children. Default: true */
|
|
122
207
|
toChildren?: boolean;
|
|
208
|
+
/** Whether checking all children automatically checks their parent. Default: true */
|
|
123
209
|
toParents?: boolean;
|
|
124
210
|
}
|
|
125
211
|
/** Props for the drop indicator rendered on the target node during drag */
|
|
126
212
|
export interface DropIndicatorComponentProps {
|
|
127
213
|
/** Whether the indicator is above, below, or inside the target node */
|
|
128
214
|
position: DropPosition;
|
|
215
|
+
/** The nesting level of the target node (useful for indenting the indicator) */
|
|
216
|
+
level: number;
|
|
217
|
+
/** The indentation multiplier used for each level (pixels per level) */
|
|
218
|
+
indentationMultiplier: number;
|
|
129
219
|
}
|
|
130
220
|
/** Style props for customizing the built-in drop indicator appearance */
|
|
131
221
|
export interface DropIndicatorStyleProps {
|
|
@@ -163,9 +253,9 @@ export interface DragDropCustomizations<ID = string> {
|
|
|
163
253
|
dropIndicatorStyleProps?: DropIndicatorStyleProps;
|
|
164
254
|
/** Style props for the drag overlay (lifted node ghost) */
|
|
165
255
|
dragOverlayStyleProps?: DragOverlayStyleProps;
|
|
166
|
-
/** Fully custom drop indicator component
|
|
256
|
+
/** Fully custom drop indicator component - replaces the built-in line/highlight */
|
|
167
257
|
CustomDropIndicatorComponent?: React.ComponentType<DropIndicatorComponentProps>;
|
|
168
|
-
/** Fully custom drag overlay component
|
|
258
|
+
/** Fully custom drag overlay component - replaces the built-in ghost node */
|
|
169
259
|
CustomDragOverlayComponent?: React.ComponentType<DragOverlayComponentProps<ID>>;
|
|
170
260
|
}
|
|
171
261
|
/** Props passed to a custom drag overlay component */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeView.types.d.ts","sourceRoot":"","sources":["../../../../src/types/treeView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,SAAS,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EACR,sBAAsB,EACtB,kBAAkB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACR,aAAa,IAAI,cAAc,EAClC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,eAAe,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC5B,UAAU,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ,CAAC,EAAE,GAAG,MAAM;IACjC,EAAE,EAAE,EAAE,CAAC;IACP,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB,CAAC,EAAE,GAAG,MAAM,CAAE,SAAQ,QAAQ,CAAC,EAAE,CAAC;IACpE,KAAK,CAAC,E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EAAE,MAAM,CAAC;CACjC;AAED,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IAClC,4EAA4E;IAC5E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAChC;AAED,iDAAiD;AACjD,MAAM,WAAW,sBAAsB,CAAC,EAAE,GAAG,MAAM;IAC/C,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAClD,2DAA2D;IAC3D,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,mFAAmF;IACnF,4BAA4B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;IAChF,6EAA6E;IAC7E,0BAA0B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC;CACnF;AAED,sDAAsD;AACtD,MAAM,WAAW,yBAAyB,CAAC,EAAE,GAAG,MAAM;IAClD,6BAA6B;IAC7B,IAAI,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;IAChC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;CACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tree-multi-select",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.3",
|
|
4
4
|
"description": "A super-fast, customizable tree view component for React Native with multi-selection, checkboxes, and search filtering capabilities.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -13,6 +13,7 @@ import { defaultIndentationMultiplier } from "../constants/treeView.constants";
|
|
|
13
13
|
|
|
14
14
|
interface DragOverlayProps<ID> extends TreeItemCustomizations<ID> {
|
|
15
15
|
overlayY: Animated.Value;
|
|
16
|
+
overlayX: Animated.Value;
|
|
16
17
|
node: __FlattenedTreeNode__<ID>;
|
|
17
18
|
level: number;
|
|
18
19
|
dragDropCustomizations?: DragDropCustomizations<ID>;
|
|
@@ -21,6 +22,7 @@ interface DragOverlayProps<ID> extends TreeItemCustomizations<ID> {
|
|
|
21
22
|
function _DragOverlay<ID>(props: DragOverlayProps<ID>) {
|
|
22
23
|
const {
|
|
23
24
|
overlayY,
|
|
25
|
+
overlayX,
|
|
24
26
|
node,
|
|
25
27
|
level,
|
|
26
28
|
indentationMultiplier = defaultIndentationMultiplier,
|
|
@@ -47,7 +49,7 @@ function _DragOverlay<ID>(props: DragOverlayProps<ID>) {
|
|
|
47
49
|
...(overlayStyleProps.elevation != null && { elevation: overlayStyleProps.elevation }),
|
|
48
50
|
},
|
|
49
51
|
overlayStyleProps?.style,
|
|
50
|
-
{ transform: [{ translateY: overlayY }] },
|
|
52
|
+
{ transform: [{ translateX: overlayX }, { translateY: overlayY }] },
|
|
51
53
|
]}
|
|
52
54
|
>
|
|
53
55
|
{CustomOverlay ? (
|
|
@@ -114,13 +114,18 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
114
114
|
updateInnerMostChildrenIds(updatedInnerMostChildrenIds);
|
|
115
115
|
}, [filteredTree, updateInnerMostChildrenIds]);
|
|
116
116
|
|
|
117
|
+
const effectiveIndentationMultiplier = indentationMultiplier ?? defaultIndentationMultiplier;
|
|
118
|
+
|
|
117
119
|
// --- Drag and drop ---
|
|
118
120
|
const {
|
|
119
121
|
panResponder,
|
|
120
122
|
overlayY,
|
|
123
|
+
overlayX,
|
|
121
124
|
isDragging,
|
|
122
125
|
draggedNode,
|
|
126
|
+
effectiveDropLevel,
|
|
123
127
|
handleNodeTouchStart,
|
|
128
|
+
handleNodeTouchEnd,
|
|
124
129
|
cancelLongPressTimer,
|
|
125
130
|
scrollOffsetRef,
|
|
126
131
|
} = useDragDrop<ID>({
|
|
@@ -137,6 +142,7 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
137
142
|
measuredItemHeightRef,
|
|
138
143
|
dragOverlayOffset,
|
|
139
144
|
autoExpandDelay,
|
|
145
|
+
indentationMultiplier: effectiveIndentationMultiplier,
|
|
140
146
|
});
|
|
141
147
|
|
|
142
148
|
// Combined onScroll handler
|
|
@@ -150,8 +156,6 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
150
156
|
treeFlashListProps?.onScroll?.(event as any);
|
|
151
157
|
}, [scrollOffsetRef, cancelLongPressTimer, treeFlashListProps]);
|
|
152
158
|
|
|
153
|
-
const effectiveIndentationMultiplier = indentationMultiplier ?? defaultIndentationMultiplier;
|
|
154
|
-
|
|
155
159
|
const nodeRenderer = React.useCallback((
|
|
156
160
|
{ item, index }: { item: __FlattenedTreeNode__<ID>; index: number; }
|
|
157
161
|
) => {
|
|
@@ -174,7 +178,7 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
174
178
|
dragEnabled={dragEnabled}
|
|
175
179
|
isDragging={isDragging}
|
|
176
180
|
onNodeTouchStart={dragEnabled ? handleNodeTouchStart : undefined}
|
|
177
|
-
onNodeTouchEnd={dragEnabled ?
|
|
181
|
+
onNodeTouchEnd={dragEnabled ? handleNodeTouchEnd : undefined}
|
|
178
182
|
onItemLayout={dragEnabled ? handleItemLayout : undefined}
|
|
179
183
|
dragDropCustomizations={dragDropCustomizations}
|
|
180
184
|
/>
|
|
@@ -190,8 +194,8 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
190
194
|
dragEnabled,
|
|
191
195
|
isDragging,
|
|
192
196
|
handleNodeTouchStart,
|
|
197
|
+
handleNodeTouchEnd,
|
|
193
198
|
dragDropCustomizations,
|
|
194
|
-
cancelLongPressTimer,
|
|
195
199
|
handleItemLayout,
|
|
196
200
|
]);
|
|
197
201
|
|
|
@@ -237,8 +241,9 @@ function _NodeList<ID>(props: NodeListProps<ID>) {
|
|
|
237
241
|
{isDragging && draggedNode && (
|
|
238
242
|
<DragOverlay<ID>
|
|
239
243
|
overlayY={overlayY}
|
|
244
|
+
overlayX={overlayX}
|
|
240
245
|
node={draggedNode}
|
|
241
|
-
level={
|
|
246
|
+
level={effectiveDropLevel}
|
|
242
247
|
indentationMultiplier={effectiveIndentationMultiplier}
|
|
243
248
|
CheckboxComponent={CheckboxComponent}
|
|
244
249
|
ExpandCollapseIconComponent={ExpandCollapseIconComponent}
|
|
@@ -306,6 +311,7 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
306
311
|
isDragInvalid,
|
|
307
312
|
isDropTarget,
|
|
308
313
|
nodeDropPosition,
|
|
314
|
+
nodeDropLevel,
|
|
309
315
|
} = useTreeViewStore<ID>(storeId)(useShallow(
|
|
310
316
|
state => ({
|
|
311
317
|
isExpanded: state.expanded.has(node.id),
|
|
@@ -317,18 +323,38 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
317
323
|
isDragInvalid: state.invalidDragTargetIds.has(node.id),
|
|
318
324
|
isDropTarget: state.dropTargetNodeId === node.id,
|
|
319
325
|
nodeDropPosition: state.dropTargetNodeId === node.id ? state.dropPosition : null,
|
|
326
|
+
nodeDropLevel: state.dropTargetNodeId === node.id ? state.dropLevel : null,
|
|
320
327
|
})
|
|
321
328
|
));
|
|
322
329
|
|
|
330
|
+
// Track when this node was dragged so we can swallow the onPress/onCheck
|
|
331
|
+
// that fires when the user lifts their finger after a long-press-initiated drag.
|
|
332
|
+
// The flag is set during render (synchronous) and cleared on the next touch start.
|
|
333
|
+
// It is also cleared via effect when dragging ends, to prevent stale `true`
|
|
334
|
+
// values surviving FlashList recycling (where refs persist across items).
|
|
335
|
+
const wasDraggedRef = React.useRef(false);
|
|
336
|
+
if (isDraggingGlobal && isBeingDragged) {
|
|
337
|
+
wasDraggedRef.current = true;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
React.useEffect(() => {
|
|
341
|
+
if (!isDraggingGlobal) {
|
|
342
|
+
wasDraggedRef.current = false;
|
|
343
|
+
}
|
|
344
|
+
}, [isDraggingGlobal]);
|
|
345
|
+
|
|
323
346
|
const _onToggleExpand = React.useCallback(() => {
|
|
347
|
+
if (wasDraggedRef.current) return;
|
|
324
348
|
handleToggleExpand(storeId, node.id);
|
|
325
349
|
}, [storeId, node.id]);
|
|
326
350
|
|
|
327
351
|
const _onCheck = React.useCallback(() => {
|
|
352
|
+
if (wasDraggedRef.current) return;
|
|
328
353
|
toggleCheckboxes(storeId, [node.id]);
|
|
329
354
|
}, [storeId, node.id]);
|
|
330
355
|
|
|
331
356
|
const handleTouchStart = React.useCallback((e: any) => {
|
|
357
|
+
wasDraggedRef.current = false;
|
|
332
358
|
if (!onNodeTouchStart) return;
|
|
333
359
|
const { pageY, locationY } = e.nativeEvent;
|
|
334
360
|
onNodeTouchStart(node.id, pageY, locationY, nodeIndex);
|
|
@@ -355,10 +381,11 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
355
381
|
} : undefined;
|
|
356
382
|
|
|
357
383
|
const CustomDropIndicator = dragDropCustomizations?.CustomDropIndicatorComponent;
|
|
384
|
+
const indicatorLevel = nodeDropLevel ?? level;
|
|
358
385
|
const dropIndicator = isDropTarget && nodeDropPosition ? (
|
|
359
386
|
CustomDropIndicator
|
|
360
|
-
? <CustomDropIndicator position={nodeDropPosition} />
|
|
361
|
-
: <NodeDropIndicator position={nodeDropPosition} styleProps={dragDropCustomizations?.dropIndicatorStyleProps} />
|
|
387
|
+
? <CustomDropIndicator position={nodeDropPosition} level={indicatorLevel} indentationMultiplier={indentationMultiplier} />
|
|
388
|
+
: <NodeDropIndicator position={nodeDropPosition} level={indicatorLevel} indentationMultiplier={indentationMultiplier} styleProps={dragDropCustomizations?.dropIndicatorStyleProps} />
|
|
362
389
|
) : null;
|
|
363
390
|
|
|
364
391
|
if (!CustomNodeRowComponent) {
|
|
@@ -371,6 +398,7 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
371
398
|
styles.nodeCheckboxAndArrowRow,
|
|
372
399
|
{ paddingStart: level * indentationMultiplier },
|
|
373
400
|
{ opacity: nodeOpacity },
|
|
401
|
+
dropIndicator ? styles.nodeOverflowVisible : undefined,
|
|
374
402
|
]}>
|
|
375
403
|
{dropIndicator}
|
|
376
404
|
<CheckboxComponent
|
|
@@ -398,7 +426,10 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
398
426
|
<View
|
|
399
427
|
{...touchHandlers}
|
|
400
428
|
onLayout={onItemLayout ? handleLayout : undefined}
|
|
401
|
-
style={
|
|
429
|
+
style={[
|
|
430
|
+
{ opacity: nodeOpacity },
|
|
431
|
+
dropIndicator ? styles.nodeOverflowVisible : undefined,
|
|
432
|
+
]}
|
|
402
433
|
>
|
|
403
434
|
{dropIndicator}
|
|
404
435
|
<CustomNodeRowComponent
|
|
@@ -417,8 +448,10 @@ function _Node<ID>(props: NodeProps<ID>) {
|
|
|
417
448
|
}
|
|
418
449
|
};
|
|
419
450
|
|
|
420
|
-
function NodeDropIndicator({ position, styleProps }: {
|
|
451
|
+
function NodeDropIndicator({ position, level, indentationMultiplier, styleProps }: {
|
|
421
452
|
position: DropPosition;
|
|
453
|
+
level: number;
|
|
454
|
+
indentationMultiplier: number;
|
|
422
455
|
styleProps?: DropIndicatorStyleProps;
|
|
423
456
|
}) {
|
|
424
457
|
const lineColor = styleProps?.lineColor ?? "#0078FF";
|
|
@@ -427,6 +460,10 @@ function NodeDropIndicator({ position, styleProps }: {
|
|
|
427
460
|
const highlightColor = styleProps?.highlightColor ?? "rgba(0, 120, 255, 0.15)";
|
|
428
461
|
const highlightBorderColor = styleProps?.highlightBorderColor ?? "rgba(0, 120, 255, 0.5)";
|
|
429
462
|
|
|
463
|
+
// Indent the line to match the node's nesting level so users can
|
|
464
|
+
// visually distinguish drops at different tree depths.
|
|
465
|
+
const leftOffset = level * indentationMultiplier;
|
|
466
|
+
|
|
430
467
|
if (position === "inside") {
|
|
431
468
|
return (
|
|
432
469
|
<View
|
|
@@ -434,6 +471,7 @@ function NodeDropIndicator({ position, styleProps }: {
|
|
|
434
471
|
style={[
|
|
435
472
|
styles.dropHighlight,
|
|
436
473
|
{
|
|
474
|
+
left: leftOffset,
|
|
437
475
|
backgroundColor: highlightColor,
|
|
438
476
|
borderColor: highlightBorderColor,
|
|
439
477
|
},
|
|
@@ -442,26 +480,25 @@ function NodeDropIndicator({ position, styleProps }: {
|
|
|
442
480
|
);
|
|
443
481
|
}
|
|
444
482
|
|
|
483
|
+
// Ensure the circle isn't clipped at shallow indent levels
|
|
484
|
+
const safeLeftOffset = Math.max(leftOffset, circleSize / 2);
|
|
485
|
+
|
|
445
486
|
return (
|
|
446
487
|
<View
|
|
447
488
|
pointerEvents="none"
|
|
448
489
|
style={[
|
|
449
490
|
styles.dropLineContainer,
|
|
450
|
-
{ height: lineThickness },
|
|
491
|
+
{ height: lineThickness, left: safeLeftOffset },
|
|
451
492
|
position === "above" ? styles.dropLineTop : styles.dropLineBottom,
|
|
452
493
|
]}
|
|
453
494
|
>
|
|
454
|
-
<View style={
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
marginLeft: -(circleSize / 2),
|
|
462
|
-
marginTop: -(circleSize / 2 - lineThickness / 2),
|
|
463
|
-
},
|
|
464
|
-
]} />
|
|
495
|
+
<View style={{
|
|
496
|
+
width: circleSize,
|
|
497
|
+
height: circleSize,
|
|
498
|
+
borderRadius: circleSize / 2,
|
|
499
|
+
backgroundColor: lineColor,
|
|
500
|
+
marginLeft: -(circleSize / 2),
|
|
501
|
+
}} />
|
|
465
502
|
<View style={[
|
|
466
503
|
styles.dropLine,
|
|
467
504
|
{
|
|
@@ -510,6 +547,7 @@ const styles = StyleSheet.create({
|
|
|
510
547
|
alignItems: "center",
|
|
511
548
|
height: 3,
|
|
512
549
|
zIndex: 10,
|
|
550
|
+
overflow: "visible",
|
|
513
551
|
},
|
|
514
552
|
dropLineTop: {
|
|
515
553
|
top: 0,
|
|
@@ -517,17 +555,12 @@ const styles = StyleSheet.create({
|
|
|
517
555
|
dropLineBottom: {
|
|
518
556
|
bottom: 0,
|
|
519
557
|
},
|
|
520
|
-
dropLineCircle: {
|
|
521
|
-
width: 10,
|
|
522
|
-
height: 10,
|
|
523
|
-
borderRadius: 5,
|
|
524
|
-
backgroundColor: "#0078FF",
|
|
525
|
-
marginLeft: -5,
|
|
526
|
-
marginTop: -4,
|
|
527
|
-
},
|
|
528
558
|
dropLine: {
|
|
529
559
|
flex: 1,
|
|
530
560
|
height: 3,
|
|
531
561
|
backgroundColor: "#0078FF",
|
|
532
562
|
},
|
|
563
|
+
nodeOverflowVisible: {
|
|
564
|
+
overflow: "visible",
|
|
565
|
+
},
|
|
533
566
|
});
|
|
@@ -225,7 +225,7 @@ export function recalculateCheckedStates<ID>(storeId: string) {
|
|
|
225
225
|
const tempIndeterminate = new Set(indeterminate);
|
|
226
226
|
|
|
227
227
|
// Collect parent nodes and clean up leaf nodes that shouldn't be indeterminate.
|
|
228
|
-
// A leaf node (no children) can never be indeterminate
|
|
228
|
+
// A leaf node (no children) can never be indeterminate - this can happen when
|
|
229
229
|
// all children of a formerly-indeterminate parent are dragged away.
|
|
230
230
|
const parentNodes: ID[] = [];
|
|
231
231
|
for (const [id, node] of nodeMap) {
|