@neo4j-ndl/react-graph 0.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/LICENSE +674 -0
- package/lib/LICENSES.txt +229 -0
- package/lib/NOTICE.txt +26 -0
- package/lib/cjs/graph-visualization-buttons.js +175 -0
- package/lib/cjs/graph-visualization-buttons.js.map +1 -0
- package/lib/cjs/graph-visualization-context.js +62 -0
- package/lib/cjs/graph-visualization-context.js.map +1 -0
- package/lib/cjs/graph-visualization-sidepanel.js +56 -0
- package/lib/cjs/graph-visualization-sidepanel.js.map +1 -0
- package/lib/cjs/graph-visualization.js +328 -0
- package/lib/cjs/graph-visualization.js.map +1 -0
- package/lib/cjs/index.js +28 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/map-to-nvl-graph.js +167 -0
- package/lib/cjs/map-to-nvl-graph.js.map +1 -0
- package/lib/cjs/sidepanel-components/button-group.js +96 -0
- package/lib/cjs/sidepanel-components/button-group.js.map +1 -0
- package/lib/cjs/sidepanel-components/clickable-urls.js +46 -0
- package/lib/cjs/sidepanel-components/clickable-urls.js.map +1 -0
- package/lib/cjs/sidepanel-components/details-panel.js +86 -0
- package/lib/cjs/sidepanel-components/details-panel.js.map +1 -0
- package/lib/cjs/sidepanel-components/overview-panel.js +45 -0
- package/lib/cjs/sidepanel-components/overview-panel.js.map +1 -0
- package/lib/cjs/sidepanel-components/properties-table.js +49 -0
- package/lib/cjs/sidepanel-components/properties-table.js.map +1 -0
- package/lib/cjs/sidepanel-components/show-all.js +44 -0
- package/lib/cjs/sidepanel-components/show-all.js.map +1 -0
- package/lib/cjs/sidepanel-components/single-selection-sidepanel-contents.js +35 -0
- package/lib/cjs/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-barebones.story.js +93 -0
- package/lib/cjs/stories/graph-visualization-barebones.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-custom.story.js +74 -0
- package/lib/cjs/stories/graph-visualization-custom.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-default.story.js +93 -0
- package/lib/cjs/stories/graph-visualization-default.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-highlighting.story.js +30 -0
- package/lib/cjs/stories/graph-visualization-highlighting.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-maximalist.story.js +105 -0
- package/lib/cjs/stories/graph-visualization-maximalist.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization-search.story.js +36 -0
- package/lib/cjs/stories/graph-visualization-search.story.js.map +1 -0
- package/lib/cjs/stories/graph-visualization.stories.js +112 -0
- package/lib/cjs/stories/graph-visualization.stories.js.map +1 -0
- package/lib/cjs/stories/index.js +51 -0
- package/lib/cjs/stories/index.js.map +1 -0
- package/lib/cjs/stories/story-data.js +89 -0
- package/lib/cjs/stories/story-data.js.map +1 -0
- package/lib/cjs/use-managed-node-state.js +262 -0
- package/lib/cjs/use-managed-node-state.js.map +1 -0
- package/lib/cjs/use-semi-controlled-state.js +43 -0
- package/lib/cjs/use-semi-controlled-state.js.map +1 -0
- package/lib/cjs/utils.js +68 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/esm/graph-visualization-buttons.js +159 -0
- package/lib/esm/graph-visualization-buttons.js.map +1 -0
- package/lib/esm/graph-visualization-context.js +58 -0
- package/lib/esm/graph-visualization-context.js.map +1 -0
- package/lib/esm/graph-visualization-sidepanel.js +52 -0
- package/lib/esm/graph-visualization-sidepanel.js.map +1 -0
- package/lib/esm/graph-visualization.js +298 -0
- package/lib/esm/graph-visualization.js.map +1 -0
- package/lib/esm/index.js +23 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/map-to-nvl-graph.js +162 -0
- package/lib/esm/map-to-nvl-graph.js.map +1 -0
- package/lib/esm/sidepanel-components/button-group.js +69 -0
- package/lib/esm/sidepanel-components/button-group.js.map +1 -0
- package/lib/esm/sidepanel-components/clickable-urls.js +40 -0
- package/lib/esm/sidepanel-components/clickable-urls.js.map +1 -0
- package/lib/esm/sidepanel-components/details-panel.js +82 -0
- package/lib/esm/sidepanel-components/details-panel.js.map +1 -0
- package/lib/esm/sidepanel-components/overview-panel.js +41 -0
- package/lib/esm/sidepanel-components/overview-panel.js.map +1 -0
- package/lib/esm/sidepanel-components/properties-table.js +45 -0
- package/lib/esm/sidepanel-components/properties-table.js.map +1 -0
- package/lib/esm/sidepanel-components/show-all.js +41 -0
- package/lib/esm/sidepanel-components/show-all.js.map +1 -0
- package/lib/esm/sidepanel-components/single-selection-sidepanel-contents.js +31 -0
- package/lib/esm/sidepanel-components/single-selection-sidepanel-contents.js.map +1 -0
- package/lib/esm/stories/graph-visualization-barebones.story.js +90 -0
- package/lib/esm/stories/graph-visualization-barebones.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization-custom.story.js +71 -0
- package/lib/esm/stories/graph-visualization-custom.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization-default.story.js +90 -0
- package/lib/esm/stories/graph-visualization-default.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization-highlighting.story.js +28 -0
- package/lib/esm/stories/graph-visualization-highlighting.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization-maximalist.story.js +102 -0
- package/lib/esm/stories/graph-visualization-maximalist.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization-search.story.js +34 -0
- package/lib/esm/stories/graph-visualization-search.story.js.map +1 -0
- package/lib/esm/stories/graph-visualization.stories.js +109 -0
- package/lib/esm/stories/graph-visualization.stories.js.map +1 -0
- package/lib/esm/stories/index.js +39 -0
- package/lib/esm/stories/index.js.map +1 -0
- package/lib/esm/stories/story-data.js +86 -0
- package/lib/esm/stories/story-data.js.map +1 -0
- package/lib/esm/use-managed-node-state.js +259 -0
- package/lib/esm/use-managed-node-state.js.map +1 -0
- package/lib/esm/use-semi-controlled-state.js +40 -0
- package/lib/esm/use-semi-controlled-state.js.map +1 -0
- package/lib/esm/utils.js +60 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/types/graph-visualization-buttons.d.ts +56 -0
- package/lib/types/graph-visualization-context.d.ts +122 -0
- package/lib/types/graph-visualization-sidepanel.d.ts +32 -0
- package/lib/types/graph-visualization.d.ts +178 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/map-to-nvl-graph.d.ts +37 -0
- package/lib/types/sidepanel-components/button-group.d.ts +24 -0
- package/lib/types/sidepanel-components/clickable-urls.d.ts +26 -0
- package/lib/types/sidepanel-components/details-panel.d.ts +25 -0
- package/lib/types/sidepanel-components/overview-panel.d.ts +21 -0
- package/lib/types/sidepanel-components/properties-table.d.ts +31 -0
- package/lib/types/sidepanel-components/show-all.d.ts +29 -0
- package/lib/types/sidepanel-components/single-selection-sidepanel-contents.d.ts +21 -0
- package/lib/types/stories/graph-visualization-barebones.story.d.ts +23 -0
- package/lib/types/stories/graph-visualization-custom.story.d.ts +23 -0
- package/lib/types/stories/graph-visualization-default.story.d.ts +23 -0
- package/lib/types/stories/graph-visualization-highlighting.story.d.ts +22 -0
- package/lib/types/stories/graph-visualization-maximalist.story.d.ts +23 -0
- package/lib/types/stories/graph-visualization-search.story.d.ts +22 -0
- package/lib/types/stories/graph-visualization.stories.d.ts +39 -0
- package/lib/types/stories/index.d.ts +32 -0
- package/lib/types/stories/story-data.d.ts +26 -0
- package/lib/types/use-managed-node-state.d.ts +116 -0
- package/lib/types/use-semi-controlled-state.d.ts +23 -0
- package/lib/types/utils.d.ts +29 -0
- package/package.json +79 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
22
|
+
import { isMac } from './utils';
|
|
23
|
+
const isMultiSelectKeyPressed = (evt) => (!isMac && evt.ctrlKey) || (isMac && evt.metaKey);
|
|
24
|
+
const isClickingOnTextInput = (e) => {
|
|
25
|
+
if (!(e.target instanceof HTMLElement)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return (e.target.isContentEditable ||
|
|
29
|
+
['INPUT', 'TEXTAREA'].includes(e.target.tagName));
|
|
30
|
+
};
|
|
31
|
+
export function useManagedNodeState({ selected, setSelected, gesture, interactionMode, setInteractionMode, mouseEventCallbacks, nvlGraph, highlightedNodeIds, highlightedRelationshipIds, }) {
|
|
32
|
+
const panOnSpace = useCallback((evt) => {
|
|
33
|
+
// We could check the gesture here
|
|
34
|
+
// but it doesn't really matter if we switch to panning mode even in single select
|
|
35
|
+
if (interactionMode === 'select' && evt.key === ' ') {
|
|
36
|
+
setInteractionMode('pan');
|
|
37
|
+
}
|
|
38
|
+
}, [interactionMode, setInteractionMode]);
|
|
39
|
+
const stopPanningReleaseSpace = useCallback((evt) => {
|
|
40
|
+
if (interactionMode === 'pan' && evt.key === ' ') {
|
|
41
|
+
setInteractionMode('select');
|
|
42
|
+
}
|
|
43
|
+
}, [interactionMode, setInteractionMode]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
document.addEventListener('keydown', panOnSpace);
|
|
46
|
+
document.addEventListener('keyup', stopPanningReleaseSpace);
|
|
47
|
+
return () => {
|
|
48
|
+
document.removeEventListener('keydown', panOnSpace);
|
|
49
|
+
document.removeEventListener('keyup', stopPanningReleaseSpace);
|
|
50
|
+
};
|
|
51
|
+
}, [panOnSpace, stopPanningReleaseSpace]);
|
|
52
|
+
const { onBoxSelect: originalBoxSelect, onLassoSelect: originalOnLassoSelect, onLassoStarted, onBoxStarted, onPan = true, onHover, onHoverNodeMargin, onNodeClick: originalOnNodeClick, onRelationshipClick: originalOnRelationshipClick, onDragStart: originalOnDragStart, onDragEnd: originalOnDragEnd, onDrawEnded: originalOnDrawEnded, onDrawStarted: originalOnDrawStarted, onCanvasClick: originalOnCanvasClick, onNodeDoubleClick: originalOnNodeDoubleClick, onRelationshipDoubleClick: originalOnRelationshipDoubleClick, } = mouseEventCallbacks;
|
|
53
|
+
const onCanvasClick = useCallback((evt) => {
|
|
54
|
+
if (isClickingOnTextInput(evt)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Clear selection
|
|
58
|
+
setSelected({ nodeIds: [], relationshipIds: [] });
|
|
59
|
+
if (typeof originalOnCanvasClick === 'function') {
|
|
60
|
+
originalOnCanvasClick(evt);
|
|
61
|
+
}
|
|
62
|
+
}, [originalOnCanvasClick, setSelected]);
|
|
63
|
+
const onDragStart = useCallback((draggedNodes, evt) => {
|
|
64
|
+
setInteractionMode('drag');
|
|
65
|
+
// Update Selection
|
|
66
|
+
const draggedNodeIds = draggedNodes.map((n) => n.id);
|
|
67
|
+
if (selected.nodeIds.length === 0 || isMultiSelectKeyPressed(evt)) {
|
|
68
|
+
setSelected({
|
|
69
|
+
nodeIds: draggedNodeIds,
|
|
70
|
+
relationshipIds: selected.relationshipIds,
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setSelected({
|
|
75
|
+
nodeIds: draggedNodeIds,
|
|
76
|
+
relationshipIds: selected.relationshipIds,
|
|
77
|
+
});
|
|
78
|
+
if (typeof originalOnDragStart === 'function') {
|
|
79
|
+
originalOnDragStart(draggedNodes, evt);
|
|
80
|
+
}
|
|
81
|
+
}, [setSelected, originalOnDragStart, selected, setInteractionMode]);
|
|
82
|
+
const onDragEnd = useCallback((draggedNodes, evt) => {
|
|
83
|
+
if (typeof originalOnDragEnd === 'function') {
|
|
84
|
+
originalOnDragEnd(draggedNodes, evt);
|
|
85
|
+
}
|
|
86
|
+
setInteractionMode('select');
|
|
87
|
+
}, [originalOnDragEnd, setInteractionMode]);
|
|
88
|
+
// wrapping so that there's a function passed, even if the original function is undefined
|
|
89
|
+
const onDrawStarted = useCallback((evt) => {
|
|
90
|
+
if (typeof originalOnDrawStarted === 'function') {
|
|
91
|
+
originalOnDrawStarted(evt);
|
|
92
|
+
}
|
|
93
|
+
}, [originalOnDrawStarted]);
|
|
94
|
+
const onDrawEnded = useCallback((newRelationshipToAdd, newTargetNodeToAdd, event) => {
|
|
95
|
+
if (typeof originalOnDrawEnded === 'function') {
|
|
96
|
+
originalOnDrawEnded(newRelationshipToAdd, newTargetNodeToAdd, event);
|
|
97
|
+
}
|
|
98
|
+
}, [originalOnDrawEnded]);
|
|
99
|
+
const onNodeClick = useCallback((node, hitElements, evt) => {
|
|
100
|
+
if (isClickingOnTextInput(evt)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (isMultiSelectKeyPressed(evt)) {
|
|
104
|
+
// if not selected, add to selection, otherwise deselect
|
|
105
|
+
const isNodeSelected = selected.nodeIds.includes(node.id);
|
|
106
|
+
if (isNodeSelected) {
|
|
107
|
+
const newSelectedNodeIds = selected.nodeIds.filter((id) => id !== node.id);
|
|
108
|
+
setSelected({
|
|
109
|
+
nodeIds: newSelectedNodeIds,
|
|
110
|
+
relationshipIds: selected.relationshipIds,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const newSelectedNodeIds = [...selected.nodeIds, node.id];
|
|
115
|
+
setSelected({
|
|
116
|
+
nodeIds: newSelectedNodeIds,
|
|
117
|
+
relationshipIds: selected.relationshipIds,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
setSelected({ nodeIds: [node.id], relationshipIds: [] });
|
|
123
|
+
}
|
|
124
|
+
if (typeof originalOnNodeClick === 'function') {
|
|
125
|
+
originalOnNodeClick(node, hitElements, evt);
|
|
126
|
+
}
|
|
127
|
+
}, [setSelected, selected, originalOnNodeClick]);
|
|
128
|
+
const onRelationshipClick = useCallback((relationship, hitElements, evt) => {
|
|
129
|
+
if (isClickingOnTextInput(evt)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (isMultiSelectKeyPressed(evt)) {
|
|
133
|
+
// if not selected, add to selection, otherwise deselect
|
|
134
|
+
const isRelationshipSelected = selected.relationshipIds.includes(relationship.id);
|
|
135
|
+
if (isRelationshipSelected) {
|
|
136
|
+
const newSelectedRelIds = selected.relationshipIds.filter((id) => id !== relationship.id);
|
|
137
|
+
setSelected({
|
|
138
|
+
nodeIds: selected.nodeIds,
|
|
139
|
+
relationshipIds: newSelectedRelIds,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const newSelectedRelIds = [
|
|
144
|
+
...selected.relationshipIds,
|
|
145
|
+
relationship.id,
|
|
146
|
+
];
|
|
147
|
+
setSelected({
|
|
148
|
+
nodeIds: selected.nodeIds,
|
|
149
|
+
relationshipIds: newSelectedRelIds,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
setSelected({ nodeIds: [], relationshipIds: [relationship.id] });
|
|
155
|
+
}
|
|
156
|
+
if (typeof originalOnRelationshipClick === 'function') {
|
|
157
|
+
originalOnRelationshipClick(relationship, hitElements, evt);
|
|
158
|
+
}
|
|
159
|
+
}, [setSelected, selected, originalOnRelationshipClick]);
|
|
160
|
+
const onNodeDoubleClick = useCallback((node, hitElements, evt) => {
|
|
161
|
+
if (isClickingOnTextInput(evt)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (typeof originalOnNodeDoubleClick === 'function') {
|
|
165
|
+
originalOnNodeDoubleClick(node, hitElements, evt);
|
|
166
|
+
}
|
|
167
|
+
}, [originalOnNodeDoubleClick]);
|
|
168
|
+
const onRelationshipDoubleClick = useCallback((relationship, hitElements, evt) => {
|
|
169
|
+
if (isClickingOnTextInput(evt)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (typeof originalOnRelationshipDoubleClick === 'function') {
|
|
173
|
+
originalOnRelationshipDoubleClick(relationship, hitElements, evt);
|
|
174
|
+
}
|
|
175
|
+
}, [originalOnRelationshipDoubleClick]);
|
|
176
|
+
const onMultiSelect = useCallback((nodes, rels, evt) => {
|
|
177
|
+
const nodeIds = nodes.map((n) => n.id);
|
|
178
|
+
const relationshipIds = rels.map((r) => r.id);
|
|
179
|
+
if (isMultiSelectKeyPressed(evt)) {
|
|
180
|
+
const currentlySelectedNodeIds = selected.nodeIds;
|
|
181
|
+
const currentlySelectedRelIds = selected.relationshipIds;
|
|
182
|
+
// Toggle selection: items that are already selected should be removed from selection,
|
|
183
|
+
// those that are not should be added
|
|
184
|
+
const xor = (a, b) => [
|
|
185
|
+
...new Set([...a, ...b].filter((id) => !a.includes(id) || !b.includes(id))),
|
|
186
|
+
];
|
|
187
|
+
const newSelectedNodeIds = xor(currentlySelectedNodeIds, nodeIds);
|
|
188
|
+
const newSelectedRelIds = xor(currentlySelectedRelIds, relationshipIds);
|
|
189
|
+
setSelected({
|
|
190
|
+
nodeIds: newSelectedNodeIds,
|
|
191
|
+
relationshipIds: newSelectedRelIds,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
// REPLACE selection
|
|
196
|
+
setSelected({ nodeIds: nodeIds, relationshipIds: relationshipIds });
|
|
197
|
+
}
|
|
198
|
+
}, [setSelected, selected]);
|
|
199
|
+
const onLassoSelect = useCallback(({ nodes, rels }, evt) => {
|
|
200
|
+
onMultiSelect(nodes, rels, evt);
|
|
201
|
+
if (typeof originalOnLassoSelect === 'function') {
|
|
202
|
+
originalOnLassoSelect({ nodes, rels }, evt);
|
|
203
|
+
}
|
|
204
|
+
}, [onMultiSelect, originalOnLassoSelect]);
|
|
205
|
+
const onBoxSelect = useCallback(({ nodes, rels }, evt) => {
|
|
206
|
+
onMultiSelect(nodes, rels, evt);
|
|
207
|
+
if (typeof originalBoxSelect === 'function') {
|
|
208
|
+
originalBoxSelect({ nodes, rels }, evt);
|
|
209
|
+
}
|
|
210
|
+
}, [onMultiSelect, originalBoxSelect]);
|
|
211
|
+
const isDrawMode = interactionMode === 'draw';
|
|
212
|
+
const isSelectMode = interactionMode === 'select';
|
|
213
|
+
const shouldEnableBox = isSelectMode && gesture === 'box';
|
|
214
|
+
const shouldEnableLasso = isSelectMode && gesture === 'lasso';
|
|
215
|
+
const shouldEnablePan = interactionMode === 'pan' || (isSelectMode && gesture === 'single');
|
|
216
|
+
const canDrag = interactionMode === 'drag' || interactionMode === 'select';
|
|
217
|
+
const wrappedMouseEventCallbacks = useMemo(() => {
|
|
218
|
+
var _a;
|
|
219
|
+
return (Object.assign(Object.assign({}, mouseEventCallbacks), { onBoxSelect: shouldEnableBox ? onBoxSelect : false, onBoxStarted: shouldEnableBox ? onBoxStarted : false, onCanvasClick: isSelectMode ? onCanvasClick : false, onDragEnd: canDrag ? onDragEnd : false, onDragStart: canDrag ? onDragStart : false, onDrawEnded: isDrawMode ? onDrawEnded : false, onDrawStarted: isDrawMode ? onDrawStarted : false, onHover: isSelectMode ? onHover : false, onHoverNodeMargin: isDrawMode ? onHoverNodeMargin : false, onLassoSelect: shouldEnableLasso ? onLassoSelect : false, onLassoStarted: shouldEnableLasso ? onLassoStarted : false, onNodeClick: isSelectMode ? onNodeClick : false, onNodeDoubleClick: isSelectMode ? onNodeDoubleClick : false, onPan: shouldEnablePan ? onPan : false, onRelationshipClick: isSelectMode ? onRelationshipClick : false, onRelationshipDoubleClick: isSelectMode
|
|
220
|
+
? onRelationshipDoubleClick
|
|
221
|
+
: false, onZoom: (_a = mouseEventCallbacks.onZoom) !== null && _a !== void 0 ? _a : true }));
|
|
222
|
+
}, [
|
|
223
|
+
canDrag,
|
|
224
|
+
shouldEnableBox,
|
|
225
|
+
shouldEnableLasso,
|
|
226
|
+
shouldEnablePan,
|
|
227
|
+
isDrawMode,
|
|
228
|
+
isSelectMode,
|
|
229
|
+
mouseEventCallbacks,
|
|
230
|
+
onBoxSelect,
|
|
231
|
+
onBoxStarted,
|
|
232
|
+
onCanvasClick,
|
|
233
|
+
onDragEnd,
|
|
234
|
+
onDragStart,
|
|
235
|
+
onDrawEnded,
|
|
236
|
+
onDrawStarted,
|
|
237
|
+
onHover,
|
|
238
|
+
onHoverNodeMargin,
|
|
239
|
+
onLassoSelect,
|
|
240
|
+
onLassoStarted,
|
|
241
|
+
onNodeClick,
|
|
242
|
+
onNodeDoubleClick,
|
|
243
|
+
onPan,
|
|
244
|
+
onRelationshipClick,
|
|
245
|
+
onRelationshipDoubleClick,
|
|
246
|
+
]);
|
|
247
|
+
const selectionSet = useMemo(() => ({
|
|
248
|
+
nodeIds: new Set(selected.nodeIds),
|
|
249
|
+
relIds: new Set(selected.relationshipIds),
|
|
250
|
+
}), [selected]);
|
|
251
|
+
const highlightedNodeSet = useMemo(() => highlightedNodeIds !== undefined ? new Set(highlightedNodeIds) : null, [highlightedNodeIds]);
|
|
252
|
+
const highlightedRelSet = useMemo(() => highlightedRelationshipIds !== undefined
|
|
253
|
+
? new Set(highlightedRelationshipIds)
|
|
254
|
+
: null, [highlightedRelationshipIds]);
|
|
255
|
+
const nodesWithState = useMemo(() => nvlGraph.nodes.map((n) => (Object.assign(Object.assign({}, n), { disabled: highlightedNodeSet ? !highlightedNodeSet.has(n.id) : false, selected: selectionSet.nodeIds.has(n.id) }))), [nvlGraph.nodes, selectionSet, highlightedNodeSet]);
|
|
256
|
+
const relsWithState = useMemo(() => nvlGraph.rels.map((r) => (Object.assign(Object.assign({}, r), { disabled: highlightedRelSet ? !highlightedRelSet.has(r.id) : false, selected: selectionSet.relIds.has(r.id) }))), [nvlGraph.rels, selectionSet, highlightedRelSet]);
|
|
257
|
+
return { nodesWithState, relsWithState, wrappedMouseEventCallbacks };
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=use-managed-node-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-managed-node-state.js","sourceRoot":"","sources":["../../src/use-managed-node-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAOxD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,uBAAuB,GAAG,CAAC,GAAe,EAAW,EAAE,CAC3D,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAEpD,MAAM,qBAAqB,GAAG,CAAC,CAAa,EAAW,EAAE;IACvD,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,CAAC,CAAC,MAAM,CAAC,iBAAiB;QAC1B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACjD,CAAC;AACJ,CAAC,CAAC;AAiBF,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,EACX,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,0BAA0B,GACL;IACrB,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,GAAkB,EAAE,EAAE;QACrB,kCAAkC;QAClC,kFAAkF;QAClF,IAAI,eAAe,K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C,EAAE,CAAC,IACxC,CAAC,EACL,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,kBAAkB,CAAC,CACnD,CAAC;IAEF,MAAM,aAAa,GAAG,OAAO,CAC3B,GAAG,EAAE,CACH,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACpB,CAAC,KACJ,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAClE,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IACvC,CAAC,EACL,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,iBAAiB,CAAC,CACjD,CAAC;IAEF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,0BAA0B,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
22
|
+
export function useSemicontrolledState(externalState, externalSetState) {
|
|
23
|
+
const [backupState, setBackupState] = useState(externalState);
|
|
24
|
+
const state = useMemo(() => (externalSetState ? externalState : backupState), [externalState, backupState, externalSetState]);
|
|
25
|
+
const setState = useCallback((newState) => {
|
|
26
|
+
if (externalSetState !== undefined) {
|
|
27
|
+
if (typeof newState === 'function') {
|
|
28
|
+
externalSetState(newState(externalState));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
externalSetState(newState);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
setBackupState(newState);
|
|
36
|
+
}
|
|
37
|
+
}, [externalSetState, setBackupState, externalState]);
|
|
38
|
+
return [state, setState];
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=use-semi-controlled-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-semi-controlled-state.js","sourceRoot":"","sources":["../../src/use-semi-controlled-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIvD,MAAM,UAAU,sBAAsB,CACpC,aAAgB,EAChB,gBAAwC;IAExC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAI,aAAa,CAAC,CAAC;IAEjE,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,EACtD,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAC/C,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,QAA2B,EAAE,EAAE;QAC9B,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;gBACnC,gBAAgB,CAAE,QAA2B,CAAC,aAAa,CAAC,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACN,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,EACD,CAAC,gBAAgB,EAAE,cAAc,EAAE,aAAa,CAAC,CAClD,CAAC;IAEF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|
package/lib/esm/utils.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
export const isMac = navigator.userAgent.includes('Mac');
|
|
22
|
+
const uniq = (arr) => [...new Set(arr)];
|
|
23
|
+
export const xor = (a, b) => uniq([...a, ...b].filter((id) => !a.includes(id) || !b.includes(id)));
|
|
24
|
+
export const mapValues = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, fn(value)]));
|
|
25
|
+
export const searchProperties = (properties, text) => {
|
|
26
|
+
var _a;
|
|
27
|
+
for (const [propName, propValue] of Object.entries(properties)) {
|
|
28
|
+
const isNameMatch = propName.toLowerCase().includes(text);
|
|
29
|
+
const raw = (_a = propValue === null || propValue === void 0 ? void 0 : propValue.stringified) !== null && _a !== void 0 ? _a : '';
|
|
30
|
+
const isValueMatch = raw.toLowerCase().includes(text);
|
|
31
|
+
if (isNameMatch || isValueMatch) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
37
|
+
export const searchNodes = (nodes, text) => {
|
|
38
|
+
const q = text.toLowerCase();
|
|
39
|
+
return nodes
|
|
40
|
+
.filter((node) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if ((_a = node.labelsSorted) === null || _a === void 0 ? void 0 : _a.some((l) => l.toLowerCase().includes(q))) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return searchProperties(node.properties, q);
|
|
46
|
+
})
|
|
47
|
+
.map((node) => node.id);
|
|
48
|
+
};
|
|
49
|
+
export const searchRels = (rels, text) => {
|
|
50
|
+
const q = text.toLowerCase();
|
|
51
|
+
return rels
|
|
52
|
+
.filter((rel) => {
|
|
53
|
+
if (rel.type.toLowerCase().includes(q)) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return searchProperties(rel.properties, q);
|
|
57
|
+
})
|
|
58
|
+
.map((rel) => rel.id);
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAEzD,MAAM,IAAI,GAAG,CAAC,GAAa,EAAE,EAAE,CAAC,CA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is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { type HtmlAttributes, type TooltipProps } from '@neo4j-ndl/react';
|
|
22
|
+
import { type CSSProperties, type PropsWithChildren } from 'react';
|
|
23
|
+
type GraphVisualizationButtonProps = {
|
|
24
|
+
className?: string;
|
|
25
|
+
style?: CSSProperties;
|
|
26
|
+
htmlAttributes?: HtmlAttributes<'button'>;
|
|
27
|
+
tooltipPlacement?: TooltipProps['placement'];
|
|
28
|
+
};
|
|
29
|
+
type BaseProperties = GraphVisualizationButtonProps & {
|
|
30
|
+
tipContent: string;
|
|
31
|
+
testid?: string;
|
|
32
|
+
ariaLabel?: string;
|
|
33
|
+
isActive?: boolean;
|
|
34
|
+
isDisabled?: boolean;
|
|
35
|
+
onClick?: () => void;
|
|
36
|
+
onMouseDown?: () => void;
|
|
37
|
+
};
|
|
38
|
+
export type GraphVisualizationGroupButton = PropsWithChildren<BaseProperties>;
|
|
39
|
+
export declare const GroupButton: (props: GraphVisualizationGroupButton) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare const SingleSelectButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export declare const BoxSelectButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const LassoSelectButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare const ZoomInButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export declare const ZoomOutButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
export declare const ZoomToFitButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
export declare const ToggleSidePanelButton: ({ className, htmlAttributes, style, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
type SearchButtonProps = GraphVisualizationButtonProps & {
|
|
48
|
+
open?: boolean;
|
|
49
|
+
setOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
50
|
+
searchTerm?: string;
|
|
51
|
+
setSearchTerm?: React.Dispatch<React.SetStateAction<string>>;
|
|
52
|
+
onSearch?: (nodeIds: string[] | undefined, relationshipIds: string[] | undefined) => void;
|
|
53
|
+
};
|
|
54
|
+
export declare const SearchButton: ({ className, style, htmlAttributes, tooltipPlacement, open: rawOpen, setOpen: rawSetOpen, searchTerm: rawSearchTerm, setSearchTerm: rawSetSearchTerm, onSearch, }: SearchButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export declare const DownloadButton: ({ className, style, htmlAttributes, tooltipPlacement, }: GraphVisualizationButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import type NVL from '@neo4j-nvl/base';
|
|
22
|
+
import { type Node, type Relationship } from '@neo4j-nvl/base';
|
|
23
|
+
export type GraphSelection = {
|
|
24
|
+
nodeIds: string[];
|
|
25
|
+
relationshipIds: string[];
|
|
26
|
+
};
|
|
27
|
+
export type Sidepanel = {
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
isSidePanelOpen: boolean;
|
|
30
|
+
setIsSidePanelOpen?: (isSidePanelOpen: boolean) => void;
|
|
31
|
+
sidePanelWidth?: number;
|
|
32
|
+
onSidePanelResize: (width: number) => void;
|
|
33
|
+
minWidth?: number;
|
|
34
|
+
};
|
|
35
|
+
export type NvlGraph = {
|
|
36
|
+
nodes: Node[];
|
|
37
|
+
rels: Relationship[];
|
|
38
|
+
dataLookupTable: DataLookupTable;
|
|
39
|
+
};
|
|
40
|
+
export type GraphItemMetaData = {
|
|
41
|
+
totalCount: number;
|
|
42
|
+
mostCommonColor: string;
|
|
43
|
+
};
|
|
44
|
+
export type DataLookupTable = {
|
|
45
|
+
nodes: Record<string, NodeData>;
|
|
46
|
+
relationships: Record<string, RelData>;
|
|
47
|
+
labels: string[];
|
|
48
|
+
types: string[];
|
|
49
|
+
labelMetaData: Record<string, GraphItemMetaData>;
|
|
50
|
+
typeMetaData: Record<string, GraphItemMetaData>;
|
|
51
|
+
};
|
|
52
|
+
export type PortableProperty = {
|
|
53
|
+
stringified: string;
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
export type NodeData = {
|
|
57
|
+
labelsSorted: string[];
|
|
58
|
+
properties: Record<string, PortableProperty>;
|
|
59
|
+
color: string;
|
|
60
|
+
id: string;
|
|
61
|
+
};
|
|
62
|
+
export type RelData = {
|
|
63
|
+
type: string;
|
|
64
|
+
properties: Record<string, PortableProperty>;
|
|
65
|
+
color: string;
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
export type NeoNode = Node & {
|
|
69
|
+
properties: Record<string, PortableProperty>;
|
|
70
|
+
labels: string[];
|
|
71
|
+
};
|
|
72
|
+
export type NeoRel = Relationship & {
|
|
73
|
+
properties: Record<string, PortableProperty>;
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Data that is shared across the graph visualization component.
|
|
78
|
+
*
|
|
79
|
+
* @see {@link useGraphVisualizationContext}
|
|
80
|
+
* @alpha
|
|
81
|
+
*/
|
|
82
|
+
export type GraphVisualizationContextData = {
|
|
83
|
+
nvlInstance: React.MutableRefObject<NVL | null>;
|
|
84
|
+
sidepanel: Sidepanel | null;
|
|
85
|
+
gesture: Gesture;
|
|
86
|
+
setGesture?: (gesture: Gesture) => void;
|
|
87
|
+
interactionMode: InteractionMode;
|
|
88
|
+
nvlGraph: NvlGraph;
|
|
89
|
+
selected: GraphSelection;
|
|
90
|
+
};
|
|
91
|
+
export declare const GraphVisualizationContext: import("react").Context<GraphVisualizationContextData | undefined>;
|
|
92
|
+
/**
|
|
93
|
+
* Hook to access the graph visualization context.
|
|
94
|
+
*
|
|
95
|
+
* This hook is used to implement custom UI components like buttons, panels, and controls
|
|
96
|
+
* that need access to data and functionality from the graph visualization component.
|
|
97
|
+
* @see {@link GraphVisualizationContextData}
|
|
98
|
+
*
|
|
99
|
+
* @returns The graph visualization context containing NVL instance, sidepanel, gestures, and graph data
|
|
100
|
+
* @throws Error if used outside of a GraphVisualizationContext provider
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* const NodeLoggerButton = () => {
|
|
105
|
+
* const { selected } = useGraphVisualizationContext();
|
|
106
|
+
*
|
|
107
|
+
* const handleClick = () => {
|
|
108
|
+
* console.log('Selected nodes:', selected.nodeIds);
|
|
109
|
+
* };
|
|
110
|
+
*
|
|
111
|
+
* return (
|
|
112
|
+
* <button onClick={handleClick}>
|
|
113
|
+
* Log Selected Nodes ({selected.nodeIds.length})
|
|
114
|
+
* </button>
|
|
115
|
+
* );
|
|
116
|
+
* };
|
|
117
|
+
* ```
|
|
118
|
+
* @alpha
|
|
119
|
+
*/
|
|
120
|
+
export declare const useGraphVisualizationContext: () => GraphVisualizationContextData;
|
|
121
|
+
export type Gesture = 'single' | 'box' | 'lasso';
|
|
122
|
+
export type InteractionMode = 'select' | 'draw' | 'edit-text' | 'pan' | 'drag' | 'none';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { type Sidepanel } from './graph-visualization-context';
|
|
22
|
+
export declare const GraphVisualizationSidepanel: {
|
|
23
|
+
({ sidepanel, }: {
|
|
24
|
+
sidepanel: Sidepanel;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
26
|
+
Title: ({ children }: {
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
Content: ({ children }: {
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
};
|