UNPKG

reagraph

Version:

WebGL Node-based Graph for React

50 lines (49 loc) 2.12 kB
import { FC, ReactNode } from 'react'; import { StoreApi } from 'zustand'; import { InternalGraphEdge, InternalGraphNode, InternalGraphPosition } from './types'; import { BufferGeometry, Mesh } from 'three'; import { CenterPositionVector, ClusterGroup } from './utils'; import { default as Graph } from 'graphology'; import { Theme } from './themes'; export type DragReferences = { [key: string]: InternalGraphNode; }; export interface GraphState { nodes: InternalGraphNode[]; edges: InternalGraphEdge[]; graph: Graph; clusters: Map<string, ClusterGroup>; collapsedNodeIds?: string[]; centerPosition?: CenterPositionVector; actives?: string[]; selections?: string[]; hoveredNodeId?: string; edgeContextMenus?: Set<string>; setEdgeContextMenus: (edges: Set<string>) => void; edgeMeshes: Array<Mesh<BufferGeometry>>; setEdgeMeshes: (edgeMeshes: Array<Mesh<BufferGeometry>>) => void; draggingIds?: string[]; drags?: DragReferences; panning?: boolean; theme: Theme; setTheme: (theme: Theme) => void; setClusters: (clusters: Map<string, ClusterGroup>) => void; setPanning: (panning: boolean) => void; setDrags: (drags: DragReferences) => void; addDraggingId: (id: string) => void; removeDraggingId: (id: string) => void; setActives: (actives: string[]) => void; setSelections: (selections: string[]) => void; setHoveredNodeId: (hoveredNodeId: string | null) => void; setNodes: (nodes: InternalGraphNode[]) => void; setEdges: (edges: InternalGraphEdge[]) => void; setNodePosition: (id: string, position: InternalGraphPosition) => void; setCollapsedNodeIds: (nodeIds: string[]) => void; setClusterPosition: (id: string, position: CenterPositionVector) => void; } export declare const createStore: ({ actives, selections, collapsedNodeIds, theme }: Partial<GraphState>) => import('zustand').UseBoundStore<StoreApi<GraphState>>; export declare const Provider: FC<{ children: ReactNode; store?: StoreApi<GraphState>; }>; export declare const useStore: <T>(selector: (state: GraphState) => T) => T;