chore: lint files

This commit is contained in:
Braks
2022-05-11 22:10:40 +02:00
parent 447d24c5a8
commit 22845c210d
133 changed files with 461 additions and 381 deletions
+4 -3
View File
@@ -57,9 +57,6 @@ A simple setup could look like this:
```vue ```vue
<!-- Flowchart.vue --> <!-- Flowchart.vue -->
<template>
<VueFlow v-model="elements"></VueFlow>
</template>
<script setup> <script setup>
import { VueFlow } from '@braks/vue-flow' import { VueFlow } from '@braks/vue-flow'
@@ -81,6 +78,10 @@ const elements = ref([
}, },
]) ])
</script> </script>
<template>
<VueFlow v-model="elements"></VueFlow>
</template>
``` ```
### __Make sure to import the necessary styles:__ ### __Make sure to import the necessary styles:__
+1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import Heart from '~icons/mdi/heart' import Heart from '~icons/mdi/heart'
</script> </script>
<template> <template>
<div id="acknowledgement" class="w-full bg-black text-white border-y-1 border-white"> <div id="acknowledgement" class="w-full bg-black text-white border-y-1 border-white">
<div class="max-w-11/12 md:max-w-6/12 m-auto py-4 md:(pb-12 pt-6) text-center"> <div class="max-w-11/12 md:max-w-6/12 m-auto py-4 md:(pb-12 pt-6) text-center">
+1
View File
@@ -6,6 +6,7 @@ import Download from '~icons/carbon/download'
const githubData = await $fetch('https://api.github.com/repos/bcakmakoglu/vue-flow?page=$i&per_page=100') const githubData = await $fetch('https://api.github.com/repos/bcakmakoglu/vue-flow?page=$i&per_page=100')
const npmData = await $fetch('https://api.npmjs.org/downloads/point/last-month/@braks/vue-flow') const npmData = await $fetch('https://api.npmjs.org/downloads/point/last-month/@braks/vue-flow')
</script> </script>
<template> <template>
<div class="w-full bg-black text-white border-b-1 border-white"> <div class="w-full bg-black text-white border-b-1 border-white">
<div class="max-w-full md:max-w-11/12 m-auto py-4 md:py-12 <md:(dark:border-t-1 border-white)"> <div class="max-w-full md:max-w-11/12 m-auto py-4 md:py-12 <md:(dark:border-t-1 border-white)">
+4 -2
View File
@@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, watch } from 'vue' import { reactive, watch } from 'vue'
import { useBreakpoints, breakpointsTailwind } from '@vueuse/core' import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
import { FlowInstance } from '@braks/vue-flow' import type { FlowInstance } from '@braks/vue-flow'
const breakpoints = useBreakpoints(breakpointsTailwind) const breakpoints = useBreakpoints(breakpointsTailwind)
@@ -22,6 +22,7 @@ watch([breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoin
}, 5), }, 5),
) )
</script> </script>
<template> <template>
<div class="w-full dark:(bg-black text-white)"> <div class="w-full dark:(bg-black text-white)">
<div <div
@@ -42,6 +43,7 @@ watch([breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoin
</div> </div>
</div> </div>
</template> </template>
<style> <style>
.button { .button {
@apply z-1 shadow-lg transition-colors duration-200 text-white font-semibold text-lg mt-4 px-5 py-3 rounded-lg bg-green-500; @apply z-1 shadow-lg transition-colors duration-200 text-white font-semibold text-lg mt-4 px-5 py-3 rounded-lg bg-green-500;
+3 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useBreakpoints, breakpointsTailwind } from '@vueuse/core' import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
import Blobity from 'blobity' import Blobity from 'blobity'
import Intro from './flows/Intro.vue' import Intro from './flows/Intro.vue'
@@ -29,11 +29,13 @@ onMounted(() => {
} }
}) })
</script> </script>
<template> <template>
<div class="relative h-[90vh] md:h-[75vh]"> <div class="relative h-[90vh] md:h-[75vh]">
<Intro /> <Intro />
</div> </div>
</template> </template>
<style> <style>
button:focus { button:focus {
outline: none; outline: none;
+5 -7
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed } from 'vue' import { computed } from 'vue'
import { MarkerType, getBezierPath, Position, EdgeProps } from '@braks/vue-flow' import type { EdgeProps, MarkerType, Position } from '@braks/vue-flow'
import { getBezierPath } from '@braks/vue-flow'
interface CustomEdgeProps extends EdgeProps { interface CustomEdgeProps extends EdgeProps {
source: string source: string
@@ -33,11 +34,13 @@ const edgePath = computed(() =>
}), }),
) )
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<path <path
:id="props.id" :id="props.id"
@@ -47,12 +50,7 @@ export default {
:marker-end="props.markerEnd" :marker-end="props.markerEnd"
/> />
<text> <text>
<textPath <textPath :href="`#${props.id}`" :style="{ fontSize: '1.25rem', fill: 'white' }" startOffset="50%" text-anchor="middle">
:href="`#${props.id}`"
:style="{ fontSize: '1.25rem', fill: 'white' }"
startOffset="50%"
text-anchor="middle"
>
{{ props.data?.text }} {{ props.data?.text }}
</textPath> </textPath>
</text> </text>
+5 -3
View File
@@ -1,6 +1,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref } from 'vue'
import { Position, Elements, VueFlow, Controls, MiniMap, Background, useVueFlow } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { Background, Controls, MiniMap, Position, VueFlow, useVueFlow } from '@braks/vue-flow'
const emit = defineEmits(['pane'])
const elements = ref<Elements>([ const elements = ref<Elements>([
{ {
@@ -77,8 +80,6 @@ const elements = ref<Elements>([
{ id: 'e6-8', type: 'step', source: '7', target: '8', animated: true }, { id: 'e6-8', type: 'step', source: '7', target: '8', animated: true },
]) ])
const emit = defineEmits(['pane'])
const { onPaneReady } = useVueFlow({ const { onPaneReady } = useVueFlow({
modelValue: elements.value, modelValue: elements.value,
zoomOnScroll: false, zoomOnScroll: false,
@@ -87,6 +88,7 @@ const { onPaneReady } = useVueFlow({
onPaneReady((i) => emit('pane', i)) onPaneReady((i) => emit('pane', i))
</script> </script>
<template> <template>
<div class="w-full h-[300px] md:min-h-[400px] shadow-xl rounded-xl font-mono uppercase overflow-hidden border-2"> <div class="w-full h-[300px] md:min-h-[400px] shadow-xl rounded-xl font-mono uppercase overflow-hidden border-2">
<VueFlow> <VueFlow>
+3 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useVueFlow, VueFlow, Handle, Position } from '@braks/vue-flow' import { Handle, Position, VueFlow, useVueFlow } from '@braks/vue-flow'
import { breakpointsTailwind, useBreakpoints } from '@vueuse/core' import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
import BoxNode from '../nodes/Box.vue' import BoxNode from '../nodes/Box.vue'
import Heart from '~icons/mdi/heart' import Heart from '~icons/mdi/heart'
@@ -170,6 +170,7 @@ const scrollTo = () => {
} }
} }
</script> </script>
<template> <template>
<VueFlow ref="el" class="dark:bg-black bg-white transition-colors duration-200 ease-in-out"> <VueFlow ref="el" class="dark:bg-black bg-white transition-colors duration-200 ease-in-out">
<template #node-box="props"> <template #node-box="props">
@@ -208,6 +209,7 @@ const scrollTo = () => {
</template> </template>
</VueFlow> </VueFlow>
</template> </template>
<style> <style>
.intro { .intro {
@apply cursor-pointer @apply cursor-pointer
+5 -3
View File
@@ -1,11 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ConnectionMode, useVueFlow, VueFlow, Background, Controls } from '@braks/vue-flow' import { Background, ConnectionMode, Controls, VueFlow, useVueFlow } from '@braks/vue-flow'
import { breakpointsTailwind } from '@vueuse/core' import { breakpointsTailwind } from '@vueuse/core'
const breakpoints = useBreakpoints(breakpointsTailwind)
const emit = defineEmits(['pane']) const emit = defineEmits(['pane'])
const breakpoints = useBreakpoints(breakpointsTailwind)
const nodeClasses = ['!normal-case font-semibold !text-white', '!border-1', 'shadow-md'].join(' ') const nodeClasses = ['!normal-case font-semibold !text-white', '!border-1', 'shadow-md'].join(' ')
const childClasses = `${nodeClasses} !bg-green-500/70 !border-white` const childClasses = `${nodeClasses} !bg-green-500/70 !border-white`
@@ -55,6 +55,7 @@ watch(
onPaneReady((i) => emit('pane', i)) onPaneReady((i) => emit('pane', i))
</script> </script>
<template> <template>
<div class="md:max-w-1/3 flex flex-col justify-center <md:pt-12"> <div class="md:max-w-1/3 flex flex-col justify-center <md:pt-12">
<div class="flex flex-col gap-2 items-center md:items-start"> <div class="flex flex-col gap-2 items-center md:items-start">
@@ -76,6 +77,7 @@ onPaneReady((i) => emit('pane', i))
</VueFlow> </VueFlow>
</div> </div>
</template> </template>
<style> <style>
.nested .vue-flow__handle { .nested .vue-flow__handle {
opacity: 0; opacity: 0;
+8 -5
View File
@@ -1,20 +1,21 @@
<script lang="ts" setup> <script lang="ts" setup>
import { BackgroundVariant, VueFlow, Background, Controls, MiniMap, MiniMapNodeFunc, useVueFlow } from '@braks/vue-flow' import type { MiniMapNodeFunc } from '@braks/vue-flow'
import { Background, BackgroundVariant, Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
import { breakpointsTailwind } from '@vueuse/core' import { breakpointsTailwind } from '@vueuse/core'
import CustomEdge from '../edges/Custom.vue' import CustomEdge from '../edges/Custom.vue'
import RGBNode from '../nodes/Input.vue' import RGBNode from '../nodes/Input.vue'
import RGBOutputNode from '../nodes/Output.vue' import RGBOutputNode from '../nodes/Output.vue'
const emit = defineEmits(['pane'])
const breakpoints = useBreakpoints(breakpointsTailwind) const breakpoints = useBreakpoints(breakpointsTailwind)
type Colors = { interface Colors {
red: number red: number
green: number green: number
blue: number blue: number
} }
const emit = defineEmits(['pane'])
const { onPaneReady, getNode, panOnDrag } = useVueFlow({ const { onPaneReady, getNode, panOnDrag } = useVueFlow({
id: 'rgb-flow', id: 'rgb-flow',
nodes: [ nodes: [
@@ -73,6 +74,7 @@ const nodeColor: MiniMapNodeFunc = (node) => {
return '' return ''
} }
</script> </script>
<template> <template>
<div <div
ref="el" ref="el"
@@ -103,7 +105,8 @@ const nodeColor: MiniMapNodeFunc = (node) => {
<div class="flex flex-col gap-2 items-center md:items-start"> <div class="flex flex-col gap-2 items-center md:items-start">
<h1>Customizable</h1> <h1>Customizable</h1>
<p> <p>
You can expand on the existing features by using your own custom nodes and edges and implement any design and functionality you want. You can expand on the existing features by using your own custom nodes and edges and implement any design and
functionality you want.
</p> </p>
<router-link class="button max-w-max" to="/guide/">Documentation</router-link> <router-link class="button max-w-max" to="/guide/">Documentation</router-link>
</div> </div>
+1
View File
@@ -3,6 +3,7 @@ import { Handle, Position } from '@braks/vue-flow'
const emit = defineEmits(['next']) const emit = defineEmits(['next'])
</script> </script>
<template> <template>
<div class="px-4 py-2 shadow-lg rounded-md border-2 border-solid border-black"> <div class="px-4 py-2 shadow-lg rounded-md border-2 border-solid border-black">
<slot /> <slot />
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Handle, NodeProps, Position } from '@braks/vue-flow' import type { NodeProps } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface RGBNodeProps extends NodeProps { interface RGBNodeProps extends NodeProps {
data: { data: {
@@ -27,6 +28,7 @@ switch (props.data?.color) {
} }
const onChange = (e: any) => emit('change', { color, val: e.target.value }) const onChange = (e: any) => emit('change', { color, val: e.target.value })
</script> </script>
<template> <template>
<div class="px-4 py-2 bg-white rounded-md border-2 border-solid border-black text-left transform scale-75 lg:scale-100"> <div class="px-4 py-2 bg-white rounded-md border-2 border-solid border-black text-left transform scale-75 lg:scale-100">
<div class="text-md" :style="{ color }">{{ `${color} Amount`.toUpperCase() }}</div> <div class="text-md" :style="{ color }">{{ `${color} Amount`.toUpperCase() }}</div>
+9 -5
View File
@@ -1,15 +1,19 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Handle, NodeProps, Position } from "@braks/vue-flow"; import type { NodeProps } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface RBGOutputNodeProps extends NodeProps { interface RBGOutputNodeProps extends NodeProps {
rgb: string; rgb: string
} }
const props = defineProps<RBGOutputNodeProps>(); const props = defineProps<RBGOutputNodeProps>()
</script> </script>
<template> <template>
<div :style="{ backgroundColor: props.rgb }" <div
class="px-6 py-2 rounded-xl text-white text-center min-w-[220px] border-2 border-white"> :style="{ backgroundColor: props.rgb }"
class="px-6 py-2 rounded-xl text-white text-center min-w-[220px] border-2 border-white"
>
<div class="text-xl font-bold">Color Output</div> <div class="text-xl font-bold">Color Output</div>
<div class="font-semibold">{{ props.rgb }}</div> <div class="font-semibold">{{ props.rgb }}</div>
<Handle type="target" :position="Position.Left" /> <Handle type="target" :position="Position.Left" />
+2 -2
View File
@@ -22,10 +22,10 @@ const nodes = [
{ {
id: '1', id: '1',
label: 'Node 1', label: 'Node 1',
position: { x: 0 , y: 0 }, position: { x: 0, y: 0 },
isValidSourcePos: (connection) => { isValidSourcePos: (connection) => {
return connection.target === '2' return connection.target === '2'
} },
}, },
] ]
``` ```
+6 -5
View File
@@ -61,16 +61,16 @@ This is how the default handle component is built:
```vue ```vue
<script lang="ts" setup> <script lang="ts" setup>
import { useHandle, useVueFlow, Position, NodeId } from '@braks/vue-flow' import { NodeId, useHandle, useVueFlow } from '@braks/vue-flow'
import type { HandleProps } from '@braks/vue-flow' import type { HandleProps, Position } from '@braks/vue-flow'
const { id, hooks, connectionStartHandle } = useVueFlow()
const props = withDefaults(defineProps<HandleProps>(), { const props = withDefaults(defineProps<HandleProps>(), {
type: 'source', type: 'source',
position: 'top' as Position, position: 'top' as Position,
connectable: true, connectable: true,
}) })
const { id, hooks, connectionStartHandle } = useVueFlow()
const nodeId = inject(NodeId, '') const nodeId = inject(NodeId, '')
const { onMouseDown, onClick } = useHandle() const { onMouseDown, onClick } = useHandle()
@@ -80,21 +80,22 @@ const onMouseDownHandler = (event: MouseEvent) =>
) )
const onClickHandler = (event: MouseEvent) => onClick(event, props.id ?? null, nodeId, props.type, props.isValidConnection) const onClickHandler = (event: MouseEvent) => onClick(event, props.id ?? null, nodeId, props.type, props.isValidConnection)
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Handle', name: 'Handle',
} }
</script> </script>
<template> <template>
<div <div
:data-handleid="props.id" :data-handleid="props.id"
:data-nodeid="nodeId" :data-nodeid="nodeId"
:data-handlepos="props.position" :data-handlepos="props.position"
class="vue-flow__handle nodrag"
:class="[ :class="[
'vue-flow__handle',
`vue-flow__handle-${props.position}`, `vue-flow__handle-${props.position}`,
`vue-flow__handle-${id}`, `vue-flow__handle-${id}`,
'nodrag',
{ {
source: props.type !== 'target', source: props.type !== 'target',
target: props.type === 'target', target: props.type === 'target',
+4 -18
View File
@@ -3,10 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"module": "ESNext", "module": "ESNext",
"target": "es2017", "target": "es2017",
"lib": [ "lib": ["DOM", "ESNext"],
"DOM",
"ESNext"
],
"noEmit": true, "noEmit": true,
"declaration": false, "declaration": false,
"strict": true, "strict": true,
@@ -18,20 +15,9 @@
"noUnusedLocals": false, "noUnusedLocals": false,
"strictNullChecks": true, "strictNullChecks": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"types": [ "types": ["vite/client", "@types/node", "unplugin-icons/types/vue"]
"vite/client",
"@types/node",
"unplugin-icons/types/vue"
]
}, },
"include": [ "include": ["components", "src", "src/.vuepress/auto-imports.d.ts"],
"components", "exclude": ["node_modules", "dist"],
"src",
"src/.vuepress/auto-imports.d.ts"
],
"exclude": [
"node_modules",
"dist"
],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }
@@ -1,4 +1,5 @@
import { useVueFlow, isEdge, isNode, Edge, Node, SetState, VueFlowStore } from '@braks/vue-flow' import type { Edge, Node, SetState, VueFlowStore } from '@braks/vue-flow'
import { isEdge, isNode, useVueFlow } from '@braks/vue-flow'
import { getElements } from '../../../../examples/src/Stress/utils' import { getElements } from '../../../../examples/src/Stress/utils'
describe('test store action setElements', () => { describe('test store action setElements', () => {
@@ -1,5 +1,6 @@
import { isRef } from 'vue' import { isRef } from 'vue'
import { useVueFlow, State } from '@braks/vue-flow' import type { State } from '@braks/vue-flow'
import { useVueFlow } from '@braks/vue-flow'
describe('test store state', () => { describe('test store state', () => {
let store = useVueFlow() let store = useVueFlow()
@@ -1,5 +1,6 @@
import { mount } from '@cypress/vue' import { mount } from '@cypress/vue'
import { VueFlow, isEdge, isNode, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { VueFlow, isEdge, isNode } from '@braks/vue-flow'
import '@braks/vue-flow/dist/style.css' import '@braks/vue-flow/dist/style.css'
import '@braks/vue-flow/dist/theme-default.css' import '@braks/vue-flow/dist/theme-default.css'
+3 -10
View File
@@ -3,10 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"module": "ESNext", "module": "ESNext",
"target": "es2017", "target": "es2017",
"lib": [ "lib": ["DOM", "ESNext"],
"DOM",
"ESNext"
],
"noEmit": true, "noEmit": true,
"declaration": false, "declaration": false,
"strict": true, "strict": true,
@@ -18,12 +15,8 @@
"noUnusedLocals": false, "noUnusedLocals": false,
"strictNullChecks": true, "strictNullChecks": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"types": [ "types": ["vite/client"]
"vite/client"
],
}, },
"include": ["cypress"], "include": ["cypress"],
"exclude": [ "exclude": ["node_modules"]
"node_modules",
],
} }
+1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import Header from './Header.vue' import Header from './Header.vue'
</script> </script>
<template> <template>
<Header /> <Header />
<router-view /> <router-view />
+1
View File
@@ -17,6 +17,7 @@ const computedRoutes = computed(() => {
})) }))
}) })
</script> </script>
<template> <template>
<header> <header>
<a class="logo" href="https://github.com/bcakmakoglu/vue-flow"> Vue Flow Dev </a> <a class="logo" href="https://github.com/bcakmakoglu/vue-flow"> Vue Flow Dev </a>
+2 -1
View File
@@ -1,4 +1,5 @@
import { createRouter, createWebHashHistory, RouterOptions } from 'vue-router' import type { RouterOptions } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'
export const routes: RouterOptions['routes'] = [ export const routes: RouterOptions['routes'] = [
{ {
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, MiniMap, Controls, Background, isNode, useVueFlow, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { Background, Controls, MiniMap, VueFlow, isNode, useVueFlow } from '@braks/vue-flow'
const elements = ref<Elements>([ const elements = ref<Elements>([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' }, { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
@@ -35,6 +36,7 @@ const logToObject = () => console.log(instance.value?.toObject())
const resetTransform = () => instance.value?.setTransform({ x: 0, y: 0, zoom: 1 }) const resetTransform = () => instance.value?.setTransform({ x: 0, y: 0, zoom: 1 })
const toggleclass = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light')) const toggleclass = () => elements.value.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
</script> </script>
<template> <template>
<VueFlow v-model="elements" class="vue-flow-basic-example"> <VueFlow v-model="elements" class="vue-flow-basic-example">
<Background /> <Background />
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { VueFlow, Background, MiniMap, Controls, Elements, FlowEvents, FlowInstance, isNode, addEdge } from '@braks/vue-flow' import type { Elements, FlowEvents, FlowInstance } from '@braks/vue-flow'
import { Background, Controls, MiniMap, VueFlow, addEdge, isNode } from '@braks/vue-flow'
export default defineComponent({ export default defineComponent({
name: 'BasicOptionsAPI', name: 'BasicOptionsAPI',
@@ -50,6 +51,7 @@ export default defineComponent({
}, },
}) })
</script> </script>
<template> <template>
<VueFlow <VueFlow
v-model="elements" v-model="elements"
+5 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Position, Handle, ValidConnectionFunc } from '@braks/vue-flow' import type { Position, ValidConnectionFunc } from '@braks/vue-flow'
import { Handle } from '@braks/vue-flow'
interface Props { interface Props {
id: string id: string
@@ -17,12 +18,14 @@ const props = withDefaults(defineProps<Props>(), {
targetPosition: 'top' as Position, targetPosition: 'top' as Position,
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'ResizableNode', name: 'ResizableNode',
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<Handle <Handle
type="target" type="target"
@@ -41,6 +44,7 @@ export default {
:is-valid-connection="props.isValidSourcePos" :is-valid-connection="props.isValidSourcePos"
/> />
</template> </template>
<style> <style>
.resize-node { .resize-node {
padding: 1rem; padding: 1rem;
@@ -7,6 +7,7 @@ interface CustomConnectionLineProps {
} }
const props = defineProps<CustomConnectionLineProps>() const props = defineProps<CustomConnectionLineProps>()
</script> </script>
<template> <template>
<g> <g>
<path <path
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Background, BackgroundVariant, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { Background, BackgroundVariant, VueFlow } from '@braks/vue-flow'
import ConnectionLine from './ConnectionLine.vue' import ConnectionLine from './ConnectionLine.vue'
const elements = ref<Elements>([ const elements = ref<Elements>([
@@ -11,6 +12,7 @@ const elements = ref<Elements>([
}, },
]) ])
</script> </script>
<template> <template>
<VueFlow v-model="elements"> <VueFlow v-model="elements">
<template #connection-line="props"> <template #connection-line="props">
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { Handle, Position, Connection, Edge, NodeProps } from '@braks/vue-flow' import type { Connection, Edge, NodeProps } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface ColorSelectorNodeProps extends NodeProps { interface ColorSelectorNodeProps extends NodeProps {
data: { data: {
@@ -16,11 +17,13 @@ const sourceHandleStyleB: CSSProperties = { ...targetHandleStyle, bottom: '10px'
const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params) const onConnect = (params: Connection | Edge) => console.log('handle onConnect', params)
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<Handle type="target" :position="Position.Left" :style="targetHandleStyle" :on-connect="onConnect" /> <Handle type="target" :position="Position.Left" :style="targetHandleStyle" :on-connect="onConnect" />
<div> <div>
+3 -12
View File
@@ -1,16 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { import type { Elements, Node, SnapGrid } from '@braks/vue-flow'
ConnectionMode, import { ConnectionMode, Controls, MiniMap, Position, VueFlow, isEdge, useVueFlow } from '@braks/vue-flow'
Controls,
Elements,
isEdge,
MiniMap,
Node,
Position,
SnapGrid,
useVueFlow,
VueFlow,
} from '@braks/vue-flow'
import ColorSelectorNode from './ColorSelectorNode.vue' import ColorSelectorNode from './ColorSelectorNode.vue'
const elements = ref<Elements>([]) const elements = ref<Elements>([])
@@ -85,6 +75,7 @@ onPaneReady((i) => {
console.log('flow loaded:', i) console.log('flow loaded:', i)
}) })
</script> </script>
<template> <template>
<VueFlow v-model="elements" :style="{ backgroundColor: bgColor }"> <VueFlow v-model="elements" :style="{ backgroundColor: bgColor }">
<template #node-selectorNode="props"> <template #node-selectorNode="props">
+4 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Node, useVueFlow } from '@braks/vue-flow' import type { Node } from '@braks/vue-flow'
import { VueFlow, useVueFlow } from '@braks/vue-flow'
import Sidebar from './Sidebar.vue' import Sidebar from './Sidebar.vue'
let id = 0 let id = 0
@@ -38,12 +39,14 @@ const onDrop = (event: DragEvent) => {
} }
} }
</script> </script>
<template> <template>
<div class="dndflow" @drop="onDrop"> <div class="dndflow" @drop="onDrop">
<VueFlow @dragover="onDragOver" /> <VueFlow @dragover="onDragOver" />
<Sidebar /> <Sidebar />
</div> </div>
</template> </template>
<style> <style>
@import 'dnd.css'; @import 'dnd.css';
</style> </style>
+1
View File
@@ -6,6 +6,7 @@ const onDragStart = (event: DragEvent, nodeType: string) => {
} }
} }
</script> </script>
<template> <template>
<aside> <aside>
<div class="description">You can drag these nodes to the pane on the left.</div> <div class="description">You can drag these nodes to the pane on the left.</div>
+3 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { FlowInstance } from '@braks/vue-flow'
import { Controls, MiniMap, VueFlow } from '@braks/vue-flow'
import { getElements } from './utils' import { getElements } from './utils'
import { VueFlow, MiniMap, Controls, FlowInstance } from '@braks/vue-flow'
const onLoad = (flowInstance: FlowInstance) => { const onLoad = (flowInstance: FlowInstance) => {
flowInstance.fitView() flowInstance.fitView()
@@ -9,6 +10,7 @@ const onLoad = (flowInstance: FlowInstance) => {
const elements = getElements() const elements = getElements()
</script> </script>
<template> <template>
<VueFlow v-model="elements" :min-zoom="0.2" @pane-ready="onLoad"> <VueFlow v-model="elements" :min-zoom="0.2" @pane-ready="onLoad">
<MiniMap /> <MiniMap />
+2 -1
View File
@@ -1,4 +1,5 @@
import { Elements, Position } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { Position } from '@braks/vue-flow'
const nodeWidth = 80 const nodeWidth = 80
const nodeGapWidth = nodeWidth * 2 const nodeGapWidth = nodeWidth * 2
+5 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getEdgeCenter, getBezierPath, Position, useVueFlow, EdgeProps } from '@braks/vue-flow' import type { EdgeProps, Position } from '@braks/vue-flow'
import { getBezierPath, getEdgeCenter, useVueFlow } from '@braks/vue-flow'
interface CustomEdgeProps<T = any> extends EdgeProps<T> { interface CustomEdgeProps<T = any> extends EdgeProps<T> {
id: string id: string
@@ -42,11 +43,13 @@ const center = computed(() =>
}), }),
) )
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<path :id="props.id" :style="props.style" class="vue-flow__edge-path" :d="edgePath" :marker-end="props.markerEnd" /> <path :id="props.id" :style="props.style" class="vue-flow__edge-path" :d="edgePath" :marker-end="props.markerEnd" />
<foreignObject <foreignObject
@@ -62,6 +65,7 @@ export default {
</body> </body>
</foreignObject> </foreignObject>
</template> </template>
<style> <style>
.edgebutton { .edgebutton {
border-radius: 999px; border-radius: 999px;
+4 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getEdgeCenter, getBezierPath, getMarkerId, Position, EdgeProps, EdgeText } from '@braks/vue-flow' import type { EdgeProps, Position } from '@braks/vue-flow'
import { EdgeText, getBezierPath, getEdgeCenter, getMarkerId } from '@braks/vue-flow'
interface CustomEdgeProps extends EdgeProps { interface CustomEdgeProps extends EdgeProps {
source: string source: string
@@ -42,11 +43,13 @@ const center = computed(() =>
) )
const onClick = () => console.log(props.data) const onClick = () => console.log(props.data)
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" /> <path :id="props.id" class="vue-flow__edge-path" :d="edgePath" :marker-end="markerEnd" />
<EdgeText <EdgeText
+1
View File
@@ -5,6 +5,7 @@ interface CustomLabelProps {
const props = defineProps<CustomLabelProps>() const props = defineProps<CustomLabelProps>()
</script> </script>
<template> <template>
<tspan dy="10" x="0">{{ props.label }}</tspan> <tspan dy="10" x="0">{{ props.label }}</tspan>
</template> </template>
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, MiniMap, Controls, Background, MarkerType, useVueFlow, Edge, Node } from '@braks/vue-flow' import type { Edge, Node } from '@braks/vue-flow'
import { Background, Controls, MarkerType, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
import CustomEdge from './CustomEdge.vue' import CustomEdge from './CustomEdge.vue'
import CustomEdge2 from './CustomEdge2.vue' import CustomEdge2 from './CustomEdge2.vue'
import CustomLabel from './CustomLabel.vue' import CustomLabel from './CustomLabel.vue'
@@ -71,6 +72,7 @@ useVueFlow({
edges: initialEdges, edges: initialEdges,
}) })
</script> </script>
<template> <template>
<VueFlow :fit-view-on-init="true" :snap-to-grid="true"> <VueFlow :fit-view-on-init="true" :snap-to-grid="true">
<template #edge-custom="props"> <template #edge-custom="props">
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, MiniMap, Controls, Background, BackgroundVariant, Node, useVueFlow } from '@braks/vue-flow' import type { Node } from '@braks/vue-flow'
import { Background, BackgroundVariant, Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
const { nodes, addNodes, edges, addEdges, onConnect, onPaneReady, onNodeDragStop, dimensions } = useVueFlow() const { nodes, addNodes, edges, addEdges, onConnect, onPaneReady, onNodeDragStop, dimensions } = useVueFlow()
@@ -17,6 +18,7 @@ const addRandomNode = () => {
addNodes([newNode]) addNodes([newNode])
} }
</script> </script>
<template> <template>
<VueFlow> <VueFlow>
<MiniMap /> <MiniMap />
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getBezierPath, GraphNode, Position } from '@braks/vue-flow' import type { GraphNode, Position } from '@braks/vue-flow'
import { getBezierPath } from '@braks/vue-flow'
import { getEdgeParams } from './floating-edge-utils' import { getEdgeParams } from './floating-edge-utils'
interface FloatingConnectionLineProps { interface FloatingConnectionLineProps {
@@ -30,6 +31,7 @@ const d = computed(() =>
}), }),
) )
</script> </script>
<template> <template>
<g> <g>
<path fill="none" stroke="#222" :stroke-width="1.5" class="animated" :d="d" /> <path fill="none" stroke="#222" :stroke-width="1.5" class="animated" :d="d" />
+4 -2
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { getBezierPath, GraphNode, EdgeProps, MarkerType } from '@braks/vue-flow' import type { EdgeProps, GraphNode, MarkerType } from '@braks/vue-flow'
import { getBezierPath } from '@braks/vue-flow'
import { getEdgeParams } from './floating-edge-utils' import { getEdgeParams } from './floating-edge-utils'
interface FloatingEdgeProps extends EdgeProps { interface FloatingEdgeProps extends EdgeProps {
@@ -33,6 +34,7 @@ const d = computed(
'', '',
) )
</script> </script>
<template> <template>
<g class="vue-flow__connection"> <g class="vue-flow__connection">
<path <path
+3 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Background, MiniMap, Controls, MarkerType, useVueFlow } from '@braks/vue-flow' import { Background, Controls, MarkerType, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
import FloatingEdge from './FloatingEdge.vue' import FloatingEdge from './FloatingEdge.vue'
import FloatingConnectionLine from './FloatingConnectionLine.vue' import FloatingConnectionLine from './FloatingConnectionLine.vue'
import { createElements } from './floating-edge-utils' import { createElements } from './floating-edge-utils'
@@ -10,6 +10,7 @@ const { addEdges, onConnect, onPaneReady, getNodes } = useVueFlow({
onPaneReady(({ fitView }) => fitView()) onPaneReady(({ fitView }) => fitView())
onConnect((params) => addEdges([{ ...params, type: 'floating', markerEnd: MarkerType.Arrow }])) onConnect((params) => addEdges([{ ...params, type: 'floating', markerEnd: MarkerType.Arrow }]))
</script> </script>
<template> <template>
<div class="floatingedges"> <div class="floatingedges">
<VueFlow> <VueFlow>
@@ -26,6 +27,7 @@ onConnect((params) => addEdges([{ ...params, type: 'floating', markerEnd: Marker
</VueFlow> </VueFlow>
</div> </div>
</template> </template>
<style> <style>
.floatingedges { .floatingedges {
flex-direction: column; flex-direction: column;
@@ -1,4 +1,5 @@
import { Position, MarkerType, XYPosition, GraphNode, Edge } from '@braks/vue-flow' import type { Edge, GraphNode, XYPosition } from '@braks/vue-flow'
import { MarkerType, Position } from '@braks/vue-flow'
// this helper function returns the intersection point // this helper function returns the intersection point
// of the line between the center of the intersectionNode and the target node // of the line between the center of the intersectionNode and the target node
+2 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, MiniMap, Controls, useVueFlow } from '@braks/vue-flow' import { Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
const isHidden = ref(false) const isHidden = ref(false)
@@ -21,6 +21,7 @@ watchEffect(() => {
edges.value.forEach((e) => (e.hidden = isHidden.value)) edges.value.forEach((e) => (e.hidden = isHidden.value))
}) })
</script> </script>
<template> <template>
<VueFlow> <VueFlow>
<MiniMap /> <MiniMap />
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, MiniMap, Controls, useVueFlow } from '@braks/vue-flow' import { Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
const { const {
nodesDraggable, nodesDraggable,
@@ -41,6 +41,7 @@ onPaneScroll((event) => captureZoomScroll.value && console.log('pane scroll', ev
onPaneContextMenu((event) => captureZoomClick && console.log('pane ctx menu', event)) onPaneContextMenu((event) => captureZoomClick && console.log('pane ctx menu', event))
onMoveEnd((flowTransform) => console.log('move end', flowTransform)) onMoveEnd((flowTransform) => console.log('move end', flowTransform))
</script> </script>
<template> <template>
<VueFlow> <VueFlow>
<MiniMap /> <MiniMap />
+4 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import dagre from 'dagre' import dagre from 'dagre'
import { VueFlow, Controls, ConnectionMode, Elements, isNode, CoordinateExtent, Position } from '@braks/vue-flow' import type { CoordinateExtent, Elements } from '@braks/vue-flow'
import { ConnectionMode, Controls, Position, VueFlow, isNode } from '@braks/vue-flow'
import initialElements from './initial-elements' import initialElements from './initial-elements'
const dagreGraph = new dagre.graphlib.Graph() const dagreGraph = new dagre.graphlib.Graph()
@@ -37,6 +38,7 @@ const onLayout = (direction: string) => {
}) })
} }
</script> </script>
<template> <template>
<div class="layoutflow"> <div class="layoutflow">
<VueFlow v-model="elements" :node-extent="nodeExtent" :connection-mode="ConnectionMode.Loose" @pane-ready="onLayout('TB')"> <VueFlow v-model="elements" :node-extent="nodeExtent" :connection-mode="ConnectionMode.Loose" @pane-ready="onLayout('TB')">
@@ -48,6 +50,7 @@ const onLayout = (direction: string) => {
</div> </div>
</div> </div>
</template> </template>
<style> <style>
@import 'layouting.css'; @import 'layouting.css';
</style> </style>
+1 -1
View File
@@ -1,4 +1,4 @@
import { Elements, XYPosition } from '@braks/vue-flow' import type { Elements, XYPosition } from '@braks/vue-flow'
const position: XYPosition = { x: 0, y: 0 } const position: XYPosition = { x: 0, y: 0 }
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Background, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { Background, VueFlow } from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' }, { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' }, { id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
@@ -11,6 +12,7 @@ const initialElements: Elements = [
const elements = ref<Elements>(initialElements) const elements = ref<Elements>(initialElements)
</script> </script>
<template> <template>
<VueFlow v-model="elements" :fit-view-on-init="true"> <VueFlow v-model="elements" :fit-view-on-init="true">
<Background /> <Background />
@@ -1,12 +1,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import Flow from './Flow.vue' import Flow from './Flow.vue'
</script> </script>
<template> <template>
<div class="vue-flow__example-multiflows"> <div class="vue-flow__example-multiflows">
<Flow /> <Flow />
<Flow /> <Flow />
</div> </div>
</template> </template>
<style> <style>
@import 'multiflows.css'; @import 'multiflows.css';
</style> </style>
+2
View File
@@ -25,6 +25,7 @@ onNodeDragStop(({ node }) => {
} }
}) })
</script> </script>
<template> <template>
<div class="vue-flow__group-node"> <div class="vue-flow__group-node">
<Handle type="target" :position="Position.Top" /> <Handle type="target" :position="Position.Top" />
@@ -32,6 +33,7 @@ onNodeDragStop(({ node }) => {
<Handle type="source" :position="Position.Bottom" /> <Handle type="source" :position="Position.Bottom" />
</div> </div>
</template> </template>
<style> <style>
.vue-flow__group-node { .vue-flow__group-node {
padding: 15px; padding: 15px;
+2 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ConnectionMode, useVueFlow, VueFlow, MiniMap, Background, Controls } from '@braks/vue-flow' import { Background, ConnectionMode, Controls, MiniMap, VueFlow, useVueFlow } from '@braks/vue-flow'
const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({ const { onConnect, nodes, edges, addEdges, addNodes } = useVueFlow({
fitViewOnInit: true, fitViewOnInit: true,
@@ -87,6 +87,7 @@ onMounted(() => {
]) ])
}) })
</script> </script>
<template> <template>
<VueFlow> <VueFlow>
<MiniMap /> <MiniMap />
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, addEdge, Connection, Edge, Elements, isEdge, FlowInstance, Position } from '@braks/vue-flow' import type { Connection, Edge, Elements, FlowInstance } from '@braks/vue-flow'
import { Position, VueFlow, addEdge, isEdge } from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ {
@@ -33,6 +34,7 @@ const changeType = () => {
}) })
} }
</script> </script>
<template> <template>
<VueFlow v-model="elements" @connect="onConnect" @pane-ready="onLoad"> <VueFlow v-model="elements" @connect="onConnect" @pane-ready="onLoad">
<button :style="{ position: 'absolute', right: 10, top: 30, zIndex: 4 }" @click="changeType">change type</button> <button :style="{ position: 'absolute', right: 10, top: 30, zIndex: 4 }" @click="changeType">change type</button>
+3 -16
View File
@@ -1,20 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { import type { Connection, Edge, Elements, FlowEvents, FlowInstance, FlowTransform, Node, SnapGrid } from '@braks/vue-flow'
VueFlow, import { Background, Controls, MarkerType, MiniMap, VueFlow, addEdge } from '@braks/vue-flow'
addEdge,
MiniMap,
Controls,
Background,
Node,
Elements,
FlowInstance,
FlowTransform,
SnapGrid,
Connection,
Edge,
FlowEvents,
MarkerType,
} from '@braks/vue-flow'
const onNodeDragStart = (e: FlowEvents['nodeDragStart']) => console.log('drag start', e) const onNodeDragStart = (e: FlowEvents['nodeDragStart']) => console.log('drag start', e)
const onNodeDrag = (e: FlowEvents['nodeDrag']) => console.log('drag', e) const onNodeDrag = (e: FlowEvents['nodeDrag']) => console.log('drag', e)
@@ -114,6 +100,7 @@ const nodeColor = (n: Node): string => {
const elements = ref<Elements>(initialElements) const elements = ref<Elements>(initialElements)
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
</script> </script>
<template> <template>
<VueFlow <VueFlow
v-model="elements" v-model="elements"
+4 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Elements, FlowInstance } from '@braks/vue-flow'
import { ConnectionMode, Controls, VueFlow, useVueFlow } from '@braks/vue-flow'
import Sidebar from './Sidebar.vue' import Sidebar from './Sidebar.vue'
import { VueFlow, Controls, FlowInstance, Elements, ConnectionMode, useVueFlow } from '@braks/vue-flow'
const onLoad = (flowInstance: FlowInstance) => console.log('flow loaded:', flowInstance) const onLoad = (flowInstance: FlowInstance) => console.log('flow loaded:', flowInstance)
@@ -16,6 +17,7 @@ const initialElements: Elements = [
useVueFlow() useVueFlow()
const elements = ref<Elements>(initialElements) const elements = ref<Elements>(initialElements)
</script> </script>
<template> <template>
<div class="providerflow"> <div class="providerflow">
<Sidebar /> <Sidebar />
@@ -26,6 +28,7 @@ const elements = ref<Elements>(initialElements)
</div> </div>
</div> </div>
</template> </template>
<style> <style>
@import 'provider.css'; @import 'provider.css';
</style> </style>
+1
View File
@@ -7,6 +7,7 @@ const selectAll = () => {
nodesSelectionActive.value = true nodesSelectionActive.value = true
} }
</script> </script>
<template> <template>
<aside> <aside>
<div class="description"> <div class="description">
+5 -2
View File
@@ -1,10 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import { templateRef } from '@vueuse/core' import { templateRef } from '@vueuse/core'
import type { Elements, FlowInstance } from '@braks/vue-flow'
import { VueFlow } from '@braks/vue-flow'
import RGBNode from './RGBNode.vue' import RGBNode from './RGBNode.vue'
import RGBOutputNode from './RGBOutputNode.vue' import RGBOutputNode from './RGBOutputNode.vue'
import { Elements, FlowInstance, VueFlow } from '@braks/vue-flow'
type Colors = { interface Colors {
red: number red: number
green: number green: number
blue: number blue: number
@@ -31,6 +32,7 @@ const color = ref<Colors>({
}) })
const onChange = ({ color: c, val }: { color: keyof Colors; val: number }) => (color.value[c] = Number(val)) const onChange = ({ color: c, val }: { color: keyof Colors; val: number }) => (color.value[c] = Number(val))
</script> </script>
<template> <template>
<div ref="page" class="demo-flow"> <div ref="page" class="demo-flow">
<VueFlow v-model="elements" @pane-ready="onLoad"> <VueFlow v-model="elements" @pane-ready="onLoad">
@@ -43,6 +45,7 @@ const onChange = ({ color: c, val }: { color: keyof Colors; val: number }) => (c
</VueFlow> </VueFlow>
</div> </div>
</template> </template>
<style> <style>
.demo-flow { .demo-flow {
display: flex; display: flex;
+5 -2
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { Handle, NodeProps, Position } from '@braks/vue-flow' import type { NodeProps } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface RGBNodeProps extends NodeProps { interface RGBNodeProps extends NodeProps {
data: { data: {
@@ -37,6 +38,7 @@ const colorVal = computed({
const style = { '--color': color } as CSSProperties const style = { '--color': color } as CSSProperties
</script> </script>
<template> <template>
<div class="wrapper"> <div class="wrapper">
<div class="text-md" :style="{ color }">{{ `${color} Amount`.toUpperCase() }}</div> <div class="text-md" :style="{ color }">{{ `${color} Amount`.toUpperCase() }}</div>
@@ -44,6 +46,7 @@ const style = { '--color': color } as CSSProperties
<Handle type="source" :position="Position.Right" :style="{ backgroundColor: color }" /> <Handle type="source" :position="Position.Right" :style="{ backgroundColor: color }" />
</div> </div>
</template> </template>
<style> <style>
.wrapper { .wrapper {
padding: 16px; padding: 16px;
+4 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Handle, NodeProps, Position } from '@braks/vue-flow' import type { NodeProps } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface RBGOutputNodeProps extends NodeProps { interface RBGOutputNodeProps extends NodeProps {
rgb: string rgb: string
@@ -7,12 +8,14 @@ interface RBGOutputNodeProps extends NodeProps {
const props = defineProps<RBGOutputNodeProps>() const props = defineProps<RBGOutputNodeProps>()
</script> </script>
<template> <template>
<div :style="{ backgroundColor: props.rgb }" class="rgb-output-node"> <div :style="{ backgroundColor: props.rgb }" class="rgb-output-node">
<div class="text-md uppercase">{{ props.rgb }}</div> <div class="text-md uppercase">{{ props.rgb }}</div>
<Handle type="target" :position="Position.Left" /> <Handle type="target" :position="Position.Left" />
</div> </div>
</template> </template>
<style> <style>
.rgb-output-node { .rgb-output-node {
padding: 9px; padding: 9px;
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useZoomPanHelper, FlowExportObject, Node, useVueFlow } from '@braks/vue-flow' import type { FlowExportObject, Node } from '@braks/vue-flow'
import { useVueFlow, useZoomPanHelper } from '@braks/vue-flow'
const flowKey = 'example-flow' const flowKey = 'example-flow'
const state = useStorage<FlowExportObject>(flowKey, { const state = useStorage<FlowExportObject>(flowKey, {
@@ -38,6 +39,7 @@ const onAdd = () => {
addNodes([newNode]) addNodes([newNode])
} }
</script> </script>
<template> <template>
<div class="save__controls"> <div class="save__controls">
<button @click="onSave">save</button> <button @click="onSave">save</button>
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Elements } from '@braks/vue-flow'
import { VueFlow } from '@braks/vue-flow'
import Controls from './Controls.vue' import Controls from './Controls.vue'
import { VueFlow, Elements } from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ id: '1', label: 'Node 1', position: { x: 100, y: 100 } }, { id: '1', label: 'Node 1', position: { x: 100, y: 100 } },
@@ -10,11 +11,13 @@ const initialElements: Elements = [
const elements = ref(initialElements) const elements = ref(initialElements)
</script> </script>
<template> <template>
<VueFlow v-model="elements"> <VueFlow v-model="elements">
<Controls /> <Controls />
</VueFlow> </VueFlow>
</template> </template>
<style> <style>
@import 'save.css'; @import 'save.css';
</style> </style>
+1
View File
@@ -16,6 +16,7 @@ onPaneReady((i) => {
console.log(i.getElements()) console.log(i.getElements())
}) })
</script> </script>
<template> <template>
<VueFlow /> <VueFlow />
</template> </template>
+1 -1
View File
@@ -1,4 +1,4 @@
import { Edge, Node } from '@braks/vue-flow' import type { Edge, Node } from '@braks/vue-flow'
export function getElements(xElements = 10, yElements = 10) { export function getElements(xElements = 10, yElements = 10) {
const initialNodes: Node[] = [] const initialNodes: Node[] = []
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { VueFlow } from '@braks/vue-flow'
const elementsA: Elements = [ const elementsA: Elements = [
{ id: '1a', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' }, { id: '1a', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
@@ -25,6 +26,7 @@ const elementsB: Elements = [
const elements = ref(elementsA) const elements = ref(elementsA)
</script> </script>
<template> <template>
<VueFlow v-model="elements"> <VueFlow v-model="elements">
<div :style="{ position: 'absolute', right: 10, top: 10, zIndex: 4 }"> <div :style="{ position: 'absolute', right: 10, top: 10, zIndex: 4 }">
+2 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { Handle, Position } from '@braks/vue-flow' import { Handle, Position } from '@braks/vue-flow'
interface Props { interface Props {
@@ -9,6 +9,7 @@ interface Props {
const props = defineProps<Props>() const props = defineProps<Props>()
const nodeStyles: CSSProperties = { padding: '10px 15px', border: '1px solid #ddd' } const nodeStyles: CSSProperties = { padding: '10px 15px', border: '1px solid #ddd' }
</script> </script>
<template> <template>
<div :key="props.id" :style="nodeStyles"> <div :key="props.id" :style="nodeStyles">
<div>node {{ props.id }}</div> <div>node {{ props.id }}</div>
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Elements, Node } from '@braks/vue-flow'
import { ConnectionLineType, ConnectionMode, MarkerType, VueFlow, useZoomPanHelper } from '@braks/vue-flow'
import CustomNode from './CustomNode.vue' import CustomNode from './CustomNode.vue'
import { VueFlow, useZoomPanHelper, Elements, Node, ConnectionLineType, ConnectionMode, MarkerType } from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ {
@@ -171,6 +172,7 @@ const onPaneClick = (evt: MouseEvent) =>
type: 'custom', type: 'custom',
} as Node)) } as Node))
</script> </script>
<template> <template>
<VueFlow <VueFlow
v-model="elements" v-model="elements"
@@ -1,16 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { import type { Connection, Edge, Elements, FlowEvents, FlowInstance } from '@braks/vue-flow'
VueFlow, import { ConnectionMode, Controls, VueFlow, addEdge, updateEdge } from '@braks/vue-flow'
Controls,
updateEdge,
addEdge,
Elements,
FlowInstance,
Connection,
Edge,
FlowEvents,
ConnectionMode,
} from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ {
@@ -42,6 +32,7 @@ const onEdgeUpdate = ({ edge, connection }: FlowEvents['edgeUpdate']) => {
} }
const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)) const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value))
</script> </script>
<template> <template>
<VueFlow <VueFlow
v-model="elements" v-model="elements"
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VueFlow, Elements } from '@braks/vue-flow' import type { Elements } from '@braks/vue-flow'
import { VueFlow } from '@braks/vue-flow'
const initialElements: Elements = [ const initialElements: Elements = [
{ id: '1', label: '-', position: { x: 100, y: 100 } }, { id: '1', label: '-', position: { x: 100, y: 100 } },
@@ -27,6 +28,7 @@ const updateNode = () => {
onMounted(updateNode) onMounted(updateNode)
</script> </script>
<template> <template>
<VueFlow v-model="elements" :default-zoom="1.5" :min-zoom="0.2" :max-zoom="4"> <VueFlow v-model="elements" :default-zoom="1.5" :min-zoom="0.2" :max-zoom="4">
<div class="updatenode__controls"> <div class="updatenode__controls">
@@ -43,6 +45,7 @@ onMounted(updateNode)
</div> </div>
</VueFlow> </VueFlow>
</template> </template>
<style> <style>
@import 'updatenode.css'; @import 'updatenode.css';
</style> </style>
+4 -1
View File
@@ -1,16 +1,19 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Position, Handle, ValidConnectionFunc } from '@braks/vue-flow' import type { ValidConnectionFunc } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface CustomInputProps { interface CustomInputProps {
isValidTargetPos: ValidConnectionFunc isValidTargetPos: ValidConnectionFunc
} }
const props = defineProps<CustomInputProps>() const props = defineProps<CustomInputProps>()
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<div>Only connectable with B</div> <div>Only connectable with B</div>
<Handle type="source" :position="Position.Right" :is-valid-connection="props.isValidTargetPos" /> <Handle type="source" :position="Position.Right" :is-valid-connection="props.isValidTargetPos" />
+4 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Position, Handle, NodeProps, ValidConnectionFunc } from '@braks/vue-flow' import type { NodeProps, ValidConnectionFunc } from '@braks/vue-flow'
import { Handle, Position } from '@braks/vue-flow'
interface CustomNodeProps extends NodeProps { interface CustomNodeProps extends NodeProps {
id: string id: string
@@ -8,11 +9,13 @@ interface CustomNodeProps extends NodeProps {
const props = defineProps<CustomNodeProps>() const props = defineProps<CustomNodeProps>()
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<Handle type="target" :position="Position.Left" :is-valid-connection="props.isValidSourcePos" /> <Handle type="target" :position="Position.Left" :is-valid-connection="props.isValidSourcePos" />
<div>{{ props.id }}</div> <div>{{ props.id }}</div>
@@ -1,7 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Connection, FlowInstance, OnConnectStartParams } from '@braks/vue-flow'
import { VueFlow, useVueFlow } from '@braks/vue-flow'
import CustomInput from './CustomInput.vue' import CustomInput from './CustomInput.vue'
import CustomNode from './CustomNode.vue' import CustomNode from './CustomNode.vue'
import { VueFlow, Connection, OnConnectStartParams, FlowInstance, useVueFlow } from '@braks/vue-flow'
const { nodes, edges, addEdges } = useVueFlow({ const { nodes, edges, addEdges } = useVueFlow({
nodes: [ nodes: [
@@ -26,6 +27,7 @@ const onConnect = (params: Connection) => {
addEdges([params]) addEdges([params])
} }
</script> </script>
<template> <template>
<VueFlow <VueFlow
:select-nodes-on-drag="false" :select-nodes-on-drag="false"
@@ -44,6 +46,7 @@ const onConnect = (params: Connection) => {
</template> </template>
</VueFlow> </VueFlow>
</template> </template>
<style> <style>
@import 'validation.css'; @import 'validation.css';
</style> </style>
+4 -14
View File
@@ -3,10 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"module": "ESNext", "module": "ESNext",
"target": "es2017", "target": "es2017",
"lib": [ "lib": ["DOM", "ESNext"],
"DOM",
"ESNext"
],
"noEmit": true, "noEmit": true,
"declaration": false, "declaration": false,
"strict": true, "strict": true,
@@ -18,18 +15,11 @@
"noUnusedLocals": false, "noUnusedLocals": false,
"strictNullChecks": true, "strictNullChecks": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"types": [ "types": ["vite/client"],
"vite/client"
],
"paths": { "paths": {
"~/*": [ "~/*": ["../package/src/*"]
"../package/src/*"
]
} }
}, },
"exclude": [ "exclude": ["node_modules", "dist"],
"node_modules",
"dist"
],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }
+6 -6
View File
@@ -2,19 +2,19 @@
"name": "@braks/vue-flow", "name": "@braks/vue-flow",
"version": "0.4.8", "version": "0.4.8",
"private": false, "private": false,
"license": "MIT",
"author": "Burak Cakmakoglu<78412429+bcakmakoglu@users.noreply.github.com>",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/bcakmakoglu/vue-flow" "url": "git+https://github.com/bcakmakoglu/vue-flow"
}, },
"license": "MIT",
"author": "Burak Cakmakoglu<78412429+bcakmakoglu@users.noreply.github.com>",
"homepage": "https://github.com/bcakmakoglu/vue-flow#readme", "homepage": "https://github.com/bcakmakoglu/vue-flow#readme",
"bugs": { "bugs": {
"url": "https://github.com/bcakmakoglu/vue-flow/issues" "url": "https://github.com/bcakmakoglu/vue-flow/issues"
}, },
"main": "./dist/vue-flow.cjs.js", "main": "./dist/vue-flow.cjs.js",
"types": "./dist/index.d.ts",
"module": "./dist/vue-flow.es.js", "module": "./dist/vue-flow.es.js",
"types": "./dist/index.d.ts",
"unpkg": "./dist/vue-flow.iife.js", "unpkg": "./dist/vue-flow.iife.js",
"jsdelivr": "./dist/vue-flow.iife.js", "jsdelivr": "./dist/vue-flow.iife.js",
"files": [ "files": [
@@ -33,6 +33,9 @@
"release": "yarn np", "release": "yarn np",
"postpublish": "shx rm README.md" "postpublish": "shx rm README.md"
}, },
"peerDependencies": {
"vue": "^3.2.25"
},
"dependencies": { "dependencies": {
"@braks/revue-draggable": "^0.4.2", "@braks/revue-draggable": "^0.4.2",
"@types/d3": "^7.1.0", "@types/d3": "^7.1.0",
@@ -58,9 +61,6 @@
"vite-svg-loader": "^2.2.0", "vite-svg-loader": "^2.2.0",
"vue-tsc": "^0.33.9" "vue-tsc": "^0.33.9"
}, },
"peerDependencies": {
"vue": "^3.2.25"
},
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
"registry": "http://registry.npmjs.org/" "registry": "http://registry.npmjs.org/"
@@ -45,11 +45,13 @@ const d = computed(
() => `M${background.scaledGap / 2} 0 V${background.scaledGap} M0 ${background.scaledGap / 2} H${background.scaledGap}`, () => `M${background.scaledGap / 2} 0 V${background.scaledGap} M0 ${background.scaledGap / 2} H${background.scaledGap}`,
) )
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Background', name: 'Background',
} }
</script> </script>
<template> <template>
<svg <svg
class="vue-flow__background" class="vue-flow__background"
@@ -3,6 +3,7 @@ export default {
name: 'ControlButton', name: 'ControlButton',
} }
</script> </script>
<template> <template>
<button class="vue-flow__controls-button"> <button class="vue-flow__controls-button">
<slot></slot> <slot></slot>
@@ -41,11 +41,13 @@ const onInteractiveChangeHandler = () => {
emit('interaction-change', !isInteractive.value) emit('interaction-change', !isInteractive.value)
} }
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Controls', name: 'Controls',
} }
</script> </script>
<template> <template>
<div class="vue-flow__controls"> <div class="vue-flow__controls">
<template v-if="showZoom"> <template v-if="showZoom">
@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ShapeRendering, MiniMapNodeFunc, GraphNode } from '../../types' import type { GraphNode, MiniMapNodeFunc, ShapeRendering } from '../../types'
import { useVueFlow, useWindow } from '../../composables' import { useVueFlow, useWindow } from '../../composables'
import { getBoundsofRects, getRectOfNodes } from '../../utils' import { getBoundsofRects, getRectOfNodes } from '../../utils'
import type { MiniMapProps } from '../../types/components' import type { MiniMapProps } from '../../types/components'
@@ -90,11 +90,13 @@ const onNodeDblClick = (event: MouseEvent, node: GraphNode) => {
hooks.miniMapNodeDoubleClick.trigger({ event, node }) hooks.miniMapNodeDoubleClick.trigger({ event, node })
} }
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'MiniMap', name: 'MiniMap',
} }
</script> </script>
<template> <template>
<svg <svg
:width="elementWidth" :width="elementWidth"
@@ -1,5 +1,5 @@
import { CSSProperties, FunctionalComponent } from 'vue' import type { CSSProperties, FunctionalComponent } from 'vue'
import { MiniMapNodeProps } from '~/types' import type { MiniMapNodeProps } from '~/types'
const MiniMapNode: FunctionalComponent<MiniMapNodeProps> = function ( const MiniMapNode: FunctionalComponent<MiniMapNodeProps> = function (
{ {
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getBezierPath, getSmoothStepPath } from '../Edges/utils' import { getBezierPath, getSmoothStepPath } from '../Edges/utils'
import { ConnectionLineType, GraphNode, HandleElement, HandleType, Position } from '../../types' import type { GraphNode, HandleElement, HandleType } from '../../types'
import { ConnectionLineType, Position } from '../../types'
import { useVueFlow } from '../../composables' import { useVueFlow } from '../../composables'
import { Slots } from '../../context' import { Slots } from '../../context'
@@ -81,11 +82,13 @@ const dAttr = computed(() => {
return path return path
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'ConnectionLine', name: 'ConnectionLine',
} }
</script> </script>
<template> <template>
<g class="vue-flow__connection"> <g class="vue-flow__connection">
<component <component
+1 -1
View File
@@ -1,4 +1,4 @@
import { CSSProperties, FunctionalComponent } from 'vue' import type { CSSProperties, FunctionalComponent } from 'vue'
import EdgeText from './EdgeText.vue' import EdgeText from './EdgeText.vue'
interface Props { interface Props {
+2 -2
View File
@@ -1,5 +1,5 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import { getBezierPath, getBezierCenter } from './utils' import { getBezierCenter, getBezierPath } from './utils'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
import type { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
+1 -1
View File
@@ -1,4 +1,4 @@
import { FunctionalComponent, HTMLAttributes } from 'vue' import type { FunctionalComponent, HTMLAttributes } from 'vue'
import { Position } from '~/types' import { Position } from '~/types'
interface Props extends HTMLAttributes { interface Props extends HTMLAttributes {
+5 -3
View File
@@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { EdgeTextProps } from '../../types/components' import type { EdgeTextProps } from '../../types/components'
import { Rect } from '../../types' import type { Rect } from '../../types'
const props = withDefaults(defineProps<EdgeTextProps>(), { const props = withDefaults(defineProps<EdgeTextProps>(), {
labelStyle: () => ({}), labelStyle: () => ({}),
@@ -19,18 +19,20 @@ onMounted(() => {
}) })
const transform = computed(() => `translate(${props.x - edgeRefBbox.width / 2} ${props.y - edgeRefBbox.height / 2})`) const transform = computed(() => `translate(${props.x - edgeRefBbox.width / 2} ${props.y - edgeRefBbox.height / 2})`)
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'EdgeText', name: 'EdgeText',
} }
</script> </script>
<template> <template>
<g :transform="transform" :class="props.class" class="vue-flow__edge-textwrapper"> <g :transform="transform" :class="props.class" class="vue-flow__edge-textwrapper">
<rect <rect
v-if="props.labelShowBg" v-if="props.labelShowBg"
class="vue-flow__edge-textbg" class="vue-flow__edge-textbg"
:width="edgeRefBbox.width + 2 * props.labelBgPadding[0] + 'px'" :width="`${edgeRefBbox.width + 2 * props.labelBgPadding[0]}px`"
:height="edgeRefBbox.height + 2 * props.labelBgPadding[1] + 'px'" :height="`${edgeRefBbox.height + 2 * props.labelBgPadding[1]}px`"
:x="-props.labelBgPadding[0]" :x="-props.labelBgPadding[0]"
:y="-props.labelBgPadding[1]" :y="-props.labelBgPadding[1]"
:style="props.labelBgStyle" :style="props.labelBgStyle"
+5 -2
View File
@@ -1,7 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { useHandle, useVueFlow } from '../../composables' import { useHandle, useVueFlow } from '../../composables'
import { ConnectionMode, EdgeComponent, GraphEdge, Position } from '../../types' import type { EdgeComponent, GraphEdge } from '../../types'
import { ConnectionMode, Position } from '../../types'
import { connectionExists, getEdgePositions, getHandle, getMarkerId } from '../../utils' import { connectionExists, getEdgePositions, getHandle, getMarkerId } from '../../utils'
import EdgeAnchor from './EdgeAnchor' import EdgeAnchor from './EdgeAnchor'
@@ -161,12 +162,14 @@ const getClass = () => {
const getStyle = () => (edge.style instanceof Function ? edge.style(edge) : edge.style) as CSSProperties const getStyle = () => (edge.style instanceof Function ? edge.style(edge) : edge.style) as CSSProperties
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Edge', name: 'Edge',
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<g <g
:class="getClass()" :class="getClass()"
@@ -1,4 +1,4 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import { getSimpleBezierCenter, getSimpleBezierPath } from './utils' import { getSimpleBezierCenter, getSimpleBezierPath } from './utils'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { Position } from '~/types' import { Position } from '~/types'
@@ -1,7 +1,8 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import { getCenter, getSmoothStepPath } from './utils' import { getCenter, getSmoothStepPath } from './utils'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { Position, SmoothStepEdgeProps } from '~/types' import type { SmoothStepEdgeProps } from '~/types'
import { Position } from '~/types'
const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
sourcePosition = Position.Bottom, sourcePosition = Position.Bottom,
+2 -2
View File
@@ -1,6 +1,6 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import SmoothStepEdge from './SmoothStepEdge' import SmoothStepEdge from './SmoothStepEdge'
import { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const StepEdge: FunctionalComponent<EdgeProps> = function (props) { const StepEdge: FunctionalComponent<EdgeProps> = function (props) {
return h(SmoothStepEdge, { ...props, borderRadius: 0 }) return h(SmoothStepEdge, { ...props, borderRadius: 0 })
+2 -2
View File
@@ -1,6 +1,6 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import BaseEdge from './BaseEdge' import BaseEdge from './BaseEdge'
import { EdgeProps } from '~/types' import type { EdgeProps } from '~/types'
const StraightEdge: FunctionalComponent<EdgeProps> = function ({ const StraightEdge: FunctionalComponent<EdgeProps> = function ({
label, label,
+4 -1
View File
@@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useHandle, useVueFlow } from '../../composables' import { useHandle, useVueFlow } from '../../composables'
import { ConnectionMode, Position } from '../../types' import type { Position } from '../../types'
import { ConnectionMode } from '../../types'
import { NodeId } from '../../context' import { NodeId } from '../../context'
import type { HandleProps } from '../../types/handle' import type { HandleProps } from '../../types/handle'
@@ -49,11 +50,13 @@ const getClasses = computed(() => {
] ]
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Handle', name: 'Handle',
} }
</script> </script>
<template> <template>
<div <div
:data-handleid="handleId" :data-handleid="handleId"
+3 -2
View File
@@ -1,6 +1,7 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import Handle from '../Handle/Handle.vue' import Handle from '../Handle/Handle.vue'
import { NodeProps, Position } from '~/types' import type { NodeProps } from '~/types'
import { Position } from '~/types'
const DefaultNode: FunctionalComponent<NodeProps> = function ({ const DefaultNode: FunctionalComponent<NodeProps> = function ({
sourcePosition = Position.Bottom, sourcePosition = Position.Bottom,
+3 -2
View File
@@ -1,6 +1,7 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import Handle from '../Handle/Handle.vue' import Handle from '../Handle/Handle.vue'
import { NodeProps, Position } from '~/types' import type { NodeProps } from '~/types'
import { Position } from '~/types'
const InputNode: FunctionalComponent<NodeProps> = function ({ const InputNode: FunctionalComponent<NodeProps> = function ({
sourcePosition = Position.Bottom, sourcePosition = Position.Bottom,
+4 -2
View File
@@ -1,8 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useDraggableCore } from '@braks/revue-draggable' import { useDraggableCore } from '@braks/revue-draggable'
import { CSSProperties } from 'vue' import type { CSSProperties } from 'vue'
import { useVueFlow } from '../../composables' import { useVueFlow } from '../../composables'
import { GraphNode, NodeComponent, SnapGrid } from '../../types' import type { GraphNode, NodeComponent, SnapGrid } from '../../types'
import { NodeId } from '../../context' import { NodeId } from '../../context'
import { getHandleBounds, getXYZPos } from '../../utils' import { getHandleBounds, getXYZPos } from '../../utils'
@@ -238,12 +238,14 @@ const getStyle = computed(() => {
} as CSSProperties } as CSSProperties
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'Node', name: 'Node',
inheritAttrs: false, inheritAttrs: false,
} }
</script> </script>
<template> <template>
<div <div
ref="nodeElement" ref="nodeElement"
+3 -2
View File
@@ -1,6 +1,7 @@
import { FunctionalComponent } from 'vue' import type { FunctionalComponent } from 'vue'
import Handle from '../Handle/Handle.vue' import Handle from '../Handle/Handle.vue'
import { NodeProps, Position } from '~/types' import type { NodeProps } from '~/types'
import { Position } from '~/types'
const OutputNode: FunctionalComponent<NodeProps> = function ({ const OutputNode: FunctionalComponent<NodeProps> = function ({
targetPosition = Position.Top, targetPosition = Position.Top,
@@ -54,11 +54,13 @@ onDragStop(({ event }) => {
getSelectedNodes.forEach((node) => (node.dragging = false)) getSelectedNodes.forEach((node) => (node.dragging = false))
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'NodesSelection', name: 'NodesSelection',
} }
</script> </script>
<template> <template>
<div class="vue-flow__nodesselection vue-flow__container" :class="noPanClassName" :style="{ transform }"> <div class="vue-flow__nodesselection vue-flow__container" :class="noPanClassName" :style="{ transform }">
<div ref="el" class="vue-flow__nodesselection-rect" :style="innerStyle" @contextmenu="onContextMenu" /> <div ref="el" class="vue-flow__nodesselection-rect" :style="innerStyle" @contextmenu="onContextMenu" />
@@ -8,11 +8,13 @@ interface SelectionRectProps {
const { width, height, x, y } = defineProps<SelectionRectProps>() const { width, height, x, y } = defineProps<SelectionRectProps>()
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'SelectionRect', name: 'SelectionRect',
} }
</script> </script>
<template> <template>
<div <div
class="vue-flow__selection" class="vue-flow__selection"
@@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useVueFlow } from '../../composables' import { useVueFlow } from '../../composables'
import { SelectionRect as Rect } from '../../types' import type { SelectionRect as Rect } from '../../types'
import { getConnectedEdges, getNodesInside } from '../../utils' import { getConnectedEdges, getNodesInside } from '../../utils'
import SelectionRect from './SelectionRect.vue' import SelectionRect from './SelectionRect.vue'
import { getMousePosition } from './utils' import { getMousePosition } from './utils'
@@ -110,11 +110,13 @@ onBeforeUnmount(() => {
reset() reset()
}) })
</script> </script>
<script lang="ts"> <script lang="ts">
export default { export default {
name: 'UserSelection', name: 'UserSelection',
} }
</script> </script>
<template> <template>
<div ref="user-selection" class="vue-flow__selectionpane vue-flow__container"> <div ref="user-selection" class="vue-flow__selectionpane vue-flow__container">
<SelectionRect v-if="rect.draw" :width="rect.width" :height="rect.height" :x="rect.x" :y="rect.y" /> <SelectionRect v-if="rect.draw" :width="rect.width" :height="rect.height" :x="rect.x" :y="rect.y" />
@@ -1,4 +1,4 @@
import { XYPosition } from '../../types' import type { XYPosition } from '../../types'
export function getMousePosition(event: MouseEvent): XYPosition | void { export function getMousePosition(event: MouseEvent): XYPosition | void {
const flowNode = (event.target as Element).closest('.vue-flow') const flowNode = (event.target as Element).closest('.vue-flow')
+3 -2
View File
@@ -1,8 +1,9 @@
import useVueFlow from './useVueFlow' import useVueFlow from './useVueFlow'
import { getHostForElement } from '~/utils' import { getHostForElement } from '~/utils'
import { Connection, ConnectionMode, Getters, GraphEdge, HandleType, ValidConnectionFunc } from '~/types' import type { Connection, Getters, GraphEdge, HandleType, ValidConnectionFunc } from '~/types'
import { ConnectionMode } from '~/types'
type Result = { interface Result {
elementBelow: Element | null elementBelow: Element | null
isValid: boolean isValid: boolean
connection: Connection connection: Connection
+2 -2
View File
@@ -1,7 +1,7 @@
import { Ref } from 'vue' import type { Ref } from 'vue'
import { onKeyDown, onKeyPressed, onKeyUp } from '@vueuse/core' import { onKeyDown, onKeyPressed, onKeyUp } from '@vueuse/core'
import useWindow from './useWindow' import useWindow from './useWindow'
import { KeyCode } from '~/types' import type { KeyCode } from '~/types'
import { isInputDOMNode } from '~/utils' import { isInputDOMNode } from '~/utils'
export default (keyCode: Ref<KeyCode>, onChange?: (keyPressed: boolean) => void): Ref<boolean> => { export default (keyCode: Ref<KeyCode>, onChange?: (keyPressed: boolean) => void): Ref<boolean> => {
+4 -6
View File
@@ -1,10 +1,8 @@
import { EffectScope } from 'vue' import type { EffectScope } from 'vue'
import { MaybeRef } from '@vueuse/core' import type { MaybeRef } from '@vueuse/core'
import { FlowOptions, FlowProps, State, VueFlowStore } from '~/types' import type { FlowOptions, FlowProps, State, VueFlowStore } from '~/types'
import { VueFlow } from '~/context' import { VueFlow } from '~/context'
import useState from '~/store/state' import { useActions, useGetters, useState } from '~/store'
import useGetters from '~/store/getters'
import useActions from '~/store/actions'
/** /**
* Stores all currently created store instances * Stores all currently created store instances
+2 -2
View File
@@ -1,8 +1,8 @@
import { zoomIdentity } from 'd3-zoom' import { zoomIdentity } from 'd3-zoom'
import useVueFlow from './useVueFlow' import useVueFlow from './useVueFlow'
import useWindow from './useWindow' import useWindow from './useWindow'
import { getRectOfNodes, pointToRendererPoint, getTransformForBounds, clampPosition } from '~/utils' import { clampPosition, getRectOfNodes, getTransformForBounds, pointToRendererPoint } from '~/utils'
import { GraphNode, ViewportFuncs, D3Selection, Getters, Dimensions } from '~/types' import type { D3Selection, Dimensions, Getters, GraphNode, ViewportFuncs } from '~/types'
const DEFAULT_PADDING = 0.1 const DEFAULT_PADDING = 0.1

Some files were not shown because too many files have changed in this diff Show More