diff --git a/.changeset/chilly-cameras-promise.md b/.changeset/chilly-cameras-promise.md deleted file mode 100644 index f62a9a83..00000000 --- a/.changeset/chilly-cameras-promise.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `useNodeId` composable - -## 🧙 Example - -```ts -const nodeId = useNodeId() - -console.log('nodeId', nodeId) // '1' -``` diff --git a/.changeset/cuddly-flies-change.md b/.changeset/cuddly-flies-change.md deleted file mode 100644 index 414d7b28..00000000 --- a/.changeset/cuddly-flies-change.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `updateNode` action - -## 🧙 Example - -```ts -const { updateNode } = useVueFlow() - -updateNode('1', { position: { x: 100, y: 100 } }) - -// or using a function to update the node -updateNode('1', (node) => ({ ...node, position: { x: 100, y: 100 } })) - -// passing options - `replace` will replace the node instead of merging it -updateNode('1', { id: '1', label: 'Node 1', position: { x: 100, y: 100 } }, { replace: true }) -``` diff --git a/.changeset/curvy-needles-enjoy.md b/.changeset/curvy-needles-enjoy.md deleted file mode 100644 index eaaf7f52..00000000 --- a/.changeset/curvy-needles-enjoy.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Call `onNodesInitialized` whenever `areNodesInitialized` is true instead of only once diff --git a/.changeset/curvy-spies-approve.md b/.changeset/curvy-spies-approve.md deleted file mode 100644 index f2001008..00000000 --- a/.changeset/curvy-spies-approve.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Omit `events` in nodes and edges when returning them from `toObject` diff --git a/.changeset/empty-moose-report.md b/.changeset/empty-moose-report.md deleted file mode 100644 index 367d7a86..00000000 --- a/.changeset/empty-moose-report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `useHandleConnections` composable - -## 🧙 Example - -```ts -const connections = useHandleConnections({ - // type of the handle you are looking for - accepts a `MaybeRefOrGetter` - type: 'source', - - // the id of the handle you are looking for - accepts a `MaybeRefOrGetter | undefined` [OPTIONAL] - id: 'a', - - // if not provided, the node id from the NodeIdContext is used - accepts a `MaybeRefOrGetter | undefined` - nodeId: '1', - - // a cb that is called when a new connection is added - onConnect: (params) => { - console.log('onConnect', params) - }, - - // a cb that is called when a connection is removed - onDisconnect: (params) => { - console.log('onDisconnect', params) - }, -}) - -watch( - connections, - (next) => { - console.log('connections', next) - }, - { immediate: true }, -) -``` diff --git a/.changeset/fresh-avocados-clap.md b/.changeset/fresh-avocados-clap.md deleted file mode 100644 index 0c70bf42..00000000 --- a/.changeset/fresh-avocados-clap.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Find handle by id regardless of number of handles that exist diff --git a/.changeset/giant-pants-speak.md b/.changeset/giant-pants-speak.md deleted file mode 100644 index b0f206ee..00000000 --- a/.changeset/giant-pants-speak.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `connectionLookup` to state diff --git a/.changeset/gorgeous-rules-relate.md b/.changeset/gorgeous-rules-relate.md deleted file mode 100644 index 41c047ea..00000000 --- a/.changeset/gorgeous-rules-relate.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `onInit` hook and deprecate `onPaneReady` diff --git a/.changeset/nice-suits-pull.md b/.changeset/nice-suits-pull.md deleted file mode 100644 index 6afc15b9..00000000 --- a/.changeset/nice-suits-pull.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `updateNodeData` action - -## 🧙 Example - -```ts -const { updateNodeData } = useVueFlow() - -updateNodeData('1', { foo: 'bar' }) - -// or using a function to update the data -updateNodeData('1', (data) => ({ ...data, foo: 'bar' })) - -// passing options - `replace` will replace the data instead of merging it -updateNodeData('1', { foo: 'bar' }, { replace: true }) -``` diff --git a/.changeset/odd-months-clap.md b/.changeset/odd-months-clap.md deleted file mode 100644 index 83f323fe..00000000 --- a/.changeset/odd-months-clap.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": patch ---- - -When updating nodes or edges by overwriting the original array, update the nodes and edges in the state by using them as the target for `Object.assign`. This keeps reference in-tact and ensures reactivity when these objects are changed/updated diff --git a/.changeset/old-jokes-raise.md b/.changeset/old-jokes-raise.md deleted file mode 100644 index 8c3f29c4..00000000 --- a/.changeset/old-jokes-raise.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add `useNodesData` composable - -## 🧙 Example - -### Single node id - -```ts -const nodeId = '1' - -const data = useNodesData(nodeId) - -console.log(data.value) // '[{ /* ... */ }] -``` - -### Array of node ids -```ts -const nodeIds = ['1', '2', '3'] - -const data = useNodesData(nodeIds) - -console.log(data.value) // '[{ /* ... */ }] -``` - -### Asserting data type -```ts -import type { Node } from '@vue-flow/core' - -interface Data { - foo: string; - bar: string; -} - -type MyNode = Node - -const nodeId = '1' - -const data = useNodesData([nodeId], (node): node is MyNode => { - return 'foo' in node.data && 'bar' in node.data -}) - -console.log(data.value) // '[{ /* foo: string; bar: string */ }] -``` diff --git a/.changeset/selfish-cherries-fetch.md b/.changeset/selfish-cherries-fetch.md deleted file mode 100644 index cdaf5d9a..00000000 --- a/.changeset/selfish-cherries-fetch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Call `fitViewOnInit` when initial node dimensions are available diff --git a/.changeset/slimy-cameras-pull.md b/.changeset/slimy-cameras-pull.md deleted file mode 100644 index 94bc0288..00000000 --- a/.changeset/slimy-cameras-pull.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Deprecate `events` property on nodes and edges diff --git a/.changeset/sour-swans-fail.md b/.changeset/sour-swans-fail.md deleted file mode 100644 index 3d5c44de..00000000 --- a/.changeset/sour-swans-fail.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Add error args to `VueFlowError` diff --git a/.changeset/spotty-buckets-suffer.md b/.changeset/spotty-buckets-suffer.md deleted file mode 100644 index 734acf33..00000000 --- a/.changeset/spotty-buckets-suffer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": patch ---- - -Update node dimensions on next tick diff --git a/.changeset/sweet-cameras-decide.md b/.changeset/sweet-cameras-decide.md deleted file mode 100644 index ed4bc123..00000000 --- a/.changeset/sweet-cameras-decide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Replace `Array.forEach` loops with `for...of` diff --git a/.changeset/tame-gifts-reply.md b/.changeset/tame-gifts-reply.md deleted file mode 100644 index 4927ef8d..00000000 --- a/.changeset/tame-gifts-reply.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@vue-flow/core": minor ---- - -Export `isErrorOfType` typeguard to narrow the type of a VueFlowError and infer it's args diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index b776d146..300439b4 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,161 @@ # @vue-flow/core +## 1.31.0 + +### Minor Changes + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`1e60944`](https://github.com/bcakmakoglu/vue-flow/commit/1e609440d392ba79cb4162cfc7d57225ce394400) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `useNodeId` composable + + ## 🧙 Example + + ```ts + const nodeId = useNodeId(); + + console.log("nodeId", nodeId); // '1' + ``` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`299408f`](https://github.com/bcakmakoglu/vue-flow/commit/299408f1706865dca619e6caae289c002d6fe2ed) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `updateNode` action + + ## 🧙 Example + + ```ts + const { updateNode } = useVueFlow(); + + updateNode("1", { position: { x: 100, y: 100 } }); + + // or using a function to update the node + updateNode("1", (node) => ({ ...node, position: { x: 100, y: 100 } })); + + // passing options - `replace` will replace the node instead of merging it + updateNode( + "1", + { id: "1", label: "Node 1", position: { x: 100, y: 100 } }, + { replace: true } + ); + ``` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`eae2118`](https://github.com/bcakmakoglu/vue-flow/commit/eae2118cd3ca0ef915dcce953abdb91a7f443af1) Thanks [@github-actions](https://github.com/apps/github-actions)! - Call `onNodesInitialized` whenever `areNodesInitialized` is true instead of only once + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`36ffa3f`](https://github.com/bcakmakoglu/vue-flow/commit/36ffa3f0c5a68cccac24b31c92978811c9d4cf0c) Thanks [@github-actions](https://github.com/apps/github-actions)! - Omit `events` in nodes and edges when returning them from `toObject` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`85536ed`](https://github.com/bcakmakoglu/vue-flow/commit/85536ed8fa686f3736cd5f0ac3ef4476fb871d30) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `useHandleConnections` composable + + ## 🧙 Example + + ```ts + const connections = useHandleConnections({ + // type of the handle you are looking for - accepts a `MaybeRefOrGetter` + type: "source", + + // the id of the handle you are looking for - accepts a `MaybeRefOrGetter | undefined` [OPTIONAL] + id: "a", + + // if not provided, the node id from the NodeIdContext is used - accepts a `MaybeRefOrGetter | undefined` + nodeId: "1", + + // a cb that is called when a new connection is added + onConnect: (params) => { + console.log("onConnect", params); + }, + + // a cb that is called when a connection is removed + onDisconnect: (params) => { + console.log("onDisconnect", params); + }, + }); + + watch( + connections, + (next) => { + console.log("connections", next); + }, + { immediate: true } + ); + ``` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`4bce8c9`](https://github.com/bcakmakoglu/vue-flow/commit/4bce8c9136a2c13c0643a8c4f9f2bd2516b99df3) Thanks [@github-actions](https://github.com/apps/github-actions)! - Find handle by id regardless of number of handles that exist + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`85536ed`](https://github.com/bcakmakoglu/vue-flow/commit/85536ed8fa686f3736cd5f0ac3ef4476fb871d30) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `connectionLookup` to state + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`3b02809`](https://github.com/bcakmakoglu/vue-flow/commit/3b028097ed4a41e59aa8db00158186045f1c1a1d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `onInit` hook and deprecate `onPaneReady` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`299408f`](https://github.com/bcakmakoglu/vue-flow/commit/299408f1706865dca619e6caae289c002d6fe2ed) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `updateNodeData` action + + ## 🧙 Example + + ```ts + const { updateNodeData } = useVueFlow(); + + updateNodeData("1", { foo: "bar" }); + + // or using a function to update the data + updateNodeData("1", (data) => ({ ...data, foo: "bar" })); + + // passing options - `replace` will replace the data instead of merging it + updateNodeData("1", { foo: "bar" }, { replace: true }); + ``` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`823956e`](https://github.com/bcakmakoglu/vue-flow/commit/823956ee92f880f0a546ab4c040c6b115b8b3345) Thanks [@github-actions](https://github.com/apps/github-actions)! - Add `useNodesData` composable + + ## 🧙 Example + + ### Single node id + + ```ts + const nodeId = "1"; + + const data = useNodesData(nodeId); + + console.log(data.value); // '[{ /* ... */ }] + ``` + + ### Array of node ids + + ```ts + const nodeIds = ["1", "2", "3"]; + + const data = useNodesData(nodeIds); + + console.log(data.value); // '[{ /* ... */ }] + ``` + + ### Asserting data type + + ```ts + import type { Node } from "@vue-flow/core"; + + interface Data { + foo: string; + bar: string; + } + + type MyNode = Node; + + const nodeId = "1"; + + const data = useNodesData([nodeId], (node): node is MyNode => { + return "foo" in node.data && "bar" in node.data; + }); + + console.log(data.value); // '[{ /* foo: string; bar: string */ }] + ``` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`99fa4fd`](https://github.com/bcakmakoglu/vue-flow/commit/99fa4fd6a9be8df866788fbe83e16dde63786328) Thanks [@github-actions](https://github.com/apps/github-actions)! - Call `fitViewOnInit` when initial node dimensions are available + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`9f8607f`](https://github.com/bcakmakoglu/vue-flow/commit/9f8607f3d9e7a5c3c0d4671f57b5d0e206b4345e) Thanks [@github-actions](https://github.com/apps/github-actions)! - Deprecate `events` property on nodes and edges + +- [#1278](https://github.com/bcakmakoglu/vue-flow/pull/1278) [`ecff6f6`](https://github.com/bcakmakoglu/vue-flow/commit/ecff6f608f9ad2961d3fe07e8658c37debac2e78) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Add error args to `VueFlowError` + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`3f60a80`](https://github.com/bcakmakoglu/vue-flow/commit/3f60a803d7a7bb7ec9d3aee316a291a2a2917212) Thanks [@github-actions](https://github.com/apps/github-actions)! - Replace `Array.forEach` loops with `for...of` + +- [#1278](https://github.com/bcakmakoglu/vue-flow/pull/1278) [`ecff6f6`](https://github.com/bcakmakoglu/vue-flow/commit/ecff6f608f9ad2961d3fe07e8658c37debac2e78) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - Export `isErrorOfType` typeguard to narrow the type of a VueFlowError and infer it's args + +### Patch Changes + +- [#1295](https://github.com/bcakmakoglu/vue-flow/pull/1295) [`4a5aa14`](https://github.com/bcakmakoglu/vue-flow/commit/4a5aa146d30a4f825b3ccafc5da9628a82bf2409) Thanks [@bcakmakoglu](https://github.com/bcakmakoglu)! - When updating nodes or edges by overwriting the original array, update the nodes and edges in the state by using them as the target for `Object.assign`. This keeps reference in-tact and ensures reactivity when these objects are changed/updated + +- [#1271](https://github.com/bcakmakoglu/vue-flow/pull/1271) [`bbee266`](https://github.com/bcakmakoglu/vue-flow/commit/bbee266a015dd567873107dadc18374c14bf382b) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update node dimensions on next tick + ## 1.30.1 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 8516d076..e65c94ba 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@vue-flow/core", - "version": "1.30.1", + "version": "1.31.0", "private": false, "license": "MIT", "author": "Burak Cakmakoglu<78412429+bcakmakoglu@users.noreply.github.com>",