@univerjs/sheets-filter-ui 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -7
- package/lib/cjs/{worker-CME9bDM7.js → config-CuFgx0Xn.js} +14 -43
- package/lib/cjs/index.js +188 -130
- package/lib/cjs/worker.js +32 -2
- package/lib/{es/worker-VROMWls7.js → config-YTXWTUKa.js} +14 -43
- package/lib/{worker-VROMWls7.js → es/config-YTXWTUKa.js} +14 -43
- package/lib/es/index.js +80 -16
- package/lib/es/worker.js +31 -1
- package/lib/index.js +80 -16
- package/lib/types/index.d.ts +0 -3
- package/lib/umd/index.js +5 -5
- package/lib/worker.js +31 -1
- package/package.json +12 -12
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, ICommandService, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Quantity, RxDisposable, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, fromCallback, merge, registerDependencies, touchDependencies } from "@univerjs/core";
|
|
1
|
+
import { a as _defineProperty, d as __decorateParam, i as version, l as getFilterTreeByValueItems, n as defaultPluginConfig, o as ISheetsGenerateFilterValuesService, r as name, s as SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME, t as SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, u as __decorate } from "./config-YTXWTUKa.js";
|
|
2
|
+
import { BooleanNumber, ColorKit, CommandType, DependentOn, Disposable, ICommandService, IConfigService, IContextService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Quantity, RxDisposable, SheetTypes, ThemeService, Tools, UniverInstanceType, VerticalAlign, createIdentifier, fromCallback, merge, registerDependencies, touchDependencies } from "@univerjs/core";
|
|
3
3
|
import { ClearSheetsFilterCriteriaCommand, CustomFilterOperator, FILTER_MUTATIONS, FilterBy, ReCalcSheetsFilterCommand, ReCalcSheetsFilterMutation, RemoveSheetsFilterMutation, SetSheetsFilterCriteriaCommand, SetSheetsFilterCriteriaMutation, SetSheetsFilterRangeMutation, SheetsFilterService, SheetsFilterSyncController, SmartToggleSheetsFilterCommand, UniverSheetsFilterPlugin } from "@univerjs/sheets-filter";
|
|
4
|
-
import { IEditorBridgeService, ISheetSelectionRenderService, SelectionControl, SetCellEditVisibleOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, SheetsRenderService, SheetsUIPart, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, getCoordByCell, getCurrentRangeDisable$, getObservableWithExclusiveRange$, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
4
|
+
import { IEditorBridgeService, ISheetSelectionRenderService, SelectionControl, SetCellEditVisibleOperation, SheetCanvasPopManagerService, SheetSkeletonManagerService, SheetsRenderService, SheetsUIPart, UniverSheetsMobileUIPlugin, UniverSheetsUIPlugin, deriveStateFromActiveSheet$, getCoordByCell, getCurrentRangeDisable$, getObservableWithExclusiveRange$, whenSheetEditorFocused } from "@univerjs/sheets-ui";
|
|
5
5
|
import { BuiltInUIPart, ComponentContainer, ComponentManager, ILayoutService, IMenuManagerService, IMessageService, IShortcutService, IUIPartsService, IconManager, KeyCode, MenuItemType, MetaKeys, MobileDrawer, RibbonDataGroup, UniverMobileUIPlugin, connectInjector, getMenuHiddenObservable, useComponentsOfPart, useDependency, useObservable } from "@univerjs/ui";
|
|
6
6
|
import { COLOR_BLACK_RGB, IRenderManagerService, Rect, Shape, UniverRenderEnginePlugin } from "@univerjs/engine-render";
|
|
7
7
|
import { INTERCEPTOR_POINT, RangeProtectionPermissionViewPoint, RefRangeService, SetRangeValuesMutation, SheetInterceptorService, SheetPermissionCheckController, SheetsSelectionsService, UniverSheetsPlugin, WorksheetFilterPermission, WorksheetViewPermission, attachSelectionWithCoord, expandToContinuousRange, getSheetCommandTarget } from "@univerjs/sheets";
|
|
@@ -1289,10 +1289,7 @@ function SmartToggleFilterMenuItemFactory(accessor) {
|
|
|
1289
1289
|
tooltip: "sheets-filter-ui.toolbar.smart-toggle-filter-tooltip",
|
|
1290
1290
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1291
1291
|
activated$: sheetsFilterService.activeFilterModel$.pipe(map((model) => !!model)),
|
|
1292
|
-
disabled$:
|
|
1293
|
-
worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission],
|
|
1294
|
-
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
1295
|
-
}))
|
|
1292
|
+
disabled$: getFilterRangeDisabled$(accessor)
|
|
1296
1293
|
};
|
|
1297
1294
|
}
|
|
1298
1295
|
function ClearFilterCriteriaMenuItemFactory(accessor) {
|
|
@@ -1302,7 +1299,10 @@ function ClearFilterCriteriaMenuItemFactory(accessor) {
|
|
|
1302
1299
|
type: MenuItemType.BUTTON,
|
|
1303
1300
|
title: "sheets-filter-ui.toolbar.clear-filter-criteria",
|
|
1304
1301
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1305
|
-
disabled$:
|
|
1302
|
+
disabled$: deriveStateFromActiveSheet$(accessor.get(IUniverInstanceService), true, ({ worksheet }) => {
|
|
1303
|
+
if (worksheet.getConfig().type === SheetTypes.CHART) return of(true);
|
|
1304
|
+
return sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => (model === null || model === void 0 ? void 0 : model.hasCriteria$.pipe(map((hasCriteria) => !hasCriteria))) ?? of(true)));
|
|
1305
|
+
})
|
|
1306
1306
|
};
|
|
1307
1307
|
}
|
|
1308
1308
|
function ReCalcFilterMenuItemFactory(accessor) {
|
|
@@ -1312,9 +1312,18 @@ function ReCalcFilterMenuItemFactory(accessor) {
|
|
|
1312
1312
|
type: MenuItemType.BUTTON,
|
|
1313
1313
|
title: "sheets-filter-ui.toolbar.re-calc-filter-conditions",
|
|
1314
1314
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1315
|
-
disabled$:
|
|
1315
|
+
disabled$: deriveStateFromActiveSheet$(accessor.get(IUniverInstanceService), true, ({ worksheet }) => {
|
|
1316
|
+
if (worksheet.getConfig().type === SheetTypes.CHART) return of(true);
|
|
1317
|
+
return sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => (model === null || model === void 0 ? void 0 : model.hasCriteria$.pipe(map((hasCriteria) => !hasCriteria))) ?? of(true)));
|
|
1318
|
+
})
|
|
1316
1319
|
};
|
|
1317
1320
|
}
|
|
1321
|
+
function getFilterRangeDisabled$(accessor) {
|
|
1322
|
+
return getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, {
|
|
1323
|
+
worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission],
|
|
1324
|
+
rangeTypes: [RangeProtectionPermissionViewPoint]
|
|
1325
|
+
}));
|
|
1326
|
+
}
|
|
1318
1327
|
|
|
1319
1328
|
// src/menu/schema.ts
|
|
1320
1329
|
const menuSchema = { [RibbonDataGroup.ORGANIZATION]: { [SmartToggleSheetsFilterCommand.id]: {
|
|
@@ -1464,6 +1473,21 @@ function MobileFilterByColor(props) {
|
|
|
1464
1473
|
}
|
|
1465
1474
|
|
|
1466
1475
|
// src/views/mobile/MobileFilterByCondition.tsx
|
|
1476
|
+
/**
|
|
1477
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1478
|
+
*
|
|
1479
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1480
|
+
* you may not use this file except in compliance with the License.
|
|
1481
|
+
* You may obtain a copy of the License at
|
|
1482
|
+
*
|
|
1483
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1484
|
+
*
|
|
1485
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1486
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1487
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1488
|
+
* See the License for the specific language governing permissions and
|
|
1489
|
+
* limitations under the License.
|
|
1490
|
+
*/
|
|
1467
1491
|
function MobileFilterByCondition(props) {
|
|
1468
1492
|
const { model } = props;
|
|
1469
1493
|
const localeService = useDependency(LocaleService);
|
|
@@ -1493,12 +1517,14 @@ function MobileFilterByCondition(props) {
|
|
|
1493
1517
|
/* @__PURE__ */ jsx(MobileSelect, {
|
|
1494
1518
|
value: operator,
|
|
1495
1519
|
options: secondaryOptions,
|
|
1496
|
-
onChange: (nextOperator) => model.onConditionFormChange({ [name]: nextOperator })
|
|
1520
|
+
onChange: (nextOperator) => model.onConditionFormChange({ [name]: nextOperator }),
|
|
1521
|
+
size: "small"
|
|
1497
1522
|
}),
|
|
1498
1523
|
needsValue && /* @__PURE__ */ jsx(Input, {
|
|
1499
1524
|
value,
|
|
1500
1525
|
placeholder: localeService.t("sheets-filter-ui.panel.input-values-placeholder"),
|
|
1501
|
-
onChange: (nextValue) => model.onConditionFormChange({ [name === "operator1" ? "val1" : "val2"]: nextValue })
|
|
1526
|
+
onChange: (nextValue) => model.onConditionFormChange({ [name === "operator1" ? "val1" : "val2"]: nextValue }),
|
|
1527
|
+
size: "small"
|
|
1502
1528
|
})
|
|
1503
1529
|
]
|
|
1504
1530
|
});
|
|
@@ -1510,7 +1536,8 @@ function MobileFilterByCondition(props) {
|
|
|
1510
1536
|
condition.numOfParameters === 1 && /* @__PURE__ */ jsx(Input, {
|
|
1511
1537
|
value: formParams.val1 ?? "",
|
|
1512
1538
|
placeholder: localeService.t("sheets-filter-ui.panel.input-values-placeholder"),
|
|
1513
|
-
onChange: (value) => model.onConditionFormChange({ val1: value })
|
|
1539
|
+
onChange: (value) => model.onConditionFormChange({ val1: value }),
|
|
1540
|
+
size: "small"
|
|
1514
1541
|
}),
|
|
1515
1542
|
condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator1, formParams.val1 ?? "", "operator1"),
|
|
1516
1543
|
condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2, formParams.val2 ?? "", "operator2"),
|
|
@@ -1552,6 +1579,21 @@ function MobileFilterByCondition(props) {
|
|
|
1552
1579
|
}
|
|
1553
1580
|
|
|
1554
1581
|
// src/views/mobile/MobileFilterByValue.tsx
|
|
1582
|
+
/**
|
|
1583
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
1584
|
+
*
|
|
1585
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1586
|
+
* you may not use this file except in compliance with the License.
|
|
1587
|
+
* You may obtain a copy of the License at
|
|
1588
|
+
*
|
|
1589
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1590
|
+
*
|
|
1591
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1592
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1593
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1594
|
+
* See the License for the specific language governing permissions and
|
|
1595
|
+
* limitations under the License.
|
|
1596
|
+
*/
|
|
1555
1597
|
function extractCheckedKeys(items) {
|
|
1556
1598
|
let checkedKeys = [];
|
|
1557
1599
|
items.forEach((item) => {
|
|
@@ -1580,7 +1622,8 @@ function MobileFilterByValue(props) {
|
|
|
1580
1622
|
className: "univer-flex-1",
|
|
1581
1623
|
value: searchText,
|
|
1582
1624
|
placeholder: searchLabel,
|
|
1583
|
-
onChange: (value) => model.setSearchString(value)
|
|
1625
|
+
onChange: (value) => model.setSearchString(value),
|
|
1626
|
+
size: "small"
|
|
1584
1627
|
}), /* @__PURE__ */ jsx("button", {
|
|
1585
1628
|
type: "button",
|
|
1586
1629
|
"aria-label": localeService.t("sheets-filter-ui.panel.cancel"),
|
|
@@ -1594,7 +1637,7 @@ function MobileFilterByValue(props) {
|
|
|
1594
1637
|
},
|
|
1595
1638
|
children: /* @__PURE__ */ jsx(CloseIcon, { className: "univer-size-5" })
|
|
1596
1639
|
})] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Checkbox, {
|
|
1597
|
-
className: "univer-
|
|
1640
|
+
className: "univer-flex-1",
|
|
1598
1641
|
contentClassName: "univer-flex univer-items-center univer-gap-1",
|
|
1599
1642
|
indeterminate,
|
|
1600
1643
|
disabled: items.length === 0,
|
|
@@ -1667,6 +1710,7 @@ function MobileFilterSyncSwitch() {
|
|
|
1667
1710
|
children: localeService.t(enabled ? "sheets-filter-ui.sync.statusTips.on" : "sheets-filter-ui.sync.statusTips.off")
|
|
1668
1711
|
})]
|
|
1669
1712
|
}), /* @__PURE__ */ jsx(Switch, {
|
|
1713
|
+
"aria-label": localeService.t("sheets-filter-ui.sync.title"),
|
|
1670
1714
|
defaultChecked: enabled,
|
|
1671
1715
|
onChange: (checked) => {
|
|
1672
1716
|
filterSyncController.setEnabled(checked);
|
|
@@ -1763,11 +1807,13 @@ function MobileSheetsFilterPanelContent() {
|
|
|
1763
1807
|
className: "univer-shrink-0 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-p-4 dark:!univer-border-gray-700",
|
|
1764
1808
|
children: /* @__PURE__ */ jsxs(MobileActionRowGroup, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1765
1809
|
onClick: () => closePanel().catch(() => void 0),
|
|
1810
|
+
size: "middle",
|
|
1766
1811
|
children: localeService.t("sheets-filter-ui.panel.cancel")
|
|
1767
1812
|
}), /* @__PURE__ */ jsx(Button, {
|
|
1768
1813
|
variant: "primary",
|
|
1769
1814
|
disabled: !canApply || !filterByModel,
|
|
1770
1815
|
onClick: () => applyFilter().catch(() => void 0),
|
|
1816
|
+
size: "middle",
|
|
1771
1817
|
children: localeService.t("sheets-filter-ui.panel.confirm")
|
|
1772
1818
|
})] })
|
|
1773
1819
|
}) : void 0,
|
|
@@ -1783,10 +1829,12 @@ function MobileSheetsFilterPanelContent() {
|
|
|
1783
1829
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
1784
1830
|
disabled: !filterRange || col <= filterRange.startColumn,
|
|
1785
1831
|
onClick: () => changeColumn(-1),
|
|
1832
|
+
size: "middle",
|
|
1786
1833
|
children: localeService.t("sheets-filter-ui.panel.mobile.previous-column")
|
|
1787
1834
|
}), /* @__PURE__ */ jsx(Button, {
|
|
1788
1835
|
disabled: !filterRange || col >= filterRange.endColumn,
|
|
1789
1836
|
onClick: () => changeColumn(1),
|
|
1837
|
+
size: "middle",
|
|
1790
1838
|
children: localeService.t("sheets-filter-ui.panel.mobile.next-column")
|
|
1791
1839
|
})]
|
|
1792
1840
|
})]
|
|
@@ -1816,7 +1864,7 @@ function MobileSheetsFilterPanelContent() {
|
|
|
1816
1864
|
}),
|
|
1817
1865
|
/* @__PURE__ */ jsx(MobileFilterSyncSwitch, {}),
|
|
1818
1866
|
/* @__PURE__ */ jsx(Button, {
|
|
1819
|
-
size: "
|
|
1867
|
+
size: "middle",
|
|
1820
1868
|
disabled: !hasCriteria || !filterByModel,
|
|
1821
1869
|
onClick: () => clearFilter().catch(() => void 0),
|
|
1822
1870
|
children: localeService.t("sheets-filter-ui.panel.clear-filter")
|
|
@@ -2549,6 +2597,21 @@ function FilterByValue(props) {
|
|
|
2549
2597
|
}
|
|
2550
2598
|
|
|
2551
2599
|
// src/views/components/SheetsFilterSyncSwitch.tsx
|
|
2600
|
+
/**
|
|
2601
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2602
|
+
*
|
|
2603
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2604
|
+
* you may not use this file except in compliance with the License.
|
|
2605
|
+
* You may obtain a copy of the License at
|
|
2606
|
+
*
|
|
2607
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2608
|
+
*
|
|
2609
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2610
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2611
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2612
|
+
* See the License for the specific language governing permissions and
|
|
2613
|
+
* limitations under the License.
|
|
2614
|
+
*/
|
|
2552
2615
|
function FilterSyncSwitch() {
|
|
2553
2616
|
const sheetsFilterSyncController = useDependency(SheetsFilterSyncController);
|
|
2554
2617
|
const visible = useObservable(sheetsFilterSyncController.visible$, void 0, true);
|
|
@@ -2566,6 +2629,7 @@ function FilterSyncSwitch() {
|
|
|
2566
2629
|
children: /* @__PURE__ */ jsx(InfoIcon, { className: "univer-block" })
|
|
2567
2630
|
})]
|
|
2568
2631
|
}), /* @__PURE__ */ jsx(Switch, {
|
|
2632
|
+
"aria-label": localeService.t("sheets-filter-ui.sync.title"),
|
|
2569
2633
|
defaultChecked: enabled,
|
|
2570
2634
|
onChange: (checked) => {
|
|
2571
2635
|
const message = checked ? localeService.t("sheets-filter-ui.sync.switchTips.on") : localeService.t("sheets-filter-ui.sync.switchTips.off");
|
|
@@ -2865,4 +2929,4 @@ UniverSheetsFilterUIPlugin = __decorate([
|
|
|
2865
2929
|
__decorateParam(3, Optional(IRPCChannelService))
|
|
2866
2930
|
], UniverSheetsFilterUIPlugin);
|
|
2867
2931
|
|
|
2868
|
-
export { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOperation, menuSchema as SheetsFilterUIMenuSchema, UniverSheetsFilterMobileUIPlugin, UniverSheetsFilterUIPlugin
|
|
2932
|
+
export { ChangeFilterByOperation, CloseFilterPanelOperation, OpenFilterPanelOperation, menuSchema as SheetsFilterUIMenuSchema, UniverSheetsFilterMobileUIPlugin, UniverSheetsFilterUIPlugin };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -20,6 +20,3 @@ export type { IUniverSheetsFilterUIConfig } from './config/config';
|
|
|
20
20
|
export { menuSchema as SheetsFilterUIMenuSchema } from './menu/schema';
|
|
21
21
|
export { UniverSheetsFilterMobileUIPlugin } from './mobile-plugin';
|
|
22
22
|
export { UniverSheetsFilterUIPlugin } from './plugin';
|
|
23
|
-
export {
|
|
24
|
-
/** @deprecated Import from '@univerjs/sheets-filter-ui/worker' instead. This root export will be removed in the next release. */
|
|
25
|
-
UniverSheetsFilterUIWorkerPlugin, } from './worker';
|