orcasvn-react-diagrams 0.2.6 → 0.2.7
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/CHANGELOG.md +18 -0
- package/README.md +12 -15
- package/ai/api-contract.json +7 -0
- package/ai/manifest.json +1 -1
- package/dist/cjs/examples.js +509 -245
- package/dist/cjs/index.js +79 -53
- package/dist/cjs/types/api/types.d.ts +4 -0
- package/dist/cjs/types/displaybox/demos/autoLayoutDemo.d.ts +2 -0
- package/dist/cjs/types/engine/DiagramEngine.d.ts +2 -0
- package/dist/cjs/types/models/ElementModel.d.ts +1 -0
- package/dist/cjs/types/renderer/konva/KonvaInteraction.d.ts +1 -2
- package/dist/esm/examples.js +509 -245
- package/dist/esm/examples.js.map +1 -1
- package/dist/esm/index.js +79 -53
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api/types.d.ts +4 -0
- package/dist/esm/types/displaybox/demos/autoLayoutDemo.d.ts +2 -0
- package/dist/esm/types/engine/DiagramEngine.d.ts +2 -0
- package/dist/esm/types/models/ElementModel.d.ts +1 -0
- package/dist/esm/types/renderer/konva/KonvaInteraction.d.ts +1 -2
- package/dist/examples.d.ts +4 -0
- package/dist/index.d.ts +6 -1
- package/docs/API_CONTRACT.md +13 -2
- package/docs/CAPABILITIES.md +1 -0
- package/docs/COMMANDS_EVENTS.md +1 -0
- package/docs/DOCUMENTATION_WORKFLOW.md +2 -1
- package/docs/INTEGRATION_PLAYBOOK.md +1 -0
- package/package.json +1 -1
- package/src/displaybox/demos/AutoLayoutDemoTab.tsx +96 -18
- package/src/displaybox/demos/autoLayoutDemo.ts +150 -31
- package/src/displaybox/demos/nestedDemo.ts +122 -69
|
@@ -3,75 +3,128 @@ import { createId } from '../../utils/ids';
|
|
|
3
3
|
import type { DemoConfig } from '../types';
|
|
4
4
|
import { baseElementShapes, basePortShapes } from './shared';
|
|
5
5
|
|
|
6
|
-
const createNestedState = (): DiagramState => ({
|
|
7
|
-
elements: [
|
|
8
|
-
{
|
|
9
|
-
id: 'parent-
|
|
10
|
-
position: { x:
|
|
11
|
-
size: { width:
|
|
12
|
-
shapeId: 'panel',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: '
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
6
|
+
const createNestedState = (): DiagramState => ({
|
|
7
|
+
elements: [
|
|
8
|
+
{
|
|
9
|
+
id: 'parent-locked',
|
|
10
|
+
position: { x: 110, y: 140 },
|
|
11
|
+
size: { width: 300, height: 240 },
|
|
12
|
+
shapeId: 'panel',
|
|
13
|
+
childElementInteraction: { movable: false },
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 'child-locked',
|
|
17
|
+
position: { x: 40, y: 60 },
|
|
18
|
+
size: { width: 160, height: 100 },
|
|
19
|
+
shapeId: 'default',
|
|
20
|
+
parentId: 'parent-locked',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'parent-free',
|
|
24
|
+
position: { x: 470, y: 140 },
|
|
25
|
+
size: { width: 300, height: 240 },
|
|
26
|
+
shapeId: 'panel',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: 'child-free',
|
|
30
|
+
position: { x: 40, y: 60 },
|
|
31
|
+
size: { width: 160, height: 100 },
|
|
32
|
+
shapeId: 'default',
|
|
33
|
+
parentId: 'parent-free',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
ports: [
|
|
37
|
+
{
|
|
38
|
+
id: 'child-port-locked',
|
|
39
|
+
elementId: 'child-locked',
|
|
40
|
+
position: { x: 20, y: 20 },
|
|
41
|
+
shapeId: 'port-circle',
|
|
42
|
+
anchorCenter: true,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'child-port-free',
|
|
46
|
+
elementId: 'child-free',
|
|
47
|
+
position: { x: 20, y: 20 },
|
|
48
|
+
shapeId: 'port-circle',
|
|
49
|
+
anchorCenter: true,
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
links: [],
|
|
53
|
+
texts: [
|
|
54
|
+
{
|
|
55
|
+
id: 'parent-locked-label',
|
|
56
|
+
content: 'Locked child drag',
|
|
57
|
+
position: { x: 12, y: 12 },
|
|
58
|
+
ownerId: 'parent-locked',
|
|
59
|
+
interaction: { movable: false, editable: false },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'child-locked-label',
|
|
63
|
+
content: 'Drag disabled',
|
|
64
|
+
position: { x: 10, y: 10 },
|
|
65
|
+
ownerId: 'child-locked',
|
|
66
|
+
interaction: { movable: false, editable: false },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'parent-free-label',
|
|
70
|
+
content: 'Movable child drag',
|
|
71
|
+
position: { x: 12, y: 12 },
|
|
72
|
+
ownerId: 'parent-free',
|
|
73
|
+
interaction: { movable: false, editable: false },
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 'child-free-label',
|
|
77
|
+
content: 'Drag enabled',
|
|
78
|
+
position: { x: 10, y: 10 },
|
|
79
|
+
ownerId: 'child-free',
|
|
80
|
+
interaction: { movable: false, editable: false },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export const nestedDemoConfig: DemoConfig = ({
|
|
86
|
+
id: 'nested',
|
|
87
|
+
title: 'Nested Elements',
|
|
88
|
+
description: 'Compare locked and movable child drag; locked children still move through API actions.',
|
|
89
|
+
createState: createNestedState,
|
|
90
|
+
elementShapes: baseElementShapes,
|
|
91
|
+
portShapes: basePortShapes,
|
|
92
|
+
defaultElementShapeId: 'default',
|
|
93
|
+
defaultPortShapeId: 'port-circle',
|
|
94
|
+
actions: [
|
|
95
|
+
{
|
|
96
|
+
id: 'move-locked-child-api',
|
|
97
|
+
label: 'Move locked child (API)',
|
|
98
|
+
run: (editor, state) => {
|
|
99
|
+
const child = state.elements.find((element) => element.id === 'child-locked');
|
|
100
|
+
const parent = state.elements.find((element) => element.id === 'parent-locked');
|
|
101
|
+
if (!child || !parent) return;
|
|
102
|
+
editor.moveElementTo(child.id, parent.position.x + child.position.x + 30, parent.position.y + child.position.y + 10);
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'move-parent',
|
|
107
|
+
label: 'Move locked parent',
|
|
108
|
+
run: (editor, state) => {
|
|
109
|
+
const parent = state.elements.find((element) => element.id === 'parent-locked');
|
|
110
|
+
if (!parent) return;
|
|
111
|
+
editor.moveElementTo(parent.id, parent.position.x + 40, parent.position.y + 20);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: 'add-child',
|
|
116
|
+
label: 'Add movable child',
|
|
117
|
+
run: (editor, state, demo, helpers) => {
|
|
118
|
+
const parent = state.elements.find((element) => element.id === 'parent-free');
|
|
119
|
+
if (!parent) return;
|
|
120
|
+
const offset = helpers.nextOffset();
|
|
121
|
+
editor.addElement({
|
|
122
|
+
id: `child-free-${createId()}`,
|
|
123
|
+
position: { x: 30 + offset, y: 50 + offset },
|
|
124
|
+
size: { width: 140, height: 90 },
|
|
125
|
+
shapeId: demo.defaultElementShapeId ?? 'default',
|
|
126
|
+
parentId: parent.id,
|
|
127
|
+
});
|
|
75
128
|
},
|
|
76
129
|
},
|
|
77
130
|
],
|