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