@formicoidea/labre-framework-bpmn 0.23.1 → 0.23.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/package.json +6 -15
- package/{dist/consts.js → src/consts.ts} +57 -48
- package/{dist/descriptor.js → src/descriptor.ts} +1 -1
- package/src/effects.ts +14 -0
- package/src/element-renderer.ts +93 -0
- package/src/element-view.ts +116 -0
- package/src/index.ts +1 -0
- package/src/node/node-renderer.ts +65 -0
- package/src/node/node-view.ts +34 -0
- package/src/templates/index.ts +156 -0
- package/src/toolbar/bpmn-menu.ts +224 -0
- package/{dist/toolbar/bpmn-senior-button.js → src/toolbar/bpmn-senior-button.ts} +102 -97
- package/src/toolbar/config.ts +74 -0
- package/{dist/toolbar/icons.js → src/toolbar/icons.ts} +43 -37
- package/{dist/toolbar/senior-tool.js → src/toolbar/senior-tool.ts} +11 -11
- package/src/view.ts +37 -0
- package/dist/consts.d.ts +0 -42
- package/dist/descriptor.d.ts +0 -7
- package/dist/effects.d.ts +0 -10
- package/dist/effects.js +0 -7
- package/dist/element-renderer.d.ts +0 -13
- package/dist/element-renderer.js +0 -58
- package/dist/element-view.d.ts +0 -22
- package/dist/element-view.js +0 -103
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/node/node-renderer.d.ts +0 -16
- package/dist/node/node-renderer.js +0 -43
- package/dist/node/node-view.d.ts +0 -17
- package/dist/node/node-view.js +0 -28
- package/dist/templates/index.d.ts +0 -3
- package/dist/templates/index.js +0 -114
- package/dist/toolbar/bpmn-menu.d.ts +0 -27
- package/dist/toolbar/bpmn-menu.js +0 -179
- package/dist/toolbar/bpmn-senior-button.d.ts +0 -16
- package/dist/toolbar/config.d.ts +0 -14
- package/dist/toolbar/config.js +0 -55
- package/dist/toolbar/icons.d.ts +0 -16
- package/dist/toolbar/senior-tool.d.ts +0 -2
- package/dist/view.d.ts +0 -7
- package/dist/view.js +0 -34
|
@@ -1,179 +0,0 @@
|
|
|
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
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
package/dist/toolbar/config.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
package/dist/toolbar/config.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
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
|
package/dist/toolbar/icons.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
package/dist/view.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|