@gravity-ui/graph
Version:
Modern graph editor component
84 lines (83 loc) • 6.3 kB
TypeScript
import type { Block, TBlock } from "../components/canvas/blocks/Block";
import { BlockConnection } from "../components/canvas/connections/BlockConnection";
import { Component } from "../lib";
import { TConnection } from "./connection/ConnectionState";
import { RootStore } from "./index";
export declare enum ECanChangeBlockGeometry {
ALL = "all",
ONLY_SELECTED = "onlySelected",
NONE = "none"
}
export type TGraphSettingsConfig<Block extends TBlock = TBlock, Connection extends TConnection = TConnection> = {
canDragCamera: boolean;
canZoomCamera: boolean;
/** @deprecated Use NewBlockLayer parameters instead */
canDuplicateBlocks?: boolean;
canChangeBlockGeometry: ECanChangeBlockGeometry;
canCreateNewConnections: boolean;
scaleFontSize: number;
showConnectionArrows: boolean;
useBezierConnections: boolean;
bezierConnectionDirection: "vertical" | "horizontal";
useBlocksAnchors: boolean;
connectivityComponentOnClickRaise: boolean;
showConnectionLabels: boolean;
blockComponents: Record<string, typeof Block<Block>>;
connection?: typeof BlockConnection<Connection>;
background?: typeof Component;
};
export declare class GraphEditorSettings {
rootStore: RootStore;
$settings: import("@preact/signals-core").Signal<TGraphSettingsConfig<TBlock, TConnection>>;
$blockComponents: import("@preact/signals-core").ReadonlySignal<Record<string, {
new (props: import("../components/canvas/blocks/Block").TBlockProps, parent: import("../components/canvas/layers/graphLayer/GraphLayer").GraphLayer): Block<TBlock, import("../components/canvas/blocks/Block").TBlockProps>;
IS: "Block";
create<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(this: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props, options?: {
readonly key?: string;
readonly ref?: ((inst: any) => void) | string;
}): import("../lib/CoreComponent").ComponentDescriptor<Props, Context>;
mount<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(Component: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props): import("../lib").CoreComponent<Props, Context>;
unmount(instance: any): void;
}>>;
$background: import("@preact/signals-core").ReadonlySignal<typeof Component>;
$connection: import("@preact/signals-core").ReadonlySignal<{
new (props: import("../components/canvas/connections/BlockConnection").TConnectionProps, parent: import("../components/canvas/connections/BlockConnections").BlockConnections): BlockConnection<TConnection>;
create<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(this: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props, options?: {
readonly key?: string;
readonly ref?: ((inst: any) => void) | string;
}): import("../lib/CoreComponent").ComponentDescriptor<Props, Context>;
mount<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(Component: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props): import("../lib").CoreComponent<Props, Context>;
unmount(instance: any): void;
}>;
constructor(rootStore: RootStore);
setupSettings(config: Partial<TGraphSettingsConfig>): void;
setConfigFlag<K extends keyof TGraphSettingsConfig>(flagPath: K, value: TGraphSettingsConfig[K]): void;
getConfigFlag(flagPath: keyof TGraphSettingsConfig): number | boolean | typeof Component | ECanChangeBlockGeometry | "vertical" | "horizontal" | Record<string, {
new (props: import("../components/canvas/blocks/Block").TBlockProps, parent: import("../components/canvas/layers/graphLayer/GraphLayer").GraphLayer): Block<TBlock, import("../components/canvas/blocks/Block").TBlockProps>;
IS: "Block";
create<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(this: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props, options?: {
readonly key?: string;
readonly ref?: ((inst: any) => void) | string;
}): import("../lib/CoreComponent").ComponentDescriptor<Props, Context>;
mount<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(Component: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props): import("../lib").CoreComponent<Props, Context>;
unmount(instance: any): void;
}> | {
new (props: import("../components/canvas/connections/BlockConnection").TConnectionProps, parent: import("../components/canvas/connections/BlockConnections").BlockConnections): BlockConnection<TConnection>;
create<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(this: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props, options?: {
readonly key?: string;
readonly ref?: ((inst: any) => void) | string;
}): import("../lib/CoreComponent").ComponentDescriptor<Props, Context>;
mount<Props extends import("../lib/CoreComponent").CoreComponentProps, Context extends import("../lib/CoreComponent").CoreComponentContext>(Component: Constructor<import("../lib").CoreComponent<Props, Context>>, props?: Props): import("../lib").CoreComponent<Props, Context>;
unmount(instance: any): void;
};
$connectionsSettings: import("@preact/signals-core").ReadonlySignal<{
useBezierConnections: boolean;
showConnectionLabels: boolean;
canCreateNewConnections: boolean;
showConnectionArrows: boolean;
bezierConnectionDirection: "vertical" | "horizontal";
}>;
toJSON(): TGraphSettingsConfig<TBlock, TConnection>;
get asConfig(): TGraphSettingsConfig;
reset(): void;
}