@flowuent-org/diagramming-core 1.0.5 → 1.0.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.
Files changed (28) hide show
  1. package/TRANSLATION_FIX_SUMMARY.md +118 -0
  2. package/apps/diagramming/src/DiagramTabs.tsx +205 -205
  3. package/apps/diagramming/src/sample-workflow-content.ts +55 -54
  4. package/package.json +116 -116
  5. package/packages/diagrams/I18N_SETUP.md +126 -0
  6. package/packages/diagrams/NODE_DATA_UPDATE_API.md +430 -430
  7. package/packages/diagrams/README.md +443 -3
  8. package/packages/diagrams/UNDO_REDO_API.md +306 -306
  9. package/packages/diagrams/locales/en/translation.json +713 -0
  10. package/packages/diagrams/package.json +5 -23
  11. package/packages/diagrams/pnpm-lock.yaml +2606 -0
  12. package/packages/diagrams/project.json +42 -38
  13. package/packages/diagrams/rollup.config.js +5 -10
  14. package/packages/diagrams/src/index.ts +116 -113
  15. package/packages/diagrams/src/lib/atoms/CardEditableTitle.tsx +76 -76
  16. package/packages/diagrams/src/lib/components/automation/AutomationApiNode.tsx +24 -3
  17. package/packages/diagrams/src/lib/components/automation/AutomationEndNode.tsx +23 -2
  18. package/packages/diagrams/src/lib/components/automation/AutomationFormattingNode.tsx +24 -3
  19. package/packages/diagrams/src/lib/components/automation/AutomationStartNode.tsx +24 -3
  20. package/packages/diagrams/src/lib/contexts/onWorkflowNodeDelete.ts +1 -1
  21. package/packages/diagrams/src/lib/i18n.ts +42 -0
  22. package/packages/diagrams/src/lib/organisms/CustomEdge/useCreateBendPoint.tsx +121 -119
  23. package/packages/diagrams/src/lib/organisms/WorkFlowNode/NodeActionButtons.tsx +1 -1
  24. package/packages/diagrams/src/lib/templates/node-forms/CallForm.tsx +370 -370
  25. package/packages/diagrams/src/lib/types/node-types.ts +29 -29
  26. package/packages/diagrams/src/lib/utils/AutomationExecutionEngine.ts +1168 -1162
  27. package/packages/diagrams/tsconfig.lib.json +1 -3
  28. package/tsconfig.base.json +1 -1
