@squeed/flow-sdk 2.0.47 → 2.0.49
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/LICENSE +21 -662
- package/README.md +139 -1392
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Squeed Flow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Turn JSON into interactive, editable flow diagrams.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Website](https://squeed.co) · [Live editor](https://app.squeed.co) ·
|
|
6
|
+
[VS Code extension](https://marketplace.visualstudio.com/items?itemName=seyiogunbowalesciphergfx.squeed-flow) ·
|
|
7
|
+
[MCP bridge](https://squeed.co/mcp) · [npm](https://www.npmjs.com/package/@squeed/flow-sdk)
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
npm
|
|
9
|
-
```
|
|
9
|
+
[](https://www.npmjs.com/package/@squeed/flow-sdk)
|
|
10
|
+
[](LICENSE)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Squeed Flow renders any JSON document as a diagram you can pan, zoom, select,
|
|
13
|
+
rearrange, and edit - then reports the edit back as JSON. The same document
|
|
14
|
+
format powers the hosted editor at [app.squeed.co](https://app.squeed.co), the
|
|
15
|
+
[VS Code preview extension](https://marketplace.visualstudio.com/items?itemName=seyiogunbowalesciphergfx.squeed-flow),
|
|
16
|
+
and agent workflows driven over MCP at [squeed.co/mcp](https://squeed.co/mcp).
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
## Features
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
- **JSON-first** - pass a parsed object or array; no separate schema or graph model.
|
|
21
|
+
- **Interactive canvas** - pan, zoom, drag, multi-select, draw edges, and collapse branches.
|
|
22
|
+
- **Inline editing** - rename nodes, edit Markdown content, change colors, icons, borders, and connections.
|
|
23
|
+
- **Controlled data flow** - every edit returns a new document through `onJsonChange`; you own state.
|
|
24
|
+
- **Flexible layout** - left/right, top/bottom, or centered branch layout with Dagre.
|
|
25
|
+
- **Rich nodes** - Markdown/HTML/JSX content, Phosphor and React Icons, animation, and compound containers.
|
|
26
|
+
- **Extensible** - custom node views, overlays, toolbars, bottom bars, and callbacks.
|
|
27
|
+
- **Themeable** - light/dark modes and Chakra UI color tokens.
|
|
28
|
+
- **Streaming-ready** - incremental JSON preview and playback helpers.
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
reusable diagram behavior, not application document storage, project ownership,
|
|
19
|
-
authentication, navigation, or backend transport. Consumers retain changed
|
|
20
|
-
documents and application state. See the
|
|
21
|
-
[app pattern](../squeed/README.md#ownership-and-code-patterns) and
|
|
22
|
-
[contribution rules](CONTRIBUTING.md).
|
|
30
|
+
## Try It
|
|
23
31
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
| `examples`, `tests` | Consumer demonstrations, fixtures, and verification |
|
|
32
|
+
| Where | Link |
|
|
33
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
34
|
+
| Website | [squeed.co](https://squeed.co) |
|
|
35
|
+
| Live editor | [app.squeed.co](https://app.squeed.co) |
|
|
36
|
+
| VS Code extension | [Squeed Flow on the Marketplace](https://marketplace.visualstudio.com/items?itemName=seyiogunbowalesciphergfx.squeed-flow) |
|
|
37
|
+
| Agent workflows (MCP) | [squeed.co/mcp](https://squeed.co/mcp) |
|
|
38
|
+
| Package | [npmjs.com/package/@squeed/flow-sdk](https://www.npmjs.com/package/@squeed/flow-sdk) |
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
host-specific branch. Keep pure document operations independent of UI and
|
|
35
|
-
storage. Prefer design/configuration defaults over imperative presentation fixes.
|
|
36
|
-
JSON edits use the shared callback binding and emit one immutable document;
|
|
37
|
-
raw graph consumers own their mutations. Preserve read-only restrictions.
|
|
40
|
+
## Install
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
avoid runtime import cycles. Document public contract changes and test the
|
|
43
|
-
owning module plus affected consumer behavior.
|
|
42
|
+
```bash
|
|
43
|
+
npm install @squeed/flow-sdk react@^18 react-dom@^18 markdown-to-jsx@^9.10.2
|
|
44
|
+
```
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
does not establish that the code follows this pattern.
|
|
46
|
+
Requires React 18, Chakra UI 3.36+, and `react-icons` 5.3+. Remaining peer
|
|
47
|
+
dependencies install automatically with npm 7+. React 19 is not currently
|
|
48
|
+
supported. The Markdown renderer is a required peer supplied by your app, not
|
|
49
|
+
bundled with the SDK.
|
|
50
50
|
|
|
51
51
|
## Quick Start
|
|
52
52
|
|
|
@@ -81,1258 +81,113 @@ function App() {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
The container must have a height. Styles are injected automatically; no CSS
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
Editing a plain-string node label updates that string in place, preserving its JSON address and connections. Object-node labels continue to use `$label`.
|
|
89
|
-
|
|
90
|
-
## Migrating From v1
|
|
91
|
-
|
|
92
|
-
**v2 is a breaking release for consumers of the Cytoscape instance.** `onCyInit` has been removed. Use `onInit(engine)` to capture a `FlowEngine`; it is not a Cytoscape-compatible object.
|
|
93
|
-
|
|
94
|
-
| v1 | v2 |
|
|
95
|
-
| ------------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
96
|
-
| `onCyInit(cy)` | `onInit(engine)` |
|
|
97
|
-
| `cy.zoom()` / `cy.zoom(level)` | `engine.zoom()` / `engine.zoom(level)` |
|
|
98
|
-
| `cy.pan()` / `cy.pan(position)` | `engine.pan()` / `engine.pan(position)` |
|
|
99
|
-
| `cy.zoom({ level, renderedPosition })` | `engine.zoomAt(level, renderedPosition)` |
|
|
100
|
-
| `cy.fit(undefined, 50)` / `cy.center()` | `engine.fit(50)` / `engine.center()` |
|
|
101
|
-
| `cy.on("pan zoom", ...)` | `callbacks.onViewportChange` or `engine.onViewportChange(listener)` |
|
|
102
|
-
| `cy.nodes()`, `cy.edges()`, `cy.style()`, plugins | Update the JSON, `nodes`/`edges`, or SDK config; no Cytoscape equivalent is exposed |
|
|
103
|
-
|
|
104
|
-
`engine.getNodeBox(id)` returns `{ x, y, w, h }` in model units after layout, or `undefined` before placement. `clientToModel(clientX, clientY)` and `modelToClient({ x, y })` convert coordinates. `onViewportChange(listener)` returns an unsubscribe function.
|
|
105
|
-
|
|
106
|
-
Direction, selection, drawing, editing, collapse, and custom render callbacks remain available. Internal Cytoscape DOM classes are gone. SVG routing and text metrics can differ from the old canvas renderer; exact pixel parity is not guaranteed. `initialViewport` is now respected instead of being overwritten by automatic fitting.
|
|
107
|
-
|
|
108
|
-
## Props
|
|
109
|
-
|
|
110
|
-
### `FlowDiagramProps`
|
|
111
|
-
|
|
112
|
-
| Prop | Type | Description |
|
|
113
|
-
| --------------- | ---------------------- | ------------------------------------------------------------------ |
|
|
114
|
-
| `json` | `SqueedJson` | Parsed JSON object or array; takes precedence over `nodes`/`edges` |
|
|
115
|
-
| `title` | `string` | Title shown on the root node (default: `"untitled"`) |
|
|
116
|
-
| `nodes` | `FlowDiagramNode[]` | Pre-computed nodes (alternative to `json`) |
|
|
117
|
-
| `edges` | `FlowDiagramEdge[]` | Pre-computed edges (alternative to `json`) |
|
|
118
|
-
| `config` | `FlowDiagramConfig` | Diagram configuration |
|
|
119
|
-
| `callbacks` | `FlowDiagramCallbacks` | Event callbacks |
|
|
120
|
-
| `showBottomBar` | `boolean` | Show the direction/mode bottom bar (default: `true`) |
|
|
121
|
-
| `className` | `string` | CSS class name |
|
|
122
|
-
| `style` | `CSSProperties` | Inline styles |
|
|
123
|
-
|
|
124
|
-
You can provide either `json` (auto-generates nodes/edges) or `nodes` + `edges` (pre-computed).
|
|
125
|
-
|
|
126
|
-
## Config
|
|
127
|
-
|
|
128
|
-
Clicking the empty graph background opens the **Graph theme** swatches after the
|
|
129
|
-
set/array control. They change the default node theme without replacing explicit
|
|
130
|
-
node colors or modifying graph JSON, and hide while a node or edge is selected
|
|
131
|
-
or the diagram is read-only. Without `config.themeColor`, the selection is stored
|
|
132
|
-
locally. For a controlled or persisted theme, pass `config.themeColor` and update
|
|
133
|
-
it from `callbacks.onThemeColorChange(color)`.
|
|
134
|
-
|
|
135
|
-
### `FlowDiagramConfig`
|
|
136
|
-
|
|
137
|
-
| Option | Type | Default | Description |
|
|
138
|
-
| ----------------------------------------------------------------------- | ------------------------------------------------ | ------------ | ------------------------------------------------------------------------------------------------- |
|
|
139
|
-
| `direction` | `"LR" \| "RL" \| "TB" \| "BT" \| "C"` | `"LR"` | Layout direction; `C` splits the JSON root's branches |
|
|
140
|
-
| `nodeAlignment` | `"leading" \| "center" \| "trailing"` | `"center"` | Align unequal node sizes within each layout rank |
|
|
141
|
-
| `edgeMode` | `"nodes" \| "properties" \| "workflow"` | `"nodes"` | Attach edges to nodes or named property rows; `"workflow"` is a compatibility alias for `"nodes"` |
|
|
142
|
-
| `layout` | `LayoutAlgorithm` | `"dagre"` | Only Dagre is implemented; other legacy values do not select a different layout |
|
|
143
|
-
| `themeColor` | `string` | `"blue.500"` | Accent color (Chakra token) |
|
|
144
|
-
| `colorMode` | `"light" \| "dark"` | `"light"` | Color mode |
|
|
145
|
-
| `backgroundPattern` | `"dot" \| "grid" \| "steel" \| "none"` | `"dot"` | Background pattern |
|
|
146
|
-
| `backgroundColor` | `string` | — | Background color override |
|
|
147
|
-
| `edgeColor` | `string` | — | Edge/line color override |
|
|
148
|
-
| `minZoom` | `number` | `0.01` | Minimum zoom level |
|
|
149
|
-
| `maxZoom` | `number` | `1.5` | Maximum zoom level |
|
|
150
|
-
| `initialViewport` | `{ pan: { x, y }, zoom }` | — | Initial viewport; omitted means fit on first layout |
|
|
151
|
-
| `edgeHandles` | `boolean` | — | `false` disables edge drawing; enabling handles does not activate Draw mode |
|
|
152
|
-
| `readOnly` | `boolean` | `false` | Disable graph gestures and edits; toolbar navigation remains available |
|
|
153
|
-
| `editable` | `boolean` | `false` | Enable inline node label editing |
|
|
154
|
-
| `parentNodeStyle` | `ParentNodeStyle` | — | Compound-node fill, border, padding, and label defaults |
|
|
155
|
-
| `selectionToolbar` | `SelectionToolbarConfig \| false` | — | Customize palette and hidden controls, or disable selection tools |
|
|
156
|
-
| `nodeOverlayActions` | `NodeOverlayAction[]` | — | Actions in node hover overlay |
|
|
157
|
-
| `renderNodeOverlay` | `(props: NodeOverlayProps) => ReactNode` | — | Custom node hover overlay |
|
|
158
|
-
| `renderSelectedNodeToolbar` | `(props: SelectedNodeToolbarProps) => ReactNode` | — | Custom multi-select toolbar |
|
|
159
|
-
| `renderSelectedEdgeToolbar` | `(props: SelectedEdgeToolbarProps) => ReactNode` | — | Custom edge selection toolbar |
|
|
160
|
-
| `renderBottomBar` | `(props: BottomBarRenderProps) => ReactNode` | — | Replace the bottom bar |
|
|
161
|
-
| `customViews` | `Record<string, ComponentType>` | — | Override node views |
|
|
162
|
-
| `disableKeyboardShortcuts` | `boolean` | `false` | Disable built-in keyboard shortcuts |
|
|
163
|
-
| `isZoomMode`, `isMultiSelectMode`, `isDragMode`, `isEdgeHandlesEnabled` | `boolean` | — | Externally controlled interaction modes |
|
|
164
|
-
|
|
165
|
-
Use `$collapsed: true` to collapse a JSON branch, and `false` to keep the expansion control. Automatic depth-based collapse is not part of the current API.
|
|
166
|
-
|
|
167
|
-
`nodeAlignment: "leading"` aligns left edges in `LR`/`C`, right edges in `RL`, top edges in `TB`, and bottom edges in `BT`. `"trailing"` aligns the opposite edge. Node dimensions and graph connections are unchanged; containers and edge paths follow the aligned positions.
|
|
168
|
-
|
|
169
|
-
## JSON Streaming And Playback
|
|
170
|
-
|
|
171
|
-
`createJsonStream` accepts incremental `append(chunk)` or cumulative
|
|
172
|
-
`snapshot(text)` input. Supply `parse`, `repair`, `preview`, and `commit`
|
|
173
|
-
callbacks: repaired previews are throttled, while `finish()` strictly parses the
|
|
174
|
-
original JSON before committing. `cancel()` clears pending work. The defaults
|
|
175
|
-
are a 150 ms preview interval and a 1 MiB input limit. The host supplies its
|
|
176
|
-
repair library, such as `jsonrepair`; the SDK has no model or transport dependency.
|
|
177
|
-
|
|
178
|
-
`createJsonPlayback` reuses that buffer for a saved document:
|
|
179
|
-
|
|
180
|
-
```ts
|
|
181
|
-
const player = createJsonPlayback({
|
|
182
|
-
...streamOptions,
|
|
183
|
-
source: JSON.stringify(document),
|
|
184
|
-
onChange: ({ position, total, playing }) =>
|
|
185
|
-
updateProgress(position, total, playing),
|
|
186
|
-
onError: reportError,
|
|
187
|
-
});
|
|
188
|
-
player.play();
|
|
189
|
-
player.pause();
|
|
190
|
-
player.seek(0);
|
|
191
|
-
player.dispose();
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Playback defaults to eight seconds, supports resuming and replaying, and reports
|
|
195
|
-
character offsets for a progress slider. Use `projectJsonPlaybackPreview(partial,
|
|
196
|
-
document)` when replaying Squeed JSON to keep structured metadata such as `$state`
|
|
197
|
-
references atomic. Keep previews separate from saved documents. SDK Test includes
|
|
198
|
-
a themed top-right player that reveals connections with their endpoints and
|
|
199
|
-
automatically fits every new layout without modifying the saved document.
|
|
200
|
-
|
|
201
|
-
## Custom Node Editing
|
|
202
|
-
|
|
203
|
-
Custom views replace the node renderer. Wrap custom visuals in the exported
|
|
204
|
-
`NodeView` to reuse SDK selection, multi-selection, overlays, and collapse
|
|
205
|
-
controls. Use `EditableLabel` for the standard inline editor, including
|
|
206
|
-
read-only handling and `onNodeLabelChange` notifications.
|
|
207
|
-
|
|
208
|
-
```tsx
|
|
209
|
-
import { NodeView, EditableLabel } from "@squeed/flow-sdk";
|
|
210
|
-
import type { FlowDiagramNode } from "@squeed/flow-sdk";
|
|
211
|
-
|
|
212
|
-
function CustomNode({ data }: FlowDiagramNode) {
|
|
213
|
-
return (
|
|
214
|
-
<NodeView data={data}>
|
|
215
|
-
{({ isActive, isEditing, onEditStart, onEditEnd }) => (
|
|
216
|
-
<div
|
|
217
|
-
data-flow-node-surface=""
|
|
218
|
-
data-selected={isActive}
|
|
219
|
-
style={{ width: 240, height: 160 }}
|
|
220
|
-
>
|
|
221
|
-
<EditableLabel
|
|
222
|
-
nodeId={data.id}
|
|
223
|
-
label={data.label ?? "Custom"}
|
|
224
|
-
color={data.viewProps?.textColor ?? "gray.900"}
|
|
225
|
-
isEditing={isEditing}
|
|
226
|
-
onEditStart={onEditStart}
|
|
227
|
-
onEditEnd={onEditEnd}
|
|
228
|
-
/>
|
|
229
|
-
</div>
|
|
230
|
-
)}
|
|
231
|
-
</NodeView>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Register the component under its node type in `config.customViews`. Do not stop
|
|
237
|
-
click propagation on the visual surface or maintain a separate selection state.
|
|
238
|
-
The custom renderer must apply the styling fields it supports, such as
|
|
239
|
-
`data.viewProps.bgColor`, `borderColor`, `borderWidth`, and `outline`, to its
|
|
240
|
-
HTML or SVG. Raw-graph callbacks must update node data; JSON mode persists edits
|
|
241
|
-
through `onJsonChange`. The wrapper does not change custom SVG geometry.
|
|
242
|
-
|
|
243
|
-
Mark the visible shape with `data-flow-node-surface`, excluding captions and
|
|
244
|
-
form summaries. For SVG views, put it on the closed geometry element (such as
|
|
245
|
-
`circle`, `polygon`, or `path`), not the surrounding `svg`. Connectors, draw
|
|
246
|
-
handles, and animated borders use that surface; layout still reserves the full
|
|
247
|
-
node bounds. In `TB` and `BT`, ordinary icon-label connectors also reserve the
|
|
248
|
-
caption below the icon, so paths and arrowheads do not cross wrapped labels or
|
|
249
|
-
subtitles. Horizontal connectors still attach to the icon surface. Unmarked
|
|
250
|
-
custom views retain rectangular host bounds.
|
|
251
|
-
|
|
252
|
-
Node edit attribution is opt-in: provide `callbacks.getNodeEditMetadata()` returning
|
|
253
|
-
`{ userId, name, at }` from the editing session (`at` is an ISO timestamp).
|
|
254
|
-
JSON node edits persist it as `$edited`; raw graphs store the same object in
|
|
255
|
-
`data.config.edited`. Existing `$subtitle` text is preserved. The shared `NodeView`
|
|
256
|
-
renders the editor and relative time using one shared minute timer, including for
|
|
257
|
-
read-only viewers of the saved document. No-op edits leave the timestamp unchanged.
|
|
258
|
-
Use `stampNodeEdit(json, address, metadata)` for custom node commit handlers.
|
|
259
|
-
Metadata is display information, not an authorization or tamper-proof audit record;
|
|
260
|
-
remote mutations must supply their actual editor, never the receiving viewer.
|
|
261
|
-
|
|
262
|
-
Edge-label placement is scoped to each canvas and skips empty label layers.
|
|
263
|
-
The existing placement is reused while node bounds, edge paths, and label
|
|
264
|
-
dimensions are unchanged. Geometry changes and font loading recheck placement;
|
|
265
|
-
unrelated updates do not resample SVG paths. This does not change JSON loading,
|
|
266
|
-
repair streaming, or playback.
|
|
267
|
-
|
|
268
|
-
For content and custom-shape views, use `<FlowPort id="tools" role="source"
|
|
269
|
-
side="bottom" position={0.5} />` inside the node. `side` accepts `top`, `right`,
|
|
270
|
-
`bottom`, or `left`; `position` ranges from 0 to 1 and defaults to the midpoint.
|
|
271
|
-
Top/bottom positions run left to right; left/right positions run top to bottom.
|
|
272
|
-
The handle and connector attach to the marked outline, including SVG slopes.
|
|
273
|
-
These ports work in Auto and Properties modes. Omitting
|
|
274
|
-
`side` retains the existing property-row behavior.
|
|
275
|
-
|
|
276
|
-
Built-in views accept the same declarations in `data.config.ports` or JSON
|
|
277
|
-
`$ports`, for example `[{ "id": "prompt", "role": "target", "side": "top" }]`.
|
|
278
|
-
An optional `label` changes a port's display text without changing its `id`:
|
|
279
|
-
`{ "id": "output:resource", "label": "output", "role": "source", "side": "right" }`.
|
|
280
|
-
The same `label` prop is supported by `FlowPort`. Workflow interfaces can declare
|
|
281
|
-
it with `/** @port output resource "output" */`; the optional label is a quoted
|
|
282
|
-
JSON string. Connections continue to use `sourceProperty: "output:resource"`.
|
|
283
|
-
Connections identify these ports using `sourceProperty` and `targetProperty`.
|
|
284
|
-
Read-only mode and disabled edge handles continue to prevent dragging.
|
|
285
|
-
|
|
286
|
-
`config.edgeMode` controls visibility: `"auto"` (default) shows both normal
|
|
287
|
-
node edges and property/port edges; `"nodes"` shows only edges without property
|
|
288
|
-
endpoints; `"properties"` shows only edges with `sourceProperty` or
|
|
289
|
-
`targetProperty`. `"workflow"` remains an alias for `"nodes"`. Switching modes
|
|
290
|
-
does not remove saved edges or change the graph used for layout by default.
|
|
291
|
-
|
|
292
|
-
Set `config.compactPropertyLayout: true` to re-layout and fit only visible
|
|
293
|
-
nodes and edges in Properties mode and in isolated views (including Auto and
|
|
294
|
-
Nodes modes). Hidden nodes and connections no longer reserve layout space or
|
|
295
|
-
influence edge routes. This flag defaults to `false`; SDK Test enables it.
|
|
296
|
-
The expanded bottom toolbar includes the labelled **Compact layout**
|
|
297
|
-
icon toggle in Auto, Nodes, and Properties modes. In SDK Test it follows
|
|
298
|
-
**Connected nodes** and stays in sync with the Layout-panel pill.
|
|
299
|
-
The SDK manages the toggle locally when `config.compactPropertyLayout` is
|
|
300
|
-
omitted. For controlled usage, handle
|
|
301
|
-
`callbacks.onCompactPropertyLayoutChange(enabled)` and update the config flag.
|
|
302
|
-
Leaving Properties mode or restoring an isolated view restores the applicable
|
|
303
|
-
full layout. Saved graph data is unchanged. Without the flag, isolation keeps
|
|
304
|
-
the existing node positions.
|
|
305
|
-
|
|
306
|
-
## Bind Your Own Data
|
|
307
|
-
|
|
308
|
-
Start with the [minimal properties example](examples/form-connection/README.md):
|
|
309
|
-
two nodes, plain state, one binding, and a three-field interface. Its
|
|
310
|
-
[React component](examples/form-connection/MinimalExample.tsx) shows the complete
|
|
311
|
-
setup, including form edits, display references, appearance, and connection modes.
|
|
312
|
-
No workflow backend is required.
|
|
313
|
-
|
|
314
|
-
Then try **Shared Configuration** and **Reusable Property** in SDK Test's Templates
|
|
315
|
-
menu. The [small-step walkthrough](examples/configuration-basics/README.md) shows
|
|
316
|
-
two consumers sharing values, editing them, and exporting plain data, before
|
|
317
|
-
introducing field-level mapping and returning values inline.
|
|
318
|
-
|
|
319
|
-
## Connect Your Execution Backend
|
|
320
|
-
|
|
321
|
-
Property schemas and bindings edit data; they do not execute it. Use
|
|
322
|
-
`createWorkflowExecution(adapter, onChange)` to submit that data through your
|
|
323
|
-
own API and receive normalized step progress and output:
|
|
324
|
-
|
|
325
|
-
```ts
|
|
326
|
-
import { createWorkflowExecution } from "@squeed/flow-sdk";
|
|
327
|
-
import type { WorkflowExecutionAdapter } from "@squeed/flow-sdk";
|
|
328
|
-
|
|
329
|
-
const adapter: WorkflowExecutionAdapter<MyWorkflow> = {
|
|
330
|
-
execute: async ({ input, executionId, signal }) => {
|
|
331
|
-
const response = await fetch("/api/workflows/run", {
|
|
332
|
-
method: "POST",
|
|
333
|
-
headers: { "Content-Type": "application/json" },
|
|
334
|
-
body: JSON.stringify({ workflow: input, executionId }),
|
|
335
|
-
signal,
|
|
336
|
-
});
|
|
337
|
-
if (!response.ok) throw new Error(`Execution failed: ${response.status}`);
|
|
338
|
-
return await response.json();
|
|
339
|
-
},
|
|
340
|
-
subscribe: ({ executionId, signal }, receive) =>
|
|
341
|
-
feedback.subscribe(executionId, receive, signal),
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
const execution = createWorkflowExecution(adapter, setRun);
|
|
345
|
-
await execution.run(workflowState);
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
`MyWorkflow`, `feedback.subscribe`, and `setRun` above are supplied by your
|
|
349
|
-
application. Map your API response and feedback to `WorkflowExecutionUpdate`:
|
|
350
|
-
|
|
351
|
-
```ts
|
|
352
|
-
receive({
|
|
353
|
-
executionId,
|
|
354
|
-
step: { id: "fetch", status: "completed", output: { count: 3 } },
|
|
355
|
-
});
|
|
356
|
-
receive({ executionId, status: "completed", output: { result: "ready" } });
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
- `subscribe` must resolve with an unsubscribe function only after feedback is
|
|
360
|
-
ready. Execution starts afterwards, so early events are not lost. SSE,
|
|
361
|
-
WebSockets, and polling can all implement this adapter.
|
|
362
|
-
- Your backend must use or correlate the supplied execution ID. Responses may
|
|
363
|
-
return an update, or nothing for an acknowledgement. Completion comes from
|
|
364
|
-
an explicit terminal status, not merely a successful HTTP response.
|
|
365
|
-
- `onChange` receives run status, per-step status/output, and final output.
|
|
366
|
-
Use your bindings to map step IDs to node IDs and update your diagram or
|
|
367
|
-
output panel; the controller does not mutate the workflow or canvas.
|
|
368
|
-
- A second run is rejected while one is active. Terminal updates release the
|
|
369
|
-
listener. Errors before terminal feedback reject `run()` and emit a failed
|
|
370
|
-
state; handle the rejection. Terminal feedback takes precedence over late
|
|
371
|
-
HTTP responses or errors. Each `run()` resolves with its own execution state.
|
|
372
|
-
- Step updates merge with the previous step: omitted output/error fields are
|
|
373
|
-
preserved; explicitly passing `undefined` clears them.
|
|
374
|
-
- Supply `adapter.cancel` to support `execution.cancel()`. Call
|
|
375
|
-
`execution.dispose()` on unmount to abort local requests and unsubscribe;
|
|
376
|
-
disposal does not cancel the remote job.
|
|
377
|
-
- Keep service credentials in your backend. The SDK does not select a server,
|
|
378
|
-
forward Squeed credentials, or translate workflows into another tool's format.
|
|
379
|
-
|
|
380
|
-
This API is for SDK hosts. It does not automatically wire the Squeed editor's
|
|
381
|
-
Execution panel or its Backflow-specific execution mapping.
|
|
382
|
-
|
|
383
|
-
## Maintainer Guide
|
|
384
|
-
|
|
385
|
-
The SDK Test **Form Connection** dataset loads
|
|
386
|
-
[examples/form-connection/ui.json](examples/form-connection/ui.json), its
|
|
387
|
-
[bindings](examples/form-connection/bindings.json), and the actual
|
|
388
|
-
[TypeScript interface](examples/form-connection/interface.ts). Double-click
|
|
389
|
-
**Generated Form** to edit the separate state shown by the State JSON node.
|
|
390
|
-
The test page preloads the bundled interface; manual uploads can replace it.
|
|
391
|
-
|
|
392
|
-
**Config Catalog** covers all 25 enabled Backflow step types with independently
|
|
393
|
-
bound, reusable configuration nodes. The full editor interface retains all
|
|
394
|
-
138 declared config fields, including JSON and dictionaries. This is form
|
|
395
|
-
coverage, not production execution validation. See the
|
|
396
|
-
[coverage and readiness checks](examples/workflow-form/README.md).
|
|
397
|
-
|
|
398
|
-
**Workflow State 2** loads the supplied
|
|
399
|
-
[Run Cast Session workflow](examples/workflow-state-2/workflow.json) as a
|
|
400
|
-
separate local dataset, with 16 step forms and 23 reusable tools. Its
|
|
401
|
-
[view generator](examples/workflow-state-2/example.ts) renders all tools in one
|
|
402
|
-
Object View node, with a distinct output port and connection identity per tool.
|
|
403
|
-
Its `portResources` binding maps those ports to individual state entries.
|
|
404
|
-
Forms edit `config`; the original `params`, `input`, and other
|
|
405
|
-
workflow fields are retained independently. Dependency links initialize the
|
|
406
|
-
view from `dependsOn`; diagram edits are not a production deployment adapter.
|
|
407
|
-
|
|
408
|
-
SDK Test's **Forms** popover exposes **Reusable configuration** after an
|
|
409
|
-
interface upload, or when a static mapping is configured. Choose an interface
|
|
410
|
-
and check the inline fields to lift into resource nodes. Object values use
|
|
411
|
-
Object View; compact form-bound nodes expose a floating dot to reveal their
|
|
412
|
-
properties, and the object header dot returns to the icon.
|
|
413
|
-
|
|
414
|
-
SDK Test fits the switched node or parent after layout completes. Its
|
|
415
|
-
`focusOptions` prop controls both click focus and dot-switch focus:
|
|
416
|
-
|
|
417
|
-
```tsx
|
|
418
|
-
<SDKTest focusOptions={{ animate: true, padding: 90 }} />
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
These are the defaults; `animate: false` makes the fit immediate, and `padding`
|
|
422
|
-
is in screen pixels. The SDK itself does not auto-focus on dot switches.
|
|
423
|
-
`callbacks.onNodeViewToggle(nodeId)` notifies a client of a dot action; clients
|
|
424
|
-
can queue `engine.focusNode(nodeId, padding, animate)` for `onLayoutComplete`.
|
|
425
|
-
|
|
426
|
-
Object rows with an empty string value and an attached property connection
|
|
427
|
-
show a full-width label without an empty value cell. Other fields retain both
|
|
428
|
-
columns, and row order, port identities, and saved values are unchanged.
|
|
429
|
-
|
|
430
|
-
The [mapping adapter](examples/workflow-state/resourceMapping.ts) uses the same
|
|
431
|
-
JSON-serializable definition for static setup and popover edits:
|
|
432
|
-
|
|
433
|
-
```ts
|
|
434
|
-
const resourceMappings = {
|
|
435
|
-
"workflow-state-2": {
|
|
436
|
-
version: 1 as const,
|
|
437
|
-
templates: true,
|
|
438
|
-
fields: [
|
|
439
|
-
{ type: "LlmConfig", field: "prompt" },
|
|
440
|
-
{ type: "LlmConfig", field: "model", createEmpty: true },
|
|
441
|
-
{ type: "DatabaseConfig", field: "data" },
|
|
442
|
-
],
|
|
443
|
-
},
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
<SDKTest resourceMappings={resourceMappings} />;
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
These are also the static defaults for Workflow State 2. An empty Model resource
|
|
450
|
-
does not add a model value to exported configuration until configured. Resource
|
|
451
|
-
forms retain their source interface through `StateFormBinding.schemaType`, so
|
|
452
|
-
reuploading the original interface does not require generated type declarations.
|
|
453
|
-
The popover imports/exports mapping JSON and exports a resolved workflow;
|
|
454
|
-
unmapping restores current resource values inline. Existing annotated resource
|
|
455
|
-
ports stay separate from user-selected inline mappings.
|
|
456
|
-
|
|
457
|
-
`templates` exposes runtime variables as Object View nodes and links step-output
|
|
458
|
-
references to their consuming property rows. Expressions are parsed, never
|
|
459
|
-
evaluated or rewritten; both sides of fallback expressions are represented.
|
|
460
|
-
Collapsing a node retains its links, and deleted template links are not restored
|
|
461
|
-
merely by rerendering. Runtime variable values are not fabricated.
|
|
462
|
-
|
|
463
|
-
[examples/squeed.json](examples/squeed.json) is an expandable diagram for new
|
|
464
|
-
maintainers: setup, architecture, data ownership, UI code, change recipes,
|
|
465
|
-
testing, workflow contracts, and SDK Test integration. Load it through the
|
|
466
|
-
`json` prop; the local Backflow admin SDK Test page includes it as **squeed**
|
|
467
|
-
alongside **advanced**. Its **File Map** chapter links concrete source files
|
|
468
|
-
with labeled runtime imports, type-only dependencies, re-exports, and tooling
|
|
469
|
-
relationships. **Trace a Change Across Files** explains callback/data flow and
|
|
470
|
-
ownership separately. The map covers important internal relationships, not every
|
|
471
|
-
external dependency. Tests verify mapped paths and import/export arrows against
|
|
472
|
-
the source tree. Edit this single JSON source to keep the guide current.
|
|
473
|
-
|
|
474
|
-
## Callbacks
|
|
475
|
-
|
|
476
|
-
`isNodeVisible(id, edges, edgeMode)` exposes the same edge-mode visibility rule
|
|
477
|
-
used by Canvas. Pass edge data, not `{ data }` wrappers. In property-edge mode,
|
|
478
|
-
`root` is hidden unless it has a property connection; other modes retain it.
|
|
479
|
-
Hosts measuring embedded content can filter with this predicate before waiting
|
|
480
|
-
for node boxes. It does not report measurement readiness or connection isolation.
|
|
481
|
-
|
|
482
|
-
### All Icon-Label Views
|
|
483
|
-
|
|
484
|
-
Inside a diagram, `useNodeViewActions()` (or `useFlowDiagramContext()`) exposes
|
|
485
|
-
`allNodesIconLabel` and `setAllNodesIconLabel(boolean)`. The bulk action reuses
|
|
486
|
-
`setNodeViewMode(id, "icon-label")` for objects/arrays and `onNodeCollapse` for
|
|
487
|
-
parents. Disable it to expand icon-label defaults into property views, restore
|
|
488
|
-
other default object views, and reopen parents. Dots use
|
|
489
|
-
the same per-node actions and remain interactive; there is no global view lock.
|
|
490
|
-
`allNodesIconLabel` reflects the current node modes.
|
|
491
|
-
|
|
492
|
-
For non-parent Object nodes with Markdown, HTML, or JSX `$content`, the expanded
|
|
493
|
-
header dot reuses `setNodeViewMode(id, "icon-label")`. It does not switch to an
|
|
494
|
-
empty properties header. Reopening reuses `restoreNodeView` and the existing
|
|
495
|
-
header/content rendering; the content source and parent-collapse behavior are
|
|
496
|
-
unchanged.
|
|
497
|
-
|
|
498
|
-
An explicit `$label: ""` on HTML/JSX content omits the expanded content header
|
|
499
|
-
and its dot. The node sizes to the preview's intrinsic width, capped at the
|
|
500
|
-
viewport width minus 40px, and grows or shrinks with the content height instead
|
|
501
|
-
of using the property-table minimum and fixed 360px preview height.
|
|
502
|
-
Explicit custom widths remain supported; Fill and fullscreen use their allocated
|
|
503
|
-
dimensions. HTML auto-height uses a nonce-protected measurement script and accepts
|
|
504
|
-
size messages only from that preview's iframe. Content scripts remain sanitized
|
|
505
|
-
out, and same-origin access remains disabled.
|
|
506
|
-
Internal HTML/JSX styling remains authoritative. Missing labels, named content,
|
|
507
|
-
Markdown and properties views retain their headers and sizing. Use
|
|
508
|
-
`$borderRadius: 0` independently for square corners. Existing content source and
|
|
509
|
-
fullscreen controls remain available.
|
|
510
|
-
|
|
511
|
-
### Live JSX Content References
|
|
512
|
-
|
|
513
|
-
Inside JSX `$content`, a value can reference another node's JSX content:
|
|
514
|
-
|
|
515
|
-
```json
|
|
516
|
-
{
|
|
517
|
-
"type": "text",
|
|
518
|
-
"text": {
|
|
519
|
-
"$contentRef": "root.navigation",
|
|
520
|
-
"path": [0, "children", 1, "text"]
|
|
521
|
-
},
|
|
522
|
-
"rawStyle": { "fontSize": "28px" }
|
|
523
|
-
}
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
`path` is relative to the source node's `$content` array. Omitting it references
|
|
527
|
-
the whole array, for example `"children": { "$contentRef": "root.header" }`.
|
|
528
|
-
Referenced values retain their types; arrays are not implicitly flattened.
|
|
529
|
-
Optional literal `prefix` and `suffix` strings format string values, such as
|
|
530
|
-
keeping an image gradient before a referenced CSS image URL. No code executes.
|
|
531
|
-
|
|
532
|
-
References resolve within the current document at compilation. Updating the
|
|
533
|
-
source updates the rendered consumer; source JSON and the consumer's other
|
|
534
|
-
styles remain unchanged. The source editor preserves reference JSON rather than
|
|
535
|
-
saving the resolved copy. To detach a value intentionally, replace its reference
|
|
536
|
-
with a literal. Ordinary `$target` edges remain connections, not content bindings.
|
|
537
|
-
Index paths refer to positions: update them when restructuring source components,
|
|
538
|
-
or reference a whole children array when its membership should follow the source.
|
|
539
|
-
|
|
540
|
-
Only JSX sources are supported. Missing paths, cycles, unsafe property names,
|
|
541
|
-
and expansion beyond 100 levels or 100,000 visits produce an error in the affected
|
|
542
|
-
preview rather than aborting the graph. References do not fetch external data or
|
|
543
|
-
cross document ownership boundaries.
|
|
544
|
-
|
|
545
|
-
In `FlowDiagram`, enabling the bulk action also suspends `forms.structured`:
|
|
546
|
-
generated detail nodes and structured form lists disappear without changing the
|
|
547
|
-
workflow data. Disabling it restores the configured `forms.structured` setting
|
|
548
|
-
and the generated nodes' default views. An initially false or omitted setting
|
|
549
|
-
stays disabled. Individual node-view actions do not change this setting.
|
|
550
|
-
|
|
551
|
-
`NodeViewMode` supports `"default"`, `"properties"` and `"icon-label"`; controlled
|
|
552
|
-
consumers continue using `config.nodeViewModes` and `onNodeViewModeChange`.
|
|
553
|
-
Dot-triggered selection includes `NodeSelectionModifiers.viewToggle: true`;
|
|
554
|
-
ordinary selections omit it. The dot invokes `onNodeViewToggle` before changing
|
|
555
|
-
the view so a host can queue geometry-aware focus without first focusing the
|
|
556
|
-
compact node. SDK Test centers the opened node using its existing default focus
|
|
557
|
-
padding; ordinary clicks still honor Include children. The layout scheduler
|
|
558
|
-
coalesces measurements and does not restart a pending focus for identical
|
|
559
|
-
destination geometry.
|
|
560
|
-
Parent changes follow the host's existing collapse persistence behavior. The
|
|
561
|
-
name `collapsed` remains reserved for child-collapse behavior, not object view
|
|
562
|
-
modes. `onAllNodesIconLabelChange` reports bulk actions. The bottom toolbar exposes
|
|
563
|
-
**Collapse all** immediately after **Compact layout**; SDK Test also exposes
|
|
564
|
-
the action as **All icon labels** under Visibility and fits the resulting layout.
|
|
565
|
-
|
|
566
|
-
### Reusable Nodes From Property Draws
|
|
567
|
-
|
|
568
|
-
SDK Test's **Blank Workflow** starts with zero nodes, steps and resources. The
|
|
569
|
-
canvas **Create node** button opens the existing reusable-node picker without a
|
|
570
|
-
source port. It creates one standalone step with an empty configuration and no
|
|
571
|
-
connection. Subsequent nodes can be created by dragging ports into empty canvas;
|
|
572
|
-
these use the same picker and the existing typed-port and dependency mapping.
|
|
573
|
-
Canceling the picker does not change the graph. No example workflow is imported.
|
|
574
|
-
|
|
575
|
-
SDK Test opens a reusable-node picker when a Properties-mode draw ends on empty
|
|
576
|
-
canvas. It reuses `NodeFormPopover` with a top filter, a fixed-height scrolling
|
|
577
|
-
list and the form vignette. Items use the current JSON bindings, interfaces and
|
|
578
|
-
icons; incompatible ports are disabled and multiple compatible ports can be
|
|
579
|
-
selected explicitly. Closing the modal makes no changes.
|
|
580
|
-
|
|
581
|
-
`callbacks.onNodeCreateRequest(request)` lets a host defer creation by returning
|
|
582
|
-
`true`. The request contains `sourceNodeId`, `sourceProperty`, `reverse` and the
|
|
583
|
-
model-space `position`. A workflow template creates a new step through the
|
|
584
|
-
configured collection/identity/dependency fields; an existing reusable retains
|
|
585
|
-
its shared state and connection. Node-mode drawing is unchanged.
|
|
586
|
-
|
|
587
|
-
Default Set and Array draws label new entries `Untitled 1`, `Untitled 2`, and
|
|
588
|
-
so on, using the next unused number among the parent's existing labels. Both
|
|
589
|
-
modes share that sequence. JSON keys such as `node_1`, `list_1`, and numeric
|
|
590
|
-
array indexes remain unchanged; the display name is stored in `$label` and
|
|
591
|
-
survives serialization. Existing names and form-generated labels are preserved.
|
|
592
|
-
Set mode creates one entry. The first Array draw from a source creates two
|
|
593
|
-
siblings in one update; later draws create one, including after reload.
|
|
594
|
-
|
|
595
|
-
After layout, `engine.setNodePosition(id, position)` places a measured node at
|
|
596
|
-
the draw endpoint without changing viewport zoom or pan. This renderer-local
|
|
597
|
-
placement is retained across relayouts while the node remains rendered; pass
|
|
598
|
-
`undefined` to release it back to automatic layout. It is not serialized into
|
|
599
|
-
the workflow document.
|
|
600
|
-
|
|
601
|
-
Use `engine.setNodePosition(id, position, { persist: false })` for an initial
|
|
602
|
-
drop placement that settles into the size-aware automatic layout. The example
|
|
603
|
-
creation picker uses this mode so object expansion, property edits, and the
|
|
604
|
-
spacing slider can reposition new nodes without retaining their drop positions.
|
|
605
|
-
|
|
606
|
-
### Node Collisions
|
|
607
|
-
|
|
608
|
-
Collision handling is opt-in through `FlowEngine`; the SDK does not automatically
|
|
609
|
-
resolve overlaps or enable node dragging. Call after measurement/layout (for
|
|
610
|
-
example from `onLayoutComplete`) or after explicitly placing nodes:
|
|
611
|
-
|
|
612
|
-
```ts
|
|
613
|
-
const collisions = engine.detectNodeCollisions({ margin: 15 });
|
|
614
|
-
const result = engine.resolveNodeCollisions({ margin: 15, animate: true });
|
|
615
|
-
// result: { positions, movedNodeIds, collisions, iterations, resolved }
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
`detectNodeCollisions` does not change state. It returns pairs with `source`,
|
|
619
|
-
`target`, and `overlap: { x, y }`, using axis-aligned measured bounds and a gap
|
|
620
|
-
of `margin` model units (default 15). Only visible layout nodes participate.
|
|
621
|
-
Siblings are compared at every hierarchy level; parent-child containment is
|
|
622
|
-
intentional, and conflicts between branches are reported as container pairs.
|
|
623
|
-
Container padding and label minimum width are included, but edge paths and
|
|
624
|
-
edge-label collisions are outside this API.
|
|
625
|
-
|
|
626
|
-
Resolution moves sibling groups with their descendants, preserving nodes pinned
|
|
627
|
-
by `setNodePosition` with persistent placement. A group containing a pinned node
|
|
628
|
-
cannot be translated. It uses at most `maxIterations` (default 50, allowed 0-1000)
|
|
629
|
-
and reports remaining collisions rather than moving pinned nodes or looping
|
|
630
|
-
indefinitely. Invalid margins/iteration limits throw `RangeError`.
|
|
631
|
-
|
|
632
|
-
`positions` is an independent map of target leaf positions, not animation progress;
|
|
633
|
-
`movedNodeIds` lists changed leaves and `collisions` lists unresolved target pairs.
|
|
634
|
-
`animate` defaults to true and reuses the layout animation driver; reduced motion,
|
|
635
|
-
`config.disableAnimations`, and performance mode apply immediately. Pan/zoom stays
|
|
636
|
-
unchanged, pending automatic viewport actions are cancelled when nodes move, and
|
|
637
|
-
resolution does not emit `onLayoutComplete` again. Another layout or explicit
|
|
638
|
-
position change can interrupt it. Results are renderer-local, are not pinned or
|
|
639
|
-
written into JSON, and may be replaced by the next automatic layout.
|
|
640
|
-
|
|
641
|
-
### Swappable Grid Mode
|
|
642
|
-
|
|
643
|
-
One graph-level call hides edges, edge labels, collapse icons and connection handles, arranges
|
|
644
|
-
visible nodes in a measured grid, then enables drag-to-swap after placement:
|
|
645
|
-
|
|
646
|
-
```ts
|
|
647
|
-
engine.setNodeGridMode(true, { columns: 3, margin: 40, animate: true });
|
|
648
|
-
engine.swapGridNodes(sourceId, targetId); // Optional programmatic swap
|
|
649
|
-
engine.setNodeGridMode(false); // Restore pre-grid positions and edge visibility
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
Drop a node onto a sibling's center to exchange their slots. Drop near its left
|
|
653
|
-
or right edge to insert into that row, or near its top or bottom edge to add a
|
|
654
|
-
row. An insertion line previews the destination without saving until release.
|
|
655
|
-
The insertion target extends 24 screen pixels outside the edge, including when
|
|
656
|
-
zoomed out or embedded in a scaled parent. Interior targets remain capped at a
|
|
657
|
-
quarter of the node dimension; the insertion line stays 3 screen pixels thick.
|
|
658
|
-
Start the drag on a title, icon, or non-interactive surface; embedded editors and
|
|
659
|
-
form controls retain their own pointer behavior.
|
|
660
|
-
Dropping outside the canvas or pressing Escape cancels the drag. Shift-drag
|
|
661
|
-
continues to use the host's transfer/grouping callback. A valid ordinary boundary
|
|
662
|
-
insertion takes priority over that callback, so a Grid member can be a sibling
|
|
663
|
-
insertion target without transferring the dragged node into its document.
|
|
664
|
-
Read-only mode prevents swaps and insertion. The original JSON, edges
|
|
665
|
-
and parent relationships are not changed. Sibling grids preserve parent groups;
|
|
666
|
-
swaps across parents are rejected. Sibling sets containing persistent pinned
|
|
667
|
-
nodes are not rearranged or swapped. Grid order survives layout/size changes
|
|
668
|
-
while the mode is active. It is renderer-local and is not saved in the document.
|
|
669
|
-
|
|
670
|
-
Explicit row membership uses
|
|
671
|
-
`options.adjustment.sections[sectionId].members: string[][]`, with `canvas` for
|
|
672
|
-
top-level siblings and the parent node ID for nested sibling groups. It applies
|
|
673
|
-
with or without Fill and independently of adjustment-handle visibility. Existing
|
|
674
|
-
rows retain their relative membership; newly arriving nodes use the column
|
|
675
|
-
setting for additional rows and missing nodes are omitted. Member IDs must be
|
|
676
|
-
nonempty strings, unique within a section. Row and column proportions continue
|
|
677
|
-
to use the existing `rows` and `columns` arrays. Hosts can persist the updated
|
|
678
|
-
options through their existing canvas configuration save path, as Squeed does.
|
|
679
|
-
|
|
680
|
-
The bottom toolbar's **Collision mode** button uses this same API. While active,
|
|
681
|
-
it shows the existing compact gap slider and a **Fill** toggle. These controls
|
|
682
|
-
stay synchronized with programmatic mode changes.
|
|
683
|
-
|
|
684
|
-
`columns` defaults to `ceil(sqrt(siblingCount))` without fill; `gaps` accepts a
|
|
685
|
-
number or `{ x, y }`, falling back to `margin` (15 model units). `animate` defaults
|
|
686
|
-
to true; reduced motion and the animation kill switch are respected. Ordinary
|
|
687
|
-
grid entry and exit center and fit with 80px viewport padding using the same queued
|
|
688
|
-
fit as direction changes, coordinated with placement and subsequent size updates.
|
|
689
|
-
Manual pan/zoom cancels the queued fit. Gap changes and swaps preserve zoom/pan.
|
|
690
|
-
Fill retains its separate tile padding and 1:1 viewport behavior.
|
|
691
|
-
For arrangement without hiding edges or enabling swaps,
|
|
692
|
-
use `engine.arrangeNodesInGrid(options)`, which returns `positions`, `movedNodeIds`,
|
|
693
|
-
`skippedNodeIds` and remaining `collisions` without changing graph data.
|
|
694
|
-
|
|
695
|
-
```ts
|
|
696
|
-
engine.setNodeGridMode(true, { fill: true, gaps: 0 });
|
|
697
|
-
```
|
|
698
|
-
|
|
699
|
-
Fill resizes the existing node tiles to cover the canvas, not just their positions.
|
|
700
|
-
It picks columns from the canvas aspect ratio and expands the final row to avoid
|
|
701
|
-
empty cells. `padding` defaults to 0; gaps are constrained when needed to keep cells
|
|
702
|
-
positive. Fill uses a 1:1 viewport (subject to configured zoom limits), with size,
|
|
703
|
-
position and viewport animation coordinated. It reflows on canvas resize and keeps
|
|
704
|
-
swapping enabled. Turning Fill off restores natural node sizes and queues an 80px
|
|
705
|
-
center-and-fit; exiting the mode
|
|
706
|
-
centers and fits the restored graph. `arrangeNodesInGrid` returns target `sizes`
|
|
707
|
-
and `bounds` when filling. These overrides never change the saved document.
|
|
708
|
-
|
|
709
|
-
On initial Fill load, the canvas measures the visible destination and uses the
|
|
710
|
-
existing Fill calculation to allocate cells before mounting node content. This
|
|
711
|
-
skips the preliminary natural-view mount and initial layout debounce. Hidden
|
|
712
|
-
destinations wait until measurable; weighted rows, spacing, nested loading,
|
|
713
|
-
saved viewports, subsequent resizing and natural sizing on exit are preserved.
|
|
714
|
-
Document preparation still uses its existing two-frame loading gate.
|
|
715
|
-
|
|
716
|
-
### Animated Viewport Actions
|
|
717
|
-
|
|
718
|
-
Capture `FlowEngine` through `callbacks.onInit`. Set `config.animateViewport`
|
|
719
|
-
to animate viewport actions by default, or pass a boolean per call:
|
|
720
|
-
|
|
721
|
-
```ts
|
|
722
|
-
engine.fit(60, true);
|
|
723
|
-
engine.centerAndFit(60, true);
|
|
724
|
-
engine.center(true);
|
|
725
|
-
engine.focusNode(nodeId, 60, true);
|
|
726
|
-
engine.focusBranch(nodeId, 60, true);
|
|
727
|
-
engine.isolateBranch(nodeId, 60, true);
|
|
728
|
-
engine.restoreView(true);
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
Pass `true` as the fourth argument to `focusBranch`, `focusNode`, or
|
|
732
|
-
`focusConnections` after a view toggle to fit the new geometry together with
|
|
733
|
-
the layout animation. Existing three-argument calls keep their behavior.
|
|
734
|
-
|
|
735
|
-
`focusBranch` accepts `centerOnNode` as its fifth argument and `zoomScale` as
|
|
736
|
-
its sixth (default `1`). For example,
|
|
737
|
-
`engine.focusBranch(nodeId, 40, true, false, true, 0.6)` keeps the selected node
|
|
738
|
-
centered and applies 60% of the fitted zoom, subject to existing zoom limits.
|
|
739
|
-
Omitting the scale preserves the previous branch fit.
|
|
740
|
-
|
|
741
|
-
For a closing preview in an ordinary document canvas, use
|
|
742
|
-
`engine.restoreView(true, savedViewport, true)` alongside the view change.
|
|
743
|
-
The optional third argument restores the saved viewport in the same transition
|
|
744
|
-
as the closing layout. It does not change Grid/Fill or isolation restoration;
|
|
745
|
-
existing one- and two-argument calls retain their behavior.
|
|
746
|
-
|
|
747
|
-
Animation defaults to false. Explicit false overrides the config default.
|
|
748
|
-
Transitions interpolate pan and zoom over 300ms; center preserves zoom.
|
|
749
|
-
Reduced-motion preferences disable animation. New viewport commands cancel
|
|
750
|
-
previous transitions, and unmount cancels pending frames. Methods return when
|
|
751
|
-
dispatched, not when animation finishes; `onViewportChange` reports intermediate
|
|
752
|
-
and final positions. Use `onLayoutComplete(engine)` to fit newly laid-out data:
|
|
753
|
-
|
|
754
|
-
```tsx
|
|
755
|
-
<FlowDiagram
|
|
756
|
-
config={{ animateViewport: true }}
|
|
757
|
-
callbacks={{ onLayoutComplete: (engine) => engine.centerAndFit(60) }}
|
|
758
|
-
/>
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
This callback runs after each settled layout, not viewport-only changes. Hosts
|
|
762
|
-
that only want to fit after dataset selection should gate it with a pending flag.
|
|
763
|
-
|
|
764
|
-
For a view change that should move nodes and the viewport together, call
|
|
765
|
-
`engine.centerAndFit(60, true, true)` before changing direction, compact layout,
|
|
766
|
-
or node presentation. The third argument defers fitting until target geometry
|
|
767
|
-
is available, using the layout's 300ms animation progress rather than a second
|
|
768
|
-
fit from `onLayoutComplete`. `focusNode` and `focusConnections` accept the same
|
|
769
|
-
option as their fourth argument. Manual zoom and pan cancel viewport motion.
|
|
770
|
-
|
|
771
|
-
Set `config.disableAnimations: true` to disable SDK layout, viewport, node/edge
|
|
772
|
-
effects, reveal, and in-diagram CSS transitions. It defaults to `false` and takes
|
|
773
|
-
precedence over `animateViewport` and per-action `true` arguments. Active motion
|
|
774
|
-
lands on its target; changing the flag back to `false` restores configured
|
|
775
|
-
animations. Embedded content and application-owned playback are not controlled
|
|
776
|
-
by this flag.
|
|
777
|
-
|
|
778
|
-
### Structured Form Bindings
|
|
779
|
-
|
|
780
|
-
Set `forms.structured: true` with `forms.state`, `forms.bindings` and
|
|
781
|
-
`config.formSchema` to author nested objects and arrays through flow nodes.
|
|
782
|
-
Use `config.edgeMode: "properties"` for their input and output handles.
|
|
783
|
-
This is opt-in; existing form consumers keep their current controls.
|
|
784
|
-
|
|
785
|
-
Objects expose typed scalar fields and nested configuration ports. Arrays have
|
|
786
|
-
ordered item nodes with add, remove and move controls. Open dictionaries expose
|
|
787
|
-
property-name and value-type controls. JSON and mixed-type values have typed
|
|
788
|
-
value nodes instead of JSON textareas. Existing resource option selectors remain
|
|
789
|
-
available. Missing optional values are not created until the user adds them.
|
|
790
|
-
|
|
791
|
-
Dragging an empty configuration port into space creates its value node.
|
|
792
|
-
Connecting a compatible value node to another field copies the value into that
|
|
793
|
-
field; it does not create a shared reference. Subsequent edits are independent.
|
|
794
|
-
Deleting an ownership edge or generated node removes the value; array deletion
|
|
795
|
-
compacts the remaining indices. Reordering changes index-based item identities.
|
|
796
|
-
All edits use `forms.onStateChange` (or `onChange`) and preserve the original
|
|
797
|
-
inline state/export shape. Read-only diagrams disable these mutations.
|
|
798
|
-
|
|
799
|
-
Generated nodes, ports and schemas are derived, not written into your view JSON;
|
|
800
|
-
their appearance is inherited rather than saved through document style callbacks.
|
|
801
|
-
Existing explicit bindings at the same state address are reused. Projection is
|
|
802
|
-
limited to 24 levels and 512 form nodes, using the SDK's existing safe dot-path
|
|
803
|
-
property addressing. Custom `renderForm` implementations remain host-owned.
|
|
804
|
-
|
|
805
|
-
### Compose Your Own Controls
|
|
806
|
-
|
|
807
|
-
### Upload Form Fields
|
|
808
|
-
|
|
809
|
-
Set `$control: "upload"` in `forms.bindings[nodeAddress].fields` (or the
|
|
810
|
-
document node's `$form.$fields`). A `string` property is a single-file field;
|
|
811
|
-
an `array` of strings is a multiple-file field. Values are stored URLs, never
|
|
812
|
-
`File` objects or temporary browser blob URLs. Upload arrays remain inline
|
|
813
|
-
controls even with `forms.structured: true`.
|
|
814
|
-
|
|
815
|
-
```tsx
|
|
816
|
-
const formSchema = {
|
|
817
|
-
Attachments: {
|
|
818
|
-
kind: "object",
|
|
819
|
-
properties: {
|
|
820
|
-
cover: { type: { kind: "string" }, optional: true },
|
|
821
|
-
files: {
|
|
822
|
-
type: { kind: "array", items: { kind: "string" } },
|
|
823
|
-
optional: true,
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
},
|
|
827
|
-
} satisfies FormSchema;
|
|
828
|
-
|
|
829
|
-
<FlowDiagram
|
|
830
|
-
json={{ attachments: { $label: "Attachments", $view: "object" } }}
|
|
831
|
-
config={{ formSchema, editable: true }}
|
|
832
|
-
forms={{
|
|
833
|
-
state,
|
|
834
|
-
bindings: {
|
|
835
|
-
"root.attachments": {
|
|
836
|
-
address: "root.record",
|
|
837
|
-
type: "Attachments",
|
|
838
|
-
fields: {
|
|
839
|
-
cover: {
|
|
840
|
-
$control: "upload",
|
|
841
|
-
$upload: { accept: "image/*", maxSizeBytes: 5_000_000 },
|
|
842
|
-
},
|
|
843
|
-
files: { $control: "upload", $upload: { accept: "image/*,.pdf" } },
|
|
844
|
-
},
|
|
845
|
-
},
|
|
846
|
-
},
|
|
847
|
-
onStateChange: setState,
|
|
848
|
-
}}
|
|
849
|
-
callbacks={{
|
|
850
|
-
uploadFormFile: ({ file, address, nodeAddress, data, signal }) =>
|
|
851
|
-
uploadToStorage(file, { address, nodeAddress, data, signal }),
|
|
852
|
-
}}
|
|
853
|
-
/>;
|
|
854
|
-
```
|
|
855
|
-
|
|
856
|
-
`uploadToStorage` is your host's uploader, not an SDK service. The callback
|
|
857
|
-
receives a `FormUploadRequest` (file, field/node addresses, optional node ID,
|
|
858
|
-
read-only form data, and an abort signal) and must return an HTTP(S) file URL
|
|
859
|
-
without embedded credentials, synchronously or as a promise. The app's
|
|
860
|
-
`SDKTest` surface accepts the same optional `uploadFormFile` prop. No storage
|
|
861
|
-
endpoint, credentials, or automatic upload service is supplied.
|
|
862
|
-
|
|
863
|
-
Empty fields show a dashed rounded square with a centered plus; click or drop
|
|
864
|
-
files to upload. Single-file fields replace that square with one preview and
|
|
865
|
-
replace/remove controls. Multiple-file fields append previews in selection
|
|
866
|
-
order and retain an add-more square. Non-image files have a file-link fallback.
|
|
867
|
-
Uploading disables mutations on that field; failed batches preserve its prior
|
|
868
|
-
value. Closing the form, changing the bound value, or disabling editing aborts
|
|
869
|
-
pending work and ignores late results. Hosts should honor `signal` and handle
|
|
870
|
-
cleanup of files already stored during a failed/cancelled batch. Removing a URL
|
|
871
|
-
changes form data only; it does not delete the server file. File type/size checks
|
|
872
|
-
are optional client checks and must also be enforced by the host/server.
|
|
873
|
-
|
|
874
|
-
### Compose Your Own Controls
|
|
875
|
-
|
|
876
|
-
All reusable control components are exported from `@squeed/flow-sdk` through
|
|
877
|
-
[src/index.ts](src/index.ts). Hide the default toolbar with `showBottomBar={false}`
|
|
878
|
-
and mount your controls as children to share the diagram and form providers:
|
|
879
|
-
|
|
880
|
-
```tsx
|
|
881
|
-
import {
|
|
882
|
-
FlowDiagram,
|
|
883
|
-
WorkflowControls,
|
|
884
|
-
DiagramAppearanceControls,
|
|
885
|
-
SvgExportButton,
|
|
886
|
-
ToolbarDivider,
|
|
887
|
-
} from "@squeed/flow-sdk";
|
|
888
|
-
|
|
889
|
-
<FlowDiagram
|
|
890
|
-
json={view}
|
|
891
|
-
forms={forms}
|
|
892
|
-
callbacks={callbacks}
|
|
893
|
-
showBottomBar={false}
|
|
894
|
-
>
|
|
895
|
-
<div
|
|
896
|
-
style={{
|
|
897
|
-
position: "absolute",
|
|
898
|
-
bottom: 20,
|
|
899
|
-
left: 20,
|
|
900
|
-
right: 20,
|
|
901
|
-
display: "flex",
|
|
902
|
-
alignItems: "center",
|
|
903
|
-
overflowX: "auto",
|
|
904
|
-
zIndex: 100,
|
|
905
|
-
}}
|
|
906
|
-
>
|
|
907
|
-
<WorkflowControls />
|
|
908
|
-
<ToolbarDivider />
|
|
909
|
-
<DiagramAppearanceControls />
|
|
910
|
-
<SvgExportButton />
|
|
911
|
-
</div>
|
|
912
|
-
</FlowDiagram>;
|
|
913
|
-
```
|
|
914
|
-
|
|
915
|
-
| Category | Public exports |
|
|
916
|
-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
917
|
-
| Toolbar primitives | `ToolbarIconButton`, `ToolbarTooltip`, `ToolbarDivider`, `ToolbarSelect`, `ToolbarScrollContainer`, `TooltipIconButton`, `ToolbarCommitInput`, `ToolbarCloseButton` |
|
|
918
|
-
| Selection controls | `NodeTools`, `EdgeTools`, `Swatches`, `NodeBorderRadiusControl`, `NodeIconPicker`, `DEFAULT_PALETTE`, `TEXT_PALETTE` |
|
|
919
|
-
| Control groups | `BottomBar`, `WorkflowControls`, `DiagramAppearanceControls`, `SvgExportButton` |
|
|
920
|
-
| Forms | `NodeForm`, `NodeFormPopover`, `NodeConfigSummary`, `FormDocumentContext` |
|
|
921
|
-
| Composition | `FlowDiagramProvider`, `FlowView`, `useFlowDiagramContext`, `useFlowData`, `FlowDiagramContextValue` |
|
|
922
|
-
| Feedback | `ErrorToast` |
|
|
923
|
-
|
|
924
|
-
`ToolbarSelect` accepts optional `pinned` (default `false`), `open`, and
|
|
925
|
-
`onOpenChange` props. Pinning disables native outside-click dismissal and keeps
|
|
926
|
-
standard option selections open, preserving the existing DOM, position, scroll,
|
|
927
|
-
and focus. The trigger and Escape still close it explicitly. Custom
|
|
928
|
-
`popupContent` owns its selection-close behavior. With `popupContent` and
|
|
929
|
-
`footer`, the footer stays outside the scrolling content. Omit the new props
|
|
930
|
-
to retain the existing uncontrolled dropdown behavior.
|
|
931
|
-
|
|
932
|
-
Use `useFlowDiagramContext()` inside a child component for mode setters,
|
|
933
|
-
selection, bound edit callbacks and `engineRef`; `useFlowData()` supplies node
|
|
934
|
-
and edge lookups. Its maps are read-only by convention: do not mutate them.
|
|
935
|
-
Standalone controls outside these providers cannot access a diagram. For an
|
|
936
|
-
external DOM toolbar, render a React portal from a child component so context
|
|
937
|
-
is preserved. `SvgExportButton` needs a DOM ancestor with `data-flow-diagram`,
|
|
938
|
-
so use the public `exportSvg` helper when your export button is portaled outside it.
|
|
939
|
-
|
|
940
|
-
`FlowDiagramProvider` plus `FlowView` supports advanced raw-graph composition;
|
|
941
|
-
it does not compile JSON or create form state. Prefer `FlowDiagram` children
|
|
942
|
-
for document mode. Context mode setters do not override explicitly controlled
|
|
943
|
-
config props; the host must update those props. Selection setters change state
|
|
944
|
-
only; invoke selection callbacks explicitly if your custom UI requires them.
|
|
945
|
-
`NodeTools`/`EdgeTools` receive selected IDs and an `onClose` handler. Their
|
|
946
|
-
edit actions use bound callbacks, preserving document-mode updates.
|
|
947
|
-
|
|
948
|
-
The main toolbar's individual mode buttons remain part of `BottomBar`; compose
|
|
949
|
-
equivalent buttons with `ToolbarIconButton` and the context setters. Appearance
|
|
950
|
-
sliders are exposed together through `DiagramAppearanceControls`.
|
|
951
|
-
|
|
952
|
-
### Named Ports In Custom Views
|
|
953
|
-
|
|
954
|
-
Use `FlowPort` inside a custom node component with `config.edgeMode: "auto"` or `"properties"`
|
|
955
|
-
and `config.edgeHandles: true`. Port IDs must be unique within a node.
|
|
956
|
-
|
|
957
|
-
```tsx
|
|
958
|
-
<FlowPort id="true" role="source">True</FlowPort>
|
|
959
|
-
<FlowPort id="false" role="source">False</FlowPort>
|
|
960
|
-
<FlowPort id="input" role="target">Input</FlowPort>
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
The engine measures each port row and supplies connection handles at the node
|
|
964
|
-
boundary. Outputs are on the right and inputs on the left, reversed in RL mode.
|
|
965
|
-
Top/bottom anchors are not supported yet. These ports do not require object
|
|
966
|
-
property rows or form state fields. Existing `sourceProperty`/`targetProperty`
|
|
967
|
-
edge fields carry the port IDs, including in `onEdgeCreate`. The host owns edge
|
|
968
|
-
persistence and any resulting workflow-state changes. Enable Draw mode to connect.
|
|
969
|
-
|
|
970
|
-
### Schema-Bound Node Creation
|
|
971
|
-
|
|
972
|
-
For independent workflow state, use the `forms` prop and external node bindings;
|
|
973
|
-
see [Independent Workflow State](examples/workflow-state/README.md). This keeps
|
|
974
|
-
form values outside the Squeed document and supports state-backed `$content`.
|
|
975
|
-
The `$form` document binding described here remains a legacy-compatible mode.
|
|
976
|
-
|
|
977
|
-
In legacy JSON mode, a selected form-bound node has a gear that opens its
|
|
978
|
-
configuration in a screen-sized dialog. The form resolves `$form.$type` using
|
|
979
|
-
`config.formSchema` or the **Upload workflow interface** control, which also
|
|
980
|
-
supplies connection validation. Nested objects and
|
|
981
|
-
non-enum arrays are edited as validated JSON; simple fields use inferred controls.
|
|
982
|
-
|
|
983
|
-
To create a typed item when drawing from a node into empty space, declare:
|
|
984
|
-
|
|
985
|
-
```json
|
|
986
|
-
{
|
|
987
|
-
"workflow": {
|
|
988
|
-
"$label": "Trigger",
|
|
989
|
-
"$form": {
|
|
990
|
-
"$type": "Workflow",
|
|
991
|
-
"$create": {
|
|
992
|
-
"$address": "root.workflow.steps",
|
|
993
|
-
"$type": "Step",
|
|
994
|
-
"$label": "Step",
|
|
995
|
-
"$edgeLabel": "Next",
|
|
996
|
-
"$defaults": { "name": "New step", "type": "conditional" }
|
|
997
|
-
}
|
|
998
|
-
},
|
|
999
|
-
"name": "Orders",
|
|
1000
|
-
"trigger": "manual",
|
|
1001
|
-
"steps": []
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
```
|
|
1005
|
-
|
|
1006
|
-
The schema must define `Workflow.steps` as an object array and expose `Step`.
|
|
1007
|
-
Upload discovers both binding types. Creation appends to that array, gives a
|
|
1008
|
-
string `id` field a UUID, copies the form/creation binding, and adds a labeled
|
|
1009
|
-
`$connections` link from the source. One `onJsonChange` reports the new node.
|
|
1010
|
-
Required fields receive initial values; strings may remain empty and require
|
|
1011
|
-
configuration. `$defaults` supplies explicit initial values. Further draws from
|
|
1012
|
-
the new step append siblings to the same destination. Untyped drawing is unchanged.
|
|
1013
|
-
The link label does not execute sequence or if/else logic; those semantics remain
|
|
1014
|
-
the host application's responsibility.
|
|
1015
|
-
|
|
1016
|
-
### SVG Download
|
|
1017
|
-
|
|
1018
|
-
The expanded toolbar's **Download SVG** icon exports the current graph view,
|
|
1019
|
-
including HTML nodes, SVG edges and the background, without toolbar buttons or
|
|
1020
|
-
drawing handles. Pan and zoom are preserved; off-screen content is not fitted
|
|
1021
|
-
automatically. The exporter is loaded on demand.
|
|
1022
|
-
|
|
1023
|
-
For custom UI, call `downloadSvg(element, "diagram.svg")`, or use
|
|
1024
|
-
`await exportSvg(element)` to obtain an SVG data URL. Pass the diagram's
|
|
1025
|
-
`[data-flow-background]` element. The SVG embeds styled HTML via `foreignObject`:
|
|
1026
|
-
it works in browsers but is not a pure-path SVG for every vector editor.
|
|
1027
|
-
Remote images/fonts need accessible URLs and may be limited by CORS.
|
|
1028
|
-
|
|
1029
|
-
### Edge Shapes
|
|
84
|
+
The container must have a height. Styles are injected automatically; no CSS
|
|
85
|
+
import is required. Keep your existing Chakra provider if your app already has
|
|
86
|
+
one.
|
|
1030
87
|
|
|
1031
|
-
|
|
1032
|
-
`rounded-orthogonal` (default). `edge.data.type` overrides it for one raw edge.
|
|
1033
|
-
Register custom SVG geometry factories in `config.customEdgeTypes`; their keys
|
|
1034
|
-
also appear in the selected-edge toolbar's **Edge shape** menu.
|
|
88
|
+
## Editing Model
|
|
1035
89
|
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
The selector follows `selectionToolbar.hide: ["style"]` and read-only mode.
|
|
90
|
+
`json` accepts a parsed object or array. Edits produce a new document via
|
|
91
|
+
`onJsonChange(next, change)`; store `next` and pass it back as `json`. Granular
|
|
92
|
+
callbacks still fire for notifications, but should not apply the same edit
|
|
93
|
+
again. With `nodes`/`edges` instead, your app owns graph updates and collapse
|
|
94
|
+
filtering.
|
|
1042
95
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
and `defaultGeometry`. Return `{ d, label: { x, y, angle }, arrow? }` in model
|
|
1046
|
-
coordinates; `arrow` is an optional filled SVG path. Return `null` to use the
|
|
1047
|
-
default route. The SDK retains selection, colors, dash animation, and labels.
|
|
1048
|
-
|
|
1049
|
-
### Node Events
|
|
1050
|
-
|
|
1051
|
-
| Callback | Signature | Description |
|
|
1052
|
-
| -------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
1053
|
-
| `onNodeSelect` | `(nodeId, nodeData) => void` | Node clicked/selected |
|
|
1054
|
-
| `onNodeDeselect` | `() => void` | Selection cleared |
|
|
1055
|
-
| `onNodeDoubleClick` | `(nodeId, nodeData) => void` | Node double-clicked |
|
|
1056
|
-
| `onNodeCreate` | `(params) => void` | Node created via edge drawing into empty space |
|
|
1057
|
-
| `onNodeDelete` | `(nodeId, nodeData) => void` | Node deleted |
|
|
1058
|
-
| `onNodeLabelChange` | `(nodeId, newLabel) => void` | Node label edited inline |
|
|
1059
|
-
| `onNodeContentChange` | `(nodeId, content: string) => void` | Multiline content saved; raw-graph consumers store `data.config.content` |
|
|
1060
|
-
| `onNodeAnimationChange` | `(nodeId, animated: boolean) => void` | Border animation toggled; raw-graph consumers store `data.isNodeAnimated` |
|
|
1061
|
-
| `onNodeCollapse` | `(nodeId, collapsed) => void` | Collapse toggle clicked |
|
|
1062
|
-
| `onNodeColorChange` | `(nodeId, colorType, color) => void` | Node color changed via toolbar |
|
|
1063
|
-
| `onNodeBorderColorChange` | `(nodeId, color: string) => void` | Border color picked; raw consumers update `data.viewProps.borderColor` (empty string resets) |
|
|
1064
|
-
| `onNodeBorderStyleChange` | `(nodeId, "solid" \| "dashed") => void` | Border style changed; raw consumers update `data.viewProps.borderStyle` |
|
|
1065
|
-
| `onNodeBorderWidthChange` | `(nodeId, width: number \| undefined) => void` | Border thickness changed; raw consumers update `data.viewProps.borderWidth` (`undefined` resets) |
|
|
1066
|
-
| `onNodeBorderRadiusChange` | `(nodeId, radius: number \| undefined) => void` | Corner radius changed; raw consumers update `data.viewProps.borderRadius` (`undefined` resets) |
|
|
1067
|
-
| `onNodeIconChange` | `(nodeId, iconName) => void` | Node icon changed via toolbar |
|
|
1068
|
-
| `onNodeOutlineChange` | `(nodeId, outline: boolean) => void` | Outline toggled; raw-graph consumers store `data.viewProps.outline` |
|
|
1069
|
-
| `onNodeHoverAction` | `(actionId, nodeId, nodeData) => void` | Hover overlay action clicked |
|
|
1070
|
-
|
|
1071
|
-
### Edge Events
|
|
1072
|
-
|
|
1073
|
-
| Callback | Signature | Description |
|
|
1074
|
-
| ------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
1075
|
-
| `onEdgeCreate` | `(sourceId, targetId, properties?: FlowEdgeProperties) => void` | New edge drawn; optional `sourceProperty` / `targetProperty` identify rows |
|
|
1076
|
-
| `onEdgeSelect` | `(edgeId, edgeData) => void` | Edge clicked/selected |
|
|
1077
|
-
| `onEdgeDeselect` | `() => void` | Edge selection cleared |
|
|
1078
|
-
| `onEdgeRemove` | `(edgeId, edgeData) => void` | Edge removed |
|
|
1079
|
-
| `onEdgeDelete` | `(edgeId, edgeData) => void` | User requested deletion |
|
|
1080
|
-
| `onEdgeColorChange` | `(edgeId, color) => void` | Edge color changed |
|
|
1081
|
-
| `onEdgeLabelChange` | `(edgeId, label) => void` | Edge label changed |
|
|
1082
|
-
| `onEdgeStyleChange` | `(edgeId, "solid" \| "dashed" \| "animated") => void` | Edge style changed |
|
|
1083
|
-
|
|
1084
|
-
### Diagram Events
|
|
1085
|
-
|
|
1086
|
-
| Callback | Signature | Description |
|
|
1087
|
-
| ------------------- | ------------------------------------------------------ | --------------------------------------------------------------------- |
|
|
1088
|
-
| `onViewportChange` | `(viewport) => void` | Pan/zoom changed |
|
|
1089
|
-
| `onDirectionChange` | `(direction) => void` | Direction changed via bottom bar |
|
|
1090
|
-
| `onArrayModeChange` | `(isArrayMode) => void` | Array/set mode toggled |
|
|
1091
|
-
| `onInit` | `(engine: FlowEngine) => void` | Renderer handle initialized; node boxes become available after layout |
|
|
1092
|
-
| `onJsonChange` | `(next: SqueedJson, change: SqueedChangeInfo) => void` | Immutable document update |
|
|
96
|
+
Editing a plain-string node label updates that string in place, preserving its
|
|
97
|
+
JSON address and connections. Object-node labels use `$label`.
|
|
1093
98
|
|
|
1094
99
|
## JSON Conventions
|
|
1095
100
|
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
|
1100
|
-
|
|
|
1101
|
-
| `$
|
|
1102
|
-
| `$
|
|
1103
|
-
| `$
|
|
1104
|
-
| `$
|
|
1105
|
-
| `$
|
|
1106
|
-
| `$
|
|
1107
|
-
| `$
|
|
1108
|
-
| `$
|
|
1109
|
-
| `$
|
|
1110
|
-
| `$
|
|
1111
|
-
| `$collapsed`
|
|
1112
|
-
| `$parent`
|
|
1113
|
-
| `$target`
|
|
1114
|
-
| `$connections`
|
|
1115
|
-
| `$
|
|
1116
|
-
| `$
|
|
1117
|
-
| `$
|
|
1118
|
-
| `$`
|
|
101
|
+
Keys become nodes, nesting becomes hierarchy, and `$`-prefixed keys configure
|
|
102
|
+
rendering:
|
|
103
|
+
|
|
104
|
+
| Key | Description |
|
|
105
|
+
| ----------------- | --------------------------------------------------------------------- |
|
|
106
|
+
| `$label` | Display label |
|
|
107
|
+
| `$content` | Markdown source, editable when `config.editable` is enabled |
|
|
108
|
+
| `$icon` | React Icons name, e.g. `PiGear` |
|
|
109
|
+
| `$bgColor` | Background color (Chakra token, hex, or `transparent`) |
|
|
110
|
+
| `$textColor` | Text color |
|
|
111
|
+
| `$borderColor` | Border color |
|
|
112
|
+
| `$borderStyle` | `"solid"` or `"dashed"` |
|
|
113
|
+
| `$borderWidth` | Border thickness in pixels; `0` hides it |
|
|
114
|
+
| `$borderRadius` | Corner radius; `0` makes square corners |
|
|
115
|
+
| `$outline` | `true` for an unfilled node with a border |
|
|
116
|
+
| `$collapsed` | `true` collapses children |
|
|
117
|
+
| `$parent` | Parent node ID for compound/container nodes |
|
|
118
|
+
| `$target` | Cross-link to a JSON address, e.g. `root.database` |
|
|
119
|
+
| `$connections` | Multiple node/property mappings |
|
|
120
|
+
| `$edgeColor` | Edge color |
|
|
121
|
+
| `$isEdgeDashed` | Dashed edge |
|
|
122
|
+
| `$isEdgeAnimated` | Animated edge |
|
|
123
|
+
| `$` | Array value, e.g. `{ $: ["a", "b"] }` |
|
|
1119
124
|
|
|
1120
125
|
```json
|
|
1121
126
|
{
|
|
1122
127
|
"$label": "Server",
|
|
1123
128
|
"$bgColor": "green.500",
|
|
1124
|
-
"$collapsed": false,
|
|
1125
129
|
"host": "localhost",
|
|
1126
130
|
"port": 3000,
|
|
1127
131
|
"routes": {
|
|
1128
132
|
"$label": "API Routes",
|
|
1129
133
|
"$collapsed": true,
|
|
1130
|
-
"users": "/api/users"
|
|
1131
|
-
"auth": "/api/auth"
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
```
|
|
1135
|
-
|
|
1136
|
-
### Content And Node Animation
|
|
1137
|
-
|
|
1138
|
-
```json
|
|
1139
|
-
{
|
|
1140
|
-
"runbook": {
|
|
1141
|
-
"$label": "Runbook",
|
|
1142
|
-
"$content": "## Recovery\n\n1. Check queue depth\n2. Restart workers",
|
|
1143
|
-
"$isNodeAnimated": true
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
```
|
|
1147
|
-
|
|
1148
|
-
`$content` renders Markdown headings, lists, emphasis, tables, links, and fenced code. Supply Markdown source text, not a filename or URL to load. Raw HTML is disabled and unsafe link schemes are filtered.
|
|
1149
|
-
|
|
1150
|
-
For `$contentFormat: "jsx"`, supply a JSON array of declarative UI components,
|
|
1151
|
-
not executable JSX source:
|
|
1152
|
-
|
|
1153
|
-
```json
|
|
1154
|
-
{
|
|
1155
|
-
"panel": {
|
|
1156
|
-
"$view": "object",
|
|
1157
|
-
"$contentFormat": "jsx",
|
|
1158
|
-
"$content": [{ "type": "text", "text": "Hello" }]
|
|
134
|
+
"users": "/api/users"
|
|
1159
135
|
}
|
|
1160
136
|
}
|
|
1161
137
|
```
|
|
1162
138
|
|
|
1163
|
-
|
|
1164
|
-
`JsxContentRendererProps`: `{ components, colorMode, fillHeight }`. Squeed provides
|
|
1165
|
-
`WorkflowContentRenderer`, which wraps the array in one `render_scene` step for
|
|
1166
|
-
`UnifiedWorkflowRenderer`. The SDK does not import or depend on that renderer.
|
|
1167
|
-
Without a supplied view, it displays an unavailable-renderer message and keeps
|
|
1168
|
-
the content editable. JSON-encoded arrays are also accepted, but JSX source code
|
|
1169
|
-
is no longer compiled or executed. Invalid arrays show a validation error.
|
|
1170
|
-
|
|
1171
|
-
The existing source editor and fullscreen controls are reused. JSX edits are
|
|
1172
|
-
parsed back into arrays, and `onNodeContentChange` receives `NodeContent`
|
|
1173
|
-
(`string | Record<string, unknown>[]`). Markdown stays text, and HTML keeps its
|
|
1174
|
-
sanitized iframe preview. Host renderers are responsible for their components'
|
|
1175
|
-
behavior and external actions; the SDK's HTML iframe sandbox does not apply to
|
|
1176
|
-
a host-supplied JSX-content view.
|
|
1177
|
-
|
|
1178
|
-
Document playback reveals completed entries of JSX `$content` arrays as chunks
|
|
1179
|
-
arrive, while unfinished entries remain hidden. Squeed's workflow channel also
|
|
1180
|
-
previews repaired streamed documents containing component arrays. Previews do
|
|
1181
|
-
not edit saved data: completion strictly parses the final JSON before committing,
|
|
1182
|
-
and failure or disconnect restores the saved document. The renderer stays in
|
|
1183
|
-
the host; this does not enable executable JSX or create a per-chunk MCP command.
|
|
1184
|
-
|
|
1185
|
-
With `config.editable: true`, click the content body to edit the original Markdown source. In Collision mode, including filled and embedded Grids, hold Shift when clicking; ordinary clicks retain their selection behavior. Shift is only required to enter the editor. Enter inserts a new line; Ctrl/Cmd+Enter or clicking away saves, and Escape cancels. Read-only mode still prevents editing. Internal JSON refreshes preserve focused editors and unsaved drafts; initial loading and explicit host loading still block interaction. Source whitespace is preserved. The node grows vertically as text is added; label editors grow horizontally within their width limit. Both keep their starting size as a minimum and omit input focus outlines. Clearing the body keeps an empty, editable content view; use `setNodeProp(json, address, "$content", undefined)` to remove the content property. Content nodes use the same minimum width as their object-property rows, and the right-aligned table/article button switches views without changing the document.
|
|
1186
|
-
|
|
1187
|
-
With one node selected, Enter activates its own visible dot or collapse control.
|
|
1188
|
-
Further presses follow that control's existing open/back sequence. Text inputs,
|
|
1189
|
-
focused controls, dialogs, modifier shortcuts and read-only mode keep their
|
|
1190
|
-
existing behavior; holding Enter does not repeatedly toggle the view.
|
|
1191
|
-
|
|
1192
|
-
An expanded Text node exposes the existing **Show icon** dot on hover or selection;
|
|
1193
|
-
**Show text** restores the Text view without rewriting source metadata. Double-click
|
|
1194
|
-
an editable Text node without an explicit form to open the existing form popup with
|
|
1195
|
-
only the Content text editor. It edits the label, not `$content`, and provides no
|
|
1196
|
-
property fields or format selector. Enter inserts a newline, Ctrl/Cmd+Enter or blur
|
|
1197
|
-
saves, and Escape cancels. Explicit forms and read-only permissions remain in force.
|
|
1198
|
-
In a host's Fill-specific body (`fillBody`), Markdown/plain text also supports
|
|
1199
|
-
direct click and focused Enter editing; other Collision views still require Shift.
|
|
139
|
+
## Core Props
|
|
1200
140
|
|
|
1201
|
-
|
|
141
|
+
| Prop | Type | Description |
|
|
142
|
+
| --------------- | ---------------------- | ------------------------------------------------- |
|
|
143
|
+
| `json` | `SqueedJson` | Parsed JSON document; takes precedence over nodes |
|
|
144
|
+
| `nodes`/`edges` | `FlowDiagramNode[]` / `FlowDiagramEdge[]` | Pre-computed graph |
|
|
145
|
+
| `title` | `string` | Root node title (default `"untitled"`) |
|
|
146
|
+
| `config` | `FlowDiagramConfig` | Layout, theme, interaction, and rendering options |
|
|
147
|
+
| `callbacks` | `FlowDiagramCallbacks` | Edit, selection, viewport, and lifecycle events |
|
|
148
|
+
| `showBottomBar` | `boolean` | Show the direction/mode bar (default `true`) |
|
|
149
|
+
| `className` | `string` | CSS class name |
|
|
150
|
+
| `style` | `CSSProperties` | Inline styles |
|
|
1202
151
|
|
|
1203
|
-
|
|
1204
|
-
the right of its bottom-toolbar icon:
|
|
1205
|
-
|
|
1206
|
-
- Nodes: **Trace** (the existing travelling stroke) or **Pulse** (the full border fades in and out).
|
|
1207
|
-
- Edges: **Dash** (the existing moving dashes) or **Trace** (a travelling highlight along the routed edge).
|
|
1208
|
-
|
|
1209
|
-
Stopping animation hides the selector but retains the chosen variant. Node
|
|
1210
|
-
Trace and edge Dash remain the defaults. Both respect reduced-motion preferences.
|
|
1211
|
-
|
|
1212
|
-
Node JSON stores `$nodeAnimationVariant: "traveling" | "pulse"` independently
|
|
1213
|
-
of `$isNodeAnimated`. Hierarchy edges use `$edgeAnimationVariant`, target
|
|
1214
|
-
links use `$targetAnimationVariant`, and `$connections` entries use
|
|
1215
|
-
`animationVariant: "dashed" | "traveling"` independently of `style`.
|
|
1216
|
-
Raw graphs use `data.nodeAnimationVariant` and `data.edgeAnimationVariant`.
|
|
1217
|
-
Handle `onNodeAnimationVariantChange(nodeId, variant)` and
|
|
1218
|
-
`onEdgeAnimationVariantChange(edgeId, variant)` for controlled raw-graph edits;
|
|
1219
|
-
JSON mode persists them through `onJsonChange`.
|
|
1220
|
-
|
|
1221
|
-
In JSON mode content and animation edits emit `onJsonChange` with types `"nodeContent"` and `"nodeAnimation"`. In raw `nodes`/`edges` mode, handle the callbacks listed above and return updated nodes. Existing edges, colors, outlines, and mappings are unchanged.
|
|
1222
|
-
|
|
1223
|
-
### Transparent Colors And Outlines
|
|
1224
|
-
|
|
1225
|
-
Every built-in color palette includes a checkerboard `transparent` swatch, including custom palettes. This is distinct from reset, which removes the override. Node fill, text/icon, border, edge, container, and canvas colors accept `"transparent"`. Transparent fills keep default text readable in light and dark modes; explicit transparent text also hides its icon.
|
|
1226
|
-
|
|
1227
|
-
The outline toggle applies to one or multiple selected nodes. It clears all node fills (including object headers/rows) without overwriting stored colors. Text, array, object, and compound nodes support it. Selection highlighting remains visible; an explicit transparent border is still respected.
|
|
1228
|
-
|
|
1229
|
-
The separate **Edit node border** toggle is a toolbar-only mode: it does not remove the fill or change `$outline`. It reuses the node-color swatches for border color, hides only the text-color controls, and reveals a dashed toggle and thickness input. Switching it off restores background/text-color editing. Color, style, and thickness persist independently; explicit border colors remain visible during selection and hover.
|
|
1230
|
-
|
|
1231
|
-
Border colors emit `nodeColor` changes, while style and thickness emit `nodeStyle` with `$borderStyle` / `$borderWidth`. Raw consumers handle the border callbacks above. Thickness accepts nonnegative numbers; clearing the input resets it, and zero hides the border and its animation. `selectionToolbar.hide: ["color"]` hides the shared palette and border mode; `"borderColor"` hides the mode toggle, and `"style"` hides dashed/thickness controls. Hiding `"outline"` affects only the separate fill-removing toggle.
|
|
1232
|
-
|
|
1233
|
-
```tsx
|
|
1234
|
-
setDoc((doc) => setNodeProp(doc, "root.service", "$outline", true));
|
|
1235
|
-
setDoc((doc) => setNodeProp(doc, "root.service", "$bgColor", "transparent"));
|
|
1236
|
-
```
|
|
1237
|
-
|
|
1238
|
-
For raw nodes use `data.viewProps.outline` and handle `onNodeOutlineChange(nodeId, outline)`; in JSON mode the SDK emits `onJsonChange` with `type: "nodeOutline"`. Container defaults can use `config.parentNodeStyle.outline`, with per-node values taking precedence. `selectionToolbar.hide: ["outline"]` hides the toggle. `readOnly` disables edits.
|
|
1239
|
-
|
|
1240
|
-
### Property Connections
|
|
1241
|
-
|
|
1242
|
-
Store mappings on the source node. Property references are exact row keys, while `target` is the destination node's JSON address:
|
|
1243
|
-
|
|
1244
|
-
```json
|
|
1245
|
-
{
|
|
1246
|
-
"backend": {
|
|
1247
|
-
"runtime": "Node",
|
|
1248
|
-
"api": "REST",
|
|
1249
|
-
"$connections": [
|
|
1250
|
-
{
|
|
1251
|
-
"sourceProperty": "api",
|
|
1252
|
-
"target": "root.handlers",
|
|
1253
|
-
"targetProperty": "http"
|
|
1254
|
-
},
|
|
1255
|
-
{
|
|
1256
|
-
"sourceProperty": "runtime",
|
|
1257
|
-
"target": "root.handlers",
|
|
1258
|
-
"targetProperty": "ws"
|
|
1259
|
-
}
|
|
1260
|
-
]
|
|
1261
|
-
},
|
|
1262
|
-
"handlers": { "http": "express", "ws": "socket.io" }
|
|
1263
|
-
}
|
|
1264
|
-
```
|
|
152
|
+
## Common Configuration
|
|
1265
153
|
|
|
1266
154
|
```tsx
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
155
|
+
config={{
|
|
156
|
+
direction: "LR", // "LR" | "RL" | "TB" | "BT" | "C"
|
|
157
|
+
nodeAlignment: "center", // "leading" | "center" | "trailing"
|
|
158
|
+
edgeMode: "nodes", // "nodes" | "properties" | "workflow"
|
|
159
|
+
themeColor: "blue.500",
|
|
160
|
+
colorMode: "light", // "light" | "dark"
|
|
161
|
+
backgroundPattern: "dot", // "dot" | "grid" | "steel" | "none"
|
|
162
|
+
editable: true,
|
|
163
|
+
readOnly: false,
|
|
164
|
+
minZoom: 0.01,
|
|
165
|
+
maxZoom: 1.5,
|
|
166
|
+
initialViewport: { pan: { x: 0, y: 0 }, zoom: 1 },
|
|
167
|
+
}}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Use `$collapsed: true` to collapse a JSON branch and `false` to keep its
|
|
171
|
+
expansion control. `readOnly` disables graph gestures and edits while leaving
|
|
172
|
+
toolbar navigation available.
|
|
1285
173
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
```ts
|
|
1289
|
-
interface Graph {
|
|
1290
|
-
alpha: { output: string; optional?: number };
|
|
1291
|
-
beta: { input: string; count: number };
|
|
1292
|
-
}
|
|
1293
|
-
```
|
|
1294
|
-
|
|
1295
|
-
Equivalent JSON Schema:
|
|
1296
|
-
|
|
1297
|
-
```json
|
|
1298
|
-
{
|
|
1299
|
-
"type": "object",
|
|
1300
|
-
"properties": {
|
|
1301
|
-
"alpha": {
|
|
1302
|
-
"type": "object",
|
|
1303
|
-
"properties": {
|
|
1304
|
-
"output": { "type": "string" },
|
|
1305
|
-
"optional": { "type": "number" }
|
|
1306
|
-
},
|
|
1307
|
-
"required": ["output"]
|
|
1308
|
-
},
|
|
1309
|
-
"beta": {
|
|
1310
|
-
"type": "object",
|
|
1311
|
-
"properties": {
|
|
1312
|
-
"input": { "type": "string" },
|
|
1313
|
-
"count": { "type": "number" }
|
|
1314
|
-
},
|
|
1315
|
-
"required": ["input", "count"]
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
```
|
|
1320
|
-
|
|
1321
|
-
Supported types are string, number, boolean, null, primitive literals/unions, arrays, and nested structural objects. JSON additionally supports integer and nonrecursive local `$ref`. Properties are optional unless included in JSON Schema `required`; optional sources cannot supply required targets. Extra object fields are allowed. This is a bounded structural compatibility checker, not the complete TypeScript type system or a full JSON Schema validator. Unsupported constraints (including closed objects), recursion, inheritance, generics, imports and executable code are rejected. Files are limited to 256 KB and expansion to 512 type nodes. TypeScript is parsed, never executed; its runtime dependency loads lazily on `.ts` uploads. Vite hosts may pre-optimize `typescript` to avoid a development-only reload on its first use.
|
|
1322
|
-
|
|
1323
|
-
For host-owned state, supply `config.edgeMode` and `config.workflowContract`, and apply `callbacks.onEdgeModeChange(mode)` and `callbacks.onWorkflowContractChange(contract)` to that state. Omit these config fields for local state. An explicitly present `workflowContract: undefined` clears a controlled contract; a failed upload retains the previous one. Read-only mode disables mode changes and uploads. Exported `parseJsonContract(source, name)`, async `parseTypeScriptContract(source, name)`, `readWorkflowContract(file)`, and `connectionIssue(contract, edgeData)` let workflow hosts reuse the same check outside the UI. `connectionIssue` returns a reason or `undefined`; it does not block workflow execution itself.
|
|
1324
|
-
|
|
1325
|
-
Drag an output port to an input port or destination row to append a mapping. Property drags into empty space cancel. Existing node-level drawing still writes `$target`. The edge toolbar edits/deletes only the selected mapping. In document mode, store the full `onJsonChange` document; in raw `nodes`/`edges` mode, store the optional third `onEdgeCreate` argument in the edge's `data`.
|
|
1326
|
-
|
|
1327
|
-
Each entry accepts `target`, optional `sourceProperty`/`targetProperty`, `id`, `label`, `color` (Chakra token or hex), and `style: "solid" | "dashed" | "animated"`. Drag-created mappings receive IDs and duplicate endpoint mappings are not appended. Supply explicit unique IDs when declaring otherwise identical mappings that need distinct identities.
|
|
1328
|
-
|
|
1329
|
-
Missing or unrendered rows fall back to the corresponding node endpoint. Missing/collapsed nodes hide their edges without deleting the saved mappings. Custom views can expose rows with `data-flow-property={key}`; their positions are measured automatically. `readOnly` and `edgeHandles: false` disable port dragging.
|
|
1330
|
-
|
|
1331
|
-
Draw mode starts off by default, including when `edgeHandles: true`. Enable it with the toolbar, or explicitly control it with `config.isEdgeHandlesEnabled`. Hover handles remain available for individual connections when Draw mode is off.
|
|
1332
|
-
|
|
1333
|
-
Mappings are metadata. The SDK does not execute workflows or transfer data.
|
|
174
|
+
## Callbacks
|
|
1334
175
|
|
|
1335
|
-
|
|
176
|
+
| Callback | Fires when |
|
|
177
|
+
| ------------------- | ------------------------------------------- |
|
|
178
|
+
| `onJsonChange` | Any toolbar or inline edit changes the JSON |
|
|
179
|
+
| `onNodeSelect` | A node is clicked or selected |
|
|
180
|
+
| `onEdgeSelect` | An edge is selected |
|
|
181
|
+
| `onViewportChange` | Pan or zoom changes |
|
|
182
|
+
| `onDirectionChange` | Layout direction changes |
|
|
183
|
+
| `onThemeColorChange`| The graph accent color changes |
|
|
184
|
+
| `onNodeCollapse` | A branch is collapsed or expanded |
|
|
185
|
+
| `onNodeLabelChange` | A label is edited inline |
|
|
186
|
+
| `onEdgeCreate` | An edge is drawn between nodes |
|
|
187
|
+
| `onInit` | The engine is ready (`zoom`, `pan`, `fit`) |
|
|
188
|
+
| `onLayoutComplete` | Layout and measurement settle |
|
|
189
|
+
|
|
190
|
+
## Utilities
|
|
1336
191
|
|
|
1337
192
|
```tsx
|
|
1338
193
|
import { compileSqueed, setNodeProp, applyCollapsed } from "@squeed/flow-sdk";
|
|
@@ -1342,138 +197,28 @@ const { nodes, edges } = compileSqueed(next, {
|
|
|
1342
197
|
title: "Services",
|
|
1343
198
|
isCenter: false,
|
|
1344
199
|
});
|
|
1345
|
-
const visible = applyCollapsed(
|
|
200
|
+
const visible = applyCollapsed(nodes, edges);
|
|
1346
201
|
```
|
|
1347
202
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
| Helper | Result |
|
|
1353
|
-
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
1354
|
-
| `getNode(json, address)` | Value at an address, or `undefined` |
|
|
1355
|
-
| `updateNode(json, address, updater)` | New document with the updater's replacement at that address |
|
|
1356
|
-
| `setNodeProp(json, address, key, value)` | New document with a `$` rendering property; null/undefined resets it, as does empty string except for `$content` |
|
|
1357
|
-
| `setCollapsed(json, address, collapsed)` | New document; preserves an explicit `false` |
|
|
1358
|
-
| `addChild(json, parentAddress, child, key?)` | `{ json, address }`; appends to plain or `$`-wrapped arrays, otherwise uses a key |
|
|
1359
|
-
| `removeNode(json, address)` | New document without that node; root and absent paths are left unchanged |
|
|
1360
|
-
| `addTargetEdge(json, sourceAddress, targetAddress, label?)` | New document; replaces the source's single `$target` |
|
|
1361
|
-
| `addConnection(json, sourceAddress, connection)` | New document; appends a mapping unless its endpoints already exist |
|
|
1362
|
-
| `setEdgeProp(json, edgeRef, key, value)` / `setEdgeStyle(json, edgeRef, style)` | New document updating only the edge's JSON owner |
|
|
1363
|
-
| `removeEdge(json, edgeRef)` | `{ json, removed }`; independently removes cross-links or property mappings |
|
|
1364
|
-
|
|
1365
|
-
Addresses use dot-separated paths such as `root.backend.runtime` or `root.tags.1`; `$` array wrappers are traversed automatically. Keys containing literal dots are not escaped by this address format. Array deletion shifts subsequent indices; these addresses are not permanent IDs across structural edits.
|
|
1366
|
-
|
|
1367
|
-
Helpers reuse untouched branches and do not fire callbacks themselves. The `updateNode` updater must return a replacement without mutating its argument. It can add a leaf under an existing parent but does not create missing ancestor chains. Pass the returned document back through `json` to refresh the diagram.
|
|
1368
|
-
|
|
1369
|
-
## Custom Overlays
|
|
1370
|
-
|
|
1371
|
-
### Node Hover Overlay
|
|
1372
|
-
|
|
1373
|
-
Reuse `config.nodeOverlayActions` for standard hover buttons. An action's optional
|
|
1374
|
-
`nodeTypes` array limits it to matching node types (for example, `["grid"]`).
|
|
1375
|
-
Omitting `nodeTypes` preserves the existing all-node behavior; actions continue
|
|
1376
|
-
to dispatch through `callbacks.onNodeHoverAction`.
|
|
1377
|
-
|
|
1378
|
-
```tsx
|
|
1379
|
-
import { HStack, IconButton } from "@chakra-ui/react";
|
|
1380
|
-
import { PiPencilSimple, PiTrash } from "react-icons/pi";
|
|
1381
|
-
|
|
1382
|
-
<FlowDiagram
|
|
1383
|
-
json={data}
|
|
1384
|
-
config={{
|
|
1385
|
-
renderNodeOverlay: ({ nodeId, nodeData, isRoot }) => (
|
|
1386
|
-
<HStack bg="gray.800" px={2} py={1} borderRadius={8}>
|
|
1387
|
-
<IconButton
|
|
1388
|
-
aria-label="Edit node"
|
|
1389
|
-
size="xs"
|
|
1390
|
-
onClick={() => edit(nodeId)}
|
|
1391
|
-
>
|
|
1392
|
-
<PiPencilSimple />
|
|
1393
|
-
</IconButton>
|
|
1394
|
-
{!isRoot && (
|
|
1395
|
-
<IconButton
|
|
1396
|
-
aria-label="Delete node"
|
|
1397
|
-
size="xs"
|
|
1398
|
-
onClick={() => remove(nodeId)}
|
|
1399
|
-
>
|
|
1400
|
-
<PiTrash />
|
|
1401
|
-
</IconButton>
|
|
1402
|
-
)}
|
|
1403
|
-
</HStack>
|
|
1404
|
-
),
|
|
1405
|
-
}}
|
|
1406
|
-
/>;
|
|
1407
|
-
```
|
|
1408
|
-
|
|
1409
|
-
### Selection Toolbar
|
|
1410
|
-
|
|
1411
|
-
```tsx
|
|
1412
|
-
import { HStack, IconButton, Text } from "@chakra-ui/react";
|
|
1413
|
-
import { PiX } from "react-icons/pi";
|
|
1414
|
-
|
|
1415
|
-
<FlowDiagram
|
|
1416
|
-
json={data}
|
|
1417
|
-
config={{
|
|
1418
|
-
renderSelectedNodeToolbar: ({ selectedNodeIds, onDeselect }) => (
|
|
1419
|
-
<HStack bg="gray.800" px={3} py={2} borderRadius={8}>
|
|
1420
|
-
<Text fontSize="xs">{selectedNodeIds.length} selected</Text>
|
|
1421
|
-
<IconButton aria-label="Clear selection" size="xs" onClick={onDeselect}>
|
|
1422
|
-
<PiX />
|
|
1423
|
-
</IconButton>
|
|
1424
|
-
</HStack>
|
|
1425
|
-
),
|
|
1426
|
-
}}
|
|
1427
|
-
/>;
|
|
1428
|
-
```
|
|
203
|
+
Address-based helpers include `getNode`, `updateNode`, `setCollapsed`,
|
|
204
|
+
`addChild`, `removeNode`, `addTargetEdge`, `addConnection`, `setEdgeProp`, and
|
|
205
|
+
`removeEdge`. They return new documents and do not fire callbacks. Addresses use
|
|
206
|
+
dot-separated paths such as `root.backend.runtime`.
|
|
1429
207
|
|
|
1430
208
|
## Keyboard Shortcuts
|
|
1431
209
|
|
|
1432
|
-
| Key | Action
|
|
1433
|
-
| ---------------------- |
|
|
1434
|
-
| `Z` | Toggle zoom mode
|
|
1435
|
-
| `M` | Toggle multi-select mode
|
|
1436
|
-
| `D` | Toggle drag/pan mode
|
|
1437
|
-
| Arrow keys | Select
|
|
1438
|
-
| `Delete` / `Backspace` | Delete selected non-root nodes
|
|
1439
|
-
| `Escape` | Cancel
|
|
1440
|
-
|
|
1441
|
-
The canvas supports pointer panning, wheel zoom, and two-finger pinch zoom. Interactive inputs inside nodes retain their own keyboard behavior.
|
|
1442
|
-
|
|
1443
|
-
Click empty canvas or an ordinary node surface to give the diagram keyboard
|
|
1444
|
-
focus. Unmodified arrows select the nearest rendered node in the requested direction, starting from the selected
|
|
1445
|
-
node or the viewport center when nothing is selected. Hidden nodes and nodes
|
|
1446
|
-
inside another canvas are excluded. Panning is immediate and preserves zoom.
|
|
1447
|
-
No candidate leaves selection and viewport unchanged. Forms, open menus,
|
|
1448
|
-
multi-selection, read-only mode, and disabled keyboard shortcuts retain their
|
|
1449
|
-
existing keyboard behavior. Selection callbacks receive
|
|
1450
|
-
`keyboardNavigation: true` in `NodeSelectionModifiers`; hosts should not apply
|
|
1451
|
-
their mouse-click fit/zoom behavior for that event.
|
|
1452
|
-
|
|
1453
|
-
Escape on a selected canvas node reuses the background-click action, including
|
|
1454
|
-
preview retraction and the host's viewport restoration. Editors, dialogs, menus,
|
|
1455
|
-
fullscreen, and active gestures retain priority. If preview opening focuses its
|
|
1456
|
-
label editor, press Escape once to cancel editing and again to close the preview.
|
|
1457
|
-
|
|
1458
|
-
## Theme Utilities
|
|
1459
|
-
|
|
1460
|
-
```tsx
|
|
1461
|
-
import {
|
|
1462
|
-
useCustomColors,
|
|
1463
|
-
getChakraColorHex,
|
|
1464
|
-
getColorVariant,
|
|
1465
|
-
} from "@squeed/flow-sdk";
|
|
1466
|
-
|
|
1467
|
-
const { background, colorText, border } = useCustomColors();
|
|
1468
|
-
const hex = getChakraColorHex("blue.500"); // → "#3182ce"
|
|
1469
|
-
```
|
|
210
|
+
| Key | Action |
|
|
211
|
+
| ---------------------- | ----------------------------------------- |
|
|
212
|
+
| `Z` | Toggle scroll-to-zoom mode |
|
|
213
|
+
| `M` | Toggle multi-select mode |
|
|
214
|
+
| `D` | Toggle drag/pan mode |
|
|
215
|
+
| Arrow keys | Select the nearest node in that direction |
|
|
216
|
+
| `Delete` / `Backspace` | Delete selected non-root nodes |
|
|
217
|
+
| `Escape` | Cancel the active editor or gesture |
|
|
1470
218
|
|
|
1471
|
-
|
|
219
|
+
Disable these with `config.disableKeyboardShortcuts`.
|
|
1472
220
|
|
|
1473
|
-
|
|
1474
|
-
for local setup and pull-request guidance, and
|
|
1475
|
-
[SECURITY.md](https://github.com/sciphergfx/squeed-flow-sdk/blob/main/SECURITY.md)
|
|
1476
|
-
for private vulnerability reporting.
|
|
221
|
+
## Development
|
|
1477
222
|
|
|
1478
223
|
```bash
|
|
1479
224
|
npm ci
|
|
@@ -1482,8 +227,10 @@ npm run check:release
|
|
|
1482
227
|
npm pack --dry-run
|
|
1483
228
|
```
|
|
1484
229
|
|
|
1485
|
-
|
|
230
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, tests, and pull-request
|
|
231
|
+
guidance. For vulnerabilities, follow [SECURITY.md](SECURITY.md) instead of
|
|
232
|
+
opening a public issue.
|
|
1486
233
|
|
|
1487
|
-
|
|
234
|
+
## License
|
|
1488
235
|
|
|
1489
|
-
|
|
236
|
+
[MIT](LICENSE).
|