update(types): Rename FlowStore to Store and ReactiveFlowStore to FlowStore
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import useStore from './useStore'
|
||||
import { getHostForElement } from '~/utils'
|
||||
import { Connection, ConnectionMode, ElementId, HandleType, ReactiveFlowStore, ValidConnectionFunc } from '~/types'
|
||||
import { Connection, ConnectionMode, ElementId, HandleType, FlowStore, 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: ReactiveFlowStore = useStore()) =>
|
||||
export default (store: FlowStore = useStore()) =>
|
||||
(
|
||||
event: MouseEvent,
|
||||
handleId: ElementId,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EmitFunc, FlowHooks, FlowEvents, FlowStore, ReactiveFlowStore } from '~/types'
|
||||
import { EmitFunc, FlowHooks, FlowEvents, FlowStore } from '~/types'
|
||||
|
||||
// flow event hooks
|
||||
export const createHooks = (): FlowHooks => ({
|
||||
@@ -49,4 +49,4 @@ const bind = (emit: EmitFunc, hooks: FlowHooks) => {
|
||||
}
|
||||
}
|
||||
|
||||
export default (store: ReactiveFlowStore, emit: EmitFunc) => bind(emit, store.hooks)
|
||||
export default (store: FlowStore, emit: EmitFunc) => bind(emit, store.hooks)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FlowExportObject, FlowOptions, FlowState, ReactiveFlowStore } from '~/types'
|
||||
import { FlowExportObject, FlowOptions, FlowState, FlowStore } from '~/types'
|
||||
import { useNewStore } from '~/store'
|
||||
import { Store } from '~/context'
|
||||
import { StoreSymbol } from '~/context'
|
||||
import { onLoadToObject, initialState } from '~/utils'
|
||||
|
||||
let id = 0
|
||||
@@ -35,12 +35,12 @@ export const createStore = (options?: FlowOptions) => {
|
||||
return store
|
||||
}
|
||||
|
||||
export default (options?: FlowOptions): ReactiveFlowStore => {
|
||||
let store = options?.id ? createStore(options) : inject(Store, undefined)
|
||||
export default (options?: FlowOptions): FlowStore => {
|
||||
let store = options?.id ? createStore(options) : inject(StoreSymbol, undefined)
|
||||
if (!store) {
|
||||
store = createStore(options)
|
||||
}
|
||||
provide(Store, store)
|
||||
provide(StoreSymbol, store)
|
||||
|
||||
return reactive(store)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import useStore from './useStore'
|
||||
import useHooks from './useHooks'
|
||||
import { EmitFunc, ReactiveFlowStore } from '~/types'
|
||||
import { EmitFunc, FlowStore } from '~/types'
|
||||
|
||||
let key = 0
|
||||
export const initFlow = (emit: EmitFunc, id = `vue-flow-${key++}`): ReactiveFlowStore => {
|
||||
export const initFlow = (emit: EmitFunc, id = `vue-flow-${key++}`): FlowStore => {
|
||||
const store = useStore({ id })
|
||||
useHooks(store, emit)
|
||||
return store
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { zoomIdentity } from 'd3-zoom'
|
||||
import useStore from './useStore'
|
||||
import { getRectOfNodes, pointToRendererPoint, getTransformForBounds, isGraphNode } from '~/utils'
|
||||
import { FitViewParams, FlowTransform, GraphNode, ReactiveFlowStore, Rect, UseZoomPanHelper, XYPosition } from '~/types'
|
||||
import { FitViewParams, FlowTransform, GraphNode, FlowStore, Rect, UseZoomPanHelper, XYPosition } from '~/types'
|
||||
|
||||
const DEFAULT_PADDING = 0.1
|
||||
|
||||
export default (store: ReactiveFlowStore = useStore()): UseZoomPanHelper => {
|
||||
export default (store: FlowStore = useStore()): UseZoomPanHelper => {
|
||||
return {
|
||||
zoomIn: () => store.d3Selection && store.d3Zoom?.scaleBy(store.d3Selection, 1.2),
|
||||
zoomOut: () => store.d3Selection && store.d3Zoom?.scaleBy(store.d3Selection, 1 / 1.2),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { InjectionKey } from 'vue'
|
||||
import { ElementId, FlowStore } from '~/types'
|
||||
import { ElementId, Store as TStore } from '~/types'
|
||||
|
||||
export const Store: InjectionKey<FlowStore> = Symbol('store')
|
||||
export const StoreSymbol: InjectionKey<TStore> = Symbol('store')
|
||||
export const NodeId: InjectionKey<ElementId> = Symbol('nodeId')
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import useState from './state'
|
||||
import useActions from './actions'
|
||||
import useGetters from './getters'
|
||||
import { FlowState, FlowStore } from '~/types'
|
||||
import { FlowState, Store } from '~/types'
|
||||
|
||||
export default (id: string, preloadedState: FlowState): FlowStore => {
|
||||
export default (id: string, preloadedState: FlowState): Store => {
|
||||
const state = reactive(useState(preloadedState))
|
||||
const getters = useGetters(state)
|
||||
const actions = useActions(state, getters)
|
||||
|
||||
+2
-2
@@ -89,5 +89,5 @@ export interface FlowGetters {
|
||||
getSelectedNodes: ComputedRef<GraphNode[]>
|
||||
}
|
||||
|
||||
export type FlowStore = { state: FlowState } & ToRefs<FlowState> & FlowActions & FlowGetters
|
||||
export type ReactiveFlowStore = UnwrapNestedRefs<FlowStore>
|
||||
export type Store = { state: FlowState } & ToRefs<FlowState> & FlowActions & FlowGetters
|
||||
export type FlowStore = UnwrapNestedRefs<Store>
|
||||
|
||||
+3
-4
@@ -11,12 +11,11 @@ import {
|
||||
FlowExportObject,
|
||||
NodeExtent,
|
||||
Dimensions,
|
||||
FlowStore,
|
||||
GraphNode,
|
||||
FlowElements,
|
||||
GraphEdge,
|
||||
NextElements,
|
||||
ReactiveFlowStore,
|
||||
FlowStore,
|
||||
FlowState,
|
||||
} from '~/types'
|
||||
import { useWindow } from '~/composables'
|
||||
@@ -163,7 +162,7 @@ export const pointToRendererPoint = (
|
||||
return position
|
||||
}
|
||||
|
||||
export const onLoadProject = (currentStore: ReactiveFlowStore) => (position: XYPosition) =>
|
||||
export const onLoadProject = (currentStore: FlowStore) => (position: XYPosition) =>
|
||||
pointToRendererPoint(position, currentStore.transform, currentStore.snapToGrid, currentStore.snapGrid)
|
||||
|
||||
export const parseNode = (node: Node, nodeExtent: NodeExtent): GraphNode => ({
|
||||
@@ -278,7 +277,7 @@ export const getConnectedEdges = (nodes: GraphNode[], edges: GraphEdge[]) => {
|
||||
return edges.filter((edge) => nodeIds.includes(edge.source) || nodeIds.includes(edge.target))
|
||||
}
|
||||
|
||||
export const onLoadGetElements = (currentStore: ReactiveFlowStore) => (): FlowElements => currentStore.elements
|
||||
export const onLoadGetElements = (currentStore: FlowStore) => (): FlowElements => currentStore.elements
|
||||
|
||||
export const onLoadToObject = (currentStore: FlowState) => (): FlowExportObject => {
|
||||
// we have to stringify/parse so objects containing refs (like nodes and edges) can potentially be saved in a storage
|
||||
|
||||
Reference in New Issue
Block a user