@univerjs/sheets-table-ui 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +224 -222
- package/lib/es/index.js +225 -224
- package/lib/index.js +225 -224
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
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";
|
|
6
|
-
import {
|
|
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";
|
|
7
4
|
import { INTERCEPTOR_POINT, RangeThemeStyle, SetRangeThemeMutation, SetRangeValuesMutation, SetSelectionsOperation, SetVerticalTextAlignCommand, SheetInterceptorService, SheetRangeThemeModel, SheetsSelectionsService, WorkbookEditablePermission, WorkbookPermissionService, expandToContinuousRange, getPrimaryForRange, getSheetCommandTarget, isSingleCellSelection } from "@univerjs/sheets";
|
|
8
|
-
import {
|
|
5
|
+
import { ISheetSelectionRenderService, SHEET_VIEW_KEY, SelectAllCommand, SetScrollOperation, SetZoomRatioOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, getCoordByCell, getCurrentRangeDisable$, getTransformCoord } from "@univerjs/sheets-ui";
|
|
6
|
+
import { Subject, distinctUntilChanged, filter, map, merge as merge$1, of, startWith, switchMap, takeUntil } from "rxjs";
|
|
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.3";
|
|
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";
|
|
@@ -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);
|
|
@@ -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
|
|
@@ -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
|
})
|
|
@@ -2785,137 +2917,6 @@ SheetTableSelectionController = __decorate([
|
|
|
2785
2917
|
__decorateParam(2, Inject(TableManager))
|
|
2786
2918
|
], SheetTableSelectionController);
|
|
2787
2919
|
|
|
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
2920
|
//#endregion
|
|
2920
2921
|
//#region src/menu/sheet-table-menu.controller.ts
|
|
2921
2922
|
/**
|
|
@@ -3014,4 +3015,4 @@ UniverSheetsTableUIPlugin = __decorate([
|
|
|
3014
3015
|
], UniverSheetsTableUIPlugin);
|
|
3015
3016
|
|
|
3016
3017
|
//#endregion
|
|
3017
|
-
export { UniverSheetsTableUIPlugin };
|
|
3018
|
+
export { menuSchema as SheetsTableUIMenuSchema, UniverSheetsTableUIPlugin };
|
package/lib/types/index.d.ts
CHANGED