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