Skip to content

Commit 889797e

Browse files
committed
chore(docs): cleanup v-model usages
1 parent 865fe72 commit 889797e

File tree

9 files changed

+38
-55
lines changed

9 files changed

+38
-55
lines changed

docs/src/guide/components/background.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ To use the background simply pass the `Background` component as a child to the `
1919
<script setup>
2020
import { VueFlow } from '@vue-flow/core'
2121
import { Background } from '@vue-flow/background'
22-
import initialElements from './initial-elements'
23-
24-
// some nodes and edges
25-
const elements = ref(initialElements)
2622
</script>
2723
2824
<template>
29-
<VueFlow v-model="elements" fit-view-on-init class="vue-flow-basic-example">
25+
<VueFlow>
3026
<Background />
3127
</VueFlow>
3228
</template>

docs/src/guide/components/controls.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ import { Controls } from '@vue-flow/controls'
2626
2727
// import default controls styles
2828
import '@vue-flow/controls/dist/style.css'
29-
30-
import initialElements from './initial-elements'
31-
32-
33-
// some nodes and edges
34-
const elements = ref(initialElements)
3529
</script>
3630
3731
<template>
38-
<VueFlow v-model="elements" fit-view-on-init class="vue-flow-basic-example">
32+
<VueFlow>
3933
<Controls />
4034
</VueFlow>
4135
</template>

docs/src/guide/components/minimap.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ import { MiniMap } from '@vue-flow/minimap'
2424
2525
// import default minimap styles
2626
import '@vue-flow/minimap/dist/style.css'
27-
28-
import initialElements from './initial-elements'
29-
30-
// some nodes and edges
31-
const elements = ref(initialElements)
3227
</script>
3328
3429
<template>
35-
<VueFlow v-model="elements" fit-view-on-init class="vue-flow-basic-example">
30+
<VueFlow>
3631
<MiniMap />
3732
</VueFlow>
3833
</template>

docs/src/guide/components/node-resizer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ npm install @vue-flow/node-resizer
1616

1717
```vue
1818
<script setup>
19+
import { ref } from 'vue'
1920
import { VueFlow } from '@vue-flow/core'
20-
import initialElements from './initial-elements'
21+
import initialNodes from './initialNodes'
2122
2223
// some nodes and edges
23-
const elements = ref(initialElements)
24+
const nodes = ref(initialNodes)
2425
</script>
2526
2627
<template>
27-
<VueFlow v-model="elements" fit-view-on-init>
28+
<VueFlow :nodes="nodes">
2829
<template #node-custom="nodeProps">
29-
<CustomNode :data="nodeProps.data" :label="nodeProps.label" />
30+
<CustomNode :data="nodeProps.data" />
3031
</template>
3132
</VueFlow>
3233
</template>
@@ -40,14 +41,13 @@ import { NodeResizer } from '@vue-flow/node-resizer'
4041
// make sure to include the necessary styles!
4142
import '@vue-flow/node-resizer/dist/style.css'
4243
43-
defineProps(['label'])
44+
defineProps(['data'])
4445
</script>
4546
4647
<template>
4748
<NodeResizer min-width="100" min-height="30" />
4849
4950
<Handle type="target" :position="Position.Left" />
50-
<div style="padding: 10px">{{ label }}</div>
5151
<Handle type="source" :position="Position.Right" />
5252
</template>
5353
```

docs/src/guide/components/node-toolbar.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ npm install @vue-flow/node-toolbar
1919
```vue
2020
<script setup>
2121
import { VueFlow } from '@vue-flow/core'
22-
import initialElements from './initial-elements'
22+
import initialNodes from './initialNodes'
2323
2424
// some nodes and edges
25-
const elements = ref(initialElements)
25+
const nodes = ref(initialNodes)
2626
</script>
2727
2828
<template>
29-
<VueFlow v-model="elements" fit-view-on-init>
29+
<VueFlow :nodes="nodes">
3030
<template #node-custom="nodeProps">
31-
<CustomNode :data="nodeProps.data" :label="nodeProps.label" />
31+
<CustomNode :data="nodeProps.data" />
3232
</template>
3333
</VueFlow>
3434
</template>
@@ -59,10 +59,6 @@ defineProps<Props>()
5959
<button>expand</button>
6060
</NodeToolbar>
6161
62-
<div :style="{ padding: '10px 20px' }">
63-
{{ label }}
64-
</div>
65-
6662
<Handle type="target" :position="Position.Left" />
6763
<Handle type="source" :position="Position.Right" />
6864
</template>

docs/src/guide/theming.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ Below are a couple of examples on how you can do this:
9191

9292
Directly styling the Vue Flow component:
9393

