diff --git a/.changeset/tame-bulldogs-juggle.md b/.changeset/tame-bulldogs-juggle.md new file mode 100644 index 00000000..1f915341 --- /dev/null +++ b/.changeset/tame-bulldogs-juggle.md @@ -0,0 +1,5 @@ +--- +'@xyflow/react': patch +--- + +fix: improve TSDoc comments for `EdgeLabelOptions` and `EdgeTextProps` diff --git a/packages/react/src/components/Edges/EdgeText.tsx b/packages/react/src/components/Edges/EdgeText.tsx index 9807302a..6646f683 100644 --- a/packages/react/src/components/Edges/EdgeText.tsx +++ b/packages/react/src/components/Edges/EdgeText.tsx @@ -8,9 +8,9 @@ function EdgeTextComponent({ x, y, label, - labelStyle = {}, + labelStyle, labelShowBg = true, - labelBgStyle = {}, + labelBgStyle, labelBgPadding = [2, 4], labelBgBorderRadius = 2, children, @@ -34,7 +34,7 @@ function EdgeTextComponent({ } }, [label]); - if (typeof label === 'undefined' || !label) { + if (!label) { return null; } diff --git a/packages/react/src/types/edges.ts b/packages/react/src/types/edges.ts index 3b922796..8fddf865 100644 --- a/packages/react/src/types/edges.ts +++ b/packages/react/src/types/edges.ts @@ -28,6 +28,9 @@ export type EdgeLabelOptions = { * custom controls. */ label?: ReactNode; + /** + * Custom styles to apply to the label. + */ labelStyle?: CSSProperties; labelShowBg?: boolean; labelBgStyle?: CSSProperties; @@ -108,7 +111,13 @@ export type DefaultEdgeOptions = DefaultEdgeOptionsBase; export type EdgeTextProps = SVGAttributes & EdgeLabelOptions & { + /** + * The x position where the label should be rendered. + */ x: number; + /** + * The y position where the label should be rendered. + */ y: number; };