@visuallyjs/browser-ui 1.2.0 → 1.2.2

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 (34) hide show
  1. package/css/visuallyjs.css +10 -0
  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 +10 -1
  6. package/types/browser-ui/browser-visuallyjs-instance.d.ts +6 -0
  7. package/types/browser-ui/components/inspector/definitions.d.ts +1 -0
  8. package/types/browser-ui/components/inspector/inspector.d.ts +2 -2
  9. package/types/browser-ui/dialogs/binder.d.ts +2 -1
  10. package/types/browser-ui/dialogs/constants.d.ts +1 -0
  11. package/types/browser-ui/pan-zoom.d.ts +14 -15
  12. package/types/browser-ui/paper-renderer/definitions.d.ts +9 -0
  13. package/types/browser-ui/paper-renderer/paper.d.ts +15 -0
  14. package/types/browser-ui/plugins/background/generated-grid-background.d.ts +1 -1
  15. package/types/browser-ui/plugins/background/tiled-background.d.ts +0 -2
  16. package/types/browser-ui/surface-renderer/index.d.ts +1 -0
  17. package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +10 -0
  18. package/types/browser-ui/surface-renderer/popups/definitions.d.ts +14 -0
  19. package/types/browser-ui/surface-renderer/popups/index.d.ts +3 -0
  20. package/types/browser-ui/surface-renderer/popups/popup-handler.d.ts +28 -0
  21. package/types/browser-ui/surface-renderer/popups/util.d.ts +4 -0
  22. package/types/browser-ui/surface-renderer/surface.d.ts +22 -9
  23. package/types/core/geom.d.ts +10 -4
  24. package/types/core/params.d.ts +58 -16
  25. package/types/core/search/visuallyjs-search.d.ts +4 -6
  26. package/types/core/toolkit.d.ts +9 -7
  27. package/types/core/undo-redo/update-action.d.ts +4 -1
  28. package/types/core/undo-redo/vertex-update-action.d.ts +4 -1
  29. package/types/core/util.d.ts +5 -0
  30. package/types/ui/core/constants.d.ts +7 -0
  31. package/types/ui/core/core.d.ts +10 -1
  32. package/types/ui/core/defaults.d.ts +5 -1
  33. package/types/ui/core/definitions.d.ts +9 -0
  34. 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.2.0",
3
+ "version": "1.2.2",
4
4
  "license": "Commercial",
5
5
  "main": "js/visuallyjs.browser-ui.cjs.js",
6
6
  "module": "js/visuallyjs.browser-ui.esm.js",
@@ -1,11 +1,12 @@
1
1
  import { PointXY } from "../core";
2
- import { SupportsElementDragging } from "../ui";
2
+ import { AutoPanBoundsStrategy, SupportsElementDragging } from "../ui";
3
3
  import { BrowserElement } from "./util";
4
4
  export interface AutoPanOptions {
5
5
  autoPanDelta?: number;
6
6
  autoPanRepeat?: number;
7
7
  onPan: (deltas: PointXY) => void;
8
8
  shouldHandle: () => boolean;
9
+ boundsStrategy?: AutoPanBoundsStrategy;
9
10
  }
10
11
  /**
11
12
  * 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).
@@ -19,6 +20,7 @@ export declare class AutoPanHandler {
19
20
  private _lastPanDirection;
20
21
  private _isPanRepeatActive;
21
22
  private _rootBounds;
23
+ private _boundsStrategy;
22
24
  constructor(draggableInstance: SupportsElementDragging<BrowserElement>, options: AutoPanOptions);
23
25
  /**
24
26
  * Called by ElementDragHandler2 to continuously update the auto-pan logic during a drag.
@@ -27,6 +29,13 @@ export declare class AutoPanHandler {
27
29
  updateDragElementPosition(boundingClientRect: DOMRect): void;
28
30
  $updateRootBounds(): void;
29
31
  private _isElementIntersectingRoot;
32
+ private _isElementContainedRoot;
33
+ /**
34
+ * Determines whether or not the given rect is conside to be inside the root bounds, depending on the current bounds strategy.
35
+ * @param boundingClientRect
36
+ * @private
37
+ */
38
+ private _isElementInsideRootBounds;
30
39
  private _updatePanDirectionAndStartRepeat;
