@gravity-ui/graph
Version:
Modern graph editor component
54 lines (53 loc) • 1.85 kB
TypeScript
import { DragContext, DragDiff } from "../../../services/drag";
import { AnchorState, EAnchorType } from "../../../store/anchor/Anchor";
import { TBlockId } from "../../../store/block/Block";
import { TPoint } from "../../../utils/types/shapes";
import { GraphComponent, TGraphComponentProps } from "../GraphComponent";
import { GraphLayer, TGraphLayerContext } from "../layers/graphLayer/GraphLayer";
export type TAnchorId = string | number;
export type TAnchor = {
id: string;
blockId: TBlockId;
type: EAnchorType | string;
index?: number;
};
export type TAnchorProps = TGraphComponentProps & TAnchor & {
size: number;
lineWidth: number;
zIndex: number;
getPosition: (anchor: TAnchor) => TPoint;
};
type TAnchorState = {
size: number;
raised: boolean;
selected: boolean;
};
export declare class Anchor<T extends TAnchorProps = TAnchorProps> extends GraphComponent<T, TAnchorState> {
readonly cursor = "pointer";
get zIndex(): number;
state: TAnchorState;
props: T;
context: TGraphLayerContext;
connectedState: AnchorState;
private shift;
private hitBoxHash;
private debouncedSetHitBox;
constructor(props: T, parent: GraphLayer);
getPosition(): TPoint;
toggleSelected(): void;
/**
* Anchor is draggable only when connection creation is disabled.
* When connections can be created via anchors, dragging is handled by ConnectionLayer.
*/
isDraggable(): boolean;
handleDragStart(context: DragContext): void;
handleDrag(diff: DragDiff, context: DragContext): void;
handleDragEnd(context: DragContext): void;
protected isVisible(): boolean;
protected unmount(): void;
didIterate(): void;
handleEvent(event: MouseEvent | KeyboardEvent): void;
private computeRenderSize;
protected render(): void;
}
export {};