@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/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.1";
|
|
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.3";
|
|
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";
|
|
@@ -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);
|
|
@@ -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
|
|
@@ -1398,7 +1530,7 @@ const SheetTableSelector = (props) => {
|
|
|
1398
1530
|
children: rangeError
|
|
1399
1531
|
}),
|
|
1400
1532
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1401
|
-
className: "univer-mt-4 univer-flex univer-justify-end",
|
|
1533
|
+
className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
|
|
1402
1534
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1403
1535
|
onClick: onCancel,
|
|
1404
1536
|
children: localeService.t("sheets-table-ui.cancel")
|
|
@@ -1412,7 +1544,6 @@ const SheetTableSelector = (props) => {
|
|
|
1412
1544
|
range: selectedRange
|
|
1413
1545
|
});
|
|
1414
1546
|
},
|
|
1415
|
-
className: "univer-ml-2",
|
|
1416
1547
|
children: localeService.t("sheets-table-ui.confirm")
|
|
1417
1548
|
})]
|
|
1418
1549
|
})
|
|
@@ -1649,7 +1780,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1649
1780
|
"univer-text-gray-900": !headerBgIsDark
|
|
1650
1781
|
}),
|
|
1651
1782
|
style: { background: headerBg }
|
|
1652
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1783
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1653
1784
|
})
|
|
1654
1785
|
})]
|
|
1655
1786
|
}),
|
|
@@ -1680,7 +1811,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1680
1811
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1681
1812
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1682
1813
|
style: { background: firstRowBg }
|
|
1683
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1814
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1684
1815
|
})
|
|
1685
1816
|
})]
|
|
1686
1817
|
}),
|
|
@@ -1709,7 +1840,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1709
1840
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1710
1841
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1711
1842
|
style: { background: secondRowBg }
|
|
1712
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1843
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1713
1844
|
})
|
|
1714
1845
|
})]
|
|
1715
1846
|
}),
|
|
@@ -1741,7 +1872,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1741
1872
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1742
1873
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-lg univer-bg-gray-400", _univerjs_design.borderClassName),
|
|
1743
1874
|
style: { background: lastRowBg }
|
|
1744
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.
|
|
1875
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DownIcon, { className: "univer-size-2" })]
|
|
1745
1876
|
})
|
|
1746
1877
|
})]
|
|
1747
1878
|
})
|
|
@@ -2787,137 +2918,6 @@ SheetTableSelectionController = __decorate([
|
|
|
2787
2918
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager))
|
|
2788
2919
|
], SheetTableSelectionController);
|
|
2789
2920
|
|
|
2790
|
-
//#endregion
|
|
2791
|
-
//#region src/menu/menu.ts
|
|
2792
|
-
const SHEET_TABLE_CONTEXT_INSERT_MENU_ID = "sheet.table.context-insert_menu-id";
|
|
2793
|
-
const SHEET_TABLE_CONTEXT_REMOVE_MENU_ID = "sheet.table.context-remove_menu-id";
|
|
2794
|
-
function sheetTableToolbarInsertMenuFactory(accessor) {
|
|
2795
|
-
return {
|
|
2796
|
-
id: OpenTableSelectorOperation.id,
|
|
2797
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2798
|
-
icon: "TableIcon",
|
|
2799
|
-
tooltip: "sheets-table-ui.title",
|
|
2800
|
-
title: "sheets-table-ui.title",
|
|
2801
|
-
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2802
|
-
disabled$: (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {}, true)
|
|
2803
|
-
};
|
|
2804
|
-
}
|
|
2805
|
-
function SheetTableInsertContextMenuFactory(accessor) {
|
|
2806
|
-
return {
|
|
2807
|
-
id: SHEET_TABLE_CONTEXT_INSERT_MENU_ID,
|
|
2808
|
-
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2809
|
-
icon: "InsertDoubleIcon",
|
|
2810
|
-
title: "sheets-table-ui.insert.main",
|
|
2811
|
-
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2812
|
-
};
|
|
2813
|
-
}
|
|
2814
|
-
function SheetTableRemoveContextMenuFactory(accessor) {
|
|
2815
|
-
return {
|
|
2816
|
-
id: SHEET_TABLE_CONTEXT_REMOVE_MENU_ID,
|
|
2817
|
-
type: _univerjs_ui.MenuItemType.SUBITEMS,
|
|
2818
|
-
icon: "ReduceDoubleIcon",
|
|
2819
|
-
title: "sheets-table-ui.remove.main",
|
|
2820
|
-
hidden$: getSheetTableRowColOperationHidden$(accessor)
|
|
2821
|
-
};
|
|
2822
|
-
}
|
|
2823
|
-
function SheetTableInsertRowMenuFactory(accessor) {
|
|
2824
|
-
return {
|
|
2825
|
-
id: _univerjs_sheets_table.SheetTableInsertRowCommand.id,
|
|
2826
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2827
|
-
title: "sheets-table-ui.insert.row",
|
|
2828
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2829
|
-
};
|
|
2830
|
-
}
|
|
2831
|
-
function SheetTableInsertColMenuFactory() {
|
|
2832
|
-
return {
|
|
2833
|
-
id: _univerjs_sheets_table.SheetTableInsertColCommand.id,
|
|
2834
|
-
title: "sheets-table-ui.insert.col",
|
|
2835
|
-
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2836
|
-
};
|
|
2837
|
-
}
|
|
2838
|
-
function SheetTableRemoveRowMenuFactory(accessor) {
|
|
2839
|
-
return {
|
|
2840
|
-
id: _univerjs_sheets_table.SheetTableRemoveRowCommand.id,
|
|
2841
|
-
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2842
|
-
title: "sheets-table-ui.remove.row",
|
|
2843
|
-
hidden$: getSheetTableHeaderOperationHidden$(accessor)
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
function SheetTableRemoveColMenuFactory() {
|
|
2847
|
-
return {
|
|
2848
|
-
id: _univerjs_sheets_table.SheetTableRemoveColCommand.id,
|
|
2849
|
-
title: "sheets-table-ui.remove.col",
|
|
2850
|
-
type: _univerjs_ui.MenuItemType.BUTTON
|
|
2851
|
-
};
|
|
2852
|
-
}
|
|
2853
|
-
function getSheetTableRowColOperationHidden$(accessor) {
|
|
2854
|
-
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
2855
|
-
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
2856
|
-
if (!workbook) return (0, rxjs.of)(true);
|
|
2857
|
-
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
2858
|
-
if (!sheet) return (0, rxjs.of)(true);
|
|
2859
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
2860
|
-
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
2861
|
-
const range = selections[0].range;
|
|
2862
|
-
return (0, rxjs.of)(!accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range));
|
|
2863
|
-
}));
|
|
2864
|
-
}));
|
|
2865
|
-
}));
|
|
2866
|
-
}
|
|
2867
|
-
function getSheetTableHeaderOperationHidden$(accessor) {
|
|
2868
|
-
const sheetsSelectionsService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
2869
|
-
return accessor.get(_univerjs_core.IUniverInstanceService).getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).pipe((0, rxjs.switchMap)((workbook) => {
|
|
2870
|
-
if (!workbook) return (0, rxjs.of)(true);
|
|
2871
|
-
return workbook.activeSheet$.pipe((0, rxjs.switchMap)((sheet) => {
|
|
2872
|
-
if (!sheet) return (0, rxjs.of)(true);
|
|
2873
|
-
return sheetsSelectionsService.selectionMoveEnd$.pipe((0, rxjs.switchMap)((selections) => {
|
|
2874
|
-
if (!selections.length || selections.length > 1) return (0, rxjs.of)(true);
|
|
2875
|
-
const range = selections[0].range;
|
|
2876
|
-
const isInTable = accessor.get(_univerjs_sheets_table.SheetsTableController).getContainerTableWithRange(workbook.getUnitId(), sheet.getSheetId(), range);
|
|
2877
|
-
if (!isInTable) return (0, rxjs.of)(true);
|
|
2878
|
-
const tableRange = isInTable.getRange();
|
|
2879
|
-
if (range.startRow === tableRange.startRow) return (0, rxjs.of)(true);
|
|
2880
|
-
return (0, rxjs.of)(false);
|
|
2881
|
-
}));
|
|
2882
|
-
}));
|
|
2883
|
-
}));
|
|
2884
|
-
}
|
|
2885
|
-
|
|
2886
|
-
//#endregion
|
|
2887
|
-
//#region src/menu/schema.ts
|
|
2888
|
-
const menuSchema = {
|
|
2889
|
-
[_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [OpenTableSelectorOperation.id]: {
|
|
2890
|
-
order: 0,
|
|
2891
|
-
menuItemFactory: sheetTableToolbarInsertMenuFactory
|
|
2892
|
-
} },
|
|
2893
|
-
[_univerjs_ui.ContextMenuPosition.MAIN_AREA]: { [_univerjs_ui.ContextMenuGroup.LAYOUT]: {
|
|
2894
|
-
[SHEET_TABLE_CONTEXT_INSERT_MENU_ID]: {
|
|
2895
|
-
order: 5,
|
|
2896
|
-
menuItemFactory: SheetTableInsertContextMenuFactory,
|
|
2897
|
-
[_univerjs_sheets_table.SheetTableInsertRowCommand.id]: {
|
|
2898
|
-
order: 1,
|
|
2899
|
-
menuItemFactory: SheetTableInsertRowMenuFactory
|
|
2900
|
-
},
|
|
2901
|
-
[_univerjs_sheets_table.SheetTableInsertColCommand.id]: {
|
|
2902
|
-
order: 2,
|
|
2903
|
-
menuItemFactory: SheetTableInsertColMenuFactory
|
|
2904
|
-
}
|
|
2905
|
-
},
|
|
2906
|
-
[SHEET_TABLE_CONTEXT_REMOVE_MENU_ID]: {
|
|
2907
|
-
order: 6,
|
|
2908
|
-
menuItemFactory: SheetTableRemoveContextMenuFactory,
|
|
2909
|
-
[_univerjs_sheets_table.SheetTableRemoveRowCommand.id]: {
|
|
2910
|
-
order: 1,
|
|
2911
|
-
menuItemFactory: SheetTableRemoveRowMenuFactory
|
|
2912
|
-
},
|
|
2913
|
-
[_univerjs_sheets_table.SheetTableRemoveColCommand.id]: {
|
|
2914
|
-
order: 2,
|
|
2915
|
-
menuItemFactory: SheetTableRemoveColMenuFactory
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
} }
|
|
2919
|
-
};
|
|
2920
|
-
|
|
2921
2921
|
//#endregion
|
|
2922
2922
|
//#region src/menu/sheet-table-menu.controller.ts
|
|
2923
2923
|
/**
|
|
@@ -3016,6 +3016,7 @@ UniverSheetsTableUIPlugin = __decorate([
|
|
|
3016
3016
|
], UniverSheetsTableUIPlugin);
|
|
3017
3017
|
|
|
3018
3018
|
//#endregion
|
|
3019
|
+
exports.SheetsTableUIMenuSchema = menuSchema;
|
|
3019
3020
|
Object.defineProperty(exports, 'UniverSheetsTableUIPlugin', {
|
|
3020
3021
|
enumerable: true,
|
|
3021
3022
|
get: function () {
|