@univerjs/sheets-filter 0.6.0 → 0.6.1-nightly.202502221605
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/es/facade.js +232 -23
- package/lib/types/facade/f-event.d.ts +22 -4
- package/lib/types/facade/f-filter.d.ts +222 -11
- package/lib/types/facade/f-range.d.ts +26 -12
- package/lib/types/facade/f-worksheet.d.ts +2 -1
- package/lib/umd/facade.js +1 -1
- package/package.json +6 -6
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("@univerjs/core"),i=require("@univerjs/sheets-filter"),s=require("@univerjs/sheets/facade"),a=require("@univerjs/core/facade");var F=Object.getOwnPropertyDescriptor,g=(o,e,t,r)=>{for(var n=r>1?void 0:r?F(e,t):e,l=o.length-1,d;l>=0;l--)(d=o[l])&&(n=d(n)||n);return n},c=(o,e)=>(t,r)=>e(t,r,o);exports.FFilter=class{constructor(e,t,r,n,l){this._workbook=e,this._worksheet=t,this._filterModel=r,this._injector=n,this._commandSrv=l}getFilteredOutRows(){return Array.from(this._filterModel.filteredOutRows).sort()}getColumnFilterCriteria(e){var t;return(t=this._filterModel.getFilterColumn(e))==null?void 0:t.getColumnData()}removeColumnFilterCriteria(e){return this._commandSrv.syncExecuteCommand(i.SetSheetsFilterCriteriaCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),col:e,criteria:null}),this}setColumnFilterCriteria(e,t){return this._commandSrv.syncExecuteCommand(i.SetSheetsFilterCriteriaCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),col:e,criteria:t}),this}getRange(){const e=this._filterModel.getRange();return this._injector.createInstance(s.FRange,this._workbook,this._worksheet,e)}removeFilterCriteria(){return this._commandSrv.syncExecuteCommand(i.ClearSheetsFilterCriteriaCommand.id),this}remove(){return this._commandSrv.syncExecuteCommand(i.RemoveSheetFilterCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()})}};exports.FFilter=g([c(3,h.Inject(h.Injector)),c(4,h.ICommandService)],exports.FFilter);class m extends s.FRange{createFilter(){return this._getFilterModel()||!this._commandService.syncExecuteCommand(i.SetSheetFilterRangeCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),range:this._range})?null:this.getFilter()}getFilter(){const e=this._getFilterModel();return e?this._injector.createInstance(exports.FFilter,this._workbook,this._worksheet,e):null}_getFilterModel(){return this._injector.get(i.SheetsFilterService).getFilterModel(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FRange.extend(m);class u extends s.FWorksheet{getFilter(){const e=this._getFilterModel();return e?this._injector.createInstance(exports.FFilter,this._workbook,this._worksheet,e):null}_getFilterModel(){return this._injector.get(i.SheetsFilterService).getFilterModel(this._workbook.getUnitId(),this._worksheet.getSheetId())}}s.FWorksheet.extend(u);class S{get CustomFilterOperator(){return i.CustomFilterOperator}}a.FEnum.extend(S);class C extends a.FEventName{get SheetBeforeRangeFilter(){return"SheetBeforeRangeFilter"}get SheetRangeFiltered(){return"SheetRangeFiltered"}get SheetRangeFilterCleared(){return"SheetRangeFilterCleared"}get SheetBeforeRangeFilterClear(){return"SheetBeforeRangeFilterClear"}}a.FEventName.extend(C);a.FEventName.extend(s.FSheetEventName);class v extends a.FUniver{_initialize(e){const t=e.get(h.ICommandService);this.registerEventHandler(this.Event.SheetBeforeRangeFilter,()=>t.beforeCommandExecuted(r=>{r.id===i.SetSheetsFilterCriteriaCommand.id&&this._beforeRangeFilter(r)})),this.registerEventHandler(this.Event.SheetBeforeRangeFilterClear,()=>t.beforeCommandExecuted(r=>{r.id===i.ClearSheetsFilterCriteriaCommand.id&&this._beforeRangeFilterClear()})),this.registerEventHandler(this.Event.SheetRangeFiltered,()=>t.onCommandExecuted(r=>{r.id===i.SetSheetsFilterCriteriaCommand.id&&this._onRangeFiltered(r)})),this.registerEventHandler(this.Event.SheetRangeFilterCleared,()=>t.onCommandExecuted(r=>{r.id===i.ClearSheetsFilterCriteriaCommand.id&&this._onRangeFilterCleared()}))}_beforeRangeFilter(e){const t=e.params,r=this.getUniverSheet(t.unitId),n={workbook:r,worksheet:r.getSheetBySheetId(t.subUnitId),col:t.col,criteria:t.criteria};if(this.fireEvent(this.Event.SheetBeforeRangeFilter,n),n.cancel)throw new Error("SetSheetsFilterCriteriaCommand canceled.")}_onRangeFiltered(e){const t=e.params,r=this.getUniverSheet(t.unitId),n={workbook:r,worksheet:r.getSheetBySheetId(t.subUnitId),col:t.col,criteria:t.criteria};this.fireEvent(this.Event.SheetRangeFiltered,n)}_beforeRangeFilterClear(){const e=this.getActiveWorkbook();if(!e)return;const t={workbook:e,worksheet:e.getActiveSheet()};if(this.fireEvent(this.Event.SheetBeforeRangeFilterClear,t),t.cancel)throw new Error("SetSheetsFilterCriteriaCommand canceled.")}_onRangeFilterCleared(){const e=this.getActiveWorkbook();if(!e)return;const t={workbook:e,worksheet:e.getActiveSheet()};this.fireEvent(this.Event.SheetRangeFilterCleared,t)}}a.FUniver.extend(v);
|
package/lib/es/facade.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Inject as
|
|
2
|
-
import { SetSheetsFilterCriteriaCommand as o, ClearSheetsFilterCriteriaCommand as l, RemoveSheetFilterCommand as v, SetSheetFilterRangeCommand as
|
|
1
|
+
import { Inject as k, Injector as S, ICommandService as m } from "@univerjs/core";
|
|
2
|
+
import { SetSheetsFilterCriteriaCommand as o, ClearSheetsFilterCriteriaCommand as l, RemoveSheetFilterCommand as v, SetSheetFilterRangeCommand as f, SheetsFilterService as F, CustomFilterOperator as C } from "@univerjs/sheets-filter";
|
|
3
3
|
import { FRange as h, FWorksheet as u, FSheetEventName as w } from "@univerjs/sheets/facade";
|
|
4
|
-
import { FEnum as
|
|
5
|
-
var
|
|
6
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
4
|
+
import { FEnum as b, FEventName as d, FUniver as _ } from "@univerjs/core/facade";
|
|
5
|
+
var E = Object.getOwnPropertyDescriptor, R = (i, e, t, r) => {
|
|
6
|
+
for (var n = r > 1 ? void 0 : r ? E(e, t) : e, a = i.length - 1, c; a >= 0; a--)
|
|
7
7
|
(c = i[a]) && (n = c(n) || n);
|
|
8
8
|
return n;
|
|
9
9
|
}, g = (i, e) => (t, r) => e(t, r, i);
|
|
@@ -14,14 +14,89 @@ let s = class {
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the filtered out rows by this filter.
|
|
16
16
|
* @returns {number[]} Filtered out rows by this filter.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
20
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
21
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
22
|
+
* fRange.setValues([
|
|
23
|
+
* [1, 2, 3, 4],
|
|
24
|
+
* [2, 3, 4, 5],
|
|
25
|
+
* [3, 4, 5, 6],
|
|
26
|
+
* [4, 5, 6, 7],
|
|
27
|
+
* [5, 6, 7, 8],
|
|
28
|
+
* [6, 7, 8, 9],
|
|
29
|
+
* [7, 8, 9, 10],
|
|
30
|
+
* [8, 9, 10, 11],
|
|
31
|
+
* [9, 10, 11, 12],
|
|
32
|
+
* [10, 11, 12, 13],
|
|
33
|
+
* ]);
|
|
34
|
+
*
|
|
35
|
+
* // Create a filter on the range
|
|
36
|
+
* let fFilter = fRange.createFilter();
|
|
37
|
+
*
|
|
38
|
+
* // If the filter already exists, remove it and create a new one
|
|
39
|
+
* if (!fFilter) {
|
|
40
|
+
* fRange.getFilter().remove();
|
|
41
|
+
* fFilter = fRange.createFilter();
|
|
42
|
+
* }
|
|
43
|
+
*
|
|
44
|
+
* // Set the filter criteria of the column A
|
|
45
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
46
|
+
* colId: 0,
|
|
47
|
+
* filters: {
|
|
48
|
+
* filters: ['1', '5', '9'],
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* console.log(fFilter?.getFilteredOutRows()); // [1, 2, 3, 5, 6, 7, 9]
|
|
53
|
+
* ```
|
|
17
54
|
*/
|
|
18
55
|
getFilteredOutRows() {
|
|
19
56
|
return Array.from(this._filterModel.filteredOutRows).sort();
|
|
20
57
|
}
|
|
21
58
|
/**
|
|
22
59
|
* Get the filter criteria of a column.
|
|
23
|
-
* @param {number}
|
|
60
|
+
* @param {number} column - The column index.
|
|
24
61
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
65
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
66
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
67
|
+
* fRange.setValues([
|
|
68
|
+
* [1, 2, 3, 4],
|
|
69
|
+
* [2, 3, 4, 5],
|
|
70
|
+
* [3, 4, 5, 6],
|
|
71
|
+
* [4, 5, 6, 7],
|
|
72
|
+
* [5, 6, 7, 8],
|
|
73
|
+
* [6, 7, 8, 9],
|
|
74
|
+
* [7, 8, 9, 10],
|
|
75
|
+
* [8, 9, 10, 11],
|
|
76
|
+
* [9, 10, 11, 12],
|
|
77
|
+
* [10, 11, 12, 13],
|
|
78
|
+
* ]);
|
|
79
|
+
*
|
|
80
|
+
* // Create a filter on the range
|
|
81
|
+
* let fFilter = fRange.createFilter();
|
|
82
|
+
*
|
|
83
|
+
* // If the filter already exists, remove it and create a new one
|
|
84
|
+
* if (!fFilter) {
|
|
85
|
+
* fRange.getFilter().remove();
|
|
86
|
+
* fFilter = fRange.createFilter();
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* // Set the filter criteria of the column A
|
|
90
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
91
|
+
* colId: 0,
|
|
92
|
+
* filters: {
|
|
93
|
+
* filters: ['1', '5', '9'],
|
|
94
|
+
* },
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* console.log(fFilter?.getColumnFilterCriteria(0)); // { colId: 0, filters: { filters: ['1', '5', '9'] } }
|
|
98
|
+
* console.log(fFilter?.getColumnFilterCriteria(1)); // undefined
|
|
99
|
+
* ```
|
|
25
100
|
*/
|
|
26
101
|
getColumnFilterCriteria(i) {
|
|
27
102
|
var e;
|
|
@@ -29,8 +104,48 @@ let s = class {
|
|
|
29
104
|
}
|
|
30
105
|
/**
|
|
31
106
|
* Clear the filter criteria of a column.
|
|
32
|
-
* @param {number}
|
|
33
|
-
* @returns {FFilter} The
|
|
107
|
+
* @param {number} column - The column index.
|
|
108
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
112
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
113
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
114
|
+
* fRange.setValues([
|
|
115
|
+
* [1, 2, 3, 4],
|
|
116
|
+
* [2, 3, 4, 5],
|
|
117
|
+
* [3, 4, 5, 6],
|
|
118
|
+
* [4, 5, 6, 7],
|
|
119
|
+
* [5, 6, 7, 8],
|
|
120
|
+
* [6, 7, 8, 9],
|
|
121
|
+
* [7, 8, 9, 10],
|
|
122
|
+
* [8, 9, 10, 11],
|
|
123
|
+
* [9, 10, 11, 12],
|
|
124
|
+
* [10, 11, 12, 13],
|
|
125
|
+
* ]);
|
|
126
|
+
*
|
|
127
|
+
* // Create a filter on the range
|
|
128
|
+
* let fFilter = fRange.createFilter();
|
|
129
|
+
*
|
|
130
|
+
* // If the filter already exists, remove it and create a new one
|
|
131
|
+
* if (!fFilter) {
|
|
132
|
+
* fRange.getFilter().remove();
|
|
133
|
+
* fFilter = fRange.createFilter();
|
|
134
|
+
* }
|
|
135
|
+
*
|
|
136
|
+
* // Set the filter criteria of the column A
|
|
137
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
138
|
+
* colId: 0,
|
|
139
|
+
* filters: {
|
|
140
|
+
* filters: ['1', '5', '9'],
|
|
141
|
+
* },
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Clear the filter criteria of the column A after 3 seconds
|
|
145
|
+
* setTimeout(() => {
|
|
146
|
+
* fFilter?.removeColumnFilterCriteria(0);
|
|
147
|
+
* }, 3000);
|
|
148
|
+
* ```
|
|
34
149
|
*/
|
|
35
150
|
removeColumnFilterCriteria(i) {
|
|
36
151
|
return this._commandSrv.syncExecuteCommand(o.id, {
|
|
@@ -42,9 +157,44 @@ let s = class {
|
|
|
42
157
|
}
|
|
43
158
|
/**
|
|
44
159
|
* Set the filter criteria of a column.
|
|
45
|
-
* @param {number}
|
|
46
|
-
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria The new filter criteria.
|
|
47
|
-
* @returns {FFilter} The
|
|
160
|
+
* @param {number} column - The column index.
|
|
161
|
+
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
162
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
166
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
167
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
168
|
+
* fRange.setValues([
|
|
169
|
+
* [1, 2, 3, 4],
|
|
170
|
+
* [2, 3, 4, 5],
|
|
171
|
+
* [3, 4, 5, 6],
|
|
172
|
+
* [4, 5, 6, 7],
|
|
173
|
+
* [5, 6, 7, 8],
|
|
174
|
+
* [6, 7, 8, 9],
|
|
175
|
+
* [7, 8, 9, 10],
|
|
176
|
+
* [8, 9, 10, 11],
|
|
177
|
+
* [9, 10, 11, 12],
|
|
178
|
+
* [10, 11, 12, 13],
|
|
179
|
+
* ]);
|
|
180
|
+
*
|
|
181
|
+
* // Create a filter on the range
|
|
182
|
+
* let fFilter = fRange.createFilter();
|
|
183
|
+
*
|
|
184
|
+
* // If the filter already exists, remove it and create a new one
|
|
185
|
+
* if (!fFilter) {
|
|
186
|
+
* fRange.getFilter().remove();
|
|
187
|
+
* fFilter = fRange.createFilter();
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* // Set the filter criteria of the column A
|
|
191
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
192
|
+
* colId: 0,
|
|
193
|
+
* filters: {
|
|
194
|
+
* filters: ['1', '5', '9'],
|
|
195
|
+
* },
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
48
198
|
*/
|
|
49
199
|
setColumnFilterCriteria(i, e) {
|
|
50
200
|
return this._commandSrv.syncExecuteCommand(o.id, {
|
|
@@ -57,6 +207,13 @@ let s = class {
|
|
|
57
207
|
/**
|
|
58
208
|
* Get the range of the filter.
|
|
59
209
|
* @returns {FRange} The range of the filter.
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
213
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
214
|
+
* const fFilter = fWorksheet.getFilter();
|
|
215
|
+
* console.log(fFilter?.getRange().getA1Notation());
|
|
216
|
+
* ```
|
|
60
217
|
*/
|
|
61
218
|
getRange() {
|
|
62
219
|
const i = this._filterModel.getRange();
|
|
@@ -64,14 +221,68 @@ let s = class {
|
|
|
64
221
|
}
|
|
65
222
|
/**
|
|
66
223
|
* Remove the filter criteria of all columns.
|
|
67
|
-
* @returns {
|
|
224
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
228
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
229
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
230
|
+
* fRange.setValues([
|
|
231
|
+
* [1, 2, 3, 4],
|
|
232
|
+
* [2, 3, 4, 5],
|
|
233
|
+
* [3, 4, 5, 6],
|
|
234
|
+
* [4, 5, 6, 7],
|
|
235
|
+
* [5, 6, 7, 8],
|
|
236
|
+
* [6, 7, 8, 9],
|
|
237
|
+
* [7, 8, 9, 10],
|
|
238
|
+
* [8, 9, 10, 11],
|
|
239
|
+
* [9, 10, 11, 12],
|
|
240
|
+
* [10, 11, 12, 13],
|
|
241
|
+
* ]);
|
|
242
|
+
*
|
|
243
|
+
* // Create a filter on the range
|
|
244
|
+
* let fFilter = fRange.createFilter();
|
|
245
|
+
*
|
|
246
|
+
* // If the filter already exists, remove it and create a new one
|
|
247
|
+
* if (!fFilter) {
|
|
248
|
+
* fRange.getFilter().remove();
|
|
249
|
+
* fFilter = fRange.createFilter();
|
|
250
|
+
* }
|
|
251
|
+
*
|
|
252
|
+
* // Set the filter criteria of the column A
|
|
253
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
254
|
+
* colId: 0,
|
|
255
|
+
* filters: {
|
|
256
|
+
* filters: ['1', '5', '9'],
|
|
257
|
+
* },
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* // Clear the filter criteria of all columns after 3 seconds
|
|
261
|
+
* setTimeout(() => {
|
|
262
|
+
* fFilter?.removeFilterCriteria();
|
|
263
|
+
* }, 3000);
|
|
264
|
+
* ```
|
|
68
265
|
*/
|
|
69
266
|
removeFilterCriteria() {
|
|
70
267
|
return this._commandSrv.syncExecuteCommand(l.id), this;
|
|
71
268
|
}
|
|
72
269
|
/**
|
|
73
270
|
* Remove the filter from the worksheet.
|
|
74
|
-
* @returns {boolean}
|
|
271
|
+
* @returns {boolean} True if the filter is removed successfully; otherwise, false.
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
275
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
276
|
+
* const fRange = fWorksheet.getRange('A1:D14');
|
|
277
|
+
* let fFilter = fRange.createFilter();
|
|
278
|
+
*
|
|
279
|
+
* // If the worksheet already has a filter, remove it and create a new filter.
|
|
280
|
+
* if (!fFilter) {
|
|
281
|
+
* fWorksheet.getFilter().remove();
|
|
282
|
+
* fFilter = fRange.createFilter();
|
|
283
|
+
* }
|
|
284
|
+
* console.log(fFilter);
|
|
285
|
+
* ```
|
|
75
286
|
*/
|
|
76
287
|
remove() {
|
|
77
288
|
return this._commandSrv.syncExecuteCommand(v.id, {
|
|
@@ -81,12 +292,12 @@ let s = class {
|
|
|
81
292
|
}
|
|
82
293
|
};
|
|
83
294
|
s = R([
|
|
84
|
-
g(3,
|
|
295
|
+
g(3, k(S)),
|
|
85
296
|
g(4, m)
|
|
86
297
|
], s);
|
|
87
298
|
class I extends h {
|
|
88
299
|
createFilter() {
|
|
89
|
-
return this._getFilterModel() || !this._commandService.syncExecuteCommand(
|
|
300
|
+
return this._getFilterModel() || !this._commandService.syncExecuteCommand(f.id, {
|
|
90
301
|
unitId: this._workbook.getUnitId(),
|
|
91
302
|
subUnitId: this._worksheet.getSheetId(),
|
|
92
303
|
range: this._range
|
|
@@ -124,10 +335,10 @@ class x extends u {
|
|
|
124
335
|
u.extend(x);
|
|
125
336
|
class U {
|
|
126
337
|
get CustomFilterOperator() {
|
|
127
|
-
return
|
|
338
|
+
return C;
|
|
128
339
|
}
|
|
129
340
|
}
|
|
130
|
-
|
|
341
|
+
b.extend(U);
|
|
131
342
|
class M extends d {
|
|
132
343
|
get SheetBeforeRangeFilter() {
|
|
133
344
|
return "SheetBeforeRangeFilter";
|
|
@@ -144,7 +355,7 @@ class M extends d {
|
|
|
144
355
|
}
|
|
145
356
|
d.extend(M);
|
|
146
357
|
d.extend(w);
|
|
147
|
-
class p extends
|
|
358
|
+
class p extends _ {
|
|
148
359
|
/**
|
|
149
360
|
* @ignore
|
|
150
361
|
*/
|
|
@@ -189,8 +400,7 @@ class p extends S {
|
|
|
189
400
|
col: t.col,
|
|
190
401
|
criteria: t.criteria
|
|
191
402
|
};
|
|
192
|
-
|
|
193
|
-
throw new Error("SetSheetsFilterCriteriaCommand canceled.");
|
|
403
|
+
this.fireEvent(this.Event.SheetRangeFiltered, n);
|
|
194
404
|
}
|
|
195
405
|
_beforeRangeFilterClear() {
|
|
196
406
|
const e = this.getActiveWorkbook();
|
|
@@ -209,11 +419,10 @@ class p extends S {
|
|
|
209
419
|
workbook: e,
|
|
210
420
|
worksheet: e.getActiveSheet()
|
|
211
421
|
};
|
|
212
|
-
|
|
213
|
-
throw new Error("SetSheetsFilterCriteriaCommand canceled.");
|
|
422
|
+
this.fireEvent(this.Event.SheetRangeFilterCleared, t);
|
|
214
423
|
}
|
|
215
424
|
}
|
|
216
|
-
|
|
425
|
+
_.extend(p);
|
|
217
426
|
export {
|
|
218
427
|
s as FFilter
|
|
219
428
|
};
|
|
@@ -7,53 +7,71 @@ import { FWorkbook, FWorksheet } from '@univerjs/sheets/facade';
|
|
|
7
7
|
export interface IFSheetFilterEventMixin {
|
|
8
8
|
/**
|
|
9
9
|
* This event will be emitted when the filter criteria on a column is changed.
|
|
10
|
-
*
|
|
10
|
+
* @see {@link ISheetRangeFilteredParams}
|
|
11
11
|
* @example
|
|
12
12
|
* ```typescript
|
|
13
13
|
* const callbackDisposable = univerAPI.addEvent(univerAPI.Event.SheetRangeFiltered, (params) => {
|
|
14
|
+
* console.log(params);
|
|
14
15
|
* const { workbook, worksheet, col, criteria } = params;
|
|
15
16
|
*
|
|
16
17
|
* // your custom logic
|
|
17
18
|
* });
|
|
19
|
+
*
|
|
20
|
+
* // Remove the event listener, use `callbackDisposable.dispose()`
|
|
18
21
|
* ```
|
|
19
22
|
*/
|
|
20
23
|
readonly SheetRangeFiltered: 'SheetRangeFiltered';
|
|
21
24
|
/**
|
|
22
25
|
* This event will be emitted before the filter criteria on a column is changed.
|
|
23
|
-
*
|
|
26
|
+
* @see {@link ISheetRangeFilteredParams}
|
|
24
27
|
* @example
|
|
25
28
|
* ```typescript
|
|
26
29
|
* const callbackDisposable = univerAPI.addEvent(univerAPI.Event.SheetBeforeRangeFilter, (params) => {
|
|
30
|
+
* console.log(params);
|
|
27
31
|
* const { workbook, worksheet, col, criteria } = params;
|
|
28
32
|
*
|
|
29
33
|
* // your custom logic
|
|
34
|
+
*
|
|
35
|
+
* // Cancel the filter criteria change operation
|
|
36
|
+
* params.cancel = true;
|
|
30
37
|
* });
|
|
38
|
+
*
|
|
39
|
+
* // Remove the event listener, use `callbackDisposable.dispose()`
|
|
31
40
|
* ```
|
|
32
41
|
*/
|
|
33
42
|
readonly SheetBeforeRangeFilter: 'SheetBeforeRangeFilter';
|
|
34
43
|
/**
|
|
35
44
|
* This event will be emitted when the filter on a worksheet is cleared.
|
|
36
|
-
*
|
|
45
|
+
* @see {@link ISheetRangeFilterClearedEventParams}
|
|
37
46
|
* @example
|
|
38
47
|
* ```typescript
|
|
39
48
|
* const callbackDisposable = univerAPI.addEvent(univerAPI.Event.SheetRangeFilterCleared, (params) => {
|
|
49
|
+
* console.log(params);
|
|
40
50
|
* const { workbook, worksheet } = params;
|
|
41
51
|
*
|
|
42
52
|
* // your custom logic
|
|
43
53
|
* });
|
|
54
|
+
*
|
|
55
|
+
* // Remove the event listener, use `callbackDisposable.dispose()`
|
|
44
56
|
* ```
|
|
45
57
|
*/
|
|
46
58
|
readonly SheetRangeFilterCleared: 'SheetRangeFilterCleared';
|
|
47
59
|
/**
|
|
48
60
|
* This event will be emitted after the filter on a worksheet is cleared.
|
|
49
|
-
*
|
|
61
|
+
* @see {@link ISheetRangeFilterClearedEventParams}
|
|
50
62
|
* @example
|
|
51
63
|
* ```typescript
|
|
52
64
|
* const callbackDisposable = univerAPI.addEvent(univerAPI.Event.SheetBeforeRangeFilterClear, (params) => {
|
|
65
|
+
* console.log(params);
|
|
53
66
|
* const { workbook, worksheet } = params;
|
|
54
67
|
*
|
|
55
68
|
* // your custom logic
|
|
69
|
+
*
|
|
70
|
+
* // Cancel the filter clear operation
|
|
71
|
+
* params.cancel = true;
|
|
56
72
|
* });
|
|
73
|
+
*
|
|
74
|
+
* // Remove the event listener, use `callbackDisposable.dispose()`
|
|
57
75
|
* ```
|
|
58
76
|
*/
|
|
59
77
|
readonly SheetBeforeRangeFilterClear: 'SheetBeforeRangeFilterClear';
|
|
@@ -15,40 +15,251 @@ export declare class FFilter {
|
|
|
15
15
|
/**
|
|
16
16
|
* Get the filtered out rows by this filter.
|
|
17
17
|
* @returns {number[]} Filtered out rows by this filter.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
21
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
22
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
23
|
+
* fRange.setValues([
|
|
24
|
+
* [1, 2, 3, 4],
|
|
25
|
+
* [2, 3, 4, 5],
|
|
26
|
+
* [3, 4, 5, 6],
|
|
27
|
+
* [4, 5, 6, 7],
|
|
28
|
+
* [5, 6, 7, 8],
|
|
29
|
+
* [6, 7, 8, 9],
|
|
30
|
+
* [7, 8, 9, 10],
|
|
31
|
+
* [8, 9, 10, 11],
|
|
32
|
+
* [9, 10, 11, 12],
|
|
33
|
+
* [10, 11, 12, 13],
|
|
34
|
+
* ]);
|
|
35
|
+
*
|
|
36
|
+
* // Create a filter on the range
|
|
37
|
+
* let fFilter = fRange.createFilter();
|
|
38
|
+
*
|
|
39
|
+
* // If the filter already exists, remove it and create a new one
|
|
40
|
+
* if (!fFilter) {
|
|
41
|
+
* fRange.getFilter().remove();
|
|
42
|
+
* fFilter = fRange.createFilter();
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* // Set the filter criteria of the column A
|
|
46
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
47
|
+
* colId: 0,
|
|
48
|
+
* filters: {
|
|
49
|
+
* filters: ['1', '5', '9'],
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* console.log(fFilter?.getFilteredOutRows()); // [1, 2, 3, 5, 6, 7, 9]
|
|
54
|
+
* ```
|
|
18
55
|
*/
|
|
19
56
|
getFilteredOutRows(): number[];
|
|
20
57
|
/**
|
|
21
58
|
* Get the filter criteria of a column.
|
|
22
|
-
* @param {number}
|
|
59
|
+
* @param {number} column - The column index.
|
|
23
60
|
* @returns {Nullable<IFilterColumn>} The filter criteria of the column.
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
64
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
65
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
66
|
+
* fRange.setValues([
|
|
67
|
+
* [1, 2, 3, 4],
|
|
68
|
+
* [2, 3, 4, 5],
|
|
69
|
+
* [3, 4, 5, 6],
|
|
70
|
+
* [4, 5, 6, 7],
|
|
71
|
+
* [5, 6, 7, 8],
|
|
72
|
+
* [6, 7, 8, 9],
|
|
73
|
+
* [7, 8, 9, 10],
|
|
74
|
+
* [8, 9, 10, 11],
|
|
75
|
+
* [9, 10, 11, 12],
|
|
76
|
+
* [10, 11, 12, 13],
|
|
77
|
+
* ]);
|
|
78
|
+
*
|
|
79
|
+
* // Create a filter on the range
|
|
80
|
+
* let fFilter = fRange.createFilter();
|
|
81
|
+
*
|
|
82
|
+
* // If the filter already exists, remove it and create a new one
|
|
83
|
+
* if (!fFilter) {
|
|
84
|
+
* fRange.getFilter().remove();
|
|
85
|
+
* fFilter = fRange.createFilter();
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* // Set the filter criteria of the column A
|
|
89
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
90
|
+
* colId: 0,
|
|
91
|
+
* filters: {
|
|
92
|
+
* filters: ['1', '5', '9'],
|
|
93
|
+
* },
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* console.log(fFilter?.getColumnFilterCriteria(0)); // { colId: 0, filters: { filters: ['1', '5', '9'] } }
|
|
97
|
+
* console.log(fFilter?.getColumnFilterCriteria(1)); // undefined
|
|
98
|
+
* ```
|
|
24
99
|
*/
|
|
25
|
-
getColumnFilterCriteria(
|
|
100
|
+
getColumnFilterCriteria(column: number): Nullable<IFilterColumn>;
|
|
26
101
|
/**
|
|
27
102
|
* Clear the filter criteria of a column.
|
|
28
|
-
* @param {number}
|
|
29
|
-
* @returns {FFilter} The
|
|
103
|
+
* @param {number} column - The column index.
|
|
104
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
108
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
109
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
110
|
+
* fRange.setValues([
|
|
111
|
+
* [1, 2, 3, 4],
|
|
112
|
+
* [2, 3, 4, 5],
|
|
113
|
+
* [3, 4, 5, 6],
|
|
114
|
+
* [4, 5, 6, 7],
|
|
115
|
+
* [5, 6, 7, 8],
|
|
116
|
+
* [6, 7, 8, 9],
|
|
117
|
+
* [7, 8, 9, 10],
|
|
118
|
+
* [8, 9, 10, 11],
|
|
119
|
+
* [9, 10, 11, 12],
|
|
120
|
+
* [10, 11, 12, 13],
|
|
121
|
+
* ]);
|
|
122
|
+
*
|
|
123
|
+
* // Create a filter on the range
|
|
124
|
+
* let fFilter = fRange.createFilter();
|
|
125
|
+
*
|
|
126
|
+
* // If the filter already exists, remove it and create a new one
|
|
127
|
+
* if (!fFilter) {
|
|
128
|
+
* fRange.getFilter().remove();
|
|
129
|
+
* fFilter = fRange.createFilter();
|
|
130
|
+
* }
|
|
131
|
+
*
|
|
132
|
+
* // Set the filter criteria of the column A
|
|
133
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
134
|
+
* colId: 0,
|
|
135
|
+
* filters: {
|
|
136
|
+
* filters: ['1', '5', '9'],
|
|
137
|
+
* },
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* // Clear the filter criteria of the column A after 3 seconds
|
|
141
|
+
* setTimeout(() => {
|
|
142
|
+
* fFilter?.removeColumnFilterCriteria(0);
|
|
143
|
+
* }, 3000);
|
|
144
|
+
* ```
|
|
30
145
|
*/
|
|
31
|
-
removeColumnFilterCriteria(
|
|
146
|
+
removeColumnFilterCriteria(column: number): FFilter;
|
|
32
147
|
/**
|
|
33
148
|
* Set the filter criteria of a column.
|
|
34
|
-
* @param {number}
|
|
35
|
-
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria The new filter criteria.
|
|
36
|
-
* @returns {FFilter} The
|
|
149
|
+
* @param {number} column - The column index.
|
|
150
|
+
* @param {ISetSheetsFilterCriteriaCommandParams['criteria']} criteria - The new filter criteria.
|
|
151
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
155
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
156
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
157
|
+
* fRange.setValues([
|
|
158
|
+
* [1, 2, 3, 4],
|
|
159
|
+
* [2, 3, 4, 5],
|
|
160
|
+
* [3, 4, 5, 6],
|
|
161
|
+
* [4, 5, 6, 7],
|
|
162
|
+
* [5, 6, 7, 8],
|
|
163
|
+
* [6, 7, 8, 9],
|
|
164
|
+
* [7, 8, 9, 10],
|
|
165
|
+
* [8, 9, 10, 11],
|
|
166
|
+
* [9, 10, 11, 12],
|
|
167
|
+
* [10, 11, 12, 13],
|
|
168
|
+
* ]);
|
|
169
|
+
*
|
|
170
|
+
* // Create a filter on the range
|
|
171
|
+
* let fFilter = fRange.createFilter();
|
|
172
|
+
*
|
|
173
|
+
* // If the filter already exists, remove it and create a new one
|
|
174
|
+
* if (!fFilter) {
|
|
175
|
+
* fRange.getFilter().remove();
|
|
176
|
+
* fFilter = fRange.createFilter();
|
|
177
|
+
* }
|
|
178
|
+
*
|
|
179
|
+
* // Set the filter criteria of the column A
|
|
180
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
181
|
+
* colId: 0,
|
|
182
|
+
* filters: {
|
|
183
|
+
* filters: ['1', '5', '9'],
|
|
184
|
+
* },
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
37
187
|
*/
|
|
38
|
-
setColumnFilterCriteria(
|
|
188
|
+
setColumnFilterCriteria(column: number, criteria: ISetSheetsFilterCriteriaCommandParams['criteria']): FFilter;
|
|
39
189
|
/**
|
|
40
190
|
* Get the range of the filter.
|
|
41
191
|
* @returns {FRange} The range of the filter.
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
195
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
196
|
+
* const fFilter = fWorksheet.getFilter();
|
|
197
|
+
* console.log(fFilter?.getRange().getA1Notation());
|
|
198
|
+
* ```
|
|
42
199
|
*/
|
|
43
200
|
getRange(): FRange;
|
|
44
201
|
/**
|
|
45
202
|
* Remove the filter criteria of all columns.
|
|
46
|
-
* @returns {
|
|
203
|
+
* @returns {FFilter} The FFilter instance for chaining.
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
207
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
208
|
+
* const fRange = fWorksheet.getRange('A1:D10');
|
|
209
|
+
* fRange.setValues([
|
|
210
|
+
* [1, 2, 3, 4],
|
|
211
|
+
* [2, 3, 4, 5],
|
|
212
|
+
* [3, 4, 5, 6],
|
|
213
|
+
* [4, 5, 6, 7],
|
|
214
|
+
* [5, 6, 7, 8],
|
|
215
|
+
* [6, 7, 8, 9],
|
|
216
|
+
* [7, 8, 9, 10],
|
|
217
|
+
* [8, 9, 10, 11],
|
|
218
|
+
* [9, 10, 11, 12],
|
|
219
|
+
* [10, 11, 12, 13],
|
|
220
|
+
* ]);
|
|
221
|
+
*
|
|
222
|
+
* // Create a filter on the range
|
|
223
|
+
* let fFilter = fRange.createFilter();
|
|
224
|
+
*
|
|
225
|
+
* // If the filter already exists, remove it and create a new one
|
|
226
|
+
* if (!fFilter) {
|
|
227
|
+
* fRange.getFilter().remove();
|
|
228
|
+
* fFilter = fRange.createFilter();
|
|
229
|
+
* }
|
|
230
|
+
*
|
|
231
|
+
* // Set the filter criteria of the column A
|
|
232
|
+
* fFilter?.setColumnFilterCriteria(0, {
|
|
233
|
+
* colId: 0,
|
|
234
|
+
* filters: {
|
|
235
|
+
* filters: ['1', '5', '9'],
|
|
236
|
+
* },
|
|
237
|
+
* });
|
|
238
|
+
*
|
|
239
|
+
* // Clear the filter criteria of all columns after 3 seconds
|
|
240
|
+
* setTimeout(() => {
|
|
241
|
+
* fFilter?.removeFilterCriteria();
|
|
242
|
+
* }, 3000);
|
|
243
|
+
* ```
|
|
47
244
|
*/
|
|
48
245
|
removeFilterCriteria(): FFilter;
|
|
49
246
|
/**
|
|
50
247
|
* Remove the filter from the worksheet.
|
|
51
|
-
* @returns {boolean}
|
|
248
|
+
* @returns {boolean} True if the filter is removed successfully; otherwise, false.
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
252
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
253
|
+
* const fRange = fWorksheet.getRange('A1:D14');
|
|
254
|
+
* let fFilter = fRange.createFilter();
|
|
255
|
+
*
|
|
256
|
+
* // If the worksheet already has a filter, remove it and create a new filter.
|
|
257
|
+
* if (!fFilter) {
|
|
258
|
+
* fWorksheet.getFilter().remove();
|
|
259
|
+
* fFilter = fRange.createFilter();
|
|
260
|
+
* }
|
|
261
|
+
* console.log(fFilter);
|
|
262
|
+
* ```
|
|
52
263
|
*/
|
|
53
264
|
remove(): boolean;
|
|
54
265
|
}
|
|
@@ -6,26 +6,40 @@ import { FFilter } from './f-filter';
|
|
|
6
6
|
export interface IFRangeFilter {
|
|
7
7
|
/**
|
|
8
8
|
* Create a filter for the current range. If the worksheet already has a filter, this method would return `null`.
|
|
9
|
-
* @returns The
|
|
10
|
-
* this method would return `null`.
|
|
9
|
+
* @returns {FFilter | null} The FFilter instance to handle the filter.
|
|
11
10
|
* @example
|
|
12
11
|
* ```typescript
|
|
13
|
-
* const
|
|
14
|
-
* const
|
|
15
|
-
* const
|
|
12
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
13
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
14
|
+
* const fRange = fWorksheet.getRange('A1:D14');
|
|
15
|
+
* let fFilter = fRange.createFilter();
|
|
16
|
+
*
|
|
17
|
+
* // If the worksheet already has a filter, remove it and create a new filter.
|
|
18
|
+
* if (!fFilter) {
|
|
19
|
+
* fWorksheet.getFilter().remove();
|
|
20
|
+
* fFilter = fRange.createFilter();
|
|
21
|
+
* }
|
|
22
|
+
* console.log(fFilter);
|
|
16
23
|
* ```
|
|
17
24
|
*/
|
|
18
25
|
createFilter(this: FRange): FFilter | null;
|
|
19
26
|
/**
|
|
20
|
-
* Get the filter
|
|
21
|
-
*
|
|
22
|
-
*
|
|
27
|
+
* Get the filter in the worksheet to which the range belongs. If the worksheet does not have a filter, this method would return `null`.
|
|
28
|
+
* Normally, you can directly call `getFilter` on {@link FWorksheet}.
|
|
29
|
+
* @returns {FFilter | null} The FFilter instance to handle the filter.
|
|
23
30
|
* @example
|
|
24
31
|
* ```typescript
|
|
25
|
-
* const
|
|
26
|
-
* const
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
32
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
33
|
+
* const fWorksheet = fWorkbook.getActiveSheet();
|
|
34
|
+
* const fRange = fWorksheet.getRange('A1:D14');
|
|
35
|
+
* let fFilter = fRange.getFilter();
|
|
36
|
+
*
|
|
37
|
+
* // If the worksheet does not have a filter, create a new filter.
|
|
38
|
+
* if (!fFilter) {
|
|
39
|
+
* fFilter = fRange.createFilter();
|
|
40
|
+
* }
|
|
41
|
+
* console.log(fFilter);
|
|
42
|
+
* ```
|
|
29
43
|
*/
|
|
30
44
|
getFilter(): FFilter | null;
|
|
31
45
|
}
|
|
@@ -13,7 +13,8 @@ export interface IFWorksheetFilter {
|
|
|
13
13
|
* const workbook = univerAPI.getActiveWorkbook();
|
|
14
14
|
* const worksheet = workbook.getActiveSheet();
|
|
15
15
|
* const filter = worksheet.getFilter();
|
|
16
|
-
*
|
|
16
|
+
* console.log(filter, filter?.getRange().getA1Notation());
|
|
17
|
+
* ```
|
|
17
18
|
*/
|
|
18
19
|
getFilter(): FFilter | null;
|
|
19
20
|
}
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/sheets/facade","@univerjs/core/facade"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverSheetsFilterFacade={},i.UniverCore,i.UniverSheetsFilter,i.UniverSheetsFacade,i.UniverCoreFacade))})(this,function(i,a,n,h,l){"use strict";var
|
|
1
|
+
(function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/sheets/facade"),require("@univerjs/core/facade")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/sheets/facade","@univerjs/core/facade"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverSheetsFilterFacade={},i.UniverCore,i.UniverSheetsFilter,i.UniverSheetsFacade,i.UniverCoreFacade))})(this,function(i,a,n,h,l){"use strict";var m=Object.getOwnPropertyDescriptor,F=(s,e,t,r)=>{for(var o=r>1?void 0:r?m(e,t):e,d=s.length-1,u;d>=0;d--)(u=s[d])&&(o=u(o)||o);return o},c=(s,e)=>(t,r)=>e(t,r,s);i.FFilter=class{constructor(e,t,r,o,d){this._workbook=e,this._worksheet=t,this._filterModel=r,this._injector=o,this._commandSrv=d}getFilteredOutRows(){return Array.from(this._filterModel.filteredOutRows).sort()}getColumnFilterCriteria(e){var t;return(t=this._filterModel.getFilterColumn(e))==null?void 0:t.getColumnData()}removeColumnFilterCriteria(e){return this._commandSrv.syncExecuteCommand(n.SetSheetsFilterCriteriaCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),col:e,criteria:null}),this}setColumnFilterCriteria(e,t){return this._commandSrv.syncExecuteCommand(n.SetSheetsFilterCriteriaCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),col:e,criteria:t}),this}getRange(){const e=this._filterModel.getRange();return this._injector.createInstance(h.FRange,this._workbook,this._worksheet,e)}removeFilterCriteria(){return this._commandSrv.syncExecuteCommand(n.ClearSheetsFilterCriteriaCommand.id),this}remove(){return this._commandSrv.syncExecuteCommand(n.RemoveSheetFilterCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId()})}},i.FFilter=F([c(3,a.Inject(a.Injector)),c(4,a.ICommandService)],i.FFilter);class g extends h.FRange{createFilter(){return this._getFilterModel()||!this._commandService.syncExecuteCommand(n.SetSheetFilterRangeCommand.id,{unitId:this._workbook.getUnitId(),subUnitId:this._worksheet.getSheetId(),range:this._range})?null:this.getFilter()}getFilter(){const e=this._getFilterModel();return e?this._injector.createInstance(i.FFilter,this._workbook,this._worksheet,e):null}_getFilterModel(){return this._injector.get(n.SheetsFilterService).getFilterModel(this._workbook.getUnitId(),this._worksheet.getSheetId())}}h.FRange.extend(g);class v extends h.FWorksheet{getFilter(){const e=this._getFilterModel();return e?this._injector.createInstance(i.FFilter,this._workbook,this._worksheet,e):null}_getFilterModel(){return this._injector.get(n.SheetsFilterService).getFilterModel(this._workbook.getUnitId(),this._worksheet.getSheetId())}}h.FWorksheet.extend(v);class S{get CustomFilterOperator(){return n.CustomFilterOperator}}l.FEnum.extend(S);class C extends l.FEventName{get SheetBeforeRangeFilter(){return"SheetBeforeRangeFilter"}get SheetRangeFiltered(){return"SheetRangeFiltered"}get SheetRangeFilterCleared(){return"SheetRangeFilterCleared"}get SheetBeforeRangeFilterClear(){return"SheetBeforeRangeFilterClear"}}l.FEventName.extend(C),l.FEventName.extend(h.FSheetEventName);class _ extends l.FUniver{_initialize(e){const t=e.get(a.ICommandService);this.registerEventHandler(this.Event.SheetBeforeRangeFilter,()=>t.beforeCommandExecuted(r=>{r.id===n.SetSheetsFilterCriteriaCommand.id&&this._beforeRangeFilter(r)})),this.registerEventHandler(this.Event.SheetBeforeRangeFilterClear,()=>t.beforeCommandExecuted(r=>{r.id===n.ClearSheetsFilterCriteriaCommand.id&&this._beforeRangeFilterClear()})),this.registerEventHandler(this.Event.SheetRangeFiltered,()=>t.onCommandExecuted(r=>{r.id===n.SetSheetsFilterCriteriaCommand.id&&this._onRangeFiltered(r)})),this.registerEventHandler(this.Event.SheetRangeFilterCleared,()=>t.onCommandExecuted(r=>{r.id===n.ClearSheetsFilterCriteriaCommand.id&&this._onRangeFilterCleared()}))}_beforeRangeFilter(e){const t=e.params,r=this.getUniverSheet(t.unitId),o={workbook:r,worksheet:r.getSheetBySheetId(t.subUnitId),col:t.col,criteria:t.criteria};if(this.fireEvent(this.Event.SheetBeforeRangeFilter,o),o.cancel)throw new Error("SetSheetsFilterCriteriaCommand canceled.")}_onRangeFiltered(e){const t=e.params,r=this.getUniverSheet(t.unitId),o={workbook:r,worksheet:r.getSheetBySheetId(t.subUnitId),col:t.col,criteria:t.criteria};this.fireEvent(this.Event.SheetRangeFiltered,o)}_beforeRangeFilterClear(){const e=this.getActiveWorkbook();if(!e)return;const t={workbook:e,worksheet:e.getActiveSheet()};if(this.fireEvent(this.Event.SheetBeforeRangeFilterClear,t),t.cancel)throw new Error("SetSheetsFilterCriteriaCommand canceled.")}_onRangeFilterCleared(){const e=this.getActiveWorkbook();if(!e)return;const t={workbook:e,worksheet:e.getActiveSheet()};this.fireEvent(this.Event.SheetRangeFilterCleared,t)}}l.FUniver.extend(_),Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-filter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1-nightly.202502221605",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library for filtering data in Univer Sheet",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"rxjs": ">=7.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@univerjs/core": "0.6.
|
|
55
|
-
"@univerjs/sheets": "0.6.
|
|
54
|
+
"@univerjs/core": "0.6.1-nightly.202502221605",
|
|
55
|
+
"@univerjs/sheets": "0.6.1-nightly.202502221605"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"rxjs": "^7.8.1",
|
|
59
59
|
"typescript": "^5.7.3",
|
|
60
|
-
"vite": "^6.1.
|
|
61
|
-
"vitest": "^3.0.
|
|
62
|
-
"@univerjs-infra/shared": "0.6.
|
|
60
|
+
"vite": "^6.1.1",
|
|
61
|
+
"vitest": "^3.0.6",
|
|
62
|
+
"@univerjs-infra/shared": "0.6.1"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
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
|