@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,174 @@
1
+ import type { RenderedShape, ViewportState } from "@bpmnkit/canvas";
2
+ import type { BpmnBounds } from "@bpmnkit/core";
3
+ import type { CreateShapeType, DiagPoint, HandleDir, HitResult, PortDir, Tool } from "./types.js";
4
+ type SelectSub = {
5
+ name: "idle";
6
+ hoveredId: string | null;
7
+ } | {
8
+ name: "pointing-canvas";
9
+ origin: DiagPoint;
10
+ screenX: number;
11
+ screenY: number;
12
+ } | {
13
+ name: "rubber-band";
14
+ origin: DiagPoint;
15
+ current: DiagPoint;
16
+ } | {
17
+ name: "pointing-shape";
18
+ origin: DiagPoint;
19
+ id: string;
20
+ screenX: number;
21
+ screenY: number;
22
+ } | {
23
+ name: "translating";
24
+ origin: DiagPoint;
25
+ last: DiagPoint;
26
+ } | {
27
+ name: "pointing-handle";
28
+ origin: DiagPoint;
29
+ id: string;
30
+ handle: HandleDir;
31
+ screenX: number;
32
+ screenY: number;
33
+ } | {
34
+ name: "resizing";
35
+ id: string;
36
+ handle: HandleDir;
37
+ original: BpmnBounds;
38
+ current: DiagPoint;
39
+ } | {
40
+ name: "pointing-port";
41
+ origin: DiagPoint;
42
+ sourceId: string;
43
+ port: PortDir;
44
+ screenX: number;
45
+ screenY: number;
46
+ } | {
47
+ name: "connecting";
48
+ sourceId: string;
49
+ ghostEnd: DiagPoint;
50
+ } | {
51
+ name: "editing-label";
52
+ id: string;
53
+ } | {
54
+ name: "pointing-edge-endpoint";
55
+ edgeId: string;
56
+ isStart: boolean;
57
+ origin: DiagPoint;
58
+ screenX: number;
59
+ screenY: number;
60
+ } | {
61
+ name: "dragging-edge-endpoint";
62
+ edgeId: string;
63
+ isStart: boolean;
64
+ origin: DiagPoint;
65
+ } | {
66
+ name: "pointing-edge-segment";
67
+ edgeId: string;
68
+ segIdx: number;
69
+ isHoriz: boolean;
70
+ projPt: DiagPoint;
71
+ origin: DiagPoint;
72
+ screenX: number;
73
+ screenY: number;
74
+ } | {
75
+ name: "dragging-edge-waypoint-new";
76
+ edgeId: string;
77
+ segIdx: number;
78
+ origin: DiagPoint;
79
+ } | {
80
+ name: "pointing-edge-waypoint";
81
+ edgeId: string;
82
+ wpIdx: number;
83
+ pt: DiagPoint;
84
+ screenX: number;
85
+ screenY: number;
86
+ } | {
87
+ name: "dragging-edge-waypoint";
88
+ edgeId: string;
89
+ wpIdx: number;
90
+ origin: DiagPoint;
91
+ };
92
+ type SpaceSub = {
93
+ name: "idle";
94
+ } | {
95
+ name: "dragging";
96
+ origin: DiagPoint;
97
+ last: DiagPoint;
98
+ axis: "h" | "v" | null;
99
+ };
100
+ export type EditorMode = {
101
+ mode: "select";
102
+ sub: SelectSub;
103
+ } | {
104
+ mode: "create";
105
+ elementType: CreateShapeType;
106
+ } | {
107
+ mode: "pan";
108
+ } | {
109
+ mode: "space";
110
+ sub: SpaceSub;
111
+ };
112
+ export interface Callbacks {
113
+ getShapes(): RenderedShape[];
114
+ getSelectedIds(): string[];
115
+ getSelectedEdgeId(): string | null;
116
+ getViewport(): ViewportState;
117
+ viewportDidPan(): boolean;
118
+ isResizable(id: string): boolean;
119
+ lockViewport(lock: boolean): void;
120
+ setSelection(ids: string[]): void;
121
+ setEdgeSelected(edgeId: string | null): void;
122
+ previewTranslate(dx: number, dy: number): void;
123
+ commitTranslate(dx: number, dy: number): void;
124
+ cancelTranslate(): void;
125
+ previewResize(bounds: BpmnBounds): void;
126
+ commitResize(id: string, bounds: BpmnBounds): void;
127
+ previewConnect(ghostEnd: DiagPoint): void;
128
+ cancelConnect(): void;
129
+ commitConnect(sourceId: string, targetId: string): void;
130
+ previewRubberBand(origin: DiagPoint, current: DiagPoint): void;
131
+ cancelRubberBand(): void;
132
+ commitCreate(type: CreateShapeType, diagPoint: DiagPoint): void;
133
+ startLabelEdit(id: string): void;
134
+ setHovered(id: string | null): void;
135
+ executeDelete(ids: string[]): void;
136
+ executeCopy(): void;
137
+ executePaste(): void;
138
+ setTool(tool: Tool): void;
139
+ previewEndpointMove(edgeId: string, isStart: boolean, diagPoint: DiagPoint): void;
140
+ commitEndpointMove(edgeId: string, isStart: boolean, diagPoint: DiagPoint): void;
141
+ cancelEndpointMove(): void;
142
+ previewWaypointInsert(edgeId: string, segIdx: number, pt: DiagPoint): void;
143
+ commitWaypointInsert(edgeId: string, segIdx: number, pt: DiagPoint): void;
144
+ cancelWaypointInsert(): void;
145
+ previewWaypointMove(edgeId: string, wpIdx: number, pt: DiagPoint): void;
146
+ commitWaypointMove(edgeId: string, wpIdx: number, pt: DiagPoint): void;
147
+ cancelWaypointMove(): void;
148
+ showEdgeHoverDot(pt: DiagPoint): void;
149
+ hideEdgeHoverDot(): void;
150
+ showEdgeWaypointBalls(edgeId: string): void;
151
+ hideEdgeWaypointBalls(): void;
152
+ previewSpace(origin: DiagPoint, current: DiagPoint, axis: "h" | "v" | null): void;
153
+ commitSpace(origin: DiagPoint, current: DiagPoint, axis: "h" | "v" | null): void;
154
+ cancelSpace(): void;
155
+ }
156
+ /**
157
+ * Discriminated-union state machine for the BPMN editor.
158
+ * Receives pointer + keyboard events from the editor and notifies the editor
159
+ * via injected `Callbacks`.
160
+ */
161
+ export declare class EditorStateMachine {
162
+ private readonly _cb;
163
+ private _mode;
164
+ constructor(_cb: Callbacks);
165
+ get mode(): EditorMode;
166
+ setMode(mode: EditorMode): void;
167
+ onPointerDown(e: PointerEvent, diag: DiagPoint, hit: HitResult): void;
168
+ onPointerMove(e: PointerEvent, diag: DiagPoint, hit: HitResult): void;
169
+ onPointerUp(_e: PointerEvent, diag: DiagPoint, hit: HitResult): void;
170
+ onDblClick(_e: MouseEvent, _diag: DiagPoint, hit: HitResult): void;
171
+ onKeyDown(e: KeyboardEvent): void;
172
+ }
173
+ export {};
174
+ //# sourceMappingURL=state-machine.d.ts.map