@visuallyjs/browser-ui 1.1.3 → 1.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.
Files changed (30) hide show
  1. package/css/visuallyjs.css +22 -1
  2. package/js/visuallyjs.browser-ui.cjs.js +53 -53
  3. package/js/visuallyjs.browser-ui.esm.js +53 -53
  4. package/package.json +1 -1
  5. package/types/browser-ui/auto-pan-handler.d.ts +36 -0
  6. package/types/browser-ui/browser-visuallyjs-instance.d.ts +8 -2
  7. package/types/browser-ui/connector-editors/editor-base.d.ts +4 -1
  8. package/types/browser-ui/css-constants.d.ts +16 -0
  9. package/types/browser-ui/edge-handler-base.d.ts +1 -1
  10. package/types/browser-ui/edge-input-handler.d.ts +2 -0
  11. package/types/browser-ui/edge-relocate-handler.d.ts +2 -2
  12. package/types/browser-ui/element-drag-handler-2.d.ts +12 -0
  13. package/types/browser-ui/plugins/browser-ui-plugin.d.ts +2 -2
  14. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +1 -1
  15. package/types/browser-ui/surface-renderer/plugins/lasso/lasso-plugin.d.ts +6 -0
  16. package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +21 -3
  17. package/types/browser-ui/surface-renderer/plugins/miniview/miniview-plugin.d.ts +15 -7
  18. package/types/browser-ui/surface-renderer/surface.d.ts +8 -3
  19. package/types/charts/sankey/sankey.d.ts +1 -1
  20. package/types/core/event-constants.d.ts +29 -0
  21. package/types/core/geom.d.ts +32 -2
  22. package/types/core/layout/circular/circular-layout.d.ts +6 -1
  23. package/types/core/selection.d.ts +6 -2
  24. package/types/core/toolkit.d.ts +6 -0
  25. package/types/test-support/test-support.d.ts +10 -5
  26. package/types/ui/core/core-events.d.ts +2 -2
  27. package/types/ui/core/core.d.ts +8 -0
  28. package/types/ui/core/definitions.d.ts +6 -0
  29. package/types/ui/core/event-constants.d.ts +16 -0
  30. package/types/version.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visuallyjs/browser-ui",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "license": "Commercial",
5
5
  "main": "js/visuallyjs.browser-ui.cjs.js",
6
6
  "module": "js/visuallyjs.browser-ui.esm.js",
@@ -0,0 +1,36 @@
1
+ import { PointXY } from "../core";
2
+ import { SupportsElementDragging } from "../ui";
3
+ import { BrowserElement } from "./util";
4
+ export interface AutoPanOptions {
5
+ autoPanDelta?: number;
6
+ autoPanRepeat?: number;
7
+ onPan: (deltas: PointXY) => void;
8
+ shouldHandle: () => boolean;
9
+ }
10
+ /**
11
+ * Manages auto pan for a component that supports dragging of elements (not just vertex elements, any elements, such as those used to manage edge dragging or lasso etc).
12
+ * @internal
13
+ */
14
+ export declare class AutoPanHandler {
15
+ private draggableInstance;
16
+ private options;
17
+ private readonly _observer;
18
+ _canvasShift: PointXY;
19
+ private _lastPanDirection;
20
+ private _isPanRepeatActive;
21
+ private _rootBounds;
22
+ constructor(draggableInstance: SupportsElementDragging<BrowserElement>, options: AutoPanOptions);
23
+ /**
24
+ * Called by ElementDragHandler2 to continuously update the auto-pan logic during a drag.
25
+ * @param boundingClientRect The bounding client rect of the dragged element.
26
+ */
27
+ updateDragElementPosition(boundingClientRect: DOMRect): void;
28
+ $updateRootBounds(): void;
29
+ private _isElementIntersectingRoot;
30
+ private _updatePanDirectionAndStartRepeat;
31
+ private _stopPanRepeatInternal;
32
+ reset(): void;
33
+ observe(el: BrowserElement): void;
34
+ unobserve(el: BrowserElement): void;
35
+ disconnect(): void;
36
+ }
@@ -1,6 +1,6 @@
1
1
  import { EVENT_EDGE_CLICK, EVENT_EDGE_CONTEXTMENU, EVENT_EDGE_DBLCLICK, EVENT_EDGE_MOUSEDOWN, EVENT_EDGE_MOUSEOUT, EVENT_EDGE_MOUSEOVER, EVENT_EDGE_MOUSEUP, EVENT_VERTEX_CLICK, EVENT_VERTEX_TAP, EVENT_VERTEX_DBLTAP, EVENT_VERTEX_MOUSEOVER, EVENT_VERTEX_MOUSEOUT, EVENT_VERTEX_MOUSEMOVE, EVENT_VERTEX_MOUSEUP, EVENT_VERTEX_MOUSEDOWN, EVENT_VERTEX_CONTEXTMENU, EVENT_VERTEX_DBLCLICK, Overlay, OverlayPaintParams, LabelOverlay, Connection, ConnectorPath, UICore, TypeDescriptorBase, VertexMapping, GroupMapping, PortMapping, NodeMapping, DragHandler2, ViewportElement, OverlaySpec, Connector, PaintStyle, ZoomToFitOptions, ZoomToFitIfNecessaryOptions, ZoomToElementsOptions, PropertyMapper, EdgePropertyMappings, ViewportGroupElement, ViewportNodeElement } from '../ui';
