@senlinz/import-export 0.1.0-beta.9 → 0.1.1

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 (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +196 -61
  3. package/README.zh.md +188 -0
  4. package/dist/index.js +2 -0
  5. package/dist/types/ExcelDefinition.d.ts +116 -0
  6. package/dist/types/index.d.ts +17 -7
  7. package/dist/types/runtime.d.ts +20 -0
  8. package/dist/types/utils.d.ts +8 -7
  9. package/package.json +22 -23
  10. package/dist/components/editable-cell.d.ts +0 -11
  11. package/dist/components/editable-cell.js +0 -2
  12. package/dist/components/import-export-definition.d.ts +0 -11
  13. package/dist/components/import-export-definition.js +0 -2
  14. package/dist/components/import-export-studio.d.ts +0 -11
  15. package/dist/components/import-export-studio.js +0 -2
  16. package/dist/components/import-export-table.d.ts +0 -11
  17. package/dist/components/import-export-table.js +0 -2
  18. package/dist/components/index.d.ts +0 -33
  19. package/dist/components/index.js +0 -2
  20. package/dist/components/p-3b0da608.js +0 -2
  21. package/dist/components/p-c9904f6a.js +0 -2
  22. package/dist/components/p-dd1bf849.js +0 -2
  23. package/dist/components/p-ddbe189c.js +0 -2
  24. package/dist/components/p-f7586df1.js +0 -2
  25. package/dist/tests/dist/editable-cell.d.ts +0 -11
  26. package/dist/tests/dist/imexport-table.d.ts +0 -11
  27. package/dist/tests/dist/import-export-definition.d.ts +0 -11
  28. package/dist/tests/dist/import-export-definiton.d.ts +0 -11
  29. package/dist/tests/dist/import-export-studio.d.ts +0 -11
  30. package/dist/tests/dist/import-export-table.d.ts +0 -11
  31. package/dist/tests/dist/index.d.ts +0 -33
  32. package/dist/tests/dist/table-definition.d.ts +0 -11
  33. package/dist/types/components/editable-cell/editable-cell.d.ts +0 -18
  34. package/dist/types/components/imexport-table/imexport-table.d.ts +0 -19
  35. package/dist/types/components/import-export-definition/import-export-definition.d.ts +0 -7
  36. package/dist/types/components/import-export-definition/import-export-definiton.d.ts +0 -6
  37. package/dist/types/components/import-export-studio/import-export-studio.d.ts +0 -14
  38. package/dist/types/components/import-export-studio/import-export-table.d.ts +0 -5
  39. package/dist/types/components/import-export-table/import-export-table.d.ts +0 -6
  40. package/dist/types/components/table-definition/table-definition.d.ts +0 -0
  41. package/dist/types/components.d.ts +0 -116
  42. package/dist/types/declarations/ExcelDefinition.d.ts +0 -17
  43. package/dist/types/declarations/ExcelDefintion.d.ts +0 -17
  44. package/dist/types/stencil-public-runtime.d.ts +0 -1674
  45. package/dist/types/types/index.d.ts +0 -19
  46. package/dist/types/utils/utils.d.ts +0 -9
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Stable scalar cell types supported by the public API.
3
+ */
4
+ type ExcelColumnDataType = "text" | "number" | "date" | "image";
5
+ /**
6
+ * Runtime support:
7
+ * - Browser ESM environments with `Blob`, `FileReader`, `atob`, and `URL.createObjectURL`.
8
+ * - Node.js can use `fromExcel`, `toExcel`, and `generateExcelTemplate` when compatible browser globals are available.
9
+ *
10
+ * Known limitations:
11
+ * - Schema-based import validates headers strictly against `columns[].name` order and position.
12
+ * - Grouped export expects parent columns and data groups to be declared before children.
13
+ * - Image export requires `imageFetcher`.
14
+ */
15
+ interface ExcelDefinition {
16
+ /** File name used for template/export downloads. */
17
+ name: string;
18
+ /** Worksheet name used for export and preferred during import. */
19
+ sheetName?: string;
20
+ /** Stable schema definition for worksheet columns. */
21
+ columns: ExcelColumnDefinition[];
22
+ /** Optional workbook author metadata written into generated files. */
23
+ author?: string;
24
+ /** Workbook creation time accepted as a `Date` or ISO-like string. */
25
+ createTime?: Date | string;
26
+ /** Optional merged title row rendered above the header. */
27
+ title?: string;
28
+ /** Height of the optional merged title row in worksheet units. */
29
+ titleHeight?: number;
30
+ /** Format applied to the optional merged title row. */
31
+ titleFormat?: ExcelCellFormatDefinition;
32
+ /** Default height used for data rows when exporting a worksheet. */
33
+ defaultRowHeight?: number;
34
+ /** Height applied to header rows during template/export generation. */
35
+ headerRowHeight?: number;
36
+ /** Horizontal column offset before writing the header. */
37
+ dx?: number;
38
+ /** Vertical row offset before writing the header. */
39
+ dy?: number;
40
+ /** Freezes the header area so column labels remain visible while scrolling. */
41
+ isHeaderFreeze?: boolean;
42
+ /** Optional progress callback receiving values from `0` to `100` during long-running work. */
43
+ progressCallback?: (progress: number) => void;
44
+ /**
45
+ * Required when any exported column uses `dataType: "image"`.
46
+ * The callback must resolve to image bytes for the provided URL or identifier.
47
+ */
48
+ imageFetcher?: (url: string) => Promise<Uint8Array>;
49
+ }
50
+ interface ExcelColumnDefinition {
51
+ /** Stable programmatic key used to map row objects. Must be unique within a definition. */
52
+ key: string;
53
+ /** Visible worksheet header label. */
54
+ name: string;
55
+ /** Column width used for template/export rendering. */
56
+ width?: number;
57
+ /** Excel note/comment attached to the header cell. */
58
+ note?: string;
59
+ /**
60
+ * Supported values:
61
+ * - `text`
62
+ * - `number`
63
+ * - `date`
64
+ * - `image`
65
+ */
66
+ dataType?: ExcelColumnDataType;
67
+ /** Drop-down allowed values used for template validation and import expectations. */
68
+ allowedValues?: string[];
69
+ /** Parent header key for multi-row headers. Parent columns must be declared first. */
70
+ parent?: string;
71
+ /** Header background color in a CSS-like hex string such as `#RRGGBB`. */
72
+ backgroundColor?: string;
73
+ /** Header text color in a CSS-like hex string such as `#RRGGBB`. */
74
+ color?: string;
75
+ /** Whether the header text should be rendered bold. */
76
+ bold?: boolean;
77
+ /** Base format applied to cells in this column. */
78
+ format?: ExcelCellFormatDefinition;
79
+ /** Conditional or direct format overrides applied to exported cell values. */
80
+ valueFormat?: ExcelCellFormatDefinition[] | ExcelCellFormatDefinition;
81
+ /** Optional logical group identifier for nested export data. */
82
+ dataGroup?: string;
83
+ /** Optional parent group identifier. Referenced groups must be declared first. */
84
+ dataGroupParent?: string;
85
+ }
86
+ interface ExcelCellFormatDefinition {
87
+ rule?: 'default' | 'eq';
88
+ value?: string;
89
+ color?: string;
90
+ bold?: boolean;
91
+ italic?: boolean;
92
+ underline?: boolean;
93
+ strikethrough?: boolean;
94
+ fontSize?: number;
95
+ backgroundColor?: string;
96
+ align?: 'left' | 'center' | 'right';
97
+ alignVertical?: 'top' | 'center' | 'bottom';
98
+ /** Excel-compatible number format string used for date display. */
99
+ dateFormat?: string;
100
+ borderColor?: string;
101
+ }
102
+ interface DynamicExcelImportOptions {
103
+ /** Preferred worksheet name. Falls back to the first sheet when omitted or missing. */
104
+ sheetName?: string;
105
+ /** 1-based worksheet row number to use as the header row. Defaults to the first non-empty row. */
106
+ headerRow?: number;
107
+ }
108
+ interface DynamicExcelImportResult {
109
+ /** Actual worksheet name that was imported. */
110
+ sheetName: string;
111
+ /** Header labels read from the worksheet in left-to-right order. */
112
+ headers: string[];
113
+ /** Row data keyed by the imported header labels. */
114
+ rows: Record<string, string>[];
115
+ }
116
+ export { ExcelDefinition, ExcelColumnDefinition, ExcelCellFormatDefinition, ExcelColumnDataType, DynamicExcelImportOptions, DynamicExcelImportResult };
@@ -1,15 +1,25 @@
1
- export type * from './components.d.ts';
2
- import { ExcelDefinition } from './declarations/ExcelDefinition.js';
3
- import { importExcel, exportExcel, downloadExcelTemplate, fromExcel, toExcel, generateExcelTemplate } from './utils.js';
1
+ export type * from './ExcelDefinition';
2
+ export type { InitializeWasmOptions } from './runtime.js';
3
+ import { ExcelDefinition } from './ExcelDefinition';
4
+ import type { DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
5
+ import { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, fromExcel, fromExcelDynamic, toExcel, generateExcelTemplate } from './utils.js';
6
+ import { bundledWasmSource, initializeWasm } from './runtime.js';
4
7
  declare function getUtils(): {
5
8
  importExcel: typeof importExcel;
9
+ importExcelDynamic: typeof importExcelDynamic;
6
10
  exportExcel: typeof exportExcel;
7
11
  downloadExcelTemplate: typeof downloadExcelTemplate;
8
12
  fromExcel: typeof fromExcel;
13
+ fromExcelDynamic: typeof fromExcelDynamic;
9
14
  toExcel: typeof toExcel;
10
15
  generateExcelTemplate: typeof generateExcelTemplate;
11
16
  };
12
- declare function _importExcel<T>(defintion: ExcelDefinition): Promise<T[]>;
13
- declare function _exportExcel<T>(defintion: ExcelDefinition, data: T[]): Promise<void>;
14
- declare function _downloadExcelTemplate(defintion: ExcelDefinition): Promise<void>;
15
- export { getUtils, _importExcel as importExcel, _exportExcel as exportExcel, _downloadExcelTemplate as downloadExcelTemplate };
17
+ declare function _importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
18
+ declare function _importExcelDynamic(options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
19
+ declare function _exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
20
+ declare function _fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
21
+ declare function _fromExcelDynamic(buffer: Uint8Array, options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
22
+ declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array>;
23
+ declare function _downloadExcelTemplate(definition: ExcelDefinition): Promise<void>;
24
+ declare function _generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array>;
25
+ export { bundledWasmSource, getUtils, initializeWasm, _importExcel as importExcel, _importExcelDynamic as importExcelDynamic, _exportExcel as exportExcel, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, _downloadExcelTemplate as downloadExcelTemplate, _generateExcelTemplate as generateExcelTemplate, };
@@ -0,0 +1,20 @@
1
+ type WasmInitializationInputKind = 'source' | 'bytes' | 'module';
2
+ interface InitializeWasmOptions {
3
+ /**
4
+ * Gzipped base64-encoded WASM source text.
5
+ */
6
+ source?: string;
7
+ /**
8
+ * Raw WebAssembly bytes loaded by the caller.
9
+ */
10
+ bytes?: BufferSource;
11
+ /**
12
+ * A precompiled WebAssembly module loaded by the caller.
13
+ */
14
+ module?: WebAssembly.Module;
15
+ }
16
+ declare const bundledWasmSource: string;
17
+ declare function ensureWasmInitialized(): void;
18
+ declare function initializeWasm(options?: InitializeWasmOptions): void;
19
+ export { bundledWasmSource, ensureWasmInitialized, initializeWasm, };
20
+ export type { InitializeWasmOptions, WasmInitializationInputKind, };
@@ -1,10 +1,11 @@
1
- import { ExcelDefinition } from './declarations/ExcelDefinition';
2
- declare function initializeWasm(): void;
3
- declare function fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
4
- declare function toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array>;
5
- declare function generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array>;
1
+ import { ExcelDefinition, DynamicExcelImportOptions, DynamicExcelImportResult } from './ExcelDefinition';
2
+ declare function _fromExcel<T>(definition: ExcelDefinition, buffer: Uint8Array): Promise<T[]>;
3
+ declare function _fromExcelDynamic(buffer: Uint8Array, options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
4
+ declare function _toExcel<T>(definition: ExcelDefinition, data: T[]): Promise<Uint8Array<ArrayBufferLike>>;
5
+ declare function generateExcelTemplate(definition: ExcelDefinition): Promise<Uint8Array<ArrayBufferLike>>;
6
6
  declare function downloadExcelTemplate(definition: ExcelDefinition): Promise<void>;
7
7
  declare function download(data: Uint8Array | string, name: string, type?: string): void;
8
- declare function importExcel<T>(defintion: ExcelDefinition): Promise<T[]>;
8
+ declare function importExcel<T>(definition: ExcelDefinition): Promise<T[]>;
9
+ declare function importExcelDynamic(options?: DynamicExcelImportOptions): Promise<DynamicExcelImportResult>;
9
10
  declare function exportExcel<T>(definition: ExcelDefinition, data: T[]): Promise<void>;
10
- export { importExcel, exportExcel, downloadExcelTemplate, fromExcel, toExcel, generateExcelTemplate, initializeWasm, download };
11
+ export { importExcel, importExcelDynamic, exportExcel, downloadExcelTemplate, _fromExcel as fromExcel, _fromExcelDynamic as fromExcelDynamic, _toExcel as toExcel, generateExcelTemplate, download };
package/package.json CHANGED
@@ -1,31 +1,35 @@
1
1
  {
2
2
  "name": "@senlinz/import-export",
3
- "version": "0.1.0-beta.9",
4
- "description": "Stencil Component for import/export excel files.",
5
- "module": "dist/components/index.js",
6
- "types": "dist/types/index.d.ts",
3
+ "version": "0.1.1",
4
+ "description": "import/export excel core",
7
5
  "files": [
8
6
  "dist/**/*.js",
9
7
  "dist/**/*.d.ts",
10
- "README.md"
8
+ "README.md",
9
+ "README.zh.md"
11
10
  ],
11
+ "type": "module",
12
+ "module": "dist/index.js",
13
+ "types": "dist/types/index.d.ts",
12
14
  "exports": {
13
15
  ".": {
14
- "import": "./dist/components/index.js",
15
- "types": "./dist/components/index.d.ts"
16
- },
17
- "./components/import-export-studio.js": {
18
- "import": "./dist/components/import-export-studio.js",
19
- "types": "./dist/components/import-export-studio.d.ts"
16
+ "import": "./dist/index.js",
17
+ "types": "./dist/types/index.d.ts"
20
18
  }
21
19
  },
22
20
  "devDependencies": {
21
+ "@rollup/plugin-commonjs": "^28.0.3",
22
+ "@rollup/plugin-node-resolve": "^16.0.1",
23
23
  "@rollup/plugin-terser": "^0.4.4",
24
- "@stencil/core": "^4.7.0",
24
+ "@rollup/plugin-typescript": "^12.1.2",
25
25
  "@types/jest": "^29.5.6",
26
26
  "@types/node": "^16.18.108",
27
27
  "jest": "^29.7.0",
28
- "jest-cli": "^29.7.0"
28
+ "jest-cli": "^29.7.0",
29
+ "rollup": "^4.39.0",
30
+ "rollup-plugin-terser": "^7.0.2",
31
+ "tslib": "^2.8.1",
32
+ "typescript": "^5.8.2"
29
33
  },
30
34
  "author": "senlin",
31
35
  "license": "MIT",
@@ -35,11 +39,9 @@
35
39
  },
36
40
  "dependencies": {
37
41
  "fflate": "^0.8.2",
38
- "@senlinz/import-export-wasm": "0.1.0-beta.9"
42
+ "@senlinz/import-export-wasm": "0.1.1"
39
43
  },
40
44
  "keywords": [
41
- "stencil",
42
- "webcomponents",
43
45
  "rust",
44
46
  "wasm",
45
47
  "import",
@@ -53,12 +55,9 @@
53
55
  "client"
54
56
  ],
55
57
  "scripts": {
56
- "build": "stencil build",
57
- "start": "stencil build --dev --watch --serve",
58
- "test": "stencil test --spec",
59
- "e2e-serve": "stencil build --config stencil.test.config.ts && serve -l 8080 ./tests",
60
- "e2e-test": "playwright test",
61
- "generate": "stencil generate",
62
- "publish-dry-run": "pnpm publish --dry-run --no-git-checks"
58
+ "build": "rollup -c",
59
+ "dev": "rollup -c -w",
60
+ "test": "playwright test -c playwright.config.ts",
61
+ "e2e-serve": "serve -l 8080 ."
63
62
  }
64
63
  }
@@ -1,11 +0,0 @@
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;
@@ -1,2 +0,0 @@
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
@@ -1,11 +0,0 @@
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;
@@ -1,2 +0,0 @@
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
@@ -1,11 +0,0 @@
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;
@@ -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,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-3b0da608.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};
2
- //# sourceMappingURL=import-export-studio.js.map
@@ -1,11 +0,0 @@
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;
@@ -1,2 +0,0 @@
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,33 +0,0 @@
1
- /**
2
- * Get the base path to where the assets can be found. Use "setAssetPath(path)"
3
- * if the path needs to be customized.
4
- */
5
- export declare const getAssetPath: (path: string) => string;
6
-
7
- /**
8
- * Used to manually set the base path where assets can be found.
9
- * If the script is used as "module", it's recommended to use "import.meta.url",
10
- * such as "setAssetPath(import.meta.url)". Other options include
11
- * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
12
- * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
13
- * But do note that this configuration depends on how your script is bundled, or lack of
14
- * bundling, and where your assets can be loaded from. Additionally custom bundling
15
- * will have to ensure the static assets are copied to its build directory.
16
- */
17
- export declare const setAssetPath: (path: string) => void;
18
-
19
- /**
20
- * Used to specify a nonce value that corresponds with an application's CSP.
21
- * When set, the nonce will be added to all dynamically created script and style tags at runtime.
22
- * Alternatively, the nonce value can be set on a meta tag in the DOM head
23
- * (<meta name="csp-nonce" content="{ nonce value here }" />) which
24
- * will result in the same behavior.
25
- */
26
- export declare const setNonce: (nonce: string) => void
27
-
28
- export interface SetPlatformOptions {
29
- raf?: (c: FrameRequestCallback) => number;
30
- ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
31
- rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
32
- }
33
- export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
@@ -1,2 +0,0 @@
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-3b0da608.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};
2
- //# sourceMappingURL=index.js.map