UNPKG

16.8 kBJavaScriptView Raw
1/*! For license information please see objectexporter.min.js.LICENSE.txt */
2(()=>{var e={"./src/js/csv.js":(e,t,o)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}o.r(t),o.d(t,{default:()=>n});const n={export:function(e){!function(e,t,o,n){if(e)if("object"!==r(e[0]))t.unshift(e);else{for(var i={},a=0;a<e.length;a++)i[e[a].name]=e[a].alias;t.unshift(i)}var s=function(e,t){for(var o="object"!==r(e)?JSON.parse(e):e,n="",i=0;i<o.length;i++){var a="";for(var s in o[i])a+=o[i][s]+t;n+=(a=a.substring(0,a.length-1))+"\r\n"}return n}(JSON.stringify(t),n),l=o+".csv",d=new Blob([s],{type:"text/csv;charset=utf-8;"});if(navigator.msSaveBlob)navigator.msSaveBlob(d,l);else{var c=document.createElement("a");if(void 0!==c.download){var u=URL.createObjectURL(d);c.setAttribute("href",u),c.setAttribute("download",l),c.style.visibility="hidden",document.body.appendChild(c),c.click(),document.body.removeChild(c)}}}(e.headers,e.exportable,e.fileName,e.columnSeparator)}}},"./src/js/doc.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>i});var r=o("./node_modules/file-saver/dist/FileSaver.min.js"),n=o("./src/js/el.js");const i={export:function(e){!function(e,t,o,i,a,s){for(var l="<html><body>"+(0,n.htmlTblCreater)("doc",e,t,i,a,s)+"</body></html>",d=new Uint8Array(l.length),c=0;c<l.length;c++)d[c]=l.charCodeAt(c);var u=new Blob([d],{type:"text/html"});(0,r.saveAs)(u,o+".doc")}(e.headers,e.exportable,e.fileName,e.headerStyle,e.cellStyle,e.repeatHeader)}}},"./src/js/el.js":(e,t,o)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t,o,n,i,a){var s='<table style="border-collapse: collapse;" width="100%;">';!0===a&&(s+="<thead>");var l=0;if("object"!==r(t[0])){s+="<tr>";for(var d=0;d<t.length;d++)s+='<th style="'+n+'" >'+t[d]+"</th>";s+="</tr>",!0===a&&(s+="</thead>");for(var c=0;c<o.length;c++){s+='<tr style="'+i+'">';for(var u=function(r){var n=o[c][Object.keys(o[c])[r]];!0===/<[a-z][\s\S]*>/i.test(n)?s+=n:s+='<td style="'+i+'" '+("csv"===e.toLowerCase()?'width="'+t[r].flex/l*100+'%;"':"")+" >"+n+"</td>"},f=0;f<Object.keys(o[c]).length-1;f++)u(f);s+="</tr>"}s+="</table>"}else{for(var p=function(e){l+="flex"in t[e]?t[e].flex:1},m=0;m<t.length;m++)p(m);s+="<tr>";for(var h=0;h<t.length;h++)s+='<th style="'+n+'" width="'+t[h].flex/l*100+'%;" >'+t[h].alias+"</th>";s+="</tr>",!0===a&&(s+="</thead>");for(var b=0;b<o.length;b++){s+='<tr style="'+i+'">';for(var y=function(r){var n=o[b][t[r].name];!0===/<[a-z][\s\S]*>/i.test(n)?s+=n:s+='<td style="'+i+'" '+("csv"===e.toLowerCase()?'width="'+t[r].flex/l*100+'%;"':"")+" >"+n+"</td>"},v=0;v<t.length;v++)y(v);s+="</tr>"}}return s}o.r(t),o.d(t,{htmlTblCreater:()=>n})},"./src/js/html.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>i});var r=o("./src/js/placeholder.js"),n=o("./node_modules/detect-browser/es/index.js").detect;const i={export:function(e){var t=n(),o=document.getElementById(e.exportable);if(void 0===o)throw new Error("There is no DOM object available for the requested id.");var i=r.default.generateFrame(e,o.innerHTML);document.getElementById("jsObjExporterFrameId")&&document.getElementById("jsObjExporterFrameId").remove(),document.getElementsByTagName("body")[0].appendChild(i);var a=document.getElementById("jsObjExporterFrameId");i.onload=function(){a.focus(),"edge"===t.name||"ie"===t.name?a.contentWindow.document.execCommand("print",!1,null):a.contentWindow.print()}}}},"./src/js/init.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>d});var r=o("./src/js/csv.js"),n=o("./src/js/xls.js"),i=o("./src/js/pdf.js"),a=o("./src/js/doc.js"),s=o("./src/js/html.js");function l(e){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l(e)}const d={init:function(){var e={type:"object",headers:null,exportable:null,fileName:"export",headerStyle:"font-size:16px; font-weight:bold;",cellStyle:"font-size:14px;",sheetName:"worksheet",documentTitle:"test document title",documentTitleStyle:"color:red;",repeatHeader:!0,columnSeparator:","},t=arguments[0];if(void 0===t)throw new Error("obj2csv expects at least 1 exportable!");if("object"!==l(t))throw new Error('Unexpected argument type! Expected "object", got '+l(t));if(e.exportable=t.exportable,e.type=void 0!==t.type?t.type:e.type,e.headers=void 0!==t.headers?t.headers:e.headers,e.fileName=void 0!==t.fileName?t.fileName:e.fileName,e.headerStyle=void 0!==t.headerStyle?t.headerStyle:e.headerStyle,e.cellStyle=void 0!==t.cellStyle?t.cellStyle:e.cellStyle,e.sheetName=void 0!==t.sheetName?t.sheetName:e.sheetName,e.documentTitle=void 0!==t.documentTitle?t.documentTitle:e.documentTitle,e.documentTitleStyle=void 0!==t.documentTitleStyle?t.documentTitleStyle:e.documentTitleStyle,e.repeatHeader=void 0!==t.repeatHeader?t.repeatHeader:e.repeatHeader,e.columnSeparator=void 0!==t.columnSeparator?t.columnSeparator:e.columnSeparator,!e.exportable)throw new Error("Invalid exportable!");if(!e.type||"string"!=typeof e.type)throw new Error("Invalid exportable type! only string type is acceptable!");if(-1===["csv","xls","pdf","doc","html"].indexOf(e.type.toLowerCase()))throw new Error('Invalid exportable type. Available types are "CSV", "XLS", "pdf" and "DOC".');if("boolean"!=typeof e.repeatHeader&&void 0!==e.repeatHeader)throw new Error('Invalid value for the repeat header parameter. Available types are "true" and "false".');switch(e.type){case"csv":r.default.export(e);break;case"xls":n.default.export(e);break;case"pdf":i.default.export(e);break;case"doc":a.default.export(e);break;case"html":s.default.export(e)}}}},"./src/js/pdf.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>i});var r=o("./src/js/el.js"),n=o("./node_modules/detect-browser/es/index.js").detect;const i={export:function(e){!function(e,t,o,i,a,s,l){var d=document.createElement("iframe");d.setAttribute("style","visibility: hidden; height: 0; width: 0; position: absolute;"),d.setAttribute("id","objectExporterPrintableBodyId"),d.srcdoc="<html></html>",document.getElementsByTagName("body")[0].appendChild(d);var c=document.getElementById("objectExporterPrintableBodyId");d.onload=function(){var d=n(),u=c.contentWindow||c.contentDocument;u.document&&(u=u.document);var f='<span style="'+t+'">'+e+"</span><br>";f+=(0,r.htmlTblCreater)("pdf",o,i,a,s,l),u.body.innerHTML=f;var p=document.createElement("style");p.innerHTML="",u.head.appendChild(p),c.focus(),"edge"===d.name||"ie"===d.name?c.contentWindow.document.execCommand("print",!1,null):c.contentWindow.print()}}(e.documentTitle,e.documentTitleStyle,e.headers,e.exportable,e.headerStyle,e.cellStyle,e.repeatHeader)}}},"./src/js/placeholder.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>r});const r={generateFrame:function(e,t){var o=document.createElement("iframe");return o.setAttribute("style","visibility: hidden; height: 0; width: 0; position: absolute;"),o.setAttribute("id","jsObjExporterFrameId"),o.srcdoc="</head><body>"+t+"</body></html>",o}}},"./src/js/xls.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>i});var r=o("./src/js/el.js"),n=o("./node_modules/detect-browser/es/index.js").detect;const i={export:function(e){!function(e,t,o,i,l,d,c,u){var f,p='<span style="'+u+'">'+c+"</span><br>",m={worksheet:d,table:p+=(0,r.htmlTblCreater)("xls",e,t,i,l,!1)},h=document.createElement("a"),b=o+".xls";h.setAttribute("href",a+function(e){return window.btoa(unescape(encodeURIComponent(e)))}((f=m,s.replace(/{(\w+)}/g,(function(e,t){return f[t]}))))),h.setAttribute("download",b),h.style.visibility="hidden";var y=n();if("edge"===y.name||"ie"===y.name){if(window.navigator.msSaveBlob){var v=new Blob([p],{type:"data:application/vnd.ms-excel;"});navigator.msSaveBlob(v,b)}}else document.body.appendChild(h),h.click(),document.body.removeChild(h)}(e.headers,e.exportable,e.fileName,e.headerStyle,e.cellStyle,e.sheetName,e.documentTitle,e.documentTitleStyle)}};var a="data:application/vnd.ms-excel;base64,",s='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head>\x3c!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e<meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'},"./node_modules/detect-browser/es/index.js":(e,t,o)=>{"use strict";o.r(t),o.d(t,{BrowserInfo:()=>n,NodeInfo:()=>i,SearchBotDeviceInfo:()=>a,BotInfo:()=>s,ReactNativeInfo:()=>l,detect:()=>f,browserName:()=>m,parseUserAgent:()=>h,detectOS:()=>b,getNodeVersion:()=>y});var r=function(e,t,o){if(o||2===arguments.length)for(var r,n=0,i=t.length;n<i;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))},n=function(e,t,o){this.name=e,this.version=t,this.os=o,this.type="browser"},i=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},a=function(e,t,o,r){this.name=e,this.version=t,this.os=o,this.bot=r,this.type="bot-device"},s=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},l=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},d=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,c=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],u=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function f(e){return e?h(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new l:"undefined"!=typeof navigator?h(navigator.userAgent):y()}function p(e){return""!==e&&c.reduce((function(t,o){var r=o[0],n=o[1];if(t)return t;var i=n.exec(e);return!!i&&[r,i]}),!1)}function m(e){var t=p(e);return t?t[0]:null}function h(e){var t=p(e);if(!t)return null;var o=t[0],i=t[1];if("searchbot"===o)return new s;var l=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);l?l.length<3&&(l=r(r([],l,!0),function(e){for(var t=[],o=0;o<e;o++)t.push("0");return t}(3-l.length),!0)):l=[];var c=l.join("."),u=b(e),f=d.exec(e);return f&&f[1]?new a(o,c,u,f[1]):new n(o,c,u)}function b(e){for(var t=0,o=u.length;t<o;t++){var r=u[t],n=r[0];if(r[1].exec(e))return n}return null}function y(){return"undefined"!=typeof process&&process.version?new i(process.version.slice(1)):null}},"./node_modules/file-saver/dist/FileSaver.min.js":function(e,t,o){var r;void 0===(r=function(){"use strict";function t(e,t,o){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){s(r.response,t,o)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function n(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(o){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof o.g&&o.g.global===o.g?o.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),s=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,o,a){var s=i.URL||i.webkitURL,l=document.createElement("a");o=o||e.name||"download",l.download=o,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?n(l):r(l.href)?t(e,o,a):n(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){n(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,o,i){if(o=o||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}(e,i),o);else if(r(e))t(e,o,i);else{var a=document.createElement("a");a.href=e,a.target="_blank",setTimeout((function(){n(a)}))}}:function(e,o,r,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return t(e,o,r);var s="application/octet-stream"===e.type,l=/constructor/i.test(i.HTMLElement)||i.safari,d=/CriOS\/[\d]+/.test(navigator.userAgent);if((d||s&&l||a)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var e=c.result;e=d?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=e:location=e,n=null},c.readAsDataURL(e)}else{var u=i.URL||i.webkitURL,f=u.createObjectURL(e);n?n.location=f:location.href=f,n=null,setTimeout((function(){u.revokeObjectURL(f)}),4e4)}});i.saveAs=s.saveAs=s,e.exports=s}.apply(t,[]))||(e.exports=r)}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{"use strict";o.r(r),o.d(r,{default:()=>t});var e=o("./src/js/init.js").default.init;"undefined"!=typeof window&&(window.objectExporter=e);const t=e})()})();
3//# sourceMappingURL=objectexporter.min.js.map
\No newline at end of file