@html-graph/html-graph 0.0.47 → 0.0.49
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 +7 -8
- package/dist/main.d.ts +204 -266
- package/dist/main.js +650 -646
- package/dist/main.umd.cjs +1 -1
- package/package.json +2 -2
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,50 +80,38 @@ 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
|
*/
|
|
106
|
-
patchViewportState(
|
|
102
|
+
patchViewportState(request: PatchViewportRequest): Canvas;
|
|
107
103
|
/**
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
moveViewport(apiTransform: MoveViewportRequest): Canvas;
|
|
111
|
-
/**
|
|
112
|
-
* applies scale transformation for content
|
|
113
|
-
*/
|
|
114
|
-
scaleViewport(apiTransform: ScaleViewportRequest): Canvas;
|
|
115
|
-
/**
|
|
116
|
-
* applies shift transformation for content
|
|
104
|
+
* moves viewport to nodes
|
|
117
105
|
*/
|
|
118
106
|
moveToNodes(nodeIds: readonly string[]): Canvas;
|
|
119
107
|
/**
|
|
120
108
|
* updates node absolute coordinates
|
|
121
109
|
*/
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* updates connection
|
|
125
|
-
*/
|
|
126
|
-
updateConnection(connectionId: string, request: UpdateConnectionRequest): Canvas;
|
|
110
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): Canvas;
|
|
127
111
|
/**
|
|
128
|
-
*
|
|
112
|
+
* updates edge
|
|
129
113
|
*/
|
|
130
|
-
|
|
114
|
+
updateConnection(edgeId: string, request: UpdateConnectionRequest): Canvas;
|
|
131
115
|
/**
|
|
132
116
|
* moves specified node on top
|
|
133
117
|
*/
|
|
@@ -160,7 +144,6 @@ export declare interface Canvas {
|
|
|
160
144
|
export declare class CanvasCore implements Canvas {
|
|
161
145
|
private readonly apiOptions?;
|
|
162
146
|
readonly transformation: PublicViewportTransformer;
|
|
163
|
-
readonly model: PublicGraphStore;
|
|
164
147
|
private readonly di;
|
|
165
148
|
private readonly connectionControllerFactory;
|
|
166
149
|
constructor(apiOptions?: CoreOptions | undefined);
|
|
@@ -168,17 +151,14 @@ export declare class CanvasCore implements Canvas {
|
|
|
168
151
|
moveNodeOnTop(nodeId: string): CanvasCore;
|
|
169
152
|
removeNode(nodeId: string): CanvasCore;
|
|
170
153
|
markPort(port: MarkPortRequest): CanvasCore;
|
|
171
|
-
|
|
154
|
+
updatePortEdges(portId: string): CanvasCore;
|
|
172
155
|
unmarkPort(portId: string): CanvasCore;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
patchViewportState(
|
|
176
|
-
moveViewport(apiTransform: MoveViewportRequest): CanvasCore;
|
|
177
|
-
scaleViewport(apiTransform: ScaleViewportRequest): CanvasCore;
|
|
156
|
+
addEdge(connection: AddEdgeRequest): CanvasCore;
|
|
157
|
+
removeEdge(connectionId: string): CanvasCore;
|
|
158
|
+
patchViewportState(request: PatchViewportRequest): CanvasCore;
|
|
178
159
|
moveToNodes(nodeIds: readonly string[]): CanvasCore;
|
|
179
|
-
|
|
160
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): CanvasCore;
|
|
180
161
|
updateConnection(connectionId: string, request: UpdateConnectionRequest): CanvasCore;
|
|
181
|
-
dragNode(nodeId: string, dx: number, dy: number): CanvasCore;
|
|
182
162
|
clear(): CanvasCore;
|
|
183
163
|
attach(element: HTMLElement): CanvasCore;
|
|
184
164
|
detach(): CanvasCore;
|
|
@@ -187,34 +167,6 @@ export declare class CanvasCore implements Canvas {
|
|
|
187
167
|
|
|
188
168
|
declare type CenterFn = (width: number, height: number) => [number, number];
|
|
189
169
|
|
|
190
|
-
export declare interface ConnectionController {
|
|
191
|
-
readonly svg: SVGSVGElement;
|
|
192
|
-
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
declare type ConnectionControllerFactory = (type: ConnectionType) => ConnectionController;
|
|
196
|
-
|
|
197
|
-
declare type ConnectionOptions = BezierConnectionOptions | StraightConnectionOptions | CustomConnectionOptions;
|
|
198
|
-
|
|
199
|
-
declare interface ConnectionPayload {
|
|
200
|
-
from: string;
|
|
201
|
-
to: string;
|
|
202
|
-
controller: ConnectionController;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export declare enum ConnectionType {
|
|
206
|
-
Regular = "regular",
|
|
207
|
-
Cycle = "cycle"
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export declare class ConnectionUtils {
|
|
211
|
-
static getPortCenter(port: PortPayload): Point;
|
|
212
|
-
static rotate(point: Point, vector: Point, center: Point): Point;
|
|
213
|
-
static getDirectionVector(direction: number | null, flipX: number, flipY: number): Point;
|
|
214
|
-
static getArrowPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowWidth: number): string;
|
|
215
|
-
static getArrowOffsetPath(vect: Point, shiftX: number, shiftY: number, arrowLength: number, arrowOffset: number): string;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
170
|
export declare interface CoreOptions {
|
|
219
171
|
/**
|
|
220
172
|
* canvas background settings
|
|
@@ -243,7 +195,7 @@ export declare interface CoreOptions {
|
|
|
243
195
|
/**
|
|
244
196
|
*connections related behavior
|
|
245
197
|
*/
|
|
246
|
-
readonly
|
|
198
|
+
readonly edges?: EdgeOptions;
|
|
247
199
|
/**
|
|
248
200
|
* layers related behavior
|
|
249
201
|
*/
|
|
@@ -255,7 +207,7 @@ export declare interface CoreOptions {
|
|
|
255
207
|
};
|
|
256
208
|
}
|
|
257
209
|
|
|
258
|
-
export declare const
|
|
210
|
+
export declare const createBezierEdgeControllerFactory: (options: {
|
|
259
211
|
color: string;
|
|
260
212
|
width: number;
|
|
261
213
|
arrowLength: number;
|
|
@@ -263,9 +215,11 @@ export declare const createBezierConnectionControllerFactory: (options: {
|
|
|
263
215
|
curvature: number;
|
|
264
216
|
hasSourceArrow: boolean;
|
|
265
217
|
hasTargetArrow: boolean;
|
|
266
|
-
|
|
218
|
+
cycleRadius: number;
|
|
219
|
+
smallCycleRadius: number;
|
|
220
|
+
}) => EdgeControllerFactory;
|
|
267
221
|
|
|
268
|
-
export declare const
|
|
222
|
+
export declare const createStraightEdgeControllerFactory: (options: {
|
|
269
223
|
color: string;
|
|
270
224
|
width: number;
|
|
271
225
|
arrowLength: number;
|
|
@@ -273,100 +227,90 @@ export declare const createStraightConnectionControllerFactory: (options: {
|
|
|
273
227
|
minPortOffset: number;
|
|
274
228
|
hasSourceArrow: boolean;
|
|
275
229
|
hasTargetArrow: boolean;
|
|
276
|
-
|
|
230
|
+
cycleSquareSide: number;
|
|
231
|
+
roundness: number;
|
|
232
|
+
}) => EdgeControllerFactory;
|
|
277
233
|
|
|
278
|
-
declare interface
|
|
234
|
+
declare interface CustomEdgeOptions {
|
|
279
235
|
readonly type: "custom";
|
|
280
|
-
readonly controllerFactory:
|
|
236
|
+
readonly controllerFactory: EdgeControllerFactory;
|
|
281
237
|
}
|
|
282
238
|
|
|
283
|
-
export declare class
|
|
284
|
-
private readonly
|
|
285
|
-
readonly
|
|
286
|
-
readonly
|
|
287
|
-
private readonly
|
|
288
|
-
private
|
|
289
|
-
private readonly
|
|
290
|
-
|
|
291
|
-
private readonly
|
|
292
|
-
private readonly
|
|
293
|
-
private readonly
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export declare interface DragOptions {
|
|
272
|
+
events?: {
|
|
273
|
+
onNodeDrag?: (payload: NodeDragPayload) => void;
|
|
274
|
+
onBeforeNodeDrag?: (payload: NodeDragPayload) => boolean;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
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"
|
|
318
290
|
}
|
|
319
291
|
|
|
320
|
-
declare class
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
private outcommingConnections;
|
|
328
|
-
private cycleConnections;
|
|
329
|
-
getAllNodes(): readonly string[];
|
|
330
|
-
getAllPorts(): readonly string[];
|
|
331
|
-
getAllConnections(): readonly string[];
|
|
332
|
-
addNode(nodeId: string, element: HTMLElement, x: number, y: number, centerFn: CenterFn): void;
|
|
333
|
-
hasNode(nodeId: string): boolean;
|
|
334
|
-
getNode(nodeId: string): NodePayload;
|
|
335
|
-
updateNodeCoords(nodeId: string, x: number, y: number): void;
|
|
336
|
-
updateConnectionController(connectionId: string, controller: ConnectionController): void;
|
|
337
|
-
removeNode(nodeId: string): void;
|
|
338
|
-
addPort(portId: string, element: HTMLElement, nodeId: string, centerFn: CenterFn, dir: number | null): void;
|
|
339
|
-
getPort(portId: string): PortPayload;
|
|
340
|
-
getPortNode(portId: string): string;
|
|
341
|
-
hasPort(portId: string): boolean;
|
|
342
|
-
removePort(portId: string): void;
|
|
343
|
-
addConnection(connectionId: string, fromPortId: string, toPortId: string, svgController: ConnectionController): void;
|
|
344
|
-
getConnection(connectionId: string): ConnectionPayload;
|
|
345
|
-
hasConnection(connectionId: string): boolean;
|
|
346
|
-
removeConnection(connectionId: string): void;
|
|
347
|
-
getPortIncomingConnections(portId: string): readonly string[];
|
|
348
|
-
getPortOutcomingConnections(portId: string): readonly string[];
|
|
349
|
-
getPortCycleConnections(portId: string): readonly string[];
|
|
350
|
-
getPortAdjacentConnections(portId: string): readonly string[];
|
|
351
|
-
getNodeIncomingConnections(nodeId: string): readonly string[];
|
|
352
|
-
getNodeOutcomingConnections(nodeId: string): readonly string[];
|
|
353
|
-
getNodeCycleConnections(nodeId: string): readonly string[];
|
|
354
|
-
getNodeAdjacentConnections(nodeId: string): readonly string[];
|
|
355
|
-
clear(): void;
|
|
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;
|
|
356
299
|
}
|
|
357
300
|
|
|
358
301
|
export declare class HtmlGraphBuilder {
|
|
359
302
|
private coreOptions;
|
|
303
|
+
private dragOptions;
|
|
360
304
|
private transformOptions;
|
|
361
305
|
private isDraggable;
|
|
362
306
|
private isTransformable;
|
|
363
307
|
setOptions(options: CoreOptions): HtmlGraphBuilder;
|
|
364
|
-
|
|
365
|
-
|
|
308
|
+
setUserDraggableNodes(options?: DragOptions): HtmlGraphBuilder;
|
|
309
|
+
setUserTransformableCanvas(options?: TransformOptions): HtmlGraphBuilder;
|
|
366
310
|
build(): Canvas;
|
|
367
311
|
}
|
|
368
312
|
|
|
369
|
-
declare type LayersMode = "
|
|
313
|
+
declare type LayersMode = "edges-on-top" | "nodes-on-top" | "edges-follow-node";
|
|
370
314
|
|
|
371
315
|
export declare type MarkNodePortRequest = HTMLElement | {
|
|
372
316
|
readonly element: HTMLElement;
|
|
@@ -382,19 +326,27 @@ export declare interface MarkPortRequest {
|
|
|
382
326
|
readonly direction?: number | null;
|
|
383
327
|
}
|
|
384
328
|
|
|
385
|
-
export declare interface
|
|
386
|
-
|
|
387
|
-
|
|
329
|
+
export declare interface NodeDragPayload {
|
|
330
|
+
readonly nodeId: string;
|
|
331
|
+
readonly element: HTMLElement;
|
|
332
|
+
readonly x: number;
|
|
333
|
+
readonly y: number;
|
|
388
334
|
}
|
|
389
335
|
|
|
390
|
-
declare interface
|
|
391
|
-
|
|
392
|
-
x: number;
|
|
393
|
-
y: number;
|
|
394
|
-
|
|
336
|
+
export declare interface NodeItem {
|
|
337
|
+
readonly id: string;
|
|
338
|
+
readonly x: number;
|
|
339
|
+
readonly y: number;
|
|
340
|
+
readonly element: HTMLElement;
|
|
395
341
|
}
|
|
396
342
|
|
|
397
|
-
export declare interface
|
|
343
|
+
export declare interface NodeResponse {
|
|
344
|
+
readonly x: number;
|
|
345
|
+
readonly y: number;
|
|
346
|
+
readonly element: HTMLElement;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export declare interface PatchViewportRequest {
|
|
398
350
|
scale?: number;
|
|
399
351
|
x?: number;
|
|
400
352
|
y?: number;
|
|
@@ -408,36 +360,6 @@ export declare interface PortPayload {
|
|
|
408
360
|
readonly direction: number | null;
|
|
409
361
|
}
|
|
410
362
|
|
|
411
|
-
declare class PublicGraphStore {
|
|
412
|
-
private readonly graphStore;
|
|
413
|
-
constructor(graphStore: GraphStore);
|
|
414
|
-
getNode(nodeId: string): {
|
|
415
|
-
x: number;
|
|
416
|
-
y: number;
|
|
417
|
-
} | null;
|
|
418
|
-
getPort(portId: string): {
|
|
419
|
-
nodeId: string;
|
|
420
|
-
} | null;
|
|
421
|
-
getConnection(connectionId: string): {
|
|
422
|
-
from: string;
|
|
423
|
-
to: string;
|
|
424
|
-
} | null;
|
|
425
|
-
getAllNodes(): readonly string[];
|
|
426
|
-
getAllPorts(): readonly string[];
|
|
427
|
-
getAllConnections(): readonly string[];
|
|
428
|
-
hasNode(nodeId: string): boolean;
|
|
429
|
-
hasPort(portId: string): boolean;
|
|
430
|
-
hasConnection(connectionId: string): boolean;
|
|
431
|
-
getPortIncomingConnections(portId: string): readonly string[];
|
|
432
|
-
getPortOutcomingConnections(portId: string): readonly string[];
|
|
433
|
-
getPortCycleConnections(portId: string): readonly string[];
|
|
434
|
-
getPortAdjacentConnections(portId: string): readonly string[];
|
|
435
|
-
getNodeIncomingConnections(nodeId: string): readonly string[];
|
|
436
|
-
getNodeOutcomingConnections(nodeId: string): readonly string[];
|
|
437
|
-
getNodeCycleConnections(nodeId: string): readonly string[];
|
|
438
|
-
getNodeAdjacentConnections(nodeId: string): readonly string[];
|
|
439
|
-
}
|
|
440
|
-
|
|
441
363
|
export declare class PublicViewportTransformer {
|
|
442
364
|
private readonly transformer;
|
|
443
365
|
constructor(transformer: ViewportTransformer);
|
|
@@ -463,30 +385,23 @@ export declare class PublicViewportTransformer {
|
|
|
463
385
|
getAbsScale(): number;
|
|
464
386
|
}
|
|
465
387
|
|
|
466
|
-
export declare
|
|
467
|
-
scale: number;
|
|
468
|
-
x?: number;
|
|
469
|
-
y?: number;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
export declare class StraightConnectionController implements ConnectionController {
|
|
388
|
+
export declare class StraightEdgeController implements EdgeController {
|
|
473
389
|
private readonly color;
|
|
474
390
|
private readonly width;
|
|
475
391
|
private readonly arrowLength;
|
|
476
392
|
private readonly arrowWidth;
|
|
477
393
|
private readonly minPortOffset;
|
|
478
|
-
private readonly hasSourceArrow;
|
|
479
|
-
private readonly hasTargetArrow;
|
|
480
394
|
readonly svg: SVGSVGElement;
|
|
481
395
|
private readonly group;
|
|
482
396
|
private readonly line;
|
|
483
397
|
private readonly sourceArrow;
|
|
484
398
|
private readonly targetArrow;
|
|
485
|
-
|
|
399
|
+
private readonly roundness;
|
|
400
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, minPortOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
486
401
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
487
402
|
}
|
|
488
403
|
|
|
489
|
-
declare interface
|
|
404
|
+
declare interface StraightEdgeOptions {
|
|
490
405
|
readonly type: "straight";
|
|
491
406
|
readonly color?: string;
|
|
492
407
|
readonly width?: number;
|
|
@@ -495,20 +410,85 @@ declare interface StraightConnectionOptions {
|
|
|
495
410
|
readonly minPortOffset?: number;
|
|
496
411
|
readonly hasSourceArrow?: boolean;
|
|
497
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;
|
|
498
437
|
}
|
|
499
438
|
|
|
500
|
-
|
|
439
|
+
declare interface UpdateConnectionRequest {
|
|
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(connection: AddEdgeRequest): UserDraggableNodesCanvas;
|
|
465
|
+
removeEdge(connectionId: string): UserDraggableNodesCanvas;
|
|
466
|
+
patchViewportState(request: PatchViewportRequest): UserDraggableNodesCanvas;
|
|
467
|
+
moveToNodes(nodeIds: readonly string[]): UserDraggableNodesCanvas;
|
|
468
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): UserDraggableNodesCanvas;
|
|
469
|
+
updateConnection(connectionId: string, request: UpdateConnectionRequest): 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;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export declare class UserTransformableCanvas implements Canvas {
|
|
501
480
|
private readonly canvas;
|
|
502
481
|
private readonly options?;
|
|
503
482
|
readonly transformation: PublicViewportTransformer;
|
|
504
|
-
readonly model: PublicGraphStore;
|
|
505
483
|
private element;
|
|
506
484
|
private isMoving;
|
|
507
485
|
private prevTouches;
|
|
486
|
+
private onTransform;
|
|
487
|
+
private onBeforeTransform;
|
|
508
488
|
private readonly isScalable;
|
|
509
489
|
private readonly isShiftable;
|
|
510
|
-
private readonly
|
|
511
|
-
private readonly
|
|
490
|
+
private readonly minViewScale;
|
|
491
|
+
private readonly maxViewScale;
|
|
512
492
|
private readonly wheelSensitivity;
|
|
513
493
|
private readonly onMouseDown;
|
|
514
494
|
private readonly onMouseMove;
|
|
@@ -518,72 +498,30 @@ export declare class TransformableCanvas implements Canvas {
|
|
|
518
498
|
private readonly onTouchMove;
|
|
519
499
|
private readonly onTouchEnd;
|
|
520
500
|
constructor(canvas: Canvas, options?: TransformOptions | undefined);
|
|
521
|
-
addNode(node: AddNodeRequest):
|
|
522
|
-
removeNode(nodeId: string):
|
|
523
|
-
markPort(port: MarkPortRequest):
|
|
524
|
-
|
|
525
|
-
unmarkPort(portId: string):
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
patchViewportState(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
clear(): TransformableCanvas;
|
|
537
|
-
attach(element: HTMLElement): TransformableCanvas;
|
|
538
|
-
detach(): TransformableCanvas;
|
|
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(connection: AddEdgeRequest): UserTransformableCanvas;
|
|
507
|
+
removeEdge(connectionId: string): UserTransformableCanvas;
|
|
508
|
+
patchViewportState(request: PatchViewportRequest): UserTransformableCanvas;
|
|
509
|
+
moveToNodes(nodeIds: readonly string[]): UserTransformableCanvas;
|
|
510
|
+
updateNodeCoordinates(nodeId: string, x: number, y: number): UserTransformableCanvas;
|
|
511
|
+
updateConnection(connectionId: string, request: UpdateConnectionRequest): UserTransformableCanvas;
|
|
512
|
+
moveNodeOnTop(nodeId: string): UserTransformableCanvas;
|
|
513
|
+
clear(): UserTransformableCanvas;
|
|
514
|
+
attach(element: HTMLElement): UserTransformableCanvas;
|
|
515
|
+
detach(): UserTransformableCanvas;
|
|
539
516
|
destroy(): void;
|
|
540
517
|
private getAverageTouch;
|
|
541
|
-
private checkNextScaleValid;
|
|
542
518
|
private setCursor;
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
export declare interface TransformOptions {
|
|
546
|
-
scale?: {
|
|
547
|
-
enabled?: boolean;
|
|
548
|
-
minContent?: number;
|
|
549
|
-
maxContent?: number;
|
|
550
|
-
wheelSensitivity?: number;
|
|
551
|
-
};
|
|
552
|
-
shift?: {
|
|
553
|
-
enabled?: boolean;
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
declare interface UpdateConnectionRequest {
|
|
558
|
-
readonly controller?: ConnectionController;
|
|
519
|
+
private moveViewport;
|
|
520
|
+
private scaleViewport;
|
|
559
521
|
}
|
|
560
522
|
|
|
561
523
|
declare class ViewportTransformer {
|
|
562
524
|
private state;
|
|
563
|
-
/**
|
|
564
|
-
* dx2 - traslate x
|
|
565
|
-
* dy2 - traslate y
|
|
566
|
-
*
|
|
567
|
-
* direct transform
|
|
568
|
-
* s1 0 dx1 1 0 dx2
|
|
569
|
-
* 0 s1 dy1 0 1 dy2
|
|
570
|
-
* 0 0 1 0 0 1
|
|
571
|
-
*
|
|
572
|
-
* [s, dx, dy] = [s1, s * dx2 + dx1, s * dy2 + dy1]
|
|
573
|
-
*/
|
|
574
|
-
applyShift(dx: number, dy: number): void;
|
|
575
|
-
/**
|
|
576
|
-
* s2 - scale
|
|
577
|
-
* cx - scale pivot x
|
|
578
|
-
* cy - scale pivot y
|
|
579
|
-
*
|
|
580
|
-
* s1 0 dx1 s2 0 (1 - s2) * cx
|
|
581
|
-
* 0 s1 dy1 0 s2 (1 - s2) * cy
|
|
582
|
-
* 0 0 1 0 0 1
|
|
583
|
-
*
|
|
584
|
-
* [s, dx, dy] = [s1 * s2, s1 * (1 - s2) * cx + dx1, s1 * (1 - s2) * cy + dy1]
|
|
585
|
-
*/
|
|
586
|
-
applyScale(s2: number, cx: number, cy: number): void;
|
|
587
525
|
getViewCoords(xa: number, ya: number): [number, number];
|
|
588
526
|
getViewScale(): number;
|
|
589
527
|
getAbsCoords(xv: number, yv: number): [number, number];
|