diff --git a/README.md b/README.md index 9fd5b57..dae1cd5 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ $ npm install tableexport #### [CDNjs](https://cdnjs.com/libraries/TableExport) | | uncompressed | compressed | | :------: | :----------: | :--------: | -| __CSS__ | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/css/tableexport.css) | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/css/tableexport.min.css) | -| __JS__ | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/js/tableexport.js) | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/js/tableexport.min.js) | -| __Images__ | — | [🔗xlsx](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/img/xlsx.svg)[🔗xls](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/img/xls.svg)[🔗csv](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/img/csv.svg)[🔗txt](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.5/img/txt.svg) | +| __CSS__ | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/css/tableexport.css) | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/css/tableexport.min.css) | +| __JS__ | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/js/tableexport.js) | [🔗](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/js/tableexport.min.js) | +| __Images__ | — | [🔗xlsx](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/img/xlsx.svg)[🔗xls](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/img/xls.svg)[🔗csv](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/img/csv.svg)[🔗txt](https://cdnjs.cloudflare.com/ajax/libs/TableExport/5.0.6/img/txt.svg) | #### [unpkg](https://unpkg.com/#/) diff --git a/bower.json b/bower.json index bd1485c..6dc0425 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tableexport.js", - "version": "5.0.5", + "version": "5.0.6", "authors": [ "clarketm " ], diff --git a/dist/css/tableexport.css b/dist/css/tableexport.css index f1535ed..b0d36ad 100644 --- a/dist/css/tableexport.css +++ b/dist/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/css/tableexport.min.css b/dist/css/tableexport.min.css index 892ac75..e6f3677 100644 --- a/dist/css/tableexport.min.css +++ b/dist/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * diff --git a/dist/js/tableexport.js b/dist/js/tableexport.js index 093dd77..3f7a6cb 100644 --- a/dist/js/tableexport.js +++ b/dist/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * @@ -162,7 +162,7 @@ * Version. * @memberof TableExport.prototype */ - version: "5.0.5", + version: "5.0.6", /** * Default library options. * @memberof TableExport.prototype diff --git a/dist/js/tableexport.min.js b/dist/js/tableexport.min.js index cb32087..c4d6eba 100644 --- a/dist/js/tableexport.min.js +++ b/dist/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,r){if("function"==typeof define&&define.amd)define(function(t){var e;try{e=t("jquery")}catch(t){}return r(e,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var e;try{e=require("jquery")}catch(t){}module.exports=r(e,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=r(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(e,s,l,c){"use strict";var o=function(t,e){var a=this;if(!t)return S('"selectors" is required. \nUsage: TableExport(selectors, options)');if(!a)return new o(t,e);a.settings=y({},a.defaults,e),a.selectors=C(t);var i=a.settings;i.ignoreRows=i.ignoreRows instanceof Array?i.ignoreRows:[i.ignoreRows],i.ignoreCols=i.ignoreCols instanceof Array?i.ignoreCols:[i.ignoreCols],i.ignoreCSS=a.ignoreCSS instanceof Array?a.ignoreCSS:[a.ignoreCSS],i.emptyCSS=a.emptyCSS instanceof Array?a.emptyCSS:[a.emptyCSS],i.formatValue=a.formatValue.bind(this,i.trimWhitespace),i.bootstrapSettings=function(t,e,r){var o={};o.bootstrapSpacing=t?(o.bootstrapClass=e[0]+" ",o.bootstrapTheme=e[1]+" ",e[2]+" "):(o.bootstrapClass=r+" ",o.bootstrapTheme="","");return o}(i.bootstrap,a.bootstrapConfig,a.defaultButton);var s={};a.getExportData=function(){return s},a.selectors.forEach(function(r){var o={};o.rows=C(r.querySelectorAll("tbody > tr")),o.rows=i.headers?C(r.querySelectorAll("thead > tr")).concat(o.rows):o.rows,o.rows=i.footers?o.rows.concat(C(r.querySelectorAll("tfoot > tr"))):o.rows,o.thAdj=i.headers?r.querySelectorAll("thead > tr").length:0,o.filename="id"===i.filename?r.getAttribute("id")?r.getAttribute("id"):a.defaultFilename:i.filename?i.filename:a.defaultFilename,o.uuid=b(r),o.checkCaption=function(t){var e=r.querySelectorAll("caption."+a.defaultCaptionClass);e.length?e[0].appendChild(t):((e=document.createElement("caption")).className=i.bootstrapSettings.bootstrapSpacing+a.defaultCaptionClass,e.style.cssText="caption-side: "+i.position,e.appendChild(t),r.insertBefore(e,r.firstChild))},o.setExportData=function(t){var e=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);s[o.uuid]=s[o.uuid]||{},s[o.uuid][r]=JSON.parse(e)},o.rcMap=(new p).build(o,i);var n=h.reduce(function(t,e){return t[e]=0,t},{});i.formats.forEach(function(t){return e=t,~h.indexOf(e)?function(t){var e;switch(t){case m.TXT:case m.CSV:case m.XLS:e=!0;break;default:e=d(t)}return e}(t)?void(n[t]||(o.setExportData(a.exporters.build.call(a,o,t)),n[t]++)):S('"'+t+'" requires "js-xlsx".'):S('"'+t+'" is not a valid format. \nFormats: '+h.join(", "));var e})});var r=document.querySelectorAll("button["+a.storageKey+"]");return n(r,"click",a.downloadHandler,a),a};o.prototype={version:"5.0.5",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",defaultCaptionClass:"tableexport-caption",defaultNamespace:"tableexport-",tableKey:"tableexport-key",storageKey:"tableexport-id",ignoreCSS:".tableexport-ignore",emptyCSS:".tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},boolean:{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,n){var a=this,i=a.settings,e=a.formatConfig[n],s=e.separator,l=t.rcMap,r=C(t.rows).map(function(t,o){return l.isIgnore(o)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o)?l.handleRowColMapProp(l.TYPE.EMPTY):C(t.querySelectorAll("th, td")).map(function(t,e){var r=function(t){if(d(n))return{v:i.formatValue(t.textContent),t:a.getType(t.className)};switch(n){case m.CSV:return'"'+i.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return i.formatValue(t.textContent)}}(t);return l.isIgnore(o,e)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o,e)?l.handleRowColMapProp(l.TYPE.EMPTY):l.handleRowColMapProp(l.TYPE.DEFAULT,o,e,n,r,s)}).processCols(n,s)}).processRows(n,a.rowDel),o=JSON.stringify({data:r,filename:t.filename,mimeType:e.mimeType,fileExtension:e.fileExtension,merges:l.merges}),p=v({uuid:t.uuid,type:n});return i.exportButtons&&t.checkCaption(a.createObjButton(p,o,e.buttonContent,e.defaultClass,i.bootstrapSettings)),u.getInstance().setItem(p,o,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("type","button"),a.setAttribute(this.storageKey,t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){var e=this;return String(t).replace(/[&<>'\/]/g,function(t){return e.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=this.typeConfig;return~t.indexOf(e.string.defaultClass)?g.STRING:~t.indexOf(e.number.defaultClass)?g.NUMBER:~t.indexOf(e.boolean.defaultClass)?g.BOOLEAN:~t.indexOf(e.date.defaultClass)?g.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=(Date.parse(t)-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(r)},createSheet:function(t,e){for(var r={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=this.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){o.s.r>a&&(o.s.r=a),o.s.c>i&&(o.s.c=i),o.e.r tr")),o.rows=i.headers?C(r.querySelectorAll("thead > tr")).concat(o.rows):o.rows,o.rows=i.footers?o.rows.concat(C(r.querySelectorAll("tfoot > tr"))):o.rows,o.thAdj=i.headers?r.querySelectorAll("thead > tr").length:0,o.filename="id"===i.filename?r.getAttribute("id")?r.getAttribute("id"):a.defaultFilename:i.filename?i.filename:a.defaultFilename,o.uuid=b(r),o.checkCaption=function(t){var e=r.querySelectorAll("caption."+a.defaultCaptionClass);e.length?e[0].appendChild(t):((e=document.createElement("caption")).className=i.bootstrapSettings.bootstrapSpacing+a.defaultCaptionClass,e.style.cssText="caption-side: "+i.position,e.appendChild(t),r.insertBefore(e,r.firstChild))},o.setExportData=function(t){var e=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);s[o.uuid]=s[o.uuid]||{},s[o.uuid][r]=JSON.parse(e)},o.rcMap=(new p).build(o,i);var n=h.reduce(function(t,e){return t[e]=0,t},{});i.formats.forEach(function(t){return e=t,~h.indexOf(e)?function(t){var e;switch(t){case m.TXT:case m.CSV:case m.XLS:e=!0;break;default:e=d(t)}return e}(t)?void(n[t]||(o.setExportData(a.exporters.build.call(a,o,t)),n[t]++)):S('"'+t+'" requires "js-xlsx".'):S('"'+t+'" is not a valid format. \nFormats: '+h.join(", "));var e})});var r=document.querySelectorAll("button["+a.storageKey+"]");return n(r,"click",a.downloadHandler,a),a};o.prototype={version:"5.0.6",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",defaultCaptionClass:"tableexport-caption",defaultNamespace:"tableexport-",tableKey:"tableexport-key",storageKey:"tableexport-id",ignoreCSS:".tableexport-ignore",emptyCSS:".tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},boolean:{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,n){var a=this,i=a.settings,e=a.formatConfig[n],s=e.separator,l=t.rcMap,r=C(t.rows).map(function(t,o){return l.isIgnore(o)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o)?l.handleRowColMapProp(l.TYPE.EMPTY):C(t.querySelectorAll("th, td")).map(function(t,e){var r=function(t){if(d(n))return{v:i.formatValue(t.textContent),t:a.getType(t.className)};switch(n){case m.CSV:return'"'+i.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return i.formatValue(t.textContent)}}(t);return l.isIgnore(o,e)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o,e)?l.handleRowColMapProp(l.TYPE.EMPTY):l.handleRowColMapProp(l.TYPE.DEFAULT,o,e,n,r,s)}).processCols(n,s)}).processRows(n,a.rowDel),o=JSON.stringify({data:r,filename:t.filename,mimeType:e.mimeType,fileExtension:e.fileExtension,merges:l.merges}),p=v({uuid:t.uuid,type:n});return i.exportButtons&&t.checkCaption(a.createObjButton(p,o,e.buttonContent,e.defaultClass,i.bootstrapSettings)),u.getInstance().setItem(p,o,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("type","button"),a.setAttribute(this.storageKey,t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){var e=this;return String(t).replace(/[&<>'\/]/g,function(t){return e.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=this.typeConfig;return~t.indexOf(e.string.defaultClass)?g.STRING:~t.indexOf(e.number.defaultClass)?g.NUMBER:~t.indexOf(e.boolean.defaultClass)?g.BOOLEAN:~t.indexOf(e.date.defaultClass)?g.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=(Date.parse(t)-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(r)},createSheet:function(t,e){for(var r={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=this.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){o.s.r>a&&(o.s.r=a),o.s.c>i&&(o.s.c=i),o.e.r - +

