chore(ts): add annotations for useReactFlow/ useSvelteFlow
This commit is contained in:
@@ -10,18 +10,24 @@ const selector = (s: ReactFlowStore) => ({
|
||||
position: s.connectionStartHandle ? s.connectionPosition : null,
|
||||
});
|
||||
|
||||
type UseConnectionResult = {
|
||||
/** The start handle where the user interaction started or null */
|
||||
startHandle: ReactFlowStore['connectionStartHandle'];
|
||||
/** The target handle that's inside the connection radius or null */
|
||||
endHandle: ReactFlowStore['connectionEndHandle'];
|
||||
/** The current connection status 'valid', 'invalid' or null*/
|
||||
status: ReactFlowStore['connectionStatus'];
|
||||
/** The current connection position or null */
|
||||
position: ReactFlowStore['connectionPosition'] | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook for accessing the ongoing connection.
|
||||
*
|
||||
* @public
|
||||
* @returns ongoing connection: startHandle, endHandle, status, position
|
||||
* @returns ongoing connection
|
||||
*/
|
||||
export function useConnection(): {
|
||||
startHandle: ReactFlowStore['connectionStartHandle'];
|
||||
endHandle: ReactFlowStore['connectionEndHandle'];
|
||||
status: ReactFlowStore['connectionStatus'];
|
||||
position: ReactFlowStore['connectionPosition'] | null;
|
||||
} {
|
||||
export function useConnection(): UseConnectionResult {
|
||||
const ongoingConnection = useStore(selector, shallow);
|
||||
|
||||
return ongoingConnection;
|
||||
|
||||
Reference in New Issue
Block a user