react-native-tree-multi-select 1.8.0 → 1.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -24
- package/lib/commonjs/TreeView.js +17 -6
- package/lib/commonjs/TreeView.js.map +1 -1
- package/lib/commonjs/components/NodeList.js +26 -10
- package/lib/commonjs/components/NodeList.js.map +1 -1
- package/lib/commonjs/handlers/ScrollToNodeHandler.js +169 -0
- package/lib/commonjs/handlers/ScrollToNodeHandler.js.map +1 -0
- package/lib/commonjs/helpers/expandCollapse.helper.js +7 -1
- package/lib/commonjs/helpers/expandCollapse.helper.js.map +1 -1
- package/lib/module/TreeView.js +18 -5
- package/lib/module/TreeView.js.map +1 -1
- package/lib/module/components/NodeList.js +27 -11
- package/lib/module/components/NodeList.js.map +1 -1
- package/lib/module/handlers/ScrollToNodeHandler.js +165 -0
- package/lib/module/handlers/ScrollToNodeHandler.js.map +1 -0
- package/lib/module/helpers/expandCollapse.helper.js +7 -1
- package/lib/module/helpers/expandCollapse.helper.js.map +1 -1
- package/lib/typescript/TreeView.d.ts.map +1 -1
- package/lib/typescript/components/NodeList.d.ts.map +1 -1
- package/lib/typescript/handlers/ScrollToNodeHandler.d.ts +58 -0
- package/lib/typescript/handlers/ScrollToNodeHandler.d.ts.map +1 -0
- package/lib/typescript/helpers/expandCollapse.helper.d.ts +3 -1
- package/lib/typescript/helpers/expandCollapse.helper.d.ts.map +1 -1
- package/lib/typescript/types/treeView.types.d.ts +6 -1
- package/lib/typescript/types/treeView.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TreeView.tsx +182 -152
- package/src/components/NodeList.tsx +31 -11
- package/src/handlers/ScrollToNodeHandler.tsx +222 -0
- package/src/helpers/expandCollapse.helper.ts +16 -1
- package/src/types/treeView.types.ts +15 -1
|
@@ -71,14 +71,29 @@ export function collapseAll(storeId: string) {
|
|
|
71
71
|
* Expand tree nodes of given ids. If the id is of a child, it also expands
|
|
72
72
|
* its ancestors up to the root.
|
|
73
73
|
* @param ids - Ids of nodes to expand.
|
|
74
|
+
* @param _doNotExpandToShowChildren - If true, the function will not expand the ids to prevent
|
|
75
|
+
* from showing their children.
|
|
74
76
|
*/
|
|
75
|
-
export function expandNodes<ID>(
|
|
77
|
+
export function expandNodes<ID>(
|
|
78
|
+
storeId: string,
|
|
79
|
+
ids: ID[],
|
|
80
|
+
_doNotExpandToShowChildren: boolean = false,
|
|
81
|
+
) {
|
|
76
82
|
const treeViewStore = getTreeViewStore<ID>(storeId);
|
|
77
83
|
const { expanded, updateExpanded, childToParentMap } = treeViewStore.getState();
|
|
78
84
|
const newExpanded = new Set(expanded);
|
|
79
85
|
const processedIds = new Set<ID>();
|
|
80
86
|
|
|
81
87
|
ids.forEach((id) => {
|
|
88
|
+
if (_doNotExpandToShowChildren) {
|
|
89
|
+
const parentId = childToParentMap.get(id);
|
|
90
|
+
|
|
91
|
+
if (parentId === undefined)
|
|
92
|
+
return;
|
|
93
|
+
else
|
|
94
|
+
id = parentId;
|
|
95
|
+
}
|
|
96
|
+
|
|
82
97
|
let currentId: ID | undefined = id;
|
|
83
98
|
while (currentId && !processedIds.has(currentId)) {
|
|
84
99
|
newExpanded.add(currentId);
|
|
@@ -8,6 +8,10 @@ import type { FlashListProps } from "@shopify/flash-list";
|
|
|
8
8
|
import {
|
|
9
9
|
type Props as RNPaperCheckboxAndroidProps
|
|
10
10
|
} from 'react-native-paper/src/components/Checkbox/CheckboxAndroid';
|
|
11
|
+
import {
|
|
12
|
+
ScrollToNodeHandlerRef,
|
|
13
|
+
ScrollToNodeParams
|
|
14
|
+
} from "../handlers/ScrollToNodeHandler";
|
|
11
15
|
|
|
12
16
|
export type CheckboxValueType = boolean | 'indeterminate';
|
|
13
17
|
|
|
@@ -64,10 +68,16 @@ export interface NodeProps<ID> extends TreeItemCustomizations<ID> {
|
|
|
64
68
|
|
|
65
69
|
export interface NodeListProps<ID> extends TreeItemCustomizations<ID> {
|
|
66
70
|
treeFlashListProps?: TreeFlatListProps;
|
|
71
|
+
|
|
72
|
+
scrollToNodeHandlerRef: React.RefObject<ScrollToNodeHandlerRef<ID>>;
|
|
73
|
+
initialScrollNodeID?: ID;
|
|
74
|
+
|
|
67
75
|
storeId: string;
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
export interface TreeViewProps<ID = string> extends Omit<
|
|
78
|
+
export interface TreeViewProps<ID = string> extends Omit<
|
|
79
|
+
NodeListProps<ID>, "storeId" | "scrollToNodeHandlerRef"
|
|
80
|
+
> {
|
|
71
81
|
data: TreeNode<ID>[];
|
|
72
82
|
|
|
73
83
|
onCheck?: (checkedIds: ID[], indeterminateIds: ID[]) => void;
|
|
@@ -120,6 +130,10 @@ export interface TreeViewRef<ID = string> {
|
|
|
120
130
|
unselectNodes: (ids: ID[]) => void;
|
|
121
131
|
|
|
122
132
|
setSearchText: (searchText: string, searchKeys?: string[]) => void;
|
|
133
|
+
|
|
134
|
+
scrollToNodeID: (scrollToNodeParams: ScrollToNodeParams<ID>) => void;
|
|
135
|
+
|
|
136
|
+
getChildToParentMap: () => Map<ID, ID>;
|
|
123
137
|
}
|
|
124
138
|
|
|
125
139
|
export interface SelectionPropagation {
|