react-native-tree-multi-select 0.5.0
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/LICENSE +20 -0
- package/README.md +124 -0
- package/android/build.gradle +94 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/treemultiselect/TreeMultiSelectModule.kt +25 -0
- package/android/src/main/java/com/treemultiselect/TreeMultiSelectPackage.kt +17 -0
- package/ios/TreeMultiSelect-Bridging-Header.h +2 -0
- package/ios/TreeMultiSelect.mm +14 -0
- package/ios/TreeMultiSelect.swift +8 -0
- package/ios/TreeMultiSelect.xcodeproj/project.pbxproj +283 -0
- package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
- package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/xcuserdata/guest_jj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/TreeMultiSelect.xcodeproj/xcuserdata/guest_jj.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/lib/commonjs/TreeView.js +99 -0
- package/lib/commonjs/TreeView.js.map +1 -0
- package/lib/commonjs/components/CheckboxView.js +77 -0
- package/lib/commonjs/components/CheckboxView.js.map +1 -0
- package/lib/commonjs/components/CustomExpandCollapseIcon.js +20 -0
- package/lib/commonjs/components/CustomExpandCollapseIcon.js.map +1 -0
- package/lib/commonjs/components/NodeList.js +193 -0
- package/lib/commonjs/components/NodeList.js.map +1 -0
- package/lib/commonjs/helpers/expandCollapse.helper.js +93 -0
- package/lib/commonjs/helpers/expandCollapse.helper.js.map +1 -0
- package/lib/commonjs/helpers/index.js +61 -0
- package/lib/commonjs/helpers/index.js.map +1 -0
- package/lib/commonjs/helpers/initNodeMap.helper.js +44 -0
- package/lib/commonjs/helpers/initNodeMap.helper.js.map +1 -0
- package/lib/commonjs/helpers/search.helper.js +29 -0
- package/lib/commonjs/helpers/search.helper.js.map +1 -0
- package/lib/commonjs/helpers/selectAll.helper.js +73 -0
- package/lib/commonjs/helpers/selectAll.helper.js.map +1 -0
- package/lib/commonjs/helpers/toggleCheckbox.helper.js +153 -0
- package/lib/commonjs/helpers/toggleCheckbox.helper.js.map +1 -0
- package/lib/commonjs/index.js +28 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/signals/global.signals.js +42 -0
- package/lib/commonjs/signals/global.signals.js.map +1 -0
- package/lib/commonjs/types/treeView.types.js +6 -0
- package/lib/commonjs/types/treeView.types.js.map +1 -0
- package/lib/module/TreeView.js +89 -0
- package/lib/module/TreeView.js.map +1 -0
- package/lib/module/components/CheckboxView.js +68 -0
- package/lib/module/components/CheckboxView.js.map +1 -0
- package/lib/module/components/CustomExpandCollapseIcon.js +13 -0
- package/lib/module/components/CustomExpandCollapseIcon.js.map +1 -0
- package/lib/module/components/NodeList.js +185 -0
- package/lib/module/components/NodeList.js.map +1 -0
- package/lib/module/helpers/expandCollapse.helper.js +86 -0
- package/lib/module/helpers/expandCollapse.helper.js.map +1 -0
- package/lib/module/helpers/index.js +6 -0
- package/lib/module/helpers/index.js.map +1 -0
- package/lib/module/helpers/initNodeMap.helper.js +39 -0
- package/lib/module/helpers/initNodeMap.helper.js.map +1 -0
- package/lib/module/helpers/search.helper.js +23 -0
- package/lib/module/helpers/search.helper.js.map +1 -0
- package/lib/module/helpers/selectAll.helper.js +65 -0
- package/lib/module/helpers/selectAll.helper.js.map +1 -0
- package/lib/module/helpers/toggleCheckbox.helper.js +148 -0
- package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/signals/global.signals.js +26 -0
- package/lib/module/signals/global.signals.js.map +1 -0
- package/lib/module/types/treeView.types.js +2 -0
- package/lib/module/types/treeView.types.js.map +1 -0
- package/lib/typescript/TreeView.d.ts +4 -0
- package/lib/typescript/TreeView.d.ts.map +1 -0
- package/lib/typescript/components/CheckboxView.d.ts +24 -0
- package/lib/typescript/components/CheckboxView.d.ts.map +1 -0
- package/lib/typescript/components/CustomExpandCollapseIcon.d.ts +4 -0
- package/lib/typescript/components/CustomExpandCollapseIcon.d.ts.map +1 -0
- package/lib/typescript/components/NodeList.d.ts +14 -0
- package/lib/typescript/components/NodeList.d.ts.map +1 -0
- package/lib/typescript/helpers/expandCollapse.helper.d.ts +18 -0
- package/lib/typescript/helpers/expandCollapse.helper.d.ts.map +1 -0
- package/lib/typescript/helpers/index.d.ts +6 -0
- package/lib/typescript/helpers/index.d.ts.map +1 -0
- package/lib/typescript/helpers/initNodeMap.helper.d.ts +12 -0
- package/lib/typescript/helpers/initNodeMap.helper.d.ts.map +1 -0
- package/lib/typescript/helpers/search.helper.d.ts +14 -0
- package/lib/typescript/helpers/search.helper.d.ts.map +1 -0
- package/lib/typescript/helpers/selectAll.helper.d.ts +25 -0
- package/lib/typescript/helpers/selectAll.helper.d.ts.map +1 -0
- package/lib/typescript/helpers/toggleCheckbox.helper.d.ts +9 -0
- package/lib/typescript/helpers/toggleCheckbox.helper.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/signals/global.signals.d.ts +11 -0
- package/lib/typescript/signals/global.signals.d.ts.map +1 -0
- package/lib/typescript/types/treeView.types.d.ts +61 -0
- package/lib/typescript/types/treeView.types.d.ts.map +1 -0
- package/package.json +165 -0
- package/react-native-tree-multi-select.podspec +41 -0
- package/src/TreeView.tsx +139 -0
- package/src/components/CheckboxView.tsx +109 -0
- package/src/components/CustomExpandCollapseIcon.tsx +20 -0
- package/src/components/NodeList.tsx +278 -0
- package/src/helpers/expandCollapse.helper.ts +88 -0
- package/src/helpers/index.ts +5 -0
- package/src/helpers/initNodeMap.helper.ts +46 -0
- package/src/helpers/search.helper.ts +28 -0
- package/src/helpers/selectAll.helper.ts +59 -0
- package/src/helpers/toggleCheckbox.helper.ts +144 -0
- package/src/index.tsx +22 -0
- package/src/signals/global.signals.ts +36 -0
- package/src/types/treeView.types.ts +86 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TreeViewProps, TreeViewRef } from './types/treeView.types';
|
|
3
|
+
export declare const TreeView: React.MemoExoticComponent<React.ForwardRefExoticComponent<TreeViewProps & React.RefAttributes<TreeViewRef>>>;
|
|
4
|
+
//# sourceMappingURL=TreeView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeView.d.ts","sourceRoot":"","sources":["../../src/TreeView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAIN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAEV,aAAa,EACb,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAiIhC,eAAO,MAAM,QAAQ,8GAAwB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CheckBoxViewProps } from "../types/treeView.types";
|
|
3
|
+
export declare const CheckboxView: React.MemoExoticComponent<typeof _CheckboxView>;
|
|
4
|
+
declare function _CheckboxView(props: CheckBoxViewProps): React.JSX.Element;
|
|
5
|
+
export declare const defaultCheckboxViewStyles: {
|
|
6
|
+
mainView: {
|
|
7
|
+
alignSelf: "center";
|
|
8
|
+
alignItems: "center";
|
|
9
|
+
flexDirection: "row";
|
|
10
|
+
marginEnd: number;
|
|
11
|
+
};
|
|
12
|
+
checkboxView: {
|
|
13
|
+
marginStart: number;
|
|
14
|
+
transform: {
|
|
15
|
+
scale: number;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
checkboxTextStyle: {
|
|
19
|
+
color: string;
|
|
20
|
+
marginTop: number | undefined;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=CheckboxView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxView.d.ts","sourceRoot":"","sources":["../../../src/components/CheckboxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EACR,iBAAiB,EAEpB,MAAM,yBAAyB,CAAC;AAYjC,eAAO,MAAM,YAAY,iDAA2C,CAAC;AAErE,iBAAS,aAAa,CAAC,KAAK,EAAE,iBAAiB,qBA+D9C;AAED,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;CAgBpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomExpandCollapseIcon.d.ts","sourceRoot":"","sources":["../../../src/components/CustomExpandCollapseIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,KAAK,EAAE,eAAe,qBActE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type TouchableOpacityProps } from "react-native";
|
|
3
|
+
import type { TreeFlatListProps, ExpandIconProps, CheckBoxViewStyleProps, CheckBoxViewProps } from "../types/treeView.types";
|
|
4
|
+
interface NodeListProps {
|
|
5
|
+
treeFlashListProps?: TreeFlatListProps;
|
|
6
|
+
checkBoxViewStyleProps?: CheckBoxViewStyleProps;
|
|
7
|
+
CheckboxComponent?: React.ComponentType<CheckBoxViewProps>;
|
|
8
|
+
ExpandCollapseIconComponent?: React.ComponentType<ExpandIconProps>;
|
|
9
|
+
ExpandCollapseTouchableComponent?: React.ComponentType<TouchableOpacityProps>;
|
|
10
|
+
}
|
|
11
|
+
declare const NodeList: React.MemoExoticComponent<typeof _NodeList>;
|
|
12
|
+
export default NodeList;
|
|
13
|
+
declare function _NodeList(props: NodeListProps): React.JSX.Element;
|
|
14
|
+
//# sourceMappingURL=NodeList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeList.d.ts","sourceRoot":"","sources":["../../../src/components/NodeList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKH,KAAK,qBAAqB,EAC7B,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EACR,iBAAiB,EAIjB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EAEpB,MAAM,yBAAyB,CAAC;AAkBjC,UAAU,aAAa;IACnB,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IACvC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAEhD,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC3D,2BAA2B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;IACnE,gCAAgC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;CACjF;AAED,QAAA,MAAM,QAAQ,6CAAwB,CAAC;AACvC,eAAe,QAAQ,CAAC;AAExB,iBAAS,SAAS,CAAC,KAAK,EAAE,aAAa,qBAoHtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toggle the expanded state of a tree node by its ID.
|
|
3
|
+
*
|
|
4
|
+
* If the node is currently expanded, it and its descendants will be collapsed.
|
|
5
|
+
* If it is currently collapsed, it will be expanded.
|
|
6
|
+
*
|
|
7
|
+
* @param id - The ID of the tree node to toggle.
|
|
8
|
+
*/
|
|
9
|
+
export declare function handleToggleExpand(id: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* Expand all nodes in the tree.
|
|
12
|
+
*/
|
|
13
|
+
export declare function expandAll(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Collapse all nodes in the tree.
|
|
16
|
+
*/
|
|
17
|
+
export declare function collapseAll(): void;
|
|
18
|
+
//# sourceMappingURL=expandCollapse.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expandCollapse.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/expandCollapse.helper.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,QAsD5C;AAED;;GAEG;AACH,wBAAgB,SAAS,SAIxB;AAED;;GAEG;AACH,wBAAgB,WAAW,SAI1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TreeNode } from "../types/treeView.types";
|
|
2
|
+
/**
|
|
3
|
+
* Initialize the maps for tracking tree nodes and their parent-child relationships.
|
|
4
|
+
*
|
|
5
|
+
* This function is intended to be called once, during component initialization,
|
|
6
|
+
* with the initial tree data and any preselected node IDs.
|
|
7
|
+
*
|
|
8
|
+
* @param initialData - An array of TreeNode objects that represent the initial tree structure.
|
|
9
|
+
* @param preselectedIds - An optional array of TreeNode IDs that should be preselected.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initializeNodeMaps(initialData: TreeNode[], preselectedIds?: string[]): void;
|
|
12
|
+
//# sourceMappingURL=initNodeMap.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initNodeMap.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/initNodeMap.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAOxD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,WAAW,EAAE,QAAQ,EAAE,EACvB,cAAc,GAAE,MAAM,EAAO,QA2BhC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TreeNode } from "../types/treeView.types";
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a given tree node contains a specific search term in any of its specified keys.
|
|
4
|
+
*
|
|
5
|
+
* This function will check each of the specified keys in the tree node, convert the key's value to a string,
|
|
6
|
+
* and check if it includes the search term.
|
|
7
|
+
*
|
|
8
|
+
* @param node - The tree node to search through.
|
|
9
|
+
* @param searchTerm - The term to search for.
|
|
10
|
+
* @param searchKeys - The keys in the tree node to search in.
|
|
11
|
+
* @returns True if the search term is found in any of the specified keys, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function doesNodeContainSearchTerm(node: TreeNode, searchTerm: string, searchKeys: string[]): boolean;
|
|
14
|
+
//# sourceMappingURL=search.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/search.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACrC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAAE,GACrB,OAAO,CAUT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selects all nodes that are currently visible due to the applied filter.
|
|
3
|
+
*
|
|
4
|
+
* If there is no search text, then it selects all nodes; otherwise, it selects all visible nodes.
|
|
5
|
+
*/
|
|
6
|
+
export declare function selectAllFiltered(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Unselects all nodes that are currently visible due to the applied filter.
|
|
9
|
+
*
|
|
10
|
+
* If there is no search text, then it unselects all nodes; otherwise, it unselects all visible nodes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function unselectAllFiltered(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Selects all nodes in the tree.
|
|
15
|
+
*
|
|
16
|
+
* This function selects all nodes by adding all node ids to the checked set and clearing the indeterminate set.
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectAll(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Unselects all nodes in the tree.
|
|
21
|
+
*
|
|
22
|
+
* This function unselects all nodes by clearing both the checked and indeterminate sets.
|
|
23
|
+
*/
|
|
24
|
+
export declare function unselectAll(): void;
|
|
25
|
+
//# sourceMappingURL=selectAll.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectAll.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/selectAll.helper.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,wBAAgB,iBAAiB,SAQhC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,SAQlC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,SAKxB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,SAG1B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to toggle checkbox state for a tree structure.
|
|
3
|
+
* It sets the checked and indeterminate state for all affected nodes in the tree after an action to check/uncheck is made.
|
|
4
|
+
* @param {string[]} ids - The ids of nodes that need to be checked or unchecked.
|
|
5
|
+
* @param {boolean} [forceCheck] - Optional. If provided, will force the check state of the nodes to be this value.
|
|
6
|
+
* If not provided, the check state will be toggled based on the current state.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toggleCheckboxes(ids: string[], forceCheck?: boolean): void;
|
|
9
|
+
//# sourceMappingURL=toggleCheckbox.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggleCheckbox.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/toggleCheckbox.helper.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,OAAO,QAsInE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TreeNode, TreeViewProps, TreeViewRef, TreeFlatListProps, ExpandIconProps, CheckBoxViewProps, CheckBoxViewStyleProps } from "./types/treeView.types";
|
|
2
|
+
export * from "./TreeView";
|
|
3
|
+
export * from "./components/CheckboxView";
|
|
4
|
+
export type { TreeNode, TreeViewProps, TreeViewRef, TreeFlatListProps, ExpandIconProps, CheckBoxViewProps, CheckBoxViewStyleProps };
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAE1C,YAAY,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACzB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TreeNode, __CheckBoxState__ } from "src/types/treeView.types";
|
|
2
|
+
export declare const state: import("@preact/signals-core").Signal<__CheckBoxState__>;
|
|
3
|
+
export declare const expanded: import("@preact/signals-core").Signal<Set<string>>;
|
|
4
|
+
export declare const globalData: import("@preact/signals-core").Signal<TreeNode[]>;
|
|
5
|
+
export declare const nodeMap: import("@preact/signals-core").Signal<Map<string, TreeNode>>;
|
|
6
|
+
export declare const childToParentMap: import("@preact/signals-core").Signal<Map<string, string>>;
|
|
7
|
+
export declare const searchText: import("@preact/signals-core").Signal<string>;
|
|
8
|
+
export declare const searchKeys: import("@preact/signals-core").Signal<string[]>;
|
|
9
|
+
export declare const innerMostChildrenIds: import("@preact/signals-core").Signal<string[]>;
|
|
10
|
+
export declare function cleanUpGlobalSignals(): void;
|
|
11
|
+
//# sourceMappingURL=global.signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.signals.d.ts","sourceRoot":"","sources":["../../../src/signals/global.signals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,eAAO,MAAM,KAAK,0DAGhB,CAAC;AACH,eAAO,MAAM,QAAQ,oDAA4B,CAAC;AAElD,eAAO,MAAM,UAAU,mDAAyB,CAAC;AAEjD,eAAO,MAAM,OAAO,8DAAsC,CAAC;AAC3D,eAAO,MAAM,gBAAgB,4DAAoC,CAAC;AAElE,eAAO,MAAM,UAAU,+CAAa,CAAC;AACrC,eAAO,MAAM,UAAU,iDAAyB,CAAC;AAEjD,eAAO,MAAM,oBAAoB,iDAAuB,CAAC;AAEzD,wBAAgB,oBAAoB,SAgBnC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StyleProp, TextProps, TouchableOpacityProps, ViewStyle } from "react-native";
|
|
3
|
+
import type { FlashListProps } from "@shopify/flash-list";
|
|
4
|
+
import { type Props as RNPaperCheckboxAndroidProps } from 'react-native-paper/src/components/Checkbox/CheckboxAndroid';
|
|
5
|
+
export type CheckboxValueType = boolean | 'indeterminate';
|
|
6
|
+
export interface ExpandIconProps {
|
|
7
|
+
isExpanded: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type __CheckBoxState__ = {
|
|
10
|
+
checked: Set<string>;
|
|
11
|
+
indeterminate: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
export interface TreeNode {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
children?: TreeNode[];
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export interface __FlattenedTreeNode__ {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
children?: TreeNode[];
|
|
23
|
+
level?: number;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
export type TreeFlatListProps<ItemT = any> = Omit<FlashListProps<ItemT>, "data" | "renderItem" | "keyExtractor">;
|
|
27
|
+
export interface TreeViewProps {
|
|
28
|
+
data: TreeNode[];
|
|
29
|
+
onCheck?: (checkedIds: string[]) => void;
|
|
30
|
+
onExpand?: (expandedIds: string[]) => void;
|
|
31
|
+
preselectedIds?: string[];
|
|
32
|
+
treeFlashListProps?: TreeFlatListProps;
|
|
33
|
+
checkBoxViewStyleProps?: CheckBoxViewStyleProps;
|
|
34
|
+
CheckboxComponent?: React.ComponentType<CheckBoxViewProps>;
|
|
35
|
+
ExpandCollapseIconComponent?: React.ComponentType<ExpandIconProps>;
|
|
36
|
+
ExpandCollapseTouchableComponent?: React.ComponentType<TouchableOpacityProps>;
|
|
37
|
+
}
|
|
38
|
+
type CheckboxProps = Omit<RNPaperCheckboxAndroidProps, "onPress" | "status">;
|
|
39
|
+
export interface CheckBoxViewProps extends CheckBoxViewStyleProps {
|
|
40
|
+
value: CheckboxValueType;
|
|
41
|
+
onValueChange: (value: boolean) => void;
|
|
42
|
+
text: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CheckBoxViewStyleProps {
|
|
45
|
+
outermostParentViewStyle?: StyleProp<ViewStyle> | {};
|
|
46
|
+
checkboxParentViewStyle?: StyleProp<ViewStyle> | {};
|
|
47
|
+
textTouchableStyle?: StyleProp<ViewStyle> | {};
|
|
48
|
+
checkboxProps?: CheckboxProps;
|
|
49
|
+
textProps?: TextProps;
|
|
50
|
+
}
|
|
51
|
+
export interface TreeViewRef {
|
|
52
|
+
selectAll: () => void;
|
|
53
|
+
unselectAll: () => void;
|
|
54
|
+
selectAllFiltered: () => void;
|
|
55
|
+
unselectAllFiltered: () => void;
|
|
56
|
+
expandAll: () => void;
|
|
57
|
+
collapseAll: () => void;
|
|
58
|
+
setSearchText: (searchText: string, searchKeys?: string[]) => void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=treeView.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeView.types.d.ts","sourceRoot":"","sources":["../../../src/types/treeView.types.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-tree-multi-select",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Tree view with multi selection using checkbox",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"module": "lib/module/index",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index",
|
|
9
|
+
"source": "src/index",
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"lib",
|
|
13
|
+
"android",
|
|
14
|
+
"ios",
|
|
15
|
+
"cpp",
|
|
16
|
+
"*.podspec",
|
|
17
|
+
"!lib/typescript/example",
|
|
18
|
+
"!ios/build",
|
|
19
|
+
"!android/build",
|
|
20
|
+
"!android/gradle",
|
|
21
|
+
"!android/gradlew",
|
|
22
|
+
"!android/gradlew.bat",
|
|
23
|
+
"!android/local.properties",
|
|
24
|
+
"!**/__tests__",
|
|
25
|
+
"!**/__fixtures__",
|
|
26
|
+
"!**/__mocks__",
|
|
27
|
+
"!**/.*"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
|
+
"prepack": "bob build",
|
|
34
|
+
"release": "release-it",
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
|
|
37
|
+
"build:ios": "cd example/ios && xcodebuild -workspace TreeMultiSelectExample.xcworkspace -scheme TreeMultiSelectExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
|
|
38
|
+
"bootstrap": "yarn example && yarn install && yarn example pods",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"react-native",
|
|
43
|
+
"ios",
|
|
44
|
+
"android"
|
|
45
|
+
],
|
|
46
|
+
"repository": "https://github.com/JairajJangle/react-native-tree-multi-select",
|
|
47
|
+
"author": "Jairaj Jangle <jairaj.jangle@gmail.com> (https://github.com/JairajJangle)",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/JairajJangle/react-native-tree-multi-select/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/JairajJangle/react-native-tree-multi-select#readme",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
58
|
+
"@evilmartians/lefthook": "^1.2.2",
|
|
59
|
+
"@react-native-community/eslint-config": "^3.0.2",
|
|
60
|
+
"@release-it/conventional-changelog": "^5.0.0",
|
|
61
|
+
"@types/color": "^3.0.3",
|
|
62
|
+
"@types/jest": "^28.1.2",
|
|
63
|
+
"@types/react": "~17.0.21",
|
|
64
|
+
"@types/react-native": "0.70.0",
|
|
65
|
+
"@types/react-native-vector-icons": "^6.4.13",
|
|
66
|
+
"commitlint": "^17.0.2",
|
|
67
|
+
"del-cli": "^5.0.0",
|
|
68
|
+
"eslint": "^8.4.1",
|
|
69
|
+
"eslint-config-prettier": "^8.5.0",
|
|
70
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
71
|
+
"jest": "^28.1.1",
|
|
72
|
+
"pod-install": "^0.1.0",
|
|
73
|
+
"prettier": "^2.0.5",
|
|
74
|
+
"react": "18.2.0",
|
|
75
|
+
"react-native": "0.72.1",
|
|
76
|
+
"react-native-builder-bob": "^0.20.0",
|
|
77
|
+
"release-it": "^15.0.0",
|
|
78
|
+
"turbo": "^1.10.7",
|
|
79
|
+
"typescript": "^5.0.2"
|
|
80
|
+
},
|
|
81
|
+
"resolutions": {
|
|
82
|
+
"@types/react": "17.0.21"
|
|
83
|
+
},
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"@shopify/flash-list": "^1.2.0",
|
|
86
|
+
"react": "*",
|
|
87
|
+
"react-native": "*"
|
|
88
|
+
},
|
|
89
|
+
"engines": {
|
|
90
|
+
"node": ">= 16.0.0"
|
|
91
|
+
},
|
|
92
|
+
"packageManager": "^yarn@1.22.15",
|
|
93
|
+
"jest": {
|
|
94
|
+
"preset": "react-native",
|
|
95
|
+
"modulePathIgnorePatterns": [
|
|
96
|
+
"<rootDir>/example/node_modules",
|
|
97
|
+
"<rootDir>/lib/"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
"commitlint": {
|
|
101
|
+
"extends": [
|
|
102
|
+
"@commitlint/config-conventional"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"release-it": {
|
|
106
|
+
"git": {
|
|
107
|
+
"commitMessage": "chore: release ${version}",
|
|
108
|
+
"tagName": "v${version}"
|
|
109
|
+
},
|
|
110
|
+
"npm": {
|
|
111
|
+
"publish": true
|
|
112
|
+
},
|
|
113
|
+
"github": {
|
|
114
|
+
"release": true
|
|
115
|
+
},
|
|
116
|
+
"plugins": {
|
|
117
|
+
"@release-it/conventional-changelog": {
|
|
118
|
+
"preset": "angular"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"eslintConfig": {
|
|
123
|
+
"root": true,
|
|
124
|
+
"extends": [
|
|
125
|
+
"@react-native-community",
|
|
126
|
+
"prettier"
|
|
127
|
+
],
|
|
128
|
+
"rules": {
|
|
129
|
+
"prettier/prettier": "off"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"eslintIgnore": [
|
|
133
|
+
"node_modules/",
|
|
134
|
+
"lib/"
|
|
135
|
+
],
|
|
136
|
+
"prettier": {
|
|
137
|
+
"quoteProps": "consistent",
|
|
138
|
+
"singleQuote": true,
|
|
139
|
+
"tabWidth": 2,
|
|
140
|
+
"trailingComma": "es5",
|
|
141
|
+
"useTabs": false
|
|
142
|
+
},
|
|
143
|
+
"react-native-builder-bob": {
|
|
144
|
+
"source": "src",
|
|
145
|
+
"output": "lib",
|
|
146
|
+
"targets": [
|
|
147
|
+
"commonjs",
|
|
148
|
+
"module",
|
|
149
|
+
[
|
|
150
|
+
"typescript",
|
|
151
|
+
{
|
|
152
|
+
"project": "tsconfig.build.json"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
"dependencies": {
|
|
158
|
+
"@preact/signals-react": "1.2.1",
|
|
159
|
+
"@shopify/flash-list": "^1.4.3",
|
|
160
|
+
"react-native-gesture-handler": "^2.12.0",
|
|
161
|
+
"react-native-paper": "^5.9.1",
|
|
162
|
+
"react-native-safe-area-context": "^4.6.4",
|
|
163
|
+
"react-native-vector-icons": "^9.2.0"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "react-native-tree-multi-select"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platforms = { :ios => "11.0" }
|
|
15
|
+
s.source = { :git => "https://github.com/JairajJangle/react-native-tree-multi-select.git", :tag => "#{s.version}" }
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
+
|
|
19
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
21
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
22
|
+
install_modules_dependencies(s)
|
|
23
|
+
else
|
|
24
|
+
s.dependency "React-Core"
|
|
25
|
+
|
|
26
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
27
|
+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
|
|
28
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
29
|
+
s.pod_target_xcconfig = {
|
|
30
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
31
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
32
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
33
|
+
}
|
|
34
|
+
s.dependency "React-Codegen"
|
|
35
|
+
s.dependency "RCT-Folly"
|
|
36
|
+
s.dependency "RCTRequired"
|
|
37
|
+
s.dependency "RCTTypeSafety"
|
|
38
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
package/src/TreeView.tsx
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
} from 'react';
|
|
6
|
+
import type {
|
|
7
|
+
TreeNode,
|
|
8
|
+
TreeViewProps,
|
|
9
|
+
TreeViewRef
|
|
10
|
+
} from './types/treeView.types';
|
|
11
|
+
import NodeList from './components/NodeList';
|
|
12
|
+
import {
|
|
13
|
+
selectAll,
|
|
14
|
+
selectAllFiltered,
|
|
15
|
+
unselectAll,
|
|
16
|
+
unselectAllFiltered,
|
|
17
|
+
initializeNodeMaps,
|
|
18
|
+
expandAll,
|
|
19
|
+
collapseAll
|
|
20
|
+
} from './helpers';
|
|
21
|
+
import { effect } from "@preact/signals-react";
|
|
22
|
+
import {
|
|
23
|
+
cleanUpGlobalSignals,
|
|
24
|
+
expanded,
|
|
25
|
+
globalData,
|
|
26
|
+
searchKeys,
|
|
27
|
+
searchText,
|
|
28
|
+
state
|
|
29
|
+
} from './signals/global.signals';
|
|
30
|
+
import { InteractionManager } from 'react-native';
|
|
31
|
+
|
|
32
|
+
const _TreeView = forwardRef<TreeViewRef, TreeViewProps>(
|
|
33
|
+
(props, ref) => {
|
|
34
|
+
const {
|
|
35
|
+
data,
|
|
36
|
+
|
|
37
|
+
onCheck,
|
|
38
|
+
onExpand,
|
|
39
|
+
|
|
40
|
+
preselectedIds,
|
|
41
|
+
|
|
42
|
+
treeFlashListProps,
|
|
43
|
+
checkBoxViewStyleProps,
|
|
44
|
+
|
|
45
|
+
CheckboxComponent,
|
|
46
|
+
ExpandCollapseIconComponent,
|
|
47
|
+
ExpandCollapseTouchableComponent
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
useImperativeHandle(ref, () => ({
|
|
51
|
+
selectAll,
|
|
52
|
+
unselectAll,
|
|
53
|
+
|
|
54
|
+
selectAllFiltered,
|
|
55
|
+
unselectAllFiltered,
|
|
56
|
+
|
|
57
|
+
expandAll,
|
|
58
|
+
collapseAll,
|
|
59
|
+
|
|
60
|
+
setSearchText
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
function setSearchText(text: string, keys: string[] = ["name"]) {
|
|
64
|
+
searchText.value = text;
|
|
65
|
+
searchKeys.value = keys;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
globalData.value = data;
|
|
70
|
+
initializeNodeMaps(
|
|
71
|
+
data,
|
|
72
|
+
preselectedIds,
|
|
73
|
+
);
|
|
74
|
+
}, [data, preselectedIds]);
|
|
75
|
+
|
|
76
|
+
const disposeCheckedStateEffect = React.useMemo(() => {
|
|
77
|
+
return effect(() => {
|
|
78
|
+
onCheck && onCheck(Array.from(state.value.checked));
|
|
79
|
+
});
|
|
80
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const disposeExpandedStateEffect = React.useMemo(() => {
|
|
84
|
+
return effect(() => {
|
|
85
|
+
onExpand && onExpand(Array.from(expanded.value));
|
|
86
|
+
});
|
|
87
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
const disposeSearchStateEffect = React.useMemo(() => {
|
|
91
|
+
return effect(() => {
|
|
92
|
+
if (searchText.value) {
|
|
93
|
+
InteractionManager.runAfterInteractions(() => {
|
|
94
|
+
expanded.value = (new Set(globalData.value.flatMap((item) => getIds(item))));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
InteractionManager.runAfterInteractions(() => {
|
|
99
|
+
expanded.value = (new Set());
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
return () => {
|
|
108
|
+
// Cleanup all global signals and signal effects
|
|
109
|
+
disposeCheckedStateEffect();
|
|
110
|
+
disposeExpandedStateEffect();
|
|
111
|
+
disposeSearchStateEffect();
|
|
112
|
+
|
|
113
|
+
cleanUpGlobalSignals();
|
|
114
|
+
};
|
|
115
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
const getIds = React.useCallback((node: TreeNode): string[] => {
|
|
119
|
+
if (!node.children || node.children.length === 0) {
|
|
120
|
+
return [node.id];
|
|
121
|
+
} else {
|
|
122
|
+
return [node.id, ...node.children.flatMap((item) => getIds(item))];
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<NodeList
|
|
128
|
+
treeFlashListProps={treeFlashListProps}
|
|
129
|
+
checkBoxViewStyleProps={checkBoxViewStyleProps}
|
|
130
|
+
|
|
131
|
+
CheckboxComponent={CheckboxComponent}
|
|
132
|
+
ExpandCollapseIconComponent={ExpandCollapseIconComponent}
|
|
133
|
+
ExpandCollapseTouchableComponent={ExpandCollapseTouchableComponent}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
export const TreeView = React.memo(_TreeView);
|