@statelyai/flow 0.1.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/esm/index.d.ts +1294 -544
- package/dist/esm/index.js +2528 -321
- package/package.json +17 -15
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ The canonical data model is `VisualGraph` from `@statelyai/graph`. Flow extends
|
|
|
63
63
|
- **`FlowNode`** — `VisualNode` + `{ dx, dy, style, ports, hidden, selectable, draggable, connectable, deletable, resizable }` for drag offsets, style overrides, and per-entity behavior
|
|
64
64
|
- **`FlowEdge`** — `VisualEdge` + `{ label, sourcePort, targetPort, kind, style, labelAnchor }` for edge labels, port binding, and edge styling
|
|
65
65
|
- **`FlowGraph`** — `VisualGraph` with `FlowNode[]` and `FlowEdge[]`
|
|
66
|
+
- **`FlowAddressable`** — descriptor for a node, edge, port, or block resolved by id
|
|
66
67
|
|
|
67
68
|
Positions use a two-layer system: `x/y` from layout, `dx/dy` from user drag. Visual position = `(x + dx, y + dy)`.
|
|
68
69
|
|
|
@@ -203,8 +204,7 @@ const graph = {
|
|
|
203
204
|
|---|---|---|
|
|
204
205
|
| `requestLayout` | `{ algorithm? }` | Request auto-layout (blocked during drag) |
|
|
205
206
|
| `applyLayoutResult` | `{ positions: Map<id, {x,y}>, edgeLabelPositions? }` | Apply layout positions, reset dx/dy |
|
|
206
|
-
| `
|
|
207
|
-
| `reportPortMeasurements` | `{ measurements: Array<{nodeId, portName, x, y, width, height}> }` | Renderer reports port positions |
|
|
207
|
+
| `updateMeasurements` | `{ measurements: Array<{ id, rect: Rect }> }` | Renderer reports measured world-space rects |
|
|
208
208
|
| `bakeLabelPositions` | `{ positions: Map<edgeId, Point> }` | Bake computed label positions into edge data |
|
|
209
209
|
|
|
210
210
|
### Configuration
|
|
@@ -212,11 +212,12 @@ const graph = {
|
|
|
212
212
|
| Event | Payload | Description |
|
|
213
213
|
|---|---|---|
|
|
214
214
|
| `setCanvasState` | `{ state: CanvasState }` | Set interaction mode |
|
|
215
|
-
| `
|
|
215
|
+
| `setMode` | `{ mode: string }` | Set active profile mode |
|
|
216
216
|
| `setDragThreshold` | `{ dragThreshold }` | Set pixel threshold before drag starts |
|
|
217
217
|
| `setAutoPanOptions` | `{ autoPanOnDrag?, autoPanThreshold?, autoPanSpeed? }` | Configure auto-pan behavior |
|
|
218
218
|
| `setSnapToGrid` | `{ enabled, grid? }` | Enable/disable grid snapping |
|
|
219
219
|
| `setSnapLines` | `{ enabled, threshold?, spacing? }` | Enable/disable Figma-style alignment guides |
|
|
220
|
+
| `setColorMode` | `{ colorMode: FlowColorMode }` | Set the preferred UI color mode (`'light'` \| `'dark'` \| `'system'`) |
|
|
220
221
|
|
|
221
222
|
### Navigation
|
|
222
223
|
|
|
@@ -224,6 +225,20 @@ const graph = {
|
|
|
224
225
|
|---|---|---|
|
|
225
226
|
| `updateParentNodeId` | `{ parentNodeId }` | Drill into/out of nested node |
|
|
226
227
|
|
|
228
|
+
### Emitted events
|
|
229
|
+
|
|
230
|
+
Subscribe with `flow.on(type, listener)` or `store.on(type, listener)`.
|
|
231
|
+
|
|
232
|
+
| Event | Payload | Description |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| `graphChanged` | `{ graph, event }` | Graph changed after a mutation |
|
|
235
|
+
| `viewportChanged` | `{ viewport, event }` | Viewport changed |
|
|
236
|
+
| `selectionChanged` | `{ selection, event }` | Selection changed |
|
|
237
|
+
| `entitiesDeleted` | `{ ids, event }` | Entities were deleted |
|
|
238
|
+
| `connectionEnded` | `ConnectionEndedEvent` | Connection gesture ended |
|
|
239
|
+
| `layoutRequested` | `LayoutRequestedEvent` | Layout was requested |
|
|
240
|
+
| `error` | `{ error, event? }` | Flow error emitted |
|
|
241
|
+
|
|
227
242
|
## Undo / redo
|
|
228
243
|
|
|
229
244
|
<!-- undo/redo config from src/store/index.ts UNDOABLE_EVENT_TYPES -->
|
|
@@ -403,6 +418,8 @@ const store = createFlowStore(graph, {
|
|
|
403
418
|
connectOnClick: false,
|
|
404
419
|
selectionMode: 'partial', // 'partial' | 'full'
|
|
405
420
|
historyLimit: 100,
|
|
421
|
+
mode: 'interactive',
|
|
422
|
+
profile: defaultFlowProfile,
|
|
406
423
|
beforeDelete: ({ graph, reason, nodes, edges }) => { /* return false to cancel */ },
|
|
407
424
|
onDeleteNodes: 'cascade', // 'cascade' | 'retarget' | custom function
|
|
408
425
|
});
|