94-
```vue{3-4}
94+
```vue{4-5}
9595
<VueFlow
96-
v-model="elements"
96+
:nodes="nodes"
97+
:edges="edges"
9798
class="my-diagram-class"
9899
:style="{ background: 'red' }"
99100
/>
@@ -108,8 +109,8 @@ Styling nodes/edges with a style or class attribute:
108109
const nodes = ref([
109110
{
110111
id: '1',
111-
label: 'Node 1',
112112
position: { x: 250, y: 5 },
113+
data: { label: 'Node 1' },
113114
114115
// Add a class name to the node
115116
class: 'my-custom-node-class',
@@ -140,11 +141,11 @@ These alterations can be implemented either on a global scale or to individual e
140141
```
141142

142143
```js{6-7} [<LogosJavascript />]
143-
const elements = ref([
144+
const nodes = ref([
144145
{
145146
id: '1',
146-
label: 'Node 1',
147147
position: { x: 100, y: 100 },
148+
data: { label: 'Node 1' },
148149
/* Overriding the `--vf-node-color` variable to change node border, box-shadow and handle color */
149150
style: { '--vf-node-color': 'blue' }
150151
},

docs/src/guide/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Vue Flow can emit several error types to help diagnose and resolve issues.
1818
<template>
1919
<!-- Ensure the parent container has a width and height -->
2020
<div style="width: 500px; height: 500px">
21-
<VueFlow v-model="elements" />
21+
<VueFlow :nodes="nodes" :edges="edges" />
2222
</div>
2323
</template>
2424
```

docs/src/guide/utils/graph.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import { VueFlow, isEdge } from '@vue-flow/core'
1414
1515
const elements = ref([
16-
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 }, },
17-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
16+
{ id: '1', position: { x: 250, y: 5 }, },
17+
{ id: '2', position: { x: 100, y: 100 }, },
1818
1919
{ id: 'e1-2', source: '1', target: '2', class: 'light' },
2020
])
@@ -27,9 +27,10 @@ const toggleClass = () => {
2727
})
2828
}
2929
</script>
30+
3031
<template>
3132
<VueFlow v-model="elements">
32-
<button style="position: absolute; top: 10px; right: 10px;" @click="toggleClass">Toggle classes</button>
33+
<button @click="toggleClass">Toggle classes</button>
3334
</VueFlow>
3435
</template>
3536
```
@@ -61,33 +62,34 @@ const toggleClass = () => {
6162
})
6263
}
6364
</script>
65+
6466
<template>
6567
<VueFlow v-model="elements">
66-
<button style="position: absolute; top: 10px; right: 10px;" @click="toggleClass">Toggle classes</button>
68+
<button @click="toggleClass">Toggle classes</button>
6769
</VueFlow>
6870
</template>
6971
```
7072

71-
## [addEdge](/typedocs/functions/isEdge)
73+
## [addEdge](/typedocs/functions/isEdge) (deprecated)
7274

7375
::: warning
74-
In the composition API you should use [`addEdges`](/typedocs/types/AddEdges)
75-
of [`useVueFlow`](/guide/composables#usevueflow/)
76+
In the composition API you should use [`addEdges`](/typedocs/types/AddEdges) of [`useVueFlow`](/guide/composables#usevueflow/)
7677
:::
7778

7879
- Details:
7980

80-
Confirms if an element is a node.
81+
Adds an edge to the elements array.
8182

8283
- Example:
8384

8485
```vue{12}
8586
<script setup>
87+
import { ref } from 'vue'
8688
import { VueFlow, addEdge } from '@vue-flow/core'
8789
8890
const elements = ref([
89-
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
90-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
91+
{ id: '1', position: { x: 250, y: 5 } },
92+
{ id: '2', position: { x: 100, y: 100 } },
9193
9294
{ id: 'e1-2', source: '1', target: '2' },
9395
])
@@ -101,16 +103,15 @@ const onConnect = (params) => {
101103
</template>
102104
```
103105

104-
## [updateEdge](/typedocs/functions/updateEdge-1)
106+
## [updateEdge](/typedocs/functions/updateEdge-1) (deprecated)
105107

106108
::: warning
107-
In the composition API you should use [`updateEdge`](/typedocs/types/UpdateEdge)
108-
of [`useVueFlow`](/guide/composables#usevueflow/)
109+
In the composition API you should use [`updateEdge`](/typedocs/types/UpdateEdge) of [`useVueFlow`](/guide/composables#usevueflow/)
109110
:::
110111

111112
- Details:
112113

113-
Updates an edge and applies new source/target.
114+
Updates an edge to a new source or target node.
114115

115116
- Example:
116117

@@ -119,8 +120,8 @@ of [`useVueFlow`](/guide/composables#usevueflow/)
119120
import { VueFlow, updateEdge } from '@vue-flow/core'
120121
121122
const elements = ref([
122-
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 }, class: 'light' },
123-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, class: 'light' },
123+
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
124+
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
124125
125126
{ id: 'e1-2', source: '1', target: '2' },
126127
])

docs/src/guide/vue-flow/config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ const edges = ref([
812812

813813
```vue{2}
814814
<template>
815-
<VueFlow v-model="elements" auto-connect />
815+
<VueFlow :auto-connect="true" />
816816
</template>
817817
```
818818

0 commit comments

Comments
 (0)