@visuallyjs/browser-ui 1.2.3 → 1.2.5

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 (66) hide show
  1. package/css/visuallyjs.css +34 -16
  2. package/js/visuallyjs.browser-ui.cjs.js +91 -59
  3. package/js/visuallyjs.browser-ui.esm.js +91 -59
  4. package/package.json +1 -1
  5. package/types/browser-ui/browser-util.d.ts +0 -7
  6. package/types/browser-ui/browser-visuallyjs-instance.d.ts +1 -0
  7. package/types/browser-ui/components/controls/controls-component.d.ts +8 -0
  8. package/types/browser-ui/components/index.d.ts +1 -0
  9. package/types/browser-ui/components/palette/auto-edge-connect.d.ts +74 -0
  10. package/types/browser-ui/components/palette/definitions.d.ts +50 -0
  11. package/types/browser-ui/components/palette/index.d.ts +3 -0
  12. package/types/browser-ui/components/palette/palette-options.d.ts +59 -2
  13. package/types/browser-ui/components/palette/palette.d.ts +25 -15
  14. package/types/browser-ui/components/palette/util.d.ts +21 -0
  15. package/types/browser-ui/components/rotate-manager.d.ts +27 -0
  16. package/types/browser-ui/constants.d.ts +5 -2
  17. package/types/browser-ui/css-constants.d.ts +28 -2
  18. package/types/browser-ui/definitions.d.ts +1 -1
  19. package/types/browser-ui/edge-handler-base.d.ts +20 -1
  20. package/types/browser-ui/edge-input-handler.d.ts +1 -18
  21. package/types/browser-ui/element-drag-handler-2.d.ts +4 -2
  22. package/types/browser-ui/event-manager.d.ts +7 -0
  23. package/types/browser-ui/index.d.ts +2 -1
  24. package/types/browser-ui/keyboard/index.d.ts +1 -0
  25. package/types/browser-ui/keyboard/keyboard-listener.d.ts +7 -0
  26. package/types/browser-ui/pan-zoom-options.d.ts +6 -2
  27. package/types/browser-ui/pan-zoom.d.ts +4 -2
  28. package/types/browser-ui/paper-renderer/paper.d.ts +1 -0
  29. package/types/browser-ui/positioning-and-sizing-utils.d.ts +5 -0
  30. package/types/browser-ui/shape-library/shape-library-definitions.d.ts +28 -8
  31. package/types/browser-ui/shape-library/shape-library.d.ts +3 -3
  32. package/types/browser-ui/surface-renderer/css-classes.d.ts +8 -0
  33. package/types/browser-ui/surface-renderer/diagrams/definitions.d.ts +41 -4
  34. package/types/browser-ui/surface-renderer/diagrams/diagram.d.ts +11 -1
  35. package/types/browser-ui/surface-renderer/diagrams/mediator.d.ts +7 -7
  36. package/types/browser-ui/surface-renderer/plugins/lasso/lasso-plugin.d.ts +8 -0
  37. package/types/browser-ui/surface-renderer/plugins/lasso/lasso.d.ts +19 -1
  38. package/types/browser-ui/surface-renderer/plugins/resizing-tools/resizing-tools-plugin.d.ts +4 -3
  39. package/types/browser-ui/surface-renderer/shape-palette-options.d.ts +31 -3
  40. package/types/browser-ui/surface-renderer/shape-palette.d.ts +1 -0
  41. package/types/browser-ui/surface-renderer/surface.d.ts +15 -1
  42. package/types/core/datasource.d.ts +1 -1
  43. package/types/core/geom.d.ts +6 -0
  44. package/types/core/io.d.ts +23 -3
  45. package/types/core/layout/bowtie/bowtie-layout.d.ts +69 -0
  46. package/types/core/layout/bowtie/index.d.ts +1 -0
  47. package/types/core/layout/hierarchy/definitions.d.ts +2 -2
  48. package/types/core/layout/hierarchy/parent-relative-placement.d.ts +2 -2
  49. package/types/core/layout/index.d.ts +1 -0
  50. package/types/core/model/graph.d.ts +8 -2
  51. package/types/core/model/group-template.d.ts +4 -2
  52. package/types/core/params.d.ts +4 -4
  53. package/types/core/rtree/definitions.d.ts +5 -5
  54. package/types/core/rtree/rtree.d.ts +2 -2
  55. package/types/core/rtree/util.d.ts +2 -1
  56. package/types/core/toolkit.d.ts +7 -3
  57. package/types/test-support/test-support.d.ts +47 -1
  58. package/types/ui/common/anchor.d.ts +0 -4
  59. package/types/ui/common/overlay.d.ts +13 -1
  60. package/types/ui/core/constants.d.ts +24 -0
  61. package/types/ui/core/core.d.ts +40 -8
  62. package/types/ui/core/definitions.d.ts +12 -5
  63. package/types/ui/core/factory/anchor-record-factory.d.ts +6 -1
  64. package/types/ui/core/type-descriptors.d.ts +2 -2
  65. package/types/ui/core/view/group-options.d.ts +4 -0
  66. package/types/version.d.ts +1 -1
