chore(examples): only use bundle

This commit is contained in:
moklick
2022-08-09 18:55:32 +02:00
parent affae72f7e
commit 0f835a2961
48 changed files with 194 additions and 513 deletions
@@ -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<ConnectionLineComponentProps> = ({
return (
<g>
<path
fill='none'
stroke='#222'
strokeWidth={1.5}
className='animated'
d={d}
/>
<circle
cx={targetX}
cy={targetY}
fill='#fff'
r={3}
stroke='#222'
strokeWidth={1.5}
/>
<path fill="none" stroke="#222" strokeWidth={1.5} className="animated" d={d} />
<circle cx={targetX} cy={targetY} fill="#fff" r={3} stroke="#222" strokeWidth={1.5} />
</g>
);
};
@@ -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<EdgeProps> = ({ 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<EdgeProps> = ({ id, source, target, style }) => {
});
return (
<g className='react-flow__connection'>
<path
id={id}
className='react-flow__edge-path'
d={d}
style={style as CSSProperties}
/>
<g className="react-flow__connection">
<path id={id} className="react-flow__edge-path" d={d} style={style as CSSProperties} />
</g>
);
};
@@ -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: [] };
+2 -5
View File
@@ -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 {