UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

40 lines (39 loc) 1.98 kB
import { ZoomConfig } from "../../api/PublicGraphApi"; import type { TBlock } from "../../components/canvas/blocks/Block"; import { Graph, TGraphConfig } from "../../graph"; import type { TGraphZoomTarget } from "../../graph"; import type { TGraphColors, TGraphConstants } from "../../graphConfig"; import type { Layer } from "../../services/Layer"; import type { TConnection } from "../../store/connection/ConnectionState"; import { RecursivePartial } from "../../utils/types/helpers"; export type HookGraphParams = Pick<TGraphConfig, "settings" | "layers"> & { graph?: Graph; name?: string; viewConfiguration?: { colors?: RecursivePartial<TGraphColors>; constants?: RecursivePartial<TGraphConstants>; }; }; export declare function useGraph(config: HookGraphParams): { graph: Graph; api: import("../../api/PublicGraphApi").PublicGraphApi; setSettings: (settings: unknown) => void; start: () => void; stop: () => void; setViewConfiguration: (viewConfig: { colors?: RecursivePartial<TGraphColors>; constants?: RecursivePartial<TGraphConstants>; }) => void; addLayer: <T extends Constructor<Layer> = Constructor<Layer<import("../../services/Layer").LayerProps, import("../../services/Layer").LayerContext, import("../..").TComponentState>>>(layerCtor: T, props: T extends Constructor<Layer<infer Props extends import("../../services/Layer").LayerProps, import("../../services/Layer").LayerContext, import("../..").TComponentState>> ? Omit<Props, "root" | "camera" | "graph" | "emitter"> & { root?: Props["root"]; } : never) => InstanceType<T>; setEntities: <B extends TBlock, C extends TConnection>(entities: { blocks?: B[]; connections?: C[]; }) => void; updateEntities: <B extends TBlock, C extends TConnection>(entities: { blocks?: B[]; connections?: C[]; }) => void; zoomTo: (target: TGraphZoomTarget, config?: ZoomConfig) => void; };