@visuallyjs/browser-ui 1.0.3 → 1.1.1

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 (139) 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 +13 -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/html-element-overlay.d.ts +3 -0
  22. package/types/browser-ui/icons/definitions.d.ts +20 -0
  23. package/types/browser-ui/pan-zoom-options.d.ts +10 -21
  24. package/types/browser-ui/pan-zoom.d.ts +29 -114
  25. package/types/browser-ui/paper-renderer/definitions.d.ts +2 -0
  26. package/types/browser-ui/paper-renderer/paper.d.ts +1 -0
  27. package/types/browser-ui/plugins/background/background-options.d.ts +4 -0
  28. package/types/browser-ui/plugins/background/tiled-background.d.ts +2 -0
  29. package/types/browser-ui/plugins/browser-ui-plugin.d.ts +6 -1
  30. package/types/browser-ui/positioning-and-sizing-utils.d.ts +21 -1
  31. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +26 -11
  32. package/types/browser-ui/shape-library/shape-library.d.ts +14 -3
  33. package/types/browser-ui/shape-library/shapes-basic.d.ts +1 -1
  34. package/types/browser-ui/shape-library/shapes-flowchart.d.ts +1 -1
  35. package/types/browser-ui/surface-renderer/anim/definitions.d.ts +13 -4
  36. package/types/browser-ui/surface-renderer/anim/path-transport.d.ts +0 -1
  37. package/types/browser-ui/surface-renderer/definitions.d.ts +14 -3
  38. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +12 -2
  39. package/types/browser-ui/surface-renderer/diagrams/diagram-link.d.ts +2 -0
  40. package/types/browser-ui/surface-renderer/diagrams/diagram-tools.d.ts +4 -0
  41. package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +4 -1
  42. package/types/browser-ui/surface-renderer/diagrams/index.d.ts +4 -2
  43. package/types/browser-ui/surface-renderer/diagrams/mediator.d.ts +14 -0
  44. package/types/browser-ui/surface-renderer/plugins/controls/controls-plugin.d.ts +2 -0
  45. package/types/browser-ui/surface-renderer/plugins/export-controls/export-controls-plugin.d.ts +3 -1
  46. package/types/browser-ui/surface-renderer/plugins/index.d.ts +1 -0
  47. package/types/browser-ui/surface-renderer/plugins/list-manager/index.d.ts +1 -0
  48. package/types/browser-ui/surface-renderer/plugins/list-manager/list-manager-plugin.d.ts +34 -0
  49. package/types/browser-ui/surface-renderer/plugins/palette/palette-plugin.d.ts +2 -0
  50. package/types/browser-ui/surface-renderer/plugins/pan-buttons/pan-buttons-plugin.d.ts +1 -2
  51. package/types/browser-ui/surface-renderer/plugins/resizing-tools/definitions.d.ts +9 -0
  52. package/types/browser-ui/surface-renderer/plugins/snaplines/snaplines-plugin.d.ts +12 -0
  53. package/types/browser-ui/surface-renderer/plugins/vertex-drawing/vertex-drawing-plugin.d.ts +0 -2
  54. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +5 -2
  55. package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -1
  56. package/types/browser-ui/surface-renderer/surface-render-options.d.ts +0 -30
  57. package/types/browser-ui/surface-renderer/surface.d.ts +47 -38
  58. package/types/browser-ui/svg-element-overlay.d.ts +1 -0
  59. package/types/browser-ui/svg-export/definitions.d.ts +12 -0
  60. package/types/browser-ui/svg-export/image-exporter.d.ts +2 -0
  61. package/types/browser-ui/svg-export/svg-exporter.d.ts +3 -0
  62. package/types/browser-ui/templating/custom-tag-definition.d.ts +1 -2
  63. package/types/browser-ui/util.d.ts +2 -0
  64. package/types/charts/bar-and-column/bar-plot.d.ts +2 -0
  65. package/types/charts/base-chart.d.ts +62 -6
  66. package/types/charts/chart-exporter.d.ts +3 -0
  67. package/types/charts/datasource.d.ts +11 -0
  68. package/types/charts/definitions.d.ts +10 -0
  69. package/types/charts/domain_scale_utilities.d.ts +4 -0
  70. package/types/charts/legend.d.ts +2 -0
  71. package/types/charts/pie/pie-chart.d.ts +2 -0
  72. package/types/charts/sankey/sankey.d.ts +1 -0
  73. package/types/charts/scatter/definitions.d.ts +1 -0
  74. package/types/charts/series/array-based-series.d.ts +2 -0
  75. package/types/charts/series/definitions.d.ts +1 -0
  76. package/types/charts/series/series.d.ts +2 -0
  77. package/types/charts/series-based-chart.d.ts +1 -0
  78. package/types/charts/tooltip.d.ts +7 -2
  79. package/types/charts/util.d.ts +10 -3
  80. package/types/core/autosaver.d.ts +2 -1
  81. package/types/core/csv-loader.d.ts +8 -2
  82. package/types/core/event-constants.d.ts +44 -2
  83. package/types/core/geom.d.ts +1 -0
  84. package/types/core/io.d.ts +31 -7
  85. package/types/core/layout/abstract-layout.d.ts +1 -0
  86. package/types/core/layout/grid/definitions.d.ts +10 -19
  87. package/types/core/layout/grid/grid-layout.d.ts +2 -2
  88. package/types/core/layout/hierarchy/util.d.ts +1 -7
  89. package/types/core/magnetizer.d.ts +1 -0
  90. package/types/core/model/anchor.d.ts +1 -0
  91. package/types/core/model/graph.d.ts +3 -11
  92. package/types/core/model/group-template.d.ts +15 -0
  93. package/types/core/params.d.ts +2 -2
  94. package/types/core/renderer.d.ts +3 -0
  95. package/types/core/rtree/rtree.d.ts +15 -0
  96. package/types/core/selection.d.ts +2 -6
  97. package/types/core/templates/core.d.ts +1 -1
  98. package/types/core/toolkit.d.ts +30 -10
  99. package/types/core/undo-redo/undo-redo.d.ts +0 -22
  100. package/types/core/util.d.ts +4 -1
  101. package/types/ui/common/overlay.d.ts +7 -1
  102. package/types/ui/common/paint-style.d.ts +2 -0
  103. package/types/ui/connector-orthogonal/operations.d.ts +1 -18
  104. package/types/ui/connector-orthogonal/utils.d.ts +0 -6
  105. package/types/ui/connector-straight/straight-connector.d.ts +2 -5
  106. package/types/ui/core/component/component.d.ts +1 -4
  107. package/types/ui/core/connector/connection-impl.d.ts +1 -0
  108. package/types/ui/core/connector/connections.d.ts +0 -29
  109. package/types/ui/core/connector/straight-segment.d.ts +0 -6
  110. package/types/ui/core/constants.d.ts +0 -4
  111. package/types/ui/core/core-events.d.ts +5 -3
  112. package/types/ui/core/core.d.ts +19 -21
  113. package/types/ui/core/defaults.d.ts +43 -9
  114. package/types/ui/core/definitions.d.ts +39 -20
  115. package/types/ui/core/event-constants.d.ts +1 -0
  116. package/types/ui/core/factory/continuous-anchors.d.ts +0 -6
  117. package/types/ui/core/grid-profile.d.ts +3 -1
  118. package/types/ui/core/magnetize-profile.d.ts +1 -3
  119. package/types/ui/core/overlay/custom-overlay.d.ts +28 -9
  120. package/types/ui/core/overlay/label-overlay.d.ts +3 -2
  121. package/types/ui/core/overlay/overlay.d.ts +5 -3
  122. package/types/ui/core/params.d.ts +12 -99
  123. package/types/ui/core/router/default-router.d.ts +89 -18
  124. package/types/ui/core/router/index.d.ts +0 -1
  125. package/types/ui/core/router/router-utils.d.ts +0 -24
  126. package/types/ui/core/router/router.d.ts +29 -20
  127. package/types/ui/core/type-descriptors.d.ts +2 -0
  128. package/types/ui/core/ui-model.d.ts +3 -0
  129. package/types/ui/core/view/edge-options.d.ts +5 -0
  130. package/types/ui/core/view/events.d.ts +22 -0
  131. package/types/ui/core/view/node-or-port-options.d.ts +6 -0
  132. package/types/ui/core/view/vertex-options.d.ts +2 -0
  133. package/types/ui/core/viewport.d.ts +7 -1
  134. package/types/ui/plugins/definitions.d.ts +6 -1
  135. package/types/ui/plugins/plugins.d.ts +4 -0
  136. package/types/ui/property-mappings/definitions.d.ts +6 -0
  137. package/types/ui/util/util.d.ts +3 -16
  138. package/types/version.d.ts +1 -1
  139. package/types/ui/core/router/base-router.d.ts +0 -100
