@formicoidea/labre-framework-cynefin 0.23.0 → 0.23.1

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 (57) hide show
  1. package/dist/cynefin/consts.d.ts +80 -0
  2. package/dist/cynefin/consts.js +142 -0
  3. package/dist/cynefin/element-renderer.d.ts +15 -0
  4. package/dist/cynefin/element-renderer.js +115 -0
  5. package/dist/cynefin/element-view.d.ts +15 -0
  6. package/dist/cynefin/element-view.js +24 -0
  7. package/dist/cynefin/toolbar/config.d.ts +32 -0
  8. package/dist/cynefin/toolbar/config.js +44 -0
  9. package/dist/descriptor.d.ts +7 -0
  10. package/{src/descriptor.ts → dist/descriptor.js} +1 -1
  11. package/dist/effects.d.ts +10 -0
  12. package/dist/effects.js +7 -0
  13. package/dist/estuarine/consts.d.ts +85 -0
  14. package/dist/estuarine/consts.js +55 -0
  15. package/dist/estuarine/element-renderer.d.ts +14 -0
  16. package/dist/estuarine/element-renderer.js +84 -0
  17. package/dist/estuarine/element-view.d.ts +15 -0
  18. package/dist/estuarine/element-view.js +24 -0
  19. package/dist/estuarine/toolbar/config.d.ts +38 -0
  20. package/dist/estuarine/toolbar/config.js +48 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +2 -0
  23. package/dist/templates/index.d.ts +4 -0
  24. package/dist/templates/index.js +95 -0
  25. package/dist/toolbar/cynefin-menu.d.ts +12 -0
  26. package/dist/toolbar/cynefin-menu.js +66 -0
  27. package/dist/toolbar/cynefin-senior-button.d.ts +13 -0
  28. package/dist/toolbar/cynefin-senior-button.js +90 -0
  29. package/dist/toolbar/estuarine-menu.d.ts +14 -0
  30. package/dist/toolbar/estuarine-menu.js +113 -0
  31. package/dist/toolbar/estuarine-senior-button.d.ts +13 -0
  32. package/dist/toolbar/estuarine-senior-button.js +90 -0
  33. package/dist/toolbar/icons.d.ts +9 -0
  34. package/{src/toolbar/icons.ts → dist/toolbar/icons.js} +14 -17
  35. package/dist/toolbar/menu.d.ts +18 -0
  36. package/{src/toolbar/menu.ts → dist/toolbar/menu.js} +68 -91
  37. package/dist/toolbar/senior-button.d.ts +13 -0
  38. package/{src/toolbar/senior-button.ts → dist/toolbar/senior-button.js} +33 -38
  39. package/dist/toolbar/senior-tool.d.ts +3 -0
  40. package/{src/toolbar/senior-tool.ts → dist/toolbar/senior-tool.js} +5 -8
  41. package/dist/utils.d.ts +12 -0
  42. package/{src/utils.ts → dist/utils.js} +11 -11
  43. package/dist/view.d.ts +7 -0
  44. package/dist/view.js +38 -0
  45. package/package.json +15 -6
  46. package/src/cynefin/consts.ts +0 -188
  47. package/src/cynefin/element-renderer.ts +0 -156
  48. package/src/cynefin/element-view.ts +0 -32
  49. package/src/cynefin/toolbar/config.ts +0 -60
  50. package/src/effects.ts +0 -20
  51. package/src/estuarine/consts.ts +0 -69
  52. package/src/estuarine/element-renderer.ts +0 -122
  53. package/src/estuarine/element-view.ts +0 -32
  54. package/src/estuarine/toolbar/config.ts +0 -65
  55. package/src/index.ts +0 -1
  56. package/src/templates/index.ts +0 -130
  57. package/src/view.ts +0 -44
@@ -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/index.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -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
- }