Fragiola

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

Edge

Flow.Edge is one edge, an SVG group drawn once both nodes have a size, holding its path, its label and its reconnect anchors.

Flow.Edge draws the edge Flow.Edges gives its children function, as an SVG g. It renders nothing until the edge has a path (both nodes measured). Its children are its parts: Flow.EdgePath by default, Flow.EdgeLabel, Flow.ReconnectAnchors, or several paths (a wide transparent one as a bigger press target). A press on its stroke selects it (selection()); with keyboard() it takes tabIndex={0}.

<Flow.Edges<Types>>
    {(edge) => (
        <Flow.Edge<Types> edge={edge} aria-label={`${edge.source} to ${edge.target}`}>
            <Flow.EdgePath className="stroke-gray-400 stroke-2" />
            {edge.data?.label && <Flow.EdgeLabel>{edge.data.label}</Flow.EdgeLabel>}
        </Flow.Edge>
    )}
</Flow.Edges>

The path follows the edge's type: bezier (none is bezier), simplebezier, smoothstep, step, straight. An app type gets the bezier path and its ends, to draw its own d on Flow.EdgePath (see Custom edges). For an edge drawn by hand, useEdge gives the same state and props.

Props

EdgeProps<T> extends the common primitive props and every SVG attribute of a g.

proptypedefaultdescription
edgeFlowEdge<T>requiredthe edge it draws: the one Flow.Edges gives
childrenReactNodea Flow.EdgePathits parts

State

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

fieldtypedescription
edgeIdstringits id
edgeFlowEdge<T>the edge, as the model holds it
pathEdgePath | undefinedits path, label point and ends (edge-path-by)
selectedbooleanit is selected (selection())
reconnectingbooleanone of its ends is being moved (reconnection())
focusablebooleanit takes DOM focus (keyboard())
attributesPartAttributesthe attributes its element carries

Data attributes

attributevalue
data-flow-part"edge"
data-flow-idits id
data-selectedpresent while selected
data-animatedpresent while its animated flag is set (your CSS animates it)
data-reconnectingpresent while one of its ends is moved
tabindex0 with keyboard()

Structural style

pointer-events: visibleStroke: a press on its stroke reaches it, one beside it reaches the pane.