@react-fabric/graph 1.0.0-beta.58 → 1.0.0-beta.60
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/dist/cjs/{packages/graph/src/components → components}/Context.js +6 -6
- package/dist/cjs/{packages/graph/src/components → components}/ContextMenu.js +8 -9
- package/dist/cjs/{packages/graph/src/components → components}/Tools.js +102 -24
- package/dist/cjs/{packages/graph/src/components → components}/Viewer.js +1 -0
- package/dist/cjs/{packages/graph/src/graph → graph}/index.js +75 -68
- package/dist/cjs/{packages/graph/src/hooks → hooks}/useSigma.js +5 -5
- package/dist/cjs/programs/arrow-head/frag.glsl.js +8 -0
- package/dist/cjs/{packages/graph/src/programs → programs}/arrow-head/index.js +1 -1
- package/dist/cjs/programs/arrow-head/vert.glsl.js +8 -0
- package/dist/cjs/{packages/graph/src/programs → programs}/edge-curve/index.js +2 -2
- package/dist/cjs/{packages/graph/src/programs → programs}/edge-line/index.js +2 -2
- package/dist/cjs/{packages/graph/src/programs → programs}/node-badge/vert.glsl.js +1 -1
- package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/base/drawHover.js +2 -1
- package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/base/drawLabel.js +2 -1
- package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/base/drawHover.js +2 -1
- package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/base/drawLabel.js +2 -1
- package/dist/esm/{packages/graph/src/components → components}/Context.js +6 -6
- package/dist/esm/{packages/graph/src/components → components}/ContextMenu.js +8 -9
- package/dist/esm/components/Tools.js +205 -0
- package/dist/esm/{packages/graph/src/components → components}/Viewer.js +1 -0
- package/dist/esm/{packages/graph/src/graph → graph}/index.js +75 -68
- package/dist/esm/{packages/graph/src/hooks → hooks}/useSigma.js +5 -5
- package/dist/esm/programs/arrow-head/frag.glsl.js +8 -0
- package/dist/esm/{packages/graph/src/programs → programs}/arrow-head/index.js +1 -1
- package/dist/esm/programs/arrow-head/vert.glsl.js +8 -0
- package/dist/esm/{packages/graph/src/programs → programs}/edge-curve/index.js +2 -2
- package/dist/esm/{packages/graph/src/programs → programs}/edge-line/index.js +2 -2
- package/dist/esm/{packages/graph/src/programs → programs}/node-badge/vert.glsl.js +1 -1
- package/dist/esm/{packages/graph/src/programs → programs}/node-circle/base/drawHover.js +2 -1
- package/dist/esm/{packages/graph/src/programs → programs}/node-circle/base/drawLabel.js +2 -1
- package/dist/esm/{packages/graph/src/programs → programs}/node-rect/base/drawHover.js +2 -1
- package/dist/esm/{packages/graph/src/programs → programs}/node-rect/base/drawLabel.js +2 -1
- package/dist/types/components/Context.d.ts +3 -3
- package/dist/types/components/Viewer.d.ts +1 -1
- package/dist/types/graph/index.d.ts +9 -4
- package/dist/types/hooks/sigmaHilighter.d.ts +1 -1
- package/dist/types/hooks/sigmaMouseActions.d.ts +1 -1
- package/dist/types/hooks/useGraphology.d.ts +1 -1
- package/dist/types/hooks/useSigma.d.ts +2 -2
- package/dist/types/programs/arrow-head/index.d.ts +4 -4
- package/dist/types/programs/edge-curve/index.d.ts +1 -1
- package/dist/types/programs/node-circle/base/drawHover.d.ts +1 -1
- package/dist/types/programs/node-circle/base/drawLabel.d.ts +1 -1
- package/dist/types/programs/node-circle/index.d.ts +1 -1
- package/dist/types/programs/node-rect/base/drawHover.d.ts +1 -1
- package/dist/types/programs/node-rect/base/drawLabel.d.ts +1 -1
- package/dist/types/programs/node-rect/index.d.ts +1 -1
- package/dist/types/types/index.d.ts +7 -7
- package/package.json +4 -4
- package/src/components/Context.tsx +18 -10
- package/src/components/ContextMenu.tsx +32 -14
- package/src/components/Tools.tsx +15 -16
- package/src/components/Viewer.tsx +2 -1
- package/src/graph/index.ts +68 -63
- package/src/graph/layout.worker.ts +1 -1
- package/src/hooks/sigmaHilighter.ts +2 -2
- package/src/hooks/sigmaMouseActions.ts +1 -1
- package/src/hooks/useGraphology.ts +1 -1
- package/src/hooks/useSigma.ts +8 -8
- package/src/programs/arrow-head/frag.glsl.ts +1 -1
- package/src/programs/arrow-head/index.ts +17 -8
- package/src/programs/arrow-head/vert.glsl.ts +1 -1
- package/src/programs/edge-curve/index.ts +2 -2
- package/src/programs/edge-line/index.ts +2 -2
- package/src/programs/node-badge/factory.ts +3 -3
- package/src/programs/node-badge/vert.glsl.ts +4 -4
- package/src/programs/node-circle/base/drawHover.ts +2 -2
- package/src/programs/node-circle/base/drawLabel.ts +6 -6
- package/src/programs/node-circle/index.ts +1 -1
- package/src/programs/node-rect/base/drawHover.ts +2 -2
- package/src/programs/node-rect/base/drawLabel.ts +6 -6
- package/src/programs/node-rect/index.ts +1 -1
- package/src/types/index.ts +6 -6
- package/dist/cjs/_virtual/_commonjs-dynamic-modules.js +0 -7
- package/dist/cjs/_virtual/_commonjsHelpers.js +0 -7
- package/dist/cjs/_virtual/elk.bundled.js +0 -5
- package/dist/cjs/node_modules/elkjs/lib/elk.bundled.js +0 -6667
- package/dist/cjs/packages/graph/src/programs/arrow-head/frag.glsl.js +0 -8
- package/dist/cjs/packages/graph/src/programs/arrow-head/vert.glsl.js +0 -8
- package/dist/esm/_virtual/_commonjs-dynamic-modules.js +0 -7
- package/dist/esm/_virtual/_commonjsHelpers.js +0 -7
- package/dist/esm/_virtual/elk.bundled.js +0 -5
- package/dist/esm/node_modules/elkjs/lib/elk.bundled.js +0 -6667
- package/dist/esm/packages/graph/src/components/Tools.js +0 -127
- package/dist/esm/packages/graph/src/programs/arrow-head/frag.glsl.js +0 -8
- package/dist/esm/packages/graph/src/programs/arrow-head/vert.glsl.js +0 -8
- /package/dist/cjs/{packages/graph/src/constants → constants}/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/hooks → hooks}/sigmaDragSelect.js +0 -0
- /package/dist/cjs/{packages/graph/src/hooks → hooks}/sigmaHilighter.js +0 -0
- /package/dist/cjs/{packages/graph/src/hooks → hooks}/sigmaMouseActions.js +0 -0
- /package/dist/cjs/{packages/graph/src/hooks → hooks}/useGraphology.js +0 -0
- /package/dist/cjs/{packages/graph/src/index.js → index.js} +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-curve/drawLabel.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-curve/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-curve/vert.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-line/drawLabel.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-line/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/edge-line/vert.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-badge/factory.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-badge/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-badge/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-badge/texture.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/base/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/base/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/base/vert.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-circle/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-image/factory.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-image/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-image/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-image/texture.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-image/vert.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/base/frag.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/base/index.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/base/vert.glsl.js +0 -0
- /package/dist/cjs/{packages/graph/src/programs → programs}/node-rect/index.js +0 -0
- /package/dist/esm/{packages/graph/src/constants → constants}/index.js +0 -0
- /package/dist/esm/{packages/graph/src/hooks → hooks}/sigmaDragSelect.js +0 -0
- /package/dist/esm/{packages/graph/src/hooks → hooks}/sigmaHilighter.js +0 -0
- /package/dist/esm/{packages/graph/src/hooks → hooks}/sigmaMouseActions.js +0 -0
- /package/dist/esm/{packages/graph/src/hooks → hooks}/useGraphology.js +0 -0
- /package/dist/esm/{packages/graph/src/index.js → index.js} +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-curve/drawLabel.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-curve/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-curve/vert.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-line/drawLabel.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-line/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/edge-line/vert.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-badge/factory.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-badge/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-badge/index.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-badge/texture.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-circle/base/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-circle/base/index.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-circle/base/vert.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-circle/index.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-image/factory.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-image/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-image/index.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-image/texture.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-image/vert.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-rect/base/frag.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-rect/base/index.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-rect/base/vert.glsl.js +0 -0
- /package/dist/esm/{packages/graph/src/programs → programs}/node-rect/index.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/* istanbul ignore file */
|
|
4
|
+
|
|
5
|
+
// language=GLSL
|
|
6
|
+
var SHADER_SOURCE = /* glsl */"\nattribute vec2 a_position;\nattribute vec2 a_normal;\nattribute float a_radius;\nattribute vec3 a_barycentric;\nattribute float a_opacity;\n\n#ifdef PICKING_MODE\nattribute vec4 a_id;\n#else\nattribute vec4 a_color;\n#endif\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_correctionRatio;\nuniform float u_minEdgeThickness;\nuniform float u_lengthToThicknessRatio;\nuniform float u_widenessToThicknessRatio;\n\nvarying vec4 v_color;\nvarying float v_opacity;\n\nconst float bias = 255.0 / 254.0;\n\nvoid main() {\n float minThickness = u_minEdgeThickness;\n\n float normalLength = length(a_normal);\n vec2 unitNormal = a_normal / normalLength;\n\n // These first computations are taken from edge.vert.glsl and\n // edge.clamped.vert.glsl. Please read it to get better comments on what's\n // happening:\n float pixelsThickness = max(normalLength / u_sizeRatio, minThickness);\n float webGLThickness = pixelsThickness * u_correctionRatio;\n float webGLNodeRadius = a_radius * 2.0 * u_correctionRatio / u_sizeRatio;\n float webGLArrowHeadLength = webGLThickness * u_lengthToThicknessRatio * 2.0;\n float webGLArrowHeadThickness = webGLThickness * u_widenessToThicknessRatio;\n\n float da = a_barycentric.x;\n float db = a_barycentric.y;\n float dc = a_barycentric.z;\n\n vec2 delta = vec2(\n da * (webGLNodeRadius * unitNormal.y)\n + db * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y + webGLArrowHeadThickness * unitNormal.x)\n + dc * ((webGLNodeRadius + webGLArrowHeadLength) * unitNormal.y - webGLArrowHeadThickness * unitNormal.x),\n\n da * (-webGLNodeRadius * unitNormal.x)\n + db * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x + webGLArrowHeadThickness * unitNormal.y)\n + dc * (-(webGLNodeRadius + webGLArrowHeadLength) * unitNormal.x - webGLArrowHeadThickness * unitNormal.y)\n );\n\n vec2 position = (u_matrix * vec3(a_position + delta, 1)).xy;\n\n gl_Position = vec4(position, 0, 1);\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_color = a_color;\n v_opacity = a_opacity;\n #endif\n\n v_color.a *= bias;\n}\n";
|
|
7
|
+
|
|
8
|
+
export { SHADER_SOURCE as default };
|
|
@@ -93,11 +93,11 @@ var EdgeCurveProgramBase = /*#__PURE__*/function (_EdgeProgram) {
|
|
|
93
93
|
}, {
|
|
94
94
|
key: "processVisibleItem",
|
|
95
95
|
value: function processVisibleItem(edgeIndex, startIndex, sourceData, targetData, data) {
|
|
96
|
-
var _data$color, _data$curvature, _data$opacity, _data$arrow, _data$arrow2;
|
|
96
|
+
var _data$color, _data$selected, _data$curvature, _data$opacity, _data$arrow, _data$arrow2;
|
|
97
97
|
var color = (_data$color = data.color) !== null && _data$color !== void 0 ? _data$color : this.renderer.getSetting("defaultEdgeColor");
|
|
98
98
|
if (data.selected) color = "#f00";
|
|
99
99
|
if (data.highlight) color = "#F54A4A";
|
|
100
|
-
var thickness = Math.min(data.size || 1, 0.5) * (data.selected
|
|
100
|
+
var thickness = Math.min(data.size || 1, 0.5) * (((_data$selected = data.selected) !== null && _data$selected !== void 0 ? _data$selected : data.highlight) ? 16 : 8);
|
|
101
101
|
var x1 = sourceData.x;
|
|
102
102
|
var y1 = sourceData.y;
|
|
103
103
|
var x2 = targetData.x;
|
|
@@ -97,11 +97,11 @@ var EdgeLineProgramBase = /*#__PURE__*/function (_EdgeProgram) {
|
|
|
97
97
|
}, {
|
|
98
98
|
key: "processVisibleItem",
|
|
99
99
|
value: function processVisibleItem(edgeIndex, startIndex, sourceData, targetData, data) {
|
|
100
|
-
var _data$color, _data$opacity, _data$arrow, _data$arrow2;
|
|
100
|
+
var _data$color, _data$selected, _data$opacity, _data$arrow, _data$arrow2;
|
|
101
101
|
var color = (_data$color = data.color) !== null && _data$color !== void 0 ? _data$color : this.renderer.getSetting("defaultEdgeColor");
|
|
102
102
|
if (data.selected) color = "#f00";
|
|
103
103
|
if (data.highlight) color = "#F54A4A";
|
|
104
|
-
var thickness = Math.min(data.size || 1, 0.5) * (data.selected
|
|
104
|
+
var thickness = Math.min(data.size || 1, 0.5) * (((_data$selected = data.selected) !== null && _data$selected !== void 0 ? _data$selected : data.highlight) ? 8 : 4);
|
|
105
105
|
var x1 = sourceData.x;
|
|
106
106
|
var y1 = sourceData.y;
|
|
107
107
|
var x2 = targetData.x;
|
|
@@ -14,6 +14,6 @@ var POSITION = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// language=GLSL
|
|
17
|
-
var VERTEX_SHADER_SOURCE = /* glsl */"\nattribute vec4 a_id;\nattribute vec4 a_fill;\nattribute vec4 a_color;\nattribute vec2 a_position;\nattribute float a_circle;\nattribute float a_placement;\nattribute float a_size;\nattribute float a_angle;\nattribute float a_opacity;\nattribute vec4 a_texture;\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_correctionRatio;\n\nvarying vec4 v_fill;\nvarying vec4 v_color;\nvarying vec2 v_diffVector;\nvarying float v_radius;\nvarying float v_opacity;\nvarying vec4 v_texture;\n\nconst float bias = 255.0 / 254.0;\nconst float marginRatio = 1.1;\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main() {\n float size = (a_size / 4.0) * u_correctionRatio / u_sizeRatio * 4.0;\n float originalSize = a_size * u_correctionRatio / u_sizeRatio * 4.0;\n vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));\n vec2 position = a_position + diffVector * marginRatio;\n float divisor = a_circle == 1.0 ? 2.5 : 2.0;\n if(a_placement == ".concat(POSITION["top-left"], ") {\n position.x -= originalSize / divisor;\n position.y += originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["top-right"], ") {\n position.x += originalSize / divisor;\n position.y += originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["bottom-left"], ") {\n position.x -= originalSize / divisor;\n position.y -= originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["bottom-right"], ") {\n position.x += originalSize / divisor;\n position.y -= originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION
|
|
17
|
+
var VERTEX_SHADER_SOURCE = /* glsl */"\nattribute vec4 a_id;\nattribute vec4 a_fill;\nattribute vec4 a_color;\nattribute vec2 a_position;\nattribute float a_circle;\nattribute float a_placement;\nattribute float a_size;\nattribute float a_angle;\nattribute float a_opacity;\nattribute vec4 a_texture;\n\nuniform mat3 u_matrix;\nuniform float u_sizeRatio;\nuniform float u_correctionRatio;\n\nvarying vec4 v_fill;\nvarying vec4 v_color;\nvarying vec2 v_diffVector;\nvarying float v_radius;\nvarying float v_opacity;\nvarying vec4 v_texture;\n\nconst float bias = 255.0 / 254.0;\nconst float marginRatio = 1.1;\nconst vec4 transparent = vec4(0.0, 0.0, 0.0, 0.0);\n\nvoid main() {\n float size = (a_size / 4.0) * u_correctionRatio / u_sizeRatio * 4.0;\n float originalSize = a_size * u_correctionRatio / u_sizeRatio * 4.0;\n vec2 diffVector = size * vec2(cos(a_angle), sin(a_angle));\n vec2 position = a_position + diffVector * marginRatio;\n float divisor = a_circle == 1.0 ? 2.5 : 2.0;\n if(a_placement == ".concat(POSITION["top-left"], ") {\n position.x -= originalSize / divisor;\n position.y += originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["top-right"], ") {\n position.x += originalSize / divisor;\n position.y += originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["bottom-left"], ") {\n position.x -= originalSize / divisor;\n position.y -= originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION["bottom-right"], ") {\n position.x += originalSize / divisor;\n position.y -= originalSize / divisor;\n }\n if(a_placement == ").concat(POSITION.top, ") {\n position.y += originalSize / 2.0;\n }\n if(a_placement == ").concat(POSITION.bottom, ") {\n position.y -= originalSize / 2.0;\n }\n if(a_placement == ").concat(POSITION.left, ") {\n position.x -= originalSize / 2.0;\n }\n if(a_placement == ").concat(POSITION.right, ") {\n position.x += originalSize / 2.0;\n }\n gl_Position = vec4(\n (u_matrix * vec3(position, 1)).xy,\n 0,\n 1\n );\n\n v_diffVector = diffVector;\n v_radius = size / 2.0 / marginRatio;\n\n #ifdef PICKING_MODE\n // For picking mode, we use the ID as the color:\n v_color = a_id;\n #else\n // For normal mode, we use the color:\n v_fill = mix(transparent, a_fill, a_opacity * bias);\n v_color = vec4(a_color.rgb, a_opacity * bias);\n v_opacity = a_opacity;\n // Pass the texture coordinates:\n v_texture = a_texture;\n #endif\n}\n");
|
|
18
18
|
|
|
19
19
|
export { VERTEX_SHADER_SOURCE as default };
|
|
@@ -5,6 +5,7 @@ import { drawNodeLabel } from './drawLabel.js';
|
|
|
5
5
|
/* istanbul ignore file */
|
|
6
6
|
|
|
7
7
|
function drawNodeHover(context, data, settings) {
|
|
8
|
+
var _ref, _data$labelColor;
|
|
8
9
|
var nodeSize = data.size;
|
|
9
10
|
var size = settings.labelSize;
|
|
10
11
|
var font = settings.labelFont;
|
|
@@ -12,7 +13,7 @@ function drawNodeHover(context, data, settings) {
|
|
|
12
13
|
// use node color or default node color
|
|
13
14
|
var bg = settings.defaultNodeColor || "#fff";
|
|
14
15
|
// use label color or default label color
|
|
15
|
-
var color = data.labelColor
|
|
16
|
+
var color = (_ref = (_data$labelColor = data.labelColor) !== null && _data$labelColor !== void 0 ? _data$labelColor : settings.labelColor.color) !== null && _ref !== void 0 ? _ref : "#000";
|
|
16
17
|
context.font = "".concat(weight, " ").concat(size, "px ").concat(font);
|
|
17
18
|
|
|
18
19
|
// Then we draw the label background
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/* istanbul ignore file */
|
|
4
4
|
|
|
5
5
|
function drawNodeLabel(context, data, settings) {
|
|
6
|
+
var _ref, _data$labelColor;
|
|
6
7
|
var nodeSize = data.size;
|
|
7
8
|
var size = settings.labelSize;
|
|
8
9
|
var font = settings.labelFont;
|
|
@@ -10,7 +11,7 @@ function drawNodeLabel(context, data, settings) {
|
|
|
10
11
|
// use node color or default node color
|
|
11
12
|
var bg = settings.defaultNodeColor || "#fff";
|
|
12
13
|
// use label color or default label color
|
|
13
|
-
var color = data.labelColor
|
|
14
|
+
var color = (_ref = (_data$labelColor = data.labelColor) !== null && _data$labelColor !== void 0 ? _data$labelColor : settings.labelColor.color) !== null && _ref !== void 0 ? _ref : "#000";
|
|
14
15
|
if (data.highlight) {
|
|
15
16
|
var _data$highlightColor, _data$highlightColor2;
|
|
16
17
|
// Then we draw the label background
|
|
@@ -5,6 +5,7 @@ import { drawNodeLabel } from './drawLabel.js';
|
|
|
5
5
|
/* istanbul ignore file */
|
|
6
6
|
|
|
7
7
|
function drawNodeHover(context, data, settings) {
|
|
8
|
+
var _ref, _data$labelColor;
|
|
8
9
|
var nodeSize = data.size;
|
|
9
10
|
var size = settings.labelSize;
|
|
10
11
|
var font = settings.labelFont;
|
|
@@ -12,7 +13,7 @@ function drawNodeHover(context, data, settings) {
|
|
|
12
13
|
// use node color or default node color
|
|
13
14
|
var bg = settings.defaultNodeColor || "#fff";
|
|
14
15
|
// use label color or default label color
|
|
15
|
-
var color = data.labelColor
|
|
16
|
+
var color = (_ref = (_data$labelColor = data.labelColor) !== null && _data$labelColor !== void 0 ? _data$labelColor : settings.labelColor.color) !== null && _ref !== void 0 ? _ref : "#000";
|
|
16
17
|
context.font = "".concat(weight, " ").concat(size, "px ").concat(font);
|
|
17
18
|
|
|
18
19
|
// Then we draw the label background
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/* istanbul ignore file */
|
|
4
4
|
|
|
5
5
|
function drawNodeLabel(context, data, settings) {
|
|
6
|
+
var _ref, _data$labelColor;
|
|
6
7
|
var nodeSize = data.size;
|
|
7
8
|
var size = settings.labelSize;
|
|
8
9
|
var font = settings.labelFont;
|
|
@@ -10,7 +11,7 @@ function drawNodeLabel(context, data, settings) {
|
|
|
10
11
|
// use node color or default node color
|
|
11
12
|
var bg = settings.defaultNodeColor || "#fff";
|
|
12
13
|
// use label color or default label color
|
|
13
|
-
var color = data.labelColor
|
|
14
|
+
var color = (_ref = (_data$labelColor = data.labelColor) !== null && _data$labelColor !== void 0 ? _data$labelColor : settings.labelColor.color) !== null && _ref !== void 0 ? _ref : "#000";
|
|
14
15
|
if (data.highlight) {
|
|
15
16
|
var _data$highlightColor, _data$color;
|
|
16
17
|
// Then we draw the label background
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
import { Graph } from "../graph";
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import { type Graph } from "../graph";
|
|
3
3
|
import { useDragSelection } from "../hooks/sigmaDragSelect";
|
|
4
4
|
import { useSigma } from "../hooks/useSigma";
|
|
5
|
-
import { EdgeAttributes, GraphProps, NodeAttributes } from "../types";
|
|
5
|
+
import { type EdgeAttributes, type GraphProps, type NodeAttributes } from "../types";
|
|
6
6
|
interface Context<N = KeyValue, E = KeyValue> {
|
|
7
7
|
sigma: ReturnType<typeof useSigma>;
|
|
8
8
|
graph: Graph<NodeAttributes<N>, EdgeAttributes<E>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { GraphProps } from "../types";
|
|
1
|
+
import { type GraphProps } from "../types";
|
|
2
2
|
export declare const SigmaGraph: <N = KeyValue, E = KeyValue>(props: GraphProps<N, E>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Graphology from "graphology";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { type ForceAtlas2Settings } from "graphology-layout-forceatlas2";
|
|
3
|
+
import { type GraphEvents, type GraphOptions } from "graphology-types";
|
|
4
|
+
import { type EdgeAttributes, type InternalNodeAttributes, type NodeAttributes, type RawGraph } from "../types";
|
|
4
5
|
interface ExtendedEvents extends GraphEvents {
|
|
5
6
|
nodesLoaded: (nodes: string[]) => void;
|
|
6
7
|
nodesDropped: (nodes: string[]) => void;
|
|
@@ -13,11 +14,15 @@ export declare class Graph<N = KeyValue, E = KeyValue> extends Graphology<Intern
|
|
|
13
14
|
on<Event extends keyof ExtendedEvents>(type: Event, listener: ExtendedEvents[Event]): this;
|
|
14
15
|
off<Event extends keyof ExtendedEvents>(type: Event, listener: ExtendedEvents[Event]): this;
|
|
15
16
|
emit<Event extends keyof ExtendedEvents>(type: Event, ...args: Parameters<ExtendedEvents[Event]>): boolean;
|
|
16
|
-
mergeNodes(key: string, nodes: string[], attributesOrNodeReducer?: NodeAttributes<N> | ((attributes: NodeAttributes<N
|
|
17
|
-
groupNodes(key: string, nodes: string[], attributesOrNodeReducer?: NodeAttributes<N> | ((attributes: NodeAttributes<N
|
|
17
|
+
mergeNodes(key: string, nodes: string[], attributesOrNodeReducer?: NodeAttributes<N> | ((attributes: Array<NodeAttributes<N>>) => NodeAttributes<N>), edgeReducer?: (edges: RawGraph<N, E>["edges"]) => RawGraph<N, E>["edges"]): this | undefined;
|
|
18
|
+
groupNodes(key: string, nodes: string[], attributesOrNodeReducer?: NodeAttributes<N> | ((attributes: Array<NodeAttributes<N>>) => NodeAttributes<N>), edgeReducer?: (edges: RawGraph<N, E>["edges"]) => RawGraph<N, E>["edges"]): this | undefined;
|
|
18
19
|
ungroupNode(node: string): this | undefined;
|
|
19
20
|
toggleExpanded(node: string, force?: boolean): this;
|
|
20
21
|
import(data: RawGraph<N, E> | Graph<N, E>, merge?: boolean): this;
|
|
22
|
+
circularLayout(): this;
|
|
23
|
+
private _timer;
|
|
24
|
+
private _worker?;
|
|
25
|
+
forceLayout(settings?: ForceAtlas2Settings): this;
|
|
21
26
|
private elk;
|
|
22
27
|
elkLayout(type: string): Promise<void>;
|
|
23
28
|
dropNodes(nodes: string[]): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type Sigma from "sigma";
|
|
2
|
-
import { EdgeAttributes, NodeAttributes } from "../types";
|
|
2
|
+
import { type EdgeAttributes, type NodeAttributes } from "../types";
|
|
3
3
|
export declare const attachHighlighter: (renderer: Sigma<NodeAttributes<any>, EdgeAttributes<any>>) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type Sigma from "sigma";
|
|
2
|
-
import { EdgeAttributes, NodeAttributes } from "../types";
|
|
2
|
+
import { type EdgeAttributes, type NodeAttributes } from "../types";
|
|
3
3
|
export declare const attachMouseActions: (renderer: Sigma<NodeAttributes<any>, EdgeAttributes<any>>) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Sigma from "sigma";
|
|
2
|
-
import { Graph } from "../graph";
|
|
3
|
-
import { EdgeAttributes, NodeAttributes } from "../types";
|
|
2
|
+
import { type Graph } from "../graph";
|
|
3
|
+
import { type EdgeAttributes, type NodeAttributes } from "../types";
|
|
4
4
|
export declare const useSigma: <N, E>(graph: Graph<N, E>, nodeReducer?: (node: NodeAttributes<N>) => NodeAttributes<N>, edgeReducer?: (edge: EdgeAttributes<E>) => EdgeAttributes<E>) => {
|
|
5
5
|
instance: Sigma<NodeAttributes<N>, EdgeAttributes<E>, import("graphology-types").Attributes> | undefined;
|
|
6
6
|
containerRef: import("react").Dispatch<import("react").SetStateAction<HTMLDivElement | null>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Attributes } from "graphology-types";
|
|
2
|
-
import { EdgeProgramType } from "sigma/rendering";
|
|
3
|
-
export
|
|
1
|
+
import { type Attributes } from "graphology-types";
|
|
2
|
+
import { type EdgeProgramType } from "sigma/rendering";
|
|
3
|
+
export interface CreateEdgeArrowHeadProgramOptions {
|
|
4
4
|
extremity: "source" | "target";
|
|
5
5
|
lengthToThicknessRatio: number;
|
|
6
6
|
widenessToThicknessRatio: number;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare const DEFAULT_EDGE_ARROW_HEAD_PROGRAM_OPTIONS: CreateEdgeArrowHeadProgramOptions;
|
|
9
9
|
export declare function createEdgeArrowHeadProgram<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes>(inputOptions?: Partial<CreateEdgeArrowHeadProgramOptions>): EdgeProgramType<N, E, G>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Attributes } from "graphology-types";
|
|
2
2
|
import { EdgeProgram, type ProgramInfo } from "sigma/rendering";
|
|
3
3
|
import { type EdgeDisplayData, type NodeDisplayData, type RenderParams } from "sigma/types";
|
|
4
|
-
import { InternalEdgeAttributes } from "../../types";
|
|
4
|
+
import { type InternalEdgeAttributes } from "../../types";
|
|
5
5
|
declare const UNIFORMS: readonly ["u_matrix", "u_sizeRatio", "u_dimensions", "u_pixelRatio", "u_feather", "u_minEdgeThickness", "u_lengthToThicknessRatio", "u_widenessToThicknessRatio"];
|
|
6
6
|
export declare class EdgeCurveProgramBase<N extends Attributes = Attributes, E extends Attributes = Attributes, G extends Attributes = Attributes> extends EdgeProgram<(typeof UNIFORMS)[number], N, E, G> {
|
|
7
7
|
getDefinition(): {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Settings } from "sigma/settings";
|
|
2
|
-
import { EdgeAttributes, NodeAttributes } from "../../../types";
|
|
2
|
+
import { type EdgeAttributes, type NodeAttributes } from "../../../types";
|
|
3
3
|
export declare function drawNodeHover(context: CanvasRenderingContext2D, data: NodeAttributes & {
|
|
4
4
|
opacity: number;
|
|
5
5
|
x: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Settings } from "sigma/settings";
|
|
2
|
-
import { EdgeAttributes, InternalNodeAttributes, NodeAttributes } from "../../../types";
|
|
2
|
+
import { type EdgeAttributes, type InternalNodeAttributes, type NodeAttributes } from "../../../types";
|
|
3
3
|
export declare function drawNodeLabel(context: CanvasRenderingContext2D, data: InternalNodeAttributes & {
|
|
4
4
|
opacity: number;
|
|
5
5
|
x: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeAttributes } from "../../types";
|
|
1
|
+
import { type NodeAttributes } from "../../types";
|
|
2
2
|
export declare const NodeCircleProgram: {
|
|
3
3
|
new (_gl: WebGLRenderingContext, _pickingBuffer: WebGLFramebuffer | null, _renderer: import("sigma").default<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes>): {
|
|
4
4
|
drawLabel: import("sigma/rendering").NodeLabelDrawingFunction<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes> | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Settings } from "sigma/settings";
|
|
2
|
-
import { EdgeAttributes, NodeAttributes } from "../../../types";
|
|
2
|
+
import { type EdgeAttributes, type NodeAttributes } from "../../../types";
|
|
3
3
|
export declare function drawNodeHover(context: CanvasRenderingContext2D, data: NodeAttributes & {
|
|
4
4
|
opacity: number;
|
|
5
5
|
x: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Settings } from "sigma/settings";
|
|
2
|
-
import { EdgeAttributes, InternalNodeAttributes, NodeAttributes } from "../../../types";
|
|
2
|
+
import { type EdgeAttributes, type InternalNodeAttributes, type NodeAttributes } from "../../../types";
|
|
3
3
|
export declare function drawNodeLabel(context: CanvasRenderingContext2D, data: InternalNodeAttributes & {
|
|
4
4
|
opacity: number;
|
|
5
5
|
x: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeAttributes } from "../../types";
|
|
1
|
+
import { type NodeAttributes } from "../../types";
|
|
2
2
|
export declare const NodeRectProgram: {
|
|
3
3
|
new (_gl: WebGLRenderingContext, _pickingBuffer: WebGLFramebuffer | null, _renderer: import("sigma").default<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes>): {
|
|
4
4
|
drawLabel: import("sigma/rendering").NodeLabelDrawingFunction<NodeAttributes<any>, import("graphology-types").Attributes, import("graphology-types").Attributes> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GraphOptions } from "graphology-types";
|
|
2
|
-
import { RefObject } from "react";
|
|
3
|
-
import { Graph } from "../graph";
|
|
1
|
+
import { type GraphOptions } from "graphology-types";
|
|
2
|
+
import { type RefObject } from "react";
|
|
3
|
+
import { type Graph } from "../graph";
|
|
4
4
|
interface NodeBadge {
|
|
5
5
|
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "top" | "left" | "right";
|
|
6
6
|
type?: "star" | "exclaim" | "thumbUp" | "thumbDown";
|
|
@@ -161,16 +161,16 @@ export interface InternalEdgeAttributes<E = KeyValue> extends EdgeAttributes<E>
|
|
|
161
161
|
id?: string;
|
|
162
162
|
}
|
|
163
163
|
export interface RawGraph<N = KeyValue, E = KeyValue> {
|
|
164
|
-
nodes: {
|
|
164
|
+
nodes: Array<{
|
|
165
165
|
key: string;
|
|
166
166
|
attributes?: NodeAttributes<N>;
|
|
167
|
-
}
|
|
168
|
-
edges: {
|
|
167
|
+
}>;
|
|
168
|
+
edges: Array<{
|
|
169
169
|
key: string;
|
|
170
170
|
source: string;
|
|
171
171
|
target: string;
|
|
172
172
|
attributes?: EdgeAttributes<E>;
|
|
173
|
-
}
|
|
173
|
+
}>;
|
|
174
174
|
attributes?: KeyValue;
|
|
175
175
|
options?: GraphOptions;
|
|
176
176
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/graph",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.60",
|
|
4
4
|
"description": "RUF: SigmaJS link analysis graph",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react": "~0.27.16",
|
|
39
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
40
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
39
|
+
"@react-fabric/core": "^1.0.0-beta.60",
|
|
40
|
+
"@react-fabric/utilities": "^1.0.0-beta.60",
|
|
41
41
|
"@sigma/edge-curve": "~3.1.0",
|
|
42
42
|
"@sigma/utils": "~3.0.0",
|
|
43
43
|
"classnames": "~2.5.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"node": ">=18.12.0",
|
|
66
66
|
"npm": ">=8.19.0"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "a79f053ee7e13422c06d7d9c35d4f0c2610cdf5d"
|
|
69
69
|
}
|
|
@@ -2,18 +2,22 @@ import { CoreIcons, Icon } from "@react-fabric/core";
|
|
|
2
2
|
import { fitViewportToNodes } from "@sigma/utils";
|
|
3
3
|
import {
|
|
4
4
|
createContext,
|
|
5
|
-
PropsWithChildren,
|
|
5
|
+
type PropsWithChildren,
|
|
6
6
|
useContext,
|
|
7
7
|
useEffect,
|
|
8
8
|
useImperativeHandle,
|
|
9
9
|
useState,
|
|
10
10
|
} from "react";
|
|
11
|
-
import { SigmaNodeEventPayload } from "sigma/types";
|
|
12
|
-
import { Graph } from "../graph";
|
|
11
|
+
import { type SigmaNodeEventPayload } from "sigma/types";
|
|
12
|
+
import { type Graph } from "../graph";
|
|
13
13
|
import { useDragSelection } from "../hooks/sigmaDragSelect";
|
|
14
14
|
import { useGraphology } from "../hooks/useGraphology";
|
|
15
15
|
import { useSigma } from "../hooks/useSigma";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
type EdgeAttributes,
|
|
18
|
+
type GraphProps,
|
|
19
|
+
type NodeAttributes,
|
|
20
|
+
} from "../types";
|
|
17
21
|
|
|
18
22
|
interface Context<N = KeyValue, E = KeyValue> {
|
|
19
23
|
sigma: ReturnType<typeof useSigma>;
|
|
@@ -50,28 +54,32 @@ export const GraphProvider = <N = KeyValue, E = KeyValue>({
|
|
|
50
54
|
|
|
51
55
|
const resetViewport = () => {
|
|
52
56
|
if (graph.size === 0) return;
|
|
53
|
-
|
|
57
|
+
void (
|
|
58
|
+
sigma.instance &&
|
|
54
59
|
fitViewportToNodes(sigma.instance, graph.nodes(), {
|
|
55
60
|
animate: true,
|
|
56
|
-
})
|
|
61
|
+
})
|
|
62
|
+
);
|
|
57
63
|
};
|
|
58
64
|
|
|
59
65
|
const zoomIn = () => {
|
|
60
66
|
if (graph.size === 0) return;
|
|
61
|
-
sigma.instance?.getCamera().animatedZoom();
|
|
67
|
+
void sigma.instance?.getCamera().animatedZoom();
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
const zoomOut = () => {
|
|
65
71
|
if (graph.size === 0) return;
|
|
66
|
-
sigma.instance?.getCamera().animatedUnzoom();
|
|
72
|
+
void sigma.instance?.getCamera().animatedUnzoom();
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
useEffect(() => {
|
|
70
76
|
const resetHandler = () => {
|
|
71
|
-
|
|
77
|
+
void (
|
|
78
|
+
sigma.instance &&
|
|
72
79
|
fitViewportToNodes(sigma.instance, graph.nodes(), {
|
|
73
80
|
animate: true,
|
|
74
|
-
})
|
|
81
|
+
})
|
|
82
|
+
);
|
|
75
83
|
};
|
|
76
84
|
graph.on("layoutRunning", setLayoutRunning);
|
|
77
85
|
graph.on("layoutDone", resetHandler);
|
|
@@ -32,21 +32,23 @@ import {
|
|
|
32
32
|
useFloatingNodeId,
|
|
33
33
|
useInteractions,
|
|
34
34
|
} from "@floating-ui/react";
|
|
35
|
+
import { Divider, Menu, MenuItem } from "@react-fabric/core";
|
|
35
36
|
import { cloneElement, useEffect, useRef, useState } from "react";
|
|
36
37
|
import {
|
|
37
|
-
SigmaEdgeEventPayload,
|
|
38
|
-
SigmaNodeEventPayload,
|
|
39
|
-
SigmaStageEventPayload,
|
|
38
|
+
type SigmaEdgeEventPayload,
|
|
39
|
+
type SigmaNodeEventPayload,
|
|
40
|
+
type SigmaStageEventPayload,
|
|
40
41
|
} from "sigma/types";
|
|
41
|
-
import { useGraph } from "./Context";
|
|
42
|
-
import { Divider, Menu, MenuItem } from "@react-fabric/core";
|
|
43
42
|
import { ICONS } from "../constants";
|
|
43
|
+
import { useGraph } from "./Context";
|
|
44
44
|
|
|
45
45
|
export const GraphContextMenu = () => {
|
|
46
46
|
const [isOpen, setIsOpen] = useState(false);
|
|
47
47
|
const nodeId = useFloatingNodeId();
|
|
48
|
-
const { sigma
|
|
49
|
-
const [menu, setMenu] = useState<React.ReactElement<typeof MenuItem
|
|
48
|
+
const { sigma } = useGraph();
|
|
49
|
+
const [menu, setMenu] = useState<Array<React.ReactElement<typeof MenuItem>>>(
|
|
50
|
+
[],
|
|
51
|
+
);
|
|
50
52
|
|
|
51
53
|
const { refs, floatingStyles, context } = useFloating({
|
|
52
54
|
open: isOpen,
|
|
@@ -80,24 +82,40 @@ export const GraphContextMenu = () => {
|
|
|
80
82
|
) => {
|
|
81
83
|
if ("node" in e) {
|
|
82
84
|
setMenu([
|
|
83
|
-
<MenuItem label="Select neighbors" />,
|
|
84
|
-
<Divider />,
|
|
85
|
+
<MenuItem key="0.0" label="Select neighbors" />,
|
|
86
|
+
<Divider key="0.1" />,
|
|
85
87
|
<MenuItem
|
|
88
|
+
key="0.2"
|
|
86
89
|
label="Delete node(s)"
|
|
87
90
|
color="danger"
|
|
88
91
|
icon={ICONS.delete}
|
|
89
92
|
/>,
|
|
90
|
-
<MenuItem
|
|
93
|
+
<MenuItem
|
|
94
|
+
key="0.3"
|
|
95
|
+
label="Clear graph"
|
|
96
|
+
color="danger"
|
|
97
|
+
icon={ICONS.clear}
|
|
98
|
+
/>,
|
|
91
99
|
]);
|
|
92
100
|
} else if ("edge" in e) {
|
|
93
101
|
setMenu([
|
|
94
|
-
<MenuItem label="Select neighbors" />,
|
|
95
|
-
<Divider />,
|
|
96
|
-
<MenuItem
|
|
102
|
+
<MenuItem key="1.0" label="Select neighbors" />,
|
|
103
|
+
<Divider key="1.1" />,
|
|
104
|
+
<MenuItem
|
|
105
|
+
key="1.2"
|
|
106
|
+
label="Clear graph"
|
|
107
|
+
color="danger"
|
|
108
|
+
icon={ICONS.clear}
|
|
109
|
+
/>,
|
|
97
110
|
]);
|
|
98
111
|
} else {
|
|
99
112
|
setMenu([
|
|
100
|
-
<MenuItem
|
|
113
|
+
<MenuItem
|
|
114
|
+
key="2.0"
|
|
115
|
+
label="Clear graph"
|
|
116
|
+
color="danger"
|
|
117
|
+
icon={ICONS.clear}
|
|
118
|
+
/>,
|
|
101
119
|
]);
|
|
102
120
|
}
|
|
103
121
|
const virtual = {
|
package/src/components/Tools.tsx
CHANGED
|
@@ -9,15 +9,8 @@ import { ICONS } from "../constants";
|
|
|
9
9
|
import { useGraph } from "./Context";
|
|
10
10
|
|
|
11
11
|
export const Tools = () => {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
graph,
|
|
15
|
-
selected,
|
|
16
|
-
layoutRunning,
|
|
17
|
-
resetViewport,
|
|
18
|
-
zoomIn,
|
|
19
|
-
zoomOut,
|
|
20
|
-
} = useGraph();
|
|
12
|
+
const { dragSelector, graph, selected, resetViewport, zoomIn, zoomOut } =
|
|
13
|
+
useGraph();
|
|
21
14
|
|
|
22
15
|
return (
|
|
23
16
|
<div className="flex flex-nowrap outline absolute top-0 start-0 p-0 z-1 bg-base">
|
|
@@ -62,27 +55,33 @@ export const Tools = () => {
|
|
|
62
55
|
}
|
|
63
56
|
/>
|
|
64
57
|
<Menu className="text-sm">
|
|
65
|
-
<MenuItem
|
|
66
|
-
|
|
58
|
+
<MenuItem
|
|
59
|
+
label="box"
|
|
60
|
+
onClick={async () => await graph.elkLayout("box")}
|
|
61
|
+
/>
|
|
62
|
+
<MenuItem
|
|
63
|
+
label="force"
|
|
64
|
+
onClick={async () => await graph.elkLayout("force")}
|
|
65
|
+
/>
|
|
67
66
|
<MenuItem
|
|
68
67
|
label="layered"
|
|
69
|
-
onClick={() => graph.elkLayout("layered")}
|
|
68
|
+
onClick={async () => await graph.elkLayout("layered")}
|
|
70
69
|
/>
|
|
71
70
|
<MenuItem
|
|
72
71
|
label="stress"
|
|
73
|
-
onClick={() => graph.elkLayout("stress")}
|
|
72
|
+
onClick={async () => await graph.elkLayout("stress")}
|
|
74
73
|
/>
|
|
75
74
|
<MenuItem
|
|
76
75
|
label="radial"
|
|
77
|
-
onClick={() => graph.elkLayout("radial")}
|
|
76
|
+
onClick={async () => await graph.elkLayout("radial")}
|
|
78
77
|
/>
|
|
79
78
|
<MenuItem
|
|
80
79
|
label="sporeOverlap"
|
|
81
|
-
onClick={() => graph.elkLayout("sporeOverlap")}
|
|
80
|
+
onClick={async () => await graph.elkLayout("sporeOverlap")}
|
|
82
81
|
/>
|
|
83
82
|
<MenuItem
|
|
84
83
|
label="sporeCompaction"
|
|
85
|
-
onClick={() => graph.elkLayout("sporeCompaction")}
|
|
84
|
+
onClick={async () => await graph.elkLayout("sporeCompaction")}
|
|
86
85
|
/>
|
|
87
86
|
</Menu>
|
|
88
87
|
</Dropdown>
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { Section } from "@react-fabric/core";
|
|
25
|
-
import { GraphProps } from "../types";
|
|
25
|
+
import { type GraphProps } from "../types";
|
|
26
26
|
import { GraphProvider, useGraph } from "./Context";
|
|
27
27
|
import { Tools } from "./Tools";
|
|
28
28
|
import { useEffect, useRef } from "react";
|
|
@@ -48,6 +48,7 @@ const Graph = () => {
|
|
|
48
48
|
<div className="area-content relative bg-base graph-viewer">
|
|
49
49
|
<div dir="ltr" ref={sigma.containerRef} className="absolute inset-0" />
|
|
50
50
|
<div
|
|
51
|
+
role="none"
|
|
51
52
|
ref={handlesRef}
|
|
52
53
|
dir="ltr"
|
|
53
54
|
onClick={(e) => {
|