diff --git a/examples/vite/main.ts b/examples/vite/main.ts
index a5854fb2..6d8604e2 100644
--- a/examples/vite/main.ts
+++ b/examples/vite/main.ts
@@ -1,5 +1,6 @@
import { createApp } from 'vue'
import './index.css'
+import { createPinia } from 'pinia'
import App from './App.vue'
import { router } from './router'
@@ -7,4 +8,5 @@ const app = createApp(App)
app.config.performance = true
app.use(router)
+app.use(createPinia())
app.mount('#root')
diff --git a/examples/vite/package.json b/examples/vite/package.json
index 7c7b0659..f4bd7355 100644
--- a/examples/vite/package.json
+++ b/examples/vite/package.json
@@ -7,13 +7,14 @@
"lint": "eslint --ext .js,.ts,.vue ./"
},
"dependencies": {
- "vueflow": "workspace:*",
"@vue-flow/background": "workspace:*",
"@vue-flow/controls": "workspace:*",
"@vue-flow/core": "workspace:*",
"@vue-flow/minimap": "workspace:*",
"@vue-flow/node-resizer": "workspace:*",
- "@vue-flow/node-toolbar": "workspace:*"
+ "@vue-flow/node-toolbar": "workspace:*",
+ "pinia": "^2.0.35",
+ "vueflow": "workspace:*"
},
"devDependencies": {
"@tooling/eslint-config": "workspace:*",
diff --git a/examples/vite/router.ts b/examples/vite/router.ts
index ae720fe9..308fc59f 100644
--- a/examples/vite/router.ts
+++ b/examples/vite/router.ts
@@ -122,6 +122,10 @@ export const routes: RouterOptions['routes'] = [
path: '/easy-connect',
component: () => import('./src/EasyConnect/EasyConnect.vue'),
},
+ {
+ path: '/pinia',
+ component: () => import('./src/Pinia/PiniaExample.vue'),
+ },
]
export const router = createRouter({
diff --git a/examples/vite/src/Pinia/PiniaExample.vue b/examples/vite/src/Pinia/PiniaExample.vue
new file mode 100644
index 00000000..28530245
--- /dev/null
+++ b/examples/vite/src/Pinia/PiniaExample.vue
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/vite/src/Pinia/store.ts b/examples/vite/src/Pinia/store.ts
new file mode 100644
index 00000000..0900f6b1
--- /dev/null
+++ b/examples/vite/src/Pinia/store.ts
@@ -0,0 +1,63 @@
+import { defineStore } from 'pinia'
+import { isNode } from '@vue-flow/core'
+
+const useStore = defineStore('elementsStore', {
+ state() {
+ return {
+ foo: ['bar', 'baz'],
+ elements: [
+ {
+ 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: '3',
+ label: 'Node 3',
+ position: { x: 400, y: 100 },
+ class: 'light',
+ },
+ {
+ id: '4',
+ label: 'Node 4',
+ position: { x: 400, y: 200 },
+ class: 'light',
+ },
+ { id: 'e1-2', source: '1', target: '2' },
+ { id: 'e1-3', source: '1', target: '3' },
+ { id: 'e3-4', source: '3', target: '4' },
+ ],
+ }
+ },
+ actions: {
+ reset() {
+ this.elements = []
+ },
+ log() {
+ console.log('stored elements', this.elements)
+ },
+ toggleClass() {
+ this.elements.forEach((el) => (el.class = el.class === 'light' ? 'dark' : 'light'))
+ },
+ updatePosition() {
+ this.elements.forEach((el) => {
+ if (isNode(el)) {
+ el.position = {
+ x: Math.random() * 400,
+ y: Math.random() * 400,
+ }
+ }
+ })
+ },
+ },
+})
+
+export default useStore
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1326ac52..766be0bd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -205,6 +205,9 @@ importers:
'@vue-flow/node-toolbar':
specifier: workspace:*
version: link:../../packages/node-toolbar
+ pinia:
+ specifier: ^2.0.35
+ version: 2.0.35(vue@3.2.47)
vueflow:
specifier: workspace:*
version: link:../../packages/vue-flow
@@ -8903,6 +8906,23 @@ packages:
engines: {node: '>=6'}
dev: true
+ /pinia@2.0.35(vue@3.2.47):
+ resolution: {integrity: sha512-P1IKKQWhxGXiiZ3atOaNI75bYlFUbRxtJdhPLX059Z7+b9Z04rnTZdSY8Aph1LA+/4QEMAYHsTQ638Wfe+6K5g==}
+ peerDependencies:
+ '@vue/composition-api': ^1.4.0
+ typescript: '>=4.4.4'
+ vue: ^2.6.14 || ^3.2.0
+ peerDependenciesMeta:
+ '@vue/composition-api':
+ optional: true
+ typescript:
+ optional: true
+ dependencies:
+ '@vue/devtools-api': 6.5.0
+ vue: 3.2.47
+ vue-demi: 0.14.0(vue@3.2.47)
+ dev: false
+
/pkg-dir@4.2.0:
resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==}
engines: {node: '>=8'}
@@ -11415,7 +11435,6 @@ packages:
optional: true
dependencies:
vue: 3.2.47
- dev: true
/vue-devtools-stub@0.1.0:
resolution: {integrity: sha512-RutnB7X8c5hjq39NceArgXg28WZtZpGc3+J16ljMiYnFhKvd8hITxSWQSQ5bvldxMDU6gG5mkxl1MTQLXckVSQ==}