@performant-software/visualize 1.0.6 → 1.0.7-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{TreeGraph:function(){return O},withZoom:function(){return x}});var n=require("@visx/group"),r=require("@visx/hierarchy"),a=require("@visx/responsive"),o=require("@visx/shape"),i=require("d3-shape"),l=require("react"),s=e.n(l),c=require("underscore"),d=e.n(c),u=require("@visx/event"),p=require("@visx/zoom"),m=require("i18next"),h=e.n(m);const g={en:{translation:JSON.parse('{"Zoom":{"buttons":{"center":"Center","clear":"Clear","reset":"Reset","zoomIn":"+","zoomOut":"-"}}}')}},b=h().createInstance();b.init({debug:!0,fallbackLng:"en",lng:"en",interpolation:{escapeValue:!1},resources:g});var f=b;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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}const k={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};var x=e=>t=>{const{parentWidth:n,parentHeight:r}=t,{scaleXMin:a=.5,scaleXMax:o=4}=t,{scaleYMin:i=.5,scaleYMax:c=4}=t,{initialTransform:d=k}=t,m=(0,l.useCallback)((e=>s().createElement("rect",{width:n,height:r,rx:14,fill:"transparent",onTouchStart:e.dragStart,onTouchMove:e.dragMove,onTouchEnd:e.dragEnd,onMouseDown:e.dragStart,onMouseMove:e.dragMove,onMouseUp:e.dragEnd,onMouseLeave:()=>{e.isDragging&&e.dragEnd()},onDoubleClick:t=>{const n=(0,u.localPoint)(t)||{x:0,y:0};e.scale({scaleX:1.1,scaleY:1.1,point:n})}})),[n,r]);return s().createElement(p.Zoom,{width:n,height:r,scaleXMin:a,scaleXMax:o,scaleYMin:i,scaleYMax:c,initialTransformMatrix:d},(n=>s().createElement("div",{className:"zoom"},s().createElement(e,y({},t,{renderZoomContainer:m.bind(void 0,n),zoom:n})),s().createElement("div",{className:"controls"},s().createElement("button",{type:"button",className:"btn btn-zoom",onClick:()=>n.scale({scaleX:1.2,scaleY:1.2})},f.t("Zoom.buttons.zoomIn")),s().createElement("button",{type:"button",className:"btn btn-zoom btn-bottom",onClick:()=>n.scale({scaleX:.8,scaleY:.8})},f.t("Zoom.buttons.zoomOut")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.center},f.t("Zoom.buttons.center")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.reset},f.t("Zoom.buttons.reset")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.clear},f.t("Zoom.buttons.clear"))))))};function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},v.apply(this,arguments)}const E="polar",C="curve",T="line",M="step",z="vertical",w=e=>s().createElement("circle",v({r:e.radius},e)),N=e=>s().createElement("rect",e),L=e=>{const t=(0,l.useRef)(),a=e.parentWidth-e.margin.left-e.margin.right,c=e.parentHeight-e.margin.top-e.margin.bottom,u=(0,l.useMemo)((()=>{let t;return t=e.layout===E?e.linkType===M?o.LinkRadialStep:e.linkType===C?o.LinkRadialCurve:e.linkType===T?o.LinkRadialLine:o.LinkRadial:e.orientation===z?e.linkType===M?o.LinkVerticalStep:e.linkType===C?o.LinkVerticalCurve:e.linkType===T?o.LinkVerticalLine:o.LinkVertical:e.linkType===M?o.LinkHorizontalStep:e.linkType===C?o.LinkHorizontalCurve:e.linkType===T?o.LinkHorizontalLine:o.LinkHorizontal,t}),[e.layout,e.linkType,e.orientation]),p=(0,l.useCallback)(((e,t)=>{let n=t;return e.isExpanded&&(n=d().max(d().map(e.children,(e=>p(e,t+1))))),n}),[]),m=(0,l.useCallback)(((t,n)=>{let r,a;if(e.layout===E){const[e,o]=(0,i.pointRadial)(t,n);r=o,a=e}else e.orientation===z?(r=n,a=t):(r=t,a=n);return{top:r,left:a}}),[e.layout,e.orientation]),h=(0,l.useMemo)((()=>{let t,n,r;const o=p(e.data,1);return e.layout===E?(r={x:a/2,y:c/2},t=2*Math.PI,n=Math.min(a,c)/2*(o/2)):(r={x:0,y:0},e.orientation===z?(t=a,n=c):(t=c,n=a)),{sizeWidth:t,sizeHeight:n,origin:r}}),[p,c,a,e.data,e.layout,e.orientation]),g=(0,l.useCallback)((t=>e.renderNode?e.renderNode(t.data):0===t.depth?s().createElement(w,{fill:"#FF4A4A",onClick:e.onClick&&e.onClick.bind(void 0,t.data)}):s().createElement(N,{fill:"#272b4d",stroke:t.data.children?"#03c0dc":"#26deb0",strokeWidth:1,strokeDasharray:t.data.children?"0":"2,2",strokeOpacity:t.data.children?1:.6,rx:t.data.children?0:10,onClick:e.onClick&&e.onClick.bind(void 0,t.data)})),[e.onClick,e.renderNode]),b=(0,l.useCallback)((t=>e.renderText?e.renderText(t.data):s().createElement("text",{dy:"0.33em",fontSize:e.fontSize,textAnchor:"middle",fill:e.textColor},t.data.name)),[e.renderText]),f=(0,l.useCallback)(((e,t)=>{const{top:r,left:a}=m(e.x,e.y);return s().createElement(n.Group,{top:r,left:a,key:t},g(e),b(e))}),[g,b,e.layout,e.orientation]);return(0,l.useEffect)((()=>{const{current:n}=t;if(n){const t=15,r=n.getElementsByTagName("g");d().each(r,(n=>{const r=d().first(n.getElementsByTagName("circle")),a=d().first(n.getElementsByTagName("rect")),o=d().first(n.getElementsByTagName("text")),{height:i}=o.getBBox();if(!o.getElementsByTagName("tspan").length){const l=o.innerHTML.split(/\s+/),s=[];let c=0;for(let t=0;t<l.length;t+=1)if(s[c]||(s[c]=[]),s[c].push(l[t]),t<l.length-1){const r=o.cloneNode();r.innerHTML=[...s[c],l[t+1]].join(" "),n.append(r),r.getBBox().width>e.nodeWidth&&(c+=1),r.remove()}d().each(s,((e,t)=>{const n=document.createElementNS("http://www.w3.org/2000/svg","tspan");n.setAttribute("x","0"),t>0&&n.setAttribute("dy",`${i}px`),n.appendChild(document.createTextNode(e.join(" "))),0===t?o.replaceChildren(n):o.appendChild(n)}));const u=o.getBBox();r&&o?(r.setAttribute("x",u.x-t),r.setAttribute("y",u.y-t),r.setAttribute("r",u.width/2+t)):a&&o&&(a.setAttribute("x",u.x-t),a.setAttribute("y",u.y-t),a.setAttribute("width",u.width+2*t),a.setAttribute("height",u.height+2*t))}}))}}),[e.data]),s().createElement("div",{className:"tree-graph",ref:t,style:{display:"flex",flexGrow:"1"}},s().createElement("svg",{width:e.parentWidth,height:e.parentHeight-e.offset,ref:e.zoom.containerRef},e.renderZoomContainer(),s().createElement(n.Group,{top:e.margin.top,left:e.margin.left,transform:e.zoom.toString()},s().createElement(r.Tree,{root:(0,r.hierarchy)(e.data,(e=>e.isExpanded?e.children:null)),size:[h.sizeWidth,h.sizeHeight],separation:(e,t)=>(e.parent===t.parent?1:2)/e.depth},(t=>s().createElement(n.Group,{top:h.origin.y,left:h.origin.x},t.links().map(((t,n)=>s().createElement(u,{key:n,data:t,percent:e.stepPercent,stroke:e.linkColor,strokeWidth:e.linkWidth,fill:"none"}))),d().map(t.descendants(),f)))))))};L.defaultProps={fontSize:12,layout:"cartesian",linkColor:"#B2B09B",linkType:T,linkWidth:1,margin:{top:30,left:30,right:30,bottom:70},nodeWidth:75,offset:0,orientation:"horizontal",stepPercent:.5,textColor:"#FFFFFF"};const S=(0,a.withParentSize)(x(L));S.Circle=w,S.Rectangle=N;var O=S;module.exports=t}();
1
+ !function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{TreeGraph:function(){return L},withZoom:function(){return v}});var n=require("@visx/group"),r=require("@visx/hierarchy"),o=require("@visx/responsive"),a=require("@visx/shape"),i=require("d3-shape"),l=require("react"),s=e.n(l),c=require("underscore"),u=e.n(c),m=require("@visx/event"),p=require("@visx/zoom"),d=require("i18next"),f=e.n(d);const g={en:{translation:JSON.parse('{"Zoom":{"buttons":{"center":"Center","clear":"Clear","reset":"Reset","zoomIn":"+","zoomOut":"-"}}}')}},h=f().createInstance();h.init({debug:!0,fallbackLng:"en",lng:"en",interpolation:{escapeValue:!1},resources:g});var b=h;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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(this,arguments)}const k={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};var v=e=>t=>{const{parentWidth:n,parentHeight:r}=t,{scaleXMin:o=.5,scaleXMax:a=4}=t,{scaleYMin:i=.5,scaleYMax:c=4}=t,{initialTransform:u=k}=t,d=(0,l.useCallback)((e=>s().createElement("rect",{width:n,height:r,rx:14,fill:"transparent",onTouchStart:e.dragStart,onTouchMove:e.dragMove,onTouchEnd:e.dragEnd,onMouseDown:e.dragStart,onMouseMove:e.dragMove,onMouseUp:e.dragEnd,onMouseLeave:()=>{e.isDragging&&e.dragEnd()},onDoubleClick:t=>{const n=(0,m.localPoint)(t)||{x:0,y:0};e.scale({scaleX:1.1,scaleY:1.1,point:n})}})),[n,r]);return s().createElement(p.Zoom,{width:n,height:r,scaleXMin:o,scaleXMax:a,scaleYMin:i,scaleYMax:c,initialTransformMatrix:u},(n=>s().createElement("div",{className:"zoom"},s().createElement(e,y({},t,{renderZoomContainer:d.bind(void 0,n),zoom:n})),s().createElement("div",{className:"controls"},s().createElement("button",{type:"button",className:"btn btn-zoom",onClick:()=>n.scale({scaleX:1.2,scaleY:1.2})},b.t("Zoom.buttons.zoomIn")),s().createElement("button",{type:"button",className:"btn btn-zoom btn-bottom",onClick:()=>n.scale({scaleX:.8,scaleY:.8})},b.t("Zoom.buttons.zoomOut")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.center},b.t("Zoom.buttons.center")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.reset},b.t("Zoom.buttons.reset")),s().createElement("button",{type:"button",className:"btn btn-lg",onClick:n.clear},b.t("Zoom.buttons.clear"))))))};const E="polar",x="curve",M="line",T="step",z="vertical",C=e=>{const t=(0,l.useRef)(),o=e.parentWidth-e.margin.left-e.margin.right,c=e.parentHeight-e.margin.top-e.margin.bottom,m=(0,l.useMemo)((()=>{let t;return t=e.layout===E?e.linkType===T?a.LinkRadialStep:e.linkType===x?a.LinkRadialCurve:e.linkType===M?a.LinkRadialLine:a.LinkRadial:e.orientation===z?e.linkType===T?a.LinkVerticalStep:e.linkType===x?a.LinkVerticalCurve:e.linkType===M?a.LinkVerticalLine:a.LinkVertical:e.linkType===T?a.LinkHorizontalStep:e.linkType===x?a.LinkHorizontalCurve:e.linkType===M?a.LinkHorizontalLine:a.LinkHorizontal,t}),[e.layout,e.linkType,e.orientation]),p=(0,l.useCallback)(((e,t)=>{let n=t;return e.isExpanded&&(n=u().max(u().map(e.children,(e=>p(e,t+1))))),n}),[]),d=(0,l.useCallback)(((t,n)=>{let r,o;if(e.layout===E){const[e,a]=(0,i.pointRadial)(t,n);r=a,o=e}else e.orientation===z?(r=n,o=t):(r=t,o=n);return{top:r,left:o}}),[e.layout,e.orientation]),f=(0,l.useMemo)((()=>{let t,n,r;const a=p(e.data,1);return e.layout===E?(r={x:o/2,y:c/2},t=2*Math.PI,n=Math.min(o,c)/2*(a/2)):(r={x:0,y:0},e.orientation===z?(t=o,n=c):(t=c,n=o)),{sizeWidth:t,sizeHeight:n,origin:r}}),[p,c,o,e.data,e.layout,e.orientation]),g=(0,l.useCallback)((t=>s().createElement("foreignObject",{width:"100%",height:"100%"},e.renderNode(t.data))),[e.renderNode]),h=(0,l.useCallback)(((e,t)=>{const{top:r,left:o}=d(e.x,e.y);return s().createElement(n.Group,{top:r,left:o,key:t},g(e))}),[g,e.layout,e.orientation,e.linkType]);return(0,l.useEffect)((()=>{const{current:e}=t;if(e){const t=e.getElementsByTagName("g");u().each(t,(e=>{const t=u().first(e.getElementsByTagName("foreignObject")),{offsetWidth:n,offsetHeight:r}=t.firstChild,o=window.getComputedStyle(e),a=new DOMMatrixReadOnly(o.transform),{m41:i,m42:l}=a,s=`translate(${i-n/2}, ${l-r/2})`;e.setAttribute("transform",s)}))}}),[e.data,e.layout,e.orientation,e.linkType]),s().createElement("div",{className:"tree-graph",ref:t,style:{display:"flex",flexGrow:"1"}},s().createElement("svg",{width:e.parentWidth,height:e.parentHeight-e.offset,ref:e.zoom.containerRef},e.renderZoomContainer(),s().createElement(n.Group,{top:e.margin.top,left:e.margin.left,transform:e.zoom.toString()},s().createElement(r.Tree,{root:(0,r.hierarchy)(e.data,(e=>e.isExpanded?e.children:null)),size:[f.sizeWidth,f.sizeHeight],separation:(e,t)=>(e.parent===t.parent?1:2)/e.depth},(t=>s().createElement(n.Group,{left:f.origin.x,top:f.origin.y},t.links().map(((t,n)=>s().createElement(m,{key:n,data:t,percent:e.stepPercent,stroke:e.linkColor,strokeWidth:e.linkWidth,fill:"none"}))),u().map(t.descendants(),h)))))))};C.defaultProps={fontSize:12,layout:"cartesian",linkColor:"#B2B09B",linkType:M,linkWidth:1,margin:{top:30,left:30,right:30,bottom:70},nodeWidth:75,offset:0,orientation:"horizontal",stepPercent:.5,textColor:"#FFFFFF"};var L=(0,o.withParentSize)(v(C));module.exports=t}();
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"yBACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,GAChC,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,WAAa,OAAOF,EAAgB,OAAG,EACvC,WAAa,OAAOA,CAAQ,EAE7B,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CACR,ECNAF,EAAwB,SAASM,EAASC,GACzC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAG3E,ECPAR,EAAwB,SAASc,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,EAAO,ECCtGf,EAAwB,SAASM,GACX,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GACvD,G,kFCNA,IAAI,EAA+BC,QAAQ,eCAvC,EAA+BA,QAAQ,mBCAvC,EAA+BA,QAAQ,oBCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,YCAvC,EAA+BA,QAAQ,S,SCAvC,EAA+BA,QAAQ,c,SCAvC,EAA+BA,QAAQ,eCAvC,EAA+BA,QAAQ,cCAvC,EAA+BA,QAAQ,W,SCI3C,MAAMC,EAAY,CAChBC,GAAI,CACFC,Y,oHAIEC,EAAOC,IAAAA,iBAEbD,EACGE,KAAK,CACJC,OAAO,EACPC,YAAa,KACbC,IAAK,KACLC,cAAe,CACbC,aAAa,GAEfV,cAGJ,Q,oOCIA,MAAMW,EAA4B,CACh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,SAAU,MAGZ,yBACE/I,MAAOF,EAAMC,YACbG,OAAQJ,EAAMG,aAAeH,EAAMkJ,OACnChG,IAAKlD,EAAMY,KAAKuI,cAEdnJ,EAAMU,sBACR,kBAAC,EAAAkG,MAAK,CACJnD,IAAKzD,EAAMqD,OAAOI,IAClBH,KAAMtD,EAAMqD,OAAOC,KACnB8F,UAAWpJ,EAAMY,KAAKyI,YAEtB,kBAAC,EAAAC,KAAI,CACH9D,MAAM+D,EAAAA,EAAAA,WAAUvJ,EAAM4F,MAAOlI,GAAOA,EAAEsH,WAAatH,EAAEwH,SAAW,OAChEsE,KAAM,CAAChE,EAAKC,UAAWD,EAAKE,YAC5B+D,WAAY,CAAC9L,EAAG+L,KAAO/L,EAAEgM,SAAWD,EAAEC,OAAS,EAAI,GAAKhM,EAAEmH,QAEvD8E,GACD,kBAAC,EAAAhD,MAAK,CACJnD,IAAK+B,EAAKG,OAAO5D,EACjBuB,KAAMkC,EAAKG,OAAO7D,GAEhB8H,EAAKC,QAAQC,KAAI,CAACC,EAAMlC,IACxB,kBAAClE,EAAa,CACZ7F,IAAK+J,EACLjC,KAAMmE,EACNC,QAAShK,EAAMiK,YACfhE,OAAQjG,EAAMkK,UACdhE,YAAalG,EAAMmK,UACnBrJ,KAAK,WAGPmE,IAAAA,IAAM2E,EAAKQ,cAAezD,QAMlC,EAIV1D,EAAUoH,aAAe,CACvB9D,SAAU,GACV1C,OAtWW,YAuWXqG,UAAW,UACXpG,SAAUnB,EACVwH,UAAW,EACX9G,OAAQ,CACNI,IAAK,GACLH,KAAM,GACNC,MAAO,GACPG,OAAQ,IAEVyE,UAAW,GACXe,OAAQ,EACR/E,YAvWY,aAwWZ8F,YAAa,GACbxD,UAAW,WAQb,MAAM6D,GAAoCC,EAAAA,EAAAA,gBAAeC,EAASvH,IAClEqH,EAAmBzH,OAASA,EAC5ByH,EAAmBtH,UAAYA,EAE/B,Q","sources":["webpack://@performant-software/visualize/webpack/bootstrap","webpack://@performant-software/visualize/webpack/runtime/compat get default export","webpack://@performant-software/visualize/webpack/runtime/define property getters","webpack://@performant-software/visualize/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/visualize/webpack/runtime/make namespace object","webpack://@performant-software/visualize/external commonjs \"@visx/group\"","webpack://@performant-software/visualize/external commonjs \"@visx/hierarchy\"","webpack://@performant-software/visualize/external commonjs \"@visx/responsive\"","webpack://@performant-software/visualize/external commonjs \"@visx/shape\"","webpack://@performant-software/visualize/external commonjs \"d3-shape\"","webpack://@performant-software/visualize/external commonjs2 \"react\"","webpack://@performant-software/visualize/external commonjs \"underscore\"","webpack://@performant-software/visualize/external commonjs \"@visx/event\"","webpack://@performant-software/visualize/external commonjs \"@visx/zoom\"","webpack://@performant-software/visualize/external commonjs \"i18next\"","webpack://@performant-software/visualize/./src/i18n/i18n.js","webpack://@performant-software/visualize/./src/hooks/Zoom.js","webpack://@performant-software/visualize/./src/components/TreeGraph.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/group\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/hierarchy\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/responsive\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"d3-shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/event\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/zoom\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"i18next\");","import i18next from 'i18next';\n\nimport en from './en.json';\n\nconst resources = {\n en: {\n translation: en\n }\n};\n\nconst i18n = i18next.createInstance();\n\ni18n\n .init({\n debug: true,\n fallbackLng: 'en',\n lng: 'en',\n interpolation: {\n escapeValue: false,\n },\n resources\n });\n\nexport default i18n;\n","// @flow\n\nimport React, { useCallback, type ComponentType, type Element } from 'react';\nimport { localPoint } from '@visx/event';\nimport { Zoom } from '@visx/zoom';\nimport i18n from '../i18n/i18n';\nimport './Zoom.css';\n\ntype Props = {\n initialTransform?: {\n skewX: number,\n skewY: number,\n scaleX: number,\n scaleY: number,\n translateX: number,\n translateY: number\n },\n parentHeight: number,\n parentWidth: number,\n scaleXMax?: number,\n scaleXMin?: number,\n scaleYMax?: number,\n scaleYMin?: number\n};\n\ntype WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => Element<any>;\n\nconst DEFAULT_INITIAL_TRANSFORM = {\n scaleX: 1,\n scaleY: 1,\n translateX: 0,\n translateY: 0,\n skewX: 0,\n skewY: 0,\n};\n\nconst withZoom: WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => {\n const { parentWidth: width, parentHeight: height } = props;\n const { scaleXMin = 1 / 2, scaleXMax = 4 } = props;\n const { scaleYMin = 1 / 2, scaleYMax = 4 } = props;\n const { initialTransform = DEFAULT_INITIAL_TRANSFORM } = props;\n\n /**\n * Renders the container with zoom controls.\n *\n * @type {unknown}\n */\n const renderZoomContainer = useCallback((zoom) => (\n <rect\n width={width}\n height={height}\n rx={14}\n fill='transparent'\n onTouchStart={zoom.dragStart}\n onTouchMove={zoom.dragMove}\n onTouchEnd={zoom.dragEnd}\n onMouseDown={zoom.dragStart}\n onMouseMove={zoom.dragMove}\n onMouseUp={zoom.dragEnd}\n onMouseLeave={() => {\n if (zoom.isDragging) zoom.dragEnd();\n }}\n onDoubleClick={(event) => {\n const point = localPoint(event) || { x: 0, y: 0 };\n zoom.scale({ scaleX: 1.1, scaleY: 1.1, point });\n }}\n />\n ), [width, height]);\n\n return (\n <Zoom\n width={width}\n height={height}\n scaleXMin={scaleXMin}\n scaleXMax={scaleXMax}\n scaleYMin={scaleYMin}\n scaleYMax={scaleYMax}\n initialTransformMatrix={initialTransform}\n >\n { (zoom) => (\n <div\n className='zoom'\n >\n <WrappedComponent\n {...props}\n renderZoomContainer={renderZoomContainer.bind(this, zoom)}\n zoom={zoom}\n />\n <div\n className='controls'\n >\n <button\n type='button'\n className='btn btn-zoom'\n onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}\n >\n { i18n.t('Zoom.buttons.zoomIn') }\n </button>\n <button\n type='button'\n className='btn btn-zoom btn-bottom'\n onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}\n >\n { i18n.t('Zoom.buttons.zoomOut') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.center}\n >\n { i18n.t('Zoom.buttons.center') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.reset}\n >\n { i18n.t('Zoom.buttons.reset') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.clear}\n >\n { i18n.t('Zoom.buttons.clear') }\n </button>\n </div>\n </div>\n )}\n </Zoom>\n );\n};\n\nexport default withZoom;\n\nexport type ZoomProps = {\n renderZoomContainer: () => Element<any>,\n zoom: typeof Zoom\n};\n","// @flow\n\nimport { Group } from '@visx/group';\nimport { hierarchy, Tree } from '@visx/hierarchy';\nimport { withParentSize } from '@visx/responsive';\nimport {\n LinkHorizontal,\n LinkHorizontalCurve,\n LinkHorizontalLine,\n LinkHorizontalStep,\n LinkRadial,\n LinkRadialCurve,\n LinkRadialLine,\n LinkRadialStep,\n LinkVertical,\n LinkVerticalCurve,\n LinkVerticalLine,\n LinkVerticalStep\n} from '@visx/shape';\nimport { pointRadial } from 'd3-shape';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type ComponentType,\n type Element\n} from 'react';\nimport _ from 'underscore';\nimport withZoom, { type ZoomProps } from '../hooks/Zoom';\nimport './TreeGraph.css';\n\ntype Props = ZoomProps & {\n data: any,\n fontSize: number,\n layout: string,\n linkType: string,\n offset: number,\n orientation: string,\n parentHeight: number,\n parentWidth: number,\n linkColor: string,\n linkWidth: number,\n margin: {\n top: number,\n right: number,\n bottom: number,\n left: number\n },\n nodeWidth: number,\n onClick?: (data: any) => void,\n renderNode?: (data: any) => Element<any>,\n renderText?: (data: any) => Element<any>,\n stepPercent: number,\n textColor: string\n};\n\nconst Layout = {\n cartesian: 'cartesian',\n polar: 'polar'\n};\n\nconst LinkType = {\n curve: 'curve',\n line: 'line',\n step: 'step'\n};\n\nconst Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical'\n};\n\nconst Circle: ComponentType<any> = (props: any) => (\n <circle\n r={props.radius}\n {...props}\n />\n);\n\nconst Rectangle: ComponentType<any> = (props: any) => (\n <rect\n {...props}\n />\n);\n\nconst TreeGraph = (props: Props) => {\n const ref = useRef();\n\n const innerWidth = props.parentWidth - props.margin.left - props.margin.right;\n const innerHeight = props.parentHeight - props.margin.top - props.margin.bottom;\n\n /**\n * Sets the link component based on the layout, linkType, and orientation props.\n *\n * @type {*}\n */\n const LinkComponent = useMemo(() => {\n let value;\n\n if (props.layout === Layout.polar) {\n if (props.linkType === LinkType.step) {\n value = LinkRadialStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkRadialCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkRadialLine;\n } else {\n value = LinkRadial;\n }\n } else if (props.orientation === Orientation.vertical) {\n if (props.linkType === LinkType.step) {\n value = LinkVerticalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkVerticalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkVerticalLine;\n } else {\n value = LinkVertical;\n }\n } else if (props.linkType === LinkType.step) {\n value = LinkHorizontalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkHorizontalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkHorizontalLine;\n } else {\n value = LinkHorizontal;\n }\n\n return value;\n }, [props.layout, props.linkType, props.orientation]);\n\n /**\n * Returns the depth of the last expanded node.\n *\n * @type {function(*, *): *}\n */\n const getMaxDepth = useCallback((node, depth) => {\n let max = depth;\n\n if (node.isExpanded) {\n max = _.max(_.map(node.children, (child) => getMaxDepth(child, depth + 1)));\n }\n\n return max;\n }, []);\n\n /**\n * Returns the node position for the passed coordinates.\n *\n * @type {function(*, *): {top: *, left: *}}\n */\n const getNodePosition = useCallback((x, y) => {\n let top;\n let left;\n\n if (props.layout === Layout.polar) {\n const [radialX, radialY] = pointRadial(x, y);\n top = radialY;\n left = radialX;\n } else if (props.orientation === Orientation.vertical) {\n top = y;\n left = x;\n } else {\n top = x;\n left = y;\n }\n\n return {\n top,\n left\n };\n }, [props.layout, props.orientation]);\n\n /**\n * Returns the position and size of the root node.\n *\n * @type {{sizeWidth: *, origin: *, sizeHeight: *}}\n */\n const root = useMemo(() => {\n let sizeWidth;\n let sizeHeight;\n let origin;\n\n const depth = getMaxDepth(props.data, 1);\n\n if (props.layout === Layout.polar) {\n origin = {\n x: innerWidth / 2,\n y: innerHeight / 2,\n };\n sizeWidth = 2 * Math.PI;\n sizeHeight = (Math.min(innerWidth, innerHeight) / 2) * (depth / 2);\n } else {\n origin = { x: 0, y: 0 };\n if (props.orientation === Orientation.vertical) {\n sizeWidth = innerWidth;\n sizeHeight = innerHeight;\n } else {\n sizeWidth = innerHeight;\n sizeHeight = innerWidth;\n }\n }\n\n return {\n sizeWidth,\n sizeHeight,\n origin\n };\n }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);\n\n /**\n * Renders the passed node. If provided, only the \"renderNode\" prop is called.\n *\n * @type {(function(*): (*))|*}\n */\n const renderNode = useCallback((node) => {\n if (props.renderNode) {\n return props.renderNode(node.data);\n }\n\n if (node.depth === 0) {\n return (\n <Circle\n fill='#FF4A4A'\n onClick={props.onClick && props.onClick.bind(this, node.data)}\n />\n );\n }\n\n return (\n <Rectangle\n fill='#272b4d'\n stroke={node.data.children ? '#03c0dc' : '#26deb0'}\n strokeWidth={1}\n strokeDasharray={node.data.children ? '0' : '2,2'}\n strokeOpacity={node.data.children ? 1 : 0.6}\n rx={node.data.children ? 0 : 10}\n onClick={props.onClick && props.onClick.bind(this, node.data)}\n />\n );\n }, [props.onClick, props.renderNode]);\n\n /**\n * Renders the text for the passed node.\n *\n * @type {(function(*): (*))|*}\n */\n const renderText = useCallback((node) => {\n if (props.renderText) {\n return props.renderText(node.data);\n }\n\n return (\n <text\n dy='0.33em'\n fontSize={props.fontSize}\n textAnchor='middle'\n fill={props.textColor}\n >\n { node.data.name }\n </text>\n );\n }, [props.renderText]);\n\n /**\n * Renders the group element for the passed node.\n *\n * @type {unknown}\n */\n const renderGroup = useCallback((node, key) => {\n const { top, left } = getNodePosition(node.x, node.y);\n\n return (\n <Group\n top={top}\n left={left}\n key={key}\n >\n { renderNode(node) }\n { renderText(node) }\n </Group>\n );\n }, [renderNode, renderText, props.layout, props.orientation]);\n\n /**\n * Resizes the \"circle\" and \"rect\" elements based on the text contained in the group. This effect will also\n * convert text into multiple lines.\n */\n useEffect(() => {\n const { current } = ref;\n if (current) {\n const padding = 15;\n const groups = current.getElementsByTagName('g');\n _.each(groups, (group) => {\n const circle = _.first(group.getElementsByTagName('circle'));\n const rect = _.first(group.getElementsByTagName('rect'));\n\n const text = _.first(group.getElementsByTagName('text'));\n const { height } = text.getBBox();\n\n if (!text.getElementsByTagName('tspan').length) {\n const words = text.innerHTML.split(/\\s+/);\n\n const lines = [];\n let lineIndex = 0;\n\n for (let i = 0; i < words.length; i += 1) {\n // Initialize the line array for the current line\n if (!lines[lineIndex]) {\n lines[lineIndex] = [];\n }\n\n // Add the current word to the current line\n lines[lineIndex].push(words[i]);\n\n // Look ahead to the next word and increment the line index if necessary\n if (i < words.length - 1) {\n const testElement = text.cloneNode();\n testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');\n group.append(testElement);\n\n if (testElement.getBBox().width > props.nodeWidth) {\n lineIndex += 1;\n }\n\n testElement.remove();\n }\n }\n\n // Append the lines to the text element\n _.each(lines, (line, index) => {\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\n tspan.setAttribute('x', '0');\n if (index > 0) {\n tspan.setAttribute('dy', `${height}px`);\n }\n tspan.appendChild(document.createTextNode(line.join(' ')));\n\n if (index === 0) {\n text.replaceChildren(tspan);\n } else {\n text.appendChild(tspan);\n }\n });\n\n // Set the shape attributes based on the text size\n const bbox = text.getBBox();\n if (circle && text) {\n circle.setAttribute('x', bbox.x - padding);\n circle.setAttribute('y', bbox.y - padding);\n circle.setAttribute('r', (bbox.width / 2) + padding);\n } else if (rect && text) {\n rect.setAttribute('x', bbox.x - padding);\n rect.setAttribute('y', bbox.y - padding);\n rect.setAttribute('width', bbox.width + 2 * padding);\n rect.setAttribute('height', bbox.height + 2 * padding);\n }\n }\n });\n }\n }, [props.data]);\n\n return (\n <div\n className='tree-graph'\n ref={ref}\n style={{\n display: 'flex',\n flexGrow: '1'\n }}\n >\n <svg\n width={props.parentWidth}\n height={props.parentHeight - props.offset}\n ref={props.zoom.containerRef}\n >\n { props.renderZoomContainer() }\n <Group\n top={props.margin.top}\n left={props.margin.left}\n transform={props.zoom.toString()}\n >\n <Tree\n root={hierarchy(props.data, (d) => (d.isExpanded ? d.children : null))}\n size={[root.sizeWidth, root.sizeHeight]}\n separation={(a, b) => (a.parent === b.parent ? 1 : 2) / a.depth}\n >\n { (tree) => (\n <Group\n top={root.origin.y}\n left={root.origin.x}\n >\n { tree.links().map((link, i) => (\n <LinkComponent\n key={i}\n data={link}\n percent={props.stepPercent}\n stroke={props.linkColor}\n strokeWidth={props.linkWidth}\n fill='none'\n />\n ))}\n { _.map(tree.descendants(), renderGroup) }\n </Group>\n )}\n </Tree>\n </Group>\n </svg>\n </div>\n );\n};\n\nTreeGraph.defaultProps = {\n fontSize: 12,\n layout: Layout.cartesian,\n linkColor: '#B2B09B',\n linkType: LinkType.line,\n linkWidth: 1,\n margin: {\n top: 30,\n left: 30,\n right: 30,\n bottom: 70\n },\n nodeWidth: 75,\n offset: 0,\n orientation: Orientation.horizontal,\n stepPercent: 0.5,\n textColor: '#FFFFFF'\n};\n\ntype TreeGraphType = ComponentType<any> & {\n Circle: typeof Circle,\n Rectangle: typeof Rectangle\n};\n\nconst TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));\nTreeGraphComponent.Circle = Circle;\nTreeGraphComponent.Rectangle = Rectangle;\n\nexport default TreeGraphComponent;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","resources","en","translation","i18n","i18next","init","debug","fallbackLng","lng","interpolation","escapeValue","DEFAULT_INITIAL_TRANSFORM","scaleX","scaleY","translateX","translateY","skewX","skewY","WrappedComponent","props","parentWidth","width","parentHeight","height","scaleXMin","scaleXMax","scaleYMin","scaleYMax","initialTransform","renderZoomContainer","useCallback","zoom","rx","fill","onTouchStart","dragStart","onTouchMove","dragMove","onTouchEnd","dragEnd","onMouseDown","onMouseMove","onMouseUp","onMouseLeave","isDragging","onDoubleClick","event","point","localPoint","x","y","scale","Zoom","initialTransformMatrix","className","bind","type","onClick","center","reset","clear","Layout","LinkType","Orientation","Circle","r","radius","Rectangle","TreeGraph","ref","useRef","innerWidth","margin","left","right","innerHeight","top","bottom","LinkComponent","useMemo","layout","linkType","LinkRadialStep","LinkRadialCurve","LinkRadialLine","LinkRadial","orientation","LinkVerticalStep","LinkVerticalCurve","LinkVerticalLine","LinkVertical","LinkHorizontalStep","LinkHorizontalCurve","LinkHorizontalLine","LinkHorizontal","getMaxDepth","node","depth","max","isExpanded","_","children","child","getNodePosition","radialX","radialY","pointRadial","root","sizeWidth","sizeHeight","origin","data","Math","PI","min","renderNode","stroke","strokeWidth","strokeDasharray","strokeOpacity","renderText","dy","fontSize","textAnchor","textColor","name","renderGroup","Group","useEffect","current","padding","groups","getElementsByTagName","group","circle","rect","text","getBBox","length","words","innerHTML","split","lines","lineIndex","i","push","testElement","cloneNode","join","append","nodeWidth","remove","line","index","tspan","document","createElementNS","setAttribute","appendChild","createTextNode","replaceChildren","bbox","style","display","flexGrow","offset","containerRef","transform","toString","Tree","hierarchy","size","separation","b","parent","tree","links","map","link","percent","stepPercent","linkColor","linkWidth","descendants","defaultProps","TreeGraphComponent","withParentSize","withZoom"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"yBACA,IAAIA,EAAsB,CCA1BA,EAAwB,SAASC,GAChC,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,WAAa,OAAOF,EAAgB,OAAG,EACvC,WAAa,OAAOA,CAAQ,EAE7B,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CACR,ECNAF,EAAwB,SAASM,EAASC,GACzC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAG3E,ECPAR,EAAwB,SAASc,EAAKC,GAAQ,OAAOL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,EAAO,ECCtGf,EAAwB,SAASM,GACX,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC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L0D,MAAO,CACLS,QAAS,OACTC,SAAU,MAGZ,yBACEhH,MAAOF,EAAMC,YACbG,OAAQJ,EAAMG,aAAeH,EAAMmH,OACnCrE,IAAK9C,EAAMY,KAAKwG,cAEdpH,EAAMU,sBACR,kBAAC,EAAAoF,MAAK,CACJzC,IAAKrD,EAAMiD,OAAOI,IAClBH,KAAMlD,EAAMiD,OAAOC,KACnB2D,UAAW7G,EAAMY,KAAKyG,YAEtB,kBAAC,EAAAC,KAAI,CACHlC,MAAMmC,EAAAA,EAAAA,WAAUvH,EAAMwF,MAAO9H,GAAOA,EAAEkH,WAAalH,EAAEoH,SAAW,OAChE0C,KAAM,CAACpC,EAAKC,UAAWD,EAAKE,YAC5BmC,WAAY,CAAC9J,EAAG+J,KAAO/J,EAAEgK,SAAWD,EAAEC,OAAS,EAAI,GAAKhK,EAAE+G,QAEvDkD,GACD,kBAAC,EAAA9B,MAAK,CACJ5C,KAAMkC,EAAKG,OAAOzD,EAClBuB,IAAK+B,EAAKG,OAAOxD,GAEf6F,EAAKC,QAAQC,KAAI,CAACC,EAAMC,IACxB,kBAACzE,EAAa,CACZzF,IAAKkK,EACLxC,KAAMuC,EACNE,QAASjI,EAAMkI,YACfC,OAAQnI,EAAMoI,UACdC,YAAarI,EAAMsI,UACnBxH,KAAK,WAGP+D,IAAAA,IAAM+C,EAAKW,cAAe1C,QAMlC,EAIVhD,EAAU2F,aAAe,CACvBC,SAAU,GACVhF,OAnPW,YAoPX2E,UAAW,UACX1E,SAAUf,EACV2F,UAAW,EACXrF,OAAQ,CACNI,IAAK,GACLH,KAAM,GACNC,MAAO,GACPG,OAAQ,IAEVoF,UAAW,GACXvB,OAAQ,EACRpD,YApPY,aAqPZmE,YAAa,GACbS,UAAW,WAIb,OAD+CC,EAAAA,EAAAA,gBAAeC,EAAShG,I","sources":["webpack://@performant-software/visualize/webpack/bootstrap","webpack://@performant-software/visualize/webpack/runtime/compat get default export","webpack://@performant-software/visualize/webpack/runtime/define property getters","webpack://@performant-software/visualize/webpack/runtime/hasOwnProperty shorthand","webpack://@performant-software/visualize/webpack/runtime/make namespace object","webpack://@performant-software/visualize/external commonjs \"@visx/group\"","webpack://@performant-software/visualize/external commonjs \"@visx/hierarchy\"","webpack://@performant-software/visualize/external commonjs \"@visx/responsive\"","webpack://@performant-software/visualize/external commonjs \"@visx/shape\"","webpack://@performant-software/visualize/external commonjs \"d3-shape\"","webpack://@performant-software/visualize/external commonjs2 \"react\"","webpack://@performant-software/visualize/external commonjs \"underscore\"","webpack://@performant-software/visualize/external commonjs \"@visx/event\"","webpack://@performant-software/visualize/external commonjs \"@visx/zoom\"","webpack://@performant-software/visualize/external commonjs \"i18next\"","webpack://@performant-software/visualize/./src/i18n/i18n.js","webpack://@performant-software/visualize/./src/hooks/Zoom.js","webpack://@performant-software/visualize/./src/components/TreeGraph.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/group\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/hierarchy\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/responsive\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"d3-shape\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"react\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"underscore\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/event\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"@visx/zoom\");","var __WEBPACK_NAMESPACE_OBJECT__ = require(\"i18next\");","import i18next from 'i18next';\n\nimport en from './en.json';\n\nconst resources = {\n en: {\n translation: en\n }\n};\n\nconst i18n = i18next.createInstance();\n\ni18n\n .init({\n debug: true,\n fallbackLng: 'en',\n lng: 'en',\n interpolation: {\n escapeValue: false,\n },\n resources\n });\n\nexport default i18n;\n","// @flow\n\nimport React, { useCallback, type ComponentType, type Element } from 'react';\nimport { localPoint } from '@visx/event';\nimport { Zoom } from '@visx/zoom';\nimport i18n from '../i18n/i18n';\nimport './Zoom.css';\n\ntype Props = {\n initialTransform?: {\n skewX: number,\n skewY: number,\n scaleX: number,\n scaleY: number,\n translateX: number,\n translateY: number\n },\n parentHeight: number,\n parentWidth: number,\n scaleXMax?: number,\n scaleXMin?: number,\n scaleYMax?: number,\n scaleYMin?: number\n};\n\ntype WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => Element<any>;\n\nconst DEFAULT_INITIAL_TRANSFORM = {\n scaleX: 1,\n scaleY: 1,\n translateX: 0,\n translateY: 0,\n skewX: 0,\n skewY: 0,\n};\n\nconst withZoom: WithZoomType = (WrappedComponent: ComponentType<any>) => (props: Props) => {\n const { parentWidth: width, parentHeight: height } = props;\n const { scaleXMin = 1 / 2, scaleXMax = 4 } = props;\n const { scaleYMin = 1 / 2, scaleYMax = 4 } = props;\n const { initialTransform = DEFAULT_INITIAL_TRANSFORM } = props;\n\n /**\n * Renders the container with zoom controls.\n *\n * @type {unknown}\n */\n const renderZoomContainer = useCallback((zoom) => (\n <rect\n width={width}\n height={height}\n rx={14}\n fill='transparent'\n onTouchStart={zoom.dragStart}\n onTouchMove={zoom.dragMove}\n onTouchEnd={zoom.dragEnd}\n onMouseDown={zoom.dragStart}\n onMouseMove={zoom.dragMove}\n onMouseUp={zoom.dragEnd}\n onMouseLeave={() => {\n if (zoom.isDragging) zoom.dragEnd();\n }}\n onDoubleClick={(event) => {\n const point = localPoint(event) || { x: 0, y: 0 };\n zoom.scale({ scaleX: 1.1, scaleY: 1.1, point });\n }}\n />\n ), [width, height]);\n\n return (\n <Zoom\n width={width}\n height={height}\n scaleXMin={scaleXMin}\n scaleXMax={scaleXMax}\n scaleYMin={scaleYMin}\n scaleYMax={scaleYMax}\n initialTransformMatrix={initialTransform}\n >\n { (zoom) => (\n <div\n className='zoom'\n >\n <WrappedComponent\n {...props}\n renderZoomContainer={renderZoomContainer.bind(this, zoom)}\n zoom={zoom}\n />\n <div\n className='controls'\n >\n <button\n type='button'\n className='btn btn-zoom'\n onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}\n >\n { i18n.t('Zoom.buttons.zoomIn') }\n </button>\n <button\n type='button'\n className='btn btn-zoom btn-bottom'\n onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}\n >\n { i18n.t('Zoom.buttons.zoomOut') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.center}\n >\n { i18n.t('Zoom.buttons.center') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.reset}\n >\n { i18n.t('Zoom.buttons.reset') }\n </button>\n <button\n type='button'\n className='btn btn-lg'\n onClick={zoom.clear}\n >\n { i18n.t('Zoom.buttons.clear') }\n </button>\n </div>\n </div>\n )}\n </Zoom>\n );\n};\n\nexport default withZoom;\n\nexport type ZoomProps = {\n renderZoomContainer: () => Element<any>,\n zoom: typeof Zoom\n};\n","// @flow\n\nimport { Group } from '@visx/group';\nimport { hierarchy, Tree } from '@visx/hierarchy';\nimport { withParentSize } from '@visx/responsive';\nimport {\n LinkHorizontal,\n LinkHorizontalCurve,\n LinkHorizontalLine,\n LinkHorizontalStep,\n LinkRadial,\n LinkRadialCurve,\n LinkRadialLine,\n LinkRadialStep,\n LinkVertical,\n LinkVerticalCurve,\n LinkVerticalLine,\n LinkVerticalStep\n} from '@visx/shape';\nimport { pointRadial } from 'd3-shape';\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n type ComponentType,\n type Element\n} from 'react';\nimport _ from 'underscore';\nimport withZoom, { type ZoomProps } from '../hooks/Zoom';\nimport './TreeGraph.css';\n\ntype Props = ZoomProps & {\n data: any,\n fontSize: number,\n layout: string,\n linkType: string,\n offset: number,\n orientation: string,\n parentHeight: number,\n parentWidth: number,\n linkColor: string,\n linkWidth: number,\n margin: {\n top: number,\n right: number,\n bottom: number,\n left: number\n },\n nodeWidth: number,\n onClick?: (data: any) => void,\n renderNode?: (data: any) => Element<any>,\n renderText?: (data: any) => Element<any>,\n stepPercent: number,\n textColor: string\n};\n\nconst Layout = {\n cartesian: 'cartesian',\n polar: 'polar'\n};\n\nconst LinkType = {\n curve: 'curve',\n line: 'line',\n step: 'step'\n};\n\nconst Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical'\n};\n\nconst TreeGraph = (props: Props) => {\n const ref = useRef();\n\n const innerWidth = props.parentWidth - props.margin.left - props.margin.right;\n const innerHeight = props.parentHeight - props.margin.top - props.margin.bottom;\n\n /**\n * Sets the link component based on the layout, linkType, and orientation props.\n *\n * @type {*}\n */\n const LinkComponent = useMemo(() => {\n let value;\n\n if (props.layout === Layout.polar) {\n if (props.linkType === LinkType.step) {\n value = LinkRadialStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkRadialCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkRadialLine;\n } else {\n value = LinkRadial;\n }\n } else if (props.orientation === Orientation.vertical) {\n if (props.linkType === LinkType.step) {\n value = LinkVerticalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkVerticalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkVerticalLine;\n } else {\n value = LinkVertical;\n }\n } else if (props.linkType === LinkType.step) {\n value = LinkHorizontalStep;\n } else if (props.linkType === LinkType.curve) {\n value = LinkHorizontalCurve;\n } else if (props.linkType === LinkType.line) {\n value = LinkHorizontalLine;\n } else {\n value = LinkHorizontal;\n }\n\n return value;\n }, [props.layout, props.linkType, props.orientation]);\n\n /**\n * Returns the depth of the last expanded node.\n *\n * @type {function(*, *): *}\n */\n const getMaxDepth = useCallback((node, depth) => {\n let max = depth;\n\n if (node.isExpanded) {\n max = _.max(_.map(node.children, (child) => getMaxDepth(child, depth + 1)));\n }\n\n return max;\n }, []);\n\n /**\n * Returns the node position for the passed coordinates.\n *\n * @type {function(*, *): {top: *, left: *}}\n */\n const getNodePosition = useCallback((x, y) => {\n let top;\n let left;\n\n if (props.layout === Layout.polar) {\n const [radialX, radialY] = pointRadial(x, y);\n top = radialY;\n left = radialX;\n } else if (props.orientation === Orientation.vertical) {\n top = y;\n left = x;\n } else {\n top = x;\n left = y;\n }\n\n return {\n top,\n left\n };\n }, [props.layout, props.orientation]);\n\n /**\n * Returns the position and size of the root node.\n *\n * @type {{sizeWidth: *, origin: *, sizeHeight: *}}\n */\n const root = useMemo(() => {\n let sizeWidth;\n let sizeHeight;\n let origin;\n\n const depth = getMaxDepth(props.data, 1);\n\n if (props.layout === Layout.polar) {\n origin = {\n x: innerWidth / 2,\n y: innerHeight / 2,\n };\n sizeWidth = 2 * Math.PI;\n sizeHeight = (Math.min(innerWidth, innerHeight) / 2) * (depth / 2);\n } else {\n origin = { x: 0, y: 0 };\n if (props.orientation === Orientation.vertical) {\n sizeWidth = innerWidth;\n sizeHeight = innerHeight;\n } else {\n sizeWidth = innerHeight;\n sizeHeight = innerWidth;\n }\n }\n\n return {\n sizeWidth,\n sizeHeight,\n origin\n };\n }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);\n\n const renderNode = useCallback((node) => (\n <foreignObject\n width='100%'\n height='100%'\n >\n { props.renderNode(node.data) }\n </foreignObject>\n ), [props.renderNode]);\n\n /**\n * Renders the group element for the passed node.\n *\n * @type {unknown}\n */\n const renderGroup = useCallback((node, key) => {\n const { top, left } = getNodePosition(node.x, node.y);\n\n return (\n <Group\n top={top}\n left={left}\n key={key}\n >\n { renderNode(node) }\n </Group>\n );\n }, [renderNode, props.layout, props.orientation, props.linkType]);\n\n /**\n * Resizes the \"circle\" and \"rect\" elements based on the text contained in the group. This effect will also\n * convert text into multiple lines.\n */\n useEffect(() => {\n const { current } = ref;\n if (current) {\n const groups = current.getElementsByTagName('g');\n _.each(groups, (group) => {\n const object = _.first(group.getElementsByTagName('foreignObject'));\n const { offsetWidth: width, offsetHeight: height } = object.firstChild;\n\n const style = window.getComputedStyle(group);\n const matrix = new DOMMatrixReadOnly(style.transform);\n const { m41: translateX, m42: translateY } = matrix;\n\n const transform = `translate(${translateX - (width / 2.0)}, ${translateY - (height / 2.0)})`;\n group.setAttribute('transform', transform);\n });\n }\n }, [props.data, props.layout, props.orientation, props.linkType]);\n\n return (\n <div\n className='tree-graph'\n ref={ref}\n style={{\n display: 'flex',\n flexGrow: '1'\n }}\n >\n <svg\n width={props.parentWidth}\n height={props.parentHeight - props.offset}\n ref={props.zoom.containerRef}\n >\n { props.renderZoomContainer() }\n <Group\n top={props.margin.top}\n left={props.margin.left}\n transform={props.zoom.toString()}\n >\n <Tree\n root={hierarchy(props.data, (d) => (d.isExpanded ? d.children : null))}\n size={[root.sizeWidth, root.sizeHeight]}\n separation={(a, b) => (a.parent === b.parent ? 1 : 2) / a.depth}\n >\n { (tree) => (\n <Group\n left={root.origin.x}\n top={root.origin.y}\n >\n { tree.links().map((link, i) => (\n <LinkComponent\n key={i}\n data={link}\n percent={props.stepPercent}\n stroke={props.linkColor}\n strokeWidth={props.linkWidth}\n fill='none'\n />\n ))}\n { _.map(tree.descendants(), renderGroup) }\n </Group>\n )}\n </Tree>\n </Group>\n </svg>\n </div>\n );\n};\n\nTreeGraph.defaultProps = {\n fontSize: 12,\n layout: Layout.cartesian,\n linkColor: '#B2B09B',\n linkType: LinkType.line,\n linkWidth: 1,\n margin: {\n top: 30,\n left: 30,\n right: 30,\n bottom: 70\n },\n nodeWidth: 75,\n offset: 0,\n orientation: Orientation.horizontal,\n stepPercent: 0.5,\n textColor: '#FFFFFF'\n};\n\nconst TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));\nexport default TreeGraphComponent;\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","resources","en","translation","i18n","i18next","init","debug","fallbackLng","lng","interpolation","escapeValue","DEFAULT_INITIAL_TRANSFORM","scaleX","scaleY","translateX","translateY","skewX","skewY","WrappedComponent","props","parentWidth","width","parentHeight","height","scaleXMin","scaleXMax","scaleYMin","scaleYMax","initialTransform","renderZoomContainer","useCallback","zoom","rx","fill","onTouchStart","dragStart","onTouchMove","dragMove","onTouchEnd","dragEnd","onMouseDown","onMouseMove","onMouseUp","onMouseLeave","isDragging","onDoubleClick","event","point","localPoint","x","y","scale","Zoom","initialTransformMatrix","className","bind","type","onClick","center","reset","clear","Layout","LinkType","Orientation","TreeGraph","ref","useRef","innerWidth","margin","left","right","innerHeight","top","bottom","LinkComponent","useMemo","layout","linkType","LinkRadialStep","LinkRadialCurve","LinkRadialLine","LinkRadial","orientation","LinkVerticalStep","LinkVerticalCurve","LinkVerticalLine","LinkVertical","LinkHorizontalStep","LinkHorizontalCurve","LinkHorizontalLine","LinkHorizontal","getMaxDepth","node","depth","max","isExpanded","_","children","child","getNodePosition","radialX","radialY","pointRadial","root","sizeWidth","sizeHeight","origin","data","Math","PI","min","renderNode","renderGroup","Group","useEffect","current","groups","getElementsByTagName","group","object","offsetWidth","offsetHeight","firstChild","style","window","getComputedStyle","matrix","DOMMatrixReadOnly","transform","m41","m42","setAttribute","display","flexGrow","offset","containerRef","toString","Tree","hierarchy","size","separation","b","parent","tree","links","map","link","i","percent","stepPercent","stroke","linkColor","strokeWidth","linkWidth","descendants","defaultProps","fontSize","nodeWidth","textColor","withParentSize","withZoom"],"sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/visualize",
3
- "version": "1.0.6",
3
+ "version": "1.0.7-beta.1",
4
4
  "description": "A package of components used for data visualization",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -71,19 +71,6 @@ const Orientation = {
71
71
  vertical: 'vertical'
72
72
  };
73
73
 
74
- const Circle: ComponentType<any> = (props: any) => (
75
- <circle
76
- r={props.radius}
77
- {...props}
78
- />
79
- );
80
-
81
- const Rectangle: ComponentType<any> = (props: any) => (
82
- <rect
83
- {...props}
84
- />
85
- );
86
-
87
74
  const TreeGraph = (props: Props) => {
88
75
  const ref = useRef();
89
76
 
@@ -210,59 +197,14 @@ const TreeGraph = (props: Props) => {
210
197
  };
211
198
  }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);
