@html-graph/html-graph 0.0.49 → 0.0.51
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 +4 -4
- package/dist/main.d.ts +55 -35
- package/dist/main.js +615 -505
- package/dist/main.umd.cjs +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -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
|
|
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 a 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,7 +38,7 @@ 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
43
|
.setUserDraggableNodes()
|
|
44
44
|
.setUserTransformableCanvas()
|
|
@@ -81,7 +81,7 @@ canvas
|
|
|
81
81
|
|
|
82
82
|
Refer to [Examples](examples) for more.
|
|
83
83
|
|
|
84
|
-
## Run examples
|
|
84
|
+
## Run examples
|
|
85
85
|
|
|
86
86
|
Use node version >= 20
|
|
87
87
|
|
package/dist/main.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ declare interface BezierEdgeOptions {
|
|
|
58
58
|
readonly hasTargetArrow?: boolean;
|
|
59
59
|
readonly cycleRadius?: number;
|
|
60
60
|
readonly smallCycleRadius?: number;
|
|
61
|
+
readonly detourDistance?: number;
|
|
62
|
+
readonly detourDirection?: number;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
export declare interface Canvas {
|
|
@@ -111,7 +113,7 @@ export declare interface Canvas {
|
|
|
111
113
|
/**
|
|
112
114
|
* updates edge
|
|
113
115
|
*/
|
|
114
|
-
|
|
116
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): Canvas;
|
|
115
117
|
/**
|
|
116
118
|
* moves specified node on top
|
|
117
119
|
*/
|
|
@@ -145,7 +147,7 @@ export declare class CanvasCore implements Canvas {
|
|
|
145
147
|
private readonly apiOptions?;
|
|
146
148
|
readonly transformation: PublicViewportTransformer;
|
|
147
149
|
private readonly di;
|
|
148
|
-
private readonly
|
|
150
|
+
private readonly edgeControllerFactory;
|
|
149
151
|
constructor(apiOptions?: CoreOptions | undefined);
|
|
150
152
|
addNode(node: AddNodeRequest): CanvasCore;
|
|
151
153
|
moveNodeOnTop(nodeId: string): CanvasCore;
|
|
@@ -153,12 +155,12 @@ export declare class CanvasCore implements Canvas {
|
|
|
153
155
|
markPort(port: MarkPortRequest): CanvasCore;
|
|
154
156
|
updatePortEdges(portId: string): CanvasCore;
|
|
155
157
|
unmarkPort(portId: string): CanvasCore;
|
|
156
|
-
addEdge(
|
|
157
|
-
removeEdge(
|
|
158
|
+
addEdge(edge: AddEdgeRequest): CanvasCore;
|
|
159
|
+
removeEdge(edgeId: string): CanvasCore;
|
|
158
160
|
patchViewportState(request: PatchViewportRequest): CanvasCore;
|
|
159
161
|
moveToNodes(nodeIds: readonly string[]): CanvasCore;
|
|
160
162
|
updateNodeCoordinates(nodeId: string, x: number, y: number): CanvasCore;
|
|
161
|
-
|
|
163
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): CanvasCore;
|
|
162
164
|
clear(): CanvasCore;
|
|
163
165
|
attach(element: HTMLElement): CanvasCore;
|
|
164
166
|
detach(): CanvasCore;
|
|
@@ -188,12 +190,16 @@ export declare interface CoreOptions {
|
|
|
188
190
|
readonly ports?: {
|
|
189
191
|
/**
|
|
190
192
|
* specifies how to determine center of port
|
|
191
|
-
* center of port determines point to which
|
|
193
|
+
* center of port determines point to which edge attaches
|
|
192
194
|
*/
|
|
193
195
|
readonly centerFn?: CenterFn;
|
|
196
|
+
/**
|
|
197
|
+
* specifies default direction of port
|
|
198
|
+
*/
|
|
199
|
+
readonly direction?: number;
|
|
194
200
|
};
|
|
195
201
|
/**
|
|
196
|
-
*
|
|
202
|
+
*edges related behavior
|
|
197
203
|
*/
|
|
198
204
|
readonly edges?: EdgeOptions;
|
|
199
205
|
/**
|
|
@@ -217,6 +223,8 @@ export declare const createBezierEdgeControllerFactory: (options: {
|
|
|
217
223
|
hasTargetArrow: boolean;
|
|
218
224
|
cycleRadius: number;
|
|
219
225
|
smallCycleRadius: number;
|
|
226
|
+
detourDistance: number;
|
|
227
|
+
detourDirection: number;
|
|
220
228
|
}) => EdgeControllerFactory;
|
|
221
229
|
|
|
222
230
|
export declare const createStraightEdgeControllerFactory: (options: {
|
|
@@ -224,11 +232,13 @@ export declare const createStraightEdgeControllerFactory: (options: {
|
|
|
224
232
|
width: number;
|
|
225
233
|
arrowLength: number;
|
|
226
234
|
arrowWidth: number;
|
|
227
|
-
|
|
235
|
+
arrowOffset: number;
|
|
228
236
|
hasSourceArrow: boolean;
|
|
229
237
|
hasTargetArrow: boolean;
|
|
230
238
|
cycleSquareSide: number;
|
|
231
239
|
roundness: number;
|
|
240
|
+
detourDistance: number;
|
|
241
|
+
detourDirection: number;
|
|
232
242
|
}) => EdgeControllerFactory;
|
|
233
243
|
|
|
234
244
|
declare interface CustomEdgeOptions {
|
|
@@ -263,11 +273,29 @@ export declare class CycleSquareEdgeController implements EdgeController {
|
|
|
263
273
|
private readonly line;
|
|
264
274
|
private readonly arrow;
|
|
265
275
|
private readonly roundness;
|
|
266
|
-
private readonly
|
|
276
|
+
private readonly linePoints;
|
|
267
277
|
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, hasArrow: boolean, side: number, minPortOffset: number, roundness: number);
|
|
268
278
|
update(x: number, y: number, _width: number, _height: number, from: PortPayload): void;
|
|
269
279
|
}
|
|
270
280
|
|
|
281
|
+
export declare class DetourStraightEdgeController implements EdgeController {
|
|
282
|
+
private readonly color;
|
|
283
|
+
private readonly width;
|
|
284
|
+
private readonly arrowLength;
|
|
285
|
+
private readonly arrowWidth;
|
|
286
|
+
private readonly arrowOffset;
|
|
287
|
+
private readonly roundness;
|
|
288
|
+
readonly svg: SVGSVGElement;
|
|
289
|
+
private readonly group;
|
|
290
|
+
private readonly line;
|
|
291
|
+
private readonly sourceArrow;
|
|
292
|
+
private readonly targetArrow;
|
|
293
|
+
private readonly detourX;
|
|
294
|
+
private readonly detourY;
|
|
295
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number, detourDistance: number, detourDirection: number);
|
|
296
|
+
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
271
299
|
export declare interface DragOptions {
|
|
272
300
|
events?: {
|
|
273
301
|
onNodeDrag?: (payload: NodeDragPayload) => void;
|
|
@@ -286,16 +314,8 @@ declare type EdgeOptions = BezierEdgeOptions | StraightEdgeOptions | CustomEdgeO
|
|
|
286
314
|
|
|
287
315
|
export declare enum EdgeType {
|
|
288
316
|
Regular = "regular",
|
|
289
|
-
|
|
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;
|
|
317
|
+
PortCycle = "port-cycle",
|
|
318
|
+
NodeCycle = "node-cycle"
|
|
299
319
|
}
|
|
300
320
|
|
|
301
321
|
export declare class HtmlGraphBuilder {
|
|
@@ -315,7 +335,7 @@ declare type LayersMode = "edges-on-top" | "nodes-on-top" | "edges-follow-node";
|
|
|
315
335
|
export declare type MarkNodePortRequest = HTMLElement | {
|
|
316
336
|
readonly element: HTMLElement;
|
|
317
337
|
readonly centerFn?: CenterFn;
|
|
318
|
-
readonly direction?: number
|
|
338
|
+
readonly direction?: number;
|
|
319
339
|
};
|
|
320
340
|
|
|
321
341
|
export declare interface MarkPortRequest {
|
|
@@ -323,7 +343,7 @@ export declare interface MarkPortRequest {
|
|
|
323
343
|
readonly element: HTMLElement;
|
|
324
344
|
readonly nodeId: string;
|
|
325
345
|
readonly centerFn?: CenterFn;
|
|
326
|
-
readonly direction?: number
|
|
346
|
+
readonly direction?: number;
|
|
327
347
|
}
|
|
328
348
|
|
|
329
349
|
export declare interface NodeDragPayload {
|
|
@@ -352,12 +372,10 @@ export declare interface PatchViewportRequest {
|
|
|
352
372
|
y?: number;
|
|
353
373
|
}
|
|
354
374
|
|
|
355
|
-
declare type Point = [number, number];
|
|
356
|
-
|
|
357
375
|
export declare interface PortPayload {
|
|
358
376
|
readonly element: HTMLElement;
|
|
359
377
|
readonly centerFn: CenterFn;
|
|
360
|
-
readonly direction: number
|
|
378
|
+
readonly direction: number;
|
|
361
379
|
}
|
|
362
380
|
|
|
363
381
|
export declare class PublicViewportTransformer {
|
|
@@ -390,14 +408,14 @@ export declare class StraightEdgeController implements EdgeController {
|
|
|
390
408
|
private readonly width;
|
|
391
409
|
private readonly arrowLength;
|
|
392
410
|
private readonly arrowWidth;
|
|
393
|
-
private readonly
|
|
411
|
+
private readonly arrowOffset;
|
|
412
|
+
private readonly roundness;
|
|
394
413
|
readonly svg: SVGSVGElement;
|
|
395
414
|
private readonly group;
|
|
396
415
|
private readonly line;
|
|
397
416
|
private readonly sourceArrow;
|
|
398
417
|
private readonly targetArrow;
|
|
399
|
-
|
|
400
|
-
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, minPortOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
418
|
+
constructor(color: string, width: number, arrowLength: number, arrowWidth: number, arrowOffset: number, hasSourceArrow: boolean, hasTargetArrow: boolean, roundness: number);
|
|
401
419
|
update(x: number, y: number, width: number, height: number, from: PortPayload, to: PortPayload): void;
|
|
402
420
|
}
|
|
403
421
|
|
|
@@ -407,11 +425,13 @@ declare interface StraightEdgeOptions {
|
|
|
407
425
|
readonly width?: number;
|
|
408
426
|
readonly arrowLength?: number;
|
|
409
427
|
readonly arrowWidth?: number;
|
|
410
|
-
readonly
|
|
428
|
+
readonly arrowOffset?: number;
|
|
411
429
|
readonly hasSourceArrow?: boolean;
|
|
412
430
|
readonly hasTargetArrow?: boolean;
|
|
413
431
|
readonly cycleSquareSide?: number;
|
|
414
432
|
readonly roundness?: number;
|
|
433
|
+
readonly detourDistance?: number;
|
|
434
|
+
readonly detourDirection?: number;
|
|
415
435
|
}
|
|
416
436
|
|
|
417
437
|
export declare interface TransformOptions {
|
|
@@ -436,7 +456,7 @@ export declare interface TransformPayload {
|
|
|
436
456
|
readonly y: number;
|
|
437
457
|
}
|
|
438
458
|
|
|
439
|
-
declare interface
|
|
459
|
+
export declare interface UpdateEdgeRequest {
|
|
440
460
|
readonly controller?: EdgeController;
|
|
441
461
|
}
|
|
442
462
|
|
|
@@ -461,12 +481,12 @@ export declare class UserDraggableNodesCanvas implements Canvas {
|
|
|
461
481
|
markPort(port: MarkPortRequest): UserDraggableNodesCanvas;
|
|
462
482
|
updatePortEdges(portId: string): UserDraggableNodesCanvas;
|
|
463
483
|
unmarkPort(portId: string): UserDraggableNodesCanvas;
|
|
464
|
-
addEdge(
|
|
465
|
-
removeEdge(
|
|
484
|
+
addEdge(edge: AddEdgeRequest): UserDraggableNodesCanvas;
|
|
485
|
+
removeEdge(edgeId: string): UserDraggableNodesCanvas;
|
|
466
486
|
patchViewportState(request: PatchViewportRequest): UserDraggableNodesCanvas;
|
|
467
487
|
moveToNodes(nodeIds: readonly string[]): UserDraggableNodesCanvas;
|
|
468
488
|
updateNodeCoordinates(nodeId: string, x: number, y: number): UserDraggableNodesCanvas;
|
|
469
|
-
|
|
489
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserDraggableNodesCanvas;
|
|
470
490
|
moveNodeOnTop(nodeId: string): UserDraggableNodesCanvas;
|
|
471
491
|
clear(): UserDraggableNodesCanvas;
|
|
472
492
|
attach(element: HTMLElement): UserDraggableNodesCanvas;
|
|
@@ -503,12 +523,12 @@ export declare class UserTransformableCanvas implements Canvas {
|
|
|
503
523
|
markPort(port: MarkPortRequest): UserTransformableCanvas;
|
|
504
524
|
updatePortEdges(portId: string): UserTransformableCanvas;
|
|
505
525
|
unmarkPort(portId: string): UserTransformableCanvas;
|
|
506
|
-
addEdge(
|
|
507
|
-
removeEdge(
|
|
526
|
+
addEdge(edge: AddEdgeRequest): UserTransformableCanvas;
|
|
527
|
+
removeEdge(edgeId: string): UserTransformableCanvas;
|
|
508
528
|
patchViewportState(request: PatchViewportRequest): UserTransformableCanvas;
|
|
509
529
|
moveToNodes(nodeIds: readonly string[]): UserTransformableCanvas;
|
|
510
530
|
updateNodeCoordinates(nodeId: string, x: number, y: number): UserTransformableCanvas;
|
|
511
|
-
|
|
531
|
+
updateEdge(edgeId: string, request: UpdateEdgeRequest): UserTransformableCanvas;
|
|
512
532
|
moveNodeOnTop(nodeId: string): UserTransformableCanvas;
|
|
513
533
|
clear(): UserTransformableCanvas;
|
|
514
534
|
attach(element: HTMLElement): UserTransformableCanvas;
|