@flowuent-org/diagramming-core 1.1.1 → 1.1.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.
@@ -5,7 +5,7 @@ export const automationDefaultNodes = [
5
5
  {
6
6
  id: 'start-node',
7
7
  type: 'AutomationStartNode',
8
- position: { x: 50, y: 200 },
8
+ position: { x: 100, y: 200 },
9
9
  data: {
10
10
  // Display data for the node UI
11
11
  label: 'Workflow Trigger',
@@ -61,7 +61,7 @@ export const automationDefaultNodes = [
61
61
  {
62
62
  id: 'api-call-node',
63
63
  type: 'AutomationApiNode',
64
- position: { x: 400, y: 200 },
64
+ position: { x: 500, y: 200 },
65
65
  data: {
66
66
  // Display data for the node UI
67
67
  label: 'Discover Headlines',
@@ -152,7 +152,7 @@ export const automationDefaultNodes = [
152
152
  {
153
153
  id: 'ai-suggestion-node',
154
154
  type: 'AutomationAISuggestionNode',
155
- position: { x: 400, y: 360 },
155
+ position: { x: 900, y: 200 },
156
156
  data: {
157
157
  label: 'Citation Extractor',
158
158
  description: 'Extract and format citation from article text.',
@@ -174,7 +174,7 @@ export const automationDefaultNodes = [
174
174
  {
175
175
  id: 'data-formatting-node',
176
176
  type: 'AutomationFormattingNode',
177
- position: { x: 750, y: 200 },
177
+ position: { x: 700, y: 200 },
178
178
  data: {
179
179
  // Display data for the node UI
180
180
  label: 'Article Analyzer',
@@ -249,7 +249,7 @@ export const automationDefaultNodes = [
249
249
  {
250
250
  id: 'google-sheets-node',
251
251
  type: 'AutomationSheetsNode',
252
- position: { x: 925, y: 200 },
252
+ position: { x: 1100, y: 200 },
253
253
  data: {
254
254
  // Display data for the node UI
255
255
  label: 'Data Sync Node',
@@ -357,7 +357,7 @@ export const automationDefaultNodes = [
357
357
  {
358
358
  id: 'note-node-1',
359
359
  type: 'AutomationNoteNode',
360
- position: { x: 400, y: 50 },
360
+ position: { x: 700, y: 50 },
361
361
  data: {
362
362
  label: 'Article Analyzer',
363
363
  description:
@@ -388,7 +388,7 @@ export const automationDefaultNodes = [
388
388
  {
389
389
  id: 'note-node-2',
390
390
  type: 'AutomationNoteNode',
391
- position: { x: 50, y: 400 },
391
+ position: { x: 500, y: 50 },
392
392
  data: {
393
393
  label: 'Discover Headlines',
394
394
  description:
@@ -419,7 +419,7 @@ export const automationDefaultNodes = [
419
419
  {
420
420
  id: 'end-node',
421
421
  type: 'AutomationEndNode',
422
- position: { x: 1275, y: 200 },
422
+ position: { x: 1500, y: 200 },
423
423
  data: {
424
424
  // Display data for the node UI
425
425
  label: 'Results Display',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowuent-org/diagramming-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,11 +24,10 @@ export const AISuggestionsPanel: React.FC<AISuggestionsPanelProps> = ({
24
24
  const parentNode = getNode(parentNodeId);
25
25
  if (!parentNode) return;
26
26
 
27
- // Calculate position for new node - below the parent node
28
- // Node height + button height (~40px) + panel height (~400px) + spacing
29
- const nodeHeight = parentNode.height || 150;
30
- const panelHeight = suggestions.length * 180 + 100; // Approximate height per suggestion + padding
31
- const newNodeY = parentNode.position.y + nodeHeight + 40 + panelHeight + 40;
27
+ // Calculate position for new node - to the right of the parent node
28
+ // Node width + spacing
29
+ const nodeWidth = parentNode.width || 336;
30
+ const newNodeX = parentNode.position.x + nodeWidth + 50;
32
31
 
33
32
  // Create new AI Suggestion node
34
33
  const newNodeId = `ai-suggestion-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
@@ -55,8 +54,8 @@ export const AISuggestionsPanel: React.FC<AISuggestionsPanelProps> = ({
55
54
  id: newNodeId,
56
55
  type: 'AutomationAISuggestionNode',
57
56
  position: {
58
- x: parentNode.position.x,
59
- y: newNodeY,
57
+ x: newNodeX,
58
+ y: parentNode.position.y,
60
59
  },
61
60
  data: {
62
61
  label: suggestion.title,
@@ -67,7 +67,7 @@ const createDiagramStore = ({
67
67
  historyIndex: -1,
68
68
  diagramType,
69
69
  edgeShapeType: 'curly',
70
- layoutDirection: 'DOWN',
70
+ layoutDirection: diagramType === 'automation' ? 'RIGHT' : 'DOWN',
71
71
  pannable: true,
72
72
  selectedNode: null,
73
73
  selectedEdge: null,
@@ -10,7 +10,7 @@ import {
10
10
  createUpdatedEdges,
11
11
  createUpdatedNodes,
12
12
  } from '../utils/create-updated';
13
- import { getNodeHeight } from '../utils/utilities';
13
+ import { getNodeHeight, getNodeWidth } from '../utils/utilities';
14
14
  import {
15
15
  useDiagram,
16
16
  useGetDefaultNodeData,
@@ -154,7 +154,7 @@ export const useGenerateNodesAndEdges = () => {
154
154
  position:
155
155
  index === 0
156
156
  ? position
157
- : { x: position.x, y: position.y + 200 * index },
157
+ : { x: position.x + (constantLengths.SUB_NODE_WIDTH + constantLengths.CONNECTION_LENGTH) * index, y: position.y },
158
158
  replacingNode: isReplacement && index === 0 ? currentNode : {},
159
159
  });
160
160
  node.data.branchIndex = nodeInfo.branchIndex;
@@ -165,7 +165,7 @@ export const useGenerateNodesAndEdges = () => {
165
165
  const edge = createEdgeConnection({
166
166
  sourceId: newNodes[edgeInfo.source].id,
167
167
  targetId: newNodes[edgeInfo.target].id,
168
- sourceHandle: `${newNodes[edgeInfo.source].id}-bottom`,
168
+ sourceHandle: `${newNodes[edgeInfo.source].id}-right`,
169
169
  edgeLabel: edgeInfo.label,
170
170
  });
171
171
  if (edge) newEdges.push(edge);
@@ -203,11 +203,11 @@ export const useCalculateNewNodesAndEdges = () => {
203
203
  : isParallelRoot || addBeforeCurrentNode
204
204
  ? { x: 0, y: constantLengths.NODE_TOP_HEIGHT }
205
205
  : {
206
- x: currentNode.position.x,
207
- y:
208
- currentNode.position.y +
209
- getNodeHeight(currentNode) +
206
+ x:
207
+ currentNode.position.x +
208
+ getNodeWidth(currentNode) +
210
209
  constantLengths.CONNECTION_LENGTH,
210
+ y: currentNode.position.y,
211
211
  };
212
212
 
213
213
  const { nodes, edges } = generateNodesAndEdges(
@@ -224,7 +224,7 @@ export const useCalculateNewNodesAndEdges = () => {
224
224
  createEdgeConnection({
225
225
  sourceId: currentNode.id,
226
226
  targetId: nodes[0].id,
227
- sourceHandle: `${currentNode.id}-bottom`,
227
+ sourceHandle: `${currentNode.id}-right`,
228
228
  })!,
229
229
  );
230
230
  }
@@ -116,12 +116,18 @@ export const DiagramContent: React.FC<DiagramContentProps> = ({
116
116
  const layoutDirection = useLayoutDirection();
117
117
  const setLayoutDirection = useSetLayoutDirection();
118
118
 
119
+ // Set layout direction to RIGHT for automation diagrams
120
+ useEffect(() => {
121
+ if (diagramType === 'automation' && layoutDirection !== 'RIGHT') {
122
+ setLayoutDirection('RIGHT');
123
+ }
124
+ }, [diagramType, layoutDirection, setLayoutDirection]);
119
125
 
120
126
  useEffect(() => {
121
127
  getLayoutedElements();
122
128
 
123
129
  return () => { };
124
- }, [nodes.length, edges.length, contentHeights, diagramType]);
130
+ }, [nodes.length, edges.length, contentHeights, diagramType, layoutDirection, getLayoutedElements]);
125
131
 
126
132
  // Listen for layout direction changes
127
133
  useEffect(() => {
@@ -208,6 +214,14 @@ export const DiagramContent: React.FC<DiagramContentProps> = ({
208
214
  edges={visibleEdges}
209
215
  onEdgesChange={onEdgesChange}
210
216
  fitView
217
+ fitViewOptions={{
218
+ padding: 0.2,
219
+ minZoom: 0.3,
220
+ maxZoom: 2,
221
+ includeHiddenNodes: false,
222
+ }}
223
+ minZoom={0.1}
224
+ maxZoom={2}
211
225
  onNodeDragStart={onNodeDragStart}
212
226
  onNodeDragStop={onNodeDragEnd}
213
227
  onConnect={onConnect}
@@ -28,8 +28,8 @@ export const createUpdatedEdges = (
28
28
  ? {
29
29
  ...e,
30
30
  source,
31
- id: `${source}-bottomv${e.target}`, // Ensure edge ID includes handle
32
- sourceHandle: `${source}-bottom`, // Update the source handle ID
31
+ id: `${source}-rightv${e.target}`, // Ensure edge ID includes handle
32
+ sourceHandle: `${source}-right`, // Update the source handle ID for horizontal workflow
33
33
  }
34
34
  : e,
35
35
  );