diff --git a/.changeset/fifty-rings-perform.md b/.changeset/fifty-rings-perform.md new file mode 100644 index 00000000..79eb8ea5 --- /dev/null +++ b/.changeset/fifty-rings-perform.md @@ -0,0 +1,7 @@ +--- +'@xyflow/react': patch +'@xyflow/svelte': patch +'@xyflow/system': patch +--- + +Add TSDoc annotations diff --git a/packages/react/src/types/general.ts b/packages/react/src/types/general.ts index 80acc45c..d13d11be 100644 --- a/packages/react/src/types/general.ts +++ b/packages/react/src/types/general.ts @@ -99,6 +99,9 @@ export type OnSelectionChangeFunc ) => void; +/** + * @inline + */ export type FitViewParams = FitViewParamsBase; /** @@ -107,9 +110,18 @@ export type FitViewParams = FitViewParamsBase = FitViewOptionsBase; + +/** + * @inline + */ export type FitView = (fitViewOptions?: FitViewOptions) => Promise; + +/** + * @inline + */ export type OnInit = ( reactFlowInstance: ReactFlowInstance ) => void; @@ -209,4 +221,8 @@ export type OnBeforeDelete; +/** + * This type can be used to type the `isValidConnection` function. + * If the function returns `true`, the connection is valid and can be created. + */ export type IsValidConnection = (edge: EdgeType | Connection) => boolean; diff --git a/packages/svelte/src/lib/types/general.ts b/packages/svelte/src/lib/types/general.ts index 34474408..701496e9 100644 --- a/packages/svelte/src/lib/types/general.ts +++ b/packages/svelte/src/lib/types/general.ts @@ -21,8 +21,16 @@ export type ConnectionData = { connectionStatus: string | null; }; +/** + * @inline + */ export type FitViewOptions = FitViewOptionsBase; +/** + * This type can be used to type the `onDelete` function with a custom node and edge type. + * + * @public + */ export type OnDelete = (params: { nodes: NodeType[]; edges: EdgeType[]; @@ -40,6 +48,10 @@ export type OnBeforeDelete< EdgeType extends Edge = Edge > = OnBeforeDeleteBase; +/** + * This type can be used to type the `isValidConnection` function. + * If the function returns `true`, the connection is valid and can be created. + */ export type IsValidConnection = ( edge: EdgeType | Connection ) => boolean; diff --git a/packages/system/src/types/general.ts b/packages/system/src/types/general.ts index 367ca1d8..15f64262 100644 --- a/packages/system/src/types/general.ts +++ b/packages/system/src/types/general.ts @@ -13,13 +13,28 @@ import { EdgeBase } from '..'; export type Project = (position: XYPosition) => XYPosition; +/** + * This type is used to define the `onMove` handler. + */ export type OnMove = (event: MouseEvent | TouchEvent | null, viewport: Viewport) => void; export type OnMoveStart = OnMove; export type OnMoveEnd = OnMove; +/** + * @inline + */ export type ZoomInOut = (options?: ViewportHelperFunctionOptions) => Promise; +/** + * @inline + */ export type ZoomTo = (zoomLevel: number, options?: ViewportHelperFunctionOptions) => Promise; +/** + * @inline + */ export type GetZoom = () => number; +/** + * @inline + */ export type GetViewport = () => Viewport; /**