Flow

Un lienzo de nodos para diagramas y flujos: nodos arrastrables, conexiones curvas con etiquetas, puntos de conexión, desplazamiento y zoom, controles y un minimapa.

Disponible en
  • Angular: disponible
  • Vue: disponible
  • React: disponible
  • React Native: aún no disponible

Uso

Order placedWebhook
In stock?
Ship orderCreate label
Notify buyerBack-order email
NoteOrders over €500 skip the stock check.
Tab moves between nodes. Arrow keys move the focused node, C starts a connection from it and Enter on another node finishes it, Delete removes the selection, plus and minus zoom.

Drag nodes and the canvas, drag from a dot to connect, Ctrl / ⌘ + scroll to zoom. Selected: none

Importación

ts
import {
  SoneFlowComponent,
  SoneFlowControlsComponent,
  SoneFlowMinimapComponent,
  SoneFlowNodeTemplateDirective,
  SoneFlowPanelDirective,
} from "@surface-one/angular/flow";

Referencia de la API

SoneFlowComponentComponente

A node canvas for diagrams and workflows. Nodes sit at `x`/`y` in canvas units, edges join their ports with a bezier, step or straight path; the canvas pans (drag the background, or scroll with `panOnScroll`), zooms (Ctrl / ⌘ + wheel, a pinch, the controls) and fits its content. `nodes`, `edges`, `viewport` and the selection are two-way: dragging a node, drawing a connection or deleting writes them back. Children: `<sone-flow-controls>`, `<sone-flow-minimap>`, `[soneFlowPanel]` overlays and a `<sone-dock>` sit on top of the canvas.

Selector
sone-flow
Inputs
NombreTipo Predeterminado
nodesbidireccionalreadonly SoneFlowNode[][]
edgesbidireccionalreadonly SoneFlowEdge[][]
viewportbidireccionalSoneFlowViewport{ x: 0, y: 0, zoom: 1 }
selectedNodesbidireccionalreadonly string[][]
selectedEdgesbidireccionalreadonly string[][]
interactivebidireccional

`false` locks the canvas: no dragging, connecting or deleting (panning and zooming stay).

booleantrue
directionSoneFlowDirection"horizontal"
edgeType

The path of edges that set no `type`.

SoneFlowEdgeType"bezier"
backgroundSoneFlowBackground"dots"
gridSizenumber20
snapToGrid

Snap dragged nodes to the grid.

booleanfalse
tool

Dragging the background pans in both tools; `pan` also stops nodes from moving.

SoneFlowTool"select"
minZoom—SONE_FLOW_MIN_ZOOM
maxZoom—SONE_FLOW_MAX_ZOOM
fitView

Fit the nodes into view once they are first measured.

booleantrue
panOnScroll

A plain wheel pans the canvas (otherwise it scrolls the page; Ctrl / ⌘ + wheel always zooms).

booleanfalse
connectablebooleantrue
deletablebooleantrue
autoConnect

Add the edge on `(connect)` (`false`: only emit it, the owner adds it).

booleantrue
isValidConnection((c: SoneFlowConnection) => boolean) | nullnull
ariaLabel

The canvas's accessible name (default "Flow diagram").

string | nullnull
labelsPartial<SoneFlowLabels>{}
Outputs
NombreTipo
connectSoneFlowConnection
nodeClickSoneFlowNode
nodeDoubleClickSoneFlowNode
nodeDragEndSoneFlowNode
edgeClickSoneFlowEdge
canvasClick

A click on the empty canvas, at that point in canvas units.

SoneFlowPoint
nodesDeletereadonly SoneFlowNode[]
edgesDeletereadonly SoneFlowEdge[]

SoneFlowControlsComponentComponente

Zoom in, zoom out, fit view, the zoom level (a reset to 100%) and a lock toggle for the `<sone-flow>` it sits in.

Selector
sone-flow-controls
Inputs
NombreTipo Predeterminado
positionSoneFlowPanelPosition"bottom-left"
orientation"horizontal" | "vertical""vertical"
showZoom

Show the zoom level as a button that resets it to 100%.

booleanfalse
showLockbooleantrue
labelsPartial<SoneFlowControlsLabels>{}

SoneFlowMinimapComponentComponente

A small overview of the whole `<sone-flow>`: every node as a block and the visible area as a frame. Click or drag in it to move the view there. A pointer shortcut — the keyboard has the controls and Tab between nodes — so it is hidden from assistive technology.

Selector
sone-flow-minimap
Inputs
NombreTipo Predeterminado
positionSoneFlowPanelPosition"bottom-right"
widthnumber200
heightnumber136

SoneFlowNodeTemplateDirectiveDirectiva

`<ng-template soneFlowNode let-node let-selected="selected">` draws the body of every node instead of the default icon, label and description. The canvas keeps the box, the selection, the dragging and the connection handles. Controls inside the template (buttons, inputs) work as usual and never start a drag.

Selector
ng-template[soneFlowNode]

SoneFlowPanelDirectiveDirectiva

Pins projected content (a legend, a run button) to a corner or edge of the canvas.

Selector
[soneFlowPanel]
Inputs
NombreTipo Predeterminado
soneFlowPanelSoneFlowPanelPosition"top-left"