@metadev/daga 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
package/src/index.d.ts CHANGED
@@ -3,21 +3,23 @@ export { ACTION_STACK_SIZE, DiagramCanvas, setCursorStyle } from './lib/diagram/
3
3
  export { DiagramContextMenu } from './lib/diagram/canvas/diagram-context-menu';
4
4
  export { DiagramUserHighlight } from './lib/diagram/canvas/diagram-user-highlight';
5
5
  export { DiagramUserSelection } from './lib/diagram/canvas/diagram-user-selection';
6
- export { CollabAction, CollabActionSerialized } from './lib/diagram/collab/collab-action';
6
+ export type { CollabAction, CollabActionSerialized } from './lib/diagram/collab/collab-action';
7
7
  export { CollabClient } from './lib/diagram/collab/collab-client';
8
- export { CollabTimestamp, CollabTimestampSet } from './lib/diagram/collab/primitives';
8
+ export type { CollabTimestamp, CollabTimestampSet } from './lib/diagram/collab/primitives';
9
9
  export { DagaExporter } from './lib/diagram/converters/daga-exporter';
10
10
  export { DagaImporter } from './lib/diagram/converters/daga-importer';
11
- export { DagaConnection, DagaModel, DagaNode, DagaPort, DagaSection } from './lib/diagram/converters/daga-model';
12
- export { DiagramModelExporter } from './lib/diagram/converters/diagram-model-exporter';
13
- export { DiagramModelImporter } from './lib/diagram/converters/diagram-model-importer';
14
- export { ActionStack, AddConnectionAction, AddNodeAction, DiagramAction, DiagramActions, EditFieldAction, RemoveAction, SetGeometryAction, UpdateValuesAction } from './lib/diagram/diagram-action';
15
- export { ButtonsComponentConfig, CanvasConfig, ComponentsConfig, ConnectionMarkerLook, ConnectionTemplateConfig, ConnectionTypeConfig, DiagramConfig, ErrorsComponentConfig, FieldConfig, GridConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTemplateConfig, NodeTypeConfig, PaletteComponentConfig, PaletteSectionConfig, PortConfig, PropertyEditorComponentConfig, SectionConfig, SectionGridConfig, UserActionConfig } from './lib/diagram/diagram-config';
16
- export { DiagramEvent } from './lib/diagram/diagram-event';
11
+ export type { DagaConnection, DagaModel, DagaNode, DagaPort, DagaSection } from './lib/diagram/converters/daga-model';
12
+ export type { DiagramModelExporter } from './lib/diagram/converters/diagram-model-exporter';
13
+ export type { DiagramModelImporter } from './lib/diagram/converters/diagram-model-importer';
14
+ export { ActionStack, ApplyLayoutAction, MoveAction, PasteAction, SetParentAction, AddConnectionAction, AddNodeAction, DiagramActionMethod, DiagramActions, EditFieldAction, RemoveAction, SetGeometryAction, UpdateValuesAction } from './lib/diagram/diagram-action';
15
+ export type { DiagramAction } from './lib/diagram/diagram-action';
16
+ export type { ButtonsComponentConfig, CanvasConfig, ComponentsConfig, ConnectionMarkerLook, ConnectionTemplateConfig, ConnectionTypeConfig, DiagramConfig, ErrorsComponentConfig, FieldConfig, GridConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTemplateConfig, NodeTypeConfig, PaletteComponentConfig, PaletteSectionConfig, PortConfig, PropertyEditorComponentConfig, SectionConfig, SectionGridConfig, UserActionConfig } from './lib/diagram/diagram-config';
17
+ export { DiagramDoubleClickEvent, DiagramEvent, DiagramEvents, DiagramSecondaryClickEvent } from './lib/diagram/diagram-event';
17
18
  export { AdjacencyLayout } from './lib/diagram/layout/adjacency-layout';
18
19
  export { BreadthAdjacencyLayout } from './lib/diagram/layout/breadth-adjacency-layout';
