@univerjs/sheets-table-ui 0.23.0 → 0.24.0-insiders.20260528-29f582d
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 +950 -488
- package/lib/cjs/locale/ar-SA.js +129 -0
- package/lib/cjs/locale/ca-ES.js +11 -1
- package/lib/cjs/locale/de-DE.js +129 -0
- package/lib/cjs/locale/en-US.js +11 -1
- package/lib/cjs/locale/es-ES.js +11 -1
- package/lib/cjs/locale/fa-IR.js +11 -1
- package/lib/cjs/locale/fr-FR.js +11 -1
- package/lib/cjs/locale/id-ID.js +129 -0
- package/lib/cjs/locale/it-IT.js +129 -0
- package/lib/cjs/locale/ja-JP.js +11 -1
- package/lib/cjs/locale/ko-KR.js +11 -1
- package/lib/cjs/locale/pl-PL.js +129 -0
- package/lib/cjs/locale/pt-BR.js +129 -0
- package/lib/cjs/locale/ru-RU.js +11 -1
- package/lib/cjs/locale/sk-SK.js +11 -1
- package/lib/cjs/locale/vi-VN.js +11 -1
- package/lib/cjs/locale/zh-CN.js +11 -1
- package/lib/cjs/locale/zh-HK.js +129 -0
- package/lib/cjs/locale/zh-TW.js +11 -1
- package/lib/es/index.js +958 -496
- package/lib/es/locale/ar-SA.js +128 -0
- package/lib/es/locale/ca-ES.js +11 -1
- package/lib/es/locale/de-DE.js +128 -0
- package/lib/es/locale/en-US.js +11 -1
- package/lib/es/locale/es-ES.js +11 -1
- package/lib/es/locale/fa-IR.js +11 -1
- package/lib/es/locale/fr-FR.js +11 -1
- package/lib/es/locale/id-ID.js +128 -0
- package/lib/es/locale/it-IT.js +128 -0
- package/lib/es/locale/ja-JP.js +11 -1
- package/lib/es/locale/ko-KR.js +11 -1
- package/lib/es/locale/pl-PL.js +128 -0
- package/lib/es/locale/pt-BR.js +128 -0
- package/lib/es/locale/ru-RU.js +11 -1
- package/lib/es/locale/sk-SK.js +11 -1
- package/lib/es/locale/vi-VN.js +11 -1
- package/lib/es/locale/zh-CN.js +11 -1
- package/lib/es/locale/zh-HK.js +128 -0
- package/lib/es/locale/zh-TW.js +11 -1
- package/lib/index.css +69 -53
- package/lib/index.js +958 -496
- package/lib/locale/ar-SA.js +128 -0
- package/lib/locale/ca-ES.js +11 -1
- package/lib/locale/de-DE.js +128 -0
- package/lib/locale/en-US.js +11 -1
- package/lib/locale/es-ES.js +11 -1
- package/lib/locale/fa-IR.js +11 -1
- package/lib/locale/fr-FR.js +11 -1
- package/lib/locale/id-ID.js +128 -0
- package/lib/locale/it-IT.js +128 -0
- package/lib/locale/ja-JP.js +11 -1
- package/lib/locale/ko-KR.js +11 -1
- package/lib/locale/pl-PL.js +128 -0
- package/lib/locale/pt-BR.js +128 -0
- package/lib/locale/ru-RU.js +11 -1
- package/lib/locale/sk-SK.js +11 -1
- package/lib/locale/vi-VN.js +11 -1
- package/lib/locale/zh-CN.js +11 -1
- package/lib/locale/zh-HK.js +128 -0
- package/lib/locale/zh-TW.js +11 -1
- package/lib/types/const.d.ts +2 -0
- package/lib/types/controllers/sheet-table-component.controller.d.ts +2 -0
- package/lib/types/controllers/sheet-table-controls-render.controller.d.ts +60 -0
- package/lib/types/controllers/sheet-table-filter-button-render.controller.d.ts +3 -2
- package/lib/types/{views/components/SheetTableAnchor.d.ts → locale/ar-SA.d.ts} +3 -1
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +11 -1
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/views/components/SheetTableRenameDialog.d.ts +21 -0
- package/lib/types/views/widgets/table-controls-util.d.ts +44 -0
- package/lib/types/views/widgets/table-controls.shape.d.ts +63 -0
- package/lib/types/views/widgets/table-filter-button.shape.d.ts +10 -5
- package/lib/umd/index.js +1 -1
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +13 -13
- package/LICENSE +0 -176
- package/lib/types/controllers/sheet-table-anchor.controller.d.ts +0 -50
- /package/lib/types/services/{sheets-table-ui-service.d.ts → sheets-table-ui.service.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -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 = "0.24.0-insiders.20260528-29f582d";
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/const.ts
|
|
@@ -40,6 +40,8 @@ const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = "SHEETS_TABLE_FILTER_PANEL_OPENED_K
|
|
|
40
40
|
const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
41
41
|
const TABLE_TOOLBAR_BUTTON = "TABLE_TOOLBAR_BUTTON";
|
|
42
42
|
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
43
|
+
const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
|
|
44
|
+
const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
43
45
|
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
44
46
|
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
45
47
|
const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
|
|
@@ -108,7 +110,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
//#endregion
|
|
111
|
-
//#region src/services/sheets-table-ui
|
|
113
|
+
//#region src/services/sheets-table-ui.service.ts
|
|
112
114
|
let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Disposable {
|
|
113
115
|
constructor(_tableManager, _sheetTableService, _univerInstanceService, _commandService, _localeService) {
|
|
114
116
|
super();
|
|
@@ -167,7 +169,7 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
167
169
|
const checkedItems = [];
|
|
168
170
|
if (table) {
|
|
169
171
|
const filter = table.getTableFilterColumn(columnIndex);
|
|
170
|
-
if (filter && (0, _univerjs_sheets_table.isManualTableFilter)(filter)) checkedItems.push(...filter.values);
|
|
172
|
+
if (filter && (0, _univerjs_sheets_table.isManualTableFilter)(filter)) checkedItems.push(...filter.values.map((value) => value === _univerjs_sheets_table.TABLE_FILTER_EMPTY_VALUE ? this._localeService.t("sheets-table-ui.condition.empty") : value));
|
|
171
173
|
}
|
|
172
174
|
return checkedItems;
|
|
173
175
|
}
|
|
@@ -194,7 +196,8 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
194
196
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
195
197
|
allItemsCount: 0
|
|
196
198
|
};
|
|
197
|
-
const
|
|
199
|
+
const tableRange = table.getTableFilterRange();
|
|
200
|
+
const { startRow, endRow, startColumn } = tableRange;
|
|
198
201
|
const column = startColumn + columnIndex;
|
|
199
202
|
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
200
203
|
if (!worksheet) return {
|
|
@@ -204,11 +207,17 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
204
207
|
};
|
|
205
208
|
const data = [];
|
|
206
209
|
const map = /* @__PURE__ */ new Map();
|
|
210
|
+
const filteredRowsByOtherColumns = /* @__PURE__ */ new Set();
|
|
211
|
+
const tableFilters = table.getTableFilters();
|
|
212
|
+
for (let i = tableRange.startColumn; i <= tableRange.endColumn; i++) {
|
|
213
|
+
const currentColumnIndex = i - tableRange.startColumn;
|
|
214
|
+
if (currentColumnIndex !== columnIndex && table.getTableFilterColumn(currentColumnIndex)) tableFilters.doColumnFilter(worksheet, tableRange, currentColumnIndex, filteredRowsByOtherColumns);
|
|
215
|
+
}
|
|
207
216
|
let allItemsCount = 0;
|
|
208
217
|
for (let row = startRow; row <= endRow; row++) {
|
|
209
|
-
if (
|
|
218
|
+
if (filteredRowsByOtherColumns.has(row)) continue;
|
|
210
219
|
let stringItem = this._sheetTableService.getCellValueWithConditionType(worksheet, row, column);
|
|
211
|
-
if (stringItem
|
|
220
|
+
if (stringItem == null) stringItem = this._localeService.t("sheets-table-ui.condition.empty");
|
|
212
221
|
if (!map.has(stringItem)) data.push({
|
|
213
222
|
title: stringItem,
|
|
214
223
|
key: `${column}_${row}`,
|
|
@@ -244,171 +253,171 @@ function getCascaderListOptions(injector) {
|
|
|
244
253
|
return [
|
|
245
254
|
{
|
|
246
255
|
value: _univerjs_sheets_table.TableConditionTypeEnum.String,
|
|
247
|
-
label: t(`sheets-table.condition.${_univerjs_sheets_table.TableConditionTypeEnum.String}`),
|
|
256
|
+
label: t(`sheets-table-ui.condition.${_univerjs_sheets_table.TableConditionTypeEnum.String}`),
|
|
248
257
|
children: [
|
|
249
258
|
{
|
|
250
259
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.Equal,
|
|
251
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.Equal}`)
|
|
260
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.Equal}`)
|
|
252
261
|
},
|
|
253
262
|
{
|
|
254
263
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.NotEqual,
|
|
255
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.NotEqual}`)
|
|
264
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.NotEqual}`)
|
|
256
265
|
},
|
|
257
266
|
{
|
|
258
267
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.Contains,
|
|
259
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.Contains}`)
|
|
268
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.Contains}`)
|
|
260
269
|
},
|
|
261
270
|
{
|
|
262
271
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.NotContains,
|
|
263
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.NotContains}`)
|
|
272
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.NotContains}`)
|
|
264
273
|
},
|
|
265
274
|
{
|
|
266
275
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.StartsWith,
|
|
267
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.StartsWith}`)
|
|
276
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.StartsWith}`)
|
|
268
277
|
},
|
|
269
278
|
{
|
|
270
279
|
value: _univerjs_sheets_table.TableStringCompareTypeEnum.EndsWith,
|
|
271
|
-
label: t(`sheets-table.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.EndsWith}`)
|
|
280
|
+
label: t(`sheets-table-ui.string.compare.${_univerjs_sheets_table.TableStringCompareTypeEnum.EndsWith}`)
|
|
272
281
|
}
|
|
273
282
|
]
|
|
274
283
|
},
|
|
275
284
|
{
|
|
276
285
|
value: _univerjs_sheets_table.TableConditionTypeEnum.Number,
|
|
277
|
-
label: t(`sheets-table.condition.${_univerjs_sheets_table.TableConditionTypeEnum.Number}`),
|
|
286
|
+
label: t(`sheets-table-ui.condition.${_univerjs_sheets_table.TableConditionTypeEnum.Number}`),
|
|
278
287
|
children: [
|
|
279
288
|
{
|
|
280
289
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.Equal,
|
|
281
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Equal}`)
|
|
290
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Equal}`)
|
|
282
291
|
},
|
|
283
292
|
{
|
|
284
293
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.NotEqual,
|
|
285
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.NotEqual}`)
|
|
294
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.NotEqual}`)
|
|
286
295
|
},
|
|
287
296
|
{
|
|
288
297
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThan,
|
|
289
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThan}`)
|
|
298
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThan}`)
|
|
290
299
|
},
|
|
291
300
|
{
|
|
292
301
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThanOrEqual,
|
|
293
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThanOrEqual}`)
|
|
302
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.GreaterThanOrEqual}`)
|
|
294
303
|
},
|
|
295
304
|
{
|
|
296
305
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.LessThan,
|
|
297
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.LessThan}`)
|
|
306
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.LessThan}`)
|
|
298
307
|
},
|
|
299
308
|
{
|
|
300
309
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.LessThanOrEqual,
|
|
301
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.LessThanOrEqual}`)
|
|
310
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.LessThanOrEqual}`)
|
|
302
311
|
},
|
|
303
312
|
{
|
|
304
313
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.Between,
|
|
305
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Between}`)
|
|
314
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Between}`)
|
|
306
315
|
},
|
|
307
316
|
{
|
|
308
317
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.NotBetween,
|
|
309
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.NotBetween}`)
|
|
318
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.NotBetween}`)
|
|
310
319
|
},
|
|
311
320
|
{
|
|
312
321
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.Above,
|
|
313
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Above}`)
|
|
322
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Above}`)
|
|
314
323
|
},
|
|
315
324
|
{
|
|
316
325
|
value: _univerjs_sheets_table.TableNumberCompareTypeEnum.Below,
|
|
317
|
-
label: t(`sheets-table.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Below}`)
|
|
326
|
+
label: t(`sheets-table-ui.number.compare.${_univerjs_sheets_table.TableNumberCompareTypeEnum.Below}`)
|
|
318
327
|
}
|
|
319
328
|
]
|
|
320
329
|
},
|
|
321
330
|
{
|
|
322
331
|
value: _univerjs_sheets_table.TableConditionTypeEnum.Date,
|
|
323
|
-
label: t(`sheets-table.condition.${_univerjs_sheets_table.TableConditionTypeEnum.Date}`),
|
|
332
|
+
label: t(`sheets-table-ui.condition.${_univerjs_sheets_table.TableConditionTypeEnum.Date}`),
|
|
324
333
|
children: [
|
|
325
334
|
{
|
|
326
335
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Equal,
|
|
327
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Equal}`)
|
|
336
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Equal}`)
|
|
328
337
|
},
|
|
329
338
|
{
|
|
330
339
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.NotEqual,
|
|
331
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NotEqual}`)
|
|
340
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NotEqual}`)
|
|
332
341
|
},
|
|
333
342
|
{
|
|
334
343
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.After,
|
|
335
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.After}`)
|
|
344
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.After}`)
|
|
336
345
|
},
|
|
337
346
|
{
|
|
338
347
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.AfterOrEqual,
|
|
339
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.AfterOrEqual}`)
|
|
348
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.AfterOrEqual}`)
|
|
340
349
|
},
|
|
341
350
|
{
|
|
342
351
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Before,
|
|
343
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Before}`)
|
|
352
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Before}`)
|
|
344
353
|
},
|
|
345
354
|
{
|
|
346
355
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.BeforeOrEqual,
|
|
347
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.BeforeOrEqual}`)
|
|
356
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.BeforeOrEqual}`)
|
|
348
357
|
},
|
|
349
358
|
{
|
|
350
359
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Between,
|
|
351
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Between}`)
|
|
360
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Between}`)
|
|
352
361
|
},
|
|
353
362
|
{
|
|
354
363
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.NotBetween,
|
|
355
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NotBetween}`)
|
|
364
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NotBetween}`)
|
|
356
365
|
},
|
|
357
366
|
{
|
|
358
367
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Today,
|
|
359
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Today}`)
|
|
368
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Today}`)
|
|
360
369
|
},
|
|
361
370
|
{
|
|
362
371
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Yesterday,
|
|
363
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Yesterday}`)
|
|
372
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Yesterday}`)
|
|
364
373
|
},
|
|
365
374
|
{
|
|
366
375
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Tomorrow,
|
|
367
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Tomorrow}`)
|
|
376
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Tomorrow}`)
|
|
368
377
|
},
|
|
369
378
|
{
|
|
370
379
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.ThisWeek,
|
|
371
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisWeek}`)
|
|
380
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisWeek}`)
|
|
372
381
|
},
|
|
373
382
|
{
|
|
374
383
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.LastWeek,
|
|
375
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastWeek}`)
|
|
384
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastWeek}`)
|
|
376
385
|
},
|
|
377
386
|
{
|
|
378
387
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.NextWeek,
|
|
379
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextWeek}`)
|
|
388
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextWeek}`)
|
|
380
389
|
},
|
|
381
390
|
{
|
|
382
391
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.ThisMonth,
|
|
383
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisMonth}`)
|
|
392
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisMonth}`)
|
|
384
393
|
},
|
|
385
394
|
{
|
|
386
395
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.LastMonth,
|
|
387
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastMonth}`)
|
|
396
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastMonth}`)
|
|
388
397
|
},
|
|
389
398
|
{
|
|
390
399
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.NextMonth,
|
|
391
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextMonth}`)
|
|
400
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextMonth}`)
|
|
392
401
|
},
|
|
393
402
|
{
|
|
394
403
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.ThisYear,
|
|
395
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisYear}`)
|
|
404
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.ThisYear}`)
|
|
396
405
|
},
|
|
397
406
|
{
|
|
398
407
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.LastYear,
|
|
399
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastYear}`)
|
|
408
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.LastYear}`)
|
|
400
409
|
},
|
|
401
410
|
{
|
|
402
411
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.NextYear,
|
|
403
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextYear}`)
|
|
412
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.NextYear}`)
|
|
404
413
|
},
|
|
405
414
|
{
|
|
406
415
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Quarter,
|
|
407
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Quarter}`)
|
|
416
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Quarter}`)
|
|
408
417
|
},
|
|
409
418
|
{
|
|
410
419
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Month,
|
|
411
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Month}`)
|
|
420
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Month}`)
|
|
412
421
|
}
|
|
413
422
|
]
|
|
414
423
|
}
|
|
@@ -421,69 +430,69 @@ function getConditionDateSelect(injector, dateType) {
|
|
|
421
430
|
case _univerjs_sheets_table.TableDateCompareTypeEnum.Quarter: return [
|
|
422
431
|
{
|
|
423
432
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Q1,
|
|
424
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q1}`)
|
|
433
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q1}`)
|
|
425
434
|
},
|
|
426
435
|
{
|
|
427
436
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Q2,
|
|
428
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q2}`)
|
|
437
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q2}`)
|
|
429
438
|
},
|
|
430
439
|
{
|
|
431
440
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Q3,
|
|
432
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q3}`)
|
|
441
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q3}`)
|
|
433
442
|
},
|
|
434
443
|
{
|
|
435
444
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.Q4,
|
|
436
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q4}`)
|
|
445
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.Q4}`)
|
|
437
446
|
}
|
|
438
447
|
];
|
|
439
448
|
case _univerjs_sheets_table.TableDateCompareTypeEnum.Month: return [
|
|
440
449
|
{
|
|
441
450
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M1,
|
|
442
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M1}`)
|
|
451
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M1}`)
|
|
443
452
|
},
|
|
444
453
|
{
|
|
445
454
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M2,
|
|
446
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M2}`)
|
|
455
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M2}`)
|
|
447
456
|
},
|
|
448
457
|
{
|
|
449
458
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M3,
|
|
450
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M3}`)
|
|
459
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M3}`)
|
|
451
460
|
},
|
|
452
461
|
{
|
|
453
462
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M4,
|
|
454
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M4}`)
|
|
463
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M4}`)
|
|
455
464
|
},
|
|
456
465
|
{
|
|
457
466
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M5,
|
|
458
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M5}`)
|
|
467
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M5}`)
|
|
459
468
|
},
|
|
460
469
|
{
|
|
461
470
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M6,
|
|
462
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M6}`)
|
|
471
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M6}`)
|
|
463
472
|
},
|
|
464
473
|
{
|
|
465
474
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M7,
|
|
466
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M7}`)
|
|
475
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M7}`)
|
|
467
476
|
},
|
|
468
477
|
{
|
|
469
478
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M8,
|
|
470
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M8}`)
|
|
479
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M8}`)
|
|
471
480
|
},
|
|
472
481
|
{
|
|
473
482
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M9,
|
|
474
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M9}`)
|
|
483
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M9}`)
|
|
475
484
|
},
|
|
476
485
|
{
|
|
477
486
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M10,
|
|
478
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M10}`)
|
|
487
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M10}`)
|
|
479
488
|
},
|
|
480
489
|
{
|
|
481
490
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M11,
|
|
482
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M11}`)
|
|
491
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M11}`)
|
|
483
492
|
},
|
|
484
493
|
{
|
|
485
494
|
value: _univerjs_sheets_table.TableDateCompareTypeEnum.M12,
|
|
486
|
-
label: t(`sheets-table.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M12}`)
|
|
495
|
+
label: t(`sheets-table-ui.date.compare.${_univerjs_sheets_table.TableDateCompareTypeEnum.M12}`)
|
|
487
496
|
}
|
|
488
497
|
];
|
|
489
498
|
default: return [];
|
|
@@ -611,8 +620,8 @@ const SheetTableConditionPanel = (props) => {
|
|
|
611
620
|
};
|
|
612
621
|
const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);
|
|
613
622
|
let selectType = "";
|
|
614
|
-
if (conditionInfo.compare) selectType = `${localeService.t(`sheets-table.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;
|
|
615
|
-
else selectType = localeService.t(`sheets-table.condition.${conditionInfo.type}`);
|
|
623
|
+
if (conditionInfo.compare) selectType = `${localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table-ui.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;
|
|
624
|
+
else selectType = localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`);
|
|
616
625
|
const conditionDateOptions = getConditionDateSelect(injector, conditionInfo.compare);
|
|
617
626
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
618
627
|
align: "start",
|
|
@@ -774,17 +783,19 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
774
783
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
775
784
|
autoFocus: true,
|
|
776
785
|
value: searchText,
|
|
777
|
-
placeholder: localeService.t("sheets-table.filter.search-placeholder"),
|
|
786
|
+
placeholder: localeService.t("sheets-table-ui.filter.search-placeholder"),
|
|
778
787
|
onChange: onSearchValueChange
|
|
779
788
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
780
789
|
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-box-border univer-flex univer-h-[180px] univer-max-h-[180px] univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-pl-2", _univerjs_design.borderClassName),
|
|
781
790
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
782
|
-
className: (0, _univerjs_design.clsx)("univer-h-40 univer-overflow-y-auto univer-py-1 univer-pl-2", _univerjs_design.scrollbarClassName),
|
|
791
|
+
className: (0, _univerjs_design.clsx)("univer-h-40 univer-min-w-0 univer-overflow-y-auto univer-py-1 univer-pl-2", _univerjs_design.scrollbarClassName),
|
|
783
792
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
784
793
|
className: "univer-h-full",
|
|
785
794
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
786
795
|
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
787
796
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
797
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
798
|
+
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
788
799
|
indeterminate,
|
|
789
800
|
disabled: items.length === 0,
|
|
790
801
|
checked: allChecked,
|
|
@@ -792,8 +803,8 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
792
803
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
793
804
|
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
794
805
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
795
|
-
className: "univer-
|
|
796
|
-
children: `${localeService.t("sheets-table.filter.select-all")}`
|
|
806
|
+
className: "univer-flex-1 univer-truncate",
|
|
807
|
+
children: `${localeService.t("sheets-table-ui.filter.select-all")}`
|
|
797
808
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
798
809
|
className: "univer-ml univer-text-gray-400",
|
|
799
810
|
children: `(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`
|
|
@@ -804,17 +815,19 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
804
815
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
805
816
|
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
806
817
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
818
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
819
|
+
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
807
820
|
checked: allChecked || checkedItemSet.has(item.title),
|
|
808
821
|
onChange: () => {
|
|
809
822
|
onCheckItemToggled(item.title);
|
|
810
823
|
},
|
|
811
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("
|
|
812
|
-
className: "univer-flex univer-h-5 univer-flex-1 univer-text-sm",
|
|
824
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
825
|
+
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
813
826
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
814
|
-
className: "univer-
|
|
827
|
+
className: "univer-flex-1 univer-truncate",
|
|
815
828
|
children: item.title
|
|
816
829
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
817
|
-
className: "univer-ml-1 univer-text-gray-400",
|
|
830
|
+
className: "univer-ml-1 univer-inline-flex univer-h-full univer-items-center univer-text-gray-400",
|
|
818
831
|
children: `(${itemsCountMap.get(item.title) || 0})`
|
|
819
832
|
})]
|
|
820
833
|
})
|
|
@@ -852,9 +865,12 @@ function SheetTableFilterPanel() {
|
|
|
852
865
|
const table = tableManager.getTable(unitId, tableId);
|
|
853
866
|
if (!table) return null;
|
|
854
867
|
const tableFilters = table.getTableFilters();
|
|
868
|
+
const tableRange = table.getRange();
|
|
855
869
|
const sortState = tableFilters.getSortState();
|
|
856
870
|
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Asc);
|
|
857
871
|
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Desc);
|
|
872
|
+
const absoluteColumn = tableFilterPanelInfo.column;
|
|
873
|
+
const canDeleteColumn = tableRange.endColumn > tableRange.startColumn;
|
|
858
874
|
const closeDialog = () => {
|
|
859
875
|
sheetsTableComponentController.closeFilterPanel();
|
|
860
876
|
};
|
|
@@ -876,10 +892,32 @@ function SheetTableFilterPanel() {
|
|
|
876
892
|
tableFilters.setSortState(columnIndex, asc ? _univerjs_sheets_table.SheetsTableSortStateEnum.Asc : _univerjs_sheets_table.SheetsTableSortStateEnum.Desc);
|
|
877
893
|
closeDialog();
|
|
878
894
|
};
|
|
895
|
+
const insertColumn = (side) => {
|
|
896
|
+
commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
897
|
+
unitId,
|
|
898
|
+
subUnitId,
|
|
899
|
+
tableId,
|
|
900
|
+
index: side === "left" ? absoluteColumn : absoluteColumn + 1,
|
|
901
|
+
count: 1
|
|
902
|
+
});
|
|
903
|
+
closeDialog();
|
|
904
|
+
};
|
|
905
|
+
const deleteColumn = () => {
|
|
906
|
+
if (!canDeleteColumn) return;
|
|
907
|
+
commandService.executeCommand(_univerjs_sheets_table.SheetTableRemoveColumnAtCommand.id, {
|
|
908
|
+
unitId,
|
|
909
|
+
subUnitId,
|
|
910
|
+
tableId,
|
|
911
|
+
index: absoluteColumn,
|
|
912
|
+
count: 1
|
|
913
|
+
});
|
|
914
|
+
closeDialog();
|
|
915
|
+
};
|
|
879
916
|
const onApply = () => {
|
|
880
917
|
if (filterBy === "items") {
|
|
881
918
|
const filteredItems = [];
|
|
882
|
-
|
|
919
|
+
const emptyLabel = localeService.t("sheets-table-ui.condition.empty");
|
|
920
|
+
for (const itemInfo of data) if (checkedItemSet.has(itemInfo.title)) filteredItems.push(itemInfo.title === emptyLabel ? _univerjs_sheets_table.TABLE_FILTER_EMPTY_VALUE : itemInfo.title);
|
|
883
921
|
const originFilter = table.getTableFilterColumn(columnIndex);
|
|
884
922
|
if (originFilter) {
|
|
885
923
|
if (originFilter.values.join(",") === filteredItems.join(",")) {
|
|
@@ -920,23 +958,55 @@ function SheetTableFilterPanel() {
|
|
|
920
958
|
};
|
|
921
959
|
const workbookEditableId = new _univerjs_sheets.WorkbookEditablePermission(unitId).id;
|
|
922
960
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
923
|
-
className: "univer-box-border univer-flex univer-
|
|
961
|
+
className: "univer-box-border univer-flex univer-w-[400px] univer-flex-col univer-rounded-[10px] univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
924
962
|
children: [
|
|
925
|
-
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
963
|
+
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
964
|
+
className: "-univer-mx-4 -univer-mt-2 univer-mb-3 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-py-1",
|
|
965
|
+
children: [
|
|
966
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
967
|
+
type: "button",
|
|
968
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
|
|
969
|
+
onClick: () => insertColumn("left"),
|
|
970
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftInsertColumnDoubleIcon, {
|
|
971
|
+
className: "univer-size-5",
|
|
972
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
973
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.insert-left") })]
|
|
974
|
+
}),
|
|
975
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
976
|
+
type: "button",
|
|
977
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
|
|
978
|
+
onClick: () => insertColumn("right"),
|
|
979
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightInsertColumnDoubleIcon, {
|
|
980
|
+
className: "univer-size-5",
|
|
981
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
982
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.insert-right") })]
|
|
983
|
+
}),
|
|
984
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
985
|
+
type: "button",
|
|
986
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-white dark:hover:!univer-bg-gray-600",
|
|
987
|
+
disabled: !canDeleteColumn,
|
|
988
|
+
onClick: deleteColumn,
|
|
989
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteColumnDoubleIcon, {
|
|
990
|
+
className: "univer-size-5",
|
|
991
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
992
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.delete") })]
|
|
993
|
+
})
|
|
994
|
+
]
|
|
995
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
926
996
|
className: "univer-mb-3 univer-flex",
|
|
927
997
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.ButtonGroup, {
|
|
928
998
|
className: "univer-mb-3 !univer-flex univer-w-full",
|
|
929
999
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
930
1000
|
className: "univer-w-1/2",
|
|
931
1001
|
onClick: () => applySort(true),
|
|
932
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AscendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.
|
|
1002
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AscendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-asc")]
|
|
933
1003
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
934
1004
|
className: "univer-w-1/2",
|
|
935
1005
|
onClick: () => applySort(false),
|
|
936
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.
|
|
1006
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-desc")]
|
|
937
1007
|
})]
|
|
938
1008
|
})
|
|
939
|
-
}),
|
|
1009
|
+
})] }),
|
|
940
1010
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
941
1011
|
className: "univer-w-full",
|
|
942
1012
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
|
|
@@ -973,15 +1043,15 @@ function SheetTableFilterPanel() {
|
|
|
973
1043
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
974
1044
|
disabled: tableFilter === void 0,
|
|
975
1045
|
onClick: onClearFilter,
|
|
976
|
-
children: localeService.t("sheets-table.filter.clear-filter")
|
|
1046
|
+
children: localeService.t("sheets-table-ui.filter.clear-filter")
|
|
977
1047
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
978
1048
|
className: "univer-mr-2",
|
|
979
1049
|
onClick: onCancel,
|
|
980
|
-
children: localeService.t("sheets-table.filter.cancel")
|
|
1050
|
+
children: localeService.t("sheets-table-ui.filter.cancel")
|
|
981
1051
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
982
1052
|
variant: "primary",
|
|
983
1053
|
onClick: onApply,
|
|
984
|
-
children: localeService.t("sheets-table.filter.confirm")
|
|
1054
|
+
children: localeService.t("sheets-table-ui.filter.confirm")
|
|
985
1055
|
})] })]
|
|
986
1056
|
})
|
|
987
1057
|
]
|
|
@@ -989,14 +1059,97 @@ function SheetTableFilterPanel() {
|
|
|
989
1059
|
}
|
|
990
1060
|
function useFilterByOptions(localeService) {
|
|
991
1061
|
return (0, react.useMemo)(() => [{
|
|
992
|
-
label: localeService.t("sheets-table.filter.by-values"),
|
|
1062
|
+
label: localeService.t("sheets-table-ui.filter.by-values"),
|
|
993
1063
|
value: "items"
|
|
994
1064
|
}, {
|
|
995
|
-
label: localeService.t("sheets-table.filter.by-conditions"),
|
|
1065
|
+
label: localeService.t("sheets-table-ui.filter.by-conditions"),
|
|
996
1066
|
value: "condition"
|
|
997
1067
|
}], [localeService.getCurrentLocale(), localeService]);
|
|
998
1068
|
}
|
|
999
1069
|
|
|
1070
|
+
//#endregion
|
|
1071
|
+
//#region src/views/components/SheetTableRenameDialog.tsx
|
|
1072
|
+
function SheetTableRenameDialog(props) {
|
|
1073
|
+
var _table$getDisplayName;
|
|
1074
|
+
const { unitId, tableId, onClose } = props;
|
|
1075
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1076
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1077
|
+
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1078
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
1079
|
+
const definedNamesService = (0, _univerjs_ui.useDependency)(_univerjs_engine_formula.IDefinedNamesService);
|
|
1080
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1081
|
+
const [value, setValue] = (0, react.useState)((_table$getDisplayName = table === null || table === void 0 ? void 0 : table.getDisplayName()) !== null && _table$getDisplayName !== void 0 ? _table$getDisplayName : "");
|
|
1082
|
+
const [error, setError] = (0, react.useState)("");
|
|
1083
|
+
const existingNames = (0, react.useMemo)(() => {
|
|
1084
|
+
const names = (0, _univerjs_sheets_table.getExistingNamesSet)(unitId, {
|
|
1085
|
+
univerInstanceService,
|
|
1086
|
+
tableManager,
|
|
1087
|
+
definedNamesService
|
|
1088
|
+
});
|
|
1089
|
+
const currentName = table === null || table === void 0 ? void 0 : table.getDisplayName().toLowerCase();
|
|
1090
|
+
if (currentName) names.delete(currentName);
|
|
1091
|
+
return names;
|
|
1092
|
+
}, [
|
|
1093
|
+
definedNamesService,
|
|
1094
|
+
table,
|
|
1095
|
+
tableManager,
|
|
1096
|
+
unitId,
|
|
1097
|
+
univerInstanceService
|
|
1098
|
+
]);
|
|
1099
|
+
const handleConfirm = () => {
|
|
1100
|
+
const nextName = value.trim();
|
|
1101
|
+
if (!table || nextName === table.getDisplayName()) {
|
|
1102
|
+
onClose();
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
if (!(0, _univerjs_sheets_table.validateSheetTableName)(nextName, existingNames).valid) {
|
|
1106
|
+
setError(localeService.t("sheets-table-ui.tableNameError"));
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1110
|
+
unitId,
|
|
1111
|
+
tableId,
|
|
1112
|
+
name: nextName
|
|
1113
|
+
});
|
|
1114
|
+
onClose();
|
|
1115
|
+
};
|
|
1116
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1117
|
+
className: "univer-box-border univer-flex univer-w-full univer-flex-col univer-gap-4 univer-pb-3 univer-pt-2",
|
|
1118
|
+
children: [
|
|
1119
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1120
|
+
size: "middle",
|
|
1121
|
+
value,
|
|
1122
|
+
placeholder: localeService.t("sheets-table-ui.renamePlaceholder"),
|
|
1123
|
+
onChange: (nextValue) => {
|
|
1124
|
+
setValue(nextValue);
|
|
1125
|
+
setError("");
|
|
1126
|
+
},
|
|
1127
|
+
onKeyDown: (event) => {
|
|
1128
|
+
if (event.key === "Enter") handleConfirm();
|
|
1129
|
+
},
|
|
1130
|
+
autoFocus: true
|
|
1131
|
+
}),
|
|
1132
|
+
error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1133
|
+
className: "-univer-mt-2 univer-text-sm univer-text-red-500",
|
|
1134
|
+
children: error
|
|
1135
|
+
}) : null,
|
|
1136
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1137
|
+
className: "univer-flex univer-w-full univer-items-center univer-justify-end univer-gap-2",
|
|
1138
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1139
|
+
className: "univer-min-w-16",
|
|
1140
|
+
onClick: onClose,
|
|
1141
|
+
children: localeService.t("sheets-table-ui.cancel")
|
|
1142
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1143
|
+
className: "univer-min-w-16",
|
|
1144
|
+
variant: "primary",
|
|
1145
|
+
onClick: handleConfirm,
|
|
1146
|
+
children: localeService.t("sheets-table-ui.confirm")
|
|
1147
|
+
})]
|
|
1148
|
+
})
|
|
1149
|
+
]
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1000
1153
|
//#endregion
|
|
1001
1154
|
//#region src/controllers/sheet-table-component.controller.ts
|
|
1002
1155
|
let SheetsTableComponentController = class SheetsTableComponentController extends _univerjs_core.Disposable {
|
|
@@ -1014,6 +1167,22 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1014
1167
|
setCurrentTableFilterInfo(info) {
|
|
1015
1168
|
this._currentTableFilterInfo = info;
|
|
1016
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
|
+
}
|
|
1017
1186
|
clearCurrentTableFilterInfo() {
|
|
1018
1187
|
this._currentTableFilterInfo = null;
|
|
1019
1188
|
}
|
|
@@ -1021,7 +1190,7 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1021
1190
|
return this._currentTableFilterInfo;
|
|
1022
1191
|
}
|
|
1023
1192
|
_initComponents() {
|
|
1024
|
-
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel]].forEach(([key, comp]) => {
|
|
1193
|
+
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
|
|
1025
1194
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1026
1195
|
});
|
|
1027
1196
|
}
|
|
@@ -1050,11 +1219,14 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1050
1219
|
});
|
|
1051
1220
|
}
|
|
1052
1221
|
_closeFilterPopup() {
|
|
1053
|
-
var _this$
|
|
1054
|
-
(_this$
|
|
1222
|
+
var _this$_popupDisposabl2;
|
|
1223
|
+
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
1055
1224
|
this._popupDisposable = null;
|
|
1056
1225
|
this.clearCurrentTableFilterInfo();
|
|
1057
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
|
+
}
|
|
1058
1230
|
};
|
|
1059
1231
|
SheetsTableComponentController = __decorate([
|
|
1060
1232
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
@@ -1072,19 +1244,15 @@ const OpenTableFilterPanelOperation = {
|
|
|
1072
1244
|
if (!params) return false;
|
|
1073
1245
|
const { row, col, unitId, subUnitId, tableId } = params;
|
|
1074
1246
|
const tableManager = accessor.get(_univerjs_sheets_table.TableManager);
|
|
1075
|
-
const contextService = accessor.get(_univerjs_core.IContextService);
|
|
1076
1247
|
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
1077
1248
|
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
});
|
|
1086
|
-
contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1087
|
-
}
|
|
1249
|
+
sheetsTableComponentController.openOrToggleFilterPanel({
|
|
1250
|
+
unitId,
|
|
1251
|
+
subUnitId,
|
|
1252
|
+
row,
|
|
1253
|
+
tableId,
|
|
1254
|
+
column: col
|
|
1255
|
+
});
|
|
1088
1256
|
return true;
|
|
1089
1257
|
}
|
|
1090
1258
|
};
|
|
@@ -1139,7 +1307,7 @@ async function openRangeSelector(accessor, unitId, subUnitId, range, tableId) {
|
|
|
1139
1307
|
};
|
|
1140
1308
|
dialogService.open({
|
|
1141
1309
|
id: TABLE_SELECTOR_DIALOG,
|
|
1142
|
-
title: { title: localeService.t("sheets-table.selectRange") },
|
|
1310
|
+
title: { title: localeService.t("sheets-table-ui.selectRange") },
|
|
1143
1311
|
draggable: true,
|
|
1144
1312
|
destroyOnClose: true,
|
|
1145
1313
|
mask: false,
|
|
@@ -1166,6 +1334,296 @@ const defaultPluginConfig = {
|
|
|
1166
1334
|
anchorBackgroundColor: "rgb(134,139,156)"
|
|
1167
1335
|
};
|
|
1168
1336
|
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/views/widgets/table-controls-util.ts
|
|
1339
|
+
const TABLE_CONTROL_MENU_WIDTH = 168;
|
|
1340
|
+
const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
|
|
1341
|
+
const TABLE_CONTROL_MENU_ACTIONS = [
|
|
1342
|
+
"rename",
|
|
1343
|
+
"update-range",
|
|
1344
|
+
"set-theme",
|
|
1345
|
+
"delete"
|
|
1346
|
+
];
|
|
1347
|
+
function isPointInTableControlRegion(region, x, y) {
|
|
1348
|
+
return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
|
|
1349
|
+
}
|
|
1350
|
+
function hitTestTableControl(regions, x, y) {
|
|
1351
|
+
for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
|
|
1352
|
+
return null;
|
|
1353
|
+
}
|
|
1354
|
+
function buildTableMenuRegions(tableId, left, top) {
|
|
1355
|
+
return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
|
|
1356
|
+
type: "menu-item",
|
|
1357
|
+
tableId,
|
|
1358
|
+
action,
|
|
1359
|
+
left,
|
|
1360
|
+
top: top + index * 32,
|
|
1361
|
+
width: 168,
|
|
1362
|
+
height: 32
|
|
1363
|
+
}));
|
|
1364
|
+
}
|
|
1365
|
+
function buildCenteredPlusSegments(centerX, centerY, size) {
|
|
1366
|
+
const halfSize = size / 2;
|
|
1367
|
+
return [{
|
|
1368
|
+
fromX: centerX - halfSize,
|
|
1369
|
+
fromY: centerY,
|
|
1370
|
+
toX: centerX + halfSize,
|
|
1371
|
+
toY: centerY
|
|
1372
|
+
}, {
|
|
1373
|
+
fromX: centerX,
|
|
1374
|
+
fromY: centerY - halfSize,
|
|
1375
|
+
toX: centerX,
|
|
1376
|
+
toY: centerY + halfSize
|
|
1377
|
+
}];
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region src/views/widgets/table-controls.shape.ts
|
|
1382
|
+
const ANCHOR_MIN_WIDTH = 122;
|
|
1383
|
+
const ANCHOR_MAX_WIDTH = 240;
|
|
1384
|
+
const ANCHOR_PADDING_X = 12;
|
|
1385
|
+
const ANCHOR_TOGGLE_WIDTH = 30;
|
|
1386
|
+
const ANCHOR_OFFSET_Y = 0;
|
|
1387
|
+
const ANCHOR_BORDER = "rgba(0, 0, 0, 0.22)";
|
|
1388
|
+
const ANCHOR_DIVIDER = "rgba(0, 0, 0, 0.20)";
|
|
1389
|
+
const ANCHOR_TOGGLE_BG_ACTIVE = "rgba(0, 0, 0, 0.12)";
|
|
1390
|
+
const MENU_RADIUS = 8;
|
|
1391
|
+
const MENU_BORDER = "#d9dee7";
|
|
1392
|
+
const MENU_HOVER_BG = "#f1f3f4";
|
|
1393
|
+
const INSERT_BUTTON_VISUAL_SIZE = 18;
|
|
1394
|
+
const INSERT_BUTTON_PLUS_SIZE = 8;
|
|
1395
|
+
var SheetTableControlsShape = class extends _univerjs_engine_render.Shape {
|
|
1396
|
+
constructor(key, _getSkeleton) {
|
|
1397
|
+
super(key, {
|
|
1398
|
+
evented: true,
|
|
1399
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
1400
|
+
zIndex: 5001
|
|
1401
|
+
});
|
|
1402
|
+
this._getSkeleton = _getSkeleton;
|
|
1403
|
+
_defineProperty(this, "_items", []);
|
|
1404
|
+
_defineProperty(this, "_regions", []);
|
|
1405
|
+
_defineProperty(this, "_openedMenuTableId", null);
|
|
1406
|
+
_defineProperty(this, "_hoveredRegion", null);
|
|
1407
|
+
_defineProperty(this, "_hoveredInsertRegion", null);
|
|
1408
|
+
_defineProperty(this, "_menuLabels", {
|
|
1409
|
+
rename: "Rename table",
|
|
1410
|
+
"update-range": "Update range",
|
|
1411
|
+
"set-theme": "Set theme",
|
|
1412
|
+
delete: "Remove table"
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
setItems(items) {
|
|
1416
|
+
this._items = items;
|
|
1417
|
+
this.makeDirty(true);
|
|
1418
|
+
}
|
|
1419
|
+
setMenuLabels(labels) {
|
|
1420
|
+
this._menuLabels = labels;
|
|
1421
|
+
this.makeDirty(true);
|
|
1422
|
+
}
|
|
1423
|
+
setOpenedMenuTableId(tableId) {
|
|
1424
|
+
if (this._openedMenuTableId === tableId) return;
|
|
1425
|
+
this._openedMenuTableId = tableId;
|
|
1426
|
+
this.makeDirty(true);
|
|
1427
|
+
}
|
|
1428
|
+
getOpenedMenuTableId() {
|
|
1429
|
+
return this._openedMenuTableId;
|
|
1430
|
+
}
|
|
1431
|
+
setHoveredRegion(region) {
|
|
1432
|
+
if (this._hoveredRegion === region) return;
|
|
1433
|
+
this._hoveredRegion = region;
|
|
1434
|
+
this.makeDirty(true);
|
|
1435
|
+
}
|
|
1436
|
+
setHoveredInsertRegion(region) {
|
|
1437
|
+
if (this._hoveredInsertRegion === region) return;
|
|
1438
|
+
this._hoveredInsertRegion = region;
|
|
1439
|
+
this.makeDirty(true);
|
|
1440
|
+
}
|
|
1441
|
+
hitTest(x, y) {
|
|
1442
|
+
return hitTestTableControl(this._regions, x, y);
|
|
1443
|
+
}
|
|
1444
|
+
isHit(coord) {
|
|
1445
|
+
return this.hitTest(coord.x, coord.y) != null;
|
|
1446
|
+
}
|
|
1447
|
+
refreshBounds() {
|
|
1448
|
+
const skeleton = this._getSkeleton();
|
|
1449
|
+
if (!skeleton) {
|
|
1450
|
+
this.hide();
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
this.show();
|
|
1454
|
+
this.transformByState({
|
|
1455
|
+
left: 0,
|
|
1456
|
+
top: 0,
|
|
1457
|
+
width: skeleton.rowHeaderWidth + skeleton.columnTotalWidth,
|
|
1458
|
+
height: skeleton.columnHeaderHeight + skeleton.rowTotalHeight
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
_draw(ctx) {
|
|
1462
|
+
this._regions = [];
|
|
1463
|
+
const skeleton = this._getSkeleton();
|
|
1464
|
+
if (!skeleton) return;
|
|
1465
|
+
ctx.save();
|
|
1466
|
+
ctx.textBaseline = "middle";
|
|
1467
|
+
for (const item of this._items) this._drawAnchor(ctx, skeleton, item);
|
|
1468
|
+
if (this._hoveredInsertRegion) {
|
|
1469
|
+
var _item$fill;
|
|
1470
|
+
const item = this._items.find((renderItem) => {
|
|
1471
|
+
var _this$_hoveredInsertR;
|
|
1472
|
+
return renderItem.tableId === ((_this$_hoveredInsertR = this._hoveredInsertRegion) === null || _this$_hoveredInsertR === void 0 ? void 0 : _this$_hoveredInsertR.tableId);
|
|
1473
|
+
});
|
|
1474
|
+
this._drawInsertButton(ctx, this._hoveredInsertRegion, (_item$fill = item === null || item === void 0 ? void 0 : item.fill) !== null && _item$fill !== void 0 ? _item$fill : "#355bb7");
|
|
1475
|
+
this._regions.push(this._hoveredInsertRegion);
|
|
1476
|
+
}
|
|
1477
|
+
ctx.restore();
|
|
1478
|
+
}
|
|
1479
|
+
_drawAnchor(ctx, skeleton, item) {
|
|
1480
|
+
const position = skeleton.getNoMergeCellWithCoordByIndex(item.range.startRow, item.range.startColumn);
|
|
1481
|
+
const left = position.startX;
|
|
1482
|
+
const rawTop = position.startY - 28 - ANCHOR_OFFSET_Y;
|
|
1483
|
+
const top = Math.max(0, rawTop);
|
|
1484
|
+
const width = Math.max(ANCHOR_MIN_WIDTH, Math.min(ANCHOR_MAX_WIDTH, item.tableName.length * 8.5 + ANCHOR_PADDING_X * 2 + ANCHOR_TOGGLE_WIDTH));
|
|
1485
|
+
const toggleRegion = {
|
|
1486
|
+
type: "anchor-menu-toggle",
|
|
1487
|
+
tableId: item.tableId,
|
|
1488
|
+
left: left + width - ANCHOR_TOGGLE_WIDTH,
|
|
1489
|
+
top,
|
|
1490
|
+
width: ANCHOR_TOGGLE_WIDTH,
|
|
1491
|
+
height: 28
|
|
1492
|
+
};
|
|
1493
|
+
ctx.save();
|
|
1494
|
+
ctx.translateWithPrecision(left, top);
|
|
1495
|
+
this._drawTopRoundedRect(ctx, width, 28, 14, item.fill, ANCHOR_BORDER);
|
|
1496
|
+
this._drawAnchorToggle(ctx, width, item.text, this._openedMenuTableId === item.tableId || this._isSameRegion(this._hoveredRegion, toggleRegion));
|
|
1497
|
+
ctx.font = `600 13px ${_univerjs_engine_render.DEFAULT_FONTFACE_PLANE}`;
|
|
1498
|
+
ctx.fillStyle = item.text;
|
|
1499
|
+
ctx.textAlign = "left";
|
|
1500
|
+
ctx.fillText(item.tableName, ANCHOR_PADDING_X, 28 / 2);
|
|
1501
|
+
ctx.restore();
|
|
1502
|
+
this._regions.push({
|
|
1503
|
+
type: "anchor-main",
|
|
1504
|
+
tableId: item.tableId,
|
|
1505
|
+
left,
|
|
1506
|
+
top,
|
|
1507
|
+
width,
|
|
1508
|
+
height: 28
|
|
1509
|
+
});
|
|
1510
|
+
this._regions.push(toggleRegion);
|
|
1511
|
+
if (this._openedMenuTableId === item.tableId) this._drawMenu(ctx, item.tableId, left, top + 28);
|
|
1512
|
+
}
|
|
1513
|
+
_drawAnchorToggle(ctx, anchorWidth, color, active) {
|
|
1514
|
+
const toggleLeft = anchorWidth - ANCHOR_TOGGLE_WIDTH;
|
|
1515
|
+
if (active) this._drawRightTopRoundedRect(ctx, toggleLeft, anchorWidth, 28, 14, ANCHOR_TOGGLE_BG_ACTIVE);
|
|
1516
|
+
ctx.save();
|
|
1517
|
+
ctx.beginPath();
|
|
1518
|
+
ctx.strokeStyle = ANCHOR_DIVIDER;
|
|
1519
|
+
ctx.lineWidth = 1;
|
|
1520
|
+
ctx.moveTo(toggleLeft + .5, 5);
|
|
1521
|
+
ctx.lineTo(toggleLeft + .5, 28 - 5);
|
|
1522
|
+
ctx.stroke();
|
|
1523
|
+
ctx.restore();
|
|
1524
|
+
const centerX = anchorWidth - ANCHOR_TOGGLE_WIDTH / 2;
|
|
1525
|
+
const centerY = 28 / 2;
|
|
1526
|
+
ctx.save();
|
|
1527
|
+
ctx.beginPath();
|
|
1528
|
+
ctx.strokeStyle = color;
|
|
1529
|
+
ctx.lineWidth = 1.6;
|
|
1530
|
+
ctx.lineCap = "round";
|
|
1531
|
+
ctx.moveTo(centerX - 5, centerY - 4);
|
|
1532
|
+
ctx.lineTo(centerX + 5, centerY - 4);
|
|
1533
|
+
ctx.moveTo(centerX - 5, centerY);
|
|
1534
|
+
ctx.lineTo(centerX + 5, centerY);
|
|
1535
|
+
ctx.moveTo(centerX - 5, centerY + 4);
|
|
1536
|
+
ctx.lineTo(centerX + 5, centerY + 4);
|
|
1537
|
+
ctx.stroke();
|
|
1538
|
+
ctx.restore();
|
|
1539
|
+
}
|
|
1540
|
+
_drawTopRoundedRect(ctx, width, height, radius, fill, stroke) {
|
|
1541
|
+
const r = Math.min(radius, width / 2, height);
|
|
1542
|
+
ctx.beginPath();
|
|
1543
|
+
ctx.moveTo(0, height);
|
|
1544
|
+
ctx.lineTo(0, r);
|
|
1545
|
+
ctx.arcTo(0, 0, r, 0, r);
|
|
1546
|
+
ctx.lineTo(width - r, 0);
|
|
1547
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1548
|
+
ctx.lineTo(width, height);
|
|
1549
|
+
ctx.closePath();
|
|
1550
|
+
ctx.fillStyle = fill;
|
|
1551
|
+
ctx.fill();
|
|
1552
|
+
if (stroke) {
|
|
1553
|
+
ctx.strokeStyle = stroke;
|
|
1554
|
+
ctx.lineWidth = 1;
|
|
1555
|
+
ctx.stroke();
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
_drawRightTopRoundedRect(ctx, left, width, height, radius, fill) {
|
|
1559
|
+
const r = Math.min(radius, width - left, height);
|
|
1560
|
+
ctx.save();
|
|
1561
|
+
ctx.beginPath();
|
|
1562
|
+
ctx.moveTo(left, height);
|
|
1563
|
+
ctx.lineTo(left, 0);
|
|
1564
|
+
ctx.lineTo(width - r, 0);
|
|
1565
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1566
|
+
ctx.lineTo(width, height);
|
|
1567
|
+
ctx.closePath();
|
|
1568
|
+
ctx.fillStyle = fill;
|
|
1569
|
+
ctx.fill();
|
|
1570
|
+
ctx.restore();
|
|
1571
|
+
}
|
|
1572
|
+
_drawMenu(ctx, tableId, left, top) {
|
|
1573
|
+
const regions = buildTableMenuRegions(tableId, left, top);
|
|
1574
|
+
ctx.save();
|
|
1575
|
+
ctx.translateWithPrecision(left, top);
|
|
1576
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1577
|
+
width: 168,
|
|
1578
|
+
height: regions.length * 32,
|
|
1579
|
+
radius: MENU_RADIUS,
|
|
1580
|
+
fill: "#fff",
|
|
1581
|
+
stroke: MENU_BORDER
|
|
1582
|
+
});
|
|
1583
|
+
ctx.restore();
|
|
1584
|
+
for (const region of regions) {
|
|
1585
|
+
if (this._isSameRegion(this._hoveredRegion, region)) {
|
|
1586
|
+
ctx.save();
|
|
1587
|
+
ctx.fillStyle = MENU_HOVER_BG;
|
|
1588
|
+
ctx.fillRectByPrecision(region.left, region.top, region.width, region.height);
|
|
1589
|
+
ctx.restore();
|
|
1590
|
+
}
|
|
1591
|
+
ctx.save();
|
|
1592
|
+
ctx.font = `12px ${_univerjs_engine_render.DEFAULT_FONTFACE_PLANE}`;
|
|
1593
|
+
ctx.fillStyle = region.action === "delete" ? "#d92d20" : "#344054";
|
|
1594
|
+
ctx.textAlign = "left";
|
|
1595
|
+
ctx.fillText(this._menuLabels[region.action], region.left + 12, region.top + region.height / 2);
|
|
1596
|
+
ctx.restore();
|
|
1597
|
+
}
|
|
1598
|
+
this._regions.push(...regions);
|
|
1599
|
+
}
|
|
1600
|
+
_drawInsertButton(ctx, region, fill) {
|
|
1601
|
+
const centerX = region.left + region.width / 2;
|
|
1602
|
+
const centerY = region.top + region.height / 2;
|
|
1603
|
+
const radius = INSERT_BUTTON_VISUAL_SIZE / 2;
|
|
1604
|
+
ctx.save();
|
|
1605
|
+
ctx.beginPath();
|
|
1606
|
+
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
1607
|
+
ctx.fillStyle = "#fff";
|
|
1608
|
+
ctx.fill();
|
|
1609
|
+
ctx.strokeStyle = fill;
|
|
1610
|
+
ctx.stroke();
|
|
1611
|
+
ctx.beginPath();
|
|
1612
|
+
ctx.strokeStyle = fill;
|
|
1613
|
+
ctx.lineWidth = 1;
|
|
1614
|
+
ctx.lineCap = "round";
|
|
1615
|
+
for (const segment of buildCenteredPlusSegments(centerX, centerY, INSERT_BUTTON_PLUS_SIZE)) {
|
|
1616
|
+
ctx.moveTo(segment.fromX, segment.fromY);
|
|
1617
|
+
ctx.lineTo(segment.toX, segment.toY);
|
|
1618
|
+
}
|
|
1619
|
+
ctx.stroke();
|
|
1620
|
+
ctx.restore();
|
|
1621
|
+
}
|
|
1622
|
+
_isSameRegion(a, b) {
|
|
1623
|
+
return Boolean(a && a.type === b.type && a.tableId === b.tableId && a.action === b.action && a.index === b.index);
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1169
1627
|
//#endregion
|
|
1170
1628
|
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1171
1629
|
let SheetTableThemeUIController = class SheetTableThemeUIController extends _univerjs_core.Disposable {
|
|
@@ -1188,372 +1646,364 @@ let SheetTableThemeUIController = class SheetTableThemeUIController extends _uni
|
|
|
1188
1646
|
SheetTableThemeUIController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService))], SheetTableThemeUIController);
|
|
1189
1647
|
|
|
1190
1648
|
//#endregion
|
|
1191
|
-
//#region src/
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
1202
|
-
const workbookPermissionInitState = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(_univerjs_sheets.WorkbookPermissionService).unitPermissionInitStateChange$, false);
|
|
1203
|
-
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1204
|
-
const rangeThemeModel = (0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetRangeThemeModel);
|
|
1205
|
-
const tableRefresh$ = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(SheetTableThemeUIController).refreshTable$);
|
|
1206
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1207
|
-
const selections = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetsSelectionsService).selectionChanged$, [{
|
|
1208
|
-
range: (0, _univerjs_core.cellToRange)(0, 0),
|
|
1209
|
-
primary: null
|
|
1210
|
-
}]);
|
|
1211
|
-
const [, setRefresh] = (0, react.useState)(Math.random());
|
|
1212
|
-
const tableConfig = (0, _univerjs_ui.useDependency)(_univerjs_core.IConfigService).getConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
1213
|
-
const anchorHeight = (_tableConfig$anchorHe = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorHeight) !== null && _tableConfig$anchorHe !== void 0 ? _tableConfig$anchorHe : 24;
|
|
1214
|
-
const anchorBackgroundColor = (_tableConfig$anchorBa = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorBackgroundColor) !== null && _tableConfig$anchorBa !== void 0 ? _tableConfig$anchorBa : "rgb(53,91,183)";
|
|
1215
|
-
const updateOpenState = (tableId, isOpen) => {
|
|
1216
|
-
setOpenStates((prev) => ({
|
|
1217
|
-
...prev,
|
|
1218
|
-
[tableId]: isOpen
|
|
1219
|
-
}));
|
|
1220
|
-
};
|
|
1221
|
-
(0, react.useEffect)(() => {
|
|
1222
|
-
setRefresh(Math.random());
|
|
1223
|
-
}, [tableRefresh$]);
|
|
1224
|
-
if (!(anchorPosition === null || anchorPosition === void 0 ? void 0 : anchorPosition.length)) return null;
|
|
1225
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
1226
|
-
if (!target) return null;
|
|
1227
|
-
const { unitId, subUnitId } = target;
|
|
1228
|
-
const handleChangeTableName = (tableId, name) => {
|
|
1229
|
-
var _tableManager$getTabl;
|
|
1230
|
-
if (((_tableManager$getTabl = tableManager.getTableById(unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getDisplayName()) === name) {
|
|
1231
|
-
setInputFocusId("");
|
|
1232
|
-
setInputValue("");
|
|
1233
|
-
return;
|
|
1234
|
-
}
|
|
1235
|
-
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1236
|
-
tableId,
|
|
1237
|
-
unitId,
|
|
1238
|
-
name
|
|
1239
|
-
});
|
|
1240
|
-
setInputValue("");
|
|
1241
|
-
setInputFocusId("");
|
|
1242
|
-
};
|
|
1243
|
-
const handleChangeRange = async (tableId) => {
|
|
1244
|
-
const table = tableManager.getTableById(unitId, tableId);
|
|
1245
|
-
if (!table) return;
|
|
1246
|
-
const selection = await openRangeSelector(injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1247
|
-
if (!selection) return;
|
|
1248
|
-
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1249
|
-
tableId,
|
|
1250
|
-
unitId,
|
|
1251
|
-
updateRange: { newRange: selection.range }
|
|
1252
|
-
});
|
|
1253
|
-
};
|
|
1254
|
-
if (!workbookPermissionInitState) return null;
|
|
1255
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1256
|
-
className: "univer-absolute univer-z-50 univer-size-0",
|
|
1257
|
-
children: anchorPosition.map((item) => {
|
|
1258
|
-
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4, _openStates$item$tabl;
|
|
1259
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1260
|
-
if (!table) return null;
|
|
1261
|
-
const rangeTheme = rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1262
|
-
const headerBgColor = (_rangeTheme$getHeader = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.bg) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) !== null && _rangeTheme$getHeader !== void 0 ? _rangeTheme$getHeader : anchorBackgroundColor;
|
|
1263
|
-
const headerTextColor = (_rangeTheme$getHeader3 = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader4 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader4 === void 0 || (_rangeTheme$getHeader4 = _rangeTheme$getHeader4.cl) === null || _rangeTheme$getHeader4 === void 0 ? void 0 : _rangeTheme$getHeader4.rgb) !== null && _rangeTheme$getHeader3 !== void 0 ? _rangeTheme$getHeader3 : "rgb(255, 255, 255)";
|
|
1264
|
-
const tableRange = table.getRange();
|
|
1265
|
-
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return null;
|
|
1266
|
-
const lastRange = selections[selections.length - 1].range;
|
|
1267
|
-
const shouldHidden = !_univerjs_core.Rectangle.intersects(tableRange, lastRange) && item.y <= 20;
|
|
1268
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1269
|
-
className: (0, _univerjs_design.clsx)("univer-shadow-xs univer-absolute univer-box-border univer-cursor-pointer univer-items-center univer-rounded-xl univer-px-2", _univerjs_design.borderClassName, {
|
|
1270
|
-
"univer-flex": !shouldHidden,
|
|
1271
|
-
"univer-hidden": shouldHidden
|
|
1272
|
-
}),
|
|
1273
|
-
style: {
|
|
1274
|
-
left: item.x,
|
|
1275
|
-
top: Math.max(item.y, 0),
|
|
1276
|
-
backgroundColor: headerBgColor,
|
|
1277
|
-
color: headerTextColor,
|
|
1278
|
-
borderWidth: "0.5px",
|
|
1279
|
-
height: anchorHeight ? `${anchorHeight}px` : "24px"
|
|
1280
|
-
},
|
|
1281
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1282
|
-
className: "univer-text-nowrap",
|
|
1283
|
-
children: inputFocusId === item.tableId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1284
|
-
className: "univer-h-[18px] univer-min-w-16 univer-rounded-none",
|
|
1285
|
-
inputClass: "univer-h-[18px] univer-w-[80px]",
|
|
1286
|
-
value: inputValue,
|
|
1287
|
-
onChange: (v) => setInputValue(v),
|
|
1288
|
-
onBlur: () => handleChangeTableName(item.tableId, inputValue),
|
|
1289
|
-
onKeyDown: (e) => {
|
|
1290
|
-
if (e.key === "Enter") handleChangeTableName(item.tableId, inputValue);
|
|
1291
|
-
},
|
|
1292
|
-
autoFocus: inputFocusId === item.tableId
|
|
1293
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1294
|
-
className: "univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm",
|
|
1295
|
-
children: item.tableName
|
|
1296
|
-
})
|
|
1297
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
1298
|
-
align: "start",
|
|
1299
|
-
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1300
|
-
className: "univer-py-2",
|
|
1301
|
-
children: [
|
|
1302
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1303
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1304
|
-
onClick: () => {
|
|
1305
|
-
setInputFocusId(item.tableId);
|
|
1306
|
-
setInputValue(item.tableName);
|
|
1307
|
-
},
|
|
1308
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RenameIcon, {}), localeService.t("sheets-table.rename")]
|
|
1309
|
-
}),
|
|
1310
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1311
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1312
|
-
onClick: () => handleChangeRange(item.tableId),
|
|
1313
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1314
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.GridOutlineIcon, {}), localeService.t("sheets-table.updateRange")]
|
|
1315
|
-
}),
|
|
1316
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1317
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1318
|
-
onClick: () => {
|
|
1319
|
-
updateOpenState(item.tableId, false);
|
|
1320
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1321
|
-
if (!table) return;
|
|
1322
|
-
const tableConfig = table.getTableConfig();
|
|
1323
|
-
const sidebarConfig = {
|
|
1324
|
-
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1325
|
-
header: { title: localeService.t("sheets-table.tableStyle") },
|
|
1326
|
-
children: {
|
|
1327
|
-
label: SHEET_TABLE_THEME_PANEL,
|
|
1328
|
-
oldConfig: tableConfig,
|
|
1329
|
-
unitId,
|
|
1330
|
-
subUnitId,
|
|
1331
|
-
tableId: item.tableId
|
|
1332
|
-
},
|
|
1333
|
-
width: 330
|
|
1334
|
-
};
|
|
1335
|
-
sidebarService.open(sidebarConfig);
|
|
1336
|
-
},
|
|
1337
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.PaintBucketDoubleIcon, { extend: { colorChannel1: "rgb(53,91,183)" } }), localeService.t("sheets-table.setTheme")]
|
|
1338
|
-
}),
|
|
1339
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1340
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1341
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1342
|
-
onClick: () => {
|
|
1343
|
-
updateOpenState(item.tableId, false);
|
|
1344
|
-
commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, {
|
|
1345
|
-
tableId: item.tableId,
|
|
1346
|
-
subUnitId,
|
|
1347
|
-
unitId
|
|
1348
|
-
});
|
|
1349
|
-
},
|
|
1350
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, { className: "univer-mr-2" }), localeService.t("sheets-table.removeTable")]
|
|
1351
|
-
})
|
|
1352
|
-
]
|
|
1353
|
-
}),
|
|
1354
|
-
open: (_openStates$item$tabl = openStates[item.tableId]) !== null && _openStates$item$tabl !== void 0 ? _openStates$item$tabl : false,
|
|
1355
|
-
onOpenChange: (isOpen) => {
|
|
1356
|
-
updateOpenState(item.tableId, isOpen);
|
|
1357
|
-
},
|
|
1358
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {}) })
|
|
1359
|
-
}, item.tableId)]
|
|
1360
|
-
}, item.tableId);
|
|
1361
|
-
})
|
|
1362
|
-
});
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1365
|
-
//#endregion
|
|
1366
|
-
//#region src/controllers/sheet-table-anchor.controller.ts
|
|
1367
|
-
let SheetTableAnchorController = class SheetTableAnchorController extends _univerjs_core.Disposable {
|
|
1368
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _renderManagerService, _commandService, _univerInstanceService, _uiPartsService, _tableManager, _scrollManagerService, _workbookPermissionService, _permissionService) {
|
|
1649
|
+
//#region src/controllers/sheet-table-controls-render.controller.ts
|
|
1650
|
+
const TABLE_CONTROLS_LAYER_INDEX = 5002;
|
|
1651
|
+
const TABLE_CONTROL_GAP_ROW = 0;
|
|
1652
|
+
const TABLE_RENDER_REFRESH_COMMANDS = new Set([_univerjs_sheets_ui.SetScrollOperation.id, _univerjs_sheets_ui.SetZoomRatioOperation.id]);
|
|
1653
|
+
function isSameTopGap(left, right) {
|
|
1654
|
+
if (left === null || right === null) return left === right;
|
|
1655
|
+
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
1656
|
+
}
|
|
1657
|
+
let SheetTableControlsRenderController = class SheetTableControlsRenderController extends _univerjs_core.Disposable {
|
|
1658
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService) {
|
|
1369
1659
|
super();
|
|
1370
1660
|
this._context = _context;
|
|
1371
1661
|
this._injector = _injector;
|
|
1372
1662
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1373
|
-
this._renderManagerService = _renderManagerService;
|
|
1374
1663
|
this._commandService = _commandService;
|
|
1375
|
-
this._univerInstanceService = _univerInstanceService;
|
|
1376
|
-
this._uiPartsService = _uiPartsService;
|
|
1377
1664
|
this._tableManager = _tableManager;
|
|
1378
|
-
this.
|
|
1665
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1379
1666
|
this._workbookPermissionService = _workbookPermissionService;
|
|
1380
1667
|
this._permissionService = _permissionService;
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
this.
|
|
1386
|
-
this.
|
|
1387
|
-
this
|
|
1668
|
+
this._sheetsSelectionsService = _sheetsSelectionsService;
|
|
1669
|
+
this._selectionRenderService = _selectionRenderService;
|
|
1670
|
+
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
1671
|
+
this._localeService = _localeService;
|
|
1672
|
+
this._dialogService = _dialogService;
|
|
1673
|
+
this._sidebarService = _sidebarService;
|
|
1674
|
+
_defineProperty(this, "_shape", void 0);
|
|
1675
|
+
_defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
|
|
1676
|
+
this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
|
|
1677
|
+
this._initShape();
|
|
1678
|
+
this._initRefresh();
|
|
1679
|
+
this._refresh();
|
|
1388
1680
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1681
|
+
_initShape() {
|
|
1682
|
+
var _this$_context$compon, _this$_context$compon2;
|
|
1683
|
+
this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
|
|
1684
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(() => {
|
|
1685
|
+
this._context.scene.removeObjects([this._shape]);
|
|
1686
|
+
}));
|
|
1687
|
+
this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
|
|
1688
|
+
this._handlePointerMove(evt, state);
|
|
1689
|
+
}));
|
|
1690
|
+
this.disposeWithMe(this._shape.onPointerLeave$.subscribeEvent((_evt, state) => {
|
|
1691
|
+
this._handlePointerLeave(state);
|
|
1692
|
+
}));
|
|
1693
|
+
this.disposeWithMe(this._shape.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1694
|
+
this._handlePointerDown(evt, state);
|
|
1695
|
+
}));
|
|
1696
|
+
this.disposeWithMe((_this$_context$compon = (_this$_context$compon2 = this._context.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.MAIN)) === null || _this$_context$compon2 === void 0 ? void 0 : _this$_context$compon2.onPointerMove$.subscribeEvent((evt) => {
|
|
1697
|
+
const point = this._getLocalPoint(evt);
|
|
1698
|
+
const insertRegion = this._getInsertRegionFromPoint(point.x, point.y);
|
|
1699
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1700
|
+
})) !== null && _this$_context$compon !== void 0 ? _this$_context$compon : (0, _univerjs_core.toDisposable)(() => {}));
|
|
1391
1701
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
if (command.
|
|
1395
|
-
this.
|
|
1396
|
-
|
|
1397
|
-
this._timer = setTimeout(() => {
|
|
1398
|
-
this._anchorVisible$.next(true);
|
|
1399
|
-
}, 300);
|
|
1702
|
+
_initRefresh() {
|
|
1703
|
+
const commandExecuted$ = (0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
|
|
1704
|
+
if (command.type === _univerjs_core.CommandType.OPERATION && TABLE_RENDER_REFRESH_COMMANDS.has(command.id)) {
|
|
1705
|
+
this._closeFloatingControls();
|
|
1706
|
+
return true;
|
|
1400
1707
|
}
|
|
1708
|
+
return command.type === _univerjs_core.CommandType.MUTATION || command.type === _univerjs_core.CommandType.COMMAND;
|
|
1709
|
+
}));
|
|
1710
|
+
this.disposeWithMe((0, rxjs.merge)(this._context.unit.activeSheet$, this._sheetSkeletonManagerService.currentSkeleton$, this._tableManager.tableAdd$, this._tableManager.tableDelete$, this._tableManager.tableNameChanged$, this._tableManager.tableRangeChanged$, this._tableManager.tableThemeChanged$, this._sheetTableThemeUIController.refreshTable$, this._workbookPermissionService.unitPermissionInitStateChange$, this._permissionService.permissionPointUpdate$, this._sheetsSelectionsService.selectionChanged$, commandExecuted$).subscribe(() => {
|
|
1711
|
+
this._closeFloatingControls();
|
|
1712
|
+
this._refresh();
|
|
1401
1713
|
}));
|
|
1402
1714
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1715
|
+
_refresh() {
|
|
1716
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1717
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1718
|
+
if (!skeleton || !worksheet || !this._canEditWorkbook()) {
|
|
1719
|
+
this._shape.setItems([]);
|
|
1720
|
+
this._shape.refreshBounds();
|
|
1721
|
+
this._context.scene.makeDirty();
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
this._syncTopTableGap(skeleton);
|
|
1725
|
+
this._shape.setMenuLabels({
|
|
1726
|
+
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
1727
|
+
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
1728
|
+
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
1729
|
+
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
1730
|
+
});
|
|
1731
|
+
const unitId = this._context.unit.getUnitId();
|
|
1732
|
+
const subUnitId = worksheet.getSheetId();
|
|
1733
|
+
const items = this._tableManager.getTablesBySubunitId(unitId, subUnitId).map((table) => {
|
|
1734
|
+
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4;
|
|
1735
|
+
const rangeTheme = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1736
|
+
return {
|
|
1737
|
+
tableId: table.getId(),
|
|
1738
|
+
tableName: table.getDisplayName(),
|
|
1739
|
+
range: table.getRange(),
|
|
1740
|
+
fill: (_rangeTheme$getHeader = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.bg) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) !== null && _rangeTheme$getHeader !== void 0 ? _rangeTheme$getHeader : "rgb(53,91,183)",
|
|
1741
|
+
text: (_rangeTheme$getHeader3 = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader4 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader4 === void 0 || (_rangeTheme$getHeader4 = _rangeTheme$getHeader4.cl) === null || _rangeTheme$getHeader4 === void 0 ? void 0 : _rangeTheme$getHeader4.rgb) !== null && _rangeTheme$getHeader3 !== void 0 ? _rangeTheme$getHeader3 : "rgb(255,255,255)"
|
|
1742
|
+
};
|
|
1743
|
+
});
|
|
1744
|
+
this._shape.setItems(items);
|
|
1745
|
+
this._shape.refreshBounds();
|
|
1746
|
+
this._shape.makeDirty(true);
|
|
1747
|
+
this._context.scene.makeDirty();
|
|
1748
|
+
}
|
|
1749
|
+
_canEditWorkbook() {
|
|
1750
|
+
var _this$_permissionServ;
|
|
1751
|
+
const unitId = this._context.unit.getUnitId();
|
|
1752
|
+
return ((_this$_permissionServ = this._permissionService.getPermissionPoint(new _univerjs_sheets.WorkbookEditablePermission(unitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) !== false;
|
|
1753
|
+
}
|
|
1754
|
+
_handlePointerMove(evt, state) {
|
|
1755
|
+
const point = this._getLocalPoint(evt);
|
|
1756
|
+
const hit = this._shape.hitTest(point.x, point.y);
|
|
1757
|
+
const insertRegion = this._isInsertHit(hit) ? hit : hit ? null : this._getInsertRegionFromPoint(point.x, point.y);
|
|
1758
|
+
const activeHit = hit !== null && hit !== void 0 ? hit : insertRegion;
|
|
1759
|
+
this._shape.setHoveredRegion(this._isInsertHit(hit) ? null : hit);
|
|
1760
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1761
|
+
if (activeHit) {
|
|
1762
|
+
state.stopPropagation();
|
|
1763
|
+
this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.POINTER);
|
|
1764
|
+
} else this._context.scene.resetCursor();
|
|
1765
|
+
}
|
|
1766
|
+
_isInsertHit(hit) {
|
|
1767
|
+
return (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-row" || (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-column";
|
|
1768
|
+
}
|
|
1769
|
+
_handlePointerLeave(state) {
|
|
1770
|
+
state.stopPropagation();
|
|
1771
|
+
this._shape.setHoveredRegion(null);
|
|
1772
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1773
|
+
this._context.scene.resetCursor();
|
|
1774
|
+
}
|
|
1775
|
+
_handlePointerDown(evt, state) {
|
|
1776
|
+
var _this$_shape$hitTest;
|
|
1777
|
+
if (evt.button === 2) return;
|
|
1778
|
+
const point = this._getLocalPoint(evt);
|
|
1779
|
+
const hit = (_this$_shape$hitTest = this._shape.hitTest(point.x, point.y)) !== null && _this$_shape$hitTest !== void 0 ? _this$_shape$hitTest : this._getInsertRegionFromPoint(point.x, point.y);
|
|
1780
|
+
if (!hit) {
|
|
1781
|
+
this._closeFloatingControls();
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
state.stopPropagation();
|
|
1785
|
+
evt.stopPropagation();
|
|
1786
|
+
evt.preventDefault();
|
|
1787
|
+
this._handleHit(hit);
|
|
1788
|
+
}
|
|
1789
|
+
_handleHit(hit) {
|
|
1790
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1791
|
+
if (!worksheet) return;
|
|
1792
|
+
const unitId = this._context.unit.getUnitId();
|
|
1793
|
+
const subUnitId = worksheet.getSheetId();
|
|
1794
|
+
if (hit.type === "anchor-menu-toggle" || hit.type === "anchor-main") {
|
|
1795
|
+
this._shape.setOpenedMenuTableId(this._shape.getOpenedMenuTableId() === hit.tableId ? null : hit.tableId);
|
|
1796
|
+
return;
|
|
1797
|
+
}
|
|
1798
|
+
if (hit.type === "insert-row") {
|
|
1799
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertRowAtCommand.id, {
|
|
1800
|
+
unitId,
|
|
1801
|
+
subUnitId,
|
|
1802
|
+
tableId: hit.tableId,
|
|
1803
|
+
index: hit.index,
|
|
1804
|
+
count: 1
|
|
1415
1805
|
});
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
tableName: table.name
|
|
1806
|
+
this._closeFloatingControls();
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
if (hit.type === "insert-column") {
|
|
1810
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
1811
|
+
unitId,
|
|
1812
|
+
subUnitId,
|
|
1813
|
+
tableId: hit.tableId,
|
|
1814
|
+
index: hit.index,
|
|
1815
|
+
count: 1
|
|
1816
|
+
});
|
|
1817
|
+
this._closeFloatingControls();
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
if (hit.type !== "menu-item") return;
|
|
1821
|
+
switch (hit.action) {
|
|
1822
|
+
case "rename":
|
|
1823
|
+
this._openRenameDialog(unitId, hit.tableId);
|
|
1824
|
+
break;
|
|
1825
|
+
case "update-range":
|
|
1826
|
+
this._openRangeSelector(unitId, subUnitId, hit.tableId);
|
|
1827
|
+
break;
|
|
1828
|
+
case "set-theme":
|
|
1829
|
+
this._openThemePanel(unitId, subUnitId, hit.tableId);
|
|
1830
|
+
break;
|
|
1831
|
+
case "delete":
|
|
1832
|
+
this._commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, {
|
|
1833
|
+
tableId: hit.tableId,
|
|
1834
|
+
subUnitId,
|
|
1835
|
+
unitId
|
|
1447
1836
|
});
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
}));
|
|
1837
|
+
break;
|
|
1838
|
+
}
|
|
1839
|
+
this._closeFloatingControls();
|
|
1452
1840
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
const PIVOT_BUTTON_EMPTY = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");
|
|
1471
|
-
var TableButton = class {
|
|
1472
|
-
static drawNoSetting(ctx, size, fgColor, bgColor) {
|
|
1473
|
-
ctx.save();
|
|
1474
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1475
|
-
radius: 2,
|
|
1476
|
-
width: BUTTON_VIEWPORT,
|
|
1477
|
-
height: BUTTON_VIEWPORT,
|
|
1478
|
-
fill: bgColor
|
|
1841
|
+
_openRenameDialog(unitId, tableId) {
|
|
1842
|
+
this._dialogService.open({
|
|
1843
|
+
id: SHEET_TABLE_RENAME_DIALOG_ID,
|
|
1844
|
+
title: { title: this._localeService.t("sheets-table-ui.rename") },
|
|
1845
|
+
draggable: true,
|
|
1846
|
+
destroyOnClose: true,
|
|
1847
|
+
mask: true,
|
|
1848
|
+
children: { label: {
|
|
1849
|
+
name: SHEET_TABLE_RENAME_DIALOG,
|
|
1850
|
+
props: {
|
|
1851
|
+
unitId,
|
|
1852
|
+
tableId,
|
|
1853
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1854
|
+
}
|
|
1855
|
+
} },
|
|
1856
|
+
width: 360,
|
|
1857
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1479
1858
|
});
|
|
1480
|
-
ctx.lineCap = "square";
|
|
1481
|
-
ctx.strokeStyle = fgColor;
|
|
1482
|
-
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1483
|
-
ctx.beginPath();
|
|
1484
|
-
ctx.lineWidth = 1;
|
|
1485
|
-
ctx.lineCap = "round";
|
|
1486
|
-
ctx.moveTo(3, 4);
|
|
1487
|
-
ctx.lineTo(13, 4);
|
|
1488
|
-
ctx.moveTo(4.5, 8);
|
|
1489
|
-
ctx.lineTo(11.5, 8);
|
|
1490
|
-
ctx.moveTo(6, 12);
|
|
1491
|
-
ctx.lineTo(10, 12);
|
|
1492
|
-
ctx.stroke();
|
|
1493
|
-
ctx.restore();
|
|
1494
1859
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1860
|
+
async _openRangeSelector(unitId, subUnitId, tableId) {
|
|
1861
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1862
|
+
if (!table) return;
|
|
1863
|
+
const selection = await openRangeSelector(this._injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1864
|
+
if (!selection) return;
|
|
1865
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1866
|
+
tableId,
|
|
1867
|
+
unitId,
|
|
1868
|
+
updateRange: { newRange: selection.range }
|
|
1504
1869
|
});
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1870
|
+
}
|
|
1871
|
+
_openThemePanel(unitId, subUnitId, tableId) {
|
|
1872
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1873
|
+
if (!table) return;
|
|
1874
|
+
this._sidebarService.open({
|
|
1875
|
+
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1876
|
+
header: { title: this._localeService.t("sheets-table-ui.tableStyle") },
|
|
1877
|
+
children: {
|
|
1878
|
+
label: SHEET_TABLE_THEME_PANEL,
|
|
1879
|
+
oldConfig: table.getTableConfig(),
|
|
1880
|
+
unitId,
|
|
1881
|
+
subUnitId,
|
|
1882
|
+
tableId
|
|
1883
|
+
},
|
|
1884
|
+
width: 330
|
|
1509
1885
|
});
|
|
1510
|
-
|
|
1886
|
+
}
|
|
1887
|
+
_getInsertRegionFromPoint(x, y) {
|
|
1888
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1889
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1890
|
+
if (!skeleton || !worksheet) return null;
|
|
1891
|
+
const unitId = this._context.unit.getUnitId();
|
|
1892
|
+
const subUnitId = worksheet.getSheetId();
|
|
1893
|
+
const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);
|
|
1894
|
+
for (const table of tables) {
|
|
1895
|
+
const range = table.getRange();
|
|
1896
|
+
const tableBounds = this._getRangeBounds(skeleton, range);
|
|
1897
|
+
if (x < tableBounds.left || x > tableBounds.right || y < tableBounds.top || y > tableBounds.bottom) continue;
|
|
1898
|
+
if (y > this._getRangeBounds(skeleton, {
|
|
1899
|
+
...range,
|
|
1900
|
+
endRow: range.startRow
|
|
1901
|
+
}).bottom) for (let row = range.startRow + 1; row <= range.endRow; row++) {
|
|
1902
|
+
const cell = skeleton.getNoMergeCellWithCoordByIndex(row, range.startColumn);
|
|
1903
|
+
if (y >= cell.startY && y <= cell.endY) return {
|
|
1904
|
+
type: "insert-row",
|
|
1905
|
+
tableId: table.getId(),
|
|
1906
|
+
index: row + 1,
|
|
1907
|
+
left: tableBounds.left - 22 / 2,
|
|
1908
|
+
top: cell.endY - 22 / 2,
|
|
1909
|
+
width: 22,
|
|
1910
|
+
height: 22
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
return null;
|
|
1915
|
+
}
|
|
1916
|
+
_getRangeBounds(skeleton, range) {
|
|
1917
|
+
const startCell = skeleton.getNoMergeCellWithCoordByIndex(range.startRow, range.startColumn);
|
|
1918
|
+
const endCell = skeleton.getNoMergeCellWithCoordByIndex(range.endRow, range.endColumn);
|
|
1919
|
+
return {
|
|
1920
|
+
left: startCell.startX,
|
|
1921
|
+
top: startCell.startY,
|
|
1922
|
+
right: endCell.endX,
|
|
1923
|
+
bottom: endCell.endY
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
_syncTopTableGap(skeleton) {
|
|
1927
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1928
|
+
if (!worksheet) return;
|
|
1929
|
+
const unitId = this._context.unit.getUnitId();
|
|
1930
|
+
const subUnitId = worksheet.getSheetId();
|
|
1931
|
+
const hasTopTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => table.getRange().startRow === 0);
|
|
1932
|
+
const current = skeleton.gapConfig;
|
|
1933
|
+
const rowGaps = { ...current.rowGaps };
|
|
1934
|
+
const previousTopGap = rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null;
|
|
1935
|
+
let shouldSync = false;
|
|
1936
|
+
if (hasTopTable) {
|
|
1937
|
+
var _baseGap$size;
|
|
1938
|
+
if (!this._topGapBaseBySkeleton.has(skeleton)) this._topGapBaseBySkeleton.set(skeleton, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null);
|
|
1939
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1940
|
+
rowGaps[TABLE_CONTROL_GAP_ROW] = {
|
|
1941
|
+
...baseGap !== null && baseGap !== void 0 ? baseGap : rowGaps[TABLE_CONTROL_GAP_ROW],
|
|
1942
|
+
size: ((_baseGap$size = baseGap === null || baseGap === void 0 ? void 0 : baseGap.size) !== null && _baseGap$size !== void 0 ? _baseGap$size : 0) + 32
|
|
1943
|
+
};
|
|
1944
|
+
shouldSync = true;
|
|
1945
|
+
} else if (this._topGapBaseBySkeleton.has(skeleton)) {
|
|
1946
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1947
|
+
if (baseGap) rowGaps[TABLE_CONTROL_GAP_ROW] = { ...baseGap };
|
|
1948
|
+
else delete rowGaps[TABLE_CONTROL_GAP_ROW];
|
|
1949
|
+
this._topGapBaseBySkeleton.delete(skeleton);
|
|
1950
|
+
shouldSync = true;
|
|
1951
|
+
}
|
|
1952
|
+
if (!shouldSync) return;
|
|
1953
|
+
if (isSameTopGap(previousTopGap, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null)) return;
|
|
1954
|
+
skeleton.setGapConfig({
|
|
1955
|
+
...current,
|
|
1956
|
+
rowGaps
|
|
1957
|
+
});
|
|
1958
|
+
this._refreshSelections();
|
|
1959
|
+
}
|
|
1960
|
+
_refreshSelections() {
|
|
1961
|
+
this._selectionRenderService.resetSelectionsByModelData(this._sheetsSelectionsService.getCurrentSelections());
|
|
1962
|
+
}
|
|
1963
|
+
_closeFloatingControls() {
|
|
1964
|
+
this._shape.setOpenedMenuTableId(null);
|
|
1965
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1966
|
+
this._shape.setHoveredRegion(null);
|
|
1967
|
+
}
|
|
1968
|
+
_getLocalPoint(evt) {
|
|
1969
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1970
|
+
if (skeleton) return (0, _univerjs_sheets_ui.getTransformCoord)(evt.offsetX, evt.offsetY, this._context.scene, skeleton);
|
|
1971
|
+
return {
|
|
1972
|
+
x: evt.offsetX,
|
|
1973
|
+
y: evt.offsetY
|
|
1974
|
+
};
|
|
1511
1975
|
}
|
|
1512
1976
|
};
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
* See the License for the specific language governing permissions and
|
|
1529
|
-
* limitations under the License.
|
|
1530
|
-
*/
|
|
1531
|
-
const filterPartial = ["M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z"];
|
|
1532
|
-
const filteredSortAsc = ["M12.4008 13.1831C12.6907 13.1831 12.9258 12.9481 12.9258 12.6581V4.60873L14.013 5.69597C14.218 5.901 14.5505 5.901 14.7555 5.69597C14.9605 5.49094 14.9605 5.15853 14.7555 4.95351L12.7721 2.97017C12.5671 2.76515 12.2347 2.76515 12.0297 2.97017L10.0463 4.95351C9.84132 5.15853 9.84132 5.49094 10.0463 5.69597C10.2514 5.901 10.5838 5.901 10.7888 5.69597L11.8758 4.60901V12.6581C11.8758 12.9481 12.1108 13.1831 12.4008 13.1831Z", "M1.28069 4.85447C0.842195 4.33439 1.21191 3.5391 1.89218 3.5391H8.59333C9.2736 3.5391 9.64331 4.33439 9.20482 4.85447L6.51052 8.0501V11.6601C6.51052 12.2245 5.94174 12.6114 5.41683 12.404L4.48092 12.0343C4.1756 11.9136 3.97498 11.6187 3.97498 11.2904V8.0501L1.28069 4.85447Z"];
|
|
1533
|
-
const filteredSortDesc = ["M12.4008 2.81641C12.6907 2.81641 12.9258 3.05146 12.9258 3.34141V11.3908L14.013 10.3036C14.218 10.0986 14.5505 10.0986 14.7555 10.3036C14.9605 10.5086 14.9605 10.841 14.7555 11.046L12.7721 13.0294C12.5671 13.2344 12.2347 13.2344 12.0297 13.0294L10.0463 11.046C9.84132 10.841 9.84132 10.5086 10.0463 10.3036C10.2514 10.0986 10.5838 10.0986 10.7888 10.3036L11.8758 11.3905V3.34141C11.8758 3.05146 12.1108 2.81641 12.4008 2.81641Z", "M1.28069 4.85444C0.842195 4.33435 1.21191 3.53906 1.89218 3.53906H8.59333C9.2736 3.53906 9.64331 4.33435 9.20482 4.85443L6.51052 8.05006V11.6601C6.51052 12.2245 5.94174 12.6113 5.41683 12.404L4.48092 12.0342C4.1756 11.9136 3.97498 11.6186 3.97498 11.2903V8.05006L1.28069 4.85444Z"];
|
|
1534
|
-
const filterNoneSortAsc = [
|
|
1535
|
-
"M11.9003 13.7046C11.9003 13.9969 11.6633 14.2339 11.371 14.2339C11.0787 14.2339 10.8417 13.9969 10.8417 13.7046V3.57272L9.74577 4.66862C9.53906 4.87534 9.20391 4.87534 8.9972 4.66862C8.79048 4.46191 8.79048 4.12676 8.9972 3.92005L10.9969 1.92039C11.2036 1.71368 11.5387 1.71368 11.7454 1.92039L13.7451 3.92005C13.9518 4.12676 13.9518 4.46191 13.7451 4.66862C13.5384 4.87534 13.2032 4.87534 12.9965 4.66862L11.9003 3.57243V13.7046Z",
|
|
1536
|
-
"M2.69779 10.0113C2.40546 10.0113 2.16847 9.77429 2.16847 9.48196C2.16847 9.18962 2.40546 8.95264 2.69779 8.95264H6.67804C6.89213 8.95264 7.08514 9.0816 7.16707 9.2794C7.249 9.47719 7.20371 9.70486 7.05233 9.85624L3.97569 12.9329H6.67804C6.97038 12.9329 7.20736 13.1699 7.20736 13.4622C7.20736 13.7545 6.97038 13.9915 6.67804 13.9915H2.69779C2.4837 13.9915 2.29069 13.8626 2.20876 13.6648C2.12684 13.467 2.17212 13.2393 2.32351 13.0879L5.40015 10.0113H2.69779Z",
|
|
1537
|
-
"M5.51638 2.58693C5.23363 1.81542 4.14248 1.81543 3.85973 2.58693L2.13245 7.29995C2.03185 7.57443 2.17281 7.87849 2.4473 7.97909C2.72178 8.07969 3.02584 7.93872 3.12644 7.66424L3.64346 6.25351L3.64504 6.25351H5.73266L6.24968 7.66424C6.35027 7.93872 6.65433 8.07969 6.92882 7.97909C7.2033 7.87849 7.34426 7.57443 7.24367 7.29995L5.51638 2.58693ZM5.34467 5.19487L4.68806 3.40325L4.03144 5.19487H5.34467Z"
|
|
1538
|
-
];
|
|
1539
|
-
const filterNoneSortDesc = [
|
|
1540
|
-
"M11.9003 2.29495C11.9003 2.00261 11.6633 1.76562 11.371 1.76562C11.0787 1.76562 10.8417 2.00261 10.8417 2.29495V12.4268L9.74577 11.3309C9.53906 11.1242 9.20391 11.1242 8.9972 11.3309C8.79048 11.5376 8.79048 11.8727 8.9972 12.0795L10.9969 14.0791C11.2036 14.2858 11.5387 14.2858 11.7454 14.0791L13.7451 12.0795C13.9518 11.8727 13.9518 11.5376 13.7451 11.3309C13.5384 11.1242 13.2032 11.1242 12.9965 11.3309L11.9003 12.4271V2.29495Z",
|
|
1541
|
-
"M2.69792 10.0113C2.40558 10.0113 2.16859 9.77429 2.16859 9.48196C2.16859 9.18962 2.40558 8.95264 2.69792 8.95264H6.67816C6.89225 8.95264 7.08526 9.0816 7.16719 9.2794C7.24912 9.47719 7.20384 9.70486 7.05245 9.85624L3.97581 12.9329H6.67816C6.9705 12.9329 7.20749 13.1699 7.20749 13.4622C7.20749 13.7545 6.9705 13.9915 6.67816 13.9915H2.69792C2.48383 13.9915 2.29082 13.8626 2.20889 13.6648C2.12696 13.467 2.17224 13.2393 2.32363 13.0879L5.40027 10.0113H2.69792Z",
|
|
1542
|
-
"M5.5165 2.58693C5.23375 1.81542 4.1426 1.81543 3.85985 2.58693L2.13257 7.29995C2.03197 7.57443 2.17294 7.8785 2.44742 7.97909C2.7219 8.07969 3.02596 7.93872 3.12656 7.66424L3.64358 6.25351L3.64516 6.25351H5.73278L6.2498 7.66424C6.35039 7.93872 6.65446 8.07969 6.92894 7.97909C7.20342 7.8785 7.34438 7.57443 7.24379 7.29995L5.5165 2.58693ZM5.34479 5.19487L4.68818 3.40325L4.03156 5.19487H5.34479Z"
|
|
1543
|
-
];
|
|
1977
|
+
SheetTableControlsRenderController = __decorate([
|
|
1978
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1979
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1980
|
+
__decorateParam(3, _univerjs_core.ICommandService),
|
|
1981
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager)),
|
|
1982
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetRangeThemeModel)),
|
|
1983
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets.WorkbookPermissionService)),
|
|
1984
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.IPermissionService)),
|
|
1985
|
+
__decorateParam(8, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
1986
|
+
__decorateParam(9, _univerjs_sheets_ui.ISheetSelectionRenderService),
|
|
1987
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(SheetTableThemeUIController)),
|
|
1988
|
+
__decorateParam(11, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1989
|
+
__decorateParam(12, _univerjs_ui.IDialogService),
|
|
1990
|
+
__decorateParam(13, _univerjs_ui.ISidebarService)
|
|
1991
|
+
], SheetTableControlsRenderController);
|
|
1544
1992
|
|
|
1545
1993
|
//#endregion
|
|
1546
1994
|
//#region src/views/widgets/table-filter-button.shape.ts
|
|
1547
1995
|
const FILTER_ICON_SIZE = 16;
|
|
1996
|
+
const FILTER_TRIGGER_HOVER_RADIUS = 4;
|
|
1548
1997
|
let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _univerjs_engine_render.Shape {
|
|
1549
|
-
constructor(key, props,
|
|
1998
|
+
constructor(key, props, _commandService) {
|
|
1550
1999
|
super(key, props);
|
|
1551
|
-
this._contextService = _contextService;
|
|
1552
2000
|
this._commandService = _commandService;
|
|
1553
|
-
this._themeService = _themeService;
|
|
1554
2001
|
_defineProperty(this, "_cellWidth", 0);
|
|
1555
2002
|
_defineProperty(this, "_cellHeight", 0);
|
|
1556
2003
|
_defineProperty(this, "_filterParams", void 0);
|
|
2004
|
+
_defineProperty(this, "_iconColor", "#fff");
|
|
2005
|
+
_defineProperty(this, "_hoverBackground", "rgba(255, 255, 255, 0.92)");
|
|
2006
|
+
_defineProperty(this, "_hoverIconColor", "#202124");
|
|
1557
2007
|
_defineProperty(this, "_hovered", false);
|
|
1558
2008
|
this.setShapeProps(props);
|
|
1559
2009
|
this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));
|
|
@@ -1564,6 +2014,9 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1564
2014
|
if (typeof props.cellHeight !== "undefined") this._cellHeight = props.cellHeight;
|
|
1565
2015
|
if (typeof props.cellWidth !== "undefined") this._cellWidth = props.cellWidth;
|
|
1566
2016
|
if (typeof props.filterParams !== "undefined") this._filterParams = props.filterParams;
|
|
2017
|
+
if (typeof props.iconColor !== "undefined") this._iconColor = props.iconColor;
|
|
2018
|
+
if (typeof props.hoverBackground !== "undefined") this._hoverBackground = props.hoverBackground;
|
|
2019
|
+
if (typeof props.hoverIconColor !== "undefined") this._hoverIconColor = props.hoverIconColor;
|
|
1567
2020
|
this.transformByState({
|
|
1568
2021
|
width: props.width,
|
|
1569
2022
|
height: props.height
|
|
@@ -1578,36 +2031,38 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1578
2031
|
const cellRegion = new Path2D();
|
|
1579
2032
|
cellRegion.rect(left, top, cellWidth, cellHeight);
|
|
1580
2033
|
ctx.clip(cellRegion);
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
icons = filteredSortAsc;
|
|
1591
|
-
break;
|
|
1592
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilteredSortDesc:
|
|
1593
|
-
icons = filteredSortDesc;
|
|
1594
|
-
break;
|
|
1595
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortNone: break;
|
|
1596
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortAsc:
|
|
1597
|
-
icons = filterNoneSortAsc;
|
|
1598
|
-
break;
|
|
1599
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortDesc:
|
|
1600
|
-
icons = filterNoneSortDesc;
|
|
1601
|
-
break;
|
|
2034
|
+
if (this._hovered) {
|
|
2035
|
+
var _ctx$roundRect;
|
|
2036
|
+
ctx.save();
|
|
2037
|
+
ctx.fillStyle = this._hoverBackground;
|
|
2038
|
+
ctx.beginPath();
|
|
2039
|
+
(_ctx$roundRect = ctx.roundRect) === null || _ctx$roundRect === void 0 || _ctx$roundRect.call(ctx, 0, 0, 16, 16, FILTER_TRIGGER_HOVER_RADIUS);
|
|
2040
|
+
if (!ctx.roundRect) ctx.rect(0, 0, 16, 16);
|
|
2041
|
+
ctx.fill();
|
|
2042
|
+
ctx.restore();
|
|
1602
2043
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
2044
|
+
this._drawChevron(ctx, this._hovered ? this._hoverIconColor : this._iconColor);
|
|
2045
|
+
ctx.restore();
|
|
2046
|
+
}
|
|
2047
|
+
_drawChevron(ctx, color) {
|
|
2048
|
+
const centerX = 16 / 2;
|
|
2049
|
+
const centerY = 16 / 2;
|
|
2050
|
+
ctx.save();
|
|
2051
|
+
ctx.beginPath();
|
|
2052
|
+
ctx.strokeStyle = color;
|
|
2053
|
+
ctx.lineWidth = 1.8;
|
|
2054
|
+
ctx.lineCap = "round";
|
|
2055
|
+
ctx.lineJoin = "round";
|
|
2056
|
+
ctx.moveTo(centerX - 4.5, centerY - 2.5);
|
|
2057
|
+
ctx.lineTo(centerX, centerY + 2);
|
|
2058
|
+
ctx.lineTo(centerX + 4.5, centerY - 2.5);
|
|
2059
|
+
ctx.stroke();
|
|
1605
2060
|
ctx.restore();
|
|
1606
2061
|
}
|
|
1607
2062
|
onPointerDown(evt) {
|
|
1608
2063
|
if (evt.button === 2) return;
|
|
1609
2064
|
const { row, col, unitId, subUnitId, tableId } = this._filterParams;
|
|
1610
|
-
if (
|
|
2065
|
+
if (!this._commandService.hasCommand(OpenTableFilterPanelOperation.id)) return;
|
|
1611
2066
|
setTimeout(() => {
|
|
1612
2067
|
const cmdParams = {
|
|
1613
2068
|
row,
|
|
@@ -1628,11 +2083,7 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1628
2083
|
this.makeDirty(true);
|
|
1629
2084
|
}
|
|
1630
2085
|
};
|
|
1631
|
-
SheetsTableFilterButtonShape = __decorate([
|
|
1632
|
-
__decorateParam(2, _univerjs_core.IContextService),
|
|
1633
|
-
__decorateParam(3, _univerjs_core.ICommandService),
|
|
1634
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
1635
|
-
], SheetsTableFilterButtonShape);
|
|
2086
|
+
SheetsTableFilterButtonShape = __decorate([__decorateParam(2, _univerjs_core.ICommandService)], SheetsTableFilterButtonShape);
|
|
1636
2087
|
|
|
1637
2088
|
//#endregion
|
|
1638
2089
|
//#region src/controllers/sheet-table-filter-button-render.controller.ts
|
|
@@ -1646,13 +2097,14 @@ const computeIconTop = (startY, endY, cellHeight, verticalAlign) => {
|
|
|
1646
2097
|
}
|
|
1647
2098
|
};
|
|
1648
2099
|
let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRenderController extends _univerjs_core.RxDisposable {
|
|
1649
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _commandService) {
|
|
2100
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _rangeThemeModel, _commandService) {
|
|
1650
2101
|
super();
|
|
1651
2102
|
this._context = _context;
|
|
1652
2103
|
this._injector = _injector;
|
|
1653
2104
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1654
2105
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1655
2106
|
this._tableManager = _tableManager;
|
|
2107
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1656
2108
|
this._commandService = _commandService;
|
|
1657
2109
|
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
1658
2110
|
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
@@ -1708,7 +2160,12 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1708
2160
|
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
1709
2161
|
if (!worksheet) return;
|
|
1710
2162
|
for (const { range, states, tableId } of tableFilterRanges) {
|
|
2163
|
+
var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
|
|
1711
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";
|
|
1712
2169
|
this._interceptCellContent(unitId, worksheetId, range);
|
|
1713
2170
|
for (let col = startColumn; col <= endColumn; col++) {
|
|
1714
2171
|
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
@@ -1726,6 +2183,9 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1726
2183
|
height: 16,
|
|
1727
2184
|
width: 16,
|
|
1728
2185
|
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2186
|
+
iconColor,
|
|
2187
|
+
hoverBackground: iconColor,
|
|
2188
|
+
hoverIconColor,
|
|
1729
2189
|
cellHeight,
|
|
1730
2190
|
cellWidth,
|
|
1731
2191
|
filterParams: {
|
|
@@ -1754,7 +2214,7 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1754
2214
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
1755
2215
|
cell.fontRenderExtension = {
|
|
1756
2216
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
1757
|
-
rightOffset: 16
|
|
2217
|
+
rightOffset: 16 + 1 + 2
|
|
1758
2218
|
};
|
|
1759
2219
|
return next(cell);
|
|
1760
2220
|
},
|
|
@@ -1774,7 +2234,8 @@ SheetsTableFilterButtonRenderController = __decorate([
|
|
|
1774
2234
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1775
2235
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
1776
2236
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager)),
|
|
1777
|
-
__decorateParam(5, _univerjs_core.
|
|
2237
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetRangeThemeModel)),
|
|
2238
|
+
__decorateParam(6, _univerjs_core.ICommandService)
|
|
1778
2239
|
], SheetsTableFilterButtonRenderController);
|
|
1779
2240
|
|
|
1780
2241
|
//#endregion
|
|
@@ -1917,7 +2378,7 @@ const SheetTableSelector = (props) => {
|
|
|
1917
2378
|
if (target.worksheet.getMergeData().some((merge) => {
|
|
1918
2379
|
return _univerjs_core.Rectangle.intersects(newRange, merge);
|
|
1919
2380
|
})) {
|
|
1920
|
-
setRangeError(localeService.t("sheets-table.tableRangeWithMergeError"));
|
|
2381
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeWithMergeError"));
|
|
1921
2382
|
return;
|
|
1922
2383
|
}
|
|
1923
2384
|
if (tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => {
|
|
@@ -1925,12 +2386,12 @@ const SheetTableSelector = (props) => {
|
|
|
1925
2386
|
const tableRange = table.getRange();
|
|
1926
2387
|
return _univerjs_core.Rectangle.intersects(newRange, tableRange);
|
|
1927
2388
|
})) {
|
|
1928
|
-
setRangeError(localeService.t("sheets-table.tableRangeWithOtherTableError"));
|
|
2389
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeWithOtherTableError"));
|
|
1929
2390
|
return;
|
|
1930
2391
|
}
|
|
1931
2392
|
const { startRow, endRow } = newRange;
|
|
1932
2393
|
if (startRow === endRow) {
|
|
1933
|
-
setRangeError(localeService.t("sheets-table.tableRangeSingleRowError"));
|
|
2394
|
+
setRangeError(localeService.t("sheets-table-ui.tableRangeSingleRowError"));
|
|
1934
2395
|
return;
|
|
1935
2396
|
}
|
|
1936
2397
|
if (originValue === text) return;
|
|
@@ -1948,7 +2409,7 @@ const SheetTableSelector = (props) => {
|
|
|
1948
2409
|
});
|
|
1949
2410
|
return;
|
|
1950
2411
|
} else {
|
|
1951
|
-
setRangeError(localeService.t("sheets-table.updateError"));
|
|
2412
|
+
setRangeError(localeService.t("sheets-table-ui.updateError"));
|
|
1952
2413
|
return;
|
|
1953
2414
|
}
|
|
1954
2415
|
}
|
|
@@ -1966,7 +2427,7 @@ const SheetTableSelector = (props) => {
|
|
|
1966
2427
|
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
1967
2428
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1968
2429
|
onClick: onCancel,
|
|
1969
|
-
children: localeService.t("sheets-table.cancel")
|
|
2430
|
+
children: localeService.t("sheets-table-ui.cancel")
|
|
1970
2431
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1971
2432
|
variant: "primary",
|
|
1972
2433
|
onClick: () => {
|
|
@@ -1978,7 +2439,7 @@ const SheetTableSelector = (props) => {
|
|
|
1978
2439
|
});
|
|
1979
2440
|
},
|
|
1980
2441
|
className: "univer-ml-2",
|
|
1981
|
-
children: localeService.t("sheets-table.confirm")
|
|
2442
|
+
children: localeService.t("sheets-table-ui.confirm")
|
|
1982
2443
|
})]
|
|
1983
2444
|
})
|
|
1984
2445
|
] });
|
|
@@ -2026,7 +2487,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2026
2487
|
};
|
|
2027
2488
|
const handleAddCustomTheme = () => {
|
|
2028
2489
|
if (customRangeThemes.length >= 11) {
|
|
2029
|
-
errorService.emit(localeService.t("sheets-table.customTooMore"));
|
|
2490
|
+
errorService.emit(localeService.t("sheets-table-ui.customTooMore"));
|
|
2030
2491
|
return;
|
|
2031
2492
|
}
|
|
2032
2493
|
const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];
|
|
@@ -2063,7 +2524,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2063
2524
|
const secondRowBgIsDark = new _univerjs_core.ColorKit(secondRowBg).isDark();
|
|
2064
2525
|
const lastRowBgIsDark = new _univerjs_core.ColorKit(lastRowBg).isDark();
|
|
2065
2526
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
2066
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h5", { children: localeService.t("sheets-table.defaultStyle") }),
|
|
2527
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h5", { children: localeService.t("sheets-table-ui.defaultStyle") }),
|
|
2067
2528
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2068
2529
|
className: "univer-flex univer-gap-2",
|
|
2069
2530
|
children: defaultRangeThemes.map((item) => {
|
|
@@ -2097,7 +2558,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2097
2558
|
}, item);
|
|
2098
2559
|
})
|
|
2099
2560
|
}),
|
|
2100
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h5", { children: localeService.t("sheets-table.customStyle") }),
|
|
2561
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h5", { children: localeService.t("sheets-table-ui.customStyle") }),
|
|
2101
2562
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2102
2563
|
className: (0, _univerjs_design.clsx)("univer-w-full univer-rounded-sm", _univerjs_design.borderClassName),
|
|
2103
2564
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -2170,7 +2631,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2170
2631
|
"univer-text-gray-900": !headerBgIsDark
|
|
2171
2632
|
}),
|
|
2172
2633
|
style: { background: headerBg },
|
|
2173
|
-
children: localeService.t("sheets-table.header")
|
|
2634
|
+
children: localeService.t("sheets-table-ui.header")
|
|
2174
2635
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
2175
2636
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2176
2637
|
className: "univer-p-2",
|
|
@@ -2205,7 +2666,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2205
2666
|
"univer-text-gray-900": !firstRowBgIsDark
|
|
2206
2667
|
}),
|
|
2207
2668
|
style: { background: firstRowBg },
|
|
2208
|
-
children: localeService.t("sheets-table.firstLine")
|
|
2669
|
+
children: localeService.t("sheets-table-ui.firstLine")
|
|
2209
2670
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
2210
2671
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2211
2672
|
className: "univer-p-2",
|
|
@@ -2236,7 +2697,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2236
2697
|
"univer-text-gray-900": !secondRowBgIsDark
|
|
2237
2698
|
}),
|
|
2238
2699
|
style: { background: secondRowBg },
|
|
2239
|
-
children: localeService.t("sheets-table.secondLine")
|
|
2700
|
+
children: localeService.t("sheets-table-ui.secondLine")
|
|
2240
2701
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
2241
2702
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2242
2703
|
className: "univer-p-2",
|
|
@@ -2265,7 +2726,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
2265
2726
|
"univer-text-gray-900": !lastRowBgIsDark
|
|
2266
2727
|
}),
|
|
2267
2728
|
style: { background: lastRowBg },
|
|
2268
|
-
children: localeService.t("sheets-table.footer")
|
|
2729
|
+
children: localeService.t("sheets-table-ui.footer")
|
|
2269
2730
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
2270
2731
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2271
2732
|
className: "univer-p-2",
|
|
@@ -2304,8 +2765,8 @@ function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
|
2304
2765
|
id: OpenTableSelectorOperation.id,
|
|
2305
2766
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2306
2767
|
icon: TABLE_TOOLBAR_BUTTON,
|
|
2307
|
-
tooltip: "sheets-table.title",
|
|
2308
|
-
title: "sheets-table.title",
|
|
2768
|
+
tooltip: "sheets-table-ui.title",
|
|
2769
|
+
title: "sheets-table-ui.title",
|
|
2309
2770
|
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2310
2771
|
disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {}, true)
|
|
2311
2772
|
};
|
|
@@ -2315,7 +2776,7 @@ function SheetTableInsertContextMenuFactory(accessor) {
|
|
|
2315
2776
|
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
2316
2777
|
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2317
2778
|
icon: "InsertDoubleIcon",
|
|
2318
|
-
title: "sheets-table.insert.main",
|
|
2779
|
+
title: "sheets-table-ui.insert.main",
|
|
2319
2780
|
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2320
2781
|
};
|
|
2321
2782
|
}
|
|
@@ -2324,7 +2785,7 @@ function SheetTableRemoveContextMenuFactory(accessor) {
|
|
|
2324
2785
|
id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,
|
|
2325
2786
|
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2326
2787
|
icon: "ReduceDoubleIcon",
|
|
2327
|
-
title: "sheets-table.remove.main",
|
|
2788
|
+
title: "sheets-table-ui.remove.main",
|
|
2328
2789
|
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2329
2790
|
};
|
|
2330
2791
|
}
|
|
@@ -2332,14 +2793,14 @@ function SheetTableInsertRowMenuFactory(accessor) {
|
|
|
2332
2793
|
return {
|
|
2333
2794
|
id: _univerjs_sheets_table.SheetTableInsertRowCommand.id,
|
|
2334
2795
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2335
|
-
title: "sheets-table.insert.row",
|
|
2796
|
+
title: "sheets-table-ui.insert.row",
|
|
2336
2797
|
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2337
2798
|
};
|
|
2338
2799
|
}
|
|
2339
2800
|
function SheetTableInsertColMenuFactory(accessor) {
|
|
2340
2801
|
return {
|
|
2341
2802
|
id: _univerjs_sheets_table.SheetTableInsertColCommand.id,
|
|
2342
|
-
title: "sheets-table.insert.col",
|
|
2803
|
+
title: "sheets-table-ui.insert.col",
|
|
2343
2804
|
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2344
2805
|
};
|
|
2345
2806
|
}
|
|
@@ -2347,14 +2808,14 @@ function SheetTableRemoveRowMenuFactory(accessor) {
|
|
|
2347
2808
|
return {
|
|
2348
2809
|
id: _univerjs_sheets_table.SheetTableRemoveRowCommand.id,
|
|
2349
2810
|
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2350
|
-
title: "sheets-table.remove.row",
|
|
2811
|
+
title: "sheets-table-ui.remove.row",
|
|
2351
2812
|
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2352
2813
|
};
|
|
2353
2814
|
}
|
|
2354
2815
|
function SheetTableRemoveColMenuFactory(accessor) {
|
|
2355
2816
|
return {
|
|
2356
2817
|
id: _univerjs_sheets_table.SheetTableRemoveColCommand.id,
|
|
2357
|
-
title: "sheets-table.remove.col",
|
|
2818
|
+
title: "sheets-table-ui.remove.col",
|
|
2358
2819
|
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2359
2820
|
};
|
|
2360
2821
|
}
|
|
@@ -2503,8 +2964,9 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerj
|
|
|
2503
2964
|
this._registerRenderModules();
|
|
2504
2965
|
}
|
|
2505
2966
|
_registerRenderModules() {
|
|
2506
|
-
const renderDependencies = [
|
|
2507
|
-
if (this._config.hideAnchor !== true) renderDependencies.push([
|
|
2967
|
+
const renderDependencies = [];
|
|
2968
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableControlsRenderController]);
|
|
2969
|
+
renderDependencies.push([SheetsTableFilterButtonRenderController], [SheetsTableRenderController]);
|
|
2508
2970
|
renderDependencies.forEach((m) => {
|
|
2509
2971
|
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, m));
|
|
2510
2972
|
});
|