From 46e67096202f56812f52924c9a798a135de159dc Mon Sep 17 00:00:00 2001 From: Bassel Ahmed Date: Thu, 1 Nov 2018 19:18:26 +0200 Subject: [PATCH] fix a bug when changing props that made valueType be undefined --- lib/reactcohortgraph.js | 14 ++++++++++---- lib/reactcohortgraph.min.js | 2 +- src/ReactCohortGraph.js | 14 ++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/reactcohortgraph.js b/lib/reactcohortgraph.js index 412c3a8..0da6680 100644 --- a/lib/reactcohortgraph.js +++ b/lib/reactcohortgraph.js @@ -2745,10 +2745,16 @@ var ReactCohortGraph = function (_React$Component) { dataStore: store }); } else { - this.setState({ - currentType: currentDataType, - valueType: valueType - }); + if (valueType) { + this.setState({ + currentType: currentDataType, + valueType: valueType + }); + } else { + this.setState({ + currentType: currentDataType + }); + } } if (typeof onStoreUpdate === 'function') { onStoreUpdate(store, currentDataType, valueType); diff --git a/lib/reactcohortgraph.min.js b/lib/reactcohortgraph.min.js index ce82aff..35e0d7a 100644 --- a/lib/reactcohortgraph.min.js +++ b/lib/reactcohortgraph.min.js @@ -3,4 +3,4 @@ object-assign (c) Sindre Sorhus @license MIT */ -var o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,l,u=r(e),c=1;c0&&void 0!==arguments[0]?arguments[0]:{};return r({width:"100%",padding:0,margin:0},e)},t.table=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table",width:"100%",borderCollapse:"collapse",textAlign:"center",borderLeft:o},e)},t.tableRow=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-row"},e)},t.tableHeading=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-header-group",fontWeight:"bold",padding:"15px 30px",borderBottom:o,borderTop:o},e)},t.tableBody=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-row-group"},e)},t.tableCell=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-cell",padding:"5px 10px",borderBottom:"1px solid #DDD",borderRight:o,minWidth:"60px",whiteSpace:"nowrap"},e)},t.headerValue=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({fontSize:"12px"},e)},t.headerLabel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({fontSize:"16px",padding:"0",margin:"0"},e)},t.fixedTablePart=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-cell",minWidth:"200px"},e)},t.scrollableTableContent=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({position:"relative",display:"block"},e)},t.scrollableTablePart=function(){return{display:"table-cell",overflowX:"auto",whiteSpace:"nowrap",width:"100%",minWidth:60,custom:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}},function(e,t,n){"use strict";(function(t){var n={};"production"!==t.env.NODE_ENV&&Object.freeze(n),e.exports=n}).call(t,n(0))},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";(function(t){function r(e,t,n){this.props=e,this.context=t,this.refs=l,this.updater=n||a}var o=n(4),a=n(15),i=n(8),l=n(11),u=n(2),c=n(1);if(r.prototype.isReactComponent={},r.prototype.setState=function(e,n){"object"!=typeof e&&"function"!=typeof e&&null!=e&&("production"!==t.env.NODE_ENV?u(!1,"setState(...): takes an object of state variables to update or a function which returns an object of state variables."):o("85")),this.updater.enqueueSetState(this,e),n&&this.updater.enqueueCallback(this,n,"setState")},r.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this),e&&this.updater.enqueueCallback(this,e,"forceUpdate")},"production"!==t.env.NODE_ENV){var s={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(var p in s)s.hasOwnProperty(p)&&function(e,n){i&&Object.defineProperty(r.prototype,e,{get:function(){"production"!==t.env.NODE_ENV&&c(!1,"%s(...) is deprecated in plain JavaScript React classes. %s",n[0],n[1])}})}(p,s[p])}e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";(function(t){function r(e){var t=Function.prototype.toString,n=Object.prototype.hasOwnProperty,r=RegExp("^"+t.call(n).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");try{var o=t.call(e);return r.test(o)}catch(e){return!1}}function o(e){var t=c(e);if(t){var n=t.childIDs;s(e),n.forEach(o)}}function a(e,t,n){return"\n in "+(e||"Unknown")+(t?" (at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+")":n?" (created by "+n+")":"")}function i(e){return null==e?"#empty":"string"==typeof e||"number"==typeof e?"#text":"string"==typeof e.type?e.type:e.type.displayName||e.type.name||"Unknown"}function l(e){var n,r=P.getDisplayName(e),o=P.getElement(e),i=P.getOwnerID(e);return i&&(n=P.getDisplayName(i)),"production"!==t.env.NODE_ENV&&b(o,"ReactComponentTreeHook: Missing React element for debugID %s when building stack",e),a(r,o&&o._source,n)}var u,c,s,p,f,d,y,h=n(4),v=n(7),m=n(2),b=n(1),E="function"==typeof Array.from&&"function"==typeof Map&&r(Map)&&null!=Map.prototype&&"function"==typeof Map.prototype.keys&&r(Map.prototype.keys)&&"function"==typeof Set&&r(Set)&&null!=Set.prototype&&"function"==typeof Set.prototype.keys&&r(Set.prototype.keys);if(E){var g=new Map,_=new Set;u=function(e,t){g.set(e,t)},c=function(e){return g.get(e)},s=function(e){g.delete(e)},p=function(){return Array.from(g.keys())},f=function(e){_.add(e)},d=function(e){_.delete(e)},y=function(){return Array.from(_.keys())}}else{var N={},O={},C=function(e){return"."+e},D=function(e){return parseInt(e.substr(1),10)};u=function(e,t){var n=C(e);N[n]=t},c=function(e){var t=C(e);return N[t]},s=function(e){var t=C(e);delete N[t]},p=function(){return Object.keys(N).map(D)},f=function(e){var t=C(e);O[t]=!0},d=function(e){var t=C(e);delete O[t]},y=function(){return Object.keys(O).map(D)}}var w=[],P={onSetChildren:function(e,n){var r=c(e);r||("production"!==t.env.NODE_ENV?m(!1,"Item must have been set"):h("144")),r.childIDs=n;for(var o=0;o.")}return t}function i(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=v.uniqueKey||(v.uniqueKey={}),o=a(n);if(!r[o]){r[o]=!0;var i="";e&&e._owner&&e._owner!==c.current&&(i=" It was passed a child from "+e._owner.getName()+"."),"production"!==t.env.NODE_ENV&&h(!1,'Each child in an array or iterator should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.%s',o,i,s.getCurrentStackAddendum(e))}}}function l(e,t){if("object"==typeof e)if(Array.isArray(e))for(var n=0;n0){var o=this._getStore(this.props),a=r[0];"function"==typeof n&&n(o,a,this.state.valueType),this.setState({currentType:a,dataStore:o})}}},{key:"componentWillReceiveProps",value:function(e){var t=e.data,n=e.dataType,r=e.valueType,o=e.onStoreUpdate,a=this.state.currentType;if(Object.keys(t).length>0){var i=this._getStore(this.props),l=n||Object.keys(t)[0];""===a||r===this.state.valueType&&n===a?this.setState({dataStore:i}):this.setState({currentType:l,valueType:r}),"function"==typeof o&&o(i,l,r)}}},{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this,t=this.props,n=t.showEmptyDataMessage,r=void 0===n||n,o=t.customEmptyDataMessage,a=t.labelFormatter,i=t.bodyCellStyles,u=void 0===i?{}:i,c=t.headerCellStyles,p=void 0===c?{}:c,f=t.tableStyles,y=t.tableRowStyles,h=t.tableHeadingStyles,m=t.tableBodyStyles,b=t.fixedTablePartStyles,E=t.wrapperStyles,g=t.scrollableTablePartStyles,_=t.scrollableTableContentStyles,N=t.headerLabelStyles,O=t.tableCellStyles,C=this.state,D=C.dataStore,w=C.currentType,P=C.valueType,x=D.getHeader(w),S=D.getRows(w),T=(0,d.table)(f),j=(0,d.tableRow)(y),k=(0,d.tableHeading)(h),R=(0,d.tableBody)(m),A=(0,d.fixedTablePart)(b),V=(0,d.wrapper)(E),I=(0,d.scrollableTablePart)(g);(0,d.scrollableTableContent)(_);return x&&x.length>0?s.default.createElement("div",{style:V},this.renderChildren(l({},this.props,this.state)),s.default.createElement("div",{style:T},s.default.createElement("div",{style:R},s.default.createElement("div",{style:j},s.default.createElement("div",{style:A},s.default.createElement("div",{style:T},s.default.createElement("div",{style:k},x.map(function(t,n){return e.isFixed(n)&&s.default.createElement(v.HeaderCell,l({tableCellStyles:O,headerLabelStyles:N,style:p,key:"header"+n},t,{valueType:P}))})),s.default.createElement("div",{style:R},S.map(function(t,n){return s.default.createElement("div",{style:j,key:"row"+n},t.map(function(t,n){return e.isFixed(n)&&s.default.createElement(v.BodyCell,l({tableCellStyles:O,style:u,key:"cell"+n},t,{valueType:P,labelFormatter:a}))}))})))),s.default.createElement("div",{style:I},s.default.createElement(v.ScrollableContent,{scrollableTableContentStyles:_},s.default.createElement("div",{style:T},s.default.createElement("div",{style:k},x.map(function(t,n){return!e.isFixed(n)&&s.default.createElement(v.HeaderCell,l({tableCellStyles:O,style:p,key:"header"+n},t,{valueType:P}))})),s.default.createElement("div",{style:R},S.map(function(t,n){return s.default.createElement("div",{style:j,key:"row"+n},t.map(function(t,n){return!e.isFixed(n)&&s.default.createElement(v.BodyCell,l({tableCellStyles:O,style:u,key:"cell"+n},t,{valueType:P}))}))}))))))))):r?o||s.default.createElement("h3",null,"No Data..!"):void 0}}]),t}(s.default.Component),E=function(){this._getStore=function(e){var t=e.data,n=void 0===t?{}:t,r=e.shadeColor,o=void 0===r?d.DEFAULT_SHADE_COLOR:r,a=e.headerCellColor,i=void 0===a?d.DEFAULT_HEADER_CELL_COLOR:a,l=e.bodyCellColor,u=void 0===l?d.DEFAULT_BODY_CELL_COLOR:l,c=e.keyCellColor,s=void 0===c?d.DEFAULT_KEY_CELL_COLOR:c;return new h.default(n,{shadeColor:o,headerCellColor:i,bodyCellColor:u,keyCellColor:s})},this.isFixed=function(e){return e<2},this.renderChildren=function(e){return s.default.Children.map(e.children,function(t){return s.default.cloneElement(t,e)})}};b.propTypes={data:f.default.object.isRequired,dataType:f.default.string,defaultValueType:f.default.string,cellClickEvent:f.default.func,showEmptyDataMessage:f.default.bool,customEmptyDataMessage:f.default.any,columnClickEvent:f.default.func,shadeColor:f.default.string,headerCellColor:f.default.string,bodyCellColor:f.default.string,keyCellColor:f.default.string,labelFormatter:f.default.func,showAbsolute:f.default.bool,toggleValues:f.default.bool,showHeaderValues:f.default.bool,onStoreUpdate:f.default.func,headerCellStyles:f.default.object,bodyCellStyles:f.default.object,tableCellStyles:f.default.object,tableStyles:f.default.object,tableRowStyles:f.default.object,tableHeadingStyles:f.default.object,tableBodyStyles:f.default.object,fixedTablePartStyles:f.default.object,wrapperStyles:f.default.object,scrollableTablePartStyles:f.default.object,scrollableTableContentStyles:f.default.object,headerValueStyles:f.default.object,headerLabelStyles:f.default.object},t.default=b},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:{};a(this,e),p.call(this),this.isValid=!0,this._checkValidity(t),this.rawStore=t,this.store={},this.headers={},this.options=n,this.isValid?(this._buildStore(t),this._buildHeaders()):console.error("Invalid Data for cohort graph..!")},p=function(){var e=this;this._checkValidity=function(t){if("object"!==(void 0===t?"undefined":i(t))||Array.isArray(t))e.isValid=!1;else for(var n in t){if(!t.hasOwnProperty(n)||"object"!==i(t[n])||Array.isArray(t[n]))return void(e.isValid=!1);for(var r in t[n])if(t[n].hasOwnProperty(r)&&!Array.isArray(t[n][r]))return void(e.isValid=!1)}},this._buildStore=function(t){for(var n in t)!function(n){if(t.hasOwnProperty(n)){e.store[n]=[];for(var a in t[n])!function(a){if(t[n].hasOwnProperty(a)){var i={};i.type=n,i[u]=a,i.valueFor=a,i.total=t[n][a].length>0?t[n][a][0]:0,i[c]=100,i.color=e.options.keyCellColor,i.isLabel=!0,e.store[n].push([i].concat(o(t[n][a].map(function(t,o){var l,s=e._getPercentage(i.total,t);return l={type:n},r(l,u,t),r(l,"valueFor",a),r(l,"total",i.total),r(l,"isTotal",0===o),r(l,c,s),r(l,"color",0===o?e.options.bodyCellColor:e._shadeCellWithColor(s,e.options.shadeColor)),l}))))}}(a)}}(n)},this._buildHeaders=function(){for(var t in e.store)!function(t){if(e.store.hasOwnProperty(t)){var n=e._turnCamelCase(t.slice(0,-1));e.headers[t]=[],e.headers[t].push({value:"",color:e.options.headerCellColor,isLabel:!0,label:e._turnCamelCase(t)});var o={};o.isHeader=!0,o.index=0,o.type=t,o[u]=e._sumOfColumnWithIndex(e.store[t],1),o.valueFor=t,o.total=o.value,o[c]=100,o.isTotal=!0,o.color=e.options.headerCellColor,o.label=n+" 0",e.headers[t].push(o);var a=e.store[t].length,i=a>0?e.store[t][0]:[];i.forEach(function(l,s){var p;if(!(s<2)){var f=e._sumOfColumnWithIndex(e.store[t],s),d=e._getPercentage(e._sumOfFirstColumnUpToIndex(e.store[t],a,s),f);e.headers[t].push((p={isHeader:!0,index:s,type:t},r(p,u,f),r(p,"valueFor",i[0]),r(p,"total",o.total),r(p,c,d),r(p,"color",e._shadeCellWithColor(d,e.options.shadeColor)),r(p,"label",n+" "+(s-1)),p))}})}}(t)},this._sumOfArrayElements=function(e){return e.reduce(function(e,t){return e+t})},this._sumOfColumnWithIndex=function(e,t){var n=0;return e.forEach(function(e){try{n+=e[t].value}catch(e){n+=0}}),n},this._sumOfFirstColumnUpToIndex=function(e,t,n){for(var r=0,o=0;o<=t;o++)try{if(!e[o][n])break;r+=e[o][1].value}catch(e){break}return r},this.getTypeData=function(t){if(e.store.hasOwnProperty(t))return e.store[t];console.error("No Data Found for type => "+t)},this.getHighestRowSize=function(t){if(e.store.hasOwnProperty(t))return e.store[t][0].length;console.error("No Columns Found for type => "+t)},this.getCellData=function(t,n,r){if(e.store.hasOwnProperty(t))try{return e.store[t][n][r]}catch(e){console.error("No Data Found for cell with type => "+t+", row => "+n+", col => "+r)}else console.error("No Data Found for cell with type => "+t+", row => "+n+", col => "+r)},this.getHeaderCellData=function(t,n){if(e.headers.hasOwnProperty(t))try{return e.headers[t][n]}catch(e){console.error("No Data Found for cell with type => "+t+", col => "+n)}else console.error("No Data Found for cell with type => "+t+", col => "+n)},this.getHeader=function(t){return e.headers.hasOwnProperty(t)?e.headers[t]:(console.error("No Headers Found for type => "+t),[])},this.getRows=function(t){return e.store.hasOwnProperty(t)?e.store[t]:(console.error("No Headers Found for type => "+t),[])},this._shadeCellWithColor=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#3f83a3",n=1-Math.ceil(e/10)/10,r=parseInt(t.slice(1),16),o=n<0?0:255,a=n<0?-1*n:n,i=r>>16,l=r>>8&255,u=255&r;return"#"+(16777216+65536*(Math.round((o-i)*a)+i)+256*(Math.round((o-l)*a)+l)+(Math.round((o-u)*a)+u)).toString(16).slice(1)},this._getPercentage=function(e,t){return e?Math.round(t/e*100*100)/100:e},this._isValidHex=function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},this._turnCamelCase=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("string"==typeof e)return e.toLowerCase().replace(/\b\w/g,function(e){return e.toUpperCase()})}};t.default=s},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 a(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.ScrollableContent=t.BodyCell=t.HeaderCell=void 0;var i=function(){function e(e,t){for(var n=0;n1?l-1:0),c=1;c0&&void 0!==arguments[0]?arguments[0]:{};return r({width:"100%",padding:0,margin:0},e)},t.table=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table",width:"100%",borderCollapse:"collapse",textAlign:"center",borderLeft:o},e)},t.tableRow=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-row"},e)},t.tableHeading=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-header-group",fontWeight:"bold",padding:"15px 30px",borderBottom:o,borderTop:o},e)},t.tableBody=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-row-group"},e)},t.tableCell=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-cell",padding:"5px 10px",borderBottom:"1px solid #DDD",borderRight:o,minWidth:"60px",whiteSpace:"nowrap"},e)},t.headerValue=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({fontSize:"12px"},e)},t.headerLabel=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({fontSize:"16px",padding:"0",margin:"0"},e)},t.fixedTablePart=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({display:"table-cell",minWidth:"200px"},e)},t.scrollableTableContent=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r({position:"relative",display:"block"},e)},t.scrollableTablePart=function(){return{display:"table-cell",overflowX:"auto",whiteSpace:"nowrap",width:"100%",minWidth:60,custom:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}},function(e,t,n){"use strict";(function(t){var n={};"production"!==t.env.NODE_ENV&&Object.freeze(n),e.exports=n}).call(t,n(0))},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";(function(t){function r(e,t,n){this.props=e,this.context=t,this.refs=l,this.updater=n||a}var o=n(4),a=n(15),i=n(8),l=n(11),u=n(2),c=n(1);if(r.prototype.isReactComponent={},r.prototype.setState=function(e,n){"object"!=typeof e&&"function"!=typeof e&&null!=e&&("production"!==t.env.NODE_ENV?u(!1,"setState(...): takes an object of state variables to update or a function which returns an object of state variables."):o("85")),this.updater.enqueueSetState(this,e),n&&this.updater.enqueueCallback(this,n,"setState")},r.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this),e&&this.updater.enqueueCallback(this,e,"forceUpdate")},"production"!==t.env.NODE_ENV){var s={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for(var p in s)s.hasOwnProperty(p)&&function(e,n){i&&Object.defineProperty(r.prototype,e,{get:function(){"production"!==t.env.NODE_ENV&&c(!1,"%s(...) is deprecated in plain JavaScript React classes. %s",n[0],n[1])}})}(p,s[p])}e.exports=r}).call(t,n(0))},function(e,t,n){"use strict";(function(t){function r(e){var t=Function.prototype.toString,n=Object.prototype.hasOwnProperty,r=RegExp("^"+t.call(n).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");try{var o=t.call(e);return r.test(o)}catch(e){return!1}}function o(e){var t=c(e);if(t){var n=t.childIDs;s(e),n.forEach(o)}}function a(e,t,n){return"\n in "+(e||"Unknown")+(t?" (at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+")":n?" (created by "+n+")":"")}function i(e){return null==e?"#empty":"string"==typeof e||"number"==typeof e?"#text":"string"==typeof e.type?e.type:e.type.displayName||e.type.name||"Unknown"}function l(e){var n,r=P.getDisplayName(e),o=P.getElement(e),i=P.getOwnerID(e);return i&&(n=P.getDisplayName(i)),"production"!==t.env.NODE_ENV&&b(o,"ReactComponentTreeHook: Missing React element for debugID %s when building stack",e),a(r,o&&o._source,n)}var u,c,s,p,f,d,y,h=n(4),v=n(7),m=n(2),b=n(1),E="function"==typeof Array.from&&"function"==typeof Map&&r(Map)&&null!=Map.prototype&&"function"==typeof Map.prototype.keys&&r(Map.prototype.keys)&&"function"==typeof Set&&r(Set)&&null!=Set.prototype&&"function"==typeof Set.prototype.keys&&r(Set.prototype.keys);if(E){var g=new Map,_=new Set;u=function(e,t){g.set(e,t)},c=function(e){return g.get(e)},s=function(e){g.delete(e)},p=function(){return Array.from(g.keys())},f=function(e){_.add(e)},d=function(e){_.delete(e)},y=function(){return Array.from(_.keys())}}else{var N={},O={},C=function(e){return"."+e},D=function(e){return parseInt(e.substr(1),10)};u=function(e,t){var n=C(e);N[n]=t},c=function(e){var t=C(e);return N[t]},s=function(e){var t=C(e);delete N[t]},p=function(){return Object.keys(N).map(D)},f=function(e){var t=C(e);O[t]=!0},d=function(e){var t=C(e);delete O[t]},y=function(){return Object.keys(O).map(D)}}var w=[],P={onSetChildren:function(e,n){var r=c(e);r||("production"!==t.env.NODE_ENV?m(!1,"Item must have been set"):h("144")),r.childIDs=n;for(var o=0;o.")}return t}function i(e,n){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=v.uniqueKey||(v.uniqueKey={}),o=a(n);if(!r[o]){r[o]=!0;var i="";e&&e._owner&&e._owner!==c.current&&(i=" It was passed a child from "+e._owner.getName()+"."),"production"!==t.env.NODE_ENV&&h(!1,'Each child in an array or iterator should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.%s',o,i,s.getCurrentStackAddendum(e))}}}function l(e,t){if("object"==typeof e)if(Array.isArray(e))for(var n=0;n0){var o=this._getStore(this.props),a=r[0];"function"==typeof n&&n(o,a,this.state.valueType),this.setState({currentType:a,dataStore:o})}}},{key:"componentWillReceiveProps",value:function(e){var t=e.data,n=e.dataType,r=e.valueType,o=e.onStoreUpdate,a=this.state.currentType;if(Object.keys(t).length>0){var i=this._getStore(this.props),l=n||Object.keys(t)[0];""===a||r===this.state.valueType&&n===a?this.setState({dataStore:i}):r?this.setState({currentType:l,valueType:r}):this.setState({currentType:l}),"function"==typeof o&&o(i,l,r)}}},{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this,t=this.props,n=t.showEmptyDataMessage,r=void 0===n||n,o=t.customEmptyDataMessage,a=t.labelFormatter,i=t.headerFormatter,u=t.bodyCellStyles,c=void 0===u?{}:u,p=t.headerCellStyles,f=void 0===p?{}:p,y=t.tableStyles,h=t.tableRowStyles,m=t.tableHeadingStyles,b=t.tableBodyStyles,E=t.fixedTablePartStyles,g=t.wrapperStyles,_=t.scrollableTablePartStyles,N=t.scrollableTableContentStyles,O=t.headerLabelStyles,C=t.tableCellStyles,D=this.state,w=D.dataStore,P=D.currentType,x=D.valueType,S=w.getHeader(P),T=w.getRows(P),j=(0,d.table)(y),k=(0,d.tableRow)(h),R=(0,d.tableHeading)(m),A=(0,d.tableBody)(b),V=(0,d.fixedTablePart)(E),I=(0,d.wrapper)(g),F=(0,d.scrollableTablePart)(_);(0,d.scrollableTableContent)(N);return console.log(S),S&&S.length>0?s.default.createElement("div",{style:I},this.renderChildren(l({},this.props,this.state)),s.default.createElement("div",{style:j},s.default.createElement("div",{style:A},s.default.createElement("div",{style:k},s.default.createElement("div",{style:V},s.default.createElement("div",{style:j},s.default.createElement("div",{style:R},S.map(function(t,n){return e.isFixed(n)&&s.default.createElement(v.HeaderCell,l({tableCellStyles:C,headerLabelStyles:O,style:f,key:"header"+n},t,{headerFormatter:i,valueType:x}))})),s.default.createElement("div",{style:A},T.map(function(t,n){return s.default.createElement("div",{style:k,key:"row"+n},t.map(function(t,n){return e.isFixed(n)&&s.default.createElement(v.BodyCell,l({tableCellStyles:C,style:c,key:"cell"+n},t,{valueType:x,labelFormatter:a}))}))})))),s.default.createElement("div",{style:F},s.default.createElement(v.ScrollableContent,{scrollableTableContentStyles:N},s.default.createElement("div",{style:j},s.default.createElement("div",{style:R},S.map(function(t,n){return!e.isFixed(n)&&s.default.createElement(v.HeaderCell,l({tableCellStyles:C,style:f,key:"header"+n},t,{headerFormatter:i,valueType:x}))})),s.default.createElement("div",{style:A},T.map(function(t,n){return s.default.createElement("div",{style:k,key:"row"+n},t.map(function(t,n){return!e.isFixed(n)&&s.default.createElement(v.BodyCell,l({tableCellStyles:C,style:c,key:"cell"+n},t,{valueType:x}))}))}))))))))):r?o||s.default.createElement("h3",null,"No Data..!"):void 0}}]),t}(s.default.Component),E=function(){this._getStore=function(e){var t=e.data,n=void 0===t?{}:t,r=e.shadeColor,o=void 0===r?d.DEFAULT_SHADE_COLOR:r,a=e.headerCellColor,i=void 0===a?d.DEFAULT_HEADER_CELL_COLOR:a,l=e.bodyCellColor,u=void 0===l?d.DEFAULT_BODY_CELL_COLOR:l,c=e.keyCellColor,s=void 0===c?d.DEFAULT_KEY_CELL_COLOR:c;return new h.default(n,{shadeColor:o,headerCellColor:i,bodyCellColor:u,keyCellColor:s})},this.isFixed=function(e){return e<2},this.renderChildren=function(e){return s.default.Children.map(e.children,function(t){return s.default.cloneElement(t,e)})}};b.propTypes={data:f.default.object.isRequired,dataType:f.default.string,defaultValueType:f.default.string,cellClickEvent:f.default.func,showEmptyDataMessage:f.default.bool,customEmptyDataMessage:f.default.any,columnClickEvent:f.default.func,shadeColor:f.default.string,headerCellColor:f.default.string,bodyCellColor:f.default.string,keyCellColor:f.default.string,labelFormatter:f.default.func,headerFormatter:f.default.func,showAbsolute:f.default.bool,toggleValues:f.default.bool,showHeaderValues:f.default.bool,onStoreUpdate:f.default.func,headerCellStyles:f.default.object,bodyCellStyles:f.default.object,tableCellStyles:f.default.object,tableStyles:f.default.object,tableRowStyles:f.default.object,tableHeadingStyles:f.default.object,tableBodyStyles:f.default.object,fixedTablePartStyles:f.default.object,wrapperStyles:f.default.object,scrollableTablePartStyles:f.default.object,scrollableTableContentStyles:f.default.object,headerValueStyles:f.default.object,headerLabelStyles:f.default.object},t.default=b},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&void 0!==arguments[1]?arguments[1]:{};a(this,e),p.call(this),this.isValid=!0,this._checkValidity(t),this.rawStore=t,this.store={},this.headers={},this.options=n,this.isValid?(this._buildStore(t),this._buildHeaders()):console.error("Invalid Data for cohort graph..!")},p=function(){var e=this;this._checkValidity=function(t){if("object"!==(void 0===t?"undefined":i(t))||Array.isArray(t))e.isValid=!1;else for(var n in t){if(!t.hasOwnProperty(n)||"object"!==i(t[n])||Array.isArray(t[n]))return void(e.isValid=!1);for(var r in t[n])if(t[n].hasOwnProperty(r)&&!Array.isArray(t[n][r]))return void(e.isValid=!1)}},this._buildStore=function(t){for(var n in t)!function(n){if(t.hasOwnProperty(n)){e.store[n]=[];for(var a in t[n])!function(a){if(t[n].hasOwnProperty(a)){var i={};i.type=n,i[u]=a,i.valueFor=a,i.total=t[n][a].length>0?t[n][a][0]:0,i[c]=100,i.color=e.options.keyCellColor,i.isLabel=!0,e.store[n].push([i].concat(o(t[n][a].map(function(t,o){var l,s=e._getPercentage(i.total,t);return l={type:n},r(l,u,t),r(l,"valueFor",a),r(l,"total",i.total),r(l,"isTotal",0===o),r(l,c,s),r(l,"color",0===o?e.options.bodyCellColor:e._shadeCellWithColor(s,e.options.shadeColor)),l}))))}}(a)}}(n)},this._buildHeaders=function(){for(var t in e.store)!function(t){if(e.store.hasOwnProperty(t)){var n=e._turnCamelCase(t.slice(0,-1));e.headers[t]=[],e.headers[t].push({value:"",color:e.options.headerCellColor,isLabel:!0,label:e._turnCamelCase(t)});var o={};o.isHeader=!0,o.index=0,o.type=t,o[u]=e._sumOfColumnWithIndex(e.store[t],1),o.valueFor=t,o.total=o.value,o[c]=100,o.isTotal=!0,o.color=e.options.headerCellColor,o.label=n+" 0",e.headers[t].push(o);var a=e.store[t].length,i=a>0?e.store[t][0]:[];i.forEach(function(l,s){var p;if(!(s<2)){var f=e._sumOfColumnWithIndex(e.store[t],s),d=e._getPercentage(e._sumOfFirstColumnUpToIndex(e.store[t],a,s),f);e.headers[t].push((p={isHeader:!0,index:s,type:t},r(p,u,f),r(p,"valueFor",i[0]),r(p,"total",o.total),r(p,c,d),r(p,"color",e._shadeCellWithColor(d,e.options.shadeColor)),r(p,"label",n+" "+(s-1)),p))}})}}(t)},this._sumOfArrayElements=function(e){return e.reduce(function(e,t){return e+t})},this._sumOfColumnWithIndex=function(e,t){var n=0;return e.forEach(function(e){try{n+=e[t].value}catch(e){n+=0}}),n},this._sumOfFirstColumnUpToIndex=function(e,t,n){for(var r=0,o=0;o<=t;o++)try{if(!e[o][n])break;r+=e[o][1].value}catch(e){break}return r},this.getTypeData=function(t){if(e.store.hasOwnProperty(t))return e.store[t];console.error("No Data Found for type => "+t)},this.getHighestRowSize=function(t){if(e.store.hasOwnProperty(t))return e.store[t][0].length;console.error("No Columns Found for type => "+t)},this.getCellData=function(t,n,r){if(e.store.hasOwnProperty(t))try{return e.store[t][n][r]}catch(e){console.error("No Data Found for cell with type => "+t+", row => "+n+", col => "+r)}else console.error("No Data Found for cell with type => "+t+", row => "+n+", col => "+r)},this.getHeaderCellData=function(t,n){if(e.headers.hasOwnProperty(t))try{return e.headers[t][n]}catch(e){console.error("No Data Found for cell with type => "+t+", col => "+n)}else console.error("No Data Found for cell with type => "+t+", col => "+n)},this.getHeader=function(t){return e.headers.hasOwnProperty(t)?e.headers[t]:(console.error("No Headers Found for type => "+t),[])},this.getRows=function(t){return e.store.hasOwnProperty(t)?e.store[t]:(console.error("No Headers Found for type => "+t),[])},this._shadeCellWithColor=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#3f83a3",n=1-Math.ceil(e/10)/10,r=parseInt(t.slice(1),16),o=n<0?0:255,a=n<0?-1*n:n,i=r>>16,l=r>>8&255,u=255&r;return"#"+(16777216+65536*(Math.round((o-i)*a)+i)+256*(Math.round((o-l)*a)+l)+(Math.round((o-u)*a)+u)).toString(16).slice(1)},this._getPercentage=function(e,t){return e?Math.round(t/e*100*100)/100:e},this._isValidHex=function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},this._turnCamelCase=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("string"==typeof e)return e.toLowerCase().replace(/\b\w/g,function(e){return e.toUpperCase()})}};t.default=s},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(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 a(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.ScrollableContent=t.BodyCell=t.HeaderCell=void 0;var i=function(){function e(e,t){for(var n=0;n1?l-1:0),c=1;c