@metadev/daga 4.0.2 → 4.2.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": "4.0.2",
3
+ "version": "4.2.0",
4
4
  "dependencies": {},
5
5
  "peerDependencies": {
6
6
  "d3": "^7.9.0",
@@ -27,11 +27,11 @@
27
27
  "./package.json": "./package.json",
28
28
  ".": {
29
29
  "module": "./index.esm.js",
30
- "types": "./index.esm.d.ts",
30
+ "types": "./index.d.ts",
31
31
  "import": "./index.cjs.mjs",
32
32
  "default": "./index.cjs.js"
33
33
  }
34
34
  },
35
35
  "module": "./index.esm.js",
36
- "types": "./index.esm.d.ts"
36
+ "types": "./index.d.ts"
37
37
  }
@@ -116,7 +116,8 @@ export declare class DiagramCanvas implements Canvas {
116
116
  updateDecoratorsInView(...ids: string[]): void;
117
117
  private updateConnectionLabelsInView;
118
118
  private updateConnectionMarkersInView;
119
- fitFieldRootInView(id: string): void;
119
+ fieldRootFitsInView(id: string): boolean;
120
+ fitFieldRootInView(id: string, shrink?: boolean): void;
120
121
  fitNodeInView(id: string): void;
121
122
  selectRoot(): d3.Selection<HTMLDivElement, unknown, null, unknown>;
122
123
  selectSVGElement(): d3.Selection<SVGElement, unknown, null, unknown>;
@@ -32,7 +32,7 @@ export interface CollabAction {
32
32
  /**
33
33
  * @private
34
34
  */
35
- export type CollabActionSerialized = AddNodeSerialized | ApplyLayoutSerialized | MoveSerialized | SetGeometrySerialized | SetParentSerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized | PasteSerialized;
35
+ export type CollabActionSerialized = AddNodeSerialized | AddSectionSerialized | ApplyLayoutSerialized | MoveSerialized | SetGeometrySerialized | SetParentSerialized | AddConnectionSerialized | EditFieldSerialized | UpdateValuesSerialized | SetSelfRemovedSerialized | PasteSerialized;
36
36
  /**
37
37
  * @private
38
38
  */
@@ -69,6 +69,36 @@ export declare class AddNodeCollabAction implements CollabAction {
69
69
  serialize(): AddNodeSerialized;
70
70
  static deserialize(canvas: Canvas, serialized: AddNodeSerialized): AddNodeCollabAction;
71
71
  }
72
+ /**
73
+ * @private
74
+ */
75
+ export type AddSectionSerialized = {
76
+ type: 'addSection';
77
+ nodeId: string;
78
+ copyColumnIndex: number | undefined;
79
+ copyRowIndex: number | undefined;
80
+ removeColumnIndex: number | undefined;
81
+ removeRowIndex: number | undefined;
82
+ timestamp: CollabTimestamp;
83
+ };
84
+ /**
85
+ * Collaborative action which consists of adding or removing sections in a node.
86
+ * @private
87
+ * @see AddNodeAction
88
+ */
89
+ export declare class AddSectionCollabAction implements CollabAction {
90
+ readonly canvas: Canvas;
91
+ readonly nodeId: string;
92
+ readonly copyColumnIndex: number | undefined;
93
+ readonly copyRowIndex: number | undefined;
94
+ readonly removeColumnIndex: number | undefined;
95
+ readonly removeRowIndex: number | undefined;
96
+ readonly timestamp: CollabTimestamp;
97
+ constructor(canvas: Canvas, nodeId: string, copyColumnIndex: number | undefined, copyRowIndex: number | undefined, removeColumnIndex: number | undefined, removeRowIndex: number | undefined, timestamp: CollabTimestamp);
98
+ do(): void;
99
+ serialize(): AddSectionSerialized;
100
+ static deserialize(canvas: Canvas, serialized: AddSectionSerialized): AddSectionCollabAction;
101
+ }
72
102
  /**
73
103
  * @private
74
104
  */
@@ -189,6 +189,14 @@ export interface NodeTemplateConfig {
189
189
  * Id of the type of node of this template. Must correspond to the id of a type of node defined in the nodeTypes list.
190
190
  */
191
191
  type: string;
192
+ /**
193
+ * Width of this template as it appears on the palette. By default, the width of the type of node is used.
194
+ */
195
+ width?: number | null;
196
+ /**
197
+ * Height of this template as it appears on the palette. By default, the height of the type of node is used.
198
+ */
199
+ height?: number | null;
192
200
  /**
193
201
  * 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.
194
202
  */
@@ -3,8 +3,8 @@ import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
3
3
  import { DiagramActions } from '../diagram-action';
4
4
  import { Property } from '../property/property';
5
5
  import { CanvasConfig } from './diagram-canvas-config';
6
- import { ConnectionLookConfig, ImageLookConfig, MarkerImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
7
6
  import { ComponentsConfig } from './diagram-components-config';
7
+ import { ConnectionLookConfig, ImageLookConfig, MarkerImageLookConfig, ShapedLookConfig, StretchableImageLookConfig } from './diagram-look-config';
8
8
  /**
9
9
  * The configuration for a diagram.
10
10
  * @public
@@ -311,6 +311,11 @@ export interface FieldConfig {
311
311
  * @default 'center'
312
312
  */
313
313
  verticalAlign?: VerticalAlign;
314
+ /**
315
+ * The orientation of the text of this field. It may be a side or a number of degrees.
316
+ * @default 'top'
317
+ */
318
+ orientation?: Side | number;
314
319
  /**
315
320
  * Whether this field and its root element should be resized automatically if the size of the text increases.
316
321
  * 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.
@@ -102,6 +102,12 @@ export declare enum DiagramActions {
102
102
  * @see AddNodeAction
103
103
  */
104
104
  AddNode = "add-node",
105
+ /**
106
+ * Action that corresponds to the addition or removal of sections in a node.
107
+ * @public
108
+ * @see AddSectionAction
109
+ */
110
+ AddSectionAction = "add-section",
105
111
  /**
106
112
  * Action that corresponds to applying a layout which changes the location of several nodes.
107
113
  * @public
@@ -192,6 +198,23 @@ export declare class AddNodeAction implements DiagramAction {
192
198
  undo(): boolean;
193
199
  redo(): boolean;
194
200
  }
201
+ /**
202
+ * Action which consists of adding or removing sections in a node.
203
+ * @private
204
+ * @see DiagramSection
205
+ */
206
+ export declare class AddSectionAction implements DiagramAction {
207
+ readonly canvas: Canvas;
208
+ nodeId: string;
209
+ copyColumnIndex: number | undefined;
210
+ copyRowIndex: number | undefined;
211
+ removeColumnIndex: number | undefined;
212
+ removeRowIndex: number | undefined;
213
+ constructor(canvas: Canvas, nodeId: string, copyColumnIndex: number | undefined, copyRowIndex: number | undefined, removeColumnIndex: number | undefined, removeRowIndex: number | undefined);
214
+ do(): boolean;
215
+ undo(): boolean;
216
+ redo(): boolean;
217
+ }
195
218
  /**
196
219
  * Action which consists of applying a layout to the diagram which can change the location of several nodes.
197
220
  * @private
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class AdjacencyLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class BreadthAdjacencyLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class BreadthLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class ForceLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class HorizontalLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class PriorityLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class TreeLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -5,5 +5,7 @@ import { DiagramLayout } from './diagram-layout';
5
5
  * @public
6
6
  */
7
7
  export declare class VerticalLayout implements DiagramLayout {
8
+ gapSize?: number;
9
+ constructor(gapSize?: number);
8
10
  apply(model: DiagramModel): DiagramModel;
9
11
  }
@@ -73,7 +73,7 @@ export declare abstract class DiagramElement implements DiagramEntity {
73
73
  */
74
74
  abstract updateInView(): void;
75
75
  /**
76
- * Put this element above other elements of its kind in the view.
76
+ * Put this element above other elements in the view.
77
77
  * @public
78
78
  */
79
79
  abstract raise(): void;
@@ -1,5 +1,5 @@
1
1
  import { Point } from '../../util/canvas-util';
2
- import { HorizontalAlign, VerticalAlign } from '../../util/svg-util';
2
+ import { HorizontalAlign, Side, VerticalAlign } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from '../collab/primitives';
4
4
  import { FieldConfig } from '../config/diagram-config';
5
5
  import { DiagramElement, DiagramElementSet } from './diagram-element';
@@ -19,6 +19,7 @@ export declare const DIAGRAM_FIELD_DEFAULTS: {
19
19
  selectedColor: string;
20
20
  horizontalAlign: HorizontalAlign;
21
21
  verticalAlign: VerticalAlign;
22
+ orientation: Side;
22
23
  fit: boolean;
23
24
  };
24
25
  export interface LabeledElement {
@@ -82,6 +83,11 @@ export declare class DiagramField extends DiagramElement {
82
83
  * @public
83
84
  */
84
85
  verticalAlign: VerticalAlign;
86
+ /**
87
+ * Orientation of the text of this field.
88
+ * @public
89
+ */
90
+ orientation: Side | number;
85
91
  private _text;
86
92
  /**
87
93
  * Default text that this field's text resets to when empty.
@@ -109,7 +115,7 @@ export declare class DiagramField extends DiagramElement {
109
115
  * @public
110
116
  */
111
117
  fit: boolean;
112
- 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, text: string, editable: boolean, fit: boolean);
118
+ 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);
113
119
  get removed(): boolean;
114
120
  updateInView(): void;
115
121
  raise(): void;
@@ -132,7 +138,7 @@ export declare class DiagramFieldSet extends DiagramElementSet<DiagramField> {
132
138
  * 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.
133
139
  * @private
134
140
  */
135
- new(rootElement: (LabeledElement & DiagramElement) | undefined, coords: Point, fontSize: number, fontFamily: string | null, color: string, selectedColor: string, width: number, height: number, horizontalAlign: HorizontalAlign, verticalAlign: VerticalAlign, text: string, editable: boolean, fit: boolean): DiagramField;
141
+ 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): DiagramField;
136
142
  remove(id: string): void;
137
143
  }
138
144
  export declare const getBottomMargin: (config?: FieldConfig | null) => number;
@@ -276,6 +276,26 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
276
276
  * @public
277
277
  */
278
278
  setGeometry(geometry: DiagramNodeGeometry): void;
279
+ /**
280
+ * Removes all sections with the given index along the x axis.
281
+ * @public
282
+ */
283
+ removeSectionColumn(columnIndex: number): void;
284
+ /**
285
+ * Removes all sections with the given index along the y axis.
286
+ * @public
287
+ */
288
+ removeSectionRow(rowIndex: number): void;
289
+ /**
290
+ * Creates a copy of all sections with the given index along the x axis.
291
+ * @public
292
+ */
293
+ copySectionColumn(columnIndex: number): void;
294
+ /**
295
+ * Creates a copy of all sections with the given index along the y axis.
296
+ * @public
297
+ */
298
+ copySectionRow(rowIndex: number): void;
279
299
  }
280
300
  export declare class DiagramNodeSet extends DiagramElementSet<DiagramNode> {
281
301
  private model;
@@ -284,11 +284,18 @@ export interface Canvas {
284
284
  * @public
285
285
  */
286
286
  updateDecoratorsInView(...ids: string[]): void;
287
+ /**
288
+ * Checks whether the root of a diagram field encompasses the totality of the field.
289
+ * @param id The id of a diagram field
290
+ * @returns `true` if the root of a diagram field encompasses the totality of the field, `false` otherwise.
291
+ */
292
+ fieldRootFitsInView(id: string): boolean;
287
293
  /**
288
294
  * Fit the root of a diagram field to encompass the totality of the field.
289
295
  * @param id The id of a diagram field
296
+ * @param shrink Whether the root of the diagram field should shrink if there is excess space; `true` by default
290
297
  */
291
- fitFieldRootInView(id: string): void;
298
+ fitFieldRootInView(id: string, shrink?: boolean): void;
292
299
  /**
293
300
  * Fit a node to encompass the totality of its sections.
294
301
  * @param id The id of a node
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src\\index";
package/index.esm.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src\\index";