@@ -21,52 +21,106 @@ const root = '#d2f5e3';
21
21
//
22
22
23
23
const clusterData = { } ;
24
- let memoizeObj = { } ;
24
+ let memoizeObjSelectors = { } ;
25
25
26
26
function clusterDataPopulate ( props ) {
27
- let atomCompObj = reorganizedObj ( props ) ;
28
-
27
+ let atomCompObj = reorganizedCompObj ( props ) ;
28
+ console . log ( props )
29
+ console . log ( atomCompObj )
30
+
31
+ //this is to set the root name property
29
32
if ( props [ 0 ] . name ) {
30
33
clusterData . name = props [ 0 ] . name ;
31
34
}
32
35
33
- let counter = 0 ;
36
+ //internal counter for the array
37
+ let ocounter = 0 ;
38
+ let icounter = 0
34
39
for ( let key in atomCompObj ) {
35
- if ( atomCompObj [ key ] . length ) {
36
- for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
37
- if ( ! memoizeObj [ key ] ) {
38
- memoizeObj [ key ] = [ ] ;
39
- if ( ! clusterData . children ) clusterData . children = [ ] ;
40
- clusterData . children . push ( { name : key } ) ;
41
- }
42
- if ( ! memoizeObj [ key ] . includes ( atomCompObj [ key ] [ i ] ) ) {
43
- if ( ! clusterData . children [ counter ] . children )
44
- clusterData . children [ counter ] . children = [ ] ;
45
- clusterData . children [ counter ] . children . push ( {
46
- name : atomCompObj [ key ] [ i ] ,
47
- } ) ;
48
- }
49
- memoizeObj [ key ] . push ( atomCompObj [ key ] [ i ] ) ;
40
+
41
+ if ( props [ 0 ] . atomSelectors [ key ] ) {
42
+ if ( ! clusterData . children ) {
43
+ clusterData . children = [ ]
44
+ }
45
+ //need to handle duplicates
46
+ clusterData . children . push ( { name : key } ) ;
47
+
48
+ if ( props [ 0 ] . atomSelectors [ key ] . length ) {
49
+ for ( let i = 0 ; i < props [ 0 ] . atomSelectors [ key ] . length ; i ++ ) {
50
+ if ( ! clusterData . children [ ocounter ] . children ) {
51
+ clusterData . children [ ocounter ] . children = [ ]
52
+ }
53
+ clusterData . children [ ocounter ] . children . push ( {
54
+ name : props [ 0 ] . atomSelectors [ key ] [ i ]
55
+ } )
56
+ for ( let i = 0 ; i < clusterData . children [ ocounter ] . children [ icounter ] )
57
+
58
+ }
59
+ }
60
+ outercounter ++
61
+ }
62
+ }
63
+
64
+ console . log ( clusterData )
65
+ }
66
+
67
+
68
+
69
+ // if (atomCompObj[key].length) {
70
+ // for (let i = 0; i < atomCompObj[key].length; i++) {
71
+
72
+ // if (!memoizeObj[key]) {
73
+ // memoizeObj[key] = [];
74
+ // if (!clusterData.children && !props[0].atomSelectors[key]) clusterData.children = [];
75
+ // clusterData.children.push({ name: key });
76
+ // }
77
+
78
+
79
+ // if (!memoizeObj[key].includes(atomCompObj[key][i])) {
80
+ // if (!clusterData.children[counter].children)
81
+ // clusterData.children[counter].children = [];
82
+ // clusterData.children[counter].children.push({
83
+ // name: atomCompObj[key][i],
84
+ // });
85
+ // }
86
+ // memoizeObj[key].push(atomCompObj[key][i]);
87
+ // }
88
+ // }
89
+ // counter++;
90
+ // }
91
+ // console.log(clusterData)
92
+
93
+
94
+ function reorganizedCompObj ( props ) {
95
+ let atomsComponentObj = props [ 0 ] . atomsComponents ;
96
+ let reorganizedCompObj = { } ;
97
+
98
+ for ( const key in atomsComponentObj ) {
99
+ for ( let i = 0 ; i < atomsComponentObj [ key ] . length ; i ++ ) {
100
+ if ( ! reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] ) {
101
+ reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] = [ key ] ;
102
+ } else {
103
+ reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] . push ( key ) ;
50
104
}
51
105
}
52
- counter ++ ;
53
106
}
107
+ return reorganizedCompObj ;
54
108
}
55
109
56
- function reorganizedObj ( props ) {
110
+ function reorganizedFamObj ( props ) {
57
111
let atomsComponentObj = props [ 0 ] . atomsComponents ;
58
- let reorganizedObj = { } ;
112
+ let reorganizedCompObj = { } ;
59
113
60
114
for ( const key in atomsComponentObj ) {
61
115
for ( let i = 0 ; i < atomsComponentObj [ key ] . length ; i ++ ) {
62
- if ( ! reorganizedObj [ atomsComponentObj [ key ] [ i ] ] ) {
63
- reorganizedObj [ atomsComponentObj [ key ] [ i ] ] = [ key ] ;
116
+ if ( ! reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] ) {
117
+ reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] = [ key ] ;
64
118
} else {
65
- reorganizedObj [ atomsComponentObj [ key ] [ i ] ] . push ( key ) ;
119
+ reorganizedCompObj [ atomsComponentObj [ key ] [ i ] ] . push ( key ) ;
66
120
}
67
121
}
68
122
}
69
- return reorganizedObj ;
123
+ return reorganizedCompObj ;
70
124
}
71
125
72
126
function Node ( { node } ) {
0 commit comments