@visuallyjs/browser-ui 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visuallyjs/browser-ui",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "license": "Commercial",
5
5
  "main": "js/visuallyjs.browser-ui.cjs.js",
6
6
  "module": "js/visuallyjs.browser-ui.esm.js",
@@ -236,8 +236,7 @@ export interface PanZoomOptions {
236
236
  */
237
237
  enabled?: boolean;
238
238
  /**
239
- * Optional filter that will be called on down event, with the event target and the event. Returning true
240
- * from this function means the widget should respond to the event.
239
+ * Optional filter that will be called on down event, with the event target and the event. Returning true from this function means the widget should respond to the event.
241
240
  */
242
241
  filter?: Function;
243
242
  /**
@@ -183,6 +183,7 @@ export declare class PanZoom {
183
183
  private _apparentOffset;
184
184
  private _canStartPanning;
185
185
  private handlers;
186
+ private _endPan;
186
187
  private _call;
187
188
  /**
188
189
  * Programmatically report a down event in order to kick the widget into action.
@@ -499,7 +500,7 @@ export declare class PanZoom {
499
500
  */
500
501
  mapEventLocation(event: MouseEvent): PointXY;
501
502
  /**
502
- * Sets whether or not the component should respond to mouse events.
503
+ * Sets whether or not the component should respond to mouse events. Resets any active pan operation - this can be invoked via the lasso arming itself after a long press.
503
504
  * @param state Whether or not to respond to mouse events.
504
505
  */
505
506
  setEnabled(state: boolean): void;
@@ -59,6 +59,14 @@ export interface LassoPluginOptions extends BrowserUIPluginOptions {
59
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
60
  */
61
61
  enableInGroups?: false | true | "metaKey";
62
+ /**
63
+ * Defaults to false. If true, the lasso will arm itself after a long press.
64
+ */
65
+ autoArm?: boolean;
66
+ /**
67
+ * Timeout in ms for autoArm long press. Defaults to 500ms.
68
+ */
69
+ armTimeout?: number;
62
70
  }
63
71
  /**
64
72
  * A Surface plugin that allows the user to select multiple elements with the mouse.
@@ -3,6 +3,9 @@ import { ViewportElement } from "../../../../ui";
3
3
  import { BrowserElement } from "../../../util";
4
4
  import { PointXY, Size } from "../../../../core";
5
5
  import { AutoPanHandler } from "../../../auto-pan-handler";
6
+ /**
7
+ * Options for a lasso
8
+ */
6
9
  export interface LassoOptions {
7
10
  canvas: Element;
8
11
  onStart?: (pagePosition: PointXY, canvasPosition: PointXY, shiftKey: boolean, e: MouseEvent, viewportElement: ViewportElement<BrowserElement> | null) => any;
@@ -14,6 +17,9 @@ export interface LassoOptions {
14
17
  * @param e
15
18
  */
16
19
  onClick?: (p: PointXY, e: MouseEvent) => any;
20
+ /**
21
+ * Set this to true to have the lasso drawn as set of overlays which mask the whole browser window except for the lassoed area.
22
+ */
17
23
  invert?: boolean;
18
24
  surface: Surface;
19
25
  filter?: ((e: MouseEvent) => boolean) | string;
@@ -34,6 +40,14 @@ export interface LassoOptions {
34
40
  * Defaults to true, meaning the canvas will pan automatically to track the lasso
35
41
  */
36
42
  autoPan?: boolean;
43
+ /**
44
+ * Defaults to false. If true, the lasso will arm itself after a long press.
45
+ */
46
+ autoArm?: boolean;
47
+ /**
48
+ * Timeout in ms for autoArm long press. Defaults to 500ms.
49
+ */
50
+ armTimeout?: number;
37
51
  }
38
52
  export declare class Lasso {
39
53
  visibleOrigin: PointXY;
@@ -69,6 +83,10 @@ export declare class Lasso {
69
83
  _enableInGroups: false | true | "metaKey";
70
84
  _generatedLassoContent: BrowserElement;
71
85
  _lastPageLocation: PointXY;
86
+ _autoArm: boolean;
87
+ _armTimeout: number;
88
+ _armTimer: any;
89
+ _armClickTriggered: boolean;
72
90
  constructor(options: LassoOptions);
73
91
  /**
74
92
  * list of selectors that should be filtered regardless of user preference
@@ -94,7 +94,13 @@ export interface VisuallyJsDefaultJSON {
94
94
  */
95
95
  groups?: Array<GroupData>;
96
96
  }
97
+ /**
98
+ * Defines the default JSON datatype
99
+ */
97
100
  export declare const JSON_DATATYPE = "json";
101
+ /**
102
+ * Defines the hierarchical json datatype
103
+ */
98
104
  export declare const HIERARCHICAL_JSON_DATATYPE = "hierarchical-json";
99
105
  /**
100
106
  * Register a parser for some given datatype
@@ -0,0 +1,69 @@
1
+ import { AbstractLayout, InternalLayoutOptions, LayoutParameters } from "../abstract-layout";
2
+ import { HasIdAndType, Vertex } from "../../model/graph";
3
+ import { PointXY, Size } from "../../util";
4
+ import { DataSource } from "../../datasource";
5
+ import { CircularLayoutParameters } from "../circular";
6
+ /**
7
+ * Bowtie layout type.
8
+ * @group Layouts
9
+ * @category Bowtie
10
+ */
11
+ export declare const LAYOUT_TYPE_BOWTIE = "Bowtie";
12
+ /**
13
+ * Options for the Bowtie layout
14
+ * @group Layouts
15
+ * @category Hierarchy
16
+ */
17
+ export interface BowtieLayoutParameters extends LayoutParameters {
18
+ /**
19
+ * Whether to draw the layout horizontally or vertically. Defaults to "horizontal".
20
+ */
21
+ axis?: "horizontal" | "vertical";
22
+ /**
23
+ * Optional node to use as the root. You must provide this or `getRootNode`.
24
+ */
25
+ rootNode?: Vertex | string;
26
+ /**
27
+ * Optional function you can provide that will dynamically be invoked to get the root node to use. You must provide this or `rootNode`.
28
+ */
29
+ getRootNode?: (dataSource: DataSource) => Vertex | string;
30
+ /**
31
+ * Gets immediate upstream nodes for the focus vertex. Only invoked with the focus vertex.
32
+ * @param dataSource
33
+ * @param vertex
34
+ */
35
+ getUpstream: (dataSource: DataSource, vertex: HasIdAndType) => Array<HasIdAndType>;
36
+ /**
37
+ * Gets immediate downstream nodes for the focus vertex. Only invoked with the focus vertex.
38
+ * @param dataSource
39
+ * @param vertex
40
+ */
41
+ getDownstream: (dataSource: DataSource, vertex: HasIdAndType) => Array<HasIdAndType>;
42
+ /**
43
+ * Optional function to invoke on any non-focus vertex, to get the vertex's children. Will not be invoked with the focus vertex. If this function returns the focus vertex in its set it will be filtered out. When you do not provide this function, VisuallyJs will find all vertices that are targets of edges for which this vertex is a source.
44
+ */
45
+ childVerticesFunction?: (node: HasIdAndType, dataSource: DataSource) => Array<HasIdAndType>;
46
+ }
47
+ /**
48
+ * Places the focus vertex in the center of the canvas and then branches out to the left and right - or top and bottom - with children of the focus. You are expected to supply a `getUpstream` and `getDownstream` function for this layout, as well as either `getRootNode` or `rootNode`. `getUpstream` is used to get the immediate children of the focus vertex that will be painted to the left or above, depending on axis. `getDownstream` is used to get the immediate children of the focus vertex that will be painted to the right or below. By default this layout will draw horizontally, which you can change by setting `axis:"vertical"`.
49
+ * @group Layouts
50
+ * @category Bowtie
51
+ */
52
+ export declare class BowtieLayout extends AbstractLayout<BowtieLayoutParameters> {
53
+ focusVertex: Vertex;
54
+ static type: string;
55
+ readonly type = "Bowtie";
56
+ private readonly _getRootNode;
57
+ private readonly _rootNode;
58
+ private _axis;
59
+ private _getUpstreamVertices;
60
+ private _getDownstreamVertices;
61
+ private _childVerticesFunction;
62
+ private _defaultGetDownstream;
63
+ constructor(params: InternalLayoutOptions<BowtieLayoutParameters>);
64
+ begin(dataSource: DataSource, positionGetter: (id: string) => PointXY, positionSetter: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: CircularLayoutParameters): void;
65
+ end(dataSource: DataSource, getPosition: (id: string) => PointXY, setPosition: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: BowtieLayoutParameters): void;
66
+ getDefaultParameters(): BowtieLayoutParameters;
67
+ reset(): void;
68
+ step(dataSource: DataSource, getPosition: (id: string) => PointXY, setPosition: (id: string, x: number, y: number) => void, sizes: Record<string, Size>, parameters: BowtieLayoutParameters): void;
69
+ }
@@ -0,0 +1 @@
1
+ export * from "./bowtie-layout";
@@ -1,5 +1,4 @@
1
1
  import { AbstractEdgeTerminus, Edge, Group, HasId, HasIdAndType, Node } from "../../model/graph";
2
- import { VisuallyJsModel } from "../../toolkit";
3
2
  import { AbsoluteBackedLayoutParameters } from "../absolute-layout";
4
3
  import { PlacementStageStrategy } from "./placement-stage";
5
4
  import { HierarchyLayout } from "./hierarchy-layout";
@@ -7,6 +6,7 @@ import { VertexSet } from "./vertex-set";
7
6
  import { LayoutLayerEntry, LayoutLayerOrdering } from "../abstract-layout";
8
7
  import { GatedPath } from "../../router";
9
8
  import { PointXY, Size } from "../../util";
9
+ import { DataSource } from "../../datasource";
10
10
  /**
11
11
  * @internal
12
12
  */
@@ -21,7 +21,7 @@ export declare const VERTEX = "vertex";
21
21
  * @category Hierarchy
22
22
  * @typeParam T Defines the type of the object from which child vertices will be retrieved, and the type of the child vertices.
23
23
  */
24
- export type ChildVerticesFunction<T extends HasId> = (node: T, layer: number, instance: VisuallyJsModel) => Array<T>;
24
+ export type ChildVerticesFunction<T extends HasId> = (node: T, layer: number, instance: DataSource) => Array<T>;
25
25
  /**
26
26
  * Axis types for a {@link HierarchyLayout}
27
27
  * @group Layouts
@@ -1,7 +1,7 @@
1
1
  import { ParentRelativePlacementStrategyOptions } from "./definitions";
2
2
  import { HasIdAndType } from "../../model/graph";
3
3
  import { PointXY } from "../../util";
4
- import { VisuallyJsModel } from "../../toolkit";
4
+ import { DataSource } from "../../datasource";
5
5
  /**
6
6
  * Places elements with respect to their parents, aligning them at parent start/end/center depending on the value of `alignment`.
7
7
  * @internal
@@ -34,7 +34,7 @@ export declare class ParentRelativePlacementStrategy<T extends HasIdAndType> {
34
34
  private readonly _getSize;
35
35
  private readonly _getChildVertices;
36
36
  private readonly _absolutePositionFunction;
37
- constructor(model: VisuallyJsModel, parameters: ParentRelativePlacementStrategyOptions<T>);
37
+ constructor(model: DataSource, parameters: ParentRelativePlacementStrategyOptions<T>);
38
38
  execute(): Map<string, {
39
39
  position: PointXY;
40
40
  layer: number;
@@ -8,3 +8,4 @@ export * from './grid';
8
8
  export * from './force-directed';
9
9
  export * from './hierarchical';
10
10
  export * from './hierarchy';
11
+ export * from './bowtie';
@@ -836,6 +836,8 @@ export declare abstract class Vertex extends Base implements AbstractEdgeTerminu
836
836
  * Gets all Edges where this Vertex is the target.
837
837
  */
838
838
  getTargetEdges(): Array<Edge>;
839
+ getAllSourceEdges(): Edge[];
840
+ getAllTargetEdges(): Edge[];
839
841
  /**
840
842
  * Adds an Edge to the vertex.
841
843
  * @param edge The Edge to add.
@@ -41,6 +41,7 @@ export interface SynthesizedEvent {
41
41
  pageX: number;
42
42
  pageY: number;
43
43
  }
44
+ declare function _createMouseEventWithPageLoc(el: Element, evt: string, pageLoc: PointXY, metaKeys?: Record<string, boolean>, button?: number): void;
44
45
  /**
45
46
  * Callbacks you can provide to connection drag methods in the TestHarness to interrupt the process
46
47
  * and inspect what's going on.
@@ -97,6 +98,7 @@ export declare const VisuallyJsTestSupport: {
97
98
  nudgeEvent: typeof _nudgeEvent;
98
99
  getEdgeCanvas: typeof getEdgeCanvas;
99
100
  defaultEventManager: EventManager;
101
+ createMouseEventWithPageLoc: typeof _createMouseEventWithPageLoc;
100
102
  /**
101
103
  * Drag any DOM element around, not just elements managed by the surface.
102
104
  * @param el
@@ -1 +1 @@
1
- export declare const VERSION = "1.2.3";
1
+ export declare const VERSION = "1.2.4";