@metadev/daga 5.0.2 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
@@ -15,7 +15,6 @@
15
15
  "index.cjs.d.ts",
16
16
  "index.cjs.default.js",
17
17
  "index.cjs.js",
18
- "index.cjs.mjs",
19
18
  "index.esm.d.ts",
20
19
  "index.esm.js",
21
20
  "package.json",
@@ -26,12 +25,12 @@
26
25
  "exports": {
27
26
  "./package.json": "./package.json",
28
27
  ".": {
28
+ "types": "./src/index.d.ts",
29
29
  "module": "./index.esm.js",
30
- "types": "./index.d.ts",
31
- "import": "./index.cjs.mjs",
30
+ "import": "./index.esm.js",
32
31
  "default": "./index.cjs.js"
33
32
  }
34
33
  },
35
34
  "module": "./index.esm.js",
36
- "types": "./index.d.ts"
35
+ "types": "./src/index.d.ts"
37
36
  }
package/src/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { CollabClient } from './lib/diagram/collab/collab-client';
9
9
  export type { CollabTimestamp, CollabTimestampSet } from './lib/diagram/collab/primitives';
10
10
  export type { CanvasConfig, GridConfig, GridStyle } from './lib/diagram/config/diagram-canvas-config';
11
11
  export type { ButtonsComponentConfig, ComponentsConfig, ConnectionTemplateConfig, ErrorsComponentConfig, NodeTemplateConfig, PaletteComponentConfig, PaletteSectionConfig, PropertyEditorComponentConfig } from './lib/diagram/config/diagram-components-config';
12
+ export { ResizableMode } from './lib/diagram/config/diagram-config';
12
13
  export type { ConnectionTypeConfig, DiagramConfig, FieldConfig, NodeTypeConfig, PortConfig, PortTypeConfig, SectionConfig, SectionGridConfig, UserActionConfig } from './lib/diagram/config/diagram-config';
