@sl-material/sl-table-sheet 1.0.0-beta1 → 1.0.0-beta11
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 +11 -0
- package/core/SheetTabs.d.ts +44 -0
- package/core/SlTableSheet.d.ts +128 -5
- package/core/TableSheet.d.ts +34 -10
- package/core/Toolbar.d.ts +2 -24
- 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/core/styles/dialog.d.ts +5 -0
- package/core/styles/index.d.ts +2 -0
- package/core/styles/toolbar.d.ts +5 -0
- package/core/types.d.ts +3 -3
- package/core/utils/DomUtils.d.ts +23 -0
- package/core/utils/index.d.ts +1 -0
- package/index.d.ts +4 -2
- package/package.json +4 -5
- package/sl-table-sheet.cjs.js +612 -435
- package/sl-table-sheet.es.js +25844 -1414
- package/sl-table-sheet.umd.umd.js +591 -414
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,47 @@
|
|
|
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
|
|
|
7
|
+
/** Loading 配置 */
|
|
8
|
+
export interface LoadingConfig {
|
|
9
|
+
/** 是否显示 loading,默认 true */
|
|
10
|
+
show?: boolean;
|
|
11
|
+
/** loading 文本,默认 "加载中..." */
|
|
12
|
+
text?: string;
|
|
13
|
+
}
|
|
6
14
|
export interface SlTableSheetConfig extends Omit<TableSheetConfig, "container"> {
|
|
7
15
|
container: HTMLElement | string;
|
|
8
16
|
showToolbar?: boolean;
|
|
17
|
+
/** 是否显示自定义 Sheet 标签页(用于多 Sheet Excel),默认 true */
|
|
18
|
+
showTabs?: boolean;
|
|
19
|
+
/** 是否启用自动监听容器尺寸变化,默认 false */
|
|
20
|
+
autoResize?: boolean;
|
|
21
|
+
/** Loading 配置 */
|
|
22
|
+
loading?: LoadingConfig;
|
|
9
23
|
toolbar?: Partial<ToolbarConfig>;
|
|
10
24
|
onExport?: (format: "csv" | "excel") => void;
|
|
11
25
|
onRefresh?: () => void;
|
|
12
26
|
onExcelImport?: (data: ExcelParseResult) => void;
|
|
27
|
+
/** 多 Sheet 导入回调 */
|
|
28
|
+
onMultiSheetImport?: (data: MultiSheetParseResult) => void;
|
|
29
|
+
/** Sheet 切换回调 */
|
|
30
|
+
onSheetChange?: (sheetData: SheetData, index: number) => void;
|
|
13
31
|
}
|
|
14
32
|
export declare class SlTableSheet {
|
|
15
33
|
private tableSheet;
|
|
16
34
|
private findReplaceDialog;
|
|
17
35
|
private toolbar;
|
|
36
|
+
private sheetTabs;
|
|
18
37
|
private container;
|
|
19
38
|
private tableContainer;
|
|
20
39
|
private toolbarContainer;
|
|
40
|
+
private sheetTabsContainer;
|
|
41
|
+
private loadingOverlay;
|
|
21
42
|
private config;
|
|
22
|
-
/**
|
|
23
|
-
private
|
|
43
|
+
/** 多 Sheet 数据 */
|
|
44
|
+
private multiSheetData;
|
|
24
45
|
constructor(config: SlTableSheetConfig);
|
|
25
46
|
/**
|
|
26
47
|
* 初始化
|
|
@@ -54,14 +75,42 @@ export declare class SlTableSheet {
|
|
|
54
75
|
* 冻结列
|
|
55
76
|
*/
|
|
56
77
|
private freezeColumns;
|
|
78
|
+
/**
|
|
79
|
+
* 公开的冻结列方法
|
|
80
|
+
* @param colCount 要冻结的列数
|
|
81
|
+
*/
|
|
82
|
+
setFrozenColCount(colCount: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* 重新计算表格尺寸(容器大小变化时调用)
|
|
85
|
+
*/
|
|
86
|
+
resize(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 监听容器尺寸变化,自动调整表格大小
|
|
89
|
+
*/
|
|
90
|
+
private resizeObserver;
|
|
91
|
+
private lastObservedWidth;
|
|
92
|
+
private lastObservedHeight;
|
|
93
|
+
/**
|
|
94
|
+
* 检查 ResizeObserver 兼容性
|
|
95
|
+
*/
|
|
96
|
+
private isResizeObserverSupported;
|
|
97
|
+
/**
|
|
98
|
+
* 启用自动 resize(监听容器尺寸变化)
|
|
99
|
+
*/
|
|
100
|
+
enableAutoResize(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* 禁用自动 resize
|
|
103
|
+
*/
|
|
104
|
+
disableAutoResize(): void;
|
|
57
105
|
/**
|
|
58
106
|
* 注入样式
|
|
59
107
|
*/
|
|
60
108
|
private injectStyles;
|
|
61
109
|
/**
|
|
62
110
|
* 更新标题统计
|
|
111
|
+
* @deprecated 此方法已废弃,请使用 leftSlot 自定义标题内容
|
|
63
112
|
*/
|
|
64
|
-
updateTitleStats(
|
|
113
|
+
updateTitleStats(_count: number, _total: number): void;
|
|
65
114
|
/**
|
|
66
115
|
* 获取 TableSheet 实例
|
|
67
116
|
*/
|
|
@@ -103,14 +152,31 @@ export declare class SlTableSheet {
|
|
|
103
152
|
* @param filename 文件名(不含扩展名)
|
|
104
153
|
*/
|
|
105
154
|
downloadExcel(filename?: string): void;
|
|
155
|
+
/**
|
|
156
|
+
* 显示 loading 状态
|
|
157
|
+
* @param text loading 文本,不传则使用配置中的默认文本
|
|
158
|
+
*/
|
|
159
|
+
showLoading(text?: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* 隐藏 loading 状态
|
|
162
|
+
*/
|
|
163
|
+
hideLoading(): void;
|
|
164
|
+
/**
|
|
165
|
+
* 设置 loading 状态
|
|
166
|
+
* @param visible 是否显示
|
|
167
|
+
* @param text loading 文本
|
|
168
|
+
*/
|
|
169
|
+
setLoading(visible: boolean, text?: string): void;
|
|
106
170
|
/**
|
|
107
171
|
* 解析在线 Excel 文件并显示到表格
|
|
108
172
|
* @param url Excel 文件的 URL 地址
|
|
109
|
-
* @param options
|
|
173
|
+
* @param options 解析选项,支持 showLoading 和 loadingText 覆盖全局配置
|
|
110
174
|
* @returns 解析后的列配置和数据
|
|
111
175
|
*/
|
|
112
176
|
loadExcelFromUrl(url: string, options?: ExcelParseOptions & {
|
|
113
177
|
autoDisplay?: boolean;
|
|
178
|
+
showLoading?: boolean;
|
|
179
|
+
loadingText?: string;
|
|
114
180
|
}): Promise<ExcelParseResult>;
|
|
115
181
|
/**
|
|
116
182
|
* 解析 Excel ArrayBuffer 并显示到表格
|
|
@@ -130,6 +196,14 @@ export declare class SlTableSheet {
|
|
|
130
196
|
parseExcelFile(file: File, options?: ExcelParseOptions & {
|
|
131
197
|
autoDisplay?: boolean;
|
|
132
198
|
}): Promise<ExcelParseResult>;
|
|
199
|
+
/**
|
|
200
|
+
* 将批注数据合并到记录中,生成带 isMarked 标记的数据格式
|
|
201
|
+
*/
|
|
202
|
+
private mergeCommentsToRecords;
|
|
203
|
+
/**
|
|
204
|
+
* 处理数据并生成样式化的列配置
|
|
205
|
+
*/
|
|
206
|
+
private processDataWithStyles;
|
|
133
207
|
/**
|
|
134
208
|
* 处理 Excel 导入结果
|
|
135
209
|
*/
|
|
@@ -162,5 +236,54 @@ export declare class SlTableSheet {
|
|
|
162
236
|
* 销毁实例
|
|
163
237
|
*/
|
|
164
238
|
destroy(): void;
|
|
239
|
+
/**
|
|
240
|
+
* 从 URL 加载 Excel 所有 Sheet
|
|
241
|
+
* @param url Excel 文件的 URL 地址
|
|
242
|
+
* @param options 解析选项,支持 showLoading 和 loadingText 覆盖全局配置
|
|
243
|
+
*/
|
|
244
|
+
loadAllSheetsFromUrl(url: string, options?: Omit<ExcelParseOptions, "sheetIndex"> & {
|
|
245
|
+
showLoading?: boolean;
|
|
246
|
+
loadingText?: string;
|
|
247
|
+
}): Promise<MultiSheetParseResult>;
|
|
248
|
+
/**
|
|
249
|
+
* 解析 Excel ArrayBuffer 的所有 Sheet
|
|
250
|
+
*/
|
|
251
|
+
parseAllSheets(buffer: ArrayBuffer, options?: Omit<ExcelParseOptions, "sheetIndex">): MultiSheetParseResult;
|
|
252
|
+
/**
|
|
253
|
+
* 处理多 Sheet 导入结果
|
|
254
|
+
*/
|
|
255
|
+
private handleMultiSheetImportResult;
|
|
256
|
+
/**
|
|
257
|
+
* 创建 Sheet 标签页
|
|
258
|
+
*/
|
|
259
|
+
private createSheetTabs;
|
|
260
|
+
/**
|
|
261
|
+
* 显示指定 Sheet 的数据
|
|
262
|
+
*/
|
|
263
|
+
private displaySheetData;
|
|
264
|
+
/**
|
|
265
|
+
* 更新 Sheet 的错误数量
|
|
266
|
+
*/
|
|
267
|
+
updateSheetError(sheetIndex: number, errorCount: number): void;
|
|
268
|
+
/**
|
|
269
|
+
* 获取当前激活的 Sheet 索引
|
|
270
|
+
*/
|
|
271
|
+
getActiveSheetIndex(): number;
|
|
272
|
+
/**
|
|
273
|
+
* 获取当前激活的 Sheet 数据
|
|
274
|
+
*/
|
|
275
|
+
getActiveSheetData(): SheetData | null;
|
|
276
|
+
/**
|
|
277
|
+
* 获取所有 Sheet 数据
|
|
278
|
+
*/
|
|
279
|
+
getAllSheetsData(): MultiSheetParseResult | null;
|
|
280
|
+
/**
|
|
281
|
+
* 切换到指定 Sheet
|
|
282
|
+
*/
|
|
283
|
+
switchToSheet(index: number): void;
|
|
284
|
+
/**
|
|
285
|
+
* 获取 SheetTabs 实例
|
|
286
|
+
*/
|
|
287
|
+
getSheetTabs(): SheetTabs | null;
|
|
165
288
|
}
|
|
166
289
|
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
|
*/
|
|
@@ -51,8 +53,8 @@ export interface TableSheetConfig {
|
|
|
51
53
|
records?: any[];
|
|
52
54
|
/** 是否显示公式栏 */
|
|
53
55
|
showFormulaBar?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
+
/** 是否显示工作表标签(VTable原生),默认 false */
|
|
57
|
+
showSheets?: boolean;
|
|
56
58
|
/** 工作表配置 */
|
|
57
59
|
sheets?: any[];
|
|
58
60
|
/** 编辑器配置 */
|
|
@@ -90,10 +92,10 @@ export declare class TableSheet {
|
|
|
90
92
|
private customComponentManager;
|
|
91
93
|
private cellMarkManager;
|
|
92
94
|
private eventManager;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
private lastWidth;
|
|
96
|
+
private lastHeight;
|
|
97
|
+
private resizeTimeout;
|
|
98
|
+
constructor(config: TableSheetConfig, markedMap?: MarkedMap);
|
|
97
99
|
/**
|
|
98
100
|
* 初始化表格
|
|
99
101
|
*/
|
|
@@ -106,6 +108,10 @@ export declare class TableSheet {
|
|
|
106
108
|
* 创建表格实例
|
|
107
109
|
*/
|
|
108
110
|
private createSheet;
|
|
111
|
+
/**
|
|
112
|
+
* 初始化 Manager
|
|
113
|
+
*/
|
|
114
|
+
private initManagers;
|
|
109
115
|
/**
|
|
110
116
|
* 修改单元格值
|
|
111
117
|
*/
|
|
@@ -154,6 +160,19 @@ export declare class TableSheet {
|
|
|
154
160
|
* 刷新表格
|
|
155
161
|
*/
|
|
156
162
|
refresh(): void;
|
|
163
|
+
/**
|
|
164
|
+
* 冻结列
|
|
165
|
+
* @param colCount 要冻结的列数
|
|
166
|
+
*/
|
|
167
|
+
setFrozenColCount(colCount: number): void;
|
|
168
|
+
/**
|
|
169
|
+
* 重新计算表格尺寸(容器大小变化时调用)
|
|
170
|
+
*/
|
|
171
|
+
resize(): void;
|
|
172
|
+
/**
|
|
173
|
+
* 防抖的 resize 方法(用于频繁触发的场景)
|
|
174
|
+
*/
|
|
175
|
+
resizeDebounced(): void;
|
|
157
176
|
/**
|
|
158
177
|
* 获取原始实例
|
|
159
178
|
*/
|
|
@@ -168,10 +187,15 @@ export declare class TableSheet {
|
|
|
168
187
|
/**
|
|
169
188
|
* 获取标记映射
|
|
170
189
|
*/
|
|
171
|
-
getMarkedMap():
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
190
|
+
getMarkedMap(): MarkedMap | null;
|
|
191
|
+
/**
|
|
192
|
+
* 获取当前表格的所有数据(包括编辑后的最新值)
|
|
193
|
+
*/
|
|
194
|
+
getAllRecords(): any[][];
|
|
195
|
+
/**
|
|
196
|
+
* 获取列配置
|
|
197
|
+
*/
|
|
198
|
+
getColumns(): any[];
|
|
175
199
|
/**
|
|
176
200
|
* 监听事件
|
|
177
201
|
*/
|
package/core/Toolbar.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
export interface ToolbarConfig {
|
|
3
3
|
container?: HTMLElement | string;
|
|
4
|
-
|
|
5
|
-
count?: number;
|
|
6
|
-
total?: number;
|
|
7
|
-
hint?: string;
|
|
4
|
+
/** 冻结列数 */
|
|
8
5
|
freezeCount?: number;
|
|
6
|
+
/** 是否显示错误列表 */
|
|
9
7
|
showErrorList?: boolean;
|
|
10
8
|
/** 左侧自定义内容,可以是 HTMLElement 或返回 HTMLElement 的函数 */
|
|
11
9
|
leftSlot?: HTMLElement | (() => HTMLElement) | null;
|
|
@@ -26,10 +24,6 @@ export declare class Toolbar {
|
|
|
26
24
|
private config;
|
|
27
25
|
private elements;
|
|
28
26
|
constructor(config: ToolbarConfig);
|
|
29
|
-
/**
|
|
30
|
-
* 初始化
|
|
31
|
-
*/
|
|
32
|
-
private init;
|
|
33
27
|
/**
|
|
34
28
|
* 获取容器
|
|
35
29
|
*/
|
|
@@ -54,26 +48,10 @@ export declare class Toolbar {
|
|
|
54
48
|
* 创建冻结列选择器(标题 + 数字输入框 + 上下箭头)
|
|
55
49
|
*/
|
|
56
50
|
private createFreezeButton;
|
|
57
|
-
/**
|
|
58
|
-
* 格式化数字(添加千分位)
|
|
59
|
-
*/
|
|
60
|
-
private formatNumber;
|
|
61
51
|
/**
|
|
62
52
|
* 注入样式
|
|
63
53
|
*/
|
|
64
54
|
private injectStyles;
|
|
65
|
-
/**
|
|
66
|
-
* 更新标题
|
|
67
|
-
*/
|
|
68
|
-
updateTitle(title: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* 更新统计数据
|
|
71
|
-
*/
|
|
72
|
-
updateStats(count: number, total: number): void;
|
|
73
|
-
/**
|
|
74
|
-
* 更新提示信息
|
|
75
|
-
*/
|
|
76
|
-
updateHint(hint: string): void;
|
|
77
55
|
/**
|
|
78
56
|
* 更新冻结列数
|
|
79
57
|
*/
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialog 样式
|
|
3
|
+
*/
|
|
4
|
+
export declare const DIALOG_STYLES = "\n .find-replace-dialog {\n position: fixed;\n top: 80px;\n left: 50%;\n transform: translateX(-50%);\n z-index: 9999;\n font-size: 14px;\n color: #1D2129;\n pointer-events: auto;\n }\n\n .find-replace-container {\n background: white;\n border-radius: 8px;\n width: 500px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);\n animation: slideIn 0.2s ease-out;\n }\n\n @keyframes slideIn {\n from { opacity: 0; transform: translateX(20px); }\n to { opacity: 1; transform: translateX(0); }\n }\n\n .find-replace-title {\n font-size: 16px;\n font-weight: 500;\n color: #303133;\n }\n\n .find-replace-body {\n padding: 16px;\n }\n\n .find-replace-group {\n margin-bottom: 16px;\n display: flex;\n align-items: center;\n }\n\n .find-replace-label {\n display: block;\n min-width: 56px;\n margin-right: 8px;\n }\n\n .find-replace-checkbox {\n display: none;\n align-items: center;\n font-weight: normal;\n min-width: auto;\n margin-right: 0;\n }\n\n .find-replace-checkbox input {\n margin-right: 6px;\n }\n\n .find-replace-input-wrapper {\n position: relative;\n display: flex;\n align-items: center;\n flex: 1;\n height: 32px;\n }\n\n .find-replace-input {\n width: 100%;\n padding: 0px 12px;\n border: 1px solid #dcdfe6;\n border-radius: 4px;\n height: 32px;\n }\n\n .find-replace-input:focus {\n outline: none;\n border-color: #409eff;\n }\n\n .current-position {\n margin-left: 10px;\n color: #409eff;\n font-weight: 500;\n }\n\n .find-replace-footer {\n padding: 0px 16px 16px 16px;\n display: flex;\n justify-content: flex-end;\n gap: 8px;\n flex-wrap: wrap;\n }\n\n .find-replace-btn {\n padding: 6px 16px;\n border-radius: 4px;\n height: 32px;\n cursor: pointer;\n background: var(--sl-color-white);\n border: 1px solid var(--sl-border-color);\n }\n\n .find-replace-btn-primary {\n background-color: var(--sl-color-primary);\n color: white;\n }\n\n .find-replace-btn-primary:hover {\n border-color: var(--sl-button-hover-border-color);\n background-color: var(--sl-button-hover-bg-color);\n }\n\n .message-toast {\n height: 40px;\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%) translateY(-100px);\n padding: 11px 15px;\n color: white;\n border-radius: 4px;\n box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);\n z-index: 9999;\n opacity: 0;\n transition: all 0.3s ease-out;\n display: flex;\n align-items: center;\n }\n\n .message-toast--info {\n background-color: var(--sl-color-info-light-9);\n border: 1px solid var(--sl-color-info-light-8);\n color: var(--sl-color-info);\n }\n\n .message-toast--success {\n background-color: var(--sl-color-success-light-9);\n border: 1px solid var(--sl-color-success-light-8);\n color: var(--sl-color-success);\n }\n\n .message-toast--warning {\n background-color: var(--sl-color-warning-light-9);\n border: 1px solid var(--sl-color-warning-light-8);\n color: var(--sl-color-warning);\n }\n\n .message-toast--error {\n background-color: var(--sl-color-error-light-9);\n border: 1px solid var(--sl-color-error-light-8);\n color: var(--sl-color-error);\n }\n\n .message-toast.show {\n transform: translateX(-50%) translateY(0);\n opacity: 1;\n }\n";
|
|
5
|
+
export declare const DIALOG_STYLE_ID = "find-replace-styles";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar 样式
|
|
3
|
+
*/
|
|
4
|
+
export declare const TOOLBAR_STYLES = "\n .sl-toolbar {\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 8px 16px;\n background: var(--sl-vtable-card-bg-color);\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n flex-shrink: 0;\n border-radius: 4px;\n }\n \n .sl-toolbar-right {\n display: flex;\n align-items: center;\n gap: 24px;\n }\n\n .sl-toolbar-btn {\n padding: 6px 16px;\n height: 32px;\n border: 1px solid var(--sl-vtable-bg-color1);\n border-radius: 4px;\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n cursor: pointer;\n white-space: nowrap;\n }\n\n .sl-toolbar-btn:hover {\n background: #E8E9EB;\n }\n\n .sl-toolbar-btn-icon {\n padding: 6px 10px;\n font-size: 16px;\n min-width: 32px;\n }\n\n .sl-toolbar-btn-complex {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .sl-btn-icon {\n font-size: 14px;\n }\n\n .sl-btn-text {\n font-size: 14px;\n }\n\n .sl-btn-count {\n font-size: 14px;\n font-weight: 600;\n color: var(--sl-vtable-primary-color);\n }\n\n .sl-btn-suffix {\n font-size: 14px;\n }\n\n .sl-freeze-selector {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n .sl-freeze-label {\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n white-space: nowrap;\n }\n\n .sl-freeze-input-wrapper {\n position: relative;\n display: inline-flex;\n align-items: center;\n background: var(--sl-vtable-bg-color1);\n border: 1px solid var(--sl-vtable-bg-color1);\n border-radius: 4px;\n transition: all 0.2s;\n height: 32px;\n box-sizing: border-box;\n }\n\n .sl-freeze-input-wrapper:focus-within {\n border-color: var(--sl-vtable-primary-color);\n box-shadow: 0 0 0 2px rgba(40, 120, 255, 0.1);\n }\n\n .sl-freeze-input {\n width: 30px;\n height: 30px;\n padding: 0px 2px;\n border-radius: 4px 0px 0px 4px;\n background: #fff;\n border: none;\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n text-align: center;\n outline: none;\n -moz-appearance: textfield;\n }\n\n .sl-freeze-input::-webkit-outer-spin-button,\n .sl-freeze-input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n\n .sl-freeze-arrows {\n display: flex;\n flex-direction: column;\n border-left: 1px solid #E5E6EB;\n }\n\n .sl-freeze-arrow {\n width: 20px;\n height: 10px;\n padding: 0;\n background: transparent;\n border: none;\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n\n .sl-freeze-arrow-up {\n border-radius: 0 8px 0 0;\n }\n\n .sl-freeze-arrow-down {\n border-radius: 0 0 8px 0;\n transform: rotate(180deg);\n }\n\n .sl-freeze-suffix {\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n }\n\n .sl-error-list-checkbox {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n user-select: none;\n }\n\n .sl-checkbox-input {\n position: absolute;\n opacity: 0;\n width: 0;\n height: 0;\n }\n\n .sl-checkbox-custom {\n position: relative;\n width: 16px;\n height: 16px;\n border: 2px solid #C9CDD4;\n border-radius: 4px;\n background: #fff;\n transition: all 0.2s;\n flex-shrink: 0;\n }\n\n .sl-checkbox-input:checked + .sl-checkbox-custom {\n background: var(--sl-vtable-primary-color);\n border-color: var(--sl-vtable-primary-color);\n }\n\n .sl-checkbox-input:checked + .sl-checkbox-custom::after {\n content: \"\";\n position: absolute;\n left: 4px;\n top: 1px;\n width: 4px;\n height: 8px;\n border: solid white;\n border-width: 0 2px 2px 0;\n transform: rotate(45deg);\n }\n\n .sl-error-list-checkbox:hover .sl-checkbox-custom {\n border-color: var(--sl-vtable-primary-color);\n }\n\n .sl-checkbox-label {\n font-size: 14px;\n color: var(--sl-vtable-content-color);\n }\n\n /* \u54CD\u5E94\u5F0F\u8BBE\u8BA1 */\n @media (max-width: 768px) {\n .sl-toolbar {\n flex-direction: column;\n align-items: flex-start;\n gap: 12px;\n }\n\n .sl-toolbar-left {\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n }\n\n .sl-toolbar-right {\n width: 100%;\n justify-content: flex-start;\n flex-wrap: wrap;\n }\n }\n";
|
|
5
|
+
export declare const TOOLBAR_STYLE_ID = "sl-toolbar-styles";
|
package/core/types.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export interface TableSheetConfig {
|
|
|
10
10
|
records?: any[];
|
|
11
11
|
/** 是否显示公式栏 */
|
|
12
12
|
showFormulaBar?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** 是否显示工作表标签(VTable原生),默认 false */
|
|
14
|
+
showSheets?: boolean;
|
|
15
15
|
/** 工作表配置 */
|
|
16
16
|
sheets?: SheetConfig[];
|
|
17
17
|
/** 编辑器配置 */
|
|
@@ -32,7 +32,7 @@ export interface SheetConfig {
|
|
|
32
32
|
columns: any[];
|
|
33
33
|
data: any[];
|
|
34
34
|
dragOrder?: {
|
|
35
|
-
dragHeaderMode?:
|
|
35
|
+
dragHeaderMode?: "all" | "column" | "row";
|
|
36
36
|
};
|
|
37
37
|
[key: string]: any;
|
|
38
38
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM 工具类 - 提取公共的 DOM 操作方法
|
|
3
|
+
*/
|
|
4
|
+
export declare class DomUtils {
|
|
5
|
+
/**
|
|
6
|
+
* 获取容器元素
|
|
7
|
+
* @param container 容器元素或选择器
|
|
8
|
+
*/
|
|
9
|
+
static getContainer(container: HTMLElement | string): HTMLElement | null;
|
|
10
|
+
/**
|
|
11
|
+
* 注入样式到页面
|
|
12
|
+
* @param id 样式标签的 ID
|
|
13
|
+
* @param css CSS 内容
|
|
14
|
+
*/
|
|
15
|
+
static injectStyles(id: string, css: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* 创建元素并设置属性
|
|
18
|
+
* @param tag 标签名
|
|
19
|
+
* @param className 类名
|
|
20
|
+
* @param innerHTML 内部 HTML
|
|
21
|
+
*/
|
|
22
|
+
static createElement<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, innerHTML?: string): HTMLElementTagNameMap[K];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DomUtils } from './DomUtils';
|
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';
|