Fragiola

API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)

Handle

Flow.Handle is a connection point on a side of its node, registered with the engine, where edges start or end and connections are drawn.

Flow.Handle goes inside Flow.Node. It registers { nodeId, handleId, type, side, connectable, connectableStart, connectableEnd } with the engine, which measures its centre relative to its node: an edge naming this handle (sourceHandle, targetHandle) starts or ends at that centre, leaving or entering by its side. With connection(), a press on it draws a connection; while one is drawn it says whether the drop here would be accepted (data-valid, data-invalid, from model.can("edge.add", …), or model.can("edge.reconnect", …) while an edge's end is moved).

<Flow.Node<Types> node={node}>
    {node.data.label}
    <Flow.Handle type="target" side="left" title="Input" className="size-2 rounded-full bg-gray-500" />
    <Flow.Handle type="source" side="right" handleId="ok" style={{ top: "30%" }} />
    <Flow.Handle type="source" side="right" handleId="error" style={{ top: "70%" }} />
</Flow.Node>

It sits at the middle of its side by default (a default your style overrides: several handles on one side are placed by you). A handle without handleId is the node's default handle of its type. Sides are physical (top, right, bottom, left): a diagram does not flip in right-to-left. See Handles and connections. For a handle rendered by hand, useHandle gives the same state and props.

Props

HandleProps extends the common primitive props, every div attribute and UseHandleOptions.

proptypedefaultdescription
typeHandleTyperequired"source": edges start here; "target": edges end here
sideHandleSiderequiredthe side of the node it sits on: the direction its edges leave or enter by
handleIdstringnoneits id among the node's handles of its type (none: the default handle)
connectablebooleantruea connection may start or end here
connectableStartbooleantruea connection may start here (a drag, a click, a key); false: only an end (React Flow's isConnectableStart)
connectableEndbooleantruea connection may end here; false: never a target (React Flow's isConnectableEnd)
nodeIdstringthe enclosing Flow.Node'sits node
childrenReactNodenoneits content

State

HandleState, what className, style and render receive:

fieldtypedescription
nodeIdstringits node
handleIdstring | undefinedits id
typeHandleType"source" or "target"
sideHandleSideits side
connectablebooleana connection may start or end here (its flag and its node's)
connectableStartbooleana connection may start here
connectableEndbooleana connection may end here
connectingbooleanthe connection under way starts here
validbooleanthe connection under way would end here and be accepted
invalidbooleanthe connection under way would end here and be refused
attributesPartAttributesthe attributes its element carries

Data attributes

attributevalue
data-flow-part"handle"
data-flow-idits handleId
data-handle-type"source" or "target"
data-side"top", "right", "bottom" or "left"
data-connectablepresent when a connection may start or end here
data-connectable-startpresent when a connection may start here
data-connectable-endpresent when a connection may end here
data-connectingpresent while the connection under way starts here
data-valid / data-invalidpresent while the connection under way would end here, accepted or refused

Structural style

position: absolute; by default centred on its side (translate(-50%, -50%)), a place your style overrides. Its size and look are yours.