@flowuent-org/diagramming-core 1.1.7 → 1.1.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowuent-org/diagramming-core",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,117 +1,117 @@
1
- export * from './lib/externals';
2
- export * from './lib/i18n';
3
- export * from './lib/templates/systemFlow';
4
- export * from './lib/theme';
5
- export * from './lib/atoms/AddNodeAnchor';
6
- export * from './lib/atoms/AddParallelColButton';
7
- export * from './lib/atoms/BendpointNode';
8
- export * from './lib/atoms/CardBlockTypeSelector';
9
- export * from './lib/atoms/CardMainContent';
10
- export * from './lib/atoms/FloatingConnectionLine';
11
- export * from './lib/atoms/MarkerSelector';
12
- export * from './lib/atoms/PropertyInput';
13
- export * from './lib/atoms/StyledBox';
14
- export * from './lib/contexts/CardDataProvider';
15
- export * from './lib/contexts/DiagramProvider';
16
- export * from './lib/contexts/diagramStoreTypes';
17
- export * from './lib/contexts/onConnect';
18
- export * from './lib/contexts/onDragStart';
19
- export * from './lib/contexts/onNodeDragEnd';
20
- export * from './lib/contexts/onNodesChange';
21
- export * from './lib/contexts/setContentHeight';
22
- export * from './lib/contexts/setDiagramType';
23
- export * from './lib/contexts/setEdges';
24
- export * from './lib/contexts/setEdgeShapeType';
25
- export * from './lib/contexts/setNodes';
26
- export * from './lib/contexts/setNodeSetting';
27
- export * from './lib/contexts/setPannable';
28
- export * from './lib/contexts/setSelectedEdge';
29
- export * from './lib/contexts/setSelectedNode';
30
- export * from './lib/contexts/undo';
31
- export * from './lib/contexts/updateNodeSetting';
32
- export * from './lib/hooks/customUseReactFlow';
33
- export * from './lib/hooks/updateNodes';
34
- export * from './lib/hooks/useDragCallbacks';
35
- export * from './lib/hooks/useModalControls';
36
- export * from './lib/hooks/useWorkflowNodeActiont';
37
- export * from './lib/hooks/useAutoRegisterFunctions';
38
- export * from './lib/molecules/AddingBlock';
39
- export * from './lib/molecules/animated-add-button';
40
- export * from './lib/molecules/Block';
41
- export * from './lib/molecules/BlockProvider';
42
- export * from './lib/molecules/BlockWrapper';
43
- export * from './lib/molecules/DraggablePane';
44
- export * from './lib/molecules/EntityNodeBlocks';
45
- export * from './lib/molecules/json-viewer';
46
- export * from './lib/molecules/SideHandles';
47
- export * from './lib/molecules/StencilItem';
48
- export * from './lib/molecules/WorkflowNodeActionButtons';
49
- export * from './lib/organisms/AddNodeView';
50
- export * from './lib/organisms/DownloadPanel';
51
- export * from './lib/organisms/EdgeModal';
52
- export * from './lib/organisms/NodeContextMenu';
53
- export * from './lib/organisms/SmartDynamicForm';
54
- export * from './lib/organisms/Stencil';
55
- export * from './lib/organisms/UseDiagramStore';
56
- export * from './lib/organisms/ConditionRuleGroup';
57
- export * from './lib/organisms/WorkflowNode';
58
- export * from './lib/templates/DiagramContainer';
59
- export * from './lib/templates/DiagramContent';
60
- export * from './lib/templates/Diagramming';
61
- export type { DiagrammingPageRef } from './lib/templates/Diagramming';
62
- export * from './lib/templates/PageLinks';
63
- export * from './lib/types/card-node';
64
- export * from './lib/types/collaboration-types';
65
- export * from './lib/types/colors';
66
- export * from './lib/types/edge-types';
67
- export * from './lib/types/hooks.types';
68
- export * from './lib/types/node-types';
69
- export * from './lib/types/SmartDynamicFormField';
70
- export * from './lib/types/stencil-item';
71
- export * from './lib/types/structures';
72
- export * from './lib/types/workflow-content-dynamic-form-type';
73
- export * from './lib/types/FunctionSignature';
74
- export * from './lib/utils/add-new-block';
75
- export * from './lib/utils/add-new-node';
76
- export * from './lib/utils/addToHistory';
77
- export * from './lib/utils/closestPoint';
78
- export * from './lib/utils/color-options';
79
- export * from './lib/utils/compress-img';
80
- export * from './lib/utils/constant-lengths';
81
- export * from './lib/utils/create-updated';
82
- export * from './lib/utils/createHistoryChange';
83
- export * from './lib/utils/edge-hooks';
84
- export * from './lib/utils/elkLayout';
85
- export * from './lib/utils/event-hooks';
86
- export * from './lib/utils/event-store';
87
- export * from './lib/utils/flow-node-hooks';
88
- export * from './lib/utils/flow-to-js';
89
- export * from './lib/utils/helpers.types';
90
- export * from './lib/utils/logger';
91
- export * from './lib/utils/model-hooks';
92
- export * from './lib/utils/node-hooks';
93
- export { useHistory, useHistoryIndex } from './lib/contexts/DiagramProvider';
94
- export * from './lib/utils/object';
95
- export * from './lib/utils/nodeutils';
96
- export * from './lib/utils/utilities';
97
- export * from './lib/utils/vhToPixels';
98
- export * from './lib/utils/nodeOrderByEdges';
99
- export * from './lib/assets/markers/markers.param';
100
- export * from './lib/assets/markers/markers.type';
101
- export * from './lib/organisms/Card/card.params';
102
- export * from './lib/organisms/Card/card.types';
103
- export * from './lib/organisms/Card/EntityNode';
104
- export * from './lib/organisms/CustomEdge/custom-edge-generator';
105
- export * from './lib/organisms/CustomEdge/custom-edge.params';
106
- export * from './lib/organisms/CustomEdge/custom-edge.type';
107
- export * from './lib/organisms/PropertiesPane';
108
- export * from './lib/organisms/HistoryPane';
109
- //export * from './lib/types/workflow-node-data-types';
110
- export * from './lib/templates/node-forms/NodeForm';
111
- export { AutomationExecutionEngine } from './lib/utils/AutomationExecutionEngine';
112
- export type {
113
- AutomationLog,
114
- AutomationResult,
115
- } from './lib/utils/AutomationExecutionEngine';
116
- export * from './lib/components/automation';
117
- export * from './lib/types/automation-node-data-types';
1
+ export * from './lib/externals';
2
+ export * from './lib/i18n';
3
+ export * from './lib/templates/systemFlow';
4
+ export * from './lib/theme';
5
+ export * from './lib/atoms/AddNodeAnchor';
6
+ export * from './lib/atoms/AddParallelColButton';
7
+ export * from './lib/atoms/BendpointNode';
8
+ export * from './lib/atoms/CardBlockTypeSelector';
9
+ export * from './lib/atoms/CardMainContent';
10
+ export * from './lib/atoms/FloatingConnectionLine';
11
+ export * from './lib/atoms/MarkerSelector';
12
+ export * from './lib/atoms/PropertyInput';
13
+ export * from './lib/atoms/StyledBox';
14
+ export * from './lib/contexts/CardDataProvider';
15
+ export * from './lib/contexts/DiagramProvider';
16
+ export * from './lib/contexts/diagramStoreTypes';
17
+ export * from './lib/contexts/onConnect';
18
+ export * from './lib/contexts/onDragStart';
19
+ export * from './lib/contexts/onNodeDragEnd';
20
+ export * from './lib/contexts/onNodesChange';
21
+ export * from './lib/contexts/setContentHeight';
22
+ export * from './lib/contexts/setDiagramType';
23
+ export * from './lib/contexts/setEdges';
24
+ export * from './lib/contexts/setEdgeShapeType';
25
+ export * from './lib/contexts/setNodes';
26
+ export * from './lib/contexts/setNodeSetting';
27
+ export * from './lib/contexts/setPannable';
28
+ export * from './lib/contexts/setSelectedEdge';
29
+ export * from './lib/contexts/setSelectedNode';
30
+ export * from './lib/contexts/undo';
31
+ export * from './lib/contexts/updateNodeSetting';
32
+ export * from './lib/hooks/customUseReactFlow';
33
+ export * from './lib/hooks/updateNodes';
34
+ export * from './lib/hooks/useDragCallbacks';
35
+ export * from './lib/hooks/useModalControls';
36
+ export * from './lib/hooks/useWorkflowNodeActiont';
37
+ export * from './lib/hooks/useAutoRegisterFunctions';
38
+ export * from './lib/molecules/AddingBlock';
39
+ export * from './lib/molecules/animated-add-button';
40
+ export * from './lib/molecules/Block';
41
+ export * from './lib/molecules/BlockProvider';
42
+ export * from './lib/molecules/BlockWrapper';
43
+ export * from './lib/molecules/DraggablePane';
44
+ export * from './lib/molecules/EntityNodeBlocks';
45
+ export * from './lib/molecules/json-viewer';
46
+ export * from './lib/molecules/SideHandles';
47
+ export * from './lib/molecules/StencilItem';
48
+ export * from './lib/molecules/WorkflowNodeActionButtons';
49
+ export * from './lib/organisms/AddNodeView';
50
+ export * from './lib/organisms/DownloadPanel';
51
+ export * from './lib/organisms/EdgeModal';
52
+ export * from './lib/organisms/NodeContextMenu';
53
+ export * from './lib/organisms/SmartDynamicForm';
54
+ export * from './lib/organisms/Stencil';
55
+ export * from './lib/organisms/UseDiagramStore';
56
+ export * from './lib/organisms/ConditionRuleGroup';
57
+ export * from './lib/organisms/WorkflowNode';
58
+ export * from './lib/templates/DiagramContainer';
59
+ export * from './lib/templates/DiagramContent';
60
+ export * from './lib/templates/Diagramming';
61
+ export type { DiagrammingPageRef } from './lib/templates/Diagramming';
62
+ export * from './lib/templates/PageLinks';
63
+ export * from './lib/types/card-node';
64
+ export * from './lib/types/collaboration-types';
65
+ export * from './lib/types/colors';
66
+ export * from './lib/types/edge-types';
67
+ export * from './lib/types/hooks.types';
68
+ export * from './lib/types/node-types';
69
+ export * from './lib/types/SmartDynamicFormField';
70
+ export * from './lib/types/stencil-item';
71
+ export * from './lib/types/structures';
72
+ export * from './lib/types/workflow-content-dynamic-form-type';
73
+ export * from './lib/types/FunctionSignature';
74
+ export * from './lib/utils/add-new-block';
75
+ export * from './lib/utils/add-new-node';
76
+ export * from './lib/utils/addToHistory';
77
+ export * from './lib/utils/closestPoint';
78
+ export * from './lib/utils/color-options';
79
+ export * from './lib/utils/compress-img';
80
+ export * from './lib/utils/constant-lengths';
81
+ export * from './lib/utils/create-updated';
82
+ export * from './lib/utils/createHistoryChange';
83
+ export * from './lib/utils/edge-hooks';
84
+ export * from './lib/utils/elkLayout';
85
+ export * from './lib/utils/event-hooks';
86
+ export * from './lib/utils/event-store';
87
+ export * from './lib/utils/flow-node-hooks';
88
+ export * from './lib/utils/flow-to-js';
89
+ export * from './lib/utils/helpers.types';
90
+ export * from './lib/utils/logger';
91
+ export * from './lib/utils/model-hooks';
92
+ export * from './lib/utils/node-hooks';
93
+ export { useHistory, useHistoryIndex } from './lib/contexts/DiagramProvider';
94
+ export * from './lib/utils/object';
95
+ export * from './lib/utils/nodeutils';
96
+ export * from './lib/utils/utilities';
97
+ export * from './lib/utils/vhToPixels';
98
+ export * from './lib/utils/nodeOrderByEdges';
99
+ export * from './lib/assets/markers/markers.param';
100
+ export * from './lib/assets/markers/markers.type';
101
+ export * from './lib/organisms/Card/card.params';
102
+ export * from './lib/organisms/Card/card.types';
103
+ export * from './lib/organisms/Card/EntityNode';
104
+ export * from './lib/organisms/CustomEdge/custom-edge-generator';
105
+ export * from './lib/organisms/CustomEdge/custom-edge.params';
106
+ export * from './lib/organisms/CustomEdge/custom-edge.type';
107
+ export * from './lib/organisms/PropertiesPane';
108
+ export * from './lib/organisms/HistoryPane';
109
+ //export * from './lib/types/workflow-node-data-types';
110
+ export * from './lib/templates/node-forms/NodeForm';
111
+ export { AutomationExecutionEngine } from './lib/utils/AutomationExecutionEngine';
112
+ export type {
113
+ AutomationLog,
114
+ AutomationResult,
115
+ } from './lib/utils/AutomationExecutionEngine';
116
+ export * from './lib/components/automation';
117
+ export * from './lib/types/automation-node-data-types';
@@ -1,178 +1,245 @@
1
- import { CssBaseline, ThemeProvider } from '@mui/material';
2
- import React, { forwardRef, useImperativeHandle } from 'react';
3
- import { Edge, Background, BackgroundVariant } from '@xyflow/react';
4
- import FloatingConnectionLine from '../atoms/FloatingConnectionLine';
5
- import { DiagramStoreProvider, useDiagram } from '../contexts/DiagramProvider';
6
- import { theme } from '../theme';
7
- import { ICardNode } from '../types/card-node';
8
- import DiagramTypes from '../types/diagram-types';
9
- import edgeTypes, { defaultEdgeOptions } from '../types/edge-types';
10
- import nodeTypes from '../types/node-types';
11
- import { useAutoRegisterVariables } from '../hooks/useAutoRegisterVariables';
12
-
13
- import {
14
- ConditionBuilderState,
15
- GetDefaultNodeDataType,
16
- OnChangeEventHandler,
17
- RenderAddNodeViewType,
18
- WorkflowNodeContentType,
19
- } from '../contexts/diagramStoreTypes';
20
- import { DiagramContainer } from './DiagramContainer';
21
- import { FunctionSignature } from '../types/FunctionSignature';
22
- import { AvailableVariable } from '../types/available-variables';
23
-
24
- // Component that handles variable registration
25
- const VariableRegistrationHandler: React.FC = () => {
26
- useAutoRegisterVariables();
27
- return null;
28
- };
29
-
30
- // Interface for the ref methods
31
- export interface DiagrammingPageRef {
32
- undo: () => void;
33
- redo: () => void;
34
- canUndo: () => boolean;
35
- canRedo: () => boolean;
36
- reset: () => void;
37
- getHistoryLength: () => number;
38
- getHistoryIndex: () => number;
39
- // Node data management methods
40
- getNodeData: (nodeId: string) => any | null;
41
- updateNodeData: (nodeId: string, data: any) => boolean;
42
- getSelectedNode: () => string | null;
43
- getNodes: () => any[];
44
- getEdges: () => any[];
45
- }
46
-
47
- // Internal component that exposes undo/redo functionality
48
- const DiagrammingPageInternal = forwardRef<DiagrammingPageRef, { children?: React.ReactNode; className?: string; showAutomationExecutionPanel?: boolean }>(({ children, className, showAutomationExecutionPanel }, ref) => {
49
- const undo = useDiagram((state) => state.undo);
50
- const redo = useDiagram((state) => state.redo);
51
- const reset = useDiagram((state) => state.reset);
52
- const history = useDiagram((state) => state.history);
53
- const historyIndex = useDiagram((state) => state.historyIndex);
54
- const nodes = useDiagram((state) => state.nodes);
55
- const edges = useDiagram((state) => state.edges);
56
- const selectedNode = useDiagram((state) => state.selectedNode);
57
- const setNodes = useDiagram((state) => state.setNodes);
58
-
59
- useImperativeHandle(ref, () => ({
60
- undo,
61
- redo,
62
- canUndo: () => historyIndex > 0,
63
- canRedo: () => historyIndex < history.length - 1,
64
- reset,
65
- getHistoryLength: () => history.length,
66
- getHistoryIndex: () => historyIndex,
67
- // Node data management methods
68
- getNodeData: (nodeId: string) => {
69
- const node = nodes.find(n => n.id === nodeId);
70
- return node ? node.data : null;
71
- },
72
- updateNodeData: (nodeId: string, newData: any) => {
73
- const nodeIndex = nodes.findIndex(n => n.id === nodeId);
74
- if (nodeIndex === -1) return false;
75
-
76
- const updatedNodes = [...nodes];
77
- updatedNodes[nodeIndex] = {
78
- ...updatedNodes[nodeIndex],
79
- data: { ...updatedNodes[nodeIndex].data, ...newData }
80
- };
81
- setNodes(updatedNodes);
82
- return true;
83
- },
84
- getSelectedNode: () => selectedNode,
85
- getNodes: () => nodes,
86
- getEdges: () => edges,
87
- }));
88
-
89
- return (
90
- <DiagramContainer
91
- defaultEdgeOptions={defaultEdgeOptions}
92
- edgeTypes={edgeTypes}
93
- nodeTypes={nodeTypes as any}
94
- connectionLineComponent={FloatingConnectionLine}
95
- style={{ backgroundColor: '#141519' }}
96
- className={className}
97
- showAutomationExecutionPanel={showAutomationExecutionPanel}
98
- >
99
- <Background
100
- color="#ffffff"
101
- variant={BackgroundVariant.Dots}
102
- gap={20}
103
- size={1}
104
- />
105
- {children}
106
- </DiagramContainer>
107
- );
108
- });
109
-
110
- export interface DiagrammingPageProps {
111
- diagramType: DiagramTypes;
112
- onChange?: OnChangeEventHandler;
113
- defaultNodes: ICardNode[];
114
- defaultEdges: Edge[];
115
- children?: React.ReactNode;
116
- workflowNodeContent?: WorkflowNodeContentType;
117
- renderAddNodeView?: RenderAddNodeViewType;
118
- getDefaultNodeData?: GetDefaultNodeDataType;
119
- availableFunctions: FunctionSignature[];
120
- availableVariables?: AvailableVariable[];
121
- id: number;
122
- className?: string;
123
- conditionBuilderStates?: ConditionBuilderState;
124
- // New: emit node selection to host app
125
- onNodeSelect?: (payload: { nodeId: string; type?: string; data?: any }) => void;
126
- // New: allow host to disable library JSON popovers/drawers
127
- enableNodeJsonPopover?: boolean;
128
- // New: control visibility of automation execution panel
129
- showAutomationExecutionPanel?: boolean;
130
- }
131
-
132
- export const DiagrammingPage = forwardRef<DiagrammingPageRef, DiagrammingPageProps>(({
133
- diagramType,
134
- defaultNodes,
135
- defaultEdges,
136
- onChange,
137
- children,
138
- workflowNodeContent,
139
- renderAddNodeView,
140
- getDefaultNodeData,
141
- availableFunctions,
142
- availableVariables,
143
- id,
144
- className,
145
- conditionBuilderStates,
146
- onNodeSelect: onNodeSelectProp,
147
- enableNodeJsonPopover: enableNodeJsonPopoverProp,
148
- showAutomationExecutionPanel
149
- }, ref) => {
150
- return (
151
- <ThemeProvider theme={theme}>
152
- <CssBaseline />
153
-
154
- <DiagramStoreProvider
155
- id={id}
156
- availableFunctions={availableFunctions}
157
- availableVariables={availableVariables}
158
- defaultNodes={defaultNodes} // Pass defaultNodes to the context
159
- defaultEdges={defaultEdges} // Pass defaultEdges to the context
160
- diagramType={diagramType} // Pass diagramType to the context
161
- onChange={onChange} // Pass onChange to the context
162
- workflowNodeContent={workflowNodeContent} // Pass workflowNodeContent to the context
163
- renderAddNodeView={renderAddNodeView} // Pass workflowNodeContent to the context
164
- getDefaultNodeData={getDefaultNodeData}
165
- conditionBuilderStates={conditionBuilderStates}
166
- onNodeSelect={onNodeSelectProp}
167
- enableNodeJsonPopover={enableNodeJsonPopoverProp}
168
- >
169
- {/* Variable registration handler */}
170
- <VariableRegistrationHandler />
171
-
172
- <DiagrammingPageInternal ref={ref} className={className} showAutomationExecutionPanel={showAutomationExecutionPanel}>
173
- {children}
174
- </DiagrammingPageInternal>
175
- </DiagramStoreProvider>
176
- </ThemeProvider>
177
- );
178
- });
1
+ import { CssBaseline, ThemeProvider } from '@mui/material';
2
+ import React, { forwardRef, useImperativeHandle, useEffect } from 'react';
3
+ import { Edge, Background, BackgroundVariant, Node } from '@xyflow/react';
4
+ import FloatingConnectionLine from '../atoms/FloatingConnectionLine';
5
+ import { DiagramStoreProvider, useDiagram } from '../contexts/DiagramProvider';
6
+ import { theme } from '../theme';
7
+ import { ICardNode } from '../types/card-node';
8
+ import DiagramTypes from '../types/diagram-types';
9
+ import edgeTypes, { defaultEdgeOptions } from '../types/edge-types';
10
+ import nodeTypes from '../types/node-types';
11
+ import { useAutoRegisterVariables } from '../hooks/useAutoRegisterVariables';
12
+ import { orderNodesByEdges, NodeOrderResult } from '../utils/nodeOrderByEdges';
13
+
14
+ import {
15
+ ConditionBuilderState,
16
+ GetDefaultNodeDataType,
17
+ OnChangeEventHandler,
18
+ RenderAddNodeViewType,
19
+ WorkflowNodeContentType,
20
+ } from '../contexts/diagramStoreTypes';
21
+ import { DiagramContainer } from './DiagramContainer';
22
+ import { FunctionSignature } from '../types/FunctionSignature';
23
+ import { AvailableVariable } from '../types/available-variables';
24
+
25
+ // Component that handles variable registration
26
+ const VariableRegistrationHandler: React.FC = () => {
27
+ useAutoRegisterVariables();
28
+ return null;
29
+ };
30
+
31
+ // Interface for the ref methods
32
+ export interface DiagrammingPageRef {
33
+ undo: () => void;
34
+ redo: () => void;
35
+ canUndo: () => boolean;
36
+ canRedo: () => boolean;
37
+ reset: () => void;
38
+ getHistoryLength: () => number;
39
+ getHistoryIndex: () => number;
40
+ // Node data management methods
41
+ getNodeData: (nodeId: string) => any | null;
42
+ updateNodeData: (nodeId: string, data: any) => boolean;
43
+ getSelectedNode: () => string | null;
44
+ getNodes: () => any[];
45
+ getEdges: () => any[];
46
+ // Get ordered nodes based on edge connections (arrow direction)
47
+ getNodeOrder: () => NodeOrderResult;
48
+ }
49
+
50
+ // Internal component that exposes undo/redo functionality
51
+ const DiagrammingPageInternal = forwardRef<DiagrammingPageRef, {
52
+ children?: React.ReactNode;
53
+ className?: string;
54
+ showAutomationExecutionPanel?: boolean;
55
+ onNodeOrderChange?: (nodeOrder: NodeOrderResult) => void;
56
+ }>(({ children, className, showAutomationExecutionPanel, onNodeOrderChange }, ref) => {
57
+ const undo = useDiagram((state) => state.undo);
58
+ const redo = useDiagram((state) => state.redo);
59
+ const reset = useDiagram((state) => state.reset);
60
+ const history = useDiagram((state) => state.history);
61
+ const historyIndex = useDiagram((state) => state.historyIndex);
62
+ const nodes = useDiagram((state) => state.nodes);
63
+ const edges = useDiagram((state) => state.edges);
64
+ const selectedNode = useDiagram((state) => state.selectedNode);
65
+ const setNodes = useDiagram((state) => state.setNodes);
66
+
67
+ // Send node order to parent project whenever nodes/edges change
68
+ useEffect(() => {
69
+ if (edges.length > 0) {
70
+ // Get only nodes that are connected by edges (exclude orphan nodes)
71
+ const nodeOrder = orderNodesByEdges(nodes, edges, { includeOrphanNodes: false });
72
+
73
+ // Get only connected nodes (nodes that appear in edges)
74
+ const connectedNodeIds = new Set<string>();
75
+ edges.forEach((edge) => {
76
+ connectedNodeIds.add(edge.source);
77
+ connectedNodeIds.add(edge.target);
78
+ });
79
+
80
+ // Filter ordered nodes to only include connected ones
81
+ const connectedOrderedNodes = nodeOrder.orderedNodes.filter(
82
+ (node) => connectedNodeIds.has(node.id)
83
+ );
84
+
85
+ // Print node structure to console
86
+ console.log('\n========== NODE ORDER BY EDGES ==========');
87
+ console.log('\nšŸ“‹ CONNECTED NODES ORDER (following arrows):');
88
+ connectedOrderedNodes.forEach((node, index) => {
89
+ console.log(` ${index + 1}. [${node.type || 'unknown'}] ${node.id}`);
90
+ });
91
+
92
+ console.log('\n🟢 START NODE:', nodeOrder.startNodes[0]?.id || '(none)');
93
+ console.log('šŸ”“ END NODE:', nodeOrder.endNodes[0]?.id || '(none)');
94
+
95
+ console.log('\nšŸ”— EDGE ORDER:');
96
+ edges.forEach((edge, index) => {
97
+ console.log(` ${index + 1}. ${edge.source} ──→ ${edge.target}`);
98
+ });
99
+
100
+ console.log('\nšŸ“Š TOTAL CONNECTED NODES:', connectedOrderedNodes.length);
101
+ console.log('==========================================\n');
102
+
103
+ // Create updated result with only connected nodes
104
+ const connectedNodeOrder: NodeOrderResult = {
105
+ ...nodeOrder,
106
+ orderedNodes: connectedOrderedNodes,
107
+ };
108
+
109
+ // Send to parent project if callback provided
110
+ if (onNodeOrderChange) {
111
+ onNodeOrderChange(connectedNodeOrder);
112
+ }
113
+ }
114
+ }, [nodes, edges, onNodeOrderChange]);
115
+
116
+ useImperativeHandle(ref, () => ({
117
+ undo,
118
+ redo,
119
+ canUndo: () => historyIndex > 0,
120
+ canRedo: () => historyIndex < history.length - 1,
121
+ reset,
122
+ getHistoryLength: () => history.length,
123
+ getHistoryIndex: () => historyIndex,
124
+ // Node data management methods
125
+ getNodeData: (nodeId: string) => {
126
+ const node = nodes.find(n => n.id === nodeId);
127
+ return node ? node.data : null;
128
+ },
129
+ updateNodeData: (nodeId: string, newData: any) => {
130
+ const nodeIndex = nodes.findIndex(n => n.id === nodeId);
131
+ if (nodeIndex === -1) return false;
132
+
133
+ const updatedNodes = [...nodes];
134
+ updatedNodes[nodeIndex] = {
135
+ ...updatedNodes[nodeIndex],
136
+ data: { ...updatedNodes[nodeIndex].data, ...newData }
137
+ };
138
+ setNodes(updatedNodes);
139
+ return true;
140
+ },
141
+ getSelectedNode: () => selectedNode,
142
+ getNodes: () => nodes,
143
+ getEdges: () => edges,
144
+ // Get ordered nodes based on edge connections
145
+ getNodeOrder: () => orderNodesByEdges(nodes, edges),
146
+ }));
147
+
148
+ return (
149
+ <DiagramContainer
150
+ defaultEdgeOptions={defaultEdgeOptions}
151
+ edgeTypes={edgeTypes}
152
+ nodeTypes={nodeTypes as any}
153
+ connectionLineComponent={FloatingConnectionLine}
154
+ style={{ backgroundColor: '#141519' }}
155
+ className={className}
156
+ showAutomationExecutionPanel={showAutomationExecutionPanel}
157
+ >
158
+ <Background
159
+ color="#ffffff"
160
+ variant={BackgroundVariant.Dots}
161
+ gap={20}
162
+ size={1}
163
+ />
164
+ {children}
165
+ </DiagramContainer>
166
+ );
167
+ });
168
+
169
+ export interface DiagrammingPageProps {
170
+ diagramType: DiagramTypes;
171
+ onChange?: OnChangeEventHandler;
172
+ defaultNodes: ICardNode[];
173
+ defaultEdges: Edge[];
174
+ children?: React.ReactNode;
175
+ workflowNodeContent?: WorkflowNodeContentType;
176
+ renderAddNodeView?: RenderAddNodeViewType;
177
+ getDefaultNodeData?: GetDefaultNodeDataType;
178
+ availableFunctions: FunctionSignature[];
179
+ availableVariables?: AvailableVariable[];
180
+ id: number;
181
+ className?: string;
182
+ conditionBuilderStates?: ConditionBuilderState;
183
+ // New: emit node selection to host app
184
+ onNodeSelect?: (payload: { nodeId: string; type?: string; data?: any }) => void;
185
+ // New: allow host to disable library JSON popovers/drawers
186
+ enableNodeJsonPopover?: boolean;
187
+ // New: control visibility of automation execution panel
188
+ showAutomationExecutionPanel?: boolean;
189
+ // New: callback to receive node order based on arrow/edge connections
190
+ onNodeOrderChange?: (nodeOrder: NodeOrderResult) => void;
191
+ }
192
+
193
+ export const DiagrammingPage = forwardRef<DiagrammingPageRef, DiagrammingPageProps>(({
194
+ diagramType,
195
+ defaultNodes,
196
+ defaultEdges,
197
+ onChange,
198
+ children,
199
+ workflowNodeContent,
200
+ renderAddNodeView,
201
+ getDefaultNodeData,
202
+ availableFunctions,
203
+ availableVariables,
204
+ id,
205
+ className,
206
+ conditionBuilderStates,
207
+ onNodeSelect: onNodeSelectProp,
208
+ enableNodeJsonPopover: enableNodeJsonPopoverProp,
209
+ showAutomationExecutionPanel,
210
+ onNodeOrderChange
211
+ }, ref) => {
212
+ return (
213
+ <ThemeProvider theme={theme}>
214
+ <CssBaseline />
215
+
216
+ <DiagramStoreProvider
217
+ id={id}
218
+ availableFunctions={availableFunctions}
219
+ availableVariables={availableVariables}
220
+ defaultNodes={defaultNodes} // Pass defaultNodes to the context
221
+ defaultEdges={defaultEdges} // Pass defaultEdges to the context
222
+ diagramType={diagramType} // Pass diagramType to the context
223
+ onChange={onChange} // Pass onChange to the context
224
+ workflowNodeContent={workflowNodeContent} // Pass workflowNodeContent to the context
225
+ renderAddNodeView={renderAddNodeView} // Pass workflowNodeContent to the context
226
+ getDefaultNodeData={getDefaultNodeData}
227
+ conditionBuilderStates={conditionBuilderStates}
228
+ onNodeSelect={onNodeSelectProp}
229
+ enableNodeJsonPopover={enableNodeJsonPopoverProp}
230
+ >
231
+ {/* Variable registration handler */}
232
+ <VariableRegistrationHandler />
233
+
234
+ <DiagrammingPageInternal
235
+ ref={ref}
236
+ className={className}
237
+ showAutomationExecutionPanel={showAutomationExecutionPanel}
238
+ onNodeOrderChange={onNodeOrderChange}
239
+ >
240
+ {children}
241
+ </DiagrammingPageInternal>
242
+ </DiagramStoreProvider>
243
+ </ThemeProvider>
244
+ );
245
+ });