@formicoidea/labre-framework-edgy 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.
Files changed (48) hide show
  1. package/package.json +6 -15
  2. package/{dist/consts.js → src/consts.ts} +50 -46
  3. package/{dist/descriptor.js → src/descriptor.ts} +1 -1
  4. package/src/effects.ts +14 -0
  5. package/src/element-renderer.ts +208 -0
  6. package/src/element-view.ts +145 -0
  7. package/src/index.ts +1 -0
  8. package/src/label-layout.ts +105 -0
  9. package/{dist/node/consts.js → src/node/consts.ts} +56 -49
  10. package/src/node/node-renderer.ts +64 -0
  11. package/{dist/node/node-view.js → src/node/node-view.ts} +33 -27
  12. package/src/templates/index.ts +254 -0
  13. package/src/toolbar/config.ts +96 -0
  14. package/src/toolbar/edgy-menu.ts +242 -0
  15. package/{dist/toolbar/edgy-senior-button.js → src/toolbar/edgy-senior-button.ts} +102 -97
  16. package/{dist/toolbar/icons.js → src/toolbar/icons.ts} +25 -20
  17. package/src/toolbar/node-config.ts +202 -0
  18. package/{dist/toolbar/senior-tool.js → src/toolbar/senior-tool.ts} +11 -11
  19. package/src/view.ts +39 -0
  20. package/dist/consts.d.ts +0 -47
  21. package/dist/descriptor.d.ts +0 -7
  22. package/dist/effects.d.ts +0 -10
  23. package/dist/effects.js +0 -7
  24. package/dist/element-renderer.d.ts +0 -17
  25. package/dist/element-renderer.js +0 -177
  26. package/dist/element-view.d.ts +0 -19
  27. package/dist/element-view.js +0 -123
  28. package/dist/index.d.ts +0 -2
  29. package/dist/index.js +0 -2
  30. package/dist/label-layout.d.ts +0 -46
  31. package/dist/label-layout.js +0 -69
  32. package/dist/node/consts.d.ts +0 -34
  33. package/dist/node/node-renderer.d.ts +0 -14
  34. package/dist/node/node-renderer.js +0 -40
  35. package/dist/node/node-view.d.ts +0 -16
  36. package/dist/templates/index.d.ts +0 -3
  37. package/dist/templates/index.js +0 -210
  38. package/dist/toolbar/config.d.ts +0 -20
  39. package/dist/toolbar/config.js +0 -71
  40. package/dist/toolbar/edgy-menu.d.ts +0 -31
  41. package/dist/toolbar/edgy-menu.js +0 -195
  42. package/dist/toolbar/edgy-senior-button.d.ts +0 -16
  43. package/dist/toolbar/icons.d.ts +0 -13
  44. package/dist/toolbar/node-config.d.ts +0 -2
  45. package/dist/toolbar/node-config.js +0 -162
  46. package/dist/toolbar/senior-tool.d.ts +0 -2
  47. package/dist/view.d.ts +0 -7
  48. package/dist/view.js +0 -36
