Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-sigma/core

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-sigma/core - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

28

lib/hooks/useRegisterEvents.js

@@ -48,3 +48,4 @@ "use strict";

}
const eventTypes = Object.keys(eventHandlers);
const userEvents = eventHandlers;
const eventTypes = Object.keys(userEvents);
const edgeSettings = {};

@@ -71,3 +72,3 @@ const reverseEdgeSettings = {};

eventTypes.forEach((event) => {
const eventHandler = eventHandlers[event];
const eventHandler = userEvents[event];
if (sigmaEvents.find((e) => e === event)) {

@@ -87,3 +88,2 @@ sigma.on(event, eventHandler);

return () => {
let event;
if (Object.keys(reverseEdgeSettings).length > 0) {

@@ -93,17 +93,17 @@ setSettings(reverseEdgeSettings);

if (sigma) {
for (event in eventHandlers) {
const eventHandler = eventHandlers[event];
if (event in sigmaEvents) {
sigma.removeListener(event, eventHandler);
eventTypes.forEach((event) => {
const eventHandler = userEvents[event];
if (sigmaEvents.find((e) => e === event)) {
sigma.off(event, eventHandler);
}
if (event in mouseEvents) {
sigma.getMouseCaptor().removeListener(event, eventHandler);
if (mouseEvents.find((e) => e === event)) {
sigma.getMouseCaptor().off(event, eventHandler);
}
if (event in touchEvents) {
sigma.getTouchCaptor().removeListener(event, eventHandler);
if (touchEvents.find((e) => e === event)) {
sigma.getTouchCaptor().off(event, eventHandler);
}
if (event in cameraEvents) {
sigma.getCamera().removeListener(event, eventHandler);
if (cameraEvents.find((e) => e === event)) {
sigma.getCamera().off(event, eventHandler);
}
}
});
}

@@ -110,0 +110,0 @@ };

@@ -1,2 +0,2 @@

import*as e from"react";import t,{createContext as n,useContext as a,useState as r,useEffect as s,useCallback as c,useRef as l,useMemo as o}from"react";import{isEqual as i}from"lodash";import u from"graphology";import{Sigma as d}from"sigma";const g=n(null),m=g.Provider;function h(){const e=a(g);if(null==e)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return e}function v(){return h().sigma}function f(){const{sigma:e,container:t}=h(),[n,a]=r({});return s((()=>{if(!e||!n)return;const a={};return Object.keys(n).forEach((t=>{a[t]=n[t],e.setSetting(t,n[t])})),()=>{e&&t&&t.offsetWidth>0&&t.offsetHeight>0&&Object.keys(a).forEach((t=>{e.setSetting(t,a[t])}))}}),[e,n,t]),a}const p=["clickNode","rightClickNode","downNode","enterNode","leaveNode","doubleClickNode","wheelNode","clickEdge","rightClickEdge","downEdge","enterEdge","leaveEdge","doubleClickEdge","wheelEdge","clickStage","rightClickStage","downStage","doubleClickStage","wheelStage","kill"],E=["click","rightClick","mouseup","mousedown","mousemove","doubleClick","wheel"],b=["touchup","touchdown","touchmove"],w=["updated"];function C(){const e=v(),t=f(),[n,a]=r({});return s((()=>{if(!e||!n)return;const a=Object.keys(n),r={},s={},c=e.getSettings();return a.some((e=>["clickEdge","rightClickEdge","doubleClickEdge","downEdge"].includes(e)))&&!1===c.enableEdgeClickEvents&&(r.enableEdgeClickEvents=!0,s.enableEdgeClickEvents=!1),a.some((e=>["enterEdge","leaveEdge"].includes(e)))&&!1===c.enableEdgeHoverEvents&&(r.enableEdgeHoverEvents=!0,s.enableEdgeHoverEvents=!1),a.some((e=>["wheelEdge"].includes(e)))&&!1===c.enableEdgeWheelEvents&&(r.enableEdgeWheelEvents=!0,s.enableEdgeWheelEvents=!1),Object.keys(r).length>0&&t(r),a.forEach((t=>{const a=n[t];p.find((e=>e===t))&&e.on(t,a),E.find((e=>e===t))&&e.getMouseCaptor().on(t,a),b.find((e=>e===t))&&e.getTouchCaptor().on(t,a),w.find((e=>e===t))&&e.getCamera().on(t,a)})),()=>{let a;if(Object.keys(s).length>0&&t(s),e)for(a in n){const t=n[a];a in p&&e.removeListener(a,t),a in E&&e.getMouseCaptor().removeListener(a,t),a in b&&e.getTouchCaptor().removeListener(a,t),a in w&&e.getCamera().removeListener(a,t)}}}),[e,n,t]),a}function O(){const e=v();return c(((t,n=!0)=>{e&&t&&(n&&e.getGraph().order>0&&e.getGraph().clear(),e.getGraph().import(t),e.refresh())}),[e])}function _(e){const t=v(),n=l();i(n.current,e)||(n.current=e);const a=c((e=>{t.getCamera().animatedZoom(Object.assign(Object.assign({},n.current),e))}),[t,n]),r=c((e=>{t.getCamera().animatedUnzoom(Object.assign(Object.assign({},n.current),e))}),[t,n]),s=c((e=>{t.getCamera().animatedReset(Object.assign(Object.assign({},n.current),e))}),[t,n]),o=c(((e,a)=>{t.getCamera().animate(e,Object.assign(Object.assign({},n.current),a))}),[t,n]),u=c(((e,a)=>{const r=t.getNodeDisplayData(e);r?t.getCamera().animate(r,Object.assign(Object.assign({},n.current),a)):console.log(`Node ${e} not found`)}),[t,n]);return{zoomIn:a,zoomOut:r,reset:s,goto:o,gotoNode:u}}function y(){const{container:e}=h(),[t,n]=r(!1),a=()=>n((e=>!e));return s((()=>(document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a))),[a]),{toggle:c((()=>{var t;t=e,document.fullscreenElement!==t?t.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()}),[e]),isFullScreen:t}}const j=({graph:e,id:n,className:a,style:c,settings:g,children:h})=>{const v=l(null),f=l(null),p={className:`react-sigma ${a||""}`,id:n,style:c},[E,b]=r(null),w=l({});i(w.current,g)||(w.current=g||{}),s((()=>{let t=null;if(null!==f.current){const n=e?"function"==typeof e?new e:e:new u;t=new d(n,f.current,Object.assign({allowInvalidContainer:!0},w.current))}return b(t),()=>{t&&t.kill(),b(null)}}),[f,e,w]);const C=o((()=>E&&v.current?{sigma:E,container:v.current}:null),[E,v.current]),O=null!==C?t.createElement(m,{value:C},h):null;return t.createElement("div",Object.assign({},p,{ref:v}),t.createElement("div",{className:"sigma-container",ref:f}),O)},k=({id:e,className:n,style:a,children:r,position:s="bottom-left"})=>{const c={className:`react-sigma-controls ${n||""} ${s}`,id:e,style:a};return t.createElement("div",Object.assign({},c),r)};var x;function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},N.apply(this,arguments)}var S,z=function(t){return e.createElement("svg",N({"aria-hidden":"true","data-prefix":"fas","data-icon":"plus",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),x||(x=e.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},H.apply(this,arguments)}var M,$=function(t){return e.createElement("svg",H({"aria-hidden":"true","data-prefix":"fas","data-icon":"minus",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),S||(S=e.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},F.apply(this,arguments)}var L=function(t){return e.createElement("svg",F({"aria-hidden":"true","data-prefix":"far","data-icon":"dot-circle",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em"},t),M||(M=e.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"})))};const V=({className:e,style:n,animationDuration:a=200,children:r})=>{const{zoomIn:s,zoomOut:c,reset:l}=_({duration:a,factor:1.5}),o={style:n,className:`react-sigma-control ${e||""}`};return t.createElement(t.Fragment,null,t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>s(),title:"Zoom In"},r?r[0]:t.createElement(z,{style:{width:"1em"}}))),t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>c(),title:"Zoom Out"},r?r[1]:t.createElement($,{style:{width:"1em"}}))),t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>l(),title:"See whole graph"},r?r[2]:t.createElement(L,{style:{width:"1em"}}))))};var G;function P(){return P=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},P.apply(this,arguments)}var B,I=function(t){return e.createElement("svg",P({"aria-hidden":"true","data-prefix":"fas","data-icon":"expand",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),G||(G=e.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"})))};function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},W.apply(this,arguments)}var Z=function(t){return e.createElement("svg",W({"aria-hidden":"true","data-prefix":"fas","data-icon":"compress",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),B||(B=e.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24zm0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"})))};const D=({id:e,className:n,style:a,children:r})=>{const{isFullScreen:s,toggle:c}=y(),l={className:`react-sigma-control ${n||""}`,id:e,style:a};return document.fullscreenEnabled?t.createElement("div",Object.assign({},l),t.createElement("button",{onClick:c,title:s?"Exit fullscreen":"Enter fullscreen"},r&&!s&&r[0],r&&s&&r[1],!r&&!s&&t.createElement(I,{style:{width:"1em"}}),!r&&s&&t.createElement(Z,{style:{width:"1em"}}))):null},R=({id:e,className:n,style:a})=>{const c=v(),l=C(),{gotoNode:o}=_(),[i,u]=r(""),[d,g]=r([]),[m,h]=r(null),[f,p]=r("");s((()=>{p(`search-${Math.random().toString(36).slice(2)}`)}),[]),s((()=>{const e=[];!m&&i.length>1&&c.getGraph().forEachNode(((t,n)=>{n.label&&n.label.toLowerCase().includes(i.toLowerCase())&&e.push({id:t,label:n.label})})),g(e)}),[i]),s((()=>{l({clickStage:()=>{h(null),u("")}})}),[l]),s((()=>{if(m)return c.getGraph().setNodeAttribute(m,"highlighted",!0),o(m),()=>{c.getGraph().setNodeAttribute(m,"highlighted",!1)}}),[m]);const E={className:`react-sigma-search ${n||""}`,id:e,style:a};return t.createElement("div",Object.assign({},E),t.createElement("label",{htmlFor:f,style:{display:"none"}},"Search a node"),t.createElement("input",{id:f,type:"text",placeholder:"Search...",list:`${f}-datalist`,value:i,onChange:e=>{const t=e.target.value,n=d.find((e=>e.label===t));n?(u(n.label),g([]),h(n.id)):(h(null),u(t))}}),t.createElement("datalist",{id:`${f}-datalist`},d.map((e=>t.createElement("option",{key:e.id,value:e.label},e.label)))))};export{k as ControlsContainer,D as FullScreenControl,R as SearchControl,j as SigmaContainer,g as SigmaContext,m as SigmaProvider,V as ZoomControl,_ as useCamera,y as useFullScreen,O as useLoadGraph,C as useRegisterEvents,f as useSetSettings,v as useSigma,h as useSigmaContext};
import*as e from"react";import t,{createContext as n,useContext as a,useState as r,useEffect as s,useCallback as c,useRef as l,useMemo as o}from"react";import{isEqual as i}from"lodash";import u from"graphology";import{Sigma as d}from"sigma";const g=n(null),m=g.Provider;function h(){const e=a(g);if(null==e)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return e}function v(){return h().sigma}function f(){const{sigma:e,container:t}=h(),[n,a]=r({});return s((()=>{if(!e||!n)return;const a={};return Object.keys(n).forEach((t=>{a[t]=n[t],e.setSetting(t,n[t])})),()=>{e&&t&&t.offsetWidth>0&&t.offsetHeight>0&&Object.keys(a).forEach((t=>{e.setSetting(t,a[t])}))}}),[e,n,t]),a}const p=["clickNode","rightClickNode","downNode","enterNode","leaveNode","doubleClickNode","wheelNode","clickEdge","rightClickEdge","downEdge","enterEdge","leaveEdge","doubleClickEdge","wheelEdge","clickStage","rightClickStage","downStage","doubleClickStage","wheelStage","kill"],E=["click","rightClick","mouseup","mousedown","mousemove","doubleClick","wheel"],b=["touchup","touchdown","touchmove"],w=["updated"];function C(){const e=v(),t=f(),[n,a]=r({});return s((()=>{if(!e||!n)return;const a=n,r=Object.keys(a),s={},c={},l=e.getSettings();return r.some((e=>["clickEdge","rightClickEdge","doubleClickEdge","downEdge"].includes(e)))&&!1===l.enableEdgeClickEvents&&(s.enableEdgeClickEvents=!0,c.enableEdgeClickEvents=!1),r.some((e=>["enterEdge","leaveEdge"].includes(e)))&&!1===l.enableEdgeHoverEvents&&(s.enableEdgeHoverEvents=!0,c.enableEdgeHoverEvents=!1),r.some((e=>["wheelEdge"].includes(e)))&&!1===l.enableEdgeWheelEvents&&(s.enableEdgeWheelEvents=!0,c.enableEdgeWheelEvents=!1),Object.keys(s).length>0&&t(s),r.forEach((t=>{const n=a[t];p.find((e=>e===t))&&e.on(t,n),E.find((e=>e===t))&&e.getMouseCaptor().on(t,n),b.find((e=>e===t))&&e.getTouchCaptor().on(t,n),w.find((e=>e===t))&&e.getCamera().on(t,n)})),()=>{Object.keys(c).length>0&&t(c),e&&r.forEach((t=>{const n=a[t];p.find((e=>e===t))&&e.off(t,n),E.find((e=>e===t))&&e.getMouseCaptor().off(t,n),b.find((e=>e===t))&&e.getTouchCaptor().off(t,n),w.find((e=>e===t))&&e.getCamera().off(t,n)}))}}),[e,n,t]),a}function O(){const e=v();return c(((t,n=!0)=>{e&&t&&(n&&e.getGraph().order>0&&e.getGraph().clear(),e.getGraph().import(t),e.refresh())}),[e])}function _(e){const t=v(),n=l();i(n.current,e)||(n.current=e);const a=c((e=>{t.getCamera().animatedZoom(Object.assign(Object.assign({},n.current),e))}),[t,n]),r=c((e=>{t.getCamera().animatedUnzoom(Object.assign(Object.assign({},n.current),e))}),[t,n]),s=c((e=>{t.getCamera().animatedReset(Object.assign(Object.assign({},n.current),e))}),[t,n]),o=c(((e,a)=>{t.getCamera().animate(e,Object.assign(Object.assign({},n.current),a))}),[t,n]),u=c(((e,a)=>{const r=t.getNodeDisplayData(e);r?t.getCamera().animate(r,Object.assign(Object.assign({},n.current),a)):console.log(`Node ${e} not found`)}),[t,n]);return{zoomIn:a,zoomOut:r,reset:s,goto:o,gotoNode:u}}function y(){const{container:e}=h(),[t,n]=r(!1),a=()=>n((e=>!e));return s((()=>(document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a))),[a]),{toggle:c((()=>{var t;t=e,document.fullscreenElement!==t?t.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()}),[e]),isFullScreen:t}}const j=({graph:e,id:n,className:a,style:c,settings:g,children:h})=>{const v=l(null),f=l(null),p={className:`react-sigma ${a||""}`,id:n,style:c},[E,b]=r(null),w=l({});i(w.current,g)||(w.current=g||{}),s((()=>{let t=null;if(null!==f.current){const n=e?"function"==typeof e?new e:e:new u;t=new d(n,f.current,Object.assign({allowInvalidContainer:!0},w.current))}return b(t),()=>{t&&t.kill(),b(null)}}),[f,e,w]);const C=o((()=>E&&v.current?{sigma:E,container:v.current}:null),[E,v.current]),O=null!==C?t.createElement(m,{value:C},h):null;return t.createElement("div",Object.assign({},p,{ref:v}),t.createElement("div",{className:"sigma-container",ref:f}),O)},k=({id:e,className:n,style:a,children:r,position:s="bottom-left"})=>{const c={className:`react-sigma-controls ${n||""} ${s}`,id:e,style:a};return t.createElement("div",Object.assign({},c),r)};var x;function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},N.apply(this,arguments)}var S,z=function(t){return e.createElement("svg",N({"aria-hidden":"true","data-prefix":"fas","data-icon":"plus",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),x||(x=e.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},H.apply(this,arguments)}var M,$=function(t){return e.createElement("svg",H({"aria-hidden":"true","data-prefix":"fas","data-icon":"minus",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),S||(S=e.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function F(){return F=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},F.apply(this,arguments)}var V=function(t){return e.createElement("svg",F({"aria-hidden":"true","data-prefix":"far","data-icon":"dot-circle",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em"},t),M||(M=e.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"})))};const G=({className:e,style:n,animationDuration:a=200,children:r})=>{const{zoomIn:s,zoomOut:c,reset:l}=_({duration:a,factor:1.5}),o={style:n,className:`react-sigma-control ${e||""}`};return t.createElement(t.Fragment,null,t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>s(),title:"Zoom In"},r?r[0]:t.createElement(z,{style:{width:"1em"}}))),t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>c(),title:"Zoom Out"},r?r[1]:t.createElement($,{style:{width:"1em"}}))),t.createElement("div",Object.assign({},o),t.createElement("button",{onClick:()=>l(),title:"See whole graph"},r?r[2]:t.createElement(V,{style:{width:"1em"}}))))};var P;function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},B.apply(this,arguments)}var L,I=function(t){return e.createElement("svg",B({"aria-hidden":"true","data-prefix":"fas","data-icon":"expand",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),P||(P=e.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"})))};function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},W.apply(this,arguments)}var Z=function(t){return e.createElement("svg",W({"aria-hidden":"true","data-prefix":"fas","data-icon":"compress",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},t),L||(L=e.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24zm0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"})))};const D=({id:e,className:n,style:a,children:r})=>{const{isFullScreen:s,toggle:c}=y(),l={className:`react-sigma-control ${n||""}`,id:e,style:a};return document.fullscreenEnabled?t.createElement("div",Object.assign({},l),t.createElement("button",{onClick:c,title:s?"Exit fullscreen":"Enter fullscreen"},r&&!s&&r[0],r&&s&&r[1],!r&&!s&&t.createElement(I,{style:{width:"1em"}}),!r&&s&&t.createElement(Z,{style:{width:"1em"}}))):null},R=({id:e,className:n,style:a})=>{const c=v(),l=C(),{gotoNode:o}=_(),[i,u]=r(""),[d,g]=r([]),[m,h]=r(null),[f,p]=r("");s((()=>{p(`search-${Math.random().toString(36).slice(2)}`)}),[]),s((()=>{const e=[];!m&&i.length>1&&c.getGraph().forEachNode(((t,n)=>{n.label&&n.label.toLowerCase().includes(i.toLowerCase())&&e.push({id:t,label:n.label})})),g(e)}),[i]),s((()=>{l({clickStage:()=>{h(null),u("")}})}),[l]),s((()=>{if(m)return c.getGraph().setNodeAttribute(m,"highlighted",!0),o(m),()=>{c.getGraph().setNodeAttribute(m,"highlighted",!1)}}),[m]);const E={className:`react-sigma-search ${n||""}`,id:e,style:a};return t.createElement("div",Object.assign({},E),t.createElement("label",{htmlFor:f,style:{display:"none"}},"Search a node"),t.createElement("input",{id:f,type:"text",placeholder:"Search...",list:`${f}-datalist`,value:i,onChange:e=>{const t=e.target.value,n=d.find((e=>e.label===t));n?(u(n.label),g([]),h(n.id)):(h(null),u(t))}}),t.createElement("datalist",{id:`${f}-datalist`},d.map((e=>t.createElement("option",{key:e.id,value:e.label},e.label)))))};export{k as ControlsContainer,D as FullScreenControl,R as SearchControl,j as SigmaContainer,g as SigmaContext,m as SigmaProvider,G as ZoomControl,_ as useCamera,y as useFullScreen,O as useLoadGraph,C as useRegisterEvents,f as useSetSettings,v as useSigma,h as useSigmaContext};
//# sourceMappingURL=react-sigma_core.esm.min.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("lodash"),require("graphology"),require("sigma")):"function"==typeof define&&define.amd?define(["exports","react","lodash","graphology","sigma"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@react-sigma/core"]={},e.React,e.lodash,e.Graph,e.sigma)}(this,(function(e,t,n,a,r){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=l(t),s=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}(t),i=l(a);const o=t.createContext(null),u=o.Provider;function d(){const e=t.useContext(o);if(null==e)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return e}function g(){return d().sigma}function f(){const{sigma:e,container:n}=d(),[a,r]=t.useState({});return t.useEffect((()=>{if(!e||!a)return;const t={};return Object.keys(a).forEach((n=>{t[n]=a[n],e.setSetting(n,a[n])})),()=>{e&&n&&n.offsetWidth>0&&n.offsetHeight>0&&Object.keys(t).forEach((n=>{e.setSetting(n,t[n])}))}}),[e,a,n]),r}const m=["clickNode","rightClickNode","downNode","enterNode","leaveNode","doubleClickNode","wheelNode","clickEdge","rightClickEdge","downEdge","enterEdge","leaveEdge","doubleClickEdge","wheelEdge","clickStage","rightClickStage","downStage","doubleClickStage","wheelStage","kill"],h=["click","rightClick","mouseup","mousedown","mousemove","doubleClick","wheel"],v=["touchup","touchdown","touchmove"],p=["updated"];function b(){const e=g(),n=f(),[a,r]=t.useState({});return t.useEffect((()=>{if(!e||!a)return;const t=Object.keys(a),r={},l={},c=e.getSettings();return t.some((e=>["clickEdge","rightClickEdge","doubleClickEdge","downEdge"].includes(e)))&&!1===c.enableEdgeClickEvents&&(r.enableEdgeClickEvents=!0,l.enableEdgeClickEvents=!1),t.some((e=>["enterEdge","leaveEdge"].includes(e)))&&!1===c.enableEdgeHoverEvents&&(r.enableEdgeHoverEvents=!0,l.enableEdgeHoverEvents=!1),t.some((e=>["wheelEdge"].includes(e)))&&!1===c.enableEdgeWheelEvents&&(r.enableEdgeWheelEvents=!0,l.enableEdgeWheelEvents=!1),Object.keys(r).length>0&&n(r),t.forEach((t=>{const n=a[t];m.find((e=>e===t))&&e.on(t,n),h.find((e=>e===t))&&e.getMouseCaptor().on(t,n),v.find((e=>e===t))&&e.getTouchCaptor().on(t,n),p.find((e=>e===t))&&e.getCamera().on(t,n)})),()=>{let t;if(Object.keys(l).length>0&&n(l),e)for(t in a){const n=a[t];t in m&&e.removeListener(t,n),t in h&&e.getMouseCaptor().removeListener(t,n),t in v&&e.getTouchCaptor().removeListener(t,n),t in p&&e.getCamera().removeListener(t,n)}}}),[e,a,n]),r}function E(e){const a=g(),r=t.useRef();n.isEqual(r.current,e)||(r.current=e);const l=t.useCallback((e=>{a.getCamera().animatedZoom(Object.assign(Object.assign({},r.current),e))}),[a,r]),c=t.useCallback((e=>{a.getCamera().animatedUnzoom(Object.assign(Object.assign({},r.current),e))}),[a,r]),s=t.useCallback((e=>{a.getCamera().animatedReset(Object.assign(Object.assign({},r.current),e))}),[a,r]),i=t.useCallback(((e,t)=>{a.getCamera().animate(e,Object.assign(Object.assign({},r.current),t))}),[a,r]),o=t.useCallback(((e,t)=>{const n=a.getNodeDisplayData(e);n?a.getCamera().animate(n,Object.assign(Object.assign({},r.current),t)):console.log(`Node ${e} not found`)}),[a,r]);return{zoomIn:l,zoomOut:c,reset:s,goto:i,gotoNode:o}}function w(){const{container:e}=d(),[n,a]=t.useState(!1),r=()=>a((e=>!e));return t.useEffect((()=>(document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r))),[r]),{toggle:t.useCallback((()=>{var t;t=e,document.fullscreenElement!==t?t.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()}),[e]),isFullScreen:n}}var C;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},y.apply(this,arguments)}var O,_=function(e){return s.createElement("svg",y({"aria-hidden":"true","data-prefix":"fas","data-icon":"plus",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),C||(C=s.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},j.apply(this,arguments)}var k,S=function(e){return s.createElement("svg",j({"aria-hidden":"true","data-prefix":"fas","data-icon":"minus",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),O||(O=s.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function x(){return x=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},x.apply(this,arguments)}var N,z=function(e){return s.createElement("svg",x({"aria-hidden":"true","data-prefix":"far","data-icon":"dot-circle",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em"},e),k||(k=s.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"})))};function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},H.apply(this,arguments)}var M,P=function(e){return s.createElement("svg",H({"aria-hidden":"true","data-prefix":"fas","data-icon":"expand",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),N||(N=s.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"})))};function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},$.apply(this,arguments)}var F=function(e){return s.createElement("svg",$({"aria-hidden":"true","data-prefix":"fas","data-icon":"compress",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),M||(M=s.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24zm0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"})))};e.ControlsContainer=({id:e,className:t,style:n,children:a,position:r="bottom-left"})=>{const l={className:`react-sigma-controls ${t||""} ${r}`,id:e,style:n};return c.default.createElement("div",Object.assign({},l),a)},e.FullScreenControl=({id:e,className:t,style:n,children:a})=>{const{isFullScreen:r,toggle:l}=w(),s={className:`react-sigma-control ${t||""}`,id:e,style:n};return document.fullscreenEnabled?c.default.createElement("div",Object.assign({},s),c.default.createElement("button",{onClick:l,title:r?"Exit fullscreen":"Enter fullscreen"},a&&!r&&a[0],a&&r&&a[1],!a&&!r&&c.default.createElement(P,{style:{width:"1em"}}),!a&&r&&c.default.createElement(F,{style:{width:"1em"}}))):null},e.SearchControl=({id:e,className:n,style:a})=>{const r=g(),l=b(),{gotoNode:s}=E(),[i,o]=t.useState(""),[u,d]=t.useState([]),[f,m]=t.useState(null),[h,v]=t.useState("");t.useEffect((()=>{v(`search-${Math.random().toString(36).slice(2)}`)}),[]),t.useEffect((()=>{const e=[];!f&&i.length>1&&r.getGraph().forEachNode(((t,n)=>{n.label&&n.label.toLowerCase().includes(i.toLowerCase())&&e.push({id:t,label:n.label})})),d(e)}),[i]),t.useEffect((()=>{l({clickStage:()=>{m(null),o("")}})}),[l]),t.useEffect((()=>{if(f)return r.getGraph().setNodeAttribute(f,"highlighted",!0),s(f),()=>{r.getGraph().setNodeAttribute(f,"highlighted",!1)}}),[f]);const p={className:`react-sigma-search ${n||""}`,id:e,style:a};return c.default.createElement("div",Object.assign({},p),c.default.createElement("label",{htmlFor:h,style:{display:"none"}},"Search a node"),c.default.createElement("input",{id:h,type:"text",placeholder:"Search...",list:`${h}-datalist`,value:i,onChange:e=>{const t=e.target.value,n=u.find((e=>e.label===t));n?(o(n.label),d([]),m(n.id)):(m(null),o(t))}}),c.default.createElement("datalist",{id:`${h}-datalist`},u.map((e=>c.default.createElement("option",{key:e.id,value:e.label},e.label)))))},e.SigmaContainer=({graph:e,id:a,className:l,style:s,settings:o,children:d})=>{const g=t.useRef(null),f=t.useRef(null),m={className:`react-sigma ${l||""}`,id:a,style:s},[h,v]=t.useState(null),p=t.useRef({});n.isEqual(p.current,o)||(p.current=o||{}),t.useEffect((()=>{let t=null;if(null!==f.current){const n=e?"function"==typeof e?new e:e:new i.default;t=new r.Sigma(n,f.current,Object.assign({allowInvalidContainer:!0},p.current))}return v(t),()=>{t&&t.kill(),v(null)}}),[f,e,p]);const b=t.useMemo((()=>h&&g.current?{sigma:h,container:g.current}:null),[h,g.current]),E=null!==b?c.default.createElement(u,{value:b},d):null;return c.default.createElement("div",Object.assign({},m,{ref:g}),c.default.createElement("div",{className:"sigma-container",ref:f}),E)},e.SigmaContext=o,e.SigmaProvider=u,e.ZoomControl=({className:e,style:t,animationDuration:n=200,children:a})=>{const{zoomIn:r,zoomOut:l,reset:s}=E({duration:n,factor:1.5}),i={style:t,className:`react-sigma-control ${e||""}`};return c.default.createElement(c.default.Fragment,null,c.default.createElement("div",Object.assign({},i),c.default.createElement("button",{onClick:()=>r(),title:"Zoom In"},a?a[0]:c.default.createElement(_,{style:{width:"1em"}}))),c.default.createElement("div",Object.assign({},i),c.default.createElement("button",{onClick:()=>l(),title:"Zoom Out"},a?a[1]:c.default.createElement(S,{style:{width:"1em"}}))),c.default.createElement("div",Object.assign({},i),c.default.createElement("button",{onClick:()=>s(),title:"See whole graph"},a?a[2]:c.default.createElement(z,{style:{width:"1em"}}))))},e.useCamera=E,e.useFullScreen=w,e.useLoadGraph=function(){const e=g();return t.useCallback(((t,n=!0)=>{e&&t&&(n&&e.getGraph().order>0&&e.getGraph().clear(),e.getGraph().import(t),e.refresh())}),[e])},e.useRegisterEvents=b,e.useSetSettings=f,e.useSigma=g,e.useSigmaContext=d,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("lodash"),require("graphology"),require("sigma")):"function"==typeof define&&define.amd?define(["exports","react","lodash","graphology","sigma"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@react-sigma/core"]={},e.React,e.lodash,e.Graph,e.sigma)}(this,(function(e,t,n,a,r){"use strict";function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=l(t),s=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}(t),o=l(a);const i=t.createContext(null),u=i.Provider;function d(){const e=t.useContext(i);if(null==e)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return e}function g(){return d().sigma}function f(){const{sigma:e,container:n}=d(),[a,r]=t.useState({});return t.useEffect((()=>{if(!e||!a)return;const t={};return Object.keys(a).forEach((n=>{t[n]=a[n],e.setSetting(n,a[n])})),()=>{e&&n&&n.offsetWidth>0&&n.offsetHeight>0&&Object.keys(t).forEach((n=>{e.setSetting(n,t[n])}))}}),[e,a,n]),r}const m=["clickNode","rightClickNode","downNode","enterNode","leaveNode","doubleClickNode","wheelNode","clickEdge","rightClickEdge","downEdge","enterEdge","leaveEdge","doubleClickEdge","wheelEdge","clickStage","rightClickStage","downStage","doubleClickStage","wheelStage","kill"],h=["click","rightClick","mouseup","mousedown","mousemove","doubleClick","wheel"],v=["touchup","touchdown","touchmove"],p=["updated"];function b(){const e=g(),n=f(),[a,r]=t.useState({});return t.useEffect((()=>{if(!e||!a)return;const t=a,r=Object.keys(t),l={},c={},s=e.getSettings();return r.some((e=>["clickEdge","rightClickEdge","doubleClickEdge","downEdge"].includes(e)))&&!1===s.enableEdgeClickEvents&&(l.enableEdgeClickEvents=!0,c.enableEdgeClickEvents=!1),r.some((e=>["enterEdge","leaveEdge"].includes(e)))&&!1===s.enableEdgeHoverEvents&&(l.enableEdgeHoverEvents=!0,c.enableEdgeHoverEvents=!1),r.some((e=>["wheelEdge"].includes(e)))&&!1===s.enableEdgeWheelEvents&&(l.enableEdgeWheelEvents=!0,c.enableEdgeWheelEvents=!1),Object.keys(l).length>0&&n(l),r.forEach((n=>{const a=t[n];m.find((e=>e===n))&&e.on(n,a),h.find((e=>e===n))&&e.getMouseCaptor().on(n,a),v.find((e=>e===n))&&e.getTouchCaptor().on(n,a),p.find((e=>e===n))&&e.getCamera().on(n,a)})),()=>{Object.keys(c).length>0&&n(c),e&&r.forEach((n=>{const a=t[n];m.find((e=>e===n))&&e.off(n,a),h.find((e=>e===n))&&e.getMouseCaptor().off(n,a),v.find((e=>e===n))&&e.getTouchCaptor().off(n,a),p.find((e=>e===n))&&e.getCamera().off(n,a)}))}}),[e,a,n]),r}function E(e){const a=g(),r=t.useRef();n.isEqual(r.current,e)||(r.current=e);const l=t.useCallback((e=>{a.getCamera().animatedZoom(Object.assign(Object.assign({},r.current),e))}),[a,r]),c=t.useCallback((e=>{a.getCamera().animatedUnzoom(Object.assign(Object.assign({},r.current),e))}),[a,r]),s=t.useCallback((e=>{a.getCamera().animatedReset(Object.assign(Object.assign({},r.current),e))}),[a,r]),o=t.useCallback(((e,t)=>{a.getCamera().animate(e,Object.assign(Object.assign({},r.current),t))}),[a,r]),i=t.useCallback(((e,t)=>{const n=a.getNodeDisplayData(e);n?a.getCamera().animate(n,Object.assign(Object.assign({},r.current),t)):console.log(`Node ${e} not found`)}),[a,r]);return{zoomIn:l,zoomOut:c,reset:s,goto:o,gotoNode:i}}function w(){const{container:e}=d(),[n,a]=t.useState(!1),r=()=>a((e=>!e));return t.useEffect((()=>(document.addEventListener("fullscreenchange",r),()=>document.removeEventListener("fullscreenchange",r))),[r]),{toggle:t.useCallback((()=>{var t;t=e,document.fullscreenElement!==t?t.requestFullscreen():document.exitFullscreen&&document.exitFullscreen()}),[e]),isFullScreen:n}}var C;function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},y.apply(this,arguments)}var O,_=function(e){return s.createElement("svg",y({"aria-hidden":"true","data-prefix":"fas","data-icon":"plus",className:"plus-solid_svg__svg-inline--fa plus-solid_svg__fa-plus plus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),C||(C=s.createElement("path",{fill:"currentColor",d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},j.apply(this,arguments)}var k,S=function(e){return s.createElement("svg",j({"aria-hidden":"true","data-prefix":"fas","data-icon":"minus",className:"minus-solid_svg__svg-inline--fa minus-solid_svg__fa-minus minus-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),O||(O=s.createElement("path",{fill:"currentColor",d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"})))};function x(){return x=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},x.apply(this,arguments)}var N,z=function(e){return s.createElement("svg",x({"aria-hidden":"true","data-prefix":"far","data-icon":"dot-circle",className:"dot-circle-regular_svg__svg-inline--fa dot-circle-regular_svg__fa-dot-circle dot-circle-regular_svg__fa-w-16",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em"},e),k||(k=s.createElement("path",{fill:"currentColor",d:"M256 56c110.532 0 200 89.451 200 200 0 110.532-89.451 200-200 200-110.532 0-200-89.451-200-200 0-110.532 89.451-200 200-200m0-48C119.033 8 8 119.033 8 256s111.033 248 248 248 248-111.033 248-248S392.967 8 256 8zm0 168c-44.183 0-80 35.817-80 80s35.817 80 80 80 80-35.817 80-80-35.817-80-80-80z"})))};function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},H.apply(this,arguments)}var M,P=function(e){return s.createElement("svg",H({"aria-hidden":"true","data-prefix":"fas","data-icon":"expand",className:"expand-solid_svg__svg-inline--fa expand-solid_svg__fa-expand expand-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),N||(N=s.createElement("path",{fill:"currentColor",d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"})))};function $(){return $=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},$.apply(this,arguments)}var F=function(e){return s.createElement("svg",$({"aria-hidden":"true","data-prefix":"fas","data-icon":"compress",className:"compress-solid_svg__svg-inline--fa compress-solid_svg__fa-compress compress-solid_svg__fa-w-14",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em"},e),M||(M=s.createElement("path",{fill:"currentColor",d:"M436 192H312c-13.3 0-24-10.7-24-24V44c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v84h84c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm-276-24V44c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v84H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24zm0 300V344c0-13.3-10.7-24-24-24H12c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-84h84c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12H312c-13.3 0-24 10.7-24 24v124c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12z"})))};e.ControlsContainer=({id:e,className:t,style:n,children:a,position:r="bottom-left"})=>{const l={className:`react-sigma-controls ${t||""} ${r}`,id:e,style:n};return c.default.createElement("div",Object.assign({},l),a)},e.FullScreenControl=({id:e,className:t,style:n,children:a})=>{const{isFullScreen:r,toggle:l}=w(),s={className:`react-sigma-control ${t||""}`,id:e,style:n};return document.fullscreenEnabled?c.default.createElement("div",Object.assign({},s),c.default.createElement("button",{onClick:l,title:r?"Exit fullscreen":"Enter fullscreen"},a&&!r&&a[0],a&&r&&a[1],!a&&!r&&c.default.createElement(P,{style:{width:"1em"}}),!a&&r&&c.default.createElement(F,{style:{width:"1em"}}))):null},e.SearchControl=({id:e,className:n,style:a})=>{const r=g(),l=b(),{gotoNode:s}=E(),[o,i]=t.useState(""),[u,d]=t.useState([]),[f,m]=t.useState(null),[h,v]=t.useState("");t.useEffect((()=>{v(`search-${Math.random().toString(36).slice(2)}`)}),[]),t.useEffect((()=>{const e=[];!f&&o.length>1&&r.getGraph().forEachNode(((t,n)=>{n.label&&n.label.toLowerCase().includes(o.toLowerCase())&&e.push({id:t,label:n.label})})),d(e)}),[o]),t.useEffect((()=>{l({clickStage:()=>{m(null),i("")}})}),[l]),t.useEffect((()=>{if(f)return r.getGraph().setNodeAttribute(f,"highlighted",!0),s(f),()=>{r.getGraph().setNodeAttribute(f,"highlighted",!1)}}),[f]);const p={className:`react-sigma-search ${n||""}`,id:e,style:a};return c.default.createElement("div",Object.assign({},p),c.default.createElement("label",{htmlFor:h,style:{display:"none"}},"Search a node"),c.default.createElement("input",{id:h,type:"text",placeholder:"Search...",list:`${h}-datalist`,value:o,onChange:e=>{const t=e.target.value,n=u.find((e=>e.label===t));n?(i(n.label),d([]),m(n.id)):(m(null),i(t))}}),c.default.createElement("datalist",{id:`${h}-datalist`},u.map((e=>c.default.createElement("option",{key:e.id,value:e.label},e.label)))))},e.SigmaContainer=({graph:e,id:a,className:l,style:s,settings:i,children:d})=>{const g=t.useRef(null),f=t.useRef(null),m={className:`react-sigma ${l||""}`,id:a,style:s},[h,v]=t.useState(null),p=t.useRef({});n.isEqual(p.current,i)||(p.current=i||{}),t.useEffect((()=>{let t=null;if(null!==f.current){const n=e?"function"==typeof e?new e:e:new o.default;t=new r.Sigma(n,f.current,Object.assign({allowInvalidContainer:!0},p.current))}return v(t),()=>{t&&t.kill(),v(null)}}),[f,e,p]);const b=t.useMemo((()=>h&&g.current?{sigma:h,container:g.current}:null),[h,g.current]),E=null!==b?c.default.createElement(u,{value:b},d):null;return c.default.createElement("div",Object.assign({},m,{ref:g}),c.default.createElement("div",{className:"sigma-container",ref:f}),E)},e.SigmaContext=i,e.SigmaProvider=u,e.ZoomControl=({className:e,style:t,animationDuration:n=200,children:a})=>{const{zoomIn:r,zoomOut:l,reset:s}=E({duration:n,factor:1.5}),o={style:t,className:`react-sigma-control ${e||""}`};return c.default.createElement(c.default.Fragment,null,c.default.createElement("div",Object.assign({},o),c.default.createElement("button",{onClick:()=>r(),title:"Zoom In"},a?a[0]:c.default.createElement(_,{style:{width:"1em"}}))),c.default.createElement("div",Object.assign({},o),c.default.createElement("button",{onClick:()=>l(),title:"Zoom Out"},a?a[1]:c.default.createElement(S,{style:{width:"1em"}}))),c.default.createElement("div",Object.assign({},o),c.default.createElement("button",{onClick:()=>s(),title:"See whole graph"},a?a[2]:c.default.createElement(z,{style:{width:"1em"}}))))},e.useCamera=E,e.useFullScreen=w,e.useLoadGraph=function(){const e=g();return t.useCallback(((t,n=!0)=>{e&&t&&(n&&e.getGraph().order>0&&e.getGraph().clear(),e.getGraph().import(t),e.refresh())}),[e])},e.useRegisterEvents=b,e.useSetSettings=f,e.useSigma=g,e.useSigmaContext=d,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=react-sigma_core.umd.min.js.map
{
"name": "@react-sigma/core",
"version": "3.0.2",
"version": "3.0.3",
"private": false,

@@ -54,3 +54,3 @@ "description": "React Sigma",

},
"gitHead": "ac6abe211efca183b42a709de8b51b53aab96aec"
"gitHead": "15f0349cd85ff0937d08cc79dcfd980719cf0fa3"
}

