@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
@@ -79,11 +79,12 @@ export declare class PanZoom {
79
79
  wheelCssFilterSpec: string;
80
80
  wheelFilter: (e: MouseEvent) => boolean;
81
81
  wheelCssFilter: (e: MouseEvent) => boolean;
82
- wheelZoomRequiresMetaKey: boolean;
82
+ wheelRequiresMetaKey: boolean;
83
83
  wheelDirection: number;
84
84
  wheelSensitivity: number;
85
85
  wheelPan: boolean;
86
86
  wheelPanAxis: PanAxis;
87
+ _shiftToSwitchPanZoom: boolean;
87
88
  background: PanZoomBackground;
88
89
  fixedLayer: FixedLayer;
89
90
  _mouseMove: Function;
@@ -183,6 +184,7 @@ export declare class PanZoom {
183
184
  private _apparentOffset;
184
185
  private _canStartPanning;
185
186
  private handlers;
187
+ private _endPan;
186
188
  private _call;
187
189
  /**
188
190
  * Programmatically report a down event in order to kick the widget into action.
@@ -499,7 +501,7 @@ export declare class PanZoom {
499
501
  */
500
502
  mapEventLocation(event: MouseEvent): PointXY;
501
503
  /**
502
- * Sets whether or not the component should respond to mouse events.
504
+ * 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
505
  * @param state Whether or not to respond to mouse events.
504
506
  */
505
507
  setEnabled(state: boolean): void;
@@ -62,5 +62,6 @@ export declare class Paper extends BrowserUI {
62
62
  zoomOut(canvasLoc?: PointXY): void;
63
63
  zoomIn(canvasLoc?: PointXY): void;
64
64
  getVisibleCanvasBounds(): RectangleXY;
65
+ $isConsideredCanvasEvent(e: MouseEvent): boolean;
65
66
  }
66
67
  export declare function createPaper(container: BrowserElement, options?: PaperOptions, modelOptions?: ModelOptions, data?: any): Paper;
@@ -14,6 +14,11 @@ export declare const ATTRIBUTE_TRANSFORM = "transform";
14
14
  */
15
15
  export declare function getElementSize(el: Element): Size;
16
16
  export declare function getPosition(el: BrowserElement, knownElementSize?: Size): PointXY;
17
+ /**
18
+ * If the given point p is not null and neither p.x nor p.y are NaN, returns p. Otherwise, returns a point with x and y both set to 0.
19
+ * @param p
20
+ */
21
+ export declare function nullSafePoint(p: PointXY): PointXY;
17
22
  export declare function setPosition(el: BrowserElement, p: PointXY): void;
18
23
  /**
19
24
  * Gets the position of an element relative to the some other SVG,
@@ -41,6 +41,10 @@ export interface ShapeType {
41
41
  * Label to use for the shape type when displayed in a palette
42
42
  */
43
43
  label?: string;
44
+ /**
45
+ * Optional label padding when labels are top/bottom to use for this shape type. The shape library will default to any labelPadding set on the shape set, or the system default.
46
+ */
47
+ labelPadding?: number;
44
48
  /**
45
49
  * Can be shown in a palette to give a user more information about a shape
46
50
  */
@@ -79,8 +83,7 @@ export interface ShapeType {
79
83
  */
80
84
  icon?: string;
81
85
  /**
82
- * A list of configurable properties exposed by this shape's template.
83
- * An inspector can read this array to automatically generate an editing UI.
86
+ * A list of configurable properties exposed by this shape's template. An inspector can read this array to automatically generate an editing UI.
84
87
  */
85
88
  properties?: Array<ShapePropertyDefinition>;
86
89
  /**
@@ -92,14 +95,19 @@ export interface ShapeType {
92
95
  */
93
96
  labelPosition?: LabelPosition;
94
97
  /**
95
- * optional name of the group to which the shape belongs.
98
+ * Optional name of the group to which the shape belongs. This is not the same concept as a "group" inside the data model: this is a grouping of shape types, used to organise them in the UI.
96
99
  */
97
100
  group?: string;
98
101
  /**
99
- * Optional blueprint for child vertices and edges to be created when this group is added.
100
- * Only relevant when objectType is Group.
102
+ * Optional blueprint for child vertices and edges to be created when this group is added. Only relevant when objectType is Group.
101
103
  */
102
104
  members?: GroupTemplate;
105
+ /**
106
+ * For groups, indicates that the group is locked and no edits can occur to the child vertices. This is intended for use with the `members` option, for groups that gather a set of elements together to form a more complex building block. As an example in the real world, consider a Binary Adder: it is a group of logic gates whose relationships are fixed.
107
+ */
108
+ locked?: boolean;
109
+ }
110
+ export interface RealisedShapeType extends ShapeType {
103
111
  }
104
112
  /**
105
113
  * Start placement for shape icon - in x axis this means the left; in y axis it means the top.
@@ -137,6 +145,10 @@ export interface ShapeSet {
137
145
  icons?: Array<IconDefinition>;
138
146
  defs?: Record<string, string>;
139
147
  children?: Array<ShapeSet>;
148
+ /**
149
+ * Optional label padding when labels are top/bottom to use as a default for all shapes. Individual shapes can set their own values. This defaults to 10 pixels.
150
+ */
151
+ labelPadding?: number;
140
152
  /**
141
153
  * A list of configurable properties exposed by shapes in this set.
142
154
  */
@@ -148,14 +160,15 @@ export interface ShapeSet {
148
160
  export interface RenderedShapeSet extends ShapeSet {
149
161
  children: Array<RenderedShapeSet>;
150
162
  parent?: string;
163
+ shapes: Array<RealisedShapeType>;
151
164
  }
152
165
  /**
153
166
  * Defines a library that acts as a factory for shapes.
154
167
  * @internal
155
168
  */
156
169
  export interface ShapeLibrary<T extends ObjectData> {
157
- $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): ShapeType;
158
- getShapeDefinition(type: string, set?: string): ShapeType;
170
+ $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
171
+ getShapeDefinition(type: string, set?: string): RealisedShapeType;
159
172
  renderCompiledShape(data: T, strokeWidth?: number): BrowserElement;
160
173
  renderShapeLabel(data: ObjectData, labelProperty: string, strokeWidth: string, label: string, fill: string, stroke: string, font: FontSpec): SVGTextElement;
161
174
  getShapeTagDefinition(isSvgContainer: boolean, strokeWidth?: number, includeLabel?: boolean, fontSpec?: FontSpec, labelAttribute?: string, defaultFillColor?: string, defaultOutlineColor?: string, defaultColor?: string): CustomTagOptions;
@@ -250,9 +263,16 @@ export interface ShapePropertyDefinition {
250
263
  */
251
264
  description?: string;
252
265
  /**
253
- * For "number" types, optional min/max constraints.
266
+ * For "number" types, optional min constraints.
254
267
  */
255
268
  min?: number;
269
+ /**
270
+ * For "number" types, optional max constraints.
271
+ */
256
272
  max?: number;
273
+ /**
274
+ * Optional set of values to pick current value from
275
+ */
276
+ values?: Array<any>;
257
277
  }
258
278
  export type LabelPosition = "top" | "bottom" | "center";
@@ -1,4 +1,4 @@
1
- import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, ShapeType, LabelPosition } from "./shape-library-definitions";
1
+ import { RenderedShapeSet, ShapeGeneratorFunction, ShapeLibrary, ShapeSet, LabelPosition, RealisedShapeType } from "./shape-library-definitions";
2
2
  import { BrowserElement } from "../util";
3
3
  import { CustomTagOptions, Recado, AbstractEntry, ObjectData } from "../../core";
4
4
  import { IconDefinition } from "../icons";
@@ -187,12 +187,12 @@ export declare class ShapeLibraryImpl<T extends ObjectData> implements ShapeLibr
187
187
  * @param type
188
188
  * @param set
189
189
  */
190
- getShapeDefinition(type: string, set?: string): ShapeType;
190
+ getShapeDefinition(type: string, set?: string): RealisedShapeType;
191
191
  /**
192
192
  * Gets the definition for some data object, using the default type/category parameters, or specific ones that you supply. May return null.
193
193
  * @internal
194
194
  */
195
- $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): ShapeType;
195
+ $getShapeDefinitionForObject(o: ObjectData, typeParameter?: string, categoryParameter?: string): RealisedShapeType;
196
196
  /**
197
197
  * Gets the template for the given shape type in the given set. If no template is resolved then we return
198
198
  * DEFAULT_TEMPLATE (and log the issue to the console).
@@ -54,6 +54,14 @@ export declare const CLASS_PALETTE_SET_TITLE = "vjs-shape-library-palette-set-ti
54
54
  * @category CSS Classes
55
55
  */
56
56
  export declare const CLASS_PALETTE_SET_SHAPES = "vjs-shape-library-palette-set-shapes";
57
+ /**
58
+ * Assigned to a group title element in the shape palette.
59
+ * @cssClass
60
+ * @context shapePalette
61
+ * @group Diagrams
62
+ * @category CSS Classes
63
+ */
64
+ export declare const CLASS_PALETTE_SET_SHAPE_GROUP_TITLE = "vjs-shape-library-palette-shape-group-title";
57
65
  /**
58
66
  * When in `tap` mode, this class is added to the lasso used to draw new vertices
59
67
  * @cssClass
@@ -4,13 +4,12 @@ import { DiagramCell } from "./diagram-cell";
4
4
  import { GridOptions, UIExportOptions, UICoreDefaults, EdgeEventOptions, OverlaySpec, ConnectorSpec, NodeEventOptions, GroupMapping, NodeMapping, AnchorSpec, EdgePropertyMappings, MagnetizeOptions, PaintStyle, OverlayVisibility, EdgeDeleteConfirmationFunction } from "../../../ui";
5
5
  import { SurfaceSaveData } from "../definitions";
6
6
  import { BrowserElement } from "../../util";
7
- import { PaletteMode } from "../../components/palette/palette-options";
7
+ import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../../components/palette/palette-options";
8
8
  import { PanOptions, WheelOptions, ZoomOptions } from "../../pan-zoom-options";
9
9
  import { MiniviewPluginOptions, LassoPluginOptions, ResizingToolsModelUpdater, ResizingToolsHandlerFactory, DragGroupsPluginOptions, ResizingToolsResizeMethod, SnaplinesPluginOptions, PanButtonsPluginOptions, LineCrossingsPluginOptions } from "../plugins";
10
- import { EdgeSnapOptions } from "../../edge-handler-base";
10
+ import { EdgeSnapOptions, EdgeInputMethod } from "../../edge-handler-base";
11
11
  import { DiagramActionMediator } from "./mediator";
12
12
  import { OnVertexAddedCallback, FontSpec } from "../../definitions";
13
- import { EdgeInputMethod } from "../../edge-input-handler";
14
13
  import { PreparedShape } from "../shape-palette-options";
15
14
  /**
16
15
  * Options for the {@link Diagram.addLink method}
@@ -66,6 +65,14 @@ export interface DiagramOptions {
66
65
  * Defaults to true, meaning the user can edit the diagram.
67
66
  */
68
67
  editable?: boolean;
68
+ /**
69
+ * Whether or not to allow rotation of elements being dragged from the palette. Defaults to true.
70
+ */
71
+ allowRotation?: boolean;
72
+ /**
73
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
74
+ */
75
+ rotationSpeed?: number;
69
76
  edges?: {
70
77
  /**
71
78
  * Whether or not to disable drop targets on which an edge from some current source may not be dropped when drag starts. Defaults to true.
@@ -459,9 +466,14 @@ export interface DiagramPaletteOptions {
459
466
  */
460
467
  dragSize?: Size;
461
468
  /**
462
- * Indicates that when one or more vertices are selected, clicking on an entry in the palette will change the type of the selected vertices to that type. Defaults to true.
469
+ * When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
463
470
  */
464
471
  inspector?: boolean;
472
+ /**
473
+ * When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`.
474
+ * This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
475
+ */
476
+ updateTypeOnPaletteTap?: boolean;
465
477
  /**
466
478
  * Optional size to use for icons. Defaults to 150x100 pixels. If you provide this but not `dragSize` this size will also be used for an icon that is being dragged.
467
479
  */
@@ -495,6 +507,15 @@ export interface DiagramPaletteOptions {
495
507
  * Defaults to true: when in 'tap' mode and a new group/node has been drawn on the canvas, the UI is set back to pan mode.
496
508
  */
497
509
  autoExitDrawMode?: boolean;
510
+ /**
511
+ * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
512
+ */
513
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter<BrowserElement>;
514
+ /**
515
+ * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
516
+ * @advanced
517
+ */
518
+ connectToPortsOnEdgeDrop?: boolean;
498
519
  /**
499
520
  * When true (which is the default), a newly dropped shape will be set as the underlying model's selection.
500
521
  */
@@ -515,6 +536,22 @@ export interface DiagramPaletteOptions {
515
536
  * Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
516
537
  */
517
538
  preparedShapes?: Array<PreparedShape>;
539
+ /**
540
+ * Whether or not to allow rotation of elements being dragged. Defaults to true.
541
+ */
542
+ allowRotation?: boolean;
543
+ /**
544
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
545
+ */
546
+ rotationSpeed?: number;
547
+ /**
548
+ * Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
549
+ */
550
+ autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
551
+ /**
552
+ * Whether or not to show groups in the palette. Defaults to true.
553
+ */
554
+ showGroups?: boolean;
518
555
  }
519
556
  /**
520
557
  * Save options for a Diagram
@@ -1,4 +1,4 @@
1
- import { ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
1
+ import { Group, ObjectData, PriorityQueue, SaveOptions, ModelOptions, Edge } from "../../../core";
2
2
  import { PropertyTracker, ZoomToFitOptions, ZoomToFitIfNecessaryOptions } from "../../../ui";
3
3
  import { BrowserElement } from "../../util";
4
4
  import { BrowserUIModel } from "../../browser-ui";
@@ -204,6 +204,16 @@ export declare class Diagram {
204
204
  * @tags zoom
205
205
  */
206
206
  zoomToFitIfNecessary(params?: ZoomToFitIfNecessaryOptions): void;
207
+ /**
208
+ * 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.
209
+ * @param groupIdOrGroup
210
+ */
211
+ lockGroup(groupOrGroupId: string | Group): void;
212
+ /**
213
+ * Unlock a group
214
+ * @param groupOrGroupId
215
+ */
216
+ unlockGroup(groupOrGroupId: string | Group): void;
207
217
  }
208
218
  /**
209
219
  * Create a new DiagramPalette in the given container element, and attach it to the given Diagram.
@@ -1,4 +1,4 @@
1
- import { Group, Vertex, Node, ObjectData, Size } from "../../../core";
1
+ import { Group, Node, ObjectData, Size } from "../../../core";
2
2
  import { ShapeType } from "../../shape-library";
3
3
  import { BrowserElement } from "../../util";
4
4
  /**
@@ -13,42 +13,42 @@ export interface DiagramActionMediator {
13
13
  * @param shape
14
14
  * @param el
15
15
  */
16
- canClone?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
16
+ canClone?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
17
17
  /**
18
18
  * Returns whether or not the given vertex should be deletable in the UI. Defaults to true, meaning the delete icon will be present in the diagram tools when the vertex is selected.
19
19
  * @param v
20
20
  * @param shape
21
21
  * @param el
22
22
  */
23
- canDelete?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
23
+ canDelete?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
24
24
  /**
25
25
  * Returns whether or not the given vertex should be linkable via edge drag in the UI. Defaults to true, meaning the link icon will be present in the diagram tools when the vertex is selected.
26
26
  * @param v
27
27
  * @param shape
28
28
  * @param el
29
29
  */
30
- canLink?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
30
+ canLink?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
31
31
  /**
32
32
  * Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the resize handles will be present in the diagram tools when the vertex is selected.
33
33
  * @param v
34
34
  * @param shape
35
35
  * @param el
36
36
  */
37
- canResize?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
37
+ canResize?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
38
38
  /**
39
39
  * Returns whether or not the given vertex should be resizable in the UI. Defaults to true, meaning the rotate handle and leader will be present in the diagram tools when the vertex is selected.
40
40
  * @param v
41
41
  * @param shape
42
42
  * @param el
43
43
  */
44
- canRotate?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
44
+ canRotate?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
45
45
  /**
46
46
  * Returns whether or not the given vertex should be draggable in the UI. Defaults to true.
47
47
  * @param v
48
48
  * @param shape
49
49
  * @param el
50
50
  */
51
- canDrag?: (v: Vertex, shape: ShapeType, el: BrowserElement) => boolean;
51
+ canDrag?: (v: Node | Group, shape: ShapeType, el: BrowserElement) => boolean;
52
52
  /**
53
53
  * Returns whether or not the given vertex should be droppable on the given target, which may either be another vertex (if `targetVertex` is set), or the diagram canvas (if `isOnCanvas` is set). This method will never be called with both `targetVertex` set an `isOnCanvas` true - it's one or the other.
54
54
  * @param v
@@ -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,12 +40,20 @@ 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;
40
54
  size: Size;
41
55
  _generateLassoContent: (origin: PointXY, e: MouseEvent) => BrowserElement;
42
- el: HTMLElement;
56
+ el: BrowserElement;
43
57
  _extentTrackerEl: BrowserElement;
44
58
  masks: Record<string, HTMLElement>;
45
59
  origin: 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
@@ -1,8 +1,8 @@
1
- import { ResizingToolsPluginOptions, ResizeHandler, ResizeDirection } from "./definitions";
2
- import { Grid, PointXY, Group, Node, ObjectData, VisuallyJsModel, Size, Vertex, VertexUpdatedReason } from "../../../../core";
1
+ import { ResizeDirection, ResizeHandler, ResizingToolsPluginOptions } from "./definitions";
2
+ import { Grid, Group, Node, ObjectData, PointXY, Size, Vertex, VertexUpdatedReason, VisuallyJsModel } from "../../../../core";
3
3
  import { Surface } from "../../surface";
4
4
  import { BrowserElement } from "../../../util";
5
- import { ViewportElement, GroupMapping, ViewportGroupElement, GroupContentAreaInfo, GroupResizeResult } from "../../../../ui";
5
+ import { GroupContentAreaInfo, GroupMapping, GroupResizeResult, ViewportElement, ViewportGroupElement } from "../../../../ui";
6
6
  import { BaseBrowserUIPlugin, BrowserUIPlugin } from "../../../plugins";
7
7
  import { ElasticGroupManager } from "../../elastic-group-manager";
8
8
  /**
@@ -108,6 +108,7 @@ export declare class ResizingToolsPlugin extends BaseBrowserUIPlugin implements
108
108
  destroy(): void;
109
109
  _handleDragHandlers: Record<string, ResizeHandler>;
110
110
  _borderDragHandlers: Record<string, ResizeHandler>;
111
+ $getRotationStopsArray(): Array<number>;
111
112
  initialise(surface: Surface, options: ResizingToolsPluginOptions): boolean;
112
113
  private _configureGroupParent;
113
114
  private _handleMouseDown;
@@ -1,7 +1,7 @@
1
1
  import { Group, ObjectData, Size, Node } from "../../core";
2
2
  import { ShapeLibrary } from "../shape-library";
3
3
  import { DataGeneratorFunction, OnVertexAddedCallback } from "../definitions";
4
- import { PaletteMode } from "../components";
4
+ import { PaletteMode, AutoEdgeConnectOptions, CanDropOnEdgeFilter } from "../components";
5
5
  /**
6
6
  * Options for a shape palette.
7
7
  * @group Components
@@ -41,9 +41,13 @@ export interface ShapePaletteOptions<T extends ObjectData> {
41
41
  */
42
42
  selectAfterDrop?: boolean;
43
43
  /**
44
- * Indicates two things: first, when one or more vertices are selected, clicking on an entry in the palette will change the type of the selected vertices to that type. Secondly, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
44
+ * When `true`, selecting an element in the canvas will cause its related shape to be selected in the palette. Defaults to true.
45
45
  */
46
46
  inspector?: boolean;
47
+ /**
48
+ * When `true`, clicking on an entry in the palette will change the type of any selected vertices to that type. Defaults to `false`. This is a potentially destructive operation if the properties of the new shape type are not compatible with the old one.
49
+ */
50
+ updateTypeOnPaletteTap?: boolean;
47
51
  /**
48
52
  * Stroke width to use for shapes in palette. Defaults to 1.
49
53
  */
@@ -95,12 +99,36 @@ export interface ShapePaletteOptions<T extends ObjectData> {
95
99
  * Optional set of prepared shapes to show in the palette. When this is provided, the palette will only render these shapes, and not the contents of the shape library.
96
100
  */
97
101
  preparedShapes?: Array<PreparedShape>;
102
+ /**
103
+ * If true, shapes can be dropped on edges in the canvas. The edge on which the shape was dropped has its target set to be the new node, and a new edge is added with the new node as source and the original edge's target as target.
104
+ */
105
+ allowDropOnEdge?: boolean | CanDropOnEdgeFilter<T>;
106
+ /**`
107
+ * If `allowDropOnEdge` is also true, this flag instructs the shape palette to provide a default `edgeDropHandler` to the underlying palette which will attempt to find a source and target port on the new vertex, and connect to those instead of to the vertex itself. Defaults to true.
108
+ * @advanced
109
+ */
110
+ connectToPortsOnEdgeDrop?: boolean;
111
+ /**
112
+ * Whether or not to allow rotation of elements being dragged. Defaults to true.
113
+ */
114
+ allowRotation?: boolean;
115
+ /**
116
+ * The number of milliseconds required to complete a full rotation of an element when the trigger key is held down. Defaults to 2000.
117
+ */
118
+ rotationSpeed?: number;
119
+ /**
120
+ * Controls whether the palette will automatically connect a new vertex being dragged onto the canvas to existing vertices, if the shape definitions for the new vertex and/or the existing vertices have source/target elements. You can set this to simply 'true', and use defaults, or you can provide values for various options.
121
+ */
122
+ autoEdgeConnect?: boolean | AutoEdgeConnectOptions;
123
+ /**
124
+ * Whether or not to show groups in the palette. Defaults to true.
125
+ */
126
+ showGroups?: boolean;
98
127
  }
99
128
  /**
100
129
  * Defines a wrapper around a shape with some `type` and `category` that adds properties (to be used to define the shape's appearance) and, optionally, the shape's initial size.
101
130
  * @group Components
102
131
  * @category Shape Palette
103
- * @internal
104
132
  */
105
133
  export interface PreparedShape {
106
134
  /**
@@ -18,6 +18,7 @@ export declare class ShapePalette<T extends ObjectData> {
18
18
  _$_templateEngine: BrowserUiRecado;
19
19
  _$_palette: Palette<ObjectData>;
20
20
  _$_userDataGenerator: DataGeneratorFunction<T>;
21
+ _$_showGroups: boolean;
21
22
  /**
22
23
  * @internal
23
24
  */
@@ -9,7 +9,6 @@ import { Base, Node, Group, Edge, Port, Vertex, ObjectData, VisuallyJsSelection,
9
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
- import { EdgeInputMethod } from "../edge-input-handler";
13
12
  import { ModelEventCallback, SurfaceEvents, SurfaceMode, SurfaceSaveData, SurfaceVertexCloneOptions } from "./definitions";
14
13
  import { EdgePathEditor } from "../connector-editors";
15
14
  import { ConnectorEditorActivateParams } from "../connector-editor";
@@ -17,6 +16,7 @@ import { ElementDragHandler2, InternalDragGroupSpec } from "../element-drag-hand
17
16
  import { Background, DragGroupSpec, SupportsPathEditing, SupportsViewportManipulation, ZoomToExtentsOptions } from "../definitions";
18
17
  import { BrowserUIModel } from "../browser-ui";
19
18
  import { MiniviewPluginOptions } from "./plugins";
19
+ import { EdgeInputMethod } from "../edge-handler-base";
20
20
  /**
21
21
  * Provides a canvas on which nodes, groups and edges can be rendered, with support for pan/zoom, layouts and various plugins. This is not a class that API users should instantiate directly: for users of a library integration, a Surface will be created internally by the appropriate component; for users of vanilla VisuallyJs, a Surface is created either via the {@link createSurface} factory method, or via a `render` call on an instance of the {@link BrowserUIModel}.
22
22
  * @group Components
@@ -72,6 +72,14 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
72
72
  * @internal
73
73
  */
74
74
  $groupRemoved(deletion: GroupRemovedParams): ViewportGroupElement<BrowserElement>;
75
+ /**
76
+ * Returns whether or not the given event is considered for all practical reasons to have occurred on the surface canvas. Tests if the event target is the surface root or canvas element, or if the panZoom considers it to be a background element.
77
+ *
78
+ * This method is used when deciding to fire a canvas click event, and also by the lasso, to make the decision to switch to auto arm.
79
+ * @internal
80
+ * @param e
81
+ */
82
+ $isConsideredCanvasEvent(e: MouseEvent): boolean;
75
83
  /**
76
84
  * @internal
77
85
  */
@@ -271,6 +279,12 @@ export declare class Surface extends BrowserUI<SurfaceEvents> implements Support
271
279
  * @param els Elements to remove from drag groups.
272
280
  */
273
281
  removeFromDragGroup(...els: Array<string | BrowserElement | Node | Group>): void;
282
+ /**
283
+ * Remove the given viewport element from a drag group it may be in. This method can be invoked after an element has been removed and it has no managed element tracked anymore, so internal invocations go through this method rather than the one above.
284
+ * @param vel
285
+ * @private
286
+ */
287
+ private _removeFromDragGroup;
274
288
  /**
275
289
  * Sets the active/passive state for the given element(s) in their respective drag groups (if any). You don't need to supply the drag group id, as elements can only be in one drag group anyway.
276
290
  * @param state true for active, false for passive.
@@ -38,7 +38,7 @@ export interface DataSource extends FilterableDataset {
38
38
  getPortType(port: ObjectData): string;
39
39
  getPortId(port: ObjectData): string;
40
40
  getDescendants(vertex: Group): Array<Node | Group>;
41
- getAncestors(vertex: Node | Group): Array<Group>;
41
+ getAncestors(vertex: Vertex): Array<Group>;
42
42
  isAncestor(focus: Node | Group, possibleAncestor: Group): boolean;
43
43
  isDescendantGroup(possibleDescendant: Group, ancestor: Group): boolean;
44
44
  getEdgeCount(): number;
@@ -310,6 +310,12 @@ export declare function clampAngle(angle: number): number;
310
310
  export interface RotatedRectangle extends RectangleXY {
311
311
  r?: number;
312
312
  }
313
+ /**
314
+ * Returns the four corner points of a rotated rectangle.
315
+ * @param rect The rotated rectangle.
316
+ * @returns An array of four PointXY objects representing the corners.
317
+ */
318
+ export declare function getRotatedCorners(rect: RotatedRectangle): PointXY[];
313
319
  /**
314
320
  * Determines if two rotated rectangles intersect using the Separating Axis Theorem (SAT).
315
321
  * @param r1 The first rotated rectangle.
@@ -29,7 +29,7 @@ export type Parser = (data: any, instance: VisuallyJsModel, parameters?: any) =>
29
29
  */
30
30
  export type Exporter = (instance: VisuallyJsModel, parameters: any) => any;
31
31
  /**
32
- * The default type that represents an edge in a dataset to load or a saved dataset
32
+ * The default type that represents an edge in a dataset to load or a saved dataset. Edges differ slightly from nodes and groups in that there are fields which are mandatory: `source` and `data`. Edges also differ from nodes and groups in that any backing data for an edge (including its `id` and/or `type`) need to be provided in the `data` member of the edge, not in the root as with nodes and groups.
33
33
  * @group Model
34
34
  */
35
35
  export interface EdgeData {
@@ -66,12 +66,12 @@ export interface EdgeData {
66
66
  };
67
67
  }
68
68
  /**
69
- * The default type that represents a node in a dataset to load or a saved dataset
69
+ * The default type that represents a node in a dataset to load or a saved dataset. While there are no specific requirements for the entries in node data, the default configuration expects that you will at the minimum have provided an `id`. Nodes have an associated `type`, which VisuallyJs will set to "default" in the absence of you providing one; as you start to build more complex interfaces with VisuallyJs you will want to provide the `type` member.
70
70
  * @group Data Model
71
71
  */
72
72
  export type NodeData = Record<string, any>;
73
73
  /**
74
- * The default type that represents a group in a dataset to load or a saved dataset
74
+ * The default type that represents a group in a dataset to load or a saved dataset. While there are no specific requirements for the entries in groups data, the default configuration expects that you will at the minimum have provided an `id`. Groups have an associated `type`, which VisuallyJs will set to "default" in the absence of you providing one; as you start to build more complex interfaces with VisuallyJs you will want to provide the `type` member.
75
75
  * @group Data Model
76
76
  */
77
77
  export type GroupData = Record<string, any>;
@@ -94,7 +94,27 @@ export interface VisuallyJsDefaultJSON {
94
94
  */
95
95
  groups?: Array<GroupData>;
96
96
  }
97
+ /**
98
+ * An entry in the hierarchical json format.
99
+ * @group Data Model
100
+ * @category Input and Output
101
+ */
102
+ export interface VisuallyJsHierarchicalJSONEntry extends ObjectData {
103
+ children?: Array<VisuallyJsHierarchicalJSONEntry>;
104
+ }
105
+ /**
106
+ * The Hierarchical JSON format. Consists of a single root entry, which has a children array, each of which may have children, etc.
107
+ * @group Data Model
108
+ * @category Input and Output
109
+ */
110
+ export type VisuallyJsHierarchicalJSON = VisuallyJsHierarchicalJSONEntry;
111
+ /**
112
+ * Defines the default JSON datatype
113
+ */
97
114
  export declare const JSON_DATATYPE = "json";
115
+ /**
116
+ * Defines the hierarchical json datatype
117
+ */
98
118
  export declare const HIERARCHICAL_JSON_DATATYPE = "hierarchical-json";
99
119
  /**
100
120
  * Register a parser for some given datatype