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,175 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes } from './shared';
4
+
5
+ const createPortConstraintState = (): DiagramState => ({
6
+ elements: [
7
+ {
8
+ id: 'anchor-rect-host',
9
+ position: { x: 80, y: 120 },
10
+ size: { width: 220, height: 150 },
11
+ shapeId: 'anchor-rect',
12
+ portMovement: { moveMode: 'anchors', anchorConstraint: { preset: 'vertices' } },
13
+ },
14
+ {
15
+ id: 'anchor-triangle-host',
16
+ position: { x: 380, y: 100 },
17
+ size: { width: 220, height: 170 },
18
+ shapeId: 'anchor-triangle',
19
+ portMovement: { moveMode: 'anchors', anchorConstraint: { preset: 'vertices' } },
20
+ },
21
+ {
22
+ id: 'anchor-ellipse-host',
23
+ position: { x: 700, y: 120 },
24
+ size: { width: 220, height: 150 },
25
+ shapeId: 'anchor-ellipse',
26
+ portMovement: { moveMode: 'anchors', anchorConstraint: { preset: 'cardinal' } },
27
+ },
28
+ {
29
+ id: 'anchor-peer-rect',
30
+ position: { x: 120, y: 390 },
31
+ size: { width: 180, height: 100 },
32
+ shapeId: 'panel',
33
+ },
34
+ {
35
+ id: 'anchor-peer-triangle',
36
+ position: { x: 420, y: 390 },
37
+ size: { width: 180, height: 100 },
38
+ shapeId: 'panel',
39
+ },
40
+ {
41
+ id: 'anchor-peer-ellipse',
42
+ position: { x: 740, y: 390 },
43
+ size: { width: 180, height: 100 },
44
+ shapeId: 'panel',
45
+ },
46
+ ],
47
+ ports: [
48
+ {
49
+ id: 'anchor-rect-port',
50
+ elementId: 'anchor-rect-host',
51
+ position: { x: 220, y: 0 },
52
+ shapeId: 'port-circle',
53
+ anchorCenter: true,
54
+ currentAnchorId: 'top-right',
55
+ },
56
+ {
57
+ id: 'anchor-triangle-port',
58
+ elementId: 'anchor-triangle-host',
59
+ position: { x: 205.2628, y: 127.5 },
60
+ shapeId: 'port-circle',
61
+ anchorCenter: true,
62
+ currentAnchorId: 'v1',
63
+ },
64
+ {
65
+ id: 'anchor-ellipse-port',
66
+ elementId: 'anchor-ellipse-host',
67
+ position: { x: 220, y: 75 },
68
+ shapeId: 'port-circle',
69
+ anchorCenter: true,
70
+ currentAnchorId: 'right',
71
+ },
72
+ {
73
+ id: 'anchor-peer-rect-port',
74
+ elementId: 'anchor-peer-rect',
75
+ position: { x: 0, y: 50 },
76
+ shapeId: 'port-dark',
77
+ moveMode: 'border',
78
+ anchorCenter: true,
79
+ },
80
+ {
81
+ id: 'anchor-peer-triangle-port',
82
+ elementId: 'anchor-peer-triangle',
83
+ position: { x: 0, y: 50 },
84
+ shapeId: 'port-dark',
85
+ moveMode: 'border',
86
+ anchorCenter: true,
87
+ },
88
+ {
89
+ id: 'anchor-peer-ellipse-port',
90
+ elementId: 'anchor-peer-ellipse',
91
+ position: { x: 0, y: 50 },
92
+ shapeId: 'port-dark',
93
+ moveMode: 'border',
94
+ anchorCenter: true,
95
+ },
96
+ ],
97
+ links: [
98
+ { id: 'anchor-link-rect', sourcePortId: 'anchor-rect-port', targetPortId: 'anchor-peer-rect-port', points: [] },
99
+ { id: 'anchor-link-triangle', sourcePortId: 'anchor-triangle-port', targetPortId: 'anchor-peer-triangle-port', points: [] },
100
+ { id: 'anchor-link-ellipse', sourcePortId: 'anchor-ellipse-port', targetPortId: 'anchor-peer-ellipse-port', points: [] },
101
+ ],
102
+ texts: [
103
+ {
104
+ id: 'anchor-instructions',
105
+ content: 'Specific points only: drag highlighted ports. Rect + triangle snap to vertices; ellipse snaps to top/right/bottom/left.',
106
+ position: { x: 80, y: 44 },
107
+ },
108
+ { id: 'anchor-rect-label', content: 'Rectangle: corners only', position: { x: 8, y: -20 }, ownerId: 'anchor-rect-host' },
109
+ { id: 'anchor-triangle-label', content: 'Triangle: peaks only', position: { x: 8, y: -20 }, ownerId: 'anchor-triangle-host' },
110
+ { id: 'anchor-ellipse-label', content: 'Ellipse: cardinal anchors', position: { x: 8, y: -20 }, ownerId: 'anchor-ellipse-host' },
111
+ { id: 'anchor-port-rect-label', content: 'Snap me', position: { x: 8, y: -18 }, ownerId: 'anchor-rect-port' },
112
+ { id: 'anchor-port-triangle-label', content: 'Snap me', position: { x: 8, y: -18 }, ownerId: 'anchor-triangle-port' },
113
+ { id: 'anchor-port-ellipse-label', content: 'Snap me', position: { x: 8, y: -18 }, ownerId: 'anchor-ellipse-port' },
114
+ ],
115
+ });
116
+
117
+ export const portConstraintsDemoConfig: DemoConfig = ({
118
+ id: 'port-constraints',
119
+ title: 'Port Discrete Anchors',
120
+ description: 'Element-level anchor policy: rectangle/polygon vertices and ellipse cardinal points only.',
121
+ createState: createPortConstraintState,
122
+ elementShapes: [
123
+ ...baseElementShapes,
124
+ {
125
+ id: 'anchor-rect',
126
+ kind: 'rect',
127
+ style: {
128
+ cornerRadius: 10,
129
+ fill: '#e6f2ff',
130
+ stroke: '#1f4d99',
131
+ strokeWidth: 2,
132
+ },
133
+ },
134
+ {
135
+ id: 'anchor-triangle',
136
+ kind: 'triangle',
137
+ style: {
138
+ fill: '#f4f1ff',
139
+ stroke: '#5b3cc4',
140
+ strokeWidth: 2,
141
+ },
142
+ },
143
+ {
144
+ id: 'anchor-ellipse',
145
+ kind: 'ellipse',
146
+ style: {
147
+ fill: '#e8f8ff',
148
+ stroke: '#1e6b8f',
149
+ strokeWidth: 2,
150
+ },
151
+ },
152
+ ],
153
+ portShapes: basePortShapes,
154
+ defaultElementShapeId: 'default',
155
+ defaultPortShapeId: 'port-circle',
156
+ actions: [
157
+ {
158
+ id: 'resize-anchor-hosts',
159
+ label: 'Resize hosts (anchor persistence)',
160
+ run: (editor, state) => {
161
+ const rectHost = state.elements.find((element) => element.id === 'anchor-rect-host');
162
+ const expanded = (rectHost?.size.width ?? 0) > 220;
163
+ if (expanded) {
164
+ editor.resizeElement('anchor-rect-host', 220, 150);
165
+ editor.resizeElement('anchor-triangle-host', 220, 170);
166
+ editor.resizeElement('anchor-ellipse-host', 220, 150);
167
+ return;
168
+ }
169
+ editor.resizeElement('anchor-rect-host', 280, 190);
170
+ editor.resizeElement('anchor-triangle-host', 280, 210);
171
+ editor.resizeElement('anchor-ellipse-host', 280, 190);
172
+ },
173
+ },
174
+ ],
175
+ });
@@ -0,0 +1,185 @@
1
+ import type { DiagramState, SimpleShape } from '../../api';
2
+ import { createId } from '../../utils/ids';
3
+ import type { DemoConfig } from '../types';
4
+ import { basePortShapes } from './shared';
5
+
6
+ const baseRectRotation = 18;
7
+ const baseEllipseRotation = 14;
8
+ const baseDiamondRotation = -20;
9
+
10
+ const rotatedCreationShapes: SimpleShape[] = [
11
+ {
12
+ id: 'rot-rect-base',
13
+ kind: 'rect',
14
+ style: {
15
+ cornerRadius: 12,
16
+ fill: '#e9f5ff',
17
+ stroke: '#1e5f97',
18
+ strokeWidth: 2,
19
+ rotation: baseRectRotation,
20
+ },
21
+ },
22
+ {
23
+ id: 'rot-ellipse-base',
24
+ kind: 'ellipse',
25
+ style: {
26
+ fill: '#eefbe9',
27
+ stroke: '#2f7a3d',
28
+ strokeWidth: 2,
29
+ rotation: baseEllipseRotation,
30
+ },
31
+ },
32
+ {
33
+ id: 'rot-diamond-base',
34
+ kind: 'diamond',
35
+ style: {
36
+ fill: '#fff3e3',
37
+ stroke: '#a35e14',
38
+ strokeWidth: 2,
39
+ rotation: baseDiamondRotation,
40
+ },
41
+ },
42
+ ];
43
+
44
+ const createRotatedCreationState = (): DiagramState => ({
45
+ elements: [
46
+ {
47
+ id: 'rot-seed-rect',
48
+ position: { x: 180, y: 120 },
49
+ size: { width: 180, height: 110 },
50
+ shapeId: 'rot-rect-base',
51
+ style: { rotation: 20 },
52
+ },
53
+ {
54
+ id: 'rot-seed-ellipse',
55
+ position: { x: 360, y: 120 },
56
+ size: { width: 190, height: 110 },
57
+ shapeId: 'rot-ellipse-base',
58
+ style: { rotation: -16 },
59
+ },
60
+ {
61
+ id: 'rot-seed-diamond',
62
+ position: { x: 620, y: 120 },
63
+ size: { width: 170, height: 120 },
64
+ shapeId: 'rot-diamond-base',
65
+ style: { rotation: -12 },
66
+ },
67
+ ],
68
+ ports: [],
69
+ links: [],
70
+ texts: [
71
+ {
72
+ id: 'rot-seed-rect-label',
73
+ content: 'Seed rect: base 18 + instance 20',
74
+ ownerId: 'rot-seed-rect',
75
+ position: { x: 10, y: -14 },
76
+ },
77
+ {
78
+ id: 'rot-seed-ellipse-label',
79
+ content: 'Seed ellipse: base 14 + instance -16',
80
+ ownerId: 'rot-seed-ellipse',
81
+ position: { x: 10, y: -14 },
82
+ },
83
+ {
84
+ id: 'rot-seed-diamond-label',
85
+ content: 'Seed diamond: base -20 + instance -12',
86
+ ownerId: 'rot-seed-diamond',
87
+ position: { x: 10, y: -14 },
88
+ },
89
+ {
90
+ id: 'rot-demo-tip',
91
+ content: 'Verify alignment: select each rotated seed shape, drag-resize it, then reselect to confirm handle persistence.',
92
+ position: { x: 120, y: 70 },
93
+ },
94
+ ],
95
+ });
96
+
97
+ export const rotatedCreationDemoConfig: DemoConfig = {
98
+ id: 'rotated-shape-creation',
99
+ title: 'Rotated Shape Creation',
100
+ description: 'Validate class-based rotated rectangle/ellipse/polygon shapes and selection-resize alignment persistence.',
101
+ createState: createRotatedCreationState,
102
+ elementShapes: rotatedCreationShapes,
103
+ portShapes: basePortShapes,
104
+ defaultElementShapeId: 'rot-rect-base',
105
+ defaultPortShapeId: 'port-circle',
106
+ actions: [
107
+ {
108
+ id: 'add-rotated-rect',
109
+ label: 'Create rotated rect',
110
+ run: (editor, _state, _demo, helpers) => {
111
+ const offset = helpers.nextOffset();
112
+ const id = `rot-rect-${createId()}`;
113
+ editor.addElement({
114
+ id,
115
+ position: { x: 160 + offset, y: 280 + offset },
116
+ size: { width: 180, height: 110 },
117
+ shapeId: 'rot-rect-base',
118
+ style: { rotation: 24 },
119
+ });
120
+ editor.addText({
121
+ id: `rot-label-${createId()}`,
122
+ content: 'base 18 + instance 24',
123
+ ownerId: id,
124
+ position: { x: 10, y: -14 },
125
+ });
126
+ editor.setSelection([id]);
127
+ },
128
+ },
129
+ {
130
+ id: 'add-rotated-diamond',
131
+ label: 'Create rotated diamond',
132
+ run: (editor, _state, _demo, helpers) => {
133
+ const offset = helpers.nextOffset();
134
+ const id = `rot-diamond-${createId()}`;
135
+ editor.addElement({
136
+ id,
137
+ position: { x: 460 + offset, y: 300 + offset },
138
+ size: { width: 170, height: 120 },
139
+ shapeId: 'rot-diamond-base',
140
+ style: { rotation: -18 },
141
+ });
142
+ editor.addText({
143
+ id: `rot-label-${createId()}`,
144
+ content: 'base -20 + instance -18',
145
+ ownerId: id,
146
+ position: { x: 10, y: -14 },
147
+ });
148
+ editor.setSelection([id]);
149
+ },
150
+ },
151
+ {
152
+ id: 'focus-rotated-rect',
153
+ label: 'Focus rotated rect',
154
+ run: (editor) => {
155
+ editor.setSelection(['rot-seed-rect']);
156
+ },
157
+ },
158
+ {
159
+ id: 'focus-rotated-ellipse',
160
+ label: 'Focus rotated ellipse',
161
+ run: (editor) => {
162
+ editor.setSelection(['rot-seed-ellipse']);
163
+ },
164
+ },
165
+ {
166
+ id: 'focus-rotated-diamond',
167
+ label: 'Focus rotated diamond',
168
+ run: (editor) => {
169
+ editor.setSelection(['rot-seed-diamond']);
170
+ },
171
+ },
172
+ {
173
+ id: 'verify-rotated-resize-persistence',
174
+ label: 'Verify rotated resize persistence',
175
+ run: (editor) => {
176
+ editor.setSelection(['rot-seed-rect']);
177
+ editor.resizeElement('rot-seed-rect', 210, 130);
178
+ editor.setSelection(['rot-seed-ellipse']);
179
+ editor.resizeElement('rot-seed-ellipse', 220, 130);
180
+ editor.setSelection(['rot-seed-diamond']);
181
+ editor.resizeElement('rot-seed-diamond', 190, 140);
182
+ },
183
+ },
184
+ ],
185
+ };
@@ -0,0 +1,93 @@
1
+ import type { DiagramState, SimpleShape } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { basePortShapes } from './shared';
4
+
5
+ const roundedRectShapes: SimpleShape[] = [
6
+ {
7
+ id: 'rounded-rect-r0',
8
+ kind: 'rect',
9
+ style: { cornerRadius: 0, fill: '#eef5ff', stroke: '#2c5aa0', strokeWidth: 2 },
10
+ },
11
+ {
12
+ id: 'rounded-rect-r10',
13
+ kind: 'rect',
14
+ style: { cornerRadius: 10, fill: '#edf9f1', stroke: '#2b7a45', strokeWidth: 2 },
15
+ },
16
+ {
17
+ id: 'rounded-rect-r24',
18
+ kind: 'rect',
19
+ style: { cornerRadius: 24, fill: '#fff5e8', stroke: '#9c5b17', strokeWidth: 2 },
20
+ },
21
+ {
22
+ id: 'rounded-rect-r42',
23
+ kind: 'rect',
24
+ style: { cornerRadius: 42, fill: '#fff0f2', stroke: '#a03e50', strokeWidth: 2 },
25
+ },
26
+ ];
27
+
28
+ const baseSizes: Record<string, { width: number; height: number }> = {
29
+ 'rounded-rect-0': { width: 180, height: 100 },
30
+ 'rounded-rect-10': { width: 180, height: 100 },
31
+ 'rounded-rect-24': { width: 180, height: 100 },
32
+ 'rounded-rect-42': { width: 180, height: 100 },
33
+ };
34
+
35
+ const wideSizes: Record<string, { width: number; height: number }> = {
36
+ 'rounded-rect-0': { width: 240, height: 120 },
37
+ 'rounded-rect-10': { width: 240, height: 120 },
38
+ 'rounded-rect-24': { width: 240, height: 120 },
39
+ 'rounded-rect-42': { width: 240, height: 120 },
40
+ };
41
+
42
+ const createRoundedRectRadiusState = (): DiagramState => ({
43
+ elements: [
44
+ { id: 'rounded-rect-0', position: { x: 80, y: 140 }, size: { width: 180, height: 100 }, shapeId: 'rounded-rect-r0' },
45
+ { id: 'rounded-rect-10', position: { x: 320, y: 140 }, size: { width: 180, height: 100 }, shapeId: 'rounded-rect-r10' },
46
+ { id: 'rounded-rect-24', position: { x: 560, y: 140 }, size: { width: 180, height: 100 }, shapeId: 'rounded-rect-r24' },
47
+ { id: 'rounded-rect-42', position: { x: 800, y: 140 }, size: { width: 180, height: 100 }, shapeId: 'rounded-rect-r42' },
48
+ ],
49
+ ports: [
50
+ { id: 'rounded-port-0', elementId: 'rounded-rect-0', position: { x: 180, y: 50 }, moveMode: 'border', anchorCenter: true },
51
+ { id: 'rounded-port-10', elementId: 'rounded-rect-10', position: { x: 180, y: 50 }, moveMode: 'border', anchorCenter: true },
52
+ { id: 'rounded-port-24', elementId: 'rounded-rect-24', position: { x: 180, y: 50 }, moveMode: 'border', anchorCenter: true },
53
+ { id: 'rounded-port-42', elementId: 'rounded-rect-42', position: { x: 180, y: 50 }, moveMode: 'border', anchorCenter: true },
54
+ ],
55
+ links: [
56
+ { id: 'rounded-link-1', sourcePortId: 'rounded-port-0', targetPortId: 'rounded-port-10', points: [] },
57
+ { id: 'rounded-link-2', sourcePortId: 'rounded-port-10', targetPortId: 'rounded-port-24', points: [] },
58
+ { id: 'rounded-link-3', sourcePortId: 'rounded-port-24', targetPortId: 'rounded-port-42', points: [] },
59
+ ],
60
+ texts: [
61
+ { id: 'rounded-label-0', content: 'radius 0', position: { x: 10, y: -14 }, ownerId: 'rounded-rect-0' },
62
+ { id: 'rounded-label-10', content: 'radius 10', position: { x: 10, y: -14 }, ownerId: 'rounded-rect-10' },
63
+ { id: 'rounded-label-24', content: 'radius 24', position: { x: 10, y: -14 }, ownerId: 'rounded-rect-24' },
64
+ { id: 'rounded-label-42', content: 'radius 42', position: { x: 10, y: -14 }, ownerId: 'rounded-rect-42' },
65
+ ],
66
+ });
67
+
68
+ export const roundedRectRadiusDemoConfig: DemoConfig = {
69
+ id: 'rounded-rect-radius',
70
+ title: 'Rounded Rect Radius',
71
+ description: 'Compare rectangle corner radii and verify border ports stay attached while resizing variants.',
72
+ createState: createRoundedRectRadiusState,
73
+ elementShapes: roundedRectShapes,
74
+ portShapes: basePortShapes,
75
+ defaultElementShapeId: 'rounded-rect-r10',
76
+ defaultPortShapeId: 'port-circle',
77
+ actions: [
78
+ {
79
+ id: 'expand-rounded-rects',
80
+ label: 'Expand all',
81
+ run: (editor) => {
82
+ Object.entries(wideSizes).forEach(([elementId, size]) => editor.resizeElement(elementId, size.width, size.height));
83
+ },
84
+ },
85
+ {
86
+ id: 'reset-rounded-rects',
87
+ label: 'Reset sizes',
88
+ run: (editor) => {
89
+ Object.entries(baseSizes).forEach(([elementId, size]) => editor.resizeElement(elementId, size.width, size.height));
90
+ },
91
+ },
92
+ ],
93
+ };
@@ -0,0 +1,57 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes, orthogonalRouter } from './shared';
4
+
5
+ const createRoutingDemoState = (): DiagramState => ({
6
+ elements: [
7
+ {
8
+ id: 'route-source',
9
+ position: { x: 120, y: 160 },
10
+ size: { width: 200, height: 120 },
11
+ shapeId: 'default',
12
+ },
13
+ {
14
+ id: 'route-target',
15
+ position: { x: 560, y: 220 },
16
+ size: { width: 200, height: 120 },
17
+ shapeId: 'panel',
18
+ },
19
+ {
20
+ id: 'route-obstacle',
21
+ position: { x: 360, y: 320 },
22
+ size: { width: 180, height: 100 },
23
+ shapeId: 'default',
24
+ },
25
+ ],
26
+ ports: [
27
+ { id: 'route-source-port', elementId: 'route-source', position: { x: 40, y: 50 }, shapeId: 'port-circle', anchorCenter: true },
28
+ { id: 'route-target-port', elementId: 'route-target', position: { x: 50, y: 40 }, shapeId: 'port-circle', anchorCenter: true },
29
+ ],
30
+ links: [
31
+ {
32
+ id: 'route-link',
33
+ sourcePortId: 'route-source-port',
34
+ targetPortId: 'route-target-port',
35
+ points: [],
36
+ routing: 'auto',
37
+ },
38
+ ],
39
+ texts: [
40
+ { id: 'route-source-label', content: 'Source', position: { x: 12, y: -12 }, ownerId: 'route-source' },
41
+ { id: 'route-target-label', content: 'Target', position: { x: 12, y: -12 }, ownerId: 'route-target' },
42
+ { id: 'route-obstacle-label', content: 'Obstacle', position: { x: 12, y: -12 }, ownerId: 'route-obstacle' },
43
+ ],
44
+ });
45
+
46
+ export const routingDemoConfig: DemoConfig = ({
47
+ id: 'routing-demo',
48
+ title: 'Routing Demo',
49
+ description: 'Auto routing uses an orthogonal router. Toggle routing to compare.',
50
+ createState: createRoutingDemoState,
51
+ elementShapes: baseElementShapes,
52
+ portShapes: basePortShapes,
53
+ defaultElementShapeId: 'default',
54
+ defaultPortShapeId: 'port-circle',
55
+ router: orthogonalRouter,
56
+ actions: [],
57
+ });
@@ -0,0 +1,49 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { baseElementShapes, basePortShapes } from './shared';
4
+
5
+ const createSelectionState = (): DiagramState => ({
6
+ elements: [
7
+ {
8
+ id: 'select-1',
9
+ position: { x: 140, y: 140 },
10
+ size: { width: 180, height: 120 },
11
+ shapeId: 'default',
12
+ },
13
+ {
14
+ id: 'select-2',
15
+ position: { x: 380, y: 220 },
16
+ size: { width: 180, height: 120 },
17
+ shapeId: 'default',
18
+ },
19
+ ],
20
+ ports: [],
21
+ links: [],
22
+ texts: [
23
+ {
24
+ id: 'select-tip',
25
+ content: 'Click to select, drag to move, Delete/Backspace to remove.',
26
+ position: { x: 80, y: 80 },
27
+ },
28
+ ],
29
+ });
30
+
31
+ export const selectionDemoConfig: DemoConfig = ({
32
+ id: 'selection',
33
+ title: 'Selection + Interaction',
34
+ description: 'Click to select, drag to move, marquee-select on empty space, delete to remove.',
35
+ createState: createSelectionState,
36
+ elementShapes: baseElementShapes,
37
+ portShapes: basePortShapes,
38
+ defaultElementShapeId: 'default',
39
+ defaultPortShapeId: 'port-circle',
40
+ actions: [
41
+ {
42
+ id: 'select-all',
43
+ label: 'Select all elements',
44
+ run: (editor, state) => {
45
+ editor.setSelection(state.elements.map((element) => element.id));
46
+ },
47
+ },
48
+ ],
49
+ });
@@ -0,0 +1,126 @@
1
+ import type { DiagramState } from '../../api';
2
+ import type { DemoConfig } from '../types';
3
+ import { basePortShapes, customGalleryShapes } from './shared';
4
+
5
+ const resizeBaseSizes: Record<string, { width: number; height: number }> = {
6
+ 'shape-border-rect': { width: 170, height: 120 },
7
+ 'shape-border-circle': { width: 170, height: 170 },
8
+ 'shape-border-ellipse': { width: 240, height: 130 },
9
+ 'shape-border-hexagon': { width: 200, height: 130 },
10
+ };
11
+
12
+ const resizeExpandedSizes: Record<string, { width: number; height: number }> = {
13
+ 'shape-border-rect': { width: 250, height: 150 },
14
+ 'shape-border-circle': { width: 210, height: 210 },
15
+ 'shape-border-ellipse': { width: 300, height: 170 },
16
+ 'shape-border-hexagon': { width: 260, height: 170 },
17
+ };
18
+
19
+ const createShapeBorderMovementState = (): DiagramState => ({
20
+ elements: [
21
+ {
22
+ id: 'shape-border-rect',
23
+ position: { x: 60, y: 110 },
24
+ size: { width: 170, height: 120 },
25
+ shapeId: 'rect-basic',
26
+ },
27
+ {
28
+ id: 'shape-border-circle',
29
+ position: { x: 280, y: 100 },
30
+ size: { width: 170, height: 170 },
31
+ shapeId: 'circle-basic',
32
+ },
33
+ {
34
+ id: 'shape-border-ellipse',
35
+ position: { x: 500, y: 120 },
36
+ size: { width: 240, height: 130 },
37
+ shapeId: 'ellipse-basic',
38
+ },
39
+ {
40
+ id: 'shape-border-hexagon',
41
+ position: { x: 790, y: 120 },
42
+ size: { width: 200, height: 130 },
43
+ shapeId: 'hexagon-basic',
44
+ },
45
+ ],
46
+ ports: [
47
+ {
48
+ id: 'shape-border-port-rect',
49
+ elementId: 'shape-border-rect',
50
+ position: { x: 85, y: 0 },
51
+ shapeId: 'port-circle',
52
+ moveMode: 'border',
53
+ anchorCenter: true,
54
+ },
55
+ {
56
+ id: 'shape-border-port-circle',
57
+ elementId: 'shape-border-circle',
58
+ position: { x: 85, y: 0 },
59
+ shapeId: 'port-circle',
60
+ moveMode: 'border',
61
+ anchorCenter: true,
62
+ },
63
+ {
64
+ id: 'shape-border-port-ellipse',
65
+ elementId: 'shape-border-ellipse',
66
+ position: { x: 120, y: 0 },
67
+ shapeId: 'port-circle',
68
+ moveMode: 'border',
69
+ anchorCenter: true,
70
+ },
71
+ {
72
+ id: 'shape-border-port-hexagon',
73
+ elementId: 'shape-border-hexagon',
74
+ position: { x: 100, y: 0 },
75
+ shapeId: 'port-circle',
76
+ moveMode: 'border',
77
+ anchorCenter: true,
78
+ },
79
+ ],
80
+ links: [
81
+ { id: 'shape-border-link-1', sourcePortId: 'shape-border-port-rect', targetPortId: 'shape-border-port-circle', points: [] },
82
+ { id: 'shape-border-link-2', sourcePortId: 'shape-border-port-circle', targetPortId: 'shape-border-port-ellipse', points: [] },
83
+ { id: 'shape-border-link-3', sourcePortId: 'shape-border-port-ellipse', targetPortId: 'shape-border-port-hexagon', points: [] },
84
+ ],
85
+ texts: [
86
+ { id: 'shape-border-rect-label', content: 'Rect (baseline)', position: { x: 8, y: -14 }, ownerId: 'shape-border-rect' },
87
+ { id: 'shape-border-circle-label', content: 'Circle', position: { x: 8, y: -14 }, ownerId: 'shape-border-circle' },
88
+ { id: 'shape-border-ellipse-label', content: 'Ellipse / Oval', position: { x: 8, y: -14 }, ownerId: 'shape-border-ellipse' },
89
+ { id: 'shape-border-hexagon-label', content: 'Hexagon', position: { x: 8, y: -14 }, ownerId: 'shape-border-hexagon' },
90
+ { id: 'shape-border-port-rect-label', content: 'Drag', position: { x: 8, y: -16 }, ownerId: 'shape-border-port-rect' },
91
+ { id: 'shape-border-port-circle-label', content: 'Drag', position: { x: 8, y: -16 }, ownerId: 'shape-border-port-circle' },
92
+ { id: 'shape-border-port-ellipse-label', content: 'Drag', position: { x: 8, y: -16 }, ownerId: 'shape-border-port-ellipse' },
93
+ { id: 'shape-border-port-hexagon-label', content: 'Drag', position: { x: 8, y: -16 }, ownerId: 'shape-border-port-hexagon' },
94
+ ],
95
+ });
96
+
97
+ export const shapeBorderMovementDemoConfig: DemoConfig = {
98
+ id: 'shape-border-movement',
99
+ title: 'Shape Border Port Movement',
100
+ description: 'Resize hosts (manual handles or quick actions) to verify border ports stay attached and connected links track them.',
101
+ createState: createShapeBorderMovementState,
102
+ elementShapes: customGalleryShapes,
103
+ portShapes: basePortShapes,
104
+ defaultElementShapeId: 'rect-basic',
105
+ defaultPortShapeId: 'port-circle',
106
+ actions: [
107
+ {
108
+ id: 'expand-hosts',
109
+ label: 'Expand hosts',
110
+ run: (editor) => {
111
+ Object.entries(resizeExpandedSizes).forEach(([elementId, size]) => {
112
+ editor.resizeElement(elementId, size.width, size.height);
113
+ });
114
+ },
115
+ },
116
+ {
117
+ id: 'reset-host-sizes',
118
+ label: 'Reset host sizes',
119
+ run: (editor) => {
120
+ Object.entries(resizeBaseSizes).forEach(([elementId, size]) => {
121
+ editor.resizeElement(elementId, size.width, size.height);
122
+ });
123
+ },
124
+ },
125
+ ],
126
+ };