orcasvn-react-diagrams 0.2.0 → 0.2.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 (133) hide show
  1. package/README.md +22 -1
  2. package/ai/api-contract.json +57 -5
  3. package/ai/invariants.json +5 -3
  4. package/ai/manifest.json +1 -1
  5. package/dist/cjs/examples.js +11775 -0
  6. package/dist/cjs/index.js +3889 -1112
  7. package/dist/cjs/types/api/createDiagramEditor.d.ts +7 -2
  8. package/dist/cjs/types/api/types.d.ts +178 -0
  9. package/dist/cjs/types/displaybox/demos/DeletionEventsDemoTab.d.ts +3 -0
  10. package/dist/cjs/types/displaybox/demos/ShapeHoverControlsDemoTab.d.ts +3 -0
  11. package/dist/cjs/types/displaybox/demos/TextLayoutDemoTab.d.ts +3 -0
  12. package/dist/cjs/types/displaybox/demos/deletionEventsDemo.d.ts +2 -0
  13. package/dist/cjs/types/displaybox/demos/rotatedCreationDemo.d.ts +2 -0
  14. package/dist/cjs/types/displaybox/demos/roundedRectRadiusDemo.d.ts +2 -0
  15. package/dist/cjs/types/displaybox/demos/shapeBorderMovementDemo.d.ts +2 -0
  16. package/dist/cjs/types/displaybox/demos/shapeHoverControlsDemo.d.ts +10 -0
  17. package/dist/cjs/types/displaybox/demos/textDemo.d.ts +4 -0
  18. package/dist/cjs/types/displaybox/useDemoEditor.d.ts +5 -2
  19. package/dist/cjs/types/engine/AutoLayoutService.d.ts +24 -0
  20. package/dist/cjs/types/engine/DiagramEngine.d.ts +32 -14
  21. package/dist/cjs/types/engine/EngineCommands.d.ts +4 -1
  22. package/dist/cjs/types/engine/LinkRoutingService.d.ts +35 -0
  23. package/dist/cjs/types/engine/MutationPipeline.d.ts +23 -0
  24. package/dist/cjs/types/engine/TextLayoutService.d.ts +40 -0
  25. package/dist/cjs/types/examples/index.d.ts +2 -0
  26. package/dist/cjs/types/measure/textStyleDefaults.d.ts +9 -0
  27. package/dist/cjs/types/models/DiagramModel.d.ts +1 -0
  28. package/dist/cjs/types/models/ElementModel.d.ts +1 -0
  29. package/dist/cjs/types/models/PortModel.d.ts +3 -0
  30. package/dist/cjs/types/models/TextModel.d.ts +8 -0
  31. package/dist/cjs/types/renderer/RenderTypes.d.ts +34 -1
  32. package/dist/cjs/types/renderer/konva/KonvaHitTester.d.ts +1 -1
  33. package/dist/cjs/types/renderer/konva/KonvaInteraction.d.ts +53 -3
  34. package/dist/cjs/types/renderer/konva/KonvaNodeFactory.d.ts +18 -1
  35. package/dist/cjs/types/renderer/konva/KonvaRenderer.d.ts +49 -2
  36. package/dist/cjs/types/shapes/BuiltInShapes.d.ts +107 -0
  37. package/dist/cjs/types/shapes/__tests__/BuiltInShapes.test.d.ts +1 -0
  38. package/dist/cjs/types/shapes/index.d.ts +1 -0
  39. package/dist/cjs/types/utils/__tests__/borderGeometry.test.d.ts +1 -0
  40. package/dist/cjs/types/utils/borderGeometry.d.ts +6 -0
  41. package/dist/cjs/types/utils/geometry.d.ts +22 -0
  42. package/dist/esm/examples.js +11767 -0
  43. package/dist/esm/examples.js.map +1 -0
  44. package/dist/esm/index.js +3890 -1113
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/types/api/createDiagramEditor.d.ts +7 -2
  47. package/dist/esm/types/api/types.d.ts +178 -0
  48. package/dist/esm/types/displaybox/demos/DeletionEventsDemoTab.d.ts +3 -0
  49. package/dist/esm/types/displaybox/demos/ShapeHoverControlsDemoTab.d.ts +3 -0
  50. package/dist/esm/types/displaybox/demos/TextLayoutDemoTab.d.ts +3 -0
  51. package/dist/esm/types/displaybox/demos/deletionEventsDemo.d.ts +2 -0
  52. package/dist/esm/types/displaybox/demos/rotatedCreationDemo.d.ts +2 -0
  53. package/dist/esm/types/displaybox/demos/roundedRectRadiusDemo.d.ts +2 -0
  54. package/dist/esm/types/displaybox/demos/shapeBorderMovementDemo.d.ts +2 -0
  55. package/dist/esm/types/displaybox/demos/shapeHoverControlsDemo.d.ts +10 -0
  56. package/dist/esm/types/displaybox/demos/textDemo.d.ts +4 -0
  57. package/dist/esm/types/displaybox/useDemoEditor.d.ts +5 -2
  58. package/dist/esm/types/engine/AutoLayoutService.d.ts +24 -0
  59. package/dist/esm/types/engine/DiagramEngine.d.ts +32 -14
  60. package/dist/esm/types/engine/EngineCommands.d.ts +4 -1
  61. package/dist/esm/types/engine/LinkRoutingService.d.ts +35 -0
  62. package/dist/esm/types/engine/MutationPipeline.d.ts +23 -0
  63. package/dist/esm/types/engine/TextLayoutService.d.ts +40 -0
  64. package/dist/esm/types/examples/index.d.ts +2 -0
  65. package/dist/esm/types/measure/textStyleDefaults.d.ts +9 -0
  66. package/dist/esm/types/models/DiagramModel.d.ts +1 -0
  67. package/dist/esm/types/models/ElementModel.d.ts +1 -0
  68. package/dist/esm/types/models/PortModel.d.ts +3 -0
  69. package/dist/esm/types/models/TextModel.d.ts +8 -0
  70. package/dist/esm/types/renderer/RenderTypes.d.ts +34 -1
  71. package/dist/esm/types/renderer/konva/KonvaHitTester.d.ts +1 -1
  72. package/dist/esm/types/renderer/konva/KonvaInteraction.d.ts +53 -3
  73. package/dist/esm/types/renderer/konva/KonvaNodeFactory.d.ts +18 -1
  74. package/dist/esm/types/renderer/konva/KonvaRenderer.d.ts +49 -2
  75. package/dist/esm/types/shapes/BuiltInShapes.d.ts +107 -0
  76. package/dist/esm/types/shapes/__tests__/BuiltInShapes.test.d.ts +1 -0
  77. package/dist/esm/types/shapes/index.d.ts +1 -0
  78. package/dist/esm/types/utils/__tests__/borderGeometry.test.d.ts +1 -0
  79. package/dist/esm/types/utils/borderGeometry.d.ts +6 -0
  80. package/dist/esm/types/utils/geometry.d.ts +22 -0
  81. package/dist/examples.d.ts +532 -0
  82. package/dist/index.d.ts +233 -2
  83. package/docs/API_CONTRACT.md +59 -3
  84. package/docs/ARCHITECTURE.md +1 -0
  85. package/docs/CAPABILITIES.md +3 -1
  86. package/docs/COMMANDS_EVENTS.md +5 -0
  87. package/docs/DOCUMENTATION_WORKFLOW.md +6 -8
  88. package/docs/INTEGRATION_PLAYBOOK.md +2 -0
  89. package/docs/PORTING_CHECKLIST.md +1 -0
  90. package/docs/STATE_INVARIANTS.md +4 -0
  91. package/package.json +20 -10
  92. package/src/displaybox/demos/AutoLayoutDemoTab.tsx +501 -0
  93. package/src/displaybox/demos/DeletionEventsDemoTab.tsx +147 -0
  94. package/src/displaybox/demos/EngineEventsDemoTab.tsx +151 -0
  95. package/src/displaybox/demos/EventHandlersDemoTab.tsx +110 -0
  96. package/src/displaybox/demos/ExternalDragDropDemoTab.tsx +261 -0
  97. package/src/displaybox/demos/LinkCancelDemoTab.tsx +238 -0
  98. package/src/displaybox/demos/ObstacleRoutingDemoTab.tsx +30 -0
  99. package/src/displaybox/demos/ShapeHoverControlsDemoTab.tsx +558 -0
  100. package/src/displaybox/demos/SimpleDemo.tsx +73 -0
  101. package/src/displaybox/demos/SvgPathDemoTab.tsx +327 -0
  102. package/src/displaybox/demos/TextLayoutDemoTab.tsx +386 -0
  103. package/src/displaybox/demos/autoLayoutDemo.ts +111 -0
  104. package/src/displaybox/demos/basicDemo.ts +131 -0
  105. package/src/displaybox/demos/childConstraintsDemo.ts +65 -0
  106. package/src/displaybox/demos/customDemo.ts +59 -0
  107. package/src/displaybox/demos/deletionEventsDemo.ts +91 -0
  108. package/src/displaybox/demos/engineEventsDemo.ts +64 -0
  109. package/src/displaybox/demos/eventHandlersDemo.ts +41 -0
  110. package/src/displaybox/demos/externalDragDropDemo.ts +28 -0
  111. package/src/displaybox/demos/gridOverlayDemo.ts +50 -0
  112. package/src/displaybox/demos/index.tsx +217 -0
  113. package/src/displaybox/demos/linkBendHandlesDemo.ts +143 -0
  114. package/src/displaybox/demos/linkCancelDemo.ts +56 -0
  115. package/src/displaybox/demos/linkPortCreationDemo.ts +46 -0
  116. package/src/displaybox/demos/multiLevelTreeDemo.ts +120 -0
  117. package/src/displaybox/demos/multipleElementsDemo.ts +62 -0
  118. package/src/displaybox/demos/nestedDemo.ts +78 -0
  119. package/src/displaybox/demos/obstacleRoutingDemo.ts +176 -0
  120. package/src/displaybox/demos/portBorderDemo.ts +98 -0
  121. package/src/displaybox/demos/portConstraintsDemo.ts +175 -0
  122. package/src/displaybox/demos/rotatedCreationDemo.ts +185 -0
  123. package/src/displaybox/demos/roundedRectRadiusDemo.ts +93 -0
  124. package/src/displaybox/demos/routingDemo.ts +57 -0
  125. package/src/displaybox/demos/selectionDemo.ts +49 -0
  126. package/src/displaybox/demos/shapeBorderMovementDemo.ts +126 -0
  127. package/src/displaybox/demos/shapeGalleryDemo.ts +73 -0
  128. package/src/displaybox/demos/shapeHoverControlsDemo.ts +172 -0
  129. package/src/displaybox/demos/shared.ts +161 -0
  130. package/src/displaybox/demos/svgPathDemo.ts +71 -0
  131. package/src/displaybox/demos/textDemo.ts +62 -0
  132. package/src/displaybox/types.ts +66 -0
  133. package/src/examples/index.ts +21 -0
