@octanejs/xyflow 0.1.0

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