@senlinz/import-export 0.1.0-beta.14 → 0.1.0-beta.15
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/dist/components/index.js +1 -1
- package/dist/types/components.d.ts +0 -92
- package/dist/types/declarations/ExcelDefinition.d.ts +1 -1
- package/package.json +2 -2
- package/dist/components/editable-cell.js +0 -2
- package/dist/components/import-export-definition.js +0 -2
- package/dist/components/import-export-studio.js +0 -2
- package/dist/components/import-export-table.js +0 -2
- package/dist/components/p-89617fec.js +0 -2
- package/dist/components/p-c9904f6a.js +0 -2
- package/dist/components/p-dd1bf849.js +0 -2
- package/dist/components/p-ddbe189c.js +0 -2
- package/dist/components/p-f7586df1.js +0 -2
- package/dist/tests/dist/editable-cell.d.ts +0 -11
- package/dist/tests/dist/imexport-table.d.ts +0 -11
- package/dist/tests/dist/import-export-definition.d.ts +0 -11
- package/dist/tests/dist/import-export-definiton.d.ts +0 -11
- package/dist/tests/dist/import-export-studio.d.ts +0 -11
- package/dist/tests/dist/import-export-table.d.ts +0 -11
- package/dist/tests/dist/table-definition.d.ts +0 -11
- package/dist/types/components/editable-cell/editable-cell.d.ts +0 -18
- package/dist/types/components/imexport-table/imexport-table.d.ts +0 -19
- package/dist/types/components/import-export-definition/import-export-definition.d.ts +0 -7
- package/dist/types/components/import-export-definition/import-export-definiton.d.ts +0 -6
- package/dist/types/components/import-export-studio/import-export-studio.d.ts +0 -14
- package/dist/types/components/import-export-studio/import-export-table.d.ts +0 -5
- package/dist/types/components/import-export-table/import-export-table.d.ts +0 -6
- package/dist/types/components/table-definition/table-definition.d.ts +0 -0
- package/dist/types/declarations/ExcelDefintion.d.ts +0 -17
- package/dist/types/types/index.d.ts +0 -19
- package/dist/types/utils/utils.d.ts +0 -9
- /package/dist/{tests/dist → components}/index.d.ts +0 -0
|
@@ -5,112 +5,20 @@
|
|
|
5
5
|
* It contains typing information for all components that exist in this project.
|
|
6
6
|
*/
|
|
7
7
|
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
|
-
import { ExcelDefinition } from "./declarations/ExcelDefinition";
|
|
9
|
-
export { ExcelDefinition } from "./declarations/ExcelDefinition";
|
|
10
8
|
export namespace Components {
|
|
11
|
-
interface EditableCell {
|
|
12
|
-
"culture": 'zh' | 'en';
|
|
13
|
-
"type": 'text' | 'datetime-local';
|
|
14
|
-
"value": string | Date;
|
|
15
|
-
}
|
|
16
|
-
interface ImportExportDefinition {
|
|
17
|
-
"culture": 'zh' | 'en';
|
|
18
|
-
"cultureResources"?: Record<string, Record<string, string>>;
|
|
19
|
-
"definition": ExcelDefinition;
|
|
20
|
-
}
|
|
21
|
-
interface ImportExportStudio {
|
|
22
|
-
"culture": 'zh' | 'en';
|
|
23
|
-
"data": any[];
|
|
24
|
-
"definition": ExcelDefinition;
|
|
25
|
-
}
|
|
26
|
-
interface ImportExportTable {
|
|
27
|
-
"data": any[];
|
|
28
|
-
"definition": ExcelDefinition;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export interface EditableCellCustomEvent<T> extends CustomEvent<T> {
|
|
32
|
-
detail: T;
|
|
33
|
-
target: HTMLEditableCellElement;
|
|
34
9
|
}
|
|
35
10
|
declare global {
|
|
36
|
-
interface HTMLEditableCellElementEventMap {
|
|
37
|
-
"valueChange": string;
|
|
38
|
-
}
|
|
39
|
-
interface HTMLEditableCellElement extends Components.EditableCell, HTMLStencilElement {
|
|
40
|
-
addEventListener<K extends keyof HTMLEditableCellElementEventMap>(type: K, listener: (this: HTMLEditableCellElement, ev: EditableCellCustomEvent<HTMLEditableCellElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
|
|
41
|
-
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
42
|
-
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
43
|
-
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
44
|
-
removeEventListener<K extends keyof HTMLEditableCellElementEventMap>(type: K, listener: (this: HTMLEditableCellElement, ev: EditableCellCustomEvent<HTMLEditableCellElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
|
|
45
|
-
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
46
|
-
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
47
|
-
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
48
|
-
}
|
|
49
|
-
var HTMLEditableCellElement: {
|
|
50
|
-
prototype: HTMLEditableCellElement;
|
|
51
|
-
new (): HTMLEditableCellElement;
|
|
52
|
-
};
|
|
53
|
-
interface HTMLImportExportDefinitionElement extends Components.ImportExportDefinition, HTMLStencilElement {
|
|
54
|
-
}
|
|
55
|
-
var HTMLImportExportDefinitionElement: {
|
|
56
|
-
prototype: HTMLImportExportDefinitionElement;
|
|
57
|
-
new (): HTMLImportExportDefinitionElement;
|
|
58
|
-
};
|
|
59
|
-
interface HTMLImportExportStudioElement extends Components.ImportExportStudio, HTMLStencilElement {
|
|
60
|
-
}
|
|
61
|
-
var HTMLImportExportStudioElement: {
|
|
62
|
-
prototype: HTMLImportExportStudioElement;
|
|
63
|
-
new (): HTMLImportExportStudioElement;
|
|
64
|
-
};
|
|
65
|
-
interface HTMLImportExportTableElement extends Components.ImportExportTable, HTMLStencilElement {
|
|
66
|
-
}
|
|
67
|
-
var HTMLImportExportTableElement: {
|
|
68
|
-
prototype: HTMLImportExportTableElement;
|
|
69
|
-
new (): HTMLImportExportTableElement;
|
|
70
|
-
};
|
|
71
11
|
interface HTMLElementTagNameMap {
|
|
72
|
-
"editable-cell": HTMLEditableCellElement;
|
|
73
|
-
"import-export-definition": HTMLImportExportDefinitionElement;
|
|
74
|
-
"import-export-studio": HTMLImportExportStudioElement;
|
|
75
|
-
"import-export-table": HTMLImportExportTableElement;
|
|
76
12
|
}
|
|
77
13
|
}
|
|
78
14
|
declare namespace LocalJSX {
|
|
79
|
-
interface EditableCell {
|
|
80
|
-
"culture"?: 'zh' | 'en';
|
|
81
|
-
"onValueChange"?: (event: EditableCellCustomEvent<string>) => void;
|
|
82
|
-
"type"?: 'text' | 'datetime-local';
|
|
83
|
-
"value"?: string | Date;
|
|
84
|
-
}
|
|
85
|
-
interface ImportExportDefinition {
|
|
86
|
-
"culture"?: 'zh' | 'en';
|
|
87
|
-
"cultureResources"?: Record<string, Record<string, string>>;
|
|
88
|
-
"definition"?: ExcelDefinition;
|
|
89
|
-
}
|
|
90
|
-
interface ImportExportStudio {
|
|
91
|
-
"culture"?: 'zh' | 'en';
|
|
92
|
-
"data"?: any[];
|
|
93
|
-
"definition"?: ExcelDefinition;
|
|
94
|
-
}
|
|
95
|
-
interface ImportExportTable {
|
|
96
|
-
"data"?: any[];
|
|
97
|
-
"definition"?: ExcelDefinition;
|
|
98
|
-
}
|
|
99
15
|
interface IntrinsicElements {
|
|
100
|
-
"editable-cell": EditableCell;
|
|
101
|
-
"import-export-definition": ImportExportDefinition;
|
|
102
|
-
"import-export-studio": ImportExportStudio;
|
|
103
|
-
"import-export-table": ImportExportTable;
|
|
104
16
|
}
|
|
105
17
|
}
|
|
106
18
|
export { LocalJSX as JSX };
|
|
107
19
|
declare module "@stencil/core" {
|
|
108
20
|
export namespace JSX {
|
|
109
21
|
interface IntrinsicElements {
|
|
110
|
-
"editable-cell": LocalJSX.EditableCell & JSXBase.HTMLAttributes<HTMLEditableCellElement>;
|
|
111
|
-
"import-export-definition": LocalJSX.ImportExportDefinition & JSXBase.HTMLAttributes<HTMLImportExportDefinitionElement>;
|
|
112
|
-
"import-export-studio": LocalJSX.ImportExportStudio & JSXBase.HTMLAttributes<HTMLImportExportStudioElement>;
|
|
113
|
-
"import-export-table": LocalJSX.ImportExportTable & JSXBase.HTMLAttributes<HTMLImportExportTableElement>;
|
|
114
22
|
}
|
|
115
23
|
}
|
|
116
24
|
}
|
|
@@ -19,7 +19,7 @@ interface ExcelColumnDefinition {
|
|
|
19
19
|
name: string;
|
|
20
20
|
width?: number;
|
|
21
21
|
note?: string;
|
|
22
|
-
dataType?: "string" | "number" | "date";
|
|
22
|
+
dataType?: "string" | "number" | "date" | "image";
|
|
23
23
|
allowedValues?: string[];
|
|
24
24
|
parent?: string;
|
|
25
25
|
backgroundColor?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senlinz/import-export",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.15",
|
|
4
4
|
"description": "Stencil Component for import/export excel files.",
|
|
5
5
|
"module": "dist/components/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"fflate": "^0.8.2",
|
|
34
|
-
"@senlinz/import-export-wasm": "0.1.0-beta.
|
|
34
|
+
"@senlinz/import-export-wasm": "0.1.0-beta.15"
|
|
35
35
|
},
|
|
36
36
|
"keywords": [
|
|
37
37
|
"stencil",
|
|
@@ -1,2 +0,0 @@
|
|
|
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-89617fec.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)),t.progressCallback&&(d=d.withProgressCallback(t.progressCallback)),t.imageFetcher&&(d=d.withImageFetcher(t.imageFetcher)),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
|
-
//# sourceMappingURL=import-export-studio.js.map
|