@cratis/components 0.1.17 → 0.1.19
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/README.md +83 -0
- package/dist/cjs/Common/ErrorBoundary.js +26 -0
- package/dist/cjs/Common/ErrorBoundary.js.map +1 -0
- package/dist/cjs/Common/FormElement.js +10 -0
- package/dist/cjs/Common/FormElement.js.map +1 -0
- package/dist/cjs/Common/index.js +12 -0
- package/dist/cjs/Common/index.js.map +1 -0
- package/dist/cjs/EventModeling/EventModeling.css +146 -0
- package/dist/cjs/EventModeling/EventModeling.js +209 -0
- package/dist/cjs/EventModeling/EventModeling.js.map +1 -0
- package/dist/cjs/EventModeling/components/Canvas.js +403 -0
- package/dist/cjs/EventModeling/components/Canvas.js.map +1 -0
- package/dist/cjs/EventModeling/components/CanvasControls.js +10 -0
- package/dist/cjs/EventModeling/components/CanvasControls.js.map +1 -0
- package/dist/cjs/EventModeling/components/Toolbox.js +18 -0
- package/dist/cjs/EventModeling/components/Toolbox.js.map +1 -0
- package/dist/cjs/EventModeling/engine/connectorGraphics.js +173 -0
- package/dist/cjs/EventModeling/engine/connectorGraphics.js.map +1 -0
- package/dist/cjs/EventModeling/engine/elementSprites.js +301 -0
- package/dist/cjs/EventModeling/engine/elementSprites.js.map +1 -0
- package/dist/cjs/EventModeling/index.js +12 -0
- package/dist/cjs/EventModeling/index.js.map +1 -0
- package/dist/cjs/EventModeling/types.js +60 -0
- package/dist/cjs/EventModeling/types.js.map +1 -0
- package/dist/cjs/PivotViewer/PivotViewer.css +54 -5
- package/dist/cjs/PivotViewer/PivotViewer.js +5 -2
- package/dist/cjs/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/cjs/PivotViewer/components/AxisLabels.js +5 -8
- package/dist/cjs/PivotViewer/components/AxisLabels.js.map +1 -1
- package/dist/cjs/PivotViewer/components/DetailPanel.js +9 -2
- package/dist/cjs/PivotViewer/components/DetailPanel.js.map +1 -1
- package/dist/cjs/PivotViewer/components/PivotCanvas.js +30 -6
- package/dist/cjs/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/cjs/PivotViewer/components/PivotViewerMain.js +16 -5
- package/dist/cjs/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/cjs/PivotViewer/components/Toolbar.js +34 -2
- package/dist/cjs/PivotViewer/components/Toolbar.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/constants.js +5 -5
- package/dist/cjs/PivotViewer/components/pivot/constants.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/groups.js +15 -15
- package/dist/cjs/PivotViewer/components/pivot/groups.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/sprites.js +10 -27
- package/dist/cjs/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/visibility.js +8 -20
- package/dist/cjs/PivotViewer/components/pivot/visibility.js.map +1 -1
- package/dist/cjs/PivotViewer/constants.js +0 -2
- package/dist/cjs/PivotViewer/constants.js.map +1 -1
- package/dist/cjs/PivotViewer/engine/layout.js +1 -1
- package/dist/cjs/PivotViewer/engine/layout.js.map +1 -1
- package/dist/cjs/PivotViewer/hooks/useCardSelection.js +2 -1
- package/dist/cjs/PivotViewer/hooks/useCardSelection.js.map +1 -1
- package/dist/cjs/PivotViewer/hooks/useZoomState.js +4 -0
- package/dist/cjs/PivotViewer/hooks/useZoomState.js.map +1 -1
- package/dist/cjs/PivotViewer/types.js.map +1 -1
- package/dist/cjs/PivotViewer/utils/animations.js +1 -1
- package/dist/cjs/PivotViewer/utils/animations.js.map +1 -1
- package/dist/cjs/PivotViewer/utils/constants.js +1 -1
- package/dist/cjs/PivotViewer/utils/constants.js.map +1 -1
- package/dist/cjs/PivotViewer/utils/selection.js +8 -1
- package/dist/cjs/PivotViewer/utils/selection.js.map +1 -1
- package/dist/cjs/TimeMachine/TimeMachine.js +0 -3
- package/dist/cjs/TimeMachine/TimeMachine.js.map +1 -1
- package/dist/cjs/index.js +16 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/esm/Common/ErrorBoundary.js +7 -4
- package/dist/esm/Common/ErrorBoundary.js.map +1 -1
- package/dist/esm/Common/FormElement.js +7 -4
- package/dist/esm/Common/FormElement.js.map +1 -1
- package/dist/esm/Common/index.js +4 -4
- package/dist/esm/Common/index.js.map +1 -1
- package/dist/esm/EventModeling/EventModeling.css +146 -0
- package/dist/esm/EventModeling/EventModeling.d.ts +11 -0
- package/dist/esm/EventModeling/EventModeling.d.ts.map +1 -0
- package/dist/esm/EventModeling/EventModeling.js +207 -0
- package/dist/esm/EventModeling/EventModeling.js.map +1 -0
- package/dist/esm/EventModeling/EventModeling.stories.d.ts +10 -0
- package/dist/esm/EventModeling/EventModeling.stories.d.ts.map +1 -0
- package/dist/esm/EventModeling/EventModeling.stories.js +252 -0
- package/dist/esm/EventModeling/EventModeling.stories.js.map +1 -0
- package/dist/esm/EventModeling/components/Canvas.d.ts +23 -0
- package/dist/esm/EventModeling/components/Canvas.d.ts.map +1 -0
- package/dist/esm/EventModeling/components/Canvas.js +382 -0
- package/dist/esm/EventModeling/components/Canvas.js.map +1 -0
- package/dist/esm/EventModeling/components/CanvasControls.d.ts +10 -0
- package/dist/esm/EventModeling/components/CanvasControls.d.ts.map +1 -0
- package/dist/esm/EventModeling/components/CanvasControls.js +8 -0
- package/dist/esm/EventModeling/components/CanvasControls.js.map +1 -0
- package/dist/esm/EventModeling/components/Toolbox.d.ts +9 -0
- package/dist/esm/EventModeling/components/Toolbox.d.ts.map +1 -0
- package/dist/esm/EventModeling/components/Toolbox.js +16 -0
- package/dist/esm/EventModeling/components/Toolbox.js.map +1 -0
- package/dist/esm/EventModeling/engine/connectorGraphics.d.ts +12 -0
- package/dist/esm/EventModeling/engine/connectorGraphics.d.ts.map +1 -0
- package/dist/esm/EventModeling/engine/connectorGraphics.js +151 -0
- package/dist/esm/EventModeling/engine/connectorGraphics.js.map +1 -0
- package/dist/esm/EventModeling/engine/elementSprites.d.ts +23 -0
- package/dist/esm/EventModeling/engine/elementSprites.d.ts.map +1 -0
- package/dist/esm/EventModeling/engine/elementSprites.js +276 -0
- package/dist/esm/EventModeling/engine/elementSprites.js.map +1 -0
- package/dist/esm/EventModeling/index.d.ts +3 -0
- package/dist/esm/EventModeling/index.d.ts.map +1 -0
- package/dist/esm/EventModeling/index.js +3 -0
- package/dist/esm/EventModeling/index.js.map +1 -0
- package/dist/esm/EventModeling/types.d.ts +79 -0
- package/dist/esm/EventModeling/types.d.ts.map +1 -0
- package/dist/esm/EventModeling/types.js +56 -0
- package/dist/esm/EventModeling/types.js.map +1 -0
- package/dist/esm/PivotViewer/PivotViewer.css +54 -5
- package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +5 -2
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.stories.d.ts +0 -1
- package/dist/esm/PivotViewer/PivotViewer.stories.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.stories.js +10 -9
- package/dist/esm/PivotViewer/PivotViewer.stories.js.map +1 -1
- package/dist/esm/PivotViewer/components/AxisLabels.d.ts +2 -1
- package/dist/esm/PivotViewer/components/AxisLabels.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/AxisLabels.js +6 -9
- package/dist/esm/PivotViewer/components/AxisLabels.js.map +1 -1
- package/dist/esm/PivotViewer/components/DetailPanel.d.ts +3 -1
- package/dist/esm/PivotViewer/components/DetailPanel.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/DetailPanel.js +10 -3
- package/dist/esm/PivotViewer/components/DetailPanel.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotCanvas.d.ts +5 -2
- package/dist/esm/PivotViewer/components/PivotCanvas.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/PivotCanvas.js +30 -6
- package/dist/esm/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.d.ts +5 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.js +16 -5
- package/dist/esm/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/esm/PivotViewer/components/Toolbar.d.ts +3 -1
- package/dist/esm/PivotViewer/components/Toolbar.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/Toolbar.js +34 -2
- package/dist/esm/PivotViewer/components/Toolbar.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/constants.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/constants.js +5 -5
- package/dist/esm/PivotViewer/components/pivot/constants.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/groups.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/groups.js +2 -2
- package/dist/esm/PivotViewer/components/pivot/groups.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.d.ts +10 -2
- package/dist/esm/PivotViewer/components/pivot/sprites.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.js +10 -27
- package/dist/esm/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/visibility.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/visibility.js +8 -20
- package/dist/esm/PivotViewer/components/pivot/visibility.js.map +1 -1
- package/dist/esm/PivotViewer/constants.js +1 -2
- package/dist/esm/PivotViewer/constants.js.map +1 -1
- package/dist/esm/PivotViewer/engine/layout.js +1 -1
- package/dist/esm/PivotViewer/engine/layout.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/useCardSelection.d.ts.map +1 -1
- package/dist/esm/PivotViewer/hooks/useCardSelection.js +2 -1
- package/dist/esm/PivotViewer/hooks/useCardSelection.js.map +1 -1
- package/dist/esm/PivotViewer/hooks/useZoomState.d.ts +1 -0
- package/dist/esm/PivotViewer/hooks/useZoomState.d.ts.map +1 -1
- package/dist/esm/PivotViewer/hooks/useZoomState.js +4 -0
- package/dist/esm/PivotViewer/hooks/useZoomState.js.map +1 -1
- package/dist/esm/PivotViewer/types.d.ts +5 -1
- package/dist/esm/PivotViewer/types.d.ts.map +1 -1
- package/dist/esm/PivotViewer/types.js.map +1 -1
- package/dist/esm/PivotViewer/utils/animations.js +1 -1
- package/dist/esm/PivotViewer/utils/animations.js.map +1 -1
- package/dist/esm/PivotViewer/utils/constants.d.ts +1 -1
- package/dist/esm/PivotViewer/utils/constants.d.ts.map +1 -1
- package/dist/esm/PivotViewer/utils/constants.js +1 -1
- package/dist/esm/PivotViewer/utils/constants.js.map +1 -1
- package/dist/esm/PivotViewer/utils/selection.d.ts.map +1 -1
- package/dist/esm/PivotViewer/utils/selection.js +8 -1
- package/dist/esm/PivotViewer/utils/selection.js.map +1 -1
- package/dist/esm/TimeMachine/TimeMachine.js +1 -1
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +16 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +3 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -78
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PIXI = require('pixi.js');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
|
|
23
|
+
|
|
24
|
+
const CONNECTOR_COLOR = 0x64748b;
|
|
25
|
+
const CONNECTOR_HOVER_COLOR = 0x3b82f6;
|
|
26
|
+
const CONNECTOR_WIDTH = 2;
|
|
27
|
+
const CONNECTOR_HOVER_WIDTH = 3;
|
|
28
|
+
function createConnectorGraphics(connector, getElements, onClick) {
|
|
29
|
+
const graphics = new PIXI__namespace.Graphics();
|
|
30
|
+
graphics.eventMode = 'static';
|
|
31
|
+
graphics.cursor = 'pointer';
|
|
32
|
+
graphics.hitArea = new PIXI__namespace.Rectangle(0, 0, 0, 0);
|
|
33
|
+
const connectorGraphics = {
|
|
34
|
+
id: connector.id,
|
|
35
|
+
graphics,
|
|
36
|
+
connector,
|
|
37
|
+
getElements,
|
|
38
|
+
isHovered: false,
|
|
39
|
+
};
|
|
40
|
+
drawConnector(graphics, connector, getElements(), false);
|
|
41
|
+
graphics.on('click', () => {
|
|
42
|
+
onClick(connector.id);
|
|
43
|
+
});
|
|
44
|
+
graphics.on('pointerover', () => {
|
|
45
|
+
connectorGraphics.isHovered = true;
|
|
46
|
+
drawConnector(graphics, connector, connectorGraphics.getElements(), true);
|
|
47
|
+
});
|
|
48
|
+
graphics.on('pointerout', () => {
|
|
49
|
+
connectorGraphics.isHovered = false;
|
|
50
|
+
drawConnector(graphics, connector, connectorGraphics.getElements(), false);
|
|
51
|
+
});
|
|
52
|
+
return connectorGraphics;
|
|
53
|
+
}
|
|
54
|
+
function drawConnector(graphics, connector, elements, isHovered) {
|
|
55
|
+
const fromElement = elements.get(connector.from.elementId);
|
|
56
|
+
const toElement = elements.get(connector.to.elementId);
|
|
57
|
+
if (!fromElement || !toElement) {
|
|
58
|
+
graphics.clear();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const fromPoint = getEdgePosition(fromElement, connector.from.side);
|
|
62
|
+
const toPoint = getEdgePosition(toElement, connector.to.side);
|
|
63
|
+
graphics.clear();
|
|
64
|
+
const controlPointOffset = Math.abs(toPoint.x - fromPoint.x) / 3;
|
|
65
|
+
let cp1x, cp1y, cp2x, cp2y;
|
|
66
|
+
if (connector.from.side === 'right' && connector.to.side === 'left') {
|
|
67
|
+
cp1x = fromPoint.x + controlPointOffset;
|
|
68
|
+
cp1y = fromPoint.y;
|
|
69
|
+
cp2x = toPoint.x - controlPointOffset;
|
|
70
|
+
cp2y = toPoint.y;
|
|
71
|
+
}
|
|
72
|
+
else if (connector.from.side === 'bottom' && connector.to.side === 'top') {
|
|
73
|
+
cp1x = fromPoint.x;
|
|
74
|
+
cp1y = fromPoint.y + controlPointOffset;
|
|
75
|
+
cp2x = toPoint.x;
|
|
76
|
+
cp2y = toPoint.y - controlPointOffset;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
switch (connector.from.side) {
|
|
80
|
+
case 'right':
|
|
81
|
+
cp1x = fromPoint.x + controlPointOffset;
|
|
82
|
+
cp1y = fromPoint.y;
|
|
83
|
+
break;
|
|
84
|
+
case 'left':
|
|
85
|
+
cp1x = fromPoint.x - controlPointOffset;
|
|
86
|
+
cp1y = fromPoint.y;
|
|
87
|
+
break;
|
|
88
|
+
case 'bottom':
|
|
89
|
+
cp1x = fromPoint.x;
|
|
90
|
+
cp1y = fromPoint.y + controlPointOffset;
|
|
91
|
+
break;
|
|
92
|
+
case 'top':
|
|
93
|
+
default:
|
|
94
|
+
cp1x = fromPoint.x;
|
|
95
|
+
cp1y = fromPoint.y - controlPointOffset;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
switch (connector.to.side) {
|
|
99
|
+
case 'left':
|
|
100
|
+
cp2x = toPoint.x - controlPointOffset;
|
|
101
|
+
cp2y = toPoint.y;
|
|
102
|
+
break;
|
|
103
|
+
case 'right':
|
|
104
|
+
cp2x = toPoint.x + controlPointOffset;
|
|
105
|
+
cp2y = toPoint.y;
|
|
106
|
+
break;
|
|
107
|
+
case 'top':
|
|
108
|
+
cp2x = toPoint.x;
|
|
109
|
+
cp2y = toPoint.y - controlPointOffset;
|
|
110
|
+
break;
|
|
111
|
+
case 'bottom':
|
|
112
|
+
default:
|
|
113
|
+
cp2x = toPoint.x;
|
|
114
|
+
cp2y = toPoint.y + controlPointOffset;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
graphics.moveTo(fromPoint.x, fromPoint.y);
|
|
119
|
+
graphics.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, toPoint.x, toPoint.y);
|
|
120
|
+
graphics.stroke({
|
|
121
|
+
color: isHovered ? CONNECTOR_HOVER_COLOR : CONNECTOR_COLOR,
|
|
122
|
+
width: isHovered ? CONNECTOR_HOVER_WIDTH : CONNECTOR_WIDTH,
|
|
123
|
+
});
|
|
124
|
+
drawArrowhead(graphics, fromPoint.x, fromPoint.y, cp1x, cp1y, cp2x, cp2y, toPoint.x, toPoint.y, isHovered);
|
|
125
|
+
const minX = Math.min(fromPoint.x, toPoint.x) - 10;
|
|
126
|
+
const minY = Math.min(fromPoint.y, toPoint.y) - 10;
|
|
127
|
+
const maxX = Math.max(fromPoint.x, toPoint.x) + 10;
|
|
128
|
+
const maxY = Math.max(fromPoint.y, toPoint.y) + 10;
|
|
129
|
+
graphics.hitArea = new PIXI__namespace.Rectangle(minX, minY, maxX - minX, maxY - minY);
|
|
130
|
+
}
|
|
131
|
+
function drawArrowhead(graphics, startX, startY, cp1x, cp1y, cp2x, cp2y, endX, endY, isHovered) {
|
|
132
|
+
const arrowSize = 10;
|
|
133
|
+
const dx = 3 * (endX - cp2x);
|
|
134
|
+
const dy = 3 * (endY - cp2y);
|
|
135
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
136
|
+
if (length === 0)
|
|
137
|
+
return;
|
|
138
|
+
const unitX = dx / length;
|
|
139
|
+
const unitY = dy / length;
|
|
140
|
+
const perpX = -unitY;
|
|
141
|
+
const perpY = unitX;
|
|
142
|
+
const backX = endX - unitX * arrowSize;
|
|
143
|
+
const backY = endY - unitY * arrowSize;
|
|
144
|
+
const left = { x: backX + perpX * (arrowSize / 2), y: backY + perpY * (arrowSize / 2) };
|
|
145
|
+
const right = { x: backX - perpX * (arrowSize / 2), y: backY - perpY * (arrowSize / 2) };
|
|
146
|
+
graphics.poly([
|
|
147
|
+
endX, endY,
|
|
148
|
+
left.x, left.y,
|
|
149
|
+
right.x, right.y,
|
|
150
|
+
endX, endY
|
|
151
|
+
]);
|
|
152
|
+
graphics.fill({ color: isHovered ? CONNECTOR_HOVER_COLOR : CONNECTOR_COLOR });
|
|
153
|
+
}
|
|
154
|
+
function getEdgePosition(element, side) {
|
|
155
|
+
const { position, size } = element;
|
|
156
|
+
switch (side) {
|
|
157
|
+
case 'top':
|
|
158
|
+
return { x: position.x + size.width / 2, y: position.y };
|
|
159
|
+
case 'right':
|
|
160
|
+
return { x: position.x + size.width, y: position.y + size.height / 2 };
|
|
161
|
+
case 'bottom':
|
|
162
|
+
return { x: position.x + size.width / 2, y: position.y + size.height };
|
|
163
|
+
case 'left':
|
|
164
|
+
return { x: position.x, y: position.y + size.height / 2 };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function updateConnectorGraphics(connectorGraphics, elements) {
|
|
168
|
+
drawConnector(connectorGraphics.graphics, connectorGraphics.connector, elements, connectorGraphics.isHovered);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exports.createConnectorGraphics = createConnectorGraphics;
|
|
172
|
+
exports.updateConnectorGraphics = updateConnectorGraphics;
|
|
173
|
+
//# sourceMappingURL=connectorGraphics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorGraphics.js","sources":["../../../../EventModeling/engine/connectorGraphics.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport * as PIXI from 'pixi.js';\nimport { Connector, ElementData, EdgeSide } from '../types';\n\nexport interface ConnectorGraphics {\n id: string;\n graphics: PIXI.Graphics;\n connector: Connector;\n getElements: () => Map<string, ElementData>;\n isHovered: boolean;\n}\n\nconst CONNECTOR_COLOR = 0x64748b;\nconst CONNECTOR_HOVER_COLOR = 0x3b82f6;\nconst CONNECTOR_WIDTH = 2;\nconst CONNECTOR_HOVER_WIDTH = 3;\n\nexport function createConnectorGraphics(\n connector: Connector,\n getElements: () => Map<string, ElementData>,\n onClick: (id: string) => void\n): ConnectorGraphics {\n const graphics = new PIXI.Graphics();\n graphics.eventMode = 'static';\n graphics.cursor = 'pointer';\n graphics.hitArea = new PIXI.Rectangle(0, 0, 0, 0); // Will be updated\n\n const connectorGraphics: ConnectorGraphics = {\n id: connector.id,\n graphics,\n connector,\n getElements,\n isHovered: false,\n };\n\n drawConnector(graphics, connector, getElements(), false);\n\n graphics.on('click', () => {\n onClick(connector.id);\n });\n\n graphics.on('pointerover', () => {\n connectorGraphics.isHovered = true;\n // Use fresh element data from getter\n drawConnector(graphics, connector, connectorGraphics.getElements(), true);\n });\n\n graphics.on('pointerout', () => {\n connectorGraphics.isHovered = false;\n // Use fresh element data from getter\n drawConnector(graphics, connector, connectorGraphics.getElements(), false);\n });\n\n return connectorGraphics;\n}\n\nfunction drawConnector(\n graphics: PIXI.Graphics,\n connector: Connector,\n elements: Map<string, ElementData>,\n isHovered: boolean\n): void {\n const fromElement = elements.get(connector.from.elementId);\n const toElement = elements.get(connector.to.elementId);\n\n if (!fromElement || !toElement) {\n graphics.clear();\n return;\n }\n\n const fromPoint = getEdgePosition(fromElement, connector.from.side);\n const toPoint = getEdgePosition(toElement, connector.to.side);\n\n graphics.clear();\n\n // Create a curved path using cubic Bezier\n const controlPointOffset = Math.abs(toPoint.x - fromPoint.x) / 3;\n \n let cp1x: number, cp1y: number, cp2x: number, cp2y: number;\n\n // Adjust control points based on connection direction\n if (connector.from.side === 'right' && connector.to.side === 'left') {\n // Horizontal connection\n cp1x = fromPoint.x + controlPointOffset;\n cp1y = fromPoint.y;\n cp2x = toPoint.x - controlPointOffset;\n cp2y = toPoint.y;\n } else if (connector.from.side === 'bottom' && connector.to.side === 'top') {\n // Vertical connection\n cp1x = fromPoint.x;\n cp1y = fromPoint.y + controlPointOffset;\n cp2x = toPoint.x;\n cp2y = toPoint.y - controlPointOffset;\n } else {\n // Mixed or diagonal connections\n switch (connector.from.side) {\n case 'right':\n cp1x = fromPoint.x + controlPointOffset;\n cp1y = fromPoint.y;\n break;\n case 'left':\n cp1x = fromPoint.x - controlPointOffset;\n cp1y = fromPoint.y;\n break;\n case 'bottom':\n cp1x = fromPoint.x;\n cp1y = fromPoint.y + controlPointOffset;\n break;\n case 'top':\n default:\n cp1x = fromPoint.x;\n cp1y = fromPoint.y - controlPointOffset;\n break;\n }\n\n switch (connector.to.side) {\n case 'left':\n cp2x = toPoint.x - controlPointOffset;\n cp2y = toPoint.y;\n break;\n case 'right':\n cp2x = toPoint.x + controlPointOffset;\n cp2y = toPoint.y;\n break;\n case 'top':\n cp2x = toPoint.x;\n cp2y = toPoint.y - controlPointOffset;\n break;\n case 'bottom':\n default:\n cp2x = toPoint.x;\n cp2y = toPoint.y + controlPointOffset;\n break;\n }\n }\n\n // Draw the curved line\n graphics.moveTo(fromPoint.x, fromPoint.y);\n graphics.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, toPoint.x, toPoint.y);\n graphics.stroke({\n color: isHovered ? CONNECTOR_HOVER_COLOR : CONNECTOR_COLOR,\n width: isHovered ? CONNECTOR_HOVER_WIDTH : CONNECTOR_WIDTH,\n });\n\n // Draw arrowhead at the end - pass all curve points for accurate tangent calculation\n drawArrowhead(graphics, fromPoint.x, fromPoint.y, cp1x, cp1y, cp2x, cp2y, toPoint.x, toPoint.y, isHovered);\n\n // Update hit area for better click detection\n const minX = Math.min(fromPoint.x, toPoint.x) - 10;\n const minY = Math.min(fromPoint.y, toPoint.y) - 10;\n const maxX = Math.max(fromPoint.x, toPoint.x) + 10;\n const maxY = Math.max(fromPoint.y, toPoint.y) + 10;\n graphics.hitArea = new PIXI.Rectangle(minX, minY, maxX - minX, maxY - minY);\n}\n\nfunction drawArrowhead(\n graphics: PIXI.Graphics,\n startX: number,\n startY: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endX: number,\n endY: number,\n isHovered: boolean\n): void {\n const arrowSize = 10;\n \n // Calculate the tangent at the end of the Bezier curve (t = 1)\n // For cubic Bezier: B'(t) = 3(1-t)²(P1-P0) + 6(1-t)t(P2-P1) + 3t²(P3-P2)\n // At t = 1: B'(1) = 3(P3 - P2)\n // This gives us the direction the curve is heading at the endpoint\n const dx = 3 * (endX - cp2x);\n const dy = 3 * (endY - cp2y);\n const length = Math.sqrt(dx * dx + dy * dy);\n \n if (length === 0) return;\n\n const unitX = dx / length;\n const unitY = dy / length;\n\n // Calculate perpendicular\n const perpX = -unitY;\n const perpY = unitX;\n\n // Calculate arrowhead points\n const backX = endX - unitX * arrowSize;\n const backY = endY - unitY * arrowSize;\n const left = { x: backX + perpX * (arrowSize / 2), y: backY + perpY * (arrowSize / 2) };\n const right = { x: backX - perpX * (arrowSize / 2), y: backY - perpY * (arrowSize / 2) };\n\n // Draw filled arrowhead\n graphics.poly([\n endX, endY,\n left.x, left.y,\n right.x, right.y,\n endX, endY\n ]);\n graphics.fill({ color: isHovered ? CONNECTOR_HOVER_COLOR : CONNECTOR_COLOR });\n}\n\nfunction getEdgePosition(element: ElementData, side: EdgeSide): { x: number; y: number } {\n const { position, size } = element;\n \n switch (side) {\n case 'top':\n return { x: position.x + size.width / 2, y: position.y };\n case 'right':\n return { x: position.x + size.width, y: position.y + size.height / 2 };\n case 'bottom':\n return { x: position.x + size.width / 2, y: position.y + size.height };\n case 'left':\n return { x: position.x, y: position.y + size.height / 2 };\n }\n}\n\nexport function updateConnectorGraphics(\n connectorGraphics: ConnectorGraphics,\n elements: Map<string, ElementData>\n): void {\n // Preserve hover state when updating\n drawConnector(connectorGraphics.graphics, connectorGraphics.connector, elements, connectorGraphics.isHovered);\n}\n"],"names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C,SAAS,CAAC;AACjH;;;;;"}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PIXI = require('pixi.js');
|
|
4
|
+
var types = require('../types.js');
|
|
5
|
+
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var PIXI__namespace = /*#__PURE__*/_interopNamespaceDefault(PIXI);
|
|
24
|
+
|
|
25
|
+
const EDGE_POINT_RADIUS = 6;
|
|
26
|
+
const BORDER_RADIUS = 8;
|
|
27
|
+
const PADDING = 16;
|
|
28
|
+
function createElementSprite(data, onElementClick, onElementDragStart, onElementDragMove, onElementDragEnd, onEdgeClick) {
|
|
29
|
+
const container = new PIXI__namespace.Container();
|
|
30
|
+
container.position.set(data.position.x, data.position.y);
|
|
31
|
+
container.eventMode = 'static';
|
|
32
|
+
container.cursor = 'move';
|
|
33
|
+
container.hitArea = new PIXI__namespace.Rectangle(0, 0, data.size.width, data.size.height);
|
|
34
|
+
const shadowGraphics = new PIXI__namespace.Graphics();
|
|
35
|
+
shadowGraphics.alpha = 0.15;
|
|
36
|
+
container.addChild(shadowGraphics);
|
|
37
|
+
const graphics = new PIXI__namespace.Graphics();
|
|
38
|
+
const edgePoints = new Map();
|
|
39
|
+
const selectionBorder = new PIXI__namespace.Graphics();
|
|
40
|
+
selectionBorder.alpha = 0;
|
|
41
|
+
container.addChild(selectionBorder);
|
|
42
|
+
const elementColors = types.ELEMENT_COLORS[data.type];
|
|
43
|
+
const backgroundColor = 'background' in elementColors ? elementColors.background : elementColors.fill;
|
|
44
|
+
if (data.type === 'process') {
|
|
45
|
+
const centerX = data.size.width / 2;
|
|
46
|
+
const centerY = data.size.height / 2;
|
|
47
|
+
const radius = Math.min(data.size.width, data.size.height) / 2;
|
|
48
|
+
for (let i = 0; i < 3; i++) {
|
|
49
|
+
shadowGraphics.circle(centerX, centerY + 2 + i, radius + i);
|
|
50
|
+
shadowGraphics.fill({ color: 0x000000, alpha: 0.06 });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
for (let i = 0; i < 4; i++) {
|
|
55
|
+
shadowGraphics.roundRect(i, 2 + i, data.size.width, data.size.height, BORDER_RADIUS);
|
|
56
|
+
shadowGraphics.fill({ color: 0x000000, alpha: 0.06 });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (data.type === 'process') {
|
|
60
|
+
const centerX = data.size.width / 2;
|
|
61
|
+
const centerY = data.size.height / 2;
|
|
62
|
+
const radius = Math.min(data.size.width, data.size.height) / 2;
|
|
63
|
+
graphics.circle(centerX, centerY, radius);
|
|
64
|
+
graphics.fill({ color: backgroundColor });
|
|
65
|
+
if ('stroke' in elementColors) {
|
|
66
|
+
graphics.stroke({ color: elementColors.stroke, width: 2 });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
graphics.roundRect(0, 0, data.size.width, data.size.height, BORDER_RADIUS);
|
|
71
|
+
graphics.fill({ color: backgroundColor });
|
|
72
|
+
}
|
|
73
|
+
container.addChild(graphics);
|
|
74
|
+
const textColor = 'text' in elementColors ? elementColors.text : 0xffffff;
|
|
75
|
+
const labelText = new PIXI__namespace.Text({
|
|
76
|
+
text: data.label,
|
|
77
|
+
style: {
|
|
78
|
+
fontSize: 14,
|
|
79
|
+
fill: textColor,
|
|
80
|
+
fontWeight: '600',
|
|
81
|
+
wordWrap: true,
|
|
82
|
+
wordWrapWidth: data.size.width - PADDING * 2,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
labelText.position.set(PADDING, PADDING);
|
|
86
|
+
container.addChild(labelText);
|
|
87
|
+
let descriptionText;
|
|
88
|
+
if (data.description && data.type !== 'process') {
|
|
89
|
+
descriptionText = new PIXI__namespace.Text({
|
|
90
|
+
text: data.description,
|
|
91
|
+
style: new PIXI__namespace.TextStyle({
|
|
92
|
+
fontSize: 12,
|
|
93
|
+
fill: textColor,
|
|
94
|
+
fontWeight: '400',
|
|
95
|
+
wordWrap: true,
|
|
96
|
+
wordWrapWidth: data.size.width - PADDING * 2,
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
descriptionText.alpha = 0.9;
|
|
100
|
+
descriptionText.position.set(PADDING, PADDING + 24);
|
|
101
|
+
container.addChild(descriptionText);
|
|
102
|
+
}
|
|
103
|
+
if (data.type !== 'process') {
|
|
104
|
+
const sides = ['top', 'right', 'bottom', 'left'];
|
|
105
|
+
sides.forEach(side => {
|
|
106
|
+
const edgePoint = createEdgePoint(data, side, () => onEdgeClick(data.id, side));
|
|
107
|
+
edgePoints.set(side, edgePoint);
|
|
108
|
+
container.addChild(edgePoint);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
container.on('pointerdown', (event) => {
|
|
112
|
+
if (!container.parent)
|
|
113
|
+
return;
|
|
114
|
+
const localPos = event.getLocalPosition(container.parent);
|
|
115
|
+
onElementDragStart(data.id, localPos.x - data.position.x, localPos.y - data.position.y);
|
|
116
|
+
});
|
|
117
|
+
container.on('click', () => {
|
|
118
|
+
onElementClick(data.id);
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
id: data.id,
|
|
122
|
+
container,
|
|
123
|
+
graphics,
|
|
124
|
+
selectionBorder,
|
|
125
|
+
labelText,
|
|
126
|
+
descriptionText,
|
|
127
|
+
edgePoints,
|
|
128
|
+
data,
|
|
129
|
+
isDragging: false,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function drawBoxElement(graphics, data) {
|
|
133
|
+
const colors = types.ELEMENT_COLORS[data.type];
|
|
134
|
+
if (!('background' in colors)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
graphics.clear();
|
|
138
|
+
graphics.roundRect(0, 0, data.size.width, data.size.height, BORDER_RADIUS);
|
|
139
|
+
graphics.fill({ color: colors.background });
|
|
140
|
+
graphics.visible = true;
|
|
141
|
+
graphics.alpha = 1;
|
|
142
|
+
}
|
|
143
|
+
function drawProcessElement(graphics, data) {
|
|
144
|
+
const colors = types.ELEMENT_COLORS.process;
|
|
145
|
+
const centerX = data.size.width / 2;
|
|
146
|
+
const centerY = data.size.height / 2;
|
|
147
|
+
const radius = Math.min(data.size.width, data.size.height) / 2;
|
|
148
|
+
graphics.clear();
|
|
149
|
+
graphics.circle(centerX, centerY, radius);
|
|
150
|
+
graphics.fill({ color: colors.fill });
|
|
151
|
+
graphics.stroke({ color: colors.stroke, width: 2 });
|
|
152
|
+
const teeth = 8;
|
|
153
|
+
const toothLength = radius * 0.2;
|
|
154
|
+
const innerRadius = radius * 0.6;
|
|
155
|
+
for (let i = 0; i < teeth; i++) {
|
|
156
|
+
const angle = (i / teeth) * Math.PI * 2;
|
|
157
|
+
const nextAngle = ((i + 0.4) / teeth) * Math.PI * 2;
|
|
158
|
+
const x1 = centerX + Math.cos(angle) * radius;
|
|
159
|
+
const y1 = centerY + Math.sin(angle) * radius;
|
|
160
|
+
const x2 = centerX + Math.cos(angle) * (radius + toothLength);
|
|
161
|
+
const y2 = centerY + Math.sin(angle) * (radius + toothLength);
|
|
162
|
+
const x3 = centerX + Math.cos(nextAngle) * (radius + toothLength);
|
|
163
|
+
const y3 = centerY + Math.sin(nextAngle) * (radius + toothLength);
|
|
164
|
+
const x4 = centerX + Math.cos(nextAngle) * radius;
|
|
165
|
+
const y4 = centerY + Math.sin(nextAngle) * radius;
|
|
166
|
+
graphics.moveTo(x1, y1);
|
|
167
|
+
graphics.lineTo(x2, y2);
|
|
168
|
+
graphics.lineTo(x3, y3);
|
|
169
|
+
graphics.lineTo(x4, y4);
|
|
170
|
+
graphics.fill({ color: colors.fill });
|
|
171
|
+
}
|
|
172
|
+
graphics.circle(centerX, centerY, innerRadius);
|
|
173
|
+
graphics.fill({ color: 0xffffff });
|
|
174
|
+
graphics.stroke({ color: colors.stroke, width: 2 });
|
|
175
|
+
}
|
|
176
|
+
function createEdgePoint(data, side, onClick) {
|
|
177
|
+
const edgePoint = new PIXI__namespace.Graphics();
|
|
178
|
+
edgePoint.eventMode = 'static';
|
|
179
|
+
edgePoint.cursor = 'crosshair';
|
|
180
|
+
const hitSize = EDGE_POINT_RADIUS * 2;
|
|
181
|
+
edgePoint.hitArea = new PIXI__namespace.Circle(0, 0, hitSize);
|
|
182
|
+
let x = 0, y = 0;
|
|
183
|
+
switch (side) {
|
|
184
|
+
case 'top':
|
|
185
|
+
x = data.size.width / 2;
|
|
186
|
+
y = 0;
|
|
187
|
+
break;
|
|
188
|
+
case 'right':
|
|
189
|
+
x = data.size.width;
|
|
190
|
+
y = data.size.height / 2;
|
|
191
|
+
break;
|
|
192
|
+
case 'bottom':
|
|
193
|
+
x = data.size.width / 2;
|
|
194
|
+
y = data.size.height;
|
|
195
|
+
break;
|
|
196
|
+
case 'left':
|
|
197
|
+
x = 0;
|
|
198
|
+
y = data.size.height / 2;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
edgePoint.position.set(x, y);
|
|
202
|
+
const colors = types.ELEMENT_COLORS[data.type];
|
|
203
|
+
edgePoint.circle(0, 0, EDGE_POINT_RADIUS);
|
|
204
|
+
edgePoint.fill({ color: 0xffffff });
|
|
205
|
+
edgePoint.stroke({ color: 'background' in colors ? colors.background : 0x6b7280, width: 2 });
|
|
206
|
+
edgePoint.alpha = 0;
|
|
207
|
+
edgePoint.on('click', (e) => {
|
|
208
|
+
e.stopPropagation();
|
|
209
|
+
onClick();
|
|
210
|
+
});
|
|
211
|
+
return edgePoint;
|
|
212
|
+
}
|
|
213
|
+
function updateElementSprite(sprite, data) {
|
|
214
|
+
sprite.data = data;
|
|
215
|
+
sprite.container.position.set(data.position.x, data.position.y);
|
|
216
|
+
if (data.type === 'process') {
|
|
217
|
+
drawProcessElement(sprite.graphics, data);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
drawBoxElement(sprite.graphics, data);
|
|
221
|
+
}
|
|
222
|
+
sprite.labelText.text = data.label;
|
|
223
|
+
if (sprite.descriptionText && data.description) {
|
|
224
|
+
sprite.descriptionText.text = data.description;
|
|
225
|
+
}
|
|
226
|
+
sprite.edgePoints.forEach((edgePoint, side) => {
|
|
227
|
+
let x = 0, y = 0;
|
|
228
|
+
switch (side) {
|
|
229
|
+
case 'top':
|
|
230
|
+
x = data.size.width / 2;
|
|
231
|
+
y = 0;
|
|
232
|
+
break;
|
|
233
|
+
case 'right':
|
|
234
|
+
x = data.size.width;
|
|
235
|
+
y = data.size.height / 2;
|
|
236
|
+
break;
|
|
237
|
+
case 'bottom':
|
|
238
|
+
x = data.size.width / 2;
|
|
239
|
+
y = data.size.height;
|
|
240
|
+
break;
|
|
241
|
+
case 'left':
|
|
242
|
+
x = 0;
|
|
243
|
+
y = data.size.height / 2;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
edgePoint.position.set(x, y);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function showEdgePoints(sprite) {
|
|
250
|
+
sprite.edgePoints.forEach(edgePoint => {
|
|
251
|
+
edgePoint.alpha = 1;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function hideEdgePoints(sprite) {
|
|
255
|
+
sprite.edgePoints.forEach(edgePoint => {
|
|
256
|
+
edgePoint.alpha = 0;
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function setElementSelected(sprite, selected) {
|
|
260
|
+
if (!sprite.selectionBorder)
|
|
261
|
+
return;
|
|
262
|
+
if (selected) {
|
|
263
|
+
updateSelectionBorder(sprite);
|
|
264
|
+
sprite.selectionBorder.alpha = 1;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
sprite.selectionBorder.alpha = 0;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function updateSelectionBorder(sprite) {
|
|
271
|
+
if (!sprite.selectionBorder)
|
|
272
|
+
return;
|
|
273
|
+
const selectionBorder = sprite.selectionBorder;
|
|
274
|
+
selectionBorder.clear();
|
|
275
|
+
const borderWidth = 3;
|
|
276
|
+
const offset = -borderWidth;
|
|
277
|
+
const primaryColor = getComputedPrimaryColor();
|
|
278
|
+
if (sprite.data.type === 'process') {
|
|
279
|
+
const centerX = sprite.data.size.width / 2;
|
|
280
|
+
const centerY = sprite.data.size.height / 2;
|
|
281
|
+
const radius = Math.min(sprite.data.size.width, sprite.data.size.height) / 2 + borderWidth;
|
|
282
|
+
selectionBorder.circle(centerX, centerY, radius);
|
|
283
|
+
selectionBorder.stroke({ color: primaryColor, width: borderWidth });
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
selectionBorder.roundRect(offset, offset, sprite.data.size.width + borderWidth * 2, sprite.data.size.height + borderWidth * 2, BORDER_RADIUS + borderWidth);
|
|
287
|
+
selectionBorder.stroke({ color: primaryColor, width: borderWidth });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function getComputedPrimaryColor() {
|
|
291
|
+
const style = getComputedStyle(document.documentElement);
|
|
292
|
+
const primaryColorStr = style.getPropertyValue('--primary-color').trim() || '#3B82F6';
|
|
293
|
+
return parseInt(primaryColorStr.replace('#', ''), 16);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
exports.createElementSprite = createElementSprite;
|
|
297
|
+
exports.hideEdgePoints = hideEdgePoints;
|
|
298
|
+
exports.setElementSelected = setElementSelected;
|
|
299
|
+
exports.showEdgePoints = showEdgePoints;
|
|
300
|
+
exports.updateElementSprite = updateElementSprite;
|
|
301
|
+
//# sourceMappingURL=elementSprites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elementSprites.js","sources":["../../../../EventModeling/engine/elementSprites.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport * as PIXI from 'pixi.js';\nimport { ElementData, ELEMENT_COLORS, EdgeSide } from '../types';\n\nexport interface ElementSprite {\n id: string;\n container: PIXI.Container;\n graphics: PIXI.Graphics;\n selectionBorder?: PIXI.Graphics;\n labelText: PIXI.Text;\n descriptionText?: PIXI.Text;\n edgePoints: Map<EdgeSide, PIXI.Graphics>;\n data: ElementData;\n isDragging: boolean;\n dragOffset?: { x: number; y: number };\n}\n\nconst EDGE_POINT_RADIUS = 6;\nconst BORDER_RADIUS = 8;\nconst PADDING = 16;\n\nexport function createElementSprite(\n data: ElementData,\n onElementClick: (id: string) => void,\n onElementDragStart: (id: string, x: number, y: number) => void,\n onElementDragMove: (id: string, x: number, y: number) => void,\n onElementDragEnd: (id: string) => void,\n onEdgeClick: (elementId: string, side: EdgeSide) => void\n): ElementSprite {\n const container = new PIXI.Container();\n container.position.set(data.position.x, data.position.y);\n container.eventMode = 'static';\n container.cursor = 'move';\n // Set explicit hit area for interaction\n container.hitArea = new PIXI.Rectangle(0, 0, data.size.width, data.size.height);\n\n // Create shadow layer\n const shadowGraphics = new PIXI.Graphics();\n shadowGraphics.alpha = 0.15;\n container.addChild(shadowGraphics);\n\n const graphics = new PIXI.Graphics();\n const edgePoints = new Map<EdgeSide, PIXI.Graphics>();\n\n // Create selection border (initially hidden)\n const selectionBorder = new PIXI.Graphics();\n selectionBorder.alpha = 0;\n container.addChild(selectionBorder);\n\n // Get colors based on element type\n const elementColors = ELEMENT_COLORS[data.type];\n const backgroundColor = 'background' in elementColors ? elementColors.background : elementColors.fill;\n \n // Draw shadow\n if (data.type === 'process') {\n const centerX = data.size.width / 2;\n const centerY = data.size.height / 2;\n const radius = Math.min(data.size.width, data.size.height) / 2;\n for (let i = 0; i < 3; i++) {\n shadowGraphics.circle(centerX, centerY + 2 + i, radius + i);\n shadowGraphics.fill({ color: 0x000000, alpha: 0.06 });\n }\n } else {\n for (let i = 0; i < 4; i++) {\n shadowGraphics.roundRect(i, 2 + i, data.size.width, data.size.height, BORDER_RADIUS);\n shadowGraphics.fill({ color: 0x000000, alpha: 0.06 });\n }\n }\n \n // Draw with proper shapes (PIXI v8 requires fill with object format)\n if (data.type === 'process') {\n const centerX = data.size.width / 2;\n const centerY = data.size.height / 2;\n const radius = Math.min(data.size.width, data.size.height) / 2;\n graphics.circle(centerX, centerY, radius);\n graphics.fill({ color: backgroundColor });\n if ('stroke' in elementColors) {\n graphics.stroke({ color: elementColors.stroke, width: 2 });\n }\n } else {\n // Use roundRect for proper appearance\n graphics.roundRect(0, 0, data.size.width, data.size.height, BORDER_RADIUS);\n graphics.fill({ color: backgroundColor });\n }\n\n container.addChild(graphics);\n\n // Create label text\n const textColor = 'text' in elementColors ? elementColors.text : 0xffffff;\n const labelText = new PIXI.Text({\n text: data.label,\n style: {\n fontSize: 14,\n fill: textColor,\n fontWeight: '600',\n wordWrap: true,\n wordWrapWidth: data.size.width - PADDING * 2,\n } as PIXI.TextStyle,\n });\n labelText.position.set(PADDING, PADDING);\n container.addChild(labelText);\n\n // Create description text if exists\n let descriptionText: PIXI.Text | undefined;\n if (data.description && data.type !== 'process') {\n descriptionText = new PIXI.Text({\n text: data.description,\n style: new PIXI.TextStyle({\n fontSize: 12,\n fill: textColor,\n fontWeight: '400',\n wordWrap: true,\n wordWrapWidth: data.size.width - PADDING * 2,\n }),\n });\n descriptionText.alpha = 0.9;\n descriptionText.position.set(PADDING, PADDING + 24);\n container.addChild(descriptionText);\n }\n\n // Create edge points for connections\n if (data.type !== 'process') {\n const sides: EdgeSide[] = ['top', 'right', 'bottom', 'left'];\n sides.forEach(side => {\n const edgePoint = createEdgePoint(data, side, () => onEdgeClick(data.id, side));\n edgePoints.set(side, edgePoint);\n container.addChild(edgePoint);\n });\n }\n\n // Set up interaction\n container.on('pointerdown', (event: PIXI.FederatedPointerEvent) => {\n if (!container.parent) return;\n const localPos = event.getLocalPosition(container.parent);\n onElementDragStart(data.id, localPos.x - data.position.x, localPos.y - data.position.y);\n });\n\n container.on('click', () => {\n onElementClick(data.id);\n });\n\n return {\n id: data.id,\n container,\n graphics,\n selectionBorder,\n labelText,\n descriptionText,\n edgePoints,\n data,\n isDragging: false,\n };\n}\n\nfunction drawBoxElement(graphics: PIXI.Graphics, data: ElementData): void {\n const colors = ELEMENT_COLORS[data.type];\n if (!('background' in colors)) {\n return;\n }\n \n graphics.clear();\n \n // Draw the rounded rectangle with solid fill (PIXI v8 - use object format)\n graphics.roundRect(0, 0, data.size.width, data.size.height, BORDER_RADIUS);\n graphics.fill({ color: colors.background });\n \n // Force visibility\n graphics.visible = true;\n graphics.alpha = 1;\n}\n\nfunction drawProcessElement(graphics: PIXI.Graphics, data: ElementData): void {\n const colors = ELEMENT_COLORS.process;\n const centerX = data.size.width / 2;\n const centerY = data.size.height / 2;\n const radius = Math.min(data.size.width, data.size.height) / 2;\n\n graphics.clear();\n \n // Draw outer circle\n graphics.circle(centerX, centerY, radius);\n graphics.fill({ color: colors.fill });\n graphics.stroke({ color: colors.stroke, width: 2 });\n\n // Draw cogwheel teeth\n const teeth = 8;\n const toothLength = radius * 0.2;\n const innerRadius = radius * 0.6;\n \n for (let i = 0; i < teeth; i++) {\n const angle = (i / teeth) * Math.PI * 2;\n const nextAngle = ((i + 0.4) / teeth) * Math.PI * 2;\n \n const x1 = centerX + Math.cos(angle) * radius;\n const y1 = centerY + Math.sin(angle) * radius;\n const x2 = centerX + Math.cos(angle) * (radius + toothLength);\n const y2 = centerY + Math.sin(angle) * (radius + toothLength);\n const x3 = centerX + Math.cos(nextAngle) * (radius + toothLength);\n const y3 = centerY + Math.sin(nextAngle) * (radius + toothLength);\n const x4 = centerX + Math.cos(nextAngle) * radius;\n const y4 = centerY + Math.sin(nextAngle) * radius;\n \n graphics.moveTo(x1, y1);\n graphics.lineTo(x2, y2);\n graphics.lineTo(x3, y3);\n graphics.lineTo(x4, y4);\n graphics.fill({ color: colors.fill });\n }\n\n // Draw inner circle\n graphics.circle(centerX, centerY, innerRadius);\n graphics.fill({ color: 0xffffff });\n graphics.stroke({ color: colors.stroke, width: 2 });\n}\n\nfunction createEdgePoint(data: ElementData, side: EdgeSide, onClick: () => void): PIXI.Graphics {\n const edgePoint = new PIXI.Graphics();\n edgePoint.eventMode = 'static';\n edgePoint.cursor = 'crosshair';\n \n // Set explicit hit area for better interaction\n const hitSize = EDGE_POINT_RADIUS * 2;\n edgePoint.hitArea = new PIXI.Circle(0, 0, hitSize);\n \n // Position based on side\n let x = 0, y = 0;\n switch (side) {\n case 'top':\n x = data.size.width / 2;\n y = 0;\n break;\n case 'right':\n x = data.size.width;\n y = data.size.height / 2;\n break;\n case 'bottom':\n x = data.size.width / 2;\n y = data.size.height;\n break;\n case 'left':\n x = 0;\n y = data.size.height / 2;\n break;\n }\n\n edgePoint.position.set(x, y);\n \n // Draw edge point (initially hidden)\n const colors = ELEMENT_COLORS[data.type];\n edgePoint.circle(0, 0, EDGE_POINT_RADIUS);\n edgePoint.fill({ color: 0xffffff });\n edgePoint.stroke({ color: 'background' in colors ? colors.background : 0x6b7280, width: 2 });\n edgePoint.alpha = 0;\n\n edgePoint.on('click', (e: PIXI.FederatedPointerEvent) => {\n e.stopPropagation();\n onClick();\n });\n\n return edgePoint;\n}\n\nexport function updateElementSprite(sprite: ElementSprite, data: ElementData): void {\n sprite.data = data;\n sprite.container.position.set(data.position.x, data.position.y);\n \n // Update graphics\n if (data.type === 'process') {\n drawProcessElement(sprite.graphics, data);\n } else {\n drawBoxElement(sprite.graphics, data);\n }\n\n // Update text\n sprite.labelText.text = data.label;\n if (sprite.descriptionText && data.description) {\n sprite.descriptionText.text = data.description;\n }\n\n // Update edge points positions\n sprite.edgePoints.forEach((edgePoint, side) => {\n let x = 0, y = 0;\n switch (side) {\n case 'top':\n x = data.size.width / 2;\n y = 0;\n break;\n case 'right':\n x = data.size.width;\n y = data.size.height / 2;\n break;\n case 'bottom':\n x = data.size.width / 2;\n y = data.size.height;\n break;\n case 'left':\n x = 0;\n y = data.size.height / 2;\n break;\n }\n edgePoint.position.set(x, y);\n });\n}\n\nexport function showEdgePoints(sprite: ElementSprite): void {\n sprite.edgePoints.forEach(edgePoint => {\n edgePoint.alpha = 1;\n });\n}\n\nexport function hideEdgePoints(sprite: ElementSprite): void {\n sprite.edgePoints.forEach(edgePoint => {\n edgePoint.alpha = 0;\n });\n}\n\nexport function setElementSelected(sprite: ElementSprite, selected: boolean): void {\n if (!sprite.selectionBorder) return;\n \n if (selected) {\n updateSelectionBorder(sprite);\n sprite.selectionBorder.alpha = 1;\n } else {\n sprite.selectionBorder.alpha = 0;\n }\n}\n\nfunction updateSelectionBorder(sprite: ElementSprite): void {\n if (!sprite.selectionBorder) return;\n \n const selectionBorder = sprite.selectionBorder;\n selectionBorder.clear();\n \n const borderWidth = 3;\n const offset = -borderWidth;\n \n // Get primary color from CSS variable with fallback\n const primaryColor = getComputedPrimaryColor();\n \n if (sprite.data.type === 'process') {\n const centerX = sprite.data.size.width / 2;\n const centerY = sprite.data.size.height / 2;\n const radius = Math.min(sprite.data.size.width, sprite.data.size.height) / 2 + borderWidth;\n \n selectionBorder.circle(centerX, centerY, radius);\n selectionBorder.stroke({ color: primaryColor, width: borderWidth });\n } else {\n selectionBorder.roundRect(\n offset, \n offset, \n sprite.data.size.width + borderWidth * 2, \n sprite.data.size.height + borderWidth * 2, \n BORDER_RADIUS + borderWidth\n );\n selectionBorder.stroke({ color: primaryColor, width: borderWidth });\n }\n}\n\nfunction getComputedPrimaryColor(): number {\n // Get the primary color from CSS custom properties\n const style = getComputedStyle(document.documentElement);\n const primaryColorStr = style.getPropertyValue('--primary-color').trim() || '#3B82F6';\n \n // Convert hex color string to number\n return parseInt(primaryColorStr.replace('#', ''), 16);\n}\n"],"names":["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 -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var EventModeling = require('./EventModeling.js');
|
|
4
|
+
var types = require('./types.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.EventModeling = EventModeling.EventModeling;
|
|
9
|
+
exports.DEFAULT_ELEMENT_SIZE = types.DEFAULT_ELEMENT_SIZE;
|
|
10
|
+
exports.ELEMENT_COLORS = types.ELEMENT_COLORS;
|
|
11
|
+
exports.calculateOptimalEdges = types.calculateOptimalEdges;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ELEMENT_COLORS = {
|
|
4
|
+
command: {
|
|
5
|
+
background: 0x3b82f6,
|
|
6
|
+
text: 0xffffff,
|
|
7
|
+
},
|
|
8
|
+
event: {
|
|
9
|
+
background: 0xf59e0b,
|
|
10
|
+
text: 0xffffff,
|
|
11
|
+
},
|
|
12
|
+
readmodel: {
|
|
13
|
+
background: 0x10b981,
|
|
14
|
+
text: 0xffffff,
|
|
15
|
+
},
|
|
16
|
+
process: {
|
|
17
|
+
fill: 0x6b7280,
|
|
18
|
+
stroke: 0x374151,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_ELEMENT_SIZE = {
|
|
22
|
+
command: { width: 200, height: 100 },
|
|
23
|
+
event: { width: 200, height: 100 },
|
|
24
|
+
readmodel: { width: 200, height: 100 },
|
|
25
|
+
process: { width: 80, height: 80 },
|
|
26
|
+
};
|
|
27
|
+
function calculateOptimalEdges(fromElement, toElement) {
|
|
28
|
+
const fromCenter = {
|
|
29
|
+
x: fromElement.position.x + fromElement.size.width / 2,
|
|
30
|
+
y: fromElement.position.y + fromElement.size.height / 2,
|
|
31
|
+
};
|
|
32
|
+
const toCenter = {
|
|
33
|
+
x: toElement.position.x + toElement.size.width / 2,
|
|
34
|
+
y: toElement.position.y + toElement.size.height / 2,
|
|
35
|
+
};
|
|
36
|
+
const dx = toCenter.x - fromCenter.x;
|
|
37
|
+
const dy = toCenter.y - fromCenter.y;
|
|
38
|
+
const isHorizontal = Math.abs(dx) > Math.abs(dy);
|
|
39
|
+
if (isHorizontal) {
|
|
40
|
+
if (dx > 0) {
|
|
41
|
+
return { fromSide: 'right', toSide: 'left' };
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return { fromSide: 'left', toSide: 'right' };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if (dy > 0) {
|
|
49
|
+
return { fromSide: 'bottom', toSide: 'top' };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return { fromSide: 'top', toSide: 'bottom' };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.DEFAULT_ELEMENT_SIZE = DEFAULT_ELEMENT_SIZE;
|
|
58
|
+
exports.ELEMENT_COLORS = ELEMENT_COLORS;
|
|
59
|
+
exports.calculateOptimalEdges = calculateOptimalEdges;
|
|
60
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../EventModeling/types.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nexport type ElementType = 'command' | 'event' | 'readmodel' | 'process';\n\nexport interface Position {\n x: number;\n y: number;\n}\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport interface ElementData {\n id: string;\n type: ElementType;\n position: Position;\n size: Size;\n label: string;\n description?: string;\n}\n\nexport type EdgeSide = 'top' | 'right' | 'bottom' | 'left';\n\nexport interface EdgePoint {\n elementId: string;\n side: EdgeSide;\n}\n\nexport interface Connector {\n id: string;\n from: EdgePoint;\n to: EdgePoint;\n}\n\nexport interface EventModelingState {\n elements: ElementData[];\n connectors: Connector[];\n selectedElementId?: string;\n selectedConnectorId?: string;\n}\n\nexport interface CanvasTransform {\n x: number;\n y: number;\n scale: number;\n}\n\nexport const ELEMENT_COLORS = {\n command: {\n background: 0x3b82f6,\n text: 0xffffff,\n },\n event: {\n background: 0xf59e0b,\n text: 0xffffff,\n },\n readmodel: {\n background: 0x10b981,\n text: 0xffffff,\n },\n process: {\n fill: 0x6b7280,\n stroke: 0x374151,\n },\n} as const;\n\nexport const DEFAULT_ELEMENT_SIZE = {\n command: { width: 200, height: 100 },\n event: { width: 200, height: 100 },\n readmodel: { width: 200, height: 100 },\n process: { width: 80, height: 80 },\n} as const;\n\n/**\n * Calculate the optimal edge pair for a connector based on element positions.\n * Returns the best matching edges for visual clarity.\n */\nexport function calculateOptimalEdges(\n fromElement: ElementData,\n toElement: ElementData\n): { fromSide: EdgeSide; toSide: EdgeSide } {\n // Calculate center points\n const fromCenter = {\n x: fromElement.position.x + fromElement.size.width / 2,\n y: fromElement.position.y + fromElement.size.height / 2,\n };\n const toCenter = {\n x: toElement.position.x + toElement.size.width / 2,\n y: toElement.position.y + toElement.size.height / 2,\n };\n\n // Calculate differences\n const dx = toCenter.x - fromCenter.x;\n const dy = toCenter.y - fromCenter.y;\n\n // Determine primary direction based on which delta is larger\n const isHorizontal = Math.abs(dx) > Math.abs(dy);\n\n if (isHorizontal) {\n // Horizontal connection is primary\n if (dx > 0) {\n // Target is to the right\n return { fromSide: 'right', toSide: 'left' };\n } else {\n // Target is to the left\n return { fromSide: 'left', toSide: 'right' };\n }\n } else {\n // Vertical connection is primary\n if (dy > 0) {\n // Target is below\n return { fromSide: 'bottom', toSide: 'top' };\n } else {\n // Target is above\n return { fromSide: 'top', toSide: 'bottom' };\n }\n }\n}\n"],"names":[],"mappings":";;AAkDO,MAAM,cAAc,GAAG;AAC1B,IAAA,OAAO,EAAE;AACL,QAAA,U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