import { SvgPanZoomInstance } from '../modules/svg-pan-zoom-ex'; import { LayoutHandler } from '../layouts/handler'; import { RecursivePartial } from './common'; import { Edge, Edges, LayerName, Node, Path, Position } from './types'; type CallableValue = V | ((target: T) => V); type CallableValues = { [K in keyof V]: CallableValue; }; export declare class Config { static value(value: CallableValue, target: T): V; static values(value: CallableValues, target: T): V; } export interface GridLine { color: string; width: number; dasharray?: string | number; } export interface GridConfig { visible: boolean; interval: number; thickIncrements: number | false; line: GridLine; thick: GridLine; } export interface BasicShapeStyle { strokeWidth: number; strokeColor?: string; strokeDasharray?: string | number; color: string; } type Percent = `${number}%`; type Pixel = `${number}px`; type NumericString = `${number}`; export type MarginValue = Percent | Pixel | NumericString | number; export type FitContentMargin = MarginValue | { top?: MarginValue; left?: MarginValue; right?: MarginValue; bottom?: MarginValue; }; export interface ViewConfig { scalingObjects: boolean; panEnabled: boolean; zoomEnabled: boolean; minZoomLevel: number; maxZoomLevel: number; doubleClickZoomEnabled: boolean; mouseWheelZoomEnabled: boolean; boxSelectionEnabled: boolean; fit?: boolean; autoPanAndZoomOnLoad: false | "center-zero" | "center-content" | "fit-content"; fitContentMargin: FitContentMargin; autoPanOnResize: boolean; layoutHandler: LayoutHandler; onSvgPanZoomInitialized?: (instance: SvgPanZoomInstance) => void; grid: GridConfig; selection: { box: BasicShapeStyle; detector: (event: KeyboardEvent) => boolean; }; builtInLayerOrder: Readonly; onBeforeInitialDisplay?: (() => Promise) | (() => any); } export type ShapeStyleBase = BasicShapeStyle; export type ShapeType = "circle" | "rect"; interface CircleShape extends ShapeStyleBase { radius: number; } interface RectangleShape extends ShapeStyleBase { width: number; height: number; borderRadius: number; } type ShapeBase = { type: T; }; export type ShapeStyle = ShapeBase & CircleShape & RectangleShape; export type CircleShapeStyle = ShapeBase<"circle"> & CircleShape; export type RectangleShapeStyle = ShapeBase<"rect"> & RectangleShape; export type AnyShapeStyle = CircleShapeStyle | RectangleShapeStyle; interface Padding { vertical: number; horizontal: number; } export interface LabelBackgroundStyle { visible: boolean; color?: string; padding?: number | Padding; borderRadius?: number; } export interface LabelStyle { fontFamily?: string; fontSize: number; color: string; background?: LabelBackgroundStyle; lineHeight: number; } export interface ZOrderConfig { enabled: boolean; zIndex: CallableValue; bringToFrontOnHover: boolean; bringToFrontOnSelected: boolean; } export interface ObjectConfigs { selectable: CallableValue | number; zOrder: ZOrderConfig; } export declare enum NodeLabelDirection { CENTER = "center", NORTH = "north", NORTH_EAST = "north-east", EAST = "east", SOUTH_EAST = "south-east", SOUTH = "south", SOUTH_WEST = "south-west", WEST = "west", NORTH_WEST = "north-west" } export type NodeLabelDirectionType = "center" | "north" | "north-east" | "east" | "south-east" | "south" | "south-west" | "west" | "north-west"; export interface OppositeNode { nodeId: string; pos: Position; } export type OppositeNodes = Record; export interface NodeLabelDirectionHandlerParams { nodeId: string; pos: Position; oppositeNodes: OppositeNodes; } export type NodeLabelDirectionAutoAdjustmentHandler = (params: NodeLabelDirectionHandlerParams) => NodeLabelDirectionType | null; export interface NodeLabelStyle extends LabelStyle { visible: boolean; margin: number; direction: NodeLabelDirectionType; directionAutoAdjustment: boolean | NodeLabelDirectionAutoAdjustmentHandler; text: string; handleNodeEvents: boolean; } export interface NodeFocusRingStyle { visible: boolean; width: number; padding: number; color: string; dasharray?: string | number; } export interface NodeConfig { normal: CallableValues; hover?: CallableValues; selected: CallableValues; draggable: CallableValue; selectable: CallableValue | number; label: CallableValues; focusring: NodeFocusRingStyle; zOrder: ZOrderConfig; transition?: string; } export interface StrokeStyle { width: number; color: string; dasharray?: string | number; linecap?: "butt" | "round" | "square"; animate: boolean; animationSpeed: number; } export interface EdgeLabelStyle extends LabelStyle { margin: number; padding: number; } export type EdgeHeadType = "none" | "arrow" | "angle" | "circle" | "custom"; export type MarkerUnits = "strokeWidth" | "userSpaceOnUse"; export interface MarkerStyle { type: EdgeHeadType; width: number; height: number; margin: number; offset: number; units: MarkerUnits; color: string | null; customId?: string; } export type EdgeType = "straight" | "curve"; export type EdgeKeepOrderType = "clock" | "vertical" | "horizontal"; export interface SelfLoopEdgeStyle { radius: number; offset: number; angle: number; isClockwise: boolean; } export interface EdgeConfig { normal: CallableValues; hover?: CallableValues; selected: CallableValues; selectable: CallableValue | number; gap: number | ((edges: Edges, configs: Configs) => number); type: EdgeType; marker: { source: CallableValues; target: CallableValues; }; margin: number | null; summarize: boolean | ((edges: Edges, configs: Configs) => boolean | null); summarized: { label: CallableValues>; shape: CallableValues>; stroke: CallableValues>; }; selfLoop: CallableValues; keepOrder: EdgeKeepOrderType; label: CallableValues; zOrder: ZOrderConfig; } export interface PathStrokeStyle extends StrokeStyle { linejoin: "miter" | "round" | "bevel"; } export type PathEndType = "centerOfNode" | "edgeOfNode"; export interface PathConfig

{ visible: boolean; clickable: CallableValue; hoverable: CallableValue; curveInNode: boolean; end: PathEndType; margin: CallableValue; path: CallableValues; normal: CallableValues; hover?: CallableValues; selected: CallableValues; selectable: CallableValue | number; zOrder: ZOrderConfig

; transition?: string; } export interface Configs { view: ViewConfig; node: NodeConfig; edge: EdgeConfig; path: PathConfig

; } /** For specification by the user */ export type UserConfigs = RecursivePartial>; /** Make a config with self object */ export declare function withSelf(callback: (self: T) => T): T; /** @deprecated */ export declare function configsWithType = UserConfigs>(configs: U): U & UserConfigs; /** Define configurations */ export declare function defineConfigs = UserConfigs>(configs: U): U & UserConfigs; export {};