update useNodeConnections

This commit is contained in:
peterkogo
2025-01-09 16:15:10 +01:00
11 changed files with 98 additions and 78 deletions
@@ -12,7 +12,7 @@ function CustomHandle({ nodeId, ...handleProps }: HandleProps & { nodeId: string
[nodeId]
);
const connections = useNodeConnections({
type: handleProps.type,
handleType: handleProps.type,
handleId: handleProps.id,
onConnect,
onDisconnect,
@@ -15,7 +15,7 @@ function CustomHandle({ nodeId, ...handleProps }: HandleProps & { nodeId: string
[nodeId]
);
const connections = useNodeConnections({
type: handleProps.type,
handleType: handleProps.type,
handleId: handleProps.id,
onConnect,
onDisconnect,
@@ -4,7 +4,7 @@ import { isTextNode, type MyNode } from '.';
function ResultNode() {
const connections = useNodeConnections({
type: 'target',
handleType: 'target',
});
const nodesData = useNodesData<MyNode>(connections.map((connection) => connection.source));
const textNodes = nodesData.filter(isTextNode);
@@ -5,7 +5,7 @@ import { isTextNode, type TextNode, type MyNode } from '.';
function UppercaseNode({ id }: NodeProps) {
const { updateNodeData } = useReactFlow();
const connections = useNodeConnections({
type: 'target',
handleType: 'target',
});
const nodesData = useNodesData<MyNode>(connections[0]?.source);
const textNode = isTextNode(nodesData) ? nodesData : null;
@@ -11,8 +11,8 @@
let { id }: NodeProps = $props();
const connections = useNodeConnections({
nodeId: id,
type: 'target'
id: id,
handleType: 'target'
});
let nodeData = $derived(
@@ -15,8 +15,8 @@
const { updateNodeData } = useSvelteFlow();
const connections = useNodeConnections({
nodeId: id,
type: 'target'
id: id,
handleType: 'target'
});
let nodeData = $derived(useNodesData<MyNode>(connections.current[0]?.source));