@senlinz/import-export 0.0.1-beta.5 → 0.1.0-beta.6

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.
Files changed (41) hide show
  1. package/README.md +20 -0
  2. package/dist/components/editable-cell.d.ts +11 -0
  3. package/dist/components/editable-cell.js +2 -0
  4. package/dist/components/import-export-definition.d.ts +11 -0
  5. package/dist/components/import-export-definition.js +2 -0
  6. package/dist/components/import-export-studio.d.ts +11 -0
  7. package/dist/components/import-export-studio.js +2 -0
  8. package/dist/components/import-export-table.d.ts +11 -0
  9. package/dist/components/import-export-table.js +2 -0
  10. package/dist/components/index.js +1 -1
  11. package/dist/components/p-199902a7.js +2 -0
  12. package/dist/components/p-c9904f6a.js +2 -0
  13. package/dist/components/p-dd1bf849.js +2 -0
  14. package/dist/components/p-ddbe189c.js +2 -0
  15. package/dist/components/p-f7586df1.js +2 -0
  16. package/dist/tests/dist/editable-cell.d.ts +11 -0
  17. package/dist/{components → tests/dist}/imexport-table.d.ts +1 -1
  18. package/dist/tests/dist/import-export-definition.d.ts +11 -0
  19. package/dist/tests/dist/import-export-definiton.d.ts +11 -0
  20. package/dist/tests/dist/import-export-studio.d.ts +11 -0
  21. package/dist/tests/dist/import-export-table.d.ts +11 -0
  22. package/dist/tests/dist/index.d.ts +33 -0
  23. package/dist/tests/dist/table-definition.d.ts +11 -0
  24. package/dist/types/components/editable-cell/editable-cell.d.ts +18 -0
  25. package/dist/types/components/imexport-table/imexport-table.d.ts +4 -5
  26. package/dist/types/components/import-export-definition/import-export-definition.d.ts +7 -0
  27. package/dist/types/components/import-export-definition/import-export-definiton.d.ts +6 -0
  28. package/dist/types/components/import-export-studio/import-export-studio.d.ts +14 -0
  29. package/dist/types/components/import-export-studio/import-export-table.d.ts +5 -0
  30. package/dist/types/components/import-export-table/import-export-table.d.ts +6 -0
  31. package/dist/types/components/table-definition/table-definition.d.ts +0 -0
  32. package/dist/types/components.d.ts +79 -23
  33. package/dist/types/declarations/ExcelDefinition.d.ts +17 -0
  34. package/dist/types/declarations/ExcelDefintion.d.ts +17 -0
  35. package/dist/types/index.d.ts +10 -1
  36. package/dist/types/types/index.d.ts +10 -3
  37. package/dist/types/utils/utils.d.ts +8 -5
  38. package/dist/types/utils.d.ts +10 -0
  39. package/package.json +12 -12
  40. package/dist/components/imexport-table.js +0 -2
  41. package/dist/components/p-4789c9c3.js +0 -2
package/README.md CHANGED
@@ -1 +1,21 @@
1
1
  # @senlinz/import-export
2
+
3
+ ```html
4
+ <!DOCTYPE html>
5
+ <html dir="ltr" lang="en">
6
+
7
+ <head>
8
+ <meta charset="utf-8" />
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
10
+ <title>Stencil Component Starter</title>
11
+ <script type="module">
12
+ import {ImexportTable} from './imexport-table.js';
13
+ </script>
14
+ </head>
15
+
16
+ <body>
17
+ <imexport-table></imexport-table>
18
+ </body>
19
+
20
+ </html>
21
+ ```
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface EditableCell extends Components.EditableCell, HTMLElement {}
4
+ export const EditableCell: {
5
+ prototype: EditableCell;
6
+ new (): EditableCell;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,2 @@
1
+ import{E as e,d as s}from"./p-dd1bf849.js";const t=e,a=s;export{t as EditableCell,a as defineCustomElement};
2
+ //# sourceMappingURL=editable-cell.js.map
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ImportExportDefinition extends Components.ImportExportDefinition, HTMLElement {}
4
+ export const ImportExportDefinition: {
5
+ prototype: ImportExportDefinition;
6
+ new (): ImportExportDefinition;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,2 @@
1
+ import{I as o,d as t}from"./p-f7586df1.js";const s=o,e=t;export{s as ImportExportDefinition,e as defineCustomElement};
2
+ //# sourceMappingURL=import-export-definition.js.map
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ImportExportStudio extends Components.ImportExportStudio, HTMLElement {}
4
+ export const ImportExportStudio: {
5
+ prototype: ImportExportStudio;
6
+ new (): ImportExportStudio;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +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 f,c as l,d as u,e as p,f as b}from"./p-199902a7.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=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,e,t.author,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)}`}(t.createTime))}async function D(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 f(e.key,null==o?"":o.toString())}));return new l(e)})),i=new u(n);return p(o,i)}(t,e);g(o,`${t.name}.xlsx`)}const v={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){const n=e.target.files[0],i=new FileReader;i.onload=async()=>{const e=new Uint8Array(i.result),n=await w(o,e);t(n)},i.readAsArrayBuffer(n)})),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(),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=v[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:()=>D(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};
2
+ //# sourceMappingURL=import-export-studio.js.map
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface ImportExportTable extends Components.ImportExportTable, HTMLElement {}
4
+ export const ImportExportTable: {
5
+ prototype: ImportExportTable;
6
+ new (): ImportExportTable;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,2 @@
1
+ import{I as o,d as s}from"./p-c9904f6a.js";const t=o,a=s;export{t as ImportExportTable,a as defineCustomElement};
2
+ //# sourceMappingURL=import-export-table.js.map
@@ -1,2 +1,2 @@
1
- export{g as getAssetPath,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-4789c9c3.js";
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 u,e as l,f as i,h as f,j as m,k as p}from"./p-199902a7.js";let x=!1;async function d(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]!=p.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 w(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 u(e);return l(o,s)}async function E(n){return i(I(n))}async function y(n){const t=`${n.name}.xlsx`;$(await E(n),t)}function $(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=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 m(n.name,n.sheetName,t,n.author,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)}`}(n.createTime))}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){const e=o.target.files[0],s=new FileReader;s.onload=async()=>{const o=new Uint8Array(s.result),e=await d(n,o);t(e)},s.readAsArrayBuffer(e)})),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(),document.body.removeChild(c)}))}async function v(n,t){$(await w(n,t),`${n.name}.xlsx`)}function z(){return function(){if(!x){const e=n(Uint8Array.from(atob(t),(n=>n.charCodeAt(0))));o({module:e}),x=!0}}(),{importExcel:h,exportExcel:v,downloadExcelTemplate:y,fromExcel:d,toExcel:w,generateExcelTemplate:E}}export{z as getUtils};
2
2
  //# sourceMappingURL=index.js.map