19
20
  export { BreadthLayout } from './lib/diagram/layout/breadth-layout';
20
- export { DiagramLayout, layouts } from './lib/diagram/layout/diagram-layout';
21
+ export { layouts, getLocationsOfNodes } from './lib/diagram/layout/diagram-layout';
22
+ export type { DiagramLayout } from './lib/diagram/layout/diagram-layout';
21
23
  export { ForceLayout } from './lib/diagram/layout/force-layout';
22
24
  export { HorizontalLayout } from './lib/diagram/layout/horizontal-layout';
23
25
  export { PriorityLayout } from './lib/diagram/layout/priority-layout';
@@ -26,22 +28,26 @@ export { VerticalLayout } from './lib/diagram/layout/vertical-layout';
26
28
  export { DiagramConnection, DiagramConnectionSet, DiagramConnectionType } from './lib/diagram/model/diagram-connection';
27
29
  export { DiagramDecorator, DiagramDecoratorSet } from './lib/diagram/model/diagram-decorator';
28
30
  export { DiagramElement, DiagramElementSet } from './lib/diagram/model/diagram-element';
29
- export { DiagramEntity, DiagramEntitySet } from './lib/diagram/model/diagram-entity';
31
+ export { DiagramEntitySet } from './lib/diagram/model/diagram-entity';
32
+ export type { DiagramEntity } from './lib/diagram/model/diagram-entity';
30
33
  export { DIAGRAM_FIELD_DEFAULTS, DiagramField, DiagramFieldSet, getBottomMargin, getBottomPadding, getLeftMargin, getLeftPadding, getRightMargin, getRightPadding, getTopMargin, getTopPadding } from './lib/diagram/model/diagram-field';
31
34
  export { DiagramModel } from './lib/diagram/model/diagram-model';
32
- export { DiagramNode, DiagramNodeGeometry, DiagramNodeSet, DiagramNodeType } from './lib/diagram/model/diagram-node';
35
+ export { DiagramNode, DiagramNodeSet, DiagramNodeType, filterByOnlyAncestors, filterByOnlyDescendants } from './lib/diagram/model/diagram-node';
36
+ export type { DiagramNodeGeometry } from './lib/diagram/model/diagram-node';
33
37
  export { DiagramObject, DiagramObjectSet } from './lib/diagram/model/diagram-object';
34
38
  export { DiagramPort, DiagramPortSet } from './lib/diagram/model/diagram-port';
35
- export { diff, equals, isObject, Option, Property, PropertySet, Type, ValueSet } from './lib/diagram/model/diagram-property';
36
- export { DiagramSection, DiagramSectionGeometry, DiagramSectionSet } from './lib/diagram/model/diagram-section';
37
- export { DiagramError } from './lib/errors/diagram-error';
38
- export { DiagramValidator } from './lib/errors/diagram-validator';
39
- export { Canvas } from './lib/interfaces/canvas';
40
- export { DiagramButtons } from './lib/interfaces/diagram-buttons';
41
- export { DiagramEditor } from './lib/interfaces/diagram-editor';
42
- export { Palette } from './lib/interfaces/palette';
43
- export { PropertyEditor } from './lib/interfaces/property-editor';
44
- export { Line, Point, Rectangle } from './lib/util/canvas-util';
39
+ export { diff, equals, isObject, Property, PropertySet, Type, ValueSet } from './lib/diagram/model/diagram-property';
40
+ export type { Option } from './lib/diagram/model/diagram-property';
41
+ export { DiagramSection, DiagramSectionSet } from './lib/diagram/model/diagram-section';
42
+ export type { DiagramSectionGeometry } from './lib/diagram/model/diagram-section';
43
+ export type { DiagramError } from './lib/errors/diagram-error';
44
+ export type { DiagramValidator } from './lib/errors/diagram-validator';
45
+ export type { Canvas } from './lib/interfaces/canvas';
46
+ export type { DiagramButtons } from './lib/interfaces/diagram-buttons';
47
+ export type { DiagramEditor } from './lib/interfaces/diagram-editor';
48
+ export type { Palette } from './lib/interfaces/palette';
49
+ export type { PropertyEditor } from './lib/interfaces/property-editor';
50
+ export type { Line, Point, Rectangle } from './lib/util/canvas-util';
45
51
  export { DragEvents, Events, Keys, ZoomEvents } from './lib/util/events';