@@ -43,7 +43,7 @@ export const AutomationStartNode: React.FC<AutomationStartNodeProps> = ({ data,
43
43
  // Get the icon component based on the iconName
44
44
  const IconComponent = getIconByName(data.iconName);
45
45
 
46
-
46
+
47
47
 
48
48
  const handleJsonClick = () => {
49
49
  if (nodeId) setSelectedNode(nodeId);
@@ -208,6 +208,19 @@ export const AutomationStartNode: React.FC<AutomationStartNodeProps> = ({ data,
208
208
  transition: 'all 0.2s ease',
209
209
  cursor: 'pointer',
210
210
  overflow: 'hidden',
211
+ ...(data.status === 'Running' && {
212
+ animation: 'pulse-glow 2s ease-in-out infinite',
213
+ '@keyframes pulse-glow': {
214
+ '0%, 100%': {
215
+ boxShadow: '0 0 20px rgba(251, 191, 36, 0.4), 0 0 40px rgba(251, 191, 36, 0.2)',
216
+ borderColor: 'rgba(251, 191, 36, 0.6)',
217
+ },
218
+ '50%': {
219
+ boxShadow: '0 0 30px rgba(251, 191, 36, 0.6), 0 0 60px rgba(251, 191, 36, 0.3)',
220
+ borderColor: 'rgba(251, 191, 36, 0.9)',
221
+ },
222
+ },
223
+ }),
211
224
  }}
212
225
  onClick={handleJsonClick}
213
226
  >
@@ -252,8 +265,16 @@ export const AutomationStartNode: React.FC<AutomationStartNodeProps> = ({ data,
252
265
  label={data.status}
253
266
  size="small"
254
267
  sx={{
255
- backgroundColor: 'rgba(16, 185, 129, 0.1)',
256
- color: '#86EFAC',
268
+ backgroundColor: data.status === 'Completed'
269
+ ? 'rgba(37, 99, 235, 0.1)'
270
+ : data.status === 'Running'
271
+ ? 'rgba(251, 191, 36, 0.1)'
272
+ : 'rgba(16, 185, 129, 0.1)',
273
+ color: data.status === 'Completed'
274
+ ? '#93C5FD'
275
+ : data.status === 'Running'
276
+ ? '#FCD34D'
277
+ : '#86EFAC',
257
278
  fontWeight: 500,
258
279
  fontSize: '12px',
259
280
  height: '24px',
@@ -1,5 +1,5 @@
1
1
  import { DiagramState } from './diagramStoreTypes';
2
- import { ICardNode } from '../types/card-node';
2
+ import { ICardNode } from '@flowuent-labs/diagrams';
3
3
 
4
4
  // Helper function to handle node deletion and edge updates
5
5
  export const onWorkflowNodeDelete = (
@@ -0,0 +1,42 @@
1
+ import i18n from 'i18next';
2
+ import { initReactI18next } from 'react-i18next';
3
+
4
+ // Import translation resources
5
+ import translationEN from '../../locales/en/translation.json';
6
+
7
+ // Initialize i18next for the diagrams library
8
+ export const initDiagramsI18n = (customResources?: any) => {
9
+ // Only initialize if not already initialized
10
+ if (!i18n.isInitialized) {
11
+ i18n.use(initReactI18next).init({
12
+ resources: customResources || {
13
+ en: {
14
+ translation: translationEN,
15
+ },
16
+ },
17
+ fallbackLng: 'en',
18
+ debug: false,
19
+ interpolation: {
20
+ escapeValue: false,
21
+ },
22
+ // Add namespace for the library to avoid conflicts
23
+ defaultNS: 'translation',
24
+ });
25
+ } else if (customResources) {
26
+ // If already initialized, add resources to existing instance
27
+ Object.keys(customResources).forEach((lng) => {
28
+ Object.keys(customResources[lng]).forEach((ns) => {
29
+ i18n.addResourceBundle(lng, ns, customResources[lng][ns], true, true);
30
+ });
31
+ });
32
+ }
33
+
34
+ return i18n;
35
+ };
36
+
37
+ // Export translation resources for manual initialization
38
+ export { translationEN };
39
+
40
+ // Export configured i18n instance
41
+ export default i18n;
42
+
@@ -1,119 +1,121 @@
1
- import { Edge } from '@xyflow/react';
2
- import { closestPoint } from '../../utils/closestPoint';
3
- import { DiagramStore } from '../../contexts/DiagramProvider';
4
- import { EdgeTypes } from './custom-edge.type';
5
- import { HistoryEvent } from '../../types/history-event';
6
- import { ICardNode } from '../../types/card-node';
7
- import { useCustomReactFlow } from '../../hooks/customUseReactFlow';
8
- import { useDiagram } from '../../contexts/DiagramProvider';
9
- import React, { useCallback } from 'react';
10
- import { v4 as uuidv4 } from 'uuid';
11
- import addToHistory from '../../utils/addToHistory';
12
-
13
- export const useCreateBendPoint = (
14
- currentEdge: Edge,
15
- sourceNode: ICardNode,
16
- targetNode: ICardNode,
17
- pathRef: React.RefObject<SVGPathElement>,
18
- ) => {
19
- const { setEdges, getEdge, screenToFlowPosition, addNodes } =
20
- useCustomReactFlow();
21
- const store = useDiagram<DiagramStore>();
22
- const { diagramType, nodes, edges, setStore } = store;
23
-
24
- return useCallback(
25
- (evt: React.MouseEvent<SVGPathElement, MouseEvent>) => {
26
- if (diagramType === 'workflow') {
27
- return;
28
- }
29
- evt.preventDefault();
30
- evt.stopPropagation();
31
- if (!pathRef.current) return;
32
-
33
- const position = screenToFlowPosition({
34
- x: evt.clientX,
35
- y: evt.clientY,
36
- });
37
- const cpoint = closestPoint(pathRef.current, [position.x, position.y]);
38
- if (!currentEdge || !sourceNode || !targetNode)
39
- throw new Error(
40
- 'Invalid Edge found with source, target or curr edge missing',
41
- );
42
-
43
- const nodesAndEdgesBefore = {
44
- nodes: [...nodes],
45
- edges: [...edges],
46
- };
47
- const nodeId = uuidv4();
48
- const newBendPoint: ICardNode = {
49
- id: nodeId,
50
- position: { x: cpoint[0], y: cpoint[1] },
51
- data: { nodeId: nodeId },
52
- type: 'bendPoint',
53
- };
54
- const newEdge: Edge = {
55
- id: uuidv4(),
56
- source: newBendPoint.id,
57
- target: currentEdge.target,
58
- type:
59
- currentEdge.type === EdgeTypes.Default ||
60
- currentEdge.type === EdgeTypes.Bend2Target
61
- ? EdgeTypes.Bend2Target
62
- : EdgeTypes.Bend2Bend,
63
- };
64
- newEdge.markerEnd =
65
- newEdge.type === EdgeTypes.Bend2Target
66
- ? currentEdge.markerEnd
67
- : undefined;
68
- currentEdge.target = newBendPoint.id;
69
- currentEdge.type =
70
- currentEdge.type === EdgeTypes.Default ||
71
- currentEdge.type === EdgeTypes.Source2Bend
72
- ? EdgeTypes.Source2Bend
73
- : EdgeTypes.Bend2Bend;
74
- delete currentEdge.markerEnd;
75
- currentEdge.markerStart =
76
- currentEdge.type === EdgeTypes.Source2Bend
77
- ? currentEdge.markerStart
78
- : undefined;
79
-
80
- const newEdges = [
81
- ...edges.filter((e) => e.id !== currentEdge.id),
82
- currentEdge,
83
- newEdge,
84
- ];
85
- const newNodes = [...nodes, newBendPoint];
86
- const nodesAndEdgesAfter = {
87
- nodes: newNodes,
88
- edges: newEdges,
89
- };
90
-
91
- const event: HistoryEvent = {
92
- forward: {
93
- t: 'complex-change',
94
- type: 'complex',
95
- nodesAndEdges: nodesAndEdgesAfter,
96
- },
97
- backward: {
98
- t: 'complex-change',
99
- type: 'complex',
100
- nodesAndEdges: nodesAndEdgesBefore,
101
- },
102
- title: 'Bend point created in the middle of ' + currentEdge.id,
103
- };
104
- setStore({
105
- ...addToHistory(store, [event]),
106
- ...nodesAndEdgesAfter,
107
- });
108
- },
109
- [
110
- pathRef.current,
111
- currentEdge.id,
112
- getEdge,
113
- setEdges,
114
- addNodes,
115
- sourceNode,
116
- targetNode,
117
- ],
118
- );
119
- };
1
+ import { Edge } from '@xyflow/react';
2
+ import {
3
+ closestPoint,
4
+ DiagramStore,
5
+ EdgeTypes,
6
+ HistoryEvent,
7
+ ICardNode,
8
+ useCustomReactFlow,
9
+ useDiagram,
10
+ } from '@flowuent-labs/diagrams';
11
+ import React, { useCallback } from 'react';
12
+ import { v4 as uuidv4 } from 'uuid';
13
+ import addToHistory from '../../utils/addToHistory';
14
+
15
+ export const useCreateBendPoint = (
16
+ currentEdge: Edge,
17
+ sourceNode: ICardNode,
18
+ targetNode: ICardNode,
19
+ pathRef: React.RefObject<SVGPathElement>,
20
+ ) => {
21
+ const { setEdges, getEdge, screenToFlowPosition, addNodes } =
22
+ useCustomReactFlow();
23
+ const store = useDiagram<DiagramStore>();
24
+ const { diagramType, nodes, edges, setStore } = store;
25
+
26
+ return useCallback(
27
+ (evt: React.MouseEvent<SVGPathElement, MouseEvent>) => {
28
+ if (diagramType === 'workflow') {
29
+ return;
30
+ }
31
+ evt.preventDefault();
32
+ evt.stopPropagation();
33
+ if (!pathRef.current) return;
34
+
35
+ const position = screenToFlowPosition({
36
+ x: evt.clientX,
37
+ y: evt.clientY,
38
+ });
39
+ const cpoint = closestPoint(pathRef.current, [position.x, position.y]);
40
+ if (!currentEdge || !sourceNode || !targetNode)
41
+ throw new Error(
42
+ 'Invalid Edge found with source, target or curr edge missing',
43
+ );
44
+
45
+ const nodesAndEdgesBefore = {
46
+ nodes: [...nodes],
47
+ edges: [...edges],
48
+ };
49
+ const nodeId = uuidv4();
50
+ const newBendPoint: ICardNode = {
51
+ id: nodeId,
52
+ position: { x: cpoint[0], y: cpoint[1] },
53
+ data: { nodeId: nodeId },
54
+ type: 'bendPoint',
55
+ };
56
+ const newEdge: Edge = {
57
+ id: uuidv4(),
58
+ source: newBendPoint.id,
59
+ target: currentEdge.target,
60
+ type:
61
+ currentEdge.type === EdgeTypes.Default ||
62
+ currentEdge.type === EdgeTypes.Bend2Target
63
+ ? EdgeTypes.Bend2Target
64
+ : EdgeTypes.Bend2Bend,
65
+ };
66
+ newEdge.markerEnd =
67
+ newEdge.type === EdgeTypes.Bend2Target
68
+ ? currentEdge.markerEnd
69
+ : undefined;
70
+ currentEdge.target = newBendPoint.id;
71
+ currentEdge.type =
72
+ currentEdge.type === EdgeTypes.Default ||
73
+ currentEdge.type === EdgeTypes.Source2Bend
74
+ ? EdgeTypes.Source2Bend
75
+ : EdgeTypes.Bend2Bend;
76
+ delete currentEdge.markerEnd;
77
+ currentEdge.markerStart =
78
+ currentEdge.type === EdgeTypes.Source2Bend
79
+ ? currentEdge.markerStart
80
+ : undefined;
81
+
82
+ const newEdges = [
83
+ ...edges.filter((e) => e.id !== currentEdge.id),
84
+ currentEdge,
85
+ newEdge,
86
+ ];
87
+ const newNodes = [...nodes, newBendPoint];
88
+ const nodesAndEdgesAfter = {
89
+ nodes: newNodes,
90
+ edges: newEdges,
91
+ };
92
+
93
+ const event: HistoryEvent = {
94
+ forward: {
95
+ t: 'complex-change',
96
+ type: 'complex',
97
+ nodesAndEdges: nodesAndEdgesAfter,
98
+ },
99
+ backward: {
100
+ t: 'complex-change',
101
+ type: 'complex',
102
+ nodesAndEdges: nodesAndEdgesBefore,
103
+ },
104
+ title: 'Bend point created in the middle of ' + currentEdge.id,
105
+ };
106
+ setStore({
107
+ ...addToHistory(store, [event]),
108
+ ...nodesAndEdgesAfter,
109
+ });
110
+ },
111
+ [
112
+ pathRef.current,
113
+ currentEdge.id,
114
+ getEdge,
115
+ setEdges,
116
+ addNodes,
117
+ sourceNode,
118
+ targetNode,
119
+ ],
120
+ );
121
+ };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Button } from '@mui/material';
3
3
  import { WorkflowNodeActionButtons } from '../../molecules/WorkflowNodeActionButtons';
4
4
  import { ICardNode } from '../../types/card-node';
5
- import { useNodeType } from '../../contexts/CardDataProvider';
5
+ import { useNodeType } from '@flowuent-labs/diagrams';
6
6
 
7
7
  interface NodeActionButtonsProps {
8
8
  addButtonVisible: boolean;