@@ -1,49 +1,56 @@
1
- /**
2
- * Visual constants for the four EDGY base-element nodes. Each node is a NATIVE
3
- * shape (ShapeElementModel-derived) so its stroke / fill / inner text are
4
- * editable via the shape toolbar; these are just the pre-formatted defaults at
5
- * creation.
6
- */
7
- export const NODE_FILL = '#ffffff';
8
- export const NODE_STROKE = '#262626';
9
- export const NODE_STROKE_WIDTH = 2;
10
- /** Outcome corner radius (absolute px — a lightly rounded rectangle). */
11
- export const OUTCOME_RADIUS = 6;
12
- /** Right-pointing chevron, as normalized polygon vertices (Activity). */
13
- export const ACTIVITY_VERTICES = [
14
- [0, 0],
15
- [0.8, 0],
16
- [1, 0.5],
17
- [0.8, 1],
18
- [0, 1],
19
- ];
20
- /** Default node sizes (model units) per kind. */
21
- export const NODE_SIZE = {
22
- people: { w: 64, h: 64 },
23
- outcome: { w: 130, h: 80 },
24
- object: { w: 130, h: 80 },
25
- activity: { w: 140, h: 80 },
26
- };
27
- /** Inner-text + label font (matches the diagram labels). */
28
- export const INNER_FONT_SIZE = 20;
29
- export const LABEL_FONT_SIZE = 18;
30
- export const LABEL_GAP = 8;
31
- /** Default inner text / label per kind. */
32
- export const NODE_LABEL = {
33
- people: 'People',
34
- outcome: 'Outcome',
35
- object: 'Object',
36
- activity: 'Activity',
37
- };
38
- /**
39
- * Person glyph for `kind: 'people'`, taken from the official `Icon-People.svg`
40
- * (viewBox 0 0 32 32). Two filled outline rings (head + shoulders) — filling
41
- * them yields the line-art person. Drawn in the node stroke color, scaled to
42
- * the node and centred.
43
- */
44
- export const PERSON_GLYPH_VIEWBOX = 32;
45
- export const PERSON_GLYPH_PATHS = [
46
- 'm16,19c-3.308,0-6-2.692-6-6v-4c0-3.308,2.692-6,6-6s6,2.692,6,6v4c0,3.308-2.692,6-6,6Zm0-14c-2.206,0-4,1.794-4,4v4c0,2.206,1.794,4,4,4s4-1.794,4-4v-4c0-2.206-1.794-4-4-4Z',
47
- 'm29,30H3v-3.5c0-3.308,2.692-6,6-6h14c3.308,0,6,2.692,6,6v3.5Zm-24-2h22v-1.5c0-2.206-1.794-4-4-4h-14c-2.206,0-4,1.794-4,4v1.5Z',
48
- ];
49
- //# sourceMappingURL=consts.js.map
1
+ import type { EdgyNodeKind } from '@formicoidea/labre-core/model';
2
+
3
+ /**
4
+ * Visual constants for the four EDGY base-element nodes. Each node is a NATIVE
5
+ * shape (ShapeElementModel-derived) so its stroke / fill / inner text are
6
+ * editable via the shape toolbar; these are just the pre-formatted defaults at
7
+ * creation.
8
+ */
9
+ export const NODE_FILL = '#ffffff';
10
+ export const NODE_STROKE = '#262626';
11
+ export const NODE_STROKE_WIDTH = 2;
12
+
13
+ /** Outcome corner radius (absolute px — a lightly rounded rectangle). */
14
+ export const OUTCOME_RADIUS = 6;
15
+
16
+ /** Right-pointing chevron, as normalized polygon vertices (Activity). */
17
+ export const ACTIVITY_VERTICES: number[][] = [
18
+ [0, 0],
19
+ [0.8, 0],
20
+ [1, 0.5],
21
+ [0.8, 1],
22
+ [0, 1],
23
+ ];
24
+
25
+ /** Default node sizes (model units) per kind. */
26
+ export const NODE_SIZE: Record<EdgyNodeKind, { w: number; h: number }> = {
27
+ people: { w: 64, h: 64 },
28
+ outcome: { w: 130, h: 80 },
29
+ object: { w: 130, h: 80 },
30
+ activity: { w: 140, h: 80 },
31
+ };
32
+
33
+ /** Inner-text + label font (matches the diagram labels). */
34
+ export const INNER_FONT_SIZE = 20;
35
+ export const LABEL_FONT_SIZE = 18;
36
+ export const LABEL_GAP = 8;
37
+
38
+ /** Default inner text / label per kind. */
39
+ export const NODE_LABEL: Record<EdgyNodeKind, string> = {
40
+ people: 'People',
41
+ outcome: 'Outcome',
42
+ object: 'Object',
43
+ activity: 'Activity',
44
+ };
45
+
46
+ /**
47
+ * Person glyph for `kind: 'people'`, taken from the official `Icon-People.svg`
48
+ * (viewBox 0 0 32 32). Two filled outline rings (head + shoulders) — filling
49
+ * them yields the line-art person. Drawn in the node stroke color, scaled to
50
+ * the node and centred.
51
+ */
52
+ export const PERSON_GLYPH_VIEWBOX = 32;
53
+ export const PERSON_GLYPH_PATHS = [
54
+ 'm16,19c-3.308,0-6-2.692-6-6v-4c0-3.308,2.692-6,6-6s6,2.692,6,6v4c0,3.308-2.692,6-6,6Zm0-14c-2.206,0-4,1.794-4,4v4c0,2.206,1.794,4,4,4s4-1.794,4-4v-4c0-2.206-1.794-4-4-4Z',
55
+ 'm29,30H3v-3.5c0-3.308,2.692-6,6-6h14c3.308,0,6,2.692,6,6v3.5Zm-24-2h22v-1.5c0-2.206-1.794-4-4-4h-14c-2.206,0-4,1.794-4,4v1.5Z',
56
+ ];
@@ -0,0 +1,64 @@
1
+ import {
2
+ type ElementRenderer,
3
+ ElementRendererExtension,
4
+ } from '@formicoidea/labre-core/blocks/surface';
5
+ import { shape as shapeRenderer } from '@formicoidea/labre-core/gfx/shape';
6
+ import { DefaultTheme, type EdgyNodeElementModel } from '@formicoidea/labre-core/model';
7
+
8
+ import { PERSON_GLYPH_PATHS, PERSON_GLYPH_VIEWBOX } from './consts';
9
+
10
+ /**
11
+ * Renderer for an EDGY base-element node. The shape body (rounded rect / rect /
12
+ * chevron polygon / ellipse) is drawn by REUSING the native shape renderer — so
13
+ * stroke width, colors, inner text and theme behave exactly like a native shape.
14
+ * Only `people` is decorated: an inscribed person glyph (the official
15
+ * `Icon-People` paths) drawn on top in the node's (editable) stroke color.
16
+ */
17
+ export const edgyNode: ElementRenderer<EdgyNodeElementModel> = (
18
+ model,
19
+ ctx,
20
+ matrix,
21
+ renderer,
22
+ rc,
23
+ bound
24
+ ) => {
25
+ const [, , w, h] = model.deserializedXYWH;
26
+ const cx = w / 2;
27
+ const cy = h / 2;
28
+
29
+ // Capture the element-local transform BEFORE the shape renderer mutates the
30
+ // matrix, so the glyph can be drawn in the same space afterwards.
31
+ const glyphMatrix = DOMMatrix.fromMatrix(matrix)
32
+ .translateSelf(cx, cy)
33
+ .rotateSelf(model.rotate)
34
+ .translateSelf(-cx, -cy);
35
+
36
+ // Native shape (fill / stroke / inner text / theme handled natively).
37
+ shapeRenderer(model, ctx, matrix, renderer, rc, bound);
38
+
39
+ if (model.kind !== 'people') return;
40
+
41
+ const color = renderer.getColorValue(
42
+ model.strokeColor,
43
+ DefaultTheme.shapeStrokeColor,
44
+ true
45
+ );
46
+
47
+ // ── Person glyph (Icon-People), scaled to the node and centred ──────
48
+ const target = Math.min(w, h) * 0.8;
49
+ const s = target / PERSON_GLYPH_VIEWBOX;
50
+
51
+ ctx.setTransform(glyphMatrix);
52
+ ctx.translate(cx, cy);
53
+ ctx.scale(s, s);
54
+ ctx.translate(-PERSON_GLYPH_VIEWBOX / 2, -PERSON_GLYPH_VIEWBOX / 2);
55
+ ctx.fillStyle = color;
56
+ for (const d of PERSON_GLYPH_PATHS) {
57
+ ctx.fill(new Path2D(d));
58
+ }
59
+ };
60
+
61
+ export const EdgyNodeRendererExtension = ElementRendererExtension(
62
+ 'edgyNode',
63
+ edgyNode
64
+ );
@@ -1,27 +1,33 @@
1
- import { mountShapeTextEditor } from '@formicoidea/labre-core/gfx/shape';
2
- import { ShapeElementModel, } from '@formicoidea/labre-core/model';
3
- import { GfxElementModelView } from '@formicoidea/labre-core/std/gfx';
4
- /**
5
- * View for an EDGY base-element node. Registering it ensures `gfx.view.get(model)`
6
- * returns a view (required so move / select / connector interactions work).
7
- *
8
- * EDGY nodes are native shapes, so we reuse the shape inner-text editor: a
9
- * double-click mounts the editable text overlay (`mountShapeTextEditor`), exactly
10
- * like a native shape. We deliberately do NOT inherit the polygon vertex-editing
11
- * overlay (the Activity chevron should keep its shape).
12
- */
13
- export class EdgyNodeView extends GfxElementModelView {
14
- static { this.type = 'edgyNode'; }
15
- onCreated() {
16
- super.onCreated();
17
- this.on('dblclick', () => {
18
- const edgeless = this.std.view.getBlock(this.std.store.root.id);
19
- if (edgeless &&
20
- !this.model.isLocked() &&
21
- this.model instanceof ShapeElementModel) {
22
- mountShapeTextEditor(this.model, edgeless);
23
- }
24
- });
25
- }
26
- }
27
- //# sourceMappingURL=node-view.js.map
1
+ import { mountShapeTextEditor } from '@formicoidea/labre-core/gfx/shape';
2
+ import {
3
+ type EdgyNodeElementModel,
4
+ ShapeElementModel,
5
+ } from '@formicoidea/labre-core/model';
6
+ import { GfxElementModelView } from '@formicoidea/labre-core/std/gfx';
7
+
8
+ /**
9
+ * View for an EDGY base-element node. Registering it ensures `gfx.view.get(model)`
10
+ * returns a view (required so move / select / connector interactions work).
11
+ *
12
+ * EDGY nodes are native shapes, so we reuse the shape inner-text editor: a
13
+ * double-click mounts the editable text overlay (`mountShapeTextEditor`), exactly
14
+ * like a native shape. We deliberately do NOT inherit the polygon vertex-editing
15
+ * overlay (the Activity chevron should keep its shape).
16
+ */
17
+ export class EdgyNodeView extends GfxElementModelView<EdgyNodeElementModel> {
18
+ static override type: string = 'edgyNode';
19
+
20
+ override onCreated(): void {
21
+ super.onCreated();
22
+ this.on('dblclick', () => {
23
+ const edgeless = this.std.view.getBlock(this.std.store.root!.id);
24
+ if (
25
+ edgeless &&
26
+ !this.model.isLocked() &&
27
+ this.model instanceof ShapeElementModel
28
+ ) {
29
+ mountShapeTextEditor(this.model, edgeless);
30
+ }
31
+ });
32
+ }
33
+ }
@@ -0,0 +1,254 @@
1
+ import {
2
+ makeTemplateSnapshot,
3
+ type SurfaceElementsJSON,
4
+ surfaceText,
5
+ type Template,
6
+ type TemplateCategory,
7
+ } from '@formicoidea/labre-core/gfx/template';
8
+ import {
9
+ ConnectorMode,
10
+ FontFamily,
11
+ PointStyle,
12
+ ShapeStyle,
13
+ StrokeStyle,
14
+ TextAlign,
15
+ } from '@formicoidea/labre-core/model';
16
+
17
+ import { REF_H, REF_W } from '../consts';
18
+ import {
19
+ ACTIVITY_VERTICES,
20
+ INNER_FONT_SIZE,
21
+ NODE_FILL,
22
+ NODE_STROKE,
23
+ NODE_STROKE_WIDTH,
24
+ OUTCOME_RADIUS,
25
+ } from '../node/consts';
26
+
27
+ // EDGY facet palette (header / pale sub-card).
28
+ const C = {
29
+ identity: ['#1ec873', '#9fe6c2'],
30
+ organisation: ['#4fd0ea', '#c2eef8'],
31
+ architecture: ['#2f6ff0', '#b3c8f7'],
32
+ product: ['#cf8cff', '#e7ccff'],
33
+ experience: ['#f5246e', '#ffc0d4'],
34
+ brand: ['#eeba51', '#f7e1ad'],
35
+ } as const;
36
+ const JOURNEY_PINK = '#f3a3c0';
37
+
38
+ // ── element helpers ───────────────────────────────────────────────────
39
+ function rect(
40
+ x: number,
41
+ y: number,
42
+ w: number,
43
+ h: number,
44
+ opts: { fill?: string; stroke?: string; sw?: number; radius?: number; text?: string; textColor?: string; fontSize?: number } = {}
45
+ ) {
46
+ const el: Record<string, unknown> = {
47
+ type: 'shape',
48
+ shapeType: 'rect',
49
+ filled: true,
50
+ fillColor: opts.fill ?? '#ffffff',
51
+ strokeColor: opts.stroke ?? NODE_STROKE,
52
+ strokeWidth: opts.sw ?? NODE_STROKE_WIDTH,
53
+ shapeStyle: ShapeStyle.General,
54
+ roughness: 0,
55
+ radius: opts.radius ?? 0,
56
+ xywh: `[${x},${y},${w},${h}]`,
57
+ };
58
+ if (opts.text != null) {
59
+ el.text = surfaceText(opts.text);
60
+ el.color = opts.textColor ?? NODE_STROKE;
61
+ el.fontFamily = FontFamily.Inter;
62
+ el.fontSize = opts.fontSize ?? 16;
63
+ el.textAlign = TextAlign.Center;
64
+ }
65
+ return el;
66
+ }
67
+
68
+ /** An EDGY node (kind drives the native shape): outcome/object box, people, activity chevron. */
69
+ function enode(
70
+ kind: 'outcome' | 'object' | 'people' | 'activity',
71
+ x: number,
72
+ y: number,
73
+ w: number,
74
+ h: number,
75
+ opts: { fill?: string; text?: string; textColor?: string; fontSize?: number } = {}
76
+ ) {
77
+ const el: Record<string, unknown> = {
78
+ type: 'edgyNode',
79
+ kind,
80
+ filled: true,
81
+ fillColor: opts.fill ?? NODE_FILL,
82
+ strokeColor: NODE_STROKE,
83
+ strokeWidth: kind === 'people' ? 0 : NODE_STROKE_WIDTH,
84
+ shapeStyle: ShapeStyle.General,
85
+ roughness: 0,
86
+ shapeType: kind === 'people' ? 'ellipse' : kind === 'activity' ? 'polygon' : 'rect',
87
+ radius: kind === 'outcome' ? OUTCOME_RADIUS : 0,
88
+ xywh: `[${x},${y},${w},${h}]`,
89
+ };
90
+ if (kind === 'activity') el.vertices = ACTIVITY_VERTICES;
91
+ if (opts.text != null) {
92
+ el.text = surfaceText(opts.text);
93
+ el.color = opts.textColor ?? NODE_STROKE;
94
+ el.fontFamily = FontFamily.Inter;
95
+ el.fontSize = opts.fontSize ?? INNER_FONT_SIZE;
96
+ el.textAlign = TextAlign.Center;
97
+ }
98
+ return el;
99
+ }
100
+
101
+ function label(x: number, y: number, w: number, h: number, str: string, opts: { color?: string; fontSize?: number; align?: TextAlign } = {}) {
102
+ return {
103
+ type: 'text',
104
+ text: surfaceText(str),
105
+ color: opts.color ?? NODE_STROKE,
106
+ fontFamily: FontFamily.Inter,
107
+ fontSize: opts.fontSize ?? 16,
108
+ textAlign: opts.align ?? TextAlign.Center,
109
+ xywh: `[${x},${y},${w},${h}]`,
110
+ };
111
+ }
112
+
113
+ function line(x1: number, y1: number, x2: number, y2: number, opts: { arrow?: boolean; dash?: boolean; sw?: number } = {}) {
114
+ return {
115
+ type: 'connector',
116
+ mode: ConnectorMode.Orthogonal,
117
+ stroke: NODE_STROKE,
118
+ strokeWidth: opts.sw ?? 2,
119
+ strokeStyle: opts.dash ? StrokeStyle.Dash : StrokeStyle.Solid,
120
+ frontEndpointStyle: PointStyle.None,
121
+ rearEndpointStyle: opts.arrow ? PointStyle.Triangle : PointStyle.None,
122
+ source: { position: [x1, y1] },
123
+ target: { position: [x2, y2] },
124
+ };
125
+ }
126
+
127
+ // ── Facets overview (six facets, sub-cards, facets/intersections) ─────
128
+ function facetsOverview(): SurfaceElementsJSON {
129
+ const out: SurfaceElementsJSON = {};
130
+ const tall = (key: keyof typeof C, x: number, name: string, cards: [string, string, string]) => {
131
+ const [hdr, sub] = C[key];
132
+ out[`${key}F`] = rect(x, 140, 192, 460, { fill: hdr, stroke: hdr, radius: 16 });
133
+ out[`${key}N`] = label(x, 168, 192, 28, name, { color: '#ffffff', fontSize: 18 });
134
+ out[`${key}1`] = rect(x + 16, 208, 160, 80, { fill: sub, stroke: sub, radius: 6, text: cards[0], fontSize: 16 });
135
+ out[`${key}2`] = rect(x + 16, 300, 160, 80, { fill: sub, stroke: sub, radius: 6, text: cards[1], fontSize: 16 });
136
+ out[`${key}3`] = enode('activity', x + 16, 392, 160, 84, { fill: sub, text: cards[2], fontSize: 16 });
137
+ };
138
+ const low = (key: keyof typeof C, x: number, name: string) => {
139
+ const [hdr, sub] = C[key];
140
+ out[`${key}F`] = rect(x, 300, 192, 424, { fill: hdr, stroke: hdr, radius: 16 });
141
+ out[`${key}1`] = rect(x + 16, 360, 160, 92, { fill: sub, stroke: sub, radius: 6, text: name, fontSize: 16 });
142
+ out[`${key}N`] = label(x, 686, 192, 28, name, { color: '#ffffff', fontSize: 18 });
143
+ };
144
+ // lower facets first (drawn behind the tall ones at the overlaps)
145
+ low('organisation', 240, 'Organisation');
146
+ low('product', 664, 'Product');
147
+ low('brand', 1088, 'Brand');
148
+ tall('identity', 40, 'Identity', ['Purpose', 'Content', 'Story']);
149
+ tall('architecture', 464, 'Architecture', ['Capability', 'Asset', 'Process']);
150
+ tall('experience', 888, 'Experience', ['Task', 'Channel', 'Journey']);
151
+ out.fLabel = label(464, 80, 192, 28, 'Facets', { fontSize: 18 });
152
+ out.fBar = line(136, 120, 984, 120);
153
+ out.iLabel = label(664, 740, 192, 28, 'Intersections', { fontSize: 18 });
154
+ out.iBar = line(336, 728, 1184, 728);
155
+ return out;
156
+ }
157
+
158
+ // ── Customer journey ──────────────────────────────────────────────────
159
+ function journey(): SurfaceElementsJSON {
160
+ const step = (i: number, x: number) =>
161
+ enode('activity', x, 132, 224, 116, { fill: JOURNEY_PINK, text: `Journey step ${i}`, textColor: '#ffffff', fontSize: 18 });
162
+ const ch = (x: number, n: string) => enode('object', x, 392, 184, 96, { fill: JOURNEY_PINK, text: `Channel ${n}`, fontSize: 16 });
163
+ const tk = (x: number, n: string) => enode('object', x, 540, 168, 92, { fill: JOURNEY_PINK, text: `Task ${n}`, fontSize: 16 });
164
+ return {
165
+ cust: enode('people', 40, 120, 64, 64, { fill: '#ffffff' }),
166
+ custL: label(20, 192, 104, 24, 'Customer', { fontSize: 14 }),
167
+ band: { type: 'shape', shapeType: 'polygon', vertices: [[0, 0], [0.86, 0], [1, 0.5], [0.86, 1], [0, 1]], filled: true, fillColor: JOURNEY_PINK, strokeColor: JOURNEY_PINK, strokeWidth: 1, shapeStyle: ShapeStyle.General, roughness: 0, xywh: '[150,108,860,164]' },
168
+ bandL: label(170, 116, 120, 24, 'Journey', { color: '#ffffff', fontSize: 16, align: TextAlign.Left }),
169
+ s1: step(1, 240),
170
+ s2: step(2, 500),
171
+ s3: step(3, 760),
172
+ rightTask: enode('object', 1060, 132, 168, 92, { text: 'Task', fontSize: 16 }),
173
+ c1: ch(258, 'X'), c2: ch(518, 'Y'), c3: ch(778, 'Z'),
174
+ t1: tk(266, 'A'), t2: tk(526, 'B'), t3: tk(786, 'C'),
175
+ trav1: label(258, 350, 184, 20, 'traverses', { fontSize: 13, color: '#5f6368' }),
176
+ trav2: label(518, 350, 184, 20, 'traverses', { fontSize: 13, color: '#5f6368' }),
177
+ trav3: label(778, 350, 184, 20, 'traverses', { fontSize: 13, color: '#5f6368' }),
178
+ use1: label(258, 504, 184, 20, 'uses', { fontSize: 13, color: '#5f6368' }),
179
+ use2: label(518, 504, 184, 20, 'uses', { fontSize: 13, color: '#5f6368' }),
180
+ use3: label(778, 504, 184, 20, 'uses', { fontSize: 13, color: '#5f6368' }),
181
+ l1: line(350, 248, 350, 392), l2: line(610, 248, 610, 392), l3: line(870, 248, 870, 392),
182
+ l4: line(350, 488, 350, 540), l5: line(610, 488, 610, 540), l6: line(870, 488, 870, 540),
183
+ };
184
+ }
185
+
186
+ // ── Service blueprint (six swimlanes) ─────────────────────────────────
187
+ function blueprint(): SurfaceElementsJSON {
188
+ const lanes = ['Physical Evidence', 'Customer Actions', 'On-stage Actions', 'Back-stage Actions', 'Support Processes', 'Support Systems'];
189
+ const laneFill = ['#fdeef2', '#fbd5e0', '#dff0fb', '#d4e9f8', '#d4e9f8', '#d4e9f8'];
190
+ const out: SurfaceElementsJSON = {};
191
+ lanes.forEach((name, i) => {
192
+ const y = 40 + i * 150;
193
+ out[`lane${i}`] = rect(36, y, 1280, 150, { fill: laneFill[i], stroke: laneFill[i], sw: 0 });
194
+ out[`laneL${i}`] = label(52, y + 12, 260, 22, name, { fontSize: 15, align: TextAlign.Left });
195
+ });
196
+ const chev = (x: number, y: number, fill: string, t: string) => enode('activity', x, y, 200, 60, { fill, text: t, fontSize: 14 });
197
+ const box = (x: number, y: number, fill: string, t: string) => enode('object', x, y, 200, 60, { fill, text: t, fontSize: 14 });
198
+ const P = C.experience[1], B = C.architecture[1];
199
+ Object.assign(out, {
200
+ af: rect(280, 64, 220, 70, { text: 'Admission Form' }),
201
+ cf: rect(1010, 64, 220, 70, { text: 'Confirmation' }),
202
+ sf: chev(280, 214, P, 'Send Form'), fs: chev(600, 214, P, 'Follow status'), rd: chev(1010, 214, P, 'Receive decision'),
203
+ fh: chev(280, 364, B, 'Form handling'), cs: chev(600, 364, B, 'Customer support'), ct: chev(1010, 364, B, 'Contact'),
204
+ csv: chev(280, 514, B, 'Customer service'), cfu: box(1010, 514, B, 'Customer follow-up'),
205
+ pf: chev(600, 664, B, 'Process Form'), dec: chev(900, 664, B, 'Decision [Accept|Reject]'),
206
+ crm: box(280, 814, B, 'CRM Application'), cms: box(600, 814, B, 'Case Management'), pay: box(900, 814, B, 'Payments System'),
207
+ a1: line(380, 134, 380, 214, { arrow: true }),
208
+ a2: line(480, 244, 600, 244, { arrow: true }),
209
+ a3: line(800, 244, 1010, 244, { arrow: true }),
210
+ a4: line(320, 274, 320, 364, { arrow: true }),
211
+ a5: line(320, 424, 320, 514, { arrow: true }),
212
+ a6: line(700, 724, 900, 694, { arrow: true }),
213
+ a7: line(380, 874, 600, 844, { arrow: true }),
214
+ a8: line(800, 844, 900, 844, { arrow: true }),
215
+ });
216
+ return out;
217
+ }
218
+
219
+ // ── Organisation chart ────────────────────────────────────────────────
220
+ function orgChart(): SurfaceElementsJSON {
221
+ const cyan = C.organisation[0];
222
+ const u = (x: number, y: number, w: number, t: string) => enode('object', x, y, w, 64, { fill: cyan, text: t, fontSize: 16 });
223
+ return {
224
+ org: u(420, 40, 180, 'Organisation'),
225
+ a: u(120, 200, 200, 'Business Unit A'), b: u(410, 200, 200, 'Business Unit B'), c: u(700, 200, 200, 'Business Unit C'),
226
+ a1: u(60, 360, 170, 'Group A-1'), a2: u(260, 360, 170, 'Group A-2'), c1: u(715, 360, 170, 'Group C-1'),
227
+ e1: line(510, 104, 510, 150), e2: line(220, 150, 800, 150),
228
+ e3: line(220, 150, 220, 200), e4: line(510, 150, 510, 200), e5: line(800, 150, 800, 200),
229
+ e6: line(220, 264, 220, 320), e7: line(145, 320, 345, 320),
230
+ e8: line(145, 320, 145, 360), e9: line(345, 320, 345, 360),
231
+ e10: line(800, 264, 800, 360),
232
+ };
233
+ }
234
+
235
+ const single = (el: Record<string, unknown>): SurfaceElementsJSON => ({ a: el });
236
+ const ATTRS = 'width="100%" height="100%" viewBox="0 0 135 80" xmlns="http://www.w3.org/2000/svg"';
237
+ function tpl(name: string, preview: string, elements: SurfaceElementsJSON): Template {
238
+ return { name, type: 'template', preview, content: makeTemplateSnapshot(elements, name) };
239
+ }
240
+
241
+ export const edgyTemplateCategory: TemplateCategory = {
242
+ name: 'EDGY',
243
+ templates: [
244
+ tpl('Facets overview', `<svg ${ATTRS} fill="none"><rect x="6" y="20" width="18" height="46" rx="3" fill="#1ec873"/><rect x="46" y="20" width="18" height="46" rx="3" fill="#2f6ff0"/><rect x="86" y="20" width="18" height="46" rx="3" fill="#f5246e"/><rect x="26" y="30" width="18" height="40" rx="3" fill="#4fd0ea"/><rect x="66" y="30" width="18" height="40" rx="3" fill="#cf8cff"/><rect x="106" y="30" width="18" height="40" rx="3" fill="#eeba51"/></svg>`, facetsOverview()),
245
+ tpl('Customer journey', `<svg ${ATTRS} fill="none"><path d="M20 24 H110 L122 40 L110 56 H20 Z" fill="#f3a3c0"/><rect x="26" y="30" width="22" height="20" fill="none" stroke="#fff"/><rect x="54" y="30" width="22" height="20" fill="none" stroke="#fff"/><rect x="82" y="30" width="22" height="20" fill="none" stroke="#fff"/></svg>`, journey()),
246
+ tpl('Service blueprint', `<svg ${ATTRS} fill="none"><rect x="8" y="14" width="119" height="16" fill="#fbd5e0"/><rect x="8" y="32" width="119" height="34" fill="#d4e9f8"/><rect x="20" y="18" width="22" height="9" fill="#f5246e" opacity="0.5"/><rect x="20" y="40" width="22" height="9" fill="#2f6ff0" opacity="0.4"/><rect x="60" y="40" width="22" height="9" fill="#2f6ff0" opacity="0.4"/></svg>`, blueprint()),
247
+ tpl('Organisation chart', `<svg ${ATTRS} fill="none"><rect x="52" y="12" width="32" height="14" rx="2" fill="#4fd0ea"/><rect x="14" y="38" width="32" height="14" rx="2" fill="#4fd0ea"/><rect x="52" y="38" width="32" height="14" rx="2" fill="#4fd0ea"/><rect x="90" y="38" width="32" height="14" rx="2" fill="#4fd0ea"/><path d="M68 26 V32 M30 32 H106 M30 32 V38 M68 32 V38 M106 32 V38" stroke="#262626"/></svg>`, orgChart()),
248
+ tpl('Facets diagram', `<svg ${ATTRS}><circle cx="55" cy="34" r="18" fill="#00ea4e" opacity="0.9"/><circle cx="80" cy="34" r="18" fill="#034cee" opacity="0.9"/><circle cx="67" cy="54" r="18" fill="#ff0056" opacity="0.9"/></svg>`, single({ type: 'edgy', xywh: `[0,0,${REF_W * 1.5},${REF_H * 1.5}]` })),
249
+ tpl('People', `<svg ${ATTRS} fill="#262626"><circle cx="67" cy="32" r="9" fill="none" stroke="#262626" stroke-width="2.4"/><path d="M50 60 a17 17 0 0 1 34 0" fill="none" stroke="#262626" stroke-width="2.4"/></svg>`, { n: enode('people', 0, 0, 64, 64), l: label(-28, 70, 120, 24, 'People', { fontSize: 16 }) }),
250
+ tpl('Outcome', `<svg ${ATTRS} fill="none"><rect x="20" y="24" width="95" height="34" rx="6" stroke="#262626" stroke-width="2"/></svg>`, single(enode('outcome', 0, 0, 130, 80, { text: 'Outcome' }))),
251
+ tpl('Object', `<svg ${ATTRS} fill="none"><rect x="20" y="24" width="95" height="34" stroke="#262626" stroke-width="2"/></svg>`, single(enode('object', 0, 0, 130, 80, { text: 'Object' }))),
252
+ tpl('Activity', `<svg ${ATTRS} fill="none"><path d="M20 24 H98 L116 41 H116 L98 58 H20 Z" stroke="#262626" stroke-width="2" stroke-linejoin="round"/></svg>`, single(enode('activity', 0, 0, 140, 80, { text: 'Activity' }))),
253
+ ],
254
+ };
@@ -0,0 +1,96 @@
1
+ import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
2
+ import { EdgyFacetsElementModel } from '@formicoidea/labre-core/model';
3
+ import {
4
+ type ToolbarContext,
5
+ type ToolbarModuleConfig,
6
+ ToolbarModuleExtension,
7
+ } from '@formicoidea/labre-core/shared/services';
8
+ import { BlockFlavourIdentifier } from '@formicoidea/labre-core/std';
9
+ import { html, type TemplateResult } from 'lit';
10
+
11
+ const ResizeIcon = html`<svg
12
+ width="24"
13
+ height="24"
14
+ viewBox="0 0 24 24"
15
+ fill="none"
16
+ stroke="currentColor"
17
+ stroke-width="1.6"
18
+ stroke-linecap="round"
19
+ stroke-linejoin="round"
20
+ >
21
+ <path d="M9 5H5v4M15 19h4v-4" />
22
+ <path d="M5 5l6 6M19 19l-6-6" />
23
+ </svg>`;
24
+
25
+ /** Tag — show / hide the facet name labels. */
26
+ const LabelsIcon = html`<svg
27
+ width="24"
28
+ height="24"
29
+ viewBox="0 0 24 24"
30
+ fill="none"
31
+ stroke="currentColor"
32
+ stroke-width="1.6"
33
+ stroke-linecap="round"
34
+ stroke-linejoin="round"
35
+ >
36
+ <path d="M3 8.5l6-4.5 12 0 0 16-12 0-6-4.5z" />
37
+ <circle cx="8" cy="12" r="1.4" />
38
+ </svg>`;
39
+
40
+ type EdgyToggleProp = 'resizeEnabled' | 'showLabels';
41
+
42
+ /**
43
+ * Build a toolbar toggle that flips a boolean flag on every selected facets
44
+ * diagram: `active` reflects the current state, `run` flips it (with an undo
45
+ * checkpoint).
46
+ */
47
+ function booleanToggle(
48
+ id: string,
49
+ tooltip: string,
50
+ icon: TemplateResult,
51
+ prop: EdgyToggleProp
52
+ ) {
53
+ return {
54
+ id,
55
+ tooltip,
56
+ icon,
57
+ active(ctx: ToolbarContext) {
58
+ const models = ctx.getSurfaceModelsByType(EdgyFacetsElementModel);
59
+ return models.length > 0 && models.every(model => model[prop]);
60
+ },
61
+ run(ctx: ToolbarContext) {
62
+ const models = ctx.getSurfaceModelsByType(EdgyFacetsElementModel);
63
+ if (!models.length) return;
64
+
65
+ const enable = !models.every(model => model[prop]);
66
+ ctx.std.store.captureSync();
67
+ const crud = ctx.std.get(EdgelessCRUDIdentifier);
68
+ for (const model of models) {
69
+ crud.updateElement(model.id, { [prop]: enable });
70
+ }
71
+ },
72
+ };
73
+ }
74
+
75
+ export const edgyToolbarConfig = {
76
+ actions: [
77
+ booleanToggle(
78
+ 'a.toggle-resize',
79
+ 'Enable / lock resizing',
80
+ ResizeIcon,
81
+ 'resizeEnabled'
82
+ ),
83
+ booleanToggle(
84
+ 'b.toggle-labels',
85
+ 'Show / hide facet labels',
86
+ LabelsIcon,
87
+ 'showLabels'
88
+ ),
89
+ ],
90
+ when: ctx => ctx.getSurfaceModelsByType(EdgyFacetsElementModel).length > 0,
91
+ } as const satisfies ToolbarModuleConfig;
92
+
93
+ export const edgyToolbarExtension = ToolbarModuleExtension({
94
+ id: BlockFlavourIdentifier('affine:surface:edgy'),
95
+ config: edgyToolbarConfig,
96
+ });