@xyflow/react 12.5.3 → 12.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/base.css +2 -2
  2. package/dist/esm/additional-components/Background/types.d.ts +9 -9
  3. package/dist/esm/additional-components/Background/types.d.ts.map +1 -1
  4. package/dist/esm/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
  5. package/dist/esm/additional-components/MiniMap/types.d.ts +65 -19
  6. package/dist/esm/additional-components/MiniMap/types.d.ts.map +1 -1
  7. package/dist/esm/additional-components/NodeResizer/NodeResizeControl.d.ts.map +1 -1
  8. package/dist/esm/additional-components/NodeResizer/types.d.ts +37 -18
  9. package/dist/esm/additional-components/NodeResizer/types.d.ts.map +1 -1
  10. package/dist/esm/additional-components/NodeToolbar/types.d.ts +6 -5
  11. package/dist/esm/additional-components/NodeToolbar/types.d.ts.map +1 -1
  12. package/dist/esm/components/Edges/SimpleBezierEdge.d.ts +10 -0
  13. package/dist/esm/components/Edges/SimpleBezierEdge.d.ts.map +1 -1
  14. package/dist/esm/components/Panel/index.d.ts +5 -5
  15. package/dist/esm/components/Panel/index.d.ts.map +1 -1
  16. package/dist/esm/contexts/NodeIdContext.d.ts +1 -1
  17. package/dist/esm/hooks/useConnection.d.ts +4 -0
  18. package/dist/esm/hooks/useConnection.d.ts.map +1 -1
  19. package/dist/esm/hooks/useEdges.d.ts +1 -1
  20. package/dist/esm/hooks/useHandleConnections.d.ts +8 -8
  21. package/dist/esm/hooks/useHandleConnections.d.ts.map +1 -1
  22. package/dist/esm/hooks/useInternalNode.d.ts +2 -2
  23. package/dist/esm/hooks/useKeyPress.d.ts +23 -4
  24. package/dist/esm/hooks/useKeyPress.d.ts.map +1 -1
  25. package/dist/esm/hooks/useNodeConnections.d.ts +6 -6
  26. package/dist/esm/hooks/useNodeConnections.d.ts.map +1 -1
  27. package/dist/esm/hooks/useNodes.d.ts +1 -1
  28. package/dist/esm/hooks/useNodesData.d.ts +7 -5
  29. package/dist/esm/hooks/useNodesData.d.ts.map +1 -1
  30. package/dist/esm/hooks/useNodesEdgesState.d.ts +32 -6
  31. package/dist/esm/hooks/useNodesEdgesState.d.ts.map +1 -1
  32. package/dist/esm/hooks/useNodesInitialized.d.ts +3 -2
  33. package/dist/esm/hooks/useNodesInitialized.d.ts.map +1 -1
  34. package/dist/esm/hooks/useOnSelectionChange.d.ts +1 -2
  35. package/dist/esm/hooks/useOnSelectionChange.d.ts.map +1 -1
  36. package/dist/esm/hooks/useOnViewportChange.d.ts +5 -6
  37. package/dist/esm/hooks/useOnViewportChange.d.ts.map +1 -1
  38. package/dist/esm/hooks/useReactFlow.d.ts +0 -2
  39. package/dist/esm/hooks/useReactFlow.d.ts.map +1 -1
  40. package/dist/esm/hooks/useStore.d.ts +8 -5
  41. package/dist/esm/hooks/useStore.d.ts.map +1 -1
  42. package/dist/esm/hooks/useUpdateNodeInternals.d.ts +5 -4
  43. package/dist/esm/hooks/useUpdateNodeInternals.d.ts.map +1 -1
  44. package/dist/esm/hooks/useViewport.d.ts +3 -3
  45. package/dist/esm/index.js +103 -74
  46. package/dist/esm/index.mjs +103 -74
  47. package/dist/esm/types/component-props.d.ts +234 -116
  48. package/dist/esm/types/component-props.d.ts.map +1 -1
  49. package/dist/esm/types/edges.d.ts +26 -8
  50. package/dist/esm/types/edges.d.ts.map +1 -1
  51. package/dist/esm/types/general.d.ts +11 -6
  52. package/dist/esm/types/general.d.ts.map +1 -1
  53. package/dist/esm/types/instance.d.ts +23 -8
  54. package/dist/esm/types/instance.d.ts.map +1 -1
  55. package/dist/esm/utils/changes.d.ts +6 -6
  56. package/dist/esm/utils/general.d.ts +11 -7
  57. package/dist/esm/utils/general.d.ts.map +1 -1
  58. package/dist/style.css +2 -2
  59. package/dist/umd/additional-components/Background/types.d.ts +9 -9
  60. package/dist/umd/additional-components/Background/types.d.ts.map +1 -1
  61. package/dist/umd/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
  62. package/dist/umd/additional-components/MiniMap/types.d.ts +65 -19
  63. package/dist/umd/additional-components/MiniMap/types.d.ts.map +1 -1
  64. package/dist/umd/additional-components/NodeResizer/NodeResizeControl.d.ts.map +1 -1
  65. package/dist/umd/additional-components/NodeResizer/types.d.ts +37 -18
  66. package/dist/umd/additional-components/NodeResizer/types.d.ts.map +1 -1
  67. package/dist/umd/additional-components/NodeToolbar/types.d.ts +6 -5
  68. package/dist/umd/additional-components/NodeToolbar/types.d.ts.map +1 -1
  69. package/dist/umd/components/Edges/SimpleBezierEdge.d.ts +10 -0
  70. package/dist/umd/components/Edges/SimpleBezierEdge.d.ts.map +1 -1
  71. package/dist/umd/components/Panel/index.d.ts +5 -5
  72. package/dist/umd/components/Panel/index.d.ts.map +1 -1
  73. package/dist/umd/contexts/NodeIdContext.d.ts +1 -1
  74. package/dist/umd/hooks/useConnection.d.ts +4 -0
  75. package/dist/umd/hooks/useConnection.d.ts.map +1 -1
  76. package/dist/umd/hooks/useEdges.d.ts +1 -1
  77. package/dist/umd/hooks/useHandleConnections.d.ts +8 -8
  78. package/dist/umd/hooks/useHandleConnections.d.ts.map +1 -1
  79. package/dist/umd/hooks/useInternalNode.d.ts +2 -2
  80. package/dist/umd/hooks/useKeyPress.d.ts +23 -4
  81. package/dist/umd/hooks/useKeyPress.d.ts.map +1 -1
  82. package/dist/umd/hooks/useNodeConnections.d.ts +6 -6
  83. package/dist/umd/hooks/useNodeConnections.d.ts.map +1 -1
  84. package/dist/umd/hooks/useNodes.d.ts +1 -1
  85. package/dist/umd/hooks/useNodesData.d.ts +7 -5
  86. package/dist/umd/hooks/useNodesData.d.ts.map +1 -1
  87. package/dist/umd/hooks/useNodesEdgesState.d.ts +32 -6
  88. package/dist/umd/hooks/useNodesEdgesState.d.ts.map +1 -1
  89. package/dist/umd/hooks/useNodesInitialized.d.ts +3 -2
  90. package/dist/umd/hooks/useNodesInitialized.d.ts.map +1 -1
  91. package/dist/umd/hooks/useOnSelectionChange.d.ts +1 -2
  92. package/dist/umd/hooks/useOnSelectionChange.d.ts.map +1 -1
  93. package/dist/umd/hooks/useOnViewportChange.d.ts +5 -6
  94. package/dist/umd/hooks/useOnViewportChange.d.ts.map +1 -1
  95. package/dist/umd/hooks/useReactFlow.d.ts +0 -2
  96. package/dist/umd/hooks/useReactFlow.d.ts.map +1 -1
  97. package/dist/umd/hooks/useStore.d.ts +8 -5
  98. package/dist/umd/hooks/useStore.d.ts.map +1 -1
  99. package/dist/umd/hooks/useUpdateNodeInternals.d.ts +5 -4
  100. package/dist/umd/hooks/useUpdateNodeInternals.d.ts.map +1 -1
  101. package/dist/umd/hooks/useViewport.d.ts +3 -3
  102. package/dist/umd/index.js +2 -2
  103. package/dist/umd/types/component-props.d.ts +234 -116
  104. package/dist/umd/types/component-props.d.ts.map +1 -1
  105. package/dist/umd/types/edges.d.ts +26 -8
  106. package/dist/umd/types/edges.d.ts.map +1 -1
  107. package/dist/umd/types/general.d.ts +11 -6
  108. package/dist/umd/types/general.d.ts.map +1 -1
  109. package/dist/umd/types/instance.d.ts +23 -8
  110. package/dist/umd/types/instance.d.ts.map +1 -1
  111. package/dist/umd/utils/changes.d.ts +6 -6
  112. package/dist/umd/utils/general.d.ts +11 -7
  113. package/dist/umd/utils/general.d.ts.map +1 -1
  114. package/package.json +4 -4
