diff --git a/examples/nextjs/package.json b/examples/nextjs/package.json
index 65430d75..bafc5537 100644
--- a/examples/nextjs/package.json
+++ b/examples/nextjs/package.json
@@ -3,18 +3,15 @@
"version": "0.1.0",
"private": true,
"scripts": {
- "dev": "yarn run copystyles && next dev",
- "copystyles": "cp ../../packages/core/src/styles/theme-default.css ./styles/theme-default.css",
+ "dev": "next dev",
+ "copystyles": "cp ../../node_modules/@react-flow/renderer/dist/style.css ./styles/rf-style.css",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@preconstruct/next": "^4.0.0",
- "@react-flow/background": "11.0.0",
- "@react-flow/controls": "11.0.0",
- "@react-flow/core": "11.0.0",
- "@react-flow/minimap": "11.0.0",
+ "@react-flow/bundle": "11.0.0",
"dagre": "^0.8.5",
"localforage": "^1.10.0",
"next": "12.2.2",
@@ -27,6 +24,7 @@
"eslint-config-next": "12.2.2",
"postcss": "^8.4.16",
"postcss-flexbugs-fixes": "^5.0.2",
+ "postcss-import": "^14.1.0",
"postcss-nested": "^5.0.6",
"postcss-preset-env": "^7.7.2"
}
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 (
{