API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)
NodesSelection
Flow.NodesSelection draws the rectangle around the nodes a box selected, in flow coordinates, and drags the selection by it.
Flow.NodesSelection goes inside Flow.Viewport, after Flow.Nodes (it is in flow
coordinates), and renders a div at the engine's selection-rect while two or more nodes are
selected by a box (selection(); with selection({ rect: "always" }), whenever two or more are
selected), and nothing otherwise. A press on it drags the selection (drag(): the same
threshold, snap, extent and auto-pan as a node's drag), with the root's onSelectionDragStart,
onSelectionDrag and onSelectionDragStop instead of the node drag's; a cancelled drag (Escape)
puts the nodes back and is onNodeDragCancel (drag-cancel). Its context menu is the
selection's (onSelectionContextMenu). With keyboard() it takes focus (tabindex="0") and
its keys are a focused selected node's: the arrows move the selection (Shift: by fastStep), a
delete key removes it, Escape clears it; Enter and Space do nothing. Give it its look and an
accessible name (aria-label="Selected nodes"). How it fits with the box and the events:
Selection.
<Flow.Root<Types, typeof features> features={features} defaultNodes={nodes}>
<Flow.Viewport>
<Flow.Nodes>{(node) => <Flow.Node node={node} />}</Flow.Nodes>
<Flow.NodesSelection aria-label="Selected nodes" className="border border-blue-500 bg-blue-500/5" />
</Flow.Viewport>
</Flow.Root>Props
NodesSelectionProps extends the common primitive props
and every div attribute.
| prop | type | default | description |
|---|---|---|---|
children | ReactNode | none | its content |
State
NodesSelectionState, what className, style and render receive:
| field | type | description |
|---|---|---|
rect | Rect | the rectangle around the selected nodes, in flow coordinates |
dragging | boolean | the selection is being dragged by it: data-dragging |
Data attributes
| attribute | value |
|---|---|
data-flow-part | "nodes-selection" |
data-dragging | present while it drags the selection |
tabindex | "0" with keyboard() installed |
Structural style
position: absolute at the flow's origin, transform: translate(x, y), width and height of
selection-rect.