Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript types #113

Merged
merged 5 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
declare module "react-graph-vis" {
import { Network, NetworkEvents, Options, Node, Edge, DataSet, Data } from "vis";
import { Component } from "react";

export { Network, NetworkEvents, Options, Node, Edge, DataSet, Data } from "vis";

export type GraphEvents = {
[event in NetworkEvents]?: (params?: any) => void;
};

export interface NetworkGraphProps {
graph: Data;
options?: Options;
events?: GraphEvents;
getNetwork?: (network: Network) => void;
identifier?: string;
style?: React.CSSProperties;
getNodes?: (nodes: DataSet<Node>) => void;
getEdges?: (edges: DataSet<Edge>) => void;
}

export interface NetworkGraphState {
identifier: string;
}

export default class NetworkGraph extends Component<
NetworkGraphProps,
NetworkGraphState
> {
render();
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.7",
"description": "A react component to render nice graphs using vis.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel -d lib/ src/",
Expand Down Expand Up @@ -33,6 +34,8 @@
"vis-network": "^9.0.0"
},
"devDependencies": {
"@types/react": "^17.0.4",
"@types/vis": "^4.21.21",
"babel-cli": "^6.22.2",
"babel-preset-env": "^1.1.8",
"babel-preset-stage-3": "^6.22.0"
Expand Down