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