feat(pkg): Add pathfinding edge pkg to packages dir
This commit is contained in:
40
packages/pathfinding-edge/example/App.vue
Normal file
40
packages/pathfinding-edge/example/App.vue
Normal 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>
|
||||
127
packages/pathfinding-edge/example/elements.ts
Normal file
127
packages/pathfinding-edge/example/elements.ts
Normal 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
|
||||
7
packages/pathfinding-edge/example/main.ts
Normal file
7
packages/pathfinding-edge/example/main.ts
Normal 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')
|
||||
Reference in New Issue
Block a user