@html-graph/html-graph 3.1.0 → 3.2.0
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 +1 -0
- package/dist/html-graph.d.ts +78 -19
- package/dist/html-graph.js +439 -304
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/html-graph.d.ts
CHANGED
|
@@ -42,6 +42,15 @@ declare interface AddPortRequest {
|
|
|
42
42
|
readonly direction: number;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
declare interface BackgroundOptions {
|
|
46
|
+
readonly tileDimensions?: {
|
|
47
|
+
readonly width?: number;
|
|
48
|
+
readonly height?: number;
|
|
49
|
+
};
|
|
50
|
+
readonly renderer?: DotsRenderer | SVGElement;
|
|
51
|
+
readonly maxViewportScale?: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
export declare interface BezierEdgeParams {
|
|
46
55
|
readonly color?: string | undefined;
|
|
47
56
|
readonly width?: number | undefined;
|
|
@@ -79,13 +88,19 @@ declare type BezierEdgeShapeConfig = {
|
|
|
79
88
|
readonly type?: "bezier" | undefined;
|
|
80
89
|
} & BezierEdgeParams;
|
|
81
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Responsibility: provides graph rendering API for end user
|
|
93
|
+
*/
|
|
82
94
|
export declare class Canvas {
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated access element directly instead
|
|
97
|
+
*/
|
|
83
98
|
readonly element: HTMLElement;
|
|
84
99
|
private readonly graphStore;
|
|
85
100
|
private readonly viewportStore;
|
|
86
101
|
private readonly htmlView;
|
|
87
102
|
/**
|
|
88
|
-
* provides api for accessing graph
|
|
103
|
+
* provides api for accessing model of rendered graph
|
|
89
104
|
*/
|
|
90
105
|
readonly graph: Graph;
|
|
91
106
|
/**
|
|
@@ -110,9 +125,13 @@ export declare class Canvas {
|
|
|
110
125
|
private readonly onBeforeClear;
|
|
111
126
|
private readonly onBeforeDestroyEmitter;
|
|
112
127
|
readonly onBeforeDestroy: EventHandler<void>;
|
|
113
|
-
constructor(
|
|
128
|
+
constructor(
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated access element directly instead
|
|
131
|
+
*/
|
|
132
|
+
element: HTMLElement, graphStore: GraphStore, viewportStore: ViewportStore, htmlView: HtmlView, options: CanvasDefaults);
|
|
114
133
|
/**
|
|
115
|
-
* adds node
|
|
134
|
+
* adds new node
|
|
116
135
|
*/
|
|
117
136
|
addNode(request: AddNodeRequest): Canvas;
|
|
118
137
|
/**
|
|
@@ -120,42 +139,42 @@ export declare class Canvas {
|
|
|
120
139
|
*/
|
|
121
140
|
updateNode(nodeId: unknown, request?: UpdateNodeRequest): Canvas;
|
|
122
141
|
/**
|
|
123
|
-
* removes node
|
|
142
|
+
* removes specified node
|
|
124
143
|
* all the ports of node get unmarked
|
|
125
144
|
* all the edges adjacent to node get removed
|
|
126
145
|
*/
|
|
127
146
|
removeNode(nodeId: unknown): Canvas;
|
|
128
147
|
/**
|
|
129
|
-
* marks element as port
|
|
148
|
+
* marks specified element as a port for specified node
|
|
130
149
|
*/
|
|
131
150
|
markPort(request: MarkPortRequest): Canvas;
|
|
132
151
|
/**
|
|
133
|
-
* updates port and attached
|
|
152
|
+
* updates port and edges attached to it
|
|
134
153
|
*/
|
|
135
154
|
updatePort(portId: unknown, request?: UpdatePortRequest): Canvas;
|
|
136
155
|
/**
|
|
137
|
-
*
|
|
138
|
-
* all the edges adjacent to port get removed
|
|
156
|
+
* unmarks specified port
|
|
157
|
+
* all the edges adjacent to the port get removed
|
|
139
158
|
*/
|
|
140
159
|
unmarkPort(portId: unknown): Canvas;
|
|
141
160
|
/**
|
|
142
|
-
* adds edge
|
|
161
|
+
* adds new edge
|
|
143
162
|
*/
|
|
144
163
|
addEdge(request: AddEdgeRequest): Canvas;
|
|
145
164
|
/**
|
|
146
|
-
* updates edge
|
|
165
|
+
* updates specified edge
|
|
147
166
|
*/
|
|
148
167
|
updateEdge(edgeId: unknown, request?: UpdateEdgeRequest): Canvas;
|
|
149
168
|
/**
|
|
150
|
-
* removes edge
|
|
169
|
+
* removes specified edge
|
|
151
170
|
*/
|
|
152
171
|
removeEdge(edgeId: unknown): Canvas;
|
|
153
172
|
/**
|
|
154
|
-
* applies transformation for viewport
|
|
173
|
+
* applies transformation for viewport matrix
|
|
155
174
|
*/
|
|
156
175
|
patchViewportMatrix(request: PatchMatrixRequest): Canvas;
|
|
157
176
|
/**
|
|
158
|
-
* applies transformation for content
|
|
177
|
+
* applies transformation for content matrix
|
|
159
178
|
*/
|
|
160
179
|
patchContentMatrix(request: PatchMatrixRequest): Canvas;
|
|
161
180
|
/**
|
|
@@ -170,15 +189,20 @@ export declare class Canvas {
|
|
|
170
189
|
destroy(): void;
|
|
171
190
|
}
|
|
172
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Responsibility: Constructs canvas based on specified configuration
|
|
194
|
+
*/
|
|
173
195
|
export declare class CanvasBuilder {
|
|
174
196
|
private element;
|
|
175
197
|
private canvasDefaults;
|
|
176
198
|
private dragOptions;
|
|
177
199
|
private transformOptions;
|
|
200
|
+
private backgroundOptions;
|
|
178
201
|
private virtualScrollOptions;
|
|
179
202
|
private hasDraggableNode;
|
|
180
203
|
private hasTransformableViewport;
|
|
181
204
|
private hasResizeReactiveNodes;
|
|
205
|
+
private hasBackground;
|
|
182
206
|
private boxRenderingTrigger;
|
|
183
207
|
setElement(element: HTMLElement): CanvasBuilder;
|
|
184
208
|
/**
|
|
@@ -202,10 +226,15 @@ export declare class CanvasBuilder {
|
|
|
202
226
|
*/
|
|
203
227
|
enableBoxAreaRendering(trigger: EventSubject<RenderingBox>): CanvasBuilder;
|
|
204
228
|
enableVirtualScroll(options: VirtualScrollOptions): CanvasBuilder;
|
|
229
|
+
enableBackground(options?: BackgroundOptions): CanvasBuilder;
|
|
205
230
|
/**
|
|
206
231
|
* builds final canvas
|
|
207
232
|
*/
|
|
208
233
|
build(): Canvas;
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated
|
|
236
|
+
* CanvasBuilder should be single use object
|
|
237
|
+
*/
|
|
209
238
|
private reset;
|
|
210
239
|
}
|
|
211
240
|
|
|
@@ -254,6 +283,11 @@ declare type ConstantPriority = number;
|
|
|
254
283
|
|
|
255
284
|
declare type CustomPriority = PriorityFn;
|
|
256
285
|
|
|
286
|
+
declare interface DotsRenderer {
|
|
287
|
+
readonly radius?: number;
|
|
288
|
+
readonly color?: string;
|
|
289
|
+
}
|
|
290
|
+
|
|
257
291
|
export declare interface DragOptions {
|
|
258
292
|
readonly moveOnTop?: boolean;
|
|
259
293
|
readonly mouse?: {
|
|
@@ -290,6 +324,9 @@ export declare interface EdgeRenderPort {
|
|
|
290
324
|
readonly nodeId: unknown;
|
|
291
325
|
}
|
|
292
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Responsibility: Rendering edge via SVG
|
|
329
|
+
*/
|
|
293
330
|
export declare interface EdgeShape {
|
|
294
331
|
readonly svg: SVGSVGElement;
|
|
295
332
|
render(params: EdgeRenderParams): void;
|
|
@@ -299,15 +336,24 @@ declare type EdgeShapeConfig = BezierEdgeShapeConfig | StraightEdgeShapeConfig |
|
|
|
299
336
|
|
|
300
337
|
declare type EdgeShapeFactory = () => EdgeShape;
|
|
301
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Responsibility: Provides a way to trigger events
|
|
341
|
+
*/
|
|
302
342
|
export declare interface EventEmitter<T> {
|
|
303
343
|
emit(payload: T): void;
|
|
304
344
|
}
|
|
305
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Responsibility: Provides a way to handle events
|
|
348
|
+
*/
|
|
306
349
|
export declare interface EventHandler<T> {
|
|
307
350
|
subscribe(callback: (payload: T) => void): void;
|
|
308
351
|
unsubscribe(callback: (payload: T) => void): void;
|
|
309
352
|
}
|
|
310
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Responsibility: Connects events and event handlers
|
|
356
|
+
*/
|
|
311
357
|
export declare class EventSubject<T> implements EventEmitter<T>, EventHandler<T> {
|
|
312
358
|
private readonly callbacks;
|
|
313
359
|
subscribe(callback: (payload: T) => void): void;
|
|
@@ -316,7 +362,7 @@ export declare class EventSubject<T> implements EventEmitter<T>, EventHandler<T>
|
|
|
316
362
|
}
|
|
317
363
|
|
|
318
364
|
/**
|
|
319
|
-
*
|
|
365
|
+
* Responsibility: Provides access to graph model for end user
|
|
320
366
|
*/
|
|
321
367
|
export declare class Graph {
|
|
322
368
|
private readonly graphStore;
|
|
@@ -372,14 +418,14 @@ export declare interface GraphPort {
|
|
|
372
418
|
}
|
|
373
419
|
|
|
374
420
|
/**
|
|
375
|
-
*
|
|
421
|
+
* Responsibility: Stores stae of graph
|
|
376
422
|
*/
|
|
377
423
|
declare class GraphStore {
|
|
378
424
|
private readonly nodes;
|
|
379
425
|
private readonly ports;
|
|
380
426
|
private readonly edges;
|
|
381
|
-
private readonly
|
|
382
|
-
private readonly
|
|
427
|
+
private readonly incomingEdges;
|
|
428
|
+
private readonly outcomingEdges;
|
|
383
429
|
private readonly cycleEdges;
|
|
384
430
|
private readonly afterNodeAddedEmitter;
|
|
385
431
|
readonly onAfterNodeAdded: EventHandler<unknown>;
|
|
@@ -474,10 +520,17 @@ declare type HorizontalEdgeShapeConfig = {
|
|
|
474
520
|
readonly type: "horizontal";
|
|
475
521
|
} & HorizontalEdgeParams;
|
|
476
522
|
|
|
523
|
+
/**
|
|
524
|
+
* Responsibility: Library specific error to throw when unexpected action
|
|
525
|
+
* occured
|
|
526
|
+
*/
|
|
477
527
|
export declare class HtmlGraphError extends Error {
|
|
478
528
|
readonly name = "HtmlGraphError";
|
|
479
529
|
}
|
|
480
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Responsibility: Provides access to DOM modifications
|
|
533
|
+
*/
|
|
481
534
|
declare interface HtmlView {
|
|
482
535
|
attachNode(nodeId: unknown): void;
|
|
483
536
|
detachNode(nodeId: unknown): void;
|
|
@@ -535,6 +588,9 @@ declare interface PatchTransformRequest {
|
|
|
535
588
|
readonly y?: number;
|
|
536
589
|
}
|
|
537
590
|
|
|
591
|
+
/**
|
|
592
|
+
* Responsibility: Specifies point coordinates
|
|
593
|
+
*/
|
|
538
594
|
export declare interface Point {
|
|
539
595
|
readonly x: number;
|
|
540
596
|
readonly y: number;
|
|
@@ -548,6 +604,9 @@ declare interface PortPayload {
|
|
|
548
604
|
|
|
549
605
|
declare type Priority = ConstantPriority | IncrementalPriority | CustomPriority;
|
|
550
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Responsibility: Specifies how to determine Z-index of an entity in DOM
|
|
609
|
+
*/
|
|
551
610
|
export declare type PriorityFn = () => number;
|
|
552
611
|
|
|
553
612
|
export declare interface RenderingBox {
|
|
@@ -735,7 +794,7 @@ declare type VerticalEdgeShapeConfig = {
|
|
|
735
794
|
} & VerticalEdgeParams;
|
|
736
795
|
|
|
737
796
|
/**
|
|
738
|
-
*
|
|
797
|
+
* Responsibility: Provides access to viewport state for end user
|
|
739
798
|
*/
|
|
740
799
|
export declare class Viewport {
|
|
741
800
|
private readonly transformer;
|
|
@@ -747,7 +806,7 @@ export declare class Viewport {
|
|
|
747
806
|
}
|
|
748
807
|
|
|
749
808
|
/**
|
|
750
|
-
*
|
|
809
|
+
* Responsibility: Stores viewport transformation state
|
|
751
810
|
*/
|
|
752
811
|
declare class ViewportStore {
|
|
753
812
|
private viewportMatrix;
|