@univerjs/sheets-filter-ui 0.25.1 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +952 -932
- package/lib/cjs/locale/ar-SA.js +1 -0
- package/lib/cjs/locale/ca-ES.js +1 -0
- package/lib/cjs/locale/de-DE.js +1 -0
- package/lib/cjs/locale/en-US.js +1 -0
- package/lib/cjs/locale/es-ES.js +1 -0
- package/lib/cjs/locale/fa-IR.js +1 -0
- package/lib/cjs/locale/fr-FR.js +1 -0
- package/lib/cjs/locale/id-ID.js +1 -0
- package/lib/cjs/locale/it-IT.js +1 -0
- package/lib/cjs/locale/ja-JP.js +1 -0
- package/lib/cjs/locale/ko-KR.js +1 -0
- package/lib/cjs/locale/pl-PL.js +1 -0
- package/lib/cjs/locale/pt-BR.js +1 -0
- package/lib/cjs/locale/ru-RU.js +1 -0
- package/lib/cjs/locale/sk-SK.js +1 -0
- package/lib/cjs/locale/vi-VN.js +1 -0
- package/lib/cjs/locale/zh-CN.js +1 -0
- package/lib/cjs/locale/zh-HK.js +1 -0
- package/lib/cjs/locale/zh-TW.js +1 -0
- package/lib/es/index.js +953 -933
- package/lib/es/locale/ar-SA.js +1 -0
- package/lib/es/locale/ca-ES.js +1 -0
- package/lib/es/locale/de-DE.js +1 -0
- package/lib/es/locale/en-US.js +1 -0
- package/lib/es/locale/es-ES.js +1 -0
- package/lib/es/locale/fa-IR.js +1 -0
- package/lib/es/locale/fr-FR.js +1 -0
- package/lib/es/locale/id-ID.js +1 -0
- package/lib/es/locale/it-IT.js +1 -0
- package/lib/es/locale/ja-JP.js +1 -0
- package/lib/es/locale/ko-KR.js +1 -0
- package/lib/es/locale/pl-PL.js +1 -0
- package/lib/es/locale/pt-BR.js +1 -0
- package/lib/es/locale/ru-RU.js +1 -0
- package/lib/es/locale/sk-SK.js +1 -0
- package/lib/es/locale/vi-VN.js +1 -0
- package/lib/es/locale/zh-CN.js +1 -0
- package/lib/es/locale/zh-HK.js +1 -0
- package/lib/es/locale/zh-TW.js +1 -0
- package/lib/index.js +953 -933
- package/lib/locale/ar-SA.js +1 -0
- package/lib/locale/ca-ES.js +1 -0
- package/lib/locale/de-DE.js +1 -0
- package/lib/locale/en-US.js +1 -0
- package/lib/locale/es-ES.js +1 -0
- package/lib/locale/fa-IR.js +1 -0
- package/lib/locale/fr-FR.js +1 -0
- package/lib/locale/id-ID.js +1 -0
- package/lib/locale/it-IT.js +1 -0
- package/lib/locale/ja-JP.js +1 -0
- package/lib/locale/ko-KR.js +1 -0
- package/lib/locale/pl-PL.js +1 -0
- package/lib/locale/pt-BR.js +1 -0
- package/lib/locale/ru-RU.js +1 -0
- package/lib/locale/sk-SK.js +1 -0
- package/lib/locale/vi-VN.js +1 -0
- package/lib/locale/zh-CN.js +1 -0
- package/lib/locale/zh-HK.js +1 -0
- package/lib/locale/zh-TW.js +1 -0
- package/lib/types/controllers/components.controller.d.ts +24 -0
- package/lib/types/controllers/sheets-filter-permission.controller.d.ts +0 -1
- package/lib/types/controllers/{sheets-filter-ui-desktop.controller.d.ts → ui.controller.d.ts} +3 -5
- package/lib/types/locale/en-US.d.ts +3 -0
- package/lib/types/locale/types.d.ts +18 -0
- package/lib/types/menu/sheets-filter.menu.d.ts +4 -3
- package/lib/types/models/conditions.d.ts +2 -1
- package/lib/types/views/components/SheetsFilterByColorsPanel.d.ts +1 -1
- package/lib/types/views/components/SheetsFilterByConditionsPanel.d.ts +1 -1
- package/lib/types/views/components/SheetsFilterByValuesPanel.d.ts +1 -1
- package/lib/types/views/components/SheetsFilterPanel.d.ts +2 -1
- package/lib/types/views/components/SheetsFilterPanel.stories.d.ts +3 -3
- package/lib/types/views/components/SheetsFilterSyncSwitch.d.ts +1 -1
- package/lib/umd/index.js +2 -2
- 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 +13 -13
- /package/lib/types/{__testing__ → __tests__}/data.d.ts +0 -0
- /package/lib/types/controllers/{sheets-filter-ui-mobile.controller.d.ts → ui-mobile.controller.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -6,11 +6,11 @@ let _univerjs_ui = require("@univerjs/ui");
|
|
|
6
6
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
7
7
|
let _univerjs_sheets = require("@univerjs/sheets");
|
|
8
8
|
let rxjs = require("rxjs");
|
|
9
|
-
let _univerjs_rpc = require("@univerjs/rpc");
|
|
10
|
-
let _univerjs_design = require("@univerjs/design");
|
|
11
9
|
let _univerjs_icons = require("@univerjs/icons");
|
|
10
|
+
let _univerjs_design = require("@univerjs/design");
|
|
12
11
|
let react = require("react");
|
|
13
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
let _univerjs_rpc = require("@univerjs/rpc");
|
|
14
14
|
|
|
15
15
|
//#region src/models/conditions.ts
|
|
16
16
|
let FilterConditionItems;
|
|
@@ -599,7 +599,7 @@ function statisticFilterByValueItems(items) {
|
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
//#endregion
|
|
602
|
-
//#region \0@oxc-project+runtime@0.
|
|
602
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
|
|
603
603
|
function __decorateParam(paramIndex, decorator) {
|
|
604
604
|
return function(target, key) {
|
|
605
605
|
decorator(target, key, paramIndex);
|
|
@@ -607,7 +607,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
//#endregion
|
|
610
|
-
//#region \0@oxc-project+runtime@0.
|
|
610
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
|
|
611
611
|
function __decorate(decorators, target, key, desc) {
|
|
612
612
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
613
613
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -717,7 +717,7 @@ function getFilterTreeByValueItems(filters, localeService, iterateRange, workshe
|
|
|
717
717
|
title: `${day}`,
|
|
718
718
|
key: `${year}-${month}-${day}`,
|
|
719
719
|
count: 1,
|
|
720
|
-
originValues: new Set([value]),
|
|
720
|
+
originValues: /* @__PURE__ */ new Set([value]),
|
|
721
721
|
leaf: true,
|
|
722
722
|
checked: isNeedClearCheckedStatus ? false : alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked
|
|
723
723
|
});
|
|
@@ -837,7 +837,7 @@ function searchTree(items, searchKeywords) {
|
|
|
837
837
|
}
|
|
838
838
|
|
|
839
839
|
//#endregion
|
|
840
|
-
//#region \0@oxc-project+runtime@0.
|
|
840
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
|
|
841
841
|
function _typeof(o) {
|
|
842
842
|
"@babel/helpers - typeof";
|
|
843
843
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -848,7 +848,7 @@ function _typeof(o) {
|
|
|
848
848
|
}
|
|
849
849
|
|
|
850
850
|
//#endregion
|
|
851
|
-
//#region \0@oxc-project+runtime@0.
|
|
851
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
|
|
852
852
|
function toPrimitive(t, r) {
|
|
853
853
|
if ("object" != _typeof(t) || !t) return t;
|
|
854
854
|
var e = t[Symbol.toPrimitive];
|
|
@@ -861,14 +861,14 @@ function toPrimitive(t, r) {
|
|
|
861
861
|
}
|
|
862
862
|
|
|
863
863
|
//#endregion
|
|
864
|
-
//#region \0@oxc-project+runtime@0.
|
|
864
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
|
|
865
865
|
function toPropertyKey(t) {
|
|
866
866
|
var i = toPrimitive(t, "string");
|
|
867
867
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
868
868
|
}
|
|
869
869
|
|
|
870
870
|
//#endregion
|
|
871
|
-
//#region \0@oxc-project+runtime@0.
|
|
871
|
+
//#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
|
|
872
872
|
function _defineProperty(e, r, t) {
|
|
873
873
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
874
874
|
value: t,
|
|
@@ -1518,7 +1518,7 @@ const ChangeFilterByOperation = {
|
|
|
1518
1518
|
//#endregion
|
|
1519
1519
|
//#region package.json
|
|
1520
1520
|
var name = "@univerjs/sheets-filter-ui";
|
|
1521
|
-
var version = "0.
|
|
1521
|
+
var version = "1.0.0-alpha.1";
|
|
1522
1522
|
|
|
1523
1523
|
//#endregion
|
|
1524
1524
|
//#region src/config/config.ts
|
|
@@ -1527,949 +1527,973 @@ const configSymbol = Symbol(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY);
|
|
|
1527
1527
|
const defaultPluginConfig = {};
|
|
1528
1528
|
|
|
1529
1529
|
//#endregion
|
|
1530
|
-
//#region src/
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
})
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
SheetsFilterPermissionController = __decorate([
|
|
1596
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_filter.SheetsFilterService)),
|
|
1597
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
1598
|
-
__decorateParam(2, _univerjs_core.ICommandService),
|
|
1599
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)),
|
|
1600
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1601
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService))
|
|
1602
|
-
], SheetsFilterPermissionController);
|
|
1603
|
-
|
|
1604
|
-
//#endregion
|
|
1605
|
-
//#region src/views/widgets/drawings.ts
|
|
1606
|
-
const BUTTON_VIEWPORT = 16;
|
|
1607
|
-
const FILTER_BUTTON_EMPTY = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");
|
|
1608
|
-
var FilterButton = class {
|
|
1609
|
-
static drawNoCriteria(ctx, size, fgColor, bgColor) {
|
|
1610
|
-
ctx.save();
|
|
1611
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1612
|
-
radius: 2,
|
|
1613
|
-
width: BUTTON_VIEWPORT,
|
|
1614
|
-
height: BUTTON_VIEWPORT,
|
|
1615
|
-
fill: bgColor
|
|
1616
|
-
});
|
|
1617
|
-
ctx.lineCap = "square";
|
|
1618
|
-
ctx.strokeStyle = fgColor;
|
|
1619
|
-
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1620
|
-
ctx.beginPath();
|
|
1621
|
-
ctx.lineWidth = 1;
|
|
1622
|
-
ctx.lineCap = "round";
|
|
1623
|
-
ctx.moveTo(3, 4);
|
|
1624
|
-
ctx.lineTo(13, 4);
|
|
1625
|
-
ctx.moveTo(4.5, 8);
|
|
1626
|
-
ctx.lineTo(11.5, 8);
|
|
1627
|
-
ctx.moveTo(6, 12);
|
|
1628
|
-
ctx.lineTo(10, 12);
|
|
1629
|
-
ctx.stroke();
|
|
1630
|
-
ctx.restore();
|
|
1631
|
-
}
|
|
1632
|
-
static drawHasCriteria(ctx, size, fgColor, bgColor) {
|
|
1633
|
-
ctx.save();
|
|
1634
|
-
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
1635
|
-
radius: 2,
|
|
1636
|
-
width: BUTTON_VIEWPORT,
|
|
1637
|
-
height: BUTTON_VIEWPORT,
|
|
1638
|
-
fill: bgColor
|
|
1639
|
-
});
|
|
1640
|
-
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
1641
|
-
ctx.fillStyle = fgColor;
|
|
1642
|
-
ctx.fill(FILTER_BUTTON_EMPTY);
|
|
1643
|
-
ctx.restore();
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1530
|
+
//#region src/views/components/SheetsFilterByColorsPanel.tsx
|
|
1531
|
+
/**
|
|
1532
|
+
* Filter by colors.
|
|
1533
|
+
*/
|
|
1534
|
+
function FilterByColor(props) {
|
|
1535
|
+
const { model } = props;
|
|
1536
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1537
|
+
const cellFillColors = (0, _univerjs_ui.useObservable)(model.cellFillColors$, [], true);
|
|
1538
|
+
const cellTextColors = (0, _univerjs_ui.useObservable)(model.cellTextColors$, [], true);
|
|
1539
|
+
const handleSelectCellFillColor = (0, react.useCallback)((color) => {
|
|
1540
|
+
model.onFilterCheckToggled(color);
|
|
1541
|
+
}, [model]);
|
|
1542
|
+
const handleSelectCellTextColor = (0, react.useCallback)((color) => {
|
|
1543
|
+
model.onFilterCheckToggled(color, false);
|
|
1544
|
+
}, [model]);
|
|
1545
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1546
|
+
"data-u-comp": "sheets-filter-panel-colors-container",
|
|
1547
|
+
className: "univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",
|
|
1548
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1549
|
+
"data-u-comp": "sheets-filter-panel",
|
|
1550
|
+
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5", _univerjs_design.borderClassName),
|
|
1551
|
+
children: [
|
|
1552
|
+
cellFillColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1553
|
+
className: "univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
1554
|
+
children: localeService.t("sheets-filter-ui.panel.filter-by-cell-fill-color")
|
|
1555
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1556
|
+
className: "univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",
|
|
1557
|
+
children: cellFillColors.map((color, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1558
|
+
className: "univer-relative univer-size-6",
|
|
1559
|
+
onClick: () => handleSelectCellFillColor(color),
|
|
1560
|
+
children: [!color.color ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BanIcon, { className: "univer-size-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1561
|
+
type: "button",
|
|
1562
|
+
className: (0, _univerjs_design.clsx)("univer-box-border univer-size-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),
|
|
1563
|
+
style: { backgroundColor: color.color }
|
|
1564
|
+
}), color.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckedIcon, {})]
|
|
1565
|
+
}, `sheets-filter-cell-fill-color-${index}`))
|
|
1566
|
+
})] }),
|
|
1567
|
+
cellTextColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1568
|
+
className: "univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
1569
|
+
children: localeService.t("sheets-filter-ui.panel.filter-by-cell-text-color")
|
|
1570
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1571
|
+
className: "univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",
|
|
1572
|
+
children: cellTextColors.map((color, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1573
|
+
className: "univer-relative univer-size-6",
|
|
1574
|
+
onClick: () => handleSelectCellTextColor(color),
|
|
1575
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1576
|
+
className: "univer-box-border univer-flex univer-size-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",
|
|
1577
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AIcon, { style: { color: color.color } })
|
|
1578
|
+
}), color.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckedIcon, {})]
|
|
1579
|
+
}, `sheets-filter-cell-text-color-${index}`))
|
|
1580
|
+
})] }),
|
|
1581
|
+
cellFillColors.length <= 1 && cellTextColors.length <= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1582
|
+
className: "univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",
|
|
1583
|
+
children: localeService.t("sheets-filter-ui.panel.filter-by-color-none")
|
|
1584
|
+
})
|
|
1585
|
+
]
|
|
1586
|
+
})
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
function CheckedIcon() {
|
|
1590
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1591
|
+
className: "univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",
|
|
1592
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SuccessIcon, { className: "univer-size-full univer-font-bold univer-text-[#418F1F]" })
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1646
1595
|
|
|
1647
1596
|
//#endregion
|
|
1648
|
-
//#region src/views/
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1597
|
+
//#region src/views/components/SheetsFilterByConditionsPanel.tsx
|
|
1598
|
+
/**
|
|
1599
|
+
* Filter by conditions.
|
|
1600
|
+
*/
|
|
1601
|
+
function FilterByCondition(props) {
|
|
1602
|
+
var _formParams$val, _formParams$val2;
|
|
1603
|
+
const { model } = props;
|
|
1604
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1605
|
+
const condition = (0, _univerjs_ui.useObservable)(model.conditionItem$, void 0);
|
|
1606
|
+
const formParams = (0, _univerjs_ui.useObservable)(model.filterConditionFormParams$, void 0);
|
|
1607
|
+
const radioValue = (formParams === null || formParams === void 0 ? void 0 : formParams.and) ? "AND" : "OR";
|
|
1608
|
+
const onRadioChange = (0, react.useCallback)((key) => {
|
|
1609
|
+
model.onConditionFormChange({ and: key === "AND" });
|
|
1610
|
+
}, [model]);
|
|
1611
|
+
const primaryOptions = usePrimaryOptions(localeService);
|
|
1612
|
+
const onPrimaryConditionChange = (0, react.useCallback)((value) => {
|
|
1613
|
+
model.onPrimaryConditionChange(value);
|
|
1614
|
+
}, [model]);
|
|
1615
|
+
const secondaryOptions = useSecondaryOptions(localeService);
|
|
1616
|
+
const onFormParamsChange = (0, react.useCallback)((diffParams) => {
|
|
1617
|
+
model.onConditionFormChange(diffParams);
|
|
1618
|
+
}, [model]);
|
|
1619
|
+
const placeholder = localeService.t("sheets-filter-ui.panel.input-values-placeholder");
|
|
1620
|
+
function renderSecondaryCondition(operator, val, name) {
|
|
1621
|
+
const shouldRenderInput = FilterConditionItems.getItemByOperator(operator).numOfParameters === 1;
|
|
1622
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1623
|
+
name === "operator2" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.RadioGroup, {
|
|
1624
|
+
value: radioValue,
|
|
1625
|
+
onChange: onRadioChange,
|
|
1626
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
|
|
1627
|
+
value: "AND",
|
|
1628
|
+
children: localeService.t("sheets-filter-ui.panel.and")
|
|
1629
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Radio, {
|
|
1630
|
+
value: "OR",
|
|
1631
|
+
children: localeService.t("sheets-filter-ui.panel.or")
|
|
1632
|
+
})]
|
|
1633
|
+
}),
|
|
1634
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
1635
|
+
value: operator,
|
|
1636
|
+
options: secondaryOptions,
|
|
1637
|
+
onChange: (operator) => onFormParamsChange({ [name]: operator })
|
|
1638
|
+
}),
|
|
1639
|
+
shouldRenderInput && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1640
|
+
className: "univer-mt-2",
|
|
1641
|
+
value: val,
|
|
1642
|
+
placeholder,
|
|
1643
|
+
onChange: (value) => onFormParamsChange({ [name === "operator1" ? "val1" : "val2"]: value })
|
|
1644
|
+
}) })
|
|
1645
|
+
] });
|
|
1664
1646
|
}
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1647
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1648
|
+
"data-u-comp": "sheets-filter-panel-conditions-container",
|
|
1649
|
+
className: "univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",
|
|
1650
|
+
children: condition && formParams && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
1651
|
+
value: condition.operator,
|
|
1652
|
+
options: primaryOptions,
|
|
1653
|
+
onChange: onPrimaryConditionChange
|
|
1654
|
+
}), FilterConditionItems.getItemByOperator(condition.operator).numOfParameters !== 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1655
|
+
"data-u-comp": "sheets-filter-panel-conditions-container-inner",
|
|
1656
|
+
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2", _univerjs_design.borderClassName),
|
|
1657
|
+
children: [
|
|
1658
|
+
condition.numOfParameters >= 1 && renderSecondaryCondition(formParams.operator1, (_formParams$val = formParams.val1) !== null && _formParams$val !== void 0 ? _formParams$val : "", "operator1"),
|
|
1659
|
+
condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2, (_formParams$val2 = formParams.val2) !== null && _formParams$val2 !== void 0 ? _formParams$val2 : "", "operator2"),
|
|
1660
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1661
|
+
"data-u-comp": "sheets-filter-panel-conditions-desc",
|
|
1662
|
+
className: "univer-mt-2 univer-text-xs univer-text-gray-500",
|
|
1663
|
+
children: [
|
|
1664
|
+
localeService.t("sheets-filter-ui.panel.?"),
|
|
1665
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}),
|
|
1666
|
+
localeService.t("sheets-filter-ui.panel.*")
|
|
1667
|
+
]
|
|
1668
|
+
})
|
|
1669
|
+
]
|
|
1670
|
+
}) : null] })
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
function usePrimaryOptions(localeService) {
|
|
1674
|
+
return (0, react.useMemo)(() => [
|
|
1675
|
+
{ options: [{
|
|
1676
|
+
label: localeService.t(FilterConditionItems.NONE.label),
|
|
1677
|
+
value: FilterConditionItems.NONE.operator
|
|
1678
|
+
}] },
|
|
1679
|
+
{ options: [{
|
|
1680
|
+
label: localeService.t(FilterConditionItems.EMPTY.label),
|
|
1681
|
+
value: FilterConditionItems.EMPTY.operator
|
|
1682
|
+
}, {
|
|
1683
|
+
label: localeService.t(FilterConditionItems.NOT_EMPTY.label),
|
|
1684
|
+
value: FilterConditionItems.NOT_EMPTY.operator
|
|
1685
|
+
}] },
|
|
1686
|
+
{ options: [
|
|
1687
|
+
{
|
|
1688
|
+
label: localeService.t(FilterConditionItems.TEXT_CONTAINS.label),
|
|
1689
|
+
value: FilterConditionItems.TEXT_CONTAINS.operator
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
label: localeService.t(FilterConditionItems.DOES_NOT_CONTAIN.label),
|
|
1693
|
+
value: FilterConditionItems.DOES_NOT_CONTAIN.operator
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
label: localeService.t(FilterConditionItems.STARTS_WITH.label),
|
|
1697
|
+
value: FilterConditionItems.STARTS_WITH.operator
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
label: localeService.t(FilterConditionItems.ENDS_WITH.label),
|
|
1701
|
+
value: FilterConditionItems.ENDS_WITH.operator
|
|
1702
|
+
},
|
|
1703
|
+
{
|
|
1704
|
+
label: localeService.t(FilterConditionItems.EQUALS.label),
|
|
1705
|
+
value: FilterConditionItems.EQUALS.operator
|
|
1706
|
+
}
|
|
1707
|
+
] },
|
|
1708
|
+
{ options: [
|
|
1709
|
+
{
|
|
1710
|
+
label: localeService.t(FilterConditionItems.GREATER_THAN.label),
|
|
1711
|
+
value: FilterConditionItems.GREATER_THAN.operator
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
label: localeService.t(FilterConditionItems.GREATER_THAN_OR_EQUAL.label),
|
|
1715
|
+
value: FilterConditionItems.GREATER_THAN_OR_EQUAL.operator
|
|
1716
|
+
},
|
|
1717
|
+
{
|
|
1718
|
+
label: localeService.t(FilterConditionItems.LESS_THAN.label),
|
|
1719
|
+
value: FilterConditionItems.LESS_THAN.operator
|
|
1720
|
+
},
|
|
1721
|
+
{
|
|
1722
|
+
label: localeService.t(FilterConditionItems.LESS_THAN_OR_EQUAL.label),
|
|
1723
|
+
value: FilterConditionItems.LESS_THAN_OR_EQUAL.operator
|
|
1724
|
+
},
|
|
1725
|
+
{
|
|
1726
|
+
label: localeService.t(FilterConditionItems.EQUAL.label),
|
|
1727
|
+
value: FilterConditionItems.EQUAL.operator
|
|
1728
|
+
},
|
|
1729
|
+
{
|
|
1730
|
+
label: localeService.t(FilterConditionItems.NOT_EQUAL.label),
|
|
1731
|
+
value: FilterConditionItems.NOT_EQUAL.operator
|
|
1732
|
+
},
|
|
1733
|
+
{
|
|
1734
|
+
label: localeService.t(FilterConditionItems.BETWEEN.label),
|
|
1735
|
+
value: FilterConditionItems.BETWEEN.operator
|
|
1736
|
+
},
|
|
1737
|
+
{
|
|
1738
|
+
label: localeService.t(FilterConditionItems.NOT_BETWEEN.label),
|
|
1739
|
+
value: FilterConditionItems.NOT_BETWEEN.operator
|
|
1740
|
+
}
|
|
1741
|
+
] },
|
|
1742
|
+
{ options: [{
|
|
1743
|
+
label: localeService.t(FilterConditionItems.CUSTOM.label),
|
|
1744
|
+
value: FilterConditionItems.CUSTOM.operator
|
|
1745
|
+
}] }
|
|
1746
|
+
], [localeService.getCurrentLocale(), localeService]);
|
|
1747
|
+
}
|
|
1748
|
+
function useSecondaryOptions(localeService) {
|
|
1749
|
+
return (0, react.useMemo)(() => FilterConditionItems.ALL_CONDITIONS.filter((c) => c.numOfParameters !== 2).map((c) => ({
|
|
1750
|
+
label: localeService.t(c.label),
|
|
1751
|
+
value: c.operator
|
|
1752
|
+
})), [localeService.getCurrentLocale(), localeService]);
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
//#endregion
|
|
1756
|
+
//#region src/views/components/SheetsFilterByValuesPanel.tsx
|
|
1757
|
+
/**
|
|
1758
|
+
* Filter by values.
|
|
1759
|
+
*/
|
|
1760
|
+
function FilterByValue(props) {
|
|
1761
|
+
const { model } = props;
|
|
1762
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1763
|
+
const searchText = (0, _univerjs_ui.useObservable)(model.searchString$, "", true);
|
|
1764
|
+
const items = (0, _univerjs_ui.useObservable)(model.filterItems$, void 0, true);
|
|
1765
|
+
const filterOnly = localeService.t("sheets-filter-ui.panel.filter-only");
|
|
1766
|
+
const stat = statisticFilterByValueItems(items);
|
|
1767
|
+
const allChecked = stat.checked > 0 && stat.unchecked === 0;
|
|
1768
|
+
const indeterminate = stat.checked > 0 && stat.unchecked > 0;
|
|
1769
|
+
const treeMap = model.treeMapCache;
|
|
1770
|
+
const onCheckAllToggled = (0, react.useCallback)(() => {
|
|
1771
|
+
model.onCheckAllToggled(!allChecked);
|
|
1772
|
+
}, [model, allChecked]);
|
|
1773
|
+
const onSearchValueChange = (0, react.useCallback)((str) => {
|
|
1774
|
+
model.setSearchString(str);
|
|
1775
|
+
}, [model]);
|
|
1776
|
+
function extractCheckedKeys(items) {
|
|
1777
|
+
let checkedKeys = [];
|
|
1778
|
+
items.forEach((item) => {
|
|
1779
|
+
if (item.checked) checkedKeys.push(item.key);
|
|
1780
|
+
if (item.children) checkedKeys = checkedKeys.concat(extractCheckedKeys(item.children));
|
|
1672
1781
|
});
|
|
1782
|
+
return checkedKeys;
|
|
1673
1783
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1784
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1785
|
+
"data-u-comp": "sheets-filter-panel-values-container",
|
|
1786
|
+
className: "univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",
|
|
1787
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Input, {
|
|
1788
|
+
autoFocus: true,
|
|
1789
|
+
value: searchText,
|
|
1790
|
+
placeholder: localeService.t("sheets-filter-ui.panel.search-placeholder"),
|
|
1791
|
+
onChange: onSearchValueChange
|
|
1792
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1793
|
+
"data-u-comp": "sheets-filter-panel",
|
|
1794
|
+
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5", _univerjs_design.borderClassName),
|
|
1795
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1796
|
+
"data-u-comp": "sheets-filter-panel-values-item",
|
|
1797
|
+
className: "univer-box-border univer-h-8 univer-w-full univer-py-0.5",
|
|
1798
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1799
|
+
"data-u-comp": "sheets-filter-panel-values-item-inner",
|
|
1800
|
+
className: "univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm",
|
|
1801
|
+
children: [
|
|
1802
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Checkbox, {
|
|
1803
|
+
indeterminate,
|
|
1804
|
+
disabled: items.length === 0,
|
|
1805
|
+
checked: allChecked,
|
|
1806
|
+
onChange: onCheckAllToggled
|
|
1807
|
+
}),
|
|
1808
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1809
|
+
"data-u-comp": "sheets-filter-panel-values-item-text",
|
|
1810
|
+
className: "univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900 dark:!univer-text-white",
|
|
1811
|
+
children: `${localeService.t("sheets-filter-ui.panel.select-all")}`
|
|
1812
|
+
}),
|
|
1813
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1814
|
+
"data-u-comp": "sheets-filter-panel-values-item-count",
|
|
1815
|
+
className: "univer-text-gray-400 dark:!univer-text-gray-500",
|
|
1816
|
+
children: `(${stat.checked}/${stat.checked + stat.unchecked})`
|
|
1817
|
+
})
|
|
1818
|
+
]
|
|
1819
|
+
})
|
|
1820
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1821
|
+
"data-u-comp": "sheets-filter-panel-values-virtual",
|
|
1822
|
+
className: "univer-flex-grow",
|
|
1823
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tree, {
|
|
1824
|
+
data: items,
|
|
1825
|
+
defaultExpandAll: false,
|
|
1826
|
+
valueGroup: extractCheckedKeys(items),
|
|
1827
|
+
onChange: (node) => {
|
|
1828
|
+
model.onFilterCheckToggled(node);
|
|
1829
|
+
},
|
|
1830
|
+
defaultCache: treeMap,
|
|
1831
|
+
itemHeight: 28,
|
|
1832
|
+
treeNodeClassName: `
|
|
1833
|
+
univer-pr-2 univer-border-box univer-rounded-md
|
|
1834
|
+
[&:hover_a]:univer-inline-block
|
|
1835
|
+
hover:univer-bg-gray-50 univer-h-full
|
|
1836
|
+
univer-text-gray-900 dark:hover:!univer-bg-gray-900
|
|
1837
|
+
dark:!univer-text-white
|
|
1838
|
+
`,
|
|
1839
|
+
attachRender: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1840
|
+
className: "univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",
|
|
1841
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1842
|
+
"data-u-comp": "sheets-filter-panel-values-item-count",
|
|
1843
|
+
className: "univer-text-gray-400 dark:!univer-text-gray-500",
|
|
1844
|
+
children: `(${item.count})`
|
|
1845
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
1846
|
+
className: "univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",
|
|
1847
|
+
onClick: () => {
|
|
1848
|
+
const filterValues = [];
|
|
1849
|
+
if (item.children) item.children.forEach((child) => {
|
|
1850
|
+
if (child.children) child.children.forEach((subChild) => {
|
|
1851
|
+
filterValues.push(subChild.key);
|
|
1852
|
+
});
|
|
1853
|
+
else filterValues.push(child.key);
|
|
1854
|
+
});
|
|
1855
|
+
else filterValues.push(item.key);
|
|
1856
|
+
model.onFilterOnly(filterValues);
|
|
1857
|
+
},
|
|
1858
|
+
children: filterOnly
|
|
1859
|
+
})]
|
|
1860
|
+
})
|
|
1861
|
+
})
|
|
1862
|
+
})]
|
|
1863
|
+
})]
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
//#endregion
|
|
1868
|
+
//#region src/views/components/SheetsFilterSyncSwitch.tsx
|
|
1869
|
+
function FilterSyncSwitch() {
|
|
1870
|
+
const sheetsFilterSyncController = (0, _univerjs_ui.useDependency)(_univerjs_sheets_filter.SheetsFilterSyncController);
|
|
1871
|
+
if (!(0, _univerjs_ui.useObservable)(sheetsFilterSyncController.visible$, void 0, true)) return null;
|
|
1872
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1873
|
+
const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
|
|
1874
|
+
const enabled = (0, _univerjs_ui.useObservable)(sheetsFilterSyncController.enabled$, void 0, true);
|
|
1875
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1876
|
+
className: "univer-mt-2 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",
|
|
1877
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1878
|
+
className: "univer-flex univer-items-center univer-gap-1",
|
|
1879
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-filter-ui.sync.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
1880
|
+
title: enabled ? localeService.t("sheets-filter-ui.sync.statusTips.off") : localeService.t("sheets-filter-ui.sync.statusTips.on"),
|
|
1881
|
+
asChild: true,
|
|
1882
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.InfoIcon, { className: "univer-block" })
|
|
1883
|
+
})]
|
|
1884
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Switch, {
|
|
1885
|
+
defaultChecked: enabled,
|
|
1886
|
+
onChange: (checked) => {
|
|
1887
|
+
const message = checked ? localeService.t("sheets-filter-ui.sync.switchTips.on") : localeService.t("sheets-filter-ui.sync.switchTips.off");
|
|
1888
|
+
sheetsFilterSyncController.setEnabled(checked);
|
|
1889
|
+
messageService.show({
|
|
1890
|
+
content: message,
|
|
1891
|
+
type: _univerjs_design.MessageType.Success,
|
|
1892
|
+
duration: 2e3
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
})]
|
|
1896
|
+
});
|
|
1897
|
+
}
|
|
1716
1898
|
|
|
1717
1899
|
//#endregion
|
|
1718
|
-
//#region src/views/
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
const getParams = () => ({
|
|
1761
|
-
unitId,
|
|
1762
|
-
worksheetId,
|
|
1763
|
-
filterModel,
|
|
1764
|
-
range: filterModel === null || filterModel === void 0 ? void 0 : filterModel.getRange(),
|
|
1765
|
-
skeleton: skeletonParams.skeleton
|
|
1766
|
-
});
|
|
1767
|
-
return (0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
|
|
1768
|
-
var _command$params;
|
|
1769
|
-
return command.type === _univerjs_core.CommandType.MUTATION && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === workbook.getUnitId() && (_univerjs_sheets_filter.FILTER_MUTATIONS.has(command.id) || command.id === _univerjs_sheets.SetRangeValuesMutation.id);
|
|
1770
|
-
}), (0, rxjs.throttleTime)(20, void 0, {
|
|
1771
|
-
leading: false,
|
|
1772
|
-
trailing: true
|
|
1773
|
-
}), (0, rxjs.map)(getParams), (0, rxjs.startWith)(getParams()));
|
|
1774
|
-
}), (0, rxjs.takeUntil)(this.dispose$)).subscribe((renderParams) => {
|
|
1775
|
-
this._currentRenderParams = renderParams;
|
|
1776
|
-
this._refreshRendering(renderParams);
|
|
1777
|
-
});
|
|
1778
|
-
}
|
|
1779
|
-
_refreshRendering(renderParams) {
|
|
1780
|
-
this._disposeRendering();
|
|
1781
|
-
if (!renderParams || !renderParams.range) return;
|
|
1782
|
-
this._renderRange(renderParams.range, renderParams.skeleton);
|
|
1783
|
-
this._renderButtons(renderParams);
|
|
1784
|
-
}
|
|
1785
|
-
_renderRange(range, skeleton) {
|
|
1786
|
-
const { scene } = this._context;
|
|
1787
|
-
const { rowHeaderWidth, columnHeaderHeight } = skeleton;
|
|
1788
|
-
const filterRangeShape = this._filterRangeShape = new _univerjs_sheets_ui.SelectionControl(scene, DEFAULT_Z_INDEX, this._themeService, {
|
|
1789
|
-
rowHeaderWidth,
|
|
1790
|
-
columnHeaderHeight,
|
|
1791
|
-
enableAutoFill: false,
|
|
1792
|
-
highlightHeader: false
|
|
1793
|
-
});
|
|
1794
|
-
const selectionWithCoord = (0, _univerjs_sheets.attachSelectionWithCoord)({
|
|
1795
|
-
range,
|
|
1796
|
-
primary: null,
|
|
1797
|
-
style: { fill: "rgba(0, 0, 0, 0.0)" }
|
|
1798
|
-
}, skeleton);
|
|
1799
|
-
filterRangeShape.updateRangeBySelectionWithCoord(selectionWithCoord);
|
|
1800
|
-
filterRangeShape.setEvent(false);
|
|
1801
|
-
scene.makeDirty(true);
|
|
1802
|
-
}
|
|
1803
|
-
_renderButtons(params) {
|
|
1804
|
-
const { range, filterModel, unitId, skeleton, worksheetId } = params;
|
|
1805
|
-
const { unit: workbook, scene } = this._context;
|
|
1806
|
-
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
1807
|
-
if (!worksheet) return;
|
|
1808
|
-
this._interceptCellContent(unitId, worksheetId, params.range);
|
|
1809
|
-
const { startColumn, endColumn, startRow } = range;
|
|
1810
|
-
for (let col = startColumn; col <= endColumn; col++) {
|
|
1811
|
-
const key = `sheets-filter-button-${col}`;
|
|
1812
|
-
const startPosition = (0, _univerjs_sheets_ui.getCoordByCell)(startRow, col, scene, skeleton);
|
|
1813
|
-
const cellStyle = worksheet.getComposedCellStyle(startRow, col);
|
|
1814
|
-
const verticalAlign = (cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle.vt) || _univerjs_core.VerticalAlign.BOTTOM;
|
|
1815
|
-
const { startX, startY, endX, endY } = startPosition;
|
|
1816
|
-
const cellWidth = endX - startX;
|
|
1817
|
-
const cellHeight = endY - startY;
|
|
1818
|
-
if (cellHeight <= 1 || cellWidth <= 1) continue;
|
|
1819
|
-
const hasCriteria = !!filterModel.getFilterColumn(col);
|
|
1820
|
-
const props = {
|
|
1821
|
-
left: endX - 16 - 1,
|
|
1822
|
-
top: computeIconTop(startY, endY, cellHeight, verticalAlign),
|
|
1823
|
-
height: 16,
|
|
1824
|
-
width: 16,
|
|
1825
|
-
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
1826
|
-
cellHeight,
|
|
1827
|
-
cellWidth,
|
|
1828
|
-
filterParams: {
|
|
1829
|
-
unitId,
|
|
1830
|
-
subUnitId: worksheetId,
|
|
1831
|
-
col,
|
|
1832
|
-
hasCriteria
|
|
1900
|
+
//#region src/views/components/SheetsFilterPanel.tsx
|
|
1901
|
+
/**
|
|
1902
|
+
* This Filter Panel component is used to filter the data in the sheet.
|
|
1903
|
+
*
|
|
1904
|
+
* @returns React element
|
|
1905
|
+
*/
|
|
1906
|
+
function FilterPanel() {
|
|
1907
|
+
var _filterService$active;
|
|
1908
|
+
const sheetsFilterPanelService = (0, _univerjs_ui.useDependency)(SheetsFilterPanelService);
|
|
1909
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1910
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1911
|
+
const filterBy = (0, _univerjs_ui.useObservable)(sheetsFilterPanelService.filterBy$, void 0, true);
|
|
1912
|
+
const filterByModel = (0, _univerjs_ui.useObservable)(sheetsFilterPanelService.filterByModel$, void 0, false);
|
|
1913
|
+
const canApply = (0, _univerjs_ui.useObservable)(() => (filterByModel === null || filterByModel === void 0 ? void 0 : filterByModel.canApply$) || (0, rxjs.of)(false), void 0, false, [filterByModel]);
|
|
1914
|
+
const items = useFilterByOptions(localeService);
|
|
1915
|
+
const clearFilterDisabled = !(0, _univerjs_ui.useObservable)(sheetsFilterPanelService.hasCriteria$);
|
|
1916
|
+
const onFilterByTypeChange = (0, react.useCallback)((value) => {
|
|
1917
|
+
commandService.executeCommand(ChangeFilterByOperation.id, { filterBy: value });
|
|
1918
|
+
}, [commandService]);
|
|
1919
|
+
const onClearCriteria = (0, react.useCallback)(async () => {
|
|
1920
|
+
await (filterByModel === null || filterByModel === void 0 ? void 0 : filterByModel.clear());
|
|
1921
|
+
commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1922
|
+
}, [filterByModel, commandService]);
|
|
1923
|
+
const onCancel = (0, react.useCallback)(() => {
|
|
1924
|
+
commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1925
|
+
}, [commandService]);
|
|
1926
|
+
const onApply = (0, react.useCallback)(async () => {
|
|
1927
|
+
await (filterByModel === null || filterByModel === void 0 ? void 0 : filterByModel.apply());
|
|
1928
|
+
commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1929
|
+
}, [filterByModel, commandService]);
|
|
1930
|
+
const range = (_filterService$active = (0, _univerjs_ui.useDependency)(_univerjs_sheets_filter.SheetsFilterService).activeFilterModel) === null || _filterService$active === void 0 ? void 0 : _filterService$active.getRange();
|
|
1931
|
+
const colIndex = sheetsFilterPanelService.col;
|
|
1932
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1933
|
+
"data-u-comp": "sheets-filter-panel",
|
|
1934
|
+
className: "univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
1935
|
+
children: [
|
|
1936
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ComponentContainer, {
|
|
1937
|
+
components: (0, _univerjs_ui.useComponentsOfPart)(_univerjs_sheets_ui.SheetsUIPart.FILTER_PANEL_EMBED_POINT),
|
|
1938
|
+
sharedProps: {
|
|
1939
|
+
range,
|
|
1940
|
+
colIndex,
|
|
1941
|
+
onClose: onCancel
|
|
1833
1942
|
}
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1943
|
+
}),
|
|
1944
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1945
|
+
className: "univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",
|
|
1946
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Segmented, {
|
|
1947
|
+
value: filterBy,
|
|
1948
|
+
items,
|
|
1949
|
+
onChange: (value) => onFilterByTypeChange(value)
|
|
1950
|
+
})
|
|
1951
|
+
}),
|
|
1952
|
+
filterByModel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1953
|
+
"data-u-comp": "sheets-filter-panel-content",
|
|
1954
|
+
className: "univer-flex-shrink univer-flex-grow univer-pt-2",
|
|
1955
|
+
children: filterBy === _univerjs_sheets_filter.FilterBy.VALUES ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByValue, { model: filterByModel }) : filterBy === _univerjs_sheets_filter.FilterBy.COLORS ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByColor, { model: filterByModel }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByCondition, { model: filterByModel })
|
|
1956
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-flex-1" }),
|
|
1957
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterSyncSwitch, {}),
|
|
1958
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1959
|
+
"data-u-comp": "sheets-filter-panel-footer",
|
|
1960
|
+
className: "univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",
|
|
1961
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1962
|
+
variant: "link",
|
|
1963
|
+
onClick: onClearCriteria,
|
|
1964
|
+
disabled: clearFilterDisabled,
|
|
1965
|
+
children: localeService.t("sheets-filter-ui.panel.clear-filter")
|
|
1966
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1967
|
+
className: "univer-flex univer-gap-2",
|
|
1968
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1969
|
+
variant: "default",
|
|
1970
|
+
onClick: onCancel,
|
|
1971
|
+
children: localeService.t("sheets-filter-ui.panel.cancel")
|
|
1972
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1973
|
+
disabled: !canApply,
|
|
1974
|
+
variant: "primary",
|
|
1975
|
+
onClick: onApply,
|
|
1976
|
+
children: localeService.t("sheets-filter-ui.panel.confirm")
|
|
1977
|
+
})]
|
|
1978
|
+
})]
|
|
1979
|
+
})
|
|
1980
|
+
]
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
const FILTER_PANEL_POPUP_KEY = "FILTER_PANEL_POPUP";
|
|
1984
|
+
function useFilterByOptions(localeService) {
|
|
1985
|
+
return (0, react.useMemo)(() => [
|
|
1986
|
+
{
|
|
1987
|
+
label: localeService.t("sheets-filter-ui.panel.by-values"),
|
|
1988
|
+
value: _univerjs_sheets_filter.FilterBy.VALUES
|
|
1989
|
+
},
|
|
1990
|
+
{
|
|
1991
|
+
label: localeService.t("sheets-filter-ui.panel.by-colors"),
|
|
1992
|
+
value: _univerjs_sheets_filter.FilterBy.COLORS
|
|
1993
|
+
},
|
|
1994
|
+
{
|
|
1995
|
+
label: localeService.t("sheets-filter-ui.panel.by-conditions"),
|
|
1996
|
+
value: _univerjs_sheets_filter.FilterBy.CONDITIONS
|
|
1837
1997
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
_interceptCellContent(workbookId, worksheetId, range) {
|
|
1842
|
-
const { startRow, startColumn, endColumn } = range;
|
|
1843
|
-
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(_univerjs_sheets.INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
1844
|
-
effect: _univerjs_core.InterceptorEffectEnum.Style,
|
|
1845
|
-
handler: (cell, pos, next) => {
|
|
1846
|
-
const { row, col, unitId, subUnitId } = pos;
|
|
1847
|
-
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
1848
|
-
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
1849
|
-
cell.fontRenderExtension = {
|
|
1850
|
-
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
1851
|
-
rightOffset: 16
|
|
1852
|
-
};
|
|
1853
|
-
return next(cell);
|
|
1854
|
-
},
|
|
1855
|
-
priority: 10
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
_disposeRendering() {
|
|
1859
|
-
var _this$_filterRangeSha, _this$_buttonRenderDi;
|
|
1860
|
-
(_this$_filterRangeSha = this._filterRangeShape) === null || _this$_filterRangeSha === void 0 || _this$_filterRangeSha.dispose();
|
|
1861
|
-
this._filterButtonShapes.forEach((s) => s.dispose());
|
|
1862
|
-
(_this$_buttonRenderDi = this._buttonRenderDisposable) === null || _this$_buttonRenderDi === void 0 || _this$_buttonRenderDi.dispose();
|
|
1863
|
-
this._filterRangeShape = null;
|
|
1864
|
-
this._buttonRenderDisposable = null;
|
|
1865
|
-
this._filterButtonShapes = [];
|
|
1866
|
-
}
|
|
1867
|
-
};
|
|
1868
|
-
SheetsFilterRenderController = __decorate([
|
|
1869
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
1870
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
1871
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets_filter.SheetsFilterService)),
|
|
1872
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService)),
|
|
1873
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
1874
|
-
__decorateParam(6, _univerjs_core.ICommandService),
|
|
1875
|
-
__decorateParam(7, _univerjs_sheets_ui.ISheetSelectionRenderService)
|
|
1876
|
-
], SheetsFilterRenderController);
|
|
1998
|
+
], [localeService.getCurrentLocale(), localeService]);
|
|
1999
|
+
}
|
|
1877
2000
|
|
|
1878
2001
|
//#endregion
|
|
1879
|
-
//#region src/controllers/
|
|
1880
|
-
|
|
1881
|
-
|
|
2002
|
+
//#region src/controllers/components.controller.ts
|
|
2003
|
+
/**
|
|
2004
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2005
|
+
*
|
|
2006
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2007
|
+
* you may not use this file except in compliance with the License.
|
|
2008
|
+
* You may obtain a copy of the License at
|
|
2009
|
+
*
|
|
2010
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2011
|
+
*
|
|
2012
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2013
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2014
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2015
|
+
* See the License for the specific language governing permissions and
|
|
2016
|
+
* limitations under the License.
|
|
2017
|
+
*/
|
|
2018
|
+
let ComponentsController = class ComponentsController extends _univerjs_core.Disposable {
|
|
2019
|
+
constructor(_componentManager, _iconManager) {
|
|
1882
2020
|
super();
|
|
1883
|
-
this.
|
|
1884
|
-
this.
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2021
|
+
this._componentManager = _componentManager;
|
|
2022
|
+
this._iconManager = _iconManager;
|
|
2023
|
+
this._registerIcons();
|
|
2024
|
+
this._registerComponents();
|
|
2025
|
+
}
|
|
2026
|
+
_registerIcons() {
|
|
2027
|
+
this.disposeWithMe(this._iconManager.register({ FilterIcon: _univerjs_icons.FilterIcon }));
|
|
2028
|
+
}
|
|
2029
|
+
_registerComponents() {
|
|
2030
|
+
[[FILTER_PANEL_POPUP_KEY, FilterPanel]].forEach(([key, comp]) => {
|
|
2031
|
+
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
2032
|
+
});
|
|
1892
2033
|
}
|
|
1893
2034
|
};
|
|
1894
|
-
|
|
2035
|
+
ComponentsController = __decorate([__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_ui.ComponentManager)), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_ui.IconManager))], ComponentsController);
|
|
1895
2036
|
|
|
1896
2037
|
//#endregion
|
|
1897
|
-
//#region src/
|
|
1898
|
-
let
|
|
1899
|
-
constructor(
|
|
2038
|
+
//#region src/controllers/sheets-filter-permission.controller.ts
|
|
2039
|
+
let SheetsFilterPermissionController = class SheetsFilterPermissionController extends _univerjs_core.Disposable {
|
|
2040
|
+
constructor(_sheetsFilterService, _localeService, _commandService, _sheetPermissionCheckPermission, _injector, _sheetsSelectionService) {
|
|
1900
2041
|
super();
|
|
1901
|
-
this.
|
|
2042
|
+
this._sheetsFilterService = _sheetsFilterService;
|
|
2043
|
+
this._localeService = _localeService;
|
|
2044
|
+
this._commandService = _commandService;
|
|
2045
|
+
this._sheetPermissionCheckPermission = _sheetPermissionCheckPermission;
|
|
1902
2046
|
this._injector = _injector;
|
|
1903
|
-
this.
|
|
1904
|
-
|
|
1905
|
-
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
1906
|
-
this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
|
|
1907
|
-
}
|
|
1908
|
-
onStarting() {
|
|
1909
|
-
[[SheetsFilterPermissionController], [SheetsFilterUIMobileController]].forEach((d) => this._injector.add(d));
|
|
1910
|
-
}
|
|
1911
|
-
onReady() {
|
|
1912
|
-
this._injector.get(SheetsFilterPermissionController);
|
|
2047
|
+
this._sheetsSelectionService = _sheetsSelectionService;
|
|
2048
|
+
this._commandExecutedListener();
|
|
1913
2049
|
}
|
|
1914
|
-
|
|
1915
|
-
this.
|
|
2050
|
+
_commandExecutedListener() {
|
|
2051
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
2052
|
+
if (command.id === _univerjs_sheets_filter.SmartToggleSheetsFilterCommand.id) {
|
|
2053
|
+
var _this$_sheetsFilterSe;
|
|
2054
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(this._injector.get(_univerjs_core.IUniverInstanceService));
|
|
2055
|
+
if (!target) return;
|
|
2056
|
+
const { unitId, subUnitId, worksheet } = target;
|
|
2057
|
+
const filterRange = (_this$_sheetsFilterSe = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe === void 0 ? void 0 : _this$_sheetsFilterSe.getRange();
|
|
2058
|
+
let permission;
|
|
2059
|
+
if (filterRange) permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
2060
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint],
|
|
2061
|
+
worksheetTypes: [_univerjs_sheets.WorksheetFilterPermission, _univerjs_sheets.WorksheetViewPermission]
|
|
2062
|
+
}, [filterRange], unitId, subUnitId);
|
|
2063
|
+
else {
|
|
2064
|
+
var _this$_sheetsSelectio;
|
|
2065
|
+
const range = (_this$_sheetsSelectio = this._sheetsSelectionService.getCurrentLastSelection()) === null || _this$_sheetsSelectio === void 0 ? void 0 : _this$_sheetsSelectio.range;
|
|
2066
|
+
if (range) {
|
|
2067
|
+
let newRange = { ...range };
|
|
2068
|
+
newRange = range.startColumn === range.endColumn && range.startRow === range.endRow ? (0, _univerjs_sheets.expandToContinuousRange)(newRange, {
|
|
2069
|
+
left: true,
|
|
2070
|
+
right: true,
|
|
2071
|
+
up: true,
|
|
2072
|
+
down: true
|
|
2073
|
+
}, worksheet) : newRange;
|
|
2074
|
+
permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
2075
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint],
|
|
2076
|
+
worksheetTypes: [_univerjs_sheets.WorksheetViewPermission, _univerjs_sheets.WorksheetFilterPermission]
|
|
2077
|
+
}, [newRange], unitId, subUnitId);
|
|
2078
|
+
} else permission = this._sheetPermissionCheckPermission.permissionCheckWithoutRange({
|
|
2079
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint],
|
|
2080
|
+
worksheetTypes: [_univerjs_sheets.WorksheetViewPermission, _univerjs_sheets.WorksheetFilterPermission]
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
if (!permission) this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("sheets-filter-ui.permission.filterErr"));
|
|
2084
|
+
}
|
|
2085
|
+
if (command.id === OpenFilterPanelOperation.id) {
|
|
2086
|
+
var _this$_sheetsFilterSe2;
|
|
2087
|
+
const params = command.params;
|
|
2088
|
+
const { unitId, subUnitId } = params;
|
|
2089
|
+
const filterRange = (_this$_sheetsFilterSe2 = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe2 === void 0 ? void 0 : _this$_sheetsFilterSe2.getRange();
|
|
2090
|
+
const colRange = _univerjs_core.Tools.deepClone(filterRange);
|
|
2091
|
+
if (colRange) {
|
|
2092
|
+
colRange.startColumn = params.col;
|
|
2093
|
+
colRange.endColumn = params.col;
|
|
2094
|
+
if (!this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
2095
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint],
|
|
2096
|
+
worksheetTypes: [_univerjs_sheets.WorksheetFilterPermission, _univerjs_sheets.WorksheetViewPermission]
|
|
2097
|
+
}, [colRange], unitId, subUnitId)) this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("sheets-filter-ui.permission.filterErr"));
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}));
|
|
1916
2101
|
}
|
|
1917
2102
|
};
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
(0, _univerjs_core.
|
|
1924
|
-
__decorateParam(
|
|
1925
|
-
|
|
1926
|
-
], UniverSheetsFilterMobileUIPlugin);
|
|
2103
|
+
SheetsFilterPermissionController = __decorate([
|
|
2104
|
+
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_sheets_filter.SheetsFilterService)),
|
|
2105
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
2106
|
+
__decorateParam(2, _univerjs_core.ICommandService),
|
|
2107
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetPermissionCheckController)),
|
|
2108
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2109
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetsSelectionsService))
|
|
2110
|
+
], SheetsFilterPermissionController);
|
|
1927
2111
|
|
|
1928
2112
|
//#endregion
|
|
1929
|
-
//#region src/
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
}
|
|
2113
|
+
//#region src/views/widgets/drawings.ts
|
|
2114
|
+
const BUTTON_VIEWPORT = 16;
|
|
2115
|
+
const FILTER_BUTTON_EMPTY = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");
|
|
2116
|
+
var FilterButton = class {
|
|
2117
|
+
static drawNoCriteria(ctx, size, fgColor, bgColor) {
|
|
2118
|
+
ctx.save();
|
|
2119
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
2120
|
+
radius: 2,
|
|
2121
|
+
width: BUTTON_VIEWPORT,
|
|
2122
|
+
height: BUTTON_VIEWPORT,
|
|
2123
|
+
fill: bgColor
|
|
2124
|
+
});
|
|
2125
|
+
ctx.lineCap = "square";
|
|
2126
|
+
ctx.strokeStyle = fgColor;
|
|
2127
|
+
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
2128
|
+
ctx.beginPath();
|
|
2129
|
+
ctx.lineWidth = 1;
|
|
2130
|
+
ctx.lineCap = "round";
|
|
2131
|
+
ctx.moveTo(3, 4);
|
|
2132
|
+
ctx.lineTo(13, 4);
|
|
2133
|
+
ctx.moveTo(4.5, 8);
|
|
2134
|
+
ctx.lineTo(11.5, 8);
|
|
2135
|
+
ctx.moveTo(6, 12);
|
|
2136
|
+
ctx.lineTo(10, 12);
|
|
2137
|
+
ctx.stroke();
|
|
2138
|
+
ctx.restore();
|
|
2139
|
+
}
|
|
2140
|
+
static drawHasCriteria(ctx, size, fgColor, bgColor) {
|
|
2141
|
+
ctx.save();
|
|
2142
|
+
_univerjs_engine_render.Rect.drawWith(ctx, {
|
|
2143
|
+
radius: 2,
|
|
2144
|
+
width: BUTTON_VIEWPORT,
|
|
2145
|
+
height: BUTTON_VIEWPORT,
|
|
2146
|
+
fill: bgColor
|
|
2147
|
+
});
|
|
2148
|
+
ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT);
|
|
2149
|
+
ctx.fillStyle = fgColor;
|
|
2150
|
+
ctx.fill(FILTER_BUTTON_EMPTY);
|
|
2151
|
+
ctx.restore();
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
1971
2154
|
|
|
1972
2155
|
//#endregion
|
|
1973
|
-
//#region src/
|
|
1974
|
-
const
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2156
|
+
//#region src/views/widgets/filter-button.shape.ts
|
|
2157
|
+
const FILTER_ICON_SIZE = 16;
|
|
2158
|
+
let SheetsFilterButtonShape = class SheetsFilterButtonShape extends _univerjs_engine_render.Shape {
|
|
2159
|
+
constructor(key, props, _contextService, _commandService, _themeService) {
|
|
2160
|
+
super(key, props);
|
|
2161
|
+
this._contextService = _contextService;
|
|
2162
|
+
this._commandService = _commandService;
|
|
2163
|
+
this._themeService = _themeService;
|
|
2164
|
+
_defineProperty(this, "_cellWidth", 0);
|
|
2165
|
+
_defineProperty(this, "_cellHeight", 0);
|
|
2166
|
+
_defineProperty(this, "_filterParams", void 0);
|
|
2167
|
+
_defineProperty(this, "_hovered", false);
|
|
2168
|
+
this.setShapeProps(props);
|
|
2169
|
+
this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt));
|
|
2170
|
+
this.onPointerEnter$.subscribeEvent(() => this.onPointerEnter());
|
|
2171
|
+
this.onPointerLeave$.subscribeEvent(() => this.onPointerLeave());
|
|
2172
|
+
}
|
|
2173
|
+
setShapeProps(props) {
|
|
2174
|
+
if (typeof props.cellHeight !== "undefined") this._cellHeight = props.cellHeight;
|
|
2175
|
+
if (typeof props.cellWidth !== "undefined") this._cellWidth = props.cellWidth;
|
|
2176
|
+
if (typeof props.filterParams !== "undefined") this._filterParams = props.filterParams;
|
|
2177
|
+
this.transformByState({
|
|
2178
|
+
width: props.width,
|
|
2179
|
+
height: props.height
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
_draw(ctx) {
|
|
2183
|
+
const cellHeight = this._cellHeight;
|
|
2184
|
+
const cellWidth = this._cellWidth;
|
|
2185
|
+
const left = 16 - cellWidth;
|
|
2186
|
+
const top = 16 - cellHeight;
|
|
2187
|
+
ctx.save();
|
|
2188
|
+
const cellRegion = new Path2D();
|
|
2189
|
+
cellRegion.rect(left, top, cellWidth, cellHeight);
|
|
2190
|
+
ctx.clip(cellRegion);
|
|
2191
|
+
const { hasCriteria } = this._filterParams;
|
|
2192
|
+
const fgColor = this._themeService.getColorFromTheme("primary.600");
|
|
2193
|
+
const bgColor = this._hovered ? this._themeService.getColorFromTheme("gray.50") : "rgba(255, 255, 255, 1.0)";
|
|
2194
|
+
if (hasCriteria) FilterButton.drawHasCriteria(ctx, 16, fgColor, bgColor);
|
|
2195
|
+
else FilterButton.drawNoCriteria(ctx, 16, fgColor, bgColor);
|
|
2196
|
+
ctx.restore();
|
|
1984
2197
|
}
|
|
1985
|
-
|
|
2198
|
+
onPointerDown(evt) {
|
|
2199
|
+
if (evt.button === 2) return;
|
|
2200
|
+
const { col, unitId, subUnitId } = this._filterParams;
|
|
2201
|
+
if (this._contextService.getContextValue("FILTER_PANEL_OPENED") || !this._commandService.hasCommand(OpenFilterPanelOperation.id)) return;
|
|
2202
|
+
setTimeout(() => {
|
|
2203
|
+
this._commandService.executeCommand(OpenFilterPanelOperation.id, {
|
|
2204
|
+
unitId,
|
|
2205
|
+
subUnitId,
|
|
2206
|
+
col
|
|
2207
|
+
});
|
|
2208
|
+
}, 200);
|
|
2209
|
+
}
|
|
2210
|
+
onPointerEnter() {
|
|
2211
|
+
this._hovered = true;
|
|
2212
|
+
this.makeDirty(true);
|
|
2213
|
+
}
|
|
2214
|
+
onPointerLeave() {
|
|
2215
|
+
this._hovered = false;
|
|
2216
|
+
this.makeDirty(true);
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
SheetsFilterButtonShape = __decorate([
|
|
2220
|
+
__decorateParam(2, _univerjs_core.IContextService),
|
|
2221
|
+
__decorateParam(3, _univerjs_core.ICommandService),
|
|
2222
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService))
|
|
2223
|
+
], SheetsFilterButtonShape);
|
|
1986
2224
|
|
|
1987
2225
|
//#endregion
|
|
1988
|
-
//#region src/views/
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
model.onFilterCheckToggled(color);
|
|
1999
|
-
}, [model]);
|
|
2000
|
-
const handleSelectCellTextColor = (0, react.useCallback)((color) => {
|
|
2001
|
-
model.onFilterCheckToggled(color, false);
|
|
2002
|
-
}, [model]);
|
|
2003
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2004
|
-
"data-u-comp": "sheets-filter-panel-colors-container",
|
|
2005
|
-
className: "univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",
|
|
2006
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2007
|
-
"data-u-comp": "sheets-filter-panel",
|
|
2008
|
-
className: (0, _univerjs_design.clsx)("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5", _univerjs_design.borderClassName),
|
|
2009
|
-
children: [
|
|
2010
|
-
cellFillColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2011
|
-
className: "univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
2012
|
-
children: localeService.t("sheets-filter-ui.panel.filter-by-cell-fill-color")
|
|
2013
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2014
|
-
className: "univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",
|
|
2015
|
-
children: cellFillColors.map((color, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2016
|
-
className: "univer-relative univer-size-6",
|
|
2017
|
-
onClick: () => handleSelectCellFillColor(color),
|
|
2018
|
-
children: [!color.color ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.BanIcon, { className: "univer-size-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2019
|
-
type: "button",
|
|
2020
|
-
className: (0, _univerjs_design.clsx)("univer-box-border univer-size-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),
|
|
2021
|
-
style: { backgroundColor: color.color }
|
|
2022
|
-
}), color.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckedIcon, {})]
|
|
2023
|
-
}, `sheets-filter-cell-fill-color-${index}`))
|
|
2024
|
-
})] }),
|
|
2025
|
-
cellTextColors.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2026
|
-
className: "univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",
|
|
2027
|
-
children: localeService.t("sheets-filter-ui.panel.filter-by-cell-text-color")
|
|
2028
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2029
|
-
className: "univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",
|
|
2030
|
-
children: cellTextColors.map((color, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2031
|
-
className: "univer-relative univer-size-6",
|
|
2032
|
-
onClick: () => handleSelectCellTextColor(color),
|
|
2033
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2034
|
-
className: "univer-box-border univer-flex univer-size-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",
|
|
2035
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.AIcon, { style: { color: color.color } })
|
|
2036
|
-
}), color.checked && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckedIcon, {})]
|
|
2037
|
-
}, `sheets-filter-cell-text-color-${index}`))
|
|
2038
|
-
})] }),
|
|
2039
|
-
cellFillColors.length <= 1 && cellTextColors.length <= 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2040
|
-
className: "univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",
|
|
2041
|
-
children: localeService.t("sheets-filter-ui.panel.filter-by-color-none")
|
|
2042
|
-
})
|
|
2043
|
-
]
|
|
2044
|
-
})
|
|
2045
|
-
});
|
|
2046
|
-
}
|
|
2047
|
-
function CheckedIcon() {
|
|
2048
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2049
|
-
className: "univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",
|
|
2050
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.SuccessIcon, { className: "univer-size-full univer-font-bold univer-text-[#418F1F]" })
|
|
2051
|
-
});
|
|
2226
|
+
//#region src/views/render-modules/sheets-filter.render-controller.ts
|
|
2227
|
+
const DEFAULT_Z_INDEX = 1e3;
|
|
2228
|
+
const SHEETS_FILTER_BUTTON_Z_INDEX = 5e3;
|
|
2229
|
+
function computeIconTop(startY, endY, cellHeight, verticalAlign) {
|
|
2230
|
+
switch (verticalAlign) {
|
|
2231
|
+
case _univerjs_core.VerticalAlign.TOP: return startY + 1;
|
|
2232
|
+
case _univerjs_core.VerticalAlign.MIDDLE: return startY + Math.max(0, (cellHeight - 16) / 2);
|
|
2233
|
+
case _univerjs_core.VerticalAlign.BOTTOM:
|
|
2234
|
+
default: return endY - 16 - 1;
|
|
2235
|
+
}
|
|
2052
2236
|
}
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2237
|
+
let SheetsFilterRenderController = class SheetsFilterRenderController extends _univerjs_core.RxDisposable {
|
|
2238
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetsFilterService, _themeService, _sheetInterceptorService, _commandService, _selectionRenderService) {
|
|
2239
|
+
super();
|
|
2240
|
+
this._context = _context;
|
|
2241
|
+
this._injector = _injector;
|
|
2242
|
+
this._sheetSkeletonManagerService = _sheetSkeletonManagerService;
|
|
2243
|
+
this._sheetsFilterService = _sheetsFilterService;
|
|
2244
|
+
this._themeService = _themeService;
|
|
2245
|
+
this._sheetInterceptorService = _sheetInterceptorService;
|
|
2246
|
+
this._commandService = _commandService;
|
|
2247
|
+
this._selectionRenderService = _selectionRenderService;
|
|
2248
|
+
_defineProperty(this, "_currentRenderParams", null);
|
|
2249
|
+
_defineProperty(this, "_filterRangeShape", null);
|
|
2250
|
+
_defineProperty(this, "_buttonRenderDisposable", null);
|
|
2251
|
+
_defineProperty(this, "_filterButtonShapes", []);
|
|
2252
|
+
this._initRenderer();
|
|
2253
|
+
}
|
|
2254
|
+
dispose() {
|
|
2255
|
+
super.dispose();
|
|
2256
|
+
this._disposeRendering();
|
|
2257
|
+
}
|
|
2258
|
+
_initRenderer() {
|
|
2259
|
+
this.disposeWithMe(this._themeService.currentTheme$.subscribe(() => {
|
|
2260
|
+
this._refreshRendering(this._currentRenderParams);
|
|
2261
|
+
}));
|
|
2262
|
+
this._sheetSkeletonManagerService.currentSkeleton$.pipe((0, rxjs.switchMap)((skeletonParams) => {
|
|
2263
|
+
var _workbook$getActiveSh, _this$_sheetsFilterSe;
|
|
2264
|
+
if (!skeletonParams) return (0, rxjs.of)(null);
|
|
2265
|
+
const { unit: workbook, unitId } = this._context;
|
|
2266
|
+
const worksheetId = ((_workbook$getActiveSh = workbook.getActiveSheet()) === null || _workbook$getActiveSh === void 0 ? void 0 : _workbook$getActiveSh.getSheetId()) || "";
|
|
2267
|
+
const filterModel = (_this$_sheetsFilterSe = this._sheetsFilterService.getFilterModel(unitId, worksheetId)) !== null && _this$_sheetsFilterSe !== void 0 ? _this$_sheetsFilterSe : void 0;
|
|
2268
|
+
const getParams = () => ({
|
|
2269
|
+
unitId,
|
|
2270
|
+
worksheetId,
|
|
2271
|
+
filterModel,
|
|
2272
|
+
range: filterModel === null || filterModel === void 0 ? void 0 : filterModel.getRange(),
|
|
2273
|
+
skeleton: skeletonParams.skeleton
|
|
2274
|
+
});
|
|
2275
|
+
return (0, _univerjs_core.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0, rxjs.filter)(([command]) => {
|
|
2276
|
+
var _command$params;
|
|
2277
|
+
return command.type === _univerjs_core.CommandType.MUTATION && ((_command$params = command.params) === null || _command$params === void 0 ? void 0 : _command$params.unitId) === workbook.getUnitId() && (_univerjs_sheets_filter.FILTER_MUTATIONS.has(command.id) || command.id === _univerjs_sheets.SetRangeValuesMutation.id);
|
|
2278
|
+
}), (0, rxjs.throttleTime)(20, void 0, {
|
|
2279
|
+
leading: false,
|
|
2280
|
+
trailing: true
|
|
2281
|
+
}), (0, rxjs.map)(getParams), (0, rxjs.startWith)(getParams()));
|
|
2282
|
+
}), (0, rxjs.takeUntil)(this.dispose$)).subscribe((renderParams) => {
|
|
2283
|
+
this._currentRenderParams = renderParams;
|
|
2284
|
+
this._refreshRendering(renderParams);
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
_refreshRendering(renderParams) {
|
|
2288
|
+
this._disposeRendering();
|
|
2289
|
+
if (!renderParams || !renderParams.range) return;
|
|
2290
|
+
this._renderRange(renderParams.range, renderParams.skeleton);
|
|
2291
|
+
this._renderButtons(renderParams);
|
|
2292
|
+
}
|
|
2293
|
+
_renderRange(range, skeleton) {
|
|
2294
|
+
const { scene } = this._context;
|
|
2295
|
+
const { rowHeaderWidth, columnHeaderHeight } = skeleton;
|
|
2296
|
+
const filterRangeShape = this._filterRangeShape = new _univerjs_sheets_ui.SelectionControl(scene, DEFAULT_Z_INDEX, this._themeService, {
|
|
2297
|
+
rowHeaderWidth,
|
|
2298
|
+
columnHeaderHeight,
|
|
2299
|
+
enableAutoFill: false,
|
|
2300
|
+
highlightHeader: false
|
|
2301
|
+
});
|
|
2302
|
+
const selectionWithCoord = (0, _univerjs_sheets.attachSelectionWithCoord)({
|
|
2303
|
+
range,
|
|
2304
|
+
primary: null,
|
|
2305
|
+
style: { fill: "rgba(0, 0, 0, 0.0)" }
|
|
2306
|
+
}, skeleton);
|
|
2307
|
+
filterRangeShape.updateRangeBySelectionWithCoord(selectionWithCoord);
|
|
2308
|
+
filterRangeShape.setEvent(false);
|
|
2309
|
+
scene.makeDirty(true);
|
|
2310
|
+
}
|
|
2311
|
+
_renderButtons(params) {
|
|
2312
|
+
const { range, filterModel, unitId, skeleton, worksheetId } = params;
|
|
2313
|
+
const { unit: workbook, scene } = this._context;
|
|
2314
|
+
const worksheet = workbook.getSheetBySheetId(worksheetId);
|
|
2315
|
+
if (!worksheet) return;
|
|
2316
|
+
this._interceptCellContent(unitId, worksheetId, params.range);
|
|
2317
|
+
const { startColumn, endColumn, startRow } = range;
|
|
2318
|
+
for (let col = startColumn; col <= endColumn; col++) {
|
|
2319
|
+
const key = `sheets-filter-button-${col}`;
|
|
2320
|
+
const startPosition = (0, _univerjs_sheets_ui.getCoordByCell)(startRow, col, scene, skeleton);
|
|
2321
|
+
const cellStyle = worksheet.getComposedCellStyle(startRow, col);
|
|
2322
|
+
const verticalAlign = (cellStyle === null || cellStyle === void 0 ? void 0 : cellStyle.vt) || _univerjs_core.VerticalAlign.BOTTOM;
|
|
2323
|
+
const { startX, startY, endX, endY } = startPosition;
|
|
2324
|
+
const cellWidth = endX - startX;
|
|
2325
|
+
const cellHeight = endY - startY;
|
|
2326
|
+
if (cellHeight <= 1 || cellWidth <= 1) continue;
|
|
2327
|
+
const hasCriteria = !!filterModel.getFilterColumn(col);
|
|
2328
|
+
const props = {
|
|
2329
|
+
left: endX - 16 - 1,
|
|
2330
|
+
top: computeIconTop(startY, endY, cellHeight, verticalAlign),
|
|
2331
|
+
height: 16,
|
|
2332
|
+
width: 16,
|
|
2333
|
+
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
2334
|
+
cellHeight,
|
|
2335
|
+
cellWidth,
|
|
2336
|
+
filterParams: {
|
|
2337
|
+
unitId,
|
|
2338
|
+
subUnitId: worksheetId,
|
|
2339
|
+
col,
|
|
2340
|
+
hasCriteria
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
const buttonShape = this._injector.createInstance(SheetsFilterButtonShape, key, props);
|
|
2344
|
+
this._filterButtonShapes.push(buttonShape);
|
|
2345
|
+
}
|
|
2346
|
+
scene.addObjects(this._filterButtonShapes);
|
|
2347
|
+
scene.makeDirty();
|
|
2104
2348
|
}
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2119
|
-
"data-u-comp": "sheets-filter-panel-conditions-desc",
|
|
2120
|
-
className: "univer-mt-2 univer-text-xs univer-text-gray-500",
|
|
2121
|
-
children: [
|
|
2122
|
-
localeService.t("sheets-filter-ui.panel.?"),
|
|
2123
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}),
|
|
2124
|
-
localeService.t("sheets-filter-ui.panel.*")
|
|
2125
|
-
]
|
|
2126
|
-
})
|
|
2127
|
-
]
|
|
2128
|
-
}) : null] })
|
|
2129
|
-
});
|
|
2130
|
-
}
|
|
2131
|
-
function usePrimaryOptions(localeService) {
|
|
2132
|
-
return (0, react.useMemo)(() => [
|
|
2133
|
-
{ options: [{
|
|
2134
|
-
label: localeService.t(FilterConditionItems.NONE.label),
|
|
2135
|
-
value: FilterConditionItems.NONE.operator
|
|
2136
|
-
}] },
|
|
2137
|
-
{ options: [{
|
|
2138
|
-
label: localeService.t(FilterConditionItems.EMPTY.label),
|
|
2139
|
-
value: FilterConditionItems.EMPTY.operator
|
|
2140
|
-
}, {
|
|
2141
|
-
label: localeService.t(FilterConditionItems.NOT_EMPTY.label),
|
|
2142
|
-
value: FilterConditionItems.NOT_EMPTY.operator
|
|
2143
|
-
}] },
|
|
2144
|
-
{ options: [
|
|
2145
|
-
{
|
|
2146
|
-
label: localeService.t(FilterConditionItems.TEXT_CONTAINS.label),
|
|
2147
|
-
value: FilterConditionItems.TEXT_CONTAINS.operator
|
|
2148
|
-
},
|
|
2149
|
-
{
|
|
2150
|
-
label: localeService.t(FilterConditionItems.DOES_NOT_CONTAIN.label),
|
|
2151
|
-
value: FilterConditionItems.DOES_NOT_CONTAIN.operator
|
|
2152
|
-
},
|
|
2153
|
-
{
|
|
2154
|
-
label: localeService.t(FilterConditionItems.STARTS_WITH.label),
|
|
2155
|
-
value: FilterConditionItems.STARTS_WITH.operator
|
|
2156
|
-
},
|
|
2157
|
-
{
|
|
2158
|
-
label: localeService.t(FilterConditionItems.ENDS_WITH.label),
|
|
2159
|
-
value: FilterConditionItems.ENDS_WITH.operator
|
|
2160
|
-
},
|
|
2161
|
-
{
|
|
2162
|
-
label: localeService.t(FilterConditionItems.EQUALS.label),
|
|
2163
|
-
value: FilterConditionItems.EQUALS.operator
|
|
2164
|
-
}
|
|
2165
|
-
] },
|
|
2166
|
-
{ options: [
|
|
2167
|
-
{
|
|
2168
|
-
label: localeService.t(FilterConditionItems.GREATER_THAN.label),
|
|
2169
|
-
value: FilterConditionItems.GREATER_THAN.operator
|
|
2170
|
-
},
|
|
2171
|
-
{
|
|
2172
|
-
label: localeService.t(FilterConditionItems.GREATER_THAN_OR_EQUAL.label),
|
|
2173
|
-
value: FilterConditionItems.GREATER_THAN_OR_EQUAL.operator
|
|
2174
|
-
},
|
|
2175
|
-
{
|
|
2176
|
-
label: localeService.t(FilterConditionItems.LESS_THAN.label),
|
|
2177
|
-
value: FilterConditionItems.LESS_THAN.operator
|
|
2178
|
-
},
|
|
2179
|
-
{
|
|
2180
|
-
label: localeService.t(FilterConditionItems.LESS_THAN_OR_EQUAL.label),
|
|
2181
|
-
value: FilterConditionItems.LESS_THAN_OR_EQUAL.operator
|
|
2182
|
-
},
|
|
2183
|
-
{
|
|
2184
|
-
label: localeService.t(FilterConditionItems.EQUAL.label),
|
|
2185
|
-
value: FilterConditionItems.EQUAL.operator
|
|
2186
|
-
},
|
|
2187
|
-
{
|
|
2188
|
-
label: localeService.t(FilterConditionItems.NOT_EQUAL.label),
|
|
2189
|
-
value: FilterConditionItems.NOT_EQUAL.operator
|
|
2190
|
-
},
|
|
2191
|
-
{
|
|
2192
|
-
label: localeService.t(FilterConditionItems.BETWEEN.label),
|
|
2193
|
-
value: FilterConditionItems.BETWEEN.operator
|
|
2349
|
+
_interceptCellContent(workbookId, worksheetId, range) {
|
|
2350
|
+
const { startRow, startColumn, endColumn } = range;
|
|
2351
|
+
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(_univerjs_sheets.INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
2352
|
+
effect: _univerjs_core.InterceptorEffectEnum.Style,
|
|
2353
|
+
handler: (cell, pos, next) => {
|
|
2354
|
+
const { row, col, unitId, subUnitId } = pos;
|
|
2355
|
+
if (unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn) return next(cell);
|
|
2356
|
+
if (!cell || cell === pos.rawData) cell = { ...pos.rawData };
|
|
2357
|
+
cell.fontRenderExtension = {
|
|
2358
|
+
...cell === null || cell === void 0 ? void 0 : cell.fontRenderExtension,
|
|
2359
|
+
rightOffset: 16
|
|
2360
|
+
};
|
|
2361
|
+
return next(cell);
|
|
2194
2362
|
},
|
|
2195
|
-
|
|
2196
|
-
label: localeService.t(FilterConditionItems.NOT_BETWEEN.label),
|
|
2197
|
-
value: FilterConditionItems.NOT_BETWEEN.operator
|
|
2198
|
-
}
|
|
2199
|
-
] },
|
|
2200
|
-
{ options: [{
|
|
2201
|
-
label: localeService.t(FilterConditionItems.CUSTOM.label),
|
|
2202
|
-
value: FilterConditionItems.CUSTOM.operator
|
|
2203
|
-
}] }
|
|
2204
|
-
], [localeService.getCurrentLocale(), localeService]);
|
|
2205
|
-
}
|
|
2206
|
-
function useSecondaryOptions(localeService) {
|
|
2207
|
-
return (0, react.useMemo)(() => FilterConditionItems.ALL_CONDITIONS.filter((c) => c.numOfParameters !== 2).map((c) => ({
|
|
2208
|
-
label: localeService.t(c.label),
|
|
2209
|
-
value: c.operator
|
|
2210
|
-
})), [localeService.getCurrentLocale(), localeService]);
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
//#endregion
|
|
2214
|
-
//#region src/views/components/SheetsFilterByValuesPanel.tsx
|
|
2215
|
-
/**
|
|
2216
|
-
* Filter by values.
|
|
2217
|
-
*/
|
|
2218
|
-
function FilterByValue(props) {
|
|
2219
|
-
const { model } = props;
|
|
2220
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
2221
|
-
const searchText = (0, _univerjs_ui.useObservable)(model.searchString$, "", true);
|
|
2222
|
-
const items = (0, _univerjs_ui.useObservable)(model.filterItems$, void 0, true);
|
|
2223
|
-
const filterOnly = localeService.t("sheets-filter-ui.panel.filter-only");
|
|
2224
|
-
const stat = statisticFilterByValueItems(items);
|
|
2225
|
-
const allChecked = stat.checked > 0 && stat.unchecked === 0;
|
|
2226
|
-
const indeterminate = stat.checked > 0 && stat.unchecked > 0;
|
|
2227
|
-
const treeMap = model.treeMapCache;
|
|
2228
|
-
const onCheckAllToggled = (0, react.useCallback)(() => {
|
|
2229
|
-
model.onCheckAllToggled(!allChecked);
|
|
2230
|
-
}, [model, allChecked]);
|
|
2231
|
-
const onSearchValueChange = (0, react.useCallback)((str) => {
|
|
2232
|
-
model.setSearchString(str);
|
|
2233
|
-
}, [model]);
|
|
2234
|
-
function extractCheckedKeys(items) {
|
|
2235
|
-
let checkedKeys = [];
|
|
2236
|
-
items.forEach((item) => {
|
|
2237
|
-
if (item.checked) checkedKeys.push(item.key);
|
|
2238
|
-
if (item.children) checkedKeys = checkedKeys.concat(extractCheckedKeys(item.children));
|
|
2363
|
+
priority: 10
|
|
2239
2364
|
});
|
|
2240
|
-
return checkedKeys;
|
|
2241
2365
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
indeterminate,
|
|
2262
|
-
disabled: items.length === 0,
|
|
2263
|
-
checked: allChecked,
|
|
2264
|
-
onChange: onCheckAllToggled
|
|
2265
|
-
}),
|
|
2266
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2267
|
-
"data-u-comp": "sheets-filter-panel-values-item-text",
|
|
2268
|
-
className: "univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900 dark:!univer-text-white",
|
|
2269
|
-
children: `${localeService.t("sheets-filter-ui.panel.select-all")}`
|
|
2270
|
-
}),
|
|
2271
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2272
|
-
"data-u-comp": "sheets-filter-panel-values-item-count",
|
|
2273
|
-
className: "univer-text-gray-400 dark:!univer-text-gray-500",
|
|
2274
|
-
children: `(${stat.checked}/${stat.checked + stat.unchecked})`
|
|
2275
|
-
})
|
|
2276
|
-
]
|
|
2277
|
-
})
|
|
2278
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2279
|
-
"data-u-comp": "sheets-filter-panel-values-virtual",
|
|
2280
|
-
className: "univer-flex-grow",
|
|
2281
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tree, {
|
|
2282
|
-
data: items,
|
|
2283
|
-
defaultExpandAll: false,
|
|
2284
|
-
valueGroup: extractCheckedKeys(items),
|
|
2285
|
-
onChange: (node) => {
|
|
2286
|
-
model.onFilterCheckToggled(node);
|
|
2287
|
-
},
|
|
2288
|
-
defaultCache: treeMap,
|
|
2289
|
-
itemHeight: 28,
|
|
2290
|
-
treeNodeClassName: `
|
|
2291
|
-
univer-pr-2 univer-border-box univer-rounded-md
|
|
2292
|
-
[&:hover_a]:univer-inline-block
|
|
2293
|
-
hover:univer-bg-gray-50 univer-h-full
|
|
2294
|
-
univer-text-gray-900 dark:hover:!univer-bg-gray-900
|
|
2295
|
-
dark:!univer-text-white
|
|
2296
|
-
`,
|
|
2297
|
-
attachRender: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2298
|
-
className: "univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500",
|
|
2299
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2300
|
-
"data-u-comp": "sheets-filter-panel-values-item-count",
|
|
2301
|
-
className: "univer-text-gray-400 dark:!univer-text-gray-500",
|
|
2302
|
-
children: `(${item.count})`
|
|
2303
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
2304
|
-
className: "univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",
|
|
2305
|
-
onClick: () => {
|
|
2306
|
-
const filterValues = [];
|
|
2307
|
-
if (item.children) item.children.forEach((child) => {
|
|
2308
|
-
if (child.children) child.children.forEach((subChild) => {
|
|
2309
|
-
filterValues.push(subChild.key);
|
|
2310
|
-
});
|
|
2311
|
-
else filterValues.push(child.key);
|
|
2312
|
-
});
|
|
2313
|
-
else filterValues.push(item.key);
|
|
2314
|
-
model.onFilterOnly(filterValues);
|
|
2315
|
-
},
|
|
2316
|
-
children: filterOnly
|
|
2317
|
-
})]
|
|
2318
|
-
})
|
|
2319
|
-
})
|
|
2320
|
-
})]
|
|
2321
|
-
})]
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2366
|
+
_disposeRendering() {
|
|
2367
|
+
var _this$_filterRangeSha, _this$_buttonRenderDi;
|
|
2368
|
+
(_this$_filterRangeSha = this._filterRangeShape) === null || _this$_filterRangeSha === void 0 || _this$_filterRangeSha.dispose();
|
|
2369
|
+
this._filterButtonShapes.forEach((s) => s.dispose());
|
|
2370
|
+
(_this$_buttonRenderDi = this._buttonRenderDisposable) === null || _this$_buttonRenderDi === void 0 || _this$_buttonRenderDi.dispose();
|
|
2371
|
+
this._filterRangeShape = null;
|
|
2372
|
+
this._buttonRenderDisposable = null;
|
|
2373
|
+
this._filterButtonShapes = [];
|
|
2374
|
+
}
|
|
2375
|
+
};
|
|
2376
|
+
SheetsFilterRenderController = __decorate([
|
|
2377
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2378
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetSkeletonManagerService)),
|
|
2379
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets_filter.SheetsFilterService)),
|
|
2380
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.ThemeService)),
|
|
2381
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_sheets.SheetInterceptorService)),
|
|
2382
|
+
__decorateParam(6, _univerjs_core.ICommandService),
|
|
2383
|
+
__decorateParam(7, _univerjs_sheets_ui.ISheetSelectionRenderService)
|
|
2384
|
+
], SheetsFilterRenderController);
|
|
2324
2385
|
|
|
2325
2386
|
//#endregion
|
|
2326
|
-
//#region src/
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
function FilterSyncSwitch() {
|
|
2343
|
-
const sheetsFilterSyncController = (0, _univerjs_ui.useDependency)(_univerjs_sheets_filter.SheetsFilterSyncController);
|
|
2344
|
-
if (!(0, _univerjs_ui.useObservable)(sheetsFilterSyncController.visible$, void 0, true)) return null;
|
|
2345
|
-
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
2346
|
-
const messageService = (0, _univerjs_ui.useDependency)(_univerjs_ui.IMessageService);
|
|
2347
|
-
const enabled = (0, _univerjs_ui.useObservable)(sheetsFilterSyncController.enabled$, void 0, true);
|
|
2348
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2349
|
-
className: "univer-mt-2 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",
|
|
2350
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2351
|
-
className: "univer-flex univer-items-center univer-gap-1",
|
|
2352
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: localeService.t("sheets-filter-ui.sync.title") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Tooltip, {
|
|
2353
|
-
title: enabled ? localeService.t("sheets-filter-ui.sync.statusTips.off") : localeService.t("sheets-filter-ui.sync.statusTips.on"),
|
|
2354
|
-
asChild: true,
|
|
2355
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.InfoIcon, { className: "univer-block" })
|
|
2356
|
-
})]
|
|
2357
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Switch, {
|
|
2358
|
-
defaultChecked: enabled,
|
|
2359
|
-
onChange: (checked) => {
|
|
2360
|
-
const message = checked ? localeService.t("sheets-filter-ui.sync.switchTips.on") : localeService.t("sheets-filter-ui.sync.switchTips.off");
|
|
2361
|
-
sheetsFilterSyncController.setEnabled(checked);
|
|
2362
|
-
messageService.show({
|
|
2363
|
-
content: message,
|
|
2364
|
-
type: _univerjs_design.MessageType.Success,
|
|
2365
|
-
duration: 2e3
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
})]
|
|
2369
|
-
});
|
|
2370
|
-
}
|
|
2387
|
+
//#region src/controllers/ui-mobile.controller.ts
|
|
2388
|
+
let SheetsFilterUIMobileController = class SheetsFilterUIMobileController extends _univerjs_core.RxDisposable {
|
|
2389
|
+
constructor(_renderManagerService, _sheetsRenderService) {
|
|
2390
|
+
super();
|
|
2391
|
+
this._renderManagerService = _renderManagerService;
|
|
2392
|
+
this._sheetsRenderService = _sheetsRenderService;
|
|
2393
|
+
[
|
|
2394
|
+
_univerjs_sheets_filter.SetSheetsFilterRangeMutation,
|
|
2395
|
+
_univerjs_sheets_filter.SetSheetsFilterCriteriaMutation,
|
|
2396
|
+
_univerjs_sheets_filter.RemoveSheetsFilterMutation,
|
|
2397
|
+
_univerjs_sheets_filter.ReCalcSheetsFilterMutation
|
|
2398
|
+
].forEach((m) => this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(m.id)));
|
|
2399
|
+
this.disposeWithMe(this._renderManagerService.registerRenderModule(_univerjs_core.UniverInstanceType.UNIVER_SHEET, [SheetsFilterRenderController]));
|
|
2400
|
+
}
|
|
2401
|
+
};
|
|
2402
|
+
SheetsFilterUIMobileController = __decorate([__decorateParam(0, _univerjs_engine_render.IRenderManagerService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetsRenderService))], SheetsFilterUIMobileController);
|
|
2371
2403
|
|
|
2372
2404
|
//#endregion
|
|
2373
|
-
//#region src/
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
onChange: (value) => onFilterByTypeChange(value)
|
|
2423
|
-
})
|
|
2424
|
-
}),
|
|
2425
|
-
filterByModel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2426
|
-
"data-u-comp": "sheets-filter-panel-content",
|
|
2427
|
-
className: "univer-flex-shrink univer-flex-grow univer-pt-2",
|
|
2428
|
-
children: filterBy === _univerjs_sheets_filter.FilterBy.VALUES ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByValue, { model: filterByModel }) : filterBy === _univerjs_sheets_filter.FilterBy.COLORS ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByColor, { model: filterByModel }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterByCondition, { model: filterByModel })
|
|
2429
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "univer-flex-1" }),
|
|
2430
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterSyncSwitch, {}),
|
|
2431
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2432
|
-
"data-u-comp": "sheets-filter-panel-footer",
|
|
2433
|
-
className: "univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden",
|
|
2434
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
2435
|
-
variant: "link",
|
|
2436
|
-
onClick: onClearCriteria,
|
|
2437
|
-
disabled: clearFilterDisabled,
|
|
2438
|
-
children: localeService.t("sheets-filter-ui.panel.clear-filter")
|
|
2439
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2440
|
-
className: "univer-flex univer-gap-2",
|
|
2441
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
2442
|
-
variant: "default",
|
|
2443
|
-
onClick: onCancel,
|
|
2444
|
-
children: localeService.t("sheets-filter-ui.panel.cancel")
|
|
2445
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
2446
|
-
disabled: !canApply,
|
|
2447
|
-
variant: "primary",
|
|
2448
|
-
onClick: onApply,
|
|
2449
|
-
children: localeService.t("sheets-filter-ui.panel.confirm")
|
|
2450
|
-
})]
|
|
2451
|
-
})]
|
|
2452
|
-
})
|
|
2453
|
-
]
|
|
2454
|
-
});
|
|
2405
|
+
//#region src/mobile-plugin.ts
|
|
2406
|
+
let UniverSheetsFilterMobileUIPlugin = class UniverSheetsFilterMobileUIPlugin extends _univerjs_core.Plugin {
|
|
2407
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
2408
|
+
super();
|
|
2409
|
+
this._config = _config;
|
|
2410
|
+
this._injector = _injector;
|
|
2411
|
+
this._configService = _configService;
|
|
2412
|
+
const { menu, ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
2413
|
+
if (menu) this._configService.setConfig("menu", menu, { merge: true });
|
|
2414
|
+
this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
|
|
2415
|
+
}
|
|
2416
|
+
onStarting() {
|
|
2417
|
+
this._injector.add([ComponentsController]);
|
|
2418
|
+
this._injector.get(ComponentsController);
|
|
2419
|
+
[[SheetsFilterPermissionController], [SheetsFilterUIMobileController]].forEach((d) => this._injector.add(d));
|
|
2420
|
+
}
|
|
2421
|
+
onReady() {
|
|
2422
|
+
this._injector.get(SheetsFilterPermissionController);
|
|
2423
|
+
}
|
|
2424
|
+
onRendered() {
|
|
2425
|
+
this._injector.get(SheetsFilterUIMobileController);
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
_defineProperty(UniverSheetsFilterMobileUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
2429
|
+
_defineProperty(UniverSheetsFilterMobileUIPlugin, "pluginName", "SHEET_FILTER_UI_PLUGIN");
|
|
2430
|
+
_defineProperty(UniverSheetsFilterMobileUIPlugin, "packageName", name);
|
|
2431
|
+
_defineProperty(UniverSheetsFilterMobileUIPlugin, "version", version);
|
|
2432
|
+
UniverSheetsFilterMobileUIPlugin = __decorate([
|
|
2433
|
+
(0, _univerjs_core.DependentOn)(_univerjs_sheets_filter.UniverSheetsFilterPlugin),
|
|
2434
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2435
|
+
__decorateParam(2, _univerjs_core.IConfigService)
|
|
2436
|
+
], UniverSheetsFilterMobileUIPlugin);
|
|
2437
|
+
|
|
2438
|
+
//#endregion
|
|
2439
|
+
//#region src/menu/sheets-filter.menu.ts
|
|
2440
|
+
function SmartToggleFilterMenuItemFactory(accessor) {
|
|
2441
|
+
const sheetsFilterService = accessor.get(_univerjs_sheets_filter.SheetsFilterService);
|
|
2442
|
+
return {
|
|
2443
|
+
id: _univerjs_sheets_filter.SmartToggleSheetsFilterCommand.id,
|
|
2444
|
+
type: _univerjs_ui.MenuItemType.BUTTON_SELECTOR,
|
|
2445
|
+
icon: "FilterIcon",
|
|
2446
|
+
tooltip: "sheets-filter-ui.toolbar.smart-toggle-filter-tooltip",
|
|
2447
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2448
|
+
activated$: sheetsFilterService.activeFilterModel$.pipe((0, rxjs.map)((model) => !!model)),
|
|
2449
|
+
disabled$: (0, _univerjs_sheets_ui.getObservableWithExclusiveRange$)(accessor, (0, _univerjs_sheets_ui.getCurrentRangeDisable$)(accessor, {
|
|
2450
|
+
worksheetTypes: [_univerjs_sheets.WorksheetFilterPermission, _univerjs_sheets.WorksheetViewPermission],
|
|
2451
|
+
rangeTypes: [_univerjs_sheets.RangeProtectionPermissionViewPoint]
|
|
2452
|
+
}))
|
|
2453
|
+
};
|
|
2455
2454
|
}
|
|
2456
|
-
function
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2455
|
+
function ClearFilterCriteriaMenuItemFactory(accessor) {
|
|
2456
|
+
const sheetsFilterService = accessor.get(_univerjs_sheets_filter.SheetsFilterService);
|
|
2457
|
+
return {
|
|
2458
|
+
id: _univerjs_sheets_filter.ClearSheetsFilterCriteriaCommand.id,
|
|
2459
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2460
|
+
title: "sheets-filter-ui.toolbar.clear-filter-criteria",
|
|
2461
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2462
|
+
disabled$: sheetsFilterService.activeFilterModel$.pipe((0, rxjs.switchMap)((model) => {
|
|
2463
|
+
var _model$hasCriteria$$p;
|
|
2464
|
+
return (_model$hasCriteria$$p = model === null || model === void 0 ? void 0 : model.hasCriteria$.pipe((0, rxjs.map)((m) => !m))) !== null && _model$hasCriteria$$p !== void 0 ? _model$hasCriteria$$p : (0, rxjs.of)(true);
|
|
2465
|
+
}))
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
function ReCalcFilterMenuItemFactory(accessor) {
|
|
2469
|
+
const sheetsFilterService = accessor.get(_univerjs_sheets_filter.SheetsFilterService);
|
|
2470
|
+
return {
|
|
2471
|
+
id: _univerjs_sheets_filter.ReCalcSheetsFilterCommand.id,
|
|
2472
|
+
type: _univerjs_ui.MenuItemType.BUTTON,
|
|
2473
|
+
title: "sheets-filter-ui.toolbar.re-calc-filter-conditions",
|
|
2474
|
+
hidden$: (0, _univerjs_ui.getMenuHiddenObservable)(accessor, _univerjs_core.UniverInstanceType.UNIVER_SHEET),
|
|
2475
|
+
disabled$: sheetsFilterService.activeFilterModel$.pipe((0, rxjs.switchMap)((model) => {
|
|
2476
|
+
var _model$hasCriteria$$p2;
|
|
2477
|
+
return (_model$hasCriteria$$p2 = model === null || model === void 0 ? void 0 : model.hasCriteria$.pipe((0, rxjs.map)((m) => !m))) !== null && _model$hasCriteria$$p2 !== void 0 ? _model$hasCriteria$$p2 : (0, rxjs.of)(true);
|
|
2478
|
+
}))
|
|
2479
|
+
};
|
|
2471
2480
|
}
|
|
2472
2481
|
|
|
2482
|
+
//#endregion
|
|
2483
|
+
//#region src/menu/schema.ts
|
|
2484
|
+
const menuSchema = { [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [_univerjs_sheets_filter.SmartToggleSheetsFilterCommand.id]: {
|
|
2485
|
+
order: 2,
|
|
2486
|
+
menuItemFactory: SmartToggleFilterMenuItemFactory,
|
|
2487
|
+
[_univerjs_sheets_filter.ClearSheetsFilterCriteriaCommand.id]: {
|
|
2488
|
+
order: 0,
|
|
2489
|
+
menuItemFactory: ClearFilterCriteriaMenuItemFactory
|
|
2490
|
+
},
|
|
2491
|
+
[_univerjs_sheets_filter.ReCalcSheetsFilterCommand.id]: {
|
|
2492
|
+
order: 1,
|
|
2493
|
+
menuItemFactory: ReCalcFilterMenuItemFactory
|
|
2494
|
+
}
|
|
2495
|
+
} } };
|
|
2496
|
+
|
|
2473
2497
|
//#endregion
|
|
2474
2498
|
//#region src/controllers/sheets-filter.shortcut.ts
|
|
2475
2499
|
const SmartToggleFilterShortcut = {
|
|
@@ -2482,13 +2506,11 @@ const SmartToggleFilterShortcut = {
|
|
|
2482
2506
|
};
|
|
2483
2507
|
|
|
2484
2508
|
//#endregion
|
|
2485
|
-
//#region src/controllers/
|
|
2486
|
-
const FILTER_PANEL_POPUP_KEY = "FILTER_PANEL_POPUP";
|
|
2509
|
+
//#region src/controllers/ui.controller.ts
|
|
2487
2510
|
let SheetsFilterUIDesktopController = class SheetsFilterUIDesktopController extends SheetsFilterUIMobileController {
|
|
2488
|
-
constructor(_injector,
|
|
2511
|
+
constructor(_injector, _sheetsFilterPanelService, _sheetCanvasPopupService, _sheetsFilterService, _localeService, _shortcutService, _commandService, _menuManagerService, _contextService, _messageService, sheetsRenderService, renderManagerService) {
|
|
2489
2512
|
super(renderManagerService, sheetsRenderService);
|
|
2490
2513
|
this._injector = _injector;
|
|
2491
|
-
this._componentManager = _componentManager;
|
|
2492
2514
|
this._sheetsFilterPanelService = _sheetsFilterPanelService;
|
|
2493
2515
|
this._sheetCanvasPopupService = _sheetCanvasPopupService;
|
|
2494
2516
|
this._sheetsFilterService = _sheetsFilterService;
|
|
@@ -2527,9 +2549,6 @@ let SheetsFilterUIDesktopController = class SheetsFilterUIDesktopController exte
|
|
|
2527
2549
|
this._menuManagerService.mergeMenu(menuSchema);
|
|
2528
2550
|
}
|
|
2529
2551
|
_initUI() {
|
|
2530
|
-
[[FILTER_PANEL_POPUP_KEY, FilterPanel], ["FilterIcon", _univerjs_icons.FilterIcon]].forEach(([key, comp]) => {
|
|
2531
|
-
this.disposeWithMe(this._componentManager.register(key, comp));
|
|
2532
|
-
});
|
|
2533
2552
|
this.disposeWithMe(this._contextService.subscribeContextValue$(FILTER_PANEL_OPENED_KEY).pipe((0, rxjs.distinctUntilChanged)()).subscribe((open) => {
|
|
2534
2553
|
if (open) this._openFilterPopup();
|
|
2535
2554
|
else this._closeFilterPopup();
|
|
@@ -2562,18 +2581,17 @@ let SheetsFilterUIDesktopController = class SheetsFilterUIDesktopController exte
|
|
|
2562
2581
|
};
|
|
2563
2582
|
SheetsFilterUIDesktopController = __decorate([
|
|
2564
2583
|
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2565
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(
|
|
2566
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(
|
|
2567
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(
|
|
2568
|
-
__decorateParam(4, (0, _univerjs_core.Inject)(
|
|
2569
|
-
__decorateParam(5,
|
|
2570
|
-
__decorateParam(6,
|
|
2571
|
-
__decorateParam(7,
|
|
2572
|
-
__decorateParam(8,
|
|
2573
|
-
__decorateParam(9,
|
|
2574
|
-
__decorateParam(10,
|
|
2575
|
-
__decorateParam(11,
|
|
2576
|
-
__decorateParam(12, _univerjs_engine_render.IRenderManagerService)
|
|
2584
|
+
__decorateParam(1, (0, _univerjs_core.Inject)(SheetsFilterPanelService)),
|
|
2585
|
+
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetCanvasPopManagerService)),
|
|
2586
|
+
__decorateParam(3, (0, _univerjs_core.Inject)(_univerjs_sheets_filter.SheetsFilterService)),
|
|
2587
|
+
__decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
2588
|
+
__decorateParam(5, _univerjs_ui.IShortcutService),
|
|
2589
|
+
__decorateParam(6, _univerjs_core.ICommandService),
|
|
2590
|
+
__decorateParam(7, _univerjs_ui.IMenuManagerService),
|
|
2591
|
+
__decorateParam(8, _univerjs_core.IContextService),
|
|
2592
|
+
__decorateParam(9, _univerjs_ui.IMessageService),
|
|
2593
|
+
__decorateParam(10, (0, _univerjs_core.Inject)(_univerjs_sheets_ui.SheetsRenderService)),
|
|
2594
|
+
__decorateParam(11, _univerjs_engine_render.IRenderManagerService)
|
|
2577
2595
|
], SheetsFilterUIDesktopController);
|
|
2578
2596
|
|
|
2579
2597
|
//#endregion
|
|
@@ -2590,6 +2608,8 @@ let UniverSheetsFilterUIPlugin = class UniverSheetsFilterUIPlugin extends _unive
|
|
|
2590
2608
|
this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
|
|
2591
2609
|
}
|
|
2592
2610
|
onStarting() {
|
|
2611
|
+
this._injector.add([ComponentsController]);
|
|
2612
|
+
this._injector.get(ComponentsController);
|
|
2593
2613
|
(0, _univerjs_core.registerDependencies)(this._injector, [
|
|
2594
2614
|
[SheetsFilterPanelService],
|
|
2595
2615
|
[SheetsFilterPermissionController],
|