@aranzatech/diagrams-bpmn 0.2.0 → 0.2.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/CHANGELOG.md +1 -1
- package/dist/catalog-DIBySQqA.d.ts +9 -0
- package/dist/catalog-m8fHIiKH.d.cts +9 -0
- package/dist/{chunk-MF2WE3OM.js → chunk-33AR3PXF.js} +36 -8
- package/dist/chunk-33AR3PXF.js.map +1 -0
- package/dist/{chunk-3AFZDIMQ.js → chunk-ECTJRD7Z.js} +3 -3
- package/dist/{chunk-3AFZDIMQ.js.map → chunk-ECTJRD7Z.js.map} +1 -1
- package/dist/{chunk-S3GGEEA5.js → chunk-H3YMTGFG.js} +50 -32
- package/dist/chunk-H3YMTGFG.js.map +1 -0
- package/dist/chunk-KALSGH4D.js +36 -0
- package/dist/chunk-KALSGH4D.js.map +1 -0
- package/dist/{chunk-DNR5WBQH.js → chunk-L5Z22RLX.js} +81 -20
- package/dist/chunk-L5Z22RLX.js.map +1 -0
- package/dist/{chunk-57LA2WSJ.js → chunk-QOGZITWB.js} +10 -6
- package/dist/chunk-QOGZITWB.js.map +1 -0
- package/dist/{chunk-5GRCJ5X6.js → chunk-RLAJNRF2.js} +3 -3
- package/dist/{chunk-5GRCJ5X6.js.map → chunk-RLAJNRF2.js.map} +1 -1
- package/dist/chunk-YQTIODXH.js +532 -0
- package/dist/chunk-YQTIODXH.js.map +1 -0
- package/dist/chunk-ZFGQVLHB.js +226 -0
- package/dist/chunk-ZFGQVLHB.js.map +1 -0
- package/dist/edges/index.cjs +1 -1
- package/dist/edges/index.cjs.map +1 -1
- package/dist/edges/index.js +2 -2
- package/dist/elements/index.cjs +81 -17
- package/dist/elements/index.cjs.map +1 -1
- package/dist/elements/index.d.cts +4 -6
- package/dist/elements/index.d.ts +4 -6
- package/dist/elements/index.js +2 -2
- package/dist/index.cjs +697 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +9 -8
- package/dist/modeling/index.cjs +383 -36
- package/dist/modeling/index.cjs.map +1 -1
- package/dist/modeling/index.d.cts +61 -3
- package/dist/modeling/index.d.ts +61 -3
- package/dist/modeling/index.js +3 -3
- package/dist/nodes/index.cjs +62 -32
- package/dist/nodes/index.cjs.map +1 -1
- package/dist/nodes/index.js +2 -2
- package/dist/simulation/index.cjs +8 -4
- package/dist/simulation/index.cjs.map +1 -1
- package/dist/simulation/index.js +1 -1
- package/dist/{types-hj621ZRJ.d.ts → types-BxjCV2oX.d.ts} +1 -1
- package/dist/{types-BKA0GZz5.d.cts → types-DznxZxpV.d.cts} +11 -1
- package/dist/{types-BKA0GZz5.d.ts → types-DznxZxpV.d.ts} +11 -1
- package/dist/{types-CCkHqtC_.d.cts → types-vVi5T7qj.d.cts} +1 -1
- package/dist/validation/index.cjs +848 -0
- package/dist/validation/index.cjs.map +1 -0
- package/dist/validation/index.d.cts +25 -0
- package/dist/validation/index.d.ts +25 -0
- package/dist/validation/index.js +5 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/xml/index.cjs +74 -22
- package/dist/xml/index.cjs.map +1 -1
- package/dist/xml/index.d.cts +2 -2
- package/dist/xml/index.d.ts +2 -2
- package/dist/xml/index.js +2 -2
- package/package.json +8 -3
- package/dist/chunk-23B2IGK5.js +0 -24
- package/dist/chunk-23B2IGK5.js.map +0 -1
- package/dist/chunk-57LA2WSJ.js.map +0 -1
- package/dist/chunk-DNR5WBQH.js.map +0 -1
- package/dist/chunk-G5S4ASP3.js +0 -277
- package/dist/chunk-G5S4ASP3.js.map +0 -1
- package/dist/chunk-MF2WE3OM.js.map +0 -1
- package/dist/chunk-S3GGEEA5.js.map +0 -1
package/dist/modeling/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
41
41
|
},
|
|
42
42
|
IntermediateCatchEvent: {
|
|
43
43
|
label: "Intermediate Catch Event",
|
|
44
|
-
icon: "
|
|
44
|
+
icon: "Clock3",
|
|
45
45
|
category: "event",
|
|
46
46
|
defaultWidth: 36,
|
|
47
47
|
defaultHeight: 36,
|
|
@@ -55,7 +55,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
55
55
|
},
|
|
56
56
|
IntermediateThrowEvent: {
|
|
57
57
|
label: "Intermediate Throw Event",
|
|
58
|
-
icon: "
|
|
58
|
+
icon: "Send",
|
|
59
59
|
category: "event",
|
|
60
60
|
defaultWidth: 36,
|
|
61
61
|
defaultHeight: 36,
|
|
@@ -69,7 +69,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
69
69
|
},
|
|
70
70
|
BoundaryEvent: {
|
|
71
71
|
label: "Boundary Event",
|
|
72
|
-
icon: "
|
|
72
|
+
icon: "AlarmClock",
|
|
73
73
|
category: "event",
|
|
74
74
|
defaultWidth: 36,
|
|
75
75
|
defaultHeight: 36,
|
|
@@ -85,7 +85,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
85
85
|
// ─── Tasks ───────────────────────────────────────────────────────────────────
|
|
86
86
|
Task: {
|
|
87
87
|
label: "Task",
|
|
88
|
-
icon: "
|
|
88
|
+
icon: "CheckSquare",
|
|
89
89
|
category: "task",
|
|
90
90
|
defaultWidth: 120,
|
|
91
91
|
defaultHeight: 60,
|
|
@@ -99,7 +99,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
99
99
|
},
|
|
100
100
|
UserTask: {
|
|
101
101
|
label: "User Task",
|
|
102
|
-
icon: "
|
|
102
|
+
icon: "UserRound",
|
|
103
103
|
category: "task",
|
|
104
104
|
defaultWidth: 120,
|
|
105
105
|
defaultHeight: 60,
|
|
@@ -113,7 +113,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
113
113
|
},
|
|
114
114
|
ServiceTask: {
|
|
115
115
|
label: "Service Task",
|
|
116
|
-
icon: "
|
|
116
|
+
icon: "Cog",
|
|
117
117
|
category: "task",
|
|
118
118
|
defaultWidth: 120,
|
|
119
119
|
defaultHeight: 60,
|
|
@@ -155,7 +155,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
155
155
|
},
|
|
156
156
|
BusinessRuleTask: {
|
|
157
157
|
label: "Business Rule Task",
|
|
158
|
-
icon: "
|
|
158
|
+
icon: "Table2",
|
|
159
159
|
category: "task",
|
|
160
160
|
defaultWidth: 120,
|
|
161
161
|
defaultHeight: 60,
|
|
@@ -169,7 +169,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
169
169
|
},
|
|
170
170
|
ReceiveTask: {
|
|
171
171
|
label: "Receive Task",
|
|
172
|
-
icon: "
|
|
172
|
+
icon: "Inbox",
|
|
173
173
|
category: "task",
|
|
174
174
|
defaultWidth: 120,
|
|
175
175
|
defaultHeight: 60,
|
|
@@ -212,7 +212,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
212
212
|
// ─── Gateways ────────────────────────────────────────────────────────────────
|
|
213
213
|
ExclusiveGateway: {
|
|
214
214
|
label: "Exclusive Gateway",
|
|
215
|
-
icon: "
|
|
215
|
+
icon: "X",
|
|
216
216
|
category: "gateway",
|
|
217
217
|
defaultWidth: 50,
|
|
218
218
|
defaultHeight: 50,
|
|
@@ -225,7 +225,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
225
225
|
},
|
|
226
226
|
InclusiveGateway: {
|
|
227
227
|
label: "Inclusive Gateway",
|
|
228
|
-
icon: "
|
|
228
|
+
icon: "Circle",
|
|
229
229
|
category: "gateway",
|
|
230
230
|
defaultWidth: 50,
|
|
231
231
|
defaultHeight: 50,
|
|
@@ -238,7 +238,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
238
238
|
},
|
|
239
239
|
ParallelGateway: {
|
|
240
240
|
label: "Parallel Gateway",
|
|
241
|
-
icon: "
|
|
241
|
+
icon: "Plus",
|
|
242
242
|
category: "gateway",
|
|
243
243
|
defaultWidth: 50,
|
|
244
244
|
defaultHeight: 50,
|
|
@@ -279,7 +279,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
279
279
|
// ─── Containers ───────────────────────────────────────────────────────────────
|
|
280
280
|
SubProcess: {
|
|
281
281
|
label: "Sub-Process",
|
|
282
|
-
icon: "
|
|
282
|
+
icon: "PlusSquare",
|
|
283
283
|
category: "container",
|
|
284
284
|
defaultWidth: 350,
|
|
285
285
|
defaultHeight: 200,
|
|
@@ -294,7 +294,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
294
294
|
},
|
|
295
295
|
Transaction: {
|
|
296
296
|
label: "Transaction",
|
|
297
|
-
icon: "
|
|
297
|
+
icon: "Receipt",
|
|
298
298
|
category: "container",
|
|
299
299
|
defaultWidth: 350,
|
|
300
300
|
defaultHeight: 200,
|
|
@@ -309,7 +309,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
309
309
|
},
|
|
310
310
|
EventSubProcess: {
|
|
311
311
|
label: "Event Sub-Process",
|
|
312
|
-
icon: "
|
|
312
|
+
icon: "CircleDotDashed",
|
|
313
313
|
category: "container",
|
|
314
314
|
defaultWidth: 350,
|
|
315
315
|
defaultHeight: 200,
|
|
@@ -324,7 +324,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
324
324
|
},
|
|
325
325
|
AdHocSubProcess: {
|
|
326
326
|
label: "Ad-Hoc Sub-Process",
|
|
327
|
-
icon: "
|
|
327
|
+
icon: "Waves",
|
|
328
328
|
category: "container",
|
|
329
329
|
defaultWidth: 350,
|
|
330
330
|
defaultHeight: 200,
|
|
@@ -339,7 +339,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
339
339
|
},
|
|
340
340
|
Pool: {
|
|
341
341
|
label: "Pool",
|
|
342
|
-
icon: "
|
|
342
|
+
icon: "Rows3",
|
|
343
343
|
category: "container",
|
|
344
344
|
defaultWidth: 600,
|
|
345
345
|
defaultHeight: 200,
|
|
@@ -354,7 +354,7 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
354
354
|
},
|
|
355
355
|
Lane: {
|
|
356
356
|
label: "Lane",
|
|
357
|
-
icon: "
|
|
357
|
+
icon: "PanelTop",
|
|
358
358
|
category: "container",
|
|
359
359
|
defaultWidth: 600,
|
|
360
360
|
defaultHeight: 120,
|
|
@@ -570,8 +570,79 @@ var BPMN_ELEMENT_CATALOG = {
|
|
|
570
570
|
canBeEnd: false
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
|
+
function getElementMeta(type) {
|
|
574
|
+
return BPMN_ELEMENT_CATALOG[type];
|
|
575
|
+
}
|
|
576
|
+
var BPMN_RESIZABLE_ELEMENT_TYPES = [
|
|
577
|
+
"Task",
|
|
578
|
+
"UserTask",
|
|
579
|
+
"ServiceTask",
|
|
580
|
+
"ScriptTask",
|
|
581
|
+
"ManualTask",
|
|
582
|
+
"BusinessRuleTask",
|
|
583
|
+
"ReceiveTask",
|
|
584
|
+
"SendTask",
|
|
585
|
+
"CallActivity",
|
|
586
|
+
"SubProcess",
|
|
587
|
+
"Transaction",
|
|
588
|
+
"EventSubProcess",
|
|
589
|
+
"AdHocSubProcess",
|
|
590
|
+
"Pool",
|
|
591
|
+
"Lane",
|
|
592
|
+
"Annotation",
|
|
593
|
+
"Group",
|
|
594
|
+
"SubConversation",
|
|
595
|
+
"ChoreographyTask",
|
|
596
|
+
"SubChoreography",
|
|
597
|
+
"CallChoreography"
|
|
598
|
+
];
|
|
599
|
+
var BPMN_MIN_SIZE_OVERRIDES = {
|
|
600
|
+
Task: { minWidth: 80, minHeight: 48 },
|
|
601
|
+
UserTask: { minWidth: 80, minHeight: 48 },
|
|
602
|
+
ServiceTask: { minWidth: 80, minHeight: 48 },
|
|
603
|
+
ScriptTask: { minWidth: 80, minHeight: 48 },
|
|
604
|
+
ManualTask: { minWidth: 80, minHeight: 48 },
|
|
605
|
+
BusinessRuleTask: { minWidth: 80, minHeight: 48 },
|
|
606
|
+
ReceiveTask: { minWidth: 80, minHeight: 48 },
|
|
607
|
+
SendTask: { minWidth: 80, minHeight: 48 },
|
|
608
|
+
CallActivity: { minWidth: 80, minHeight: 48 },
|
|
609
|
+
SubProcess: { minWidth: 160, minHeight: 100 },
|
|
610
|
+
Transaction: { minWidth: 160, minHeight: 100 },
|
|
611
|
+
EventSubProcess: { minWidth: 160, minHeight: 100 },
|
|
612
|
+
AdHocSubProcess: { minWidth: 160, minHeight: 100 },
|
|
613
|
+
Pool: { minWidth: 240, minHeight: 120 },
|
|
614
|
+
Lane: { minWidth: 240, minHeight: 80 },
|
|
615
|
+
Annotation: { minWidth: 80, minHeight: 40 },
|
|
616
|
+
Group: { minWidth: 120, minHeight: 80 },
|
|
617
|
+
SubConversation: { minWidth: 60, minHeight: 52 },
|
|
618
|
+
ChoreographyTask: { minWidth: 100, minHeight: 70 },
|
|
619
|
+
SubChoreography: { minWidth: 100, minHeight: 70 },
|
|
620
|
+
CallChoreography: { minWidth: 100, minHeight: 70 }
|
|
621
|
+
};
|
|
622
|
+
var resizableTypes = new Set(BPMN_RESIZABLE_ELEMENT_TYPES);
|
|
623
|
+
function isBpmnElementResizable(type) {
|
|
624
|
+
return resizableTypes.has(type);
|
|
625
|
+
}
|
|
626
|
+
function getBpmnElementSize(type) {
|
|
627
|
+
const meta = getElementMeta(type);
|
|
628
|
+
const min = BPMN_MIN_SIZE_OVERRIDES[type];
|
|
629
|
+
return {
|
|
630
|
+
width: meta.defaultWidth,
|
|
631
|
+
height: meta.defaultHeight,
|
|
632
|
+
minWidth: meta.minWidth ?? min?.minWidth ?? meta.defaultWidth,
|
|
633
|
+
minHeight: meta.minHeight ?? min?.minHeight ?? meta.defaultHeight,
|
|
634
|
+
resizable: meta.resizable ?? isBpmnElementResizable(type)
|
|
635
|
+
};
|
|
636
|
+
}
|
|
573
637
|
|
|
574
638
|
// src/elements/guards.ts
|
|
639
|
+
var GATEWAY_TYPES = /* @__PURE__ */ new Set([
|
|
640
|
+
"ExclusiveGateway",
|
|
641
|
+
"InclusiveGateway",
|
|
642
|
+
"ParallelGateway",
|
|
643
|
+
"EventBasedGateway",
|
|
644
|
+
"ComplexGateway"
|
|
645
|
+
]);
|
|
575
646
|
var EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
576
647
|
"StartEvent",
|
|
577
648
|
"EndEvent",
|
|
@@ -587,6 +658,9 @@ var DATA_TYPES = /* @__PURE__ */ new Set([
|
|
|
587
658
|
"DataStore",
|
|
588
659
|
"DataStoreReference"
|
|
589
660
|
]);
|
|
661
|
+
function isGatewayType(type) {
|
|
662
|
+
return GATEWAY_TYPES.has(type);
|
|
663
|
+
}
|
|
590
664
|
function isEventType(type) {
|
|
591
665
|
return EVENT_TYPES.has(type);
|
|
592
666
|
}
|
|
@@ -602,21 +676,88 @@ function getHandlePolicy(type) {
|
|
|
602
676
|
|
|
603
677
|
// src/modeling/index.ts
|
|
604
678
|
function createBpmnNode(options) {
|
|
679
|
+
const size = getBpmnElementSize(options.elementType);
|
|
605
680
|
const meta = BPMN_ELEMENT_CATALOG[options.elementType];
|
|
681
|
+
const orientation = options.data?.orientation ?? meta.orientation;
|
|
682
|
+
const dragHandle = getBpmnDragHandleSelector(options.elementType);
|
|
606
683
|
return {
|
|
607
684
|
id: options.id,
|
|
608
685
|
type: options.elementType,
|
|
609
686
|
position: options.position,
|
|
610
687
|
data: {
|
|
611
688
|
elementType: options.elementType,
|
|
689
|
+
orientation,
|
|
612
690
|
...options.label ? { label: options.label } : {},
|
|
613
691
|
...options.data ?? {}
|
|
614
692
|
},
|
|
615
|
-
width: options.width ??
|
|
616
|
-
height: options.height ??
|
|
617
|
-
...options.parentId ? { parentId: options.parentId } : {}
|
|
693
|
+
width: options.width ?? size.width,
|
|
694
|
+
height: options.height ?? size.height,
|
|
695
|
+
...options.parentId ? { parentId: options.parentId } : {},
|
|
696
|
+
...dragHandle ? { dragHandle } : {}
|
|
618
697
|
};
|
|
619
698
|
}
|
|
699
|
+
var BPMN_POOL_LANE_LAYOUT = {
|
|
700
|
+
poolHeaderSize: 30,
|
|
701
|
+
laneHeaderSize: 24,
|
|
702
|
+
laneGap: 0
|
|
703
|
+
};
|
|
704
|
+
function getBpmnDragHandleSelector(elementType) {
|
|
705
|
+
if (elementType === "Pool") return ".pool-drag-handle";
|
|
706
|
+
if (elementType === "Lane") return ".lane-drag-handle";
|
|
707
|
+
return void 0;
|
|
708
|
+
}
|
|
709
|
+
var BPMN_SELECTION_STYLE = {
|
|
710
|
+
nodeOutline: "#2563eb",
|
|
711
|
+
edgeStroke: "#2563eb",
|
|
712
|
+
handleFill: "#ffffff",
|
|
713
|
+
handleStroke: "#2563eb",
|
|
714
|
+
resizeHandleSize: 8,
|
|
715
|
+
routingPointRadius: 5
|
|
716
|
+
};
|
|
717
|
+
var BPMN_ROUTABLE_EDGE_TYPES = [
|
|
718
|
+
"sequenceFlow",
|
|
719
|
+
"messageFlow",
|
|
720
|
+
"association",
|
|
721
|
+
"dataAssociation",
|
|
722
|
+
"conversationLink"
|
|
723
|
+
];
|
|
724
|
+
var BPMN_EDGE_CONNECTION_RULES = {
|
|
725
|
+
sequenceFlow: {
|
|
726
|
+
edgeType: "sequenceFlow",
|
|
727
|
+
sourceCategories: ["flowNode"],
|
|
728
|
+
targetCategories: ["flowNode"],
|
|
729
|
+
allowSameParent: true,
|
|
730
|
+
allowDifferentParent: false
|
|
731
|
+
},
|
|
732
|
+
messageFlow: {
|
|
733
|
+
edgeType: "messageFlow",
|
|
734
|
+
sourceCategories: ["flowNode"],
|
|
735
|
+
targetCategories: ["flowNode"],
|
|
736
|
+
allowSameParent: false,
|
|
737
|
+
allowDifferentParent: true
|
|
738
|
+
},
|
|
739
|
+
association: {
|
|
740
|
+
edgeType: "association",
|
|
741
|
+
sourceCategories: ["flowNode", "artifact", "data"],
|
|
742
|
+
targetCategories: ["flowNode", "artifact", "data"],
|
|
743
|
+
allowSameParent: true,
|
|
744
|
+
allowDifferentParent: true
|
|
745
|
+
},
|
|
746
|
+
dataAssociation: {
|
|
747
|
+
edgeType: "dataAssociation",
|
|
748
|
+
sourceCategories: ["flowNode", "data"],
|
|
749
|
+
targetCategories: ["flowNode", "data"],
|
|
750
|
+
allowSameParent: true,
|
|
751
|
+
allowDifferentParent: true
|
|
752
|
+
},
|
|
753
|
+
conversationLink: {
|
|
754
|
+
edgeType: "conversationLink",
|
|
755
|
+
sourceCategories: ["conversation", "flowNode"],
|
|
756
|
+
targetCategories: ["conversation", "flowNode"],
|
|
757
|
+
allowSameParent: true,
|
|
758
|
+
allowDifferentParent: true
|
|
759
|
+
}
|
|
760
|
+
};
|
|
620
761
|
function inferBpmnEdgeType(state, sourceId, targetId) {
|
|
621
762
|
const source = diagramsCore.getNode(state, sourceId);
|
|
622
763
|
const target = diagramsCore.getNode(state, targetId);
|
|
@@ -639,6 +780,135 @@ function canUseSequenceFlow(type) {
|
|
|
639
780
|
const meta = BPMN_ELEMENT_CATALOG[type];
|
|
640
781
|
return meta.handlePolicy !== "none" && !isDataType(type) && type !== "Annotation" && type !== "Group" && meta.category !== "conversation";
|
|
641
782
|
}
|
|
783
|
+
function matchesConnectionCategory(type, categories) {
|
|
784
|
+
return categories.some((category) => {
|
|
785
|
+
if (category === type) return true;
|
|
786
|
+
if (category === "flowNode") return canUseSequenceFlow(type);
|
|
787
|
+
if (category === "data") return isDataType(type);
|
|
788
|
+
if (category === "artifact") return type === "Annotation" || type === "Group";
|
|
789
|
+
if (category === "conversation") return BPMN_ELEMENT_CATALOG[type].category === "conversation";
|
|
790
|
+
return false;
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
function isBpmnEdgeRoutingEditable(edgeType) {
|
|
794
|
+
return BPMN_ROUTABLE_EDGE_TYPES.includes(edgeType);
|
|
795
|
+
}
|
|
796
|
+
function isBpmnProcessNode(type) {
|
|
797
|
+
return isEventType(type) || isGatewayType(type) || type.includes("Task") || type === "CallActivity" || type === "SubProcess" || type === "Transaction" || type === "EventSubProcess" || type === "AdHocSubProcess";
|
|
798
|
+
}
|
|
799
|
+
function canContainBpmnElement(parentType, childType) {
|
|
800
|
+
if (!parentType) return true;
|
|
801
|
+
if (parentType === "Pool") {
|
|
802
|
+
return childType === "Lane" || isBpmnProcessNode(childType) ? true : "Pools can contain lanes or BPMN process nodes.";
|
|
803
|
+
}
|
|
804
|
+
if (parentType === "Lane") {
|
|
805
|
+
return isBpmnProcessNode(childType) ? true : "Lanes can only contain BPMN process nodes.";
|
|
806
|
+
}
|
|
807
|
+
if (parentType === "SubProcess" || parentType === "Transaction" || parentType === "EventSubProcess" || parentType === "AdHocSubProcess") {
|
|
808
|
+
return isBpmnProcessNode(childType) ? true : "Subprocesses can only contain BPMN process nodes.";
|
|
809
|
+
}
|
|
810
|
+
return `${parentType} cannot contain BPMN child elements.`;
|
|
811
|
+
}
|
|
812
|
+
function getDirectBpmnChildren(state, parentId) {
|
|
813
|
+
return state.nodes.filter((node) => node.parentId === parentId);
|
|
814
|
+
}
|
|
815
|
+
function getBpmnPoolLanes(state, poolId) {
|
|
816
|
+
return getDirectBpmnChildren(state, poolId).filter(
|
|
817
|
+
(node) => node.data.elementType === "Lane"
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
function getNodeDimension(node, axis) {
|
|
821
|
+
return node[axis] ?? node.measured?.[axis] ?? getBpmnElementSize(node.data.elementType)[axis];
|
|
822
|
+
}
|
|
823
|
+
function resolvePoolLaneDirection(pool) {
|
|
824
|
+
return pool.data.orientation === "vertical" ? "horizontal" : "vertical";
|
|
825
|
+
}
|
|
826
|
+
function getBpmnLaneIndexAtPosition(state, poolId, position) {
|
|
827
|
+
const pool = diagramsCore.getNode(state, poolId);
|
|
828
|
+
if (!pool) return 0;
|
|
829
|
+
const lanes = getBpmnPoolLanes(state, poolId);
|
|
830
|
+
const direction = resolvePoolLaneDirection(pool);
|
|
831
|
+
const axis = direction === "vertical" ? "y" : "x";
|
|
832
|
+
const sizeKey = direction === "vertical" ? "height" : "width";
|
|
833
|
+
for (let index = 0; index < lanes.length; index += 1) {
|
|
834
|
+
const lane = lanes[index];
|
|
835
|
+
const midpoint = lane.position[axis] + getNodeDimension(lane, sizeKey) / 2;
|
|
836
|
+
if (position[axis] < midpoint) return index;
|
|
837
|
+
}
|
|
838
|
+
return lanes.length;
|
|
839
|
+
}
|
|
840
|
+
function sortBpmnLanes(state, poolId, laneId, index) {
|
|
841
|
+
const lanes = getBpmnPoolLanes(state, poolId);
|
|
842
|
+
const currentIndex = lanes.findIndex((lane) => lane.id === laneId);
|
|
843
|
+
if (currentIndex < 0) return state;
|
|
844
|
+
const orderedIds = lanes.map((lane) => lane.id);
|
|
845
|
+
const [moved] = orderedIds.splice(currentIndex, 1);
|
|
846
|
+
orderedIds.splice(Math.max(0, Math.min(index, orderedIds.length)), 0, moved);
|
|
847
|
+
const order = new Map(orderedIds.map((id, laneIndex) => [id, laneIndex]));
|
|
848
|
+
return {
|
|
849
|
+
...state,
|
|
850
|
+
nodes: [...state.nodes].sort((a, b) => {
|
|
851
|
+
const aOrder = order.get(a.id);
|
|
852
|
+
const bOrder = order.get(b.id);
|
|
853
|
+
if (aOrder === void 0 && bOrder === void 0) return 0;
|
|
854
|
+
if (aOrder === void 0) return -1;
|
|
855
|
+
if (bOrder === void 0) return 1;
|
|
856
|
+
return aOrder - bOrder;
|
|
857
|
+
})
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
function layoutBpmnPoolLanes(state, poolId) {
|
|
861
|
+
const pool = diagramsCore.getNode(state, poolId);
|
|
862
|
+
if (!pool) return state;
|
|
863
|
+
const poolSize = getBpmnElementSize("Pool");
|
|
864
|
+
const direction = resolvePoolLaneDirection(pool);
|
|
865
|
+
const lanes = getBpmnPoolLanes(state, poolId);
|
|
866
|
+
let cursor = direction === "vertical" ? BPMN_POOL_LANE_LAYOUT.poolHeaderSize : 0;
|
|
867
|
+
let next = state;
|
|
868
|
+
for (const lane of lanes) {
|
|
869
|
+
const laneSize = getBpmnElementSize("Lane");
|
|
870
|
+
const width = direction === "vertical" ? Math.max(poolSize.minWidth - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.width ?? laneSize.width) : lane.width ?? laneSize.width;
|
|
871
|
+
const height = direction === "vertical" ? lane.height ?? laneSize.height : Math.max(poolSize.minHeight - BPMN_POOL_LANE_LAYOUT.poolHeaderSize, lane.height ?? laneSize.height);
|
|
872
|
+
next = diagramsCore.patchNode(next, lane.id, {
|
|
873
|
+
position: direction === "vertical" ? { x: BPMN_POOL_LANE_LAYOUT.poolHeaderSize, y: cursor } : { x: cursor, y: BPMN_POOL_LANE_LAYOUT.poolHeaderSize },
|
|
874
|
+
width,
|
|
875
|
+
height,
|
|
876
|
+
data: { orientation: pool.data.orientation ?? "horizontal" }
|
|
877
|
+
});
|
|
878
|
+
cursor += (direction === "vertical" ? height : width) + BPMN_POOL_LANE_LAYOUT.laneGap;
|
|
879
|
+
}
|
|
880
|
+
const minWidth = direction === "vertical" ? poolSize.minWidth : Math.max(poolSize.minWidth, cursor);
|
|
881
|
+
const minHeight = direction === "vertical" ? Math.max(poolSize.minHeight, cursor) : poolSize.minHeight;
|
|
882
|
+
return diagramsCore.resizeNode(next, poolId, { width: minWidth, height: minHeight });
|
|
883
|
+
}
|
|
884
|
+
function reorderBpmnLane(state, options) {
|
|
885
|
+
return layoutBpmnPoolLanes(
|
|
886
|
+
sortBpmnLanes(state, options.poolId, options.laneId, options.index),
|
|
887
|
+
options.poolId
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
function validateBpmnConnectionForEdgeType(state, edgeType, source, target) {
|
|
891
|
+
const rule = BPMN_EDGE_CONNECTION_RULES[edgeType];
|
|
892
|
+
if (!matchesConnectionCategory(source.data.elementType, rule.sourceCategories)) {
|
|
893
|
+
return `${edgeType} cannot start from ${source.data.elementType}.`;
|
|
894
|
+
}
|
|
895
|
+
if (!matchesConnectionCategory(target.data.elementType, rule.targetCategories)) {
|
|
896
|
+
return `${edgeType} cannot target ${target.data.elementType}.`;
|
|
897
|
+
}
|
|
898
|
+
const sameParent = (source.parentId ?? null) === (target.parentId ?? null);
|
|
899
|
+
if (sameParent && rule.allowSameParent === false) {
|
|
900
|
+
return `${edgeType} must connect BPMN elements in different participants/scopes.`;
|
|
901
|
+
}
|
|
902
|
+
if (!sameParent && rule.allowDifferentParent === false) {
|
|
903
|
+
return `${edgeType} must stay inside the same BPMN participant/scope.`;
|
|
904
|
+
}
|
|
905
|
+
if (edgeType === "sequenceFlow") {
|
|
906
|
+
if (source.data.elementType === "EndEvent") return "End events cannot have outgoing sequence flows.";
|
|
907
|
+
if (target.data.elementType === "StartEvent") return "Start events cannot have incoming sequence flows.";
|
|
908
|
+
return validateEdgeCardinality(state, edgeType, source, target);
|
|
909
|
+
}
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
642
912
|
function validateEdgeCardinality(state, edgeType, source, target) {
|
|
643
913
|
if (edgeType !== "sequenceFlow") return true;
|
|
644
914
|
const sourceMax = BPMN_ELEMENT_CATALOG[source.data.elementType].maxOutgoing;
|
|
@@ -665,14 +935,9 @@ var bpmnConnectionValidators = [
|
|
|
665
935
|
return "Elements without BPMN connection handles cannot be directly connected.";
|
|
666
936
|
}
|
|
667
937
|
if (edgeType === "sequenceFlow") {
|
|
668
|
-
|
|
669
|
-
return "Sequence flows can only connect BPMN flow nodes.";
|
|
670
|
-
}
|
|
671
|
-
if (source.data.elementType === "EndEvent") return "End events cannot have outgoing sequence flows.";
|
|
672
|
-
if (target.data.elementType === "StartEvent") return "Start events cannot have incoming sequence flows.";
|
|
673
|
-
return validateEdgeCardinality(state, edgeType, source, target);
|
|
938
|
+
return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
|
|
674
939
|
}
|
|
675
|
-
return
|
|
940
|
+
return validateBpmnConnectionForEdgeType(state, edgeType, source, target);
|
|
676
941
|
}
|
|
677
942
|
];
|
|
678
943
|
var BPMN_MODELING_RULES = diagramsCore.createModelingRules({
|
|
@@ -697,10 +962,7 @@ var BPMN_MODELING_RULES = diagramsCore.createModelingRules({
|
|
|
697
962
|
if (node.data.elementType === "BoundaryEvent") {
|
|
698
963
|
return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be attached to tasks or subprocesses.";
|
|
699
964
|
}
|
|
700
|
-
|
|
701
|
-
return isEventType(node.data.elementType) || node.data.elementType.includes("Task") || node.data.elementType.includes("Gateway") || node.data.elementType.includes("SubProcess") ? true : "Only flow nodes can be dropped into pools or lanes.";
|
|
702
|
-
}
|
|
703
|
-
return true;
|
|
965
|
+
return canContainBpmnElement(parent.data.elementType, node.data.elementType);
|
|
704
966
|
}
|
|
705
967
|
],
|
|
706
968
|
reparent: [
|
|
@@ -709,11 +971,13 @@ var BPMN_MODELING_RULES = diagramsCore.createModelingRules({
|
|
|
709
971
|
if (node.data.elementType === "BoundaryEvent") {
|
|
710
972
|
return acceptsBoundaryEvents(parent.data.elementType) ? true : "Boundary events can only be reparented to tasks or subprocesses.";
|
|
711
973
|
}
|
|
712
|
-
return
|
|
974
|
+
return canContainBpmnElement(parent?.data.elementType, node.data.elementType);
|
|
713
975
|
}
|
|
714
976
|
],
|
|
715
977
|
delete: [() => true],
|
|
716
|
-
resize: [
|
|
978
|
+
resize: [
|
|
979
|
+
({ node }) => !node || isBpmnElementResizable(node.data.elementType) ? true : `${node.data.elementType} is not resizable in BPMN.`
|
|
980
|
+
]
|
|
717
981
|
});
|
|
718
982
|
function createBpmnNodeCommand(options) {
|
|
719
983
|
return {
|
|
@@ -728,6 +992,12 @@ function connectBpmnCommand(options) {
|
|
|
728
992
|
label: "Connect BPMN elements",
|
|
729
993
|
execute: (state) => {
|
|
730
994
|
const edgeType = options.edgeType ?? inferBpmnEdgeType(state, options.source, options.target);
|
|
995
|
+
const source = diagramsCore.getNode(state, options.source);
|
|
996
|
+
const target = diagramsCore.getNode(state, options.target);
|
|
997
|
+
if (!source) throw new Error(`Source node "${options.source}" does not exist.`);
|
|
998
|
+
if (!target) throw new Error(`Target node "${options.target}" does not exist.`);
|
|
999
|
+
const validation = validateBpmnConnectionForEdgeType(state, edgeType, source, target);
|
|
1000
|
+
if (validation !== true) throw new Error(validation);
|
|
731
1001
|
return diagramsCore.connectNodes(
|
|
732
1002
|
state,
|
|
733
1003
|
{
|
|
@@ -743,7 +1013,7 @@ function connectBpmnCommand(options) {
|
|
|
743
1013
|
...options.data ?? {}
|
|
744
1014
|
}
|
|
745
1015
|
},
|
|
746
|
-
|
|
1016
|
+
[]
|
|
747
1017
|
);
|
|
748
1018
|
}
|
|
749
1019
|
};
|
|
@@ -802,10 +1072,13 @@ function reparentBpmnNodeCommand(options) {
|
|
|
802
1072
|
if (parent && node.data.elementType === "BoundaryEvent" && !acceptsBoundaryEvents(parent.data.elementType)) {
|
|
803
1073
|
throw new Error("Boundary events can only be reparented to tasks or subprocesses.");
|
|
804
1074
|
}
|
|
805
|
-
|
|
1075
|
+
const containment = canContainBpmnElement(parent?.data.elementType, node.data.elementType);
|
|
1076
|
+
if (containment !== true) throw new Error(containment);
|
|
1077
|
+
const reparented = diagramsCore.reparentNode(state, options.id, {
|
|
806
1078
|
...options.parentId !== void 0 ? { parentId: options.parentId } : {},
|
|
807
1079
|
...options.position ? { position: options.position } : {}
|
|
808
1080
|
});
|
|
1081
|
+
return parent?.data.elementType === "Pool" && node.data.elementType === "Lane" ? layoutBpmnPoolLanes(reparented, parent.id) : reparented;
|
|
809
1082
|
}
|
|
810
1083
|
};
|
|
811
1084
|
}
|
|
@@ -813,7 +1086,63 @@ function resizeBpmnNodeCommand(options) {
|
|
|
813
1086
|
return {
|
|
814
1087
|
id: `bpmn.resize.${options.id}`,
|
|
815
1088
|
label: "Resize BPMN element",
|
|
816
|
-
execute: (state) =>
|
|
1089
|
+
execute: (state) => {
|
|
1090
|
+
const node = diagramsCore.getNode(state, options.id);
|
|
1091
|
+
if (!node) throw new Error(`Element "${options.id}" does not exist.`);
|
|
1092
|
+
const size = getBpmnElementSize(node.data.elementType);
|
|
1093
|
+
if (!size.resizable) {
|
|
1094
|
+
throw new Error(`${node.data.elementType} is not resizable in BPMN.`);
|
|
1095
|
+
}
|
|
1096
|
+
return diagramsCore.resizeNode(state, options.id, {
|
|
1097
|
+
width: options.width === void 0 ? void 0 : Math.max(size.minWidth, options.width),
|
|
1098
|
+
height: options.height === void 0 ? void 0 : Math.max(size.minHeight, options.height)
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
function reorderBpmnLaneCommand(options) {
|
|
1104
|
+
return {
|
|
1105
|
+
id: `bpmn.reorderLane.${options.poolId}.${options.laneId}`,
|
|
1106
|
+
label: "Reorder BPMN lane",
|
|
1107
|
+
execute: (state) => {
|
|
1108
|
+
const pool = diagramsCore.getNode(state, options.poolId);
|
|
1109
|
+
const lane = diagramsCore.getNode(state, options.laneId);
|
|
1110
|
+
if (!pool || pool.data.elementType !== "Pool") {
|
|
1111
|
+
throw new Error(`Element "${options.poolId}" is not a pool.`);
|
|
1112
|
+
}
|
|
1113
|
+
if (!lane || lane.data.elementType !== "Lane" || lane.parentId !== options.poolId) {
|
|
1114
|
+
throw new Error(`Element "${options.laneId}" is not a lane in pool "${options.poolId}".`);
|
|
1115
|
+
}
|
|
1116
|
+
return reorderBpmnLane(state, options);
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
function moveBpmnLaneCommand(options) {
|
|
1121
|
+
return {
|
|
1122
|
+
id: `bpmn.moveLane.${options.poolId}.${options.laneId}`,
|
|
1123
|
+
label: "Move BPMN lane",
|
|
1124
|
+
execute: (state) => reorderBpmnLane(state, {
|
|
1125
|
+
poolId: options.poolId,
|
|
1126
|
+
laneId: options.laneId,
|
|
1127
|
+
index: getBpmnLaneIndexAtPosition(state, options.poolId, options.position)
|
|
1128
|
+
})
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
function routeBpmnEdgeCommand(options) {
|
|
1132
|
+
return {
|
|
1133
|
+
id: `bpmn.routeEdge.${options.id}`,
|
|
1134
|
+
label: "Route BPMN edge",
|
|
1135
|
+
execute: (state) => {
|
|
1136
|
+
const edge = state.edges.find((item) => item.id === options.id);
|
|
1137
|
+
if (!edge) throw new Error(`Edge "${options.id}" does not exist.`);
|
|
1138
|
+
const edgeType = edge.data?.edgeType;
|
|
1139
|
+
if (!edgeType || !isBpmnEdgeRoutingEditable(edgeType)) {
|
|
1140
|
+
throw new Error(`${edgeType ?? "edge"} routing points cannot be edited.`);
|
|
1141
|
+
}
|
|
1142
|
+
return diagramsCore.patchEdge(state, options.id, {
|
|
1143
|
+
data: { routingPoints: options.routingPoints }
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
817
1146
|
};
|
|
818
1147
|
}
|
|
819
1148
|
function deleteBpmnElementsCommand(ids) {
|
|
@@ -870,9 +1199,14 @@ function runBpmnCommands(stack, commands, options = {}) {
|
|
|
870
1199
|
return diagramsCore.executeCommands(stack, commands, options);
|
|
871
1200
|
}
|
|
872
1201
|
|
|
1202
|
+
exports.BPMN_EDGE_CONNECTION_RULES = BPMN_EDGE_CONNECTION_RULES;
|
|
873
1203
|
exports.BPMN_MODELING_RULES = BPMN_MODELING_RULES;
|
|
1204
|
+
exports.BPMN_POOL_LANE_LAYOUT = BPMN_POOL_LANE_LAYOUT;
|
|
1205
|
+
exports.BPMN_ROUTABLE_EDGE_TYPES = BPMN_ROUTABLE_EDGE_TYPES;
|
|
1206
|
+
exports.BPMN_SELECTION_STYLE = BPMN_SELECTION_STYLE;
|
|
874
1207
|
exports.attachBoundaryEventCommand = attachBoundaryEventCommand;
|
|
875
1208
|
exports.bpmnConnectionValidators = bpmnConnectionValidators;
|
|
1209
|
+
exports.canContainBpmnElement = canContainBpmnElement;
|
|
876
1210
|
exports.connectBpmnCommand = connectBpmnCommand;
|
|
877
1211
|
exports.copyBpmnElements = copyBpmnElements;
|
|
878
1212
|
exports.createBpmnDiagramDocument = createBpmnDiagramDocument;
|
|
@@ -880,15 +1214,28 @@ exports.createBpmnNode = createBpmnNode;
|
|
|
880
1214
|
exports.createBpmnNodeCommand = createBpmnNodeCommand;
|
|
881
1215
|
exports.deleteBpmnElementsCommand = deleteBpmnElementsCommand;
|
|
882
1216
|
exports.deserializeBpmnDiagram = deserializeBpmnDiagram;
|
|
1217
|
+
exports.getBpmnDragHandleSelector = getBpmnDragHandleSelector;
|
|
1218
|
+
exports.getBpmnElementSize = getBpmnElementSize;
|
|
1219
|
+
exports.getBpmnLaneIndexAtPosition = getBpmnLaneIndexAtPosition;
|
|
1220
|
+
exports.getBpmnPoolLanes = getBpmnPoolLanes;
|
|
883
1221
|
exports.inferBpmnEdgeType = inferBpmnEdgeType;
|
|
1222
|
+
exports.isBpmnEdgeRoutingEditable = isBpmnEdgeRoutingEditable;
|
|
1223
|
+
exports.isBpmnElementResizable = isBpmnElementResizable;
|
|
1224
|
+
exports.isBpmnProcessNode = isBpmnProcessNode;
|
|
1225
|
+
exports.layoutBpmnPoolLanes = layoutBpmnPoolLanes;
|
|
1226
|
+
exports.moveBpmnLaneCommand = moveBpmnLaneCommand;
|
|
884
1227
|
exports.parseBpmnDiagramDocument = parseBpmnDiagramDocument;
|
|
885
1228
|
exports.pasteBpmnElementsCommand = pasteBpmnElementsCommand;
|
|
1229
|
+
exports.reorderBpmnLane = reorderBpmnLane;
|
|
1230
|
+
exports.reorderBpmnLaneCommand = reorderBpmnLaneCommand;
|
|
886
1231
|
exports.reparentBpmnNodeCommand = reparentBpmnNodeCommand;
|
|
887
1232
|
exports.replaceBpmnNodeCommand = replaceBpmnNodeCommand;
|
|
888
1233
|
exports.resizeBpmnNodeCommand = resizeBpmnNodeCommand;
|
|
1234
|
+
exports.routeBpmnEdgeCommand = routeBpmnEdgeCommand;
|
|
889
1235
|
exports.runBpmnCommand = runBpmnCommand;
|
|
890
1236
|
exports.runBpmnCommands = runBpmnCommands;
|
|
891
1237
|
exports.selectBpmnElementsCommand = selectBpmnElementsCommand;
|
|
892
1238
|
exports.serializeBpmnDiagram = serializeBpmnDiagram;
|
|
1239
|
+
exports.validateBpmnConnectionForEdgeType = validateBpmnConnectionForEdgeType;
|
|
893
1240
|
//# sourceMappingURL=index.cjs.map
|
|
894
1241
|
//# sourceMappingURL=index.cjs.map
|