diff --git a/docs/components/Node.md b/docs/components/Node.md index 1bf3d5f5..d1796b99 100644 --- a/docs/components/Node.md +++ b/docs/components/Node.md @@ -12,9 +12,10 @@ type: `object` defaultValue: `undefined` -### `circleRadius` (required) +### `circleRadius` type: `number` +defaultValue: `undefined` ### `name` (required) @@ -27,6 +28,11 @@ type: `string` type: `object` +### `nodeSvgShape` (required) + +type: `object` + + ### `onClick` (required) type: `func` @@ -56,10 +62,14 @@ defaultValue: `{ ### `textAnchor` -type: `string` defaultValue: `'start'` +### `textLayout` (required) + +type: `object` + + ### `transitionDuration` (required) type: `number` diff --git a/docs/components/Tree.md b/docs/components/Tree.md index 54c2b4c1..d017831f 100644 --- a/docs/components/Tree.md +++ b/docs/components/Tree.md @@ -9,7 +9,7 @@ Props ### `circleRadius` type: `number` -defaultValue: `10` +defaultValue: `undefined` ### `collapsible` @@ -41,6 +41,17 @@ type: `shape[object Object]` defaultValue: `{ x: 140, y: 140 }` +### `nodeSvgShape` + +type: `shape[object Object]` +defaultValue: `{ + shape: 'circle', + shapeProps: { + r: 10, + }, +}` + + ### `onClick` type: `func` @@ -77,6 +88,16 @@ type: `shape[object Object]` defaultValue: `{}` +### `textLayout` + +type: `object` +defaultValue: `{ + textAnchor: 'start', + x: 10, + y: -10, +}` + + ### `transitionDuration` type: `number` diff --git a/lib/react-d3-tree.min.js b/lib/react-d3-tree.min.js index 513efb53..e6daac75 100644 --- a/lib/react-d3-tree.min.js +++ b/lib/react-d3-tree.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3"),require("prop-types"),require("react"),require("uuid"),require("clone"),require("deep-equal"),require("react-transition-group")):"function"==typeof define&&define.amd?define("react-d3-tree",["d3","prop-types","react","uuid","clone","deep-equal","react-transition-group"],t):"object"==typeof exports?exports["react-d3-tree"]=t(require("d3"),require("prop-types"),require("react"),require("uuid"),require("clone"),require("deep-equal"),require("react-transition-group")):e["react-d3-tree"]=t(e.d3,e["prop-types"],e.react,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.i=function(e){return e},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=10)}([function(t,n){t.exports=e},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=0&&g.splice(t,1)}function s(e){var t=document.createElement("style");return e.attrs.type="text/css",l(t,e.attrs),a(e,t),t}function u(e){var t=document.createElement("link");return 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(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=m++;n=v||(v=s(t)),r=f.bind(null,n,l,!1),o=f.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=p.bind(null,n,t),o=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),r=d.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 f(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=k(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 d(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 p(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 h={},y=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),b=function(e){var t={};return function(n){return void 0===t[n]&&(t[n]=e.call(this,n)),t[n]}}(function(e){return document.querySelector(e)}),v=null,m=0,g=[],x=n(14);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:{},void 0===t.singleton&&(t.singleton=y()),void 0===t.insertInto&&(t.insertInto="head"),void 0===t.insertAt&&(t.insertAt="bottom");var n=o(e,t);return r(n,t),function(e){for(var a=[],i=0;i=t})}},{key:"bindZoomListener",value:function(e){var t=e.zoomable,n=e.scaleExtent,r=e.translate,o=(0,p.select)(".rd3t-svg"),a=(0,p.select)(".rd3t-g");t&&o.call(p.behavior.zoom().scaleExtent([n.min,n.max]).on("zoom",function(){a.attr("transform","translate("+p.event.translate+") scale("+p.event.scale+")")}).translate([r.x,r.y]))}},{key:"assignInternalProperties",value:function(e){var t=this;return e.map(function(e){return e.id=g.default.v4(),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){return t._children&&t._children.length>0?n=r.findNodesById(e,t._children,n):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:"handleNodeToggle",value:function(e){var t=this,n=(0,y.default)(this.state.data),r=this.findNodesById(e,n,[]),o=r[0];this.props.collapsible?(o._collapsed?this.expandNode(o):this.collapseNode(o),this.setState({data:n},function(){return t.handleOnClickCb(o)})):this.handleOnClickCb(o)}},{key:"handleOnClickCb",value:function(e){var t=this.props.onClick;t&&"function"==typeof t&&t((0,y.default)(e))}},{key:"generateTree",value:function(){var e=this.props,t=e.initialDepth,n=e.depthFactor,r=e.separation,o=e.nodeSize,a=e.orientation,i=p.layout.tree().nodeSize("horizontal"===a?[o.y,o.x]:[o.x,o.y]).separation(function(e,t){return(0,v.default)(e.parent,t.parent)?r.siblings:r.nonSiblings}).children(function(e){return e._collapsed?null:e._children}),s=this.state.data[0],u=i.nodes(s),l=i.links(u);return void 0!==t&&this.state.initialRender&&this.setInitialTreeDepth(u,t),n&&u.forEach(function(e){e.y=e.depth*n}),{nodes:u,links:l}}},{key:"render",value:function(){var e=this,t=this.generateTree(),n=t.nodes,r=t.links,o=this.props,a=o.orientation,i=o.translate,s=o.pathFunc,u=o.transitionDuration,c=o.zoomable,f=o.circleRadius,p=o.styles;return l.default.createElement("div",{className:"rd3t-tree-container "+(c?"rd3t-grabbable":void 0)},l.default.createElement("svg",{className:"rd3t-svg",width:"100%",height:"100%"},l.default.createElement(d.TransitionGroup,{component:"g",className:"rd3t-g",transform:"translate("+i.x+","+i.y+")"},r.map(function(e){return l.default.createElement(_.default,{key:g.default.v4(),orientation:a,pathFunc:s,linkData:e,transitionDuration:u,styles:p.links})}),n.map(function(t){return l.default.createElement(k.default,{key:t.id,orientation:a,transitionDuration:u,textAnchor:"start",nodeData:t,name:t.name,attributes:t.attributes,onClick:e.handleNodeToggle,circleRadius:f,styles:p.nodes})}))))}}]),t}(l.default.Component);t.default=w,w.defaultProps={onClick:void 0,orientation:"horizontal",translate:{x:0,y:0},pathFunc:"diagonal",transitionDuration:500,depthFactor:void 0,collapsible:!0,initialDepth:void 0,zoomable:!0,scaleExtent:{min:.1,max:1},nodeSize:{x:140,y:140},separation:{siblings:1,nonSiblings:2},circleRadius:10,styles:{}},w.propTypes={data:f.default.array.isRequired,onClick:f.default.func,orientation:f.default.oneOf(["horizontal","vertical"]),translate:f.default.shape({x:f.default.number,y:f.default.number}),pathFunc:f.default.oneOf(["diagonal","elbow","straight"]),transitionDuration:f.default.number,depthFactor:f.default.number,collapsible:f.default.bool,initialDepth:f.default.number,zoomable:f.default.bool,scaleExtent:f.default.shape({min:f.default.number,max:f.default.number}),nodeSize:f.default.shape({x:f.default.number,y:f.default.number}),separation:f.default.shape({siblings:f.default.number,nonSiblings:f.default.number}),circleRadius:f.default.number,styles:f.default.shape({nodes:f.default.object,links:f.default.object})},e.exports=t.default},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(0),l=n(5),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},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;t1&&void 0!==arguments[1]?arguments[1]:function(){},n=this.props.transitionDuration;(0,p.select)(this.link).transition().duration(n).style("opacity",e).each("end",t)}},{key:"diagonalPath",value:function(e,t){return p.svg.diagonal().projection(function(e){return"horizontal"===t?[e.y,e.x]:[e.x,e.y]})(e)}},{key:"straightPath",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:"elbowPath",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"elbow"===r?this.elbowPath(t,n):"straight"===r?this.straightPath(t,n):this.diagonalPath(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.oneOf(["diagonal","elbow","straight"]).isRequired,transitionDuration:d.default.number.isRequired,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=Object.assign||function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=this.props.transitionDuration;(0,y.select)(this.node).transition().duration(r).attr("transform",e).style("opacity",t).each("end",n)}},{key:"handleClick",value:function(){this.props.onClick(this.props.nodeData.id)}},{key:"componentWillLeave",value:function(e){var t=this.props.nodeData.parent,n=t?t.x:0,r=t?t.y:0,o=this.setTransformOrientation(n,r);this.applyTransform(o,0,e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.nodeData,r=t.styles,o=n._children?s({},r.node):s({},r.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},c.default.createElement("text",{className:"nodeNameBase",textAnchor:this.props.textAnchor,style:o.name,x:"10",y:"-10",dy:".35em"},this.props.name),c.default.createElement("circle",{r:this.props.circleRadius,style:o.circle}),c.default.createElement("text",{className:"nodeAttributesBase",y:"0",textAnchor:this.props.textAnchor,style:o.attributes},this.props.attributes&&Object.keys(this.props.attributes).map(function(t){return c.default.createElement("tspan",{x:"10",dy:"1.2em",key:h.default.v4()},t,": ",e.props.attributes[t])})))}}]),t}(c.default.Component);t.default=b,b.defaultProps={textAnchor:"start",attributes:void 0,styles:{node:{circle:{},name:{},attributes:{}},leafNode:{circle:{},name:{},attributes:{}}}},b.propTypes={nodeData:d.default.object.isRequired,orientation:d.default.oneOf(["horizontal","vertical"]).isRequired,transitionDuration:d.default.number.isRequired,onClick:d.default.func.isRequired,name:d.default.string.isRequired,attributes:d.default.object,textAnchor:d.default.string,circleRadius:d.default.number.isRequired,styles:d.default.object},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.treeUtil=t.Tree=void 0;var r=n(6),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=n(7),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){t=e.exports=n(1)(void 0),t.push([e.i,".linkBase {\n fill: none;\n stroke: #000;\n}",""])},function(e,t,n){t=e.exports=n(1)(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 stroke: #000;\n stroke-width: 1;\n}\n\n.nodeAttributesBase {\n stroke: #777;\n stroke-width: 1;\n font-size: smaller;\n}\n",""])},function(e,t,n){t=e.exports=n(1)(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){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:\/\/\/)/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){var r=n(11);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=void 0;n(2)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){var r=n(12);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=void 0;n(2)(r,o);r.locals&&(e.exports=r.locals)},function(e,t,n){var r=n(13);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=void 0;n(2)(r,o);r.locals&&(e.exports=r.locals)},function(e,t){e.exports=o},function(e,t){e.exports=a},function(e,t){e.exports=i}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("d3"),require("react"),require("prop-types"),require("uuid"),require("react-transition-group"),require("clone"),require("deep-equal")):"function"==typeof define&&define.amd?define("react-d3-tree",["d3","react","prop-types","uuid","react-transition-group","clone","deep-equal"],t):"object"==typeof exports?exports["react-d3-tree"]=t(require("d3"),require("react"),require("prop-types"),require("uuid"),require("react-transition-group"),require("clone"),require("deep-equal")):e["react-d3-tree"]=t(e.d3,e.react,e["prop-types"],e.uuid,e["react-transition-group"],e.clone,e["deep-equal"])}(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=0&&g.splice(t,1)}function s(e){var t=document.createElement("style");return e.attrs.type="text/css",l(t,e.attrs),a(e,t),t}function u(e){var t=document.createElement("link");return 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(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=m++;n=v||(v=s(t)),r=f.bind(null,n,l,!1),o=f.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=p.bind(null,n,t),o=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=s(t),r=d.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 f(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=k(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 d(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 p(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 h={},y=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),b=function(e){var t={};return function(n){return void 0===t[n]&&(t[n]=e.call(this,n)),t[n]}}(function(e){return document.querySelector(e)}),v=null,m=0,g=[],x=n(14);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:{},void 0===t.singleton&&(t.singleton=y()),void 0===t.insertInto&&(t.insertInto="head"),void 0===t.insertAt&&(t.insertAt="bottom");var n=o(e,t);return r(n,t),function(e){for(var a=[],i=0;i=t})}},{key:"bindZoomListener",value:function(e){var t=e.zoomable,n=e.scaleExtent,r=e.translate,o=(0,p.select)(".rd3t-svg"),a=(0,p.select)(".rd3t-g");t&&o.call(p.behavior.zoom().scaleExtent([n.min,n.max]).on("zoom",function(){a.attr("transform","translate("+p.event.translate+") scale("+p.event.scale+")")}).translate([r.x,r.y]))}},{key:"assignInternalProperties",value:function(e){var t=this;return e.map(function(e){return e.id=g.default.v4(),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){return t._children&&t._children.length>0?n=r.findNodesById(e,t._children,n):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:"handleNodeToggle",value:function(e){var t=this,n=(0,y.default)(this.state.data),r=this.findNodesById(e,n,[]),o=r[0];this.props.collapsible?(o._collapsed?this.expandNode(o):this.collapseNode(o),this.setState({data:n},function(){return t.handleOnClickCb(o)})):this.handleOnClickCb(o)}},{key:"handleOnClickCb",value:function(e){var t=this.props.onClick;t&&"function"==typeof t&&t((0,y.default)(e))}},{key:"generateTree",value:function(){var e=this.props,t=e.initialDepth,n=e.depthFactor,r=e.separation,o=e.nodeSize,a=e.orientation,i=p.layout.tree().nodeSize("horizontal"===a?[o.y,o.x]:[o.x,o.y]).separation(function(e,t){return(0,v.default)(e.parent,t.parent)?r.siblings:r.nonSiblings}).children(function(e){return e._collapsed?null:e._children}),s=this.state.data[0],u=i.nodes(s),l=i.links(u);return void 0!==t&&this.state.initialRender&&this.setInitialTreeDepth(u,t),n&&u.forEach(function(e){e.y=e.depth*n}),{nodes:u,links:l}}},{key:"render",value:function(){var e=this,t=this.generateTree(),n=t.nodes,r=t.links,o=this.props,a=o.nodeSvgShape,i=o.orientation,s=o.translate,u=o.pathFunc,c=o.transitionDuration,f=o.zoomable,p=o.textLayout,h=o.circleRadius,y=o.styles;return l.default.createElement("div",{className:"rd3t-tree-container "+(f?"rd3t-grabbable":void 0)},l.default.createElement("svg",{className:"rd3t-svg",width:"100%",height:"100%"},l.default.createElement(d.TransitionGroup,{component:"g",className:"rd3t-g",transform:"translate("+s.x+","+s.y+")"},r.map(function(e){return l.default.createElement(_.default,{key:g.default.v4(),orientation:i,pathFunc:u,linkData:e,transitionDuration:c,styles:y.links})}),n.map(function(t){return l.default.createElement(k.default,{key:t.id,nodeSvgShape:a,orientation:i,transitionDuration:c,nodeData:t,name:t.name,attributes:t.attributes,onClick:e.handleNodeToggle,textLayout:p,circleRadius:h,styles:y.nodes})}))))}}]),t}(l.default.Component);t.default=w,w.defaultProps={nodeSvgShape:{shape:"circle",shapeProps:{r:10}},onClick:void 0,orientation:"horizontal",translate:{x:0,y:0},pathFunc:"diagonal",transitionDuration:500,depthFactor:void 0,collapsible:!0,initialDepth:void 0,zoomable:!0,scaleExtent:{min:.1,max:1},nodeSize:{x:140,y:140},separation:{siblings:1,nonSiblings:2},textLayout:{textAnchor:"start",x:10,y:-10},circleRadius:void 0,styles:{}},w.propTypes={data:f.default.array.isRequired,nodeSvgShape:f.default.shape({shape:f.default.string,shapeProps:f.default.object}),onClick:f.default.func,orientation:f.default.oneOf(["horizontal","vertical"]),translate:f.default.shape({x:f.default.number,y:f.default.number}),pathFunc:f.default.oneOf(["diagonal","elbow","straight"]),transitionDuration:f.default.number,depthFactor:f.default.number,collapsible:f.default.bool,initialDepth:f.default.number,zoomable:f.default.bool,scaleExtent:f.default.shape({min:f.default.number,max:f.default.number}),nodeSize:f.default.shape({x:f.default.number,y:f.default.number}),separation:f.default.shape({siblings:f.default.number,nonSiblings:f.default.number}),textLayout:f.default.object,circleRadius:f.default.number,styles:f.default.shape({nodes:f.default.object,links:f.default.object})},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}}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;t1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=this.props.transitionDuration;(0,y.select)(this.node).transition().duration(r).attr("transform",e).style("opacity",t).each("end",n)}},{key:"handleClick",value:function(){this.props.onClick(this.props.nodeData.id)}},{key:"componentWillLeave",value:function(e){var t=this.props.nodeData.parent,n=t?t.x:0,r=t?t.y:0,o=this.setTransformOrientation(n,r);this.applyTransform(o,0,e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.nodeData,r=t.nodeSvgShape,o=t.textLayout,a=t.styles,i=n._children?s({},a.node):s({},a.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},this.props.circleRadius?c.default.createElement("circle",{r:this.props.circleRadius,style:i.circle}):c.default.createElement(r.shape,s({},r.shapeProps,i.circle)),c.default.createElement("text",{className:"nodeNameBase",style:i.name,textAnchor:o.textAnchor,x:o.x,y:o.y,dy:".35em"},this.props.name),c.default.createElement("text",{className:"nodeAttributesBase",y:o.y+10,textAnchor:o.textAnchor,style:i.attributes},this.props.attributes&&Object.keys(this.props.attributes).map(function(t){return c.default.createElement("tspan",{x:o.x,dy:"1.2em",key:h.default.v4()},t,": ",e.props.attributes[t])})))}}]),t}(c.default.Component);t.default=b,b.defaultProps={textAnchor:"start",attributes:void 0,circleRadius:void 0,styles:{node:{circle:{},name:{},attributes:{}},leafNode:{circle:{},name:{},attributes:{}}}},b.propTypes={nodeData:d.default.object.isRequired,nodeSvgShape:d.default.object.isRequired,orientation:d.default.oneOf(["horizontal","vertical"]).isRequired,transitionDuration:d.default.number.isRequired,onClick:d.default.func.isRequired,name:d.default.string.isRequired,attributes:d.default.object,textLayout:d.default.object.isRequired,circleRadius:d.default.number,styles:d.default.object},e.exports=t.default},function(e,t,n){var r=n(13);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=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:\/\/\/)/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;t1&&void 0!==arguments[1]?arguments[1]:function(){},n=this.props.transitionDuration;(0,p.select)(this.link).transition().duration(n).style("opacity",e).each("end",t)}},{key:"diagonalPath",value:function(e,t){return p.svg.diagonal().projection(function(e){return"horizontal"===t?[e.y,e.x]:[e.x,e.y]})(e)}},{key:"straightPath",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:"elbowPath",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"elbow"===r?this.elbowPath(t,n):"straight"===r?this.straightPath(t,n):this.diagonalPath(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.oneOf(["diagonal","elbow","straight"]).isRequired,transitionDuration:d.default.number.isRequired,styles:d.default.object},e.exports=t.default},function(e,t,n){var r=n(17);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=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(19);"string"==typeof r&&(r=[[e.i,r,""]]);var o={};o.transform=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(0),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}])}); \ No newline at end of file