212
199
 
213
- /**
214
- * Renders the passed node. If provided, only the "renderNode" prop is called.
215
- *
216
- * @type {(function(*): (*))|*}
217
- */
218
- const renderNode = useCallback((node) => {
219
- if (props.renderNode) {
220
- return props.renderNode(node.data);
221
- }
222
-
223
- if (node.depth === 0) {
224
- return (
225
- <Circle
226
- fill='#FF4A4A'
227
- onClick={props.onClick && props.onClick.bind(this, node.data)}
228
- />
229
- );
230
- }
231
-
232
- return (
233
- <Rectangle
234
- fill='#272b4d'
235
- stroke={node.data.children ? '#03c0dc' : '#26deb0'}
236
- strokeWidth={1}
237
- strokeDasharray={node.data.children ? '0' : '2,2'}
238
- strokeOpacity={node.data.children ? 1 : 0.6}
239
- rx={node.data.children ? 0 : 10}
240
- onClick={props.onClick && props.onClick.bind(this, node.data)}
241
- />
242
- );
243
- }, [props.onClick, props.renderNode]);
244
-
245
- /**
246
- * Renders the text for the passed node.
247
- *
248
- * @type {(function(*): (*))|*}
249
- */
250
- const renderText = useCallback((node) => {
251
- if (props.renderText) {
252
- return props.renderText(node.data);
253
- }
254
-
255
- return (
256
- <text
257
- dy='0.33em'
258
- fontSize={props.fontSize}
259
- textAnchor='middle'
260
- fill={props.textColor}
261
- >
262
- { node.data.name }
263
- </text>
264
- );
265
- }, [props.renderText]);
200
+ const renderNode = useCallback((node) => (
201
+ <foreignObject
202
+ width='100%'
203
+ height='100%'
204
+ >
205
+ { props.renderNode(node.data) }
206
+ </foreignObject>
207
+ ), [props.renderNode]);
266
208
 
