@univerjs/sheets-table-ui 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +835 -385
- package/lib/cjs/locale/ca-ES.js +6 -0
- package/lib/cjs/locale/en-US.js +6 -0
- package/lib/cjs/locale/es-ES.js +6 -0
- package/lib/cjs/locale/fa-IR.js +6 -0
- package/lib/cjs/locale/fr-FR.js +6 -0
- package/lib/cjs/locale/ja-JP.js +6 -0
- package/lib/cjs/locale/ko-KR.js +6 -0
- package/lib/cjs/locale/ru-RU.js +6 -0
- package/lib/cjs/locale/sk-SK.js +6 -0
- package/lib/cjs/locale/vi-VN.js +6 -0
- package/lib/cjs/locale/zh-CN.js +6 -0
- package/lib/cjs/locale/zh-TW.js +6 -0
- package/lib/es/index.js +843 -393
- package/lib/es/locale/ca-ES.js +6 -0
- package/lib/es/locale/en-US.js +6 -0
- package/lib/es/locale/es-ES.js +6 -0
- package/lib/es/locale/fa-IR.js +6 -0
- package/lib/es/locale/fr-FR.js +6 -0
- package/lib/es/locale/ja-JP.js +6 -0
- package/lib/es/locale/ko-KR.js +6 -0
- package/lib/es/locale/ru-RU.js +6 -0
- package/lib/es/locale/sk-SK.js +6 -0
- package/lib/es/locale/vi-VN.js +6 -0
- package/lib/es/locale/zh-CN.js +6 -0
- package/lib/es/locale/zh-TW.js +6 -0
- package/lib/index.css +63 -47
- package/lib/index.js +843 -393
- package/lib/locale/ca-ES.js +6 -0
- package/lib/locale/en-US.js +6 -0
- package/lib/locale/es-ES.js +6 -0
- package/lib/locale/fa-IR.js +6 -0
- package/lib/locale/fr-FR.js +6 -0
- package/lib/locale/ja-JP.js +6 -0
- package/lib/locale/ko-KR.js +6 -0
- package/lib/locale/ru-RU.js +6 -0
- package/lib/locale/sk-SK.js +6 -0
- package/lib/locale/vi-VN.js +6 -0
- package/lib/locale/zh-CN.js +6 -0
- package/lib/locale/zh-TW.js +6 -0
- 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/locale/en-US.d.ts +6 -0
- package/lib/types/views/components/{SheetTableAnchor.d.ts → SheetTableRenameDialog.d.ts} +6 -1
- 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/ca-ES.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/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.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-TW.js +1 -1
- package/package.json +13 -13
- 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/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandService, IConfigService, IContextService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, Rectangle, RxDisposable,
|
|
2
|
-
import {
|
|
3
|
-
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SheetTableInsertColCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveRowCommand, SheetTableService,
|
|
4
|
-
import { SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { ColorKit, CommandType, DependentOn, Disposable, ErrorService, ICommandService, IConfigService, IContextService, IPermissionService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, Rectangle, RxDisposable, UniverInstanceType, VerticalAlign, cellToRange, fromCallback, merge, registerDependencies, toDisposable, touchDependencies } from "@univerjs/core";
|
|
2
|
+
import { CURSOR_TYPE, DEFAULT_FONTFACE_PLANE, IRenderManagerService, Rect, Shape } from "@univerjs/engine-render";
|
|
3
|
+
import { AddSheetTableCommand, AddTableThemeCommand, DeleteSheetTableCommand, RemoveTableThemeCommand, SHEET_TABLE_CUSTOM_THEME_PREFIX, SetSheetTableCommand, SetSheetTableFilterCommand, SheetTableInsertColCommand, SheetTableInsertColumnAtCommand, SheetTableInsertRowAtCommand, SheetTableInsertRowCommand, SheetTableRemoveColCommand, SheetTableRemoveColumnAtCommand, SheetTableRemoveRowCommand, SheetTableService, SheetsTableController, SheetsTableSortStateEnum, TableColumnFilterTypeEnum, TableConditionTypeEnum, TableDateCompareTypeEnum, TableManager, TableNumberCompareTypeEnum, TableStringCompareTypeEnum, UniverSheetsTablePlugin, customEmptyThemeWithBorderStyle, getExistingNamesSet, isConditionFilter, isManualTableFilter, processStyleWithBorderStyle, validateSheetTableName } from "@univerjs/sheets-table";
|
|
4
|
+
import { ISheetSelectionRenderService, SHEET_VIEW_KEY, SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, getCoordByCell, getCurrentRangeDisable$, getTransformCoord } from "@univerjs/sheets-ui";
|
|
5
|
+
import { ComponentManager, ContextMenuGroup, ContextMenuPosition, IDialogService, IMenuManagerService, ISidebarService, MenuItemType, RibbonDataGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
6
|
+
import { Subject, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
7
7
|
import { Button, ButtonGroup, CascaderList, Checkbox, ColorPicker, DatePicker, DateRangePicker, Dropdown, Input, InputNumber, Segmented, Select, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
8
|
-
import { AscendingIcon,
|
|
8
|
+
import { AscendingIcon, DeleteColumnDoubleIcon, DescendingIcon, DropdownIcon, LeftInsertColumnDoubleIcon, MoreDownIcon, RightInsertColumnDoubleIcon, TableIcon } from "@univerjs/icons";
|
|
9
9
|
import { INTERCEPTOR_POINT, RangeThemeStyle, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
|
|
10
10
|
import { SortRangeCommand, SortType } from "@univerjs/sheets-sort";
|
|
11
11
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
13
|
+
import { IDefinedNamesService, deserializeRangeWithSheet, serializeRange } from "@univerjs/engine-formula";
|
|
14
14
|
import { RangeSelector } from "@univerjs/sheets-formula-ui";
|
|
15
15
|
|
|
16
16
|
//#region package.json
|
|
17
17
|
var name = "@univerjs/sheets-table-ui";
|
|
18
|
-
var version = "0.
|
|
18
|
+
var version = "0.24.0";
|
|
19
19
|
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/const.ts
|
|
@@ -39,6 +39,8 @@ const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = "SHEETS_TABLE_FILTER_PANEL_OPENED_K
|
|
|
39
39
|
const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
40
40
|
const TABLE_TOOLBAR_BUTTON = "TABLE_TOOLBAR_BUTTON";
|
|
41
41
|
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
42
|
+
const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
|
|
43
|
+
const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
42
44
|
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
43
45
|
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
44
46
|
const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
|
|
@@ -107,7 +109,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
//#endregion
|
|
110
|
-
//#region src/services/sheets-table-ui
|
|
112
|
+
//#region src/services/sheets-table-ui.service.ts
|
|
111
113
|
let SheetsTableUiService = class SheetsTableUiService extends Disposable {
|
|
112
114
|
constructor(_tableManager, _sheetTableService, _univerInstanceService, _commandService, _localeService) {
|
|
113
115
|
super();
|
|
@@ -851,9 +853,12 @@ function SheetTableFilterPanel() {
|
|
|
851
853
|
const table = tableManager.getTable(unitId, tableId);
|
|
852
854
|
if (!table) return null;
|
|
853
855
|
const tableFilters = table.getTableFilters();
|
|
856
|
+
const tableRange = table.getRange();
|
|
854
857
|
const sortState = tableFilters.getSortState();
|
|
855
858
|
sortState.columnIndex === columnIndex && (sortState.sortState, SheetsTableSortStateEnum.Asc);
|
|
856
859
|
sortState.columnIndex === columnIndex && (sortState.sortState, SheetsTableSortStateEnum.Desc);
|
|
860
|
+
const absoluteColumn = tableFilterPanelInfo.column;
|
|
861
|
+
const canDeleteColumn = tableRange.endColumn > tableRange.startColumn;
|
|
857
862
|
const closeDialog = () => {
|
|
858
863
|
sheetsTableComponentController.closeFilterPanel();
|
|
859
864
|
};
|
|
@@ -875,6 +880,27 @@ function SheetTableFilterPanel() {
|
|
|
875
880
|
tableFilters.setSortState(columnIndex, asc ? SheetsTableSortStateEnum.Asc : SheetsTableSortStateEnum.Desc);
|
|
876
881
|
closeDialog();
|
|
877
882
|
};
|
|
883
|
+
const insertColumn = (side) => {
|
|
884
|
+
commandService.executeCommand(SheetTableInsertColumnAtCommand.id, {
|
|
885
|
+
unitId,
|
|
886
|
+
subUnitId,
|
|
887
|
+
tableId,
|
|
888
|
+
index: side === "left" ? absoluteColumn : absoluteColumn + 1,
|
|
889
|
+
count: 1
|
|
890
|
+
});
|
|
891
|
+
closeDialog();
|
|
892
|
+
};
|
|
893
|
+
const deleteColumn = () => {
|
|
894
|
+
if (!canDeleteColumn) return;
|
|
895
|
+
commandService.executeCommand(SheetTableRemoveColumnAtCommand.id, {
|
|
896
|
+
unitId,
|
|
897
|
+
subUnitId,
|
|
898
|
+
tableId,
|
|
899
|
+
index: absoluteColumn,
|
|
900
|
+
count: 1
|
|
901
|
+
});
|
|
902
|
+
closeDialog();
|
|
903
|
+
};
|
|
878
904
|
const onApply = () => {
|
|
879
905
|
if (filterBy === "items") {
|
|
880
906
|
const filteredItems = [];
|
|
@@ -921,7 +947,39 @@ function SheetTableFilterPanel() {
|
|
|
921
947
|
return /* @__PURE__ */ jsxs("div", {
|
|
922
948
|
className: "univer-box-border univer-flex univer-min-w-[312px] 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",
|
|
923
949
|
children: [
|
|
924
|
-
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */
|
|
950
|
+
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
|
|
951
|
+
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",
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ jsxs("button", {
|
|
954
|
+
type: "button",
|
|
955
|
+
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",
|
|
956
|
+
onClick: () => insertColumn("left"),
|
|
957
|
+
children: [/* @__PURE__ */ jsx(LeftInsertColumnDoubleIcon, {
|
|
958
|
+
className: "univer-size-5",
|
|
959
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
960
|
+
}), /* @__PURE__ */ jsx("span", { children: localeService.t("sheets-table.columnMenu.insert-left") })]
|
|
961
|
+
}),
|
|
962
|
+
/* @__PURE__ */ jsxs("button", {
|
|
963
|
+
type: "button",
|
|
964
|
+
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",
|
|
965
|
+
onClick: () => insertColumn("right"),
|
|
966
|
+
children: [/* @__PURE__ */ jsx(RightInsertColumnDoubleIcon, {
|
|
967
|
+
className: "univer-size-5",
|
|
968
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
969
|
+
}), /* @__PURE__ */ jsx("span", { children: localeService.t("sheets-table.columnMenu.insert-right") })]
|
|
970
|
+
}),
|
|
971
|
+
/* @__PURE__ */ jsxs("button", {
|
|
972
|
+
type: "button",
|
|
973
|
+
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",
|
|
974
|
+
disabled: !canDeleteColumn,
|
|
975
|
+
onClick: deleteColumn,
|
|
976
|
+
children: [/* @__PURE__ */ jsx(DeleteColumnDoubleIcon, {
|
|
977
|
+
className: "univer-size-5",
|
|
978
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
979
|
+
}), /* @__PURE__ */ jsx("span", { children: localeService.t("sheets-table.columnMenu.delete") })]
|
|
980
|
+
})
|
|
981
|
+
]
|
|
982
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
925
983
|
className: "univer-mb-3 univer-flex",
|
|
926
984
|
children: /* @__PURE__ */ jsxs(ButtonGroup, {
|
|
927
985
|
className: "univer-mb-3 !univer-flex univer-w-full",
|
|
@@ -935,7 +993,7 @@ function SheetTableFilterPanel() {
|
|
|
935
993
|
children: [/* @__PURE__ */ jsx(DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.general.sort-desc")]
|
|
936
994
|
})]
|
|
937
995
|
})
|
|
938
|
-
}),
|
|
996
|
+
})] }),
|
|
939
997
|
/* @__PURE__ */ jsx("div", {
|
|
940
998
|
className: "univer-w-full",
|
|
941
999
|
children: /* @__PURE__ */ jsx(Segmented, {
|
|
@@ -996,6 +1054,89 @@ function useFilterByOptions(localeService) {
|
|
|
996
1054
|
}], [localeService.getCurrentLocale(), localeService]);
|
|
997
1055
|
}
|
|
998
1056
|
|
|
1057
|
+
//#endregion
|
|
1058
|
+
//#region src/views/components/SheetTableRenameDialog.tsx
|
|
1059
|
+
function SheetTableRenameDialog(props) {
|
|
1060
|
+
var _table$getDisplayName;
|
|
1061
|
+
const { unitId, tableId, onClose } = props;
|
|
1062
|
+
const localeService = useDependency(LocaleService);
|
|
1063
|
+
const commandService = useDependency(ICommandService);
|
|
1064
|
+
const tableManager = useDependency(TableManager);
|
|
1065
|
+
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1066
|
+
const definedNamesService = useDependency(IDefinedNamesService);
|
|
1067
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1068
|
+
const [value, setValue] = useState((_table$getDisplayName = table === null || table === void 0 ? void 0 : table.getDisplayName()) !== null && _table$getDisplayName !== void 0 ? _table$getDisplayName : "");
|
|
1069
|
+
const [error, setError] = useState("");
|
|
1070
|
+
const existingNames = useMemo(() => {
|
|
1071
|
+
const names = getExistingNamesSet(unitId, {
|
|
1072
|
+
univerInstanceService,
|
|
1073
|
+
tableManager,
|
|
1074
|
+
definedNamesService
|
|
1075
|
+
});
|
|
1076
|
+
const currentName = table === null || table === void 0 ? void 0 : table.getDisplayName().toLowerCase();
|
|
1077
|
+
if (currentName) names.delete(currentName);
|
|
1078
|
+
return names;
|
|
1079
|
+
}, [
|
|
1080
|
+
definedNamesService,
|
|
1081
|
+
table,
|
|
1082
|
+
tableManager,
|
|
1083
|
+
unitId,
|
|
1084
|
+
univerInstanceService
|
|
1085
|
+
]);
|
|
1086
|
+
const handleConfirm = () => {
|
|
1087
|
+
const nextName = value.trim();
|
|
1088
|
+
if (!table || nextName === table.getDisplayName()) {
|
|
1089
|
+
onClose();
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
if (!validateSheetTableName(nextName, existingNames).valid) {
|
|
1093
|
+
setError(localeService.t("sheets-table.tableNameError"));
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1097
|
+
unitId,
|
|
1098
|
+
tableId,
|
|
1099
|
+
name: nextName
|
|
1100
|
+
});
|
|
1101
|
+
onClose();
|
|
1102
|
+
};
|
|
1103
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1104
|
+
className: "univer-box-border univer-flex univer-w-full univer-flex-col univer-gap-4 univer-pb-3 univer-pt-2",
|
|
1105
|
+
children: [
|
|
1106
|
+
/* @__PURE__ */ jsx(Input, {
|
|
1107
|
+
size: "middle",
|
|
1108
|
+
value,
|
|
1109
|
+
placeholder: localeService.t("sheets-table.renamePlaceholder"),
|
|
1110
|
+
onChange: (nextValue) => {
|
|
1111
|
+
setValue(nextValue);
|
|
1112
|
+
setError("");
|
|
1113
|
+
},
|
|
1114
|
+
onKeyDown: (event) => {
|
|
1115
|
+
if (event.key === "Enter") handleConfirm();
|
|
1116
|
+
},
|
|
1117
|
+
autoFocus: true
|
|
1118
|
+
}),
|
|
1119
|
+
error ? /* @__PURE__ */ jsx("div", {
|
|
1120
|
+
className: "-univer-mt-2 univer-text-sm univer-text-red-500",
|
|
1121
|
+
children: error
|
|
1122
|
+
}) : null,
|
|
1123
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1124
|
+
className: "univer-flex univer-w-full univer-items-center univer-justify-end univer-gap-2",
|
|
1125
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
1126
|
+
className: "univer-min-w-16",
|
|
1127
|
+
onClick: onClose,
|
|
1128
|
+
children: localeService.t("sheets-table.cancel")
|
|
1129
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
1130
|
+
className: "univer-min-w-16",
|
|
1131
|
+
variant: "primary",
|
|
1132
|
+
onClick: handleConfirm,
|
|
1133
|
+
children: localeService.t("sheets-table.confirm")
|
|
1134
|
+
})]
|
|
1135
|
+
})
|
|
1136
|
+
]
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
|
|
999
1140
|
//#endregion
|
|
1000
1141
|
//#region src/controllers/sheet-table-component.controller.ts
|
|
1001
1142
|
let SheetsTableComponentController = class SheetsTableComponentController extends Disposable {
|
|
@@ -1013,6 +1154,22 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1013
1154
|
setCurrentTableFilterInfo(info) {
|
|
1014
1155
|
this._currentTableFilterInfo = info;
|
|
1015
1156
|
}
|
|
1157
|
+
openOrToggleFilterPanel(info) {
|
|
1158
|
+
const opened = this._contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY);
|
|
1159
|
+
if (opened && this._isSameFilterPanelInfo(this._currentTableFilterInfo, info)) {
|
|
1160
|
+
this.closeFilterPanel();
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
this.setCurrentTableFilterInfo(info);
|
|
1164
|
+
if (opened) {
|
|
1165
|
+
var _this$_popupDisposabl;
|
|
1166
|
+
(_this$_popupDisposabl = this._popupDisposable) === null || _this$_popupDisposabl === void 0 || _this$_popupDisposabl.dispose();
|
|
1167
|
+
this._popupDisposable = null;
|
|
1168
|
+
this._openFilterPopup();
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1172
|
+
}
|
|
1016
1173
|
clearCurrentTableFilterInfo() {
|
|
1017
1174
|
this._currentTableFilterInfo = null;
|
|
1018
1175
|
}
|
|
@@ -1020,7 +1177,7 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1020
1177
|
return this._currentTableFilterInfo;
|
|
1021
1178
|
}
|
|
1022
1179
|
_initComponents() {
|
|
1023
|
-
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel]].forEach(([key, comp]) => {
|
|
1180
|
+
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
|
|
1024
1181
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1025
1182
|
});
|
|
1026
1183
|
}
|
|
@@ -1049,11 +1206,14 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1049
1206
|
});
|
|
1050
1207
|
}
|
|
1051
1208
|
_closeFilterPopup() {
|
|
1052
|
-
var _this$
|
|
1053
|
-
(_this$
|
|
1209
|
+
var _this$_popupDisposabl2;
|
|
1210
|
+
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
1054
1211
|
this._popupDisposable = null;
|
|
1055
1212
|
this.clearCurrentTableFilterInfo();
|
|
1056
1213
|
}
|
|
1214
|
+
_isSameFilterPanelInfo(a, b) {
|
|
1215
|
+
return Boolean(a && a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.tableId === b.tableId && a.column === b.column && a.row === b.row);
|
|
1216
|
+
}
|
|
1057
1217
|
};
|
|
1058
1218
|
SheetsTableComponentController = __decorate([
|
|
1059
1219
|
__decorateParam(0, Inject(ComponentManager)),
|
|
@@ -1071,19 +1231,15 @@ const OpenTableFilterPanelOperation = {
|
|
|
1071
1231
|
if (!params) return false;
|
|
1072
1232
|
const { row, col, unitId, subUnitId, tableId } = params;
|
|
1073
1233
|
const tableManager = accessor.get(TableManager);
|
|
1074
|
-
const contextService = accessor.get(IContextService);
|
|
1075
1234
|
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
1076
1235
|
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
});
|
|
1085
|
-
contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1086
|
-
}
|
|
1236
|
+
sheetsTableComponentController.openOrToggleFilterPanel({
|
|
1237
|
+
unitId,
|
|
1238
|
+
subUnitId,
|
|
1239
|
+
row,
|
|
1240
|
+
tableId,
|
|
1241
|
+
column: col
|
|
1242
|
+
});
|
|
1087
1243
|
return true;
|
|
1088
1244
|
}
|
|
1089
1245
|
};
|
|
@@ -1165,6 +1321,296 @@ const defaultPluginConfig = {
|
|
|
1165
1321
|
anchorBackgroundColor: "rgb(134,139,156)"
|
|
1166
1322
|
};
|
|
1167
1323
|
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region src/views/widgets/table-controls-util.ts
|
|
1326
|
+
const TABLE_CONTROL_MENU_WIDTH = 168;
|
|
1327
|
+
const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
|
|
1328
|
+
const TABLE_CONTROL_MENU_ACTIONS = [
|
|
1329
|
+
"rename",
|
|
1330
|
+
"update-range",
|
|
1331
|
+
"set-theme",
|
|
1332
|
+
"delete"
|
|
1333
|
+
];
|
|
1334
|
+
function isPointInTableControlRegion(region, x, y) {
|
|
1335
|
+
return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
|
|
1336
|
+
}
|
|
1337
|
+
function hitTestTableControl(regions, x, y) {
|
|
1338
|
+
for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
|
|
1339
|
+
return null;
|
|
1340
|
+
}
|
|
1341
|
+
function buildTableMenuRegions(tableId, left, top) {
|
|
1342
|
+
return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
|
|
1343
|
+
type: "menu-item",
|
|
1344
|
+
tableId,
|
|
1345
|
+
action,
|
|
1346
|
+
left,
|
|
1347
|
+
top: top + index * 32,
|
|
1348
|
+
width: 168,
|
|
1349
|
+
height: 32
|
|
1350
|
+
}));
|
|
1351
|
+
}
|
|
1352
|
+
function buildCenteredPlusSegments(centerX, centerY, size) {
|
|
1353
|
+
const halfSize = size / 2;
|
|
1354
|
+
return [{
|
|
1355
|
+
fromX: centerX - halfSize,
|
|
1356
|
+
fromY: centerY,
|
|
1357
|
+
toX: centerX + halfSize,
|
|
1358
|
+
toY: centerY
|
|
1359
|
+
}, {
|
|
1360
|
+
fromX: centerX,
|
|
1361
|
+
fromY: centerY - halfSize,
|
|
1362
|
+
toX: centerX,
|
|
1363
|
+
toY: centerY + halfSize
|
|
1364
|
+
}];
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
//#endregion
|
|
1368
|
+
//#region src/views/widgets/table-controls.shape.ts
|
|
1369
|
+
const ANCHOR_MIN_WIDTH = 122;
|
|
1370
|
+
const ANCHOR_MAX_WIDTH = 240;
|
|
1371
|
+
const ANCHOR_PADDING_X = 12;
|
|
1372
|
+
const ANCHOR_TOGGLE_WIDTH = 30;
|
|
1373
|
+
const ANCHOR_OFFSET_Y = 0;
|
|
1374
|
+
const ANCHOR_BORDER = "rgba(0, 0, 0, 0.22)";
|
|
1375
|
+
const ANCHOR_DIVIDER = "rgba(0, 0, 0, 0.20)";
|
|
1376
|
+
const ANCHOR_TOGGLE_BG_ACTIVE = "rgba(0, 0, 0, 0.12)";
|
|
1377
|
+
const MENU_RADIUS = 8;
|
|
1378
|
+
const MENU_BORDER = "#d9dee7";
|
|
1379
|
+
const MENU_HOVER_BG = "#f1f3f4";
|
|
1380
|
+
const INSERT_BUTTON_VISUAL_SIZE = 18;
|
|
1381
|
+
const INSERT_BUTTON_PLUS_SIZE = 8;
|
|
1382
|
+
var SheetTableControlsShape = class extends Shape {
|
|
1383
|
+
constructor(key, _getSkeleton) {
|
|
1384
|
+
super(key, {
|
|
1385
|
+
evented: true,
|
|
1386
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
1387
|
+
zIndex: 5001
|
|
1388
|
+
});
|
|
1389
|
+
this._getSkeleton = _getSkeleton;
|
|
1390
|
+
_defineProperty(this, "_items", []);
|
|
1391
|
+
_defineProperty(this, "_regions", []);
|
|
1392
|
+
_defineProperty(this, "_openedMenuTableId", null);
|
|
1393
|
+
_defineProperty(this, "_hoveredRegion", null);
|
|
1394
|
+
_defineProperty(this, "_hoveredInsertRegion", null);
|
|
1395
|
+
_defineProperty(this, "_menuLabels", {
|
|
1396
|
+
rename: "Rename table",
|
|
1397
|
+
"update-range": "Update range",
|
|
1398
|
+
"set-theme": "Set theme",
|
|
1399
|
+
delete: "Remove table"
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
setItems(items) {
|
|
1403
|
+
this._items = items;
|
|
1404
|
+
this.makeDirty(true);
|
|
1405
|
+
}
|
|
1406
|
+
setMenuLabels(labels) {
|
|
1407
|
+
this._menuLabels = labels;
|
|
1408
|
+
this.makeDirty(true);
|
|
1409
|
+
}
|
|
1410
|
+
setOpenedMenuTableId(tableId) {
|
|
1411
|
+
if (this._openedMenuTableId === tableId) return;
|
|
1412
|
+
this._openedMenuTableId = tableId;
|
|
1413
|
+
this.makeDirty(true);
|
|
1414
|
+
}
|
|
1415
|
+
getOpenedMenuTableId() {
|
|
1416
|
+
return this._openedMenuTableId;
|
|
1417
|
+
}
|
|
1418
|
+
setHoveredRegion(region) {
|
|
1419
|
+
if (this._hoveredRegion === region) return;
|
|
1420
|
+
this._hoveredRegion = region;
|
|
1421
|
+
this.makeDirty(true);
|
|
1422
|
+
}
|
|
1423
|
+
setHoveredInsertRegion(region) {
|
|
1424
|
+
if (this._hoveredInsertRegion === region) return;
|
|
1425
|
+
this._hoveredInsertRegion = region;
|
|
1426
|
+
this.makeDirty(true);
|
|
1427
|
+
}
|
|
1428
|
+
hitTest(x, y) {
|
|
1429
|
+
return hitTestTableControl(this._regions, x, y);
|
|
1430
|
+
}
|
|
1431
|
+
isHit(coord) {
|
|
1432
|
+
return this.hitTest(coord.x, coord.y) != null;
|
|
1433
|
+
}
|
|
1434
|
+
refreshBounds() {
|
|
1435
|
+
const skeleton = this._getSkeleton();
|
|
1436
|
+
if (!skeleton) {
|
|
1437
|
+
this.hide();
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
this.show();
|
|
1441
|
+
this.transformByState({
|
|
1442
|
+
left: 0,
|
|
1443
|
+
top: 0,
|
|
1444
|
+
width: skeleton.rowHeaderWidth + skeleton.columnTotalWidth,
|
|
1445
|
+
height: skeleton.columnHeaderHeight + skeleton.rowTotalHeight
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
_draw(ctx) {
|
|
1449
|
+
this._regions = [];
|
|
1450
|
+
const skeleton = this._getSkeleton();
|
|
1451
|
+
if (!skeleton) return;
|
|
1452
|
+
ctx.save();
|
|
1453
|
+
ctx.textBaseline = "middle";
|
|
1454
|
+
for (const item of this._items) this._drawAnchor(ctx, skeleton, item);
|
|
1455
|
+
if (this._hoveredInsertRegion) {
|
|
1456
|
+
var _item$fill;
|
|
1457
|
+
const item = this._items.find((renderItem) => {
|
|
1458
|
+
var _this$_hoveredInsertR;
|
|
1459
|
+
return renderItem.tableId === ((_this$_hoveredInsertR = this._hoveredInsertRegion) === null || _this$_hoveredInsertR === void 0 ? void 0 : _this$_hoveredInsertR.tableId);
|
|
1460
|
+
});
|
|
1461
|
+
this._drawInsertButton(ctx, this._hoveredInsertRegion, (_item$fill = item === null || item === void 0 ? void 0 : item.fill) !== null && _item$fill !== void 0 ? _item$fill : "#355bb7");
|
|
1462
|
+
this._regions.push(this._hoveredInsertRegion);
|
|
1463
|
+
}
|
|
1464
|
+
ctx.restore();
|
|
1465
|
+
}
|
|
1466
|
+
_drawAnchor(ctx, skeleton, item) {
|
|
1467
|
+
const position = skeleton.getNoMergeCellWithCoordByIndex(item.range.startRow, item.range.startColumn);
|
|
1468
|
+
const left = position.startX;
|
|
1469
|
+
const rawTop = position.startY - 28 - ANCHOR_OFFSET_Y;
|
|
1470
|
+
const top = Math.max(0, rawTop);
|
|
1471
|
+
const width = Math.max(ANCHOR_MIN_WIDTH, Math.min(ANCHOR_MAX_WIDTH, item.tableName.length * 8.5 + ANCHOR_PADDING_X * 2 + ANCHOR_TOGGLE_WIDTH));
|
|
1472
|
+
const toggleRegion = {
|
|
1473
|
+
type: "anchor-menu-toggle",
|
|
1474
|
+
tableId: item.tableId,
|
|
1475
|
+
left: left + width - ANCHOR_TOGGLE_WIDTH,
|
|
1476
|
+
top,
|
|
1477
|
+
width: ANCHOR_TOGGLE_WIDTH,
|
|
1478
|
+
height: 28
|
|
1479
|
+
};
|
|
1480
|
+
ctx.save();
|
|
1481
|
+
ctx.translateWithPrecision(left, top);
|
|
1482
|
+
this._drawTopRoundedRect(ctx, width, 28, 14, item.fill, ANCHOR_BORDER);
|
|
1483
|
+
this._drawAnchorToggle(ctx, width, item.text, this._openedMenuTableId === item.tableId || this._isSameRegion(this._hoveredRegion, toggleRegion));
|
|
1484
|
+
ctx.font = `600 13px ${DEFAULT_FONTFACE_PLANE}`;
|
|
1485
|
+
ctx.fillStyle = item.text;
|
|
1486
|
+
ctx.textAlign = "left";
|
|
1487
|
+
ctx.fillText(item.tableName, ANCHOR_PADDING_X, 28 / 2);
|
|
1488
|
+
ctx.restore();
|
|
1489
|
+
this._regions.push({
|
|
1490
|
+
type: "anchor-main",
|
|
1491
|
+
tableId: item.tableId,
|
|
1492
|
+
left,
|
|
1493
|
+
top,
|
|
1494
|
+
width,
|
|
1495
|
+
height: 28
|
|
1496
|
+
});
|
|
1497
|
+
this._regions.push(toggleRegion);
|
|
1498
|
+
if (this._openedMenuTableId === item.tableId) this._drawMenu(ctx, item.tableId, left, top + 28);
|
|
1499
|
+
}
|
|
1500
|
+
_drawAnchorToggle(ctx, anchorWidth, color, active) {
|
|
1501
|
+
const toggleLeft = anchorWidth - ANCHOR_TOGGLE_WIDTH;
|
|
1502
|
+
if (active) this._drawRightTopRoundedRect(ctx, toggleLeft, anchorWidth, 28, 14, ANCHOR_TOGGLE_BG_ACTIVE);
|
|
1503
|
+
ctx.save();
|
|
1504
|
+
ctx.beginPath();
|
|
1505
|
+
ctx.strokeStyle = ANCHOR_DIVIDER;
|
|
1506
|
+
ctx.lineWidth = 1;
|
|
1507
|
+
ctx.moveTo(toggleLeft + .5, 5);
|
|
1508
|
+
ctx.lineTo(toggleLeft + .5, 28 - 5);
|
|
1509
|
+
ctx.stroke();
|
|
1510
|
+
ctx.restore();
|
|
1511
|
+
const centerX = anchorWidth - ANCHOR_TOGGLE_WIDTH / 2;
|
|
1512
|
+
const centerY = 28 / 2;
|
|
1513
|
+
ctx.save();
|
|
1514
|
+
ctx.beginPath();
|
|
1515
|
+
ctx.strokeStyle = color;
|
|
1516
|
+
ctx.lineWidth = 1.6;
|
|
1517
|
+
ctx.lineCap = "round";
|
|
1518
|
+
ctx.moveTo(centerX - 5, centerY - 4);
|
|
1519
|
+
ctx.lineTo(centerX + 5, centerY - 4);
|
|
1520
|
+
ctx.moveTo(centerX - 5, centerY);
|
|
1521
|
+
ctx.lineTo(centerX + 5, centerY);
|
|
1522
|
+
ctx.moveTo(centerX - 5, centerY + 4);
|
|
1523
|
+
ctx.lineTo(centerX + 5, centerY + 4);
|
|
1524
|
+
ctx.stroke();
|
|
1525
|
+
ctx.restore();
|
|
1526
|
+
}
|
|
1527
|
+
_drawTopRoundedRect(ctx, width, height, radius, fill, stroke) {
|
|
1528
|
+
const r = Math.min(radius, width / 2, height);
|
|
1529
|
+
ctx.beginPath();
|
|
1530
|
+
ctx.moveTo(0, height);
|
|
1531
|
+
ctx.lineTo(0, r);
|
|
1532
|
+
ctx.arcTo(0, 0, r, 0, r);
|
|
1533
|
+
ctx.lineTo(width - r, 0);
|
|
1534
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1535
|
+
ctx.lineTo(width, height);
|
|
1536
|
+
ctx.closePath();
|
|
1537
|
+
ctx.fillStyle = fill;
|
|
1538
|
+
ctx.fill();
|
|
1539
|
+
if (stroke) {
|
|
1540
|
+
ctx.strokeStyle = stroke;
|
|
1541
|
+
ctx.lineWidth = 1;
|
|
1542
|
+
ctx.stroke();
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
_drawRightTopRoundedRect(ctx, left, width, height, radius, fill) {
|
|
1546
|
+
const r = Math.min(radius, width - left, height);
|
|
1547
|
+
ctx.save();
|
|
1548
|
+
ctx.beginPath();
|
|
1549
|
+
ctx.moveTo(left, height);
|
|
1550
|
+
ctx.lineTo(left, 0);
|
|
1551
|
+
ctx.lineTo(width - r, 0);
|
|
1552
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1553
|
+
ctx.lineTo(width, height);
|
|
1554
|
+
ctx.closePath();
|
|
1555
|
+
ctx.fillStyle = fill;
|
|
1556
|
+
ctx.fill();
|
|
1557
|
+
ctx.restore();
|
|
1558
|
+
}
|
|
1559
|
+
_drawMenu(ctx, tableId, left, top) {
|
|
1560
|
+
const regions = buildTableMenuRegions(tableId, left, top);
|
|
1561
|
+
ctx.save();
|
|
1562
|
+
ctx.translateWithPrecision(left, top);
|
|
1563
|
+
Rect.drawWith(ctx, {
|
|
1564
|
+
width: 168,
|
|
1565
|
+
height: regions.length * 32,
|
|
1566
|
+
radius: MENU_RADIUS,
|
|
1567
|
+
fill: "#fff",
|
|
1568
|
+
stroke: MENU_BORDER
|
|
1569
|
+
});
|
|
1570
|
+
ctx.restore();
|
|
1571
|
+
for (const region of regions) {
|
|
1572
|
+
if (this._isSameRegion(this._hoveredRegion, region)) {
|
|
1573
|
+
ctx.save();
|
|
1574
|
+
ctx.fillStyle = MENU_HOVER_BG;
|
|
1575
|
+
ctx.fillRectByPrecision(region.left, region.top, region.width, region.height);
|
|
1576
|
+
ctx.restore();
|
|
1577
|
+
}
|
|
1578
|
+
ctx.save();
|
|
1579
|
+
ctx.font = `12px ${DEFAULT_FONTFACE_PLANE}`;
|
|
1580
|
+
ctx.fillStyle = region.action === "delete" ? "#d92d20" : "#344054";
|
|
1581
|
+
ctx.textAlign = "left";
|
|
1582
|
+
ctx.fillText(this._menuLabels[region.action], region.left + 12, region.top + region.height / 2);
|
|
1583
|
+
ctx.restore();
|
|
1584
|
+
}
|
|
1585
|
+
this._regions.push(...regions);
|
|
1586
|
+
}
|
|
1587
|
+
_drawInsertButton(ctx, region, fill) {
|
|
1588
|
+
const centerX = region.left + region.width / 2;
|
|
1589
|
+
const centerY = region.top + region.height / 2;
|
|
1590
|
+
const radius = INSERT_BUTTON_VISUAL_SIZE / 2;
|
|
1591
|
+
ctx.save();
|
|
1592
|
+
ctx.beginPath();
|
|
1593
|
+
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
1594
|
+
ctx.fillStyle = "#fff";
|
|
1595
|
+
ctx.fill();
|
|
1596
|
+
ctx.strokeStyle = fill;
|
|
1597
|
+
ctx.stroke();
|
|
1598
|
+
ctx.beginPath();
|
|
1599
|
+
ctx.strokeStyle = fill;
|
|
1600
|
+
ctx.lineWidth = 1;
|
|
1601
|
+
ctx.lineCap = "round";
|
|
1602
|
+
for (const segment of buildCenteredPlusSegments(centerX, centerY, INSERT_BUTTON_PLUS_SIZE)) {
|
|
1603
|
+
ctx.moveTo(segment.fromX, segment.fromY);
|
|
1604
|
+
ctx.lineTo(segment.toX, segment.toY);
|
|
1605
|
+
}
|
|
1606
|
+
ctx.stroke();
|
|
1607
|
+
ctx.restore();
|
|
1608
|
+
}
|
|
1609
|
+
_isSameRegion(a, b) {
|
|
1610
|
+
return Boolean(a && a.type === b.type && a.tableId === b.tableId && a.action === b.action && a.index === b.index);
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
|
|
1168
1614
|
//#endregion
|
|
1169
1615
|
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1170
1616
|
let SheetTableThemeUIController = class SheetTableThemeUIController extends Disposable {
|
|
@@ -1187,372 +1633,364 @@ let SheetTableThemeUIController = class SheetTableThemeUIController extends Disp
|
|
|
1187
1633
|
SheetTableThemeUIController = __decorate([__decorateParam(0, Inject(ICommandService))], SheetTableThemeUIController);
|
|
1188
1634
|
|
|
1189
1635
|
//#endregion
|
|
1190
|
-
//#region src/
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
const univerInstanceService = useDependency(IUniverInstanceService);
|
|
1201
|
-
const workbookPermissionInitState = useObservable(useDependency(WorkbookPermissionService).unitPermissionInitStateChange$, false);
|
|
1202
|
-
const tableManager = useDependency(TableManager);
|
|
1203
|
-
const rangeThemeModel = useDependency(SheetRangeThemeModel);
|
|
1204
|
-
const tableRefresh$ = useObservable(useDependency(SheetTableThemeUIController).refreshTable$);
|
|
1205
|
-
const localeService = useDependency(LocaleService);
|
|
1206
|
-
const selections = useObservable(useDependency(SheetsSelectionsService).selectionChanged$, [{
|
|
1207
|
-
range: cellToRange(0, 0),
|
|
1208
|
-
primary: null
|
|
1209
|
-
}]);
|
|
1210
|
-
const [, setRefresh] = useState(Math.random());
|
|
1211
|
-
const tableConfig = useDependency(IConfigService).getConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
1212
|
-
const anchorHeight = (_tableConfig$anchorHe = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorHeight) !== null && _tableConfig$anchorHe !== void 0 ? _tableConfig$anchorHe : 24;
|
|
1213
|
-
const anchorBackgroundColor = (_tableConfig$anchorBa = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorBackgroundColor) !== null && _tableConfig$anchorBa !== void 0 ? _tableConfig$anchorBa : "rgb(53,91,183)";
|
|
1214
|
-
const updateOpenState = (tableId, isOpen) => {
|
|
1215
|
-
setOpenStates((prev) => ({
|
|
1216
|
-
...prev,
|
|
1217
|
-
[tableId]: isOpen
|
|
1218
|
-
}));
|
|
1219
|
-
};
|
|
1220
|
-
useEffect(() => {
|
|
1221
|
-
setRefresh(Math.random());
|
|
1222
|
-
}, [tableRefresh$]);
|
|
1223
|
-
if (!(anchorPosition === null || anchorPosition === void 0 ? void 0 : anchorPosition.length)) return null;
|
|
1224
|
-
const target = getSheetCommandTarget(univerInstanceService);
|
|
1225
|
-
if (!target) return null;
|
|
1226
|
-
const { unitId, subUnitId } = target;
|
|
1227
|
-
const handleChangeTableName = (tableId, name) => {
|
|
1228
|
-
var _tableManager$getTabl;
|
|
1229
|
-
if (((_tableManager$getTabl = tableManager.getTableById(unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getDisplayName()) === name) {
|
|
1230
|
-
setInputFocusId("");
|
|
1231
|
-
setInputValue("");
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
|
-
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1235
|
-
tableId,
|
|
1236
|
-
unitId,
|
|
1237
|
-
name
|
|
1238
|
-
});
|
|
1239
|
-
setInputValue("");
|
|
1240
|
-
setInputFocusId("");
|
|
1241
|
-
};
|
|
1242
|
-
const handleChangeRange = async (tableId) => {
|
|
1243
|
-
const table = tableManager.getTableById(unitId, tableId);
|
|
1244
|
-
if (!table) return;
|
|
1245
|
-
const selection = await openRangeSelector(injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1246
|
-
if (!selection) return;
|
|
1247
|
-
commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1248
|
-
tableId,
|
|
1249
|
-
unitId,
|
|
1250
|
-
updateRange: { newRange: selection.range }
|
|
1251
|
-
});
|
|
1252
|
-
};
|
|
1253
|
-
if (!workbookPermissionInitState) return null;
|
|
1254
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1255
|
-
className: "univer-absolute univer-z-50 univer-size-0",
|
|
1256
|
-
children: anchorPosition.map((item) => {
|
|
1257
|
-
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4, _openStates$item$tabl;
|
|
1258
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1259
|
-
if (!table) return null;
|
|
1260
|
-
const rangeTheme = rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1261
|
-
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;
|
|
1262
|
-
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)";
|
|
1263
|
-
const tableRange = table.getRange();
|
|
1264
|
-
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return null;
|
|
1265
|
-
const lastRange = selections[selections.length - 1].range;
|
|
1266
|
-
const shouldHidden = !Rectangle.intersects(tableRange, lastRange) && item.y <= 20;
|
|
1267
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
1268
|
-
className: clsx("univer-shadow-xs univer-absolute univer-box-border univer-cursor-pointer univer-items-center univer-rounded-xl univer-px-2", borderClassName, {
|
|
1269
|
-
"univer-flex": !shouldHidden,
|
|
1270
|
-
"univer-hidden": shouldHidden
|
|
1271
|
-
}),
|
|
1272
|
-
style: {
|
|
1273
|
-
left: item.x,
|
|
1274
|
-
top: Math.max(item.y, 0),
|
|
1275
|
-
backgroundColor: headerBgColor,
|
|
1276
|
-
color: headerTextColor,
|
|
1277
|
-
borderWidth: "0.5px",
|
|
1278
|
-
height: anchorHeight ? `${anchorHeight}px` : "24px"
|
|
1279
|
-
},
|
|
1280
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
1281
|
-
className: "univer-text-nowrap",
|
|
1282
|
-
children: inputFocusId === item.tableId ? /* @__PURE__ */ jsx(Input, {
|
|
1283
|
-
className: "univer-h-[18px] univer-min-w-16 univer-rounded-none",
|
|
1284
|
-
inputClass: "univer-h-[18px] univer-w-[80px]",
|
|
1285
|
-
value: inputValue,
|
|
1286
|
-
onChange: (v) => setInputValue(v),
|
|
1287
|
-
onBlur: () => handleChangeTableName(item.tableId, inputValue),
|
|
1288
|
-
onKeyDown: (e) => {
|
|
1289
|
-
if (e.key === "Enter") handleChangeTableName(item.tableId, inputValue);
|
|
1290
|
-
},
|
|
1291
|
-
autoFocus: inputFocusId === item.tableId
|
|
1292
|
-
}) : /* @__PURE__ */ jsx("div", {
|
|
1293
|
-
className: "univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm",
|
|
1294
|
-
children: item.tableName
|
|
1295
|
-
})
|
|
1296
|
-
}), /* @__PURE__ */ jsx(Dropdown, {
|
|
1297
|
-
align: "start",
|
|
1298
|
-
overlay: /* @__PURE__ */ jsxs("div", {
|
|
1299
|
-
className: "univer-py-2",
|
|
1300
|
-
children: [
|
|
1301
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1302
|
-
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",
|
|
1303
|
-
onClick: () => {
|
|
1304
|
-
setInputFocusId(item.tableId);
|
|
1305
|
-
setInputValue(item.tableName);
|
|
1306
|
-
},
|
|
1307
|
-
children: [/* @__PURE__ */ jsx(RenameIcon, {}), localeService.t("sheets-table.rename")]
|
|
1308
|
-
}),
|
|
1309
|
-
/* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1310
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1311
|
-
onClick: () => handleChangeRange(item.tableId),
|
|
1312
|
-
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",
|
|
1313
|
-
children: [/* @__PURE__ */ jsx(GridOutlineIcon, {}), localeService.t("sheets-table.updateRange")]
|
|
1314
|
-
}),
|
|
1315
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1316
|
-
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",
|
|
1317
|
-
onClick: () => {
|
|
1318
|
-
updateOpenState(item.tableId, false);
|
|
1319
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1320
|
-
if (!table) return;
|
|
1321
|
-
const tableConfig = table.getTableConfig();
|
|
1322
|
-
const sidebarConfig = {
|
|
1323
|
-
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1324
|
-
header: { title: localeService.t("sheets-table.tableStyle") },
|
|
1325
|
-
children: {
|
|
1326
|
-
label: SHEET_TABLE_THEME_PANEL,
|
|
1327
|
-
oldConfig: tableConfig,
|
|
1328
|
-
unitId,
|
|
1329
|
-
subUnitId,
|
|
1330
|
-
tableId: item.tableId
|
|
1331
|
-
},
|
|
1332
|
-
width: 330
|
|
1333
|
-
};
|
|
1334
|
-
sidebarService.open(sidebarConfig);
|
|
1335
|
-
},
|
|
1336
|
-
children: [/* @__PURE__ */ jsx(PaintBucketDoubleIcon, { extend: { colorChannel1: "rgb(53,91,183)" } }), localeService.t("sheets-table.setTheme")]
|
|
1337
|
-
}),
|
|
1338
|
-
/* @__PURE__ */ jsx("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1339
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1340
|
-
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",
|
|
1341
|
-
onClick: () => {
|
|
1342
|
-
updateOpenState(item.tableId, false);
|
|
1343
|
-
commandService.executeCommand(DeleteSheetTableCommand.id, {
|
|
1344
|
-
tableId: item.tableId,
|
|
1345
|
-
subUnitId,
|
|
1346
|
-
unitId
|
|
1347
|
-
});
|
|
1348
|
-
},
|
|
1349
|
-
children: [/* @__PURE__ */ jsx(DeleteIcon, { className: "univer-mr-2" }), localeService.t("sheets-table.removeTable")]
|
|
1350
|
-
})
|
|
1351
|
-
]
|
|
1352
|
-
}),
|
|
1353
|
-
open: (_openStates$item$tabl = openStates[item.tableId]) !== null && _openStates$item$tabl !== void 0 ? _openStates$item$tabl : false,
|
|
1354
|
-
onOpenChange: (isOpen) => {
|
|
1355
|
-
updateOpenState(item.tableId, isOpen);
|
|
1356
|
-
},
|
|
1357
|
-
children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(MoreDownIcon, {}) })
|
|
1358
|
-
}, item.tableId)]
|
|
1359
|
-
}, item.tableId);
|
|
1360
|
-
})
|
|
1361
|
-
});
|
|
1362
|
-
};
|
|
1363
|
-
|
|
1364
|
-
//#endregion
|
|
1365
|
-
//#region src/controllers/sheet-table-anchor.controller.ts
|
|
1366
|
-
let SheetTableAnchorController = class SheetTableAnchorController extends Disposable {
|
|
1367
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _renderManagerService, _commandService, _univerInstanceService, _uiPartsService, _tableManager, _scrollManagerService, _workbookPermissionService, _permissionService) {
|
|
1636
|
+
//#region src/controllers/sheet-table-controls-render.controller.ts
|
|
1637
|
+
const TABLE_CONTROLS_LAYER_INDEX = 5002;
|
|
1638
|
+
const TABLE_CONTROL_GAP_ROW = 0;
|
|
1639
|
+
const TABLE_RENDER_REFRESH_COMMANDS = new Set([SetScrollOperation.id, SetZoomRatioOperation.id]);
|
|
1640
|
+
function isSameTopGap(left, right) {
|
|
1641
|
+
if (left === null || right === null) return left === right;
|
|
1642
|
+
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
1643
|
+
}
|
|
1644
|
+
let SheetTableControlsRenderController = class SheetTableControlsRenderController extends Disposable {
|
|
1645
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService) {
|
|
1368
1646
|
super();
|
|
1369
1647
|
this._context = _context;
|
|
1370
1648
|
this._injector = _injector;
|
|
1371
1649
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1372
|
-
this._renderManagerService = _renderManagerService;
|
|
1373
1650
|
this._commandService = _commandService;
|
|
1374
|
-
this._univerInstanceService = _univerInstanceService;
|
|
1375
|
-
this._uiPartsService = _uiPartsService;
|
|
1376
1651
|
this._tableManager = _tableManager;
|
|
1377
|
-
this.
|
|
1652
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1378
1653
|
this._workbookPermissionService = _workbookPermissionService;
|
|
1379
1654
|
this._permissionService = _permissionService;
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
this.
|
|
1385
|
-
this.
|
|
1386
|
-
this
|
|
1655
|
+
this._sheetsSelectionsService = _sheetsSelectionsService;
|
|
1656
|
+
this._selectionRenderService = _selectionRenderService;
|
|
1657
|
+
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
1658
|
+
this._localeService = _localeService;
|
|
1659
|
+
this._dialogService = _dialogService;
|
|
1660
|
+
this._sidebarService = _sidebarService;
|
|
1661
|
+
_defineProperty(this, "_shape", void 0);
|
|
1662
|
+
_defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
|
|
1663
|
+
this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
|
|
1664
|
+
this._initShape();
|
|
1665
|
+
this._initRefresh();
|
|
1666
|
+
this._refresh();
|
|
1387
1667
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1668
|
+
_initShape() {
|
|
1669
|
+
var _this$_context$compon, _this$_context$compon2;
|
|
1670
|
+
this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
|
|
1671
|
+
this.disposeWithMe(toDisposable(() => {
|
|
1672
|
+
this._context.scene.removeObjects([this._shape]);
|
|
1673
|
+
}));
|
|
1674
|
+
this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
|
|
1675
|
+
this._handlePointerMove(evt, state);
|
|
1676
|
+
}));
|
|
1677
|
+
this.disposeWithMe(this._shape.onPointerLeave$.subscribeEvent((_evt, state) => {
|
|
1678
|
+
this._handlePointerLeave(state);
|
|
1679
|
+
}));
|
|
1680
|
+
this.disposeWithMe(this._shape.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1681
|
+
this._handlePointerDown(evt, state);
|
|
1682
|
+
}));
|
|
1683
|
+
this.disposeWithMe((_this$_context$compon = (_this$_context$compon2 = this._context.components.get(SHEET_VIEW_KEY.MAIN)) === null || _this$_context$compon2 === void 0 ? void 0 : _this$_context$compon2.onPointerMove$.subscribeEvent((evt) => {
|
|
1684
|
+
const point = this._getLocalPoint(evt);
|
|
1685
|
+
const insertRegion = this._getInsertRegionFromPoint(point.x, point.y);
|
|
1686
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1687
|
+
})) !== null && _this$_context$compon !== void 0 ? _this$_context$compon : toDisposable(() => {}));
|
|
1390
1688
|
}
|
|
1391
|
-
|
|
1392
|
-
this.
|
|
1393
|
-
if (command.
|
|
1394
|
-
this.
|
|
1395
|
-
|
|
1396
|
-
this._timer = setTimeout(() => {
|
|
1397
|
-
this._anchorVisible$.next(true);
|
|
1398
|
-
}, 300);
|
|
1689
|
+
_initRefresh() {
|
|
1690
|
+
const commandExecuted$ = fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(filter(([command]) => {
|
|
1691
|
+
if (command.type === CommandType.OPERATION && TABLE_RENDER_REFRESH_COMMANDS.has(command.id)) {
|
|
1692
|
+
this._closeFloatingControls();
|
|
1693
|
+
return true;
|
|
1399
1694
|
}
|
|
1695
|
+
return command.type === CommandType.MUTATION || command.type === CommandType.COMMAND;
|
|
1696
|
+
}));
|
|
1697
|
+
this.disposeWithMe(merge$1(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(() => {
|
|
1698
|
+
this._closeFloatingControls();
|
|
1699
|
+
this._refresh();
|
|
1400
1700
|
}));
|
|
1401
1701
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1702
|
+
_refresh() {
|
|
1703
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1704
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1705
|
+
if (!skeleton || !worksheet || !this._canEditWorkbook()) {
|
|
1706
|
+
this._shape.setItems([]);
|
|
1707
|
+
this._shape.refreshBounds();
|
|
1708
|
+
this._context.scene.makeDirty();
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
this._syncTopTableGap(skeleton);
|
|
1712
|
+
this._shape.setMenuLabels({
|
|
1713
|
+
rename: this._localeService.t("sheets-table.rename"),
|
|
1714
|
+
"update-range": this._localeService.t("sheets-table.updateRange"),
|
|
1715
|
+
"set-theme": this._localeService.t("sheets-table.setTheme"),
|
|
1716
|
+
delete: this._localeService.t("sheets-table.removeTable")
|
|
1717
|
+
});
|
|
1718
|
+
const unitId = this._context.unit.getUnitId();
|
|
1719
|
+
const subUnitId = worksheet.getSheetId();
|
|
1720
|
+
const items = this._tableManager.getTablesBySubunitId(unitId, subUnitId).map((table) => {
|
|
1721
|
+
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4;
|
|
1722
|
+
const rangeTheme = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1723
|
+
return {
|
|
1724
|
+
tableId: table.getId(),
|
|
1725
|
+
tableName: table.getDisplayName(),
|
|
1726
|
+
range: table.getRange(),
|
|
1727
|
+
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)",
|
|
1728
|
+
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)"
|
|
1729
|
+
};
|
|
1730
|
+
});
|
|
1731
|
+
this._shape.setItems(items);
|
|
1732
|
+
this._shape.refreshBounds();
|
|
1733
|
+
this._shape.makeDirty(true);
|
|
1734
|
+
this._context.scene.makeDirty();
|
|
1735
|
+
}
|
|
1736
|
+
_canEditWorkbook() {
|
|
1737
|
+
var _this$_permissionServ;
|
|
1738
|
+
const unitId = this._context.unit.getUnitId();
|
|
1739
|
+
return ((_this$_permissionServ = this._permissionService.getPermissionPoint(new WorkbookEditablePermission(unitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) !== false;
|
|
1740
|
+
}
|
|
1741
|
+
_handlePointerMove(evt, state) {
|
|
1742
|
+
const point = this._getLocalPoint(evt);
|
|
1743
|
+
const hit = this._shape.hitTest(point.x, point.y);
|
|
1744
|
+
const insertRegion = this._isInsertHit(hit) ? hit : hit ? null : this._getInsertRegionFromPoint(point.x, point.y);
|
|
1745
|
+
const activeHit = hit !== null && hit !== void 0 ? hit : insertRegion;
|
|
1746
|
+
this._shape.setHoveredRegion(this._isInsertHit(hit) ? null : hit);
|
|
1747
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1748
|
+
if (activeHit) {
|
|
1749
|
+
state.stopPropagation();
|
|
1750
|
+
this._context.scene.setCursor(CURSOR_TYPE.POINTER);
|
|
1751
|
+
} else this._context.scene.resetCursor();
|
|
1752
|
+
}
|
|
1753
|
+
_isInsertHit(hit) {
|
|
1754
|
+
return (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-row" || (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-column";
|
|
1755
|
+
}
|
|
1756
|
+
_handlePointerLeave(state) {
|
|
1757
|
+
state.stopPropagation();
|
|
1758
|
+
this._shape.setHoveredRegion(null);
|
|
1759
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1760
|
+
this._context.scene.resetCursor();
|
|
1761
|
+
}
|
|
1762
|
+
_handlePointerDown(evt, state) {
|
|
1763
|
+
var _this$_shape$hitTest;
|
|
1764
|
+
if (evt.button === 2) return;
|
|
1765
|
+
const point = this._getLocalPoint(evt);
|
|
1766
|
+
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);
|
|
1767
|
+
if (!hit) {
|
|
1768
|
+
this._closeFloatingControls();
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
state.stopPropagation();
|
|
1772
|
+
evt.stopPropagation();
|
|
1773
|
+
evt.preventDefault();
|
|
1774
|
+
this._handleHit(hit);
|
|
1775
|
+
}
|
|
1776
|
+
_handleHit(hit) {
|
|
1777
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1778
|
+
if (!worksheet) return;
|
|
1779
|
+
const unitId = this._context.unit.getUnitId();
|
|
1780
|
+
const subUnitId = worksheet.getSheetId();
|
|
1781
|
+
if (hit.type === "anchor-menu-toggle" || hit.type === "anchor-main") {
|
|
1782
|
+
this._shape.setOpenedMenuTableId(this._shape.getOpenedMenuTableId() === hit.tableId ? null : hit.tableId);
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1785
|
+
if (hit.type === "insert-row") {
|
|
1786
|
+
this._commandService.executeCommand(SheetTableInsertRowAtCommand.id, {
|
|
1787
|
+
unitId,
|
|
1788
|
+
subUnitId,
|
|
1789
|
+
tableId: hit.tableId,
|
|
1790
|
+
index: hit.index,
|
|
1791
|
+
count: 1
|
|
1414
1792
|
});
|
|
1415
|
-
|
|
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
|
-
tableName: table.name
|
|
1793
|
+
this._closeFloatingControls();
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
if (hit.type === "insert-column") {
|
|
1797
|
+
this._commandService.executeCommand(SheetTableInsertColumnAtCommand.id, {
|
|
1798
|
+
unitId,
|
|
1799
|
+
subUnitId,
|
|
1800
|
+
tableId: hit.tableId,
|
|
1801
|
+
index: hit.index,
|
|
1802
|
+
count: 1
|
|
1803
|
+
});
|
|
1804
|
+
this._closeFloatingControls();
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
if (hit.type !== "menu-item") return;
|
|
1808
|
+
switch (hit.action) {
|
|
1809
|
+
case "rename":
|
|
1810
|
+
this._openRenameDialog(unitId, hit.tableId);
|
|
1811
|
+
break;
|
|
1812
|
+
case "update-range":
|
|
1813
|
+
this._openRangeSelector(unitId, subUnitId, hit.tableId);
|
|
1814
|
+
break;
|
|
1815
|
+
case "set-theme":
|
|
1816
|
+
this._openThemePanel(unitId, subUnitId, hit.tableId);
|
|
1817
|
+
break;
|
|
1818
|
+
case "delete":
|
|
1819
|
+
this._commandService.executeCommand(DeleteSheetTableCommand.id, {
|
|
1820
|
+
tableId: hit.tableId,
|
|
1821
|
+
subUnitId,
|
|
1822
|
+
unitId
|
|
1446
1823
|
});
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
}));
|
|
1824
|
+
break;
|
|
1825
|
+
}
|
|
1826
|
+
this._closeFloatingControls();
|
|
1451
1827
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
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");
|
|
1470
|
-
var TableButton = class {
|
|
1471
|
-
static drawNoSetting(ctx, size, fgColor, bgColor) {
|
|
1472
|
-
ctx.save();
|
|
1473
|
-
Rect.drawWith(ctx, {
|
|
1474
|
-
radius: 2,
|
|
1475
|
-
width: BUTTON_VIEWPORT,
|
|
1476
|
-
height: BUTTON_VIEWPORT,
|
|
1477
|
-
fill: bgColor
|
|
1828
|
+
_openRenameDialog(unitId, tableId) {
|
|
1829
|
+
this._dialogService.open({
|
|
1830
|
+
id: SHEET_TABLE_RENAME_DIALOG_ID,
|
|
1831
|
+
title: { title: this._localeService.t("sheets-table.rename") },
|
|
1832
|
+
draggable: true,
|
|
1833
|
+
destroyOnClose: true,
|
|
1834
|
+
mask: true,
|
|
1835
|
+
children: { label: {
|
|
1836
|
+
name: SHEET_TABLE_RENAME_DIALOG,
|
|
1837
|
+
props: {
|
|
1838
|
+
unitId,
|
|
1839
|
+
tableId,
|
|
1840
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1841
|
+
}
|
|
1842
|
+
} },
|
|
1843
|
+
width: 360,
|
|
1844
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1478
1845
|
});
|
|
1479
|
-
ctx.lineCap = "square";
|
|
1480
|
-
ctx.strokeStyle = fgColor;
|
|
1481
|
-
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1482
|
-
ctx.beginPath();
|
|
1483
|
-
ctx.lineWidth = 1;
|
|
1484
|
-
ctx.lineCap = "round";
|
|
1485
|
-
ctx.moveTo(3, 4);
|
|
1486
|
-
ctx.lineTo(13, 4);
|
|
1487
|
-
ctx.moveTo(4.5, 8);
|
|
1488
|
-
ctx.lineTo(11.5, 8);
|
|
1489
|
-
ctx.moveTo(6, 12);
|
|
1490
|
-
ctx.lineTo(10, 12);
|
|
1491
|
-
ctx.stroke();
|
|
1492
|
-
ctx.restore();
|
|
1493
1846
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1847
|
+
async _openRangeSelector(unitId, subUnitId, tableId) {
|
|
1848
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1849
|
+
if (!table) return;
|
|
1850
|
+
const selection = await openRangeSelector(this._injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1851
|
+
if (!selection) return;
|
|
1852
|
+
this._commandService.executeCommand(SetSheetTableCommand.id, {
|
|
1853
|
+
tableId,
|
|
1854
|
+
unitId,
|
|
1855
|
+
updateRange: { newRange: selection.range }
|
|
1503
1856
|
});
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1857
|
+
}
|
|
1858
|
+
_openThemePanel(unitId, subUnitId, tableId) {
|
|
1859
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1860
|
+
if (!table) return;
|
|
1861
|
+
this._sidebarService.open({
|
|
1862
|
+
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1863
|
+
header: { title: this._localeService.t("sheets-table.tableStyle") },
|
|
1864
|
+
children: {
|
|
1865
|
+
label: SHEET_TABLE_THEME_PANEL,
|
|
1866
|
+
oldConfig: table.getTableConfig(),
|
|
1867
|
+
unitId,
|
|
1868
|
+
subUnitId,
|
|
1869
|
+
tableId
|
|
1870
|
+
},
|
|
1871
|
+
width: 330
|
|
1508
1872
|
});
|
|
1509
|
-
|
|
1873
|
+
}
|
|
1874
|
+
_getInsertRegionFromPoint(x, y) {
|
|
1875
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1876
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1877
|
+
if (!skeleton || !worksheet) return null;
|
|
1878
|
+
const unitId = this._context.unit.getUnitId();
|
|
1879
|
+
const subUnitId = worksheet.getSheetId();
|
|
1880
|
+
const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);
|
|
1881
|
+
for (const table of tables) {
|
|
1882
|
+
const range = table.getRange();
|
|
1883
|
+
const tableBounds = this._getRangeBounds(skeleton, range);
|
|
1884
|
+
if (x < tableBounds.left || x > tableBounds.right || y < tableBounds.top || y > tableBounds.bottom) continue;
|
|
1885
|
+
if (y > this._getRangeBounds(skeleton, {
|
|
1886
|
+
...range,
|
|
1887
|
+
endRow: range.startRow
|
|
1888
|
+
}).bottom) for (let row = range.startRow + 1; row <= range.endRow; row++) {
|
|
1889
|
+
const cell = skeleton.getNoMergeCellWithCoordByIndex(row, range.startColumn);
|
|
1890
|
+
if (y >= cell.startY && y <= cell.endY) return {
|
|
1891
|
+
type: "insert-row",
|
|
1892
|
+
tableId: table.getId(),
|
|
1893
|
+
index: row + 1,
|
|
1894
|
+
left: tableBounds.left - 22 / 2,
|
|
1895
|
+
top: cell.endY - 22 / 2,
|
|
1896
|
+
width: 22,
|
|
1897
|
+
height: 22
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return null;
|
|
1902
|
+
}
|
|
1903
|
+
_getRangeBounds(skeleton, range) {
|
|
1904
|
+
const startCell = skeleton.getNoMergeCellWithCoordByIndex(range.startRow, range.startColumn);
|
|
1905
|
+
const endCell = skeleton.getNoMergeCellWithCoordByIndex(range.endRow, range.endColumn);
|
|
1906
|
+
return {
|
|
1907
|
+
left: startCell.startX,
|
|
1908
|
+
top: startCell.startY,
|
|
1909
|
+
right: endCell.endX,
|
|
1910
|
+
bottom: endCell.endY
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
_syncTopTableGap(skeleton) {
|
|
1914
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1915
|
+
if (!worksheet) return;
|
|
1916
|
+
const unitId = this._context.unit.getUnitId();
|
|
1917
|
+
const subUnitId = worksheet.getSheetId();
|
|
1918
|
+
const hasTopTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => table.getRange().startRow === 0);
|
|
1919
|
+
const current = skeleton.gapConfig;
|
|
1920
|
+
const rowGaps = { ...current.rowGaps };
|
|
1921
|
+
const previousTopGap = rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null;
|
|
1922
|
+
let shouldSync = false;
|
|
1923
|
+
if (hasTopTable) {
|
|
1924
|
+
var _baseGap$size;
|
|
1925
|
+
if (!this._topGapBaseBySkeleton.has(skeleton)) this._topGapBaseBySkeleton.set(skeleton, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null);
|
|
1926
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1927
|
+
rowGaps[TABLE_CONTROL_GAP_ROW] = {
|
|
1928
|
+
...baseGap !== null && baseGap !== void 0 ? baseGap : rowGaps[TABLE_CONTROL_GAP_ROW],
|
|
1929
|
+
size: ((_baseGap$size = baseGap === null || baseGap === void 0 ? void 0 : baseGap.size) !== null && _baseGap$size !== void 0 ? _baseGap$size : 0) + 32
|
|
1930
|
+
};
|
|
1931
|
+
shouldSync = true;
|
|
1932
|
+
} else if (this._topGapBaseBySkeleton.has(skeleton)) {
|
|
1933
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1934
|
+
if (baseGap) rowGaps[TABLE_CONTROL_GAP_ROW] = { ...baseGap };
|
|
1935
|
+
else delete rowGaps[TABLE_CONTROL_GAP_ROW];
|
|
1936
|
+
this._topGapBaseBySkeleton.delete(skeleton);
|
|
1937
|
+
shouldSync = true;
|
|
1938
|
+
}
|
|
1939
|
+
if (!shouldSync) return;
|
|
1940
|
+
if (isSameTopGap(previousTopGap, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null)) return;
|
|
1941
|
+
skeleton.setGapConfig({
|
|
1942
|
+
...current,
|
|
1943
|
+
rowGaps
|
|
1944
|
+
});
|
|
1945
|
+
this._refreshSelections();
|
|
1946
|
+
}
|
|
1947
|
+
_refreshSelections() {
|
|
1948
|
+
this._selectionRenderService.resetSelectionsByModelData(this._sheetsSelectionsService.getCurrentSelections());
|
|
1949
|
+
}
|
|
1950
|
+
_closeFloatingControls() {
|
|
1951
|
+
this._shape.setOpenedMenuTableId(null);
|
|
1952
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1953
|
+
this._shape.setHoveredRegion(null);
|
|
1954
|
+
}
|
|
1955
|
+
_getLocalPoint(evt) {
|
|
1956
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1957
|
+
if (skeleton) return getTransformCoord(evt.offsetX, evt.offsetY, this._context.scene, skeleton);
|
|
1958
|
+
return {
|
|
1959
|
+
x: evt.offsetX,
|
|
1960
|
+
y: evt.offsetY
|
|
1961
|
+
};
|
|
1510
1962
|
}
|
|
1511
1963
|
};
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
* See the License for the specific language governing permissions and
|
|
1528
|
-
* limitations under the License.
|
|
1529
|
-
*/
|
|
1530
|
-
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"];
|
|
1531
|
-
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"];
|
|
1532
|
-
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"];
|
|
1533
|
-
const filterNoneSortAsc = [
|
|
1534
|
-
"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",
|
|
1535
|
-
"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",
|
|
1536
|
-
"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"
|
|
1537
|
-
];
|
|
1538
|
-
const filterNoneSortDesc = [
|
|
1539
|
-
"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",
|
|
1540
|
-
"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",
|
|
1541
|
-
"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"
|
|
1542
|
-
];
|
|
1964
|
+
SheetTableControlsRenderController = __decorate([
|
|
1965
|
+
__decorateParam(1, Inject(Injector)),
|
|
1966
|
+
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
1967
|
+
__decorateParam(3, ICommandService),
|
|
1968
|
+
__decorateParam(4, Inject(TableManager)),
|
|
1969
|
+
__decorateParam(5, Inject(SheetRangeThemeModel)),
|
|
1970
|
+
__decorateParam(6, Inject(WorkbookPermissionService)),
|
|
1971
|
+
__decorateParam(7, Inject(IPermissionService)),
|
|
1972
|
+
__decorateParam(8, Inject(SheetsSelectionsService)),
|
|
1973
|
+
__decorateParam(9, ISheetSelectionRenderService),
|
|
1974
|
+
__decorateParam(10, Inject(SheetTableThemeUIController)),
|
|
1975
|
+
__decorateParam(11, Inject(LocaleService)),
|
|
1976
|
+
__decorateParam(12, IDialogService),
|
|
1977
|
+
__decorateParam(13, ISidebarService)
|
|
1978
|
+
], SheetTableControlsRenderController);
|
|
1543
1979
|
|
|
1544
1980
|
//#endregion
|
|
1545
1981
|
//#region src/views/widgets/table-filter-button.shape.ts
|
|
1546
1982
|
const FILTER_ICON_SIZE = 16;
|
|
1983
|
+
const FILTER_TRIGGER_HOVER_RADIUS = 4;
|
|
1547
1984
|
let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Shape {
|
|
1548
|
-
constructor(key, props,
|
|
1985
|
+
constructor(key, props, _commandService) {
|
|
1549
1986
|
super(key, props);
|
|
1550
|
-
this._contextService = _contextService;
|
|
1551
1987
|
this._commandService = _commandService;
|
|
1552
|
-
this._themeService = _themeService;
|
|
1553
1988
|
_defineProperty(this, "_cellWidth", 0);
|
|
1554
1989
|
_defineProperty(this, "_cellHeight", 0);
|
|
1555
1990
|
_defineProperty(this, "_filterParams", void 0);
|
|
1991
|
+
_defineProperty(this, "_iconColor", "#fff");
|
|
1992
|
+
_defineProperty(this, "_hoverBackground", "rgba(255, 255, 255, 0.92)");
|
|
1993
|
+
_defineProperty(this, "_hoverIconColor", "#202124");
|
|
1556
1994
|
_defineProperty(this, "_hovered", false);
|
|
1557
1995
|
this.setShapeProps(props);
|
|
1558
1996
|
this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));
|
|
@@ -1563,6 +2001,9 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Sh
|
|
|
1563
2001
|
if (typeof props.cellHeight !== "undefined") this._cellHeight = props.cellHeight;
|
|
1564
2002
|
if (typeof props.cellWidth !== "undefined") this._cellWidth = props.cellWidth;
|
|
1565
2003
|
if (typeof props.filterParams !== "undefined") this._filterParams = props.filterParams;
|
|
2004
|
+
if (typeof props.iconColor !== "undefined") this._iconColor = props.iconColor;
|
|
2005
|
+
if (typeof props.hoverBackground !== "undefined") this._hoverBackground = props.hoverBackground;
|
|
2006
|
+
if (typeof props.hoverIconColor !== "undefined") this._hoverIconColor = props.hoverIconColor;
|
|
1566
2007
|
this.transformByState({
|
|
1567
2008
|
width: props.width,
|
|
1568
2009
|
height: props.height
|
|
@@ -1577,36 +2018,38 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Sh
|
|
|
1577
2018
|
const cellRegion = new Path2D();
|
|
1578
2019
|
cellRegion.rect(left, top, cellWidth, cellHeight);
|
|
1579
2020
|
ctx.clip(cellRegion);
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
icons = filteredSortAsc;
|
|
1590
|
-
break;
|
|
1591
|
-
case SheetsTableButtonStateEnum.FilteredSortDesc:
|
|
1592
|
-
icons = filteredSortDesc;
|
|
1593
|
-
break;
|
|
1594
|
-
case SheetsTableButtonStateEnum.FilterNoneSortNone: break;
|
|
1595
|
-
case SheetsTableButtonStateEnum.FilterNoneSortAsc:
|
|
1596
|
-
icons = filterNoneSortAsc;
|
|
1597
|
-
break;
|
|
1598
|
-
case SheetsTableButtonStateEnum.FilterNoneSortDesc:
|
|
1599
|
-
icons = filterNoneSortDesc;
|
|
1600
|
-
break;
|
|
2021
|
+
if (this._hovered) {
|
|
2022
|
+
var _ctx$roundRect;
|
|
2023
|
+
ctx.save();
|
|
2024
|
+
ctx.fillStyle = this._hoverBackground;
|
|
2025
|
+
ctx.beginPath();
|
|
2026
|
+
(_ctx$roundRect = ctx.roundRect) === null || _ctx$roundRect === void 0 || _ctx$roundRect.call(ctx, 0, 0, 16, 16, FILTER_TRIGGER_HOVER_RADIUS);
|
|
2027
|
+
if (!ctx.roundRect) ctx.rect(0, 0, 16, 16);
|
|
2028
|
+
ctx.fill();
|
|
2029
|
+
ctx.restore();
|
|
1601
2030
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
2031
|
+
this._drawChevron(ctx, this._hovered ? this._hoverIconColor : this._iconColor);
|
|
2032
|
+
ctx.restore();
|
|
2033
|
+
}
|
|
2034
|
+
_drawChevron(ctx, color) {
|
|
2035
|
+
const centerX = 16 / 2;
|
|
2036
|
+
const centerY = 16 / 2 + 1;
|
|
2037
|
+
ctx.save();
|
|
2038
|
+
ctx.beginPath();
|
|
2039
|
+
ctx.strokeStyle = color;
|
|
2040
|
+
ctx.lineWidth = 1.8;
|
|
2041
|
+
ctx.lineCap = "round";
|
|
2042
|
+
ctx.lineJoin = "round";
|
|
2043
|
+
ctx.moveTo(centerX - 4.5, centerY - 2.5);
|
|
2044
|
+
ctx.lineTo(centerX, centerY + 2);
|
|
2045
|
+
ctx.lineTo(centerX + 4.5, centerY - 2.5);
|
|
2046
|
+
ctx.stroke();
|
|
1604
2047
|
ctx.restore();
|
|
1605
2048
|
}
|
|
1606
2049
|
onPointerDown(evt) {
|
|
1607
2050
|
if (evt.button === 2) return;
|
|
1608
2051
|
const { row, col, unitId, subUnitId, tableId } = this._filterParams;
|
|
1609
|
-
if (
|
|
2052
|
+
if (!this._commandService.hasCommand(OpenTableFilterPanelOperation.id)) return;
|
|
1610
2053
|
setTimeout(() => {
|
|
1611
2054
|
const cmdParams = {
|
|
1612
2055
|
row,
|
|
@@ -1627,11 +2070,7 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends Sh
|
|
|
1627
2070
|
this.makeDirty(true);
|
|
1628
2071
|
}
|
|
1629
2072
|
};
|
|
1630
|
-
SheetsTableFilterButtonShape = __decorate([
|
|
1631
|
-
__decorateParam(2, IContextService),
|
|
1632
|
-
__decorateParam(3, ICommandService),
|
|
1633
|
-
__decorateParam(4, Inject(ThemeService))
|
|
1634
|
-
], SheetsTableFilterButtonShape);
|
|
2073
|
+
SheetsTableFilterButtonShape = __decorate([__decorateParam(2, ICommandService)], SheetsTableFilterButtonShape);
|
|
1635
2074
|
|
|
1636
2075
|
//#endregion
|
|
1637
2076
|
//#region src/controllers/sheet-table-filter-button-render.controller.ts
|
|
@@ -1645,13 +2084,14 @@ const computeIconTop = (startY, endY, cellHeight, verticalAlign) => {
|
|
|
1645
2084
|
}
|
|
1646
2085
|
};
|
|
1647
2086
|
let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRenderController extends RxDisposable {
|
|
1648
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _commandService) {
|
|
2087
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _rangeThemeModel, _commandService) {
|
|
1649
2088
|
super();
|
|
1650
2089
|
this._context = _context;
|
|
1651
2090
|
this._injector = _injector;
|
|
1652
2091
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1653
2092
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1654
2093
|
this._tableManager = _tableManager;
|
|
2094
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1655
2095
|
this._commandService = _commandService;
|
|
1656
2096
|
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
1657
2097
|
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
@@ -1707,7 +2147,12 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1707
2147
|
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
1708
2148
|
if (!worksheet) return;
|
|
1709
2149
|
for (const { range, states, tableId } of tableFilterRanges) {
|
|
2150
|
+
var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
|
|
1710
2151
|
const { startRow, startColumn, endColumn } = range;
|
|
2152
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
2153
|
+
const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
|
|
2154
|
+
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";
|
|
2155
|
+
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";
|
|
1711
2156
|
this._interceptCellContent(unitId, worksheetId, range);
|
|
1712
2157
|
for (let col = startColumn; col <= endColumn; col++) {
|
|
1713
2158
|
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
@@ -1725,6 +2170,9 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1725
2170
|
height: 16,
|
|
1726
2171
|
width: 16,
|
|
1727
2172
|
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2173
|
+
iconColor,
|
|
2174
|
+
hoverBackground: iconColor,
|
|
2175
|
+
hoverIconColor,
|
|
1728
2176
|
cellHeight,
|
|
1729
2177
|
cellWidth,
|
|
1730
2178
|
filterParams: {
|
|
@@ -1773,7 +2221,8 @@ SheetsTableFilterButtonRenderController = __decorate([
|
|
|
1773
2221
|
__decorateParam(2, Inject(SheetSkeletonManagerService)),
|
|
1774
2222
|
__decorateParam(3, Inject(SheetInterceptorService)),
|
|
1775
2223
|
__decorateParam(4, Inject(TableManager)),
|
|
1776
|
-
__decorateParam(5,
|
|
2224
|
+
__decorateParam(5, Inject(SheetRangeThemeModel)),
|
|
2225
|
+
__decorateParam(6, ICommandService)
|
|
1777
2226
|
], SheetsTableFilterButtonRenderController);
|
|
1778
2227
|
|
|
1779
2228
|
//#endregion
|
|
@@ -2502,8 +2951,9 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends Plugin {
|
|
|
2502
2951
|
this._registerRenderModules();
|
|
2503
2952
|
}
|
|
2504
2953
|
_registerRenderModules() {
|
|
2505
|
-
const renderDependencies = [
|
|
2506
|
-
if (this._config.hideAnchor !== true) renderDependencies.push([
|
|
2954
|
+
const renderDependencies = [];
|
|
2955
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableControlsRenderController]);
|
|
2956
|
+
renderDependencies.push([SheetsTableFilterButtonRenderController], [SheetsTableRenderController]);
|
|
2507
2957
|
renderDependencies.forEach((m) => {
|
|
2508
2958
|
this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
|
|
2509
2959
|
});
|