pict-section-flow 1.4.0 → 2.0.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.
Files changed (164) hide show
  1. package/package.json +7 -2
  2. package/source/Pict-Section-Flow.js +20 -14
  3. package/source/providers/PictProvider-Flow-Background.js +303 -0
  4. package/source/providers/PictProvider-Flow-CSS.js +73 -7
  5. package/source/providers/PictProvider-Flow-Geometry.js +11 -421
  6. package/source/providers/PictProvider-Flow-Icons.js +12 -0
  7. package/source/providers/PictProvider-Flow-Layouts.js +107 -0
  8. package/source/services/PictService-Flow-ConnectionRenderer.js +1 -1
  9. package/source/services/PictService-Flow-CursorManager.js +113 -0
  10. package/source/services/PictService-Flow-InteractionManager.js +439 -59
  11. package/source/services/PictService-Flow-Layout.js +21 -16
  12. package/source/services/PictService-Flow-PathGenerator.js +30 -417
  13. package/source/services/PictService-Flow-RenderManager.js +9 -1
  14. package/source/services/PictService-Flow-ViewportManager.js +102 -0
  15. package/source/views/PictView-Flow-FloatingToolbar.js +5 -1
  16. package/source/views/PictView-Flow-Node.js +29 -0
  17. package/source/views/PictView-Flow-Toolbar.js +50 -3
  18. package/source/views/PictView-Flow.js +591 -2
  19. package/.claude/launch.json +0 -11
  20. package/docs/.nojekyll +0 -0
  21. package/docs/Architecture.md +0 -163
  22. package/docs/Custom-Styling.md +0 -275
  23. package/docs/Data_Model.md +0 -149
  24. package/docs/Event_System.md +0 -156
  25. package/docs/Getting_Started.md +0 -237
  26. package/docs/Implementation_Reference.md +0 -528
  27. package/docs/Layout_Persistence.md +0 -117
  28. package/docs/README.md +0 -103
  29. package/docs/Theme_Integration.md +0 -150
  30. package/docs/_brand.json +0 -18
  31. package/docs/_cover.md +0 -17
  32. package/docs/_playground.json +0 -24
  33. package/docs/_sidebar.md +0 -57
  34. package/docs/_topbar.md +0 -8
  35. package/docs/_version.json +0 -7
  36. package/docs/api/PictFlowCard.md +0 -216
  37. package/docs/api/PictFlowCardPropertiesPanel.md +0 -235
  38. package/docs/api/addConnection.md +0 -101
  39. package/docs/api/addNode.md +0 -137
  40. package/docs/api/autoLayout.md +0 -77
  41. package/docs/api/getFlowData.md +0 -112
  42. package/docs/api/marshalToView.md +0 -95
  43. package/docs/api/openPanel.md +0 -128
  44. package/docs/api/registerHandler.md +0 -174
  45. package/docs/api/registerNodeType.md +0 -142
  46. package/docs/api/removeConnection.md +0 -57
  47. package/docs/api/removeNode.md +0 -80
  48. package/docs/api/saveLayout.md +0 -152
  49. package/docs/api/screenToSVGCoords.md +0 -68
  50. package/docs/api/selectNode.md +0 -116
  51. package/docs/api/setTheme.md +0 -168
  52. package/docs/api/setZoom.md +0 -97
  53. package/docs/api/toggleFullscreen.md +0 -68
  54. package/docs/card-help/EACH.md +0 -19
  55. package/docs/card-help/FREAD.md +0 -24
  56. package/docs/card-help/FWRITE.md +0 -24
  57. package/docs/card-help/GET.md +0 -22
  58. package/docs/card-help/ITE.md +0 -23
  59. package/docs/card-help/LOG.md +0 -23
  60. package/docs/card-help/NOTE.md +0 -17
  61. package/docs/card-help/PREV.md +0 -18
  62. package/docs/card-help/SET.md +0 -27
  63. package/docs/card-help/SPKL.md +0 -22
  64. package/docs/card-help/STAT.md +0 -23
  65. package/docs/card-help/SW.md +0 -25
  66. package/docs/diagrams/architecture-at-a-glance.excalidraw +0 -4270
  67. package/docs/diagrams/architecture-at-a-glance.mmd +0 -30
  68. package/docs/diagrams/architecture-at-a-glance.svg +0 -2
  69. package/docs/diagrams/data-flow.excalidraw +0 -1451
  70. package/docs/diagrams/data-flow.mmd +0 -17
  71. package/docs/diagrams/data-flow.svg +0 -2
  72. package/docs/diagrams/high-level-design.excalidraw +0 -5767
  73. package/docs/diagrams/high-level-design.mmd +0 -86
  74. package/docs/diagrams/high-level-design.svg +0 -2
  75. package/docs/diagrams/relationships.excalidraw +0 -3852
  76. package/docs/diagrams/relationships.mmd +0 -9
  77. package/docs/diagrams/relationships.svg +0 -2
  78. package/docs/diagrams/service-initialization-sequence.excalidraw +0 -1466
  79. package/docs/diagrams/service-initialization-sequence.mmd +0 -19
  80. package/docs/diagrams/service-initialization-sequence.svg +0 -2
  81. package/docs/diagrams/svg-layer-structure.excalidraw +0 -1060
  82. package/docs/diagrams/svg-layer-structure.mmd +0 -18
  83. package/docs/diagrams/svg-layer-structure.svg +0 -2
  84. package/docs/examples/README.md +0 -9
  85. package/docs/examples/simple_cards/README.md +0 -677
  86. package/docs/examples/simple_cards/css/flowexample.css +0 -65
  87. package/docs/examples/simple_cards/index.html +0 -32
  88. package/docs/examples/simple_cards/js/pict.min.js +0 -12
  89. package/docs/examples/simple_cards/pict-section-flow-example-simple-cards.compatible.min.js +0 -1
  90. package/docs/index.html +0 -38
  91. package/docs/playground/app.json +0 -6
  92. package/docs/playground/appdata.json +0 -85
  93. package/docs/playground/application.js +0 -23
  94. package/docs/playground/pict.json +0 -17
  95. package/docs/playground/runtime/pict-application.min.js +0 -2
  96. package/docs/playground/runtime/pict-section-flow.min.js +0 -2
  97. package/docs/playground/runtime/pict-section-modal.min.js +0 -2
  98. package/docs/playground/runtime/pict.min.js +0 -12
  99. package/docs/retold-catalog.json +0 -244
  100. package/docs/retold-keyword-index.json +0 -26028
  101. package/example_applications/simple_cards/css/flowexample.css +0 -65
  102. package/example_applications/simple_cards/html/index.html +0 -32
  103. package/example_applications/simple_cards/package.json +0 -52
  104. package/example_applications/simple_cards/source/Pict-Application-FlowExample-Configuration.json +0 -15
  105. package/example_applications/simple_cards/source/Pict-Application-FlowExample.js +0 -539
  106. package/example_applications/simple_cards/source/card-help-content.js +0 -16
  107. package/example_applications/simple_cards/source/cards/FlowCard-Comment.js +0 -38
  108. package/example_applications/simple_cards/source/cards/FlowCard-DataPreview.js +0 -44
  109. package/example_applications/simple_cards/source/cards/FlowCard-Each.js +0 -38
  110. package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +0 -56
  111. package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +0 -50
  112. package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +0 -37
  113. package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +0 -49
  114. package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +0 -55
  115. package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +0 -97
  116. package/example_applications/simple_cards/source/cards/FlowCard-Sparkline.js +0 -100
  117. package/example_applications/simple_cards/source/cards/FlowCard-StatusMonitor.js +0 -46
  118. package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +0 -39
  119. package/example_applications/simple_cards/source/providers/PictRouter-FlowExample-Configuration.json +0 -22
  120. package/example_applications/simple_cards/source/sample-flows.js +0 -410
  121. package/example_applications/simple_cards/source/views/PictView-FlowExample-About.js +0 -184
  122. package/example_applications/simple_cards/source/views/PictView-FlowExample-BottomBar.js +0 -77
  123. package/example_applications/simple_cards/source/views/PictView-FlowExample-Documentation.js +0 -325
  124. package/example_applications/simple_cards/source/views/PictView-FlowExample-FileWriteInfo.js +0 -59
  125. package/example_applications/simple_cards/source/views/PictView-FlowExample-Layout.js +0 -90
  126. package/example_applications/simple_cards/source/views/PictView-FlowExample-MainWorkspace.js +0 -453
  127. package/example_applications/simple_cards/source/views/PictView-FlowExample-TopBar.js +0 -95
  128. package/scripts/generate-card-help.js +0 -214
  129. package/source/providers/edges/Edge-Bezier.js +0 -41
  130. package/source/providers/edges/Edge-Orthogonal.js +0 -37
  131. package/source/providers/edges/Edge-OrthogonalSnap.js +0 -72
  132. package/source/providers/edges/Edge-Perimeter-Linear.js +0 -31
  133. package/source/providers/edges/Edge-Perimeter-Orthogonal.js +0 -39
  134. package/source/providers/edges/Edge-Perimeter.js +0 -48
  135. package/source/providers/edges/Edge-PerimeterMath.js +0 -92
  136. package/source/providers/edges/Edge-Straight.js +0 -24
  137. package/source/providers/layouts/Layout-Circular.js +0 -203
  138. package/source/providers/layouts/Layout-Coerce.js +0 -40
  139. package/source/providers/layouts/Layout-Columnar.js +0 -134
  140. package/source/providers/layouts/Layout-Custom.js +0 -27
  141. package/source/providers/layouts/Layout-ForcedFromCenter.js +0 -256
  142. package/source/providers/layouts/Layout-Grid.js +0 -134
  143. package/source/providers/layouts/Layout-Layered.js +0 -155
  144. package/source/providers/layouts/Layout-Rank.js +0 -141
  145. package/source/providers/layouts/Layout-Staggered.js +0 -131
  146. package/source/providers/layouts/Layout-Tabular.js +0 -94
  147. package/test/CardPalette_tests.js +0 -43
  148. package/test/ConnectionHandleManager_tests.js +0 -717
  149. package/test/ConnectionRenderer_tests.js +0 -591
  150. package/test/ConnectionStyle_tests.js +0 -90
  151. package/test/DataManager_tests.js +0 -859
  152. package/test/Geometry_tests.js +0 -767
  153. package/test/InteractionManager_tests.js +0 -279
  154. package/test/Layout_tests.js +0 -1604
  155. package/test/NodeView_tests.js +0 -66
  156. package/test/PanelManager_tests.js +0 -172
  157. package/test/PathGenerator_tests.js +0 -978
  158. package/test/PortRenderer_tests.js +0 -376
  159. package/test/RenderManager_tests.js +0 -756
  160. package/test/Renderer_tests.js +0 -133
  161. package/test/SelectionManager_tests.js +0 -185
  162. package/test/StylePresets_tests.js +0 -153
  163. package/test/ToolbarExtraButtons_tests.js +0 -138
  164. package/test/UndirectedConnections_tests.js +0 -70
