@formicoidea/labre-framework-bpmn 0.23.0 → 0.23.1
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/dist/consts.d.ts +42 -0
- package/{src/consts.ts → dist/consts.js} +11 -20
- package/dist/descriptor.d.ts +7 -0
- package/{src/descriptor.ts → dist/descriptor.js} +1 -1
- package/dist/effects.d.ts +10 -0
- package/dist/effects.js +7 -0
- package/dist/element-renderer.d.ts +13 -0
- package/dist/element-renderer.js +58 -0
- package/dist/element-view.d.ts +22 -0
- package/dist/element-view.js +103 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/node/node-renderer.d.ts +16 -0
- package/dist/node/node-renderer.js +43 -0
- package/dist/node/node-view.d.ts +17 -0
- package/dist/node/node-view.js +28 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +114 -0
- package/dist/toolbar/bpmn-menu.d.ts +27 -0
- package/dist/toolbar/bpmn-menu.js +179 -0
- package/dist/toolbar/bpmn-senior-button.d.ts +16 -0
- package/{src/toolbar/bpmn-senior-button.ts → dist/toolbar/bpmn-senior-button.js} +33 -38
- package/dist/toolbar/config.d.ts +14 -0
- package/dist/toolbar/config.js +55 -0
- package/dist/toolbar/icons.d.ts +16 -0
- package/{src/toolbar/icons.ts → dist/toolbar/icons.js} +8 -14
- package/dist/toolbar/senior-tool.d.ts +2 -0
- package/{src/toolbar/senior-tool.ts → dist/toolbar/senior-tool.js} +5 -5
- package/dist/view.d.ts +7 -0
- package/dist/view.js +34 -0
- package/package.json +15 -6
- package/src/effects.ts +0 -14
- package/src/element-renderer.ts +0 -93
- package/src/element-view.ts +0 -116
- package/src/index.ts +0 -1
- package/src/node/node-renderer.ts +0 -65
- package/src/node/node-view.ts +0 -34
- package/src/templates/index.ts +0 -156
- package/src/toolbar/bpmn-menu.ts +0 -224
- package/src/toolbar/config.ts +0 -74
- package/src/view.ts +0 -37
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { ConnectorTool } from '@formicoidea/labre-core/gfx/connector';
|
|
3
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
4
|
+
import { ConnectorMode, FontFamily, PointStyle, ShapeStyle, StrokeStyle, } from '@formicoidea/labre-core/model';
|
|
5
|
+
import { EditPropsStore, TelemetryProvider, } from '@formicoidea/labre-core/shared/services';
|
|
6
|
+
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
7
|
+
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
8
|
+
import { css, html, LitElement } from 'lit';
|
|
9
|
+
import { EVENT_END, EVENT_START, END_WIDTH, INNER_FONT_SIZE, NEUTRAL_STROKE, NODE_FILL, NODE_LABEL, NODE_SIZE, NODE_STROKE_WIDTH, SEQUENCE_STROKE, SEQUENCE_WIDTH, START_WIDTH, TASK_RADIUS, } from '../consts';
|
|
10
|
+
import { bpmnEndIcon, bpmnGatewayIcon, bpmnPoolIcon, bpmnSequenceIcon, bpmnStartIcon, bpmnTaskIcon, } from './icons';
|
|
11
|
+
/** Per-kind native shape + accent presets (style C). */
|
|
12
|
+
const NODE_PRESETS = {
|
|
13
|
+
startEvent: { shapeType: 'ellipse', stroke: EVENT_START, width: START_WIDTH },
|
|
14
|
+
endEvent: { shapeType: 'ellipse', stroke: EVENT_END, width: END_WIDTH },
|
|
15
|
+
task: { shapeType: 'rect', stroke: NEUTRAL_STROKE, width: NODE_STROKE_WIDTH },
|
|
16
|
+
gatewayExclusive: {
|
|
17
|
+
shapeType: 'diamond',
|
|
18
|
+
stroke: NEUTRAL_STROKE,
|
|
19
|
+
width: NODE_STROKE_WIDTH,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The popover above the toolbar for the BPMN toolbox. Items create the flow
|
|
24
|
+
* objects (native shapes, so they stay editable), the pool background, and arm
|
|
25
|
+
* the native connector tool for sequence flows. Mirrors the EDGY menu.
|
|
26
|
+
*/
|
|
27
|
+
export class EdgelessBpmnMenu extends EdgelessToolbarToolMixin(LitElement) {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.type = EmptyTool;
|
|
31
|
+
}
|
|
32
|
+
static { this.styles = css `
|
|
33
|
+
:host {
|
|
34
|
+
position: absolute;
|
|
35
|
+
display: flex;
|
|
36
|
+
z-index: -1;
|
|
37
|
+
}
|
|
38
|
+
.menu-content {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
}
|
|
43
|
+
.button-group-container {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 14px;
|
|
47
|
+
fill: var(--affine-icon-color);
|
|
48
|
+
}
|
|
49
|
+
.button-group-container svg {
|
|
50
|
+
width: 24px;
|
|
51
|
+
height: 24px;
|
|
52
|
+
}
|
|
53
|
+
`; }
|
|
54
|
+
/** Create a flow-object node (native shape) centred on the viewport. */
|
|
55
|
+
_createNode(kind) {
|
|
56
|
+
const surface = this.gfx.surface;
|
|
57
|
+
if (!surface)
|
|
58
|
+
return;
|
|
59
|
+
const { w, h } = NODE_SIZE[kind];
|
|
60
|
+
const { centerX: cx, centerY: cy } = this.gfx.viewport;
|
|
61
|
+
const preset = NODE_PRESETS[kind];
|
|
62
|
+
const id = surface.addElement({
|
|
63
|
+
type: 'bpmnNode',
|
|
64
|
+
kind,
|
|
65
|
+
shapeType: preset.shapeType,
|
|
66
|
+
filled: true,
|
|
67
|
+
fillColor: NODE_FILL,
|
|
68
|
+
strokeColor: preset.stroke,
|
|
69
|
+
strokeWidth: preset.width,
|
|
70
|
+
shapeStyle: ShapeStyle.General,
|
|
71
|
+
roughness: 0,
|
|
72
|
+
radius: kind === 'task' ? TASK_RADIUS : 0,
|
|
73
|
+
text: NODE_LABEL[kind] || undefined,
|
|
74
|
+
color: NEUTRAL_STROKE,
|
|
75
|
+
fontFamily: FontFamily.Inter,
|
|
76
|
+
fontSize: INNER_FONT_SIZE,
|
|
77
|
+
textAlign: 'center',
|
|
78
|
+
xywh: new Bound(cx - w / 2, cy - h / 2, w, h).serialize(),
|
|
79
|
+
});
|
|
80
|
+
this._track('FrameworkElementAdded', `node:${kind}`);
|
|
81
|
+
this._finish(id);
|
|
82
|
+
}
|
|
83
|
+
/** Create a pool (background container) centred on the viewport. */
|
|
84
|
+
_createPool() {
|
|
85
|
+
const surface = this.gfx.surface;
|
|
86
|
+
if (!surface)
|
|
87
|
+
return;
|
|
88
|
+
const w = 560;
|
|
89
|
+
const h = 200;
|
|
90
|
+
const { centerX: cx, centerY: cy } = this.gfx.viewport;
|
|
91
|
+
const id = surface.addElement({
|
|
92
|
+
type: 'bpmnPool',
|
|
93
|
+
xywh: new Bound(cx - w / 2, cy - h / 2, w, h).serialize(),
|
|
94
|
+
});
|
|
95
|
+
this._track('FrameworkElementAdded', 'pool');
|
|
96
|
+
this._finish(id);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Arm the native connector tool, pre-styled for a BPMN sequence flow:
|
|
100
|
+
* orthogonal, solid, with a filled triangle head. The user then draws from
|
|
101
|
+
* one node to another (endpoints attach to centers).
|
|
102
|
+
*/
|
|
103
|
+
_activateSequenceFlow() {
|
|
104
|
+
this.edgeless.std.get(EditPropsStore).recordLastProps('connector', {
|
|
105
|
+
mode: ConnectorMode.Orthogonal,
|
|
106
|
+
stroke: SEQUENCE_STROKE,
|
|
107
|
+
strokeStyle: StrokeStyle.Solid,
|
|
108
|
+
strokeWidth: SEQUENCE_WIDTH,
|
|
109
|
+
frontEndpointStyle: PointStyle.None,
|
|
110
|
+
rearEndpointStyle: PointStyle.Triangle,
|
|
111
|
+
});
|
|
112
|
+
this._track('FrameworkToolPicked', 'connector:sequence');
|
|
113
|
+
this.gfx.tool.setTool(ConnectorTool, { mode: ConnectorMode.Orthogonal });
|
|
114
|
+
// Keep the palette open (native sub-menu behaviour).
|
|
115
|
+
}
|
|
116
|
+
_finish(id) {
|
|
117
|
+
const { gfx } = this;
|
|
118
|
+
gfx.doc.captureSync();
|
|
119
|
+
gfx.tool.setTool(DefaultTool);
|
|
120
|
+
gfx.selection.set({ elements: [id], editing: false });
|
|
121
|
+
// Keep the palette open (native sub-menu behaviour).
|
|
122
|
+
}
|
|
123
|
+
_track(event, element) {
|
|
124
|
+
this.edgeless.std.getOptional(TelemetryProvider)?.track(event, {
|
|
125
|
+
framework: 'bpmn',
|
|
126
|
+
element,
|
|
127
|
+
page: 'whiteboard editor',
|
|
128
|
+
segment: 'bpmn toolbox',
|
|
129
|
+
module: 'bpmn menu',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
return html `
|
|
134
|
+
<edgeless-slide-menu>
|
|
135
|
+
<div class="menu-content">
|
|
136
|
+
<div class="button-group-container">
|
|
137
|
+
<edgeless-tool-icon-button
|
|
138
|
+
.tooltip=${'Start event'}
|
|
139
|
+
@click=${() => this._createNode('startEvent')}
|
|
140
|
+
>
|
|
141
|
+
${bpmnStartIcon}
|
|
142
|
+
</edgeless-tool-icon-button>
|
|
143
|
+
<edgeless-tool-icon-button
|
|
144
|
+
.tooltip=${'End event'}
|
|
145
|
+
@click=${() => this._createNode('endEvent')}
|
|
146
|
+
>
|
|
147
|
+
${bpmnEndIcon}
|
|
148
|
+
</edgeless-tool-icon-button>
|
|
149
|
+
<edgeless-tool-icon-button
|
|
150
|
+
.tooltip=${'Task'}
|
|
151
|
+
@click=${() => this._createNode('task')}
|
|
152
|
+
>
|
|
153
|
+
${bpmnTaskIcon}
|
|
154
|
+
</edgeless-tool-icon-button>
|
|
155
|
+
<edgeless-tool-icon-button
|
|
156
|
+
.tooltip=${'Exclusive gateway'}
|
|
157
|
+
@click=${() => this._createNode('gatewayExclusive')}
|
|
158
|
+
>
|
|
159
|
+
${bpmnGatewayIcon}
|
|
160
|
+
</edgeless-tool-icon-button>
|
|
161
|
+
<edgeless-tool-icon-button
|
|
162
|
+
.tooltip=${'Sequence flow'}
|
|
163
|
+
@click=${this._activateSequenceFlow}
|
|
164
|
+
>
|
|
165
|
+
${bpmnSequenceIcon}
|
|
166
|
+
</edgeless-tool-icon-button>
|
|
167
|
+
<edgeless-tool-icon-button
|
|
168
|
+
.tooltip=${'Pool'}
|
|
169
|
+
@click=${this._createPool}
|
|
170
|
+
>
|
|
171
|
+
${bpmnPoolIcon}
|
|
172
|
+
</edgeless-tool-icon-button>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
</edgeless-slide-menu>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=bpmn-menu.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
declare const EdgelessBpmnSeniorButton_base: typeof LitElement & import("@formicoidea/labre-core/global/utils").Constructor<import("@formicoidea/labre-core/widgets/edgeless-toolbar").EdgelessToolbarToolClass>;
|
|
4
|
+
/**
|
|
5
|
+
* Main toolbar button (colored BPMN glyph) that opens the BPMN toolbox sub-menu
|
|
6
|
+
* above the toolbar. Mirrors the EDGY / Wardley senior buttons.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EdgelessBpmnSeniorButton extends EdgelessBpmnSeniorButton_base {
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
enableActiveBackground: boolean;
|
|
11
|
+
type: typeof EmptyTool;
|
|
12
|
+
private _toggleMenu;
|
|
13
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=bpmn-senior-button.d.ts.map
|
|
@@ -3,17 +3,18 @@ import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
|
3
3
|
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
4
4
|
import { SignalWatcher } from '@formicoidea/labre-core/global/lit';
|
|
5
5
|
import { css, html, LitElement } from 'lit';
|
|
6
|
-
|
|
7
6
|
import { bpmnToolbarIcon } from './icons';
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* Main toolbar button (colored BPMN glyph) that opens the BPMN toolbox sub-menu
|
|
11
9
|
* above the toolbar. Mirrors the EDGY / Wardley senior buttons.
|
|
12
10
|
*/
|
|
13
|
-
export class EdgelessBpmnSeniorButton extends EdgelessToolbarToolMixin(
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
|
|
11
|
+
export class EdgelessBpmnSeniorButton extends EdgelessToolbarToolMixin(SignalWatcher(LitElement)) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.enableActiveBackground = true;
|
|
15
|
+
this.type = EmptyTool;
|
|
16
|
+
}
|
|
17
|
+
static { this.styles = css `
|
|
17
18
|
:host,
|
|
18
19
|
.bpmn-button {
|
|
19
20
|
display: block;
|
|
@@ -56,38 +57,31 @@ export class EdgelessBpmnSeniorButton extends EdgelessToolbarToolMixin(
|
|
|
56
57
|
--y: -10px;
|
|
57
58
|
--s: 1.07;
|
|
58
59
|
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
`; }
|
|
61
|
+
_toggleMenu() {
|
|
62
|
+
if (this.popper) {
|
|
63
|
+
this.popper.dispose();
|
|
64
|
+
this.popper = null;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.setEdgelessTool(DefaultTool);
|
|
68
|
+
const menu = this.createPopper('edgeless-bpmn-menu', this);
|
|
69
|
+
menu.element.edgeless = this.edgeless;
|
|
70
|
+
const el = menu.element;
|
|
71
|
+
const wrap = el.parentElement;
|
|
72
|
+
if (wrap) {
|
|
73
|
+
wrap.style.overflow = 'visible';
|
|
74
|
+
wrap.style.justifyContent = 'flex-end';
|
|
75
|
+
}
|
|
76
|
+
Object.assign(el.style, {
|
|
77
|
+
position: 'static',
|
|
78
|
+
width: 'max-content',
|
|
79
|
+
maxWidth: 'calc(100vw - 16px)',
|
|
80
|
+
marginLeft: '0',
|
|
81
|
+
});
|
|
80
82
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
width: 'max-content',
|
|
84
|
-
maxWidth: 'calc(100vw - 16px)',
|
|
85
|
-
marginLeft: '0',
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
override render() {
|
|
90
|
-
return html`<edgeless-toolbar-button
|
|
83
|
+
render() {
|
|
84
|
+
return html `<edgeless-toolbar-button
|
|
91
85
|
class="bpmn-button"
|
|
92
86
|
.tooltip=${this.popper ? '' : 'BPMN'}
|
|
93
87
|
.tooltipOffset=${4}
|
|
@@ -98,5 +92,6 @@ export class EdgelessBpmnSeniorButton extends EdgelessToolbarToolMixin(
|
|
|
98
92
|
<div class="bpmn-card">${bpmnToolbarIcon}</div>
|
|
99
93
|
</div>
|
|
100
94
|
</edgeless-toolbar-button>`;
|
|
101
|
-
|
|
95
|
+
}
|
|
102
96
|
}
|
|
97
|
+
//# sourceMappingURL=bpmn-senior-button.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ToolbarContext } from '@formicoidea/labre-core/shared/services';
|
|
2
|
+
import { type TemplateResult } from 'lit';
|
|
3
|
+
export declare const bpmnPoolToolbarConfig: {
|
|
4
|
+
readonly actions: [{
|
|
5
|
+
id: string;
|
|
6
|
+
tooltip: string;
|
|
7
|
+
icon: TemplateResult;
|
|
8
|
+
active(ctx: ToolbarContext): boolean;
|
|
9
|
+
run(ctx: ToolbarContext): void;
|
|
10
|
+
}];
|
|
11
|
+
readonly when: (ctx: ToolbarContext) => boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const bpmnPoolToolbarExtension: import("@formicoidea/labre-core/store").ExtensionType;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { BpmnPoolElementModel } from '@formicoidea/labre-core/model';
|
|
3
|
+
import { ToolbarModuleExtension, } from '@formicoidea/labre-core/shared/services';
|
|
4
|
+
import { BlockFlavourIdentifier } from '@formicoidea/labre-core/std';
|
|
5
|
+
import { html } from 'lit';
|
|
6
|
+
const ResizeIcon = html `<svg
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke="currentColor"
|
|
12
|
+
stroke-width="1.6"
|
|
13
|
+
stroke-linecap="round"
|
|
14
|
+
stroke-linejoin="round"
|
|
15
|
+
>
|
|
16
|
+
<path d="M9 5H5v4M15 19h4v-4" />
|
|
17
|
+
<path d="M5 5l6 6M19 19l-6-6" />
|
|
18
|
+
</svg>`;
|
|
19
|
+
/**
|
|
20
|
+
* Build a toolbar toggle that flips a boolean flag on every selected pool:
|
|
21
|
+
* `active` reflects the current state, `run` flips it (with an undo checkpoint).
|
|
22
|
+
*/
|
|
23
|
+
function booleanToggle(id, tooltip, icon, prop) {
|
|
24
|
+
return {
|
|
25
|
+
id,
|
|
26
|
+
tooltip,
|
|
27
|
+
icon,
|
|
28
|
+
active(ctx) {
|
|
29
|
+
const models = ctx.getSurfaceModelsByType(BpmnPoolElementModel);
|
|
30
|
+
return models.length > 0 && models.every(model => model[prop]);
|
|
31
|
+
},
|
|
32
|
+
run(ctx) {
|
|
33
|
+
const models = ctx.getSurfaceModelsByType(BpmnPoolElementModel);
|
|
34
|
+
if (!models.length)
|
|
35
|
+
return;
|
|
36
|
+
const enable = !models.every(model => model[prop]);
|
|
37
|
+
ctx.std.store.captureSync();
|
|
38
|
+
const crud = ctx.std.get(EdgelessCRUDIdentifier);
|
|
39
|
+
for (const model of models) {
|
|
40
|
+
crud.updateElement(model.id, { [prop]: enable });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export const bpmnPoolToolbarConfig = {
|
|
46
|
+
actions: [
|
|
47
|
+
booleanToggle('a.toggle-resize', 'Enable / lock resizing', ResizeIcon, 'resizeEnabled'),
|
|
48
|
+
],
|
|
49
|
+
when: ctx => ctx.getSurfaceModelsByType(BpmnPoolElementModel).length > 0,
|
|
50
|
+
};
|
|
51
|
+
export const bpmnPoolToolbarExtension = ToolbarModuleExtension({
|
|
52
|
+
id: BlockFlavourIdentifier('affine:surface:bpmnPool'),
|
|
53
|
+
config: bpmnPoolToolbarConfig,
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Colored BPMN glyph for the main toolbar button: a pool (green name band) with
|
|
2
|
+
* a single activity inside. */
|
|
3
|
+
export declare const bpmnToolbarIcon: import("lit-html").TemplateResult<2>;
|
|
4
|
+
/** Start event — thin green ring. */
|
|
5
|
+
export declare const bpmnStartIcon: import("lit-html").TemplateResult<2>;
|
|
6
|
+
/** End event — thick red ring. */
|
|
7
|
+
export declare const bpmnEndIcon: import("lit-html").TemplateResult<2>;
|
|
8
|
+
/** Task — rounded rectangle. */
|
|
9
|
+
export declare const bpmnTaskIcon: import("lit-html").TemplateResult<2>;
|
|
10
|
+
/** Exclusive gateway — diamond with an X. */
|
|
11
|
+
export declare const bpmnGatewayIcon: import("lit-html").TemplateResult<2>;
|
|
12
|
+
/** Sequence flow — solid arrow with a filled head. */
|
|
13
|
+
export declare const bpmnSequenceIcon: import("lit-html").TemplateResult<2>;
|
|
14
|
+
/** Pool — rectangle with a left name band. */
|
|
15
|
+
export declare const bpmnPoolIcon: import("lit-html").TemplateResult<2>;
|
|
16
|
+
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -1,43 +1,37 @@
|
|
|
1
1
|
import { svg } from 'lit';
|
|
2
|
-
|
|
3
2
|
/** Colored BPMN glyph for the main toolbar button: a pool (green name band) with
|
|
4
3
|
* a single activity inside. */
|
|
5
|
-
export const bpmnToolbarIcon = svg`<svg width="100%" height="100%" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
export const bpmnToolbarIcon = svg `<svg width="100%" height="100%" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6
5
|
<rect x="4" y="13" width="48" height="30" rx="3" fill="#ffffff" stroke="#262626" stroke-width="2.2"/>
|
|
7
6
|
<path d="M6 14 h5 v28 h-5 z" fill="#43a06b"/>
|
|
8
7
|
<line x1="11" y1="13" x2="11" y2="43" stroke="#262626" stroke-width="1.8"/>
|
|
9
8
|
<rect x="20" y="20" width="24" height="16" rx="3.5" fill="#ffffff" stroke="#262626" stroke-width="2.2"/>
|
|
10
9
|
</svg>`;
|
|
11
|
-
|
|
12
10
|
/** Start event — thin green ring. */
|
|
13
|
-
export const bpmnStartIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
11
|
+
export const bpmnStartIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
14
12
|
<circle cx="12" cy="12" r="8" stroke="#43a06b" stroke-width="2"/>
|
|
15
13
|
</svg>`;
|
|
16
|
-
|
|
17
14
|
/** End event — thick red ring. */
|
|
18
|
-
export const bpmnEndIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
export const bpmnEndIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
19
16
|
<circle cx="12" cy="12" r="8" stroke="#cf5648" stroke-width="3.5"/>
|
|
20
17
|
</svg>`;
|
|
21
|
-
|
|
22
18
|
/** Task — rounded rectangle. */
|
|
23
|
-
export const bpmnTaskIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
19
|
+
export const bpmnTaskIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
24
20
|
<rect x="3.5" y="6.5" width="17" height="11" rx="2.5" stroke="currentColor" stroke-width="1.6"/>
|
|
25
21
|
</svg>`;
|
|
26
|
-
|
|
27
22
|
/** Exclusive gateway — diamond with an X. */
|
|
28
|
-
export const bpmnGatewayIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
23
|
+
export const bpmnGatewayIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
24
|
<path d="M12 3 L21 12 L12 21 L3 12 Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
|
|
30
25
|
<path d="M9 9 L15 15 M15 9 L9 15" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
|
|
31
26
|
</svg>`;
|
|
32
|
-
|
|
33
27
|
/** Sequence flow — solid arrow with a filled head. */
|
|
34
|
-
export const bpmnSequenceIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
28
|
+
export const bpmnSequenceIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
35
29
|
<path d="M3 12 H17" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
36
30
|
<path d="M15 8 L21 12 L15 16 Z" fill="currentColor"/>
|
|
37
31
|
</svg>`;
|
|
38
|
-
|
|
39
32
|
/** Pool — rectangle with a left name band. */
|
|
40
|
-
export const bpmnPoolIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
33
|
+
export const bpmnPoolIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
41
34
|
<rect x="3.5" y="5.5" width="17" height="13" rx="1.5" stroke="currentColor" stroke-width="1.6"/>
|
|
42
35
|
<path d="M8 5.5 V18.5" stroke="currentColor" stroke-width="1.6"/>
|
|
43
36
|
</svg>`;
|
|
37
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SeniorToolExtension } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
2
2
|
import { html } from 'lit';
|
|
3
|
-
|
|
4
3
|
export const bpmnSeniorTool = SeniorToolExtension('bpmn', ({ block }) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
return {
|
|
5
|
+
name: 'BPMN',
|
|
6
|
+
content: html `<edgeless-bpmn-senior-button
|
|
8
7
|
.edgeless=${block}
|
|
9
8
|
></edgeless-bpmn-senior-button>`,
|
|
10
|
-
|
|
9
|
+
};
|
|
11
10
|
});
|
|
11
|
+
//# sourceMappingURL=senior-tool.js.map
|
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ViewExtensionContext, ViewExtensionProvider } from '@formicoidea/labre-core/ext-loader';
|
|
2
|
+
export declare class BpmnViewExtension extends ViewExtensionProvider {
|
|
3
|
+
name: string;
|
|
4
|
+
effect(): void;
|
|
5
|
+
setup(context: ViewExtensionContext): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=view.d.ts.map
|
package/dist/view.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ViewExtensionProvider, } from '@formicoidea/labre-core/ext-loader';
|
|
2
|
+
import { extendTemplateCategory } from '@formicoidea/labre-core/gfx/template';
|
|
3
|
+
import { effects } from './effects';
|
|
4
|
+
import { bpmnTemplateCategory } from './templates';
|
|
5
|
+
import { BpmnPoolRendererExtension } from './element-renderer';
|
|
6
|
+
import { BpmnPoolInteraction, BpmnPoolView } from './element-view';
|
|
7
|
+
import { BpmnNodeRendererExtension } from './node/node-renderer';
|
|
8
|
+
import { BpmnNodeView } from './node/node-view';
|
|
9
|
+
import { bpmnPoolToolbarExtension } from './toolbar/config';
|
|
10
|
+
import { bpmnSeniorTool } from './toolbar/senior-tool';
|
|
11
|
+
export class BpmnViewExtension extends ViewExtensionProvider {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.name = 'affine-bpmn-gfx';
|
|
15
|
+
}
|
|
16
|
+
effect() {
|
|
17
|
+
super.effect();
|
|
18
|
+
effects();
|
|
19
|
+
extendTemplateCategory(bpmnTemplateCategory);
|
|
20
|
+
}
|
|
21
|
+
setup(context) {
|
|
22
|
+
super.setup(context);
|
|
23
|
+
context.register(BpmnPoolView);
|
|
24
|
+
context.register(BpmnPoolRendererExtension);
|
|
25
|
+
context.register(BpmnNodeView);
|
|
26
|
+
context.register(BpmnNodeRendererExtension);
|
|
27
|
+
if (this.isEdgeless(context.scope)) {
|
|
28
|
+
context.register(BpmnPoolInteraction);
|
|
29
|
+
context.register(bpmnSeniorTool);
|
|
30
|
+
context.register(bpmnPoolToolbarExtension);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=view.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formicoidea/labre-framework-bpmn",
|
|
3
3
|
"description": "Labre bpmn framework for @formicoidea/labre-core.",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"author": "lajola",
|
|
@@ -10,15 +10,24 @@
|
|
|
10
10
|
],
|
|
11
11
|
"license": "MPL-2.0",
|
|
12
12
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./view": {
|
|
18
|
+
"types": "./dist/view.d.ts",
|
|
19
|
+
"import": "./dist/view.js"
|
|
20
|
+
},
|
|
21
|
+
"./descriptor": {
|
|
22
|
+
"types": "./dist/descriptor.d.ts",
|
|
23
|
+
"import": "./dist/descriptor.js"
|
|
24
|
+
}
|
|
16
25
|
},
|
|
17
26
|
"files": [
|
|
18
|
-
"
|
|
27
|
+
"dist"
|
|
19
28
|
],
|
|
20
29
|
"dependencies": {
|
|
21
|
-
"@formicoidea/labre-core": "0.23.
|
|
30
|
+
"@formicoidea/labre-core": "0.23.1",
|
|
22
31
|
"lit": "^3.2.0"
|
|
23
32
|
}
|
|
24
33
|
}
|
package/src/effects.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EdgelessBpmnMenu } from './toolbar/bpmn-menu';
|
|
2
|
-
import { EdgelessBpmnSeniorButton } from './toolbar/bpmn-senior-button';
|
|
3
|
-
|
|
4
|
-
export function effects() {
|
|
5
|
-
customElements.define('edgeless-bpmn-menu', EdgelessBpmnMenu);
|
|
6
|
-
customElements.define('edgeless-bpmn-senior-button', EdgelessBpmnSeniorButton);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare global {
|
|
10
|
-
interface HTMLElementTagNameMap {
|
|
11
|
-
'edgeless-bpmn-menu': EdgelessBpmnMenu;
|
|
12
|
-
'edgeless-bpmn-senior-button': EdgelessBpmnSeniorButton;
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/element-renderer.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ElementRenderer,
|
|
3
|
-
ElementRendererExtension,
|
|
4
|
-
} from '@formicoidea/labre-core/blocks/surface';
|
|
5
|
-
import type { BpmnPoolElementModel } from '@formicoidea/labre-core/model';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
POOL_BAND_FILL,
|
|
9
|
-
POOL_BAND_WIDTH,
|
|
10
|
-
POOL_FONT_FAMILY,
|
|
11
|
-
POOL_FRAME_COLOR,
|
|
12
|
-
POOL_FRAME_WIDTH,
|
|
13
|
-
POOL_NAME_COLOR,
|
|
14
|
-
POOL_NAME_FONT_SIZE,
|
|
15
|
-
} from './consts';
|
|
16
|
-
|
|
17
|
-
/** Trace a rounded-rectangle path (no dependency on ctx.roundRect). */
|
|
18
|
-
function roundedRectPath(
|
|
19
|
-
ctx: CanvasRenderingContext2D,
|
|
20
|
-
x: number,
|
|
21
|
-
y: number,
|
|
22
|
-
w: number,
|
|
23
|
-
h: number,
|
|
24
|
-
r: number
|
|
25
|
-
): void {
|
|
26
|
-
const rr = Math.min(r, w / 2, h / 2);
|
|
27
|
-
ctx.beginPath();
|
|
28
|
-
ctx.moveTo(x + rr, y);
|
|
29
|
-
ctx.lineTo(x + w - rr, y);
|
|
30
|
-
ctx.arcTo(x + w, y, x + w, y + rr, rr);
|
|
31
|
-
ctx.lineTo(x + w, y + h - rr);
|
|
32
|
-
ctx.arcTo(x + w, y + h, x + w - rr, y + h, rr);
|
|
33
|
-
ctx.lineTo(x + rr, y + h);
|
|
34
|
-
ctx.arcTo(x, y + h, x, y + h - rr, rr);
|
|
35
|
-
ctx.lineTo(x, y + rr);
|
|
36
|
-
ctx.arcTo(x, y, x + rr, y, rr);
|
|
37
|
-
ctx.closePath();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Canvas renderer for a BPMN pool: a rounded-rect frame with a vertical name
|
|
42
|
-
* band on the left (the participant name is drawn rotated, as in the spec).
|
|
43
|
-
* Drawn directly in element space; the band width and font are fixed so they
|
|
44
|
-
* stay legible at any pool size. Mirrors the other framework backgrounds.
|
|
45
|
-
*/
|
|
46
|
-
export const bpmnPool: ElementRenderer<BpmnPoolElementModel> = (
|
|
47
|
-
model,
|
|
48
|
-
ctx,
|
|
49
|
-
matrix
|
|
50
|
-
) => {
|
|
51
|
-
const [, , w, h] = model.deserializedXYWH;
|
|
52
|
-
const cx = w / 2;
|
|
53
|
-
const cy = h / 2;
|
|
54
|
-
ctx.setTransform(
|
|
55
|
-
matrix.translateSelf(cx, cy).rotateSelf(model.rotate).translateSelf(-cx, -cy)
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const band = Math.min(POOL_BAND_WIDTH, w);
|
|
59
|
-
const inset = POOL_FRAME_WIDTH / 2;
|
|
60
|
-
|
|
61
|
-
// Name band (left), filled.
|
|
62
|
-
ctx.fillStyle = POOL_BAND_FILL;
|
|
63
|
-
ctx.fillRect(0, 0, band, h);
|
|
64
|
-
|
|
65
|
-
// Frame + band divider.
|
|
66
|
-
ctx.strokeStyle = POOL_FRAME_COLOR;
|
|
67
|
-
ctx.lineWidth = POOL_FRAME_WIDTH;
|
|
68
|
-
ctx.lineJoin = 'round';
|
|
69
|
-
roundedRectPath(ctx, inset, inset, w - POOL_FRAME_WIDTH, h - POOL_FRAME_WIDTH, 6);
|
|
70
|
-
ctx.stroke();
|
|
71
|
-
ctx.beginPath();
|
|
72
|
-
ctx.moveTo(band, 0);
|
|
73
|
-
ctx.lineTo(band, h);
|
|
74
|
-
ctx.stroke();
|
|
75
|
-
|
|
76
|
-
// Participant name, rotated to read up the band (skip when empty / too narrow).
|
|
77
|
-
if (model.name && band > 12) {
|
|
78
|
-
ctx.save();
|
|
79
|
-
ctx.translate(band / 2, h / 2);
|
|
80
|
-
ctx.rotate(-Math.PI / 2);
|
|
81
|
-
ctx.fillStyle = POOL_NAME_COLOR;
|
|
82
|
-
ctx.font = `600 ${POOL_NAME_FONT_SIZE}px ${POOL_FONT_FAMILY}`;
|
|
83
|
-
ctx.textAlign = 'center';
|
|
84
|
-
ctx.textBaseline = 'middle';
|
|
85
|
-
ctx.fillText(model.name, 0, 0);
|
|
86
|
-
ctx.restore();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const BpmnPoolRendererExtension = ElementRendererExtension(
|
|
91
|
-
'bpmnPool',
|
|
92
|
-
bpmnPool
|
|
93
|
-
);
|