fix: improve TSDoc comments for HandleProps, NodeBase and InternalNodeBase
This commit is contained in:
@@ -15,29 +15,43 @@ export type Handle = {
|
|||||||
|
|
||||||
export type HandleProps = {
|
export type HandleProps = {
|
||||||
/**
|
/**
|
||||||
* Type of the handle
|
* Type of the handle.
|
||||||
|
* @default "source"
|
||||||
* @example HandleType.Source, HandleType.Target
|
* @example HandleType.Source, HandleType.Target
|
||||||
*/
|
*/
|
||||||
type: HandleType;
|
type: HandleType;
|
||||||
/**
|
/**
|
||||||
* Position of the handle
|
* The position of the handle relative to the node. In a horizontal flow source handles are
|
||||||
* @example Position.TopLeft, Position.TopRight,
|
* typically `Position.Right` and in a vertical flow they are typically `Position.Top`.
|
||||||
* Position.BottomLeft, Position.BottomRight
|
* @default Position.Top
|
||||||
|
* @example Position.TopLeft, Position.TopRight, Position.BottomLeft, Position.BottomRight
|
||||||
*/
|
*/
|
||||||
position: Position;
|
position: Position;
|
||||||
/** Should you be able to connect to/from this handle */
|
/**
|
||||||
|
* Should you be able to connect to/from this handle.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
isConnectable?: boolean;
|
isConnectable?: boolean;
|
||||||
/** Should you be able to connect from this handle */
|
/**
|
||||||
|
* Dictates whether a connection can start from this handle.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
isConnectableStart?: boolean;
|
isConnectableStart?: boolean;
|
||||||
/** Should you be able to connect to this handle */
|
/**
|
||||||
|
* Dictates whether a connection can end on this handle.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
isConnectableEnd?: boolean;
|
isConnectableEnd?: boolean;
|
||||||
/**
|
/**
|
||||||
* Callback if connection is valid
|
* Called when a connection is dragged to this handle. You can use this callback to perform some
|
||||||
|
* custom validation logic based on the connection target and source, for example. Where possible,
|
||||||
|
* we recommend you move this logic to the `isValidConnection` prop on the main ReactFlow
|
||||||
|
* component for performance reasons.
|
||||||
* @remarks connection becomes an edge if isValidConnection returns true
|
* @remarks connection becomes an edge if isValidConnection returns true
|
||||||
*/
|
*/
|
||||||
isValidConnection?: IsValidConnection;
|
isValidConnection?: IsValidConnection;
|
||||||
/**
|
/**
|
||||||
* Id of the handle
|
* Id of the handle.
|
||||||
* @remarks optional if there is only one handle of this type
|
* @remarks optional if there is only one handle of this type
|
||||||
*/
|
*/
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
|
|||||||
@@ -12,52 +12,62 @@ export type NodeBase<
|
|||||||
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
NodeData extends Record<string, unknown> = Record<string, unknown>,
|
||||||
NodeType extends string = string
|
NodeType extends string = string
|
||||||
> = {
|
> = {
|
||||||
/** Unique id of a node */
|
/** Unique id of a node. */
|
||||||
id: string;
|
id: string;
|
||||||
/**
|
/**
|
||||||
* Position of a node on the pane
|
* Position of a node on the pane.
|
||||||
* @example { x: 0, y: 0 }
|
* @example { x: 0, y: 0 }
|
||||||
*/
|
*/
|
||||||
position: XYPosition;
|
position: XYPosition;
|
||||||
/** Arbitrary data passed to a node */
|
/** Arbitrary data passed to a node. */
|
||||||
data: NodeData;
|
data: NodeData;
|
||||||
/** Type of node defined in nodeTypes */
|
/** Type of node defined in `nodeTypes`. */
|
||||||
type?: NodeType;
|
type?: NodeType;
|
||||||
/**
|
/**
|
||||||
* Only relevant for default, source, target nodeType. controls source position
|
* Only relevant for default, source, target nodeType. Controls source position.
|
||||||
* @example 'right', 'left', 'top', 'bottom'
|
* @example 'right', 'left', 'top', 'bottom'
|
||||||
*/
|
*/
|
||||||
sourcePosition?: Position;
|
sourcePosition?: Position;
|
||||||
/**
|
/**
|
||||||
* Only relevant for default, source, target nodeType. controls target position
|
* Only relevant for default, source, target nodeType. Controls target position.
|
||||||
* @example 'right', 'left', 'top', 'bottom'
|
* @example 'right', 'left', 'top', 'bottom'
|
||||||
*/
|
*/
|
||||||
targetPosition?: Position;
|
targetPosition?: Position;
|
||||||
|
/** Whether or not the node should be visible on the canvas. */
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
/** True, if node is being dragged */
|
/** Whether or not the node is currently being dragged. */
|
||||||
dragging?: boolean;
|
dragging?: boolean;
|
||||||
|
/** Whether or not the node is able to be dragged. */
|
||||||
draggable?: boolean;
|
draggable?: boolean;
|
||||||
selectable?: boolean;
|
selectable?: boolean;
|
||||||
connectable?: boolean;
|
connectable?: boolean;
|
||||||
deletable?: boolean;
|
deletable?: boolean;
|
||||||
|
/**
|
||||||
|
* A class name that can be applied to elements inside the node that allows those elements to act
|
||||||
|
* as drag handles, letting the user drag the node by clicking and dragging on those elements.
|
||||||
|
*/
|
||||||
dragHandle?: string;
|
dragHandle?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
initialWidth?: number;
|
initialWidth?: number;
|
||||||
initialHeight?: number;
|
initialHeight?: number;
|
||||||
/** Parent node id, used for creating sub-flows */
|
/** Parent node id, used for creating sub-flows. */
|
||||||
parentId?: string;
|
parentId?: string;
|
||||||
zIndex?: number;
|
zIndex?: number;
|
||||||
/**
|
/**
|
||||||
* Boundary a node can be moved in
|
* Boundary a node can be moved in.
|
||||||
* @example 'parent' or [[0, 0], [100, 100]]
|
* @example 'parent' or [[0, 0], [100, 100]]
|
||||||
*/
|
*/
|
||||||
extent?: 'parent' | CoordinateExtent;
|
extent?: 'parent' | CoordinateExtent;
|
||||||
|
/**
|
||||||
|
* When `true`, the parent node will automatically expand if this node is dragged to the edge of
|
||||||
|
* the parent node's bounds.
|
||||||
|
*/
|
||||||
expandParent?: boolean;
|
expandParent?: boolean;
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
/**
|
/**
|
||||||
* Origin of the node relative to it's position
|
* Origin of the node relative to its position.
|
||||||
* @example
|
* @example
|
||||||
* [0.5, 0.5] // centers the node
|
* [0.5, 0.5] // centers the node
|
||||||
* [0, 0] // top left
|
* [0, 0] // top left
|
||||||
@@ -71,7 +81,7 @@ export type NodeBase<
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = NodeType & {
|
export type InternalNodeBase<NodeType extends NodeBase = NodeBase> = Omit<NodeType, 'measured'> & {
|
||||||
measured: {
|
measured: {
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
@@ -99,11 +109,11 @@ export type NodeProps<NodeType extends NodeBase> = Pick<
|
|||||||
'id' | 'data' | 'width' | 'height' | 'sourcePosition' | 'targetPosition' | 'dragHandle' | 'parentId'
|
'id' | 'data' | 'width' | 'height' | 'sourcePosition' | 'targetPosition' | 'dragHandle' | 'parentId'
|
||||||
> &
|
> &
|
||||||
Required<Pick<NodeType, 'type' | 'dragging' | 'zIndex' | 'selectable' | 'deletable' | 'selected' | 'draggable'>> & {
|
Required<Pick<NodeType, 'type' | 'dragging' | 'zIndex' | 'selectable' | 'deletable' | 'selected' | 'draggable'>> & {
|
||||||
/** whether a node is connectable or not */
|
/** Whether a node is connectable or not. */
|
||||||
isConnectable: boolean;
|
isConnectable: boolean;
|
||||||
/** position absolute x value */
|
/** Position absolute x value. */
|
||||||
positionAbsoluteX: number;
|
positionAbsoluteX: number;
|
||||||
/** position absolute x value */
|
/** Position absolute y value. */
|
||||||
positionAbsoluteY: number;
|
positionAbsoluteY: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user