@@ -1,235 +0,0 @@
1
- # PictFlowCardPropertiesPanel
2
-
3
- Base class for flow card property panels. Extend this class to create custom panel types beyond the four built-in types (Template, Markdown, Form, View).
4
-
5
- ## Import
6
-
7
- ```javascript
8
- const libPictFlowCardPropertiesPanel = require('pict-section-flow').PictFlowCardPropertiesPanel;
9
- ```
10
-
11
- ## Constructor
12
-
13
- ```javascript
14
- class MyPanel extends libPictFlowCardPropertiesPanel
15
- {
16
- constructor(pFable, pOptions, pServiceHash)
17
- {
18
- super(pFable, Object.assign({},
19
- {
20
- PanelType: 'Custom',
21
- Title: 'My Panel',
22
- Width: 300,
23
- Height: 200,
24
- Configuration: {}
25
- }, pOptions), pServiceHash);
26
- }
27
- }
28
- ```
29
-
30
- ## Configuration Options
31
-
32
- | Property | Type | Default | Description |
33
- |----------|------|---------|-------------|
34
- | `PanelType` | string | `'Base'` | Panel type identifier |
35
- | `Title` | string | `'Properties'` | Panel title bar text |
36
- | `Width` | number | `300` | Default width in pixels |
37
- | `Height` | number | `200` | Default height in pixels |
38
- | `Configuration` | object | `{}` | Panel-type-specific config |
39
-
40
- ## Methods to Override
41
-
42
- ### render(pContainer, pNodeData)
43
-
44
- Render the panel's content into a DOM container element. Subclasses **must** override this.
45
-
46
- | Parameter | Type | Description |
47
- |-----------|------|-------------|
48
- | `pContainer` | HTMLElement | The DOM element to render into |
49
- | `pNodeData` | object | The node data object (has `.Data` property) |
50
-
51
- ### marshalToPanel(pNodeData)
52
-
53
- Marshal data from the node's Data object into the panel UI. Called when the panel opens or when data changes externally.
54
-
55
- | Parameter | Type | Description |
56
- |-----------|------|-------------|
57
- | `pNodeData` | object | The node data object |
58
-
59
- ### marshalFromPanel(pNodeData)
60
-
61
- Marshal data from the panel UI into the node's Data object. Called before saving or when the panel is about to close.
62
-
63
- | Parameter | Type | Description |
64
- |-----------|------|-------------|
65
- | `pNodeData` | object | The node data object to update |
66
-
67
- ### destroy()
68
-
69
- Called when the panel is being closed. Clean up resources, event listeners, etc.
70
-
71
- ## Internal Properties
72
-
73
- | Property | Type | Description |
74
- |----------|------|-------------|
75
- | `this._FlowView` | PictViewFlow | Reference to the flow view (set when panel is activated) |
76
- | `this._NodeData` | object | The node data this panel is operating on |
77
- | `this._ContentContainer` | HTMLElement | The DOM container element |
78
- | `this._Configuration` | object | Panel-type-specific configuration |
79
-
80
- ## Built-in Panel Types
81
-
82
- ### Template
83
-
84
- Renders Pict templates inside the panel.
85
-
86
- ```javascript
87
- {
88
- PanelType: 'Template',
89
- Configuration:
90
- {
91
- Templates:
92
- [
93
- {
94
- Hash: 'my-template',
95
- Template: '<div class="info">{~D:Record.Data.Label~}</div>'
96
- }
97
- ],
98
- TemplateHash: 'my-template'
99
- }
100
- }
101
- ```
102
-
103
- ### Markdown
104
-
105
- Renders markdown content via `pict-section-content`.
106
-
107
- ```javascript
108
- {
109
- PanelType: 'Markdown',
110
- Configuration:
111
- {
112
- Markdown: '## Help\nThis node reads a file from disk.\n\n**Inputs:** File path\n**Outputs:** File contents or error'
113
- }
114
- }
115
- ```
116
-
117
- ### Form
118
-
119
- Creates an ephemeral `pict-section-form` section.
120
-
121
- ```javascript
122
- {
123
- PanelType: 'Form',
124
- Configuration:
125
- {
126
- Fields:
127
- [
128
- { Name: 'FilePath', DataType: 'String' },
129
- { Name: 'Encoding', DataType: 'String' },
130
- { Name: 'MaxSize', DataType: 'Number' }
131
- ]
132
- }
133
- }
134
- ```
135
-
136
- ### View
137
-
138
- Renders an existing registered Pict view inside the panel.
139
-
140
- ```javascript
141
- {
142
- PanelType: 'View',
143
- Configuration:
144
- {
145
- ViewHash: 'my-custom-view'
146
- }
147
- }
148
- ```
149
-
150
- ## Examples
151
-
152
- ### Custom chart panel
153
-
154
- ```javascript
155
- class ChartPanel extends libPictFlowCardPropertiesPanel
156
- {
157
- constructor(pFable, pOptions, pServiceHash)
158
- {
159
- super(pFable, Object.assign({},
160
- {
161
- PanelType: 'Chart',
162
- Title: 'Data Preview',
163
- Width: 400,
164
- Height: 300
165
- }, pOptions), pServiceHash);
166
-
167
- this._ChartInstance = null;
168
- }
169
-
170
- render(pContainer, pNodeData)
171
- {
172
- super.render(pContainer, pNodeData);
173
-
174
- let tmpCanvas = document.createElement('canvas');
175
- tmpCanvas.width = 380;
176
- tmpCanvas.height = 260;
177
- pContainer.appendChild(tmpCanvas);
178
-
179
- // Create chart from node data
180
- this._ChartInstance = new Chart(tmpCanvas,
181
- {
182
- type: 'line',
183
- data: pNodeData.Data.ChartData || { labels: [], datasets: [] }
184
- });
185
- }
186
-
187
- marshalToPanel(pNodeData)
188
- {
189
- super.marshalToPanel(pNodeData);
190
- if (this._ChartInstance && pNodeData.Data.ChartData)
191
- {
192
- this._ChartInstance.data = pNodeData.Data.ChartData;
193
- this._ChartInstance.update();
194
- }
195
- }
196
-
197
- destroy()
198
- {
199
- if (this._ChartInstance)
200
- {
201
- this._ChartInstance.destroy();
202
- this._ChartInstance = null;
203
- }
204
- super.destroy();
205
- }
206
- }
207
- ```
208
-
209
- ### Using a custom panel in a card
210
-
211
- ```javascript
212
- class DataPreviewCard extends libPictFlowCard
213
- {
214
- constructor(pFable, pOptions, pServiceHash)
215
- {
216
- super(pFable, Object.assign({},
217
- {
218
- Title: 'Data Preview',
219
- Code: 'DPRV',
220
- PropertiesPanel:
221
- {
222
- PanelType: 'Chart',
223
- Title: 'Preview',
224
- DefaultWidth: 400,
225
- DefaultHeight: 300
226
- }
227
- }, pOptions), pServiceHash);
228
- }
229
- }
230
- ```
231
-
232
- ## See Also
233
-
234
- - [PictFlowCard](PictFlowCard.md) -- Define cards that use panels
235
- - [openPanel / closePanel](openPanel.md) -- Panel lifecycle methods
@@ -1,101 +0,0 @@
1
- # addConnection
2
-
3
- Connect two ports on the flow canvas. Creates a visual line between the source port (typically an output) and the target port (typically an input). The connection is validated before creation.
4
-
5
- ## Signature
6
-
7
- ```javascript
8
- flowView.addConnection(pSourceNode, pSourcePort, pTargetNode, pTargetPort, pData)
9
- ```
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Description |
14
- |-----------|------|----------|-------------|
15
- | `pSourceNode` | string | Yes | Hash of the source node |
16
- | `pSourcePort` | string | Yes | Hash of the source port |
17
- | `pTargetNode` | string | Yes | Hash of the target node |
18
- | `pTargetPort` | string | Yes | Hash of the target port |
19
- | `pData` | object | No | Optional connection metadata |
20
-
21
- ### Connection Data Options
22
-
23
- | Property | Type | Default | Description |
24
- |----------|------|---------|-------------|
25
- | `LineMode` | string | `'bezier'` | Path style: `'bezier'` or `'orthogonal'` |
26
-
27
- ## Returns
28
-
29
- The connection object on success, or `false` if validation failed (e.g. duplicate connection, self-connection, or port not found).
30
-
31
- ```javascript
32
- {
33
- Hash: 'conn-x1y2z3',
34
- SourceNodeHash: 'node-a1b2',
35
- SourcePortHash: 'port-c3d4',
36
- TargetNodeHash: 'node-e5f6',
37
- TargetPortHash: 'port-g7h8',
38
- Data:
39
- {
40
- LineMode: 'bezier',
41
- HandleCustomized: false
42
- }
43
- }
44
- ```
45
-
46
- ## Events Fired
47
-
48
- - `onConnectionCreated` -- with the new connection object
49
- - `onFlowChanged` -- with the complete flow data
50
-
51
- ## Examples
52
-
53
- ### Basic connection
54
-
55
- ```javascript
56
- let tmpStart = flowView.addNode('start', 50, 150, 'Begin');
57
- let tmpEnd = flowView.addNode('end', 400, 150, 'Done');
58
-
59
- let tmpOutPort = tmpStart.Ports.find((pPort) => pPort.Direction === 'output');
60
- let tmpInPort = tmpEnd.Ports.find((pPort) => pPort.Direction === 'input');
61
-
62
- let tmpConn = flowView.addConnection(
63
- tmpStart.Hash, tmpOutPort.Hash,
64
- tmpEnd.Hash, tmpInPort.Hash
65
- );
66
-
67
- console.log(tmpConn.Hash); // 'conn-...'
68
- ```
69
-
70
- ### Orthogonal connection
71
-
72
- ```javascript
73
- let tmpConn = flowView.addConnection(
74
- tmpA.Hash, tmpOutPort.Hash,
75
- tmpB.Hash, tmpInPort.Hash,
76
- { LineMode: 'orthogonal' }
77
- );
78
- ```
79
-
80
- ### Decision node branching
81
-
82
- ```javascript
83
- let tmpDecision = flowView.addNode('decision', 200, 150, 'Check Status');
84
- let tmpSuccess = flowView.addNode('default', 400, 50, 'Handle Success');
85
- let tmpFailure = flowView.addNode('halt', 400, 250, 'Handle Error');
86
-
87
- // Find the Yes and No output ports on the decision node
88
- let tmpYesPort = tmpDecision.Ports.find((pPort) => pPort.Label === 'Yes');
89
- let tmpNoPort = tmpDecision.Ports.find((pPort) => pPort.Label === 'No');
90
-
91
- let tmpSuccessIn = tmpSuccess.Ports.find((pPort) => pPort.Direction === 'input');
92
- let tmpFailureIn = tmpFailure.Ports.find((pPort) => pPort.Direction === 'input');
93
-
94
- flowView.addConnection(tmpDecision.Hash, tmpYesPort.Hash, tmpSuccess.Hash, tmpSuccessIn.Hash);
95
- flowView.addConnection(tmpDecision.Hash, tmpNoPort.Hash, tmpFailure.Hash, tmpFailureIn.Hash);
96
- ```
97
-
98
- ## See Also
99
-
100
- - [removeConnection](removeConnection.md) -- Delete a connection
101
- - [addNode](addNode.md) -- Create nodes to connect
@@ -1,137 +0,0 @@
1
- # addNode
2
-
3
- Create a new node on the flow canvas. The node is added to the flow data, assigned a UUID hash, populated with default ports from the node type definition, and the canvas is re-rendered.
4
-
5
- ## Signature
6
-
7
- ```javascript
8
- flowView.addNode(pType, pX, pY, pTitle, pData)
9
- ```
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Description |
14
- |-----------|------|----------|-------------|
15
- | `pType` | string | Yes | Node type key. Built-in types: `'start'`, `'end'`, `'halt'`, `'decision'`, `'default'`. Custom types use the `Code` from a registered `PictFlowCard`. |
16
- | `pX` | number | Yes | X coordinate in SVG space |
17
- | `pY` | number | Yes | Y coordinate in SVG space |
18
- | `pTitle` | string | Yes | Display title shown on the node's title bar |
19
- | `pData` | object | No | Optional custom data object attached to the node's `Data` property |
20
-
21
- ## Returns
22
-
23
- The newly created node object:
24
-
25
- ```javascript
26
- {
27
- Hash: 'node-a1b2c3d4',
28
- Type: 'start',
29
- X: 50,
30
- Y: 150,
31
- Width: 140,
32
- Height: 80,
33
- Title: 'Begin',
34
- Ports:
35
- [
36
- {
37
- Hash: 'port-e5f6g7h8',
38
- Direction: 'output',
39
- Side: 'right',
40
- Label: 'Out'
41
- }
42
- ],
43
- Data: {}
44
- }
45
- ```
46
-
47
- ## Events Fired
48
-
49
- - `onNodeAdded` -- with the new node object
50
- - `onFlowChanged` -- with the complete flow data
51
-
52
- ## Examples
53
-
54
- ### Basic usage
55
-
56
- ```javascript
57
- // Add a start node at position (50, 150)
58
- let tmpStart = flowView.addNode('start', 50, 150, 'Begin');
59
-
60
- // Add a processing node
61
- let tmpProcess = flowView.addNode('default', 250, 150, 'Transform Data');
62
-
63
- // Add an end node
64
- let tmpEnd = flowView.addNode('end', 450, 150, 'Done');
65
- ```
66
-
67
- ### With custom data
68
-
69
- ```javascript
70
- let tmpFileRead = flowView.addNode('FREAD', 100, 200, 'Read Config',
71
- {
72
- FilePath: '/etc/app/config.json',
73
- Encoding: 'utf-8'
74
- });
75
-
76
- console.log(tmpFileRead.Data.FilePath); // '/etc/app/config.json'
77
- ```
78
-
79
- ### Adding a decision node
80
-
81
- ```javascript
82
- let tmpDecision = flowView.addNode('decision', 300, 200, 'Is Valid?');
83
-
84
- // The decision node has three ports by default: In, Yes, No
85
- console.log(tmpDecision.Ports.length); // 3
86
- ```
87
-
88
- ### Programmatic flow construction
89
-
90
- ```javascript
91
- function buildPipeline(pFlowView, pSteps)
92
- {
93
- let tmpPreviousNode = null;
94
-
95
- for (let i = 0; i < pSteps.length; i++)
96
- {
97
- let tmpNode = pFlowView.addNode(
98
- pSteps[i].Type,
99
- 100 + (i * 200),
100
- 150,
101
- pSteps[i].Title,
102
- pSteps[i].Data
103
- );
104
-
105
- if (tmpPreviousNode)
106
- {
107
- let tmpOutPort = tmpPreviousNode.Ports.find((pPort) => pPort.Direction === 'output');
108
- let tmpInPort = tmpNode.Ports.find((pPort) => pPort.Direction === 'input');
109
-
110
- if (tmpOutPort && tmpInPort)
111
- {
112
- pFlowView.addConnection(
113
- tmpPreviousNode.Hash, tmpOutPort.Hash,
114
- tmpNode.Hash, tmpInPort.Hash
115
- );
116
- }
117
- }
118
-
119
- tmpPreviousNode = tmpNode;
120
- }
121
- }
122
-
123
- buildPipeline(flowView,
124
- [
125
- { Type: 'start', Title: 'Begin' },
126
- { Type: 'FREAD', Title: 'Load Data', Data: { FilePath: '/data/input.csv' } },
127
- { Type: 'default', Title: 'Process' },
128
- { Type: 'end', Title: 'Complete' }
129
- ]);
130
- ```
131
-
132
- ## See Also
133
-
134
- - [removeNode](removeNode.md) -- Delete a node
135
- - [getFlowData](getFlowData.md) -- Retrieve the full flow state
136
- - [PictFlowCard](PictFlowCard.md) -- Define custom node types
137
- - [registerNodeType](registerNodeType.md) -- Register node types directly
@@ -1,77 +0,0 @@
1
- # autoLayout
2
-
3
- Automatically arrange all nodes in the flow using a topological sort algorithm. Nodes are positioned in columns based on their dependency order, with even vertical spacing within each column. This is useful for organizing complex flows or providing a clean starting arrangement.
4
-
5
- ## Signature
6
-
7
- ```javascript
8
- flowView.autoLayout();
9
- ```
10
-
11
- ## Parameters
12
-
13
- None.
14
-
15
- ## Behavior
16
-
17
- 1. Performs a topological sort of the node graph based on connections
18
- 2. Assigns nodes to columns (layers) based on their depth from root nodes
19
- 3. Distributes nodes evenly within each column
20
- 4. Re-renders the entire canvas
21
- 5. Optionally snaps to grid if `EnableGridSnap` is `true`
22
-
23
- Nodes with no connections are placed in a separate area to the side.
24
-
25
- ## Examples
26
-
27
- ### Basic usage
28
-
29
- ```javascript
30
- // After constructing a complex flow programmatically
31
- flowView.autoLayout();
32
- flowView.zoomToFit();
33
- ```
34
-
35
- ### Auto-layout after data load
36
-
37
- ```javascript
38
- fetch('/api/flows/my-flow')
39
- .then((pResponse) => pResponse.json())
40
- .then((pFlowData) =>
41
- {
42
- flowView.setFlowData(pFlowData);
43
- flowView.autoLayout();
44
- flowView.zoomToFit();
45
- });
46
- ```
47
-
48
- ### Layout button
49
-
50
- ```javascript
51
- document.getElementById('auto-layout-btn').addEventListener('click', () =>
52
- {
53
- flowView.autoLayout();
54
- flowView.zoomToFit();
55
- });
56
- ```
57
-
58
- ## Grid Snap
59
-
60
- When `EnableGridSnap` is `true`, the auto-layout algorithm snaps node positions to the nearest grid point based on `GridSnapSize`:
61
-
62
- ```javascript
63
- _Pict.addView('MyFlow',
64
- {
65
- EnableGridSnap: true,
66
- GridSnapSize: 20
67
- },
68
- libPictSectionFlow);
69
-
70
- // Auto-layout will snap to 20px grid
71
- flowView.autoLayout();
72
- ```
73
-
74
- ## See Also
75
-
76
- - [setZoom / zoomToFit](setZoom.md) -- Fit the result in the viewport
77
- - [saveLayout / restoreLayout](saveLayout.md) -- Persist spatial arrangements
@@ -1,112 +0,0 @@
1
- # getFlowData / setFlowData
2
-
3
- Get or replace the entire flow state. `getFlowData` returns a deep clone so mutations do not affect the live state. `setFlowData` replaces the flow data and triggers a full re-render.
4
-
5
- ## Signatures
6
-
7
- ```javascript
8
- let tmpFlowData = flowView.getFlowData();
9
- flowView.setFlowData(pFlowData);
10
- ```
11
-
12
- ## getFlowData
13
-
14
- ### Parameters
15
-
16
- None.
17
-
18
- ### Returns
19
-
20
- A deep clone of the complete flow state:
21
-
22
- ```javascript
23
- {
24
- Nodes: [ /* ... */ ],
25
- Connections: [ /* ... */ ],
26
- OpenPanels: [ /* ... */ ],
27
- SavedLayouts: [ /* ... */ ],
28
- ViewState:
29
- {
30
- PanX: 0,
31
- PanY: 0,
32
- Zoom: 1,
33
- SelectedNodeHash: null,
34
- SelectedConnectionHash: null,
35
- SelectedTetherHash: null
36
- }
37
- }
38
- ```
39
-
40
- ## setFlowData
41
-
42
- ### Parameters
43
-
44
- | Parameter | Type | Required | Description |
45
- |-----------|------|----------|-------------|
46
- | `pFlowData` | object | Yes | Complete flow data structure |
47
-
48
- ### Events Fired
49
-
50
- - `onFlowChanged` -- with the new flow data
51
-
52
- ## Examples
53
-
54
- ### Save flow state to a server
55
-
56
- ```javascript
57
- let tmpFlowData = flowView.getFlowData();
58
-
59
- fetch('/api/flows/my-flow',
60
- {
61
- method: 'PUT',
62
- headers: { 'Content-Type': 'application/json' },
63
- body: JSON.stringify(tmpFlowData)
64
- });
65
- ```
66
-
67
- ### Load flow state from a server
68
-
69
- ```javascript
70
- fetch('/api/flows/my-flow')
71
- .then((pResponse) => pResponse.json())
72
- .then((pFlowData) =>
73
- {
74
- flowView.setFlowData(pFlowData);
75
- });
76
- ```
77
-
78
- ### Clone a flow
79
-
80
- ```javascript
81
- let tmpOriginal = flowView.getFlowData();
82
-
83
- // Modify the clone without affecting the original
84
- tmpOriginal.Nodes.forEach((pNode) =>
85
- {
86
- pNode.X += 200;
87
- });
88
-
89
- flowView.setFlowData(tmpOriginal);
90
- ```
91
-
92
- ### Inspect flow statistics
93
-
94
- ```javascript
95
- let tmpData = flowView.getFlowData();
96
-
97
- console.log('Nodes:', tmpData.Nodes.length);
98
- console.log('Connections:', tmpData.Connections.length);
99
- console.log('Open Panels:', tmpData.OpenPanels.length);
100
- console.log('Saved Layouts:', tmpData.SavedLayouts.length);
101
- console.log('Zoom:', tmpData.ViewState.Zoom);
102
- ```
103
-
104
- ## Related Methods
105
-
106
- - `getNode(pNodeHash)` -- Retrieve a single node by hash
107
- - `getConnection(pConnectionHash)` -- Retrieve a single connection by hash
108
-
109
- ## See Also
110
-
111
- - [marshalToView / marshalFromView](marshalToView.md) -- AppData two-way binding
112
- - [addNode](addNode.md) -- Add individual nodes