@visuallyjs/browser-ui 1.0.3 → 1.1.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.
Files changed (135) hide show
  1. package/js/visuallyjs.browser-ui.cjs.js +57 -57
  2. package/js/visuallyjs.browser-ui.esm.js +57 -57
  3. package/package.json +1 -1
  4. package/types/browser-ui/browser-ui.d.ts +4 -7
  5. package/types/browser-ui/browser-util.d.ts +1 -0
  6. package/types/browser-ui/browser-visuallyjs-instance.d.ts +12 -6
  7. package/types/browser-ui/components/controls/css-classes.d.ts +24 -0
  8. package/types/browser-ui/components/inspector/color-picker-tag.d.ts +6 -0
  9. package/types/browser-ui/components/palette/palette.d.ts +1 -0
  10. package/types/browser-ui/connector-editors/editor-base.d.ts +0 -1
  11. package/types/browser-ui/connector-editors/util.d.ts +0 -2
  12. package/types/browser-ui/connector-editors-bezier/css-constants.d.ts +0 -12
  13. package/types/browser-ui/constants.d.ts +4 -10
  14. package/types/browser-ui/css-constants.d.ts +57 -8
  15. package/types/browser-ui/definitions.d.ts +27 -6
  16. package/types/browser-ui/dialogs/binder.d.ts +0 -11
  17. package/types/browser-ui/edge-handler-base.d.ts +9 -16
  18. package/types/browser-ui/edge-input-handler.d.ts +3 -10
  19. package/types/browser-ui/edge-mappings/flowchart-basic.d.ts +2 -1
  20. package/types/browser-ui/element-drag-handler-2.d.ts +0 -3
  21. package/types/browser-ui/icons/definitions.d.ts +20 -0
  22. package/types/browser-ui/pan-zoom-options.d.ts +10 -21
  23. package/types/browser-ui/pan-zoom.d.ts +29 -114
  24. package/types/browser-ui/paper-renderer/definitions.d.ts +2 -0
  25. package/types/browser-ui/paper-renderer/paper.d.ts +1 -0
  26. package/types/browser-ui/plugins/background/background-options.d.ts +4 -0
  27. package/types/browser-ui/plugins/background/tiled-background.d.ts +2 -0
  28. package/types/browser-ui/plugins/browser-ui-plugin.d.ts +6 -1
  29. package/types/browser-ui/positioning-and-sizing-utils.d.ts +21 -1
  30. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +26 -11
  31. package/types/browser-ui/shape-library/shape-library.d.ts +14 -3
  32. package/types/browser-ui/shape-library/shapes-basic.d.ts +1 -1
  33. package/types/browser-ui/shape-library/shapes-flowchart.d.ts +1 -1
  34. package/types/browser-ui/surface-renderer/anim/definitions.d.ts +13 -4
  35. package/types/browser-ui/surface-renderer/anim/path-transport.d.ts +0 -1
  36. package/types/browser-ui/surface-renderer/definitions.d.ts +14 -3
  37. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +8 -2
  38. package/types/browser-ui/surface-renderer/diagrams/diagram-link.d.ts +2 -0
  39. package/types/browser-ui/surface-renderer/diagrams/diagram-tools.d.ts +4 -0
  40. package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +4 -1
  41. package/types/browser-ui/surface-renderer/diagrams/index.d.ts +4 -2
  42. package/types/browser-ui/surface-renderer/diagrams/mediator.d.ts +14 -0
  43. package/types/browser-ui/surface-renderer/plugins/controls/controls-plugin.d.ts +2 -0
  44. package/types/browser-ui/surface-renderer/plugins/export-controls/export-controls-plugin.d.ts +3 -1
  45. package/types/browser-ui/surface-renderer/plugins/index.d.ts +1 -0
  46. package/types/browser-ui/surface-renderer/plugins/list-manager/index.d.ts +1 -0
  47. package/types/browser-ui/surface-renderer/plugins/list-manager/list-manager-plugin.d.ts +34 -0
  48. package/types/browser-ui/surface-renderer/plugins/palette/palette-plugin.d.ts +2 -0
  49. package/types/browser-ui/surface-renderer/plugins/pan-buttons/pan-buttons-plugin.d.ts +1 -2
  50. package/types/browser-ui/surface-renderer/plugins/resizing-tools/definitions.d.ts +9 -0
  51. package/types/browser-ui/surface-renderer/plugins/snaplines/snaplines-plugin.d.ts +12 -0
  52. package/types/browser-ui/surface-renderer/plugins/vertex-drawing/vertex-drawing-plugin.d.ts +0 -2
  53. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +5 -2
  54. package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -1
  55. package/types/browser-ui/surface-renderer/surface-render-options.d.ts +0 -30
  56. package/types/browser-ui/surface-renderer/surface.d.ts +47 -38
  57. package/types/browser-ui/svg-export/definitions.d.ts +12 -0
  58. package/types/browser-ui/svg-export/image-exporter.d.ts +2 -0
  59. package/types/browser-ui/svg-export/svg-exporter.d.ts +3 -0
  60. package/types/browser-ui/templating/custom-tag-definition.d.ts +1 -2
  61. package/types/browser-ui/util.d.ts +2 -0
  62. package/types/charts/bar-and-column/bar-plot.d.ts +2 -0
  63. package/types/charts/base-chart.d.ts +62 -6
  64. package/types/charts/chart-exporter.d.ts +3 -0
  65. package/types/charts/datasource.d.ts +11 -0
  66. package/types/charts/definitions.d.ts +10 -0
  67. package/types/charts/domain_scale_utilities.d.ts +4 -0
  68. package/types/charts/legend.d.ts +2 -0
  69. package/types/charts/pie/pie-chart.d.ts +2 -0
  70. package/types/charts/sankey/sankey.d.ts +1 -0
  71. package/types/charts/scatter/definitions.d.ts +1 -0
  72. package/types/charts/series/array-based-series.d.ts +2 -0
  73. package/types/charts/series/definitions.d.ts +1 -0
  74. package/types/charts/series/series.d.ts +2 -0
  75. package/types/charts/series-based-chart.d.ts +1 -0
  76. package/types/charts/tooltip.d.ts +7 -2
  77. package/types/charts/util.d.ts +10 -3
  78. package/types/core/autosaver.d.ts +2 -1
  79. package/types/core/csv-loader.d.ts +8 -2
  80. package/types/core/event-constants.d.ts +44 -2
  81. package/types/core/geom.d.ts +1 -0
  82. package/types/core/io.d.ts +31 -7
  83. package/types/core/layout/abstract-layout.d.ts +1 -0
  84. package/types/core/layout/grid/definitions.d.ts +10 -19
  85. package/types/core/layout/grid/grid-layout.d.ts +2 -2
  86. package/types/core/layout/hierarchy/util.d.ts +1 -7
  87. package/types/core/magnetizer.d.ts +1 -0
  88. package/types/core/model/anchor.d.ts +1 -0
  89. package/types/core/model/graph.d.ts +3 -11
  90. package/types/core/model/group-template.d.ts +15 -0
  91. package/types/core/params.d.ts +2 -2
  92. package/types/core/renderer.d.ts +3 -0
  93. package/types/core/rtree/rtree.d.ts +15 -0
  94. package/types/core/selection.d.ts +2 -6
  95. package/types/core/templates/core.d.ts +1 -1
  96. package/types/core/toolkit.d.ts +30 -10
  97. package/types/core/undo-redo/undo-redo.d.ts +0 -22
  98. package/types/core/util.d.ts +4 -1
  99. package/types/ui/common/overlay.d.ts +3 -1
  100. package/types/ui/common/paint-style.d.ts +2 -0
  101. package/types/ui/connector-orthogonal/operations.d.ts +1 -18
  102. package/types/ui/connector-orthogonal/utils.d.ts +0 -6
  103. package/types/ui/connector-straight/straight-connector.d.ts +2 -5
  104. package/types/ui/core/component/component.d.ts +1 -4
  105. package/types/ui/core/connector/connection-impl.d.ts +1 -0
  106. package/types/ui/core/connector/connections.d.ts +0 -29
  107. package/types/ui/core/connector/straight-segment.d.ts +0 -6
  108. package/types/ui/core/constants.d.ts +0 -4
  109. package/types/ui/core/core-events.d.ts +5 -3
  110. package/types/ui/core/core.d.ts +19 -21
  111. package/types/ui/core/defaults.d.ts +43 -9
  112. package/types/ui/core/definitions.d.ts +39 -20
  113. package/types/ui/core/event-constants.d.ts +1 -0
  114. package/types/ui/core/factory/continuous-anchors.d.ts +0 -6
  115. package/types/ui/core/grid-profile.d.ts +3 -1
  116. package/types/ui/core/magnetize-profile.d.ts +1 -3
  117. package/types/ui/core/overlay/overlay.d.ts +2 -0
  118. package/types/ui/core/params.d.ts +8 -99
  119. package/types/ui/core/router/default-router.d.ts +89 -18
  120. package/types/ui/core/router/index.d.ts +0 -1
  121. package/types/ui/core/router/router-utils.d.ts +0 -24
  122. package/types/ui/core/router/router.d.ts +29 -20
  123. package/types/ui/core/type-descriptors.d.ts +2 -0
  124. package/types/ui/core/ui-model.d.ts +3 -0
  125. package/types/ui/core/view/edge-options.d.ts +1 -0
  126. package/types/ui/core/view/events.d.ts +22 -0
  127. package/types/ui/core/view/node-or-port-options.d.ts +6 -0
  128. package/types/ui/core/view/vertex-options.d.ts +2 -0
  129. package/types/ui/core/viewport.d.ts +7 -1
  130. package/types/ui/plugins/definitions.d.ts +6 -1
  131. package/types/ui/plugins/plugins.d.ts +4 -0
  132. package/types/ui/property-mappings/definitions.d.ts +6 -0
  133. package/types/ui/util/util.d.ts +3 -16
  134. package/types/version.d.ts +1 -1
  135. package/types/ui/core/router/base-router.d.ts +0 -100
