@metadev/daga 4.2.9 → 5.0.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/Changelog.md +13 -2
- package/index.cjs.js +62 -20
- package/index.esm.js +62 -21
- package/package.json +2 -2
- package/src/index.d.ts +1 -1
- package/src/lib/diagram/diagram-event.d.ts +18 -4
- package/src/lib/util/object-util.d.ts +5 -0
- package/src/lib/util/test-util.d.ts +0 -5
package/Changelog.md
CHANGED
|
@@ -4,7 +4,18 @@ List of releases and changes.
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
## Next release
|
|
7
|
+
## Next release Durendal
|
|
8
|
+
|
|
9
|
+
## 5.0.0 Joyeuse
|
|
10
|
+
|
|
11
|
+
- Support for Angular 21 [#346](https://github.com/metadevpro/daga/pull/346)
|
|
12
|
+
- Ensure that an array remains an array after cloning [#349](https://github.com/metadevpro/daga/pull/349)
|
|
13
|
+
- When checking if a port is being shared, ignore connections that have been removed [#350](https://github.com/metadevpro/daga/pull/350)
|
|
14
|
+
- Create `DiagramZoomEvent` to enable listening to user zooming and panning events [#351](https://github.com/metadevpro/daga/pull/351)
|
|
15
|
+
|
|
16
|
+
## v. 4.2.10
|
|
17
|
+
|
|
18
|
+
- Fix errors with cloned objects containing functions [#345](https://github.com/metadevpro/daga/pull/345)
|
|
8
19
|
|
|
9
20
|
## v. 4.2.9
|
|
10
21
|
|
|
@@ -157,7 +168,7 @@ Date: _2025-01-21_
|
|
|
157
168
|
- Add node continence [#200](https://github.com/metadevpro/daga/pull/200)
|
|
158
169
|
- Enable defining custom shape functions for nodes in the configuration [#206](https://github.com/metadevpro/daga/pull/206)
|
|
159
170
|
- Fix order of diagram elements [#208](https://github.com/metadevpro/daga/pull/208)
|
|
160
|
-
- Simplify usage of `<daga-diagram>` tag in
|
|
171
|
+
- Simplify usage of `<daga-diagram>` tag in Angular by removing the need to include a `<daga-diagram-editor>` inside [#210](https://github.com/metadevpro/daga/pull/210)
|
|
161
172
|
- Distinguish between diagram actions (which affect the model) and diagram events (which don't affect the model) [#210](https://github.com/metadevpro/daga/pull/210)
|
|
162
173
|
- Add layout action so layouts applied by the user can be undone and redone (which don't affect the model) [#210](https://github.com/metadevpro/daga/pull/210)
|
|
163
174
|
- Add diagram events for the selection and highlight of diagram elements [#212](https://github.com/metadevpro/daga/pull/212) [#214](https://github.com/metadevpro/daga/pull/214)
|
package/index.cjs.js
CHANGED
|
@@ -1186,6 +1186,29 @@ const numberOfRows = s => {
|
|
|
1186
1186
|
return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
1187
1187
|
};
|
|
1188
1188
|
|
|
1189
|
+
/**
|
|
1190
|
+
* Clones an object with support for functions.
|
|
1191
|
+
* @private
|
|
1192
|
+
*/
|
|
1193
|
+
const clone = o => {
|
|
1194
|
+
if (typeof o !== 'object') {
|
|
1195
|
+
return o;
|
|
1196
|
+
}
|
|
1197
|
+
if (Array.isArray(o)) {
|
|
1198
|
+
return o.map(clone);
|
|
1199
|
+
}
|
|
1200
|
+
const res = {};
|
|
1201
|
+
for (const e of Object.entries(o)) {
|
|
1202
|
+
res[e[0]] = clone(e[1]);
|
|
1203
|
+
// if (typeof e[1] === 'object') {
|
|
1204
|
+
// res[e[0]] = clone(e[1]);
|
|
1205
|
+
// } else {
|
|
1206
|
+
// res[e[0]] = e[1];
|
|
1207
|
+
// }
|
|
1208
|
+
}
|
|
1209
|
+
return res;
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1189
1212
|
/******************************************************************************
|
|
1190
1213
|
Copyright (c) Microsoft Corporation.
|
|
1191
1214
|
|
|
@@ -2050,7 +2073,7 @@ class ValueSet {
|
|
|
2050
2073
|
if (property.type === exports.Type.Object) {
|
|
2051
2074
|
this.valueSets[key] = this.constructSubValueSet(key);
|
|
2052
2075
|
} else {
|
|
2053
|
-
this.values[key] =
|
|
2076
|
+
this.values[key] = clone(property.defaultValue);
|
|
2054
2077
|
}
|
|
2055
2078
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
2056
2079
|
if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
|
|
@@ -2074,7 +2097,7 @@ class ValueSet {
|
|
|
2074
2097
|
const property = this.propertySet.getProperty(key);
|
|
2075
2098
|
const propertySet = new PropertySet(property.properties);
|
|
2076
2099
|
const valueSet = new ValueSet(propertySet, this.rootElement);
|
|
2077
|
-
valueSet.overwriteValues(
|
|
2100
|
+
valueSet.overwriteValues(clone(property.defaultValue));
|
|
2078
2101
|
return valueSet;
|
|
2079
2102
|
}
|
|
2080
2103
|
/**
|
|
@@ -2510,18 +2533,18 @@ class DiagramConnection extends DiagramElement {
|
|
|
2510
2533
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2511
2534
|
continue checkAlternativeStartPorts;
|
|
2512
2535
|
}
|
|
2513
|
-
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.
|
|
2536
|
+
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeStartPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2514
2537
|
// alternative start port not valid, it already has other connections
|
|
2515
2538
|
continue checkAlternativeStartPorts;
|
|
2516
2539
|
}
|
|
2517
2540
|
if (!allowSharingBothPorts) {
|
|
2518
|
-
for (const connection of alternativeStartPort.outgoingConnections) {
|
|
2541
|
+
for (const connection of alternativeStartPort.outgoingConnections.filter(c => !c.removed)) {
|
|
2519
2542
|
if (connection !== this && connection.end === this.end) {
|
|
2520
2543
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
2521
2544
|
continue checkAlternativeStartPorts;
|
|
2522
2545
|
}
|
|
2523
2546
|
}
|
|
2524
|
-
for (const connection of alternativeStartPort.incomingConnections) {
|
|
2547
|
+
for (const connection of alternativeStartPort.incomingConnections.filter(c => !c.removed)) {
|
|
2525
2548
|
if (connection !== this && connection.start === this.end) {
|
|
2526
2549
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
2527
2550
|
continue checkAlternativeStartPorts;
|
|
@@ -2548,18 +2571,18 @@ class DiagramConnection extends DiagramElement {
|
|
|
2548
2571
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2549
2572
|
continue checkAlternativeEndPorts;
|
|
2550
2573
|
}
|
|
2551
|
-
if (!allowSharingPorts && (alternativeEndPort.
|
|
2574
|
+
if (!allowSharingPorts && (alternativeEndPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeEndPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2552
2575
|
// alternative end port not valid, it already has other connections
|
|
2553
2576
|
continue checkAlternativeEndPorts;
|
|
2554
2577
|
}
|
|
2555
2578
|
if (!allowSharingBothPorts) {
|
|
2556
|
-
for (const connection of alternativeEndPort.incomingConnections) {
|
|
2579
|
+
for (const connection of alternativeEndPort.incomingConnections.filter(c => !c.removed)) {
|
|
2557
2580
|
if (connection !== this && connection.start === this.start) {
|
|
2558
2581
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
2559
2582
|
continue checkAlternativeEndPorts;
|
|
2560
2583
|
}
|
|
2561
2584
|
}
|
|
2562
|
-
for (const connection of alternativeEndPort.outgoingConnections) {
|
|
2585
|
+
for (const connection of alternativeEndPort.outgoingConnections.filter(c => !c.removed)) {
|
|
2563
2586
|
if (connection !== this && connection.end === this.start) {
|
|
2564
2587
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
2565
2588
|
continue checkAlternativeEndPorts;
|
|
@@ -5080,7 +5103,7 @@ class AddNodeCollabAction {
|
|
|
5080
5103
|
node.label.text = this.label || '';
|
|
5081
5104
|
}
|
|
5082
5105
|
if (this.values !== undefined) {
|
|
5083
|
-
node.valueSet.setValues(
|
|
5106
|
+
node.valueSet.setValues(clone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
|
|
5084
5107
|
} else {
|
|
5085
5108
|
node.valueSet.resetValues();
|
|
5086
5109
|
}
|
|
@@ -6282,11 +6305,27 @@ class DiagramEvent {
|
|
|
6282
6305
|
*/
|
|
6283
6306
|
exports.DiagramEvents = void 0;
|
|
6284
6307
|
(function (DiagramEvents) {
|
|
6285
|
-
DiagramEvents[DiagramEvents["
|
|
6286
|
-
DiagramEvents[DiagramEvents["
|
|
6287
|
-
DiagramEvents[DiagramEvents["
|
|
6288
|
-
DiagramEvents[DiagramEvents["
|
|
6308
|
+
DiagramEvents[DiagramEvents["Zoom"] = 0] = "Zoom";
|
|
6309
|
+
DiagramEvents[DiagramEvents["DoubleClick"] = 1] = "DoubleClick";
|
|
6310
|
+
DiagramEvents[DiagramEvents["SecondaryClick"] = 2] = "SecondaryClick";
|
|
6311
|
+
DiagramEvents[DiagramEvents["Selection"] = 3] = "Selection";
|
|
6312
|
+
DiagramEvents[DiagramEvents["Highlight"] = 4] = "Highlight";
|
|
6289
6313
|
})(exports.DiagramEvents || (exports.DiagramEvents = {}));
|
|
6314
|
+
/**
|
|
6315
|
+
* Diagram event which consists of the user zooming or panning.
|
|
6316
|
+
*/
|
|
6317
|
+
class DiagramZoomEvent extends DiagramEvent {
|
|
6318
|
+
/**
|
|
6319
|
+
* Create a diagram zoom event.
|
|
6320
|
+
*
|
|
6321
|
+
* @param coords .
|
|
6322
|
+
*/
|
|
6323
|
+
constructor(coords, zoom) {
|
|
6324
|
+
super(exports.DiagramEvents.Zoom);
|
|
6325
|
+
this.coords = coords;
|
|
6326
|
+
this.zoom = zoom;
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6290
6329
|
/**
|
|
6291
6330
|
* Diagram event which consists of the user performing a double click on the diagram.
|
|
6292
6331
|
*/
|
|
@@ -7128,7 +7167,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7128
7167
|
this.canvas.propertyEditorChanges$.pipe(rxjs.debounceTime(2000)).subscribe(() => {
|
|
7129
7168
|
this.makeUpdateValuesAction();
|
|
7130
7169
|
});
|
|
7131
|
-
console.log(diagramPropertiesText);
|
|
7170
|
+
//console.log(diagramPropertiesText);
|
|
7132
7171
|
this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
|
|
7133
7172
|
}
|
|
7134
7173
|
add(element) {
|
|
@@ -7307,7 +7346,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7307
7346
|
if (selectedValueSet) {
|
|
7308
7347
|
this.propertyEditorSelection = selection;
|
|
7309
7348
|
if (makeUpdateValuesAction) {
|
|
7310
|
-
this.propertyEditorValues =
|
|
7349
|
+
this.propertyEditorValues = clone(selectedValueSet.getValues());
|
|
7311
7350
|
}
|
|
7312
7351
|
if (propertyEditor) {
|
|
7313
7352
|
if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
|
|
@@ -7351,7 +7390,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7351
7390
|
return;
|
|
7352
7391
|
}
|
|
7353
7392
|
const from = this.propertyEditorValues;
|
|
7354
|
-
const to =
|
|
7393
|
+
const to = clone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
|
|
7355
7394
|
const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
|
|
7356
7395
|
const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
|
|
7357
7396
|
currentAction.do();
|
|
@@ -7678,6 +7717,7 @@ class DiagramCanvas {
|
|
|
7678
7717
|
this.selectCanvasElements().attr('transform', transformAttribute);
|
|
7679
7718
|
d3__namespace.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
|
|
7680
7719
|
this.contextMenu.close();
|
|
7720
|
+
this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
|
|
7681
7721
|
}).on(exports.ZoomEvents.End, () => {
|
|
7682
7722
|
setCursorStyle();
|
|
7683
7723
|
}));
|
|
@@ -8338,7 +8378,7 @@ class DiagramCanvas {
|
|
|
8338
8378
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
8339
8379
|
this.startMultipleSelection(event);
|
|
8340
8380
|
} else {
|
|
8341
|
-
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.length === 0 && d.outgoingConnections.length === 0) && !d.removed) {
|
|
8381
|
+
if (this.canUserPerformAction(exports.DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.filter(c => !c.removed).length === 0 && d.outgoingConnections.filter(c => !c.removed).length === 0) && !d.removed) {
|
|
8342
8382
|
setCursorStyle(exports.CursorStyle.Grabbing);
|
|
8343
8383
|
this.startConnection(d);
|
|
8344
8384
|
// should be true after having called this.startConnection()
|
|
@@ -8564,7 +8604,8 @@ class DiagramCanvas {
|
|
|
8564
8604
|
this.diagramEvent$.next(diagramEvent);
|
|
8565
8605
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(exports.DiagramActions.EditField) && d.editable && !d.removed) {
|
|
8566
8606
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
8567
|
-
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation,
|
|
8607
|
+
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, () => {
|
|
8608
|
+
// (_text)
|
|
8568
8609
|
/*
|
|
8569
8610
|
Empty for now
|
|
8570
8611
|
We should create a better function to stretch the root element as the text expands
|
|
@@ -9088,13 +9129,13 @@ class DiagramCanvas {
|
|
|
9088
9129
|
this.dropConnection();
|
|
9089
9130
|
return;
|
|
9090
9131
|
}
|
|
9091
|
-
if (!this.allowSharingPorts && (port.incomingConnections.length > 0 || port.outgoingConnections.length > 0)) {
|
|
9132
|
+
if (!this.allowSharingPorts && (port.incomingConnections.filter(c => !c.removed).length > 0 || port.outgoingConnections.filter(c => !c.removed).length > 0)) {
|
|
9092
9133
|
this.dropConnection();
|
|
9093
9134
|
return;
|
|
9094
9135
|
}
|
|
9095
9136
|
if (!this.allowSharingBothPorts && this.model.connections.find(c => {
|
|
9096
9137
|
var _a, _b;
|
|
9097
|
-
return c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port;
|
|
9138
|
+
return !c.removed && (c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port);
|
|
9098
9139
|
}) !== undefined) {
|
|
9099
9140
|
this.dropConnection();
|
|
9100
9141
|
return;
|
|
@@ -10306,6 +10347,7 @@ exports.DiagramSectionSet = DiagramSectionSet;
|
|
|
10306
10347
|
exports.DiagramSelectionEvent = DiagramSelectionEvent;
|
|
10307
10348
|
exports.DiagramUserHighlight = DiagramUserHighlight;
|
|
10308
10349
|
exports.DiagramUserSelection = DiagramUserSelection;
|
|
10350
|
+
exports.DiagramZoomEvent = DiagramZoomEvent;
|
|
10309
10351
|
exports.EditFieldAction = EditFieldAction;
|
|
10310
10352
|
exports.ForceLayout = ForceLayout;
|
|
10311
10353
|
exports.HorizontalLayout = HorizontalLayout;
|
package/index.esm.js
CHANGED
|
@@ -1165,6 +1165,29 @@ const numberOfRows = s => {
|
|
|
1165
1165
|
return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
1166
1166
|
};
|
|
1167
1167
|
|
|
1168
|
+
/**
|
|
1169
|
+
* Clones an object with support for functions.
|
|
1170
|
+
* @private
|
|
1171
|
+
*/
|
|
1172
|
+
const clone = o => {
|
|
1173
|
+
if (typeof o !== 'object') {
|
|
1174
|
+
return o;
|
|
1175
|
+
}
|
|
1176
|
+
if (Array.isArray(o)) {
|
|
1177
|
+
return o.map(clone);
|
|
1178
|
+
}
|
|
1179
|
+
const res = {};
|
|
1180
|
+
for (const e of Object.entries(o)) {
|
|
1181
|
+
res[e[0]] = clone(e[1]);
|
|
1182
|
+
// if (typeof e[1] === 'object') {
|
|
1183
|
+
// res[e[0]] = clone(e[1]);
|
|
1184
|
+
// } else {
|
|
1185
|
+
// res[e[0]] = e[1];
|
|
1186
|
+
// }
|
|
1187
|
+
}
|
|
1188
|
+
return res;
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1168
1191
|
/******************************************************************************
|
|
1169
1192
|
Copyright (c) Microsoft Corporation.
|
|
1170
1193
|
|
|
@@ -2029,7 +2052,7 @@ class ValueSet {
|
|
|
2029
2052
|
if (property.type === Type.Object) {
|
|
2030
2053
|
this.valueSets[key] = this.constructSubValueSet(key);
|
|
2031
2054
|
} else {
|
|
2032
|
-
this.values[key] =
|
|
2055
|
+
this.values[key] = clone(property.defaultValue);
|
|
2033
2056
|
}
|
|
2034
2057
|
if (rootAttribute !== undefined && rootAttribute !== null) {
|
|
2035
2058
|
if (property.defaultValue !== undefined && !equals(this.getRootElementValue(rootAttribute), property.defaultValue)) {
|
|
@@ -2053,7 +2076,7 @@ class ValueSet {
|
|
|
2053
2076
|
const property = this.propertySet.getProperty(key);
|
|
2054
2077
|
const propertySet = new PropertySet(property.properties);
|
|
2055
2078
|
const valueSet = new ValueSet(propertySet, this.rootElement);
|
|
2056
|
-
valueSet.overwriteValues(
|
|
2079
|
+
valueSet.overwriteValues(clone(property.defaultValue));
|
|
2057
2080
|
return valueSet;
|
|
2058
2081
|
}
|
|
2059
2082
|
/**
|
|
@@ -2489,18 +2512,18 @@ class DiagramConnection extends DiagramElement {
|
|
|
2489
2512
|
// alternative start port not valid, it doesn't allow outgoing connections
|
|
2490
2513
|
continue checkAlternativeStartPorts;
|
|
2491
2514
|
}
|
|
2492
|
-
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.
|
|
2515
|
+
if (!allowSharingPorts && (alternativeStartPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeStartPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2493
2516
|
// alternative start port not valid, it already has other connections
|
|
2494
2517
|
continue checkAlternativeStartPorts;
|
|
2495
2518
|
}
|
|
2496
2519
|
if (!allowSharingBothPorts) {
|
|
2497
|
-
for (const connection of alternativeStartPort.outgoingConnections) {
|
|
2520
|
+
for (const connection of alternativeStartPort.outgoingConnections.filter(c => !c.removed)) {
|
|
2498
2521
|
if (connection !== this && connection.end === this.end) {
|
|
2499
2522
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
2500
2523
|
continue checkAlternativeStartPorts;
|
|
2501
2524
|
}
|
|
2502
2525
|
}
|
|
2503
|
-
for (const connection of alternativeStartPort.incomingConnections) {
|
|
2526
|
+
for (const connection of alternativeStartPort.incomingConnections.filter(c => !c.removed)) {
|
|
2504
2527
|
if (connection !== this && connection.start === this.end) {
|
|
2505
2528
|
// alternative start port not valid, there is a connection whose start and end matches the alternative start port and this connection's end
|
|
2506
2529
|
continue checkAlternativeStartPorts;
|
|
@@ -2527,18 +2550,18 @@ class DiagramConnection extends DiagramElement {
|
|
|
2527
2550
|
// alternative end port not valid, it doesn't allow incoming connections
|
|
2528
2551
|
continue checkAlternativeEndPorts;
|
|
2529
2552
|
}
|
|
2530
|
-
if (!allowSharingPorts && (alternativeEndPort.
|
|
2553
|
+
if (!allowSharingPorts && (alternativeEndPort.incomingConnections.filter(c => !c.removed && c !== this).length > 0 || alternativeEndPort.outgoingConnections.filter(c => !c.removed && c !== this).length > 0)) {
|
|
2531
2554
|
// alternative end port not valid, it already has other connections
|
|
2532
2555
|
continue checkAlternativeEndPorts;
|
|
2533
2556
|
}
|
|
2534
2557
|
if (!allowSharingBothPorts) {
|
|
2535
|
-
for (const connection of alternativeEndPort.incomingConnections) {
|
|
2558
|
+
for (const connection of alternativeEndPort.incomingConnections.filter(c => !c.removed)) {
|
|
2536
2559
|
if (connection !== this && connection.start === this.start) {
|
|
2537
2560
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
2538
2561
|
continue checkAlternativeEndPorts;
|
|
2539
2562
|
}
|
|
2540
2563
|
}
|
|
2541
|
-
for (const connection of alternativeEndPort.outgoingConnections) {
|
|
2564
|
+
for (const connection of alternativeEndPort.outgoingConnections.filter(c => !c.removed)) {
|
|
2542
2565
|
if (connection !== this && connection.end === this.start) {
|
|
2543
2566
|
// alternative end port not valid, there is a connection whose start and end matches the alternative end port and this connection's start
|
|
2544
2567
|
continue checkAlternativeEndPorts;
|
|
@@ -5059,7 +5082,7 @@ class AddNodeCollabAction {
|
|
|
5059
5082
|
node.label.text = this.label || '';
|
|
5060
5083
|
}
|
|
5061
5084
|
if (this.values !== undefined) {
|
|
5062
|
-
node.valueSet.setValues(
|
|
5085
|
+
node.valueSet.setValues(clone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
|
|
5063
5086
|
} else {
|
|
5064
5087
|
node.valueSet.resetValues();
|
|
5065
5088
|
}
|
|
@@ -6261,11 +6284,27 @@ class DiagramEvent {
|
|
|
6261
6284
|
*/
|
|
6262
6285
|
var DiagramEvents;
|
|
6263
6286
|
(function (DiagramEvents) {
|
|
6264
|
-
DiagramEvents[DiagramEvents["
|
|
6265
|
-
DiagramEvents[DiagramEvents["
|
|
6266
|
-
DiagramEvents[DiagramEvents["
|
|
6267
|
-
DiagramEvents[DiagramEvents["
|
|
6287
|
+
DiagramEvents[DiagramEvents["Zoom"] = 0] = "Zoom";
|
|
6288
|
+
DiagramEvents[DiagramEvents["DoubleClick"] = 1] = "DoubleClick";
|
|
6289
|
+
DiagramEvents[DiagramEvents["SecondaryClick"] = 2] = "SecondaryClick";
|
|
6290
|
+
DiagramEvents[DiagramEvents["Selection"] = 3] = "Selection";
|
|
6291
|
+
DiagramEvents[DiagramEvents["Highlight"] = 4] = "Highlight";
|
|
6268
6292
|
})(DiagramEvents || (DiagramEvents = {}));
|
|
6293
|
+
/**
|
|
6294
|
+
* Diagram event which consists of the user zooming or panning.
|
|
6295
|
+
*/
|
|
6296
|
+
class DiagramZoomEvent extends DiagramEvent {
|
|
6297
|
+
/**
|
|
6298
|
+
* Create a diagram zoom event.
|
|
6299
|
+
*
|
|
6300
|
+
* @param coords .
|
|
6301
|
+
*/
|
|
6302
|
+
constructor(coords, zoom) {
|
|
6303
|
+
super(DiagramEvents.Zoom);
|
|
6304
|
+
this.coords = coords;
|
|
6305
|
+
this.zoom = zoom;
|
|
6306
|
+
}
|
|
6307
|
+
}
|
|
6269
6308
|
/**
|
|
6270
6309
|
* Diagram event which consists of the user performing a double click on the diagram.
|
|
6271
6310
|
*/
|
|
@@ -7107,7 +7146,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7107
7146
|
this.canvas.propertyEditorChanges$.pipe(debounceTime(2000)).subscribe(() => {
|
|
7108
7147
|
this.makeUpdateValuesAction();
|
|
7109
7148
|
});
|
|
7110
|
-
console.log(diagramPropertiesText);
|
|
7149
|
+
//console.log(diagramPropertiesText);
|
|
7111
7150
|
this.diagramPropertiesText = diagramPropertiesText !== undefined ? diagramPropertiesText : DIAGRAM_PROPERTIES_DEFAULT_TEXT;
|
|
7112
7151
|
}
|
|
7113
7152
|
add(element) {
|
|
@@ -7286,7 +7325,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7286
7325
|
if (selectedValueSet) {
|
|
7287
7326
|
this.propertyEditorSelection = selection;
|
|
7288
7327
|
if (makeUpdateValuesAction) {
|
|
7289
|
-
this.propertyEditorValues =
|
|
7328
|
+
this.propertyEditorValues = clone(selectedValueSet.getValues());
|
|
7290
7329
|
}
|
|
7291
7330
|
if (propertyEditor) {
|
|
7292
7331
|
if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
|
|
@@ -7330,7 +7369,7 @@ class DiagramUserSelection extends DiagramElementSet {
|
|
|
7330
7369
|
return;
|
|
7331
7370
|
}
|
|
7332
7371
|
const from = this.propertyEditorValues;
|
|
7333
|
-
const to =
|
|
7372
|
+
const to = clone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
|
|
7334
7373
|
const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
|
|
7335
7374
|
const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
|
|
7336
7375
|
currentAction.do();
|
|
@@ -7657,6 +7696,7 @@ class DiagramCanvas {
|
|
|
7657
7696
|
this.selectCanvasElements().attr('transform', transformAttribute);
|
|
7658
7697
|
d3.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
|
|
7659
7698
|
this.contextMenu.close();
|
|
7699
|
+
this.diagramEvent$.next(new DiagramZoomEvent([this.zoomTransform.x, this.zoomTransform.y], this.zoomTransform.k));
|
|
7660
7700
|
}).on(ZoomEvents.End, () => {
|
|
7661
7701
|
setCursorStyle();
|
|
7662
7702
|
}));
|
|
@@ -8317,7 +8357,7 @@ class DiagramCanvas {
|
|
|
8317
8357
|
if (this.multipleSelectionOn || this.secondaryButton) {
|
|
8318
8358
|
this.startMultipleSelection(event);
|
|
8319
8359
|
} else {
|
|
8320
|
-
if (this.canUserPerformAction(DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.length === 0 && d.outgoingConnections.length === 0) && !d.removed) {
|
|
8360
|
+
if (this.canUserPerformAction(DiagramActions.AddConnection) && (this.allowSharingPorts || d.incomingConnections.filter(c => !c.removed).length === 0 && d.outgoingConnections.filter(c => !c.removed).length === 0) && !d.removed) {
|
|
8321
8361
|
setCursorStyle(CursorStyle.Grabbing);
|
|
8322
8362
|
this.startConnection(d);
|
|
8323
8363
|
// should be true after having called this.startConnection()
|
|
@@ -8543,7 +8583,8 @@ class DiagramCanvas {
|
|
|
8543
8583
|
this.diagramEvent$.next(diagramEvent);
|
|
8544
8584
|
if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.EditField) && d.editable && !d.removed) {
|
|
8545
8585
|
this.currentAction = new EditFieldAction(this, d.id, d.text, '');
|
|
8546
|
-
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation,
|
|
8586
|
+
this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, () => {
|
|
8587
|
+
// (_text)
|
|
8547
8588
|
/*
|
|
8548
8589
|
Empty for now
|
|
8549
8590
|
We should create a better function to stretch the root element as the text expands
|
|
@@ -9067,13 +9108,13 @@ class DiagramCanvas {
|
|
|
9067
9108
|
this.dropConnection();
|
|
9068
9109
|
return;
|
|
9069
9110
|
}
|
|
9070
|
-
if (!this.allowSharingPorts && (port.incomingConnections.length > 0 || port.outgoingConnections.length > 0)) {
|
|
9111
|
+
if (!this.allowSharingPorts && (port.incomingConnections.filter(c => !c.removed).length > 0 || port.outgoingConnections.filter(c => !c.removed).length > 0)) {
|
|
9071
9112
|
this.dropConnection();
|
|
9072
9113
|
return;
|
|
9073
9114
|
}
|
|
9074
9115
|
if (!this.allowSharingBothPorts && this.model.connections.find(c => {
|
|
9075
9116
|
var _a, _b;
|
|
9076
|
-
return c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port;
|
|
9117
|
+
return !c.removed && (c.start === ((_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) && c.end === port || c.end === ((_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.start) && c.start === port);
|
|
9077
9118
|
}) !== undefined) {
|
|
9078
9119
|
this.dropConnection();
|
|
9079
9120
|
return;
|
|
@@ -10243,4 +10284,4 @@ const getLocationsOfNodes = model => {
|
|
|
10243
10284
|
return locations;
|
|
10244
10285
|
};
|
|
10245
10286
|
|
|
10246
|
-
export { ACTION_STACK_SIZE, ActionStack, AddConnectionAction, AddNodeAction, AdjacencyLayout, ApplyLayoutAction, BreadthAdjacencyLayout, BreadthLayout, ClosedShape, CollabClient, Corner, CursorStyle, DIAGRAM_FIELD_DEFAULTS, DagaExporter, DagaImporter, DiagramActionMethod, DiagramActions, DiagramCanvas, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramContextMenu, DiagramDecorator, DiagramDecoratorSet, DiagramDoubleClickEvent, DiagramElement, DiagramElementSet, DiagramEntitySet, DiagramEvent, DiagramEvents, DiagramField, DiagramFieldSet, DiagramHighlightedEvent, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramObject, DiagramObjectSet, DiagramPort, DiagramPortSet, DiagramPortType, DiagramSecondaryClickEvent, DiagramSection, DiagramSectionSet, DiagramSelectionEvent, DiagramUserHighlight, DiagramUserSelection, DragEvents, EditFieldAction, Events, ForceLayout, HorizontalAlign, HorizontalLayout, Keys, LineShape, LineStyle, MoveAction, PasteAction, PriorityLayout, Property, PropertySet, RemoveAction, SetGeometryAction, SetParentAction, Side, TreeLayout, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, ZoomEvents, addIfNotExists, diff, equals, filterByOnlyAncestors, filterByOnlyDescendants, generalClosedPath, getBottomMargin, getBottomPadding$1 as getBottomPadding, getLeftMargin, getLeftPadding$1 as getLeftPadding, getLocationsOfNodes, getRightMargin, getRightPadding$1 as getRightPadding, getTopMargin, getTopPadding$1 as getTopPadding, isObject, layouts, linePath, lineStyleDasharray, removeIfExists, setCursorStyle };
|
|
10287
|
+
export { ACTION_STACK_SIZE, ActionStack, AddConnectionAction, AddNodeAction, AdjacencyLayout, ApplyLayoutAction, BreadthAdjacencyLayout, BreadthLayout, ClosedShape, CollabClient, Corner, CursorStyle, DIAGRAM_FIELD_DEFAULTS, DagaExporter, DagaImporter, DiagramActionMethod, DiagramActions, DiagramCanvas, DiagramConnection, DiagramConnectionSet, DiagramConnectionType, DiagramContextMenu, DiagramDecorator, DiagramDecoratorSet, DiagramDoubleClickEvent, DiagramElement, DiagramElementSet, DiagramEntitySet, DiagramEvent, DiagramEvents, DiagramField, DiagramFieldSet, DiagramHighlightedEvent, DiagramModel, DiagramNode, DiagramNodeSet, DiagramNodeType, DiagramObject, DiagramObjectSet, DiagramPort, DiagramPortSet, DiagramPortType, DiagramSecondaryClickEvent, DiagramSection, DiagramSectionSet, DiagramSelectionEvent, DiagramUserHighlight, DiagramUserSelection, DiagramZoomEvent, DragEvents, EditFieldAction, Events, ForceLayout, HorizontalAlign, HorizontalLayout, Keys, LineShape, LineStyle, MoveAction, PasteAction, PriorityLayout, Property, PropertySet, RemoveAction, SetGeometryAction, SetParentAction, Side, TreeLayout, Type, UpdateValuesAction, ValueSet, VerticalAlign, VerticalLayout, ZoomEvents, addIfNotExists, diff, equals, filterByOnlyAncestors, filterByOnlyDescendants, generalClosedPath, getBottomMargin, getBottomPadding$1 as getBottomPadding, getLeftMargin, getLeftPadding$1 as getLeftPadding, getLocationsOfNodes, getRightMargin, getRightPadding$1 as getRightPadding, getTopMargin, getTopPadding$1 as getTopPadding, isObject, layouts, linePath, lineStyleDasharray, removeIfExists, setCursorStyle };
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metadev/daga",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"dependencies": {},
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"d3": "^7.9.0",
|
|
7
7
|
"rxjs": "~7.8.1",
|
|
8
|
-
"uuid": "^
|
|
8
|
+
"uuid": "^13.0.0"
|
|
9
9
|
},
|
|
10
10
|
"main": "./index.cjs.js",
|
|
11
11
|
"typings": "./src/index.d.ts",
|
package/src/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type { DiagramModelExporter } from './lib/diagram/converters/diagram-mode
|
|
|
18
18
|
export type { DiagramModelImporter } from './lib/diagram/converters/diagram-model-importer';
|
|
19
19
|
export { ActionStack, AddConnectionAction, AddNodeAction, ApplyLayoutAction, DiagramActionMethod, DiagramActions, EditFieldAction, MoveAction, PasteAction, RemoveAction, SetGeometryAction, SetParentAction, UpdateValuesAction } from './lib/diagram/diagram-action';
|
|
20
20
|
export type { DiagramAction } from './lib/diagram/diagram-action';
|
|
21
|
-
export { DiagramDoubleClickEvent, DiagramEvent, DiagramEvents, DiagramHighlightedEvent, DiagramSecondaryClickEvent, DiagramSelectionEvent } from './lib/diagram/diagram-event';
|
|
21
|
+
export { DiagramDoubleClickEvent, DiagramEvent, DiagramEvents, DiagramHighlightedEvent, DiagramSecondaryClickEvent, DiagramSelectionEvent, DiagramZoomEvent } from './lib/diagram/diagram-event';
|
|
22
22
|
export { AdjacencyLayout } from './lib/diagram/layout/adjacency-layout';
|
|
23
23
|
export { BreadthAdjacencyLayout } from './lib/diagram/layout/breadth-adjacency-layout';
|
|
24
24
|
export { BreadthLayout } from './lib/diagram/layout/breadth-layout';
|
|
@@ -16,10 +16,24 @@ export declare abstract class DiagramEvent {
|
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
18
18
|
export declare enum DiagramEvents {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
Zoom = 0,
|
|
20
|
+
DoubleClick = 1,
|
|
21
|
+
SecondaryClick = 2,
|
|
22
|
+
Selection = 3,
|
|
23
|
+
Highlight = 4
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Diagram event which consists of the user zooming or panning.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DiagramZoomEvent extends DiagramEvent {
|
|
29
|
+
coords: Point;
|
|
30
|
+
zoom: number;
|
|
31
|
+
/**
|
|
32
|
+
* Create a diagram zoom event.
|
|
33
|
+
*
|
|
34
|
+
* @param coords .
|
|
35
|
+
*/
|
|
36
|
+
constructor(coords: Point, zoom: number);
|
|
23
37
|
}
|
|
24
38
|
/**
|
|
25
39
|
* Diagram event which consists of the user performing a double click on the diagram.
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { DiagramConfig } from '../diagram/config/diagram-config';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the structuredClone function if it doesn't exist.
|
|
4
|
-
* @private
|
|
5
|
-
*/
|
|
6
|
-
export declare const createStructuredClone: () => void;
|
|
7
2
|
/**
|
|
8
3
|
* Generic diagram configuration used for testing.
|
|
9
4
|
* @private
|