@sl-material/sl-table-sheet 1.0.0-beta2 → 1.0.0-beta4
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/config/config.d.ts +10 -0
- package/core/SheetTabs.d.ts +44 -0
- package/core/SlTableSheet.d.ts +73 -3
- package/core/TableSheet.d.ts +16 -8
- package/core/excel/ExcelParser.d.ts +9 -1
- package/core/excel/index.d.ts +13 -1
- package/core/excel/types.d.ts +24 -1
- package/core/managers/CellMarkManager.d.ts +12 -16
- package/core/managers/EventManager.d.ts +4 -0
- package/core/processors/DataProcessor.d.ts +3 -7
- package/core/processors/StyleProcessor.d.ts +10 -11
- package/index.d.ts +4 -2
- package/package.json +1 -1
- package/sl-table-sheet.cjs.js +244 -116
- package/sl-table-sheet.es.js +24891 -21298
- package/sl-table-sheet.umd.umd.js +241 -113
package/config/config.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SheetData } from './excel/types';
|
|
2
|
+
|
|
3
|
+
export interface SheetTabsConfig {
|
|
4
|
+
container: HTMLElement;
|
|
5
|
+
sheets: SheetData[];
|
|
6
|
+
activeIndex?: number;
|
|
7
|
+
onTabChange?: (sheetData: SheetData, index: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class SheetTabs {
|
|
10
|
+
private container;
|
|
11
|
+
private tabsElement;
|
|
12
|
+
private sheets;
|
|
13
|
+
private activeIndex;
|
|
14
|
+
private onTabChange?;
|
|
15
|
+
constructor(config: SheetTabsConfig);
|
|
16
|
+
private init;
|
|
17
|
+
private injectStyles;
|
|
18
|
+
private render;
|
|
19
|
+
private createTab;
|
|
20
|
+
/**
|
|
21
|
+
* 设置当前激活的标签
|
|
22
|
+
*/
|
|
23
|
+
setActiveTab(index: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* 更新 Sheet 数据
|
|
26
|
+
*/
|
|
27
|
+
updateSheets(sheets: SheetData[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* 更新单个 Sheet 的错误数量
|
|
30
|
+
*/
|
|
31
|
+
updateSheetError(index: number, errorCount: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* 获取当前激活的 Sheet 数据
|
|
34
|
+
*/
|
|
35
|
+
getActiveSheet(): SheetData | null;
|
|
36
|
+
/**
|
|
37
|
+
* 获取当前激活的索引
|
|
38
|
+
*/
|
|
39
|
+
getActiveIndex(): number;
|
|
40
|
+
/**
|
|
41
|
+
* 销毁组件
|
|
42
|
+
*/
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
package/core/SlTableSheet.d.ts
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
import { TableSheet, TableSheetConfig } from './TableSheet';
|
|
2
2
|
import { FindReplaceDialog } from './Dialog';
|
|
3
3
|
import { Toolbar, ToolbarConfig } from './Toolbar';
|
|
4
|
-
import {
|
|
4
|
+
import { SheetTabs } from './SheetTabs';
|
|
5
|
+
import { ExcelParseOptions, ExcelParseResult, MultiSheetParseResult, SheetData } from './excel';
|
|
5
6
|
|
|
6
7
|
export interface SlTableSheetConfig extends Omit<TableSheetConfig, "container"> {
|
|
7
8
|
container: HTMLElement | string;
|
|
8
9
|
showToolbar?: boolean;
|
|
10
|
+
/** 是否显示自定义 Sheet 标签页(用于多 Sheet Excel) */
|
|
11
|
+
showSheetTabs?: boolean;
|
|
9
12
|
toolbar?: Partial<ToolbarConfig>;
|
|
10
13
|
onExport?: (format: "csv" | "excel") => void;
|
|
11
14
|
onRefresh?: () => void;
|
|
12
15
|
onExcelImport?: (data: ExcelParseResult) => void;
|
|
16
|
+
/** 多 Sheet 导入回调 */
|
|
17
|
+
onMultiSheetImport?: (data: MultiSheetParseResult) => void;
|
|
18
|
+
/** Sheet 切换回调 */
|
|
19
|
+
onSheetChange?: (sheetData: SheetData, index: number) => void;
|
|
13
20
|
}
|
|
14
21
|
export declare class SlTableSheet {
|
|
15
22
|
private tableSheet;
|
|
16
23
|
private findReplaceDialog;
|
|
17
24
|
private toolbar;
|
|
25
|
+
private sheetTabs;
|
|
18
26
|
private container;
|
|
19
27
|
private tableContainer;
|
|
20
28
|
private toolbarContainer;
|
|
29
|
+
private sheetTabsContainer;
|
|
30
|
+
private loadingOverlay;
|
|
21
31
|
private config;
|
|
22
|
-
/**
|
|
23
|
-
private
|
|
32
|
+
/** 多 Sheet 数据 */
|
|
33
|
+
private multiSheetData;
|
|
24
34
|
constructor(config: SlTableSheetConfig);
|
|
25
35
|
/**
|
|
26
36
|
* 初始化
|
|
@@ -103,6 +113,14 @@ export declare class SlTableSheet {
|
|
|
103
113
|
* @param filename 文件名(不含扩展名)
|
|
104
114
|
*/
|
|
105
115
|
downloadExcel(filename?: string): void;
|
|
116
|
+
/**
|
|
117
|
+
* 显示 loading 状态
|
|
118
|
+
*/
|
|
119
|
+
showLoading(text?: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* 隐藏 loading 状态
|
|
122
|
+
*/
|
|
123
|
+
hideLoading(): void;
|
|
106
124
|
/**
|
|
107
125
|
* 解析在线 Excel 文件并显示到表格
|
|
108
126
|
* @param url Excel 文件的 URL 地址
|
|
@@ -130,6 +148,14 @@ export declare class SlTableSheet {
|
|
|
130
148
|
parseExcelFile(file: File, options?: ExcelParseOptions & {
|
|
131
149
|
autoDisplay?: boolean;
|
|
132
150
|
}): Promise<ExcelParseResult>;
|
|
151
|
+
/**
|
|
152
|
+
* 将批注数据合并到记录中,生成带 isMarked 标记的数据格式
|
|
153
|
+
*/
|
|
154
|
+
private mergeCommentsToRecords;
|
|
155
|
+
/**
|
|
156
|
+
* 处理数据并生成样式化的列配置
|
|
157
|
+
*/
|
|
158
|
+
private processDataWithStyles;
|
|
133
159
|
/**
|
|
134
160
|
* 处理 Excel 导入结果
|
|
135
161
|
*/
|
|
@@ -162,5 +188,49 @@ export declare class SlTableSheet {
|
|
|
162
188
|
* 销毁实例
|
|
163
189
|
*/
|
|
164
190
|
destroy(): void;
|
|
191
|
+
/**
|
|
192
|
+
* 从 URL 加载 Excel 所有 Sheet
|
|
193
|
+
*/
|
|
194
|
+
loadAllSheetsFromUrl(url: string, options?: Omit<ExcelParseOptions, "sheetIndex">): Promise<MultiSheetParseResult>;
|
|
195
|
+
/**
|
|
196
|
+
* 解析 Excel ArrayBuffer 的所有 Sheet
|
|
197
|
+
*/
|
|
198
|
+
parseAllSheets(buffer: ArrayBuffer, options?: Omit<ExcelParseOptions, "sheetIndex">): MultiSheetParseResult;
|
|
199
|
+
/**
|
|
200
|
+
* 处理多 Sheet 导入结果
|
|
201
|
+
*/
|
|
202
|
+
private handleMultiSheetImportResult;
|
|
203
|
+
/**
|
|
204
|
+
* 创建 Sheet 标签页
|
|
205
|
+
*/
|
|
206
|
+
private createSheetTabs;
|
|
207
|
+
/**
|
|
208
|
+
* 显示指定 Sheet 的数据
|
|
209
|
+
*/
|
|
210
|
+
private displaySheetData;
|
|
211
|
+
/**
|
|
212
|
+
* 更新 Sheet 的错误数量
|
|
213
|
+
*/
|
|
214
|
+
updateSheetError(sheetIndex: number, errorCount: number): void;
|
|
215
|
+
/**
|
|
216
|
+
* 获取当前激活的 Sheet 索引
|
|
217
|
+
*/
|
|
218
|
+
getActiveSheetIndex(): number;
|
|
219
|
+
/**
|
|
220
|
+
* 获取当前激活的 Sheet 数据
|
|
221
|
+
*/
|
|
222
|
+
getActiveSheetData(): SheetData | null;
|
|
223
|
+
/**
|
|
224
|
+
* 获取所有 Sheet 数据
|
|
225
|
+
*/
|
|
226
|
+
getAllSheetsData(): MultiSheetParseResult | null;
|
|
227
|
+
/**
|
|
228
|
+
* 切换到指定 Sheet
|
|
229
|
+
*/
|
|
230
|
+
switchToSheet(index: number): void;
|
|
231
|
+
/**
|
|
232
|
+
* 获取 SheetTabs 实例
|
|
233
|
+
*/
|
|
234
|
+
getSheetTabs(): SheetTabs | null;
|
|
165
235
|
}
|
|
166
236
|
export default SlTableSheet;
|
package/core/TableSheet.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MarkedMap } from './processors/StyleProcessor';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 自定义组件配置接口
|
|
3
5
|
*/
|
|
@@ -90,10 +92,7 @@ export declare class TableSheet {
|
|
|
90
92
|
private customComponentManager;
|
|
91
93
|
private cellMarkManager;
|
|
92
94
|
private eventManager;
|
|
93
|
-
constructor(config: TableSheetConfig, markedMap?:
|
|
94
|
-
isMarked: boolean;
|
|
95
|
-
comment?: string;
|
|
96
|
-
}>);
|
|
95
|
+
constructor(config: TableSheetConfig, markedMap?: MarkedMap);
|
|
97
96
|
/**
|
|
98
97
|
* 初始化表格
|
|
99
98
|
*/
|
|
@@ -106,6 +105,10 @@ export declare class TableSheet {
|
|
|
106
105
|
* 创建表格实例
|
|
107
106
|
*/
|
|
108
107
|
private createSheet;
|
|
108
|
+
/**
|
|
109
|
+
* 初始化 Manager
|
|
110
|
+
*/
|
|
111
|
+
private initManagers;
|
|
109
112
|
/**
|
|
110
113
|
* 修改单元格值
|
|
111
114
|
*/
|
|
@@ -168,10 +171,15 @@ export declare class TableSheet {
|
|
|
168
171
|
/**
|
|
169
172
|
* 获取标记映射
|
|
170
173
|
*/
|
|
171
|
-
getMarkedMap():
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
getMarkedMap(): MarkedMap | null;
|
|
175
|
+
/**
|
|
176
|
+
* 获取当前表格的所有数据(包括编辑后的最新值)
|
|
177
|
+
*/
|
|
178
|
+
getAllRecords(): any[][];
|
|
179
|
+
/**
|
|
180
|
+
* 获取列配置
|
|
181
|
+
*/
|
|
182
|
+
getColumns(): any[];
|
|
175
183
|
/**
|
|
176
184
|
* 监听事件
|
|
177
185
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExcelParseOptions, ExcelParseResult } from './types';
|
|
1
|
+
import { ExcelParseOptions, ExcelParseResult, MultiSheetParseResult } from './types';
|
|
2
2
|
|
|
3
3
|
export declare class ExcelParser {
|
|
4
4
|
/**
|
|
@@ -9,4 +9,12 @@ export declare class ExcelParser {
|
|
|
9
9
|
* 构建列配置
|
|
10
10
|
*/
|
|
11
11
|
private static buildColumns;
|
|
12
|
+
/**
|
|
13
|
+
* 解析 Excel 所有 Sheet
|
|
14
|
+
*/
|
|
15
|
+
static parseAllSheets(buffer: ArrayBuffer, options?: Omit<ExcelParseOptions, "sheetIndex">): MultiSheetParseResult;
|
|
16
|
+
/**
|
|
17
|
+
* 获取 Excel 文件的 Sheet 名称列表
|
|
18
|
+
*/
|
|
19
|
+
static getSheetNames(buffer: ArrayBuffer): string[];
|
|
12
20
|
}
|
package/core/excel/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExcelParseOptions, ExcelParseResult } from './types';
|
|
1
|
+
import { ExcelParseOptions, ExcelParseResult, MultiSheetParseResult } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Excel 模块统一导出
|
|
4
4
|
*/
|
|
@@ -13,3 +13,15 @@ export declare function exportToExcelStream(columns: any[], records: any[], opti
|
|
|
13
13
|
filterEmptyColumns?: boolean;
|
|
14
14
|
}): ArrayBuffer;
|
|
15
15
|
export declare function downloadExcel(buffer: ArrayBuffer, filename?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* 解析 Excel 所有 Sheet
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseAllSheets(buffer: ArrayBuffer, options?: Omit<ExcelParseOptions, "sheetIndex">): MultiSheetParseResult;
|
|
20
|
+
/**
|
|
21
|
+
* 从 URL 加载并解析 Excel 所有 Sheet
|
|
22
|
+
*/
|
|
23
|
+
export declare function loadAllSheetsFromUrl(url: string, options?: Omit<ExcelParseOptions, "sheetIndex">): Promise<MultiSheetParseResult>;
|
|
24
|
+
/**
|
|
25
|
+
* 获取 Excel 文件的 Sheet 名称列表
|
|
26
|
+
*/
|
|
27
|
+
export declare function getSheetNames(buffer: ArrayBuffer): string[];
|
package/core/excel/types.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface CellComment {
|
|
|
27
27
|
export interface ExcelParseResult {
|
|
28
28
|
columns: Array<{
|
|
29
29
|
key: string;
|
|
30
|
-
field: string;
|
|
30
|
+
field: string | number;
|
|
31
31
|
title: string;
|
|
32
32
|
width: number;
|
|
33
33
|
sort?: boolean;
|
|
@@ -37,3 +37,26 @@ export interface ExcelParseResult {
|
|
|
37
37
|
cellStyles?: Map<string, CellStyle>;
|
|
38
38
|
cellComments?: Map<string, CellComment>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 单个 Sheet 的解析结果
|
|
42
|
+
*/
|
|
43
|
+
export interface SheetData {
|
|
44
|
+
sheetName: string;
|
|
45
|
+
sheetIndex: number;
|
|
46
|
+
columns: ExcelParseResult["columns"];
|
|
47
|
+
records: any[][];
|
|
48
|
+
cellStyles?: Map<string, CellStyle>;
|
|
49
|
+
cellComments?: Map<string, CellComment>;
|
|
50
|
+
/** 是否有错误数据 */
|
|
51
|
+
hasError?: boolean;
|
|
52
|
+
/** 错误数量 */
|
|
53
|
+
errorCount?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 多 Sheet 解析结果
|
|
57
|
+
*/
|
|
58
|
+
export interface MultiSheetParseResult {
|
|
59
|
+
sheets: SheetData[];
|
|
60
|
+
sheetNames: string[];
|
|
61
|
+
activeSheetIndex: number;
|
|
62
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { MarkedMap } from '../processors/StyleProcessor';
|
|
2
|
+
|
|
4
3
|
export declare class CellMarkManager {
|
|
5
4
|
private markedMap;
|
|
6
5
|
private tableInstance;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}>);
|
|
6
|
+
private markedCellsSet;
|
|
7
|
+
private tooltipThrottle;
|
|
8
|
+
constructor(tableInstance: any, markedMap?: MarkedMap);
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* 处理单元格鼠标进入事件(性能优化版)
|
|
13
11
|
*/
|
|
14
12
|
handleCellMouseEnter(args: any): void;
|
|
15
13
|
/**
|
|
@@ -19,15 +17,13 @@ export declare class CellMarkManager {
|
|
|
19
17
|
/**
|
|
20
18
|
* 获取标记映射
|
|
21
19
|
*/
|
|
22
|
-
getMarkedMap():
|
|
23
|
-
isMarked: boolean;
|
|
24
|
-
comment?: string;
|
|
25
|
-
}> | null;
|
|
20
|
+
getMarkedMap(): MarkedMap | null;
|
|
26
21
|
/**
|
|
27
22
|
* 设置标记映射
|
|
28
23
|
*/
|
|
29
|
-
setMarkedMap(markedMap:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
setMarkedMap(markedMap: MarkedMap): void;
|
|
25
|
+
/**
|
|
26
|
+
* 销毁实例,清理引用
|
|
27
|
+
*/
|
|
28
|
+
destroy(): void;
|
|
33
29
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { MarkedMap } from './StyleProcessor';
|
|
2
|
+
|
|
4
3
|
export declare class DataProcessor {
|
|
5
4
|
/**
|
|
6
5
|
* 预处理数据:将 {value, isMarked} 格式转换为二维数组格式,并构建标记索引
|
|
7
6
|
*/
|
|
8
7
|
static processRecords(records: any[], columns: any[]): {
|
|
9
8
|
displayRecords: any[][];
|
|
10
|
-
markedMap:
|
|
11
|
-
isMarked: boolean;
|
|
12
|
-
comment?: string;
|
|
13
|
-
}>;
|
|
9
|
+
markedMap: MarkedMap;
|
|
14
10
|
};
|
|
15
11
|
/**
|
|
16
12
|
* 处理数组格式的行
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 样式处理器 - 处理列样式配置
|
|
3
|
+
*/
|
|
4
|
+
export interface MarkedInfo {
|
|
5
|
+
isMarked: boolean;
|
|
6
|
+
comment?: string;
|
|
7
|
+
}
|
|
8
|
+
export type MarkedMap = Map<string, MarkedInfo>;
|
|
3
9
|
export declare class StyleProcessor {
|
|
4
10
|
/**
|
|
5
|
-
* 初始化列配置,根据 markedMap
|
|
6
|
-
*/
|
|
7
|
-
static initColumns(columns: any[], markedMap: Map<string, {
|
|
8
|
-
isMarked: boolean;
|
|
9
|
-
comment?: string;
|
|
10
|
-
}>, cellStyles?: Map<string, CellStyle> | null): any[];
|
|
11
|
-
/**
|
|
12
|
-
* 应用 Excel 单元格样式
|
|
11
|
+
* 初始化列配置,根据 markedMap 添加高亮样式
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
static initColumns(columns: any[], markedMap: MarkedMap, headerRowCount?: number): any[];
|
|
15
14
|
}
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* 支持多种技术栈:Vue 2/3、原生 JS、Web Component
|
|
4
4
|
*/
|
|
5
5
|
export type { TableSheetConfig, SheetConfig, EditorConfig, CellInfo, } from './core/types';
|
|
6
|
-
export { loadExcelFromUrl, parseExcelFile, parseExcelBuffer, fetchExcelFromUrl, } from './core/
|
|
7
|
-
export type { ExcelParseOptions, ExcelParseResult, CellStyle, } from './core/
|
|
6
|
+
export { loadExcelFromUrl, parseExcelFile, parseExcelBuffer, fetchExcelFromUrl, parseAllSheets, loadAllSheetsFromUrl, getSheetNames, } from './core/excel';
|
|
7
|
+
export type { ExcelParseOptions, ExcelParseResult, CellStyle, SheetData, MultiSheetParseResult, } from './core/excel';
|
|
8
|
+
export { SheetTabs } from './core/SheetTabs';
|
|
9
|
+
export type { SheetTabsConfig } from './core/SheetTabs';
|
|
8
10
|
export { SlTableSheet as default } from './core/SlTableSheet';
|