@metadev/daga 1.5.5 → 1.5.7

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/index.d.ts CHANGED
@@ -14,7 +14,8 @@ export { ACTION_QUEUE_SIZE, DiagramCanvas } from './lib/diagram-editor/diagram/d
14
14
  export { ButtonsComponentConfig, ComponentsConfig, ConnectionMarkerLook, ConnectionTemplateConfig, ConnectionTypeConfig, DiagramConfig, ErrorsComponentConfig, FieldConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTemplateConfig, NodeTypeConfig, PaletteComponentConfig, PaletteSectionConfig, PortConfig, PropertyEditorComponentConfig, SectionConfig, SectionGridConfig, UserActionConfig } from './lib/diagram-editor/diagram/diagram-config';
15
15
  export { DiagramConnection, DiagramConnectionSet, DiagramConnectionType } from './lib/diagram-editor/diagram/diagram-connection';
16
16
  export { DiagramDecorator, DiagramDecoratorSet } from './lib/diagram-editor/diagram/diagram-decorator';
17
- export { DiagramElement, DiagramEntity, DiagramEntitySet } from './lib/diagram-editor/diagram/diagram-element';
17
+ export { DiagramElement, DiagramElementSet } from './lib/diagram-editor/diagram/diagram-element';
18
+ export { DiagramEntity, DiagramEntitySet } from './lib/diagram-editor/diagram/diagram-entity';
18
19
  export { DiagramEvent } from './lib/diagram-editor/diagram/diagram-event';
19
20
  export { DiagramField, DiagramFieldSet } from './lib/diagram-editor/diagram/diagram-field';
20
21
  export { DiagramModel } from './lib/diagram-editor/diagram/diagram-model';
@@ -423,15 +423,15 @@ export interface FieldConfig {
423
423
  */
424
424
  fontSize?: number;
425
425
  /**
426
- * The margin around the field in pixels.
426
+ * The margin around the field in pixels. May be a single value or an array, in which case the value is interpreted in the same way as in CSS margin.
427
427
  * @default 0
428
428
  */
429
- margin?: number;
429
+ margin?: number | number[];
430
430
  /**
431
- * The padding around the field in pixels.
431
+ * The padding around the field in pixels. May be a single value or an array, in which case the value is interpreted in the same way as in CSS padding.
432
432
  * @default 0
433
433
  */
434
- padding?: number;
434
+ padding?: number | number[];
435
435
  /**
436
436
  * The font family of the text of this field.
437
437
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-family |font-family}
@@ -2,7 +2,8 @@ import { Point } from '../../util/canvas-util';
2
2
  import { LineShape, LineStyle } from '../../util/line';
3
3
  import { Side } from '../../util/svg-util';
4
4
  import { ConnectionMarkerLook, ConnectionTypeConfig, FieldConfig } from './diagram-config';
5
- import { DiagramElement, DiagramEntity, DiagramEntitySet } from './diagram-element';
5
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
6
+ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
6
7
  import { DiagramModel } from './diagram-model';
7
8
  import { DiagramPort } from './diagram-port';
8
9
  import { PropertySet, ValueSet } from './diagram-property';
@@ -172,7 +173,7 @@ export declare class DiagramConnection extends DiagramElement {
172
173
  tighten(): void;
173
174
  getPriority(): number;
174
175
  }
175
- export declare class DiagramConnectionSet extends DiagramEntitySet<DiagramConnection> {
176
+ export declare class DiagramConnectionSet extends DiagramElementSet<DiagramConnection> {
176
177
  private model;
177
178
  /**
178
179
  * Set of the possible types of connection that the connections of this set can have.
@@ -1,5 +1,5 @@
1
1
  import { Point } from '../../util/canvas-util';
2
- import { DiagramElement, DiagramEntitySet } from './diagram-element';
2
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
3
3
  import { DiagramModel } from './diagram-model';
4
4
  import { DiagramNode } from './diagram-node';
5
5
  import { DiagramSection } from './diagram-section';
@@ -47,7 +47,7 @@ export declare class DiagramDecorator extends DiagramElement {
47
47
  move(coords: Point): void;
48
48
  getPriority(): number;
49
49
  }
50
- export declare class DiagramDecoratorSet extends DiagramEntitySet<DiagramDecorator> {
50
+ export declare class DiagramDecoratorSet extends DiagramElementSet<DiagramDecorator> {
51
51
  private model;
52
52
  /**
53
53
  * Instance a set of decorators for the given model. This method is used internally.
@@ -1,23 +1,12 @@
1
1
  import * as d3 from 'd3';
2
- import { DiagramModel } from './diagram-model';
3
2
  import { CollabTimestamp } from './collab/primitives';
3
+ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
4
+ import { DiagramModel } from './diagram-model';
4
5
  /**
5
6
  * Default priority value for diagram elements.
6
7
  * @private
7
8
  */
8
9
  export declare const DEFAULT_PRIORITY = 0;
9
- /**
10
- * Represents an object which exists as part of a diagram model.
11
- * @public
12
- * @see DiagramModel
13
- */
14
- export interface DiagramEntity {
15
- /**
16
- * Identifier that uniquely identifies this entity within its diagram model.
17
- * @public
18
- */
19
- get id(): string;
20
- }
21
10
  /**
22
11
  * Represents an object which exists as part of a specific diagram model and has a visual representation in a diagram canvas.
23
12
  * @public
@@ -61,7 +50,8 @@ export declare abstract class DiagramElement implements DiagramEntity {
61
50
  selfRemovedTimestamp: CollabTimestamp | null;
62
51
  constructor(model: DiagramModel, id: string);
63
52
  /**
64
- * Whether this diagram element has been removed.
53
+ * Whether this diagram element has been soft removed, that is,
54
+ * it has been marked as removed but the data is still in the model.
65
55
  *
66
56
  * An element can be removed because it was explicitly removed, or because one of
67
57
  * its dependencies was removed. For example, a DiagramConnection depends on both of its ports.
@@ -85,83 +75,18 @@ export declare abstract class DiagramElement implements DiagramEntity {
85
75
  */
86
76
  select(): d3.Selection<SVGGElement, unknown, null, unknown> | undefined;
87
77
  }
