@flowuent-org/diagramming-core 1.1.8 → 1.2.0
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/package.json +116 -116
- package/packages/diagrams/src/index.ts +1 -0
- package/packages/diagrams/src/lib/atoms/ConnectionPoints.tsx +149 -0
- package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +794 -650
- package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +606 -449
- package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +831 -687
- package/packages/diagrams/src/lib/components/automation/AutomationNoteNode.tsx +420 -275
- package/packages/diagrams/src/lib/components/automation/AutomationSheetsNode.tsx +1118 -974
- package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +509 -344
- package/packages/diagrams/src/lib/components/automation/NodeAIAssistantPopup.tsx +504 -0
- package/packages/diagrams/src/lib/components/automation/NodeActionButtons.tsx +146 -0
- package/packages/diagrams/src/lib/components/automation/index.ts +20 -11
- package/packages/diagrams/src/lib/molecules/SideHandles.tsx +177 -12
- package/packages/diagrams/src/lib/organisms/CustomEdge/custom-edge-generator.tsx +10 -5
- package/packages/diagrams/src/lib/styles.css +53 -0
- package/packages/diagrams/src/lib/templates/DiagramContainer.tsx +59 -0
- package/packages/diagrams/src/lib/templates/Diagramming.tsx +246 -204
- package/packages/diagrams/src/lib/types/edge-types.ts +17 -0
- package/packages/diagrams/src/lib/utils/generateEdgesFromNodeOrder.ts +113 -0
- package/packages/diagrams/src/lib/utils/nodeAIAssistantConfig.ts +54 -0
|
@@ -1,275 +1,420 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { Handle, Position, useNodeId } from '@xyflow/react';
|
|
3
|
-
import { Box, Typography, Button } from '@mui/material';
|
|
4
|
-
import { Description as DescriptionIcon, Lightbulb as LightbulbIcon } from '@mui/icons-material';
|
|
5
|
-
import { getIconByName } from '../../utils/iconMapper';
|
|
6
|
-
import { AISuggestion } from './AISuggestionsModal';
|
|
7
|
-
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
width:
|
|
57
|
-
height:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Handle, Position, useNodeId } from '@xyflow/react';
|
|
3
|
+
import { Box, Typography, Button } from '@mui/material';
|
|
4
|
+
import { Description as DescriptionIcon, Lightbulb as LightbulbIcon } from '@mui/icons-material';
|
|
5
|
+
import { getIconByName } from '../../utils/iconMapper';
|
|
6
|
+
import { AISuggestion } from './AISuggestionsModal';
|
|
7
|
+
import { AISuggestionsPanel } from './AISuggestionsPanel';
|
|
8
|
+
import { NodeActionButtons } from './NodeActionButtons';
|
|
9
|
+
import { showNodeAIAssistantPopup } from './NodeAIAssistantPopup';
|
|
10
|
+
import { useDiagram } from '../../contexts/DiagramProvider';
|
|
11
|
+
|
|
12
|
+
interface AutomationNoteNodeProps {
|
|
13
|
+
data: {
|
|
14
|
+
label: string;
|
|
15
|
+
description: string;
|
|
16
|
+
backgroundColor?: string;
|
|
17
|
+
textColor?: string;
|
|
18
|
+
borderColor?: string;
|
|
19
|
+
iconName?: string;
|
|
20
|
+
noteType?: 'info' | 'warning' | 'note' | 'purpose';
|
|
21
|
+
formData?: {
|
|
22
|
+
aiSuggestionsCount?: number; // Number of AI suggestions available
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
selected?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const AutomationNoteNode: React.FC<AutomationNoteNodeProps> = ({ data, selected }) => {
|
|
30
|
+
const nodeRef = useRef<HTMLDivElement | null>(null);
|
|
31
|
+
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
32
|
+
const nodeId = useNodeId();
|
|
33
|
+
const onNodesChange = useDiagram((state) => state.onNodesChange);
|
|
34
|
+
const nodes = useDiagram((state) => state.nodes);
|
|
35
|
+
const setNodes = useDiagram((state) => state.setNodes);
|
|
36
|
+
|
|
37
|
+
// Get the icon component based on the iconName, default to DescriptionIcon
|
|
38
|
+
const IconComponent = getIconByName(data.iconName || 'Description');
|
|
39
|
+
|
|
40
|
+
// Use consistent colors with other automation nodes
|
|
41
|
+
const colors = {
|
|
42
|
+
backgroundColor: '#181C25', // Default automation node background
|
|
43
|
+
textColor: '#ffffff',
|
|
44
|
+
borderColor: '#1e293b',
|
|
45
|
+
iconBg: '#3b82f6' // Default blue for icon background
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Debug logging for node dimensions
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (nodeRef.current) {
|
|
51
|
+
const rect = nodeRef.current.getBoundingClientRect();
|
|
52
|
+
const computedStyle = window.getComputedStyle(nodeRef.current);
|
|
53
|
+
console.log('AutomationNoteNode Debug:', {
|
|
54
|
+
nodeId: data.label,
|
|
55
|
+
actualDimensions: {
|
|
56
|
+
width: rect.width,
|
|
57
|
+
height: rect.height,
|
|
58
|
+
left: rect.left,
|
|
59
|
+
top: rect.top
|
|
60
|
+
},
|
|
61
|
+
computedStyle: {
|
|
62
|
+
width: computedStyle.width,
|
|
63
|
+
height: computedStyle.height,
|
|
64
|
+
padding: computedStyle.padding,
|
|
65
|
+
border: computedStyle.border,
|
|
66
|
+
boxShadow: computedStyle.boxShadow,
|
|
67
|
+
margin: computedStyle.margin
|
|
68
|
+
},
|
|
69
|
+
handlePositions: {
|
|
70
|
+
left: '-8px',
|
|
71
|
+
right: '-8px'
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, [data.label]);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Box
|
|
79
|
+
sx={{
|
|
80
|
+
position: 'relative',
|
|
81
|
+
width: '336px',
|
|
82
|
+
overflow: 'visible',
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<Box
|
|
86
|
+
ref={nodeRef}
|
|
87
|
+
sx={{
|
|
88
|
+
width: '336px',
|
|
89
|
+
minHeight: '150px',
|
|
90
|
+
backgroundColor: colors.backgroundColor,
|
|
91
|
+
border: selected ? `2px solid ${colors.borderColor}` : `1px solid ${colors.borderColor}`,
|
|
92
|
+
borderRadius: '12px',
|
|
93
|
+
padding: '0',
|
|
94
|
+
color: colors.textColor,
|
|
95
|
+
position: 'relative',
|
|
96
|
+
boxShadow: selected ? `0 0 0 2px rgba(59, 130, 246, 0.5)` : '0 4px 8px rgba(0, 0, 0, 0.3)',
|
|
97
|
+
transition: 'all 0.2s ease',
|
|
98
|
+
cursor: 'pointer',
|
|
99
|
+
overflow: 'hidden',
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{/* Header */}
|
|
103
|
+
<Box sx={{
|
|
104
|
+
display: 'flex',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
justifyContent: 'space-between',
|
|
107
|
+
p: 2,
|
|
108
|
+
borderBottom: '1px solid rgba(255, 255, 255, 0.1)'
|
|
109
|
+
}}>
|
|
110
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
|
111
|
+
<Box
|
|
112
|
+
sx={{
|
|
113
|
+
width: '32px',
|
|
114
|
+
height: '32px',
|
|
115
|
+
backgroundColor: colors.iconBg,
|
|
116
|
+
borderRadius: '6px',
|
|
117
|
+
display: 'flex',
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
justifyContent: 'center',
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<IconComponent sx={{ color: 'white', fontSize: '18px' }} />
|
|
123
|
+
</Box>
|
|
124
|
+
<Typography variant="h6" sx={{ fontWeight: 600, fontSize: '16px' }}>
|
|
125
|
+
{data.label}
|
|
126
|
+
</Typography>
|
|
127
|
+
</Box>
|
|
128
|
+
</Box>
|
|
129
|
+
|
|
130
|
+
{/* Content */}
|
|
131
|
+
<Box sx={{ p: 2 }}>
|
|
132
|
+
<Typography variant="body2" sx={{
|
|
133
|
+
color: colors.textColor,
|
|
134
|
+
fontSize: '14px',
|
|
135
|
+
lineHeight: 1.5,
|
|
136
|
+
opacity: 0.9
|
|
137
|
+
}}>
|
|
138
|
+
{data.description}
|
|
139
|
+
</Typography>
|
|
140
|
+
</Box>
|
|
141
|
+
|
|
142
|
+
{/* Note Type Indicator */}
|
|
143
|
+
<Box sx={{
|
|
144
|
+
position: 'absolute',
|
|
145
|
+
top: '8px',
|
|
146
|
+
right: '8px',
|
|
147
|
+
px: 1,
|
|
148
|
+
py: 0.5,
|
|
149
|
+
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
150
|
+
borderRadius: '4px',
|
|
151
|
+
fontSize: '10px',
|
|
152
|
+
fontWeight: 500,
|
|
153
|
+
textTransform: 'uppercase',
|
|
154
|
+
letterSpacing: '0.5px'
|
|
155
|
+
}}>
|
|
156
|
+
{data.noteType || 'note'}
|
|
157
|
+
</Box>
|
|
158
|
+
|
|
159
|
+
{/* Connection Handles - Bidirectional (source + target at each position) */}
|
|
160
|
+
{/* Top - Source */}
|
|
161
|
+
<Handle
|
|
162
|
+
type="source"
|
|
163
|
+
position={Position.Top}
|
|
164
|
+
id="top-source"
|
|
165
|
+
className="connection-handle"
|
|
166
|
+
style={{
|
|
167
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
168
|
+
width: '14px',
|
|
169
|
+
height: '14px',
|
|
170
|
+
border: '3px solid #10B981',
|
|
171
|
+
top: '-8px',
|
|
172
|
+
opacity: selected ? 1 : 0,
|
|
173
|
+
transition: 'all 0.2s ease-in-out',
|
|
174
|
+
cursor: 'crosshair',
|
|
175
|
+
zIndex: 10,
|
|
176
|
+
}}
|
|
177
|
+
/>
|
|
178
|
+
{/* Top - Target (hidden but functional) */}
|
|
179
|
+
<Handle
|
|
180
|
+
type="target"
|
|
181
|
+
position={Position.Top}
|
|
182
|
+
id="top-target"
|
|
183
|
+
style={{
|
|
184
|
+
background: 'transparent',
|
|
185
|
+
width: '14px',
|
|
186
|
+
height: '14px',
|
|
187
|
+
border: 'none',
|
|
188
|
+
top: '-8px',
|
|
189
|
+
opacity: 0,
|
|
190
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
193
|
+
{/* Bottom - Source */}
|
|
194
|
+
<Handle
|
|
195
|
+
type="source"
|
|
196
|
+
position={Position.Bottom}
|
|
197
|
+
id="bottom-source"
|
|
198
|
+
className="connection-handle"
|
|
199
|
+
style={{
|
|
200
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
201
|
+
width: '14px',
|
|
202
|
+
height: '14px',
|
|
203
|
+
border: '3px solid #10B981',
|
|
204
|
+
bottom: '-8px',
|
|
205
|
+
opacity: selected ? 1 : 0,
|
|
206
|
+
transition: 'all 0.2s ease-in-out',
|
|
207
|
+
cursor: 'crosshair',
|
|
208
|
+
zIndex: 10,
|
|
209
|
+
}}
|
|
210
|
+
/>
|
|
211
|
+
{/* Bottom - Target (hidden but functional) */}
|
|
212
|
+
<Handle
|
|
213
|
+
type="target"
|
|
214
|
+
position={Position.Bottom}
|
|
215
|
+
id="bottom-target"
|
|
216
|
+
style={{
|
|
217
|
+
background: 'transparent',
|
|
218
|
+
width: '14px',
|
|
219
|
+
height: '14px',
|
|
220
|
+
border: 'none',
|
|
221
|
+
bottom: '-8px',
|
|
222
|
+
opacity: 0,
|
|
223
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
{/* Left - Source */}
|
|
227
|
+
<Handle
|
|
228
|
+
type="source"
|
|
229
|
+
position={Position.Left}
|
|
230
|
+
id="left-source"
|
|
231
|
+
className="connection-handle"
|
|
232
|
+
style={{
|
|
233
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
234
|
+
width: '14px',
|
|
235
|
+
height: '14px',
|
|
236
|
+
border: '3px solid #10B981',
|
|
237
|
+
left: '-8px',
|
|
238
|
+
opacity: selected ? 1 : 0,
|
|
239
|
+
transition: 'all 0.2s ease-in-out',
|
|
240
|
+
cursor: 'crosshair',
|
|
241
|
+
zIndex: 10,
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
244
|
+
{/* Left - Target (hidden but functional) */}
|
|
245
|
+
<Handle
|
|
246
|
+
type="target"
|
|
247
|
+
position={Position.Left}
|
|
248
|
+
id="left-target"
|
|
249
|
+
style={{
|
|
250
|
+
background: 'transparent',
|
|
251
|
+
width: '14px',
|
|
252
|
+
height: '14px',
|
|
253
|
+
border: 'none',
|
|
254
|
+
left: '-8px',
|
|
255
|
+
opacity: 0,
|
|
256
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
{/* Right - Source */}
|
|
260
|
+
<Handle
|
|
261
|
+
type="source"
|
|
262
|
+
position={Position.Right}
|
|
263
|
+
id="right-source"
|
|
264
|
+
className="connection-handle"
|
|
265
|
+
style={{
|
|
266
|
+
background: selected ? '#10B981' : '#1a1a2e',
|
|
267
|
+
width: '14px',
|
|
268
|
+
height: '14px',
|
|
269
|
+
border: '3px solid #10B981',
|
|
270
|
+
right: '-8px',
|
|
271
|
+
opacity: selected ? 1 : 0,
|
|
272
|
+
transition: 'all 0.2s ease-in-out',
|
|
273
|
+
cursor: 'crosshair',
|
|
274
|
+
zIndex: 10,
|
|
275
|
+
}}
|
|
276
|
+
/>
|
|
277
|
+
{/* Right - Target (hidden but functional) */}
|
|
278
|
+
<Handle
|
|
279
|
+
type="target"
|
|
280
|
+
position={Position.Right}
|
|
281
|
+
id="right-target"
|
|
282
|
+
style={{
|
|
283
|
+
background: 'transparent',
|
|
284
|
+
width: '14px',
|
|
285
|
+
height: '14px',
|
|
286
|
+
border: 'none',
|
|
287
|
+
right: '-8px',
|
|
288
|
+
opacity: 0,
|
|
289
|
+
pointerEvents: selected ? 'all' : 'none',
|
|
290
|
+
}}
|
|
291
|
+
/>
|
|
292
|
+
|
|
293
|
+
</Box>
|
|
294
|
+
|
|
295
|
+
{/* Node Action Buttons - Shows when selected */}
|
|
296
|
+
<NodeActionButtons
|
|
297
|
+
selected={selected}
|
|
298
|
+
onOpenAIAssistant={(buttonElement) => {
|
|
299
|
+
if (nodeId) {
|
|
300
|
+
showNodeAIAssistantPopup(nodeId, 'Note Node', buttonElement);
|
|
301
|
+
}
|
|
302
|
+
}}
|
|
303
|
+
onDelete={() => {
|
|
304
|
+
if (nodeId && onNodesChange) {
|
|
305
|
+
onNodesChange([{ id: nodeId, type: 'remove' }]);
|
|
306
|
+
}
|
|
307
|
+
}}
|
|
308
|
+
onDuplicate={() => {
|
|
309
|
+
if (nodeId) {
|
|
310
|
+
const currentNode = nodes.find(n => n.id === nodeId);
|
|
311
|
+
if (currentNode) {
|
|
312
|
+
const newNode = {
|
|
313
|
+
...currentNode,
|
|
314
|
+
id: `${currentNode.id}-copy-${Date.now()}`,
|
|
315
|
+
position: {
|
|
316
|
+
x: currentNode.position.x + 50,
|
|
317
|
+
y: currentNode.position.y + 50,
|
|
318
|
+
},
|
|
319
|
+
selected: false,
|
|
320
|
+
};
|
|
321
|
+
setNodes([...nodes, newNode]);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}}
|
|
325
|
+
/>
|
|
326
|
+
|
|
327
|
+
{/* AI Suggestions Button - Positioned below the node box */}
|
|
328
|
+
{data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && (
|
|
329
|
+
<Box
|
|
330
|
+
sx={{
|
|
331
|
+
position: 'absolute',
|
|
332
|
+
top: '100%',
|
|
333
|
+
left: '50%',
|
|
334
|
+
transform: 'translateX(-50%)',
|
|
335
|
+
marginTop: '12px',
|
|
336
|
+
zIndex: 10,
|
|
337
|
+
whiteSpace: 'nowrap',
|
|
338
|
+
}}
|
|
339
|
+
onClick={(e) => {
|
|
340
|
+
e.stopPropagation();
|
|
341
|
+
// Toggle AI Suggestions panel
|
|
342
|
+
setShowSuggestions(!showSuggestions);
|
|
343
|
+
}}
|
|
344
|
+
>
|
|
345
|
+
<Button
|
|
346
|
+
variant="contained"
|
|
347
|
+
startIcon={<LightbulbIcon sx={{ fontSize: '12px' }} />}
|
|
348
|
+
sx={{
|
|
349
|
+
backgroundColor: '#2563EB',
|
|
350
|
+
color: '#ffffff',
|
|
351
|
+
borderRadius: '20px',
|
|
352
|
+
textTransform: 'none',
|
|
353
|
+
fontSize: '10px',
|
|
354
|
+
fontWeight: 400,
|
|
355
|
+
padding: '8px 16px',
|
|
356
|
+
whiteSpace: 'nowrap',
|
|
357
|
+
display: 'inline-flex',
|
|
358
|
+
alignItems: 'center',
|
|
359
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.3)',
|
|
360
|
+
'&:hover': {
|
|
361
|
+
backgroundColor: '#2563eb',
|
|
362
|
+
},
|
|
363
|
+
'& .MuiButton-startIcon': {
|
|
364
|
+
marginRight: '8px',
|
|
365
|
+
}
|
|
366
|
+
}}
|
|
367
|
+
>
|
|
368
|
+
AI Suggestions
|
|
369
|
+
<Box
|
|
370
|
+
component="span"
|
|
371
|
+
sx={{
|
|
372
|
+
marginLeft: '8px',
|
|
373
|
+
backgroundColor: '#FFFFFF26',
|
|
374
|
+
color: '#ffffff',
|
|
375
|
+
fontSize: '10px',
|
|
376
|
+
fontWeight: 400,
|
|
377
|
+
minWidth: '18px',
|
|
378
|
+
height: '18px',
|
|
379
|
+
borderRadius: '9px',
|
|
380
|
+
display: 'inline-flex',
|
|
381
|
+
alignItems: 'center',
|
|
382
|
+
justifyContent: 'center',
|
|
383
|
+
padding: '0 6px',
|
|
384
|
+
border: '1px solid rgba(255, 255, 255, 0.2)',
|
|
385
|
+
}}
|
|
386
|
+
>
|
|
387
|
+
{data.formData.aiSuggestionsCount}
|
|
388
|
+
</Box>
|
|
389
|
+
</Button>
|
|
390
|
+
</Box>
|
|
391
|
+
)}
|
|
392
|
+
|
|
393
|
+
{/* AI Suggestions Panel - Rendered on canvas below the button */}
|
|
394
|
+
{showSuggestions && data.formData?.aiSuggestionsCount !== undefined && data.formData.aiSuggestionsCount > 0 && nodeId && (
|
|
395
|
+
<AISuggestionsPanel
|
|
396
|
+
suggestions={data.formData?.aiSuggestions || [
|
|
397
|
+
{
|
|
398
|
+
id: '1',
|
|
399
|
+
title: 'Add Citation Extraction',
|
|
400
|
+
description: 'Automatically extract and format citations from article content.',
|
|
401
|
+
tags: ['classification', 'enhancement'],
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
id: '2',
|
|
405
|
+
title: 'Generate Bullet Summary',
|
|
406
|
+
description: 'Create a concise bullet-point summary of the article\'s main points.',
|
|
407
|
+
tags: ['classification', 'enhancement'],
|
|
408
|
+
},
|
|
409
|
+
]}
|
|
410
|
+
parentNodeId={nodeId}
|
|
411
|
+
onSuggestionClick={(suggestion) => {
|
|
412
|
+
console.log('Suggestion clicked:', suggestion);
|
|
413
|
+
// Handle suggestion selection here
|
|
414
|
+
}}
|
|
415
|
+
onClose={() => setShowSuggestions(false)}
|
|
416
|
+
/>
|
|
417
|
+
)}
|
|
418
|
+
</Box>
|
|
419
|
+
);
|
|
420
|
+
};
|