@univerjs/sheets-filter-ui 1.0.0-rc.0 → 1.0.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 +44 -23
- package/lib/cjs/locale/ar-SA.js +0 -1
- package/lib/cjs/locale/ca-ES.js +0 -1
- package/lib/cjs/locale/de-DE.js +0 -1
- package/lib/cjs/locale/en-US.js +0 -1
- package/lib/cjs/locale/es-ES.js +0 -1
- package/lib/cjs/locale/fa-IR.js +0 -1
- package/lib/cjs/locale/fr-FR.js +0 -1
- package/lib/cjs/locale/id-ID.js +0 -1
- package/lib/cjs/locale/it-IT.js +0 -1
- package/lib/cjs/locale/ja-JP.js +0 -1
- package/lib/cjs/locale/ko-KR.js +0 -1
- package/lib/cjs/locale/pl-PL.js +0 -1
- package/lib/cjs/locale/pt-BR.js +0 -1
- package/lib/cjs/locale/ru-RU.js +0 -1
- package/lib/cjs/locale/sk-SK.js +0 -1
- package/lib/cjs/locale/vi-VN.js +0 -1
- package/lib/cjs/locale/zh-CN.js +0 -1
- package/lib/cjs/locale/zh-HK.js +0 -1
- package/lib/cjs/locale/zh-TW.js +0 -1
- package/lib/es/index.js +44 -23
- package/lib/index.js +44 -23
- package/lib/types/__testing__/data.d.ts +87 -0
- package/lib/types/controllers/sheets-filter-ui-desktop.controller.d.ts +48 -0
- package/lib/types/controllers/sheets-filter-ui-mobile.controller.d.ts +23 -0
- package/lib/types/menu/mobile-schema.d.ts +17 -0
- package/lib/umd/index.js +5 -5
- package/package.json +13 -13
package/lib/cjs/index.js
CHANGED
|
@@ -580,12 +580,14 @@ function statisticFilterByValueItems(items) {
|
|
|
580
580
|
let checked = 0;
|
|
581
581
|
let unchecked = 0;
|
|
582
582
|
function traverse(node) {
|
|
583
|
-
if (node.leaf)
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
583
|
+
if (node.leaf) {
|
|
584
|
+
if (node.checked) {
|
|
585
|
+
checkedItems.push(node);
|
|
586
|
+
checked += node.count;
|
|
587
|
+
} else {
|
|
588
|
+
uncheckedItems.push(node);
|
|
589
|
+
unchecked += node.count;
|
|
590
|
+
}
|
|
589
591
|
}
|
|
590
592
|
if (node.children) node.children.forEach(traverse);
|
|
591
593
|
}
|
|
@@ -599,7 +601,7 @@ function statisticFilterByValueItems(items) {
|
|
|
599
601
|
}
|
|
600
602
|
|
|
601
603
|
//#endregion
|
|
602
|
-
//#region \0@oxc-project+runtime@0.
|
|
604
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
603
605
|
function __decorateParam(paramIndex, decorator) {
|
|
604
606
|
return function(target, key) {
|
|
605
607
|
decorator(target, key, paramIndex);
|
|
@@ -607,7 +609,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
607
609
|
}
|
|
608
610
|
|
|
609
611
|
//#endregion
|
|
610
|
-
//#region \0@oxc-project+runtime@0.
|
|
612
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
611
613
|
function __decorate(decorators, target, key, desc) {
|
|
612
614
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
613
615
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -811,8 +813,10 @@ function areAllLeafNodesChecked(node) {
|
|
|
811
813
|
return node.children ? node.children.every((child) => areAllLeafNodesChecked(child)) : true;
|
|
812
814
|
}
|
|
813
815
|
function updateLeafNodesCheckedStatus(node, status) {
|
|
814
|
-
if (node.leaf)
|
|
815
|
-
|
|
816
|
+
if (node.leaf) {
|
|
817
|
+
if (status !== void 0) node.checked = status;
|
|
818
|
+
else node.checked = !node.checked;
|
|
819
|
+
}
|
|
816
820
|
if (node.children) node.children.forEach((child) => updateLeafNodesCheckedStatus(child, status));
|
|
817
821
|
}
|
|
818
822
|
function searchTree(items, searchKeywords) {
|
|
@@ -837,7 +841,7 @@ function searchTree(items, searchKeywords) {
|
|
|
837
841
|
}
|
|
838
842
|
|
|
839
843
|
//#endregion
|
|
840
|
-
//#region \0@oxc-project+runtime@0.
|
|
844
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
841
845
|
function _typeof(o) {
|
|
842
846
|
"@babel/helpers - typeof";
|
|
843
847
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -848,7 +852,7 @@ function _typeof(o) {
|
|
|
848
852
|
}
|
|
849
853
|
|
|
850
854
|
//#endregion
|
|
851
|
-
//#region \0@oxc-project+runtime@0.
|
|
855
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
852
856
|
function toPrimitive(t, r) {
|
|
853
857
|
if ("object" != _typeof(t) || !t) return t;
|
|
854
858
|
var e = t[Symbol.toPrimitive];
|
|
@@ -861,14 +865,14 @@ function toPrimitive(t, r) {
|
|
|
861
865
|
}
|
|
862
866
|
|
|
863
867
|
//#endregion
|
|
864
|
-
//#region \0@oxc-project+runtime@0.
|
|
868
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
865
869
|
function toPropertyKey(t) {
|
|
866
870
|
var i = toPrimitive(t, "string");
|
|
867
871
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
868
872
|
}
|
|
869
873
|
|
|
870
874
|
//#endregion
|
|
871
|
-
//#region \0@oxc-project+runtime@0.
|
|
875
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
872
876
|
function _defineProperty(e, r, t) {
|
|
873
877
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
874
878
|
value: t,
|
|
@@ -960,9 +964,7 @@ let SheetsFilterPanelService = class SheetsFilterPanelService extends _univerjs_
|
|
|
960
964
|
case _univerjs_sheets_filter.FilterBy.COLORS:
|
|
961
965
|
this._setupByColors(this._filterModel, this.col);
|
|
962
966
|
break;
|
|
963
|
-
case _univerjs_sheets_filter.FilterBy.CONDITIONS:
|
|
964
|
-
this._setupByConditions(this._filterModel, this.col);
|
|
965
|
-
break;
|
|
967
|
+
case _univerjs_sheets_filter.FilterBy.CONDITIONS: this._setupByConditions(this._filterModel, this.col);
|
|
966
968
|
}
|
|
967
969
|
return true;
|
|
968
970
|
}
|
|
@@ -1221,7 +1223,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends _univerjs_core.
|
|
|
1221
1223
|
trailing: true
|
|
1222
1224
|
}), (0, rxjs.startWith)(void 0)), this._rawFilterItems$]).pipe((0, rxjs.map)(([searchString, items]) => {
|
|
1223
1225
|
if (!searchString) return items;
|
|
1224
|
-
|
|
1226
|
+
const searchKeyWords = searchString.toLowerCase().split(/\s+/).filter((s) => !!s);
|
|
1227
|
+
return searchTree(items, searchKeyWords);
|
|
1225
1228
|
})), this._manuallyUpdateFilterItems$).pipe((0, rxjs.shareReplay)({
|
|
1226
1229
|
bufferSize: 1,
|
|
1227
1230
|
refCount: true
|
|
@@ -1253,7 +1256,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends _univerjs_core.
|
|
|
1253
1256
|
const items = _univerjs_core.Tools.deepClone(this._filterItems);
|
|
1254
1257
|
const changedItem = findObjectByKey(items, item.key);
|
|
1255
1258
|
if (!changedItem) return;
|
|
1256
|
-
|
|
1259
|
+
const allLeafChecked = areAllLeafNodesChecked(changedItem);
|
|
1260
|
+
updateLeafNodesCheckedStatus(changedItem, !allLeafChecked);
|
|
1257
1261
|
this._manuallyUpdateFilterItems(items);
|
|
1258
1262
|
}
|
|
1259
1263
|
onFilterOnly(itemKeys) {
|
|
@@ -1577,7 +1581,7 @@ const menuSchema = { [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [_univerjs_s
|
|
|
1577
1581
|
//#endregion
|
|
1578
1582
|
//#region package.json
|
|
1579
1583
|
var name = "@univerjs/sheets-filter-ui";
|
|
1580
|
-
var version = "1.0.0
|
|
1584
|
+
var version = "1.0.0";
|
|
1581
1585
|
|
|
1582
1586
|
//#endregion
|
|
1583
1587
|
//#region src/config/config.ts
|
|
@@ -1585,6 +1589,21 @@ const SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY = "sheets-filter-ui.config";
|
|
|
1585
1589
|
const configSymbol = Symbol(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY);
|
|
1586
1590
|
const defaultPluginConfig = {};
|
|
1587
1591
|
|
|
1592
|
+
//#endregion
|
|
1593
|
+
//#region src/menu/mobile-schema.ts
|
|
1594
|
+
const mobileMenuSchema = { [_univerjs_ui.RibbonDataGroup.ORGANIZATION]: { [_univerjs_sheets_filter.SmartToggleSheetsFilterCommand.id]: {
|
|
1595
|
+
order: 2,
|
|
1596
|
+
menuItemFactory: SmartToggleFilterMenuItemFactory,
|
|
1597
|
+
[_univerjs_sheets_filter.ClearSheetsFilterCriteriaCommand.id]: {
|
|
1598
|
+
order: 0,
|
|
1599
|
+
menuItemFactory: ClearFilterCriteriaMenuItemFactory
|
|
1600
|
+
},
|
|
1601
|
+
[_univerjs_sheets_filter.ReCalcSheetsFilterCommand.id]: {
|
|
1602
|
+
order: 1,
|
|
1603
|
+
menuItemFactory: ReCalcFilterMenuItemFactory
|
|
1604
|
+
}
|
|
1605
|
+
} } };
|
|
1606
|
+
|
|
1588
1607
|
//#endregion
|
|
1589
1608
|
//#region src/controllers/mobile-menu.controller.ts
|
|
1590
1609
|
/**
|
|
@@ -1606,7 +1625,7 @@ let SheetsFilterMobileMenuController = class SheetsFilterMobileMenuController ex
|
|
|
1606
1625
|
constructor(commandService, menuManagerService) {
|
|
1607
1626
|
super();
|
|
1608
1627
|
this.disposeWithMe(commandService.registerCommand(_univerjs_sheets_filter.SmartToggleSheetsFilterCommand));
|
|
1609
|
-
menuManagerService.mergeMenu(
|
|
1628
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
1610
1629
|
}
|
|
1611
1630
|
};
|
|
1612
1631
|
SheetsFilterMobileMenuController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, _univerjs_ui.IMenuManagerService)], SheetsFilterMobileMenuController);
|
|
@@ -2402,7 +2421,8 @@ let SheetsFilterPermissionController = class SheetsFilterPermissionController ex
|
|
|
2402
2421
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
2403
2422
|
if (command.id === _univerjs_sheets_filter.SmartToggleSheetsFilterCommand.id) {
|
|
2404
2423
|
var _this$_sheetsFilterSe;
|
|
2405
|
-
const
|
|
2424
|
+
const univerInstanceService = this._injector.get(_univerjs_core.IUniverInstanceService);
|
|
2425
|
+
const target = (0, _univerjs_sheets.getSheetCommandTarget)(univerInstanceService);
|
|
2406
2426
|
if (!target) return;
|
|
2407
2427
|
const { unitId, subUnitId, worksheet } = target;
|
|
2408
2428
|
const filterRange = (_this$_sheetsFilterSe = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe === void 0 ? void 0 : _this$_sheetsFilterSe.getRange();
|
|
@@ -2867,12 +2887,13 @@ function FilterPanel() {
|
|
|
2867
2887
|
}, [filterByModel, commandService]);
|
|
2868
2888
|
const range = (_filterService$active = (0, _univerjs_ui.useDependency)(_univerjs_sheets_filter.SheetsFilterService).activeFilterModel) === null || _filterService$active === void 0 ? void 0 : _filterService$active.getRange();
|
|
2869
2889
|
const colIndex = sheetsFilterPanelService.col;
|
|
2890
|
+
const FilterPanelEmbedPointPart = (0, _univerjs_ui.useComponentsOfPart)(_univerjs_sheets_ui.SheetsUIPart.FILTER_PANEL_EMBED_POINT);
|
|
2870
2891
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2871
2892
|
"data-u-comp": "sheets-filter-panel",
|
|
2872
2893
|
className: "univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
2873
2894
|
children: [
|
|
2874
2895
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_ui.ComponentContainer, {
|
|
2875
|
-
components:
|
|
2896
|
+
components: FilterPanelEmbedPointPart,
|
|
2876
2897
|
sharedProps: {
|
|
2877
2898
|
range,
|
|
2878
2899
|
colIndex,
|
package/lib/cjs/locale/ar-SA.js
CHANGED
package/lib/cjs/locale/ca-ES.js
CHANGED
package/lib/cjs/locale/de-DE.js
CHANGED
package/lib/cjs/locale/en-US.js
CHANGED
package/lib/cjs/locale/es-ES.js
CHANGED
package/lib/cjs/locale/fa-IR.js
CHANGED
package/lib/cjs/locale/fr-FR.js
CHANGED
package/lib/cjs/locale/id-ID.js
CHANGED
package/lib/cjs/locale/it-IT.js
CHANGED
package/lib/cjs/locale/ja-JP.js
CHANGED
package/lib/cjs/locale/ko-KR.js
CHANGED
package/lib/cjs/locale/pl-PL.js
CHANGED
package/lib/cjs/locale/pt-BR.js
CHANGED
package/lib/cjs/locale/ru-RU.js
CHANGED
package/lib/cjs/locale/sk-SK.js
CHANGED
package/lib/cjs/locale/vi-VN.js
CHANGED
package/lib/cjs/locale/zh-CN.js
CHANGED
package/lib/cjs/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/index.js
CHANGED
|
@@ -579,12 +579,14 @@ function statisticFilterByValueItems(items) {
|
|
|
579
579
|
let checked = 0;
|
|
580
580
|
let unchecked = 0;
|
|
581
581
|
function traverse(node) {
|
|
582
|
-
if (node.leaf)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
582
|
+
if (node.leaf) {
|
|
583
|
+
if (node.checked) {
|
|
584
|
+
checkedItems.push(node);
|
|
585
|
+
checked += node.count;
|
|
586
|
+
} else {
|
|
587
|
+
uncheckedItems.push(node);
|
|
588
|
+
unchecked += node.count;
|
|
589
|
+
}
|
|
588
590
|
}
|
|
589
591
|
if (node.children) node.children.forEach(traverse);
|
|
590
592
|
}
|
|
@@ -598,7 +600,7 @@ function statisticFilterByValueItems(items) {
|
|
|
598
600
|
}
|
|
599
601
|
|
|
600
602
|
//#endregion
|
|
601
|
-
//#region \0@oxc-project+runtime@0.
|
|
603
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
602
604
|
function __decorateParam(paramIndex, decorator) {
|
|
603
605
|
return function(target, key) {
|
|
604
606
|
decorator(target, key, paramIndex);
|
|
@@ -606,7 +608,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
606
608
|
}
|
|
607
609
|
|
|
608
610
|
//#endregion
|
|
609
|
-
//#region \0@oxc-project+runtime@0.
|
|
611
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
610
612
|
function __decorate(decorators, target, key, desc) {
|
|
611
613
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
612
614
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -810,8 +812,10 @@ function areAllLeafNodesChecked(node) {
|
|
|
810
812
|
return node.children ? node.children.every((child) => areAllLeafNodesChecked(child)) : true;
|
|
811
813
|
}
|
|
812
814
|
function updateLeafNodesCheckedStatus(node, status) {
|
|
813
|
-
if (node.leaf)
|
|
814
|
-
|
|
815
|
+
if (node.leaf) {
|
|
816
|
+
if (status !== void 0) node.checked = status;
|
|
817
|
+
else node.checked = !node.checked;
|
|
818
|
+
}
|
|
815
819
|
if (node.children) node.children.forEach((child) => updateLeafNodesCheckedStatus(child, status));
|
|
816
820
|
}
|
|
817
821
|
function searchTree(items, searchKeywords) {
|
|
@@ -836,7 +840,7 @@ function searchTree(items, searchKeywords) {
|
|
|
836
840
|
}
|
|
837
841
|
|
|
838
842
|
//#endregion
|
|
839
|
-
//#region \0@oxc-project+runtime@0.
|
|
843
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
840
844
|
function _typeof(o) {
|
|
841
845
|
"@babel/helpers - typeof";
|
|
842
846
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -847,7 +851,7 @@ function _typeof(o) {
|
|
|
847
851
|
}
|
|
848
852
|
|
|
849
853
|
//#endregion
|
|
850
|
-
//#region \0@oxc-project+runtime@0.
|
|
854
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
851
855
|
function toPrimitive(t, r) {
|
|
852
856
|
if ("object" != _typeof(t) || !t) return t;
|
|
853
857
|
var e = t[Symbol.toPrimitive];
|
|
@@ -860,14 +864,14 @@ function toPrimitive(t, r) {
|
|
|
860
864
|
}
|
|
861
865
|
|
|
862
866
|
//#endregion
|
|
863
|
-
//#region \0@oxc-project+runtime@0.
|
|
867
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
864
868
|
function toPropertyKey(t) {
|
|
865
869
|
var i = toPrimitive(t, "string");
|
|
866
870
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
867
871
|
}
|
|
868
872
|
|
|
869
873
|
//#endregion
|
|
870
|
-
//#region \0@oxc-project+runtime@0.
|
|
874
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
871
875
|
function _defineProperty(e, r, t) {
|
|
872
876
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
873
877
|
value: t,
|
|
@@ -959,9 +963,7 @@ let SheetsFilterPanelService = class SheetsFilterPanelService extends Disposable
|
|
|
959
963
|
case FilterBy.COLORS:
|
|
960
964
|
this._setupByColors(this._filterModel, this.col);
|
|
961
965
|
break;
|
|
962
|
-
case FilterBy.CONDITIONS:
|
|
963
|
-
this._setupByConditions(this._filterModel, this.col);
|
|
964
|
-
break;
|
|
966
|
+
case FilterBy.CONDITIONS: this._setupByConditions(this._filterModel, this.col);
|
|
965
967
|
}
|
|
966
968
|
return true;
|
|
967
969
|
}
|
|
@@ -1220,7 +1222,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends Disposable {
|
|
|
1220
1222
|
trailing: true
|
|
1221
1223
|
}), startWith(void 0)), this._rawFilterItems$]).pipe(map(([searchString, items]) => {
|
|
1222
1224
|
if (!searchString) return items;
|
|
1223
|
-
|
|
1225
|
+
const searchKeyWords = searchString.toLowerCase().split(/\s+/).filter((s) => !!s);
|
|
1226
|
+
return searchTree(items, searchKeyWords);
|
|
1224
1227
|
})), this._manuallyUpdateFilterItems$).pipe(shareReplay({
|
|
1225
1228
|
bufferSize: 1,
|
|
1226
1229
|
refCount: true
|
|
@@ -1252,7 +1255,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends Disposable {
|
|
|
1252
1255
|
const items = Tools.deepClone(this._filterItems);
|
|
1253
1256
|
const changedItem = findObjectByKey(items, item.key);
|
|
1254
1257
|
if (!changedItem) return;
|
|
1255
|
-
|
|
1258
|
+
const allLeafChecked = areAllLeafNodesChecked(changedItem);
|
|
1259
|
+
updateLeafNodesCheckedStatus(changedItem, !allLeafChecked);
|
|
1256
1260
|
this._manuallyUpdateFilterItems(items);
|
|
1257
1261
|
}
|
|
1258
1262
|
onFilterOnly(itemKeys) {
|
|
@@ -1576,7 +1580,7 @@ const menuSchema = { [RibbonDataGroup.ORGANIZATION]: { [SmartToggleSheetsFilterC
|
|
|
1576
1580
|
//#endregion
|
|
1577
1581
|
//#region package.json
|
|
1578
1582
|
var name = "@univerjs/sheets-filter-ui";
|
|
1579
|
-
var version = "1.0.0
|
|
1583
|
+
var version = "1.0.0";
|
|
1580
1584
|
|
|
1581
1585
|
//#endregion
|
|
1582
1586
|
//#region src/config/config.ts
|
|
@@ -1584,6 +1588,21 @@ const SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY = "sheets-filter-ui.config";
|
|
|
1584
1588
|
const configSymbol = Symbol(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY);
|
|
1585
1589
|
const defaultPluginConfig = {};
|
|
1586
1590
|
|
|
1591
|
+
//#endregion
|
|
1592
|
+
//#region src/menu/mobile-schema.ts
|
|
1593
|
+
const mobileMenuSchema = { [RibbonDataGroup.ORGANIZATION]: { [SmartToggleSheetsFilterCommand.id]: {
|
|
1594
|
+
order: 2,
|
|
1595
|
+
menuItemFactory: SmartToggleFilterMenuItemFactory,
|
|
1596
|
+
[ClearSheetsFilterCriteriaCommand.id]: {
|
|
1597
|
+
order: 0,
|
|
1598
|
+
menuItemFactory: ClearFilterCriteriaMenuItemFactory
|
|
1599
|
+
},
|
|
1600
|
+
[ReCalcSheetsFilterCommand.id]: {
|
|
1601
|
+
order: 1,
|
|
1602
|
+
menuItemFactory: ReCalcFilterMenuItemFactory
|
|
1603
|
+
}
|
|
1604
|
+
} } };
|
|
1605
|
+
|
|
1587
1606
|
//#endregion
|
|
1588
1607
|
//#region src/controllers/mobile-menu.controller.ts
|
|
1589
1608
|
/**
|
|
@@ -1605,7 +1624,7 @@ let SheetsFilterMobileMenuController = class SheetsFilterMobileMenuController ex
|
|
|
1605
1624
|
constructor(commandService, menuManagerService) {
|
|
1606
1625
|
super();
|
|
1607
1626
|
this.disposeWithMe(commandService.registerCommand(SmartToggleSheetsFilterCommand));
|
|
1608
|
-
menuManagerService.mergeMenu(
|
|
1627
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
1609
1628
|
}
|
|
1610
1629
|
};
|
|
1611
1630
|
SheetsFilterMobileMenuController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IMenuManagerService)], SheetsFilterMobileMenuController);
|
|
@@ -2401,7 +2420,8 @@ let SheetsFilterPermissionController = class SheetsFilterPermissionController ex
|
|
|
2401
2420
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
2402
2421
|
if (command.id === SmartToggleSheetsFilterCommand.id) {
|
|
2403
2422
|
var _this$_sheetsFilterSe;
|
|
2404
|
-
const
|
|
2423
|
+
const univerInstanceService = this._injector.get(IUniverInstanceService);
|
|
2424
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
2405
2425
|
if (!target) return;
|
|
2406
2426
|
const { unitId, subUnitId, worksheet } = target;
|
|
2407
2427
|
const filterRange = (_this$_sheetsFilterSe = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe === void 0 ? void 0 : _this$_sheetsFilterSe.getRange();
|
|
@@ -2866,12 +2886,13 @@ function FilterPanel() {
|
|
|
2866
2886
|
}, [filterByModel, commandService]);
|
|
2867
2887
|
const range = (_filterService$active = useDependency(SheetsFilterService).activeFilterModel) === null || _filterService$active === void 0 ? void 0 : _filterService$active.getRange();
|
|
2868
2888
|
const colIndex = sheetsFilterPanelService.col;
|
|
2889
|
+
const FilterPanelEmbedPointPart = useComponentsOfPart(SheetsUIPart.FILTER_PANEL_EMBED_POINT);
|
|
2869
2890
|
return /* @__PURE__ */ jsxs("div", {
|
|
2870
2891
|
"data-u-comp": "sheets-filter-panel",
|
|
2871
2892
|
className: "univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
2872
2893
|
children: [
|
|
2873
2894
|
/* @__PURE__ */ jsx(ComponentContainer, {
|
|
2874
|
-
components:
|
|
2895
|
+
components: FilterPanelEmbedPointPart,
|
|
2875
2896
|
sharedProps: {
|
|
2876
2897
|
range,
|
|
2877
2898
|
colIndex,
|
package/lib/index.js
CHANGED
|
@@ -579,12 +579,14 @@ function statisticFilterByValueItems(items) {
|
|
|
579
579
|
let checked = 0;
|
|
580
580
|
let unchecked = 0;
|
|
581
581
|
function traverse(node) {
|
|
582
|
-
if (node.leaf)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
582
|
+
if (node.leaf) {
|
|
583
|
+
if (node.checked) {
|
|
584
|
+
checkedItems.push(node);
|
|
585
|
+
checked += node.count;
|
|
586
|
+
} else {
|
|
587
|
+
uncheckedItems.push(node);
|
|
588
|
+
unchecked += node.count;
|
|
589
|
+
}
|
|
588
590
|
}
|
|
589
591
|
if (node.children) node.children.forEach(traverse);
|
|
590
592
|
}
|
|
@@ -598,7 +600,7 @@ function statisticFilterByValueItems(items) {
|
|
|
598
600
|
}
|
|
599
601
|
|
|
600
602
|
//#endregion
|
|
601
|
-
//#region \0@oxc-project+runtime@0.
|
|
603
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
602
604
|
function __decorateParam(paramIndex, decorator) {
|
|
603
605
|
return function(target, key) {
|
|
604
606
|
decorator(target, key, paramIndex);
|
|
@@ -606,7 +608,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
606
608
|
}
|
|
607
609
|
|
|
608
610
|
//#endregion
|
|
609
|
-
//#region \0@oxc-project+runtime@0.
|
|
611
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
610
612
|
function __decorate(decorators, target, key, desc) {
|
|
611
613
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
612
614
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -810,8 +812,10 @@ function areAllLeafNodesChecked(node) {
|
|
|
810
812
|
return node.children ? node.children.every((child) => areAllLeafNodesChecked(child)) : true;
|
|
811
813
|
}
|
|
812
814
|
function updateLeafNodesCheckedStatus(node, status) {
|
|
813
|
-
if (node.leaf)
|
|
814
|
-
|
|
815
|
+
if (node.leaf) {
|
|
816
|
+
if (status !== void 0) node.checked = status;
|
|
817
|
+
else node.checked = !node.checked;
|
|
818
|
+
}
|
|
815
819
|
if (node.children) node.children.forEach((child) => updateLeafNodesCheckedStatus(child, status));
|
|
816
820
|
}
|
|
817
821
|
function searchTree(items, searchKeywords) {
|
|
@@ -836,7 +840,7 @@ function searchTree(items, searchKeywords) {
|
|
|
836
840
|
}
|
|
837
841
|
|
|
838
842
|
//#endregion
|
|
839
|
-
//#region \0@oxc-project+runtime@0.
|
|
843
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
840
844
|
function _typeof(o) {
|
|
841
845
|
"@babel/helpers - typeof";
|
|
842
846
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -847,7 +851,7 @@ function _typeof(o) {
|
|
|
847
851
|
}
|
|
848
852
|
|
|
849
853
|
//#endregion
|
|
850
|
-
//#region \0@oxc-project+runtime@0.
|
|
854
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
851
855
|
function toPrimitive(t, r) {
|
|
852
856
|
if ("object" != _typeof(t) || !t) return t;
|
|
853
857
|
var e = t[Symbol.toPrimitive];
|
|
@@ -860,14 +864,14 @@ function toPrimitive(t, r) {
|
|
|
860
864
|
}
|
|
861
865
|
|
|
862
866
|
//#endregion
|
|
863
|
-
//#region \0@oxc-project+runtime@0.
|
|
867
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
864
868
|
function toPropertyKey(t) {
|
|
865
869
|
var i = toPrimitive(t, "string");
|
|
866
870
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
867
871
|
}
|
|
868
872
|
|
|
869
873
|
//#endregion
|
|
870
|
-
//#region \0@oxc-project+runtime@0.
|
|
874
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
871
875
|
function _defineProperty(e, r, t) {
|
|
872
876
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
873
877
|
value: t,
|
|
@@ -959,9 +963,7 @@ let SheetsFilterPanelService = class SheetsFilterPanelService extends Disposable
|
|
|
959
963
|
case FilterBy.COLORS:
|
|
960
964
|
this._setupByColors(this._filterModel, this.col);
|
|
961
965
|
break;
|
|
962
|
-
case FilterBy.CONDITIONS:
|
|
963
|
-
this._setupByConditions(this._filterModel, this.col);
|
|
964
|
-
break;
|
|
966
|
+
case FilterBy.CONDITIONS: this._setupByConditions(this._filterModel, this.col);
|
|
965
967
|
}
|
|
966
968
|
return true;
|
|
967
969
|
}
|
|
@@ -1220,7 +1222,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends Disposable {
|
|
|
1220
1222
|
trailing: true
|
|
1221
1223
|
}), startWith(void 0)), this._rawFilterItems$]).pipe(map(([searchString, items]) => {
|
|
1222
1224
|
if (!searchString) return items;
|
|
1223
|
-
|
|
1225
|
+
const searchKeyWords = searchString.toLowerCase().split(/\s+/).filter((s) => !!s);
|
|
1226
|
+
return searchTree(items, searchKeyWords);
|
|
1224
1227
|
})), this._manuallyUpdateFilterItems$).pipe(shareReplay({
|
|
1225
1228
|
bufferSize: 1,
|
|
1226
1229
|
refCount: true
|
|
@@ -1252,7 +1255,8 @@ let ByValuesModel = _ByValuesModel = class ByValuesModel extends Disposable {
|
|
|
1252
1255
|
const items = Tools.deepClone(this._filterItems);
|
|
1253
1256
|
const changedItem = findObjectByKey(items, item.key);
|
|
1254
1257
|
if (!changedItem) return;
|
|
1255
|
-
|
|
1258
|
+
const allLeafChecked = areAllLeafNodesChecked(changedItem);
|
|
1259
|
+
updateLeafNodesCheckedStatus(changedItem, !allLeafChecked);
|
|
1256
1260
|
this._manuallyUpdateFilterItems(items);
|
|
1257
1261
|
}
|
|
1258
1262
|
onFilterOnly(itemKeys) {
|
|
@@ -1576,7 +1580,7 @@ const menuSchema = { [RibbonDataGroup.ORGANIZATION]: { [SmartToggleSheetsFilterC
|
|
|
1576
1580
|
//#endregion
|
|
1577
1581
|
//#region package.json
|
|
1578
1582
|
var name = "@univerjs/sheets-filter-ui";
|
|
1579
|
-
var version = "1.0.0
|
|
1583
|
+
var version = "1.0.0";
|
|
1580
1584
|
|
|
1581
1585
|
//#endregion
|
|
1582
1586
|
//#region src/config/config.ts
|
|
@@ -1584,6 +1588,21 @@ const SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY = "sheets-filter-ui.config";
|
|
|
1584
1588
|
const configSymbol = Symbol(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY);
|
|
1585
1589
|
const defaultPluginConfig = {};
|
|
1586
1590
|
|
|
1591
|
+
//#endregion
|
|
1592
|
+
//#region src/menu/mobile-schema.ts
|
|
1593
|
+
const mobileMenuSchema = { [RibbonDataGroup.ORGANIZATION]: { [SmartToggleSheetsFilterCommand.id]: {
|
|
1594
|
+
order: 2,
|
|
1595
|
+
menuItemFactory: SmartToggleFilterMenuItemFactory,
|
|
1596
|
+
[ClearSheetsFilterCriteriaCommand.id]: {
|
|
1597
|
+
order: 0,
|
|
1598
|
+
menuItemFactory: ClearFilterCriteriaMenuItemFactory
|
|
1599
|
+
},
|
|
1600
|
+
[ReCalcSheetsFilterCommand.id]: {
|
|
1601
|
+
order: 1,
|
|
1602
|
+
menuItemFactory: ReCalcFilterMenuItemFactory
|
|
1603
|
+
}
|
|
1604
|
+
} } };
|
|
1605
|
+
|
|
1587
1606
|
//#endregion
|
|
1588
1607
|
//#region src/controllers/mobile-menu.controller.ts
|
|
1589
1608
|
/**
|
|
@@ -1605,7 +1624,7 @@ let SheetsFilterMobileMenuController = class SheetsFilterMobileMenuController ex
|
|
|
1605
1624
|
constructor(commandService, menuManagerService) {
|
|
1606
1625
|
super();
|
|
1607
1626
|
this.disposeWithMe(commandService.registerCommand(SmartToggleSheetsFilterCommand));
|
|
1608
|
-
menuManagerService.mergeMenu(
|
|
1627
|
+
menuManagerService.mergeMenu(mobileMenuSchema);
|
|
1609
1628
|
}
|
|
1610
1629
|
};
|
|
1611
1630
|
SheetsFilterMobileMenuController = __decorate([__decorateParam(0, ICommandService), __decorateParam(1, IMenuManagerService)], SheetsFilterMobileMenuController);
|
|
@@ -2401,7 +2420,8 @@ let SheetsFilterPermissionController = class SheetsFilterPermissionController ex
|
|
|
2401
2420
|
this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
|
|
2402
2421
|
if (command.id === SmartToggleSheetsFilterCommand.id) {
|
|
2403
2422
|
var _this$_sheetsFilterSe;
|
|
2404
|
-
const
|
|
2423
|
+
const univerInstanceService = this._injector.get(IUniverInstanceService);
|
|
2424
|
+
const target = getSheetCommandTarget(univerInstanceService);
|
|
2405
2425
|
if (!target) return;
|
|
2406
2426
|
const { unitId, subUnitId, worksheet } = target;
|
|
2407
2427
|
const filterRange = (_this$_sheetsFilterSe = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe === void 0 ? void 0 : _this$_sheetsFilterSe.getRange();
|
|
@@ -2866,12 +2886,13 @@ function FilterPanel() {
|
|
|
2866
2886
|
}, [filterByModel, commandService]);
|
|
2867
2887
|
const range = (_filterService$active = useDependency(SheetsFilterService).activeFilterModel) === null || _filterService$active === void 0 ? void 0 : _filterService$active.getRange();
|
|
2868
2888
|
const colIndex = sheetsFilterPanelService.col;
|
|
2889
|
+
const FilterPanelEmbedPointPart = useComponentsOfPart(SheetsUIPart.FILTER_PANEL_EMBED_POINT);
|
|
2869
2890
|
return /* @__PURE__ */ jsxs("div", {
|
|
2870
2891
|
"data-u-comp": "sheets-filter-panel",
|
|
2871
2892
|
className: "univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-gray-0 univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",
|
|
2872
2893
|
children: [
|
|
2873
2894
|
/* @__PURE__ */ jsx(ComponentContainer, {
|
|
2874
|
-
components:
|
|
2895
|
+
components: FilterPanelEmbedPointPart,
|
|
2875
2896
|
sharedProps: {
|
|
2876
2897
|
range,
|
|
2877
2898
|
colIndex,
|