diff --git a/examples/nextjs/pages/Backgrounds/index.tsx b/examples/nextjs/pages/Backgrounds/index.tsx index 9af3cbde..fa3eaec6 100644 --- a/examples/nextjs/pages/Backgrounds/index.tsx +++ b/examples/nextjs/pages/Backgrounds/index.tsx @@ -5,13 +5,10 @@ import { Node, ReactFlowProvider, useNodesState, -} from '@react-flow/core'; - -import { Background, BackgroundProps, BackgroundVariant, -} from '@react-flow/background'; +} from '@react-flow/bundle'; import styles from './style.module.css'; @@ -23,10 +20,7 @@ const initialNodes: Node[] = [ }, ]; -const Flow: FC<{ id: string; bgProps: BackgroundProps }> = ({ - id, - bgProps, -}) => { +const Flow: FC<{ id: string; bgProps: BackgroundProps }> = ({ id, bgProps }) => { const [nodes, , onNodesChange] = useNodesState(initialNodes); return ( @@ -41,14 +35,8 @@ const Flow: FC<{ id: string; bgProps: BackgroundProps }> = ({ const Backgrounds: FC = () => (
- - + +
); diff --git a/examples/nextjs/pages/ControlledUncontrolled/index.tsx b/examples/nextjs/pages/ControlledUncontrolled/index.tsx index 1f3871ad..37b68d3f 100644 --- a/examples/nextjs/pages/ControlledUncontrolled/index.tsx +++ b/examples/nextjs/pages/ControlledUncontrolled/index.tsx @@ -7,8 +7,9 @@ import { ReactFlowProvider, useNodesState, useEdgesState, -} from '@react-flow/core'; -import { Background, BackgroundVariant } from '@react-flow/background'; + Background, + BackgroundVariant, +} from '@react-flow/bunde'; const defaultNodes: Node[] = [ { diff --git a/examples/nextjs/pages/CustomConnectionLine/ConnectionLine.tsx b/examples/nextjs/pages/CustomConnectionLine/ConnectionLine.tsx index fb14ef1a..8a552f44 100644 --- a/examples/nextjs/pages/CustomConnectionLine/ConnectionLine.tsx +++ b/examples/nextjs/pages/CustomConnectionLine/ConnectionLine.tsx @@ -1,12 +1,7 @@ import React, { FC } from 'react'; -import { ConnectionLineComponentProps } from '@react-flow/core'; +import { ConnectionLineComponentProps } from '@react-flow/bundle'; -const ConnectionLine: FC = ({ - fromX, - fromY, - toX, - toY, -}) => { +const ConnectionLine: FC = ({ fromX, fromY, toX, toY }) => { return ( = ({ className="animated" d={`M${fromX},${fromY} C ${fromX} ${toY} ${fromX} ${toY} ${toX},${toY}`} /> - + ); }; diff --git a/examples/nextjs/pages/CustomConnectionLine/index.tsx b/examples/nextjs/pages/CustomConnectionLine/index.tsx index aa430f2f..360aa6d4 100644 --- a/examples/nextjs/pages/CustomConnectionLine/index.tsx +++ b/examples/nextjs/pages/CustomConnectionLine/index.tsx @@ -7,8 +7,9 @@ import { Edge, useNodesState, useEdgesState, -} from '@react-flow/core'; -import { Background, BackgroundVariant } from '@react-flow/background'; + Background, + BackgroundVariant, +} from '@react-flow/bundle'; import ConnectionLine from './ConnectionLine'; @@ -25,10 +26,7 @@ const initialEdges: Edge[] = []; const ConnectionLineFlow = () => { const [nodes, , onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); - const onConnect = useCallback( - (params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)), - [setEdges] - ); + const onConnect = useCallback((params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)), [setEdges]); return ( - console.log('handle onConnect', params); +const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params); const ColorSelectorNode: FC = ({ data, isConnectable }) => { return ( <> - +
Custom Color Picker Node: {data.color}
- + = ({ data, isConnectable }) => { console.log('You trigger mousedown event', e); }} /> - + ); }; diff --git a/examples/nextjs/pages/CustomNode/index.tsx b/examples/nextjs/pages/CustomNode/index.tsx index 43bfaedf..84e7894f 100644 --- a/examples/nextjs/pages/CustomNode/index.tsx +++ b/examples/nextjs/pages/CustomNode/index.tsx @@ -11,7 +11,7 @@ import { Connection, useNodesState, useEdgesState, -} from '@react-flow/renderer'; +} from '@react-flow/bundle'; import ColorSelectorNode from './ColorSelectorNode'; @@ -120,9 +120,7 @@ const CustomNodeFlow = () => { }, []); const onConnect = (connection: Connection) => - setEdges((eds) => - addEdge({ ...connection, animated: true, style: { stroke: '#fff' } }, eds) - ); + setEdges((eds) => addEdge({ ...connection, animated: true, style: { stroke: '#fff' } }, eds)); return ( { }; return ( - +
diff --git a/examples/nextjs/pages/DragHandle/DragHandleNode.tsx b/examples/nextjs/pages/DragHandle/DragHandleNode.tsx index 716ab781..5343f437 100644 --- a/examples/nextjs/pages/DragHandle/DragHandleNode.tsx +++ b/examples/nextjs/pages/DragHandle/DragHandleNode.tsx @@ -1,15 +1,8 @@ import React, { memo, FC } from 'react'; -import { - Handle, - Position, - NodeProps, - Connection, - Edge, -} from '@react-flow/core'; +import { Handle, Position, NodeProps, Connection, Edge } from '@react-flow/bundle'; -const onConnect = (params: Connection | Edge) => - console.log('handle onConnect', params); +const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params); const labelStyle = { display: 'flex', @@ -28,12 +21,11 @@ const dragHandleStyle = { const ColorSelectorNode: FC = () => { return ( <> - +
- Only draggable here →{' '} - + Only draggable here →
- + ); }; diff --git a/examples/nextjs/pages/DragNDrop/index.tsx b/examples/nextjs/pages/DragNDrop/index.tsx index cd9b4b89..b1b6a048 100644 --- a/examples/nextjs/pages/DragNDrop/index.tsx +++ b/examples/nextjs/pages/DragNDrop/index.tsx @@ -9,8 +9,8 @@ import { Node, useNodesState, useEdgesState, -} from '@react-flow/core'; -import { Controls } from '@react-flow/controls'; + Controls, +} from '@react-flow/bundle'; import Sidebar from './Sidebar'; @@ -34,13 +34,11 @@ let id = 0; const getId = () => `dndnode_${id++}`; const DnDFlow = () => { - const [reactFlowInstance, setReactFlowInstance] = - useState(); + const [reactFlowInstance, setReactFlowInstance] = useState(); const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState([]); - const onConnect = (params: Connection | Edge) => - setEdges((eds) => addEdge(params, eds)); + const onConnect = (params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)); const onInit = (rfi: ReactFlowInstance) => setReactFlowInstance(rfi); const onDrop = (event: DragEvent) => { diff --git a/examples/nextjs/pages/EdgeTypes/index.tsx b/examples/nextjs/pages/EdgeTypes/index.tsx index 5f020ca4..2877239a 100644 --- a/examples/nextjs/pages/EdgeTypes/index.tsx +++ b/examples/nextjs/pages/EdgeTypes/index.tsx @@ -14,7 +14,7 @@ import { Edge, useNodesState, useEdgesState, -} from '@react-flow/renderer'; +} from '@react-flow/bundle'; import { getElements } from './utils'; @@ -31,8 +31,7 @@ const deleteKeyCode = ['AltLeft+KeyD', 'Backspace']; const EdgeTypesFlow = () => { const [nodes, , onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); - const onConnect = (params: Connection | Edge) => - setEdges((eds) => addEdge(params, eds)); + const onConnect = (params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)); return ( (id++).toString(); export function getElements(): { nodes: Node[]; edges: Edge[] } { const initialElements = { nodes: [] as Node[], edges: [] as Edge[] }; - for ( - let sourceTargetIndex = 0; - sourceTargetIndex < sourceTargetPositions.length; - sourceTargetIndex++ - ) { + for (let sourceTargetIndex = 0; sourceTargetIndex < sourceTargetPositions.length; sourceTargetIndex++) { const currSourceTargetPos = sourceTargetPositions[sourceTargetIndex]; - for ( - let edgeTypeIndex = 0; - edgeTypeIndex < edgeTypes.length; - edgeTypeIndex++ - ) { + for (let edgeTypeIndex = 0; edgeTypeIndex < edgeTypes.length; edgeTypeIndex++) { const currEdgeType = edgeTypes[edgeTypeIndex]; for (let offsetIndex = 0; offsetIndex < offsets.length; offsetIndex++) { diff --git a/examples/nextjs/pages/Edges/CustomEdge.tsx b/examples/nextjs/pages/Edges/CustomEdge.tsx index e2ec0cb5..a51c86af 100644 --- a/examples/nextjs/pages/Edges/CustomEdge.tsx +++ b/examples/nextjs/pages/Edges/CustomEdge.tsx @@ -1,5 +1,5 @@ import React, { FC } from 'react'; -import { EdgeProps, getBezierPath } from '@react-flow/core'; +import { EdgeProps, getBezierPath } from '@react-flow/bundle'; const CustomEdge: FC = ({ id, @@ -22,14 +22,9 @@ const CustomEdge: FC = ({ return ( <> - + - + {data.text} diff --git a/examples/nextjs/pages/Edges/CustomEdge2.tsx b/examples/nextjs/pages/Edges/CustomEdge2.tsx index cd1f810a..cb446f07 100644 --- a/examples/nextjs/pages/Edges/CustomEdge2.tsx +++ b/examples/nextjs/pages/Edges/CustomEdge2.tsx @@ -1,10 +1,5 @@ import React, { FC } from 'react'; -import { - EdgeProps, - getBezierPath, - EdgeText, - getBezierEdgeCenter, -} from '@react-flow/core'; +import { EdgeProps, getBezierPath, EdgeText, getBezierEdgeCenter } from '@react-flow/bundle'; const CustomEdge: FC = ({ id, @@ -33,7 +28,7 @@ const CustomEdge: FC = ({ return ( <> - + - console.log('drag stop', node); +const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node); const onNodeClick = (_: MouseEvent, node: Node) => console.log('click', node); const onEdgeClick = (_: MouseEvent, edge: Edge) => console.log('click', edge); -const onEdgeDoubleClick = (_: MouseEvent, edge: Edge) => - console.log('dblclick', edge); -const onEdgeMouseEnter = (_: MouseEvent, edge: Edge) => - console.log('enter', edge); -const onEdgeMouseMove = (_: MouseEvent, edge: Edge) => - console.log('move', edge); -const onEdgeMouseLeave = (_: MouseEvent, edge: Edge) => - console.log('leave', edge); +const onEdgeDoubleClick = (_: MouseEvent, edge: Edge) => console.log('dblclick', edge); +const onEdgeMouseEnter = (_: MouseEvent, edge: Edge) => console.log('enter', edge); +const onEdgeMouseMove = (_: MouseEvent, edge: Edge) => console.log('move', edge); +const onEdgeMouseLeave = (_: MouseEvent, edge: Edge) => console.log('leave', edge); const initialNodes: Node[] = [ { @@ -189,10 +184,7 @@ const defaultViewport = { const EdgesFlow = () => { const [nodes, , onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); - const onConnect = useCallback( - (params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)), - [setEdges] - ); + const onConnect = useCallback((params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)), [setEdges]); return ( - console.log('flow loaded:', reactFlowInstance); +const onInit = (reactFlowInstance: ReactFlowInstance) => console.log('flow loaded:', reactFlowInstance); const onNodeClick = (_: MouseEvent, node: Node) => console.log('click', node); -const onNodeDragStop = (_: MouseEvent, node: Node) => - console.log('drag stop', node); +const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node); const buttonStyle: CSSProperties = { position: 'absolute', @@ -31,10 +29,7 @@ const EmptyFlow = () => { const [nodes, setNodes, onNodesChange] = useNodesState([]); const [edges, setEdges, onEdgesChange] = useEdgesState([]); - const onConnect = useCallback( - (params: Connection | Edge) => setEdges((els) => addEdge(params, els)), - [setEdges] - ); + const onConnect = useCallback((params: Connection | Edge) => setEdges((els) => addEdge(params, els)), [setEdges]); const addRandomNode = () => { const nodeId = (nodes.length + 1).toString(); const newNode: Node = { diff --git a/examples/nextjs/pages/FloatingEdges/FloatingConnectionLine.tsx b/examples/nextjs/pages/FloatingEdges/FloatingConnectionLine.tsx index 3bd4d562..1930bf73 100644 --- a/examples/nextjs/pages/FloatingEdges/FloatingConnectionLine.tsx +++ b/examples/nextjs/pages/FloatingEdges/FloatingConnectionLine.tsx @@ -1,9 +1,5 @@ import React, { FC } from 'react'; -import { - getBezierPath, - ConnectionLineComponentProps, - Node, -} from '@react-flow/core'; +import { getBezierPath, ConnectionLineComponentProps, Node } from '@react-flow/bundle'; import { getEdgeParams } from './utils'; @@ -37,21 +33,8 @@ const FloatingConnectionLine: FC = ({ return ( - - + + ); }; diff --git a/examples/nextjs/pages/FloatingEdges/FloatingEdge.tsx b/examples/nextjs/pages/FloatingEdges/FloatingEdge.tsx index e0a3a432..1187d70c 100644 --- a/examples/nextjs/pages/FloatingEdges/FloatingEdge.tsx +++ b/examples/nextjs/pages/FloatingEdges/FloatingEdge.tsx @@ -1,10 +1,5 @@ import React, { FC, useMemo, CSSProperties } from 'react'; -import { - EdgeProps, - useStore, - getBezierPath, - ReactFlowState, -} from '@react-flow/core'; +import { EdgeProps, useStore, getBezierPath, ReactFlowState } from '@react-flow/bundle'; import { getEdgeParams } from './utils'; @@ -13,23 +8,14 @@ const nodeSelector = (s: ReactFlowState) => s.nodeInternals; const FloatingEdge: FC = ({ id, source, target, style }) => { const nodeInternals = useStore(nodeSelector); - const sourceNode = useMemo( - () => nodeInternals.get(source), - [source, nodeInternals] - ); - const targetNode = useMemo( - () => nodeInternals.get(target), - [target, nodeInternals] - ); + const sourceNode = useMemo(() => nodeInternals.get(source), [source, nodeInternals]); + const targetNode = useMemo(() => nodeInternals.get(target), [target, nodeInternals]); if (!sourceNode || !targetNode) { return null; } - const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams( - sourceNode, - targetNode - ); + const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode); const d = getBezierPath({ sourceX: sx, @@ -41,13 +27,8 @@ const FloatingEdge: FC = ({ id, source, target, style }) => { }); return ( - - + + ); }; diff --git a/examples/nextjs/pages/FloatingEdges/index.tsx b/examples/nextjs/pages/FloatingEdges/index.tsx index d24b7ca0..11f7ae38 100644 --- a/examples/nextjs/pages/FloatingEdges/index.tsx +++ b/examples/nextjs/pages/FloatingEdges/index.tsx @@ -9,7 +9,7 @@ import { Connection, useNodesState, useEdgesState, -} from '@react-flow/renderer'; +} from '@react-flow/bundle'; import styles from './style.module.css'; @@ -17,8 +17,7 @@ import FloatingConnectionLine from './FloatingConnectionLine'; import FloatingEdge from './FloatingEdge'; import { createElements } from './utils'; -const onInit = (reactFlowInstance: ReactFlowInstance) => - reactFlowInstance.fitView(); +const onInit = (reactFlowInstance: ReactFlowInstance) => reactFlowInstance.fitView(); const { nodes: initialNodes, edges: initialEdges } = typeof window !== 'undefined' ? createElements() : { nodes: [], edges: [] }; diff --git a/examples/nextjs/pages/FloatingEdges/utils.ts b/examples/nextjs/pages/FloatingEdges/utils.ts index 5e8f50b9..9f12d22a 100644 --- a/examples/nextjs/pages/FloatingEdges/utils.ts +++ b/examples/nextjs/pages/FloatingEdges/utils.ts @@ -1,11 +1,8 @@ -import React, { Position, XYPosition, Node, Edge } from '@react-flow/core'; +import { Position, XYPosition, Node, Edge } from '@react-flow/bundle'; // this helper function returns the intersection point // of the line between the center of the intersectionNode and the target node -function getNodeIntersection( - intersectionNode: Node, - targetNode: Node -): XYPosition { +function getNodeIntersection(intersectionNode: Node, targetNode: Node): XYPosition { // https://math.stackexchange.com/questions/1724792/an-algorithm-for-finding-the-intersection-point-between-a-center-of-vision-and-a const { diff --git a/examples/nextjs/pages/Hidden/index.tsx b/examples/nextjs/pages/Hidden/index.tsx index 1e860359..c11b28ec 100644 --- a/examples/nextjs/pages/Hidden/index.tsx +++ b/examples/nextjs/pages/Hidden/index.tsx @@ -8,10 +8,9 @@ import { Node, useNodesState, useEdgesState, -} from '@react-flow/core'; - -import { Controls } from '@react-flow/controls'; -import { MiniMap } from '@react-flow/minimap'; + MiniMap, + Controls, +} from '@react-flow/bundle'; const initialNodes: Node[] = [ { diff --git a/examples/nextjs/pages/Interaction/index.tsx b/examples/nextjs/pages/Interaction/index.tsx index 26e12a73..efff90b6 100644 --- a/examples/nextjs/pages/Interaction/index.tsx +++ b/examples/nextjs/pages/Interaction/index.tsx @@ -1,8 +1,4 @@ -import React, { - useState, - MouseEvent as ReactMouseEvent, - WheelEvent, -} from 'react'; +import React, { useState, MouseEvent as ReactMouseEvent, WheelEvent } from 'react'; import { ReactFlow, addEdge, @@ -13,10 +9,9 @@ import { Viewport, useNodesState, useEdgesState, -} from '@react-flow/core'; - -import { Controls } from '@react-flow/controls'; -import { MiniMap } from '@react-flow/minimap'; + Controls, + MiniMap, +} from '@react-flow/bundle'; const initialNodes: Node[] = [ { @@ -35,27 +30,19 @@ const initialEdges: Edge[] = [ { id: 'e1-3', source: '1', target: '3' }, ]; -const onNodeDragStart = (_: ReactMouseEvent, node: Node) => - console.log('drag start', node); -const onNodeDragStop = (_: ReactMouseEvent, node: Node) => - console.log('drag stop', node); -const onNodeClick = (_: ReactMouseEvent, node: Node) => - console.log('click', node); -const onEdgeClick = (_: ReactMouseEvent, edge: Edge) => - console.log('click', edge); -const onPaneClick = (event: ReactMouseEvent) => - console.log('onPaneClick', event); +const onNodeDragStart = (_: ReactMouseEvent, node: Node) => console.log('drag start', node); +const onNodeDragStop = (_: ReactMouseEvent, node: Node) => console.log('drag stop', node); +const onNodeClick = (_: ReactMouseEvent, node: Node) => console.log('click', node); +const onEdgeClick = (_: ReactMouseEvent, edge: Edge) => console.log('click', edge); +const onPaneClick = (event: ReactMouseEvent) => console.log('onPaneClick', event); const onPaneScroll = (event?: WheelEvent) => console.log('onPaneScroll', event); -const onPaneContextMenu = (event: ReactMouseEvent) => - console.log('onPaneContextMenu', event); -const onMoveEnd = (_: TouchEvent | MouseEvent, viewport: Viewport) => - console.log('onMoveEnd', viewport); +const onPaneContextMenu = (event: ReactMouseEvent) => console.log('onPaneContextMenu', event); +const onMoveEnd = (_: TouchEvent | MouseEvent, viewport: Viewport) => console.log('onMoveEnd', viewport); const InteractionFlow = () => { const [nodes, , onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); - const onConnect = (params: Connection | Edge) => - setEdges((els) => addEdge(params, els)); + const onConnect = (params: Connection | Edge) => setEdges((els) => addEdge(params, els)); const [isSelectable, setIsSelectable] = useState(false); const [isDraggable, setIsDraggable] = useState(false); @@ -63,15 +50,12 @@ const InteractionFlow = () => { const [zoomOnScroll, setZoomOnScroll] = useState(false); const [zoomOnPinch, setZoomOnPinch] = useState(false); const [panOnScroll, setPanOnScroll] = useState(false); - const [panOnScrollMode, setPanOnScrollMode] = useState( - PanOnScrollMode.Free - ); + const [panOnScrollMode, setPanOnScrollMode] = useState(PanOnScrollMode.Free); const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(false); const [panOnDrag, setPanOnDrag] = useState(true); const [captureZoomClick, setCaptureZoomClick] = useState(false); const [captureZoomScroll, setCaptureZoomScroll] = useState(false); - const [captureElementClick, setCaptureElementClick] = - useState(false); + const [captureElementClick, setCaptureElementClick] = useState(false); return ( { setNodeName(evt.target.value)} - /> + setNodeName(evt.target.value)} /> setNodeBg(evt.target.value)} />
- setNodeHidden(evt.target.checked)} - /> + setNodeHidden(evt.target.checked)} />
diff --git a/examples/nextjs/pages/UseKeyPress/index.tsx b/examples/nextjs/pages/UseKeyPress/index.tsx index f279a4bc..b61dad2e 100644 --- a/examples/nextjs/pages/UseKeyPress/index.tsx +++ b/examples/nextjs/pages/UseKeyPress/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useKeyPress } from '@react-flow/core'; +import { useKeyPress } from '@react-flow/bundle'; const UseKeyPressComponent = () => { const metaPressed = useKeyPress(['Meta']); diff --git a/examples/nextjs/pages/UseReactFlow/index.tsx b/examples/nextjs/pages/UseReactFlow/index.tsx index 0a7f6c0a..e60428d4 100644 --- a/examples/nextjs/pages/UseReactFlow/index.tsx +++ b/examples/nextjs/pages/UseReactFlow/index.tsx @@ -11,7 +11,7 @@ import { Edge, useNodesState, useEdgesState, -} from '@react-flow/renderer'; +} from '@react-flow/bundle'; const initialNodes: Node[] = [ { @@ -53,8 +53,7 @@ const getId = () => `${id++}`; const UseZoomPanHelperFlow = () => { const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges); - const onConnect = (params: Connection | Edge) => - setEdges((eds) => addEdge(params, eds)); + const onConnect = (params: Connection | Edge) => setEdges((eds) => addEdge(params, eds)); const { project, setCenter, @@ -117,10 +116,7 @@ const UseZoomPanHelperFlow = () => { addEdges({ id: 'e3-4', source: '3', target: '4' }); }, [addEdges]); - const onResetNodes = useCallback( - () => setNodesHook(initialNodes), - [setNodesHook] - ); + const onResetNodes = useCallback(() => setNodesHook(initialNodes), [setNodesHook]); return ( {
- + diff --git a/examples/nextjs/pages/UseUpdateNodeInternals/CustomNode.tsx b/examples/nextjs/pages/UseUpdateNodeInternals/CustomNode.tsx index f93ebc3d..38ee4af1 100644 --- a/examples/nextjs/pages/UseUpdateNodeInternals/CustomNode.tsx +++ b/examples/nextjs/pages/UseUpdateNodeInternals/CustomNode.tsx @@ -1,5 +1,5 @@ import React, { memo, FC, useMemo, CSSProperties } from 'react'; -import { Handle, Position, NodeProps } from '@react-flow/core'; +import { Handle, Position, NodeProps } from '@react-flow/bundle'; const nodeStyles: CSSProperties = { padding: 10, border: '1px solid #ddd' }; @@ -11,7 +11,7 @@ const CustomNode: FC = ({ data }) => { return ( = ({ data }) => { return (
- +
output handle count: {data.handleCount}
{handles}
diff --git a/examples/nextjs/pages/UseUpdateNodeInternals/index.tsx b/examples/nextjs/pages/UseUpdateNodeInternals/index.tsx index 511d6aaf..2598665e 100644 --- a/examples/nextjs/pages/UseUpdateNodeInternals/index.tsx +++ b/examples/nextjs/pages/UseUpdateNodeInternals/index.tsx @@ -12,7 +12,7 @@ import { Position, useNodesState, useEdgesState, -} from '@react-flow/core'; +} from '@react-flow/bundle'; import CustomNode from './CustomNode'; @@ -48,10 +48,7 @@ const getId = (): string => `${id++}`; const UpdateNodeInternalsFlow = () => { const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); const [edges, setEdges, onEdgesChange] = useEdgesState([]); - const onConnect = useCallback( - (params: Edge | Connection) => setEdges((els) => addEdge(params, els)), - [setEdges] - ); + const onConnect = useCallback((params: Edge | Connection) => setEdges((els) => addEdge(params, els)), [setEdges]); const updateNodeInternals = useUpdateNodeInternals(); const { project } = useReactFlow(); @@ -98,10 +95,7 @@ const UpdateNodeInternalsFlow = () => { ); }, [setNodes]); - const updateNode = useCallback( - () => updateNodeInternals('1'), - [updateNodeInternals] - ); + const updateNode = useCallback(() => updateNodeInternals('1'), [updateNodeInternals]); return ( connection.target === 'B'; const CustomInput: FC = () => ( <>
Only connectable with B
- + ); const CustomNode: FC = ({ id }) => ( <> - +
{id}
- + ); diff --git a/examples/nextjs/pages/index.tsx b/examples/nextjs/pages/index.tsx index 0df7753e..bd8f0248 100755 --- a/examples/nextjs/pages/index.tsx +++ b/examples/nextjs/pages/index.tsx @@ -10,7 +10,7 @@ import { Node, Edge, useReactFlow, -} from '@react-flow/renderer'; +} from '@react-flow/bundle'; const onNodeDrag = (_: MouseEvent, node: Node) => console.log('drag', node); const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node);