@painekillers/tree-builder-viewer 1.0.0 → 1.0.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.
- package/package.json +4 -3
- package/viewer.js +27 -2
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@painekillers/tree-builder-viewer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": "./
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./themes/*": "./themes/*"
|
|
7
8
|
},
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"@painekillers/tree-builder-core": "^1.0.0"
|
|
10
11
|
}
|
|
11
|
-
}
|
|
12
|
+
}
|
package/viewer.js
CHANGED
|
@@ -35,9 +35,12 @@ export default class Viewer {
|
|
|
35
35
|
#search
|
|
36
36
|
#tooltip
|
|
37
37
|
|
|
38
|
+
#uiUpdates
|
|
39
|
+
|
|
38
40
|
#enabled = false
|
|
39
41
|
|
|
40
42
|
recurse = true
|
|
43
|
+
strategy = "First"
|
|
41
44
|
/*
|
|
42
45
|
Null: No recursion
|
|
43
46
|
False: Creates fake nodes when encountering recursion
|
|
@@ -544,7 +547,8 @@ export default class Viewer {
|
|
|
544
547
|
root.addEventListener("click", () => {
|
|
545
548
|
this.#bridge.calculateLayout(
|
|
546
549
|
result.entry.value.id,
|
|
547
|
-
this.recurse
|
|
550
|
+
this.recurse,
|
|
551
|
+
this.strategy
|
|
548
552
|
)
|
|
549
553
|
|
|
550
554
|
this.#bridge.calculateDraw(
|
|
@@ -609,6 +613,12 @@ export default class Viewer {
|
|
|
609
613
|
updateThemeMenu()
|
|
610
614
|
updateSearchResults()
|
|
611
615
|
|
|
616
|
+
this.#uiUpdates = {
|
|
617
|
+
updateThemeButtons,
|
|
618
|
+
updateThemeMenu,
|
|
619
|
+
updateSearchResults
|
|
620
|
+
}
|
|
621
|
+
|
|
612
622
|
// Init tooltip
|
|
613
623
|
this.tooltip = {
|
|
614
624
|
offset: 12,
|
|
@@ -629,6 +639,9 @@ export default class Viewer {
|
|
|
629
639
|
name: node.id,
|
|
630
640
|
value: node
|
|
631
641
|
}))
|
|
642
|
+
|
|
643
|
+
this.updateUi()
|
|
644
|
+
|
|
632
645
|
}
|
|
633
646
|
|
|
634
647
|
set tooltip({
|
|
@@ -650,6 +663,15 @@ export default class Viewer {
|
|
|
650
663
|
)
|
|
651
664
|
}
|
|
652
665
|
|
|
666
|
+
updateUi(updateTheme = false) {
|
|
667
|
+
this.#uiUpdates.updateSearchResults()
|
|
668
|
+
|
|
669
|
+
if (updateTheme) {
|
|
670
|
+
this.#uiUpdates.updateThemeButtons()
|
|
671
|
+
this.#uiUpdates.updateThemeMenu()
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
653
675
|
setRoot(root) {
|
|
654
676
|
if(!this.#graph) {
|
|
655
677
|
console.warn(
|
|
@@ -661,7 +683,8 @@ export default class Viewer {
|
|
|
661
683
|
|
|
662
684
|
this.#bridge.calculateLayout(
|
|
663
685
|
root,
|
|
664
|
-
this.recurse
|
|
686
|
+
this.recurse,
|
|
687
|
+
this.strategy
|
|
665
688
|
)
|
|
666
689
|
}
|
|
667
690
|
|
|
@@ -696,6 +719,8 @@ export default class Viewer {
|
|
|
696
719
|
this.#bridge.createObjects(
|
|
697
720
|
maxDepth ?? null
|
|
698
721
|
)
|
|
722
|
+
|
|
723
|
+
this.updateUi()
|
|
699
724
|
}
|
|
700
725
|
|
|
701
726
|
enable() {
|