Arabic

@@ -48,4 +48,4 @@

Arabic

- \ No newline at end of file + diff --git a/examples/bootstrap.html b/examples/bootstrap.html index dfa1747..716023d 100644 --- a/examples/bootstrap.html +++ b/examples/bootstrap.html @@ -10,7 +10,7 @@ - +

Bootstrap @@ -85,4 +85,4 @@

Bootstrap - \ No newline at end of file + diff --git a/examples/cell-data-types.html b/examples/cell-data-types.html index 6940de9..19b6d78 100644 --- a/examples/cell-data-types.html +++ b/examples/cell-data-types.html @@ -9,7 +9,7 @@ - +

Cell data type

@@ -60,7 +60,7 @@

Cell data type

- \ No newline at end of file + diff --git a/examples/exportButtons.html b/examples/exportButtons.html index 9a2abcb..efab998 100644 --- a/examples/exportButtons.html +++ b/examples/exportButtons.html @@ -9,7 +9,7 @@ - +

ExportButtons @@ -171,4 +171,4 @@

ExportButtons - \ No newline at end of file + diff --git a/examples/filename.html b/examples/filename.html index f71c4ca..f87e0f4 100644 --- a/examples/filename.html +++ b/examples/filename.html @@ -9,7 +9,7 @@ - +

