Skip to content

Commit 2ca5bd8

Browse files
committed
chore(core,composables): update jsdocs
1 parent 6e162d5 commit 2ca5bd8

File tree

8 files changed

+36
-23
lines changed

8 files changed

+36
-23
lines changed

packages/core/src/composables/useConnection.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
1-
import type { VueFlowStore } from '../types'
21
import { useVueFlow } from './useVueFlow'
32

4-
export interface UseConnectionReturn {
5-
startHandle: VueFlowStore['connectionStartHandle']
6-
endHandle: VueFlowStore['connectionEndHandle']
7-
status: VueFlowStore['connectionStatus']
8-
position: VueFlowStore['connectionPosition']
9-
}
10-
113
/**
12-
* Hook for accessing the ongoing connection.
4+
* Composable for accessing the currently ongoing connection.
135
*
14-
* @returns ongoing connection: startHandle, endHandle, status, position
6+
* @returns current connection: startHandle, endHandle, status, position
157
*/
16-
export function useConnection(): {
17-
startHandle: VueFlowStore['connectionStartHandle']
18-
endHandle: VueFlowStore['connectionEndHandle']
19-
status: VueFlowStore['connectionStatus']
20-
position: VueFlowStore['connectionPosition'] | null
21-
} {
8+
export function useConnection() {
229
const {
2310
connectionStartHandle: startHandle,
2411
connectionEndHandle: endHandle,

packages/core/src/composables/useEdge.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import { EdgeId, EdgeRef } from '../context'
55
import { useVueFlow } from './useVueFlow'
66

77
/**
8-
* Access an edge
8+
* This composable provides access to an edge object and it's dom element
99
*
1010
* If no edge id is provided, the edge id is injected from context
1111
*
12-
* Meaning if you do not provide an id, this composable has to be called in a child of your custom edge component, or it will throw
12+
* If you do not provide an id, this composable has to be called in a child of your custom edge component, or it will throw
13+
*
14+
* @param id - The id of the edge to access
15+
* @returns the edge id, the edge and the edge dom element
1316
*/
1417
export function useEdge<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(id?: string) {
1518
const edgeId = id ?? inject(EdgeId, '')

packages/core/src/composables/useHandle.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ function alwaysValid() {
3131
return true
3232
}
3333

34+
/**
35+
* This composable provides listeners for handle events
36+
*
37+
* Generally it's recommended to use the `<Handle />` component instead of this composable.
38+
*/
3439
export function useHandle({
3540
handleId,
3641
nodeId,

packages/core/src/composables/useHandleConnections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ interface UseHandleConnectionsParams {
1818
/**
1919
* Composable that returns existing connections of a handle
2020
*
21-
* @public
2221
* @param UseHandleConnectionsParams
2322
* @param UseHandleConnectionsParams.type - handle type `source` or `target`
2423
* @param UseHandleConnectionsParams.nodeId - node id - if not provided, the node id from the `useNodeId` (meaning, the context-based injection) is used
2524
* @param UseHandleConnectionsParams.id - the handle id (this is required if the node has multiple handles of the same type)
2625
* @param UseHandleConnectionsParams.onConnect - gets called when a connection is created
2726
* @param UseHandleConnectionsParams.onDisconnect - gets called when a connection is removed
27+
*
2828
* @returns An array of connections
2929
*/
3030
export function useHandleConnections({

packages/core/src/composables/useNode.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ import { useVueFlow } from './useVueFlow'
66
import { useNodeId } from './useNodeId'
77

88
/**
9-
* Access a node, it's parent (if one exists) and connected edges
9+
* This composable provides access to a node object, parent node object, connected edges and it's dom element
1010
*
1111
* If no node id is provided, the node id is injected from context
1212
*
13-
* Meaning if you do not provide an id, this composable has to be called in a child of your custom node component, or it will throw
13+
* If you do not provide an id, this composable has to be called in a child of your custom node component, or it will throw
14+
*
15+
* @param id - The id of the node to access
16+
* @returns the node id, the node, the node dom element, it's parent and connected edges
1417
*/
1518
export function useNode<Data = ElementData, CustomEvents extends Record<string, CustomEvent> = any>(id?: string) {
1619
const nodeId = id ?? useNodeId() ?? ''
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { inject } from 'vue'
22
import { NodeId } from '../context'
33

4+
/**
5+
* This composable returns the current node id from the ctx.
6+
*
7+
* It should be used inside a (custom-)node components ctx as the id is provided by the internal `NodeWrapper` component.
8+
*
9+
* @returns the current node id
10+
*/
411
export function useNodeId() {
5-
return inject(NodeId, null)
12+
return inject(NodeId, '')
613
}

packages/core/src/composables/useNodesData.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type NodeData<NodeType extends Node = GraphNode> = NonNullable<NodeType['data']>
1010
/**
1111
* Composable for receiving data of one or multiple nodes
1212
*
13-
* @public
1413
* @param nodeId - The id (or ids) of the node to get the data from
1514
* @param guard - Optional guard function to narrow down the node type
1615
* @returns An array of data objects

packages/core/src/composables/useVueFlow.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ type Injection = VueFlowStore | null | undefined
8787
type Scope = (EffectScope & { vueFlowId: string }) | undefined
8888

8989
// todo: maybe replace the storage with a context based solution; This would break calling useVueFlow outside a setup function though, which should be fine
90+
/**
91+
* Composable that provides access to a store instance
92+
*
93+
* If no id is provided, the store instance is injected from context
94+
*
95+
* If no store instance is found in context, a new store instance is created and registered in storage
96+
*
97+
* @returns a vue flow store instance
98+
*/
9099
export function useVueFlow(options?: FlowProps): VueFlowStore {
91100
const storage = Storage.getInstance()
92101

0 commit comments

Comments
 (0)