@univerjs/sheets-filter 1.0.0-insiders.20260813-7c9aa50 → 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/LICENSE +176 -0
- package/README.md +10 -2
- package/lib/cjs/facade.js +5 -5
- package/lib/cjs/index.js +19 -12
- 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/facade.js +5 -5
- package/lib/es/index.js +19 -12
- package/lib/facade.js +5 -5
- package/lib/index.js +19 -12
- package/lib/types/commands/mutations/sheets-filter.mutation.d.ts +2 -0
- package/lib/types/facade/f-filter.d.ts +3 -3
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
12
|
| --- | --- | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/sheets-filter` | `UniverSheetsFilter` | No |
|
|
13
|
+
| `@univerjs/sheets-filter` | `UniverSheetsFilter` | No | Yes | Yes |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -25,7 +25,16 @@ Keep all `@univerjs/*` packages on the same version.
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
|
+
import { LocaleType, mergeLocales, Univer } from '@univerjs/core';
|
|
28
29
|
import { UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
|
|
30
|
+
import EnUS from '@univerjs/sheets-filter/locale/en-US';
|
|
31
|
+
|
|
32
|
+
const univer = new Univer({
|
|
33
|
+
locale: LocaleType.EN_US,
|
|
34
|
+
locales: {
|
|
35
|
+
[LocaleType.EN_US]: mergeLocales(EnUS),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
29
38
|
|
|
30
39
|
univer.registerPlugin(UniverSheetsFilterPlugin);
|
|
31
40
|
```
|
|
@@ -39,4 +48,3 @@ Use this package with `@univerjs/sheets-filter-ui` when users need filter menus
|
|
|
39
48
|
- [Documentation](https://docs.univer.ai)
|
|
40
49
|
- [NPM package](https://npmjs.com/package/@univerjs/sheets-filter)
|
|
41
50
|
- [GitHub repository](https://github.com/dream-num/univer)
|
|
42
|
-
|
package/lib/cjs/facade.js
CHANGED
|
@@ -70,7 +70,7 @@ var FUniverSheetsFilterMixin = class extends _univerjs_core_facade.FUniver {
|
|
|
70
70
|
_univerjs_core_facade.FUniver.extend(FUniverSheetsFilterMixin);
|
|
71
71
|
|
|
72
72
|
//#endregion
|
|
73
|
-
//#region \0@oxc-project+runtime@0.
|
|
73
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
74
74
|
function __decorateParam(paramIndex, decorator) {
|
|
75
75
|
return function(target, key) {
|
|
76
76
|
decorator(target, key, paramIndex);
|
|
@@ -78,7 +78,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
//#endregion
|
|
81
|
-
//#region \0@oxc-project+runtime@0.
|
|
81
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
82
82
|
function __decorate(decorators, target, key, desc) {
|
|
83
83
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
84
84
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -147,7 +147,7 @@ let FFilter = class FFilter {
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Get the filter criteria of a column.
|
|
150
|
-
* @param {number} column - The column index.
|
|
150
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
151
151
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
152
152
|
* @example
|
|
153
153
|
* ```typescript
|
|
@@ -199,7 +199,7 @@ let FFilter = class FFilter {
|
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* Clear the filter criteria of a column.
|
|
202
|
-
* @param {number} column - The column index.
|
|
202
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
203
203
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
204
204
|
* @example
|
|
205
205
|
* ```typescript
|
|
@@ -257,7 +257,7 @@ let FFilter = class FFilter {
|
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
259
|
* Set the filter criteria of a column.
|
|
260
|
-
* @param {number} column - The column index.
|
|
260
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
261
261
|
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
262
262
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
263
263
|
* @example
|
package/lib/cjs/index.js
CHANGED
|
@@ -164,7 +164,7 @@ function isWildCardString(str) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
//#endregion
|
|
167
|
-
//#region \0@oxc-project+runtime@0.
|
|
167
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
168
168
|
function _typeof(o) {
|
|
169
169
|
"@babel/helpers - typeof";
|
|
170
170
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -175,7 +175,7 @@ function _typeof(o) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
//#endregion
|
|
178
|
-
//#region \0@oxc-project+runtime@0.
|
|
178
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
179
179
|
function toPrimitive(t, r) {
|
|
180
180
|
if ("object" != _typeof(t) || !t) return t;
|
|
181
181
|
var e = t[Symbol.toPrimitive];
|
|
@@ -188,14 +188,14 @@ function toPrimitive(t, r) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
//#endregion
|
|
191
|
-
//#region \0@oxc-project+runtime@0.
|
|
191
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
192
192
|
function toPropertyKey(t) {
|
|
193
193
|
var i = toPrimitive(t, "string");
|
|
194
194
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
//#endregion
|
|
198
|
-
//#region \0@oxc-project+runtime@0.
|
|
198
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
199
199
|
function _defineProperty(e, r, t) {
|
|
200
200
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
201
201
|
value: t,
|
|
@@ -595,7 +595,7 @@ function extractFilterValueFromCell(cell) {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
//#endregion
|
|
598
|
-
//#region \0@oxc-project+runtime@0.
|
|
598
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
599
599
|
function __decorateParam(paramIndex, decorator) {
|
|
600
600
|
return function(target, key) {
|
|
601
601
|
decorator(target, key, paramIndex);
|
|
@@ -603,7 +603,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
//#endregion
|
|
606
|
-
//#region \0@oxc-project+runtime@0.
|
|
606
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
607
607
|
function __decorate(decorators, target, key, desc) {
|
|
608
608
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
609
609
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -764,7 +764,9 @@ const SetSheetsFilterRangeMutation = {
|
|
|
764
764
|
type: _univerjs_core.CommandType.MUTATION,
|
|
765
765
|
handler: (accessor, params) => {
|
|
766
766
|
const { subUnitId, unitId, range } = params;
|
|
767
|
-
accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId)
|
|
767
|
+
const filterModel = accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId);
|
|
768
|
+
filterModel.setRange(range);
|
|
769
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
768
770
|
return true;
|
|
769
771
|
}
|
|
770
772
|
};
|
|
@@ -779,6 +781,7 @@ const SetSheetsFilterCriteriaMutation = {
|
|
|
779
781
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
780
782
|
if (!filterModel) return false;
|
|
781
783
|
filterModel.setCriteria(col, criteria, reCalc);
|
|
784
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
782
785
|
return true;
|
|
783
786
|
}
|
|
784
787
|
};
|
|
@@ -790,7 +793,9 @@ const RemoveSheetsFilterMutation = {
|
|
|
790
793
|
type: _univerjs_core.CommandType.MUTATION,
|
|
791
794
|
handler: (accessor, params) => {
|
|
792
795
|
const { unitId, subUnitId } = params;
|
|
793
|
-
|
|
796
|
+
const removed = accessor.get(SheetsFilterService).removeFilterModel(unitId, subUnitId);
|
|
797
|
+
if (removed) params.filteredOutRows = [];
|
|
798
|
+
return removed;
|
|
794
799
|
}
|
|
795
800
|
};
|
|
796
801
|
/**
|
|
@@ -804,6 +809,7 @@ const ReCalcSheetsFilterMutation = {
|
|
|
804
809
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
805
810
|
if (!filterModel) return false;
|
|
806
811
|
filterModel.reCalc();
|
|
812
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
807
813
|
return true;
|
|
808
814
|
}
|
|
809
815
|
};
|
|
@@ -1025,7 +1031,8 @@ const ReCalcSheetsFilterCommand = {
|
|
|
1025
1031
|
handler: (accessor, params) => {
|
|
1026
1032
|
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1027
1033
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
1028
|
-
const
|
|
1034
|
+
const instanceSrv = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
1035
|
+
const commandTarget = (0, _univerjs_sheets.getSheetCommandTarget)(instanceSrv, params);
|
|
1029
1036
|
if (!commandTarget) return false;
|
|
1030
1037
|
const { unitId, subUnitId } = commandTarget;
|
|
1031
1038
|
if (!sheetsFilterService.getFilterModel(commandTarget.unitId, commandTarget.subUnitId)) return false;
|
|
@@ -2217,7 +2224,7 @@ SheetsFilterSyncController = __decorate([
|
|
|
2217
2224
|
//#endregion
|
|
2218
2225
|
//#region package.json
|
|
2219
2226
|
var name = "@univerjs/sheets-filter";
|
|
2220
|
-
var version = "1.0.0
|
|
2227
|
+
var version = "1.0.0";
|
|
2221
2228
|
|
|
2222
2229
|
//#endregion
|
|
2223
2230
|
//#region src/services/sheet-filter-formula.service.ts
|
|
@@ -2263,10 +2270,10 @@ let SheetsFilterFormulaService = class SheetsFilterFormulaService extends _unive
|
|
|
2263
2270
|
}];
|
|
2264
2271
|
}
|
|
2265
2272
|
_registerSheetRowFiltered() {
|
|
2266
|
-
this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2273
|
+
this.disposeWithMe(this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2267
2274
|
var _this$_sheetsFilterSe2;
|
|
2268
2275
|
return ((_this$_sheetsFilterSe2 = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe2 === void 0 ? void 0 : _this$_sheetsFilterSe2.isRowFiltered(row)) ?? false;
|
|
2269
|
-
});
|
|
2276
|
+
}));
|
|
2270
2277
|
}
|
|
2271
2278
|
};
|
|
2272
2279
|
SheetsFilterFormulaService = __decorate([
|
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/facade.js
CHANGED
|
@@ -69,7 +69,7 @@ var FUniverSheetsFilterMixin = class extends FUniver {
|
|
|
69
69
|
FUniver.extend(FUniverSheetsFilterMixin);
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
|
-
//#region \0@oxc-project+runtime@0.
|
|
72
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
73
73
|
function __decorateParam(paramIndex, decorator) {
|
|
74
74
|
return function(target, key) {
|
|
75
75
|
decorator(target, key, paramIndex);
|
|
@@ -77,7 +77,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region \0@oxc-project+runtime@0.
|
|
80
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
81
81
|
function __decorate(decorators, target, key, desc) {
|
|
82
82
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
83
83
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -146,7 +146,7 @@ let FFilter = class FFilter {
|
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Get the filter criteria of a column.
|
|
149
|
-
* @param {number} column - The column index.
|
|
149
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
150
150
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
151
151
|
* @example
|
|
152
152
|
* ```typescript
|
|
@@ -198,7 +198,7 @@ let FFilter = class FFilter {
|
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
200
|
* Clear the filter criteria of a column.
|
|
201
|
-
* @param {number} column - The column index.
|
|
201
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
202
202
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
203
203
|
* @example
|
|
204
204
|
* ```typescript
|
|
@@ -256,7 +256,7 @@ let FFilter = class FFilter {
|
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Set the filter criteria of a column.
|
|
259
|
-
* @param {number} column - The column index.
|
|
259
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
260
260
|
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
261
261
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
262
262
|
* @example
|
package/lib/es/index.js
CHANGED
|
@@ -163,7 +163,7 @@ function isWildCardString(str) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region \0@oxc-project+runtime@0.
|
|
166
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
167
167
|
function _typeof(o) {
|
|
168
168
|
"@babel/helpers - typeof";
|
|
169
169
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -174,7 +174,7 @@ function _typeof(o) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region \0@oxc-project+runtime@0.
|
|
177
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
178
178
|
function toPrimitive(t, r) {
|
|
179
179
|
if ("object" != _typeof(t) || !t) return t;
|
|
180
180
|
var e = t[Symbol.toPrimitive];
|
|
@@ -187,14 +187,14 @@ function toPrimitive(t, r) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
//#endregion
|
|
190
|
-
//#region \0@oxc-project+runtime@0.
|
|
190
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
191
191
|
function toPropertyKey(t) {
|
|
192
192
|
var i = toPrimitive(t, "string");
|
|
193
193
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
//#endregion
|
|
197
|
-
//#region \0@oxc-project+runtime@0.
|
|
197
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
198
198
|
function _defineProperty(e, r, t) {
|
|
199
199
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
200
200
|
value: t,
|
|
@@ -594,7 +594,7 @@ function extractFilterValueFromCell(cell) {
|
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
//#endregion
|
|
597
|
-
//#region \0@oxc-project+runtime@0.
|
|
597
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
598
598
|
function __decorateParam(paramIndex, decorator) {
|
|
599
599
|
return function(target, key) {
|
|
600
600
|
decorator(target, key, paramIndex);
|
|
@@ -602,7 +602,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
//#endregion
|
|
605
|
-
//#region \0@oxc-project+runtime@0.
|
|
605
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
606
606
|
function __decorate(decorators, target, key, desc) {
|
|
607
607
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
608
608
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -763,7 +763,9 @@ const SetSheetsFilterRangeMutation = {
|
|
|
763
763
|
type: CommandType.MUTATION,
|
|
764
764
|
handler: (accessor, params) => {
|
|
765
765
|
const { subUnitId, unitId, range } = params;
|
|
766
|
-
accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId)
|
|
766
|
+
const filterModel = accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId);
|
|
767
|
+
filterModel.setRange(range);
|
|
768
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
767
769
|
return true;
|
|
768
770
|
}
|
|
769
771
|
};
|
|
@@ -778,6 +780,7 @@ const SetSheetsFilterCriteriaMutation = {
|
|
|
778
780
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
779
781
|
if (!filterModel) return false;
|
|
780
782
|
filterModel.setCriteria(col, criteria, reCalc);
|
|
783
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
781
784
|
return true;
|
|
782
785
|
}
|
|
783
786
|
};
|
|
@@ -789,7 +792,9 @@ const RemoveSheetsFilterMutation = {
|
|
|
789
792
|
type: CommandType.MUTATION,
|
|
790
793
|
handler: (accessor, params) => {
|
|
791
794
|
const { unitId, subUnitId } = params;
|
|
792
|
-
|
|
795
|
+
const removed = accessor.get(SheetsFilterService).removeFilterModel(unitId, subUnitId);
|
|
796
|
+
if (removed) params.filteredOutRows = [];
|
|
797
|
+
return removed;
|
|
793
798
|
}
|
|
794
799
|
};
|
|
795
800
|
/**
|
|
@@ -803,6 +808,7 @@ const ReCalcSheetsFilterMutation = {
|
|
|
803
808
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
804
809
|
if (!filterModel) return false;
|
|
805
810
|
filterModel.reCalc();
|
|
811
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
806
812
|
return true;
|
|
807
813
|
}
|
|
808
814
|
};
|
|
@@ -1024,7 +1030,8 @@ const ReCalcSheetsFilterCommand = {
|
|
|
1024
1030
|
handler: (accessor, params) => {
|
|
1025
1031
|
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1026
1032
|
const commandService = accessor.get(ICommandService);
|
|
1027
|
-
const
|
|
1033
|
+
const instanceSrv = accessor.get(IUniverInstanceService);
|
|
1034
|
+
const commandTarget = getSheetCommandTarget(instanceSrv, params);
|
|
1028
1035
|
if (!commandTarget) return false;
|
|
1029
1036
|
const { unitId, subUnitId } = commandTarget;
|
|
1030
1037
|
if (!sheetsFilterService.getFilterModel(commandTarget.unitId, commandTarget.subUnitId)) return false;
|
|
@@ -2216,7 +2223,7 @@ SheetsFilterSyncController = __decorate([
|
|
|
2216
2223
|
//#endregion
|
|
2217
2224
|
//#region package.json
|
|
2218
2225
|
var name = "@univerjs/sheets-filter";
|
|
2219
|
-
var version = "1.0.0
|
|
2226
|
+
var version = "1.0.0";
|
|
2220
2227
|
|
|
2221
2228
|
//#endregion
|
|
2222
2229
|
//#region src/services/sheet-filter-formula.service.ts
|
|
@@ -2262,10 +2269,10 @@ let SheetsFilterFormulaService = class SheetsFilterFormulaService extends Dispos
|
|
|
2262
2269
|
}];
|
|
2263
2270
|
}
|
|
2264
2271
|
_registerSheetRowFiltered() {
|
|
2265
|
-
this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2272
|
+
this.disposeWithMe(this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2266
2273
|
var _this$_sheetsFilterSe2;
|
|
2267
2274
|
return ((_this$_sheetsFilterSe2 = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe2 === void 0 ? void 0 : _this$_sheetsFilterSe2.isRowFiltered(row)) ?? false;
|
|
2268
|
-
});
|
|
2275
|
+
}));
|
|
2269
2276
|
}
|
|
2270
2277
|
};
|
|
2271
2278
|
SheetsFilterFormulaService = __decorate([
|
package/lib/facade.js
CHANGED
|
@@ -69,7 +69,7 @@ var FUniverSheetsFilterMixin = class extends FUniver {
|
|
|
69
69
|
FUniver.extend(FUniverSheetsFilterMixin);
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
|
-
//#region \0@oxc-project+runtime@0.
|
|
72
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
73
73
|
function __decorateParam(paramIndex, decorator) {
|
|
74
74
|
return function(target, key) {
|
|
75
75
|
decorator(target, key, paramIndex);
|
|
@@ -77,7 +77,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//#endregion
|
|
80
|
-
//#region \0@oxc-project+runtime@0.
|
|
80
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
81
81
|
function __decorate(decorators, target, key, desc) {
|
|
82
82
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
83
83
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -146,7 +146,7 @@ let FFilter = class FFilter {
|
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Get the filter criteria of a column.
|
|
149
|
-
* @param {number} column - The column index.
|
|
149
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
150
150
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
151
151
|
* @example
|
|
152
152
|
* ```typescript
|
|
@@ -198,7 +198,7 @@ let FFilter = class FFilter {
|
|
|
198
198
|
}
|
|
199
199
|
/**
|
|
200
200
|
* Clear the filter criteria of a column.
|
|
201
|
-
* @param {number} column - The column index.
|
|
201
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
202
202
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
203
203
|
* @example
|
|
204
204
|
* ```typescript
|
|
@@ -256,7 +256,7 @@ let FFilter = class FFilter {
|
|
|
256
256
|
}
|
|
257
257
|
/**
|
|
258
258
|
* Set the filter criteria of a column.
|
|
259
|
-
* @param {number} column - The column index.
|
|
259
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
260
260
|
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
261
261
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
262
262
|
* @example
|
package/lib/index.js
CHANGED
|
@@ -163,7 +163,7 @@ function isWildCardString(str) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region \0@oxc-project+runtime@0.
|
|
166
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
167
167
|
function _typeof(o) {
|
|
168
168
|
"@babel/helpers - typeof";
|
|
169
169
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -174,7 +174,7 @@ function _typeof(o) {
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
//#endregion
|
|
177
|
-
//#region \0@oxc-project+runtime@0.
|
|
177
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
178
178
|
function toPrimitive(t, r) {
|
|
179
179
|
if ("object" != _typeof(t) || !t) return t;
|
|
180
180
|
var e = t[Symbol.toPrimitive];
|
|
@@ -187,14 +187,14 @@ function toPrimitive(t, r) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
//#endregion
|
|
190
|
-
//#region \0@oxc-project+runtime@0.
|
|
190
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
191
191
|
function toPropertyKey(t) {
|
|
192
192
|
var i = toPrimitive(t, "string");
|
|
193
193
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
//#endregion
|
|
197
|
-
//#region \0@oxc-project+runtime@0.
|
|
197
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
198
198
|
function _defineProperty(e, r, t) {
|
|
199
199
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
200
200
|
value: t,
|
|
@@ -594,7 +594,7 @@ function extractFilterValueFromCell(cell) {
|
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
//#endregion
|
|
597
|
-
//#region \0@oxc-project+runtime@0.
|
|
597
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
598
598
|
function __decorateParam(paramIndex, decorator) {
|
|
599
599
|
return function(target, key) {
|
|
600
600
|
decorator(target, key, paramIndex);
|
|
@@ -602,7 +602,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
//#endregion
|
|
605
|
-
//#region \0@oxc-project+runtime@0.
|
|
605
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
606
606
|
function __decorate(decorators, target, key, desc) {
|
|
607
607
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
608
608
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -763,7 +763,9 @@ const SetSheetsFilterRangeMutation = {
|
|
|
763
763
|
type: CommandType.MUTATION,
|
|
764
764
|
handler: (accessor, params) => {
|
|
765
765
|
const { subUnitId, unitId, range } = params;
|
|
766
|
-
accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId)
|
|
766
|
+
const filterModel = accessor.get(SheetsFilterService).ensureFilterModel(unitId, subUnitId);
|
|
767
|
+
filterModel.setRange(range);
|
|
768
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
767
769
|
return true;
|
|
768
770
|
}
|
|
769
771
|
};
|
|
@@ -778,6 +780,7 @@ const SetSheetsFilterCriteriaMutation = {
|
|
|
778
780
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
779
781
|
if (!filterModel) return false;
|
|
780
782
|
filterModel.setCriteria(col, criteria, reCalc);
|
|
783
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
781
784
|
return true;
|
|
782
785
|
}
|
|
783
786
|
};
|
|
@@ -789,7 +792,9 @@ const RemoveSheetsFilterMutation = {
|
|
|
789
792
|
type: CommandType.MUTATION,
|
|
790
793
|
handler: (accessor, params) => {
|
|
791
794
|
const { unitId, subUnitId } = params;
|
|
792
|
-
|
|
795
|
+
const removed = accessor.get(SheetsFilterService).removeFilterModel(unitId, subUnitId);
|
|
796
|
+
if (removed) params.filteredOutRows = [];
|
|
797
|
+
return removed;
|
|
793
798
|
}
|
|
794
799
|
};
|
|
795
800
|
/**
|
|
@@ -803,6 +808,7 @@ const ReCalcSheetsFilterMutation = {
|
|
|
803
808
|
const filterModel = accessor.get(SheetsFilterService).getFilterModel(unitId, subUnitId);
|
|
804
809
|
if (!filterModel) return false;
|
|
805
810
|
filterModel.reCalc();
|
|
811
|
+
params.filteredOutRows = Array.from(filterModel.filteredOutRows);
|
|
806
812
|
return true;
|
|
807
813
|
}
|
|
808
814
|
};
|
|
@@ -1024,7 +1030,8 @@ const ReCalcSheetsFilterCommand = {
|
|
|
1024
1030
|
handler: (accessor, params) => {
|
|
1025
1031
|
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1026
1032
|
const commandService = accessor.get(ICommandService);
|
|
1027
|
-
const
|
|
1033
|
+
const instanceSrv = accessor.get(IUniverInstanceService);
|
|
1034
|
+
const commandTarget = getSheetCommandTarget(instanceSrv, params);
|
|
1028
1035
|
if (!commandTarget) return false;
|
|
1029
1036
|
const { unitId, subUnitId } = commandTarget;
|
|
1030
1037
|
if (!sheetsFilterService.getFilterModel(commandTarget.unitId, commandTarget.subUnitId)) return false;
|
|
@@ -2216,7 +2223,7 @@ SheetsFilterSyncController = __decorate([
|
|
|
2216
2223
|
//#endregion
|
|
2217
2224
|
//#region package.json
|
|
2218
2225
|
var name = "@univerjs/sheets-filter";
|
|
2219
|
-
var version = "1.0.0
|
|
2226
|
+
var version = "1.0.0";
|
|
2220
2227
|
|
|
2221
2228
|
//#endregion
|
|
2222
2229
|
//#region src/services/sheet-filter-formula.service.ts
|
|
@@ -2262,10 +2269,10 @@ let SheetsFilterFormulaService = class SheetsFilterFormulaService extends Dispos
|
|
|
2262
2269
|
}];
|
|
2263
2270
|
}
|
|
2264
2271
|
_registerSheetRowFiltered() {
|
|
2265
|
-
this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2272
|
+
this.disposeWithMe(this._sheetRowFilteredService.register((unitId, subUnitId, row) => {
|
|
2266
2273
|
var _this$_sheetsFilterSe2;
|
|
2267
2274
|
return ((_this$_sheetsFilterSe2 = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) === null || _this$_sheetsFilterSe2 === void 0 ? void 0 : _this$_sheetsFilterSe2.isRowFiltered(row)) ?? false;
|
|
2268
|
-
});
|
|
2275
|
+
}));
|
|
2269
2276
|
}
|
|
2270
2277
|
};
|
|
2271
2278
|
SheetsFilterFormulaService = __decorate([
|
|
@@ -22,6 +22,7 @@ import type { IFilterColumn } from '../../models/types';
|
|
|
22
22
|
*/
|
|
23
23
|
export interface ISetSheetsFilterRangeMutationParams extends ISheetCommandSharedParams {
|
|
24
24
|
range: IRange;
|
|
25
|
+
filteredOutRows?: number[];
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* A {@link CommandType.MUTATION} to set filter range in a {@link Worksheet}. If no {@link FilterModel} exists,
|
|
@@ -41,6 +42,7 @@ export interface ISetSheetsFilterCriteriaMutationParams extends ISheetCommandSha
|
|
|
41
42
|
col: number;
|
|
42
43
|
criteria: Nullable<IFilterColumn>;
|
|
43
44
|
reCalc?: boolean;
|
|
45
|
+
filteredOutRows?: number[];
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* A {@link CommandType.MUTATION} to set filter criteria of a given column of a {@link FilterModel}.
|
|
@@ -77,7 +77,7 @@ export declare class FFilter {
|
|
|
77
77
|
getFilteredOutRows(): number[];
|
|
78
78
|
/**
|
|
79
79
|
* Get the filter criteria of a column.
|
|
80
|
-
* @param {number} column - The column index.
|
|
80
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
81
81
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
82
82
|
* @example
|
|
83
83
|
* ```typescript
|
|
@@ -126,7 +126,7 @@ export declare class FFilter {
|
|
|
126
126
|
getColumnFilterCriteria(column: number): Nullable<IFilterColumn>;
|
|
127
127
|
/**
|
|
128
128
|
* Clear the filter criteria of a column.
|
|
129
|
-
* @param {number} column - The column index.
|
|
129
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
130
130
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
131
131
|
* @example
|
|
132
132
|
* ```typescript
|
|
@@ -176,7 +176,7 @@ export declare class FFilter {
|
|
|
176
176
|
removeColumnFilterCriteria(column: number): FFilter;
|
|
177
177
|
/**
|
|
178
178
|
* Set the filter criteria of a column.
|
|
179
|
-
* @param {number} column - The column index.
|
|
179
|
+
* @param {number} column - The absolute, zero-based worksheet column index, not an index relative to the filter range.
|
|
180
180
|
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
181
181
|
* @returns {FFilter} The FFilter instance for chaining.
|
|
182
182
|
* @example
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/rpc"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-render`,`@univerjs/rpc`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsFilter={},e.UniverCore,e.UniverSheets,e.rxjs,e.UniverEngineRender,e.UniverRpc,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let s=`sheet.mutation.set-filter-range`,c=`sheet.mutation.set-filter-criteria`,l=`sheet.mutation.remove-filter`,u=`sheet.mutation.re-calc-filter`,d=new Set([s,c,l,u]),f=function(e){return e[e.VALUES=0]=`VALUES`,e[e.COLORS=1]=`COLORS`,e[e.CONDITIONS=2]=`CONDITIONS`,e}({}),p=function(e){return e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_EQUALS=`notEqual`,e}({}),m={operator:`greaterThan`,fn:(e,t)=>S(e)?e>t:!1},h={operator:`greaterThanOrEqual`,fn:(e,t)=>S(e)?e>=t:!1},g={operator:`lessThan`,fn:(e,t)=>S(e)?e<t:!1},_={operator:`lessThanOrEqual`,fn:(e,t)=>S(e)?e<=t:!1},v={operator:`equal`,fn:(e,t)=>S(e)?e===t:!1},y={operator:`notEqual`,fn:(e,n)=>{if(typeof n==`string`){if(n===` `)return e!=null;let r=w(e);return r&&ne(n)?!t.regexp.createFromWildcard(n).test(r):r!==n}return!S(e)||e!==n}},b=new Map([]);[m,h,g,_,v,y].forEach(e=>{b.set(e.operator,e)});function ee(e){return!!e}let te={fn:(e,n)=>{let r=w(e);return r===null?n===``:t.regexp.createFromWildcard(n).test(r)}};function x(e){return e?b.get(e):te}function S(e){return typeof e==`number`}function C(e){return!!(typeof e==`number`||typeof e==`string`&&(0,t.isNumeric)(e))}function w(e){return typeof e==`boolean`||e==null?null:typeof e==`string`?e:e.toString()}function ne(e){return typeof e==`number`?!1:e.indexOf(`*`)!==-1||e.indexOf(`?`)!==-1}function T(e){"@babel/helpers - typeof";return T=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},T(e)}function re(e,t){if(T(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(T(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ie(e){var t=re(e,`string`);return T(t)==`symbol`?t:t+``}function E(e,t,n){return(t=ie(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=()=>new Set;var O=class e extends t.Disposable{get filteredOutRows(){return this._filteredOutRows$.getValue()}set filteredOutRows(e){this._alreadyFilteredOutRows=e,this._filteredOutRows$.next(e)}constructor(e,t,n){super(),this.unitId=e,this.subUnitId=t,this._worksheet=n,E(this,`_filteredOutRows$`,new r.BehaviorSubject(D())),E(this,`filteredOutRows$`,this._filteredOutRows$.asObservable()),E(this,`_hasCriteria$`,new r.BehaviorSubject(!1)),E(this,`hasCriteria$`,this._hasCriteria$.asObservable()),E(this,`_filterColumnByIndex`,new Map),E(this,`_alreadyFilteredOutRows`,D()),E(this,`_range`,void 0)}dispose(){super.dispose(),this._filteredOutRows$.complete(),this._hasCriteria$.complete(),this._worksheet=null}serialize(){let e={ref:t.Rectangle.clone(this._range),filterColumns:this._getAllFilterColumns(!0).sort(([e],[t])=>e-t).map(([e,t])=>t.serialize())};return this._alreadyFilteredOutRows&&(e.cachedFilteredOut=Array.from(this._alreadyFilteredOutRows).sort()),e}static deserialize(t,n,r,i){let a=new e(t,n,r);return a._dump(i),a}_dump(e){var t;this.setRange(e.ref),(t=e.filterColumns)==null||t.filter(e=>!(!e.filters&&!e.colorFilters&&!e.customFilters)).forEach(e=>this._setCriteriaWithoutReCalc(e.colId,e)),e.cachedFilteredOut?(this._alreadyFilteredOutRows=new Set(e.cachedFilteredOut),this._emit()):e.filterColumns&&e.filterColumns.length>0&&(this._reCalcAllColumns(),this._emit()),this._emitHasCriteria()}isRowFiltered(e){return this._alreadyFilteredOutRows.has(e)}getRange(){if(!this._range)throw Error(`[FilterModel] could not get range before a range is set!`);return this._range}getFilteredOutRowsExceptCol(e){return this._getAllFilterColumns(!0).filter(([t])=>t!==e).reduce((e,[,n])=>{let r=n.calc({getAlreadyFilteredOutRows:()=>e});return r?(0,t.mergeSets)(e,r):e},new Set)}setRange(e){this._range=e,this._getAllFilterColumns(!0).forEach(([t,n])=>{n.setRangeAndColumn({startRow:e.startRow,endRow:e.endRow,startColumn:t,endColumn:t},t)})}setCriteria(e,t,n=!1){if(!this._range)throw Error(`[FilterModel] could not set criteria before a range is set!`);if(!t){this._removeCriteria(e),this._rebuildAlreadyFilteredOutRowsWithCache(),n&&this._reCalcAllColumns(),this._emit(),this._emitHasCriteria();return}this._setCriteriaWithoutReCalc(e,t),n&&(this._rebuildAlreadyFilteredOutRowsWithCache(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns(),this._emit(),this._emitHasCriteria())}getAllFilterColumns(){return this._getAllFilterColumns(!0)}getFilterColumn(e){return this._filterColumnByIndex.get(e)??null}reCalc(){this._reCalcAllColumns(),this._emit()}_getAllFilterColumns(e=!1){let t=Array.from(this._filterColumnByIndex.entries());return e?t:t.map(([e,t])=>t)}_reCalcAllColumns(){this._alreadyFilteredOutRows=D(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns()}_setCriteriaWithoutReCalc(e,t){let n=this._range;if(!n)throw Error(`[FilterModel] could not set criteria before a range is set!`);let{startColumn:r,endColumn:i}=n;if(e>i||e<r)throw Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);let a;this._filterColumnByIndex.has(e)?a=this._filterColumnByIndex.get(e):(a=new k(this.unitId,this.subUnitId,this._worksheet,t,{getAlreadyFilteredOutRows:()=>this._alreadyFilteredOutRows}),a.setRangeAndColumn(n,e),this._filterColumnByIndex.set(e,a)),a.setCriteria(t)}_removeCriteria(e){let t=this._filterColumnByIndex.get(e);t&&(t.dispose(),this._filterColumnByIndex.delete(e))}_emit(){this._filteredOutRows$.next(this._alreadyFilteredOutRows)}_emitHasCriteria(){this._hasCriteria$.next(this._filterColumnByIndex.size>0)}_rebuildAlreadyFilteredOutRowsWithCache(){let e=this._getAllFilterColumns().filter(e=>e.hasCache()).reduce((e,n)=>(0,t.mergeSets)(e,n.filteredOutRows),new Set);this._alreadyFilteredOutRows=e}_reCalcWithNoCacheColumns(){let e=this._getAllFilterColumns().filter(e=>!e.hasCache());for(let n of e){let e=n.reCalc();e&&(this._alreadyFilteredOutRows=(0,t.mergeSets)(this._alreadyFilteredOutRows,e))}}},k=class extends t.Disposable{get filteredOutRows(){return this._filteredOutRows}get filterBy(){return this._filterBy}constructor(e,t,n,r,i){super(),this.unitId=e,this.subUnitId=t,this._worksheet=n,this._criteria=r,this._filterColumnContext=i,E(this,`_filteredOutRows`,null),E(this,`_filterFn`,null),E(this,`_range`,null),E(this,`_column`,0),E(this,`_filterBy`,0)}dispose(){super.dispose(),this._filteredOutRows=null}__clearCache(){this._filteredOutRows=null}serialize(){if(!this._criteria)throw Error(`[FilterColumn]: could not serialize without a filter column!`);return t.Tools.deepClone({...this._criteria,colId:this._column})}hasCache(){return this._filteredOutRows!==null}setRangeAndColumn(e,t){this._range=e,this._column=t}setCriteria(e){this._criteria=e,this._generateFilterFn(),this._filteredOutRows=null}getColumnData(){return t.Tools.deepClone(this._criteria)}reCalc(){return this._filteredOutRows=this.calc(this._filterColumnContext),this._filteredOutRows}calc(e){if(!this._filterFn)throw Error(`[FilterColumn] cannot calculate without a filter fn!`);if(!this._range)throw Error(`[FilterColumn] cannot calculate without a range!`);if(typeof this._column!=`number`)throw TypeError(`[FilterColumn] cannot calculate without a column offset!`);let n=this._column,r={startColumn:n,endColumn:n,startRow:this._range.startRow+1,endRow:this._range.endRow},i=new Set,a=e.getAlreadyFilteredOutRows();for(let e of this._worksheet.iterateByColumn(r,!1,!1)){let{row:n,rowSpan:r,col:o}=e;if(!(a.has(n)&&(!r||r===1))&&!(this._filterBy===0?this._filterFn((0,t.extractPureTextFromCell)(this._worksheet.getCell(n,o))):this._filterBy===1?this._filterFn(this._worksheet.getComposedCellStyle(n,o)):this._filterFn(fe(this._worksheet,n,o)))&&(i.add(n),r))for(let e=1;e<r;e++)i.add(n+e)}return i}_generateFilterFn(){this._criteria&&(this._filterFn=ae(this._criteria),this._filterBy=this._criteria.filters?0:this._criteria.colorFilters?1:2)}};function ae(e){if(e.filters)return oe(e.filters);if(e.colorFilters)return se(e.colorFilters);if(e.customFilters)return ce(e.customFilters);throw Error(`[FilterModel]: other types of filters are not supported yet.`)}function oe(e){let t=!!e.blank,n=new Set(e.filters);return e=>e===void 0||e===``?t:n.has(typeof e==`string`?e:`${e}`)}function se(e){if(e.cellFillColors){let n=new Set(e.cellFillColors);return e=>{var r;if(!e||!((r=e.bg)!=null&&r.rgb))return!!n.has(null);let i=new t.ColorKit(e.bg.rgb).toRgbString();return n.has(i)}}if(e.cellTextColors){let n=new Set(e.cellTextColors);return e=>{var r;if(!e||!((r=e.cl)!=null&&r.rgb))return!!n.has(i.COLOR_BLACK_RGB);let a=new t.ColorKit(e.cl.rgb).toRgbString();return n.has(a)}}throw Error(`[FilterModel]: color filters are not supported yet.`)}function ce(e){let t=e.customFilters.map(e=>A(e));return de(t)?e.and?le(t):ue(t):t[0]}function le(e){let[t,n]=e;return e=>t(e)&&n(e)}function ue(e){let[t,n]=e;return e=>t(e)||n(e)}function de(e){return e.length===2}function A(e){let t=e.val;if(e.operator===`notEqual`&&!C(t))return e=>y.fn(e,t);if(ee(e.operator)){if(!C(t))return()=>!1;let n=x(e.operator),r=Number(t);return e=>n.fn(e,r)}let n=x(e.operator);return e=>n.fn(e,t)}function fe(e,n,r){let i=e.getCell(n,r);if(!i)return null;let a=e.getCellRaw(n,r);return i&&!a?j(i):a?i.t===t.CellValueType.NUMBER&&typeof i.v==`string`?a.v:i.t===t.CellValueType.NUMBER?Number(a.v):j(a):null}function j(e){var n;let r=(n=e.p)==null||(n=n.body)==null?void 0:n.dataStream;if(r)return r.trimEnd();let i=e.v;return typeof i==`string`?e.t===t.CellValueType.BOOLEAN?i.toUpperCase():i:typeof i==`number`?e.t===t.CellValueType.BOOLEAN?i?`TRUE`:`FALSE`:i:typeof i==`boolean`?i?`TRUE`:`FALSE`:``}function M(e,t){return function(n,r){t(n,r,e)}}function N(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let P=`SHEET_FILTER_PLUGIN`,F=class extends t.Disposable{get activeFilterModel(){return this._activeFilterModel$.getValue()}constructor(e,t,n){super(),this._resourcesManagerService=e,this._univerInstanceService=t,this._commandService=n,E(this,`_filterModels`,new Map),E(this,`_loadedUnitId$`,new r.BehaviorSubject(null)),E(this,`loadedUnitId$`,this._loadedUnitId$.asObservable()),E(this,`_errorMsg$`,new r.BehaviorSubject(null)),E(this,`errorMsg$`,this._errorMsg$.asObservable()),E(this,`_activeFilterModel$`,new r.BehaviorSubject(null)),E(this,`activeFilterModel$`,this._activeFilterModel$.asObservable()),this._initModel(),this._initActiveFilterModel()}ensureFilterModel(e,n){let r=this.getFilterModel(e,n);if(r)return r;let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)throw Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${e}!`);let a=i.getSheetBySheetId(n);if(!a)throw Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${n}!`);let o=new O(e,n,a);return this._cacheFilterModel(e,n,o),o}getFilterModel(e,t){var n;return((n=this._filterModels.get(e))==null?void 0:n.get(t))??null}removeFilterModel(e,t){let n=this.getFilterModel(e,t);return n?(n.dispose(),this._filterModels.get(e).delete(t),!0):!1}setFilterErrorMsg(e){this._errorMsg$.next(e)}_updateActiveFilterModel(){let e;try{if(e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),!e){this._activeFilterModel$.next(null);return}}catch(e){console.error(`[SheetsFilterService]: could not get active workbook!`,e);return}let n=e.getActiveSheet(!0);if(!n){this._activeFilterModel$.next(null);return}let r=n.getUnitId(),i=n.getSheetId(),a=this.getFilterModel(r,i);this._activeFilterModel$.next(a)}_initActiveFilterModel(){this.disposeWithMe((0,r.merge)((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,r.filter)(([e])=>e.type===t.CommandType.MUTATION&&d.has(e.id))),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,r.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,r.of)(null)))).subscribe(()=>this._updateActiveFilterModel()))}_serializeAutoFiltersForUnit(e){let t=this._filterModels.get(e);if(!t)return`{}`;let n={};return t.forEach((e,t)=>{n[t]=e.serialize()}),JSON.stringify(n)}_deserializeAutoFiltersForUnit(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);Object.keys(n).forEach(t=>{let i=n[t],a=O.deserialize(e,t,r.getSheetBySheetId(t),i);this._cacheFilterModel(e,t,a)})}dispose(){super.dispose(),this._loadedUnitId$.complete(),this._errorMsg$.complete(),this._activeFilterModel$.complete(),this._filterModels.forEach(e=>{e.forEach(e=>e.dispose()),e.clear()}),this._filterModels.clear()}_initModel(){this._resourcesManagerService.registerPluginResource({pluginName:P,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:e=>this._serializeAutoFiltersForUnit(e),parseJson:e=>JSON.parse(e),onLoad:(e,t)=>{this._deserializeAutoFiltersForUnit(e,t),this._loadedUnitId$.next(e),this._updateActiveFilterModel()},onUnLoad:e=>{let t=this._filterModels.get(e);t&&(t.forEach(e=>e.dispose()),this._filterModels.delete(e))}})}_cacheFilterModel(e,t,n){this._filterModels.has(e)||this._filterModels.set(e,new Map),this._filterModels.get(e).set(t,n)}};F=N([M(0,t.IResourceManagerService),M(1,t.IUniverInstanceService),M(2,t.ICommandService)],F);let I={id:s,type:t.CommandType.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,range:i}=t;return e.get(F).ensureFilterModel(r,n).setRange(i),!0}},L={id:c,type:t.CommandType.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,criteria:i,col:a,reCalc:o=!0}=t,s=e.get(F).getFilterModel(r,n);return s?(s.setCriteria(a,i,o),!0):!1}},R={id:l,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r}=t;return e.get(F).removeFilterModel(n,r)}},z={id:u,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r}=t,i=e.get(F).getFilterModel(n,r);return i?(i.reCalc(),!0):!1}},B={id:`sheet.command.set-filter-range`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=e.get(F),a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),{unitId:c,subUnitId:l,range:u}=r;if(!(0,n.getSheetCommandTarget)(s,r)||i.getFilterModel(c,l))return!1;if(u.endRow===u.startRow){let n=e.get(t.ErrorService),r=e.get(t.LocaleService);return n.emit(r.t(`sheets-filter.command.not-valid-filter-range`)),!1}let d={id:I.id,params:{unitId:c,subUnitId:l,range:u}},f=a.syncExecuteCommand(d.id,d.params);return f&&o.pushUndoRedo({unitID:c,undoMutations:[{id:R.id,params:{unitId:c,subUnitId:l}}],redoMutations:[d]}),f}},V={id:`sheet.command.remove-sheet-filter`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let l=c.getRange();if(!l)return!1;let u=e.get(t.ICommandService),d=e.get(t.IUndoRedoService),f=me(o,s,c.serialize()),p=u.syncExecuteCommand(R.id,{unitId:o,subUnitId:s});return p&&(d.pushUndoRedo({unitID:o,undoMutations:f,redoMutations:[{id:R.id,params:{unitId:o,subUnitId:s}}]}),u.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:l})),p}},pe={id:`sheet.command.smart-toggle-filter`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.IUniverInstanceService),i=e.get(F),a=e.get(t.ICommandService),o=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s||!o)return!1;let c=o.getUnitId(),l=s.getSheetId();if(i.getFilterModel(c,l))return a.executeCommand(V.id,{unitId:c,subUnitId:l});let u=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!u)return!1;let d=u.range,f=(0,n.isSingleCellSelection)(u)?(0,n.expandToContinuousRange)(d,{left:!0,right:!0,up:!0,down:!0},s):d.startRow===d.endRow?(0,n.expandToContinuousRange)(d,{down:!0},s):d;return a.executeCommand(B.id,{unitId:c,subUnitId:l,range:f})}},H={id:`sheet.command.set-filter-criteria`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let{col:l,criteria:u}=r,d=c.getRange();if(!d||l<d.startColumn||l>d.endColumn)return!1;let f=e.get(t.ICommandService),p=e.get(t.IUndoRedoService),m=ge(o,s,l,c.getFilterColumn(l)),h={id:L.id,params:{unitId:o,subUnitId:s,col:l,criteria:u}},g=f.syncExecuteCommand(h.id,h.params);return g&&(p.pushUndoRedo({unitID:o,undoMutations:[m],redoMutations:[h]}),f.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:d})),g}},U={id:`sheet.command.clear-filter-criteria`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let l=c.getRange();if(!l)return!1;let u=e.get(t.IUndoRedoService),d=e.get(t.ICommandService),f=c.serialize(),p=G(o,s,f),m=he(o,s,f);return(0,t.sequenceExecute)(m,d).result?(u.pushUndoRedo({unitID:o,undoMutations:p,redoMutations:m}),d.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:l}),!0):!1}},W={id:`sheet.command.re-calc-filter`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=e.get(F),a=e.get(t.ICommandService),o=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!o)return!1;let{unitId:s,subUnitId:c}=o;return i.getFilterModel(o.unitId,o.subUnitId)?a.executeCommand(z.id,{unitId:s,subUnitId:c}):!1}};function me(e,t,n){let r=[],i={id:I.id,params:{unitId:e,subUnitId:t,range:n.ref}};return r.push(i),G(e,t,n).forEach(e=>r.push(e)),r}function G(e,t,n){var r;let i=[];return(r=n.filterColumns)==null||r.forEach(n=>{let r={id:L.id,params:{unitId:e,subUnitId:t,col:n.colId,criteria:n}};i.push(r)}),i}function he(e,t,n){var r;let i=[];return(r=n.filterColumns)==null||r.forEach(n=>{let r={id:L.id,params:{unitId:e,subUnitId:t,col:n.colId,criteria:null}};i.push(r)}),i}function ge(e,t,n,r){if(!r)return{id:L.id,params:{unitId:e,subUnitId:t,col:n,criteria:null}};let i=r.serialize();return{id:L.id,params:{unitId:e,subUnitId:t,col:n,criteria:i}}}let K=`sheets-filter.config`,q={};function _e(e,t){for(let n=0;n<e.length;n++){let r=n;if(e[n])for(let i=n+1;i<e.length;i++)e[r]&&e[i]&&t(e[r],e[i])&&(e[r]=null,r=i)}return e.filter(e=>e!==null)}function J(e){return _e(e,(e,t)=>e.id===L.id&&t.id===L.id&&e.params.unitId===t.params.unitId&&e.params.subUnitId===t.params.subUnitId&&e.params.col===t.params.col)}let Y=class extends t.Disposable{constructor(e,n,r,i,a,o,s){super(),this._commandService=e,this._sheetInterceptorService=n,this._sheetsFilterService=r,this._univerInstanceService=i,this._refRangeService=a,this._dataSyncPrimaryController=o,this._zebraCrossingCacheController=s,E(this,`_disposableCollection`,new t.DisposableCollection),this._initCommands(),this._initRowFilteredInterceptor(),this._initInterceptors(),this._commandExecutedListener(),this._initErrorHandling(),this._initZebraCrossingCacheListener()}_initZebraCrossingCacheListener(){this.disposeWithMe(this._sheetsFilterService.activeFilterModel$.subscribe(e=>{e&&this.disposeWithMe(e.filteredOutRows$.subscribe(()=>{this._zebraCrossingCacheController.updateZebraCrossingCache(e.unitId,e.subUnitId)}))}))}_initCommands(){[B,V,H,U,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),[L,I,z,R].forEach(e=>{var t;this.disposeWithMe(this._commandService.registerCommand(e)),(t=this._dataSyncPrimaryController)==null||t.registerSyncingMutations(e)})}_initInterceptors(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>this._getUpdateFilter(e)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===n.SetWorksheetActiveOperation.id){let t=e.params,n=t.subUnitId,r=t.unitId;if(!n||!r)return;this._registerRefRange(r,n)}if(e.id===I.id){let t=e.params,n=t.subUnitId,r=t.unitId;if(!n||!r)return;this._registerRefRange(t.unitId,t.subUnitId)}})),this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe(e=>{if(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getActiveSheet();r&&this._registerRefRange(e,r.getSheetId())}}))}_registerRefRange(e,r){var i;this._disposableCollection.dispose();let a=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),o=a==null?void 0:a.getSheetBySheetId(r);if(!a||!o)return;let s=(i=this._sheetsFilterService.getFilterModel(e,r))==null?void 0:i.getRange();s&&this._disposableCollection.add(this._refRangeService.registerRefRange(s,t=>{switch(t.id){case n.InsertRowCommand.id:{let n=t.params,i=n.unitId||e,a=n.subUnitId||r;return this._handleInsertRowCommand(n,i,a)}case n.InsertColCommand.id:{let n=t.params,i=n.unitId||e,a=n.subUnitId||r;return this.handleInsertColCommand(n.range,i,a)}case n.RemoveColCommand.id:{let n=t.params;return this.handleRemoveColCommand(n.range,e,r)}case n.RemoveRowCommand.id:{let n=t.params;return this._handleRemoveRowCommand(n,e,r)}case n.EffectRefRangId.MoveColsCommandId:{let n=t.params;return this.handleMoveColsCommand({fromRange:n.fromRange,toRange:n.toRange},e,r)}case n.EffectRefRangId.MoveRowsCommandId:{let n=t.params;return this._handleMoveRowsCommand(n,e,r)}case n.MoveRangeCommand.id:{let n=t.params;return this._handleMoveRangeCommand(n,e,r)}}return{redos:[],undos:[]}},e,r))}_getUpdateFilter(e){let{id:t}=e;switch(t){case n.RemoveSheetCommand.id:{let t=e.params;return this._handleRemoveSheetCommand(t,t.unitId,t.subUnitId)}case n.CopySheetCommand.id:{let{targetSubUnitId:t,unitId:n,subUnitId:r}=e.params;return!n||!r||!t?this._handleNull():this._handleCopySheetCommand(n,r,t)}}return{redos:[],undos:[]}}handleInsertColCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startColumn:a,endColumn:o}=i,{startColumn:s,endColumn:c}=e,l=c-s+1;if(c>o)return this._handleNull();let u=[],d=[],f=s,p={unitId:t,subUnitId:n,range:{...i,startColumn:s<=a?a+l:a,endColumn:o+l}},m={unitId:t,subUnitId:n,range:i};u.push({id:I.id,params:p}),d.push({id:I.id,params:m});let h=r.getAllFilterColumns().filter(e=>e[0]>=f);if(h.length!==0){let{newRange:e,oldRange:r}=this._moveCriteria(t,n,h,l);u.push(...r.redos,...e.redos),d.push(...e.undos,...r.undos)}return{redos:J(u),undos:J(d)}}_handleInsertRowCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startRow:a,endRow:o}=i,{startRow:s,endRow:c}=e.range,l=c-s+1;if(c>o)return this._handleNull();let u=[],d=[],f={unitId:t,subUnitId:n,range:{...i,startRow:s<=a?a+l:a,endRow:o+l}},p={unitId:t,subUnitId:n,range:i};return u.push({id:I.id,params:f}),d.push({id:I.id,params:p}),{redos:J(u),undos:J(d)}}handleRemoveColCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startColumn:a,endColumn:o}=i,{startColumn:s,endColumn:c}=e;if(s>o)return this._handleNull();let l=[],u=[],d=c<a?0:Math.min(c,o)-Math.max(s,a)+1,f=c-s+1,p=r.getAllFilterColumns();p.forEach(e=>{let[r,i]=e;r<=c&&r>=s&&(l.push({id:L.id,params:{unitId:t,subUnitId:n,col:r,criteria:null}}),u.push({id:L.id,params:{unitId:t,subUnitId:n,col:r,criteria:{...i.serialize(),colId:r}}}))});let m=p.filter(e=>{let[t,n]=e;return t>c}),h={undos:[],redos:[]};if(m.length>0){let{oldRange:e,newRange:r}=this._moveCriteria(t,n,m,-f);h=r,l.push(...e.redos),u.unshift(...e.undos)}if(d===o-a+1){let e={unitId:t,subUnitId:n};l.push({id:R.id,params:e}),u.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}})}else{let e=a<=s?a:d===0?a-f:s,r=a<=s?o-d:o-f,c={unitId:t,subUnitId:n,range:{...i,startColumn:e,endColumn:r}};l.push({id:I.id,params:c}),u.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}}),l.push(...h.redos),u.unshift(...h.undos)}return{undos:u,redos:l}}_handleRemoveRowCommand(e,n,r){let i=this._sheetsFilterService.getFilterModel(n,r);if(!i)return this._handleNull();let a=i.getRange(),{startRow:o,endRow:s}=a,{startRow:c,endRow:l}=e.range;if(c>s)return this._handleNull();if(l<o)return{undos:[{id:I.id,params:{range:a,unitId:n,subUnitId:r}}],redos:[{id:I.id,params:{range:{...a,startRow:o-(l-c+1),endRow:s-(l-c+1)},unitId:n,subUnitId:r}}]};let u=[],d=[],f=i.getAllFilterColumns(),p=o<=l&&o>=c;d.push({id:I.id,params:{range:a,unitId:n,subUnitId:r}});let m=Math.min(l,s)-Math.max(c,o)+1;if(m===s-o+1||p){let e={unitId:n,subUnitId:r};u.push({id:R.id,params:e}),f.forEach(e=>{let[t,i]=e,a={unitId:n,subUnitId:r,col:t,criteria:{...i.serialize(),colId:t}};d.push({id:L.id,params:a})})}else{var h;let e=(h=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET))==null?void 0:h.getSheetBySheetId(r);if(!e)return this._handleNull();let i=this._getFilteredRowCount(e,c,l),d=Math.min(o,c),f=d+(s-o)-m+i,p={unitId:n,subUnitId:r,range:{...a,startRow:d,endRow:f}};u.push({id:I.id,params:p})}return{undos:J(d),redos:J(u)}}_getFilteredRowCount(e,t,n){let r=0;for(let i=t;i<=n;i++)e.getRowFiltered(i)&&r++;return r}handleMoveColsCommand({fromRange:e,toRange:n},r,i){let a=this._sheetsFilterService.getFilterModel(r,i),o=(a==null?void 0:a.getRange())??null;if(!a||!o)return this._handleNull();let{startColumn:s,endColumn:c}=o;if(e.endColumn<s&&n.startColumn<=s||e.startColumn>c&&n.endColumn>c)return this._handleNull();let l=[],u=[],d={};for(let e=s;e<=c;e++)d[e]={colIndex:e,filter:a.getFilterColumn(e)};(0,t.moveMatrixArray)(e.startColumn,e.endColumn-e.startColumn+1,n.startColumn,d);let f=o.startColumn,p=o.endColumn;s>=e.startColumn&&s<=e.endColumn&&n.startColumn>e.startColumn&&e.endColumn<c&&(f=e.endColumn+1),c>=e.startColumn&&c<=e.endColumn&&n.startColumn<e.startColumn&&e.startColumn>s&&(p=e.startColumn-1);let m=Object.keys(d).map(e=>Number(e)),h=m.find(e=>d[e].colIndex===p),g=m.find(e=>d[e].colIndex===f);if(m.forEach(e=>{let{colIndex:t,filter:n}=d[e],o=e;if(n){var s;if(o>=g&&o<=h){var c;let e={unitId:r,subUnitId:i,col:o,criteria:{...n.serialize(),colId:o}},t={unitId:r,subUnitId:i,col:o,criteria:a.getFilterColumn(o)?{...(c=a.getFilterColumn(o))==null?void 0:c.serialize(),colId:o}:null};l.push({id:L.id,params:e}),u.push({id:L.id,params:t})}if(!((s=d[t])!=null&&s.filter)){let e={unitId:r,subUnitId:i,col:t,criteria:null};l.push({id:L.id,params:e}),u.push({id:L.id,params:{unitId:r,subUnitId:i,col:t,criteria:{...n.serialize(),colId:t}}})}}}),s!==g||c!==h){let e={unitId:r,subUnitId:i,range:{...o,startColumn:g,endColumn:h}};l.unshift({id:I.id,params:e}),u.unshift({id:I.id,params:{range:o,unitId:r,subUnitId:i}})}return{undos:u,redos:l}}_handleMoveRowsCommand(e,n,r){let i=this._sheetsFilterService.getFilterModel(n,r),a=(i==null?void 0:i.getRange())??null;if(!i||!a)return this._handleNull();let{startRow:o,endRow:s}=a,{fromRange:c,toRange:l}=e;if(c.endRow<o&&l.startRow<=o||c.startRow>s&&l.endRow>s)return this._handleNull();let u=[],d=[],f={};for(let e=o;e<=s;e++)f[e]={oldIndex:e};let p=o,m=s;s>=c.startRow&&s<=c.endRow&&l.startRow<c.startRow&&c.startRow>o&&(m=c.startRow-1),(0,t.moveMatrixArray)(c.startRow,c.endRow-c.startRow+1,l.startRow,f);let h=Object.keys(f).map(e=>Number(e)),g=h.find(e=>f[e].oldIndex===m),_=h.find(e=>f[e].oldIndex===p);if(o!==_||s!==g){let e={unitId:n,subUnitId:r,range:{...a,startRow:_,endRow:g}};u.push({id:I.id,params:e},{id:z.id,params:{unitId:n,subUnitId:r}}),d.push({id:I.id,params:{range:a,unitId:n,subUnitId:r}},{id:z.id,params:{unitId:n,subUnitId:r}})}return{redos:u,undos:d}}_handleMoveRangeCommand(e,n,r){let{fromRange:i,toRange:a}=e,o=this._sheetsFilterService.getFilterModel(n,r);if(!o)return this._handleNull();let s=o.getRange();if(!s)return this._handleNull();let c=[],l=[];if(t.Rectangle.contains(i,s)){let e=s.startRow-i.startRow,t=s.startColumn-i.startColumn,u={startRow:a.startRow+e,startColumn:a.startColumn+t,endRow:a.startRow+e+(s.endRow-s.startRow),endColumn:a.startColumn+t+(s.endColumn-s.startColumn)},d={id:R.id,params:{unitId:n,subUnitId:r}},f={id:I.id,params:{unitId:n,subUnitId:r,range:u}},p={id:I.id,params:{unitId:n,subUnitId:r,range:s}};c.push(d,f),l.push(d,p);let m=o.getAllFilterColumns(),h=a.startColumn-i.startColumn;m.forEach(e=>{let[t,i]=e;i&&(c.push({id:L.id,params:{unitId:n,subUnitId:r,col:t+h,criteria:{...i.serialize(),colId:t+h}}}),l.push({id:L.id,params:{unitId:n,subUnitId:r,col:t,criteria:{...i.serialize(),colId:t}}}))})}else if(t.Rectangle.intersects(a,s)){let e={...s,endRow:Math.max(s.endRow,a.endRow)};c.push({id:I.id,params:{unitId:n,subUnitId:r,range:e}}),l.push({id:I.id,params:{unitId:n,subUnitId:r,range:s}})}return{redos:c,undos:l}}_handleRemoveSheetCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n);if(!r)return this._handleNull();let i=r.getRange();if(!i)return this._handleNull();let a=[],o=[];return r.getAllFilterColumns().forEach(([e,r])=>{o.push({id:L.id,params:{unitId:t,subUnitId:n,col:e,criteria:{...r.serialize(),colId:e}}})}),a.push({id:R.id,params:{unitId:t,subUnitId:n,range:i}}),o.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}}),{undos:o,redos:a}}_handleCopySheetCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return this._handleNull();let i=r.getRange();if(!i)return this._handleNull();let a=[],o=[],s=[];return r.getAllFilterColumns().forEach(([t,r])=>{a.push({id:L.id,params:{unitId:e,subUnitId:n,col:t,criteria:{...r.serialize(),colId:t}}}),s.push({id:L.id,params:{unitId:e,subUnitId:n,col:t,criteria:null}})}),s.push({id:R.id,params:{unitId:e,subUnitId:n,range:i}}),a.unshift({id:I.id,params:{range:i,unitId:e,subUnitId:n}}),{undos:o,redos:a,preUndos:s,preRedos:[]}}_handleNull(){return{redos:[],undos:[]}}_initRowFilteredInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.ROW_FILTERED,{handler:(e,t)=>{var n;return e?!0:((n=this._sheetsFilterService.getFilterModel(t.unitId,t.subUnitId))==null?void 0:n.isRowFiltered(t.row))??!1}}))}_moveCriteria(e,t,n,r){let i={unitId:e,subUnitId:t,criteria:null,col:-1},a=[],o=[],s=[],c=[];return n.forEach(e=>{let[t,n]=e;o.push({id:L.id,params:{...i,col:t}}),a.push({id:L.id,params:{...i,col:t,criteria:{...n.serialize(),colId:t}}})}),n.forEach(e=>{let[t,n]=e;c.push({id:L.id,params:{...i,col:t+r,criteria:{...n.serialize(),colId:t+r}}}),s.push({id:L.id,params:{...i,col:t+r,criteria:null}})}),{newRange:{redos:c,undos:s},oldRange:{redos:o,undos:a}}}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{let{unitId:r,subUnitId:i}=e.params||{},a=this._sheetsFilterService.getFilterModel(r,i);if(!a)return;let o=Array.from(a.filteredOutRows).sort((e,t)=>e-t),s=[],c=!1;if(e.id===n.RemoveRowMutation.id){let{startRow:t,endRow:n}=e.params.range,r=o.filter(e=>e>=t&&e<=n);o.forEach(e=>{if(e<t)s.push(e);else if(c=!0,e<=n){let e=Math.max(t,s.length?s[s.length-1]+1:t);s.push(e)}else s.push(e-(n-t+1-r.length))})}if(e.id===n.InsertRowMutation.id){let{startRow:t,endRow:n}=e.params.range;o.forEach(e=>{e>=t?(c=!0,s.push(e+(n-t+1))):s.push(e)})}if(c&&(a.filteredOutRows=new Set(s)),e.id===n.SetRangeValuesMutation.id&&!(t!=null&&t.onlyLocal)){let t=this._getExtendRegion(r,i);if(t){let a=e.params.cellValue;if(a)for(let e=t.startColumn;e<=t.endColumn;e++){var l;let o=a==null||(l=a[t.startRow])==null?void 0:l[e];if(o&&this._cellHasValue(o)){var u;let e=(u=this._univerInstanceService.getUnit(r))==null?void 0:u.getSheetBySheetId(i);if(e){let a=(0,n.expandToContinuousRange)(t,{down:!0},e),o=this._sheetsFilterService.getFilterModel(r,i),s=o.getRange();o.setRange({...s,endRow:a.endRow}),this._registerRefRange(r,i)}}}}}}))}_getExtendRegion(e,t){var n;let r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return null;let i=(n=this._univerInstanceService.getUnit(e))==null?void 0:n.getSheetBySheetId(t);if(!i)return null;let a=r.getRange();if(!a)return null;let o=i.getRowCount()-1,s=i.getRowManager();for(let e=a.endRow+1;e<=o;e++)if(s.getRowRawVisible(e))return{startRow:e,endRow:e,startColumn:a.startColumn,endColumn:a.endColumn};return null}_initErrorHandling(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{let t=e.params,r=(0,n.getSheetCommandTarget)(this._univerInstanceService,t);if(!r)return;let{subUnitId:i,unitId:a}=r,o=this._sheetsFilterService.getFilterModel(a,i);if(!o)return;let s=o.getRange();if(e.id===n.MoveRowsCommand.id&&t.fromRange.startRow<=s.startRow&&t.fromRange.endRow<s.endRow&&t.fromRange.endRow>=s.startRow)throw this._sheetsFilterService.setFilterErrorMsg(`sheets-filter.msg.filter-header-forbidden`),Error(`[SheetsFilterController]: Cannot move header row of filter`)}))}_cellHasValue(e){let t=Object.values(e);return!(t.length===0||t.every(e=>e==null))}};Y=N([M(0,t.ICommandService),M(1,(0,t.Inject)(n.SheetInterceptorService)),M(2,(0,t.Inject)(F)),M(3,t.IUniverInstanceService),M(4,(0,t.Inject)(n.RefRangeService)),M(5,(0,t.Optional)(a.DataSyncPrimaryController)),M(6,(0,t.Inject)(n.ZebraCrossingCacheController))],Y);let ve=[L.id,z.id],X=[n.InsertColMutation.id,n.RemoveColMutation.id,n.MoveColsMutation.id],Z=class extends t.Disposable{get visible(){return this._visible$.getValue()}get enabled(){return this._enabled$.getValue()}constructor(e,n,i){super(),this._sheetsFilterController=e,this._commandService=n,this._configService=i,E(this,`_d`,new t.DisposableCollection),E(this,`_visible$`,new r.BehaviorSubject(!1)),E(this,`visible$`,this._visible$.asObservable()),E(this,`_enabled$`,new r.BehaviorSubject(!0)),E(this,`enabled$`,this._enabled$.asObservable());let a=this._configService.getConfig(K);a!=null&&a.enableSyncSwitch&&(this._visible$.next(!0),typeof a.enableSyncSwitch==`object`&&this.setEnabled(a.enableSyncSwitch.defaultValue??!0))}setEnabled(e){this._enabled$.next(e),e?this._d.dispose():this._initOnlyLocalListener()}_initOnlyLocalListener(){this._d.add(this._commandService.beforeCommandExecuted((e,t)=>{ve.includes(e.id)&&(t||={},t.onlyLocal=!0)})),this._d.add(this._commandService.onCommandExecuted((e,r)=>{if(X.includes(e.id)&&r!=null&&r.fromCollab){if(e.id===n.InsertColMutation.id){let{range:n,unitId:i,subUnitId:a}=e.params,{redos:o}=this._sheetsFilterController.handleInsertColCommand(n,i,a);(0,t.sequenceExecute)(o,this._commandService,r)}else if(e.id===n.RemoveColMutation.id){let{range:n,unitId:i,subUnitId:a}=e.params,{redos:o}=this._sheetsFilterController.handleRemoveColCommand(n,i,a);(0,t.sequenceExecute)(o,this._commandService,r)}else if(e.id===n.MoveColsMutation.id){let{sourceRange:n,targetRange:i,unitId:a,subUnitId:o}=e.params,{redos:s}=this._sheetsFilterController.handleMoveColsCommand({fromRange:n,toRange:i},a,o);(0,t.sequenceExecute)(s,this._commandService,r)}}}))}};Z=N([M(0,(0,t.Inject)(Y)),M(1,t.ICommandService),M(2,t.IConfigService)],Z);var ye=`@univerjs/sheets-filter`,be=`1.0.0-insiders.20260813-7c9aa50`;let Q=class extends t.Disposable{constructor(e,t,n,r){super(),this._activeDirtyManagerService=e,this._sheetRowFilteredService=t,this._sheetsFilterService=n,this._univerInstanceService=r,this._initFormulaDirtyRange(),this._registerSheetRowFiltered()}_initFormulaDirtyRange(){d.forEach(e=>{this._activeDirtyManagerService.register(e,{commandId:e,getDirtyData:e=>{let{unitId:t,subUnitId:n}=e.params;return{dirtyRanges:this._getHideRowMutation(t,n),clearDependencyTreeCache:{[t]:{[n]:`1`}}}}})})}_getHideRowMutation(e,t){var n,r;let i=(n=this._sheetsFilterService.getFilterModel(e,t))==null?void 0:n.getRange(),a=(r=this._univerInstanceService.getUnit(e))==null?void 0:r.getSheetBySheetId(t);if(i==null||a==null)return[];let{startRow:o,endRow:s}=i;return[{unitId:e,sheetId:t,range:{startRow:o,startColumn:0,endRow:s,endColumn:a.getColumnCount()-1}}]}_registerSheetRowFiltered(){this._sheetRowFilteredService.register((e,t,n)=>{var r;return((r=this._sheetsFilterService.getFilterModel(e,t))==null?void 0:r.isRowFiltered(n))??!1})}};Q=N([M(0,(0,t.Inject)(o.IActiveDirtyManagerService)),M(1,(0,t.Inject)(o.ISheetRowFilteredService)),M(2,(0,t.Inject)(F)),M(3,t.IUniverInstanceService)],Q);let $=class extends t.Plugin{constructor(e=q,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},q,this._config);this._configService.setConfig(K,i)}onStarting(){[[Q],[F],[Y],[Z]].forEach(e=>this._injector.add(e))}onReady(){(0,t.touchDependencies)(this._injector,[[Q],[Y],[Z]])}};E($,`type`,t.UniverInstanceType.UNIVER_SHEET),E($,`pluginName`,P),E($,`packageName`,ye),E($,`version`,be),$=N([(0,t.DependentOn)(o.UniverFormulaEnginePlugin,n.UniverSheetsPlugin),M(1,(0,t.Inject)(t.Injector)),M(2,t.IConfigService)],$),e.ClearSheetsFilterCriteriaCommand=U,e.CustomFilterOperator=p,e.FILTER_MUTATIONS=d,e.FilterBy=f,e.FilterColumn=k,e.FilterModel=O,e.ReCalcSheetsFilterCommand=W,e.ReCalcSheetsFilterMutation=z,e.RemoveSheetFilterCommand=V,e.RemoveSheetsFilterMutation=R,e.SHEET_FILTER_SNAPSHOT_ID=P,e.SetSheetFilterRangeCommand=B,e.SetSheetsFilterCriteriaCommand=H,e.SetSheetsFilterCriteriaMutation=L,e.SetSheetsFilterRangeMutation=I,Object.defineProperty(e,"SheetsFilterService",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SheetsFilterSyncController",{enumerable:!0,get:function(){return Z}}),e.SmartToggleSheetsFilterCommand=pe,Object.defineProperty(e,"UniverSheetsFilterPlugin",{enumerable:!0,get:function(){return $}}),e.equals=v,e.getCustomFilterFn=x,e.greaterThan=m,e.greaterThanOrEqualTo=h,e.lessThan=g,e.lessThanOrEqualTo=_,e.notEquals=y});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/rpc"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`@univerjs/sheets`,`rxjs`,`@univerjs/engine-render`,`@univerjs/rpc`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsFilter={},e.UniverCore,e.UniverSheets,e.rxjs,e.UniverEngineRender,e.UniverRpc,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let s=`sheet.mutation.set-filter-range`,c=`sheet.mutation.set-filter-criteria`,l=`sheet.mutation.remove-filter`,u=`sheet.mutation.re-calc-filter`,d=new Set([s,c,l,u]),f=function(e){return e[e.VALUES=0]=`VALUES`,e[e.COLORS=1]=`COLORS`,e[e.CONDITIONS=2]=`CONDITIONS`,e}({}),p=function(e){return e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_EQUALS=`notEqual`,e}({}),m={operator:`greaterThan`,fn:(e,t)=>S(e)?e>t:!1},h={operator:`greaterThanOrEqual`,fn:(e,t)=>S(e)?e>=t:!1},g={operator:`lessThan`,fn:(e,t)=>S(e)?e<t:!1},_={operator:`lessThanOrEqual`,fn:(e,t)=>S(e)?e<=t:!1},v={operator:`equal`,fn:(e,t)=>S(e)?e===t:!1},y={operator:`notEqual`,fn:(e,n)=>{if(typeof n==`string`){if(n===` `)return e!=null;let r=w(e);return r&&ne(n)?!t.regexp.createFromWildcard(n).test(r):r!==n}return!S(e)||e!==n}},b=new Map([]);[m,h,g,_,v,y].forEach(e=>{b.set(e.operator,e)});function ee(e){return!!e}let te={fn:(e,n)=>{let r=w(e);return r===null?n===``:t.regexp.createFromWildcard(n).test(r)}};function x(e){return e?b.get(e):te}function S(e){return typeof e==`number`}function C(e){return!!(typeof e==`number`||typeof e==`string`&&(0,t.isNumeric)(e))}function w(e){return typeof e==`boolean`||e==null?null:typeof e==`string`?e:e.toString()}function ne(e){return typeof e==`number`?!1:e.indexOf(`*`)!==-1||e.indexOf(`?`)!==-1}function T(e){"@babel/helpers - typeof";return T=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},T(e)}function re(e,t){if(T(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(T(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ie(e){var t=re(e,`string`);return T(t)==`symbol`?t:t+``}function E(e,t,n){return(t=ie(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let D=()=>new Set;var O=class e extends t.Disposable{get filteredOutRows(){return this._filteredOutRows$.getValue()}set filteredOutRows(e){this._alreadyFilteredOutRows=e,this._filteredOutRows$.next(e)}constructor(e,t,n){super(),this.unitId=e,this.subUnitId=t,this._worksheet=n,E(this,`_filteredOutRows$`,new r.BehaviorSubject(D())),E(this,`filteredOutRows$`,this._filteredOutRows$.asObservable()),E(this,`_hasCriteria$`,new r.BehaviorSubject(!1)),E(this,`hasCriteria$`,this._hasCriteria$.asObservable()),E(this,`_filterColumnByIndex`,new Map),E(this,`_alreadyFilteredOutRows`,D()),E(this,`_range`,void 0)}dispose(){super.dispose(),this._filteredOutRows$.complete(),this._hasCriteria$.complete(),this._worksheet=null}serialize(){let e={ref:t.Rectangle.clone(this._range),filterColumns:this._getAllFilterColumns(!0).sort(([e],[t])=>e-t).map(([e,t])=>t.serialize())};return this._alreadyFilteredOutRows&&(e.cachedFilteredOut=Array.from(this._alreadyFilteredOutRows).sort()),e}static deserialize(t,n,r,i){let a=new e(t,n,r);return a._dump(i),a}_dump(e){var t;this.setRange(e.ref),(t=e.filterColumns)==null||t.filter(e=>!(!e.filters&&!e.colorFilters&&!e.customFilters)).forEach(e=>this._setCriteriaWithoutReCalc(e.colId,e)),e.cachedFilteredOut?(this._alreadyFilteredOutRows=new Set(e.cachedFilteredOut),this._emit()):e.filterColumns&&e.filterColumns.length>0&&(this._reCalcAllColumns(),this._emit()),this._emitHasCriteria()}isRowFiltered(e){return this._alreadyFilteredOutRows.has(e)}getRange(){if(!this._range)throw Error(`[FilterModel] could not get range before a range is set!`);return this._range}getFilteredOutRowsExceptCol(e){return this._getAllFilterColumns(!0).filter(([t])=>t!==e).reduce((e,[,n])=>{let r=n.calc({getAlreadyFilteredOutRows:()=>e});return r?(0,t.mergeSets)(e,r):e},new Set)}setRange(e){this._range=e,this._getAllFilterColumns(!0).forEach(([t,n])=>{n.setRangeAndColumn({startRow:e.startRow,endRow:e.endRow,startColumn:t,endColumn:t},t)})}setCriteria(e,t,n=!1){if(!this._range)throw Error(`[FilterModel] could not set criteria before a range is set!`);if(!t){this._removeCriteria(e),this._rebuildAlreadyFilteredOutRowsWithCache(),n&&this._reCalcAllColumns(),this._emit(),this._emitHasCriteria();return}this._setCriteriaWithoutReCalc(e,t),n&&(this._rebuildAlreadyFilteredOutRowsWithCache(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns(),this._emit(),this._emitHasCriteria())}getAllFilterColumns(){return this._getAllFilterColumns(!0)}getFilterColumn(e){return this._filterColumnByIndex.get(e)??null}reCalc(){this._reCalcAllColumns(),this._emit()}_getAllFilterColumns(e=!1){let t=Array.from(this._filterColumnByIndex.entries());return e?t:t.map(([e,t])=>t)}_reCalcAllColumns(){this._alreadyFilteredOutRows=D(),this._getAllFilterColumns().forEach(e=>e.__clearCache()),this._reCalcWithNoCacheColumns()}_setCriteriaWithoutReCalc(e,t){let n=this._range;if(!n)throw Error(`[FilterModel] could not set criteria before a range is set!`);let{startColumn:r,endColumn:i}=n;if(e>i||e<r)throw Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);let a;this._filterColumnByIndex.has(e)?a=this._filterColumnByIndex.get(e):(a=new k(this.unitId,this.subUnitId,this._worksheet,t,{getAlreadyFilteredOutRows:()=>this._alreadyFilteredOutRows}),a.setRangeAndColumn(n,e),this._filterColumnByIndex.set(e,a)),a.setCriteria(t)}_removeCriteria(e){let t=this._filterColumnByIndex.get(e);t&&(t.dispose(),this._filterColumnByIndex.delete(e))}_emit(){this._filteredOutRows$.next(this._alreadyFilteredOutRows)}_emitHasCriteria(){this._hasCriteria$.next(this._filterColumnByIndex.size>0)}_rebuildAlreadyFilteredOutRowsWithCache(){let e=this._getAllFilterColumns().filter(e=>e.hasCache()).reduce((e,n)=>(0,t.mergeSets)(e,n.filteredOutRows),new Set);this._alreadyFilteredOutRows=e}_reCalcWithNoCacheColumns(){let e=this._getAllFilterColumns().filter(e=>!e.hasCache());for(let n of e){let e=n.reCalc();e&&(this._alreadyFilteredOutRows=(0,t.mergeSets)(this._alreadyFilteredOutRows,e))}}},k=class extends t.Disposable{get filteredOutRows(){return this._filteredOutRows}get filterBy(){return this._filterBy}constructor(e,t,n,r,i){super(),this.unitId=e,this.subUnitId=t,this._worksheet=n,this._criteria=r,this._filterColumnContext=i,E(this,`_filteredOutRows`,null),E(this,`_filterFn`,null),E(this,`_range`,null),E(this,`_column`,0),E(this,`_filterBy`,0)}dispose(){super.dispose(),this._filteredOutRows=null}__clearCache(){this._filteredOutRows=null}serialize(){if(!this._criteria)throw Error(`[FilterColumn]: could not serialize without a filter column!`);return t.Tools.deepClone({...this._criteria,colId:this._column})}hasCache(){return this._filteredOutRows!==null}setRangeAndColumn(e,t){this._range=e,this._column=t}setCriteria(e){this._criteria=e,this._generateFilterFn(),this._filteredOutRows=null}getColumnData(){return t.Tools.deepClone(this._criteria)}reCalc(){return this._filteredOutRows=this.calc(this._filterColumnContext),this._filteredOutRows}calc(e){if(!this._filterFn)throw Error(`[FilterColumn] cannot calculate without a filter fn!`);if(!this._range)throw Error(`[FilterColumn] cannot calculate without a range!`);if(typeof this._column!=`number`)throw TypeError(`[FilterColumn] cannot calculate without a column offset!`);let n=this._column,r={startColumn:n,endColumn:n,startRow:this._range.startRow+1,endRow:this._range.endRow},i=new Set,a=e.getAlreadyFilteredOutRows();for(let e of this._worksheet.iterateByColumn(r,!1,!1)){let{row:n,rowSpan:r,col:o}=e;if((!a.has(n)||r&&r!==1)&&!(this._filterBy===0?this._filterFn((0,t.extractPureTextFromCell)(this._worksheet.getCell(n,o))):this._filterBy===1?this._filterFn(this._worksheet.getComposedCellStyle(n,o)):this._filterFn(fe(this._worksheet,n,o)))&&(i.add(n),r))for(let e=1;e<r;e++)i.add(n+e)}return i}_generateFilterFn(){this._criteria&&(this._filterFn=ae(this._criteria),this._filterBy=this._criteria.filters?0:this._criteria.colorFilters?1:2)}};function ae(e){if(e.filters)return oe(e.filters);if(e.colorFilters)return se(e.colorFilters);if(e.customFilters)return ce(e.customFilters);throw Error(`[FilterModel]: other types of filters are not supported yet.`)}function oe(e){let t=!!e.blank,n=new Set(e.filters);return e=>e===void 0||e===``?t:n.has(typeof e==`string`?e:`${e}`)}function se(e){if(e.cellFillColors){let n=new Set(e.cellFillColors);return e=>{var r;if(!e||!((r=e.bg)!=null&&r.rgb))return!!n.has(null);let i=new t.ColorKit(e.bg.rgb).toRgbString();return n.has(i)}}if(e.cellTextColors){let n=new Set(e.cellTextColors);return e=>{var r;if(!e||!((r=e.cl)!=null&&r.rgb))return!!n.has(i.COLOR_BLACK_RGB);let a=new t.ColorKit(e.cl.rgb).toRgbString();return n.has(a)}}throw Error(`[FilterModel]: color filters are not supported yet.`)}function ce(e){let t=e.customFilters.map(e=>A(e));return de(t)?e.and?le(t):ue(t):t[0]}function le(e){let[t,n]=e;return e=>t(e)&&n(e)}function ue(e){let[t,n]=e;return e=>t(e)||n(e)}function de(e){return e.length===2}function A(e){let t=e.val;if(e.operator===`notEqual`&&!C(t))return e=>y.fn(e,t);if(ee(e.operator)){if(!C(t))return()=>!1;let n=x(e.operator),r=Number(t);return e=>n.fn(e,r)}let n=x(e.operator);return e=>n.fn(e,t)}function fe(e,n,r){let i=e.getCell(n,r);if(!i)return null;let a=e.getCellRaw(n,r);return i&&!a?j(i):a?i.t===t.CellValueType.NUMBER&&typeof i.v==`string`?a.v:i.t===t.CellValueType.NUMBER?Number(a.v):j(a):null}function j(e){var n;let r=(n=e.p)==null||(n=n.body)==null?void 0:n.dataStream;if(r)return r.trimEnd();let i=e.v;return typeof i==`string`?e.t===t.CellValueType.BOOLEAN?i.toUpperCase():i:typeof i==`number`?e.t===t.CellValueType.BOOLEAN?i?`TRUE`:`FALSE`:i:typeof i==`boolean`?i?`TRUE`:`FALSE`:``}function M(e,t){return function(n,r){t(n,r,e)}}function N(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let P=`SHEET_FILTER_PLUGIN`,F=class extends t.Disposable{get activeFilterModel(){return this._activeFilterModel$.getValue()}constructor(e,t,n){super(),this._resourcesManagerService=e,this._univerInstanceService=t,this._commandService=n,E(this,`_filterModels`,new Map),E(this,`_loadedUnitId$`,new r.BehaviorSubject(null)),E(this,`loadedUnitId$`,this._loadedUnitId$.asObservable()),E(this,`_errorMsg$`,new r.BehaviorSubject(null)),E(this,`errorMsg$`,this._errorMsg$.asObservable()),E(this,`_activeFilterModel$`,new r.BehaviorSubject(null)),E(this,`activeFilterModel$`,this._activeFilterModel$.asObservable()),this._initModel(),this._initActiveFilterModel()}ensureFilterModel(e,n){let r=this.getFilterModel(e,n);if(r)return r;let i=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);if(!i)throw Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${e}!`);let a=i.getSheetBySheetId(n);if(!a)throw Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${n}!`);let o=new O(e,n,a);return this._cacheFilterModel(e,n,o),o}getFilterModel(e,t){var n;return((n=this._filterModels.get(e))==null?void 0:n.get(t))??null}removeFilterModel(e,t){let n=this.getFilterModel(e,t);return n?(n.dispose(),this._filterModels.get(e).delete(t),!0):!1}setFilterErrorMsg(e){this._errorMsg$.next(e)}_updateActiveFilterModel(){let e;try{if(e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),!e){this._activeFilterModel$.next(null);return}}catch(e){console.error(`[SheetsFilterService]: could not get active workbook!`,e);return}let n=e.getActiveSheet(!0);if(!n){this._activeFilterModel$.next(null);return}let r=n.getUnitId(),i=n.getSheetId(),a=this.getFilterModel(r,i);this._activeFilterModel$.next(a)}_initActiveFilterModel(){this.disposeWithMe((0,r.merge)((0,t.fromCallback)(this._commandService.onCommandExecuted.bind(this._commandService)).pipe((0,r.filter)(([e])=>e.type===t.CommandType.MUTATION&&d.has(e.id))),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).pipe((0,r.switchMap)(e=>(e==null?void 0:e.activeSheet$)??(0,r.of)(null)))).subscribe(()=>this._updateActiveFilterModel()))}_serializeAutoFiltersForUnit(e){let t=this._filterModels.get(e);if(!t)return`{}`;let n={};return t.forEach((e,t)=>{n[t]=e.serialize()}),JSON.stringify(n)}_deserializeAutoFiltersForUnit(e,n){let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET);Object.keys(n).forEach(t=>{let i=n[t],a=O.deserialize(e,t,r.getSheetBySheetId(t),i);this._cacheFilterModel(e,t,a)})}dispose(){super.dispose(),this._loadedUnitId$.complete(),this._errorMsg$.complete(),this._activeFilterModel$.complete(),this._filterModels.forEach(e=>{e.forEach(e=>e.dispose()),e.clear()}),this._filterModels.clear()}_initModel(){this._resourcesManagerService.registerPluginResource({pluginName:P,businesses:[t.UniverInstanceType.UNIVER_SHEET],toJson:e=>this._serializeAutoFiltersForUnit(e),parseJson:e=>JSON.parse(e),onLoad:(e,t)=>{this._deserializeAutoFiltersForUnit(e,t),this._loadedUnitId$.next(e),this._updateActiveFilterModel()},onUnLoad:e=>{let t=this._filterModels.get(e);t&&(t.forEach(e=>e.dispose()),this._filterModels.delete(e))}})}_cacheFilterModel(e,t,n){this._filterModels.has(e)||this._filterModels.set(e,new Map),this._filterModels.get(e).set(t,n)}};F=N([M(0,t.IResourceManagerService),M(1,t.IUniverInstanceService),M(2,t.ICommandService)],F);let I={id:s,type:t.CommandType.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,range:i}=t,a=e.get(F).ensureFilterModel(r,n);return a.setRange(i),t.filteredOutRows=Array.from(a.filteredOutRows),!0}},L={id:c,type:t.CommandType.MUTATION,handler:(e,t)=>{let{subUnitId:n,unitId:r,criteria:i,col:a,reCalc:o=!0}=t,s=e.get(F).getFilterModel(r,n);return s?(s.setCriteria(a,i,o),t.filteredOutRows=Array.from(s.filteredOutRows),!0):!1}},R={id:l,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r}=t,i=e.get(F).removeFilterModel(n,r);return i&&(t.filteredOutRows=[]),i}},z={id:u,type:t.CommandType.MUTATION,handler:(e,t)=>{let{unitId:n,subUnitId:r}=t,i=e.get(F).getFilterModel(n,r);return i?(i.reCalc(),t.filteredOutRows=Array.from(i.filteredOutRows),!0):!1}},B={id:`sheet.command.set-filter-range`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=e.get(F),a=e.get(t.ICommandService),o=e.get(t.IUndoRedoService),s=e.get(t.IUniverInstanceService),{unitId:c,subUnitId:l,range:u}=r;if(!(0,n.getSheetCommandTarget)(s,r)||i.getFilterModel(c,l))return!1;if(u.endRow===u.startRow){let n=e.get(t.ErrorService),r=e.get(t.LocaleService);return n.emit(r.t(`sheets-filter.command.not-valid-filter-range`)),!1}let d={id:I.id,params:{unitId:c,subUnitId:l,range:u}},f=a.syncExecuteCommand(d.id,d.params);return f&&o.pushUndoRedo({unitID:c,undoMutations:[{id:R.id,params:{unitId:c,subUnitId:l}}],redoMutations:[d]}),f}},V={id:`sheet.command.remove-sheet-filter`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let l=c.getRange();if(!l)return!1;let u=e.get(t.ICommandService),d=e.get(t.IUndoRedoService),f=me(o,s,c.serialize()),p=u.syncExecuteCommand(R.id,{unitId:o,subUnitId:s});return p&&(d.pushUndoRedo({unitID:o,undoMutations:f,redoMutations:[{id:R.id,params:{unitId:o,subUnitId:s}}]}),u.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:l})),p}},pe={id:`sheet.command.smart-toggle-filter`,type:t.CommandType.COMMAND,handler:async e=>{let r=e.get(t.IUniverInstanceService),i=e.get(F),a=e.get(t.ICommandService),o=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s||!o)return!1;let c=o.getUnitId(),l=s.getSheetId();if(i.getFilterModel(c,l))return a.executeCommand(V.id,{unitId:c,subUnitId:l});let u=e.get(n.SheetsSelectionsService).getCurrentLastSelection();if(!u)return!1;let d=u.range,f=(0,n.isSingleCellSelection)(u)?(0,n.expandToContinuousRange)(d,{left:!0,right:!0,up:!0,down:!0},s):d.startRow===d.endRow?(0,n.expandToContinuousRange)(d,{down:!0},s):d;return a.executeCommand(B.id,{unitId:c,subUnitId:l,range:f})}},H={id:`sheet.command.set-filter-criteria`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let{col:l,criteria:u}=r,d=c.getRange();if(!d||l<d.startColumn||l>d.endColumn)return!1;let f=e.get(t.ICommandService),p=e.get(t.IUndoRedoService),m=ge(o,s,l,c.getFilterColumn(l)),h={id:L.id,params:{unitId:o,subUnitId:s,col:l,criteria:u}},g=f.syncExecuteCommand(h.id,h.params);return g&&(p.pushUndoRedo({unitID:o,undoMutations:[m],redoMutations:[h]}),f.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:d})),g}},U={id:`sheet.command.clear-filter-criteria`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService),r);if(!i)return!1;let a=e.get(F),{unitId:o,subUnitId:s}=i,c=a.getFilterModel(o,s);if(!c)return!1;let l=c.getRange();if(!l)return!1;let u=e.get(t.IUndoRedoService),d=e.get(t.ICommandService),f=c.serialize(),p=G(o,s,f),m=he(o,s,f);return(0,t.sequenceExecute)(m,d).result?(u.pushUndoRedo({unitID:o,undoMutations:p,redoMutations:m}),d.executeCommand(n.MarkDirtyFilterChangeMutation.id,{unitId:o,subUnitId:s,filterRange:l}),!0):!1}},W={id:`sheet.command.re-calc-filter`,type:t.CommandType.COMMAND,handler:(e,r)=>{let i=e.get(F),a=e.get(t.ICommandService),o=e.get(t.IUniverInstanceService),s=(0,n.getSheetCommandTarget)(o,r);if(!s)return!1;let{unitId:c,subUnitId:l}=s;return i.getFilterModel(s.unitId,s.subUnitId)?a.executeCommand(z.id,{unitId:c,subUnitId:l}):!1}};function me(e,t,n){let r=[],i={id:I.id,params:{unitId:e,subUnitId:t,range:n.ref}};return r.push(i),G(e,t,n).forEach(e=>r.push(e)),r}function G(e,t,n){var r;let i=[];return(r=n.filterColumns)==null||r.forEach(n=>{let r={id:L.id,params:{unitId:e,subUnitId:t,col:n.colId,criteria:n}};i.push(r)}),i}function he(e,t,n){var r;let i=[];return(r=n.filterColumns)==null||r.forEach(n=>{let r={id:L.id,params:{unitId:e,subUnitId:t,col:n.colId,criteria:null}};i.push(r)}),i}function ge(e,t,n,r){if(!r)return{id:L.id,params:{unitId:e,subUnitId:t,col:n,criteria:null}};let i=r.serialize();return{id:L.id,params:{unitId:e,subUnitId:t,col:n,criteria:i}}}let K=`sheets-filter.config`,q={};function _e(e,t){for(let n=0;n<e.length;n++){let r=n;if(e[n])for(let i=n+1;i<e.length;i++)e[r]&&e[i]&&t(e[r],e[i])&&(e[r]=null,r=i)}return e.filter(e=>e!==null)}function J(e){return _e(e,(e,t)=>e.id===L.id&&t.id===L.id&&e.params.unitId===t.params.unitId&&e.params.subUnitId===t.params.subUnitId&&e.params.col===t.params.col)}let Y=class extends t.Disposable{constructor(e,n,r,i,a,o,s){super(),this._commandService=e,this._sheetInterceptorService=n,this._sheetsFilterService=r,this._univerInstanceService=i,this._refRangeService=a,this._dataSyncPrimaryController=o,this._zebraCrossingCacheController=s,E(this,`_disposableCollection`,new t.DisposableCollection),this._initCommands(),this._initRowFilteredInterceptor(),this._initInterceptors(),this._commandExecutedListener(),this._initErrorHandling(),this._initZebraCrossingCacheListener()}_initZebraCrossingCacheListener(){this.disposeWithMe(this._sheetsFilterService.activeFilterModel$.subscribe(e=>{e&&this.disposeWithMe(e.filteredOutRows$.subscribe(()=>{this._zebraCrossingCacheController.updateZebraCrossingCache(e.unitId,e.subUnitId)}))}))}_initCommands(){[B,V,H,U,W].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))}),[L,I,z,R].forEach(e=>{var t;this.disposeWithMe(this._commandService.registerCommand(e)),(t=this._dataSyncPrimaryController)==null||t.registerSyncingMutations(e)})}_initInterceptors(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>this._getUpdateFilter(e)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===n.SetWorksheetActiveOperation.id){let t=e.params,n=t.subUnitId,r=t.unitId;if(!n||!r)return;this._registerRefRange(r,n)}if(e.id===I.id){let t=e.params,n=t.subUnitId,r=t.unitId;if(!n||!r)return;this._registerRefRange(t.unitId,t.subUnitId)}})),this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe(e=>{if(e){let n=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),r=n==null?void 0:n.getActiveSheet();r&&this._registerRefRange(e,r.getSheetId())}}))}_registerRefRange(e,r){var i;this._disposableCollection.dispose();let a=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_SHEET),o=a==null?void 0:a.getSheetBySheetId(r);if(!a||!o)return;let s=(i=this._sheetsFilterService.getFilterModel(e,r))==null?void 0:i.getRange();s&&this._disposableCollection.add(this._refRangeService.registerRefRange(s,t=>{switch(t.id){case n.InsertRowCommand.id:{let n=t.params,i=n.unitId||e,a=n.subUnitId||r;return this._handleInsertRowCommand(n,i,a)}case n.InsertColCommand.id:{let n=t.params,i=n.unitId||e,a=n.subUnitId||r;return this.handleInsertColCommand(n.range,i,a)}case n.RemoveColCommand.id:{let n=t.params;return this.handleRemoveColCommand(n.range,e,r)}case n.RemoveRowCommand.id:{let n=t.params;return this._handleRemoveRowCommand(n,e,r)}case n.EffectRefRangId.MoveColsCommandId:{let n=t.params;return this.handleMoveColsCommand({fromRange:n.fromRange,toRange:n.toRange},e,r)}case n.EffectRefRangId.MoveRowsCommandId:{let n=t.params;return this._handleMoveRowsCommand(n,e,r)}case n.MoveRangeCommand.id:{let n=t.params;return this._handleMoveRangeCommand(n,e,r)}}return{redos:[],undos:[]}},e,r))}_getUpdateFilter(e){let{id:t}=e;switch(t){case n.RemoveSheetCommand.id:{let t=e.params;return this._handleRemoveSheetCommand(t,t.unitId,t.subUnitId)}case n.CopySheetCommand.id:{let{targetSubUnitId:t,unitId:n,subUnitId:r}=e.params;return!n||!r||!t?this._handleNull():this._handleCopySheetCommand(n,r,t)}}return{redos:[],undos:[]}}handleInsertColCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startColumn:a,endColumn:o}=i,{startColumn:s,endColumn:c}=e,l=c-s+1;if(c>o)return this._handleNull();let u=[],d=[],f=s,p={unitId:t,subUnitId:n,range:{...i,startColumn:s<=a?a+l:a,endColumn:o+l}},m={unitId:t,subUnitId:n,range:i};u.push({id:I.id,params:p}),d.push({id:I.id,params:m});let h=r.getAllFilterColumns().filter(e=>e[0]>=f);if(h.length!==0){let{newRange:e,oldRange:r}=this._moveCriteria(t,n,h,l);u.push(...r.redos,...e.redos),d.push(...e.undos,...r.undos)}return{redos:J(u),undos:J(d)}}_handleInsertRowCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startRow:a,endRow:o}=i,{startRow:s,endRow:c}=e.range,l=c-s+1;if(c>o)return this._handleNull();let u=[],d=[],f={unitId:t,subUnitId:n,range:{...i,startRow:s<=a?a+l:a,endRow:o+l}},p={unitId:t,subUnitId:n,range:i};return u.push({id:I.id,params:f}),d.push({id:I.id,params:p}),{redos:J(u),undos:J(d)}}handleRemoveColCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n),i=(r==null?void 0:r.getRange())??null;if(!r||!i)return this._handleNull();let{startColumn:a,endColumn:o}=i,{startColumn:s,endColumn:c}=e;if(s>o)return this._handleNull();let l=[],u=[],d=c<a?0:Math.min(c,o)-Math.max(s,a)+1,f=c-s+1,p=r.getAllFilterColumns();p.forEach(e=>{let[r,i]=e;r<=c&&r>=s&&(l.push({id:L.id,params:{unitId:t,subUnitId:n,col:r,criteria:null}}),u.push({id:L.id,params:{unitId:t,subUnitId:n,col:r,criteria:{...i.serialize(),colId:r}}}))});let m=p.filter(e=>{let[t,n]=e;return t>c}),h={undos:[],redos:[]};if(m.length>0){let{oldRange:e,newRange:r}=this._moveCriteria(t,n,m,-f);h=r,l.push(...e.redos),u.unshift(...e.undos)}if(d===o-a+1){let e={unitId:t,subUnitId:n};l.push({id:R.id,params:e}),u.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}})}else{let e=a<=s?a:d===0?a-f:s,r=a<=s?o-d:o-f,c={unitId:t,subUnitId:n,range:{...i,startColumn:e,endColumn:r}};l.push({id:I.id,params:c}),u.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}}),l.push(...h.redos),u.unshift(...h.undos)}return{undos:u,redos:l}}_handleRemoveRowCommand(e,n,r){let i=this._sheetsFilterService.getFilterModel(n,r);if(!i)return this._handleNull();let a=i.getRange(),{startRow:o,endRow:s}=a,{startRow:c,endRow:l}=e.range;if(c>s)return this._handleNull();if(l<o)return{undos:[{id:I.id,params:{range:a,unitId:n,subUnitId:r}}],redos:[{id:I.id,params:{range:{...a,startRow:o-(l-c+1),endRow:s-(l-c+1)},unitId:n,subUnitId:r}}]};let u=[],d=[],f=i.getAllFilterColumns(),p=o<=l&&o>=c;d.push({id:I.id,params:{range:a,unitId:n,subUnitId:r}});let m=Math.min(l,s)-Math.max(c,o)+1;if(m===s-o+1||p){let e={unitId:n,subUnitId:r};u.push({id:R.id,params:e}),f.forEach(e=>{let[t,i]=e,a={unitId:n,subUnitId:r,col:t,criteria:{...i.serialize(),colId:t}};d.push({id:L.id,params:a})})}else{var h;let e=(h=this._univerInstanceService.getUnit(n,t.UniverInstanceType.UNIVER_SHEET))==null?void 0:h.getSheetBySheetId(r);if(!e)return this._handleNull();let i=this._getFilteredRowCount(e,c,l),d=Math.min(o,c),f=d+(s-o)-m+i,p={unitId:n,subUnitId:r,range:{...a,startRow:d,endRow:f}};u.push({id:I.id,params:p})}return{undos:J(d),redos:J(u)}}_getFilteredRowCount(e,t,n){let r=0;for(let i=t;i<=n;i++)e.getRowFiltered(i)&&r++;return r}handleMoveColsCommand({fromRange:e,toRange:n},r,i){let a=this._sheetsFilterService.getFilterModel(r,i),o=(a==null?void 0:a.getRange())??null;if(!a||!o)return this._handleNull();let{startColumn:s,endColumn:c}=o;if(e.endColumn<s&&n.startColumn<=s||e.startColumn>c&&n.endColumn>c)return this._handleNull();let l=[],u=[],d={};for(let e=s;e<=c;e++)d[e]={colIndex:e,filter:a.getFilterColumn(e)};(0,t.moveMatrixArray)(e.startColumn,e.endColumn-e.startColumn+1,n.startColumn,d);let f=o.startColumn,p=o.endColumn;s>=e.startColumn&&s<=e.endColumn&&n.startColumn>e.startColumn&&e.endColumn<c&&(f=e.endColumn+1),c>=e.startColumn&&c<=e.endColumn&&n.startColumn<e.startColumn&&e.startColumn>s&&(p=e.startColumn-1);let m=Object.keys(d).map(e=>Number(e)),h=m.find(e=>d[e].colIndex===p),g=m.find(e=>d[e].colIndex===f);if(m.forEach(e=>{let{colIndex:t,filter:n}=d[e],o=e;if(n){var s;if(o>=g&&o<=h){var c;let e={unitId:r,subUnitId:i,col:o,criteria:{...n.serialize(),colId:o}},t={unitId:r,subUnitId:i,col:o,criteria:a.getFilterColumn(o)?{...(c=a.getFilterColumn(o))==null?void 0:c.serialize(),colId:o}:null};l.push({id:L.id,params:e}),u.push({id:L.id,params:t})}if(!((s=d[t])!=null&&s.filter)){let e={unitId:r,subUnitId:i,col:t,criteria:null};l.push({id:L.id,params:e}),u.push({id:L.id,params:{unitId:r,subUnitId:i,col:t,criteria:{...n.serialize(),colId:t}}})}}}),s!==g||c!==h){let e={unitId:r,subUnitId:i,range:{...o,startColumn:g,endColumn:h}};l.unshift({id:I.id,params:e}),u.unshift({id:I.id,params:{range:o,unitId:r,subUnitId:i}})}return{undos:u,redos:l}}_handleMoveRowsCommand(e,n,r){let i=this._sheetsFilterService.getFilterModel(n,r),a=(i==null?void 0:i.getRange())??null;if(!i||!a)return this._handleNull();let{startRow:o,endRow:s}=a,{fromRange:c,toRange:l}=e;if(c.endRow<o&&l.startRow<=o||c.startRow>s&&l.endRow>s)return this._handleNull();let u=[],d=[],f={};for(let e=o;e<=s;e++)f[e]={oldIndex:e};let p=o,m=s;s>=c.startRow&&s<=c.endRow&&l.startRow<c.startRow&&c.startRow>o&&(m=c.startRow-1),(0,t.moveMatrixArray)(c.startRow,c.endRow-c.startRow+1,l.startRow,f);let h=Object.keys(f).map(e=>Number(e)),g=h.find(e=>f[e].oldIndex===m),_=h.find(e=>f[e].oldIndex===p);if(o!==_||s!==g){let e={unitId:n,subUnitId:r,range:{...a,startRow:_,endRow:g}};u.push({id:I.id,params:e},{id:z.id,params:{unitId:n,subUnitId:r}}),d.push({id:I.id,params:{range:a,unitId:n,subUnitId:r}},{id:z.id,params:{unitId:n,subUnitId:r}})}return{redos:u,undos:d}}_handleMoveRangeCommand(e,n,r){let{fromRange:i,toRange:a}=e,o=this._sheetsFilterService.getFilterModel(n,r);if(!o)return this._handleNull();let s=o.getRange();if(!s)return this._handleNull();let c=[],l=[];if(t.Rectangle.contains(i,s)){let e=s.startRow-i.startRow,t=s.startColumn-i.startColumn,u={startRow:a.startRow+e,startColumn:a.startColumn+t,endRow:a.startRow+e+(s.endRow-s.startRow),endColumn:a.startColumn+t+(s.endColumn-s.startColumn)},d={id:R.id,params:{unitId:n,subUnitId:r}},f={id:I.id,params:{unitId:n,subUnitId:r,range:u}},p={id:I.id,params:{unitId:n,subUnitId:r,range:s}};c.push(d,f),l.push(d,p);let m=o.getAllFilterColumns(),h=a.startColumn-i.startColumn;m.forEach(e=>{let[t,i]=e;i&&(c.push({id:L.id,params:{unitId:n,subUnitId:r,col:t+h,criteria:{...i.serialize(),colId:t+h}}}),l.push({id:L.id,params:{unitId:n,subUnitId:r,col:t,criteria:{...i.serialize(),colId:t}}}))})}else if(t.Rectangle.intersects(a,s)){let e={...s,endRow:Math.max(s.endRow,a.endRow)};c.push({id:I.id,params:{unitId:n,subUnitId:r,range:e}}),l.push({id:I.id,params:{unitId:n,subUnitId:r,range:s}})}return{redos:c,undos:l}}_handleRemoveSheetCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(t,n);if(!r)return this._handleNull();let i=r.getRange();if(!i)return this._handleNull();let a=[],o=[];return r.getAllFilterColumns().forEach(([e,r])=>{o.push({id:L.id,params:{unitId:t,subUnitId:n,col:e,criteria:{...r.serialize(),colId:e}}})}),a.push({id:R.id,params:{unitId:t,subUnitId:n,range:i}}),o.unshift({id:I.id,params:{range:i,unitId:t,subUnitId:n}}),{undos:o,redos:a}}_handleCopySheetCommand(e,t,n){let r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return this._handleNull();let i=r.getRange();if(!i)return this._handleNull();let a=[],o=[],s=[];return r.getAllFilterColumns().forEach(([t,r])=>{a.push({id:L.id,params:{unitId:e,subUnitId:n,col:t,criteria:{...r.serialize(),colId:t}}}),s.push({id:L.id,params:{unitId:e,subUnitId:n,col:t,criteria:null}})}),s.push({id:R.id,params:{unitId:e,subUnitId:n,range:i}}),a.unshift({id:I.id,params:{range:i,unitId:e,subUnitId:n}}),{undos:o,redos:a,preUndos:s,preRedos:[]}}_handleNull(){return{redos:[],undos:[]}}_initRowFilteredInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.ROW_FILTERED,{handler:(e,t)=>{var n;return e?!0:((n=this._sheetsFilterService.getFilterModel(t.unitId,t.subUnitId))==null?void 0:n.isRowFiltered(t.row))??!1}}))}_moveCriteria(e,t,n,r){let i={unitId:e,subUnitId:t,criteria:null,col:-1},a=[],o=[],s=[],c=[];return n.forEach(e=>{let[t,n]=e;o.push({id:L.id,params:{...i,col:t}}),a.push({id:L.id,params:{...i,col:t,criteria:{...n.serialize(),colId:t}}})}),n.forEach(e=>{let[t,n]=e;c.push({id:L.id,params:{...i,col:t+r,criteria:{...n.serialize(),colId:t+r}}}),s.push({id:L.id,params:{...i,col:t+r,criteria:null}})}),{newRange:{redos:c,undos:s},oldRange:{redos:o,undos:a}}}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{let{unitId:r,subUnitId:i}=e.params||{},a=this._sheetsFilterService.getFilterModel(r,i);if(!a)return;let o=Array.from(a.filteredOutRows).sort((e,t)=>e-t),s=[],c=!1;if(e.id===n.RemoveRowMutation.id){let{startRow:t,endRow:n}=e.params.range,r=o.filter(e=>e>=t&&e<=n);o.forEach(e=>{if(e<t)s.push(e);else if(c=!0,e<=n){let e=Math.max(t,s.length?s[s.length-1]+1:t);s.push(e)}else s.push(e-(n-t+1-r.length))})}if(e.id===n.InsertRowMutation.id){let{startRow:t,endRow:n}=e.params.range;o.forEach(e=>{e>=t?(c=!0,s.push(e+(n-t+1))):s.push(e)})}if(c&&(a.filteredOutRows=new Set(s)),e.id===n.SetRangeValuesMutation.id&&!(t!=null&&t.onlyLocal)){let t=this._getExtendRegion(r,i);if(t){let a=e.params.cellValue;if(a)for(let e=t.startColumn;e<=t.endColumn;e++){var l;let o=a==null||(l=a[t.startRow])==null?void 0:l[e];if(o&&this._cellHasValue(o)){var u;let e=(u=this._univerInstanceService.getUnit(r))==null?void 0:u.getSheetBySheetId(i);if(e){let a=(0,n.expandToContinuousRange)(t,{down:!0},e),o=this._sheetsFilterService.getFilterModel(r,i),s=o.getRange();o.setRange({...s,endRow:a.endRow}),this._registerRefRange(r,i)}}}}}}))}_getExtendRegion(e,t){var n;let r=this._sheetsFilterService.getFilterModel(e,t);if(!r)return null;let i=(n=this._univerInstanceService.getUnit(e))==null?void 0:n.getSheetBySheetId(t);if(!i)return null;let a=r.getRange();if(!a)return null;let o=i.getRowCount()-1,s=i.getRowManager();for(let e=a.endRow+1;e<=o;e++)if(s.getRowRawVisible(e))return{startRow:e,endRow:e,startColumn:a.startColumn,endColumn:a.endColumn};return null}_initErrorHandling(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{let t=e.params,r=(0,n.getSheetCommandTarget)(this._univerInstanceService,t);if(!r)return;let{subUnitId:i,unitId:a}=r,o=this._sheetsFilterService.getFilterModel(a,i);if(!o)return;let s=o.getRange();if(e.id===n.MoveRowsCommand.id&&t.fromRange.startRow<=s.startRow&&t.fromRange.endRow<s.endRow&&t.fromRange.endRow>=s.startRow)throw this._sheetsFilterService.setFilterErrorMsg(`sheets-filter.msg.filter-header-forbidden`),Error(`[SheetsFilterController]: Cannot move header row of filter`)}))}_cellHasValue(e){let t=Object.values(e);return!(t.length===0||t.every(e=>e==null))}};Y=N([M(0,t.ICommandService),M(1,(0,t.Inject)(n.SheetInterceptorService)),M(2,(0,t.Inject)(F)),M(3,t.IUniverInstanceService),M(4,(0,t.Inject)(n.RefRangeService)),M(5,(0,t.Optional)(a.DataSyncPrimaryController)),M(6,(0,t.Inject)(n.ZebraCrossingCacheController))],Y);let ve=[L.id,z.id],X=[n.InsertColMutation.id,n.RemoveColMutation.id,n.MoveColsMutation.id],Z=class extends t.Disposable{get visible(){return this._visible$.getValue()}get enabled(){return this._enabled$.getValue()}constructor(e,n,i){super(),this._sheetsFilterController=e,this._commandService=n,this._configService=i,E(this,`_d`,new t.DisposableCollection),E(this,`_visible$`,new r.BehaviorSubject(!1)),E(this,`visible$`,this._visible$.asObservable()),E(this,`_enabled$`,new r.BehaviorSubject(!0)),E(this,`enabled$`,this._enabled$.asObservable());let a=this._configService.getConfig(K);a!=null&&a.enableSyncSwitch&&(this._visible$.next(!0),typeof a.enableSyncSwitch==`object`&&this.setEnabled(a.enableSyncSwitch.defaultValue??!0))}setEnabled(e){this._enabled$.next(e),e?this._d.dispose():this._initOnlyLocalListener()}_initOnlyLocalListener(){this._d.add(this._commandService.beforeCommandExecuted((e,t)=>{ve.includes(e.id)&&(t||={},t.onlyLocal=!0)})),this._d.add(this._commandService.onCommandExecuted((e,r)=>{if(X.includes(e.id)&&r!=null&&r.fromCollab){if(e.id===n.InsertColMutation.id){let{range:n,unitId:i,subUnitId:a}=e.params,{redos:o}=this._sheetsFilterController.handleInsertColCommand(n,i,a);(0,t.sequenceExecute)(o,this._commandService,r)}else if(e.id===n.RemoveColMutation.id){let{range:n,unitId:i,subUnitId:a}=e.params,{redos:o}=this._sheetsFilterController.handleRemoveColCommand(n,i,a);(0,t.sequenceExecute)(o,this._commandService,r)}else if(e.id===n.MoveColsMutation.id){let{sourceRange:n,targetRange:i,unitId:a,subUnitId:o}=e.params,{redos:s}=this._sheetsFilterController.handleMoveColsCommand({fromRange:n,toRange:i},a,o);(0,t.sequenceExecute)(s,this._commandService,r)}}}))}};Z=N([M(0,(0,t.Inject)(Y)),M(1,t.ICommandService),M(2,t.IConfigService)],Z);var ye=`@univerjs/sheets-filter`,be=`1.0.0`;let Q=class extends t.Disposable{constructor(e,t,n,r){super(),this._activeDirtyManagerService=e,this._sheetRowFilteredService=t,this._sheetsFilterService=n,this._univerInstanceService=r,this._initFormulaDirtyRange(),this._registerSheetRowFiltered()}_initFormulaDirtyRange(){d.forEach(e=>{this._activeDirtyManagerService.register(e,{commandId:e,getDirtyData:e=>{let{unitId:t,subUnitId:n}=e.params;return{dirtyRanges:this._getHideRowMutation(t,n),clearDependencyTreeCache:{[t]:{[n]:`1`}}}}})})}_getHideRowMutation(e,t){var n,r;let i=(n=this._sheetsFilterService.getFilterModel(e,t))==null?void 0:n.getRange(),a=(r=this._univerInstanceService.getUnit(e))==null?void 0:r.getSheetBySheetId(t);if(i==null||a==null)return[];let{startRow:o,endRow:s}=i;return[{unitId:e,sheetId:t,range:{startRow:o,startColumn:0,endRow:s,endColumn:a.getColumnCount()-1}}]}_registerSheetRowFiltered(){this.disposeWithMe(this._sheetRowFilteredService.register((e,t,n)=>{var r;return((r=this._sheetsFilterService.getFilterModel(e,t))==null?void 0:r.isRowFiltered(n))??!1}))}};Q=N([M(0,(0,t.Inject)(o.IActiveDirtyManagerService)),M(1,(0,t.Inject)(o.ISheetRowFilteredService)),M(2,(0,t.Inject)(F)),M(3,t.IUniverInstanceService)],Q);let $=class extends t.Plugin{constructor(e=q,n,r){super(),this._config=e,this._injector=n,this._configService=r;let{...i}=(0,t.merge)({},q,this._config);this._configService.setConfig(K,i)}onStarting(){[[Q],[F],[Y],[Z]].forEach(e=>this._injector.add(e))}onReady(){(0,t.touchDependencies)(this._injector,[[Q],[Y],[Z]])}};E($,`type`,t.UniverInstanceType.UNIVER_SHEET),E($,`pluginName`,P),E($,`packageName`,ye),E($,`version`,be),$=N([(0,t.DependentOn)(o.UniverFormulaEnginePlugin,n.UniverSheetsPlugin),M(1,(0,t.Inject)(t.Injector)),M(2,t.IConfigService)],$),e.ClearSheetsFilterCriteriaCommand=U,e.CustomFilterOperator=p,e.FILTER_MUTATIONS=d,e.FilterBy=f,e.FilterColumn=k,e.FilterModel=O,e.ReCalcSheetsFilterCommand=W,e.ReCalcSheetsFilterMutation=z,e.RemoveSheetFilterCommand=V,e.RemoveSheetsFilterMutation=R,e.SHEET_FILTER_SNAPSHOT_ID=P,e.SetSheetFilterRangeCommand=B,e.SetSheetsFilterCriteriaCommand=H,e.SetSheetsFilterCriteriaMutation=L,e.SetSheetsFilterRangeMutation=I,Object.defineProperty(e,"SheetsFilterService",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SheetsFilterSyncController",{enumerable:!0,get:function(){return Z}}),e.SmartToggleSheetsFilterCommand=pe,Object.defineProperty(e,"UniverSheetsFilterPlugin",{enumerable:!0,get:function(){return $}}),e.equals=v,e.getCustomFilterFn=x,e.greaterThan=m,e.greaterThanOrEqualTo=h,e.lessThan=g,e.lessThanOrEqualTo=_,e.notEquals=y});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-filter",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Filtering model, commands, and services for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"rxjs": ">=7.0.0"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@univerjs/
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/engine-
|
|
73
|
-
"@univerjs/
|
|
74
|
-
"@univerjs/
|
|
70
|
+
"@univerjs/core": "1.0.0",
|
|
71
|
+
"@univerjs/engine-formula": "1.0.0",
|
|
72
|
+
"@univerjs/engine-render": "1.0.0",
|
|
73
|
+
"@univerjs/rpc": "1.0.0",
|
|
74
|
+
"@univerjs/sheets": "1.0.0"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
+
"@univerjs-infra/shared": "1.0.0",
|
|
77
78
|
"rxjs": "^7.8.2",
|
|
78
79
|
"typescript": "^6.0.3",
|
|
79
|
-
"vitest": "^
|
|
80
|
-
"@univerjs-infra/shared": "1.0.0-beta.0"
|
|
80
|
+
"vitest": "^5.0.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"test": "vitest run",
|