Filename- string diff --git a/examples/formats-xlsx-xls-csv-txt.html b/examples/formats-xlsx-xls-csv-txt.html index 36c7d64..afc50a3 100644 --- a/examples/formats-xlsx-xls-csv-txt.html +++ b/examples/formats-xlsx-xls-csv-txt.html @@ -8,7 +8,7 @@ - +

Formats @@ -129,4 +129,4 @@

Formats - \ No newline at end of file + diff --git a/examples/headers_footers.html b/examples/headers_footers.html index 36399bd..6b85ac0 100644 --- a/examples/headers_footers.html +++ b/examples/headers_footers.html @@ -9,7 +9,7 @@ - +

Headers diff --git a/examples/ignore-row-cols-cells.html b/examples/ignore-row-cols-cells.html index 50e40be..acaf0bf 100644 --- a/examples/ignore-row-cols-cells.html +++ b/examples/ignore-row-cols-cells.html @@ -9,7 +9,7 @@ - +

IgnoreRows diff --git a/examples/position.html b/examples/position.html index ccaa274..9fd4f77 100644 --- a/examples/position.html +++ b/examples/position.html @@ -9,7 +9,7 @@ - +

Position @@ -77,4 +77,4 @@

Position - \ No newline at end of file + diff --git a/examples/rowspan-colspan.html b/examples/rowspan-colspan.html index 46eb911..0035a3f 100644 --- a/examples/rowspan-colspan.html +++ b/examples/rowspan-colspan.html @@ -11,7 +11,7 @@ - +

