pivotick / InterractionCallbacks / InterractionCallbacks
Interface: InterractionCallbacks<TElement>
Defined in: interfaces/InterractionCallbacks.ts:12
Type Parameters
TElement
TElement = unknown
Properties
isValidConnection()?
optionalisValidConnection: (source,target) =>boolean
Defined in: interfaces/InterractionCallbacks.ts:251
Live validity predicate evaluated during the connect gesture as the cursor hovers candidate targets (à la React Flow's isValidConnection). Return false to mark the hovered target invalid: the shadow edge renders in an invalid style, and releasing / clicking on it creates nothing (in that case onBeforeEdgeCreate is not consulted). Runs on every pointer move, so it must be synchronous and cheap.
Parameters
source
target
Returns
boolean
onBadgeClick()?
optionalonBadgeClick: (event,node,badge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:69
Called when any of a node's rim badges is clicked, after that badge's own onClick. Use it for behaviour every badge shares; use NodeBadge.onClick for one badge's own action.
Declaring it makes every badge take the pointer cursor and consume its click, so the node underneath is not also selected.
Parameters
event
PointerEvent
node
badge
element
TElement
Returns
void
onBeforeDelete()?
optionalonBeforeDelete: (context) =>DeleteDecision|Promise<DeleteDecision>
Defined in: interfaces/InterractionCallbacks.ts:277
Called when the user asks to delete graph elements, before anything is removed. The library resolves the whole target set first — including the edges that removing a node would take with it (DeleteContext.cascadingEdges) — so a consumer can persist the full consequence of the gesture without re-deriving the cascade.
- Return
false/{ accept: false }to veto: nothing is removed, nonodeRemove/edgeRemove/noteRemovefires, and the selection is left intact. - Return
trueto delete exactly what was requested. - Return
{ accept: true, nodes?, edges?, notes? }to narrow the delete to a subset — e.g. keep only what the backend actually deleted. An omitted key means "as requested", so{ accept: true }is equivalent totrue; pass an empty array to spare that kind entirely. Elements that weren't part of the request are ignored.
May be async (persist the delete, then decide) — a second delete gesture is ignored while a decision is pending. DeleteContext.confirm opens a confirmation modal so consumers don't rebuild one.
Only user-initiated deletes are gated: programmatic graph.removeNode() / graph.removeEdge() / noteManager.removeNote() never invoke this hook, so consumer code driving the model isn't blocked by the consumer's own gate.
Parameters
context
Returns
DeleteDecision | Promise<DeleteDecision>
onBeforeEdgeCreate()?
optionalonBeforeEdgeCreate: (context) =>EdgeCreateDecision|Promise<EdgeCreateDecision>
Defined in: interfaces/InterractionCallbacks.ts:241
Called during a connect gesture, after the target node is resolved but before the edge (or note-link) is created. Acts as the edge equivalent of onBeforeNodeEditCommit: a validation / enrichment / veto hook.
- Return
false/{ accept: false }to veto: the preview is dropped, nothing is added, and connect mode stays armed so the user can retry. - Return
trueto accept with defaults. - Return
{ accept: true, data?, style?, id?, directed? }to accept and supply the new edge's payload/style/id/direction.
May be async (e.g. persist to a backend before deciding); the shadow-edge preview persists until the promise settles, and no new connect gesture is accepted while it is pending. Fires for both click- and drag-to-connect. Also fires for note→node links (EdgeCreateContext.kind 'note-link'), where the edge-specific fields of the decision are ignored.
Parameters
context
Returns
EdgeCreateDecision | Promise<EdgeCreateDecision>
whether the connection should be created, optionally with its data.
onBeforeEdgeEditCommit()?
optionalonBeforeEdgeEditCommit: (context) =>boolean|Promise<boolean>
Defined in: interfaces/InterractionCallbacks.ts:320
Called when an edge edit session is about to be committed. Acts as a validation / persistence / veto hook, mirroring onBeforeNodeEditCommit: return false (or a promise of it) to refuse, leaving the edge's data untouched and the modal open. On success the edge's data is replaced and edgeChange fires on the data bus.
Parameters
context
Returns
boolean | Promise<boolean>
whether the commit should proceed
onBeforeIngest()?
optionalonBeforeIngest: (context) =>IngestDecision|Promise<IngestDecision>
Defined in: interfaces/InterractionCallbacks.ts:300
Called once, with the whole candidate set, just before a pivot ingests it — the one gate on the ingest pipeline.
- Return
false/{ accept: false }to veto: nothing lands, and the run reports'vetoed'. - Return
trueto ingest exactly what was chosen. - Return
{ accept: true, nodes?, edges? }to narrow the ingest to a subset — e.g. only what the backend confirmed. An omitted key means "as requested", so{ accept: true }is equivalent totrue; pass an empty array to land none of that kind.
Called once per ingest with the entire batch, never per candidate: a pivot that found 1,800 correlations must not turn into 1,800 hook calls, and the per-gesture write-path hooks (onBeforeEdgeCreate, onBeforeDelete) are deliberately about user gestures rather than a programmatic merge. It gates autoIngest pivots too, which is what keeps them governed.
May be async (persist, then decide). IngestContext.confirm opens the shared confirmation modal.
Parameters
context
Returns
IngestDecision | Promise<IngestDecision>
onBeforeNodeCreate()?
optionalonBeforeNodeCreate: (context) =>NodeCreateDecision|Promise<NodeCreateDecision>
Defined in: interfaces/InterractionCallbacks.ts:342
Called when the user creates a node interactively (Create ▸ Add node, or the canvas context-menu's "Add Node Here"), once the graph-space position is known and before the node is added. Mirrors onBeforeEdgeCreate:
- Return
false/{ accept: false }to veto — nothing is added. - Return
trueto accept the library's default node. - Return
{ accept: true, id?, data?, style? }to accept and supply the new node's id / payload / style.
May be async, and NodeCreateContext.promptData opens the same declarative-form or custom-HTML modal the edge hook uses. Absent this hook the tool still works — it just creates a default, unnamed node. Programmatic graph.addNode() is never gated.
Parameters
context
Returns
NodeCreateDecision | Promise<NodeCreateDecision>
onBeforeNodeEditCommit()?
optionalonBeforeNodeEditCommit: (context) =>boolean|Promise<boolean>
Defined in: interfaces/InterractionCallbacks.ts:216
Called when a node edit session is about to be committed. Acts as a validation / persistence / veto hook: return false (or a promise of it) to refuse, leaving the node's data untouched and the modal open. On success the node's data is replaced and nodeChange fires on the data bus.
Parameters
context
Returns
boolean | Promise<boolean>
boolean indicating if the commit should proceed or not
onCanvasBeforeZoom()?
optionalonCanvasBeforeZoom: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:176
Called when the canvas is about to be zoomed.
Parameters
event
unknown
Returns
void
onCanvasClick()?
optionalonCanvasClick: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:162
Called when the canvas is clicked.
Parameters
event
PointerEvent
Returns
void
onCanvasContextmenu()?
optionalonCanvasContextmenu: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:186
Called when the canvas is right clicked.
Parameters
event
PointerEvent
Returns
void
onCanvasMousemove()?
optionalonCanvasMousemove: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:191
Called when the mouse move over the canvas.
Parameters
event
MouseEvent
Returns
void
onCanvasPointerDown()?
optionalonCanvasPointerDown: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:167
Called when a user pointer down the canvas.
Parameters
event
PointerEvent
Returns
void
onCanvasPointerUp()?
optionalonCanvasPointerUp: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:171
Called when a user pointer up the canvas.
Parameters
event
PointerEvent
Returns
void
onCanvasZoom()?
optionalonCanvasZoom: (event) =>void
Defined in: interfaces/InterractionCallbacks.ts:181
Called when the canvas is zoomed.
Parameters
event
unknown
Returns
void
onEdgeBlur()?
optionalonEdgeBlur: (edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:102
Called when an edge is unselected by the user.
Parameters
edge
element
TElement
Returns
void
onEdgeClick()?
optionalonEdgeClick: (event,edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:84
Called when an edge is selected by the user.
Parameters
event
PointerEvent
edge
element
TElement
Returns
void
onEdgeContextmenu()?
optionalonEdgeContextmenu: (event,edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:92
Called when an edge is right clicked.
Parameters
event
PointerEvent
edge
element
TElement
Returns
void
onEdgeDbclick()?
optionalonEdgeDbclick: (event,edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:88
Called when an edge is selected by the user.
Parameters
event
PointerEvent
edge
element
TElement
Returns
void
onEdgeEdit()?
optionalonEdgeEdit: (session) =>HTMLDivElement
Defined in: interfaces/InterractionCallbacks.ts:310
Called when an edge edit session starts. Acts as a UI hook, mirroring onNodeEdit: return the body to inject into the edit modal. A custom body owns the draft — mutate session.draft (or call session.setDraft) as the user types, because the library has no form to read on submit.
Parameters
session
EdgeEditSession
The edge edit session
Returns
HTMLDivElement
A HTML Div that will be injected in the modal's body
onEdgeEditCancel()?
optionalonEdgeEditCancel: (edge) =>void
Defined in: interfaces/InterractionCallbacks.ts:325
Called when an edge edit session gets cancelled.
Parameters
edge
Returns
void
onEdgeHoverIn()?
optionalonEdgeHoverIn: (event,edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:107
Called when a user hovers over an edge.
Parameters
event
PointerEvent
edge
element
TElement
Returns
void
onEdgeHoverOut()?
optionalonEdgeHoverOut: (event,edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:111
Called when a user hovers over an edge.
Parameters
event
PointerEvent
edge
element
TElement
Returns
void
onEdgeSelect()?
optionalonEdgeSelect: (edge,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:97
Called when an edge is selected by the user.
Parameters
edge
element
TElement
Returns
void
onNodeBlur()?
optionalonNodeBlur: (node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:59
Called when a node is unselected by the user.
Parameters
node
element
TElement
Returns
void
onNodeClick()?
optionalonNodeClick: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:16
Called when a node is clicked.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodeContextmenu()?
optionalonNodeContextmenu: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:26
Called when a node is right clicked.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodeDbclick()?
optionalonNodeDbclick: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:21
Called when a node is double clicked.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodeDragended()?
optionalonNodeDragended: (event,node) =>void
Defined in: interfaces/InterractionCallbacks.ts:79
Called when a node drag ends.
Parameters
event
MouseEvent
node
Returns
void
onNodeDragging()?
optionalonNodeDragging: (event,node) =>void
Defined in: interfaces/InterractionCallbacks.ts:74
Called when a node is dragged.
Parameters
event
MouseEvent
node
Returns
void
onNodeEdit()?
optionalonNodeEdit: (session) =>HTMLDivElement
Defined in: interfaces/InterractionCallbacks.ts:208
Called when a node edit session starts. Act as a UI hook.
Parameters
session
NodeEditSession
The node edit session
Returns
HTMLDivElement
A HTML Div that will be injected in the modal's body
onNodeEditCancel()?
optionalonNodeEditCancel: (node) =>void
Defined in: interfaces/InterractionCallbacks.ts:220
Called when an node edit session gets cancelled
Parameters
node
Returns
void
onNodeHoverIn()?
optionalonNodeHoverIn: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:31
Called when a user hovers over a node.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodeHoverOut()?
optionalonNodeHoverOut: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:35
Called when a user hovers out of a node.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodePointerDown()?
optionalonNodePointerDown: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:40
Called when a user pointer down a node.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodePointerUp()?
optionalonNodePointerUp: (event,node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:44
Called when a user pointer up a node.
Parameters
event
PointerEvent
node
element
TElement
Returns
void
onNodeSelect()?
optionalonNodeSelect: (node,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:49
Called when a node is selected by the user.
Parameters
node
element
TElement
Returns
void
onNodesSelect()?
optionalonNodesSelect: (selection) =>void
Defined in: interfaces/InterractionCallbacks.ts:54
Called when nodes are selected by the user.
Parameters
selection
NodeSelection<TElement>[]
Returns
void
onNoteClick()?
optionalonNoteClick: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:116
Called when a note is clicked.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNoteContextmenu()?
optionalonNoteContextmenu: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:126
Called when a note is right clicked.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNoteDbclick()?
optionalonNoteDbclick: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:121
Called when a note is double clicked.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNoteDragging()?
optionalonNoteDragging: (event,note) =>void
Defined in: interfaces/InterractionCallbacks.ts:157
Called when a user pointer up a node.
Parameters
event
PointerEvent
note
Returns
void
onNoteHandleClick()?
optionalonNoteHandleClick: (event,note,handle) =>void
Defined in: interfaces/InterractionCallbacks.ts:149
Called when a user pointer down a node.
Parameters
event
PointerEvent
note
handle
HTMLElement
Returns
void
onNoteHandlePointerDown()?
optionalonNoteHandlePointerDown: (event,note,handle) =>void
Defined in: interfaces/InterractionCallbacks.ts:153
Called when a user pointer up a node.
Parameters
event
PointerEvent
note
handle
HTMLElement
Returns
void
onNoteHoverIn()?
optionalonNoteHoverIn: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:131
Called when a user hovers over a note.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNoteHoverOut()?
optionalonNoteHoverOut: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:135
Called when a user hovers out of a note.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNotePointerDown()?
optionalonNotePointerDown: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:140
Called when a user pointer down a node.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onNotePointerUp()?
optionalonNotePointerUp: (event,note,element) =>void
Defined in: interfaces/InterractionCallbacks.ts:144
Called when a user pointer up a node.
Parameters
event
PointerEvent
note
element
TElement
Returns
void
onSimulationSlowTick()?
optionalonSimulationSlowTick: () =>void
Defined in: interfaces/InterractionCallbacks.ts:201
Called when the every tenth of simulation ticks.
Returns
void
onSimulationTick()?
optionalonSimulationTick: () =>void
Defined in: interfaces/InterractionCallbacks.ts:196
Called when the simulation ticks.
Returns
void