react-native-tree-multi-select 1.9.4 → 2.0.0-beta.2

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.
Files changed (144) hide show
  1. package/README.md +6 -5
  2. package/lib/module/TreeView.js +8 -9
  3. package/lib/module/TreeView.js.map +1 -1
  4. package/lib/module/components/CheckboxView.js +4 -4
  5. package/lib/module/components/CheckboxView.js.map +1 -1
  6. package/lib/module/components/CustomExpandCollapseIcon.js +22 -1
  7. package/lib/module/components/CustomExpandCollapseIcon.js.map +1 -1
  8. package/lib/module/components/NodeList.js +7 -7
  9. package/lib/module/components/NodeList.js.map +1 -1
  10. package/lib/module/handlers/ScrollToNodeHandler.js +3 -3
  11. package/lib/module/handlers/ScrollToNodeHandler.js.map +1 -1
  12. package/lib/module/helpers/expandCollapse.helper.js +1 -1
  13. package/lib/module/helpers/expandCollapse.helper.js.map +1 -1
  14. package/lib/module/helpers/flattenTree.helper.js.map +1 -1
  15. package/lib/module/helpers/index.js +6 -6
  16. package/lib/module/helpers/index.js.map +1 -1
  17. package/lib/module/helpers/selectAll.helper.js +2 -2
  18. package/lib/module/helpers/selectAll.helper.js.map +1 -1
  19. package/lib/module/helpers/toggleCheckbox.helper.js +1 -1
  20. package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -1
  21. package/lib/module/helpers/treeNode.helper.js +30 -24
  22. package/lib/module/helpers/treeNode.helper.js.map +1 -1
  23. package/lib/module/index.js +2 -2
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/store/treeView.store.js.map +1 -1
  26. package/lib/typescript/package.json +1 -0
  27. package/lib/typescript/{TreeView.d.ts → src/TreeView.d.ts} +1 -1
  28. package/lib/typescript/src/TreeView.d.ts.map +1 -0
  29. package/lib/typescript/{components → src/components}/CheckboxView.d.ts +1 -1
  30. package/lib/typescript/src/components/CheckboxView.d.ts.map +1 -0
  31. package/lib/typescript/{components → src/components}/CustomExpandCollapseIcon.d.ts +2 -2
  32. package/lib/typescript/src/components/CustomExpandCollapseIcon.d.ts.map +1 -0
  33. package/lib/typescript/src/components/NodeList.d.ts +5 -0
  34. package/lib/typescript/src/components/NodeList.d.ts.map +1 -0
  35. package/lib/typescript/src/constants/tests.constants.d.ts.map +1 -0
  36. package/lib/typescript/src/constants/treeView.constants.d.ts.map +1 -0
  37. package/lib/typescript/{handlers → src/handlers}/ScrollToNodeHandler.d.ts +1 -1
  38. package/lib/typescript/src/handlers/ScrollToNodeHandler.d.ts.map +1 -0
  39. package/lib/typescript/src/helpers/expandCollapse.helper.d.ts.map +1 -0
  40. package/lib/typescript/{helpers → src/helpers}/flattenTree.helper.d.ts +1 -1
  41. package/lib/typescript/src/helpers/flattenTree.helper.d.ts.map +1 -0
  42. package/lib/typescript/src/helpers/index.d.ts.map +1 -0
  43. package/lib/typescript/{helpers → src/helpers}/search.helper.d.ts +1 -1
  44. package/lib/typescript/src/helpers/search.helper.d.ts.map +1 -0
  45. package/lib/typescript/{helpers → src/helpers}/selectAll.helper.d.ts +1 -1
  46. package/lib/typescript/src/helpers/selectAll.helper.d.ts.map +1 -0
  47. package/lib/typescript/src/helpers/toggleCheckbox.helper.d.ts.map +1 -0
  48. package/lib/typescript/{helpers → src/helpers}/treeNode.helper.d.ts +1 -1
  49. package/lib/typescript/src/helpers/treeNode.helper.d.ts.map +1 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/lib/typescript/src/jest.setup.d.ts.map +1 -0
  52. package/lib/typescript/{store → src/store}/treeView.store.d.ts +2 -2
  53. package/lib/typescript/src/store/treeView.store.d.ts.map +1 -0
  54. package/lib/typescript/{types → src/types}/treeView.types.d.ts +3 -3
  55. package/lib/typescript/src/types/treeView.types.d.ts.map +1 -0
  56. package/lib/typescript/src/utils/typedMemo.d.ts.map +1 -0
  57. package/lib/typescript/src/utils/useDeepCompareEffect.d.ts.map +1 -0
  58. package/lib/typescript/src/utils/usePreviousState.d.ts.map +1 -0
  59. package/package.json +30 -25
  60. package/src/TreeView.tsx +3 -4
  61. package/src/components/CheckboxView.tsx +4 -4
  62. package/src/components/CustomExpandCollapseIcon.tsx +25 -2
  63. package/src/handlers/ScrollToNodeHandler.tsx +1 -1
  64. package/src/helpers/flattenTree.helper.ts +4 -1
  65. package/src/helpers/search.helper.ts +1 -1
  66. package/src/helpers/selectAll.helper.ts +1 -1
  67. package/src/helpers/treeNode.helper.ts +32 -38
  68. package/src/store/treeView.store.ts +2 -2
  69. package/src/types/treeView.types.ts +3 -5
  70. package/lib/commonjs/TreeView.js +0 -154
  71. package/lib/commonjs/TreeView.js.map +0 -1
  72. package/lib/commonjs/components/CheckboxView.js +0 -82
  73. package/lib/commonjs/components/CheckboxView.js.map +0 -1
  74. package/lib/commonjs/components/CustomExpandCollapseIcon.js +0 -22
  75. package/lib/commonjs/components/CustomExpandCollapseIcon.js.map +0 -1
  76. package/lib/commonjs/components/NodeList.js +0 -188
  77. package/lib/commonjs/components/NodeList.js.map +0 -1
  78. package/lib/commonjs/constants/tests.constants.js +0 -8
  79. package/lib/commonjs/constants/tests.constants.js.map +0 -1
  80. package/lib/commonjs/constants/treeView.constants.js +0 -8
  81. package/lib/commonjs/constants/treeView.constants.js.map +0 -1
  82. package/lib/commonjs/handlers/ScrollToNodeHandler.js +0 -169
  83. package/lib/commonjs/handlers/ScrollToNodeHandler.js.map +0 -1
  84. package/lib/commonjs/helpers/expandCollapse.helper.js +0 -147
  85. package/lib/commonjs/helpers/expandCollapse.helper.js.map +0 -1
  86. package/lib/commonjs/helpers/flattenTree.helper.js +0 -66
  87. package/lib/commonjs/helpers/flattenTree.helper.js.map +0 -1
  88. package/lib/commonjs/helpers/index.js +0 -72
  89. package/lib/commonjs/helpers/index.js.map +0 -1
  90. package/lib/commonjs/helpers/search.helper.js +0 -65
  91. package/lib/commonjs/helpers/search.helper.js.map +0 -1
  92. package/lib/commonjs/helpers/selectAll.helper.js +0 -117
  93. package/lib/commonjs/helpers/selectAll.helper.js.map +0 -1
  94. package/lib/commonjs/helpers/toggleCheckbox.helper.js +0 -192
  95. package/lib/commonjs/helpers/toggleCheckbox.helper.js.map +0 -1
  96. package/lib/commonjs/helpers/treeNode.helper.js +0 -48
  97. package/lib/commonjs/helpers/treeNode.helper.js.map +0 -1
  98. package/lib/commonjs/index.js +0 -28
  99. package/lib/commonjs/index.js.map +0 -1
  100. package/lib/commonjs/jest.setup.js +0 -4
  101. package/lib/commonjs/jest.setup.js.map +0 -1
  102. package/lib/commonjs/package.json +0 -1
  103. package/lib/commonjs/store/treeView.store.js +0 -86
  104. package/lib/commonjs/store/treeView.store.js.map +0 -1
  105. package/lib/commonjs/types/treeView.types.js +0 -6
  106. package/lib/commonjs/types/treeView.types.js.map +0 -1
  107. package/lib/commonjs/utils/typedMemo.js +0 -11
  108. package/lib/commonjs/utils/typedMemo.js.map +0 -1
  109. package/lib/commonjs/utils/useDeepCompareEffect.js +0 -40
  110. package/lib/commonjs/utils/useDeepCompareEffect.js.map +0 -1
  111. package/lib/commonjs/utils/usePreviousState.js +0 -20
  112. package/lib/commonjs/utils/usePreviousState.js.map +0 -1
  113. package/lib/typescript/TreeView.d.ts.map +0 -1
  114. package/lib/typescript/components/CheckboxView.d.ts.map +0 -1
  115. package/lib/typescript/components/CustomExpandCollapseIcon.d.ts.map +0 -1
  116. package/lib/typescript/components/NodeList.d.ts +0 -6
  117. package/lib/typescript/components/NodeList.d.ts.map +0 -1
  118. package/lib/typescript/constants/tests.constants.d.ts.map +0 -1
  119. package/lib/typescript/constants/treeView.constants.d.ts.map +0 -1
  120. package/lib/typescript/handlers/ScrollToNodeHandler.d.ts.map +0 -1
  121. package/lib/typescript/helpers/expandCollapse.helper.d.ts.map +0 -1
  122. package/lib/typescript/helpers/flattenTree.helper.d.ts.map +0 -1
  123. package/lib/typescript/helpers/index.d.ts.map +0 -1
  124. package/lib/typescript/helpers/search.helper.d.ts.map +0 -1
  125. package/lib/typescript/helpers/selectAll.helper.d.ts.map +0 -1
  126. package/lib/typescript/helpers/toggleCheckbox.helper.d.ts.map +0 -1
  127. package/lib/typescript/helpers/treeNode.helper.d.ts.map +0 -1
  128. package/lib/typescript/index.d.ts.map +0 -1
  129. package/lib/typescript/jest.setup.d.ts.map +0 -1
  130. package/lib/typescript/store/treeView.store.d.ts.map +0 -1
  131. package/lib/typescript/types/treeView.types.d.ts.map +0 -1
  132. package/lib/typescript/utils/typedMemo.d.ts.map +0 -1
  133. package/lib/typescript/utils/useDeepCompareEffect.d.ts.map +0 -1
  134. package/lib/typescript/utils/usePreviousState.d.ts.map +0 -1
  135. /package/lib/typescript/{constants → src/constants}/tests.constants.d.ts +0 -0
  136. /package/lib/typescript/{constants → src/constants}/treeView.constants.d.ts +0 -0
  137. /package/lib/typescript/{helpers → src/helpers}/expandCollapse.helper.d.ts +0 -0
  138. /package/lib/typescript/{helpers → src/helpers}/index.d.ts +0 -0
  139. /package/lib/typescript/{helpers → src/helpers}/toggleCheckbox.helper.d.ts +0 -0
  140. /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
  141. /package/lib/typescript/{jest.setup.d.ts → src/jest.setup.d.ts} +0 -0
  142. /package/lib/typescript/{utils → src/utils}/typedMemo.d.ts +0 -0
  143. /package/lib/typescript/{utils → src/utils}/useDeepCompareEffect.d.ts +0 -0
  144. /package/lib/typescript/{utils → src/utils}/usePreviousState.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import { ExpandIconProps } from "src/types/treeView.types";
