✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
add generic support store hooks
AykutSaracb02f7ccb99ed
diff --git a/src/store/useConfig.tsx b/src/store/useConfig.tsxindex 020f14f7..a6c6c0ee 100644--- a/src/store/useConfig.tsx+++ b/src/store/useConfig.tsx@@ -2,9 +2,12 @@ import { ReactZoomPanPinchRef } from "react-zoom-pan-pinch";import { defaultJson } from "src/constants/data";import create from "zustand";+type StateType = keyof typeof initialStates;+type StateKey<T extends StateType> = typeof initialStates[T];+interface ConfigActions {setJson: (json: string) => void;- setConfig: (key: keyof Config, value: unknown) => void;+ setConfig: <T extends StateType, K extends StateKey<T>>(key: T, value: K) => void;getJson: () => string;zoomIn: () => void;zoomOut: () => void;diff --git a/src/store/useGraph.tsx b/src/store/useGraph.tsxindex e11462d2..dfead397 100644--- a/src/store/useGraph.tsx+++ b/src/store/useGraph.tsx@@ -17,8 +17,14 @@ const initialStates = {export type Graph = typeof initialStates;+type StateType = keyof typeof initialStates;+type StateKey<T extends StateType> = typeof initialStates[T];+interface GraphActions {- setGraphValue: (key: keyof Graph, value: any) => void;+ setGraphValue: <T extends StateType, K extends StateKey<T>>(+ key: T,+ value: K+ ) => void;setLoading: (loading: boolean) => void;setDirection: (direction: CanvasDirection) => void;expandNodes: (nodeId: string) => void;