diff --git a/lib/react-d3-tree.min.js b/lib/react-d3-tree.min.js index 39895471..074180f9 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("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=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=x(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=O(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){if(void 0===t[n]){var r=e.call(this,n);if(r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[n]=r}return t[n]}}(function(e){return document.querySelector(e)}),v=null,m=0,g=[],O=n(15);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||(t.singleton=y()),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=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 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,t){var n=this,r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];this.props.collapsible&&!this.state.isTransitioning?(a._collapsed?this.expandNode(a):this.collapseNode(a),this.setState({data:r,isTransitioning:!0},function(){return n.handleOnClickCb(a,t)}),setTimeout(function(){return n.setState({isTransitioning:!1})},this.props.transitionDuration+10),this.internalState.targetNode=a):this.handleOnClickCb(a,t)}},{key:"handleOnClickCb",value:function(e,t){var n=this.props.onClick;n&&"function"==typeof n&&n((0,y.default)(e),t)}},{key:"handleOnMouseOverCb",value:function(e,t){var n=this.props.onMouseOver;if(n&&"function"==typeof n){var r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];n((0,y.default)(a),t)}}},{key:"handleOnMouseOutCb",value:function(e,t){var n=this.props.onMouseOut;if(n&&"function"==typeof n){var r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];n((0,y.default)(a),t)}}},{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 e.parent.id===t.parent.id?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.internalState.initialRender&&this.setInitialTreeDepth(u,t),n&&u.forEach(function(e){e.y=e.depth*n}),{nodes:u,links:l}}},{key:"calculateD3Geometry",value:function(e){var t=void 0;return t=e.zoom>e.scaleExtent.max?e.scaleExtent.max:e.zoom0},n}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;t2&&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:"renderNodeElement",value:function(e){var t=this.props,n=t.circleRadius,r=t.nodeSvgShape;return n?c.default.createElement("circle",{r:n,style:e.circle}):"none"===r.shape?null:c.default.createElement(r.shape,s({},e.circle,r.shapeProps))}},{key:"handleClick",value:function(e){this.props.onClick(this.props.nodeData.id,e)}},{key:"handleOnMouseOver",value:function(e){this.props.onMouseOver(this.props.nodeData.id,e)}},{key:"handleOnMouseOut",value:function(e){this.props.onMouseOut(this.props.nodeData.id,e)}},{key:"componentWillLeave",value:function(e){var t=this.props,n=t.nodeData.parent,r=t.orientation,o=t.transitionDuration,a=n?n.x:0,i=n?n.y:0,s=this.setTransformOrientation(a,i,r);this.applyTransform(s,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){var r=n(14);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};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=function(){function e(e,t){for(var n=0;n2&&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:"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"function"==typeof r?r(t,n):"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.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;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;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}])}); \ No newline at end of file +!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=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=x(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=O(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){if(void 0===t[n]){var r=e.call(this,n);if(r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[n]=r}return t[n]}}(function(e){return document.querySelector(e)}),v=null,m=0,g=[],O=n(15);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||(t.singleton=y()),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=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 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,t){var n=this,r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];this.props.collapsible&&!this.state.isTransitioning?(a._collapsed?this.expandNode(a):this.collapseNode(a),this.setState({data:r,isTransitioning:!0},function(){return n.handleOnClickCb(a,t)}),setTimeout(function(){return n.setState({isTransitioning:!1})},this.props.transitionDuration+10),this.internalState.targetNode=a):this.handleOnClickCb(a,t)}},{key:"handleOnClickCb",value:function(e,t){var n=this.props.onClick;n&&"function"==typeof n&&n((0,y.default)(e),t)}},{key:"handleOnMouseOverCb",value:function(e,t){var n=this.props.onMouseOver;if(n&&"function"==typeof n){var r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];n((0,y.default)(a),t)}}},{key:"handleOnMouseOutCb",value:function(e,t){var n=this.props.onMouseOut;if(n&&"function"==typeof n){var r=(0,y.default)(this.state.data),o=this.findNodesById(e,r,[]),a=o[0];n((0,y.default)(a),t)}}},{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 e.parent.id===t.parent.id?r.siblings:r.nonSiblings}).children(function(e){return e._collapsed?null:e._children}),s=this.state.data[0],u=i.nodes(s);return void 0!==t&&this.internalState.initialRender&&(this.setInitialTreeDepth(u,t),u=i.nodes(s)),n&&u.forEach(function(e){e.y=e.depth*n}),{nodes:u,links:i.links(u)}}},{key:"calculateD3Geometry",value:function(e){var t=void 0;return t=e.zoom>e.scaleExtent.max?e.scaleExtent.max:e.zoom0},n}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;t2&&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:"renderNodeElement",value:function(e){var t=this.props,n=t.circleRadius,r=t.nodeSvgShape;return n?c.default.createElement("circle",{r:n,style:e.circle}):"none"===r.shape?null:c.default.createElement(r.shape,s({},e.circle,r.shapeProps))}},{key:"handleClick",value:function(e){this.props.onClick(this.props.nodeData.id,e)}},{key:"handleOnMouseOver",value:function(e){this.props.onMouseOver(this.props.nodeData.id,e)}},{key:"handleOnMouseOut",value:function(e){this.props.onMouseOut(this.props.nodeData.id,e)}},{key:"componentWillLeave",value:function(e){var t=this.props,n=t.nodeData.parent,r=t.orientation,o=t.transitionDuration,a=n?n.x:0,i=n?n.y:0,s=this.setTransformOrientation(a,i,r);this.applyTransform(s,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){var r=n(14);"string"==typeof r&&(r=[[e.i,r,""]]);var o={hmr:!0};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=function(){function e(e,t){for(var n=0;n2&&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:"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"function"==typeof r?r(t,n):"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.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;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;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}])}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3e0e124d..ae347b39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-d3-tree", - "version": "1.10.5", + "version": "1.10.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6647144e..56b5cb14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-d3-tree", - "version": "1.10.5", + "version": "1.10.6", "description": "React component to create interactive D3 tree hierarchies", "main": "lib/react-d3-tree.min.js", "scripts": {