@fxhash/open-form-graph 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +2099 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
import { ForceGraphMethods } from 'react-force-graph-2d';
|
2
|
+
import { ForceGraphMethods as ForceGraphMethods$1 } from 'react-force-graph-3d';
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
|
+
import { ReactNode } from 'react';
|
5
|
+
|
6
|
+
type RawNode = {
|
7
|
+
id: string;
|
8
|
+
label?: string;
|
9
|
+
imgSrc?: string;
|
10
|
+
};
|
11
|
+
type RawLink = {
|
12
|
+
source: string;
|
13
|
+
target: string;
|
14
|
+
};
|
15
|
+
type Link = {
|
16
|
+
source: Node;
|
17
|
+
target: Node;
|
18
|
+
};
|
19
|
+
type Node = {
|
20
|
+
id: string;
|
21
|
+
collapsed: boolean;
|
22
|
+
hide: boolean;
|
23
|
+
clusterSize: number;
|
24
|
+
level?: number;
|
25
|
+
childLinks: Link[];
|
26
|
+
image?: HTMLImageElement;
|
27
|
+
} & RawNode;
|
28
|
+
type RawGraphData = {
|
29
|
+
nodes: RawNode[];
|
30
|
+
links: RawLink[];
|
31
|
+
};
|
32
|
+
type GraphData = {
|
33
|
+
nodes: Node[];
|
34
|
+
links: Link[];
|
35
|
+
};
|
36
|
+
type RGB = [number, number, number];
|
37
|
+
type ColorTransform = (rgb: RGB) => RGB;
|
38
|
+
|
39
|
+
interface GraphConfig {
|
40
|
+
debug: false;
|
41
|
+
nodeSize: number;
|
42
|
+
minClusterSize: number;
|
43
|
+
maxClusterSize: number;
|
44
|
+
minZoom: number;
|
45
|
+
maxZoom: number;
|
46
|
+
focusPadding: number;
|
47
|
+
minDagLevelDistance: number;
|
48
|
+
maxDagLevelDistance: number;
|
49
|
+
theme: {
|
50
|
+
dark: [number, number, number];
|
51
|
+
light: [number, number, number];
|
52
|
+
};
|
53
|
+
}
|
54
|
+
interface LayoutConfig {
|
55
|
+
velocityDecay: number;
|
56
|
+
alphaDecay: number;
|
57
|
+
alphaMin: number;
|
58
|
+
dagLevelDistance: number;
|
59
|
+
}
|
60
|
+
type _ForceGraphMethods = ForceGraphMethods<Node, Link> | ForceGraphMethods$1<Node, Link>;
|
61
|
+
interface OpenFormGraphApi {
|
62
|
+
ref: React.MutableRefObject<_ForceGraphMethods | undefined>;
|
63
|
+
rootId: string;
|
64
|
+
data: GraphData;
|
65
|
+
onClickNode: (nodeId: string) => void;
|
66
|
+
hasNodeChildren: (nodeId: string) => boolean;
|
67
|
+
clusterSizeRange: [number, number];
|
68
|
+
graphLevelRange: [number, number];
|
69
|
+
setLayoutConfig: React.Dispatch<React.SetStateAction<LayoutConfig>>;
|
70
|
+
layoutConfig: LayoutConfig;
|
71
|
+
selectedNode: Node | null;
|
72
|
+
selectedNodeId: string | null;
|
73
|
+
setSelectedNodeId: (node: string | null) => void;
|
74
|
+
highlights: GraphData;
|
75
|
+
theme: "dark" | "light";
|
76
|
+
setTheme: (theme: "dark" | "light") => void;
|
77
|
+
config: GraphConfig;
|
78
|
+
setConfig: React.Dispatch<React.SetStateAction<GraphConfig>>;
|
79
|
+
getNodeSize: (nodeId: string) => number;
|
80
|
+
getNodeForce: (nodeId: string) => number;
|
81
|
+
search: (startNodeId: string, rootId: string) => {
|
82
|
+
nodes: Node[];
|
83
|
+
links: Link[];
|
84
|
+
};
|
85
|
+
}
|
86
|
+
|
87
|
+
interface ProjectGraphProps$1 {
|
88
|
+
width: number;
|
89
|
+
height: number;
|
90
|
+
}
|
91
|
+
declare function OpenFormGraph(props: ProjectGraphProps$1): react_jsx_runtime.JSX.Element;
|
92
|
+
|
93
|
+
interface ProjectGraphProps {
|
94
|
+
width: number;
|
95
|
+
height: number;
|
96
|
+
}
|
97
|
+
declare function OpenFormGraph3D(props: ProjectGraphProps): react_jsx_runtime.JSX.Element;
|
98
|
+
|
99
|
+
interface OpenFormGraphProviderProps {
|
100
|
+
config?: Partial<GraphConfig>;
|
101
|
+
theme: "dark" | "light";
|
102
|
+
children: ReactNode;
|
103
|
+
data: {
|
104
|
+
nodes: RawNode[];
|
105
|
+
links: RawLink[];
|
106
|
+
};
|
107
|
+
rootId: string;
|
108
|
+
}
|
109
|
+
declare function OpenFormGraphProvider({ config, theme, data, rootId: _rootId, children, }: OpenFormGraphProviderProps): react_jsx_runtime.JSX.Element;
|
110
|
+
declare function useOpenFormGraph(): OpenFormGraphApi;
|
111
|
+
|
112
|
+
declare const VOID_ROOT_ID = "void-root";
|
113
|
+
declare const DEFAULT_GRAPH_CONFIG: GraphConfig;
|
114
|
+
|
115
|
+
declare function normalize(val: number, min: number, max: number, minOut: number, maxOut: number): number;
|
116
|
+
|
117
|
+
interface ColorHandler {
|
118
|
+
(arg?: number): string;
|
119
|
+
(arg: ColorTransform): ColorHandler;
|
120
|
+
rgb: RGB;
|
121
|
+
}
|
122
|
+
declare function color(rgb: RGB): ColorHandler;
|
123
|
+
/**
|
124
|
+
* Dims a color to white or black
|
125
|
+
* @param color An array of 3 numbers representing RGB values (0-255)
|
126
|
+
* @param dimFactor A value between 0 and 1 where 0 is completely black and 1 is the original color
|
127
|
+
* @returns A new array with the dimmed RGB values
|
128
|
+
*/
|
129
|
+
declare function dim(factor?: number, white?: boolean): ColorTransform;
|
130
|
+
|
131
|
+
declare function generateTree(maxNodes: number, maxChildren: number): RawGraphData;
|
132
|
+
declare function collectChildren(node: Node, threshold: number, visited?: Set<string>): {
|
133
|
+
nodes: Node[];
|
134
|
+
links: Link[];
|
135
|
+
};
|
136
|
+
|
137
|
+
declare function preloadImage(url: string, ref: React.MutableRefObject<ForceGraphMethods<Node, Link> | undefined>): HTMLImageElement;
|
138
|
+
|
139
|
+
export { type ColorHandler, type ColorTransform, DEFAULT_GRAPH_CONFIG, type GraphConfig, type GraphData, type LayoutConfig, type Link, type Node, OpenFormGraph, OpenFormGraph3D, type OpenFormGraphApi, OpenFormGraphProvider, type RGB, type RawGraphData, type RawLink, type RawNode, VOID_ROOT_ID, collectChildren, color, dim, generateTree, normalize, preloadImage, useOpenFormGraph };
|