13
14
  export type { ConnectionLook, ConnectionLookConfig, ImageLook, ImageLookConfig, Look, LookConfig, MarkerImageLook, MarkerImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from './lib/diagram/config/diagram-look-config';
14
15
  export { DagaExporter } from './lib/diagram/converters/daga-exporter';
@@ -18,7 +19,7 @@ export type { DiagramModelExporter } from './lib/diagram/converters/diagram-mode
18
19
  export type { DiagramModelImporter } from './lib/diagram/converters/diagram-model-importer';
19
20
  export { ActionStack, AddConnectionAction, AddNodeAction, ApplyLayoutAction, DiagramActionMethod, DiagramActions, EditFieldAction, MoveAction, PasteAction, RemoveAction, SetGeometryAction, SetParentAction, UpdateValuesAction } from './lib/diagram/diagram-action';
20
21
  export type { DiagramAction } from './lib/diagram/diagram-action';
21
- export { DiagramDoubleClickEvent, DiagramEvent, DiagramEvents, DiagramHighlightedEvent, DiagramSecondaryClickEvent, DiagramSelectionEvent, DiagramZoomEvent } from './lib/diagram/diagram-event';
22
+ export { DiagramDoubleClickEvent, DiagramEvent, DiagramEvents, DiagramHighlightedEvent, DiagramDraggingNodeEvent, DiagramSecondaryClickEvent, DiagramSelectionEvent, DiagramZoomEvent } from './lib/diagram/diagram-event';
22
23
  export { AdjacencyLayout } from './lib/diagram/layout/adjacency-layout';
23
24
  export { BreadthAdjacencyLayout } from './lib/diagram/layout/breadth-adjacency-layout';
24
25
  export { BreadthLayout } from './lib/diagram/layout/breadth-layout';
@@ -20,9 +20,11 @@ export declare const isSecondaryButton: (event: MouseEvent) => boolean;
20
20
  * @private
21
21
  * @see linePath
22
22
  */
23
- export declare const getConnectionPath: (shape: LineShape | LineFunction, startCoords: Point, endCoords: Point, startDirection: Side | undefined, endDirection: Side | undefined, width: number, startMarkerWidth: number | undefined, endMarkerWidth: number | undefined) => string;
23
+ export declare const getConnectionPath: (shape: LineShape | LineFunction, startCoords: Point, endCoords: Point, startDirection: Side | undefined, endDirection: Side | undefined, points: Point[], width: number, startMarkerWidth: number | undefined, endMarkerWidth: number | undefined) => string;
24
24
  export declare const setCursorStyle: (style?: CursorStyle) => void;
25
25
  export declare const getRelatedNodeOrItself: (element: DiagramNode | DiagramSection | DiagramPort | DiagramField) => DiagramNode | DiagramSection | DiagramPort | DiagramField;
26
+ export declare const needsResizerX: (element: DiagramNode | DiagramSection) => boolean;
27
+ export declare const needsResizerY: (element: DiagramNode | DiagramSection) => boolean;
26
28
  export declare const initializeLook: (selection: d3.Selection<SVGGElement, DiagramNode | DiagramSection | DiagramPort, d3.BaseType, unknown>) => void;
27
29
  export declare const SHAPED_LOOK_DEFAULTS: {
28
30
  fillColor: string;
@@ -53,6 +53,7 @@ export declare class DiagramCanvas implements Canvas {
53
53
  get connectionType(): DiagramConnectionType | undefined;
54
54
  set connectionType(value: DiagramConnectionType | undefined);
55
55
  autoTightenConnections: boolean;
56
+ tightenConnectionsAcrossPortTypes: boolean;
56
57
  allowConnectionLoops: boolean;
57
58
  allowSharingPorts: boolean;
58
59
  allowSharingBothPorts: boolean;
@@ -73,6 +74,7 @@ export declare class DiagramCanvas implements Canvas {
73
74
  * Invisible path followed by an unfinished connection. Used for making unfinished connections stop before the cursor rather than stopping right at the cursor.
74
75
  */
75
76
  private unfinishedConnectionTracer?;
77
+ private unfinishedConnectionPort?;
76
78
  private inputFieldContainer?;
77
79
  private multipleSelectionContainer?;
78
80
  private draggingFrom;
@@ -105,7 +107,8 @@ export declare class DiagramCanvas implements Canvas {
105
107
  getViewCoordinates(): Point;
106
108
  translateBy(x: number, y: number): void;
107
109
  translateTo(x: number, y: number): void;
108
- center(): void;
110
+ zoomAndPanTo(x: number, y: number, z: number, duration?: number): void;
111
+ center(nodeIds?: string[], maxZoomLevel?: number, duration?: number): void;
109
112
  getClosestGridPoint(point: Point): Point;
110
113
  getCoordinatesOnScreen(): [Point, Point];
111
114
  private getEventHoldingCoordinates;
@@ -135,9 +138,12 @@ export declare class DiagramCanvas implements Canvas {
135
138
  private dropConnection;
136
139
  cancelAllUserActions(): void;
137
140
  canUserPerformAction(action: DiagramActions): boolean;
141
+ openTextInput(id: string): void;
138
142
  private createInputField;
139
143
  private removeInputField;
140
144
  private minimumSizeOfField;
145
+ private setFieldTextAndWrap;
146
+ private setFieldText;
141
147
  /**
142
148
  * Method to call to start the moving of a node triggered by a user drag event.
143
149
  */
@@ -52,6 +52,11 @@ export interface ButtonsComponentConfig {
52
52
  * @default 'top'
53
53
  */
54
54
  direction?: Side;
55
+ /**
56
+ * Duration of the center animation when pressing the center button. May be set to `0` or `undefined` to make it instant without animation.
57
+ * @default undefined
58
+ */
59
+ centerAnimationDuration?: number;
55
60
  /**
56
61
  * Whether to enable the user action (undo, redo) buttons in this component.
57
62
  * @default true
@@ -103,6 +103,11 @@ export interface ConnectionSettingsConfig {
103
103
  * @default true
104
104
  */
105
105
  autoTighten?: boolean;
106
+ /**
107
+ * When tightening a connection allow changing the start and end ports to ports of a different type.
108
+ * @default false
109
+ */
110
+ tightenAcrossPortTypes?: boolean;
106
111
  /**
107
112
  * Whether a connection can use the same port as start and end.
108
113
  * @default false
@@ -169,12 +174,12 @@ export interface NodeTypeConfig {
169
174
  * Whether the user can resize nodes of this type along the x axis.
170
175
  * @default false
171
176
  */
172
- resizableX?: boolean;
177
+ resizableX?: boolean | ResizableMode;
173
178
  /**
174
179
  * Whether the user can resize nodes of this type along the y axis.
175
180
  * @default false
176
181
  */
177
- resizableY?: boolean;
182
+ resizableY?: boolean | ResizableMode;
178
183
  /**
179
184
  * By how much the location of nodes of this type should be offset when snapping to grid in diagram units.
180
185
  * Each value corresponds to left, top, right and bottom respectively.
@@ -381,6 +386,11 @@ export interface FieldConfig {
381
386
  * @default 'top'
382
387
  */
383
388
  orientation?: Side | number;
389
+ /**
390
+ * Whether this field can have multiple lines.
391
+ * @default false
392
+ */
393
+ multiline?: boolean;
384
394
  /**
385
395
  * Whether this field and its root element should be resized automatically if the size of the text increases.
386
396
  * Setting this to true should also entail setting reasonable `minWidth` and `minHeight` values for the configuration of any nodes or sections that contain this field.
@@ -499,13 +509,13 @@ export interface SectionConfig {
499
509
  * If undefined, inherits from the parent node's resizableX setting.
500
510
  * @default undefined
501
511
  */
502
- resizableX?: boolean;
512
+ resizableX?: boolean | ResizableMode;
503
513
  /**
504
514
  * Whether this section can be resized vertically.
505
515
  * If undefined, inherits from the parent node's resizableY setting.
506
516
  * @default undefined
507
517
  */
508
- resizableY?: boolean;
518
+ resizableY?: boolean | ResizableMode;
509
519
  }
510
520
  /**
511
521
  * Configuration for a type of connection.
@@ -556,3 +566,6 @@ export interface ConnectionTypeConfig {
556
566
  */
557
567
  properties?: Property[];
558
568
  }
569
+ export declare enum ResizableMode {
570
+ OnlyWhenSelected = 0
571
+ }
@@ -1,5 +1,6 @@
1
1
  import { Point } from '../util/canvas-util';
2
2
  import { DiagramElement } from './model/diagram-element';
3
+ import { DiagramNode } from './model/diagram-node';
3
4
  /**
4
5
  * Represents an action taken by the user on the diagram which doesn't have an impact on the diagram's model.
5
6
  * Contrast with {@link DiagramAction} which does have an impact on the diagram's model.
@@ -20,7 +21,8 @@ export declare enum DiagramEvents {
20
21
  DoubleClick = 1,
21
22
  SecondaryClick = 2,
22
23
  Selection = 3,
23
- Highlight = 4
24
+ Highlight = 4,
25
+ DraggingNode = 5
24
26
  }
25
27
  /**
26
28
  * Diagram event which consists of the user zooming or panning.
@@ -94,3 +96,15 @@ export declare class DiagramHighlightedEvent extends DiagramEvent {
94
96
  */
95
97
  constructor(target: DiagramElement | null);
96
98
  }
99
+ /**
100
+ * Diagram event which consists of the user dragging a diagram node.
101
+ */
102
+ export declare class DiagramDraggingNodeEvent extends DiagramEvent {
103
+ target: DiagramNode;
104
+ /**
105
+ * Create a diagram dragging node event.
106
+ *
107
+ * @param target Diagram node which is targeted by the event.
108
+ */
109
+ constructor(target: DiagramNode);
110
+ }
@@ -138,7 +138,7 @@ export declare class DiagramConnection extends DiagramElement {
138
138
  */
139
139
  endLabel: string;
140
140
  /**
141
- * Points that this connection passes through.
141
+ * Points that this connection must pass through in its route from its start point to its end point, in order.
142
142
  * @public
143
143
  */
144
144
  points: Point[];
@@ -21,6 +21,7 @@ export declare const DIAGRAM_FIELD_DEFAULTS: {
21
21
  horizontalAlign: HorizontalAlign;
22
22
  verticalAlign: VerticalAlign;
23
23
  orientation: Side;
24
+ multiline: boolean;
24
25
  fit: boolean;
25
26
  shrink: boolean;
26
27
  };
@@ -90,6 +91,11 @@ export declare class DiagramField extends DiagramElement {
90
91
  * @public
91
92
  */
92
93
  orientation: number;
94
+ /**
95
+ * Whether this field can have multiple lines.
96
+ * @public
97
+ */
98
+ multiline: boolean;
93
99
  private _text;
94
100
  /**
95
101
  * Default text that this field's text resets to when empty.
@@ -122,7 +128,7 @@ export declare class DiagramField extends DiagramElement {
122
128
  * @public
123
129
  */
124
130
  shrink: boolean;
125
- constructor(model: DiagramModel, rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, text: string, editable: boolean, fit: boolean, shrink: boolean);
131
+ constructor(model: DiagramModel, rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, width: number, height: number, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, text: string, editable: boolean, fit: boolean, shrink: boolean);
126
132
  get removed(): boolean;
127
133
  updateInView(): void;
128
134
  raise(): void;
@@ -145,7 +151,7 @@ export declare class DiagramFieldSet extends DiagramElementSet<DiagramField> {
145
151
  * Instance a new field and add it to this set. This method is normally called when instancing an element with a field and it is rarely called by itself.
146
152
  * @private
147
153
  */
148
- new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, text: string, editable: boolean, fit: boolean, shrink: boolean): DiagramField;
154
+ new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, orientation: Side | number, multiline: boolean, text: string, editable: boolean, fit: boolean, shrink: boolean): DiagramField;
149
155
  remove(id: string): void;
150
156
  }
151
157
  export declare const getBottomMargin: (config?: FieldConfig | null) => number;
@@ -1,7 +1,7 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
- import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig } from '../config/diagram-config';
4
+ import { DecoratorConfig, FieldConfig, NodeTypeConfig, PortConfig, ResizableMode } from '../config/diagram-config';
5
5
  import { ImageLook, ImageLookConfig, ShapedLook, ShapedLookConfig, StretchableImageLook, StretchableImageLookConfig } from '../config/diagram-look-config';
6
6
  import { PropertySet } from '../property/property';
7
7
  import { ValueSet } from '../property/value';
@@ -75,8 +75,8 @@ export declare class DiagramNodeType implements DiagramEntity {
75
75
  defaultHeight: number;
76
76
  minWidth: number;
77
77
  minHeight: number;
78
- resizableX: boolean;
79
- resizableY: boolean;
78
+ resizableX: boolean | ResizableMode;
79
+ resizableY: boolean | ResizableMode;
80
80
  snapToGridOffset: [number, number, number, number];
81
81
  bottomPadding: number;
82
82
  leftPadding: number;
@@ -207,6 +207,16 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
207
207
  updateInView(): void;
208
208
  raise(): void;
209
209
  getPriority(): number;
210
+ /**
211
+ * Returns whether this node can be resized horizontally.
212
+ * @public
213
+ */
214
+ getResizableX(): boolean;
215
+ /**
216
+ * Returns whether this node can be resized vertically.
217
+ * @public
218
+ */
219
+ getResizableY(): boolean;
210
220
  /**
211
221
  * Get the port of this node which is closest to the given coordinates.
212
222
  * @param coords A point in the diagram.
@@ -173,7 +173,7 @@ export declare class DiagramPort extends DiagramElement implements LabeledElemen
173
173
  constructor(model: DiagramModel, type: DiagramPortType | undefined, rootElement: DiagramNode | DiagramSection | undefined, coords: Point, connectionPoint: Point | undefined, direction: Side, id: string, anchorPointX?: AnchorPoint, anchorPointY?: AnchorPoint);
174
174
  get removed(): boolean;
175
175
  updateInView(): void;
176
- raise(): void;
176
+ raise(raiseConnections?: boolean): void;
177
177
  /**
178
178
  * Add a connection to this port's list of outgoing connections.
179
179
  * @public
@@ -1,6 +1,6 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
- import { FieldConfig, PortConfig, SectionConfig, SectionGridConfig } from '../config/diagram-config';
3
+ import { FieldConfig, PortConfig, ResizableMode, SectionConfig, SectionGridConfig } from '../config/diagram-config';
4
4
  import { ImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from '../config/diagram-look-config';
5
5
  import { DiagramConnection } from './diagram-connection';
6
6
  import { DiagramDecorator } from './diagram-decorator';
@@ -61,8 +61,8 @@ export declare class DiagramSectionType {
61
61
  highlightedLook: NodeLook;
62
62
  selectedAndHighlightedLook: NodeLook;
63
63
  priority: number;
64
- resizableX: boolean | undefined;
65
- resizableY: boolean | undefined;
64
+ resizableX: boolean | ResizableMode | undefined;
65
+ resizableY: boolean | ResizableMode | undefined;
66
66
  constructor(options: SectionConfig);
67
67
  }
68
68
  /**
@@ -108,6 +108,11 @@ export interface Canvas {
108
108
  * @public
109
109
  */
110
110
  autoTightenConnections: boolean;
111
+ /**
112
+ * Whether a connection can be tightened to use ports of a different type.
113
+ * @public
114
+ */
115
+ tightenConnectionsAcrossPortTypes: boolean;
111
116
  /**
112
117
  * Whether a connection can use the same port as start and end.
113
118
  * @public
@@ -195,7 +200,8 @@ export interface Canvas {
195
200
  */
196
201
  zoomTo(level: number): void;
197
202
  /**
198
- * Gets the current coordinates of the view.
203
+ * Gets the current coordinates of the center of view.
204
+ * Ensures that calling `translateTo()` with the result causes no changes.
199
205
  * @public
200
206
  */
201
207
  getViewCoordinates(): Point;
@@ -207,17 +213,30 @@ export interface Canvas {
207
213
  */
208
214
  translateBy(x: number, y: number): void;
209
215
  /**
210
- * Translates the view to the given point.
216
+ * Translates the center of the view to the given point.
211
217
  * @public
212
218
  * @param x A coordinate along the x axis.
213
219
  * @param y A coordinate along the y axis.
214
220
  */
215
221
  translateTo(x: number, y: number): void;
222
+ /**
223
+ * Translates the center of the view to the given point and the given zoom level over the given duration of time.
224
+ * The duration may be set to `0` or `undefined` to make the move instant without animation.
225
+ * @public
226
+ * @param x A coordinate along the x axis.
227
+ * @param y A coordinate along the y axis.
228
+ * @param z A level of zoom.
229
+ * @param duration A duration for the animation in milliseconds. May be set to `0` or `undefined` to make it instant without animation.
230
+ */
231
+ zoomAndPanTo(x: number, y: number, z: number, duration?: number): void;
216
232
  /**
217
233
  * Centers by zooming and translating the view such that every element fits in the view.
218
234
  * @public
235
+ * @param nodeIds A list of node ids to center the view on. If `undefined`, it encompasses all nodes.
236
+ * @param maxZoomLevel The maximum zoom level that can be used when zooming into the elements. Can be used to prevent zooming in past a given level. `1` by default.
237
+ * @param duration A duration for the animation in milliseconds. May be set to `0` or `undefined` to make it instant without animation.
219
238
  */
220
- center(): void;
239
+ center(nodeIds?: string[], maxZoomLevel?: number, duration?: number): void;
221
240
  /**
222
241
  * Get the closest grid point to the given point.
223
242
  * @public
@@ -337,6 +356,11 @@ export interface Canvas {
337
356
  * @param shrink Whether the node should shrink if there is excess space; `true` by default
338
357
  */
339
358
  fitNodeInView(id: string, shrink?: boolean): void;
359
+ /**
360
+ * Open a text input for a field.
361
+ * @param id The id of a field.
362
+ */
363
+ openTextInput(id: string): void;
340
364
  /**
341
365
  * Get the d3 Selection containing the root html div element of the canvas.
342
366
  * @private
@@ -0,0 +1,2 @@
1
+ export declare const isUserAgentSafari: (userAgent: string) => boolean;
2
+ export declare const isSafari: boolean;
@@ -144,7 +144,7 @@ export declare const linesOverlap: (line1: Line, line2: Line) => boolean;
144
144
  */
145
145
  export declare const lineIntersectsRectangle: (line: Line, rectangle: Rectangle) => boolean;
146
146
  /**
147
- * Checks whether the two given reactangles share at least one point.
147
+ * Checks whether the two given rectangles share at least one point.
148
148
  * @public
149
149
  * @param rectangle1 A rectangle.
150
150
  * @param rectangle2 A rectangle.
@@ -9,12 +9,3 @@ export declare const radiansToDegrees: (theta: number) => number;
9
9
  * @returns The size of the bounding box.
10
10
  */
11
11
  export declare const rotate: (width: number, height: number, orientation: number) => [number, number];
12
- /**
13
- * Calculates the original size of the a rectangle that has been rotated by the given number of degrees resulting in a bounding box of the given size.
14
- *
15
- * @param width The width of a bounding box.
16
- * @param height The height of a bounding box.
17
- * @param orientation A rotation in degrees.
18
- * @returns The size of the original rectangle.
19
- */
20
- export declare const unrotate: (width: number, height: number, orientation: number) => [number, number];
@@ -1 +0,0 @@
1
- exports._default = require('./index.cjs.js').default;
package/index.cjs.mjs DELETED
@@ -1,2 +0,0 @@
1
- export * from './index.cjs.js';
2
- export { _default as default } from './index.cjs.default.js';