Skip to content

Commit f6bb711

Browse files
authored
refactor(core)!: remove deprecated exports (#1549)
* refactor(core)!: remove deprecated exports Signed-off-by: braks <[email protected]> * chore(changeset): add Signed-off-by: braks <[email protected]> * chore(docs): cleanup deprecated functions Signed-off-by: braks <[email protected]> * chore(changeset): update Signed-off-by: braks <[email protected]> --------- Signed-off-by: braks <[email protected]>
1 parent bbb54be commit f6bb711

File tree

6 files changed

+6
-166
lines changed

6 files changed

+6
-166
lines changed

.changeset/nine-fishes-lick.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": major
3+
---
4+
5+
Remove deprecated exports `addEdge`, `updateEdge` & `useZoomPanHelper`

docs/src/guide/utils/graph.md

-65
Original file line numberDiff line numberDiff line change
@@ -70,71 +70,6 @@ const toggleClass = () => {
7070
</template>
7171
```
7272

73-
## [addEdge](/typedocs/functions/isEdge) (deprecated)
74-
75-
::: warning
76-
In the composition API you should use [`addEdges`](/typedocs/types/AddEdges) of [`useVueFlow`](/guide/composables#usevueflow/)
77-
:::
78-
79-
- Details:
80-
81-
Adds an edge to the elements array.
82-
83-
- Example:
84-
85-
```vue{12}
86-
<script setup>
87-
import { ref } from 'vue'
88-
import { VueFlow, addEdge } from '@vue-flow/core'
89-
90-
const elements = ref([
91-
{ id: '1', position: { x: 250, y: 5 } },
92-
{ id: '2', position: { x: 100, y: 100 } },
93-
94-
{ id: 'e1-2', source: '1', target: '2' },
95-
])
96-
97-
const onConnect = (params) => {
98-
addEdge(params, elements.value)
99-
}
100-
</script>
101-
<template>
102-
<VueFlow v-model="elements" @connect="onConnect" />
103-
</template>
104-
```
105-
106-
## [updateEdge](/typedocs/functions/updateEdge-1) (deprecated)
107-
108-
::: warning
109-
In the composition API you should use [`updateEdge`](/typedocs/types/UpdateEdge) of [`useVueFlow`](/guide/composables#usevueflow/)
110-
:::
111-
112-
- Details:
113-
114-
Updates an edge to a new source or target node.
115-
116-
- Example:
117-
118-
```vue{12}
119-
<script setup>
120-
import { VueFlow, updateEdge } from '@vue-flow/core'
121-
122-
const elements = ref([
123-
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
124-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
125-
126-
{ id: 'e1-2', source: '1', target: '2' },
127-
])
128-
129-
const onEdgeUpdate = ({ edge, connection }) => {
130-
elements.value = updateEdge(edge, connection, elements.value)
131-
}
132-
</script>
133-
<template>
134-
<VueFlow v-model="elements" @edge-update="onEdgeUpdate" />
135-
</template>
136-
```
137-
13873
## [getOutgoers](/typedocs/functions/getOutgoers)
13974

14075
- Details:

packages/core/src/composables/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ export * from './useUpdateNodePositions'
1010
export * from './useViewportHelper'
1111
export * from './useVueFlow'
1212
export * from './useWatchProps'
13-
export * from './useZoomPanHelper'

packages/core/src/composables/useZoomPanHelper.ts

-27
This file was deleted.

packages/core/src/index.ts

-5
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,13 @@ export {
3232
isEdge,
3333
isGraphNode,
3434
isGraphEdge,
35-
addEdge,
36-
updateEdge,
3735
getOutgoers,
3836
getIncomers,
3937
getConnectedEdges,
4038
getTransformForBounds,
4139
getRectOfNodes,
4240
pointToRendererPoint,
4341
rendererPointToPoint,
44-
/** @deprecated - will be removed in the next major version, use `rendererPointToPoint` instead */
45-
rendererPointToPoint as graphPosToZoomedPos,
4642
getNodesInside,
4743
getMarkerId,
4844
getBoundsofRects,
@@ -61,7 +57,6 @@ export { defaultEdgeTypes, defaultNodeTypes } from './utils/defaultNodesEdges'
6157

6258
export { VueFlow as VueFlowInjection, NodeId as NodeIdInjection } from './context'
6359

64-
export { useZoomPanHelper } from './composables/useZoomPanHelper'
6560
export { useVueFlow } from './composables/useVueFlow'
6661
export { useHandle } from './composables/useHandle'
6762
export { useNode } from './composables/useNode'

packages/core/src/utils/graph.ts

+1-68
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {
2121
XYPosition,
2222
XYZPosition,
2323
} from '../types'
24-
import { isDef, warn } from '.'
24+
import { isDef } from '.'
2525

2626
export function nodeToRect(node: GraphNode): Rect {
2727
return {
@@ -222,73 +222,6 @@ export function connectionExists(edge: Edge | Connection, elements: Elements) {
222222
)
223223
}
224224

225-
/**
226-
* @deprecated Use store instance and call `addEdges` with template-ref or the one received by `onPaneReady` instead
227-
*
228-
* Intended for options API
229-
* In composition API you can access utilities from `useVueFlow`
230-
*/
231-
export function addEdge(edgeParams: Edge | Connection, elements: Elements, defaults?: DefaultEdgeOptions) {
232-
if (!edgeParams.source || !edgeParams.target) {
233-
warn("Can't create edge. An edge needs a source and a target.")
234-
return elements
235-
}
236-
237-
let edge
238-
239-
if (isEdge(edgeParams)) {
240-
edge = { ...edgeParams }
241-
} else {
242-
edge = {
243-
...edgeParams,
244-
id: getEdgeId(edgeParams),
245-
} as Edge
246-
}
247-
248-
edge = parseEdge(edge, undefined, defaults)
249-
250-
if (connectionExists(edge, elements)) {
251-
return elements
252-
}
253-
254-
elements.push(edge)
255-
256-
return elements
257-
}
258-
259-
/**
260-
* @deprecated Use store instance and call `updateEdge` with template-ref or the one received by `onPaneReady` instead
261-
*
262-
* Intended for options API
263-
* In composition API you can access utilities from `useVueFlow`
264-
*/
265-
export function updateEdge(oldEdge: Edge, newConnection: Connection, elements: Elements) {
266-
if (!newConnection.source || !newConnection.target) {
267-
warn("Can't create new edge. An edge needs a source and a target.")
268-
return elements
269-
}
270-
271-
const foundEdge = elements.find((e) => isEdge(e) && e.id === oldEdge.id)
272-
273-
if (!foundEdge) {
274-
warn(`The old edge with id=${oldEdge.id} does not exist.`)
275-
return elements
276-
}
277-
278-
// Remove old edge and create the new edge with parameters of old edge.
279-
const edge: Edge = {
280-
...oldEdge,
281-
id: getEdgeId(newConnection),
282-
source: newConnection.source,
283-
target: newConnection.target,
284-
sourceHandle: newConnection.sourceHandle,
285-
targetHandle: newConnection.targetHandle,
286-
}
287-
elements.splice(elements.indexOf(foundEdge), 1, edge)
288-
289-
return elements.filter((e) => e.id !== oldEdge.id)
290-
}
291-
292225
export function rendererPointToPoint({ x, y }: XYPosition, { x: tx, y: ty, zoom: tScale }: ViewportTransform): XYPosition {
293226
return {
294227
x: x * tScale + tx,

0 commit comments

Comments
 (0)