@corva/ui 0.36.0-3 → 0.36.0-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/main.js +1 -1
package/package.json
CHANGED
package/utils/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/regenerator";import n from"file-saver";import o from"chroma-js";import i from"lodash/round";import a from"lodash/isNaN";import u from"lodash/isNumber";import c from"html2canvas";import s from"@material-ui/core/colors/grey";import m from"@material-ui/core/colors/red";import l from"@material-ui/core/colors/yellow";import f from"@material-ui/core/colors/blue";import p from"@material-ui/core/colors/green";import{SUPPORTED_DRILLING_OPERATIONS as h,DEFAULT_DRILLING_OPERATION_TYPE as d}from"../constants/apps.js";var g=s[500],v=m[500],b=l[500],N=f[500],
|
|
1
|
+
import e from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/regenerator";import n from"file-saver";import o from"chroma-js";import i from"lodash/round";import a from"lodash/isNaN";import u from"lodash/isNumber";import c from"html2canvas";import s from"@material-ui/core/colors/grey";import m from"@material-ui/core/colors/red";import l from"@material-ui/core/colors/yellow";import f from"@material-ui/core/colors/blue";import p from"@material-ui/core/colors/green";import{SUPPORTED_DRILLING_OPERATIONS as h,DEFAULT_DRILLING_OPERATION_TYPE as d}from"../constants/apps.js";var g=s[500],v=m[500],b=l[500],N=f[500],w=p[500],F={formatValuePrecision:function(e){return Number.isFinite(e)?e<100&&e>-100?e.formatNumeral("0,0.00"):e.formatNumeral("0,0.0"):e},downloadPDF:function(e,t){var r=new File([t],"".concat(e,".pdf"),{type:"application/pdf;charset=utf-8"});n.saveAs(r)},unescapeLineBreaks:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.replace(/\\n/g,"\n")},dataURLtoBlob:function(e){for(var t=window.atob(e.split(",")[1]),r=e.split(",")[0].split(":")[1].split(";")[0],n=new ArrayBuffer(t.length),o=new Uint8Array(n),i=0;i<t.length;i+=1)o[i]=t.charCodeAt(i);return new Blob([n],{type:r})},banchmarkTimer:function(e){var t=new Date;return{stop:function(){var r=(new Date).getTime()-t.getTime();console.info("Timer:",e,"finished in",r,"ms")}}},convertToPercent:function(e,t){return e&&Number.isFinite(t)&&0!==t?Math.round(100*e/t*100)/100:0},getAverageByColumnsForCSV:function(e){var r=this,n=e.split("\n"),o=n[0].split(","),c=n[1].split(",").map((function(e){return[r.parseNumberFromString(e)]})),s=this.getLinesFrequency(n.length);n.shift();var m=n.reduce((function(e,n,o){if(o%s==0){var i=n.split(",").map(r.parseNumberFromString);return e.map((function(e,r){var n=+i[r];return u(n)&&!a(n)&&n>0?[].concat(t(e),[n]):e}))}return e}),c).map((function(e){return e.reduce((function(e,t){return e+t}))/e.length}));return m.map((function(e,t){return{header:o[t],value:i(e,5)}}))},parseNumberFromString:function(e){var t=+e;return a(t)?0:t},getLinesFrequency:function(e){var t="".concat(e);if(t.length<=4)return 1;var r=t.slice(4).length;return 1*Math.pow(10,r)},getColorFromString:function(e){return this.intToRGB(this.hashCode(e))},intToRGB:function(e){var t=(16777215&e).toString(16).toUpperCase();return"00000".substring(0,6-t.length)+t},hashCode:function(e){for(var t=0,r=0;r<e.length;r+=1)t=e.charCodeAt(r)+((t<<5)-t);return t},throttledEventListener:function(e,t,r,n){var o=!1,i=function(){o||(o=!0,window.requestAnimationFrame((function(){r.call(n),o=!1})))};return e.addEventListener(t,i),function(){e.removeEventListener(t,i)}},getSnapshotForElement:function(t){return e(r.mark((function e(){var n,o,i,a;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=window.document.getElementById(t)){e.next=3;break}return e.abrupt("return",null);case 3:return o=n.clientHeight,i=n.clientWidth,e.next=6,c(n,{height:o,width:i,logging:!1});case 6:return a=e.sent,e.abrupt("return",a.toDataURL());case 8:case"end":return e.stop()}}),e)})))()},getAssetStatusColor:function(e){return"active"===e?w:"complete"===e?N:"paused"===e?b:"idle"===e||"unknown"===e?g:v},closest:function(e,t){return e.reduce((function(e,r){return Math.abs(r-t)<Math.abs(e-t)?r:e}))},mathMax:function(e,t){return Number.isFinite(e)?Number.isFinite(t)?Math.max(e,t):e:t},mathMin:function(e,t){return Number.isFinite(e)?Number.isFinite(t)?Math.min(e,t):e:t},getOperationByType:function(e){return Object.values(h).find((function(t){return t.value===e||d}))},getUserFullName:function(e){return e?"".concat(e.first_name," ").concat(e.last_name):""},getNameInitials:function(e){return e.split(" ").slice(0,2).map((function(e){return e.substr(0,1)})).join("")},getS3BucketName:function(){return"development"===process.env.REACT_APP_ENVIRONMENT||"qa"===process.env.REACT_APP_ENVIRONMENT?"corva-files-qa":"corva-files"},getS3FileUrl:function(e,t){return"https://".concat(e,".s3.amazonaws.com/").concat(t)},getFileNameWithExtensionFromPath:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.split("?")[0].replace(/^.*[\\/]/,"")},hexToRgbA:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=o(e).rgba();return r[r.length-1]=t,"rgba(".concat(r.join(","),")")},truncateString:function(e,t){return e.length>t?"".concat(e.substr(0,t-1),"…"):e},copyToClipboard:function(e){if(navigator.clipboard)navigator.clipboard.writeText(e);else{var t=document.createElement("textarea");t.textContent=e,document.body.appendChild(t);var r=document.getSelection(),n=document.createRange();n.selectNode(t),r.removeAllRanges(),r.addRange(n),document.execCommand("copy"),r.removeAllRanges(),document.body.removeChild(t)}}};window.getSnapshotForElement=F.getSnapshotForElement;export{F as default};
|