fix(flow): store & usevueflow types
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import useVueFlow from './useVueFlow'
|
||||
import { getHostForElement } from '~/utils'
|
||||
import { Connection, ConnectionMode, HandleType, FlowStore, ValidConnectionFunc } from '~/types'
|
||||
import { Connection, ConnectionMode, HandleType, Store, ValidConnectionFunc } from '~/types'
|
||||
|
||||
type Result = {
|
||||
elementBelow: Element | null
|
||||
@@ -67,7 +67,7 @@ const resetRecentHandle = (hoveredHandle: Element): void => {
|
||||
hoveredHandle?.classList.remove('vue-flow__handle-connecting')
|
||||
}
|
||||
|
||||
export default (store: FlowStore = useVueFlow().store) => {
|
||||
export default (store: Store = useVueFlow().store) => {
|
||||
let recentHoveredHandle: Element
|
||||
|
||||
const onMouseDown = (
|
||||
|
||||
@@ -30,14 +30,12 @@ export class Storage {
|
||||
|
||||
public create(id: string, options?: Partial<FlowOptions>) {
|
||||
const store = useStore(options)
|
||||
const flow = {
|
||||
const flow: UseVueFlow = {
|
||||
id,
|
||||
store: reactive(store),
|
||||
store,
|
||||
...(store as any),
|
||||
...toRefs(store.state),
|
||||
...store.getters,
|
||||
...store.actions,
|
||||
...store.hooksOn,
|
||||
} as unknown as UseVueFlow
|
||||
}
|
||||
this.set(id, flow)
|
||||
return flow
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ import { zoomIdentity } from 'd3-zoom'
|
||||
import useVueFlow from './useVueFlow'
|
||||
import useWindow from './useWindow'
|
||||
import { getRectOfNodes, pointToRendererPoint, getTransformForBounds } from '~/utils'
|
||||
import { GraphNode, FlowStore, UseZoomPanHelper, D3Selection } from '~/types'
|
||||
import { GraphNode, Store, UseZoomPanHelper, D3Selection } from '~/types'
|
||||
|
||||
const DEFAULT_PADDING = 0.1
|
||||
|
||||
const transition = (selection: D3Selection, ms = 0) => selection.transition().duration(ms)
|
||||
|
||||
export default (store: FlowStore = useVueFlow().store): UseZoomPanHelper => ({
|
||||
export default (store: Store = useVueFlow().store): UseZoomPanHelper => ({
|
||||
zoomIn: (options) => store.d3Selection && store.d3Zoom?.scaleBy(transition(store.d3Selection, options?.duration), 1.2),
|
||||
zoomOut: (options) => store.d3Selection && store.d3Zoom?.scaleBy(transition(store.d3Selection, options?.duration), 1 / 1.2),
|
||||
zoomTo: (zoomLevel, options) =>
|
||||
|
||||
Reference in New Issue
Block a user