2
2
  import { VisuallyJSDOMElement } from './element-facade';
3
- import { VisuallyJsModel, Base, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsSelection, DataSource, EVENT_GROUP_MOVE, Grid, GroupRemovedParams, NodeRemovedParams, PointXY, RectangleXY, Size, CustomTagOptions, AbstractLayoutAdapter, LayoutResultSet } from "../core";
3
+ import { VisuallyJsModel, Base, Edge, Group, Node, ObjectData, Port, Vertex, VisuallyJsSelection, DataSource, EVENT_GROUP_MOVE, Grid, GroupRemovedParams, NodeRemovedParams, PointXY, RectangleXY, Size, CustomTagOptions, AbstractLayoutAdapter, LayoutResultSet, EVENT_EDGE_DRAG_START, EVENT_EDGE_DRAG, EVENT_EDGE_DRAG_END, EVENT_EDGE_DRAG_ABORT } from "../core";
4
4
  import { TemplateRenderer } from "./browser-ui";
5
5
  import { Background, BrowserUIDefaults, BrowserUIOptions, ElementModelInfo, SupportsClassManipulation, SupportsClassManipulationElement } from "./definitions";
6
6
  import { BrowserElement } from './util';
@@ -11,7 +11,7 @@ import { BrowserUIClipboard } from "./copy-paste";
11
11
  * @group Events
12
12
  * @category UI Events
13
13
  */
14
- export type BrowserUIEvent = typeof EVENT_EDGE_MOUSEUP | typeof EVENT_EDGE_MOUSEDOWN | typeof EVENT_VERTEX_CLICK | typeof EVENT_VERTEX_DBLCLICK | typeof EVENT_EDGE_CONTEXTMENU | typeof EVENT_EDGE_CLICK | typeof EVENT_EDGE_DBLCLICK | typeof EVENT_VERTEX_DBLTAP | typeof EVENT_VERTEX_TAP | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_VERTEX_MOUSEOUT | typeof EVENT_VERTEX_MOUSEMOVE | typeof EVENT_VERTEX_MOUSEDOWN | typeof EVENT_VERTEX_MOUSEUP | typeof EVENT_VERTEX_CONTEXTMENU | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_EDGE_MOUSEOVER | typeof EVENT_EDGE_MOUSEOUT | typeof EVENT_GROUP_MOVE;
14
+ export type BrowserUIEvent = typeof EVENT_EDGE_MOUSEUP | typeof EVENT_EDGE_MOUSEDOWN | typeof EVENT_VERTEX_CLICK | typeof EVENT_VERTEX_DBLCLICK | typeof EVENT_EDGE_CONTEXTMENU | typeof EVENT_EDGE_CLICK | typeof EVENT_EDGE_DBLCLICK | typeof EVENT_VERTEX_DBLTAP | typeof EVENT_VERTEX_TAP | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_VERTEX_MOUSEOUT | typeof EVENT_VERTEX_MOUSEMOVE | typeof EVENT_VERTEX_MOUSEDOWN | typeof EVENT_VERTEX_MOUSEUP | typeof EVENT_VERTEX_CONTEXTMENU | typeof EVENT_VERTEX_MOUSEOVER | typeof EVENT_EDGE_MOUSEOVER | typeof EVENT_EDGE_MOUSEOUT | typeof EVENT_GROUP_MOVE | typeof EVENT_EDGE_DRAG_START | typeof EVENT_EDGE_DRAG | typeof EVENT_EDGE_DRAG_END | typeof EVENT_EDGE_DRAG_ABORT;
15
15
  /**
16
16
  * Subclass of UICore that renders to the DOM in a browser, and supports dragging of elements/connections.
17
17
  * @group Components
@@ -276,6 +276,7 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
276
276
  */
277
277
  $getSize(el: BrowserElement): Size;
278
278
  $setElementRotation(el: BrowserElement, r: number): void;
279
+ $setVisibleElementRotation(vel: ViewportElement<BrowserElement>, r: number): void;
279
280
  /**
280
281
  * Gets the position of the given element relative to its offset parent,
281
282
  * in canvas coordinates, ie. not scaled per the current zoom. Currently
@@ -738,6 +739,11 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
738
739
  */
739
740
  $getModelInfoForDragElement(el: BrowserElement, asSource: boolean, createMissingPorts: boolean): ElementModelInfo;
740
741
  $isElement(obj: any): obj is BrowserElement;
