@univerjs/sheets-filter-ui 0.5.0-nightly.202411291606 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/index.js +2 -2
- package/lib/es/index.js +334 -333
- package/lib/umd/index.js +2 -2
- package/package.json +12 -12
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/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var st=Object.defineProperty;var it=(t,e,r)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>it(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),ge=require("@univerjs/rpc"),u=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),w=require("@univerjs/sheets-ui"),C=require("@univerjs/ui"),g=require("rxjs"),M=require("@univerjs/design"),ae=require("@univerjs/engine-render"),A=require("react"),Ve="sheets-filter-ui.config",We={};var R=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(R||{}),v=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(v||{}),d;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:v.NONE,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:s=>s.operator1===v.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:s=>!s.customFilters&&!s.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:v.EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:v.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:v.NOT_EMPTY,order:R.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:v.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:v.CONTAINS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.CONTAINS,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===v.CONTAINS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:v.DOES_NOT_CONTAIN,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:s=>{const[o]=B(s);return o===v.DOES_NOT_CONTAIN},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:v.STARTS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.STARTS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`${s.val1}*`}]}}),testMappingParams:s=>{const[o]=B(s);return o===v.STARTS_WITH},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:v.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:v.ENDS_WITH,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.ENDS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}`}]}}),testMappingParams:s=>{const[o]=B(s);return o===v.ENDS_WITH},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:v.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:v.EQUALS,order:R.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.EQUALS,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===v.EQUALS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:s=>{var o,a,c;return((a=(o=s.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:v.EQUALS,val1:""}:((c=s.customFilters)==null?void 0:c.customFilters.length)===1&&!s.customFilters.customFilters[0].operator?{operator1:v.EQUALS,val1:s.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:R.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:s=>{const[o]=B(s);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:v.BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:c}=s;if(!o)return!1;const m=[a,c];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:c}=s,m=c===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:h.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:v.NOT_BETWEEN,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:c}=s;if(o)return!1;const m=[a,c];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:c}=s,m=c===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:v.CUSTOM,order:R.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:v.NONE,val1:"",operator2:v.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:s=>{const{and:o,val1:a,val2:c,operator1:m,operator2:p}=s;function F(U,$){for(const I of t.ALL_CONDITIONS)if(I.operator===U)return I.mapToFilterColumn({val1:$,operator1:U})}const f=!m||m===t.NONE.operator,T=!p||p===t.NONE.operator;if(f&&T)return t.NONE.mapToFilterColumn({});if(f)return F(p,c);if(T)return F(m,a);const E=F(m,a),b=F(p,c),N={customFilters:[E.customFilters.customFilters[0],b.customFilters.customFilters[0]]};return o&&(N.and=h.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:s=>{var c;if(((c=s.customFilters)==null?void 0:c.customFilters.length)!==2)return!1;const o=s.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return s.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${s}`);return o}t.getItemByOperator=e;function r(s,o){for(const a of t.ALL_CONDITIONS.filter(c=>c.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(s))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(s))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function n(s,o){return s.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(s){if(!s)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(s);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(d||(d={}));function B(t){const{operator1:e,operator2:r,val1:i,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,n]}function Pe(t){const e=[],r=[];let i=0,n=0;function l(s){s.leaf&&(s.checked?(e.push(s),i+=s.count):(r.push(s),n+=s.count)),s.children&&s.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:n}}var nt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,at=(t,e,r,i)=>{for(var n=i>1?void 0:i?ot(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&nt(e,r,n),n},Te=(t,e)=>(r,i)=>e(r,i,t);const be="sheets-filter.generate-filter-values.service",pe=h.createIdentifier(be),lt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ne=class extends h.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:n,blankChecked:l,iterateRange:s,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),c=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!c?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),ke(n,this._localeService,s,c,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Ne=at([Te(0,h.Inject(h.LocaleService)),Te(1,h.IUniverInstanceService),Te(2,h.ILogService)],Ne);function ke(t,e,r,i,n,l,s,o){var E,b,N,U,$,I,H,k,Z;const a=new Map,c=new Map,m="yyyy-mm-dd",p=new Set(lt),F="empty";let f=0;for(const y of i.iterateByColumn(r,!1,!1)){const{row:et,rowSpan:Ue=1}=y;let J=0;for(;J<Ue;){const tt=et+J;if(n.has(tt)){J++;continue}const q=y!=null&&y.value?h.extractPureTextFromCell(y.value):"";if(!q){f+=1,J+=Ue;continue}const ue=(E=y.value)!=null&&E.v&&!y.value.p?(U=(N=o.get((b=y.value)==null?void 0:b.s))==null?void 0:N.n)==null?void 0:U.pattern:"",rt=ue&&h.numfmt.isDate(ue);if(ue&&rt&&p.has(ue)){const Q=($=i.getCellRaw(y.row,y.col))==null?void 0:$.v;if(!Q){J++;continue}const z=h.numfmt.format(m,Q),[L,x,ie]=z.split("-").map(Number);let K=a.get(`${L}`);K||(K={title:`${L}`,key:`${L}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${L}`,K),c.set(`${L}`,[`${L}`]));let V=(I=K.children)==null?void 0:I.find(Ce=>Ce.key===`${L}-${x}`);V||(V={title:e.t(`sheets-filter.date.${x}`),key:`${L}-${x}`,children:[],count:0,leaf:!1,checked:!1},(H=K.children)==null||H.push(V),c.set(`${L}-${x}`,[`${L}`,`${L}-${x}`]));const Fe=(k=V==null?void 0:V.children)==null?void 0:k.find(Ce=>Ce.key===`${L}-${x}-${ie}`);Fe?(Fe.originValues.add(q),Fe.count++,V.count++,K.count++):((Z=V.children)==null||Z.push({title:`${ie}`,key:`${L}-${x}-${ie}`,count:1,originValues:new Set([q]),leaf:!0,checked:l.size?l.has(q):!s}),V.count++,K.count++,c.set(`${L}-${x}-${ie}`,[`${L}`,`${L}-${x}`,`${L}-${x}-${ie}`]))}else{const Q=q;let z=a.get(Q);z?z.count++:(z={title:q,leaf:!0,checked:l.size?l.has(q):!s,key:Q,count:1},a.set(Q,z),c.set(Q,[Q]))}J++}}const T=t?s:!0;if(f>0){const y={title:e.t("sheets-filter.panel.empty"),count:f,leaf:!0,checked:T,key:F};a.set("empty",y),c.set("empty",[F])}return{filterTreeItems:ct(Array.from(a.values())),filterTreeMapCache:c}}function ct(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((i,n)=>{const l=Number.parseInt(i.key.split("-")[2],10),s=Number.parseInt(n.key.split("-")[2],10);return l-s})}),e))}function ye(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=ye(r.children,e);if(i)return i}}return null}function Qe(t){return t.leaf?t.checked:t.children?t.children.every(e=>Qe(e)):!0}function oe(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>oe(r,e))}function Ge(t,e){const r=[];return t.forEach(i=>{const n=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...i});else if(i.children){const o=Ge(i.children,e);if(o.length>0){const a=o.reduce((c,m)=>c+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ut=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,Le=(t,e,r,i)=>{for(var n=i>1?void 0:i?ht(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ut(e,r,n),n},de=(t,e)=>(r,i)=>e(r,i,t),fe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(fe||{});h.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Y=class extends h.Disposable{constructor(e,r){super();S(this,"_filterBy$",new g.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new g.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new g.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new g.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const n=i.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,n=e.subUnitId,l=e.getRange(),s={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,n,s,(o,a)=>{if(!a)this.terminate();else{const c=a.startColumn-o.startColumn;c!==0&&this._filterByModel.deltaCol(c)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Y=Le([de(0,h.Inject(h.Injector)),de(1,h.Inject(O.RefRangeService))],Y);let _e=class extends h.Disposable{constructor(e,r,i,n,l){super();S(this,"canApply$",g.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new g.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,n){const[l,s]=d.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,r,i,l,s)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=d.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=d.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(d.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=d.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};_e=Le([de(4,h.ICommandService)],_e);let Se=class extends h.Disposable{constructor(e,r,i,n,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new g.Subject,this.filterItems$=g.merge(g.combineLatest([this._searchString$.pipe(g.throttleTime(500,void 0,{leading:!0,trailing:!0}),g.startWith(void 0)),this._rawFilterItems$]).pipe(g.map(([s,o])=>{if(!s)return o;const c=s.toLowerCase().split(/\s+/).filter(m=>!!m);return Ge(o,c)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(s=>Pe(s).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(s=>this._filterItems=s))}static async fromFilterColumn(e,r,i){var I;const n=e.get(h.IUniverInstanceService),l=e.get(h.LocaleService),s=e.get(pe,h.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,c=n.getUniverSheetInstance(o);if(!c)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=c==null?void 0:c.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const p=r.getRange(),F=i,f=(I=r.getFilterColumn(i))==null?void 0:I.getColumnData().filters,T=new Set(f==null?void 0:f.filters),E=!!(f&&f.blank),b=r.getFilteredOutRowsExceptCol(i),N={...p,startRow:p.startRow+1,startColumn:F,endColumn:F};let U,$;if(s){const H=await s.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(b),filters:!!f,blankChecked:E,iterateRange:N,alreadyChecked:Array.from(T)});U=H.filterTreeItems,$=H.filterTreeMapCache}else{const H=ke(!!f,l,N,m,b,T,E,c.getStyles());U=H.filterTreeItems,$=H.filterTreeMapCache}return e.createInstance(Se,r,i,U,$)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=h.Tools.deepClone(this._filterItems);r.forEach(i=>oe(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=h.Tools.deepClone(this._filterItems),i=ye(r,e.key);if(!i)return;const n=Qe(i);oe(i,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=h.Tools.deepClone(this._filterItems);r.forEach(i=>oe(i,!1)),e.forEach(i=>{const n=ye(r,i);n&&oe(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Pe(this._filterItems),{checked:r,checkedItems:i}=e,n=this.rawFilterItems;let l=0;for(const c of n)l+=c.count;const s=r===0,o=e.checked===l,a={colId:this.col};if(s)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const c=i.filter(p=>p.key!=="empty");c.length>0&&(a.filters={filters:c.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),c.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};Se=Le([de(4,h.ICommandService)],Se);const re="FILTER_PANEL_OPENED",le={id:"sheet.operation.open-filter-panel",type:h.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(h.IContextService),i=t.get(u.SheetsFilterService),n=t.get(Y);t.get(h.ICommandService).syncExecuteCommand(w.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:o,col:a}=e,c=i.getFilterModel(s,o);return c?(n.setupCol(c,a),r.getContextValue(re)||r.setContextValue(re,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:h.CommandType.OPERATION,handler:t=>{const e=t.get(h.IContextService),r=t.get(Y),i=t.get(C.ILayoutService,h.Quantity.OPTIONAL);return e.getContextValue(re)?(e.setContextValue(re,!1),i==null||i.focus(),r.terminate()):!1}},Me={id:"sheet.operation.apply-filter",type:h.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Y).changeFilterBy(r)}};var mt=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?pt(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&mt(e,r,n),n},ee=(t,e)=>(r,i)=>e(r,i,t);let se=class extends h.Disposable{constructor(t,e,r,i,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionInterceptorBaseController=i,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(h.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:s,subUnitId:o,worksheet:a}=l,c=(e=this._sheetsFilterService.getFilterModel(s,o))==null?void 0:e.getRange();let m;if(c)m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[c]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let F={...p};F=p.startColumn===p.endColumn&&p.startRow===p.endRow?O.expandToContinuousRange(F,{left:!0,right:!0,up:!0,down:!0},a):F,m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[F],s,o)}else m=this._sheetPermissionInterceptorBaseController.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr"))}if(t.id===le.id){const n=t.params,{unitId:l,subUnitId:s}=n,o=(i=this._sheetsFilterService.getFilterModel(l,s))==null?void 0:i.getRange(),a=h.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr")))}}))}};se=dt([ee(0,h.Inject(u.SheetsFilterService)),ee(1,h.Inject(h.LocaleService)),ee(2,h.ICommandService),ee(3,h.Inject(w.SheetPermissionInterceptorBaseController)),ee(4,h.Inject(h.Injector)),ee(5,h.Inject(O.SheetsSelectionsService))],se);var j=function(){return j=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},j.apply(this,arguments)},ft=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},Ye=A.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,l=t.extend,s=ft(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),a=A.useRef("_".concat(vt()));return qe(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},j({ref:e,className:o},s),l)});function qe(t,e,r,i,n){return A.createElement(t.tag,j(j({key:e},_t(t,r,n)),i),(St(t,r).children||[]).map(function(l,s){return qe(l,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function _t(t,e,r){var i=j({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var s=l[0],o=l[1];typeof o=="string"&&(i[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function St(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?j(j({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?j(j({},n),{attrs:j(j({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function vt(){return Math.random().toString(36).substring(2,8)}Ye.displayName="UniverIcon";var gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ke=A.forwardRef(function(t,e){return A.createElement(Ye,Object.assign({},t,{id:"filter-single",ref:e,icon:gt}))});Ke.displayName="FilterSingle";var Ee={exports:{}},ne={};/**
|
|
1
|
+
"use strict";var st=Object.defineProperty;var it=(t,e,r)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>it(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),ge=require("@univerjs/rpc"),c=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),$=require("@univerjs/sheets-ui"),T=require("@univerjs/ui"),g=require("rxjs"),L=require("@univerjs/design"),ne=require("@univerjs/engine-render"),y=require("react"),Ve="sheets-filter-ui.config",We={};var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),v=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(v||{}),d;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:v.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:s=>s.operator1===v.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:s=>!s.customFilters&&!s.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:v.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:v.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:v.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:v.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:v.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.CONTAINS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.CONTAINS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:v.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.DOES_NOT_CONTAIN},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:v.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.STARTS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`${s.val1}*`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.STARTS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:v.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:v.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.ENDS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.ENDS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:v.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:v.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.EQUALS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:s=>{var o,a,h;return((a=(o=s.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:v.EQUALS,val1:""}:((h=s.customFilters)==null?void 0:h.customFilters.length)===1&&!s.customFilters.customFilters[0].operator?{operator1:v.EQUALS,val1:s.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:v.BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:v.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:v.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:v.NONE,val1:"",operator2:v.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:s=>{const{and:o,val1:a,val2:h,operator1:m,operator2:p}=s;function F(M,b){for(const j of t.ALL_CONDITIONS)if(j.operator===M)return j.mapToFilterColumn({val1:b,operator1:M})}const _=!m||m===t.NONE.operator,E=!p||p===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return F(p,h);if(E)return F(m,a);const C=F(m,a),R=F(p,h),I={customFilters:[C.customFilters.customFilters[0],R.customFilters.customFilters[0]]};return o&&(I.and=u.BooleanNumber.TRUE),{customFilters:I}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=s.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return s.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${s}`);return o}t.getItemByOperator=e;function r(s,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(s))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(s))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function n(s,o){return s.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(s){if(!s)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(s);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(d||(d={}));function H(t){const{operator1:e,operator2:r,val1:i,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,i]:[r,n]}function Pe(t){const e=[],r=[];let i=0,n=0;function l(s){s.leaf&&(s.checked?(e.push(s),i+=s.count):(r.push(s),n+=s.count)),s.children&&s.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:n}}var nt=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,at=(t,e,r,i)=>{for(var n=i>1?void 0:i?ot(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&nt(e,r,n),n},Te=(t,e)=>(r,i)=>e(r,i,t);const be="sheets-filter.generate-filter-values.service",pe=u.createIdentifier(be),lt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ne=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:n,blankChecked:l,iterateRange:s,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),ke(n,this._localeService,s,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Ne=at([Te(0,u.Inject(u.LocaleService)),Te(1,u.IUniverInstanceService),Te(2,u.ILogService)],Ne);function ke(t,e,r,i,n,l,s,o){var C,R,I,M,b,j,B,le,ce;const a=new Map,h=new Map,m="yyyy-mm-dd",p=new Set(lt),F="empty";let _=0;for(const U of i.iterateByColumn(r,!1,!1)){const{row:et,rowSpan:Ue=1}=U;let X=0;for(;X<Ue;){const tt=et+X;if(n.has(tt)){X++;continue}const Y=U!=null&&U.value?u.extractPureTextFromCell(U.value):"";if(!Y){_+=1,X+=Ue;continue}const ue=(C=U.value)!=null&&C.v&&!U.value.p?(M=(I=o.get((R=U.value)==null?void 0:R.s))==null?void 0:I.n)==null?void 0:M.pattern:"",rt=ue&&u.numfmt.isDate(ue);if(ue&&rt&&p.has(ue)){const k=(b=i.getCellRaw(U.row,U.col))==null?void 0:b.v;if(!k){X++;continue}const Z=u.numfmt.format(m,k),[A,x,re]=Z.split("-").map(Number);let q=a.get(`${A}`);q||(q={title:`${A}`,key:`${A}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${A}`,q),h.set(`${A}`,[`${A}`]));let V=(j=q.children)==null?void 0:j.find(Ce=>Ce.key===`${A}-${x}`);V||(V={title:e.t(`sheets-filter.date.${x}`),key:`${A}-${x}`,children:[],count:0,leaf:!1,checked:!1},(B=q.children)==null||B.push(V),h.set(`${A}-${x}`,[`${A}`,`${A}-${x}`]));const Fe=(le=V==null?void 0:V.children)==null?void 0:le.find(Ce=>Ce.key===`${A}-${x}-${re}`);Fe?(Fe.originValues.add(Y),Fe.count++,V.count++,q.count++):((ce=V.children)==null||ce.push({title:`${re}`,key:`${A}-${x}-${re}`,count:1,originValues:new Set([Y]),leaf:!0,checked:l.size?l.has(Y):!s}),V.count++,q.count++,h.set(`${A}-${x}-${re}`,[`${A}`,`${A}-${x}`,`${A}-${x}-${re}`]))}else{const k=Y;let Z=a.get(k);Z?Z.count++:(Z={title:Y,leaf:!0,checked:l.size?l.has(Y):!s,key:k,count:1},a.set(k,Z),h.set(k,[k]))}X++}}const E=t?s:!0;if(_>0){const U={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:F};a.set("empty",U),h.set("empty",[F])}return{filterTreeItems:ct(Array.from(a.values())),filterTreeMapCache:h}}function ct(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((i,n)=>{const l=Number.parseInt(i.key.split("-")[2],10),s=Number.parseInt(n.key.split("-")[2],10);return l-s})}),e))}function ye(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=ye(r.children,e);if(i)return i}}return null}function Qe(t){return t.leaf?t.checked:t.children?t.children.every(e=>Qe(e)):!0}function ie(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>ie(r,e))}function Ge(t,e){const r=[];return t.forEach(i=>{const n=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...i});else if(i.children){const o=Ge(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ut=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,Le=(t,e,r,i)=>{for(var n=i>1?void 0:i?ht(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ut(e,r,n),n},de=(t,e)=>(r,i)=>e(r,i,t),fe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(fe||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();S(this,"_filterBy$",new g.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new g.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new g.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new g.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const i=e.getFilterColumn(r);if(i){const n=i.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,n=e.subUnitId,l=e.getRange(),s={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,n,s,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=Le([de(0,u.Inject(u.Injector)),de(1,u.Inject(O.RefRangeService))],G);let _e=class extends u.Disposable{constructor(e,r,i,n,l){super();S(this,"canApply$",g.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new g.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,n){const[l,s]=d.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,r,i,l,s)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=d.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=d.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(d.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=d.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};_e=Le([de(4,u.ICommandService)],_e);let Se=class extends u.Disposable{constructor(e,r,i,n,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new g.Subject,this.filterItems$=g.merge(g.combineLatest([this._searchString$.pipe(g.throttleTime(500,void 0,{leading:!0,trailing:!0}),g.startWith(void 0)),this._rawFilterItems$]).pipe(g.map(([s,o])=>{if(!s)return o;const h=s.toLowerCase().split(/\s+/).filter(m=>!!m);return Ge(o,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(s=>Pe(s).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(s=>this._filterItems=s))}static async fromFilterColumn(e,r,i){var j;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),s=e.get(pe,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const p=r.getRange(),F=i,_=(j=r.getFilterColumn(i))==null?void 0:j.getColumnData().filters,E=new Set(_==null?void 0:_.filters),C=!!(_&&_.blank),R=r.getFilteredOutRowsExceptCol(i),I={...p,startRow:p.startRow+1,startColumn:F,endColumn:F};let M,b;if(s){const B=await s.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(R),filters:!!_,blankChecked:C,iterateRange:I,alreadyChecked:Array.from(E)});M=B.filterTreeItems,b=B.filterTreeMapCache}else{const B=ke(!!_,l,I,m,R,E,C,h.getStyles());M=B.filterTreeItems,b=B.filterTreeMapCache}return e.createInstance(Se,r,i,M,b)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(i=>ie(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),i=ye(r,e.key);if(!i)return;const n=Qe(i);ie(i,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(i=>ie(i,!1)),e.forEach(i=>{const n=ye(r,i);n&&ie(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Pe(this._filterItems),{checked:r,checkedItems:i}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const s=r===0,o=e.checked===l,a={colId:this.col};if(s)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};Se=Le([de(4,u.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),i=t.get(c.SheetsFilterService),n=t.get(G);t.get(u.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:o,col:a}=e,h=i.getFilterModel(s,o);return h?(n.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),i=t.get(T.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),i==null||i.focus(),r.terminate()):!1}},Me={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}};var mt=Object.defineProperty,pt=Object.getOwnPropertyDescriptor,dt=(t,e,r,i)=>{for(var n=i>1?void 0:i?pt(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&mt(e,r,n),n},J=(t,e)=>(r,i)=>e(r,i,t);let te=class extends u.Disposable{constructor(t,e,r,i,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionInterceptorBaseController=i,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:s,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(s,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let F={...p};F=p.startColumn===p.endColumn&&p.startRow===p.endRow?O.expandToContinuousRange(F,{left:!0,right:!0,up:!0,down:!0},a):F,m=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[F],s,o)}else m=this._sheetPermissionInterceptorBaseController.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const n=t.params,{unitId:l,subUnitId:s}=n,o=(i=this._sheetsFilterService.getFilterModel(l,s))==null?void 0:i.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.filterErr")))}}))}};te=dt([J(0,u.Inject(c.SheetsFilterService)),J(1,u.Inject(u.LocaleService)),J(2,u.ICommandService),J(3,u.Inject($.SheetPermissionInterceptorBaseController)),J(4,u.Inject(u.Injector)),J(5,u.Inject(O.SheetsSelectionsService))],te);var D=function(){return D=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},D.apply(this,arguments)},ft=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},Ye=y.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,l=t.extend,s=ft(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),a=y.useRef("_".concat(vt()));return qe(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:o},s),l)});function qe(t,e,r,i,n){return y.createElement(t.tag,D(D({key:e},_t(t,r,n)),i),(St(t,r).children||[]).map(function(l,s){return qe(l,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function _t(t,e,r){var i=D({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var s=l[0],o=l[1];typeof o=="string"&&(i[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function St(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?D(D({},n),{attrs:D(D({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function vt(){return Math.random().toString(36).substring(2,8)}Ye.displayName="UniverIcon";var gt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ke=y.forwardRef(function(t,e){return y.createElement(Ye,Object.assign({},t,{id:"filter-single",ref:e,icon:gt}))});Ke.displayName="FilterSingle";var Ee={exports:{}},se={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var $e;function Ft(){if($e)return ne;$e=1;var t=A,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(o,a,c){var m,p={},F=null,f=null;c!==void 0&&(F=""+c),a.key!==void 0&&(F=""+a.key),a.ref!==void 0&&(f=a.ref);for(m in a)i.call(a,m)&&!l.hasOwnProperty(m)&&(p[m]=a[m]);if(o&&o.defaultProps)for(m in a=o.defaultProps,a)p[m]===void 0&&(p[m]=a[m]);return{$$typeof:e,type:o,key:F,ref:f,props:p,_owner:n.current}}return ne.Fragment=r,ne.jsx=s,ne.jsxs=s,ne}var we;function Ct(){return we||(we=1,Ee.exports=Ft()),Ee.exports}var _=Ct();const Tt="univer-sheets-filter-panel",Et="univer-sheets-filter-panel-header",Ot="univer-sheets-filter-panel-content",It="univer-sheets-filter-panel-select-all",Pt="univer-sheets-filter-panel-select-all-count",Nt="univer-sheets-filter-panel-values-container",yt="univer-input-affix-wrapper",Rt="univer-select",At="univer-radio-group",bt="univer-sheets-filter-panel-values-find",Lt="univer-sheets-filter-panel-values-list",Mt="univer-sheets-filter-panel-values-list-inner-container",Ut="univer-sheets-filter-panel-values-virtual",$t="univer-sheets-filter-panel-values-item",wt="univer-sheets-filter-panel-values-item-inner",Dt="univer-sheets-filter-panel-values-item-count",Ht="univer-sheets-filter-panel-values-item-exclude-button",jt="univer-sheets-filter-panel-values-item-text",Bt="univer-sheets-filter-panel-conditions-container",xt="univer-sheets-filter-panel-conditions-container-inner",Vt="univer-sheets-filter-panel-conditions-desc",Wt="univer-sheets-filter-panel-footer",kt="univer-sheets-filter-panel-footer-primary-buttons",Qt="univer-button",Gt="univer-input",Yt="univer-form-dual-column-layout",qt="univer-sheets-filter-tree-node",Kt="univer-sheets-filter-tree-node-filter-only",Xt="univer-sheets-filter-tree-node-attach",P={sheetsFilterPanel:Tt,sheetsFilterPanelHeader:Et,sheetsFilterPanelContent:Ot,sheetsFilterPanelSelectAll:It,sheetsFilterPanelSelectAllCount:Pt,sheetsFilterPanelValuesContainer:Nt,inputAffixWrapper:yt,select:Rt,radioGroup:At,sheetsFilterPanelValuesFind:bt,sheetsFilterPanelValuesList:Lt,sheetsFilterPanelValuesListInnerContainer:Mt,sheetsFilterPanelValuesVirtual:Ut,sheetsFilterPanelValuesItem:$t,sheetsFilterPanelValuesItemInner:wt,sheetsFilterPanelValuesItemCount:Dt,sheetsFilterPanelValuesItemExcludeButton:Ht,sheetsFilterPanelValuesItemText:jt,sheetsFilterPanelConditionsContainer:Bt,sheetsFilterPanelConditionsContainerInner:xt,sheetsFilterPanelConditionsDesc:Vt,sheetsFilterPanelFooter:Wt,sheetsFilterPanelFooterPrimaryButtons:kt,button:Qt,input:Gt,formDualColumnLayout:Yt,sheetsFilterTreeNode:qt,sheetsFilterTreeNodeFilterOnly:Kt,sheetsFilterTreeNodeAttach:Xt};function Zt(t){const{model:e}=t,r=h.useDependency(h.LocaleService),i=C.useObservable(e.conditionItem$,void 0,!0),n=C.useObservable(e.filterConditionFormParams$,void 0,!0),{operator:l,numOfParameters:s}=i,{operator1:o,operator2:a,val1:c,val2:m,and:p}=n,F=p?"AND":"OR",f=A.useCallback(I=>{e.onConditionFormChange({and:I==="AND"})},[e]),T=Jt(r),E=A.useCallback(I=>{e.onPrimaryConditionChange(I)},[e]),b=zt(r),N=A.useCallback(I=>{e.onConditionFormChange(I)},[e]),U=r.t("sheets-filter.panel.input-values-placeholder");function $(I,H,k){const Z=d.getItemByOperator(I).numOfParameters===1;return _.jsxs(_.Fragment,{children:[k==="operator2"&&_.jsxs(M.RadioGroup,{value:F,onChange:f,children:[_.jsx(M.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),_.jsx(M.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),_.jsx(M.Select,{value:I,options:b,onChange:y=>N({[k]:y})}),Z&&_.jsx("div",{children:_.jsx(M.Input,{value:H,placeholder:U,onChange:y=>N({[k==="operator1"?"val1":"val2"]:y})})})]})}return _.jsxs("div",{className:P.sheetsFilterPanelConditionsContainer,children:[_.jsx(M.Select,{value:l,options:T,onChange:E}),d.getItemByOperator(l).numOfParameters!==0?_.jsxs("div",{className:P.sheetsFilterPanelConditionsContainerInner,children:[s>=1&&$(o,c!=null?c:"","operator1"),s>=2&&$(a,m!=null?m:"","operator2"),_.jsxs("div",{className:P.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),_.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})}function Jt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{options:[{label:t.t(d.NONE.label),value:d.NONE.operator}]},{options:[{label:t.t(d.EMPTY.label),value:d.EMPTY.operator},{label:t.t(d.NOT_EMPTY.label),value:d.NOT_EMPTY.operator}]},{options:[{label:t.t(d.TEXT_CONTAINS.label),value:d.TEXT_CONTAINS.operator},{label:t.t(d.DOES_NOT_CONTAIN.label),value:d.DOES_NOT_CONTAIN.operator},{label:t.t(d.STARTS_WITH.label),value:d.STARTS_WITH.operator},{label:t.t(d.ENDS_WITH.label),value:d.ENDS_WITH.operator},{label:t.t(d.EQUALS.label),value:d.EQUALS.operator}]},{options:[{label:t.t(d.GREATER_THAN.label),value:d.GREATER_THAN.operator},{label:t.t(d.GREATER_THAN_OR_EQUAL.label),value:d.GREATER_THAN_OR_EQUAL.operator},{label:t.t(d.LESS_THAN.label),value:d.LESS_THAN.operator},{label:t.t(d.LESS_THAN_OR_EQUAL.label),value:d.LESS_THAN_OR_EQUAL.operator},{label:t.t(d.EQUAL.label),value:d.EQUAL.operator},{label:t.t(d.NOT_EQUAL.label),value:d.NOT_EQUAL.operator},{label:t.t(d.BETWEEN.label),value:d.BETWEEN.operator},{label:t.t(d.NOT_BETWEEN.label),value:d.NOT_BETWEEN.operator}]},{options:[{label:t.t(d.CUSTOM.label),value:d.CUSTOM.operator}]}],[e,t])}function zt(t){const e=t.getCurrentLocale();return A.useMemo(()=>d.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function er(t){const{model:e}=t,r=h.useDependency(h.LocaleService),i=C.useObservable(e.searchString$,"",!0),n=C.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),s=Pe(n),o=s.checked>0&&s.unchecked===0,a=s.checked>0&&s.unchecked>0,c=e.treeMapCache,m=A.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=A.useCallback(f=>{e.setSearchString(f)},[e]);function F(f){let T=[];return f.forEach(E=>{E.checked&&T.push(E.key),E.children&&(T=T.concat(F(E.children)))}),T}return _.jsxs("div",{className:P.sheetsFilterPanelValuesContainer,children:[_.jsx(M.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),_.jsxs("div",{className:P.sheetsFilterPanelValuesList,children:[_.jsx("div",{className:P.sheetsFilterPanelValuesItem,children:_.jsxs("div",{className:P.sheetsFilterPanelValuesItemInner,children:[_.jsx(M.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),_.jsx("span",{className:P.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),_.jsx("span",{className:P.sheetsFilterPanelValuesItemCount,children:`(${s.checked}/${s.checked+s.unchecked})`})]})}),_.jsx("div",{className:P.sheetsFilterPanelValuesVirtual,children:_.jsx(M.Tree,{data:n,defaultExpandAll:!1,valueGroup:F(n),height:180,onChange:f=>{e.onFilterCheckToggled(f)},defaultCache:c,itemHeight:28,treeNodeClassName:P.sheetsFilterTreeNode,attachRender:f=>_.jsxs("div",{className:P.sheetsFilterTreeNodeAttach,children:[_.jsx("span",{className:P.sheetsFilterPanelValuesItemCount,children:`(${f.count})`}),_.jsx(M.Button,{className:P.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const T=[];f.children?f.children.forEach(E=>{E.children?E.children.forEach(b=>{T.push(b.key)}):T.push(E.key)}):T.push(f.key),e.onFilterOnly(T)},children:l})]})})})]})]})}function tr(){var b;const t=h.useDependency(Y),e=h.useDependency(h.LocaleService),r=h.useDependency(h.ICommandService),i=C.useObservable(t.filterBy$,void 0,!0),n=C.useObservable(t.filterByModel$,void 0,!1),l=C.useObservable(()=>(n==null?void 0:n.canApply$)||g.of(!1),void 0,!1,[n]),s=rr(e),o=!C.useObservable(t.hasCriteria$),a=A.useCallback(N=>{r.executeCommand(Me.id,{filterBy:N})},[r]),c=A.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(te.id)},[n,r]),m=A.useCallback(()=>{r.executeCommand(te.id)},[r]),p=A.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(te.id)},[n,r]),f=(b=h.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:b.getRange(),T=t.col,E=C.useComponentsOfPart(w.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return _.jsxs("div",{className:P.sheetsFilterPanel,children:[_.jsx(C.ComponentContainer,{components:E,sharedProps:{range:f,colIndex:T,onClose:m}}),_.jsx("div",{className:P.sheetsFilterPanelHeader,children:_.jsx(M.Segmented,{value:i,options:s,onChange:N=>a(N)})}),n?_.jsx("div",{className:P.sheetsFilterPanelContent,children:i===fe.VALUES?_.jsx(er,{model:n}):_.jsx(Zt,{model:n})}):_.jsx("div",{style:{flex:1}}),_.jsxs("div",{className:P.sheetsFilterPanelFooter,children:[_.jsx(M.Button,{type:"link",onClick:c,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),_.jsxs("span",{className:P.sheetsFilterPanelFooterPrimaryButtons,children:[_.jsx(M.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),_.jsx(M.Button,{disabled:!l,type:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function rr(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:fe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:fe.CONDITIONS}],[e,t])}function sr(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(t,h.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:w.getObservableWithExclusiveRange$(t,w.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function ir(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(t,h.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}function nr(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(t,h.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}const or={[C.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:sr,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:ir},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:nr}}}},ar={id:u.SmartToggleSheetsFilterCommand.id,binding:C.KeyCode.L|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:w.whenSheetEditorFocused,group:"4_sheet-edit"},G=16,lr=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class De{static drawNoCriteria(e,r,i,n){e.save(),ae.Rect.drawWith(e,{radius:2,width:G,height:G,fill:n}),e.lineCap="square",e.strokeStyle=i,e.scale(r/G,r/G),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,n){e.save(),ae.Rect.drawWith(e,{radius:2,width:G,height:G,fill:n}),e.scale(r/G,r/G),e.fillStyle=i,e.fill(lr),e.restore()}}var cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,hr=(t,e,r,i)=>{for(var n=i>1?void 0:i?ur(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&cr(e,r,n),n},Oe=(t,e)=>(r,i)=>e(r,i,t);const W=16,he=1;let Re=class extends ae.Shape{constructor(e,r,i,n,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(s=>this.onPointerDown(s)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,n=W-i,l=W-r;e.save();const s=new Path2D;s.rect(n,l,i,r),e.clip(s);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,c=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?De.drawHasCriteria(e,W,a,c):De.drawNoCriteria(e,W,a,c),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:n}=this._filterParams;this._contextService.getContextValue(re)||!this._commandService.hasCommand(le.id)||setTimeout(()=>{this._commandService.executeCommand(le.id,{unitId:i,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Re=hr([Oe(2,h.IContextService),Oe(3,h.ICommandService),Oe(4,h.Inject(h.ThemeService))],Re);var mr=Object.defineProperty,pr=Object.getOwnPropertyDescriptor,dr=(t,e,r,i)=>{for(var n=i>1?void 0:i?pr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&mr(e,r,n),n},X=(t,e)=>(r,i)=>e(r,i,t);const fr=1e3,_r=5e3;let Ae=class extends h.RxDisposable{constructor(e,r,i,n,l,s,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=s,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var o,a;if(!e)return g.of(null);const{unit:r,unitId:i}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,n))!=null?a:void 0,s=()=>({unitId:i,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return h.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.filter(([c])=>{var m;return c.type===h.CommandType.MUTATION&&((m=c.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(c.id)||c.id===O.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(s),g.startWith(s()))}),g.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,s=this._filterRangeShape=new w.SelectionControl(i,fr,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=w.attachSelectionWithCoord(o,r);s.updateRangeBySelectionWithCoord(a),s.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:n,skeleton:l,worksheetId:s}=e,{scene:o}=this._context;this._interceptCellContent(n,s,e.range);const{startColumn:a,endColumn:c,startRow:m}=r;for(let p=a;p<=c;p++){const F=`sheets-filter-button-${p}`,f=w.getCoordByCell(m,p,o,l),{startX:T,startY:E,endX:b,endY:N}=f,U=b-T,$=N-E;if($<=he||U<=he)continue;const I=!!i.getFilterColumn(p),H=b-W-he,k=N-W-he,Z={left:H,top:k,height:W,width:W,zIndex:_r,cellHeight:$,cellWidth:U,filterParams:{unitId:n,subUnitId:s,col:p,hasCriteria:I}},y=this._injector.createInstance(Re,F,Z);this._filterButtonShapes.push(y)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:n,startColumn:l,endColumn:s}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:h.InterceptorEffectEnum.Style,handler:(o,a,c)=>{const{row:m,col:p,unitId:F,subUnitId:f}=a;return F!==e||f!==r||m!==n||p<l||p>s?c(o):c({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:W}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Ae=dr([X(1,h.Inject(h.Injector)),X(2,h.Inject(w.SheetSkeletonManagerService)),X(3,h.Inject(u.SheetsFilterService)),X(4,h.Inject(h.ThemeService)),X(5,h.Inject(O.SheetInterceptorService)),X(6,h.ICommandService),X(7,w.ISheetSelectionRenderService)],Ae);var Sr=Object.defineProperty,vr=Object.getOwnPropertyDescriptor,gr=(t,e,r,i)=>{for(var n=i>1?void 0:i?vr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Sr(e,r,n),n},He=(t,e)=>(r,i)=>e(r,i,t);let ce=class extends h.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(h.UniverInstanceType.UNIVER_SHEET,[Ae]))}};ce=gr([He(0,ae.IRenderManagerService),He(1,h.Inject(w.SheetsRenderService))],ce);var Fr=Object.defineProperty,Cr=Object.getOwnPropertyDescriptor,Tr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Cr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Fr(e,r,n),n},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let ve=class extends ce{constructor(e,r,i,n,l,s,o,a,c,m,p,F,f){super(f,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=s,this._shortcutService=o,this._commandService=a,this._menuManagerService=c,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[ar].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Me,le,te].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(or)}_initUI(){this.disposeWithMe(this._componentManager.register(je,tr)),this.disposeWithMe(this._componentManager.register("FilterSingle",Ke)),this.disposeWithMe(this._contextService.subscribeContextValue$(re).pipe(g.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:M.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(te.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=Tr([D(0,h.Inject(h.Injector)),D(1,h.Inject(C.ComponentManager)),D(2,h.Inject(Y)),D(3,h.Inject(w.SheetCanvasPopManagerService)),D(4,h.Inject(u.SheetsFilterService)),D(5,h.Inject(h.LocaleService)),D(6,C.IShortcutService),D(7,h.ICommandService),D(8,C.IMenuManagerService),D(9,h.IContextService),D(10,C.IMessageService),D(11,h.Inject(w.SheetsRenderService)),D(12,ae.IRenderManagerService)],ve);var Xe=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,Or=(t,e,r)=>e in t?Xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ir=(t,e,r,i)=>{for(var n=i>1?void 0:i?Er(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Xe(e,r,n),n},Ie=(t,e)=>(r,i)=>e(r,i,t),Ze=(t,e,r)=>Or(t,typeof e!="symbol"?e+"":e,r);const Pr="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends h.Plugin{constructor(e=We,r,i,n){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=n;const{menu:l,...s}=this._config;l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ve,s)}onStarting(){[[Y],[se],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([pe,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(be))}])}onReady(){this._injector.get(se)}onRendered(){this._injector.get(ve)}};Ze(exports.UniverSheetsFilterUIPlugin,"type",h.UniverInstanceType.UNIVER_SHEET);Ze(exports.UniverSheetsFilterUIPlugin,"pluginName",Pr);exports.UniverSheetsFilterUIPlugin=Ir([h.DependentOn(u.UniverSheetsFilterPlugin),Ie(1,h.Inject(h.Injector)),Ie(2,h.IConfigService),Ie(3,h.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var Je=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,yr=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Nr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Je(e,r,n),n},Be=(t,e)=>(r,i)=>e(r,i,t),ze=(t,e,r)=>yr(t,typeof e!="symbol"?e+"":e,r);const Ar="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends h.Plugin{constructor(e=We,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:n,...l}=this._config;n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ve,l)}onStarting(){[[se],[ce]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(se)}onRendered(){this._injector.get(ce)}};ze(exports.UniverSheetsFilterMobileUIPlugin,"type",h.UniverInstanceType.UNIVER_SHEET);ze(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Ar);exports.UniverSheetsFilterMobileUIPlugin=Rr([h.DependentOn(u.UniverSheetsFilterPlugin),Be(1,h.Inject(h.Injector)),Be(2,h.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var br=Object.defineProperty,Lr=Object.getOwnPropertyDescriptor,Mr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Lr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&br(e,r,n),n},xe=(t,e)=>(r,i)=>e(r,i,t),me;exports.UniverSheetsFilterUIWorkerPlugin=(me=class extends h.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[pe,{useClass:Ne}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(be,ge.fromModule(this._injector.get(pe)))}},S(me,"type",h.UniverInstanceType.UNIVER_SHEET),S(me,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),me);exports.UniverSheetsFilterUIWorkerPlugin=Mr([xe(1,h.Inject(h.Injector)),xe(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Me;exports.CloseFilterPanelOperation=te;exports.OpenFilterPanelOperation=le;
|
|
9
|
+
*/var $e;function Ft(){if($e)return se;$e=1;var t=y,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,n=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(o,a,h){var m,p={},F=null,_=null;h!==void 0&&(F=""+h),a.key!==void 0&&(F=""+a.key),a.ref!==void 0&&(_=a.ref);for(m in a)i.call(a,m)&&!l.hasOwnProperty(m)&&(p[m]=a[m]);if(o&&o.defaultProps)for(m in a=o.defaultProps,a)p[m]===void 0&&(p[m]=a[m]);return{$$typeof:e,type:o,key:F,ref:_,props:p,_owner:n.current}}return se.Fragment=r,se.jsx=s,se.jsxs=s,se}var we;function Ct(){return we||(we=1,Ee.exports=Ft()),Ee.exports}var f=Ct();const Tt="univer-sheets-filter-panel",Et="univer-sheets-filter-panel-header",Ot="univer-sheets-filter-panel-content",It="univer-sheets-filter-panel-select-all",Pt="univer-sheets-filter-panel-select-all-count",Nt="univer-sheets-filter-panel-values-container",yt="univer-input-affix-wrapper",Rt="univer-select",At="univer-radio-group",bt="univer-sheets-filter-panel-values-find",Lt="univer-sheets-filter-panel-values-list",Mt="univer-sheets-filter-panel-values-list-inner-container",Ut="univer-sheets-filter-panel-values-virtual",$t="univer-sheets-filter-panel-values-item",wt="univer-sheets-filter-panel-values-item-inner",Dt="univer-sheets-filter-panel-values-item-count",Ht="univer-sheets-filter-panel-values-item-exclude-button",jt="univer-sheets-filter-panel-values-item-text",Bt="univer-sheets-filter-panel-conditions-container",xt="univer-sheets-filter-panel-conditions-container-inner",Vt="univer-sheets-filter-panel-conditions-desc",Wt="univer-sheets-filter-panel-footer",kt="univer-sheets-filter-panel-footer-primary-buttons",Qt="univer-button",Gt="univer-input",Yt="univer-form-dual-column-layout",qt="univer-sheets-filter-tree-node",Kt="univer-sheets-filter-tree-node-filter-only",Xt="univer-sheets-filter-tree-node-attach",P={sheetsFilterPanel:Tt,sheetsFilterPanelHeader:Et,sheetsFilterPanelContent:Ot,sheetsFilterPanelSelectAll:It,sheetsFilterPanelSelectAllCount:Pt,sheetsFilterPanelValuesContainer:Nt,inputAffixWrapper:yt,select:Rt,radioGroup:At,sheetsFilterPanelValuesFind:bt,sheetsFilterPanelValuesList:Lt,sheetsFilterPanelValuesListInnerContainer:Mt,sheetsFilterPanelValuesVirtual:Ut,sheetsFilterPanelValuesItem:$t,sheetsFilterPanelValuesItemInner:wt,sheetsFilterPanelValuesItemCount:Dt,sheetsFilterPanelValuesItemExcludeButton:Ht,sheetsFilterPanelValuesItemText:jt,sheetsFilterPanelConditionsContainer:Bt,sheetsFilterPanelConditionsContainerInner:xt,sheetsFilterPanelConditionsDesc:Vt,sheetsFilterPanelFooter:Wt,sheetsFilterPanelFooterPrimaryButtons:kt,button:Qt,input:Gt,formDualColumnLayout:Yt,sheetsFilterTreeNode:qt,sheetsFilterTreeNodeFilterOnly:Kt,sheetsFilterTreeNodeAttach:Xt};function Zt(t){var _,E;const{model:e}=t,r=u.useDependency(u.LocaleService),i=T.useObservable(e.conditionItem$,void 0),n=T.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",s=y.useCallback(C=>{e.onConditionFormChange({and:C==="AND"})},[e]),o=Jt(r),a=y.useCallback(C=>{e.onPrimaryConditionChange(C)},[e]),h=zt(r),m=y.useCallback(C=>{e.onConditionFormChange(C)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function F(C,R,I){const M=d.getItemByOperator(C).numOfParameters===1;return f.jsxs(f.Fragment,{children:[I==="operator2"&&f.jsxs(L.RadioGroup,{value:l,onChange:s,children:[f.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),f.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),f.jsx(L.Select,{value:C,options:h,onChange:b=>m({[I]:b})}),M&&f.jsx("div",{children:f.jsx(L.Input,{value:R,placeholder:p,onChange:b=>m({[I==="operator1"?"val1":"val2"]:b})})})]})}return f.jsx("div",{className:P.sheetsFilterPanelConditionsContainer,children:i&&n&&f.jsxs(f.Fragment,{children:[f.jsx(L.Select,{value:i.operator,options:o,onChange:a}),d.getItemByOperator(i.operator).numOfParameters!==0?f.jsxs("div",{className:P.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&F(n.operator1,(_=n.val1)!=null?_:"","operator1"),i.numOfParameters>=2&&F(n.operator2,(E=n.val2)!=null?E:"","operator2"),f.jsxs("div",{className:P.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),f.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Jt(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{options:[{label:t.t(d.NONE.label),value:d.NONE.operator}]},{options:[{label:t.t(d.EMPTY.label),value:d.EMPTY.operator},{label:t.t(d.NOT_EMPTY.label),value:d.NOT_EMPTY.operator}]},{options:[{label:t.t(d.TEXT_CONTAINS.label),value:d.TEXT_CONTAINS.operator},{label:t.t(d.DOES_NOT_CONTAIN.label),value:d.DOES_NOT_CONTAIN.operator},{label:t.t(d.STARTS_WITH.label),value:d.STARTS_WITH.operator},{label:t.t(d.ENDS_WITH.label),value:d.ENDS_WITH.operator},{label:t.t(d.EQUALS.label),value:d.EQUALS.operator}]},{options:[{label:t.t(d.GREATER_THAN.label),value:d.GREATER_THAN.operator},{label:t.t(d.GREATER_THAN_OR_EQUAL.label),value:d.GREATER_THAN_OR_EQUAL.operator},{label:t.t(d.LESS_THAN.label),value:d.LESS_THAN.operator},{label:t.t(d.LESS_THAN_OR_EQUAL.label),value:d.LESS_THAN_OR_EQUAL.operator},{label:t.t(d.EQUAL.label),value:d.EQUAL.operator},{label:t.t(d.NOT_EQUAL.label),value:d.NOT_EQUAL.operator},{label:t.t(d.BETWEEN.label),value:d.BETWEEN.operator},{label:t.t(d.NOT_BETWEEN.label),value:d.NOT_BETWEEN.operator}]},{options:[{label:t.t(d.CUSTOM.label),value:d.CUSTOM.operator}]}],[e,t])}function zt(t){const e=t.getCurrentLocale();return y.useMemo(()=>d.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function er(t){const{model:e}=t,r=u.useDependency(u.LocaleService),i=T.useObservable(e.searchString$,"",!0),n=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),s=Pe(n),o=s.checked>0&&s.unchecked===0,a=s.checked>0&&s.unchecked>0,h=e.treeMapCache,m=y.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=y.useCallback(_=>{e.setSearchString(_)},[e]);function F(_){let E=[];return _.forEach(C=>{C.checked&&E.push(C.key),C.children&&(E=E.concat(F(C.children)))}),E}return f.jsxs("div",{className:P.sheetsFilterPanelValuesContainer,children:[f.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),f.jsxs("div",{className:P.sheetsFilterPanelValuesList,children:[f.jsx("div",{className:P.sheetsFilterPanelValuesItem,children:f.jsxs("div",{className:P.sheetsFilterPanelValuesItemInner,children:[f.jsx(L.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),f.jsx("span",{className:P.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),f.jsx("span",{className:P.sheetsFilterPanelValuesItemCount,children:`(${s.checked}/${s.checked+s.unchecked})`})]})}),f.jsx("div",{className:P.sheetsFilterPanelValuesVirtual,children:f.jsx(L.Tree,{data:n,defaultExpandAll:!1,valueGroup:F(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:P.sheetsFilterTreeNode,attachRender:_=>f.jsxs("div",{className:P.sheetsFilterTreeNodeAttach,children:[f.jsx("span",{className:P.sheetsFilterPanelValuesItemCount,children:`(${_.count})`}),f.jsx(L.Button,{className:P.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const E=[];_.children?_.children.forEach(C=>{C.children?C.children.forEach(R=>{E.push(R.key)}):E.push(C.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function tr(){var R;const t=u.useDependency(G),e=u.useDependency(u.LocaleService),r=u.useDependency(u.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),n=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(n==null?void 0:n.canApply$)||g.of(!1),void 0,!1,[n]),s=rr(e),o=!T.useObservable(t.hasCriteria$),a=y.useCallback(I=>{r.executeCommand(Me.id,{filterBy:I})},[r]),h=y.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(z.id)},[n,r]),m=y.useCallback(()=>{r.executeCommand(z.id)},[r]),p=y.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(z.id)},[n,r]),_=(R=u.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:R.getRange(),E=t.col,C=T.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return f.jsxs("div",{className:P.sheetsFilterPanel,children:[f.jsx(T.ComponentContainer,{components:C,sharedProps:{range:_,colIndex:E,onClose:m}}),f.jsx("div",{className:P.sheetsFilterPanelHeader,children:f.jsx(L.Segmented,{value:i,options:s,onChange:I=>a(I)})}),n?f.jsx("div",{className:P.sheetsFilterPanelContent,children:i===fe.VALUES?f.jsx(er,{model:n}):f.jsx(Zt,{model:n})}):f.jsx("div",{style:{flex:1}}),f.jsxs("div",{className:P.sheetsFilterPanelFooter,children:[f.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),f.jsxs("span",{className:P.sheetsFilterPanelFooterPrimaryButtons,children:[f.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),f.jsx(L.Button,{disabled:!l,type:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function rr(t){const e=t.getCurrentLocale();return y.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:fe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:fe.CONDITIONS}],[e,t])}function sr(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function ir(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}function nr(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}const or={[T.RibbonStartGroup.FORMULAS_INSERT]:{[c.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:sr,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:ir},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:nr}}}},ar={id:c.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"},Q=16,lr=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class De{static drawNoCriteria(e,r,i,n){e.save(),ne.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Q,r/Q),e.beginPath(),e.lineWidth=1,e.lineCap="round",e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,r,i,n){e.save(),ne.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.scale(r/Q,r/Q),e.fillStyle=i,e.fill(lr),e.restore()}}var cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,hr=(t,e,r,i)=>{for(var n=i>1?void 0:i?ur(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&cr(e,r,n),n},Oe=(t,e)=>(r,i)=>e(r,i,t);const W=16,he=1;let Re=class extends ne.Shape{constructor(e,r,i,n,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(s=>this.onPointerDown(s)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,i=this._cellWidth,n=W-i,l=W-r;e.save();const s=new Path2D;s.rect(n,l,i,r),e.clip(s);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?De.drawHasCriteria(e,W,a,h):De.drawNoCriteria(e,W,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:n}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Re=hr([Oe(2,u.IContextService),Oe(3,u.ICommandService),Oe(4,u.Inject(u.ThemeService))],Re);var mr=Object.defineProperty,pr=Object.getOwnPropertyDescriptor,dr=(t,e,r,i)=>{for(var n=i>1?void 0:i?pr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&mr(e,r,n),n},K=(t,e)=>(r,i)=>e(r,i,t);const fr=1e3,_r=5e3;let Ae=class extends u.RxDisposable{constructor(e,r,i,n,l,s,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=s,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var o,a;if(!e)return g.of(null);const{unit:r,unitId:i}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,n))!=null?a:void 0,s=()=>({unitId:i,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(s),g.startWith(s()))}),g.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,s=this._filterRangeShape=new $.SelectionControl(i,fr,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(o,r);s.updateRangeBySelectionWithCoord(a),s.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:n,skeleton:l,worksheetId:s}=e,{scene:o}=this._context;this._interceptCellContent(n,s,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const F=`sheets-filter-button-${p}`,_=$.getCoordByCell(m,p,o,l),{startX:E,startY:C,endX:R,endY:I}=_,M=R-E,b=I-C;if(b<=he||M<=he)continue;const j=!!i.getFilterColumn(p),B=R-W-he,le=I-W-he,ce={left:B,top:le,height:W,width:W,zIndex:_r,cellHeight:b,cellWidth:M,filterParams:{unitId:n,subUnitId:s,col:p,hasCriteria:j}},U=this._injector.createInstance(Re,F,ce);this._filterButtonShapes.push(U)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:n,startColumn:l,endColumn:s}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:p,unitId:F,subUnitId:_}=a;return F!==e||_!==r||m!==n||p<l||p>s?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:W}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Ae=dr([K(1,u.Inject(u.Injector)),K(2,u.Inject($.SheetSkeletonManagerService)),K(3,u.Inject(c.SheetsFilterService)),K(4,u.Inject(u.ThemeService)),K(5,u.Inject(O.SheetInterceptorService)),K(6,u.ICommandService),K(7,$.ISheetSelectionRenderService)],Ae);var Sr=Object.defineProperty,vr=Object.getOwnPropertyDescriptor,gr=(t,e,r,i)=>{for(var n=i>1?void 0:i?vr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Sr(e,r,n),n},He=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Ae]))}};ae=gr([He(0,ne.IRenderManagerService),He(1,u.Inject($.SheetsRenderService))],ae);var Fr=Object.defineProperty,Cr=Object.getOwnPropertyDescriptor,Tr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Cr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Fr(e,r,n),n},w=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let ve=class extends ae{constructor(e,r,i,n,l,s,o,a,h,m,p,F,_){super(_,F);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=s,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[ar].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Me,oe,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(or)}_initUI(){this.disposeWithMe(this._componentManager.register(je,tr)),this.disposeWithMe(this._componentManager.register("FilterSingle",Ke)),this.disposeWithMe(this._contextService.subscribeContextValue$(ee).pipe(g.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),i=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=Tr([w(0,u.Inject(u.Injector)),w(1,u.Inject(T.ComponentManager)),w(2,u.Inject(G)),w(3,u.Inject($.SheetCanvasPopManagerService)),w(4,u.Inject(c.SheetsFilterService)),w(5,u.Inject(u.LocaleService)),w(6,T.IShortcutService),w(7,u.ICommandService),w(8,T.IMenuManagerService),w(9,u.IContextService),w(10,T.IMessageService),w(11,u.Inject($.SheetsRenderService)),w(12,ne.IRenderManagerService)],ve);var Xe=Object.defineProperty,Er=Object.getOwnPropertyDescriptor,Or=(t,e,r)=>e in t?Xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ir=(t,e,r,i)=>{for(var n=i>1?void 0:i?Er(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Xe(e,r,n),n},Ie=(t,e)=>(r,i)=>e(r,i,t),Ze=(t,e,r)=>Or(t,typeof e!="symbol"?e+"":e,r);const Pr="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=We,r,i,n){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=n;const{menu:l,...s}=this._config;l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ve,s)}onStarting(){[[G],[te],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([pe,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(be))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ve)}};Ze(exports.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ze(exports.UniverSheetsFilterUIPlugin,"pluginName",Pr);exports.UniverSheetsFilterUIPlugin=Ir([u.DependentOn(c.UniverSheetsFilterPlugin),Ie(1,u.Inject(u.Injector)),Ie(2,u.IConfigService),Ie(3,u.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var Je=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,yr=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Nr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Je(e,r,n),n},Be=(t,e)=>(r,i)=>e(r,i,t),ze=(t,e,r)=>yr(t,typeof e!="symbol"?e+"":e,r);const Ar="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=We,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:n,...l}=this._config;n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ve,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}};ze(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);ze(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Ar);exports.UniverSheetsFilterMobileUIPlugin=Rr([u.DependentOn(c.UniverSheetsFilterPlugin),Be(1,u.Inject(u.Injector)),Be(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var br=Object.defineProperty,Lr=Object.getOwnPropertyDescriptor,Mr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Lr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&br(e,r,n),n},xe=(t,e)=>(r,i)=>e(r,i,t),me;exports.UniverSheetsFilterUIWorkerPlugin=(me=class extends u.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[pe,{useClass:Ne}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(be,ge.fromModule(this._injector.get(pe)))}},S(me,"type",u.UniverInstanceType.UNIVER_SHEET),S(me,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),me);exports.UniverSheetsFilterUIWorkerPlugin=Mr([xe(1,u.Inject(u.Injector)),xe(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Me;exports.CloseFilterPanelOperation=z;exports.OpenFilterPanelOperation=oe;
|