46
52
  export { linePath, LineShape, LineStyle, lineStyleDasharray } from './lib/util/line';
47
53
  export { addIfNotExists, removeIfExists } from './lib/util/list-util';
@@ -6,7 +6,7 @@ import { DiagramEditor } from '../../interfaces/diagram-editor';
6
6
  import { Point } from '../../util/canvas-util';
7
7
  import { CursorStyle } from '../../util/style';
8
8
  import { CollabEngine } from '../collab/collab-engine';
9
- import { ActionStack, DiagramActions } from '../diagram-action';
9
+ import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from '../diagram-action';
10
10
  import { DiagramConfig } from '../diagram-config';
11
11
  import { DiagramEvent } from '../diagram-event';
12
12
  import { DiagramConnectionType } from '../model/diagram-connection';
@@ -75,10 +75,12 @@ export declare class DiagramCanvas implements Canvas {
75
75
  private currentAction?;
76
76
  readonly viewInitialized$: Subject<void>;
77
77
  readonly validatorChange$: Subject<void>;
78
- readonly diagramChange$: Subject<void>;
79
- readonly diagramImportantChange$: Subject<void>;
80
- readonly propertyEditorChanges$: Subject<void>;
78
+ readonly diagramChange$: Subject<{
79
+ action: DiagramAction;
80
+ method: DiagramActionMethod;
81
+ }>;
81
82
  readonly diagramEvent$: Subject<DiagramEvent>;
83
+ readonly propertyEditorChanges$: Subject<void>;
82
84
  /**
83
85
  * Constructs a canvas object.
84
86
  * @public
@@ -119,13 +121,6 @@ export declare class DiagramCanvas implements Canvas {
119
121
  selectRoot(): d3.Selection<SVGElement, unknown, null, unknown>;
120
122
  selectCanvasView(): d3.Selection<SVGGElement, unknown, null, unknown>;
121
123
  selectCanvasElements(): d3.Selection<SVGGElement, unknown, null, unknown>;
122
- selectCanvasNodes(): d3.Selection<SVGGElement, unknown, null, unknown>;
123
- selectCanvasSections(): d3.Selection<SVGGElement, unknown, null, unknown>;
124
- selectCanvasPorts(): d3.Selection<SVGGElement, unknown, null, unknown>;
125
- selectCanvasConnections(): d3.Selection<SVGGElement, unknown, null, unknown>;
126
- selectCanvasFields(): d3.Selection<SVGGElement, unknown, null, unknown>;
127
- selectCanvasObjects(): d3.Selection<SVGGElement, unknown, null, unknown>;
128
- selectCanvasDecorators(): d3.Selection<SVGGElement, unknown, null, unknown>;
129
124
  private startConnection;
130
125
  private finishConnection;
131
126
  private dropConnection;
@@ -32,7 +32,7 @@ export interface CollabAction {
32
32
  /**
33
33
  * @private
34
34
  */
35
- export type CollabActionSerialized = AddNodeSerialized | MoveSerialized | SetGeometrySerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized | PasteSerialized;
35
+ export type CollabActionSerialized = AddNodeSerialized | ApplyLayoutSerialized | MoveSerialized | SetGeometrySerialized | SetParentSerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized | PasteSerialized;
36
36
  /**
37
37
  * @private
38
38
  */
@@ -41,6 +41,7 @@ export type AddNodeSerialized = {
41
41
  id: string;
42
42
  typeId: string;
43
43
  coords: Point;
44
+ parentId?: string;
44
45
  label?: string;
45
46
  values?: {
46
47
  [key: string]: unknown;
@@ -56,17 +57,46 @@ export declare class AddNodeCollabAction implements CollabAction {
56
57
  readonly id: string;
57
58
  readonly typeId: string;
58
59
  readonly coords: Point;
60
+ readonly parentId?: string | undefined;
59
61
  readonly label?: string | undefined;
60
62
  readonly values?: {
61
63
  [key: string]: unknown;
62
64
  } | undefined;
63
- constructor(canvas: Canvas, id: string, typeId: string, coords: Point, label?: string | undefined, values?: {
65
+ constructor(canvas: Canvas, id: string, typeId: string, coords: Point, parentId?: string | undefined, label?: string | undefined, values?: {
64
66
  [key: string]: unknown;
65
67
  } | undefined);
66
68
  do(): void;
67
69
  serialize(): AddNodeSerialized;
68
70
  static deserialize(canvas: Canvas, serialized: AddNodeSerialized): AddNodeCollabAction;
69
71
  }
72
+ /**
73
+ * @private
74
+ */
75
+ export type ApplyLayoutSerialized = {
76
+ type: 'applyLayout';
77
+ to: {
78
+ [key: string]: Point;
79
+ };
80
+ timestamp: CollabTimestamp;
81
+ };
82
+ /**
83
+ * Collaborative which consists of applying a layout to the diagram which can change the location of several nodes.
84
+ * @private
85
+ * @see ApplyLayoutAction
86
+ */
87
+ export declare class ApplyLayoutCollabAction implements CollabAction {
88
+ readonly canvas: Canvas;
89
+ readonly to: {
90
+ [key: string]: Point;
91
+ };
92
+ readonly timestamp: CollabTimestamp;
93
+ constructor(canvas: Canvas, to: {
94
+ [key: string]: Point;
95
+ }, timestamp: CollabTimestamp);
96
+ do(): void;
97
+ serialize(): ApplyLayoutSerialized;
98
+ static deserialize(canvas: Canvas, serialized: ApplyLayoutSerialized): ApplyLayoutCollabAction;
99
+ }
70
100
  /**
71
101
  * @private
72
102
  */
@@ -115,6 +145,32 @@ export declare class SetGeometryCollabAction implements CollabAction {
115
145
  serialize(): SetGeometrySerialized;
116
146
  static deserialize(canvas: Canvas, serialized: SetGeometrySerialized): SetGeometryCollabAction;
117
147
  }
148
+ /**
149
+ * @private
150
+ */
151
+ export type SetParentSerialized = {
152
+ type: 'setParent';
153
+ childId: string;
154
+ parentId: string | undefined;
155
+ childGeometry: DiagramNodeGeometry;
156
+ timestamp: CollabTimestamp;
157
+ };
158
+ /**
159
+ * Collaborative action which consists of setting a node's parent.
160
+ * @private
161
+ * @see SetParentAction
162
+ */
163
+ export declare class SetParentCollabAction implements CollabAction {
164
+ readonly canvas: Canvas;
165
+ readonly childId: string;
166
+ readonly parentId: string | undefined;
167
+ readonly childGeometry: DiagramNodeGeometry;
168
+ readonly timestamp: CollabTimestamp;
169
+ constructor(canvas: Canvas, childId: string, parentId: string | undefined, childGeometry: DiagramNodeGeometry, timestamp: CollabTimestamp);
170
+ do(): void;
171
+ serialize(): SetParentSerialized;
172
+ static deserialize(canvas: Canvas, serialized: SetParentSerialized): SetParentCollabAction;
173
+ }
118
174
  /**
119
175
  * @private
120
176
  */
@@ -32,6 +32,7 @@ export interface DagaModel {
32
32
  export interface DagaNode {
33
33
  id: string;
34
34
  type: string;
35
+ children?: DagaNode[];
35
36
  sections?: DagaSection[];
36
37
  ports?: DagaPort[];
37
38
  label: string;
@@ -4,7 +4,7 @@ import { DagaConnection, DagaNode } from './converters/daga-model';
4
4
  import { DiagramConnectionType } from './model/diagram-connection';
5
5
  import { DiagramNodeGeometry, DiagramNodeType } from './model/diagram-node';
6
6
  /**
7
- * A stack of recent actions taken by the user that can be undone and redone.
7
+ * A stack of recent actions taken by the user.
8
8
  * @private
9
9
  */
10
10
  export declare class ActionStack {
@@ -47,7 +47,17 @@ export declare class ActionStack {
47
47
  redo(): void;
48
48
  }
49
49
  /**
50
- * An action taken by the user that can be undone and redone.
50
+ * The different methods of an action.
51
+ * @private
52
+ */
53
+ export declare enum DiagramActionMethod {
54
+ Do = 0,
55
+ Undo = 1,
56
+ Redo = 2
57
+ }
58
+ /**
59
+ * An action taken by the user that can be undone and redone and implies a change to the diagram's model.
60
+ * Contrast with {@link DiagramEvent} which doesn't have an impact on the diagram's model.
51
61
  * @private
52
62
  */
53
63
  export interface DiagramAction {
@@ -92,6 +102,12 @@ export declare enum DiagramActions {
92
102
  * @see AddNodeAction
93
103
  */
94
104
  AddNode = "add-node",
105
+ /**
106
+ * Action that corresponds to applying a layout which changes the location of several nodes.
107
+ * @public
108
+ * @see ApplyLayoutAction
109
+ */
110
+ ApplyLayout = "apply-layout",
95
111
  /**
96
112
  * Action that corresponds to copying diagram elements to the clipboard.
97
113
  * @public
@@ -160,18 +176,43 @@ export declare class AddNodeAction implements DiagramAction {
160
176
  readonly canvas: Canvas;
161
177
  type: DiagramNodeType;
162
178
  coords: Point;
179
+ parentId?: string;
180
+ ancestorId?: string | undefined;
181
+ fromAncestorGeometry?: DiagramNodeGeometry | undefined;
182
+ toAncestorGeometry?: DiagramNodeGeometry | undefined;
163
183
  label?: string;
164
184
  values?: {
165
185
  [key: string]: unknown;
166
186
  };
167
187
  id: string;
168
- constructor(canvas: Canvas, type: DiagramNodeType, coords: Point, label?: string, values?: {
188
+ constructor(canvas: Canvas, type: DiagramNodeType, coords: Point, parentId?: string, ancestorId?: string | undefined, fromAncestorGeometry?: DiagramNodeGeometry | undefined, toAncestorGeometry?: DiagramNodeGeometry | undefined, label?: string, values?: {
169
189
  [key: string]: unknown;
170
190
  });
171
191
  do(): boolean;
172
192
  undo(): boolean;
173
193
  redo(): boolean;
174
194
  }
195
+ /**
196
+ * Action which consists of applying a layout to the diagram which can change the location of several nodes.
197
+ * @private
198
+ */
199
+ export declare class ApplyLayoutAction implements DiagramAction {
200
+ readonly canvas: Canvas;
201
+ from: {
202
+ [key: string]: Point;
203
+ };
204
+ to: {
205
+ [key: string]: Point;
206
+ };
207
+ constructor(canvas: Canvas, from: {
208
+ [key: string]: Point;
209
+ }, to: {
210
+ [key: string]: Point;
211
+ });
212
+ do(): boolean;
213
+ undo(): boolean;
214
+ redo(): boolean;
215
+ }
175
216
  /**
176
217
  * Action which consists of changing the coordinates of diagram elements by a fixed amount.
177
218
  * @private
@@ -196,7 +237,29 @@ export declare class SetGeometryAction implements DiagramAction {
196
237
  nodeId: string;
197
238
  from: DiagramNodeGeometry;
198
239
  to: DiagramNodeGeometry;
199
- constructor(canvas: Canvas, intent: DiagramActions.MoveNode | DiagramActions.StretchNode | DiagramActions.StretchSection, nodeId: string, from: DiagramNodeGeometry, to: DiagramNodeGeometry);
240
+ ancestorId: string | undefined;
241
+ fromAncestorGeometry: DiagramNodeGeometry | undefined;
242
+ toAncestorGeometry: DiagramNodeGeometry | undefined;
243
+ constructor(canvas: Canvas, intent: DiagramActions.MoveNode | DiagramActions.StretchNode | DiagramActions.StretchSection, nodeId: string, from: DiagramNodeGeometry, to: DiagramNodeGeometry, ancestorId?: string | undefined, fromAncestorGeometry?: DiagramNodeGeometry | undefined, toAncestorGeometry?: DiagramNodeGeometry | undefined);
244
+ do(): boolean;
245
+ undo(): boolean;
246
+ redo(): boolean;
247
+ }
248
+ /**
249
+ * Action which consists of setting a node's parent.
250
+ * @private
251
+ */
252
+ export declare class SetParentAction implements DiagramAction {
253
+ readonly canvas: Canvas;
254
+ childId: string;
255
+ fromParentId: string | undefined;
256
+ toParentId: string | undefined;
257
+ fromChildGeometry: DiagramNodeGeometry;
258
+ toChildGeometry: DiagramNodeGeometry;
259
+ ancestorId: string | undefined;
260
+ fromAncestorGeometry: DiagramNodeGeometry | undefined;
261
+ toAncestorGeometry: DiagramNodeGeometry | undefined;
262
+ constructor(canvas: Canvas, childId: string, fromParentId: string | undefined, toParentId: string | undefined, fromChildGeometry: DiagramNodeGeometry, toChildGeometry: DiagramNodeGeometry, ancestorId: string | undefined, fromAncestorGeometry: DiagramNodeGeometry | undefined, toAncestorGeometry: DiagramNodeGeometry | undefined);
200
263
  do(): boolean;
201
264
  undo(): boolean;
202
265
  redo(): boolean;
@@ -1,6 +1,6 @@
1
1
  import { Point } from '../util/canvas-util';
2
- import { LineShape, LineStyle } from '../util/line';
3
- import { ClosedShape } from '../util/shape';
2
+ import { LineFunction, LineShape, LineStyle } from '../util/line';
3
+ import { ClosedShape, ShapeFunction } from '../util/shape';
4
4
  import { Corner, HorizontalAlign, Side, VerticalAlign } from '../util/svg-util';
5
5
  import { DiagramActions } from './diagram-action';
6
6
  import { Property } from './model/diagram-property';
@@ -335,6 +335,10 @@ export interface NodeTemplateConfig {
335
335
  * Id of the type of node of this template. Must correspond to the id of a type of node defined in the nodeTypes list.
336
336
  */
337
337
  type: string;
338
+ /**
339
+ * Look of this template as it appears on the palette which can be used to override the default look of the nodes of this type.
340
+ */
341
+ look?: NodeShapedLook | NodeImageLook | NodeStretchableImageLook;
338
342
  /**
339
343
  * Label of this template as it appears on the palette and label that will be given to nodes created from this template.
340
344
  */
@@ -433,6 +437,11 @@ export interface NodeTypeConfig {
433
437
  * @default false
434
438
  */
435
439
  resizableY?: boolean;
440
+ /**
441
+ * The padding between the node and its children in diagram units if children are present. May be a single value or an array, in which case the value is interpreted in the same way as in CSS padding.
442
+ * @default 0
443
+ */
444
+ padding?: number | number[];
436
445
  /**
437
446
  * Configuration for the label of nodes of this type.
438
447
  * @default null
@@ -458,6 +467,16 @@ export interface NodeTypeConfig {
458
467
  * @default false
459
468
  */
460
469
  isUnique?: boolean;
470
+ /**
471
+ * Whether nodes of this type can exist without being contained within another node.
472
+ * @default true
473
+ */
474
+ canBeParentless?: boolean;
475
+ /**
476
+ * Ids of the types of nodes that can be contained within this node. Must correspond to the ids of types of node defined in the nodeTypes list.
477
+ * @default []
478
+ */
479
+ childrenTypes?: string[];
461
480
  /**
462
481
  * The priority of this node when filtering out nodes below a given threshold.
463
482
  * @default 0
@@ -621,7 +640,7 @@ export interface NodeShapedLook {
621
640
  /**
622
641
  * Shape of nodes using this look.
623
642
  */
624
- shape: ClosedShape;
643
+ shape: ClosedShape | ShapeFunction;
625
644
  /**
626
645
  * Background color of nodes using this look.
627
646
  */
@@ -788,7 +807,7 @@ export interface ConnectionTypeConfig {
788
807
  * Shape of the line of connections of this type.
789
808
  * @default 'straight'
790
809
  */
791
- shape?: LineShape;
810
+ shape?: LineShape | LineFunction;
792
811
  /**
793
812
  * Style of the line of connections of this type.
794
813
  * @default 'solid'
@@ -1,16 +1,82 @@
1
1
  import { Point } from '../util/canvas-util';
2
- import { Events } from '../util/events';
3
2
  import { DiagramElement } from './model/diagram-element';
4
3
  /**
5
- * Represents an action taken by the user on the diagram.
4
+ * Represents an action taken by the user on the diagram which doesn't have an impact on the diagram's model.
5
+ * Contrast with {@link DiagramAction} which does have an impact on the diagram's model.
6
6
  * @public
7
7
  */
8
- export declare class DiagramEvent {
9
- cause: Event;
10
- type: Events;
11
- target?: DiagramElement;
12
- coords?: Point;
8
+ export declare abstract class DiagramEvent {
9
+ readonly type: DiagramEvents;
13
10
  defaultPrevented: boolean;
14
- constructor(cause: Event, type: Events, target?: DiagramElement, coords?: Point);
11
+ constructor(type: DiagramEvents);
15
12
  preventDefault(): void;
16
13
  }
14
+ /**
15
+ * Diagram user events.
16
+ * @public
17
+ */
18
+ export declare enum DiagramEvents {
19
+ DoubleClick = 0,
20
+ SecondaryClick = 1,
21
+ Selection = 2,
22
+ Highlight = 3
23
+ }
24
+ /**
25
+ * Diagram event which consists of the user performing a double click on the diagram.
26
+ */
27
+ export declare class DiagramDoubleClickEvent extends DiagramEvent {
28
+ cause: MouseEvent;
29
+ target: DiagramElement | null;
30
+ coords?: Point;
31
+ /**
32
+ * Create a diagram double click event.
33
+ *
34
+ * @param cause Mouse event which triggered this event.
35
+ * @param target Diagram element which is targeted by the event, or null if no element was targeted (the diagram background was targeted).
36
+ * @param coords Optionally, coordinates of the point of the diagram where the event happened.
37
+ */
38
+ constructor(cause: MouseEvent, target: DiagramElement | null, coords?: Point);
39
+ }
40
+ /**
41
+ * Diagram event which consists of the user performing a secondary click on the diagram.
42
+ */
43
+ export declare class DiagramSecondaryClickEvent extends DiagramEvent {
44
+ cause: MouseEvent;
45
+ target: DiagramElement | null;
46
+ coords?: Point;
47
+ /**
48
+ * Create a diagram secondary click event.
49
+ *
50
+ * @param cause Mouse event which triggered this event.
51
+ * @param target Diagram element which is targeted by the event, or null if no element was targeted (the diagram background was targeted).
52
+ * @param coords Optionally, coordinates of the point of the diagram where the event happened.
53
+ */
54
+ constructor(cause: MouseEvent, target: DiagramElement | null, coords?: Point);
55
+ }
56
+ /**
57
+ * Diagram event which consists of the user either adding or removing one or several diagram elements from the user selection.
58
+ */
59
+ export declare class DiagramSelectionEvent extends DiagramEvent {
60
+ targets: DiagramElement[];
61
+ selected: boolean;
62
+ /**
63
+ * Create a diagram selection event.
64
+ *
65
+ * @param targets Diagram elements which are targeted by the event.
66
+ * @param selected `true` if the targets were selected, `false` if the targets were deselected.
67
+ */
68
+ constructor(targets: DiagramElement[], selected: boolean);
69
+ }
70
+ /**
71
+ * Diagram event which consists of the user highlighting a diagram element.
72
+ * If the target is `null`, that means that the previously highlighted element was unhighlighted.
73
+ */
74
+ export declare class DiagramHighlightedEvent extends DiagramEvent {
75
+ target: DiagramElement | null;
76
+ /**
77
+ * Create a diagram highlight event.
78
+ *
79
+ * @param target Diagram element which is targeted by the event.
80
+ */
81
+ constructor(target: DiagramElement | null);
82
+ }
@@ -1,3 +1,4 @@
1
+ import { Point } from '../../util/canvas-util';
1
2
  import { DiagramModel } from '../model/diagram-model';
2
3
  /**
3
4
  * A layout algorithm that can be applied to a diagram.
@@ -16,3 +17,6 @@ export interface DiagramLayout {
16
17
  export declare const layouts: {
17
18
  [key: string]: DiagramLayout;
18
19
  };
20
+ export declare const getLocationsOfNodes: (model: DiagramModel) => {
21
+ [key: string]: Point;
22
+ };
@@ -1,5 +1,5 @@
1
1
  import { Point } from '../../util/canvas-util';
2
- import { LineShape, LineStyle } from '../../util/line';
2
+ import { LineFunction, LineShape, LineStyle } from '../../util/line';
3
3
  import { Side } from '../../util/svg-util';
4
4
  import { ConnectionMarkerLook, ConnectionTypeConfig, FieldConfig } from '../diagram-config';
5
5
  import { DiagramElement, DiagramElementSet } from './diagram-element';
@@ -51,7 +51,7 @@ export declare class DiagramConnectionType implements DiagramEntity {
51
51
  id: string;
52
52
  name: string;
53
53
  width: number;
54
- shape: LineShape;
54
+ shape: LineShape | LineFunction;
55
55
  style: LineStyle;
56
56
  label: FieldConfig | null;
57
57
  defaultStartMarkerLook: ConnectionMarkerLook | null;
@@ -151,6 +151,7 @@ export declare class DiagramConnection extends DiagramElement {
151
151
  constructor(model: DiagramModel, type: DiagramConnectionType, start: DiagramPort | undefined, end: DiagramPort | undefined, id: string);
152
152
  get removed(): boolean;
153
153
  updateInView(): void;
154
+ raise(): void;
154
155
  /**
155
156
  * Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
156
157
  * Add or remove this connection from the list of outgoing connections of ports correspondingly.
@@ -39,6 +39,7 @@ export declare class DiagramDecorator extends DiagramElement {
39
39
  select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
40
40
  get removed(): boolean;
41
41
  updateInView(): void;
42
+ raise(): void;
42
43
  /**
43
44
  * Change the coordinates of this decorator to the given coordinates.
44
45
  * @public
@@ -68,6 +68,11 @@ export declare abstract class DiagramElement implements DiagramEntity {
68
68
  * @public
69
69
  */
70
70
  abstract updateInView(): void;
71
+ /**
72
+ * Put this element above other elements of its kind in the view.
73
+ * @public
74
+ */
75
+ abstract raise(): void;
71
76
  /**
72
77
  * Obtain the selection of this element.
73
78
  * @private
@@ -113,6 +113,7 @@ export declare class DiagramField extends DiagramElement {
113
113
  select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
114
114
  get removed(): boolean;
115
115
  updateInView(): void;
116
+ raise(): void;
116
117
  /**
117
118
  * Change the coordinates of this field to the given coordinates.
118
119
  * @public