Fragiola

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

Nodes

Flow.Nodes is the layer of the nodes, calling your children function once per node that is shown, keyed by id and memoized per node.

Flow.Nodes goes inside Flow.Viewport, after Flow.Edges. It calls its children function for each node that is not hidden, in drawing order, keyed by the node's id (a node keeps its element when it moves). With the root's onlyRenderVisible, only the nodes in view (and those not measured yet) are rendered (visible-nodes), and none before the engine knows the view (the server render, the first client render). You render each node: usually a Flow.Node with its content and handles, switching on node.type when the flow has several.

function renderNode(node: FlowNode<Types>) {
    return (
        <Flow.Node<Types> node={node} className="rounded border bg-white p-2">
            {node.data.label}
            <Flow.Handle type="target" side="left" />
            <Flow.Handle type="source" side="right" />
        </Flow.Node>
    );
}

<Flow.Nodes<Types>>{renderNode}</Flow.Nodes>;

In React, each node's render is memoized on the node and the children function: a drag step re-renders the moved nodes only. A new children function re-renders every node, so keep it stable (a module function as above, or useCallback) when the app re-renders on each change (controlled nodes).

Props

NodesProps<T> extends the common primitive props and every div attribute but children.

proptypedefaultdescription
children(node: FlowNode<T>) => ReactNoderequiredrenders one node

State

NodesState, what className, style and render receive:

fieldtypedescription
countnumberhow many nodes are rendered

Data attributes

attributevalue
data-flow-part"nodes"

Structural style

position: absolute at the viewport's origin, and isolation: isolate: the nodes' z-index (a selected node raised) orders them among themselves and never lifts one above what follows the layer in Flow.Viewport (the connection line). While an edge stands above some node (render-layers has several levels), the layer drops its isolation, so the nodes' z-indexes (negative ranks, then) interleave with the edges' layers in the viewport; the nodes never leave it. Keep it, and Flow.Edges, free of anything that makes a stacking context (opacity below 1, transform, filter, isolation, a z-index), or the layering breaks (z-order). The layer is part of the pane: a press on it, off any node, pans or draws a selection box.