|
| 1 | +// Import Internal Dependencies |
| 2 | +import { PackageInfo } from "../components/package/package.js"; |
| 3 | + |
1 | 4 | export class NetworkNavigation {
|
2 | 5 | /**
|
3 | 6 | * @type {import("@nodesecure/vis-network").NodeSecureDataSet}
|
@@ -62,6 +65,11 @@ export class NetworkNavigation {
|
62 | 65 | * Represents the active locked node index.
|
63 | 66 | */
|
64 | 67 | #lockedNodesActiveIndex = 0;
|
| 68 | + /** |
| 69 | + * -`true` package info navigation\ |
| 70 | + * -`false` network navigation |
| 71 | + */ |
| 72 | + #packageInfoFocus = false; |
65 | 73 |
|
66 | 74 | set currentNodeParams(params) {
|
67 | 75 | this.#currentNodeParams = params;
|
@@ -119,6 +127,24 @@ export class NetworkNavigation {
|
119 | 127 | return;
|
120 | 128 | }
|
121 | 129 |
|
| 130 | + if (event.code === "Enter") { |
| 131 | + this.#packageInfoFocus = !this.#packageInfoFocus; |
| 132 | + console.log(`[INFO] keyboard navigation switched (focus:${this.#packageInfoFocus ? "package-info" : "network"})`); |
| 133 | + } |
| 134 | + |
| 135 | + if (this.#packageInfoFocus) { |
| 136 | + if (["ArrowLeft", "ArrowRight"].includes(event.code)) { |
| 137 | + const direction = event.code === "ArrowLeft" ? "previous" : "next"; |
| 138 | + PackageInfo.switch(direction); |
| 139 | + } |
| 140 | + else if (["ArrowUp", "ArrowDown"].includes(event.code)) { |
| 141 | + const direction = event.code === "ArrowUp" ? "up" : "down"; |
| 142 | + PackageInfo.scroll(direction); |
| 143 | + } |
| 144 | + |
| 145 | + return; |
| 146 | + } |
| 147 | + |
122 | 148 | const nodeParam = this.#currentNodeParams ?? this.rootNodeParams;
|
123 | 149 |
|
124 | 150 | if (this.#nsn.lastHighlightedIds === null) {
|
|
0 commit comments