@@ -18,6 +18,8 @@ export declare function isFullOverlaySpec(o: OverlaySpec): o is FullOverlaySpec;
18
18
  export declare function convertToFullOverlaySpec(spec: string | OverlaySpec): InternalOverlaySpec;
19
19
  /**
20
20
  * Events that can be bound on an overlay in a view.
21
+ * @group Edges
22
+ * @category Overlays
21
23
  */
22
24
  export type OverlayEvents = typeof EVENT_CLICK;
23
25
  /**
@@ -61,7 +63,7 @@ export declare function setOverlayLocation(o: Overlay<any>, l: number | string):
61
63
  * @internal
62
64
  */
63
65
  export declare abstract class Overlay<EL> {
64
- component: Connection<EL>;
66
+ connection: Connection<EL>;
65
67
  id: string;
66
68
  abstract type: string;
67
69
  cssClass: string;
@@ -75,11 +77,11 @@ export declare abstract class Overlay<EL> {
75
77
  * types system.
76
78
  * @internal
77
79
  * @param instance
78
- * @param component
80
+ * @param connection
79
81
  * @param p
80
82
  */
81
83
  ignoreTypes: boolean;
82
- constructor(component: Connection<EL>, p: OverlayOptions);
84
+ constructor(connection: Connection<EL>, p: OverlayOptions);
83
85
  abstract updateFrom(opts: any, context: ObjectData): void;
84
86
  abstract isSimpleShape: boolean;
85
87
  }
@@ -1,13 +1,12 @@
1
1
  import { ConnectorSpec, PaintStyle, OverlaySpec, AnchorSpec, LightweightAnchor } from "../common";
2
- import { Extents, PointXY, Size, Edge, Group, Node, VisuallyJsRenderer, AbstractLayout, GradientSpec } from "../../core";
2
+ import { Extents, PointXY, Size, Edge, Group, Node, AbstractLayout, GradientSpec } from "../../core";
3
3
  /**
4
4
  * Options for the `connect` call on a UICore
5
5
  * @internal
6
6
  */
7
7
  export interface ConnectParams<E> {
8
8
  /**
9
- * If true, the router should try to route this connection around
10
- * any vertices that lie in its path.
9
+ * If true, the router should try to route this connection around any vertices that lie in its path.
11
10
  */
12
11
  avoidVertices?: boolean;
13
12
  /**
@@ -22,32 +21,26 @@ export interface ConnectParams<E> {
22
21
  * Whether or not the connection is detachable. Defaults to true.
23
22
  */
24
23
  detachable?: boolean;
25
- /**
26
- * Whether or not to delete the connection's endpoints when this connection is detached. Defaults to false. Does not
27
- * delete endpoints if they have other connections.
28
- */
29
- deleteEndpointsOnDetach?: boolean;
30
- /**
31
- * Whether or not to delete any endpoints that were created by this connect call if at some
32
- * point in the future the endpoint has no remaining connections. Defaults to false.
33
- */
34
- deleteEndpointsOnEmpty?: boolean;
35
24
  /**
36
25
  * Whether or not to reattach this connection automatically should it be detached via user intervention. Defaults to false.
37
26
  */
38
27
  reattach?: boolean;
39
28
  /**
40
- * Spec for the anchor to use for both source and target endpoints.
29
+ * Spec for the anchor to use for both source and target locations.
41
30
  */
42
31
  anchor?: AnchorSpec | LightweightAnchor;
43
32
  /**
44
- * Individual anchor specs for the source/target endpoints.
33
+ * Individual anchor specs for the source/target locations.
45
34
  */
46
35
  anchors?: [AnchorSpec | LightweightAnchor, AnchorSpec | LightweightAnchor];
47
36
  /**
48
37
  * Optional label to set on the connection. In the default browser UI implementation this is rendered as a `label` attribute on the SVG element representing the connection.
49
38
  */
50
39
  label?: string;
40
+ /**
41
+ * When true, the label will be rotated so that it is at the same angle as the slope of the connector at the point at which the label is located.
42
+ */
43
+ labelsRotatable?: boolean;
51
44
  /**
52
45
  * Spec for the connector used to paint the connection.
53
46
  */
@@ -97,107 +90,27 @@ export interface ConnectParams<E> {
97
90
  useHTMLLabel?: boolean;
98
91
  edge?: Edge;
99
92
  }
100
- /**
101
- * Options for the UpdateOffset method
102
- * @internal
103
- */
104
- export interface UpdateOffsetOptions {
105
- timestamp?: string;
106
- recalc?: boolean;
107
- elId?: string;
108
- pos?: PointXY;
109
- size?: Size;
110
- rotation?: number;
111
- }
112
93
  export interface RelayoutParams<A extends AbstractLayout<any>> {
113
94
  bounds: Extents;
114
95
  positions: Record<string, PointXY>;
115
96
  sizes: Record<string, Size>;
116
97
  layout: A;
117
98
  }
118
- export interface GroupCollapsedParams<E> {
119
- group: Group;
120
- }
121
- export interface GroupExpandedParams<E> {
122
- group: Group;
123
- }
124
99
  /**
125
- * Payload for a EVENT_GROUP_MEMBER_ADDED event from the ui
100
+ * Payload for a {@link EVENT_GROUP_COLLAPSED}event.
126
101
  * @group Events
127
102
  * @category UI Event Payloads
128
103
  */
129
- export interface UIGroupMemberAddedParams<EL> {
130
- /**
131
- * Element representing the member that was added to the group
132
- */
133
- el: EL;
134
- /**
135
- * Element representing the group
136
- */
137
- groupEl: EL;
138
- /**
139
- * Vertex that was added to the group
140
- */
141
- vertex: Node | Group;
142
- /**
143
- * Group the vertex was added to
144
- */
104
+ export interface GroupCollapsedParams {
145
105
  group: Group;
146
- /**
147
- * Optional new location for the vertex that was added
148
- */
149
- pos?: PointXY;
150
- /**
151
- * If a vertex being added to some group is currently a member of some other group, that group is provided here.
152
- */
153
- sourceGroup?: Group;
154
- /**
155
- * @internal
156
- */
157
- source?: VisuallyJsRenderer<any>;
158
- /**
159
- * Set to true if the vertex is also brand new, not copied from elsewhere in the dataset.
160
- */
161
- vertexIsNew?: boolean;
162
- /**
163
- * @internal
164
- */
165
- payload?: Record<string, any>;
166
106
  }
167
107
  /**
168
- * Payload for a EVENT_GROUP_MEMBER_REMOVED event from the UI.
108
+ * Payload for a {@link EVENT_GROUP_EXPANDED}event.
169
109
  * @group Events
170
110
  * @category UI Event Payloads
171
111
  */
172
- export interface UIGroupMemberRemovedParams<EL> {
173
- /**
174
- * Element representing the member that was added to the group
175
- */
176
- el: EL;
177
- /**
178
- * DOM element representing the group
179
- */
180
- groupEl: EL;
181
- /**
182
- * Position the member that was removed was located at.
183
- */
184
- pos: PointXY;
185
- /**
186
- * Vertex that was removed from the group
187
- */
188
- vertex: Node | Group;
189
- /**
190
- * Group the vertex was removed from
191
- */
112
+ export interface GroupExpandedParams {
192
113
  group: Group;
193
- /**
194
- * @internal
195
- */
196
- source?: VisuallyJsRenderer<any>;
197
- /**
198
- * If the vertex is being moved to some other group, that group is provided here.
199
- */
200
- targetGroup?: Group;
201
114
  }
202
115
  /**
203
116
  * Payload for an {@link EVENT_NODE_RENDERED} event from the UI.
@@ -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;
@@ -78,6 +79,10 @@ export interface EdgeMapping extends BaseViewObjectMapping, LineStyle {
78
79
  * Optional spec for label font. Will use browser defaults if not specified (or CSS, but remember that CSS is not taken into account when you export an SVG from a diagram or an app using an SVG container)
79
80
  */
80
81
  labelFont?: FontSpec;
82
+ /**
83
+ * When true, the label will be rotated so that it is at the same angle as the slope of the connector at the point at which the label is located.
84
+ */
85
+ labelsRotatable?: boolean;
81
86
  /**
82
87
  * Optional width of the edge's outline. Defaults to 0.
83
88
  */
@@ -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;