@neo4j-nvl/react 1.0.0-d107600c → 1.0.0-d4b29aaa
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.
|
@@ -11,7 +11,37 @@ jest.mock('@neo4j-nvl/interaction-handlers');
|
|
|
11
11
|
const MockedNVL = NVL;
|
|
12
12
|
let mockOnInitialization;
|
|
13
13
|
HoverInteraction.prototype.callbackMap = new Map();
|
|
14
|
+
HoverInteraction.prototype.updateCallback = jest.fn();
|
|
15
|
+
HoverInteraction.prototype.removeCallback = jest.fn();
|
|
16
|
+
HoverInteraction.prototype.destroy = jest.fn();
|
|
14
17
|
PanInteraction.prototype.callbackMap = new Map();
|
|
18
|
+
PanInteraction.prototype.updateCallback = jest.fn();
|
|
19
|
+
PanInteraction.prototype.removeCallback = jest.fn();
|
|
20
|
+
PanInteraction.prototype.destroy = jest.fn();
|
|
21
|
+
ClickInteraction.prototype.callbackMap = new Map();
|
|
22
|
+
ClickInteraction.prototype.updateCallback = jest.fn();
|
|
23
|
+
ClickInteraction.prototype.removeCallback = jest.fn();
|
|
24
|
+
ClickInteraction.prototype.destroy = jest.fn();
|
|
25
|
+
ZoomInteraction.prototype.callbackMap = new Map();
|
|
26
|
+
ZoomInteraction.prototype.updateCallback = jest.fn();
|
|
27
|
+
ZoomInteraction.prototype.removeCallback = jest.fn();
|
|
28
|
+
ZoomInteraction.prototype.destroy = jest.fn();
|
|
29
|
+
DragNodeInteraction.prototype.callbackMap = new Map();
|
|
30
|
+
DragNodeInteraction.prototype.updateCallback = jest.fn();
|
|
31
|
+
DragNodeInteraction.prototype.removeCallback = jest.fn();
|
|
32
|
+
DragNodeInteraction.prototype.destroy = jest.fn();
|
|
33
|
+
DrawInteraction.prototype.callbackMap = new Map();
|
|
34
|
+
DrawInteraction.prototype.updateCallback = jest.fn();
|
|
35
|
+
DrawInteraction.prototype.removeCallback = jest.fn();
|
|
36
|
+
DrawInteraction.prototype.destroy = jest.fn();
|
|
37
|
+
BoxSelectInteraction.prototype.callbackMap = new Map();
|
|
38
|
+
BoxSelectInteraction.prototype.updateCallback = jest.fn();
|
|
39
|
+
BoxSelectInteraction.prototype.removeCallback = jest.fn();
|
|
40
|
+
BoxSelectInteraction.prototype.destroy = jest.fn();
|
|
41
|
+
LassoInteraction.prototype.callbackMap = new Map();
|
|
42
|
+
LassoInteraction.prototype.updateCallback = jest.fn();
|
|
43
|
+
LassoInteraction.prototype.removeCallback = jest.fn();
|
|
44
|
+
LassoInteraction.prototype.destroy = jest.fn();
|
|
15
45
|
let mockDestroy;
|
|
16
46
|
let destroyHoverInteraction;
|
|
17
47
|
let destroyPanInteraction;
|
|
@@ -34,6 +64,12 @@ describe('InteractiveNvlWrapper', () => {
|
|
|
34
64
|
jest.spyOn(NVL.prototype, 'destroy').mockImplementation(mockDestroy);
|
|
35
65
|
jest.spyOn(HoverInteraction.prototype, 'destroy').mockImplementation(destroyHoverInteraction);
|
|
36
66
|
jest.spyOn(PanInteraction.prototype, 'destroy').mockImplementation(destroyPanInteraction);
|
|
67
|
+
jest.spyOn(ClickInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
68
|
+
jest.spyOn(ZoomInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
69
|
+
jest.spyOn(DragNodeInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
70
|
+
jest.spyOn(DrawInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
71
|
+
jest.spyOn(BoxSelectInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
72
|
+
jest.spyOn(LassoInteraction.prototype, 'destroy').mockImplementation(jest.fn());
|
|
37
73
|
});
|
|
38
74
|
afterEach(() => {
|
|
39
75
|
jest.clearAllMocks();
|
|
@@ -75,6 +111,148 @@ describe('InteractiveNvlWrapper', () => {
|
|
|
75
111
|
expect(BoxSelectInteraction).not.toHaveBeenCalled();
|
|
76
112
|
expect(LassoInteraction).not.toHaveBeenCalled();
|
|
77
113
|
});
|
|
114
|
+
test.each([
|
|
115
|
+
{
|
|
116
|
+
name: 'HoverInteraction',
|
|
117
|
+
InteractionClass: HoverInteraction,
|
|
118
|
+
callback: { onHover: jest.fn() },
|
|
119
|
+
options: { drawShadowOnHover: true }
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'ClickInteraction with onCanvasClick',
|
|
123
|
+
InteractionClass: ClickInteraction,
|
|
124
|
+
callback: { onCanvasClick: jest.fn() },
|
|
125
|
+
options: { selectOnClick: false }
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'ClickInteraction with onCanvasDoubleClick',
|
|
129
|
+
InteractionClass: ClickInteraction,
|
|
130
|
+
callback: { onCanvasDoubleClick: jest.fn() },
|
|
131
|
+
options: { selectOnClick: false }
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'ClickInteraction with onCanvasRightClick',
|
|
135
|
+
InteractionClass: ClickInteraction,
|
|
136
|
+
callback: { onCanvasRightClick: jest.fn() },
|
|
137
|
+
options: { selectOnClick: false }
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'ClickInteraction with onNodeClick',
|
|
141
|
+
InteractionClass: ClickInteraction,
|
|
142
|
+
callback: { onNodeClick: jest.fn() },
|
|
143
|
+
options: { selectOnClick: true }
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'ClickInteraction with onNodeDoubleClick',
|
|
147
|
+
InteractionClass: ClickInteraction,
|
|
148
|
+
callback: { onNodeDoubleClick: jest.fn() },
|
|
149
|
+
options: { selectOnClick: false }
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'ClickInteraction with onNodeRightClick',
|
|
153
|
+
InteractionClass: ClickInteraction,
|
|
154
|
+
callback: { onNodeRightClick: jest.fn() },
|
|
155
|
+
options: { selectOnClick: false }
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'ClickInteraction with onRelationshipClick',
|
|
159
|
+
InteractionClass: ClickInteraction,
|
|
160
|
+
callback: { onRelationshipClick: jest.fn() },
|
|
161
|
+
options: { selectOnClick: false }
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: 'ClickInteraction with onRelationshipDoubleClick',
|
|
165
|
+
InteractionClass: ClickInteraction,
|
|
166
|
+
callback: { onRelationshipDoubleClick: jest.fn() },
|
|
167
|
+
options: { selectOnClick: false }
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'ClickInteraction with onRelationshipRightClick',
|
|
171
|
+
InteractionClass: ClickInteraction,
|
|
172
|
+
callback: { onRelationshipRightClick: jest.fn() },
|
|
173
|
+
options: { selectOnClick: false }
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'PanInteraction',
|
|
177
|
+
InteractionClass: PanInteraction,
|
|
178
|
+
callback: { onPan: jest.fn() },
|
|
179
|
+
options: {}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: 'ZoomInteraction',
|
|
183
|
+
InteractionClass: ZoomInteraction,
|
|
184
|
+
callback: { onZoom: jest.fn() },
|
|
185
|
+
options: {}
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'DragNodeInteraction with onDrag',
|
|
189
|
+
InteractionClass: DragNodeInteraction,
|
|
190
|
+
callback: { onDrag: jest.fn() },
|
|
191
|
+
options: { selectOnRelease: false }
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'DragNodeInteraction with onDragStart',
|
|
195
|
+
InteractionClass: DragNodeInteraction,
|
|
196
|
+
callback: { onDragStart: jest.fn() },
|
|
197
|
+
options: {}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'DragNodeInteraction with onDragEnd',
|
|
201
|
+
InteractionClass: DragNodeInteraction,
|
|
202
|
+
callback: { onDragEnd: jest.fn() },
|
|
203
|
+
options: {}
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'DrawInteraction with onHoverNodeMargin',
|
|
207
|
+
InteractionClass: DrawInteraction,
|
|
208
|
+
callback: { onHoverNodeMargin: jest.fn() },
|
|
209
|
+
options: { excludeNodeMargin: false }
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'DrawInteraction with onDrawStarted',
|
|
213
|
+
InteractionClass: DrawInteraction,
|
|
214
|
+
callback: { onDrawStarted: jest.fn() },
|
|
215
|
+
options: {}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'DrawInteraction with onDrawEnded',
|
|
219
|
+
InteractionClass: DrawInteraction,
|
|
220
|
+
callback: { onDrawEnded: jest.fn() },
|
|
221
|
+
options: {}
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'BoxSelectInteraction with onBoxStarted',
|
|
225
|
+
InteractionClass: BoxSelectInteraction,
|
|
226
|
+
callback: { onBoxStarted: jest.fn() },
|
|
227
|
+
options: {}
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'BoxSelectInteraction with onBoxSelect',
|
|
231
|
+
InteractionClass: BoxSelectInteraction,
|
|
232
|
+
callback: { onBoxSelect: jest.fn() },
|
|
233
|
+
options: {}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'LassoInteraction with onLassoStarted',
|
|
237
|
+
InteractionClass: LassoInteraction,
|
|
238
|
+
callback: { onLassoStarted: jest.fn() },
|
|
239
|
+
options: {}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'LassoInteraction with onLassoSelect',
|
|
243
|
+
InteractionClass: LassoInteraction,
|
|
244
|
+
callback: { onLassoSelect: jest.fn() },
|
|
245
|
+
options: {}
|
|
246
|
+
}
|
|
247
|
+
])('initialises $name when its callback is provided', ({ InteractionClass, callback, options }) => {
|
|
248
|
+
const myNvlRef = createRef();
|
|
249
|
+
render(_jsx(InteractiveNvlWrapper, { nodes: [], rels: [], ref: myNvlRef, mouseEventCallbacks: callback, interactionOptions: options }));
|
|
250
|
+
act(() => {
|
|
251
|
+
mockOnInitialization?.();
|
|
252
|
+
});
|
|
253
|
+
expect(InteractionClass).toHaveBeenCalledWith(myNvlRef.current, options);
|
|
254
|
+
expect(InteractionClass).toHaveBeenCalledTimes(1);
|
|
255
|
+
});
|
|
78
256
|
test('does not attempt to initialize interaction handlers if NVL container is not available', () => {
|
|
79
257
|
const myNvlRef = createRef();
|
|
80
258
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -45,4 +45,4 @@ export interface BasicReactWrapperProps {
|
|
|
45
45
|
*
|
|
46
46
|
* For examples, head to the {@link https://neo4j.com/docs/nvl/current/react-wrappers/#_basic_react_wrapper Basic React wrapper documentation page}.
|
|
47
47
|
*/
|
|
48
|
-
export declare const BasicNvlWrapper: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<BasicReactWrapperProps & HTMLProps<HTMLDivElement>, "ref"> & import("react").RefAttributes<Partial<Pick<NVL, "
|
|
48
|
+
export declare const BasicNvlWrapper: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<BasicReactWrapperProps & HTMLProps<HTMLDivElement>, "ref"> & import("react").RefAttributes<Partial<Pick<NVL, "restart" | "destroy" | "addAndUpdateElementsInGraph" | "getSelectedNodes" | "getSelectedRelationships" | "removeNodesWithIds" | "removeRelationshipsWithIds" | "getNodes" | "getRelationships" | "getNodeById" | "getRelationshipById" | "getPositionById" | "getCurrentOptions" | "deselectAll" | "fit" | "resetZoom" | "setRenderer" | "setDisableWebGL" | "pinNode" | "unPinNode" | "setLayout" | "setLayoutOptions" | "getNodesOnScreen" | "getNodePositions" | "setNodePositions" | "isLayoutMoving" | "saveToFile" | "saveToSvg" | "getImageDataUrl" | "saveFullGraphToLargeFile" | "setZoom" | "getScale" | "getPan" | "getHits" | "getContainer">>>>>;
|
|
@@ -18,6 +18,7 @@ export const InteractionHandlers = ({ nvlRef, mouseEventCallbacks, interactionOp
|
|
|
18
18
|
useInteraction(ClickInteraction, clickInteraction, mouseEventCallbacks.onRelationshipDoubleClick, 'onRelationshipDoubleClick', nvlRef, interactionOptions);
|
|
19
19
|
useInteraction(ClickInteraction, clickInteraction, mouseEventCallbacks.onRelationshipRightClick, 'onRelationshipRightClick', nvlRef, interactionOptions);
|
|
20
20
|
useInteraction(ClickInteraction, clickInteraction, mouseEventCallbacks.onCanvasClick, 'onCanvasClick', nvlRef, interactionOptions);
|
|
21
|
+
useInteraction(ClickInteraction, clickInteraction, mouseEventCallbacks.onCanvasDoubleClick, 'onCanvasDoubleClick', nvlRef, interactionOptions);
|
|
21
22
|
useInteraction(ClickInteraction, clickInteraction, mouseEventCallbacks.onCanvasRightClick, 'onCanvasRightClick', nvlRef, interactionOptions);
|
|
22
23
|
useInteraction(PanInteraction, panInteraction, mouseEventCallbacks.onPan, 'onPan', nvlRef, interactionOptions);
|
|
23
24
|
useInteraction(ZoomInteraction, zoomInteraction, mouseEventCallbacks.onZoom, 'onZoom', nvlRef, interactionOptions);
|
|
@@ -2,4 +2,4 @@ import type NVL from '@neo4j-nvl/base';
|
|
|
2
2
|
import type { MutableRefObject } from 'react';
|
|
3
3
|
import type { InteractionOptions, MouseEvent, MouseInteraction, MouseInteractionModule } from './types';
|
|
4
4
|
export declare const destroyInteraction: (interactionRef: MutableRefObject<MouseInteraction | null>) => void;
|
|
5
|
-
export declare const useInteraction: (Interaction: MouseInteractionModule, interactionRef: MutableRefObject<MouseInteraction | null>, callback:
|
|
5
|
+
export declare const useInteraction: (Interaction: MouseInteractionModule, interactionRef: MutableRefObject<MouseInteraction | null>, callback: ((...args: unknown[]) => void) | boolean | undefined, eventName: MouseEvent, nvlRef: MutableRefObject<NVL | null>, interactionOptions: InteractionOptions) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/react",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-d4b29aaa",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"homepage": "https://neo4j.com/docs/nvl/current/",
|
|
6
6
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
"lib"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@testing-library/dom": "
|
|
31
|
-
"@testing-library/jest-dom": "
|
|
32
|
-
"@testing-library/react": "
|
|
33
|
-
"@types/lodash": "4.
|
|
34
|
-
"@types/react": "
|
|
35
|
-
"react": "
|
|
36
|
-
"react-dom": "
|
|
30
|
+
"@testing-library/dom": "10.4.1",
|
|
31
|
+
"@testing-library/jest-dom": "5.17.0",
|
|
32
|
+
"@testing-library/react": "16.3.0",
|
|
33
|
+
"@types/lodash": "4.17.21",
|
|
34
|
+
"@types/react": "18.3.27",
|
|
35
|
+
"react": "19.2.1",
|
|
36
|
+
"react-dom": "19.2.1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@neo4j-nvl/base": "1.0.0-
|
|
40
|
-
"@neo4j-nvl/interaction-handlers": "1.0.0-
|
|
41
|
-
"lodash": "4.17.
|
|
39
|
+
"@neo4j-nvl/base": "1.0.0-d4b29aaa",
|
|
40
|
+
"@neo4j-nvl/interaction-handlers": "1.0.0-d4b29aaa",
|
|
41
|
+
"lodash": "4.17.23"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"react": "
|
|
45
|
-
"react-dom": "
|
|
44
|
+
"react": "18.0.0 || ^19.0.0",
|
|
45
|
+
"react-dom": "18.0.0 || ^19.0.0"
|
|
46
46
|
},
|
|
47
47
|
"stableVersion": "1.0.0"
|
|
48
48
|
}
|