@painekillers/tree-builder-viewer 1.0.1 → 1.0.3

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 (2) hide show
  1. package/package.json +2 -2
  2. package/viewer.js +21 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@painekillers/tree-builder-viewer",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -9,4 +9,4 @@
9
9
  "dependencies": {
10
10
  "@painekillers/tree-builder-core": "^1.0.0"
11
11
  }
12
- }
12
+ }
package/viewer.js CHANGED
@@ -40,13 +40,23 @@ export default class Viewer {
40
40
  #enabled = false
41
41
 
42
42
  recurse = true
43
+ strategy = "First"
43
44
  /*
45
+ Recursion settings
44
46
  Null: No recursion
45
47
  False: Creates fake nodes when encountering recursion
46
48
  True: Connects back to existing instance of a node when recursing
47
49
  #: Real recursion to depths #
48
50
  */
49
51
 
52
+ /*
53
+ Strategies
54
+ - [X] Current BFS (First) — Layer by shortest distance from root; first discovery determines placement.
55
+ - [X] Undirected BFS (Undirected) — Shortest distance to root; layering is on directional.
56
+ - [X] Directed BFS, outward only (Outwards) — Follow prerequisite-to-dependent edges only.
57
+ - [X] Furthest-parent layering (Furthest) — Place each node one layer below its deepest prerequisite.
58
+ */
59
+
50
60
  constructor(container, themes) {
51
61
  this.#container = container
52
62
 
@@ -546,7 +556,8 @@ export default class Viewer {
546
556
  root.addEventListener("click", () => {
547
557
  this.#bridge.calculateLayout(
548
558
  result.entry.value.id,
549
- this.recurse
559
+ this.recurse,
560
+ this.strategy
550
561
  )
551
562
 
552
563
  this.#bridge.calculateDraw(
@@ -661,8 +672,13 @@ export default class Viewer {
661
672
  )
662
673
  }
663
674
 
664
- updateUi() {
665
- Object.values(this.#uiUpdates).forEach(callback => callback())
675
+ updateUi(updateTheme = false) {
676
+ this.#uiUpdates.updateSearchResults()
677
+
678
+ if (updateTheme) {
679
+ this.#uiUpdates.updateThemeButtons()
680
+ this.#uiUpdates.updateThemeMenu()
681
+ }
666
682
  }
667
683
 
668
684
  setRoot(root) {
@@ -676,7 +692,8 @@ export default class Viewer {
676
692
 
677
693
  this.#bridge.calculateLayout(
678
694
  root,
679
- this.recurse
695
+ this.recurse,
696
+ this.strategy
680
697
  )
681
698
  }
682
699