pict-section-flow 0.0.10 → 0.0.13
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/.claude/launch.json +1 -1
- package/README.md +176 -0
- package/docs/.nojekyll +0 -0
- package/docs/Architecture.md +303 -0
- package/docs/Custom-Styling.md +275 -0
- package/docs/Data_Model.md +158 -0
- package/docs/Event_System.md +156 -0
- package/docs/Getting_Started.md +237 -0
- package/docs/Implementation_Reference.md +528 -0
- package/docs/Layout_Persistence.md +117 -0
- package/docs/README.md +115 -52
- package/docs/_cover.md +11 -0
- package/docs/_sidebar.md +52 -0
- package/docs/_topbar.md +8 -0
- package/docs/api/PictFlowCard.md +216 -0
- package/docs/api/PictFlowCardPropertiesPanel.md +235 -0
- package/docs/api/addConnection.md +101 -0
- package/docs/api/addNode.md +137 -0
- package/docs/api/autoLayout.md +77 -0
- package/docs/api/getFlowData.md +112 -0
- package/docs/api/marshalToView.md +95 -0
- package/docs/api/openPanel.md +128 -0
- package/docs/api/registerHandler.md +174 -0
- package/docs/api/registerNodeType.md +142 -0
- package/docs/api/removeConnection.md +57 -0
- package/docs/api/removeNode.md +80 -0
- package/docs/api/saveLayout.md +152 -0
- package/docs/api/screenToSVGCoords.md +68 -0
- package/docs/api/selectNode.md +116 -0
- package/docs/api/setTheme.md +168 -0
- package/docs/api/setZoom.md +97 -0
- package/docs/api/toggleFullscreen.md +68 -0
- package/docs/card-help/EACH.md +19 -0
- package/docs/card-help/FREAD.md +24 -0
- package/docs/card-help/FWRITE.md +24 -0
- package/docs/card-help/GET.md +22 -0
- package/docs/card-help/ITE.md +23 -0
- package/docs/card-help/LOG.md +23 -0
- package/docs/card-help/NOTE.md +17 -0
- package/docs/card-help/PREV.md +18 -0
- package/docs/card-help/SET.md +27 -0
- package/docs/card-help/SPKL.md +22 -0
- package/docs/card-help/STAT.md +23 -0
- package/docs/card-help/SW.md +25 -0
- package/docs/css/docuserve.css +73 -0
- package/docs/index.html +39 -0
- package/docs/retold-catalog.json +169 -0
- package/docs/retold-keyword-index.json +13942 -0
- package/example_applications/simple_cards/package.json +1 -0
- package/example_applications/simple_cards/source/card-help-content.js +16 -0
- package/example_applications/simple_cards/source/cards/FlowCard-Comment.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-DataPreview.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-Each.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-Sparkline.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-StatusMonitor.js +2 -0
- package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +2 -0
- package/package.json +11 -7
- package/scripts/generate-card-help.js +214 -0
- package/source/Pict-Section-Flow.js +4 -0
- package/source/PictFlowCard.js +3 -1
- package/source/providers/PictProvider-Flow-CSS.js +245 -152
- package/source/providers/PictProvider-Flow-ConnectorShapes.js +24 -0
- package/source/providers/PictProvider-Flow-Geometry.js +195 -38
- package/source/providers/PictProvider-Flow-PanelChrome.js +14 -12
- package/source/services/PictService-Flow-ConnectionHandleManager.js +263 -0
- package/source/services/PictService-Flow-ConnectionRenderer.js +134 -183
- package/source/services/PictService-Flow-DataManager.js +338 -0
- package/source/services/PictService-Flow-InteractionManager.js +165 -7
- package/source/services/PictService-Flow-PathGenerator.js +282 -0
- package/source/services/PictService-Flow-PortRenderer.js +269 -0
- package/source/services/PictService-Flow-RenderManager.js +281 -0
- package/source/services/PictService-Flow-Tether.js +6 -42
- package/source/views/PictView-Flow-Node.js +2 -220
- package/source/views/PictView-Flow-PropertiesPanel.js +89 -44
- package/source/views/PictView-Flow.js +130 -882
- package/test/ConnectionHandleManager_tests.js +717 -0
- package/test/ConnectionRenderer_tests.js +591 -0
- package/test/DataManager_tests.js +859 -0
- package/test/Geometry_tests.js +767 -0
- package/test/PathGenerator_tests.js +978 -0
- package/test/PortRenderer_tests.js +367 -0
- package/test/RenderManager_tests.js +756 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This guide walks you through creating a flow diagram from scratch — installing the package, registering a view, adding nodes and connections, and wiring up custom card types.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 16+
|
|
8
|
+
- A Pict application (or willingness to create one)
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install pict-section-flow
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If you are building for the browser, also install the build tool:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev quackage
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Step 1: Create a Pict Application
|
|
23
|
+
|
|
24
|
+
If you do not already have a Pict application, create a minimal one:
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const libPict = require('pict');
|
|
28
|
+
|
|
29
|
+
let _Pict = new libPict(
|
|
30
|
+
{
|
|
31
|
+
Product: 'FlowDemo',
|
|
32
|
+
ProductVersion: '1.0.0'
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Step 2: Register the Flow View
|
|
37
|
+
|
|
38
|
+
Pict-Section-Flow exports a View class. Register it with your Pict instance:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const libPictSectionFlow = require('pict-section-flow');
|
|
42
|
+
|
|
43
|
+
_Pict.addView('MyFlowDiagram',
|
|
44
|
+
{
|
|
45
|
+
DefaultDestinationAddress: '#flow-container',
|
|
46
|
+
EnableToolbar: true,
|
|
47
|
+
EnableGridSnap: true,
|
|
48
|
+
GridSnapSize: 20
|
|
49
|
+
},
|
|
50
|
+
libPictSectionFlow);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Your HTML needs a target element:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<div id="flow-container"></div>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Step 3: Initialize and Render
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// Initialize the application (triggers view initialization)
|
|
63
|
+
_Pict.initialize();
|
|
64
|
+
|
|
65
|
+
// The flow view is now accessible
|
|
66
|
+
let tmpFlowView = _Pict.views.MyFlowDiagram;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Step 4: Add Nodes
|
|
70
|
+
|
|
71
|
+
Use the `addNode` method to place nodes on the canvas:
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
// addNode(pType, pX, pY, pTitle, pData)
|
|
75
|
+
let tmpStart = tmpFlowView.addNode('start', 50, 150, 'Begin');
|
|
76
|
+
let tmpProcess = tmpFlowView.addNode('default', 250, 150, 'Process Data');
|
|
77
|
+
let tmpEnd = tmpFlowView.addNode('end', 450, 150, 'Done');
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Five built-in node types are available out of the box:
|
|
81
|
+
|
|
82
|
+
| Type | Ports | Color | Use Case |
|
|
83
|
+
|------|-------|-------|----------|
|
|
84
|
+
| `default` | In, Out | Gray | Generic operation |
|
|
85
|
+
| `start` | Out | Green | Flow entry point |
|
|
86
|
+
| `end` | In | Teal | Flow exit point |
|
|
87
|
+
| `halt` | In | Red | Error termination |
|
|
88
|
+
| `decision` | In, Yes, No | Orange | Conditional branch |
|
|
89
|
+
|
|
90
|
+
## Step 5: Connect Nodes
|
|
91
|
+
|
|
92
|
+
Link two ports by providing node and port hashes:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
// Get the output port of the start node
|
|
96
|
+
let tmpSourcePort = tmpStart.Ports.find((pPort) => pPort.Direction === 'output');
|
|
97
|
+
// Get the input port of the process node
|
|
98
|
+
let tmpTargetPort = tmpProcess.Ports.find((pPort) => pPort.Direction === 'input');
|
|
99
|
+
|
|
100
|
+
tmpFlowView.addConnection(
|
|
101
|
+
tmpStart.Hash, tmpSourcePort.Hash,
|
|
102
|
+
tmpProcess.Hash, tmpTargetPort.Hash
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Step 6: Define a Custom Card Type
|
|
107
|
+
|
|
108
|
+
For domain-specific node types, extend `PictFlowCard`:
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
const libPictFlowCard = require('pict-section-flow').PictFlowCard;
|
|
112
|
+
|
|
113
|
+
class FileReadCard extends libPictFlowCard
|
|
114
|
+
{
|
|
115
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
116
|
+
{
|
|
117
|
+
super(pFable, Object.assign({},
|
|
118
|
+
{
|
|
119
|
+
Title: 'File Read',
|
|
120
|
+
Code: 'FREAD',
|
|
121
|
+
Category: 'File I/O',
|
|
122
|
+
Description: 'Read contents from a file path',
|
|
123
|
+
TitleBarColor: '#2980b9',
|
|
124
|
+
Width: 160,
|
|
125
|
+
Height: 70,
|
|
126
|
+
Inputs:
|
|
127
|
+
[
|
|
128
|
+
{ Name: 'Path', Side: 'left', PortType: 'value' }
|
|
129
|
+
],
|
|
130
|
+
Outputs:
|
|
131
|
+
[
|
|
132
|
+
{ Name: 'Data', Side: 'right', PortType: 'value' },
|
|
133
|
+
{ Name: 'Error', Side: 'bottom', PortType: 'error' }
|
|
134
|
+
],
|
|
135
|
+
PropertiesPanel:
|
|
136
|
+
{
|
|
137
|
+
PanelType: 'Form',
|
|
138
|
+
Title: 'File Read Settings',
|
|
139
|
+
DefaultWidth: 300,
|
|
140
|
+
DefaultHeight: 180,
|
|
141
|
+
Configuration:
|
|
142
|
+
{
|
|
143
|
+
Fields:
|
|
144
|
+
[
|
|
145
|
+
{ Name: 'FilePath', DataType: 'String' },
|
|
146
|
+
{ Name: 'Encoding', DataType: 'String' }
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, pOptions), pServiceHash);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Register it with the flow view:
|
|
156
|
+
|
|
157
|
+
```javascript
|
|
158
|
+
let tmpCard = new FileReadCard(_Pict, {});
|
|
159
|
+
tmpCard.registerWithFlowView(tmpFlowView);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The card now appears in the toolbar palette under the "File I/O" category.
|
|
163
|
+
|
|
164
|
+
## Step 7: Listen for Events
|
|
165
|
+
|
|
166
|
+
Hook into the event system to react to user actions:
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
tmpFlowView._EventHandlerProvider.registerHandler('onNodeSelected',
|
|
170
|
+
(pNode) =>
|
|
171
|
+
{
|
|
172
|
+
console.log('Selected node:', pNode.Title, pNode.Hash);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
tmpFlowView._EventHandlerProvider.registerHandler('onFlowChanged',
|
|
176
|
+
(pFlowData) =>
|
|
177
|
+
{
|
|
178
|
+
// Persist flow state to your backend
|
|
179
|
+
fetch('/api/flows/my-flow',
|
|
180
|
+
{
|
|
181
|
+
method: 'PUT',
|
|
182
|
+
headers: { 'Content-Type': 'application/json' },
|
|
183
|
+
body: JSON.stringify(pFlowData)
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Step 8: Switch Themes
|
|
189
|
+
|
|
190
|
+
Apply a built-in theme or register a custom one:
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
// Use a built-in theme
|
|
194
|
+
tmpFlowView.setTheme('blueprint');
|
|
195
|
+
|
|
196
|
+
// Or register your own
|
|
197
|
+
tmpFlowView._ThemeProvider.registerTheme('dark',
|
|
198
|
+
{
|
|
199
|
+
Key: 'dark',
|
|
200
|
+
Label: 'Dark Mode',
|
|
201
|
+
CSSVariables:
|
|
202
|
+
{
|
|
203
|
+
'--pf-canvas-bg': '#1a1a2e',
|
|
204
|
+
'--pf-node-body-fill': '#16213e',
|
|
205
|
+
'--pf-text-primary': '#e8e8e8',
|
|
206
|
+
'--pf-node-selected-stroke': '#e94560'
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
tmpFlowView.setTheme('dark');
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Step 9: Build for the Browser
|
|
213
|
+
|
|
214
|
+
Add a build script to your `package.json`:
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"scripts": {
|
|
219
|
+
"build": "npx quack build"
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Then build:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npm run build
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
This produces a browser bundle in `dist/` that includes pict-section-flow and all its dependencies.
|
|
231
|
+
|
|
232
|
+
## Next Steps
|
|
233
|
+
|
|
234
|
+
- **[Architecture](Architecture.md)** — Understand the service/provider design
|
|
235
|
+
- **[Implementation Reference](Implementation_Reference.md)** — Full API for every method
|
|
236
|
+
- **[Custom Styling](Custom-Styling.md)** — CSS variables and theme configuration
|
|
237
|
+
- **[Layout Persistence](Layout_Persistence.md)** — Save layouts to localStorage or a REST API
|