2
+ import { type ExpandIconProps } from "../types/treeView.types";
3
3
  export declare const CustomExpandCollapseIcon: React.MemoExoticComponent<typeof _CustomExpandCollapseIcon>;
4
- declare function _CustomExpandCollapseIcon(props: ExpandIconProps): React.JSX.Element;
4
+ declare function _CustomExpandCollapseIcon(props: ExpandIconProps): import("react/jsx-runtime").JSX.Element | null;
5
5
  export {};
6
6
  //# sourceMappingURL=CustomExpandCollapseIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomExpandCollapseIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/CustomExpandCollapseIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAqB/D,eAAO,MAAM,wBAAwB,6DAEpC,CAAC;AAEF,iBAAS,yBAAyB,CAAC,KAAK,EAAE,eAAe,kDAoBxD"}
@@ -0,0 +1,5 @@
1
+ import type { NodeListProps } from "../types/treeView.types";
2
+ declare const NodeList: typeof _NodeList;
3
+ export default NodeList;
4
+ declare function _NodeList<ID>(props: NodeListProps<ID>): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=NodeList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeList.d.ts","sourceRoot":"","sources":["../../../../src/components/NodeList.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAGR,aAAa,EAEhB,MAAM,yBAAyB,CAAC;AAiBjC,QAAA,MAAM,QAAQ,kBAAuB,CAAC;AACtC,eAAe,QAAQ,CAAC;AAExB,iBAAS,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,2CAgH9C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tests.constants.d.ts","sourceRoot":"","sources":["../../../../src/constants/tests.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeView.constants.d.ts","sourceRoot":"","sources":["../../../../src/constants/treeView.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
@@ -32,7 +32,7 @@
32
32
  * in the UI, thus preventing issues with attempting to scroll to an element that does not exist yet.