@@ -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';
@@ -202,8 +202,8 @@ export interface InternalAddEdgeOptions {
202
202
  directed?: boolean;
203
203
  transient?: boolean;
204
204
  anchors?: {
205
- source?: ObjectAnchorSpec;
206
- target?: ObjectAnchorSpec;
205
+ source?: any;
206
+ target?: any;
207
207
  };
208
208
  }
209
209
  /**
@@ -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.
@@ -1043,6 +1045,10 @@ export declare class Group extends Node {
1043
1045
  * @internal
1044
1046
  */
1045
1047
  _memberMap: Record<string, Node>;
1048
+ /**
1049
+ * @internal
1050
+ */
1051
+ locked: boolean;
1046
1052
  constructor(graph: Graph, data?: any, idFunction?: IdFunction);
1047
1053
  /**
1048
1054
  * @internal
@@ -8,8 +8,10 @@ export interface GroupTemplate {
8
8
  groupTemplate?: string | GroupTemplate;
9
9
  }>;
10
10
  edges?: Array<{
11
- source: string;
12
- target: string;
11
+ source?: string;
12
+ sourcePort?: string;
13
+ target?: string;
14
+ targetPort?: string;
13
15
  data?: ObjectData;
14
16
  }>;
15
17
  }
@@ -3,7 +3,7 @@ import { VisuallyJsRenderer } from "./renderer";
3
3
  import { PointXY } from "./util";
4
4
  import { EdgeUpdatedReason, VertexUpdatedReason } from "./toolkit";
5
5
  import { VisuallyJsSelection } from "./selection";
6
- import { ObjectAnchorSpec } from "./model/anchor";
6
+ import { LineStyle, SingleAnchorSpec } from "../ui";
7
7
  /**
8
8
  * Defines the payload for a node added event.
9
9
  * @group Events
@@ -495,7 +495,7 @@ export interface AddEdgeOptions {
495
495
  /**
496
496
  * Optional backing data for the edge.
497
497
  */
498
- data?: any;
498
+ data?: ObjectData & LineStyle;
499
499
  /**
500
500
  * Optional edge cost. Defaults to 1.
501
501
  */
@@ -512,7 +512,7 @@ export interface AddEdgeOptions {
512
512
  * Optional anchors for the edge.
513
513
  */
514
514
  anchors?: {
515
- source?: ObjectAnchorSpec;
516
- target?: ObjectAnchorSpec;
515
+ source?: SingleAnchorSpec;
516
+ target?: SingleAnchorSpec;
517
517
  };
518
518
  }
@@ -4,10 +4,10 @@ import { RectangleXY } from "../util";
4
4
  * Base region used by RTree
5
5
  * @internal
6
6
  */
