@univerjs/sheets-table-ui 0.25.0 → 1.0.0-alpha.0
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/index.js +984 -956
- package/lib/es/index.js +985 -957
- package/lib/index.js +985 -957
- package/lib/types/const.d.ts +0 -1
- package/lib/types/controllers/components.controller.d.ts +24 -0
- package/lib/types/controllers/sheet-table-component.controller.d.ts +2 -4
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/menu/menu.d.ts +6 -5
- package/lib/types/menu/sheet-table-menu.controller.d.ts +3 -3
- package/lib/types/views/components/SheetTableConditionPanel.d.ts +1 -1
- package/lib/types/views/components/SheetTableFilterPanel.d.ts +1 -1
- package/lib/types/views/components/SheetTableItemsFilterPanel.d.ts +1 -1
- package/lib/types/views/components/SheetTableRenameDialog.d.ts +1 -1
- package/lib/types/views/components/SheetTableSelector.d.ts +1 -1
- package/lib/types/views/components/SheetTableThemePanel.d.ts +1 -1
- package/lib/types/views/components/util.d.ts +1 -21
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandS
|
|
|
2
2
|
import { CURSOR_TYPE, DEFAULT_FONTFACE_PLANE, IRenderManagerService, Rect, Shape } from "@univerjs/engine-render";
|
|
3
3
|
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableController, SheetsTableSortStateEnum, TABLE_FILTER_EMPTY_VALUE, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, getExistingNamesSet, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle, validateSheetTableName } from "@univerjs/sheets-table";
|
|
4
4
|
import { ISheetSelectionRenderService, SHEET_VIEW_KEY, SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, getCoordByCell, getCurrentRangeDisable$, getTransformCoord } from "@univerjs/sheets-ui";
|
|
5
|
-
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, MenuItemType, RibbonDataGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
5
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonDataGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
6
6
|
import { Subject, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
7
|
-
import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
8
|
-
import { AscendingIcon, DeleteColumnDoubleIcon, DescendingIcon, DropdownIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, RightInsertColumnDoubleIcon, TableIcon } from "@univerjs/icons";
|
|
9
7
|
import { INTERCEPTOR_POINT, RangeThemeStyle, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
|
|
8
|
+
import { AscendingIcon, DeleteColumnDoubleIcon, DescendingIcon, DropdownIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, RightInsertColumnDoubleIcon, TableIcon } from "@univerjs/icons";
|
|
9
|
+
import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
10
10
|
import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
|
|
11
11
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -15,7 +15,7 @@ import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
|
15
15
|
|
|
16
16
|
//#region package.json
|
|
17
17
|
var name = "@univerjs/sheets-table-ui";
|
|
18
|
-
var version = "0.
|
|
18
|
+
var version = "1.0.0-alpha.0";
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/const.ts
|
|
@@ -37,7 +37,6 @@ var version = "0.25.0";
|
|
|
37
37
|
const PLUGIN_NAME = "SHEET_TABLE_UI_PLUGIN";
|
|
38
38
|
const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = "SHEETS_TABLE_FILTER_PANEL_OPENED_KEY";
|
|
39
39
|
const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
40
|
-
const TABLE_TOOLBAR_BUTTON = "TABLE_TOOLBAR_BUTTON";
|
|
41
40
|
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
42
41
|
const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
|
|
43
42
|
const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
@@ -50,7 +49,7 @@ const TABLE_BORDER_NONE = "none";
|
|
|
50
49
|
const TABLE_BORDER_DEFAULT = "1px solid rgb(var(--grey-200))";
|
|
51
50
|
|
|
52
51
|
//#endregion
|
|
53
|
-
//#region \0@oxc-project+runtime@0.
|
|
52
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
54
53
|
function _typeof(o) {
|
|
55
54
|
"@babel/helpers - typeof";
|
|
56
55
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -61,7 +60,7 @@ function _typeof(o) {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
//#endregion
|
|
64
|
-
//#region \0@oxc-project+runtime@0.
|
|
63
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
65
64
|
function toPrimitive(t, r) {
|
|
66
65
|
if ("object" != _typeof(t) || !t) return t;
|
|
67
66
|
var e = t[Symbol.toPrimitive];
|
|
@@ -74,14 +73,14 @@ function toPrimitive(t, r) {
|
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
//#endregion
|
|
77
|
-
//#region \0@oxc-project+runtime@0.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
78
77
|
function toPropertyKey(t) {
|
|
79
78
|
var i = toPrimitive(t, "string");
|
|
80
79
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
//#endregion
|
|
84
|
-
//#region \0@oxc-project+runtime@0.
|
|
83
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
85
84
|
function _defineProperty(e, r, t) {
|
|
86
85
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
87
86
|
value: t,
|
|
@@ -92,7 +91,7 @@ function _defineProperty(e, r, t) {
|
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
//#endregion
|
|
95
|
-
//#region \0@oxc-project+runtime@0.
|
|
94
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
96
95
|
function __decorateParam(paramIndex, decorator) {
|
|
97
96
|
return function(target, key) {
|
|
98
97
|
decorator(target, key, paramIndex);
|
|
@@ -100,7 +99,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
//#endregion
|
|
103
|
-
//#region \0@oxc-project+runtime@0.
|
|
102
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
104
103
|
function __decorate(decorators, target, key, desc) {
|
|
105
104
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
106
105
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -108,6 +107,182 @@ function __decorate(decorators, target, key, desc) {
|
|
|
108
107
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
109
108
|
}
|
|
110
109
|
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/controllers/sheet-table-component.controller.ts
|
|
112
|
+
let SheetsTableComponentController = class SheetsTableComponentController extends Disposable {
|
|
113
|
+
constructor(_contextService, _sheetCanvasPopupService, _dialogService) {
|
|
114
|
+
super();
|
|
115
|
+
this._contextService = _contextService;
|
|
116
|
+
this._sheetCanvasPopupService = _sheetCanvasPopupService;
|
|
117
|
+
this._dialogService = _dialogService;
|
|
118
|
+
_defineProperty(this, "_popupDisposable", void 0);
|
|
119
|
+
_defineProperty(this, "_currentTableFilterInfo", null);
|
|
120
|
+
this._initUIPopup();
|
|
121
|
+
}
|
|
122
|
+
setCurrentTableFilterInfo(info) {
|
|
123
|
+
this._currentTableFilterInfo = info;
|
|
124
|
+
}
|
|
125
|
+
openOrToggleFilterPanel(info) {
|
|
126
|
+
const opened = this._contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY);
|
|
127
|
+
if (opened && this._isSameFilterPanelInfo(this._currentTableFilterInfo, info)) {
|
|
128
|
+
this.closeFilterPanel();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.setCurrentTableFilterInfo(info);
|
|
132
|
+
if (opened) {
|
|
133
|
+
var _this$_popupDisposabl;
|
|
134
|
+
(_this$_popupDisposabl = this._popupDisposable) === null || _this$_popupDisposabl === void 0 || _this$_popupDisposabl.dispose();
|
|
135
|
+
this._popupDisposable = null;
|
|
136
|
+
this._openFilterPopup();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
140
|
+
}
|
|
141
|
+
clearCurrentTableFilterInfo() {
|
|
142
|
+
this._currentTableFilterInfo = null;
|
|
143
|
+
}
|
|
144
|
+
getCurrentTableFilterInfo() {
|
|
145
|
+
return this._currentTableFilterInfo;
|
|
146
|
+
}
|
|
147
|
+
_initUIPopup() {
|
|
148
|
+
this.disposeWithMe(this._contextService.subscribeContextValue$(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY).pipe(startWith(void 0), distinctUntilChanged()).subscribe((open) => {
|
|
149
|
+
if (open) this._openFilterPopup();
|
|
150
|
+
else if (open === false) this._closeFilterPopup();
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
closeFilterPanel() {
|
|
154
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
155
|
+
}
|
|
156
|
+
_openFilterPopup() {
|
|
157
|
+
const currentFilterModel = this._currentTableFilterInfo;
|
|
158
|
+
if (!currentFilterModel) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
159
|
+
const { row: startRow, column: col } = currentFilterModel;
|
|
160
|
+
this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(startRow, col, {
|
|
161
|
+
componentKey: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,
|
|
162
|
+
direction: "horizontal",
|
|
163
|
+
onClickOutside: () => {
|
|
164
|
+
this._dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);
|
|
165
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
166
|
+
},
|
|
167
|
+
offset: [5, 0],
|
|
168
|
+
portal: true
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
_closeFilterPopup() {
|
|
172
|
+
var _this$_popupDisposabl2;
|
|
173
|
+
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
174
|
+
this._popupDisposable = null;
|
|
175
|
+
this.clearCurrentTableFilterInfo();
|
|
176
|
+
}
|
|
177
|
+
_isSameFilterPanelInfo(a, b) {
|
|
178
|
+
return Boolean(a && a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.tableId === b.tableId && a.column === b.column && a.row === b.row);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
SheetsTableComponentController = __decorate([
|
|
182
|
+
__decorateParam(0, IContextService),
|
|
183
|
+
__decorateParam(1, Inject(SheetCanvasPopManagerService)),
|
|
184
|
+
__decorateParam(2, Inject(IDialogService))
|
|
185
|
+
], SheetsTableComponentController);
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/commands/operations/open-table-filter-dialog.opration.ts
|
|
189
|
+
const OpenTableFilterPanelOperation = {
|
|
190
|
+
type: CommandType.OPERATION,
|
|
191
|
+
id: "sheet.operation.open-table-filter-panel",
|
|
192
|
+
async handler(accessor, params) {
|
|
193
|
+
if (!params) return false;
|
|
194
|
+
const { row, col, unitId, subUnitId, tableId } = params;
|
|
195
|
+
const tableManager = accessor.get(TableManager);
|
|
196
|
+
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
197
|
+
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
198
|
+
sheetsTableComponentController.openOrToggleFilterPanel({
|
|
199
|
+
unitId,
|
|
200
|
+
subUnitId,
|
|
201
|
+
row,
|
|
202
|
+
tableId,
|
|
203
|
+
column: col
|
|
204
|
+
});
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/commands/operations/open-table-selector.operation.ts
|
|
211
|
+
const OpenTableSelectorOperation = {
|
|
212
|
+
type: CommandType.OPERATION,
|
|
213
|
+
id: "sheet.operation.open-table-selector",
|
|
214
|
+
async handler(accessor) {
|
|
215
|
+
var _lastSelection$range;
|
|
216
|
+
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
217
|
+
const commandService = accessor.get(ICommandService);
|
|
218
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
219
|
+
if (!target) return false;
|
|
220
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
221
|
+
const lastSelection = accessor.get(SheetsSelectionsService).getCurrentLastSelection();
|
|
222
|
+
const range = (_lastSelection$range = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) !== null && _lastSelection$range !== void 0 ? _lastSelection$range : {
|
|
223
|
+
startRow: 0,
|
|
224
|
+
endRow: 0,
|
|
225
|
+
startColumn: 0,
|
|
226
|
+
endColumn: 0
|
|
227
|
+
};
|
|
228
|
+
const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, isSingleCellSelection(lastSelection) ? expandToContinuousRange(range, {
|
|
229
|
+
up: true,
|
|
230
|
+
left: true,
|
|
231
|
+
right: true,
|
|
232
|
+
down: true
|
|
233
|
+
}, worksheet) : range);
|
|
234
|
+
if (!rangeInfo) return false;
|
|
235
|
+
commandService.executeCommand(AddSheetTableCommand.id, { ...rangeInfo });
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
async function openRangeSelector(accessor, unitId, subUnitId, range, tableId) {
|
|
240
|
+
const dialogService = accessor.get(IDialogService);
|
|
241
|
+
const localeService = accessor.get(LocaleService);
|
|
242
|
+
return new Promise((resolve) => {
|
|
243
|
+
const dialogProps = {
|
|
244
|
+
unitId,
|
|
245
|
+
subUnitId,
|
|
246
|
+
range,
|
|
247
|
+
tableId,
|
|
248
|
+
onConfirm: (info) => {
|
|
249
|
+
resolve(info);
|
|
250
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
251
|
+
},
|
|
252
|
+
onCancel: () => {
|
|
253
|
+
resolve(null);
|
|
254
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
dialogService.open({
|
|
258
|
+
id: TABLE_SELECTOR_DIALOG,
|
|
259
|
+
title: { title: localeService.t("sheets-table-ui.selectRange") },
|
|
260
|
+
draggable: true,
|
|
261
|
+
destroyOnClose: true,
|
|
262
|
+
mask: false,
|
|
263
|
+
maskClosable: false,
|
|
264
|
+
children: { label: {
|
|
265
|
+
name: TABLE_SELECTOR_DIALOG,
|
|
266
|
+
props: dialogProps
|
|
267
|
+
} },
|
|
268
|
+
width: 300,
|
|
269
|
+
onClose: () => {
|
|
270
|
+
resolve(null);
|
|
271
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/config/config.ts
|
|
279
|
+
const SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY = "sheets-table-ui.config";
|
|
280
|
+
const configSymbol = Symbol(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
281
|
+
const defaultPluginConfig = {
|
|
282
|
+
anchorHeight: 24,
|
|
283
|
+
anchorBackgroundColor: "rgb(134,139,156)"
|
|
284
|
+
};
|
|
285
|
+
|
|
111
286
|
//#endregion
|
|
112
287
|
//#region src/services/sheets-table-ui.service.ts
|
|
113
288
|
let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
@@ -248,175 +423,175 @@ SheetsTableUiService = __decorate([
|
|
|
248
423
|
//#endregion
|
|
249
424
|
//#region src/views/components/util.ts
|
|
250
425
|
function getCascaderListOptions(injector) {
|
|
251
|
-
const
|
|
426
|
+
const localeService = injector.get(LocaleService);
|
|
252
427
|
return [
|
|
253
428
|
{
|
|
254
429
|
value: TableConditionTypeEnum.String,
|
|
255
|
-
label: t(`sheets-table-ui.condition.${TableConditionTypeEnum.String}`),
|
|
430
|
+
label: localeService.t(`sheets-table-ui.condition.${TableConditionTypeEnum.String}`),
|
|
256
431
|
children: [
|
|
257
432
|
{
|
|
258
433
|
value: TableStringCompareTypeEnum.Equal,
|
|
259
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.Equal}`)
|
|
434
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.Equal}`)
|
|
260
435
|
},
|
|
261
436
|
{
|
|
262
437
|
value: TableStringCompareTypeEnum.NotEqual,
|
|
263
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.NotEqual}`)
|
|
438
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.NotEqual}`)
|
|
264
439
|
},
|
|
265
440
|
{
|
|
266
441
|
value: TableStringCompareTypeEnum.Contains,
|
|
267
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.Contains}`)
|
|
442
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.Contains}`)
|
|
268
443
|
},
|
|
269
444
|
{
|
|
270
445
|
value: TableStringCompareTypeEnum.NotContains,
|
|
271
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.NotContains}`)
|
|
446
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.NotContains}`)
|
|
272
447
|
},
|
|
273
448
|
{
|
|
274
449
|
value: TableStringCompareTypeEnum.StartsWith,
|
|
275
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.StartsWith}`)
|
|
450
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.StartsWith}`)
|
|
276
451
|
},
|
|
277
452
|
{
|
|
278
453
|
value: TableStringCompareTypeEnum.EndsWith,
|
|
279
|
-
label: t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.EndsWith}`)
|
|
454
|
+
label: localeService.t(`sheets-table-ui.string.compare.${TableStringCompareTypeEnum.EndsWith}`)
|
|
280
455
|
}
|
|
281
456
|
]
|
|
282
457
|
},
|
|
283
458
|
{
|
|
284
459
|
value: TableConditionTypeEnum.Number,
|
|
285
|
-
label: t(`sheets-table-ui.condition.${TableConditionTypeEnum.Number}`),
|
|
460
|
+
label: localeService.t(`sheets-table-ui.condition.${TableConditionTypeEnum.Number}`),
|
|
286
461
|
children: [
|
|
287
462
|
{
|
|
288
463
|
value: TableNumberCompareTypeEnum.Equal,
|
|
289
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Equal}`)
|
|
464
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Equal}`)
|
|
290
465
|
},
|
|
291
466
|
{
|
|
292
467
|
value: TableNumberCompareTypeEnum.NotEqual,
|
|
293
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.NotEqual}`)
|
|
468
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.NotEqual}`)
|
|
294
469
|
},
|
|
295
470
|
{
|
|
296
471
|
value: TableNumberCompareTypeEnum.GreaterThan,
|
|
297
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.GreaterThan}`)
|
|
472
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.GreaterThan}`)
|
|
298
473
|
},
|
|
299
474
|
{
|
|
300
475
|
value: TableNumberCompareTypeEnum.GreaterThanOrEqual,
|
|
301
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.GreaterThanOrEqual}`)
|
|
476
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.GreaterThanOrEqual}`)
|
|
302
477
|
},
|
|
303
478
|
{
|
|
304
479
|
value: TableNumberCompareTypeEnum.LessThan,
|
|
305
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.LessThan}`)
|
|
480
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.LessThan}`)
|
|
306
481
|
},
|
|
307
482
|
{
|
|
308
483
|
value: TableNumberCompareTypeEnum.LessThanOrEqual,
|
|
309
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.LessThanOrEqual}`)
|
|
484
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.LessThanOrEqual}`)
|
|
310
485
|
},
|
|
311
486
|
{
|
|
312
487
|
value: TableNumberCompareTypeEnum.Between,
|
|
313
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Between}`)
|
|
488
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Between}`)
|
|
314
489
|
},
|
|
315
490
|
{
|
|
316
491
|
value: TableNumberCompareTypeEnum.NotBetween,
|
|
317
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.NotBetween}`)
|
|
492
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.NotBetween}`)
|
|
318
493
|
},
|
|
319
494
|
{
|
|
320
495
|
value: TableNumberCompareTypeEnum.Above,
|
|
321
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Above}`)
|
|
496
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Above}`)
|
|
322
497
|
},
|
|
323
498
|
{
|
|
324
499
|
value: TableNumberCompareTypeEnum.Below,
|
|
325
|
-
label: t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Below}`)
|
|
500
|
+
label: localeService.t(`sheets-table-ui.number.compare.${TableNumberCompareTypeEnum.Below}`)
|
|
326
501
|
}
|
|
327
502
|
]
|
|
328
503
|
},
|
|
329
504
|
{
|
|
330
505
|
value: TableConditionTypeEnum.Date,
|
|
331
|
-
label: t(`sheets-table-ui.condition.${TableConditionTypeEnum.Date}`),
|
|
506
|
+
label: localeService.t(`sheets-table-ui.condition.${TableConditionTypeEnum.Date}`),
|
|
332
507
|
children: [
|
|
333
508
|
{
|
|
334
509
|
value: TableDateCompareTypeEnum.Equal,
|
|
335
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Equal}`)
|
|
510
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Equal}`)
|
|
336
511
|
},
|
|
337
512
|
{
|
|
338
513
|
value: TableDateCompareTypeEnum.NotEqual,
|
|
339
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NotEqual}`)
|
|
514
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NotEqual}`)
|
|
340
515
|
},
|
|
341
516
|
{
|
|
342
517
|
value: TableDateCompareTypeEnum.After,
|
|
343
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.After}`)
|
|
518
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.After}`)
|
|
344
519
|
},
|
|
345
520
|
{
|
|
346
521
|
value: TableDateCompareTypeEnum.AfterOrEqual,
|
|
347
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.AfterOrEqual}`)
|
|
522
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.AfterOrEqual}`)
|
|
348
523
|
},
|
|
349
524
|
{
|
|
350
525
|
value: TableDateCompareTypeEnum.Before,
|
|
351
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Before}`)
|
|
526
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Before}`)
|
|
352
527
|
},
|
|
353
528
|
{
|
|
354
529
|
value: TableDateCompareTypeEnum.BeforeOrEqual,
|
|
355
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.BeforeOrEqual}`)
|
|
530
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.BeforeOrEqual}`)
|
|
356
531
|
},
|
|
357
532
|
{
|
|
358
533
|
value: TableDateCompareTypeEnum.Between,
|
|
359
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Between}`)
|
|
534
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Between}`)
|
|
360
535
|
},
|
|
361
536
|
{
|
|
362
537
|
value: TableDateCompareTypeEnum.NotBetween,
|
|
363
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NotBetween}`)
|
|
538
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NotBetween}`)
|
|
364
539
|
},
|
|
365
540
|
{
|
|
366
541
|
value: TableDateCompareTypeEnum.Today,
|
|
367
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Today}`)
|
|
542
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Today}`)
|
|
368
543
|
},
|
|
369
544
|
{
|
|
370
545
|
value: TableDateCompareTypeEnum.Yesterday,
|
|
371
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Yesterday}`)
|
|
546
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Yesterday}`)
|
|
372
547
|
},
|
|
373
548
|
{
|
|
374
549
|
value: TableDateCompareTypeEnum.Tomorrow,
|
|
375
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Tomorrow}`)
|
|
550
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Tomorrow}`)
|
|
376
551
|
},
|
|
377
552
|
{
|
|
378
553
|
value: TableDateCompareTypeEnum.ThisWeek,
|
|
379
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisWeek}`)
|
|
554
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisWeek}`)
|
|
380
555
|
},
|
|
381
556
|
{
|
|
382
557
|
value: TableDateCompareTypeEnum.LastWeek,
|
|
383
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastWeek}`)
|
|
558
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastWeek}`)
|
|
384
559
|
},
|
|
385
560
|
{
|
|
386
561
|
value: TableDateCompareTypeEnum.NextWeek,
|
|
387
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextWeek}`)
|
|
562
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextWeek}`)
|
|
388
563
|
},
|
|
389
564
|
{
|
|
390
565
|
value: TableDateCompareTypeEnum.ThisMonth,
|
|
391
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisMonth}`)
|
|
566
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisMonth}`)
|
|
392
567
|
},
|
|
393
568
|
{
|
|
394
569
|
value: TableDateCompareTypeEnum.LastMonth,
|
|
395
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastMonth}`)
|
|
570
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastMonth}`)
|
|
396
571
|
},
|
|
397
572
|
{
|
|
398
573
|
value: TableDateCompareTypeEnum.NextMonth,
|
|
399
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextMonth}`)
|
|
574
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextMonth}`)
|
|
400
575
|
},
|
|
401
576
|
{
|
|
402
577
|
value: TableDateCompareTypeEnum.ThisYear,
|
|
403
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisYear}`)
|
|
578
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.ThisYear}`)
|
|
404
579
|
},
|
|
405
580
|
{
|
|
406
581
|
value: TableDateCompareTypeEnum.LastYear,
|
|
407
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastYear}`)
|
|
582
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.LastYear}`)
|
|
408
583
|
},
|
|
409
584
|
{
|
|
410
585
|
value: TableDateCompareTypeEnum.NextYear,
|
|
411
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextYear}`)
|
|
586
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.NextYear}`)
|
|
412
587
|
},
|
|
413
588
|
{
|
|
414
589
|
value: TableDateCompareTypeEnum.Quarter,
|
|
415
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Quarter}`)
|
|
590
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Quarter}`)
|
|
416
591
|
},
|
|
417
592
|
{
|
|
418
593
|
value: TableDateCompareTypeEnum.Month,
|
|
419
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Month}`)
|
|
594
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Month}`)
|
|
420
595
|
}
|
|
421
596
|
]
|
|
422
597
|
}
|
|
@@ -424,80 +599,80 @@ function getCascaderListOptions(injector) {
|
|
|
424
599
|
}
|
|
425
600
|
function getConditionDateSelect(injector, dateType) {
|
|
426
601
|
if (!dateType) return [];
|
|
427
|
-
const
|
|
602
|
+
const localeService = injector.get(LocaleService);
|
|
428
603
|
switch (dateType) {
|
|
429
604
|
case TableDateCompareTypeEnum.Quarter: return [
|
|
430
605
|
{
|
|
431
606
|
value: TableDateCompareTypeEnum.Q1,
|
|
432
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q1}`)
|
|
607
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q1}`)
|
|
433
608
|
},
|
|
434
609
|
{
|
|
435
610
|
value: TableDateCompareTypeEnum.Q2,
|
|
436
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q2}`)
|
|
611
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q2}`)
|
|
437
612
|
},
|
|
438
613
|
{
|
|
439
614
|
value: TableDateCompareTypeEnum.Q3,
|
|
440
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q3}`)
|
|
615
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q3}`)
|
|
441
616
|
},
|
|
442
617
|
{
|
|
443
618
|
value: TableDateCompareTypeEnum.Q4,
|
|
444
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q4}`)
|
|
619
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.Q4}`)
|
|
445
620
|
}
|
|
446
621
|
];
|
|
447
622
|
case TableDateCompareTypeEnum.Month: return [
|
|
448
623
|
{
|
|
449
624
|
value: TableDateCompareTypeEnum.M1,
|
|
450
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M1}`)
|
|
625
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M1}`)
|
|
451
626
|
},
|
|
452
627
|
{
|
|
453
628
|
value: TableDateCompareTypeEnum.M2,
|
|
454
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M2}`)
|
|
629
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M2}`)
|
|
455
630
|
},
|
|
456
631
|
{
|
|
457
632
|
value: TableDateCompareTypeEnum.M3,
|
|
458
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M3}`)
|
|
633
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M3}`)
|
|
459
634
|
},
|
|
460
635
|
{
|
|
461
636
|
value: TableDateCompareTypeEnum.M4,
|
|
462
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M4}`)
|
|
637
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M4}`)
|
|
463
638
|
},
|
|
464
639
|
{
|
|
465
640
|
value: TableDateCompareTypeEnum.M5,
|
|
466
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M5}`)
|
|
641
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M5}`)
|
|
467
642
|
},
|
|
468
643
|
{
|
|
469
644
|
value: TableDateCompareTypeEnum.M6,
|
|
470
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M6}`)
|
|
645
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M6}`)
|
|
471
646
|
},
|
|
472
647
|
{
|
|
473
648
|
value: TableDateCompareTypeEnum.M7,
|
|
474
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M7}`)
|
|
649
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M7}`)
|
|
475
650
|
},
|
|
476
651
|
{
|
|
477
652
|
value: TableDateCompareTypeEnum.M8,
|
|
478
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M8}`)
|
|
653
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M8}`)
|
|
479
654
|
},
|
|
480
655
|
{
|
|
481
656
|
value: TableDateCompareTypeEnum.M9,
|
|
482
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M9}`)
|
|
657
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M9}`)
|
|
483
658
|
},
|
|
484
659
|
{
|
|
485
660
|
value: TableDateCompareTypeEnum.M10,
|
|
486
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M10}`)
|
|
661
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M10}`)
|
|
487
662
|
},
|
|
488
663
|
{
|
|
489
664
|
value: TableDateCompareTypeEnum.M11,
|
|
490
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M11}`)
|
|
665
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M11}`)
|
|
491
666
|
},
|
|
492
667
|
{
|
|
493
668
|
value: TableDateCompareTypeEnum.M12,
|
|
494
|
-
label: t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M12}`)
|
|
669
|
+
label: localeService.t(`sheets-table-ui.date.compare.${TableDateCompareTypeEnum.M12}`)
|
|
495
670
|
}
|
|
496
671
|
];
|
|
497
672
|
default: return [];
|
|
498
673
|
}
|
|
499
674
|
}
|
|
500
|
-
const datePickerSet = new Set([
|
|
675
|
+
const datePickerSet = /* @__PURE__ */ new Set([
|
|
501
676
|
TableDateCompareTypeEnum.Equal,
|
|
502
677
|
TableDateCompareTypeEnum.NotEqual,
|
|
503
678
|
TableDateCompareTypeEnum.After,
|
|
@@ -521,7 +696,7 @@ function getSubComponentType(type, compare) {
|
|
|
521
696
|
function getInitConditionInfo(tableFilter) {
|
|
522
697
|
if (!tableFilter || tableFilter.filterType !== "condition") return {
|
|
523
698
|
type: TableConditionTypeEnum.String,
|
|
524
|
-
|
|
699
|
+
compare: TableStringCompareTypeEnum.Equal,
|
|
525
700
|
info: {}
|
|
526
701
|
};
|
|
527
702
|
const filterInfo = tableFilter.filterInfo;
|
|
@@ -550,12 +725,12 @@ function getInitConditionInfo(tableFilter) {
|
|
|
550
725
|
compare: compareType,
|
|
551
726
|
info: { date }
|
|
552
727
|
};
|
|
553
|
-
} else if (new Set([
|
|
728
|
+
} else if ((/* @__PURE__ */ new Set([
|
|
554
729
|
TableDateCompareTypeEnum.Q1,
|
|
555
730
|
TableDateCompareTypeEnum.Q2,
|
|
556
731
|
TableDateCompareTypeEnum.Q3,
|
|
557
732
|
TableDateCompareTypeEnum.Q4
|
|
558
|
-
]).has(compareType)) return {
|
|
733
|
+
])).has(compareType)) return {
|
|
559
734
|
type: conditionType,
|
|
560
735
|
compare: TableDateCompareTypeEnum.Quarter,
|
|
561
736
|
info: { dateSelect: filterInfo.compareType }
|
|
@@ -712,10 +887,11 @@ const SheetTableConditionPanel = (props) => {
|
|
|
712
887
|
|
|
713
888
|
//#endregion
|
|
714
889
|
//#region src/views/components/SheetTableItemsFilterPanel.tsx
|
|
715
|
-
const
|
|
890
|
+
const getCheckedItemCount = (map, checkedItemSet) => {
|
|
716
891
|
let count = 0;
|
|
717
|
-
|
|
718
|
-
|
|
892
|
+
checkedItemSet.forEach((item) => {
|
|
893
|
+
var _map$get;
|
|
894
|
+
count += (_map$get = map.get(item)) !== null && _map$get !== void 0 ? _map$get : 0;
|
|
719
895
|
});
|
|
720
896
|
return count;
|
|
721
897
|
};
|
|
@@ -724,7 +900,7 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
724
900
|
const localeService = useDependency(LocaleService);
|
|
725
901
|
const { data: items, itemsCountMap, allItemsCount } = useDependency(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
726
902
|
const [allChecked, setAllChecked] = useState(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
727
|
-
const [checkedCount, setCheckedCount] = useState(allChecked ? allItemsCount :
|
|
903
|
+
const [checkedCount, setCheckedCount] = useState(allChecked ? allItemsCount : getCheckedItemCount(itemsCountMap, checkedItemSet));
|
|
728
904
|
const indeterminate = !allChecked && checkedItemSet.size > 0;
|
|
729
905
|
const [searchText, setSearchText] = useState("");
|
|
730
906
|
const displayItems = useMemo(() => {
|
|
@@ -1150,206 +1326,486 @@ function SheetTableRenameDialog(props) {
|
|
|
1150
1326
|
}
|
|
1151
1327
|
|
|
1152
1328
|
//#endregion
|
|
1153
|
-
//#region src/
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
this._initUIPopup();
|
|
1165
|
-
}
|
|
1166
|
-
setCurrentTableFilterInfo(info) {
|
|
1167
|
-
this._currentTableFilterInfo = info;
|
|
1168
|
-
}
|
|
1169
|
-
openOrToggleFilterPanel(info) {
|
|
1170
|
-
const opened = this._contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY);
|
|
1171
|
-
if (opened && this._isSameFilterPanelInfo(this._currentTableFilterInfo, info)) {
|
|
1172
|
-
this.closeFilterPanel();
|
|
1173
|
-
return;
|
|
1174
|
-
}
|
|
1175
|
-
this.setCurrentTableFilterInfo(info);
|
|
1176
|
-
if (opened) {
|
|
1177
|
-
var _this$_popupDisposabl;
|
|
1178
|
-
(_this$_popupDisposabl = this._popupDisposable) === null || _this$_popupDisposabl === void 0 || _this$_popupDisposabl.dispose();
|
|
1179
|
-
this._popupDisposable = null;
|
|
1180
|
-
this._openFilterPopup();
|
|
1181
|
-
return;
|
|
1182
|
-
}
|
|
1183
|
-
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1184
|
-
}
|
|
1185
|
-
clearCurrentTableFilterInfo() {
|
|
1186
|
-
this._currentTableFilterInfo = null;
|
|
1187
|
-
}
|
|
1188
|
-
getCurrentTableFilterInfo() {
|
|
1189
|
-
return this._currentTableFilterInfo;
|
|
1190
|
-
}
|
|
1191
|
-
_initComponents() {
|
|
1192
|
-
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
|
|
1193
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1194
|
-
});
|
|
1195
|
-
}
|
|
1196
|
-
_initUIPopup() {
|
|
1197
|
-
this.disposeWithMe(this._contextService.subscribeContextValue$(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY).pipe(startWith(void 0), distinctUntilChanged()).subscribe((open) => {
|
|
1198
|
-
if (open) this._openFilterPopup();
|
|
1199
|
-
else if (open === false) this._closeFilterPopup();
|
|
1200
|
-
}));
|
|
1201
|
-
}
|
|
1202
|
-
closeFilterPanel() {
|
|
1203
|
-
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
1204
|
-
}
|
|
1205
|
-
_openFilterPopup() {
|
|
1206
|
-
const currentFilterModel = this._currentTableFilterInfo;
|
|
1207
|
-
if (!currentFilterModel) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
1208
|
-
const { row: startRow, column: col } = currentFilterModel;
|
|
1209
|
-
this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(startRow, col, {
|
|
1210
|
-
componentKey: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,
|
|
1211
|
-
direction: "horizontal",
|
|
1212
|
-
onClickOutside: () => {
|
|
1213
|
-
this._dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);
|
|
1214
|
-
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
1215
|
-
},
|
|
1216
|
-
offset: [5, 0],
|
|
1217
|
-
portal: true
|
|
1218
|
-
});
|
|
1219
|
-
}
|
|
1220
|
-
_closeFilterPopup() {
|
|
1221
|
-
var _this$_popupDisposabl2;
|
|
1222
|
-
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
1223
|
-
this._popupDisposable = null;
|
|
1224
|
-
this.clearCurrentTableFilterInfo();
|
|
1225
|
-
}
|
|
1226
|
-
_isSameFilterPanelInfo(a, b) {
|
|
1227
|
-
return Boolean(a && a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.tableId === b.tableId && a.column === b.column && a.row === b.row);
|
|
1228
|
-
}
|
|
1229
|
-
};
|
|
1230
|
-
SheetsTableComponentController = __decorate([
|
|
1231
|
-
__decorateParam(0, Inject(ComponentManager)),
|
|
1232
|
-
__decorateParam(1, IContextService),
|
|
1233
|
-
__decorateParam(2, Inject(SheetCanvasPopManagerService)),
|
|
1234
|
-
__decorateParam(3, Inject(IDialogService))
|
|
1235
|
-
], SheetsTableComponentController);
|
|
1236
|
-
|
|
1237
|
-
//#endregion
|
|
1238
|
-
//#region src/commands/operations/open-table-filter-dialog.opration.ts
|
|
1239
|
-
const OpenTableFilterPanelOperation = {
|
|
1240
|
-
type: CommandType.OPERATION,
|
|
1241
|
-
id: "sheet.operation.open-table-filter-panel",
|
|
1242
|
-
async handler(accessor, params) {
|
|
1243
|
-
if (!params) return false;
|
|
1244
|
-
const { row, col, unitId, subUnitId, tableId } = params;
|
|
1245
|
-
const tableManager = accessor.get(TableManager);
|
|
1246
|
-
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
1247
|
-
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
1248
|
-
sheetsTableComponentController.openOrToggleFilterPanel({
|
|
1329
|
+
//#region src/views/components/SheetTableSelector.tsx
|
|
1330
|
+
const SheetTableSelector = (props) => {
|
|
1331
|
+
const { unitId, subUnitId, range, onCancel, onConfirm, tableId } = props;
|
|
1332
|
+
const tableManager = useDependency(TableManager);
|
|
1333
|
+
const [selectedRange, setSelectedRange] = useState(range);
|
|
1334
|
+
const [rangeError, setRangeError] = useState("");
|
|
1335
|
+
const localeService = useDependency(LocaleService);
|
|
1336
|
+
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1337
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1338
|
+
/* @__PURE__ */ jsx(RangeSelector, {
|
|
1339
|
+
maxRangeCount: 1,
|
|
1249
1340
|
unitId,
|
|
1250
1341
|
subUnitId,
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1342
|
+
initialValue: serializeRange(range),
|
|
1343
|
+
onChange: (_, text) => {
|
|
1344
|
+
const originValue = serializeRange(range);
|
|
1345
|
+
const newRange = deserializeRangeWithSheet(text).range;
|
|
1346
|
+
const target = getSheetCommandTarget(univerInstanceService, {
|
|
1347
|
+
unitId,
|
|
1348
|
+
subUnitId
|
|
1349
|
+
});
|
|
1350
|
+
if (!target) return;
|
|
1351
|
+
if (target.worksheet.getMergeData().some((merge) => {
|
|
1352
|
+
return Rectangle.intersects(newRange, merge);
|
|
1353
|
+
})) {
|
|
1354
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeWithMergeError"));
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
if (tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => {
|
|
1358
|
+
if (table.getId() === tableId) return false;
|
|
1359
|
+
const tableRange = table.getRange();
|
|
1360
|
+
return Rectangle.intersects(newRange, tableRange);
|
|
1361
|
+
})) {
|
|
1362
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeWithOtherTableError"));
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
const { startRow, endRow } = newRange;
|
|
1366
|
+
if (startRow === endRow) {
|
|
1367
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeSingleRowError"));
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
if (originValue === text) return;
|
|
1371
|
+
if (tableId) {
|
|
1372
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1373
|
+
if (table) {
|
|
1374
|
+
const oldRange = table.getRange();
|
|
1375
|
+
if (Rectangle.intersects(newRange, oldRange) && oldRange.startRow === newRange.startRow) {
|
|
1376
|
+
setSelectedRange(newRange);
|
|
1377
|
+
setRangeError("");
|
|
1378
|
+
onConfirm({
|
|
1379
|
+
unitId,
|
|
1380
|
+
subUnitId,
|
|
1381
|
+
range: newRange
|
|
1382
|
+
});
|
|
1383
|
+
return;
|
|
1384
|
+
} else {
|
|
1385
|
+
setRangeError(localeService.t("sheets-table-ui.updateError"));
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
setSelectedRange(newRange);
|
|
1391
|
+
setRangeError("");
|
|
1392
|
+
},
|
|
1393
|
+
supportAcrossSheet: false
|
|
1394
|
+
}),
|
|
1395
|
+
rangeError && /* @__PURE__ */ jsx("div", {
|
|
1396
|
+
className: "univer-mt-1 univer-text-xs univer-text-red-500",
|
|
1397
|
+
children: rangeError
|
|
1398
|
+
}),
|
|
1399
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1400
|
+
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
1401
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1402
|
+
onClick: onCancel,
|
|
1403
|
+
children: localeService.t("sheets-table-ui.cancel")
|
|
1404
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1405
|
+
variant: "primary",
|
|
1406
|
+
onClick: () => {
|
|
1407
|
+
if (rangeError) return;
|
|
1408
|
+
onConfirm({
|
|
1409
|
+
unitId,
|
|
1410
|
+
subUnitId,
|
|
1411
|
+
range: selectedRange
|
|
1412
|
+
});
|
|
1413
|
+
},
|
|
1414
|
+
className: "univer-ml-2",
|
|
1415
|
+
children: localeService.t("sheets-table-ui.confirm")
|
|
1416
|
+
})]
|
|
1417
|
+
})
|
|
1418
|
+
] });
|
|
1257
1419
|
};
|
|
1258
1420
|
|
|
1259
1421
|
//#endregion
|
|
1260
|
-
//#region src/
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
endColumn: 0
|
|
1277
|
-
};
|
|
1278
|
-
const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, isSingleCellSelection(lastSelection) ? expandToContinuousRange(range, {
|
|
1279
|
-
up: true,
|
|
1280
|
-
left: true,
|
|
1281
|
-
right: true,
|
|
1282
|
-
down: true
|
|
1283
|
-
}, worksheet) : range);
|
|
1284
|
-
if (!rangeInfo) return false;
|
|
1285
|
-
commandService.executeCommand(AddSheetTableCommand.id, { ...rangeInfo });
|
|
1286
|
-
return true;
|
|
1422
|
+
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1423
|
+
let SheetTableThemeUIController = class SheetTableThemeUIController extends Disposable {
|
|
1424
|
+
constructor(_commandService) {
|
|
1425
|
+
super();
|
|
1426
|
+
this._commandService = _commandService;
|
|
1427
|
+
_defineProperty(this, "_refreshTable", new Subject());
|
|
1428
|
+
_defineProperty(this, "refreshTable$", this._refreshTable.asObservable());
|
|
1429
|
+
this._initListener();
|
|
1430
|
+
}
|
|
1431
|
+
_initListener() {
|
|
1432
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1433
|
+
if (command.id === SetRangeThemeMutation.id) {
|
|
1434
|
+
const { styleName } = command.params;
|
|
1435
|
+
if (styleName.startsWith(SHEET_TABLE_CUSTOM_THEME_PREFIX)) this._refreshTable.next(Math.random());
|
|
1436
|
+
}
|
|
1437
|
+
}));
|
|
1287
1438
|
}
|
|
1288
1439
|
};
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1440
|
+
SheetTableThemeUIController = __decorate([__decorateParam(0, Inject(ICommandService))], SheetTableThemeUIController);
|
|
1441
|
+
|
|
1442
|
+
//#endregion
|
|
1443
|
+
//#region src/views/components/SheetTableThemePanel.tsx
|
|
1444
|
+
const SheetTableThemePanel = (props) => {
|
|
1445
|
+
var _customStyle$getHeade, _customStyle$getHeade2, _customStyle$getFirst, _customStyle$getFirst2, _customStyle$getSecon, _customStyle$getSecon2, _customStyle$getLastR, _customStyle$getLastR2;
|
|
1446
|
+
const { unitId, subUnitId, tableId } = props;
|
|
1447
|
+
const commandService = useDependency(ICommandService);
|
|
1448
|
+
const localeService = useDependency(LocaleService);
|
|
1449
|
+
const tableManager = useDependency(TableManager);
|
|
1450
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1451
|
+
const rangeThemeModel = useDependency(SheetRangeThemeModel);
|
|
1452
|
+
const sheetTableThemeUIController = useDependency(SheetTableThemeUIController);
|
|
1453
|
+
const rangeThemeMapChanged = useObservable(rangeThemeModel.rangeThemeMapChange$);
|
|
1454
|
+
const tableRefresh = useObservable(sheetTableThemeUIController.refreshTable$);
|
|
1455
|
+
const errorService = useDependency(ErrorService);
|
|
1456
|
+
const [, setRefresh] = useState(Math.random());
|
|
1457
|
+
const themeConfig = useObservable(tableManager.tableThemeChanged$, {
|
|
1458
|
+
theme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
1459
|
+
oldTheme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
1460
|
+
unitId,
|
|
1461
|
+
subUnitId,
|
|
1462
|
+
tableId
|
|
1463
|
+
});
|
|
1464
|
+
const defaultRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_DEFAULT_NAME_PREFIX));
|
|
1465
|
+
const customRangeThemes = rangeThemeModel.getALLRegisteredTheme(unitId).filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_CUSTOM_NAME_PREFIX));
|
|
1466
|
+
const selectedTheme = table === null || table === void 0 ? void 0 : table.getTableStyleId();
|
|
1467
|
+
const customSelected = customRangeThemes.find((item) => item === selectedTheme);
|
|
1468
|
+
const customStyleName = customSelected || customRangeThemes[0];
|
|
1469
|
+
const customStyle = rangeThemeModel.getCustomRangeThemeStyle(unitId, customStyleName);
|
|
1470
|
+
const headerBg = (_customStyle$getHeade = customStyle === null || customStyle === void 0 || (_customStyle$getHeade2 = customStyle.getHeaderRowStyle()) === null || _customStyle$getHeade2 === void 0 || (_customStyle$getHeade2 = _customStyle$getHeade2.bg) === null || _customStyle$getHeade2 === void 0 ? void 0 : _customStyle$getHeade2.rgb) !== null && _customStyle$getHeade !== void 0 ? _customStyle$getHeade : TABLE_DEFAULT_BG_COLOR;
|
|
1471
|
+
const firstRowBg = (_customStyle$getFirst = customStyle === null || customStyle === void 0 || (_customStyle$getFirst2 = customStyle.getFirstRowStyle()) === null || _customStyle$getFirst2 === void 0 || (_customStyle$getFirst2 = _customStyle$getFirst2.bg) === null || _customStyle$getFirst2 === void 0 ? void 0 : _customStyle$getFirst2.rgb) !== null && _customStyle$getFirst !== void 0 ? _customStyle$getFirst : TABLE_DEFAULT_BG_COLOR;
|
|
1472
|
+
const secondRowBg = (_customStyle$getSecon = customStyle === null || customStyle === void 0 || (_customStyle$getSecon2 = customStyle.getSecondRowStyle()) === null || _customStyle$getSecon2 === void 0 || (_customStyle$getSecon2 = _customStyle$getSecon2.bg) === null || _customStyle$getSecon2 === void 0 ? void 0 : _customStyle$getSecon2.rgb) !== null && _customStyle$getSecon !== void 0 ? _customStyle$getSecon : TABLE_DEFAULT_BG_COLOR;
|
|
1473
|
+
const lastRowBg = (_customStyle$getLastR = customStyle === null || customStyle === void 0 || (_customStyle$getLastR2 = customStyle.getLastRowStyle()) === null || _customStyle$getLastR2 === void 0 || (_customStyle$getLastR2 = _customStyle$getLastR2.bg) === null || _customStyle$getLastR2 === void 0 ? void 0 : _customStyle$getLastR2.rgb) !== null && _customStyle$getLastR !== void 0 ? _customStyle$getLastR : TABLE_DEFAULT_BG_COLOR;
|
|
1474
|
+
const [hoverCustomId, setHoverCustomId] = useState(null);
|
|
1475
|
+
const handleThemeChange = (theme) => {
|
|
1476
|
+
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1477
|
+
unitId,
|
|
1478
|
+
tableId,
|
|
1479
|
+
theme
|
|
1480
|
+
});
|
|
1481
|
+
};
|
|
1482
|
+
const handleAddCustomTheme = () => {
|
|
1483
|
+
if (customRangeThemes.length >= 11) {
|
|
1484
|
+
errorService.emit(localeService.t("sheets-table-ui.customTooMore"));
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];
|
|
1488
|
+
let newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}1`;
|
|
1489
|
+
if (lastCustomTheme) newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}${Number(lastCustomTheme.split("-")[2]) + 1}`;
|
|
1490
|
+
const newTheme = new RangeThemeStyle(newThemeName, { ...customEmptyThemeWithBorderStyle });
|
|
1491
|
+
commandService.executeCommand(AddTableThemeCommand.id, {
|
|
1492
|
+
unitId,
|
|
1493
|
+
tableId,
|
|
1494
|
+
themeStyle: newTheme
|
|
1495
|
+
});
|
|
1496
|
+
};
|
|
1497
|
+
const setCustomTheme = (themeName, tableThemeStyle) => {
|
|
1498
|
+
commandService.executeCommand(SetRangeThemeMutation.id, {
|
|
1294
1499
|
unitId,
|
|
1295
1500
|
subUnitId,
|
|
1296
|
-
|
|
1501
|
+
styleName: themeName,
|
|
1502
|
+
style: tableThemeStyle
|
|
1503
|
+
});
|
|
1504
|
+
};
|
|
1505
|
+
const removeCustomTheme = (themeName) => {
|
|
1506
|
+
commandService.executeCommand(RemoveTableThemeCommand.id, {
|
|
1507
|
+
unitId,
|
|
1297
1508
|
tableId,
|
|
1298
|
-
|
|
1299
|
-
resolve(info);
|
|
1300
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1301
|
-
},
|
|
1302
|
-
onCancel: () => {
|
|
1303
|
-
resolve(null);
|
|
1304
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1305
|
-
}
|
|
1306
|
-
};
|
|
1307
|
-
dialogService.open({
|
|
1308
|
-
id: TABLE_SELECTOR_DIALOG,
|
|
1309
|
-
title: { title: localeService.t("sheets-table-ui.selectRange") },
|
|
1310
|
-
draggable: true,
|
|
1311
|
-
destroyOnClose: true,
|
|
1312
|
-
mask: false,
|
|
1313
|
-
maskClosable: false,
|
|
1314
|
-
children: { label: {
|
|
1315
|
-
name: TABLE_SELECTOR_DIALOG,
|
|
1316
|
-
props: dialogProps
|
|
1317
|
-
} },
|
|
1318
|
-
width: 300,
|
|
1319
|
-
onClose: () => {
|
|
1320
|
-
resolve(null);
|
|
1321
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
1322
|
-
}
|
|
1509
|
+
themeName
|
|
1323
1510
|
});
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
const
|
|
1330
|
-
const
|
|
1331
|
-
const
|
|
1332
|
-
|
|
1333
|
-
|
|
1511
|
+
};
|
|
1512
|
+
useEffect(() => {
|
|
1513
|
+
setRefresh(Math.random());
|
|
1514
|
+
}, [rangeThemeMapChanged, tableRefresh]);
|
|
1515
|
+
if (!table) return null;
|
|
1516
|
+
const headerBgIsDark = new ColorKit(headerBg).isDark();
|
|
1517
|
+
const firstRowBgIsDark = new ColorKit(firstRowBg).isDark();
|
|
1518
|
+
const secondRowBgIsDark = new ColorKit(secondRowBg).isDark();
|
|
1519
|
+
const lastRowBgIsDark = new ColorKit(lastRowBg).isDark();
|
|
1520
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1521
|
+
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.defaultStyle") }),
|
|
1522
|
+
/* @__PURE__ */ jsx("div", {
|
|
1523
|
+
className: "univer-flex univer-gap-2",
|
|
1524
|
+
children: defaultRangeThemes.map((item) => {
|
|
1525
|
+
var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
|
|
1526
|
+
const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
|
|
1527
|
+
const headerRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe === void 0 || (_rangeThemeItem$getHe = _rangeThemeItem$getHe.bg) === null || _rangeThemeItem$getHe === void 0 ? void 0 : _rangeThemeItem$getHe.rgb) || "rgb(255, 255, 255)";
|
|
1528
|
+
const firstRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi === void 0 || (_rangeThemeItem$getFi = _rangeThemeItem$getFi.bg) === null || _rangeThemeItem$getFi === void 0 ? void 0 : _rangeThemeItem$getFi.rgb) || "rgb(255, 255, 255)";
|
|
1529
|
+
const secondRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe === void 0 || (_rangeThemeItem$getSe = _rangeThemeItem$getSe.bg) === null || _rangeThemeItem$getSe === void 0 ? void 0 : _rangeThemeItem$getSe.rgb) || "rgb(255, 255, 255)";
|
|
1530
|
+
const lastRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa === void 0 || (_rangeThemeItem$getLa = _rangeThemeItem$getLa.bg) === null || _rangeThemeItem$getLa === void 0 ? void 0 : _rangeThemeItem$getLa.rgb) || "rgb(255, 255, 255)";
|
|
1531
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1532
|
+
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px [&>div]:univer-box-border [&>div]:univer-h-2.5", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
1533
|
+
onClick: () => handleThemeChange(item),
|
|
1534
|
+
children: [
|
|
1535
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1536
|
+
background: headerRowBg,
|
|
1537
|
+
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1538
|
+
} }),
|
|
1539
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1540
|
+
background: firstRowBg,
|
|
1541
|
+
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1542
|
+
} }),
|
|
1543
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1544
|
+
background: secondRowBg,
|
|
1545
|
+
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1546
|
+
} }),
|
|
1547
|
+
/* @__PURE__ */ jsx("div", { style: {
|
|
1548
|
+
background: lastRowBg,
|
|
1549
|
+
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1550
|
+
} })
|
|
1551
|
+
]
|
|
1552
|
+
}, item);
|
|
1553
|
+
})
|
|
1554
|
+
}),
|
|
1555
|
+
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.customStyle") }),
|
|
1556
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1557
|
+
className: clsx("univer-w-full univer-rounded-sm", borderClassName),
|
|
1558
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1559
|
+
className: "univer-flex univer-flex-wrap univer-gap-2 univer-p-2",
|
|
1560
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1561
|
+
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10", borderClassName),
|
|
1562
|
+
onClick: handleAddCustomTheme,
|
|
1563
|
+
children: "+"
|
|
1564
|
+
}), customRangeThemes.map((item) => {
|
|
1565
|
+
var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
|
|
1566
|
+
const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
|
|
1567
|
+
const headerRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe2 = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe2 === void 0 || (_rangeThemeItem$getHe2 = _rangeThemeItem$getHe2.bg) === null || _rangeThemeItem$getHe2 === void 0 ? void 0 : _rangeThemeItem$getHe2.rgb;
|
|
1568
|
+
const firstRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi2 = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi2 === void 0 || (_rangeThemeItem$getFi2 = _rangeThemeItem$getFi2.bg) === null || _rangeThemeItem$getFi2 === void 0 ? void 0 : _rangeThemeItem$getFi2.rgb;
|
|
1569
|
+
const secondRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe2 = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe2 === void 0 || (_rangeThemeItem$getSe2 = _rangeThemeItem$getSe2.bg) === null || _rangeThemeItem$getSe2 === void 0 ? void 0 : _rangeThemeItem$getSe2.rgb;
|
|
1570
|
+
const lastRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa2 = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa2 === void 0 || (_rangeThemeItem$getLa2 = _rangeThemeItem$getLa2.bg) === null || _rangeThemeItem$getLa2 === void 0 ? void 0 : _rangeThemeItem$getLa2.rgb;
|
|
1571
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1572
|
+
className: clsx("univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
1573
|
+
onClick: () => handleThemeChange(item),
|
|
1574
|
+
onMouseEnter: () => setHoverCustomId(item),
|
|
1575
|
+
onMouseLeave: () => setHoverCustomId(null),
|
|
1576
|
+
children: [
|
|
1577
|
+
/* @__PURE__ */ jsx("div", {
|
|
1578
|
+
className: "univer-box-border univer-h-2.5",
|
|
1579
|
+
style: {
|
|
1580
|
+
background: headerRowBg !== null && headerRowBg !== void 0 ? headerRowBg : TABLE_BORDER_NONE,
|
|
1581
|
+
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1582
|
+
}
|
|
1583
|
+
}),
|
|
1584
|
+
/* @__PURE__ */ jsx("div", {
|
|
1585
|
+
className: "univer-box-border univer-h-2.5",
|
|
1586
|
+
style: {
|
|
1587
|
+
background: firstRowBg !== null && firstRowBg !== void 0 ? firstRowBg : TABLE_BORDER_NONE,
|
|
1588
|
+
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1589
|
+
}
|
|
1590
|
+
}),
|
|
1591
|
+
/* @__PURE__ */ jsx("div", {
|
|
1592
|
+
className: "univer-box-border univer-h-2.5",
|
|
1593
|
+
style: {
|
|
1594
|
+
background: secondRowBg !== null && secondRowBg !== void 0 ? secondRowBg : TABLE_BORDER_NONE,
|
|
1595
|
+
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1596
|
+
}
|
|
1597
|
+
}),
|
|
1598
|
+
/* @__PURE__ */ jsx("div", {
|
|
1599
|
+
className: "univer-box-border univer-h-2.5",
|
|
1600
|
+
style: {
|
|
1601
|
+
background: lastRowBg !== null && lastRowBg !== void 0 ? lastRowBg : TABLE_BORDER_NONE,
|
|
1602
|
+
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
1603
|
+
}
|
|
1604
|
+
}),
|
|
1605
|
+
/* @__PURE__ */ jsx("div", {
|
|
1606
|
+
className: "univer-absolute univer-right-[-3px] univer-top-[-3px] univer-size-3 univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs univer-leading-[10px]",
|
|
1607
|
+
style: { display: hoverCustomId === item ? "block" : "none" },
|
|
1608
|
+
onClick: (e) => {
|
|
1609
|
+
e.stopPropagation();
|
|
1610
|
+
removeCustomTheme(item);
|
|
1611
|
+
},
|
|
1612
|
+
children: "x"
|
|
1613
|
+
})
|
|
1614
|
+
]
|
|
1615
|
+
}, item);
|
|
1616
|
+
})]
|
|
1617
|
+
}), customSelected && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "univer-h-px univer-w-full univer-bg-gray-200" }), /* @__PURE__ */ jsxs("div", {
|
|
1618
|
+
className: "univer-flex univer-flex-col univer-gap-2 univer-p-2",
|
|
1619
|
+
children: [
|
|
1620
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1621
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
1622
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1623
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
1624
|
+
"univer-text-white": headerBgIsDark,
|
|
1625
|
+
"univer-text-gray-900": !headerBgIsDark
|
|
1626
|
+
}),
|
|
1627
|
+
style: { background: headerBg },
|
|
1628
|
+
children: localeService.t("sheets-table-ui.header")
|
|
1629
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1630
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
1631
|
+
className: "univer-p-2",
|
|
1632
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
1633
|
+
value: headerBg,
|
|
1634
|
+
onChange: (val) => {
|
|
1635
|
+
const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
|
|
1636
|
+
bg: { rgb: val },
|
|
1637
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
1638
|
+
});
|
|
1639
|
+
setCustomTheme(table.getTableStyleId(), { headerRowStyle });
|
|
1640
|
+
}
|
|
1641
|
+
})
|
|
1642
|
+
}),
|
|
1643
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1644
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
1645
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1646
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName, {
|
|
1647
|
+
"univer-text-white": headerBgIsDark,
|
|
1648
|
+
"univer-text-gray-900": !headerBgIsDark
|
|
1649
|
+
}),
|
|
1650
|
+
style: { background: headerBg }
|
|
1651
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
1652
|
+
})
|
|
1653
|
+
})]
|
|
1654
|
+
}),
|
|
1655
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1656
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
1657
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1658
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
1659
|
+
"univer-text-white": firstRowBgIsDark,
|
|
1660
|
+
"univer-text-gray-900": !firstRowBgIsDark
|
|
1661
|
+
}),
|
|
1662
|
+
style: { background: firstRowBg },
|
|
1663
|
+
children: localeService.t("sheets-table-ui.firstLine")
|
|
1664
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1665
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
1666
|
+
className: "univer-p-2",
|
|
1667
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
1668
|
+
value: firstRowBg,
|
|
1669
|
+
onChange: (val) => {
|
|
1670
|
+
setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
|
|
1671
|
+
bg: { rgb: val },
|
|
1672
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
1673
|
+
} });
|
|
1674
|
+
}
|
|
1675
|
+
})
|
|
1676
|
+
}),
|
|
1677
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1678
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
1679
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1680
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1681
|
+
style: { background: firstRowBg }
|
|
1682
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
1683
|
+
})
|
|
1684
|
+
})]
|
|
1685
|
+
}),
|
|
1686
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1687
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
1688
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1689
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
1690
|
+
"univer-text-white": secondRowBgIsDark,
|
|
1691
|
+
"univer-text-gray-900": !secondRowBgIsDark
|
|
1692
|
+
}),
|
|
1693
|
+
style: { background: secondRowBg },
|
|
1694
|
+
children: localeService.t("sheets-table-ui.secondLine")
|
|
1695
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1696
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
1697
|
+
className: "univer-p-2",
|
|
1698
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
1699
|
+
value: secondRowBg,
|
|
1700
|
+
onChange: (val) => setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
|
|
1701
|
+
bg: { rgb: val },
|
|
1702
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
1703
|
+
} })
|
|
1704
|
+
})
|
|
1705
|
+
}),
|
|
1706
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1707
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
1708
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1709
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1710
|
+
style: { background: secondRowBg }
|
|
1711
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
1712
|
+
})
|
|
1713
|
+
})]
|
|
1714
|
+
}),
|
|
1715
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1716
|
+
className: "univer-flex univer-h-9 univer-gap-2",
|
|
1717
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1718
|
+
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
1719
|
+
"univer-text-white": lastRowBgIsDark,
|
|
1720
|
+
"univer-text-gray-900": !lastRowBgIsDark
|
|
1721
|
+
}),
|
|
1722
|
+
style: { background: lastRowBg },
|
|
1723
|
+
children: localeService.t("sheets-table-ui.footer")
|
|
1724
|
+
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1725
|
+
overlay: /* @__PURE__ */ jsx("div", {
|
|
1726
|
+
className: "univer-p-2",
|
|
1727
|
+
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
1728
|
+
value: lastRowBg,
|
|
1729
|
+
onChange: (val) => {
|
|
1730
|
+
const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
|
|
1731
|
+
bg: { rgb: val },
|
|
1732
|
+
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
1733
|
+
});
|
|
1734
|
+
setCustomTheme(table.getTableStyleId(), { lastRowStyle });
|
|
1735
|
+
}
|
|
1736
|
+
})
|
|
1737
|
+
}),
|
|
1738
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1739
|
+
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
1740
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1741
|
+
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1742
|
+
style: { background: lastRowBg }
|
|
1743
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
1744
|
+
})
|
|
1745
|
+
})]
|
|
1746
|
+
})
|
|
1747
|
+
]
|
|
1748
|
+
})] })]
|
|
1749
|
+
})
|
|
1750
|
+
] });
|
|
1334
1751
|
};
|
|
1335
1752
|
|
|
1336
1753
|
//#endregion
|
|
1337
|
-
//#region src/
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1754
|
+
//#region src/controllers/components.controller.ts
|
|
1755
|
+
/**
|
|
1756
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1757
|
+
*
|
|
1758
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1759
|
+
* you may not use this file except in compliance with the License.
|
|
1760
|
+
* You may obtain a copy of the License at
|
|
1761
|
+
*
|
|
1762
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1763
|
+
*
|
|
1764
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1765
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1766
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1767
|
+
* See the License for the specific language governing permissions and
|
|
1768
|
+
* limitations under the License.
|
|
1769
|
+
*/
|
|
1770
|
+
let ComponentsController = class ComponentsController extends Disposable {
|
|
1771
|
+
constructor(_componentManager, _iconManager) {
|
|
1772
|
+
super();
|
|
1773
|
+
this._componentManager = _componentManager;
|
|
1774
|
+
this._iconManager = _iconManager;
|
|
1775
|
+
this._registerComponents();
|
|
1776
|
+
this._registerIcons();
|
|
1777
|
+
}
|
|
1778
|
+
_registerComponents() {
|
|
1779
|
+
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
|
|
1780
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1781
|
+
});
|
|
1782
|
+
[[TABLE_SELECTOR_DIALOG, SheetTableSelector], [SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]].forEach(([key, comp]) => {
|
|
1783
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
_registerIcons() {
|
|
1787
|
+
this.disposeWithMe(this._iconManager.register({ TableIcon }));
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
1791
|
+
|
|
1792
|
+
//#endregion
|
|
1793
|
+
//#region src/views/widgets/table-controls-util.ts
|
|
1794
|
+
const TABLE_CONTROL_MENU_WIDTH = 168;
|
|
1795
|
+
const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
|
|
1796
|
+
const TABLE_CONTROL_MENU_ACTIONS = [
|
|
1797
|
+
"rename",
|
|
1798
|
+
"update-range",
|
|
1799
|
+
"set-theme",
|
|
1800
|
+
"delete"
|
|
1801
|
+
];
|
|
1802
|
+
function isPointInTableControlRegion(region, x, y) {
|
|
1803
|
+
return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
|
|
1804
|
+
}
|
|
1805
|
+
function hitTestTableControl(regions, x, y) {
|
|
1806
|
+
for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
|
|
1807
|
+
return null;
|
|
1808
|
+
}
|
|
1353
1809
|
function buildTableMenuRegions(tableId, left, top) {
|
|
1354
1810
|
return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
|
|
1355
1811
|
type: "menu-item",
|
|
@@ -1623,32 +2079,11 @@ var SheetTableControlsShape = class extends Shape {
|
|
|
1623
2079
|
}
|
|
1624
2080
|
};
|
|
1625
2081
|
|
|
1626
|
-
//#endregion
|
|
1627
|
-
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1628
|
-
let SheetTableThemeUIController = class SheetTableThemeUIController extends Disposable {
|
|
1629
|
-
constructor(_commandService) {
|
|
1630
|
-
super();
|
|
1631
|
-
this._commandService = _commandService;
|
|
1632
|
-
_defineProperty(this, "_refreshTable", new Subject());
|
|
1633
|
-
_defineProperty(this, "refreshTable$", this._refreshTable.asObservable());
|
|
1634
|
-
this._initListener();
|
|
1635
|
-
}
|
|
1636
|
-
_initListener() {
|
|
1637
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
1638
|
-
if (command.id === SetRangeThemeMutation.id) {
|
|
1639
|
-
const { styleName } = command.params;
|
|
1640
|
-
if (styleName.startsWith(SHEET_TABLE_CUSTOM_THEME_PREFIX)) this._refreshTable.next(Math.random());
|
|
1641
|
-
}
|
|
1642
|
-
}));
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
SheetTableThemeUIController = __decorate([__decorateParam(0, Inject(ICommandService))], SheetTableThemeUIController);
|
|
1646
|
-
|
|
1647
2082
|
//#endregion
|
|
1648
2083
|
//#region src/controllers/sheet-table-controls-render.controller.ts
|
|
1649
2084
|
const TABLE_CONTROLS_LAYER_INDEX = 5002;
|
|
1650
2085
|
const TABLE_CONTROL_GAP_ROW = 0;
|
|
1651
|
-
const TABLE_RENDER_REFRESH_COMMANDS = new Set([SetScrollOperation.id, SetZoomRatioOperation.id]);
|
|
2086
|
+
const TABLE_RENDER_REFRESH_COMMANDS = /* @__PURE__ */ new Set([SetScrollOperation.id, SetZoomRatioOperation.id]);
|
|
1652
2087
|
function isSameTopGap(left, right) {
|
|
1653
2088
|
if (left === null || right === null) return left === right;
|
|
1654
2089
|
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
@@ -2097,663 +2532,259 @@ const computeIconTop = (startY, endY, cellHeight, verticalAlign) => {
|
|
|
2097
2532
|
};
|
|
2098
2533
|
let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRenderController extends RxDisposable {
|
|
2099
2534
|
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _rangeThemeModel, _commandService) {
|
|
2100
|
-
super();
|
|
2101
|
-
this._context = _context;
|
|
2102
|
-
this._injector = _injector;
|
|
2103
|
-
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2104
|
-
this._sheetInterceptorService = _sheetInterceptorService;
|
|
2105
|
-
this._tableManager = _tableManager;
|
|
2106
|
-
this._rangeThemeModel = _rangeThemeModel;
|
|
2107
|
-
this._commandService = _commandService;
|
|
2108
|
-
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
2109
|
-
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
2110
|
-
this._initRenderer();
|
|
2111
|
-
this._initCommandExecuted();
|
|
2112
|
-
}
|
|
2113
|
-
dispose() {
|
|
2114
|
-
super.dispose();
|
|
2115
|
-
this._disposeRendering();
|
|
2116
|
-
}
|
|
2117
|
-
_initRenderer() {
|
|
2118
|
-
const tableManager = this._tableManager;
|
|
2119
|
-
this._sheetSkeletonManagerService.currentSkeleton$.pipe(switchMap((skeletonParams) => {
|
|
2120
|
-
var _workbook$getActiveSh;
|
|
2121
|
-
if (!skeletonParams) return of(null);
|
|
2122
|
-
const { unit: workbook, unitId } = this._context;
|
|
2123
|
-
const worksheetId = ((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId()) || "";
|
|
2124
|
-
const getParams = () => ({
|
|
2125
|
-
unitId,
|
|
2126
|
-
worksheetId,
|
|
2127
|
-
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
2128
|
-
skeleton: skeletonParams.skeleton
|
|
2129
|
-
});
|
|
2130
|
-
return merge$1(tableManager.tableAdd$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableDelete$, tableManager.tableFilterChanged$).pipe(map(() => getParams()), startWith(getParams()));
|
|
2131
|
-
}), takeUntil(this.dispose$)).subscribe((renderParams) => {
|
|
2132
|
-
this._disposeRendering();
|
|
2133
|
-
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
2134
|
-
this._renderButtons(renderParams);
|
|
2135
|
-
});
|
|
2136
|
-
}
|
|
2137
|
-
_initCommandExecuted() {
|
|
2138
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2139
|
-
var _workbook$getActiveSh2;
|
|
2140
|
-
if (command.id !== SetVerticalTextAlignCommand.id) return;
|
|
2141
|
-
const { unit: workbook, unitId } = this._context;
|
|
2142
|
-
const worksheetId = ((_workbook$getActiveSh2 = workbook.getActiveSheet()) === null || _workbook$getActiveSh2 === void 0 ? void 0 : _workbook$getActiveSh2.getSheetId()) || "";
|
|
2143
|
-
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
2144
|
-
if (!skeleton) return;
|
|
2145
|
-
const renderParams = {
|
|
2146
|
-
unitId,
|
|
2147
|
-
worksheetId,
|
|
2148
|
-
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
2149
|
-
skeleton
|
|
2150
|
-
};
|
|
2151
|
-
this._disposeRendering();
|
|
2152
|
-
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
2153
|
-
this._renderButtons(renderParams);
|
|
2154
|
-
}));
|
|
2155
|
-
}
|
|
2156
|
-
_renderButtons(params) {
|
|
2157
|
-
const { tableFilterRanges, unitId, skeleton, worksheetId } = params;
|
|
2158
|
-
const { unit: workbook, scene } = this._context;
|
|
2159
|
-
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
2160
|
-
if (!worksheet) return;
|
|
2161
|
-
for (const { range, states, tableId } of tableFilterRanges) {
|
|
2162
|
-
var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
|
|
2163
|
-
const { startRow, startColumn, endColumn } = range;
|
|
2164
|
-
const table = this._tableManager.getTableById(unitId, tableId);
|
|
2165
|
-
const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
|
|
2166
|
-
const iconColor = (_headerStyle$cl$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$cl = headerStyle.cl) === null || _headerStyle$cl === void 0 ? void 0 : _headerStyle$cl.rgb) !== null && _headerStyle$cl$rgb !== void 0 ? _headerStyle$cl$rgb : "#fff";
|
|
2167
|
-
const hoverIconColor = (_headerStyle$bg$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) !== null && _headerStyle$bg$rgb !== void 0 ? _headerStyle$bg$rgb : "#202124";
|
|
2168
|
-
this._interceptCellContent(unitId, worksheetId, range);
|
|
2169
|
-
for (let col = startColumn; col <= endColumn; col++) {
|
|
2170
|
-
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
2171
|
-
const startPosition = getCoordByCell(startRow, col, scene, skeleton);
|
|
2172
|
-
const cellStyle = worksheet.getCellStyle(startRow, col);
|
|
2173
|
-
const verticalAlign = (cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle.vt) || VerticalAlign.BOTTOM;
|
|
2174
|
-
const { startX, startY, endX, endY } = startPosition;
|
|
2175
|
-
const cellWidth = endX - startX;
|
|
2176
|
-
const cellHeight = endY - startY;
|
|
2177
|
-
if (cellHeight <= 1 || cellWidth <= 1) continue;
|
|
2178
|
-
const state = states[col - startColumn];
|
|
2179
|
-
const props = {
|
|
2180
|
-
left: endX - 16 - 1,
|
|
2181
|
-
top: computeIconTop(startY, endY, cellHeight, verticalAlign),
|
|
2182
|
-
height: 16,
|
|
2183
|
-
width: 16,
|
|
2184
|
-
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2185
|
-
iconColor,
|
|
2186
|
-
hoverBackground: iconColor,
|
|
2187
|
-
hoverIconColor,
|
|
2188
|
-
cellHeight,
|
|
2189
|
-
cellWidth,
|
|
2190
|
-
filterParams: {
|
|
2191
|
-
unitId,
|
|
2192
|
-
subUnitId: worksheetId,
|
|
2193
|
-
row: startRow,
|
|
2194
|
-
col,
|
|
2195
|
-
buttonState: state,
|
|
2196
|
-
tableId
|
|
2197
|
-
}
|
|
2198
|
-
};
|
|
2199
|
-
const buttonShape = this._injector.createInstance(SheetsTableFilterButtonShape, key, props);
|
|
2200
|
-
this._tableFilterButtonShapes.push(buttonShape);
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
scene.addObjects(this._tableFilterButtonShapes);
|
|
2204
|
-
scene.makeDirty();
|
|
2205
|
-
}
|
|
2206
|
-
_interceptCellContent(workbookId, worksheetId, range) {
|
|
2207
|
-
const { startRow, startColumn, endColumn } = range;
|
|
2208
|
-
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
2209
|
-
effect: InterceptorEffectEnum.Style,
|
|
2210
|
-
handler: (cell, pos, next) => {
|
|
2211
|
-
const { row, col, unitId, subUnitId } = pos;
|
|
2212
|
-
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
2213
|
-
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2214
|
-
cell.fontRenderExtension = {
|
|
2215
|
-
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2216
|
-
rightOffset: 16 + 1 + 2
|
|
2217
|
-
};
|
|
2218
|
-
return next(cell);
|
|
2219
|
-
},
|
|
2220
|
-
priority: 10
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
_disposeRendering() {
|
|
2224
|
-
var _this$_buttonRenderDi;
|
|
2225
|
-
this._tableFilterButtonShapes.forEach((s) => s.dispose());
|
|
2226
|
-
(_this$_buttonRenderDi = this._buttonRenderDisposable) === null || _this$_buttonRenderDi === void 0 || _this$_buttonRenderDi.dispose();
|
|
2227
|
-
this._buttonRenderDisposable = null;
|
|
2228
|
-
this._tableFilterButtonShapes = [];
|
|
2229
|
-
}
|
|
2230
|
-
};
|
|
2231
|
-
SheetsTableFilterButtonRenderController = __decorate([
|
|
2232
|
-
__decorateParam(1, Inject(Injector)),
|
|
2233
|
-
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
2234
|
-
__decorateParam(3, Inject(SheetInterceptorService)),
|
|
2235
|
-
__decorateParam(4, Inject(TableManager)),
|
|
2236
|
-
__decorateParam(5, Inject(SheetRangeThemeModel)),
|
|
2237
|
-
__decorateParam(6, ICommandService)
|
|
2238
|
-
], SheetsTableFilterButtonRenderController);
|
|
2239
|
-
|
|
2240
|
-
//#endregion
|
|
2241
|
-
//#region src/controllers/sheet-table-render.controller.ts
|
|
2242
|
-
let SheetsTableRenderController = class SheetsTableRenderController extends RxDisposable {
|
|
2243
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _tableManager, _sheetTableThemeUIController) {
|
|
2244
|
-
super();
|
|
2245
|
-
this._context = _context;
|
|
2246
|
-
this._injector = _injector;
|
|
2247
|
-
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2248
|
-
this._tableManager = _tableManager;
|
|
2249
|
-
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
2250
|
-
this._initListener();
|
|
2251
|
-
}
|
|
2252
|
-
_dirtySkeleton() {
|
|
2253
|
-
var _this$_context$mainCo;
|
|
2254
|
-
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
|
|
2255
|
-
const currentParam = this._sheetSkeletonManagerService.getCurrentParam();
|
|
2256
|
-
if (currentParam) {
|
|
2257
|
-
const param = {
|
|
2258
|
-
...currentParam,
|
|
2259
|
-
dirty: true
|
|
2260
|
-
};
|
|
2261
|
-
this._sheetSkeletonManagerService.reCalculate(param);
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
_initListener() {
|
|
2265
|
-
const tableManager = this._tableManager;
|
|
2266
|
-
const dirtySkeleton = this._dirtySkeleton.bind(this);
|
|
2267
|
-
this.disposeWithMe(merge$1(tableManager.tableAdd$, tableManager.tableDelete$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableFilterChanged$, tableManager.tableInitStatus$, this._sheetTableThemeUIController.refreshTable$).subscribe(dirtySkeleton));
|
|
2268
|
-
}
|
|
2269
|
-
};
|
|
2270
|
-
SheetsTableRenderController = __decorate([
|
|
2271
|
-
__decorateParam(1, Inject(Injector)),
|
|
2272
|
-
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
2273
|
-
__decorateParam(3, Inject(TableManager)),
|
|
2274
|
-
__decorateParam(4, Inject(SheetTableThemeUIController))
|
|
2275
|
-
], SheetsTableRenderController);
|
|
2276
|
-
|
|
2277
|
-
//#endregion
|
|
2278
|
-
//#region src/controllers/sheet-table-selection.controller.ts
|
|
2279
|
-
let SheetTableSelectionController = class SheetTableSelectionController extends Disposable {
|
|
2280
|
-
constructor(_sheetInterceptorService, _univerInstanceService, _tableManager) {
|
|
2281
|
-
super();
|
|
2282
|
-
this._sheetInterceptorService = _sheetInterceptorService;
|
|
2283
|
-
this._univerInstanceService = _univerInstanceService;
|
|
2284
|
-
this._tableManager = _tableManager;
|
|
2285
|
-
this._initSelectionChange();
|
|
2286
|
-
}
|
|
2287
|
-
_initSelectionChange() {
|
|
2288
|
-
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({ getMutations: (command) => {
|
|
2289
|
-
if (command.id === SelectAllCommand.id) {
|
|
2290
|
-
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
2291
|
-
if (!target) return {
|
|
2292
|
-
redos: [],
|
|
2293
|
-
undos: []
|
|
2294
|
-
};
|
|
2295
|
-
const { range } = command.params;
|
|
2296
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
2297
|
-
const overlapTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).find((table) => {
|
|
2298
|
-
const tableRange = table.getRange();
|
|
2299
|
-
return Rectangle.contains(tableRange, range);
|
|
2300
|
-
});
|
|
2301
|
-
if (overlapTable) {
|
|
2302
|
-
const tableRange = overlapTable.getRange();
|
|
2303
|
-
const tableRangeWithoutHeader = {
|
|
2304
|
-
...tableRange,
|
|
2305
|
-
startRow: tableRange.startRow + 1
|
|
2306
|
-
};
|
|
2307
|
-
if (Rectangle.equals(tableRange, range)) return {
|
|
2308
|
-
undos: [],
|
|
2309
|
-
redos: []
|
|
2310
|
-
};
|
|
2311
|
-
else if (Rectangle.equals(tableRangeWithoutHeader, range)) return {
|
|
2312
|
-
undos: [],
|
|
2313
|
-
redos: [{
|
|
2314
|
-
id: SetSelectionsOperation.id,
|
|
2315
|
-
params: {
|
|
2316
|
-
unitId,
|
|
2317
|
-
subUnitId,
|
|
2318
|
-
selections: [{
|
|
2319
|
-
range: tableRange,
|
|
2320
|
-
primary: getPrimaryForRange(tableRange, worksheet)
|
|
2321
|
-
}]
|
|
2322
|
-
}
|
|
2323
|
-
}]
|
|
2324
|
-
};
|
|
2325
|
-
else return {
|
|
2326
|
-
undos: [],
|
|
2327
|
-
redos: [{
|
|
2328
|
-
id: SetSelectionsOperation.id,
|
|
2329
|
-
params: {
|
|
2330
|
-
unitId,
|
|
2331
|
-
subUnitId,
|
|
2332
|
-
selections: [{
|
|
2333
|
-
range: tableRangeWithoutHeader,
|
|
2334
|
-
primary: getPrimaryForRange(tableRangeWithoutHeader, worksheet)
|
|
2335
|
-
}]
|
|
2336
|
-
}
|
|
2337
|
-
}]
|
|
2338
|
-
};
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
return {
|
|
2342
|
-
redos: [],
|
|
2343
|
-
undos: []
|
|
2344
|
-
};
|
|
2345
|
-
} }));
|
|
2346
|
-
}
|
|
2347
|
-
};
|
|
2348
|
-
SheetTableSelectionController = __decorate([
|
|
2349
|
-
__decorateParam(0, Inject(SheetInterceptorService)),
|
|
2350
|
-
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
2351
|
-
__decorateParam(2, Inject(TableManager))
|
|
2352
|
-
], SheetTableSelectionController);
|
|
2353
|
-
|
|
2354
|
-
//#endregion
|
|
2355
|
-
//#region src/views/components/SheetTableSelector.tsx
|
|
2356
|
-
const SheetTableSelector = (props) => {
|
|
2357
|
-
const { unitId, subUnitId, range, onCancel, onConfirm, tableId } = props;
|
|
2358
|
-
const tableManager = useDependency(TableManager);
|
|
2359
|
-
const [selectedRange, setSelectedRange] = useState(range);
|
|
2360
|
-
const [rangeError, setRangeError] = useState("");
|
|
2361
|
-
const localeService = useDependency(LocaleService);
|
|
2362
|
-
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
2363
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2364
|
-
/* @__PURE__ */ jsx(RangeSelector, {
|
|
2365
|
-
maxRangeCount: 1,
|
|
2366
|
-
unitId,
|
|
2367
|
-
subUnitId,
|
|
2368
|
-
initialValue: serializeRange(range),
|
|
2369
|
-
onChange: (_, text) => {
|
|
2370
|
-
const originValue = serializeRange(range);
|
|
2371
|
-
const newRange = deserializeRangeWithSheet(text).range;
|
|
2372
|
-
const target = getSheetCommandTarget(univerInstanceService, {
|
|
2373
|
-
unitId,
|
|
2374
|
-
subUnitId
|
|
2375
|
-
});
|
|
2376
|
-
if (!target) return;
|
|
2377
|
-
if (target.worksheet.getMergeData().some((merge) => {
|
|
2378
|
-
return Rectangle.intersects(newRange, merge);
|
|
2379
|
-
})) {
|
|
2380
|
-
setRangeError(localeService.t("sheets-table-ui.tableRangeWithMergeError"));
|
|
2381
|
-
return;
|
|
2382
|
-
}
|
|
2383
|
-
if (tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => {
|
|
2384
|
-
if (table.getId() === tableId) return false;
|
|
2385
|
-
const tableRange = table.getRange();
|
|
2386
|
-
return Rectangle.intersects(newRange, tableRange);
|
|
2387
|
-
})) {
|
|
2388
|
-
setRangeError(localeService.t("sheets-table-ui.tableRangeWithOtherTableError"));
|
|
2389
|
-
return;
|
|
2390
|
-
}
|
|
2391
|
-
const { startRow, endRow } = newRange;
|
|
2392
|
-
if (startRow === endRow) {
|
|
2393
|
-
setRangeError(localeService.t("sheets-table-ui.tableRangeSingleRowError"));
|
|
2394
|
-
return;
|
|
2395
|
-
}
|
|
2396
|
-
if (originValue === text) return;
|
|
2397
|
-
if (tableId) {
|
|
2398
|
-
const table = tableManager.getTableById(unitId, tableId);
|
|
2399
|
-
if (table) {
|
|
2400
|
-
const oldRange = table.getRange();
|
|
2401
|
-
if (Rectangle.intersects(newRange, oldRange) && oldRange.startRow === newRange.startRow) {
|
|
2402
|
-
setSelectedRange(newRange);
|
|
2403
|
-
setRangeError("");
|
|
2404
|
-
onConfirm({
|
|
2405
|
-
unitId,
|
|
2406
|
-
subUnitId,
|
|
2407
|
-
range: newRange
|
|
2408
|
-
});
|
|
2409
|
-
return;
|
|
2410
|
-
} else {
|
|
2411
|
-
setRangeError(localeService.t("sheets-table-ui.updateError"));
|
|
2412
|
-
return;
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
setSelectedRange(newRange);
|
|
2417
|
-
setRangeError("");
|
|
2418
|
-
},
|
|
2419
|
-
supportAcrossSheet: false
|
|
2420
|
-
}),
|
|
2421
|
-
rangeError && /* @__PURE__ */ jsx("div", {
|
|
2422
|
-
className: "univer-mt-1 univer-text-xs univer-text-red-500",
|
|
2423
|
-
children: rangeError
|
|
2424
|
-
}),
|
|
2425
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2426
|
-
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
2427
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
2428
|
-
onClick: onCancel,
|
|
2429
|
-
children: localeService.t("sheets-table-ui.cancel")
|
|
2430
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
2431
|
-
variant: "primary",
|
|
2432
|
-
onClick: () => {
|
|
2433
|
-
if (rangeError) return;
|
|
2434
|
-
onConfirm({
|
|
2435
|
-
unitId,
|
|
2436
|
-
subUnitId,
|
|
2437
|
-
range: selectedRange
|
|
2438
|
-
});
|
|
2439
|
-
},
|
|
2440
|
-
className: "univer-ml-2",
|
|
2441
|
-
children: localeService.t("sheets-table-ui.confirm")
|
|
2442
|
-
})]
|
|
2443
|
-
})
|
|
2444
|
-
] });
|
|
2445
|
-
};
|
|
2446
|
-
|
|
2447
|
-
//#endregion
|
|
2448
|
-
//#region src/views/components/SheetTableThemePanel.tsx
|
|
2449
|
-
const SheetTableThemePanel = (props) => {
|
|
2450
|
-
var _customStyle$getHeade, _customStyle$getHeade2, _customStyle$getFirst, _customStyle$getFirst2, _customStyle$getSecon, _customStyle$getSecon2, _customStyle$getLastR, _customStyle$getLastR2;
|
|
2451
|
-
const { unitId, subUnitId, tableId } = props;
|
|
2452
|
-
const commandService = useDependency(ICommandService);
|
|
2453
|
-
const localeService = useDependency(LocaleService);
|
|
2454
|
-
const tableManager = useDependency(TableManager);
|
|
2455
|
-
const table = tableManager.getTableById(unitId, tableId);
|
|
2456
|
-
const rangeThemeModel = useDependency(SheetRangeThemeModel);
|
|
2457
|
-
const sheetTableThemeUIController = useDependency(SheetTableThemeUIController);
|
|
2458
|
-
const rangeThemeMapChanged = useObservable(rangeThemeModel.rangeThemeMapChange$);
|
|
2459
|
-
const tableRefresh = useObservable(sheetTableThemeUIController.refreshTable$);
|
|
2460
|
-
const errorService = useDependency(ErrorService);
|
|
2461
|
-
const [, setRefresh] = useState(Math.random());
|
|
2462
|
-
const themeConfig = useObservable(tableManager.tableThemeChanged$, {
|
|
2463
|
-
theme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
2464
|
-
oldTheme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
2465
|
-
unitId,
|
|
2466
|
-
subUnitId,
|
|
2467
|
-
tableId
|
|
2468
|
-
});
|
|
2469
|
-
const defaultRangeThemes = rangeThemeModel.getRegisteredRangeThemes().filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_DEFAULT_NAME_PREFIX));
|
|
2470
|
-
const customRangeThemes = rangeThemeModel.getALLRegisteredTheme(unitId).filter((item) => item === null || item === void 0 ? void 0 : item.startsWith(TABLE_CUSTOM_NAME_PREFIX));
|
|
2471
|
-
const selectedTheme = table === null || table === void 0 ? void 0 : table.getTableStyleId();
|
|
2472
|
-
const customSelected = customRangeThemes.find((item) => item === selectedTheme);
|
|
2473
|
-
const customStyleName = customSelected || customRangeThemes[0];
|
|
2474
|
-
const customStyle = rangeThemeModel.getCustomRangeThemeStyle(unitId, customStyleName);
|
|
2475
|
-
const headerBg = (_customStyle$getHeade = customStyle === null || customStyle === void 0 || (_customStyle$getHeade2 = customStyle.getHeaderRowStyle()) === null || _customStyle$getHeade2 === void 0 || (_customStyle$getHeade2 = _customStyle$getHeade2.bg) === null || _customStyle$getHeade2 === void 0 ? void 0 : _customStyle$getHeade2.rgb) !== null && _customStyle$getHeade !== void 0 ? _customStyle$getHeade : TABLE_DEFAULT_BG_COLOR;
|
|
2476
|
-
const firstRowBg = (_customStyle$getFirst = customStyle === null || customStyle === void 0 || (_customStyle$getFirst2 = customStyle.getFirstRowStyle()) === null || _customStyle$getFirst2 === void 0 || (_customStyle$getFirst2 = _customStyle$getFirst2.bg) === null || _customStyle$getFirst2 === void 0 ? void 0 : _customStyle$getFirst2.rgb) !== null && _customStyle$getFirst !== void 0 ? _customStyle$getFirst : TABLE_DEFAULT_BG_COLOR;
|
|
2477
|
-
const secondRowBg = (_customStyle$getSecon = customStyle === null || customStyle === void 0 || (_customStyle$getSecon2 = customStyle.getSecondRowStyle()) === null || _customStyle$getSecon2 === void 0 || (_customStyle$getSecon2 = _customStyle$getSecon2.bg) === null || _customStyle$getSecon2 === void 0 ? void 0 : _customStyle$getSecon2.rgb) !== null && _customStyle$getSecon !== void 0 ? _customStyle$getSecon : TABLE_DEFAULT_BG_COLOR;
|
|
2478
|
-
const lastRowBg = (_customStyle$getLastR = customStyle === null || customStyle === void 0 || (_customStyle$getLastR2 = customStyle.getLastRowStyle()) === null || _customStyle$getLastR2 === void 0 || (_customStyle$getLastR2 = _customStyle$getLastR2.bg) === null || _customStyle$getLastR2 === void 0 ? void 0 : _customStyle$getLastR2.rgb) !== null && _customStyle$getLastR !== void 0 ? _customStyle$getLastR : TABLE_DEFAULT_BG_COLOR;
|
|
2479
|
-
const [hoverCustomId, setHoverCustomId] = useState(null);
|
|
2480
|
-
const handleThemeChange = (theme) => {
|
|
2481
|
-
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
2482
|
-
unitId,
|
|
2483
|
-
tableId,
|
|
2484
|
-
theme
|
|
2485
|
-
});
|
|
2486
|
-
};
|
|
2487
|
-
const handleAddCustomTheme = () => {
|
|
2488
|
-
if (customRangeThemes.length >= 11) {
|
|
2489
|
-
errorService.emit(localeService.t("sheets-table-ui.customTooMore"));
|
|
2490
|
-
return;
|
|
2491
|
-
}
|
|
2492
|
-
const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];
|
|
2493
|
-
let newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}1`;
|
|
2494
|
-
if (lastCustomTheme) newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}${Number(lastCustomTheme.split("-")[2]) + 1}`;
|
|
2495
|
-
const newTheme = new RangeThemeStyle(newThemeName, { ...customEmptyThemeWithBorderStyle });
|
|
2496
|
-
commandService.executeCommand(AddTableThemeCommand.id, {
|
|
2497
|
-
unitId,
|
|
2498
|
-
tableId,
|
|
2499
|
-
themeStyle: newTheme
|
|
2500
|
-
});
|
|
2501
|
-
};
|
|
2502
|
-
const setCustomTheme = (themeName, tableThemeStyle) => {
|
|
2503
|
-
commandService.executeCommand(SetRangeThemeMutation.id, {
|
|
2504
|
-
unitId,
|
|
2505
|
-
subUnitId,
|
|
2506
|
-
styleName: themeName,
|
|
2507
|
-
style: tableThemeStyle
|
|
2508
|
-
});
|
|
2509
|
-
};
|
|
2510
|
-
const removeCustomTheme = (themeName) => {
|
|
2511
|
-
commandService.executeCommand(RemoveTableThemeCommand.id, {
|
|
2512
|
-
unitId,
|
|
2513
|
-
tableId,
|
|
2514
|
-
themeName
|
|
2515
|
-
});
|
|
2516
|
-
};
|
|
2517
|
-
useEffect(() => {
|
|
2518
|
-
setRefresh(Math.random());
|
|
2519
|
-
}, [rangeThemeMapChanged, tableRefresh]);
|
|
2520
|
-
if (!table) return null;
|
|
2521
|
-
const headerBgIsDark = new ColorKit(headerBg).isDark();
|
|
2522
|
-
const firstRowBgIsDark = new ColorKit(firstRowBg).isDark();
|
|
2523
|
-
const secondRowBgIsDark = new ColorKit(secondRowBg).isDark();
|
|
2524
|
-
const lastRowBgIsDark = new ColorKit(lastRowBg).isDark();
|
|
2525
|
-
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2526
|
-
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.defaultStyle") }),
|
|
2527
|
-
/* @__PURE__ */ jsx("div", {
|
|
2528
|
-
className: "univer-flex univer-gap-2",
|
|
2529
|
-
children: defaultRangeThemes.map((item) => {
|
|
2530
|
-
var _rangeThemeItem$getHe, _rangeThemeItem$getFi, _rangeThemeItem$getSe, _rangeThemeItem$getLa;
|
|
2531
|
-
const rangeThemeItem = rangeThemeModel.getDefaultRangeThemeStyle(item);
|
|
2532
|
-
const headerRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe === void 0 || (_rangeThemeItem$getHe = _rangeThemeItem$getHe.bg) === null || _rangeThemeItem$getHe === void 0 ? void 0 : _rangeThemeItem$getHe.rgb) || "rgb(255, 255, 255)";
|
|
2533
|
-
const firstRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi === void 0 || (_rangeThemeItem$getFi = _rangeThemeItem$getFi.bg) === null || _rangeThemeItem$getFi === void 0 ? void 0 : _rangeThemeItem$getFi.rgb) || "rgb(255, 255, 255)";
|
|
2534
|
-
const secondRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe === void 0 || (_rangeThemeItem$getSe = _rangeThemeItem$getSe.bg) === null || _rangeThemeItem$getSe === void 0 ? void 0 : _rangeThemeItem$getSe.rgb) || "rgb(255, 255, 255)";
|
|
2535
|
-
const lastRowBg = (rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa === void 0 || (_rangeThemeItem$getLa = _rangeThemeItem$getLa.bg) === null || _rangeThemeItem$getLa === void 0 ? void 0 : _rangeThemeItem$getLa.rgb) || "rgb(255, 255, 255)";
|
|
2536
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2537
|
-
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px [&>div]:univer-box-border [&>div]:univer-h-2.5", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
2538
|
-
onClick: () => handleThemeChange(item),
|
|
2539
|
-
children: [
|
|
2540
|
-
/* @__PURE__ */ jsx("div", { style: {
|
|
2541
|
-
background: headerRowBg,
|
|
2542
|
-
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2543
|
-
} }),
|
|
2544
|
-
/* @__PURE__ */ jsx("div", { style: {
|
|
2545
|
-
background: firstRowBg,
|
|
2546
|
-
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2547
|
-
} }),
|
|
2548
|
-
/* @__PURE__ */ jsx("div", { style: {
|
|
2549
|
-
background: secondRowBg,
|
|
2550
|
-
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2551
|
-
} }),
|
|
2552
|
-
/* @__PURE__ */ jsx("div", { style: {
|
|
2553
|
-
background: lastRowBg,
|
|
2554
|
-
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2555
|
-
} })
|
|
2556
|
-
]
|
|
2557
|
-
}, item);
|
|
2558
|
-
})
|
|
2559
|
-
}),
|
|
2560
|
-
/* @__PURE__ */ jsx("h5", { children: localeService.t("sheets-table-ui.customStyle") }),
|
|
2561
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2562
|
-
className: clsx("univer-w-full univer-rounded-sm", borderClassName),
|
|
2563
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
2564
|
-
className: "univer-flex univer-flex-wrap univer-gap-2 univer-p-2",
|
|
2565
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2566
|
-
className: clsx("univer-h-10 univer-w-8 univer-cursor-pointer univer-p-px univer-text-center univer-leading-10", borderClassName),
|
|
2567
|
-
onClick: handleAddCustomTheme,
|
|
2568
|
-
children: "+"
|
|
2569
|
-
}), customRangeThemes.map((item) => {
|
|
2570
|
-
var _rangeThemeItem$getHe2, _rangeThemeItem$getFi2, _rangeThemeItem$getSe2, _rangeThemeItem$getLa2;
|
|
2571
|
-
const rangeThemeItem = rangeThemeModel.getCustomRangeThemeStyle(unitId, item);
|
|
2572
|
-
const headerRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getHe2 = rangeThemeItem.getHeaderRowStyle()) === null || _rangeThemeItem$getHe2 === void 0 || (_rangeThemeItem$getHe2 = _rangeThemeItem$getHe2.bg) === null || _rangeThemeItem$getHe2 === void 0 ? void 0 : _rangeThemeItem$getHe2.rgb;
|
|
2573
|
-
const firstRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getFi2 = rangeThemeItem.getFirstRowStyle()) === null || _rangeThemeItem$getFi2 === void 0 || (_rangeThemeItem$getFi2 = _rangeThemeItem$getFi2.bg) === null || _rangeThemeItem$getFi2 === void 0 ? void 0 : _rangeThemeItem$getFi2.rgb;
|
|
2574
|
-
const secondRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getSe2 = rangeThemeItem.getSecondRowStyle()) === null || _rangeThemeItem$getSe2 === void 0 || (_rangeThemeItem$getSe2 = _rangeThemeItem$getSe2.bg) === null || _rangeThemeItem$getSe2 === void 0 ? void 0 : _rangeThemeItem$getSe2.rgb;
|
|
2575
|
-
const lastRowBg = rangeThemeItem === null || rangeThemeItem === void 0 || (_rangeThemeItem$getLa2 = rangeThemeItem.getLastRowStyle()) === null || _rangeThemeItem$getLa2 === void 0 || (_rangeThemeItem$getLa2 = _rangeThemeItem$getLa2.bg) === null || _rangeThemeItem$getLa2 === void 0 ? void 0 : _rangeThemeItem$getLa2.rgb;
|
|
2576
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2577
|
-
className: clsx("univer-relative univer-h-10 univer-w-8 univer-cursor-pointer univer-border univer-border-solid univer-border-gray-200 univer-p-px", { "univer-border-blue-500": item === themeConfig.theme }),
|
|
2578
|
-
onClick: () => handleThemeChange(item),
|
|
2579
|
-
onMouseEnter: () => setHoverCustomId(item),
|
|
2580
|
-
onMouseLeave: () => setHoverCustomId(null),
|
|
2581
|
-
children: [
|
|
2582
|
-
/* @__PURE__ */ jsx("div", {
|
|
2583
|
-
className: "univer-box-border univer-h-2.5",
|
|
2584
|
-
style: {
|
|
2585
|
-
background: headerRowBg !== null && headerRowBg !== void 0 ? headerRowBg : TABLE_BORDER_NONE,
|
|
2586
|
-
border: `${headerRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2587
|
-
}
|
|
2588
|
-
}),
|
|
2589
|
-
/* @__PURE__ */ jsx("div", {
|
|
2590
|
-
className: "univer-box-border univer-h-2.5",
|
|
2591
|
-
style: {
|
|
2592
|
-
background: firstRowBg !== null && firstRowBg !== void 0 ? firstRowBg : TABLE_BORDER_NONE,
|
|
2593
|
-
border: `${firstRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2594
|
-
}
|
|
2595
|
-
}),
|
|
2596
|
-
/* @__PURE__ */ jsx("div", {
|
|
2597
|
-
className: "univer-box-border univer-h-2.5",
|
|
2598
|
-
style: {
|
|
2599
|
-
background: secondRowBg !== null && secondRowBg !== void 0 ? secondRowBg : TABLE_BORDER_NONE,
|
|
2600
|
-
border: `${secondRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2601
|
-
}
|
|
2602
|
-
}),
|
|
2603
|
-
/* @__PURE__ */ jsx("div", {
|
|
2604
|
-
className: "univer-box-border univer-h-2.5",
|
|
2605
|
-
style: {
|
|
2606
|
-
background: lastRowBg !== null && lastRowBg !== void 0 ? lastRowBg : TABLE_BORDER_NONE,
|
|
2607
|
-
border: `${lastRowBg ? TABLE_BORDER_NONE : TABLE_BORDER_DEFAULT}`
|
|
2608
|
-
}
|
|
2609
|
-
}),
|
|
2610
|
-
/* @__PURE__ */ jsx("div", {
|
|
2611
|
-
className: "univer-absolute univer-right-[-3px] univer-top-[-3px] univer-size-3 univer-rounded-md univer-bg-gray-200 univer-text-center univer-text-xs univer-leading-[10px]",
|
|
2612
|
-
style: { display: hoverCustomId === item ? "block" : "none" },
|
|
2613
|
-
onClick: (e) => {
|
|
2614
|
-
e.stopPropagation();
|
|
2615
|
-
removeCustomTheme(item);
|
|
2616
|
-
},
|
|
2617
|
-
children: "x"
|
|
2618
|
-
})
|
|
2619
|
-
]
|
|
2620
|
-
}, item);
|
|
2621
|
-
})]
|
|
2622
|
-
}), customSelected && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "univer-h-px univer-w-full univer-bg-gray-200" }), /* @__PURE__ */ jsxs("div", {
|
|
2623
|
-
className: "univer-flex univer-flex-col univer-gap-2 univer-p-2",
|
|
2624
|
-
children: [
|
|
2625
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2626
|
-
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2627
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2628
|
-
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2629
|
-
"univer-text-white": headerBgIsDark,
|
|
2630
|
-
"univer-text-gray-900": !headerBgIsDark
|
|
2631
|
-
}),
|
|
2632
|
-
style: { background: headerBg },
|
|
2633
|
-
children: localeService.t("sheets-table-ui.header")
|
|
2634
|
-
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2635
|
-
overlay: /* @__PURE__ */ jsx("div", {
|
|
2636
|
-
className: "univer-p-2",
|
|
2637
|
-
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2638
|
-
value: headerBg,
|
|
2639
|
-
onChange: (val) => {
|
|
2640
|
-
const headerRowStyle = processStyleWithBorderStyle("headerRowStyle", {
|
|
2641
|
-
bg: { rgb: val },
|
|
2642
|
-
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2643
|
-
});
|
|
2644
|
-
setCustomTheme(table.getTableStyleId(), { headerRowStyle });
|
|
2645
|
-
}
|
|
2646
|
-
})
|
|
2647
|
-
}),
|
|
2648
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2649
|
-
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2650
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2651
|
-
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName, {
|
|
2652
|
-
"univer-text-white": headerBgIsDark,
|
|
2653
|
-
"univer-text-gray-900": !headerBgIsDark
|
|
2654
|
-
}),
|
|
2655
|
-
style: { background: headerBg }
|
|
2656
|
-
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2657
|
-
})
|
|
2658
|
-
})]
|
|
2659
|
-
}),
|
|
2660
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2661
|
-
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2662
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2663
|
-
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2664
|
-
"univer-text-white": firstRowBgIsDark,
|
|
2665
|
-
"univer-text-gray-900": !firstRowBgIsDark
|
|
2666
|
-
}),
|
|
2667
|
-
style: { background: firstRowBg },
|
|
2668
|
-
children: localeService.t("sheets-table-ui.firstLine")
|
|
2669
|
-
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2670
|
-
overlay: /* @__PURE__ */ jsx("div", {
|
|
2671
|
-
className: "univer-p-2",
|
|
2672
|
-
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2673
|
-
value: firstRowBg,
|
|
2674
|
-
onChange: (val) => {
|
|
2675
|
-
setCustomTheme(table.getTableStyleId(), { firstRowStyle: {
|
|
2676
|
-
bg: { rgb: val },
|
|
2677
|
-
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2678
|
-
} });
|
|
2679
|
-
}
|
|
2680
|
-
})
|
|
2681
|
-
}),
|
|
2682
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2683
|
-
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2684
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2685
|
-
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2686
|
-
style: { background: firstRowBg }
|
|
2687
|
-
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2688
|
-
})
|
|
2689
|
-
})]
|
|
2690
|
-
}),
|
|
2691
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2692
|
-
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2693
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2694
|
-
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2695
|
-
"univer-text-white": secondRowBgIsDark,
|
|
2696
|
-
"univer-text-gray-900": !secondRowBgIsDark
|
|
2697
|
-
}),
|
|
2698
|
-
style: { background: secondRowBg },
|
|
2699
|
-
children: localeService.t("sheets-table-ui.secondLine")
|
|
2700
|
-
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2701
|
-
overlay: /* @__PURE__ */ jsx("div", {
|
|
2702
|
-
className: "univer-p-2",
|
|
2703
|
-
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2704
|
-
value: secondRowBg,
|
|
2705
|
-
onChange: (val) => setCustomTheme(table.getTableStyleId(), { secondRowStyle: {
|
|
2706
|
-
bg: { rgb: val },
|
|
2707
|
-
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2708
|
-
} })
|
|
2709
|
-
})
|
|
2710
|
-
}),
|
|
2711
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2712
|
-
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2713
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2714
|
-
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2715
|
-
style: { background: secondRowBg }
|
|
2716
|
-
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2717
|
-
})
|
|
2718
|
-
})]
|
|
2719
|
-
}),
|
|
2720
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2721
|
-
className: "univer-flex univer-h-9 univer-gap-2",
|
|
2722
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2723
|
-
className: clsx("univer-box-border univer-h-full univer-w-52 univer-rounded-sm univer-text-center univer-leading-9", borderClassName, {
|
|
2724
|
-
"univer-text-white": lastRowBgIsDark,
|
|
2725
|
-
"univer-text-gray-900": !lastRowBgIsDark
|
|
2726
|
-
}),
|
|
2727
|
-
style: { background: lastRowBg },
|
|
2728
|
-
children: localeService.t("sheets-table-ui.footer")
|
|
2729
|
-
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
2730
|
-
overlay: /* @__PURE__ */ jsx("div", {
|
|
2731
|
-
className: "univer-p-2",
|
|
2732
|
-
children: /* @__PURE__ */ jsx(ColorPicker, {
|
|
2733
|
-
value: lastRowBg,
|
|
2734
|
-
onChange: (val) => {
|
|
2735
|
-
const lastRowStyle = processStyleWithBorderStyle("lastRowStyle", {
|
|
2736
|
-
bg: { rgb: val },
|
|
2737
|
-
cl: { rgb: new ColorKit(val).isDark() ? "#fff" : "#000" }
|
|
2738
|
-
});
|
|
2739
|
-
setCustomTheme(table.getTableStyleId(), { lastRowStyle });
|
|
2740
|
-
}
|
|
2741
|
-
})
|
|
2742
|
-
}),
|
|
2743
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2744
|
-
className: clsx("univer-flex univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-sm univer-bg-white univer-p-1", borderClassName),
|
|
2745
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
2746
|
-
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
2747
|
-
style: { background: lastRowBg }
|
|
2748
|
-
}), /* @__PURE__ */ jsx(DropdownIcon, { className: "univer-size-2" })]
|
|
2749
|
-
})
|
|
2750
|
-
})]
|
|
2751
|
-
})
|
|
2752
|
-
]
|
|
2753
|
-
})] })]
|
|
2754
|
-
})
|
|
2755
|
-
] });
|
|
2535
|
+
super();
|
|
2536
|
+
this._context = _context;
|
|
2537
|
+
this._injector = _injector;
|
|
2538
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2539
|
+
this._sheetInterceptorService = _sheetInterceptorService;
|
|
2540
|
+
this._tableManager = _tableManager;
|
|
2541
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
2542
|
+
this._commandService = _commandService;
|
|
2543
|
+
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
2544
|
+
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
2545
|
+
this._initRenderer();
|
|
2546
|
+
this._initCommandExecuted();
|
|
2547
|
+
}
|
|
2548
|
+
dispose() {
|
|
2549
|
+
super.dispose();
|
|
2550
|
+
this._disposeRendering();
|
|
2551
|
+
}
|
|
2552
|
+
_initRenderer() {
|
|
2553
|
+
const tableManager = this._tableManager;
|
|
2554
|
+
this._sheetSkeletonManagerService.currentSkeleton$.pipe(switchMap((skeletonParams) => {
|
|
2555
|
+
var _workbook$getActiveSh;
|
|
2556
|
+
if (!skeletonParams) return of(null);
|
|
2557
|
+
const { unit: workbook, unitId } = this._context;
|
|
2558
|
+
const worksheetId = ((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId()) || "";
|
|
2559
|
+
const getParams = () => ({
|
|
2560
|
+
unitId,
|
|
2561
|
+
worksheetId,
|
|
2562
|
+
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
2563
|
+
skeleton: skeletonParams.skeleton
|
|
2564
|
+
});
|
|
2565
|
+
return merge$1(tableManager.tableAdd$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableDelete$, tableManager.tableFilterChanged$).pipe(map(() => getParams()), startWith(getParams()));
|
|
2566
|
+
}), takeUntil(this.dispose$)).subscribe((renderParams) => {
|
|
2567
|
+
this._disposeRendering();
|
|
2568
|
+
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
2569
|
+
this._renderButtons(renderParams);
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
_initCommandExecuted() {
|
|
2573
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2574
|
+
var _workbook$getActiveSh2;
|
|
2575
|
+
if (command.id !== SetVerticalTextAlignCommand.id) return;
|
|
2576
|
+
const { unit: workbook, unitId } = this._context;
|
|
2577
|
+
const worksheetId = ((_workbook$getActiveSh2 = workbook.getActiveSheet()) === null || _workbook$getActiveSh2 === void 0 ? void 0 : _workbook$getActiveSh2.getSheetId()) || "";
|
|
2578
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
2579
|
+
if (!skeleton) return;
|
|
2580
|
+
const renderParams = {
|
|
2581
|
+
unitId,
|
|
2582
|
+
worksheetId,
|
|
2583
|
+
tableFilterRanges: this._tableManager.getSheetFilterRangeWithState(workbook.getUnitId(), worksheetId),
|
|
2584
|
+
skeleton
|
|
2585
|
+
};
|
|
2586
|
+
this._disposeRendering();
|
|
2587
|
+
if (!renderParams || !renderParams.tableFilterRanges) return;
|
|
2588
|
+
this._renderButtons(renderParams);
|
|
2589
|
+
}));
|
|
2590
|
+
}
|
|
2591
|
+
_renderButtons(params) {
|
|
2592
|
+
const { tableFilterRanges, unitId, skeleton, worksheetId } = params;
|
|
2593
|
+
const { unit: workbook, scene } = this._context;
|
|
2594
|
+
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
2595
|
+
if (!worksheet) return;
|
|
2596
|
+
for (const { range, states, tableId } of tableFilterRanges) {
|
|
2597
|
+
var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
|
|
2598
|
+
const { startRow, startColumn, endColumn } = range;
|
|
2599
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
2600
|
+
const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
|
|
2601
|
+
const iconColor = (_headerStyle$cl$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$cl = headerStyle.cl) === null || _headerStyle$cl === void 0 ? void 0 : _headerStyle$cl.rgb) !== null && _headerStyle$cl$rgb !== void 0 ? _headerStyle$cl$rgb : "#fff";
|
|
2602
|
+
const hoverIconColor = (_headerStyle$bg$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) !== null && _headerStyle$bg$rgb !== void 0 ? _headerStyle$bg$rgb : "#202124";
|
|
2603
|
+
this._interceptCellContent(unitId, worksheetId, range);
|
|
2604
|
+
for (let col = startColumn; col <= endColumn; col++) {
|
|
2605
|
+
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
2606
|
+
const startPosition = getCoordByCell(startRow, col, scene, skeleton);
|
|
2607
|
+
const cellStyle = worksheet.getCellStyle(startRow, col);
|
|
2608
|
+
const verticalAlign = (cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle.vt) || VerticalAlign.BOTTOM;
|
|
2609
|
+
const { startX, startY, endX, endY } = startPosition;
|
|
2610
|
+
const cellWidth = endX - startX;
|
|
2611
|
+
const cellHeight = endY - startY;
|
|
2612
|
+
if (cellHeight <= 1 || cellWidth <= 1) continue;
|
|
2613
|
+
const state = states[col - startColumn];
|
|
2614
|
+
const props = {
|
|
2615
|
+
left: endX - 16 - 1,
|
|
2616
|
+
top: computeIconTop(startY, endY, cellHeight, verticalAlign),
|
|
2617
|
+
height: 16,
|
|
2618
|
+
width: 16,
|
|
2619
|
+
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2620
|
+
iconColor,
|
|
2621
|
+
hoverBackground: iconColor,
|
|
2622
|
+
hoverIconColor,
|
|
2623
|
+
cellHeight,
|
|
2624
|
+
cellWidth,
|
|
2625
|
+
filterParams: {
|
|
2626
|
+
unitId,
|
|
2627
|
+
subUnitId: worksheetId,
|
|
2628
|
+
row: startRow,
|
|
2629
|
+
col,
|
|
2630
|
+
buttonState: state,
|
|
2631
|
+
tableId
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
const buttonShape = this._injector.createInstance(SheetsTableFilterButtonShape, key, props);
|
|
2635
|
+
this._tableFilterButtonShapes.push(buttonShape);
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
scene.addObjects(this._tableFilterButtonShapes);
|
|
2639
|
+
scene.makeDirty();
|
|
2640
|
+
}
|
|
2641
|
+
_interceptCellContent(workbookId, worksheetId, range) {
|
|
2642
|
+
const { startRow, startColumn, endColumn } = range;
|
|
2643
|
+
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
2644
|
+
effect: InterceptorEffectEnum.Style,
|
|
2645
|
+
handler: (cell, pos, next) => {
|
|
2646
|
+
const { row, col, unitId, subUnitId } = pos;
|
|
2647
|
+
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
2648
|
+
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2649
|
+
cell.fontRenderExtension = {
|
|
2650
|
+
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2651
|
+
rightOffset: 16 + 1 + 2
|
|
2652
|
+
};
|
|
2653
|
+
return next(cell);
|
|
2654
|
+
},
|
|
2655
|
+
priority: 10
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
_disposeRendering() {
|
|
2659
|
+
var _this$_buttonRenderDi;
|
|
2660
|
+
this._tableFilterButtonShapes.forEach((s) => s.dispose());
|
|
2661
|
+
(_this$_buttonRenderDi = this._buttonRenderDisposable) === null || _this$_buttonRenderDi === void 0 || _this$_buttonRenderDi.dispose();
|
|
2662
|
+
this._buttonRenderDisposable = null;
|
|
2663
|
+
this._tableFilterButtonShapes = [];
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2666
|
+
SheetsTableFilterButtonRenderController = __decorate([
|
|
2667
|
+
__decorateParam(1, Inject(Injector)),
|
|
2668
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
2669
|
+
__decorateParam(3, Inject(SheetInterceptorService)),
|
|
2670
|
+
__decorateParam(4, Inject(TableManager)),
|
|
2671
|
+
__decorateParam(5, Inject(SheetRangeThemeModel)),
|
|
2672
|
+
__decorateParam(6, ICommandService)
|
|
2673
|
+
], SheetsTableFilterButtonRenderController);
|
|
2674
|
+
|
|
2675
|
+
//#endregion
|
|
2676
|
+
//#region src/controllers/sheet-table-render.controller.ts
|
|
2677
|
+
let SheetsTableRenderController = class SheetsTableRenderController extends RxDisposable {
|
|
2678
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _tableManager, _sheetTableThemeUIController) {
|
|
2679
|
+
super();
|
|
2680
|
+
this._context = _context;
|
|
2681
|
+
this._injector = _injector;
|
|
2682
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2683
|
+
this._tableManager = _tableManager;
|
|
2684
|
+
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
2685
|
+
this._initListener();
|
|
2686
|
+
}
|
|
2687
|
+
_dirtySkeleton() {
|
|
2688
|
+
var _this$_context$mainCo;
|
|
2689
|
+
(_this$_context$mainCo = this._context.mainComponent) === null || _this$_context$mainCo === void 0 || _this$_context$mainCo.makeDirty();
|
|
2690
|
+
const currentParam = this._sheetSkeletonManagerService.getCurrentParam();
|
|
2691
|
+
if (currentParam) {
|
|
2692
|
+
const param = {
|
|
2693
|
+
...currentParam,
|
|
2694
|
+
dirty: true
|
|
2695
|
+
};
|
|
2696
|
+
this._sheetSkeletonManagerService.reCalculate(param);
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
_initListener() {
|
|
2700
|
+
const tableManager = this._tableManager;
|
|
2701
|
+
const dirtySkeleton = this._dirtySkeleton.bind(this);
|
|
2702
|
+
this.disposeWithMe(merge$1(tableManager.tableAdd$, tableManager.tableDelete$, tableManager.tableNameChanged$, tableManager.tableRangeChanged$, tableManager.tableThemeChanged$, tableManager.tableFilterChanged$, tableManager.tableInitStatus$, this._sheetTableThemeUIController.refreshTable$).subscribe(dirtySkeleton));
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
SheetsTableRenderController = __decorate([
|
|
2706
|
+
__decorateParam(1, Inject(Injector)),
|
|
2707
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
2708
|
+
__decorateParam(3, Inject(TableManager)),
|
|
2709
|
+
__decorateParam(4, Inject(SheetTableThemeUIController))
|
|
2710
|
+
], SheetsTableRenderController);
|
|
2711
|
+
|
|
2712
|
+
//#endregion
|
|
2713
|
+
//#region src/controllers/sheet-table-selection.controller.ts
|
|
2714
|
+
let SheetTableSelectionController = class SheetTableSelectionController extends Disposable {
|
|
2715
|
+
constructor(_sheetInterceptorService, _univerInstanceService, _tableManager) {
|
|
2716
|
+
super();
|
|
2717
|
+
this._sheetInterceptorService = _sheetInterceptorService;
|
|
2718
|
+
this._univerInstanceService = _univerInstanceService;
|
|
2719
|
+
this._tableManager = _tableManager;
|
|
2720
|
+
this._initSelectionChange();
|
|
2721
|
+
}
|
|
2722
|
+
_initSelectionChange() {
|
|
2723
|
+
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({ getMutations: (command) => {
|
|
2724
|
+
if (command.id === SelectAllCommand.id) {
|
|
2725
|
+
const target = getSheetCommandTarget(this._univerInstanceService);
|
|
2726
|
+
if (!target) return {
|
|
2727
|
+
redos: [],
|
|
2728
|
+
undos: []
|
|
2729
|
+
};
|
|
2730
|
+
const { range } = command.params;
|
|
2731
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
2732
|
+
const overlapTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).find((table) => {
|
|
2733
|
+
const tableRange = table.getRange();
|
|
2734
|
+
return Rectangle.contains(tableRange, range);
|
|
2735
|
+
});
|
|
2736
|
+
if (overlapTable) {
|
|
2737
|
+
const tableRange = overlapTable.getRange();
|
|
2738
|
+
const tableRangeWithoutHeader = {
|
|
2739
|
+
...tableRange,
|
|
2740
|
+
startRow: tableRange.startRow + 1
|
|
2741
|
+
};
|
|
2742
|
+
if (Rectangle.equals(tableRange, range)) return {
|
|
2743
|
+
undos: [],
|
|
2744
|
+
redos: []
|
|
2745
|
+
};
|
|
2746
|
+
else if (Rectangle.equals(tableRangeWithoutHeader, range)) return {
|
|
2747
|
+
undos: [],
|
|
2748
|
+
redos: [{
|
|
2749
|
+
id: SetSelectionsOperation.id,
|
|
2750
|
+
params: {
|
|
2751
|
+
unitId,
|
|
2752
|
+
subUnitId,
|
|
2753
|
+
selections: [{
|
|
2754
|
+
range: tableRange,
|
|
2755
|
+
primary: getPrimaryForRange(tableRange, worksheet)
|
|
2756
|
+
}]
|
|
2757
|
+
}
|
|
2758
|
+
}]
|
|
2759
|
+
};
|
|
2760
|
+
else return {
|
|
2761
|
+
undos: [],
|
|
2762
|
+
redos: [{
|
|
2763
|
+
id: SetSelectionsOperation.id,
|
|
2764
|
+
params: {
|
|
2765
|
+
unitId,
|
|
2766
|
+
subUnitId,
|
|
2767
|
+
selections: [{
|
|
2768
|
+
range: tableRangeWithoutHeader,
|
|
2769
|
+
primary: getPrimaryForRange(tableRangeWithoutHeader, worksheet)
|
|
2770
|
+
}]
|
|
2771
|
+
}
|
|
2772
|
+
}]
|
|
2773
|
+
};
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
return {
|
|
2777
|
+
redos: [],
|
|
2778
|
+
undos: []
|
|
2779
|
+
};
|
|
2780
|
+
} }));
|
|
2781
|
+
}
|
|
2756
2782
|
};
|
|
2783
|
+
SheetTableSelectionController = __decorate([
|
|
2784
|
+
__decorateParam(0, Inject(SheetInterceptorService)),
|
|
2785
|
+
__decorateParam(1, Inject(IUniverInstanceService)),
|
|
2786
|
+
__decorateParam(2, Inject(TableManager))
|
|
2787
|
+
], SheetTableSelectionController);
|
|
2757
2788
|
|
|
2758
2789
|
//#endregion
|
|
2759
2790
|
//#region src/menu/menu.ts
|
|
@@ -2763,7 +2794,7 @@ function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
|
2763
2794
|
return {
|
|
2764
2795
|
id: OpenTableSelectorOperation.id,
|
|
2765
2796
|
type: MenuItemType.BUTTON,
|
|
2766
|
-
icon:
|
|
2797
|
+
icon: "TableIcon",
|
|
2767
2798
|
tooltip: "sheets-table-ui.title",
|
|
2768
2799
|
title: "sheets-table-ui.title",
|
|
2769
2800
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
@@ -2796,7 +2827,7 @@ function SheetTableInsertRowMenuFactory(accessor) {
|
|
|
2796
2827
|
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2797
2828
|
};
|
|
2798
2829
|
}
|
|
2799
|
-
function SheetTableInsertColMenuFactory(
|
|
2830
|
+
function SheetTableInsertColMenuFactory() {
|
|
2800
2831
|
return {
|
|
2801
2832
|
id: SheetTableInsertColCommand.id,
|
|
2802
2833
|
title: "sheets-table-ui.insert.col",
|
|
@@ -2811,7 +2842,7 @@ function SheetTableRemoveRowMenuFactory(accessor) {
|
|
|
2811
2842
|
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2812
2843
|
};
|
|
2813
2844
|
}
|
|
2814
|
-
function SheetTableRemoveColMenuFactory(
|
|
2845
|
+
function SheetTableRemoveColMenuFactory() {
|
|
2815
2846
|
return {
|
|
2816
2847
|
id: SheetTableRemoveColCommand.id,
|
|
2817
2848
|
title: "sheets-table-ui.remove.col",
|
|
@@ -2904,27 +2935,22 @@ const menuSchema = {
|
|
|
2904
2935
|
* limitations under the License.
|
|
2905
2936
|
*/
|
|
2906
2937
|
let SheetTableMenuController = class SheetTableMenuController extends Disposable {
|
|
2907
|
-
constructor(_componentManager, _menuManagerService) {
|
|
2938
|
+
constructor(_componentManager, _iconManager, _menuManagerService) {
|
|
2908
2939
|
super();
|
|
2909
2940
|
this._componentManager = _componentManager;
|
|
2941
|
+
this._iconManager = _iconManager;
|
|
2910
2942
|
this._menuManagerService = _menuManagerService;
|
|
2911
|
-
this._initComponents();
|
|
2912
2943
|
this._initMenu();
|
|
2913
2944
|
}
|
|
2914
|
-
_initComponents() {
|
|
2915
|
-
[
|
|
2916
|
-
[TABLE_TOOLBAR_BUTTON, TableIcon],
|
|
2917
|
-
[TABLE_SELECTOR_DIALOG, SheetTableSelector],
|
|
2918
|
-
[SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]
|
|
2919
|
-
].forEach(([key, comp]) => {
|
|
2920
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
2921
|
-
});
|
|
2922
|
-
}
|
|
2923
2945
|
_initMenu() {
|
|
2924
2946
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
2925
2947
|
}
|
|
2926
2948
|
};
|
|
2927
|
-
SheetTableMenuController = __decorate([
|
|
2949
|
+
SheetTableMenuController = __decorate([
|
|
2950
|
+
__decorateParam(0, Inject(ComponentManager)),
|
|
2951
|
+
__decorateParam(1, Inject(IconManager)),
|
|
2952
|
+
__decorateParam(2, Inject(IMenuManagerService))
|
|
2953
|
+
], SheetTableMenuController);
|
|
2928
2954
|
|
|
2929
2955
|
//#endregion
|
|
2930
2956
|
//#region src/plugin.ts
|
|
@@ -2942,6 +2968,8 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends Plugin {
|
|
|
2942
2968
|
this._initRegisterCommand();
|
|
2943
2969
|
}
|
|
2944
2970
|
onStarting() {
|
|
2971
|
+
this._injector.add([ComponentsController]);
|
|
2972
|
+
this._injector.get(ComponentsController);
|
|
2945
2973
|
registerDependencies(this._injector, [
|
|
2946
2974
|
[SheetsTableComponentController],
|
|
2947
2975
|
[SheetsTableUiService],
|