UNPKG

sigma

Version:

A JavaScript library dedicated to graph drawing.

75 lines (74 loc) 1.81 kB
/** * Sigma.js Types * =============== * * Various type declarations used throughout the library. * @module */ /** * Util type to represent maps of typed elements, but implemented with * JavaScript objects. */ export declare type PlainObject<T = any> = { [k: string]: T; }; /** * Returns a type similar to T, but with the the K set of properties of the type * T optional. */ export declare type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> & { [others: string]: any; }; /** * Returns a type similar to T, but with the the K set of properties of the type * T *required*, and the rest optional. */ export declare type PartialButFor<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>> & { [others: string]: any; }; export declare type Listener = (...args: any[]) => void; export interface CameraState extends Coordinates { angle: number; ratio: number; } export interface Coordinates { x: number; y: number; } export interface MouseCoords extends Coordinates { clientX: number; clientY: number; ctrlKey: boolean; metaKey: boolean; altKey: boolean; shiftKey: boolean; preventDefault(): void; original: MouseEvent; } export interface TouchCoords { touches: Coordinates[]; ctrlKey: boolean; metaKey: boolean; altKey: boolean; shiftKey: boolean; preventDefault(): void; original: TouchEvent; } export interface Dimensions { width: number; height: number; } export declare type Extent = [number, number]; export interface NodeAttributes extends Coordinates { size: number; color: string; hidden: boolean; highlighted: boolean; label: string; } export interface EdgeAttributes { size: number; color: string; hidden: boolean; label: string; }