@@ -1,13 +1,97 @@
1
+ import { AnchorPlacement } from "../../../core";
2
+ import { ConnectionDetachedParams } from "../callbacks";
3
+ import { RedrawResult, Router } from "./router";
1
4
  import { Connection } from "../connector/connection-impl";
2
- import { BaseRouter, BaseRouterOptions } from "./base-router";
3
- import { Connector } from "../../common";
4
- import { ConnectorComputeParams } from "../connector/abstract-connector";
5
- import { Geometry, AnchorPlacement } from "../../../core";
6
5
  import { UICore } from "../core";
6
+ import { ViewportElement } from "../viewport";
7
7
  /**
8
+ * Default router options.
8
9
  * @internal
9
10
  */
10
- export interface DefaultRouterOptions extends BaseRouterOptions {
11
+ export interface DefaultRouterOptions {
12
+ gridCellSize?: number;
13
+ avoidVertices?: boolean;
14
+ vertexBuffer?: number;
15
+ vertexBorder?: number;
16
+ }
17
+ /**
18
+ * The default router paints edges with anchor computation. This class manages continuous anchors and offers A* vertex avoidance.
19
+ * @internal
20
+ */
21
+ export declare class DefaultRouter<EL> implements Router<EL> {
22
+ instance: UICore<any, any>;
23
+ private _timestamp;
24
+ private $anchorLists;
25
+ private _avoidVertices;
26
+ private _gridCellSize;
27
+ private _vertexBuffer;
28
+ private _vertexBorder;
29
+ private _orientationCache;
30
+ private _orientationCacheTimestamp;
31
+ private _grid;
32
+ static type: string;
33
+ constructor(instance: UICore<any, any>, options?: DefaultRouterOptions);
34
+ $computePath(connection: Connection<any>, timestamp: string): void;
35
+ $connectionDetachedFromElement(connection: Connection<EL>, el: ViewportElement<any>): void;
36
+ /**
37
+ * Notification that a connection was removed. We remove it from continuous anchor lists.
38
+ * @param params
39
+ * @internal
40
+ */
41
+ $connectionRemoved(params: ConnectionDetachedParams<any>): void;
42
+ /**
43
+ * Called by the UI when it has unloaded an element from the canvas. We cleanup the element from continuous anchor lists.
44
+ * @param el
45
+ */
46
+ $elementRemoved(el: ViewportElement<EL>): void;
47
+ /**
48
+ * Redraws a list of connections. Does not update element positions.
49
+ * @internal
50
+ */
51
+ $redrawConnections(conns: Array<Connection<EL>>, timestamp?: string): RedrawResult;
52
+ /**
53
+ * Reset the router. Called by the UI's own reset method.
54
+ */
55
+ $reset(): void;
56
+ private _removeConnection;
57
+ /**
58
+ * Computes the position for an anchor that is neither floating nor continuous, or is currently fixed. This case covers what was previously both DynamicAnchor and Anchor, since those concepts have now been folded into a single concept - any given anchor has one or more locations.
59
+ * @param anchor
60
+ * @param params
61
+ */
62
+ private _defaultAnchorCompute;
63
+ private _placeContinuousAnchors;
64
+ private _updateContinuousAnchorList;
65
+ /**
66
+ * Remove the given anchor from the continuous anchor lists. This method is invoked when a connection is detached.
67
+ * @param elementId
68
+ * @param anchor
69
+ * @private
70
+ * @internal
71
+ */
72
+ private _removeAnchorFromAnchorLists;
73
+ private _computeAnchorLocation;
74
+ private _doComputePath;
75
+ private _doUpdatePath;
76
+ /**
77
+ * Default path compute uses the connector's path computation.
78
+ * @param connection
79
+ * @param c
80
+ * @param params
81
+ * @private
82
+ */
83
+ private _doComputePathDefault;
84
+ /**
85
+ * A* path compute uses A* path finder algorithm
86
+ * @param connection
87
+ * @param c
88
+ * @param params
89
+ * @param timestamp
90
+ * @private
91
+ */
92
+ private _doComputePathAStar;
93
+ private _calculateOrientation;
94
+ private _anchorSelector;
11
95
  }
12
96
  /**
13
97
  * Adjust the given anchor placement for the specified gap amount.
@@ -23,16 +107,3 @@ export declare function _adjustForGap(pos: AnchorPlacement, gap: number): {
23
107
  x: number;
24
108
  y: number;
25
109
  };
26
- /**
27
- * @internal
28
- */
29
- export declare class DefaultRouter<EL> extends BaseRouter<EL> {
30
- instance: UICore<EL, any>;
31
- static type: string;
32
- protected _timestamp: string;
33
- constructor(instance: UICore<EL, any>, options?: DefaultRouterOptions);
34
- _doComputePath(connection: Connection<EL>, c: Connector, params: ConnectorComputeParams, timestamp: string): Geometry;
35
- _doUpdatePath(connection: Connection<EL>, c: Connector, params: ConnectorComputeParams, timestamp: string, sourceMoved: boolean, targetMoved: boolean): Geometry;
36
- private _doComputePathDefault;
37
- private _doComputePathAStar;
38
- }
@@ -1,5 +1,4 @@
1
1
  export * from './router';
2
2
  export * from './router-utils';
3
- export * from './base-router';
4
3
  export * from './default-router';
5
4
  export * from './astar-path-finder';
@@ -1,6 +1,5 @@
1
1
  import { SortFunction } from "../../util";
2
2
  import { ViewportElement } from "../viewport";
3
- import { Connection } from "../connector/connection-impl";
4
3
  import { PointXY, RectangleXY, Size, AnchorPlacement } from "../../../core";
5
4
  import { AnchorComputeParams, AnchorRecord, Face, LightweightAnchor, LightweightContinuousAnchor } from "../../common";
6
5
  /**
@@ -73,17 +72,6 @@ export declare function _isContinuousAnchor(a: LightweightAnchor): a is Lightwei
73
72
  * @param anchor
74
73
  */
75
74
  export declare function _getCurrentAnchorLocation(anchor: LightweightAnchor): [number, AnchorRecord];
76
- /**
77
- * Create a padded rectangle around the given point. The point lies on one edge of the resulting rectangle: it is not
78
- * in the center. The rectangle represents whitespace around some anchor point but does not spill over into the vertex
79
- * on which the anchor resides.
80
- * @param point
81
- * @param face
82
- * @param size
83
- * @internal
84
- */
85
- export declare function _padPointForFace(point: PointXY, face: Face, size: number): RectangleXY;
86
- export declare function _padPointForFace2(point: PointXY, face: Face, size: number): RectangleXY;
87
75
  /**
88
76
  * Create a padded rectangle around the given point. The point lies on one edge of the resulting rectangle: it is not
89
77
  * in the center. The rectangle represents whitespace around some anchor point but does not spill over into the vertex
@@ -96,18 +84,6 @@ export declare function _padPointForFace2(point: PointXY, face: Face, size: numb
96
84
  * @internal
97
85
  */
98
86
  export declare function _padPoint(point: PointXY, ox: number, oy: number, mainAxisSize: number, otherAxisSize: number): RectangleXY;
99
- /**
100
- * For the given anchor point, constructs a padded box around it to use to check if the anchor is too
101
- * close to some other element, and a different anchor location might be preferred. If the connection has no
102
- * connector registered it means it is still being created, so we just pass back a 1x1 rectangle with the given point
103
- * as origin.
104
- * @param p
105
- * @param ox
106
- * @param oy
107
- * @param connection
108
- * @internal
109
- */
110
- export declare function _padAnchorPoint(p: PointXY, ox: -1 | 0 | 1, oy: -1 | 0 | 1, connection: Connection<any>): RectangleXY;
111
87
  /**
112
88
  * @internal
113
89
  * @param loc
@@ -1,30 +1,39 @@
1
1
  import { Connection } from '../connector/connection-impl';
2
- import { AnchorComputeParams, LightweightAnchor, AnchorSpec } from "../../common";
3
- import { PointXY, AnchorPlacement, Edge } from "../../../core";
4
2
  import { ConnectionDetachedParams } from "../callbacks";
5
3
  import { ViewportElement } from "../viewport";
6
- export interface RedrawResult {
7
- c: Set<Connection<any>>;
8
- }
9
- export declare function EmptyRedrawResult(): RedrawResult;
10
- export interface Router<EL, A> {
11
- reset(): void;
12
- elementRemoved(el: ViewportElement<EL>): void;
13
- $redrawConnection(edge: Edge, timestamp?: string): RedrawResult;
14
- $redrawEveryConnection(): RedrawResult;
15
- $redraw(viewportElement: ViewportElement<EL>, timestamp?: string, offsetToUI?: PointXY): RedrawResult;
16
- computePath(connection: Connection<EL>, timestamp: string): void;
17
- computeAnchorLocation(anchor: A, params: AnchorComputeParams): AnchorPlacement;
18
- prepareAnchor(params: AnchorSpec | Array<AnchorSpec>): A;
19
- setConnectionAnchors(conn: Connection<EL>, anchors: [A, A]): void;
20
- $setCurrentLocation(anchor: LightweightAnchor, idx: number, connection?: Connection<any>): void;
4
+ export type RedrawResult = Set<Connection<any>>;
5
+ export declare function EmptyRedrawResult(): Set<Connection<any>>;
6
+ export interface Router<EL> {
7
+ /**
8
+ * Called by the UI's own reset() method.
9
+ */
10
+ $reset(): void;
21
11
  /**
22
- * Notification that a connection was detached from some element. The connection itself
23
- * is not being removed; it is being reconnected elsewhere.
12
+ * Called by the UI when it has unloaded an element from the canvas.
13
+ * @param el
14
+ */
15
+ $elementRemoved(el: ViewportElement<EL>): void;
16
+ /**
17
+ * Redraw a list of connections
18
+ * @param c
19
+ * @param timestamp
20
+ */
21
+ $redrawConnections(c: Array<Connection<any>>, timestamp?: string): RedrawResult;
22
+ /**
23
+ * Called by the UI when it wants to paint a connection.
24
+ * @param connection
25
+ * @param timestamp
26
+ */
27
+ $computePath(connection: Connection<EL>, timestamp: string): void;
28
+ /**
29
+ * Notification from the UI that a connection was detached from some element. The connection itself is not being removed; it is being reconnected elsewhere.
24
30
  * @param connection
25
31
  * @param el
26
- * @param index
27
32
  */
28
33
  $connectionDetachedFromElement(connection: Connection<EL>, el: ViewportElement<any>): void;
34
+ /**
35
+ * Called by the UI when a connection has been removed the canvas.
36
+ * @param params
37
+ */
29
38
  $connectionRemoved(params: ConnectionDetachedParams): void;
30
39
  }
