@html-graph/html-graph 0.0.51 → 0.0.53
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 +20 -10
- package/dist/main.d.ts +276 -84
- package/dist/main.js +810 -596
- package/dist/main.umd.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -10,12 +10,10 @@
|
|
|
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
|
-
|
|
14
|
-
Port is an entity of a node to which edge can be attached to.
|
|
15
|
-
|
|
16
|
-
This library fits for tasks where easy nodes customization and interactiveness are required.
|
|
13
|
+
Visit <a target="_blank" href="https://html-graph.github.io">live demo</a>.
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
Instead of connecting nodes directly this library uses concept of ports, which provide greater fexibility at managing edges.
|
|
16
|
+
Port is an entity of a node to which edge can be attached to.
|
|
19
17
|
|
|
20
18
|
## Features:
|
|
21
19
|
|
|
@@ -33,12 +31,18 @@ npm i @html-graph/html-graph
|
|
|
33
31
|
```
|
|
34
32
|
|
|
35
33
|
```typescript
|
|
36
|
-
import {
|
|
34
|
+
import { AddNodePorts, HtmlGraphBuilder } from "@html-graph/html-graph";
|
|
37
35
|
|
|
38
36
|
const canvas = new HtmlGraphBuilder()
|
|
39
37
|
.setOptions({
|
|
40
|
-
background: {
|
|
41
|
-
|
|
38
|
+
background: {
|
|
39
|
+
type: "dots",
|
|
40
|
+
},
|
|
41
|
+
edges: {
|
|
42
|
+
shape: {
|
|
43
|
+
hasTargetArrow: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
42
46
|
})
|
|
43
47
|
.setUserDraggableNodes()
|
|
44
48
|
.setUserTransformableCanvas()
|
|
@@ -48,7 +52,7 @@ function createNode(
|
|
|
48
52
|
name: string,
|
|
49
53
|
frontPortId: string,
|
|
50
54
|
backPortId: string,
|
|
51
|
-
): [HTMLElement,
|
|
55
|
+
): [HTMLElement, AddNodePorts] {
|
|
52
56
|
const node = document.createElement("div");
|
|
53
57
|
node.classList.add("node");
|
|
54
58
|
|
|
@@ -64,7 +68,13 @@ function createNode(
|
|
|
64
68
|
backPort.classList.add("port");
|
|
65
69
|
node.appendChild(backPort);
|
|
66
70
|
|
|
67
|
-
return [
|
|
71
|
+
return [
|
|
72
|
+
node,
|
|
73
|
+
[
|
|
74
|
+
[frontPortId, frontPort],
|
|
75
|
+
[backPortId, backPort],
|
|
76
|
+
],
|
|
77
|
+
];
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
const [node1, ports1] = createNode("Node 1", "port-1-1", "port-1-2");
|
package/dist/main.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
export declare interface AddEdgeRequest {
|
|
2
|
-
id?:
|
|
2
|
+
id?: unknown;
|
|
3
3
|
from: string;
|
|
4
4
|
to: string;
|
|
5
|
-
options?:
|
|
5
|
+
options?: EdgeShape;
|
|
6
|
+
priority?: number;
|
|
6
7
|
}
|
|
7
8
|
|
|
9
|
+
export declare type AddNodePorts = Iterable<readonly [unknown, MarkNodePortRequest]>;
|
|
10
|
+
|
|
8
11
|
export declare interface AddNodeRequest {
|
|
9
|
-
id?:
|
|
12
|
+
id?: unknown;
|
|
10
13
|
element: HTMLElement;
|
|
11
14
|
x: number;
|
|
12
15
|
y: number;
|
|
13
|
-
ports?:
|
|
16
|
+
ports?: AddNodePorts;
|
|
14
17
|
centerFn?: CenterFn;
|
|
18
|
+
priority?: number;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export declare type BackgroundDrawingFn = (ctx: CanvasRenderingContext2D, transformer: PublicViewportTransformer) => void;
|
|
18
22
|
|
|
19
23
|
declare type BackgroundOptions = {
|
|
20
24
|
readonly type: "none";
|
|
21
|
-
} | {
|
|
22
|
-
readonly type: "color";
|
|
23
|
-
readonly color?: string;
|
|
24
25
|
} | {
|
|
25
26
|
readonly type: "dots";
|
|
26
27
|
readonly dotColor?: string;
|
|
@@ -32,7 +33,7 @@ declare type BackgroundOptions = {
|
|
|
32
33
|
readonly drawingFn: BackgroundDrawingFn;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
export declare class
|
|
36
|
+
export declare class BezierEdgeShape implements EdgeController {
|
|
36
37
|
private readonly color;
|
|
37
38
|
private readonly width;
|
|
38
39
|
private readonly curvature;
|
|
@@ -47,7 +48,7 @@ export declare class BezierEdgeController implements EdgeController {
|
|
|
47
48
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
declare interface
|
|
51
|
+
declare interface BezierEdgeShape_2 {
|
|
51
52
|
readonly type?: "bezier";
|
|
52
53
|
readonly color?: string;
|
|
53
54
|
readonly width?: number;
|
|
@@ -63,6 +64,10 @@ declare interface BezierEdgeOptions {
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
export declare interface Canvas {
|
|
67
|
+
/**
|
|
68
|
+
* provides api for accessing graph model
|
|
69
|
+
*/
|
|
70
|
+
readonly model: PublicGraphStore;
|
|
66
71
|
/**
|
|
67
72
|
* provides api for canvas transformation
|
|
68
73
|
*/
|
|
@@ -71,20 +76,24 @@ export declare interface Canvas {
|
|
|
71
76
|
* adds node to graph
|
|
72
77
|
*/
|
|
73
78
|
addNode(node: AddNodeRequest): Canvas;
|
|
79
|
+
/**
|
|
80
|
+
* updates node absolute coordinates
|
|
81
|
+
*/
|
|
82
|
+
updateNode(nodeId: unknown, request: UpdateNodeRequest): Canvas;
|
|
74
83
|
/**
|
|
75
84
|
* removes node from graph
|
|
76
85
|
* all the ports of node get unmarked
|
|
77
86
|
* all the edges adjacent to node get removed
|
|
78
87
|
*/
|
|
79
|
-
removeNode(nodeId:
|
|
88
|
+
removeNode(nodeId: unknown): Canvas;
|
|
80
89
|
/**
|
|
81
90
|
* marks element as port of node
|
|
82
91
|
*/
|
|
83
92
|
markPort(port: MarkPortRequest): Canvas;
|
|
84
93
|
/**
|
|
85
|
-
* updates
|
|
94
|
+
* updates port and attached edges
|
|
86
95
|
*/
|
|
87
|
-
|
|
96
|
+
updatePort(portId: string, request?: UpdatePortRequest): Canvas;
|
|
88
97
|
/**
|
|
89
98
|
* ummarks element as port of node
|
|
90
99
|
* all the edges adjacent to port get removed
|
|
@@ -94,10 +103,14 @@ export declare interface Canvas {
|
|
|
94
103
|
* adds edge to graph
|
|
95
104
|
*/
|
|
96
105
|
addEdge(edge: AddEdgeRequest): Canvas;
|
|
106
|
+
/**
|
|
107
|
+
* updates edge
|
|
108
|
+
*/
|
|
109
|
+
updateEdge(edgeId: unknown, request: UpdateEdgeRequest): Canvas;
|
|
97
110
|
/**
|
|
98
111
|
* removes edge from graph
|
|
99
112
|
*/
|
|
100
|
-
removeEdge(edgeId:
|
|
113
|
+
removeEdge(edgeId: unknown): Canvas;
|
|
101
114
|
/**
|
|
102
115
|
* applies transformation for viewport
|
|
103
116
|
*/
|
|
@@ -106,18 +119,6 @@ export declare interface Canvas {
|
|
|
106
119
|
* moves viewport to nodes
|
|
107
120
|
*/
|
|
108
121
|
moveToNodes(nodeIds: readonly string[]): Canvas;
|
|
109
|
-
/**
|
|
110
|
-
* updates node absolute coordinates
|
|
111
|
-
*/
|
|
112
|
-
updateNodeCoordinates(nodeId: string, x: number, y: number): Canvas;
|
|
113
|
-
/**
|
|
114
|
-
* updates edge
|
|
115
|
-
*/
|
|
116
|
-
updateEdge(edgeId: string, request: UpdateEdgeRequest): Canvas;
|
|
117
|
-
/**
|
|
118
|
-
* moves specified node on top
|
|
119
|
-
*/
|
|
120
|
-
moveNodeOnTop(nodeId: string): Canvas;
|
|
121
122
|
/**
|
|
122
123
|
* attaches canvas to given element
|
|
123
124
|
*/
|
|
@@ -135,7 +136,7 @@ export declare interface Canvas {
|
|
|
135
136
|
/**
|
|
136
137
|
* destroys canvas
|
|
137
138
|
* canvas element gets rolled back to initial state
|
|
138
|
-
* canvas
|
|
139
|
+
* canvas can not be reused
|
|
139
140
|
*/
|
|
140
141
|
destroy(): void;
|
|
141
142
|
}
|
|
@@ -146,28 +147,30 @@ export declare interface Canvas {
|
|
|
146
147
|
export declare class CanvasCore implements Canvas {
|
|
147
148
|
private readonly apiOptions?;
|
|
148
149
|
readonly transformation: PublicViewportTransformer;
|
|
150
|
+
readonly model: PublicGraphStore;
|
|
149
151
|
private readonly di;
|
|
150
|
-
private readonly
|
|
152
|
+
private readonly edgeShapeFactory;
|
|
151
153
|
constructor(apiOptions?: CoreOptions | undefined);
|
|
152
154
|
addNode(node: AddNodeRequest): CanvasCore;
|
|
153
|
-
|
|
154
|
-
removeNode(nodeId:
|
|
155
|
+
updateNode(nodeId: unknown, request: UpdateNodeRequest): CanvasCore;
|
|
156
|
+
removeNode(nodeId: unknown): CanvasCore;
|
|
155
157
|
markPort(port: MarkPortRequest): CanvasCore;
|
|
156
|
-
|
|
158
|
+
updatePort(portId: string, request: UpdatePortRequest): CanvasCore;
|
|
157
159
|
unmarkPort(portId: string): CanvasCore;
|
|
158
160
|
addEdge(edge: AddEdgeRequest): CanvasCore;
|
|
159
|
-
|
|
161
|
+
updateEdge(edgeId: unknown, request: UpdateEdgeRequest): CanvasCore;
|
|
162
|
+
removeEdge(edgeId: unknown): CanvasCore;
|
|
160
163
|
patchViewportState(request: PatchViewportRequest): CanvasCore;
|
|
161
164
|
moveToNodes(nodeIds: readonly string[]): CanvasCore;
|
|
162
|
-
updateNodeCoordinates(nodeId: string, x: number, y: number): CanvasCore;
|
|
163
|
-
updateEdge(edgeId: string, request: UpdateEdgeRequest): CanvasCore;
|
|
164
165
|
clear(): CanvasCore;
|
|
165
166
|
attach(element: HTMLElement): CanvasCore;
|
|
166
167
|
detach(): CanvasCore;
|
|
167
168
|
destroy(): void;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
declare type CenterFn = (width: number, height: number) => [number, number];
|
|
171
|
+
export declare type CenterFn = (width: number, height: number) => [number, number];
|
|
172
|
+
|
|
173
|
+
declare type ConstantPriority = number;
|
|
171
174
|
|
|
172
175
|
export declare interface CoreOptions {
|
|
173
176
|
/**
|
|
@@ -183,6 +186,10 @@ export declare interface CoreOptions {
|
|
|
183
186
|
* center of nodes specified in addNode method by x and y
|
|
184
187
|
*/
|
|
185
188
|
readonly centerFn?: CenterFn;
|
|
189
|
+
/**
|
|
190
|
+
* specifies default z-index value
|
|
191
|
+
*/
|
|
192
|
+
readonly priority?: Priority;
|
|
186
193
|
};
|
|
187
194
|
/**
|
|
188
195
|
* ports related behavior
|
|
@@ -201,19 +208,19 @@ export declare interface CoreOptions {
|
|
|
201
208
|
/**
|
|
202
209
|
*edges related behavior
|
|
203
210
|
*/
|
|
204
|
-
readonly edges?:
|
|
205
|
-
/**
|
|
206
|
-
* layers related behavior
|
|
207
|
-
*/
|
|
208
|
-
readonly layers?: {
|
|
211
|
+
readonly edges?: {
|
|
209
212
|
/**
|
|
210
|
-
*
|
|
213
|
+
* specifies default controller
|
|
211
214
|
*/
|
|
212
|
-
readonly
|
|
215
|
+
readonly shape?: EdgeShape;
|
|
216
|
+
/**
|
|
217
|
+
* specifies default z-index value
|
|
218
|
+
*/
|
|
219
|
+
readonly priority?: Priority;
|
|
213
220
|
};
|
|
214
221
|
}
|
|
215
222
|
|
|
216
|
-
export declare const
|
|
223
|
+
export declare const createBezierEdgeShapeFactory: (options: {
|
|
217
224
|
color: string;
|
|
218
225
|
width: number;
|
|
219
226
|
arrowLength: number;
|
|
@@ -225,9 +232,23 @@ export declare const createBezierEdgeControllerFactory: (options: {
|
|
|
225
232
|
smallCycleRadius: number;
|
|
226
233
|
detourDistance: number;
|
|
227
234
|
detourDirection: number;
|
|
228
|
-
}) =>
|
|
235
|
+
}) => EdgeShapeFactory;
|
|
236
|
+
|
|
237
|
+
export declare const createHorizontalEdgeShapeFactory: (options: {
|
|
238
|
+
color: string;
|
|
239
|
+
width: number;
|
|
240
|
+
arrowLength: number;
|
|
241
|
+
arrowWidth: number;
|
|
242
|
+
arrowOffset: number;
|
|
243
|
+
hasSourceArrow: boolean;
|
|
244
|
+
hasTargetArrow: boolean;
|
|
245
|
+
cycleSquareSide: number;
|
|
246
|
+
roundness: number;
|
|
247
|
+
detourDistance: number;
|
|
248
|
+
detourDirection: number;
|
|
249
|
+
}) => EdgeShapeFactory;
|
|
229
250
|
|
|
230
|
-
export declare const
|
|
251
|
+
export declare const createStraightEdgeShareFactory: (options: {
|
|
231
252
|
color: string;
|
|
232
253
|
width: number;
|
|
233
254
|
arrowLength: number;
|
|
@@ -239,14 +260,30 @@ export declare const createStraightEdgeControllerFactory: (options: {
|
|
|
239
260
|
roundness: number;
|
|
240
261
|
detourDistance: number;
|
|
241
262
|
detourDirection: number;
|
|
242
|
-
}) =>
|
|
263
|
+
}) => EdgeShapeFactory;
|
|
243
264
|
|
|
244
|
-
declare
|
|
265
|
+
export declare const createVerticalEdgeShapeFactory: (options: {
|
|
266
|
+
color: string;
|
|
267
|
+
width: number;
|
|
268
|
+
arrowLength: number;
|
|
269
|
+
arrowWidth: number;
|
|
270
|
+
arrowOffset: number;
|
|
271
|
+
hasSourceArrow: boolean;
|
|
272
|
+
hasTargetArrow: boolean;
|
|
273
|
+
cycleSquareSide: number;
|
|
274
|
+
roundness: number;
|
|
275
|
+
detourDistance: number;
|
|
276
|
+
detourDirection: number;
|
|
277
|
+
}) => EdgeShapeFactory;
|
|
278
|
+
|
|
279
|
+
declare interface CustomEdgeShape {
|
|
245
280
|
readonly type: "custom";
|
|
246
|
-
readonly controllerFactory:
|
|
281
|
+
readonly controllerFactory: EdgeShapeFactory;
|
|
247
282
|
}
|
|
248
283
|
|
|
249
|
-
|
|
284
|
+
declare type CustomPriority = PriorityFn;
|
|
285
|
+
|
|
286
|
+
export declare class CycleCircleEdgeShape implements EdgeController {
|
|
250
287
|
private readonly color;
|
|
251
288
|
private readonly width;
|
|
252
289
|
private readonly arrowLength;
|
|
@@ -261,7 +298,7 @@ export declare class CycleCircleEdgeController implements EdgeController {
|
|
|
261
298
|
update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
|
|
262
299
|
}
|
|
263
300
|
|
|
264
|
-
export declare class
|
|
301
|
+
export declare class CycleSquareEdgeShape implements EdgeController {
|
|
265
302
|
private readonly color;
|
|
266
303
|
private readonly width;
|
|
267
304
|
private readonly arrowLength;
|
|
@@ -278,7 +315,7 @@ export declare class CycleSquareEdgeController implements EdgeController {
|
|
|
278
315
|
update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
|
|
279
316
|
}
|
|
280
317
|
|
|
281
|
-
export declare class
|
|
318
|
+
export declare class DetourStraightEdgeShape implements EdgeController {
|
|
282
319
|
private readonly color;
|
|
283
320
|
private readonly width;
|
|
284
321
|
private readonly arrowLength;
|
|
@@ -297,6 +334,7 @@ export declare class DetourStraightEdgeController implements EdgeController {
|
|
|
297
334
|
}
|
|
298
335
|
|
|
299
336
|
export declare interface DragOptions {
|
|
337
|
+
grabPriorityStrategy?: "freeze" | "move-on-top";
|
|
300
338
|
events?: {
|
|
301
339
|
onNodeDrag?: (payload: NodeDragPayload) => void;
|
|
302
340
|
onBeforeNodeDrag?: (payload: NodeDragPayload) => boolean;
|
|
@@ -308,9 +346,16 @@ export declare interface EdgeController {
|
|
|
308
346
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
309
347
|
}
|
|
310
348
|
|
|
311
|
-
declare
|
|
349
|
+
declare interface EdgePayload {
|
|
350
|
+
from: string;
|
|
351
|
+
to: string;
|
|
352
|
+
shape: EdgeController;
|
|
353
|
+
priority: number;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare type EdgeShape = BezierEdgeShape_2 | StraightEdgeShape_2 | CustomEdgeShape | HorizontalEdgeShape_2 | VerticalEdgeShape_2;
|
|
312
357
|
|
|
313
|
-
declare type
|
|
358
|
+
declare type EdgeShapeFactory = (type: EdgeType) => EdgeController;
|
|
314
359
|
|
|
315
360
|
export declare enum EdgeType {
|
|
316
361
|
Regular = "regular",
|
|
@@ -318,6 +363,87 @@ export declare enum EdgeType {
|
|
|
318
363
|
NodeCycle = "node-cycle"
|
|
319
364
|
}
|
|
320
365
|
|
|
366
|
+
export declare interface GraphEdge {
|
|
367
|
+
readonly from: unknown;
|
|
368
|
+
readonly to: unknown;
|
|
369
|
+
readonly priority: number;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export declare interface GraphNode {
|
|
373
|
+
readonly element: HTMLElement;
|
|
374
|
+
readonly x: number;
|
|
375
|
+
readonly y: number;
|
|
376
|
+
readonly centerFn: CenterFn;
|
|
377
|
+
readonly priority: number;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export declare interface GraphPort {
|
|
381
|
+
readonly element: HTMLElement;
|
|
382
|
+
readonly centerFn: CenterFn;
|
|
383
|
+
readonly direction: number;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare class GraphStore {
|
|
387
|
+
private readonly nodes;
|
|
388
|
+
private readonly ports;
|
|
389
|
+
private readonly nodePorts;
|
|
390
|
+
private readonly portNodeId;
|
|
391
|
+
private readonly edges;
|
|
392
|
+
private readonly incommingEdges;
|
|
393
|
+
private readonly outcommingEdges;
|
|
394
|
+
private readonly cycleEdges;
|
|
395
|
+
addNode(nodeId: unknown, element: HTMLElement, x: number, y: number, centerFn: CenterFn, priority: number): void;
|
|
396
|
+
getNode(nodeId: unknown): NodePayload | undefined;
|
|
397
|
+
removeNode(nodeId: unknown): void;
|
|
398
|
+
addPort(portId: unknown, element: HTMLElement, nodeId: unknown, centerFn: CenterFn, dir: number): void;
|
|
399
|
+
getPort(portId: unknown): PortPayload | undefined;
|
|
400
|
+
getPortNode(portId: string): unknown | undefined;
|
|
401
|
+
removePort(portId: string): void;
|
|
402
|
+
addEdge(edgeId: unknown, fromPortId: string, toPortId: string, shape: EdgeController, priority: number): void;
|
|
403
|
+
getEdge(edgeId: unknown): EdgePayload | undefined;
|
|
404
|
+
removeEdge(edgeId: unknown): void;
|
|
405
|
+
getPortAdjacentEdges(portId: string): readonly unknown[];
|
|
406
|
+
getNodeAdjacentEdges(nodeId: unknown): readonly unknown[];
|
|
407
|
+
clear(): void;
|
|
408
|
+
getPortIncomingEdges(portId: unknown): readonly unknown[];
|
|
409
|
+
getPortOutcomingEdges(portId: unknown): readonly unknown[];
|
|
410
|
+
getPortCycleEdges(portId: unknown): readonly unknown[];
|
|
411
|
+
getNodeIncomingEdges(nodeId: unknown): readonly unknown[];
|
|
412
|
+
getNodeOutcomingEdges(nodeId: unknown): readonly unknown[];
|
|
413
|
+
getNodeCycleEdges(nodeId: unknown): readonly unknown[];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export declare class HorizontalEdgeShape implements EdgeController {
|
|
417
|
+
private readonly color;
|
|
418
|
+
private readonly width;
|
|
419
|
+
private readonly arrowLength;
|
|
420
|
+
private readonly arrowWidth;
|
|
421
|
+
private readonly arrowOffset;
|
|
422
|
+
private readonly roundness;
|
|
423
|
+
readonly svg: SVGSVGElement;
|
|
424
|
+
private readonly group;
|
|
425
|
+
private readonly line;
|
|
426
|
+
private readonly sourceArrow;
|
|
427
|
+
private readonly targetArrow;
|
|
428
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
429
|
+
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare interface HorizontalEdgeShape_2 {
|
|
433
|
+
readonly type: "horizontal";
|
|
434
|
+
readonly color?: string;
|
|
435
|
+
readonly width?: number;
|
|
436
|
+
readonly arrowLength?: number;
|
|
437
|
+
readonly arrowWidth?: number;
|
|
438
|
+
readonly arrowOffset?: number;
|
|
439
|
+
readonly hasSourceArrow?: boolean;
|
|
440
|
+
readonly hasTargetArrow?: boolean;
|
|
441
|
+
readonly cycleSquareSide?: number;
|
|
442
|
+
readonly roundness?: number;
|
|
443
|
+
readonly detourDistance?: number;
|
|
444
|
+
readonly detourDirection?: number;
|
|
445
|
+
}
|
|
446
|
+
|
|
321
447
|
export declare class HtmlGraphBuilder {
|
|
322
448
|
private coreOptions;
|
|
323
449
|
private dragOptions;
|
|
@@ -330,7 +456,7 @@ export declare class HtmlGraphBuilder {
|
|
|
330
456
|
build(): Canvas;
|
|
331
457
|
}
|
|
332
458
|
|
|
333
|
-
declare type
|
|
459
|
+
declare type IncrementalPriority = "incremental";
|
|
334
460
|
|
|
335
461
|
export declare type MarkNodePortRequest = HTMLElement | {
|
|
336
462
|
readonly element: HTMLElement;
|
|
@@ -339,31 +465,26 @@ export declare type MarkNodePortRequest = HTMLElement | {
|
|
|
339
465
|
};
|
|
340
466
|
|
|
341
467
|
export declare interface MarkPortRequest {
|
|
342
|
-
readonly id?:
|
|
468
|
+
readonly id?: unknown;
|
|
343
469
|
readonly element: HTMLElement;
|
|
344
|
-
readonly nodeId:
|
|
470
|
+
readonly nodeId: unknown;
|
|
345
471
|
readonly centerFn?: CenterFn;
|
|
346
472
|
readonly direction?: number;
|
|
347
473
|
}
|
|
348
474
|
|
|
349
475
|
export declare interface NodeDragPayload {
|
|
350
|
-
readonly nodeId:
|
|
476
|
+
readonly nodeId: unknown;
|
|
351
477
|
readonly element: HTMLElement;
|
|
352
478
|
readonly x: number;
|
|
353
479
|
readonly y: number;
|
|
354
480
|
}
|
|
355
481
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
export declare interface NodeResponse {
|
|
364
|
-
readonly x: number;
|
|
365
|
-
readonly y: number;
|
|
366
|
-
readonly element: HTMLElement;
|
|
482
|
+
declare interface NodePayload {
|
|
483
|
+
element: HTMLElement;
|
|
484
|
+
x: number;
|
|
485
|
+
y: number;
|
|
486
|
+
centerFn: CenterFn;
|
|
487
|
+
priority: number;
|
|
367
488
|
}
|
|
368
489
|
|
|
369
490
|
export declare interface PatchViewportRequest {
|
|
@@ -374,8 +495,29 @@ export declare interface PatchViewportRequest {
|
|
|
374
495
|
|
|
375
496
|
export declare interface PortPayload {
|
|
376
497
|
readonly element: HTMLElement;
|
|
377
|
-
|
|
378
|
-
|
|
498
|
+
centerFn: CenterFn;
|
|
499
|
+
direction: number;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
declare type Priority = ConstantPriority | IncrementalPriority | SharedIncrementalPriority | CustomPriority;
|
|
503
|
+
|
|
504
|
+
export declare type PriorityFn = () => number;
|
|
505
|
+
|
|
506
|
+
declare class PublicGraphStore {
|
|
507
|
+
private readonly graphStore;
|
|
508
|
+
constructor(graphStore: GraphStore);
|
|
509
|
+
getNode(nodeId: unknown): GraphNode | undefined;
|
|
510
|
+
getPort(portId: unknown): GraphPort | undefined;
|
|
511
|
+
getPortNode(portId: string): unknown | undefined;
|
|
512
|
+
getEdge(edgeId: unknown): GraphEdge | undefined;
|
|
513
|
+
getPortAdjacentEdges(portId: string): readonly unknown[];
|
|
514
|
+
getNodeAdjacentEdges(nodeId: unknown): readonly unknown[];
|
|
515
|
+
getPortIncomingEdges(portId: unknown): readonly unknown[];
|
|
516
|
+
getPortOutcomingEdges(portId: unknown): readonly unknown[];
|
|
517
|
+
getPortCycleEdges(portId: unknown): readonly unknown[];
|
|
518
|
+
getNodeIncomingEdges(nodeId: unknown): readonly unknown[];
|
|
519
|
+
getNodeOutcomingEdges(nodeId: unknown): readonly unknown[];
|
|
520
|
+
getNodeCycleEdges(nodeId: unknown): readonly unknown[];
|
|
379
521
|
}
|
|
380
522
|
|
|
381
523
|
export declare class PublicViewportTransformer {
|
|
@@ -403,7 +545,9 @@ export declare class PublicViewportTransformer {
|
|
|
403
545
|
getAbsScale(): number;
|
|
404
546
|
}
|
|
405
547
|
|
|
406
|
-
|
|
548
|
+
declare type SharedIncrementalPriority = "shared-incremental";
|
|
549
|
+
|
|
550
|
+
export declare class StraightEdgeShape implements EdgeController {
|
|
407
551
|
private readonly color;
|
|
408
552
|
private readonly width;
|
|
409
553
|
private readonly arrowLength;
|
|
@@ -419,7 +563,7 @@ export declare class StraightEdgeController implements EdgeController {
|
|
|
419
563
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
420
564
|
}
|
|
421
565
|
|
|
422
|
-
declare interface
|
|
566
|
+
declare interface StraightEdgeShape_2 {
|
|
423
567
|
readonly type: "straight";
|
|
424
568
|
readonly color?: string;
|
|
425
569
|
readonly width?: number;
|
|
@@ -458,11 +602,26 @@ export declare interface TransformPayload {
|
|
|
458
602
|
|
|
459
603
|
export declare interface UpdateEdgeRequest {
|
|
460
604
|
readonly controller?: EdgeController;
|
|
605
|
+
readonly priority?: number;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
declare interface UpdateNodeRequest {
|
|
609
|
+
readonly x?: number;
|
|
610
|
+
readonly y?: number;
|
|
611
|
+
readonly priority?: number;
|
|
612
|
+
readonly centerFn?: CenterFn;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
declare interface UpdatePortRequest {
|
|
616
|
+
readonly direction?: number;
|
|
617
|
+
readonly centerFn?: CenterFn;
|
|
461
618
|
}
|
|
462
619
|
|
|
463
620
|
export declare class UserDraggableNodesCanvas implements Canvas {
|
|
464
621
|
private readonly canvas;
|
|
622
|
+
readonly model: PublicGraphStore;
|
|
465
623
|
readonly transformation: PublicViewportTransformer;
|
|
624
|
+
private maxNodePriority;
|
|
466
625
|
private readonly nodes;
|
|
467
626
|
private grabbedNodeId;
|
|
468
627
|
private onNodeDrag;
|
|
@@ -475,30 +634,33 @@ export declare class UserDraggableNodesCanvas implements Canvas {
|
|
|
475
634
|
private readonly onCanvasTouchMove;
|
|
476
635
|
private readonly onCanvasTouchEnd;
|
|
477
636
|
private previousTouchCoords;
|
|
637
|
+
private freezePriority;
|
|
478
638
|
constructor(canvas: Canvas, dragOptions?: DragOptions);
|
|
479
|
-
addNode(
|
|
480
|
-
|
|
639
|
+
addNode(request: AddNodeRequest): UserDraggableNodesCanvas;
|
|
640
|
+
updateNode(nodeId: unknown, request: UpdateNodeRequest): UserDraggableNodesCanvas;
|
|
641
|
+
removeNode(nodeId: unknown): UserDraggableNodesCanvas;
|
|
481
642
|
markPort(port: MarkPortRequest): UserDraggableNodesCanvas;
|
|
482
|
-
|
|
643
|
+
updatePort(portId: string, request?: UpdatePortRequest): UserDraggableNodesCanvas;
|
|
483
644
|
unmarkPort(portId: string): UserDraggableNodesCanvas;
|
|
484
645
|
addEdge(edge: AddEdgeRequest): UserDraggableNodesCanvas;
|
|
485
|
-
|
|
646
|
+
updateEdge(edgeId: unknown, request: UpdateEdgeRequest): UserDraggableNodesCanvas;
|
|
647
|
+
removeEdge(edgeId: unknown): UserDraggableNodesCanvas;
|
|
486
648
|
patchViewportState(request: PatchViewportRequest): UserDraggableNodesCanvas;
|
|
487
649
|
moveToNodes(nodeIds: readonly string[]): UserDraggableNodesCanvas;
|
|
488
|
-
updateNodeCoordinates(nodeId: string, x: number, y: number): UserDraggableNodesCanvas;
|
|
489
|
-
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserDraggableNodesCanvas;
|
|
490
|
-
moveNodeOnTop(nodeId: string): UserDraggableNodesCanvas;
|
|
491
650
|
clear(): UserDraggableNodesCanvas;
|
|
492
651
|
attach(element: HTMLElement): UserDraggableNodesCanvas;
|
|
493
652
|
detach(): UserDraggableNodesCanvas;
|
|
494
653
|
destroy(): void;
|
|
495
654
|
private setCursor;
|
|
496
655
|
private dragNode;
|
|
656
|
+
private updateMaxNodePriority;
|
|
657
|
+
private moveNodeOnTop;
|
|
497
658
|
}
|
|
498
659
|
|
|
499
660
|
export declare class UserTransformableCanvas implements Canvas {
|
|
500
661
|
private readonly canvas;
|
|
501
662
|
private readonly options?;
|
|
663
|
+
readonly model: PublicGraphStore;
|
|
502
664
|
readonly transformation: PublicViewportTransformer;
|
|
503
665
|
private element;
|
|
504
666
|
private isMoving;
|
|
@@ -519,17 +681,16 @@ export declare class UserTransformableCanvas implements Canvas {
|
|
|
519
681
|
private readonly onTouchEnd;
|
|
520
682
|
constructor(canvas: Canvas, options?: TransformOptions | undefined);
|
|
521
683
|
addNode(node: AddNodeRequest): UserTransformableCanvas;
|
|
522
|
-
|
|
684
|
+
updateNode(nodeId: unknown, request: UpdateNodeRequest): UserTransformableCanvas;
|
|
685
|
+
removeNode(nodeId: unknown): UserTransformableCanvas;
|
|
523
686
|
markPort(port: MarkPortRequest): UserTransformableCanvas;
|
|
524
|
-
|
|
687
|
+
updatePort(portId: string, request: UpdatePortRequest): UserTransformableCanvas;
|
|
525
688
|
unmarkPort(portId: string): UserTransformableCanvas;
|
|
526
689
|
addEdge(edge: AddEdgeRequest): UserTransformableCanvas;
|
|
527
|
-
|
|
690
|
+
updateEdge(edgeId: unknown, request: UpdateEdgeRequest): UserTransformableCanvas;
|
|
691
|
+
removeEdge(edgeId: unknown): UserTransformableCanvas;
|
|
528
692
|
patchViewportState(request: PatchViewportRequest): UserTransformableCanvas;
|
|
529
693
|
moveToNodes(nodeIds: readonly string[]): UserTransformableCanvas;
|
|
530
|
-
updateNodeCoordinates(nodeId: string, x: number, y: number): UserTransformableCanvas;
|
|
531
|
-
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserTransformableCanvas;
|
|
532
|
-
moveNodeOnTop(nodeId: string): UserTransformableCanvas;
|
|
533
694
|
clear(): UserTransformableCanvas;
|
|
534
695
|
attach(element: HTMLElement): UserTransformableCanvas;
|
|
535
696
|
detach(): UserTransformableCanvas;
|
|
@@ -540,6 +701,37 @@ export declare class UserTransformableCanvas implements Canvas {
|
|
|
540
701
|
private scaleViewport;
|
|
541
702
|
}
|
|
542
703
|
|
|
704
|
+
export declare class VerticalEdgeShape implements EdgeController {
|
|
705
|
+
private readonly color;
|
|
706
|
+
private readonly width;
|
|
707
|
+
private readonly arrowLength;
|
|
708
|
+
private readonly arrowWidth;
|
|
709
|
+
private readonly arrowOffset;
|
|
710
|
+
private readonly roundness;
|
|
711
|
+
readonly svg: SVGSVGElement;
|
|
712
|
+
private readonly group;
|
|
713
|
+
private readonly line;
|
|
714
|
+
private readonly sourceArrow;
|
|
715
|
+
private readonly targetArrow;
|
|
716
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
717
|
+
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
declare interface VerticalEdgeShape_2 {
|
|
721
|
+
readonly type: "vertical";
|
|
722
|
+
readonly color?: string;
|
|
723
|
+
readonly width?: number;
|
|
724
|
+
readonly arrowLength?: number;
|
|
725
|
+
readonly arrowWidth?: number;
|
|
726
|
+
readonly arrowOffset?: number;
|
|
727
|
+
readonly hasSourceArrow?: boolean;
|
|
728
|
+
readonly hasTargetArrow?: boolean;
|
|
729
|
+
readonly cycleSquareSide?: number;
|
|
730
|
+
readonly roundness?: number;
|
|
731
|
+
readonly detourDistance?: number;
|
|
732
|
+
readonly detourDirection?: number;
|
|
733
|
+
}
|
|
734
|
+
|
|
543
735
|
declare class ViewportTransformer {
|
|
544
736
|
private state;
|
|
545
737
|
getViewCoords(xa: number, ya: number): [number, number];
|