From 6ec942fc6501f81009c278cc995764bef3e8d03b Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 5 Apr 2025 17:06:50 +0200 Subject: [PATCH] Improve TSDoc comments for `type GetBezierPathParams` and `getBezierPath` function --- .changeset/rich-mirrors-exist.md | 5 +++ .../system/src/utils/edges/bezier-edge.ts | 33 ++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .changeset/rich-mirrors-exist.md diff --git a/.changeset/rich-mirrors-exist.md b/.changeset/rich-mirrors-exist.md new file mode 100644 index 00000000..1cff8576 --- /dev/null +++ b/.changeset/rich-mirrors-exist.md @@ -0,0 +1,5 @@ +--- +'@xyflow/system': patch +--- + +Improve TSDoc comments for `type GetBezierPathParams` and `getBezierPath` function diff --git a/packages/system/src/utils/edges/bezier-edge.ts b/packages/system/src/utils/edges/bezier-edge.ts index 3b373938..d5c0b6bb 100644 --- a/packages/system/src/utils/edges/bezier-edge.ts +++ b/packages/system/src/utils/edges/bezier-edge.ts @@ -1,12 +1,28 @@ import { Position } from '../../types'; export type GetBezierPathParams = { + /** The `x` position of the source handle. */ sourceX: number; + /** The `y` position of the source handle. */ sourceY: number; + /** + * The position of the source handle. + * @default Position.Bottom + */ sourcePosition?: Position; + /** The `x` position of the target handle. */ targetX: number; + /** The `y` position of the target handle. */ targetY: number; + /** + * The position of the target handle. + * @default Position.Top + */ targetPosition?: Position; + /** + * The curvature of the bezier edge. + * @default 0.25 + */ curvature?: number; }; @@ -75,14 +91,15 @@ function getControlWithCurvature({ pos, x1, y1, x2, y2, c }: GetControlWithCurva * The `getBezierPath` util returns everything you need to render a bezier edge *between two nodes. * @public - * @param params.sourceX - The x position of the source handle - * @param params.sourceY - The y position of the source handle - * @param params.sourcePosition - The position of the source handle (default: Position.Bottom) - * @param params.targetX - The x position of the target handle - * @param params.targetY - The y position of the target handle - * @param params.targetPosition - The position of the target handle (default: Position.Top) - * @param params.curvature - The curvature of the bezier edge - * @returns A path string you can use in an SVG, the labelX and labelY position (center of path) and offsetX, offsetY between source handle and label + * @returns A path string you can use in an SVG, the `labelX` and `labelY` position (center of path) + * and `offsetX`, `offsetY` between source handle and label. + * - `path`: the path to use in an SVG `` 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. * @example * ```js * const source = { x: 0, y: 20 };