import { RecursivePartial } from "./common" ; export interface Node { name ? : string ; [ x ] : any ; } export type Nodes = Record < string , Node > ; export interface Edge { source : string ; target : string ; [ x ] : any ; } export type Edges = Record < string , Edge > ; export interface LinePosition { x1 : number ; y1 : number ; x2 : number ; y2 : number ; } export type LayerPosition = "paths" | "nodes" | "focusring" | "edges" | "base" | "grid" | "background" | "root" ; export const LayerPositions = [ "paths" , "nodes" , "focusring" , "edges" , "base" , "grid" , "background" , "root" , ] ; export type Layers = Record < string , LayerPosition > ; export interface Position { x : number ; y : number ; } export interface Size { width : number ; height : number ; } export interface FixablePosition extends Position { fixed ? : boolean ; } export type NodePositions = Record < string , FixablePosition > ; export interface Layouts { nodes : NodePositions ; } /** ユーザ指定用 optionalな指定のためのinterface */ export type UserLayouts = RecursivePartial < Layouts > ; export interface EdgeLabelArea { source : { above : Position ; below : Position ; } ; target : { above : Position ; below : Position ; } ; } export interface Path { edges : string [ ] ; [ x ] : any ; } export type Paths = Path [ ] ; export type PositionOrCurve = Position | Position [ ] | null ; export type ViewEvent < T extends Event > = { event : T ; } ; export type NodeEvent < T extends Event > = { node : string ; event : T ; } ; export type EdgeEvent < T extends Event > = { edge : string ; edges : string [ ] ; summarized : false ; event : T ; } | { edge ? : undefined ; edges : string [ ] ; summarized : true ; event : T ; } ; export type PathEvent < T extends Event > = { path : Path ; event : T ; } ; export type NodePointerEvent = NodeEvent < PointerEvent > ; export type EdgePointerEvent = EdgeEvent < PointerEvent > ; export type Events = { "view:load" : undefined ; "view:unload" : undefined ; "view:mode" : "default" | "node" | "edge" ; "view:zoom" : number ; "view:pan" : { x : number ; y : number ; } ; "view:fit" : undefined ; "view:resize" : { x : number ; y : number ; width : number ; height : number ; } ; "view:click" : ViewEvent < PointerEvent > ; "view:contextmenu" : ViewEvent < MouseEvent > ; "node:click" : NodeEvent < PointerEvent > ; "node:pointerover" : NodeEvent < PointerEvent > ; "node:pointerout" : NodeEvent < PointerEvent > ; "node:pointerup" : NodeEvent < PointerEvent > ; "node:pointerdown" : NodeEvent < PointerEvent > ; "node:contextmenu" : NodeEvent < MouseEvent > ; "node:dragstart" : { [ name ] : Position ; } ; "node:pointermove" : { [ name ] : Position ; } ; "node:dragend" : { [ name ] : Position ; } ; "node:select" : string [ ] ; "edge:pointerup" : EdgeEvent < PointerEvent > ; "edge:pointerdown" : EdgeEvent < PointerEvent > ; "edge:click" : EdgeEvent < PointerEvent > ; "edge:pointerover" : EdgeEvent < PointerEvent > ; "edge:pointerout" : EdgeEvent < PointerEvent > ; "edge:contextmenu" : EdgeEvent < MouseEvent > ; "edge:select" : string [ ] ; "path:click" : PathEvent < MouseEvent > ; "path:contextmenu" : PathEvent < MouseEvent > ; } ; export type EventHandlers = { "*" ? : < T extends keyof Events > ( type : T , event : Events [ T ] ) => void ; } & { [ K in keyof Events ] ? : ( event : Events [ K ] ) => void ; } ; export type OnClickHandler = ( param : NodeEvent < PointerEvent > ) => void ; export type OnDragHandler = ( param : { [ name ] : Position ; } ) => void ; export interface Point { x : number ; y : number ; } export interface Sizes { width : number ; height : number ; viewBox : { x : number ; y : number ; width : number ; height : number ; } ; }