@formicoidea/labre-framework-cynefin 0.23.2 → 0.23.3
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/cynefin/consts.d.ts +79 -0
- package/dist/cynefin/consts.js +141 -0
- package/dist/cynefin/element-renderer.d.ts +14 -0
- package/dist/cynefin/element-renderer.js +114 -0
- package/dist/cynefin/element-view.d.ts +14 -0
- package/dist/cynefin/element-view.js +23 -0
- package/dist/cynefin/toolbar/config.d.ts +31 -0
- package/dist/cynefin/toolbar/config.js +43 -0
- package/dist/descriptor.d.ts +7 -0
- package/{src/descriptor.ts → dist/descriptor.js} +4 -5
- package/dist/effects.d.ts +9 -0
- package/dist/effects.js +6 -0
- package/dist/estuarine/consts.d.ts +84 -0
- package/dist/estuarine/consts.js +54 -0
- package/dist/estuarine/element-renderer.d.ts +13 -0
- package/dist/estuarine/element-renderer.js +83 -0
- package/dist/estuarine/element-view.d.ts +14 -0
- package/dist/estuarine/element-view.js +23 -0
- package/dist/estuarine/toolbar/config.d.ts +37 -0
- package/dist/estuarine/toolbar/config.js +47 -0
- package/{src/index.ts → dist/index.d.ts} +1 -1
- package/dist/index.js +1 -0
- package/dist/templates/index.d.ts +3 -0
- package/dist/templates/index.js +94 -0
- package/dist/toolbar/icons.d.ts +8 -0
- package/{src/toolbar/icons.ts → dist/toolbar/icons.js} +13 -17
- package/dist/toolbar/menu.d.ts +17 -0
- package/{src/toolbar/menu.ts → dist/toolbar/menu.js} +88 -112
- package/dist/toolbar/senior-button.d.ts +12 -0
- package/{src/toolbar/senior-button.ts → dist/toolbar/senior-button.js} +42 -48
- package/dist/toolbar/senior-tool.d.ts +2 -0
- package/{src/toolbar/senior-tool.ts → dist/toolbar/senior-tool.js} +10 -14
- package/dist/utils.d.ts +11 -0
- package/{src/utils.ts → dist/utils.js} +10 -11
- package/dist/view.d.ts +6 -0
- package/dist/view.js +37 -0
- package/package.json +15 -6
- package/src/cynefin/consts.ts +0 -188
- package/src/cynefin/element-renderer.ts +0 -156
- package/src/cynefin/element-view.ts +0 -32
- package/src/cynefin/toolbar/config.ts +0 -60
- package/src/effects.ts +0 -20
- package/src/estuarine/consts.ts +0 -69
- package/src/estuarine/element-renderer.ts +0 -122
- package/src/estuarine/element-view.ts +0 -32
- package/src/estuarine/toolbar/config.ts +0 -65
- package/src/templates/index.ts +0 -130
- package/src/view.ts +0 -44
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
-
import { CynefinElementModel } 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 width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5H5v4M15 19h4v-4" /><path d="M5 5l6 6M19 19l-6-6" /></svg>`;
|
|
12
|
-
const TitlesIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 7h14M9 7v11" /></svg>`;
|
|
13
|
-
const DescIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 8h14M5 12h14M5 16h9" /></svg>`;
|
|
14
|
-
const LiminalIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 17 C9 6 15 6 19 7" /></svg>`;
|
|
15
|
-
|
|
16
|
-
type CynefinToggleProp =
|
|
17
|
-
| 'resizeEnabled'
|
|
18
|
-
| 'showTitles'
|
|
19
|
-
| 'showDescriptions'
|
|
20
|
-
| 'showLiminalLine';
|
|
21
|
-
|
|
22
|
-
function booleanToggle(
|
|
23
|
-
id: string,
|
|
24
|
-
tooltip: string,
|
|
25
|
-
icon: TemplateResult,
|
|
26
|
-
prop: CynefinToggleProp
|
|
27
|
-
) {
|
|
28
|
-
return {
|
|
29
|
-
id,
|
|
30
|
-
tooltip,
|
|
31
|
-
icon,
|
|
32
|
-
active(ctx: ToolbarContext) {
|
|
33
|
-
const models = ctx.getSurfaceModelsByType(CynefinElementModel);
|
|
34
|
-
return models.length > 0 && models.every(model => model[prop]);
|
|
35
|
-
},
|
|
36
|
-
run(ctx: ToolbarContext) {
|
|
37
|
-
const models = ctx.getSurfaceModelsByType(CynefinElementModel);
|
|
38
|
-
if (!models.length) return;
|
|
39
|
-
const enable = !models.every(model => model[prop]);
|
|
40
|
-
ctx.std.store.captureSync();
|
|
41
|
-
const crud = ctx.std.get(EdgelessCRUDIdentifier);
|
|
42
|
-
for (const model of models) crud.updateElement(model.id, { [prop]: enable });
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export const cynefinToolbarConfig = {
|
|
48
|
-
actions: [
|
|
49
|
-
booleanToggle('a.toggle-resize', 'Enable / lock resizing', ResizeIcon, 'resizeEnabled'),
|
|
50
|
-
booleanToggle('b.toggle-titles', 'Show / hide titles', TitlesIcon, 'showTitles'),
|
|
51
|
-
booleanToggle('c.toggle-descriptions', 'Show / hide explanatory text', DescIcon, 'showDescriptions'),
|
|
52
|
-
booleanToggle('d.toggle-liminal', 'Show / hide liminal line', LiminalIcon, 'showLiminalLine'),
|
|
53
|
-
],
|
|
54
|
-
when: ctx => ctx.getSurfaceModelsByType(CynefinElementModel).length > 0,
|
|
55
|
-
} as const satisfies ToolbarModuleConfig;
|
|
56
|
-
|
|
57
|
-
export const cynefinToolbarExtension = ToolbarModuleExtension({
|
|
58
|
-
id: BlockFlavourIdentifier('affine:surface:cynefin'),
|
|
59
|
-
config: cynefinToolbarConfig,
|
|
60
|
-
});
|
package/src/effects.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { EdgelessCynefinEstuarineMenu } from './toolbar/menu';
|
|
2
|
-
import { EdgelessCynefinEstuarineSeniorButton } from './toolbar/senior-button';
|
|
3
|
-
|
|
4
|
-
export function effects() {
|
|
5
|
-
customElements.define(
|
|
6
|
-
'edgeless-cynefin-estuarine-menu',
|
|
7
|
-
EdgelessCynefinEstuarineMenu
|
|
8
|
-
);
|
|
9
|
-
customElements.define(
|
|
10
|
-
'edgeless-cynefin-estuarine-senior-button',
|
|
11
|
-
EdgelessCynefinEstuarineSeniorButton
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare global {
|
|
16
|
-
interface HTMLElementTagNameMap {
|
|
17
|
-
'edgeless-cynefin-estuarine-menu': EdgelessCynefinEstuarineMenu;
|
|
18
|
-
'edgeless-cynefin-estuarine-senior-button': EdgelessCynefinEstuarineSeniorButton;
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/estuarine/consts.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Visual constants for the Estuarine framework map, reproduced from the official
|
|
3
|
-
* SVG (viewBox 0 0 690 801). All geometry is authored in that fixed reference
|
|
4
|
-
* space and scaled uniformly to the element bounds by the renderer. The e axis
|
|
5
|
-
* is vertical & double-headed (energy), the t axis horizontal & single-headed
|
|
6
|
-
* (time only flows one way).
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const REF_W = 690;
|
|
10
|
-
export const REF_H = 801;
|
|
11
|
-
|
|
12
|
-
export const COLORS = {
|
|
13
|
-
axis: '#941253',
|
|
14
|
-
/** Italic e / t axis letters. */
|
|
15
|
-
axisLabel: '#c0392b',
|
|
16
|
-
liminal: '#5ecc44',
|
|
17
|
-
/** LIMINAL legend (darker than the curve). */
|
|
18
|
-
liminalLabel: '#2e7d32',
|
|
19
|
-
volatile: '#e63322',
|
|
20
|
-
counterfactual: '#1a1a1a',
|
|
21
|
-
/** VOLATILE + COUNTER FACTUAL legends. */
|
|
22
|
-
label: '#1a1a1a',
|
|
23
|
-
} as const;
|
|
24
|
-
|
|
25
|
-
/** e axis (vertical, double-headed): x, top y, bottom y. */
|
|
26
|
-
export const E_AXIS = { x: 43.5, y1: 97, y2: 763 } as const;
|
|
27
|
-
/** t axis (horizontal, single-headed → right): y, left x, right x. */
|
|
28
|
-
export const T_AXIS = { y: 649, x1: 28, x2: 616 } as const;
|
|
29
|
-
export const AXIS_WIDTH = 8;
|
|
30
|
-
|
|
31
|
-
/** Filled arrowhead triangles: [[tipX,tipY],[baseAX,baseAY],[baseBX,baseBY]]. */
|
|
32
|
-
export const ARROWHEADS: ReadonlyArray<
|
|
33
|
-
readonly [readonly [number, number], readonly [number, number], readonly [number, number]]
|
|
34
|
-
> = [
|
|
35
|
-
[[43.5, 72], [30, 100], [57, 100]], // e — top
|
|
36
|
-
[[43.5, 785], [30, 758], [57, 758]], // e — bottom
|
|
37
|
-
[[643, 649], [613, 636], [613, 662]], // t — right
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
/** Liminal: green boundary rising gently then dipping at the right end. */
|
|
41
|
-
export const LIMINAL_PATH =
|
|
42
|
-
'M 63 193 C 67 192, 78 189, 85 188 C 92 187, 100 186, 107 185 C 114 184, 122 183, 129 183 C 136 183, 144 183, 151 183 C 158 183, 166 183, 173 183 C 180 183, 188 184, 195 185 C 202 186, 210 188, 217 189 C 224 190, 232 192, 239 194 C 246 196, 254 198, 261 201 C 268 204, 276 207, 283 210 C 290 213, 298 217, 305 220 C 312 223, 320 226, 327 230 C 334 234, 342 238, 349 242 C 356 246, 364 250, 371 255 C 378 260, 386 264, 393 269 C 400 274, 408 278, 415 283 C 422 288, 430 292, 437 297 C 444 302, 451 306, 458 310 C 465 314, 473 319, 480 323 C 487 327, 495 332, 502 335 C 509 338, 517 341, 524 343 C 531 345, 539 348, 546 349 C 553 350, 561 350, 568 350 C 575 350, 583 348, 590 346 C 597 344, 605 340, 612 336 C 619 332, 626 325, 633 319 C 640 313, 648 302, 651 298 C 654 294, 654 295, 654 294';
|
|
43
|
-
export const LIMINAL_WIDTH = 4.5;
|
|
44
|
-
|
|
45
|
-
/** Counter-factual: dark boundary sweeping from the top down to the right. */
|
|
46
|
-
export const COUNTERFACTUAL_PATH =
|
|
47
|
-
'M 422 30 C 420 33, 414 41, 411 47 C 408 53, 405 59, 402 65 C 399 71, 397 77, 395 83 C 393 89, 392 95, 391 101 C 390 107, 389 113, 389 119 C 389 125, 389 131, 390 137 C 391 143, 392 149, 394 155 C 396 161, 399 167, 402 173 C 405 179, 408 185, 412 191 C 416 197, 421 203, 426 209 C 431 215, 436 221, 442 226 C 448 231, 454 237, 460 241 C 466 245, 472 249, 478 252 C 484 255, 490 258, 496 260 C 502 262, 508 264, 514 266 C 520 268, 526 270, 532 271 C 538 272, 544 274, 550 275 C 556 276, 562 277, 568 278 C 574 279, 580 279, 586 279 C 592 279, 598 280, 604 280 C 610 280, 616 281, 622 281 C 628 281, 634 280, 640 280 C 646 280, 655 279, 658 279';
|
|
48
|
-
export const COUNTERFACTUAL_WIDTH = 5.5;
|
|
49
|
-
|
|
50
|
-
/** Volatile: red boundary descending along the left, bulging right. */
|
|
51
|
-
export const VOLATILE_PATH =
|
|
52
|
-
'M 58 446 C 61 447, 70 451, 76 454 C 82 457, 88 462, 94 466 C 100 470, 107 476, 112 481 C 117 486, 122 492, 126 498 C 130 504, 135 509, 139 515 C 143 521, 145 526, 148 532 C 151 538, 153 544, 155 550 C 157 556, 159 562, 160 568 C 161 574, 162 580, 163 586 C 164 592, 164 598, 164 604 C 164 610, 166 616, 166 622 C 166 628, 166 634, 165 640 C 164 646, 164 652, 163 658 C 162 664, 162 670, 161 676 C 160 682, 160 688, 159 694 C 158 700, 155 706, 154 712 C 153 718, 152 724, 151 730 C 150 736, 148 746, 147 749';
|
|
53
|
-
export const VOLATILE_WIDTH = 5;
|
|
54
|
-
|
|
55
|
-
/** Uppercase legends: anchored centre, alphabetic baseline, with letter-spacing. */
|
|
56
|
-
export const LABELS = {
|
|
57
|
-
counterfactual: { text: 'COUNTER FACTUAL', x: 422, y: 25, size: 20, color: COLORS.label },
|
|
58
|
-
liminal: { text: 'LIMINAL', x: 316, y: 192, size: 18, color: COLORS.liminalLabel },
|
|
59
|
-
volatile: { text: 'VOLATILE', x: 219, y: 783, size: 20, color: COLORS.volatile },
|
|
60
|
-
} as const;
|
|
61
|
-
|
|
62
|
-
/** Italic Georgia axis letters (left-anchored, alphabetic baseline). */
|
|
63
|
-
export const AXIS_LABELS = {
|
|
64
|
-
e: { text: 'e', x: 14, y: 138 },
|
|
65
|
-
t: { text: 't', x: 580, y: 685 },
|
|
66
|
-
size: 34,
|
|
67
|
-
} as const;
|
|
68
|
-
|
|
69
|
-
export const LABEL_LETTER_SPACING = 4;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ElementRenderer,
|
|
3
|
-
ElementRendererExtension,
|
|
4
|
-
} from '@formicoidea/labre-core/blocks/surface';
|
|
5
|
-
import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
|
|
6
|
-
|
|
7
|
-
import { FONT_FAMILY, refScale } from '../utils';
|
|
8
|
-
import {
|
|
9
|
-
ARROWHEADS,
|
|
10
|
-
AXIS_LABELS,
|
|
11
|
-
AXIS_WIDTH,
|
|
12
|
-
COLORS,
|
|
13
|
-
COUNTERFACTUAL_PATH,
|
|
14
|
-
COUNTERFACTUAL_WIDTH,
|
|
15
|
-
E_AXIS,
|
|
16
|
-
LABEL_LETTER_SPACING,
|
|
17
|
-
LABELS,
|
|
18
|
-
LIMINAL_PATH,
|
|
19
|
-
LIMINAL_WIDTH,
|
|
20
|
-
REF_H,
|
|
21
|
-
REF_W,
|
|
22
|
-
T_AXIS,
|
|
23
|
-
VOLATILE_PATH,
|
|
24
|
-
VOLATILE_WIDTH,
|
|
25
|
-
} from './consts';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Canvas renderer for the Estuarine framework map — reproduces the official SVG:
|
|
29
|
-
* the e (vertical, double-headed) / t (horizontal, single-headed) axes and the
|
|
30
|
-
* three reference curves (Liminal / Volatile / Counter-factual), each with its
|
|
31
|
-
* legend and individually hideable. Drawn in the fixed reference space and
|
|
32
|
-
* scaled uniformly to the element bounds.
|
|
33
|
-
*/
|
|
34
|
-
export const estuarine: ElementRenderer<EstuarineElementModel> = (
|
|
35
|
-
model,
|
|
36
|
-
ctx,
|
|
37
|
-
matrix
|
|
38
|
-
) => {
|
|
39
|
-
const [, , w, h] = model.deserializedXYWH;
|
|
40
|
-
const cx = w / 2;
|
|
41
|
-
const cy = h / 2;
|
|
42
|
-
ctx.setTransform(
|
|
43
|
-
matrix.translateSelf(cx, cy).rotateSelf(model.rotate).translateSelf(-cx, -cy)
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
const { s, ox, oy } = refScale(w, h, REF_W, REF_H);
|
|
47
|
-
ctx.translate(ox, oy);
|
|
48
|
-
ctx.scale(s, s);
|
|
49
|
-
|
|
50
|
-
ctx.lineCap = 'round';
|
|
51
|
-
ctx.lineJoin = 'round';
|
|
52
|
-
|
|
53
|
-
// ── Axes ────────────────────────────────────────────────────────────
|
|
54
|
-
ctx.strokeStyle = COLORS.axis;
|
|
55
|
-
ctx.fillStyle = COLORS.axis;
|
|
56
|
-
ctx.lineWidth = AXIS_WIDTH;
|
|
57
|
-
ctx.beginPath();
|
|
58
|
-
ctx.moveTo(E_AXIS.x, E_AXIS.y1);
|
|
59
|
-
ctx.lineTo(E_AXIS.x, E_AXIS.y2);
|
|
60
|
-
ctx.moveTo(T_AXIS.x1, T_AXIS.y);
|
|
61
|
-
ctx.lineTo(T_AXIS.x2, T_AXIS.y);
|
|
62
|
-
ctx.stroke();
|
|
63
|
-
for (const [[tx, ty], [ax, ay], [bx, by]] of ARROWHEADS) {
|
|
64
|
-
ctx.beginPath();
|
|
65
|
-
ctx.moveTo(tx, ty);
|
|
66
|
-
ctx.lineTo(ax, ay);
|
|
67
|
-
ctx.lineTo(bx, by);
|
|
68
|
-
ctx.closePath();
|
|
69
|
-
ctx.fill();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Uppercase legend (centre-anchored, alphabetic baseline, letter-spaced).
|
|
73
|
-
const hasSpacing = 'letterSpacing' in ctx;
|
|
74
|
-
const legend = (l: { text: string; x: number; y: number; size: number; color: string }) => {
|
|
75
|
-
ctx.fillStyle = l.color;
|
|
76
|
-
ctx.font = `600 ${l.size}px ${FONT_FAMILY}`;
|
|
77
|
-
ctx.textAlign = 'center';
|
|
78
|
-
ctx.textBaseline = 'alphabetic';
|
|
79
|
-
if (hasSpacing) ctx.letterSpacing = `${LABEL_LETTER_SPACING}px`;
|
|
80
|
-
ctx.fillText(l.text, l.x, l.y);
|
|
81
|
-
if (hasSpacing) ctx.letterSpacing = '0px';
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ── Liminal (green) ─────────────────────────────────────────────────
|
|
85
|
-
if (model.showLiminal) {
|
|
86
|
-
ctx.strokeStyle = COLORS.liminal;
|
|
87
|
-
ctx.lineWidth = LIMINAL_WIDTH;
|
|
88
|
-
ctx.stroke(new Path2D(LIMINAL_PATH));
|
|
89
|
-
legend(LABELS.liminal);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ── Volatile (red) ──────────────────────────────────────────────────
|
|
93
|
-
if (model.showVolatile) {
|
|
94
|
-
ctx.strokeStyle = COLORS.volatile;
|
|
95
|
-
ctx.lineWidth = VOLATILE_WIDTH;
|
|
96
|
-
ctx.stroke(new Path2D(VOLATILE_PATH));
|
|
97
|
-
legend(LABELS.volatile);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ── Counter-factual (dark) ──────────────────────────────────────────
|
|
101
|
-
if (model.showCounterfactual) {
|
|
102
|
-
ctx.strokeStyle = COLORS.counterfactual;
|
|
103
|
-
ctx.lineWidth = COUNTERFACTUAL_WIDTH;
|
|
104
|
-
ctx.stroke(new Path2D(COUNTERFACTUAL_PATH));
|
|
105
|
-
legend(LABELS.counterfactual);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ── Italic e / t axis letters ───────────────────────────────────────
|
|
109
|
-
if (model.showAxisLabels) {
|
|
110
|
-
ctx.fillStyle = COLORS.axisLabel;
|
|
111
|
-
ctx.font = `italic 700 ${AXIS_LABELS.size}px Georgia, serif`;
|
|
112
|
-
ctx.textAlign = 'left';
|
|
113
|
-
ctx.textBaseline = 'alphabetic';
|
|
114
|
-
ctx.fillText(AXIS_LABELS.e.text, AXIS_LABELS.e.x, AXIS_LABELS.e.y);
|
|
115
|
-
ctx.fillText(AXIS_LABELS.t.text, AXIS_LABELS.t.x, AXIS_LABELS.t.y);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const EstuarineRendererExtension = ElementRendererExtension(
|
|
120
|
-
'estuarine',
|
|
121
|
-
estuarine
|
|
122
|
-
);
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
|
|
2
|
-
import {
|
|
3
|
-
GfxElementModelView,
|
|
4
|
-
GfxViewInteractionExtension,
|
|
5
|
-
} from '@formicoidea/labre-core/std/gfx';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* View for the Estuarine background. Registering it ensures `gfx.view.get(model)`
|
|
9
|
-
* returns a view (required so move / select interactions work).
|
|
10
|
-
*/
|
|
11
|
-
export class EstuarineView extends GfxElementModelView<EstuarineElementModel> {
|
|
12
|
-
static override type: string = 'estuarine';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Resize gating: the resize handles are hidden unless `model.resizeEnabled` is
|
|
17
|
-
* true (toggled from the toolbar). Moving / selecting stays available.
|
|
18
|
-
*/
|
|
19
|
-
export const EstuarineInteraction = GfxViewInteractionExtension<EstuarineView>(
|
|
20
|
-
EstuarineView.type,
|
|
21
|
-
{
|
|
22
|
-
handleResize({ model }) {
|
|
23
|
-
return {
|
|
24
|
-
beforeResize({ set }) {
|
|
25
|
-
if (!model.resizeEnabled) {
|
|
26
|
-
set({ allowedHandlers: [] });
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
-
import { EstuarineElementModel } 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 width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5H5v4M15 19h4v-4" /><path d="M5 5l6 6M19 19l-6-6" /></svg>`;
|
|
12
|
-
// All curve icons use currentColor so the toolbar can grey them when inactive;
|
|
13
|
-
// they are distinguished by shape (wave / arc / hooked curve).
|
|
14
|
-
const LiminalIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 13c3-6 6 4 9 0s6-6 9 0" /></svg>`;
|
|
15
|
-
const VolatileIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M7 4a9 9 0 0 1 0 18" /></svg>`;
|
|
16
|
-
const CounterfactualIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7c7 0 11 4 12 14" /></svg>`;
|
|
17
|
-
const AxisIcon = html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3v18M6 12h15" /><path d="M3 6l3-3 3 3M18 9l3 3-3 3" /></svg>`;
|
|
18
|
-
|
|
19
|
-
type EstuarineToggleProp =
|
|
20
|
-
| 'resizeEnabled'
|
|
21
|
-
| 'showLiminal'
|
|
22
|
-
| 'showVolatile'
|
|
23
|
-
| 'showCounterfactual'
|
|
24
|
-
| 'showAxisLabels';
|
|
25
|
-
|
|
26
|
-
function booleanToggle(
|
|
27
|
-
id: string,
|
|
28
|
-
tooltip: string,
|
|
29
|
-
icon: TemplateResult,
|
|
30
|
-
prop: EstuarineToggleProp
|
|
31
|
-
) {
|
|
32
|
-
return {
|
|
33
|
-
id,
|
|
34
|
-
tooltip,
|
|
35
|
-
icon,
|
|
36
|
-
active(ctx: ToolbarContext) {
|
|
37
|
-
const models = ctx.getSurfaceModelsByType(EstuarineElementModel);
|
|
38
|
-
return models.length > 0 && models.every(model => model[prop]);
|
|
39
|
-
},
|
|
40
|
-
run(ctx: ToolbarContext) {
|
|
41
|
-
const models = ctx.getSurfaceModelsByType(EstuarineElementModel);
|
|
42
|
-
if (!models.length) return;
|
|
43
|
-
const enable = !models.every(model => model[prop]);
|
|
44
|
-
ctx.std.store.captureSync();
|
|
45
|
-
const crud = ctx.std.get(EdgelessCRUDIdentifier);
|
|
46
|
-
for (const model of models) crud.updateElement(model.id, { [prop]: enable });
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const estuarineToolbarConfig = {
|
|
52
|
-
actions: [
|
|
53
|
-
booleanToggle('a.toggle-resize', 'Enable / lock resizing', ResizeIcon, 'resizeEnabled'),
|
|
54
|
-
booleanToggle('b.toggle-liminal', 'Show / hide the Liminal line', LiminalIcon, 'showLiminal'),
|
|
55
|
-
booleanToggle('c.toggle-volatile', 'Show / hide the Volatile line', VolatileIcon, 'showVolatile'),
|
|
56
|
-
booleanToggle('d.toggle-counterfactual', 'Show / hide the Counter-factual line', CounterfactualIcon, 'showCounterfactual'),
|
|
57
|
-
booleanToggle('e.toggle-axis-labels', 'Show / hide axis labels (e / t)', AxisIcon, 'showAxisLabels'),
|
|
58
|
-
],
|
|
59
|
-
when: ctx => ctx.getSurfaceModelsByType(EstuarineElementModel).length > 0,
|
|
60
|
-
} as const satisfies ToolbarModuleConfig;
|
|
61
|
-
|
|
62
|
-
export const estuarineToolbarExtension = ToolbarModuleExtension({
|
|
63
|
-
id: BlockFlavourIdentifier('affine:surface:estuarine'),
|
|
64
|
-
config: estuarineToolbarConfig,
|
|
65
|
-
});
|
package/src/templates/index.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeTemplateSnapshot,
|
|
3
|
-
type SurfaceElementsJSON,
|
|
4
|
-
surfaceText,
|
|
5
|
-
type Template,
|
|
6
|
-
type TemplateCategory,
|
|
7
|
-
} from '@formicoidea/labre-core/gfx/template';
|
|
8
|
-
import { FontFamily, ShapeStyle, TextAlign } from '@formicoidea/labre-core/model';
|
|
9
|
-
|
|
10
|
-
import { REF_H as CYN_H, REF_W as CYN_W } from '../cynefin/consts';
|
|
11
|
-
import { REF_H as EST_H, REF_W as EST_W } from '../estuarine/consts';
|
|
12
|
-
|
|
13
|
-
const HEX_SIZE = 60;
|
|
14
|
-
const HEX_FILL = '#34c724';
|
|
15
|
-
const HEX_STROKE = '#1f1f1f';
|
|
16
|
-
const HEX_VERTICES = [
|
|
17
|
-
[1, 0.5],
|
|
18
|
-
[0.75, 0.933],
|
|
19
|
-
[0.25, 0.933],
|
|
20
|
-
[0, 0.5],
|
|
21
|
-
[0.25, 0.067],
|
|
22
|
-
[0.75, 0.067],
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
function sticky(x: number, y: number, text: string) {
|
|
26
|
-
return {
|
|
27
|
-
type: 'shape',
|
|
28
|
-
shapeType: 'rect',
|
|
29
|
-
filled: true,
|
|
30
|
-
fillColor: '#fff3b0',
|
|
31
|
-
strokeColor: '#d9b740',
|
|
32
|
-
strokeWidth: 1.5,
|
|
33
|
-
shapeStyle: ShapeStyle.General,
|
|
34
|
-
roughness: 0,
|
|
35
|
-
radius: 8,
|
|
36
|
-
text: surfaceText(text),
|
|
37
|
-
color: '#1a1a1a',
|
|
38
|
-
fontFamily: FontFamily.Inter,
|
|
39
|
-
fontSize: 18,
|
|
40
|
-
textAlign: TextAlign.Center,
|
|
41
|
-
xywh: `[${x},${y},200,70]`,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function hexagon(x: number, y: number) {
|
|
46
|
-
return {
|
|
47
|
-
type: 'shape',
|
|
48
|
-
shapeType: 'polygon',
|
|
49
|
-
vertices: HEX_VERTICES,
|
|
50
|
-
filled: true,
|
|
51
|
-
fillColor: HEX_FILL,
|
|
52
|
-
strokeColor: HEX_STROKE,
|
|
53
|
-
strokeWidth: 2,
|
|
54
|
-
shapeStyle: ShapeStyle.General,
|
|
55
|
-
roughness: 0,
|
|
56
|
-
xywh: `[${x},${y},${HEX_SIZE},${HEX_SIZE}]`,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function caption(x: number, y: number, str: string) {
|
|
61
|
-
return {
|
|
62
|
-
type: 'text',
|
|
63
|
-
text: surfaceText(str),
|
|
64
|
-
color: '#1a1a1a',
|
|
65
|
-
fontFamily: FontFamily.Inter,
|
|
66
|
-
fontSize: 16,
|
|
67
|
-
textAlign: TextAlign.Center,
|
|
68
|
-
xywh: `[${x},${y},120,24]`,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function tpl(name: string, preview: string, elements: SurfaceElementsJSON): Template {
|
|
73
|
-
return { name, type: 'template', preview, content: makeTemplateSnapshot(elements, name) };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const ATTRS = 'width="100%" height="100%" viewBox="0 0 135 80" xmlns="http://www.w3.org/2000/svg"';
|
|
77
|
-
|
|
78
|
-
const cynefinBg = (xywh: string) => ({ type: 'cynefin', xywh });
|
|
79
|
-
const estuarineBg = (xywh: string) => ({ type: 'estuarine', xywh });
|
|
80
|
-
|
|
81
|
-
export const cynefinTemplateCategory: TemplateCategory = {
|
|
82
|
-
name: 'Cynefin',
|
|
83
|
-
templates: [
|
|
84
|
-
tpl(
|
|
85
|
-
'Decision sorting',
|
|
86
|
-
`<svg ${ATTRS} fill="none"><rect x="8" y="10" width="119" height="60" rx="4" stroke="#2a9d99" stroke-width="1.5"/><path d="M67 10 V70 M8 40 H127" stroke="#9aa0a6"/><rect x="18" y="18" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="83" y="18" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="18" y="48" width="34" height="14" rx="2" fill="#fff3b0"/><rect x="83" y="48" width="34" height="14" rx="2" fill="#fff3b0"/></svg>`,
|
|
87
|
-
{
|
|
88
|
-
bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`),
|
|
89
|
-
s1: sticky(190, 175, 'Probe & learn'),
|
|
90
|
-
s2: sticky(690, 175, 'Expert analysis'),
|
|
91
|
-
s3: sticky(190, 505, 'Act now'),
|
|
92
|
-
s4: sticky(690, 505, 'Known issue'),
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
tpl(
|
|
96
|
-
'Cynefin framework',
|
|
97
|
-
`<svg ${ATTRS} fill="none"><rect x="14" y="12" width="107" height="56" rx="4" stroke="#2a9d99" stroke-width="1.6"/><path d="M67 12 V68 M14 40 H121" stroke="#9aa0a6"/></svg>`,
|
|
98
|
-
{ bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`) }
|
|
99
|
-
),
|
|
100
|
-
],
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const estuarineTemplateCategory: TemplateCategory = {
|
|
104
|
-
name: 'Estuarine',
|
|
105
|
-
templates: [
|
|
106
|
-
tpl(
|
|
107
|
-
'Constraint map',
|
|
108
|
-
`<svg ${ATTRS} fill="none"><path d="M20 12 V70 M20 70 H120" stroke="#941253" stroke-width="2"/><g fill="#34c724" stroke="#1f1f1f"><path d="M44 28 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/><path d="M74 40 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/><path d="M56 52 l6 4 l0 8 l-6 4 l-6 -4 l0 -8 z"/></g></svg>`,
|
|
109
|
-
{
|
|
110
|
-
bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`),
|
|
111
|
-
h1: hexagon(150, 220),
|
|
112
|
-
c1: caption(120, 284, 'Policy'),
|
|
113
|
-
h2: hexagon(330, 360),
|
|
114
|
-
c2: caption(300, 424, 'Habit'),
|
|
115
|
-
h3: hexagon(230, 520),
|
|
116
|
-
c3: caption(200, 584, 'Budget'),
|
|
117
|
-
}
|
|
118
|
-
),
|
|
119
|
-
tpl(
|
|
120
|
-
'Estuarine map',
|
|
121
|
-
`<svg ${ATTRS} fill="none"><path d="M24 10 V70 M24 70 H120" stroke="#941253" stroke-width="2.4"/><path d="M30 52 q40 -30 84 -34" stroke="#5ecc44" stroke-width="2" fill="none"/></svg>`,
|
|
122
|
-
{ bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`) }
|
|
123
|
-
),
|
|
124
|
-
tpl(
|
|
125
|
-
'Hexagon constraint',
|
|
126
|
-
`<svg ${ATTRS} fill="none"><path d="M67 24 l18 11 l0 22 l-18 11 l-18 -11 l0 -22 z" fill="#34c724" stroke="#1f1f1f" stroke-width="2"/></svg>`,
|
|
127
|
-
{ hex: hexagon(0, 0) }
|
|
128
|
-
),
|
|
129
|
-
],
|
|
130
|
-
};
|
package/src/view.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ViewExtensionContext,
|
|
3
|
-
ViewExtensionProvider,
|
|
4
|
-
} from '@formicoidea/labre-core/ext-loader';
|
|
5
|
-
import { extendTemplateCategory } from '@formicoidea/labre-core/gfx/template';
|
|
6
|
-
|
|
7
|
-
import { CynefinRendererExtension } from './cynefin/element-renderer';
|
|
8
|
-
import { CynefinInteraction, CynefinView } from './cynefin/element-view';
|
|
9
|
-
import { cynefinToolbarExtension } from './cynefin/toolbar/config';
|
|
10
|
-
import { effects } from './effects';
|
|
11
|
-
import { EstuarineRendererExtension } from './estuarine/element-renderer';
|
|
12
|
-
import { EstuarineInteraction, EstuarineView } from './estuarine/element-view';
|
|
13
|
-
import { estuarineToolbarExtension } from './estuarine/toolbar/config';
|
|
14
|
-
import {
|
|
15
|
-
cynefinTemplateCategory,
|
|
16
|
-
estuarineTemplateCategory,
|
|
17
|
-
} from './templates';
|
|
18
|
-
import { cynefinEstuarineSeniorTool } from './toolbar/senior-tool';
|
|
19
|
-
|
|
20
|
-
export class CynefinEstuarineViewExtension extends ViewExtensionProvider {
|
|
21
|
-
override name = 'affine-cynefin-estuarine-gfx';
|
|
22
|
-
|
|
23
|
-
override effect(): void {
|
|
24
|
-
super.effect();
|
|
25
|
-
effects();
|
|
26
|
-
extendTemplateCategory(cynefinTemplateCategory);
|
|
27
|
-
extendTemplateCategory(estuarineTemplateCategory);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override setup(context: ViewExtensionContext) {
|
|
31
|
-
super.setup(context);
|
|
32
|
-
context.register(CynefinView);
|
|
33
|
-
context.register(CynefinRendererExtension);
|
|
34
|
-
context.register(EstuarineView);
|
|
35
|
-
context.register(EstuarineRendererExtension);
|
|
36
|
-
if (this.isEdgeless(context.scope)) {
|
|
37
|
-
context.register(CynefinInteraction);
|
|
38
|
-
context.register(EstuarineInteraction);
|
|
39
|
-
context.register(cynefinEstuarineSeniorTool);
|
|
40
|
-
context.register(cynefinToolbarExtension);
|
|
41
|
-
context.register(estuarineToolbarExtension);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|