pixel-react 1.9.3 → 1.9.5

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 (33) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/lib/components/Charts/MultiRadialChart/types.d.ts +2 -2
  3. package/lib/components/TableTree/types.d.ts +27 -3
  4. package/lib/components/Tabs/Tabs.d.ts +1 -1
  5. package/lib/components/Tabs/types.d.ts +1 -0
  6. package/lib/index.d.ts +105 -9
  7. package/lib/index.esm.js +121 -29
  8. package/lib/index.esm.js.map +1 -1
  9. package/lib/index.js +122 -28
  10. package/lib/index.js.map +1 -1
  11. package/lib/tsconfig.tsbuildinfo +1 -1
  12. package/lib/utils/getTreeDetails/getTreeDetails.d.ts +38 -0
  13. package/lib/utils/handleTreeNodeSelect/handleTreeNodeSelect.d.ts +31 -0
  14. package/package.json +1 -1
  15. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.scss +6 -3
  16. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
  17. package/src/components/Charts/MultiRadialChart/types.ts +16 -17
  18. package/src/components/TableTree/Components/TableBody.tsx +0 -3
  19. package/src/components/TableTree/Components/TableCell.tsx +2 -3
  20. package/src/components/TableTree/TableTree.scss +11 -1
  21. package/src/components/TableTree/TableTree.tsx +24 -13
  22. package/src/components/TableTree/data.ts +86 -1
  23. package/src/components/TableTree/types.ts +27 -3
  24. package/src/components/Tabs/Tabs.scss +44 -1
  25. package/src/components/Tabs/Tabs.stories.tsx +26 -0
  26. package/src/components/Tabs/Tabs.tsx +2 -0
  27. package/src/components/Tabs/types.ts +1 -0
  28. package/src/index.ts +11 -3
  29. package/src/utils/findAndInsert/findAndInsert.stories.tsx +1 -0
  30. package/src/utils/getTreeDetails/getTreeDetails.stories.tsx +167 -0
  31. package/src/utils/getTreeDetails/getTreeDetails.ts +93 -0
  32. package/src/utils/handleTreeNodeSelect/HandleTreeNodeSelect.stories.tsx +195 -0
  33. package/src/utils/handleTreeNodeSelect/handleTreeNodeSelect.ts +90 -0
@@ -0,0 +1,90 @@
1
+ export type TreeNode = {
2
+ createdBy: string;
3
+ modifiedBy: string;
4
+ createdByUname: string;
5
+ modifiedByUname: string;
6
+ createdOn: string;
7
+ modifiedOn: string;
8
+ state: string;
9
+ path: string;
10
+ searchKey: string;
11
+ key: string;
12
+ name: string;
13
+ projectId: string;
14
+ hierarchy: number;
15
+ executionOrder: number;
16
+ subContainerCount: number;
17
+ resourceCount: number;
18
+ totalSubContainerCount: number;
19
+ totalResourceCount: number;
20
+ totalProjectElementCount: number;
21
+ totalSharedElementCount: number;
22
+ container: boolean;
23
+ localDelete: boolean;
24
+ defaultEntity: boolean;
25
+ lastResource: boolean;
26
+ platform?: string;
27
+ parentId?: string;
28
+ parentName?: string;
29
+ checked?: boolean | 'partial';
30
+ };
31
+
32
+ export const handleTreeNodeSect = (
33
+ data: TreeNode[],
34
+ key: string,
35
+ isChecked: boolean | 'partial'
36
+ ): TreeNode[] => {
37
+ const nodesMap = new Map<string, TreeNode>();
38
+
39
+ // Build a map for quick access to nodes by key
40
+ data.forEach((node) => nodesMap.set(node.key, node));
41
+
42
+ // Helper to update child nodes
43
+ function updateChildren(nodeKey: string, checkedStatus: boolean | 'partial') {
44
+ for (const node of data) {
45
+ if (node.parentId === nodeKey) {
46
+ node.checked = checkedStatus;
47
+ updateChildren(node.key, checkedStatus);
48
+ }
49
+ }
50
+ }
51
+
52
+ // Helper to update parent nodes
53
+ function updateParents(nodeKey: string) {
54
+ const node = nodesMap.get(nodeKey);
55
+ if (node && node.parentId) {
56
+ const parentNode = nodesMap.get(node.parentId);
57
+ if (parentNode) {
58
+ const siblings = data.filter(
59
+ (sibling) => sibling.parentId === parentNode.key
60
+ );
61
+ const allChecked = siblings.every(
62
+ (sibling) => sibling.checked === true
63
+ );
64
+ const someChecked = siblings.some(
65
+ (sibling) => sibling.checked === true || sibling.checked === 'partial'
66
+ );
67
+
68
+ parentNode.checked = allChecked
69
+ ? true
70
+ : someChecked
71
+ ? 'partial'
72
+ : false;
73
+
74
+ updateParents(parentNode.key);
75
+ }
76
+ }
77
+ }
78
+
79
+ // Find the target node and update its state
80
+ const targetNode = nodesMap.get(key);
81
+ if (targetNode) {
82
+ targetNode.checked = isChecked;
83
+ // Update children recursively
84
+ updateChildren(key, isChecked);
85
+ // Update parents recursively
86
+ updateParents(key);
87
+ }
88
+
89
+ return data;
90
+ };