@neo4j-nvl/interaction-handlers 2.0.0 → 2.1.0
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/CHANGELOG.md +25 -1
- package/README.md +8 -0
- package/lib/constants.d.ts +1 -1
- package/lib/constants.js +4 -2
- package/lib/index.d.ts +10 -20
- package/lib/index.js +10 -10
- package/lib/interaction-handlers/base.d.ts +67 -67
- package/lib/interaction-handlers/base.js +98 -104
- package/lib/interaction-handlers/box-select-interaction.d.ts +44 -44
- package/lib/interaction-handlers/box-select-interaction.js +133 -127
- package/lib/interaction-handlers/click-interaction.d.ts +111 -111
- package/lib/interaction-handlers/click-interaction.js +116 -131
- package/lib/interaction-handlers/drag-node-interaction.d.ts +40 -40
- package/lib/interaction-handlers/drag-node-interaction.js +102 -111
- package/lib/interaction-handlers/draw-interaction.d.ts +37 -37
- package/lib/interaction-handlers/draw-interaction.js +245 -278
- package/lib/interaction-handlers/hover-interaction.d.ts +34 -30
- package/lib/interaction-handlers/hover-interaction.js +83 -89
- package/lib/interaction-handlers/keyboard-interaction.d.ts +149 -97
- package/lib/interaction-handlers/keyboard-interaction.js +255 -201
- package/lib/interaction-handlers/lasso-interaction.d.ts +45 -45
- package/lib/interaction-handlers/lasso-interaction.js +174 -196
- package/lib/interaction-handlers/pan-interaction.d.ts +62 -61
- package/lib/interaction-handlers/pan-interaction.js +111 -100
- package/lib/interaction-handlers/utils.d.ts +2 -2
- package/lib/interaction-handlers/utils.js +39 -38
- package/lib/interaction-handlers/zoom-interaction.d.ts +52 -48
- package/lib/interaction-handlers/zoom-interaction.js +73 -71
- package/lib/overlay-renderer/overlay-renderer.d.ts +13 -13
- package/lib/overlay-renderer/overlay-renderer.js +96 -111
- package/package.json +19 -6
- package/lib/__tests__/box-select-interaction.test.d.ts +0 -1
- package/lib/__tests__/box-select-interaction.test.js +0 -149
- package/lib/__tests__/click-interaction.test.d.ts +0 -1
- package/lib/__tests__/click-interaction.test.js +0 -505
- package/lib/__tests__/drag-node-interaction.test.d.ts +0 -1
- package/lib/__tests__/drag-node-interaction.test.js +0 -247
- package/lib/__tests__/hover-interaction.test.d.ts +0 -1
- package/lib/__tests__/hover-interaction.test.js +0 -374
- package/lib/__tests__/keyboard-interaction.test.d.ts +0 -1
- package/lib/__tests__/keyboard-interaction.test.js +0 -322
- package/lib/__tests__/lasso-interaction.test.d.ts +0 -1
- package/lib/__tests__/lasso-interaction.test.js +0 -219
- package/lib/__tests__/pan-interaction.test.d.ts +0 -1
- package/lib/__tests__/pan-interaction.test.js +0 -223
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -19
- package/lib/__tests__/zoom-interaction.test.d.ts +0 -1
- package/lib/__tests__/zoom-interaction.test.js +0 -185
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to NVL will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
4
4
|
|
|
5
|
-
## [2.
|
|
5
|
+
## [2.1.0] - 2026-11-10
|
|
6
|
+
|
|
7
|
+
This release adds keyboard actions for moving nodes, ships an agent skill for NVL, and makes all packages loadable as ESM in Node.js without a bundler.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
* Keyboard interaction handler actions for moving nodes with the arrow keys, with a new `onNodeMove` callback.
|
|
12
|
+
* Agent skill files for NVL, shipped with `@neo4j-nvl/base`.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
* `@neo4j-nvl/react` and `@neo4j-nvl/interaction-handlers` are now spec-compliant ESM with `"type": "module"` and an `exports` map. Note that deep imports into `lib/` will no longer work.
|
|
17
|
+
* Replaced `lodash` with `lodash-es` in `@neo4j-nvl/react` and `@neo4j-nvl/interaction-handlers` (Jest users transforming `@neo4j-nvl/*` also need to transform `lodash-es`).
|
|
18
|
+
* Type declarations of `@neo4j-nvl/base` now resolve correctly with `moduleResolution: "nodenext"`.
|
|
19
|
+
* Container resizing uses the native `ResizeObserver` instead of the `resizelistener` dependency.
|
|
20
|
+
* Default `height` and `outline` styles of NVL containers can now be overridden by stylesheets.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
* `fit()` zooms out beyond `minZoom` when `allowDynamicMinZoom` is `true` and the graph does not fit the viewport.
|
|
25
|
+
* `onHover` callback's `element` parameter is now typed as possibly `undefined`, matching the runtime behaviour.
|
|
26
|
+
* Added missing caret for the React 18 peer dependency range in `@neo4j-nvl/react`.
|
|
27
|
+
* Several dependency updates
|
|
28
|
+
|
|
29
|
+
## [2.0.0] - 2026-09-15
|
|
6
30
|
|
|
7
31
|
This 2.0.0 major release upgrades NVL to WebGL2 for both the renderer and physics engine, unlocking major performance improvements. It also adds new clustering capabilities with visual decorations to the force directed and hierarchical layouts.
|
|
8
32
|
|
package/README.md
CHANGED
|
@@ -33,4 +33,12 @@ clickInteraction.updateCallback('onNodeClick', (node) => {
|
|
|
33
33
|
|
|
34
34
|
If you are using React and want to add interactivity to your graph, you can also make use of the InteractiveNvlWrapper.
|
|
35
35
|
|
|
36
|
+
### Agent skills
|
|
37
|
+
|
|
38
|
+
The agent skill for NVL (`neo4j-nvl-skill`) ships with `@neo4j-nvl/base`, which this package depends on. To make it available to your AI coding assistant, run the following with a recent version of the `skills` CLI:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx skills experimental_sync
|
|
42
|
+
```
|
|
43
|
+
|
|
36
44
|
You can find more instructions and examples on how to use NVL interaction handlers in the [docs](https://neo4j.com/docs/nvl/current/interaction-handlers/) and [API docs](https://neo4j.com/docs/api/nvl/current/modules/_neo4j_nvl_interaction_handlers.html), as well as in these [NVL code examples](https://neo4j.com/docs/api/nvl/current/examples.html?tab=plain-interaction-module).
|
package/lib/constants.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const NODE_EDGE_WIDTH = 10;
|
|
2
|
-
export declare const DRAG_THRESHOLD = 10;
|
|
2
|
+
export declare const DRAG_THRESHOLD = 10;
|
package/lib/constants.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
import type { KeyboardInteractionCallbacks, KeyboardInteractionOptions } from './interaction-handlers/keyboard-interaction';
|
|
12
|
-
import { KeyboardInteraction } from './interaction-handlers/keyboard-interaction';
|
|
13
|
-
import { LassoInteraction } from './interaction-handlers/lasso-interaction';
|
|
14
|
-
import type { LassoInteractionCallbacks, LassoInteractionOptions } from './interaction-handlers/lasso-interaction';
|
|
15
|
-
import type { PanInteractionCallbacks, PanInteractionOptions } from './interaction-handlers/pan-interaction';
|
|
16
|
-
import { PanInteraction } from './interaction-handlers/pan-interaction';
|
|
17
|
-
import type { ZoomInteractionCallbacks, ZoomInteractionOptions } from './interaction-handlers/zoom-interaction';
|
|
18
|
-
import { ZoomInteraction } from './interaction-handlers/zoom-interaction';
|
|
19
|
-
export type { BoxSelectInteractionOptions, BoxSelectInteractionCallbacks, ClickInteractionOptions, HoverInteractionOptions, HoverInteractionCallbacks, DragNodeInteractionCallbacks, ClickInteractionCallbacks, KeyboardInteractionCallbacks, KeyboardInteractionOptions, PanInteractionCallbacks, DrawInteractionCallbacks, PanInteractionOptions, ZoomInteractionCallbacks, ZoomInteractionOptions, LassoInteractionOptions, LassoInteractionCallbacks, DrawInteractionOptions };
|
|
20
|
-
export { ZoomInteraction, PanInteraction, BoxSelectInteraction, ClickInteraction, HoverInteraction, DragNodeInteraction, DrawInteraction, LassoInteraction, KeyboardInteraction };
|
|
1
|
+
import { BoxSelectInteraction, BoxSelectInteractionCallbacks, BoxSelectInteractionOptions } from "./interaction-handlers/box-select-interaction.js";
|
|
2
|
+
import { ClickInteraction, ClickInteractionCallbacks, ClickInteractionOptions } from "./interaction-handlers/click-interaction.js";
|
|
3
|
+
import { DragNodeInteraction, DragNodeInteractionCallbacks } from "./interaction-handlers/drag-node-interaction.js";
|
|
4
|
+
import { DrawInteraction, DrawInteractionCallbacks, DrawInteractionOptions } from "./interaction-handlers/draw-interaction.js";
|
|
5
|
+
import { HoverInteraction, HoverInteractionCallbacks, HoverInteractionOptions } from "./interaction-handlers/hover-interaction.js";
|
|
6
|
+
import { KeyboardInteraction, KeyboardInteractionCallbacks, KeyboardInteractionOptions } from "./interaction-handlers/keyboard-interaction.js";
|
|
7
|
+
import { LassoInteraction, LassoInteractionCallbacks, LassoInteractionOptions } from "./interaction-handlers/lasso-interaction.js";
|
|
8
|
+
import { PanInteraction, PanInteractionCallbacks, PanInteractionOptions } from "./interaction-handlers/pan-interaction.js";
|
|
9
|
+
import { ZoomInteraction, ZoomInteractionCallbacks, ZoomInteractionOptions } from "./interaction-handlers/zoom-interaction.js";
|
|
10
|
+
export { BoxSelectInteraction, type BoxSelectInteractionCallbacks, type BoxSelectInteractionOptions, ClickInteraction, type ClickInteractionCallbacks, type ClickInteractionOptions, DragNodeInteraction, type DragNodeInteractionCallbacks, DrawInteraction, type DrawInteractionCallbacks, type DrawInteractionOptions, HoverInteraction, type HoverInteractionCallbacks, type HoverInteractionOptions, KeyboardInteraction, type KeyboardInteractionCallbacks, type KeyboardInteractionOptions, LassoInteraction, type LassoInteractionCallbacks, type LassoInteractionOptions, PanInteraction, type PanInteractionCallbacks, type PanInteractionOptions, ZoomInteraction, type ZoomInteractionCallbacks, type ZoomInteractionOptions };
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BoxSelectInteraction } from
|
|
2
|
-
import { ClickInteraction } from
|
|
3
|
-
import { DragNodeInteraction } from
|
|
4
|
-
import { DrawInteraction } from
|
|
5
|
-
import { HoverInteraction } from
|
|
6
|
-
import { KeyboardInteraction } from
|
|
7
|
-
import { LassoInteraction } from
|
|
8
|
-
import { PanInteraction } from
|
|
9
|
-
import { ZoomInteraction } from
|
|
10
|
-
export {
|
|
1
|
+
import { BoxSelectInteraction } from "./interaction-handlers/box-select-interaction.js";
|
|
2
|
+
import { ClickInteraction } from "./interaction-handlers/click-interaction.js";
|
|
3
|
+
import { DragNodeInteraction } from "./interaction-handlers/drag-node-interaction.js";
|
|
4
|
+
import { DrawInteraction } from "./interaction-handlers/draw-interaction.js";
|
|
5
|
+
import { HoverInteraction } from "./interaction-handlers/hover-interaction.js";
|
|
6
|
+
import { KeyboardInteraction } from "./interaction-handlers/keyboard-interaction.js";
|
|
7
|
+
import { LassoInteraction } from "./interaction-handlers/lasso-interaction.js";
|
|
8
|
+
import { PanInteraction } from "./interaction-handlers/pan-interaction.js";
|
|
9
|
+
import { ZoomInteraction } from "./interaction-handlers/zoom-interaction.js";
|
|
10
|
+
export { BoxSelectInteraction, ClickInteraction, DragNodeInteraction, DrawInteraction, HoverInteraction, KeyboardInteraction, LassoInteraction, PanInteraction, ZoomInteraction };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NVL } from "@neo4j-nvl/base";
|
|
2
2
|
/**
|
|
3
3
|
* Base class for all interactions.
|
|
4
4
|
* @abstract
|
|
@@ -6,70 +6,70 @@ import type { NVL } from '@neo4j-nvl/base';
|
|
|
6
6
|
* @hidden
|
|
7
7
|
*/
|
|
8
8
|
declare abstract class BaseInteraction<P extends Record<string, unknown>> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
9
|
+
private readonly nvl;
|
|
10
|
+
private readonly options;
|
|
11
|
+
private readonly container;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
callbackMap: Map<string, ((...args: unknown[]) => void) | boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
constructor(nvl: NVL, options: P);
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* @hidden
|
|
25
|
+
*/
|
|
26
|
+
get nvlInstance(): NVL;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the current options of the interaction.
|
|
29
|
+
* @returns The current options of the interaction.
|
|
30
|
+
*/
|
|
31
|
+
get currentOptions(): P;
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
get containerInstance(): HTMLElement;
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
addEventListener: (type: keyof HTMLElementEventMap, listener: (event: Event) => void, options?: boolean | AddEventListenerOptions) => void;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
removeEventListener: (type: keyof HTMLElementEventMap, listener: (event: Event) => void, options?: boolean | EventListenerOptions) => void;
|
|
47
|
+
/**
|
|
48
|
+
* @internal
|
|
49
|
+
* @hidden
|
|
50
|
+
*/
|
|
51
|
+
callCallbackIfRegistered: (name: string, ...args: unknown[]) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Add or update a callback for a given event of type.
|
|
54
|
+
* @param name - The name of the event.
|
|
55
|
+
* @param callback - The callback to be called when the event is triggered.
|
|
56
|
+
*/
|
|
57
|
+
updateCallback: (name: string, callback: ((...args: unknown[]) => void) | boolean) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Remove a callback for a given event of type.
|
|
60
|
+
* @param name - The name of the event.
|
|
61
|
+
*/
|
|
62
|
+
removeCallback: (name: string) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Enables or disables global text selection during a drag or pan operation.
|
|
65
|
+
* @param enable - Whether to enable or disable global text selection.
|
|
66
|
+
* @param eventFunction - The event function to be added/removed when text selection is disabled/enabled.
|
|
67
|
+
*/
|
|
68
|
+
toggleGlobalTextSelection: (enable: boolean, eventFunction?: (this: HTMLElement, ev: MouseEvent) => void) => void;
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
* @hidden
|
|
72
|
+
*/
|
|
73
|
+
abstract destroy(): void;
|
|
74
74
|
}
|
|
75
|
-
export { BaseInteraction };
|
|
75
|
+
export { BaseInteraction };
|
|
@@ -1,106 +1,100 @@
|
|
|
1
|
+
// src/interaction-handlers/base.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
document.body.style.setProperty('user-select', 'none', 'important');
|
|
100
|
-
if (eventFunction) {
|
|
101
|
-
document.body.addEventListener('mouseup', eventFunction);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
3
|
+
* Base class for all interactions.
|
|
4
|
+
* @abstract
|
|
5
|
+
* @internal
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
var BaseInteraction = class {
|
|
9
|
+
nvl;
|
|
10
|
+
options;
|
|
11
|
+
container;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
callbackMap;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
* @hidden
|
|
20
|
+
*/
|
|
21
|
+
constructor(nvl, options) {
|
|
22
|
+
this.nvl = nvl;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.container = this.nvl.getContainer();
|
|
25
|
+
this.callbackMap = /* @__PURE__ */ new Map();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @internal
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
get nvlInstance() {
|
|
32
|
+
return this.nvl;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the current options of the interaction.
|
|
36
|
+
* @returns The current options of the interaction.
|
|
37
|
+
*/
|
|
38
|
+
get currentOptions() {
|
|
39
|
+
return this.options;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
get containerInstance() {
|
|
46
|
+
return this.container;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
* @hidden
|
|
51
|
+
*/
|
|
52
|
+
addEventListener = (type, listener, options) => {
|
|
53
|
+
this.container?.addEventListener(type, listener, options);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* @hidden
|
|
58
|
+
*/
|
|
59
|
+
removeEventListener = (type, listener, options) => {
|
|
60
|
+
this.container?.removeEventListener(type, listener, options);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
callCallbackIfRegistered = (name, ...args) => {
|
|
67
|
+
const callback = this.callbackMap.get(name);
|
|
68
|
+
if (typeof callback === "function") callback(...args);
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Add or update a callback for a given event of type.
|
|
72
|
+
* @param name - The name of the event.
|
|
73
|
+
* @param callback - The callback to be called when the event is triggered.
|
|
74
|
+
*/
|
|
75
|
+
updateCallback = (name, callback) => {
|
|
76
|
+
this.callbackMap.set(name, callback);
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Remove a callback for a given event of type.
|
|
80
|
+
* @param name - The name of the event.
|
|
81
|
+
*/
|
|
82
|
+
removeCallback = (name) => {
|
|
83
|
+
this.callbackMap.delete(name);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Enables or disables global text selection during a drag or pan operation.
|
|
87
|
+
* @param enable - Whether to enable or disable global text selection.
|
|
88
|
+
* @param eventFunction - The event function to be added/removed when text selection is disabled/enabled.
|
|
89
|
+
*/
|
|
90
|
+
toggleGlobalTextSelection = (enable, eventFunction) => {
|
|
91
|
+
if (enable) {
|
|
92
|
+
document.body.style.removeProperty("user-select");
|
|
93
|
+
if (eventFunction) document.body.removeEventListener("mouseup", eventFunction);
|
|
94
|
+
} else {
|
|
95
|
+
document.body.style.setProperty("user-select", "none", "important");
|
|
96
|
+
if (eventFunction) document.body.addEventListener("mouseup", eventFunction);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
106
100
|
export { BaseInteraction };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { BaseInteraction } from "./base.js";
|
|
2
|
+
import { NVL, Node, Relationship } from "@neo4j-nvl/base";
|
|
3
3
|
/**
|
|
4
4
|
* Options for the multi-select interaction handler to customize its behavior.
|
|
5
5
|
*/
|
|
6
6
|
export type BoxSelectInteractionOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* If true, the selection will be applied when the mouse is released.
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
selectOnRelease?: boolean;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Callbacks for the box select interaction handler.
|
|
15
15
|
*/
|
|
16
16
|
export type BoxSelectInteractionCallbacks = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Called once when the user presses the mouse on the canvas, starting the box selection.
|
|
19
|
+
* @param event - The original mouse event.
|
|
20
|
+
*/
|
|
21
|
+
onBoxStarted?: ((event: MouseEvent) => void) | boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Called once the user releases the mouse after multi-selecting.
|
|
24
|
+
* @param selectionObject - The selected nodes and relationships.
|
|
25
|
+
* @param event - The original mouse event.
|
|
26
|
+
*/
|
|
27
|
+
onBoxSelect?: (({ nodes, rels }: {
|
|
28
|
+
nodes: Node[];
|
|
29
|
+
rels: Relationship[];
|
|
30
|
+
}, event: MouseEvent) => void) | boolean;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* An interaction handler for multi-selecting nodes and relationships.
|
|
@@ -36,26 +36,26 @@ export type BoxSelectInteractionCallbacks = {
|
|
|
36
36
|
* For examples, head to the {@link https://neo4j.com/docs/nvl/current/interaction-handlers/#_boxselectinteraction Box Select Interaction documentation page}.
|
|
37
37
|
*/
|
|
38
38
|
export declare class BoxSelectInteraction extends BaseInteraction<BoxSelectInteractionOptions> {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
39
|
+
private mousePosition;
|
|
40
|
+
private startWorldPosition;
|
|
41
|
+
private startClientPosition;
|
|
42
|
+
private overlayRenderer;
|
|
43
|
+
private isBoxSelecting;
|
|
44
|
+
private boxSelectPending;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new instance of the multi-select interaction handler.
|
|
47
|
+
* @param nvl - The NVL instance to attach the interaction handler to.
|
|
48
|
+
* @param options - Options for the multi-select interaction handler to customize its behavior.
|
|
49
|
+
*/
|
|
50
|
+
constructor(nvl: NVL, options?: BoxSelectInteractionOptions);
|
|
51
|
+
private handleMouseDown;
|
|
52
|
+
private handleDrag;
|
|
53
|
+
private getHitsInBox;
|
|
54
|
+
private endBoxSelect;
|
|
55
|
+
/**
|
|
56
|
+
* Removes all related event listeners and the overlay renderer for the box.
|
|
57
|
+
*/
|
|
58
|
+
destroy(): void;
|
|
59
|
+
private activateBoxSelect;
|
|
60
|
+
private turnOnBoxSelect;
|
|
61
|
+
}
|