diff --git a/packages/react/src/hooks/useReactFlow.ts b/packages/react/src/hooks/useReactFlow.ts index da65a4e3..70f5e203 100644 --- a/packages/react/src/hooks/useReactFlow.ts +++ b/packages/react/src/hooks/useReactFlow.ts @@ -178,7 +178,7 @@ export default function useReactFlow(): ReactFlo const getNodeRect = useCallback( ( - nodeOrRect: (Partial> & { id: Node['id'] }) | Rect + nodeOrRect: Node | { id: Node['id'] } | Rect ): [Rect | null, Node | null | undefined, boolean] => { const isRect = isRectObject(nodeOrRect); const node = isRect ? null : store.getState().nodes.find((n) => n.id === nodeOrRect.id); diff --git a/packages/react/src/types/instance.ts b/packages/react/src/types/instance.ts index 3d123c1a..f229ec87 100644 --- a/packages/react/src/types/instance.ts +++ b/packages/react/src/types/instance.ts @@ -10,8 +10,8 @@ export type ReactFlowJsonObject = { }; export type DeleteElementsOptions = { - nodes?: (Partial & { id: Node['id'] })[]; - edges?: (Partial & { id: Edge['id'] })[]; + nodes?: (Node | { id: Node['id'] })[]; + edges?: (Edge | { id: Edge['id'] })[]; }; export namespace Instance { @@ -33,18 +33,18 @@ export namespace Instance { deletedEdges: Edge[]; }; export type GetIntersectingNodes = ( - node: (Partial> & { id: Node['id'] }) | Rect, + node: Node | { id: Node['id'] } | Rect, partially?: boolean, nodes?: Node[] ) => Node[]; export type IsNodeIntersecting = ( - node: (Partial> & { id: Node['id'] }) | Rect, + node: Node | { id: Node['id'] } | Rect, area: Rect, partially?: boolean ) => boolean; - export type getConnectedEdges = (id: string | (Partial & { id: Node['id'] })[]) => Edge[]; - export type getIncomers = (node: string | (Partial & { id: Node['id'] })) => Node[]; - export type getOutgoers = (node: string | (Partial & { id: Node['id'] })) => Node[]; + export type getConnectedEdges = (id: string | (Node | { id: Node['id'] })[]) => Edge[]; + export type getIncomers = (node: string | Node | { id: Node['id'] }) => Node[]; + export type getOutgoers = (node: string | Node | { id: Node['id'] }) => Node[]; } export type ReactFlowInstance = { diff --git a/packages/svelte/src/lib/hooks/useSvelteFlow.ts b/packages/svelte/src/lib/hooks/useSvelteFlow.ts index 756b856c..d4a832d9 100644 --- a/packages/svelte/src/lib/hooks/useSvelteFlow.ts +++ b/packages/svelte/src/lib/hooks/useSvelteFlow.ts @@ -31,26 +31,26 @@ export function useSvelteFlow(): { getViewport: () => Viewport; fitView: (options?: FitViewOptions) => void; getIntersectingNodes: ( - nodeOrRect: (Partial & { id: Node['id'] }) | Rect, + nodeOrRect: Node | { id: Node['id'] } | Rect, partially?: boolean, nodesToIntersect?: Node[] ) => Node[]; isNodeIntersecting: ( - nodeOrRect: (Partial & { id: Node['id'] }) | Rect, + nodeOrRect: Node | { id: Node['id'] } | Rect, area: Rect, partially?: boolean ) => boolean; fitBounds: (bounds: Rect, options?: FitBoundsOptions) => void; deleteElements: ( - nodesToRemove?: Partial & { id: string }[], - edgesToRemove?: Partial & { id: string }[] + nodesToRemove?: (Node | { id: Node['id'] })[], + edgesToRemove?: (Edge | { id: Edge['id'] })[] ) => { deletedNodes: Node[]; deletedEdges: Edge[] }; screenToFlowCoordinate: (position: XYPosition) => XYPosition; flowToScreenCoordinate: (position: XYPosition) => XYPosition; viewport: Writable; - getConnectedEdges: (id: string | (Partial & { id: Node['id'] })[]) => Edge[]; - getIncomers: (node: string | (Partial & { id: Node['id'] })) => Node[]; - getOutgoers: (node: string | (Partial & { id: Node['id'] })) => Node[]; + getConnectedEdges: (id: string | (Node | { id: Node['id'] })[]) => Edge[]; + getIncomers: (node: string | Node | { id: Node['id'] }) => Node[]; + getOutgoers: (node: string | Node | { id: Node['id'] }) => Node[]; } { const { zoomIn, @@ -69,7 +69,7 @@ export function useSvelteFlow(): { } = useStore(); const getNodeRect = ( - nodeOrRect: (Partial & { id: Node['id'] }) | Rect + nodeOrRect: Node | { id: Node['id'] } | Rect ): [Rect | null, Node | null | undefined, boolean] => { const isRect = isRectObject(nodeOrRect); const node = isRect ? null : get(nodes).find((n) => n.id === nodeOrRect.id); @@ -136,7 +136,7 @@ export function useSvelteFlow(): { ); }, getIntersectingNodes: ( - nodeOrRect: (Partial & { id: Node['id'] }) | Rect, + nodeOrRect: Node | { id: Node['id'] } | Rect, partially = true, nodesToIntersect?: Node[] ) => { @@ -155,11 +155,11 @@ export function useSvelteFlow(): { const overlappingArea = getOverlappingArea(currNodeRect, nodeRect); const partiallyVisible = partially && overlappingArea > 0; - return partiallyVisible || overlappingArea >= nodeOrRect.width! * nodeOrRect.height!; + return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height; }); }, isNodeIntersecting: ( - nodeOrRect: (Partial & { id: Node['id'] }) | Rect, + nodeOrRect: Node | { id: Node['id'] } | Rect, area: Rect, partially = true ) => { @@ -172,11 +172,11 @@ export function useSvelteFlow(): { const overlappingArea = getOverlappingArea(nodeRect, area); const partiallyVisible = partially && overlappingArea > 0; - return partiallyVisible || overlappingArea >= nodeOrRect.width! * nodeOrRect.height!; + return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height; }, deleteElements: ( - nodesToRemove: Partial & { id: string }[] = [], - edgesToRemove: Partial & { id: string }[] = [] + nodesToRemove: (Node | { id: Node['id'] })[] = [], + edgesToRemove: (Edge | { id: Edge['id'] })[] = [] ) => { const _nodes = get(nodes); const _edges = get(edges); diff --git a/packages/svelte/src/lib/types/edges.ts b/packages/svelte/src/lib/types/edges.ts index 3f65be9c..33f0d908 100644 --- a/packages/svelte/src/lib/types/edges.ts +++ b/packages/svelte/src/lib/types/edges.ts @@ -39,6 +39,8 @@ export type Edge = export type EdgeProps = Omit & EdgePosition & { + markerStart?: string; + markerEnd?: string; sourceHandleId?: string | null; targetHandleId?: string | null; }; diff --git a/packages/system/src/types/general.ts b/packages/system/src/types/general.ts index d23dee9b..bc86442d 100644 --- a/packages/system/src/types/general.ts +++ b/packages/system/src/types/general.ts @@ -63,7 +63,7 @@ export type FitViewOptionsBase = { minZoom?: number; maxZoom?: number; duration?: number; - nodes?: (Partial & { id: NodeType['id'] })[]; + nodes?: (NodeType | { id: NodeType['id'] })[]; }; export type Viewport = { diff --git a/packages/system/src/utils/graph.ts b/packages/system/src/utils/graph.ts index 17467503..d9ef7163 100644 --- a/packages/system/src/utils/graph.ts +++ b/packages/system/src/utils/graph.ts @@ -35,7 +35,7 @@ export const isNodeBase = 'id' in element && !('source' in element) && !('target' in element); export const getOutgoersBase = ( - node: Partial & { id: string }, + node: NodeType | { id: string }, nodes: NodeType[], edges: EdgeType[] ): NodeType[] => { @@ -54,7 +54,7 @@ export const getOutgoersBase = ( - node: Partial & { id: string }, + node: NodeType | { id: string }, nodes: NodeType[], edges: EdgeType[] ): NodeType[] => {