@senlinz/import-export 0.1.0-beta.10 → 0.1.0-beta.12

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.
@@ -1,2 +1,2 @@
1
- import{p as t,H as e,h as o}from"./p-ddbe189c.js";import{g as n,i,a as s,b as a,h as c,j as r,k as d,E as l,c as f,d as u,e as p,f as b}from"./p-2f3be56b.js";import{d as m}from"./p-dd1bf849.js";import{d as h}from"./p-f7586df1.js";import{d as x}from"./p-c9904f6a.js";let y=!1;async function w(t,e){const o=E(t),n=async function(t,e){const o=[],n={};for(const t of e)n[t.key]=t.dataType;for(const e of t.rows){const t={};for(const o of e.columns)n[o.key]!=d.Number?t[o.key]=o.value:t[o.key]=parseFloat(o.value);o.push(t)}return o}(a(o,e),t.columns);return n}async function k(t){const e=`${t.name}.xlsx`,o=await async function(t){return b(E(t))}(t);g(o,e)}function g(t,e,o="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var n;const i="senlinzImportExportDownload";null===(n=document.querySelector(`#${i}`))||void 0===n||n.remove();const s=document.createElement("a");s.id=i,s.download=e;const a=new Blob([t],{type:o});s.href=URL.createObjectURL(a),s.click()}function E(t){var e,o,n=t.columns.map((t=>{const e=new c(t.key,t.name,t.width);return t.dataType&&e.setDataType(t.dataType),t.note&&e.setNote(t.note),t.allowedValues&&e.setAllowedValues(t.allowedValues),e}));return new r(t.name,t.sheetName,n,null!==(e=t.author)&&void 0!==e?e:"",function(t){if("string"==typeof t)return t;const e=t.getFullYear(),o=t.getMonth()+1,n=t.getDate(),i=t.getHours(),s=t.getMinutes(),a=t.getSeconds(),c=t=>t<10?`0${t}`:t.toString();return`${e}-${c(o)}-${c(n)} ${c(i)}:${c(s)}:${c(a)}`}(null!==(o=t.createTime)&&void 0!==o?o:new Date))}async function v(t,e){const o=await async function(t,e){const o=E(t),n=e.map((t=>{const e=o.columns.map((e=>{const o=t[e.key];return new l(e.key,null==o?"":o.toString())}));return new f(e)})),i=new u(n);return p(o,i)}(t,e);g(o,`${t.name}.xlsx`)}const D={zh:{hideDefinition:"隐藏定义",showDefinition:"显示定义",downloadTemplate:"下载模板",exportExcel:"导出Excel",importExcel:"导入Excel",downloadDefinition:"下载定义",preview:"预览",dataSource:"数据源",hideDataSource:"隐藏数据源",showDataSource:"显示数据源"},en:{hideDefinition:"Hide Definition",showDefinition:"Show Definition",downloadTemplate:"Download Template",exportExcel:"Export Excel",importExcel:"Import Excel",downloadDefinition:"Download Definition",preview:"Preview",dataSource:"Data Source",hideDataSource:"Hide Data Source",showDataSource:"Show Data Source"}},S=t(class extends e{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.toggleDefinitionVisibility=()=>{this.showDefinition=!this.showDefinition},this.toggleDataSourceVisibility=()=>{this.showDataSource=!this.showDataSource},this.importExcelHandler=async t=>{const e=await(o=t,new Promise(((t,e)=>{var n;let i=document.querySelector("#senlinzImportExportInput");i||(null===(n=document.querySelector("#senlinzImportExportInput"))||void 0===n||n.remove(),i=document.createElement("input"),i.id="senlinzImportExportInput",i.style.display="none",i.type="file",i.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",i.addEventListener("change",(function e(n){const s=n.target.files[0],a=new FileReader;a.onload=async()=>{const n=new Uint8Array(a.result),s=await w(o,n);i.removeEventListener("change",e),i.remove(),t(s)},a.readAsArrayBuffer(s)})),document.body.appendChild(i));const s=document.createElement("button");s.textContent="Import Excel",s.style.display="none",s.addEventListener("click",(()=>{i.click()})),document.body.appendChild(s),s.click(),s.removeEventListener("click",(()=>{i.click()})),document.body.removeChild(s)})));var o;this.data=e},this.handleDataSourceChange=t=>{const e=t.target;try{this.data=JSON.parse(e.value)}catch(t){console.log(t)}},this.definition=void 0,this.culture="en",this.data=[],this.showDefinition=!0,this.showDataSource=!1}componentWillLoad(){!function(){if(!y){const t=n(Uint8Array.from(atob(i),(t=>t.charCodeAt(0))));s({module:t}),y=!0}}()}render(){const t=D[this.culture];return o("div",{key:"9b80914f0440e8f10960ffd58c7e20bc27beb9ae",class:"import-export-studio"},o("div",{key:"5f61a5605d2ba737169f0e0549e8078b80f2e128",class:"operation"},o("button",{key:"4ec2f3ff61487e91a0f508c65c57b061b5316bf6",type:"text",class:"studio-button",onClick:this.toggleDefinitionVisibility},this.showDefinition?t.hideDefinition:t.showDefinition),o("button",{key:"31e3970572332e77a4ee111096c13509053a71a0",type:"text",class:"studio-button",onClick:()=>{return t=this.definition,void g(JSON.stringify(t,null,2),`${t.name}-definition.json`,"application/json");var t}},t.downloadDefinition),o("button",{key:"8b062e1c105b0a67f8fbf6a85b2ff6e4cbfa0825",type:"text",class:"studio-button",onClick:()=>k(this.definition)},t.downloadTemplate),o("button",{key:"6ee2da16c955c8f4b4298f6a1da6987e2a1eda8a",type:"text",class:"studio-button",onClick:()=>v(this.definition,this.data)},t.exportExcel),o("button",{key:"ea7429bd2e8ed556c398c92a2264433b80d11d67",type:"text",class:"studio-button",onClick:()=>this.importExcelHandler(this.definition)},t.importExcel),o("button",{key:"9bbcb60005f3621b7b2212ebc7381206b8333743",type:"text",class:"studio-button",onClick:()=>this.toggleDataSourceVisibility()},this.showDataSource?t.hideDataSource:t.showDataSource)),o("div",{key:"8dc12abc11a572e4d57ba341eba5b82078790baf",class:"definition"},this.showDefinition&&o("import-export-definition",{key:"0e53a51e6fb268566d2a2982fec6df1d7c9fb548",definition:this.definition,culture:this.culture})),o("div",{key:"df601e00704f71e0dbb74cc74bafbaa59816be7e",class:"preview-table"},o("h3",{key:"469d94d10cc84788438fe5ee4ddfdf55b9e062f1"},t.preview),o("import-export-table",{key:"e0080482da9af16e16507f94f725f38c3bb460a0",definition:this.definition,data:this.data})),this.showDataSource&&o("div",{key:"40025966896deee2003402bef85c812071d302d9",class:"data-source"},o("h3",{key:"b69b787b893065dfd25b45e7e9a453c7823f7c8c"},t.dataSource),o("p",{key:"ac27bb80c702815decdf847c9b34adde399d1832"},JSON.stringify(this.data,null,2))))}static get style(){return".import-export-studio{font-family:Arial, sans-serif;padding:10px;background-color:#f9f9f9}.studio-button{background:linear-gradient(to right, #4caf50, #549757);color:white;border:none;padding:8px 16px;margin-right:8px;text-decoration:none;display:inline-block;font-size:16px;margin:0;cursor:pointer;border-radius:6px;transition:background-color 0.3s}.toggle-definition-button:hover{background:linear-gradient(to right, #45a049, #2d9231)}.operation{display:flex;gap:10px;align-items:center;margin-bottom:10px}.definition{margin-bottom:10px}.data-source textarea{width:100%;height:50%}"}},[1,"import-export-studio",{definition:[16],culture:[1],data:[16],showDefinition:[32],showDataSource:[32]}]);function $(){if("undefined"==typeof customElements)return;["import-export-studio","editable-cell","import-export-definition","import-export-table"].forEach((t=>{switch(t){case"import-export-studio":customElements.get(t)||customElements.define(t,S);break;case"editable-cell":customElements.get(t)||m();break;case"import-export-definition":customElements.get(t)||h();break;case"import-export-table":customElements.get(t)||x()}}))}$();const I=S,j=$;export{I as ImportExportStudio,j as defineCustomElement};
1
+ import{p as t,H as e,h as o}from"./p-ddbe189c.js";import{g as n,i,a as s,b as a,d as c,f as r,E as d,e as l,c as f,k as u,h as p,j as b}from"./p-24a77e62.js";import{d as m}from"./p-dd1bf849.js";import{d as h}from"./p-f7586df1.js";import{d as x}from"./p-c9904f6a.js";let y=!1;async function w(t,e){const o=S(t),n=async function(t,e){const o=[],n={};for(const t of e)n[t.key]=t.dataType;for(const e of t.rows){const t={};for(const o of e.columns)"number"!=n[o.key]?t[o.key]=o.value:t[o.key]=parseFloat(o.value);o.push(t)}return o}(a(o,e),t.columns);return n}function k(t,e,o=""){const n=[];for(const i of t){let t=[];for(const n in i){let s=e[n],a=i[n];if(s&&void 0!==a)if(s.data_group){if(a.children&&a.children.length){let i=k(a.children,e,n);o?t.push(p.newGroup(n,a.value.toString(),i)):t.push(p.newRootGroup(n,i))}}else t.push(new p(n,a.toString()))}n.push(new b(t))}return n}async function v(t,e){const o=S(t);let n={};for(const t of o.columns)n[t.key]=t;const i=k(e,n),s=new d(i);return l(o,s)}async function g(t){const e=`${t.name}.xlsx`,o=await async function(t){return f(S(t))}(t);E(o,e)}function E(t,e,o="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var n;const i="senlinzImportExportDownload";null===(n=document.querySelector(`#${i}`))||void 0===n||n.remove();const s=document.createElement("a");s.id=i,s.download=e;const a=new Blob([t],{type:o});s.href=URL.createObjectURL(a),s.click()}function D(t){let e=new u;return t.rule&&(e=e.withRule(t.rule)),t.value&&(e=e.withValue(t.value)),t.color&&(e=e.withColor(t.color)),t.bold&&(e=e.withBold(t.bold)),t.italic&&(e=e.withItalic(t.italic)),t.underline&&(e=e.withUnderline(t.underline)),t.strikethrough&&(e=e.withStrikethrough(t.strikethrough)),t.fontSize&&(e=e.withFontSize(t.fontSize)),t.backgroundColor&&(e=e.withBackgroundColor(t.backgroundColor)),t.align&&(e=e.withAlign(t.align)),t.alignVertical&&(e=e.withAlignVertical(t.alignVertical)),t.borderColor&&(e=e.withBorderColor(t.borderColor)),t.dateFormat&&(e=e.withDateFormat(t.dateFormat)),e}function S(t){var e,o,n,i,s,a=t.columns.map((t=>{let e=new c(t.key,t.name);if(t.width&&(e=e.withWidth(t.width)),t.dataType&&(e=e.withDataType(t.dataType)),t.note&&(e=e.withNote(t.note)),t.allowedValues&&(e=e.withAllowedValues(t.allowedValues)),t.parent&&(e=e.withParent(t.parent)),t.format&&(e=e.withFormat(D(t.format))),t.valueFormat){let o=Array.isArray(t.valueFormat)?t.valueFormat:[t.valueFormat];e=e.withValueFormat(o.map(D))}return t.dataGroup&&(e=e.withDataGroup(t.dataGroup)),t.dataGroupParent&&(e=e.withDataGroupParent(t.dataGroupParent)),e})),d=new r(t.name,null!==(e=t.sheetName)&&void 0!==e?e:"sheet1",a,null!==(o=t.author)&&void 0!==o?o:"",function(t){if("string"==typeof t)return t;const e=t.getFullYear(),o=t.getMonth()+1,n=t.getDate(),i=t.getHours(),s=t.getMinutes(),a=t.getSeconds(),c=t=>t<10?`0${t}`:t.toString();return`${e}-${c(o)}-${c(n)} ${c(i)}:${c(s)}:${c(a)}`}(null!==(n=t.createTime)&&void 0!==n?n:new Date));let l=null!==(i=t.dx)&&void 0!==i?i:0,f=null!==(s=t.dy)&&void 0!==s?s:0;return d=d.withOffset(l,f),t.title&&(d=d.withTitle(t.title)),t.titleHeight&&(d=d.withTitleHeight(t.titleHeight)),t.titleFormat&&(d=d.withTitleFormat(D(t.titleFormat))),t.defaultRowHeight&&(d=d.withDefaultRowHeight(t.defaultRowHeight)),t.isHeaderFreeze&&(d=d.withIsHeaderFreeze(t.isHeaderFreeze)),d}const $={zh:{hideDefinition:"隐藏定义",showDefinition:"显示定义",downloadTemplate:"下载模板",exportExcel:"导出Excel",importExcel:"导入Excel",downloadDefinition:"下载定义",preview:"预览",dataSource:"数据源",hideDataSource:"隐藏数据源",showDataSource:"显示数据源"},en:{hideDefinition:"Hide Definition",showDefinition:"Show Definition",downloadTemplate:"Download Template",exportExcel:"Export Excel",importExcel:"Import Excel",downloadDefinition:"Download Definition",preview:"Preview",dataSource:"Data Source",hideDataSource:"Hide Data Source",showDataSource:"Show Data Source"}},I=t(class extends e{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.toggleDefinitionVisibility=()=>{this.showDefinition=!this.showDefinition},this.toggleDataSourceVisibility=()=>{this.showDataSource=!this.showDataSource},this.importExcelHandler=async t=>{const e=await(o=t,new Promise(((t,e)=>{var n;let i=document.querySelector("#senlinzImportExportInput");i||(null===(n=document.querySelector("#senlinzImportExportInput"))||void 0===n||n.remove(),i=document.createElement("input"),i.id="senlinzImportExportInput",i.style.display="none",i.type="file",i.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",i.addEventListener("change",(function e(n){const s=n.target.files[0],a=new FileReader;a.onload=async()=>{const n=new Uint8Array(a.result),s=await w(o,n);i.removeEventListener("change",e),i.remove(),t(s)},a.readAsArrayBuffer(s)})),document.body.appendChild(i));const s=document.createElement("button");s.textContent="Import Excel",s.style.display="none",s.addEventListener("click",(()=>{i.click()})),document.body.appendChild(s),s.click(),s.removeEventListener("click",(()=>{i.click()})),document.body.removeChild(s)})));var o;this.data=e},this.handleDataSourceChange=t=>{const e=t.target;try{this.data=JSON.parse(e.value)}catch(t){console.log(t)}},this.definition=void 0,this.culture="en",this.data=[],this.showDefinition=!0,this.showDataSource=!1}componentWillLoad(){!function(){if(!y){const t=n(Uint8Array.from(atob(i),(t=>t.charCodeAt(0))));s({module:t}),y=!0}}()}render(){const t=$[this.culture];return o("div",{key:"9b80914f0440e8f10960ffd58c7e20bc27beb9ae",class:"import-export-studio"},o("div",{key:"5f61a5605d2ba737169f0e0549e8078b80f2e128",class:"operation"},o("button",{key:"4ec2f3ff61487e91a0f508c65c57b061b5316bf6",type:"text",class:"studio-button",onClick:this.toggleDefinitionVisibility},this.showDefinition?t.hideDefinition:t.showDefinition),o("button",{key:"31e3970572332e77a4ee111096c13509053a71a0",type:"text",class:"studio-button",onClick:()=>{return t=this.definition,void E(JSON.stringify(t,null,2),`${t.name}-definition.json`,"application/json");var t}},t.downloadDefinition),o("button",{key:"8b062e1c105b0a67f8fbf6a85b2ff6e4cbfa0825",type:"text",class:"studio-button",onClick:()=>g(this.definition)},t.downloadTemplate),o("button",{key:"6ee2da16c955c8f4b4298f6a1da6987e2a1eda8a",type:"text",class:"studio-button",onClick:()=>async function(t,e){E(await v(t,e),`${t.name}.xlsx`)}(this.definition,this.data)},t.exportExcel),o("button",{key:"ea7429bd2e8ed556c398c92a2264433b80d11d67",type:"text",class:"studio-button",onClick:()=>this.importExcelHandler(this.definition)},t.importExcel),o("button",{key:"9bbcb60005f3621b7b2212ebc7381206b8333743",type:"text",class:"studio-button",onClick:()=>this.toggleDataSourceVisibility()},this.showDataSource?t.hideDataSource:t.showDataSource)),o("div",{key:"8dc12abc11a572e4d57ba341eba5b82078790baf",class:"definition"},this.showDefinition&&o("import-export-definition",{key:"0e53a51e6fb268566d2a2982fec6df1d7c9fb548",definition:this.definition,culture:this.culture})),o("div",{key:"df601e00704f71e0dbb74cc74bafbaa59816be7e",class:"preview-table"},o("h3",{key:"469d94d10cc84788438fe5ee4ddfdf55b9e062f1"},t.preview),o("import-export-table",{key:"e0080482da9af16e16507f94f725f38c3bb460a0",definition:this.definition,data:this.data})),this.showDataSource&&o("div",{key:"40025966896deee2003402bef85c812071d302d9",class:"data-source"},o("h3",{key:"b69b787b893065dfd25b45e7e9a453c7823f7c8c"},t.dataSource),o("p",{key:"ac27bb80c702815decdf847c9b34adde399d1832"},JSON.stringify(this.data,null,2))))}static get style(){return".import-export-studio{font-family:Arial, sans-serif;padding:10px;background-color:#f9f9f9}.studio-button{background:linear-gradient(to right, #4caf50, #549757);color:white;border:none;padding:8px 16px;margin-right:8px;text-decoration:none;display:inline-block;font-size:16px;margin:0;cursor:pointer;border-radius:6px;transition:background-color 0.3s}.toggle-definition-button:hover{background:linear-gradient(to right, #45a049, #2d9231)}.operation{display:flex;gap:10px;align-items:center;margin-bottom:10px}.definition{margin-bottom:10px}.data-source textarea{width:100%;height:50%}"}},[1,"import-export-studio",{definition:[16],culture:[1],data:[16],showDefinition:[32],showDataSource:[32]}]);function j(){if("undefined"==typeof customElements)return;["import-export-studio","editable-cell","import-export-definition","import-export-table"].forEach((t=>{switch(t){case"import-export-studio":customElements.get(t)||customElements.define(t,I);break;case"editable-cell":customElements.get(t)||m();break;case"import-export-definition":customElements.get(t)||h();break;case"import-export-table":customElements.get(t)||x()}}))}j();const C=I,z=j;export{C as ImportExportStudio,z as defineCustomElement};
2
2
  //# sourceMappingURL=import-export-studio.js.map
@@ -1,2 +1,2 @@
1
- export{g as getAssetPath,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-ddbe189c.js";import{g as n,i as t,a as o,b as e,E as c,c as r,d as l,e as u,f as i,h as f,j as p,k as m}from"./p-2f3be56b.js";let x=!1;function d(){if(!x){const e=n(Uint8Array.from(atob(t),(n=>n.charCodeAt(0))));o({module:e}),x=!0}}async function w(n,t){const o=I(n),s=async function(n,t){const o=[],e={};for(const n of t)e[n.key]=n.dataType;for(const t of n.rows){const n={};for(const o of t.columns)e[o.key]!=m.Number?n[o.key]=o.value:n[o.key]=parseFloat(o.value);o.push(n)}return o}(e(o,t),n.columns);return s}async function E(n,t){const o=I(n),e=t.map((n=>{const t=o.columns.map((t=>{const o=n[t.key];return new c(t.key,null==o?"":o.toString())}));return new r(t)})),s=new l(e);return u(o,s)}async function y(n){return i(I(n))}async function $(n){const t=`${n.name}.xlsx`;v(await y(n),t)}function v(n,t,o="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var e;const s="senlinzImportExportDownload";null===(e=document.querySelector(`#${s}`))||void 0===e||e.remove();const c=document.createElement("a");c.id=s,c.download=t;const r=new Blob([n],{type:o});c.href=URL.createObjectURL(r),c.click()}function I(n){var t,o,e=n.columns.map((n=>{const t=new f(n.key,n.name,n.width);return n.dataType&&t.setDataType(n.dataType),n.note&&t.setNote(n.note),n.allowedValues&&t.setAllowedValues(n.allowedValues),t}));return new p(n.name,n.sheetName,e,null!==(t=n.author)&&void 0!==t?t:"",function(n){if("string"==typeof n)return n;const t=n.getFullYear(),o=n.getMonth()+1,e=n.getDate(),s=n.getHours(),c=n.getMinutes(),r=n.getSeconds(),a=n=>n<10?`0${n}`:n.toString();return`${t}-${a(o)}-${a(e)} ${a(s)}:${a(c)}:${a(r)}`}(null!==(o=n.createTime)&&void 0!==o?o:new Date))}function h(n){return new Promise(((t,o)=>{var e;let s=document.querySelector("#senlinzImportExportInput");s||(null===(e=document.querySelector("#senlinzImportExportInput"))||void 0===e||e.remove(),s=document.createElement("input"),s.id="senlinzImportExportInput",s.style.display="none",s.type="file",s.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",s.addEventListener("change",(function o(e){const c=e.target.files[0],r=new FileReader;r.onload=async()=>{const e=new Uint8Array(r.result),c=await w(n,e);s.removeEventListener("change",o),s.remove(),t(c)},r.readAsArrayBuffer(c)})),document.body.appendChild(s));const c=document.createElement("button");c.textContent="Import Excel",c.style.display="none",c.addEventListener("click",(()=>{s.click()})),document.body.appendChild(c),c.click(),c.removeEventListener("click",(()=>{s.click()})),document.body.removeChild(c)}))}async function z(n,t){v(await E(n,t),`${n.name}.xlsx`)}function A(){return d(),{importExcel:h,exportExcel:z,downloadExcelTemplate:$,fromExcel:w,toExcel:E,generateExcelTemplate:y}}function P(n){return d(),h(n)}function U(n,t){return d(),z(n,t)}function j(n){return d(),$(n)}export{j as downloadExcelTemplate,U as exportExcel,A as getUtils,P as importExcel};
1
+ export{g as getAssetPath,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-ddbe189c.js";import{g as n,i as t,a as o,b as e,E as c,e as r,c as l,d as i,f as u,h as f,j as m,k as p}from"./p-24a77e62.js";let d=!1;function x(){if(!d){const e=n(Uint8Array.from(atob(t),(n=>n.charCodeAt(0))));o({module:e}),d=!0}}async function w(n,t){const o=A(n),s=async function(n,t){const o=[],e={};for(const n of t)e[n.key]=n.dataType;for(const t of n.rows){const n={};for(const o of t.columns)"number"!=e[o.key]?n[o.key]=o.value:n[o.key]=parseFloat(o.value);o.push(n)}return o}(e(o,t),n.columns);return s}function E(n,t,o=""){const e=[];for(const s of n){let n=[];for(const e in s){let c=t[e],r=s[e];if(c&&void 0!==r)if(c.data_group){if(r.children&&r.children.length){let s=E(r.children,t,e);o?n.push(f.newGroup(e,r.value.toString(),s)):n.push(f.newRootGroup(e,s))}}else n.push(new f(e,r.toString()))}e.push(new m(n))}return e}async function v(n,t){const o=A(n);let e={};for(const n of o.columns)e[n.key]=n;const s=E(t,e),a=new c(s);return r(o,a)}async function y(n){return l(A(n))}async function $(n){const t=`${n.name}.xlsx`;h(await y(n),t)}function h(n,t,o="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"){var e;const s="senlinzImportExportDownload";null===(e=document.querySelector(`#${s}`))||void 0===e||e.remove();const c=document.createElement("a");c.id=s,c.download=t;const r=new Blob([n],{type:o});c.href=URL.createObjectURL(r),c.click()}function I(n){let t=new p;return n.rule&&(t=t.withRule(n.rule)),n.value&&(t=t.withValue(n.value)),n.color&&(t=t.withColor(n.color)),n.bold&&(t=t.withBold(n.bold)),n.italic&&(t=t.withItalic(n.italic)),n.underline&&(t=t.withUnderline(n.underline)),n.strikethrough&&(t=t.withStrikethrough(n.strikethrough)),n.fontSize&&(t=t.withFontSize(n.fontSize)),n.backgroundColor&&(t=t.withBackgroundColor(n.backgroundColor)),n.align&&(t=t.withAlign(n.align)),n.alignVertical&&(t=t.withAlignVertical(n.alignVertical)),n.borderColor&&(t=t.withBorderColor(n.borderColor)),n.dateFormat&&(t=t.withDateFormat(n.dateFormat)),t}function A(n){var t,o,e,s,c,r=n.columns.map((n=>{let t=new i(n.key,n.name);if(n.width&&(t=t.withWidth(n.width)),n.dataType&&(t=t.withDataType(n.dataType)),n.note&&(t=t.withNote(n.note)),n.allowedValues&&(t=t.withAllowedValues(n.allowedValues)),n.parent&&(t=t.withParent(n.parent)),n.format&&(t=t.withFormat(I(n.format))),n.valueFormat){let o=Array.isArray(n.valueFormat)?n.valueFormat:[n.valueFormat];t=t.withValueFormat(o.map(I))}return n.dataGroup&&(t=t.withDataGroup(n.dataGroup)),n.dataGroupParent&&(t=t.withDataGroupParent(n.dataGroupParent)),t})),a=new u(n.name,null!==(t=n.sheetName)&&void 0!==t?t:"sheet1",r,null!==(o=n.author)&&void 0!==o?o:"",function(n){if("string"==typeof n)return n;const t=n.getFullYear(),o=n.getMonth()+1,e=n.getDate(),s=n.getHours(),c=n.getMinutes(),r=n.getSeconds(),a=n=>n<10?`0${n}`:n.toString();return`${t}-${a(o)}-${a(e)} ${a(s)}:${a(c)}:${a(r)}`}(null!==(e=n.createTime)&&void 0!==e?e:new Date));let l=null!==(s=n.dx)&&void 0!==s?s:0,f=null!==(c=n.dy)&&void 0!==c?c:0;return a=a.withOffset(l,f),n.title&&(a=a.withTitle(n.title)),n.titleHeight&&(a=a.withTitleHeight(n.titleHeight)),n.titleFormat&&(a=a.withTitleFormat(I(n.titleFormat))),n.defaultRowHeight&&(a=a.withDefaultRowHeight(n.defaultRowHeight)),n.isHeaderFreeze&&(a=a.withIsHeaderFreeze(n.isHeaderFreeze)),a}function z(n){return new Promise(((t,o)=>{var e;let s=document.querySelector("#senlinzImportExportInput");s||(null===(e=document.querySelector("#senlinzImportExportInput"))||void 0===e||e.remove(),s=document.createElement("input"),s.id="senlinzImportExportInput",s.style.display="none",s.type="file",s.accept=".xlsx,.xls,.xlsm,.xlsb,.xla,.xlam,.ods",s.addEventListener("change",(function o(e){const c=e.target.files[0],r=new FileReader;r.onload=async()=>{const e=new Uint8Array(r.result),c=await w(n,e);s.removeEventListener("change",o),s.remove(),t(c)},r.readAsArrayBuffer(c)})),document.body.appendChild(s));const c=document.createElement("button");c.textContent="Import Excel",c.style.display="none",c.addEventListener("click",(()=>{s.click()})),document.body.appendChild(c),c.click(),c.removeEventListener("click",(()=>{s.click()})),document.body.removeChild(c)}))}async function P(n,t){h(await v(n,t),`${n.name}.xlsx`)}function U(){return x(),{importExcel:z,exportExcel:P,downloadExcelTemplate:$,fromExcel:w,toExcel:v,generateExcelTemplate:y}}function j(n){return x(),z(n)}function k(n,t){return x(),P(n,t)}function T(n){return x(),$(n)}export{T as downloadExcelTemplate,k as exportExcel,U as getUtils,j as importExcel};
2
2
  //# sourceMappingURL=index.js.map