UNPKG

@gugotech/react-d3-tree

Version:

React component to create interactive D3 tree hierarchies

1 lines 35 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("d3"),require("uuid"),require("react-lifecycles-compat"),require("clone"),require("deep-equal"),require("react-transition-group")):"function"==typeof define&&define.amd?define("react-d3-tree",["react","prop-types","d3","uuid","react-lifecycles-compat","clone","deep-equal","react-transition-group"],t):"object"==typeof exports?exports["react-d3-tree"]=t(require("react"),require("prop-types"),require("d3"),require("uuid"),require("react-lifecycles-compat"),require("clone"),require("deep-equal"),require("react-transition-group")):e["react-d3-tree"]=t(e.react,e["prop-types"],e.d3,e.uuid,e["react-lifecycles-compat"],e.clone,e["deep-equal"],e["react-transition-group"])}(this,function(e,t,n,r,o,a,i,s){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var a=r(o);return[n].concat(o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"})).concat([a]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=n(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var a=this[o][0];"number"==typeof a&&(r[a]=!0)}for(o=0;o<e.length;o++){var i=e[o];"number"==typeof i[0]&&r[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),t.push(i))}},t}},function(e,t,n){function r(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=y[r.id];if(o){o.refs++;for(var a=0;a<o.parts.length;a++)o.parts[a](r.parts[a]);for(;a<r.parts.length;a++)o.parts.push(f(r.parts[a],t))}else{for(var i=[],a=0;a<r.parts.length;a++)i.push(f(r.parts[a],t));y[r.id]={id:r.id,refs:1,parts:i}}}}function o(e,t){for(var n=[],r={},o=0;o<e.length;o++){var a=e[o],i=t.base?a[0]+t.base:a[0],s=a[1],u=a[2],l=a[3],c={css:s,media:u,sourceMap:l};r[i]?r[i].parts.push(c):n.push(r[i]={id:i,parts:[c]})}return n}function a(e,t){var n=m(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=k[k.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),k.push(t);else if("bottom"===e.insertAt)n.appendChild(t);else{if("object"!=typeof e.insertAt||!e.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var o=m(e.insertAt.before,n);n.insertBefore(t,o)}}function i(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=k.indexOf(e);t>=0&&k.splice(t,1)}function s(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=c();n&&(e.attrs.nonce=n)}return l(t,e.attrs),a(e,t),t}function u(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",l(t,e.attrs),a(e,t),t}function l(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function c(){return n.nc}function f(e,t){var n,r,o,a;if(t.transform&&e.css){if(!(a=t.transform(e.css)))return function(){};e.css=a}if(t.singleton){var l=O++;n=g||(g=s(t)),r=d.bind(null,n,l,!1),o=d.bind(null,n,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=u(t),r=h.bind(null,n,t),o=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),r=p.bind(null,n),o=function(){i(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}function d(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=j(t,o);else{var a=document.createTextNode(o),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}function p(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function h(e,t,n){var r=n.css,o=n.sourceMap,a=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||a)&&(r=x(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([r],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(i),s&&URL.revokeObjectURL(s)}var y={},b=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),v=function(e,t){return t?t.querySelector(e):document.querySelector(e)},m=function(e){var t={};return function(e,n){if("function"==typeof e)return e();if(void 0===t[e]){var r=v.call(this,e,n);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[e]=r}return t[e]}}(),g=null,O=0,k=[],x=n(18);e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},t.attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=b()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=o(e,t);return r(n,t),function(e){for(var a=[],i=0;i<n.length;i++){var s=n[i],u=y[s.id];u.refs--,a.push(u)}if(e){r(o(e,t),t)}for(var i=0;i<a.length;i++){var u=a[i];if(0===u.refs){for(var l=0;l<u.parts.length;l++)u.parts[l]();delete y[u.id]}}}};var j=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.treeUtil=t.Tree=void 0;var r=n(7),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(24),i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(a);t.Tree=o.default,t.treeUtil=i,t.default=o.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||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},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),c=r(l),f=n(8),d=n(1),p=r(d),h=n(2),y=n(9),b=r(y),v=n(10),m=r(v),g=n(3),O=r(g),k=n(11),x=r(k),j=n(13),_=r(j),w=n(19),C=r(w);n(22);var N=function(e){function t(){var e,n,r,i;o(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),r.state={dataRef:r.props.data,data:t.assignInternalProperties((0,b.default)(r.props.data)),d3:t.calculateD3Geometry(r.props),rd3tSvgClassName:"_"+O.default.v4(),rd3tGClassName:"_"+O.default.v4(),isInitialRenderForDataset:!0},r.internalState={targetNode:null,isTransitioning:!1},r.handleNodeToggle=function(e,n){var o=(0,b.default)(r.state.data),a=r.findNodesById(e,o,[]),i=a[0];n.persist(),r.props.collapsible&&!r.state.isTransitioning?(i._collapsed?(t.expandNode(i),r.props.shouldCollapseNeighborNodes&&r.collapseNeighborNodes(i,o)):t.collapseNode(i),r.setState({data:o,isTransitioning:!0},function(){return r.handleOnClickCb(i,n)}),setTimeout(function(){return r.setState({isTransitioning:!1})},r.props.transitionDuration+10),r.internalState.targetNode=i):r.handleOnClickCb(i,n)},r.handleOnClickCb=function(e,t){var n=r.props.onClick;n&&"function"==typeof n&&n((0,b.default)(e),t)},r.handleOnLinkClickCb=function(e,t,n){var o=r.props.onLinkClick;o&&"function"==typeof o&&(n.persist(),o((0,b.default)(e),(0,b.default)(t),n))},r.handleOnMouseOverCb=function(e,t){var n=r.props.onMouseOver;if(n&&"function"==typeof n){var o=(0,b.default)(r.state.data),a=r.findNodesById(e,o,[]),i=a[0];t.persist(),n((0,b.default)(i),t)}},r.handleOnLinkMouseOverCb=function(e,t,n){var o=r.props.onLinkMouseOver;o&&"function"==typeof o&&(n.persist(),o((0,b.default)(e),(0,b.default)(t),n))},r.handleOnMouseOutCb=function(e,t){var n=r.props.onMouseOut;if(n&&"function"==typeof n){var o=(0,b.default)(r.state.data),a=r.findNodesById(e,o,[]),i=a[0];t.persist(),n((0,b.default)(i),t)}},r.handleOnLinkMouseOutCb=function(e,t,n){var o=r.props.onLinkMouseOut;o&&"function"==typeof o&&(n.persist(),o((0,b.default)(e),(0,b.default)(t),n))},i=n,a(r,i)}return i(t,e),u(t,[{key:"componentDidMount",value:function(){this.bindZoomListener(this.props),this.setState({isInitialRenderForDataset:!1})}},{key:"componentDidUpdate",value:function(e){this.props.data!==e.data&&this.setState({isInitialRenderForDataset:!1}),(0,m.default)(this.props.translate,e.translate)&&(0,m.default)(this.props.scaleExtent,e.scaleExtent)&&this.props.zoom===e.zoom&&this.props.transitionDuration===e.transitionDuration||this.bindZoomListener(this.props),"function"==typeof this.props.onUpdate&&this.props.onUpdate({node:this.internalState.targetNode?(0,b.default)(this.internalState.targetNode):null,zoom:this.state.d3.scale,translate:this.state.d3.translate}),this.internalState.targetNode=null}},{key:"setInitialTreeDepth",value:function(e,t){e.forEach(function(e){e._collapsed=e.depth>=t})}},{key:"bindZoomListener",value:function(e){var t=this,n=e.zoomable,r=e.scaleExtent,o=e.translate,a=e.zoom,i=e.onUpdate,s=this.state,u=s.rd3tSvgClassName,l=s.rd3tGClassName,c=(0,h.select)("."+u),f=(0,h.select)("."+l);n&&c.call(h.behavior.zoom().scaleExtent([r.min,r.max]).on("zoom",function(){f.attr("transform","translate("+h.event.translate+") scale("+h.event.scale+")"),"function"==typeof i&&(i({node:null,zoom:h.event.scale,translate:{x:h.event.translate[0],y:h.event.translate[1]}}),t.state.d3.scale=h.event.scale,t.state.d3.translate={x:h.event.translate[0],y:h.event.translate[1]})}).scale(a).translate([o.x,o.y]))}},{key:"findNodesById",value:function(e,t,n){var r=this;return n.length>0?n:(n=n.concat(t.filter(function(t){return t.id===e})),t.forEach(function(t){t._children&&t._children.length>0&&(n=r.findNodesById(e,t._children,n))}),n)}},{key:"findNodesAtDepth",value:function(e,t,n){var r=this;return n=n.concat(t.filter(function(t){return t.depth===e})),t.forEach(function(t){t._children&&t._children.length>0&&(n=r.findNodesAtDepth(e,t._children,n))}),n}},{key:"collapseNeighborNodes",value:function(e,n){this.findNodesAtDepth(e.depth,n,[]).filter(function(t){return t.id!==e.id}).forEach(function(e){return t.collapseNode(e)})}},{key:"generateTree",value:function(){var e=this.props,t=e.initialDepth,n=e.useCollapseData,r=e.depthFactor,o=e.separation,a=e.nodeSize,i=e.orientation,s=this.state.isInitialRenderForDataset,u=h.layout.tree().nodeSize("horizontal"===i?[a.y,a.x]:[a.x,a.y]).separation(function(e,t){return e.parent.id===t.parent.id?o.siblings:o.nonSiblings}).children(function(e){return e._collapsed?null:e._children}),l=this.state.data[0],c=u.nodes(l);return!1===n&&void 0!==t&&s&&(this.setInitialTreeDepth(c,t),c=u.nodes(l)),r&&c.forEach(function(e){e.y=e.depth*r}),{nodes:c,links:u.links(c)}}},{key:"render",value:function(){var e=this,t=this.generateTree(),n=t.nodes,r=t.links,o=this.state,a=o.rd3tSvgClassName,i=o.rd3tGClassName,u=this.props,l=u.svgClassName,f=u.nodeSvgShape,d=u.nodeLabelComponent,p=u.orientation,h=u.pathFunc,y=u.pathClassFunc,b=u.transitionDuration,v=u.zoomable,m=u.textLayout,g=u.nodeSize,k=u.depthFactor,j=u.initialDepth,w=u.separation,N=u.circleRadius,E=u.allowForeignObjects,M=u.styles,S=this.state.d3,D=S.translate,P=S.scale,R=s({},g,w,{depthFactor:k,initialDepth:j});return c.default.createElement("div",{className:"rd3t-tree-container "+(v?"rd3t-grabbable":void 0)},c.default.createElement("svg",{className:[a,l].join(" "),width:"100%",height:"100%"},c.default.createElement(x.default,{transitionDuration:b,component:"g",className:i,transform:"translate("+D.x+","+D.y+") scale("+P+")"},r.map(function(t){return c.default.createElement(C.default,{key:O.default.v4(),orientation:p,pathFunc:h,pathClassFunc:y,linkData:t,onClick:e.handleOnLinkClickCb,onMouseOver:e.handleOnLinkMouseOverCb,onMouseOut:e.handleOnLinkMouseOutCb,transitionDuration:b,styles:M.links})}),n.map(function(t){return c.default.createElement(_.default,{key:t.id,nodeSvgShape:s({},f,t.nodeSvgShape),disableNodeClickEvent:e.props.disableNodeClickEvent,passEventPropsToNode:e.props.passEventPropsToNode,nodeLabelComponent:d,nodeSize:g,orientation:p,transitionDuration:b,nodeData:t,name:t.name,attributes:t.attributes,onClick:e.handleNodeToggle,onMouseOver:e.handleOnMouseOverCb,onMouseOut:e.handleOnMouseOutCb,textLayout:t.textLayout||m,circleRadius:N,subscriptions:R,allowForeignObjects:E,styles:M.nodes})}))))}}],[{key:"getDerivedStateFromProps",value:function(e,n){var r=null;e.data!==n.dataRef&&(r={dataRef:e.data,data:t.assignInternalProperties((0,b.default)(e.data)),isInitialRenderForDataset:!0});var o=t.calculateD3Geometry(e);return(0,m.default)(o,n.d3)||(r=r||{},r.d3=o),r}},{key:"assignInternalProperties",value:function(e){return(Array.isArray(e)?e:[e]).map(function(e){return e.id=O.default.v4(),void 0===e._collapsed&&(e._collapsed=!1),e.children&&e.children.length>0&&(e.children=t.assignInternalProperties(e.children),e._children=e.children),e})}},{key:"collapseNode",value:function(e){e._collapsed=!0,e._children&&e._children.length>0&&e._children.forEach(function(e){t.collapseNode(e)})}},{key:"expandNode",value:function(e){e._collapsed=!1}},{key:"calculateD3Geometry",value:function(e){var t=void 0;return t=e.zoom>e.scaleExtent.max?e.scaleExtent.max:e.zoom<e.scaleExtent.min?e.scaleExtent.min:e.zoom,{translate:e.translate,scale:t}}}]),t}(c.default.Component);N.defaultProps={svgClassName:void 0,nodeSvgShape:{shape:"circle",shapeProps:{r:10}},disableNodeClickEvent:!1,nodeLabelComponent:null,onClick:void 0,onMouseOver:void 0,onMouseOut:void 0,onLinkClick:void 0,onLinkMouseOver:void 0,onLinkMouseOut:void 0,onUpdate:void 0,orientation:"horizontal",translate:{x:0,y:0},pathClassFunc:void 0,pathFunc:"diagonal",transitionDuration:500,depthFactor:void 0,collapsible:!0,useCollapseData:!1,initialDepth:void 0,zoomable:!0,zoom:1,scaleExtent:{min:.1,max:1},nodeSize:{x:140,y:140},separation:{siblings:1,nonSiblings:2},textLayout:{textAnchor:"start",x:10,y:-10,transform:void 0},allowForeignObjects:!1,passEventPropsToNode:!1,shouldCollapseNeighborNodes:!1,circleRadius:void 0,styles:{}},N.propTypes={disableNodeClickEvent:p.default.bool,passEventPropsToNode:p.default.bool,svgClassName:p.default.string,data:p.default.oneOfType([p.default.array,p.default.object]).isRequired,nodeSvgShape:p.default.shape({shape:p.default.string,shapeProps:p.default.object}),nodeLabelComponent:p.default.object,onClick:p.default.func,onMouseOver:p.default.func,onMouseOut:p.default.func,onLinkClick:p.default.func,onLinkMouseOver:p.default.func,onLinkMouseOut:p.default.func,onUpdate:p.default.func,orientation:p.default.oneOf(["horizontal","vertical"]),translate:p.default.shape({x:p.default.number,y:p.default.number}),pathClassFunc:p.default.func,pathFunc:p.default.oneOfType([p.default.oneOf(["diagonal","elbow","straight","step"]),p.default.func]),transitionDuration:p.default.number,depthFactor:p.default.number,collapsible:p.default.bool,useCollapseData:p.default.bool,initialDepth:p.default.number,zoomable:p.default.bool,zoom:p.default.number,scaleExtent:p.default.shape({min:p.default.number,max:p.default.number}),nodeSize:p.default.shape({x:p.default.number,y:p.default.number}),separation:p.default.shape({siblings:p.default.number,nonSiblings:p.default.number}),textLayout:p.default.object,allowForeignObjects:p.default.bool,shouldCollapseNeighborNodes:p.default.bool,circleRadius:p.default.number,styles:p.default.shape({nodes:p.default.object,links:p.default.object})},(0,f.polyfill)(N),t.default=N,e.exports=t.default},function(e,t){e.exports=o},function(e,t){e.exports=a},function(e,t){e.exports=i},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),a=r(o),i=n(1),s=r(i),u=n(12),l=function(e){return e.transitionDuration>0?a.default.createElement(u.TransitionGroup,{component:e.component,className:e.className,transform:e.transform},e.children):a.default.createElement("g",{className:e.className,transform:e.transform},e.children)};l.defaultProps={component:"g"},l.propTypes={transitionDuration:s.default.number.isRequired,component:s.default.string,className:s.default.string.isRequired,transform:s.default.string.isRequired,children:s.default.array.isRequired},t.default=l,e.exports=t.default},function(e,t){e.exports=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=Object.assign||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},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),f=r(c),d=n(1),p=r(d),h=n(2),y=n(14),b=r(y),v=n(15),m=r(v);n(16);var g=function(e){function t(){var e,n,r,i;o(this,t);for(var s=arguments.length,l=Array(s),c=0;c<s;c++)l[c]=arguments[c];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),r.state={transform:r.setTransform(r.props.nodeData,r.props.orientation,!0),initialStyle:{opacity:0}},r.shouldNodeTransform=function(e,t){return t.subscriptions!==e.subscriptions||t.nodeData.x!==e.nodeData.x||t.nodeData.y!==e.nodeData.y||t.orientation!==e.orientation},r.renderNodeElement=function(e){var t=r.props,n=t.circleRadius,o=t.nodeSvgShape,a=t.passEventPropsToNode;return n?f.default.createElement("circle",{r:n,style:e.circle}):"none"===o.shape?null:f.default.createElement(o.shape,u({},e.circle,o.shapeProps,a?{toggleExpand:function(e){return r.props.onClick(r.props.nodeData.id,e)}}:{}))},r.handleOnClick=function(e){r.props.disableNodeClickEvent||r.props.onClick(r.props.nodeData.id,e)},r.handleOnMouseOver=function(e){r.props.onMouseOver(r.props.nodeData.id,e)},r.handleOnMouseOut=function(e){r.props.onMouseOut(r.props.nodeData.id,e)},i=n,a(r,i)}return i(t,e),l(t,[{key:"componentDidMount",value:function(){this.commitTransform()}},{key:"componentDidUpdate",value:function(){this.commitTransform()}},{key:"shouldComponentUpdate",value:function(e){return this.shouldNodeTransform(this.props,e)}},{key:"setTransform",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.x,o=e.y,a=e.parent;if(n){var i="object"===(void 0===a?"undefined":s(a)),u=i?a.x:0,l=i?a.y:0;return"horizontal"===t?"translate("+l+","+u+")":"translate("+u+","+l+")"}return"horizontal"===t?"translate("+o+","+r+")":"translate("+r+","+o+")"}},{key:"applyTransform",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){};0===t?((0,h.select)(this.node).attr("transform",e).style("opacity",n),r()):(0,h.select)(this.node).transition().duration(t).attr("transform",e).style("opacity",n).each("end",r)}},{key:"commitTransform",value:function(){var e=this.props,t=e.nodeData,n=e.orientation,r=e.transitionDuration,o=this.setTransform(t,n);this.applyTransform(o,r)}},{key:"componentWillLeave",value:function(e){var t=this.props,n=t.nodeData,r=t.orientation,o=t.transitionDuration,a=this.setTransform(n,r,!0);this.applyTransform(a,o,0,e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.nodeData,r=t.nodeSize,o=t.nodeLabelComponent,a=t.allowForeignObjects,i=t.styles,s=n._children?u({},i.node):u({},i.leafNode);return f.default.createElement("g",{id:n.id,ref:function(t){e.node=t},style:this.state.initialStyle,className:n._children?"nodeBase":"leafNodeBase",transform:this.state.transform,onClick:this.handleOnClick,onMouseOver:this.handleOnMouseOver,onMouseOut:this.handleOnMouseOut},this.renderNodeElement(s),a&&o?f.default.createElement(m.default,u({nodeData:n,nodeSize:r},o)):f.default.createElement(b.default,u({},this.props,{nodeStyle:s})))}}]),t}(f.default.Component);t.default=g,g.defaultProps={nodeLabelComponent:null,name:"",attributes:void 0,circleRadius:void 0,disableNodeClickEvent:!1,passEventPropsToNode:!1,styles:{node:{circle:{},name:{},attributes:{}},leafNode:{circle:{},name:{},attributes:{}}}},g.propTypes={nodeData:p.default.object.isRequired,nodeSvgShape:p.default.object.isRequired,nodeLabelComponent:p.default.object,nodeSize:p.default.object.isRequired,orientation:p.default.oneOf(["horizontal","vertical"]).isRequired,transitionDuration:p.default.number.isRequired,onClick:p.default.func.isRequired,onMouseOver:p.default.func.isRequired,onMouseOut:p.default.func.isRequired,name:p.default.string,attributes:p.default.object,textLayout:p.default.object.isRequired,subscriptions:p.default.object.isRequired,allowForeignObjects:p.default.bool.isRequired,circleRadius:p.default.number,styles:p.default.object,disableNodeClickEvent:p.default.bool,passEventPropsToNode:p.default.bool},e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),l=r(u),c=n(3),f=r(c),d=n(1),p=r(d),h=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),s(t,[{key:"render",value:function(){var e=this.props,t=e.name,n=e.nodeStyle,r=e.textLayout,o=e.attributes;return l.default.createElement("g",null,l.default.createElement("text",{className:"nodeNameBase",style:n.name,textAnchor:r.textAnchor,x:r.x,y:r.y,transform:r.transform,dy:".35em"},t),l.default.createElement("text",{className:"nodeAttributesBase",y:r.y+10,textAnchor:r.textAnchor,transform:r.transform,style:n.attributes},o&&Object.keys(o).map(function(e){return l.default.createElement("tspan",{x:r.x,dy:"1.2em",key:f.default.v4()},e,": ",o[e])})))}}]),t}(l.default.PureComponent);t.default=h,h.defaultProps={attributes:void 0},h.propTypes={name:p.default.string.isRequired,attributes:p.default.object,textLayout:p.default.object.isRequired,nodeStyle:p.default.object.isRequired},e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.BASE_MARGIN=void 0;var s=Object.assign||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},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),c=r(l),f=n(1),d=r(f),p=t.BASE_MARGIN=24,h=function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),u(t,[{key:"render",value:function(){var e=this.props,t=e.nodeData,n=e.nodeSize,r=e.render,o=e.foreignObjectWrapper;return c.default.createElement("foreignObject",s({width:n.x-p,height:n.y-p},o),c.default.cloneElement(r,{nodeData:t}))}}]),t}(c.default.PureComponent);t.default=h,h.defaultProps={foreignObjectWrapper:{}},h.propTypes={render:d.default.oneOfType([d.default.element,d.default.node]).isRequired,nodeData:d.default.object.isRequired,nodeSize:d.default.shape({x:d.default.number,y:d.default.number}).isRequired,foreignObjectWrapper:d.default.object}},function(e,t,n){var r=n(17);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};o.transform=void 0,o.insertInto=void 0;n(5)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(4)(void 0),t.push([e.i,".nodeBase {\n cursor: pointer;\n fill: #777;\n stroke: #000;\n stroke-width: 2;\n}\n\n.leafNodeBase {\n cursor: pointer;\n fill: transparent;\n stroke: #000;\n stroke-width: 2;\n}\n\n.nodeNameBase {\n fill: #000;\n stroke: #000;\n stroke-width: 1;\n}\n\n.nodeAttributesBase {\n fill: #777;\n stroke: #777;\n stroke-width: 1;\n font-size: smaller;\n}\n",""])},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,r=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var o=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});if(/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(o))return e;var a;return a=0===o.indexOf("//")?o:0===o.indexOf("/")?n+o:r+o.replace(/^\.\//,""),"url("+JSON.stringify(a)+")"})}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=Object.assign||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},u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),c=r(l),f=n(1),d=r(f),p=n(2);n(20);var h=function(e){function t(){var e,n,r,i;o(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),r.state={initialStyle:{opacity:0}},r.handleOnClick=function(e){r.props.onClick(r.props.linkData.source,r.props.linkData.target,e)},r.handleOnMouseOver=function(e){r.props.onMouseOver(r.props.linkData.source,r.props.linkData.target,e)},r.handleOnMouseOut=function(e){r.props.onMouseOut(r.props.linkData.source,r.props.linkData.target,e)},i=n,a(r,i)}return i(t,e),u(t,[{key:"componentDidMount",value:function(){this.applyOpacity(1,this.props.transitionDuration)}},{key:"componentWillLeave",value:function(e){this.applyOpacity(0,this.props.transitionDuration,e)}},{key:"applyOpacity",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};0===t?((0,p.select)(this.link).style("opacity",e),n()):(0,p.select)(this.link).transition().duration(t).style("opacity",e).each("end",n)}},{key:"drawStepPath",value:function(e,t){var n=e.source,r=e.target,o=r.y-n.y;return"horizontal"===t?"M"+n.y+","+n.x+" H"+(n.y+o/2)+" V"+r.x+" H"+r.y:"M"+n.x+","+n.y+" V"+(n.y+o/2)+" H"+r.x+" V"+r.y}},{key:"drawDiagonalPath",value:function(e,t){return p.svg.diagonal().projection(function(e){return"horizontal"===t?[e.y,e.x]:[e.x,e.y]})(e)}},{key:"drawStraightPath",value:function(e,t){var n=p.svg.line().interpolate("basis").x(function(e){return e.x}).y(function(e){return e.y}),r=[{x:e.source.x,y:e.source.y},{x:e.target.x,y:e.target.y}];return"horizontal"===t&&(r=[{x:e.source.y,y:e.source.x},{x:e.target.y,y:e.target.x}]),n(r)}},{key:"drawElbowPath",value:function(e,t){return"horizontal"===t?"M"+e.source.y+","+e.source.x+"V"+e.target.x+"H"+e.target.y:"M"+e.source.x+","+e.source.y+"V"+e.target.y+"H"+e.target.x}},{key:"drawPath",value:function(){var e=this.props,t=e.linkData,n=e.orientation,r=e.pathFunc;return"function"==typeof r?r(t,n):"elbow"===r?this.drawElbowPath(t,n):"straight"===r?this.drawStraightPath(t,n):"step"===r?this.drawStepPath(t,n):this.drawDiagonalPath(t,n)}},{key:"getClassNames",value:function(){var e=this.props,t=e.linkData,n=e.orientation,r=e.pathClassFunc,o=["linkBase"];return"function"==typeof r&&o.push(r(t,n)),o.join(" ")}},{key:"render",value:function(){var e=this,t=this.props.styles;return c.default.createElement("path",{ref:function(t){e.link=t},style:s({},this.state.initialStyle,t),className:this.getClassNames(),d:this.drawPath(),onClick:this.handleOnClick,onMouseOver:this.handleOnMouseOver,onMouseOut:this.handleOnMouseOut,"data-source-id":this.props.linkData.source.id,"data-target-id":this.props.linkData.target.id})}}]),t}(c.default.PureComponent);t.default=h,h.defaultProps={styles:{},pathClassFunc:void 0},h.propTypes={linkData:d.default.object.isRequired,orientation:d.default.oneOf(["horizontal","vertical"]).isRequired,pathClassFunc:d.default.func,pathFunc:d.default.oneOfType([d.default.oneOf(["diagonal","elbow","straight","step"]),d.default.func]).isRequired,transitionDuration:d.default.number.isRequired,onClick:d.default.func.isRequired,onMouseOver:d.default.func.isRequired,onMouseOut:d.default.func.isRequired,styles:d.default.object},e.exports=t.default},function(e,t,n){var r=n(21);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};o.transform=void 0,o.insertInto=void 0;n(5)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(4)(void 0),t.push([e.i,".linkBase {\n fill: none;\n stroke: #000;\n}",""])},function(e,t,n){var r=n(23);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};o.transform=void 0,o.insertInto=void 0;n(5)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){t=e.exports=n(4)(void 0),t.push([e.i,".rd3t-tree-container {\n width: 100%;\n height: 100%;\n}\n\n.rd3t-grabbable {\n cursor: move; /* fallback if grab cursor is unsupported */\n cursor: grab;\n cursor: -moz-grab;\n cursor: -webkit-grab;\n}\n.rd3t-grabbable:active {\n cursor: grabbing;\n cursor: -moz-grabbing;\n cursor: -webkit-grabbing;\n}\n",""])},function(e,t,n){"use strict";function r(e,t){var n={},r=function(e){return n[e]||(n[e]={name:e}),n[e]},o=function(e,t){return n[e]||(n[e]={name:e,attributes:t}),n[e]};return e.forEach(function(e){if(t){var n={};t.forEach(function(t){n[t]=e[t]}),e.attributes=n}e.source=r(e.parent),e.target=o(e.child,e.attributes);var a=e.source,i=e.target;a.id=c.default.v4(),i.id=c.default.v4(),i.parent=a.name||null,a._collapsed=i._collapsed=!1,a._children?a._children.push(i):a._children=[i]}),[e.filter(function(e){return!e.source.parent})[0].source]}function o(e,t){return new Promise(function(n,o){try{(0,u.csv)(e,function(e){return n(r(e,t))})}catch(e){o(e)}})}function a(e){return new Promise(function(t,n){try{(0,u.json)(e,function(e){return t([e])})}catch(e){n(e)}})}function i(e,t){return new Promise(function(n,o){try{(0,u.json)(e,function(e){return n(r(e,t))})}catch(e){o(e)}})}function s(e){return r(e)}Object.defineProperty(t,"__esModule",{value:!0});var u=n(2),l=n(3),c=function(e){return e&&e.__esModule?e:{default:e}}(l);t.default={parseCSV:o,parseJSON:a,parseFlatJSON:i,generateHierarchy:s},e.exports=t.default}])});