Flow
図やワークフローのためのノードキャンバス。ドラッグできるノード、ラベル付きの曲線エッジ、接続ハンドル、パンとズーム、コントロール、ミニマップ。
Angular: 対応 Vue: 対応 React: 対応 React Native: 未対応
使い方
Drag nodes and the canvas, drag from a dot to connect, Ctrl / ⌘ + scroll to zoom. Selected: none
<div class="demo-stack" style="width: 100%">
<sone-segmented size="sm" ariaLabel="Edge style" [options]="types" [(value)]="edgeType" />
<sone-flow
style="--sone-flow-h: 26rem; width: 100%"
ariaLabel="Order fulfilment"
[edgeType]="$any(edgeType())"
[(nodes)]="nodes"
[(edges)]="edges"
[(selectedNodes)]="selected"
>
<sone-flow-controls showZoom />
<sone-flow-minimap />
</sone-flow>
<p class="text-hint">
Drag nodes and the canvas, drag from a dot to connect, Ctrl / ⌘ + scroll to zoom.
Selected: {{ selected().join(', ') || 'none' }}
</p>
</div>インポート
import {
SoneFlowComponent,
SoneFlowControlsComponent,
SoneFlowMinimapComponent,
SoneFlowNodeTemplateDirective,
SoneFlowPanelDirective,
} from "@surface-one/angular/flow";API リファレンス
SoneFlowComponentコンポーネント
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.
| 名前 | 型 | デフォルト |
|---|---|---|
nodes双方向 | readonly SoneFlowNode[] | [] |
edges双方向 | readonly SoneFlowEdge[] | [] |
viewport双方向 | SoneFlowViewport | { x: 0, y: 0, zoom: 1 } |
selectedNodes双方向 | readonly string[] | [] |
selectedEdges双方向 | readonly string[] | [] |
interactive双方向`false` locks the canvas: no dragging, connecting or deleting (panning and zooming stay). | boolean | true |
direction | SoneFlowDirection | "horizontal" |
edgeTypeThe path of edges that set no `type`. | SoneFlowEdgeType | "bezier" |
background | SoneFlowBackground | "dots" |
gridSize | number | 20 |
snapToGridSnap dragged nodes to the grid. | boolean | false |
toolDragging the background pans in both tools; `pan` also stops nodes from moving. | SoneFlowTool | "select" |
minZoom | — | SONE_FLOW_MIN_ZOOM |
maxZoom | — | SONE_FLOW_MAX_ZOOM |
fitViewFit the nodes into view once they are first measured. | boolean | true |
panOnScrollA plain wheel pans the canvas (otherwise it scrolls the page; Ctrl / ⌘ + wheel always zooms). | boolean | false |
connectable | boolean | true |
deletable | boolean | true |
autoConnectAdd the edge on `(connect)` (`false`: only emit it, the owner adds it). | boolean | true |
isValidConnection | ((c: SoneFlowConnection) => boolean) | null | null |
ariaLabelThe canvas's accessible name (default "Flow diagram"). | string | null | null |
labels | Partial<SoneFlowLabels> | {} |
| 名前 | 型 |
|---|---|
connect | SoneFlowConnection |
nodeClick | SoneFlowNode |
nodeDoubleClick | SoneFlowNode |
nodeDragEnd | SoneFlowNode |
edgeClick | SoneFlowEdge |
canvasClickA click on the empty canvas, at that point in canvas units. | SoneFlowPoint |
nodesDelete | readonly SoneFlowNode[] |
edgesDelete | readonly SoneFlowEdge[] |
SoneFlowControlsComponentコンポーネント
Zoom in, zoom out, fit view, the zoom level (a reset to 100%) and a lock toggle for the `<sone-flow>` it sits in.
| 名前 | 型 | デフォルト |
|---|---|---|
position | SoneFlowPanelPosition | "bottom-left" |
orientation | "horizontal" | "vertical" | "vertical" |
showZoomShow the zoom level as a button that resets it to 100%. | boolean | false |
showLock | boolean | true |
labels | Partial<SoneFlowControlsLabels> | {} |
SoneFlowMinimapComponentコンポーネント
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.
| 名前 | 型 | デフォルト |
|---|---|---|
position | SoneFlowPanelPosition | "bottom-right" |
width | number | 200 |
height | number | 136 |
SoneFlowNodeTemplateDirectiveディレクティブ
`<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.
SoneFlowPanelDirectiveディレクティブ
Pins projected content (a legend, a run button) to a corner or edge of the canvas.
| 名前 | 型 | デフォルト |
|---|---|---|
soneFlowPanel | SoneFlowPanelPosition | "top-left" |