88
- /**
89
- * Represents a collection of diagram entities of a type that exists as part of a diagram model.
90
- * @public
91
- * @see DiagramEntity
92
- * @see DiagramModel
93
- */
94
- export declare class DiagramEntitySet<E extends DiagramEntity> implements Iterable<E> {
95
- /**
96
- * The list of entities contained in this set.
97
- * @private
98
- */
99
- protected entities: E[];
100
- /**
101
- * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
102
- * @private
103
- */
104
- protected entityMap: {
105
- [id: string]: E;
106
- };
107
- /**
108
- * The number of entities of this set.
109
- * @public
110
- */
111
- get length(): number;
112
- /**
113
- * Gets all of the entities of this set.
114
- * @public
115
- * @returns An array containing all of the entities of this set.
116
- */
117
- all(): E[];
118
- /**
119
- * Adds an entity to this set if there are no entities with the same id. Has no effect if there already exists an entity with the same id as the given entity.
120
- * For creating entities with relationships with other entities, the new() method should be used instead. The add() method adds an entity but doesn't take care of setting that entity's relationships with other entities.
121
- * @private
122
- * @param entity An entity to be added to this set.
123
- */
124
- add(entity: E): void;
125
- /**
126
- * Removes all the entities in this set.
127
- * @public
128
- */
129
- clear(): void;
130
- /**
131
- * Checks if this set contains an entity with the given id.
132
- * @public
133
- * @param id An id.
134
- * @returns `true` if this set contains an entity with the given id, `false` otherwise.
135
- */
136
- contains(id: string): boolean;
137
- /**
138
- * Gets all of the entities of this set filtered following given criteria.
139
- * @public
140
- * @returns An array containing the entities of this set that meet the given criteria.
141
- */
142
- filter(predicate: (value: E, index: number, array: E[]) => unknown): E[];
143
- /**
144
- * Gets an entity of this set matching specific criteria.
145
- * @public
146
- * @returns An entity of this set.
147
- */
148
- find(predicate: (value: E, index: number, array: E[]) => unknown): E | undefined;
149
- /**
150
- * Gets an entity from this set.
151
- * @public
152
- * @param id An id.
153
- * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
154
- */
155
- get(id: string): E | undefined;
156
- /**
157
- * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
158
- * @public
159
- * @param id An id.
160
- */
161
- remove(id: string): void;
162
- /**
163
- * Iterator to iterate over the entities of this set.
78
+ export declare class DiagramElementSet<E extends DiagramElement> extends DiagramEntitySet<E> {
79
+ all(includeRemoved?: boolean): E[];
80
+ contains(id: string, includeRemoved?: boolean): boolean;
81
+ count(predicate: (value: E, index: number, array: E[]) => unknown, includeRemoved?: boolean): number;
82
+ filter(predicate: (value: E, index: number, array: E[]) => unknown, includeRemoved?: boolean): E[];
83
+ find(predicate: (value: E, index: number, array: E[]) => unknown, includeRemoved?: boolean): E | undefined;
84
+ get(id: string, includeRemoved?: boolean): E | undefined;
85
+ map<R>(callback: (value: E, index: number, array: E[]) => R, includeRemoved?: boolean): R[];
86
+ /**
87
+ * Gets the number of entities in this set.
164
88
  * @public
165
89
  */
166
- [Symbol.iterator](): Iterator<E>;
90
+ size(includeRemoved?: boolean): number;
91
+ [Symbol.iterator](includeRemoved?: boolean): Iterator<E>;
167
92
  }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Represents an object which exists as part of a diagram model.
