@xyflow/react 12.4.2 → 12.4.4
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.
- package/dist/esm/additional-components/Background/Background.d.ts +53 -0
- package/dist/esm/additional-components/Background/Background.d.ts.map +1 -1
- package/dist/esm/additional-components/Background/types.d.ts +11 -1
- package/dist/esm/additional-components/Background/types.d.ts.map +1 -1
- package/dist/esm/additional-components/Controls/ControlButton.d.ts +23 -0
- package/dist/esm/additional-components/Controls/ControlButton.d.ts.map +1 -1
- package/dist/esm/additional-components/Controls/Controls.d.ts +21 -0
- package/dist/esm/additional-components/Controls/Controls.d.ts.map +1 -1
- package/dist/esm/additional-components/Controls/types.d.ts +8 -1
- package/dist/esm/additional-components/Controls/types.d.ts.map +1 -1
- package/dist/esm/additional-components/MiniMap/MiniMap.d.ts +20 -0
- package/dist/esm/additional-components/MiniMap/MiniMap.d.ts.map +1 -1
- package/dist/esm/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
- package/dist/esm/additional-components/MiniMap/types.d.ts +11 -1
- package/dist/esm/additional-components/MiniMap/types.d.ts.map +1 -1
- package/dist/esm/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
- package/dist/esm/additional-components/NodeResizer/NodeResizeControl.d.ts.map +1 -1
- package/dist/esm/additional-components/NodeResizer/NodeResizer.d.ts +24 -0
- package/dist/esm/additional-components/NodeResizer/NodeResizer.d.ts.map +1 -1
- package/dist/esm/additional-components/NodeResizer/types.d.ts +15 -3
- package/dist/esm/additional-components/NodeResizer/types.d.ts.map +1 -1
- package/dist/esm/additional-components/NodeToolbar/NodeToolbar.d.ts +35 -0
- package/dist/esm/additional-components/NodeToolbar/NodeToolbar.d.ts.map +1 -1
- package/dist/esm/additional-components/NodeToolbar/types.d.ts +7 -2
- package/dist/esm/additional-components/NodeToolbar/types.d.ts.map +1 -1
- package/dist/esm/components/BatchProvider/index.d.ts.map +1 -1
- package/dist/esm/components/BatchProvider/useQueue.d.ts.map +1 -1
- package/dist/esm/components/ConnectionLine/index.d.ts +4 -4
- package/dist/esm/components/ConnectionLine/index.d.ts.map +1 -1
- package/dist/esm/components/EdgeLabelRenderer/index.d.ts +40 -0
- package/dist/esm/components/EdgeLabelRenderer/index.d.ts.map +1 -1
- package/dist/esm/components/EdgeWrapper/index.d.ts +1 -1
- package/dist/esm/components/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/esm/components/Edges/BaseEdge.d.ts +27 -0
- package/dist/esm/components/Edges/BaseEdge.d.ts.map +1 -1
- package/dist/esm/components/Edges/EdgeText.d.ts +26 -0
- package/dist/esm/components/Edges/EdgeText.d.ts.map +1 -1
- package/dist/esm/components/Edges/SimpleBezierEdge.d.ts +5 -0
- package/dist/esm/components/Edges/SimpleBezierEdge.d.ts.map +1 -1
- package/dist/esm/components/Edges/index.d.ts.map +1 -1
- package/dist/esm/components/Handle/index.d.ts +32 -4
- package/dist/esm/components/Handle/index.d.ts.map +1 -1
- package/dist/esm/components/NodeWrapper/index.d.ts +1 -1
- package/dist/esm/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/esm/components/NodeWrapper/useNodeObserver.d.ts.map +1 -1
- package/dist/esm/components/NodeWrapper/utils.d.ts.map +1 -1
- package/dist/esm/components/Nodes/utils.d.ts.map +1 -1
- package/dist/esm/components/Panel/index.d.ts +32 -4
- package/dist/esm/components/Panel/index.d.ts.map +1 -1
- package/dist/esm/components/ReactFlowProvider/index.d.ts +34 -0
- package/dist/esm/components/ReactFlowProvider/index.d.ts.map +1 -1
- package/dist/esm/components/SelectionListener/index.d.ts +4 -4
- package/dist/esm/components/SelectionListener/index.d.ts.map +1 -1
- package/dist/esm/components/StoreUpdater/index.d.ts.map +1 -1
- package/dist/esm/components/ViewportPortal/index.d.ts +25 -0
- package/dist/esm/components/ViewportPortal/index.d.ts.map +1 -1
- package/dist/esm/container/EdgeRenderer/MarkerDefinitions.d.ts.map +1 -1
- package/dist/esm/container/NodeRenderer/index.d.ts.map +1 -1
- package/dist/esm/container/Pane/index.d.ts.map +1 -1
- package/dist/esm/container/ReactFlow/Wrapper.d.ts.map +1 -1
- package/dist/esm/container/ReactFlow/index.d.ts +21 -1
- package/dist/esm/container/ReactFlow/index.d.ts.map +1 -1
- package/dist/esm/contexts/NodeIdContext.d.ts +28 -0
- package/dist/esm/contexts/NodeIdContext.d.ts.map +1 -1
- package/dist/esm/hooks/useConnection.d.ts +20 -1
- package/dist/esm/hooks/useConnection.d.ts.map +1 -1
- package/dist/esm/hooks/useEdges.d.ts +13 -1
- package/dist/esm/hooks/useEdges.d.ts.map +1 -1
- package/dist/esm/hooks/useInternalNode.d.ts +21 -1
- package/dist/esm/hooks/useInternalNode.d.ts.map +1 -1
- package/dist/esm/hooks/useKeyPress.d.ts +19 -1
- package/dist/esm/hooks/useKeyPress.d.ts.map +1 -1
- package/dist/esm/hooks/useMoveSelectedNodes.d.ts.map +1 -1
- package/dist/esm/hooks/useNodeConnections.d.ts +17 -1
- package/dist/esm/hooks/useNodeConnections.d.ts.map +1 -1
- package/dist/esm/hooks/useNodes.d.ts +14 -1
- package/dist/esm/hooks/useNodes.d.ts.map +1 -1
- package/dist/esm/hooks/useNodesData.d.ts +14 -2
- package/dist/esm/hooks/useNodesData.d.ts.map +1 -1
- package/dist/esm/hooks/useNodesEdgesState.d.ts +62 -2
- package/dist/esm/hooks/useNodesEdgesState.d.ts.map +1 -1
- package/dist/esm/hooks/useNodesInitialized.d.ts +27 -1
- package/dist/esm/hooks/useNodesInitialized.d.ts.map +1 -1
- package/dist/esm/hooks/useOnSelectionChange.d.ts +37 -5
- package/dist/esm/hooks/useOnSelectionChange.d.ts.map +1 -1
- package/dist/esm/hooks/useOnViewportChange.d.ts +19 -1
- package/dist/esm/hooks/useOnViewportChange.d.ts.map +1 -1
- package/dist/esm/hooks/useReactFlow.d.ts +24 -1
- package/dist/esm/hooks/useReactFlow.d.ts.map +1 -1
- package/dist/esm/hooks/useStore.d.ts +23 -2
- package/dist/esm/hooks/useStore.d.ts.map +1 -1
- package/dist/esm/hooks/useUpdateNodeInternals.d.ts +39 -1
- package/dist/esm/hooks/useUpdateNodeInternals.d.ts.map +1 -1
- package/dist/esm/hooks/useViewport.d.ts +24 -1
- package/dist/esm/hooks/useViewport.d.ts.map +1 -1
- package/dist/esm/hooks/useViewportHelper.d.ts.map +1 -1
- package/dist/esm/index.js +1107 -198
- package/dist/esm/index.mjs +1107 -198
- package/dist/esm/store/index.d.ts.map +1 -1
- package/dist/esm/types/component-props.d.ts +112 -57
- package/dist/esm/types/component-props.d.ts.map +1 -1
- package/dist/esm/types/edges.d.ts +27 -2
- package/dist/esm/types/edges.d.ts.map +1 -1
- package/dist/esm/types/general.d.ts +48 -7
- package/dist/esm/types/general.d.ts.map +1 -1
- package/dist/esm/types/instance.d.ts +11 -1
- package/dist/esm/types/instance.d.ts.map +1 -1
- package/dist/esm/types/nodes.d.ts +46 -4
- package/dist/esm/types/nodes.d.ts.map +1 -1
- package/dist/esm/types/store.d.ts +2 -2
- package/dist/esm/types/store.d.ts.map +1 -1
- package/dist/esm/utils/changes.d.ts +45 -23
- package/dist/esm/utils/changes.d.ts.map +1 -1
- package/dist/esm/utils/general.d.ts +27 -3
- package/dist/esm/utils/general.d.ts.map +1 -1
- package/dist/umd/additional-components/Background/Background.d.ts +53 -0
- package/dist/umd/additional-components/Background/Background.d.ts.map +1 -1
- package/dist/umd/additional-components/Background/types.d.ts +11 -1
- package/dist/umd/additional-components/Background/types.d.ts.map +1 -1
- package/dist/umd/additional-components/Controls/ControlButton.d.ts +23 -0
- package/dist/umd/additional-components/Controls/ControlButton.d.ts.map +1 -1
- package/dist/umd/additional-components/Controls/Controls.d.ts +21 -0
- package/dist/umd/additional-components/Controls/Controls.d.ts.map +1 -1
- package/dist/umd/additional-components/Controls/types.d.ts +8 -1
- package/dist/umd/additional-components/Controls/types.d.ts.map +1 -1
- package/dist/umd/additional-components/MiniMap/MiniMap.d.ts +20 -0
- package/dist/umd/additional-components/MiniMap/MiniMap.d.ts.map +1 -1
- package/dist/umd/additional-components/MiniMap/MiniMapNodes.d.ts.map +1 -1
- package/dist/umd/additional-components/MiniMap/types.d.ts +11 -1
- package/dist/umd/additional-components/MiniMap/types.d.ts.map +1 -1
- package/dist/umd/additional-components/NodeResizer/NodeResizeControl.d.ts +5 -0
- package/dist/umd/additional-components/NodeResizer/NodeResizeControl.d.ts.map +1 -1
- package/dist/umd/additional-components/NodeResizer/NodeResizer.d.ts +24 -0
- package/dist/umd/additional-components/NodeResizer/NodeResizer.d.ts.map +1 -1
- package/dist/umd/additional-components/NodeResizer/types.d.ts +15 -3
- package/dist/umd/additional-components/NodeResizer/types.d.ts.map +1 -1
- package/dist/umd/additional-components/NodeToolbar/NodeToolbar.d.ts +35 -0
- package/dist/umd/additional-components/NodeToolbar/NodeToolbar.d.ts.map +1 -1
- package/dist/umd/additional-components/NodeToolbar/types.d.ts +7 -2
- package/dist/umd/additional-components/NodeToolbar/types.d.ts.map +1 -1
- package/dist/umd/components/BatchProvider/index.d.ts.map +1 -1
- package/dist/umd/components/BatchProvider/useQueue.d.ts.map +1 -1
- package/dist/umd/components/ConnectionLine/index.d.ts +4 -4
- package/dist/umd/components/ConnectionLine/index.d.ts.map +1 -1
- package/dist/umd/components/EdgeLabelRenderer/index.d.ts +40 -0
- package/dist/umd/components/EdgeLabelRenderer/index.d.ts.map +1 -1
- package/dist/umd/components/EdgeWrapper/index.d.ts +1 -1
- package/dist/umd/components/EdgeWrapper/index.d.ts.map +1 -1
- package/dist/umd/components/Edges/BaseEdge.d.ts +27 -0
- package/dist/umd/components/Edges/BaseEdge.d.ts.map +1 -1
- package/dist/umd/components/Edges/EdgeText.d.ts +26 -0
- package/dist/umd/components/Edges/EdgeText.d.ts.map +1 -1
- package/dist/umd/components/Edges/SimpleBezierEdge.d.ts +5 -0
- package/dist/umd/components/Edges/SimpleBezierEdge.d.ts.map +1 -1
- package/dist/umd/components/Edges/index.d.ts.map +1 -1
- package/dist/umd/components/Handle/index.d.ts +32 -4
- package/dist/umd/components/Handle/index.d.ts.map +1 -1
- package/dist/umd/components/NodeWrapper/index.d.ts +1 -1
- package/dist/umd/components/NodeWrapper/index.d.ts.map +1 -1
- package/dist/umd/components/NodeWrapper/useNodeObserver.d.ts.map +1 -1
- package/dist/umd/components/NodeWrapper/utils.d.ts.map +1 -1
- package/dist/umd/components/Nodes/utils.d.ts.map +1 -1
- package/dist/umd/components/Panel/index.d.ts +32 -4
- package/dist/umd/components/Panel/index.d.ts.map +1 -1
- package/dist/umd/components/ReactFlowProvider/index.d.ts +34 -0
- package/dist/umd/components/ReactFlowProvider/index.d.ts.map +1 -1
- package/dist/umd/components/SelectionListener/index.d.ts +4 -4
- package/dist/umd/components/SelectionListener/index.d.ts.map +1 -1
- package/dist/umd/components/StoreUpdater/index.d.ts.map +1 -1
- package/dist/umd/components/ViewportPortal/index.d.ts +25 -0
- package/dist/umd/components/ViewportPortal/index.d.ts.map +1 -1
- package/dist/umd/container/EdgeRenderer/MarkerDefinitions.d.ts.map +1 -1
- package/dist/umd/container/NodeRenderer/index.d.ts.map +1 -1
- package/dist/umd/container/Pane/index.d.ts.map +1 -1
- package/dist/umd/container/ReactFlow/Wrapper.d.ts.map +1 -1
- package/dist/umd/container/ReactFlow/index.d.ts +21 -1
- package/dist/umd/container/ReactFlow/index.d.ts.map +1 -1
- package/dist/umd/contexts/NodeIdContext.d.ts +28 -0
- package/dist/umd/contexts/NodeIdContext.d.ts.map +1 -1
- package/dist/umd/hooks/useConnection.d.ts +20 -1
- package/dist/umd/hooks/useConnection.d.ts.map +1 -1
- package/dist/umd/hooks/useEdges.d.ts +13 -1
- package/dist/umd/hooks/useEdges.d.ts.map +1 -1
- package/dist/umd/hooks/useInternalNode.d.ts +21 -1
- package/dist/umd/hooks/useInternalNode.d.ts.map +1 -1
- package/dist/umd/hooks/useKeyPress.d.ts +19 -1
- package/dist/umd/hooks/useKeyPress.d.ts.map +1 -1
- package/dist/umd/hooks/useMoveSelectedNodes.d.ts.map +1 -1
- package/dist/umd/hooks/useNodeConnections.d.ts +17 -1
- package/dist/umd/hooks/useNodeConnections.d.ts.map +1 -1
- package/dist/umd/hooks/useNodes.d.ts +14 -1
- package/dist/umd/hooks/useNodes.d.ts.map +1 -1
- package/dist/umd/hooks/useNodesData.d.ts +14 -2
- package/dist/umd/hooks/useNodesData.d.ts.map +1 -1
- package/dist/umd/hooks/useNodesEdgesState.d.ts +62 -2
- package/dist/umd/hooks/useNodesEdgesState.d.ts.map +1 -1
- package/dist/umd/hooks/useNodesInitialized.d.ts +27 -1
- package/dist/umd/hooks/useNodesInitialized.d.ts.map +1 -1
- package/dist/umd/hooks/useOnSelectionChange.d.ts +37 -5
- package/dist/umd/hooks/useOnSelectionChange.d.ts.map +1 -1
- package/dist/umd/hooks/useOnViewportChange.d.ts +19 -1
- package/dist/umd/hooks/useOnViewportChange.d.ts.map +1 -1
- package/dist/umd/hooks/useReactFlow.d.ts +24 -1
- package/dist/umd/hooks/useReactFlow.d.ts.map +1 -1
- package/dist/umd/hooks/useStore.d.ts +23 -2
- package/dist/umd/hooks/useStore.d.ts.map +1 -1
- package/dist/umd/hooks/useUpdateNodeInternals.d.ts +39 -1
- package/dist/umd/hooks/useUpdateNodeInternals.d.ts.map +1 -1
- package/dist/umd/hooks/useViewport.d.ts +24 -1
- package/dist/umd/hooks/useViewport.d.ts.map +1 -1
- package/dist/umd/hooks/useViewportHelper.d.ts.map +1 -1
- package/dist/umd/index.js +2 -2
- package/dist/umd/store/index.d.ts.map +1 -1
- package/dist/umd/types/component-props.d.ts +112 -57
- package/dist/umd/types/component-props.d.ts.map +1 -1
- package/dist/umd/types/edges.d.ts +27 -2
- package/dist/umd/types/edges.d.ts.map +1 -1
- package/dist/umd/types/general.d.ts +48 -7
- package/dist/umd/types/general.d.ts.map +1 -1
- package/dist/umd/types/instance.d.ts +11 -1
- package/dist/umd/types/instance.d.ts.map +1 -1
- package/dist/umd/types/nodes.d.ts +46 -4
- package/dist/umd/types/nodes.d.ts.map +1 -1
- package/dist/umd/types/store.d.ts +2 -2
- package/dist/umd/types/store.d.ts.map +1 -1
- package/dist/umd/utils/changes.d.ts +45 -23
- package/dist/umd/utils/changes.d.ts.map +1 -1
- package/dist/umd/utils/general.d.ts +27 -3
- package/dist/umd/utils/general.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import type { Node } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This hook returns an array of the current nodes. Components that use this hook
|
|
4
|
+
* will re-render **whenever any node changes**, including when a node is selected
|
|
5
|
+
* or moved.
|
|
4
6
|
*
|
|
5
7
|
* @public
|
|
6
8
|
* @returns An array of nodes
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
*import { useNodes } from '@xyflow/react';
|
|
13
|
+
*
|
|
14
|
+
*export default function() {
|
|
15
|
+
* const nodes = useNodes();
|
|
16
|
+
*
|
|
17
|
+
* return <div>There are currently {nodes.length} nodes!</div>;
|
|
18
|
+
*}
|
|
19
|
+
*```
|
|
7
20
|
*/
|
|
8
21
|
export declare function useNodes<NodeType extends Node = Node>(): NodeType[];
|
|
9
22
|
//# sourceMappingURL=useNodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodes.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAIrD
|
|
1
|
+
{"version":3,"file":"useNodes.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,UAAU,CAAC;AAIrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,EAAE,CAInE"}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import type { Node } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This hook lets you subscribe to changes of a specific nodes `data` object.
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
* @param nodeId - The id (or ids) of the node to get the data from
|
|
7
|
-
* @param guard - Optional guard function to narrow down the node type
|
|
8
7
|
* @returns An object (or array of object) with {id, type, data} representing each node
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
*```jsx
|
|
12
|
+
*import { useNodesData } from '@xyflow/react';
|
|
13
|
+
*
|
|
14
|
+
*export default function() {
|
|
15
|
+
* const nodeData = useNodesData('nodeId-1');
|
|
16
|
+
* const nodesData = useNodesData(['nodeId-1', 'nodeId-2']);
|
|
17
|
+
*
|
|
18
|
+
* return null;
|
|
19
|
+
*}
|
|
20
|
+
*```
|
|
9
21
|
*/
|
|
10
22
|
export declare function useNodesData<NodeType extends Node = Node>(nodeId: string): Pick<NodeType, 'id' | 'type' | 'data'> | null;
|
|
11
23
|
export declare function useNodesData<NodeType extends Node = Node>(nodeIds: string[]): Pick<NodeType, 'id' | 'type' | 'data'>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodesData.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC
|
|
1
|
+
{"version":3,"file":"useNodesData.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EACvD,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;AACjD,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC"}
|
|
@@ -1,19 +1,79 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
2
|
import type { Node, Edge, OnNodesChange, OnEdgesChange } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* This hook makes it easy to prototype a controlled flow where you manage the
|
|
5
|
+
* state of nodes and edges outside the `ReactFlowInstance`. You can think of it
|
|
6
|
+
* like React's `useState` hook with an additional helper callback.
|
|
5
7
|
*
|
|
6
8
|
* @public
|
|
7
9
|
* @param initialNodes
|
|
8
10
|
* @returns an array [nodes, setNodes, onNodesChange]
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
*```tsx
|
|
14
|
+
*import { ReactFlow, useNodesState, useEdgesState } from '@xyflow/react';
|
|
15
|
+
*
|
|
16
|
+
*const initialNodes = [];
|
|
17
|
+
*const initialEdges = [];
|
|
18
|
+
*
|
|
19
|
+
*export default function () {
|
|
20
|
+
* const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
|
|
21
|
+
* const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <ReactFlow
|
|
25
|
+
* nodes={nodes}
|
|
26
|
+
* edges={edges}
|
|
27
|
+
* onNodesChange={onNodesChange}
|
|
28
|
+
* onEdgesChange={onEdgesChange}
|
|
29
|
+
* />
|
|
30
|
+
* );
|
|
31
|
+
*}
|
|
32
|
+
*```
|
|
33
|
+
*
|
|
34
|
+
* @remarks This hook was created to make prototyping easier and our documentation
|
|
35
|
+
* examples clearer. Although it is OK to use this hook in production, in
|
|
36
|
+
* practice you may want to use a more sophisticated state management solution
|
|
37
|
+
* like Zustand {@link https://reactflow.dev/docs/guides/state-management/} instead.
|
|
38
|
+
*
|
|
9
39
|
*/
|
|
10
40
|
export declare function useNodesState<NodeType extends Node>(initialNodes: NodeType[]): [NodeType[], Dispatch<SetStateAction<NodeType[]>>, OnNodesChange<NodeType>];
|
|
11
41
|
/**
|
|
12
|
-
*
|
|
42
|
+
* This hook makes it easy to prototype a controlled flow where you manage the
|
|
43
|
+
* state of nodes and edges outside the `ReactFlowInstance`. You can think of it
|
|
44
|
+
* like React's `useState` hook with an additional helper callback.
|
|
13
45
|
*
|
|
14
46
|
* @public
|
|
15
47
|
* @param initialEdges
|
|
16
48
|
* @returns an array [edges, setEdges, onEdgesChange]
|
|
49
|
+
* @example
|
|
50
|
+
*
|
|
51
|
+
*```tsx
|
|
52
|
+
*import { ReactFlow, useNodesState, useEdgesState } from '@xyflow/react';
|
|
53
|
+
*
|
|
54
|
+
*const initialNodes = [];
|
|
55
|
+
*const initialEdges = [];
|
|
56
|
+
*
|
|
57
|
+
*export default function () {
|
|
58
|
+
* const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
|
|
59
|
+
* const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
|
|
60
|
+
*
|
|
61
|
+
* return (
|
|
62
|
+
* <ReactFlow
|
|
63
|
+
* nodes={nodes}
|
|
64
|
+
* edges={edges}
|
|
65
|
+
* onNodesChange={onNodesChange}
|
|
66
|
+
* onEdgesChange={onEdgesChange}
|
|
67
|
+
* />
|
|
68
|
+
* );
|
|
69
|
+
*}
|
|
70
|
+
*```
|
|
71
|
+
*
|
|
72
|
+
* @remarks This hook was created to make prototyping easier and our documentation
|
|
73
|
+
* examples clearer. Although it is OK to use this hook in production, in
|
|
74
|
+
* practice you may want to use a more sophisticated state management solution
|
|
75
|
+
* like Zustand {@link https://reactflow.dev/docs/guides/state-management/} instead.
|
|
76
|
+
*
|
|
17
77
|
*/
|
|
18
78
|
export declare function useEdgesState<EdgeType extends Edge = Edge>(initialEdges: EdgeType[]): [EdgeType[], Dispatch<SetStateAction<EdgeType[]>>, OnEdgesChange<EdgeType>];
|
|
19
79
|
//# sourceMappingURL=useNodesEdgesState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodesEdgesState.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesEdgesState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAGlF,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzE
|
|
1
|
+
{"version":3,"file":"useNodesEdgesState.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesEdgesState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAGlF,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,IAAI,EACjD,YAAY,EAAE,QAAQ,EAAE,GACvB,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAQ7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,aAAa,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EACxD,YAAY,EAAE,QAAQ,EAAE,GACvB,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAQ7E"}
|
|
@@ -2,11 +2,37 @@ export type UseNodesInitializedOptions = {
|
|
|
2
2
|
includeHiddenNodes?: boolean;
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* This hook tells you whether all the nodes in a flow have been measured and given
|
|
6
|
+
*a width and height. When you add a node to the flow, this hook will return
|
|
7
|
+
*`false` and then `true` again once the node has been measured.
|
|
6
8
|
*
|
|
7
9
|
* @public
|
|
8
10
|
* @param options.includeHiddenNodes - defaults to false
|
|
9
11
|
* @returns boolean indicating whether all nodes are initialized
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```jsx
|
|
15
|
+
*import { useReactFlow, useNodesInitialized } from '@xyflow/react';
|
|
16
|
+
*import { useEffect, useState } from 'react';
|
|
17
|
+
*
|
|
18
|
+
*const options = {
|
|
19
|
+
* includeHiddenNodes: false,
|
|
20
|
+
*};
|
|
21
|
+
*
|
|
22
|
+
*export default function useLayout() {
|
|
23
|
+
* const { getNodes } = useReactFlow();
|
|
24
|
+
* const nodesInitialized = useNodesInitialized(options);
|
|
25
|
+
* const [layoutedNodes, setLayoutedNodes] = useState(getNodes());
|
|
26
|
+
*
|
|
27
|
+
* useEffect(() => {
|
|
28
|
+
* if (nodesInitialized) {
|
|
29
|
+
* setLayoutedNodes(yourLayoutingFunction(getNodes()));
|
|
30
|
+
* }
|
|
31
|
+
* }, [nodesInitialized]);
|
|
32
|
+
*
|
|
33
|
+
* return layoutedNodes;
|
|
34
|
+
*}
|
|
35
|
+
*```
|
|
10
36
|
*/
|
|
11
37
|
export declare function useNodesInitialized(options?: UseNodesInitializedOptions): boolean;
|
|
12
38
|
//# sourceMappingURL=useNodesInitialized.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodesInitialized.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesInitialized.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNodesInitialized.d.ts","sourceRoot":"","sources":["../../src/hooks/useNodesInitialized.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,0BAA0B,GAAG;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAkBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAER,GACA,OAAO,CAIT"}
|
|
@@ -1,12 +1,44 @@
|
|
|
1
|
-
import type { OnSelectionChangeFunc } from '../types';
|
|
2
|
-
export type UseOnSelectionChangeOptions = {
|
|
3
|
-
onChange: OnSelectionChangeFunc
|
|
1
|
+
import type { OnSelectionChangeFunc, Node, Edge } from '../types';
|
|
2
|
+
export type UseOnSelectionChangeOptions<NodeType extends Node = Node, EdgeType extends Edge = Edge> = {
|
|
3
|
+
onChange: OnSelectionChangeFunc<NodeType, EdgeType>;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* This hook lets you listen for changes to both node and edge selection. As the
|
|
7
|
+
*name implies, the callback you provide will be called whenever the selection of
|
|
8
|
+
*_either_ nodes or edges changes.
|
|
7
9
|
*
|
|
8
10
|
* @public
|
|
9
11
|
* @param params.onChange - The handler to register
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```jsx
|
|
15
|
+
*import { useState } from 'react';
|
|
16
|
+
*import { ReactFlow, useOnSelectionChange } from '@xyflow/react';
|
|
17
|
+
*
|
|
18
|
+
*function SelectionDisplay() {
|
|
19
|
+
* const [selectedNodes, setSelectedNodes] = useState([]);
|
|
20
|
+
* const [selectedEdges, setSelectedEdges] = useState([]);
|
|
21
|
+
*
|
|
22
|
+
* // the passed handler has to be memoized, otherwise the hook will not work correctly
|
|
23
|
+
* const onChange = useCallback(({ nodes, edges }) => {
|
|
24
|
+
* setSelectedNodes(nodes.map((node) => node.id));
|
|
25
|
+
* setSelectedEdges(edges.map((edge) => edge.id));
|
|
26
|
+
* }, []);
|
|
27
|
+
*
|
|
28
|
+
* useOnSelectionChange({
|
|
29
|
+
* onChange,
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <div>
|
|
34
|
+
* <p>Selected nodes: {selectedNodes.join(', ')}</p>
|
|
35
|
+
* <p>Selected edges: {selectedEdges.join(', ')}</p>
|
|
36
|
+
* </div>
|
|
37
|
+
* );
|
|
38
|
+
*}
|
|
39
|
+
*```
|
|
40
|
+
*
|
|
41
|
+
* @remarks You need to memoize the passed `onChange` handler, otherwise the hook will not work correctly.
|
|
10
42
|
*/
|
|
11
|
-
export declare function useOnSelectionChange({ onChange }: UseOnSelectionChangeOptions): void;
|
|
43
|
+
export declare function useOnSelectionChange<NodeType extends Node = Node, EdgeType extends Edge = Edge>({ onChange, }: UseOnSelectionChangeOptions<NodeType, EdgeType>): void;
|
|
12
44
|
//# sourceMappingURL=useOnSelectionChange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnSelectionChange.d.ts","sourceRoot":"","sources":["../../src/hooks/useOnSelectionChange.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useOnSelectionChange.d.ts","sourceRoot":"","sources":["../../src/hooks/useOnSelectionChange.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAElE,MAAM,MAAM,2BAA2B,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,IAAI;IACpG,QAAQ,EAAE,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CACrD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,EAC/F,QAAQ,GACT,EAAE,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAYjD"}
|
|
@@ -5,12 +5,30 @@ export type UseOnViewportChangeOptions = {
|
|
|
5
5
|
onEnd?: OnViewportChange;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* The `useOnViewportChange` hook lets you listen for changes to the viewport such
|
|
9
|
+
*as panning and zooming. You can provide a callback for each phase of a viewport
|
|
10
|
+
*change: `onStart`, `onChange`, and `onEnd`.
|
|
9
11
|
*
|
|
10
12
|
* @public
|
|
11
13
|
* @param params.onStart - gets called when the viewport starts changing
|
|
12
14
|
* @param params.onChange - gets called when the viewport changes
|
|
13
15
|
* @param params.onEnd - gets called when the viewport stops changing
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```jsx
|
|
19
|
+
*import { useCallback } from 'react';
|
|
20
|
+
*import { useOnViewportChange } from '@xyflow/react';
|
|
21
|
+
*
|
|
22
|
+
*function ViewportChangeLogger() {
|
|
23
|
+
* useOnViewportChange({
|
|
24
|
+
* onStart: (viewport: Viewport) => console.log('start', viewport),
|
|
25
|
+
* onChange: (viewport: Viewport) => console.log('change', viewport),
|
|
26
|
+
* onEnd: (viewport: Viewport) => console.log('end', viewport),
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* return null;
|
|
30
|
+
*}
|
|
31
|
+
*```
|
|
14
32
|
*/
|
|
15
33
|
export declare function useOnViewportChange({ onStart, onChange, onEnd }: UseOnViewportChangeOptions): void;
|
|
16
34
|
//# sourceMappingURL=useOnViewportChange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnViewportChange.d.ts","sourceRoot":"","sources":["../../src/hooks/useOnViewportChange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"useOnViewportChange.d.ts","sourceRoot":"","sources":["../../src/hooks/useOnViewportChange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,0BAA0B,QAc3F"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import type { ReactFlowInstance, Node, Edge } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This hook returns a ReactFlowInstance that can be used to update nodes and edges, manipulate the viewport, or query the current state of the flow.
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
* @returns ReactFlowInstance
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
*import { useCallback, useState } from 'react';
|
|
11
|
+
*import { useReactFlow } from '@xyflow/react';
|
|
12
|
+
*
|
|
13
|
+
*export function NodeCounter() {
|
|
14
|
+
* const reactFlow = useReactFlow();
|
|
15
|
+
* const [count, setCount] = useState(0);
|
|
16
|
+
* const countNodes = useCallback(() => {
|
|
17
|
+
* setCount(reactFlow.getNodes().length);
|
|
18
|
+
* // you need to pass it as a dependency if you are using it with useEffect or useCallback
|
|
19
|
+
* // because at the first render, it's not initialized yet and some functions might not work.
|
|
20
|
+
* }, [reactFlow]);
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <div>
|
|
24
|
+
* <button onClick={countNodes}>Update count</button>
|
|
25
|
+
* <p>There are {count} nodes in the flow.</p>
|
|
26
|
+
* </div>
|
|
27
|
+
* );
|
|
28
|
+
*}
|
|
29
|
+
*```
|
|
7
30
|
*/
|
|
8
31
|
export declare function useReactFlow<NodeType extends Node = Node, EdgeType extends Edge = Edge>(): ReactFlowInstance<NodeType, EdgeType>;
|
|
9
32
|
//# sourceMappingURL=useReactFlow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactFlow.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAgD,MAAM,UAAU,CAAC;AAI5G
|
|
1
|
+
{"version":3,"file":"useReactFlow.d.ts","sourceRoot":"","sources":["../../src/hooks/useReactFlow.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAgD,MAAM,UAAU,CAAC;AAI5G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI,KAAK,iBAAiB,CAC3G,QAAQ,EACR,QAAQ,CACT,CAsOA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Edge, Node, ReactFlowState } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* This hook can be used to subscribe to internal state changes of the React Flow
|
|
4
|
+
* component. The `useStore` hook is re-exported from the [Zustand](https://github.com/pmndrs/zustand)
|
|
5
|
+
* state management library, so you should check out their docs for more details.
|
|
4
6
|
*
|
|
5
7
|
* @public
|
|
6
8
|
* @param selector
|
|
@@ -8,10 +10,29 @@ import type { Edge, Node, ReactFlowState } from '../types';
|
|
|
8
10
|
* @returns The selected state slice
|
|
9
11
|
*
|
|
10
12
|
* @example
|
|
11
|
-
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const nodes = useStore((state) => state.nodes);
|
|
15
|
+
* ```
|
|
12
16
|
*
|
|
17
|
+
* @remarks This hook should only be used if there is no other way to access the internal
|
|
18
|
+
* state. For many of the common use cases, there are dedicated hooks available
|
|
19
|
+
* such as {@link useReactFlow}, {@link useViewport}, etc.
|
|
13
20
|
*/
|
|
14
21
|
declare function useStore<StateSlice = unknown>(selector: (state: ReactFlowState) => StateSlice, equalityFn?: (a: StateSlice, b: StateSlice) => boolean): StateSlice;
|
|
22
|
+
/**
|
|
23
|
+
* In some cases, you might need to access the store directly. This hook returns the store object which can be used on demand to access the state or dispatch actions.
|
|
24
|
+
*
|
|
25
|
+
* @returns The store object
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const store = useStoreApi();
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @remarks This hook should only be used if there is no other way to access the internal
|
|
33
|
+
* state. For many of the common use cases, there are dedicated hooks available
|
|
34
|
+
* such as {@link useReactFlow}, {@link useViewport}, etc.
|
|
35
|
+
*/
|
|
15
36
|
declare function useStoreApi<NodeType extends Node = Node, EdgeType extends Edge = Edge>(): {
|
|
16
37
|
getState: () => ReactFlowState<NodeType, EdgeType>;
|
|
17
38
|
setState: (partial: ReactFlowState<NodeType, EdgeType> | Partial<ReactFlowState<NodeType, EdgeType>> | ((state: ReactFlowState<NodeType, EdgeType>) => ReactFlowState<NodeType, EdgeType> | Partial<ReactFlowState<NodeType, EdgeType>>), replace?: boolean | undefined) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI3D
|
|
1
|
+
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI3D;;;;;;;;;;;;;;;;;;GAkBG;AACH,iBAAS,QAAQ,CAAC,UAAU,GAAG,OAAO,EACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,UAAU,EAC/C,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,KAAK,OAAO,cASvD;AAED;;;;;;;;;;;;;GAaG;AACH,iBAAS,WAAW,CAAC,QAAQ,SAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,SAAS,IAAI,GAAG,IAAI;;;;EAiB9E;AAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
import type { UpdateNodeInternals } from '@xyflow/system';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* When you programmatically add or remove handles to a node or update a node's
|
|
4
|
+
*handle position, you need to let React Flow know about it using this hook. This
|
|
5
|
+
*will update the internal dimensions of the node and properly reposition handles
|
|
6
|
+
*on the canvas if necessary.
|
|
4
7
|
*
|
|
5
8
|
* @public
|
|
6
9
|
* @returns function for updating node internals
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
*import { useCallback, useState } from 'react';
|
|
14
|
+
*import { Handle, useUpdateNodeInternals } from '@xyflow/react';
|
|
15
|
+
*
|
|
16
|
+
*export default function RandomHandleNode({ id }) {
|
|
17
|
+
* const updateNodeInternals = useUpdateNodeInternals();
|
|
18
|
+
* const [handleCount, setHandleCount] = useState(0);
|
|
19
|
+
* const randomizeHandleCount = useCallback(() => {
|
|
20
|
+
* setHandleCount(Math.floor(Math.random() * 10));
|
|
21
|
+
* updateNodeInternals(id);
|
|
22
|
+
* }, [id, updateNodeInternals]);
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <>
|
|
26
|
+
* {Array.from({ length: handleCount }).map((_, index) => (
|
|
27
|
+
* <Handle
|
|
28
|
+
* key={index}
|
|
29
|
+
* type="target"
|
|
30
|
+
* position="left"
|
|
31
|
+
* id={`handle-${index}`}
|
|
32
|
+
* />
|
|
33
|
+
* ))}
|
|
34
|
+
*
|
|
35
|
+
* <div>
|
|
36
|
+
* <button onClick={randomizeHandleCount}>Randomize handle count</button>
|
|
37
|
+
* <p>There are {handleCount} handles on this node.</p>
|
|
38
|
+
* </div>
|
|
39
|
+
* </>
|
|
40
|
+
* );
|
|
41
|
+
*}
|
|
42
|
+
*```
|
|
43
|
+
* @remarks This hook can only be used in a component that is a child of a
|
|
44
|
+
*{@link ReactFlowProvider} or a {@link ReactFlow} component.
|
|
7
45
|
*/
|
|
8
46
|
export declare function useUpdateNodeInternals(): UpdateNodeInternals;
|
|
9
47
|
//# sourceMappingURL=useUpdateNodeInternals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUpdateNodeInternals.d.ts","sourceRoot":"","sources":["../../src/hooks/useUpdateNodeInternals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAI9E
|
|
1
|
+
{"version":3,"file":"useUpdateNodeInternals.d.ts","sourceRoot":"","sources":["../../src/hooks/useUpdateNodeInternals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAsB,MAAM,gBAAgB,CAAC;AAI9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAkB5D"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import type { Viewport } from '@xyflow/system';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The `useViewport` hook is a convenient way to read the current state of the
|
|
4
|
+
*{@link Viewport} in a component. Components that use this hook
|
|
5
|
+
*will re-render **whenever the viewport changes**.
|
|
4
6
|
*
|
|
5
7
|
* @public
|
|
6
8
|
* @returns The current viewport
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
*
|
|
12
|
+
*```jsx
|
|
13
|
+
*import { useViewport } from '@xyflow/react';
|
|
14
|
+
*
|
|
15
|
+
*export default function ViewportDisplay() {
|
|
16
|
+
* const { x, y, zoom } = useViewport();
|
|
17
|
+
*
|
|
18
|
+
* return (
|
|
19
|
+
* <div>
|
|
20
|
+
* <p>
|
|
21
|
+
* The viewport is currently at ({x}, {y}) and zoomed to {zoom}.
|
|
22
|
+
* </p>
|
|
23
|
+
* </div>
|
|
24
|
+
* );
|
|
25
|
+
*}
|
|
26
|
+
*```
|
|
27
|
+
*
|
|
28
|
+
* @remarks This hook can only be used in a component that is a child of a
|
|
29
|
+
*{@link ReactFlowProvider} or a {@link ReactFlow} component.
|
|
7
30
|
*/
|
|
8
31
|
export declare function useViewport(): Viewport;
|
|
9
32
|
//# sourceMappingURL=useViewport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewport.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAW/C
|
|
1
|
+
{"version":3,"file":"useViewport.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAW/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAItC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewportHelper.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewportHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useViewportHelper.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewportHelper.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;GAKG;AACH,QAAA,MAAM,iBAAiB,QAAO,uBA0I7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|