@react-fabric/graph 1.0.0-beta.62 → 1.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.
Files changed (220) hide show
  1. package/dist/cjs/context/context.js +16 -0
  2. package/dist/cjs/graph/index.js +62 -385
  3. package/dist/cjs/index.js +25 -21
  4. package/dist/cjs/utils/edge.js +76 -0
  5. package/dist/cjs/utils/node.js +93 -0
  6. package/dist/cjs/utils/sdfFolder.js +107 -0
  7. package/dist/cjs/viewer/Graph.js +174 -0
  8. package/dist/esm/context/context.js +15 -0
  9. package/dist/esm/graph/index.js +63 -386
  10. package/dist/esm/index.js +24 -20
  11. package/dist/esm/utils/edge.js +75 -0
  12. package/dist/esm/utils/node.js +92 -0
  13. package/dist/esm/utils/sdfFolder.js +107 -0
  14. package/dist/esm/viewer/Graph.js +174 -0
  15. package/dist/types/context/context.d.ts +35 -0
  16. package/dist/types/graph/index.d.ts +47 -24
  17. package/dist/types/index.d.ts +28 -2
  18. package/dist/types/types/index.d.ts +124 -175
  19. package/dist/types/utils/edge.d.ts +28 -0
  20. package/dist/types/utils/node.d.ts +28 -0
  21. package/dist/types/utils/sdfFolder.d.ts +75 -0
  22. package/dist/types/viewer/Graph.d.ts +31 -0
  23. package/package.json +19 -25
  24. package/src/context/context.tsx +43 -0
  25. package/src/graph/index.ts +76 -399
  26. package/src/index.ts +24 -26
  27. package/src/types/index.ts +139 -185
  28. package/src/utils/edge.ts +65 -0
  29. package/src/utils/node.ts +105 -0
  30. package/src/utils/sdfFolder.ts +141 -0
  31. package/src/viewer/Graph.tsx +159 -0
  32. package/css/styles.css +0 -56
  33. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -14
  34. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -9
  35. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +0 -35
  36. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  37. package/dist/cjs/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -20
  38. package/dist/cjs/_virtual/elk-worker.js +0 -8
  39. package/dist/cjs/components/Context.js +0 -107
  40. package/dist/cjs/components/ContextMenu.js +0 -133
  41. package/dist/cjs/components/Tools.js +0 -205
  42. package/dist/cjs/components/Viewer.js +0 -58
  43. package/dist/cjs/constants/index.js +0 -16
  44. package/dist/cjs/hooks/sigmaDragSelect.js +0 -169
  45. package/dist/cjs/hooks/sigmaHilighter.js +0 -83
  46. package/dist/cjs/hooks/sigmaMouseActions.js +0 -145
  47. package/dist/cjs/hooks/useGraphology.js +0 -41
  48. package/dist/cjs/hooks/useSigma.js +0 -112
  49. package/dist/cjs/programs/arrow-head/frag.glsl.js +0 -8
  50. package/dist/cjs/programs/arrow-head/index.js +0 -142
  51. package/dist/cjs/programs/arrow-head/vert.glsl.js +0 -8
  52. package/dist/cjs/programs/edge-curve/drawLabel.js +0 -136
  53. package/dist/cjs/programs/edge-curve/frag.glsl.js +0 -8
  54. package/dist/cjs/programs/edge-curve/index.js +0 -157
  55. package/dist/cjs/programs/edge-curve/vert.glsl.js +0 -8
  56. package/dist/cjs/programs/edge-line/drawLabel.js +0 -70
  57. package/dist/cjs/programs/edge-line/frag.glsl.js +0 -8
  58. package/dist/cjs/programs/edge-line/index.js +0 -166
  59. package/dist/cjs/programs/edge-line/vert.glsl.js +0 -8
  60. package/dist/cjs/programs/node-badge/factory.js +0 -249
  61. package/dist/cjs/programs/node-badge/frag.glsl.js +0 -8
  62. package/dist/cjs/programs/node-badge/index.js +0 -33
  63. package/dist/cjs/programs/node-badge/texture.js +0 -455
  64. package/dist/cjs/programs/node-badge/vert.glsl.js +0 -19
  65. package/dist/cjs/programs/node-circle/base/drawHover.js +0 -71
  66. package/dist/cjs/programs/node-circle/base/drawLabel.js +0 -113
  67. package/dist/cjs/programs/node-circle/base/frag.glsl.js +0 -8
  68. package/dist/cjs/programs/node-circle/base/index.js +0 -136
  69. package/dist/cjs/programs/node-circle/base/vert.glsl.js +0 -8
  70. package/dist/cjs/programs/node-circle/index.js +0 -15
  71. package/dist/cjs/programs/node-image/factory.js +0 -223
  72. package/dist/cjs/programs/node-image/frag.glsl.js +0 -8
  73. package/dist/cjs/programs/node-image/index.js +0 -14
  74. package/dist/cjs/programs/node-image/texture.js +0 -472
  75. package/dist/cjs/programs/node-image/vert.glsl.js +0 -8
  76. package/dist/cjs/programs/node-rect/base/drawHover.js +0 -68
  77. package/dist/cjs/programs/node-rect/base/drawLabel.js +0 -107
  78. package/dist/cjs/programs/node-rect/base/frag.glsl.js +0 -8
  79. package/dist/cjs/programs/node-rect/base/index.js +0 -135
  80. package/dist/cjs/programs/node-rect/base/vert.glsl.js +0 -8
  81. package/dist/cjs/programs/node-rect/index.js +0 -15
  82. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -14
  83. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -9
  84. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +0 -34
  85. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -13
  86. package/dist/esm/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -20
  87. package/dist/esm/_virtual/elk-worker.js +0 -8
  88. package/dist/esm/components/Context.js +0 -106
  89. package/dist/esm/components/ContextMenu.js +0 -133
  90. package/dist/esm/components/Tools.js +0 -205
  91. package/dist/esm/components/Viewer.js +0 -58
  92. package/dist/esm/constants/index.js +0 -16
  93. package/dist/esm/hooks/sigmaDragSelect.js +0 -169
  94. package/dist/esm/hooks/sigmaHilighter.js +0 -83
  95. package/dist/esm/hooks/sigmaMouseActions.js +0 -145
  96. package/dist/esm/hooks/useGraphology.js +0 -41
  97. package/dist/esm/hooks/useSigma.js +0 -112
  98. package/dist/esm/programs/arrow-head/frag.glsl.js +0 -8
  99. package/dist/esm/programs/arrow-head/index.js +0 -141
  100. package/dist/esm/programs/arrow-head/vert.glsl.js +0 -8
  101. package/dist/esm/programs/edge-curve/drawLabel.js +0 -136
  102. package/dist/esm/programs/edge-curve/frag.glsl.js +0 -8
  103. package/dist/esm/programs/edge-curve/index.js +0 -156
  104. package/dist/esm/programs/edge-curve/vert.glsl.js +0 -8
  105. package/dist/esm/programs/edge-line/drawLabel.js +0 -70
  106. package/dist/esm/programs/edge-line/frag.glsl.js +0 -8
  107. package/dist/esm/programs/edge-line/index.js +0 -166
  108. package/dist/esm/programs/edge-line/vert.glsl.js +0 -8
  109. package/dist/esm/programs/node-badge/factory.js +0 -249
  110. package/dist/esm/programs/node-badge/frag.glsl.js +0 -8
  111. package/dist/esm/programs/node-badge/index.js +0 -32
  112. package/dist/esm/programs/node-badge/texture.js +0 -445
  113. package/dist/esm/programs/node-badge/vert.glsl.js +0 -19
  114. package/dist/esm/programs/node-circle/base/drawHover.js +0 -71
  115. package/dist/esm/programs/node-circle/base/drawLabel.js +0 -113
  116. package/dist/esm/programs/node-circle/base/frag.glsl.js +0 -8
  117. package/dist/esm/programs/node-circle/base/index.js +0 -136
  118. package/dist/esm/programs/node-circle/base/vert.glsl.js +0 -8
  119. package/dist/esm/programs/node-circle/index.js +0 -15
  120. package/dist/esm/programs/node-image/factory.js +0 -223
  121. package/dist/esm/programs/node-image/frag.glsl.js +0 -8
  122. package/dist/esm/programs/node-image/index.js +0 -13
  123. package/dist/esm/programs/node-image/texture.js +0 -462
  124. package/dist/esm/programs/node-image/vert.glsl.js +0 -8
  125. package/dist/esm/programs/node-rect/base/drawHover.js +0 -68
  126. package/dist/esm/programs/node-rect/base/drawLabel.js +0 -107
  127. package/dist/esm/programs/node-rect/base/frag.glsl.js +0 -8
  128. package/dist/esm/programs/node-rect/base/index.js +0 -135
  129. package/dist/esm/programs/node-rect/base/vert.glsl.js +0 -8
  130. package/dist/esm/programs/node-rect/index.js +0 -15
  131. package/dist/types/components/Context.d.ts +0 -18
  132. package/dist/types/components/ContextMenu.d.ts +0 -1
  133. package/dist/types/components/Tools.d.ts +0 -1
  134. package/dist/types/components/Viewer.d.ts +0 -2
  135. package/dist/types/constants/index.d.ts +0 -12
  136. package/dist/types/graph/layout.worker.d.ts +0 -1
  137. package/dist/types/hooks/sigmaDragSelect.d.ts +0 -8
  138. package/dist/types/hooks/sigmaHilighter.d.ts +0 -3
  139. package/dist/types/hooks/sigmaMouseActions.d.ts +0 -3
  140. package/dist/types/hooks/useGraphology.d.ts +0 -6
  141. package/dist/types/hooks/useSigma.d.ts +0 -8
  142. package/dist/types/i18n/index.d.ts +0 -0
  143. package/dist/types/programs/arrow-head/frag.glsl.d.ts +0 -2
  144. package/dist/types/programs/arrow-head/index.d.ts +0 -9
  145. package/dist/types/programs/arrow-head/vert.glsl.d.ts +0 -2
  146. package/dist/types/programs/edge-curve/drawLabel.d.ts +0 -6
  147. package/dist/types/programs/edge-curve/frag.glsl.d.ts +0 -2
  148. package/dist/types/programs/edge-curve/index.d.ts +0 -43
  149. package/dist/types/programs/edge-curve/vert.glsl.d.ts +0 -2
  150. package/dist/types/programs/edge-line/drawLabel.d.ts +0 -5
  151. package/dist/types/programs/edge-line/frag.glsl.d.ts +0 -2
  152. package/dist/types/programs/edge-line/index.d.ts +0 -11
  153. package/dist/types/programs/edge-line/vert.glsl.d.ts +0 -2
  154. package/dist/types/programs/node-badge/factory.d.ts +0 -27
  155. package/dist/types/programs/node-badge/frag.glsl.d.ts +0 -2
  156. package/dist/types/programs/node-badge/index.d.ts +0 -5
  157. package/dist/types/programs/node-badge/texture.d.ts +0 -102
  158. package/dist/types/programs/node-badge/vert.glsl.d.ts +0 -2
  159. package/dist/types/programs/node-circle/base/drawHover.d.ts +0 -8
  160. package/dist/types/programs/node-circle/base/drawLabel.d.ts +0 -8
  161. package/dist/types/programs/node-circle/base/frag.glsl.d.ts +0 -2
  162. package/dist/types/programs/node-circle/base/index.d.ts +0 -37
  163. package/dist/types/programs/node-circle/base/vert.glsl.d.ts +0 -2
  164. package/dist/types/programs/node-circle/index.d.ts +0 -11
  165. package/dist/types/programs/node-image/factory.d.ts +0 -25
  166. package/dist/types/programs/node-image/frag.glsl.d.ts +0 -2
  167. package/dist/types/programs/node-image/index.d.ts +0 -5
  168. package/dist/types/programs/node-image/texture.d.ts +0 -102
  169. package/dist/types/programs/node-image/vert.glsl.d.ts +0 -2
  170. package/dist/types/programs/node-rect/base/drawHover.d.ts +0 -8
  171. package/dist/types/programs/node-rect/base/drawLabel.d.ts +0 -8
  172. package/dist/types/programs/node-rect/base/frag.glsl.d.ts +0 -2
  173. package/dist/types/programs/node-rect/base/index.d.ts +0 -34
  174. package/dist/types/programs/node-rect/base/vert.glsl.d.ts +0 -2
  175. package/dist/types/programs/node-rect/index.d.ts +0 -11
  176. package/src/components/Context.tsx +0 -143
  177. package/src/components/ContextMenu.tsx +0 -174
  178. package/src/components/Tools.tsx +0 -106
  179. package/src/components/Viewer.tsx +0 -76
  180. package/src/constants/index.ts +0 -22
  181. package/src/graph/layout.worker.ts +0 -42
  182. package/src/hooks/sigmaDragSelect.ts +0 -219
  183. package/src/hooks/sigmaHilighter.ts +0 -107
  184. package/src/hooks/sigmaMouseActions.ts +0 -153
  185. package/src/hooks/useGraphology.ts +0 -31
  186. package/src/hooks/useSigma.ts +0 -118
  187. package/src/i18n/index.ts +0 -0
  188. package/src/programs/arrow-head/frag.glsl.ts +0 -18
  189. package/src/programs/arrow-head/index.ts +0 -157
  190. package/src/programs/arrow-head/vert.glsl.ts +0 -75
  191. package/src/programs/edge-curve/drawLabel.ts +0 -166
  192. package/src/programs/edge-curve/frag.glsl.ts +0 -86
  193. package/src/programs/edge-curve/index.ts +0 -158
  194. package/src/programs/edge-curve/vert.glsl.ts +0 -110
  195. package/src/programs/edge-line/drawLabel.ts +0 -113
  196. package/src/programs/edge-line/frag.glsl.ts +0 -34
  197. package/src/programs/edge-line/index.ts +0 -165
  198. package/src/programs/edge-line/vert.glsl.ts +0 -104
  199. package/src/programs/node-badge/factory.ts +0 -327
  200. package/src/programs/node-badge/frag.glsl.ts +0 -79
  201. package/src/programs/node-badge/index.ts +0 -35
  202. package/src/programs/node-badge/texture.ts +0 -425
  203. package/src/programs/node-badge/vert.glsl.ts +0 -99
  204. package/src/programs/node-circle/base/drawHover.ts +0 -80
  205. package/src/programs/node-circle/base/drawLabel.ts +0 -145
  206. package/src/programs/node-circle/base/frag.glsl.ts +0 -72
  207. package/src/programs/node-circle/base/index.ts +0 -102
  208. package/src/programs/node-circle/base/vert.glsl.ts +0 -83
  209. package/src/programs/node-circle/index.ts +0 -19
  210. package/src/programs/node-image/factory.ts +0 -301
  211. package/src/programs/node-image/frag.glsl.ts +0 -97
  212. package/src/programs/node-image/index.ts +0 -7
  213. package/src/programs/node-image/texture.ts +0 -435
  214. package/src/programs/node-image/vert.glsl.ts +0 -60
  215. package/src/programs/node-rect/base/drawHover.ts +0 -77
  216. package/src/programs/node-rect/base/drawLabel.ts +0 -149
  217. package/src/programs/node-rect/base/frag.glsl.ts +0 -67
  218. package/src/programs/node-rect/base/index.ts +0 -109
  219. package/src/programs/node-rect/base/vert.glsl.ts +0 -87
  220. package/src/programs/node-rect/index.ts +0 -19