3
+ * @public
4
+ * @see DiagramModel
5
+ */
6
+ export interface DiagramEntity {
7
+ /**
8
+ * Identifier that uniquely identifies this entity within its diagram model.
9
+ * @public
10
+ */
11
+ get id(): string;
12
+ }
13
+ /**
14
+ * Represents a collection of diagram entities of a type that exists as part of a diagram model.
15
+ * @public
16
+ * @see DiagramEntity
17
+ * @see DiagramModel
18
+ */
19
+ export declare class DiagramEntitySet<E extends DiagramEntity> implements Iterable<E> {
20
+ /**
21
+ * The list of entities contained in this set.
22
+ * @private
23
+ */
24
+ protected entities: E[];
25
+ /**
26
+ * A mapping of entity ids to their corresponding entity in this set for quickly fetching entities based on their id.
27
+ * @private
28
+ */
29
+ protected entityMap: {
30
+ [id: string]: E;
31
+ };
32
+ /**
33
+ * The number of entities in this set.
34
+ * @public
35
+ */
36
+ get length(): number;
37
+ /**
38
+ * Gets all of the entities of this set.
39
+ * @public
40
+ * @returns An array containing all of the entities of this set.
41
+ */
42
+ all(): E[];
43
+ /**
44
+ * Adds an entity to this set if there are no entities with the same id. Has no effect if there already exists an entity with the same id as the given entity.
45
+ * For creating entities with relationships with other entities, the new() method should be used instead. The add() method adds an entity but doesn't take care of setting that entity's relationships with other entities.
46
+ * @private
47
+ * @param entity An entity to be added to this set.
48
+ */
49
+ add(entity: E): void;
50
+ /**
51
+ * Removes all the entities in this set.
52
+ * @public
53
+ */
54
+ clear(): void;
55
+ /**
56
+ * Checks if this set contains an entity with the given id.
57
+ * @public
58
+ * @param id An id.
59
+ * @returns `true` if this set contains an entity with the given id, `false` otherwise.
60
+ */
61
+ contains(id: string): boolean;
62
+ /**
63
+ * Counts the number of entities of this set following the given criteria.
64
+ * @public
65
+ * @returns The number of entities of this set following the given criteria.
66
+ */
67
+ count(predicate: (value: E, index: number, array: E[]) => unknown): number;
68
+ /**
69
+ * Gets all of the entities of this set filtered following given criteria.
70
+ * @public
71
+ * @returns An array containing the entities of this set that meet the given criteria.
72
+ */
73
+ filter(predicate: (value: E, index: number, array: E[]) => unknown): E[];
74
+ /**
75
+ * Gets an entity of this set matching specific criteria.
76
+ * @public
77
+ * @returns An entity of this set.
78
+ */
79
+ find(predicate: (value: E, index: number, array: E[]) => unknown): E | undefined;
80
+ /**
81
+ * Gets an entity from this set.
82
+ * @public
83
+ * @param id An id.
84
+ * @returns An entity with the given id, or `undefined` if there are no entities with the given id.
85
+ */
86
+ get(id: string): E | undefined;
87
+ /**
88
+ * Gets all of the entities of this set mapped to the result of the given function applied to them.
89
+ * @public
90
+ * @returns An array containing the entities of this set that meet the given criteria.
91
+ */
92
+ map<R>(callback: (value: E, index: number, array: E[]) => R): R[];
93
+ /**
94
+ * Attempts to find and remove an entity with the given id. Has no effect if there are no entities with the given id.
95
+ * @public
96
+ * @param id An id.
97
+ */
98
+ remove(id: string): void;
99
+ /**
100
+ * Gets the number of entities in this set.
101
+ * @public
102
+ */
103
+ size(): number;
104
+ /**
105
+ * Iterator to iterate over the entities of this set.
106
+ * @public
107
+ */
108
+ [Symbol.iterator](): Iterator<E>;
109
+ }
@@ -1,7 +1,8 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { HorizontalAlign, VerticalAlign } from '../../util/svg-util';
3
3
  import { CollabTimestamp } from './collab/primitives';
