1
- import { ComponentInt , ComponentsInt , ChildInt } from " ./interfaces.ts" ;
1
+ import { ComponentInt , ComponentsInt , ChildInt } from ' ./interfaces.ts' ;
2
2
3
3
interface getSelectableInt {
4
4
[ key : string ] : Array < number > ;
5
5
}
6
6
7
- function getSelectable (
8
- newFocusComponent : ComponentInt ,
9
- components : ComponentsInt
10
- ) {
7
+ function getSelectable ( newFocusComponent : ComponentInt , components : ComponentsInt ) {
11
8
const focusComponentId = newFocusComponent . id ;
12
9
const componentsToCheck = components
13
10
. map ( ( comp : ComponentInt ) => comp . id )
@@ -19,12 +16,12 @@ function findAncestors(
19
16
components : ComponentsInt ,
20
17
currentCompArr : ComponentsInt ,
21
18
componentsToCheck : ComponentsInt ,
22
- ancestors : Array < number > = [ ]
19
+ ancestors : Array < number > = [ ] ,
23
20
) : getSelectableInt {
24
21
if ( ! currentCompArr . length ) {
25
22
return {
26
- ancestors : ancestors ,
27
- selectableChildren : componentsToCheck
23
+ ancestors,
24
+ selectableChildren : componentsToCheck ,
28
25
} ;
29
26
}
30
27
@@ -33,20 +30,16 @@ function findAncestors(
33
30
for ( let i = 0 ; i < components . length ; i ++ ) {
34
31
if ( componentsToCheck . includes ( components [ i ] . id ) ) {
35
32
const myChildren = components [ i ] . childrenArray . map (
36
- ( child : ChildInt ) => child . childComponentId
33
+ ( child : ChildInt ) => child . childComponentId ,
37
34
) ;
38
35
39
- const found = currentCompArr . filter ( ( comp : ComponentInt ) =>
40
- myChildren . includes ( comp )
41
- ) ;
36
+ const found = currentCompArr . filter ( ( comp : ComponentInt ) => myChildren . includes ( comp ) ) ;
42
37
43
38
if ( found . length ) {
44
39
ancestors . push ( components [ i ] . id ) ;
45
40
newAncestors . push ( components [ i ] . id ) ;
46
41
47
- const indexToDelete = componentsToCheck . findIndex (
48
- ( c : Number ) => c === components [ i ] . id
49
- ) ;
42
+ const indexToDelete = componentsToCheck . findIndex ( ( c : Number ) => c === components [ i ] . id ) ;
50
43
51
44
componentsToCheck . splice ( indexToDelete , 1 ) ;
52
45
}
0 commit comments