pict-section-flow 0.0.1 → 0.0.2

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 (48) hide show
  1. package/docs/README.md +19 -0
  2. package/{example_application → example_applications/simple_cards}/html/index.html +2 -2
  3. package/example_applications/simple_cards/package.json +43 -0
  4. package/example_applications/simple_cards/source/Pict-Application-FlowExample.js +434 -0
  5. package/example_applications/simple_cards/source/cards/FlowCard-Each.js +36 -0
  6. package/example_applications/simple_cards/source/cards/FlowCard-FileRead.js +54 -0
  7. package/example_applications/simple_cards/source/cards/FlowCard-FileWrite.js +48 -0
  8. package/example_applications/simple_cards/source/cards/FlowCard-GetValue.js +35 -0
  9. package/example_applications/simple_cards/source/cards/FlowCard-IfThenElse.js +47 -0
  10. package/example_applications/simple_cards/source/cards/FlowCard-LogValues.js +53 -0
  11. package/example_applications/simple_cards/source/cards/FlowCard-SetValue.js +95 -0
  12. package/example_applications/simple_cards/source/cards/FlowCard-Switch.js +37 -0
  13. package/example_applications/simple_cards/source/views/PictView-FlowExample-FileWriteInfo.js +59 -0
  14. package/{example_application → example_applications/simple_cards}/source/views/PictView-FlowExample-Layout.js +5 -1
  15. package/example_applications/simple_cards/source/views/PictView-FlowExample-MainWorkspace.js +312 -0
  16. package/package.json +6 -6
  17. package/source/Pict-Section-Flow.js +19 -0
  18. package/source/PictFlowCard.js +207 -0
  19. package/source/PictFlowCardPropertiesPanel.js +105 -0
  20. package/source/panels/FlowCardPropertiesPanel-Form.js +174 -0
  21. package/source/panels/FlowCardPropertiesPanel-Markdown.js +148 -0
  22. package/source/panels/FlowCardPropertiesPanel-Template.js +88 -0
  23. package/source/panels/FlowCardPropertiesPanel-View.js +114 -0
  24. package/source/providers/PictProvider-Flow-EventHandler.js +19 -8
  25. package/source/providers/PictProvider-Flow-Geometry.js +64 -0
  26. package/source/providers/PictProvider-Flow-Layouts.js +284 -0
  27. package/source/providers/PictProvider-Flow-NodeTypes.js +70 -0
  28. package/source/providers/PictProvider-Flow-PanelChrome.js +72 -0
  29. package/source/providers/PictProvider-Flow-SVGHelpers.js +30 -0
  30. package/source/services/PictService-Flow-ConnectionRenderer.js +324 -66
  31. package/source/services/PictService-Flow-InteractionManager.js +399 -75
  32. package/source/services/PictService-Flow-Layout.js +159 -0
  33. package/source/services/PictService-Flow-PathGenerator.js +199 -0
  34. package/source/services/PictService-Flow-Tether.js +544 -0
  35. package/source/views/PictView-Flow-Node.js +95 -18
  36. package/source/views/PictView-Flow-PropertiesPanel.js +435 -0
  37. package/source/views/PictView-Flow-Toolbar.js +491 -5
  38. package/source/views/PictView-Flow.js +830 -8
  39. package/example_application/package.json +0 -41
  40. package/example_application/source/Pict-Application-FlowExample.js +0 -241
  41. package/example_application/source/views/PictView-FlowExample-MainWorkspace.js +0 -191
  42. /package/{example_application → example_applications/simple_cards}/css/flowexample.css +0 -0
  43. /package/{example_application → example_applications/simple_cards}/source/Pict-Application-FlowExample-Configuration.json +0 -0
  44. /package/{example_application → example_applications/simple_cards}/source/providers/PictRouter-FlowExample-Configuration.json +0 -0
  45. /package/{example_application → example_applications/simple_cards}/source/views/PictView-FlowExample-About.js +0 -0
  46. /package/{example_application → example_applications/simple_cards}/source/views/PictView-FlowExample-BottomBar.js +0 -0
  47. /package/{example_application → example_applications/simple_cards}/source/views/PictView-FlowExample-Documentation.js +0 -0
  48. /package/{example_application → example_applications/simple_cards}/source/views/PictView-FlowExample-TopBar.js +0 -0
