@univerjs/sheets-table-ui 1.0.0-rc.0 → 1.0.1
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 +629 -206
- package/lib/cjs/locale/ar-SA.js +11 -1
- package/lib/cjs/locale/ca-ES.js +11 -1
- package/lib/cjs/locale/de-DE.js +11 -1
- 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 +11 -1
- package/lib/cjs/locale/it-IT.js +11 -1
- 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 +11 -1
- package/lib/cjs/locale/pt-BR.js +11 -1
- 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 +11 -1
- package/lib/cjs/locale/zh-TW.js +11 -1
- package/lib/es/index.js +633 -210
- package/lib/es/locale/ar-SA.js +11 -0
- package/lib/es/locale/ca-ES.js +11 -0
- package/lib/es/locale/de-DE.js +11 -0
- package/lib/es/locale/en-US.js +11 -0
- package/lib/es/locale/es-ES.js +11 -0
- package/lib/es/locale/fa-IR.js +11 -0
- package/lib/es/locale/fr-FR.js +11 -0
- package/lib/es/locale/id-ID.js +11 -0
- package/lib/es/locale/it-IT.js +11 -0
- package/lib/es/locale/ja-JP.js +11 -0
- package/lib/es/locale/ko-KR.js +11 -0
- package/lib/es/locale/pl-PL.js +11 -0
- package/lib/es/locale/pt-BR.js +11 -0
- package/lib/es/locale/ru-RU.js +11 -0
- package/lib/es/locale/sk-SK.js +11 -0
- package/lib/es/locale/vi-VN.js +11 -0
- package/lib/es/locale/zh-CN.js +11 -0
- package/lib/es/locale/zh-HK.js +11 -0
- package/lib/es/locale/zh-TW.js +11 -0
- package/lib/index.css +9 -0
- package/lib/index.js +633 -210
- package/lib/locale/ar-SA.js +11 -0
- package/lib/locale/ca-ES.js +11 -0
- package/lib/locale/de-DE.js +11 -0
- package/lib/locale/en-US.js +11 -0
- package/lib/locale/es-ES.js +11 -0
- package/lib/locale/fa-IR.js +11 -0
- package/lib/locale/fr-FR.js +11 -0
- package/lib/locale/id-ID.js +11 -0
- package/lib/locale/it-IT.js +11 -0
- package/lib/locale/ja-JP.js +11 -0
- package/lib/locale/ko-KR.js +11 -0
- package/lib/locale/pl-PL.js +11 -0
- package/lib/locale/pt-BR.js +11 -0
- package/lib/locale/ru-RU.js +11 -0
- package/lib/locale/sk-SK.js +11 -0
- package/lib/locale/vi-VN.js +11 -0
- package/lib/locale/zh-CN.js +11 -0
- package/lib/locale/zh-HK.js +11 -0
- package/lib/locale/zh-TW.js +11 -0
- package/lib/types/commands/operations/mobile/open-table-filter-dialog.operation.d.ts +18 -0
- package/lib/types/const.d.ts +2 -0
- package/lib/types/controllers/sheet-table-controls-render.controller.d.ts +2 -0
- package/lib/types/locale/en-US.d.ts +11 -0
- package/lib/types/menu/mobile-schema.d.ts +17 -0
- package/lib/types/menu/mobile-sheet-table-menu.controller.d.ts +20 -0
- package/lib/types/services/sheets-table-ui.service.d.ts +3 -1
- package/lib/types/types.d.ts +3 -0
- package/lib/types/views/components/MobileSheetTableItemsFilterPanel.d.ts +2 -0
- package/lib/types/views/components/MobileSheetTableSettingsDialog.d.ts +17 -0
- package/lib/types/views/components/SheetTableCalculatedColumn.d.ts +21 -0
- package/lib/types/views/components/SheetTableItemsFilterPanel.d.ts +2 -0
- package/lib/types/views/components/SheetTableMenu.d.ts +1 -1
- package/lib/types/views/components/SheetTableSettingsDialog.d.ts +23 -0
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- 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 -1
- package/lib/umd/locale/it-IT.js +1 -1
- 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 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- 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 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +15 -15
package/lib/es/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableController, SheetsTableSortStateEnum, TABLE_FILTER_EMPTY_VALUE, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, getExistingNamesSet, isColorTableFilter, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle, validateSheetTableName } from "@univerjs/sheets-table";
|
|
1
|
+
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SetSheetTableFilterMutation, SetSheetTableMutation, SetSheetTableSortStateCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableController, SheetsTableSortStateEnum, TABLE_FILTER_EMPTY_VALUE, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, compileTableRecordFilter, customEmptyThemeWithBorderStyle, getExistingNamesSet, getTableRecordValue, getTableRecordValueKey, isColorTableFilter, isConditionFilter, isManualTableFilter, isRecordTableFilter, processStyleWithBorderStyle, validateSheetTableName } from "@univerjs/sheets-table";
|
|
2
2
|
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, MobileDrawer, RibbonDataGroup, UniverMobileUIPlugin, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
3
|
-
import { ColorKit, CommandType, DEFAULT_STYLES, DependentOn, Disposable, ErrorService, ICommandService, IConfigService, IContextService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, Rectangle, RxDisposable, UniverInstanceType, VerticalAlign, cellToRange, fromCallback, generateRandomId, getColorStyle, merge, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
|
|
3
|
+
import { ColorKit, CommandType, DEFAULT_STYLES, DependentOn, Disposable, ErrorService, FilterSelectionMode, ICommandService, IConfigService, IContextService, IPermissionService, IUndoRedoService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, RecordValueType, Rectangle, RxDisposable, UniverInstanceType, VerticalAlign, cellToRange, fromCallback, generateRandomId, getColorStyle, merge, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
|
|
4
4
|
import { INTERCEPTOR_POINT, RangeThemeStyle, SelectRangeCommand, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, UniverSheetsPlugin, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
|
|
5
5
|
import { ExpandSelectionCommand, ISheetSelectionRenderService, MoveSelectionCommand, MoveSelectionEnterAndTabCommand, SHEET_VIEW_KEY, SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCoordByCell, getCurrentRangeDisable$, getTransformCoord } from "@univerjs/sheets-ui";
|
|
6
6
|
import { Subject, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
7
7
|
import { CURSOR_TYPE, DEFAULT_FONTFACE_PLANE, IRenderManagerService, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
8
8
|
import { AIcon, AscendingIcon, BanIcon, CheckMarkIcon, CloseIcon, DeleteColumnDoubleIcon, DescendingIcon, DownIcon, IncreaseIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, MoreLeftIcon, MoreRightIcon, RightInsertColumnDoubleIcon, SuccessIcon, TableIcon } from "@univerjs/icons";
|
|
9
|
-
import { ActionRow, Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, DropdownMenu, Input, InputNumber, MobileActionRow, MobileActionRowGroup, MobileColorPicker, MobileDropdown, MobileSelect, Segmented, Select, borderClassName, clsx, resetButtonClassName, scrollbarClassName } from "@univerjs/design";
|
|
9
|
+
import { ActionRow, Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, DropdownMenu, FormLayout, Input, InputNumber, MobileActionRow, MobileActionRowGroup, MobileColorPicker, MobileDropdown, MobileSelect, Segmented, Select, borderClassName, clsx, resetButtonClassName, scrollbarClassName } from "@univerjs/design";
|
|
10
10
|
import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
|
|
11
|
-
import {
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { createPortal } from "react-dom";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { IDefinedNamesService, deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
@@ -36,6 +36,8 @@ const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
|
36
36
|
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
37
37
|
const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
|
|
38
38
|
const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
39
|
+
const SHEET_TABLE_SETTINGS_DIALOG = "SHEET_TABLE_SETTINGS_DIALOG";
|
|
40
|
+
const SHEET_TABLE_SETTINGS_DIALOG_ID = "SHEET_TABLE_SETTINGS_DIALOG_ID";
|
|
39
41
|
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
40
42
|
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
41
43
|
const SHEET_TABLE_MENU = "SHEET_TABLE_MENU";
|
|
@@ -184,7 +186,8 @@ function getSheetTableRowColOperationHidden$(accessor) {
|
|
|
184
186
|
return sheetsSelectionsService.selectionMoveEnd$.pipe(startWith(sheetsSelectionsService.getCurrentSelections()), switchMap((selections) => {
|
|
185
187
|
if (!selections.length || selections.length > 1) return of(true);
|
|
186
188
|
const range = selections[0].range;
|
|
187
|
-
|
|
189
|
+
const isInTable = accessor.get(SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
190
|
+
return of(!isInTable);
|
|
188
191
|
}));
|
|
189
192
|
}));
|
|
190
193
|
}));
|
|
@@ -250,10 +253,10 @@ const menuSchema = {
|
|
|
250
253
|
//#endregion
|
|
251
254
|
//#region package.json
|
|
252
255
|
var name = "@univerjs/sheets-table-ui";
|
|
253
|
-
var version = "1.0.
|
|
256
|
+
var version = "1.0.1";
|
|
254
257
|
|
|
255
258
|
//#endregion
|
|
256
|
-
//#region \0@oxc-project+runtime@0.
|
|
259
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
257
260
|
function _typeof(o) {
|
|
258
261
|
"@babel/helpers - typeof";
|
|
259
262
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -264,7 +267,7 @@ function _typeof(o) {
|
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
//#endregion
|
|
267
|
-
//#region \0@oxc-project+runtime@0.
|
|
270
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
268
271
|
function toPrimitive(t, r) {
|
|
269
272
|
if ("object" != _typeof(t) || !t) return t;
|
|
270
273
|
var e = t[Symbol.toPrimitive];
|
|
@@ -277,14 +280,14 @@ function toPrimitive(t, r) {
|
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
//#endregion
|
|
280
|
-
//#region \0@oxc-project+runtime@0.
|
|
283
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
281
284
|
function toPropertyKey(t) {
|
|
282
285
|
var i = toPrimitive(t, "string");
|
|
283
286
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
284
287
|
}
|
|
285
288
|
|
|
286
289
|
//#endregion
|
|
287
|
-
//#region \0@oxc-project+runtime@0.
|
|
290
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
288
291
|
function _defineProperty(e, r, t) {
|
|
289
292
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
290
293
|
value: t,
|
|
@@ -295,7 +298,7 @@ function _defineProperty(e, r, t) {
|
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
//#endregion
|
|
298
|
-
//#region \0@oxc-project+runtime@0.
|
|
301
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
299
302
|
function __decorateParam(paramIndex, decorator) {
|
|
300
303
|
return function(target, key) {
|
|
301
304
|
decorator(target, key, paramIndex);
|
|
@@ -303,7 +306,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
303
306
|
}
|
|
304
307
|
|
|
305
308
|
//#endregion
|
|
306
|
-
//#region \0@oxc-project+runtime@0.
|
|
309
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
307
310
|
function __decorate(decorators, target, key, desc) {
|
|
308
311
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
309
312
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -389,6 +392,37 @@ SheetsTableComponentController = __decorate([
|
|
|
389
392
|
__decorateParam(2, Inject(IDialogService))
|
|
390
393
|
], SheetsTableComponentController);
|
|
391
394
|
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/controllers/mobile/sheet-table-component.controller.ts
|
|
397
|
+
/**
|
|
398
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
399
|
+
*
|
|
400
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
401
|
+
* you may not use this file except in compliance with the License.
|
|
402
|
+
* You may obtain a copy of the License at
|
|
403
|
+
*
|
|
404
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
405
|
+
*
|
|
406
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
407
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
408
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
409
|
+
* See the License for the specific language governing permissions and
|
|
410
|
+
* limitations under the License.
|
|
411
|
+
*/
|
|
412
|
+
var SheetsTableMobileComponentController = class extends SheetsTableComponentController {
|
|
413
|
+
_openFilterPopup() {
|
|
414
|
+
if (!this.getCurrentTableFilterInfo()) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
415
|
+
this._dialogService.open({
|
|
416
|
+
id: UNIVER_SHEET_TABLE_FILTER_PANEL_ID,
|
|
417
|
+
title: { title: "sheets-table-ui.filter.title" },
|
|
418
|
+
children: { label: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY },
|
|
419
|
+
onClose: () => {
|
|
420
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
392
426
|
//#endregion
|
|
393
427
|
//#region src/commands/operations/open-table-filter-dialog.opration.ts
|
|
394
428
|
const OpenTableFilterPanelOperation = {
|
|
@@ -411,6 +445,28 @@ const OpenTableFilterPanelOperation = {
|
|
|
411
445
|
}
|
|
412
446
|
};
|
|
413
447
|
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/commands/operations/mobile/open-table-filter-dialog.operation.ts
|
|
450
|
+
const OpenTableFilterPanelMobileOperation = {
|
|
451
|
+
type: CommandType.OPERATION,
|
|
452
|
+
id: OpenTableFilterPanelOperation.id,
|
|
453
|
+
async handler(accessor, params) {
|
|
454
|
+
if (!params) return false;
|
|
455
|
+
const { row, col, unitId, subUnitId, tableId } = params;
|
|
456
|
+
const tableManager = accessor.get(TableManager);
|
|
457
|
+
const componentController = accessor.get(SheetsTableMobileComponentController);
|
|
458
|
+
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
459
|
+
componentController.openOrToggleFilterPanel({
|
|
460
|
+
unitId,
|
|
461
|
+
subUnitId,
|
|
462
|
+
row,
|
|
463
|
+
tableId,
|
|
464
|
+
column: col
|
|
465
|
+
});
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
|
|
414
470
|
//#endregion
|
|
415
471
|
//#region src/config/config.ts
|
|
416
472
|
const SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY = "sheets-table-ui.config";
|
|
@@ -434,7 +490,7 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
434
490
|
this._registerTableFilterChangeEvent();
|
|
435
491
|
}
|
|
436
492
|
_registerTableFilterChangeEvent() {
|
|
437
|
-
this._commandService.onCommandExecuted((command) => {
|
|
493
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
438
494
|
if (command.id === SetRangeValuesMutation.id) {
|
|
439
495
|
const { unitId, subUnitId, cellValue } = command.params;
|
|
440
496
|
const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);
|
|
@@ -447,20 +503,19 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
447
503
|
});
|
|
448
504
|
if (overlapTable) {
|
|
449
505
|
const colIndex = col - overlapTable.getRange().startColumn;
|
|
450
|
-
this._itemsCache.delete(overlapTable.getId()
|
|
506
|
+
this._itemsCache.delete(this._getItemsCacheKey(unitId, overlapTable.getId(), colIndex));
|
|
451
507
|
}
|
|
452
508
|
});
|
|
453
|
-
} else if (command.id ===
|
|
509
|
+
} else if (command.id === SetSheetTableFilterMutation.id) {
|
|
454
510
|
const { unitId, tableId } = command.params;
|
|
455
511
|
const table = this._tableManager.getTable(unitId, tableId);
|
|
456
512
|
if (!table) return;
|
|
457
513
|
const subUnitId = table.getSubunitId();
|
|
458
514
|
this._tableManager.getTablesBySubunitId(unitId, subUnitId).forEach((table) => {
|
|
459
|
-
|
|
460
|
-
for (let i = range.startColumn; i <= range.endColumn; i++) this._itemsCache.delete(table.getId() + i);
|
|
515
|
+
for (let columnIndex = 0; columnIndex < table.getColumnsCount(); columnIndex++) this._itemsCache.delete(this._getItemsCacheKey(unitId, table.getId(), columnIndex));
|
|
461
516
|
});
|
|
462
517
|
}
|
|
463
|
-
});
|
|
518
|
+
}));
|
|
464
519
|
}
|
|
465
520
|
getTableFilterPanelInitProps(unitId, subUnitId, tableId, column) {
|
|
466
521
|
const table = this._tableManager.getTable(unitId, tableId);
|
|
@@ -480,10 +535,43 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
480
535
|
const checkedItems = [];
|
|
481
536
|
if (table) {
|
|
482
537
|
const filter = table.getTableFilterColumn(columnIndex);
|
|
483
|
-
if (
|
|
538
|
+
if (isManualTableFilter(filter)) checkedItems.push(...filter.values.map((value) => value === TABLE_FILTER_EMPTY_VALUE ? this._localeService.t("sheets-table-ui.condition.empty") : value));
|
|
539
|
+
else if (isRecordTableFilter(filter)) {
|
|
540
|
+
const accepts = compileTableRecordFilter(filter);
|
|
541
|
+
const items = this.getTableFilterItems(unitId, table.getSubunitId(), tableId, columnIndex);
|
|
542
|
+
checkedItems.push(...items.data.filter((item) => item.recordValue && accepts(item.recordValue)).map((item) => item.valueKey));
|
|
543
|
+
}
|
|
484
544
|
}
|
|
485
545
|
return checkedItems;
|
|
486
546
|
}
|
|
547
|
+
createItemFilter(unitId, tableId, columnIndex, items, checkedItemSet, selectAllRequested) {
|
|
548
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
549
|
+
const currentFilter = table === null || table === void 0 ? void 0 : table.getTableFilterColumn(columnIndex);
|
|
550
|
+
if (selectAllRequested) return;
|
|
551
|
+
if (!isRecordTableFilter(currentFilter)) {
|
|
552
|
+
const emptyLabel = this._localeService.t("sheets-table-ui.condition.empty");
|
|
553
|
+
const values = items.data.filter((item) => checkedItemSet.has(item.valueKey ?? item.title)).map((item) => item.title === emptyLabel ? TABLE_FILTER_EMPTY_VALUE : item.title);
|
|
554
|
+
return values.length === items.data.length ? void 0 : {
|
|
555
|
+
filterType: TableColumnFilterTypeEnum.manual,
|
|
556
|
+
values
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
const accepts = compileTableRecordFilter(currentFilter);
|
|
560
|
+
const recordItems = items.data.filter((item) => item.valueKey && item.recordValue);
|
|
561
|
+
if (recordItems.every((item) => checkedItemSet.has(item.valueKey) === accepts(item.recordValue))) return currentFilter;
|
|
562
|
+
const candidateKeys = new Set(recordItems.map((item) => item.valueKey));
|
|
563
|
+
const values = currentFilter.values.filter((value) => !candidateKeys.has(getTableRecordValueKey(value))).map((value) => value.type === RecordValueType.Blank ? { type: RecordValueType.Blank } : { ...value });
|
|
564
|
+
recordItems.forEach((item) => {
|
|
565
|
+
const selected = checkedItemSet.has(item.valueKey);
|
|
566
|
+
if (currentFilter.mode === FilterSelectionMode.Include === selected) values.push(item.recordValue);
|
|
567
|
+
});
|
|
568
|
+
if (currentFilter.mode === FilterSelectionMode.Exclude && values.length === 0) return;
|
|
569
|
+
return {
|
|
570
|
+
filterType: TableColumnFilterTypeEnum.record,
|
|
571
|
+
mode: currentFilter.mode,
|
|
572
|
+
values
|
|
573
|
+
};
|
|
574
|
+
}
|
|
487
575
|
async setTableFilter(unitId, tableId, columnIndex, tableFilter) {
|
|
488
576
|
if (!this._tableManager.getTable(unitId, tableId)) return false;
|
|
489
577
|
const setTableFilterParams = {
|
|
@@ -535,13 +623,14 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
535
623
|
}
|
|
536
624
|
getTableFilterItems(unitId, subUnitId, tableId, columnIndex) {
|
|
537
625
|
var _this$_univerInstance2;
|
|
538
|
-
|
|
626
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
627
|
+
if (!table) return {
|
|
539
628
|
data: [],
|
|
540
629
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
541
630
|
allItemsCount: 0
|
|
542
631
|
};
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
632
|
+
const cacheKey = this._getItemsCacheKey(unitId, tableId, columnIndex);
|
|
633
|
+
if (this._itemsCache.has(cacheKey)) return this._itemsCache.get(cacheKey) || {
|
|
545
634
|
data: [],
|
|
546
635
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
547
636
|
allItemsCount: 0
|
|
@@ -556,21 +645,29 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
556
645
|
};
|
|
557
646
|
const data = [];
|
|
558
647
|
const map = /* @__PURE__ */ new Map();
|
|
648
|
+
const currentFilter = table.getTableFilterColumn(columnIndex);
|
|
649
|
+
const useRecordValues = isRecordTableFilter(currentFilter);
|
|
559
650
|
const filteredRowsByOtherColumns = this._getFilteredRowsByOtherColumns(worksheet, tableId, unitId, columnIndex);
|
|
560
651
|
let allItemsCount = 0;
|
|
561
652
|
for (let row = startRow; row <= endRow; row++) {
|
|
562
653
|
if (filteredRowsByOtherColumns.has(row)) continue;
|
|
563
654
|
let stringItem = this._sheetTableService.getCellValueWithConditionType(worksheet, row, column);
|
|
564
655
|
if (stringItem == null) stringItem = this._localeService.t("sheets-table-ui.condition.empty");
|
|
565
|
-
if (
|
|
656
|
+
if (useRecordValues && typeof stringItem !== "string") stringItem = String(stringItem);
|
|
657
|
+
const recordValue = useRecordValues ? getTableRecordValue(worksheet, row, column) : void 0;
|
|
658
|
+
const valueKey = recordValue ? getTableRecordValueKey(recordValue) : void 0;
|
|
659
|
+
const itemKey = valueKey ?? stringItem;
|
|
660
|
+
if (!map.has(itemKey)) data.push({
|
|
566
661
|
title: stringItem,
|
|
567
|
-
key: `${column}_${row}`,
|
|
568
|
-
leaf: true
|
|
662
|
+
key: valueKey ?? `${column}_${row}`,
|
|
663
|
+
leaf: true,
|
|
664
|
+
valueKey,
|
|
665
|
+
recordValue
|
|
569
666
|
});
|
|
570
667
|
allItemsCount++;
|
|
571
|
-
map.set(
|
|
668
|
+
map.set(itemKey, (map.get(itemKey) || 0) + 1);
|
|
572
669
|
}
|
|
573
|
-
this._itemsCache.set(
|
|
670
|
+
this._itemsCache.set(cacheKey, {
|
|
574
671
|
data,
|
|
575
672
|
itemsCountMap: map,
|
|
576
673
|
allItemsCount
|
|
@@ -581,6 +678,15 @@ let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
|
581
678
|
allItemsCount
|
|
582
679
|
};
|
|
583
680
|
}
|
|
681
|
+
_getItemsCacheKey(unitId, tableId, columnIndex) {
|
|
682
|
+
var _this$_tableManager$g;
|
|
683
|
+
const columnId = (_this$_tableManager$g = this._tableManager.getTable(unitId, tableId)) === null || _this$_tableManager$g === void 0 || (_this$_tableManager$g = _this$_tableManager$g.getTableColumnByIndex(columnIndex)) === null || _this$_tableManager$g === void 0 ? void 0 : _this$_tableManager$g.id;
|
|
684
|
+
return JSON.stringify([
|
|
685
|
+
unitId,
|
|
686
|
+
tableId,
|
|
687
|
+
columnId ?? columnIndex
|
|
688
|
+
]);
|
|
689
|
+
}
|
|
584
690
|
_getFilteredRowsByOtherColumns(worksheet, tableId, unitId, columnIndex) {
|
|
585
691
|
const filteredRows = /* @__PURE__ */ new Set();
|
|
586
692
|
const table = this._tableManager.getTable(unitId, tableId);
|
|
@@ -945,9 +1051,10 @@ const datePickerSet = /* @__PURE__ */ new Set([
|
|
|
945
1051
|
function getSubComponentType(type, compare) {
|
|
946
1052
|
if (!compare) return "None";
|
|
947
1053
|
if (type === TableConditionTypeEnum.String) return "Input";
|
|
948
|
-
else if (type === TableConditionTypeEnum.Number)
|
|
949
|
-
|
|
950
|
-
|
|
1054
|
+
else if (type === TableConditionTypeEnum.Number) {
|
|
1055
|
+
if (compare === TableNumberCompareTypeEnum.Between || compare === TableNumberCompareTypeEnum.NotBetween) return "Inputs";
|
|
1056
|
+
else return "Input";
|
|
1057
|
+
} else if (type === TableConditionTypeEnum.Date) {
|
|
951
1058
|
if (compare === TableDateCompareTypeEnum.Between || compare === TableDateCompareTypeEnum.NotBetween) return "DateRange";
|
|
952
1059
|
else if (compare === TableDateCompareTypeEnum.Quarter || compare === TableDateCompareTypeEnum.Month) return "Select";
|
|
953
1060
|
else if (datePickerSet.has(compare)) return "DatePicker";
|
|
@@ -963,56 +1070,58 @@ function getInitConditionInfo(tableFilter) {
|
|
|
963
1070
|
};
|
|
964
1071
|
const filterInfo = tableFilter.filterInfo;
|
|
965
1072
|
const { conditionType, compareType } = filterInfo;
|
|
966
|
-
if (conditionType === TableConditionTypeEnum.Date)
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1073
|
+
if (conditionType === TableConditionTypeEnum.Date) {
|
|
1074
|
+
if (compareType === TableDateCompareTypeEnum.Between || compareType === TableDateCompareTypeEnum.NotBetween) {
|
|
1075
|
+
let dateRange;
|
|
1076
|
+
if (Array.isArray(filterInfo.expectedValue)) dateRange = filterInfo.expectedValue.map((i) => typeof i === "string" ? new Date(i) : i);
|
|
1077
|
+
return {
|
|
1078
|
+
type: conditionType,
|
|
1079
|
+
compare: compareType,
|
|
1080
|
+
info: { dateRange }
|
|
1081
|
+
};
|
|
1082
|
+
} else if (compareType === TableDateCompareTypeEnum.Today || compareType === TableDateCompareTypeEnum.Yesterday || compareType === TableDateCompareTypeEnum.Tomorrow || compareType === TableDateCompareTypeEnum.ThisWeek || compareType === TableDateCompareTypeEnum.LastWeek || compareType === TableDateCompareTypeEnum.NextWeek || compareType === TableDateCompareTypeEnum.ThisMonth || compareType === TableDateCompareTypeEnum.LastMonth || compareType === TableDateCompareTypeEnum.NextMonth || compareType === TableDateCompareTypeEnum.ThisYear || compareType === TableDateCompareTypeEnum.LastYear || compareType === TableDateCompareTypeEnum.NextYear) return {
|
|
970
1083
|
type: conditionType,
|
|
971
1084
|
compare: compareType,
|
|
972
|
-
info: {
|
|
1085
|
+
info: {}
|
|
973
1086
|
};
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1087
|
+
else if (datePickerSet.has(compareType)) {
|
|
1088
|
+
let date;
|
|
1089
|
+
if (typeof filterInfo.expectedValue === "string") date = new Date(filterInfo.expectedValue);
|
|
1090
|
+
else if (Array.isArray(filterInfo.expectedValue)) {
|
|
1091
|
+
for (let i = 0; i < filterInfo.expectedValue.length; i++) if (typeof filterInfo.expectedValue[i] === "string") filterInfo.expectedValue[i] = new Date(filterInfo.expectedValue[i]);
|
|
1092
|
+
}
|
|
1093
|
+
return {
|
|
1094
|
+
type: conditionType,
|
|
1095
|
+
compare: compareType,
|
|
1096
|
+
info: { date }
|
|
1097
|
+
};
|
|
1098
|
+
} else if ((/* @__PURE__ */ new Set([
|
|
1099
|
+
TableDateCompareTypeEnum.Q1,
|
|
1100
|
+
TableDateCompareTypeEnum.Q2,
|
|
1101
|
+
TableDateCompareTypeEnum.Q3,
|
|
1102
|
+
TableDateCompareTypeEnum.Q4
|
|
1103
|
+
])).has(compareType)) return {
|
|
1104
|
+
type: conditionType,
|
|
1105
|
+
compare: TableDateCompareTypeEnum.Quarter,
|
|
1106
|
+
info: { dateSelect: filterInfo.compareType }
|
|
1107
|
+
};
|
|
1108
|
+
else return {
|
|
1109
|
+
type: conditionType,
|
|
1110
|
+
compare: TableDateCompareTypeEnum.Month,
|
|
1111
|
+
info: { dateSelect: filterInfo.compareType }
|
|
1112
|
+
};
|
|
1113
|
+
} else if (conditionType === TableConditionTypeEnum.Number) {
|
|
1114
|
+
if (compareType === TableNumberCompareTypeEnum.Between || compareType === TableNumberCompareTypeEnum.NotBetween) return {
|
|
986
1115
|
type: conditionType,
|
|
987
1116
|
compare: compareType,
|
|
988
|
-
info: {
|
|
1117
|
+
info: { numberRange: filterInfo.expectedValue }
|
|
989
1118
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
type: conditionType,
|
|
997
|
-
compare: TableDateCompareTypeEnum.Quarter,
|
|
998
|
-
info: { dateSelect: filterInfo.compareType }
|
|
999
|
-
};
|
|
1000
|
-
else return {
|
|
1001
|
-
type: conditionType,
|
|
1002
|
-
compare: TableDateCompareTypeEnum.Month,
|
|
1003
|
-
info: { dateSelect: filterInfo.compareType }
|
|
1004
|
-
};
|
|
1005
|
-
else if (conditionType === TableConditionTypeEnum.Number) if (compareType === TableNumberCompareTypeEnum.Between || compareType === TableNumberCompareTypeEnum.NotBetween) return {
|
|
1006
|
-
type: conditionType,
|
|
1007
|
-
compare: compareType,
|
|
1008
|
-
info: { numberRange: filterInfo.expectedValue }
|
|
1009
|
-
};
|
|
1010
|
-
else return {
|
|
1011
|
-
type: conditionType,
|
|
1012
|
-
compare: compareType,
|
|
1013
|
-
info: { number: filterInfo.expectedValue }
|
|
1014
|
-
};
|
|
1015
|
-
else if (conditionType === TableConditionTypeEnum.String) return {
|
|
1119
|
+
else return {
|
|
1120
|
+
type: conditionType,
|
|
1121
|
+
compare: compareType,
|
|
1122
|
+
info: { number: filterInfo.expectedValue }
|
|
1123
|
+
};
|
|
1124
|
+
} else if (conditionType === TableConditionTypeEnum.String) return {
|
|
1016
1125
|
type: conditionType,
|
|
1017
1126
|
compare: compareType,
|
|
1018
1127
|
info: { string: filterInfo.expectedValue }
|
|
@@ -1046,11 +1155,12 @@ function MobileSheetTableConditionPanel(props) {
|
|
|
1046
1155
|
const compare = value[1];
|
|
1047
1156
|
if (compare) setConditionVisible(false);
|
|
1048
1157
|
const info = {};
|
|
1049
|
-
if (type === TableConditionTypeEnum.Date)
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1158
|
+
if (type === TableConditionTypeEnum.Date) {
|
|
1159
|
+
if (compare === TableDateCompareTypeEnum.Quarter) info.dateSelect = TableDateCompareTypeEnum.Q1;
|
|
1160
|
+
else if (compare === TableDateCompareTypeEnum.Month) info.dateSelect = TableDateCompareTypeEnum.M1;
|
|
1161
|
+
else if (datePickerSet.has(compare)) info.date = /* @__PURE__ */ new Date();
|
|
1162
|
+
else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
1163
|
+
} else if (type === TableConditionTypeEnum.Number) info.number = 0;
|
|
1054
1164
|
else if (type === TableConditionTypeEnum.String) info.string = "";
|
|
1055
1165
|
handleConditionInfo(info, type, compare ?? TableStringCompareTypeEnum.Equal);
|
|
1056
1166
|
}
|
|
@@ -1145,28 +1255,33 @@ function MobileSheetTableConditionPanel(props) {
|
|
|
1145
1255
|
//#endregion
|
|
1146
1256
|
//#region src/views/components/MobileSheetTableItemsFilterPanel.tsx
|
|
1147
1257
|
function MobileSheetTableItemsFilterPanel(props) {
|
|
1148
|
-
const { items, checkedItemSet, setCheckedItemSet } = props;
|
|
1258
|
+
const { items, checkedItemSet, setCheckedItemSet, onSelectAllChange, onItemChange } = props;
|
|
1149
1259
|
const localeService = useDependency(LocaleService);
|
|
1150
1260
|
const [searchText, setSearchText] = useState("");
|
|
1151
1261
|
const displayItems = useMemo(() => {
|
|
1152
1262
|
const normalizedSearchText = searchText.toLowerCase();
|
|
1153
1263
|
return normalizedSearchText ? items.data.filter((item) => String(item.title).toLowerCase().includes(normalizedSearchText)) : items.data;
|
|
1154
1264
|
}, [items.data, searchText]);
|
|
1155
|
-
const allDisplayedChecked = displayItems.length > 0 && displayItems.every((item) => checkedItemSet.has(item.title));
|
|
1156
|
-
const someDisplayedChecked = displayItems.some((item) => checkedItemSet.has(item.title));
|
|
1265
|
+
const allDisplayedChecked = displayItems.length > 0 && displayItems.every((item) => checkedItemSet.has(item.valueKey ?? item.title));
|
|
1266
|
+
const someDisplayedChecked = displayItems.some((item) => checkedItemSet.has(item.valueKey ?? item.title));
|
|
1157
1267
|
function toggleAllDisplayed() {
|
|
1158
1268
|
setCheckedItemSet((current) => {
|
|
1159
1269
|
const next = new Set(current);
|
|
1160
|
-
for (const item of displayItems)
|
|
1161
|
-
|
|
1270
|
+
for (const item of displayItems) {
|
|
1271
|
+
const itemKey = item.valueKey ?? item.title;
|
|
1272
|
+
if (allDisplayedChecked) next.delete(itemKey);
|
|
1273
|
+
else next.add(itemKey);
|
|
1274
|
+
}
|
|
1162
1275
|
return next;
|
|
1163
1276
|
});
|
|
1277
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(!allDisplayedChecked && searchText === "");
|
|
1164
1278
|
}
|
|
1165
|
-
function toggleItem(
|
|
1279
|
+
function toggleItem(itemKey) {
|
|
1280
|
+
onItemChange === null || onItemChange === void 0 || onItemChange();
|
|
1166
1281
|
setCheckedItemSet((current) => {
|
|
1167
1282
|
const next = new Set(current);
|
|
1168
|
-
if (next.has(
|
|
1169
|
-
else next.add(
|
|
1283
|
+
if (next.has(itemKey)) next.delete(itemKey);
|
|
1284
|
+
else next.add(itemKey);
|
|
1170
1285
|
return next;
|
|
1171
1286
|
});
|
|
1172
1287
|
}
|
|
@@ -1189,24 +1304,27 @@ function MobileSheetTableItemsFilterPanel(props) {
|
|
|
1189
1304
|
onChange: toggleAllDisplayed,
|
|
1190
1305
|
children: localeService.t("sheets-table-ui.filter.select-all")
|
|
1191
1306
|
})
|
|
1192
|
-
}), displayItems.map((item) =>
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
className: "univer-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
children:
|
|
1201
|
-
className: "univer-min-w-0 univer-flex-1 univer-
|
|
1202
|
-
children:
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1307
|
+
}), displayItems.map((item) => {
|
|
1308
|
+
const itemKey = item.valueKey ?? item.title;
|
|
1309
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1310
|
+
className: "univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-px-4 last:univer-border-b-0 dark:!univer-border-gray-700",
|
|
1311
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1312
|
+
className: "univer-flex univer-min-h-12 univer-items-center",
|
|
1313
|
+
checked: checkedItemSet.has(itemKey),
|
|
1314
|
+
onChange: () => toggleItem(itemKey),
|
|
1315
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
1316
|
+
className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-2",
|
|
1317
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1318
|
+
className: "univer-min-w-0 univer-flex-1 univer-truncate",
|
|
1319
|
+
children: item.title
|
|
1320
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1321
|
+
className: "univer-shrink-0 univer-text-gray-400",
|
|
1322
|
+
children: `(${items.itemsCountMap.get(itemKey) ?? 0})`
|
|
1323
|
+
})]
|
|
1324
|
+
})
|
|
1207
1325
|
})
|
|
1208
|
-
})
|
|
1209
|
-
}
|
|
1326
|
+
}, item.key);
|
|
1327
|
+
})]
|
|
1210
1328
|
})]
|
|
1211
1329
|
});
|
|
1212
1330
|
}
|
|
@@ -1228,7 +1346,7 @@ const FILTER_BY_OPTIONS$1 = [
|
|
|
1228
1346
|
}
|
|
1229
1347
|
];
|
|
1230
1348
|
function MobileSheetTableFilterPanel() {
|
|
1231
|
-
const tableFilterPanelInfo = useDependency(
|
|
1349
|
+
const tableFilterPanelInfo = useDependency(SheetsTableMobileComponentController).getCurrentTableFilterInfo();
|
|
1232
1350
|
if (!tableFilterPanelInfo) return null;
|
|
1233
1351
|
return /* @__PURE__ */ jsx(MobileSheetTableFilterPanelContent, { tableFilterPanelInfo });
|
|
1234
1352
|
}
|
|
@@ -1241,7 +1359,7 @@ function MobileSheetTableFilterPanelContent(props) {
|
|
|
1241
1359
|
const commandService = useDependency(ICommandService);
|
|
1242
1360
|
const permissionService = useDependency(IPermissionService);
|
|
1243
1361
|
const undoRedoService = useDependency(IUndoRedoService);
|
|
1244
|
-
const sheetsTableComponentController = useDependency(
|
|
1362
|
+
const sheetsTableComponentController = useDependency(SheetsTableMobileComponentController);
|
|
1245
1363
|
const [detailFilterBy, setDetailFilterBy] = useState(null);
|
|
1246
1364
|
const [drawerSnap, setDrawerSnap] = useState("expanded");
|
|
1247
1365
|
const layerRef = useRef(null);
|
|
@@ -1249,7 +1367,8 @@ function MobileSheetTableFilterPanelContent(props) {
|
|
|
1249
1367
|
const currentTable = tableManager.getTable(unitId, tableId);
|
|
1250
1368
|
const items = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
1251
1369
|
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
1252
|
-
const [checkedItemSet, setCheckedItemSet] = useState(() => new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.manual ? checkedItems : items.data.map((item) => item.title)));
|
|
1370
|
+
const [checkedItemSet, setCheckedItemSet] = useState(() => new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.manual || (tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.record ? checkedItems : items.data.map((item) => item.valueKey ?? item.title)));
|
|
1371
|
+
const [selectAllRequested, setSelectAllRequested] = useState(false);
|
|
1253
1372
|
const [conditionInfo, setConditionInfo] = useState(() => getInitConditionInfo(tableFilter));
|
|
1254
1373
|
const [colors, setColors] = useState(() => tableUiService.getTableFilterColors(unitId, subUnitId, tableId, columnIndex));
|
|
1255
1374
|
const tableRange = currentTable.getRange();
|
|
@@ -1306,14 +1425,8 @@ function MobileSheetTableFilterPanelContent(props) {
|
|
|
1306
1425
|
}
|
|
1307
1426
|
async function applyFilter() {
|
|
1308
1427
|
let filter;
|
|
1309
|
-
if (detailFilterBy === "items")
|
|
1310
|
-
|
|
1311
|
-
const values = items.data.filter((item) => checkedItemSet.has(item.title)).map((item) => item.title === emptyLabel ? TABLE_FILTER_EMPTY_VALUE : item.title);
|
|
1312
|
-
filter = values.length === items.data.length ? void 0 : {
|
|
1313
|
-
filterType: TableColumnFilterTypeEnum.manual,
|
|
1314
|
-
values
|
|
1315
|
-
};
|
|
1316
|
-
} else if (detailFilterBy === "color") {
|
|
1428
|
+
if (detailFilterBy === "items") filter = tableUiService.createItemFilter(unitId, tableId, columnIndex, items, checkedItemSet, selectAllRequested);
|
|
1429
|
+
else if (detailFilterBy === "color") {
|
|
1317
1430
|
const cellFillColors = colors.cellFillColors.filter((item) => item.checked).map((item) => item.color);
|
|
1318
1431
|
const cellTextColors = colors.cellTextColors.filter((item) => item.checked).map((item) => item.color);
|
|
1319
1432
|
if (cellFillColors.length) filter = {
|
|
@@ -1341,8 +1454,10 @@ function MobileSheetTableFilterPanelContent(props) {
|
|
|
1341
1454
|
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, void 0)) closePanel();
|
|
1342
1455
|
}
|
|
1343
1456
|
function openDetail(filterBy) {
|
|
1344
|
-
if (filterBy === "items")
|
|
1345
|
-
|
|
1457
|
+
if (filterBy === "items") {
|
|
1458
|
+
setCheckedItemSet(new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.manual || (tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.record ? checkedItems : items.data.map((item) => item.valueKey ?? item.title)));
|
|
1459
|
+
setSelectAllRequested(false);
|
|
1460
|
+
} else if (filterBy === "color") setColors(tableUiService.getTableFilterColors(unitId, subUnitId, tableId, columnIndex));
|
|
1346
1461
|
else if (filterBy === "condition") setConditionInfo(getInitConditionInfo(tableFilter));
|
|
1347
1462
|
setDetailFilterBy(filterBy);
|
|
1348
1463
|
setDrawerSnap("expanded");
|
|
@@ -1399,7 +1514,9 @@ function MobileSheetTableFilterPanelContent(props) {
|
|
|
1399
1514
|
detailFilterBy === "items" && /* @__PURE__ */ jsx(MobileSheetTableItemsFilterPanel, {
|
|
1400
1515
|
items,
|
|
1401
1516
|
checkedItemSet,
|
|
1402
|
-
setCheckedItemSet
|
|
1517
|
+
setCheckedItemSet,
|
|
1518
|
+
onSelectAllChange: setSelectAllRequested,
|
|
1519
|
+
onItemChange: () => setSelectAllRequested(false)
|
|
1403
1520
|
}),
|
|
1404
1521
|
detailFilterBy === "color" && /* @__PURE__ */ jsx(MobileSheetTableColorFilterPanel, {
|
|
1405
1522
|
colors,
|
|
@@ -1475,6 +1592,7 @@ const ACTIONS = [
|
|
|
1475
1592
|
"rename",
|
|
1476
1593
|
"update-range",
|
|
1477
1594
|
"set-theme",
|
|
1595
|
+
"settings",
|
|
1478
1596
|
"delete"
|
|
1479
1597
|
];
|
|
1480
1598
|
function MobileSheetTableMenu({ menu }) {
|
|
@@ -1682,6 +1800,198 @@ function MobileSheetTableSelector(props) {
|
|
|
1682
1800
|
});
|
|
1683
1801
|
}
|
|
1684
1802
|
|
|
1803
|
+
//#endregion
|
|
1804
|
+
//#region src/views/components/SheetTableCalculatedColumn.tsx
|
|
1805
|
+
function SheetTableCalculatedColumn({ unitId, tableId }) {
|
|
1806
|
+
var _columns$, _columns$2, _table$getColumn2;
|
|
1807
|
+
const localeService = useDependency(LocaleService);
|
|
1808
|
+
const commands = useDependency(ICommandService);
|
|
1809
|
+
const table = useDependency(TableManager).getTableById(unitId, tableId);
|
|
1810
|
+
const columns = (table === null || table === void 0 ? void 0 : table.getTableInfo().columns) ?? [];
|
|
1811
|
+
const [columnId, setColumnId] = useState(((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.id) ?? "");
|
|
1812
|
+
const [formula, setFormula] = useState(((_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.formula) ?? "");
|
|
1813
|
+
const [result, setResult] = useState();
|
|
1814
|
+
const range = table === null || table === void 0 ? void 0 : table.getTableFilterRange();
|
|
1815
|
+
const apply = (value) => {
|
|
1816
|
+
try {
|
|
1817
|
+
const success = commands.syncExecuteCommand(SetSheetTableCommand.id, {
|
|
1818
|
+
unitId,
|
|
1819
|
+
tableId,
|
|
1820
|
+
calculatedColumn: {
|
|
1821
|
+
columnId,
|
|
1822
|
+
formula: value
|
|
1823
|
+
}
|
|
1824
|
+
});
|
|
1825
|
+
setResult(success);
|
|
1826
|
+
if (success) setFormula(value);
|
|
1827
|
+
} catch {
|
|
1828
|
+
setResult(false);
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
1832
|
+
className: "univer-m-0 univer-min-w-0 univer-border-0 univer-p-0",
|
|
1833
|
+
disabled: !table,
|
|
1834
|
+
children: [
|
|
1835
|
+
/* @__PURE__ */ jsx("legend", {
|
|
1836
|
+
className: "univer-mb-2 univer-text-sm",
|
|
1837
|
+
children: localeService.t("sheets-table-ui.calculatedColumn")
|
|
1838
|
+
}),
|
|
1839
|
+
/* @__PURE__ */ jsx(Select, {
|
|
1840
|
+
className: "univer-w-full",
|
|
1841
|
+
options: columns.map((column) => ({
|
|
1842
|
+
value: column.id,
|
|
1843
|
+
label: column.displayName
|
|
1844
|
+
})),
|
|
1845
|
+
value: columnId,
|
|
1846
|
+
onChange: (id) => {
|
|
1847
|
+
var _table$getColumn;
|
|
1848
|
+
setColumnId(id);
|
|
1849
|
+
setFormula((table === null || table === void 0 || (_table$getColumn = table.getColumn(id)) === null || _table$getColumn === void 0 ? void 0 : _table$getColumn.formula) ?? "");
|
|
1850
|
+
setResult(void 0);
|
|
1851
|
+
}
|
|
1852
|
+
}),
|
|
1853
|
+
/* @__PURE__ */ jsx(FormLayout, {
|
|
1854
|
+
label: localeService.t("sheets-table-ui.columnFormula"),
|
|
1855
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
1856
|
+
value: formula,
|
|
1857
|
+
onChange: (value) => {
|
|
1858
|
+
setFormula(value);
|
|
1859
|
+
setResult(void 0);
|
|
1860
|
+
}
|
|
1861
|
+
})
|
|
1862
|
+
}),
|
|
1863
|
+
/* @__PURE__ */ jsx("p", {
|
|
1864
|
+
className: "univer-text-sm univer-text-gray-500",
|
|
1865
|
+
children: localeService.t("sheets-table-ui.columnFormulaHint", String(Math.max(0, ((range === null || range === void 0 ? void 0 : range.endRow) ?? -1) - ((range === null || range === void 0 ? void 0 : range.startRow) ?? 0) + 1)))
|
|
1866
|
+
}),
|
|
1867
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1868
|
+
className: "univer-flex univer-flex-wrap univer-gap-2",
|
|
1869
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1870
|
+
disabled: !columnId || !formula.trim(),
|
|
1871
|
+
onClick: () => apply(formula),
|
|
1872
|
+
children: localeService.t("sheets-table-ui.applyColumnFormula")
|
|
1873
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1874
|
+
disabled: !(table === null || table === void 0 || (_table$getColumn2 = table.getColumn(columnId)) === null || _table$getColumn2 === void 0 ? void 0 : _table$getColumn2.formula),
|
|
1875
|
+
onClick: () => apply(""),
|
|
1876
|
+
children: localeService.t("sheets-table-ui.stopColumnFormula")
|
|
1877
|
+
})]
|
|
1878
|
+
}),
|
|
1879
|
+
result !== void 0 && /* @__PURE__ */ jsx("p", {
|
|
1880
|
+
role: result ? "status" : "alert",
|
|
1881
|
+
className: "univer-text-sm",
|
|
1882
|
+
children: localeService.t(result ? "sheets-table-ui.columnFormulaApplied" : "sheets-table-ui.settingsError")
|
|
1883
|
+
})
|
|
1884
|
+
]
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
//#endregion
|
|
1889
|
+
//#region src/views/components/SheetTableSettingsDialog.tsx
|
|
1890
|
+
function SheetTableSettingsDialog(props) {
|
|
1891
|
+
const { unitId, tableId, onClose, ActionRowComponent = ActionRow } = props;
|
|
1892
|
+
const localeService = useDependency(LocaleService);
|
|
1893
|
+
const commandService = useDependency(ICommandService);
|
|
1894
|
+
const tableManager = useDependency(TableManager);
|
|
1895
|
+
const [initial] = useState(() => {
|
|
1896
|
+
var _tableManager$getTabl;
|
|
1897
|
+
return (_tableManager$getTabl = tableManager.getTableById(unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getTableInfo();
|
|
1898
|
+
});
|
|
1899
|
+
const [showAutoFilter, setShowAutoFilter] = useState((initial === null || initial === void 0 ? void 0 : initial.showAutoFilter) ?? true);
|
|
1900
|
+
const [columns, setColumns] = useState(() => Object.fromEntries(((initial === null || initial === void 0 ? void 0 : initial.columns) ?? []).map((column) => [column.id, column.showFilterButton !== false])));
|
|
1901
|
+
const [saving, setSaving] = useState(false);
|
|
1902
|
+
const [error, setError] = useState(false);
|
|
1903
|
+
const handleConfirm = async () => {
|
|
1904
|
+
if (!initial || saving) return;
|
|
1905
|
+
const changedColumns = Object.fromEntries(initial.columns.filter((column) => columns[column.id] !== (column.showFilterButton !== false)).map((column) => [column.id, columns[column.id]]));
|
|
1906
|
+
if (showAutoFilter === initial.showAutoFilter && Object.keys(changedColumns).length === 0) {
|
|
1907
|
+
onClose();
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
setSaving(true);
|
|
1911
|
+
setError(false);
|
|
1912
|
+
try {
|
|
1913
|
+
if (await commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1914
|
+
unitId,
|
|
1915
|
+
tableId,
|
|
1916
|
+
filterButtons: {
|
|
1917
|
+
...showAutoFilter === initial.showAutoFilter ? {} : { showAutoFilter },
|
|
1918
|
+
columns: changedColumns
|
|
1919
|
+
}
|
|
1920
|
+
})) onClose();
|
|
1921
|
+
else setError(true);
|
|
1922
|
+
} catch {
|
|
1923
|
+
setError(true);
|
|
1924
|
+
} finally {
|
|
1925
|
+
setSaving(false);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1929
|
+
className: "univer-flex univer-flex-col univer-gap-4 univer-py-2",
|
|
1930
|
+
children: [
|
|
1931
|
+
/* @__PURE__ */ jsx(Checkbox, {
|
|
1932
|
+
checked: showAutoFilter,
|
|
1933
|
+
disabled: saving || !initial,
|
|
1934
|
+
onChange: (value) => setShowAutoFilter(Boolean(value)),
|
|
1935
|
+
children: localeService.t("sheets-table-ui.showFilterButtons")
|
|
1936
|
+
}),
|
|
1937
|
+
/* @__PURE__ */ jsx("p", {
|
|
1938
|
+
className: "univer-m-0 univer-text-sm univer-text-gray-500",
|
|
1939
|
+
children: localeService.t("sheets-table-ui.filterButtonsHint")
|
|
1940
|
+
}),
|
|
1941
|
+
/* @__PURE__ */ jsxs("fieldset", {
|
|
1942
|
+
className: "univer-m-0 univer-min-w-0 univer-border-0 univer-p-0",
|
|
1943
|
+
disabled: !showAutoFilter || saving,
|
|
1944
|
+
children: [/* @__PURE__ */ jsx("legend", {
|
|
1945
|
+
className: "univer-mb-2 univer-text-sm",
|
|
1946
|
+
children: localeService.t("sheets-table-ui.columnFilterButtons")
|
|
1947
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1948
|
+
className: "univer-flex univer-max-h-64 univer-flex-col univer-gap-2 univer-overflow-y-auto",
|
|
1949
|
+
children: initial === null || initial === void 0 ? void 0 : initial.columns.map((column) => /* @__PURE__ */ jsx(Checkbox, {
|
|
1950
|
+
checked: columns[column.id],
|
|
1951
|
+
disabled: !showAutoFilter || saving,
|
|
1952
|
+
onChange: (value) => setColumns((previous) => ({
|
|
1953
|
+
...previous,
|
|
1954
|
+
[column.id]: Boolean(value)
|
|
1955
|
+
})),
|
|
1956
|
+
children: column.displayName
|
|
1957
|
+
}, column.id))
|
|
1958
|
+
})]
|
|
1959
|
+
}),
|
|
1960
|
+
/* @__PURE__ */ jsx(SheetTableCalculatedColumn, {
|
|
1961
|
+
unitId,
|
|
1962
|
+
tableId
|
|
1963
|
+
}),
|
|
1964
|
+
error && /* @__PURE__ */ jsx("div", {
|
|
1965
|
+
role: "alert",
|
|
1966
|
+
className: "univer-text-sm univer-text-red-500",
|
|
1967
|
+
children: localeService.t("sheets-table-ui.settingsError")
|
|
1968
|
+
}),
|
|
1969
|
+
/* @__PURE__ */ jsxs(ActionRowComponent, {
|
|
1970
|
+
className: "univer-flex univer-justify-end univer-gap-2",
|
|
1971
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1972
|
+
disabled: saving,
|
|
1973
|
+
onClick: onClose,
|
|
1974
|
+
children: localeService.t("sheets-table-ui.cancel")
|
|
1975
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1976
|
+
variant: "primary",
|
|
1977
|
+
disabled: saving || !initial,
|
|
1978
|
+
onClick: handleConfirm,
|
|
1979
|
+
children: localeService.t("sheets-table-ui.confirm")
|
|
1980
|
+
})]
|
|
1981
|
+
})
|
|
1982
|
+
]
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
//#endregion
|
|
1987
|
+
//#region src/views/components/MobileSheetTableSettingsDialog.tsx
|
|
1988
|
+
function MobileSheetTableSettingsDialog(props) {
|
|
1989
|
+
return /* @__PURE__ */ jsx(SheetTableSettingsDialog, {
|
|
1990
|
+
...props,
|
|
1991
|
+
ActionRowComponent: MobileActionRowGroup
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1685
1995
|
//#endregion
|
|
1686
1996
|
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1687
1997
|
let SheetTableThemeUIController = class SheetTableThemeUIController extends Disposable {
|
|
@@ -1750,7 +2060,10 @@ const SheetTableThemePanel = (props) => {
|
|
|
1750
2060
|
}
|
|
1751
2061
|
const lastCustomTheme = customRangeThemes[customRangeThemes.length - 1];
|
|
1752
2062
|
let newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}1`;
|
|
1753
|
-
if (lastCustomTheme)
|
|
2063
|
+
if (lastCustomTheme) {
|
|
2064
|
+
const index = Number(lastCustomTheme.split("-")[2]);
|
|
2065
|
+
newThemeName = `${TABLE_CUSTOM_NAME_PREFIX}${index + 1}`;
|
|
2066
|
+
}
|
|
1754
2067
|
const newTheme = new RangeThemeStyle(newThemeName, { ...customEmptyThemeWithBorderStyle });
|
|
1755
2068
|
commandService.executeCommand(AddTableThemeCommand.id, {
|
|
1756
2069
|
unitId,
|
|
@@ -2003,6 +2316,7 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
|
|
|
2003
2316
|
[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, MobileSheetTableFilterPanel],
|
|
2004
2317
|
[SHEET_TABLE_MOBILE_MENU, MobileSheetTableMenu],
|
|
2005
2318
|
[SHEET_TABLE_RENAME_DIALOG, MobileSheetTableRenameDialog],
|
|
2319
|
+
[SHEET_TABLE_SETTINGS_DIALOG, MobileSheetTableSettingsDialog],
|
|
2006
2320
|
[TABLE_SELECTOR_DIALOG, MobileSheetTableSelector],
|
|
2007
2321
|
[SHEET_TABLE_THEME_PANEL, MobileSheetTableThemePanel]
|
|
2008
2322
|
].forEach(([key, component]) => {
|
|
@@ -2013,37 +2327,6 @@ let MobileComponentsController = class MobileComponentsController extends Dispos
|
|
|
2013
2327
|
};
|
|
2014
2328
|
MobileComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], MobileComponentsController);
|
|
2015
2329
|
|
|
2016
|
-
//#endregion
|
|
2017
|
-
//#region src/controllers/mobile/sheet-table-component.controller.ts
|
|
2018
|
-
/**
|
|
2019
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2020
|
-
*
|
|
2021
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2022
|
-
* you may not use this file except in compliance with the License.
|
|
2023
|
-
* You may obtain a copy of the License at
|
|
2024
|
-
*
|
|
2025
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2026
|
-
*
|
|
2027
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2028
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2029
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2030
|
-
* See the License for the specific language governing permissions and
|
|
2031
|
-
* limitations under the License.
|
|
2032
|
-
*/
|
|
2033
|
-
var SheetsTableMobileComponentController = class extends SheetsTableComponentController {
|
|
2034
|
-
_openFilterPopup() {
|
|
2035
|
-
if (!this.getCurrentTableFilterInfo()) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
2036
|
-
this._dialogService.open({
|
|
2037
|
-
id: UNIVER_SHEET_TABLE_FILTER_PANEL_ID,
|
|
2038
|
-
title: { title: "sheets-table-ui.filter.title" },
|
|
2039
|
-
children: { label: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY },
|
|
2040
|
-
onClose: () => {
|
|
2041
|
-
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
};
|
|
2046
|
-
|
|
2047
2330
|
//#endregion
|
|
2048
2331
|
//#region src/views/widgets/table-controls-util.ts
|
|
2049
2332
|
function isPointInTableControlRegion(region, x, y) {
|
|
@@ -2161,7 +2444,7 @@ var SheetTableControlsShape = class extends Shape {
|
|
|
2161
2444
|
const left = position.startX;
|
|
2162
2445
|
const rawTop = position.startY - 28 - ANCHOR_OFFSET_Y;
|
|
2163
2446
|
const top = Math.max(0, rawTop);
|
|
2164
|
-
const width = Math.max(ANCHOR_MIN_WIDTH, Math.min(ANCHOR_MAX_WIDTH, item.tableName.length * 8.5 +
|
|
2447
|
+
const width = Math.max(ANCHOR_MIN_WIDTH, Math.min(ANCHOR_MAX_WIDTH, item.tableName.length * 8.5 + 24 + ANCHOR_TOGGLE_WIDTH));
|
|
2165
2448
|
const toggleRegion = {
|
|
2166
2449
|
type: "anchor-menu-toggle",
|
|
2167
2450
|
tableId: item.tableId,
|
|
@@ -2313,6 +2596,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2313
2596
|
_defineProperty(this, "_shape", void 0);
|
|
2314
2597
|
_defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
|
|
2315
2598
|
_defineProperty(this, "_menuPopup", null);
|
|
2599
|
+
_defineProperty(this, "_settingsDialog", null);
|
|
2316
2600
|
this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
|
|
2317
2601
|
this._initShape();
|
|
2318
2602
|
this._initRefresh();
|
|
@@ -2322,7 +2606,10 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2322
2606
|
var _this$_context$compon;
|
|
2323
2607
|
this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
|
|
2324
2608
|
this.disposeWithMe(toDisposable(() => {
|
|
2609
|
+
var _this$_settingsDialog;
|
|
2325
2610
|
this._closeFloatingControls();
|
|
2611
|
+
(_this$_settingsDialog = this._settingsDialog) === null || _this$_settingsDialog === void 0 || _this$_settingsDialog.dispose();
|
|
2612
|
+
this._settingsDialog = null;
|
|
2326
2613
|
this._context.scene.removeObjects([this._shape]);
|
|
2327
2614
|
}));
|
|
2328
2615
|
this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
|
|
@@ -2475,6 +2762,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2475
2762
|
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
2476
2763
|
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
2477
2764
|
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
2765
|
+
settings: this._localeService.t("sheets-table-ui.settings"),
|
|
2478
2766
|
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
2479
2767
|
},
|
|
2480
2768
|
onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
|
|
@@ -2500,6 +2788,9 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2500
2788
|
_handleTableMenuAction(action, unitId, subUnitId, tableId) {
|
|
2501
2789
|
this._closeFloatingControls();
|
|
2502
2790
|
switch (action) {
|
|
2791
|
+
case "settings":
|
|
2792
|
+
this._openSettingsDialog(unitId, tableId);
|
|
2793
|
+
break;
|
|
2503
2794
|
case "rename":
|
|
2504
2795
|
this._openRenameDialog(unitId, tableId);
|
|
2505
2796
|
break;
|
|
@@ -2507,15 +2798,34 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2507
2798
|
case "set-theme":
|
|
2508
2799
|
this._openThemePanel(unitId, subUnitId, tableId);
|
|
2509
2800
|
break;
|
|
2510
|
-
case "delete":
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
});
|
|
2516
|
-
break;
|
|
2801
|
+
case "delete": this._commandService.executeCommand(DeleteSheetTableCommand.id, {
|
|
2802
|
+
tableId,
|
|
2803
|
+
subUnitId,
|
|
2804
|
+
unitId
|
|
2805
|
+
});
|
|
2517
2806
|
}
|
|
2518
2807
|
}
|
|
2808
|
+
_openSettingsDialog(unitId, tableId) {
|
|
2809
|
+
var _this$_settingsDialog2;
|
|
2810
|
+
(_this$_settingsDialog2 = this._settingsDialog) === null || _this$_settingsDialog2 === void 0 || _this$_settingsDialog2.dispose();
|
|
2811
|
+
this._dialogService.open({
|
|
2812
|
+
id: SHEET_TABLE_SETTINGS_DIALOG_ID,
|
|
2813
|
+
title: { title: this._localeService.t("sheets-table-ui.settings") },
|
|
2814
|
+
draggable: true,
|
|
2815
|
+
mask: true,
|
|
2816
|
+
children: { label: {
|
|
2817
|
+
name: SHEET_TABLE_SETTINGS_DIALOG,
|
|
2818
|
+
props: {
|
|
2819
|
+
unitId,
|
|
2820
|
+
tableId,
|
|
2821
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_SETTINGS_DIALOG_ID)
|
|
2822
|
+
}
|
|
2823
|
+
} },
|
|
2824
|
+
width: 400,
|
|
2825
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_SETTINGS_DIALOG_ID)
|
|
2826
|
+
});
|
|
2827
|
+
this._settingsDialog = toDisposable(() => this._dialogService.close(SHEET_TABLE_SETTINGS_DIALOG_ID));
|
|
2828
|
+
}
|
|
2519
2829
|
_openRenameDialog(unitId, tableId) {
|
|
2520
2830
|
this._dialogService.open({
|
|
2521
2831
|
id: SHEET_TABLE_RENAME_DIALOG_ID,
|
|
@@ -2694,6 +3004,7 @@ var SheetTableControlsMobileRenderController = class extends SheetTableControlsR
|
|
|
2694
3004
|
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
2695
3005
|
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
2696
3006
|
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
3007
|
+
settings: this._localeService.t("sheets-table-ui.settings"),
|
|
2697
3008
|
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
2698
3009
|
},
|
|
2699
3010
|
onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
|
|
@@ -2768,16 +3079,15 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Sh
|
|
|
2768
3079
|
}
|
|
2769
3080
|
_drawChevron(ctx, color) {
|
|
2770
3081
|
const centerX = 16 / 2;
|
|
2771
|
-
const centerY = 16 / 2;
|
|
2772
3082
|
ctx.save();
|
|
2773
3083
|
ctx.beginPath();
|
|
2774
3084
|
ctx.strokeStyle = color;
|
|
2775
3085
|
ctx.lineWidth = 1.8;
|
|
2776
3086
|
ctx.lineCap = "round";
|
|
2777
3087
|
ctx.lineJoin = "round";
|
|
2778
|
-
ctx.moveTo(
|
|
3088
|
+
ctx.moveTo(3.5, 5.5);
|
|
2779
3089
|
ctx.lineTo(centerX, 10);
|
|
2780
|
-
ctx.lineTo(12.5,
|
|
3090
|
+
ctx.lineTo(12.5, 5.5);
|
|
2781
3091
|
ctx.stroke();
|
|
2782
3092
|
ctx.restore();
|
|
2783
3093
|
}
|
|
@@ -2860,7 +3170,12 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
2860
3170
|
_initCommandExecuted() {
|
|
2861
3171
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
2862
3172
|
var _workbook$getActiveSh2;
|
|
2863
|
-
if (command.id !== SetVerticalTextAlignCommand.id) return;
|
|
3173
|
+
if (command.id !== SetVerticalTextAlignCommand.id && command.id !== SetSheetTableMutation.id) return;
|
|
3174
|
+
if (command.id === SetSheetTableMutation.id) {
|
|
3175
|
+
var _this$_context$unit$g;
|
|
3176
|
+
const params = command.params;
|
|
3177
|
+
if (!(params === null || params === void 0 ? void 0 : params.config.filterButtons) || params.unitId !== this._context.unitId || params.subUnitId !== ((_this$_context$unit$g = this._context.unit.getActiveSheet()) === null || _this$_context$unit$g === void 0 ? void 0 : _this$_context$unit$g.getSheetId())) return;
|
|
3178
|
+
}
|
|
2864
3179
|
const { unit: workbook, unitId } = this._context;
|
|
2865
3180
|
const worksheetId = ((_workbook$getActiveSh2 = workbook.getActiveSheet()) === null || _workbook$getActiveSh2 === void 0 ? void 0 : _workbook$getActiveSh2.getSheetId()) || "";
|
|
2866
3181
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
@@ -2888,8 +3203,14 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
2888
3203
|
const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
|
|
2889
3204
|
const iconColor = (headerStyle === null || headerStyle === void 0 || (_headerStyle$cl = headerStyle.cl) === null || _headerStyle$cl === void 0 ? void 0 : _headerStyle$cl.rgb) ?? "#fff";
|
|
2890
3205
|
const hoverIconColor = (headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) ?? "#202124";
|
|
2891
|
-
|
|
3206
|
+
const visibleColumns = /* @__PURE__ */ new Set();
|
|
3207
|
+
for (let col = startColumn; col <= endColumn; col++) {
|
|
3208
|
+
var _table$getTableColumn;
|
|
3209
|
+
if ((table === null || table === void 0 || (_table$getTableColumn = table.getTableColumnByIndex(col - startColumn)) === null || _table$getTableColumn === void 0 ? void 0 : _table$getTableColumn.isShowFilterButton()) !== false) visibleColumns.add(col);
|
|
3210
|
+
}
|
|
3211
|
+
this._interceptCellContent(unitId, worksheetId, range, visibleColumns);
|
|
2892
3212
|
for (let col = startColumn; col <= endColumn; col++) {
|
|
3213
|
+
if (!visibleColumns.has(col)) continue;
|
|
2893
3214
|
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
2894
3215
|
const startPosition = getCoordByCell(startRow, col, scene, skeleton);
|
|
2895
3216
|
const cellStyle = worksheet.getCellStyle(startRow, col);
|
|
@@ -2926,13 +3247,13 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
2926
3247
|
scene.addObjects(this._tableFilterButtonShapes);
|
|
2927
3248
|
scene.makeDirty();
|
|
2928
3249
|
}
|
|
2929
|
-
_interceptCellContent(workbookId, worksheetId, range) {
|
|
3250
|
+
_interceptCellContent(workbookId, worksheetId, range, visibleColumns) {
|
|
2930
3251
|
const { startRow, startColumn, endColumn } = range;
|
|
2931
3252
|
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
2932
3253
|
effect: InterceptorEffectEnum.Style,
|
|
2933
3254
|
handler: (cell, pos, next) => {
|
|
2934
3255
|
const { row, col, unitId, subUnitId } = pos;
|
|
2935
|
-
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
3256
|
+
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn || !visibleColumns.has(col)) return next(cell);
|
|
2936
3257
|
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2937
3258
|
cell.fontRenderExtension = {
|
|
2938
3259
|
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
@@ -3075,7 +3396,42 @@ SheetTableSelectionController = __decorate([
|
|
|
3075
3396
|
], SheetTableSelectionController);
|
|
3076
3397
|
|
|
3077
3398
|
//#endregion
|
|
3078
|
-
//#region src/menu/
|
|
3399
|
+
//#region src/menu/mobile-schema.ts
|
|
3400
|
+
const mobileMenuSchema = {
|
|
3401
|
+
[RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
3402
|
+
order: 0,
|
|
3403
|
+
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
3404
|
+
} },
|
|
3405
|
+
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.LAYOUT]: {
|
|
3406
|
+
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
3407
|
+
order: 5,
|
|
3408
|
+
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
3409
|
+
[SheetTableInsertRowCommand.id]: {
|
|
3410
|
+
order: 1,
|
|
3411
|
+
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
3412
|
+
},
|
|
3413
|
+
[SheetTableInsertColCommand.id]: {
|
|
3414
|
+
order: 2,
|
|
3415
|
+
menuItemFactory: SheetTableInsertColMenuFactory
|
|
3416
|
+
}
|
|
3417
|
+
},
|
|
3418
|
+
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
3419
|
+
order: 6,
|
|
3420
|
+
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
3421
|
+
[SheetTableRemoveRowCommand.id]: {
|
|
3422
|
+
order: 1,
|
|
3423
|
+
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
3424
|
+
},
|
|
3425
|
+
[SheetTableRemoveColCommand.id]: {
|
|
3426
|
+
order: 2,
|
|
3427
|
+
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
} }
|
|
3431
|
+
};
|
|
3432
|
+
|
|
3433
|
+
//#endregion
|
|
3434
|
+
//#region src/menu/mobile-sheet-table-menu.controller.ts
|
|
3079
3435
|
/**
|
|
3080
3436
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3081
3437
|
*
|
|
@@ -3091,17 +3447,13 @@ SheetTableSelectionController = __decorate([
|
|
|
3091
3447
|
* See the License for the specific language governing permissions and
|
|
3092
3448
|
* limitations under the License.
|
|
3093
3449
|
*/
|
|
3094
|
-
let
|
|
3095
|
-
constructor(
|
|
3450
|
+
let MobileSheetTableMenuController = class MobileSheetTableMenuController extends Disposable {
|
|
3451
|
+
constructor(menuManagerService) {
|
|
3096
3452
|
super();
|
|
3097
|
-
|
|
3098
|
-
this._initMenu();
|
|
3099
|
-
}
|
|
3100
|
-
_initMenu() {
|
|
3101
|
-
this._menuManagerService.mergeMenu(menuSchema);
|
|
3453
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
3102
3454
|
}
|
|
3103
3455
|
};
|
|
3104
|
-
|
|
3456
|
+
MobileSheetTableMenuController = __decorate([__decorateParam(0, IMenuManagerService)], MobileSheetTableMenuController);
|
|
3105
3457
|
|
|
3106
3458
|
//#endregion
|
|
3107
3459
|
//#region src/mobile-plugin.ts
|
|
@@ -3123,9 +3475,8 @@ let UniverSheetsTableMobileUIPlugin = class UniverSheetsTableMobileUIPlugin exte
|
|
|
3123
3475
|
this._injector.get(MobileComponentsController);
|
|
3124
3476
|
registerDependencies(this._injector, [
|
|
3125
3477
|
[SheetsTableMobileComponentController],
|
|
3126
|
-
[SheetsTableComponentController, { useExisting: SheetsTableMobileComponentController }],
|
|
3127
3478
|
[SheetsTableUiService],
|
|
3128
|
-
[
|
|
3479
|
+
[MobileSheetTableMenuController],
|
|
3129
3480
|
[SheetTableThemeUIController],
|
|
3130
3481
|
[SheetTableSelectionController]
|
|
3131
3482
|
]);
|
|
@@ -3134,7 +3485,7 @@ let UniverSheetsTableMobileUIPlugin = class UniverSheetsTableMobileUIPlugin exte
|
|
|
3134
3485
|
touchDependencies(this._injector, [
|
|
3135
3486
|
[SheetsTableMobileComponentController],
|
|
3136
3487
|
[SheetsTableUiService],
|
|
3137
|
-
[
|
|
3488
|
+
[MobileSheetTableMenuController],
|
|
3138
3489
|
[SheetTableThemeUIController],
|
|
3139
3490
|
[SheetTableSelectionController]
|
|
3140
3491
|
]);
|
|
@@ -3151,7 +3502,7 @@ let UniverSheetsTableMobileUIPlugin = class UniverSheetsTableMobileUIPlugin exte
|
|
|
3151
3502
|
});
|
|
3152
3503
|
}
|
|
3153
3504
|
_initRegisterCommand() {
|
|
3154
|
-
[
|
|
3505
|
+
[OpenTableFilterPanelMobileOperation, OpenTableSelectorOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
3155
3506
|
}
|
|
3156
3507
|
};
|
|
3157
3508
|
_defineProperty(UniverSheetsTableMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
@@ -3263,11 +3614,12 @@ const SheetTableConditionPanel = (props) => {
|
|
|
3263
3614
|
const compare = value[1];
|
|
3264
3615
|
if (compare) setConditionVisible(false);
|
|
3265
3616
|
const info = {};
|
|
3266
|
-
if (type === TableConditionTypeEnum.Date)
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3617
|
+
if (type === TableConditionTypeEnum.Date) {
|
|
3618
|
+
if (compare === TableDateCompareTypeEnum.Quarter) info.dateSelect = TableDateCompareTypeEnum.Q1;
|
|
3619
|
+
else if (compare === TableDateCompareTypeEnum.Month) info.dateSelect = TableDateCompareTypeEnum.M1;
|
|
3620
|
+
else if (datePickerSet.has(compare)) info.date = /* @__PURE__ */ new Date();
|
|
3621
|
+
else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
3622
|
+
} else if (type === TableConditionTypeEnum.Number) info.number = 0;
|
|
3271
3623
|
else if (type === TableConditionTypeEnum.String) info.string = "";
|
|
3272
3624
|
handleConditionInfo(info, value[0], value[1] ?? TableStringCompareTypeEnum.Equal);
|
|
3273
3625
|
};
|
|
@@ -3374,7 +3726,7 @@ const getCheckedItemCount = (map, checkedItemSet) => {
|
|
|
3374
3726
|
return count;
|
|
3375
3727
|
};
|
|
3376
3728
|
function SheetTableItemsFilterPanel(props) {
|
|
3377
|
-
const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter } = props;
|
|
3729
|
+
const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter, onSelectAllChange, onItemChange } = props;
|
|
3378
3730
|
const localeService = useDependency(LocaleService);
|
|
3379
3731
|
const { data: items, itemsCountMap, allItemsCount } = useDependency(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
3380
3732
|
const [allChecked, setAllChecked] = useState(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
@@ -3386,38 +3738,75 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
3386
3738
|
return String(item.title).toLowerCase().includes(searchText.toLowerCase());
|
|
3387
3739
|
}) : items;
|
|
3388
3740
|
}, [searchText, items]);
|
|
3389
|
-
const
|
|
3741
|
+
const recordFilter = isRecordTableFilter(tableFilter);
|
|
3742
|
+
const allDisplayedChecked = displayItems.length > 0 && displayItems.every((item) => checkedItemSet.has(item.valueKey ?? item.title));
|
|
3743
|
+
const someDisplayedChecked = displayItems.some((item) => checkedItemSet.has(item.valueKey ?? item.title));
|
|
3744
|
+
const displayedAllChecked = recordFilter ? allDisplayedChecked : allChecked;
|
|
3745
|
+
const displayedIndeterminate = recordFilter ? !allDisplayedChecked && someDisplayedChecked : indeterminate;
|
|
3746
|
+
const onCheckAllToggled = () => {
|
|
3747
|
+
if (recordFilter) {
|
|
3748
|
+
const next = new Set(checkedItemSet);
|
|
3749
|
+
displayItems.forEach((item) => {
|
|
3750
|
+
const itemKey = item.valueKey ?? item.title;
|
|
3751
|
+
if (allDisplayedChecked) next.delete(itemKey);
|
|
3752
|
+
else next.add(itemKey);
|
|
3753
|
+
});
|
|
3754
|
+
setCheckedItemSet(next);
|
|
3755
|
+
setCheckedCount(getCheckedItemCount(itemsCountMap, next));
|
|
3756
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(!allDisplayedChecked && searchText === "");
|
|
3757
|
+
return;
|
|
3758
|
+
}
|
|
3390
3759
|
if (allChecked) {
|
|
3391
3760
|
checkedItemSet.clear();
|
|
3392
3761
|
setCheckedItemSet(new Set(checkedItemSet));
|
|
3393
3762
|
setAllChecked(false);
|
|
3763
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(false);
|
|
3394
3764
|
} else {
|
|
3395
3765
|
displayItems.forEach((item) => {
|
|
3396
|
-
checkedItemSet.add(item.title);
|
|
3766
|
+
checkedItemSet.add(item.valueKey ?? item.title);
|
|
3397
3767
|
});
|
|
3398
3768
|
setCheckedItemSet(new Set(checkedItemSet));
|
|
3399
3769
|
setAllChecked(true);
|
|
3770
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(items.every((item) => checkedItemSet.has(item.valueKey ?? item.title)));
|
|
3771
|
+
}
|
|
3772
|
+
};
|
|
3773
|
+
const onSearchValueChange = (str) => {
|
|
3774
|
+
if (recordFilter) {
|
|
3775
|
+
setSearchText(str);
|
|
3776
|
+
return;
|
|
3400
3777
|
}
|
|
3401
|
-
}, [allChecked]);
|
|
3402
|
-
const onSearchValueChange = useCallback((str) => {
|
|
3403
3778
|
if (str === "") {
|
|
3404
3779
|
setAllChecked(true);
|
|
3405
3780
|
items.forEach((item) => {
|
|
3406
|
-
checkedItemSet.add(item.title);
|
|
3781
|
+
checkedItemSet.add(item.valueKey ?? item.title);
|
|
3407
3782
|
});
|
|
3408
3783
|
setCheckedCount(allItemsCount);
|
|
3784
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(true);
|
|
3409
3785
|
} else {
|
|
3410
3786
|
checkedItemSet.clear();
|
|
3411
3787
|
setAllChecked(false);
|
|
3412
3788
|
setCheckedCount(0);
|
|
3789
|
+
onSelectAllChange === null || onSelectAllChange === void 0 || onSelectAllChange(false);
|
|
3413
3790
|
}
|
|
3414
3791
|
setSearchText(str);
|
|
3415
|
-
}
|
|
3792
|
+
};
|
|
3416
3793
|
const onCheckItemToggled = (key) => {
|
|
3794
|
+
onItemChange === null || onItemChange === void 0 || onItemChange();
|
|
3795
|
+
if (recordFilter) {
|
|
3796
|
+
const next = new Set(checkedItemSet);
|
|
3797
|
+
if (next.has(key)) next.delete(key);
|
|
3798
|
+
else next.add(key);
|
|
3799
|
+
setCheckedCount(getCheckedItemCount(itemsCountMap, next));
|
|
3800
|
+
setCheckedItemSet(next);
|
|
3801
|
+
return;
|
|
3802
|
+
}
|
|
3417
3803
|
if (allChecked) {
|
|
3418
3804
|
setAllChecked(false);
|
|
3419
3805
|
const newSet = /* @__PURE__ */ new Set();
|
|
3420
|
-
for (const
|
|
3806
|
+
for (const item of items) {
|
|
3807
|
+
const itemKey = item.valueKey ?? item.title;
|
|
3808
|
+
if (key !== itemKey) newSet.add(itemKey);
|
|
3809
|
+
}
|
|
3421
3810
|
setCheckedCount(allItemsCount - itemsCountMap.get(key));
|
|
3422
3811
|
setCheckedItemSet(newSet);
|
|
3423
3812
|
} else {
|
|
@@ -3449,9 +3838,9 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
3449
3838
|
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
3450
3839
|
className: "univer-min-w-0 univer-flex-1",
|
|
3451
3840
|
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
3452
|
-
indeterminate,
|
|
3841
|
+
indeterminate: displayedIndeterminate,
|
|
3453
3842
|
disabled: items.length === 0,
|
|
3454
|
-
checked:
|
|
3843
|
+
checked: displayedAllChecked,
|
|
3455
3844
|
onChange: onCheckAllToggled,
|
|
3456
3845
|
children: /* @__PURE__ */ jsxs("div", {
|
|
3457
3846
|
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
@@ -3465,14 +3854,15 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
3465
3854
|
})
|
|
3466
3855
|
})
|
|
3467
3856
|
}), displayItems.map((item) => {
|
|
3857
|
+
const itemKey = item.valueKey ?? item.title;
|
|
3468
3858
|
return /* @__PURE__ */ jsx("div", {
|
|
3469
3859
|
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
3470
3860
|
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
3471
3861
|
className: "univer-min-w-0 univer-flex-1",
|
|
3472
3862
|
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
3473
|
-
checked:
|
|
3863
|
+
checked: displayedAllChecked || checkedItemSet.has(itemKey),
|
|
3474
3864
|
onChange: () => {
|
|
3475
|
-
onCheckItemToggled(
|
|
3865
|
+
onCheckItemToggled(itemKey);
|
|
3476
3866
|
},
|
|
3477
3867
|
children: /* @__PURE__ */ jsxs("span", {
|
|
3478
3868
|
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
@@ -3481,7 +3871,7 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
3481
3871
|
children: item.title
|
|
3482
3872
|
}), /* @__PURE__ */ jsx("span", {
|
|
3483
3873
|
className: "univer-ml-1 univer-inline-flex univer-h-full univer-items-center univer-text-gray-400",
|
|
3484
|
-
children: `(${itemsCountMap.get(
|
|
3874
|
+
children: `(${itemsCountMap.get(itemKey) || 0})`
|
|
3485
3875
|
})]
|
|
3486
3876
|
})
|
|
3487
3877
|
})
|
|
@@ -3527,7 +3917,8 @@ function SheetTableFilterPanel() {
|
|
|
3527
3917
|
const { unitId, subUnitId, tableId, tableFilter, currentFilterBy, columnIndex } = panelProps;
|
|
3528
3918
|
const { data } = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
3529
3919
|
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
3530
|
-
const [checkedItemSet, setCheckedItemSet] = useState(() => new Set(
|
|
3920
|
+
const [checkedItemSet, setCheckedItemSet] = useState(() => new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.manual || (tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === TableColumnFilterTypeEnum.record ? checkedItems : data.map((item) => item.valueKey ?? item.title)));
|
|
3921
|
+
const [selectAllRequested, setSelectAllRequested] = useState(false);
|
|
3531
3922
|
const [filterBy, setFilterBy] = useState(currentFilterBy || "items");
|
|
3532
3923
|
const [conditionInfo, setConditionInfo] = useState(() => {
|
|
3533
3924
|
const tableFilter = panelProps.tableFilter;
|
|
@@ -3593,23 +3984,17 @@ function SheetTableFilterPanel() {
|
|
|
3593
3984
|
const onApply = async () => {
|
|
3594
3985
|
let filter;
|
|
3595
3986
|
if (filterBy === "items") {
|
|
3596
|
-
|
|
3597
|
-
const emptyLabel = localeService.t("sheets-table-ui.condition.empty");
|
|
3598
|
-
for (const itemInfo of data) if (checkedItemSet.has(itemInfo.title)) filteredItems.push(itemInfo.title === emptyLabel ? TABLE_FILTER_EMPTY_VALUE : itemInfo.title);
|
|
3987
|
+
filter = tableUiService.createItemFilter(unitId, tableId, columnIndex, tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex), checkedItemSet, selectAllRequested);
|
|
3599
3988
|
const originFilter = table.getTableFilterColumn(columnIndex);
|
|
3600
|
-
if (isManualTableFilter(originFilter)) {
|
|
3601
|
-
if (originFilter.values.join(",") ===
|
|
3989
|
+
if (isManualTableFilter(originFilter) && isManualTableFilter(filter)) {
|
|
3990
|
+
if (originFilter.values.join(",") === filter.values.join(",")) {
|
|
3602
3991
|
closeDialog();
|
|
3603
3992
|
return;
|
|
3604
3993
|
}
|
|
3605
|
-
} else if (
|
|
3994
|
+
} else if (!filter && !originFilter) {
|
|
3606
3995
|
closeDialog();
|
|
3607
3996
|
return;
|
|
3608
3997
|
}
|
|
3609
|
-
filter = filteredItems.length === data.length ? void 0 : {
|
|
3610
|
-
filterType: TableColumnFilterTypeEnum.manual,
|
|
3611
|
-
values: filteredItems
|
|
3612
|
-
};
|
|
3613
3998
|
} else if (filterBy === "color") {
|
|
3614
3999
|
const cellFillColors = colors.cellFillColors.filter((item) => item.checked).map((item) => item.color);
|
|
3615
4000
|
const cellTextColors = colors.cellTextColors.filter((item) => item.checked).map((item) => item.color);
|
|
@@ -3643,10 +4028,11 @@ function SheetTableFilterPanel() {
|
|
|
3643
4028
|
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, void 0)) closeDialog();
|
|
3644
4029
|
};
|
|
3645
4030
|
const workbookEditableId = new WorkbookEditablePermission(unitId).id;
|
|
4031
|
+
const editable = (_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value;
|
|
3646
4032
|
return /* @__PURE__ */ jsxs("div", {
|
|
3647
4033
|
className: "univer-box-border univer-flex univer-w-[400px] univer-flex-col univer-rounded-[10px] univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
3648
4034
|
children: [
|
|
3649
|
-
|
|
4035
|
+
editable && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
3650
4036
|
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",
|
|
3651
4037
|
children: [
|
|
3652
4038
|
/* @__PURE__ */ jsxs("button", {
|
|
@@ -3713,7 +4099,9 @@ function SheetTableFilterPanel() {
|
|
|
3713
4099
|
tableId,
|
|
3714
4100
|
columnIndex,
|
|
3715
4101
|
checkedItemSet,
|
|
3716
|
-
setCheckedItemSet
|
|
4102
|
+
setCheckedItemSet,
|
|
4103
|
+
onSelectAllChange: setSelectAllRequested,
|
|
4104
|
+
onItemChange: () => setSelectAllRequested(false)
|
|
3717
4105
|
}),
|
|
3718
4106
|
filterBy === "color" && /* @__PURE__ */ jsx(SheetTableColorFilterPanel, {
|
|
3719
4107
|
colors,
|
|
@@ -3777,6 +4165,11 @@ function SheetTableMenu({ popup }) {
|
|
|
3777
4165
|
children: menu.labels["set-theme"],
|
|
3778
4166
|
onSelect: () => menu.onSelect("set-theme")
|
|
3779
4167
|
},
|
|
4168
|
+
{
|
|
4169
|
+
type: "item",
|
|
4170
|
+
children: menu.labels.settings,
|
|
4171
|
+
onSelect: () => menu.onSelect("settings")
|
|
4172
|
+
},
|
|
3780
4173
|
{
|
|
3781
4174
|
type: "item",
|
|
3782
4175
|
children: menu.labels.delete,
|
|
@@ -3828,7 +4221,8 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
3828
4221
|
[
|
|
3829
4222
|
[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel],
|
|
3830
4223
|
[SHEET_TABLE_MENU, SheetTableMenu],
|
|
3831
|
-
[SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]
|
|
4224
|
+
[SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog],
|
|
4225
|
+
[SHEET_TABLE_SETTINGS_DIALOG, SheetTableSettingsDialog]
|
|
3832
4226
|
].forEach(([key, comp]) => {
|
|
3833
4227
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
3834
4228
|
});
|
|
@@ -3842,6 +4236,35 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
3842
4236
|
};
|
|
3843
4237
|
ComponentsController = __decorate([__decorateParam(0, Inject(ComponentManager)), __decorateParam(1, Inject(IconManager))], ComponentsController);
|
|
3844
4238
|
|
|
4239
|
+
//#endregion
|
|
4240
|
+
//#region src/menu/sheet-table-menu.controller.ts
|
|
4241
|
+
/**
|
|
4242
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
4243
|
+
*
|
|
4244
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4245
|
+
* you may not use this file except in compliance with the License.
|
|
4246
|
+
* You may obtain a copy of the License at
|
|
4247
|
+
*
|
|
4248
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
4249
|
+
*
|
|
4250
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
4251
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
4252
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
4253
|
+
* See the License for the specific language governing permissions and
|
|
4254
|
+
* limitations under the License.
|
|
4255
|
+
*/
|
|
4256
|
+
let SheetTableMenuController = class SheetTableMenuController extends Disposable {
|
|
4257
|
+
constructor(_menuManagerService) {
|
|
4258
|
+
super();
|
|
4259
|
+
this._menuManagerService = _menuManagerService;
|
|
4260
|
+
this._initMenu();
|
|
4261
|
+
}
|
|
4262
|
+
_initMenu() {
|
|
4263
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
4264
|
+
}
|
|
4265
|
+
};
|
|
4266
|
+
SheetTableMenuController = __decorate([__decorateParam(0, Inject(IMenuManagerService))], SheetTableMenuController);
|
|
4267
|
+
|
|
3845
4268
|
//#endregion
|
|
3846
4269
|
//#region src/plugin.ts
|
|
3847
4270
|
let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends Plugin {
|