4
- import { DiagramElement, DiagramEntitySet } from './diagram-element';
4
+ import { FieldConfig } from './diagram-config';
5
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
5
6
  import { DiagramModel } from './diagram-model';
6
7
  import { DiagramNode } from './diagram-node';
7
8
  import { DiagramPort } from './diagram-port';
@@ -120,7 +121,7 @@ export declare class DiagramField extends DiagramElement {
120
121
  move(coords: Point): void;
121
122
  getPriority(): number;
122
123
  }
123
- export declare class DiagramFieldSet extends DiagramEntitySet<DiagramField> {
124
+ export declare class DiagramFieldSet extends DiagramElementSet<DiagramField> {
124
125
  private model;
125
126
  /**
126
127
  * Instance a set of fields for the given model. This method is used internally.
@@ -134,3 +135,11 @@ export declare class DiagramFieldSet extends DiagramEntitySet<DiagramField> {
134
135
  new(rootElement: DiagramNode | DiagramSection | DiagramPort | 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;
135
136
  remove(id: string): void;
136
137
  }
138
+ export declare const getBottomMargin: (config?: FieldConfig | null) => number;
139
+ export declare const getLeftMargin: (config?: FieldConfig | null) => number;
140
+ export declare const getRightMargin: (config?: FieldConfig | null) => number;
141
+ export declare const getTopMargin: (config?: FieldConfig | null) => number;
142
+ export declare const getBottomPadding: (config?: FieldConfig | null) => number;
143
+ export declare const getLeftPadding: (config?: FieldConfig | null) => number;
144
+ export declare const getRightPadding: (config?: FieldConfig | null) => number;
145
+ export declare const getTopPadding: (config?: FieldConfig | null) => number;
@@ -4,7 +4,8 @@ import { CollabTimestamp } from './collab/primitives';
4
4
  import { FieldConfig, NodeImageLook, NodeShapedLook, NodeStretchableImageLook, NodeTypeConfig, PortConfig, SectionGridConfig } from './diagram-config';
5
5
  import { DiagramConnection } from './diagram-connection';
6
6
  import { DiagramDecorator } from './diagram-decorator';
7
- import { DiagramElement, DiagramEntity, DiagramEntitySet } from './diagram-element';
7
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
8
+ import { DiagramEntity, DiagramEntitySet } from './diagram-entity';
8
9
  import { DiagramField } from './diagram-field';
9
10
  import { DiagramModel } from './diagram-model';
10
11
  import { DiagramPort } from './diagram-port';
@@ -148,25 +149,25 @@ export declare class DiagramNode extends DiagramElement {
148
149
  * @public
149
150
  * @returns A list of connections.
150
151
  */
151
- getIncomingConnections(): DiagramConnection[];
152
+ getIncomingConnections(includeRemoved?: boolean): DiagramConnection[];
152
153
  /**
153
154
  * Get all outgoing connections of all ports of this node, not including outgoing connections of sections of this node.
154
155
  * @public
155
156
  * @returns A list of connections.
156
157
  */
157
- getOutgoingConnections(): DiagramConnection[];
158
+ getOutgoingConnections(includeRemoved?: boolean): DiagramConnection[];
158
159
  /**
159
160
  * Get all connections of all ports of this node, not including connections of sections of this node.
160
161
  * @public
161
162
  * @returns A list of connections.
162
163
  */
163
- getConnections(): DiagramConnection[];
164
+ getConnections(includeRemoved?: boolean): DiagramConnection[];
164
165
  /**
165
166
  * Get all nodes that have a direct connection to this node, not including nodes that have a direct connection to sections of this node.
166
167
  * @public
167
168
  * @returns A list of nodes.
168
169
  */
169
- getAdjacentNodes(): DiagramNode[];
170
+ getAdjacentNodes(includeRemoved?: boolean): DiagramNode[];
170
171
  /**
171
172
  * Change the coordinates of this node to the given coordinates and move its sections, ports and labels correspondingly.
172
173
  * @public
@@ -200,7 +201,7 @@ export declare class DiagramNode extends DiagramElement {
200
201
  */
201
202
  setGeometry(geometry: DiagramNodeGeometry): void;
202
203
  }
203
- export declare class DiagramNodeSet extends DiagramEntitySet<DiagramNode> {
204
+ export declare class DiagramNodeSet extends DiagramElementSet<DiagramNode> {
204
205
  private model;
205
206
  /**
206
207
  * Set of the possible types of node that the nodes of this set can have.
@@ -1,5 +1,5 @@
1
1
  import { Point } from '../../util/canvas-util';
2
- import { DiagramElement, DiagramEntitySet } from './diagram-element';
2
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
3
3
  import { DiagramModel } from './diagram-model';
4
4
  /**
5
5
  * A foreign object which is inserted with arbitrary html into a diagram.
@@ -36,7 +36,7 @@ export declare class DiagramObject extends DiagramElement {
36
36
  move(coords: Point): void;
37
37
  getPriority(): number;
38
38
  }
39
- export declare class DiagramObjectSet extends DiagramEntitySet<DiagramObject> {
39
+ export declare class DiagramObjectSet extends DiagramElementSet<DiagramObject> {
40
40
  private model;
41
41
  /**
42
42
  * Instance a set of objects for the given model. This method is used internally.
@@ -1,7 +1,7 @@
1
1
  import { Point } from '../../util/canvas-util';
2
2
  import { Side } from '../../util/svg-util';
3
3
  import { DiagramConnection } from './diagram-connection';
4
- import { DiagramElement, DiagramEntitySet } from './diagram-element';
4
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
5
5
  import { DiagramField } from './diagram-field';
6
6
  import { DiagramModel } from './diagram-model';
7
7
  import { DiagramNode } from './diagram-node';
@@ -84,7 +84,7 @@ export declare class DiagramPort extends DiagramElement {
84
84
  move(coords: Point): void;
85
85
  distanceTo(coords: Point): number;
86
86
  }
87
- export declare class DiagramPortSet extends DiagramEntitySet<DiagramPort> {
87
+ export declare class DiagramPortSet extends DiagramElementSet<DiagramPort> {
88
88
  private model;
89
89
  /**
90
90
  * Instance a set of ports for the given model. This method is used internally.
@@ -3,7 +3,7 @@ import { Side } from '../../util/svg-util';
3
3
  import { NodeShapedLook, SectionConfig } from './diagram-config';
4
4
  import { DiagramConnection } from './diagram-connection';
5
5
  import { DiagramDecorator } from './diagram-decorator';
6
- import { DiagramElement, DiagramEntitySet } from './diagram-element';
6
+ import { DiagramElement, DiagramElementSet } from './diagram-element';
7
7
  import { DiagramField } from './diagram-field';
8
8
  import { DiagramModel } from './diagram-model';
9
9
  import { DiagramNode } from './diagram-node';
@@ -129,19 +129,19 @@ export declare class DiagramSection extends DiagramElement {
129
129
  * @public
130
130
  * @returns A list of connections.
131
131
  */
132
- getIncomingConnections(): DiagramConnection[];
132
+ getIncomingConnections(includeRemoved?: boolean): DiagramConnection[];
133
133
  /**
134
134
  * Get all outgoing connections of all ports of this section.
135
135
  * @public
136
136
  * @returns A list of connections.
137
137
  */
138
- getOutgoingConnections(): DiagramConnection[];
138
+ getOutgoingConnections(includeRemoved?: boolean): DiagramConnection[];
139
139
  /**
140
140
  * Get all connections of all ports of this section.
141
141
  * @public
142
142
  * @returns A list of connections.
143
143
  */
144
- getConnections(): DiagramConnection[];
144
+ getConnections(includeRemoved?: boolean): DiagramConnection[];
145
145
  /**
146
146
  * Change the coordinates of this section to the given coordinates and move its ports and labels correspondingly.
147
147
  * @public
@@ -166,7 +166,7 @@ export declare class DiagramSection extends DiagramElement {
166
166
  */
167
167
  setGeometry(geometry: DiagramSectionGeometry): void;
168
168
  }
169
- export declare class DiagramSectionSet extends DiagramEntitySet<DiagramSection> {
169
+ export declare class DiagramSectionSet extends DiagramElementSet<DiagramSection> {
170
170
  private model;
171
171
  /**
172
172
  * Instance a set of sections for the given model. This method is used internally.
@@ -4,6 +4,10 @@ import { ValueSet } from '../diagram-editor/diagram/diagram-property';
4
4
  import { PropertyEditor } from '../interfaces/property-editor';
5
5
  import { Corner, Side } from '../util/svg-util';
6
6
  import * as i0 from "@angular/core";
7
+ /**
8
+ * Duration of the highlight property animation in milliseconds.
9
+ */
10
+ export declare const HIGHLIGHT_ANIMATION_DURATION_MS = 1000;
7
11
  /**
8
12
  * Editor of the values of a value set.
9
13
  * @see ValueSet
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
3
  "description": "Diagramming engine for editing models on the Web. Made by Metadev.",
4
- "version": "1.5.5",
4
+ "version": "1.5.7",
5
5
  "author": "Metadev (https://metadev.pro)",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
7
7
  "repository": "git+https://github.com/metadevpro/daga-tutorial.git",