@formicoidea/labre-framework-cynefin 0.23.2 → 0.24.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/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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ElementRenderer } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
|
|
3
|
+
/**
|
|
4
|
+
* Canvas renderer for the Estuarine framework map — reproduces the official SVG:
|
|
5
|
+
* the e (vertical, double-headed) / t (horizontal, single-headed) axes and the
|
|
6
|
+
* three reference curves (Liminal / Volatile / Counter-factual), each with its
|
|
7
|
+
* legend and individually hideable. Drawn in the fixed reference space and
|
|
8
|
+
* scaled uniformly to the element bounds.
|
|
9
|
+
*/
|
|
10
|
+
export declare const estuarine: ElementRenderer<EstuarineElementModel>;
|
|
11
|
+
export declare const EstuarineRendererExtension: import("@formicoidea/labre-core/store").ExtensionType & {
|
|
12
|
+
identifier: import("@formicoidea/labre-core/_pkgs/global/di").ServiceIdentifier<ElementRenderer<EstuarineElementModel>>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ElementRendererExtension, } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { FONT_FAMILY, refScale } from '../utils';
|
|
3
|
+
import { ARROWHEADS, AXIS_LABELS, AXIS_WIDTH, COLORS, COUNTERFACTUAL_PATH, COUNTERFACTUAL_WIDTH, E_AXIS, LABEL_LETTER_SPACING, LABELS, LIMINAL_PATH, LIMINAL_WIDTH, REF_H, REF_W, T_AXIS, VOLATILE_PATH, VOLATILE_WIDTH, } from './consts';
|
|
4
|
+
/**
|
|
5
|
+
* Canvas renderer for the Estuarine framework map — reproduces the official SVG:
|
|
6
|
+
* the e (vertical, double-headed) / t (horizontal, single-headed) axes and the
|
|
7
|
+
* three reference curves (Liminal / Volatile / Counter-factual), each with its
|
|
8
|
+
* legend and individually hideable. Drawn in the fixed reference space and
|
|
9
|
+
* scaled uniformly to the element bounds.
|
|
10
|
+
*/
|
|
11
|
+
export const estuarine = (model, ctx, matrix) => {
|
|
12
|
+
const [, , w, h] = model.deserializedXYWH;
|
|
13
|
+
const cx = w / 2;
|
|
14
|
+
const cy = h / 2;
|
|
15
|
+
ctx.setTransform(matrix.translateSelf(cx, cy).rotateSelf(model.rotate).translateSelf(-cx, -cy));
|
|
16
|
+
const { s, ox, oy } = refScale(w, h, REF_W, REF_H);
|
|
17
|
+
ctx.translate(ox, oy);
|
|
18
|
+
ctx.scale(s, s);
|
|
19
|
+
ctx.lineCap = 'round';
|
|
20
|
+
ctx.lineJoin = 'round';
|
|
21
|
+
// ── Axes ────────────────────────────────────────────────────────────
|
|
22
|
+
ctx.strokeStyle = COLORS.axis;
|
|
23
|
+
ctx.fillStyle = COLORS.axis;
|
|
24
|
+
ctx.lineWidth = AXIS_WIDTH;
|
|
25
|
+
ctx.beginPath();
|
|
26
|
+
ctx.moveTo(E_AXIS.x, E_AXIS.y1);
|
|
27
|
+
ctx.lineTo(E_AXIS.x, E_AXIS.y2);
|
|
28
|
+
ctx.moveTo(T_AXIS.x1, T_AXIS.y);
|
|
29
|
+
ctx.lineTo(T_AXIS.x2, T_AXIS.y);
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
for (const [[tx, ty], [ax, ay], [bx, by]] of ARROWHEADS) {
|
|
32
|
+
ctx.beginPath();
|
|
33
|
+
ctx.moveTo(tx, ty);
|
|
34
|
+
ctx.lineTo(ax, ay);
|
|
35
|
+
ctx.lineTo(bx, by);
|
|
36
|
+
ctx.closePath();
|
|
37
|
+
ctx.fill();
|
|
38
|
+
}
|
|
39
|
+
// Uppercase legend (centre-anchored, alphabetic baseline, letter-spaced).
|
|
40
|
+
const hasSpacing = 'letterSpacing' in ctx;
|
|
41
|
+
const legend = (l) => {
|
|
42
|
+
ctx.fillStyle = l.color;
|
|
43
|
+
ctx.font = `600 ${l.size}px ${FONT_FAMILY}`;
|
|
44
|
+
ctx.textAlign = 'center';
|
|
45
|
+
ctx.textBaseline = 'alphabetic';
|
|
46
|
+
if (hasSpacing)
|
|
47
|
+
ctx.letterSpacing = `${LABEL_LETTER_SPACING}px`;
|
|
48
|
+
ctx.fillText(l.text, l.x, l.y);
|
|
49
|
+
if (hasSpacing)
|
|
50
|
+
ctx.letterSpacing = '0px';
|
|
51
|
+
};
|
|
52
|
+
// ── Liminal (green) ─────────────────────────────────────────────────
|
|
53
|
+
if (model.showLiminal) {
|
|
54
|
+
ctx.strokeStyle = COLORS.liminal;
|
|
55
|
+
ctx.lineWidth = LIMINAL_WIDTH;
|
|
56
|
+
ctx.stroke(new Path2D(LIMINAL_PATH));
|
|
57
|
+
legend(LABELS.liminal);
|
|
58
|
+
}
|
|
59
|
+
// ── Volatile (red) ──────────────────────────────────────────────────
|
|
60
|
+
if (model.showVolatile) {
|
|
61
|
+
ctx.strokeStyle = COLORS.volatile;
|
|
62
|
+
ctx.lineWidth = VOLATILE_WIDTH;
|
|
63
|
+
ctx.stroke(new Path2D(VOLATILE_PATH));
|
|
64
|
+
legend(LABELS.volatile);
|
|
65
|
+
}
|
|
66
|
+
// ── Counter-factual (dark) ──────────────────────────────────────────
|
|
67
|
+
if (model.showCounterfactual) {
|
|
68
|
+
ctx.strokeStyle = COLORS.counterfactual;
|
|
69
|
+
ctx.lineWidth = COUNTERFACTUAL_WIDTH;
|
|
70
|
+
ctx.stroke(new Path2D(COUNTERFACTUAL_PATH));
|
|
71
|
+
legend(LABELS.counterfactual);
|
|
72
|
+
}
|
|
73
|
+
// ── Italic e / t axis letters ───────────────────────────────────────
|
|
74
|
+
if (model.showAxisLabels) {
|
|
75
|
+
ctx.fillStyle = COLORS.axisLabel;
|
|
76
|
+
ctx.font = `italic 700 ${AXIS_LABELS.size}px Georgia, serif`;
|
|
77
|
+
ctx.textAlign = 'left';
|
|
78
|
+
ctx.textBaseline = 'alphabetic';
|
|
79
|
+
ctx.fillText(AXIS_LABELS.e.text, AXIS_LABELS.e.x, AXIS_LABELS.e.y);
|
|
80
|
+
ctx.fillText(AXIS_LABELS.t.text, AXIS_LABELS.t.x, AXIS_LABELS.t.y);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export const EstuarineRendererExtension = ElementRendererExtension('estuarine', estuarine);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EstuarineElementModel } from '@formicoidea/labre-core/model';
|
|
2
|
+
import { GfxElementModelView } from '@formicoidea/labre-core/std/gfx';
|
|
3
|
+
/**
|
|
4
|
+
* View for the Estuarine background. Registering it ensures `gfx.view.get(model)`
|
|
5
|
+
* returns a view (required so move / select interactions work).
|
|
6
|
+
*/
|
|
7
|
+
export declare class EstuarineView extends GfxElementModelView<EstuarineElementModel> {
|
|
8
|
+
static type: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resize gating: the resize handles are hidden unless `model.resizeEnabled` is
|
|
12
|
+
* true (toggled from the toolbar). Moving / selecting stays available.
|
|
13
|
+
*/
|
|
14
|
+
export declare const EstuarineInteraction: import("@formicoidea/labre-core/store").ExtensionType;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GfxElementModelView, GfxViewInteractionExtension, } from '@formicoidea/labre-core/std/gfx';
|
|
2
|
+
/**
|
|
3
|
+
* View for the Estuarine background. Registering it ensures `gfx.view.get(model)`
|
|
4
|
+
* returns a view (required so move / select interactions work).
|
|
5
|
+
*/
|
|
6
|
+
export class EstuarineView extends GfxElementModelView {
|
|
7
|
+
static { this.type = 'estuarine'; }
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resize gating: the resize handles are hidden unless `model.resizeEnabled` is
|
|
11
|
+
* true (toggled from the toolbar). Moving / selecting stays available.
|
|
12
|
+
*/
|
|
13
|
+
export const EstuarineInteraction = GfxViewInteractionExtension(EstuarineView.type, {
|
|
14
|
+
handleResize({ model }) {
|
|
15
|
+
return {
|
|
16
|
+
beforeResize({ set }) {
|
|
17
|
+
if (!model.resizeEnabled) {
|
|
18
|
+
set({ allowedHandlers: [] });
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ToolbarContext } from '@formicoidea/labre-core/shared/services';
|
|
2
|
+
import { type TemplateResult } from 'lit';
|
|
3
|
+
export declare const estuarineToolbarConfig: {
|
|
4
|
+
readonly actions: [{
|
|
5
|
+
id: string;
|
|
6
|
+
tooltip: string;
|
|
7
|
+
icon: TemplateResult;
|
|
8
|
+
active(ctx: ToolbarContext): boolean;
|
|
9
|
+
run(ctx: ToolbarContext): void;
|
|
10
|
+
}, {
|
|
11
|
+
id: string;
|
|
12
|
+
tooltip: string;
|
|
13
|
+
icon: TemplateResult;
|
|
14
|
+
active(ctx: ToolbarContext): boolean;
|
|
15
|
+
run(ctx: ToolbarContext): void;
|
|
16
|
+
}, {
|
|
17
|
+
id: string;
|
|
18
|
+
tooltip: string;
|
|
19
|
+
icon: TemplateResult;
|
|
20
|
+
active(ctx: ToolbarContext): boolean;
|
|
21
|
+
run(ctx: ToolbarContext): void;
|
|
22
|
+
}, {
|
|
23
|
+
id: string;
|
|
24
|
+
tooltip: string;
|
|
25
|
+
icon: TemplateResult;
|
|
26
|
+
active(ctx: ToolbarContext): boolean;
|
|
27
|
+
run(ctx: ToolbarContext): void;
|
|
28
|
+
}, {
|
|
29
|
+
id: string;
|
|
30
|
+
tooltip: string;
|
|
31
|
+
icon: TemplateResult;
|
|
32
|
+
active(ctx: ToolbarContext): boolean;
|
|
33
|
+
run(ctx: ToolbarContext): void;
|
|
34
|
+
}];
|
|
35
|
+
readonly when: (ctx: ToolbarContext) => boolean;
|
|
36
|
+
};
|
|
37
|
+
export declare const estuarineToolbarExtension: import("@formicoidea/labre-core/store").ExtensionType;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { EdgelessCRUDIdentifier } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { EstuarineElementModel } 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 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>`;
|
|
7
|
+
// All curve icons use currentColor so the toolbar can grey them when inactive;
|
|
8
|
+
// they are distinguished by shape (wave / arc / hooked curve).
|
|
9
|
+
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>`;
|
|
10
|
+
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>`;
|
|
11
|
+
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>`;
|
|
12
|
+
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>`;
|
|
13
|
+
function booleanToggle(id, tooltip, icon, prop) {
|
|
14
|
+
return {
|
|
15
|
+
id,
|
|
16
|
+
tooltip,
|
|
17
|
+
icon,
|
|
18
|
+
active(ctx) {
|
|
19
|
+
const models = ctx.getSurfaceModelsByType(EstuarineElementModel);
|
|
20
|
+
return models.length > 0 && models.every(model => model[prop]);
|
|
21
|
+
},
|
|
22
|
+
run(ctx) {
|
|
23
|
+
const models = ctx.getSurfaceModelsByType(EstuarineElementModel);
|
|
24
|
+
if (!models.length)
|
|
25
|
+
return;
|
|
26
|
+
const enable = !models.every(model => model[prop]);
|
|
27
|
+
ctx.std.store.captureSync();
|
|
28
|
+
const crud = ctx.std.get(EdgelessCRUDIdentifier);
|
|
29
|
+
for (const model of models)
|
|
30
|
+
crud.updateElement(model.id, { [prop]: enable });
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export const estuarineToolbarConfig = {
|
|
35
|
+
actions: [
|
|
36
|
+
booleanToggle('a.toggle-resize', 'Enable / lock resizing', ResizeIcon, 'resizeEnabled'),
|
|
37
|
+
booleanToggle('b.toggle-liminal', 'Show / hide the Liminal line', LiminalIcon, 'showLiminal'),
|
|
38
|
+
booleanToggle('c.toggle-volatile', 'Show / hide the Volatile line', VolatileIcon, 'showVolatile'),
|
|
39
|
+
booleanToggle('d.toggle-counterfactual', 'Show / hide the Counter-factual line', CounterfactualIcon, 'showCounterfactual'),
|
|
40
|
+
booleanToggle('e.toggle-axis-labels', 'Show / hide axis labels (e / t)', AxisIcon, 'showAxisLabels'),
|
|
41
|
+
],
|
|
42
|
+
when: ctx => ctx.getSurfaceModelsByType(EstuarineElementModel).length > 0,
|
|
43
|
+
};
|
|
44
|
+
export const estuarineToolbarExtension = ToolbarModuleExtension({
|
|
45
|
+
id: BlockFlavourIdentifier('affine:surface:estuarine'),
|
|
46
|
+
config: estuarineToolbarConfig,
|
|
47
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { makeTemplateSnapshot, surfaceText, } from '@formicoidea/labre-core/gfx/template';
|
|
2
|
+
import { FontFamily, ShapeStyle, TextAlign } from '@formicoidea/labre-core/model';
|
|
3
|
+
import { REF_H as CYN_H, REF_W as CYN_W } from '../cynefin/consts';
|
|
4
|
+
import { REF_H as EST_H, REF_W as EST_W } from '../estuarine/consts';
|
|
5
|
+
const HEX_SIZE = 60;
|
|
6
|
+
const HEX_FILL = '#34c724';
|
|
7
|
+
const HEX_STROKE = '#1f1f1f';
|
|
8
|
+
const HEX_VERTICES = [
|
|
9
|
+
[1, 0.5],
|
|
10
|
+
[0.75, 0.933],
|
|
11
|
+
[0.25, 0.933],
|
|
12
|
+
[0, 0.5],
|
|
13
|
+
[0.25, 0.067],
|
|
14
|
+
[0.75, 0.067],
|
|
15
|
+
];
|
|
16
|
+
function sticky(x, y, text) {
|
|
17
|
+
return {
|
|
18
|
+
type: 'shape',
|
|
19
|
+
shapeType: 'rect',
|
|
20
|
+
filled: true,
|
|
21
|
+
fillColor: '#fff3b0',
|
|
22
|
+
strokeColor: '#d9b740',
|
|
23
|
+
strokeWidth: 1.5,
|
|
24
|
+
shapeStyle: ShapeStyle.General,
|
|
25
|
+
roughness: 0,
|
|
26
|
+
radius: 8,
|
|
27
|
+
text: surfaceText(text),
|
|
28
|
+
color: '#1a1a1a',
|
|
29
|
+
fontFamily: FontFamily.Inter,
|
|
30
|
+
fontSize: 18,
|
|
31
|
+
textAlign: TextAlign.Center,
|
|
32
|
+
xywh: `[${x},${y},200,70]`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function hexagon(x, y) {
|
|
36
|
+
return {
|
|
37
|
+
type: 'shape',
|
|
38
|
+
shapeType: 'polygon',
|
|
39
|
+
vertices: HEX_VERTICES,
|
|
40
|
+
filled: true,
|
|
41
|
+
fillColor: HEX_FILL,
|
|
42
|
+
strokeColor: HEX_STROKE,
|
|
43
|
+
strokeWidth: 2,
|
|
44
|
+
shapeStyle: ShapeStyle.General,
|
|
45
|
+
roughness: 0,
|
|
46
|
+
xywh: `[${x},${y},${HEX_SIZE},${HEX_SIZE}]`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function caption(x, y, str) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'text',
|
|
52
|
+
text: surfaceText(str),
|
|
53
|
+
color: '#1a1a1a',
|
|
54
|
+
fontFamily: FontFamily.Inter,
|
|
55
|
+
fontSize: 16,
|
|
56
|
+
textAlign: TextAlign.Center,
|
|
57
|
+
xywh: `[${x},${y},120,24]`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function tpl(name, preview, elements) {
|
|
61
|
+
return { name, type: 'template', preview, content: makeTemplateSnapshot(elements, name) };
|
|
62
|
+
}
|
|
63
|
+
const ATTRS = 'width="100%" height="100%" viewBox="0 0 135 80" xmlns="http://www.w3.org/2000/svg"';
|
|
64
|
+
const cynefinBg = (xywh) => ({ type: 'cynefin', xywh });
|
|
65
|
+
const estuarineBg = (xywh) => ({ type: 'estuarine', xywh });
|
|
66
|
+
export const cynefinTemplateCategory = {
|
|
67
|
+
name: 'Cynefin',
|
|
68
|
+
templates: [
|
|
69
|
+
tpl('Decision sorting', `<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>`, {
|
|
70
|
+
bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`),
|
|
71
|
+
s1: sticky(190, 175, 'Probe & learn'),
|
|
72
|
+
s2: sticky(690, 175, 'Expert analysis'),
|
|
73
|
+
s3: sticky(190, 505, 'Act now'),
|
|
74
|
+
s4: sticky(690, 505, 'Known issue'),
|
|
75
|
+
}),
|
|
76
|
+
tpl('Cynefin framework', `<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>`, { bg: cynefinBg(`[0,0,${CYN_W},${CYN_H}]`) }),
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
export const estuarineTemplateCategory = {
|
|
80
|
+
name: 'Estuarine',
|
|
81
|
+
templates: [
|
|
82
|
+
tpl('Constraint map', `<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>`, {
|
|
83
|
+
bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`),
|
|
84
|
+
h1: hexagon(150, 220),
|
|
85
|
+
c1: caption(120, 284, 'Policy'),
|
|
86
|
+
h2: hexagon(330, 360),
|
|
87
|
+
c2: caption(300, 424, 'Habit'),
|
|
88
|
+
h3: hexagon(230, 520),
|
|
89
|
+
c3: caption(200, 584, 'Budget'),
|
|
90
|
+
}),
|
|
91
|
+
tpl('Estuarine map', `<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>`, { bg: estuarineBg(`[0,0,${EST_W},${EST_H}]`) }),
|
|
92
|
+
tpl('Hexagon constraint', `<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>`, { hex: hexagon(0, 0) }),
|
|
93
|
+
],
|
|
94
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Colored Cynefin glyph for the main toolbar button. */
|
|
2
|
+
export declare const cynefinToolbarIcon: import("lit-html").TemplateResult<2>;
|
|
3
|
+
/** Menu icon — create the Cynefin diagram. */
|
|
4
|
+
export declare const cynefinMenuIcon: import("lit-html").TemplateResult<2>;
|
|
5
|
+
/** Menu icon — create the Estuarine map. */
|
|
6
|
+
export declare const estuarineMenuIcon: import("lit-html").TemplateResult<2>;
|
|
7
|
+
/** Menu icon — hexagon constraint node. */
|
|
8
|
+
export declare const hexagonMenuIcon: import("lit-html").TemplateResult<2>;
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import { svg } from 'lit';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const cynefinToolbarIcon = svg`<svg width="100%" height="100%" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1
|
+
import { svg } from 'lit';
|
|
2
|
+
/** Colored Cynefin glyph for the main toolbar button. */
|
|
3
|
+
export const cynefinToolbarIcon = svg `<svg width="100%" height="100%" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
5
4
|
<g stroke="#3f444a" stroke-width="3" stroke-linecap="round">
|
|
6
5
|
<path d="M30 8 C28 18 33 24 26 30 C20 35 14 33 9 33"/>
|
|
7
6
|
<path d="M26 30 C28 40 28 46 28 50"/>
|
|
8
7
|
<path d="M34 22 C40 23 46 24 50 25" stroke-dasharray="3 3"/>
|
|
9
8
|
</g>
|
|
10
9
|
<g stroke="#3f444a" stroke-width="1.4"><path d="M22 33 l-2 4M24 38 l-2 5M26 43 l-2 5"/></g>
|
|
11
|
-
</svg>`;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export const cynefinMenuIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
10
|
+
</svg>`;
|
|
11
|
+
/** Menu icon — create the Cynefin diagram. */
|
|
12
|
+
export const cynefinMenuIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
15
13
|
<path d="M13 3 C12 8 14 11 11 13 C8 15 5 14 3 14" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
|
|
16
14
|
<path d="M11 13 C12 18 12 20 12 22" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
|
|
17
15
|
<path d="M15 10 C18 10.5 20 11 22 11.5" stroke="currentColor" stroke-width="1.6" stroke-dasharray="2.5 2.5" stroke-linecap="round"/>
|
|
18
|
-
</svg>`;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const estuarineMenuIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
</svg>`;
|
|
17
|
+
/** Menu icon — create the Estuarine map. */
|
|
18
|
+
export const estuarineMenuIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
22
19
|
<path d="M5 3 V20 M5 17 H21" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>
|
|
23
20
|
<path d="M3 6 l2-2 2 2 M3 17 l2 2 2 -2 M18 15 l3 2 -3 2" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
|
24
21
|
<path d="M6 10 C11 6 14 13 21 9" stroke="currentColor" stroke-width="1.4" fill="none" stroke-linecap="round"/>
|
|
25
|
-
</svg>`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export const hexagonMenuIcon = svg`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
22
|
+
</svg>`;
|
|
23
|
+
/** Menu icon — hexagon constraint node. */
|
|
24
|
+
export const hexagonMenuIcon = svg `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
29
25
|
<polygon points="21,12 16.5,19.8 7.5,19.8 3,12 7.5,4.2 16.5,4.2" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
|
|
30
|
-
</svg>`;
|
|
26
|
+
</svg>`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
declare const EdgelessCynefinEstuarineMenu_base: typeof LitElement & import("@formicoidea/labre-core/_pkgs/global/utils").Constructor<import("@formicoidea/labre-core/_pkgs/affine-widget-edgeless-toolbar").EdgelessToolbarToolClass>;
|
|
4
|
+
/**
|
|
5
|
+
* The popover above the toolbar hosting both frameworks: create the Cynefin
|
|
6
|
+
* diagram, the Estuarine map, or a hexagon constraint node.
|
|
7
|
+
*/
|
|
8
|
+
export declare class EdgelessCynefinEstuarineMenu extends EdgelessCynefinEstuarineMenu_base {
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
type: typeof EmptyTool;
|
|
11
|
+
private _finish;
|
|
12
|
+
private _createCynefin;
|
|
13
|
+
private _createMap;
|
|
14
|
+
private _createHexagon;
|
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
-
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
-
import { ShapeStyle } from '@formicoidea/labre-core/model';
|
|
4
|
-
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
5
|
-
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
6
|
-
import { css, html, LitElement } from 'lit';
|
|
7
|
-
|
|
8
|
-
import { REF_H as
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
export class EdgelessCynefinEstuarineMenu extends EdgelessToolbarToolMixin(
|
|
36
|
-
LitElement
|
|
37
|
-
) {
|
|
38
|
-
static override styles = css`
|
|
1
|
+
import { DefaultTool } from '@formicoidea/labre-core/blocks/surface';
|
|
2
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
3
|
+
import { ShapeStyle } from '@formicoidea/labre-core/model';
|
|
4
|
+
import { EdgelessToolbarToolMixin } from '@formicoidea/labre-core/widgets/edgeless-toolbar';
|
|
5
|
+
import { Bound } from '@formicoidea/labre-core/global/gfx';
|
|
6
|
+
import { css, html, LitElement } from 'lit';
|
|
7
|
+
import { REF_H as CYN_H, REF_W as CYN_W } from '../cynefin/consts';
|
|
8
|
+
import { REF_H as EST_H, REF_W as EST_W } from '../estuarine/consts';
|
|
9
|
+
import { cynefinMenuIcon, estuarineMenuIcon, hexagonMenuIcon, } from './icons';
|
|
10
|
+
/** Estuarine map default size (REF aspect, scaled up so it reads on canvas). */
|
|
11
|
+
const MAP_SCALE = 1.2;
|
|
12
|
+
const HEX_SIZE = 60;
|
|
13
|
+
const HEX_FILL = '#34c724';
|
|
14
|
+
const HEX_STROKE = '#1f1f1f';
|
|
15
|
+
/** Flat-top regular hexagon, normalized vertices. */
|
|
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
|
+
* The popover above the toolbar hosting both frameworks: create the Cynefin
|
|
26
|
+
* diagram, the Estuarine map, or a hexagon constraint node.
|
|
27
|
+
*/
|
|
28
|
+
export class EdgelessCynefinEstuarineMenu extends EdgelessToolbarToolMixin(LitElement) {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.type = EmptyTool;
|
|
32
|
+
}
|
|
33
|
+
static { this.styles = css `
|
|
39
34
|
:host {
|
|
40
35
|
position: absolute;
|
|
41
36
|
display: flex;
|
|
@@ -56,77 +51,58 @@ export class EdgelessCynefinEstuarineMenu extends EdgelessToolbarToolMixin(
|
|
|
56
51
|
width: 24px;
|
|
57
52
|
height: 24px;
|
|
58
53
|
}
|
|
59
|
-
`;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
vertices: HEX_VERTICES,
|
|
112
|
-
filled: true,
|
|
113
|
-
fillColor: HEX_FILL,
|
|
114
|
-
strokeColor: HEX_STROKE,
|
|
115
|
-
strokeWidth: 2,
|
|
116
|
-
shapeStyle: ShapeStyle.General,
|
|
117
|
-
roughness: 0,
|
|
118
|
-
xywh: new Bound(
|
|
119
|
-
cx - HEX_SIZE / 2,
|
|
120
|
-
cy - HEX_SIZE / 2,
|
|
121
|
-
HEX_SIZE,
|
|
122
|
-
HEX_SIZE
|
|
123
|
-
).serialize(),
|
|
124
|
-
});
|
|
125
|
-
this._finish(id);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
override render() {
|
|
129
|
-
return html`
|
|
54
|
+
`; }
|
|
55
|
+
_finish(id) {
|
|
56
|
+
const { gfx } = this;
|
|
57
|
+
gfx.doc.captureSync();
|
|
58
|
+
gfx.tool.setTool(DefaultTool);
|
|
59
|
+
gfx.selection.set({ elements: [id], editing: false });
|
|
60
|
+
}
|
|
61
|
+
_createCynefin() {
|
|
62
|
+
const { gfx } = this;
|
|
63
|
+
if (!gfx.surface)
|
|
64
|
+
return;
|
|
65
|
+
const { centerX, centerY } = gfx.viewport;
|
|
66
|
+
const id = gfx.surface.addElement({
|
|
67
|
+
type: 'cynefin',
|
|
68
|
+
xywh: new Bound(centerX - CYN_W / 2, centerY - CYN_H / 2, CYN_W, CYN_H).serialize(),
|
|
69
|
+
});
|
|
70
|
+
this._finish(id);
|
|
71
|
+
}
|
|
72
|
+
_createMap() {
|
|
73
|
+
const { gfx } = this;
|
|
74
|
+
if (!gfx.surface)
|
|
75
|
+
return;
|
|
76
|
+
const width = EST_W * MAP_SCALE;
|
|
77
|
+
const height = EST_H * MAP_SCALE;
|
|
78
|
+
const { centerX, centerY } = gfx.viewport;
|
|
79
|
+
const id = gfx.surface.addElement({
|
|
80
|
+
type: 'estuarine',
|
|
81
|
+
xywh: new Bound(centerX - width / 2, centerY - height / 2, width, height).serialize(),
|
|
82
|
+
});
|
|
83
|
+
this._finish(id);
|
|
84
|
+
}
|
|
85
|
+
_createHexagon() {
|
|
86
|
+
const { gfx } = this;
|
|
87
|
+
if (!gfx.surface)
|
|
88
|
+
return;
|
|
89
|
+
const { centerX: cx, centerY: cy } = gfx.viewport;
|
|
90
|
+
const id = gfx.surface.addElement({
|
|
91
|
+
type: 'shape',
|
|
92
|
+
shapeType: 'polygon',
|
|
93
|
+
vertices: HEX_VERTICES,
|
|
94
|
+
filled: true,
|
|
95
|
+
fillColor: HEX_FILL,
|
|
96
|
+
strokeColor: HEX_STROKE,
|
|
97
|
+
strokeWidth: 2,
|
|
98
|
+
shapeStyle: ShapeStyle.General,
|
|
99
|
+
roughness: 0,
|
|
100
|
+
xywh: new Bound(cx - HEX_SIZE / 2, cy - HEX_SIZE / 2, HEX_SIZE, HEX_SIZE).serialize(),
|
|
101
|
+
});
|
|
102
|
+
this._finish(id);
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
return html `
|
|
130
106
|
<edgeless-slide-menu>
|
|
131
107
|
<div class="menu-content">
|
|
132
108
|
<div class="button-group-container">
|
|
@@ -151,6 +127,6 @@ export class EdgelessCynefinEstuarineMenu extends EdgelessToolbarToolMixin(
|
|
|
151
127
|
</div>
|
|
152
128
|
</div>
|
|
153
129
|
</edgeless-slide-menu>
|
|
154
|
-
`;
|
|
155
|
-
|
|
156
|
-
}
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmptyTool } from '@formicoidea/labre-core/gfx/pointer';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
declare const EdgelessCynefinEstuarineSeniorButton_base: typeof LitElement & import("@formicoidea/labre-core/_pkgs/global/utils").Constructor<import("@formicoidea/labre-core/_pkgs/affine-widget-edgeless-toolbar").EdgelessToolbarToolClass>;
|
|
4
|
+
/** Main toolbar button that opens the combined Cynefin / Estuarine sub-menu. */
|
|
5
|
+
export declare class EdgelessCynefinEstuarineSeniorButton extends EdgelessCynefinEstuarineSeniorButton_base {
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
enableActiveBackground: boolean;
|
|
8
|
+
type: typeof EmptyTool;
|
|
9
|
+
private _toggleMenu;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|