267
209
  /**
268
210
  * Renders the group element for the passed node.
@@ -279,10 +221,9 @@ const TreeGraph = (props: Props) => {
279
221
  key={key}
280
222
  >
281
223
  { renderNode(node) }
282
- { renderText(node) }
283
224
  </Group>
284
225
  );
285
- }, [renderNode, renderText, props.layout, props.orientation]);
226
+ }, [renderNode, props.layout, props.orientation, props.linkType]);
286
227
 
287
228
  /**
288
229
  * Resizes the "circle" and "rect" elements based on the text contained in the group. This effect will also
@@ -291,76 +232,20 @@ const TreeGraph = (props: Props) => {
291
232
  useEffect(() => {
292
233
  const { current } = ref;
293
234
  if (current) {
294
- const padding = 15;
295
235
  const groups = current.getElementsByTagName('g');
296
236
  _.each(groups, (group) => {
297
- const circle = _.first(group.getElementsByTagName('circle'));
298
- const rect = _.first(group.getElementsByTagName('rect'));
299
-
300
- const text = _.first(group.getElementsByTagName('text'));
301
- const { height } = text.getBBox();
302
-
303
- if (!text.getElementsByTagName('tspan').length) {
304
- const words = text.innerHTML.split(/\s+/);
305
-
306
- const lines = [];
307
- let lineIndex = 0;
308
-
309
- for (let i = 0; i < words.length; i += 1) {
310
- // Initialize the line array for the current line
311
- if (!lines[lineIndex]) {
312
- lines[lineIndex] = [];
313
- }
314
-
315
- // Add the current word to the current line
316
- lines[lineIndex].push(words[i]);
317
-
318
- // Look ahead to the next word and increment the line index if necessary
319
- if (i < words.length - 1) {
320
- const testElement = text.cloneNode();
321
- testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');
322
- group.append(testElement);
237
+ const object = _.first(group.getElementsByTagName('foreignObject'));
238
+ const { offsetWidth: width, offsetHeight: height } = object.firstChild;
323
239
 
324
- if (testElement.getBBox().width > props.nodeWidth) {
325
- lineIndex += 1;
326
- }
240
+ const style = window.getComputedStyle(group);
241
+ const matrix = new DOMMatrixReadOnly(style.transform);
242
+ const { m41: translateX, m42: translateY } = matrix;
327
243
 
328
- testElement.remove();
329
- }
330
- }
331
-
332
- // Append the lines to the text element
333
- _.each(lines, (line, index) => {
334
- const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
335
- tspan.setAttribute('x', '0');
336
- if (index > 0) {
337
- tspan.setAttribute('dy', `${height}px`);
338
- }
339
- tspan.appendChild(document.createTextNode(line.join(' ')));
340
-
341
- if (index === 0) {
342
- text.replaceChildren(tspan);
343
- } else {
344
- text.appendChild(tspan);
345
- }
346
- });
347
-
348
- // Set the shape attributes based on the text size
349
- const bbox = text.getBBox();
350
- if (circle && text) {
351
- circle.setAttribute('x', bbox.x - padding);
352
- circle.setAttribute('y', bbox.y - padding);
353
- circle.setAttribute('r', (bbox.width / 2) + padding);
354
- } else if (rect && text) {
355
- rect.setAttribute('x', bbox.x - padding);
356
- rect.setAttribute('y', bbox.y - padding);
357
- rect.setAttribute('width', bbox.width + 2 * padding);
358
- rect.setAttribute('height', bbox.height + 2 * padding);
359
- }
360
- }
244
+ const transform = `translate(${translateX - (width / 2.0)}, ${translateY - (height / 2.0)})`;
245
+ group.setAttribute('transform', transform);
361
246
  });
362
247
  }
363
- }, [props.data]);
248
+ }, [props.data, props.layout, props.orientation, props.linkType]);
364
249
 
365
250
  return (
366
251
  <div
@@ -389,8 +274,8 @@ const TreeGraph = (props: Props) => {
389
274
  >
390
275
  { (tree) => (
391
276
  <Group
392
- top={root.origin.y}
393
277
  left={root.origin.x}
278
+ top={root.origin.y}
394
279
  >
395
280
  { tree.links().map((link, i) => (
396
281
  <LinkComponent
@@ -431,13 +316,5 @@ TreeGraph.defaultProps = {
431
316
  textColor: '#FFFFFF'
432
317
  };
433
318
 
434
- type TreeGraphType = ComponentType<any> & {
435
- Circle: typeof Circle,
436
- Rectangle: typeof Rectangle
437
- };
438
-
439
- const TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));
440
- TreeGraphComponent.Circle = Circle;
441
- TreeGraphComponent.Rectangle = Rectangle;
442
-
319
+ const TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));
443
320
  export default TreeGraphComponent;
@@ -71,19 +71,6 @@ const Orientation = {
71
71
  vertical: 'vertical'
72
72
  };
73
73
 
74
- const Circle: ComponentType<any> = (props: any) => (
75
- <circle
76
- r={props.radius}
77
- {...props}
78
- />
79
- );
80
-
81
- const Rectangle: ComponentType<any> = (props: any) => (
82
- <rect
83
- {...props}
84
- />
85
- );
86
-
87
74
  const TreeGraph = (props: Props) => {
88
75
  const ref = useRef();
89
76
 
@@ -210,59 +197,14 @@ const TreeGraph = (props: Props) => {
210
197
  };
211
198
  }, [getMaxDepth, innerHeight, innerWidth, props.data, props.layout, props.orientation]);
212
199
 
213
- /**
214
- * Renders the passed node. If provided, only the "renderNode" prop is called.
215
- *
216
- * @type {(function(*): (*))|*}
217
- */
218
- const renderNode = useCallback((node) => {
219
- if (props.renderNode) {
220
- return props.renderNode(node.data);
221
- }
222
-
223
- if (node.depth === 0) {
224
- return (
225
- <Circle
226
- fill='#FF4A4A'
227
- onClick={props.onClick && props.onClick.bind(this, node.data)}
228
- />
229
- );
230
- }
231
-
232
- return (
233
- <Rectangle
234
- fill='#272b4d'
235
- stroke={node.data.children ? '#03c0dc' : '#26deb0'}
236
- strokeWidth={1}
237
- strokeDasharray={node.data.children ? '0' : '2,2'}
238
- strokeOpacity={node.data.children ? 1 : 0.6}
239
- rx={node.data.children ? 0 : 10}
240
- onClick={props.onClick && props.onClick.bind(this, node.data)}
241
- />
242
- );
243
- }, [props.onClick, props.renderNode]);
244
-
245
- /**
246
- * Renders the text for the passed node.
247
- *
248
- * @type {(function(*): (*))|*}
249
- */
250
- const renderText = useCallback((node) => {
251
- if (props.renderText) {
252
- return props.renderText(node.data);
253
- }
254
-
255
- return (
256
- <text
257
- dy='0.33em'
258
- fontSize={props.fontSize}
259
- textAnchor='middle'
260
- fill={props.textColor}
261
- >
262
- { node.data.name }
263
- </text>
264
- );
265
- }, [props.renderText]);
200
+ const renderNode = useCallback((node) => (
201
+ <foreignObject
202
+ width='100%'
203
+ height='100%'
204
+ >
205
+ { props.renderNode(node.data) }
206
+ </foreignObject>
207
+ ), [props.renderNode]);
266
208
 
