API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)
Edges
Flow.Edges is the SVG layer of the edges, calling your children function for each edge once both its nodes have a size, plus the labels' layer.
Flow.Edges goes inside Flow.Viewport, before Flow.Nodes so the nodes are drawn on top. It
renders a div holding an SVG where its children function draws each edge (usually a
Flow.Edge), and is the HTML layer Flow.EdgeLabels are portalled into. An edge is drawn once
both its nodes have a size (edge-path-by is defined). Before the engine exists (a server render,
the first client render) it draws the document's static geometry:
the edges whose nodes declare a size (width / height or initialWidth / initialHeight), at
their declared handles; the others wait for their nodes' measurements. Hidden edges, and edges
of hidden nodes, are left out; with onlyRenderVisible, only those in view (visible-edges), and
none before the engine knows the view. They
are drawn in the engine's order (drawn-edges): by their stack value (zIndex, a selected edge
raised with elevateEdgesOnSelect, an edge of a child at least as high as its ends with
zIndexMode: "auto"), then in the document's order.
With one render level (render-layers) every edge stays below every node, in one SVG: the DOM
below. When an edge stands above some node (a selected edge in "auto", an edge between a group's
children, a zIndex above a node's), each level gets a wrapper of its own inside the div,
data-flow-part="edges-layer" with data-level and the level's z-index, holding that level's
SVG (data-flow-part="edges") and its edges' labels. An edge that moves to another level is
remounted (in Angular, moved) and gets its focus back (z-order).
function renderEdge(edge: FlowEdge<Types>) {
return (
<Flow.Edge<Types> edge={edge}>
<Flow.EdgePath className="stroke-gray-400 data-selected:stroke-blue-500" />
</Flow.Edge>
);
}
<Flow.Edges<Types>>{renderEdge}</Flow.Edges>;The layer lets presses through to the pane; the edges' own parts take them. Each edge's render is
memoized on the edge and the children function (its path re-renders by itself): keep the function
stable, as for Flow.Nodes.
Props
EdgesProps<T> extends the common primitive props and
every div attribute but children.
| prop | type | default | description |
|---|---|---|---|
children | (edge: FlowEdge<T>) => ReactNode | required | draws one edge, as SVG |
State
EdgesState, what className, style and render receive:
| field | type | description |
|---|---|---|
count | number | how many edges are drawn |
Data attributes
| attribute | value |
|---|---|
data-flow-part | "edges", on the div and on its svg (each level's svg with several); "edges-layer" on each level's wrapper |
data-level | on an edges-layer: its render level, 0 the lowest |
Structural style
The div and the svg are absolute, 100% of the viewport, overflow: visible and
pointer-events: none; so is each edges-layer, with its level's z-index. The div makes no
stacking context, so the levels interleave with the nodes: do not give it (nor Flow.Nodes) an
opacity, a transform, a filter, an isolation or a z-index.