33
33
  */
34
34
  import React from "react";
35
- import { __FlattenedTreeNode__ } from "../types/treeView.types";
35
+ import { type __FlattenedTreeNode__ } from "../types/treeView.types";
36
36
  interface Props<ID> {
37
37
  storeId: string;
38
38
  flashListRef: React.Mutable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sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC;CAAE,KACzE,UAAU,CAAC,OAAO,yBAAyB,CAIzB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expandCollapse.helper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/expandCollapse.helper.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,QAoC7D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,QAMxC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,QAK1C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAC1B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,EAAE,EAAE,EACT,0BAA0B,GAAE,OAAe,QA0B9C;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,QA6B3D"}
@@ -1,4 +1,4 @@
1
- import { TreeNode, __FlattenedTreeNode__ } from "../types/treeView.types";
1
+ import { type TreeNode, type __FlattenedTreeNode__ } from "../types/treeView.types";
2
2
  /**
3
3
  * Flatten the tree and attach a "level" key to object to indicate it's depth. This
4
4
  * returns the flattened tree data of expanded ids only. We do not prune the tree off the
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flattenTree.helper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/flattenTree.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,qBAAqB,EAC7B,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EACnC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,EACrB,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,GACrB,qBAAqB,CAAC,EAAE,CAAC,EAAE,CAoC7B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/helpers/index.ts"],"names":[],"mappings":"AAEA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { TreeNode } from "../types/treeView.types";
1
+ import { type TreeNode } from "../types/treeView.types";
2
2
  /**
3
3
  * Get filtered tree data based on the search term and the search keys
4
4
  * If any of the parent contains the search term, the tree will also contain
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.helper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/search.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAClC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,EACrB,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAE,MAAM,EAAE,GACrB,QAAQ,CAAC,EAAE,CAAC,EAAE,CA6BhB"}
@@ -1,4 +1,4 @@
1
- import { TreeNode } from "../types/treeView.types";
1
+ import { type TreeNode } from "../types/treeView.types";
2
2
  /**
3
3
  * Selects all nodes that are currently visible due to the applied filter.
4
4
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectAll.helper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/selectAll.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,QAWhD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,QAWlD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,QAcxC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,QAO1C;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,EAAE,EAC5C,iBAAiB,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAClC,EAAE,EAAE,CAgBN"}
@@ -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,EAAE,EAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,EAAE,EAAE,EACT,UAAU,CAAC,EAAE,OAAO,QA6LvB"}
@@ -5,8 +5,8 @@ import type { TreeNode } from "../types/treeView.types";
5
5
  * This function is intended to be called once, during component initialization,
6
6
  * with the initial tree data and any preselected node IDs.
7
7
  *
8
+ * @param storeId - Identifier for the specific tree view store.
8
9
  * @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
10
  */
11
11
  export declare function initializeNodeMaps<ID>(storeId: string, initialData: TreeNode<ID>[]): void;
12
12
  //# sourceMappingURL=treeNode.helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeNode.helper.d.ts","sourceRoot":"","sources":["../../../../src/helpers/treeNode.helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,QA+BlF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAE1C,YAAY,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,6BAA6B,EAC7B,oBAAoB,EACvB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.setup.d.ts","sourceRoot":"","sources":["../../../src/jest.setup.ts"],"names":[],"mappings":"AAAA,OAAO,4CAA4C,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { SelectionPropagation, TreeNode } from "src/types/treeView.types";
2
- import { StoreApi, UseBoundStore } from "zustand";
1
+ import type { SelectionPropagation, TreeNode } from "../types/treeView.types";
2
+ import { type StoreApi, type UseBoundStore } from "zustand";
3
3
  export type TreeViewState<ID> = {
4
4
  checked: Set<ID>;
5
5
  updateChecked: (checked: Set<ID>) => void;
@@ -0,0 +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;AAC9E,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpE,MAAM,MAAM,aAAa,CAAC,EAAE,IAAI;IAE5B,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,aAAa,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAG1C,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACvB,mBAAmB,EAAE,C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,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CA+D3F;AAED,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,MAAM,8CAEvD"}
@@ -1,7 +1,7 @@
1
1
  import type { StyleProp, TextProps, TouchableOpacityProps, ViewStyle } from "react-native";
2
2
  import type { FlashListProps } from "@shopify/flash-list";
3
- import { type Props as RNPaperCheckboxAndroidProps } from "react-native-paper/src/components/Checkbox/CheckboxAndroid";
4
- import { ScrollToNodeHandlerRef, ScrollToNodeParams } from "../handlers/ScrollToNodeHandler";
3
+ import type { ScrollToNodeHandlerRef, ScrollToNodeParams } from "../handlers/ScrollToNodeHandler";
4
+ import type { CheckboxProps as _CheckboxProps } from "@futurejj/react-native-checkbox";
5
5
  export type CheckboxValueType = boolean | "indeterminate";
6
6
  export interface ExpandIconProps {
7
7
  isExpanded: boolean;
@@ -51,7 +51,7 @@ export interface TreeViewProps<ID = string> extends Omit<NodeListProps<ID>, "sto
51
51
  preExpandedIds?: ID[];
52
52
  selectionPropagation?: SelectionPropagation;
53
53
  }
54
- type CheckboxProps = Omit<RNPaperCheckboxAndroidProps, "onPress" | "status">;
54
+ type CheckboxProps = Omit<_CheckboxProps, "onPress" | "status">;
55
55
  export interface CheckBoxViewProps {
56
56
  value: CheckboxValueType;
57
57
  onValueChange: (value: boolean) => void;
@@ -0,0 +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,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,iCAAi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O,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typedMemo.d.ts","sourceRoot":"","sources":["../../../../src/utils/typedMemo.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAc,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeepCompareEffect.d.ts","sourceRoot":"","sources":["../../../../src/utils/useDeepCompareEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,MAAM,EAAE,KAAK,CAAC,cAAc,EAC5B,IAAI,EAAE,KAAK,CAAC,cAAc,QA4B3B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreviousState.d.ts","sourceRoot":"","sources":["../../../../src/utils/usePreviousState.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,iBAQnD"}
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "react-native-tree-multi-select",
3
- "version": "1.9.4",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "A super-fast, customizable tree view component for React Native with multi-selection, checkboxes, and search filtering capabilities.",
5
- "main": "lib/commonjs/index.js",
6
- "module": "lib/module/index.js",
7
- "types": "lib/typescript/index.d.ts",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
8
7
  "react-native": "src/index.tsx",
9
8
  "source": "src/index.tsx",
10
9
  "files": [
@@ -27,17 +26,14 @@
27
26
  "!**/.*"
28
27
  ],
29
28
  "scripts": {
29
+ "example": "yarn workspace react-native-tree-multi-select-example",
30
30
  "test": "jest",
31
31
  "test:cov": "jest --coverage --maxWorkers=2 --coverageReporters=\"json-summary\" --coverageReporters=\"html\"",
32
- "typecheck": "tsc --noEmit",
32
+ "typecheck": "tsc --noEmit --skipLibCheck",
33
33
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
34
- "prepack": "bob build",
35
- "release": "release-it",
36
- "example": "yarn --cwd example",
37
- "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
38
- "build:ios": "cd example/ios && pod install && 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",
39
- "bootstrap": "yarn example && yarn install && yarn example pods && yarn patch-package",
40
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
34
+ "clean": "del-cli lib",
35
+ "prepare": "bob build",
36
+ "release": "release-it"
41
37
  },
42
38
  "keywords": [
43
39
  "react-native",
@@ -84,7 +80,9 @@
84
80
  "devDependencies": {
85
81
  "@commitlint/config-conventional": "^19.7.1",
86
82
  "@evilmartians/lefthook": "^1.10.10",
83
+ "@expo/vector-icons": "14.1.0",
87
84
  "@react-native-community/eslint-config": "^3.2.0",
85
+ "@react-native/babel-preset": "0.78.2",
88
86
  "@release-it/conventional-changelog": "^10.0.0",
89
87
  "@semantic-release/changelog": "^6.0.3",
90
88
  "@semantic-release/git": "^10.0.1",
@@ -109,26 +107,25 @@
109
107
  "prettier": "^3.3.3",
110
108
  "react": "18.2.0",
111
109
  "react-native": "^0.72.15",
112
- "react-native-builder-bob": "^0.30.0",
113
- "react-native-paper": "5.x.x",
114
- "react-test-renderer": "18.2.0",
110
+ "react-native-builder-bob": "^0.40.10",
111
+ "react-test-renderer": "18.3.0",
115
112
  "release-it": "^18.1.2",
116
113
  "semantic-release": "^24.1.0",
117
114
  "ts-jest": "^29.1.1",
118
- "turbo": "^2.1.0",
119
115
  "typescript": "^5.0.2"
120
116
  },
121
117
  "peerDependencies": {
122
118
  "@shopify/flash-list": "1.x.x",
123
- "react": "*",
119
+ "react": ">=18.0.0",
124
120
  "react-native": "*",
125
- "react-native-paper": "5.x.x",
126
121
  "react-native-vector-icons": "*"
127
122
  },
128
- "engines": {
129
- "node": ">= 18.0.0"
123
+ "peerDependenciesMeta": {
124
+ "react-native-vector-icons": {
125
+ "optional": true
126
+ }
130
127
  },
131
- "packageManager": "yarn@1.22.22",
128
+ "packageManager": "yarn@3.6.1",
132
129
  "jest": {
133
130
  "preset": "react-native",
134
131
  "setupFilesAfterEnv": [
@@ -180,7 +177,8 @@
180
177
  "quotes": [
181
178
  "error",
182
179
  "double"
183
- ]
180
+ ],
181
+ "react/react-in-jsx-scope": "off"
184
182
  }
185
183
  },
186
184
  "eslintIgnore": [
@@ -199,8 +197,12 @@
199
197
  "source": "src",
200
198
  "output": "lib",
201
199
  "targets": [
202
- "commonjs",
203
- "module",
200
+ [
201
+ "module",
202
+ {
203
+ "esm": true
204
+ }
205
+ ],
204
206
  [
205
207
  "typescript",
206
208
  {
@@ -210,10 +212,13 @@
210
212
  ]
211
213
  },
212
214
  "dependencies": {
215
+ "@futurejj/react-native-checkbox": "^1.0.0",
213
216
  "fast-is-equal": "^1.0.2",
214
- "react-native-uuid": "^2.0.3",
215
217
  "zustand": "^5.0.3"
216
218
  },
219
+ "workspaces": [
220
+ "example"
221
+ ],
217
222
  "funding": [
218
223
  {
219
224
  "type": "individual",
package/src/TreeView.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useId } from "react";
2
2
  import { InteractionManager } from "react-native";
3
3
  import type {
4
4
  TreeNode,
@@ -21,10 +21,9 @@ import {
21
21
  import { getTreeViewStore, useTreeViewStore } from "./store/treeView.store";
22
22
  import usePreviousState from "./utils/usePreviousState";
23
23
  import { useShallow } from "zustand/react/shallow";
24
- import uuid from "react-native-uuid";
25
24
  import useDeepCompareEffect from "./utils/useDeepCompareEffect";
26
25
  import { typedMemo } from "./utils/typedMemo";
27
- import {
26
+ import type {
28
27
  ScrollToNodeHandlerRef,
29
28
  ScrollToNodeParams
30
29
  } from "./handlers/ScrollToNodeHandler";
@@ -58,7 +57,7 @@ function _innerTreeView<ID>(
58
57
  CustomNodeRowComponent,
59
58
  } = props;
60
59
 
61
- const storeId = React.useMemo(() => uuid.v4(), []);
60
+ const storeId = useId();
62
61
 
63
62
  const {
64
63
  expanded,
@@ -7,11 +7,11 @@ import {
7
7
  View
8
8
  } from "react-native";
9
9
 
10
- import { Checkbox } from "react-native-paper";
11
10
  import type {
12
11
  BuiltInCheckBoxViewProps,
13
12
  CheckboxValueType
14
13
  } from "../types/treeView.types";
14
+ import { Checkbox } from "@futurejj/react-native-checkbox";
15
15
 
16
16
  function arePropsEqual(
17
17
  prevProps: BuiltInCheckBoxViewProps,
@@ -43,7 +43,7 @@ function _CheckboxView(props: BuiltInCheckBoxViewProps) {
43
43
  },
44
44
  } = props;
45
45
 
46
- const customCheckboxValueTypeToRNPaperType = React.useCallback((
46
+ const customCheckboxValToCheckboxValType = React.useCallback((
47
47
  customCheckboxValueType: CheckboxValueType
48
48
  ) => {
49
49
  return customCheckboxValueType === "indeterminate"
@@ -70,9 +70,9 @@ function _CheckboxView(props: BuiltInCheckBoxViewProps) {
70
70
  style={outermostParentViewStyle}>
71
71
  <View
72
72
  style={checkboxParentViewStyle}>
73
- <Checkbox.Android
73
+ <Checkbox
74
74
  {...checkboxProps}
75
- status={customCheckboxValueTypeToRNPaperType(value)}
75
+ status={customCheckboxValToCheckboxValType(value)}
76
76
  onPress={onValueChangeModifier} />
77
77
  </View>
78
78
 
@@ -1,7 +1,24 @@
1
1
  import React from "react";
2
- import FontAwesomeIcon from "react-native-vector-icons/FontAwesome";
2
+ import { type ExpandIconProps } from "../types/treeView.types";
3
3
 
4
- import { ExpandIconProps } from "src/types/treeView.types";
4
+ // Function to dynamically load FontAwesomeIcon from either Expo or React Native
5
+ function loadFontAwesomeIcon() {
6
+ try {
7
+ return require("@expo/vector-icons/FontAwesome").default;
8
+ } catch (e) {
9
+ try {
10
+ return require("react-native-vector-icons/FontAwesome").default;
11
+ } catch (error) {
12
+ console.error(
13
+ "No FontAwesome icon library found. Please install either @expo/vector-icons or react-native-vector-icons"
14
+ );
15
+ return null;
16
+ }
17
+ }
18
+ }
19
+
20
+ // Load the FontAwesomeIcon component
21
+ const FontAwesomeIcon = loadFontAwesomeIcon();
5
22
 
6
23
  export const CustomExpandCollapseIcon = React.memo(
7
24
  _CustomExpandCollapseIcon
@@ -10,6 +27,12 @@ export const CustomExpandCollapseIcon = React.memo(
10
27
  function _CustomExpandCollapseIcon(props: ExpandIconProps) {
11
28
  const { isExpanded } = props;
12
29
 
30
+ // If FontAwesomeIcon is not available, render a fallback or null
31
+ if (!FontAwesomeIcon) {
32
+ console.warn("FontAwesomeIcon is not available");
33
+ return null;
34
+ }
35
+
13
36
  return (
14
37
  <FontAwesomeIcon
15
38
  name={
@@ -36,7 +36,7 @@ import React from "react";
36
36
  import { expandNodes } from "../helpers/expandCollapse.helper";
37
37
  import { useTreeViewStore } from "../store/treeView.store";
38
38
  import { useShallow } from "zustand/react/shallow";
39
- import { __FlattenedTreeNode__ } from "../types/treeView.types";
39
+ import { type __FlattenedTreeNode__ } from "../types/treeView.types";
40
40
  import { typedMemo } from "../utils/typedMemo";
41
41
  import { fastIsEqual } from "fast-is-equal";
42
42
 
@@ -1,4 +1,7 @@
1
- import { TreeNode, __FlattenedTreeNode__ } from "../types/treeView.types";
1
+ import {
2
+ type TreeNode,
3
+ type __FlattenedTreeNode__
4
+ } from "../types/treeView.types";
2
5
 
3
6
  /**
4
7
  * Flatten the tree and attach a "level" key to object to indicate it's depth. This
@@ -1,4 +1,4 @@
1
- import { TreeNode } from "../types/treeView.types";
1
+ import { type TreeNode } from "../types/treeView.types";
2
2
 
3
3
  /**
4
4
  * Get filtered tree data based on the search term and the search keys
@@ -1,4 +1,4 @@
1
- import { TreeNode } from "../types/treeView.types";
1
+ import { type TreeNode } from "../types/treeView.types";
2
2
  import { getTreeViewStore } from "../store/treeView.store";
3
3
  import { toggleCheckboxes } from "./toggleCheckbox.helper";
4
4
 
@@ -1,7 +1,5 @@
1
1
  import type { TreeNode } from "../types/treeView.types";
2
- import {
3
- getTreeViewStore,
4
- } from "../store/treeView.store";
2
+ import { getTreeViewStore } from "../store/treeView.store";
5
3
 
6
4
  /**
7
5
  * Initialize the maps for tracking tree nodes and their parent-child relationships.
@@ -9,42 +7,38 @@ import {
9
7
  * This function is intended to be called once, during component initialization,
10
8
  * with the initial tree data and any preselected node IDs.
11
9
  *
10
+ * @param storeId - Identifier for the specific tree view store.
12
11
  * @param initialData - An array of TreeNode objects that represent the initial tree structure.
13
- * @param preselectedIds - An optional array of TreeNode IDs that should be preselected.
14
12
  */
15
13
  export function initializeNodeMaps<ID>(storeId: string, initialData: TreeNode<ID>[]) {
16
14
  const treeViewStore = getTreeViewStore<ID>(storeId);
17
- const {
18
- updateNodeMap,
19
- updateChildToParentMap
20
- } = treeViewStore.getState();
21
-
22
- const tempNodeMap: Map<ID, TreeNode<ID>> = new Map();
23
- const tempChildToParentMap: Map<ID, ID> = new Map();
24
-
25
- /**
26
- * Recursively processes nodes, adding them to the nodeMap and childToParentMap.
27
- *
28
- * @param nodes - An array of TreeNode objects to be processed.
29
- * @param parentId - The ID of the parent node, if applicable.
30
- */
31
- const processNodes = (
32
- nodes: TreeNode<ID>[],
33
- parentId: ID | null = null
34
- ) => {
35
- nodes.forEach((node) => {
36
- // Each node is added to the nodeMap with its ID as the key
37
- tempNodeMap.set(node.id, node);
38
- // If the node has a parent, its ID is mapped to the parent's ID in the childToParentMap
39
- if (parentId) tempChildToParentMap.set(node.id, parentId);
40
- // If the node has children, recursively process them
41
- if (node.children) processNodes(node.children, node.id);
42
- });
43
- };
44
-
45
- // Begin processing with the initial tree data
46
- processNodes(initialData);
47
-
48
- updateNodeMap(tempNodeMap);
49
- updateChildToParentMap(tempChildToParentMap);
50
- }
15
+ const { updateNodeMap, updateChildToParentMap } = treeViewStore.getState();
16
+
17
+ const nodeMap = new Map<ID, TreeNode<ID>>();
18
+ const childToParentMap = new Map<ID, ID>();
19
+
20
+ // Use an iterative approach with a stack instead of recursion
21
+ const stack: Array<{ nodes: TreeNode<ID>[], parentId: ID | null; }> = [
22
+ { nodes: initialData, parentId: null }
23
+ ];
24
+
25
+ while (stack.length > 0) {
26
+ const { nodes, parentId } = stack.pop()!;
27
+
28
+ for (const node of nodes) {
29
+ nodeMap.set(node.id, node);
30
+
31
+ if (parentId !== null) {
32
+ childToParentMap.set(node.id, parentId);
33
+ }
34
+
35
+ if (node.children && node.children.length > 0) {
36
+ stack.push({ nodes: node.children, parentId: node.id });
37
+ }
38
+ }
39
+ }
40
+
41
+ // Batch update the store with both maps at once
42
+ updateNodeMap(nodeMap);
43
+ updateChildToParentMap(childToParentMap);
44
+ }
@@ -1,5 +1,5 @@
1
- import type { SelectionPropagation, TreeNode } from "src/types/treeView.types";
2
- import { create, StoreApi, UseBoundStore } from "zustand";
1
+ import type { SelectionPropagation, TreeNode } from "../types/treeView.types";
2
+ import { create, type StoreApi, type UseBoundStore } from "zustand";
3
3
 
4
4
  export type TreeViewState<ID> = {
5
5
  // Store ids of checked tree nodes
@@ -5,13 +5,11 @@ import type {
5
5
  ViewStyle
6
6
  } from "react-native";
7
7
  import type { FlashListProps } from "@shopify/flash-list";
8
- import {
9
- type Props as RNPaperCheckboxAndroidProps
10
- } from "react-native-paper/src/components/Checkbox/CheckboxAndroid";
11
- import {
8
+ import type {
12
9
  ScrollToNodeHandlerRef,
13
10
  ScrollToNodeParams
14
11
  } from "../handlers/ScrollToNodeHandler";
12
+ import type { CheckboxProps as _CheckboxProps } from "@futurejj/react-native-checkbox";
15
13
 
16
14
  export type CheckboxValueType = boolean | "indeterminate";
17
15
 
@@ -90,7 +88,7 @@ export interface TreeViewProps<ID = string> extends Omit<
90
88
  selectionPropagation?: SelectionPropagation;
91
89
  }
92
90
 
93
- type CheckboxProps = Omit<RNPaperCheckboxAndroidProps, "onPress" | "status">;
91
+ type CheckboxProps = Omit<_CheckboxProps, "onPress" | "status">;
94
92
 
95
93
  export interface CheckBoxViewProps {
96
94
  value: CheckboxValueType;