267
209
  /**
268
210
  * Renders the group element for the passed node.
@@ -279,10 +221,9 @@ const TreeGraph = (props: Props) => {
279
221
  key={key}
280
222
  >
281
223
  { renderNode(node) }
282
- { renderText(node) }
283
224
  </Group>
284
225
  );
285
- }, [renderNode, renderText, props.layout, props.orientation]);
226
+ }, [renderNode, props.layout, props.orientation, props.linkType]);
286
227
 
287
228
  /**
288
229
  * Resizes the "circle" and "rect" elements based on the text contained in the group. This effect will also
@@ -291,76 +232,20 @@ const TreeGraph = (props: Props) => {
291
232
  useEffect(() => {
292
233
  const { current } = ref;
293
234
  if (current) {
294
- const padding = 15;
295
235
  const groups = current.getElementsByTagName('g');
296
236
  _.each(groups, (group) => {
297
- const circle = _.first(group.getElementsByTagName('circle'));
298
- const rect = _.first(group.getElementsByTagName('rect'));
299
-
300
- const text = _.first(group.getElementsByTagName('text'));
301
- const { height } = text.getBBox();
302
-
303
- if (!text.getElementsByTagName('tspan').length) {
304
- const words = text.innerHTML.split(/\s+/);
305
-
306
- const lines = [];
307
- let lineIndex = 0;
308
-
309
- for (let i = 0; i < words.length; i += 1) {
310
- // Initialize the line array for the current line
311
- if (!lines[lineIndex]) {
312
- lines[lineIndex] = [];
313
- }
314
-
315
- // Add the current word to the current line
316
- lines[lineIndex].push(words[i]);
317
-
318
- // Look ahead to the next word and increment the line index if necessary
319
- if (i < words.length - 1) {
320
- const testElement = text.cloneNode();
321
- testElement.innerHTML = [...lines[lineIndex], words[i + 1]].join(' ');
322
- group.append(testElement);
237
+ const object = _.first(group.getElementsByTagName('foreignObject'));
238
+ const { offsetWidth: width, offsetHeight: height } = object.firstChild;
323
239
 
324
- if (testElement.getBBox().width > props.nodeWidth) {
325
- lineIndex += 1;
326
- }
240
+ const style = window.getComputedStyle(group);
241
+ const matrix = new DOMMatrixReadOnly(style.transform);
242
+ const { m41: translateX, m42: translateY } = matrix;
327
243
 
328
- testElement.remove();
329
- }
330
- }
331
-
332
- // Append the lines to the text element
333
- _.each(lines, (line, index) => {
334
- const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
335
- tspan.setAttribute('x', '0');
336
- if (index > 0) {
337
- tspan.setAttribute('dy', `${height}px`);
338
- }
339
- tspan.appendChild(document.createTextNode(line.join(' ')));
340
-
341
- if (index === 0) {
342
- text.replaceChildren(tspan);
343
- } else {
344
- text.appendChild(tspan);
345
- }
346
- });
347
-
348
- // Set the shape attributes based on the text size
349
- const bbox = text.getBBox();
350
- if (circle && text) {
351
- circle.setAttribute('x', bbox.x - padding);
352
- circle.setAttribute('y', bbox.y - padding);
353
- circle.setAttribute('r', (bbox.width / 2) + padding);
354
- } else if (rect && text) {
355
- rect.setAttribute('x', bbox.x - padding);
356
- rect.setAttribute('y', bbox.y - padding);
357
- rect.setAttribute('width', bbox.width + 2 * padding);
358
- rect.setAttribute('height', bbox.height + 2 * padding);
359
- }
360
- }
244
+ const transform = `translate(${translateX - (width / 2.0)}, ${translateY - (height / 2.0)})`;
245
+ group.setAttribute('transform', transform);
361
246
  });
362
247
  }
363
- }, [props.data]);
248
+ }, [props.data, props.layout, props.orientation, props.linkType]);
364
249
 
365
250
  return (
366
251
  <div
@@ -389,8 +274,8 @@ const TreeGraph = (props: Props) => {
389
274
  >
390
275
  { (tree) => (
391
276
  <Group
392
- top={root.origin.y}
393
277
  left={root.origin.x}
278
+ top={root.origin.y}
394
279
  >
395
280
  { tree.links().map((link, i) => (
396
281
  <LinkComponent
@@ -431,13 +316,5 @@ TreeGraph.defaultProps = {
431
316
  textColor: '#FFFFFF'
432
317
  };
433
318
 
434
- type TreeGraphType = ComponentType<any> & {
435
- Circle: typeof Circle,
436
- Rectangle: typeof Rectangle
437
- };
438
-
439
- const TreeGraphComponent: TreeGraphType = withParentSize(withZoom(TreeGraph));
440
- TreeGraphComponent.Circle = Circle;
441
- TreeGraphComponent.Rectangle = Rectangle;
442
-
319
+ const TreeGraphComponent: ComponentType<any> = withParentSize(withZoom(TreeGraph));
443
320
  export default TreeGraphComponent;