UNPKG

react-hierarchy-tree-graph

Version:

React component to create interactive D3 tree hierarchies

1 lines 33.5 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("prop-types"),require("d3"),require("uuid"),require("clone"),require("deep-equal"),require("react-transition-group")):"function"==typeof define&&define.amd?define("react-d3-tree",["react","prop-types","d3","uuid","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("clone"),require("deep-equal"),require("react-transition-group")):e["react-d3-tree"]=t(e.react,e["prop-types"],e.d3,e.uuid,e.clone,e["deep-equal"],e["react-transition-group"])}(this,function(e,t,n,r,o,a,i){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=x[x.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),x.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=x.indexOf(e);t>=0&&x.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=w(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=_(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,x=[],_=n(17);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 w=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(23),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(1),d=r(f),p=n(2),h=n(8),y=r(h),b=n(9),v=r(b),m=n(3),g=r(m),O=n(10),x=r(O),_=n(12),w=r(_),j=n(18),k=r(j);n(21);var S=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={data:r.assignInternalProperties((0,y.default)(r.props.data)),rd3tSvgClassName:"_"+g.default.v4(),rd3tGClassName:"_"+g.default.v4()},r.internalState={initialRender:!0,targetNode:null,isTransitioning:!1,d3:{scale:r.props.zoom,translate:r.props.translate}},r.handleNodeToggle=function(e,t){var n=(0,y.default)(r.state.data),o=r.findNodesById(e,n,[]),a=o[0];t.persist(),r.props.collapsible&&!r.state.isTransitioning?(a._collapsed?(r.expandNode(a),r.props.shouldCollapseNeighborNodes&&r.collapseNeighborNodes(a,n)):r.collapseNode(a),r.setState({data:n,isTransitioning:!0},function(){return r.handleOnClickCb(a,t)}),setTimeout(function(){return r.setState({isTransitioning:!1})},r.props.transitionDuration+10),r.internalState.targetNode=a):r.handleOnClickCb(a,t)},r.handleOnClickCb=function(e,t){var n=r.props.onClick;n&&"function"==typeof n&&n((0,y.default)(e),t)},r.handleOnMouseOverCb=function(e,t){var n=r.props.onMouseOver;if(n&&"function"==typeof n){var o=(0,y.default)(r.state.data),a=r.findNodesById(e,o,[]),i=a[0];t.persist(),n((0,y.default)(i),t)}},r.handleOnMouseOutCb=function(e,t){var n=r.props.onMouseOut;if(n&&"function"==typeof n){var o=(0,y.default)(r.state.data),a=r.findNodesById(e,o,[]),i=a[0];t.persist(),n((0,y.default)(i),t)}},i=n,a(r,i)}return i(t,e),u(t,[{key:"componentWillMount",value:function(){this.internalState.d3=this.calculateD3Geometry(this.props)}},{key:"componentDidMount",value:function(){this.bindZoomListener(this.props),this.internalState.initialRender=!1}},{key:"componentDidUpdate",value:function(e){e.transitionDuration!==this.props.transitionDuration&&this.bindZoomListener(this.props),"function"==typeof this.props.onUpdate&&(this.props.onUpdate({node:this.internalState.targetNode?(0,y.default)(this.internalState.targetNode):null,zoom:this.internalState.d3.scale,translate:this.internalState.d3.translate}),this.internalState.targetNode=null)}},{key:"componentWillReceiveProps",value:function(e){this.props.data!==e.data&&this.setState({data:this.assignInternalProperties((0,y.default)(e.data))}),this.internalState.d3=this.calculateD3Geometry(e),(0,v.default)(this.props.translate,e.translate)&&(0,v.default)(this.props.scaleExtent,e.scaleExtent)&&this.props.zoom===e.zoom||this.bindZoomListener(e)}},{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,p.select)("."+u),f=(0,p.select)("."+l);n&&c.call(p.behavior.zoom().scaleExtent([r.min,r.max]).on("zoom",function(){f.attr("transform","translate("+p.event.translate+") scale("+p.event.scale+")"),"function"==typeof i&&(i({node:null,zoom:p.event.scale,translate:{x:p.event.translate[0],y:p.event.translate[1]}}),t.internalState.d3.scale=p.event.scale,t.internalState.d3.translate={x:p.event.translate[0],y:p.event.translate[1]})}).scale(a).translate([o.x,o.y]))}},{key:"assignInternalProperties",value:function(e){var t=this;return(Array.isArray(e)?e:[e]).map(function(e){return 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:"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:"collapseNode",value:function(e){var t=this;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:"collapseNeighborNodes",value:function(e,t){var n=this;this.findNodesAtDepth(e.depth,t,[]).filter(function(t){return t.id!==e.id}).forEach(function(e){return n.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=p.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}),u=this.state.data[0],l=s.nodes(u);return!1===n&&void 0!==t&&this.internalState.initialRender&&(this.setInitialTreeDepth(l,t),l=s.nodes(u)),r&&l.forEach(function(e){e.y=e.depth*r}),{nodes:l,links:s.links(l)}}},{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}}},{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.nodeSvgShape,f=u.nodeLabelComponent,d=u.orientation,p=u.pathFunc,h=u.transitionDuration,y=u.zoomable,b=u.textLayout,v=u.nodeSize,m=u.depthFactor,g=u.initialDepth,O=u.separation,_=u.circleRadius,j=u.allowForeignObjects,S=u.styles,E=this.internalState.d3,N=E.translate,P=E.scale,D=s({},v,O,{depthFactor:m,initialDepth:g});return c.default.createElement("div",{className:"rd3t-tree-container "+(y?"rd3t-grabbable":void 0)},c.default.createElement("svg",{className:a,width:"100%",height:"100%"},c.default.createElement(x.default,{transitionDuration:h,component:"g",className:i,transform:"translate("+N.x+","+N.y+") scale("+P+")"},r.map(function(e){return c.default.createElement(k.default,{key:e.id,orientation:d,pathFunc:p,linkData:e,transitionDuration:h,styles:S.links})}),n.map(function(t){return c.default.createElement(w.default,{key:t.id,nodeSvgShape:s({},l,t.nodeSvgShape),nodeLabelComponent:f,nodeSize:v,orientation:d,transitionDuration:h,nodeData:t,name:t.name,attributes:t.attributes,onClick:e.handleNodeToggle,onMouseOver:e.handleOnMouseOverCb,onMouseOut:e.handleOnMouseOutCb,textLayout:b,circleRadius:_,subscriptions:D,allowForeignObjects:j,styles:S.nodes})}))))}}]),t}(c.default.Component);t.default=S,S.defaultProps={nodeSvgShape:{shape:"circle",shapeProps:{r:10}},nodeLabelComponent:null,onClick:void 0,onMouseOver:void 0,onMouseOut:void 0,onUpdate:void 0,orientation:"horizontal",translate:{x:0,y: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,shouldCollapseNeighborNodes:!1,circleRadius:void 0,styles:{}},S.propTypes={data:d.default.oneOfType([d.default.array,d.default.object]).isRequired,nodeSvgShape:d.default.shape({shape:d.default.string,shapeProps:d.default.object}),nodeLabelComponent:d.default.object,onClick:d.default.func,onMouseOver:d.default.func,onMouseOut:d.default.func,onUpdate:d.default.func,orientation:d.default.oneOf(["horizontal","vertical"]),translate:d.default.shape({x:d.default.number,y:d.default.number}),pathFunc:d.default.oneOfType([d.default.oneOf(["diagonal","elbow","straight"]),d.default.func]),transitionDuration:d.default.number,depthFactor:d.default.number,collapsible:d.default.bool,useCollapseData:d.default.bool,initialDepth:d.default.number,zoomable:d.default.bool,zoom:d.default.number,scaleExtent:d.default.shape({min:d.default.number,max:d.default.number}),nodeSize:d.default.shape({x:d.default.number,y:d.default.number}),separation:d.default.shape({siblings:d.default.number,nonSiblings:d.default.number}),textLayout:d.default.object,allowForeignObjects:d.default.bool,shouldCollapseNeighborNodes:d.default.bool,circleRadius:d.default.number,styles:d.default.shape({nodes:d.default.object,links:d.default.object})},e.exports=t.default},function(e,t){e.exports=o},function(e,t){e.exports=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=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(1),f=r(c),d=n(11),p=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={enableTransitions:r.props.transitionDuration>0},i=n,a(r,i)}return i(t,e),s(t,[{key:"componentWillReceiveProps",value:function(e){e.transitionDuration!==this.props.transitionDuration&&this.setState({enableTransitions:e.transitionDuration>0})}},{key:"render",value:function(){return this.state.enableTransitions?l.default.createElement(d.TransitionGroup,{component:this.props.component,className:this.props.className,transform:this.props.transform},this.props.children):l.default.createElement("g",{className:this.props.className,transform:this.props.transform},this.props.children)}}]),t}(l.default.Component);t.default=p,p.defaultProps={component:"g"},p.propTypes={transitionDuration:f.default.number.isRequired,component:f.default.string,className:f.default.string.isRequired,transform:f.default.string.isRequired,children:f.default.array.isRequired},e.exports=t.default},function(e,t){e.exports=i},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),h=n(13),y=r(h),b=n(14),v=r(b);n(15);var m=function(e){function t(){var e,n,r,i;o(this,t);for(var u=arguments.length,l=Array(u),f=0;f<u;f++)l[f]=arguments[f];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;return n?c.default.createElement("circle",{r:n,style:e.circle}):"none"===o.shape?null:c.default.createElement(o.shape,s({},e.circle,o.shapeProps))},r.handleClick=function(e){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),u(t,[{key:"componentDidMount",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:"componentWillUpdate",value:function(e){var t=this.setTransform(e.nodeData,e.orientation);this.applyTransform(t,e.transitionDuration)}},{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=a?a.x:0,s=a?a.y:0;return"horizontal"===t?"translate("+s+","+i+")":"translate("+i+","+s+")"}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,p.select)(this.node).attr("transform",e).style("opacity",n),r()):(0,p.select)(this.node).transition().duration(t).attr("transform",e).style("opacity",n).each("end",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,u=n._children?s({},i.node):s({},i.leafNode);return c.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.handleClick,onMouseOver:this.handleOnMouseOver,onMouseOut:this.handleOnMouseOut},this.renderNodeElement(u),a&&o?c.default.createElement(v.default,s({nodeData:n,nodeSize:r},o)):c.default.createElement(y.default,s({},this.props,{nodeStyle:u})))}}]),t}(c.default.Component);t.default=m,m.defaultProps={nodeLabelComponent:null,attributes:void 0,circleRadius:void 0,styles:{node:{circle:{},name:{},attributes:{}},leafNode:{circle:{},name:{},attributes:{}}}},m.propTypes={nodeData:d.default.object.isRequired,nodeSvgShape:d.default.object.isRequired,nodeLabelComponent:d.default.object,nodeSize:d.default.object.isRequired,orientation:d.default.oneOf(["horizontal","vertical"]).isRequired,transitionDuration:d.default.number.isRequired,onClick:d.default.func.isRequired,onMouseOver:d.default.func.isRequired,onMouseOut:d.default.func.isRequired,name:d.default.string.isRequired,attributes:d.default.object,textLayout:d.default.object.isRequired,subscriptions:d.default.object.isRequired,allowForeignObjects:d.default.bool.isRequired,circleRadius:d.default.number,styles:d.default.object},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(16);"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(19);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}},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:"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):this.drawDiagonalPath(t,n)}},{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:"linkBase",d:this.drawPath()})}}]),t}(c.default.PureComponent);t.default=h,h.defaultProps={styles:{}},h.propTypes={linkData:d.default.object.isRequired,orientation:d.default.oneOf(["horizontal","vertical"]).isRequired,pathFunc:d.default.oneOfType([d.default.oneOf(["diagonal","elbow","straight"]),d.default.func]).isRequired,transitionDuration:d.default.number.isRequired,styles:d.default.object},e.exports=t.default},function(e,t,n){var r=n(20);"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(22);"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}])});