diff --git a/docs/nuxt.config.ts b/docs/nuxt.config.ts index dc2bfd8c..44932212 100644 --- a/docs/nuxt.config.ts +++ b/docs/nuxt.config.ts @@ -11,6 +11,7 @@ export default defineNuxtConfig({ }, vite: { alias: { + dagre: resolve('./node_modules/dagre'), vue: resolve('./node_modules/vue'), }, resolve: { diff --git a/docs/pages/examples/initialLayoutingElements.ts b/docs/pages/examples/initialLayoutingElements.ts deleted file mode 100644 index 35280ada..00000000 --- a/docs/pages/examples/initialLayoutingElements.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { Elements, XYPosition } from '@braks/vue-flow' - -const position: XYPosition = { x: 0, y: 0 } - -const elements: Elements = [ - { - id: '1', - type: 'input', - data: { label: 'input' }, - position, - }, - { - id: '2', - data: { label: 'node 2' }, - position, - }, - { - id: '2a', - data: { label: 'node 2a' }, - position, - }, - { - id: '2b', - data: { label: 'node 2b' }, - position, - }, - { - id: '2c', - data: { label: 'node 2c' }, - position, - }, - { - id: '2d', - data: { label: 'node 2d' }, - position, - }, - { - id: '3', - data: { label: 'node 3' }, - position, - }, - { - id: '4', - data: { label: 'node 4' }, - position, - }, - { - id: '5', - data: { label: 'node 5' }, - position, - }, - { - id: '6', - type: 'output', - data: { label: 'output' }, - position, - }, - { id: '7', type: 'output', data: { label: 'output' }, position: { x: 400, y: 450 } }, - { id: 'e12', source: '1', target: '2', type: 'smoothstep', animated: true }, - { id: 'e13', source: '1', target: '3', type: 'smoothstep', animated: true }, - { id: 'e22a', source: '2', target: '2a', type: 'smoothstep', animated: true }, - { id: 'e22b', source: '2', target: '2b', type: 'smoothstep', animated: true }, - { id: 'e22c', source: '2', target: '2c', type: 'smoothstep', animated: true }, - { id: 'e2c2d', source: '2c', target: '2d', type: 'smoothstep', animated: true }, - - { id: 'e45', source: '4', target: '5', type: 'smoothstep', animated: true }, - { id: 'e56', source: '5', target: '6', type: 'smoothstep', animated: true }, - { id: 'e57', source: '5', target: '7', type: 'smoothstep', animated: true }, -] - -export default elements diff --git a/docs/pages/examples/layouting.vue b/docs/pages/examples/layouting.vue index 9678d51a..42650451 100644 --- a/docs/pages/examples/layouting.vue +++ b/docs/pages/examples/layouting.vue @@ -12,8 +12,76 @@ import { NodeExtent, Position, removeElements, + XYPosition, } from '@braks/vue-flow' -import initialElements from './initialLayoutingElements' + +const position: XYPosition = { x: 0, y: 0 } + +const initialElements: Elements = [ + { + id: '1', + type: 'input', + data: { label: 'input' }, + position, + }, + { + id: '2', + data: { label: 'node 2' }, + position, + }, + { + id: '2a', + data: { label: 'node 2a' }, + position, + }, + { + id: '2b', + data: { label: 'node 2b' }, + position, + }, + { + id: '2c', + data: { label: 'node 2c' }, + position, + }, + { + id: '2d', + data: { label: 'node 2d' }, + position, + }, + { + id: '3', + data: { label: 'node 3' }, + position, + }, + { + id: '4', + data: { label: 'node 4' }, + position, + }, + { + id: '5', + data: { label: 'node 5' }, + position, + }, + { + id: '6', + type: 'output', + data: { label: 'output' }, + position, + }, + { id: '7', type: 'output', data: { label: 'output' }, position: { x: 400, y: 450 } }, + { id: 'e12', source: '1', target: '2', type: 'smoothstep', animated: true }, + { id: 'e13', source: '1', target: '3', type: 'smoothstep', animated: true }, + { id: 'e22a', source: '2', target: '2a', type: 'smoothstep', animated: true }, + { id: 'e22b', source: '2', target: '2b', type: 'smoothstep', animated: true }, + { id: 'e22c', source: '2', target: '2c', type: 'smoothstep', animated: true }, + { id: 'e2c2d', source: '2c', target: '2d', type: 'smoothstep', animated: true }, + + { id: 'e45', source: '4', target: '5', type: 'smoothstep', animated: true }, + { id: 'e56', source: '5', target: '6', type: 'smoothstep', animated: true }, + { id: 'e57', source: '5', target: '7', type: 'smoothstep', animated: true }, +] const dagreGraph = new dagre.graphlib.Graph() dagreGraph.setDefaultEdgeLabel(() => ({})) @@ -51,7 +119,6 @@ const onLayout = (direction: string) => { return el }) - console.log(elements.value) } diff --git a/examples/Basic/Basic.vue b/examples/Basic/Basic.vue index a7913cc5..367a7536 100644 --- a/examples/Basic/Basic.vue +++ b/examples/Basic/Basic.vue @@ -13,7 +13,7 @@ import { isNode, removeElements, Node, -} from '@braks/vue-flow' +} from '~/index' const onNodeDragStop = ({ node }: { node: Node }) => console.log('drag stop', node) const onElementClick = ({ node }: { node: Node }) => console.log('click', node) @@ -48,9 +48,9 @@ const updatePos = () => { const logToObject = () => console.log(rfInstance.value?.toObject()) const resetTransform = () => rfInstance.value?.setTransform({ x: 0, y: 0, zoom: 1 }) -const toggleClassnames = () => { +const toggleclasss = () => { elements.value = elements.value.map((el: FlowElement) => { - if (isNode(el)) el.className = el.className === 'light' ? 'dark' : 'light' + if (isNode(el)) el.class = el.class === 'light' ? 'dark' : 'light' return el }) } @@ -75,7 +75,7 @@ const toggleClassnames = () => {
- +
diff --git a/examples/EdgeTypes/EdgeTypesExample.vue b/examples/EdgeTypes/EdgeTypesExample.vue index e58a81da..a9c67122 100644 --- a/examples/EdgeTypes/EdgeTypesExample.vue +++ b/examples/EdgeTypes/EdgeTypesExample.vue @@ -1,7 +1,4 @@ + + diff --git a/package.json b/package.json index 78999906..a872b97a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "dist" ], "scripts": { + "dev": "vite", "build": "vite build && vue-tsc --declaration --emitDeclarationOnly", "prepublishOnly": "yarn build", "test": "exit 0;", @@ -43,12 +44,15 @@ "devDependencies": { "@antfu/eslint-config": "^0.9.0", "@rollup/plugin-replace": "^2.4.2", + "@types/dagre": "^0.7.46", "@vitejs/plugin-vue": "^1.9.3", "@vue/compiler-sfc": "^3.2.21", "autoprefixer": "^10.3.7", + "dagre": "^0.8.5", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^3.4.1", + "localforage": "^1.10.0", "np": "^7.5.0", "postcss-nested": "^5.0.6", "prettier": "^2.4.1", @@ -57,6 +61,7 @@ "vite": "^2.6.10", "vite-svg-loader": "^2.2.0", "vue": "^3.2.21", + "vue-router": "^4.0.12", "vue-tsc": "^0.28.7" }, "peerDependencies": { diff --git a/src/additional-components/Background/Background.vue b/src/additional-components/Background/Background.vue index e1ed7390..024e519e 100644 --- a/src/additional-components/Background/Background.vue +++ b/src/additional-components/Background/Background.vue @@ -1,7 +1,7 @@