@html-graph/html-graph 3.3.0 → 3.5.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 -2
- package/dist/html-graph.d.ts +51 -39
- package/dist/html-graph.js +205 -199
- package/dist/html-graph.umd.cjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,8 +51,7 @@ function createNode({ name, x, y, frontPortId, backPortId }) {
|
|
|
51
51
|
|
|
52
52
|
const element = document.getElementById("canvas");
|
|
53
53
|
|
|
54
|
-
const canvas = new CanvasBuilder()
|
|
55
|
-
.setElement(element)
|
|
54
|
+
const canvas = new CanvasBuilder(element)
|
|
56
55
|
.setDefaults({
|
|
57
56
|
edges: {
|
|
58
57
|
shape: {
|
package/dist/html-graph.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ declare interface AddPortRequest {
|
|
|
42
42
|
readonly direction: number;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
declare interface
|
|
45
|
+
export declare interface BackgroundConfig {
|
|
46
46
|
readonly tileDimensions?: {
|
|
47
47
|
readonly width?: number;
|
|
48
48
|
readonly height?: number;
|
|
@@ -198,11 +198,11 @@ export declare class Canvas {
|
|
|
198
198
|
export declare class CanvasBuilder {
|
|
199
199
|
private element;
|
|
200
200
|
private canvasDefaults;
|
|
201
|
-
private
|
|
202
|
-
private
|
|
203
|
-
private
|
|
204
|
-
private
|
|
205
|
-
private
|
|
201
|
+
private dragConfig;
|
|
202
|
+
private transformConfig;
|
|
203
|
+
private backgroundConfig;
|
|
204
|
+
private connectablePortsConfig;
|
|
205
|
+
private virtualScrollConfig;
|
|
206
206
|
private hasDraggableNode;
|
|
207
207
|
private hasTransformableViewport;
|
|
208
208
|
private hasResizeReactiveNodes;
|
|
@@ -210,6 +210,11 @@ export declare class CanvasBuilder {
|
|
|
210
210
|
private hasUserConnectablePorts;
|
|
211
211
|
private boxRenderingTrigger;
|
|
212
212
|
private readonly window;
|
|
213
|
+
constructor(element?: HTMLElement);
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated
|
|
216
|
+
* use `new CanvasBuilder(element);` instead
|
|
217
|
+
*/
|
|
213
218
|
setElement(element: HTMLElement): CanvasBuilder;
|
|
214
219
|
/**
|
|
215
220
|
* specifies default values for graph entities
|
|
@@ -218,11 +223,11 @@ export declare class CanvasBuilder {
|
|
|
218
223
|
/**
|
|
219
224
|
* enables nodes draggable by user
|
|
220
225
|
*/
|
|
221
|
-
enableUserDraggableNodes(
|
|
226
|
+
enableUserDraggableNodes(config?: DraggableNodesConfig): CanvasBuilder;
|
|
222
227
|
/**
|
|
223
228
|
* enables viewport transformable by user
|
|
224
229
|
*/
|
|
225
|
-
enableUserTransformableViewport(
|
|
230
|
+
enableUserTransformableViewport(config?: ViewportTransformConfig): CanvasBuilder;
|
|
226
231
|
/**
|
|
227
232
|
* enables automatic edges update on node resize
|
|
228
233
|
*/
|
|
@@ -235,15 +240,15 @@ export declare class CanvasBuilder {
|
|
|
235
240
|
* enables built-in virtual scroll behavior, when only nodes and edges close
|
|
236
241
|
* to viewport are rendered
|
|
237
242
|
*/
|
|
238
|
-
enableVirtualScroll(
|
|
243
|
+
enableVirtualScroll(config: VirtualScrollConfig): CanvasBuilder;
|
|
239
244
|
/**
|
|
240
245
|
* enables built-in background rendering
|
|
241
246
|
*/
|
|
242
|
-
enableBackground(
|
|
247
|
+
enableBackground(config?: BackgroundConfig): CanvasBuilder;
|
|
243
248
|
/**
|
|
244
249
|
* enables edge creation by dragging one port to another
|
|
245
250
|
*/
|
|
246
|
-
enableUserConnectablePorts(
|
|
251
|
+
enableUserConnectablePorts(config?: ConnectablePortsConfig): CanvasBuilder;
|
|
247
252
|
/**
|
|
248
253
|
* builds final canvas
|
|
249
254
|
*/
|
|
@@ -296,14 +301,17 @@ export declare interface CanvasDefaults {
|
|
|
296
301
|
|
|
297
302
|
export declare type CenterFn = (width: number, height: number) => Point;
|
|
298
303
|
|
|
299
|
-
|
|
304
|
+
declare interface ConnectablePortsConfig {
|
|
300
305
|
readonly connectionTypeResolver?: ConnectionTypeResolver;
|
|
301
306
|
readonly connectionPreprocessor?: ConnectionPreprocessor;
|
|
302
307
|
readonly mouseDownEventVerifier?: MouseEventVerifier;
|
|
308
|
+
readonly mouseUpEventVerifier?: MouseEventVerifier;
|
|
303
309
|
readonly events?: {
|
|
304
310
|
readonly onAfterEdgeCreated?: (edgeId: unknown) => void;
|
|
305
311
|
};
|
|
306
312
|
}
|
|
313
|
+
export { ConnectablePortsConfig }
|
|
314
|
+
export { ConnectablePortsConfig as ConnectablePortsOptions }
|
|
307
315
|
|
|
308
316
|
export declare type ConnectionPreprocessor = (request: AddEdgeRequest) => AddEdgeRequest | null;
|
|
309
317
|
|
|
@@ -318,7 +326,7 @@ declare interface DotsRenderer {
|
|
|
318
326
|
readonly color?: string;
|
|
319
327
|
}
|
|
320
328
|
|
|
321
|
-
|
|
329
|
+
declare interface DraggableNodesConfig {
|
|
322
330
|
readonly moveOnTop?: boolean;
|
|
323
331
|
readonly mouse?: {
|
|
324
332
|
readonly dragCursor?: string | null;
|
|
@@ -331,6 +339,8 @@ export declare interface DragOptions {
|
|
|
331
339
|
readonly onNodeDragFinished?: (payload: NodeDragPayload) => void;
|
|
332
340
|
};
|
|
333
341
|
}
|
|
342
|
+
export { DraggableNodesConfig as DragOptions }
|
|
343
|
+
export { DraggableNodesConfig }
|
|
334
344
|
|
|
335
345
|
declare interface EdgePayload {
|
|
336
346
|
readonly from: unknown;
|
|
@@ -697,37 +707,13 @@ declare type StraightEdgeShapeConfig = {
|
|
|
697
707
|
readonly type: "straight";
|
|
698
708
|
} & StraightEdgeParams;
|
|
699
709
|
|
|
700
|
-
export declare interface TransformOptions {
|
|
701
|
-
readonly scale?: {
|
|
702
|
-
readonly mouseWheelSensitivity?: number;
|
|
703
|
-
readonly mouseWheelEventVerifier?: (event: WheelEvent) => boolean;
|
|
704
|
-
readonly wheelFinishTimeout?: number;
|
|
705
|
-
};
|
|
706
|
-
readonly shift?: {
|
|
707
|
-
readonly cursor?: string | null;
|
|
708
|
-
readonly mouseDownEventVerifier?: MouseEventVerifier;
|
|
709
|
-
readonly mouseUpEventVerifier?: MouseEventVerifier;
|
|
710
|
-
};
|
|
711
|
-
readonly transformPreprocessor?: TransformPreprocessorOption | TransformPreprocessorOption[];
|
|
712
|
-
readonly events?: {
|
|
713
|
-
readonly onTransformStarted?: () => void;
|
|
714
|
-
readonly onTransformFinished?: () => void;
|
|
715
|
-
readonly onBeforeTransformChange?: () => void;
|
|
716
|
-
readonly onTransformChange?: () => void;
|
|
717
|
-
readonly onResizeTransformStarted?: () => void;
|
|
718
|
-
readonly onResizeTransformFinished?: () => void;
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
|
|
722
710
|
export declare interface TransformPayload {
|
|
723
711
|
readonly scale: number;
|
|
724
712
|
readonly x: number;
|
|
725
713
|
readonly y: number;
|
|
726
714
|
}
|
|
727
715
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
declare type TransformPreprocessorOption = {
|
|
716
|
+
declare type TransformPreprocessorConfig = {
|
|
731
717
|
readonly type: "scale-limit";
|
|
732
718
|
readonly minContentScale?: number;
|
|
733
719
|
readonly maxContentScale?: number;
|
|
@@ -739,6 +725,8 @@ declare type TransformPreprocessorOption = {
|
|
|
739
725
|
readonly maxY?: number;
|
|
740
726
|
} | TransformPreprocessorFn;
|
|
741
727
|
|
|
728
|
+
export declare type TransformPreprocessorFn = (params: TransformPreprocessorParams) => TransformPayload;
|
|
729
|
+
|
|
742
730
|
export declare interface TransformPreprocessorParams {
|
|
743
731
|
readonly prevTransform: TransformPayload;
|
|
744
732
|
readonly nextTransform: TransformPayload;
|
|
@@ -854,7 +842,31 @@ declare class ViewportStore {
|
|
|
854
842
|
patchContentMatrix(matrix: PatchTransformRequest): void;
|
|
855
843
|
}
|
|
856
844
|
|
|
857
|
-
declare interface
|
|
845
|
+
declare interface ViewportTransformConfig {
|
|
846
|
+
readonly scale?: {
|
|
847
|
+
readonly mouseWheelSensitivity?: number;
|
|
848
|
+
readonly mouseWheelEventVerifier?: (event: WheelEvent) => boolean;
|
|
849
|
+
readonly wheelFinishTimeout?: number;
|
|
850
|
+
};
|
|
851
|
+
readonly shift?: {
|
|
852
|
+
readonly cursor?: string | null;
|
|
853
|
+
readonly mouseDownEventVerifier?: MouseEventVerifier;
|
|
854
|
+
readonly mouseUpEventVerifier?: MouseEventVerifier;
|
|
855
|
+
};
|
|
856
|
+
readonly transformPreprocessor?: TransformPreprocessorConfig | TransformPreprocessorConfig[];
|
|
857
|
+
readonly events?: {
|
|
858
|
+
readonly onTransformStarted?: () => void;
|
|
859
|
+
readonly onTransformFinished?: () => void;
|
|
860
|
+
readonly onBeforeTransformChange?: () => void;
|
|
861
|
+
readonly onTransformChange?: () => void;
|
|
862
|
+
readonly onResizeTransformStarted?: () => void;
|
|
863
|
+
readonly onResizeTransformFinished?: () => void;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
export { ViewportTransformConfig as TransformOptions }
|
|
867
|
+
export { ViewportTransformConfig }
|
|
868
|
+
|
|
869
|
+
export declare interface VirtualScrollConfig {
|
|
858
870
|
readonly nodeContainingRadius: {
|
|
859
871
|
readonly vertical: number;
|
|
860
872
|
readonly horizontal: number;
|