@@ -0,0 +1,73 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { basePortShapes, customGalleryShapes } from './shared';
4
+
5
+ const createShapeGalleryState = (): DiagramState => ({
6
+ elements: [
7
+ {
8
+ id: 'shape-rect',
9
+ position: { x: 80, y: 80 },
10
+ size: { width: 170, height: 110 },
11
+ shapeId: 'rect-basic',
12
+ },
13
+ {
14
+ id: 'shape-circle',
15
+ position: { x: 310, y: 65 },
16
+ size: { width: 140, height: 140 },
17
+ shapeId: 'circle-basic',
18
+ },
19
+ {
20
+ id: 'shape-ellipse',
21
+ position: { x: 500, y: 95 },
22
+ size: { width: 210, height: 120 },
23
+ shapeId: 'ellipse-basic',
24
+ },
25
+ {
26
+ id: 'shape-diamond',
27
+ position: { x: 760, y: 80 },
28
+ size: { width: 150, height: 120 },
29
+ shapeId: 'diamond-basic',
30
+ },
31
+ {
32
+ id: 'shape-triangle',
33
+ position: { x: 90, y: 290 },
34
+ size: { width: 180, height: 130 },
35
+ shapeId: 'triangle-basic',
36
+ },
37
+ {
38
+ id: 'shape-pentagon',
39
+ position: { x: 360, y: 280 },
40
+ size: { width: 170, height: 150 },
41
+ shapeId: 'pentagon-basic',
42
+ },
43
+ {
44
+ id: 'shape-hexagon',
45
+ position: { x: 620, y: 290 },
46
+ size: { width: 200, height: 130 },
47
+ shapeId: 'hexagon-basic',
48
+ },
49
+ ],
50
+ ports: [],
51
+ links: [],
52
+ texts: [
53
+ { id: 'shape-rect-label', content: 'Rectangle', position: { x: 12, y: -12 }, ownerId: 'shape-rect' },
54
+ { id: 'shape-circle-label', content: 'Circle', position: { x: 12, y: -12 }, ownerId: 'shape-circle' },
55
+ { id: 'shape-ellipse-label', content: 'Ellipse / Oval', position: { x: 12, y: -12 }, ownerId: 'shape-ellipse' },
56
+ { id: 'shape-diamond-label', content: 'Diamond', position: { x: 12, y: -12 }, ownerId: 'shape-diamond' },
57
+ { id: 'shape-triangle-label', content: 'Triangle', position: { x: 12, y: -12 }, ownerId: 'shape-triangle' },
58
+ { id: 'shape-pentagon-label', content: 'Pentagon', position: { x: 12, y: -12 }, ownerId: 'shape-pentagon' },
59
+ { id: 'shape-hexagon-label', content: 'Hexagon', position: { x: 12, y: -12 }, ownerId: 'shape-hexagon' },
60
+ ],
61
+ });
62
+
63
+ export const shapeGalleryDemoConfig: DemoConfig = ({
64
+ id: 'shape-gallery',
65
+ title: 'Custom Shapes Gallery',
66
+ description: 'Compare circle vs ellipse plus baseline and polygonal shapes (rect, diamond, triangle, pentagon, hexagon).',
67
+ createState: createShapeGalleryState,
68
+ elementShapes: customGalleryShapes,
69
+ portShapes: basePortShapes,
70
+ defaultElementShapeId: 'rect-basic',
71
+ defaultPortShapeId: 'port-circle',
72
+ actions: [],
73
+ });
@@ -0,0 +1,172 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes } from './shared';
4
+
5
+ export const shapeHoverDemoIds = {
6
+ drawer: 'hover-drawer',
7
+ diamond: 'hover-diamond',
8
+ target: 'hover-target-rect',
9
+ ellipse: 'hover-ellipse-host',
10
+ circle: 'hover-circle-host',
11
+ noopRect: 'hover-noop-rect',
12
+ } as const;
13
+
14
+ const elementShapes = [
15
+ ...baseElementShapes,
16
+ {
17
+ id: 'hover-diamond-shape',
18
+ kind: 'diamond' as const,
19
+ style: {
20
+ fill: '#f8ecff',
21
+ stroke: '#6b3fa0',
22
+ strokeWidth: 2,
23
+ },
24
+ },
25
+ {
26
+ id: 'hover-ellipse-shape',
27
+ kind: 'ellipse' as const,
28
+ style: {
29
+ fill: '#edf8ff',
30
+ stroke: '#2b6f99',
31
+ strokeWidth: 2,
32
+ },
33
+ },
34
+ {
35
+ id: 'hover-circle-shape',
36
+ kind: 'circle' as const,
37
+ style: {
38
+ fill: '#ecfdf5',
39
+ stroke: '#0f766e',
40
+ strokeWidth: 2,
41
+ },
42
+ },
43
+ ];
44
+
45
+ const createShapeHoverControlsState = (): DiagramState => ({
46
+ elements: [
47
+ {
48
+ id: shapeHoverDemoIds.drawer,
49
+ position: { x: 80, y: 100 },
50
+ size: { width: 380, height: 230 },
51
+ shapeId: 'panel',
52
+ },
53
+ {
54
+ id: 'hover-drawer-child-a',
55
+ parentId: shapeHoverDemoIds.drawer,
56
+ position: { x: 32, y: 64 },
57
+ size: { width: 130, height: 70 },
58
+ shapeId: 'default',
59
+ },
60
+ {
61
+ id: 'hover-drawer-child-b',
62
+ parentId: shapeHoverDemoIds.drawer,
63
+ position: { x: 212, y: 64 },
64
+ size: { width: 130, height: 70 },
65
+ shapeId: 'default',
66
+ },
67
+ {
68
+ id: shapeHoverDemoIds.diamond,
69
+ position: { x: 560, y: 120 },
70
+ size: { width: 170, height: 130 },
71
+ shapeId: 'hover-diamond-shape',
72
+ },
73
+ {
74
+ id: shapeHoverDemoIds.target,
75
+ position: { x: 820, y: 140 },
76
+ size: { width: 220, height: 140 },
77
+ shapeId: 'default',
78
+ },
79
+ {
80
+ id: shapeHoverDemoIds.ellipse,
81
+ position: { x: 540, y: 350 },
82
+ size: { width: 240, height: 120 },
83
+ shapeId: 'hover-ellipse-shape',
84
+ },
85
+ {
86
+ id: shapeHoverDemoIds.circle,
87
+ position: { x: 830, y: 340 },
88
+ size: { width: 140, height: 140 },
89
+ shapeId: 'hover-circle-shape',
90
+ },
91
+ {
92
+ id: shapeHoverDemoIds.noopRect,
93
+ position: { x: 1010, y: 360 },
94
+ size: { width: 180, height: 110 },
95
+ shapeId: 'default',
96
+ },
97
+ ],
98
+ ports: [],
99
+ links: [],
100
+ texts: [
101
+ {
102
+ id: 'hover-drawer-label',
103
+ content: 'Drawer (hover bottom edge control to add child)',
104
+ ownerId: shapeHoverDemoIds.drawer,
105
+ position: { x: 14, y: 14 },
106
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
107
+ },
108
+ {
109
+ id: 'hover-diamond-label',
110
+ content: 'Diamond vertex control creates link',
111
+ ownerId: shapeHoverDemoIds.diamond,
112
+ position: { x: 8, y: -16 },
113
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
114
+ },
115
+ {
116
+ id: 'hover-target-label',
117
+ content: 'Rectangle target',
118
+ ownerId: shapeHoverDemoIds.target,
119
+ position: { x: 12, y: -14 },
120
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
121
+ },
122
+ {
123
+ id: 'hover-ellipse-label',
124
+ content: 'Ellipse enum targets: top/right/bottom/left',
125
+ ownerId: shapeHoverDemoIds.ellipse,
126
+ position: { x: 12, y: -14 },
127
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
128
+ },
129
+ {
130
+ id: 'hover-circle-label',
131
+ content: 'Circle enum targets',
132
+ ownerId: shapeHoverDemoIds.circle,
133
+ position: { x: 10, y: -14 },
134
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
135
+ },
136
+ {
137
+ id: 'hover-noop-rect-label',
138
+ content: 'Rectangle no-op for ellipse-midpoint',
139
+ ownerId: shapeHoverDemoIds.noopRect,
140
+ position: { x: 10, y: -14 },
141
+ style: { fontSize: 13, fontFamily: 'sans-serif' },
142
+ },
143
+ ],
144
+ });
145
+
146
+ export const shapeHoverControlsDemoConfig: DemoConfig = {
147
+ id: 'shape-hover-controls',
148
+ title: 'Shape Hover Controls',
149
+ description:
150
+ 'Host-configured edge/midpoint/vertex plus ellipse-midpoint controls with trigger modes, selectors, click actions, and drag event logging.',
151
+ createState: createShapeHoverControlsState,
152
+ elementShapes,
153
+ portShapes: basePortShapes,
154
+ defaultElementShapeId: 'default',
155
+ defaultPortShapeId: 'port-circle',
156
+ actions: [
157
+ {
158
+ id: 'focus-drawer',
159
+ label: 'Focus drawer',
160
+ run: (editor) => {
161
+ editor.setSelection([shapeHoverDemoIds.drawer]);
162
+ },
163
+ },
164
+ {
165
+ id: 'focus-diamond',
166
+ label: 'Focus diamond',
167
+ run: (editor) => {
168
+ editor.setSelection([shapeHoverDemoIds.diamond]);
169
+ },
170
+ },
171
+ ],
172
+ };
@@ -0,0 +1,161 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { SimpleShape } from '../../api';
3
+ import type { ToolboxItem } from '../types';
4
+ import type { RouterStrategy } from '../../strategies/RouterStrategy';
5
+
6
+ export const baseElementShapes: SimpleShape[] = [
7
+ {
8
+ id: 'default',
9
+ kind: 'rect',
10
+ style: {
11
+ cornerRadius: 8,
12
+ fill: '#e6f2ff',
13
+ stroke: '#1f4d99',
14
+ strokeWidth: 2,
15
+ },
16
+ },
17
+ {
18
+ id: 'panel',
19
+ kind: 'rect',
20
+ style: {
21
+ cornerRadius: 14,
22
+ fill: '#fff4dd',
23
+ stroke: '#a26722',
24
+ strokeWidth: 2,
25
+ },
26
+ },
27
+ ];
28
+
29
+ export const basePortShapes: SimpleShape[] = [
30
+ {
31
+ id: 'port-circle',
32
+ kind: 'circle',
33
+ style: {
34
+ radius: 6,
35
+ fill: '#ffffff',
36
+ stroke: '#1f4d99',
37
+ strokeWidth: 2,
38
+ name: 'port',
39
+ },
40
+ },
41
+ {
42
+ id: 'port-dark',
43
+ kind: 'circle',
44
+ style: {
45
+ radius: 5,
46
+ fill: '#1f4d99',
47
+ stroke: '#1f4d99',
48
+ strokeWidth: 1,
49
+ name: 'port',
50
+ },
51
+ },
52
+ ];
53
+
54
+ export const customGalleryShapes: SimpleShape[] = [
55
+ {
56
+ id: 'rect-basic',
57
+ kind: 'rect',
58
+ style: {
59
+ cornerRadius: 8,
60
+ fill: '#e6f2ff',
61
+ stroke: '#1f4d99',
62
+ strokeWidth: 2,
63
+ },
64
+ },
65
+ {
66
+ id: 'circle-basic',
67
+ kind: 'circle',
68
+ style: {
69
+ fill: '#eaf7e6',
70
+ stroke: '#2f7a3d',
71
+ strokeWidth: 2,
72
+ },
73
+ },
74
+ {
75
+ id: 'ellipse-basic',
76
+ kind: 'ellipse',
77
+ style: {
78
+ fill: '#e8f8ff',
79
+ stroke: '#1e6b8f',
80
+ strokeWidth: 2,
81
+ },
82
+ },
83
+ {
84
+ id: 'diamond-basic',
85
+ kind: 'diamond',
86
+ style: {
87
+ fill: '#fff0f3',
88
+ stroke: '#c0392b',
89
+ strokeWidth: 2,
90
+ },
91
+ },
92
+ {
93
+ id: 'triangle-basic',
94
+ kind: 'triangle',
95
+ style: {
96
+ fill: '#f3f1ff',
97
+ stroke: '#5b3cc4',
98
+ strokeWidth: 2,
99
+ },
100
+ },
101
+ {
102
+ id: 'pentagon-basic',
103
+ kind: 'pentagon',
104
+ style: {
105
+ fill: '#fef5e7',
106
+ stroke: '#b86d1f',
107
+ strokeWidth: 2,
108
+ },
109
+ },
110
+ {
111
+ id: 'hexagon-basic',
112
+ kind: 'hexagon',
113
+ style: {
114
+ fill: '#eefbe9',
115
+ stroke: '#3f7b2c',
116
+ strokeWidth: 2,
117
+ },
118
+ },
119
+ ];
120
+
121
+ export const externalToolboxItems: ToolboxItem[] = [
122
+ {
123
+ id: 'toolbox-default',
124
+ label: 'Standard Node',
125
+ shapeId: 'default',
126
+ size: { width: 180, height: 120 },
127
+ },
128
+ {
129
+ id: 'toolbox-panel',
130
+ label: 'Panel Node',
131
+ shapeId: 'panel',
132
+ size: { width: 220, height: 140 },
133
+ },
134
+ ];
135
+
136
+ export const defaultGhostSize = { width: 180, height: 120 };
137
+
138
+ export const defaultSvgPath = 'M10 10 H110 V90 H10 Z';
139
+ export const defaultSvgPathSize = { width: 180, height: 120 };
140
+
141
+ export const orthogonalRouter: RouterStrategy = {
142
+ route: (source, target) => {
143
+ if (Math.abs(source.x - target.x) < 1 || Math.abs(source.y - target.y) < 1) {
144
+ return [{ ...source }, { ...target }];
145
+ }
146
+ const midX = Math.round((source.x + target.x) / 2);
147
+ return [
148
+ { ...source },
149
+ { x: midX, y: source.y },
150
+ { x: midX, y: target.y },
151
+ { ...target },
152
+ ];
153
+ },
154
+ };
155
+
156
+ export const gridStageStyle: CSSProperties = {
157
+ backgroundColor: '#f8f8f8',
158
+ backgroundImage:
159
+ 'linear-gradient(0deg, rgba(0,0,0,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px)',
160
+ backgroundSize: '20px 20px',
161
+ };
@@ -0,0 +1,71 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes } from './shared';
4
+
5
+ const createSvgPathDemoState = (): DiagramState => ({
6
+ elements: [
7
+ {
8
+ id: 'svg-host',
9
+ position: { x: 260, y: 190 },
10
+ size: { width: 320, height: 220 },
11
+ shapeId: 'default',
12
+ },
13
+ {
14
+ id: 'svg-peer',
15
+ position: { x: 680, y: 230 },
16
+ size: { width: 220, height: 140 },
17
+ shapeId: 'panel',
18
+ },
19
+ ],
20
+ ports: [
21
+ {
22
+ id: 'svg-host-port',
23
+ elementId: 'svg-host',
24
+ position: { x: 0, y: 110 },
25
+ shapeId: 'port-circle',
26
+ moveMode: 'border',
27
+ anchorCenter: true,
28
+ },
29
+ {
30
+ id: 'svg-peer-port',
31
+ elementId: 'svg-peer',
32
+ position: { x: 0, y: 70 },
33
+ shapeId: 'port-dark',
34
+ moveMode: 'border',
35
+ anchorCenter: true,
36
+ },
37
+ ],
38
+ links: [],
39
+ texts: [
40
+ {
41
+ id: 'svg-path-tip',
42
+ content: 'Use presets (crow-foot, optional, mandatory) to insert relationship glyph ports quickly.',
43
+ position: { x: 120, y: 100 },
44
+ },
45
+ {
46
+ id: 'svg-host-label',
47
+ content: 'SVG Port Host',
48
+ position: { x: 12, y: -14 },
49
+ ownerId: 'svg-host',
50
+ },
51
+ {
52
+ id: 'svg-peer-label',
53
+ content: 'Link Target Host',
54
+ position: { x: 12, y: -14 },
55
+ ownerId: 'svg-peer',
56
+ },
57
+ ],
58
+ });
59
+
60
+ export const svgPathDemoConfig: DemoConfig = ({
61
+ id: 'svg-path',
62
+ title: 'SVG Glyph Ports',
63
+ description:
64
+ 'Paste custom paths or use uncommon ERD-style presets (including crow-foot) with manual or border-normal orientation.',
65
+ createState: createSvgPathDemoState,
66
+ elementShapes: baseElementShapes,
67
+ portShapes: basePortShapes,
68
+ defaultElementShapeId: 'default',
69
+ defaultPortShapeId: 'port-circle',
70
+ actions: [],
71
+ });
@@ -0,0 +1,62 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes } from './shared';
4
+
5
+ export const textDemoOwnerId = 'text-layout-owner';
6
+ export const textDemoOwnedTextId = 'text-owned-overflow';
7
+ export const textDemoFloatingTextId = 'text-floating-overflow';
8
+ export const textDemoLongSample =
9
+ 'Long diagram label: middle ellipsis should keep the beginning and end visible while preserving the full canonical content in model state.';
10
+
11
+ const createTextOwnershipState = (): DiagramState => ({
12
+ elements: [
13
+ {
14
+ id: textDemoOwnerId,
15
+ position: { x: 160, y: 170 },
16
+ size: { width: 260, height: 140 },
17
+ shapeId: 'default',
18
+ },
19
+ ],
20
+ ports: [],
21
+ links: [],
22
+ texts: [
23
+ {
24
+ id: textDemoOwnedTextId,
25
+ content: textDemoLongSample,
26
+ position: { x: 12, y: 12 },
27
+ ownerId: textDemoOwnerId,
28
+ layout: {
29
+ boundsMode: 'owner-width',
30
+ wrap: 'none',
31
+ overflow: 'ellipsis-middle',
32
+ padding: 12,
33
+ },
34
+ },
35
+ {
36
+ id: textDemoFloatingTextId,
37
+ content: textDemoLongSample,
38
+ position: { x: 470, y: 120 },
39
+ layout: {
40
+ boundsMode: 'fixed',
41
+ fixedSize: { width: 240, height: 90 },
42
+ wrap: 'word',
43
+ overflow: 'ellipsis-end',
44
+ padding: 8,
45
+ maxLines: 3,
46
+ },
47
+ },
48
+ ],
49
+ });
50
+
51
+ export const textDemoConfig: DemoConfig = ({
52
+ id: 'text',
53
+ title: 'Text Layout + Overflow',
54
+ description:
55
+ 'Owner-constrained and fixed-bounds text with wrap and ellipsis behavior. Full content is preserved in model state; truncation is visual-only.',
56
+ createState: createTextOwnershipState,
57
+ elementShapes: baseElementShapes,
58
+ portShapes: basePortShapes,
59
+ defaultElementShapeId: 'default',
60
+ defaultPortShapeId: 'port-circle',
61
+ actions: [],
62
+ });
@@ -0,0 +1,66 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { DiagramEditorHandle, DiagramState, SimpleShape } from '../api';
3
+ import type { RouterStrategy } from '../strategies/RouterStrategy';
4
+
5
+ export type DemoActionHelpers = {
6
+ nextOffset: () => number;
7
+ };
8
+
9
+ export type DemoAction = {
10
+ id: string;
11
+ label: string;
12
+ run: (
13
+ editor: DiagramEditorHandle,
14
+ state: DiagramState,
15
+ demo: DemoConfig,
16
+ helpers: DemoActionHelpers
17
+ ) => void;
18
+ };
19
+
20
+ export type DemoConfig = {
21
+ id: string;
22
+ title: string;
23
+ description: string;
24
+ createState: () => DiagramState;
25
+ elementShapes?: SimpleShape[];
26
+ portShapes?: SimpleShape[];
27
+ defaultElementShapeId?: string;
28
+ defaultPortShapeId?: string;
29
+ router?: RouterStrategy;
30
+ snapDefault?: boolean;
31
+ stageStyle?: CSSProperties;
32
+ actions: DemoAction[];
33
+ };
34
+
35
+ export type DemoDefinition = {
36
+ id: string;
37
+ title: string;
38
+ description: string;
39
+ Component: React.ComponentType;
40
+ };
41
+
42
+ export type ToolboxItem = {
43
+ id: string;
44
+ label: string;
45
+ shapeId: string;
46
+ size: { width: number; height: number };
47
+ };
48
+
49
+ export type DiagramCounts = {
50
+ elements: number;
51
+ ports: number;
52
+ links: number;
53
+ texts: number;
54
+ };
55
+
56
+ export type ViewportSnapshot = {
57
+ pan: { x: number; y: number };
58
+ zoom: number;
59
+ };
60
+
61
+ export type DisplayBoxMetrics = {
62
+ selection: string[];
63
+ counts: DiagramCounts;
64
+ viewport: ViewportSnapshot;
65
+ snapEnabled: boolean;
66
+ };
@@ -0,0 +1,21 @@
1
+ export {
2
+ demoTabs,
3
+ baseElementShapes,
4
+ basePortShapes,
5
+ customGalleryShapes,
6
+ defaultGhostSize,
7
+ defaultSvgPath,
8
+ defaultSvgPathSize,
9
+ externalToolboxItems,
10
+ } from '../displaybox/demos';
11
+
12
+ export type {
13
+ DemoAction,
14
+ DemoActionHelpers,
15
+ DemoConfig,
16
+ DemoDefinition,
17
+ ToolboxItem,
18
+ DiagramCounts,
19
+ ViewportSnapshot,
20
+ DisplayBoxMetrics,
21
+ } from '../displaybox/types';