7
- export interface RTreeRegion extends RectangleXY {
8
- data?: ObjectData;
9
- children: Array<RTreeRegion>;
10
- parent?: RTreeRegion;
7
+ export interface RTreeRegion<DataPayload extends ObjectData = ObjectData> extends RectangleXY {
8
+ data?: DataPayload;
9
+ children: Array<RTreeRegion<DataPayload>>;
10
+ parent?: RTreeRegion<DataPayload>;
11
11
  id?: string;
12
12
  }
13
13
  /**
@@ -19,6 +19,6 @@ export declare const RTREE_DEFAULT_MAX_CHILD_ENTRIES = 4;
19
19
  * A data node in an RTree
20
20
  * @internal
21
21
  */
22
- export interface RTreeDataNode extends RTreeRegion {
22
+ export interface RTreeDataNode<DataPayload extends ObjectData = ObjectData> extends RTreeRegion<DataPayload> {
23
23
  id: string;
24
24
  }
@@ -23,7 +23,7 @@ export interface RTreeSearchOptions {
23
23
  * An RTree. Used internally to facilitate fast spatial querying.
24
24
  * @internal
25
25
  */
26
- export declare class RTree {
26
+ export declare class RTree<DataPayload extends ObjectData = ObjectData> {
27
27
  private readonly _maxNodes;
28
28
  private _root;
29
29
  private _dataNodes;
@@ -33,7 +33,7 @@ export declare class RTree {
33
33
  * @param searchBoundary
34
34
  * @param options
35
35
  */
36
- search(searchBoundary: RectangleXY, options?: RTreeSearchOptions): Array<RTreeDataNode>;
36
+ search(searchBoundary: RectangleXY, options?: RTreeSearchOptions): Array<RTreeDataNode<DataPayload>>;
37
37
  /**
38
38
  * Search the tree and find all entries that intersect the given rectangle, then rank them by the amount they overlap.
39
39
  * @param searchBoundary
@@ -1,4 +1,5 @@
1
1
  import { RTreeRegion } from "./definitions";
2
+ import { ObjectData } from "../model/graph";
2
3
  export declare function _growToFit(rectToGrow: RTreeRegion, otherRect: RTreeRegion): void;
3
4
  /**
4
5
  * Adjust the bounds of `rect` so that they fit the bounds of its children, then if the rect has a parent, traverse up to the parent
@@ -14,7 +15,7 @@ export declare function splitIntoSiblings(r: RTreeRegion): [RTreeRegion, RTreeRe
14
15
  * @private
15
16
  * @internal
16
17
  */
17
- export declare function _emptyRTreeRegion(id?: string): RTreeRegion;
18
+ export declare function _emptyRTreeRegion<DataPayload extends ObjectData = ObjectData>(id?: string): RTreeRegion<DataPayload>;
18
19
  /**
19
20
  * Return whether or not the given region is a leaf
20
21
  * @param r
@@ -16,6 +16,7 @@ import { PointXY, Geometry } from "./util";
16
16
  import { OptimisticEventGenerator } from "./event-generator";
17
17
  import { ProxyLocation } from "./constants";
18
18
  import { GroupTemplate } from "./model/group-template";
19
+ import { SingleAnchorSpec } from "../ui";
19
20
  /**
20
21
  * Definition of a function to use as a beforeConnect interceptor.
21
22
  * @param source The source vertex for the new edge
@@ -550,11 +551,11 @@ export declare abstract class VisuallyJsModel extends OptimisticEventGenerator i
550
551
  */
551
552
  getDescendants(vertex: Group): Array<Node | Group>;
552
553
  /**
553
- * Gets a list of groups that are ancestors of the given node/group. The list of ancestors is ordered in terms of their proximity to the focus, ie. the first entry is the focus vertex's immediate parent.
554
+ * Gets a list of groups that are ancestors of the given node/group (or port, for which we first resolve the node/group it resides on). The list of ancestors is ordered in terms of their proximity to the focus, ie. the first entry is the focus vertex's immediate parent.
554
555
  * @param vertex
555
556
  *
556
557
  */
557
- getAncestors(vertex: Node | Group): Array<Group>;
558
+ getAncestors(vertex: Vertex): Array<Group>;
558
559
  /**
559
560
  * Returns whether or not `possibleAncestor` is in fact an ancestor of the given focus node/group
560
561
  * @param focus Vertex to test
@@ -722,7 +723,10 @@ export declare abstract class VisuallyJsModel extends OptimisticEventGenerator i
722
723
  * @param context
723
724
  * @internal
724
725
  */
725
- $addTransientEdge(renderer: VisuallyJsRenderer<any>, source: Vertex, target: Vertex, data?: ObjectData, geometry?: Geometry, context?: Record<string, any>): Edge;
726
+ $addTransientEdge(renderer: VisuallyJsRenderer<any>, source: string | Vertex, target: string | Vertex, data?: ObjectData, geometry?: Geometry, context?: Record<string, any>, anchors?: {
727
+ source?: SingleAnchorSpec;
728
+ target?: SingleAnchorSpec;
729
+ }): Edge;
726
730
  /**
727
731
  * Adds a Group by type, running the data generation for the node through the current GroupFactory. This is different from `addGroup` in that with `addGroup` you are supplying the final data and your GroupFactory is not called. This method can be called with one, two or three arguments. A single argument is considered to be the new Group's `type`, and a backing data object will be created with this set, and no callback will occur. If you provide two arguments the second argument may be either the new Group's backing data OR a callback to hit with the newly created Group. With three arguments the second argument is the Group's backing data and the third is a callback to hit with the newly created Group.
728
732
  * @param type Required. Type of the object to create. `type` will be passed as the first argument to your group factory.
@@ -41,6 +41,8 @@ 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;
45
+ declare function _createKeyboardEvent(el: Element, type: string, key: string, modifiers?: Record<string, boolean>): void;
44
46
  /**
45
47
  * Callbacks you can provide to connection drag methods in the TestHarness to interrupt the process
46
48
  * and inspect what's going on.
@@ -62,6 +64,37 @@ export interface DragEventHandlers {
62
64
  afterMove?: Function;
63
65
  afterUp?: Function;
64
66
  }
67
+ /**
68
+ * Hadlers you can pass as an argument to palette drag handlers,
69
+ */
70
+ export interface PaletteEventHandlers {
71
+ /**
72
+ * Fired before the mousedown event is posted
73
+ */
74
+ beforeDown?: Function;
75
+ /**
76
+ * Fired before an initial move event is posted
77
+ */
78
+ beforeMove?: Function;
79
+ /**
80
+ * fired after the initial move event is posted and before the 2nd move event is posted
81
+ */
82
+ afterMove?: Function;
83
+ /**
84
+ * Fired after the 2nd move event, before the up event
85
+ */
86
+ beforeUp?: Function;
87
+ /**
88
+ * Fired after the operation has been completed
89
+ */
90
+ after?: Function;
91
+ }
92
+ export type PaletteDragHarness = {
93
+ start: () => any;
94
+ move: () => any;
95
+ up: () => any;
96
+ end: () => any;
97
+ };
65
98
  /**
66
99
  * Synthesize an event
67
100
  * @param l
@@ -97,6 +130,8 @@ export declare const VisuallyJsTestSupport: {
97
130
  nudgeEvent: typeof _nudgeEvent;
98
131
  getEdgeCanvas: typeof getEdgeCanvas;
99
132
  defaultEventManager: EventManager;
133
+ createMouseEventWithPageLoc: typeof _createMouseEventWithPageLoc;
134
+ keyEvent: typeof _createKeyboardEvent;
100
135
  /**
101
136
  * Drag any DOM element around, not just elements managed by the surface.
102
137
  * @param el
@@ -459,6 +494,14 @@ export declare class TestHarness {
459
494
  * @param data
460
495
  */
461
496
  triggerEventAt(el: HTMLElement, eventName: string, x: number, y: number, data?: Record<string, any>): void;
497
+ /**
498
+ * Dispatch a keyboard event of the given type on the given element, with the given key code.
499
+ * @param el Element to dispatch the event on.
500
+ * @param type Type of event, e.g. "keydown", "keyup", "keypress".
501
+ * @param key
502
+ * @param modifiers Optional modifiers for the event.
503
+ */
504
+ keyEvent(el: Element, type: string, key: string, modifiers?: Record<string, boolean>): void;
462
505
  /**
463
506
  * Synthesize an event for the given object. This method is used by other parts of the test harness class
464
507
  * and is not something a user of the API will necessarily need to make use of.
@@ -742,8 +785,11 @@ export declare class TestHarness {
742
785
  * @param edgeOrEdgeId
743
786
  */
744
787
  dblTapOnEdge(edgeOrEdgeId: string | Edge): void;
788
+ private _addFromPaletteInit;
745
789
  private _addFromPalette;
746
- dragFromPalette(palette: Palette<any>, selector: string, options?: any): void;
790
+ private _addFromPaletteASync;
791
+ dragFromPalette(palette: Palette<any>, selector: string, options?: any, metaKeys?: Record<string, boolean>): void;
792
+ dragFromPaletteAsync(palette: Palette<any>, selector: string, options?: any, metaKeys?: Record<string, boolean>): PaletteDragHarness;
747
793
  tapFromPalette(palette: Palette<any>, selector: string, options?: any): void;
748
794
  /**
749
795
  * Trigger a mousedown event on the edge with the given id.
@@ -1,7 +1,3 @@
1
- /**
2
- * Common options for anchors.
3
- *
4
- */
5
1
  import { PointXY, Size, Rotations, AnchorOrientationHint, ObjectAnchorSpec } from "../../core";
6
2
  import { Connection } from "../core";
7
3
  export type Orientation = Record<"y" | "x", AnchorOrientationHint>;
@@ -1,6 +1,7 @@
1
1
  import { PaintStyle } from './paint-style';
2
2
  import { OverlayEvents, OverlayVisibility } from "../core/overlay/overlay";
3
3
  import { FontSpec } from "../../browser-ui";
4
+ import { Edge } from "../../core";
4
5
  /**
5
6
  * Base options for an overlay.
6
7
  * @group Edges
@@ -111,7 +112,18 @@ export type FullOverlaySpec = {
111
112
  */
112
113
  options: OverlayOptions;
113
114
  };
114
- export type InternalOverlaySpec = FullOverlaySpec & {
115
+ export interface InternalOverlayOptions extends OverlayOptions {
116
+ shouldAddToEdge?: (e: Edge) => boolean;
117
+ }
118
+ export type InternalOverlaySpec = {
119
+ /**
120
+ * Overlay type
121
+ */
122
+ type: string;
123
+ /**
124
+ * Options for the overlay
125
+ */
126
+ options: InternalOverlayOptions;
115
127
  sourceMarker?: boolean;
116
128
  targetMarker?: boolean;
117
129
  };
@@ -163,6 +163,30 @@ export declare const ATTRIBUTE_VJS_TARGET_PORT_TYPE = "data-vjs-target-port-type
163
163
  * @context edge-dragging
164
164
  */
165
165
  export declare const ATTRIBUTE_VJS_MAGNET = "data-vjs-magnet";
166
+ /**
167
+ * Specifies the anchor to use for both source and target of an edge connected to some element, when an edge is dragged from that element as the source.
168
+ * @group Nodes and Groups
169
+ * @category DOM Attributes
170
+ * @domAttribute
171
+ * @context edge-dragging
172
+ */
173
+ export declare const ATTRIBUTE_VJS_ANCHOR = "data-vjs-anchor";
174
+ /**
175
+ * Specifies the anchor to use for the source of an edge connected to some element, when an edge is dragged from that element.
176
+ * @group Nodes and Groups
177
+ * @category DOM Attributes
178
+ * @domAttribute
179
+ * @context edge-dragging
180
+ */
181
+ export declare const ATTRIBUTE_VJS_SOURCE_ANCHOR = "data-vjs-source-anchor";
182
+ /**
183
+ * Specifies the anchor to use for the target of an edge connected to some element, when an edge is dragged from that element.
184
+ * @group Nodes and Groups
185
+ * @category DOM Attributes
186
+ * @domAttribute
187
+ * @context edge-dragging
188
+ */
189
+ export declare const ATTRIBUTE_VJS_TARGET_ANCHOR = "data-vjs-target-anchor";
166
190
  /**
167
191
  * Attribute written by VisuallyJs to store edge id on its visual representation.
168
192
  * @group Edges
@@ -6,7 +6,7 @@ import { ConnectionEstablishedParams } from "./callbacks";
6
6
  import { Viewport, ViewportElement, ViewportGroupElement, ViewportNodeElement } from "./viewport";
7
7
  import { ComponentBase } from './component/component';
8
8
  import { LabelOverlay } from './overlay/label-overlay';
9
- import { AnchorSpec, LightweightAnchor, FullOverlaySpec, OverlaySpec, Connector, PaintStyle, ConnectorSpec } from "../common";
9
+ import { AnchorSpec, LightweightAnchor, FullOverlaySpec, OverlaySpec, Connector, PaintStyle, ConnectorSpec, SingleAnchorSpec } from "../common";
10
10
  import { GroupRelayoutReason } from './event-constants';
11
11
  import { Connection } from "./connector/connection-impl";
12
12
  import { Base, Edge, Group, Node, ObjectData, Port, Vertex, IntersectingVertex, PortRemovedParams, PortAddedParams, ProxyLocation, ObjectAnchorSpec } from "../../core";
@@ -15,7 +15,7 @@ import { GroupMapping, NodeMapping, NodeOrGroupMapping, PortMapping, VertexMappi
15
15
  import { Magnetizer, MagnetizeResult } from "../../core/magnetizer";
16
16
  import { AbstractLayout, LayoutParameters, LayoutResultSet } from "../../core/layout/abstract-layout";
17
17
  import { DataSource, EdgeAddedParams, EdgeRemovedParams, EdgeSourceChangedParams, EdgeTargetChangedParams, Extents, FilterableDataset, Grid, GroupAddedParams, GroupMemberAddedParams, GroupMemberRemovedParams, GroupRemovedParams, NodeAddedParams, NodeRemovedParams, OptimisticEventGenerator, PointXY, RectangleXY, VisuallyJsSelection, Size, VisuallyJsRenderer, VertexUpdatedParams, VisuallyJsModel, SaveOptions, Rotations, AbstractLayoutAdapter } from "../../core";
18
- import { DataHook, ElementType, EnclosedVerticesOptions, GroupContentAreaInfo, GroupResizeResult, IntersectingVerticesOptions, UIExportOptions, UISaveData, ViewportBounds, ZoomToElementsOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions } from "./definitions";
18
+ import { DataHook, ElementType, EnclosedVerticesOptions, GroupContentAreaInfo, GroupResizeResult, IntersectingVerticesOptions, UICapabilities, UIExportOptions, UISaveData, ViewportBounds, ZoomToElementsOptions, ZoomToFitIfNecessaryOptions, ZoomToFitOptions } from "./definitions";
19
19
  import { GridProfile } from "./grid-profile";
20
20
  import { MagnetizeProfile } from "./magnetize-profile";
21
21
  import { UIPlugin, UIPluginOptions, UIPluginSpec } from "../plugins/definitions";
@@ -109,6 +109,8 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
109
109
  $_discardEdgeEditsOnDrag: boolean;
110
110
  $_vertexBuffer: number;
111
111
  $_vertexBorder: number;
112
+ private _installedCapabilities;
113
+ private _installedCapabilitiesConfigurationProviders;
112
114
  private _$_edgesAvoidVertices;
113
115
  readonly viewport: Viewport<EL>;
114
116
  readonly router: Router<EL>;
@@ -128,6 +130,17 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
128
130
  * @internal
129
131
  */
130
132
  protected $isInMotion: boolean;
133
+ /**
134
+ * Mark a group as "locked" : edges inside of it cannot be detached, removed or have their paths edited, edges cannot be established to child vertices.
135
+ * @param groupIdOrGroup
136
+ */
137
+ lockGroup(groupIdOrGroup: string | Group): void;
138
+ $isGroupDefinedAsLocked(g: Group): boolean;
139
+ /**
140
+ * Unlock a group.
141
+ * @param groupIdOrGroup
142
+ */
143
+ unlockGroup(groupIdOrGroup: string | Group): void;
131
144
  magnetizerProfile: MagnetizeProfile;
132
145
  protected magnetizer: Magnetizer<Vertex>;
133
146
  /**
@@ -244,6 +257,22 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
244
257
  * @param size
245
258
  */
246
259
  abstract $setGroupElementSize(group: Group, size: Size): void;
260
+ /**
261
+ * Test whether the specific capability is available on this instance of the UI.
262
+ * @param c
263
+ */
264
+ $hasCapability(c: UICapabilities): boolean;
265
+ /**
266
+ * Gets the config for some capability. May be an empty object. A capability provider may be registered at the point that a capability is registered - the function is provided by the code that registers the capability.
267
+ * @param c
268
+ */
269
+ $getCapabilityConfig(c: UICapabilities): Record<string, any>;
270
+ /**
271
+ * For subclasses/plugins/component to use to register that a specific capability is available. It is not possible for external code to say a capability is _not_ available, only that one is.
272
+ * @param c
273
+ * @internal
274
+ */
275
+ $setCapabilityAvailable(c: UICapabilities, configProvider?: () => Record<string, any>): void;
247
276
  /**
248
277
  * Notification from the model that the target for some edge has changed.
249
278
  * @param data
@@ -373,8 +402,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
373
402
  */
374
403
  private $flushUnrenderedEdges;
375
404
  /**
376
- * Check to see if an edge can be rendered (ie. there is an element available for both its source and target), and
377
- * if so, render it.
405
+ * Check to see if an edge can be rendered (ie. there is an element available for both its source and target), and if so, render it.
378
406
  * @internal
379
407
  */
380
408
  private _maybeRenderEdge;
@@ -642,7 +670,7 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
642
670
  * @param _doNotRepaint - For internal use.
643
671
  * @internal
644
672
  */
645
- private _rotateElement;
673
+ $rotateElement(vertex: Vertex | string, rotation: number, _doNotRepaint: boolean, animate: boolean): void;
646
674
  abstract $isTouchDevice(): boolean;
647
675
  abstract $syncManagedElementWithView(mel: ViewportElement<EL>, andThenRepaint: boolean): void;
648
676
  /**
@@ -1559,11 +1587,12 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
1559
1587
  * @param style
1560
1588
  * @param clazz
1561
1589
  * @param atts
1590
+ * @param EL the element to use, instead of creating one.
1562
1591
  * @internal
1563
1592
  */
1564
- $addTransientVertex(position: PointXY, size: Size, data?: ObjectData, style?: Record<string, any>, clazz?: string, atts?: Record<string, string>): {
1593
+ $addTransientVertex(position: PointXY, size: Size, data?: ObjectData, style?: Record<string, any>, clazz?: string, atts?: Record<string, string>, element?: EL): {
1565
1594
  vertex: Node;
1566
- el: ViewportElement<EL>;
1595
+ el: ViewportNodeElement<EL>;
1567
1596
  };
1568
1597
  /**
1569
1598
  * Renders a dummy vertex. The model calls this at various points in the lifecycle.
@@ -1587,7 +1616,10 @@ export declare abstract class UICore<EL, EVT = CoreUIEvent> extends OptimisticEv
1587
1616
  * @param data
1588
1617
  * @internal
1589
1618
  */
1590
- $addTransientEdge(source: Vertex, target: Vertex, data?: ObjectData, context?: Record<string, any>): Edge;
1619
+ $addTransientEdge(source: Vertex, target: Vertex, data?: ObjectData, context?: Record<string, any>, anchors?: {
1620
+ source?: SingleAnchorSpec;
1621
+ target?: SingleAnchorSpec;
1622
+ }): Edge;
1591
1623
  /**
1592
1624
  * Tests if the given edge type may be unattached at its source and/or target. An edge type might mandate some
1593
1625
  * preference for that, or it may have been set via the `allowUnattached` flag in the edges defaults.
@@ -1,10 +1,7 @@
1
1
  import { ViewportElement, ViewportGroupElement } from "./viewport";
2
- import { Extents, PointXY, Size, Group, Node, Vertex } from "../../core";
3
- import { ExportOptions, VisuallyJsModel } from "../../core/toolkit";
2
+ import { Extents, PointXY, Size, Group, Node, Vertex, BOTTOM, CENTER, LEFT, RIGHT, TOP, ExportOptions, VisuallyJsModel, MagnetizeResult } from "../../core";
4
3
  import { MagnetizeProfile } from "./magnetize-profile";
5
- import { MagnetizeResult } from "../../core/magnetizer";
6
- import { ConstrainFunction } from "../util/util";
7
- import { BOTTOM, CENTER, LEFT, RIGHT, TOP } from "../../core";
4
+ import { ConstrainFunction } from "../util";
8
5
  import { UICore } from "./core";
9
6
  export type ElementSelectionSpecifier<E> = E | Array<E> | '*';
10
7
  export type SelectionList = '*' | Array<string>;
@@ -571,4 +568,14 @@ export declare enum ElementTypes {
571
568
  * @internal
572
569
  */
573
570
  export type ElementType = keyof typeof ElementTypes;
571
+ /**
572
+ * Definition of capabilities that may have been added to a UI. This is an internal concept, managed by this class, its subclasses, and plugins/components. It provides a central place to store knowledge about the capabilities of the UI, without disparate parts needing to know about each other. For instance, if the ResizingToolsPlugin is installed and rotation is enabled, that plugin will set `vertexResize` and `vertexRotate` as available capabilities. The palette can then discover these are available, and support rotate while dragging - without needing to know about the implementation details. Similarly, the element dragging functionality can offer rotate by testing if the capability is available.
573
+ * @internal
574
+ */
575
+ export declare enum UICapabilities {
576
+ vertexDrag = "vertexDrag",
577
+ vertexRotate = "vertexRotate",
578
+ vertexResize = "vertexResize",
579
+ vertexDrawing = "vertexDrawing"
580
+ }
574
581
  export {};
@@ -1,5 +1,5 @@
1
1
  import { AnchorRecord, AnchorSpec, LightweightAnchor } from "../../common";
2
- import { PointXY } from "../../../core";
2
+ import { ObjectAnchorSpec, PointXY } from "../../../core";
3
3
  /**
4
4
  * @internal
5
5
  * @param type
@@ -8,6 +8,11 @@ import { PointXY } from "../../../core";
8
8
  * @private
9
9
  */
10
10
  export declare function _createAnchor(type: string, locations: Array<AnchorRecord>, params: Record<string, any>, fixedLocation: AnchorRecord): LightweightAnchor;
11
+ /**
12
+ * @internal
13
+ * @param oa
14
+ */
15
+ export declare function isObjectAnchorSpec(oa: any): oa is ObjectAnchorSpec;
11
16
  export declare function makeLightweightAnchorFromArraySpec(specs: Array<AnchorSpec>, selectedAnchor?: number, currentPosition?: PointXY): LightweightAnchor;
12
17
  /**
13
18
  * @internal
@@ -1,4 +1,4 @@
1
- import { AnchorSpec, OverlaySpec, PaintStyle, ConnectorSpec, FullOverlaySpec } from "../common";
1
+ import { AnchorSpec, OverlaySpec, PaintStyle, ConnectorSpec, FullOverlaySpec, InternalOverlaySpec } 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
4
  * @group UI
@@ -79,7 +79,7 @@ export interface TypeDescriptorBase {
79
79
  * @internal
80
80
  */
81
81
  export interface CompiledTypeDescriptor extends Omit<TypeDescriptorBase, 'overlays' | 'sourceMarker' | 'targetMarker'> {
82
- overlays?: Record<string, FullOverlaySpec>;
82
+ overlays?: Record<string, InternalOverlaySpec>;
83
83
  sourceMarker?: FullOverlaySpec;
84
84
  targetMarker?: FullOverlaySpec;
85
85
  }
@@ -72,4 +72,8 @@ export interface GroupMapping<EL> extends NodeOrGroupMapping<Group, EL, GroupEve
72
72
  * The size to use for this group type when it is collapsed.
73
73
  */
74
74
  collapsedSize?: Size;
75
+ /**
76
+ * Whether or not the group is locked.
77
+ */
78
+ locked?: boolean;
75
79
  }
@@ -1 +1 @@
1
- export declare const VERSION = "1.2.3";
1
+ export declare const VERSION = "1.2.5";