refactor(core): remove barrel files and use auto-imports instead
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import useState from './state'
|
||||
import type {
|
||||
Actions,
|
||||
ComputedGetters,
|
||||
@@ -20,7 +19,7 @@ import type {
|
||||
State,
|
||||
} from '~/types'
|
||||
|
||||
export default (state: State, getters: ComputedGetters): Actions => {
|
||||
export function useActions(state: State, getters: ComputedGetters): Actions {
|
||||
const updateNodeInternals: Actions['updateNodeInternals'] = (ids) => {
|
||||
state.hooks.updateNodeInternals.trigger(ids)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { defaultEdgeTypes, defaultNodeTypes } from './state'
|
||||
import type { ComputedGetters, GraphEdge, GraphNode, State } from '~/types'
|
||||
import { getNodesInside, isEdgeVisible, warn } from '~/utils'
|
||||
|
||||
export default (state: State): ComputedGetters => {
|
||||
export function useGetters(state: State): ComputedGetters {
|
||||
const nodeIds = computed(() => state.nodes.map((n) => n.id))
|
||||
const edgeIds = computed(() => state.edges.map((e) => e.id))
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export const createHooks = (): FlowHooks => ({
|
||||
updateNodeInternals: createEventHook(),
|
||||
})
|
||||
|
||||
export default (emit: Emits, hooks: Ref<FlowHooks>) => {
|
||||
export function useHooks(emit: Emits, hooks: Ref<FlowHooks>) {
|
||||
onBeforeMount(() => {
|
||||
for (const [key, value] of Object.entries(hooks.value)) {
|
||||
const listener = (data: any) => {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export { default as useHooks, createHooks } from './hooks'
|
||||
export { default as useActions } from './actions'
|
||||
export { default as useState, defaultEdgeTypes, defaultNodeTypes } from './state'
|
||||
export { default as useGetters } from './getters'
|
||||
@@ -121,7 +121,7 @@ const defaultState = (): State => ({
|
||||
vueFlowVersion: typeof __VUE_FLOW_VERSION__ !== 'undefined' ? __VUE_FLOW_VERSION__ : '-',
|
||||
})
|
||||
|
||||
export default (opts?: FlowOptions): State => {
|
||||
export function useState(opts?: FlowOptions): State {
|
||||
const state = defaultState()
|
||||
if (opts) {
|
||||
Object.keys(opts).forEach((o) => {
|
||||
|
||||
Reference in New Issue
Block a user