@univerjs/sheets-table-ui 1.0.0-alpha.1 → 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 +225 -224
- package/lib/es/index.js +226 -226
- package/lib/index.css +0 -4
- package/lib/index.js +226 -226
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +15 -15
package/lib/es/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.1";
|
|
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
|
|
@@ -1397,7 +1529,7 @@ const SheetTableSelector = (props) => {
|
|
|
1397
1529
|
children: rangeError
|
|
1398
1530
|
}),
|
|
1399
1531
|
/* @__PURE__ */ jsxs("div", {
|
|
1400
|
-
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
1532
|
+
className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
|
|
1401
1533
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
1402
1534
|
onClick: onCancel,
|
|
1403
1535
|
children: localeService.t("sheets-table-ui.cancel")
|
|
@@ -1411,7 +1543,6 @@ const SheetTableSelector = (props) => {
|
|
|
1411
1543
|
range: selectedRange
|
|
1412
1544
|
});
|
|
1413
1545
|
},
|
|
1414
|
-
className: "univer-ml-2",
|
|
1415
1546
|
children: localeService.t("sheets-table-ui.confirm")
|
|
1416
1547
|
})]
|
|
1417
1548
|
})
|
|
@@ -1648,7 +1779,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1648
1779
|
"univer-text-gray-900": !headerBgIsDark
|
|
1649
1780
|
}),
|
|
1650
1781
|
style: { background: headerBg }
|
|
1651
|
-
}), /* @__PURE__ */ jsx(
|
|
1782
|
+
}), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
|
|
1652
1783
|
})
|
|
1653
1784
|
})]
|
|
1654
1785
|
}),
|
|
@@ -1679,7 +1810,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1679
1810
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1680
1811
|
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1681
1812
|
style: { background: firstRowBg }
|
|
1682
|
-
}), /* @__PURE__ */ jsx(
|
|
1813
|
+
}), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
|
|
1683
1814
|
})
|
|
1684
1815
|
})]
|
|
1685
1816
|
}),
|
|
@@ -1708,7 +1839,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1708
1839
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1709
1840
|
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1710
1841
|
style: { background: secondRowBg }
|
|
1711
|
-
}), /* @__PURE__ */ jsx(
|
|
1842
|
+
}), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
|
|
1712
1843
|
})
|
|
1713
1844
|
})]
|
|
1714
1845
|
}),
|
|
@@ -1740,7 +1871,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1740
1871
|
children: [/* @__PURE__ */ jsx("div", {
|
|
1741
1872
|
className: clsx("univer-size-4 univer-rounded-lg univer-bg-gray-400", borderClassName),
|
|
1742
1873
|
style: { background: lastRowBg }
|
|
1743
|
-
}), /* @__PURE__ */ jsx(
|
|
1874
|
+
}), /* @__PURE__ */ jsx(DownIcon, { className: "univer-size-2" })]
|
|
1744
1875
|
})
|
|
1745
1876
|
})]
|
|
1746
1877
|
})
|
|
@@ -2786,137 +2917,6 @@ SheetTableSelectionController = __decorate([
|
|
|
2786
2917
|
__decorateParam(2, Inject(TableManager))
|
|
2787
2918
|
], SheetTableSelectionController);
|
|
2788
2919
|
|
|
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: MenuItemType.BUTTON,
|
|
2797
|
-
icon: "TableIcon",
|
|
2798
|
-
tooltip: "sheets-table-ui.title",
|
|
2799
|
-
title: "sheets-table-ui.title",
|
|
2800
|
-
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
2801
|
-
disabled$: getCurrentRangeDisable$(accessor, {}, true)
|
|
2802
|
-
};
|
|
2803
|
-
}
|
|
2804
|
-
function SheetTableInsertContextMenuFactory(accessor) {
|
|
2805
|
-
return {
|
|
2806
|
-
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
2807
|
-
type: 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: 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: SheetTableInsertRowCommand.id,
|
|
2825
|
-
type: MenuItemType.BUTTON,
|
|
2826
|
-
title: "sheets-table-ui.insert.row",
|
|
2827
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2828
|
-
};
|
|
2829
|
-
}
|
|
2830
|
-
function SheetTableInsertColMenuFactory() {
|
|
2831
|
-
return {
|
|
2832
|
-
id: SheetTableInsertColCommand.id,
|
|
2833
|
-
title: "sheets-table-ui.insert.col",
|
|
2834
|
-
type: MenuItemType.BUTTON
|
|
2835
|
-
};
|
|
2836
|
-
}
|
|
2837
|
-
function SheetTableRemoveRowMenuFactory(accessor) {
|
|
2838
|
-
return {
|
|
2839
|
-
id: SheetTableRemoveRowCommand.id,
|
|
2840
|
-
type: MenuItemType.BUTTON,
|
|
2841
|
-
title: "sheets-table-ui.remove.row",
|
|
2842
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2843
|
-
};
|
|
2844
|
-
}
|
|
2845
|
-
function SheetTableRemoveColMenuFactory() {
|
|
2846
|
-
return {
|
|
2847
|
-
id: SheetTableRemoveColCommand.id,
|
|
2848
|
-
title: "sheets-table-ui.remove.col",
|
|
2849
|
-
type: MenuItemType.BUTTON
|
|
2850
|
-
};
|
|
2851
|
-
}
|
|
2852
|
-
function getSheetTableRowColOperationHidden$(accessor) {
|
|
2853
|
-
const sheetsSelectionsService = accessor.get(SheetsSelectionsService);
|
|
2854
|
-
return accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
|
|
2855
|
-
if (!workbook) return of(true);
|
|
2856
|
-
return workbook.activeSheet$.pipe(switchMap((sheet) => {
|
|
2857
|
-
if (!sheet) return of(true);
|
|
2858
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe(switchMap((selections) => {
|
|
2859
|
-
if (!selections.length || selections.length > 1) return of(true);
|
|
2860
|
-
const range = selections[0].range;
|
|
2861
|
-
return of(!accessor.get(SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range));
|
|
2862
|
-
}));
|
|
2863
|
-
}));
|
|
2864
|
-
}));
|
|
2865
|
-
}
|
|
2866
|
-
function getSheetTableHeaderOperationHidden$(accessor) {
|
|
2867
|
-
const sheetsSelectionsService = accessor.get(SheetsSelectionsService);
|
|
2868
|
-
return accessor.get(IUniverInstanceService).getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(switchMap((workbook) => {
|
|
2869
|
-
if (!workbook) return of(true);
|
|
2870
|
-
return workbook.activeSheet$.pipe(switchMap((sheet) => {
|
|
2871
|
-
if (!sheet) return of(true);
|
|
2872
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe(switchMap((selections) => {
|
|
2873
|
-
if (!selections.length || selections.length > 1) return of(true);
|
|
2874
|
-
const range = selections[0].range;
|
|
2875
|
-
const isInTable = accessor.get(SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
2876
|
-
if (!isInTable) return of(true);
|
|
2877
|
-
const tableRange = isInTable.getRange();
|
|
2878
|
-
if (range.startRow === tableRange.startRow) return of(true);
|
|
2879
|
-
return of(false);
|
|
2880
|
-
}));
|
|
2881
|
-
}));
|
|
2882
|
-
}));
|
|
2883
|
-
}
|
|
2884
|
-
|
|
2885
|
-
//#endregion
|
|
2886
|
-
//#region src/menu/schema.ts
|
|
2887
|
-
const menuSchema = {
|
|
2888
|
-
[RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
2889
|
-
order: 0,
|
|
2890
|
-
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
2891
|
-
} },
|
|
2892
|
-
[ContextMenuPosition.MAIN_AREA]: { [ContextMenuGroup.LAYOUT]: {
|
|
2893
|
-
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
2894
|
-
order: 5,
|
|
2895
|
-
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
2896
|
-
[SheetTableInsertRowCommand.id]: {
|
|
2897
|
-
order: 1,
|
|
2898
|
-
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
2899
|
-
},
|
|
2900
|
-
[SheetTableInsertColCommand.id]: {
|
|
2901
|
-
order: 2,
|
|
2902
|
-
menuItemFactory: SheetTableInsertColMenuFactory
|
|
2903
|
-
}
|
|
2904
|
-
},
|
|
2905
|
-
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
2906
|
-
order: 6,
|
|
2907
|
-
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
2908
|
-
[SheetTableRemoveRowCommand.id]: {
|
|
2909
|
-
order: 1,
|
|
2910
|
-
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
2911
|
-
},
|
|
2912
|
-
[SheetTableRemoveColCommand.id]: {
|
|
2913
|
-
order: 2,
|
|
2914
|
-
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
} }
|
|
2918
|
-
};
|
|
2919
|
-
|
|
2920
2920
|
//#endregion
|
|
2921
2921
|
//#region src/menu/sheet-table-menu.controller.ts
|
|
2922
2922
|
/**
|
|
@@ -3015,4 +3015,4 @@ UniverSheetsTableUIPlugin = __decorate([
|
|
|
3015
3015
|
], UniverSheetsTableUIPlugin);
|
|
3016
3016
|
|
|
3017
3017
|
//#endregion
|
|
3018
|
-
export { UniverSheetsTableUIPlugin };
|
|
3018
|
+
export { menuSchema as SheetsTableUIMenuSchema, UniverSheetsTableUIPlugin };
|