feat(core,composables): add useNodesInitialized composable

This commit is contained in:
braks
2024-02-15 17:46:21 +01:00
committed by Braks
parent eb78f77c72
commit f2165afe6f
3 changed files with 33 additions and 0 deletions
@@ -0,0 +1,26 @@
import { computed } from 'vue'
import { useVueFlow } from './useVueFlow'
export interface UseNodesInitializedOptions {
includeHiddenNodes?: boolean
}
export function useNodesInitialized(options: UseNodesInitializedOptions = { includeHiddenNodes: false }) {
const { nodes } = useVueFlow()
return computed(() => {
if (nodes.value.length === 0) {
return false
}
for (const node of nodes.value) {
if (options.includeHiddenNodes || !node.hidden) {
if (node?.handleBounds === undefined) {
return false
}
}
}
return true
})
}