@aranzatech/diagrams-bpmn 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/dist/{catalog-xOMF2ifW.d.cts → catalog-DAGDhO-D.d.cts} +1 -1
- package/dist/{catalog-CK3_4cOb.d.ts → catalog-Q1QmKLDD.d.ts} +1 -1
- package/dist/{chunk-YUE5EM3W.js → chunk-334WN4JZ.js} +276 -107
- package/dist/chunk-334WN4JZ.js.map +1 -0
- package/dist/chunk-77L6O76M.js +3 -0
- package/dist/chunk-77L6O76M.js.map +1 -0
- package/dist/{chunk-QSMP34CT.js → chunk-CPFUQM6H.js} +80 -44
- package/dist/chunk-CPFUQM6H.js.map +1 -0
- package/dist/{chunk-XMVV7FRZ.js → chunk-FFWJA5BV.js} +3 -3
- package/dist/{chunk-XMVV7FRZ.js.map → chunk-FFWJA5BV.js.map} +1 -1
- package/dist/{chunk-FBTGIYZS.js → chunk-JEGYVEJO.js} +80 -3
- package/dist/{chunk-FBTGIYZS.js.map → chunk-JEGYVEJO.js.map} +1 -1
- package/dist/chunk-TB6V4S5N.js +104 -0
- package/dist/chunk-TB6V4S5N.js.map +1 -0
- package/dist/{chunk-HOWK3ZOO.js → chunk-YAYZW45I.js} +379 -16
- package/dist/chunk-YAYZW45I.js.map +1 -0
- package/dist/edges/index.cjs +78 -42
- package/dist/edges/index.cjs.map +1 -1
- package/dist/edges/index.js +1 -1
- package/dist/elements/index.cjs +78 -0
- package/dist/elements/index.cjs.map +1 -1
- package/dist/elements/index.d.cts +24 -5
- package/dist/elements/index.d.ts +24 -5
- package/dist/elements/index.js +1 -1
- package/dist/elk-QT7H4252.js +6 -0
- package/dist/elk-QT7H4252.js.map +1 -0
- package/dist/extensions/index.cjs +108 -0
- package/dist/extensions/index.cjs.map +1 -0
- package/dist/extensions/index.d.cts +145 -0
- package/dist/extensions/index.d.ts +145 -0
- package/dist/extensions/index.js +4 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/index.cjs +922 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/layout/index.cjs +11 -1
- package/dist/layout/index.cjs.map +1 -1
- package/dist/layout/index.d.cts +4 -3
- package/dist/layout/index.d.ts +4 -3
- package/dist/layout/index.js +3 -3
- package/dist/modeling/index.cjs +387 -13
- package/dist/modeling/index.cjs.map +1 -1
- package/dist/modeling/index.d.cts +62 -4
- package/dist/modeling/index.d.ts +62 -4
- package/dist/modeling/index.js +1 -1
- package/dist/types-BX_o95GC.d.cts +40 -0
- package/dist/{types-y-ZbX-ff.d.ts → types-BYN4Zuee.d.cts} +15 -1
- package/dist/{types-y-ZbX-ff.d.cts → types-BYN4Zuee.d.ts} +15 -1
- package/dist/{types-jIDz306Y.d.cts → types-CggktCqr.d.cts} +4 -1
- package/dist/types-D7zel9dq.d.ts +40 -0
- package/dist/{types-DG5yPKld.d.ts → types-DmDODKlh.d.ts} +4 -1
- package/dist/validation/index.cjs +81 -125
- package/dist/validation/index.cjs.map +1 -1
- package/dist/validation/index.d.cts +22 -5
- package/dist/validation/index.d.ts +22 -5
- package/dist/validation/index.js +82 -126
- package/dist/validation/index.js.map +1 -1
- package/dist/xml/index.cjs +319 -49
- package/dist/xml/index.cjs.map +1 -1
- package/dist/xml/index.d.cts +5 -3
- package/dist/xml/index.d.ts +5 -3
- package/dist/xml/index.js +2 -1
- package/package.json +6 -1
- package/dist/chunk-HOWK3ZOO.js.map +0 -1
- package/dist/chunk-QSMP34CT.js.map +0 -1
- package/dist/chunk-YUE5EM3W.js.map +0 -1
- package/dist/elk-FSFIEL6O.js +0 -6
- package/dist/elk-FSFIEL6O.js.map +0 -1
- package/dist/guards-C70uIY_O.d.cts +0 -16
- package/dist/guards-foB6XIfZ.d.ts +0 -16
package/dist/layout/index.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { LayoutResult, LayoutOptions } from '@aranzatech/diagrams-core/types';
|
|
2
2
|
export { applyLayoutResultToDiagram } from '@aranzatech/diagrams-core/layout';
|
|
3
|
-
import { d as BpmnRFNode, c as BpmnRFEdge } from '../types-
|
|
3
|
+
import { d as BpmnRFNode, c as BpmnRFEdge } from '../types-CggktCqr.cjs';
|
|
4
4
|
import { BpmnDiagramState } from '../modeling/index.cjs';
|
|
5
5
|
import '@xyflow/react';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-BYN4Zuee.cjs';
|
|
7
|
+
import '../types-BX_o95GC.cjs';
|
|
7
8
|
import '@aranzatech/diagrams-core';
|
|
8
9
|
import '@aranzatech/diagrams-core/serialization';
|
|
9
|
-
import '../catalog-
|
|
10
|
+
import '../catalog-DAGDhO-D.cjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* ELK-based auto-layout for BPMN diagrams.
|
package/dist/layout/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { LayoutResult, LayoutOptions } from '@aranzatech/diagrams-core/types';
|
|
2
2
|
export { applyLayoutResultToDiagram } from '@aranzatech/diagrams-core/layout';
|
|
3
|
-
import { d as BpmnRFNode, c as BpmnRFEdge } from '../types-
|
|
3
|
+
import { d as BpmnRFNode, c as BpmnRFEdge } from '../types-DmDODKlh.js';
|
|
4
4
|
import { BpmnDiagramState } from '../modeling/index.js';
|
|
5
5
|
import '@xyflow/react';
|
|
6
|
-
import '../types-
|
|
6
|
+
import '../types-BYN4Zuee.js';
|
|
7
|
+
import '../types-D7zel9dq.js';
|
|
7
8
|
import '@aranzatech/diagrams-core';
|
|
8
9
|
import '@aranzatech/diagrams-core/serialization';
|
|
9
|
-
import '../catalog-
|
|
10
|
+
import '../catalog-Q1QmKLDD.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* ELK-based auto-layout for BPMN diagrams.
|
package/dist/layout/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { bpmnElkLayout } from '../chunk-
|
|
2
|
-
import { getBpmnNodeSize } from '../chunk-
|
|
1
|
+
export { bpmnElkLayout } from '../chunk-FFWJA5BV.js';
|
|
2
|
+
import { getBpmnNodeSize } from '../chunk-YAYZW45I.js';
|
|
3
3
|
import '../chunk-RLAJNRF2.js';
|
|
4
4
|
import '../chunk-L5Z22RLX.js';
|
|
5
5
|
import { dagreLayout, applyLayoutResultToDiagram } from '@aranzatech/diagrams-core/layout';
|
|
@@ -525,7 +525,7 @@ async function bpmnCustomLayout(nodes, edges) {
|
|
|
525
525
|
const lanes = nodes.filter((n) => n.data.elementType === "Lane");
|
|
526
526
|
const content = nodes.filter((n) => !LAYOUT_CONTAINER_TYPES.has(n.data.elementType));
|
|
527
527
|
if (pools.length === 0) {
|
|
528
|
-
const { bpmnElkLayout: bpmnElkLayout2 } = await import('../elk-
|
|
528
|
+
const { bpmnElkLayout: bpmnElkLayout2 } = await import('../elk-QT7H4252.js');
|
|
529
529
|
return bpmnElkLayout2(nodes, edges);
|
|
530
530
|
}
|
|
531
531
|
const poolIds = new Set(pools.map((p) => p.id));
|
package/dist/modeling/index.cjs
CHANGED
|
@@ -724,6 +724,13 @@ var BPMN_POOL_LANE_LAYOUT = {
|
|
|
724
724
|
verticalPoolHeaderSize: 28,
|
|
725
725
|
minLaneSize: 96
|
|
726
726
|
};
|
|
727
|
+
var BPMN_POOL_LANE_STACK_LAYOUT = {
|
|
728
|
+
poolInnerPad: 8,
|
|
729
|
+
laneGap: 8,
|
|
730
|
+
minLaneWidth: 240,
|
|
731
|
+
minLaneHeight: 80,
|
|
732
|
+
defaultLaneHeight: 120
|
|
733
|
+
};
|
|
727
734
|
function getBpmnDragHandleSelector(elementType) {
|
|
728
735
|
if (elementType === "Pool") return ".pool-drag-handle";
|
|
729
736
|
if (elementType === "Lane") return ".lane-drag-handle";
|
|
@@ -794,7 +801,9 @@ function inferBpmnEdgeType(state, sourceId, targetId) {
|
|
|
794
801
|
if (source.data.elementType === "Conversation" || source.data.elementType === "SubConversation" || source.data.elementType === "CallConversation" || target.data.elementType === "Conversation" || target.data.elementType === "SubConversation" || target.data.elementType === "CallConversation") {
|
|
795
802
|
return "conversationLink";
|
|
796
803
|
}
|
|
797
|
-
|
|
804
|
+
const sourcePoolId = getAncestorContainerId(state, source, "Pool");
|
|
805
|
+
const targetPoolId = getAncestorContainerId(state, target, "Pool");
|
|
806
|
+
if (sourcePoolId && targetPoolId && sourcePoolId !== targetPoolId) {
|
|
798
807
|
return "messageFlow";
|
|
799
808
|
}
|
|
800
809
|
return "sequenceFlow";
|
|
@@ -852,6 +861,35 @@ function getBpmnNodeBounds(state, node) {
|
|
|
852
861
|
height: size.height
|
|
853
862
|
};
|
|
854
863
|
}
|
|
864
|
+
var BPMN_BOUNDARY_ATTACH_MARGIN = 32;
|
|
865
|
+
function clampBoundaryCoordinate(value, min, max) {
|
|
866
|
+
return Math.min(max, Math.max(min, value));
|
|
867
|
+
}
|
|
868
|
+
function isPointInsideExpandedBounds(point, origin, size) {
|
|
869
|
+
return point.x >= origin.x - BPMN_BOUNDARY_ATTACH_MARGIN && point.x <= origin.x + size.width + BPMN_BOUNDARY_ATTACH_MARGIN && point.y >= origin.y - BPMN_BOUNDARY_ATTACH_MARGIN && point.y <= origin.y + size.height + BPMN_BOUNDARY_ATTACH_MARGIN;
|
|
870
|
+
}
|
|
871
|
+
function snapBoundaryCenterToHostBorder(center, hostOrigin, hostSize) {
|
|
872
|
+
const distances = [
|
|
873
|
+
{ side: "left", value: Math.abs(center.x - hostOrigin.x) },
|
|
874
|
+
{ side: "right", value: Math.abs(center.x - (hostOrigin.x + hostSize.width)) },
|
|
875
|
+
{ side: "top", value: Math.abs(center.y - hostOrigin.y) },
|
|
876
|
+
{ side: "bottom", value: Math.abs(center.y - (hostOrigin.y + hostSize.height)) }
|
|
877
|
+
].sort((a, b) => a.value - b.value);
|
|
878
|
+
const side = distances[0]?.side;
|
|
879
|
+
if (side === "left") {
|
|
880
|
+
return { x: hostOrigin.x, y: clampBoundaryCoordinate(center.y, hostOrigin.y, hostOrigin.y + hostSize.height) };
|
|
881
|
+
}
|
|
882
|
+
if (side === "right") {
|
|
883
|
+
return { x: hostOrigin.x + hostSize.width, y: clampBoundaryCoordinate(center.y, hostOrigin.y, hostOrigin.y + hostSize.height) };
|
|
884
|
+
}
|
|
885
|
+
if (side === "top") {
|
|
886
|
+
return { x: clampBoundaryCoordinate(center.x, hostOrigin.x, hostOrigin.x + hostSize.width), y: hostOrigin.y };
|
|
887
|
+
}
|
|
888
|
+
return {
|
|
889
|
+
x: clampBoundaryCoordinate(center.x, hostOrigin.x, hostOrigin.x + hostSize.width),
|
|
890
|
+
y: hostOrigin.y + hostSize.height
|
|
891
|
+
};
|
|
892
|
+
}
|
|
855
893
|
function findBpmnLaneAt(state, position) {
|
|
856
894
|
return state.nodes.find((node) => {
|
|
857
895
|
if (node.data.elementType !== "Lane") return false;
|
|
@@ -867,6 +905,14 @@ function getAncestorLaneId(state, node) {
|
|
|
867
905
|
}
|
|
868
906
|
return void 0;
|
|
869
907
|
}
|
|
908
|
+
function getAncestorContainerId(state, node, elementType) {
|
|
909
|
+
let current = node;
|
|
910
|
+
while (current) {
|
|
911
|
+
if (current.data.elementType === elementType) return current.id;
|
|
912
|
+
current = current.parentId ? diagramsCore.getNode(state, current.parentId) : void 0;
|
|
913
|
+
}
|
|
914
|
+
return void 0;
|
|
915
|
+
}
|
|
870
916
|
function getNodeDimension(node, axis) {
|
|
871
917
|
return node[axis] ?? node.measured?.[axis] ?? getBpmnElementSize(node.data.elementType)[axis];
|
|
872
918
|
}
|
|
@@ -874,6 +920,237 @@ function getBpmnLaneOrderPosition(lane, orientation) {
|
|
|
874
920
|
const size = getBpmnNodeSize(lane);
|
|
875
921
|
return orientation === "vertical" ? lane.position.x + size.width / 2 : lane.position.y + size.height / 2;
|
|
876
922
|
}
|
|
923
|
+
function getBpmnPoolOrientation(pool) {
|
|
924
|
+
return pool.data.orientation === "vertical" ? "vertical" : "horizontal";
|
|
925
|
+
}
|
|
926
|
+
function getBpmnPoolLanesOrderedByStack(nodes, poolId, orientation) {
|
|
927
|
+
return nodes.filter((node) => node.parentId === poolId && node.data.elementType === "Lane").sort((a, b) => {
|
|
928
|
+
const aIndex = typeof a.data.laneIndex === "number" ? a.data.laneIndex : void 0;
|
|
929
|
+
const bIndex = typeof b.data.laneIndex === "number" ? b.data.laneIndex : void 0;
|
|
930
|
+
if (aIndex !== void 0 || bIndex !== void 0) return (aIndex ?? 0) - (bIndex ?? 0);
|
|
931
|
+
return orientation === "vertical" ? (a.position?.x ?? 0) - (b.position?.x ?? 0) : (a.position?.y ?? 0) - (b.position?.y ?? 0);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
function layoutBpmnPoolLaneNodesPreservingHeights(nodes, poolId) {
|
|
935
|
+
const pool = nodes.find((node) => node.id === poolId && node.data.elementType === "Pool");
|
|
936
|
+
if (!pool) return nodes;
|
|
937
|
+
const orientation = getBpmnPoolOrientation(pool);
|
|
938
|
+
const lanes = getBpmnPoolLanesOrderedByStack(nodes, pool.id, orientation);
|
|
939
|
+
if (lanes.length === 0) return withBpmnNodeZIndexes(nodes);
|
|
940
|
+
const poolW = pool.measured?.width ?? pool.width ?? 720;
|
|
941
|
+
const poolH = pool.measured?.height ?? pool.height ?? 200;
|
|
942
|
+
const pad = BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad;
|
|
943
|
+
const gap = BPMN_POOL_LANE_STACK_LAYOUT.laneGap;
|
|
944
|
+
const minLaneW = BPMN_POOL_LANE_STACK_LAYOUT.minLaneWidth;
|
|
945
|
+
const minLaneH = BPMN_POOL_LANE_STACK_LAYOUT.minLaneHeight;
|
|
946
|
+
const defaultLaneH = BPMN_POOL_LANE_STACK_LAYOUT.defaultLaneHeight;
|
|
947
|
+
if (orientation === "vertical") {
|
|
948
|
+
const laneWidth2 = Math.max(
|
|
949
|
+
minLaneW,
|
|
950
|
+
Math.floor((poolW - pad * 2 - gap * Math.max(0, lanes.length - 1)) / Math.max(1, lanes.length))
|
|
951
|
+
);
|
|
952
|
+
const laneHeight = Math.max(minLaneH, poolH - pad * 2);
|
|
953
|
+
let cumX = pad;
|
|
954
|
+
const laneMap2 = new Map(
|
|
955
|
+
lanes.map((lane, index) => {
|
|
956
|
+
const nextLane = {
|
|
957
|
+
...lane,
|
|
958
|
+
position: { x: cumX, y: pad },
|
|
959
|
+
width: laneWidth2,
|
|
960
|
+
height: laneHeight,
|
|
961
|
+
parentId: pool.id,
|
|
962
|
+
data: { ...lane.data, orientation: "vertical", laneIndex: index }
|
|
963
|
+
};
|
|
964
|
+
cumX += laneWidth2 + gap;
|
|
965
|
+
return [lane.id, nextLane];
|
|
966
|
+
})
|
|
967
|
+
);
|
|
968
|
+
const requiredPoolW = cumX - gap + pad;
|
|
969
|
+
return withBpmnNodeZIndexes(
|
|
970
|
+
nodes.map(
|
|
971
|
+
(node) => laneMap2.get(node.id) ?? (node.id === pool.id ? { ...pool, width: Math.max(requiredPoolW, poolW) } : node)
|
|
972
|
+
)
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
const laneWidth = Math.max(minLaneW, poolW - pad * 2);
|
|
976
|
+
let cumY = pad;
|
|
977
|
+
const laneMap = new Map(
|
|
978
|
+
lanes.map((lane, index) => {
|
|
979
|
+
const laneHeight = Math.max(minLaneH, lane.measured?.height ?? lane.height ?? defaultLaneH);
|
|
980
|
+
const nextLane = {
|
|
981
|
+
...lane,
|
|
982
|
+
position: { x: pad, y: cumY },
|
|
983
|
+
width: laneWidth,
|
|
984
|
+
height: laneHeight,
|
|
985
|
+
parentId: pool.id,
|
|
986
|
+
data: { ...lane.data, orientation: "horizontal", laneIndex: index }
|
|
987
|
+
};
|
|
988
|
+
cumY += laneHeight + gap;
|
|
989
|
+
return [lane.id, nextLane];
|
|
990
|
+
})
|
|
991
|
+
);
|
|
992
|
+
const requiredPoolH = cumY - gap + pad;
|
|
993
|
+
return withBpmnNodeZIndexes(
|
|
994
|
+
nodes.map(
|
|
995
|
+
(node) => laneMap.get(node.id) ?? (node.id === pool.id ? { ...pool, height: Math.max(requiredPoolH, poolH) } : node)
|
|
996
|
+
)
|
|
997
|
+
);
|
|
998
|
+
}
|
|
999
|
+
function reorderBpmnPoolLaneAfterDropPreservingHeights(nodes, laneId) {
|
|
1000
|
+
const lane = nodes.find((node) => node.id === laneId && node.data.elementType === "Lane");
|
|
1001
|
+
if (!lane?.parentId) return nodes;
|
|
1002
|
+
const pool = nodes.find((node) => node.id === lane.parentId && node.data.elementType === "Pool");
|
|
1003
|
+
if (!pool) return nodes;
|
|
1004
|
+
const orientation = getBpmnPoolOrientation(pool);
|
|
1005
|
+
const lanes = getBpmnPoolLanesOrderedByStack(nodes, pool.id, orientation);
|
|
1006
|
+
const moved = lanes.find((candidate) => candidate.id === lane.id);
|
|
1007
|
+
if (!moved) return layoutBpmnPoolLaneNodesPreservingHeights(nodes, pool.id);
|
|
1008
|
+
const withoutMoved = lanes.filter((candidate) => candidate.id !== lane.id);
|
|
1009
|
+
const movedCenter = orientation === "vertical" ? (lane.position?.x ?? 0) + (lane.width ?? 0) / 2 : (lane.position?.y ?? 0) + (lane.height ?? 0) / 2;
|
|
1010
|
+
const insertIndex = withoutMoved.findIndex((candidate) => {
|
|
1011
|
+
const candidateCenter = orientation === "vertical" ? (candidate.position?.x ?? 0) + (candidate.width ?? 0) / 2 : (candidate.position?.y ?? 0) + (candidate.height ?? 0) / 2;
|
|
1012
|
+
return movedCenter < candidateCenter;
|
|
1013
|
+
});
|
|
1014
|
+
const ordered = [...withoutMoved];
|
|
1015
|
+
ordered.splice(insertIndex === -1 ? ordered.length : insertIndex, 0, moved);
|
|
1016
|
+
const orderedMap = new Map(ordered.map((candidate, index) => [candidate.id, index]));
|
|
1017
|
+
return layoutBpmnPoolLaneNodesPreservingHeights(
|
|
1018
|
+
nodes.map(
|
|
1019
|
+
(node) => node.parentId === pool.id && node.data.elementType === "Lane" ? { ...node, data: { ...node.data, laneIndex: orderedMap.get(node.id) ?? 0 } } : node
|
|
1020
|
+
),
|
|
1021
|
+
pool.id
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function getAppendedBpmnLaneFrame(nodes, poolOrId) {
|
|
1025
|
+
const pool = typeof poolOrId === "string" ? nodes.find((node) => node.id === poolOrId && node.data.elementType === "Pool") : poolOrId;
|
|
1026
|
+
if (!pool || pool.data.elementType !== "Pool") return null;
|
|
1027
|
+
const orientation = getBpmnPoolOrientation(pool);
|
|
1028
|
+
const existingLanes = getBpmnPoolLanesOrderedByStack(nodes, pool.id, orientation);
|
|
1029
|
+
const poolW = pool.measured?.width ?? pool.width ?? 600;
|
|
1030
|
+
const poolH = pool.measured?.height ?? pool.height ?? 400;
|
|
1031
|
+
const pad = BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad;
|
|
1032
|
+
const gap = BPMN_POOL_LANE_STACK_LAYOUT.laneGap;
|
|
1033
|
+
const minLaneW = BPMN_POOL_LANE_STACK_LAYOUT.minLaneWidth;
|
|
1034
|
+
const minLaneH = BPMN_POOL_LANE_STACK_LAYOUT.minLaneHeight;
|
|
1035
|
+
const defaultLaneH = BPMN_POOL_LANE_STACK_LAYOUT.defaultLaneHeight;
|
|
1036
|
+
if (orientation === "horizontal") {
|
|
1037
|
+
const lastLane2 = existingLanes[existingLanes.length - 1];
|
|
1038
|
+
return {
|
|
1039
|
+
position: {
|
|
1040
|
+
x: pad,
|
|
1041
|
+
y: lastLane2 ? (lastLane2.position?.y ?? pad) + (lastLane2.height ?? defaultLaneH) + gap : pad
|
|
1042
|
+
},
|
|
1043
|
+
width: Math.max(minLaneW, poolW - pad * 2),
|
|
1044
|
+
height: existingLanes.length === 0 ? Math.max(minLaneH, poolH - pad * 2) : defaultLaneH,
|
|
1045
|
+
laneIndex: existingLanes.length,
|
|
1046
|
+
orientation
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
const lastLane = existingLanes[existingLanes.length - 1];
|
|
1050
|
+
return {
|
|
1051
|
+
position: {
|
|
1052
|
+
x: lastLane ? (lastLane.position?.x ?? pad) + (lastLane.width ?? defaultLaneH) + gap : pad,
|
|
1053
|
+
y: pad
|
|
1054
|
+
},
|
|
1055
|
+
width: existingLanes.length === 0 ? Math.max(minLaneW, poolW - pad * 2) : defaultLaneH,
|
|
1056
|
+
height: Math.max(minLaneH, poolH - pad * 2),
|
|
1057
|
+
laneIndex: existingLanes.length,
|
|
1058
|
+
orientation
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function getBpmnPoolLaneNodeMaxSize(state, nodeId) {
|
|
1062
|
+
const n = diagramsCore.getNode(state, nodeId);
|
|
1063
|
+
if (n?.data.elementType === "Lane" && n.parentId) {
|
|
1064
|
+
const pool = diagramsCore.getNode(state, n.parentId);
|
|
1065
|
+
if (pool) {
|
|
1066
|
+
const siblings = state.nodes.filter(
|
|
1067
|
+
(x) => x.parentId === n.parentId && x.data.elementType === "Lane" && x.id !== n.id
|
|
1068
|
+
);
|
|
1069
|
+
const poolH = pool.measured?.height ?? pool.height ?? 500;
|
|
1070
|
+
const siblingsMinH = siblings.length * BPMN_POOL_LANE_STACK_LAYOUT.minLaneHeight;
|
|
1071
|
+
const siblingGaps = siblings.length * BPMN_POOL_LANE_STACK_LAYOUT.laneGap;
|
|
1072
|
+
const maxH = Math.max(
|
|
1073
|
+
BPMN_POOL_LANE_STACK_LAYOUT.minLaneHeight,
|
|
1074
|
+
poolH - BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad * 2 - siblingsMinH - siblingGaps
|
|
1075
|
+
);
|
|
1076
|
+
return {
|
|
1077
|
+
width: (pool.width ?? 720) - BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad * 2,
|
|
1078
|
+
height: maxH
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return void 0;
|
|
1083
|
+
}
|
|
1084
|
+
function getBpmnPoolLaneNodeMinSize(state, nodeId) {
|
|
1085
|
+
const n = diagramsCore.getNode(state, nodeId);
|
|
1086
|
+
if (n?.data.elementType === "Pool") {
|
|
1087
|
+
const lanes = state.nodes.filter((x) => x.parentId === nodeId && x.data.elementType === "Lane");
|
|
1088
|
+
if (lanes.length > 0) {
|
|
1089
|
+
const minW = Math.max(...lanes.map((l) => (l.width ?? 0) + BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad * 2));
|
|
1090
|
+
const minH = lanes.reduce((s, l) => s + (l.height ?? BPMN_POOL_LANE_STACK_LAYOUT.defaultLaneHeight), 0) + BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad * 2 + Math.max(0, lanes.length - 1) * BPMN_POOL_LANE_STACK_LAYOUT.laneGap;
|
|
1091
|
+
return { width: minW, height: minH };
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return void 0;
|
|
1095
|
+
}
|
|
1096
|
+
function applyBpmnPoolLaneDimensionChange(nodes, previousNodes, nodeId, width, height) {
|
|
1097
|
+
const node = nodes.find((candidate) => candidate.id === nodeId);
|
|
1098
|
+
const previousNode = previousNodes.find((candidate) => candidate.id === nodeId);
|
|
1099
|
+
if (!node) return nodes;
|
|
1100
|
+
const curW = previousNode?.measured?.width ?? previousNode?.width ?? 0;
|
|
1101
|
+
const curH = previousNode?.measured?.height ?? previousNode?.height ?? 0;
|
|
1102
|
+
if (Math.abs(width - curW) < 1 && Math.abs(height - curH) < 1) return nodes;
|
|
1103
|
+
const pad = BPMN_POOL_LANE_STACK_LAYOUT.poolInnerPad;
|
|
1104
|
+
const gap = BPMN_POOL_LANE_STACK_LAYOUT.laneGap;
|
|
1105
|
+
const minLaneW = BPMN_POOL_LANE_STACK_LAYOUT.minLaneWidth;
|
|
1106
|
+
const defaultLaneH = BPMN_POOL_LANE_STACK_LAYOUT.defaultLaneHeight;
|
|
1107
|
+
if (node.data.elementType === "Pool") {
|
|
1108
|
+
const targetLaneW = Math.max(minLaneW, width - pad * 2);
|
|
1109
|
+
return nodes.map(
|
|
1110
|
+
(candidate) => candidate.parentId === node.id && candidate.data.elementType === "Lane" ? {
|
|
1111
|
+
...candidate,
|
|
1112
|
+
width: targetLaneW,
|
|
1113
|
+
measured: {
|
|
1114
|
+
width: targetLaneW,
|
|
1115
|
+
height: candidate.measured?.height ?? candidate.height ?? defaultLaneH
|
|
1116
|
+
},
|
|
1117
|
+
position: { x: pad, y: candidate.position?.y ?? pad }
|
|
1118
|
+
} : candidate
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
if (node.data.elementType === "Lane" && node.parentId) {
|
|
1122
|
+
const pool = nodes.find((candidate) => candidate.id === node.parentId && candidate.data.elementType === "Pool");
|
|
1123
|
+
if (!pool) return nodes;
|
|
1124
|
+
const poolW = Math.max(width + pad * 2, pool.measured?.width ?? pool.width ?? 720);
|
|
1125
|
+
const sortedLanes = getBpmnPoolLanesOrderedByStack(nodes, node.parentId, "horizontal");
|
|
1126
|
+
let cumY = pad;
|
|
1127
|
+
const laneMap = /* @__PURE__ */ new Map();
|
|
1128
|
+
for (const lane of sortedLanes) {
|
|
1129
|
+
const laneH = lane.id === node.id ? height : lane.measured?.height ?? lane.height ?? defaultLaneH;
|
|
1130
|
+
laneMap.set(lane.id, {
|
|
1131
|
+
...lane,
|
|
1132
|
+
width,
|
|
1133
|
+
height: laneH,
|
|
1134
|
+
measured: { width, height: laneH },
|
|
1135
|
+
position: { x: pad, y: cumY }
|
|
1136
|
+
});
|
|
1137
|
+
cumY += laneH + gap;
|
|
1138
|
+
}
|
|
1139
|
+
const newPoolH = cumY - gap + pad;
|
|
1140
|
+
return nodes.map((candidate) => {
|
|
1141
|
+
if (candidate.id === pool.id) {
|
|
1142
|
+
return {
|
|
1143
|
+
...candidate,
|
|
1144
|
+
width: poolW,
|
|
1145
|
+
height: newPoolH,
|
|
1146
|
+
measured: { width: poolW, height: newPoolH }
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
return laneMap.get(candidate.id) ?? candidate;
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
return nodes;
|
|
1153
|
+
}
|
|
877
1154
|
function resizeHorizontalBpmnLanes(lanes, pool) {
|
|
878
1155
|
const pad = BPMN_POOL_LANE_LAYOUT.poolPad;
|
|
879
1156
|
const poolSize = getBpmnNodeSize(pool);
|
|
@@ -1041,6 +1318,66 @@ function resolveBpmnDropTarget(state, options) {
|
|
|
1041
1318
|
function getBpmnNodeCenter(node, absolutePosition) {
|
|
1042
1319
|
return diagramsCore.getNodeCenterPosition(absolutePosition, getBpmnNodeSize(node));
|
|
1043
1320
|
}
|
|
1321
|
+
function getBoundaryEventAttachment(state, boundaryNode) {
|
|
1322
|
+
if (boundaryNode.data.elementType !== "BoundaryEvent") return null;
|
|
1323
|
+
const boundaryOrigin = getBpmnNodeAbsolutePosition(state, boundaryNode) ?? boundaryNode.position;
|
|
1324
|
+
const boundarySize = getBpmnNodeSize(boundaryNode);
|
|
1325
|
+
const boundaryCenter = {
|
|
1326
|
+
x: boundaryOrigin.x + boundarySize.width / 2,
|
|
1327
|
+
y: boundaryOrigin.y + boundarySize.height / 2
|
|
1328
|
+
};
|
|
1329
|
+
const candidates = state.nodes.filter((node) => node.id !== boundaryNode.id && acceptsBoundaryEvents(node.data.elementType)).map((node) => {
|
|
1330
|
+
const origin = getBpmnNodeAbsolutePosition(state, node) ?? node.position;
|
|
1331
|
+
const size = getBpmnNodeSize(node);
|
|
1332
|
+
const hostCenter = { x: origin.x + size.width / 2, y: origin.y + size.height / 2 };
|
|
1333
|
+
return {
|
|
1334
|
+
node,
|
|
1335
|
+
origin,
|
|
1336
|
+
size,
|
|
1337
|
+
distance: Math.hypot(boundaryCenter.x - hostCenter.x, boundaryCenter.y - hostCenter.y)
|
|
1338
|
+
};
|
|
1339
|
+
}).filter(({ origin, size }) => isPointInsideExpandedBounds(boundaryCenter, origin, size)).sort((a, b) => a.distance - b.distance);
|
|
1340
|
+
const host = candidates[0];
|
|
1341
|
+
if (!host) return null;
|
|
1342
|
+
const snappedCenter = snapBoundaryCenterToHostBorder(boundaryCenter, host.origin, host.size);
|
|
1343
|
+
return {
|
|
1344
|
+
hostId: host.node.id,
|
|
1345
|
+
position: {
|
|
1346
|
+
x: snappedCenter.x - host.origin.x - boundarySize.width / 2,
|
|
1347
|
+
y: snappedCenter.y - host.origin.y - boundarySize.height / 2
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
function getBpmnEdgeLaneContext(state, edgeOrId) {
|
|
1352
|
+
const edge = typeof edgeOrId === "string" ? state.edges.find((candidate) => candidate.id === edgeOrId) : edgeOrId;
|
|
1353
|
+
if (!edge) return void 0;
|
|
1354
|
+
const source = diagramsCore.getNode(state, edge.source);
|
|
1355
|
+
const target = diagramsCore.getNode(state, edge.target);
|
|
1356
|
+
if (!source || !target) return void 0;
|
|
1357
|
+
const sourceLaneId = getAncestorLaneId(state, source);
|
|
1358
|
+
const targetLaneId = getAncestorLaneId(state, target);
|
|
1359
|
+
const sourcePoolId = getAncestorContainerId(state, source, "Pool");
|
|
1360
|
+
const targetPoolId = getAncestorContainerId(state, target, "Pool");
|
|
1361
|
+
const sameLane = Boolean(sourceLaneId) && sourceLaneId === targetLaneId;
|
|
1362
|
+
const samePool = Boolean(sourcePoolId) && sourcePoolId === targetPoolId;
|
|
1363
|
+
const crossesLanesWithinPool = Boolean(
|
|
1364
|
+
sourceLaneId && targetLaneId && sourceLaneId !== targetLaneId && samePool
|
|
1365
|
+
);
|
|
1366
|
+
const crossesPools = Boolean(
|
|
1367
|
+
sourcePoolId && targetPoolId && sourcePoolId !== targetPoolId
|
|
1368
|
+
);
|
|
1369
|
+
return {
|
|
1370
|
+
edgeId: edge.id,
|
|
1371
|
+
...sourceLaneId ? { sourceLaneId } : {},
|
|
1372
|
+
...targetLaneId ? { targetLaneId } : {},
|
|
1373
|
+
...sourcePoolId ? { sourcePoolId } : {},
|
|
1374
|
+
...targetPoolId ? { targetPoolId } : {},
|
|
1375
|
+
sameLane,
|
|
1376
|
+
samePool,
|
|
1377
|
+
crossesLanesWithinPool,
|
|
1378
|
+
crossesPools
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1044
1381
|
function resolvePoolLaneDirection(pool) {
|
|
1045
1382
|
return pool.data.orientation === "vertical" ? "horizontal" : "vertical";
|
|
1046
1383
|
}
|
|
@@ -1130,6 +1467,14 @@ function validateBpmnConnectionForEdgeType(state, edgeType, source, target) {
|
|
|
1130
1467
|
}
|
|
1131
1468
|
return true;
|
|
1132
1469
|
}
|
|
1470
|
+
function resolveBpmnConnection(state, sourceId, targetId, requestedType) {
|
|
1471
|
+
const source = diagramsCore.getNode(state, sourceId);
|
|
1472
|
+
const target = diagramsCore.getNode(state, targetId);
|
|
1473
|
+
if (!source || !target) return { ok: false, reason: "No se encontr\xF3 el origen o destino." };
|
|
1474
|
+
const validation = validateBpmnConnectionForEdgeType(state, requestedType, source, target);
|
|
1475
|
+
if (validation !== true) return { ok: false, reason: validation };
|
|
1476
|
+
return { ok: true, edgeType: requestedType };
|
|
1477
|
+
}
|
|
1133
1478
|
function validateEdgeCardinality(state, edgeType, source, target) {
|
|
1134
1479
|
if (edgeType !== "sequenceFlow") return true;
|
|
1135
1480
|
const sourceMax = BPMN_ELEMENT_CATALOG[source.data.elementType].maxOutgoing;
|
|
@@ -1317,6 +1662,28 @@ function reparentBpmnNodeAtPosition(state, options) {
|
|
|
1317
1662
|
});
|
|
1318
1663
|
}
|
|
1319
1664
|
var BE_HALF = 18;
|
|
1665
|
+
function getBoundarySpanRatio(value, size) {
|
|
1666
|
+
const min = BE_HALF;
|
|
1667
|
+
const max = size - BE_HALF;
|
|
1668
|
+
if (max <= min) return 0.5;
|
|
1669
|
+
return (clampBoundaryCoordinate(value, min, max) - min) / (max - min);
|
|
1670
|
+
}
|
|
1671
|
+
function fromBoundarySpanRatio(ratio, size) {
|
|
1672
|
+
const min = BE_HALF;
|
|
1673
|
+
const max = size - BE_HALF;
|
|
1674
|
+
if (max <= min) return size / 2;
|
|
1675
|
+
return min + (max - min) * ratio;
|
|
1676
|
+
}
|
|
1677
|
+
function detectBoundarySide(center, hostSize) {
|
|
1678
|
+
const distances = [
|
|
1679
|
+
{ side: "left", value: Math.abs(center.x) },
|
|
1680
|
+
{ side: "right", value: Math.abs(center.x - hostSize.width) },
|
|
1681
|
+
{ side: "top", value: Math.abs(center.y) },
|
|
1682
|
+
{ side: "bottom", value: Math.abs(center.y - hostSize.height) }
|
|
1683
|
+
];
|
|
1684
|
+
distances.sort((a, b) => a.value - b.value);
|
|
1685
|
+
return distances[0]?.side ?? "bottom";
|
|
1686
|
+
}
|
|
1320
1687
|
function clampBoundaryEventsAfterResize(state, hostId, oldW, oldH, newW, newH) {
|
|
1321
1688
|
const boundaryEvents = state.nodes.filter(
|
|
1322
1689
|
(n) => n.data.elementType === "BoundaryEvent" && n.parentId === hostId
|
|
@@ -1327,25 +1694,21 @@ function clampBoundaryEventsAfterResize(state, hostId, oldW, oldH, newW, newH) {
|
|
|
1327
1694
|
const py = be.position?.y ?? 0;
|
|
1328
1695
|
const cx = px + BE_HALF;
|
|
1329
1696
|
const cy = py + BE_HALF;
|
|
1330
|
-
const
|
|
1331
|
-
const distRight = Math.abs(cx - oldW);
|
|
1332
|
-
const distTop = Math.abs(cy);
|
|
1333
|
-
const distBottom = Math.abs(cy - oldH);
|
|
1334
|
-
const minDist = Math.min(distLeft, distRight, distTop, distBottom);
|
|
1697
|
+
const side = detectBoundarySide({ x: cx, y: cy }, { width: oldW, height: oldH });
|
|
1335
1698
|
let newCx;
|
|
1336
1699
|
let newCy;
|
|
1337
|
-
if (
|
|
1700
|
+
if (side === "bottom") {
|
|
1338
1701
|
newCy = newH;
|
|
1339
|
-
newCx =
|
|
1340
|
-
} else if (
|
|
1702
|
+
newCx = fromBoundarySpanRatio(getBoundarySpanRatio(cx, oldW), newW);
|
|
1703
|
+
} else if (side === "right") {
|
|
1341
1704
|
newCx = newW;
|
|
1342
|
-
newCy =
|
|
1343
|
-
} else if (
|
|
1705
|
+
newCy = fromBoundarySpanRatio(getBoundarySpanRatio(cy, oldH), newH);
|
|
1706
|
+
} else if (side === "top") {
|
|
1344
1707
|
newCy = 0;
|
|
1345
|
-
newCx =
|
|
1708
|
+
newCx = fromBoundarySpanRatio(getBoundarySpanRatio(cx, oldW), newW);
|
|
1346
1709
|
} else {
|
|
1347
1710
|
newCx = 0;
|
|
1348
|
-
newCy =
|
|
1711
|
+
newCy = fromBoundarySpanRatio(getBoundarySpanRatio(cy, oldH), newH);
|
|
1349
1712
|
}
|
|
1350
1713
|
next = diagramsCore.moveNode(next, be.id, { x: newCx - BE_HALF, y: newCy - BE_HALF });
|
|
1351
1714
|
}
|
|
@@ -1612,8 +1975,10 @@ function withBpmnLayoutCache(layoutFn, cache) {
|
|
|
1612
1975
|
exports.BPMN_EDGE_CONNECTION_RULES = BPMN_EDGE_CONNECTION_RULES;
|
|
1613
1976
|
exports.BPMN_MODELING_RULES = BPMN_MODELING_RULES;
|
|
1614
1977
|
exports.BPMN_POOL_LANE_LAYOUT = BPMN_POOL_LANE_LAYOUT;
|
|
1978
|
+
exports.BPMN_POOL_LANE_STACK_LAYOUT = BPMN_POOL_LANE_STACK_LAYOUT;
|
|
1615
1979
|
exports.BPMN_ROUTABLE_EDGE_TYPES = BPMN_ROUTABLE_EDGE_TYPES;
|
|
1616
1980
|
exports.BPMN_SELECTION_STYLE = BPMN_SELECTION_STYLE;
|
|
1981
|
+
exports.applyBpmnPoolLaneDimensionChange = applyBpmnPoolLaneDimensionChange;
|
|
1617
1982
|
exports.attachBoundaryEventCommand = attachBoundaryEventCommand;
|
|
1618
1983
|
exports.bpmnConnectionValidators = bpmnConnectionValidators;
|
|
1619
1984
|
exports.canContainBpmnElement = canContainBpmnElement;
|
|
@@ -1629,15 +1994,21 @@ exports.deleteBpmnElementsCommand = deleteBpmnElementsCommand;
|
|
|
1629
1994
|
exports.deserializeBpmnDiagram = deserializeBpmnDiagram;
|
|
1630
1995
|
exports.deserializeBpmnDiagramSnapshot = deserializeBpmnDiagramSnapshot;
|
|
1631
1996
|
exports.findBpmnContainerAt = findBpmnContainerAt;
|
|
1997
|
+
exports.getAppendedBpmnLaneFrame = getAppendedBpmnLaneFrame;
|
|
1998
|
+
exports.getBoundaryEventAttachment = getBoundaryEventAttachment;
|
|
1632
1999
|
exports.getBpmnDragHandleSelector = getBpmnDragHandleSelector;
|
|
1633
2000
|
exports.getBpmnEdgeLabelLayout = getBpmnEdgeLabelLayout;
|
|
2001
|
+
exports.getBpmnEdgeLaneContext = getBpmnEdgeLaneContext;
|
|
1634
2002
|
exports.getBpmnElementSize = getBpmnElementSize;
|
|
1635
2003
|
exports.getBpmnLaneIndexAtPosition = getBpmnLaneIndexAtPosition;
|
|
1636
2004
|
exports.getBpmnNodeAbsolutePosition = getBpmnNodeAbsolutePosition;
|
|
1637
2005
|
exports.getBpmnNodeCenter = getBpmnNodeCenter;
|
|
1638
2006
|
exports.getBpmnNodeSize = getBpmnNodeSize;
|
|
1639
2007
|
exports.getBpmnNodeZIndex = getBpmnNodeZIndex;
|
|
2008
|
+
exports.getBpmnPoolLaneNodeMaxSize = getBpmnPoolLaneNodeMaxSize;
|
|
2009
|
+
exports.getBpmnPoolLaneNodeMinSize = getBpmnPoolLaneNodeMinSize;
|
|
1640
2010
|
exports.getBpmnPoolLanes = getBpmnPoolLanes;
|
|
2011
|
+
exports.getBpmnPoolOrientation = getBpmnPoolOrientation;
|
|
1641
2012
|
exports.getBpmnTabOrder = getBpmnTabOrder;
|
|
1642
2013
|
exports.groupAsBpmnSubProcessCommand = groupAsBpmnSubProcessCommand;
|
|
1643
2014
|
exports.inferBpmnEdgeType = inferBpmnEdgeType;
|
|
@@ -1646,6 +2017,7 @@ exports.isBpmnEdgeRoutingEditable = isBpmnEdgeRoutingEditable;
|
|
|
1646
2017
|
exports.isBpmnElementResizable = isBpmnElementResizable;
|
|
1647
2018
|
exports.isBpmnProcessNode = isBpmnProcessNode;
|
|
1648
2019
|
exports.layoutBpmnPoolLaneNodes = layoutBpmnPoolLaneNodes;
|
|
2020
|
+
exports.layoutBpmnPoolLaneNodesPreservingHeights = layoutBpmnPoolLaneNodesPreservingHeights;
|
|
1649
2021
|
exports.layoutBpmnPoolLanes = layoutBpmnPoolLanes;
|
|
1650
2022
|
exports.moveBpmnLaneCommand = moveBpmnLaneCommand;
|
|
1651
2023
|
exports.parseBpmnDiagramDocument = parseBpmnDiagramDocument;
|
|
@@ -1654,11 +2026,13 @@ exports.persistBpmnHistory = persistBpmnHistory;
|
|
|
1654
2026
|
exports.reorderBpmnLane = reorderBpmnLane;
|
|
1655
2027
|
exports.reorderBpmnLaneAfterDrop = reorderBpmnLaneAfterDrop;
|
|
1656
2028
|
exports.reorderBpmnLaneCommand = reorderBpmnLaneCommand;
|
|
2029
|
+
exports.reorderBpmnPoolLaneAfterDropPreservingHeights = reorderBpmnPoolLaneAfterDropPreservingHeights;
|
|
1657
2030
|
exports.reparentBpmnNodeAtPosition = reparentBpmnNodeAtPosition;
|
|
1658
2031
|
exports.reparentBpmnNodeCommand = reparentBpmnNodeCommand;
|
|
1659
2032
|
exports.replaceBpmnNodeCommand = replaceBpmnNodeCommand;
|
|
1660
2033
|
exports.resizeBpmnNodeByHandleCommand = resizeBpmnNodeByHandleCommand;
|
|
1661
2034
|
exports.resizeBpmnNodeCommand = resizeBpmnNodeCommand;
|
|
2035
|
+
exports.resolveBpmnConnection = resolveBpmnConnection;
|
|
1662
2036
|
exports.resolveBpmnDropTarget = resolveBpmnDropTarget;
|
|
1663
2037
|
exports.restoreBpmnHistory = restoreBpmnHistory;
|
|
1664
2038
|
exports.routeBpmnEdgeCommand = routeBpmnEdgeCommand;
|