@html-graph/html-graph 0.0.48 → 0.0.50
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/README.md +8 -8
- package/dist/main.d.ts +185 -193
- package/dist/main.js +693 -606
- package/dist/main.umd.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="/media/favicon.png" alt="HTMLGraph" width="25" height="25"/> HTMLGraph
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Graph visualization library that enables nodes customization using HTML
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
<img width="100%" src="https://raw.githubusercontent.com/html-graph/html-graph/master/media/full-demo.gif"/>
|
|
11
11
|
</a>
|
|
12
12
|
|
|
13
|
-
Instead of connecting nodes dirrectly this library uses concept of ports, which provide greater fexibility at managing
|
|
14
|
-
Port is an entity of the node to which
|
|
13
|
+
Instead of connecting nodes dirrectly this library uses concept of ports, which provide greater fexibility at managing edges.
|
|
14
|
+
Port is an entity of the node to which edge can be attached to.
|
|
15
15
|
|
|
16
16
|
This library fits for tasks where easy nodes customization and interactiveness are required.
|
|
17
17
|
|
|
@@ -38,17 +38,17 @@ import { MarkNodePortRequest, HtmlGraphBuilder } from "@html-graph/html-graph";
|
|
|
38
38
|
const canvas = new HtmlGraphBuilder()
|
|
39
39
|
.setOptions({
|
|
40
40
|
background: { type: "dots" },
|
|
41
|
-
|
|
41
|
+
edges: { hasTargetArrow: true },
|
|
42
42
|
})
|
|
43
|
-
.
|
|
44
|
-
.
|
|
43
|
+
.setUserDraggableNodes()
|
|
44
|
+
.setUserTransformableCanvas()
|
|
45
45
|
.build();
|
|
46
46
|
|
|
47
47
|
function createNode(
|
|
48
48
|
name: string,
|
|
49
49
|
frontPortId: string,
|
|
50
50
|
backPortId: string,
|
|
51
|
-
): [HTMLElement, Record<string,
|
|
51
|
+
): [HTMLElement, Record<string, MarkNodePortRequest>] {
|
|
52
52
|
const node = document.createElement("div");
|
|
53
53
|
node.classList.add("node");
|
|
54
54
|
|
|
@@ -76,7 +76,7 @@ canvas
|
|
|
76
76
|
.attach(canvasElement)
|
|
77
77
|
.addNode({ element: node1, x: 200, y: 400, ports: ports1 })
|
|
78
78
|
.addNode({ element: node2, x: 600, y: 500, ports: ports2 })
|
|
79
|
-
.
|
|
79
|
+
.addEdge({ from: "port-1-2", to: "port-2-1" });
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
Refer to [Examples](examples) for more.
|
package/dist/main.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare interface
|
|
1
|
+
export declare interface AddEdgeRequest {
|
|
2
2
|
id?: string;
|
|
3
3
|
from: string;
|
|
4
4
|
to: string;
|
|
5
|
-
options?:
|
|
5
|
+
options?: EdgeOptions;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export declare interface AddNodeRequest {
|
|
@@ -32,14 +32,12 @@ declare type BackgroundOptions = {
|
|
|
32
32
|
readonly drawingFn: BackgroundDrawingFn;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export declare class
|
|
35
|
+
export declare class BezierEdgeController implements EdgeController {
|
|
36
36
|
private readonly color;
|
|
37
37
|
private readonly width;
|
|
38
38
|
private readonly curvature;
|
|
39
39
|
private readonly arrowLength;
|
|
40
40
|
private readonly arrowWidth;
|
|
41
|
-
private readonly hasSourceArrow;
|
|
42
|
-
private readonly hasTargetArrow;
|
|
43
41
|
readonly svg: SVGSVGElement;
|
|
44
42
|
private readonly group;
|
|
45
43
|
private readonly line;
|
|
@@ -49,7 +47,7 @@ export declare class BezierConnectionController implements ConnectionController
|
|
|
49
47
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
declare interface
|
|
50
|
+
declare interface BezierEdgeOptions {
|
|
53
51
|
readonly type?: "bezier";
|
|
54
52
|
readonly color?: string;
|
|
55
53
|
readonly width?: number;
|
|
@@ -58,6 +56,8 @@ declare interface BezierConnectionOptions {
|
|
|
58
56
|
readonly arrowWidth?: number;
|
|
59
57
|
readonly hasSourceArrow?: boolean;
|
|
60
58
|
readonly hasTargetArrow?: boolean;
|
|
59
|
+
readonly cycleRadius?: number;
|
|
60
|
+
readonly smallCycleRadius?: number;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export declare interface Canvas {
|
|
@@ -65,10 +65,6 @@ export declare interface Canvas {
|
|
|
65
65
|
* provides api for canvas transformation
|
|
66
66
|
*/
|
|
67
67
|
readonly transformation: PublicViewportTransformer;
|
|
68
|
-
/**
|
|
69
|
-
* provides api for graph structure access
|
|
70
|
-
*/
|
|
71
|
-
readonly model: PublicGraphStore;
|
|
72
68
|
/**
|
|
73
69
|
* adds node to graph
|
|
74
70
|
*/
|
|
@@ -76,7 +72,7 @@ export declare interface Canvas {
|
|
|
76
72
|
/**
|
|
77
73
|
* removes node from graph
|
|
78
74
|
* all the ports of node get unmarked
|
|
79
|
-
* all the
|
|
75
|
+
* all the edges adjacent to node get removed
|
|
80
76
|
*/
|
|
81
77
|
removeNode(nodeId: string): Canvas;
|
|
82
78
|
/**
|
|
@@ -84,22 +80,22 @@ export declare interface Canvas {
|
|
|
84
80
|
*/
|
|
85
81
|
markPort(port: MarkPortRequest): Canvas;
|
|
86
82
|
/**
|
|
87
|
-
* updates
|
|
83
|
+
* updates edge attached to port
|
|
88
84
|
*/
|
|
89
|
-
|
|
85
|
+
updatePortEdges(portId: string): Canvas;
|
|
90
86
|
/**
|
|
91
87
|
* ummarks element as port of node
|
|
92
|
-
* all the
|
|
88
|
+
* all the edges adjacent to port get removed
|
|
93
89
|
*/
|
|
94
90
|
unmarkPort(portId: string): Canvas;
|
|
95
91
|
/**
|
|
96
|
-
* adds
|
|
92
|
+
* adds edge to graph
|
|
97
93
|
*/
|
|
98
|
-
|
|
94
|
+
addEdge(edge: AddEdgeRequest): Canvas;
|
|
99
95
|
/**
|
|
100
|
-
* removes
|
|
96
|
+
* removes edge from graph
|
|
101
97
|
*/
|
|
102
|
-
|
|
98
|
+
removeEdge(edgeId: string): Canvas;
|
|
103
99
|
/**
|
|
104
100
|
* applies transformation for viewport
|
|
105
101
|
*/
|
|
@@ -113,9 +109,9 @@ export declare interface Canvas {
|
|
|
113
109
|
*/
|
|
114
110
|
updateNodeCoordinates(nodeId: string, x: number, y: number): Canvas;
|
|
115
111
|
/**
|
|
116
|
-
* updates
|
|
112
|
+
* updates edge
|
|
117
113
|
*/
|
|
118
|
-
|
|
114
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): Canvas;
|
|
119
115
|
/**
|
|
120
116
|
* moves specified node on top
|
|
121
117
|
*/
|
|
@@ -148,22 +144,21 @@ export declare interface Canvas {
|
|
|
148
144
|
export declare class CanvasCore implements Canvas {
|
|
149
145
|
private readonly apiOptions?;
|
|
150
146
|
readonly transformation: PublicViewportTransformer;
|
|
151
|
-
readonly model: PublicGraphStore;
|
|
152
147
|
private readonly di;
|
|
153
|
-
private readonly
|
|
148
|
+
private readonly edgeControllerFactory;
|
|
154
149
|
constructor(apiOptions?: CoreOptions | undefined);
|
|
155
150
|
addNode(node: AddNodeRequest): CanvasCore;
|
|
156
151
|
moveNodeOnTop(nodeId: string): CanvasCore;
|
|
157
152
|
removeNode(nodeId: string): CanvasCore;
|
|
158
153
|
markPort(port: MarkPortRequest): CanvasCore;
|
|
159
|
-
|
|
154
|
+
updatePortEdges(portId: string): CanvasCore;
|
|
160
155
|
unmarkPort(portId: string): CanvasCore;
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
addEdge(edge: AddEdgeRequest): CanvasCore;
|
|
157
|
+
removeEdge(edgeId: string): CanvasCore;
|
|
163
158
|
patchViewportState(request: PatchViewportRequest): CanvasCore;
|
|
164
159
|
moveToNodes(nodeIds: readonly string[]): CanvasCore;
|
|
165
160
|
updateNodeCoordinates(nodeId: string, x: number, y: number): CanvasCore;
|
|
166
|
-
|
|
161
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): CanvasCore;
|
|
167
162
|
clear(): CanvasCore;
|
|
168
163
|
attach(element: HTMLElement): CanvasCore;
|
|
169
164
|
detach(): CanvasCore;
|
|
@@ -172,34 +167,6 @@ export declare class CanvasCore implements Canvas {
|
|
|
172
167
|
|
|
173
168
|
declare type CenterFn = (width: number, height: number) => [number, number];
|
|
174
169
|
|
|
175
|
-
export declare interface ConnectionController {
|
|
176
|
-
readonly svg: SVGSVGElement;
|
|
177
|
-
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
declare type ConnectionControllerFactory = (type: ConnectionType) => ConnectionController;
|
|
181
|
-
|
|
182
|
-
declare type ConnectionOptions = BezierConnectionOptions | StraightConnectionOptions | CustomConnectionOptions;
|
|
183
|
-
|
|
184
|
-
declare interface ConnectionPayload {
|
|
185
|
-
from: string;
|
|
186
|
-
to: string;
|
|
187
|
-
controller: ConnectionController;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export declare enum ConnectionType {
|
|
191
|
-
Regular = "regular",
|
|
192
|
-
Cycle = "cycle"
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export declare class ConnectionUtils {
|
|
196
|
-
static getPortCenter(port: PortPayload): Point;
|
|
197
|
-
static rotate(point: Point, vector: Point, center: Point): Point;
|
|
198
|
-
static getDirectionVector(direction: number | null, flipX: number, flipY: number): Point;
|
|
199
|
-
static getArrowPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowWidth: number): string;
|
|
200
|
-
static getArrowOffsetPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowOffset: number): string;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
170
|
export declare interface CoreOptions {
|
|
204
171
|
/**
|
|
205
172
|
* canvas background settings
|
|
@@ -221,14 +188,14 @@ export declare interface CoreOptions {
|
|
|
221
188
|
readonly ports?: {
|
|
222
189
|
/**
|
|
223
190
|
* specifies how to determine center of port
|
|
224
|
-
* center of port determines point to which
|
|
191
|
+
* center of port determines point to which edge attaches
|
|
225
192
|
*/
|
|
226
193
|
readonly centerFn?: CenterFn;
|
|
227
194
|
};
|
|
228
195
|
/**
|
|
229
|
-
*
|
|
196
|
+
*edges related behavior
|
|
230
197
|
*/
|
|
231
|
-
readonly
|
|
198
|
+
readonly edges?: EdgeOptions;
|
|
232
199
|
/**
|
|
233
200
|
* layers related behavior
|
|
234
201
|
*/
|
|
@@ -240,7 +207,7 @@ export declare interface CoreOptions {
|
|
|
240
207
|
};
|
|
241
208
|
}
|
|
242
209
|
|
|
243
|
-
export declare const
|
|
210
|
+
export declare const createBezierEdgeControllerFactory: (options: {
|
|
244
211
|
color: string;
|
|
245
212
|
width: number;
|
|
246
213
|
arrowLength: number;
|
|
@@ -248,99 +215,87 @@ export declare const createBezierConnectionControllerFactory: (options: {
|
|
|
248
215
|
curvature: number;
|
|
249
216
|
hasSourceArrow: boolean;
|
|
250
217
|
hasTargetArrow: boolean;
|
|
251
|
-
|
|
218
|
+
cycleRadius: number;
|
|
219
|
+
smallCycleRadius: number;
|
|
220
|
+
}) => EdgeControllerFactory;
|
|
252
221
|
|
|
253
|
-
export declare const
|
|
222
|
+
export declare const createStraightEdgeControllerFactory: (options: {
|
|
254
223
|
color: string;
|
|
255
224
|
width: number;
|
|
256
225
|
arrowLength: number;
|
|
257
226
|
arrowWidth: number;
|
|
258
|
-
|
|
227
|
+
arrowOffset: number;
|
|
259
228
|
hasSourceArrow: boolean;
|
|
260
229
|
hasTargetArrow: boolean;
|
|
261
|
-
|
|
230
|
+
cycleSquareSide: number;
|
|
231
|
+
roundness: number;
|
|
232
|
+
}) => EdgeControllerFactory;
|
|
262
233
|
|
|
263
|
-
declare interface
|
|
234
|
+
declare interface CustomEdgeOptions {
|
|
264
235
|
readonly type: "custom";
|
|
265
|
-
readonly controllerFactory:
|
|
236
|
+
readonly controllerFactory: EdgeControllerFactory;
|
|
266
237
|
}
|
|
267
238
|
|
|
268
|
-
export declare class
|
|
269
|
-
private readonly
|
|
270
|
-
readonly
|
|
271
|
-
readonly
|
|
272
|
-
private readonly
|
|
273
|
-
private
|
|
274
|
-
private
|
|
275
|
-
|
|
276
|
-
private
|
|
277
|
-
private readonly
|
|
278
|
-
private readonly
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
detach(): DraggableNodesCanvas;
|
|
299
|
-
destroy(): void;
|
|
300
|
-
private setCursor;
|
|
301
|
-
private dragNode;
|
|
239
|
+
export declare class CycleCircleEdgeController implements EdgeController {
|
|
240
|
+
private readonly color;
|
|
241
|
+
private readonly width;
|
|
242
|
+
private readonly arrowLength;
|
|
243
|
+
private readonly arrowWidth;
|
|
244
|
+
private readonly radius;
|
|
245
|
+
private readonly smallRadius;
|
|
246
|
+
readonly svg: SVGSVGElement;
|
|
247
|
+
private readonly group;
|
|
248
|
+
private readonly line;
|
|
249
|
+
private readonly arrow;
|
|
250
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, hasArrow: boolean, radius: number, smallRadius: number);
|
|
251
|
+
update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export declare class CycleSquareEdgeController implements EdgeController {
|
|
255
|
+
private readonly color;
|
|
256
|
+
private readonly width;
|
|
257
|
+
private readonly arrowLength;
|
|
258
|
+
private readonly arrowWidth;
|
|
259
|
+
private readonly side;
|
|
260
|
+
private readonly minPortOffset;
|
|
261
|
+
readonly svg: SVGSVGElement;
|
|
262
|
+
private readonly group;
|
|
263
|
+
private readonly line;
|
|
264
|
+
private readonly arrow;
|
|
265
|
+
private readonly roundness;
|
|
266
|
+
private readonly points;
|
|
267
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, hasArrow: boolean, side: number, minPortOffset: number, roundness: number);
|
|
268
|
+
update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
|
|
302
269
|
}
|
|
303
270
|
|
|
304
271
|
export declare interface DragOptions {
|
|
305
272
|
events?: {
|
|
306
|
-
onNodeDrag?: (
|
|
273
|
+
onNodeDrag?: (payload: NodeDragPayload) => void;
|
|
274
|
+
onBeforeNodeDrag?: (payload: NodeDragPayload) => boolean;
|
|
307
275
|
};
|
|
308
276
|
}
|
|
309
277
|
|
|
310
|
-
declare
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
addConnection(connectionId: string, fromPortId: string, toPortId: string, svgController: ConnectionController): void;
|
|
332
|
-
getConnection(connectionId: string): ConnectionPayload;
|
|
333
|
-
hasConnection(connectionId: string): boolean;
|
|
334
|
-
removeConnection(connectionId: string): void;
|
|
335
|
-
getPortAdjacentConnections(portId: string): readonly string[];
|
|
336
|
-
getNodeAdjacentConnections(nodeId: string): readonly string[];
|
|
337
|
-
clear(): void;
|
|
338
|
-
private getPortIncomingConnections;
|
|
339
|
-
private getPortOutcomingConnections;
|
|
340
|
-
private getPortCycleConnections;
|
|
341
|
-
private getNodeIncomingConnections;
|
|
342
|
-
private getNodeOutcomingConnections;
|
|
343
|
-
private getNodeCycleConnections;
|
|
278
|
+
export declare interface EdgeController {
|
|
279
|
+
readonly svg: SVGSVGElement;
|
|
280
|
+
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
declare type EdgeControllerFactory = (type: EdgeType) => EdgeController;
|
|
284
|
+
|
|
285
|
+
declare type EdgeOptions = BezierEdgeOptions | StraightEdgeOptions | CustomEdgeOptions;
|
|
286
|
+
|
|
287
|
+
export declare enum EdgeType {
|
|
288
|
+
Regular = "regular",
|
|
289
|
+
Cycle = "cycle"
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export declare class EdgeUtils {
|
|
293
|
+
static getPortCenter(port: PortPayload): Point;
|
|
294
|
+
static rotate(point: Point, vector: Point, center: Point): Point;
|
|
295
|
+
static getDirectionVector(direction: number | null, flipX: number, flipY: number): Point;
|
|
296
|
+
static getArrowPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowWidth: number): string;
|
|
297
|
+
static getArrowOffsetPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowOffset: number): string;
|
|
298
|
+
static createStraightPath(ps: Point[]): string;
|
|
344
299
|
}
|
|
345
300
|
|
|
346
301
|
export declare class HtmlGraphBuilder {
|
|
@@ -350,12 +305,12 @@ export declare class HtmlGraphBuilder {
|
|
|
350
305
|
private isDraggable;
|
|
351
306
|
private isTransformable;
|
|
352
307
|
setOptions(options: CoreOptions): HtmlGraphBuilder;
|
|
353
|
-
|
|
354
|
-
|
|
308
|
+
setUserDraggableNodes(options?: DragOptions): HtmlGraphBuilder;
|
|
309
|
+
setUserTransformableCanvas(options?: TransformOptions): HtmlGraphBuilder;
|
|
355
310
|
build(): Canvas;
|
|
356
311
|
}
|
|
357
312
|
|
|
358
|
-
declare type LayersMode = "
|
|
313
|
+
declare type LayersMode = "edges-on-top" | "nodes-on-top" | "edges-follow-node";
|
|
359
314
|
|
|
360
315
|
export declare type MarkNodePortRequest = HTMLElement | {
|
|
361
316
|
readonly element: HTMLElement;
|
|
@@ -371,6 +326,13 @@ export declare interface MarkPortRequest {
|
|
|
371
326
|
readonly direction?: number | null;
|
|
372
327
|
}
|
|
373
328
|
|
|
329
|
+
export declare interface NodeDragPayload {
|
|
330
|
+
readonly nodeId: string;
|
|
331
|
+
readonly element: HTMLElement;
|
|
332
|
+
readonly x: number;
|
|
333
|
+
readonly y: number;
|
|
334
|
+
}
|
|
335
|
+
|
|
374
336
|
export declare interface NodeItem {
|
|
375
337
|
readonly id: string;
|
|
376
338
|
readonly x: number;
|
|
@@ -378,13 +340,6 @@ export declare interface NodeItem {
|
|
|
378
340
|
readonly element: HTMLElement;
|
|
379
341
|
}
|
|
380
342
|
|
|
381
|
-
declare interface NodePayload {
|
|
382
|
-
element: HTMLElement;
|
|
383
|
-
x: number;
|
|
384
|
-
y: number;
|
|
385
|
-
centerFn: CenterFn;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
343
|
export declare interface NodeResponse {
|
|
389
344
|
readonly x: number;
|
|
390
345
|
readonly y: number;
|
|
@@ -405,13 +360,6 @@ export declare interface PortPayload {
|
|
|
405
360
|
readonly direction: number | null;
|
|
406
361
|
}
|
|
407
362
|
|
|
408
|
-
declare class PublicGraphStore {
|
|
409
|
-
private readonly graphStore;
|
|
410
|
-
constructor(graphStore: GraphStore);
|
|
411
|
-
getNode(nodeId: string): NodeResponse | null;
|
|
412
|
-
getNodes(ids?: readonly string[]): readonly NodeItem[];
|
|
413
|
-
}
|
|
414
|
-
|
|
415
363
|
export declare class PublicViewportTransformer {
|
|
416
364
|
private readonly transformer;
|
|
417
365
|
constructor(transformer: ViewportTransformer);
|
|
@@ -437,43 +385,106 @@ export declare class PublicViewportTransformer {
|
|
|
437
385
|
getAbsScale(): number;
|
|
438
386
|
}
|
|
439
387
|
|
|
440
|
-
export declare class
|
|
388
|
+
export declare class StraightEdgeController implements EdgeController {
|
|
441
389
|
private readonly color;
|
|
442
390
|
private readonly width;
|
|
443
391
|
private readonly arrowLength;
|
|
444
392
|
private readonly arrowWidth;
|
|
445
|
-
private readonly
|
|
446
|
-
private readonly hasSourceArrow;
|
|
447
|
-
private readonly hasTargetArrow;
|
|
393
|
+
private readonly arrowOffset;
|
|
448
394
|
readonly svg: SVGSVGElement;
|
|
449
395
|
private readonly group;
|
|
450
396
|
private readonly line;
|
|
451
397
|
private readonly sourceArrow;
|
|
452
398
|
private readonly targetArrow;
|
|
453
|
-
|
|
399
|
+
private readonly roundness;
|
|
400
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
454
401
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
455
402
|
}
|
|
456
403
|
|
|
457
|
-
declare interface
|
|
404
|
+
declare interface StraightEdgeOptions {
|
|
458
405
|
readonly type: "straight";
|
|
459
406
|
readonly color?: string;
|
|
460
407
|
readonly width?: number;
|
|
461
408
|
readonly arrowLength?: number;
|
|
462
409
|
readonly arrowWidth?: number;
|
|
463
|
-
readonly
|
|
410
|
+
readonly arrowOffset?: number;
|
|
464
411
|
readonly hasSourceArrow?: boolean;
|
|
465
412
|
readonly hasTargetArrow?: boolean;
|
|
413
|
+
readonly cycleSquareSide?: number;
|
|
414
|
+
readonly roundness?: number;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export declare interface TransformOptions {
|
|
418
|
+
scale?: {
|
|
419
|
+
enabled?: boolean;
|
|
420
|
+
min?: number;
|
|
421
|
+
max?: number;
|
|
422
|
+
wheelSensitivity?: number;
|
|
423
|
+
};
|
|
424
|
+
shift?: {
|
|
425
|
+
enabled?: boolean;
|
|
426
|
+
};
|
|
427
|
+
events?: {
|
|
428
|
+
onTransform?: (payload: TransformPayload) => void;
|
|
429
|
+
onBeforeTransform?: (payload: TransformPayload) => boolean;
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export declare interface TransformPayload {
|
|
434
|
+
readonly scale: number;
|
|
435
|
+
readonly x: number;
|
|
436
|
+
readonly y: number;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export declare interface UpdateEdgeRequest {
|
|
440
|
+
readonly controller?: EdgeController;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export declare class UserDraggableNodesCanvas implements Canvas {
|
|
444
|
+
private readonly canvas;
|
|
445
|
+
readonly transformation: PublicViewportTransformer;
|
|
446
|
+
private readonly nodes;
|
|
447
|
+
private grabbedNodeId;
|
|
448
|
+
private onNodeDrag;
|
|
449
|
+
private onBeforeNodeDrag;
|
|
450
|
+
private readonly nodeIdGenerator;
|
|
451
|
+
private element;
|
|
452
|
+
private readonly onCanvasMouseUp;
|
|
453
|
+
private readonly onCanvasMouseMove;
|
|
454
|
+
private readonly onCanvasTouchStart;
|
|
455
|
+
private readonly onCanvasTouchMove;
|
|
456
|
+
private readonly onCanvasTouchEnd;
|
|
457
|
+
private previousTouchCoords;
|
|
458
|
+
constructor(canvas: Canvas, dragOptions?: DragOptions);
|
|
459
|
+
addNode(node: AddNodeRequest): UserDraggableNodesCanvas;
|
|
460
|
+
removeNode(nodeId: string): UserDraggableNodesCanvas;
|
|
461
|
+
markPort(port: MarkPortRequest): UserDraggableNodesCanvas;
|
|
462
|
+
updatePortEdges(portId: string): UserDraggableNodesCanvas;
|
|
463
|
+
unmarkPort(portId: string): UserDraggableNodesCanvas;
|
|
464
|
+
addEdge(edge: AddEdgeRequest): UserDraggableNodesCanvas;
|
|
465
|
+
removeEdge(edgeId: string): UserDraggableNodesCanvas;
|
|
466
|
+
patchViewportState(request: PatchViewportRequest): UserDraggableNodesCanvas;
|
|
467
|
+
moveToNodes(nodeIds: readonly string[]): UserDraggableNodesCanvas;
|
|
468
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): UserDraggableNodesCanvas;
|
|
469
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserDraggableNodesCanvas;
|
|
470
|
+
moveNodeOnTop(nodeId: string): UserDraggableNodesCanvas;
|
|
471
|
+
clear(): UserDraggableNodesCanvas;
|
|
472
|
+
attach(element: HTMLElement): UserDraggableNodesCanvas;
|
|
473
|
+
detach(): UserDraggableNodesCanvas;
|
|
474
|
+
destroy(): void;
|
|
475
|
+
private setCursor;
|
|
476
|
+
private dragNode;
|
|
466
477
|
}
|
|
467
478
|
|
|
468
|
-
export declare class
|
|
479
|
+
export declare class UserTransformableCanvas implements Canvas {
|
|
469
480
|
private readonly canvas;
|
|
470
481
|
private readonly options?;
|
|
471
482
|
readonly transformation: PublicViewportTransformer;
|
|
472
|
-
readonly model: PublicGraphStore;
|
|
473
483
|
private element;
|
|
474
484
|
private isMoving;
|
|
475
485
|
private prevTouches;
|
|
476
486
|
private onTransform;
|
|
487
|
+
private onBeforeTransform;
|
|
477
488
|
private readonly isScalable;
|
|
478
489
|
private readonly isShiftable;
|
|
479
490
|
private readonly minViewScale;
|
|
@@ -487,21 +498,21 @@ export declare class TransformableCanvas implements Canvas {
|
|
|
487
498
|
private readonly onTouchMove;
|
|
488
499
|
private readonly onTouchEnd;
|
|
489
500
|
constructor(canvas: Canvas, options?: TransformOptions | undefined);
|
|
490
|
-
addNode(node: AddNodeRequest):
|
|
491
|
-
removeNode(nodeId: string):
|
|
492
|
-
markPort(port: MarkPortRequest):
|
|
493
|
-
|
|
494
|
-
unmarkPort(portId: string):
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
patchViewportState(request: PatchViewportRequest):
|
|
498
|
-
moveToNodes(nodeIds: readonly string[]):
|
|
499
|
-
updateNodeCoordinates(nodeId: string, x: number, y: number):
|
|
500
|
-
|
|
501
|
-
moveNodeOnTop(nodeId: string):
|
|
502
|
-
clear():
|
|
503
|
-
attach(element: HTMLElement):
|
|
504
|
-
detach():
|
|
501
|
+
addNode(node: AddNodeRequest): UserTransformableCanvas;
|
|
502
|
+
removeNode(nodeId: string): UserTransformableCanvas;
|
|
503
|
+
markPort(port: MarkPortRequest): UserTransformableCanvas;
|
|
504
|
+
updatePortEdges(portId: string): UserTransformableCanvas;
|
|
505
|
+
unmarkPort(portId: string): UserTransformableCanvas;
|
|
506
|
+
addEdge(edge: AddEdgeRequest): UserTransformableCanvas;
|
|
507
|
+
removeEdge(edgeId: string): UserTransformableCanvas;
|
|
508
|
+
patchViewportState(request: PatchViewportRequest): UserTransformableCanvas;
|
|
509
|
+
moveToNodes(nodeIds: readonly string[]): UserTransformableCanvas;
|
|
510
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): UserTransformableCanvas;
|
|
511
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserTransformableCanvas;
|
|
512
|
+
moveNodeOnTop(nodeId: string): UserTransformableCanvas;
|
|
513
|
+
clear(): UserTransformableCanvas;
|
|
514
|
+
attach(element: HTMLElement): UserTransformableCanvas;
|
|
515
|
+
detach(): UserTransformableCanvas;
|
|
505
516
|
destroy(): void;
|
|
506
517
|
private getAverageTouch;
|
|
507
518
|
private setCursor;
|
|
@@ -509,25 +520,6 @@ export declare class TransformableCanvas implements Canvas {
|
|
|
509
520
|
private scaleViewport;
|
|
510
521
|
}
|
|
511
522
|
|
|
512
|
-
export declare interface TransformOptions {
|
|
513
|
-
scale?: {
|
|
514
|
-
enabled?: boolean;
|
|
515
|
-
minContent?: number;
|
|
516
|
-
maxContent?: number;
|
|
517
|
-
wheelSensitivity?: number;
|
|
518
|
-
};
|
|
519
|
-
shift?: {
|
|
520
|
-
enabled?: boolean;
|
|
521
|
-
};
|
|
522
|
-
events?: {
|
|
523
|
-
onTransform?: () => void;
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
declare interface UpdateConnectionRequest {
|
|
528
|
-
readonly controller?: ConnectionController;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
523
|
declare class ViewportTransformer {
|
|
532
524
|
private state;
|
|
533
525
|
getViewCoords(xa: number, ya: number): [number, number];
|