31
40
  private _stopPanRepeatInternal;
32
41
  reset(): void;
@@ -40,6 +40,7 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
40
40
  private readonly _managedElementsSelector;
41
41
  private readonly _hoverEvents;
42
42
  private readonly _eventManager;
43
+ private _elementEventFilterSelectors;
43
44
  private _canDropHandler;
44
45
  private _transferrableVertexAttributes;
45
46
  /**
@@ -59,6 +60,11 @@ export declare abstract class BrowserUI<EVT = any> extends UICore<BrowserElement
59
60
  * @internal
60
61
  */
61
62
  $canDrop(candidate: Node | Group, target?: Node | Group, onCanvas?: boolean): boolean;
63
+ /**
64
+ * Adds a CSS3 selector filter which will exclude the given element (and descendants) from reporting element events. Used internally by popups, but exposed in the API as it may be useful.
65
+ * @param selector A valid CSS3 selector.
66
+ */
67
+ addElementEventFilter(selector: string): void;
62
68
  $vertexRendered<N extends Vertex>(v: N, el: BrowserElement, def: VertexMapping<any, BrowserElement>, eventInfo?: {
63
69
  position: PointXY;
64
70
  }): void;
@@ -84,6 +84,7 @@ export type FieldInfo = {
84
84
  commonValue: any;
85
85
  editedValue?: any;
86
86
  attribute: string;
87
+ portId?: string;
87
88
  };
88
89
  /**
89
90
  * Options for the VanillaInspector, an instance of Inspector that uses VisuallyJs's default templating mechanism to render elements.
@@ -77,7 +77,7 @@ export declare class Inspector extends VjsContext {
77
77
  protected $_recomputeCommonData(): void;
78
78
  private __filterEmptyStrings;
79
79
  /**
80
- * Write the changes to the toolkit.
80
+ * Write the changes to the model.
81
81
  * @param updates
82
82
  * @internal
83
83
  */