@@ -71,4 +71,6 @@ import { useEffect, useState } from "react";

const userEvents = eventHandlers;
// list of event types to register
const eventTypes = Object.keys(eventHandlers) as Array<EventType>;
const eventTypes = Object.keys(userEvents) as Array<EventType>;

@@ -102,3 +104,3 @@ // Set settings for edge event if needed

eventTypes.forEach((event: EventType) => {
const eventHandler = eventHandlers[event] as (...args: unknown[]) => void;
const eventHandler = userEvents[event] as (...args: unknown[]) => void;
if (sigmaEvents.find((e) => e === event)) {

@@ -122,4 +124,2 @@ sigma.on(event as keyof SigmaEvents, eventHandler);

return () => {
let event: EventType;
// Reverse settings

@@ -132,17 +132,17 @@ if (Object.keys(reverseEdgeSettings).length > 0) {

if (sigma) {
for (event in eventHandlers) {
const eventHandler = eventHandlers[event] as (...args: unknown[]) => void;
if (event in sigmaEvents) {
sigma.removeListener(event as keyof SigmaEvents, eventHandler);
eventTypes.forEach((event: EventType) => {
const eventHandler = userEvents[event] as (...args: unknown[]) => void;
if (sigmaEvents.find((e) => e === event)) {
sigma.off(event as keyof SigmaEvents, eventHandler);
}
if (event in mouseEvents) {
sigma.getMouseCaptor().removeListener(event as keyof MouseCaptorEvents, eventHandler);
if (mouseEvents.find((e) => e === event)) {
sigma.getMouseCaptor().off(event as keyof MouseCaptorEvents, eventHandler);
}
if (event in touchEvents) {
sigma.getTouchCaptor().removeListener(event as keyof TouchCaptorEvents, eventHandler);
if (touchEvents.find((e) => e === event)) {
sigma.getTouchCaptor().off(event as keyof TouchCaptorEvents, eventHandler);
}
if (event in cameraEvents) {
sigma.getCamera().removeListener(event as keyof CameraEvents, eventHandler);
if (cameraEvents.find((e) => e === event)) {
sigma.getCamera().off(event as keyof CameraEvents, eventHandler);
}
}
});
}

@@ -149,0 +149,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc