@formicoidea/labre-ddd-shared 0.30.1 → 0.32.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './shared/consts.js';
2
2
  export * from './shared/prefabs.js';
3
3
  export * from './shared/utils.js';
4
- export { DddMenuBase } from './toolbar/menu-base.js';
5
4
  export * from './toolbar/icons.js';
6
5
  export { DddSeniorButtonBase } from './toolbar/senior-buttons.js';
7
6
  export { CD_TEMPLATES, CM_TEMPLATES, ES_TEMPLATES, } from './templates/components.js';
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export * from './shared/consts.js';
2
2
  export * from './shared/prefabs.js';
3
3
  export * from './shared/utils.js';
4
- export { DddMenuBase } from './toolbar/menu-base.js';
5
4
  export * from './toolbar/icons.js';
6
5
  export { DddSeniorButtonBase } from './toolbar/senior-buttons.js';
7
6
  export { CD_TEMPLATES, CM_TEMPLATES, ES_TEMPLATES, } from './templates/components.js';
@@ -1,5 +1,5 @@
1
1
  import type { BlockStdScope } from '@formicoidea/labre-core/std';
2
- import type { GfxController } from '@formicoidea/labre-core/std/gfx';
2
+ import { type GfxController } from '@formicoidea/labre-core/std/gfx';
3
3
  /**
4
4
  * Irreducible reusable units composed by all three DDD sub-menus. Each helper
5
5
  * wraps native `surface.addElement` (shape / text / connector / group); nothing
@@ -7,6 +7,14 @@ import type { GfxController } from '@formicoidea/labre-core/std/gfx';
7
7
  * stickies, Context Map bubbles + relationships and Core Domain dots + arrows.
8
8
  */
9
9
  type Surface = NonNullable<GfxController['surface']>;
10
+ /**
11
+ * Build one DDD artefact at the viewport centre and select it, leaving the
12
+ * palette open so several can be added in a row. This is the old
13
+ * `DddMenuBase.finish` — moved here when PF3 turned the three menus into pure
14
+ * renderers over the command registry, since the placement is what the command
15
+ * bodies need and the menu no longer has any.
16
+ */
17
+ export declare function placeDddElement(std: BlockStdScope, build: (surface: Surface, cx: number, cy: number) => string): void;
10
18
  /** Group several element ids; returns the group id (or the first id on failure). */
11
19
  export declare function groupIds(std: BlockStdScope, ids: string[]): string;
12
20
  /**
@@ -1,9 +1,29 @@
1
+ import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
1
2
  import { createGroupCommand } from '@formicoidea/labre-core/gfx/group';
2
3
  import { ConnectorMode, FontWeight, PointStyle, ShapeStyle, StrokeStyle, TextFitMode, } from '@formicoidea/labre-core/model';
3
4
  import { Bound } from '@formicoidea/labre-core/global/gfx';
5
+ import { GfxControllerIdentifier } from '@formicoidea/labre-core/std/gfx';
4
6
  import * as Y from 'yjs';
5
- import { CLOUD, CLOUD_VERTICES, CM_BUBBLE, DOT_SIZE, LABEL_COLOR, LABEL_FONT, LABEL_FONT_SIZE, MARKER_SIZE, SHADOW_COLOR, SHADOW_OFFSET, STICKY_FONT, STICKY_FONT_SIZE, STICKY_RADIUS, STICKY_SIZE, } from './consts';
7
+ import { CLOUD, CLOUD_VERTICES, CM_BUBBLE, DOT_SIZE, LABEL_COLOR, LABEL_FONT, LABEL_FONT_SIZE, MARKER_SIZE, SHADOW_COLOR, SHADOW_OFFSET, STICKY_FONT, STICKY_FONT_SIZE, STICKY_RADIUS, STICKY_SIZE, } from './consts.js';
6
8
  const NO_STROKE = '#00000000';
9
+ /**
10
+ * Build one DDD artefact at the viewport centre and select it, leaving the
11
+ * palette open so several can be added in a row. This is the old
12
+ * `DddMenuBase.finish` — moved here when PF3 turned the three menus into pure
13
+ * renderers over the command registry, since the placement is what the command
14
+ * bodies need and the menu no longer has any.
15
+ */
16
+ export function placeDddElement(std, build) {
17
+ const gfx = std.get(GfxControllerIdentifier);
18
+ const surface = gfx.surface;
19
+ if (!surface)
20
+ return;
21
+ const { centerX, centerY } = gfx.viewport;
22
+ const id = build(surface, centerX, centerY);
23
+ gfx.doc.captureSync();
24
+ gfx.tool.setTool(DefaultTool);
25
+ gfx.selection.set({ elements: [id], editing: false });
26
+ }
7
27
  /** Group several element ids; returns the group id (or the first id on failure). */
