feat(svelte): add SvelteFlowProvider and useSvelteFlow hook

This commit is contained in:
moklick
2023-03-08 20:17:33 +01:00
parent 71cdc0ff02
commit 7bd8032ea4
19 changed files with 202 additions and 46 deletions
+6 -6
View File
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { Selection as D3Selection } from 'd3';
import { zoomIdentity } from 'd3-zoom';
import { boxToRect, clamp, devWarn, getBoundsOfBoxes, getOverlappingArea, rectToBox } from './utils';
@@ -11,10 +10,11 @@ import {
type XYPosition,
type Rect,
type NodeOrigin,
BaseNode,
BaseEdge,
FitViewParamsBase,
FitViewOptionsBase,
type BaseNode,
type BaseEdge,
type FitViewParamsBase,
type FitViewOptionsBase,
type D3SelectionInstance,
} from '@reactflow/system';
export const isEdgeBase = <NodeType extends BaseNode = BaseNode, EdgeType extends BaseEdge = BaseEdge>(
@@ -304,7 +304,7 @@ export const getTransformForBounds = (
return [x, y, clampedZoom];
};
export const getD3Transition = (selection: D3Selection<Element, unknown, null, undefined>, duration = 0) => {
export const getD3Transition = (selection: D3SelectionInstance, duration = 0) => {
return selection.transition().duration(duration);
};