@@ -107,7 +107,7 @@ export declare class Inspector extends VjsContext {
107
107
  * @param value
108
108
  *
109
109
  */
110
- setValue(key: string, value: any, repaintAfterwards?: boolean): void;
110
+ setValue(key: string, value: any, portId: string, repaintAfterwards?: boolean): void;
111
111
  /**
112
112
  * @internal
113
113
  * @param b
@@ -22,6 +22,7 @@ export declare function attemptCoerce(value: string, datatype: SupportedCoercion
22
22
  * @internal
23
23
  */
24
24
  export declare function extractValueFromElement(el: HTMLElement, unresolvedElementGetter?: (el: Element) => any): any;
25
+ export declare function $makeFieldKey(att: string, portSeparator: string, portId: string | null): string;
25
26
  /**
26
27
  * Apply the given object to the given DOM element. This method will find all child elements of `el` that have a `vjs-att`
27
28
  * attribute set, and then attempt to set the value of any found DOM element with a value extracted from `dataset`.
@@ -30,7 +31,7 @@ export declare function extractValueFromElement(el: HTMLElement, unresolvedEleme
30
31
  * @param autoCommitHandler
31
32
  * @internal
32
33
  */
33
- export declare function apply(dataset: Record<string, any>, el: any, autoCommitHandler?: (e: Element) => any, unresolvedElementSetter?: (e: Element, value: any) => any): void;
34
+ export declare function apply(dataset: Record<string, any>, el: any, portSeparator: string, autoCommitHandler?: (e: Element) => any): void;
34
35
  /**
35
36
  * @internal
36
37
  */
@@ -6,6 +6,7 @@ export declare const DialogConstants: {
6
6
  VJS_COMMIT: string;
7
7
  MULTIPLE: string;
8
8
  VJS: string;
9
+ VJS_PORT: string;
9
10
  DATATYPE: string;
10
11
  TITLE: string;
11
12
  FOCUS: string;
@@ -470,7 +470,7 @@ export declare class PanZoom {
470
470
  */
471
471
  setTransformOrigin(x: number, y: number): void;
472
472
  /**
473
- * Maps the given page location to a value relative to the viewport origin, allowing for zoom and pan of the canvas. This takes into account the offset of the viewport in the page so that what you get back is the mapped position relative to the target element's [left,top] corner. If you wish, you can supply true for 'doNotAdjustForOffset', to suppress that behavior.
473
+ * Maps the given page location to a value relative to the viewport origin, allowing for zoom and pan of the canvas. This takes into account the offset of the viewport in the page so that what you get back is the mapped position relative to the target element's [left,top] corner.
474
474
  * @param left X location
475
475
  * @param top Y location
476
476
  * @param roundValues If true, return integers.
@@ -479,13 +479,19 @@ export declare class PanZoom {
479
479
  fromPageLocation(left: number, top: number, roundValues?: boolean): PointXY;
480
480
  fromWindowLocation(left: number, top: number, roundValues?: boolean): PointXY;
481
481
  /**
482
- * Maps the given location on the canvas to a point relative to the page origin, allowing for zoom and
483
- * pan of the canvas. This takes into account the offset of the viewport in the page so that what
484
- * you get back is the mapped position computed relative to the target element's [left,top] corner.
482
+ * Maps the given location on the canvas to a point relative to the page origin, allowing for zoom and pan of the canvas. This takes into account the offset of the viewport in the page so that what you get back is the mapped position computed relative to the target element's [left,top] corner.
485
483
  * @param left
486
484
  * @param top
487
485
  */
488
486
  toPageLocation(left: number, top: number): PointXY;
487
+ /**
488
+ * Maps the given canvas location to a point, in page coordinates, relative to the panzoom container's origin. A return value of [0,0] from this method indicates the top left corner of the surface's container as seen by the user; negative values for x and/or y mean that the point is not in the visible viewport. Similarly, values for x greater the container width, or y greater than the container height, indicate that the point is not in the visible viewport.
489
+ *
490
+ * This method is useful when you want to position an element over the canvas at some specific canvas location. For instance, the SurfacePopup components use this to position themselves relative to the vertex they are currently referencing.
491
+ * @param left
492
+ * @param top
493
+ */
494
+ toViewportLocation(left: number, top: number): PointXY;
489
495
  /**
490
496
  * Maps the page location of the given event to a value relative to the viewport origin, allowing for zoom and pan of the canvas. This takes into account the offset of the viewport in the page so that what you get back is the mapped position relative to the target element's [left,top] corner. If you wish, you can supply true for 'doNotAdjustForOffset', to suppress that behavior.
491
497
  * @param event Browser event
@@ -498,10 +504,7 @@ export declare class PanZoom {
498
504
  */
499
505
  setEnabled(state: boolean): void;
500
506
  /**
501
- * Returns the apparent origin of the canvas inside the viewport - the coordinates, in real pixel
502
- * values, of where the origin of the canvas appears to be. This apparent origin is not necessarily the
503
- * same as the origin values of the canvas, because the transform origin and zoom values change
504
- * things. This function can be used in conjunction with the content bounds by widgets such as the miniview, to calculate what is actually visible in the viewport at some point in time.
507
+ * Returns the apparent origin of the canvas inside the viewport - the coordinates, in real pixel values, of where the origin of the canvas appears to be. This apparent origin is not necessarily the same as the origin values of the canvas, because the transform origin and zoom values change things. This function can be used in conjunction with the content bounds by widgets such as the miniview, to calculate what is actually visible in the viewport at some point in time.
505
508
  * @returns Position of the canvas, relative to the viewport's 0,0.
506
509
  */
507
510
  getApparentCanvasLocation(): PointXY;
@@ -517,16 +520,13 @@ export declare class PanZoom {
517
520
  */
518
521
  getVisibleContentArea(): RectangleXY;
519
522
  /**
520
- * Appends an element to the viewport so that it floats above the content that is being zoomed and panned.
521
- * The element will have `position:absolute` set on it. You can float any element you like, but note that the
522
- * responsibility for setting an appropriate z index is yours.
523
+ * Appends an element to the viewport so that it floats above the content that is being zoomed and panned. The element will have `position:absolute` set on it. You can float any element you like, but note that the responsibility for setting an appropriate z index is yours.
523
524
  * @param el - Element to float.
524
525
  * @param pos - Position to float the element at.
525
526
  */
526
527
  floatElement(el: Element, pos: PointXY): void;
527
528
  /**
528
- * Appends an element to the viewport such that it is zoomed with everything else, but constrains pan
529
- * in one or both axes so that the element remains fixed with respect to the viewport origin.
529
+ * Appends an element to the viewport such that it is zoomed with everything else, but constrains pan in one or both axes so that the element remains fixed with respect to the viewport origin.
530
530
  * @param el The DOM element to append.
531
531
  * @param pos Location of the element's origin.
532
532
  * @param constraints Flags to indicate optional constraint to each axis.
@@ -564,8 +564,7 @@ export declare class PanZoom {
564
564
  */
565
565
  destroy(): void;
566
566
  /**
567
- * returns whether or not the given element is owned by the current background, if there is one. with some library
568
- * integrations the background can be temporarily null during the processing of an event.
567
+ * returns whether or not the given element is owned by the current background, if there is one. with some library integrations the background can be temporarily null during the processing of an event.
569
568
  * @internal
570
569
  * @param el
571
570
  */
@@ -7,6 +7,14 @@ import { BrowserUIDefaults, BrowserUIOptions } from "../definitions";
7
7
  * @category Paper
8
8
  */
9
9
  export declare const CLASS_PAPER = "vjs-paper";
10
+ /**
11
+ * Css class added to a Paper component's container element when scaling is switched off.
12
+ * @cssClass
13
+ * @context paper
14
+ * @group Components
15
+ * @category Paper
16
+ */
17
+ export declare const CLASS_PAPER_NO_SCALE = "vjs-paper-no-scale";
10
18
  /**
11
19
  * Css class added to the DOM element used to render a Paper object.
12
20
  * @group Components
@@ -75,6 +83,7 @@ export interface PaperOptions extends BrowserUIOptions<PaperDefaults> {
75
83
  * Strategy to use to place content within whitespace in the vertical axis.
76
84
  */
77
85
  verticalAlign?: PaperAlignment;
86
+ scale?: boolean;
78
87
  }
79
88
  /**
80
89
  * Defaults for a Paper renderer
@@ -16,6 +16,7 @@ export declare class Paper extends BrowserUI {
16
16
  $margin: number;
17
17
  $horizontalAlign: PaperAlignment;
18
18
  $verticalAlign: PaperAlignment;
19
+ $scale: boolean;
19
20
  /**
20
21
  * @internal
21
22
  * @param model
@@ -41,6 +42,20 @@ export declare class Paper extends BrowserUI {
41
42
  fromWindowLocation(left: number, top: number, roundValues?: boolean): PointXY;
42
43
  mapEventLocation(event: MouseEvent): PointXY;
43
44
  getViewportBoundsInfo(): ViewportBounds;
45
+ /**
46
+ * When not scaling, this method is used by the background to determine what size it should be.
47
+ * @internal
48
+ */
49
+ $getFixedViewportBoundsInfo(): {
50
+ x: number;
51
+ y: number;
52
+ width: number;
53
+ height: number;
54
+ vw: number;
55
+ vh: number;
56
+ zoom: number;
57
+ minimumFill: number;
58
+ };
44
59
  getApparentCanvasLocation(): PointXY;
45
60
  addBackground(background: Background): void;
46
61
  removeBackground(background: Background): void;
@@ -168,7 +168,7 @@ export declare const CLASS_BACKGROUND_GRID_DOT_MINOR = "vjs-background-grid-dott
168
168
  * lines or dots - control this via the `gridType` option.
169
169
  *
170
170
  * The size of the grid can be mandated in the options for the background, or
171
- * it can be extracted from the surface.
171
+ * it can be extracted from the UI.
172
172
  *
173
173
  * You can hide/show the background grid via the `hide()`, `show()`, `toggle()` or `setVisible(boolean)`
174
174
  * methods.
@@ -1,7 +1,6 @@
1
1
  import { ImageBackgroundOptions, TilingStrategy } from "./background-options";
2
2
  import { Size } from "../../../core";
3
3
  import { VisuallyJSDOMElement } from "../../element-facade";
4
- import { PanZoom } from "../../pan-zoom";
5
4
  import { BrowserUI } from "../../browser-visuallyjs-instance";
6
5
  import { ImageBackground, InternalBackgroundOptions } from "../../definitions";
7
6
  /**
@@ -86,7 +85,6 @@ export declare class TiledBackground implements ImageBackground {
86
85
  private layers;
87
86
  private currentLayer;
88
87
  widgetZoom: number;
89
- zoomWidget: PanZoom;
90
88
  width: number;
91
89
  height: number;
92
90
  tileSize: Size;
@@ -16,6 +16,7 @@ export * from './surface-events';
16
16
  export * from './surface-render-options';
17
17
  export * from './diagrams';
18
18
  export * from './css-classes';
19
+ export * from "./popups";
19
20
  /**
20
21
  * Register a new decorator for use with the {@link Surface} component.
21
22
  * @param name Name to use when registering the decorator.
@@ -70,6 +70,16 @@ export declare class Lasso {
70
70
  _generatedLassoContent: BrowserElement;
71
71
  _lastPageLocation: PointXY;
72
72
  constructor(options: LassoOptions);
73
+ /**
74
+ * list of selectors that should be filtered regardless of user preference
75
+ */
76
+ _systemFilteredSelectors: string[];
77
+ /**
78
+ * Filter function that always runs regardless of user filter
79
+ * @param e
80
+ * @private
81
+ */
82
+ private _systemFilter;
73
83
  private _prepareFilter;
74
84
  private _position;
75
85
  private _setVisible;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The attribute uyed to instruct a PopupHandler where to place a popup with respect to the vertex it is attached to.
3
+ */
4
+ export declare const ATTRIBUTE_POPUP_POSITION = "data-vjs-popup-position";
5
+ /**
6
+ * Possible values for the popup position attribute.
7
+ */
8
+ export type PopupPosition = "top" | "bottom" | "left" | "right" | "center";
9
+ /**
10
+ * CSS class written on surface popups
11
+ * @cssClass
12
+ * @context Popups
13
+ */
14
+ export declare const CLASS_SURFACE_POPUP = "vjs-surface-popup";
@@ -0,0 +1,3 @@
1
+ export * from "./definitions";
2
+ export * from "./popup-handler";
3
+ export * from "./util";
@@ -0,0 +1,28 @@
1
+ import { PopupPosition } from "./definitions";
2
+ import { Vertex } from "../../../core";
3
+ import { BrowserElement } from "../../util";
4
+ import { ViewportElement } from "../../../ui";
5
+ import { Surface } from "../surface";
6
+ /**
7
+ * A handler for popups to appear in relation to vertices on the canvas. This class manages positioning of the popup and provision of the current vertex, but not the display of the popup itself, which is delegated to the library integrations
8
+ */
9
+ export declare class PopupHandler {
10
+ _current: ViewportElement<any> | null;
11
+ _anchor: PopupPosition;
12
+ _defaultAnchor: PopupPosition;
13
+ setCurrent: (v: Vertex | null) => any;
14
+ container: BrowserElement;
15
+ surface: Surface;
16
+ _cleanup: () => void;
17
+ private _doSetCurrent;
18
+ constructor(selector: string, container: BrowserElement, surface: Surface, setCurrent: (v: Vertex | null) => any, anchor?: PopupPosition);
19
+ $destroy(): void;
20
+ /**
21
+ * Sets the current object to null, which hides the popup
22
+ */
23
+ $hide(): void;
24
+ /**
25
+ * @internal
26
+ */
27
+ $positionPopup(): void;
28
+ }
@@ -0,0 +1,4 @@
1
+ import { PointXY, Size } from "../../../core";
2
+ import { ViewportElement } from "../../../ui";
3
+ import { Surface } from "../surface";
4
+ export declare function computeOrigin(anchor: string, referenceElement: ViewportElement<any>, popupSize: Size, surface: Surface): PointXY;
@@ -412,6 +412,11 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
412
412
  * Gets the current bounds information.
413
413
  */
414
414
  getViewportBoundsInfo(): ViewportBounds;
415
+ /**
416
+ * Surface does not have fixed viewport bounds.
417
+ * @internal
418
+ */
419
+ $getFixedViewportBoundsInfo(): ViewportBounds | null;
415
420
  getApparentCanvasLocation(): PointXY;
416
421
  /**
417
422
  * Adds a background. Theoretically you can add multiple backgrounds but the end result of that is indeterminate.
@@ -508,21 +513,22 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
508
513
  *
509
514
  */
510
515
  setPanAndZoom(x: number, y: number, zoom: number, animate?: boolean): void;
516
+ private __findBoundsForElements;
511
517
  /**
512
- * Center on the current object and zoom in on it.
513
- * @param element - The element to center. Can be a DOM element, vertex id, or a Node/Group
518
+ * Center on the current object/objects and zoom in on it/them.
519
+ * @param element - The element(s) to center. Can be a DOM element, vertex id, or a Node/Group, or an array of these.
514
520
  * @param fillRatio How much of the viewport to fill with the object we zoom in on. This will be limited by the current zoom range. Defaults to 0.6.
515
521
  * @param doNotAnimate - by default, this operation will be animated.
516
522
  * @canvasPosition
517
523
  *
518
524
  */
519
- centerOnAndZoom(element: string | Vertex | Element, fillRatio?: number, doNotAnimate?: boolean): void;
525
+ centerOnAndZoom(element: string | Vertex | Element | Array<string | Vertex | Element>, fillRatio?: number, doNotAnimate?: boolean): void;
520
526
  /**
521
- * Takes a node/group as argument and positions the surface canvas such that the given node is at the center in both axes.
522
- * @param element - The element to center. Can be a DOM element, vertex id, or a Node/Group.
527
+ * Takes a single node/group, or an array of nodes/groups, and positions the surface canvas such that the given vertex/vertices is/are at the center in both axes. It does NOT change the zoom.
528
+ * @param element - The element(s) to center. Can be a DOM element, vertex id, or a Node/Group, or an array of these.
523
529
  * @canvasPosition
524
530
  */
525
- centerOn(element: string | Vertex | Element): void;
531
+ centerOn(element: string | Vertex | Element | Array<string | Vertex | Element>, doNotAnimate?: boolean): void;
526
532
  /**
527
533
  * Takes a node/group as argument and positions the surface canvas such that the given node is at the center in the horizontal axis.
528
534
  * @param element - The element to center. Can be a DOM element, vertex id, or a Node/Group
@@ -574,13 +580,20 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
574
580
  */
575
581
  fromWindowLocation(left: number, top: number, roundValues?: boolean): PointXY;
576
582
  /**
577
- * Maps the given location relative to the viewport origin, to a page location, allowing for zoom and pan of the canvas. This takes into account the offset of the viewport in the page so that what you get back is the mapped position relative to the target element's [left,top] corner.
583
+ * Maps the given canvas location to a page location, allowing for zoom and pan of the canvas. Note that `page` in this method takes scroll into account. If you wish to map to just the visible section of the browser, use `toWindowLocation`.
578
584
  * @param left X location
579
585
  * @param top Y location
580
586
  * @returns The mapped location, as a PointXY object.
581
- *
582
587
  */
583
588
  toPageLocation(left: number, top: number): PointXY;
589
+ /**
590
+ * Maps the given canvas location to a point, in page coordinates, relative to the surface container's origin. A return value of [0,0] from this method indicates the top left corner of the surface's container as seen by the user; negative values for x and/or y mean that the point is not in the visible viewport. Similarly, values for x greater the container width, or y greater than the container height, indicate that the point is not in the visible viewport.
591
+ *
592
+ * This method is useful when you want to position an element over the canvas at some specific canvas location. For instance, the SurfacePopup components use this to position themselves relative to the vertex they are currently referencing.
593
+ * @param left
594
+ * @param top
595
+ */
596
+ toViewportLocation(left: number, top: number): PointXY;
584
597
  /**
585
598
  * Binds to a mouse event occurring on a given model object. This is a wrapper around the `on` event binding method, which searches for an associated model object for the given event. For instance, you might have a node template that has a button inside of it that you want to respond to. When the button is clicked you want to know the node associated with the button. This method provides that. It is possible to find the associated model object yourself, via the `getObjectInfo` method of the Surface, called with the event's target, but this method does that for you.
586
599
  *
@@ -634,7 +647,7 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
634
647
  /**
635
648
  * Appends an element to the viewport so that it floats above the content that is being zoomed and panned. The element will have `position:absolute` set on it. You can float any element you like, but note that the responsibility for setting an appropriate z index is yours.
636
649
  * @param el Element to float.
637
- * @param pos Position to float the element at.
650
+ * @param pos Position to float the element at. This is in page coordinates, ie. it ignores the pan/zoom of the surface, and defines a position relative to the viewport's top/left corner.
638
651
  *
639
652
  */
640
653
  floatElement(el: BrowserElement, pos: PointXY): void;
@@ -209,10 +209,16 @@ export declare function linesOverlap(line1Point1: number, line1Point2: number, l
209
209
  */
210
210
  export declare function expandRectangle<T extends RectangleXY>(r: RectangleXY, deltaX: number, deltaY: number): T;
211
211
  /**
212
- * Find the intersection point of the two lines, which are treated as being of
213
- * unlimited length, ie. if both lines are of non-zero length and are not parallel, then
214
- * an intersection point is always returned even if they do not actually meet: their projections meet
215
- * at the point this method returns.
212
+ * Computes the bounding box union of two RectangleXY objects.
213
+ * This operation returns a new RectangleXY that is large enough to encompass both input rectangles.
214
+ *
215
+ * @param rect1 The first RectangleXY object.
216
+ * @param rect2 The second RectangleXY object.
217
+ * @returns A new RectangleXY object representing the union of the two input rectangles.
218
+ */
219
+ export declare function unionOfRectangles(rect1: RectangleXY, rect2: RectangleXY): RectangleXY;
220
+ /**
221
+ * Find the intersection point of the two lines, which are treated as being of unlimited length, ie. if both lines are of non-zero length and are not parallel, then an intersection point is always returned even if they do not actually meet: their projections meet at the point this method returns.
216
222
  * @param l1
217
223
  * @param l2
218
224
  * @internal
@@ -144,7 +144,7 @@ export interface GroupAddedParams {
144
144
  * @group Events
145
145
  * @category Payloads
146
146
  */
147
- export interface GroupRemovedParams {
147
+ export interface GroupRemovedParams extends VertexRemovedParams {
148
148
  /**
149
149
  * Group that was removed
150
150
  */
@@ -157,12 +157,24 @@ export interface GroupRemovedParams {
157
157
  * If children were removed, this is the list of them
158
158
  */
159
159
  children: Array<Node | Group>;
160
+ }
161
+ /**
162
+ * Base payload for a vertex removed event in the model
163
+ * @group Events
164
+ * @category Payloads
165
+ */
166
+ export interface VertexRemovedParams {
167
+ vertex: Node | Group;
160
168
  /**
161
- * If the group was a member of some other group, that group is provided here
169
+ * List of edges that are being removed as a result of this vertex's removal.
170
+ */
171
+ edges: Array<Edge>;
172
+ /**
173
+ * If the vertex was a member of some other group, that group is provided here
162
174
  */
163
175
  parentGroup?: Group;
164
176
  /**
165
- * Indicates that the group is being removed because some parent group is being removed and is forcing removal of its children.
177
+ * Indicates that the vertex is being removed because some parent group is being removed and is forcing removal of its children.
166
178
  */
167
179
  parentGroupIsBeingRemoved: boolean;
168
180
  }
@@ -171,23 +183,11 @@ export interface GroupRemovedParams {
171
183
  * @group Events
172
184
  * @category Payloads
173
185
  */
174
- export interface NodeRemovedParams {
186
+ export interface NodeRemovedParams extends VertexRemovedParams {
175
187
  /**
176
188
  * Node that was removed
177
189
  */
178
190
  node: Node;
179
- /**
180
- * List of edges that are being removed as a result of this node's removal.
181
- */
182
- edges: Array<Edge>;
183
- /**
184
- * If the node was a member of some other group, that group is provided here
185
- */
186
- parentGroup?: Group;
187
- /**
188
- * Indicates that the node is being removed because some parent group is being removed and is forcing removal of its children.
189
- */
190
- parentGroupIsBeingRemoved: boolean;
191
191
  }
192
192
  /**
193
193
  * Payload for a vertex updated event.
@@ -202,6 +202,9 @@ export interface VertexUpdatedParams {
202
202
  originalPortId?: string;
203
203
  reason: VertexUpdatedReason;
204
204
  port?: Port;
205
+ typeChanged?: boolean;
206
+ newType?: string;
207
+ previousType?: string;
205
208
  }
206
209
  /**
207
210
  * Payload for a port removed event.
@@ -226,6 +229,42 @@ export interface PortUpdatedParams {
226
229
  originalId: string;
227
230
  originalPortId?: string;
228
231
  }
232
+ /**
233
+ * Payload for an edge type changed event
234
+ */
235
+ export interface EdgeTypeChangedParams {
236
+ obj: Edge;
237
+ previousType: string;
238
+ newType: string;
239
+ isPartOfUpdate?: boolean;
240
+ }
241
+ /**
242
+ * Payload for a node type changed event
243
+ */
244
+ export interface NodeTypeChangedParams {
245
+ obj: Node;
246
+ previousType: string;
247
+ newType: string;
248
+ isPartOfUpdate?: boolean;
249
+ }
250
+ /**
251
+ * Payload for a port type changed event
252
+ */
253
+ export interface PortTypeChangedParams {
254
+ obj: Port;
255
+ previousType: string;
256
+ newType: string;
257
+ isPartOfUpdate?: boolean;
258
+ }
259
+ /**
260
+ * Payload for a group type changed event
261
+ */
262
+ export interface GroupTypeChangedParams {
263
+ obj: Group;
264
+ previousType: string;
265
+ newType: string;
266
+ isPartOfUpdate?: boolean;
267
+ }
229
268
  /**
230
269
  * Payload for an edge added event
231
270
  * @group Events
@@ -263,6 +302,9 @@ export interface EdgeUpdatedParams {
263
302
  updates: ObjectData;
264
303
  originalData: ObjectData;
265
304
  reason?: EdgeUpdatedReason;
305
+ typeChanged?: boolean;
306
+ newType?: string;
307
+ previousType?: string;
266
308
  }
267
309
  /**
268
310
  * @internal
@@ -88,11 +88,10 @@ export interface IndexEntry {
88
88
  key: string;
89
89
  }
90
90
  /**
91
- * Index for a dataset
91
+ * Reverse text index (think Lucene). This class operates on arbitrary Javascript objects and offers a method to search the fields of all documents. By default every field is searched, but you can control which fields to search via the options you pass to the constructor.
92
92
  * @group Search
93
- * @internal
94
93
  */
95
- declare class DatasetIndex {
94
+ export declare class DatasetIndex {
96
95
  fields: Array<string>;
97
96
  root: IndexEntry;
98
97
  tokenizer: Tokenizer;
@@ -145,10 +144,10 @@ export type SearchResults = {
145
144
  ports: Array<Port>;
146
145
  };
147
146
  /**
148
- * Search index.
147
+ * Search index for a Graph. This class wraps 4 indexes - one each for nodes, groups, ports and edges, and exposes a search method that searches across each of the indexes. By default every field in the data objects is searched, but you can control that via the options you pass to the constructor.
149
148
  * @group Search
150
149
  */
151
- export declare class Index {
150
+ export declare class GraphSearchIndex {
152
151
  instance: VisuallyJsModel;
153
152
  nodeIndex: DatasetIndex;
154
153
  groupIndex: DatasetIndex;
@@ -164,4 +163,3 @@ export declare class Index {
164
163
  */
165
164
  search(value: string): SearchResults;
166
165
  }
167
- export {};