feat(pkg): Add pathfinding edge pkg to packages dir

This commit is contained in:
Braks
2022-05-15 17:00:08 +02:00
parent b9dbb97374
commit 4ee7eb909a
27 changed files with 6901 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<script lang="ts" setup>
import { VueFlow, MiniMap, Controls, Background, Connection, Edge, Elements, FlowInstance, addEdge } from '@braks/vue-flow'
import initialElements from './elements'
import { PathFindingEdge } from '~/index'
const elements = ref<Elements>(initialElements)
const rfInstance = ref<FlowInstance | null>(null)
const onConnect = (params: Edge | Connection) => (elements.value = addEdge(params, elements.value))
const onLoad = (flowInstance: FlowInstance) => {
flowInstance.fitView({ padding: 1 })
rfInstance.value = flowInstance
}
</script>
<template>
<div style="height: 100%">
<VueFlow v-model="elements" class="vue-flow-basic-example" @connect="onConnect" @pane-ready="onLoad">
<template #edge-pathFinding="props">
<PathFindingEdge v-bind="props" />
</template>
<Controls />
<MiniMap />
<Background color="#aaa" :gap="8" />
</VueFlow>
</div>
</template>
<style>
@import '../node_modules/@braks/vue-flow/dist/style.css';
@import '../node_modules/@braks/vue-flow/dist/theme-default.css';
html,
body,
#root {
height: 100%;
width: 100%;
font-family: 'JetBrains Mono', monospace;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-transform: uppercase;
}
</style>

View File

@@ -0,0 +1,127 @@
import { MarkerType, Elements } from '@braks/vue-flow'
const markerEnd = MarkerType.Arrow
export default [
{
id: '1',
label: 'Node 1',
position: {
x: 430,
y: 0,
},
},
{
id: '2',
label: 'Node 2',
position: {
x: 230,
y: 90,
},
},
{
id: '2a',
label: 'Node 2a',
position: {
x: 0,
y: 180,
},
},
{
id: '2b',
label: 'Node 2b',
position: {
x: 230,
y: 180,
},
},
{
id: '2c',
label: 'Node 2c',
position: {
x: 430,
y: 180,
},
},
{
id: '2d',
label: 'Node 2d',
position: {
x: 475,
y: 270,
},
},
{
id: '3',
label: 'Node 3',
position: {
x: 430,
y: 90,
},
},
{
id: 'e12',
source: '1',
target: '2',
label: 'Foobar',
style: { stroke: 'red' },
type: 'pathFinding',
markerEnd,
},
{
id: 'e13',
source: '1',
target: '3',
type: 'pathFinding',
markerEnd,
},
{
id: 'e22a',
source: '2',
target: '2a',
type: 'pathFinding',
markerEnd,
},
{
id: 'e22b',
source: '2',
target: '2b',
type: 'pathFinding',
markerEnd,
},
{
id: 'e22c',
source: '2',
target: '2c',
type: 'pathFinding',
markerEnd,
},
{
id: 'e2c2d',
source: '2c',
target: '2d',
type: 'pathFinding',
markerEnd,
},
{
id: 'e2d2c',
source: '2d',
target: '2c',
type: 'pathFinding',
markerEnd,
},
{
id: 'e2d1',
source: '2d',
target: '1',
type: 'pathFinding',
markerEnd,
},
{
id: 'e2a2b',
source: '2a',
target: '2b',
type: 'pathFinding',
markerEnd,
},
] as Elements

View File

@@ -0,0 +1,7 @@
import { createApp } from 'vue'
import App from './App.vue'
const app = createApp(App)
app.config.performance = true
app.mount('#root')