Skip to content

pivotick v3.0.0


pivotick / InterractionCallbacks / InterractionCallbacks

Interface: InterractionCallbacks<TElement> ​

Defined in: interfaces/InterractionCallbacks.ts:12

Type Parameters ​

TElement ​

TElement = unknown

Properties ​

isValidConnection()? ​

optional isValidConnection: (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 ​

Node | Note

target ​

Node

Returns ​

boolean


onBadgeClick()? ​

optional onBadgeClick: (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 ​

Node

badge ​

NodeBadge

element ​

TElement

Returns ​

void


onBeforeDelete()? ​

optional onBeforeDelete: (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, no nodeRemove/edgeRemove/noteRemove fires, and the selection is left intact.
  • Return true to 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 to true; 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 ​

DeleteContext

Returns ​

DeleteDecision | Promise<DeleteDecision>


onBeforeEdgeCreate()? ​

optional onBeforeEdgeCreate: (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 true to 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 ​

EdgeCreateContext

Returns ​

EdgeCreateDecision | Promise<EdgeCreateDecision>

whether the connection should be created, optionally with its data.


onBeforeEdgeEditCommit()? ​

optional onBeforeEdgeEditCommit: (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 ​

EdgeEditCommitContext

Returns ​

boolean | Promise<boolean>

whether the commit should proceed


onBeforeIngest()? ​

optional onBeforeIngest: (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 true to 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 to true; 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 ​

IngestContext

Returns ​

IngestDecision | Promise<IngestDecision>


onBeforeNodeCreate()? ​

optional onBeforeNodeCreate: (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 true to 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 ​

NodeCreateContext

Returns ​

NodeCreateDecision | Promise<NodeCreateDecision>


onBeforeNodeEditCommit()? ​

optional onBeforeNodeEditCommit: (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 ​

NodeEditCommitContext

Returns ​

boolean | Promise<boolean>

boolean indicating if the commit should proceed or not


onCanvasBeforeZoom()? ​

optional onCanvasBeforeZoom: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:176

Called when the canvas is about to be zoomed.

Parameters ​

event ​

unknown

Returns ​

void


onCanvasClick()? ​

optional onCanvasClick: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:162

Called when the canvas is clicked.

Parameters ​

event ​

PointerEvent

Returns ​

void


onCanvasContextmenu()? ​

optional onCanvasContextmenu: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:186

Called when the canvas is right clicked.

Parameters ​

event ​

PointerEvent

Returns ​

void


onCanvasMousemove()? ​

optional onCanvasMousemove: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:191

Called when the mouse move over the canvas.

Parameters ​

event ​

MouseEvent

Returns ​

void


onCanvasPointerDown()? ​

optional onCanvasPointerDown: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:167

Called when a user pointer down the canvas.

Parameters ​

event ​

PointerEvent

Returns ​

void


onCanvasPointerUp()? ​

optional onCanvasPointerUp: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:171

Called when a user pointer up the canvas.

Parameters ​

event ​

PointerEvent

Returns ​

void


onCanvasZoom()? ​

optional onCanvasZoom: (event) => void

Defined in: interfaces/InterractionCallbacks.ts:181

Called when the canvas is zoomed.

Parameters ​

event ​

unknown

Returns ​

void


onEdgeBlur()? ​

optional onEdgeBlur: (edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:102

Called when an edge is unselected by the user.

Parameters ​

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeClick()? ​

optional onEdgeClick: (event, edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:84

Called when an edge is selected by the user.

Parameters ​

event ​

PointerEvent

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeContextmenu()? ​

optional onEdgeContextmenu: (event, edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:92

Called when an edge is right clicked.

Parameters ​

event ​

PointerEvent

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeDbclick()? ​

optional onEdgeDbclick: (event, edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:88

Called when an edge is selected by the user.

Parameters ​

event ​

PointerEvent

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeEdit()? ​

optional onEdgeEdit: (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()? ​

optional onEdgeEditCancel: (edge) => void

Defined in: interfaces/InterractionCallbacks.ts:325

Called when an edge edit session gets cancelled.

Parameters ​

edge ​

Edge

Returns ​

void


onEdgeHoverIn()? ​

optional onEdgeHoverIn: (event, edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:107

Called when a user hovers over an edge.

Parameters ​

event ​

PointerEvent

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeHoverOut()? ​

optional onEdgeHoverOut: (event, edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:111

Called when a user hovers over an edge.

Parameters ​

event ​

PointerEvent

edge ​

Edge

element ​

TElement

Returns ​

void


onEdgeSelect()? ​

optional onEdgeSelect: (edge, element) => void

Defined in: interfaces/InterractionCallbacks.ts:97

Called when an edge is selected by the user.

Parameters ​

edge ​

Edge

element ​

TElement

Returns ​

void


onNodeBlur()? ​

optional onNodeBlur: (node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:59

Called when a node is unselected by the user.

Parameters ​

node ​

Node

element ​

TElement

Returns ​

void


onNodeClick()? ​

optional onNodeClick: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:16

Called when a node is clicked.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodeContextmenu()? ​

optional onNodeContextmenu: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:26

Called when a node is right clicked.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodeDbclick()? ​

optional onNodeDbclick: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:21

Called when a node is double clicked.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodeDragended()? ​

optional onNodeDragended: (event, node) => void

Defined in: interfaces/InterractionCallbacks.ts:79

Called when a node drag ends.

Parameters ​

event ​

MouseEvent

node ​

Node

Returns ​

void


onNodeDragging()? ​

optional onNodeDragging: (event, node) => void

Defined in: interfaces/InterractionCallbacks.ts:74

Called when a node is dragged.

Parameters ​

event ​

MouseEvent

node ​

Node

Returns ​

void


onNodeEdit()? ​

optional onNodeEdit: (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()? ​

optional onNodeEditCancel: (node) => void

Defined in: interfaces/InterractionCallbacks.ts:220

Called when an node edit session gets cancelled

Parameters ​

node ​

Node

Returns ​

void


onNodeHoverIn()? ​

optional onNodeHoverIn: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:31

Called when a user hovers over a node.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodeHoverOut()? ​

optional onNodeHoverOut: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:35

Called when a user hovers out of a node.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodePointerDown()? ​

optional onNodePointerDown: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:40

Called when a user pointer down a node.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodePointerUp()? ​

optional onNodePointerUp: (event, node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:44

Called when a user pointer up a node.

Parameters ​

event ​

PointerEvent

node ​

Node

element ​

TElement

Returns ​

void


onNodeSelect()? ​

optional onNodeSelect: (node, element) => void

Defined in: interfaces/InterractionCallbacks.ts:49

Called when a node is selected by the user.

Parameters ​

node ​

Node

element ​

TElement

Returns ​

void


onNodesSelect()? ​

optional onNodesSelect: (selection) => void

Defined in: interfaces/InterractionCallbacks.ts:54

Called when nodes are selected by the user.

Parameters ​

selection ​

NodeSelection<TElement>[]

Returns ​

void


onNoteClick()? ​

optional onNoteClick: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:116

Called when a note is clicked.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNoteContextmenu()? ​

optional onNoteContextmenu: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:126

Called when a note is right clicked.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNoteDbclick()? ​

optional onNoteDbclick: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:121

Called when a note is double clicked.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNoteDragging()? ​

optional onNoteDragging: (event, note) => void

Defined in: interfaces/InterractionCallbacks.ts:157

Called when a user pointer up a node.

Parameters ​

event ​

PointerEvent

note ​

Note

Returns ​

void


onNoteHandleClick()? ​

optional onNoteHandleClick: (event, note, handle) => void

Defined in: interfaces/InterractionCallbacks.ts:149

Called when a user pointer down a node.

Parameters ​

event ​

PointerEvent

note ​

Note

handle ​

HTMLElement

Returns ​

void


onNoteHandlePointerDown()? ​

optional onNoteHandlePointerDown: (event, note, handle) => void

Defined in: interfaces/InterractionCallbacks.ts:153

Called when a user pointer up a node.

Parameters ​

event ​

PointerEvent

note ​

Note

handle ​

HTMLElement

Returns ​

void


onNoteHoverIn()? ​

optional onNoteHoverIn: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:131

Called when a user hovers over a note.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNoteHoverOut()? ​

optional onNoteHoverOut: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:135

Called when a user hovers out of a note.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNotePointerDown()? ​

optional onNotePointerDown: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:140

Called when a user pointer down a node.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onNotePointerUp()? ​

optional onNotePointerUp: (event, note, element) => void

Defined in: interfaces/InterractionCallbacks.ts:144

Called when a user pointer up a node.

Parameters ​

event ​

PointerEvent

note ​

Note

element ​

TElement

Returns ​

void


onSimulationSlowTick()? ​

optional onSimulationSlowTick: () => void

Defined in: interfaces/InterractionCallbacks.ts:201

Called when the every tenth of simulation ticks.

Returns ​

void


onSimulationTick()? ​

optional onSimulationTick: () => void

Defined in: interfaces/InterractionCallbacks.ts:196

Called when the simulation ticks.

Returns ​

void