@@ -8,6 +8,7 @@ import type { OnSelectionChangeFunc, NodeTypes, EdgeTypes, Node, Edge, Connectio
8
8
  export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends Edge = Edge> extends Omit<HTMLAttributes<HTMLDivElement>, 'onError'> {
9
9
  /**
10
10
  * An array of nodes to render in a controlled flow.
11
+ * @default []
11
12
  * @example
12
13
  * const nodes = [
13
14
  * {
@@ -21,6 +22,7 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
21
22
  nodes?: NodeType[];
22
23
  /**
23
24
  * An array of edges to render in a controlled flow.
25
+ * @default []
24
26
  * @example
25
27
  * const edges = [
26
28
  * {
@@ -56,51 +58,66 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
56
58
  * }
57
59
  */
58
60
  defaultEdgeOptions?: DefaultEdgeOptions;
59
- /** This event handler is called when a user clicks on a node */
61
+ /** This event handler is called when a user clicks on a node. */
60
62
  onNodeClick?: NodeMouseHandler<NodeType>;
61
- /** This event handler is called when a user double clicks on a node */
63
+ /** This event handler is called when a user double-clicks on a node. */
62
64
  onNodeDoubleClick?: NodeMouseHandler<NodeType>;
63
- /** This event handler is called when mouse of a user enters a node */
65
+ /** This event handler is called when mouse of a user enters a node. */
64
66
  onNodeMouseEnter?: NodeMouseHandler<NodeType>;
65
- /** This event handler is called when mouse of a user moves over a node */
67
+ /** This event handler is called when mouse of a user moves over a node. */
66
68
  onNodeMouseMove?: NodeMouseHandler<NodeType>;
67
- /** This event handler is called when mouse of a user leaves a node */
69
+ /** This event handler is called when mouse of a user leaves a node. */
68
70
  onNodeMouseLeave?: NodeMouseHandler<NodeType>;
69
- /** This event handler is called when a user right clicks on a node */
71
+ /** This event handler is called when a user right-clicks on a node. */
70
72
  onNodeContextMenu?: NodeMouseHandler<NodeType>;
71
- /** This event handler is called when a user starts to drag a node */
73
+ /** This event handler is called when a user starts to drag a node. */
72
74
  onNodeDragStart?: OnNodeDrag<NodeType>;
73
- /** This event handler is called when a user drags a node */
75
+ /** This event handler is called when a user drags a node. */
74
76
  onNodeDrag?: OnNodeDrag<NodeType>;
75
- /** This event handler is called when a user stops dragging a node */
77
+ /** This event handler is called when a user stops dragging a node. */
76
78
  onNodeDragStop?: OnNodeDrag<NodeType>;
77
- /** This event handler is called when a user clicks on an edge */
79
+ /** This event handler is called when a user clicks on an edge. */
78
80
  onEdgeClick?: (event: ReactMouseEvent, edge: EdgeType) => void;
79
- /** This event handler is called when a user right clicks on an edge */
81
+ /** This event handler is called when a user right-clicks on an edge. */
80
82
  onEdgeContextMenu?: EdgeMouseHandler<EdgeType>;
81
- /** This event handler is called when mouse of a user enters an edge */
83
+ /** This event handler is called when mouse of a user enters an edge. */
82
84
  onEdgeMouseEnter?: EdgeMouseHandler<EdgeType>;
83
- /** This event handler is called when mouse of a user moves over an edge */
85
+ /** This event handler is called when mouse of a user moves over an edge. */
84
86
  onEdgeMouseMove?: EdgeMouseHandler<EdgeType>;
85
- /** This event handler is called when mouse of a user leaves an edge */
87
+ /** This event handler is called when mouse of a user leaves an edge. */
86
88
  onEdgeMouseLeave?: EdgeMouseHandler<EdgeType>;
87
- /** This event handler is called when a user double clicks on an edge */
89
+ /** This event handler is called when a user double-clicks on an edge. */
88
90
  onEdgeDoubleClick?: EdgeMouseHandler<EdgeType>;
91
+ /**
92
+ * This handler is called when the source or target of a reconnectable edge is dragged from the
93
+ * current node. It will fire even if the edge's source or target do not end up changing.
94
+ *
95
+ * You can use the `reconnectEdge` utility to convert the connection to a new edge.
96
+ */
89
97
  onReconnect?: OnReconnect<EdgeType>;
98
+ /**
99
+ * This event fires when the user begins dragging the source or target of an editable edge.
100
+ */
90
101
  onReconnectStart?: (event: ReactMouseEvent, edge: EdgeType, handleType: HandleType) => void;
102
+ /**
103
+ * This event fires when the user releases the source or target of an editable edge. It is called
104
+ * even if an edge update does not occur.
105
+ *
106
+ */
91
107
  onReconnectEnd?: (event: MouseEvent | TouchEvent, edge: EdgeType, handleType: HandleType) => void;
92
108
  /**
93
- * This event handler is called when a Node is updated
109
+ * Use this event handler to add interactivity to a controlled flow.
110
+ * It is called on node drag, select, and move.
94
111
  * @example // Use NodesState hook to create edges and get onNodesChange handler
95
112
  * import ReactFlow, { useNodesState } from '@xyflow/react';
96
- * const [edges, setNodes, onNodesChange] = useNodesState(initialNodes);
113
+ * const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
97
114
  *
98
115
  * return (<ReactFlow onNodeChange={onNodeChange} {...rest} />)
99
- * @example // Use helper function to update edge
116
+ * @example // Use helper function to update node
100
117
  * import ReactFlow, { applyNodeChanges } from '@xyflow/react';
101
118
  *
102
119
  * const onNodeChange = useCallback(
103
- * (changes) => setNode((eds) => applyNodeChanges(changes, eds)),
120
+ * (changes) => setNode((nds) => applyNodeChanges(changes, nds)),
104
121
  * [],
105
122
  * );
106
123
  *
@@ -108,7 +125,8 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
108
125
  */
109
126
  onNodesChange?: OnNodesChange<NodeType>;
110
127
  /**
111
- * This event handler is called when a Edge is updated
128
+ * Use this event handler to add interactivity to a controlled flow. It is called on edge select
129
+ * and remove.
112
130
  * @example // Use EdgesState hook to create edges and get onEdgesChange handler
113
131
  * import ReactFlow, { useEdgesState } from '@xyflow/react';
114
132
  * const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
@@ -125,25 +143,28 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
125
143
  * return (<ReactFlow onEdgesChange={onEdgesChange} {...rest} />)
126
144
  */
127
145
  onEdgesChange?: OnEdgesChange<EdgeType>;
128
- /** This event handler gets called when a Node is deleted */
146
+ /** This event handler gets called when a node is deleted. */
129
147
  onNodesDelete?: OnNodesDelete<NodeType>;
130
- /** This event handler gets called when a Edge is deleted */
148
+ /** This event handler gets called when an edge is deleted. */
131
149
  onEdgesDelete?: OnEdgesDelete<EdgeType>;
132
- /** This event handler gets called when a Node or Edge is deleted */
150
+ /** This event handler gets called when a node or edge is deleted. */
133
151
  onDelete?: OnDelete<NodeType, EdgeType>;
134
- /** This event handler gets called when a user starts to drag a selection box */
152
+ /** This event handler gets called when a user starts to drag a selection box. */
135
153
  onSelectionDragStart?: SelectionDragHandler<NodeType>;
136
- /** This event handler gets called when a user drags a selection box */
154
+ /** This event handler gets called when a user drags a selection box. */
137
155
  onSelectionDrag?: SelectionDragHandler<NodeType>;
138
- /** This event handler gets called when a user stops dragging a selection box */
156
+ /** This event handler gets called when a user stops dragging a selection box. */
139
157
  onSelectionDragStop?: SelectionDragHandler<NodeType>;
140
158
  onSelectionStart?: (event: ReactMouseEvent) => void;
141
159
  onSelectionEnd?: (event: ReactMouseEvent) => void;
160
+ /**
161
+ * This event handler is called when a user right-clicks on a node selection.
162
+ */
142
163
  onSelectionContextMenu?: (event: ReactMouseEvent, nodes: NodeType[]) => void;
143
164
  /**
144
165
  * When a connection line is completed and two nodes are connected by the user, this event fires with the new connection.
145
166
  *
146
- * You can use the addEdge utility to convert the connection to a complete edge.
167
+ * You can use the `addEdge` utility to convert the connection to a complete edge.
147
168
  * @example // Use helper function to update edges onConnect
148
169
  * import ReactFlow, { addEdge } from '@xyflow/react';
149
170
  *
@@ -155,50 +176,70 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
155
176
  * return (<ReactFlow onConnect={onConnect} {...rest} />)
156
177
  */
157
178
  onConnect?: OnConnect;
158
- /** This event handler gets called when a user starts to drag a connection line */
179
+ /** This event handler gets called when a user starts to drag a connection line. */
159
180
  onConnectStart?: OnConnectStart;
160
- /** This event handler gets called when a user stops dragging a connection line */
181
+ /**
182
+ * This callback will fire regardless of whether a valid connection could be made or not. You can
183
+ * use the second `connectionState` parameter to have different behavior when a connection was
184
+ * unsuccessful.
185
+ */
161
186
  onConnectEnd?: OnConnectEnd;
162
187
  onClickConnectStart?: OnConnectStart;
163
188
  onClickConnectEnd?: OnConnectEnd;
164
- /** This event handler gets called when a flow has finished initializing */
189
+ /**
190
+ * The `onInit` callback is called when the viewport is initialized. At this point you can use the
191
+ * instance to call methods like `fitView` or `zoomTo`.
192
+ */
165
193
  onInit?: OnInit<NodeType, EdgeType>;
166
194
  /** This event handler is called while the user is either panning or zooming the viewport. */
167
195
  onMove?: OnMove;
168
- /** This event handler gets called when a user starts to pan or zoom the viewport */
196
+ /** This event handler is called when the user begins to pan or zoom the viewport. */
169
197
  onMoveStart?: OnMoveStart;
170
- /** This event handler gets called when a user stops panning or zooming the viewport */
198
+ /**
199
+ * This event handler is called when panning or zooming viewport movement stops.
200
+ * If the movement is not user-initiated, the event parameter will be `null`.
201
+ */
171
202
  onMoveEnd?: OnMoveEnd;
172
- /** This event handler gets called when a user changes group of selected elements in the flow */
203
+ /** This event handler gets called when a user changes group of selected elements in the flow. */
173
204
  onSelectionChange?: OnSelectionChangeFunc<NodeType, EdgeType>;
174
- /** This event handler gets called when user scroll inside the pane */
205
+ /** This event handler gets called when user scroll inside the pane. */
175
206
  onPaneScroll?: (event?: WheelEvent) => void;
176
- /** This event handler gets called when user clicks inside the pane */
207
+ /** This event handler gets called when user clicks inside the pane. */
177
208
  onPaneClick?: (event: ReactMouseEvent) => void;
178
- /** This event handler gets called when user right clicks inside the pane */
209
+ /** This event handler gets called when user right clicks inside the pane. */
179
210
  onPaneContextMenu?: (event: ReactMouseEvent | MouseEvent) => void;
180
- /** This event handler gets called when mouse enters the pane */
211
+ /** This event handler gets called when mouse enters the pane. */
181
212
  onPaneMouseEnter?: (event: ReactMouseEvent) => void;
182
- /** This event handler gets called when mouse moves over the pane */
213
+ /** This event handler gets called when mouse moves over the pane. */
183
214
  onPaneMouseMove?: (event: ReactMouseEvent) => void;
184
- /** This event handler gets called when mouse leaves the pane */
215
+ /** This event handler gets called when mouse leaves the pane. */
185
216
  onPaneMouseLeave?: (event: ReactMouseEvent) => void;
186
217
  /**
187
- * Distance that the mouse can move between mousedown/up that will trigger a click
218
+ * Distance that the mouse can move between mousedown/up that will trigger a click.
188
219
  * @default 0
189
220
  */
190
221
  paneClickDistance?: number;
191
222
  /**
192
- * Distance that the mouse can move between mousedown/up that will trigger a click
223
+ * Distance that the mouse can move between mousedown/up that will trigger a click.
193
224
  * @default 0
194
225
  */
195
226
  nodeClickDistance?: number;
196
- /** This handler gets called before the user deletes nodes or edges and provides a way to abort the deletion by returning false. */
227
+ /**
228
+ * This handler is called before nodes or edges are deleted, allowing the deletion to be aborted
229
+ * by returning `false` or modified by returning updated nodes and edges.
230
+ */
197
231
  onBeforeDelete?: OnBeforeDelete<NodeType, EdgeType>;
198
232
  /**
199
233
  * Custom node types to be available in a flow.
200
234
  *
201
- * React Flow matches a node's type to a component in the nodeTypes object.
235
+ * React Flow matches a node's type to a component in the `nodeTypes` object.
236
+ * @TODO check if @default is correct
237
+ * @default {
238
+ * input: InputNode,
239
+ * default: DefaultNode,
240
+ * output: OutputNode,
241
+ * group: GroupNode
242
+ * }
202
243
  * @example
203
244
  * import CustomNode from './CustomNode';
204
245
  *
@@ -208,7 +249,15 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
208
249
  /**
209
250
  * Custom edge types to be available in a flow.
210
251
  *
211
- * React Flow matches an edge's type to a component in the edgeTypes object.
252
+ * React Flow matches an edge's type to a component in the `edgeTypes` object.
253
+ * @TODO check if @default is correct
254
+ * @default {
255
+ * default: BezierEdge,
256
+ * straight: StraightEdge,
257
+ * step: StepEdge,
258
+ * smoothstep: SmoothStepEdge,
259
+ * simplebezier: SimpleBezier
260
+ * }
212
261
  * @example
213
262
  * import CustomEdge from './CustomEdge';
214
263
  *
@@ -219,91 +268,110 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
219
268
  * The type of edge path to use for connection lines.
220
269
  *
221
270
  * Although created edges can be of any type, React Flow needs to know what type of path to render for the connection line before the edge is created!
271
+ * @default ConnectionLineType.Bezier
222
272
  */
223
273
  connectionLineType?: ConnectionLineType;
224
- /** Styles to be applied to the connection line */
274
+ /** Styles to be applied to the connection line. */
225
275
  connectionLineStyle?: CSSProperties;
226
- /** React Component to be used as a connection line */
276
+ /** React Component to be used as a connection line. */
227
277
  connectionLineComponent?: ConnectionLineComponent<NodeType>;
228
- /** Styles to be applied to the container of the connection line */
278
+ /** Styles to be applied to the container of the connection line. */
229
279
  connectionLineContainerStyle?: CSSProperties;
230
280
  /**
231
- * 'strict' connection mode will only allow you to connect source handles to target handles.
232
- *
233
- * 'loose' connection mode will allow you to connect handles of any type to one another.
281
+ * A loose connection mode will allow you to connect handles with differing types, including
282
+ * source-to-source connections. However, it does not support target-to-target connections. Strict
283
+ * mode allows only connections between source handles and target handles.
234
284
  * @default 'strict'
235
285
  */
236
286
  connectionMode?: ConnectionMode;
237
287
  /**
238
- * Pressing down this key deletes all selected nodes & edges.
288
+ * If set, pressing the key or chord will delete any selected nodes and edges. Passing an array
289
+ * represents multiple keys that can be pressed.
290
+ *
291
+ * For example, `["Delete", "Backspace"]` will delete selected elements when either key is pressed.
239
292
  * @default 'Backspace'
240
293
  */
241
294
  deleteKeyCode?: KeyCode | null;
242
295
  /**
243
- * If a key is set, you can pan the viewport while that key is held down even if panOnScroll is set to false.
296
+ * If set, holding this key will let you click and drag to draw a selection box around multiple
297
+ * nodes and edges. Passing an array represents multiple keys that can be pressed.
244
298
  *
245
- * By setting this prop to null you can disable this functionality.
246
- * @default 'Space'
299
+ * For example, `["Shift", "Meta"]` will allow you to draw a selection box when either key is
300
+ * pressed.
301
+ * @default 'Shift'
247
302
  */
248
303
  selectionKeyCode?: KeyCode | null;
249
- /** Select multiple elements with a selection box, without pressing down selectionKey */
304
+ /**
305
+ * Select multiple elements with a selection box, without pressing down `selectionKey`.
306
+ * @default false
307
+ */
250
308
  selectionOnDrag?: boolean;
251
309
  /**
252
- * When set to "partial", when the user creates a selection box by click and dragging nodes that are only partially in the box are still selected.
310
+ * When set to `"partial"`, when the user creates a selection box by click and dragging nodes that
311
+ * are only partially in the box are still selected.
253
312
  * @default 'full'
254
313
  */
255
314
  selectionMode?: SelectionMode;
256
315
  /**
257
- * If a key is set, you can pan the viewport while that key is held down even if panOnScroll is set to false.
316
+ * If a key is set, you can pan the viewport while that key is held down even if `panOnScroll`
317
+ * is set to `false`.
258
318
  *
259
- * By setting this prop to null you can disable this functionality.
319
+ * By setting this prop to `null` you can disable this functionality.
260
320
  * @default 'Space'
261
321
  */
262
322
  panActivationKeyCode?: KeyCode | null;
263
323
  /**
264
324
  * Pressing down this key you can select multiple elements by clicking.
265
- * @default 'Meta' for macOS, "Ctrl" for other systems
325
+ * @default "Meta" for macOS, "Control" for other systems
266
326
  */
267
327
  multiSelectionKeyCode?: KeyCode | null;
268
328
  /**
269
- * If a key is set, you can zoom the viewport while that key is held down even if panOnScroll is set to false.
329
+ * If a key is set, you can zoom the viewport while that key is held down even if `panOnScroll`
330
+ * is set to `false`.
270
331
  *
271
- * By setting this prop to null you can disable this functionality.
272
- * @default 'Meta' for macOS, "Ctrl" for other systems
332
+ * By setting this prop to `null` you can disable this functionality.
333
+ * @default "Meta" for macOS, "Control" for other systems
273
334
  *
274
335
  */
275
336
  zoomActivationKeyCode?: KeyCode | null;
276
- /** Set this prop to make the flow snap to the grid */
337
+ /** When enabled, nodes will snap to the grid when dragged. */
277
338
  snapToGrid?: boolean;
278
339
  /**
279
- * Grid all nodes will snap to
340
+ * If `snapToGrid` is enabled, this prop configures the grid that nodes will snap to.
280
341
  * @example [20, 20]
281
342
  */
282
343
  snapGrid?: SnapGrid;
283
344
  /**
284
- * You can enable this optimisation to instruct Svelte Flow to only render nodes and edges that would be visible in the viewport.
345
+ * You can enable this optimisation to instruct React Flow to only render nodes and edges that would be visible in the viewport.
285
346
  *
286
347
  * This might improve performance when you have a large number of nodes and edges but also adds an overhead.
287
348
  * @default false
288
349
  */
289
350
  onlyRenderVisibleElements?: boolean;
290
351
  /**
291
- * Controls if all nodes should be draggable
352
+ * Controls whether all nodes should be draggable or not. Individual nodes can override this
353
+ * setting by setting their `draggable` prop. If you want to use the mouse handlers on
354
+ * non-draggable nodes, you need to add the `"nopan"` class to those nodes.
292
355
  * @default true
293
356
  */
294
357
  nodesDraggable?: boolean;
295
358
  /**
296
- * Controls if all nodes should be connectable to each other
359
+ * Controls whether all nodes should be connectable or not. Individual nodes can override this
360
+ * setting by setting their `connectable` prop.
297
361
  * @default true
298
362
  */
299
363
  nodesConnectable?: boolean;
300
364
  /**
301
- * Controls if all nodes should be focusable
365
+ * When `true`, focus between nodes can be cycled with the `Tab` key and selected with the `Enter`
366
+ * key. This option can be overridden by individual nodes by setting their `focusable` prop.
302
367
  * @default true
303
368
  */
304
369
  nodesFocusable?: boolean;
305
370
  /**
306
- * Defines nodes relative position to its coordinates
371
+ * The origin of the node to use when placing it in the flow or looking up its `x` and `y`
372
+ * position. An origin of `[0, 0]` means that a node's top left corner will be placed at the `x`
373
+ * and `y` position.
374
+ * @default [0, 0]
307
375
  * @example
308
376
  * [0, 0] // default, top left
309
377
  * [0.5, 0.5] // center
@@ -311,49 +379,57 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
311
379
  */
312
380
  nodeOrigin?: NodeOrigin;
313
381
  /**
314
- * Controls if all edges should be focusable
382
+ * When `true`, focus between edges can be cycled with the `Tab` key and selected with the `Enter`
383
+ * key. This option can be overridden by individual edges by setting their `focusable` prop.
315
384
  * @default true
316
385
  */
317
386
  edgesFocusable?: boolean;
318
387
  /**
319
- * Controls if all edges should be updateable
388
+ * Whether edges can be updated once they are created. When both this prop is `true` and an
389
+ * `onReconnect` handler is provided, the user can drag an existing edge to a new source or
390
+ * target. Individual edges can override this value with their reconnectable property.
320
391
  * @default true
321
392
  */
322
393
  edgesReconnectable?: boolean;
323
394
  /**
324
- * Controls if all elements should (nodes & edges) be selectable
395
+ * When `true`, elements (nodes and edges) can be selected by clicking on them. This option can be
396
+ * overridden by individual elements by setting their `selectable` prop.
325
397
  * @default true
326
398
  */
327
399
  elementsSelectable?: boolean;
328
400
  /**
329
- * If true, nodes get selected on drag
401
+ * If `true`, nodes get selected on drag.
330
402
  * @default true
331
403
  */
332
404
  selectNodesOnDrag?: boolean;
333
405
  /**
334
- * Enableing this prop allows users to pan the viewport by clicking and dragging.
406
+ * Enabling this prop allows users to pan the viewport by clicking and dragging.
335
407
  *
336
408
  * You can also set this prop to an array of numbers to limit which mouse buttons can activate panning.
409
+ * @default true
337
410
  * @example [0, 2] // allows panning with the left and right mouse buttons
338
411
  * [0, 1, 2, 3, 4] // allows panning with all mouse buttons
339
412
  */
340
413
  panOnDrag?: boolean | number[];
341
414
  /**
342
- * Minimum zoom level
415
+ * Minimum zoom level.
343
416
  * @default 0.5
344
417
  */
345
418
  minZoom?: number;
346
419
  /**
347
- * Maximum zoom level
420
+ * Maximum zoom level.
348
421
  * @default 2
349
422
  */
350
423
  maxZoom?: number;
351
- /** Controlled viewport to be used instead of internal one */
424
+ /**
425
+ * When you pass a `viewport` prop, it's controlled, and you also need to pass `onViewportChange`
426
+ * to handle internal changes.
427
+ */
352
428
  viewport?: Viewport;
353
429
  /**
354
- * Sets the initial position and zoom of the viewport.
355
- *
356
- * If a default viewport is provided but fitView is enabled, the default viewport will be ignored.
430
+ * Sets the initial position and zoom of the viewport. If a default viewport is provided but
431
+ * `fitView` is enabled, the default viewport will be ignored.
432
+ * @default { x: 0, y: 0, zoom: 1 }
357
433
  * @example
358
434
  * const initialViewport = {
359
435
  * zoom: 0.5,
@@ -362,13 +438,14 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
362
438
  */
363
439
  defaultViewport?: Viewport;
364
440
  /**
365
- * Gets called when the viewport changes.
441
+ * Used when working with a controlled viewport for updating the user viewport state.
366
442
  */
367
443
  onViewportChange?: (viewport: Viewport) => void;
368
444
  /**
369
- * By default the viewport extends infinitely. You can use this prop to set a boundary.
445
+ * By default, the viewport extends infinitely. You can use this prop to set a boundary.
370
446
  *
371
447
  * The first pair of coordinates is the top left boundary and the second pair is the bottom right.
448
+ * @default [[-∞, -∞], [+∞, +∞]]
372
449
  * @example [[-1000, -10000], [1000, 1000]]
373
450
  */
374
451
  translateExtent?: CoordinateExtent;
@@ -378,51 +455,86 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
378
455
  */
379
456
  preventScrolling?: boolean;
380
457
  /**
381
- * By default nodes can be placed on an infinite flow. You can use this prop to set a boundary.
458
+ * By default, nodes can be placed on an infinite flow. You can use this prop to set a boundary.
382
459
  *
383
460
  * The first pair of coordinates is the top left boundary and the second pair is the bottom right.
384
461
  * @example [[-1000, -10000], [1000, 1000]]
385
462
  */
386
463
  nodeExtent?: CoordinateExtent;
387
464
  /**
388
- * Color of edge markers
389
- * @example "#b1b1b7"
465
+ * Color of edge markers.
466
+ * @default '#b1b1b7'
390
467
  */
391
468
  defaultMarkerColor?: string;
392
- /** Controls if the viewport should zoom by scrolling inside the container */
469
+ /**
470
+ * Controls if the viewport should zoom by scrolling inside the container.
471
+ * @default true
472
+ */
393
473
  zoomOnScroll?: boolean;
394
- /** Controls if the viewport should zoom by pinching on a touch screen */
474
+ /**
475
+ * Controls if the viewport should zoom by pinching on a touch screen.
476
+ * @default true
477
+ */
395
478
  zoomOnPinch?: boolean;
396
479
  /**
397
- * Controls if the viewport should pan by scrolling inside the container
480
+ * Controls if the viewport should pan by scrolling inside the container.
398
481
  *
399
- * Can be limited to a specific direction with panOnScrollMode
482
+ * Can be limited to a specific direction with `panOnScrollMode`.
483
+ * @default false
400
484
  */
401
485
  panOnScroll?: boolean;
402
486
  /**
403
487
  * Controls how fast viewport should be panned on scroll.
404
488
  *
405
- * Use togther with panOnScroll prop.
489
+ * Use together with `panOnScroll` prop.
490
+ * @default 0.5
406
491
  */
407
492
  panOnScrollSpeed?: number;
408
493
  /**
409
- * This prop is used to limit the direction of panning when panOnScroll is enabled.
494
+ * This prop is used to limit the direction of panning when `panOnScroll` is enabled.
410
495
  *
411
- * The "free" option allows panning in any direction.
496
+ * The `"free"` option allows panning in any direction.
412
497
  * @default "free"
413
498
  * @example "horizontal" | "vertical"
414
499
  */
415
500
  panOnScrollMode?: PanOnScrollMode;
416
- /** Controls if the viewport should zoom by double clicking somewhere on the flow */
501
+ /**
502
+ * Controls if the viewport should zoom by double-clicking somewhere on the flow.
503
+ * @default true
504
+ */
417
505
  zoomOnDoubleClick?: boolean;
506
+ /**
507
+ * The radius around an edge connection that can trigger an edge reconnection.
508
+ * @default 10
509
+ */
418
510
  reconnectRadius?: number;
511
+ /**
512
+ * If a node is draggable, clicking and dragging that node will move it around the canvas. Adding
513
+ * the `"nodrag"` class prevents this behavior and this prop allows you to change the name of that
514
+ * class.
515
+ * @default "nodrag"
516
+ */
419
517
  noDragClassName?: string;
518
+ /**
519
+ * Typically, scrolling the mouse wheel when the mouse is over the canvas will zoom the viewport.
520
+ * Adding the `"nowheel"` class to an element n the canvas will prevent this behavior and this prop
521
+ * allows you to change the name of that class.
522
+ * @default "nowheel"
523
+ */
420
524
  noWheelClassName?: string;
525
+ /**
526
+ * If an element in the canvas does not stop mouse events from propagating, clicking and dragging
527
+ * that element will pan the viewport. Adding the `"nopan"` class prevents this behavior and this
528
+ * prop allows you to change the name of that class.
529
+ * @default "nopan"
530
+ */
421
531
  noPanClassName?: string;
422
- /** If set, initial viewport will show all nodes & edges */
532
+ /** When `true`, the flow will be zoomed and panned to fit all the nodes initially provided. */
423
533
  fitView?: boolean;
424
534
  /**
425
- * Options to be used in combination with fitView
535
+ * When you typically call `fitView` on a `ReactFlowInstance`, you can provide an object of
536
+ * options to customize its behavior. This prop lets you do the same for the initial `fitView`
537
+ * call.
426
538
  * @example
427
539
  * const fitViewOptions = {
428
540
  * padding: 0.1,
@@ -435,15 +547,18 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
435
547
  */
436
548
  fitViewOptions?: FitViewOptions;
437
549
  /**
438
- *The connectOnClick option lets you click or tap on a source handle to start a connection
550
+ * The `connectOnClick` option lets you click or tap on a source handle to start a connection
439
551
  * and then click on a target handle to complete the connection.
440
552
  *
441
- * If you set this option to false, users will need to drag the connection line to the target
553
+ * If you set this option to `false`, users will need to drag the connection line to the target
442
554
  * handle to create a connection.
555
+ * @default true
443
556
  */
444
557
  connectOnClick?: boolean;
445
558
  /**
446
- * Set position of the attribution
559
+ * By default, React Flow will render a small attribution in the bottom right corner of the flow.
560
+ *
561
+ * You can use this prop to change its position in case you want to place something else there.
447
562
  * @default 'bottom-right'
448
563
  * @example 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'
449
564
  */
@@ -463,21 +578,23 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
463
578
  elevateNodesOnSelect?: boolean;
464
579
  /**
465
580
  * Enabling this option will raise the z-index of edges when they are selected.
466
- * @default true
467
581
  */
468
582
  elevateEdgesOnSelect?: boolean;
469
583
  /**
470
- * Can be set true if built-in keyboard controls should be disabled.
584
+ * You can use this prop to disable keyboard accessibility features such as selecting nodes or
585
+ * moving selected nodes with the arrow keys.
471
586
  * @default false
472
587
  */
473
588
  disableKeyboardA11y?: boolean;
474
589
  /**
475
- * You can enable this prop to automatically pan the viewport while dragging a node.
590
+ * When `true`, the viewport will pan automatically when the cursor moves to the edge of the
591
+ * viewport while dragging a node.
476
592
  * @default true
477
593
  */
478
594
  autoPanOnNodeDrag?: boolean;
479
595
  /**
480
- * You can enable this prop to automatically pan the viewport while dragging a node.
596
+ * When `true`, the viewport will pan automatically when the cursor moves to the edge of the
597
+ * viewport while creating a connection.
481
598
  * @default true
482
599
  */
483
600
  autoPanOnConnect?: boolean;
@@ -487,12 +604,12 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
487
604
  */
488
605
  autoPanSpeed?: number;
489
606
  /**
490
- * You can enable this prop to automatically pan the viewport while making a new connection.
491
- * @default true
607
+ * The radius around a handle where you drop a connection line to create a new edge.
608
+ * @default 20
492
609
  */
493
610
  connectionRadius?: number;
494
611
  /**
495
- * Ocassionally something may happen that causes Svelte Flow to throw an error.
612
+ * Occasionally something may happen that causes React Flow to throw an error.
496
613
  *
497
614
  * Instead of exploding your application, we log a message to the console and then call this event handler.
498
615
  * You might use it for additional logging or to show a message to the user.
@@ -501,32 +618,33 @@ export interface ReactFlowProps<NodeType extends Node = Node, EdgeType extends E
501
618
  /**
502
619
  * This callback can be used to validate a new connection
503
620
  *
504
- * If you return false, the edge will not be added to your flow.
505
- * If you have custom connection logic its preferred to use this callback over the isValidConnection prop on the handle component for performance reasons.
506
- * @default (connection: Connection) => true
621
+ * If you return `false`, the edge will not be added to your flow.
622
+ * If you have custom connection logic its preferred to use this callback over the
623
+ * `isValidConnection` prop on the handle component for performance reasons.
507
624
  */
508
625
  isValidConnection?: IsValidConnection<EdgeType>;
509
626
  /**
510
- * With a threshold greater than zero you can control the distinction between node drag and click events.
627
+ * With a threshold greater than zero you can delay node drag events.
511
628
  *
512
629
  * If threshold equals 1, you need to drag the node 1 pixel before a drag event is fired.
630
+ *
631
+ * 1 is the default value, so clicks don't trigger drag events.
513
632
  * @default 1
514
633
  */
515
634
  nodeDragThreshold?: number;
516
- /** Sets a fixed width for the flow */
635
+ /** Sets a fixed width for the flow. */
517
636
  width?: number;
518
- /** Sets a fixed height for the flow */
637
+ /** Sets a fixed height for the flow. */
519
638
  height?: number;
520
639
  /**
521
- * Controls color scheme used for styling the flow
522
- * @default 'system'
640
+ * Controls color scheme used for styling the flow.
641
+ * @default 'light'
523
642
  * @example 'system' | 'light' | 'dark'
524
643
  */
525
644
  colorMode?: ColorMode;
526
645
  /**
527
- * If set true, some debug information will be logged to the console like which events are fired.
528
- *
529
- * @default undefined
646
+ * If set `true`, some debug information will be logged to the console like which events are fired.
647
+ * @default false
530
648
  */
531
649
  debug?: boolean;
532
650
  }