@@ -1,6 +1,8 @@
1
1
  import { AnchorSpec, OverlaySpec, PaintStyle, ConnectorSpec, FullOverlaySpec } from "../common";
2
2
  /**
3
3
  * Base interface for vertex/edge types. This interface contains parameters that are common between the two types, and is shared by internal methods and public methods.
4
+ * @group UI
5
+ * @category Definitions
4
6
  */
5
7
  export interface TypeDescriptorBase {
6
8
  /**
@@ -23,6 +23,7 @@ export declare function mergeWithParents<T extends {
23
23
  }>(type: Array<string> | string, map: Record<string, T>): any;
24
24
  /**
25
25
  * A function that returns an anchor definition from the given element, position on the element, and vertex.
26
+ * @group UI
26
27
  */
27
28
  export type AnchorPositionFinder<EL> = (el: EL, pos: PointXY, vertex: Vertex, vertexDefinition: VertexMapping<any, any>) => ObjectAnchorSpec | null;
28
29
  /**
@@ -53,6 +54,8 @@ export declare class UIModel<EL> {
53
54
  }
54
55
  /**
55
56
  * Return value from the UI's getObjectInfo method.
57
+ * @group UI
58
+ * @category Definitions
56
59
  */
57
60
  export interface UIObjectInfo<T, E> {
58
61
  el: E;
@@ -7,6 +7,7 @@ import { LineStyle } from "../core";
7
7
  import { FontSpec } from "../../../browser-ui";
8
8
  /**
9
9
  * Definition of the function you can provide as `deleteConfirm` on an edge definition. VisuallyJs gives you the edge to be possibly deleted and the pointer event that instigated the deletion. If you wish to delete the edge you must invoke the `proceed()` function.
10
+ * @group Edges
10
11
  */
11
12
  export type EdgeDeleteConfirmationFunction = (params: {
12
13
  edge: Edge;
@@ -5,15 +5,19 @@ import { Connection } from "../connector/connection-impl";
5
5
  /**
6
6
  * Events that can be bound in UI render options.
7
7
  * @group Events
8
+ * @category UI Events
8
9
  */
9
10
  export type BindableRenderEvent = typeof EVENT_VERTEX_CLICK | typeof EVENT_VERTEX_DBLCLICK | typeof EVENT_VERTEX_CONTEXTMENU | typeof EVENT_VERTEX_DBLTAP | typeof EVENT_VERTEX_MOUSEMOVE | typeof EVENT_VERTEX_MOUSEOUT | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_VERTEX_TAP | typeof EVENT_EDGE_CLICK | typeof EVENT_EDGE_DBLCLICK | typeof EVENT_EDGE_TAP | typeof EVENT_EDGE_DBLTAP | typeof EVENT_EDGE_MOUSEDOWN | typeof EVENT_EDGE_MOUSEUP | typeof EVENT_EDGE_MOUSEOVER | typeof EVENT_EDGE_MOUSEOUT | typeof EVENT_CANVAS_CLICK | typeof EVENT_CANVAS_DBLCLICK | typeof EVENT_PAN | typeof EVENT_NODE_MOVE_END | typeof EVENT_GROUP_MOVE_END | typeof EVENT_NODE_MOVE_START | typeof EVENT_GROUP_MOVE_START;
10
11
  /**
11
12
  * Events that can be bound in a view.
12
13
  * @group Events
14
+ * @category UI Events
13
15
  */
14
16
  export type BindableViewEvent = typeof EVENT_CLICK | typeof EVENT_DBLCLICK | typeof EVENT_TAP | typeof EVENT_DBLTAP | typeof EVENT_CONTEXTMENU | typeof EVENT_MOUSEDOWN | typeof EVENT_MOUSEOUT | typeof EVENT_MOUSEUP | typeof EVENT_MOUSEOVER | typeof EVENT_MOUSEMOVE;
15
17
  /**
16
18
  * The payload passed to a {@link NodeEventCallback}
19
+ * @group Events
20
+ * @category UI Events
17
21
  */
18
22
  export interface NodeEventCallbackPayload<EL> {
19
23
  /**
@@ -39,6 +43,8 @@ export interface NodeEventCallbackPayload<EL> {
39
43
  }
40
44
  /**
41
45
  * The payload passed to a {@link GroupEventCallback}
46
+ * @group Events
47
+ * @category UI Events
42
48
  */
43
49
  export interface GroupEventCallbackPayload<EL> {
44
50
  /**
@@ -64,6 +70,8 @@ export interface GroupEventCallbackPayload<EL> {
64
70
  }
65
71
  /**
66
72
  * The payload passed to a {@link PortEventCallback}
73
+ * @group Events
74
+ * @category UI Events
67
75
  */
68
76
  export interface PortEventCallbackPayload<EL> {
69
77
  /**
@@ -89,6 +97,8 @@ export interface PortEventCallbackPayload<EL> {
89
97
  }
90
98
  /**
91
99
  * The payload passed to an {@link EdgeEventCallback}
100
+ * @group Events
101
+ * @category UI Events
92
102
  */
93
103
  export interface EdgeEventCallbackPayload {
94
104
  /**
@@ -115,23 +125,32 @@ export interface EdgeEventCallbackPayload {
115
125
  export default EdgeEventCallbackPayload;
116
126
  /**
117
127
  * The definition of a callback function for an edge event mapped in a view.
128
+ * @group Events
129
+ * @category UI Events
118
130
  */
119
131
  export type EdgeEventCallback = (p: EdgeEventCallbackPayload) => any;
120
132
  /**
121
133
  * The definition of a callback function for a node event mapped in a view.
134
+ * @group Events
135
+ * @category UI Events
122
136
  */
123
137
  export type NodeEventCallback<EL> = (p: NodeEventCallbackPayload<EL>) => any;
124
138
  /**
125
139
  * The definition of a callback function for a port event mapped in a view.
140
+ * @group Events
141
+ * @category UI Events
126
142
  */
127
143
  export type PortEventCallback<EL> = (p: PortEventCallbackPayload<EL>) => any;
128
144
  /**
129
145
  * The definition of a callback function for a group event mapped in a view.
146
+ * @group Events
147
+ * @category UI Events
130
148
  */
131
149
  export type GroupEventCallback<EL> = (p: GroupEventCallbackPayload<EL>) => any;
132
150
  /**
133
151
  * Events that can be mapped in a node definition in a view.
134
152
  * @group Events
153
+ * @category UI Events
135
154
  */
136
155
  export type NodeEventOptions<EL> = {
137
156
  [K in BindableViewEvent]?: NodeEventCallback<EL>;
@@ -139,6 +158,7 @@ export type NodeEventOptions<EL> = {
139
158
  /**
140
159
  * Events that can be mapped in a group definition in a view.
141
160
  * @group Events
161
+ * @category UI Events
142
162
  */
143
163
  export type GroupEventOptions<EL> = {
144
164
  [K in BindableViewEvent]?: GroupEventCallback<EL>;
@@ -146,6 +166,7 @@ export type GroupEventOptions<EL> = {
146
166
  /**
147
167
  * Events that can be mapped in a port definition in a view.
148
168
  * @group Events
169
+ * @category UI Events
149
170
  */
150
171
  export type PortEventOptions<EL> = {
151
172
  [K in BindableViewEvent]?: PortEventCallback<EL>;
@@ -153,6 +174,7 @@ export type PortEventOptions<EL> = {
153
174
  /**
154
175
  * Events that can be mapped in an edge definition in a view.
155
176
  * @group Events
177
+ * @category UI Events
156
178
  */
157
179
  export type EdgeEventOptions = {
158
180
  [K in BindableViewEvent]?: EdgeEventCallback;
@@ -1,4 +1,6 @@
1
+ import { ObjectData, Vertex, VisuallyJsModel } from "../../../core";
1
2
  import { VertexMapping } from "./vertex-options";
3
+ import { UICore } from "../core";
2
4
  /**
3
5
  * Base view mapping for nodes and ports (and groups, since they extend nodes)
4
6
  * @group Components
@@ -13,6 +15,10 @@ export interface NodeOrPortMapping<E, N, EVT> extends VertexMapping<N, EVT> {
13
15
  * ID of the template to use for a vertex of this type. This is only for 'vanilla' VisuallyJs: if you are using an integration such as React/Angular/Vue, you will not need to provide this. This parameter is distinct from `template` in that when you provide `templateId` you are expecting VisuallyJs to resolve the template for you, either from a `templates` block in a `render` call, or by looking for a script element in the DOM with the appropriate ID. If you provide this and also `template`, `template` will take precedence.
14
16
  */
15
17
  templateId?: string;
18
+ /**
19
+ * A function that can resolve the ID of the template to use for the given vertex. This is an advanced configuration that is not often needed, and is only for 'vanilla' VisuallyJs. This function will take precedence over both `template` and `templateId`.
20
+ */
21
+ templateIdResolver?: (data: ObjectData, ui: UICore<E>, model: VisuallyJsModel, object: Vertex) => string;
16
22
  /**
17
23
  * Template to use for a vertex of this type. This is only for 'vanilla' VisuallyJs: if you are using an integration such as React/Angular/Vue/Svelte, you will not need to provide this. If you provide this and also `templateId`, this will take precedence.
18
24
  */
@@ -3,6 +3,8 @@ import { VertexDefinition, ObjectAnchorSpec } from "../../../core";
3
3
  import { AnchorPositionFinder } from "../ui-model";
4
4
  /**
5
5
  * Base mapping for nodes, groups and ports.
6
+ * @group UI
7
+ * @category Definitions
6
8
  */
7
9
  export interface VertexMapping<O, EVT> extends BaseViewObjectMapping, VertexDefinition {
8
10
  /**
@@ -252,8 +252,9 @@ export declare class Viewport<EL> {
252
252
  */
253
253
  isEmpty(): boolean;
254
254
  /**
255
- * Gets the position of the element. This returns both the original position, and also the translated position of the element. Certain internal methods, such as the anchor calculation code, use the unrotated position and then subsequently apply the element's rotation to any calculated positions. Other parts of the codebase - the Toolkit's magnetizer or pan/zoom widget, for instance - are interested in the rotated position. If the element is marked 'dirty' it is first refreshed.
255
+ * Gets the position of the element. This returns both the original position, and also the translated position of the element. Certain internal methods, such as the anchor calculation code, use the unrotated position and then subsequently apply the element's rotation to any calculated positions. Other parts of the codebase - the magnetizer or pan/zoom widget, for instance - are interested in the rotated position. If the element is marked 'dirty' it is first refreshed.
256
256
  * @param id
257
+ * @internal
257
258
  */
258
259
  getElement(id: string): ViewportElement<EL>;
259
260
  /**
@@ -293,5 +294,10 @@ export declare class Viewport<EL> {
293
294
  * @param rotation
294
295
  */
295
296
  addElement(elId: string, el: EL, modelObject: Vertex, position: PointXY, size: Size, rotation: number): ViewportElement<any>;
297
+ /**
298
+ * Calculates the extents of only the top-level elements.
299
+ * @internal
300
+ */
301
+ getTopLevelExtents(): Extents;
296
302
  }
297
303
  export {};
@@ -1,4 +1,4 @@
1
- import { Connection, GroupResizeResult, UICore, ViewportElement, ViewportGroupElement } from "../core";
1
+ import { Connection, ConnectionEstablishedParams, GroupResizeResult, UICore, ViewportElement, ViewportGroupElement } from "../core";
2
2
  import { Vertex, Size, VertexUpdatedReason, Edge } from "../../core";
3
3
  /**
4
4
  * Placeholder interface for plugin options.
@@ -62,6 +62,11 @@ export interface UIPlugin<EL, O extends UIPluginOptions, U extends UICore<EL, an
62
62
  * @param element
63
63
  */
64
64
  $edgeUpdated: (edge: Edge, connection: Connection<EL>) => void;
65
+ /**
66
+ * Notification that an edge was rendered
67
+ * @param p
68
+ */
69
+ $edgeRendered: (p: ConnectionEstablishedParams) => void;
65
70
  /**
66
71
  * Invoked when a vertex has been resized
67
72
  * @param element
@@ -4,4 +4,8 @@ export declare const UIPlugins: {
4
4
  get: <P extends UIPlugin<any, any, any> = UIPlugin<any, any, any>>(name: string) => P;
5
5
  register: <P extends UIPlugin<any, any, any> = UIPlugin<any, any, any>>(name: string, sp: Constructable<P>) => void;
6
6
  };
7
+ /**
8
+ * Decorator function that can be used to register a plugin.
9
+ * @param pluginName
10
+ */
7
11
  export declare function registerPlugin(pluginName: string): (constructor: Constructable<any>) => void;
@@ -2,6 +2,8 @@ import { EdgeMapping } from "../core";
2
2
  /**
3
3
  * A mapping of some property/properties to a set of appearance values. Currently only used by edges.
4
4
  * @typeParam D Identifies the type that each mapping has. For instance, for {@link EdgePropertyMappings}, this type is {@link EdgeDefinition}.
5
+ * @group UI
6
+ * @category Definitions
5
7
  */
6
8
  export interface PropertyMapping<D> {
7
9
  /**
@@ -15,10 +17,14 @@ export interface PropertyMapping<D> {
15
17
  }
16
18
  /**
17
19
  * A set of property mappings for edges.
20
+ * @group UI
21
+ * @category Definitions
18
22
  */
19
23
  export type EdgePropertyMappings = Array<PropertyMapping<EdgeMapping>>;
20
24
  /**
21
25
  * A set of {@link PropertyMapping}s - currently only edges are supported, but future versions will support nodes, groups and ports
26
+ * @group UI
27
+ * @category Definitions
22
28
  */
23
29
  export interface PropertyMappings {
24
30
  /**
@@ -6,7 +6,6 @@
6
6
  * @internal
7
7
  */
8
8
  import { PointXY, Size } from "../../core";
9
- export declare function filterList(list: Array<any> | string, value: any, missingIsFalse?: boolean): boolean;
10
9
  /**
11
10
  * Equivalent of Object.assign, which IE11 does not support.
12
11
  * @param o1
@@ -23,13 +22,6 @@ export interface RotatedPointXY extends PointXY {
23
22
  cr: number;
24
23
  sr: number;
25
24
  }
26
- /**
27
- * Internal method used to rotate an anchor orientation.
28
- * @param orientation
29
- * @param rotation
30
- * @internal
31
- */
32
- export declare function rotateAnchorOrientation(orientation: [number, number], rotation: any): [number, number];
33
25
  /**
34
26
  * Iterates through the given `obj` and applies the given function. if `obj` is not ArrayLike then the function is
35
27
  * executed directly on `obj`.
@@ -46,24 +38,19 @@ export declare function each(obj: any, fn: Function): void;
46
38
  * @internal
47
39
  */
48
40
  export declare function wrap(wrappedFunction: Function, newFunction: Function, returnOnThisValue?: any): () => any;
49
- /**
50
- * A copy of a concept from a later version of Typescript than jsPlumb can currently use.
51
- * @internal
52
- */
53
41
  /**
54
42
  * Defines a function that can be used to sort an array.
55
43
  * @internal
56
44
  */
57
45
  export type SortFunction<T> = (a: T, b: T) => number;
58
46
  /**
59
- * Definition of a function that can be used to constrain the movement of an element that is being dragged. The function is
60
- * given the "desiredLoc", which is the location the element would be moved to if not constrained, and it is expected to return
61
- * either some other value, meaning place the element at that position, or null, meaning for the given desired location there
62
- * is no preferred position and the element should not be moved.
47
+ * Definition of a function that can be used to constrain the movement of an element that is being dragged. The function is given the "desiredLoc", which is the location the element would be moved to if not constrained, and it is expected to return either some other value, meaning place the element at that position, or null, meaning for the given desired location there is no preferred position and the element should not be moved.
63
48
  *
64
49
  * @param desiredLoc - Position the element will be placed at if unconstrained
65
50
  * @param dragEl - the element that is being dragged
66
51
  * @param size - The size of the element being dragged
67
52
  * @param e - The event associated with this tick of the drag lifecycle.
53
+ * @group UI
54
+ * @category Definitions
68
55
  */
69
56
  export type ConstrainFunction<EL, E> = (desiredLoc: PointXY, dragEl: EL, constrainRect: Size, size: Size, currentPos: PointXY, e: E) => PointXY;
@@ -1 +1 @@
1
- export declare const VERSION = "1.0.3";
1
+ export declare const VERSION = "1.1.0";
@@ -1,100 +0,0 @@
1
- import { AnchorPlacement, Geometry, Edge } from "../../../core";
2
- import { ConnectionDetachedParams } from "../callbacks";
3
- import { RedrawResult, Router } from "./router";
4
- import { Connection } from "../connector/connection-impl";
5
- import { UICore } from "../core";
6
- import { ViewportElement } from "../viewport";
7
- import { AnchorSpec, Connector, AnchorComputeParams, LightweightAnchor, LightweightContinuousAnchor } from "../../common";
8
- import { AStarGrid } from "../../../core";
9
- import { ConnectorComputeParams } from "../connector/abstract-connector";
10
- import { AnchorLists } from "./router-utils";
11
- /**
12
- * Base router options. Placeholder interface for subclasses.
13
- * @internal
14
- */
15
- export interface BaseRouterOptions {
16
- gridCellSize?: number;
17
- avoidVertices?: boolean;
18
- vertexBuffer?: number;
19
- vertexBorder?: number;
20
- }
21
- /**
22
- * @internal
23
- */
24
- export declare abstract class BaseRouter<EL> implements Router<EL, LightweightAnchor> {
25
- instance: UICore<any, any>;
26
- anchorLists: Map<string, AnchorLists>;
27
- protected _avoidVertices: boolean;
28
- protected _gridCellSize: number;
29
- protected _vertexBuffer: number;
30
- protected _vertexBorder: number;
31
- protected _grid: AStarGrid;
32
- protected constructor(instance: UICore<any, any>, options?: BaseRouterOptions);
33
- /**
34
- * Notification that a connection was removed.
35
- * @param params
36
- */
37
- $connectionRemoved(params: ConnectionDetachedParams<any>): void;
38
- elementRemoved(el: ViewportElement<EL>): void;
39
- private _removeConnection;
40
- $connectionDetachedFromElement(connection: Connection<EL>, el: ViewportElement<any>): void;
41
- /**
42
- * Sets the current anchor index in an anchor that has more than one location
43
- * @internal
44
- * @param anchor
45
- * @param idx
46
- * @param connection
47
- */
48
- $setCurrentLocation(anchor: LightweightAnchor, idx: number, connection?: Connection<any>): void;
49
- /**
50
- * Computes the position for an anchor that is neither floating nor continuous, or is currently fixed. This case
51
- * covers what was previously both DynamicAnchor and Anchor, since those concepts have now been folded into
52
- * a single concept - any given anchor has one or more locations.
53
- * @param anchor
54
- * @param params
55
- */
56
- private _defaultAnchorCompute;
57
- private _placeContinuousAnchors;
58
- private _updateContinuousAnchorList;
59
- /**
60
- * Remove the given anchor from the continuous anchor lists. This method is invoked when a connection is detached.
61
- * @param elementId
62
- * @param anchor
63
- * @private
64
- * @internal
65
- */
66
- $_removeAnchorFromAnchorLists(elementId: string, anchor: LightweightContinuousAnchor): void;
67
- computeAnchorLocation(anchor: LightweightAnchor, params: AnchorComputeParams): AnchorPlacement;
68
- computePath(connection: Connection<any>, timestamp: string): void;
69
- abstract _doComputePath(connection: Connection<EL>, connector: Connector, params: ConnectorComputeParams, timestamp: string): Geometry;
70
- abstract _doUpdatePath(connection: Connection<EL>, connector: Connector, params: ConnectorComputeParams, timestamp: string, sourceMoved: boolean, targetMoved: boolean): Geometry;
71
- prepareAnchor(params: AnchorSpec | Array<AnchorSpec>): LightweightAnchor;
72
- private _orientationCache;
73
- private _orientationCacheTimestamp;
74
- /**
75
- * @internal
76
- * @param c
77
- * @private
78
- */
79
- protected _computeObstaclePadding(c: Connector): number;
80
- private _calculateOrientation;
81
- /**
82
- * Redraws every connection. Does not update element positions.
83
- * @internal
84
- */
85
- $redrawEveryConnection(): RedrawResult;
86
- $redrawConnection(edge: Edge, timestamp?: string): RedrawResult;
87
- /**
88
- * Redraws connections for the given element. Does not update element positions.
89
- * @internal
90
- */
91
- $redraw(viewportElement: ViewportElement<EL>, timestamp?: string): RedrawResult;
92
- /**
93
- * Redraws a list of connections. Does not update element positions.
94
- * @internal
95
- */
96
- private _redrawConnections;
97
- reset(): void;
98
- setConnectionAnchors(conn: Connection<any>, anchors: [LightweightAnchor, LightweightAnchor]): void;
99
- private _anchorSelector;
100
- }