@bpmnkit/editor 0.0.8

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.
@@ -0,0 +1,14 @@
1
+ import type { CreateShapeType, LabelPosition } from "./types.js";
2
+ export interface ElementGroup {
3
+ id: string;
4
+ title: string;
5
+ defaultType: CreateShapeType;
6
+ types: ReadonlyArray<CreateShapeType>;
7
+ }
8
+ export declare const ELEMENT_GROUPS: ReadonlyArray<ElementGroup>;
9
+ export declare function getElementGroup(type: CreateShapeType): ElementGroup | undefined;
10
+ export declare const ELEMENT_TYPE_LABELS: Readonly<Record<CreateShapeType, string>>;
11
+ export declare const EXTERNAL_LABEL_TYPES: ReadonlySet<CreateShapeType>;
12
+ export declare const CONTEXTUAL_ADD_TYPES: ReadonlyArray<CreateShapeType>;
13
+ export declare function getValidLabelPositions(type: CreateShapeType): ReadonlyArray<LabelPosition>;
14
+ //# sourceMappingURL=element-groups.d.ts.map
@@ -0,0 +1,195 @@
1
+ export const ELEMENT_GROUPS = [
2
+ {
3
+ id: "startEvents",
4
+ title: "Start Events",
5
+ defaultType: "startEvent",
6
+ types: [
7
+ "startEvent",
8
+ "messageStartEvent",
9
+ "timerStartEvent",
10
+ "conditionalStartEvent",
11
+ "signalStartEvent",
12
+ ],
13
+ },
14
+ {
15
+ id: "endEvents",
16
+ title: "End Events",
17
+ defaultType: "endEvent",
18
+ types: [
19
+ "endEvent",
20
+ "messageEndEvent",
21
+ "escalationEndEvent",
22
+ "errorEndEvent",
23
+ "compensationEndEvent",
24
+ "signalEndEvent",
25
+ "terminateEndEvent",
26
+ ],
27
+ },
28
+ {
29
+ id: "intermediateEvents",
30
+ title: "Intermediate Events",
31
+ defaultType: "messageCatchEvent",
32
+ types: [
33
+ "messageCatchEvent",
34
+ "messageThrowEvent",
35
+ "timerCatchEvent",
36
+ "escalationThrowEvent",
37
+ "conditionalCatchEvent",
38
+ "linkCatchEvent",
39
+ "linkThrowEvent",
40
+ "compensationThrowEvent",
41
+ "signalCatchEvent",
42
+ "signalThrowEvent",
43
+ ],
44
+ },
45
+ {
46
+ id: "activities",
47
+ title: "Activities",
48
+ defaultType: "serviceTask",
49
+ types: [
50
+ "task",
51
+ "serviceTask",
52
+ "userTask",
53
+ "scriptTask",
54
+ "sendTask",
55
+ "receiveTask",
56
+ "businessRuleTask",
57
+ "manualTask",
58
+ "callActivity",
59
+ "subProcess",
60
+ "adHocSubProcess",
61
+ "transaction",
62
+ ],
63
+ },
64
+ {
65
+ id: "gateways",
66
+ title: "Gateways",
67
+ defaultType: "exclusiveGateway",
68
+ types: [
69
+ "exclusiveGateway",
70
+ "parallelGateway",
71
+ "inclusiveGateway",
72
+ "eventBasedGateway",
73
+ "complexGateway",
74
+ ],
75
+ },
76
+ {
77
+ id: "annotations",
78
+ title: "Annotations",
79
+ defaultType: "textAnnotation",
80
+ types: ["textAnnotation"],
81
+ },
82
+ ];
83
+ const _typeToGroup = new Map();
84
+ for (const group of ELEMENT_GROUPS) {
85
+ for (const type of group.types) {
86
+ _typeToGroup.set(type, group);
87
+ }
88
+ }
89
+ export function getElementGroup(type) {
90
+ return _typeToGroup.get(type);
91
+ }
92
+ export const ELEMENT_TYPE_LABELS = {
93
+ startEvent: "Start Event",
94
+ messageStartEvent: "Message Start Event",
95
+ timerStartEvent: "Timer Start Event",
96
+ conditionalStartEvent: "Conditional Start Event",
97
+ signalStartEvent: "Signal Start Event",
98
+ endEvent: "End Event",
99
+ messageEndEvent: "Message End Event",
100
+ escalationEndEvent: "Escalation End Event",
101
+ errorEndEvent: "Error End Event",
102
+ compensationEndEvent: "Compensation End Event",
103
+ signalEndEvent: "Signal End Event",
104
+ terminateEndEvent: "Terminate End Event",
105
+ intermediateThrowEvent: "Intermediate Throw Event",
106
+ intermediateCatchEvent: "Intermediate Catch Event",
107
+ messageCatchEvent: "Message Intermediate Catch Event",
108
+ messageThrowEvent: "Message Intermediate Throw Event",
109
+ timerCatchEvent: "Timer Intermediate Catch Event",
110
+ escalationThrowEvent: "Escalation Intermediate Throw Event",
111
+ conditionalCatchEvent: "Conditional Intermediate Catch Event",
112
+ linkCatchEvent: "Link Intermediate Catch Event",
113
+ linkThrowEvent: "Link Intermediate Throw Event",
114
+ compensationThrowEvent: "Compensation Intermediate Throw Event",
115
+ signalCatchEvent: "Signal Intermediate Catch Event",
116
+ signalThrowEvent: "Signal Intermediate Throw Event",
117
+ task: "Task",
118
+ serviceTask: "Service Task",
119
+ userTask: "User Task",
120
+ scriptTask: "Script Task",
121
+ sendTask: "Send Task",
122
+ receiveTask: "Receive Task",
123
+ businessRuleTask: "Business Rule Task",
124
+ manualTask: "Manual Task",
125
+ callActivity: "Call Activity",
126
+ subProcess: "Sub-Process",
127
+ adHocSubProcess: "Ad-hoc Sub-Process",
128
+ transaction: "Transaction",
129
+ exclusiveGateway: "Exclusive Gateway",
130
+ parallelGateway: "Parallel Gateway",
131
+ inclusiveGateway: "Inclusive Gateway",
132
+ eventBasedGateway: "Event-based Gateway",
133
+ complexGateway: "Complex Gateway",
134
+ textAnnotation: "Text Annotation",
135
+ };
136
+ export const EXTERNAL_LABEL_TYPES = new Set([
137
+ "startEvent",
138
+ "messageStartEvent",
139
+ "timerStartEvent",
140
+ "conditionalStartEvent",
141
+ "signalStartEvent",
142
+ "endEvent",
143
+ "messageEndEvent",
144
+ "escalationEndEvent",
145
+ "errorEndEvent",
146
+ "compensationEndEvent",
147
+ "signalEndEvent",
148
+ "terminateEndEvent",
149
+ "intermediateThrowEvent",
150
+ "intermediateCatchEvent",
151
+ "messageCatchEvent",
152
+ "messageThrowEvent",
153
+ "timerCatchEvent",
154
+ "escalationThrowEvent",
155
+ "conditionalCatchEvent",
156
+ "linkCatchEvent",
157
+ "linkThrowEvent",
158
+ "compensationThrowEvent",
159
+ "signalCatchEvent",
160
+ "signalThrowEvent",
161
+ "exclusiveGateway",
162
+ "parallelGateway",
163
+ "inclusiveGateway",
164
+ "eventBasedGateway",
165
+ "complexGateway",
166
+ ]);
167
+ export const CONTEXTUAL_ADD_TYPES = [
168
+ "serviceTask",
169
+ "exclusiveGateway",
170
+ "endEvent",
171
+ ];
172
+ export function getValidLabelPositions(type) {
173
+ const base = ["bottom", "top", "left", "right"];
174
+ if (type === "exclusiveGateway" ||
175
+ type === "parallelGateway" ||
176
+ type === "inclusiveGateway" ||
177
+ type === "eventBasedGateway" ||
178
+ type === "complexGateway" ||
179
+ type === "intermediateThrowEvent" ||
180
+ type === "intermediateCatchEvent" ||
181
+ type === "messageCatchEvent" ||
182
+ type === "messageThrowEvent" ||
183
+ type === "timerCatchEvent" ||
184
+ type === "escalationThrowEvent" ||
185
+ type === "conditionalCatchEvent" ||
186
+ type === "linkCatchEvent" ||
187
+ type === "linkThrowEvent" ||
188
+ type === "compensationThrowEvent" ||
189
+ type === "signalCatchEvent" ||
190
+ type === "signalThrowEvent") {
191
+ return [...base, "bottom-left", "bottom-right", "top-left", "top-right"];
192
+ }
193
+ return base;
194
+ }
195
+ //# sourceMappingURL=element-groups.js.map
@@ -0,0 +1,89 @@
1
+ import type { RenderedShape, ViewportState } from "@bpmnkit/canvas";
2
+ import type { BpmnBounds, BpmnWaypoint } from "@bpmnkit/core";
3
+ import type { DiagPoint, HandleDir, LabelPosition, PortDir } from "./types.js";
4
+ /**
5
+ * Converts client (screen) coordinates to diagram coordinates accounting for
6
+ * the current viewport transform.
7
+ */
8
+ export declare function screenToDiagram(screenX: number, screenY: number, viewport: ViewportState, svgRect: DOMRect): DiagPoint;
9
+ /**
10
+ * Converts diagram coordinates to client (screen) coordinates.
11
+ */
12
+ export declare function diagramToScreen(diagX: number, diagY: number, viewport: ViewportState, svgRect: DOMRect): {
13
+ x: number;
14
+ y: number;
15
+ };
16
+ /**
17
+ * Returns the topmost shape that contains the diagram-space point (x, y),
18
+ * or null if none. Iterates in reverse render order (last = top).
19
+ */
20
+ export declare function hitTestShape(shapes: RenderedShape[], x: number, y: number): RenderedShape | null;
21
+ /** Returns the 8 handle positions (diagram space) for a shape's bounding box. */
22
+ export declare function handlePositions(bounds: BpmnBounds): Record<HandleDir, DiagPoint>;
23
+ /** Returns the 4 connection port positions (diagram space) for a shape. */
24
+ export declare function portPositions(bounds: BpmnBounds): Array<{
25
+ x: number;
26
+ y: number;
27
+ dir: PortDir;
28
+ }>;
29
+ /**
30
+ * Applies a resize handle drag to produce new bounds.
31
+ * `diagX` and `diagY` are the current cursor position in diagram space.
32
+ */
33
+ export declare function applyResize(original: BpmnBounds, handle: HandleDir, diagX: number, diagY: number): BpmnBounds;
34
+ /**
35
+ * Computes orthogonal (H/V only) waypoints between two shapes.
36
+ * Picks exit/entry ports based on relative position: prefers L-shaped (one-bend) routes
37
+ * over Z-shaped (two-bend) routes. For gateways or events below/above the source,
38
+ * uses the bottom/top port rather than always exiting right.
39
+ */
40
+ export declare function computeWaypoints(src: BpmnBounds, tgt: BpmnBounds): BpmnWaypoint[];
41
+ /**
42
+ * Computes the absolute diagram-space bounds for an external label given a
43
+ * position option and the shape it belongs to.
44
+ */
45
+ export declare function labelBoundsForPosition(shape: BpmnBounds, position: LabelPosition): BpmnBounds;
46
+ /** Returns the midpoint of a specific port edge in diagram space. */
47
+ export declare function portPoint(bounds: BpmnBounds, port: PortDir): DiagPoint;
48
+ /** Returns which port of `bounds` is nearest to `pos` in diagram space. */
49
+ export declare function closestPort(pos: DiagPoint, bounds: BpmnBounds): PortDir;
50
+ /**
51
+ * Derives which port of `bounds` a waypoint exits from / enters at.
52
+ * Uses the dominant axis between the waypoint and the shape centre.
53
+ */
54
+ export declare function portFromWaypoint(wp: BpmnWaypoint, bounds: BpmnBounds): PortDir;
55
+ /**
56
+ * Computes orthogonal waypoints connecting two shapes via explicit exit/entry
57
+ * ports. All segments are horizontal or vertical.
58
+ */
59
+ /**
60
+ * Routes orthogonal waypoints between two explicit points given their exit/entry directions.
61
+ * All segments are horizontal or vertical.
62
+ */
63
+ export declare function routeOrthogonal(E: DiagPoint, srcPort: PortDir, P: DiagPoint, tgtPort: PortDir): BpmnWaypoint[];
64
+ export declare function computeWaypointsWithPorts(src: BpmnBounds, srcPort: PortDir, tgt: BpmnBounds, tgtPort: PortDir): BpmnWaypoint[];
65
+ export declare function waypointsIntersectObstacles(wps: BpmnWaypoint[], obstacles: BpmnBounds[]): boolean;
66
+ /**
67
+ * Returns true if any intermediate waypoint (not the first or last) lies strictly
68
+ * inside the shape's bounding box. This catches routes that enter the source or
69
+ * target shape's interior before reaching the connection point — a situation that
70
+ * waypointsIntersectObstacles cannot detect because src/tgt are excluded from the
71
+ * obstacles list.
72
+ */
73
+ export declare function routeEntersShape(wps: BpmnWaypoint[], shape: BpmnBounds): boolean;
74
+ /**
75
+ * Computes waypoints between two shapes, routing around obstacle shapes and
76
+ * never passing through the source or target shape's own interior.
77
+ *
78
+ * Strategy:
79
+ * 1. Try the default (most natural) route.
80
+ * 2. Try all 16 port-pair combinations in natural-first order.
81
+ * 3. Try explicit bypass corridors above/below/left/right of each obstacle.
82
+ * 4. Fall back to the default route as an absolute last resort.
83
+ */
84
+ export declare function computeWaypointsAvoiding(src: BpmnBounds, tgt: BpmnBounds, obstacles: BpmnBounds[]): BpmnWaypoint[];
85
+ /**
86
+ * Returns the bounding box that encloses all selected shapes, or null if none.
87
+ */
88
+ export declare function selectionBounds(shapes: RenderedShape[], ids: string[]): BpmnBounds | null;
89
+ //# sourceMappingURL=geometry.d.ts.map