@univerjs/sheets-table 0.20.1 → 0.21.0-insiders.20260422-d7fcb4d
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/lib/cjs/facade.js +207 -1
- package/lib/cjs/index.js +3944 -1
- package/lib/es/facade.js +208 -1
- package/lib/es/index.js +3893 -1
- package/lib/facade.js +208 -1
- package/lib/index.js +3893 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1,207 @@
|
|
|
1
|
-
let
|
|
1
|
+
let _univerjs_core = require("@univerjs/core");
|
|
2
|
+
let _univerjs_sheets_table = require("@univerjs/sheets-table");
|
|
3
|
+
let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
|
|
4
|
+
let _univerjs_sheets = require("@univerjs/sheets");
|
|
5
|
+
let _univerjs_core_facade = require("@univerjs/core/facade");
|
|
6
|
+
|
|
7
|
+
//#region src/facade/f-workbook.ts
|
|
8
|
+
var FWorkbookSheetsTableMixin = class extends _univerjs_sheets_facade.FWorkbook {
|
|
9
|
+
getTableInfo(tableId) {
|
|
10
|
+
const unitId = this.getId();
|
|
11
|
+
return this._injector.get(_univerjs_sheets_table.SheetTableService).getTableInfo(unitId, tableId);
|
|
12
|
+
}
|
|
13
|
+
getTableList() {
|
|
14
|
+
const unitId = this.getId();
|
|
15
|
+
return this._injector.get(_univerjs_sheets_table.SheetTableService).getTableList(unitId);
|
|
16
|
+
}
|
|
17
|
+
async addTable(subUnitId, tableName, rangeInfo, tableId, options) {
|
|
18
|
+
const sheetTableService = this._injector.get(_univerjs_sheets_table.SheetTableService);
|
|
19
|
+
const localeService = this._injector.get(_univerjs_core.LocaleService);
|
|
20
|
+
const workbook = this._injector.get(_univerjs_core.IUniverInstanceService).getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
21
|
+
const sheetNameSet = /* @__PURE__ */ new Set();
|
|
22
|
+
if (workbook) workbook.getSheets().forEach((sheet) => {
|
|
23
|
+
sheetNameSet.add(sheet.getName());
|
|
24
|
+
});
|
|
25
|
+
if (!(0, _univerjs_core.customNameCharacterCheck)(tableName, sheetNameSet)) {
|
|
26
|
+
this._injector.get(_univerjs_core.ILogService).warn(localeService.t("sheets-table.tableNameError"));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const addTableParams = {
|
|
30
|
+
unitId: this.getId(),
|
|
31
|
+
name: tableName,
|
|
32
|
+
subUnitId,
|
|
33
|
+
range: rangeInfo,
|
|
34
|
+
options,
|
|
35
|
+
id: tableId
|
|
36
|
+
};
|
|
37
|
+
if (await this._commandService.executeCommand(_univerjs_sheets_table.AddSheetTableCommand.id, addTableParams)) {
|
|
38
|
+
var _sheetTableService$ge;
|
|
39
|
+
return (_sheetTableService$ge = sheetTableService.getTableList(this.getId()).find((table) => table.name === tableName)) === null || _sheetTableService$ge === void 0 ? void 0 : _sheetTableService$ge.id;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async removeTable(tableId) {
|
|
43
|
+
var _this$getTableInfo;
|
|
44
|
+
const subUnitId = (_this$getTableInfo = this.getTableInfo(tableId)) === null || _this$getTableInfo === void 0 ? void 0 : _this$getTableInfo.subUnitId;
|
|
45
|
+
if (!subUnitId) return false;
|
|
46
|
+
const removedTableParams = {
|
|
47
|
+
unitId: this.getId(),
|
|
48
|
+
subUnitId,
|
|
49
|
+
tableId
|
|
50
|
+
};
|
|
51
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, removedTableParams);
|
|
52
|
+
}
|
|
53
|
+
getTableInfoByName(tableName) {
|
|
54
|
+
return this.getTableList().find((table) => table.name === tableName);
|
|
55
|
+
}
|
|
56
|
+
setTableFilter(tableId, column, filter) {
|
|
57
|
+
const setTableFilterParams = {
|
|
58
|
+
unitId: this.getId(),
|
|
59
|
+
tableId,
|
|
60
|
+
column,
|
|
61
|
+
tableFilter: filter
|
|
62
|
+
};
|
|
63
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
_univerjs_sheets_facade.FWorkbook.extend(FWorkbookSheetsTableMixin);
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/facade/f-worksheet.ts
|
|
70
|
+
var FWorksheetTableMixin = class extends _univerjs_sheets_facade.FWorksheet {
|
|
71
|
+
addTable(tableName, rangeInfo, tableId, options) {
|
|
72
|
+
const subUnitId = this.getSheetId();
|
|
73
|
+
const workbook = this.getWorkbook();
|
|
74
|
+
const unitId = workbook.getUnitId();
|
|
75
|
+
const localeService = this._injector.get(_univerjs_core.LocaleService);
|
|
76
|
+
const sheetNameSet = /* @__PURE__ */ new Set();
|
|
77
|
+
if (workbook) workbook.getSheets().forEach((sheet) => {
|
|
78
|
+
sheetNameSet.add(sheet.getName());
|
|
79
|
+
});
|
|
80
|
+
if (!(0, _univerjs_core.customNameCharacterCheck)(tableName, sheetNameSet)) {
|
|
81
|
+
this._injector.get(_univerjs_core.ILogService).warn(localeService.t("sheets-table.tableNameError"));
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const addTableParams = {
|
|
85
|
+
unitId,
|
|
86
|
+
subUnitId,
|
|
87
|
+
name: tableName,
|
|
88
|
+
range: rangeInfo,
|
|
89
|
+
id: tableId,
|
|
90
|
+
options
|
|
91
|
+
};
|
|
92
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.AddSheetTableCommand.id, addTableParams);
|
|
93
|
+
}
|
|
94
|
+
setTableFilter(tableId, column, filter) {
|
|
95
|
+
const setTableFilterParams = {
|
|
96
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
97
|
+
tableId,
|
|
98
|
+
column,
|
|
99
|
+
tableFilter: filter
|
|
100
|
+
};
|
|
101
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
102
|
+
}
|
|
103
|
+
removeTable(tableId) {
|
|
104
|
+
const removedTableParams = {
|
|
105
|
+
unitId: this._fWorkbook.getId(),
|
|
106
|
+
subUnitId: this.getSheetId(),
|
|
107
|
+
tableId
|
|
108
|
+
};
|
|
109
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, removedTableParams);
|
|
110
|
+
}
|
|
111
|
+
setTableRange(tableId, rangeInfo) {
|
|
112
|
+
const tableSetConfig = {
|
|
113
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
114
|
+
tableId,
|
|
115
|
+
updateRange: { newRange: rangeInfo }
|
|
116
|
+
};
|
|
117
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, tableSetConfig);
|
|
118
|
+
}
|
|
119
|
+
setTableName(tableId, tableName) {
|
|
120
|
+
const workbook = this.getWorkbook();
|
|
121
|
+
const localeService = this._injector.get(_univerjs_core.LocaleService);
|
|
122
|
+
const sheetNameSet = /* @__PURE__ */ new Set();
|
|
123
|
+
if (workbook) workbook.getSheets().forEach((sheet) => {
|
|
124
|
+
sheetNameSet.add(sheet.getName());
|
|
125
|
+
});
|
|
126
|
+
if (!(0, _univerjs_core.customNameCharacterCheck)(tableName, sheetNameSet)) {
|
|
127
|
+
this._injector.get(_univerjs_core.ILogService).warn(localeService.t("sheets-table.tableNameError"));
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const tableSetConfig = {
|
|
131
|
+
unitId: this.getWorkbook().getUnitId(),
|
|
132
|
+
tableId,
|
|
133
|
+
name: tableName
|
|
134
|
+
};
|
|
135
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, tableSetConfig);
|
|
136
|
+
}
|
|
137
|
+
getSubTableInfos() {
|
|
138
|
+
const unitId = this._fWorkbook.getId();
|
|
139
|
+
return this._injector.get(_univerjs_sheets_table.SheetTableService).getTableList(unitId).filter((table) => table.subUnitId === this.getSheetId());
|
|
140
|
+
}
|
|
141
|
+
resetFilter(tableId, column) {
|
|
142
|
+
const setTableFilterParams = {
|
|
143
|
+
unitId: this._fWorkbook.getId(),
|
|
144
|
+
tableId,
|
|
145
|
+
column,
|
|
146
|
+
tableFilter: void 0
|
|
147
|
+
};
|
|
148
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
149
|
+
}
|
|
150
|
+
getTableByCell(row, column) {
|
|
151
|
+
const unitId = this._fWorkbook.getId();
|
|
152
|
+
const allSubTableInfos = this._injector.get(_univerjs_sheets_table.SheetTableService).getTableList(unitId).filter((table) => table.subUnitId === this.getSheetId());
|
|
153
|
+
const cellRange = (0, _univerjs_core.cellToRange)(row, column);
|
|
154
|
+
return allSubTableInfos.find((table) => {
|
|
155
|
+
const tableRange = table.range;
|
|
156
|
+
return _univerjs_core.Rectangle.intersects(tableRange, cellRange);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
addTableTheme(tableId, themeStyleJSON) {
|
|
160
|
+
const themeStyle = new _univerjs_sheets.RangeThemeStyle("table-style");
|
|
161
|
+
themeStyle.fromJson(themeStyleJSON);
|
|
162
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.AddTableThemeCommand.id, {
|
|
163
|
+
unitId: this._fWorkbook.getId(),
|
|
164
|
+
tableId,
|
|
165
|
+
themeStyle
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
_univerjs_sheets_facade.FWorksheet.extend(FWorksheetTableMixin);
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/facade/f-enum.ts
|
|
173
|
+
/**
|
|
174
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
175
|
+
*
|
|
176
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
+
* you may not use this file except in compliance with the License.
|
|
178
|
+
* You may obtain a copy of the License at
|
|
179
|
+
*
|
|
180
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
+
*
|
|
182
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
183
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
+
* See the License for the specific language governing permissions and
|
|
186
|
+
* limitations under the License.
|
|
187
|
+
*/
|
|
188
|
+
var FSheetsTableEnumMixin = class extends _univerjs_core_facade.FEnum {
|
|
189
|
+
get TableColumnFilterTypeEnum() {
|
|
190
|
+
return _univerjs_sheets_table.TableColumnFilterTypeEnum;
|
|
191
|
+
}
|
|
192
|
+
get TableConditionTypeEnum() {
|
|
193
|
+
return _univerjs_sheets_table.TableConditionTypeEnum;
|
|
194
|
+
}
|
|
195
|
+
get TableNumberCompareTypeEnum() {
|
|
196
|
+
return _univerjs_sheets_table.TableNumberCompareTypeEnum;
|
|
197
|
+
}
|
|
198
|
+
get TableStringCompareTypeEnum() {
|
|
199
|
+
return _univerjs_sheets_table.TableStringCompareTypeEnum;
|
|
200
|
+
}
|
|
201
|
+
get TableDateCompareTypeEnum() {
|
|
202
|
+
return _univerjs_sheets_table.TableDateCompareTypeEnum;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
_univerjs_core_facade.FEnum.extend(FSheetsTableEnumMixin);
|
|
206
|
+
|
|
207
|
+
//#endregion
|