@file-viewer/renderer-spreadsheet 2.1.16 → 2.1.18
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/spreadsheet.d.ts +32 -0
- package/dist/spreadsheet.js +30 -1
- package/package.json +3 -3
package/dist/spreadsheet.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
import { type FileRenderContext, type FileViewerRenderedInstance as AppWrapper } from '@file-viewer/core';
|
|
2
|
+
type EVirtTableInstance = {
|
|
3
|
+
ctx: {
|
|
4
|
+
body: {
|
|
5
|
+
headIndex?: number;
|
|
6
|
+
tailIndex?: number;
|
|
7
|
+
};
|
|
8
|
+
scrollX?: number;
|
|
9
|
+
scrollY?: number;
|
|
10
|
+
selector?: {
|
|
11
|
+
xArr: number[];
|
|
12
|
+
yArr: number[];
|
|
13
|
+
xArrCopy: number[];
|
|
14
|
+
yArrCopy: number[];
|
|
15
|
+
};
|
|
16
|
+
emit?(type: string, ...args: unknown[]): void;
|
|
17
|
+
};
|
|
18
|
+
on(type: string, handler: (...args: any[]) => void): void;
|
|
19
|
+
loadConfig(config: unknown): void;
|
|
20
|
+
loadColumns(columns: unknown[]): void;
|
|
21
|
+
loadData(rows: unknown[]): void;
|
|
22
|
+
setCustomHeader?(customHeader: unknown, ignoreEmit?: boolean): void;
|
|
23
|
+
draw(): void;
|
|
24
|
+
doLayout(): void;
|
|
25
|
+
scrollTo(x: number, y: number): void;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
};
|
|
28
|
+
type EVirtTableConstructor = new (container: HTMLElement, options: {
|
|
29
|
+
data: unknown[];
|
|
30
|
+
columns: unknown[];
|
|
31
|
+
config: unknown;
|
|
32
|
+
}) => EVirtTableInstance;
|
|
33
|
+
export declare const resolveEVirtTableConstructor: (module: unknown) => EVirtTableConstructor;
|
|
2
34
|
declare const renderFileViewerSpreadsheet: (buffer: ArrayBuffer, target: HTMLDivElement, _type?: string, context?: FileRenderContext) => Promise<AppWrapper>;
|
|
3
35
|
export default renderFileViewerSpreadsheet;
|
package/dist/spreadsheet.js
CHANGED
|
@@ -44,9 +44,38 @@ const spreadsheetStyle = `
|
|
|
44
44
|
@keyframes sheet-loading-pulse{0%,100%{opacity:.55;transform:scale(.9)}50%{opacity:1;transform:scale(1)}}
|
|
45
45
|
@media (max-width:720px){.excel-wrapper .toolbar{align-items:stretch;flex-direction:column}.excel-wrapper .btn-group{flex:0 0 auto}.excel-wrapper .summary{max-width:none;white-space:normal}.excel-wrapper .sheet-loading{left:12px;right:12px;bottom:58px;justify-content:center}.excel-wrapper .loading-card{margin:18px;flex-direction:column;text-align:center}}
|
|
46
46
|
`;
|
|
47
|
+
const isEVirtTableConstructor = (value) => {
|
|
48
|
+
return typeof value === 'function';
|
|
49
|
+
};
|
|
50
|
+
const asModuleRecord = (value) => {
|
|
51
|
+
return value && typeof value === 'object'
|
|
52
|
+
? value
|
|
53
|
+
: null;
|
|
54
|
+
};
|
|
55
|
+
export const resolveEVirtTableConstructor = (module) => {
|
|
56
|
+
const record = asModuleRecord(module);
|
|
57
|
+
const defaultRecord = asModuleRecord(record === null || record === void 0 ? void 0 : record.default);
|
|
58
|
+
const moduleExportsRecord = asModuleRecord(record === null || record === void 0 ? void 0 : record['module.exports']);
|
|
59
|
+
const candidates = [
|
|
60
|
+
module,
|
|
61
|
+
record === null || record === void 0 ? void 0 : record.default,
|
|
62
|
+
record === null || record === void 0 ? void 0 : record.EVirtTable,
|
|
63
|
+
record === null || record === void 0 ? void 0 : record['module.exports'],
|
|
64
|
+
defaultRecord === null || defaultRecord === void 0 ? void 0 : defaultRecord.default,
|
|
65
|
+
defaultRecord === null || defaultRecord === void 0 ? void 0 : defaultRecord.EVirtTable,
|
|
66
|
+
moduleExportsRecord === null || moduleExportsRecord === void 0 ? void 0 : moduleExportsRecord.default,
|
|
67
|
+
moduleExportsRecord === null || moduleExportsRecord === void 0 ? void 0 : moduleExportsRecord.EVirtTable,
|
|
68
|
+
];
|
|
69
|
+
const constructor = candidates.find(isEVirtTableConstructor);
|
|
70
|
+
if (!constructor) {
|
|
71
|
+
const keys = record ? Object.keys(record).join(', ') : typeof module;
|
|
72
|
+
throw new Error(`Unable to resolve e-virt-table constructor from module exports: ${keys}`);
|
|
73
|
+
}
|
|
74
|
+
return constructor;
|
|
75
|
+
};
|
|
47
76
|
const loadEVirtTable = async () => {
|
|
48
77
|
const module = await import('e-virt-table');
|
|
49
|
-
return module
|
|
78
|
+
return resolveEVirtTableConstructor(module);
|
|
50
79
|
};
|
|
51
80
|
const getTargetWindow = (target) => {
|
|
52
81
|
return target.ownerDocument.defaultView;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@file-viewer/renderer-spreadsheet",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.18",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Standalone spreadsheet renderer plugin for Flyfish File Viewer powered by styled-exceljs and e-virt-table.",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"funding": {
|
|
40
40
|
"type": "individual",
|
|
41
|
-
"url": "https://dev.flyfish.group/
|
|
41
|
+
"url": "https://dev.flyfish.group/donate?source=npm"
|
|
42
42
|
},
|
|
43
43
|
"main": "./dist/index.js",
|
|
44
44
|
"module": "./dist/index.js",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"LICENSE"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@file-viewer/core": "^2.1.
|
|
71
|
+
"@file-viewer/core": "^2.1.18",
|
|
72
72
|
"e-virt-table": "^1.3.26",
|
|
73
73
|
"styled-exceljs": "0.21.1",
|
|
74
74
|
"tinycolor2": "^1.6.0"
|