@univerjs/sheets-table-ui 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +246 -237
- package/lib/es/index.js +247 -239
- package/lib/index.js +247 -239
- package/lib/types/index.d.ts +1 -0
- package/lib/types/menu/sheet-table-menu.controller.d.ts +2 -4
- package/lib/umd/index.js +1 -1
- package/package.json +15 -15
package/lib/cjs/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let _univerjs_core = require("@univerjs/core");
|
|
3
|
-
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
4
2
|
let _univerjs_sheets_table = require("@univerjs/sheets-table");
|
|
5
|
-
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
6
3
|
let _univerjs_ui = require("@univerjs/ui");
|
|
7
|
-
let
|
|
4
|
+
let _univerjs_core = require("@univerjs/core");
|
|
8
5
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
6
|
+
let _univerjs_sheets_ui = require("@univerjs/sheets-ui");
|
|
7
|
+
let rxjs = require("rxjs");
|
|
8
|
+
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
9
9
|
let _univerjs_icons = require("@univerjs/icons");
|
|
10
10
|
let _univerjs_design = require("@univerjs/design");
|
|
11
11
|
let _univerjs_sheets_sort = require("@univerjs/sheets-sort");
|
|
@@ -14,11 +14,6 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
14
14
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
15
15
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
16
16
|
|
|
17
|
-
//#region package.json
|
|
18
|
-
var name = "@univerjs/sheets-table-ui";
|
|
19
|
-
var version = "1.0.0-alpha.2";
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
17
|
//#region src/const.ts
|
|
23
18
|
/**
|
|
24
19
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
@@ -49,6 +44,210 @@ const TABLE_DEFAULT_BG_COLOR = "rgb(255, 255, 255)";
|
|
|
49
44
|
const TABLE_BORDER_NONE = "none";
|
|
50
45
|
const TABLE_BORDER_DEFAULT = "1px solid rgb(var(--grey-200))";
|
|
51
46
|
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/commands/operations/open-table-selector.operation.ts
|
|
49
|
+
const OpenTableSelectorOperation = {
|
|
50
|
+
type: _univerjs_core.CommandType.OPERATION,
|
|
51
|
+
id: "sheet.operation.open-table-selector",
|
|
52
|
+
async handler(accessor) {
|
|
53
|
+
var _lastSelection$range;
|
|
54
|
+
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
55
|
+
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
56
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
57
|
+
if (!target) return false;
|
|
58
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
59
|
+
const lastSelection = accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
60
|
+
const range = (_lastSelection$range = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) !== null && _lastSelection$range !== void 0 ? _lastSelection$range : {
|
|
61
|
+
startRow: 0,
|
|
62
|
+
endRow: 0,
|
|
63
|
+
startColumn: 0,
|
|
64
|
+
endColumn: 0
|
|
65
|
+
};
|
|
66
|
+
const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, (0, _univerjs_sheets.isSingleCellSelection)(lastSelection) ? (0, _univerjs_sheets.expandToContinuousRange)(range, {
|
|
67
|
+
up: true,
|
|
68
|
+
left: true,
|
|
69
|
+
right: true,
|
|
70
|
+
down: true
|
|
71
|
+
}, worksheet) : range);
|
|
72
|
+
if (!rangeInfo) return false;
|
|
73
|
+
commandService.executeCommand(_univerjs_sheets_table.AddSheetTableCommand.id, { ...rangeInfo });
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
async function openRangeSelector(accessor, unitId, subUnitId, range, tableId) {
|
|
78
|
+
const dialogService = accessor.get(_univerjs_ui.IDialogService);
|
|
79
|
+
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
80
|
+
return new Promise((resolve) => {
|
|
81
|
+
const dialogProps = {
|
|
82
|
+
unitId,
|
|
83
|
+
subUnitId,
|
|
84
|
+
range,
|
|
85
|
+
tableId,
|
|
86
|
+
onConfirm: (info) => {
|
|
87
|
+
resolve(info);
|
|
88
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
89
|
+
},
|
|
90
|
+
onCancel: () => {
|
|
91
|
+
resolve(null);
|
|
92
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
dialogService.open({
|
|
96
|
+
id: TABLE_SELECTOR_DIALOG,
|
|
97
|
+
title: { title: localeService.t("sheets-table-ui.selectRange") },
|
|
98
|
+
draggable: true,
|
|
99
|
+
destroyOnClose: true,
|
|
100
|
+
mask: false,
|
|
101
|
+
maskClosable: false,
|
|
102
|
+
children: { label: {
|
|
103
|
+
name: TABLE_SELECTOR_DIALOG,
|
|
104
|
+
props: dialogProps
|
|
105
|
+
} },
|
|
106
|
+
width: 300,
|
|
107
|
+
onClose: () => {
|
|
108
|
+
resolve(null);
|
|
109
|
+
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/menu/menu.ts
|
|
117
|
+
const SHEET_TABLE_CONTEXT_INSERT_MENU_ID = "sheet.table.context-insert_menu-id";
|
|
118
|
+
const SHEET_TABLE_CONTEXT_REMOVE_MENU_ID = "sheet.table.context-remove_menu-id";
|
|
119
|
+
function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
120
|
+
return {
|
|
121
|
+
id: OpenTableSelectorOperation.id,
|
|
122
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
123
|
+
icon: "TableIcon",
|
|
124
|
+
tooltip: "sheets-table-ui.title",
|
|
125
|
+
title: "sheets-table-ui.title",
|
|
126
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
127
|
+
disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {}, true)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function SheetTableInsertContextMenuFactory(accessor) {
|
|
131
|
+
return {
|
|
132
|
+
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
133
|
+
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
134
|
+
icon: "InsertDoubleIcon",
|
|
135
|
+
title: "sheets-table-ui.insert.main",
|
|
136
|
+
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function SheetTableRemoveContextMenuFactory(accessor) {
|
|
140
|
+
return {
|
|
141
|
+
id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,
|
|
142
|
+
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
143
|
+
icon: "ReduceDoubleIcon",
|
|
144
|
+
title: "sheets-table-ui.remove.main",
|
|
145
|
+
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function SheetTableInsertRowMenuFactory(accessor) {
|
|
149
|
+
return {
|
|
150
|
+
id: _univerjs_sheets_table.SheetTableInsertRowCommand.id,
|
|
151
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
152
|
+
title: "sheets-table-ui.insert.row",
|
|
153
|
+
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function SheetTableInsertColMenuFactory() {
|
|
157
|
+
return {
|
|
158
|
+
id: _univerjs_sheets_table.SheetTableInsertColCommand.id,
|
|
159
|
+
title: "sheets-table-ui.insert.col",
|
|
160
|
+
type: _univerjs_ui.MenuItemType.BUTTON
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function SheetTableRemoveRowMenuFactory(accessor) {
|
|
164
|
+
return {
|
|
165
|
+
id: _univerjs_sheets_table.SheetTableRemoveRowCommand.id,
|
|
166
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
167
|
+
title: "sheets-table-ui.remove.row",
|
|
168
|
+
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function SheetTableRemoveColMenuFactory() {
|
|
172
|
+
return {
|
|
173
|
+
id: _univerjs_sheets_table.SheetTableRemoveColCommand.id,
|
|
174
|
+
title: "sheets-table-ui.remove.col",
|
|
175
|
+
type: _univerjs_ui.MenuItemType.BUTTON
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function getSheetTableRowColOperationHidden$(accessor) {
|
|
179
|
+
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
180
|
+
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
181
|
+
if (!workbook) return (0, rxjs.of)(true);
|
|
182
|
+
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
183
|
+
if (!sheet) return (0, rxjs.of)(true);
|
|
184
|
+
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
185
|
+
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
186
|
+
const range = selections[0].range;
|
|
187
|
+
return (0, rxjs.of)(!accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range));
|
|
188
|
+
}));
|
|
189
|
+
}));
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
function getSheetTableHeaderOperationHidden$(accessor) {
|
|
193
|
+
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
194
|
+
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
195
|
+
if (!workbook) return (0, rxjs.of)(true);
|
|
196
|
+
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
197
|
+
if (!sheet) return (0, rxjs.of)(true);
|
|
198
|
+
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
199
|
+
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
200
|
+
const range = selections[0].range;
|
|
201
|
+
const isInTable = accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
202
|
+
if (!isInTable) return (0, rxjs.of)(true);
|
|
203
|
+
const tableRange = isInTable.getRange();
|
|
204
|
+
if (range.startRow === tableRange.startRow) return (0, rxjs.of)(true);
|
|
205
|
+
return (0, rxjs.of)(false);
|
|
206
|
+
}));
|
|
207
|
+
}));
|
|
208
|
+
}));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/menu/schema.ts
|
|
213
|
+
const menuSchema = {
|
|
214
|
+
[_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
215
|
+
order: 0,
|
|
216
|
+
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
217
|
+
} },
|
|
218
|
+
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.LAYOUT]: {
|
|
219
|
+
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
220
|
+
order: 5,
|
|
221
|
+
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
222
|
+
[_univerjs_sheets_table.SheetTableInsertRowCommand.id]: {
|
|
223
|
+
order: 1,
|
|
224
|
+
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
225
|
+
},
|
|
226
|
+
[_univerjs_sheets_table.SheetTableInsertColCommand.id]: {
|
|
227
|
+
order: 2,
|
|
228
|
+
menuItemFactory: SheetTableInsertColMenuFactory
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
232
|
+
order: 6,
|
|
233
|
+
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
234
|
+
[_univerjs_sheets_table.SheetTableRemoveRowCommand.id]: {
|
|
235
|
+
order: 1,
|
|
236
|
+
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
237
|
+
},
|
|
238
|
+
[_univerjs_sheets_table.SheetTableRemoveColCommand.id]: {
|
|
239
|
+
order: 2,
|
|
240
|
+
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} }
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region package.json
|
|
248
|
+
var name = "@univerjs/sheets-table-ui";
|
|
249
|
+
var version = "1.0.0-alpha.4";
|
|
250
|
+
|
|
52
251
|
//#endregion
|
|
53
252
|
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
54
253
|
function _typeof(o) {
|
|
@@ -207,74 +406,6 @@ const OpenTableFilterPanelOperation = {
|
|
|
207
406
|
}
|
|
208
407
|
};
|
|
209
408
|
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region src/commands/operations/open-table-selector.operation.ts
|
|
212
|
-
const OpenTableSelectorOperation = {
|
|
213
|
-
type: _univerjs_core.CommandType.OPERATION,
|
|
214
|
-
id: "sheet.operation.open-table-selector",
|
|
215
|
-
async handler(accessor) {
|
|
216
|
-
var _lastSelection$range;
|
|
217
|
-
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
218
|
-
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
219
|
-
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
220
|
-
if (!target) return false;
|
|
221
|
-
const { unitId, subUnitId, worksheet } = target;
|
|
222
|
-
const lastSelection = accessor.get(_univerjs_sheets.SheetsSelectionsService).getCurrentLastSelection();
|
|
223
|
-
const range = (_lastSelection$range = lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.range) !== null && _lastSelection$range !== void 0 ? _lastSelection$range : {
|
|
224
|
-
startRow: 0,
|
|
225
|
-
endRow: 0,
|
|
226
|
-
startColumn: 0,
|
|
227
|
-
endColumn: 0
|
|
228
|
-
};
|
|
229
|
-
const rangeInfo = await openRangeSelector(accessor, unitId, subUnitId, (0, _univerjs_sheets.isSingleCellSelection)(lastSelection) ? (0, _univerjs_sheets.expandToContinuousRange)(range, {
|
|
230
|
-
up: true,
|
|
231
|
-
left: true,
|
|
232
|
-
right: true,
|
|
233
|
-
down: true
|
|
234
|
-
}, worksheet) : range);
|
|
235
|
-
if (!rangeInfo) return false;
|
|
236
|
-
commandService.executeCommand(_univerjs_sheets_table.AddSheetTableCommand.id, { ...rangeInfo });
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
async function openRangeSelector(accessor, unitId, subUnitId, range, tableId) {
|
|
241
|
-
const dialogService = accessor.get(_univerjs_ui.IDialogService);
|
|
242
|
-
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
243
|
-
return new Promise((resolve) => {
|
|
244
|
-
const dialogProps = {
|
|
245
|
-
unitId,
|
|
246
|
-
subUnitId,
|
|
247
|
-
range,
|
|
248
|
-
tableId,
|
|
249
|
-
onConfirm: (info) => {
|
|
250
|
-
resolve(info);
|
|
251
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
252
|
-
},
|
|
253
|
-
onCancel: () => {
|
|
254
|
-
resolve(null);
|
|
255
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
dialogService.open({
|
|
259
|
-
id: TABLE_SELECTOR_DIALOG,
|
|
260
|
-
title: { title: localeService.t("sheets-table-ui.selectRange") },
|
|
261
|
-
draggable: true,
|
|
262
|
-
destroyOnClose: true,
|
|
263
|
-
mask: false,
|
|
264
|
-
maskClosable: false,
|
|
265
|
-
children: { label: {
|
|
266
|
-
name: TABLE_SELECTOR_DIALOG,
|
|
267
|
-
props: dialogProps
|
|
268
|
-
} },
|
|
269
|
-
width: 300,
|
|
270
|
-
onClose: () => {
|
|
271
|
-
resolve(null);
|
|
272
|
-
dialogService.close(TABLE_SELECTOR_DIALOG);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
409
|
//#endregion
|
|
279
410
|
//#region src/config/config.ts
|
|
280
411
|
const SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY = "sheets-table-ui.config";
|
|
@@ -901,7 +1032,7 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
901
1032
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
902
1033
|
const { data: items, itemsCountMap, allItemsCount } = (0, _univerjs_ui.useDependency)(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
903
1034
|
const [allChecked, setAllChecked] = (0, react.useState)(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
904
|
-
const [checkedCount, setCheckedCount] = (0, react.useState)(allChecked ? allItemsCount : getCheckedItemCount(itemsCountMap, checkedItemSet));
|
|
1035
|
+
const [checkedCount, setCheckedCount] = (0, react.useState)(() => allChecked ? allItemsCount : getCheckedItemCount(itemsCountMap, checkedItemSet));
|
|
905
1036
|
const indeterminate = !allChecked && checkedItemSet.size > 0;
|
|
906
1037
|
const [searchText, setSearchText] = (0, react.useState)("");
|
|
907
1038
|
const displayItems = (0, react.useMemo)(() => {
|
|
@@ -1018,10 +1149,20 @@ function SheetTableItemsFilterPanel(props) {
|
|
|
1018
1149
|
|
|
1019
1150
|
//#endregion
|
|
1020
1151
|
//#region src/views/components/SheetTableFilterPanel.tsx
|
|
1152
|
+
const FILTER_BY_OPTIONS = [{
|
|
1153
|
+
label: "sheets-table-ui.filter.by-values",
|
|
1154
|
+
value: "items"
|
|
1155
|
+
}, {
|
|
1156
|
+
label: "sheets-table-ui.filter.by-conditions",
|
|
1157
|
+
value: "condition"
|
|
1158
|
+
}];
|
|
1021
1159
|
function SheetTableFilterPanel() {
|
|
1022
1160
|
var _permissionService$ge;
|
|
1023
1161
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1024
|
-
const filterByItems =
|
|
1162
|
+
const filterByItems = FILTER_BY_OPTIONS.map((option) => ({
|
|
1163
|
+
...option,
|
|
1164
|
+
label: localeService.t(option.label)
|
|
1165
|
+
}));
|
|
1025
1166
|
const tableUiService = (0, _univerjs_ui.useDependency)(SheetsTableUiService);
|
|
1026
1167
|
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1027
1168
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
@@ -1032,7 +1173,7 @@ function SheetTableFilterPanel() {
|
|
|
1032
1173
|
const { unitId, subUnitId, tableId, tableFilter, currentFilterBy, columnIndex } = props;
|
|
1033
1174
|
const { data } = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
1034
1175
|
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
1035
|
-
const [checkedItemSet, setCheckedItemSet] = (0, react.useState)(new Set(checkedItems));
|
|
1176
|
+
const [checkedItemSet, setCheckedItemSet] = (0, react.useState)(() => new Set(checkedItems));
|
|
1036
1177
|
const [filterBy, setFilterBy] = (0, react.useState)(currentFilterBy || "items");
|
|
1037
1178
|
const [conditionInfo, setConditionInfo] = (0, react.useState)(() => {
|
|
1038
1179
|
const tableFilter = props.tableFilter;
|
|
@@ -1233,15 +1374,6 @@ function SheetTableFilterPanel() {
|
|
|
1233
1374
|
]
|
|
1234
1375
|
});
|
|
1235
1376
|
}
|
|
1236
|
-
function useFilterByOptions(localeService) {
|
|
1237
|
-
return (0, react.useMemo)(() => [{
|
|
1238
|
-
label: localeService.t("sheets-table-ui.filter.by-values"),
|
|
1239
|
-
value: "items"
|
|
1240
|
-
}, {
|
|
1241
|
-
label: localeService.t("sheets-table-ui.filter.by-conditions"),
|
|
1242
|
-
value: "condition"
|
|
1243
|
-
}], [localeService.getCurrentLocale(), localeService]);
|
|
1244
|
-
}
|
|
1245
1377
|
|
|
1246
1378
|
//#endregion
|
|
1247
1379
|
//#region src/views/components/SheetTableRenameDialog.tsx
|
|
@@ -1453,7 +1585,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1453
1585
|
const rangeThemeMapChanged = (0, _univerjs_ui.useObservable)(rangeThemeModel.rangeThemeMapChange$);
|
|
1454
1586
|
const tableRefresh = (0, _univerjs_ui.useObservable)(sheetTableThemeUIController.refreshTable$);
|
|
1455
1587
|
const errorService = (0, _univerjs_ui.useDependency)(_univerjs_core.ErrorService);
|
|
1456
|
-
const [, setRefresh] = (0, react.useState)(Math.random
|
|
1588
|
+
const [, setRefresh] = (0, react.useState)(Math.random);
|
|
1457
1589
|
const themeConfig = (0, _univerjs_ui.useObservable)(tableManager.tableThemeChanged$, {
|
|
1458
1590
|
theme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
1459
1591
|
oldTheme: table === null || table === void 0 ? void 0 : table.getTableStyleId(),
|
|
@@ -1648,7 +1780,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1648
1780
|
"univer-text-gray-900": !headerBgIsDark
|
|
1649
1781
|
}),
|
|
1650
1782
|
style: { background: headerBg }
|
|
1651
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1783
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1652
1784
|
})
|
|
1653
1785
|
})]
|
|
1654
1786
|
}),
|
|
@@ -1679,7 +1811,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1679
1811
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1680
1812
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1681
1813
|
style: { background: firstRowBg }
|
|
1682
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1814
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1683
1815
|
})
|
|
1684
1816
|
})]
|
|
1685
1817
|
}),
|
|
@@ -1708,7 +1840,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1708
1840
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1709
1841
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1710
1842
|
style: { background: secondRowBg }
|
|
1711
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1843
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1712
1844
|
})
|
|
1713
1845
|
})]
|
|
1714
1846
|
}),
|
|
@@ -1740,7 +1872,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1740
1872
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1741
1873
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1742
1874
|
style: { background: lastRowBg }
|
|
1743
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1875
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1744
1876
|
})
|
|
1745
1877
|
})]
|
|
1746
1878
|
})
|
|
@@ -2084,6 +2216,13 @@ var SheetTableControlsShape = class extends _univerjs_engine_render.Shape {
|
|
|
2084
2216
|
const TABLE_CONTROLS_LAYER_INDEX = 5002;
|
|
2085
2217
|
const TABLE_CONTROL_GAP_ROW = 0;
|
|
2086
2218
|
const TABLE_RENDER_REFRESH_COMMANDS = /* @__PURE__ */ new Set([_univerjs_sheets_ui.SetScrollOperation.id, _univerjs_sheets_ui.SetZoomRatioOperation.id]);
|
|
2219
|
+
const SELECTION_ONLY_COMMANDS = /* @__PURE__ */ new Set([
|
|
2220
|
+
_univerjs_sheets_ui.MoveSelectionCommand.id,
|
|
2221
|
+
_univerjs_sheets_ui.MoveSelectionEnterAndTabCommand.id,
|
|
2222
|
+
_univerjs_sheets_ui.ExpandSelectionCommand.id,
|
|
2223
|
+
_univerjs_sheets_ui.SelectAllCommand.id,
|
|
2224
|
+
_univerjs_sheets.SelectRangeCommand.id
|
|
2225
|
+
]);
|
|
2087
2226
|
function isSameTopGap(left, right) {
|
|
2088
2227
|
if (left === null || right === null) return left === right;
|
|
2089
2228
|
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
@@ -2135,24 +2274,30 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2135
2274
|
}
|
|
2136
2275
|
_initRefresh() {
|
|
2137
2276
|
const commandExecuted$ = (0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
|
|
2277
|
+
if (command.id.startsWith("doc.") || SELECTION_ONLY_COMMANDS.has(command.id)) return false;
|
|
2138
2278
|
if (command.type === _univerjs_core.CommandType.OPERATION && TABLE_RENDER_REFRESH_COMMANDS.has(command.id)) {
|
|
2139
2279
|
this._closeFloatingControls();
|
|
2140
2280
|
return true;
|
|
2141
2281
|
}
|
|
2142
2282
|
return command.type === _univerjs_core.CommandType.MUTATION || command.type === _univerjs_core.CommandType.COMMAND;
|
|
2143
2283
|
}));
|
|
2144
|
-
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$,
|
|
2284
|
+
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$, commandExecuted$).subscribe(() => {
|
|
2145
2285
|
this._closeFloatingControls();
|
|
2146
2286
|
this._refresh();
|
|
2147
2287
|
}));
|
|
2288
|
+
this.disposeWithMe(this._sheetsSelectionsService.selectionChanged$.subscribe(() => {
|
|
2289
|
+
this._closeFloatingControls();
|
|
2290
|
+
this._refresh(false);
|
|
2291
|
+
}));
|
|
2148
2292
|
}
|
|
2149
|
-
_refresh() {
|
|
2293
|
+
_refresh(invalidateScene = true) {
|
|
2150
2294
|
const skeleton = this._sheetSkeletonManagerService.getCurrentSkeleton();
|
|
2151
2295
|
const worksheet = this._context.unit.getActiveSheet();
|
|
2152
2296
|
if (!skeleton || !worksheet || !this._canEditWorkbook()) {
|
|
2153
2297
|
this._shape.setItems([]);
|
|
2154
2298
|
this._shape.refreshBounds();
|
|
2155
|
-
this.
|
|
2299
|
+
this._shape.makeDirty(true);
|
|
2300
|
+
if (invalidateScene) this._context.scene.makeDirty();
|
|
2156
2301
|
return;
|
|
2157
2302
|
}
|
|
2158
2303
|
this._syncTopTableGap(skeleton);
|
|
@@ -2178,7 +2323,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2178
2323
|
this._shape.setItems(items);
|
|
2179
2324
|
this._shape.refreshBounds();
|
|
2180
2325
|
this._shape.makeDirty(true);
|
|
2181
|
-
this._context.scene.makeDirty();
|
|
2326
|
+
if (invalidateScene) this._context.scene.makeDirty();
|
|
2182
2327
|
}
|
|
2183
2328
|
_canEditWorkbook() {
|
|
2184
2329
|
var _this$_permissionServ;
|
|
@@ -2786,137 +2931,6 @@ SheetTableSelectionController = __decorate([
|
|
|
2786
2931
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager))
|
|
2787
2932
|
], SheetTableSelectionController);
|
|
2788
2933
|
|
|
2789
|
-
//#endregion
|
|
2790
|
-
//#region src/menu/menu.ts
|
|
2791
|
-
const SHEET_TABLE_CONTEXT_INSERT_MENU_ID = "sheet.table.context-insert_menu-id";
|
|
2792
|
-
const SHEET_TABLE_CONTEXT_REMOVE_MENU_ID = "sheet.table.context-remove_menu-id";
|
|
2793
|
-
function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
2794
|
-
return {
|
|
2795
|
-
id: OpenTableSelectorOperation.id,
|
|
2796
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2797
|
-
icon: "TableIcon",
|
|
2798
|
-
tooltip: "sheets-table-ui.title",
|
|
2799
|
-
title: "sheets-table-ui.title",
|
|
2800
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2801
|
-
disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {}, true)
|
|
2802
|
-
};
|
|
2803
|
-
}
|
|
2804
|
-
function SheetTableInsertContextMenuFactory(accessor) {
|
|
2805
|
-
return {
|
|
2806
|
-
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
2807
|
-
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2808
|
-
icon: "InsertDoubleIcon",
|
|
2809
|
-
title: "sheets-table-ui.insert.main",
|
|
2810
|
-
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2811
|
-
};
|
|
2812
|
-
}
|
|
2813
|
-
function SheetTableRemoveContextMenuFactory(accessor) {
|
|
2814
|
-
return {
|
|
2815
|
-
id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,
|
|
2816
|
-
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2817
|
-
icon: "ReduceDoubleIcon",
|
|
2818
|
-
title: "sheets-table-ui.remove.main",
|
|
2819
|
-
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2820
|
-
};
|
|
2821
|
-
}
|
|
2822
|
-
function SheetTableInsertRowMenuFactory(accessor) {
|
|
2823
|
-
return {
|
|
2824
|
-
id: _univerjs_sheets_table.SheetTableInsertRowCommand.id,
|
|
2825
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2826
|
-
title: "sheets-table-ui.insert.row",
|
|
2827
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2828
|
-
};
|
|
2829
|
-
}
|
|
2830
|
-
function SheetTableInsertColMenuFactory() {
|
|
2831
|
-
return {
|
|
2832
|
-
id: _univerjs_sheets_table.SheetTableInsertColCommand.id,
|
|
2833
|
-
title: "sheets-table-ui.insert.col",
|
|
2834
|
-
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
function SheetTableRemoveRowMenuFactory(accessor) {
|
|
2838
|
-
return {
|
|
2839
|
-
id: _univerjs_sheets_table.SheetTableRemoveRowCommand.id,
|
|
2840
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2841
|
-
title: "sheets-table-ui.remove.row",
|
|
2842
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2843
|
-
};
|
|
2844
|
-
}
|
|
2845
|
-
function SheetTableRemoveColMenuFactory() {
|
|
2846
|
-
return {
|
|
2847
|
-
id: _univerjs_sheets_table.SheetTableRemoveColCommand.id,
|
|
2848
|
-
title: "sheets-table-ui.remove.col",
|
|
2849
|
-
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2850
|
-
};
|
|
2851
|
-
}
|
|
2852
|
-
function getSheetTableRowColOperationHidden$(accessor) {
|
|
2853
|
-
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
2854
|
-
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
2855
|
-
if (!workbook) return (0, rxjs.of)(true);
|
|
2856
|
-
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
2857
|
-
if (!sheet) return (0, rxjs.of)(true);
|
|
2858
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
2859
|
-
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
2860
|
-
const range = selections[0].range;
|
|
2861
|
-
return (0, rxjs.of)(!accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range));
|
|
2862
|
-
}));
|
|
2863
|
-
}));
|
|
2864
|
-
}));
|
|
2865
|
-
}
|
|
2866
|
-
function getSheetTableHeaderOperationHidden$(accessor) {
|
|
2867
|
-
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
2868
|
-
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
2869
|
-
if (!workbook) return (0, rxjs.of)(true);
|
|
2870
|
-
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
2871
|
-
if (!sheet) return (0, rxjs.of)(true);
|
|
2872
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
2873
|
-
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
2874
|
-
const range = selections[0].range;
|
|
2875
|
-
const isInTable = accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
2876
|
-
if (!isInTable) return (0, rxjs.of)(true);
|
|
2877
|
-
const tableRange = isInTable.getRange();
|
|
2878
|
-
if (range.startRow === tableRange.startRow) return (0, rxjs.of)(true);
|
|
2879
|
-
return (0, rxjs.of)(false);
|
|
2880
|
-
}));
|
|
2881
|
-
}));
|
|
2882
|
-
}));
|
|
2883
|
-
}
|
|
2884
|
-
|
|
2885
|
-
//#endregion
|
|
2886
|
-
//#region src/menu/schema.ts
|
|
2887
|
-
const menuSchema = {
|
|
2888
|
-
[_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
2889
|
-
order: 0,
|
|
2890
|
-
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
2891
|
-
} },
|
|
2892
|
-
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.LAYOUT]: {
|
|
2893
|
-
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
2894
|
-
order: 5,
|
|
2895
|
-
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
2896
|
-
[_univerjs_sheets_table.SheetTableInsertRowCommand.id]: {
|
|
2897
|
-
order: 1,
|
|
2898
|
-
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
2899
|
-
},
|
|
2900
|
-
[_univerjs_sheets_table.SheetTableInsertColCommand.id]: {
|
|
2901
|
-
order: 2,
|
|
2902
|
-
menuItemFactory: SheetTableInsertColMenuFactory
|
|
2903
|
-
}
|
|
2904
|
-
},
|
|
2905
|
-
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
2906
|
-
order: 6,
|
|
2907
|
-
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
2908
|
-
[_univerjs_sheets_table.SheetTableRemoveRowCommand.id]: {
|
|
2909
|
-
order: 1,
|
|
2910
|
-
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
2911
|
-
},
|
|
2912
|
-
[_univerjs_sheets_table.SheetTableRemoveColCommand.id]: {
|
|
2913
|
-
order: 2,
|
|
2914
|
-
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
} }
|
|
2918
|
-
};
|
|
2919
|
-
|
|
2920
2934
|
//#endregion
|
|
2921
2935
|
//#region src/menu/sheet-table-menu.controller.ts
|
|
2922
2936
|
/**
|
|
@@ -2935,10 +2949,8 @@ const menuSchema = {
|
|
|
2935
2949
|
* limitations under the License.
|
|
2936
2950
|
*/
|
|
2937
2951
|
let SheetTableMenuController = class SheetTableMenuController extends _univerjs_core.Disposable {
|
|
2938
|
-
constructor(
|
|
2952
|
+
constructor(_menuManagerService) {
|
|
2939
2953
|
super();
|
|
2940
|
-
this._componentManager = _componentManager;
|
|
2941
|
-
this._iconManager = _iconManager;
|
|
2942
2954
|
this._menuManagerService = _menuManagerService;
|
|
2943
2955
|
this._initMenu();
|
|
2944
2956
|
}
|
|
@@ -2946,11 +2958,7 @@ let SheetTableMenuController = class SheetTableMenuController extends _univerjs_
|
|
|
2946
2958
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
2947
2959
|
}
|
|
2948
2960
|
};
|
|
2949
|
-
SheetTableMenuController = __decorate([
|
|
2950
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)),
|
|
2951
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager)),
|
|
2952
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_ui.IMenuManagerService))
|
|
2953
|
-
], SheetTableMenuController);
|
|
2961
|
+
SheetTableMenuController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.IMenuManagerService))], SheetTableMenuController);
|
|
2954
2962
|
|
|
2955
2963
|
//#endregion
|
|
2956
2964
|
//#region src/plugin.ts
|
|
@@ -3015,6 +3023,7 @@ UniverSheetsTableUIPlugin = __decorate([
|
|
|
3015
3023
|
], UniverSheetsTableUIPlugin);
|
|
3016
3024
|
|
|
3017
3025
|
//#endregion
|
|
3026
|
+
exports.SheetsTableUIMenuSchema = menuSchema;
|
|
3018
3027
|
Object.defineProperty(exports, 'UniverSheetsTableUIPlugin', {
|
|
3019
3028
|
enumerable: true,
|
|
3020
3029
|
get: function () {
|