@univerjs/sheets-filter 0.10.6-experimental.20250904-9591d16 → 0.10.6-nightly.202509060614
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +747 -679
- package/lib/index.js +747 -679
- package/lib/types/controllers/config.schema.d.ts +6 -0
- package/lib/types/controllers/sheets-filter-sync.controller.d.ts +17 -0
- package/lib/types/controllers/sheets-filter.controller.d.ts +16 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
package/lib/es/index.js
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isNumeric as
|
|
5
|
-
import { getSheetCommandTarget as
|
|
6
|
-
import { BehaviorSubject as
|
|
7
|
-
import { COLOR_BLACK_RGB as
|
|
8
|
-
import { DataSyncPrimaryController as
|
|
9
|
-
import { IActiveDirtyManagerService as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var be = Object.defineProperty;
|
|
2
|
+
var $e = (i, t, e) => t in i ? be(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var C = (i, t, e) => $e(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { isNumeric as Le, Disposable as U, Rectangle as ee, mergeSets as Z, Tools as ie, extractPureTextFromCell as Ue, CellValueType as te, ColorKit as se, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as N, ICommandService as T, IUndoRedoService as Q, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as me, moveMatrixArray as oe, IConfigService as ge, Plugin as Ve, merge as We, touchDependencies as je, Injector as ke } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as H, SheetsSelectionsService as qe, isSingleCellSelection as Ge, expandToContinuousRange as _e, SheetInterceptorService as Qe, RefRangeService as Je, ZebraCrossingCacheController as Ze, SetWorksheetActiveOperation as Ke, CopySheetCommand as Ye, RemoveSheetCommand as Xe, INTERCEPTOR_POINT as et, RemoveRowMutation as tt, InsertRowMutation as rt, SetRangeValuesMutation as nt, MoveRowsCommand as it, MoveRangeCommand as st, EffectRefRangId as le, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Ce, RemoveColMutation as Re, MoveColsMutation as pe } from "@univerjs/sheets";
|
|
6
|
+
import { BehaviorSubject as $, merge as dt, filter as ut, switchMap as ht, of as ft } from "rxjs";
|
|
7
|
+
import { COLOR_BLACK_RGB as mt } from "@univerjs/engine-render";
|
|
8
|
+
import { DataSyncPrimaryController as gt } from "@univerjs/rpc";
|
|
9
|
+
import { IActiveDirtyManagerService as _t, ISheetRowFilteredService as Ct } from "@univerjs/engine-formula";
|
|
10
|
+
const Se = "sheet.mutation.set-filter-range", Fe = "sheet.mutation.set-filter-criteria", we = "sheet.mutation.remove-filter", ve = "sheet.mutation.re-calc-filter", Me = /* @__PURE__ */ new Set([
|
|
11
|
+
Se,
|
|
12
|
+
Fe,
|
|
13
|
+
we,
|
|
14
|
+
ve
|
|
15
15
|
]);
|
|
16
16
|
var b = /* @__PURE__ */ ((i) => (i[i.VALUES = 0] = "VALUES", i[i.COLORS = 1] = "COLORS", i[i.CONDITIONS = 2] = "CONDITIONS", i))(b || {}), x = /* @__PURE__ */ ((i) => (i.EQUAL = "equal", i.GREATER_THAN = "greaterThan", i.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", i.LESS_THAN = "lessThan", i.LESS_THAN_OR_EQUAL = "lessThanOrEqual", i.NOT_EQUALS = "notEqual", i))(x || {});
|
|
17
|
-
const
|
|
17
|
+
const Rt = {
|
|
18
18
|
operator: x.GREATER_THAN,
|
|
19
|
-
fn: (i,
|
|
20
|
-
},
|
|
19
|
+
fn: (i, t) => P(i) ? i > t : !1
|
|
20
|
+
}, pt = {
|
|
21
21
|
operator: x.GREATER_THAN_OR_EQUAL,
|
|
22
|
-
fn: (i,
|
|
23
|
-
},
|
|
22
|
+
fn: (i, t) => P(i) ? i >= t : !1
|
|
23
|
+
}, St = {
|
|
24
24
|
operator: x.LESS_THAN,
|
|
25
|
-
fn: (i,
|
|
26
|
-
},
|
|
25
|
+
fn: (i, t) => P(i) ? i < t : !1
|
|
26
|
+
}, Ft = {
|
|
27
27
|
operator: x.LESS_THAN_OR_EQUAL,
|
|
28
|
-
fn: (i,
|
|
29
|
-
},
|
|
28
|
+
fn: (i, t) => P(i) ? i <= t : !1
|
|
29
|
+
}, wt = {
|
|
30
30
|
operator: x.EQUAL,
|
|
31
|
-
fn: (i,
|
|
32
|
-
},
|
|
31
|
+
fn: (i, t) => P(i) ? i === t : !1
|
|
32
|
+
}, Ee = {
|
|
33
33
|
operator: x.NOT_EQUALS,
|
|
34
|
-
fn: (i,
|
|
35
|
-
if (typeof
|
|
36
|
-
if (
|
|
34
|
+
fn: (i, t) => {
|
|
35
|
+
if (typeof t == "string") {
|
|
36
|
+
if (t === " ")
|
|
37
37
|
return i != null;
|
|
38
|
-
const e =
|
|
39
|
-
return e &&
|
|
38
|
+
const e = ye(i);
|
|
39
|
+
return e && Ot(t) ? !Ae(t).test(e) : e !== t;
|
|
40
40
|
}
|
|
41
|
-
return
|
|
41
|
+
return P(i) ? i !== t : !0;
|
|
42
42
|
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
}, Oe = /* @__PURE__ */ new Map([]), vt = [Rt, pt, St, Ft, wt, Ee];
|
|
44
|
+
vt.forEach((i) => {
|
|
45
|
+
Oe.set(i.operator, i);
|
|
46
46
|
});
|
|
47
|
-
function
|
|
47
|
+
function Mt(i) {
|
|
48
48
|
return !!i;
|
|
49
49
|
}
|
|
50
|
-
const
|
|
51
|
-
fn: (i,
|
|
52
|
-
const e =
|
|
53
|
-
return e === null ?
|
|
50
|
+
const Et = {
|
|
51
|
+
fn: (i, t) => {
|
|
52
|
+
const e = ye(i);
|
|
53
|
+
return e === null ? t === "" : Ae(t).test(e);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
function
|
|
57
|
-
return i ?
|
|
56
|
+
function ae(i) {
|
|
57
|
+
return i ? Oe.get(i) : Et;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function P(i) {
|
|
60
60
|
return typeof i == "number";
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return !!(typeof i == "number" || typeof i == "string" &&
|
|
62
|
+
function ce(i) {
|
|
63
|
+
return !!(typeof i == "number" || typeof i == "string" && Le(i));
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function ye(i) {
|
|
66
66
|
return typeof i == "boolean" || i == null ? null : typeof i == "string" ? i : i.toString();
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Ot(i) {
|
|
69
69
|
return typeof i == "number" ? !1 : i.indexOf("*") !== -1 || i.indexOf("?") !== -1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
return new RegExp(`^${
|
|
71
|
+
function Ae(i) {
|
|
72
|
+
const t = i.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
|
|
73
|
+
return new RegExp(`^${t}$`);
|
|
74
74
|
}
|
|
75
|
-
const
|
|
76
|
-
class
|
|
77
|
-
constructor(e,
|
|
75
|
+
const K = () => /* @__PURE__ */ new Set();
|
|
76
|
+
class k extends U {
|
|
77
|
+
constructor(e, r, n) {
|
|
78
78
|
super();
|
|
79
|
-
|
|
79
|
+
C(this, "_filteredOutRows$", new $(K()));
|
|
80
80
|
/** An observable value. A set of filtered out rows. */
|
|
81
|
-
|
|
81
|
+
C(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
|
|
82
82
|
// TODO: we may need to update which cols have criteria rather than simple boolean
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.unitId = e, this.subUnitId =
|
|
83
|
+
C(this, "_hasCriteria$", new $(!1));
|
|
84
|
+
C(this, "hasCriteria$", this._hasCriteria$.asObservable());
|
|
85
|
+
C(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
|
|
86
|
+
C(this, "_alreadyFilteredOutRows", K());
|
|
87
|
+
C(this, "_range");
|
|
88
|
+
this.unitId = e, this.subUnitId = r, this._worksheet = n;
|
|
89
89
|
}
|
|
90
90
|
get filteredOutRows() {
|
|
91
91
|
return this._filteredOutRows$.getValue();
|
|
@@ -101,8 +101,8 @@ class j extends B {
|
|
|
101
101
|
*/
|
|
102
102
|
serialize() {
|
|
103
103
|
const e = {
|
|
104
|
-
ref:
|
|
105
|
-
filterColumns: this._getAllFilterColumns(!0).sort(([
|
|
104
|
+
ref: ee.clone(this._range),
|
|
105
|
+
filterColumns: this._getAllFilterColumns(!0).sort(([r], [n]) => r - n).map(([r, n]) => n.serialize())
|
|
106
106
|
};
|
|
107
107
|
return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
|
|
108
108
|
}
|
|
@@ -113,13 +113,13 @@ class j extends B {
|
|
|
113
113
|
* @param worksheet the Worksheet object
|
|
114
114
|
* @param autoFilter auto filter data
|
|
115
115
|
*/
|
|
116
|
-
static deserialize(e,
|
|
117
|
-
const o = new
|
|
116
|
+
static deserialize(e, r, n, s) {
|
|
117
|
+
const o = new k(e, r, n);
|
|
118
118
|
return o._dump(s), o;
|
|
119
119
|
}
|
|
120
120
|
_dump(e) {
|
|
121
|
-
var
|
|
122
|
-
this.setRange(e.ref), (
|
|
121
|
+
var r;
|
|
122
|
+
this.setRange(e.ref), (r = e.filterColumns) == null || r.forEach((n) => this._setCriteriaWithoutReCalc(n.colId, n)), e.cachedFilteredOut && (this._alreadyFilteredOutRows = new Set(e.cachedFilteredOut), this._emit()), this._emitHasCriteria();
|
|
123
123
|
}
|
|
124
124
|
isRowFiltered(e) {
|
|
125
125
|
return this._alreadyFilteredOutRows.has(e);
|
|
@@ -135,9 +135,9 @@ class j extends B {
|
|
|
135
135
|
* @param col
|
|
136
136
|
*/
|
|
137
137
|
getFilteredOutRowsExceptCol(e) {
|
|
138
|
-
return this._getAllFilterColumns(!0).filter(([
|
|
139
|
-
const s = n.calc({ getAlreadyFilteredOutRows: () =>
|
|
140
|
-
return s ?
|
|
138
|
+
return this._getAllFilterColumns(!0).filter(([r]) => r !== e).reduce((r, [, n]) => {
|
|
139
|
+
const s = n.calc({ getAlreadyFilteredOutRows: () => r });
|
|
140
|
+
return s ? Z(r, s) : r;
|
|
141
141
|
}, /* @__PURE__ */ new Set());
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
@@ -145,45 +145,45 @@ class j extends B {
|
|
|
145
145
|
* if the new range not overlaps the old range.
|
|
146
146
|
*/
|
|
147
147
|
setRange(e) {
|
|
148
|
-
this._range = e, this._getAllFilterColumns(!0).forEach(([
|
|
148
|
+
this._range = e, this._getAllFilterColumns(!0).forEach(([r, n]) => {
|
|
149
149
|
n.setRangeAndColumn({
|
|
150
150
|
startRow: e.startRow,
|
|
151
151
|
endRow: e.endRow,
|
|
152
|
-
startColumn:
|
|
153
|
-
endColumn:
|
|
154
|
-
},
|
|
152
|
+
startColumn: r,
|
|
153
|
+
endColumn: r
|
|
154
|
+
}, r);
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Set or remove filter criteria on a specific row.
|
|
159
159
|
*/
|
|
160
|
-
setCriteria(e,
|
|
160
|
+
setCriteria(e, r, n = !1) {
|
|
161
161
|
if (!this._range)
|
|
162
162
|
throw new Error("[FilterModel] could not set criteria before a range is set!");
|
|
163
|
-
if (!
|
|
163
|
+
if (!r) {
|
|
164
164
|
this._removeCriteria(e), this._rebuildAlreadyFilteredOutRowsWithCache(), n && this._reCalcAllColumns(), this._emit(), this._emitHasCriteria();
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
-
this._setCriteriaWithoutReCalc(e,
|
|
167
|
+
this._setCriteriaWithoutReCalc(e, r), n && (this._rebuildAlreadyFilteredOutRowsWithCache(), this._reCalcWithNoCacheColumns(), this._emit(), this._emitHasCriteria());
|
|
168
168
|
}
|
|
169
169
|
getAllFilterColumns() {
|
|
170
170
|
return this._getAllFilterColumns(!0);
|
|
171
171
|
}
|
|
172
172
|
getFilterColumn(e) {
|
|
173
|
-
var
|
|
174
|
-
return (
|
|
173
|
+
var r;
|
|
174
|
+
return (r = this._filterColumnByIndex.get(e)) != null ? r : null;
|
|
175
175
|
}
|
|
176
176
|
reCalc() {
|
|
177
177
|
this._reCalcAllColumns(), this._emit();
|
|
178
178
|
}
|
|
179
179
|
_getAllFilterColumns(e = !1) {
|
|
180
|
-
const
|
|
181
|
-
return e ?
|
|
180
|
+
const r = Array.from(this._filterColumnByIndex.entries());
|
|
181
|
+
return e ? r : r.map(([n, s]) => s);
|
|
182
182
|
}
|
|
183
183
|
_reCalcAllColumns() {
|
|
184
|
-
this._alreadyFilteredOutRows =
|
|
184
|
+
this._alreadyFilteredOutRows = K(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
|
|
185
185
|
}
|
|
186
|
-
_setCriteriaWithoutReCalc(e,
|
|
186
|
+
_setCriteriaWithoutReCalc(e, r) {
|
|
187
187
|
const n = this._range;
|
|
188
188
|
if (!n)
|
|
189
189
|
throw new Error("[FilterModel] could not set criteria before a range is set!");
|
|
@@ -191,17 +191,17 @@ class j extends B {
|
|
|
191
191
|
if (e > o || e < s)
|
|
192
192
|
throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
|
|
193
193
|
let l;
|
|
194
|
-
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new
|
|
194
|
+
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new yt(
|
|
195
195
|
this.unitId,
|
|
196
196
|
this.subUnitId,
|
|
197
197
|
this._worksheet,
|
|
198
|
-
|
|
198
|
+
r,
|
|
199
199
|
{ getAlreadyFilteredOutRows: () => this._alreadyFilteredOutRows }
|
|
200
|
-
), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(
|
|
200
|
+
), l.setRangeAndColumn(n, e), this._filterColumnByIndex.set(e, l)), l.setCriteria(r);
|
|
201
201
|
}
|
|
202
202
|
_removeCriteria(e) {
|
|
203
|
-
const
|
|
204
|
-
|
|
203
|
+
const r = this._filterColumnByIndex.get(e);
|
|
204
|
+
r && (r.dispose(), this._filterColumnByIndex.delete(e));
|
|
205
205
|
}
|
|
206
206
|
_emit() {
|
|
207
207
|
this._filteredOutRows$.next(this._alreadyFilteredOutRows);
|
|
@@ -210,27 +210,27 @@ class j extends B {
|
|
|
210
210
|
this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
|
|
211
211
|
}
|
|
212
212
|
_rebuildAlreadyFilteredOutRowsWithCache() {
|
|
213
|
-
const e = this._getAllFilterColumns().filter((
|
|
213
|
+
const e = this._getAllFilterColumns().filter((r) => r.hasCache()).reduce((r, n) => Z(r, n.filteredOutRows), /* @__PURE__ */ new Set());
|
|
214
214
|
this._alreadyFilteredOutRows = e;
|
|
215
215
|
}
|
|
216
216
|
_reCalcWithNoCacheColumns() {
|
|
217
|
-
const e = this._getAllFilterColumns().filter((
|
|
218
|
-
for (const
|
|
219
|
-
const n =
|
|
220
|
-
n && (this._alreadyFilteredOutRows =
|
|
217
|
+
const e = this._getAllFilterColumns().filter((r) => !r.hasCache());
|
|
218
|
+
for (const r of e) {
|
|
219
|
+
const n = r.reCalc();
|
|
220
|
+
n && (this._alreadyFilteredOutRows = Z(this._alreadyFilteredOutRows, n));
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
class
|
|
225
|
-
constructor(e,
|
|
224
|
+
class yt extends U {
|
|
225
|
+
constructor(e, r, n, s, o) {
|
|
226
226
|
super();
|
|
227
|
-
|
|
227
|
+
C(this, "_filteredOutRows", null);
|
|
228
228
|
/** Cache the filter function. */
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this.unitId = e, this.subUnitId =
|
|
229
|
+
C(this, "_filterFn", null);
|
|
230
|
+
C(this, "_range", null);
|
|
231
|
+
C(this, "_column", 0);
|
|
232
|
+
C(this, "_filterBy", b.VALUES);
|
|
233
|
+
this.unitId = e, this.subUnitId = r, this._worksheet = n, this._criteria = s, this._filterColumnContext = o;
|
|
234
234
|
}
|
|
235
235
|
get filteredOutRows() {
|
|
236
236
|
return this._filteredOutRows;
|
|
@@ -250,7 +250,7 @@ class wt extends B {
|
|
|
250
250
|
serialize() {
|
|
251
251
|
if (!this._criteria)
|
|
252
252
|
throw new Error("[FilterColumn]: could not serialize without a filter column!");
|
|
253
|
-
return
|
|
253
|
+
return ie.deepClone({
|
|
254
254
|
...this._criteria,
|
|
255
255
|
colId: this._column
|
|
256
256
|
});
|
|
@@ -259,14 +259,14 @@ class wt extends B {
|
|
|
259
259
|
return this._filteredOutRows !== null;
|
|
260
260
|
}
|
|
261
261
|
// The first row should be omitted!
|
|
262
|
-
setRangeAndColumn(e,
|
|
263
|
-
this._range = e, this._column =
|
|
262
|
+
setRangeAndColumn(e, r) {
|
|
263
|
+
this._range = e, this._column = r;
|
|
264
264
|
}
|
|
265
265
|
setCriteria(e) {
|
|
266
266
|
this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
|
|
267
267
|
}
|
|
268
268
|
getColumnData() {
|
|
269
|
-
return
|
|
269
|
+
return ie.deepClone(this._criteria);
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
272
272
|
* Trigger new calculation on this `FilterModel` instance.
|
|
@@ -284,115 +284,115 @@ class wt extends B {
|
|
|
284
284
|
throw new Error("[FilterColumn] cannot calculate without a range!");
|
|
285
285
|
if (typeof this._column != "number")
|
|
286
286
|
throw new TypeError("[FilterColumn] cannot calculate without a column offset!");
|
|
287
|
-
const
|
|
287
|
+
const r = this._column, n = { startColumn: r, endColumn: r, startRow: this._range.startRow + 1, endRow: this._range.endRow }, s = /* @__PURE__ */ new Set(), o = e.getAlreadyFilteredOutRows();
|
|
288
288
|
for (const l of this._worksheet.iterateByColumn(n, !1, !1)) {
|
|
289
|
-
const { row: a, rowSpan: c, col:
|
|
289
|
+
const { row: a, rowSpan: c, col: u } = l;
|
|
290
290
|
if (o.has(a) && (!c || c === 1))
|
|
291
291
|
continue;
|
|
292
|
-
if (!(this._filterBy === b.VALUES ? this._filterFn(
|
|
293
|
-
for (let
|
|
294
|
-
s.add(a +
|
|
292
|
+
if (!(this._filterBy === b.VALUES ? this._filterFn(Ue(this._worksheet.getCell(a, u))) : this._filterBy === b.COLORS ? this._filterFn(this._worksheet.getComposedCellStyle(a, u)) : this._filterFn(Ut(this._worksheet, a, u))) && (s.add(a), c))
|
|
293
|
+
for (let h = 1; h < c; h++)
|
|
294
|
+
s.add(a + h);
|
|
295
295
|
}
|
|
296
296
|
return s;
|
|
297
297
|
}
|
|
298
298
|
_generateFilterFn() {
|
|
299
|
-
this._criteria && (this._filterFn =
|
|
299
|
+
this._criteria && (this._filterFn = At(this._criteria), this._filterBy = this._criteria.filters ? b.VALUES : this._criteria.colorFilters ? b.COLORS : b.CONDITIONS);
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function At(i) {
|
|
303
303
|
if (i.filters)
|
|
304
|
-
return
|
|
304
|
+
return Tt(i.filters);
|
|
305
305
|
if (i.colorFilters)
|
|
306
|
-
return
|
|
306
|
+
return Nt(i.colorFilters);
|
|
307
307
|
if (i.customFilters)
|
|
308
|
-
return
|
|
308
|
+
return xt(i.customFilters);
|
|
309
309
|
throw new Error("[FilterModel]: other types of filters are not supported yet.");
|
|
310
310
|
}
|
|
311
|
-
function
|
|
312
|
-
const
|
|
313
|
-
return (
|
|
311
|
+
function Tt(i) {
|
|
312
|
+
const t = !!i.blank, e = new Set(i.filters);
|
|
313
|
+
return (r) => r === void 0 || r === "" ? t : e.has(typeof r == "string" ? r : `${r}`);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Nt(i) {
|
|
316
316
|
if (i.cellFillColors) {
|
|
317
|
-
const
|
|
317
|
+
const t = new Set(i.cellFillColors);
|
|
318
318
|
return (e) => {
|
|
319
319
|
var n;
|
|
320
320
|
if (!e || !((n = e.bg) != null && n.rgb))
|
|
321
|
-
return !!
|
|
322
|
-
const
|
|
323
|
-
return
|
|
321
|
+
return !!t.has(null);
|
|
322
|
+
const r = new se(e.bg.rgb).toRgbString();
|
|
323
|
+
return t.has(r);
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
326
|
if (i.cellTextColors) {
|
|
327
|
-
const
|
|
327
|
+
const t = new Set(i.cellTextColors);
|
|
328
328
|
return (e) => {
|
|
329
329
|
var n;
|
|
330
330
|
if (!e || !((n = e.cl) != null && n.rgb))
|
|
331
|
-
return !!
|
|
332
|
-
const
|
|
333
|
-
return
|
|
331
|
+
return !!t.has(mt);
|
|
332
|
+
const r = new se(e.cl.rgb).toRgbString();
|
|
333
|
+
return t.has(r);
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
336
|
throw new Error("[FilterModel]: color filters are not supported yet.");
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
const
|
|
340
|
-
return
|
|
338
|
+
function xt(i) {
|
|
339
|
+
const t = i.customFilters.map((e) => Lt(e));
|
|
340
|
+
return $t(t) ? i.and ? It(t) : bt(t) : t[0];
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
const [
|
|
344
|
-
return (
|
|
342
|
+
function It(i) {
|
|
343
|
+
const [t, e] = i;
|
|
344
|
+
return (r) => t(r) && e(r);
|
|
345
345
|
}
|
|
346
|
-
function
|
|
347
|
-
const [
|
|
348
|
-
return (
|
|
346
|
+
function bt(i) {
|
|
347
|
+
const [t, e] = i;
|
|
348
|
+
return (r) => t(r) || e(r);
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function $t(i) {
|
|
351
351
|
return i.length === 2;
|
|
352
352
|
}
|
|
353
|
-
function
|
|
354
|
-
const
|
|
355
|
-
if (i.operator === x.NOT_EQUALS && !
|
|
356
|
-
return (n) =>
|
|
357
|
-
if (
|
|
358
|
-
if (!
|
|
359
|
-
const n =
|
|
353
|
+
function Lt(i) {
|
|
354
|
+
const t = i.val;
|
|
355
|
+
if (i.operator === x.NOT_EQUALS && !ce(t))
|
|
356
|
+
return (n) => Ee.fn(n, t);
|
|
357
|
+
if (Mt(i.operator)) {
|
|
358
|
+
if (!ce(t)) return () => !1;
|
|
359
|
+
const n = ae(i.operator), s = Number(t);
|
|
360
360
|
return (o) => n.fn(o, s);
|
|
361
361
|
}
|
|
362
|
-
const e =
|
|
363
|
-
return (
|
|
362
|
+
const e = ae(i.operator);
|
|
363
|
+
return (r) => e.fn(r, t);
|
|
364
364
|
}
|
|
365
|
-
function
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
const n = i.getCellRaw(
|
|
369
|
-
return
|
|
365
|
+
function Ut(i, t, e) {
|
|
366
|
+
const r = i.getCell(t, e);
|
|
367
|
+
if (!r) return null;
|
|
368
|
+
const n = i.getCellRaw(t, e);
|
|
369
|
+
return r && !n ? de(r) : n ? r.t === te.NUMBER && typeof r.v == "string" ? n.v : de(n) : null;
|
|
370
370
|
}
|
|
371
|
-
function
|
|
372
|
-
var
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
371
|
+
function de(i) {
|
|
372
|
+
var r, n;
|
|
373
|
+
const t = (n = (r = i.p) == null ? void 0 : r.body) == null ? void 0 : n.dataStream;
|
|
374
|
+
if (t) return t.trimEnd();
|
|
375
375
|
const e = i.v;
|
|
376
|
-
return typeof e == "string" ? i.t ===
|
|
376
|
+
return typeof e == "string" ? i.t === te.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === te.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
|
|
377
377
|
}
|
|
378
|
-
var
|
|
379
|
-
for (var n =
|
|
378
|
+
var Pt = Object.getOwnPropertyDescriptor, Dt = (i, t, e, r) => {
|
|
379
|
+
for (var n = r > 1 ? void 0 : r ? Pt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
380
380
|
(o = i[s]) && (n = o(n) || n);
|
|
381
381
|
return n;
|
|
382
|
-
},
|
|
383
|
-
const
|
|
384
|
-
let M = class extends
|
|
385
|
-
constructor(
|
|
382
|
+
}, Y = (i, t) => (e, r) => t(e, r, i);
|
|
383
|
+
const Te = "SHEET_FILTER_PLUGIN";
|
|
384
|
+
let M = class extends U {
|
|
385
|
+
constructor(t, e, r) {
|
|
386
386
|
super();
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
C(this, "_filterModels", /* @__PURE__ */ new Map());
|
|
388
|
+
C(this, "_loadedUnitId$", new $(null));
|
|
389
|
+
C(this, "loadedUnitId$", this._loadedUnitId$.asObservable());
|
|
390
|
+
C(this, "_errorMsg$", new $(null));
|
|
391
|
+
C(this, "errorMsg$", this._errorMsg$.asObservable());
|
|
392
|
+
C(this, "_activeFilterModel$", new $(null));
|
|
393
393
|
/** An observable value emitting the current Workbook's active Worksheet's filter model (if there is one). */
|
|
394
|
-
|
|
395
|
-
this._resourcesManagerService =
|
|
394
|
+
C(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
|
|
395
|
+
this._resourcesManagerService = t, this._univerInstanceService = e, this._commandService = r, this._initModel(), this._initActiveFilterModel();
|
|
396
396
|
}
|
|
397
397
|
/** The current Workbook's active Worksheet's filter model (if there is one). */
|
|
398
398
|
get activeFilterModel() {
|
|
@@ -403,34 +403,34 @@ let M = class extends B {
|
|
|
403
403
|
* @param unitId
|
|
404
404
|
* @param subUnitId
|
|
405
405
|
*/
|
|
406
|
-
ensureFilterModel(
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
409
|
-
return
|
|
410
|
-
const n = this._univerInstanceService.getUniverSheetInstance(
|
|
406
|
+
ensureFilterModel(t, e) {
|
|
407
|
+
const r = this.getFilterModel(t, e);
|
|
408
|
+
if (r)
|
|
409
|
+
return r;
|
|
410
|
+
const n = this._univerInstanceService.getUniverSheetInstance(t);
|
|
411
411
|
if (!n)
|
|
412
|
-
throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${
|
|
412
|
+
throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing workbook ${t}!`);
|
|
413
413
|
const s = n.getSheetBySheetId(e);
|
|
414
414
|
if (!s)
|
|
415
415
|
throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
|
|
416
|
-
const o = new
|
|
417
|
-
return this._cacheFilterModel(
|
|
416
|
+
const o = new k(t, e, s);
|
|
417
|
+
return this._cacheFilterModel(t, e, o), o;
|
|
418
418
|
}
|
|
419
|
-
getFilterModel(
|
|
420
|
-
var
|
|
421
|
-
return (n = (
|
|
419
|
+
getFilterModel(t, e) {
|
|
420
|
+
var r, n;
|
|
421
|
+
return (n = (r = this._filterModels.get(t)) == null ? void 0 : r.get(e)) != null ? n : null;
|
|
422
422
|
}
|
|
423
|
-
removeFilterModel(
|
|
424
|
-
const
|
|
425
|
-
return
|
|
423
|
+
removeFilterModel(t, e) {
|
|
424
|
+
const r = this.getFilterModel(t, e);
|
|
425
|
+
return r ? (r.dispose(), this._filterModels.get(t).delete(e), !0) : !1;
|
|
426
426
|
}
|
|
427
|
-
setFilterErrorMsg(
|
|
428
|
-
this._errorMsg$.next(
|
|
427
|
+
setFilterErrorMsg(t) {
|
|
428
|
+
this._errorMsg$.next(t);
|
|
429
429
|
}
|
|
430
430
|
_updateActiveFilterModel() {
|
|
431
|
-
let
|
|
431
|
+
let t;
|
|
432
432
|
try {
|
|
433
|
-
if (
|
|
433
|
+
if (t = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !t) {
|
|
434
434
|
this._activeFilterModel$.next(null);
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
@@ -438,154 +438,154 @@ let M = class extends B {
|
|
|
438
438
|
console.error("[SheetsFilterService]: could not get active workbook!", o);
|
|
439
439
|
return;
|
|
440
440
|
}
|
|
441
|
-
const e =
|
|
441
|
+
const e = t.getActiveSheet(!0);
|
|
442
442
|
if (!e) {
|
|
443
443
|
this._activeFilterModel$.next(null);
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
|
-
const
|
|
446
|
+
const r = e.getUnitId(), n = e.getSheetId(), s = this.getFilterModel(r, n);
|
|
447
447
|
this._activeFilterModel$.next(s);
|
|
448
448
|
}
|
|
449
449
|
_initActiveFilterModel() {
|
|
450
450
|
this.disposeWithMe(
|
|
451
|
-
|
|
451
|
+
dt(
|
|
452
452
|
// source1: executing filter related mutations
|
|
453
|
-
|
|
453
|
+
Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([t]) => t.type === O.MUTATION && Me.has(t.id))),
|
|
454
454
|
// source2: activate sheet changes
|
|
455
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
455
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((t) => {
|
|
456
456
|
var e;
|
|
457
|
-
return (e =
|
|
457
|
+
return (e = t == null ? void 0 : t.activeSheet$) != null ? e : ft(null);
|
|
458
458
|
}))
|
|
459
459
|
).subscribe(() => this._updateActiveFilterModel())
|
|
460
460
|
);
|
|
461
461
|
}
|
|
462
|
-
_serializeAutoFiltersForUnit(
|
|
463
|
-
const e = this._filterModels.get(
|
|
462
|
+
_serializeAutoFiltersForUnit(t) {
|
|
463
|
+
const e = this._filterModels.get(t);
|
|
464
464
|
if (!e)
|
|
465
465
|
return "{}";
|
|
466
|
-
const
|
|
466
|
+
const r = {};
|
|
467
467
|
return e.forEach((n, s) => {
|
|
468
|
-
|
|
469
|
-
}), JSON.stringify(
|
|
468
|
+
r[s] = n.serialize();
|
|
469
|
+
}), JSON.stringify(r);
|
|
470
470
|
}
|
|
471
|
-
_deserializeAutoFiltersForUnit(
|
|
472
|
-
const
|
|
471
|
+
_deserializeAutoFiltersForUnit(t, e) {
|
|
472
|
+
const r = this._univerInstanceService.getUniverSheetInstance(t);
|
|
473
473
|
Object.keys(e).forEach((n) => {
|
|
474
|
-
const s = e[n], o =
|
|
475
|
-
this._cacheFilterModel(
|
|
474
|
+
const s = e[n], o = k.deserialize(t, n, r.getSheetBySheetId(n), s);
|
|
475
|
+
this._cacheFilterModel(t, n, o);
|
|
476
476
|
});
|
|
477
477
|
}
|
|
478
478
|
_initModel() {
|
|
479
479
|
this._resourcesManagerService.registerPluginResource({
|
|
480
|
-
pluginName:
|
|
481
|
-
businesses: [
|
|
482
|
-
toJson: (
|
|
483
|
-
parseJson: (
|
|
484
|
-
onLoad: (
|
|
485
|
-
this._deserializeAutoFiltersForUnit(
|
|
480
|
+
pluginName: Te,
|
|
481
|
+
businesses: [D.UNIVER_SHEET],
|
|
482
|
+
toJson: (t) => this._serializeAutoFiltersForUnit(t),
|
|
483
|
+
parseJson: (t) => JSON.parse(t),
|
|
484
|
+
onLoad: (t, e) => {
|
|
485
|
+
this._deserializeAutoFiltersForUnit(t, e), this._loadedUnitId$.next(t), this._updateActiveFilterModel();
|
|
486
486
|
},
|
|
487
|
-
onUnLoad: (
|
|
488
|
-
const e = this._filterModels.get(
|
|
489
|
-
e && (e.forEach((
|
|
487
|
+
onUnLoad: (t) => {
|
|
488
|
+
const e = this._filterModels.get(t);
|
|
489
|
+
e && (e.forEach((r) => r.dispose()), this._filterModels.delete(t));
|
|
490
490
|
}
|
|
491
491
|
});
|
|
492
492
|
}
|
|
493
|
-
_cacheFilterModel(
|
|
494
|
-
this._filterModels.has(
|
|
493
|
+
_cacheFilterModel(t, e, r) {
|
|
494
|
+
this._filterModels.has(t) || this._filterModels.set(t, /* @__PURE__ */ new Map()), this._filterModels.get(t).set(e, r);
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
|
-
M =
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
M = Dt([
|
|
498
|
+
Y(0, De),
|
|
499
|
+
Y(1, N),
|
|
500
|
+
Y(2, T)
|
|
501
501
|
], M);
|
|
502
|
-
const
|
|
503
|
-
id:
|
|
504
|
-
type:
|
|
505
|
-
handler: (i,
|
|
506
|
-
const { subUnitId: e, unitId:
|
|
507
|
-
return i.get(M).ensureFilterModel(
|
|
502
|
+
const R = {
|
|
503
|
+
id: Se,
|
|
504
|
+
type: O.MUTATION,
|
|
505
|
+
handler: (i, t) => {
|
|
506
|
+
const { subUnitId: e, unitId: r, range: n } = t;
|
|
507
|
+
return i.get(M).ensureFilterModel(r, e).setRange(n), !0;
|
|
508
508
|
}
|
|
509
509
|
}, p = {
|
|
510
|
-
id:
|
|
511
|
-
type:
|
|
512
|
-
handler: (i,
|
|
513
|
-
const { subUnitId: e, unitId:
|
|
510
|
+
id: Fe,
|
|
511
|
+
type: O.MUTATION,
|
|
512
|
+
handler: (i, t) => {
|
|
513
|
+
const { subUnitId: e, unitId: r, criteria: n, col: s, reCalc: o = !0 } = t, a = i.get(M).getFilterModel(r, e);
|
|
514
514
|
return a ? (a.setCriteria(s, n, o), !0) : !1;
|
|
515
515
|
}
|
|
516
|
-
},
|
|
517
|
-
id:
|
|
518
|
-
type:
|
|
519
|
-
handler: (i,
|
|
520
|
-
const { unitId: e, subUnitId:
|
|
521
|
-
return i.get(M).removeFilterModel(e,
|
|
522
|
-
}
|
|
523
|
-
},
|
|
524
|
-
id:
|
|
525
|
-
type:
|
|
526
|
-
handler: (i,
|
|
527
|
-
const { unitId: e, subUnitId:
|
|
516
|
+
}, y = {
|
|
517
|
+
id: we,
|
|
518
|
+
type: O.MUTATION,
|
|
519
|
+
handler: (i, t) => {
|
|
520
|
+
const { unitId: e, subUnitId: r } = t;
|
|
521
|
+
return i.get(M).removeFilterModel(e, r);
|
|
522
|
+
}
|
|
523
|
+
}, B = {
|
|
524
|
+
id: ve,
|
|
525
|
+
type: O.MUTATION,
|
|
526
|
+
handler: (i, t) => {
|
|
527
|
+
const { unitId: e, subUnitId: r } = t, s = i.get(M).getFilterModel(e, r);
|
|
528
528
|
return s ? (s.reCalc(), !0) : !1;
|
|
529
529
|
}
|
|
530
|
-
},
|
|
530
|
+
}, Bt = {
|
|
531
531
|
id: "sheet.command.set-filter-range",
|
|
532
|
-
type:
|
|
533
|
-
handler: (i,
|
|
534
|
-
const e = i.get(M),
|
|
535
|
-
if (!
|
|
532
|
+
type: O.COMMAND,
|
|
533
|
+
handler: (i, t) => {
|
|
534
|
+
const e = i.get(M), r = i.get(T), n = i.get(Q), s = i.get(N), { unitId: o, subUnitId: l, range: a } = t;
|
|
535
|
+
if (!H(s, t) || e.getFilterModel(o, l)) return !1;
|
|
536
536
|
if (a.endRow === a.startRow) {
|
|
537
|
-
const
|
|
538
|
-
return
|
|
537
|
+
const g = i.get(Be), _ = i.get(ze);
|
|
538
|
+
return g.emit(_.t("sheets-filter.command.not-valid-filter-range")), !1;
|
|
539
539
|
}
|
|
540
|
-
const
|
|
541
|
-
return
|
|
540
|
+
const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = r.syncExecuteCommand(d.id, d.params);
|
|
541
|
+
return h && n.pushUndoRedo({
|
|
542
542
|
unitID: o,
|
|
543
|
-
undoMutations: [{ id:
|
|
544
|
-
redoMutations: [
|
|
545
|
-
}),
|
|
543
|
+
undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
|
|
544
|
+
redoMutations: [d]
|
|
545
|
+
}), h;
|
|
546
546
|
}
|
|
547
|
-
},
|
|
547
|
+
}, zt = {
|
|
548
548
|
id: "sheet.command.remove-sheet-filter",
|
|
549
|
-
type:
|
|
550
|
-
handler: (i,
|
|
551
|
-
const e = i.get(N),
|
|
549
|
+
type: O.COMMAND,
|
|
550
|
+
handler: (i, t) => {
|
|
551
|
+
const e = i.get(N), r = i.get(M), n = i.get(T), s = i.get(Q), o = H(e, t);
|
|
552
552
|
if (!o) return !1;
|
|
553
|
-
const { unitId: l, subUnitId: a } = o, c =
|
|
553
|
+
const { unitId: l, subUnitId: a } = o, c = r.getFilterModel(l, a);
|
|
554
554
|
if (!c) return !1;
|
|
555
|
-
const
|
|
556
|
-
return
|
|
555
|
+
const u = c == null ? void 0 : c.serialize(), d = Ht(l, a, u), h = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
|
|
556
|
+
return h && s.pushUndoRedo({
|
|
557
557
|
unitID: l,
|
|
558
|
-
undoMutations:
|
|
559
|
-
redoMutations: [{ id:
|
|
560
|
-
}),
|
|
558
|
+
undoMutations: d,
|
|
559
|
+
redoMutations: [{ id: y.id, params: { unitId: l, subUnitId: a } }]
|
|
560
|
+
}), h;
|
|
561
561
|
}
|
|
562
|
-
},
|
|
562
|
+
}, ar = {
|
|
563
563
|
id: "sheet.command.smart-toggle-filter",
|
|
564
|
-
type:
|
|
564
|
+
type: O.COMMAND,
|
|
565
565
|
handler: async (i) => {
|
|
566
|
-
const
|
|
566
|
+
const t = i.get(N), e = i.get(M), r = i.get(T), n = t.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
|
|
567
567
|
if (!s || !n) return !1;
|
|
568
568
|
const o = n.getUnitId(), l = s.getSheetId();
|
|
569
569
|
if (e.getFilterModel(o, l))
|
|
570
|
-
return
|
|
571
|
-
const
|
|
572
|
-
if (!
|
|
573
|
-
const
|
|
574
|
-
return
|
|
570
|
+
return r.executeCommand(zt.id, { unitId: o, subUnitId: l });
|
|
571
|
+
const u = i.get(qe).getCurrentLastSelection();
|
|
572
|
+
if (!u) return !1;
|
|
573
|
+
const d = u.range, h = Ge(u) ? _e(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
|
|
574
|
+
return r.executeCommand(Bt.id, {
|
|
575
575
|
unitId: o,
|
|
576
576
|
subUnitId: l,
|
|
577
|
-
range:
|
|
577
|
+
range: h
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
|
-
},
|
|
580
|
+
}, cr = {
|
|
581
581
|
id: "sheet.command.set-filter-criteria",
|
|
582
|
-
type:
|
|
583
|
-
handler: (i,
|
|
584
|
-
const e = i.get(M),
|
|
582
|
+
type: O.COMMAND,
|
|
583
|
+
handler: (i, t) => {
|
|
584
|
+
const e = i.get(M), r = i.get(T), n = i.get(Q), { unitId: s, subUnitId: o, col: l, criteria: a } = t, c = e.getFilterModel(s, o);
|
|
585
585
|
if (!c) return !1;
|
|
586
|
-
const
|
|
587
|
-
if (!
|
|
588
|
-
const
|
|
586
|
+
const u = c.getRange();
|
|
587
|
+
if (!u || l < u.startColumn || l > u.endColumn) return !1;
|
|
588
|
+
const d = c.getFilterColumn(l), h = Wt(s, o, l, d), g = {
|
|
589
589
|
id: p.id,
|
|
590
590
|
params: {
|
|
591
591
|
unitId: s,
|
|
@@ -593,133 +593,133 @@ const C = {
|
|
|
593
593
|
col: l,
|
|
594
594
|
criteria: a
|
|
595
595
|
}
|
|
596
|
-
},
|
|
597
|
-
return
|
|
596
|
+
}, _ = r.syncExecuteCommand(g.id, g.params);
|
|
597
|
+
return _ && n.pushUndoRedo({
|
|
598
598
|
unitID: s,
|
|
599
|
-
undoMutations: [
|
|
600
|
-
redoMutations: [
|
|
601
|
-
}),
|
|
599
|
+
undoMutations: [h],
|
|
600
|
+
redoMutations: [g]
|
|
601
|
+
}), _;
|
|
602
602
|
}
|
|
603
|
-
},
|
|
603
|
+
}, dr = {
|
|
604
604
|
id: "sheet.command.clear-filter-criteria",
|
|
605
|
-
type:
|
|
606
|
-
handler: (i,
|
|
607
|
-
const e = i.get(M),
|
|
605
|
+
type: O.COMMAND,
|
|
606
|
+
handler: (i, t) => {
|
|
607
|
+
const e = i.get(M), r = i.get(Q), n = i.get(T), s = i.get(N), o = H(s, t);
|
|
608
608
|
if (!o) return !1;
|
|
609
609
|
const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
|
|
610
610
|
if (!c) return !1;
|
|
611
|
-
const
|
|
612
|
-
return
|
|
611
|
+
const u = c.serialize(), d = Ne(l, a, u), h = Vt(l, a, u);
|
|
612
|
+
return j(h, n).result ? (r.pushUndoRedo({
|
|
613
613
|
unitID: l,
|
|
614
|
-
undoMutations:
|
|
615
|
-
redoMutations:
|
|
614
|
+
undoMutations: d,
|
|
615
|
+
redoMutations: h
|
|
616
616
|
}), !0) : !1;
|
|
617
617
|
}
|
|
618
|
-
},
|
|
618
|
+
}, ur = {
|
|
619
619
|
id: "sheet.command.re-calc-filter",
|
|
620
|
-
type:
|
|
621
|
-
handler: (i,
|
|
622
|
-
const e = i.get(M),
|
|
620
|
+
type: O.COMMAND,
|
|
621
|
+
handler: (i, t) => {
|
|
622
|
+
const e = i.get(M), r = i.get(T), n = i.get(N), s = H(n, t);
|
|
623
623
|
if (!s) return !1;
|
|
624
624
|
const { unitId: o, subUnitId: l } = s;
|
|
625
|
-
return e.getFilterModel(s.unitId, s.subUnitId) ?
|
|
625
|
+
return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
|
|
626
626
|
}
|
|
627
627
|
};
|
|
628
|
-
function
|
|
629
|
-
const
|
|
630
|
-
id:
|
|
628
|
+
function Ht(i, t, e) {
|
|
629
|
+
const r = [], n = {
|
|
630
|
+
id: R.id,
|
|
631
631
|
params: {
|
|
632
632
|
unitId: i,
|
|
633
|
-
subUnitId:
|
|
633
|
+
subUnitId: t,
|
|
634
634
|
range: e.ref
|
|
635
635
|
}
|
|
636
636
|
};
|
|
637
|
-
return
|
|
637
|
+
return r.push(n), Ne(i, t, e).forEach((o) => r.push(o)), r;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Ne(i, t, e) {
|
|
640
640
|
var n;
|
|
641
|
-
const
|
|
641
|
+
const r = [];
|
|
642
642
|
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
643
643
|
const o = {
|
|
644
644
|
id: p.id,
|
|
645
645
|
params: {
|
|
646
646
|
unitId: i,
|
|
647
|
-
subUnitId:
|
|
647
|
+
subUnitId: t,
|
|
648
648
|
col: s.colId,
|
|
649
649
|
criteria: s
|
|
650
650
|
}
|
|
651
651
|
};
|
|
652
|
-
|
|
653
|
-
}),
|
|
652
|
+
r.push(o);
|
|
653
|
+
}), r;
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function Vt(i, t, e) {
|
|
656
656
|
var n;
|
|
657
|
-
const
|
|
657
|
+
const r = [];
|
|
658
658
|
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
659
659
|
const o = {
|
|
660
660
|
id: p.id,
|
|
661
661
|
params: {
|
|
662
662
|
unitId: i,
|
|
663
|
-
subUnitId:
|
|
663
|
+
subUnitId: t,
|
|
664
664
|
col: s.colId,
|
|
665
665
|
criteria: null
|
|
666
666
|
}
|
|
667
667
|
};
|
|
668
|
-
|
|
669
|
-
}),
|
|
668
|
+
r.push(o);
|
|
669
|
+
}), r;
|
|
670
670
|
}
|
|
671
|
-
function
|
|
672
|
-
if (!
|
|
671
|
+
function Wt(i, t, e, r) {
|
|
672
|
+
if (!r)
|
|
673
673
|
return {
|
|
674
674
|
id: p.id,
|
|
675
675
|
params: {
|
|
676
676
|
unitId: i,
|
|
677
|
-
subUnitId:
|
|
677
|
+
subUnitId: t,
|
|
678
678
|
col: e,
|
|
679
679
|
criteria: null
|
|
680
680
|
}
|
|
681
681
|
};
|
|
682
|
-
const n =
|
|
682
|
+
const n = r.serialize();
|
|
683
683
|
return {
|
|
684
684
|
id: p.id,
|
|
685
685
|
params: {
|
|
686
686
|
unitId: i,
|
|
687
|
-
subUnitId:
|
|
687
|
+
subUnitId: t,
|
|
688
688
|
col: e,
|
|
689
689
|
criteria: n
|
|
690
690
|
}
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
|
-
const
|
|
694
|
-
function
|
|
693
|
+
const xe = "sheets-filter.config", ue = {};
|
|
694
|
+
function jt(i, t) {
|
|
695
695
|
for (let e = 0; e < i.length; e++) {
|
|
696
|
-
let
|
|
696
|
+
let r = e;
|
|
697
697
|
if (i[e])
|
|
698
698
|
for (let n = e + 1; n < i.length; n++)
|
|
699
|
-
i[
|
|
699
|
+
i[r] && i[n] && t(i[r], i[n]) && (i[r] = null, r = n);
|
|
700
700
|
}
|
|
701
701
|
return i.filter((e) => e !== null);
|
|
702
702
|
}
|
|
703
703
|
function L(i) {
|
|
704
|
-
return
|
|
704
|
+
return jt(i, (t, e) => t.id === p.id && e.id === p.id && t.params.unitId === e.params.unitId && t.params.subUnitId === e.params.subUnitId && t.params.col === e.params.col);
|
|
705
705
|
}
|
|
706
|
-
var
|
|
707
|
-
for (var n =
|
|
706
|
+
var kt = Object.getOwnPropertyDescriptor, qt = (i, t, e, r) => {
|
|
707
|
+
for (var n = r > 1 ? void 0 : r ? kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
708
708
|
(o = i[s]) && (n = o(n) || n);
|
|
709
709
|
return n;
|
|
710
|
-
},
|
|
711
|
-
let
|
|
712
|
-
constructor(
|
|
710
|
+
}, I = (i, t) => (e, r) => t(e, r, i);
|
|
711
|
+
let z = class extends U {
|
|
712
|
+
constructor(t, e, r, n, s, o, l) {
|
|
713
713
|
super();
|
|
714
|
-
|
|
715
|
-
this._commandService =
|
|
714
|
+
C(this, "_disposableCollection", new me());
|
|
715
|
+
this._commandService = t, this._sheetInterceptorService = e, this._sheetsFilterService = r, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._zebraCrossingCacheController = l, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling(), this._initZebraCrossingCacheListener();
|
|
716
716
|
}
|
|
717
717
|
_initZebraCrossingCacheListener() {
|
|
718
718
|
this.disposeWithMe(
|
|
719
|
-
this._sheetsFilterService.activeFilterModel$.subscribe((
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
this._zebraCrossingCacheController.updateZebraCrossingCache(
|
|
719
|
+
this._sheetsFilterService.activeFilterModel$.subscribe((t) => {
|
|
720
|
+
t && this.disposeWithMe(
|
|
721
|
+
t.filteredOutRows$.subscribe(() => {
|
|
722
|
+
this._zebraCrossingCacheController.updateZebraCrossingCache(t.unitId, t.subUnitId);
|
|
723
723
|
})
|
|
724
724
|
);
|
|
725
725
|
})
|
|
@@ -728,86 +728,89 @@ let k = class extends B {
|
|
|
728
728
|
_initCommands() {
|
|
729
729
|
[
|
|
730
730
|
p,
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
].forEach((
|
|
731
|
+
R,
|
|
732
|
+
B,
|
|
733
|
+
y
|
|
734
|
+
].forEach((t) => {
|
|
735
735
|
var e;
|
|
736
|
-
this.disposeWithMe(this._commandService.registerCommand(
|
|
736
|
+
this.disposeWithMe(this._commandService.registerCommand(t)), (e = this._dataSyncPrimaryController) == null || e.registerSyncingMutations(t);
|
|
737
737
|
});
|
|
738
738
|
}
|
|
739
739
|
_initInterceptors() {
|
|
740
740
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
741
|
-
getMutations: (
|
|
742
|
-
})), this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
743
|
-
if (
|
|
744
|
-
const e =
|
|
745
|
-
if (!
|
|
741
|
+
getMutations: (t) => this._getUpdateFilter(t)
|
|
742
|
+
})), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
|
|
743
|
+
if (t.id === Ke.id) {
|
|
744
|
+
const e = t.params, r = e.subUnitId, n = e.unitId;
|
|
745
|
+
if (!r || !n)
|
|
746
746
|
return;
|
|
747
|
-
this._registerRefRange(n,
|
|
747
|
+
this._registerRefRange(n, r);
|
|
748
748
|
}
|
|
749
|
-
if (
|
|
750
|
-
const e =
|
|
751
|
-
if (!
|
|
749
|
+
if (t.id === R.id) {
|
|
750
|
+
const e = t.params, r = e.subUnitId, n = e.unitId;
|
|
751
|
+
if (!r || !n)
|
|
752
752
|
return;
|
|
753
753
|
this._registerRefRange(e.unitId, e.subUnitId);
|
|
754
754
|
}
|
|
755
|
-
})), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((
|
|
756
|
-
if (
|
|
757
|
-
const e = this._univerInstanceService.getUniverSheetInstance(
|
|
758
|
-
|
|
755
|
+
})), this.disposeWithMe(this._sheetsFilterService.loadedUnitId$.subscribe((t) => {
|
|
756
|
+
if (t) {
|
|
757
|
+
const e = this._univerInstanceService.getUniverSheetInstance(t), r = e == null ? void 0 : e.getActiveSheet();
|
|
758
|
+
r && this._registerRefRange(t, r.getSheetId());
|
|
759
759
|
}
|
|
760
760
|
}));
|
|
761
761
|
}
|
|
762
|
-
_registerRefRange(
|
|
762
|
+
_registerRefRange(t, e) {
|
|
763
763
|
var l;
|
|
764
764
|
this._disposableCollection.dispose();
|
|
765
|
-
const
|
|
766
|
-
if (!
|
|
767
|
-
const s = (l = this._sheetsFilterService.getFilterModel(
|
|
765
|
+
const r = this._univerInstanceService.getUniverSheetInstance(t), n = r == null ? void 0 : r.getSheetBySheetId(e);
|
|
766
|
+
if (!r || !n) return;
|
|
767
|
+
const s = (l = this._sheetsFilterService.getFilterModel(t, e)) == null ? void 0 : l.getRange(), o = (a) => {
|
|
768
768
|
switch (a.id) {
|
|
769
|
-
case
|
|
770
|
-
const c = a.params,
|
|
771
|
-
return this._handleInsertRowCommand(c,
|
|
769
|
+
case ct.id: {
|
|
770
|
+
const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
|
|
771
|
+
return this._handleInsertRowCommand(c, u, d);
|
|
772
772
|
}
|
|
773
|
-
case
|
|
774
|
-
const c = a.params,
|
|
775
|
-
return this.
|
|
773
|
+
case at.id: {
|
|
774
|
+
const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
|
|
775
|
+
return this.handleInsertColCommand(c.range, u, d);
|
|
776
776
|
}
|
|
777
|
-
case
|
|
777
|
+
case lt.id: {
|
|
778
778
|
const c = a.params;
|
|
779
|
-
return this.
|
|
779
|
+
return this.handleRemoveColCommand(c.range, t, e);
|
|
780
780
|
}
|
|
781
|
-
case
|
|
781
|
+
case ot.id: {
|
|
782
782
|
const c = a.params;
|
|
783
|
-
return this._handleRemoveRowCommand(c,
|
|
783
|
+
return this._handleRemoveRowCommand(c, t, e);
|
|
784
784
|
}
|
|
785
|
-
case
|
|
785
|
+
case le.MoveColsCommandId: {
|
|
786
786
|
const c = a.params;
|
|
787
|
-
return this.
|
|
787
|
+
return this.handleMoveColsCommand({
|
|
788
|
+
fromRange: c.fromRange,
|
|
789
|
+
toRange: c.toRange
|
|
790
|
+
}, t, e);
|
|
788
791
|
}
|
|
789
|
-
case
|
|
792
|
+
case le.MoveRowsCommandId: {
|
|
790
793
|
const c = a.params;
|
|
791
|
-
return this._handleMoveRowsCommand(c,
|
|
794
|
+
return this._handleMoveRowsCommand(c, t, e);
|
|
792
795
|
}
|
|
793
|
-
case
|
|
796
|
+
case st.id: {
|
|
794
797
|
const c = a.params;
|
|
795
|
-
return this._handleMoveRangeCommand(c,
|
|
798
|
+
return this._handleMoveRangeCommand(c, t, e);
|
|
796
799
|
}
|
|
797
800
|
}
|
|
798
801
|
return { redos: [], undos: [] };
|
|
799
802
|
};
|
|
800
|
-
s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o,
|
|
803
|
+
s && this._disposableCollection.add(this._refRangeService.registerRefRange(s, o, t, e));
|
|
801
804
|
}
|
|
802
|
-
_getUpdateFilter(
|
|
803
|
-
const { id: e } =
|
|
805
|
+
_getUpdateFilter(t) {
|
|
806
|
+
const { id: e } = t;
|
|
804
807
|
switch (e) {
|
|
805
|
-
case
|
|
806
|
-
const
|
|
807
|
-
return this._handleRemoveSheetCommand(
|
|
808
|
+
case Xe.id: {
|
|
809
|
+
const r = t.params;
|
|
810
|
+
return this._handleRemoveSheetCommand(r, r.unitId, r.subUnitId);
|
|
808
811
|
}
|
|
809
|
-
case
|
|
810
|
-
const
|
|
812
|
+
case Ye.id: {
|
|
813
|
+
const r = t.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = r;
|
|
811
814
|
return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
|
|
812
815
|
}
|
|
813
816
|
}
|
|
@@ -816,115 +819,115 @@ let k = class extends B {
|
|
|
816
819
|
undos: []
|
|
817
820
|
};
|
|
818
821
|
}
|
|
819
|
-
|
|
820
|
-
var
|
|
821
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
822
|
+
handleInsertColCommand(t, e, r) {
|
|
823
|
+
var f;
|
|
824
|
+
const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
|
|
822
825
|
if (!n || !s)
|
|
823
826
|
return this._handleNull();
|
|
824
|
-
const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } =
|
|
827
|
+
const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t, u = c - a + 1;
|
|
825
828
|
if (c > l)
|
|
826
829
|
return this._handleNull();
|
|
827
|
-
const
|
|
830
|
+
const d = [], h = [], g = a, _ = {
|
|
828
831
|
unitId: e,
|
|
829
|
-
subUnitId:
|
|
832
|
+
subUnitId: r,
|
|
830
833
|
range: {
|
|
831
834
|
...s,
|
|
832
|
-
startColumn: a <= o ? o +
|
|
833
|
-
endColumn: l +
|
|
835
|
+
startColumn: a <= o ? o + u : o,
|
|
836
|
+
endColumn: l + u
|
|
834
837
|
}
|
|
835
|
-
},
|
|
838
|
+
}, S = {
|
|
836
839
|
unitId: e,
|
|
837
|
-
subUnitId:
|
|
840
|
+
subUnitId: r,
|
|
838
841
|
range: s
|
|
839
842
|
};
|
|
840
|
-
|
|
841
|
-
const F = n.getAllFilterColumns().filter((
|
|
843
|
+
d.push({ id: R.id, params: _ }), h.push({ id: R.id, params: S });
|
|
844
|
+
const F = n.getAllFilterColumns().filter((m) => m[0] >= g);
|
|
842
845
|
if (F.length !== 0) {
|
|
843
|
-
const { newRange:
|
|
844
|
-
|
|
846
|
+
const { newRange: m, oldRange: v } = this._moveCriteria(e, r, F, u);
|
|
847
|
+
d.push(...v.redos, ...m.redos), h.push(...m.undos, ...v.undos);
|
|
845
848
|
}
|
|
846
|
-
return { redos: L(
|
|
849
|
+
return { redos: L(d), undos: L(h) };
|
|
847
850
|
}
|
|
848
|
-
_handleInsertRowCommand(
|
|
849
|
-
var
|
|
850
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
851
|
+
_handleInsertRowCommand(t, e, r) {
|
|
852
|
+
var S;
|
|
853
|
+
const n = this._sheetsFilterService.getFilterModel(e, r), s = (S = n == null ? void 0 : n.getRange()) != null ? S : null;
|
|
851
854
|
if (!n || !s)
|
|
852
855
|
return this._handleNull();
|
|
853
|
-
const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } =
|
|
856
|
+
const { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range, u = c - a + 1;
|
|
854
857
|
if (c > l)
|
|
855
858
|
return this._handleNull();
|
|
856
|
-
const
|
|
859
|
+
const d = [], h = [], g = {
|
|
857
860
|
unitId: e,
|
|
858
|
-
subUnitId:
|
|
861
|
+
subUnitId: r,
|
|
859
862
|
range: {
|
|
860
863
|
...s,
|
|
861
|
-
startRow: a <= o ? o +
|
|
862
|
-
endRow: l +
|
|
864
|
+
startRow: a <= o ? o + u : o,
|
|
865
|
+
endRow: l + u
|
|
863
866
|
}
|
|
864
|
-
},
|
|
867
|
+
}, _ = {
|
|
865
868
|
unitId: e,
|
|
866
|
-
subUnitId:
|
|
869
|
+
subUnitId: r,
|
|
867
870
|
range: s
|
|
868
871
|
};
|
|
869
|
-
return
|
|
870
|
-
redos: L(
|
|
871
|
-
undos: L(
|
|
872
|
+
return d.push({ id: R.id, params: g }), h.push({ id: R.id, params: _ }), {
|
|
873
|
+
redos: L(d),
|
|
874
|
+
undos: L(h)
|
|
872
875
|
};
|
|
873
876
|
}
|
|
874
|
-
|
|
877
|
+
handleRemoveColCommand(t, e, r) {
|
|
875
878
|
var F;
|
|
876
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
879
|
+
const n = this._sheetsFilterService.getFilterModel(e, r), s = (F = n == null ? void 0 : n.getRange()) != null ? F : null;
|
|
877
880
|
if (!n || !s)
|
|
878
881
|
return this._handleNull();
|
|
879
|
-
const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } =
|
|
882
|
+
const { startColumn: o, endColumn: l } = s, { startColumn: a, endColumn: c } = t;
|
|
880
883
|
if (a > l)
|
|
881
884
|
return this._handleNull();
|
|
882
|
-
const
|
|
883
|
-
|
|
884
|
-
const [
|
|
885
|
-
|
|
885
|
+
const u = [], d = [], h = c < o ? 0 : Math.min(c, l) - Math.max(a, o) + 1, g = c - a + 1, _ = n.getAllFilterColumns();
|
|
886
|
+
_.forEach((f) => {
|
|
887
|
+
const [m, v] = f;
|
|
888
|
+
m <= c && m >= a && (u.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: null } }), d.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
|
|
886
889
|
});
|
|
887
|
-
const
|
|
888
|
-
const [
|
|
889
|
-
return
|
|
890
|
+
const S = _.filter((f) => {
|
|
891
|
+
const [m, v] = f;
|
|
892
|
+
return m > c;
|
|
890
893
|
});
|
|
891
894
|
let w = { undos: [], redos: [] };
|
|
892
|
-
if (
|
|
893
|
-
const { oldRange:
|
|
894
|
-
w =
|
|
895
|
+
if (S.length > 0) {
|
|
896
|
+
const { oldRange: f, newRange: m } = this._moveCriteria(e, r, S, -g);
|
|
897
|
+
w = m, u.push(...f.redos), d.unshift(...f.undos);
|
|
895
898
|
}
|
|
896
|
-
if (
|
|
897
|
-
const
|
|
899
|
+
if (h === l - o + 1) {
|
|
900
|
+
const f = {
|
|
898
901
|
unitId: e,
|
|
899
|
-
subUnitId:
|
|
902
|
+
subUnitId: r
|
|
900
903
|
};
|
|
901
|
-
|
|
904
|
+
u.push({ id: y.id, params: f }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
|
|
902
905
|
} else {
|
|
903
|
-
const
|
|
906
|
+
const f = o <= a ? o : h === 0 ? o - g : a, m = o <= a ? l - h : l - g, v = {
|
|
904
907
|
unitId: e,
|
|
905
|
-
subUnitId:
|
|
906
|
-
range: { ...s, startColumn:
|
|
908
|
+
subUnitId: r,
|
|
909
|
+
range: { ...s, startColumn: f, endColumn: m }
|
|
907
910
|
};
|
|
908
|
-
|
|
911
|
+
u.push({ id: R.id, params: v }), d.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), u.push(...w.redos), d.unshift(...w.undos);
|
|
909
912
|
}
|
|
910
913
|
return {
|
|
911
|
-
undos:
|
|
912
|
-
redos:
|
|
914
|
+
undos: d,
|
|
915
|
+
redos: u
|
|
913
916
|
};
|
|
914
917
|
}
|
|
915
|
-
_handleRemoveRowCommand(
|
|
916
|
-
var
|
|
917
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
918
|
+
_handleRemoveRowCommand(t, e, r) {
|
|
919
|
+
var S;
|
|
920
|
+
const n = this._sheetsFilterService.getFilterModel(e, r);
|
|
918
921
|
if (!n)
|
|
919
922
|
return this._handleNull();
|
|
920
|
-
const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } =
|
|
923
|
+
const s = n.getRange(), { startRow: o, endRow: l } = s, { startRow: a, endRow: c } = t.range;
|
|
921
924
|
if (a > l)
|
|
922
925
|
return this._handleNull();
|
|
923
926
|
if (c < o)
|
|
924
927
|
return {
|
|
925
|
-
undos: [{ id:
|
|
928
|
+
undos: [{ id: R.id, params: { range: s, unitId: e, subUnitId: r } }],
|
|
926
929
|
redos: [{
|
|
927
|
-
id:
|
|
930
|
+
id: R.id,
|
|
928
931
|
params: {
|
|
929
932
|
range: {
|
|
930
933
|
...s,
|
|
@@ -932,213 +935,213 @@ let k = class extends B {
|
|
|
932
935
|
endRow: l - (c - a + 1)
|
|
933
936
|
},
|
|
934
937
|
unitId: e,
|
|
935
|
-
subUnitId:
|
|
938
|
+
subUnitId: r
|
|
936
939
|
}
|
|
937
940
|
}]
|
|
938
941
|
};
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
942
|
+
const u = [], d = [], h = n.getAllFilterColumns(), g = o <= c && o >= a;
|
|
943
|
+
d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } });
|
|
944
|
+
const _ = Math.min(c, l) - Math.max(a, o) + 1;
|
|
945
|
+
if (_ === l - o + 1 || g) {
|
|
943
946
|
const w = {
|
|
944
947
|
unitId: e,
|
|
945
|
-
subUnitId:
|
|
948
|
+
subUnitId: r
|
|
946
949
|
};
|
|
947
|
-
|
|
948
|
-
const [
|
|
950
|
+
u.push({ id: y.id, params: w }), h.forEach((F) => {
|
|
951
|
+
const [f, m] = F, v = {
|
|
949
952
|
unitId: e,
|
|
950
|
-
subUnitId:
|
|
951
|
-
col:
|
|
952
|
-
criteria: { ...
|
|
953
|
+
subUnitId: r,
|
|
954
|
+
col: f,
|
|
955
|
+
criteria: { ...m.serialize(), colId: f }
|
|
953
956
|
};
|
|
954
|
-
|
|
957
|
+
d.push({ id: p.id, params: v });
|
|
955
958
|
});
|
|
956
959
|
} else {
|
|
957
|
-
const w = (
|
|
960
|
+
const w = (S = this._univerInstanceService.getUniverSheetInstance(e)) == null ? void 0 : S.getSheetBySheetId(r);
|
|
958
961
|
if (!w)
|
|
959
962
|
return this._handleNull();
|
|
960
963
|
const F = [];
|
|
961
|
-
for (let
|
|
962
|
-
w.getRowFiltered(
|
|
963
|
-
const
|
|
964
|
+
for (let E = a; E <= c; E++)
|
|
965
|
+
w.getRowFiltered(E) && F.push(E);
|
|
966
|
+
const f = Math.min(o, a), m = f + (l - o) - _ + F.length, v = {
|
|
964
967
|
unitId: e,
|
|
965
|
-
subUnitId:
|
|
968
|
+
subUnitId: r,
|
|
966
969
|
range: {
|
|
967
970
|
...s,
|
|
968
|
-
startRow:
|
|
969
|
-
endRow:
|
|
971
|
+
startRow: f,
|
|
972
|
+
endRow: m
|
|
970
973
|
}
|
|
971
974
|
};
|
|
972
|
-
|
|
975
|
+
u.push({ id: R.id, params: v });
|
|
973
976
|
}
|
|
974
977
|
return {
|
|
975
|
-
undos: L(
|
|
976
|
-
redos: L(
|
|
978
|
+
undos: L(d),
|
|
979
|
+
redos: L(u)
|
|
977
980
|
};
|
|
978
981
|
}
|
|
979
982
|
// eslint-disable-next-line max-lines-per-function
|
|
980
|
-
|
|
981
|
-
var
|
|
982
|
-
const
|
|
983
|
-
if (!
|
|
983
|
+
handleMoveColsCommand({ fromRange: t, toRange: e }, r, n) {
|
|
984
|
+
var F;
|
|
985
|
+
const s = this._sheetsFilterService.getFilterModel(r, n), o = (F = s == null ? void 0 : s.getRange()) != null ? F : null;
|
|
986
|
+
if (!s || !o)
|
|
984
987
|
return this._handleNull();
|
|
985
|
-
const { startColumn:
|
|
986
|
-
if (
|
|
988
|
+
const { startColumn: l, endColumn: a } = o;
|
|
989
|
+
if (t.endColumn < l && e.startColumn <= l || t.startColumn > a && e.endColumn > a)
|
|
987
990
|
return this._handleNull();
|
|
988
|
-
const
|
|
989
|
-
for (let f =
|
|
991
|
+
const c = [], u = [], d = {};
|
|
992
|
+
for (let f = l; f <= a; f++)
|
|
990
993
|
d[f] = {
|
|
991
994
|
colIndex: f,
|
|
992
|
-
filter:
|
|
995
|
+
filter: s.getFilterColumn(f)
|
|
993
996
|
};
|
|
994
|
-
|
|
995
|
-
let
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
var
|
|
1000
|
-
const { colIndex:
|
|
1001
|
-
if (
|
|
1002
|
-
if (
|
|
1003
|
-
const
|
|
1004
|
-
unitId:
|
|
1005
|
-
subUnitId:
|
|
1006
|
-
col:
|
|
1007
|
-
criteria: { ...
|
|
1008
|
-
},
|
|
1009
|
-
unitId:
|
|
1010
|
-
subUnitId:
|
|
1011
|
-
col:
|
|
1012
|
-
criteria:
|
|
997
|
+
oe(t.startColumn, t.endColumn - t.startColumn + 1, e.startColumn, d);
|
|
998
|
+
let h = o.startColumn, g = o.endColumn;
|
|
999
|
+
l >= t.startColumn && l <= t.endColumn && e.startColumn > t.startColumn && t.endColumn < a && (h = t.endColumn + 1), a >= t.startColumn && a <= t.endColumn && e.startColumn < t.startColumn && t.startColumn > l && (g = t.startColumn - 1);
|
|
1000
|
+
const _ = Object.keys(d).map((f) => Number(f)), S = _.find((f) => d[f].colIndex === g), w = _.find((f) => d[f].colIndex === h);
|
|
1001
|
+
if (_.forEach((f) => {
|
|
1002
|
+
var re, ne;
|
|
1003
|
+
const { colIndex: m, filter: v } = d[f], E = f;
|
|
1004
|
+
if (v) {
|
|
1005
|
+
if (E >= w && E <= S) {
|
|
1006
|
+
const J = {
|
|
1007
|
+
unitId: r,
|
|
1008
|
+
subUnitId: n,
|
|
1009
|
+
col: E,
|
|
1010
|
+
criteria: { ...v.serialize(), colId: E }
|
|
1011
|
+
}, Ie = {
|
|
1012
|
+
unitId: r,
|
|
1013
|
+
subUnitId: n,
|
|
1014
|
+
col: E,
|
|
1015
|
+
criteria: s.getFilterColumn(E) ? { ...(re = s.getFilterColumn(E)) == null ? void 0 : re.serialize(), colId: E } : null
|
|
1013
1016
|
};
|
|
1014
|
-
|
|
1017
|
+
c.push({ id: p.id, params: J }), u.push({ id: p.id, params: Ie });
|
|
1015
1018
|
}
|
|
1016
|
-
if (!((
|
|
1017
|
-
const
|
|
1018
|
-
unitId:
|
|
1019
|
-
subUnitId:
|
|
1020
|
-
col:
|
|
1019
|
+
if (!((ne = d[m]) != null && ne.filter)) {
|
|
1020
|
+
const J = {
|
|
1021
|
+
unitId: r,
|
|
1022
|
+
subUnitId: n,
|
|
1023
|
+
col: m,
|
|
1021
1024
|
criteria: null
|
|
1022
1025
|
};
|
|
1023
|
-
|
|
1026
|
+
c.push({ id: p.id, params: J }), u.push({ id: p.id, params: { unitId: r, subUnitId: n, col: m, criteria: { ...v.serialize(), colId: m } } });
|
|
1024
1027
|
}
|
|
1025
1028
|
}
|
|
1026
|
-
}),
|
|
1029
|
+
}), l !== w || a !== S) {
|
|
1027
1030
|
const f = {
|
|
1028
|
-
unitId:
|
|
1029
|
-
subUnitId:
|
|
1031
|
+
unitId: r,
|
|
1032
|
+
subUnitId: n,
|
|
1030
1033
|
range: {
|
|
1031
|
-
...
|
|
1032
|
-
startColumn:
|
|
1033
|
-
endColumn:
|
|
1034
|
+
...o,
|
|
1035
|
+
startColumn: w,
|
|
1036
|
+
endColumn: S
|
|
1034
1037
|
}
|
|
1035
1038
|
};
|
|
1036
|
-
|
|
1039
|
+
c.unshift({ id: R.id, params: f }), u.unshift({ id: R.id, params: { range: o, unitId: r, subUnitId: n } });
|
|
1037
1040
|
}
|
|
1038
1041
|
return {
|
|
1039
1042
|
undos: u,
|
|
1040
|
-
redos:
|
|
1043
|
+
redos: c
|
|
1041
1044
|
};
|
|
1042
1045
|
}
|
|
1043
|
-
_handleMoveRowsCommand(
|
|
1044
|
-
var
|
|
1045
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
1046
|
+
_handleMoveRowsCommand(t, e, r) {
|
|
1047
|
+
var f;
|
|
1048
|
+
const n = this._sheetsFilterService.getFilterModel(e, r), s = (f = n == null ? void 0 : n.getRange()) != null ? f : null;
|
|
1046
1049
|
if (!n || !s)
|
|
1047
1050
|
return this._handleNull();
|
|
1048
|
-
const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } =
|
|
1051
|
+
const { startRow: o, endRow: l } = s, { fromRange: a, toRange: c } = t;
|
|
1049
1052
|
if (a.endRow < o && c.startRow <= o || a.startRow > l && c.endRow > l)
|
|
1050
1053
|
return this._handleNull();
|
|
1051
|
-
const
|
|
1052
|
-
for (let
|
|
1053
|
-
|
|
1054
|
-
oldIndex:
|
|
1054
|
+
const u = [], d = [], h = {};
|
|
1055
|
+
for (let m = o; m <= l; m++)
|
|
1056
|
+
h[m] = {
|
|
1057
|
+
oldIndex: m
|
|
1055
1058
|
};
|
|
1056
|
-
const
|
|
1057
|
-
let
|
|
1058
|
-
l >= a.startRow && l <= a.endRow && c.startRow < a.startRow && a.startRow > o && (
|
|
1059
|
-
const
|
|
1059
|
+
const g = o;
|
|
1060
|
+
let _ = l;
|
|
1061
|
+
l >= a.startRow && l <= a.endRow && c.startRow < a.startRow && a.startRow > o && (_ = a.startRow - 1), oe(a.startRow, a.endRow - a.startRow + 1, c.startRow, h);
|
|
1062
|
+
const S = Object.keys(h).map((m) => Number(m)), w = S.find((m) => h[m].oldIndex === _), F = S.find((m) => h[m].oldIndex === g);
|
|
1060
1063
|
if (o !== F || l !== w) {
|
|
1061
|
-
const
|
|
1064
|
+
const m = {
|
|
1062
1065
|
unitId: e,
|
|
1063
|
-
subUnitId:
|
|
1066
|
+
subUnitId: r,
|
|
1064
1067
|
range: {
|
|
1065
1068
|
...s,
|
|
1066
1069
|
startRow: F,
|
|
1067
1070
|
endRow: w
|
|
1068
1071
|
}
|
|
1069
1072
|
};
|
|
1070
|
-
|
|
1073
|
+
u.push({ id: R.id, params: m }, { id: B.id, params: { unitId: e, subUnitId: r } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }, { id: B.id, params: { unitId: e, subUnitId: r } });
|
|
1071
1074
|
}
|
|
1072
1075
|
return {
|
|
1073
|
-
redos:
|
|
1074
|
-
undos:
|
|
1076
|
+
redos: u,
|
|
1077
|
+
undos: d
|
|
1075
1078
|
};
|
|
1076
1079
|
}
|
|
1077
|
-
_handleMoveRangeCommand(
|
|
1078
|
-
const { fromRange: n, toRange: s } =
|
|
1080
|
+
_handleMoveRangeCommand(t, e, r) {
|
|
1081
|
+
const { fromRange: n, toRange: s } = t, o = this._sheetsFilterService.getFilterModel(e, r);
|
|
1079
1082
|
if (!o)
|
|
1080
1083
|
return this._handleNull();
|
|
1081
1084
|
const l = o.getRange();
|
|
1082
1085
|
if (!l)
|
|
1083
1086
|
return this._handleNull();
|
|
1084
1087
|
const a = [], c = [];
|
|
1085
|
-
if (
|
|
1086
|
-
const
|
|
1087
|
-
startRow: s.startRow +
|
|
1088
|
-
startColumn: s.startColumn +
|
|
1089
|
-
endRow: s.startRow +
|
|
1090
|
-
endColumn: s.startColumn +
|
|
1091
|
-
},
|
|
1092
|
-
id:
|
|
1088
|
+
if (ee.contains(n, l)) {
|
|
1089
|
+
const u = l.startRow - n.startRow, d = l.startColumn - n.startColumn, h = {
|
|
1090
|
+
startRow: s.startRow + u,
|
|
1091
|
+
startColumn: s.startColumn + d,
|
|
1092
|
+
endRow: s.startRow + u + (l.endRow - l.startRow),
|
|
1093
|
+
endColumn: s.startColumn + d + (l.endColumn - l.startColumn)
|
|
1094
|
+
}, g = {
|
|
1095
|
+
id: y.id,
|
|
1093
1096
|
params: {
|
|
1094
1097
|
unitId: e,
|
|
1095
|
-
subUnitId:
|
|
1098
|
+
subUnitId: r
|
|
1096
1099
|
}
|
|
1097
|
-
},
|
|
1098
|
-
a.push(
|
|
1100
|
+
}, _ = { id: R.id, params: { unitId: e, subUnitId: r, range: h } }, S = { id: R.id, params: { unitId: e, subUnitId: r, range: l } };
|
|
1101
|
+
a.push(g, _), c.push(g, S);
|
|
1099
1102
|
const w = o.getAllFilterColumns(), F = s.startColumn - n.startColumn;
|
|
1100
|
-
w.forEach((
|
|
1101
|
-
const [
|
|
1102
|
-
v && (a.push({ id: p.id, params: { unitId: e, subUnitId:
|
|
1103
|
+
w.forEach((f) => {
|
|
1104
|
+
const [m, v] = f;
|
|
1105
|
+
v && (a.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m + F, criteria: { ...v.serialize(), colId: m + F } } }), c.push({ id: p.id, params: { unitId: e, subUnitId: r, col: m, criteria: { ...v.serialize(), colId: m } } }));
|
|
1103
1106
|
});
|
|
1104
|
-
} else if (
|
|
1105
|
-
const
|
|
1107
|
+
} else if (ee.intersects(s, l)) {
|
|
1108
|
+
const u = {
|
|
1106
1109
|
...l,
|
|
1107
1110
|
endRow: Math.max(l.endRow, s.endRow)
|
|
1108
1111
|
};
|
|
1109
|
-
a.push({ id:
|
|
1112
|
+
a.push({ id: R.id, params: { unitId: e, subUnitId: r, range: u } }), c.push({ id: R.id, params: { unitId: e, subUnitId: r, range: l } });
|
|
1110
1113
|
}
|
|
1111
1114
|
return {
|
|
1112
1115
|
redos: a,
|
|
1113
1116
|
undos: c
|
|
1114
1117
|
};
|
|
1115
1118
|
}
|
|
1116
|
-
_handleRemoveSheetCommand(
|
|
1117
|
-
const n = this._sheetsFilterService.getFilterModel(e,
|
|
1119
|
+
_handleRemoveSheetCommand(t, e, r) {
|
|
1120
|
+
const n = this._sheetsFilterService.getFilterModel(e, r);
|
|
1118
1121
|
if (!n)
|
|
1119
1122
|
return this._handleNull();
|
|
1120
1123
|
const s = n.getRange();
|
|
1121
1124
|
if (!s)
|
|
1122
1125
|
return this._handleNull();
|
|
1123
1126
|
const o = [], l = [];
|
|
1124
|
-
return n.getAllFilterColumns().forEach(([c,
|
|
1125
|
-
l.push({ id: p.id, params: { unitId: e, subUnitId:
|
|
1126
|
-
}), o.push({ id:
|
|
1127
|
+
return n.getAllFilterColumns().forEach(([c, u]) => {
|
|
1128
|
+
l.push({ id: p.id, params: { unitId: e, subUnitId: r, col: c, criteria: { ...u.serialize(), colId: c } } });
|
|
1129
|
+
}), o.push({ id: y.id, params: { unitId: e, subUnitId: r, range: s } }), l.unshift({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }), {
|
|
1127
1130
|
undos: l,
|
|
1128
1131
|
redos: o
|
|
1129
1132
|
};
|
|
1130
1133
|
}
|
|
1131
|
-
_handleCopySheetCommand(
|
|
1132
|
-
const n = this._sheetsFilterService.getFilterModel(
|
|
1134
|
+
_handleCopySheetCommand(t, e, r) {
|
|
1135
|
+
const n = this._sheetsFilterService.getFilterModel(t, e);
|
|
1133
1136
|
if (!n)
|
|
1134
1137
|
return this._handleNull();
|
|
1135
1138
|
const s = n.getRange();
|
|
1136
1139
|
if (!s)
|
|
1137
1140
|
return this._handleNull();
|
|
1138
1141
|
const o = [], l = [], a = [], c = [];
|
|
1139
|
-
return n.getAllFilterColumns().forEach(([
|
|
1140
|
-
o.push({ id: p.id, params: { unitId:
|
|
1141
|
-
}), a.push({ id:
|
|
1142
|
+
return n.getAllFilterColumns().forEach(([d, h]) => {
|
|
1143
|
+
o.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: { ...h.serialize(), colId: d } } }), a.push({ id: p.id, params: { unitId: t, subUnitId: r, col: d, criteria: null } });
|
|
1144
|
+
}), a.push({ id: y.id, params: { unitId: t, subUnitId: r, range: s } }), o.unshift({ id: R.id, params: { range: s, unitId: t, subUnitId: r } }), {
|
|
1142
1145
|
undos: l,
|
|
1143
1146
|
redos: o,
|
|
1144
1147
|
preUndos: a,
|
|
@@ -1149,54 +1152,54 @@ let k = class extends B {
|
|
|
1149
1152
|
return { redos: [], undos: [] };
|
|
1150
1153
|
}
|
|
1151
1154
|
_initRowFilteredInterceptor() {
|
|
1152
|
-
this.disposeWithMe(this._sheetInterceptorService.intercept(
|
|
1155
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(et.ROW_FILTERED, {
|
|
1153
1156
|
// sheet-interceptor.service.ts
|
|
1154
|
-
handler: (
|
|
1155
|
-
var
|
|
1156
|
-
return
|
|
1157
|
+
handler: (t, e) => {
|
|
1158
|
+
var r, n;
|
|
1159
|
+
return t ? !0 : (n = (r = this._sheetsFilterService.getFilterModel(
|
|
1157
1160
|
e.unitId,
|
|
1158
1161
|
e.subUnitId
|
|
1159
|
-
)) == null ? void 0 :
|
|
1162
|
+
)) == null ? void 0 : r.isRowFiltered(e.row)) != null ? n : !1;
|
|
1160
1163
|
}
|
|
1161
1164
|
}));
|
|
1162
1165
|
}
|
|
1163
|
-
_moveCriteria(
|
|
1166
|
+
_moveCriteria(t, e, r, n) {
|
|
1164
1167
|
const s = {
|
|
1165
|
-
unitId:
|
|
1168
|
+
unitId: t,
|
|
1166
1169
|
subUnitId: e,
|
|
1167
1170
|
criteria: null,
|
|
1168
1171
|
col: -1
|
|
1169
1172
|
}, o = [], l = [], a = [], c = [];
|
|
1170
|
-
return
|
|
1171
|
-
const [
|
|
1173
|
+
return r.forEach((u) => {
|
|
1174
|
+
const [d, h] = u;
|
|
1172
1175
|
l.push({
|
|
1173
1176
|
id: p.id,
|
|
1174
1177
|
params: {
|
|
1175
1178
|
...s,
|
|
1176
|
-
col:
|
|
1179
|
+
col: d
|
|
1177
1180
|
}
|
|
1178
1181
|
}), o.push({
|
|
1179
1182
|
id: p.id,
|
|
1180
1183
|
params: {
|
|
1181
1184
|
...s,
|
|
1182
|
-
col:
|
|
1183
|
-
criteria: { ...
|
|
1185
|
+
col: d,
|
|
1186
|
+
criteria: { ...h.serialize(), colId: d }
|
|
1184
1187
|
}
|
|
1185
1188
|
});
|
|
1186
|
-
}),
|
|
1187
|
-
const [
|
|
1189
|
+
}), r.forEach((u) => {
|
|
1190
|
+
const [d, h] = u;
|
|
1188
1191
|
c.push({
|
|
1189
1192
|
id: p.id,
|
|
1190
1193
|
params: {
|
|
1191
1194
|
...s,
|
|
1192
|
-
col:
|
|
1193
|
-
criteria: { ...
|
|
1195
|
+
col: d + n,
|
|
1196
|
+
criteria: { ...h.serialize(), colId: d + n }
|
|
1194
1197
|
}
|
|
1195
1198
|
}), a.push({
|
|
1196
1199
|
id: p.id,
|
|
1197
1200
|
params: {
|
|
1198
1201
|
...s,
|
|
1199
|
-
col:
|
|
1202
|
+
col: d + n,
|
|
1200
1203
|
criteria: null
|
|
1201
1204
|
}
|
|
1202
1205
|
});
|
|
@@ -1212,45 +1215,45 @@ let k = class extends B {
|
|
|
1212
1215
|
};
|
|
1213
1216
|
}
|
|
1214
1217
|
_commandExecutedListener() {
|
|
1215
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
1216
|
-
var c,
|
|
1217
|
-
const { unitId:
|
|
1218
|
+
this.disposeWithMe(this._commandService.onCommandExecuted((t, e) => {
|
|
1219
|
+
var c, u;
|
|
1220
|
+
const { unitId: r, subUnitId: n } = t.params || {}, s = this._sheetsFilterService.getFilterModel(r, n);
|
|
1218
1221
|
if (!s) return;
|
|
1219
|
-
const o = Array.from(s.filteredOutRows).sort((
|
|
1222
|
+
const o = Array.from(s.filteredOutRows).sort((d, h) => d - h), l = [];
|
|
1220
1223
|
let a = !1;
|
|
1221
|
-
if (
|
|
1222
|
-
const { startRow:
|
|
1223
|
-
o.forEach((
|
|
1224
|
-
if (
|
|
1225
|
-
l.push(
|
|
1226
|
-
else if (a = !0,
|
|
1227
|
-
const
|
|
1228
|
-
l.push(
|
|
1224
|
+
if (t.id === tt.id) {
|
|
1225
|
+
const { startRow: d, endRow: h } = t.params.range, g = o.filter((_) => _ >= d && _ <= h);
|
|
1226
|
+
o.forEach((_) => {
|
|
1227
|
+
if (_ < d)
|
|
1228
|
+
l.push(_);
|
|
1229
|
+
else if (a = !0, _ <= h) {
|
|
1230
|
+
const S = Math.max(d, l.length ? l[l.length - 1] + 1 : d);
|
|
1231
|
+
l.push(S);
|
|
1229
1232
|
} else
|
|
1230
|
-
l.push(
|
|
1233
|
+
l.push(_ - (h - d + 1 - g.length));
|
|
1231
1234
|
});
|
|
1232
1235
|
}
|
|
1233
|
-
if (
|
|
1234
|
-
const { startRow:
|
|
1235
|
-
o.forEach((
|
|
1236
|
-
|
|
1236
|
+
if (t.id === rt.id) {
|
|
1237
|
+
const { startRow: d, endRow: h } = t.params.range;
|
|
1238
|
+
o.forEach((g) => {
|
|
1239
|
+
g >= d ? (a = !0, l.push(g + (h - d + 1))) : l.push(g);
|
|
1237
1240
|
});
|
|
1238
1241
|
}
|
|
1239
|
-
if (a && (s.filteredOutRows = new Set(l)),
|
|
1240
|
-
const
|
|
1241
|
-
if (
|
|
1242
|
-
const
|
|
1243
|
-
if (
|
|
1244
|
-
for (let
|
|
1245
|
-
const
|
|
1246
|
-
if (
|
|
1247
|
-
const
|
|
1248
|
-
if (
|
|
1249
|
-
const w =
|
|
1242
|
+
if (a && (s.filteredOutRows = new Set(l)), t.id === nt.id && !(e != null && e.onlyLocal)) {
|
|
1243
|
+
const d = this._getExtendRegion(r, n);
|
|
1244
|
+
if (d) {
|
|
1245
|
+
const h = t.params.cellValue;
|
|
1246
|
+
if (h)
|
|
1247
|
+
for (let g = d.startColumn; g <= d.endColumn; g++) {
|
|
1248
|
+
const _ = (c = h == null ? void 0 : h[d.startRow]) == null ? void 0 : c[g];
|
|
1249
|
+
if (_ && this._cellHasValue(_)) {
|
|
1250
|
+
const S = (u = this._univerInstanceService.getUnit(r)) == null ? void 0 : u.getSheetBySheetId(n);
|
|
1251
|
+
if (S) {
|
|
1252
|
+
const w = _e(d, { down: !0 }, S), F = this._sheetsFilterService.getFilterModel(r, n), f = F.getRange();
|
|
1250
1253
|
F.setRange({
|
|
1251
|
-
...
|
|
1254
|
+
...f,
|
|
1252
1255
|
endRow: w.endRow
|
|
1253
|
-
}), this._registerRefRange(
|
|
1256
|
+
}), this._registerRefRange(r, n);
|
|
1254
1257
|
}
|
|
1255
1258
|
}
|
|
1256
1259
|
}
|
|
@@ -1258,15 +1261,15 @@ let k = class extends B {
|
|
|
1258
1261
|
}
|
|
1259
1262
|
}));
|
|
1260
1263
|
}
|
|
1261
|
-
_getExtendRegion(
|
|
1264
|
+
_getExtendRegion(t, e) {
|
|
1262
1265
|
var a;
|
|
1263
|
-
const
|
|
1264
|
-
if (!
|
|
1266
|
+
const r = this._sheetsFilterService.getFilterModel(t, e);
|
|
1267
|
+
if (!r)
|
|
1265
1268
|
return null;
|
|
1266
|
-
const n = (a = this._univerInstanceService.getUnit(
|
|
1269
|
+
const n = (a = this._univerInstanceService.getUnit(t)) == null ? void 0 : a.getSheetBySheetId(e);
|
|
1267
1270
|
if (!n)
|
|
1268
1271
|
return null;
|
|
1269
|
-
const s =
|
|
1272
|
+
const s = r.getRange();
|
|
1270
1273
|
if (!s)
|
|
1271
1274
|
return null;
|
|
1272
1275
|
const o = n.getRowCount() - 1, l = n.getRowManager();
|
|
@@ -1281,51 +1284,113 @@ let k = class extends B {
|
|
|
1281
1284
|
return null;
|
|
1282
1285
|
}
|
|
1283
1286
|
_initErrorHandling() {
|
|
1284
|
-
this.disposeWithMe(this._commandService.beforeCommandExecuted((
|
|
1285
|
-
const e =
|
|
1286
|
-
if (!
|
|
1287
|
-
const { subUnitId: n, unitId: s } =
|
|
1287
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((t) => {
|
|
1288
|
+
const e = t.params, r = H(this._univerInstanceService);
|
|
1289
|
+
if (!r) return;
|
|
1290
|
+
const { subUnitId: n, unitId: s } = r, o = this._sheetsFilterService.getFilterModel(s, n);
|
|
1288
1291
|
if (!o) return;
|
|
1289
1292
|
const l = o.getRange();
|
|
1290
|
-
if (
|
|
1293
|
+
if (t.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
|
|
1291
1294
|
throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
|
|
1292
1295
|
}));
|
|
1293
1296
|
}
|
|
1294
|
-
_cellHasValue(
|
|
1295
|
-
const e = Object.values(
|
|
1296
|
-
return !(e.length === 0 || e.every((
|
|
1297
|
+
_cellHasValue(t) {
|
|
1298
|
+
const e = Object.values(t);
|
|
1299
|
+
return !(e.length === 0 || e.every((r) => r == null));
|
|
1297
1300
|
}
|
|
1298
1301
|
};
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
],
|
|
1308
|
-
var
|
|
1309
|
-
for (var n =
|
|
1302
|
+
z = qt([
|
|
1303
|
+
I(0, T),
|
|
1304
|
+
I(1, A(Qe)),
|
|
1305
|
+
I(2, A(M)),
|
|
1306
|
+
I(3, N),
|
|
1307
|
+
I(4, A(Je)),
|
|
1308
|
+
I(5, He(gt)),
|
|
1309
|
+
I(6, A(Ze))
|
|
1310
|
+
], z);
|
|
1311
|
+
var Gt = Object.getOwnPropertyDescriptor, Qt = (i, t, e, r) => {
|
|
1312
|
+
for (var n = r > 1 ? void 0 : r ? Gt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1310
1313
|
(o = i[s]) && (n = o(n) || n);
|
|
1311
1314
|
return n;
|
|
1312
|
-
},
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1315
|
+
}, X = (i, t) => (e, r) => t(e, r, i);
|
|
1316
|
+
const Jt = [
|
|
1317
|
+
p.id,
|
|
1318
|
+
B.id
|
|
1319
|
+
], Zt = [
|
|
1320
|
+
Ce.id,
|
|
1321
|
+
Re.id,
|
|
1322
|
+
pe.id
|
|
1323
|
+
];
|
|
1324
|
+
let q = class extends U {
|
|
1325
|
+
constructor(t, e, r) {
|
|
1326
|
+
super();
|
|
1327
|
+
C(this, "_d", new me());
|
|
1328
|
+
C(this, "_visible$", new $(!1));
|
|
1329
|
+
C(this, "visible$", this._visible$.asObservable());
|
|
1330
|
+
C(this, "_enabled$", new $(!0));
|
|
1331
|
+
C(this, "enabled$", this._enabled$.asObservable());
|
|
1332
|
+
this._sheetsFilterController = t, this._commandService = e, this._configService = r;
|
|
1333
|
+
const n = this._configService.getConfig(xe);
|
|
1334
|
+
n != null && n.enableSyncSwitch && this._visible$.next(!0);
|
|
1335
|
+
}
|
|
1336
|
+
get visible() {
|
|
1337
|
+
return this._visible$.getValue();
|
|
1338
|
+
}
|
|
1339
|
+
get enabled() {
|
|
1340
|
+
return this._enabled$.getValue();
|
|
1341
|
+
}
|
|
1342
|
+
setEnabled(t) {
|
|
1343
|
+
this._enabled$.next(t), t ? this._d.dispose() : this._initOnlyLocalListener();
|
|
1344
|
+
}
|
|
1345
|
+
_initOnlyLocalListener() {
|
|
1346
|
+
this._d.add(
|
|
1347
|
+
this._commandService.beforeCommandExecuted((t, e) => {
|
|
1348
|
+
Jt.includes(t.id) && (e || (e = {}), e.onlyLocal = !0);
|
|
1349
|
+
})
|
|
1350
|
+
), this._d.add(
|
|
1351
|
+
this._commandService.onCommandExecuted((t, e) => {
|
|
1352
|
+
if (Zt.includes(t.id) && (e != null && e.fromCollab)) {
|
|
1353
|
+
if (t.id === Ce.id) {
|
|
1354
|
+
const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(r, n, s);
|
|
1355
|
+
j(o, this._commandService, e);
|
|
1356
|
+
} else if (t.id === Re.id) {
|
|
1357
|
+
const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(r, n, s);
|
|
1358
|
+
j(o, this._commandService, e);
|
|
1359
|
+
} else if (t.id === pe.id) {
|
|
1360
|
+
const { sourceRange: r, targetRange: n, unitId: s, subUnitId: o } = t.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: r, toRange: n }, s, o);
|
|
1361
|
+
j(l, this._commandService, e);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
})
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
q = Qt([
|
|
1369
|
+
X(0, A(z)),
|
|
1370
|
+
X(1, T),
|
|
1371
|
+
X(2, ge)
|
|
1372
|
+
], q);
|
|
1373
|
+
var Kt = Object.getOwnPropertyDescriptor, Yt = (i, t, e, r) => {
|
|
1374
|
+
for (var n = r > 1 ? void 0 : r ? Kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1375
|
+
(o = i[s]) && (n = o(n) || n);
|
|
1376
|
+
return n;
|
|
1377
|
+
}, V = (i, t) => (e, r) => t(e, r, i);
|
|
1378
|
+
let G = class extends U {
|
|
1379
|
+
constructor(i, t, e, r) {
|
|
1380
|
+
super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = t, this._sheetsFilterService = e, this._univerInstanceService = r, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
|
|
1316
1381
|
}
|
|
1317
1382
|
_initFormulaDirtyRange() {
|
|
1318
|
-
|
|
1383
|
+
Me.forEach((i) => {
|
|
1319
1384
|
this._activeDirtyManagerService.register(
|
|
1320
1385
|
i,
|
|
1321
1386
|
{
|
|
1322
1387
|
commandId: i,
|
|
1323
|
-
getDirtyData: (
|
|
1324
|
-
const e =
|
|
1388
|
+
getDirtyData: (t) => {
|
|
1389
|
+
const e = t.params, { unitId: r, subUnitId: n } = e;
|
|
1325
1390
|
return {
|
|
1326
|
-
dirtyRanges: this._getHideRowMutation(
|
|
1391
|
+
dirtyRanges: this._getHideRowMutation(r, n),
|
|
1327
1392
|
clearDependencyTreeCache: {
|
|
1328
|
-
[
|
|
1393
|
+
[r]: {
|
|
1329
1394
|
[n]: "1"
|
|
1330
1395
|
}
|
|
1331
1396
|
}
|
|
@@ -1335,93 +1400,96 @@ let q = class extends B {
|
|
|
1335
1400
|
);
|
|
1336
1401
|
});
|
|
1337
1402
|
}
|
|
1338
|
-
_getHideRowMutation(i,
|
|
1403
|
+
_getHideRowMutation(i, t) {
|
|
1339
1404
|
var l, a;
|
|
1340
|
-
const e = (l = this._sheetsFilterService.getFilterModel(i,
|
|
1341
|
-
if (e == null ||
|
|
1405
|
+
const e = (l = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : l.getRange(), r = (a = this._univerInstanceService.getUnit(i)) == null ? void 0 : a.getSheetBySheetId(t);
|
|
1406
|
+
if (e == null || r == null)
|
|
1342
1407
|
return [];
|
|
1343
1408
|
const { startRow: n, endRow: s } = e;
|
|
1344
1409
|
return [{
|
|
1345
1410
|
unitId: i,
|
|
1346
|
-
sheetId:
|
|
1411
|
+
sheetId: t,
|
|
1347
1412
|
range: {
|
|
1348
1413
|
startRow: n,
|
|
1349
1414
|
startColumn: 0,
|
|
1350
1415
|
endRow: s,
|
|
1351
|
-
endColumn:
|
|
1416
|
+
endColumn: r.getColumnCount() - 1
|
|
1352
1417
|
}
|
|
1353
1418
|
}];
|
|
1354
1419
|
}
|
|
1355
1420
|
_registerSheetRowFiltered() {
|
|
1356
|
-
this._sheetRowFilteredService.register((i,
|
|
1357
|
-
var
|
|
1358
|
-
return (n = (
|
|
1421
|
+
this._sheetRowFilteredService.register((i, t, e) => {
|
|
1422
|
+
var r, n;
|
|
1423
|
+
return (n = (r = this._sheetsFilterService.getFilterModel(i, t)) == null ? void 0 : r.isRowFiltered(e)) != null ? n : !1;
|
|
1359
1424
|
});
|
|
1360
1425
|
}
|
|
1361
1426
|
};
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
],
|
|
1368
|
-
var
|
|
1369
|
-
for (var n =
|
|
1427
|
+
G = Yt([
|
|
1428
|
+
V(0, A(_t)),
|
|
1429
|
+
V(1, A(Ct)),
|
|
1430
|
+
V(2, A(M)),
|
|
1431
|
+
V(3, N)
|
|
1432
|
+
], G);
|
|
1433
|
+
var Xt = Object.getOwnPropertyDescriptor, er = (i, t, e, r) => {
|
|
1434
|
+
for (var n = r > 1 ? void 0 : r ? Xt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
|
|
1370
1435
|
(o = i[s]) && (n = o(n) || n);
|
|
1371
1436
|
return n;
|
|
1372
|
-
},
|
|
1373
|
-
let
|
|
1374
|
-
constructor(i =
|
|
1375
|
-
super(), this._config = i, this._injector =
|
|
1376
|
-
const { ...
|
|
1437
|
+
}, he = (i, t) => (e, r) => t(e, r, i), W;
|
|
1438
|
+
let fe = (W = class extends Ve {
|
|
1439
|
+
constructor(i = ue, t, e) {
|
|
1440
|
+
super(), this._config = i, this._injector = t, this._configService = e;
|
|
1441
|
+
const { ...r } = We(
|
|
1377
1442
|
{},
|
|
1378
|
-
|
|
1443
|
+
ue,
|
|
1379
1444
|
this._config
|
|
1380
1445
|
);
|
|
1381
|
-
this._configService.setConfig(
|
|
1446
|
+
this._configService.setConfig(xe, r);
|
|
1382
1447
|
}
|
|
1383
1448
|
onStarting() {
|
|
1384
1449
|
[
|
|
1385
|
-
[
|
|
1450
|
+
[G],
|
|
1386
1451
|
[M],
|
|
1387
|
-
[
|
|
1452
|
+
[z],
|
|
1453
|
+
[q]
|
|
1388
1454
|
].forEach((i) => this._injector.add(i));
|
|
1389
1455
|
}
|
|
1390
1456
|
onReady() {
|
|
1391
|
-
|
|
1392
|
-
[
|
|
1393
|
-
[
|
|
1457
|
+
je(this._injector, [
|
|
1458
|
+
[G],
|
|
1459
|
+
[z],
|
|
1460
|
+
[q]
|
|
1394
1461
|
]);
|
|
1395
1462
|
}
|
|
1396
|
-
},
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
],
|
|
1463
|
+
}, C(W, "type", D.UNIVER_SHEET), C(W, "pluginName", Te), W);
|
|
1464
|
+
fe = er([
|
|
1465
|
+
he(1, A(ke)),
|
|
1466
|
+
he(2, ge)
|
|
1467
|
+
], fe);
|
|
1401
1468
|
export {
|
|
1402
|
-
|
|
1469
|
+
dr as ClearSheetsFilterCriteriaCommand,
|
|
1403
1470
|
x as CustomFilterOperator,
|
|
1404
|
-
|
|
1471
|
+
Me as FILTER_MUTATIONS,
|
|
1405
1472
|
b as FilterBy,
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1473
|
+
yt as FilterColumn,
|
|
1474
|
+
k as FilterModel,
|
|
1475
|
+
ur as ReCalcSheetsFilterCommand,
|
|
1476
|
+
B as ReCalcSheetsFilterMutation,
|
|
1477
|
+
zt as RemoveSheetFilterCommand,
|
|
1478
|
+
y as RemoveSheetsFilterMutation,
|
|
1479
|
+
Te as SHEET_FILTER_SNAPSHOT_ID,
|
|
1480
|
+
Bt as SetSheetFilterRangeCommand,
|
|
1481
|
+
cr as SetSheetsFilterCriteriaCommand,
|
|
1415
1482
|
p as SetSheetsFilterCriteriaMutation,
|
|
1416
|
-
|
|
1483
|
+
R as SetSheetsFilterRangeMutation,
|
|
1417
1484
|
M as SheetsFilterService,
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1485
|
+
q as SheetsFilterSyncController,
|
|
1486
|
+
ar as SmartToggleSheetsFilterCommand,
|
|
1487
|
+
fe as UniverSheetsFilterPlugin,
|
|
1488
|
+
wt as equals,
|
|
1489
|
+
ae as getCustomFilterFn,
|
|
1490
|
+
Rt as greaterThan,
|
|
1491
|
+
pt as greaterThanOrEqualTo,
|
|
1492
|
+
St as lessThan,
|
|
1493
|
+
Ft as lessThanOrEqualTo,
|
|
1494
|
+
Ee as notEquals
|
|
1427
1495
|
};
|