Connection rules let you restrict which inputs can accept a connection from a specific output or outlet.
Instead of letting users connect anything to anything, you can declare an allow‑list directly on the source connector and the library will:
Connection rules are a UX guardrail. Your app should still validate and persist the final graph state.
API note (v19+). On the unified
fConnectordirective the allow-list input is calledfCanBeConnectedTo, and targets are matched byfConnectorId/fConnectorCategory. The legacyfCanBeConnectedInputsinput onfNodeOutput/fNodeOutletis deprecated but keeps working. The matching semantics below are the same for both APIs.
Rules are defined on source connectors:
fConnector with type source, source-target, or outlet — via fCanBeConnectedTo: string[]fNodeOutput / fNodeOutlet (deprecated) — via fCanBeConnectedInputs: string[]During drag-to-connect, the library checks each candidate target connector and considers it connectable when either matches:
fConnectorId, legacy fInputId)fConnectorCategory, legacy fInputCategory) — if you use categoriesOnly input-approve can be targeted.
Only targets with fConnectorCategory="A" are valid.
fCanBeConnectedTo (legacy fCanBeConnectedInputs) is a simple allow-list of strings.
Each string can be interpreted as either:
fConnectorId, legacy fInputId)fConnectorCategory, legacy fInputCategory)Because both are plain strings, you should adopt a convention to avoid accidental collisions (when some target id equals a category name).
Use prefixes:
id:<inputId> — for a specific inputcat:<category> — for a categoryExample:
And on the targets:
You can also enforce “no overlap” by policy:
input:<name> or in-<number>CAT_<name> or type:<name>The key point is: make ids and categories visually distinct so allow-lists are readable and safe.
fCanBeConnectedTo: string[];
Declared on [fConnector] (types source, source-target, outlet).
fCanBeConnectedInputs: string[]; (deprecated)
Declared on [fNodeOutput] and [fNodeOutlet].
fConnectorId: InputSignal<string>;fConnectorCategory: InputSignal<string | undefined>; (optional)fInputId / fInputCategory on [fNodeInput] (deprecated)fCreateConnection from f-flow[fDraggable]During drag-to-connect, the library applies state classes so you can clearly communicate rules:
.f-connector-connectable - marks valid targets during drag.f-connector-not-connectable - blocked ports (legacy: .f-node-input-not-connectable / .f-node-output-not-connectable)(Exact styling is up to you; the library keeps defaults minimal.)
fCanBeConnectedTo / legacy fCanBeConnectedInputs) is empty or undefined, there is no allow-list restriction.[example.html] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/connectors/connection-rules/example.html [example.ts] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/connectors/connection-rules/example.ts [example.scss] <<< https://raw.githubusercontent.com/Foblex/f-flow/main/libs/f-examples/connectors/connection-rules/example.scss