Merge pull request #5170 from dimaMachina/tsdoc2-16

Improve TSDoc comments for `interface GetSimpleBezierPathParams` and `getSimpleBezierPath`
This commit is contained in:
Moritz Klack
2025-04-07 11:19:43 +02:00
committed by GitHub
4 changed files with 24 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@xyflow/react': patch
---
Improve TSDoc comments for `interface GetSimpleBezierPathParams` and `getSimpleBezierPath`
@@ -7,9 +7,11 @@ import type { SimpleBezierEdgeProps } from '../../types';
export interface GetSimpleBezierPathParams { export interface GetSimpleBezierPathParams {
sourceX: number; sourceX: number;
sourceY: number; sourceY: number;
/** @default Position.Bottom */
sourcePosition?: Position; sourcePosition?: Position;
targetX: number; targetX: number;
targetY: number; targetY: number;
/** @default Position.Top */
targetPosition?: Position; targetPosition?: Position;
} }
@@ -33,6 +35,14 @@ function getControl({ pos, x1, y1, x2, y2 }: GetControlParams): [number, number]
* The `getSimpleBezierPath` util returns everything you need to render a simple * The `getSimpleBezierPath` util returns everything you need to render a simple
* bezier edge between two nodes. * bezier edge between two nodes.
* @public * @public
* @returns
* - `path`: the path to use in an SVG `<path>` element.
* - `labelX`: the `x` position you can use to render a label for this edge.
* - `labelY`: the `y` position you can use to render a label for this edge.
* - `offsetX`: the absolute difference between the source `x` position and the `x` position of the
* middle of this path.
* - `offsetY`: the absolute difference between the source `y` position and the `y` position of the
* middle of this path.
*/ */
export function getSimpleBezierPath({ export function getSimpleBezierPath({
sourceX, sourceX,
@@ -85,8 +95,8 @@ function createSimpleBezierEdge(params: { isInternal: boolean }) {
sourceY, sourceY,
targetX, targetX,
targetY, targetY,
sourcePosition = Position.Bottom, sourcePosition,
targetPosition = Position.Top, targetPosition,
label, label,
labelStyle, labelStyle,
labelShowBg, labelShowBg,
@@ -11,7 +11,7 @@ import { useStore, useStoreApi } from '../../hooks/useStore';
import type { Node, Edge, ReactFlowState, ReactFlowProps, FitViewOptions } from '../../types'; import type { Node, Edge, ReactFlowState, ReactFlowProps, FitViewOptions } from '../../types';
import { defaultNodeOrigin } from '../../container/ReactFlow/init-values'; import { defaultNodeOrigin } from '../../container/ReactFlow/init-values';
// these fields exist in the global store and we need to keep them up to date // These fields exist in the global store, and we need to keep them up to date
const reactFlowFieldsToTrack = [ const reactFlowFieldsToTrack = [
'nodes', 'nodes',
'edges', 'edges',
+6 -6
View File
@@ -147,9 +147,9 @@ function applyChange(change: any, element: any): any {
/** /**
* Drop in function that applies node changes to an array of nodes. * Drop in function that applies node changes to an array of nodes.
* @public * @public
* @param changes - Array of changes to apply * @param changes - Array of changes to apply.
* @param nodes - Array of nodes to apply the changes to * @param nodes - Array of nodes to apply the changes to.
* @returns Array of updated nodes * @returns Array of updated nodes.
* @example * @example
*```tsx *```tsx
*import { useState, useCallback } from 'react'; *import { useState, useCallback } from 'react';
@@ -185,9 +185,9 @@ export function applyNodeChanges<NodeType extends Node = Node>(
/** /**
* Drop in function that applies edge changes to an array of edges. * Drop in function that applies edge changes to an array of edges.
* @public * @public
* @param changes - Array of changes to apply * @param changes - Array of changes to apply.
* @param edges - Array of edge to apply the changes to * @param edges - Array of edge to apply the changes to.
* @returns Array of updated edges * @returns Array of updated edges.
* @example * @example
* ```tsx * ```tsx
*import { useState, useCallback } from 'react'; *import { useState, useCallback } from 'react';