@@ -1,189 +1,138 @@
1
- import { type GraphOptions } from "graphology-types";
2
- import { type RefObject } from "react";
3
- import { type Graph } from "../graph";
4
- interface NodeBadge {
5
- position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top" | "left" | "right";
6
- type?: "star" | "exclaim" | "thumbUp" | "thumbDown";
7
- path?: string;
8
- /**
9
- * icon color
10
- */
11
- iconColor?: string;
12
- /**
13
- * fill color
14
- */
15
- color?: string;
16
- }
17
- export interface NodeAttributes<N = KeyValue> {
18
- /**
19
- * node label
20
- */
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ export interface NodeAttributes<N extends KeyValue = KeyValue> {
26
+ data?: N;
27
+ id: string;
28
+ type?: string;
21
29
  label?: string;
22
- /**
23
- * node shape
24
- */
25
- type?: "circle" | "rect";
26
- /**
27
- * node size
28
- */
29
- size?: number;
30
- /**
31
- * node weight to apply proportional size
32
- */
33
- weight?: number;
34
- /**
35
- * label color
36
- */
37
- labelColor?: string;
38
- /**
39
- * border color
40
- */
41
- borderColor?: string;
42
- /**
43
- * icon color
44
- */
45
- iconColor?: string;
46
- /**
47
- * fill color
48
- */
30
+ icon?: string;
31
+ image?: string;
49
32
  color?: string;
50
- /**
51
- * border width
52
- */
53
33
  border?: number;
54
- /**
55
- * hover color
56
- */
57
- hoverColor?: string;
58
- /**
59
- * highlighted color
60
- */
61
- highlightColor?: string;
62
- /**
63
- * define node type
64
- */
65
- nodeType?: string;
66
- /**
67
- * pie colors
68
- */
69
- pie?: string[];
70
- /**
71
- * svg path
72
- */
73
- path?: string;
74
- /**
75
- * avatar/image url
76
- */
77
- image?: string;
78
- /**
79
- * selected state
80
- */
81
- selected?: boolean;
82
- /**
83
- * highlighted state
84
- */
85
- highlight?: boolean;
86
- badge?: NodeBadge[];
34
+ borderColor?: string;
35
+ segments?: string[] | number[] | {
36
+ [color: string]: number;
37
+ };
38
+ size?: number;
39
+ shape?: "square" | "circle" | "folder" | "diamond" | "triangle" | "folderOpen";
40
+ visible?: boolean;
87
41
  x?: number;
88
42
  y?: number;
89
- hidden?: boolean;
90
- data?: N;
43
+ z?: number;
91
44
  }
92
- export interface EdgeAttributes<E = KeyValue> {
93
- /**
94
- * edge shape
95
- */
96
- type?: "line" | "curved";
97
- /**
98
- * edge label
99
- */
45
+ export interface EdgeAttributes<E extends KeyValue = KeyValue> {
46
+ data?: E;
47
+ id: string;
48
+ source: string;
49
+ target: string;
50
+ type?: string;
100
51
  label?: string;
101
- /**
102
- * edge size
103
- */
52
+ count?: number;
104
53
  size?: number;
105
- /**
106
- * edge weight to apply proportional size
107
- */
108
- weight?: number;
109
- /**
110
- * edge color
111
- */
112
54
  color?: string;
113
- /**
114
- * hover color
115
- */
116
- hoverColor?: string;
117
- /**
118
- * highlighted color
119
- */
120
- highlightColor?: string;
121
- /**
122
- * define edge type
123
- */
124
- edgeType?: "curved" | "line";
125
- /**
126
- * edge arrow head
127
- */
128
- arrow?: "source" | "target" | "both";
129
- /**
130
- * edge count
131
- */
132
- count?: number;
133
- /**
134
- * selected state
135
- */
136
- selected?: boolean;
137
- /**
138
- * highlighted state
139
- */
140
- highlight?: boolean;
141
- data?: E;
55
+ path?: "straight" | "curved" | "stepCurved" | "curvedS";
56
+ style?: "solid" | "dashed" | "dotted";
57
+ head?: "arrow";
58
+ tail?: "arrow";
59
+ visible?: boolean;
60
+ /** Marks a link that was created as a clone during `groupNodes`. Used by `ungroupNodes` to drop clones and revert the originals. */
61
+ groupEdge?: boolean;
62
+ }
63
+ export interface RawGraph<N extends KeyValue = KeyValue, E extends KeyValue = KeyValue> {
64
+ nodes: NodeAttributes<N>[];
65
+ edges: EdgeAttributes<E>[];
142
66
  }
143
- export interface InternalNodeAttributes<N = KeyValue> extends NodeAttributes<N> {
67
+ export interface InternalNode<N extends KeyValue = KeyValue> extends NodeAttributes<N> {
68
+ group?: boolean;
69
+ groupExpanded?: boolean;
70
+ groupNodes?: string[];
71
+ /** Back-reference to the group node that owns this (hidden) member. Empty for top-level nodes. */
144
72
  groupId?: string;
145
- isGroup?: boolean;
146
- expanded?: boolean;
147
- nodeList?: string[];
148
- opacity?: number;
149
- id?: string;
150
- fixed?: boolean;
151
- originalEdges?: Array<{
152
- key: string;
153
- source: string;
154
- target: string;
155
- attributes?: KeyValue;
156
- }>;
73
+ locked?: boolean;
74
+ /** Transient selection state, toggled by `selectNodes` / `unselectNodes`. */
75
+ selected?: boolean;
76
+ hilighted?: boolean;
77
+ x?: number;
78
+ y?: number;
79
+ z?: number;
80
+ fx?: number;
81
+ fy?: number;
82
+ fz?: number;
83
+ pieSize?: number;
84
+ slice_0?: number;
85
+ slice_1?: number;
86
+ slice_2?: number;
87
+ slice_3?: number;
88
+ slice_4?: number;
89
+ slice_5?: number;
90
+ slice_6?: number;
91
+ slice_7?: number;
92
+ slice_8?: number;
93
+ slice_9?: number;
94
+ slice_10?: number;
95
+ slice_11?: number;
96
+ color_0?: string;
97
+ color_1?: string;
98
+ color_2?: string;
99
+ color_3?: string;
100
+ color_4?: string;
101
+ color_5?: string;
102
+ color_6?: string;
103
+ color_7?: string;
104
+ color_8?: string;
105
+ color_9?: string;
106
+ color_10?: string;
107
+ color_11?: string;
157
108
  }
158
- export interface InternalEdgeAttributes<E = KeyValue> extends EdgeAttributes<E> {
159
- opacity?: number;
109
+ export interface InternalEdge<E extends KeyValue = KeyValue> extends EdgeAttributes<E> {
110
+ group?: boolean;
111
+ /** Curvature of a `path: "curved"` edge; 0 = straight. Assigned by `assignCurvature` for parallel edges. */
160
112
  curvature?: number;
161
- id?: string;
162
- }
163
- export interface RawGraph<N = KeyValue, E = KeyValue> {
164
- nodes: Array<{
165
- key: string;
166
- attributes?: NodeAttributes<N>;
167
- }>;
168
- edges: Array<{
169
- key: string;
170
- source: string;
171
- target: string;
172
- attributes?: EdgeAttributes<E>;
173
- }>;
174
- attributes?: KeyValue;
175
- options?: GraphOptions;
176
- }
177
- export interface GraphRef<N = KeyValue, E = KeyValue> {
178
- graph: Graph<N, E>;
179
- }
180
- export interface GraphProps<N = KeyValue, E = KeyValue> {
181
- ref?: RefObject<GraphRef<N, E> | null>;
182
- data: RawGraph<N, E> | Graph<N, E>;
183
- nodeReducer?: (node: NodeAttributes<N>) => NodeAttributes<N>;
184
- edgeReducer?: (edge: EdgeAttributes<E>) => EdgeAttributes<E>;
185
- onSelectChange?: (selected: string[]) => void;
186
- onNodeDoubleClick?: (node: string, attributes: NodeAttributes<N>) => void;
187
- onContextMenu?: (type: "canvas" | "node" | "edge", nodesOrEdge?: string | string[]) => void;
113
+ /** Dash length for `layerDashed`, in relative edge-length units. Assigned by `assignEdgeDash` from `shape`. */
114
+ dashSize?: number;
115
+ /** Dash gap length for `layerDashed`, in relative edge-length units. Assigned by `assignEdgeDash` from `shape`. */
116
+ gapSize?: number;
117
+ rotation?: number;
118
+ /** Transient selection state. */
119
+ selected?: boolean;
120
+ /**
121
+ * The endpoint before it was re-pointed onto a group / merge node. Captured by
122
+ * `hydrateEdge` when the link is added; read back by `ungroupNode`.
123
+ */
124
+ originalSource?: string;
125
+ originalTarget?: string;
188
126
  }
189
- export {};
127
+ /**
128
+ * Public, listener-facing node: the node `id` merged with its `data` bag. This is
129
+ * what every `nodes*` event emits — internal fields (positions, pins, group and
130
+ * selection state) never leak to listeners.
131
+ */
132
+ export type PublicNode<N extends KeyValue = KeyValue> = {
133
+ id: string;
134
+ } & N;
135
+ /** Public, listener-facing link: the link `id` merged with its `data` bag. Emitted by `edges*` events. */
136
+ export type PublicEdge<E extends KeyValue = KeyValue> = {
137
+ id: string;
138
+ } & E;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import type { DisplayData } from "sigma/types";
26
+ import type { EdgeAttributes } from "../types";
27
+ export declare function edgeReducer(_: unknown, edge: DisplayData, attrs: EdgeAttributes): DisplayData;
28
+ export declare function defaultEdgeStyles(isDark?: boolean): never[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import { type DisplayData } from "sigma/types";
26
+ import type { InternalNode } from "../types";
27
+ export declare function nodeReducer(_: unknown, node: DisplayData, attrs: InternalNode): DisplayData;
28
+ export declare function defaultNodeStyles(isDark?: boolean): never;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import { type SDFShape, type ValueSource } from "sigma/rendering";
26
+ /**
27
+ * Options for the {@link sdfFolder} shape.
28
+ *
29
+ * @property cornerRadius - Corner rounding as a fraction of the node size.
30
+ * `0` gives sharp corners; larger values round the body and the tab. May
31
+ * also be a per-node attribute via `{ attribute, default }`.
32
+ * @property rotation - Rotation of the folder, in radians, applied before the
33
+ * distance field is evaluated. May also be a per-node attribute via
34
+ * `{ attribute, default }`.
35
+ */
36
+ export interface FolderOptions {
37
+ /**
38
+ * Corner rounding as a fraction of the node size. Defaults to `0` (sharp
39
+ * corners).
40
+ */
41
+ cornerRadius?: ValueSource<number>;
42
+ /**
43
+ * Rotation of the folder, in radians, applied before the distance is
44
+ * computed. Defaults to `0`.
45
+ */
46
+ rotation?: ValueSource<number>;
47
+ }
48
+ /**
49
+ * Creates a folder SDF shape.
50
+ *
51
+ * The outline is the union of two rounded rectangles: a wide **body** and a
52
+ * smaller **tab** flap that rises above the body's top-left corner — the shape
53
+ * of a classic manila folder. Each panel is an Inigo Quilez rounded-box
54
+ * distance field (https://iquilezles.org/articles/distfunctions2d/) and the
55
+ * union is the closer of the two distances.
56
+ *
57
+ * @param options - Configuration for the folder
58
+ * @returns Folder SDF shape definition
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Sharp folder with a top-left tab
63
+ * const folder = sdfFolder();
64
+ *
65
+ * // Rounded folder
66
+ * const rounded = sdfFolder({ cornerRadius: 0.12 });
67
+ *
68
+ * // Per-node folder, driven by attributes
69
+ * const perNode = sdfFolder({
70
+ * cornerRadius: { attribute: "folderCorner" },
71
+ * rotation: { attribute: "folderRotation" },
72
+ * });
73
+ * ```
74
+ */
75
+ export declare function sdfFolder(options?: FolderOptions): SDFShape;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ import type { Graph } from "../graph";
26
+ interface GraphViewerProps<N extends KeyValue = KeyValue, E extends KeyValue = KeyValue> {
27
+ data: Graph<N, E>;
28
+ children?: React.ReactNode;
29
+ }
30
+ export declare function GraphViewer<N extends KeyValue = KeyValue, E extends KeyValue = KeyValue>({ data, children }: GraphViewerProps<N, E>): import("react").JSX.Element;
31
+ export {};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@react-fabric/graph",
3
- "version": "1.0.0-beta.62",
3
+ "version": "1.0.1",
4
4
  "description": "RUF: SigmaJS link analysis graph",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
7
- "repository": "https://github.com/adarshpastakia/react-ui-framework/tree/main/packages/graph",
7
+ "repository": "https://github.com/adarshpastakia/react-fabric/tree/main/packages/graph",
8
8
  "source": "src/index.ts",
9
9
  "main": "dist/cjs/index.js",
10
10
  "module": "dist/esm/index.js",
@@ -24,8 +24,6 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "scripts": {
27
- "makelink": "yarn link",
28
- "removelink": "yarn unlink",
29
27
  "prebuild": "rm -rf ./dist",
30
28
  "build:dts": "tsc -p ./tsconfig.build.json",
31
29
  "build:rollup": "rollup -c ../../rollup.config.mjs",
@@ -35,35 +33,31 @@
35
33
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
34
  },
37
35
  "dependencies": {
38
- "@floating-ui/react": "~0.27.16",
39
- "@react-fabric/core": "^1.0.0-beta.62",
40
- "@react-fabric/utilities": "^1.0.0-beta.62",
41
- "@sigma/edge-curve": "~3.1.0",
42
- "@sigma/utils": "~3.0.0",
43
- "classnames": "~2.5.1",
36
+ "@floating-ui/react": "~0.27.20",
37
+ "@react-fabric/core": "^1.0.1",
38
+ "@react-fabric/utilities": "^1.0.1",
39
+ "@sigma/layer-webgl": "beta",
40
+ "@sigma/node-border": "beta",
41
+ "@sigma/node-image": "beta",
42
+ "@sigma/node-piechart": "beta",
43
+ "@sigma/utils": "beta",
44
44
  "dom-to-image": "~2.6.0",
45
45
  "graphology": "~0.26.0",
46
- "graphology-canvas": "~0.4.2",
47
46
  "graphology-layout": "~0.6.1",
47
+ "graphology-layout-force": "~0.2.4",
48
48
  "graphology-layout-forceatlas2": "~0.10.1",
49
- "graphology-shortest-path": "~2.1.0",
50
49
  "graphology-types": "~0.24.8",
51
- "sigma": "~3.0.2"
50
+ "sigma": "beta"
52
51
  },
53
52
  "peerDependencies": {
54
- "i18next": "~25.6.0",
55
- "react": "~19.2.0",
56
- "react-dom": "~19.2.0",
57
- "react-i18next": "~16.2.1"
58
- },
59
- "devDependencies": {
60
- "@types/dom-to-image": "~2.6.7",
61
- "@types/highlight.js": "~10.1.0",
62
- "elkjs": "~0.11.0"
53
+ "i18next": "~26.3.6",
54
+ "react": "~19.3.0",
55
+ "react-dom": "~19.3.0",
56
+ "react-i18next": "~17.0.11"
63
57
  },
64
58
  "engines": {
65
- "node": ">=18.12.0",
66
- "npm": ">=8.19.0"
59
+ "node": ">=24.0.0",
60
+ "npm": ">=11.0.0"
67
61
  },
68
- "gitHead": "9dce2fd9bb753d67e3f8adbf50be257b4bc64242"
62
+ "gitHead": "1419a9df05b5e3850e1d2b4e896ab63df702c7e8"
69
63
  }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { createContext, use } from "react";
27
+ import type Sigma from "sigma";
28
+ import type { Graph } from "../graph";
29
+ import type { EdgeAttributes, NodeAttributes } from "../types";
30
+
31
+ interface ContextType<N extends KeyValue = KeyValue, E extends KeyValue = KeyValue> {
32
+ data: Graph<N, E>;
33
+ sigma: Sigma<NodeAttributes<N>, EdgeAttributes<E>>;
34
+ }
35
+
36
+ export const Context = createContext<ContextType>({} as ContextType);
37
+
38
+ export const useGraph = <N extends KeyValue = KeyValue, E extends KeyValue = KeyValue>() => use(Context) as ContextType<N, E>;
39
+
40
+ export const Provider = <N extends KeyValue = KeyValue, E extends KeyValue = KeyValue>(props: AnyObject) => {
41
+ const Provider = Context.Provider as React.Provider<ContextType<N, E>>;
42
+ return <Provider {...props} />;
43
+ };