@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/cjs/index.js
CHANGED
|
@@ -16,7 +16,7 @@ let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
|
16
16
|
|
|
17
17
|
//#region package.json
|
|
18
18
|
var name = "@univerjs/sheets-table-ui";
|
|
19
|
-
var version = "0.
|
|
19
|
+
var version = "0.24.0";
|
|
20
20
|
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region src/const.ts
|
|
@@ -40,6 +40,8 @@ const SHEETS_TABLE_FILTER_PANEL_OPENED_KEY = "SHEETS_TABLE_FILTER_PANEL_OPENED_K
|
|
|
40
40
|
const UNIVER_SHEET_TABLE_FILTER_PANEL_ID = "UNIVER_SHEET_Table_FILTER_PANEL_ID";
|
|
41
41
|
const TABLE_TOOLBAR_BUTTON = "TABLE_TOOLBAR_BUTTON";
|
|
42
42
|
const TABLE_SELECTOR_DIALOG = "TABLE_SELECTOR_DIALOG";
|
|
43
|
+
const SHEET_TABLE_RENAME_DIALOG = "SHEET_TABLE_RENAME_DIALOG";
|
|
44
|
+
const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
43
45
|
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
44
46
|
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
45
47
|
const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
|
|
@@ -108,7 +110,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
//#endregion
|
|
111
|
-
//#region src/services/sheets-table-ui
|
|
113
|
+
//#region src/services/sheets-table-ui.service.ts
|
|
112
114
|
let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Disposable {
|
|
113
115
|
constructor(_tableManager, _sheetTableService, _univerInstanceService, _commandService, _localeService) {
|
|
114
116
|
super();
|
|
@@ -852,9 +854,12 @@ function SheetTableFilterPanel() {
|
|
|
852
854
|
const table = tableManager.getTable(unitId, tableId);
|
|
853
855
|
if (!table) return null;
|
|
854
856
|
const tableFilters = table.getTableFilters();
|
|
857
|
+
const tableRange = table.getRange();
|
|
855
858
|
const sortState = tableFilters.getSortState();
|
|
856
859
|
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Asc);
|
|
857
860
|
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Desc);
|
|
861
|
+
const absoluteColumn = tableFilterPanelInfo.column;
|
|
862
|
+
const canDeleteColumn = tableRange.endColumn > tableRange.startColumn;
|
|
858
863
|
const closeDialog = () => {
|
|
859
864
|
sheetsTableComponentController.closeFilterPanel();
|
|
860
865
|
};
|
|
@@ -876,6 +881,27 @@ function SheetTableFilterPanel() {
|
|
|
876
881
|
tableFilters.setSortState(columnIndex, asc ? _univerjs_sheets_table.SheetsTableSortStateEnum.Asc : _univerjs_sheets_table.SheetsTableSortStateEnum.Desc);
|
|
877
882
|
closeDialog();
|
|
878
883
|
};
|
|
884
|
+
const insertColumn = (side) => {
|
|
885
|
+
commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
886
|
+
unitId,
|
|
887
|
+
subUnitId,
|
|
888
|
+
tableId,
|
|
889
|
+
index: side === "left" ? absoluteColumn : absoluteColumn + 1,
|
|
890
|
+
count: 1
|
|
891
|
+
});
|
|
892
|
+
closeDialog();
|
|
893
|
+
};
|
|
894
|
+
const deleteColumn = () => {
|
|
895
|
+
if (!canDeleteColumn) return;
|
|
896
|
+
commandService.executeCommand(_univerjs_sheets_table.SheetTableRemoveColumnAtCommand.id, {
|
|
897
|
+
unitId,
|
|
898
|
+
subUnitId,
|
|
899
|
+
tableId,
|
|
900
|
+
index: absoluteColumn,
|
|
901
|
+
count: 1
|
|
902
|
+
});
|
|
903
|
+
closeDialog();
|
|
904
|
+
};
|
|
879
905
|
const onApply = () => {
|
|
880
906
|
if (filterBy === "items") {
|
|
881
907
|
const filteredItems = [];
|
|
@@ -922,7 +948,39 @@ function SheetTableFilterPanel() {
|
|
|
922
948
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
923
949
|
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",
|
|
924
950
|
children: [
|
|
925
|
-
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
951
|
+
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
952
|
+
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",
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
955
|
+
type: "button",
|
|
956
|
+
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",
|
|
957
|
+
onClick: () => insertColumn("left"),
|
|
958
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftInsertColumnDoubleIcon, {
|
|
959
|
+
className: "univer-size-5",
|
|
960
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
961
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table.columnMenu.insert-left") })]
|
|
962
|
+
}),
|
|
963
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
964
|
+
type: "button",
|
|
965
|
+
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",
|
|
966
|
+
onClick: () => insertColumn("right"),
|
|
967
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightInsertColumnDoubleIcon, {
|
|
968
|
+
className: "univer-size-5",
|
|
969
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
970
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table.columnMenu.insert-right") })]
|
|
971
|
+
}),
|
|
972
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
973
|
+
type: "button",
|
|
974
|
+
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",
|
|
975
|
+
disabled: !canDeleteColumn,
|
|
976
|
+
onClick: deleteColumn,
|
|
977
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteColumnDoubleIcon, {
|
|
978
|
+
className: "univer-size-5",
|
|
979
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
980
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table.columnMenu.delete") })]
|
|
981
|
+
})
|
|
982
|
+
]
|
|
983
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
926
984
|
className: "univer-mb-3 univer-flex",
|
|
927
985
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.ButtonGroup, {
|
|
928
986
|
className: "univer-mb-3 !univer-flex univer-w-full",
|
|
@@ -936,7 +994,7 @@ function SheetTableFilterPanel() {
|
|
|
936
994
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-sort.general.sort-desc")]
|
|
937
995
|
})]
|
|
938
996
|
})
|
|
939
|
-
}),
|
|
997
|
+
})] }),
|
|
940
998
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
941
999
|
className: "univer-w-full",
|
|
942
1000
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
|
|
@@ -997,6 +1055,89 @@ function useFilterByOptions(localeService) {
|
|
|
997
1055
|
}], [localeService.getCurrentLocale(), localeService]);
|
|
998
1056
|
}
|
|
999
1057
|
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/views/components/SheetTableRenameDialog.tsx
|
|
1060
|
+
function SheetTableRenameDialog(props) {
|
|
1061
|
+
var _table$getDisplayName;
|
|
1062
|
+
const { unitId, tableId, onClose } = props;
|
|
1063
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1064
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1065
|
+
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1066
|
+
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
1067
|
+
const definedNamesService = (0, _univerjs_ui.useDependency)(_univerjs_engine_formula.IDefinedNamesService);
|
|
1068
|
+
const table = tableManager.getTableById(unitId, tableId);
|
|
1069
|
+
const [value, setValue] = (0, react.useState)((_table$getDisplayName = table === null || table === void 0 ? void 0 : table.getDisplayName()) !== null && _table$getDisplayName !== void 0 ? _table$getDisplayName : "");
|
|
1070
|
+
const [error, setError] = (0, react.useState)("");
|
|
1071
|
+
const existingNames = (0, react.useMemo)(() => {
|
|
1072
|
+
const names = (0, _univerjs_sheets_table.getExistingNamesSet)(unitId, {
|
|
1073
|
+
univerInstanceService,
|
|
1074
|
+
tableManager,
|
|
1075
|
+
definedNamesService
|
|
1076
|
+
});
|
|
1077
|
+
const currentName = table === null || table === void 0 ? void 0 : table.getDisplayName().toLowerCase();
|
|
1078
|
+
if (currentName) names.delete(currentName);
|
|
1079
|
+
return names;
|
|
1080
|
+
}, [
|
|
1081
|
+
definedNamesService,
|
|
1082
|
+
table,
|
|
1083
|
+
tableManager,
|
|
1084
|
+
unitId,
|
|
1085
|
+
univerInstanceService
|
|
1086
|
+
]);
|
|
1087
|
+
const handleConfirm = () => {
|
|
1088
|
+
const nextName = value.trim();
|
|
1089
|
+
if (!table || nextName === table.getDisplayName()) {
|
|
1090
|
+
onClose();
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (!(0, _univerjs_sheets_table.validateSheetTableName)(nextName, existingNames).valid) {
|
|
1094
|
+
setError(localeService.t("sheets-table.tableNameError"));
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1098
|
+
unitId,
|
|
1099
|
+
tableId,
|
|
1100
|
+
name: nextName
|
|
1101
|
+
});
|
|
1102
|
+
onClose();
|
|
1103
|
+
};
|
|
1104
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1105
|
+
className: "univer-box-border univer-flex univer-w-full univer-flex-col univer-gap-4 univer-pb-3 univer-pt-2",
|
|
1106
|
+
children: [
|
|
1107
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1108
|
+
size: "middle",
|
|
1109
|
+
value,
|
|
1110
|
+
placeholder: localeService.t("sheets-table.renamePlaceholder"),
|
|
1111
|
+
onChange: (nextValue) => {
|
|
1112
|
+
setValue(nextValue);
|
|
1113
|
+
setError("");
|
|
1114
|
+
},
|
|
1115
|
+
onKeyDown: (event) => {
|
|
1116
|
+
if (event.key === "Enter") handleConfirm();
|
|
1117
|
+
},
|
|
1118
|
+
autoFocus: true
|
|
1119
|
+
}),
|
|
1120
|
+
error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1121
|
+
className: "-univer-mt-2 univer-text-sm univer-text-red-500",
|
|
1122
|
+
children: error
|
|
1123
|
+
}) : null,
|
|
1124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1125
|
+
className: "univer-flex univer-w-full univer-items-center univer-justify-end univer-gap-2",
|
|
1126
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1127
|
+
className: "univer-min-w-16",
|
|
1128
|
+
onClick: onClose,
|
|
1129
|
+
children: localeService.t("sheets-table.cancel")
|
|
1130
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1131
|
+
className: "univer-min-w-16",
|
|
1132
|
+
variant: "primary",
|
|
1133
|
+
onClick: handleConfirm,
|
|
1134
|
+
children: localeService.t("sheets-table.confirm")
|
|
1135
|
+
})]
|
|
1136
|
+
})
|
|
1137
|
+
]
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1000
1141
|
//#endregion
|
|
1001
1142
|
//#region src/controllers/sheet-table-component.controller.ts
|
|
1002
1143
|
let SheetsTableComponentController = class SheetsTableComponentController extends _univerjs_core.Disposable {
|
|
@@ -1014,6 +1155,22 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1014
1155
|
setCurrentTableFilterInfo(info) {
|
|
1015
1156
|
this._currentTableFilterInfo = info;
|
|
1016
1157
|
}
|
|
1158
|
+
openOrToggleFilterPanel(info) {
|
|
1159
|
+
const opened = this._contextService.getContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY);
|
|
1160
|
+
if (opened && this._isSameFilterPanelInfo(this._currentTableFilterInfo, info)) {
|
|
1161
|
+
this.closeFilterPanel();
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
this.setCurrentTableFilterInfo(info);
|
|
1165
|
+
if (opened) {
|
|
1166
|
+
var _this$_popupDisposabl;
|
|
1167
|
+
(_this$_popupDisposabl = this._popupDisposable) === null || _this$_popupDisposabl === void 0 || _this$_popupDisposabl.dispose();
|
|
1168
|
+
this._popupDisposable = null;
|
|
1169
|
+
this._openFilterPopup();
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1172
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1173
|
+
}
|
|
1017
1174
|
clearCurrentTableFilterInfo() {
|
|
1018
1175
|
this._currentTableFilterInfo = null;
|
|
1019
1176
|
}
|
|
@@ -1021,7 +1178,7 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1021
1178
|
return this._currentTableFilterInfo;
|
|
1022
1179
|
}
|
|
1023
1180
|
_initComponents() {
|
|
1024
|
-
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel]].forEach(([key, comp]) => {
|
|
1181
|
+
[[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel], [SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]].forEach(([key, comp]) => {
|
|
1025
1182
|
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
1026
1183
|
});
|
|
1027
1184
|
}
|
|
@@ -1050,11 +1207,14 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
1050
1207
|
});
|
|
1051
1208
|
}
|
|
1052
1209
|
_closeFilterPopup() {
|
|
1053
|
-
var _this$
|
|
1054
|
-
(_this$
|
|
1210
|
+
var _this$_popupDisposabl2;
|
|
1211
|
+
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
1055
1212
|
this._popupDisposable = null;
|
|
1056
1213
|
this.clearCurrentTableFilterInfo();
|
|
1057
1214
|
}
|
|
1215
|
+
_isSameFilterPanelInfo(a, b) {
|
|
1216
|
+
return Boolean(a && a.unitId === b.unitId && a.subUnitId === b.subUnitId && a.tableId === b.tableId && a.column === b.column && a.row === b.row);
|
|
1217
|
+
}
|
|
1058
1218
|
};
|
|
1059
1219
|
SheetsTableComponentController = __decorate([
|
|
1060
1220
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
@@ -1072,19 +1232,15 @@ const OpenTableFilterPanelOperation = {
|
|
|
1072
1232
|
if (!params) return false;
|
|
1073
1233
|
const { row, col, unitId, subUnitId, tableId } = params;
|
|
1074
1234
|
const tableManager = accessor.get(_univerjs_sheets_table.TableManager);
|
|
1075
|
-
const contextService = accessor.get(_univerjs_core.IContextService);
|
|
1076
1235
|
const sheetsTableComponentController = accessor.get(SheetsTableComponentController);
|
|
1077
1236
|
if (!tableManager.getTable(unitId, tableId)) return false;
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
});
|
|
1086
|
-
contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, true);
|
|
1087
|
-
}
|
|
1237
|
+
sheetsTableComponentController.openOrToggleFilterPanel({
|
|
1238
|
+
unitId,
|
|
1239
|
+
subUnitId,
|
|
1240
|
+
row,
|
|
1241
|
+
tableId,
|
|
1242
|
+
column: col
|
|
1243
|
+
});
|
|
1088
1244
|
return true;
|
|
1089
1245
|
}
|
|
1090
1246
|
};
|
|
@@ -1166,6 +1322,296 @@ const defaultPluginConfig = {
|
|
|
1166
1322
|
anchorBackgroundColor: "rgb(134,139,156)"
|
|
1167
1323
|
};
|
|
1168
1324
|
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/views/widgets/table-controls-util.ts
|
|
1327
|
+
const TABLE_CONTROL_MENU_WIDTH = 168;
|
|
1328
|
+
const TABLE_CONTROL_MENU_ITEM_HEIGHT = 32;
|
|
1329
|
+
const TABLE_CONTROL_MENU_ACTIONS = [
|
|
1330
|
+
"rename",
|
|
1331
|
+
"update-range",
|
|
1332
|
+
"set-theme",
|
|
1333
|
+
"delete"
|
|
1334
|
+
];
|
|
1335
|
+
function isPointInTableControlRegion(region, x, y) {
|
|
1336
|
+
return x >= region.left && x <= region.left + region.width && y >= region.top && y <= region.top + region.height;
|
|
1337
|
+
}
|
|
1338
|
+
function hitTestTableControl(regions, x, y) {
|
|
1339
|
+
for (let i = regions.length - 1; i >= 0; i--) if (isPointInTableControlRegion(regions[i], x, y)) return regions[i];
|
|
1340
|
+
return null;
|
|
1341
|
+
}
|
|
1342
|
+
function buildTableMenuRegions(tableId, left, top) {
|
|
1343
|
+
return TABLE_CONTROL_MENU_ACTIONS.map((action, index) => ({
|
|
1344
|
+
type: "menu-item",
|
|
1345
|
+
tableId,
|
|
1346
|
+
action,
|
|
1347
|
+
left,
|
|
1348
|
+
top: top + index * 32,
|
|
1349
|
+
width: 168,
|
|
1350
|
+
height: 32
|
|
1351
|
+
}));
|
|
1352
|
+
}
|
|
1353
|
+
function buildCenteredPlusSegments(centerX, centerY, size) {
|
|
1354
|
+
const halfSize = size / 2;
|
|
1355
|
+
return [{
|
|
1356
|
+
fromX: centerX - halfSize,
|
|
1357
|
+
fromY: centerY,
|
|
1358
|
+
toX: centerX + halfSize,
|
|
1359
|
+
toY: centerY
|
|
1360
|
+
}, {
|
|
1361
|
+
fromX: centerX,
|
|
1362
|
+
fromY: centerY - halfSize,
|
|
1363
|
+
toX: centerX,
|
|
1364
|
+
toY: centerY + halfSize
|
|
1365
|
+
}];
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region src/views/widgets/table-controls.shape.ts
|
|
1370
|
+
const ANCHOR_MIN_WIDTH = 122;
|
|
1371
|
+
const ANCHOR_MAX_WIDTH = 240;
|
|
1372
|
+
const ANCHOR_PADDING_X = 12;
|
|
1373
|
+
const ANCHOR_TOGGLE_WIDTH = 30;
|
|
1374
|
+
const ANCHOR_OFFSET_Y = 0;
|
|
1375
|
+
const ANCHOR_BORDER = "rgba(0, 0, 0, 0.22)";
|
|
1376
|
+
const ANCHOR_DIVIDER = "rgba(0, 0, 0, 0.20)";
|
|
1377
|
+
const ANCHOR_TOGGLE_BG_ACTIVE = "rgba(0, 0, 0, 0.12)";
|
|
1378
|
+
const MENU_RADIUS = 8;
|
|
1379
|
+
const MENU_BORDER = "#d9dee7";
|
|
1380
|
+
const MENU_HOVER_BG = "#f1f3f4";
|
|
1381
|
+
const INSERT_BUTTON_VISUAL_SIZE = 18;
|
|
1382
|
+
const INSERT_BUTTON_PLUS_SIZE = 8;
|
|
1383
|
+
var SheetTableControlsShape = class extends _univerjs_engine_render.Shape {
|
|
1384
|
+
constructor(key, _getSkeleton) {
|
|
1385
|
+
super(key, {
|
|
1386
|
+
evented: true,
|
|
1387
|
+
fill: "rgba(0, 0, 0, 0)",
|
|
1388
|
+
zIndex: 5001
|
|
1389
|
+
});
|
|
1390
|
+
this._getSkeleton = _getSkeleton;
|
|
1391
|
+
_defineProperty(this, "_items", []);
|
|
1392
|
+
_defineProperty(this, "_regions", []);
|
|
1393
|
+
_defineProperty(this, "_openedMenuTableId", null);
|
|
1394
|
+
_defineProperty(this, "_hoveredRegion", null);
|
|
1395
|
+
_defineProperty(this, "_hoveredInsertRegion", null);
|
|
1396
|
+
_defineProperty(this, "_menuLabels", {
|
|
1397
|
+
rename: "Rename table",
|
|
1398
|
+
"update-range": "Update range",
|
|
1399
|
+
"set-theme": "Set theme",
|
|
1400
|
+
delete: "Remove table"
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
setItems(items) {
|
|
1404
|
+
this._items = items;
|
|
1405
|
+
this.makeDirty(true);
|
|
1406
|
+
}
|
|
1407
|
+
setMenuLabels(labels) {
|
|
1408
|
+
this._menuLabels = labels;
|
|
1409
|
+
this.makeDirty(true);
|
|
1410
|
+
}
|
|
1411
|
+
setOpenedMenuTableId(tableId) {
|
|
1412
|
+
if (this._openedMenuTableId === tableId) return;
|
|
1413
|
+
this._openedMenuTableId = tableId;
|
|
1414
|
+
this.makeDirty(true);
|
|
1415
|
+
}
|
|
1416
|
+
getOpenedMenuTableId() {
|
|
1417
|
+
return this._openedMenuTableId;
|
|
1418
|
+
}
|
|
1419
|
+
setHoveredRegion(region) {
|
|
1420
|
+
if (this._hoveredRegion === region) return;
|
|
1421
|
+
this._hoveredRegion = region;
|
|
1422
|
+
this.makeDirty(true);
|
|
1423
|
+
}
|
|
1424
|
+
setHoveredInsertRegion(region) {
|
|
1425
|
+
if (this._hoveredInsertRegion === region) return;
|
|
1426
|
+
this._hoveredInsertRegion = region;
|
|
1427
|
+
this.makeDirty(true);
|
|
1428
|
+
}
|
|
1429
|
+
hitTest(x, y) {
|
|
1430
|
+
return hitTestTableControl(this._regions, x, y);
|
|
1431
|
+
}
|
|
1432
|
+
isHit(coord) {
|
|
1433
|
+
return this.hitTest(coord.x, coord.y) != null;
|
|
1434
|
+
}
|
|
1435
|
+
refreshBounds() {
|
|
1436
|
+
const skeleton = this._getSkeleton();
|
|
1437
|
+
if (!skeleton) {
|
|
1438
|
+
this.hide();
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
this.show();
|
|
1442
|
+
this.transformByState({
|
|
1443
|
+
left: 0,
|
|
1444
|
+
top: 0,
|
|
1445
|
+
width: skeleton.rowHeaderWidth + skeleton.columnTotalWidth,
|
|
1446
|
+
height: skeleton.columnHeaderHeight + skeleton.rowTotalHeight
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
_draw(ctx) {
|
|
1450
|
+
this._regions = [];
|
|
1451
|
+
const skeleton = this._getSkeleton();
|
|
1452
|
+
if (!skeleton) return;
|
|
1453
|
+
ctx.save();
|
|
1454
|
+
ctx.textBaseline = "middle";
|
|
1455
|
+
for (const item of this._items) this._drawAnchor(ctx, skeleton, item);
|
|
1456
|
+
if (this._hoveredInsertRegion) {
|
|
1457
|
+
var _item$fill;
|
|
1458
|
+
const item = this._items.find((renderItem) => {
|
|
1459
|
+
var _this$_hoveredInsertR;
|
|
1460
|
+
return renderItem.tableId === ((_this$_hoveredInsertR = this._hoveredInsertRegion) === null || _this$_hoveredInsertR === void 0 ? void 0 : _this$_hoveredInsertR.tableId);
|
|
1461
|
+
});
|
|
1462
|
+
this._drawInsertButton(ctx, this._hoveredInsertRegion, (_item$fill = item === null || item === void 0 ? void 0 : item.fill) !== null && _item$fill !== void 0 ? _item$fill : "#355bb7");
|
|
1463
|
+
this._regions.push(this._hoveredInsertRegion);
|
|
1464
|
+
}
|
|
1465
|
+
ctx.restore();
|
|
1466
|
+
}
|
|
1467
|
+
_drawAnchor(ctx, skeleton, item) {
|
|
1468
|
+
const position = skeleton.getNoMergeCellWithCoordByIndex(item.range.startRow, item.range.startColumn);
|
|
1469
|
+
const left = position.startX;
|
|
1470
|
+
const rawTop = position.startY - 28 - ANCHOR_OFFSET_Y;
|
|
1471
|
+
const top = Math.max(0, rawTop);
|
|
1472
|
+
const width = Math.max(ANCHOR_MIN_WIDTH, Math.min(ANCHOR_MAX_WIDTH, item.tableName.length * 8.5 + ANCHOR_PADDING_X * 2 + ANCHOR_TOGGLE_WIDTH));
|
|
1473
|
+
const toggleRegion = {
|
|
1474
|
+
type: "anchor-menu-toggle",
|
|
1475
|
+
tableId: item.tableId,
|
|
1476
|
+
left: left + width - ANCHOR_TOGGLE_WIDTH,
|
|
1477
|
+
top,
|
|
1478
|
+
width: ANCHOR_TOGGLE_WIDTH,
|
|
1479
|
+
height: 28
|
|
1480
|
+
};
|
|
1481
|
+
ctx.save();
|
|
1482
|
+
ctx.translateWithPrecision(left, top);
|
|
1483
|
+
this._drawTopRoundedRect(ctx, width, 28, 14, item.fill, ANCHOR_BORDER);
|
|
1484
|
+
this._drawAnchorToggle(ctx, width, item.text, this._openedMenuTableId === item.tableId || this._isSameRegion(this._hoveredRegion, toggleRegion));
|
|
1485
|
+
ctx.font = `600 13px ${_univerjs_engine_render.DEFAULT_FONTFACE_PLANE}`;
|
|
1486
|
+
ctx.fillStyle = item.text;
|
|
1487
|
+
ctx.textAlign = "left";
|
|
1488
|
+
ctx.fillText(item.tableName, ANCHOR_PADDING_X, 28 / 2);
|
|
1489
|
+
ctx.restore();
|
|
1490
|
+
this._regions.push({
|
|
1491
|
+
type: "anchor-main",
|
|
1492
|
+
tableId: item.tableId,
|
|
1493
|
+
left,
|
|
1494
|
+
top,
|
|
1495
|
+
width,
|
|
1496
|
+
height: 28
|
|
1497
|
+
});
|
|
1498
|
+
this._regions.push(toggleRegion);
|
|
1499
|
+
if (this._openedMenuTableId === item.tableId) this._drawMenu(ctx, item.tableId, left, top + 28);
|
|
1500
|
+
}
|
|
1501
|
+
_drawAnchorToggle(ctx, anchorWidth, color, active) {
|
|
1502
|
+
const toggleLeft = anchorWidth - ANCHOR_TOGGLE_WIDTH;
|
|
1503
|
+
if (active) this._drawRightTopRoundedRect(ctx, toggleLeft, anchorWidth, 28, 14, ANCHOR_TOGGLE_BG_ACTIVE);
|
|
1504
|
+
ctx.save();
|
|
1505
|
+
ctx.beginPath();
|
|
1506
|
+
ctx.strokeStyle = ANCHOR_DIVIDER;
|
|
1507
|
+
ctx.lineWidth = 1;
|
|
1508
|
+
ctx.moveTo(toggleLeft + .5, 5);
|
|
1509
|
+
ctx.lineTo(toggleLeft + .5, 28 - 5);
|
|
1510
|
+
ctx.stroke();
|
|
1511
|
+
ctx.restore();
|
|
1512
|
+
const centerX = anchorWidth - ANCHOR_TOGGLE_WIDTH / 2;
|
|
1513
|
+
const centerY = 28 / 2;
|
|
1514
|
+
ctx.save();
|
|
1515
|
+
ctx.beginPath();
|
|
1516
|
+
ctx.strokeStyle = color;
|
|
1517
|
+
ctx.lineWidth = 1.6;
|
|
1518
|
+
ctx.lineCap = "round";
|
|
1519
|
+
ctx.moveTo(centerX - 5, centerY - 4);
|
|
1520
|
+
ctx.lineTo(centerX + 5, centerY - 4);
|
|
1521
|
+
ctx.moveTo(centerX - 5, centerY);
|
|
1522
|
+
ctx.lineTo(centerX + 5, centerY);
|
|
1523
|
+
ctx.moveTo(centerX - 5, centerY + 4);
|
|
1524
|
+
ctx.lineTo(centerX + 5, centerY + 4);
|
|
1525
|
+
ctx.stroke();
|
|
1526
|
+
ctx.restore();
|
|
1527
|
+
}
|
|
1528
|
+
_drawTopRoundedRect(ctx, width, height, radius, fill, stroke) {
|
|
1529
|
+
const r = Math.min(radius, width / 2, height);
|
|
1530
|
+
ctx.beginPath();
|
|
1531
|
+
ctx.moveTo(0, height);
|
|
1532
|
+
ctx.lineTo(0, r);
|
|
1533
|
+
ctx.arcTo(0, 0, r, 0, r);
|
|
1534
|
+
ctx.lineTo(width - r, 0);
|
|
1535
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1536
|
+
ctx.lineTo(width, height);
|
|
1537
|
+
ctx.closePath();
|
|
1538
|
+
ctx.fillStyle = fill;
|
|
1539
|
+
ctx.fill();
|
|
1540
|
+
if (stroke) {
|
|
1541
|
+
ctx.strokeStyle = stroke;
|
|
1542
|
+
ctx.lineWidth = 1;
|
|
1543
|
+
ctx.stroke();
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
_drawRightTopRoundedRect(ctx, left, width, height, radius, fill) {
|
|
1547
|
+
const r = Math.min(radius, width - left, height);
|
|
1548
|
+
ctx.save();
|
|
1549
|
+
ctx.beginPath();
|
|
1550
|
+
ctx.moveTo(left, height);
|
|
1551
|
+
ctx.lineTo(left, 0);
|
|
1552
|
+
ctx.lineTo(width - r, 0);
|
|
1553
|
+
ctx.arcTo(width, 0, width, r, r);
|
|
1554
|
+
ctx.lineTo(width, height);
|
|
1555
|
+
ctx.closePath();
|
|
1556
|
+
ctx.fillStyle = fill;
|
|
1557
|
+
ctx.fill();
|
|
1558
|
+
ctx.restore();
|
|
1559
|
+
}
|
|
1560
|
+
_drawMenu(ctx, tableId, left, top) {
|
|
1561
|
+
const regions = buildTableMenuRegions(tableId, left, top);
|
|
1562
|
+
ctx.save();
|
|
1563
|
+
ctx.translateWithPrecision(left, top);
|
|
1564
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1565
|
+
width: 168,
|
|
1566
|
+
height: regions.length * 32,
|
|
1567
|
+
radius: MENU_RADIUS,
|
|
1568
|
+
fill: "#fff",
|
|
1569
|
+
stroke: MENU_BORDER
|
|
1570
|
+
});
|
|
1571
|
+
ctx.restore();
|
|
1572
|
+
for (const region of regions) {
|
|
1573
|
+
if (this._isSameRegion(this._hoveredRegion, region)) {
|
|
1574
|
+
ctx.save();
|
|
1575
|
+
ctx.fillStyle = MENU_HOVER_BG;
|
|
1576
|
+
ctx.fillRectByPrecision(region.left, region.top, region.width, region.height);
|
|
1577
|
+
ctx.restore();
|
|
1578
|
+
}
|
|
1579
|
+
ctx.save();
|
|
1580
|
+
ctx.font = `12px ${_univerjs_engine_render.DEFAULT_FONTFACE_PLANE}`;
|
|
1581
|
+
ctx.fillStyle = region.action === "delete" ? "#d92d20" : "#344054";
|
|
1582
|
+
ctx.textAlign = "left";
|
|
1583
|
+
ctx.fillText(this._menuLabels[region.action], region.left + 12, region.top + region.height / 2);
|
|
1584
|
+
ctx.restore();
|
|
1585
|
+
}
|
|
1586
|
+
this._regions.push(...regions);
|
|
1587
|
+
}
|
|
1588
|
+
_drawInsertButton(ctx, region, fill) {
|
|
1589
|
+
const centerX = region.left + region.width / 2;
|
|
1590
|
+
const centerY = region.top + region.height / 2;
|
|
1591
|
+
const radius = INSERT_BUTTON_VISUAL_SIZE / 2;
|
|
1592
|
+
ctx.save();
|
|
1593
|
+
ctx.beginPath();
|
|
1594
|
+
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2);
|
|
1595
|
+
ctx.fillStyle = "#fff";
|
|
1596
|
+
ctx.fill();
|
|
1597
|
+
ctx.strokeStyle = fill;
|
|
1598
|
+
ctx.stroke();
|
|
1599
|
+
ctx.beginPath();
|
|
1600
|
+
ctx.strokeStyle = fill;
|
|
1601
|
+
ctx.lineWidth = 1;
|
|
1602
|
+
ctx.lineCap = "round";
|
|
1603
|
+
for (const segment of buildCenteredPlusSegments(centerX, centerY, INSERT_BUTTON_PLUS_SIZE)) {
|
|
1604
|
+
ctx.moveTo(segment.fromX, segment.fromY);
|
|
1605
|
+
ctx.lineTo(segment.toX, segment.toY);
|
|
1606
|
+
}
|
|
1607
|
+
ctx.stroke();
|
|
1608
|
+
ctx.restore();
|
|
1609
|
+
}
|
|
1610
|
+
_isSameRegion(a, b) {
|
|
1611
|
+
return Boolean(a && a.type === b.type && a.tableId === b.tableId && a.action === b.action && a.index === b.index);
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
|
|
1169
1615
|
//#endregion
|
|
1170
1616
|
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1171
1617
|
let SheetTableThemeUIController = class SheetTableThemeUIController extends _univerjs_core.Disposable {
|
|
@@ -1188,372 +1634,364 @@ let SheetTableThemeUIController = class SheetTableThemeUIController extends _uni
|
|
|
1188
1634
|
SheetTableThemeUIController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService))], SheetTableThemeUIController);
|
|
1189
1635
|
|
|
1190
1636
|
//#endregion
|
|
1191
|
-
//#region src/
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
const univerInstanceService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUniverInstanceService);
|
|
1202
|
-
const workbookPermissionInitState = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(_univerjs_sheets.WorkbookPermissionService).unitPermissionInitStateChange$, false);
|
|
1203
|
-
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1204
|
-
const rangeThemeModel = (0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetRangeThemeModel);
|
|
1205
|
-
const tableRefresh$ = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(SheetTableThemeUIController).refreshTable$);
|
|
1206
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1207
|
-
const selections = (0, _univerjs_ui.useObservable)((0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetsSelectionsService).selectionChanged$, [{
|
|
1208
|
-
range: (0, _univerjs_core.cellToRange)(0, 0),
|
|
1209
|
-
primary: null
|
|
1210
|
-
}]);
|
|
1211
|
-
const [, setRefresh] = (0, react.useState)(Math.random());
|
|
1212
|
-
const tableConfig = (0, _univerjs_ui.useDependency)(_univerjs_core.IConfigService).getConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY);
|
|
1213
|
-
const anchorHeight = (_tableConfig$anchorHe = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorHeight) !== null && _tableConfig$anchorHe !== void 0 ? _tableConfig$anchorHe : 24;
|
|
1214
|
-
const anchorBackgroundColor = (_tableConfig$anchorBa = tableConfig === null || tableConfig === void 0 ? void 0 : tableConfig.anchorBackgroundColor) !== null && _tableConfig$anchorBa !== void 0 ? _tableConfig$anchorBa : "rgb(53,91,183)";
|
|
1215
|
-
const updateOpenState = (tableId, isOpen) => {
|
|
1216
|
-
setOpenStates((prev) => ({
|
|
1217
|
-
...prev,
|
|
1218
|
-
[tableId]: isOpen
|
|
1219
|
-
}));
|
|
1220
|
-
};
|
|
1221
|
-
(0, react.useEffect)(() => {
|
|
1222
|
-
setRefresh(Math.random());
|
|
1223
|
-
}, [tableRefresh$]);
|
|
1224
|
-
if (!(anchorPosition === null || anchorPosition === void 0 ? void 0 : anchorPosition.length)) return null;
|
|
1225
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
1226
|
-
if (!target) return null;
|
|
1227
|
-
const { unitId, subUnitId } = target;
|
|
1228
|
-
const handleChangeTableName = (tableId, name) => {
|
|
1229
|
-
var _tableManager$getTabl;
|
|
1230
|
-
if (((_tableManager$getTabl = tableManager.getTableById(unitId, tableId)) === null || _tableManager$getTabl === void 0 ? void 0 : _tableManager$getTabl.getDisplayName()) === name) {
|
|
1231
|
-
setInputFocusId("");
|
|
1232
|
-
setInputValue("");
|
|
1233
|
-
return;
|
|
1234
|
-
}
|
|
1235
|
-
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1236
|
-
tableId,
|
|
1237
|
-
unitId,
|
|
1238
|
-
name
|
|
1239
|
-
});
|
|
1240
|
-
setInputValue("");
|
|
1241
|
-
setInputFocusId("");
|
|
1242
|
-
};
|
|
1243
|
-
const handleChangeRange = async (tableId) => {
|
|
1244
|
-
const table = tableManager.getTableById(unitId, tableId);
|
|
1245
|
-
if (!table) return;
|
|
1246
|
-
const selection = await openRangeSelector(injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1247
|
-
if (!selection) return;
|
|
1248
|
-
commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1249
|
-
tableId,
|
|
1250
|
-
unitId,
|
|
1251
|
-
updateRange: { newRange: selection.range }
|
|
1252
|
-
});
|
|
1253
|
-
};
|
|
1254
|
-
if (!workbookPermissionInitState) return null;
|
|
1255
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1256
|
-
className: "univer-absolute univer-z-50 univer-size-0",
|
|
1257
|
-
children: anchorPosition.map((item) => {
|
|
1258
|
-
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4, _openStates$item$tabl;
|
|
1259
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1260
|
-
if (!table) return null;
|
|
1261
|
-
const rangeTheme = rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1262
|
-
const headerBgColor = (_rangeTheme$getHeader = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader2 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader2 === void 0 || (_rangeTheme$getHeader2 = _rangeTheme$getHeader2.bg) === null || _rangeTheme$getHeader2 === void 0 ? void 0 : _rangeTheme$getHeader2.rgb) !== null && _rangeTheme$getHeader !== void 0 ? _rangeTheme$getHeader : anchorBackgroundColor;
|
|
1263
|
-
const headerTextColor = (_rangeTheme$getHeader3 = rangeTheme === null || rangeTheme === void 0 || (_rangeTheme$getHeader4 = rangeTheme.getHeaderRowStyle()) === null || _rangeTheme$getHeader4 === void 0 || (_rangeTheme$getHeader4 = _rangeTheme$getHeader4.cl) === null || _rangeTheme$getHeader4 === void 0 ? void 0 : _rangeTheme$getHeader4.rgb) !== null && _rangeTheme$getHeader3 !== void 0 ? _rangeTheme$getHeader3 : "rgb(255, 255, 255)";
|
|
1264
|
-
const tableRange = table.getRange();
|
|
1265
|
-
if (!(selections === null || selections === void 0 ? void 0 : selections.length)) return null;
|
|
1266
|
-
const lastRange = selections[selections.length - 1].range;
|
|
1267
|
-
const shouldHidden = !_univerjs_core.Rectangle.intersects(tableRange, lastRange) && item.y <= 20;
|
|
1268
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1269
|
-
className: (0, _univerjs_design.clsx)("univer-shadow-xs univer-absolute univer-box-border univer-cursor-pointer univer-items-center univer-rounded-xl univer-px-2", _univerjs_design.borderClassName, {
|
|
1270
|
-
"univer-flex": !shouldHidden,
|
|
1271
|
-
"univer-hidden": shouldHidden
|
|
1272
|
-
}),
|
|
1273
|
-
style: {
|
|
1274
|
-
left: item.x,
|
|
1275
|
-
top: Math.max(item.y, 0),
|
|
1276
|
-
backgroundColor: headerBgColor,
|
|
1277
|
-
color: headerTextColor,
|
|
1278
|
-
borderWidth: "0.5px",
|
|
1279
|
-
height: anchorHeight ? `${anchorHeight}px` : "24px"
|
|
1280
|
-
},
|
|
1281
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1282
|
-
className: "univer-text-nowrap",
|
|
1283
|
-
children: inputFocusId === item.tableId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1284
|
-
className: "univer-h-[18px] univer-min-w-16 univer-rounded-none",
|
|
1285
|
-
inputClass: "univer-h-[18px] univer-w-[80px]",
|
|
1286
|
-
value: inputValue,
|
|
1287
|
-
onChange: (v) => setInputValue(v),
|
|
1288
|
-
onBlur: () => handleChangeTableName(item.tableId, inputValue),
|
|
1289
|
-
onKeyDown: (e) => {
|
|
1290
|
-
if (e.key === "Enter") handleChangeTableName(item.tableId, inputValue);
|
|
1291
|
-
},
|
|
1292
|
-
autoFocus: inputFocusId === item.tableId
|
|
1293
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1294
|
-
className: "univer-h-[18px] univer-max-w-24 univer-truncate univer-text-sm",
|
|
1295
|
-
children: item.tableName
|
|
1296
|
-
})
|
|
1297
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
1298
|
-
align: "start",
|
|
1299
|
-
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1300
|
-
className: "univer-py-2",
|
|
1301
|
-
children: [
|
|
1302
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1303
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1304
|
-
onClick: () => {
|
|
1305
|
-
setInputFocusId(item.tableId);
|
|
1306
|
-
setInputValue(item.tableName);
|
|
1307
|
-
},
|
|
1308
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RenameIcon, {}), localeService.t("sheets-table.rename")]
|
|
1309
|
-
}),
|
|
1310
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1311
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1312
|
-
onClick: () => handleChangeRange(item.tableId),
|
|
1313
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1314
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.GridOutlineIcon, {}), localeService.t("sheets-table.updateRange")]
|
|
1315
|
-
}),
|
|
1316
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1317
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-gap-2 univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1318
|
-
onClick: () => {
|
|
1319
|
-
updateOpenState(item.tableId, false);
|
|
1320
|
-
const table = tableManager.getTableById(unitId, item.tableId);
|
|
1321
|
-
if (!table) return;
|
|
1322
|
-
const tableConfig = table.getTableConfig();
|
|
1323
|
-
const sidebarConfig = {
|
|
1324
|
-
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1325
|
-
header: { title: localeService.t("sheets-table.tableStyle") },
|
|
1326
|
-
children: {
|
|
1327
|
-
label: SHEET_TABLE_THEME_PANEL,
|
|
1328
|
-
oldConfig: tableConfig,
|
|
1329
|
-
unitId,
|
|
1330
|
-
subUnitId,
|
|
1331
|
-
tableId: item.tableId
|
|
1332
|
-
},
|
|
1333
|
-
width: 330
|
|
1334
|
-
};
|
|
1335
|
-
sidebarService.open(sidebarConfig);
|
|
1336
|
-
},
|
|
1337
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.PaintBucketDoubleIcon, { extend: { colorChannel1: "rgb(53,91,183)" } }), localeService.t("sheets-table.setTheme")]
|
|
1338
|
-
}),
|
|
1339
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-my-1 univer-h-px univer-w-full univer-bg-gray-200" }),
|
|
1340
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1341
|
-
className: "univer-flex univer-min-w-32 univer-cursor-pointer univer-items-center univer-px-2 univer-py-1 univer-text-sm hover:univer-bg-gray-200",
|
|
1342
|
-
onClick: () => {
|
|
1343
|
-
updateOpenState(item.tableId, false);
|
|
1344
|
-
commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, {
|
|
1345
|
-
tableId: item.tableId,
|
|
1346
|
-
subUnitId,
|
|
1347
|
-
unitId
|
|
1348
|
-
});
|
|
1349
|
-
},
|
|
1350
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteIcon, { className: "univer-mr-2" }), localeService.t("sheets-table.removeTable")]
|
|
1351
|
-
})
|
|
1352
|
-
]
|
|
1353
|
-
}),
|
|
1354
|
-
open: (_openStates$item$tabl = openStates[item.tableId]) !== null && _openStates$item$tabl !== void 0 ? _openStates$item$tabl : false,
|
|
1355
|
-
onOpenChange: (isOpen) => {
|
|
1356
|
-
updateOpenState(item.tableId, isOpen);
|
|
1357
|
-
},
|
|
1358
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {}) })
|
|
1359
|
-
}, item.tableId)]
|
|
1360
|
-
}, item.tableId);
|
|
1361
|
-
})
|
|
1362
|
-
});
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1365
|
-
//#endregion
|
|
1366
|
-
//#region src/controllers/sheet-table-anchor.controller.ts
|
|
1367
|
-
let SheetTableAnchorController = class SheetTableAnchorController extends _univerjs_core.Disposable {
|
|
1368
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _renderManagerService, _commandService, _univerInstanceService, _uiPartsService, _tableManager, _scrollManagerService, _workbookPermissionService, _permissionService) {
|
|
1637
|
+
//#region src/controllers/sheet-table-controls-render.controller.ts
|
|
1638
|
+
const TABLE_CONTROLS_LAYER_INDEX = 5002;
|
|
1639
|
+
const TABLE_CONTROL_GAP_ROW = 0;
|
|
1640
|
+
const TABLE_RENDER_REFRESH_COMMANDS = new Set([_univerjs_sheets_ui.SetScrollOperation.id, _univerjs_sheets_ui.SetZoomRatioOperation.id]);
|
|
1641
|
+
function isSameTopGap(left, right) {
|
|
1642
|
+
if (left === null || right === null) return left === right;
|
|
1643
|
+
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
1644
|
+
}
|
|
1645
|
+
let SheetTableControlsRenderController = class SheetTableControlsRenderController extends _univerjs_core.Disposable {
|
|
1646
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService) {
|
|
1369
1647
|
super();
|
|
1370
1648
|
this._context = _context;
|
|
1371
1649
|
this._injector = _injector;
|
|
1372
1650
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1373
|
-
this._renderManagerService = _renderManagerService;
|
|
1374
1651
|
this._commandService = _commandService;
|
|
1375
|
-
this._univerInstanceService = _univerInstanceService;
|
|
1376
|
-
this._uiPartsService = _uiPartsService;
|
|
1377
1652
|
this._tableManager = _tableManager;
|
|
1378
|
-
this.
|
|
1653
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1379
1654
|
this._workbookPermissionService = _workbookPermissionService;
|
|
1380
1655
|
this._permissionService = _permissionService;
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
this.
|
|
1386
|
-
this.
|
|
1387
|
-
this
|
|
1656
|
+
this._sheetsSelectionsService = _sheetsSelectionsService;
|
|
1657
|
+
this._selectionRenderService = _selectionRenderService;
|
|
1658
|
+
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
1659
|
+
this._localeService = _localeService;
|
|
1660
|
+
this._dialogService = _dialogService;
|
|
1661
|
+
this._sidebarService = _sidebarService;
|
|
1662
|
+
_defineProperty(this, "_shape", void 0);
|
|
1663
|
+
_defineProperty(this, "_topGapBaseBySkeleton", /* @__PURE__ */ new WeakMap());
|
|
1664
|
+
this._shape = new SheetTableControlsShape("SheetTableControlsShape", () => this._sheetSkeletonManagerService.getCurrentSkeleton() || null);
|
|
1665
|
+
this._initShape();
|
|
1666
|
+
this._initRefresh();
|
|
1667
|
+
this._refresh();
|
|
1388
1668
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1669
|
+
_initShape() {
|
|
1670
|
+
var _this$_context$compon, _this$_context$compon2;
|
|
1671
|
+
this._context.scene.addObjects([this._shape], TABLE_CONTROLS_LAYER_INDEX);
|
|
1672
|
+
this.disposeWithMe((0, _univerjs_core.toDisposable)(() => {
|
|
1673
|
+
this._context.scene.removeObjects([this._shape]);
|
|
1674
|
+
}));
|
|
1675
|
+
this.disposeWithMe(this._shape.onPointerMove$.subscribeEvent((evt, state) => {
|
|
1676
|
+
this._handlePointerMove(evt, state);
|
|
1677
|
+
}));
|
|
1678
|
+
this.disposeWithMe(this._shape.onPointerLeave$.subscribeEvent((_evt, state) => {
|
|
1679
|
+
this._handlePointerLeave(state);
|
|
1680
|
+
}));
|
|
1681
|
+
this.disposeWithMe(this._shape.onPointerDown$.subscribeEvent((evt, state) => {
|
|
1682
|
+
this._handlePointerDown(evt, state);
|
|
1683
|
+
}));
|
|
1684
|
+
this.disposeWithMe((_this$_context$compon = (_this$_context$compon2 = this._context.components.get(_univerjs_sheets_ui.SHEET_VIEW_KEY.MAIN)) === null || _this$_context$compon2 === void 0 ? void 0 : _this$_context$compon2.onPointerMove$.subscribeEvent((evt) => {
|
|
1685
|
+
const point = this._getLocalPoint(evt);
|
|
1686
|
+
const insertRegion = this._getInsertRegionFromPoint(point.x, point.y);
|
|
1687
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1688
|
+
})) !== null && _this$_context$compon !== void 0 ? _this$_context$compon : (0, _univerjs_core.toDisposable)(() => {}));
|
|
1391
1689
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
if (command.
|
|
1395
|
-
this.
|
|
1396
|
-
|
|
1397
|
-
this._timer = setTimeout(() => {
|
|
1398
|
-
this._anchorVisible$.next(true);
|
|
1399
|
-
}, 300);
|
|
1690
|
+
_initRefresh() {
|
|
1691
|
+
const commandExecuted$ = (0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
|
|
1692
|
+
if (command.type === _univerjs_core.CommandType.OPERATION && TABLE_RENDER_REFRESH_COMMANDS.has(command.id)) {
|
|
1693
|
+
this._closeFloatingControls();
|
|
1694
|
+
return true;
|
|
1400
1695
|
}
|
|
1696
|
+
return command.type === _univerjs_core.CommandType.MUTATION || command.type === _univerjs_core.CommandType.COMMAND;
|
|
1697
|
+
}));
|
|
1698
|
+
this.disposeWithMe((0, rxjs.merge)(this._context.unit.activeSheet$, this._sheetSkeletonManagerService.currentSkeleton$, this._tableManager.tableAdd$, this._tableManager.tableDelete$, this._tableManager.tableNameChanged$, this._tableManager.tableRangeChanged$, this._tableManager.tableThemeChanged$, this._sheetTableThemeUIController.refreshTable$, this._workbookPermissionService.unitPermissionInitStateChange$, this._permissionService.permissionPointUpdate$, this._sheetsSelectionsService.selectionChanged$, commandExecuted$).subscribe(() => {
|
|
1699
|
+
this._closeFloatingControls();
|
|
1700
|
+
this._refresh();
|
|
1401
1701
|
}));
|
|
1402
1702
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1703
|
+
_refresh() {
|
|
1704
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1705
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1706
|
+
if (!skeleton || !worksheet || !this._canEditWorkbook()) {
|
|
1707
|
+
this._shape.setItems([]);
|
|
1708
|
+
this._shape.refreshBounds();
|
|
1709
|
+
this._context.scene.makeDirty();
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
this._syncTopTableGap(skeleton);
|
|
1713
|
+
this._shape.setMenuLabels({
|
|
1714
|
+
rename: this._localeService.t("sheets-table.rename"),
|
|
1715
|
+
"update-range": this._localeService.t("sheets-table.updateRange"),
|
|
1716
|
+
"set-theme": this._localeService.t("sheets-table.setTheme"),
|
|
1717
|
+
delete: this._localeService.t("sheets-table.removeTable")
|
|
1718
|
+
});
|
|
1719
|
+
const unitId = this._context.unit.getUnitId();
|
|
1720
|
+
const subUnitId = worksheet.getSheetId();
|
|
1721
|
+
const items = this._tableManager.getTablesBySubunitId(unitId, subUnitId).map((table) => {
|
|
1722
|
+
var _rangeTheme$getHeader, _rangeTheme$getHeader2, _rangeTheme$getHeader3, _rangeTheme$getHeader4;
|
|
1723
|
+
const rangeTheme = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId());
|
|
1724
|
+
return {
|
|
1725
|
+
tableId: table.getId(),
|
|
1726
|
+
tableName: table.getDisplayName(),
|
|
1727
|
+
range: table.getRange(),
|
|
1728
|
+
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)",
|
|
1729
|
+
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)"
|
|
1730
|
+
};
|
|
1731
|
+
});
|
|
1732
|
+
this._shape.setItems(items);
|
|
1733
|
+
this._shape.refreshBounds();
|
|
1734
|
+
this._shape.makeDirty(true);
|
|
1735
|
+
this._context.scene.makeDirty();
|
|
1736
|
+
}
|
|
1737
|
+
_canEditWorkbook() {
|
|
1738
|
+
var _this$_permissionServ;
|
|
1739
|
+
const unitId = this._context.unit.getUnitId();
|
|
1740
|
+
return ((_this$_permissionServ = this._permissionService.getPermissionPoint(new _univerjs_sheets.WorkbookEditablePermission(unitId).id)) === null || _this$_permissionServ === void 0 ? void 0 : _this$_permissionServ.value) !== false;
|
|
1741
|
+
}
|
|
1742
|
+
_handlePointerMove(evt, state) {
|
|
1743
|
+
const point = this._getLocalPoint(evt);
|
|
1744
|
+
const hit = this._shape.hitTest(point.x, point.y);
|
|
1745
|
+
const insertRegion = this._isInsertHit(hit) ? hit : hit ? null : this._getInsertRegionFromPoint(point.x, point.y);
|
|
1746
|
+
const activeHit = hit !== null && hit !== void 0 ? hit : insertRegion;
|
|
1747
|
+
this._shape.setHoveredRegion(this._isInsertHit(hit) ? null : hit);
|
|
1748
|
+
this._shape.setHoveredInsertRegion(insertRegion);
|
|
1749
|
+
if (activeHit) {
|
|
1750
|
+
state.stopPropagation();
|
|
1751
|
+
this._context.scene.setCursor(_univerjs_engine_render.CURSOR_TYPE.POINTER);
|
|
1752
|
+
} else this._context.scene.resetCursor();
|
|
1753
|
+
}
|
|
1754
|
+
_isInsertHit(hit) {
|
|
1755
|
+
return (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-row" || (hit === null || hit === void 0 ? void 0 : hit.type) === "insert-column";
|
|
1756
|
+
}
|
|
1757
|
+
_handlePointerLeave(state) {
|
|
1758
|
+
state.stopPropagation();
|
|
1759
|
+
this._shape.setHoveredRegion(null);
|
|
1760
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1761
|
+
this._context.scene.resetCursor();
|
|
1762
|
+
}
|
|
1763
|
+
_handlePointerDown(evt, state) {
|
|
1764
|
+
var _this$_shape$hitTest;
|
|
1765
|
+
if (evt.button === 2) return;
|
|
1766
|
+
const point = this._getLocalPoint(evt);
|
|
1767
|
+
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);
|
|
1768
|
+
if (!hit) {
|
|
1769
|
+
this._closeFloatingControls();
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
state.stopPropagation();
|
|
1773
|
+
evt.stopPropagation();
|
|
1774
|
+
evt.preventDefault();
|
|
1775
|
+
this._handleHit(hit);
|
|
1776
|
+
}
|
|
1777
|
+
_handleHit(hit) {
|
|
1778
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1779
|
+
if (!worksheet) return;
|
|
1780
|
+
const unitId = this._context.unit.getUnitId();
|
|
1781
|
+
const subUnitId = worksheet.getSheetId();
|
|
1782
|
+
if (hit.type === "anchor-menu-toggle" || hit.type === "anchor-main") {
|
|
1783
|
+
this._shape.setOpenedMenuTableId(this._shape.getOpenedMenuTableId() === hit.tableId ? null : hit.tableId);
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
if (hit.type === "insert-row") {
|
|
1787
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertRowAtCommand.id, {
|
|
1788
|
+
unitId,
|
|
1789
|
+
subUnitId,
|
|
1790
|
+
tableId: hit.tableId,
|
|
1791
|
+
index: hit.index,
|
|
1792
|
+
count: 1
|
|
1415
1793
|
});
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
tableName: table.name
|
|
1794
|
+
this._closeFloatingControls();
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
if (hit.type === "insert-column") {
|
|
1798
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
1799
|
+
unitId,
|
|
1800
|
+
subUnitId,
|
|
1801
|
+
tableId: hit.tableId,
|
|
1802
|
+
index: hit.index,
|
|
1803
|
+
count: 1
|
|
1804
|
+
});
|
|
1805
|
+
this._closeFloatingControls();
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
if (hit.type !== "menu-item") return;
|
|
1809
|
+
switch (hit.action) {
|
|
1810
|
+
case "rename":
|
|
1811
|
+
this._openRenameDialog(unitId, hit.tableId);
|
|
1812
|
+
break;
|
|
1813
|
+
case "update-range":
|
|
1814
|
+
this._openRangeSelector(unitId, subUnitId, hit.tableId);
|
|
1815
|
+
break;
|
|
1816
|
+
case "set-theme":
|
|
1817
|
+
this._openThemePanel(unitId, subUnitId, hit.tableId);
|
|
1818
|
+
break;
|
|
1819
|
+
case "delete":
|
|
1820
|
+
this._commandService.executeCommand(_univerjs_sheets_table.DeleteSheetTableCommand.id, {
|
|
1821
|
+
tableId: hit.tableId,
|
|
1822
|
+
subUnitId,
|
|
1823
|
+
unitId
|
|
1447
1824
|
});
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
}));
|
|
1825
|
+
break;
|
|
1826
|
+
}
|
|
1827
|
+
this._closeFloatingControls();
|
|
1452
1828
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
const PIVOT_BUTTON_EMPTY = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");
|
|
1471
|
-
var TableButton = class {
|
|
1472
|
-
static drawNoSetting(ctx, size, fgColor, bgColor) {
|
|
1473
|
-
ctx.save();
|
|
1474
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1475
|
-
radius: 2,
|
|
1476
|
-
width: BUTTON_VIEWPORT,
|
|
1477
|
-
height: BUTTON_VIEWPORT,
|
|
1478
|
-
fill: bgColor
|
|
1829
|
+
_openRenameDialog(unitId, tableId) {
|
|
1830
|
+
this._dialogService.open({
|
|
1831
|
+
id: SHEET_TABLE_RENAME_DIALOG_ID,
|
|
1832
|
+
title: { title: this._localeService.t("sheets-table.rename") },
|
|
1833
|
+
draggable: true,
|
|
1834
|
+
destroyOnClose: true,
|
|
1835
|
+
mask: true,
|
|
1836
|
+
children: { label: {
|
|
1837
|
+
name: SHEET_TABLE_RENAME_DIALOG,
|
|
1838
|
+
props: {
|
|
1839
|
+
unitId,
|
|
1840
|
+
tableId,
|
|
1841
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1842
|
+
}
|
|
1843
|
+
} },
|
|
1844
|
+
width: 360,
|
|
1845
|
+
onClose: () => this._dialogService.close(SHEET_TABLE_RENAME_DIALOG_ID)
|
|
1479
1846
|
});
|
|
1480
|
-
ctx.lineCap = "square";
|
|
1481
|
-
ctx.strokeStyle = fgColor;
|
|
1482
|
-
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1483
|
-
ctx.beginPath();
|
|
1484
|
-
ctx.lineWidth = 1;
|
|
1485
|
-
ctx.lineCap = "round";
|
|
1486
|
-
ctx.moveTo(3, 4);
|
|
1487
|
-
ctx.lineTo(13, 4);
|
|
1488
|
-
ctx.moveTo(4.5, 8);
|
|
1489
|
-
ctx.lineTo(11.5, 8);
|
|
1490
|
-
ctx.moveTo(6, 12);
|
|
1491
|
-
ctx.lineTo(10, 12);
|
|
1492
|
-
ctx.stroke();
|
|
1493
|
-
ctx.restore();
|
|
1494
1847
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1848
|
+
async _openRangeSelector(unitId, subUnitId, tableId) {
|
|
1849
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1850
|
+
if (!table) return;
|
|
1851
|
+
const selection = await openRangeSelector(this._injector, unitId, subUnitId, table.getRange(), tableId);
|
|
1852
|
+
if (!selection) return;
|
|
1853
|
+
this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableCommand.id, {
|
|
1854
|
+
tableId,
|
|
1855
|
+
unitId,
|
|
1856
|
+
updateRange: { newRange: selection.range }
|
|
1504
1857
|
});
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1858
|
+
}
|
|
1859
|
+
_openThemePanel(unitId, subUnitId, tableId) {
|
|
1860
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
1861
|
+
if (!table) return;
|
|
1862
|
+
this._sidebarService.open({
|
|
1863
|
+
id: SHEET_TABLE_THEME_PANEL_ID,
|
|
1864
|
+
header: { title: this._localeService.t("sheets-table.tableStyle") },
|
|
1865
|
+
children: {
|
|
1866
|
+
label: SHEET_TABLE_THEME_PANEL,
|
|
1867
|
+
oldConfig: table.getTableConfig(),
|
|
1868
|
+
unitId,
|
|
1869
|
+
subUnitId,
|
|
1870
|
+
tableId
|
|
1871
|
+
},
|
|
1872
|
+
width: 330
|
|
1509
1873
|
});
|
|
1510
|
-
|
|
1874
|
+
}
|
|
1875
|
+
_getInsertRegionFromPoint(x, y) {
|
|
1876
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1877
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1878
|
+
if (!skeleton || !worksheet) return null;
|
|
1879
|
+
const unitId = this._context.unit.getUnitId();
|
|
1880
|
+
const subUnitId = worksheet.getSheetId();
|
|
1881
|
+
const tables = this._tableManager.getTablesBySubunitId(unitId, subUnitId);
|
|
1882
|
+
for (const table of tables) {
|
|
1883
|
+
const range = table.getRange();
|
|
1884
|
+
const tableBounds = this._getRangeBounds(skeleton, range);
|
|
1885
|
+
if (x < tableBounds.left || x > tableBounds.right || y < tableBounds.top || y > tableBounds.bottom) continue;
|
|
1886
|
+
if (y > this._getRangeBounds(skeleton, {
|
|
1887
|
+
...range,
|
|
1888
|
+
endRow: range.startRow
|
|
1889
|
+
}).bottom) for (let row = range.startRow + 1; row <= range.endRow; row++) {
|
|
1890
|
+
const cell = skeleton.getNoMergeCellWithCoordByIndex(row, range.startColumn);
|
|
1891
|
+
if (y >= cell.startY && y <= cell.endY) return {
|
|
1892
|
+
type: "insert-row",
|
|
1893
|
+
tableId: table.getId(),
|
|
1894
|
+
index: row + 1,
|
|
1895
|
+
left: tableBounds.left - 22 / 2,
|
|
1896
|
+
top: cell.endY - 22 / 2,
|
|
1897
|
+
width: 22,
|
|
1898
|
+
height: 22
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
return null;
|
|
1903
|
+
}
|
|
1904
|
+
_getRangeBounds(skeleton, range) {
|
|
1905
|
+
const startCell = skeleton.getNoMergeCellWithCoordByIndex(range.startRow, range.startColumn);
|
|
1906
|
+
const endCell = skeleton.getNoMergeCellWithCoordByIndex(range.endRow, range.endColumn);
|
|
1907
|
+
return {
|
|
1908
|
+
left: startCell.startX,
|
|
1909
|
+
top: startCell.startY,
|
|
1910
|
+
right: endCell.endX,
|
|
1911
|
+
bottom: endCell.endY
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
_syncTopTableGap(skeleton) {
|
|
1915
|
+
const worksheet = this._context.unit.getActiveSheet();
|
|
1916
|
+
if (!worksheet) return;
|
|
1917
|
+
const unitId = this._context.unit.getUnitId();
|
|
1918
|
+
const subUnitId = worksheet.getSheetId();
|
|
1919
|
+
const hasTopTable = this._tableManager.getTablesBySubunitId(unitId, subUnitId).some((table) => table.getRange().startRow === 0);
|
|
1920
|
+
const current = skeleton.gapConfig;
|
|
1921
|
+
const rowGaps = { ...current.rowGaps };
|
|
1922
|
+
const previousTopGap = rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null;
|
|
1923
|
+
let shouldSync = false;
|
|
1924
|
+
if (hasTopTable) {
|
|
1925
|
+
var _baseGap$size;
|
|
1926
|
+
if (!this._topGapBaseBySkeleton.has(skeleton)) this._topGapBaseBySkeleton.set(skeleton, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null);
|
|
1927
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1928
|
+
rowGaps[TABLE_CONTROL_GAP_ROW] = {
|
|
1929
|
+
...baseGap !== null && baseGap !== void 0 ? baseGap : rowGaps[TABLE_CONTROL_GAP_ROW],
|
|
1930
|
+
size: ((_baseGap$size = baseGap === null || baseGap === void 0 ? void 0 : baseGap.size) !== null && _baseGap$size !== void 0 ? _baseGap$size : 0) + 32
|
|
1931
|
+
};
|
|
1932
|
+
shouldSync = true;
|
|
1933
|
+
} else if (this._topGapBaseBySkeleton.has(skeleton)) {
|
|
1934
|
+
const baseGap = this._topGapBaseBySkeleton.get(skeleton);
|
|
1935
|
+
if (baseGap) rowGaps[TABLE_CONTROL_GAP_ROW] = { ...baseGap };
|
|
1936
|
+
else delete rowGaps[TABLE_CONTROL_GAP_ROW];
|
|
1937
|
+
this._topGapBaseBySkeleton.delete(skeleton);
|
|
1938
|
+
shouldSync = true;
|
|
1939
|
+
}
|
|
1940
|
+
if (!shouldSync) return;
|
|
1941
|
+
if (isSameTopGap(previousTopGap, rowGaps[TABLE_CONTROL_GAP_ROW] ? { ...rowGaps[TABLE_CONTROL_GAP_ROW] } : null)) return;
|
|
1942
|
+
skeleton.setGapConfig({
|
|
1943
|
+
...current,
|
|
1944
|
+
rowGaps
|
|
1945
|
+
});
|
|
1946
|
+
this._refreshSelections();
|
|
1947
|
+
}
|
|
1948
|
+
_refreshSelections() {
|
|
1949
|
+
this._selectionRenderService.resetSelectionsByModelData(this._sheetsSelectionsService.getCurrentSelections());
|
|
1950
|
+
}
|
|
1951
|
+
_closeFloatingControls() {
|
|
1952
|
+
this._shape.setOpenedMenuTableId(null);
|
|
1953
|
+
this._shape.setHoveredInsertRegion(null);
|
|
1954
|
+
this._shape.setHoveredRegion(null);
|
|
1955
|
+
}
|
|
1956
|
+
_getLocalPoint(evt) {
|
|
1957
|
+
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
1958
|
+
if (skeleton) return (0, _univerjs_sheets_ui.getTransformCoord)(evt.offsetX, evt.offsetY, this._context.scene, skeleton);
|
|
1959
|
+
return {
|
|
1960
|
+
x: evt.offsetX,
|
|
1961
|
+
y: evt.offsetY
|
|
1962
|
+
};
|
|
1511
1963
|
}
|
|
1512
1964
|
};
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
* See the License for the specific language governing permissions and
|
|
1529
|
-
* limitations under the License.
|
|
1530
|
-
*/
|
|
1531
|
-
const filterPartial = ["M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z"];
|
|
1532
|
-
const filteredSortAsc = ["M12.4008 13.1831C12.6907 13.1831 12.9258 12.9481 12.9258 12.6581V4.60873L14.013 5.69597C14.218 5.901 14.5505 5.901 14.7555 5.69597C14.9605 5.49094 14.9605 5.15853 14.7555 4.95351L12.7721 2.97017C12.5671 2.76515 12.2347 2.76515 12.0297 2.97017L10.0463 4.95351C9.84132 5.15853 9.84132 5.49094 10.0463 5.69597C10.2514 5.901 10.5838 5.901 10.7888 5.69597L11.8758 4.60901V12.6581C11.8758 12.9481 12.1108 13.1831 12.4008 13.1831Z", "M1.28069 4.85447C0.842195 4.33439 1.21191 3.5391 1.89218 3.5391H8.59333C9.2736 3.5391 9.64331 4.33439 9.20482 4.85447L6.51052 8.0501V11.6601C6.51052 12.2245 5.94174 12.6114 5.41683 12.404L4.48092 12.0343C4.1756 11.9136 3.97498 11.6187 3.97498 11.2904V8.0501L1.28069 4.85447Z"];
|
|
1533
|
-
const filteredSortDesc = ["M12.4008 2.81641C12.6907 2.81641 12.9258 3.05146 12.9258 3.34141V11.3908L14.013 10.3036C14.218 10.0986 14.5505 10.0986 14.7555 10.3036C14.9605 10.5086 14.9605 10.841 14.7555 11.046L12.7721 13.0294C12.5671 13.2344 12.2347 13.2344 12.0297 13.0294L10.0463 11.046C9.84132 10.841 9.84132 10.5086 10.0463 10.3036C10.2514 10.0986 10.5838 10.0986 10.7888 10.3036L11.8758 11.3905V3.34141C11.8758 3.05146 12.1108 2.81641 12.4008 2.81641Z", "M1.28069 4.85444C0.842195 4.33435 1.21191 3.53906 1.89218 3.53906H8.59333C9.2736 3.53906 9.64331 4.33435 9.20482 4.85443L6.51052 8.05006V11.6601C6.51052 12.2245 5.94174 12.6113 5.41683 12.404L4.48092 12.0342C4.1756 11.9136 3.97498 11.6186 3.97498 11.2903V8.05006L1.28069 4.85444Z"];
|
|
1534
|
-
const filterNoneSortAsc = [
|
|
1535
|
-
"M11.9003 13.7046C11.9003 13.9969 11.6633 14.2339 11.371 14.2339C11.0787 14.2339 10.8417 13.9969 10.8417 13.7046V3.57272L9.74577 4.66862C9.53906 4.87534 9.20391 4.87534 8.9972 4.66862C8.79048 4.46191 8.79048 4.12676 8.9972 3.92005L10.9969 1.92039C11.2036 1.71368 11.5387 1.71368 11.7454 1.92039L13.7451 3.92005C13.9518 4.12676 13.9518 4.46191 13.7451 4.66862C13.5384 4.87534 13.2032 4.87534 12.9965 4.66862L11.9003 3.57243V13.7046Z",
|
|
1536
|
-
"M2.69779 10.0113C2.40546 10.0113 2.16847 9.77429 2.16847 9.48196C2.16847 9.18962 2.40546 8.95264 2.69779 8.95264H6.67804C6.89213 8.95264 7.08514 9.0816 7.16707 9.2794C7.249 9.47719 7.20371 9.70486 7.05233 9.85624L3.97569 12.9329H6.67804C6.97038 12.9329 7.20736 13.1699 7.20736 13.4622C7.20736 13.7545 6.97038 13.9915 6.67804 13.9915H2.69779C2.4837 13.9915 2.29069 13.8626 2.20876 13.6648C2.12684 13.467 2.17212 13.2393 2.32351 13.0879L5.40015 10.0113H2.69779Z",
|
|
1537
|
-
"M5.51638 2.58693C5.23363 1.81542 4.14248 1.81543 3.85973 2.58693L2.13245 7.29995C2.03185 7.57443 2.17281 7.87849 2.4473 7.97909C2.72178 8.07969 3.02584 7.93872 3.12644 7.66424L3.64346 6.25351L3.64504 6.25351H5.73266L6.24968 7.66424C6.35027 7.93872 6.65433 8.07969 6.92882 7.97909C7.2033 7.87849 7.34426 7.57443 7.24367 7.29995L5.51638 2.58693ZM5.34467 5.19487L4.68806 3.40325L4.03144 5.19487H5.34467Z"
|
|
1538
|
-
];
|
|
1539
|
-
const filterNoneSortDesc = [
|
|
1540
|
-
"M11.9003 2.29495C11.9003 2.00261 11.6633 1.76562 11.371 1.76562C11.0787 1.76562 10.8417 2.00261 10.8417 2.29495V12.4268L9.74577 11.3309C9.53906 11.1242 9.20391 11.1242 8.9972 11.3309C8.79048 11.5376 8.79048 11.8727 8.9972 12.0795L10.9969 14.0791C11.2036 14.2858 11.5387 14.2858 11.7454 14.0791L13.7451 12.0795C13.9518 11.8727 13.9518 11.5376 13.7451 11.3309C13.5384 11.1242 13.2032 11.1242 12.9965 11.3309L11.9003 12.4271V2.29495Z",
|
|
1541
|
-
"M2.69792 10.0113C2.40558 10.0113 2.16859 9.77429 2.16859 9.48196C2.16859 9.18962 2.40558 8.95264 2.69792 8.95264H6.67816C6.89225 8.95264 7.08526 9.0816 7.16719 9.2794C7.24912 9.47719 7.20384 9.70486 7.05245 9.85624L3.97581 12.9329H6.67816C6.9705 12.9329 7.20749 13.1699 7.20749 13.4622C7.20749 13.7545 6.9705 13.9915 6.67816 13.9915H2.69792C2.48383 13.9915 2.29082 13.8626 2.20889 13.6648C2.12696 13.467 2.17224 13.2393 2.32363 13.0879L5.40027 10.0113H2.69792Z",
|
|
1542
|
-
"M5.5165 2.58693C5.23375 1.81542 4.1426 1.81543 3.85985 2.58693L2.13257 7.29995C2.03197 7.57443 2.17294 7.8785 2.44742 7.97909C2.7219 8.07969 3.02596 7.93872 3.12656 7.66424L3.64358 6.25351L3.64516 6.25351H5.73278L6.2498 7.66424C6.35039 7.93872 6.65446 8.07969 6.92894 7.97909C7.20342 7.8785 7.34438 7.57443 7.24379 7.29995L5.5165 2.58693ZM5.34479 5.19487L4.68818 3.40325L4.03156 5.19487H5.34479Z"
|
|
1543
|
-
];
|
|
1965
|
+
SheetTableControlsRenderController = __decorate([
|
|
1966
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1967
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1968
|
+
__decorateParam(3, _univerjs_core.ICommandService),
|
|
1969
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager)),
|
|
1970
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetRangeThemeModel)),
|
|
1971
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_sheets.WorkbookPermissionService)),
|
|
1972
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_core.IPermissionService)),
|
|
1973
|
+
__decorateParam(8, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService)),
|
|
1974
|
+
__decorateParam(9, _univerjs_sheets_ui.ISheetSelectionRenderService),
|
|
1975
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(SheetTableThemeUIController)),
|
|
1976
|
+
__decorateParam(11, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1977
|
+
__decorateParam(12, _univerjs_ui.IDialogService),
|
|
1978
|
+
__decorateParam(13, _univerjs_ui.ISidebarService)
|
|
1979
|
+
], SheetTableControlsRenderController);
|
|
1544
1980
|
|
|
1545
1981
|
//#endregion
|
|
1546
1982
|
//#region src/views/widgets/table-filter-button.shape.ts
|
|
1547
1983
|
const FILTER_ICON_SIZE = 16;
|
|
1984
|
+
const FILTER_TRIGGER_HOVER_RADIUS = 4;
|
|
1548
1985
|
let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _univerjs_engine_render.Shape {
|
|
1549
|
-
constructor(key, props,
|
|
1986
|
+
constructor(key, props, _commandService) {
|
|
1550
1987
|
super(key, props);
|
|
1551
|
-
this._contextService = _contextService;
|
|
1552
1988
|
this._commandService = _commandService;
|
|
1553
|
-
this._themeService = _themeService;
|
|
1554
1989
|
_defineProperty(this, "_cellWidth", 0);
|
|
1555
1990
|
_defineProperty(this, "_cellHeight", 0);
|
|
1556
1991
|
_defineProperty(this, "_filterParams", void 0);
|
|
1992
|
+
_defineProperty(this, "_iconColor", "#fff");
|
|
1993
|
+
_defineProperty(this, "_hoverBackground", "rgba(255, 255, 255, 0.92)");
|
|
1994
|
+
_defineProperty(this, "_hoverIconColor", "#202124");
|
|
1557
1995
|
_defineProperty(this, "_hovered", false);
|
|
1558
1996
|
this.setShapeProps(props);
|
|
1559
1997
|
this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));
|
|
@@ -1564,6 +2002,9 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1564
2002
|
if (typeof props.cellHeight !== "undefined") this._cellHeight = props.cellHeight;
|
|
1565
2003
|
if (typeof props.cellWidth !== "undefined") this._cellWidth = props.cellWidth;
|
|
1566
2004
|
if (typeof props.filterParams !== "undefined") this._filterParams = props.filterParams;
|
|
2005
|
+
if (typeof props.iconColor !== "undefined") this._iconColor = props.iconColor;
|
|
2006
|
+
if (typeof props.hoverBackground !== "undefined") this._hoverBackground = props.hoverBackground;
|
|
2007
|
+
if (typeof props.hoverIconColor !== "undefined") this._hoverIconColor = props.hoverIconColor;
|
|
1567
2008
|
this.transformByState({
|
|
1568
2009
|
width: props.width,
|
|
1569
2010
|
height: props.height
|
|
@@ -1578,36 +2019,38 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1578
2019
|
const cellRegion = new Path2D();
|
|
1579
2020
|
cellRegion.rect(left, top, cellWidth, cellHeight);
|
|
1580
2021
|
ctx.clip(cellRegion);
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
icons = filteredSortAsc;
|
|
1591
|
-
break;
|
|
1592
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilteredSortDesc:
|
|
1593
|
-
icons = filteredSortDesc;
|
|
1594
|
-
break;
|
|
1595
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortNone: break;
|
|
1596
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortAsc:
|
|
1597
|
-
icons = filterNoneSortAsc;
|
|
1598
|
-
break;
|
|
1599
|
-
case _univerjs_sheets_table.SheetsTableButtonStateEnum.FilterNoneSortDesc:
|
|
1600
|
-
icons = filterNoneSortDesc;
|
|
1601
|
-
break;
|
|
2022
|
+
if (this._hovered) {
|
|
2023
|
+
var _ctx$roundRect;
|
|
2024
|
+
ctx.save();
|
|
2025
|
+
ctx.fillStyle = this._hoverBackground;
|
|
2026
|
+
ctx.beginPath();
|
|
2027
|
+
(_ctx$roundRect = ctx.roundRect) === null || _ctx$roundRect === void 0 || _ctx$roundRect.call(ctx, 0, 0, 16, 16, FILTER_TRIGGER_HOVER_RADIUS);
|
|
2028
|
+
if (!ctx.roundRect) ctx.rect(0, 0, 16, 16);
|
|
2029
|
+
ctx.fill();
|
|
2030
|
+
ctx.restore();
|
|
1602
2031
|
}
|
|
1603
|
-
|
|
1604
|
-
|
|
2032
|
+
this._drawChevron(ctx, this._hovered ? this._hoverIconColor : this._iconColor);
|
|
2033
|
+
ctx.restore();
|
|
2034
|
+
}
|
|
2035
|
+
_drawChevron(ctx, color) {
|
|
2036
|
+
const centerX = 16 / 2;
|
|
2037
|
+
const centerY = 16 / 2 + 1;
|
|
2038
|
+
ctx.save();
|
|
2039
|
+
ctx.beginPath();
|
|
2040
|
+
ctx.strokeStyle = color;
|
|
2041
|
+
ctx.lineWidth = 1.8;
|
|
2042
|
+
ctx.lineCap = "round";
|
|
2043
|
+
ctx.lineJoin = "round";
|
|
2044
|
+
ctx.moveTo(centerX - 4.5, centerY - 2.5);
|
|
2045
|
+
ctx.lineTo(centerX, centerY + 2);
|
|
2046
|
+
ctx.lineTo(centerX + 4.5, centerY - 2.5);
|
|
2047
|
+
ctx.stroke();
|
|
1605
2048
|
ctx.restore();
|
|
1606
2049
|
}
|
|
1607
2050
|
onPointerDown(evt) {
|
|
1608
2051
|
if (evt.button === 2) return;
|
|
1609
2052
|
const { row, col, unitId, subUnitId, tableId } = this._filterParams;
|
|
1610
|
-
if (
|
|
2053
|
+
if (!this._commandService.hasCommand(OpenTableFilterPanelOperation.id)) return;
|
|
1611
2054
|
setTimeout(() => {
|
|
1612
2055
|
const cmdParams = {
|
|
1613
2056
|
row,
|
|
@@ -1628,11 +2071,7 @@ let SheetsTableFilterButtonShape = class SheetsTableFilterButtonShape extends _u
|
|
|
1628
2071
|
this.makeDirty(true);
|
|
1629
2072
|
}
|
|
1630
2073
|
};
|
|
1631
|
-
SheetsTableFilterButtonShape = __decorate([
|
|
1632
|
-
__decorateParam(2, _univerjs_core.IContextService),
|
|
1633
|
-
__decorateParam(3, _univerjs_core.ICommandService),
|
|
1634
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
1635
|
-
], SheetsTableFilterButtonShape);
|
|
2074
|
+
SheetsTableFilterButtonShape = __decorate([__decorateParam(2, _univerjs_core.ICommandService)], SheetsTableFilterButtonShape);
|
|
1636
2075
|
|
|
1637
2076
|
//#endregion
|
|
1638
2077
|
//#region src/controllers/sheet-table-filter-button-render.controller.ts
|
|
@@ -1646,13 +2085,14 @@ const computeIconTop = (startY, endY, cellHeight, verticalAlign) => {
|
|
|
1646
2085
|
}
|
|
1647
2086
|
};
|
|
1648
2087
|
let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRenderController extends _univerjs_core.RxDisposable {
|
|
1649
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _commandService) {
|
|
2088
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetInterceptorService, _tableManager, _rangeThemeModel, _commandService) {
|
|
1650
2089
|
super();
|
|
1651
2090
|
this._context = _context;
|
|
1652
2091
|
this._injector = _injector;
|
|
1653
2092
|
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
1654
2093
|
this._sheetInterceptorService = _sheetInterceptorService;
|
|
1655
2094
|
this._tableManager = _tableManager;
|
|
2095
|
+
this._rangeThemeModel = _rangeThemeModel;
|
|
1656
2096
|
this._commandService = _commandService;
|
|
1657
2097
|
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
1658
2098
|
_defineProperty(this, "_tableFilterButtonShapes", []);
|
|
@@ -1708,7 +2148,12 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1708
2148
|
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
1709
2149
|
if (!worksheet) return;
|
|
1710
2150
|
for (const { range, states, tableId } of tableFilterRanges) {
|
|
2151
|
+
var _this$_rangeThemeMode, _headerStyle$cl$rgb, _headerStyle$cl, _headerStyle$bg$rgb, _headerStyle$bg;
|
|
1711
2152
|
const { startRow, startColumn, endColumn } = range;
|
|
2153
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
2154
|
+
const headerStyle = table ? (_this$_rangeThemeMode = this._rangeThemeModel.getRangeThemeStyle(unitId, table.getTableStyleId())) === null || _this$_rangeThemeMode === void 0 ? void 0 : _this$_rangeThemeMode.getHeaderRowStyle() : null;
|
|
2155
|
+
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";
|
|
2156
|
+
const hoverIconColor = (_headerStyle$bg$rgb = headerStyle === null || headerStyle === void 0 || (_headerStyle$bg = headerStyle.bg) === null || _headerStyle$bg === void 0 ? void 0 : _headerStyle$bg.rgb) !== null && _headerStyle$bg$rgb !== void 0 ? _headerStyle$bg$rgb : "#202124";
|
|
1712
2157
|
this._interceptCellContent(unitId, worksheetId, range);
|
|
1713
2158
|
for (let col = startColumn; col <= endColumn; col++) {
|
|
1714
2159
|
const key = `sheets-table-filter-button-${startRow}-${col}`;
|
|
@@ -1726,6 +2171,9 @@ let SheetsTableFilterButtonRenderController = class SheetsTableFilterButtonRende
|
|
|
1726
2171
|
height: 16,
|
|
1727
2172
|
width: 16,
|
|
1728
2173
|
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2174
|
+
iconColor,
|
|
2175
|
+
hoverBackground: iconColor,
|
|
2176
|
+
hoverIconColor,
|
|
1729
2177
|
cellHeight,
|
|
1730
2178
|
cellWidth,
|
|
1731
2179
|
filterParams: {
|
|
@@ -1774,7 +2222,8 @@ SheetsTableFilterButtonRenderController = __decorate([
|
|
|
1774
2222
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1775
2223
|
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
1776
2224
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager)),
|
|
1777
|
-
__decorateParam(5, _univerjs_core.
|
|
2225
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetRangeThemeModel)),
|
|
2226
|
+
__decorateParam(6, _univerjs_core.ICommandService)
|
|
1778
2227
|
], SheetsTableFilterButtonRenderController);
|
|
1779
2228
|
|
|
1780
2229
|
//#endregion
|
|
@@ -2503,8 +2952,9 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerj
|
|
|
2503
2952
|
this._registerRenderModules();
|
|
2504
2953
|
}
|
|
2505
2954
|
_registerRenderModules() {
|
|
2506
|
-
const renderDependencies = [
|
|
2507
|
-
if (this._config.hideAnchor !== true) renderDependencies.push([
|
|
2955
|
+
const renderDependencies = [];
|
|
2956
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableControlsRenderController]);
|
|
2957
|
+
renderDependencies.push([SheetsTableFilterButtonRenderController], [SheetsTableRenderController]);
|
|
2508
2958
|
renderDependencies.forEach((m) => {
|
|
2509
2959
|
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, m));
|
|
2510
2960
|
});
|