@formicoidea/labre-framework-ddd-event-storming 0.31.0 → 0.33.0

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,86 @@
1
+ import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
2
+ import { createAutoLegend, dddLegendIcon } from '@formicoidea/labre-ddd-shared';
3
+ import { EventStormingBoardElementModel } from '@formicoidea/labre-core/model';
4
+ import { TelemetryProvider, ToolbarModuleExtension, } from '@formicoidea/labre-core/shared/services';
5
+ import { BlockFlavourIdentifier } from '@formicoidea/labre-core/std';
6
+ import { html } from 'lit';
7
+ import { EVENT_STORMING_AUTO_LEGEND } from '../legend.js';
8
+ const ResizeIcon = html `<svg
9
+ width="24"
10
+ height="24"
11
+ viewBox="0 0 24 24"
12
+ fill="none"
13
+ stroke="currentColor"
14
+ stroke-width="1.6"
15
+ stroke-linecap="round"
16
+ stroke-linejoin="round"
17
+ >
18
+ <path d="M9 5H5v4M15 19h4v-4" />
19
+ <path d="M5 5l6 6M19 19l-6-6" />
20
+ </svg>`;
21
+ /**
22
+ * The selected board's contextual toolbar: the resize toggle, and the automatic
23
+ * legend of the sticky kinds actually stuck to the board. Registered ALWAYS-ON
24
+ * (`DddEventStormingRenderViewExtension`) — a stored board must stay usable with
25
+ * the Event Storming button switched off (`docs/adr/0009`), legend included: a
26
+ * legend is real editable elements, so generating one is authoring a document,
27
+ * not tooling that a flag may take away.
28
+ *
29
+ * This is the module's ONLY legend gesture: the Event Storming palette never had
30
+ * a static Legend entry, and a wall of colour-coded stickies is exactly the
31
+ * board a reader needs one for.
32
+ */
33
+ export const eventStormingBoardToolbarConfig = {
34
+ actions: [
35
+ {
36
+ id: 'a.toggle-resize',
37
+ tooltip: 'Enable / lock resizing',
38
+ icon: ResizeIcon,
39
+ active(ctx) {
40
+ const models = ctx.getSurfaceModelsByType(EventStormingBoardElementModel);
41
+ return models.length > 0 && models.every(model => model.resizeEnabled);
42
+ },
43
+ run(ctx) {
44
+ const models = ctx.getSurfaceModelsByType(EventStormingBoardElementModel);
45
+ if (!models.length)
46
+ return;
47
+ const enable = !models.every(model => model.resizeEnabled);
48
+ ctx.std.store.captureSync();
49
+ const crud = ctx.std.get(EdgelessCRUDIdentifier);
50
+ for (const model of models) {
51
+ crud.updateElement(model.id, { resizeEnabled: enable });
52
+ }
53
+ },
54
+ },
55
+ {
56
+ id: 'b.legend',
57
+ tooltip: 'Generate the legend (notation present)',
58
+ icon: dddLegendIcon,
59
+ run(ctx) {
60
+ const board = ctx.getSurfaceModelsByType(EventStormingBoardElementModel)[0];
61
+ if (!board)
62
+ return;
63
+ createAutoLegend(ctx.std, board, EVENT_STORMING_AUTO_LEGEND);
64
+ ctx.std
65
+ .getOptional(TelemetryProvider)
66
+ ?.track('FrameworkLegendCreated', {
67
+ // The WIRE value, which is not the module id: the framework is
68
+ // `ddd-event-storming` in code and `event-storming` in PostHog
69
+ // (`frameworks.ts` `telemetryKey`, and the only value
70
+ // `FrameworkElementEvent` accepts). Same convention as Wardley's own
71
+ // legend button, so the two are comparable.
72
+ framework: 'event-storming',
73
+ element: 'legend',
74
+ page: 'whiteboard editor',
75
+ segment: 'element toolbar',
76
+ module: 'event-storming toolbar',
77
+ });
78
+ },
79
+ },
80
+ ],
81
+ when: (ctx) => ctx.getSurfaceModelsByType(EventStormingBoardElementModel).length > 0,
82
+ };
83
+ export const eventStormingBoardToolbarExtension = ToolbarModuleExtension({
84
+ id: BlockFlavourIdentifier('affine:surface:eventStorming'),
85
+ config: eventStormingBoardToolbarConfig,
86
+ });
@@ -1,9 +1,16 @@
1
- import { DddMenuBase } from '@formicoidea/labre-ddd-shared';
2
- /** Event Storming palette: the colour-coded stickies, the hotspot, a flow arrow. */
3
- export declare class EdgelessDddEventStormingMenu extends DddMenuBase {
4
- protected framework: "event-storming";
5
- private _createSticky;
6
- private _createHotspot;
7
- private _createFlow;
8
- render(): import("lit-html").TemplateResult<1>;
1
+ import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
2
+ import { EdgelessCommandMenu } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
3
+ /**
4
+ * Event Storming palette. Since PF3 it declares nothing:
5
+ * {@link EdgelessCommandMenu} renders `eventStormingCommands` for the
6
+ * `senior-menu` surface, and `DddMenuBase` — shell, finish helper and `track`
7
+ * helper — is gone with the duplication it carried (`docs/adr/0008`).
8
+ *
9
+ * The DDD palettes keep their tighter gap: they carry more buttons than the
10
+ * other frameworks (Event Storming: 11, Context Map: 13).
11
+ */
12
+ export declare class EdgelessDddEventStormingMenu extends EdgelessCommandMenu {
13
+ static styles: import("lit").CSSResultGroup[];
14
+ protected owner: "ddd-event-storming";
15
+ type: typeof EmptyTool;
9
16
  }
@@ -1,76 +1,27 @@
1
- import { addConnector, addSticky, DddMenuBase, ES_HOTSPOT, ES_STICKIES, } from '@formicoidea/labre-ddd-shared';
2
- import { html, svg } from 'lit';
3
- const squareSwatch = (color) => svg `<svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="3" fill="${color}"/></svg>`;
4
- const diamondSwatch = (color) => svg `<svg viewBox="0 0 24 24"><rect x="6" y="6" width="12" height="12" transform="rotate(45 12 12)" fill="${color}"/></svg>`;
5
- const flowSwatch = svg `<svg viewBox="0 0 24 24" fill="none"><path d="M4 12 H18" stroke="currentColor" stroke-width="2"/><path d="M16 8 L20 12 L16 16" stroke="currentColor" stroke-width="2" fill="none"/></svg>`;
6
- /** Event Storming palette: the colour-coded stickies, the hotspot, a flow arrow. */
7
- export class EdgelessDddEventStormingMenu extends DddMenuBase {
1
+ import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
2
+ import { EdgelessCommandMenu } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
3
+ import { css } from 'lit';
4
+ /**
5
+ * Event Storming palette. Since PF3 it declares nothing:
6
+ * {@link EdgelessCommandMenu} renders `eventStormingCommands` for the
7
+ * `senior-menu` surface, and `DddMenuBase` — shell, finish helper and `track`
8
+ * helper — is gone with the duplication it carried (`docs/adr/0008`).
9
+ *
10
+ * The DDD palettes keep their tighter gap: they carry more buttons than the
11
+ * other frameworks (Event Storming: 11, Context Map: 13).
12
+ */
13
+ export class EdgelessDddEventStormingMenu extends EdgelessCommandMenu {
8
14
  constructor() {
9
15
  super(...arguments);
10
- this.framework = 'event-storming';
11
- }
12
- _createSticky(preset) {
13
- const surface = this.surface;
14
- if (!surface)
15
- return;
16
- const { cx, cy } = this.center;
17
- const id = addSticky(surface, this.edgeless.std, cx, cy, {
18
- fill: preset.fill,
19
- text: preset.text,
20
- label: preset.label,
21
- });
22
- this.track('FrameworkElementAdded', `sticky:${preset.kind}`);
23
- this.finish(id);
24
- }
25
- _createHotspot() {
26
- const surface = this.surface;
27
- if (!surface)
28
- return;
29
- const { cx, cy } = this.center;
30
- const id = addSticky(surface, this.edgeless.std, cx, cy, {
31
- fill: ES_HOTSPOT.fill,
32
- text: ES_HOTSPOT.text,
33
- label: ES_HOTSPOT.label,
34
- shapeType: 'diamond',
35
- });
36
- this.track('FrameworkElementAdded', 'sticky:hotspot');
37
- this.finish(id);
38
- }
39
- _createFlow() {
40
- const surface = this.surface;
41
- if (!surface)
42
- return;
43
- const { cx, cy } = this.center;
44
- const id = addConnector(surface, cx - 110, cy, cx + 110, cy, { rearArrow: true });
45
- this.track('FrameworkElementAdded', 'flow');
46
- this.finish(id);
47
- }
48
- render() {
49
- return html `
50
- <edgeless-slide-menu>
51
- <div class="menu-content">
52
- <div class="button-group-container">
53
- ${ES_STICKIES.map(preset => html `<edgeless-tool-icon-button
54
- .tooltip=${preset.label}
55
- @click=${() => this._createSticky(preset)}
56
- >
57
- ${squareSwatch(preset.fill)}
58
- </edgeless-tool-icon-button>`)}
59
- <edgeless-tool-icon-button
60
- .tooltip=${ES_HOTSPOT.label}
61
- @click=${() => this._createHotspot()}
62
- >
63
- ${diamondSwatch(ES_HOTSPOT.fill)}
64
- </edgeless-tool-icon-button>
65
- <edgeless-tool-icon-button
66
- .tooltip=${'Flow'}
67
- @click=${() => this._createFlow()}
68
- >
69
- ${flowSwatch}
70
- </edgeless-tool-icon-button>
71
- </div>
72
- </div>
73
- </edgeless-slide-menu>
74
- `;
16
+ this.owner = 'ddd-event-storming';
17
+ this.type = EmptyTool;
75
18
  }
19
+ static { this.styles = [
20
+ EdgelessCommandMenu.styles,
21
+ css `
22
+ :host {
23
+ --labre-command-menu-gap: 10px;
24
+ }
25
+ `,
26
+ ]; }
76
27
  }
@@ -2,5 +2,6 @@ import { DddSeniorButtonBase } from '@formicoidea/labre-ddd-shared';
2
2
  export declare class EdgelessDddEventStormingSeniorButton extends DddSeniorButtonBase {
3
3
  protected menuTag: "edgeless-ddd-event-storming-menu";
4
4
  protected label: string;
5
+ protected labelKey: string;
5
6
  protected icon: import("lit-html").TemplateResult<2>;
6
7
  }
@@ -4,6 +4,7 @@ export class EdgelessDddEventStormingSeniorButton extends DddSeniorButtonBase {
4
4
  super(...arguments);
5
5
  this.menuTag = 'edgeless-ddd-event-storming-menu';
6
6
  this.label = 'Event Storming';
7
+ this.labelKey = 'com.labre.framework.ddd-event-storming';
7
8
  this.icon = eventStormingToolbarIcon;
8
9
  }
9
10
  }
@@ -3,6 +3,7 @@ import { html } from 'lit';
3
3
  /** Independent senior tool — Event Storming. */
4
4
  export const eventStormingSeniorTool = SeniorToolExtension('ddd-event-storming', ({ block }) => ({
5
5
  name: 'Event Storming',
6
+ labelKey: 'com.labre.framework.ddd-event-storming',
6
7
  content: html `<edgeless-ddd-event-storming-senior-button
7
8
  .edgeless=${block}
8
9
  ></edgeless-ddd-event-storming-senior-button>`,
@@ -0,0 +1,16 @@
1
+ import { type TranslationKeyManifestEntry } from '@formicoidea/labre-core/std';
2
+ /**
3
+ * THIS framework's contribution to the translation-key manifest — every
4
+ * `com.labre.*` key Event Storming can hand to `TranslationProvider.t`,
5
+ * derived from the very declarations the editor registers (never restated).
6
+ *
7
+ * Its command labels and descriptions are built from a TEMPLATE, so the
8
+ * concrete keys exist nowhere but in the declarations themselves and the core
9
+ * manifest could not restate them even if it wanted to. The contribution
10
+ * therefore ships WITH the framework: in the bundled distribution
11
+ * `@formicoidea/labre-framework-ddd-event-storming` carries it, and a host
12
+ * composes it into its catalogue exactly as it already composes
13
+ * `eventStormingCommands` into the command registry. See
14
+ * `packages/affine/all/src/translations.ts`.
15
+ */
16
+ export declare const eventStormingTranslationEntries: TranslationKeyManifestEntry[];
@@ -0,0 +1,22 @@
1
+ import { collectTranslationKeys, commandTranslationEntries, mergeTranslationEntries, } from '@formicoidea/labre-core/std';
2
+ import { EVENT_STORMING_BACKGROUND } from './background.js';
3
+ import { eventStormingCommands } from './commands.js';
4
+ import { EVENT_STORMING_NUDGES } from './nudges.js';
5
+ import { EVENT_STORMING_PROFILES } from './profiles.js';
6
+ import { EVENT_STORMING_ROLES } from './roles.js';
7
+ import { EVENT_STORMING_RULES } from './rules.js';
8
+ /**
9
+ * THIS framework's contribution to the translation-key manifest — every
10
+ * `com.labre.*` key Event Storming can hand to `TranslationProvider.t`,
11
+ * derived from the very declarations the editor registers (never restated).
12
+ *
13
+ * Its command labels and descriptions are built from a TEMPLATE, so the
14
+ * concrete keys exist nowhere but in the declarations themselves and the core
15
+ * manifest could not restate them even if it wanted to. The contribution
16
+ * therefore ships WITH the framework: in the bundled distribution
17
+ * `@formicoidea/labre-framework-ddd-event-storming` carries it, and a host
18
+ * composes it into its catalogue exactly as it already composes
19
+ * `eventStormingCommands` into the command registry. See
20
+ * `packages/affine/all/src/translations.ts`.
21
+ */
22
+ export const eventStormingTranslationEntries = mergeTranslationEntries(commandTranslationEntries(eventStormingCommands), collectTranslationKeys('role', EVENT_STORMING_ROLES), collectTranslationKeys('background', EVENT_STORMING_BACKGROUND), collectTranslationKeys('rule', EVENT_STORMING_RULES), collectTranslationKeys('nudge', EVENT_STORMING_NUDGES), collectTranslationKeys('profile', EVENT_STORMING_PROFILES));
package/dist/view.d.ts CHANGED
@@ -1,6 +1,22 @@
1
1
  import { type ViewExtensionContext, ViewExtensionProvider } from '@formicoidea/labre-core/ext-loader';
2
2
  /**
3
- * Event Storming — independently flag-gated (`ddd-event-storming`).
3
+ * Event Storming rendering ALWAYS registered, independent of any flag.
4
+ * Disabling `ddd-event-storming` hides only the creation tooling (see
5
+ * {@link DddEventStormingViewExtension}); boards already stormed must still
6
+ * paint, stay selectable, stay movable and keep their contextual toolbar. See
7
+ * `docs/adr/0009`.
8
+ */
9
+ export declare class DddEventStormingRenderViewExtension extends ViewExtensionProvider {
10
+ name: string;
11
+ setup(context: ViewExtensionContext): void;
12
+ }
13
+ /**
14
+ * Event Storming creation tooling — independently flag-gated
15
+ * (`ddd-event-storming`): the senior toolbar button, its palette and the
16
+ * validation rules, profiles and quality nudges. Both halves are tooling: a
17
+ * board stormed while the flag was on keeps rendering when it goes off, it just
18
+ * stops being checked — and the profile it was put on stays written, unread,
19
+ * until the flag comes back.
4
20
  *
5
21
  * Note: its Templates-panel category is registered by the aggregate package's
6
22
  * {@link DddTemplatesViewExtension} (gated by `ddd-templates`), so templates
package/dist/view.js CHANGED
@@ -1,8 +1,54 @@
1
+ import { QualityNudgeExtension, validationToolbarConfig, ValidationProfileExtension, ValidationRuleExtension, } from '@formicoidea/labre-core/blocks/surface';
1
2
  import { ViewExtensionProvider, } from '@formicoidea/labre-core/ext-loader';
3
+ import { ToolbarModuleExtension } from '@formicoidea/labre-core/shared/services';
4
+ import { BlockFlavourIdentifier, CommandExtension } from '@formicoidea/labre-core/std';
5
+ import { RoleVocabularyExtension } from '@formicoidea/labre-core/std/gfx';
6
+ import { eventStormingCommandIcons, eventStormingCommands } from './commands.js';
2
7
  import { eventStormingEffects } from './effects.js';
8
+ import { EventStormingRendererExtension } from './element-renderer.js';
9
+ import { EventStormingInteraction, EventStormingView } from './element-view.js';
10
+ import { EVENT_STORMING_NUDGES } from './nudges.js';
11
+ import { EVENT_STORMING_PROFILES } from './profiles.js';
12
+ import { EVENT_STORMING_ROLES } from './roles.js';
13
+ import { EVENT_STORMING_RULES } from './rules.js';
14
+ import { eventStormingBoardToolbarExtension } from './toolbar/board-config.js';
3
15
  import { eventStormingSeniorTool } from './toolbar/senior-tool.js';
4
16
  /**
5
- * Event Storming — independently flag-gated (`ddd-event-storming`).
17
+ * Event Storming rendering ALWAYS registered, independent of any flag.
18
+ * Disabling `ddd-event-storming` hides only the creation tooling (see
19
+ * {@link DddEventStormingViewExtension}); boards already stormed must still
20
+ * paint, stay selectable, stay movable and keep their contextual toolbar. See
21
+ * `docs/adr/0009`.
22
+ */
23
+ export class DddEventStormingRenderViewExtension extends ViewExtensionProvider {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.name = 'affine-ddd-event-storming-render-gfx';
27
+ }
28
+ setup(context) {
29
+ super.setup(context);
30
+ context.register(EventStormingView);
31
+ context.register(EventStormingRendererExtension);
32
+ // The role VOCABULARY, always on. A role is written in the DOCUMENT, not in
33
+ // the tooling: the direction reveal of a typed flow, the inversion command
34
+ // and the toolbar entry that must not lie about one all read this, and they
35
+ // have to keep working on a board stormed while the flag was on and opened
36
+ // while it is off (`docs/adr/0009`, `docs/adr/0010`). The rules that JUDGE
37
+ // those roles stay in the flag-gated extension below.
38
+ context.register(RoleVocabularyExtension(EVENT_STORMING_ROLES));
39
+ if (this.isEdgeless(context.scope)) {
40
+ context.register(EventStormingInteraction);
41
+ context.register(eventStormingBoardToolbarExtension);
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Event Storming creation tooling — independently flag-gated
47
+ * (`ddd-event-storming`): the senior toolbar button, its palette and the
48
+ * validation rules, profiles and quality nudges. Both halves are tooling: a
49
+ * board stormed while the flag was on keeps rendering when it goes off, it just
50
+ * stops being checked — and the profile it was put on stays written, unread,
51
+ * until the flag comes back.
6
52
  *
7
53
  * Note: its Templates-panel category is registered by the aggregate package's
8
54
  * {@link DddTemplatesViewExtension} (gated by `ddd-templates`), so templates
@@ -20,7 +66,22 @@ export class DddEventStormingViewExtension extends ViewExtensionProvider {
20
66
  setup(context) {
21
67
  super.setup(context);
22
68
  if (this.isEdgeless(context.scope)) {
69
+ context.register(ValidationRuleExtension(EVENT_STORMING_RULES));
70
+ context.register(ValidationProfileExtension(EVENT_STORMING_PROFILES));
71
+ context.register(QualityNudgeExtension(EVENT_STORMING_NUDGES));
72
+ // The Validation dropdown on a selected board's contextual toolbar. A
73
+ // SECOND module on the same element, through the `custom:` flavour slot:
74
+ // `eventStormingBoardToolbarExtension` is registered always-on because a
75
+ // stored board must keep its resize toggle, while choosing how hard to
76
+ // check it is tooling and belongs here. The config names no framework —
77
+ // it reads roles and profiles — so it is the very same object Wardley
78
+ // registers on its own flavour.
79
+ context.register(ToolbarModuleExtension({
80
+ id: BlockFlavourIdentifier('custom:affine:surface:eventStorming'),
81
+ config: validationToolbarConfig,
82
+ }));
23
83
  context.register(eventStormingSeniorTool);
84
+ context.register(CommandExtension(eventStormingCommands, eventStormingCommandIcons));
24
85
  }
25
86
  }
26
87
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-ddd-event-storming",
3
3
  "description": "Labre ddd-event-storming framework for @formicoidea/labre-core.",
4
- "version": "0.31.0",
4
+ "version": "0.33.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -27,8 +27,8 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@formicoidea/labre-core": "0.31.0",
31
- "@formicoidea/labre-ddd-shared": "0.31.0",
30
+ "@formicoidea/labre-core": "0.33.0",
31
+ "@formicoidea/labre-ddd-shared": "0.33.0",
32
32
  "lit": "^3.2.0"
33
33
  }
34
34
  }