@metadev/daga 4.1.0 → 4.2.1

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.esm.js CHANGED
@@ -137,17 +137,67 @@ const translateCoordinate = (oldCoordinate, oldCoordinates, newCoordinates) => {
137
137
  return (oldCoordinate - oldCoordinates[0]) / (oldCoordinates[1] - oldCoordinates[0]) * (newCoordinates[1] - newCoordinates[0]) + newCoordinates[0];
138
138
  };
139
139
  /**
140
- * Moves the coordinates of the given point according to the given changes in coordinates.
140
+ * Moves the coordinates of the given point according to the given changes in coordinates and anchor points.
141
141
  * @public
142
142
  * @param oldPoint A point.
143
143
  * @param oldCoordsX A range of coordinates along the x axis.
144
144
  * @param oldCoordsY A range of coordinates along the y axis.
145
145
  * @param newCoordsX A range of coordinates along the x axis.
146
146
  * @param newCoordsY A range of coordinates along the y axis.
147
+ * @param anchorPointX The horizontal anchor point behavior.
148
+ * @param anchorPointY The vertical anchor point behavior.
147
149
  * @returns A new point.
148
150
  */
149
- const translatePoint = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY) => {
150
- return [translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX), translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY)];
151
+ const translatePointWithAnchors = (oldPoint, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, anchorPointX, anchorPointY) => {
152
+ const newX = (() => {
153
+ switch (anchorPointX) {
154
+ case 'start':
155
+ // Always maintain the same distance from the left edge
156
+ return newCoordsX[0] + (oldPoint[0] - oldCoordsX[0]);
157
+ case 'end':
158
+ // Always maintain the same distance from the right edge
159
+ return newCoordsX[1] - (oldCoordsX[1] - oldPoint[0]);
160
+ case 'middle':
161
+ {
162
+ // Always maintain the same relative position from the center
163
+ const oldCenterX = (oldCoordsX[0] + oldCoordsX[1]) / 2;
164
+ const newCenterX = (newCoordsX[0] + newCoordsX[1]) / 2;
165
+ const oldWidth = oldCoordsX[1] - oldCoordsX[0];
166
+ const newWidth = newCoordsX[1] - newCoordsX[0];
167
+ const relativePosition = (oldPoint[0] - oldCenterX) / oldWidth;
168
+ return newCenterX + relativePosition * newWidth;
169
+ }
170
+ case 'floating':
171
+ default:
172
+ // Scale proportionally (original behavior)
173
+ return translateCoordinate(oldPoint[0], oldCoordsX, newCoordsX);
174
+ }
175
+ })();
176
+ const newY = (() => {
177
+ switch (anchorPointY) {
178
+ case 'start':
179
+ // Always maintain the same distance from the top edge
180
+ return newCoordsY[0] + (oldPoint[1] - oldCoordsY[0]);
181
+ case 'end':
182
+ // Always maintain the same distance from the bottom edge
183
+ return newCoordsY[1] - (oldCoordsY[1] - oldPoint[1]);
184
+ case 'middle':
185
+ {
186
+ // Always maintain the same relative position from the center
187
+ const oldCenterY = (oldCoordsY[0] + oldCoordsY[1]) / 2;
188
+ const newCenterY = (newCoordsY[0] + newCoordsY[1]) / 2;
189
+ const oldHeight = oldCoordsY[1] - oldCoordsY[0];
190
+ const newHeight = newCoordsY[1] - newCoordsY[0];
191
+ const relativePosition = (oldPoint[1] - oldCenterY) / oldHeight;
192
+ return newCenterY + relativePosition * newHeight;
193
+ }
194
+ case 'floating':
195
+ default:
196
+ // Scale proportionally (original behavior)
197
+ return translateCoordinate(oldPoint[1], oldCoordsY, newCoordsY);
198
+ }
199
+ })();
200
+ return [newX, newY];
151
201
  };
152
202
  /**
153
203
  * Calculates the euclidean distance between two points.
@@ -244,6 +294,10 @@ var ZoomEvents;
244
294
  ZoomEvents["End"] = "end";
245
295
  })(ZoomEvents || (ZoomEvents = {}));
246
296
 
297
+ const escapeSelector = selector => {
298
+ return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
299
+ };
300
+
247
301
  /**
248
302
  * An enumeration of the possible shapes of a line.
249
303
  * @public
@@ -804,7 +858,7 @@ const numberOfColumns = s => {
804
858
  };
805
859
  const numberOfRows = s => {
806
860
  var _a;
807
- return ((_a = s.match(/\n/g)) === null || _a === undefined ? undefined : _a.length) || 0;
861
+ return ((_a = s.match(/\n/g)) === null || _a === void 0 ? void 0 : _a.length) || 0;
808
862
  };
809
863
 
810
864
  /******************************************************************************
@@ -1001,10 +1055,6 @@ class DiagramEntitySet {
1001
1055
  }
1002
1056
  }
1003
1057
 
1004
- const escapeSelector = selector => {
1005
- return selector.replace(/([!"#$%&'()*+,\-./:;<=>?@[\\\]^`{|}])/g, '\\$1');
1006
- };
1007
-
1008
1058
  /**
1009
1059
  * Default priority value for diagram elements.
1010
1060
  * @private
@@ -1030,14 +1080,14 @@ class DiagramElement {
1030
1080
  */
1031
1081
  get highlighted() {
1032
1082
  var _a, _b;
1033
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userHighlight) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1083
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userHighlight) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1034
1084
  }
1035
1085
  /**
1036
1086
  * Whether this diagram element is currently in the user selection.
1037
1087
  */
