@metadev/daga 5.1.1 → 5.1.2

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.cjs.js CHANGED
@@ -3691,6 +3691,7 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
3691
3691
  defaultHeight: 1,
3692
3692
  minWidth: 1,
3693
3693
  minHeight: 1,
3694
+ defaultZ: 0,
3694
3695
  resizableX: false,
3695
3696
  resizableY: false,
3696
3697
  snapToGridOffset: [0, 0, 0, 0],
@@ -3720,6 +3721,7 @@ class DiagramNodeType {
3720
3721
  this.defaultHeight = values.defaultHeight;
3721
3722
  this.minWidth = values.minWidth;
3722
3723
  this.minHeight = values.minHeight;
3724
+ this.defaultZ = values.defaultZ;
3723
3725
  if (typeof options.resizableX === 'undefined') {
3724
3726
  this.resizerX = new DiagramResizer({
3725
3727
  mode: exports.ResizableMode.Never
@@ -3900,6 +3902,7 @@ class DiagramNode extends DiagramElement {
3900
3902
  this.coords = coords;
3901
3903
  this.width = type.defaultWidth;
3902
3904
  this.height = type.defaultHeight;
3905
+ this.z = type.defaultZ;
3903
3906
  }
3904
3907
  get removed() {
3905
3908
  return this.selfRemoved;
@@ -3927,6 +3930,16 @@ class DiagramNode extends DiagramElement {
3927
3930
  child.raise();
3928
3931
  }
3929
3932
  }
3933
+ /**
3934
+ * Put this element above other elements in the view if they have a lower z coordinate.
3935
+ */
3936
+ raiseWithZ() {
3937
+ this.raise();
3938
+ const overlappingNodesWithHigherPriority = this.model.nodes.filter(n => n.id !== this.id && n.z > this.z && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [this.coords, [this.coords[0] + this.width, this.coords[1] + this.height]]));
3939
+ for (const n of overlappingNodesWithHigherPriority) {
3940
+ n.raiseWithZ();
3941
+ }
3942
+ }
3930
3943
  getPriority() {
3931
3944
  return this.type.priority;
3932
3945
  }
@@ -4230,6 +4243,7 @@ class DiagramNode extends DiagramElement {
4230
4243
  }
4231
4244
  this.setGeometry({
4232
4245
  coords,
4246
+ z: this.z,
4233
4247
  width: this.width,
4234
4248
  height: this.height,
4235
4249
  // We already moved the sections above - skip changing them in setDimensions.
@@ -4281,6 +4295,7 @@ class DiagramNode extends DiagramElement {
4281
4295
  }
4282
4296
  this.setGeometry({
4283
4297
  coords: [newCoordsX[0], newCoordsY[0]],
4298
+ z: this.z,
4284
4299
  width: newCoordsX[1] - newCoordsX[0],
4285
4300
  height: newCoordsY[1] - newCoordsY[0],
4286
4301
  // we ignore this.sections, the stretching of a node with sections is handled in the stretchSections method
@@ -4388,6 +4403,7 @@ class DiagramNode extends DiagramElement {
4388
4403
  }
4389
4404
  return {
4390
4405
  coords: [...this.coords],
4406
+ z: this.z,
4391
4407
  width: this.width,
4392
4408
  height: this.height,
4393
4409
  sections,
@@ -4404,6 +4420,7 @@ class DiagramNode extends DiagramElement {
4404
4420
  const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
4405
4421
  const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
4406
4422
  this.coords = [...geometry.coords];
4423
+ this.z = geometry.z;
4407
4424
  this.width = geometry.width;
4408
4425
  this.height = geometry.height;
4409
4426
  const newCoordsX = [this.coords[0], this.coords[0] + this.width];
@@ -5580,6 +5597,7 @@ class AddNodeCollabAction {
5580
5597
  } else {
5581
5598
  node.valueSet.resetValues();
5582
5599
  }
5600
+ node.raiseWithZ();
5583
5601
  }
5584
5602
  serialize() {
5585
5603
  return {
@@ -5738,6 +5756,7 @@ class SetGeometryCollabAction {
5738
5756
  }
5739
5757
  }
5740
5758
  (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
5759
+ node.raiseWithZ();
5741
5760
  node.geometryTimestamp = this.timestamp;
5742
5761
  }
5743
5762
  }
@@ -6968,14 +6987,28 @@ class DiagramModel {
6968
6987
  }
6969
6988
 
6970
6989
  /**
6971
- * Checks if the given mouse event was produced with a secondary button press.
6990
+ * Checks if the given pointer event was produced with a secondary button press.
6972
6991
  * @private
6973
- * @param event A mouse event.
6974
- * @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
6992
+ * @param event A pointer event.
6993
+ * @returns `true` if the given pointer event was produced with a secondary button press, `false` otherwise.
6975
6994
  */
6976
6995
  const isSecondaryButton = event => {
6977
6996
  return !!event.button;
6978
6997
  };
6998
+ /**
6999
+ * Obtain the pointer event which is valid for passing to the `d3.pointer()` function.
7000
+ * @param event A pointer event.
7001
+ * @returns A pointer event which can be passed to the `d3.pointer()` function.
7002
+ */
7003
+ const getEventHoldingCoordinates = event => {
7004
+ if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
7005
+ const sourceEvent = event.sourceEvent;
7006
+ if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
7007
+ return sourceEvent.touches[0] || sourceEvent.changedTouches[0];
7008
+ }
7009
+ }
7010
+ return event;
7011
+ };
6979
7012
  /**
6980
7013
  * Get the SVG path of a diagram connection.
6981
7014
  * @private
@@ -8345,30 +8378,14 @@ class DiagramCanvas {
8345
8378
  const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
8346
8379
  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]];
8347
8380
  }
8348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8349
- getEventHoldingCoordinates(event) {
8350
- if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
8351
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8352
- const sourceEvent = event.sourceEvent;
8353
- if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
8354
- return (
8355
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8356
- event.sourceEvent.touches[0] ||
8357
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8358
- event.sourceEvent.changedTouches[0]
8359
- );
8360
- }
8361
- }
8362
- return event;
8363
- }
8364
8381
  getPointerLocationRelativeToCanvas(event) {
8365
- return d3__namespace.pointer(this.getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8382
+ return d3__namespace.pointer(getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8366
8383
  }
8367
8384
  getPointerLocationRelativeToRoot(event) {
8368
- return d3__namespace.pointer(this.getEventHoldingCoordinates(event), this.selectSVGElement().node());
8385
+ return d3__namespace.pointer(getEventHoldingCoordinates(event), this.selectSVGElement().node());
8369
8386
  }
8370
8387
  getPointerLocationRelativeToBody(event) {
8371
- return d3__namespace.pointer(this.getEventHoldingCoordinates(event), d3__namespace.select('body').node());
8388
+ return d3__namespace.pointer(getEventHoldingCoordinates(event), d3__namespace.select('body').node());
8372
8389
  }
8373
8390
  getPointerLocationRelativeToScreen(event) {
8374
8391
  const pointerLocationRelativeToBody = this.getPointerLocationRelativeToBody(event);
@@ -9792,6 +9809,46 @@ class DiagramCanvas {
9792
9809
  endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
9793
9810
  }
9794
9811
  }
9812
+ bringToFront(node) {
9813
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9814
+ let maximumZ = node.z;
9815
+ for (const n of overlappingNodes) {
9816
+ if (n.z > maximumZ) {
9817
+ maximumZ = n.z;
9818
+ }
9819
+ }
9820
+ maximumZ += 1;
9821
+ const action = new SetGeometryAction(this, exports.DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9822
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9823
+ z: maximumZ
9824
+ }));
9825
+ node.raiseWithZ();
9826
+ action.to = node.getGeometry();
9827
+ this.currentAction = action;
9828
+ this.currentAction.do();
9829
+ this.actionStack.add(this.currentAction);
9830
+ this.currentAction = undefined;
9831
+ }
9832
+ sendToBack(node) {
9833
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9834
+ let minimumZ = node.z;
9835
+ for (const n of overlappingNodes) {
9836
+ if (n.z < minimumZ) {
9837
+ minimumZ = n.z;
9838
+ }
9839
+ }
9840
+ minimumZ -= 1;
9841
+ const action = new SetGeometryAction(this, exports.DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9842
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9843
+ z: minimumZ
9844
+ }));
9845
+ node.raiseWithZ();
9846
+ action.to = node.getGeometry();
9847
+ this.currentAction = action;
9848
+ this.currentAction.do();
9849
+ this.actionStack.add(this.currentAction);
9850
+ this.currentAction = undefined;
9851
+ }
9795
9852
  fieldRootFitsInView(id) {
9796
9853
  var _a, _b, _c, _d;
9797
9854
  const field = this.model.fields.get(id);
package/index.esm.js CHANGED
@@ -3670,6 +3670,7 @@ const DIAGRAM_NODE_TYPE_DEFAULTS = {
3670
3670
  defaultHeight: 1,
3671
3671
  minWidth: 1,
3672
3672
  minHeight: 1,
3673
+ defaultZ: 0,
3673
3674
  resizableX: false,
3674
3675
  resizableY: false,
3675
3676
  snapToGridOffset: [0, 0, 0, 0],
@@ -3699,6 +3700,7 @@ class DiagramNodeType {
3699
3700
  this.defaultHeight = values.defaultHeight;
3700
3701
  this.minWidth = values.minWidth;
3701
3702
  this.minHeight = values.minHeight;
3703
+ this.defaultZ = values.defaultZ;
3702
3704
  if (typeof options.resizableX === 'undefined') {
3703
3705
  this.resizerX = new DiagramResizer({
3704
3706
  mode: ResizableMode.Never
@@ -3879,6 +3881,7 @@ class DiagramNode extends DiagramElement {
3879
3881
  this.coords = coords;
3880
3882
  this.width = type.defaultWidth;
3881
3883
  this.height = type.defaultHeight;
3884
+ this.z = type.defaultZ;
3882
3885
  }
3883
3886
  get removed() {
3884
3887
  return this.selfRemoved;
@@ -3906,6 +3909,16 @@ class DiagramNode extends DiagramElement {
3906
3909
  child.raise();
3907
3910
  }
3908
3911
  }
3912
+ /**
3913
+ * Put this element above other elements in the view if they have a lower z coordinate.
3914
+ */
3915
+ raiseWithZ() {
3916
+ this.raise();
3917
+ const overlappingNodesWithHigherPriority = this.model.nodes.filter(n => n.id !== this.id && n.z > this.z && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [this.coords, [this.coords[0] + this.width, this.coords[1] + this.height]]));
3918
+ for (const n of overlappingNodesWithHigherPriority) {
3919
+ n.raiseWithZ();
3920
+ }
3921
+ }
3909
3922
  getPriority() {
3910
3923
  return this.type.priority;
3911
3924
  }
@@ -4209,6 +4222,7 @@ class DiagramNode extends DiagramElement {
4209
4222
  }
4210
4223
  this.setGeometry({
4211
4224
  coords,
4225
+ z: this.z,
4212
4226
  width: this.width,
4213
4227
  height: this.height,
4214
4228
  // We already moved the sections above - skip changing them in setDimensions.
@@ -4260,6 +4274,7 @@ class DiagramNode extends DiagramElement {
4260
4274
  }
4261
4275
  this.setGeometry({
4262
4276
  coords: [newCoordsX[0], newCoordsY[0]],
4277
+ z: this.z,
4263
4278
  width: newCoordsX[1] - newCoordsX[0],
4264
4279
  height: newCoordsY[1] - newCoordsY[0],
4265
4280
  // we ignore this.sections, the stretching of a node with sections is handled in the stretchSections method
@@ -4367,6 +4382,7 @@ class DiagramNode extends DiagramElement {
4367
4382
  }
4368
4383
  return {
4369
4384
  coords: [...this.coords],
4385
+ z: this.z,
4370
4386
  width: this.width,
4371
4387
  height: this.height,
4372
4388
  sections,
@@ -4383,6 +4399,7 @@ class DiagramNode extends DiagramElement {
4383
4399
  const oldCoordsX = [this.coords[0], this.coords[0] + this.width];
4384
4400
  const oldCoordsY = [this.coords[1], this.coords[1] + this.height];
4385
4401
  this.coords = [...geometry.coords];
4402
+ this.z = geometry.z;
4386
4403
  this.width = geometry.width;
4387
4404
  this.height = geometry.height;
4388
4405
  const newCoordsX = [this.coords[0], this.coords[0] + this.width];
@@ -5559,6 +5576,7 @@ class AddNodeCollabAction {
5559
5576
  } else {
5560
5577
  node.valueSet.resetValues();
5561
5578
  }
5579
+ node.raiseWithZ();
5562
5580
  }
5563
5581
  serialize() {
5564
5582
  return {
@@ -5717,6 +5735,7 @@ class SetGeometryCollabAction {
5717
5735
  }
5718
5736
  }
5719
5737
  (_c = node.parent) === null || _c === void 0 ? void 0 : _c.fitToChild(node);
5738
+ node.raiseWithZ();
5720
5739
  node.geometryTimestamp = this.timestamp;
5721
5740
  }
5722
5741
  }
@@ -6947,14 +6966,28 @@ class DiagramModel {
6947
6966
  }
6948
6967
 
6949
6968
  /**
6950
- * Checks if the given mouse event was produced with a secondary button press.
6969
+ * Checks if the given pointer event was produced with a secondary button press.
6951
6970
  * @private
6952
- * @param event A mouse event.
6953
- * @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
6971
+ * @param event A pointer event.
6972
+ * @returns `true` if the given pointer event was produced with a secondary button press, `false` otherwise.
6954
6973
  */
6955
6974
  const isSecondaryButton = event => {
6956
6975
  return !!event.button;
6957
6976
  };
6977
+ /**
6978
+ * Obtain the pointer event which is valid for passing to the `d3.pointer()` function.
6979
+ * @param event A pointer event.
6980
+ * @returns A pointer event which can be passed to the `d3.pointer()` function.
6981
+ */
6982
+ const getEventHoldingCoordinates = event => {
6983
+ if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
6984
+ const sourceEvent = event.sourceEvent;
6985
+ if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
6986
+ return sourceEvent.touches[0] || sourceEvent.changedTouches[0];
6987
+ }
6988
+ }
6989
+ return event;
6990
+ };
6958
6991
  /**
6959
6992
  * Get the SVG path of a diagram connection.
6960
6993
  * @private
@@ -8324,30 +8357,14 @@ class DiagramCanvas {
8324
8357
  const rootDimensions = [(rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.width) || 0, (rootBoundingClientRect === null || rootBoundingClientRect === void 0 ? void 0 : rootBoundingClientRect.height) || 0];
8325
8358
  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]];
8326
8359
  }
8327
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8328
- getEventHoldingCoordinates(event) {
8329
- if (event.type === 'drag' || event.type === 'start' || event.type === 'end') {
8330
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8331
- const sourceEvent = event.sourceEvent;
8332
- if (sourceEvent && (sourceEvent.type === 'touchmove' || sourceEvent.type === 'touchstart' || sourceEvent.type === 'touchend')) {
8333
- return (
8334
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8335
- event.sourceEvent.touches[0] ||
8336
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8337
- event.sourceEvent.changedTouches[0]
8338
- );
8339
- }
8340
- }
8341
- return event;
8342
- }
8343
8360
  getPointerLocationRelativeToCanvas(event) {
8344
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8361
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectCanvasElements().node());
8345
8362
  }
8346
8363
  getPointerLocationRelativeToRoot(event) {
8347
- return d3.pointer(this.getEventHoldingCoordinates(event), this.selectSVGElement().node());
8364
+ return d3.pointer(getEventHoldingCoordinates(event), this.selectSVGElement().node());
8348
8365
  }
8349
8366
  getPointerLocationRelativeToBody(event) {
8350
- return d3.pointer(this.getEventHoldingCoordinates(event), d3.select('body').node());
8367
+ return d3.pointer(getEventHoldingCoordinates(event), d3.select('body').node());
8351
8368
  }
8352
8369
  getPointerLocationRelativeToScreen(event) {
8353
8370
  const pointerLocationRelativeToBody = this.getPointerLocationRelativeToBody(event);
@@ -9771,6 +9788,46 @@ class DiagramCanvas {
9771
9788
  endMarkerSelection.attr('orient', 'auto-start-reverse').attr('markerWidth', 0).attr('markerHeight', 0);
9772
9789
  }
9773
9790
  }
9791
+ bringToFront(node) {
9792
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9793
+ let maximumZ = node.z;
9794
+ for (const n of overlappingNodes) {
9795
+ if (n.z > maximumZ) {
9796
+ maximumZ = n.z;
9797
+ }
9798
+ }
9799
+ maximumZ += 1;
9800
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9801
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9802
+ z: maximumZ
9803
+ }));
9804
+ node.raiseWithZ();
9805
+ action.to = node.getGeometry();
9806
+ this.currentAction = action;
9807
+ this.currentAction.do();
9808
+ this.actionStack.add(this.currentAction);
9809
+ this.currentAction = undefined;
9810
+ }
9811
+ sendToBack(node) {
9812
+ const overlappingNodes = this.model.nodes.filter(n => n.id !== node.id && rectanglesIntersect([n.coords, [n.coords[0] + n.width, n.coords[1] + n.height]], [node.coords, [node.coords[0] + node.width, node.coords[1] + node.height]]));
9813
+ let minimumZ = node.z;
9814
+ for (const n of overlappingNodes) {
9815
+ if (n.z < minimumZ) {
9816
+ minimumZ = n.z;
9817
+ }
9818
+ }
9819
+ minimumZ -= 1;
9820
+ const action = new SetGeometryAction(this, DiagramActions.MoveNode, node.id, node.getGeometry(), node.getGeometry());
9821
+ node.setGeometry(Object.assign(Object.assign({}, node.getGeometry()), {
9822
+ z: minimumZ
9823
+ }));
9824
+ node.raiseWithZ();
9825
+ action.to = node.getGeometry();
9826
+ this.currentAction = action;
9827
+ this.currentAction.do();
9828
+ this.actionStack.add(this.currentAction);
9829
+ this.currentAction = undefined;
9830
+ }
9774
9831
  fieldRootFitsInView(id) {
9775
9832
  var _a, _b, _c, _d;
9776
9833
  const field = this.model.fields.get(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metadev/daga",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "dependencies": {},
6
6
  "peerDependencies": {
@@ -10,12 +10,18 @@ import { DiagramPort } from '../model/diagram-port';
10
10
  import { DiagramSection } from '../model/diagram-section';
11
11
  import { DiagramCanvas } from './diagram-canvas';
12
12
  /**
13
- * Checks if the given mouse event was produced with a secondary button press.
13
+ * Checks if the given pointer event was produced with a secondary button press.
14
14
  * @private
15
- * @param event A mouse event.
16
- * @returns `true` if the given mouse event was produced with a secondary button press, `false` otherwise.
15
+ * @param event A pointer event.
16
+ * @returns `true` if the given pointer event was produced with a secondary button press, `false` otherwise.
17
17
  */
18
18
  export declare const isSecondaryButton: (event: MouseEvent) => boolean;
19
+ /**
20
+ * Obtain the pointer event which is valid for passing to the `d3.pointer()` function.
21
+ * @param event A pointer event.
22
+ * @returns A pointer event which can be passed to the `d3.pointer()` function.
23
+ */
24
+ export declare const getEventHoldingCoordinates: (event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>) => unknown;
19
25
  /**
20
26
  * Get the SVG path of a diagram connection.
21
27
  * @private
@@ -11,6 +11,7 @@ import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from
11
11
  import { DiagramEvent } from '../diagram-event';
12
12
  import { DiagramConnectionType } from '../model/diagram-connection';
13
13
  import { DiagramModel } from '../model/diagram-model';
14
+ import { DiagramNode } from '../model/diagram-node';
14
15
  import { DiagramContextMenu } from './diagram-context-menu';
15
16
  import { DiagramUserHighlight } from './diagram-user-highlight';
16
17
  import { DiagramUserSelection } from './diagram-user-selection';
@@ -104,11 +105,10 @@ export declare class DiagramCanvas implements Canvas {
104
105
  center(nodeIds?: string[], maxZoomLevel?: number, duration?: number): void;
105
106
  getClosestGridPoint(point: Point): Point;
106
107
  getCoordinatesOnScreen(): [Point, Point];
107
- private getEventHoldingCoordinates;
108
- getPointerLocationRelativeToCanvas(event: MouseEvent): Point;
109
- getPointerLocationRelativeToRoot(event: MouseEvent): Point;
110
- getPointerLocationRelativeToBody(event: MouseEvent): Point;
111
- getPointerLocationRelativeToScreen(event: MouseEvent): Point;
108
+ getPointerLocationRelativeToCanvas(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
109
+ getPointerLocationRelativeToRoot(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
110
+ getPointerLocationRelativeToBody(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
111
+ getPointerLocationRelativeToScreen(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
112
112
  updateModelInView(): void;
113
113
  updateNodesInView(...ids: string[]): void;
114
114
  updateSectionsInView(...ids: string[]): void;
@@ -119,6 +119,8 @@ export declare class DiagramCanvas implements Canvas {
119
119
  updateDecoratorsInView(...ids: string[]): void;
120
120
  private updateConnectionLabelsInView;
121
121
  private updateConnectionMarkersInView;
122
+ bringToFront(node: DiagramNode): void;
123
+ sendToBack(node: DiagramNode): void;
122
124
  fieldRootFitsInView(id: string): boolean;
123
125
  fitFieldRootInView(id: string, shrink?: boolean): void;
124
126
  fitNodeInView(id: string, shrink?: boolean): void;
@@ -170,6 +170,11 @@ export interface NodeTypeConfig {
170
170
  * @default 1
171
171
  */
172
172
  minHeight?: number;
173
+ /**
174
+ * The default z coordinate of nodes of this type when rendering them in order relative to other diagram elements.
175
+ * @default 0
176
+ */
177
+ defaultZ?: number;
173
178
  /**
174
179
  * Whether the user can resize nodes of this type horizontally.
175
180
  * @default false
@@ -31,6 +31,7 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
31
31
  defaultHeight: number;
32
32
  minWidth: number;
33
33
  minHeight: number;
34
+ defaultZ: number;
34
35
  resizableX: boolean;
35
36
  resizableY: boolean;
36
37
  snapToGridOffset: [number, number, number, number];
@@ -48,6 +49,7 @@ export declare const DIAGRAM_NODE_TYPE_DEFAULTS: {
48
49
  };
49
50
  export type DiagramNodeGeometry = {
50
51
  readonly coords: Point;
52
+ readonly z: number;
51
53
  readonly width: number;
52
54
  readonly height: number;
53
55
  readonly sections: {
@@ -76,6 +78,7 @@ export declare class DiagramNodeType implements DiagramEntity {
76
78
  defaultHeight: number;
77
79
  minWidth: number;
78
80
  minHeight: number;
81
+ defaultZ: number;
79
82
  resizerX: DiagramResizer;
80
83
  resizerY: DiagramResizer;
81
84
  resizerXY: DiagramResizer;
@@ -172,6 +175,11 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
172
175
  * @public
173
176
  */
174
177
  height: number;
178
+ /**
179
+ * The relative z coordinate of this node. Used to render this node below nodes with a higher z coordinate.
180
+ * @public
181
+ */
182
+ z: number;
175
183
  /**
176
184
  * Name of this node. Alias for this node's label's text.
177
185
  * @public
@@ -208,6 +216,10 @@ export declare class DiagramNode extends DiagramElement implements LabeledElemen
208
216
  get removed(): boolean;
209
217
  updateInView(): void;
210
218
  raise(): void;
219
+ /**
220
+ * Put this element above other elements in the view if they have a lower z coordinate.
221
+ */
222
+ raiseWithZ(): void;
211
223
  getPriority(): number;
212
224
  /**
213
225
  * Returns the horizontal resizer of this node.
@@ -9,6 +9,7 @@ import { ActionStack, DiagramAction, DiagramActionMethod, DiagramActions } from
9
9
  import { DiagramEvent } from '../diagram/diagram-event';
10
10
  import { DiagramConnectionType } from '../diagram/model/diagram-connection';
11
11
  import { DiagramModel } from '../diagram/model/diagram-model';
12
+ import { DiagramNode } from '../diagram/model/diagram-node';
12
13
  import { DiagramValidator } from '../errors/diagram-validator';
13
14
  import { Point } from '../util/canvas-util';
14
15
  import { DiagramEditor } from './diagram-editor';
@@ -233,25 +234,25 @@ export interface Canvas {
233
234
  * @private
234
235
  * @param event A MouseEvent.
235
236
  */
236
- getPointerLocationRelativeToCanvas(event: MouseEvent): Point;
237
+ getPointerLocationRelativeToCanvas(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
237
238
  /**
238
239
  * Get the location of the pointer in the given event relative to the svg element.
239
240
  * @private
240
241
  * @param event A MouseEvent.
241
242
  */
242
- getPointerLocationRelativeToRoot(event: MouseEvent): Point;
243
+ getPointerLocationRelativeToRoot(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
243
244
  /**
244
245
  * Get the location of the pointer in the given event relative to the body.
245
246
  * @private
246
247
  * @param event A MouseEvent.
247
248
  */
248
- getPointerLocationRelativeToBody(event: MouseEvent): Point;
249
+ getPointerLocationRelativeToBody(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
249
250
  /**
250
251
  * Get the location of the pointer in the given event relative to the screen.
251
252
  * @private
252
253
  * @param event A MouseEvent.
253
254
  */
254
- getPointerLocationRelativeToScreen(event: MouseEvent): Point;
255
+ getPointerLocationRelativeToScreen(event: MouseEvent | d3.D3DragEvent<Element, unknown, unknown>): Point;
255
256
  /**
256
257
  * Adds a validator to the list of validators of the diagram.
257
258
  * @public
@@ -318,6 +319,16 @@ export interface Canvas {
318
319
  * @public
319
320
  */
320
321
  updateDecoratorsInView(...ids: string[]): void;
322
+ /**
323
+ * Update the z coordinate of a node to be higher than any node that overlaps with it.
324
+ * @public
325
+ */
326
+ bringToFront(node: DiagramNode): void;
327
+ /**
328
+ * Update the z coordinate of a node to be lower than any node that overlaps with it.
329
+ * @public
330
+ */
331
+ sendToBack(node: DiagramNode): void;
321
332
  /**
322
333
  * Checks whether the root of a diagram field encompasses the totality of the field.
323
334
  * @param id The id of a diagram field