Fragiola

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

Node

Flow.Node renders one node at its place in the flow, registers it with the engine to be measured, and holds its content, handles and toolbar.

Flow.Node renders the node Flow.Nodes gives its children function. It is absolutely positioned at the node's place (a structural transform: translate(x, y) from node-rect-by, absolute even in a sub-flow: a child is not nested in its parent's element), with the document's width and height when it gives them. It registers its element with the engine, which measures it (ResizeObserver) and resolves presses on it: a drag (drag()), a click selects (selection()), a press on one of its handles draws a connection (connection()). With keyboard() it takes tabIndex={0}.

It renders only its children: the content, Flow.Handles, a NodeResizer, a Flow.NodeToolbar. Fields, buttons and links inside it start no gesture, nor does an element marked data-flow-no-gesture; data-flow-no-wheel keeps the wheel (a scrolling list).

<Flow.Nodes<Types>>
    {(node) => (
        <Flow.Node<Types>
            node={node}
            aria-label={node.data.label}
            className={(state) => (state.selected ? "node node-selected" : "node")}
        >
            {node.data.label}
            <Flow.Handle type="target" side="top" />
            <Flow.Handle type="source" side="bottom" />
        </Flow.Node>
    )}
</Flow.Nodes>

It has no role and no name: give it the ones your app means (see Accessible names), and user-select: none so a drag does not select its text. For a node rendered by hand, useNode gives the same state and props.

Props

NodeProps<T> extends the common primitive props and every div attribute.

proptypedefaultdescription
nodeFlowNode<T>requiredthe node it renders: the one Flow.Nodes gives
childrenReactNodenoneits content, handles, resizer, toolbar

State

NodeState<T>, what className, style and render receive (also useNode's state):

fieldtypedescription
nodeIdstringits id
nodeFlowNode<T>the node, as the model holds it
x, ynumberits top-left corner in absolute flow coordinates
selectedbooleanit is selected (selection())
draggingbooleanit is being dragged (drag())
resizingbooleanit is being resized (resize())
measuredbooleanits size is known (measured or given)
focusablebooleanit takes DOM focus (keyboard())
attributesPartAttributesthe attributes its element carries

Data attributes

attributevalue
data-flow-part"node"
data-flow-idits id
data-selectedpresent while selected
data-draggingpresent while dragged
data-resizingpresent while resized
data-measuredpresent once its size is known
data-hiddenpresent when hidden: only on a node you render by hand with useNode, since Flow.Nodes leaves hidden nodes out
tabindex0 with keyboard()

Structural style

position: absolute; top: 0; left: 0; transform: translate(<x>px, <y>px) (its box's top-left corner, its origin or the root's nodeOrigin applied), z-index (node-z-index-by: its zIndex, raised by 10 000 while selected with elevateNodesOnSelect, at least its parent's + 1; a negative rank while edges stand above nodes), and width / height when the document gives them. Before the engine is attached (the first render, a server render) the same place and z-index come from the document's static geometry, so nothing moves when the engine takes over. Its look is yours.