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.
Files changed (108) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +124 -0
  3. package/android/build.gradle +94 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/com/treemultiselect/TreeMultiSelectModule.kt +25 -0
  7. package/android/src/main/java/com/treemultiselect/TreeMultiSelectPackage.kt +17 -0
  8. package/ios/TreeMultiSelect-Bridging-Header.h +2 -0
  9. package/ios/TreeMultiSelect.mm +14 -0
  10. package/ios/TreeMultiSelect.swift +8 -0
  11. package/ios/TreeMultiSelect.xcodeproj/project.pbxproj +283 -0
  12. package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  13. package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  14. package/ios/TreeMultiSelect.xcodeproj/project.xcworkspace/xcuserdata/guest_jj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  15. package/ios/TreeMultiSelect.xcodeproj/xcuserdata/guest_jj.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  16. package/lib/commonjs/TreeView.js +99 -0
  17. package/lib/commonjs/TreeView.js.map +1 -0
  18. package/lib/commonjs/components/CheckboxView.js +77 -0
  19. package/lib/commonjs/components/CheckboxView.js.map +1 -0
  20. package/lib/commonjs/components/CustomExpandCollapseIcon.js +20 -0
  21. package/lib/commonjs/components/CustomExpandCollapseIcon.js.map +1 -0
  22. package/lib/commonjs/components/NodeList.js +193 -0
  23. package/lib/commonjs/components/NodeList.js.map +1 -0
  24. package/lib/commonjs/helpers/expandCollapse.helper.js +93 -0
  25. package/lib/commonjs/helpers/expandCollapse.helper.js.map +1 -0
  26. package/lib/commonjs/helpers/index.js +61 -0
  27. package/lib/commonjs/helpers/index.js.map +1 -0
  28. package/lib/commonjs/helpers/initNodeMap.helper.js +44 -0
  29. package/lib/commonjs/helpers/initNodeMap.helper.js.map +1 -0
  30. package/lib/commonjs/helpers/search.helper.js +29 -0
  31. package/lib/commonjs/helpers/search.helper.js.map +1 -0
  32. package/lib/commonjs/helpers/selectAll.helper.js +73 -0
  33. package/lib/commonjs/helpers/selectAll.helper.js.map +1 -0
  34. package/lib/commonjs/helpers/toggleCheckbox.helper.js +153 -0
  35. package/lib/commonjs/helpers/toggleCheckbox.helper.js.map +1 -0
  36. package/lib/commonjs/index.js +28 -0
  37. package/lib/commonjs/index.js.map +1 -0
  38. package/lib/commonjs/signals/global.signals.js +42 -0
  39. package/lib/commonjs/signals/global.signals.js.map +1 -0
  40. package/lib/commonjs/types/treeView.types.js +6 -0
  41. package/lib/commonjs/types/treeView.types.js.map +1 -0
  42. package/lib/module/TreeView.js +89 -0
  43. package/lib/module/TreeView.js.map +1 -0
  44. package/lib/module/components/CheckboxView.js +68 -0
  45. package/lib/module/components/CheckboxView.js.map +1 -0
  46. package/lib/module/components/CustomExpandCollapseIcon.js +13 -0
  47. package/lib/module/components/CustomExpandCollapseIcon.js.map +1 -0
  48. package/lib/module/components/NodeList.js +185 -0
  49. package/lib/module/components/NodeList.js.map +1 -0
  50. package/lib/module/helpers/expandCollapse.helper.js +86 -0
  51. package/lib/module/helpers/expandCollapse.helper.js.map +1 -0
  52. package/lib/module/helpers/index.js +6 -0
  53. package/lib/module/helpers/index.js.map +1 -0
  54. package/lib/module/helpers/initNodeMap.helper.js +39 -0
  55. package/lib/module/helpers/initNodeMap.helper.js.map +1 -0
  56. package/lib/module/helpers/search.helper.js +23 -0
  57. package/lib/module/helpers/search.helper.js.map +1 -0
  58. package/lib/module/helpers/selectAll.helper.js +65 -0
  59. package/lib/module/helpers/selectAll.helper.js.map +1 -0
  60. package/lib/module/helpers/toggleCheckbox.helper.js +148 -0
  61. package/lib/module/helpers/toggleCheckbox.helper.js.map +1 -0
  62. package/lib/module/index.js +4 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/signals/global.signals.js +26 -0
  65. package/lib/module/signals/global.signals.js.map +1 -0
  66. package/lib/module/types/treeView.types.js +2 -0
  67. package/lib/module/types/treeView.types.js.map +1 -0
  68. package/lib/typescript/TreeView.d.ts +4 -0
  69. package/lib/typescript/TreeView.d.ts.map +1 -0
  70. package/lib/typescript/components/CheckboxView.d.ts +24 -0
  71. package/lib/typescript/components/CheckboxView.d.ts.map +1 -0
  72. package/lib/typescript/components/CustomExpandCollapseIcon.d.ts +4 -0
  73. package/lib/typescript/components/CustomExpandCollapseIcon.d.ts.map +1 -0
  74. package/lib/typescript/components/NodeList.d.ts +14 -0
  75. package/lib/typescript/components/NodeList.d.ts.map +1 -0
  76. package/lib/typescript/helpers/expandCollapse.helper.d.ts +18 -0
  77. package/lib/typescript/helpers/expandCollapse.helper.d.ts.map +1 -0
  78. package/lib/typescript/helpers/index.d.ts +6 -0
  79. package/lib/typescript/helpers/index.d.ts.map +1 -0
  80. package/lib/typescript/helpers/initNodeMap.helper.d.ts +12 -0
  81. package/lib/typescript/helpers/initNodeMap.helper.d.ts.map +1 -0
  82. package/lib/typescript/helpers/search.helper.d.ts +14 -0
  83. package/lib/typescript/helpers/search.helper.d.ts.map +1 -0
  84. package/lib/typescript/helpers/selectAll.helper.d.ts +25 -0
  85. package/lib/typescript/helpers/selectAll.helper.d.ts.map +1 -0
  86. package/lib/typescript/helpers/toggleCheckbox.helper.d.ts +9 -0
  87. package/lib/typescript/helpers/toggleCheckbox.helper.d.ts.map +1 -0
  88. package/lib/typescript/index.d.ts +5 -0
  89. package/lib/typescript/index.d.ts.map +1 -0
  90. package/lib/typescript/signals/global.signals.d.ts +11 -0
  91. package/lib/typescript/signals/global.signals.d.ts.map +1 -0
  92. package/lib/typescript/types/treeView.types.d.ts +61 -0
  93. package/lib/typescript/types/treeView.types.d.ts.map +1 -0
  94. package/package.json +165 -0
  95. package/react-native-tree-multi-select.podspec +41 -0
  96. package/src/TreeView.tsx +139 -0
  97. package/src/components/CheckboxView.tsx +109 -0
  98. package/src/components/CustomExpandCollapseIcon.tsx +20 -0
  99. package/src/components/NodeList.tsx +278 -0
  100. package/src/helpers/expandCollapse.helper.ts +88 -0
  101. package/src/helpers/index.ts +5 -0
  102. package/src/helpers/initNodeMap.helper.ts +46 -0
  103. package/src/helpers/search.helper.ts +28 -0
  104. package/src/helpers/selectAll.helper.ts +59 -0
  105. package/src/helpers/toggleCheckbox.helper.ts +144 -0
  106. package/src/index.tsx +22 -0
  107. package/src/signals/global.signals.ts +36 -0
  108. package/src/types/treeView.types.ts +86 -0
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.doesNodeContainSearchTerm = doesNodeContainSearchTerm;
7
+ /**
8
+ * Checks if a given tree node contains a specific search term in any of its specified keys.
9
+ *
10
+ * This function will check each of the specified keys in the tree node, convert the key's value to a string,
11
+ * and check if it includes the search term.
12
+ *
13
+ * @param node - The tree node to search through.
14
+ * @param searchTerm - The term to search for.
15
+ * @param searchKeys - The keys in the tree node to search in.
16
+ * @returns True if the search term is found in any of the specified keys, false otherwise.
17
+ */
18
+ function doesNodeContainSearchTerm(node, searchTerm, searchKeys) {
19
+ // We're using the `some` method on the array of keys to check each one
20
+ return searchKeys.some(key => {
21
+ // Get the value of the key in the tree node
22
+ const nodeValue = node[key];
23
+ // Check if the string representation of the key's value includes the search term
24
+ // If the value is undefined or null, `nodeValue?.toString()` will return undefined,
25
+ // and the call to `toLowerCase().includes(searchTerm)` will return false.
26
+ return nodeValue === null || nodeValue === void 0 ? void 0 : nodeValue.toString().toLowerCase().includes(searchTerm);
27
+ });
28
+ }
29
+ //# sourceMappingURL=search.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["doesNodeContainSearchTerm","node","searchTerm","searchKeys","some","key","nodeValue","toString","toLowerCase","includes"],"sourceRoot":"../../../src","sources":["helpers/search.helper.ts"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAyBA,CACrCC,IAAc,EACdC,UAAkB,EAClBC,UAAoB,EACb;EACP;EACA,OAAOA,UAAU,CAACC,IAAI,CAACC,GAAG,IAAI;IAC1B;IACA,MAAMC,SAAS,GAAGL,IAAI,CAACI,GAAG,CAAC;IAC3B;IACA;IACA;IACA,OAAQC,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEC,QAAQ,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAACC,QAAQ,CAACP,UAAU,CAAC;EACpE,CAAC,CAAC;AACN"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectAll = selectAll;
7
+ exports.selectAllFiltered = selectAllFiltered;
8
+ exports.unselectAll = unselectAll;
9
+ exports.unselectAllFiltered = unselectAllFiltered;
10
+ var _global = require("../signals/global.signals");
11
+ var _toggleCheckbox = require("./toggleCheckbox.helper");
12
+ /**
13
+ * Selects all nodes that are currently visible due to the applied filter.
14
+ *
15
+ * If there is no search text, then it selects all nodes; otherwise, it selects all visible nodes.
16
+ */
17
+ function selectAllFiltered() {
18
+ // If there's no search text, select all nodes
19
+ if (!_global.searchText.value) {
20
+ selectAll();
21
+ } else {
22
+ // If there's search text, only select the visible nodes
23
+ (0, _toggleCheckbox.toggleCheckboxes)(_global.innerMostChildrenIds.value, true);
24
+ }
25
+ }
26
+ ;
27
+
28
+ /**
29
+ * Unselects all nodes that are currently visible due to the applied filter.
30
+ *
31
+ * If there is no search text, then it unselects all nodes; otherwise, it unselects all visible nodes.
32
+ */
33
+ function unselectAllFiltered() {
34
+ // If there's no search text, unselect all nodes
35
+ if (!_global.searchText.value) {
36
+ unselectAll();
37
+ } else {
38
+ // If there's search text, only unselect the visible nodes
39
+ (0, _toggleCheckbox.toggleCheckboxes)(_global.innerMostChildrenIds.value, false);
40
+ }
41
+ }
42
+ ;
43
+
44
+ /**
45
+ * Selects all nodes in the tree.
46
+ *
47
+ * This function selects all nodes by adding all node ids to the checked set and clearing the indeterminate set.
48
+ */
49
+ function selectAll() {
50
+ // Create a new set containing the ids of all nodes
51
+ const newChecked = new Set(_global.nodeMap.value.keys());
52
+ // Update the state to mark all nodes as checked
53
+ _global.state.value = {
54
+ checked: newChecked,
55
+ indeterminate: new Set()
56
+ };
57
+ }
58
+ ;
59
+
60
+ /**
61
+ * Unselects all nodes in the tree.
62
+ *
63
+ * This function unselects all nodes by clearing both the checked and indeterminate sets.
64
+ */
65
+ function unselectAll() {
66
+ // Update the state to mark all nodes as unchecked
67
+ _global.state.value = {
68
+ checked: new Set(),
69
+ indeterminate: new Set()
70
+ };
71
+ }
72
+ ;
73
+ //# sourceMappingURL=selectAll.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_global","require","_toggleCheckbox","selectAllFiltered","searchText","value","selectAll","toggleCheckboxes","innerMostChildrenIds","unselectAllFiltered","unselectAll","newChecked","Set","nodeMap","keys","state","checked","indeterminate"],"sourceRoot":"../../../src","sources":["helpers/selectAll.helper.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,iBAAiBA,CAAA,EAAG;EAChC;EACA,IAAI,CAACC,kBAAU,CAACC,KAAK,EAAE;IACnBC,SAAS,CAAC,CAAC;EACf,CAAC,MAAM;IACH;IACA,IAAAC,gCAAgB,EAACC,4BAAoB,CAACH,KAAK,EAAE,IAAI,CAAC;EACtD;AACJ;AAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAASI,mBAAmBA,CAAA,EAAG;EAClC;EACA,IAAI,CAACL,kBAAU,CAACC,KAAK,EAAE;IACnBK,WAAW,CAAC,CAAC;EACjB,CAAC,MAAM;IACH;IACA,IAAAH,gCAAgB,EAACC,4BAAoB,CAACH,KAAK,EAAE,KAAK,CAAC;EACvD;AACJ;AAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAA,EAAG;EACxB;EACA,MAAMK,UAAU,GAAG,IAAIC,GAAG,CAACC,eAAO,CAACR,KAAK,CAACS,IAAI,CAAC,CAAC,CAAC;EAChD;EACAC,aAAK,CAACV,KAAK,GAAI;IAAEW,OAAO,EAAEL,UAAU;IAAEM,aAAa,EAAE,IAAIL,GAAG,CAAC;EAAE,CAAE;AACrE;AAAC;;AAED;AACA;AACA;AACA;AACA;AACO,SAASF,WAAWA,CAAA,EAAG;EAC1B;EACAK,aAAK,CAACV,KAAK,GAAI;IAAEW,OAAO,EAAE,IAAIJ,GAAG,CAAC,CAAC;IAAEK,aAAa,EAAE,IAAIL,GAAG,CAAC;EAAE,CAAE;AACpE;AAAC"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toggleCheckboxes = toggleCheckboxes;
7
+ var _global = require("../signals/global.signals");
8
+ /**
9
+ * Function to toggle checkbox state for a tree structure.
10
+ * It sets the checked and indeterminate state for all affected nodes in the tree after an action to check/uncheck is made.
11
+ * @param {string[]} ids - The ids of nodes that need to be checked or unchecked.
12
+ * @param {boolean} [forceCheck] - Optional. If provided, will force the check state of the nodes to be this value.
13
+ * If not provided, the check state will be toggled based on the current state.
14
+ */
15
+ function toggleCheckboxes(ids, forceCheck) {
16
+ // Create new sets for checked and indeterminate state so as not to mutate the original state.
17
+ const checked = new Set(_global.state.value.checked);
18
+ const indeterminate = new Set(_global.state.value.indeterminate);
19
+
20
+ // Maps for memoization of the recursive functions areAllDescendantsChecked and areAnyDescendantsChecked.
21
+ const memoAllDescendantsChecked = new Map();
22
+ const memoAnyDescendantsChecked = new Map();
23
+
24
+ /**
25
+ * Recursive function to check/uncheck a node and all its children.
26
+ * @param {string} nodeId - The id of the node to be checked or unchecked.
27
+ * @param {boolean} isChecked - Whether the node should be checked or unchecked.
28
+ */
29
+ const toggleNodeAndChildren = (nodeId, isChecked) => {
30
+ var _node$children;
31
+ // Set or unset this node in the checked set, and remove it from the indeterminate set.
32
+ if (isChecked) {
33
+ checked.add(nodeId);
34
+ indeterminate.delete(nodeId);
35
+ } else {
36
+ checked.delete(nodeId);
37
+ }
38
+
39
+ // Get the node from the node map and recursively apply the same state to all its children.
40
+ const node = _global.nodeMap.value.get(nodeId);
41
+ node === null || node === void 0 || (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.forEach(childNode => {
42
+ if (isChecked) indeterminate.delete(childNode.id);
43
+ toggleNodeAndChildren(childNode.id, isChecked);
44
+ });
45
+ };
46
+
47
+ /**
48
+ * Recursive function to check if all descendants of a node are checked.
49
+ * It uses memoization to avoid redundant calculations.
50
+ * @param {string} nodeId - The id of the node to be checked.
51
+ * @returns {boolean} - Whether all descendants of the node are checked.
52
+ */
53
+ const areAllDescendantsChecked = nodeId => {
54
+ // If the result for this node is already in the map, return it.
55
+ if (memoAllDescendantsChecked.has(nodeId)) {
56
+ return memoAllDescendantsChecked.get(nodeId);
57
+ }
58
+ const node = _global.nodeMap.value.get(nodeId);
59
+ let allChecked = true;
60
+ if (node !== null && node !== void 0 && node.children) {
61
+ // If the node has children, recursively check all children.
62
+ for (const childNode of node.children) {
63
+ allChecked = allChecked && areAllDescendantsChecked(childNode.id);
64
+ }
65
+ } else {
66
+ // If the node has no children, its state is equal to whether it is in the checked set.
67
+ allChecked = checked.has(nodeId);
68
+ }
69
+
70
+ // Store the result in the map and return it.
71
+ memoAllDescendantsChecked.set(nodeId, allChecked);
72
+ return allChecked;
73
+ };
74
+
75
+ /**
76
+ * Recursive function to check if any descendants of a node are checked.
77
+ * It uses memoization to avoid redundant calculations.
78
+ * @param {string} nodeId - The id of the node to be checked.
79
+ * @returns {boolean} - Whether any descendants of the node are checked.
80
+ */
81
+ const areAnyDescendantsChecked = nodeId => {
82
+ // If the result for this node is already in the map, return it.
83
+ if (memoAnyDescendantsChecked.has(nodeId)) {
84
+ return memoAnyDescendantsChecked.get(nodeId);
85
+ }
86
+ const node = _global.nodeMap.value.get(nodeId);
87
+ let anyChecked = false;
88
+ if (node !== null && node !== void 0 && node.children) {
89
+ // If the node has children, recursively check all children.
90
+ for (const childNode of node.children) {
91
+ anyChecked = anyChecked || areAnyDescendantsChecked(childNode.id);
92
+ }
93
+ } else {
94
+ // If the node has no children, its state is equal to whether it is in the checked set.
95
+ anyChecked = checked.has(nodeId);
96
+ }
97
+
98
+ // Store the result in the map and return it.
99
+ memoAnyDescendantsChecked.set(nodeId, anyChecked);
100
+ return anyChecked;
101
+ };
102
+
103
+ /**
104
+ * Function to update the indeterminate and checked state of a node and its ancestors.
105
+ * @param {string} nodeId - The id of the node to be updated.
106
+ */
107
+ const updateNodeAndAncestorsState = nodeId => {
108
+ const node = _global.nodeMap.value.get(nodeId);
109
+ const hasOnlyOneChild = (node === null || node === void 0 ? void 0 : node.children) && node.children.length === 1;
110
+
111
+ // Update the node's state based on the state of its descendants.
112
+ if (areAllDescendantsChecked(nodeId)) {
113
+ checked.add(nodeId);
114
+ indeterminate.delete(nodeId);
115
+ } else if (areAnyDescendantsChecked(nodeId)) {
116
+ if (hasOnlyOneChild) {
117
+ // If a node has only one child and it's not checked,
118
+ // remove this node from both checked and indeterminate sets.
119
+ checked.delete(nodeId);
120
+ indeterminate.delete(nodeId);
121
+ } else {
122
+ checked.delete(nodeId);
123
+ indeterminate.add(nodeId);
124
+ }
125
+ } else {
126
+ checked.delete(nodeId);
127
+ indeterminate.delete(nodeId);
128
+ }
129
+ };
130
+
131
+ // Toggle the clicked nodes and their children.
132
+ ids.forEach(id => {
133
+ const isChecked = checked.has(id);
134
+ toggleNodeAndChildren(id, forceCheck === undefined ? !isChecked : forceCheck);
135
+ });
136
+
137
+ // Update the state of all affected nodes.
138
+ ids.forEach(id => {
139
+ let currentNodeId = id;
140
+ while (currentNodeId) {
141
+ updateNodeAndAncestorsState(currentNodeId);
142
+ currentNodeId = _global.childToParentMap.value.get(currentNodeId);
143
+ }
144
+ });
145
+
146
+ // Update the state object with the new checked and indeterminate sets.
147
+ _global.state.value = {
148
+ checked,
149
+ indeterminate
150
+ };
151
+ }
152
+ ;
153
+ //# sourceMappingURL=toggleCheckbox.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_global","require","toggleCheckboxes","ids","forceCheck","checked","Set","state","value","indeterminate","memoAllDescendantsChecked","Map","memoAnyDescendantsChecked","toggleNodeAndChildren","nodeId","isChecked","_node$children","add","delete","node","nodeMap","get","children","forEach","childNode","id","areAllDescendantsChecked","has","allChecked","set","areAnyDescendantsChecked","anyChecked","updateNodeAndAncestorsState","hasOnlyOneChild","length","undefined","currentNodeId","childToParentMap"],"sourceRoot":"../../../src","sources":["helpers/toggleCheckbox.helper.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,GAAa,EAAEC,UAAoB,EAAE;EAClE;EACA,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACC,aAAK,CAACC,KAAK,CAACH,OAAO,CAAC;EAC5C,MAAMI,aAAa,GAAG,IAAIH,GAAG,CAACC,aAAK,CAACC,KAAK,CAACC,aAAa,CAAC;;EAExD;EACA,MAAMC,yBAAyB,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3C,MAAMC,yBAAyB,GAAG,IAAID,GAAG,CAAC,CAAC;;EAE3C;AACJ;AACA;AACA;AACA;EACI,MAAME,qBAAqB,GAAGA,CAACC,MAAc,EAAEC,SAAkB,KAAK;IAAA,IAAAC,cAAA;IAClE;IACA,IAAID,SAAS,EAAE;MACXV,OAAO,CAACY,GAAG,CAACH,MAAM,CAAC;MACnBL,aAAa,CAACS,MAAM,CAACJ,MAAM,CAAC;IAChC,CAAC,MAAM;MACHT,OAAO,CAACa,MAAM,CAACJ,MAAM,CAAC;IAC1B;;IAEA;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B;IACJ,CAAC,MAAM;MACHT,OAAO,CAACa,MAAM,CAACJ,MAAM,CAAC;MACtBL,aAAa,CAACS,MAAM,CAACJ,MAAM,CAAC;IAChC;EACJ,CAAC;;EAED;EACAX,GAAG,CAACoB,OAAO,CAAEE,EAAE,IAAK;IAChB,MAAMV,SAAS,GAAGV,OAAO,CAACsB,GAAG,CAACF,EAAE,CAAC;IACjCZ,qBAAqB,CAACY,EAAE,EAAErB,UAAU,KAAK+B,SAAS,GAAG,CAACpB,SAAS,GAAGX,UAAU,CAAC;EACjF,CAAC,CAAC;;EAEF;EACAD,GAAG,CAACoB,OAAO,CAAEE,EAAE,IAAK;IAChB,IAAIW,aAAiC,GAAGX,EAAE;IAC1C,OAAOW,aAAa,EAAE;MAClBJ,2BAA2B,CAACI,aAAa,CAAC;MAC1CA,aAAa,GAAGC,wBAAgB,CAAC7B,KAAK,CAACa,GAAG,CAACe,aAAa,CAAC;IAC7D;EACJ,CAAC,CAAC;;EAEF;EACA7B,aAAK,CAACC,KAAK,GAAI;IAAEH,OAAO;IAAEI;EAAc,CAAE;AAC9C;AAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _TreeView = require("./TreeView");
7
+ Object.keys(_TreeView).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _TreeView[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _TreeView[key];
14
+ }
15
+ });
16
+ });
17
+ var _CheckboxView = require("./components/CheckboxView");
18
+ Object.keys(_CheckboxView).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _CheckboxView[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _CheckboxView[key];
25
+ }
26
+ });
27
+ });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_TreeView","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_CheckboxView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;AAUA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.childToParentMap = void 0;
7
+ exports.cleanUpGlobalSignals = cleanUpGlobalSignals;
8
+ exports.state = exports.searchText = exports.searchKeys = exports.nodeMap = exports.innerMostChildrenIds = exports.globalData = exports.expanded = void 0;
9
+ var _signalsReact = require("@preact/signals-react");
10
+ const state = (0, _signalsReact.signal)({
11
+ checked: new Set(),
12
+ indeterminate: new Set()
13
+ });
14
+ exports.state = state;
15
+ const expanded = (0, _signalsReact.signal)(new Set());
16
+ exports.expanded = expanded;
17
+ const globalData = (0, _signalsReact.signal)([]);
18
+ exports.globalData = globalData;
19
+ const nodeMap = (0, _signalsReact.signal)(new Map());
20
+ exports.nodeMap = nodeMap;
21
+ const childToParentMap = (0, _signalsReact.signal)(new Map());
22
+ exports.childToParentMap = childToParentMap;
23
+ const searchText = (0, _signalsReact.signal)("");
24
+ exports.searchText = searchText;
25
+ const searchKeys = (0, _signalsReact.signal)([""]);
26
+ exports.searchKeys = searchKeys;
27
+ const innerMostChildrenIds = (0, _signalsReact.signal)([]);
28
+ exports.innerMostChildrenIds = innerMostChildrenIds;
29
+ function cleanUpGlobalSignals() {
30
+ state.value = {
31
+ checked: new Set(),
32
+ indeterminate: new Set()
33
+ };
34
+ expanded.value = new Set();
35
+ globalData.value = [];
36
+ nodeMap.value = new Map();
37
+ childToParentMap.value = new Map();
38
+ searchText.value = "";
39
+ searchKeys.value = [];
40
+ innerMostChildrenIds.value = [];
41
+ }
42
+ //# sourceMappingURL=global.signals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_signalsReact","require","state","signal","checked","Set","indeterminate","exports","expanded","globalData","nodeMap","Map","childToParentMap","searchText","searchKeys","innerMostChildrenIds","cleanUpGlobalSignals","value"],"sourceRoot":"../../../src","sources":["signals/global.signals.ts"],"mappings":";;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAGO,MAAMC,KAAK,GAAG,IAAAC,oBAAM,EAAoB;EAC3CC,OAAO,EAAE,IAAIC,GAAG,CAAC,CAAC;EAClBC,aAAa,EAAE,IAAID,GAAG,CAAC;AAC3B,CAAC,CAAC;AAACE,OAAA,CAAAL,KAAA,GAAAA,KAAA;AACI,MAAMM,QAAQ,GAAG,IAAAL,oBAAM,EAAC,IAAIE,GAAG,CAAS,CAAC,CAAC;AAACE,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAE3C,MAAMC,UAAU,GAAG,IAAAN,oBAAM,EAAa,EAAE,CAAC;AAACI,OAAA,CAAAE,UAAA,GAAAA,UAAA;AAE1C,MAAMC,OAAO,GAAG,IAAAP,oBAAM,EAAC,IAAIQ,GAAG,CAAmB,CAAC,CAAC;AAACJ,OAAA,CAAAG,OAAA,GAAAA,OAAA;AACpD,MAAME,gBAAgB,GAAG,IAAAT,oBAAM,EAAC,IAAIQ,GAAG,CAAiB,CAAC,CAAC;AAACJ,OAAA,CAAAK,gBAAA,GAAAA,gBAAA;AAE3D,MAAMC,UAAU,GAAG,IAAAV,oBAAM,EAAC,EAAE,CAAC;AAACI,OAAA,CAAAM,UAAA,GAAAA,UAAA;AAC9B,MAAMC,UAAU,GAAG,IAAAX,oBAAM,EAAW,CAAC,EAAE,CAAC,CAAC;AAACI,OAAA,CAAAO,UAAA,GAAAA,UAAA;AAE1C,MAAMC,oBAAoB,GAAG,IAAAZ,oBAAM,EAAW,EAAE,CAAC;AAACI,OAAA,CAAAQ,oBAAA,GAAAA,oBAAA;AAElD,SAASC,oBAAoBA,CAAA,EAAG;EACnCd,KAAK,CAACe,KAAK,GAAI;IACXb,OAAO,EAAE,IAAIC,GAAG,CAAC,CAAC;IAClBC,aAAa,EAAE,IAAID,GAAG,CAAC;EAC3B,CAAE;EACFG,QAAQ,CAACS,KAAK,GAAG,IAAIZ,GAAG,CAAS,CAAC;EAElCI,UAAU,CAACQ,KAAK,GAAG,EAAE;EAErBP,OAAO,CAACO,KAAK,GAAG,IAAIN,GAAG,CAAmB,CAAC;EAC3CC,gBAAgB,CAACK,KAAK,GAAG,IAAIN,GAAG,CAAiB,CAAC;EAElDE,UAAU,CAACI,KAAK,GAAG,EAAE;EACrBH,UAAU,CAACG,KAAK,GAAG,EAAE;EAErBF,oBAAoB,CAACE,KAAK,GAAG,EAAE;AACnC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=treeView.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/treeView.types.ts"],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import React, { useEffect, forwardRef, useImperativeHandle } from 'react';
2
+ import NodeList from './components/NodeList';
3
+ import { selectAll, selectAllFiltered, unselectAll, unselectAllFiltered, initializeNodeMaps, expandAll, collapseAll } from './helpers';
4
+ import { effect } from "@preact/signals-react";
5
+ import { cleanUpGlobalSignals, expanded, globalData, searchKeys, searchText, state } from './signals/global.signals';
6
+ import { InteractionManager } from 'react-native';
7
+ const _TreeView = /*#__PURE__*/forwardRef((props, ref) => {
8
+ const {
9
+ data,
10
+ onCheck,
11
+ onExpand,
12
+ preselectedIds,
13
+ treeFlashListProps,
14
+ checkBoxViewStyleProps,
15
+ CheckboxComponent,
16
+ ExpandCollapseIconComponent,
17
+ ExpandCollapseTouchableComponent
18
+ } = props;
19
+ useImperativeHandle(ref, () => ({
20
+ selectAll,
21
+ unselectAll,
22
+ selectAllFiltered,
23
+ unselectAllFiltered,
24
+ expandAll,
25
+ collapseAll,
26
+ setSearchText
27
+ }));
28
+ function setSearchText(text) {
29
+ let keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ["name"];
30
+ searchText.value = text;
31
+ searchKeys.value = keys;
32
+ }
33
+ useEffect(() => {
34
+ globalData.value = data;
35
+ initializeNodeMaps(data, preselectedIds);
36
+ }, [data, preselectedIds]);
37
+ const disposeCheckedStateEffect = React.useMemo(() => {
38
+ return effect(() => {
39
+ onCheck && onCheck(Array.from(state.value.checked));
40
+ });
41
+ // eslint-disable-next-line react-hooks/exhaustive-deps
42
+ }, []);
43
+ const disposeExpandedStateEffect = React.useMemo(() => {
44
+ return effect(() => {
45
+ onExpand && onExpand(Array.from(expanded.value));
46
+ });
47
+ // eslint-disable-next-line react-hooks/exhaustive-deps
48
+ }, []);
49
+ const disposeSearchStateEffect = React.useMemo(() => {
50
+ return effect(() => {
51
+ if (searchText.value) {
52
+ InteractionManager.runAfterInteractions(() => {
53
+ expanded.value = new Set(globalData.value.flatMap(item => getIds(item)));
54
+ });
55
+ } else {
56
+ InteractionManager.runAfterInteractions(() => {
57
+ expanded.value = new Set();
58
+ });
59
+ }
60
+ });
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ }, []);
63
+ useEffect(() => {
64
+ return () => {
65
+ // Cleanup all global signals and signal effects
66
+ disposeCheckedStateEffect();
67
+ disposeExpandedStateEffect();
68
+ disposeSearchStateEffect();
69
+ cleanUpGlobalSignals();
70
+ };
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ }, []);
73
+ const getIds = React.useCallback(node => {
74
+ if (!node.children || node.children.length === 0) {
75
+ return [node.id];
76
+ } else {
77
+ return [node.id, ...node.children.flatMap(item => getIds(item))];
78
+ }
79
+ }, []);
80
+ return /*#__PURE__*/React.createElement(NodeList, {
81
+ treeFlashListProps: treeFlashListProps,
82
+ checkBoxViewStyleProps: checkBoxViewStyleProps,
83
+ CheckboxComponent: CheckboxComponent,
84
+ ExpandCollapseIconComponent: ExpandCollapseIconComponent,
85
+ ExpandCollapseTouchableComponent: ExpandCollapseTouchableComponent
86
+ });
87
+ });
88
+ export const TreeView = /*#__PURE__*/React.memo(_TreeView);
89
+ //# sourceMappingURL=TreeView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","forwardRef","useImperativeHandle","NodeList","selectAll","selectAllFiltered","unselectAll","unselectAllFiltered","initializeNodeMaps","expandAll","collapseAll","effect","cleanUpGlobalSignals","expanded","globalData","searchKeys","searchText","state","InteractionManager","_TreeView","props","ref","data","onCheck","onExpand","preselectedIds","treeFlashListProps","checkBoxViewStyleProps","CheckboxComponent","ExpandCollapseIconComponent","ExpandCollapseTouchableComponent","setSearchText","text","keys","arguments","length","undefined","value","disposeCheckedStateEffect","useMemo","Array","from","checked","disposeExpandedStateEffect","disposeSearchStateEffect","runAfterInteractions","Set","flatMap","item","getIds","useCallback","node","children","id","createElement","TreeView","memo"],"sourceRoot":"../../src","sources":["TreeView.tsx"],"mappings":"AAAA,OAAOA,KAAK,I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AC7D,IAAI,CAACA,IAAI,CAACC,QAAQ,IAAID,IAAI,CAACC,QAAQ,CAACjB,MAAM,KAAK,CAAC,EAAE;MAChD,OAAO,CAACgB,IAAI,CAACE,EAAE,CAAC;IAClB,CAAC,MAAM;MACL,OAAO,CAACF,IAAI,CAACE,EAAE,EAAE,GAAGF,IAAI,CAACC,QAAQ,CAACL,OAAO,CAAEC,IAAI,IAAKC,MAAM,CAACD,IAAI,CAAC,CAAC,CAAC;IACpE;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,oBACEjD,KAAA,CAAAuD,aAAA,CAACnD,QAAQ;IACPuB,kBAAkB,EAAEA,kBAAmB;IACvCC,sBAAsB,EAAEA,sBAAuB;IAE/CC,iBAAiB,EAAEA,iBAAkB;IACrCC,2BAA2B,EAAEA,2BAA4B;IACzDC,gCAAgC,EAAEA;EAAiC,CACpE,CAAC;AAEN,CACF,CAAC;AAED,OAAO,MAAMyB,QAAQ,gBAAGxD,KAAK,CAACyD,IAAI,CAACrC,SAAS,CAAC"}
@@ -0,0 +1,68 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ import React from "react";
3
+ import { Platform, StyleSheet, Text, TouchableOpacity, View } from "react-native";
4
+ import { Checkbox } from 'react-native-paper';
5
+ function arePropsEqual(prevProps, nextProps) {
6
+ return prevProps.value === nextProps.value && prevProps.text === nextProps.text;
7
+ }
8
+ export const CheckboxView = /*#__PURE__*/React.memo(_CheckboxView, arePropsEqual);
9
+ function _CheckboxView(props) {
10
+ const {
11
+ value,
12
+ onValueChange,
13
+ text,
14
+ outermostParentViewStyle = defaultCheckboxViewStyles.mainView,
15
+ checkboxParentViewStyle = defaultCheckboxViewStyles.checkboxView,
16
+ textTouchableStyle,
17
+ checkboxProps,
18
+ textProps = {
19
+ style: defaultCheckboxViewStyles.checkboxTextStyle,
20
+ numberOfLines: 1,
21
+ ellipsizeMode: "middle"
22
+ }
23
+ } = props;
24
+ function customCheckboxValueTypeToRNPaperType(customCheckboxValueType) {
25
+ return customCheckboxValueType === 'indeterminate' ? 'indeterminate' : customCheckboxValueType ? 'checked' : 'unchecked';
26
+ }
27
+
28
+ /**
29
+ * This function modifies the change in value when the previous state was indeterminate.
30
+ * If the prior value is 'indeterminate', it will mark the CheckBox as checked upon click.
31
+ *
32
+ * @param newValue This represents the updated CheckBox value after it's clicked.
33
+ */
34
+ function onValueChangeModifier() {
35
+ // If the previous state was 'indeterminate', set checked to true
36
+ if (value === 'indeterminate') onValueChange(true);else onValueChange(!value);
37
+ }
38
+ return /*#__PURE__*/React.createElement(View, {
39
+ style: outermostParentViewStyle
40
+ }, /*#__PURE__*/React.createElement(View, {
41
+ style: checkboxParentViewStyle
42
+ }, /*#__PURE__*/React.createElement(Checkbox.Android, _extends({}, checkboxProps, {
43
+ status: customCheckboxValueTypeToRNPaperType(value),
44
+ onPress: onValueChangeModifier
45
+ }))), text ? /*#__PURE__*/React.createElement(TouchableOpacity, {
46
+ style: textTouchableStyle,
47
+ onPress: onValueChangeModifier
48
+ }, /*#__PURE__*/React.createElement(Text, textProps, text)) : null);
49
+ }
50
+ export const defaultCheckboxViewStyles = StyleSheet.create({
51
+ mainView: {
52
+ alignSelf: 'center',
53
+ alignItems: 'center',
54
+ flexDirection: 'row',
55
+ marginEnd: 10
56
+ },
57
+ checkboxView: {
58
+ marginStart: 5,
59
+ transform: [{
60
+ scale: 1.2
61
+ }]
62
+ },
63
+ checkboxTextStyle: {
64
+ color: "black",
65
+ marginTop: Platform.OS === 'android' ? 2 : undefined
66
+ }
67
+ });
68
+ //# sourceMappingURL=CheckboxView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Platform","StyleSheet","Text","TouchableOpacity","View","Checkbox","arePropsEqual","prevProps","nextProps","value","text","CheckboxView","memo","_CheckboxView","props","onValueChange","outermostParentViewStyle","defaultCheckboxViewStyles","mainView","checkboxParentViewStyle","checkboxView","textTouchableStyle","checkboxProps","textProps","style","checkboxTextStyle","numberOfLines","ellipsizeMode","customCheckboxValueTypeToRNPaperType","customCheckboxValueType","onValueChangeModifier","createElement","Android","_extends","status","onPress","create","alignSelf","alignItems","flexDirection","marginEnd","marginStart","transform","scale","color","marginTop","OS","undefined"],"sourceRoot":"../../../src","sources":["components/CheckboxView.tsx"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACIC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,IAAI,QACD,cAAc;AAErB,SAASC,QAAQ,QAAQ,oBAAoB;AAM7C,SAASC,aAAaA,CAClBC,SAA4B,EAC5BC,SAA4B,EAC9B;EACE,OACID,SAAS,CAACE,KAAK,KAAKD,SAAS,CAACC,KAAK,IACnCF,SAAS,CAACG,IAAI,KAAKF,SAAS,CAACE,IAAI;AAEzC;AAEA,OAAO,MAAMC,YAAY,gBAAGZ,KAAK,CAACa,IAAI,CAACC,aAAa,EAAEP,aAAa,CAAC;AAEpE,SAASO,aAAaA,CAACC,KAAwB,EAAE;EAC7C,MAAM;IACFL,KAAK;IACLM,aAAa;IACbL,IAAI;IAEJM,wBAAwB,GAAGC,yBAAyB,CAACC,QAAQ;IAC7DC,uBAAuB,GAAGF,yBAAyB,CAACG,YAAY;IAChEC,kBAAkB;IAElBC,aAAa;IACbC,SAAS,GAAG;MACRC,KAAK,EAAEP,yBAAyB,CAACQ,iBAAiB;MAClDC,aAAa,EAAE,CAAC;MAChBC,aAAa,EAAE;IACnB;EACJ,CAAC,GAAGb,KAAK;EAET,SAASc,oCAAoCA,CACzCC,uBAA0C,EAC5C;IACE,OAAOA,uBAAuB,KAAK,eAAe,GAC5C,eAAe,GACfA,uBAAuB,GACnB,SAAS,GACT,WAAW;EACzB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACI,SAASC,qBAAqBA,CAAA,EAAG;IAC7B;IACA,IAAIrB,KAAK,KAAK,eAAe,EAAEM,aAAa,CAAC,IAAI,CAAC,CAAC,KAC9CA,aAAa,CAAC,CAACN,KAAK,CAAC;EAC9B;EAEA,oBACIV,KAAA,CAAAgC,aAAA,CAAC3B,IAAI;IACDoB,KAAK,EAAER;EAAyB,gBAChCjB,KAAA,CAAAgC,aAAA,CAAC3B,IAAI;IACDoB,KAAK,EAAEL;EAAwB,gBAC/BpB,KAAA,CAAAgC,aAAA,CAAC1B,QAAQ,CAAC2B,OAAO,EAAAC,QAAA,KACTX,aAAa;IACjBY,MAAM,EAAEN,oCAAoC,CAACnB,KAAK,CAAE;IACpD0B,OAAO,EAAEL;EAAsB,EAAE,CACnC,CAAC,EAENpB,IAAI,gBACDX,KAAA,CAAAgC,aAAA,CAAC5B,gBAAgB;IACbqB,KAAK,EAAEH,kBAAmB;IAC1Bc,OAAO,EAAEL;EAAsB,gBAC/B/B,KAAA,CAAAgC,aAAA,CAAC7B,IAAI,EACGqB,SAAS,EACZb,IACC,CACQ,CAAC,GACnB,IACF,CAAC;AAEf;AAEA,OAAO,MAAMO,yBAAyB,GAAGhB,UAAU,CAACmC,MAAM,CAAC;EACvDlB,QAAQ,EAAE;IACNmB,SAAS,EAAE,QAAQ;IACnBC,UAAU,EAAE,QAAQ;IACpBC,aAAa,EAAE,KAAK;IAEpBC,SAAS,EAAE;EACf,CAAC;EACDpB,YAAY,EAAE;IACVqB,WAAW,EAAE,CAAC;IACdC,SAAS,EAAE,CAAC;MAAEC,KAAK,EAAE;IAAI,CAAC;EAC9B,CAAC;EACDlB,iBAAiB,EAAE;IACfmB,KAAK,EAAE,OAAO;IACdC,SAAS,EAAE7C,QAAQ,CAAC8C,EAAE,KAAK,SAAS,GAAG,CAAC,GAAGC;EAC/C;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import Icon from 'react-native-vector-icons/FontAwesome';
3
+ export default function CustomExpandCollapseIcon(props) {
4
+ const {
5
+ isExpanded
6
+ } = props;
7
+ return /*#__PURE__*/React.createElement(Icon, {
8
+ name: isExpanded ? 'caret-down' : 'caret-right',
9
+ size: 20,
10
+ color: "black"
11
+ });
12
+ }
13
+ //# sourceMappingURL=CustomExpandCollapseIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Icon","CustomExpandCollapseIcon","props","isExpanded","createElement","name","size","color"],"sourceRoot":"../../../src","sources":["components/CustomExpandCollapseIcon.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,IAAI,MAAM,uCAAuC;AAIxD,eAAe,SAASC,wBAAwBA,CAACC,KAAsB,EAAE;EACrE,MAAM;IAAEC;EAAW,CAAC,GAAGD,KAAK;EAE5B,oBACIH,KAAA,CAAAK,aAAA,CAACJ,IAAI;IACDK,IAAI,EACAF,UAAU,GACJ,YAAY,GACZ,aACT;IACDG,IAAI,EAAE,EAAG;IACTC,KAAK,EAAC;EAAO,CAChB,CAAC;AAEV"}