Rowspan / Colspan

@@ -191,4 +191,4 @@

Colspan

- \ No newline at end of file + diff --git a/examples/unicode-emoji.html b/examples/unicode-emoji.html index e2d9c93..601e64c 100644 --- a/examples/unicode-emoji.html +++ b/examples/unicode-emoji.html @@ -9,7 +9,7 @@ - +

Emoji

@@ -44,7 +44,7 @@

Emoji

- \ No newline at end of file + diff --git a/examples/update_reset_remove.html b/examples/update_reset_remove.html index 34b31d4..7fc02ec 100644 --- a/examples/update_reset_remove.html +++ b/examples/update_reset_remove.html @@ -9,7 +9,7 @@ - +

Update check the filename of the next exported file. Do you notice anything different?

diff --git a/examples/whitespace.html b/examples/whitespace.html index 3f68050..4a662dc 100644 --- a/examples/whitespace.html +++ b/examples/whitespace.html @@ -9,7 +9,7 @@ - +

Whitespace diff --git a/package.json b/package.json index 840ad92..bcca18d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tableexport", - "version": "5.0.5", + "version": "5.0.6", "author": "Travis Clarke (https://www.travismclarke.com/)", "description": "The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files", "main": "dist/js/tableexport.js", diff --git a/src/stable/css/tableexport.css b/src/stable/css/tableexport.css index f1535ed..b0d36ad 100644 --- a/src/stable/css/tableexport.css +++ b/src/stable/css/tableexport.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/css/tableexport.min.css b/src/stable/css/tableexport.min.css index 892ac75..e6f3677 100644 --- a/src/stable/css/tableexport.min.css +++ b/src/stable/css/tableexport.min.css @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * diff --git a/src/stable/js/tableexport.js b/src/stable/js/tableexport.js index 093dd77..3f7a6cb 100644 --- a/src/stable/js/tableexport.js +++ b/src/stable/js/tableexport.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * @@ -162,7 +162,7 @@ * Version. * @memberof TableExport.prototype */ - version: "5.0.5", + version: "5.0.6", /** * Default library options. * @memberof TableExport.prototype diff --git a/src/stable/js/tableexport.min.js b/src/stable/js/tableexport.min.js index cb32087..c4d6eba 100644 --- a/src/stable/js/tableexport.min.js +++ b/src/stable/js/tableexport.min.js @@ -1,5 +1,5 @@ /*! - * TableExport.js v5.0.5 (https://www.travismclarke.com) + * TableExport.js v5.0.6 (https://www.travismclarke.com) * * Copyright (c) 2018 - Travis Clarke - https://www.travismclarke.com * @@ -16,4 +16,4 @@ * limitations under the License. * */ -!function(t,r){if("function"==typeof define&&define.amd)define(function(t){var e;try{e=t("jquery")}catch(t){}return r(e,t("blobjs"),t("file-saverjs"),t("xlsx"))});else if("object"==typeof exports&&"string"!=typeof exports.nodeName){var e;try{e=require("jquery")}catch(t){}module.exports=r(e,require("blobjs"),require("file-saverjs"),require("xlsx"))}else t.TableExport=r(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(e,s,l,c){"use strict";var o=function(t,e){var a=this;if(!t)return S('"selectors" is required. \nUsage: TableExport(selectors, options)');if(!a)return new o(t,e);a.settings=y({},a.defaults,e),a.selectors=C(t);var i=a.settings;i.ignoreRows=i.ignoreRows instanceof Array?i.ignoreRows:[i.ignoreRows],i.ignoreCols=i.ignoreCols instanceof Array?i.ignoreCols:[i.ignoreCols],i.ignoreCSS=a.ignoreCSS instanceof Array?a.ignoreCSS:[a.ignoreCSS],i.emptyCSS=a.emptyCSS instanceof Array?a.emptyCSS:[a.emptyCSS],i.formatValue=a.formatValue.bind(this,i.trimWhitespace),i.bootstrapSettings=function(t,e,r){var o={};o.bootstrapSpacing=t?(o.bootstrapClass=e[0]+" ",o.bootstrapTheme=e[1]+" ",e[2]+" "):(o.bootstrapClass=r+" ",o.bootstrapTheme="","");return o}(i.bootstrap,a.bootstrapConfig,a.defaultButton);var s={};a.getExportData=function(){return s},a.selectors.forEach(function(r){var o={};o.rows=C(r.querySelectorAll("tbody > tr")),o.rows=i.headers?C(r.querySelectorAll("thead > tr")).concat(o.rows):o.rows,o.rows=i.footers?o.rows.concat(C(r.querySelectorAll("tfoot > tr"))):o.rows,o.thAdj=i.headers?r.querySelectorAll("thead > tr").length:0,o.filename="id"===i.filename?r.getAttribute("id")?r.getAttribute("id"):a.defaultFilename:i.filename?i.filename:a.defaultFilename,o.uuid=b(r),o.checkCaption=function(t){var e=r.querySelectorAll("caption."+a.defaultCaptionClass);e.length?e[0].appendChild(t):((e=document.createElement("caption")).className=i.bootstrapSettings.bootstrapSpacing+a.defaultCaptionClass,e.style.cssText="caption-side: "+i.position,e.appendChild(t),r.insertBefore(e,r.firstChild))},o.setExportData=function(t){var e=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);s[o.uuid]=s[o.uuid]||{},s[o.uuid][r]=JSON.parse(e)},o.rcMap=(new p).build(o,i);var n=h.reduce(function(t,e){return t[e]=0,t},{});i.formats.forEach(function(t){return e=t,~h.indexOf(e)?function(t){var e;switch(t){case m.TXT:case m.CSV:case m.XLS:e=!0;break;default:e=d(t)}return e}(t)?void(n[t]||(o.setExportData(a.exporters.build.call(a,o,t)),n[t]++)):S('"'+t+'" requires "js-xlsx".'):S('"'+t+'" is not a valid format. \nFormats: '+h.join(", "));var e})});var r=document.querySelectorAll("button["+a.storageKey+"]");return n(r,"click",a.downloadHandler,a),a};o.prototype={version:"5.0.5",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",defaultCaptionClass:"tableexport-caption",defaultNamespace:"tableexport-",tableKey:"tableexport-key",storageKey:"tableexport-id",ignoreCSS:".tableexport-ignore",emptyCSS:".tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},boolean:{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,n){var a=this,i=a.settings,e=a.formatConfig[n],s=e.separator,l=t.rcMap,r=C(t.rows).map(function(t,o){return l.isIgnore(o)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o)?l.handleRowColMapProp(l.TYPE.EMPTY):C(t.querySelectorAll("th, td")).map(function(t,e){var r=function(t){if(d(n))return{v:i.formatValue(t.textContent),t:a.getType(t.className)};switch(n){case m.CSV:return'"'+i.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return i.formatValue(t.textContent)}}(t);return l.isIgnore(o,e)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o,e)?l.handleRowColMapProp(l.TYPE.EMPTY):l.handleRowColMapProp(l.TYPE.DEFAULT,o,e,n,r,s)}).processCols(n,s)}).processRows(n,a.rowDel),o=JSON.stringify({data:r,filename:t.filename,mimeType:e.mimeType,fileExtension:e.fileExtension,merges:l.merges}),p=v({uuid:t.uuid,type:n});return i.exportButtons&&t.checkCaption(a.createObjButton(p,o,e.buttonContent,e.defaultClass,i.bootstrapSettings)),u.getInstance().setItem(p,o,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("type","button"),a.setAttribute(this.storageKey,t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){var e=this;return String(t).replace(/[&<>'\/]/g,function(t){return e.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=this.typeConfig;return~t.indexOf(e.string.defaultClass)?g.STRING:~t.indexOf(e.number.defaultClass)?g.NUMBER:~t.indexOf(e.boolean.defaultClass)?g.BOOLEAN:~t.indexOf(e.date.defaultClass)?g.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=(Date.parse(t)-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(r)},createSheet:function(t,e){for(var r={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=this.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){o.s.r>a&&(o.s.r=a),o.s.c>i&&(o.s.c=i),o.e.r tr")),o.rows=i.headers?C(r.querySelectorAll("thead > tr")).concat(o.rows):o.rows,o.rows=i.footers?o.rows.concat(C(r.querySelectorAll("tfoot > tr"))):o.rows,o.thAdj=i.headers?r.querySelectorAll("thead > tr").length:0,o.filename="id"===i.filename?r.getAttribute("id")?r.getAttribute("id"):a.defaultFilename:i.filename?i.filename:a.defaultFilename,o.uuid=b(r),o.checkCaption=function(t){var e=r.querySelectorAll("caption."+a.defaultCaptionClass);e.length?e[0].appendChild(t):((e=document.createElement("caption")).className=i.bootstrapSettings.bootstrapSpacing+a.defaultCaptionClass,e.style.cssText="caption-side: "+i.position,e.appendChild(t),r.insertBefore(e,r.firstChild))},o.setExportData=function(t){var e=u.getInstance().getItem(t),r=t.substring(t.indexOf("-")+1);s[o.uuid]=s[o.uuid]||{},s[o.uuid][r]=JSON.parse(e)},o.rcMap=(new p).build(o,i);var n=h.reduce(function(t,e){return t[e]=0,t},{});i.formats.forEach(function(t){return e=t,~h.indexOf(e)?function(t){var e;switch(t){case m.TXT:case m.CSV:case m.XLS:e=!0;break;default:e=d(t)}return e}(t)?void(n[t]||(o.setExportData(a.exporters.build.call(a,o,t)),n[t]++)):S('"'+t+'" requires "js-xlsx".'):S('"'+t+'" is not a valid format. \nFormats: '+h.join(", "));var e})});var r=document.querySelectorAll("button["+a.storageKey+"]");return n(r,"click",a.downloadHandler,a),a};o.prototype={version:"5.0.6",defaults:{headers:!0,footers:!0,formats:["xlsx","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},CONSTANTS:{FORMAT:{XLSX:"xlsx",XLSM:"xlsm",XLSB:"xlsb",BIFF2:"biff2",XLS:"xls",CSV:"csv",TXT:"txt"},TYPE:{STRING:"s",NUMBER:"n",BOOLEAN:"b",DATE:"d"}},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",defaultCaptionClass:"tableexport-caption",defaultNamespace:"tableexport-",tableKey:"tableexport-key",storageKey:"tableexport-id",ignoreCSS:".tableexport-ignore",emptyCSS:".tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&","<":"<",">":">","'":"'","/":"/"},formatConfig:{xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xlsm:{defaultClass:"xlsm",buttonContent:"Export to xlsm",mimeType:"application/vnd.ms-excel.sheet.macroEnabled.main+xml",fileExtension:".xlsm"},xlsb:{defaultClass:"xlsb",buttonContent:"Export to xlsb",mimeType:"application/vnd.ms-excel.sheet.binary.macroEnabled.main",fileExtension:".xlsb"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls",enforceStrictRFC4180:!1},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv",enforceStrictRFC4180:!0},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt",enforceStrictRFC4180:!0}},typeConfig:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t)}},boolean:{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!/.*%/.test(t)&&!isNaN(Date.parse(t))}}},exporters:{build:function(t,n){var a=this,i=a.settings,e=a.formatConfig[n],s=e.separator,l=t.rcMap,r=C(t.rows).map(function(t,o){return l.isIgnore(o)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o)?l.handleRowColMapProp(l.TYPE.EMPTY):C(t.querySelectorAll("th, td")).map(function(t,e){var r=function(t){if(d(n))return{v:i.formatValue(t.textContent),t:a.getType(t.className)};switch(n){case m.CSV:return'"'+i.formatValue(t.textContent.replace(/"/g,'""'))+'"';default:return i.formatValue(t.textContent)}}(t);return l.isIgnore(o,e)?l.handleRowColMapProp(l.TYPE.IGNORE):l.isEmpty(o,e)?l.handleRowColMapProp(l.TYPE.EMPTY):l.handleRowColMapProp(l.TYPE.DEFAULT,o,e,n,r,s)}).processCols(n,s)}).processRows(n,a.rowDel),o=JSON.stringify({data:r,filename:t.filename,mimeType:e.mimeType,fileExtension:e.fileExtension,merges:l.merges}),p=v({uuid:t.uuid,type:n});return i.exportButtons&&t.checkCaption(a.createObjButton(p,o,e.buttonContent,e.defaultClass,i.bootstrapSettings)),u.getInstance().setItem(p,o,!0)}},createObjButton:function(t,e,r,o,n){var a=document.createElement("button");return a.setAttribute("type","button"),a.setAttribute(this.storageKey,t),a.className=n.bootstrapClass+n.bootstrapTheme+o,a.textContent=r,a},escapeHtml:function(t){var e=this;return String(t).replace(/[&<>'\/]/g,function(t){return e.entityMap[t]})},unescapeHtml:function(t){var e=String(t);for(var r in this.entityMap)e=e.replace(RegExp(this.entityMap[r],"g"),r);return e},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=this.typeConfig;return~t.indexOf(e.string.defaultClass)?g.STRING:~t.indexOf(e.number.defaultClass)?g.NUMBER:~t.indexOf(e.boolean.defaultClass)?g.BOOLEAN:~t.indexOf(e.date.defaultClass)?g.DATE:""},dateNum:function(t,e){e&&(t+=1462);var r=(Date.parse(t)-new Date(Date.UTC(1899,11,30)))/864e5;return Math.floor(r)},createSheet:function(t,e){for(var r={},o={s:{c:1e7,r:1e7},e:{c:0,r:0}},n=this.typeConfig,a=0;a!==t.length;++a)for(var i=0;i!==t[a].length;++i){o.s.r>a&&(o.s.r=a),o.s.c>i&&(o.s.c=i),o.e.r