UNPKG

react-phylogeny-tree-gl

Version:

React integration of phylocanvas.gl. Component and hook for phylogenetic tree visualistion.

44 lines (43 loc) 2.35 kB
/// <reference types="react" /> import { PhylocanvasProps, PhylocanvasInitProps, Plugins, Phylocanvas, Source, PhylocanvasMethods, TreeNode } from './phylocanvas.gl'; export declare type Props = Record<string, unknown> & PhylocanvasProps; declare type SourceRequired = { source: Source; }; export declare type InitProps<CP extends Props> = CP extends SourceRequired ? Props : Props & SourceRequired; export declare type TreeProps<IP extends InitProps<CP>, CP extends Props, M extends Record<string, (...args: unknown[]) => unknown>> = { initProps: IP; controlledProps?: CP | undefined; plugins?: Plugins<IP & CP, M>; hooks?: Hooks<IP & CP, M>; zoomButtons?: boolean; zoomButtonsStyle?: React.CSSProperties; }; export declare type Hooks<P extends PhylocanvasInitProps, M extends Record<string, (...args: unknown[]) => unknown>> = ((getTree: GetTree<P, M>, props: P) => void)[]; export declare type GetTree<P extends PhylocanvasInitProps = PhylocanvasInitProps, M extends Record<string, (...args: unknown[]) => unknown> = Record<string, (...args: unknown[]) => unknown>> = () => Phylocanvas<P, M> | null; export declare type PhylogenyTreeRef<P extends PhylocanvasInitProps = PhylocanvasInitProps & Record<string, unknown>, M extends Record<string, (...args: unknown[]) => unknown> = Record<string, (...args: unknown[]) => unknown>> = { getTree: GetTree<P, M>; }; export declare type RedoUndoHookedMethodsNames = 'setProps' | 'setRoot' | 'setSource'; export declare type MethodArgs<M extends RedoUndoHookedMethodsNames> = Parameters<(PhylocanvasMethods & UndoRedoMethods)[M]>; export declare type StateValue<M extends RedoUndoHookedMethodsNames = RedoUndoHookedMethodsNames, MP extends M = M> = { method: M; args: MethodArgs<MP>; props?: Record<string, unknown> | undefined; }; export declare type RedoUndoState = { past: StateValue[]; future: StateValue[]; }; export declare type UndoRedoProps = { history: RedoUndoState; } & PhylocanvasInitProps; export declare type UndoRedoMethods = { canUndo: () => boolean; canRedo: () => boolean; undo: () => void; redo: () => void; setSource: (data: Source, original?: Source | undefined, isUndoRedo?: boolean) => void; setRoot: (nodeOrId?: TreeNode | string, props?: Partial<UndoRedoProps>, isUndoRedo?: boolean) => void; }; export {};