1038
1088
  get selected() {
1039
1089
  var _a, _b;
1040
- return ((_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.contains(this.id)) || false;
1090
+ return ((_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.contains(this.id)) || false;
1041
1091
  }
1042
1092
  constructor(model, id) {
1043
1093
  /**
@@ -1066,7 +1116,7 @@ class DiagramElement {
1066
1116
  */
1067
1117
  select() {
1068
1118
  var _a, _b;
1069
- return (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.selectCanvasView()) === null || _b === undefined ? undefined : _b.select(`[id='${escapeSelector(this.id)}']`);
1119
+ return (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.selectCanvasView()) === null || _b === void 0 ? void 0 : _b.select(`[id='${escapeSelector(this.id)}']`);
1070
1120
  }
1071
1121
  }
1072
1122
  class DiagramElementSet extends DiagramEntitySet {
@@ -1464,7 +1514,7 @@ class ValueSet {
1464
1514
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1465
1515
  getValue(key) {
1466
1516
  var _a;
1467
- const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === undefined ? undefined : _a.rootAttribute;
1517
+ const rootAttribute = (_a = this.propertySet.getProperty(key)) === null || _a === void 0 ? void 0 : _a.rootAttribute;
1468
1518
  if (rootAttribute !== undefined && rootAttribute !== null) {
1469
1519
  this.values[key] = this.getRootElementValue(rootAttribute);
1470
1520
  }
@@ -1549,7 +1599,7 @@ class ValueSet {
1549
1599
  if (property && property.type === Type.Object) {
1550
1600
  return this.getSubValueSet(key).hasAnySetValue();
1551
1601
  }
1552
- return !empty(value) && !equals(value, property === null || property === undefined ? undefined : property.defaultValue);
1602
+ return !empty(value) && !equals(value, property === null || property === void 0 ? void 0 : property.defaultValue);
1553
1603
  }
1554
1604
  /**
1555
1605
  * Checks if any of the values in the set are not empty or the default value.
@@ -1816,20 +1866,24 @@ class DiagramConnection extends DiagramElement {
1816
1866
  }
1817
1867
  set type(type) {
1818
1868
  var _a, _b;
1819
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
1820
- this._type = type;
1821
- if (this.valueSet) {
1822
- this.valueSet = new ValueSet(type.propertySet, this);
1869
+ if (type !== this._type) {
1870
+ this._type = type;
1871
+ if (this.valueSet) {
1872
+ this.valueSet = new ValueSet(type.propertySet, this);
1873
+ }
1874
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
1875
+ this.updateInView();
1823
1876
  }
1824
- this.updateInView();
1825
1877
  }
1826
1878
  get typeString() {
1827
1879
  return this.type.id;
1828
1880
  }
1829
1881
  set typeString(typeString) {
1830
- const type = this.model.connections.types.get(typeString);
1831
- if (type) {
1832
- this.type = type;
1882
+ if (typeString !== this.type.id) {
1883
+ const type = this.model.connections.types.get(typeString);
1884
+ if (type) {
1885
+ this.type = type;
1886
+ }
1833
1887
  }
1834
1888
  }
1835
1889
  /**
@@ -2005,11 +2059,11 @@ class DiagramConnection extends DiagramElement {
2005
2059
  }
2006
2060
  updateInView() {
2007
2061
  var _a;
2008
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateConnectionsInView(this.id);
2062
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateConnectionsInView(this.id);
2009
2063
  }
2010
2064
  raise() {
2011
2065
  var _a;
2012
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2066
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2013
2067
  }
2014
2068
  /**
2015
2069
  * Set the start of this connection to the given port or reset this connection's starting port if `undefined`.
@@ -2025,12 +2079,12 @@ class DiagramConnection extends DiagramElement {
2025
2079
  this.start = start;
2026
2080
  if (start !== undefined) {
2027
2081
  start.outgoingConnections.push(this);
2028
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2029
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2082
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2083
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2030
2084
  }
2031
2085
  } else {
2032
- this.startDirection = start === null || start === undefined ? undefined : start.direction;
2033
- this.startCoords = (start === null || start === undefined ? undefined : start.connectionPoint) || [0, 0];
2086
+ this.startDirection = start === null || start === void 0 ? void 0 : start.direction;
2087
+ this.startCoords = (start === null || start === void 0 ? void 0 : start.connectionPoint) || [0, 0];
2034
2088
  }
2035
2089
  this.updateInView();
2036
2090
  }
@@ -2048,12 +2102,12 @@ class DiagramConnection extends DiagramElement {
2048
2102
  this.end = end;
2049
2103
  if (end !== undefined) {
2050
2104
  end.incomingConnections.push(this);
2051
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2052
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2105
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2106
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2053
2107
  }
2054
2108
  } else {
2055
- this.endDirection = end === null || end === undefined ? undefined : end.direction;
2056
- this.endCoords = (end === null || end === undefined ? undefined : end.connectionPoint) || [0, 0];
2109
+ this.endDirection = end === null || end === void 0 ? void 0 : end.direction;
2110
+ this.endCoords = (end === null || end === void 0 ? void 0 : end.connectionPoint) || [0, 0];
2057
2111
  }
2058
2112
  this.updateInView();
2059
2113
  }
@@ -2064,7 +2118,7 @@ class DiagramConnection extends DiagramElement {
2064
2118
  */
2065
2119
  tighten() {
2066
2120
  var _a, _b;
2067
- if (((_a = this.start) === null || _a === undefined ? undefined : _a.rootElement) && this.end) {
2121
+ if (((_a = this.start) === null || _a === void 0 ? void 0 : _a.rootElement) && this.end) {
2068
2122
  const alternativeStartPortsSortedByDistanceAscending = this.start.rootElement.ports.map(p => [p, p.distanceTo(this.end.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
2069
2123
  checkAlternativeStartPorts: for (const alternativeStartPort of alternativeStartPortsSortedByDistanceAscending) {
2070
2124
  if (alternativeStartPort === this.end) {
@@ -2098,7 +2152,7 @@ class DiagramConnection extends DiagramElement {
2098
2152
  }
2099
2153
  }
2100
2154
  }
2101
- if (((_b = this.end) === null || _b === undefined ? undefined : _b.rootElement) && this.start) {
2155
+ if (((_b = this.end) === null || _b === void 0 ? void 0 : _b.rootElement) && this.start) {
2102
2156
  const alternativeEndPortsSortedByDistanceAscending = this.end.rootElement.ports.map(p => [p, p.distanceTo(this.start.coords)]).sort((a, b) => a[1] - b[1]).map(a => a[0]);
2103
2157
  checkAlternativeEndPorts: for (const alternativeEndPort of alternativeEndPortsSortedByDistanceAscending) {
2104
2158
  if (alternativeEndPort === this.start) {
@@ -2194,8 +2248,8 @@ class DiagramConnectionSet extends DiagramElementSet {
2194
2248
  const connection = this.get(id, true);
2195
2249
  if (connection) {
2196
2250
  // remove from ports
2197
- removeIfExists(((_a = connection.start) === null || _a === undefined ? undefined : _a.outgoingConnections) || [], connection);
2198
- removeIfExists(((_b = connection.end) === null || _b === undefined ? undefined : _b.incomingConnections) || [], connection);
2251
+ removeIfExists(((_a = connection.start) === null || _a === void 0 ? void 0 : _a.outgoingConnections) || [], connection);
2252
+ removeIfExists(((_b = connection.end) === null || _b === void 0 ? void 0 : _b.incomingConnections) || [], connection);
2199
2253
  // remove from set of connections
2200
2254
  super.remove(id);
2201
2255
  // remove from canvas
@@ -2219,7 +2273,9 @@ const DIAGRAM_FIELD_DEFAULTS = {
2219
2273
  selectedColor: '#000000',
2220
2274
  horizontalAlign: HorizontalAlign.Center,
2221
2275
  verticalAlign: VerticalAlign.Center,
2222
- fit: false
2276
+ orientation: Side.Top,
2277
+ fit: false,
2278
+ shrink: true
2223
2279
  };
2224
2280
  /**
2225
2281
  * A field which displays text and is part of a diagram element.
@@ -2238,17 +2294,17 @@ class DiagramField extends DiagramElement {
2238
2294
  }
2239
2295
  set text(value) {
2240
2296
  var _a;
2241
- if (value === null || value === undefined || (value === null || value === undefined ? undefined : value.trim()) === '') {
2297
+ if (value === null || value === undefined || (value === null || value === void 0 ? void 0 : value.trim()) === '') {
2242
2298
  value = this.defaultText;
2243
2299
  }
2244
2300
  this._text = value;
2245
2301
  this.updateInView();
2246
2302
  if (this.fit) {
2247
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.fitFieldRootInView(this.id);
2303
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.fitFieldRootInView(this.id, this.shrink);
2248
2304
  }
2249
2305
  }
2250
- constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit) {
2251
- const id = `${rootElement === null || rootElement === undefined ? undefined : rootElement.id}_field`;
2306
+ constructor(model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2307
+ const id = `${rootElement === null || rootElement === void 0 ? void 0 : rootElement.id}_field`;
2252
2308
  if (model.fields.get(id) !== undefined) {
2253
2309
  throw new Error('DiagramField for rootElement already exists');
2254
2310
  }
@@ -2268,21 +2324,42 @@ class DiagramField extends DiagramElement {
2268
2324
  this.selectedColor = selectedColor;
2269
2325
  this.horizontalAlign = horizontalAlign;
2270
2326
  this.verticalAlign = verticalAlign;
2327
+ if (!isNaN(Number(orientation))) {
2328
+ this.orientation = Number(orientation);
2329
+ } else {
2330
+ switch (orientation) {
2331
+ case Side.Top:
2332
+ this.orientation = 0;
2333
+ break;
2334
+ case Side.Right:
2335
+ this.orientation = 90;
2336
+ break;
2337
+ case Side.Bottom:
2338
+ this.orientation = 180;
2339
+ break;
2340
+ case Side.Left:
2341
+ this.orientation = 270;
2342
+ break;
2343
+ default:
2344
+ this.orientation = 0;
2345
+ }
2346
+ }
2271
2347
  this.defaultText = text;
2272
2348
  this._text = text;
2273
2349
  this.editable = editable;
2274
2350
  this.fit = fit;
2351
+ this.shrink = shrink;
2275
2352
  }
2276
2353
  get removed() {
2277
2354
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
2278
2355
  }
2279
2356
  updateInView() {
2280
2357
  var _a;
2281
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateFieldsInView(this.id);
2358
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateFieldsInView(this.id);
2282
2359
  }
2283
2360
  raise() {
2284
2361
  var _a;
2285
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2362
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2286
2363
  }
2287
2364
  /**
2288
2365
  * Change the coordinates of this field to the given coordinates.
@@ -2295,7 +2372,7 @@ class DiagramField extends DiagramElement {
2295
2372
  }
2296
2373
  getPriority() {
2297
2374
  var _a;
2298
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
2375
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
2299
2376
  }
2300
2377
  }
2301
2378
  class DiagramFieldSet extends DiagramElementSet {
@@ -2311,8 +2388,8 @@ class DiagramFieldSet extends DiagramElementSet {
2311
2388
  * 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.
2312
2389
  * @private
2313
2390
  */
2314
- new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, text, editable, fit) {
2315
- const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, text, editable, fit);
2391
+ new(rootElement, coords, fontSize, fontFamily, color, selectedColor, width, height, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink) {
2392
+ const field = new DiagramField(this.model, rootElement, coords, width, height, fontSize, fontFamily, color, selectedColor, horizontalAlign, verticalAlign, orientation, text, editable, fit, shrink);
2316
2393
  super.add(field);
2317
2394
  field.updateInView();
2318
2395
  // add this field to its root element
@@ -2326,7 +2403,7 @@ class DiagramFieldSet extends DiagramElementSet {
2326
2403
  const field = this.get(id, true);
2327
2404
  if (field) {
2328
2405
  // remove from root element
2329
- if (((_a = field.rootElement) === null || _a === undefined ? undefined : _a.label) !== undefined) {
2406
+ if (((_a = field.rootElement) === null || _a === void 0 ? void 0 : _a.label) !== undefined) {
2330
2407
  if (field.rootElement.label === field) {
2331
2408
  field.rootElement.label = undefined;
2332
2409
  }
@@ -2339,7 +2416,7 @@ class DiagramFieldSet extends DiagramElementSet {
2339
2416
  }
2340
2417
  }
2341
2418
  const getBottomMargin = config => {
2342
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2419
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2343
2420
  return DIAGRAM_FIELD_DEFAULTS.margin;
2344
2421
  } else if (typeof config.margin === 'number') {
2345
2422
  return config.margin;
@@ -2358,7 +2435,7 @@ const getBottomMargin = config => {
2358
2435
  }
2359
2436
  };
2360
2437
  const getLeftMargin = config => {
2361
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2438
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2362
2439
  return DIAGRAM_FIELD_DEFAULTS.margin;
2363
2440
  } else if (typeof config.margin === 'number') {
2364
2441
  return config.margin;
@@ -2377,7 +2454,7 @@ const getLeftMargin = config => {
2377
2454
  }
2378
2455
  };
2379
2456
  const getRightMargin = config => {
2380
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2457
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2381
2458
  return DIAGRAM_FIELD_DEFAULTS.margin;
2382
2459
  } else if (typeof config.margin === 'number') {
2383
2460
  return config.margin;
@@ -2396,7 +2473,7 @@ const getRightMargin = config => {
2396
2473
  }
2397
2474
  };
2398
2475
  const getTopMargin = config => {
2399
- if ((config === null || config === undefined ? undefined : config.margin) === null || (config === null || config === undefined ? undefined : config.margin) === undefined) {
2476
+ if ((config === null || config === void 0 ? void 0 : config.margin) === null || (config === null || config === void 0 ? void 0 : config.margin) === undefined) {
2400
2477
  return DIAGRAM_FIELD_DEFAULTS.margin;
2401
2478
  } else if (typeof config.margin === 'number') {
2402
2479
  return config.margin;
@@ -2415,7 +2492,7 @@ const getTopMargin = config => {
2415
2492
  }
2416
2493
  };
2417
2494
  const getBottomPadding$1 = config => {
2418
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2495
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2419
2496
  return DIAGRAM_FIELD_DEFAULTS.padding;
2420
2497
  } else if (typeof config.padding === 'number') {
2421
2498
  return config.padding;
@@ -2434,7 +2511,7 @@ const getBottomPadding$1 = config => {
2434
2511
  }
2435
2512
  };
2436
2513
  const getLeftPadding$1 = config => {
2437
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2514
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2438
2515
  return DIAGRAM_FIELD_DEFAULTS.padding;
2439
2516
  } else if (typeof config.padding === 'number') {
2440
2517
  return config.padding;
@@ -2453,7 +2530,7 @@ const getLeftPadding$1 = config => {
2453
2530
  }
2454
2531
  };
2455
2532
  const getRightPadding$1 = config => {
2456
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2533
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2457
2534
  return DIAGRAM_FIELD_DEFAULTS.padding;
2458
2535
  } else if (typeof config.padding === 'number') {
2459
2536
  return config.padding;
@@ -2472,7 +2549,7 @@ const getRightPadding$1 = config => {
2472
2549
  }
2473
2550
  };
2474
2551
  const getTopPadding$1 = config => {
2475
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
2552
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
2476
2553
  return DIAGRAM_FIELD_DEFAULTS.padding;
2477
2554
  } else if (typeof config.padding === 'number') {
2478
2555
  return config.padding;
@@ -2543,6 +2620,8 @@ class DiagramSectionType {
2543
2620
  this.label = options.label || null;
2544
2621
  this.ports = options.ports || [];
2545
2622
  this.priority = options.priority || DEFAULT_PRIORITY;
2623
+ this.resizableX = options.resizableX;
2624
+ this.resizableY = options.resizableY;
2546
2625
  const looks = extractLooksFromConfig(options.look || DIAGRAM_NODE_LOOK_DEFAULTS);
2547
2626
  this.defaultLook = looks.defaultLook;
2548
2627
  this.selectedLook = looks.selectedLook;
@@ -2564,7 +2643,7 @@ class DiagramSection extends DiagramElement {
2564
2643
  */
2565
2644
  get name() {
2566
2645
  var _a;
2567
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
2646
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
2568
2647
  }
2569
2648
  set name(name) {
2570
2649
  if (this.label) {
@@ -2579,15 +2658,15 @@ class DiagramSection extends DiagramElement {
2579
2658
  var _a, _b, _c, _d, _e, _f, _g, _h;
2580
2659
  if (this.selected) {
2581
2660
  if (this.highlighted) {
2582
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === undefined ? undefined : _b.look);
2661
+ return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : ((_a = this.type) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook) || ((_b = this.node) === null || _b === void 0 ? void 0 : _b.look);
2583
2662
  } else {
2584
- return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === undefined ? undefined : _c.selectedLook) || ((_d = this.node) === null || _d === undefined ? undefined : _d.look);
2663
+ return this._selectedLook !== undefined ? this._selectedLook : ((_c = this.type) === null || _c === void 0 ? void 0 : _c.selectedLook) || ((_d = this.node) === null || _d === void 0 ? void 0 : _d.look);
2585
2664
  }
2586
2665
  } else {
2587
2666
  if (this.highlighted) {
2588
- return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === undefined ? undefined : _e.highlightedLook) || ((_f = this.node) === null || _f === undefined ? undefined : _f.look);
2667
+ return this._highlightedLook !== undefined ? this._highlightedLook : ((_e = this.type) === null || _e === void 0 ? void 0 : _e.highlightedLook) || ((_f = this.node) === null || _f === void 0 ? void 0 : _f.look);
2589
2668
  } else {
2590
- return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === undefined ? undefined : _g.defaultLook) || ((_h = this.node) === null || _h === undefined ? undefined : _h.look);
2669
+ return this._defaultLook !== undefined ? this._defaultLook : ((_g = this.type) === null || _g === void 0 ? void 0 : _g.defaultLook) || ((_h = this.node) === null || _h === void 0 ? void 0 : _h.look);
2591
2670
  }
2592
2671
  }
2593
2672
  }
@@ -2640,11 +2719,11 @@ class DiagramSection extends DiagramElement {
2640
2719
  }
2641
2720
  updateInView() {
2642
2721
  var _a;
2643
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateSectionsInView(this.id);
2722
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateSectionsInView(this.id);
2644
2723
  }
2645
2724
  raise() {
2646
2725
  var _a;
2647
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
2726
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
2648
2727
  if (this.label) {
2649
2728
  this.label.raise();
2650
2729
  }
@@ -2657,19 +2736,47 @@ class DiagramSection extends DiagramElement {
2657
2736
  }
2658
2737
  get type() {
2659
2738
  var _a, _b, _c, _d, _e;
2660
- return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode];
2739
+ return (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode];
2661
2740
  }
2662
2741
  getMinWidth() {
2663
2742
  var _a, _b, _c, _d;
2664
- return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minWidths) === null || _d === undefined ? undefined : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
2743
+ return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minWidths) === null || _d === void 0 ? void 0 : _d[this.indexXInNode]) || DIAGRAM_SECTION_MIN_WIDTH;
2665
2744
  }
2666
2745
  getMinHeight() {
2667
2746
  var _a, _b, _c, _d;
2668
- return ((_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.minHeights) === null || _d === undefined ? undefined : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
2747
+ return ((_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.minHeights) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) || DIAGRAM_SECTION_MIN_HEIGHT;
2669
2748
  }
2670
2749
  getPriority() {
2671
2750
  var _a, _b, _c, _d, _e, _f;
2672
- return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[this.indexYInNode]) === null || _e === undefined ? undefined : _e[this.indexXInNode]) === null || _f === undefined ? undefined : _f.priority) || DEFAULT_PRIORITY;
2751
+ return ((_f = (_e = (_d = (_c = (_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[this.indexYInNode]) === null || _e === void 0 ? void 0 : _e[this.indexXInNode]) === null || _f === void 0 ? void 0 : _f.priority) || DEFAULT_PRIORITY;
2752
+ }
2753
+ /**
2754
+ * Returns whether this section can be resized horizontally.
2755
+ * If the section has a specific resizableX setting, it uses that.
2756
+ * Otherwise, it inherits from the parent node's resizableX setting.
2757
+ * @public
2758
+ */
2759
+ getResizableX() {
2760
+ var _a, _b;
2761
+ const sectionType = this.type;
2762
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableX) !== undefined) {
2763
+ return sectionType.resizableX;
2764
+ }
2765
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableX) || false;
2766
+ }
2767
+ /**
2768
+ * Returns whether this section can be resized vertically.
2769
+ * If the section has a specific resizableY setting, it uses that.
2770
+ * Otherwise, it inherits from the parent node's resizableY setting.
2771
+ * @public
2772
+ */
2773
+ getResizableY() {
2774
+ var _a, _b;
2775
+ const sectionType = this.type;
2776
+ if ((sectionType === null || sectionType === void 0 ? void 0 : sectionType.resizableY) !== undefined) {
2777
+ return sectionType.resizableY;
2778
+ }
2779
+ return ((_b = (_a = this.node) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.resizableY) || false;
2673
2780
  }
2674
2781
  /**
2675
2782
  * Get the port of this section which is closest to the given coordinates.
@@ -2829,19 +2936,19 @@ class DiagramSection extends DiagramElement {
2829
2936
  const newCoordsY = [this.coords[1], this.coords[1] + this.height];
2830
2937
  // Move ports to match the new coords.
2831
2938
  for (const port of this.ports) {
2832
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2939
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
2833
2940
  }
2834
2941
  // Set label's dimensions as a function of ours.
2835
2942
  const type = this.type;
2836
2943
  if (this.label) {
2837
- this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label), this.coords[1] + getTopMargin(type === null || type === undefined ? undefined : type.label)];
2838
- this.label.width = this.width - getLeftMargin(type === null || type === undefined ? undefined : type.label) - getRightMargin(type === null || type === undefined ? undefined : type.label);
2839
- this.label.height = this.height - getTopMargin(type === null || type === undefined ? undefined : type.label) - getBottomMargin(type === null || type === undefined ? undefined : type.label);
2944
+ this.label.coords = [this.coords[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label), this.coords[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label)];
2945
+ this.label.width = this.width - getLeftMargin(type === null || type === void 0 ? void 0 : type.label) - getRightMargin(type === null || type === void 0 ? void 0 : type.label);
2946
+ this.label.height = this.height - getTopMargin(type === null || type === void 0 ? void 0 : type.label) - getBottomMargin(type === null || type === void 0 ? void 0 : type.label);
2840
2947
  this.label.updateInView();
2841
2948
  }
2842
2949
  // Move decorators to match the new coords.
2843
2950
  for (const decorator of this.decorators) {
2844
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
2951
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
2845
2952
  }
2846
2953
  // Update canvas.
2847
2954
  this.getConnections().forEach(c => c.tighten());
@@ -2870,13 +2977,13 @@ class DiagramSectionSet extends DiagramElementSet {
2870
2977
  node.sections.push(section);
2871
2978
  node.updateInView();
2872
2979
  // add section ports
2873
- const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.sections) === null || _b === undefined ? undefined : _b[indexYInNode]) === null || _c === undefined ? undefined : _c[indexXInNode]) === null || _d === undefined ? undefined : _d.ports;
2980
+ const sectionPorts = (_d = (_c = (_b = (_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.sections) === null || _b === void 0 ? void 0 : _b[indexYInNode]) === null || _c === void 0 ? void 0 : _c[indexXInNode]) === null || _d === void 0 ? void 0 : _d.ports;
2874
2981
  if (sectionPorts && sectionPorts.length > 0) {
2875
2982
  for (let i = 0; i < sectionPorts.length; ++i) {
2876
2983
  const portConfig = sectionPorts[i];
2877
- const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === undefined ? undefined : portConfig.direction, `${section.id}_${i}`);
2878
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
2879
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
2984
+ const port = this.model.ports.new(portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined, section, [section.coords[0] + (portConfig.coords[0] || 0), section.coords[1] + (portConfig.coords[1] || 0)], portConfig.connectionPoint !== undefined ? [section.coords[0] + (portConfig.connectionPoint[0] || 0), section.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig === null || portConfig === void 0 ? void 0 : portConfig.direction, `${section.id}_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
2985
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
2986
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
2880
2987
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
2881
2988
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
2882
2989
  let labelCoords;
@@ -2892,15 +2999,15 @@ class DiagramSectionSet extends DiagramElementSet {
2892
2999
  default:
2893
3000
  labelCoords = port.coords;
2894
3001
  }
2895
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3002
+ this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
2896
3003
  }
2897
3004
  }
2898
3005
  }
2899
3006
  // add section label
2900
- const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[indexYInNode]) === null || _j === undefined ? undefined : _j[indexXInNode]) === null || _k === undefined ? undefined : _k.label;
3007
+ const sectionLabel = (_k = (_j = (_h = (_g = node.type.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[indexYInNode]) === null || _j === void 0 ? void 0 : _j[indexXInNode]) === null || _k === void 0 ? void 0 : _k.label;
2901
3008
  if (sectionLabel) {
2902
3009
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), sectionLabel);
2903
- this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3010
+ this.model.fields.new(section, [section.coords[0] + getLeftMargin(labelConfiguration), section.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, section.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), section.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
2904
3011
  }
2905
3012
  return section;
2906
3013
  }
@@ -3004,7 +3111,7 @@ class DiagramNodeType {
3004
3111
  this.canBeParentless = values.canBeParentless;
3005
3112
  this.childrenTypes = values.childrenTypes;
3006
3113
  this.priority = values.priority;
3007
- this.propertySet = new PropertySet((options === null || options === undefined ? undefined : options.properties) || []);
3114
+ this.propertySet = new PropertySet((options === null || options === void 0 ? void 0 : options.properties) || []);
3008
3115
  }
3009
3116
  }
3010
3117
  /**
@@ -3020,20 +3127,24 @@ class DiagramNode extends DiagramElement {
3020
3127
  }
3021
3128
  set type(type) {
3022
3129
  var _a, _b;
3023
- (_b = (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.userSelection) === null || _b === undefined ? undefined : _b.openInPropertyEditor(undefined);
3024
- this._type = type;
3025
- if (this.valueSet) {
3026
- this.valueSet = new ValueSet(type.propertySet, this);
3130
+ if (type !== this._type) {
3131
+ this._type = type;
3132
+ if (this.valueSet) {
3133
+ this.valueSet = new ValueSet(type.propertySet, this);
3134
+ }
3135
+ (_b = (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.userSelection) === null || _b === void 0 ? void 0 : _b.openInPropertyEditor(this, false);
3136
+ this.updateInView();
3027
3137
  }
3028
- this.updateInView();
3029
3138
  }
3030
3139
  get typeString() {
3031
3140
  return this.type.id;
3032
3141
  }
3033
3142
  set typeString(typeString) {
3034
- const type = this.model.nodes.types.get(typeString);
3035
- if (type) {
3036
- this.type = type;
3143
+ if (typeString !== this.type.id) {
3144
+ const type = this.model.nodes.types.get(typeString);
3145
+ if (type) {
3146
+ this.type = type;
3147
+ }
3037
3148
  }
3038
3149
  }
3039
3150
  /**
@@ -3042,7 +3153,7 @@ class DiagramNode extends DiagramElement {
3042
3153
  */
3043
3154
  get name() {
3044
3155
  var _a;
3045
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
3156
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
3046
3157
  }
3047
3158
  set name(name) {
3048
3159
  if (this.label) {
@@ -3132,11 +3243,11 @@ class DiagramNode extends DiagramElement {
3132
3243
  }
3133
3244
  updateInView() {
3134
3245
  var _a;
3135
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateNodesInView(this.id);
3246
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateNodesInView(this.id);
3136
3247
  }
3137
3248
  raise() {
3138
3249
  var _a;
3139
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
3250
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
3140
3251
  for (const section of this.sections) {
3141
3252
  section.raise();
3142
3253
  }
@@ -3243,7 +3354,7 @@ class DiagramNode extends DiagramElement {
3243
3354
  if (!includeRemoved && incomingConnection.removed) {
3244
3355
  continue;
3245
3356
  }
3246
- const otherNode = (_a = incomingConnection.start) === null || _a === undefined ? undefined : _a.getNode();
3357
+ const otherNode = (_a = incomingConnection.start) === null || _a === void 0 ? void 0 : _a.getNode();
3247
3358
  if (otherNode) {
3248
3359
  if (!includeRemoved && otherNode.removed) {
3249
3360
  continue;
@@ -3255,7 +3366,7 @@ class DiagramNode extends DiagramElement {
3255
3366
  if (!includeRemoved && outgoingConnection.removed) {
3256
3367
  continue;
3257
3368
  }
3258
- const otherNode = (_b = outgoingConnection.end) === null || _b === undefined ? undefined : _b.getNode();
3369
+ const otherNode = (_b = outgoingConnection.end) === null || _b === void 0 ? void 0 : _b.getNode();
3259
3370
  if (otherNode) {
3260
3371
  if (!includeRemoved && otherNode.removed) {
3261
3372
  continue;
@@ -3274,7 +3385,7 @@ class DiagramNode extends DiagramElement {
3274
3385
  // eslint-disable-next-line @typescript-eslint/no-this-alias
3275
3386
  let node = this;
3276
3387
  while (node.parent !== undefined) {
3277
- node = node === null || node === undefined ? undefined : node.parent;
3388
+ node = node === null || node === void 0 ? void 0 : node.parent;
3278
3389
  }
3279
3390
  return node;
3280
3391
  }
@@ -3333,21 +3444,42 @@ class DiagramNode extends DiagramElement {
3333
3444
  child.parent = undefined;
3334
3445
  }
3335
3446
  fitToChild(child) {
3447
+ // if the node includes sections, we stretch the sections as well when fitting to a child node
3448
+ // we assume it is most natural to stretch the last row and column of section
3449
+ // TODO: consider being able to configure which row or column gets stretched first
3450
+ const maxSectionIndexX = Math.max(...this.sections.map(s => s.indexXInNode));
3451
+ const maxSectionIndexY = Math.max(...this.sections.map(s => s.indexYInNode));
3336
3452
  const excessLeft = this.coords[0] - child.coords[0] + this.type.leftPadding;
3337
3453
  if (excessLeft >= 0) {
3338
- this.stretch(Side.Left, excessLeft);
3454
+ if (this.sections.length > 0) {
3455
+ this.stretchSections(Side.Left, excessLeft, maxSectionIndexX, maxSectionIndexY);
3456
+ } else {
3457
+ this.stretch(Side.Left, excessLeft);
3458
+ }
3339
3459
  }
3340
3460
  const excessTop = this.coords[1] - child.coords[1] + this.type.topPadding;
3341
3461
  if (excessTop >= 0) {
3342
- this.stretch(Side.Top, excessTop);
3462
+ if (this.sections.length > 0) {
3463
+ this.stretchSections(Side.Top, excessTop, maxSectionIndexX, maxSectionIndexY);
3464
+ } else {
3465
+ this.stretch(Side.Top, excessTop);
3466
+ }
3343
3467
  }
3344
3468
  const excessRight = child.coords[0] + child.width - (this.coords[0] + this.width) + this.type.rightPadding;
3345
3469
  if (excessRight >= 0) {
3346
- this.stretch(Side.Right, excessRight);
3470
+ if (this.sections.length > 0) {
3471
+ this.stretchSections(Side.Right, excessRight, maxSectionIndexX, maxSectionIndexY);
3472
+ } else {
3473
+ this.stretch(Side.Right, excessRight);
3474
+ }
3347
3475
  }
3348
3476
  const excessBottom = child.coords[1] + child.height - (this.coords[1] + this.height) + this.type.bottomPadding;
3349
3477
  if (excessBottom >= 0) {
3350
- this.stretch(Side.Bottom, excessBottom);
3478
+ if (this.sections.length > 0) {
3479
+ this.stretchSections(Side.Bottom, excessBottom, maxSectionIndexX, maxSectionIndexY);
3480
+ } else {
3481
+ this.stretch(Side.Bottom, excessBottom);
3482
+ }
3351
3483
  }
3352
3484
  if (this.parent) {
3353
3485
  // ensure this node also fits inside its parent after stretching
@@ -3562,7 +3694,7 @@ class DiagramNode extends DiagramElement {
3562
3694
  }
3563
3695
  // Move ports to match the new coords.
3564
3696
  for (const port of this.ports) {
3565
- port.move(translatePoint(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3697
+ port.move(translatePointWithAnchors(port.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, port.anchorPointX, port.anchorPointY));
3566
3698
  }
3567
3699
  // Set label's dimensions as a function of ours.
3568
3700
  if (this.label) {
@@ -3573,7 +3705,7 @@ class DiagramNode extends DiagramElement {
3573
3705
  }
3574
3706
  // Move decorators to match the new coords.
3575
3707
  for (const decorator of this.decorators) {
3576
- decorator.move(translatePoint(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY));
3708
+ decorator.move(translatePointWithAnchors(decorator.coords, oldCoordsX, oldCoordsY, newCoordsX, newCoordsY, decorator.anchorPointX, decorator.anchorPointY));
3577
3709
  }
3578
3710
  // Update canvas.
3579
3711
  this.getConnections().forEach(c => c.tighten());
@@ -3585,7 +3717,7 @@ class DiagramNode extends DiagramElement {
3585
3717
  */
3586
3718
  removeSectionColumn(columnIndex) {
3587
3719
  var _a;
3588
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3720
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3589
3721
  let columnWidth = 0;
3590
3722
  const sections = [...this.sections];
3591
3723
  for (const section of sections) {
@@ -3608,7 +3740,7 @@ class DiagramNode extends DiagramElement {
3608
3740
  */
3609
3741
  removeSectionRow(rowIndex) {
3610
3742
  var _a;
3611
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3743
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3612
3744
  let rowHeight = 0;
3613
3745
  const sections = [...this.sections];
3614
3746
  for (const section of sections) {
@@ -3631,7 +3763,7 @@ class DiagramNode extends DiagramElement {
3631
3763
  */
3632
3764
  copySectionColumn(columnIndex) {
3633
3765
  var _a;
3634
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3766
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3635
3767
  let columnWidth = 0;
3636
3768
  const sections = [...this.sections];
3637
3769
  for (const section of sections) {
@@ -3658,7 +3790,7 @@ class DiagramNode extends DiagramElement {
3658
3790
  */
3659
3791
  copySectionRow(rowIndex) {
3660
3792
  var _a;
3661
- const margin = ((_a = this.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
3793
+ const margin = ((_a = this.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
3662
3794
  let rowHeight = 0;
3663
3795
  const sections = [...this.sections];
3664
3796
  for (const section of sections) {
@@ -3724,10 +3856,10 @@ class DiagramNodeSet extends DiagramElementSet {
3724
3856
  for (let j = 0; j < nodeType.sectionGrid.sections.length; ++j) {
3725
3857
  let widthAccumulator = node.coords[0] + (nodeType.sectionGrid.margin || 0);
3726
3858
  for (let i = 0; i < nodeType.sectionGrid.sections[j].length; ++i) {
3727
- this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === undefined ? undefined : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === undefined ? undefined : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
3728
- widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === undefined ? undefined : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3859
+ this.model.sections.new(node, i, j, [widthAccumulator, heightAccumulator], ((_a = nodeType.sectionGrid.defaultWidths) === null || _a === void 0 ? void 0 : _a[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH, ((_b = nodeType.sectionGrid.defaultHeights) === null || _b === void 0 ? void 0 : _b[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT, `${node.id}_${j}_${i}`);
3860
+ widthAccumulator += (((_c = nodeType.sectionGrid.defaultWidths) === null || _c === void 0 ? void 0 : _c[i]) || DIAGRAM_SECTION_DEFAULT_WIDTH) + (nodeType.sectionGrid.margin || 0);
3729
3861
  }
3730
- heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === undefined ? undefined : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3862
+ heightAccumulator += (((_d = nodeType.sectionGrid.defaultHeights) === null || _d === void 0 ? void 0 : _d[j]) || DIAGRAM_SECTION_DEFAULT_HEIGHT) + (nodeType.sectionGrid.margin || 0);
3731
3863
  }
3732
3864
  }
3733
3865
  // add node ports
@@ -3735,9 +3867,9 @@ class DiagramNodeSet extends DiagramElementSet {
3735
3867
  for (let i = 0; i < nodeType.ports.length; ++i) {
3736
3868
  const portConfig = nodeType.ports[i];
3737
3869
  const portType = portConfig.type !== undefined ? this.model.ports.types.get(portConfig.type) : undefined;
3738
- const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`);
3739
- if ((_e = port.type) === null || _e === undefined ? undefined : _e.label) {
3740
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === undefined ? undefined : _f.label);
3870
+ const port = this.model.ports.new(portType, node, [node.coords[0] + portConfig.coords[0], node.coords[1] + portConfig.coords[1]], portConfig.connectionPoint !== undefined ? [node.coords[0] + (portConfig.connectionPoint[0] || 0), node.coords[1] + (portConfig.connectionPoint[1] || 0)] : undefined, portConfig.direction, `${node.id}_port_${i}`, portConfig.anchorPointX || 'floating', portConfig.anchorPointY || 'floating');
3871
+ if ((_e = port.type) === null || _e === void 0 ? void 0 : _e.label) {
3872
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_f = port.type) === null || _f === void 0 ? void 0 : _f.label);
3741
3873
  const labelWidth = 6 * labelConfiguration.fontSize + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
3742
3874
  const labelHeight = labelConfiguration.fontSize + getTopPadding$1(labelConfiguration) + getBottomPadding$1(labelConfiguration);
3743
3875
  let labelCoords;
@@ -3753,24 +3885,24 @@ class DiagramNodeSet extends DiagramElementSet {
3753
3885
  default:
3754
3886
  labelCoords = port.coords;
3755
3887
  }
3756
- this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3888
+ this.model.fields.new(port, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelWidth, labelHeight, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3757
3889
  }
3758
3890
  }
3759
3891
  }
3760
3892
  // add node label
3761
3893
  if (nodeType.label) {
3762
3894
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), nodeType.label);
3763
- this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
3895
+ this.model.fields.new(node, [node.coords[0] + getLeftMargin(labelConfiguration), node.coords[1] + getTopMargin(labelConfiguration)], labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, node.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), node.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
3764
3896
  }
3765
3897
  // add node decorators
3766
3898
  if (nodeType.decorators.length > 0) {
3767
3899
  for (let i = 0; i < nodeType.decorators.length; ++i) {
3768
3900
  const decoratorConfig = nodeType.decorators[i];
3769
- this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`);
3901
+ this.model.decorators.new(node, [node.coords[0] + decoratorConfig.coords[0], node.coords[1] + decoratorConfig.coords[1]], decoratorConfig.width, decoratorConfig.height, node.getPriority(), decoratorConfig.html, `${node.id}_decorator_${i}`, decoratorConfig.anchorPointX || 'floating', decoratorConfig.anchorPointY || 'floating');
3770
3902
  }
3771
3903
  }
3772
3904
  node.valueSet.resetValues();
3773
- (_g = node.model.canvas) === null || _g === undefined ? undefined : _g.fitNodeInView(node.id);
3905
+ (_g = node.model.canvas) === null || _g === void 0 ? void 0 : _g.fitNodeInView(node.id);
3774
3906
  return node;
3775
3907
  }
3776
3908
  remove(id) {
@@ -3862,7 +3994,7 @@ const filterByOnlyDescendants = nodes => {
3862
3994
  return nodes;
3863
3995
  };
3864
3996
  const getBottomPadding = config => {
3865
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
3997
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3866
3998
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3867
3999
  } else if (typeof config.padding === 'number') {
3868
4000
  return config.padding;
@@ -3881,7 +4013,7 @@ const getBottomPadding = config => {
3881
4013
  }
3882
4014
  };
3883
4015
  const getLeftPadding = config => {
3884
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4016
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3885
4017
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3886
4018
  } else if (typeof config.padding === 'number') {
3887
4019
  return config.padding;
@@ -3900,7 +4032,7 @@ const getLeftPadding = config => {
3900
4032
  }
3901
4033
  };
3902
4034
  const getRightPadding = config => {
3903
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4035
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3904
4036
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3905
4037
  } else if (typeof config.padding === 'number') {
3906
4038
  return config.padding;
@@ -3919,7 +4051,7 @@ const getRightPadding = config => {
3919
4051
  }
3920
4052
  };
3921
4053
  const getTopPadding = config => {
3922
- if ((config === null || config === undefined ? undefined : config.padding) === null || (config === null || config === undefined ? undefined : config.padding) === undefined) {
4054
+ if ((config === null || config === void 0 ? void 0 : config.padding) === null || (config === null || config === void 0 ? void 0 : config.padding) === undefined) {
3923
4055
  return DIAGRAM_NODE_TYPE_DEFAULTS.padding;
3924
4056
  } else if (typeof config.padding === 'number') {
3925
4057
  return config.padding;
@@ -4003,20 +4135,25 @@ class DiagramPort extends DiagramElement {
4003
4135
  return this._type;
4004
4136
  }
4005
4137
  set type(type) {
4006
- this._type = type;
4007
- this.updateInView();
4138
+ if (type !== this._type) {
4139
+ this._type = type;
4140
+ this.updateInView();
4141
+ }
4008
4142
  }
4009
4143
  get typeString() {
4010
4144
  var _a;
4011
- return (_a = this.type) === null || _a === undefined ? undefined : _a.id;
4145
+ return (_a = this.type) === null || _a === void 0 ? void 0 : _a.id;
4012
4146
  }
4013
4147
  set typeString(typeString) {
4014
- if (typeString === undefined) {
4015
- this.type = undefined;
4016
- } else {
4017
- const type = this.model.ports.types.get(typeString);
4018
- if (type) {
4019
- this.type = type;
4148
+ var _a;
4149
+ if (typeString !== ((_a = this.type) === null || _a === void 0 ? void 0 : _a.id)) {
4150
+ if (typeString === undefined) {
4151
+ this.type = undefined;
4152
+ } else {
4153
+ const type = this.model.ports.types.get(typeString);
4154
+ if (type) {
4155
+ this.type = type;
4156
+ }
4020
4157
  }
4021
4158
  }
4022
4159
  }
@@ -4025,14 +4162,14 @@ class DiagramPort extends DiagramElement {
4025
4162
  */
4026
4163
  get allowsOutgoing() {
4027
4164
  var _a, _b;
4028
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsOutgoing : true;
4165
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsOutgoing) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsOutgoing : true;
4029
4166
  }
4030
4167
  /**
4031
4168
  * Whether this port can be used as a connection end point.
4032
4169
  */
4033
4170
  get allowsIncoming() {
4034
4171
  var _a, _b;
4035
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === undefined ? undefined : _b.allowsIncoming : true;
4172
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.allowsIncoming) !== undefined ? (_b = this.type) === null || _b === void 0 ? void 0 : _b.allowsIncoming : true;
4036
4173
  }
4037
4174
  /**
4038
4175
  * Name of this port. Alias for this port's label's text.
@@ -4040,7 +4177,7 @@ class DiagramPort extends DiagramElement {
4040
4177
  */
4041
4178
  get name() {
4042
4179
  var _a;
4043
- return ((_a = this.label) === null || _a === undefined ? undefined : _a.text) || '';
4180
+ return ((_a = this.label) === null || _a === void 0 ? void 0 : _a.text) || '';
4044
4181
  }
4045
4182
  set name(name) {
4046
4183
  if (this.label) {
@@ -4055,15 +4192,15 @@ class DiagramPort extends DiagramElement {
4055
4192
  var _a, _b, _c, _d;
4056
4193
  if (this.selected) {
4057
4194
  if (this.highlighted) {
4058
- return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === undefined ? undefined : _a.selectedAndHighlightedLook;
4195
+ return this._selectedAndHighlightedLook !== undefined ? this._selectedAndHighlightedLook : (_a = this.type || DIAGRAM_PORT_LOOKS) === null || _a === void 0 ? void 0 : _a.selectedAndHighlightedLook;
4059
4196
  } else {
4060
- return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === undefined ? undefined : _b.selectedLook;
4197
+ return this._selectedLook !== undefined ? this._selectedLook : (_b = this.type || DIAGRAM_PORT_LOOKS) === null || _b === void 0 ? void 0 : _b.selectedLook;
4061
4198
  }
4062
4199
  } else {
4063
4200
  if (this.highlighted) {
4064
- return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === undefined ? undefined : _c.highlightedLook;
4201
+ return this._highlightedLook !== undefined ? this._highlightedLook : (_c = this.type || DIAGRAM_PORT_LOOKS) === null || _c === void 0 ? void 0 : _c.highlightedLook;
4065
4202
  } else {
4066
- return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === undefined ? undefined : _d.defaultLook;
4203
+ return this._defaultLook !== undefined ? this._defaultLook : (_d = this.type || DIAGRAM_PORT_LOOKS) === null || _d === void 0 ? void 0 : _d.defaultLook;
4067
4204
  }
4068
4205
  }
4069
4206
  }
@@ -4092,7 +4229,7 @@ class DiagramPort extends DiagramElement {
4092
4229
  */
4093
4230
  get width() {
4094
4231
  var _a;
4095
- return ((_a = this.type) === null || _a === undefined ? undefined : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
4232
+ return ((_a = this.type) === null || _a === void 0 ? void 0 : _a.width) || DIAGRAM_PORT_TYPE_DEFAULTS.width;
4096
4233
  }
4097
4234
  /**
4098
4235
  * Current height of this port. Same as the width.
@@ -4101,7 +4238,7 @@ class DiagramPort extends DiagramElement {
4101
4238
  get height() {
4102
4239
  return this.width;
4103
4240
  }
4104
- constructor(model, type, rootElement, coords, connectionPoint, direction, id) {
4241
+ constructor(model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4105
4242
  if (model.ports.get(id) !== undefined) {
4106
4243
  throw new Error(`DiagramPort with id "${id}" already exists`);
4107
4244
  }
@@ -4124,17 +4261,19 @@ class DiagramPort extends DiagramElement {
4124
4261
  this.coords = coords;
4125
4262
  this.connectionPoint = connectionPoint || coords;
4126
4263
  this.direction = direction;
4264
+ this.anchorPointX = anchorPointX;
4265
+ this.anchorPointY = anchorPointY;
4127
4266
  }
4128
4267
  get removed() {
4129
4268
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
4130
4269
  }
4131
4270
  updateInView() {
4132
4271
  var _a;
4133
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updatePortsInView(this.id);
4272
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updatePortsInView(this.id);
4134
4273
  }
4135
4274
  raise() {
4136
4275
  var _a;
4137
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
4276
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
4138
4277
  if (this.label) {
4139
4278
  this.label.raise();
4140
4279
  }
@@ -4176,7 +4315,7 @@ class DiagramPort extends DiagramElement {
4176
4315
  }
4177
4316
  getPriority() {
4178
4317
  var _a;
4179
- return ((_a = this.rootElement) === null || _a === undefined ? undefined : _a.getPriority()) || DEFAULT_PRIORITY;
4318
+ return ((_a = this.rootElement) === null || _a === void 0 ? void 0 : _a.getPriority()) || DEFAULT_PRIORITY;
4180
4319
  }
4181
4320
  /**
4182
4321
  * Change the coordinates of this port to the given coordinates and move its labels correspondingly.
@@ -4221,8 +4360,8 @@ class DiagramPortSet extends DiagramElementSet {
4221
4360
  * Instance a new port and add it to this set. This method is normally called when instancing an element with a port and it is rarely called by itself.
4222
4361
  * @private
4223
4362
  */
4224
- new(type, rootElement, coords, connectionPoint, direction, id) {
4225
- const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id);
4363
+ new(type, rootElement, coords, connectionPoint, direction, id, anchorPointX = 'floating', anchorPointY = 'floating') {
4364
+ const port = new DiagramPort(this.model, type, rootElement, coords, connectionPoint, direction, id, anchorPointX, anchorPointY);
4226
4365
  super.add(port);
4227
4366
  port.updateInView();
4228
4367
  // add this port to its root element
@@ -4307,7 +4446,7 @@ class DagaImporter {
4307
4446
  // add node label
4308
4447
  if (newNodeType.label) {
4309
4448
  const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newNodeType.label);
4310
- const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4449
+ const newField = new DiagramField(model, newNode, [newNode.coords[0] + getLeftMargin(labelConfiguration), newNode.coords[1] + getTopMargin(labelConfiguration)], newNode.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newNode.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4311
4450
  newField.text = node.label;
4312
4451
  newNode.label = newField;
4313
4452
  model.fields.add(newField);
@@ -4317,19 +4456,19 @@ class DagaImporter {
4317
4456
  for (const child of node.children || []) {
4318
4457
  const newChild = this.importNode(model, child);
4319
4458
  if (newChild !== undefined) {
4320
- (_a = newNode.children) === null || _a === undefined ? undefined : _a.push(newChild);
4459
+ (_a = newNode.children) === null || _a === void 0 ? void 0 : _a.push(newChild);
4321
4460
  newChild.parent = newNode;
4322
4461
  }
4323
4462
  }
4324
4463
  for (const section of node.sections || []) {
4325
4464
  const newSection = new DiagramSection(model, newNode, section.indexXInNode, section.indexYInNode, section.coords, section.width, section.height, section.id);
4326
- (_b = newNode.sections) === null || _b === undefined ? undefined : _b.push(newSection);
4465
+ (_b = newNode.sections) === null || _b === void 0 ? void 0 : _b.push(newSection);
4327
4466
  model.sections.add(newSection);
4328
4467
  if (section.label) {
4329
4468
  // add section label
4330
- if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === undefined ? undefined : _c.sections) === null || _d === undefined ? undefined : _d[section.indexYInNode]) === null || _e === undefined ? undefined : _e[section.indexXInNode]) === null || _f === undefined ? undefined : _f.label) {
4331
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === undefined ? undefined : _g.sections) === null || _h === undefined ? undefined : _h[section.indexYInNode]) === null || _j === undefined ? undefined : _j[section.indexXInNode]) === null || _k === undefined ? undefined : _k.label);
4332
- const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4469
+ if ((_f = (_e = (_d = (_c = newNodeType.sectionGrid) === null || _c === void 0 ? void 0 : _c.sections) === null || _d === void 0 ? void 0 : _d[section.indexYInNode]) === null || _e === void 0 ? void 0 : _e[section.indexXInNode]) === null || _f === void 0 ? void 0 : _f.label) {
4470
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), (_k = (_j = (_h = (_g = newNodeType.sectionGrid) === null || _g === void 0 ? void 0 : _g.sections) === null || _h === void 0 ? void 0 : _h[section.indexYInNode]) === null || _j === void 0 ? void 0 : _j[section.indexXInNode]) === null || _k === void 0 ? void 0 : _k.label);
4471
+ const newField = new DiagramField(model, newSection, [newSection.coords[0] + getLeftMargin(labelConfiguration), newSection.coords[1] + getTopMargin(labelConfiguration)], newSection.width - getLeftMargin(labelConfiguration) - getRightMargin(labelConfiguration), newSection.height - getTopMargin(labelConfiguration) - getBottomMargin(labelConfiguration), labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4333
4472
  newField.text = section.label;
4334
4473
  newSection.label = newField;
4335
4474
  model.fields.add(newField);
@@ -4344,8 +4483,8 @@ class DagaImporter {
4344
4483
  model.ports.add(newPort);
4345
4484
  if (port.label) {
4346
4485
  // add port label
4347
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4348
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4486
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4487
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4349
4488
  let labelCoords;
4350
4489
  switch (newPort.direction) {
4351
4490
  case Side.Top:
@@ -4361,7 +4500,7 @@ class DagaImporter {
4361
4500
  default:
4362
4501
  labelCoords = newPort.coords;
4363
4502
  }
4364
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4503
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4365
4504
  newField.text = port.label;
4366
4505
  newPort.label = newField;
4367
4506
  model.fields.add(newField);
@@ -4391,8 +4530,8 @@ class DagaImporter {
4391
4530
  model.ports.add(newPort);
4392
4531
  if (port.label) {
4393
4532
  // add port label
4394
- if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === undefined ? undefined : newPortType.label)) {
4395
- const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === undefined ? undefined : newPortType.label);
4533
+ if (newNodeType.ports.length > portCounter && (newPortType === null || newPortType === void 0 ? void 0 : newPortType.label)) {
4534
+ const labelConfiguration = Object.assign(Object.assign({}, DIAGRAM_FIELD_DEFAULTS), newPortType === null || newPortType === void 0 ? void 0 : newPortType.label);
4396
4535
  let labelCoords;
4397
4536
  switch (newPort.direction) {
4398
4537
  case Side.Top:
@@ -4408,7 +4547,7 @@ class DagaImporter {
4408
4547
  default:
4409
4548
  labelCoords = newPort.coords;
4410
4549
  }
4411
- const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, '', labelConfiguration.editable, labelConfiguration.fit);
4550
+ const newField = new DiagramField(model, newPort, labelCoords, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontSize, labelConfiguration.fontFamily, labelConfiguration.color, labelConfiguration.selectedColor, labelConfiguration.horizontalAlign, labelConfiguration.verticalAlign, labelConfiguration.orientation, '', labelConfiguration.editable, labelConfiguration.fit, labelConfiguration.shrink);
4412
4551
  newField.text = port.label;
4413
4552
  newPort.label = newField;
4414
4553
  model.fields.add(newField);
@@ -4492,14 +4631,16 @@ class AddNodeCollabAction {
4492
4631
  var _a;
4493
4632
  const node = this.canvas.model.nodes.new(this.typeId, this.coords, this.id);
4494
4633
  if (this.parentId !== undefined) {
4495
- (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === undefined ? undefined : _a.addChild(node);
4496
- }
4497
- if (this.values !== undefined) {
4498
- node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4634
+ (_a = this.canvas.model.nodes.get(this.parentId)) === null || _a === void 0 ? void 0 : _a.addChild(node);
4499
4635
  }
4500
4636
  if (node.label) {
4501
4637
  node.label.text = this.label || '';
4502
4638
  }
4639
+ if (this.values !== undefined) {
4640
+ node.valueSet.setValues(structuredClone(Object.assign(Object.assign({}, node.valueSet.getValues()), this.values)));
4641
+ } else {
4642
+ node.valueSet.resetValues();
4643
+ }
4503
4644
  }
4504
4645
  serialize() {
4505
4646
  return {
@@ -4614,7 +4755,7 @@ class MoveCollabAction {
4614
4755
  const node = this.canvas.model.nodes.get(nodeId, true);
4615
4756
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4616
4757
  node.move([node.coords[0] + this.delta[0], node.coords[1] + this.delta[1]]);
4617
- (_a = node.parent) === null || _a === undefined ? undefined : _a.fitToChild(node);
4758
+ (_a = node.parent) === null || _a === void 0 ? void 0 : _a.fitToChild(node);
4618
4759
  node.geometryTimestamp = this.timestamp;
4619
4760
  }
4620
4761
  }
@@ -4649,15 +4790,15 @@ class SetGeometryCollabAction {
4649
4790
  if (node && timestampWins(this.timestamp, node.geometryTimestamp)) {
4650
4791
  node.setGeometry(this.to);
4651
4792
  // Re-fit the labels, in case their text has changed since `this.to` was measured.
4652
- if ((_a = node.label) === null || _a === undefined ? undefined : _a.fit) {
4653
- this.canvas.fitFieldRootInView(node.label.id);
4793
+ if ((_a = node.label) === null || _a === void 0 ? void 0 : _a.fit) {
4794
+ this.canvas.fitFieldRootInView(node.label.id, node.label.shrink);
4654
4795
  }
4655
4796
  for (const section of node.sections) {
4656
- if ((_b = section.label) === null || _b === undefined ? undefined : _b.fit) {
4657
- this.canvas.fitFieldRootInView(section.label.id);
4797
+ if ((_b = section.label) === null || _b === void 0 ? void 0 : _b.fit) {
4798
+ this.canvas.fitFieldRootInView(section.label.id, section.label.shrink);
4658
4799
  }
4659
4800
  }
4660
- (_c = node.parent) === null || _c === undefined ? undefined : _c.fitToChild(node);
4801
+ (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
4661
4802
  node.geometryTimestamp = this.timestamp;
4662
4803
  }
4663
4804
  }
@@ -4691,9 +4832,9 @@ class SetParentCollabAction {
4691
4832
  const childNode = this.canvas.model.nodes.get(this.childId, true);
4692
4833
  const parentNode = this.parentId !== undefined ? this.canvas.model.nodes.get(this.parentId, true) : undefined;
4693
4834
  if (childNode && (this.parentId !== undefined ? parentNode : true) && timestampWins(this.timestamp, childNode.geometryTimestamp)) {
4694
- (_a = childNode.parent) === null || _a === undefined ? undefined : _a.removeChild(childNode);
4835
+ (_a = childNode.parent) === null || _a === void 0 ? void 0 : _a.removeChild(childNode);
4695
4836
  childNode.setGeometry(this.childGeometry);
4696
- parentNode === null || parentNode === undefined ? undefined : parentNode.addChild(childNode);
4837
+ parentNode === null || parentNode === void 0 ? void 0 : parentNode.addChild(childNode);
4697
4838
  }
4698
4839
  }
4699
4840
  serialize() {
@@ -4790,12 +4931,12 @@ class UpdateValuesCollabAction {
4790
4931
  if (this.id === undefined) {
4791
4932
  return this.canvas.model.valueSet;
4792
4933
  } else {
4793
- return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === undefined ? undefined : _a.valueSet;
4934
+ return (_a = this.canvas.model.nodes.get(this.id, true) || this.canvas.model.connections.get(this.id, true)) === null || _a === void 0 ? void 0 : _a.valueSet;
4794
4935
  }
4795
4936
  }
4796
4937
  do() {
4797
4938
  var _a;
4798
- (_a = this.getValueSet()) === null || _a === undefined ? undefined : _a.overwriteValuesLww(this.to, this.timestamp);
4939
+ (_a = this.getValueSet()) === null || _a === void 0 ? void 0 : _a.overwriteValuesLww(this.to, this.timestamp);
4799
4940
  }
4800
4941
  serialize() {
4801
4942
  return {
@@ -5775,7 +5916,7 @@ class DiagramHighlightedEvent extends DiagramEvent {
5775
5916
  * @see DiagramSection
5776
5917
  */
5777
5918
  class DiagramDecorator extends DiagramElement {
5778
- constructor(model, rootElement, coords, width, height, priority, html, id) {
5919
+ constructor(model, rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
5779
5920
  if (model.objects.get(id) !== undefined) {
5780
5921
  throw new Error(`DiagramDecorator with id "${id}" already exists`);
5781
5922
  }
@@ -5789,17 +5930,19 @@ class DiagramDecorator extends DiagramElement {
5789
5930
  this.height = height;
5790
5931
  this.priority = priority;
5791
5932
  this.html = html;
5933
+ this.anchorPointX = anchorPointX;
5934
+ this.anchorPointY = anchorPointY;
5792
5935
  }
5793
5936
  get removed() {
5794
5937
  return this.selfRemoved || this.rootElement !== undefined && this.rootElement.removed;
5795
5938
  }
5796
5939
  updateInView() {
5797
5940
  var _a;
5798
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateDecoratorsInView(this.id);
5941
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateDecoratorsInView(this.id);
5799
5942
  }
5800
5943
  raise() {
5801
5944
  var _a;
5802
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
5945
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5803
5946
  }
5804
5947
  /**
5805
5948
  * Change the coordinates of this decorator to the given coordinates.
@@ -5834,8 +5977,8 @@ class DiagramDecoratorSet extends DiagramElementSet {
5834
5977
  * @param id The id of the decorator. Cannot be an empty string.
5835
5978
  * @returns The instanced decorator.
5836
5979
  */
5837
- new(rootElement, coords, width, height, priority, html, id) {
5838
- const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id);
5980
+ new(rootElement, coords, width, height, priority, html, id, anchorPointX = 'floating', anchorPointY = 'floating') {
5981
+ const decorator = new DiagramDecorator(this.model, rootElement, coords, width, height, priority, html, id, anchorPointX, anchorPointY);
5839
5982
  super.add(decorator);
5840
5983
  decorator.updateInView();
5841
5984
  // add this port to its root element
@@ -5884,11 +6027,11 @@ class DiagramObject extends DiagramElement {
5884
6027
  }
5885
6028
  updateInView() {
5886
6029
  var _a;
5887
- (_a = this.model.canvas) === null || _a === undefined ? undefined : _a.updateObjectsInView(this.id);
6030
+ (_a = this.model.canvas) === null || _a === void 0 ? void 0 : _a.updateObjectsInView(this.id);
5888
6031
  }
5889
6032
  raise() {
5890
6033
  var _a;
5891
- (_a = this.select()) === null || _a === undefined ? undefined : _a.raise();
6034
+ (_a = this.select()) === null || _a === void 0 ? void 0 : _a.raise();
5892
6035
  }
5893
6036
  /**
5894
6037
  * Change the coordinates of this object to the given coordinates.
@@ -6005,7 +6148,7 @@ class DiagramModel {
6005
6148
  */
6006
6149
  clear() {
6007
6150
  var _a, _b;
6008
- (_a = this.canvas) === null || _a === undefined ? undefined : _a.cancelAllUserActions();
6151
+ (_a = this.canvas) === null || _a === void 0 ? void 0 : _a.cancelAllUserActions();
6009
6152
  this.id = undefined;
6010
6153
  this.name = '';
6011
6154
  this.description = undefined;
@@ -6020,7 +6163,7 @@ class DiagramModel {
6020
6163
  this.objects.clear();
6021
6164
  this.decorators.clear();
6022
6165
  this.valueSet.resetValues();
6023
- (_b = this.canvas) === null || _b === undefined ? undefined : _b.updateModelInView();
6166
+ (_b = this.canvas) === null || _b === void 0 ? void 0 : _b.updateModelInView();
6024
6167
  }
6025
6168
  }
6026
6169
 
@@ -6086,7 +6229,6 @@ const updateLook = selection => {
6086
6229
  selection.filter('.stretchable-image-look').select('image.bottom-right-image').attr('x', d => d.width - d.look.rightMargin).attr('y', d => d.height - d.look.bottomMargin).attr('width', d => d.look.rightMargin).attr('height', d => d.look.bottomMargin).attr('href', d => d.look.backgroundImageBottomRight);
6087
6230
  };
6088
6231
  const GRID_DEFAULTS = {
6089
- enabled: true,
6090
6232
  style: 'dots',
6091
6233
  color: 'rgba(0, 0, 0, 0.1)',
6092
6234
  snap: false,
@@ -6244,7 +6386,7 @@ class DiagramContextMenu {
6244
6386
  */
6245
6387
  close() {
6246
6388
  var _a;
6247
- (_a = this.contextMenuContainer) === null || _a === undefined ? undefined : _a.remove();
6389
+ (_a = this.contextMenuContainer) === null || _a === void 0 ? void 0 : _a.remove();
6248
6390
  this.contextMenuContainer = undefined;
6249
6391
  }
6250
6392
  }
@@ -6380,11 +6522,11 @@ class DagaExporter {
6380
6522
  for (const port of section.ports) {
6381
6523
  ports.push(Object.assign({
6382
6524
  id: port.id,
6383
- type: (_a = port.type) === null || _a === undefined ? undefined : _a.id,
6525
+ type: (_a = port.type) === null || _a === void 0 ? void 0 : _a.id,
6384
6526
  coords: roundPoint(port.coords),
6385
6527
  connectionPoint: roundPoint(port.connectionPoint),
6386
6528
  direction: port.direction,
6387
- label: ((_b = port.label) === null || _b === undefined ? undefined : _b.text) || ''
6529
+ label: ((_b = port.label) === null || _b === void 0 ? void 0 : _b.text) || ''
6388
6530
  }, includeCollabMeta ? {
6389
6531
  collabMeta: Object.assign({
6390
6532
  removed: port.removed,
@@ -6396,7 +6538,7 @@ class DagaExporter {
6396
6538
  sections.push(Object.assign({
6397
6539
  id: section.id,
6398
6540
  ports,
6399
- label: ((_c = section.label) === null || _c === undefined ? undefined : _c.text) || '',
6541
+ label: ((_c = section.label) === null || _c === void 0 ? void 0 : _c.text) || '',
6400
6542
  indexXInNode: section.indexXInNode,
6401
6543
  indexYInNode: section.indexYInNode,
6402
6544
  coords: roundPoint(section.coords),
@@ -6414,11 +6556,11 @@ class DagaExporter {
6414
6556
  for (const port of node.ports) {
6415
6557
  ports.push(Object.assign({
6416
6558
  id: port.id,
6417
- type: (_d = port.type) === null || _d === undefined ? undefined : _d.id,
6559
+ type: (_d = port.type) === null || _d === void 0 ? void 0 : _d.id,
6418
6560
  coords: roundPoint(port.coords),
6419
6561
  connectionPoint: roundPoint(port.connectionPoint),
6420
6562
  direction: port.direction,
6421
- label: ((_e = port.label) === null || _e === undefined ? undefined : _e.text) || ''
6563
+ label: ((_e = port.label) === null || _e === void 0 ? void 0 : _e.text) || ''
6422
6564
  }, includeCollabMeta ? {
6423
6565
  collabMeta: Object.assign({
6424
6566
  removed: port.removed,
@@ -6433,7 +6575,7 @@ class DagaExporter {
6433
6575
  children,
6434
6576
  sections,
6435
6577
  ports,
6436
- label: ((_f = node.label) === null || _f === undefined ? undefined : _f.text) || '',
6578
+ label: ((_f = node.label) === null || _f === void 0 ? void 0 : _f.text) || '',
6437
6579
  coords: roundPoint(node.coords),
6438
6580
  width: node.width,
6439
6581
  height: node.height,
@@ -6453,8 +6595,8 @@ class DagaExporter {
6453
6595
  return Object.assign({
6454
6596
  id: connection.id,
6455
6597
  type: connection.type.id,
6456
- start: ((_a = connection.start) === null || _a === undefined ? undefined : _a.id) || '',
6457
- end: ((_b = connection.end) === null || _b === undefined ? undefined : _b.id) || '',
6598
+ start: ((_a = connection.start) === null || _a === void 0 ? void 0 : _a.id) || '',
6599
+ end: ((_b = connection.end) === null || _b === void 0 ? void 0 : _b.id) || '',
6458
6600
  startLabel: connection.startLabel,
6459
6601
  middleLabel: connection.middleLabel,
6460
6602
  endLabel: connection.endLabel,
@@ -6669,19 +6811,25 @@ class DiagramUserSelection extends DiagramElementSet {
6669
6811
  * Opens the value set of a diagram model or a diagram element in the property editor.
6670
6812
  * @public
6671
6813
  * @param selection A diagram model or a diagram element with a value set.
6814
+ * @param makeUpdateValuesAction Whether the method should create an UpdateValuesAction.
6672
6815
  * @see PropertyEditor
6816
+ * @see UpdateValuesAction
6673
6817
  */
6674
- openInPropertyEditor(selection) {
6818
+ openInPropertyEditor(selection, makeUpdateValuesAction = true) {
6675
6819
  var _a;
6676
- this.makeUpdateValuesAction();
6677
- const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === undefined ? undefined : _a.propertyEditor;
6820
+ if (makeUpdateValuesAction) {
6821
+ this.makeUpdateValuesAction();
6822
+ }
6823
+ const propertyEditor = (_a = this.canvas.parentComponent) === null || _a === void 0 ? void 0 : _a.propertyEditor;
6678
6824
  if (propertyEditor === undefined) {
6679
6825
  return;
6680
6826
  }
6681
- const selectedValueSet = selection === null || selection === undefined ? undefined : selection.valueSet;
6827
+ const selectedValueSet = selection === null || selection === void 0 ? void 0 : selection.valueSet;
6682
6828
  if (selectedValueSet) {
6683
6829
  this.propertyEditorSelection = selection;
6684
- this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6830
+ if (makeUpdateValuesAction) {
6831
+ this.propertyEditorValues = structuredClone(selectedValueSet.getValues());
6832
+ }
6685
6833
  if (propertyEditor) {
6686
6834
  if (selection instanceof DiagramNode || selection instanceof DiagramConnection) {
6687
6835
  if (selection instanceof DiagramNode) {
@@ -6720,12 +6868,12 @@ class DiagramUserSelection extends DiagramElementSet {
6720
6868
  const previousSelectionId = this.propertyEditorSelection instanceof DiagramModel ? undefined : this.propertyEditorSelection.id;
6721
6869
  // check if there have been changes in the previously selected ValueSet,
6722
6870
  // and create an UpdateValuesAction if there have
6723
- if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === undefined ? undefined : _a.valueSet.getValues())) {
6871
+ if (equals(this.propertyEditorValues, (_a = this.propertyEditorSelection) === null || _a === void 0 ? void 0 : _a.valueSet.getValues())) {
6724
6872
  return;
6725
6873
  }
6726
6874
  const from = this.propertyEditorValues;
6727
- const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === undefined ? undefined : _b.valueSet.getValues());
6728
- const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === undefined ? undefined : _c.valueSet);
6875
+ const to = structuredClone((_b = this.propertyEditorSelection) === null || _b === void 0 ? void 0 : _b.valueSet.getValues());
6876
+ const [fromDiff, toDiff] = diffProperties(from, to, (_c = this.propertyEditorSelection) === null || _c === void 0 ? void 0 : _c.valueSet);
6729
6877
  const currentAction = new UpdateValuesAction(this.canvas, previousSelectionId, fromDiff, toDiff);
6730
6878
  currentAction.do();
6731
6879
  this.canvas.actionStack.add(currentAction);
@@ -6733,6 +6881,26 @@ class DiagramUserSelection extends DiagramElementSet {
6733
6881
  }
6734
6882
  }
6735
6883
 
6884
+ const degreesToRadians = theta => theta * Math.PI / 180;
6885
+ /**
6886
+ * 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.
6887
+ *
6888
+ * @param width The width of a bounding box.
6889
+ * @param height The height of a bounding box.
6890
+ * @param orientation A rotation in degrees.
6891
+ * @returns The size of the original rectangle.
6892
+ */
6893
+ const unrotate = (width, height, orientation) => {
6894
+ // TODO: this method fails under certain edge cases
6895
+ // like for example, when angle is 45 degrees so sin(theta) == cos(theta)
6896
+ const theta = degreesToRadians(orientation);
6897
+ const orientationSine = Math.sin(theta);
6898
+ const orientationCosine = Math.cos(theta);
6899
+ const oldWidth = (Math.abs(width * orientationCosine) - Math.abs(height * orientationSine)) / (orientationCosine * orientationCosine - orientationSine * orientationSine);
6900
+ const oldHeight = (Math.abs(width * orientationSine) - Math.abs(height * orientationCosine)) / (orientationSine * orientationSine - orientationCosine * orientationCosine);
6901
+ return [oldWidth, oldHeight];
6902
+ };
6903
+
6736
6904
  /**
6737
6905
  * Thickness of the invisible path around a connection used to make it easier to click on, in diagram units.
6738
6906
  * @private
@@ -6759,7 +6927,7 @@ class DiagramCanvas {
6759
6927
  var _a, _b;
6760
6928
  this._connectionType = value;
6761
6929
  // refresh the palette every time connectionType is set so that the palette keeps track of updates to the connectionType
6762
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
6930
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6763
6931
  }
6764
6932
  /**
6765
6933
  * Constructs a canvas object.
@@ -6785,18 +6953,18 @@ class DiagramCanvas {
6785
6953
  this.model = new DiagramModel(this, undefined, config.name || 'unnamed', '', config.type || '', config.properties || []);
6786
6954
  this.userSelection = new DiagramUserSelection(this);
6787
6955
  this.userHighlight = new DiagramUserHighlight(this);
6788
- this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === undefined ? undefined : _a.contextMenu);
6789
- this.backgroundColor = ((_b = config.canvas) === null || _b === undefined ? undefined : _b.backgroundColor) || '#FFFFFF';
6790
- this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c === undefined ? undefined : _c.grid) === null || _d === undefined ? undefined : _d.style) !== null && _e !== undefined ? _e : GRID_DEFAULTS.style;
6791
- this.gridSize = ((_g = (_f = config.canvas) === null || _f === undefined ? undefined : _f.grid) === null || _g === undefined ? undefined : _g.enabled) === false || ((_h = config.canvas) === null || _h === undefined ? undefined : _h.grid) === undefined ? 0 : Math.abs(((_k = (_j = config.canvas) === null || _j === undefined ? undefined : _j.grid) === null || _k === undefined ? undefined : _k.spacing) || GRID_DEFAULTS.spacing);
6792
- this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === undefined ? undefined : _l.grid) === null || _m === undefined ? undefined : _m.thickness) || GRID_DEFAULTS.thickness);
6793
- this.gridColor = ((_p = (_o = config.canvas) === null || _o === undefined ? undefined : _o.grid) === null || _p === undefined ? undefined : _p.color) || GRID_DEFAULTS.color;
6794
- this.snapToGrid = ((_r = (_q = config.canvas) === null || _q === undefined ? undefined : _q.grid) === null || _r === undefined ? undefined : _r.enabled) === false || ((_s = config.canvas) === null || _s === undefined ? undefined : _s.grid) === undefined ? false : ((_u = (_t = config.canvas) === null || _t === undefined ? undefined : _t.grid) === null || _u === undefined ? undefined : _u.snap) || GRID_DEFAULTS.snap;
6795
- this.zoomFactor = ((_v = config.canvas) === null || _v === undefined ? undefined : _v.zoomFactor) || 2;
6796
- this.panRate = ((_w = config.canvas) === null || _w === undefined ? undefined : _w.panRate) || 100;
6956
+ this.contextMenu = new DiagramContextMenu(this, (_a = config.canvas) === null || _a === void 0 ? void 0 : _a.contextMenu);
6957
+ this.backgroundColor = ((_b = config.canvas) === null || _b === void 0 ? void 0 : _b.backgroundColor) || '#FFFFFF';
6958
+ this.gridStyle = (_e = (_d = (_c = config.canvas) === null || _c === void 0 ? void 0 : _c.grid) === null || _d === void 0 ? void 0 : _d.style) !== null && _e !== void 0 ? _e : GRID_DEFAULTS.style;
6959
+ this.gridSize = ((_g = (_f = config.canvas) === null || _f === void 0 ? void 0 : _f.grid) === null || _g === void 0 ? void 0 : _g.enabled) === false || ((_h = config.canvas) === null || _h === void 0 ? void 0 : _h.grid) === undefined ? 0 : Math.abs(((_k = (_j = config.canvas) === null || _j === void 0 ? void 0 : _j.grid) === null || _k === void 0 ? void 0 : _k.spacing) || GRID_DEFAULTS.spacing);
6960
+ this.gridThickness = Math.abs(((_m = (_l = config.canvas) === null || _l === void 0 ? void 0 : _l.grid) === null || _m === void 0 ? void 0 : _m.thickness) || GRID_DEFAULTS.thickness);
6961
+ this.gridColor = ((_p = (_o = config.canvas) === null || _o === void 0 ? void 0 : _o.grid) === null || _p === void 0 ? void 0 : _p.color) || GRID_DEFAULTS.color;
6962
+ this.snapToGrid = ((_r = (_q = config.canvas) === null || _q === void 0 ? void 0 : _q.grid) === null || _r === void 0 ? void 0 : _r.enabled) === false || ((_s = config.canvas) === null || _s === void 0 ? void 0 : _s.grid) === undefined ? false : ((_u = (_t = config.canvas) === null || _t === void 0 ? void 0 : _t.grid) === null || _u === void 0 ? void 0 : _u.snap) || GRID_DEFAULTS.snap;
6963
+ this.zoomFactor = ((_v = config.canvas) === null || _v === void 0 ? void 0 : _v.zoomFactor) || 2;
6964
+ this.panRate = ((_w = config.canvas) === null || _w === void 0 ? void 0 : _w.panRate) || 100;
6797
6965
  this.inferConnectionType = config.inferConnectionType || false;
6798
6966
  this.multipleSelectionOn = false;
6799
- this.priorityThresholds = ((_x = config.canvas) === null || _x === undefined ? undefined : _x.priorityThresholds) || [];
6967
+ this.priorityThresholds = ((_x = config.canvas) === null || _x === void 0 ? void 0 : _x.priorityThresholds) || [];
6800
6968
  this.priorityThreshold = this.priorityThresholds ? this.priorityThresholds[0] : undefined;
6801
6969
  this.layoutFormat = config.layoutFormat;
6802
6970
  this.userActions = config.userActions || {};
@@ -6847,7 +7015,7 @@ class DiagramCanvas {
6847
7015
  for (const node of this.model.nodes) {
6848
7016
  this.fitNodeInView(node.id);
6849
7017
  }
6850
- (_b = (_a = this.parentComponent) === null || _a === undefined ? undefined : _a.palette) === null || _b === undefined ? undefined : _b.refreshPalette();
7018
+ (_b = (_a = this.parentComponent) === null || _a === void 0 ? void 0 : _a.palette) === null || _b === void 0 ? void 0 : _b.refreshPalette();
6851
7019
  }
6852
7020
  // View methods
6853
7021
  initView(appendTo) {
@@ -6861,7 +7029,7 @@ class DiagramCanvas {
6861
7029
  var _a;
6862
7030
  // focus on the diagram when clicking so that we can focus on the diagram
6863
7031
  // keyboard events only work if we're focusing on the diagram
6864
- (_a = d3.select(this.diagramRoot).node()) === null || _a === undefined ? undefined : _a.focus();
7032
+ (_a = d3.select(this.diagramRoot).node()) === null || _a === void 0 ? void 0 : _a.focus();
6865
7033
  }).on(Events.ContextMenu, event => {
6866
7034
  if (this.dragging) {
6867
7035
  event.preventDefault();
@@ -7001,6 +7169,32 @@ class DiagramCanvas {
7001
7169
  }
7002
7170
  });
7003
7171
  const canvasView = this.selectSVGElement().append('g').attr('class', 'daga-canvas-view').attr('width', `100%`).attr('height', `100%`);
7172
+ canvasView.call(this.zoomBehavior = d3.zoom().on(ZoomEvents.Zoom, event => {
7173
+ if (event.sourceEvent) {
7174
+ // zoom event was triggered by user
7175
+ if (!this.canUserPerformAction(DiagramActions.Zoom)) {
7176
+ setCursorStyle(CursorStyle.NotAllowed);
7177
+ return;
7178
+ }
7179
+ if (event.sourceEvent.type === Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7180
+ if (event.sourceEvent.wheelDelta > 0) {
7181
+ setCursorStyle(CursorStyle.ZoomIn);
7182
+ }
7183
+ if (event.sourceEvent.wheelDelta < 0) {
7184
+ setCursorStyle(CursorStyle.ZoomOut);
7185
+ }
7186
+ } else if (event.sourceEvent.type === Events.MouseMove) {
7187
+ setCursorStyle(CursorStyle.AllScroll);
7188
+ }
7189
+ }
7190
+ this.zoomTransform = event.transform;
7191
+ const transformAttribute = event.transform.toString();
7192
+ this.selectCanvasElements().attr('transform', transformAttribute);
7193
+ d3.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7194
+ this.contextMenu.close();
7195
+ }).on(ZoomEvents.End, () => {
7196
+ setCursorStyle();
7197
+ }));
7004
7198
  canvasView.append('rect').attr('x', 0).attr('y', 0).attr('width', `100%`).attr('height', `100%`).attr('fill', this.backgroundColor).attr('stroke-width', '0').on(Events.MouseMove, event => {
7005
7199
  if (this.unfinishedConnection !== undefined) {
7006
7200
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
@@ -7031,60 +7225,35 @@ class DiagramCanvas {
7031
7225
  this.continueMultipleSelection(event);
7032
7226
  }).on(DragEvents.End, event => {
7033
7227
  this.finishMultipleSelection(event);
7034
- })).call(this.zoomBehavior = d3.zoom().on(ZoomEvents.Zoom, event => {
7035
- if (event.sourceEvent) {
7036
- // zoom event was triggered by user
7037
- if (!this.canUserPerformAction(DiagramActions.Zoom)) {
7038
- setCursorStyle(CursorStyle.NotAllowed);
7039
- return;
7040
- }
7041
- if (event.sourceEvent.type === Events.Wheel && event.sourceEvent.wheelDelta !== undefined) {
7042
- if (event.sourceEvent.wheelDelta > 0) {
7043
- setCursorStyle(CursorStyle.ZoomIn);
7044
- }
7045
- if (event.sourceEvent.wheelDelta < 0) {
7046
- setCursorStyle(CursorStyle.ZoomOut);
7047
- }
7048
- } else if (event.sourceEvent.type === Events.MouseMove) {
7049
- setCursorStyle(CursorStyle.AllScroll);
7050
- }
7051
- }
7052
- this.zoomTransform = event.transform;
7053
- const transformAttribute = event.transform.toString();
7054
- this.selectCanvasElements().attr('transform', transformAttribute);
7055
- d3.select(`#${this.backgroundPatternId}`).attr('patternTransform', transformAttribute);
7056
- this.contextMenu.close();
7057
- }).on(ZoomEvents.End, () => {
7058
- setCursorStyle();
7059
7228
  }));
7060
7229
  initializeGrid(this, canvasView, this.backgroundPatternId);
7061
7230
  canvasView.append('g').attr('class', 'daga-canvas-elements');
7062
7231
  }
7063
7232
  zoomBy(factor) {
7064
7233
  if (!isNaN(factor)) {
7065
- this.zoomBehavior.scaleBy(this.selectCanvasView().select('rect'), factor);
7234
+ this.zoomBehavior.scaleBy(this.selectCanvasView(), factor);
7066
7235
  }
7067
7236
  }
7068
7237
  zoomTo(level) {
7069
7238
  if (!isNaN(level)) {
7070
- this.zoomBehavior.scaleTo(this.selectCanvasView().select('rect'), level);
7239
+ this.zoomBehavior.scaleTo(this.selectCanvasView(), level);
7071
7240
  }
7072
7241
  }
7073
7242
  translateBy(x, y) {
7074
7243
  if (!isNaN(x) && !isNaN(y)) {
7075
- this.zoomBehavior.translateBy(this.selectCanvasView().select('rect'), x, y);
7244
+ this.zoomBehavior.translateBy(this.selectCanvasView(), x, y);
7076
7245
  }
7077
7246
  }
7078
7247
  translateTo(x, y) {
7079
7248
  if (!isNaN(x) && !isNaN(y)) {
7080
- this.zoomBehavior.translateTo(this.selectCanvasView().select('rect'), x, y);
7249
+ this.zoomBehavior.translateTo(this.selectCanvasView(), x, y);
7081
7250
  }
7082
7251
  }
7083
7252
  center() {
7084
7253
  var _a;
7085
7254
  // if there are no nodes, we have nothing to do here
7086
7255
  if (this.model.nodes.length > 0) {
7087
- const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === undefined ? undefined : _a.getBBox();
7256
+ const canvasViewBoundingBox = (_a = this.selectCanvasView().select('rect').node()) === null || _a === void 0 ? void 0 : _a.getBBox();
7088
7257
  const nonRemovedNodes = this.model.nodes.all();
7089
7258
  const minimumX = Math.min(...nonRemovedNodes.map(n => n.coords[0]));
7090
7259
  const maximumX = Math.max(...nonRemovedNodes.map(n => n.coords[0] + n.width));
@@ -7116,8 +7285,8 @@ class DiagramCanvas {
7116
7285
  }
7117
7286
  getCoordinatesOnScreen() {
7118
7287
  var _a;
7119
- const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
7120
- const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === undefined ? undefined : rootBoundingClientRect.height) || 0];
7288
+ const rootBoundingClientRect = (_a = this.selectSVGElement().node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
7289
+ const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
7121
7290
  return [[-this.zoomTransform.x / this.zoomTransform.k, -this.zoomTransform.y / this.zoomTransform.k], [(rootDimensions[0] - this.zoomTransform.x) / this.zoomTransform.k, (rootDimensions[1] - this.zoomTransform.y) / this.zoomTransform.k]];
7122
7291
  }
7123
7292
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -7371,8 +7540,8 @@ class DiagramCanvas {
7371
7540
  let updateSelection = this.selectCanvasElements().selectAll('g.diagram-section').data(this.model.sections.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
7372
7541
  const exitSelection = updateSelection.exit();
7373
7542
  const enterSelection = updateSelection.enter().append('g').attr('id', d => d.id).attr('class', d => {
7374
- var _a, _b, _c, _d, _e;
7375
- return `diagram-section${((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) ? ' resizable-x' : ''}${((_d = (_c = d.node) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.resizableY) ? ' resizable-y' : ''} ${(_e = d.look) === null || _e === undefined ? undefined : _e.lookType}`;
7543
+ var _a;
7544
+ return `diagram-section${d.getResizableX() ? ' resizable-x' : ''}${d.getResizableY() ? ' resizable-y' : ''} ${(_a = d.look) === null || _a === void 0 ? void 0 : _a.lookType}`;
7376
7545
  });
7377
7546
  if (ids && ids.length > 0) {
7378
7547
  updateSelection = updateSelection.filter(d => ids.includes(d.id));
@@ -7421,7 +7590,7 @@ class DiagramCanvas {
7421
7590
  if (this.multipleSelectionOn || this.secondaryButton) {
7422
7591
  this.startMultipleSelection(event);
7423
7592
  } else {
7424
- const node = d === null || d === undefined ? undefined : d.node;
7593
+ const node = d === null || d === void 0 ? void 0 : d.node;
7425
7594
  if (node) {
7426
7595
  this.startMovingNode(event, node);
7427
7596
  } else {
@@ -7432,7 +7601,7 @@ class DiagramCanvas {
7432
7601
  if (this.multipleSelectionOn || this.secondaryButton) {
7433
7602
  this.continueMultipleSelection(event);
7434
7603
  } else {
7435
- const node = d === null || d === undefined ? undefined : d.node;
7604
+ const node = d === null || d === void 0 ? void 0 : d.node;
7436
7605
  if (node) {
7437
7606
  this.continueMovingNode(event, node);
7438
7607
  } else {
@@ -7443,7 +7612,7 @@ class DiagramCanvas {
7443
7612
  if (this.multipleSelectionOn || this.secondaryButton) {
7444
7613
  this.finishMultipleSelection(event);
7445
7614
  } else {
7446
- const node = d === null || d === undefined ? undefined : d.node;
7615
+ const node = d === null || d === void 0 ? void 0 : d.node;
7447
7616
  if (node) {
7448
7617
  this.finishMovingNode(event, node);
7449
7618
  } else {
@@ -7454,32 +7623,27 @@ class DiagramCanvas {
7454
7623
  }));
7455
7624
  initializeLook(enterSelection);
7456
7625
  enterSelection.filter('.resizable-x').append('line').attr('class', 'left-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7457
- var _a, _b;
7458
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7626
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7459
7627
  setCursorStyle(CursorStyle.EWResize);
7460
7628
  }
7461
7629
  }).on(Events.MouseOut, (_event, d) => {
7462
- var _a, _b;
7463
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7630
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7464
7631
  setCursorStyle();
7465
7632
  }
7466
7633
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7467
- var _a, _b;
7468
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7634
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7469
7635
  setCursorStyle(CursorStyle.EWResize);
7470
7636
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7471
7637
  } else {
7472
7638
  setCursorStyle(CursorStyle.NotAllowed);
7473
7639
  }
7474
7640
  }).on(DragEvents.Drag, (event, d) => {
7475
- var _a, _b;
7476
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7641
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7477
7642
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7478
7643
  d.node.stretchSections(Side.Left, d.coords[0] - pointerCoords[0], d.indexXInNode, d.indexYInNode);
7479
7644
  }
7480
7645
  }).on(DragEvents.End, (event, d) => {
7481
- var _a, _b;
7482
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7646
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
7483
7647
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7484
7648
  if (this.snapToGrid) {
7485
7649
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7493,32 +7657,27 @@ class DiagramCanvas {
7493
7657
  setCursorStyle();
7494
7658
  }));
7495
7659
  enterSelection.filter('.resizable-y').append('line').attr('class', 'top-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7496
- var _a, _b;
7497
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7660
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7498
7661
  setCursorStyle(CursorStyle.NSResize);
7499
7662
  }
7500
7663
  }).on(Events.MouseOut, (_event, d) => {
7501
- var _a, _b;
7502
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7664
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7503
7665
  setCursorStyle();
7504
7666
  }
7505
7667
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7506
- var _a, _b;
7507
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7668
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7508
7669
  setCursorStyle(CursorStyle.NSResize);
7509
7670
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7510
7671
  } else {
7511
7672
  setCursorStyle(CursorStyle.NotAllowed);
7512
7673
  }
7513
7674
  }).on(DragEvents.Drag, (event, d) => {
7514
- var _a, _b;
7515
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7675
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7516
7676
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7517
7677
  d.node.stretchSections(Side.Top, d.coords[1] - pointerCoords[1], d.indexXInNode, d.indexYInNode);
7518
7678
  }
7519
7679
  }).on(DragEvents.End, (event, d) => {
7520
- var _a, _b;
7521
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7680
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
7522
7681
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7523
7682
  if (this.snapToGrid) {
7524
7683
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7532,32 +7691,27 @@ class DiagramCanvas {
7532
7691
  setCursorStyle();
7533
7692
  }));
7534
7693
  enterSelection.filter('.resizable-x').append('line').attr('class', 'right-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7535
- var _a, _b;
7536
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7694
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7537
7695
  setCursorStyle(CursorStyle.EWResize);
7538
7696
  }
7539
7697
  }).on(Events.MouseOut, (_event, d) => {
7540
- var _a, _b;
7541
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7698
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed) {
7542
7699
  setCursorStyle();
7543
7700
  }
7544
7701
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7545
- var _a, _b;
7546
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7702
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7547
7703
  setCursorStyle(CursorStyle.EWResize);
7548
7704
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7549
7705
  } else {
7550
7706
  setCursorStyle(CursorStyle.NotAllowed);
7551
7707
  }
7552
7708
  }).on(DragEvents.Drag, (event, d) => {
7553
- var _a, _b;
7554
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed) {
7709
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && d.node) {
7555
7710
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7556
7711
  d.node.stretchSections(Side.Right, pointerCoords[0] - (d.coords[0] + d.width), d.indexXInNode, d.indexYInNode);
7557
7712
  }
7558
7713
  }).on(DragEvents.End, (event, d) => {
7559
- var _a, _b;
7560
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableX) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7714
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableX() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
7561
7715
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7562
7716
  if (this.snapToGrid) {
7563
7717
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7571,32 +7725,27 @@ class DiagramCanvas {
7571
7725
  setCursorStyle();
7572
7726
  }));
7573
7727
  enterSelection.filter('.resizable-y').append('line').attr('class', 'bottom-resizer').attr('stroke', 'transparent').attr('stroke-width', `${RESIZER_THICKNESS}px`).on(Events.MouseOver, (_event, d) => {
7574
- var _a, _b;
7575
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7728
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7576
7729
  setCursorStyle(CursorStyle.NSResize);
7577
7730
  }
7578
7731
  }).on(Events.MouseOut, (_event, d) => {
7579
- var _a, _b;
7580
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7732
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed) {
7581
7733
  setCursorStyle();
7582
7734
  }
7583
7735
  }).call(d3.drag().on(DragEvents.Start, (_event, d) => {
7584
- var _a, _b;
7585
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7736
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7586
7737
  setCursorStyle(CursorStyle.NSResize);
7587
7738
  this.currentAction = new SetGeometryAction(this, DiagramActions.StretchSection, d.node.id, d.node.getGeometry(), d.node.getGeometry());
7588
7739
  } else {
7589
7740
  setCursorStyle(CursorStyle.NotAllowed);
7590
7741
  }
7591
7742
  }).on(DragEvents.Drag, (event, d) => {
7592
- var _a, _b;
7593
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed) {
7743
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && d.node) {
7594
7744
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7595
7745
  d.node.stretchSections(Side.Bottom, pointerCoords[1] - (d.coords[1] + d.height), d.indexXInNode, d.indexYInNode);
7596
7746
  }
7597
7747
  }).on(DragEvents.End, (event, d) => {
7598
- var _a, _b;
7599
- if (this.canUserPerformAction(DiagramActions.StretchSection) && ((_b = (_a = d.node) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.resizableY) && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection) {
7748
+ if (this.canUserPerformAction(DiagramActions.StretchSection) && d.getResizableY() && !d.removed && this.currentAction instanceof SetGeometryAction && this.currentAction.intent === DiagramActions.StretchSection && d.node) {
7600
7749
  let pointerCoords = this.getPointerLocationRelativeToCanvas(event);
7601
7750
  if (this.snapToGrid) {
7602
7751
  pointerCoords = this.getClosestGridPoint(pointerCoords);
@@ -7635,13 +7784,13 @@ class DiagramCanvas {
7635
7784
  if (this.unfinishedConnection) {
7636
7785
  const canConnectionFinishAtThisPort =
7637
7786
  // can start at the starting port
7638
- this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === undefined ? undefined : _a.getNode()) === null || _b === undefined ? undefined : _b.type) === null || _c === undefined ? undefined : _c.id) || '') && ((_d = this.unfinishedConnection.start) === null || _d === undefined ? undefined : _d.allowsOutgoing) &&
7787
+ this.unfinishedConnection.type.canStartFromType(((_c = (_b = (_a = this.unfinishedConnection.start) === null || _a === void 0 ? void 0 : _a.getNode()) === null || _b === void 0 ? void 0 : _b.type) === null || _c === void 0 ? void 0 : _c.id) || '') && ((_d = this.unfinishedConnection.start) === null || _d === void 0 ? void 0 : _d.allowsOutgoing) &&
7639
7788
  // can end at the ending port
7640
- this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === undefined ? undefined : _e.type) === null || _f === undefined ? undefined : _f.id) || '') && d.allowsIncoming ||
7789
+ this.unfinishedConnection.type.canFinishOnType(((_f = (_e = d.getNode()) === null || _e === void 0 ? void 0 : _e.type) === null || _f === void 0 ? void 0 : _f.id) || '') && d.allowsIncoming ||
7641
7790
  // can start at the ending port
7642
- this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && d.allowsOutgoing &&
7791
+ this.unfinishedConnection.type.canStartFromType(((_h = (_g = d.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && d.allowsOutgoing &&
7643
7792
  // can end at the starting port
7644
- this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j === undefined ? undefined : _j.getNode()) === null || _k === undefined ? undefined : _k.type) === null || _l === undefined ? undefined : _l.id) || '') && ((_m = this.unfinishedConnection.start) === null || _m === undefined ? undefined : _m.allowsIncoming);
7793
+ this.unfinishedConnection.type.canFinishOnType(((_l = (_k = (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.getNode()) === null || _k === void 0 ? void 0 : _k.type) === null || _l === void 0 ? void 0 : _l.id) || '') && ((_m = this.unfinishedConnection.start) === null || _m === void 0 ? void 0 : _m.allowsIncoming);
7645
7794
  if (!canConnectionFinishAtThisPort) {
7646
7795
  setCursorStyle(CursorStyle.NoDrop);
7647
7796
  }
@@ -7706,8 +7855,8 @@ class DiagramCanvas {
7706
7855
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
7707
7856
  if (this.unfinishedConnection !== undefined) {
7708
7857
  const endCoords = [event.x, event.y];
7709
- (_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === undefined ? undefined : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === undefined ? undefined : _c.width));
7710
- const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === undefined ? undefined : _d.node();
7858
+ (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.attr('d', getConnectionPath(this.unfinishedConnection.look.shape, this.unfinishedConnection.startCoords, endCoords, this.unfinishedConnection.startDirection, this.unfinishedConnection.endDirection, this.unfinishedConnection.look.thickness, (_b = this.unfinishedConnection.startMarkerLook) === null || _b === void 0 ? void 0 : _b.width, (_c = this.unfinishedConnection.endMarkerLook) === null || _c === void 0 ? void 0 : _c.width));
7859
+ const unfinishedConnectionGhostNode = (_d = this.unfinishedConnectionTracer) === null || _d === void 0 ? void 0 : _d.node();
7711
7860
  if (unfinishedConnectionGhostNode) {
7712
7861
  let margin = 2;
7713
7862
  const unfinishedConnectionTotalLength = unfinishedConnectionGhostNode.getTotalLength();
@@ -7748,7 +7897,7 @@ class DiagramCanvas {
7748
7897
  this.finishMultipleSelection(event);
7749
7898
  } else {
7750
7899
  if (this.canUserPerformAction(DiagramActions.AddConnection) && !d.removed) {
7751
- (_a = this.unfinishedConnectionTracer) === null || _a === undefined ? undefined : _a.remove();
7900
+ (_a = this.unfinishedConnectionTracer) === null || _a === void 0 ? void 0 : _a.remove();
7752
7901
  const userHighlight = this.userHighlight.getFocus();
7753
7902
  if (userHighlight instanceof DiagramPort) {
7754
7903
  this.finishConnection(userHighlight);
@@ -7854,11 +8003,11 @@ class DiagramCanvas {
7854
8003
  enterSelection.select('g.diagram-connection-end-label').append('text').style('user-select', 'none');
7855
8004
  mergeSelection.attr('opacity', d => d.removed ? 0.5 : 1).select('path.diagram-connection-path').attr('d', d => {
7856
8005
  var _a, _b;
7857
- return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
8006
+ return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
7858
8007
  }).attr('marker-start', d => `url(#${d.id}-start-marker)`).attr('marker-end', d => `url(#${d.id}-end-marker)`).attr('stroke', d => d.look.color).attr('stroke-width', d => `${d.look.thickness}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
7859
8008
  mergeSelection.select('path.diagram-connection-path-box').attr('d', d => {
7860
8009
  var _a, _b;
7861
- return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === undefined ? undefined : _a.width, (_b = d.endMarkerLook) === null || _b === undefined ? undefined : _b.width);
8010
+ return getConnectionPath(d.look.shape, d.startCoords, d.endCoords, d.startDirection, d.endDirection, d.look.thickness, (_a = d.startMarkerLook) === null || _a === void 0 ? void 0 : _a.width, (_b = d.endMarkerLook) === null || _b === void 0 ? void 0 : _b.width);
7862
8011
  }).attr('stroke', 'transparent')
7863
8012
  // allow generating pointer events even when it is transparent
7864
8013
  .attr('pointer-events', 'stroke').attr('stroke-width', d => `${d.look.thickness + CONNECTION_PATH_BOX_THICKNESS}px`).attr('stroke-dasharray', d => lineStyleDasharray(d.look.style, d.look.thickness)).attr('fill', 'none');
@@ -7913,8 +8062,12 @@ class DiagramCanvas {
7913
8062
  this.diagramEvent$.next(diagramEvent);
7914
8063
  if (!diagramEvent.defaultPrevented && this.canUserPerformAction(DiagramActions.EditField) && d.editable && !d.removed) {
7915
8064
  this.currentAction = new EditFieldAction(this, d.id, d.text, '');
7916
- this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, text => {
7917
- d.text = text;
8065
+ this.createInputField(d.text, d.coords, d.width, d.height, d.fontSize, d.fontFamily || DIAGRAM_FIELD_DEFAULTS.fontFamily, d.orientation, _text => {
8066
+ /*
8067
+ Empty for now
8068
+ We should create a better function to stretch the root element as the text expands
8069
+ Bear in mind that DiagramNode.setGeometry() calls DiagramNode.raise(), which breaks the input field
8070
+ */
7918
8071
  }, text => {
7919
8072
  d.text = text;
7920
8073
  if (this.currentAction instanceof EditFieldAction) {
@@ -7978,7 +8131,7 @@ class DiagramCanvas {
7978
8131
  }
7979
8132
  this.secondaryButton = false;
7980
8133
  })).append('xhtml:div').style('width', '100%').style('height', '100%').style('display', 'flex').append('xhtml:p').style('box-sizing', 'border-box').style('outline', 0).style('margin', 0).style('border', 0).style('padding', 0).style('user-select', 'none').style('font-kerning', 'none').style('white-space', 'nowrap');
7981
- mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === VerticalAlign.Center ? 'center' : d.verticalAlign === VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : '100%').style('max-height', d => d.fit ? 'default' : '100%').style('overflow', d => d.fit ? 'default' : 'hidden').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
8134
+ mergeSelection.attr('x', 0).attr('y', 0).attr('width', d => `${d.width}px`).attr('height', d => `${d.height}px`).attr('transform', d => `translate(${d.coords[0]},${d.coords[1]})`).attr('opacity', d => d.removed ? 0.5 : 1).select('div').style('justify-content', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'flex-end' : 'flex-start').style('align-items', d => d.verticalAlign === VerticalAlign.Center ? 'center' : d.verticalAlign === VerticalAlign.Bottom ? 'end' : 'start').select('p').style('max-width', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[0]}px`).style('max-height', d => d.fit ? 'default' : `${unrotate(d.width, d.height, d.orientation)[1]}px`).style('overflow', d => d.fit ? 'default' : 'clip').style('text-overflow', d => d.fit ? 'default' : 'ellipsis').style('text-align', d => d.horizontalAlign === HorizontalAlign.Center ? 'center' : d.horizontalAlign === HorizontalAlign.Right ? 'end' : 'start').style('transform', d => `rotate(${d.orientation}deg)`).style('font-size', d => `${d.fontSize}px`).style('font-family', d => d.fontFamily || "'Wonder Unit Sans', sans-serif").style('font-weight', d => d.highlighted ? 600 : 400).style('color', d => d.selected ? d.selectedColor || '#000000' : d.color || '#000000').html(d => d.text.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br/>'));
7982
8135
  }
7983
8136
  updateObjectsInView(...ids) {
7984
8137
  let updateSelection = this.selectCanvasElements().selectAll('foreignObject.diagram-object').data(this.model.objects.filter(e => this.priorityThreshold !== undefined ? e.getPriority() >= this.priorityThreshold : true), d => d.id);
@@ -8136,7 +8289,7 @@ class DiagramCanvas {
8136
8289
  const pathLength = pathNode.getTotalLength();
8137
8290
  // bind start labels
8138
8291
  connectionSelection.select('g.diagram-connection-start-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.startLabel);
8139
- const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === undefined ? undefined : _a.getBoundingClientRect();
8292
+ const startLabelBoundingRect = (_a = connectionSelection.select('g.diagram-connection-start-label text').node()) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
8140
8293
  if (startLabelBoundingRect) {
8141
8294
  // don't create space for the label if the label is empty
8142
8295
  const boundingWidth = !connection.startLabel ? 0 : startLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8147,7 +8300,7 @@ class DiagramCanvas {
8147
8300
  }
8148
8301
  // bind middle labels
8149
8302
  connectionSelection.select('g.diagram-connection-middle-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.middleLabel);
8150
- const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === undefined ? undefined : _b.getBoundingClientRect();
8303
+ const middleLabelBoundingRect = (_b = connectionSelection.select('g.diagram-connection-middle-label text').node()) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
8151
8304
  if (middleLabelBoundingRect) {
8152
8305
  // don't create space for the label if the label is empty
8153
8306
  const boundingWidth = !connection.middleLabel ? 0 : middleLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8158,7 +8311,7 @@ class DiagramCanvas {
8158
8311
  }
8159
8312
  // bind end labels
8160
8313
  connectionSelection.select('g.diagram-connection-end-label text').attr('x', 0).attr('y', labelConfiguration.fontSize / 3).attr('text-anchor', 'middle').attr('font-family', labelConfiguration.fontFamily).attr('font-size', labelConfiguration.fontSize).attr('fill', connection.selected ? labelConfiguration.selectedColor : labelConfiguration.color).style('font-kerning', 'none').text(connection.endLabel);
8161
- const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === undefined ? undefined : _c.getBoundingClientRect();
8314
+ const endLabelBoundingRect = (_c = connectionSelection.select('g.diagram-connection-end-label text').node()) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
8162
8315
  if (endLabelBoundingRect) {
8163
8316
  // don't create space for the label if the label is empty
8164
8317
  const boundingWidth = !connection.endLabel ? 0 : endLabelBoundingRect.width / this.zoomTransform.k + getLeftPadding$1(labelConfiguration) + getRightPadding$1(labelConfiguration);
@@ -8192,13 +8345,13 @@ class DiagramCanvas {
8192
8345
  }
8193
8346
  if (field.rootElement instanceof DiagramNode || field.rootElement instanceof DiagramSection) {
8194
8347
  const fieldDimensions = this.minimumSizeOfField(field);
8195
- const stretchX = fieldDimensions[0] + getLeftMargin((_a = field.rootElement.type) === null || _a === undefined ? undefined : _a.label) + getRightMargin((_b = field.rootElement.type) === null || _b === undefined ? undefined : _b.label) - field.rootElement.width;
8196
- const stretchY = fieldDimensions[1] + getTopMargin((_c = field.rootElement.type) === null || _c === undefined ? undefined : _c.label) + getBottomMargin((_d = field.rootElement.type) === null || _d === undefined ? undefined : _d.label) - field.rootElement.height;
8348
+ const stretchX = fieldDimensions[0] + getLeftMargin((_a = field.rootElement.type) === null || _a === void 0 ? void 0 : _a.label) + getRightMargin((_b = field.rootElement.type) === null || _b === void 0 ? void 0 : _b.label) - field.rootElement.width;
8349
+ const stretchY = fieldDimensions[1] + getTopMargin((_c = field.rootElement.type) === null || _c === void 0 ? void 0 : _c.label) + getBottomMargin((_d = field.rootElement.type) === null || _d === void 0 ? void 0 : _d.label) - field.rootElement.height;
8197
8350
  return stretchX <= 0 && stretchY <= 0;
8198
8351
  }
8199
8352
  return true;
8200
8353
  }
8201
- fitFieldRootInView(id, shrink) {
8354
+ fitFieldRootInView(id, shrink = true) {
8202
8355
  var _a, _b, _c;
8203
8356
  const field = this.model.fields.get(id);
8204
8357
  if (!field) {
@@ -8230,7 +8383,7 @@ class DiagramCanvas {
8230
8383
  const fieldDimensions = this.minimumSizeOfField(field);
8231
8384
  let minimumFieldWidth = fieldDimensions[0];
8232
8385
  let minimumFieldHeight = fieldDimensions[1];
8233
- for (const section of ((_a = field.rootElement.node) === null || _a === undefined ? undefined : _a.sections) || []) {
8386
+ for (const section of ((_a = field.rootElement.node) === null || _a === void 0 ? void 0 : _a.sections) || []) {
8234
8387
  if (section.label) {
8235
8388
  if (section.indexXInNode === field.rootElement.indexXInNode && section.indexYInNode !== field.rootElement.indexYInNode) {
8236
8389
  minimumFieldWidth = Math.max(minimumFieldWidth, this.minimumSizeOfField(section.label)[0]);
@@ -8246,8 +8399,8 @@ class DiagramCanvas {
8246
8399
  fieldDimensions[1] = minimumFieldHeight;
8247
8400
  }
8248
8401
  const type = field.rootElement.type;
8249
- let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === undefined ? undefined : type.label) + getRightMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.width;
8250
- let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === undefined ? undefined : type.label) + getBottomMargin(type === null || type === undefined ? undefined : type.label) - field.rootElement.height;
8402
+ let stretchX = fieldDimensions[0] + getLeftMargin(type === null || type === void 0 ? void 0 : type.label) + getRightMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.width;
8403
+ let stretchY = fieldDimensions[1] + getTopMargin(type === null || type === void 0 ? void 0 : type.label) + getBottomMargin(type === null || type === void 0 ? void 0 : type.label) - field.rootElement.height;
8251
8404
  if (this.snapToGrid) {
8252
8405
  stretchX = Math.ceil(stretchX / this.gridSize) * this.gridSize;
8253
8406
  stretchY = Math.ceil(stretchY / this.gridSize) * this.gridSize;
@@ -8259,15 +8412,15 @@ class DiagramCanvas {
8259
8412
  if (field.rootElement.height + stretchY < (field.rootElement.getMinHeight() || 0)) {
8260
8413
  stretchY = (field.rootElement.getMinHeight() || 0) - field.rootElement.height;
8261
8414
  }
8262
- if (shrink !== false || stretchX > 0) {
8263
- (_b = field.rootElement.node) === null || _b === undefined ? undefined : _b.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8415
+ if (shrink || stretchX > 0) {
8416
+ (_b = field.rootElement.node) === null || _b === void 0 ? void 0 : _b.stretchSections(Side.Right, stretchX, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8264
8417
  }
8265
- if (shrink !== false || stretchY > 0) {
8266
- (_c = field.rootElement.node) === null || _c === undefined ? undefined : _c.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8418
+ if (shrink || stretchY > 0) {
8419
+ (_c = field.rootElement.node) === null || _c === void 0 ? void 0 : _c.stretchSections(Side.Bottom, stretchY, field.rootElement.indexXInNode, field.rootElement.indexYInNode);
8267
8420
  }
8268
8421
  }
8269
8422
  }
8270
- fitNodeInView(id) {
8423
+ fitNodeInView(id, shrink = true) {
8271
8424
  var _a, _b;
8272
8425
  const node = this.model.nodes.get(id);
8273
8426
  if (!node) {
@@ -8286,10 +8439,14 @@ class DiagramCanvas {
8286
8439
  }
8287
8440
  }
8288
8441
  // add the margin that goes between the rightmost and bottommost points of the sections and the edge of the node
8289
- newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === undefined ? undefined : _a.margin) || 0;
8290
- newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === undefined ? undefined : _b.margin) || 0;
8291
- node.stretch(Side.Right, newNodeWidth - node.width);
8292
- node.stretch(Side.Bottom, newNodeHeight - node.height);
8442
+ newNodeWidth += ((_a = node.type.sectionGrid) === null || _a === void 0 ? void 0 : _a.margin) || 0;
8443
+ newNodeHeight += ((_b = node.type.sectionGrid) === null || _b === void 0 ? void 0 : _b.margin) || 0;
8444
+ if (shrink || newNodeWidth > node.width) {
8445
+ node.stretch(Side.Right, newNodeWidth - node.width);
8446
+ }
8447
+ if (shrink || newNodeHeight > node.height) {
8448
+ node.stretch(Side.Bottom, newNodeHeight - node.height);
8449
+ }
8293
8450
  }
8294
8451
  }
8295
8452
  selectRoot() {
@@ -8308,18 +8465,18 @@ class DiagramCanvas {
8308
8465
  startConnection(port) {
8309
8466
  var _a, _b, _c, _d;
8310
8467
  if (port.allowsOutgoing || port.allowsIncoming) {
8311
- if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && port.allowsIncoming)) {
8468
+ if (this.connectionType && (this.connectionType.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '') && port.allowsOutgoing || this.connectionType.canFinishOnType(((_d = (_c = port.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && port.allowsIncoming)) {
8312
8469
  this.unfinishedConnection = new DiagramConnection(this.model, this.connectionType, port, undefined, UNFINISHED_CONNECTION_ID);
8313
8470
  } else {
8314
8471
  if (this.inferConnectionType) {
8315
8472
  let differentConnectionType = this.model.connections.types.all().find(t => {
8316
8473
  var _a, _b;
8317
- return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8474
+ return port.allowsOutgoing && t.canStartFromType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
8318
8475
  });
8319
8476
  if (differentConnectionType === undefined) {
8320
8477
  differentConnectionType = this.model.connections.types.all().find(t => {
8321
8478
  var _a, _b;
8322
- return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === undefined ? undefined : _a.type) === null || _b === undefined ? undefined : _b.id) || '');
8479
+ return port.allowsIncoming && t.canFinishOnType(((_b = (_a = port.getNode()) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.id) || '');
8323
8480
  });
8324
8481
  }
8325
8482
  if (differentConnectionType !== undefined) {
@@ -8334,14 +8491,14 @@ class DiagramCanvas {
8334
8491
  this.userHighlight.clear();
8335
8492
  if (this.unfinishedConnection !== undefined) {
8336
8493
  if (this.unfinishedConnection.start !== port) {
8337
- if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsOutgoing) && this.unfinishedConnection.type.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsIncoming) {
8338
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === undefined ? undefined : _j.id, port.id);
8494
+ if (this.unfinishedConnection.type.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && this.unfinishedConnection.type.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming) {
8495
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, (_j = this.unfinishedConnection.start) === null || _j === void 0 ? void 0 : _j.id, port.id);
8339
8496
  // clean up the previous unfinished connection
8340
8497
  this.dropConnection();
8341
8498
  addConnectionAction.do();
8342
8499
  this.actionStack.add(addConnectionAction);
8343
- } else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k === undefined ? undefined : _k.start) === null || _l === undefined ? undefined : _l.getNode()) === null || _m === undefined ? undefined : _m.type) === null || _o === undefined ? undefined : _o.id) || '') && ((_q = (_p = this.unfinishedConnection) === null || _p === undefined ? undefined : _p.start) === null || _q === undefined ? undefined : _q.allowsIncoming) && this.unfinishedConnection.type.canStartFromType(((_s = (_r = port.getNode()) === null || _r === undefined ? undefined : _r.type) === null || _s === undefined ? undefined : _s.id) || '') && port.allowsOutgoing) {
8344
- const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === undefined ? undefined : _t.id);
8500
+ } else if (this.unfinishedConnection.type.canFinishOnType(((_o = (_m = (_l = (_k = this.unfinishedConnection) === null || _k === void 0 ? void 0 : _k.start) === null || _l === void 0 ? void 0 : _l.getNode()) === null || _m === void 0 ? void 0 : _m.type) === null || _o === void 0 ? void 0 : _o.id) || '') && ((_q = (_p = this.unfinishedConnection) === null || _p === void 0 ? void 0 : _p.start) === null || _q === void 0 ? void 0 : _q.allowsIncoming) && this.unfinishedConnection.type.canStartFromType(((_s = (_r = port.getNode()) === null || _r === void 0 ? void 0 : _r.type) === null || _s === void 0 ? void 0 : _s.id) || '') && port.allowsOutgoing) {
8501
+ const addConnectionAction = new AddConnectionAction(this, this.unfinishedConnection.type, port.id, (_t = this.unfinishedConnection.start) === null || _t === void 0 ? void 0 : _t.id);
8345
8502
  // clean up the previous unfinished connection
8346
8503
  this.dropConnection();
8347
8504
  addConnectionAction.do();
@@ -8350,18 +8507,18 @@ class DiagramCanvas {
8350
8507
  if (this.inferConnectionType) {
8351
8508
  let differentConnectionType = this.model.connections.types.all().find(t => {
8352
8509
  var _a, _b, _c, _d, _e, _f, _g, _h;
8353
- return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsOutgoing) && t.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsIncoming;
8510
+ return t.canStartFromType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsOutgoing) && t.canFinishOnType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsIncoming;
8354
8511
  });
8355
8512
  let invertConnection = false;
8356
8513
  if (differentConnectionType === undefined) {
8357
8514
  differentConnectionType = this.model.connections.types.all().find(t => {
8358
8515
  var _a, _b, _c, _d, _e, _f, _g, _h;
8359
- return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.start) === null || _b === undefined ? undefined : _b.getNode()) === null || _c === undefined ? undefined : _c.type) === null || _d === undefined ? undefined : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === undefined ? undefined : _e.start) === null || _f === undefined ? undefined : _f.allowsIncoming) && t.canStartFromType(((_h = (_g = port.getNode()) === null || _g === undefined ? undefined : _g.type) === null || _h === undefined ? undefined : _h.id) || '') && port.allowsOutgoing;
8516
+ return t.canFinishOnType(((_d = (_c = (_b = (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.getNode()) === null || _c === void 0 ? void 0 : _c.type) === null || _d === void 0 ? void 0 : _d.id) || '') && ((_f = (_e = this.unfinishedConnection) === null || _e === void 0 ? void 0 : _e.start) === null || _f === void 0 ? void 0 : _f.allowsIncoming) && t.canStartFromType(((_h = (_g = port.getNode()) === null || _g === void 0 ? void 0 : _g.type) === null || _h === void 0 ? void 0 : _h.id) || '') && port.allowsOutgoing;
8360
8517
  });
8361
8518
  invertConnection = true;
8362
8519
  }
8363
8520
  if (differentConnectionType !== undefined) {
8364
- const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === undefined ? undefined : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === undefined ? undefined : _v.id : port.id);
8521
+ const addConnectionAction = new AddConnectionAction(this, differentConnectionType, invertConnection ? port.id : (_u = this.unfinishedConnection.start) === null || _u === void 0 ? void 0 : _u.id, invertConnection ? (_v = this.unfinishedConnection.start) === null || _v === void 0 ? void 0 : _v.id : port.id);
8365
8522
  // clean up the previous unfinished connection
8366
8523
  this.dropConnection();
8367
8524
  addConnectionAction.do();
@@ -8383,9 +8540,9 @@ class DiagramCanvas {
8383
8540
  }
8384
8541
  dropConnection() {
8385
8542
  var _a, _b, _c, _d;
8386
- (_a = this.unfinishedConnection) === null || _a === undefined ? undefined : _a.setStart(undefined);
8387
- (_b = this.unfinishedConnection) === null || _b === undefined ? undefined : _b.setEnd(undefined);
8388
- (_d = (_c = this.unfinishedConnection) === null || _c === undefined ? undefined : _c.select()) === null || _d === undefined ? undefined : _d.remove();
8543
+ (_a = this.unfinishedConnection) === null || _a === void 0 ? void 0 : _a.setStart(undefined);
8544
+ (_b = this.unfinishedConnection) === null || _b === void 0 ? void 0 : _b.setEnd(undefined);
8545
+ (_d = (_c = this.unfinishedConnection) === null || _c === void 0 ? void 0 : _c.select()) === null || _d === void 0 ? void 0 : _d.remove();
8389
8546
  this.unfinishedConnection = undefined;
8390
8547
  }
8391
8548
  cancelAllUserActions() {
@@ -8398,7 +8555,7 @@ class DiagramCanvas {
8398
8555
  canUserPerformAction(action) {
8399
8556
  return this.userActions[action] !== false;
8400
8557
  }
8401
- createInputField(text, coords, width, height, fontSize, fontFamily, changeCallback, finishCallback) {
8558
+ createInputField(text, coords, width, height, fontSize, fontFamily, orientation, changeCallback, finishCallback) {
8402
8559
  // if we have a text input open, close it before creating a new one
8403
8560
  this.removeInputField();
8404
8561
  const inputFieldContainer = this.selectCanvasElements().append('foreignObject').attr('x', `${coords[0]}px`).attr('y', `${coords[1]}px`).attr('width', `${width}px`).attr('height', `${height}px`).style('box-sizing', 'border-box').style('border', '1px solid');
@@ -8430,9 +8587,9 @@ class DiagramCanvas {
8430
8587
  // keep the field from shrinking below its original size
8431
8588
  const newWidth = Math.max(inputFieldWidth, width);
8432
8589
  const newHeight = Math.max(inputFieldHeight, height);
8433
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('width', `${newWidth}px`);
8590
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('width', `${newWidth}px`);
8434
8591
  inputField.style('width', `${newWidth}px`);
8435
- inputFieldContainer === null || inputFieldContainer === undefined ? undefined : inputFieldContainer.attr('height', `${newHeight}px`);
8592
+ inputFieldContainer === null || inputFieldContainer === void 0 ? void 0 : inputFieldContainer.attr('height', `${newHeight}px`);
8436
8593
  inputField.style('height', `${newHeight}px`);
8437
8594
  if (changeCallback) {
8438
8595
  changeCallback(value);
@@ -8454,13 +8611,13 @@ class DiagramCanvas {
8454
8611
  var _a, _b, _c;
8455
8612
  // when removing an element, a blur event is emitted
8456
8613
  // we remove the listener for blur so that it doesn't shoot again on element removal
8457
- (_b = (_a = this.inputFieldContainer) === null || _a === undefined ? undefined : _a.select('input')) === null || _b === undefined ? undefined : _b.on(Events.Blur, null);
8458
- (_c = this.inputFieldContainer) === null || _c === undefined ? undefined : _c.remove();
8614
+ (_b = (_a = this.inputFieldContainer) === null || _a === void 0 ? void 0 : _a.select('input')) === null || _b === void 0 ? void 0 : _b.on(Events.Blur, null);
8615
+ (_c = this.inputFieldContainer) === null || _c === void 0 ? void 0 : _c.remove();
8459
8616
  this.inputFieldContainer = undefined;
8460
8617
  }
8461
8618
  minimumSizeOfField(field) {
8462
8619
  var _a, _b;
8463
- const pNode = (_b = (_a = field.select()) === null || _a === undefined ? undefined : _a.select('p')) === null || _b === undefined ? undefined : _b.node();
8620
+ const pNode = (_b = (_a = field.select()) === null || _a === void 0 ? void 0 : _a.select('p')) === null || _b === void 0 ? void 0 : _b.node();
8464
8621
  if (!pNode) {
8465
8622
  // happens when a field has been created but not updated in view yet
8466
8623
  return [0, 0];
@@ -8479,7 +8636,7 @@ class DiagramCanvas {
8479
8636
  this.currentAction = new MoveAction(this, this.userSelection.filter(e => e instanceof DiagramNode).map(n => n.id), d.coords);
8480
8637
  } else {
8481
8638
  const ancestorOfNode = d.getLastAncestor();
8482
- this.currentAction = new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id));
8639
+ this.currentAction = new SetGeometryAction(this, DiagramActions.MoveNode, d.id, d.getGeometry(), d.getGeometry(), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id, ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id), ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id));
8483
8640
  }
8484
8641
  } else {
8485
8642
  setCursorStyle(CursorStyle.NotAllowed);
@@ -8532,23 +8689,23 @@ class DiagramCanvas {
8532
8689
  const filteredNodesAtLocation = filterByOnlyDescendants(nodesAtLocationWhichCanHaveNodeAsAChild);
8533
8690
  const droppedOn = filteredNodesAtLocation[filteredNodesAtLocation.length - 1];
8534
8691
  if (droppedOn !== d.parent && (d.type.canBeParentless || droppedOn !== undefined)) {
8535
- const ancestorOfDroppedOn = droppedOn === null || droppedOn === undefined ? undefined : droppedOn.getLastAncestor();
8692
+ const ancestorOfDroppedOn = droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.getLastAncestor();
8536
8693
  const fromChildGeometry = this.currentAction.from;
8537
- const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === undefined ? undefined : _a.id, droppedOn === null || droppedOn === undefined ? undefined : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id));
8538
- (_b = d.parent) === null || _b === undefined ? undefined : _b.removeChild(d);
8694
+ const setParentAction = new SetParentAction(this, d.id, (_a = d.parent) === null || _a === void 0 ? void 0 : _a.id, droppedOn === null || droppedOn === void 0 ? void 0 : droppedOn.id, fromChildGeometry, d.getGeometry(), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.id, ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id), ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id));
8695
+ (_b = d.parent) === null || _b === void 0 ? void 0 : _b.removeChild(d);
8539
8696
  if (droppedOn !== undefined) {
8540
8697
  droppedOn.addChild(d);
8541
8698
  }
8542
8699
  setParentAction.toChildGeometry = d.getGeometry(d.id);
8543
- setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === undefined ? undefined : ancestorOfDroppedOn.getGeometry(d.id);
8700
+ setParentAction.toAncestorGeometry = ancestorOfDroppedOn === null || ancestorOfDroppedOn === void 0 ? void 0 : ancestorOfDroppedOn.getGeometry(d.id);
8544
8701
  this.currentAction = setParentAction;
8545
8702
  } else {
8546
- const ancestorOfNode = d === null || d === undefined ? undefined : d.getLastAncestor();
8547
- this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.id;
8548
- this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8549
- (_c = d.parent) === null || _c === undefined ? undefined : _c.fitToChild(d);
8703
+ const ancestorOfNode = d === null || d === void 0 ? void 0 : d.getLastAncestor();
8704
+ this.currentAction.ancestorId = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.id;
8705
+ this.currentAction.fromAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8706
+ (_c = d.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(d);
8550
8707
  this.currentAction.to = d.getGeometry(d.id);
8551
- this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === undefined ? undefined : ancestorOfNode.getGeometry(d.id);
8708
+ this.currentAction.toAncestorGeometry = ancestorOfNode === null || ancestorOfNode === void 0 ? void 0 : ancestorOfNode.getGeometry(d.id);
8552
8709
  }
8553
8710
  }
8554
8711
  if (this.currentAction !== undefined) {
@@ -8574,14 +8731,14 @@ class DiagramCanvas {
8574
8731
  setCursorStyle(CursorStyle.Crosshair);
8575
8732
  // since the multiple selection rectangle is not affected by zoom,
8576
8733
  // we compensate its coordinates based in the zoom transform to draw it
8577
- (_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]) * this.zoomTransform.k + this.zoomTransform.x)) === null || _b === undefined ? undefined : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]) * this.zoomTransform.k + this.zoomTransform.y)) === null || _c === undefined ? undefined : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]) * this.zoomTransform.k)) === null || _d === undefined ? undefined : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]) * this.zoomTransform.k);
8734
+ (_d = (_c = (_b = (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.attr('x', Math.min(this.draggingFrom[0], pointerCoords[0]) * this.zoomTransform.k + this.zoomTransform.x)) === null || _b === void 0 ? void 0 : _b.attr('y', Math.min(this.draggingFrom[1], pointerCoords[1]) * this.zoomTransform.k + this.zoomTransform.y)) === null || _c === void 0 ? void 0 : _c.attr('width', Math.abs(this.draggingFrom[0] - pointerCoords[0]) * this.zoomTransform.k)) === null || _d === void 0 ? void 0 : _d.attr('height', Math.abs(this.draggingFrom[1] - pointerCoords[1]) * this.zoomTransform.k);
8578
8735
  this.dragging = true;
8579
8736
  }
8580
8737
  }
8581
8738
  finishMultipleSelection(event) {
8582
8739
  var _a;
8583
8740
  const pointerCoords = this.getPointerLocationRelativeToCanvas(event);
8584
- (_a = this.multipleSelectionContainer) === null || _a === undefined ? undefined : _a.remove();
8741
+ (_a = this.multipleSelectionContainer) === null || _a === void 0 ? void 0 : _a.remove();
8585
8742
  this.multipleSelectionContainer = undefined;
8586
8743
  this.userSelection.clear();
8587
8744
  for (const node of this.model.nodes) {
@@ -8675,7 +8832,7 @@ class CollabClient {
8675
8832
  const initialModel = message.initialModel;
8676
8833
  new DagaImporter().import(session.canvas.model, initialModel);
8677
8834
  this.startSyncing(session);
8678
- (_a = session.joinRoomResolve) === null || _a === undefined ? undefined : _a.call(session);
8835
+ (_a = session.joinRoomResolve) === null || _a === void 0 ? void 0 : _a.call(session);
8679
8836
  session.joinRoomResolve = undefined;
8680
8837
  break;
8681
8838
  }
@@ -8698,7 +8855,7 @@ class CollabClient {
8698
8855
  session.locator = message.locator;
8699
8856
  this.pendingSessions.delete(message.refId);
8700
8857
  this.sessions.set(session.locator, session);
8701
- (_b = session.createRoomResolve) === null || _b === undefined ? undefined : _b.call(session, session.locator);
8858
+ (_b = session.createRoomResolve) === null || _b === void 0 ? void 0 : _b.call(session, session.locator);
8702
8859
  session.createRoomResolve = undefined;
8703
8860
  // Deliver queued AddMessages now that we have a locator.
8704
8861
  for (const message of session.addQueue) {
@@ -8971,7 +9128,7 @@ class AdjacencyLayout {
8971
9128
  // place nodes according to arrangement
8972
9129
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
8973
9130
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
8974
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9131
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
8975
9132
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
8976
9133
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
8977
9134
  const node = nodeArrangement.get([x, y]);
@@ -9039,7 +9196,7 @@ class BreadthAdjacencyLayout {
9039
9196
  // place nodes according to arrangement
9040
9197
  const maximumWidth = Math.max(...model.nodes.map(n => n.width));
9041
9198
  const maximumHeight = Math.max(...model.nodes.map(n => n.height));
9042
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9199
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9043
9200
  for (let y = nodeArrangement.minY(); y <= nodeArrangement.maxY(); ++y) {
9044
9201
  for (let x = nodeArrangement.minX(); x <= nodeArrangement.maxX(); ++x) {
9045
9202
  const node = nodeArrangement.get([x, y]);
@@ -9066,7 +9223,7 @@ class BreadthLayout {
9066
9223
  // nothing to arrange...
9067
9224
  return model;
9068
9225
  }
9069
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9226
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9070
9227
  let nodesToBeArranged = model.nodes.filter(n => !n.parent);
9071
9228
  // Arrange nodes by a breadth first search
9072
9229
  const firstNode = nodesToBeArranged[0];
@@ -9132,8 +9289,8 @@ class ForceLayout {
9132
9289
  return model;
9133
9290
  }
9134
9291
  // as a starting point, we apply a simple layout
9135
- new BreadthLayout().apply(model);
9136
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9292
+ new BreadthLayout(this.gapSize).apply(model);
9293
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9137
9294
  const coolingFactor = 0.99;
9138
9295
  const minimumTemperature = 1;
9139
9296
  const attractionFactor = 0.1;
@@ -9229,7 +9386,7 @@ class HorizontalLayout {
9229
9386
  // nothing to arrange...
9230
9387
  return model;
9231
9388
  }
9232
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9389
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9233
9390
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9234
9391
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9235
9392
  let widthAccumulator = 0;
@@ -9259,10 +9416,10 @@ class PriorityLayout {
9259
9416
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9260
9417
  if (maximumPriority === minimumPriority) {
9261
9418
  // if there's no disparity in priorities, just use breadth layout
9262
- new BreadthLayout().apply(model);
9419
+ new BreadthLayout(this.gapSize).apply(model);
9263
9420
  return model;
9264
9421
  }
9265
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9422
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9266
9423
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9267
9424
  const nodeArrangement = [];
9268
9425
  const nodesWithMaximumPriorityToBeArranged = model.nodes.filter(n => !n.parent).filter(n => n.getPriority() >= maximumPriority);
@@ -9369,10 +9526,10 @@ class TreeLayout {
9369
9526
  const minimumPriority = Math.min(...model.nodes.map(n => n.getPriority()));
9370
9527
  if (maximumPriority === minimumPriority) {
9371
9528
  // if there's no disparity in priorities, just use breadth layout
9372
- new BreadthLayout().apply(model);
9529
+ new BreadthLayout(this.gapSize).apply(model);
9373
9530
  return model;
9374
9531
  }
9375
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9532
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9376
9533
  const nodesToBeArranged = model.nodes.filter(n => !n.parent).sort((n1, n2) => n2.getPriority() - n1.getPriority());
9377
9534
  const branches = [];
9378
9535
  while (nodesToBeArranged.length > 0) {
@@ -9466,7 +9623,7 @@ class VerticalLayout {
9466
9623
  // nothing to arrange...
9467
9624
  return model;
9468
9625
  }
9469
- const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === undefined ? undefined : _a.gridSize) || 0) * 2;
9626
+ const gapSize = this.gapSize !== undefined ? this.gapSize : (((_a = model.canvas) === null || _a === void 0 ? void 0 : _a.gridSize) || 0) * 2;
9470
9627
  const nodesToBeArranged = model.nodes.filter(n => !n.parent);
9471
9628
  nodesToBeArranged.sort((a, b) => b.type.priority - a.type.priority);
9472
9629
  let heightAccumulator = 0;