@univerjs/sheets-table-ui 1.0.0-insiders.20260809-70eefdd → 1.0.0-rc.0
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/LICENSE +176 -0
- package/README.md +0 -1
- package/lib/cjs/index.js +1375 -471
- package/lib/cjs/locale/ar-SA.js +7 -2
- package/lib/cjs/locale/ca-ES.js +7 -2
- package/lib/cjs/locale/de-DE.js +7 -2
- package/lib/cjs/locale/en-US.js +7 -2
- package/lib/cjs/locale/es-ES.js +7 -2
- package/lib/cjs/locale/fa-IR.js +8 -3
- package/lib/cjs/locale/fr-FR.js +7 -2
- package/lib/cjs/locale/id-ID.js +7 -2
- package/lib/cjs/locale/it-IT.js +7 -2
- package/lib/cjs/locale/ja-JP.js +7 -2
- package/lib/cjs/locale/ko-KR.js +7 -2
- package/lib/cjs/locale/pl-PL.js +7 -2
- package/lib/cjs/locale/pt-BR.js +7 -2
- package/lib/cjs/locale/ru-RU.js +7 -2
- package/lib/cjs/locale/sk-SK.js +7 -2
- package/lib/cjs/locale/vi-VN.js +7 -2
- package/lib/cjs/locale/zh-CN.js +7 -2
- package/lib/cjs/locale/zh-HK.js +7 -2
- package/lib/cjs/locale/zh-TW.js +7 -2
- package/lib/es/index.js +1359 -461
- package/lib/es/locale/ar-SA.js +7 -2
- package/lib/es/locale/ca-ES.js +7 -2
- package/lib/es/locale/de-DE.js +7 -2
- package/lib/es/locale/en-US.js +7 -2
- package/lib/es/locale/es-ES.js +7 -2
- package/lib/es/locale/fa-IR.js +8 -3
- package/lib/es/locale/fr-FR.js +7 -2
- package/lib/es/locale/id-ID.js +7 -2
- package/lib/es/locale/it-IT.js +7 -2
- package/lib/es/locale/ja-JP.js +7 -2
- package/lib/es/locale/ko-KR.js +7 -2
- package/lib/es/locale/pl-PL.js +7 -2
- package/lib/es/locale/pt-BR.js +7 -2
- package/lib/es/locale/ru-RU.js +7 -2
- package/lib/es/locale/sk-SK.js +7 -2
- package/lib/es/locale/vi-VN.js +7 -2
- package/lib/es/locale/zh-CN.js +7 -2
- package/lib/es/locale/zh-HK.js +7 -2
- package/lib/es/locale/zh-TW.js +7 -2
- package/lib/index.css +184 -45
- package/lib/index.js +1359 -461
- package/lib/locale/ar-SA.js +7 -2
- package/lib/locale/ca-ES.js +7 -2
- package/lib/locale/de-DE.js +7 -2
- package/lib/locale/en-US.js +7 -2
- package/lib/locale/es-ES.js +7 -2
- package/lib/locale/fa-IR.js +8 -3
- package/lib/locale/fr-FR.js +7 -2
- package/lib/locale/id-ID.js +7 -2
- package/lib/locale/it-IT.js +7 -2
- package/lib/locale/ja-JP.js +7 -2
- package/lib/locale/ko-KR.js +7 -2
- package/lib/locale/pl-PL.js +7 -2
- package/lib/locale/pt-BR.js +7 -2
- package/lib/locale/ru-RU.js +7 -2
- package/lib/locale/sk-SK.js +7 -2
- package/lib/locale/vi-VN.js +7 -2
- package/lib/locale/zh-CN.js +7 -2
- package/lib/locale/zh-HK.js +7 -2
- package/lib/locale/zh-TW.js +7 -2
- package/lib/types/const.d.ts +1 -0
- package/lib/types/controllers/mobile/components.controller.d.ts +20 -0
- package/lib/types/controllers/mobile/sheet-table-component.controller.d.ts +19 -0
- package/lib/types/controllers/mobile/sheet-table-controls-render.controller.d.ts +19 -0
- package/lib/types/controllers/sheet-table-component.controller.d.ts +4 -5
- package/lib/types/controllers/sheet-table-controls-render.controller.d.ts +15 -12
- package/lib/types/index.d.ts +1 -0
- package/lib/types/locale/en-US.d.ts +7 -2
- package/lib/types/mobile-plugin.d.ts +35 -0
- package/lib/types/services/sheets-table-ui.service.d.ts +4 -2
- package/lib/types/types.d.ts +9 -0
- package/lib/types/views/components/MobileSheetTableColorFilterPanel.d.ts +22 -0
- package/lib/types/views/components/MobileSheetTableConditionPanel.d.ts +28 -0
- package/lib/types/views/components/MobileSheetTableFilterPanel.d.ts +16 -0
- package/lib/types/views/components/MobileSheetTableItemsFilterPanel.d.ts +24 -0
- package/lib/types/views/components/MobileSheetTableMenu.d.ts +19 -0
- package/lib/types/views/components/MobileSheetTableRenameDialog.d.ts +17 -0
- package/lib/types/views/components/MobileSheetTableSelector.d.ts +17 -0
- package/lib/types/views/components/MobileSheetTableThemePanel.d.ts +17 -0
- package/lib/types/views/components/SheetTableColorFilterPanel.d.ts +22 -0
- package/lib/types/views/components/SheetTableRenameDialog.d.ts +2 -0
- package/lib/types/views/components/SheetTableSelector.d.ts +5 -2
- package/lib/types/views/components/SheetTableThemePanel.d.ts +3 -0
- package/lib/umd/index.js +4 -1
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +16 -15
package/lib/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
10
10
|
let _univerjs_design = require("@univerjs/design");
|
|
11
11
|
let _univerjs_sheets_sort = require("@univerjs/sheets-sort");
|
|
12
12
|
let react = require("react");
|
|
13
|
+
let react_dom = require("react-dom");
|
|
13
14
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
15
|
let _univerjs_engine_formula = require("@univerjs/engine-formula");
|
|
15
16
|
let _univerjs_sheets_formula_ui = require("@univerjs/sheets-formula-ui");
|
|
@@ -39,6 +40,7 @@ const SHEET_TABLE_RENAME_DIALOG_ID = "SHEET_TABLE_RENAME_DIALOG_ID";
|
|
|
39
40
|
const SHEET_TABLE_THEME_PANEL_ID = "SHEET_TABLE_THEME_PANEL_ID";
|
|
40
41
|
const SHEET_TABLE_THEME_PANEL = "SHEET_TABLE_THEME_PANEL";
|
|
41
42
|
const SHEET_TABLE_MENU = "SHEET_TABLE_MENU";
|
|
43
|
+
const SHEET_TABLE_MOBILE_MENU = "SHEET_TABLE_MOBILE_MENU";
|
|
42
44
|
const TABLE_CUSTOM_NAME_PREFIX = "table-custom-";
|
|
43
45
|
const TABLE_DEFAULT_NAME_PREFIX = "table-default-";
|
|
44
46
|
const TABLE_DEFAULT_BG_COLOR = "rgb(255, 255, 255)";
|
|
@@ -249,7 +251,7 @@ const menuSchema = {
|
|
|
249
251
|
//#endregion
|
|
250
252
|
//#region package.json
|
|
251
253
|
var name = "@univerjs/sheets-table-ui";
|
|
252
|
-
var version = "1.0.0-
|
|
254
|
+
var version = "1.0.0-rc.0";
|
|
253
255
|
|
|
254
256
|
//#endregion
|
|
255
257
|
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
|
|
@@ -373,6 +375,7 @@ let SheetsTableComponentController = class SheetsTableComponentController extend
|
|
|
373
375
|
}
|
|
374
376
|
_closeFilterPopup() {
|
|
375
377
|
var _this$_popupDisposabl2;
|
|
378
|
+
this._dialogService.close(UNIVER_SHEET_TABLE_FILTER_PANEL_ID);
|
|
376
379
|
(_this$_popupDisposabl2 = this._popupDisposable) === null || _this$_popupDisposabl2 === void 0 || _this$_popupDisposabl2.dispose();
|
|
377
380
|
this._popupDisposable = null;
|
|
378
381
|
this.clearCurrentTableFilterInfo();
|
|
@@ -468,7 +471,7 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
468
471
|
unitId,
|
|
469
472
|
subUnitId,
|
|
470
473
|
tableFilter,
|
|
471
|
-
currentFilterBy: (0, _univerjs_sheets_table.isConditionFilter)(tableFilter) ? "condition" : "items",
|
|
474
|
+
currentFilterBy: (0, _univerjs_sheets_table.isConditionFilter)(tableFilter) ? "condition" : (0, _univerjs_sheets_table.isColorTableFilter)(tableFilter) ? "color" : "items",
|
|
472
475
|
tableId,
|
|
473
476
|
columnIndex: column - tableRange.startColumn
|
|
474
477
|
};
|
|
@@ -482,18 +485,57 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
482
485
|
}
|
|
483
486
|
return checkedItems;
|
|
484
487
|
}
|
|
485
|
-
setTableFilter(unitId, tableId, columnIndex, tableFilter) {
|
|
486
|
-
if (!this._tableManager.getTable(unitId, tableId)) return;
|
|
488
|
+
async setTableFilter(unitId, tableId, columnIndex, tableFilter) {
|
|
489
|
+
if (!this._tableManager.getTable(unitId, tableId)) return false;
|
|
487
490
|
const setTableFilterParams = {
|
|
488
491
|
unitId,
|
|
489
492
|
tableId,
|
|
490
493
|
column: columnIndex,
|
|
491
494
|
tableFilter
|
|
492
495
|
};
|
|
493
|
-
this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
496
|
+
return this._commandService.executeCommand(_univerjs_sheets_table.SetSheetTableFilterCommand.id, setTableFilterParams);
|
|
497
|
+
}
|
|
498
|
+
getTableFilterColors(unitId, subUnitId, tableId, columnIndex) {
|
|
499
|
+
var _this$_univerInstance, _currentFilter$cellFi, _currentFilter$cellTe;
|
|
500
|
+
const emptyResult = {
|
|
501
|
+
cellFillColors: [],
|
|
502
|
+
cellTextColors: []
|
|
503
|
+
};
|
|
504
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
505
|
+
if (!table) return emptyResult;
|
|
506
|
+
const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
|
|
507
|
+
if (!worksheet) return emptyResult;
|
|
508
|
+
const normalizeColor = (color) => color ? new _univerjs_core.ColorKit(color).toRgbString() : null;
|
|
509
|
+
const currentFilter = table.getTableFilterColumn(columnIndex);
|
|
510
|
+
const checkedFillColors = new Set((0, _univerjs_sheets_table.isColorTableFilter)(currentFilter) ? (_currentFilter$cellFi = currentFilter.cellFillColors) === null || _currentFilter$cellFi === void 0 ? void 0 : _currentFilter$cellFi.map(normalizeColor) : []);
|
|
511
|
+
const checkedTextColors = new Set((0, _univerjs_sheets_table.isColorTableFilter)(currentFilter) ? (_currentFilter$cellTe = currentFilter.cellTextColors) === null || _currentFilter$cellTe === void 0 ? void 0 : _currentFilter$cellTe.map(normalizeColor) : []);
|
|
512
|
+
const cellFillColors = /* @__PURE__ */ new Map();
|
|
513
|
+
const cellTextColors = /* @__PURE__ */ new Map();
|
|
514
|
+
const tableRange = table.getTableFilterRange();
|
|
515
|
+
const column = tableRange.startColumn + columnIndex;
|
|
516
|
+
const filteredRowsByOtherColumns = this._getFilteredRowsByOtherColumns(worksheet, tableId, unitId, columnIndex);
|
|
517
|
+
for (let row = tableRange.startRow; row <= tableRange.endRow; row++) {
|
|
518
|
+
if (filteredRowsByOtherColumns.has(row)) continue;
|
|
519
|
+
const cellData = worksheet.getCell(row, column);
|
|
520
|
+
const style = worksheet.getComposedCellStyleByCellData(row, column, cellData);
|
|
521
|
+
const fillColor = normalizeColor((0, _univerjs_core.getColorStyle)(style.bg));
|
|
522
|
+
const textColor = normalizeColor((0, _univerjs_core.getColorStyle)(style.cl) ?? (0, _univerjs_core.getColorStyle)(_univerjs_core.DEFAULT_STYLES.cl));
|
|
523
|
+
cellFillColors.set(fillColor, checkedFillColors.has(fillColor));
|
|
524
|
+
cellTextColors.set(textColor, checkedTextColors.has(textColor));
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
cellFillColors: Array.from(cellFillColors, ([color, checked]) => ({
|
|
528
|
+
color,
|
|
529
|
+
checked
|
|
530
|
+
})),
|
|
531
|
+
cellTextColors: Array.from(cellTextColors, ([color, checked]) => ({
|
|
532
|
+
color,
|
|
533
|
+
checked
|
|
534
|
+
}))
|
|
535
|
+
};
|
|
494
536
|
}
|
|
495
537
|
getTableFilterItems(unitId, subUnitId, tableId, columnIndex) {
|
|
496
|
-
var _this$
|
|
538
|
+
var _this$_univerInstance2;
|
|
497
539
|
if (this._itemsCache.has(tableId + columnIndex)) return this._itemsCache.get(tableId + columnIndex) || {
|
|
498
540
|
data: [],
|
|
499
541
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
@@ -505,10 +547,9 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
505
547
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
506
548
|
allItemsCount: 0
|
|
507
549
|
};
|
|
508
|
-
const
|
|
509
|
-
const { startRow, endRow, startColumn } = tableRange;
|
|
550
|
+
const { startRow, endRow, startColumn } = table.getTableFilterRange();
|
|
510
551
|
const column = startColumn + columnIndex;
|
|
511
|
-
const worksheet = (_this$
|
|
552
|
+
const worksheet = (_this$_univerInstance2 = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getSheetBySheetId(subUnitId);
|
|
512
553
|
if (!worksheet) return {
|
|
513
554
|
data: [],
|
|
514
555
|
itemsCountMap: /* @__PURE__ */ new Map(),
|
|
@@ -516,12 +557,7 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
516
557
|
};
|
|
517
558
|
const data = [];
|
|
518
559
|
const map = /* @__PURE__ */ new Map();
|
|
519
|
-
const filteredRowsByOtherColumns =
|
|
520
|
-
const tableFilters = table.getTableFilters();
|
|
521
|
-
for (let i = tableRange.startColumn; i <= tableRange.endColumn; i++) {
|
|
522
|
-
const currentColumnIndex = i - tableRange.startColumn;
|
|
523
|
-
if (currentColumnIndex !== columnIndex && table.getTableFilterColumn(currentColumnIndex)) tableFilters.doColumnFilter(worksheet, tableRange, currentColumnIndex, filteredRowsByOtherColumns);
|
|
524
|
-
}
|
|
560
|
+
const filteredRowsByOtherColumns = this._getFilteredRowsByOtherColumns(worksheet, tableId, unitId, columnIndex);
|
|
525
561
|
let allItemsCount = 0;
|
|
526
562
|
for (let row = startRow; row <= endRow; row++) {
|
|
527
563
|
if (filteredRowsByOtherColumns.has(row)) continue;
|
|
@@ -546,6 +582,18 @@ let SheetsTableUiService = class SheetsTableUiService extends _univerjs_core.Dis
|
|
|
546
582
|
allItemsCount
|
|
547
583
|
};
|
|
548
584
|
}
|
|
585
|
+
_getFilteredRowsByOtherColumns(worksheet, tableId, unitId, columnIndex) {
|
|
586
|
+
const filteredRows = /* @__PURE__ */ new Set();
|
|
587
|
+
const table = this._tableManager.getTable(unitId, tableId);
|
|
588
|
+
if (!table) return filteredRows;
|
|
589
|
+
const tableRange = table.getTableFilterRange();
|
|
590
|
+
const tableFilters = table.getTableFilters();
|
|
591
|
+
for (let column = tableRange.startColumn; column <= tableRange.endColumn; column++) {
|
|
592
|
+
const currentColumnIndex = column - tableRange.startColumn;
|
|
593
|
+
if (currentColumnIndex !== columnIndex && table.getTableFilterColumn(currentColumnIndex)) tableFilters.doColumnFilter(worksheet, tableRange, currentColumnIndex, filteredRows);
|
|
594
|
+
}
|
|
595
|
+
return filteredRows;
|
|
596
|
+
}
|
|
549
597
|
};
|
|
550
598
|
SheetsTableUiService = __decorate([
|
|
551
599
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_table.TableManager)),
|
|
@@ -555,6 +603,86 @@ SheetsTableUiService = __decorate([
|
|
|
555
603
|
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
|
|
556
604
|
], SheetsTableUiService);
|
|
557
605
|
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/views/components/MobileSheetTableColorFilterPanel.tsx
|
|
608
|
+
function MobileColorOption(props) {
|
|
609
|
+
const { item, label, textColor = false, onClick } = props;
|
|
610
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
611
|
+
type: "button",
|
|
612
|
+
"aria-label": item.color ?? label,
|
|
613
|
+
"aria-pressed": item.checked,
|
|
614
|
+
className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-relative univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 dark:!univer-border-gray-600 dark:!univer-bg-gray-800"),
|
|
615
|
+
style: !textColor && item.color ? { backgroundColor: item.color } : void 0,
|
|
616
|
+
onClick,
|
|
617
|
+
children: [
|
|
618
|
+
!item.color && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BanIcon, { className: "univer-size-7" }),
|
|
619
|
+
textColor && item.color && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AIcon, {
|
|
620
|
+
className: "univer-size-7",
|
|
621
|
+
style: { color: item.color }
|
|
622
|
+
}),
|
|
623
|
+
item.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
624
|
+
className: "univer-absolute -univer-bottom-1 -univer-right-1 univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded-full univer-bg-primary-600 univer-text-gray-0",
|
|
625
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.CheckMarkIcon, { className: "univer-size-3" })
|
|
626
|
+
})
|
|
627
|
+
]
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function MobileSheetTableColorFilterPanel(props) {
|
|
631
|
+
const { colors, onChange } = props;
|
|
632
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
633
|
+
const fillLabel = localeService.t("sheets-table-ui.filter.filter-by-cell-fill-color");
|
|
634
|
+
const textLabel = localeService.t("sheets-table-ui.filter.filter-by-cell-text-color");
|
|
635
|
+
const hasMultipleColors = colors.cellFillColors.length > 1 || colors.cellTextColors.length > 1;
|
|
636
|
+
function toggleColor(item, fillColor) {
|
|
637
|
+
const key = fillColor ? "cellFillColors" : "cellTextColors";
|
|
638
|
+
const otherKey = fillColor ? "cellTextColors" : "cellFillColors";
|
|
639
|
+
onChange({
|
|
640
|
+
...colors,
|
|
641
|
+
[key]: colors[key].map((color) => color.color === item.color ? {
|
|
642
|
+
...color,
|
|
643
|
+
checked: !color.checked
|
|
644
|
+
} : color),
|
|
645
|
+
[otherKey]: colors[otherKey].map((color) => ({
|
|
646
|
+
...color,
|
|
647
|
+
checked: false
|
|
648
|
+
}))
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
652
|
+
"data-u-comp": "mobile-sheet-table-filter-by-colors",
|
|
653
|
+
className: "univer-grid univer-gap-6",
|
|
654
|
+
children: [
|
|
655
|
+
colors.cellFillColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
656
|
+
className: "univer-m-0 univer-mb-4 univer-text-base univer-font-medium",
|
|
657
|
+
children: fillLabel
|
|
658
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
659
|
+
className: "univer-flex univer-flex-wrap univer-gap-4",
|
|
660
|
+
children: colors.cellFillColors.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileColorOption, {
|
|
661
|
+
item,
|
|
662
|
+
label: fillLabel,
|
|
663
|
+
onClick: () => toggleColor(item, true)
|
|
664
|
+
}, item.color ?? "none"))
|
|
665
|
+
})] }),
|
|
666
|
+
colors.cellTextColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
667
|
+
className: "univer-m-0 univer-mb-4 univer-text-base univer-font-medium",
|
|
668
|
+
children: textLabel
|
|
669
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
670
|
+
className: "univer-flex univer-flex-wrap univer-gap-4",
|
|
671
|
+
children: colors.cellTextColors.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileColorOption, {
|
|
672
|
+
item,
|
|
673
|
+
label: textLabel,
|
|
674
|
+
textColor: true,
|
|
675
|
+
onClick: () => toggleColor(item, false)
|
|
676
|
+
}, item.color ?? "none"))
|
|
677
|
+
})] }),
|
|
678
|
+
!hasMultipleColors && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
679
|
+
className: "univer-flex univer-min-h-40 univer-items-center univer-justify-center univer-text-gray-500",
|
|
680
|
+
children: localeService.t("sheets-table-ui.filter.filter-by-color-none")
|
|
681
|
+
})
|
|
682
|
+
]
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
|
|
558
686
|
//#endregion
|
|
559
687
|
//#region src/views/components/util.ts
|
|
560
688
|
function getCascaderListOptions(injector) {
|
|
@@ -829,7 +957,7 @@ function getSubComponentType(type, compare) {
|
|
|
829
957
|
return "None";
|
|
830
958
|
}
|
|
831
959
|
function getInitConditionInfo(tableFilter) {
|
|
832
|
-
if (!tableFilter || tableFilter.filterType !==
|
|
960
|
+
if (!tableFilter || tableFilter.filterType !== _univerjs_sheets_table.TableColumnFilterTypeEnum.condition) return {
|
|
833
961
|
type: _univerjs_sheets_table.TableConditionTypeEnum.String,
|
|
834
962
|
compare: _univerjs_sheets_table.TableStringCompareTypeEnum.Equal,
|
|
835
963
|
info: {}
|
|
@@ -898,22 +1026,23 @@ function getInitConditionInfo(tableFilter) {
|
|
|
898
1026
|
}
|
|
899
1027
|
|
|
900
1028
|
//#endregion
|
|
901
|
-
//#region src/views/components/
|
|
902
|
-
|
|
1029
|
+
//#region src/views/components/MobileSheetTableConditionPanel.tsx
|
|
1030
|
+
function MobileSheetTableConditionPanel(props) {
|
|
903
1031
|
var _conditionInfo$info$d, _conditionInfo$info$d2, _conditionInfo$info$n, _conditionInfo$info$n3;
|
|
904
1032
|
const { conditionInfo, onChange } = props;
|
|
905
1033
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
906
|
-
const [conditionVisible, setConditionVisible] = (0, react.useState)(false);
|
|
907
1034
|
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
1035
|
+
const [conditionVisible, setConditionVisible] = (0, react.useState)(false);
|
|
1036
|
+
const [defaultDate] = (0, react.useState)(() => /* @__PURE__ */ new Date());
|
|
908
1037
|
const cascaderOptions = getCascaderListOptions(injector);
|
|
909
|
-
|
|
1038
|
+
function handleConditionInfo(info, type, compare) {
|
|
910
1039
|
onChange({
|
|
911
1040
|
type: type ?? conditionInfo.type,
|
|
912
1041
|
compare: compare ?? conditionInfo.compare,
|
|
913
1042
|
info
|
|
914
1043
|
});
|
|
915
|
-
}
|
|
916
|
-
|
|
1044
|
+
}
|
|
1045
|
+
function handleChange(value) {
|
|
917
1046
|
const type = value[0];
|
|
918
1047
|
const compare = value[1];
|
|
919
1048
|
if (compare) setConditionVisible(false);
|
|
@@ -924,14 +1053,12 @@ const SheetTableConditionPanel = (props) => {
|
|
|
924
1053
|
else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
925
1054
|
else if (type === _univerjs_sheets_table.TableConditionTypeEnum.Number) info.number = 0;
|
|
926
1055
|
else if (type === _univerjs_sheets_table.TableConditionTypeEnum.String) info.string = "";
|
|
927
|
-
handleConditionInfo(info,
|
|
928
|
-
}
|
|
1056
|
+
handleConditionInfo(info, type, compare ?? _univerjs_sheets_table.TableStringCompareTypeEnum.Equal);
|
|
1057
|
+
}
|
|
929
1058
|
const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);
|
|
930
|
-
|
|
931
|
-
if (conditionInfo.compare) selectType = `${localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table-ui.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;
|
|
932
|
-
else selectType = localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`);
|
|
1059
|
+
const selectType = conditionInfo.compare ? `${localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table-ui.${conditionInfo.type}.compare.${conditionInfo.compare}`)}` : localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`);
|
|
933
1060
|
const conditionDateOptions = getConditionDateSelect(injector, conditionInfo.compare);
|
|
934
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.
|
|
1061
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileDropdown, {
|
|
935
1062
|
align: "start",
|
|
936
1063
|
open: conditionVisible,
|
|
937
1064
|
onOpenChange: setConditionVisible,
|
|
@@ -943,7 +1070,7 @@ const SheetTableConditionPanel = (props) => {
|
|
|
943
1070
|
wrapperClassName: "!univer-h-[150px]"
|
|
944
1071
|
}),
|
|
945
1072
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
946
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-
|
|
1073
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-gray-0 univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-gray-0", _univerjs_design.borderClassName),
|
|
947
1074
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectType }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
|
|
948
1075
|
})
|
|
949
1076
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -953,32 +1080,29 @@ const SheetTableConditionPanel = (props) => {
|
|
|
953
1080
|
className: "univer-w-full",
|
|
954
1081
|
placeholder: localeService.t("sheets-table-ui.filter.input-values-placeholder"),
|
|
955
1082
|
value: conditionInfo.info.string,
|
|
956
|
-
onChange: (
|
|
1083
|
+
onChange: (value) => handleConditionInfo({ string: value })
|
|
957
1084
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
958
1085
|
className: "univer-h-7 univer-w-full",
|
|
959
1086
|
value: conditionInfo.info.number,
|
|
960
1087
|
controls: false,
|
|
961
|
-
onChange: (
|
|
962
|
-
if (
|
|
1088
|
+
onChange: (value) => {
|
|
1089
|
+
if (value !== null) handleConditionInfo({ number: value });
|
|
963
1090
|
}
|
|
964
1091
|
}) }),
|
|
965
|
-
|
|
1092
|
+
subComponentType === "DatePicker" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
966
1093
|
id: "univer-table-date-picker-wrapper",
|
|
967
1094
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DatePicker, {
|
|
968
1095
|
className: "univer-w-full",
|
|
969
|
-
value: conditionInfo.info.date ??
|
|
970
|
-
onValueChange: (
|
|
1096
|
+
value: conditionInfo.info.date ?? defaultDate,
|
|
1097
|
+
onValueChange: (value) => handleConditionInfo({ date: value })
|
|
971
1098
|
})
|
|
972
1099
|
}),
|
|
973
|
-
|
|
1100
|
+
subComponentType === "DateRange" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
974
1101
|
id: "univer-table-date-range-wrapper",
|
|
975
1102
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DateRangePicker, {
|
|
976
1103
|
className: "univer-w-full",
|
|
977
|
-
value: [((_conditionInfo$info$d = conditionInfo.info.dateRange) === null || _conditionInfo$info$d === void 0 ? void 0 : _conditionInfo$info$d[0]) ??
|
|
978
|
-
onValueChange: (
|
|
979
|
-
if (v) handleConditionInfo({ dateRange: v });
|
|
980
|
-
else handleConditionInfo({});
|
|
981
|
-
}
|
|
1104
|
+
value: [((_conditionInfo$info$d = conditionInfo.info.dateRange) === null || _conditionInfo$info$d === void 0 ? void 0 : _conditionInfo$info$d[0]) ?? defaultDate, ((_conditionInfo$info$d2 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d2 === void 0 ? void 0 : _conditionInfo$info$d2[1]) ?? defaultDate],
|
|
1105
|
+
onValueChange: (value) => handleConditionInfo(value ? { dateRange: value } : {})
|
|
982
1106
|
})
|
|
983
1107
|
}),
|
|
984
1108
|
subComponentType === "Inputs" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -987,447 +1111,390 @@ const SheetTableConditionPanel = (props) => {
|
|
|
987
1111
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
988
1112
|
className: "univer-w-full",
|
|
989
1113
|
value: (_conditionInfo$info$n = conditionInfo.info.numberRange) === null || _conditionInfo$info$n === void 0 ? void 0 : _conditionInfo$info$n[0],
|
|
990
|
-
|
|
991
|
-
|
|
1114
|
+
controls: false,
|
|
1115
|
+
onChange: (value) => {
|
|
1116
|
+
if (value !== null) {
|
|
992
1117
|
var _conditionInfo$info$n2;
|
|
993
|
-
handleConditionInfo({ numberRange: [
|
|
1118
|
+
handleConditionInfo({ numberRange: [value, (_conditionInfo$info$n2 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n2 === void 0 ? void 0 : _conditionInfo$info$n2[1]] });
|
|
994
1119
|
}
|
|
995
|
-
}
|
|
996
|
-
controls: false
|
|
1120
|
+
}
|
|
997
1121
|
}),
|
|
998
1122
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: " - " }),
|
|
999
1123
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
1000
1124
|
className: "univer-w-full",
|
|
1001
1125
|
value: (_conditionInfo$info$n3 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n3 === void 0 ? void 0 : _conditionInfo$info$n3[1],
|
|
1002
1126
|
controls: false,
|
|
1003
|
-
onChange: (
|
|
1004
|
-
if (
|
|
1127
|
+
onChange: (value) => {
|
|
1128
|
+
if (value !== null) {
|
|
1005
1129
|
var _conditionInfo$info$n4;
|
|
1006
|
-
handleConditionInfo({ numberRange: [(_conditionInfo$info$n4 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n4 === void 0 ? void 0 : _conditionInfo$info$n4[0],
|
|
1130
|
+
handleConditionInfo({ numberRange: [(_conditionInfo$info$n4 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n4 === void 0 ? void 0 : _conditionInfo$info$n4[0], value] });
|
|
1007
1131
|
}
|
|
1008
1132
|
}
|
|
1009
1133
|
})
|
|
1010
1134
|
]
|
|
1011
1135
|
}),
|
|
1012
|
-
|
|
1136
|
+
subComponentType === "Select" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileSelect, {
|
|
1013
1137
|
className: "univer-w-full",
|
|
1014
1138
|
value: conditionInfo.info.dateSelect ?? conditionDateOptions[0].value,
|
|
1015
1139
|
options: conditionDateOptions,
|
|
1016
|
-
onChange: (
|
|
1140
|
+
onChange: (value) => handleConditionInfo({ dateSelect: value })
|
|
1017
1141
|
})
|
|
1018
1142
|
]
|
|
1019
1143
|
})] });
|
|
1020
|
-
}
|
|
1144
|
+
}
|
|
1021
1145
|
|
|
1022
1146
|
//#endregion
|
|
1023
|
-
//#region src/views/components/
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
checkedItemSet.forEach((item) => {
|
|
1027
|
-
count += map.get(item) ?? 0;
|
|
1028
|
-
});
|
|
1029
|
-
return count;
|
|
1030
|
-
};
|
|
1031
|
-
function SheetTableItemsFilterPanel(props) {
|
|
1032
|
-
const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter } = props;
|
|
1147
|
+
//#region src/views/components/MobileSheetTableItemsFilterPanel.tsx
|
|
1148
|
+
function MobileSheetTableItemsFilterPanel(props) {
|
|
1149
|
+
const { items, checkedItemSet, setCheckedItemSet } = props;
|
|
1033
1150
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1034
|
-
const { data: items, itemsCountMap, allItemsCount } = (0, _univerjs_ui.useDependency)(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
1035
|
-
const [allChecked, setAllChecked] = (0, react.useState)(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
1036
|
-
const [checkedCount, setCheckedCount] = (0, react.useState)(() => allChecked ? allItemsCount : getCheckedItemCount(itemsCountMap, checkedItemSet));
|
|
1037
|
-
const indeterminate = !allChecked && checkedItemSet.size > 0;
|
|
1038
1151
|
const [searchText, setSearchText] = (0, react.useState)("");
|
|
1039
1152
|
const displayItems = (0, react.useMemo)(() => {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
const
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
checkedItemSet.add(item.title);
|
|
1062
|
-
});
|
|
1063
|
-
setCheckedCount(allItemsCount);
|
|
1064
|
-
} else {
|
|
1065
|
-
checkedItemSet.clear();
|
|
1066
|
-
setAllChecked(false);
|
|
1067
|
-
setCheckedCount(0);
|
|
1068
|
-
}
|
|
1069
|
-
setSearchText(str);
|
|
1070
|
-
}, []);
|
|
1071
|
-
const onCheckItemToggled = (key) => {
|
|
1072
|
-
if (allChecked) {
|
|
1073
|
-
setAllChecked(false);
|
|
1074
|
-
const newSet = /* @__PURE__ */ new Set();
|
|
1075
|
-
for (const { title } of items) if (key !== title) newSet.add(title);
|
|
1076
|
-
setCheckedCount(allItemsCount - itemsCountMap.get(key));
|
|
1077
|
-
setCheckedItemSet(newSet);
|
|
1078
|
-
} else {
|
|
1079
|
-
if (checkedItemSet.has(key)) {
|
|
1080
|
-
checkedItemSet.delete(key);
|
|
1081
|
-
setCheckedCount(checkedCount - itemsCountMap.get(key));
|
|
1082
|
-
} else {
|
|
1083
|
-
checkedItemSet.add(key);
|
|
1084
|
-
setCheckedCount(checkedCount + itemsCountMap.get(key));
|
|
1085
|
-
}
|
|
1086
|
-
setCheckedItemSet(new Set(checkedItemSet));
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1153
|
+
const normalizedSearchText = searchText.toLowerCase();
|
|
1154
|
+
return normalizedSearchText ? items.data.filter((item) => String(item.title).toLowerCase().includes(normalizedSearchText)) : items.data;
|
|
1155
|
+
}, [items.data, searchText]);
|
|
1156
|
+
const allDisplayedChecked = displayItems.length > 0 && displayItems.every((item) => checkedItemSet.has(item.title));
|
|
1157
|
+
const someDisplayedChecked = displayItems.some((item) => checkedItemSet.has(item.title));
|
|
1158
|
+
function toggleAllDisplayed() {
|
|
1159
|
+
setCheckedItemSet((current) => {
|
|
1160
|
+
const next = new Set(current);
|
|
1161
|
+
for (const item of displayItems) if (allDisplayedChecked) next.delete(item.title);
|
|
1162
|
+
else next.add(item.title);
|
|
1163
|
+
return next;
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
function toggleItem(title) {
|
|
1167
|
+
setCheckedItemSet((current) => {
|
|
1168
|
+
const next = new Set(current);
|
|
1169
|
+
if (next.has(title)) next.delete(title);
|
|
1170
|
+
else next.add(title);
|
|
1171
|
+
return next;
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1089
1174
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1090
|
-
|
|
1175
|
+
"data-u-comp": "mobile-sheet-table-filter-by-values",
|
|
1176
|
+
className: "univer-grid univer-gap-3",
|
|
1091
1177
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1092
|
-
autoFocus: true,
|
|
1093
1178
|
value: searchText,
|
|
1094
1179
|
placeholder: localeService.t("sheets-table-ui.filter.search-placeholder"),
|
|
1095
|
-
onChange:
|
|
1096
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1097
|
-
className:
|
|
1098
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1099
|
-
className:
|
|
1100
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
1101
|
-
className: "univer-h-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
indeterminate,
|
|
1108
|
-
disabled: items.length === 0,
|
|
1109
|
-
checked: allChecked,
|
|
1110
|
-
onChange: onCheckAllToggled,
|
|
1111
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1112
|
-
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
1113
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1114
|
-
className: "univer-flex-1 univer-truncate",
|
|
1115
|
-
children: `${localeService.t("sheets-table-ui.filter.select-all")}`
|
|
1116
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1117
|
-
className: "univer-ml univer-text-gray-400",
|
|
1118
|
-
children: `(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`
|
|
1119
|
-
})]
|
|
1120
|
-
})
|
|
1121
|
-
})
|
|
1122
|
-
}), displayItems.map((item) => {
|
|
1123
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1124
|
-
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
1125
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1126
|
-
className: "univer-min-w-0 univer-flex-1",
|
|
1127
|
-
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
1128
|
-
checked: allChecked || checkedItemSet.has(item.title),
|
|
1129
|
-
onChange: () => {
|
|
1130
|
-
onCheckItemToggled(item.title);
|
|
1131
|
-
},
|
|
1132
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1133
|
-
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
1134
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1135
|
-
className: "univer-flex-1 univer-truncate",
|
|
1136
|
-
children: item.title
|
|
1137
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1138
|
-
className: "univer-ml-1 univer-inline-flex univer-h-full univer-items-center univer-text-gray-400",
|
|
1139
|
-
children: `(${itemsCountMap.get(item.title) || 0})`
|
|
1140
|
-
})]
|
|
1141
|
-
})
|
|
1142
|
-
})
|
|
1143
|
-
}, item.key);
|
|
1144
|
-
})]
|
|
1180
|
+
onChange: setSearchText
|
|
1181
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1182
|
+
className: "univer-overflow-hidden univer-rounded-xl univer-bg-gray-0 dark:!univer-bg-gray-800",
|
|
1183
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1184
|
+
className: "univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-px-4 dark:!univer-border-gray-700",
|
|
1185
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1186
|
+
className: "univer-flex univer-min-h-12 univer-items-center",
|
|
1187
|
+
checked: allDisplayedChecked,
|
|
1188
|
+
indeterminate: !allDisplayedChecked && someDisplayedChecked,
|
|
1189
|
+
disabled: displayItems.length === 0,
|
|
1190
|
+
onChange: toggleAllDisplayed,
|
|
1191
|
+
children: localeService.t("sheets-table-ui.filter.select-all")
|
|
1145
1192
|
})
|
|
1146
|
-
})
|
|
1193
|
+
}), displayItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1194
|
+
className: "univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-px-4 last:univer-border-b-0 dark:!univer-border-gray-700",
|
|
1195
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1196
|
+
className: "univer-flex univer-min-h-12 univer-items-center",
|
|
1197
|
+
checked: checkedItemSet.has(item.title),
|
|
1198
|
+
onChange: () => toggleItem(item.title),
|
|
1199
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1200
|
+
className: "univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-2",
|
|
1201
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1202
|
+
className: "univer-min-w-0 univer-flex-1 univer-truncate",
|
|
1203
|
+
children: item.title
|
|
1204
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1205
|
+
className: "univer-shrink-0 univer-text-gray-400",
|
|
1206
|
+
children: `(${items.itemsCountMap.get(item.title) ?? 0})`
|
|
1207
|
+
})]
|
|
1208
|
+
})
|
|
1209
|
+
})
|
|
1210
|
+
}, item.key))]
|
|
1147
1211
|
})]
|
|
1148
1212
|
});
|
|
1149
1213
|
}
|
|
1150
1214
|
|
|
1151
1215
|
//#endregion
|
|
1152
|
-
//#region src/views/components/
|
|
1153
|
-
const FILTER_BY_OPTIONS = [
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1216
|
+
//#region src/views/components/MobileSheetTableFilterPanel.tsx
|
|
1217
|
+
const FILTER_BY_OPTIONS$1 = [
|
|
1218
|
+
{
|
|
1219
|
+
label: "sheets-table-ui.filter.by-values",
|
|
1220
|
+
value: "items"
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
label: "sheets-table-ui.filter.by-colors",
|
|
1224
|
+
value: "color"
|
|
1225
|
+
},
|
|
1226
|
+
{
|
|
1227
|
+
label: "sheets-table-ui.filter.by-conditions",
|
|
1228
|
+
value: "condition"
|
|
1229
|
+
}
|
|
1230
|
+
];
|
|
1231
|
+
function MobileSheetTableFilterPanel() {
|
|
1232
|
+
const tableFilterPanelInfo = (0, _univerjs_ui.useDependency)(SheetsTableComponentController).getCurrentTableFilterInfo();
|
|
1233
|
+
if (!tableFilterPanelInfo) return null;
|
|
1234
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSheetTableFilterPanelContent, { tableFilterPanelInfo });
|
|
1235
|
+
}
|
|
1236
|
+
function MobileSheetTableFilterPanelContent(props) {
|
|
1161
1237
|
var _permissionService$ge;
|
|
1238
|
+
const { tableFilterPanelInfo } = props;
|
|
1162
1239
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1163
|
-
const filterByItems = FILTER_BY_OPTIONS.map((option) => ({
|
|
1164
|
-
...option,
|
|
1165
|
-
label: localeService.t(option.label)
|
|
1166
|
-
}));
|
|
1167
1240
|
const tableUiService = (0, _univerjs_ui.useDependency)(SheetsTableUiService);
|
|
1168
1241
|
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1169
1242
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1170
1243
|
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
1244
|
+
const undoRedoService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUndoRedoService);
|
|
1171
1245
|
const sheetsTableComponentController = (0, _univerjs_ui.useDependency)(SheetsTableComponentController);
|
|
1172
|
-
const
|
|
1173
|
-
const
|
|
1174
|
-
const
|
|
1175
|
-
const {
|
|
1246
|
+
const [detailFilterBy, setDetailFilterBy] = (0, react.useState)(null);
|
|
1247
|
+
const [drawerSnap, setDrawerSnap] = (0, react.useState)("expanded");
|
|
1248
|
+
const layerRef = (0, react.useRef)(null);
|
|
1249
|
+
const { unitId, subUnitId, tableId, tableFilter, columnIndex } = tableUiService.getTableFilterPanelInitProps(tableFilterPanelInfo.unitId, tableFilterPanelInfo.subUnitId, tableFilterPanelInfo.tableId, tableFilterPanelInfo.column);
|
|
1250
|
+
const currentTable = tableManager.getTable(unitId, tableId);
|
|
1251
|
+
const items = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
1176
1252
|
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
1177
|
-
const [checkedItemSet, setCheckedItemSet] = (0, react.useState)(() => new Set(checkedItems));
|
|
1178
|
-
const [
|
|
1179
|
-
const [
|
|
1180
|
-
|
|
1181
|
-
return getInitConditionInfo(tableFilter);
|
|
1182
|
-
});
|
|
1183
|
-
const table = tableManager.getTable(unitId, tableId);
|
|
1184
|
-
if (!table) return null;
|
|
1185
|
-
const tableFilters = table.getTableFilters();
|
|
1186
|
-
const tableRange = table.getRange();
|
|
1187
|
-
const sortState = tableFilters.getSortState();
|
|
1188
|
-
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Asc);
|
|
1189
|
-
sortState.columnIndex === columnIndex && (sortState.sortState, _univerjs_sheets_table.SheetsTableSortStateEnum.Desc);
|
|
1190
|
-
const absoluteColumn = tableFilterPanelInfo.column;
|
|
1253
|
+
const [checkedItemSet, setCheckedItemSet] = (0, react.useState)(() => new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === _univerjs_sheets_table.TableColumnFilterTypeEnum.manual ? checkedItems : items.data.map((item) => item.title)));
|
|
1254
|
+
const [conditionInfo, setConditionInfo] = (0, react.useState)(() => getInitConditionInfo(tableFilter));
|
|
1255
|
+
const [colors, setColors] = (0, react.useState)(() => tableUiService.getTableFilterColors(unitId, subUnitId, tableId, columnIndex));
|
|
1256
|
+
const tableRange = currentTable.getRange();
|
|
1191
1257
|
const canDeleteColumn = tableRange.endColumn > tableRange.startColumn;
|
|
1192
|
-
const
|
|
1258
|
+
const absoluteColumn = tableFilterPanelInfo.column;
|
|
1259
|
+
const editable = (_permissionService$ge = permissionService.getPermissionPoint(new _univerjs_sheets.WorkbookEditablePermission(unitId).id)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value;
|
|
1260
|
+
function closePanel() {
|
|
1193
1261
|
sheetsTableComponentController.closeFilterPanel();
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1262
|
+
}
|
|
1263
|
+
async function applySort(ascending) {
|
|
1264
|
+
const range = currentTable.getTableFilterRange();
|
|
1265
|
+
const undoRedoGroup = undoRedoService.beginUndoRedoGroup(unitId, (0, _univerjs_core.generateRandomId)(), "append");
|
|
1266
|
+
try {
|
|
1267
|
+
if (!await commandService.executeCommand(_univerjs_sheets_sort.SortRangeCommand.id, {
|
|
1268
|
+
unitId,
|
|
1269
|
+
subUnitId,
|
|
1270
|
+
range,
|
|
1271
|
+
orderRules: [{
|
|
1272
|
+
colIndex: columnIndex + range.startColumn,
|
|
1273
|
+
type: ascending ? _univerjs_sheets_sort.SortType.ASC : _univerjs_sheets_sort.SortType.DESC
|
|
1274
|
+
}],
|
|
1275
|
+
hasTitle: false
|
|
1276
|
+
})) return;
|
|
1277
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SetSheetTableSortStateCommand.id, {
|
|
1278
|
+
unitId,
|
|
1279
|
+
tableId,
|
|
1280
|
+
sortInfo: {
|
|
1281
|
+
columnIndex,
|
|
1282
|
+
sortState: ascending ? _univerjs_sheets_table.SheetsTableSortStateEnum.Asc : _univerjs_sheets_table.SheetsTableSortStateEnum.Desc
|
|
1283
|
+
}
|
|
1284
|
+
})) closePanel();
|
|
1285
|
+
} finally {
|
|
1286
|
+
undoRedoGroup.dispose();
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
async function insertColumn(side) {
|
|
1290
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
1215
1291
|
unitId,
|
|
1216
1292
|
subUnitId,
|
|
1217
1293
|
tableId,
|
|
1218
1294
|
index: side === "left" ? absoluteColumn : absoluteColumn + 1,
|
|
1219
1295
|
count: 1
|
|
1220
|
-
});
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
const deleteColumn = () => {
|
|
1296
|
+
})) closePanel();
|
|
1297
|
+
}
|
|
1298
|
+
async function deleteColumn() {
|
|
1224
1299
|
if (!canDeleteColumn) return;
|
|
1225
|
-
commandService.executeCommand(_univerjs_sheets_table.SheetTableRemoveColumnAtCommand.id, {
|
|
1300
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SheetTableRemoveColumnAtCommand.id, {
|
|
1226
1301
|
unitId,
|
|
1227
1302
|
subUnitId,
|
|
1228
1303
|
tableId,
|
|
1229
1304
|
index: absoluteColumn,
|
|
1230
1305
|
count: 1
|
|
1231
|
-
});
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
if (
|
|
1236
|
-
const filteredItems = [];
|
|
1306
|
+
})) closePanel();
|
|
1307
|
+
}
|
|
1308
|
+
async function applyFilter() {
|
|
1309
|
+
let filter;
|
|
1310
|
+
if (detailFilterBy === "items") {
|
|
1237
1311
|
const emptyLabel = localeService.t("sheets-table-ui.condition.empty");
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
if (originFilter) {
|
|
1241
|
-
if (originFilter.values.join(",") === filteredItems.join(",")) {
|
|
1242
|
-
closeDialog();
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1245
|
-
} else if (filteredItems.length === 0) {
|
|
1246
|
-
closeDialog();
|
|
1247
|
-
return;
|
|
1248
|
-
}
|
|
1249
|
-
const tableFilter = {
|
|
1312
|
+
const values = items.data.filter((item) => checkedItemSet.has(item.title)).map((item) => item.title === emptyLabel ? _univerjs_sheets_table.TABLE_FILTER_EMPTY_VALUE : item.title);
|
|
1313
|
+
filter = values.length === items.data.length ? void 0 : {
|
|
1250
1314
|
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.manual,
|
|
1251
|
-
values
|
|
1315
|
+
values
|
|
1252
1316
|
};
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
if (
|
|
1257
|
-
|
|
1258
|
-
|
|
1317
|
+
} else if (detailFilterBy === "color") {
|
|
1318
|
+
const cellFillColors = colors.cellFillColors.filter((item) => item.checked).map((item) => item.color);
|
|
1319
|
+
const cellTextColors = colors.cellTextColors.filter((item) => item.checked).map((item) => item.color);
|
|
1320
|
+
if (cellFillColors.length) filter = {
|
|
1321
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.color,
|
|
1322
|
+
cellFillColors
|
|
1259
1323
|
};
|
|
1260
|
-
else
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
expectedValue: Object.values(conditionInfo.info)[0]
|
|
1324
|
+
else if (cellTextColors.length) filter = {
|
|
1325
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.color,
|
|
1326
|
+
cellTextColors
|
|
1264
1327
|
};
|
|
1265
|
-
|
|
1328
|
+
} else if (detailFilterBy === "condition") {
|
|
1329
|
+
const dynamicCompare = conditionInfo.compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Quarter || conditionInfo.compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Month;
|
|
1330
|
+
filter = {
|
|
1266
1331
|
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.condition,
|
|
1267
|
-
filterInfo
|
|
1332
|
+
filterInfo: {
|
|
1333
|
+
conditionType: conditionInfo.type,
|
|
1334
|
+
compareType: dynamicCompare ? Object.values(conditionInfo.info)[0] : conditionInfo.compare,
|
|
1335
|
+
expectedValue: dynamicCompare ? void 0 : Object.values(conditionInfo.info)[0]
|
|
1336
|
+
}
|
|
1268
1337
|
};
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
className: "univer-w-1/2",
|
|
1319
|
-
onClick: () => applySort(true),
|
|
1320
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AscendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-asc")]
|
|
1321
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
1322
|
-
className: "univer-w-1/2",
|
|
1323
|
-
onClick: () => applySort(false),
|
|
1324
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-desc")]
|
|
1325
|
-
})]
|
|
1326
|
-
})
|
|
1327
|
-
})] }),
|
|
1328
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1329
|
-
className: "univer-w-full",
|
|
1330
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
|
|
1331
|
-
value: filterBy,
|
|
1332
|
-
items: filterByItems,
|
|
1333
|
-
onChange: (value) => setFilterBy(value)
|
|
1334
|
-
})
|
|
1338
|
+
} else return;
|
|
1339
|
+
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, filter)) closePanel();
|
|
1340
|
+
}
|
|
1341
|
+
async function clearFilter() {
|
|
1342
|
+
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, void 0)) closePanel();
|
|
1343
|
+
}
|
|
1344
|
+
function openDetail(filterBy) {
|
|
1345
|
+
if (filterBy === "items") setCheckedItemSet(new Set((tableFilter === null || tableFilter === void 0 ? void 0 : tableFilter.filterType) === _univerjs_sheets_table.TableColumnFilterTypeEnum.manual ? checkedItems : items.data.map((item) => item.title)));
|
|
1346
|
+
else if (filterBy === "color") setColors(tableUiService.getTableFilterColors(unitId, subUnitId, tableId, columnIndex));
|
|
1347
|
+
else if (filterBy === "condition") setConditionInfo(getInitConditionInfo(tableFilter));
|
|
1348
|
+
setDetailFilterBy(filterBy);
|
|
1349
|
+
setDrawerSnap("expanded");
|
|
1350
|
+
}
|
|
1351
|
+
function closeDetail() {
|
|
1352
|
+
setDetailFilterBy(null);
|
|
1353
|
+
}
|
|
1354
|
+
const detailOption = FILTER_BY_OPTIONS$1.find((option) => option.value === detailFilterBy);
|
|
1355
|
+
const detailTitle = detailOption ? localeService.t(detailOption.label) : "";
|
|
1356
|
+
const detailDrawer = detailFilterBy ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1357
|
+
ref: layerRef,
|
|
1358
|
+
className: "univer-pointer-events-none univer-fixed univer-inset-0 univer-z-[1300]",
|
|
1359
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_ui.MobileDrawer, {
|
|
1360
|
+
layerRef,
|
|
1361
|
+
componentName: "mobile-sheet-table-filter-detail",
|
|
1362
|
+
openMode: "push",
|
|
1363
|
+
snap: drawerSnap,
|
|
1364
|
+
expandLabel: localeService.t("sheets-table-ui.filter.resize"),
|
|
1365
|
+
collapseLabel: localeService.t("sheets-table-ui.filter.resize"),
|
|
1366
|
+
onSnapChange: setDrawerSnap,
|
|
1367
|
+
onClose: closeDetail,
|
|
1368
|
+
role: "dialog",
|
|
1369
|
+
ariaLabel: detailTitle,
|
|
1370
|
+
panelClassName: "univer-pointer-events-auto",
|
|
1371
|
+
contentClassName: "univer-min-h-0 univer-px-4 univer-pb-4",
|
|
1372
|
+
header: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
1373
|
+
className: "univer-grid univer-h-12 univer-flex-1 univer-grid-cols-[48px_1fr_48px] univer-items-center",
|
|
1374
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1375
|
+
type: "button",
|
|
1376
|
+
"aria-label": localeService.t("sheets-table-ui.filter.back"),
|
|
1377
|
+
className: `
|
|
1378
|
+
${_univerjs_design.resetButtonClassName}
|
|
1379
|
+
univer-flex univer-size-12 univer-items-center univer-justify-center
|
|
1380
|
+
`,
|
|
1381
|
+
onClick: closeDetail,
|
|
1382
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, { className: "univer-size-6" })
|
|
1383
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1384
|
+
className: "univer-truncate univer-text-center univer-text-base univer-font-semibold",
|
|
1385
|
+
children: detailTitle
|
|
1386
|
+
})]
|
|
1335
1387
|
}),
|
|
1336
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
1337
|
-
className: "univer-
|
|
1338
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1339
|
-
|
|
1340
|
-
children:
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
checkedItemSet,
|
|
1347
|
-
setCheckedItemSet
|
|
1348
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableConditionPanel, {
|
|
1349
|
-
tableFilter,
|
|
1350
|
-
unitId,
|
|
1351
|
-
subUnitId,
|
|
1352
|
-
tableId,
|
|
1353
|
-
columnIndex,
|
|
1354
|
-
conditionInfo,
|
|
1355
|
-
onChange: setConditionInfo
|
|
1356
|
-
})
|
|
1357
|
-
})
|
|
1388
|
+
footer: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("footer", {
|
|
1389
|
+
className: "univer-shrink-0 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-p-4 dark:!univer-border-gray-700",
|
|
1390
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.MobileActionRowGroup, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1391
|
+
onClick: closeDetail,
|
|
1392
|
+
children: localeService.t("sheets-table-ui.filter.cancel")
|
|
1393
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1394
|
+
variant: "primary",
|
|
1395
|
+
onClick: () => applyFilter().catch(() => void 0),
|
|
1396
|
+
children: localeService.t("sheets-table-ui.filter.confirm")
|
|
1397
|
+
})] })
|
|
1358
1398
|
}),
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1399
|
+
children: [
|
|
1400
|
+
detailFilterBy === "items" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSheetTableItemsFilterPanel, {
|
|
1401
|
+
items,
|
|
1402
|
+
checkedItemSet,
|
|
1403
|
+
setCheckedItemSet
|
|
1404
|
+
}),
|
|
1405
|
+
detailFilterBy === "color" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSheetTableColorFilterPanel, {
|
|
1406
|
+
colors,
|
|
1407
|
+
onChange: setColors
|
|
1408
|
+
}),
|
|
1409
|
+
detailFilterBy === "condition" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileSheetTableConditionPanel, {
|
|
1410
|
+
tableFilter,
|
|
1411
|
+
unitId,
|
|
1412
|
+
subUnitId,
|
|
1413
|
+
tableId,
|
|
1414
|
+
columnIndex,
|
|
1415
|
+
conditionInfo,
|
|
1416
|
+
onChange: setConditionInfo
|
|
1417
|
+
})
|
|
1418
|
+
]
|
|
1419
|
+
})
|
|
1420
|
+
}), document.body) : null;
|
|
1421
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1422
|
+
className: "univer-flex univer-flex-col univer-gap-2",
|
|
1423
|
+
children: [
|
|
1424
|
+
editable && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1425
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1426
|
+
variant: "subtle",
|
|
1427
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftInsertColumnDoubleIcon, {}),
|
|
1428
|
+
title: localeService.t("sheets-table-ui.columnMenu.insert-left"),
|
|
1429
|
+
onClick: () => insertColumn("left").catch(() => void 0)
|
|
1430
|
+
}),
|
|
1431
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1432
|
+
variant: "subtle",
|
|
1433
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightInsertColumnDoubleIcon, {}),
|
|
1434
|
+
title: localeService.t("sheets-table-ui.columnMenu.insert-right"),
|
|
1435
|
+
onClick: () => insertColumn("right").catch(() => void 0)
|
|
1436
|
+
}),
|
|
1437
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1438
|
+
variant: "subtle",
|
|
1439
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteColumnDoubleIcon, {}),
|
|
1440
|
+
title: localeService.t("sheets-table-ui.columnMenu.delete"),
|
|
1441
|
+
disabled: !canDeleteColumn,
|
|
1442
|
+
onClick: () => deleteColumn().catch(() => void 0)
|
|
1443
|
+
}),
|
|
1444
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1445
|
+
variant: "subtle",
|
|
1446
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AscendingIcon, {}),
|
|
1447
|
+
title: localeService.t("sheets-table-ui.sort.sort-asc"),
|
|
1448
|
+
onClick: () => applySort(true).catch(() => void 0)
|
|
1449
|
+
}),
|
|
1450
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1451
|
+
variant: "subtle",
|
|
1452
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, {}),
|
|
1453
|
+
title: localeService.t("sheets-table-ui.sort.sort-desc"),
|
|
1454
|
+
onClick: () => applySort(false).catch(() => void 0)
|
|
1455
|
+
})
|
|
1456
|
+
] }),
|
|
1457
|
+
FILTER_BY_OPTIONS$1.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1458
|
+
variant: "subtle",
|
|
1459
|
+
title: localeService.t(option.label),
|
|
1460
|
+
trailing: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreRightIcon, { className: "univer-size-5 univer-text-gray-400" }),
|
|
1461
|
+
onClick: () => openDetail(option.value)
|
|
1462
|
+
}, option.value)),
|
|
1463
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1464
|
+
variant: "subtle",
|
|
1465
|
+
title: localeService.t("sheets-table-ui.filter.clear-filter"),
|
|
1466
|
+
disabled: !tableFilter,
|
|
1467
|
+
onClick: () => clearFilter().catch(() => void 0)
|
|
1376
1468
|
})
|
|
1377
1469
|
]
|
|
1378
|
-
});
|
|
1470
|
+
}), detailDrawer] });
|
|
1379
1471
|
}
|
|
1380
1472
|
|
|
1381
1473
|
//#endregion
|
|
1382
|
-
//#region src/views/components/
|
|
1383
|
-
|
|
1384
|
-
|
|
1474
|
+
//#region src/views/components/MobileSheetTableMenu.tsx
|
|
1475
|
+
const ACTIONS = [
|
|
1476
|
+
"rename",
|
|
1477
|
+
"update-range",
|
|
1478
|
+
"set-theme",
|
|
1479
|
+
"delete"
|
|
1480
|
+
];
|
|
1481
|
+
function MobileSheetTableMenu({ menu }) {
|
|
1385
1482
|
if (!menu) return null;
|
|
1386
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
type: "item",
|
|
1397
|
-
children: menu.labels["update-range"],
|
|
1398
|
-
onSelect: () => menu.onSelect("update-range")
|
|
1399
|
-
},
|
|
1400
|
-
{
|
|
1401
|
-
type: "item",
|
|
1402
|
-
children: menu.labels["set-theme"],
|
|
1403
|
-
onSelect: () => menu.onSelect("set-theme")
|
|
1404
|
-
},
|
|
1405
|
-
{
|
|
1406
|
-
type: "item",
|
|
1407
|
-
children: menu.labels.delete,
|
|
1408
|
-
variant: "destructive",
|
|
1409
|
-
onSelect: () => menu.onSelect("delete")
|
|
1410
|
-
}
|
|
1411
|
-
],
|
|
1412
|
-
open: true,
|
|
1413
|
-
sideOffset: 0,
|
|
1414
|
-
onOpenChange: (open) => {
|
|
1415
|
-
if (!open) menu.onClose();
|
|
1416
|
-
},
|
|
1417
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1418
|
-
type: "button",
|
|
1419
|
-
"aria-label": menu.tableName,
|
|
1420
|
-
className: "univer-block univer-h-px univer-opacity-0",
|
|
1421
|
-
style: { width: menu.anchorWidth },
|
|
1422
|
-
tabIndex: -1
|
|
1423
|
-
})
|
|
1483
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1484
|
+
className: "univer-flex univer-flex-col univer-gap-2",
|
|
1485
|
+
children: ACTIONS.map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRow, {
|
|
1486
|
+
title: menu.labels[action],
|
|
1487
|
+
"aria-label": menu.labels[action],
|
|
1488
|
+
variant: "subtle",
|
|
1489
|
+
onClick: () => menu.onSelect(action)
|
|
1490
|
+
}, action))
|
|
1424
1491
|
});
|
|
1425
1492
|
}
|
|
1426
1493
|
|
|
1427
1494
|
//#endregion
|
|
1428
1495
|
//#region src/views/components/SheetTableRenameDialog.tsx
|
|
1429
1496
|
function SheetTableRenameDialog(props) {
|
|
1430
|
-
const { unitId, tableId, onClose } = props;
|
|
1497
|
+
const { unitId, tableId, onClose, ActionRowComponent = _univerjs_design.ActionRow } = props;
|
|
1431
1498
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1432
1499
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1433
1500
|
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
@@ -1489,7 +1556,7 @@ function SheetTableRenameDialog(props) {
|
|
|
1489
1556
|
className: "-univer-mt-2 univer-text-sm univer-text-red-500",
|
|
1490
1557
|
children: error
|
|
1491
1558
|
}) : null,
|
|
1492
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
1559
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ActionRowComponent, {
|
|
1493
1560
|
className: "univer-flex univer-w-full univer-items-center univer-justify-end univer-gap-2",
|
|
1494
1561
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1495
1562
|
className: "univer-min-w-16",
|
|
@@ -1506,10 +1573,19 @@ function SheetTableRenameDialog(props) {
|
|
|
1506
1573
|
});
|
|
1507
1574
|
}
|
|
1508
1575
|
|
|
1576
|
+
//#endregion
|
|
1577
|
+
//#region src/views/components/MobileSheetTableRenameDialog.tsx
|
|
1578
|
+
function MobileSheetTableRenameDialog(props) {
|
|
1579
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableRenameDialog, {
|
|
1580
|
+
...props,
|
|
1581
|
+
ActionRowComponent: _univerjs_design.MobileActionRowGroup
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1509
1585
|
//#endregion
|
|
1510
1586
|
//#region src/views/components/SheetTableSelector.tsx
|
|
1511
1587
|
const SheetTableSelector = (props) => {
|
|
1512
|
-
const { unitId, subUnitId, range, onCancel, onConfirm, tableId } = props;
|
|
1588
|
+
const { unitId, subUnitId, range, onCancel, onConfirm, tableId, ActionRowComponent = _univerjs_design.ActionRow } = props;
|
|
1513
1589
|
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
1514
1590
|
const [selectedRange, setSelectedRange] = (0, react.useState)(range);
|
|
1515
1591
|
const [rangeError, setRangeError] = (0, react.useState)("");
|
|
@@ -1577,7 +1653,7 @@ const SheetTableSelector = (props) => {
|
|
|
1577
1653
|
className: "univer-mt-1 univer-text-xs univer-text-red-500",
|
|
1578
1654
|
children: rangeError
|
|
1579
1655
|
}),
|
|
1580
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
1656
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ActionRowComponent, {
|
|
1581
1657
|
className: "univer-mt-4 univer-flex univer-justify-end univer-gap-2",
|
|
1582
1658
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1583
1659
|
onClick: onCancel,
|
|
@@ -1598,6 +1674,15 @@ const SheetTableSelector = (props) => {
|
|
|
1598
1674
|
] });
|
|
1599
1675
|
};
|
|
1600
1676
|
|
|
1677
|
+
//#endregion
|
|
1678
|
+
//#region src/views/components/MobileSheetTableSelector.tsx
|
|
1679
|
+
function MobileSheetTableSelector(props) {
|
|
1680
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableSelector, {
|
|
1681
|
+
...props,
|
|
1682
|
+
ActionRowComponent: _univerjs_design.MobileActionRowGroup
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1601
1686
|
//#endregion
|
|
1602
1687
|
//#region src/controllers/sheet-table-theme-ui.controller.ts
|
|
1603
1688
|
let SheetTableThemeUIController = class SheetTableThemeUIController extends _univerjs_core.Disposable {
|
|
@@ -1623,7 +1708,7 @@ SheetTableThemeUIController = __decorate([__decorateParam(0, (0, _univerjs_core.
|
|
|
1623
1708
|
//#region src/views/components/SheetTableThemePanel.tsx
|
|
1624
1709
|
const SheetTableThemePanel = (props) => {
|
|
1625
1710
|
var _customStyle$getHeade, _customStyle$getFirst, _customStyle$getSecon, _customStyle$getLastR;
|
|
1626
|
-
const { unitId, subUnitId, tableId } = props;
|
|
1711
|
+
const { unitId, subUnitId, tableId, ColorPickerComponent = _univerjs_design.ColorPicker, DropdownComponent = _univerjs_design.Dropdown } = props;
|
|
1627
1712
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1628
1713
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1629
1714
|
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
@@ -1774,7 +1859,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1774
1859
|
title: item,
|
|
1775
1860
|
"aria-label": item,
|
|
1776
1861
|
"aria-pressed": selected,
|
|
1777
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-
|
|
1862
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-1 univer-shadow-sm univer-transition-all hover:univer-border-gray-400 hover:univer-shadow-md focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-800", _univerjs_design.borderClassName, { "!univer-border-primary-500 univer-ring-2 univer-ring-primary-100": selected }),
|
|
1778
1863
|
onClick: () => handleThemeChange(item),
|
|
1779
1864
|
children: rowBackgrounds.map((background, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1780
1865
|
className: "univer-min-h-0 univer-w-full univer-flex-1",
|
|
@@ -1799,7 +1884,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1799
1884
|
type: "button",
|
|
1800
1885
|
"data-u-comp": "sheet-table-theme-add",
|
|
1801
1886
|
"aria-label": localeService.t("sheets-table-ui.setTheme"),
|
|
1802
|
-
className: "univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border univer-border-dashed univer-border-gray-300 univer-bg-
|
|
1887
|
+
className: "univer-flex univer-h-12 univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-lg univer-border univer-border-dashed univer-border-gray-300 univer-bg-gray-0 univer-p-0 univer-text-gray-500 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-border-gray-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-300",
|
|
1803
1888
|
onClick: handleAddCustomTheme,
|
|
1804
1889
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, { className: "univer-size-4" })
|
|
1805
1890
|
}), customRangeThemes.map((item) => {
|
|
@@ -1819,7 +1904,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1819
1904
|
title: item,
|
|
1820
1905
|
"aria-label": item,
|
|
1821
1906
|
"aria-pressed": selected,
|
|
1822
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-size-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-
|
|
1907
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-size-full univer-cursor-pointer univer-flex-col univer-overflow-hidden univer-rounded-lg univer-bg-gray-0 univer-p-1 univer-shadow-sm univer-transition-all hover:univer-border-gray-400 hover:univer-shadow-md focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-900", _univerjs_design.borderClassName, { "!univer-border-primary-500 univer-ring-2 univer-ring-primary-100": selected }),
|
|
1823
1908
|
onClick: () => handleThemeChange(item),
|
|
1824
1909
|
children: rowBackgrounds.map((background, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1825
1910
|
className: "univer-min-h-0 univer-w-full univer-flex-1",
|
|
@@ -1832,7 +1917,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1832
1917
|
type: "button",
|
|
1833
1918
|
"data-u-comp": "sheet-table-theme-remove",
|
|
1834
1919
|
"aria-label": `${localeService.t("sheets-table-ui.customStyle")} ${item}`,
|
|
1835
|
-
className: (0, _univerjs_design.clsx)("univer-absolute univer-right-[-6px] univer-top-[-6px] univer-z-10 univer-flex univer-size-5 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-gray-200 univer-bg-
|
|
1920
|
+
className: (0, _univerjs_design.clsx)("univer-absolute univer-right-[-6px] univer-top-[-6px] univer-z-10 univer-flex univer-size-5 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-p-0 univer-text-gray-500 univer-shadow-sm univer-transition-all hover:univer-border-red-200 hover:univer-bg-red-50 hover:univer-text-red-600 focus:univer-opacity-100 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 rtl:univer-left-[-6px] rtl:univer-right-auto dark:!univer-border-gray-600 dark:!univer-bg-gray-900", {
|
|
1836
1921
|
"univer-opacity-100": selected,
|
|
1837
1922
|
"univer-opacity-0 group-focus-within:univer-opacity-100 group-hover:univer-opacity-100": !selected
|
|
1838
1923
|
}),
|
|
@@ -1851,7 +1936,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1851
1936
|
className: "univer-flex univer-h-10 univer-min-w-0 univer-gap-2",
|
|
1852
1937
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1853
1938
|
className: (0, _univerjs_design.clsx)("univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-rounded-md univer-px-3 univer-text-sm univer-font-medium rtl:univer-text-right", _univerjs_design.borderClassName, {
|
|
1854
|
-
"univer-text-
|
|
1939
|
+
"univer-text-gray-0": row.isDark,
|
|
1855
1940
|
"univer-text-gray-900": !row.isDark
|
|
1856
1941
|
}),
|
|
1857
1942
|
style: { background: row.background },
|
|
@@ -1859,11 +1944,11 @@ const SheetTableThemePanel = (props) => {
|
|
|
1859
1944
|
className: "univer-truncate",
|
|
1860
1945
|
children: row.label
|
|
1861
1946
|
})
|
|
1862
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1947
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownComponent, {
|
|
1863
1948
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1864
1949
|
dir: direction,
|
|
1865
1950
|
className: "univer-p-2",
|
|
1866
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1951
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorPickerComponent, {
|
|
1867
1952
|
value: new _univerjs_core.ColorKit(row.background).toHexString(),
|
|
1868
1953
|
onChange: row.onChange
|
|
1869
1954
|
})
|
|
@@ -1871,7 +1956,7 @@ const SheetTableThemePanel = (props) => {
|
|
|
1871
1956
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1872
1957
|
type: "button",
|
|
1873
1958
|
"aria-label": `${row.label} ${localeService.t("sheets-table-ui.setTheme")}`,
|
|
1874
|
-
className: (0, _univerjs_design.clsx)("univer-flex univer-h-10 univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-md univer-bg-
|
|
1959
|
+
className: (0, _univerjs_design.clsx)("univer-flex univer-h-10 univer-cursor-pointer univer-items-center univer-gap-2 univer-rounded-md univer-bg-gray-0 univer-px-2 univer-text-gray-600 univer-transition-colors hover:univer-bg-gray-100 focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-200 dark:!univer-bg-gray-900 dark:!univer-text-gray-300", _univerjs_design.borderClassName),
|
|
1875
1960
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1876
1961
|
className: (0, _univerjs_design.clsx)("univer-size-4 univer-rounded-full", _univerjs_design.borderClassName),
|
|
1877
1962
|
style: { background: row.background }
|
|
@@ -1886,7 +1971,17 @@ const SheetTableThemePanel = (props) => {
|
|
|
1886
1971
|
};
|
|
1887
1972
|
|
|
1888
1973
|
//#endregion
|
|
1889
|
-
//#region src/
|
|
1974
|
+
//#region src/views/components/MobileSheetTableThemePanel.tsx
|
|
1975
|
+
function MobileSheetTableThemePanel(props) {
|
|
1976
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableThemePanel, {
|
|
1977
|
+
...props,
|
|
1978
|
+
ColorPickerComponent: _univerjs_design.MobileColorPicker,
|
|
1979
|
+
DropdownComponent: _univerjs_design.MobileDropdown
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
//#endregion
|
|
1984
|
+
//#region src/controllers/mobile/components.controller.ts
|
|
1890
1985
|
/**
|
|
1891
1986
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1892
1987
|
*
|
|
@@ -1902,31 +1997,53 @@ const SheetTableThemePanel = (props) => {
|
|
|
1902
1997
|
* See the License for the specific language governing permissions and
|
|
1903
1998
|
* limitations under the License.
|
|
1904
1999
|
*/
|
|
1905
|
-
let
|
|
1906
|
-
constructor(
|
|
2000
|
+
let MobileComponentsController = class MobileComponentsController extends _univerjs_core.Disposable {
|
|
2001
|
+
constructor(componentManager, iconManager) {
|
|
1907
2002
|
super();
|
|
1908
|
-
this._componentManager = _componentManager;
|
|
1909
|
-
this._iconManager = _iconManager;
|
|
1910
|
-
this._registerComponents();
|
|
1911
|
-
this._registerIcons();
|
|
1912
|
-
}
|
|
1913
|
-
_registerComponents() {
|
|
1914
2003
|
[
|
|
1915
|
-
[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY,
|
|
1916
|
-
[
|
|
1917
|
-
[SHEET_TABLE_RENAME_DIALOG,
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
2004
|
+
[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, MobileSheetTableFilterPanel],
|
|
2005
|
+
[SHEET_TABLE_MOBILE_MENU, MobileSheetTableMenu],
|
|
2006
|
+
[SHEET_TABLE_RENAME_DIALOG, MobileSheetTableRenameDialog],
|
|
2007
|
+
[TABLE_SELECTOR_DIALOG, MobileSheetTableSelector],
|
|
2008
|
+
[SHEET_TABLE_THEME_PANEL, MobileSheetTableThemePanel]
|
|
2009
|
+
].forEach(([key, component]) => {
|
|
2010
|
+
this.disposeWithMe(componentManager.register(key, component));
|
|
1923
2011
|
});
|
|
2012
|
+
this.disposeWithMe(iconManager.register({ TableIcon: _univerjs_icons.TableIcon }));
|
|
1924
2013
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
2014
|
+
};
|
|
2015
|
+
MobileComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], MobileComponentsController);
|
|
2016
|
+
|
|
2017
|
+
//#endregion
|
|
2018
|
+
//#region src/controllers/mobile/sheet-table-component.controller.ts
|
|
2019
|
+
/**
|
|
2020
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2021
|
+
*
|
|
2022
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2023
|
+
* you may not use this file except in compliance with the License.
|
|
2024
|
+
* You may obtain a copy of the License at
|
|
2025
|
+
*
|
|
2026
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2027
|
+
*
|
|
2028
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2029
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2030
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2031
|
+
* See the License for the specific language governing permissions and
|
|
2032
|
+
* limitations under the License.
|
|
2033
|
+
*/
|
|
2034
|
+
var SheetsTableMobileComponentController = class extends SheetsTableComponentController {
|
|
2035
|
+
_openFilterPopup() {
|
|
2036
|
+
if (!this.getCurrentTableFilterInfo()) throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
2037
|
+
this._dialogService.open({
|
|
2038
|
+
id: UNIVER_SHEET_TABLE_FILTER_PANEL_ID,
|
|
2039
|
+
title: { title: "sheets-table-ui.filter.title" },
|
|
2040
|
+
children: { label: SHEETS_TABLE_FILTER_PANEL_OPENED_KEY },
|
|
2041
|
+
onClose: () => {
|
|
2042
|
+
this._contextService.setContextValue(SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, false);
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
1927
2045
|
}
|
|
1928
2046
|
};
|
|
1929
|
-
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
1930
2047
|
|
|
1931
2048
|
//#endregion
|
|
1932
2049
|
//#region src/views/widgets/table-controls-util.ts
|
|
@@ -2176,7 +2293,7 @@ function isSameTopGap(left, right) {
|
|
|
2176
2293
|
return left.size === right.size && left.color === right.color && left.stripeColor === right.stripeColor;
|
|
2177
2294
|
}
|
|
2178
2295
|
let SheetTableControlsRenderController = class SheetTableControlsRenderController extends _univerjs_core.Disposable {
|
|
2179
|
-
constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _dialogService, _sidebarService, _sheetCanvasPopupService) {
|
|
2296
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _commandService, _tableManager, _rangeThemeModel, _workbookPermissionService, _permissionService, _sheetsSelectionsService, _selectionRenderService, _sheetTableThemeUIController, _localeService, _contextService, _dialogService, _sidebarService, _sheetCanvasPopupService) {
|
|
2180
2297
|
super();
|
|
2181
2298
|
this._context = _context;
|
|
2182
2299
|
this._injector = _injector;
|
|
@@ -2190,6 +2307,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2190
2307
|
this._selectionRenderService = _selectionRenderService;
|
|
2191
2308
|
this._sheetTableThemeUIController = _sheetTableThemeUIController;
|
|
2192
2309
|
this._localeService = _localeService;
|
|
2310
|
+
this._contextService = _contextService;
|
|
2193
2311
|
this._dialogService = _dialogService;
|
|
2194
2312
|
this._sidebarService = _sidebarService;
|
|
2195
2313
|
this._sheetCanvasPopupService = _sheetCanvasPopupService;
|
|
@@ -2351,6 +2469,18 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2351
2469
|
this._closeFloatingControls();
|
|
2352
2470
|
this._shape.setOpenedMenuTableId(tableId);
|
|
2353
2471
|
const range = table.getRange();
|
|
2472
|
+
const extraProps = {
|
|
2473
|
+
anchorWidth: anchor.width,
|
|
2474
|
+
tableName: table.getDisplayName(),
|
|
2475
|
+
labels: {
|
|
2476
|
+
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
2477
|
+
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
2478
|
+
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
2479
|
+
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
2480
|
+
},
|
|
2481
|
+
onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
|
|
2482
|
+
onClose: () => this._closeFloatingControls()
|
|
2483
|
+
};
|
|
2354
2484
|
this._menuPopup = this._sheetCanvasPopupService.attachPopupByPosition({
|
|
2355
2485
|
left: anchor.left,
|
|
2356
2486
|
right: anchor.left + anchor.width,
|
|
@@ -2359,18 +2489,7 @@ let SheetTableControlsRenderController = class SheetTableControlsRenderControlle
|
|
|
2359
2489
|
}, {
|
|
2360
2490
|
componentKey: "SHEET_TABLE_MENU",
|
|
2361
2491
|
direction: "bottom-left",
|
|
2362
|
-
extraProps
|
|
2363
|
-
anchorWidth: anchor.width,
|
|
2364
|
-
tableName: table.getDisplayName(),
|
|
2365
|
-
labels: {
|
|
2366
|
-
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
2367
|
-
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
2368
|
-
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
2369
|
-
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
2370
|
-
},
|
|
2371
|
-
onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
|
|
2372
|
-
onClose: () => this._closeFloatingControls()
|
|
2373
|
-
}
|
|
2492
|
+
extraProps
|
|
2374
2493
|
}, {
|
|
2375
2494
|
unitId,
|
|
2376
2495
|
subUnitId,
|
|
@@ -2549,11 +2668,51 @@ SheetTableControlsRenderController = __decorate([
|
|
|
2549
2668
|
__decorateParam(9, _univerjs_sheets_ui.ISheetSelectionRenderService),
|
|
2550
2669
|
__decorateParam(10, (0, _univerjs_core.Inject)(SheetTableThemeUIController)),
|
|
2551
2670
|
__decorateParam(11, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
2552
|
-
__decorateParam(12,
|
|
2553
|
-
__decorateParam(13, _univerjs_ui.
|
|
2554
|
-
__decorateParam(14,
|
|
2671
|
+
__decorateParam(12, _univerjs_core.IContextService),
|
|
2672
|
+
__decorateParam(13, _univerjs_ui.IDialogService),
|
|
2673
|
+
__decorateParam(14, _univerjs_ui.ISidebarService),
|
|
2674
|
+
__decorateParam(15, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetCanvasPopManagerService))
|
|
2555
2675
|
], SheetTableControlsRenderController);
|
|
2556
2676
|
|
|
2677
|
+
//#endregion
|
|
2678
|
+
//#region src/controllers/mobile/sheet-table-controls-render.controller.ts
|
|
2679
|
+
const SHEET_TABLE_MOBILE_MENU_DIALOG_ID = "sheet-table-mobile-menu";
|
|
2680
|
+
var SheetTableControlsMobileRenderController = class extends SheetTableControlsRenderController {
|
|
2681
|
+
_toggleTableMenu(unitId, subUnitId, tableId) {
|
|
2682
|
+
if (this._shape.getOpenedMenuTableId() === tableId) {
|
|
2683
|
+
this._closeFloatingControls();
|
|
2684
|
+
return;
|
|
2685
|
+
}
|
|
2686
|
+
const table = this._tableManager.getTableById(unitId, tableId);
|
|
2687
|
+
const anchor = this._shape.getAnchorRegion(tableId);
|
|
2688
|
+
if (!table || !anchor) return;
|
|
2689
|
+
this._closeFloatingControls();
|
|
2690
|
+
this._shape.setOpenedMenuTableId(tableId);
|
|
2691
|
+
const extraProps = {
|
|
2692
|
+
anchorWidth: anchor.width,
|
|
2693
|
+
tableName: table.getDisplayName(),
|
|
2694
|
+
labels: {
|
|
2695
|
+
rename: this._localeService.t("sheets-table-ui.rename"),
|
|
2696
|
+
"update-range": this._localeService.t("sheets-table-ui.updateRange"),
|
|
2697
|
+
"set-theme": this._localeService.t("sheets-table-ui.setTheme"),
|
|
2698
|
+
delete: this._localeService.t("sheets-table-ui.removeTable")
|
|
2699
|
+
},
|
|
2700
|
+
onSelect: (action) => this._handleTableMenuAction(action, unitId, subUnitId, tableId),
|
|
2701
|
+
onClose: () => this._closeFloatingControls()
|
|
2702
|
+
};
|
|
2703
|
+
this._dialogService.open({
|
|
2704
|
+
id: SHEET_TABLE_MOBILE_MENU_DIALOG_ID,
|
|
2705
|
+
title: { title: table.getDisplayName() },
|
|
2706
|
+
children: { label: {
|
|
2707
|
+
name: SHEET_TABLE_MOBILE_MENU,
|
|
2708
|
+
props: { menu: extraProps }
|
|
2709
|
+
} },
|
|
2710
|
+
onClose: () => this._closeFloatingControls()
|
|
2711
|
+
});
|
|
2712
|
+
this._menuPopup = (0, _univerjs_core.toDisposable)(() => this._dialogService.close(SHEET_TABLE_MOBILE_MENU_DIALOG_ID));
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
|
|
2557
2716
|
//#endregion
|
|
2558
2717
|
//#region src/views/widgets/table-filter-button.shape.ts
|
|
2559
2718
|
const FILTER_ICON_SIZE = 16;
|
|
@@ -2946,8 +3105,8 @@ let SheetTableMenuController = class SheetTableMenuController extends _univerjs_
|
|
|
2946
3105
|
SheetTableMenuController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.IMenuManagerService))], SheetTableMenuController);
|
|
2947
3106
|
|
|
2948
3107
|
//#endregion
|
|
2949
|
-
//#region src/plugin.ts
|
|
2950
|
-
let
|
|
3108
|
+
//#region src/mobile-plugin.ts
|
|
3109
|
+
let UniverSheetsTableMobileUIPlugin = class UniverSheetsTableMobileUIPlugin extends _univerjs_core.Plugin {
|
|
2951
3110
|
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService, _renderManagerService) {
|
|
2952
3111
|
super();
|
|
2953
3112
|
this._config = _config;
|
|
@@ -2961,10 +3120,11 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerj
|
|
|
2961
3120
|
this._initRegisterCommand();
|
|
2962
3121
|
}
|
|
2963
3122
|
onStarting() {
|
|
2964
|
-
this._injector.add([
|
|
2965
|
-
this._injector.get(
|
|
3123
|
+
this._injector.add([MobileComponentsController]);
|
|
3124
|
+
this._injector.get(MobileComponentsController);
|
|
2966
3125
|
(0, _univerjs_core.registerDependencies)(this._injector, [
|
|
2967
|
-
[
|
|
3126
|
+
[SheetsTableMobileComponentController],
|
|
3127
|
+
[SheetsTableComponentController, { useExisting: SheetsTableMobileComponentController }],
|
|
2968
3128
|
[SheetsTableUiService],
|
|
2969
3129
|
[SheetTableMenuController],
|
|
2970
3130
|
[SheetTableThemeUIController],
|
|
@@ -2973,7 +3133,7 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerj
|
|
|
2973
3133
|
}
|
|
2974
3134
|
onReady() {
|
|
2975
3135
|
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
2976
|
-
[
|
|
3136
|
+
[SheetsTableMobileComponentController],
|
|
2977
3137
|
[SheetsTableUiService],
|
|
2978
3138
|
[SheetTableMenuController],
|
|
2979
3139
|
[SheetTableThemeUIController],
|
|
@@ -2985,30 +3145,774 @@ let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerj
|
|
|
2985
3145
|
}
|
|
2986
3146
|
_registerRenderModules() {
|
|
2987
3147
|
const renderDependencies = [];
|
|
2988
|
-
if (this._config.hideAnchor !== true) renderDependencies.push([
|
|
3148
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableControlsMobileRenderController]);
|
|
2989
3149
|
renderDependencies.push([SheetsTableFilterButtonRenderController], [SheetsTableRenderController]);
|
|
2990
|
-
renderDependencies.forEach((
|
|
2991
|
-
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET,
|
|
3150
|
+
renderDependencies.forEach((dependency) => {
|
|
3151
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, dependency));
|
|
2992
3152
|
});
|
|
2993
3153
|
}
|
|
2994
3154
|
_initRegisterCommand() {
|
|
2995
|
-
[OpenTableFilterPanelOperation, OpenTableSelectorOperation].forEach((
|
|
3155
|
+
[OpenTableFilterPanelOperation, OpenTableSelectorOperation].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
|
|
2996
3156
|
}
|
|
2997
3157
|
};
|
|
2998
|
-
_defineProperty(
|
|
2999
|
-
_defineProperty(
|
|
3000
|
-
_defineProperty(
|
|
3001
|
-
_defineProperty(
|
|
3002
|
-
|
|
3003
|
-
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_table.UniverSheetsTablePlugin, _univerjs_sheets_ui.
|
|
3158
|
+
_defineProperty(UniverSheetsTableMobileUIPlugin, "pluginName", PLUGIN_NAME);
|
|
3159
|
+
_defineProperty(UniverSheetsTableMobileUIPlugin, "packageName", name);
|
|
3160
|
+
_defineProperty(UniverSheetsTableMobileUIPlugin, "version", version);
|
|
3161
|
+
_defineProperty(UniverSheetsTableMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3162
|
+
UniverSheetsTableMobileUIPlugin = __decorate([
|
|
3163
|
+
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_table.UniverSheetsTablePlugin, _univerjs_sheets_ui.UniverSheetsMobileUIPlugin, _univerjs_ui.UniverMobileUIPlugin),
|
|
3004
3164
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3005
3165
|
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
|
|
3006
3166
|
__decorateParam(3, _univerjs_core.IConfigService),
|
|
3007
3167
|
__decorateParam(4, _univerjs_engine_render.IRenderManagerService)
|
|
3008
|
-
],
|
|
3168
|
+
], UniverSheetsTableMobileUIPlugin);
|
|
3009
3169
|
|
|
3010
3170
|
//#endregion
|
|
3011
|
-
|
|
3171
|
+
//#region src/views/components/SheetTableColorFilterPanel.tsx
|
|
3172
|
+
function ColorOption(props) {
|
|
3173
|
+
const { item, label, textColor = false, onClick } = props;
|
|
3174
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3175
|
+
type: "button",
|
|
3176
|
+
"aria-label": item.color ?? label,
|
|
3177
|
+
"aria-pressed": item.checked,
|
|
3178
|
+
className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-relative univer-flex univer-size-6 univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 hover:univer-ring-2 hover:univer-ring-offset-2 dark:!univer-border-gray-600 dark:!univer-bg-gray-800"),
|
|
3179
|
+
style: !textColor && item.color ? { backgroundColor: item.color } : void 0,
|
|
3180
|
+
onClick,
|
|
3181
|
+
children: [
|
|
3182
|
+
!item.color && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BanIcon, { className: "univer-size-5" }),
|
|
3183
|
+
textColor && item.color && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AIcon, {
|
|
3184
|
+
className: "univer-size-5",
|
|
3185
|
+
style: { color: item.color }
|
|
3186
|
+
}),
|
|
3187
|
+
item.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SuccessIcon, { className: "univer-absolute -univer-bottom-1 -univer-right-1 univer-size-3 univer-rounded-full univer-bg-gray-0 univer-text-green-600" })
|
|
3188
|
+
]
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
function SheetTableColorFilterPanel(props) {
|
|
3192
|
+
const { colors, onChange } = props;
|
|
3193
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3194
|
+
const fillLabel = localeService.t("sheets-table-ui.filter.filter-by-cell-fill-color");
|
|
3195
|
+
const textLabel = localeService.t("sheets-table-ui.filter.filter-by-cell-text-color");
|
|
3196
|
+
const hasMultipleColors = colors.cellFillColors.length > 1 || colors.cellTextColors.length > 1;
|
|
3197
|
+
function toggleColor(item, fillColor) {
|
|
3198
|
+
const key = fillColor ? "cellFillColors" : "cellTextColors";
|
|
3199
|
+
const otherKey = fillColor ? "cellTextColors" : "cellFillColors";
|
|
3200
|
+
onChange({
|
|
3201
|
+
...colors,
|
|
3202
|
+
[key]: colors[key].map((color) => color.color === item.color ? {
|
|
3203
|
+
...color,
|
|
3204
|
+
checked: !color.checked
|
|
3205
|
+
} : color),
|
|
3206
|
+
[otherKey]: colors[otherKey].map((color) => ({
|
|
3207
|
+
...color,
|
|
3208
|
+
checked: false
|
|
3209
|
+
}))
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3213
|
+
className: "univer-grid univer-h-full univer-gap-4 univer-overflow-auto univer-rounded-md univer-p-2",
|
|
3214
|
+
children: [
|
|
3215
|
+
colors.cellFillColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
3216
|
+
className: "univer-m-0 univer-mb-2 univer-text-sm univer-font-normal",
|
|
3217
|
+
children: fillLabel
|
|
3218
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3219
|
+
className: "univer-grid univer-grid-cols-8 univer-gap-2",
|
|
3220
|
+
children: colors.cellFillColors.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorOption, {
|
|
3221
|
+
item,
|
|
3222
|
+
label: fillLabel,
|
|
3223
|
+
onClick: () => toggleColor(item, true)
|
|
3224
|
+
}, item.color ?? "none"))
|
|
3225
|
+
})] }),
|
|
3226
|
+
colors.cellTextColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
3227
|
+
className: "univer-m-0 univer-mb-2 univer-text-sm univer-font-normal",
|
|
3228
|
+
children: textLabel
|
|
3229
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3230
|
+
className: "univer-grid univer-grid-cols-8 univer-gap-2",
|
|
3231
|
+
children: colors.cellTextColors.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorOption, {
|
|
3232
|
+
item,
|
|
3233
|
+
label: textLabel,
|
|
3234
|
+
textColor: true,
|
|
3235
|
+
onClick: () => toggleColor(item, false)
|
|
3236
|
+
}, item.color ?? "none"))
|
|
3237
|
+
})] }),
|
|
3238
|
+
!hasMultipleColors && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3239
|
+
className: "univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm",
|
|
3240
|
+
children: localeService.t("sheets-table-ui.filter.filter-by-color-none")
|
|
3241
|
+
})
|
|
3242
|
+
]
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
//#endregion
|
|
3247
|
+
//#region src/views/components/SheetTableConditionPanel.tsx
|
|
3248
|
+
const SheetTableConditionPanel = (props) => {
|
|
3249
|
+
var _conditionInfo$info$d, _conditionInfo$info$d2, _conditionInfo$info$n, _conditionInfo$info$n3;
|
|
3250
|
+
const { conditionInfo, onChange } = props;
|
|
3251
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3252
|
+
const [conditionVisible, setConditionVisible] = (0, react.useState)(false);
|
|
3253
|
+
const injector = (0, _univerjs_ui.useDependency)(_univerjs_core.Injector);
|
|
3254
|
+
const cascaderOptions = getCascaderListOptions(injector);
|
|
3255
|
+
const handleConditionInfo = (info, type, compare) => {
|
|
3256
|
+
onChange({
|
|
3257
|
+
type: type ?? conditionInfo.type,
|
|
3258
|
+
compare: compare ?? conditionInfo.compare,
|
|
3259
|
+
info
|
|
3260
|
+
});
|
|
3261
|
+
};
|
|
3262
|
+
const handleChange = (value) => {
|
|
3263
|
+
const type = value[0];
|
|
3264
|
+
const compare = value[1];
|
|
3265
|
+
if (compare) setConditionVisible(false);
|
|
3266
|
+
const info = {};
|
|
3267
|
+
if (type === _univerjs_sheets_table.TableConditionTypeEnum.Date) if (compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Quarter) info.dateSelect = _univerjs_sheets_table.TableDateCompareTypeEnum.Q1;
|
|
3268
|
+
else if (compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Month) info.dateSelect = _univerjs_sheets_table.TableDateCompareTypeEnum.M1;
|
|
3269
|
+
else if (datePickerSet.has(compare)) info.date = /* @__PURE__ */ new Date();
|
|
3270
|
+
else info.dateRange = [/* @__PURE__ */ new Date(), /* @__PURE__ */ new Date()];
|
|
3271
|
+
else if (type === _univerjs_sheets_table.TableConditionTypeEnum.Number) info.number = 0;
|
|
3272
|
+
else if (type === _univerjs_sheets_table.TableConditionTypeEnum.String) info.string = "";
|
|
3273
|
+
handleConditionInfo(info, value[0], value[1] ?? _univerjs_sheets_table.TableStringCompareTypeEnum.Equal);
|
|
3274
|
+
};
|
|
3275
|
+
const subComponentType = getSubComponentType(conditionInfo.type, conditionInfo.compare);
|
|
3276
|
+
let selectType = "";
|
|
3277
|
+
if (conditionInfo.compare) selectType = `${localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`)} - ${localeService.t(`sheets-table-ui.${conditionInfo.type}.compare.${conditionInfo.compare}`)}`;
|
|
3278
|
+
else selectType = localeService.t(`sheets-table-ui.condition.${conditionInfo.type}`);
|
|
3279
|
+
const conditionDateOptions = getConditionDateSelect(injector, conditionInfo.compare);
|
|
3280
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
3281
|
+
align: "start",
|
|
3282
|
+
open: conditionVisible,
|
|
3283
|
+
onOpenChange: setConditionVisible,
|
|
3284
|
+
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.CascaderList, {
|
|
3285
|
+
value: [conditionInfo.type, conditionInfo.compare],
|
|
3286
|
+
options: cascaderOptions,
|
|
3287
|
+
onChange: handleChange,
|
|
3288
|
+
contentClassName: "univer-flex-1",
|
|
3289
|
+
wrapperClassName: "!univer-h-[150px]"
|
|
3290
|
+
}),
|
|
3291
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3292
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-gray-0 univer-px-2 univer-text-sm univer-transition-colors univer-duration-200 hover:univer-border-primary-600 focus:univer-border-primary-600 focus:univer-outline-none focus:univer-ring-2 dark:!univer-bg-gray-700 dark:!univer-text-gray-0", _univerjs_design.borderClassName),
|
|
3293
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: selectType }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreDownIcon, {})]
|
|
3294
|
+
})
|
|
3295
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3296
|
+
className: "univer-mt-3 univer-w-full",
|
|
3297
|
+
children: [
|
|
3298
|
+
subComponentType === "Input" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: conditionInfo.type === _univerjs_sheets_table.TableConditionTypeEnum.String ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
3299
|
+
className: "univer-w-full",
|
|
3300
|
+
placeholder: localeService.t("sheets-table-ui.filter.input-values-placeholder"),
|
|
3301
|
+
value: conditionInfo.info.string,
|
|
3302
|
+
onChange: (v) => handleConditionInfo({ string: v })
|
|
3303
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
3304
|
+
className: "univer-h-7 univer-w-full",
|
|
3305
|
+
value: conditionInfo.info.number,
|
|
3306
|
+
controls: false,
|
|
3307
|
+
onChange: (v) => {
|
|
3308
|
+
if (v !== null) handleConditionInfo({ number: v });
|
|
3309
|
+
}
|
|
3310
|
+
}) }),
|
|
3311
|
+
!!(subComponentType === "DatePicker") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3312
|
+
id: "univer-table-date-picker-wrapper",
|
|
3313
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DatePicker, {
|
|
3314
|
+
className: "univer-w-full",
|
|
3315
|
+
value: conditionInfo.info.date ?? /* @__PURE__ */ new Date(),
|
|
3316
|
+
onValueChange: (v) => handleConditionInfo({ date: v })
|
|
3317
|
+
})
|
|
3318
|
+
}),
|
|
3319
|
+
!!(subComponentType === "DateRange") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3320
|
+
id: "univer-table-date-range-wrapper",
|
|
3321
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DateRangePicker, {
|
|
3322
|
+
className: "univer-w-full",
|
|
3323
|
+
value: [((_conditionInfo$info$d = conditionInfo.info.dateRange) === null || _conditionInfo$info$d === void 0 ? void 0 : _conditionInfo$info$d[0]) ?? /* @__PURE__ */ new Date(), ((_conditionInfo$info$d2 = conditionInfo.info.dateRange) === null || _conditionInfo$info$d2 === void 0 ? void 0 : _conditionInfo$info$d2[1]) ?? /* @__PURE__ */ new Date()],
|
|
3324
|
+
onValueChange: (v) => {
|
|
3325
|
+
if (v) handleConditionInfo({ dateRange: v });
|
|
3326
|
+
else handleConditionInfo({});
|
|
3327
|
+
}
|
|
3328
|
+
})
|
|
3329
|
+
}),
|
|
3330
|
+
subComponentType === "Inputs" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3331
|
+
className: "univer-flex univer-items-center univer-gap-2",
|
|
3332
|
+
children: [
|
|
3333
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
3334
|
+
className: "univer-w-full",
|
|
3335
|
+
value: (_conditionInfo$info$n = conditionInfo.info.numberRange) === null || _conditionInfo$info$n === void 0 ? void 0 : _conditionInfo$info$n[0],
|
|
3336
|
+
onChange: (v) => {
|
|
3337
|
+
if (v !== null) {
|
|
3338
|
+
var _conditionInfo$info$n2;
|
|
3339
|
+
handleConditionInfo({ numberRange: [v, (_conditionInfo$info$n2 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n2 === void 0 ? void 0 : _conditionInfo$info$n2[1]] });
|
|
3340
|
+
}
|
|
3341
|
+
},
|
|
3342
|
+
controls: false
|
|
3343
|
+
}),
|
|
3344
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: " - " }),
|
|
3345
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.InputNumber, {
|
|
3346
|
+
className: "univer-w-full",
|
|
3347
|
+
value: (_conditionInfo$info$n3 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n3 === void 0 ? void 0 : _conditionInfo$info$n3[1],
|
|
3348
|
+
controls: false,
|
|
3349
|
+
onChange: (v) => {
|
|
3350
|
+
if (v !== null) {
|
|
3351
|
+
var _conditionInfo$info$n4;
|
|
3352
|
+
handleConditionInfo({ numberRange: [(_conditionInfo$info$n4 = conditionInfo.info.numberRange) === null || _conditionInfo$info$n4 === void 0 ? void 0 : _conditionInfo$info$n4[0], v] });
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
})
|
|
3356
|
+
]
|
|
3357
|
+
}),
|
|
3358
|
+
!!(subComponentType === "Select") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
3359
|
+
className: "univer-w-full",
|
|
3360
|
+
value: conditionInfo.info.dateSelect ?? conditionDateOptions[0].value,
|
|
3361
|
+
options: conditionDateOptions,
|
|
3362
|
+
onChange: (v) => handleConditionInfo({ dateSelect: v })
|
|
3363
|
+
})
|
|
3364
|
+
]
|
|
3365
|
+
})] });
|
|
3366
|
+
};
|
|
3367
|
+
|
|
3368
|
+
//#endregion
|
|
3369
|
+
//#region src/views/components/SheetTableItemsFilterPanel.tsx
|
|
3370
|
+
const getCheckedItemCount = (map, checkedItemSet) => {
|
|
3371
|
+
let count = 0;
|
|
3372
|
+
checkedItemSet.forEach((item) => {
|
|
3373
|
+
count += map.get(item) ?? 0;
|
|
3374
|
+
});
|
|
3375
|
+
return count;
|
|
3376
|
+
};
|
|
3377
|
+
function SheetTableItemsFilterPanel(props) {
|
|
3378
|
+
const { unitId, tableId, subUnitId, columnIndex, checkedItemSet, setCheckedItemSet, tableFilter } = props;
|
|
3379
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3380
|
+
const { data: items, itemsCountMap, allItemsCount } = (0, _univerjs_ui.useDependency)(SheetsTableUiService).getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
3381
|
+
const [allChecked, setAllChecked] = (0, react.useState)(tableFilter === void 0 ? true : checkedItemSet.size === itemsCountMap.size);
|
|
3382
|
+
const [checkedCount, setCheckedCount] = (0, react.useState)(() => allChecked ? allItemsCount : getCheckedItemCount(itemsCountMap, checkedItemSet));
|
|
3383
|
+
const indeterminate = !allChecked && checkedItemSet.size > 0;
|
|
3384
|
+
const [searchText, setSearchText] = (0, react.useState)("");
|
|
3385
|
+
const displayItems = (0, react.useMemo)(() => {
|
|
3386
|
+
return searchText ? items.filter((item) => {
|
|
3387
|
+
return String(item.title).toLowerCase().includes(searchText.toLowerCase());
|
|
3388
|
+
}) : items;
|
|
3389
|
+
}, [searchText, items]);
|
|
3390
|
+
const onCheckAllToggled = (0, react.useCallback)(() => {
|
|
3391
|
+
if (allChecked) {
|
|
3392
|
+
checkedItemSet.clear();
|
|
3393
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
3394
|
+
setAllChecked(false);
|
|
3395
|
+
} else {
|
|
3396
|
+
displayItems.forEach((item) => {
|
|
3397
|
+
checkedItemSet.add(item.title);
|
|
3398
|
+
});
|
|
3399
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
3400
|
+
setAllChecked(true);
|
|
3401
|
+
}
|
|
3402
|
+
}, [allChecked]);
|
|
3403
|
+
const onSearchValueChange = (0, react.useCallback)((str) => {
|
|
3404
|
+
if (str === "") {
|
|
3405
|
+
setAllChecked(true);
|
|
3406
|
+
items.forEach((item) => {
|
|
3407
|
+
checkedItemSet.add(item.title);
|
|
3408
|
+
});
|
|
3409
|
+
setCheckedCount(allItemsCount);
|
|
3410
|
+
} else {
|
|
3411
|
+
checkedItemSet.clear();
|
|
3412
|
+
setAllChecked(false);
|
|
3413
|
+
setCheckedCount(0);
|
|
3414
|
+
}
|
|
3415
|
+
setSearchText(str);
|
|
3416
|
+
}, []);
|
|
3417
|
+
const onCheckItemToggled = (key) => {
|
|
3418
|
+
if (allChecked) {
|
|
3419
|
+
setAllChecked(false);
|
|
3420
|
+
const newSet = /* @__PURE__ */ new Set();
|
|
3421
|
+
for (const { title } of items) if (key !== title) newSet.add(title);
|
|
3422
|
+
setCheckedCount(allItemsCount - itemsCountMap.get(key));
|
|
3423
|
+
setCheckedItemSet(newSet);
|
|
3424
|
+
} else {
|
|
3425
|
+
if (checkedItemSet.has(key)) {
|
|
3426
|
+
checkedItemSet.delete(key);
|
|
3427
|
+
setCheckedCount(checkedCount - itemsCountMap.get(key));
|
|
3428
|
+
} else {
|
|
3429
|
+
checkedItemSet.add(key);
|
|
3430
|
+
setCheckedCount(checkedCount + itemsCountMap.get(key));
|
|
3431
|
+
}
|
|
3432
|
+
setCheckedItemSet(new Set(checkedItemSet));
|
|
3433
|
+
}
|
|
3434
|
+
};
|
|
3435
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3436
|
+
className: "univer-flex univer-h-full univer-flex-col",
|
|
3437
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
3438
|
+
autoFocus: true,
|
|
3439
|
+
value: searchText,
|
|
3440
|
+
placeholder: localeService.t("sheets-table-ui.filter.search-placeholder"),
|
|
3441
|
+
onChange: onSearchValueChange
|
|
3442
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3443
|
+
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-box-border univer-flex univer-h-[180px] univer-max-h-[180px] univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-py-1.5 univer-pl-2", _univerjs_design.borderClassName),
|
|
3444
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3445
|
+
className: (0, _univerjs_design.clsx)("univer-h-40 univer-min-w-0 univer-overflow-y-auto univer-py-1 univer-pl-2", _univerjs_design.scrollbarClassName),
|
|
3446
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3447
|
+
className: "univer-h-full",
|
|
3448
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3449
|
+
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
3450
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
3451
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
3452
|
+
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
3453
|
+
indeterminate,
|
|
3454
|
+
disabled: items.length === 0,
|
|
3455
|
+
checked: allChecked,
|
|
3456
|
+
onChange: onCheckAllToggled,
|
|
3457
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3458
|
+
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
3459
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3460
|
+
className: "univer-flex-1 univer-truncate",
|
|
3461
|
+
children: `${localeService.t("sheets-table-ui.filter.select-all")}`
|
|
3462
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3463
|
+
className: "univer-ml univer-text-gray-400",
|
|
3464
|
+
children: `(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`
|
|
3465
|
+
})]
|
|
3466
|
+
})
|
|
3467
|
+
})
|
|
3468
|
+
}), displayItems.map((item) => {
|
|
3469
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3470
|
+
className: "univer-flex univer-items-center univer-px-2 univer-py-1",
|
|
3471
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
3472
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
3473
|
+
contentClassName: "univer-flex-1 univer-min-w-0",
|
|
3474
|
+
checked: allChecked || checkedItemSet.has(item.title),
|
|
3475
|
+
onChange: () => {
|
|
3476
|
+
onCheckItemToggled(item.title);
|
|
3477
|
+
},
|
|
3478
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3479
|
+
className: "univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm",
|
|
3480
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3481
|
+
className: "univer-flex-1 univer-truncate",
|
|
3482
|
+
children: item.title
|
|
3483
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3484
|
+
className: "univer-ml-1 univer-inline-flex univer-h-full univer-items-center univer-text-gray-400",
|
|
3485
|
+
children: `(${itemsCountMap.get(item.title) || 0})`
|
|
3486
|
+
})]
|
|
3487
|
+
})
|
|
3488
|
+
})
|
|
3489
|
+
}, item.key);
|
|
3490
|
+
})]
|
|
3491
|
+
})
|
|
3492
|
+
})
|
|
3493
|
+
})]
|
|
3494
|
+
});
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
//#endregion
|
|
3498
|
+
//#region src/views/components/SheetTableFilterPanel.tsx
|
|
3499
|
+
const FILTER_BY_OPTIONS = [
|
|
3500
|
+
{
|
|
3501
|
+
label: "sheets-table-ui.filter.by-values",
|
|
3502
|
+
value: "items"
|
|
3503
|
+
},
|
|
3504
|
+
{
|
|
3505
|
+
label: "sheets-table-ui.filter.by-colors",
|
|
3506
|
+
value: "color"
|
|
3507
|
+
},
|
|
3508
|
+
{
|
|
3509
|
+
label: "sheets-table-ui.filter.by-conditions",
|
|
3510
|
+
value: "condition"
|
|
3511
|
+
}
|
|
3512
|
+
];
|
|
3513
|
+
function SheetTableFilterPanel() {
|
|
3514
|
+
var _permissionService$ge;
|
|
3515
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
3516
|
+
const filterByItems = FILTER_BY_OPTIONS.map((option) => ({
|
|
3517
|
+
...option,
|
|
3518
|
+
label: localeService.t(option.label)
|
|
3519
|
+
}));
|
|
3520
|
+
const tableUiService = (0, _univerjs_ui.useDependency)(SheetsTableUiService);
|
|
3521
|
+
const tableManager = (0, _univerjs_ui.useDependency)(_univerjs_sheets_table.TableManager);
|
|
3522
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
3523
|
+
const permissionService = (0, _univerjs_ui.useDependency)(_univerjs_core.IPermissionService);
|
|
3524
|
+
const undoRedoService = (0, _univerjs_ui.useDependency)(_univerjs_core.IUndoRedoService);
|
|
3525
|
+
const sheetsTableComponentController = (0, _univerjs_ui.useDependency)(SheetsTableComponentController);
|
|
3526
|
+
const tableFilterPanelInfo = sheetsTableComponentController.getCurrentTableFilterInfo();
|
|
3527
|
+
const panelProps = tableUiService.getTableFilterPanelInitProps(tableFilterPanelInfo.unitId, tableFilterPanelInfo.subUnitId, tableFilterPanelInfo.tableId, tableFilterPanelInfo.column);
|
|
3528
|
+
const { unitId, subUnitId, tableId, tableFilter, currentFilterBy, columnIndex } = panelProps;
|
|
3529
|
+
const { data } = tableUiService.getTableFilterItems(unitId, subUnitId, tableId, columnIndex);
|
|
3530
|
+
const checkedItems = tableUiService.getTableFilterCheckedItems(unitId, tableId, columnIndex);
|
|
3531
|
+
const [checkedItemSet, setCheckedItemSet] = (0, react.useState)(() => new Set((0, _univerjs_sheets_table.isManualTableFilter)(tableFilter) ? checkedItems : data.map((item) => item.title)));
|
|
3532
|
+
const [filterBy, setFilterBy] = (0, react.useState)(currentFilterBy || "items");
|
|
3533
|
+
const [conditionInfo, setConditionInfo] = (0, react.useState)(() => {
|
|
3534
|
+
const tableFilter = panelProps.tableFilter;
|
|
3535
|
+
return getInitConditionInfo(tableFilter);
|
|
3536
|
+
});
|
|
3537
|
+
const [colors, setColors] = (0, react.useState)(() => tableUiService.getTableFilterColors(unitId, subUnitId, tableId, columnIndex));
|
|
3538
|
+
const table = tableManager.getTable(unitId, tableId);
|
|
3539
|
+
if (!table) return null;
|
|
3540
|
+
const tableRange = table.getRange();
|
|
3541
|
+
const absoluteColumn = tableFilterPanelInfo.column;
|
|
3542
|
+
const canDeleteColumn = tableRange.endColumn > tableRange.startColumn;
|
|
3543
|
+
const closeDialog = () => {
|
|
3544
|
+
sheetsTableComponentController.closeFilterPanel();
|
|
3545
|
+
};
|
|
3546
|
+
const onCancel = () => {
|
|
3547
|
+
closeDialog();
|
|
3548
|
+
};
|
|
3549
|
+
const applySort = async (asc) => {
|
|
3550
|
+
const range = table.getTableFilterRange();
|
|
3551
|
+
const undoRedoGroup = undoRedoService.beginUndoRedoGroup(unitId, (0, _univerjs_core.generateRandomId)(), "append");
|
|
3552
|
+
try {
|
|
3553
|
+
if (!await commandService.executeCommand(_univerjs_sheets_sort.SortRangeCommand.id, {
|
|
3554
|
+
unitId,
|
|
3555
|
+
subUnitId,
|
|
3556
|
+
range,
|
|
3557
|
+
orderRules: [{
|
|
3558
|
+
colIndex: columnIndex + range.startColumn,
|
|
3559
|
+
type: asc ? _univerjs_sheets_sort.SortType.ASC : _univerjs_sheets_sort.SortType.DESC
|
|
3560
|
+
}],
|
|
3561
|
+
hasTitle: false
|
|
3562
|
+
})) return;
|
|
3563
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SetSheetTableSortStateCommand.id, {
|
|
3564
|
+
unitId,
|
|
3565
|
+
tableId,
|
|
3566
|
+
sortInfo: {
|
|
3567
|
+
columnIndex,
|
|
3568
|
+
sortState: asc ? _univerjs_sheets_table.SheetsTableSortStateEnum.Asc : _univerjs_sheets_table.SheetsTableSortStateEnum.Desc
|
|
3569
|
+
}
|
|
3570
|
+
})) closeDialog();
|
|
3571
|
+
} finally {
|
|
3572
|
+
undoRedoGroup.dispose();
|
|
3573
|
+
}
|
|
3574
|
+
};
|
|
3575
|
+
const insertColumn = async (side) => {
|
|
3576
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SheetTableInsertColumnAtCommand.id, {
|
|
3577
|
+
unitId,
|
|
3578
|
+
subUnitId,
|
|
3579
|
+
tableId,
|
|
3580
|
+
index: side === "left" ? absoluteColumn : absoluteColumn + 1,
|
|
3581
|
+
count: 1
|
|
3582
|
+
})) closeDialog();
|
|
3583
|
+
};
|
|
3584
|
+
const deleteColumn = async () => {
|
|
3585
|
+
if (!canDeleteColumn) return;
|
|
3586
|
+
if (await commandService.executeCommand(_univerjs_sheets_table.SheetTableRemoveColumnAtCommand.id, {
|
|
3587
|
+
unitId,
|
|
3588
|
+
subUnitId,
|
|
3589
|
+
tableId,
|
|
3590
|
+
index: absoluteColumn,
|
|
3591
|
+
count: 1
|
|
3592
|
+
})) closeDialog();
|
|
3593
|
+
};
|
|
3594
|
+
const onApply = async () => {
|
|
3595
|
+
let filter;
|
|
3596
|
+
if (filterBy === "items") {
|
|
3597
|
+
const filteredItems = [];
|
|
3598
|
+
const emptyLabel = localeService.t("sheets-table-ui.condition.empty");
|
|
3599
|
+
for (const itemInfo of data) if (checkedItemSet.has(itemInfo.title)) filteredItems.push(itemInfo.title === emptyLabel ? _univerjs_sheets_table.TABLE_FILTER_EMPTY_VALUE : itemInfo.title);
|
|
3600
|
+
const originFilter = table.getTableFilterColumn(columnIndex);
|
|
3601
|
+
if ((0, _univerjs_sheets_table.isManualTableFilter)(originFilter)) {
|
|
3602
|
+
if (originFilter.values.join(",") === filteredItems.join(",")) {
|
|
3603
|
+
closeDialog();
|
|
3604
|
+
return;
|
|
3605
|
+
}
|
|
3606
|
+
} else if (filteredItems.length === data.length && !originFilter) {
|
|
3607
|
+
closeDialog();
|
|
3608
|
+
return;
|
|
3609
|
+
}
|
|
3610
|
+
filter = filteredItems.length === data.length ? void 0 : {
|
|
3611
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.manual,
|
|
3612
|
+
values: filteredItems
|
|
3613
|
+
};
|
|
3614
|
+
} else if (filterBy === "color") {
|
|
3615
|
+
const cellFillColors = colors.cellFillColors.filter((item) => item.checked).map((item) => item.color);
|
|
3616
|
+
const cellTextColors = colors.cellTextColors.filter((item) => item.checked).map((item) => item.color);
|
|
3617
|
+
if (cellFillColors.length) filter = {
|
|
3618
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.color,
|
|
3619
|
+
cellFillColors
|
|
3620
|
+
};
|
|
3621
|
+
else if (cellTextColors.length) filter = {
|
|
3622
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.color,
|
|
3623
|
+
cellTextColors
|
|
3624
|
+
};
|
|
3625
|
+
} else {
|
|
3626
|
+
let filterInfo;
|
|
3627
|
+
if (conditionInfo.compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Quarter || conditionInfo.compare === _univerjs_sheets_table.TableDateCompareTypeEnum.Month) filterInfo = {
|
|
3628
|
+
conditionType: conditionInfo.type,
|
|
3629
|
+
compareType: Object.values(conditionInfo.info)[0]
|
|
3630
|
+
};
|
|
3631
|
+
else filterInfo = {
|
|
3632
|
+
conditionType: conditionInfo.type,
|
|
3633
|
+
compareType: conditionInfo.compare,
|
|
3634
|
+
expectedValue: Object.values(conditionInfo.info)[0]
|
|
3635
|
+
};
|
|
3636
|
+
filter = {
|
|
3637
|
+
filterType: _univerjs_sheets_table.TableColumnFilterTypeEnum.condition,
|
|
3638
|
+
filterInfo
|
|
3639
|
+
};
|
|
3640
|
+
}
|
|
3641
|
+
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, filter)) closeDialog();
|
|
3642
|
+
};
|
|
3643
|
+
const onClearFilter = async () => {
|
|
3644
|
+
if (await tableUiService.setTableFilter(unitId, tableId, columnIndex, void 0)) closeDialog();
|
|
3645
|
+
};
|
|
3646
|
+
const workbookEditableId = new _univerjs_sheets.WorkbookEditablePermission(unitId).id;
|
|
3647
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3648
|
+
className: "univer-box-border univer-flex univer-w-[400px] univer-flex-col univer-rounded-[10px] univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
3649
|
+
children: [
|
|
3650
|
+
((_permissionService$ge = permissionService.getPermissionPoint(workbookEditableId)) === null || _permissionService$ge === void 0 ? void 0 : _permissionService$ge.value) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3651
|
+
className: "-univer-mx-4 -univer-mt-2 univer-mb-3 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-py-1",
|
|
3652
|
+
children: [
|
|
3653
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3654
|
+
type: "button",
|
|
3655
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
|
|
3656
|
+
onClick: () => insertColumn("left").catch(() => void 0),
|
|
3657
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.LeftInsertColumnDoubleIcon, {
|
|
3658
|
+
className: "univer-size-5",
|
|
3659
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
3660
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.insert-left") })]
|
|
3661
|
+
}),
|
|
3662
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3663
|
+
type: "button",
|
|
3664
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
|
|
3665
|
+
onClick: () => insertColumn("right").catch(() => void 0),
|
|
3666
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.RightInsertColumnDoubleIcon, {
|
|
3667
|
+
className: "univer-size-5",
|
|
3668
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
3669
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.insert-right") })]
|
|
3670
|
+
}),
|
|
3671
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3672
|
+
type: "button",
|
|
3673
|
+
className: "univer-box-border univer-flex univer-h-10 univer-w-full univer-cursor-pointer univer-items-center univer-gap-3 univer-border-none univer-bg-transparent univer-px-4 univer-text-left univer-text-sm univer-text-gray-900 hover:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-text-gray-400 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-600",
|
|
3674
|
+
disabled: !canDeleteColumn,
|
|
3675
|
+
onClick: () => deleteColumn().catch(() => void 0),
|
|
3676
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DeleteColumnDoubleIcon, {
|
|
3677
|
+
className: "univer-size-5",
|
|
3678
|
+
extend: { colorChannel1: "var(--univer-primary-600)" }
|
|
3679
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-table-ui.columnMenu.delete") })]
|
|
3680
|
+
})
|
|
3681
|
+
]
|
|
3682
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3683
|
+
className: "univer-mb-3 univer-flex",
|
|
3684
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.ButtonGroup, {
|
|
3685
|
+
className: "univer-mb-3 !univer-flex univer-w-full",
|
|
3686
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
3687
|
+
className: "univer-w-1/2",
|
|
3688
|
+
onClick: () => applySort(true).catch(() => void 0),
|
|
3689
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AscendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-asc")]
|
|
3690
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
3691
|
+
className: "univer-w-1/2",
|
|
3692
|
+
onClick: () => applySort(false).catch(() => void 0),
|
|
3693
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.DescendingIcon, { className: "univer-mr-1" }), localeService.t("sheets-table-ui.sort.sort-desc")]
|
|
3694
|
+
})]
|
|
3695
|
+
})
|
|
3696
|
+
})] }),
|
|
3697
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3698
|
+
className: "univer-w-full",
|
|
3699
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
|
|
3700
|
+
value: filterBy,
|
|
3701
|
+
items: filterByItems,
|
|
3702
|
+
onChange: (value) => setFilterBy(value)
|
|
3703
|
+
})
|
|
3704
|
+
}),
|
|
3705
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3706
|
+
className: "univer-z-10 univer-h-60",
|
|
3707
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3708
|
+
className: "univer-mt-3 univer-size-full",
|
|
3709
|
+
children: [
|
|
3710
|
+
filterBy === "items" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableItemsFilterPanel, {
|
|
3711
|
+
tableFilter,
|
|
3712
|
+
unitId,
|
|
3713
|
+
subUnitId,
|
|
3714
|
+
tableId,
|
|
3715
|
+
columnIndex,
|
|
3716
|
+
checkedItemSet,
|
|
3717
|
+
setCheckedItemSet
|
|
3718
|
+
}),
|
|
3719
|
+
filterBy === "color" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableColorFilterPanel, {
|
|
3720
|
+
colors,
|
|
3721
|
+
onChange: setColors
|
|
3722
|
+
}),
|
|
3723
|
+
filterBy === "condition" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SheetTableConditionPanel, {
|
|
3724
|
+
tableFilter,
|
|
3725
|
+
unitId,
|
|
3726
|
+
subUnitId,
|
|
3727
|
+
tableId,
|
|
3728
|
+
columnIndex,
|
|
3729
|
+
conditionInfo,
|
|
3730
|
+
onChange: setConditionInfo
|
|
3731
|
+
})
|
|
3732
|
+
]
|
|
3733
|
+
})
|
|
3734
|
+
}),
|
|
3735
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.ActionRow, {
|
|
3736
|
+
className: "univer-flex-wrap-nowrap univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-justify-between univer-gap-6 univer-overflow-hidden",
|
|
3737
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
3738
|
+
disabled: tableFilter === void 0,
|
|
3739
|
+
onClick: () => onClearFilter().catch(() => void 0),
|
|
3740
|
+
children: localeService.t("sheets-table-ui.filter.clear-filter")
|
|
3741
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.ActionRow, {
|
|
3742
|
+
className: "univer-flex univer-flex-1 univer-gap-x-2",
|
|
3743
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
3744
|
+
onClick: onCancel,
|
|
3745
|
+
children: localeService.t("sheets-table-ui.filter.cancel")
|
|
3746
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
3747
|
+
variant: "primary",
|
|
3748
|
+
onClick: () => onApply().catch(() => void 0),
|
|
3749
|
+
children: localeService.t("sheets-table-ui.filter.confirm")
|
|
3750
|
+
})]
|
|
3751
|
+
})]
|
|
3752
|
+
})
|
|
3753
|
+
]
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
|
|
3757
|
+
//#endregion
|
|
3758
|
+
//#region src/views/components/SheetTableMenu.tsx
|
|
3759
|
+
function SheetTableMenu({ popup }) {
|
|
3760
|
+
const menu = popup.extraProps;
|
|
3761
|
+
if (!menu) return null;
|
|
3762
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.DropdownMenu, {
|
|
3763
|
+
align: "start",
|
|
3764
|
+
className: "univer-min-w-40",
|
|
3765
|
+
items: [
|
|
3766
|
+
{
|
|
3767
|
+
type: "item",
|
|
3768
|
+
children: menu.labels.rename,
|
|
3769
|
+
onSelect: () => menu.onSelect("rename")
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
type: "item",
|
|
3773
|
+
children: menu.labels["update-range"],
|
|
3774
|
+
onSelect: () => menu.onSelect("update-range")
|
|
3775
|
+
},
|
|
3776
|
+
{
|
|
3777
|
+
type: "item",
|
|
3778
|
+
children: menu.labels["set-theme"],
|
|
3779
|
+
onSelect: () => menu.onSelect("set-theme")
|
|
3780
|
+
},
|
|
3781
|
+
{
|
|
3782
|
+
type: "item",
|
|
3783
|
+
children: menu.labels.delete,
|
|
3784
|
+
variant: "destructive",
|
|
3785
|
+
onSelect: () => menu.onSelect("delete")
|
|
3786
|
+
}
|
|
3787
|
+
],
|
|
3788
|
+
open: true,
|
|
3789
|
+
sideOffset: 0,
|
|
3790
|
+
onOpenChange: (open) => {
|
|
3791
|
+
if (!open) menu.onClose();
|
|
3792
|
+
},
|
|
3793
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3794
|
+
type: "button",
|
|
3795
|
+
"aria-label": menu.tableName,
|
|
3796
|
+
className: "univer-block univer-h-px univer-opacity-0",
|
|
3797
|
+
style: { width: menu.anchorWidth },
|
|
3798
|
+
tabIndex: -1
|
|
3799
|
+
})
|
|
3800
|
+
});
|
|
3801
|
+
}
|
|
3802
|
+
|
|
3803
|
+
//#endregion
|
|
3804
|
+
//#region src/controllers/components.controller.ts
|
|
3805
|
+
/**
|
|
3806
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3807
|
+
*
|
|
3808
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3809
|
+
* you may not use this file except in compliance with the License.
|
|
3810
|
+
* You may obtain a copy of the License at
|
|
3811
|
+
*
|
|
3812
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3813
|
+
*
|
|
3814
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
3815
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3816
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3817
|
+
* See the License for the specific language governing permissions and
|
|
3818
|
+
* limitations under the License.
|
|
3819
|
+
*/
|
|
3820
|
+
let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
|
|
3821
|
+
constructor(_componentManager, _iconManager) {
|
|
3822
|
+
super();
|
|
3823
|
+
this._componentManager = _componentManager;
|
|
3824
|
+
this._iconManager = _iconManager;
|
|
3825
|
+
this._registerComponents();
|
|
3826
|
+
this._registerIcons();
|
|
3827
|
+
}
|
|
3828
|
+
_registerComponents() {
|
|
3829
|
+
[
|
|
3830
|
+
[SHEETS_TABLE_FILTER_PANEL_OPENED_KEY, SheetTableFilterPanel],
|
|
3831
|
+
[SHEET_TABLE_MENU, SheetTableMenu],
|
|
3832
|
+
[SHEET_TABLE_RENAME_DIALOG, SheetTableRenameDialog]
|
|
3833
|
+
].forEach(([key, comp]) => {
|
|
3834
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
3835
|
+
});
|
|
3836
|
+
[[TABLE_SELECTOR_DIALOG, SheetTableSelector], [SHEET_TABLE_THEME_PANEL, SheetTableThemePanel]].forEach(([key, comp]) => {
|
|
3837
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
3838
|
+
});
|
|
3839
|
+
}
|
|
3840
|
+
_registerIcons() {
|
|
3841
|
+
this.disposeWithMe(this._iconManager.register({ TableIcon: _univerjs_icons.TableIcon }));
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
3845
|
+
|
|
3846
|
+
//#endregion
|
|
3847
|
+
//#region src/plugin.ts
|
|
3848
|
+
let UniverSheetsTableUIPlugin = class UniverSheetsTableUIPlugin extends _univerjs_core.Plugin {
|
|
3849
|
+
constructor(_config = defaultPluginConfig, _injector, _commandService, _configService, _renderManagerService) {
|
|
3850
|
+
super();
|
|
3851
|
+
this._config = _config;
|
|
3852
|
+
this._injector = _injector;
|
|
3853
|
+
this._commandService = _commandService;
|
|
3854
|
+
this._configService = _configService;
|
|
3855
|
+
this._renderManagerService = _renderManagerService;
|
|
3856
|
+
const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
3857
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
3858
|
+
this._configService.setConfig(SHEETS_TABLE_UI_PLUGIN_CONFIG_KEY, rest);
|
|
3859
|
+
this._initRegisterCommand();
|
|
3860
|
+
}
|
|
3861
|
+
onStarting() {
|
|
3862
|
+
this._injector.add([ComponentsController]);
|
|
3863
|
+
this._injector.get(ComponentsController);
|
|
3864
|
+
(0, _univerjs_core.registerDependencies)(this._injector, [
|
|
3865
|
+
[SheetsTableComponentController],
|
|
3866
|
+
[SheetsTableUiService],
|
|
3867
|
+
[SheetTableMenuController],
|
|
3868
|
+
[SheetTableThemeUIController],
|
|
3869
|
+
[SheetTableSelectionController]
|
|
3870
|
+
]);
|
|
3871
|
+
}
|
|
3872
|
+
onReady() {
|
|
3873
|
+
(0, _univerjs_core.touchDependencies)(this._injector, [
|
|
3874
|
+
[SheetsTableComponentController],
|
|
3875
|
+
[SheetsTableUiService],
|
|
3876
|
+
[SheetTableMenuController],
|
|
3877
|
+
[SheetTableThemeUIController],
|
|
3878
|
+
[SheetTableSelectionController]
|
|
3879
|
+
]);
|
|
3880
|
+
}
|
|
3881
|
+
onRendered() {
|
|
3882
|
+
this._registerRenderModules();
|
|
3883
|
+
}
|
|
3884
|
+
_registerRenderModules() {
|
|
3885
|
+
const renderDependencies = [];
|
|
3886
|
+
if (this._config.hideAnchor !== true) renderDependencies.push([SheetTableControlsRenderController]);
|
|
3887
|
+
renderDependencies.push([SheetsTableFilterButtonRenderController], [SheetsTableRenderController]);
|
|
3888
|
+
renderDependencies.forEach((m) => {
|
|
3889
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, m));
|
|
3890
|
+
});
|
|
3891
|
+
}
|
|
3892
|
+
_initRegisterCommand() {
|
|
3893
|
+
[OpenTableFilterPanelOperation, OpenTableSelectorOperation].forEach((m) => this._commandService.registerCommand(m));
|
|
3894
|
+
}
|
|
3895
|
+
};
|
|
3896
|
+
_defineProperty(UniverSheetsTableUIPlugin, "pluginName", PLUGIN_NAME);
|
|
3897
|
+
_defineProperty(UniverSheetsTableUIPlugin, "packageName", name);
|
|
3898
|
+
_defineProperty(UniverSheetsTableUIPlugin, "version", version);
|
|
3899
|
+
_defineProperty(UniverSheetsTableUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
3900
|
+
UniverSheetsTableUIPlugin = __decorate([
|
|
3901
|
+
(0, _univerjs_core.DependentOn)(_univerjs_engine_render.UniverRenderEnginePlugin, _univerjs_sheets.UniverSheetsPlugin, _univerjs_sheets_table.UniverSheetsTablePlugin, _univerjs_sheets_ui.UniverSheetsUIPlugin),
|
|
3902
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3903
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.ICommandService)),
|
|
3904
|
+
__decorateParam(3, _univerjs_core.IConfigService),
|
|
3905
|
+
__decorateParam(4, _univerjs_engine_render.IRenderManagerService)
|
|
3906
|
+
], UniverSheetsTableUIPlugin);
|
|
3907
|
+
|
|
3908
|
+
//#endregion
|
|
3909
|
+
exports.SheetsTableUIMenuSchema = menuSchema;
|
|
3910
|
+
Object.defineProperty(exports, 'UniverSheetsTableMobileUIPlugin', {
|
|
3911
|
+
enumerable: true,
|
|
3912
|
+
get: function () {
|
|
3913
|
+
return UniverSheetsTableMobileUIPlugin;
|
|
3914
|
+
}
|
|
3915
|
+
});
|
|
3012
3916
|
Object.defineProperty(exports, 'UniverSheetsTableUIPlugin', {
|
|
3013
3917
|
enumerable: true,
|
|
3014
3918
|
get: function () {
|