fix(alignment): use OnNodeDrag (NodeDragHandler doesn't exist in @xyflow/react)
CI build failed with TS2305: NodeDragHandler is not exported. Local typecheck missed it because tsc-noEmit is more permissive than tsc -b. Use the exported OnNodeDrag<NodeType> type and alias it with our NodeData so the callback params are inferred (no implicit any).
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { useReactFlow, type Node, type NodeDragHandler } from '@xyflow/react'
|
import { useReactFlow, type Node, type OnNodeDrag } from '@xyflow/react'
|
||||||
import { computeSnap, unionBox, type Box, type Guide } from '@/utils/alignment'
|
import { computeSnap, unionBox, type Box, type Guide } from '@/utils/alignment'
|
||||||
import {
|
import {
|
||||||
type AlignmentSettings,
|
type AlignmentSettings,
|
||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
} from '@/utils/alignmentSettings'
|
} from '@/utils/alignmentSettings'
|
||||||
import type { NodeData } from '@/types'
|
import type { NodeData } from '@/types'
|
||||||
|
|
||||||
|
type NodeDrag = OnNodeDrag<Node<NodeData>>
|
||||||
|
|
||||||
function nodeBox(n: Node<NodeData>): Box | null {
|
function nodeBox(n: Node<NodeData>): Box | null {
|
||||||
// Skip nodes with a parent — alignment between absolute & parent-relative
|
// Skip nodes with a parent — alignment between absolute & parent-relative
|
||||||
// coordinates is misleading. Top-level nodes only for v1.
|
// coordinates is misleading. Top-level nodes only for v1.
|
||||||
@@ -46,7 +48,7 @@ export function useAlignmentGuides() {
|
|||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const onNodeDrag: NodeDragHandler = useCallback((_event, dragNode, dragNodes) => {
|
const onNodeDrag: NodeDrag = useCallback((_event, dragNode, dragNodes) => {
|
||||||
if (!settings.enabled || altDownRef.current) {
|
if (!settings.enabled || altDownRef.current) {
|
||||||
if (guides.length > 0) setGuides([])
|
if (guides.length > 0) setGuides([])
|
||||||
return
|
return
|
||||||
@@ -77,7 +79,7 @@ export function useAlignmentGuides() {
|
|||||||
}
|
}
|
||||||
}, [settings.enabled, settings.threshold, getNodes, setNodes, guides.length])
|
}, [settings.enabled, settings.threshold, getNodes, setNodes, guides.length])
|
||||||
|
|
||||||
const onNodeDragStop: NodeDragHandler = useCallback(() => {
|
const onNodeDragStop: NodeDrag = useCallback(() => {
|
||||||
if (guides.length > 0) setGuides([])
|
if (guides.length > 0) setGuides([])
|
||||||
}, [guides.length])
|
}, [guides.length])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user