8
28
  export function groupIds(std, ids) {
9
29
  const [, result] = std.command.exec(createGroupCommand, { elements: ids });
@@ -1,6 +1,6 @@
1
1
  import { makeTemplateSnapshot, surfaceText, } from '@formicoidea/labre-core/gfx/template';
2
2
  import { ConnectorMode, FontFamily, PointStyle, ShapeStyle, StrokeStyle, TextAlign, } from '@formicoidea/labre-core/model';
3
- import { CD_SUBDOMAINS, CLOUD, CLOUD_VERTICES, CM_BUBBLE, CM_RELATIONSHIPS, ES_HOTSPOT, ES_STICKIES, MOVEMENT_COLOR, TEAM_TOPOLOGIES, } from '../shared/consts';
3
+ import { CD_SUBDOMAINS, CLOUD, CLOUD_VERTICES, CM_BUBBLE, CM_RELATIONSHIPS, ES_HOTSPOT, ES_STICKIES, MOVEMENT_COLOR, TEAM_TOPOLOGIES, } from '../shared/consts.js';
4
4
  /**
5
5
  * Every DDD component (the things the three senior menus create) re-expressed as
6
6
  * an insertable Template, so the whole toolbox is also available from the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-ddd-shared",
3
3
  "description": "Labre ddd-shared — shared building blocks for @formicoidea/labre-core frameworks.",
4
- "version": "0.30.1",
4
+ "version": "0.32.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -19,7 +19,7 @@
19
19
  "dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@formicoidea/labre-core": "0.30.1",
22
+ "@formicoidea/labre-core": "0.32.0",
23
23
  "lit": "^3.2.0"
24
24
  }
25
25
  }
@@ -1,23 +0,0 @@
1
- import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
2
- import { LitElement } from 'lit';
3
- declare const DddMenuBase_base: typeof LitElement & import("@formicoidea/labre-core/_pkgs/global/utils").Constructor<import("@formicoidea/labre-core/_pkgs/affine-widget-edgeless-toolbar").EdgelessToolbarToolClass>;
4
- /**
5
- * Shared base for the three DDD popover menus: the menu shell styles, the
6
- * "create then return to selection (palette stays open)" finish helper and
7
- * the telemetry track helper. Each subclass adds its own create* methods (built
8
- * from the shared prefab builders) and its own render().
9
- */
10
- export declare abstract class DddMenuBase extends DddMenuBase_base {
11
- static styles: import("lit").CSSResult;
12
- type: typeof EmptyTool;
13
- /** Framework id for telemetry. */
14
- protected abstract framework: 'event-storming' | 'core-domain' | 'context-map';
15
- protected get surface(): import("@formicoidea/labre-core/std/gfx").SurfaceBlockModel | null;
16
- protected get center(): {
17
- cx: number;
18
- cy: number;
19
- };
20
- protected finish(id: string): void;
21
- protected track(event: 'FrameworkElementAdded' | 'FrameworkToolPicked', element: string): void;
22
- }
23
- export {};
@@ -1,62 +0,0 @@
1
- import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
2
- import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
3
- import { TelemetryProvider } from '@formicoidea/labre-core/shared/services';
4
- import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
5
- import { css, LitElement } from 'lit';
6
- /**
7
- * Shared base for the three DDD popover menus: the menu shell styles, the
8
- * "create then return to selection (palette stays open)" finish helper and
9
- * the telemetry track helper. Each subclass adds its own create* methods (built
10
- * from the shared prefab builders) and its own render().
11
- */
12
- export class DddMenuBase extends EdgelessToolbarToolMixin(LitElement) {
13
- constructor() {
14
- super(...arguments);
15
- this.type = EmptyTool;
16
- }
17
- static { this.styles = css `
18
- :host {
19
- display: flex;
20
- z-index: -1;
21
- justify-content: center;
22
- }
23
- .menu-content {
24
- display: flex;
25
- align-items: center;
26
- justify-content: center;
27
- }
28
- .button-group-container {
29
- display: flex;
30
- align-items: center;
31
- gap: 10px;
32
- fill: var(--affine-icon-color);
33
- }
34
- .button-group-container svg {
35
- width: 24px;
36
- height: 24px;
37
- }
38
- `; }
39
- get surface() {
40
- return this.gfx.surface;
41
- }
42
- get center() {
43
- const { centerX, centerY } = this.gfx.viewport;
44
- return { cx: centerX, cy: centerY };
45
- }
46
- finish(id) {
47
- const { gfx } = this;
48
- gfx.doc.captureSync();
49
- gfx.tool.setTool(DefaultTool);
50
- gfx.selection.set({ elements: [id], editing: false });
51
- // Palette stays open so several objects can be added in a row.
52
- }
53
- track(event, element) {
54
- this.edgeless.std.getOptional(TelemetryProvider)?.track(event, {
55
- framework: this.framework,
56
- element,
57
- page: 'whiteboard editor',
58
- segment: 'ddd toolbox',
59
- module: `${this.framework} menu`,
60
- });
61
- }
62
- }