@@ -1,41 +0,0 @@
1
- {
2
- "name": "pict-section-flow-example",
3
- "version": "0.0.1",
4
- "description": "Pict Section Flow Example Application",
5
- "main": "source/Pict-Application-FlowExample.js",
6
- "scripts": {
7
- "start": "node source/Pict-Application-FlowExample.js",
8
- "build": "npx quack build && npx quack copy",
9
- "test": "echo \"Error: no test specified\" && exit 0"
10
- },
11
- "author": "steven velozo <steven@velozo.com>",
12
- "license": "MIT",
13
- "dependencies": {
14
- "pict": "^1.0.343",
15
- "pict-application": "^1.0.28",
16
- "pict-router": "^1.0.4",
17
- "pict-view": "^1.0.64",
18
- "pict-provider": "^1.0.3",
19
- "pict-section-flow": "file:../"
20
- },
21
- "devDependencies": {
22
- "quackage": "^1.0.42"
23
- },
24
- "copyFilesSettings": {
25
- "whenFileExists": "overwrite"
26
- },
27
- "copyFiles": [
28
- {
29
- "from": "./html/*",
30
- "to": "./dist/"
31
- },
32
- {
33
- "from": "./css/**",
34
- "to": "./dist/css/"
35
- },
36
- {
37
- "from": "./node_modules/pict/dist/*",
38
- "to": "./dist/js/"
39
- }
40
- ]
41
- }
@@ -1,241 +0,0 @@
1
- const libPictApplication = require('pict-application');
2
- const libPictRouter = require('pict-router');
3
-
4
- // Views
5
- const libViewLayout = require('./views/PictView-FlowExample-Layout.js');
6
- const libViewTopBar = require('./views/PictView-FlowExample-TopBar.js');
7
- const libViewBottomBar = require('./views/PictView-FlowExample-BottomBar.js');
8
- const libViewMainWorkspace = require('./views/PictView-FlowExample-MainWorkspace.js');
9
- const libViewAbout = require('./views/PictView-FlowExample-About.js');
10
- const libViewDocumentation = require('./views/PictView-FlowExample-Documentation.js');
11
-
12
- class FlowExampleApplication extends libPictApplication
13
- {
14
- constructor(pFable, pOptions, pServiceHash)
15
- {
16
- super(pFable, pOptions, pServiceHash);
17
-
18
- // Add the router provider with routes
19
- this.pict.addProvider('PictRouter', require('./providers/PictRouter-FlowExample-Configuration.json'), libPictRouter);
20
-
21
- // Add the layout view (the shell that contains top bar, workspace, bottom bar)
22
- this.pict.addView('FlowExample-Layout', libViewLayout.default_configuration, libViewLayout);
23
-
24
- // Add the top bar and bottom bar views
25
- this.pict.addView('FlowExample-TopBar', libViewTopBar.default_configuration, libViewTopBar);
26
- this.pict.addView('FlowExample-BottomBar', libViewBottomBar.default_configuration, libViewBottomBar);
27
-
28
- // Add the main content workspace view
29
- this.pict.addView('FlowExample-MainWorkspace', libViewMainWorkspace.default_configuration, libViewMainWorkspace);
30
-
31
- // Add the about page view
32
- this.pict.addView('FlowExample-About', libViewAbout.default_configuration, libViewAbout);
33
-
34
- // Add the documentation page view
35
- this.pict.addView('FlowExample-Documentation', libViewDocumentation.default_configuration, libViewDocumentation);
36
- }
37
-
38
- onAfterInitializeAsync(fCallback)
39
- {
40
- // Initialize application state
41
- this.pict.AppData.FlowExample =
42
- {
43
- CurrentRoute: 'home'
44
- };
45
-
46
- // Initialize sample flow data
47
- this.pict.AppData.FlowExample.SampleFlow =
48
- {
49
- Nodes:
50
- [
51
- {
52
- Hash: 'node-start',
53
- Type: 'start',
54
- X: 50,
55
- Y: 150,
56
- Width: 140,
57
- Height: 80,
58
- Title: 'Start',
59
- Ports:
60
- [
61
- { Hash: 'port-start-out', Direction: 'output', Side: 'right', Label: 'Out' }
62
- ],
63
- Data: {}
64
- },
65
- {
66
- Hash: 'node-process-1',
67
- Type: 'default',
68
- X: 300,
69
- Y: 80,
70
- Width: 180,
71
- Height: 80,
72
- Title: 'Validate',
73
- Ports:
74
- [
75
- { Hash: 'port-proc1-in', Direction: 'input', Side: 'left', Label: 'In' },
76
- { Hash: 'port-proc1-out', Direction: 'output', Side: 'right', Label: 'Out' }
77
- ],
78
- Data: {}
79
- },
80
- {
81
- Hash: 'node-decision',
82
- Type: 'decision',
83
- X: 580,
84
- Y: 100,
85
- Width: 200,
86
- Height: 100,
87
- Title: 'Valid?',
88
- Ports:
89
- [
90
- { Hash: 'port-dec-in', Direction: 'input', Side: 'left', Label: 'In' },
91
- { Hash: 'port-dec-yes', Direction: 'output', Side: 'right', Label: 'Yes' },
92
- { Hash: 'port-dec-no', Direction: 'output', Side: 'bottom', Label: 'No' }
93
- ],
94
- Data: {}
95
- },
96
- {
97
- Hash: 'node-process-2',
98
- Type: 'default',
99
- X: 880,
100
- Y: 80,
101
- Width: 180,
102
- Height: 80,
103
- Title: 'Process',
104
- Ports:
105
- [
106
- { Hash: 'port-proc2-in', Direction: 'input', Side: 'left', Label: 'In' },
107
- { Hash: 'port-proc2-out', Direction: 'output', Side: 'right', Label: 'Out' }
108
- ],
109
- Data: {}
110
- },
111
- {
112
- Hash: 'node-error',
113
- Type: 'default',
114
- X: 600,
115
- Y: 320,
116
- Width: 180,
117
- Height: 80,
118
- Title: 'Error',
119
- Ports:
120
- [
121
- { Hash: 'port-err-in', Direction: 'input', Side: 'top', Label: 'In' },
122
- { Hash: 'port-err-out', Direction: 'output', Side: 'right', Label: 'Out' }
123
- ],
124
- Data: {}
125
- },
126
- {
127
- Hash: 'node-end',
128
- Type: 'end',
129
- X: 1160,
130
- Y: 150,
131
- Width: 140,
132
- Height: 80,
133
- Title: 'End',
134
- Ports:
135
- [
136
- { Hash: 'port-end-in', Direction: 'input', Side: 'left', Label: 'In' }
137
- ],
138
- Data: {}
139
- }
140
- ],
141
- Connections:
142
- [
143
- {
144
- Hash: 'conn-1',
145
- SourceNodeHash: 'node-start',
146
- SourcePortHash: 'port-start-out',
147
- TargetNodeHash: 'node-process-1',
148
- TargetPortHash: 'port-proc1-in',
149
- Data: {}
150
- },
151
- {
152
- Hash: 'conn-2',
153
- SourceNodeHash: 'node-process-1',
154
- SourcePortHash: 'port-proc1-out',
155
- TargetNodeHash: 'node-decision',
156
- TargetPortHash: 'port-dec-in',
157
- Data: {}
158
- },
159
- {
160
- Hash: 'conn-3',
161
- SourceNodeHash: 'node-decision',
162
- SourcePortHash: 'port-dec-yes',
163
- TargetNodeHash: 'node-process-2',
164
- TargetPortHash: 'port-proc2-in',
165
- Data: {}
166
- },
167
- {
168
- Hash: 'conn-4',
169
- SourceNodeHash: 'node-decision',
170
- SourcePortHash: 'port-dec-no',
171
- TargetNodeHash: 'node-error',
172
- TargetPortHash: 'port-err-in',
173
- Data: {}
174
- },
175
- {
176
- Hash: 'conn-5',
177
- SourceNodeHash: 'node-process-2',
178
- SourcePortHash: 'port-proc2-out',
179
- TargetNodeHash: 'node-end',
180
- TargetPortHash: 'port-end-in',
181
- Data: {}
182
- },
183
- {
184
- Hash: 'conn-6',
185
- SourceNodeHash: 'node-error',
186
- SourcePortHash: 'port-err-out',
187
- TargetNodeHash: 'node-end',
188
- TargetPortHash: 'port-end-in',
189
- Data: {}
190
- }
191
- ],
192
- ViewState:
193
- {
194
- PanX: 0,
195
- PanY: 0,
196
- Zoom: 1,
197
- SelectedNodeHash: null,
198
- SelectedConnectionHash: null
199
- }
200
- };
201
-
202
- // Render the layout shell first, then the initial content
203
- this.pict.views['FlowExample-Layout'].render();
204
-
205
- return super.onAfterInitializeAsync(fCallback);
206
- }
207
-
208
- /**
209
- * Navigate to a route using the pict-router.
210
- *
211
- * @param {string} pRoute - The route path to navigate to (e.g. '/About')
212
- */
213
- navigateTo(pRoute)
214
- {
215
- this.pict.providers.PictRouter.navigate(pRoute);
216
- }
217
-
218
- /**
219
- * Render a specific content view into the main workspace area.
220
- * This is called by the router when a route is matched.
221
- *
222
- * @param {string} pViewIdentifier - The view identifier to render
223
- */
224
- showView(pViewIdentifier)
225
- {
226
- if (pViewIdentifier in this.pict.views)
227
- {
228
- this.pict.AppData.FlowExample.CurrentRoute = pViewIdentifier;
229
- this.pict.views[pViewIdentifier].render();
230
- }
231
- else
232
- {
233
- this.pict.log.warn(`View [${pViewIdentifier}] not found; falling back to main workspace.`);
234
- this.pict.views['FlowExample-MainWorkspace'].render();
235
- }
236
- }
237
- }
238
-
239
- module.exports = FlowExampleApplication;
240
-
241
- module.exports.default_configuration = require('./Pict-Application-FlowExample-Configuration.json');
@@ -1,191 +0,0 @@
1
- const libPictView = require('pict-view');
2
- const libPictSectionFlow = require('pict-section-flow');
3
-
4
- const _ViewConfiguration =
5
- {
6
- ViewIdentifier: "FlowExample-MainWorkspace",
7
-
8
- DefaultRenderable: "FlowExample-MainWorkspace-Content",
9
- DefaultDestinationAddress: "#FlowExample-Content-Container",
10
-
11
- AutoRender: false,
12
-
13
- CSS: /*css*/`
14
- .flowexample-workspace {
15
- padding: 2em;
16
- max-width: 1400px;
17
- margin: 0 auto;
18
- }
19
- .flowexample-workspace-header {
20
- margin: 0 0 1.5em 0;
21
- padding-bottom: 1em;
22
- border-bottom: 1px solid #eee;
23
- }
24
- .flowexample-workspace-header h1 {
25
- margin: 0 0 0.25em 0;
26
- font-size: 2em;
27
- font-weight: 300;
28
- color: #2c3e50;
29
- }
30
- .flowexample-workspace-header p {
31
- margin: 0;
32
- color: #7f8c8d;
33
- font-size: 1.1em;
34
- }
35
- #FlowExample-Flow-Container {
36
- min-height: 500px;
37
- }
38
- .flowexample-hints {
39
- margin-top: 1.5em;
40
- display: grid;
41
- grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
42
- gap: 1em;
43
- }
44
- .flowexample-hint {
45
- background: #fff;
46
- border: 1px solid #e0e0e0;
47
- border-radius: 6px;
48
- padding: 1em 1.25em;
49
- }
50
- .flowexample-hint h4 {
51
- margin: 0 0 0.35em 0;
52
- font-size: 0.95em;
53
- color: #2c3e50;
54
- }
55
- .flowexample-hint p {
56
- margin: 0;
57
- color: #666;
58
- font-size: 0.85em;
59
- line-height: 1.5;
60
- }
61
- .flowexample-hint code {
62
- background: #f4f4f5;
63
- padding: 0.1em 0.3em;
64
- border-radius: 3px;
65
- font-size: 0.9em;
66
- color: #e74c3c;
67
- }
68
- `,
69
-
70
- Templates:
71
- [
72
- {
73
- Hash: "FlowExample-MainWorkspace-Template",
74
- Template: /*html*/`
75
- <div class="flowexample-workspace">
76
- <div class="flowexample-workspace-header">
77
- <h1>Flow Diagram</h1>
78
- <p>Create, edit, and connect nodes to build flow diagrams. Drag nodes to reposition, drag from output ports to input ports to create connections.</p>
79
- </div>
80
- <div id="FlowExample-Flow-Container"></div>
81
- <div class="flowexample-hints">
82
- <div class="flowexample-hint">
83
- <h4>Add Nodes</h4>
84
- <p>Select a node type from the dropdown and click <code>+ Add Node</code> in the toolbar.</p>
85
- </div>
86
- <div class="flowexample-hint">
87
- <h4>Connect Nodes</h4>
88
- <p>Drag from a green output port to a blue input port to create a connection.</p>
89
- </div>
90
- <div class="flowexample-hint">
91
- <h4>Move Nodes</h4>
92
- <p>Click and drag any node to reposition it. Connections update automatically.</p>
93
- </div>
94
- <div class="flowexample-hint">
95
- <h4>Pan &amp; Zoom</h4>
96
- <p>Click and drag the background to pan. Use the mouse wheel to zoom in and out.</p>
97
- </div>
98
- <div class="flowexample-hint">
99
- <h4>Delete</h4>
100
- <p>Select a node or connection and press <code>Delete</code> or click the Delete button.</p>
101
- </div>
102
- <div class="flowexample-hint">
103
- <h4>Auto Layout</h4>
104
- <p>Click <code>Auto Layout</code> in the toolbar to automatically arrange nodes left to right.</p>
105
- </div>
106
- </div>
107
- </div>
108
- `
109
- }
110
- ],
111
-
112
- Renderables:
113
- [
114
- {
115
- RenderableHash: "FlowExample-MainWorkspace-Content",
116
- TemplateHash: "FlowExample-MainWorkspace-Template",
117
- DestinationAddress: "#FlowExample-Content-Container",
118
- RenderMethod: "replace"
119
- }
120
- ]
121
- };
122
-
123
- class FlowExampleMainWorkspaceView extends libPictView
124
- {
125
- constructor(pFable, pOptions, pServiceHash)
126
- {
127
- super(pFable, pOptions, pServiceHash);
128
-
129
- this._FlowView = null;
130
- }
131
-
132
- onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent)
133
- {
134
- // Create and render the flow section view into its container
135
- if (!this._FlowView)
136
- {
137
- this._FlowView = this.pict.addView('FlowExample-FlowDiagram',
138
- {
139
- ViewIdentifier: 'FlowExample-FlowDiagram',
140
-
141
- DefaultRenderable: 'Flow-Container',
142
- DefaultDestinationAddress: '#FlowExample-Flow-Container',
143
-
144
- AutoRender: false,
145
-
146
- FlowDataAddress: 'AppData.FlowExample.SampleFlow',
147
-
148
- TargetElementAddress: '#Flow-SVG-Container',
149
-
150
- EnableToolbar: true,
151
- EnablePanning: true,
152
- EnableZooming: true,
153
- EnableNodeDragging: true,
154
- EnableConnectionCreation: true,
155
- EnableGridSnap: false,
156
- GridSnapSize: 20,
157
-
158
- MinZoom: 0.1,
159
- MaxZoom: 5.0,
160
- ZoomStep: 0.1,
161
-
162
- DefaultNodeType: 'default',
163
- DefaultNodeWidth: 180,
164
- DefaultNodeHeight: 80,
165
-
166
- Renderables:
167
- [
168
- {
169
- RenderableHash: 'Flow-Container',
170
- TemplateHash: 'Flow-Container-Template',
171
- DestinationAddress: '#FlowExample-Flow-Container',
172
- RenderMethod: 'replace'
173
- }
174
- ]
175
- },
176
- libPictSectionFlow
177
- );
178
- }
179
-
180
- // Reset the flow view's render state so it re-initializes SVG elements
181
- // when re-rendered (e.g. after navigating away and back)
182
- this._FlowView.initialRenderComplete = false;
183
- this._FlowView.render();
184
-
185
- return super.onAfterRender(pRenderable, pRenderDestinationAddress, pRecord, pContent);
186
- }
187
- }
188
-
189
- module.exports = FlowExampleMainWorkspaceView;
190
-
191
- module.exports.default_configuration = _ViewConfiguration;