742
+ /**
743
+ * Get the model object + DOM element on which the given event occurred.
744
+ * @param e
745
+ */
746
+ getElementFromEvent(e: MouseEvent): ViewportElement<BrowserElement> | null;
741
747
  getModelObjectFromElement(el: BrowserElement, searchAncestors: boolean, createMissingPorts: boolean): {
742
748
  obj: Node | Group | Port | Edge;
743
749
  el: VisuallyJSDOMElement;
@@ -38,9 +38,12 @@ export declare abstract class EditorBase<ConnectorType extends Connector> implem
38
38
  private _anchorVertex;
39
39
  private _dragHandlers;
40
40
  private _anchorDragContext;
41
+ /**
42
+ * Subclasses must implement.
43
+ * @param args
44
+ */
41
45
  abstract $repaint(args?: any): void;
42
46
  isBusy(): boolean;
43
- private _repaint;
44
47
  /**
45
48
  * @internal
46
49
  */
@@ -261,6 +261,14 @@ export declare const CLASS_MINIVIEW_CANVAS = "vjs-miniview-canvas";
261
261
  * @context miniview
262
262
  */
263
263
  export declare const CLASS_MINIVIEW_PANNER = "vjs-miniview-panner";
264
+ /**
265
+ * Assigned by the Miniview to the DOM element that provides the visual cue showing the lasso
266
+ * @group Plugins
267
+ * @category Miniview
268
+ * @cssClass
269
+ * @context miniview
270
+ */
271
+ export declare const CLASS_MINIVIEW_LASSO = "vjs-miniview-lasso";
264
272
  /**
265
273
  * Assigned by the Miniview to a DOM element representing a node.
266
274
  * @group Plugins
@@ -277,6 +285,14 @@ export declare const CLASS_MINIVIEW_ELEMENT = "vjs-miniview-element";
277
285
  * @context miniview
278
286
  */
279
287
  export declare const CLASS_MINIVIEW_GROUP_ELEMENT = "vjs-miniview-group-element";
288
+ /**
289
+ * Assigned by the Miniview to a DOM element that is in the model's current selection.
290
+ * @group Plugins
291
+ * @category Miniview
292
+ * @cssClass
293
+ * @context miniview
294
+ */
295
+ export declare const CLASS_MINIVIEW_SELECTED_ELEMENT = "vjs-miniview-selected";
280
296
  /**
281
297
  * Assigned by the Miniview to its canvas when the user is panning it.
282
298
  * @group Plugins
@@ -112,7 +112,7 @@ export declare function _getVertexInfo(surface: Surface, el: BrowserElement, asS
112
112
  * @param boundingRect
113
113
  * @param e
114
114
  */
115
- export declare function testIntersectingDropTarget(surface: Surface, dropTargets: Array<DropTarget>, boundingRect: RectangleXY, e: MouseEvent): DropTarget;
115
+ export declare function testIntersectingDropTarget(surface: Surface, dropTargets: Array<DropTarget>, boundingRect: RectangleXY, e: MouseEvent, canvasShift: PointXY): DropTarget;
116
116
  export declare function _populateTargetZones(surface: Surface, activeFiltering: boolean, focusVertex: Vertex, loopbackAllowed: boolean, payload?: ObjectData, scope?: string): {
117
117
  dropTargets: Array<DropTarget>;
118
118
  disabledDropTargets: Array<VisuallyJSDOMElement>;
@@ -66,6 +66,7 @@ export declare class EdgeInputHandler extends EdgeHandlerBase {
66
66
  private _dragContext;
67
67
  method: EdgeInputMethod;
68
68
  private _autoPanObserver;
69
+ private _canvasShift;
69
70
  constructor(options: EdgeInputHandlerOptions);
70
71
  private _cleanup;
71
72
  private _addTransientEdge;
@@ -78,6 +79,7 @@ export declare class EdgeInputHandler extends EdgeHandlerBase {
78
79
  */
79
80
  private _canStartNewEdgeInput;
80
81
  private _startDrag;
82
+ private _unobservePanRepeat;
81
83
  private _finaliseTransientEdge;
82
84
  private _stopDrag;
83
85
  /**
@@ -24,11 +24,11 @@ export declare class EdgeRelocateHandler extends EdgeHandlerBase {
24
24
  currentEdge: Edge;
25
25
  currentConnection: Connection<BrowserElement>;
26
26
  currentIndex: ProxyLocation;
27
+ private _autoPanObserver;
28
+ private _canvasShift;
27
29
  mouseMoveHandler: (e: MouseEvent) => void;
28
30
  mouseUpHandler: (e: MouseEvent) => void;
29
31
  documentKeypressHandler: (e: KeyboardEvent) => any;
30
- private _canvasShift;
31
- private _autoPanObserver;
32
32
  currentPosition: PointXY;
33
33
  currentPagePosition: PointXY;
34
34
  private _hasMoved;
@@ -157,6 +157,7 @@ export declare class ElementDragHandler2 {
157
157
  */
158
158
  private _canDropOnCanvas;
159
159
  private _suppressRootElementClasses;
160
+ private _rotationContext;
160
161
  /**
161
162
  * List of group targets whose location intersects the drag object's current position. We push a bunch of groups onto this array and sort them by nested depth to find which one should be the current drop target.
162
163
  */
@@ -198,11 +199,13 @@ export declare class ElementDragHandler2 {
198
199
  private _cleanup;
199
200
  private _cleanupGroupTargetHoverState;
200
201
  private _findDraggableVertex;
202
+ private _computeRotationMatrix;
201
203
  private _start;
202
204
  private _unobservePanRepeat;
203
205
  private _addGroupClass;
204
206
  private _removeGroupClass;
205
207
  private _stop;
208
+ private _mapToGroupCoords;
206
209
  /**
207
210
  * For the current drag group, compute a position for each of the elements such that each element is gathered around the focus position. This is used when dropping a vertex on a group: the focus vertex goes where it was dropped, and the rest of the drag group are pulled in around that focus element. The gather operation should try to maintain the original orientation between the focus element and the other members of the group, but obviously we want to pull them right in close in order to drop them as a unit.
208
211
  * @param focusPosition
@@ -218,6 +221,14 @@ export declare class ElementDragHandler2 {
218
221
  private _revert;
219
222
  private _isOriginalGroup;
220
223
  private _moveToNewPosition;
224
+ private _rotateOneElement;
225
+ private _updateDragContextRotation;
226
+ /**
227
+ * return all elements to the rotation specified in the viewport.
228
+ * @private
229
+ */
230
+ private _resetDragContextRotation;
231
+ private _rotateDelta;
221
232
  private _drag;
222
233
  private _setRelativePositionAtDown;
223
234
  /**
@@ -247,5 +258,6 @@ export declare class ElementDragHandler2 {
247
258
  private _sizeElasticGroupFrame;
248
259
  private _canDragVertex;
249
260
  $addVertexDragFilter(filter: VertexDragFilter<BrowserElement>): void;
261
+ $destroy(): void;
250
262
  }
251
263
  export {};
@@ -88,8 +88,8 @@ export declare abstract class BaseBrowserUIPlugin {
88
88
  */
89
89
  $edgeUpdated(edge: Edge): void;
90
90
  /**
91
- * Invoked when an edge has been rendered
92
- * @param edge
91
+ * Invoked when an edge has been initially rendered. Only fired once for each edge.
92
+ * @param p
93
93
  */
94
94
  $edgeRendered(p: ConnectionEstablishedParams): void;
95
95
  }
@@ -178,7 +178,7 @@ export interface DiagramOptions {
178
178
  */
179
179
  layerIndex?: number;
180
180
  /**
181
- * Defaults to true - when an edge is selected, it's bounding box will be highlighted.
181
+ * When an edge is selected, highlight its bounding box. Defaults to false.
182
182
  */
183
183
  highlightSelected?: boolean;
184
184
  /**
@@ -1,6 +1,7 @@
1
1
  import { Edge, Vertex, PointXY } from "../../../../core";
2
2
  import { Surface } from "../../surface";
3
3
  import { SurfaceMode } from "../../definitions";
4
+ import { ViewportGroupElement } from "../../../../ui";
4
5
  import { BrowserElement } from "../../../util";
5
6
  import { BaseBrowserUIPlugin, BrowserUIPlugin, BrowserUIPluginOptions } from "../../../plugins";
6
7
  /**
@@ -54,6 +55,10 @@ export interface LassoPluginOptions extends BrowserUIPluginOptions {
54
55
  * @param e
55
56
  */
56
57
  generateLassoContent?: (origin: PointXY, e: MouseEvent) => BrowserElement;
58
+ /**
59
+ * Optional setting for whether lasso inside groups is enabled - it is by default. Setting this to `false` will mean that the user cannot lasso items inside a group. Setting to `"metaKey"` will mean that lasso is supported inside groups if the user is holding the meta key down (ie the Window key, or Cmd on macs).
60
+ */
61
+ enableInGroups?: false | true | "metaKey";
57
62
  }
58
63
  /**
59
64
  * A Surface plugin that allows the user to select multiple elements with the mouse.
@@ -72,6 +77,7 @@ export declare class LassoPlugin extends BaseBrowserUIPlugin implements BrowserU
72
77
  selectionFilter: (o: Edge | Vertex) => boolean;
73
78
  autoExit: boolean;
74
79
  lassoSelections: Array<any>;
80
+ _currentGroup: ViewportGroupElement<BrowserElement>;
75
81
  destroy(): void;
76
82
  initialise(surface: Surface, options: LassoPluginOptions): boolean;
77
83
  reset(): void;
@@ -1,9 +1,11 @@
1
1
  import { Surface } from "../../surface";
2
+ import { ViewportElement } from "../../../../ui";
2
3
  import { BrowserElement } from "../../../util";
3
4
  import { PointXY, Size } from "../../../../core";
5
+ import { AutoPanHandler } from "../../../auto-pan-handler";
4
6
  export interface LassoOptions {
5
7
  canvas: Element;
6
- onStart?: (pagePosition: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent) => any;
8
+ onStart?: (pagePosition: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent, viewportElement: ViewportElement<BrowserElement> | null) => any;
7
9
  onEnd?: (visibleOrigin: PointXY, size: Size) => any;
8
10
  onSelect?: (pagePosition: PointXY, pageSize: Size, canvasPosition: PointXY, canvasSize: Size, axesPositive: [boolean, boolean], shiftKey: boolean) => any;
9
11
  /**
@@ -16,23 +18,36 @@ export interface LassoOptions {
16
18
  surface: Surface;
17
19
  filter?: ((e: MouseEvent) => boolean) | string;
18
20
  cssClass?: string;
19
- /** optionally users of the lasso can impose a grid on its movement. used internally by the vertex drawing plugin. */
21
+ /**
22
+ * optionally users of the lasso can impose a grid on its movement. used internally by the vertex drawing plugin. */
20
23
  mapToGrid?: (p: PointXY) => PointXY;
21
24
  /**
22
25
  * Optional method that can return an element to inject as the lasso's child.
23
26
  * @private
24
27
  */
25
28
  generateLassoContent?: (origin: PointXY, e: MouseEvent) => BrowserElement;
29
+ /**
30
+ * Optional setting for whether lasso inside groups is enabled - it is by default. Setting this to `false` will mean that the user cannot lasso items inside a group. Setting to `"metaKey"` will mean that lasso is supported inside groups if the user is holding the meta key down (ie the Window key, or Cmd on macs).
31
+ */
32
+ enableInGroups?: false | true | "metaKey";
33
+ /**
34
+ * Defaults to true, meaning the canvas will pan automatically to track the lasso
35
+ */
36
+ autoPan?: boolean;
26
37
  }
27
38
  export declare class Lasso {
28
39
  visibleOrigin: PointXY;
29
40
  size: Size;
30
41
  _generateLassoContent: (origin: PointXY, e: MouseEvent) => BrowserElement;
31
42
  el: HTMLElement;
43
+ _extentTrackerEl: BrowserElement;
32
44
  masks: Record<string, HTMLElement>;
33
45
  origin: PointXY;
34
46
  canvasOrigin: PointXY;
35
- onStart: (origin: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent) => any;
47
+ canvasExtent: PointXY;
48
+ _canvasShift: PointXY;
49
+ _autoPanHandler: AutoPanHandler;
50
+ onStart: (origin: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent, viewportElement: ViewportElement<BrowserElement> | null) => any;
36
51
  onEnd: (visibleOrigin: PointXY, size: Size) => any;
37
52
  onSelect: (pagePosition: PointXY, pageSize: Size, canvasPosition: PointXY, canvasSize: Size, axesPositive: [boolean, boolean], shiftKey: boolean, lassoContent?: BrowserElement) => any;
38
53
  onClick: (p: PointXY, e: MouseEvent) => any;
@@ -51,13 +66,16 @@ export declare class Lasso {
51
66
  upEvent: string;
52
67
  moveEvent: string;
53
68
  enabled: boolean;
69
+ _enableInGroups: false | true | "metaKey";
54
70
  _generatedLassoContent: BrowserElement;
71
+ _lastPageLocation: PointXY;
55
72
  constructor(options: LassoOptions);
56
73
  private _prepareFilter;
57
74
  private _position;
58
75
  private _setVisible;
59
76
  private _mapPoint;
60
77
  private _downListener;
78
+ private _repaint;
61
79
  private _moveListener;
62
80
  private _upListener;
63
81
  private _createMasks;
@@ -27,14 +27,12 @@ export interface MiniviewPluginOptions extends BrowserUIPluginOptions {
27
27
  */
28
28
  collapsible?: boolean;
29
29
  /**
30
- * Optional function to use to derive a type for each rendered node/group. This is written onto
31
- * the corresponding element as the value of the `data-vjs-miniview-type` attribute, and can be useful
32
- * for styling.
30
+ * Optional function to use to derive a type for each rendered node/group. This is written onto the corresponding element as the value of the `data-vjs-miniview-type` attribute, and can be useful for styling.
33
31
  * @param v
34
32
  */
35
33
  typeFunction?: (v: Node | Group) => string;
36
34
  /**
37
- * Optional overide for how sensitive the wheel zoom should be.
35
+ * Optional override for how sensitive the wheel zoom should be.
38
36
  */
39
37
  wheelSensitivity?: number;
40
38
  /**
@@ -55,14 +53,21 @@ export interface MiniviewPluginOptions extends BrowserUIPluginOptions {
55
53
  */
56
54
  wheelReverse?: boolean;
57
55
  /**
58
- * Defaults to true, meaning the miniview actively updates as nodes/groups are dragged on the related surface. If this is set
59
- * to false, the miniview only updates after mouseup.
56
+ * Defaults to true, meaning the miniview actively updates as nodes/groups are dragged on the related surface. If this is set to false, the miniview only updates after mouseup.
60
57
  */
61
58
  activeTracking?: boolean;
62
59
  /**
63
60
  * Defaults to true, meaning a click on a node/group in the miniview will cause that node/group to be centered in the related surface.
64
61
  */
65
62
  clickToCenter?: boolean;
63
+ /**
64
+ * Defaults to true - the miniview will display a lasso as the user is using the lasso in the canvas
65
+ */
66
+ showLasso?: boolean;
67
+ /**
68
+ * Defaults to true - the miniview will add a CSS class to elements whose model object is in the current selection.
69
+ */
70
+ trackSelection?: boolean;
66
71
  }
67
72
  interface MiniviewDOMElement extends VisuallyJSDOMElement {
68
73
  vertex: Vertex;
@@ -95,6 +100,7 @@ export declare class MiniviewPlugin extends BaseBrowserUIPlugin implements Brows
95
100
  containerElement: BrowserElement;
96
101
  canvasElement: BrowserElement;
97
102
  pannerElement: BrowserElement;
103
+ lassoElement: BrowserElement;
98
104
  uiBounds: ViewportBounds;
99
105
  suspended: boolean;
100
106
  _collapsible: boolean;
@@ -117,7 +123,9 @@ export declare class MiniviewPlugin extends BaseBrowserUIPlugin implements Brows
117
123
  /**
118
124
  * Defaults to true, meaning a click on a node/group in the miniview will cause that node/group to be centered in the related surface.
119
125
  */
120
- clickToCenter: boolean;
126
+ _clickToCenter: boolean;
127
+ _showLasso: boolean;
128
+ _trackSelection: boolean;
121
129
  vertexMap: Record<string, MiniviewDOMElement>;
122
130
  enableWheelZoom: boolean;
123
131
  eventManager: EventManager;
@@ -6,7 +6,7 @@ import { UIPath } from '../ui-path';
6
6
  import { FixedElement, FixedElementConstraints } from "../fixed-layer";
7
7
  import { SurfaceOptions } from "./surface-render-options";
8
8
  import { Base, Node, Group, Edge, Port, Vertex, ObjectData, VisuallyJsSelection, PathOptions, DataSource, NodeRemovedParams, PointXY, RectangleXY, ZoomRange, LayoutResultSet, GroupRemovedParams } from '../../core';
9
- import { Connection, SupportsElementDragging, DragOptions, Overlay, ViewportBounds, UIExportOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions, ZoomToElementsOptions, ViewportNodeElement, ViewportElement, ViewportGroupElement, CenterContentOptions, AlignContentOptions, AlignContentToFaceOptions, CenterContentHorizontallyOptions, CenterContentVerticallyOptions } from "../../ui";
9
+ import { Connection, SupportsElementDragging, DragOptions, Overlay, ViewportBounds, UIExportOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions, ZoomToElementsOptions, ViewportNodeElement, ViewportElement, ViewportGroupElement, CenterContentOptions, AlignContentOptions, AlignContentToFaceOptions, CenterContentHorizontallyOptions, CenterContentVerticallyOptions, VertexDragFilter } from "../../ui";
10
10
  import { BrowserUI } from "../browser-visuallyjs-instance";
11
11
  import { BrowserElement } from "../util";
12
12
  import { EdgeInputMethod } from "../edge-input-handler";
@@ -235,15 +235,20 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
235
235
  */
236
236
  addDragFilter(filter: (e: MouseEvent) => boolean, exclude?: boolean): void;
237
237
  /**
238
- * Adds a CSS class filter to the drag handler.
238
+ * Adds a CSS class name filter to the drag handler - without the `.`.
239
239
  * @param clazz Either a single class name, or a comma separated list of classnames, or an array of classnames.
240
240
  */
241
241
  addDragClassnameFilter(clazz: string | Array<string>): void;
242
242
  /**
243
- * Adds a CSS3 selector filter to the drag handler. A drag cannot start on an element that matches this selector.
243
+ * Adds a CSS3 selector filter to the drag handler. A drag cannot start on an element that matches this selector. For more fine-grained control over dragging, see {@link #addVertexDragFilter}.
244
244
  * @param selector A valid CSS3 selector.
245
245
  */
246
246
  addDragSelectorFilter(selector: string): void;
247
+ /**
248
+ * Adds a filter function to the drag handler. A drag cannot start if this function returns false. See also {@link #addDragSelectorFilter}
249
+ * @param f Function that can return false to disallow drag.
250
+ */
251
+ addVertexDragFilter(f: VertexDragFilter<BrowserElement>): void;
247
252
  /**
248
253
  * Removes a CSS class filter from the drag handler.
249
254
  * @param clazz Either a single class name, or a comma separated list of classnames, or an array of classnames.
@@ -175,7 +175,7 @@ export declare class SankeyChart extends BaseChart {
175
175
  csvData?: string;
176
176
  dataType?: string;
177
177
  jsonData?: VisuallyJsDefaultJSON;
178
- }): void;
178
+ }, onload?: () => any): void;
179
179
  hasData(): boolean;
180
180
  destroy(): void;
181
181
  private _clearVertex;
@@ -211,6 +211,34 @@ export declare const EVENT_EDGE_GEOMETRY = "edge:geometry";
211
211
  * @category UI
212
212
  */
213
213
  export declare const EVENT_EDGE_PATH_EDITED = "edge:pathEdited";
214
+ /**
215
+ * Fired by the UI when the user has started to drag a new edge
216
+ * @event
217
+ * @group Events
218
+ * @category UI
219
+ */
220
+ export declare const EVENT_EDGE_DRAG_START = "edge:dragStart";
221
+ /**
222
+ * Fired by the UI when the mouse moves as the user is dragging a new edge
223
+ * @event
224
+ * @group Events
225
+ * @category UI
226
+ */
227
+ export declare const EVENT_EDGE_DRAG = "edge:drag";
228
+ /**
229
+ * Fired by the UI when the user has finished dragging a new edge
230
+ * @event
231
+ * @group Events
232
+ * @category UI
233
+ */
234
+ export declare const EVENT_EDGE_DRAG_END = "edge:dragEnd";
235
+ /**
236
+ * Fired by the UI when the user has aborted dragging a new edge
237
+ * @event
238
+ * @group Events
239
+ * @category UI
240
+ */
241
+ export declare const EVENT_EDGE_DRAG_ABORT = "edge:dragAbort";
214
242
  /**
215
243
  * Fired by the model when the type of a node has changed.
216
244
  * @event
@@ -278,6 +306,7 @@ export declare const EVENT_INTERNAL_GROUP_SIZE_CHANGED_REDO = "internal:group:si
278
306
  * @internal
279
307
  */
280
308
  export declare const EVENT_INTERNAL_GROUP_SIZE_CHANGED_UNDO = "internal:group:sizeChangedUndo";
309
+ export declare const EVENT_INTERNAL_EDGE_REDRAW = "internal:edge:redraw";
281
310
  /**
282
311
  * @internal
283
312
  * @payload RendererAddedParams
@@ -96,6 +96,7 @@ export declare function fixPrecision(n: number, digits?: number): number;
96
96
  * @returns A point if an intersection found, null otherwise.
97
97
  * @internal
98
98
  */
99
+ export declare const EPSILON = 0.000001;
99
100
  export declare function lineIntersection(l1: LineXY, l2: LineXY): PointXY | null;
100
101
  /**
101
102
  * Finds all points where the given line intersects the given rectangle.
@@ -278,7 +279,36 @@ export declare const chebyshevDistance: (x1: number, y1: number, x2: number, y2:
278
279
  */
279
280
  export declare const octileDistance: (x1: number, y1: number, x2: number, y2: number) => number;
280
281
  /**
281
- * Clamps the given angle to lie inside the range 0 - 360
282
- * @param rangle
282
+ * Clamps the given angle (in degrees) to lie inside the range 0 - 360
283
+ * @param angle
283
284
  */
284
285
  export declare function clampAngle(angle: number): number;
286
+ /**
287
+ * Compares a moving point to a reference point and returns a directional PointXY object.
288
+ * The direction is determined by imagining 4 lines at 45 degrees emanating from the reference point.
289
+ *
290
+ * - {x:0, y:-1} for TOP (moving point is primarily above the reference point)
291
+ * - {x:-1, y:0} for LEFT (moving point is primarily to the left of the reference point)
292
+ * - {x:1, y:0} for RIGHT (moving point is primarily to the right of the reference point)
293
+ * - {x:0, y:1} for BOTTOM (moving point is primarily below the reference point)
294
+ *
295
+ * @param referencePoint The reference point.
296
+ * @param movingPoint The moving point to compare.
297
+ * @returns A PointXY object indicating the direction.
298
+ */
299
+ /**
300
+ * Represents a rectangle with an optional rotation.
301
+ * The rotation is in degrees, and defaults to 0.
302
+ * The rotation is assumed to be around the center of the rectangle.
303
+ */
304
+ export interface RotatedRectangle extends RectangleXY {
305
+ r?: number;
306
+ }
307
+ /**
308
+ * Determines if two rotated rectangles intersect using the Separating Axis Theorem (SAT).
309
+ * @param r1 The first rotated rectangle.
310
+ * @param r2 The second rotated rectangle.
311
+ * @returns True if the rectangles intersect, false otherwise.
312
+ * @internal
313
+ */
314
+ export declare function rotatedRectanglesIntersect(r1: RotatedRectangle, r2: RotatedRectangle): boolean;
@@ -11,14 +11,19 @@ export interface CircularLayoutParameters extends LayoutParameters {
11
11
  * If true, the first node in the data set will be placed in the center of the circle. Defaults to false.
12
12
  */
13
13
  centerRoot?: boolean;
14
+ /**
15
+ * Whether or not to shift the layout so that the origin is [width/2, height/2] and not [0,0]. This is useful in situations such as groups, where elements cannot be placed in a negative position in either axis (due to there being no facility to pan the group canvas)
16
+ */
17
+ centerContent?: boolean;
14
18
  }
15
19
  /**
16
- * A layout that places vertices in a circle, optionally with one at the center.
20
+ * A layout that places vertices in a circle, optionally with one at the center, and optionally centered around [width/2, height/2] (the default origin is 0,0).
17
21
  * @group Layouts
18
22
  * @category Circular
19
23
  */
20
24
  export declare class CircularLayout extends AbstractLayout<CircularLayoutParameters> {
21
25
  private readonly _centerRoot;
26
+ private readonly _centerContent;
22
27
  static type: string;
23
28
  readonly type: string;
24
29
  padding: PointXY;
@@ -66,7 +66,7 @@ export interface SelectionOptions {
66
66
  /**
67
67
  * Optional function that can be called to fill the selection. You'd use this when you are rendering individual selections and you need to be able to refresh the whole view based on some change in the data model.
68
68
  */
69
- generator?: Function;
69
+ generator?: SelectionGenerator;
70
70
  /**
71
71
  * If true, the selection will not populate itself as soon as it is constructed. Otherwise, and this is the default behaviour, it will.
72
72
  */
@@ -82,6 +82,10 @@ export interface SelectionOptions {
82
82
  * @category Selection
83
83
  */
84
84
  export type SELECTION_EVENTS = typeof EVENT_EDGE_UPDATED | typeof EVENT_DATA_LOAD_END | typeof EVENT_DATA_LOAD_START | typeof EVENT_NODE_UPDATED | typeof EVENT_GRAPH_CLEAR_START | typeof EVENT_GROUP_UPDATED | typeof EVENT_PORT_UPDATED | typeof EVENT_EDGE_TARGET_CHANGED | typeof EVENT_EDGE_SOURCE_CHANGED | typeof EVENT_EDGE_REMOVED | typeof EVENT_EDGE_ADDED | typeof EVENT_GROUP_REMOVED | typeof EVENT_NODE_REMOVED | typeof EVENT_GROUP_ADDED | typeof EVENT_NODE_ADDED;
85
+ /**
86
+ * Defines a function that can be used as the generator for a selection.
87
+ */
88
+ export type SelectionGenerator = (s: VisuallyJsSelection, m: VisuallyJsModel) => any;
85
89
  /**
86
90
  * A selection is a group of vertices and edges, upon which you can perform bulk operations.
87
91
  * @group Model
@@ -97,7 +101,7 @@ export declare class VisuallyJsSelection extends OptimisticEventGenerator implem
97
101
  _groups: Array<Group>;
98
102
  _edges: Array<Edge>;
99
103
  capacityPolicy: string;
100
- generator: Function;
104
+ generator: SelectionGenerator;
101
105
  onReload: Function;
102
106
  onBeforeReload: Function;
103
107
  onClear: Function;
@@ -248,6 +248,11 @@ export interface ModelOptions {
248
248
  * Optional map of group templates to register on the model.
249
249
  */
250
250
  groupTemplates?: Record<string, GroupTemplate>;
251
+ /**
252
+ * The name of the property inside nodes/groups that identifies their parent group. This defaults to "group" but
253
+ * can be changed if it clashes with your data model.
254
+ */
255
+ groupProperty?: string;
251
256
  }
252
257
  /**
253
258
  * Definition of a model event callback.
@@ -395,6 +400,7 @@ export declare abstract class VisuallyJsModel extends OptimisticEventGenerator i
395
400
  typeProperty: string;
396
401
  edgeTypeProperty: string;
397
402
  portTypeProperty: string;
403
+ groupProperty: string;
398
404
  typeFunction: TypeFunction;
399
405
  edgeIdFunction: IdFunction;
400
406
  edgeTypeFunction: TypeFunction;
@@ -78,8 +78,8 @@ export interface ContainerOptions {
78
78
  width?: number;
79
79
  height?: number;
80
80
  }
81
- declare function lasso(surface: Surface, start: PointXY, end: PointXY, callbacks?: ConnectionDragEventHandlers): void;
82
- declare function lassoOnElement(surface: Surface, downEventElement: BrowserElement, start: PointXY, end: PointXY, callbacks?: ConnectionDragEventHandlers): void;
81
+ declare function lasso(surface: Surface, start: PointXY, end: PointXY, callbacks?: ConnectionDragEventHandlers, group?: Group, eventFlags?: Record<string, boolean>, mouseUpContinuer?: Function): void;
82
+ declare function lassoOnElement(surface: Surface, downEventElement: BrowserElement, start: PointXY, end: PointXY, callbacks?: ConnectionDragEventHandlers, metaKeys?: Record<string, boolean>, mouseUpContinuer?: Function): void;
83
83
  /**
84
84
  * @internal
85
85
  */
@@ -371,7 +371,12 @@ export declare class TestHarness {
371
371
  *
372
372
  * @return a Connection. You can access the underlying edge via the `.edge` property of the connection.
373
373
  */
374
- dragConnection(source: BrowserElement | string | [string, string], target: BrowserElement | string | [string, string], callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY): Connection<BrowserElement>;
374
+ dragConnection(source: BrowserElement | string | [string, string], target: BrowserElement | string | [string, string], callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY, mouseUpContinuer?: Function): Connection<BrowserElement>;
375
+ /**
376
+ * Drags a connection from the given source and then aborts the drag by releasing the pointer button at a distant location.
377
+ * @param source
378
+ */
379
+ dragAndAbortConnection(source: BrowserElement | string): void;
375
380
  /**
376
381
  * Drag a connection in a way that activates the snap to target functionality, ie. it fires mouse events close to
377
382
  * the target but not over it.
@@ -407,7 +412,7 @@ export declare class TestHarness {
407
412
  * @param callbacks
408
413
  * @param locationOnTarget
409
414
  */
410
- relocateEdgeTarget(edge: Edge, target: string | Node | Port | Group | BrowserElement, callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY): void;
415
+ relocateEdgeTarget(edge: Edge, target: string | Node | Port | Group | BrowserElement, callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY, mouseUpContinuation?: Function): void;
411
416
  /**
412
417
  * Drag the given edge's source relocator and drop it on some other vertex/element.
413
418
  * @param edge
@@ -415,7 +420,7 @@ export declare class TestHarness {
415
420
  * @param callbacks
416
421
  * @param locationOnTarget
417
422
  */
418
- relocateEdgeSource(edge: Edge, source: string | Node | Port | Group | BrowserElement, callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY): void;
423
+ relocateEdgeSource(edge: Edge, source: string | Node | Port | Group | BrowserElement, callbacks?: ConnectionDragEventHandlers, locationOnTarget?: PointXY, mouseUpContinuation?: Function): void;
419
424
  /**
420
425
  * Trigger the event with the given name on the given object. By default the event will occur in the middle of the
421
426
  * DOM element representing the object.