@univerjs/sheets-filter 0.1.11 → 0.1.13
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/es/index.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { isNumeric as
|
|
5
|
-
import { Inject as
|
|
6
|
-
import { BehaviorSubject as
|
|
7
|
-
import { SheetInterceptorService as Se, RefRangeService as
|
|
8
|
-
var
|
|
9
|
-
const
|
|
10
|
-
operator:
|
|
11
|
-
fn: (s, r) =>
|
|
12
|
-
}, Le = {
|
|
13
|
-
operator: E.GREATER_THAN_OR_EQUAL,
|
|
14
|
-
fn: (s, r) => A(s) ? s >= r : !1
|
|
15
|
-
}, Be = {
|
|
16
|
-
operator: E.LESS_THAN,
|
|
17
|
-
fn: (s, r) => A(s) ? s < r : !1
|
|
1
|
+
var ue = Object.defineProperty;
|
|
2
|
+
var de = (s, r, e) => r in s ? ue(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var g = (s, r, e) => (de(s, typeof r != "symbol" ? r + "" : r, e), e);
|
|
4
|
+
import { isNumeric as he, Disposable as b, Rectangle as k, mergeSets as z, Tools as q, extractPureTextFromCell as fe, CellValueType as j, CommandType as $, UniverInstanceType as V, fromCallback as me, OnLifecycle as ee, LifecycleStages as te, IResourceManagerService as _e, IUniverInstanceService as re, ICommandService as se, DisposableCollection as ge, moveMatrixArray as G, Plugin as Ce } from "@univerjs/core";
|
|
5
|
+
import { Inject as P, Injector as Re } from "@wendellhu/redi";
|
|
6
|
+
import { BehaviorSubject as x, merge as pe, filter as we, switchMap as Fe, of as ve } from "rxjs";
|
|
7
|
+
import { SheetInterceptorService as Se, RefRangeService as Me, SetWorksheetActivateCommand as Ee, RemoveSheetCommand as Oe, INTERCEPTOR_POINT as ye, RemoveRowMutation as Ae, InsertRowMutation as Te, getSheetCommandTarget as Ne, MoveRowsCommand as xe, MoveRangeCommand as $e, EffectRefRangId as J, RemoveRowCommand as Ie, RemoveColCommand as Pe, InsertColCommand as Le, InsertRowCommand as Be } from "@univerjs/sheets";
|
|
8
|
+
var O = /* @__PURE__ */ ((s) => (s.EQUAL = "equal", s.GREATER_THAN = "greaterThan", s.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", s.LESS_THAN = "lessThan", s.LESS_THAN_OR_EQUAL = "lessThanOrEqual", s.NOT_EQUALS = "notEqual", s))(O || {});
|
|
9
|
+
const be = {
|
|
10
|
+
operator: O.GREATER_THAN,
|
|
11
|
+
fn: (s, r) => T(s) ? s > r : !1
|
|
18
12
|
}, Ue = {
|
|
19
|
-
operator:
|
|
20
|
-
fn: (s, r) =>
|
|
13
|
+
operator: O.GREATER_THAN_OR_EQUAL,
|
|
14
|
+
fn: (s, r) => T(s) ? s >= r : !1
|
|
21
15
|
}, ze = {
|
|
22
|
-
operator:
|
|
23
|
-
fn: (s, r) =>
|
|
24
|
-
},
|
|
25
|
-
operator:
|
|
16
|
+
operator: O.LESS_THAN,
|
|
17
|
+
fn: (s, r) => T(s) ? s < r : !1
|
|
18
|
+
}, He = {
|
|
19
|
+
operator: O.LESS_THAN_OR_EQUAL,
|
|
20
|
+
fn: (s, r) => T(s) ? s <= r : !1
|
|
21
|
+
}, We = {
|
|
22
|
+
operator: O.EQUAL,
|
|
23
|
+
fn: (s, r) => T(s) ? s === r : !1
|
|
24
|
+
}, ne = {
|
|
25
|
+
operator: O.NOT_EQUALS,
|
|
26
26
|
fn: (s, r) => {
|
|
27
27
|
if (typeof r == "string") {
|
|
28
28
|
if (r === " ")
|
|
29
29
|
return s != null;
|
|
30
|
-
const e =
|
|
31
|
-
return e &&
|
|
30
|
+
const e = oe(s);
|
|
31
|
+
return e && Qe(r) ? !le(r).test(e) : e !== r;
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return T(s) ? s !== r : !0;
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
}, ie = /* @__PURE__ */ new Map([]), je = [be, Ue, ze, He, We, ne];
|
|
36
|
+
je.forEach((s) => {
|
|
37
|
+
ie.set(s.operator, s);
|
|
38
38
|
});
|
|
39
|
-
function
|
|
39
|
+
function Ve(s) {
|
|
40
40
|
return !!s;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const De = {
|
|
43
43
|
fn: (s, r) => {
|
|
44
|
-
const e =
|
|
45
|
-
return e === null ? r === "" :
|
|
44
|
+
const e = oe(s);
|
|
45
|
+
return e === null ? r === "" : le(r).test(e);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
function
|
|
49
|
-
return s ?
|
|
48
|
+
function X(s) {
|
|
49
|
+
return s ? ie.get(s) : De;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function T(s) {
|
|
52
52
|
return typeof s == "number";
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return !!(typeof s == "number" || typeof s == "string" &&
|
|
54
|
+
function Y(s) {
|
|
55
|
+
return !!(typeof s == "number" || typeof s == "string" && he(s));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function oe(s) {
|
|
58
58
|
return typeof s == "boolean" || s == null ? null : typeof s == "string" ? s : s.toString();
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Qe(s) {
|
|
61
61
|
return typeof s == "number" ? !1 : s.indexOf("*") !== -1 || s.indexOf("?") !== -1;
|
|
62
62
|
}
|
|
63
|
-
function
|
|
63
|
+
function le(s) {
|
|
64
64
|
const r = s.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("?", ".").replace(/[*]/g, ".$&");
|
|
65
65
|
return new RegExp(`^${r}$`);
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
class
|
|
67
|
+
const H = () => /* @__PURE__ */ new Set();
|
|
68
|
+
class B extends b {
|
|
69
69
|
constructor(e, t, n) {
|
|
70
70
|
super();
|
|
71
|
-
|
|
71
|
+
g(this, "_filteredOutRows$", new x(H()));
|
|
72
72
|
/** An observable value. A set of filtered out rows. */
|
|
73
|
-
|
|
73
|
+
g(this, "filteredOutRows$", this._filteredOutRows$.asObservable());
|
|
74
74
|
// TODO: we may need to update which cols have criteria rather than simple boolean
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
g(this, "_hasCriteria$", new x(!1));
|
|
76
|
+
g(this, "hasCriteria$", this._hasCriteria$.asObservable());
|
|
77
|
+
g(this, "_filterColumnByIndex", /* @__PURE__ */ new Map());
|
|
78
|
+
g(this, "_alreadyFilteredOutRows", H());
|
|
79
|
+
g(this, "_range");
|
|
80
80
|
this.unitId = e, this.subUnitId = t, this._worksheet = n;
|
|
81
81
|
}
|
|
82
82
|
get filteredOutRows() {
|
|
@@ -93,7 +93,7 @@ class L extends B {
|
|
|
93
93
|
*/
|
|
94
94
|
serialize() {
|
|
95
95
|
const e = {
|
|
96
|
-
ref:
|
|
96
|
+
ref: k.clone(this._range),
|
|
97
97
|
filterColumns: this._getAllFilterColumns(!0).sort(([t], [n]) => t - n).map(([t, n]) => n.serialize())
|
|
98
98
|
};
|
|
99
99
|
return this._alreadyFilteredOutRows && (e.cachedFilteredOut = Array.from(this._alreadyFilteredOutRows).sort()), e;
|
|
@@ -106,7 +106,7 @@ class L extends B {
|
|
|
106
106
|
* @param autoFilter auto filter data
|
|
107
107
|
*/
|
|
108
108
|
static deserialize(e, t, n, i) {
|
|
109
|
-
const o = new
|
|
109
|
+
const o = new B(e, t, n);
|
|
110
110
|
return o._dump(i), o;
|
|
111
111
|
}
|
|
112
112
|
_dump(e) {
|
|
@@ -129,7 +129,7 @@ class L extends B {
|
|
|
129
129
|
getFilteredOutRowsExceptCol(e) {
|
|
130
130
|
return this._getAllFilterColumns(!0).filter(([t]) => t !== e).reduce((t, [, n]) => {
|
|
131
131
|
const i = n.calc({ getAlreadyFilteredOutRows: () => t });
|
|
132
|
-
return i ?
|
|
132
|
+
return i ? z(t, i) : t;
|
|
133
133
|
}, /* @__PURE__ */ new Set());
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
@@ -173,7 +173,7 @@ class L extends B {
|
|
|
173
173
|
return e ? t : t.map(([n, i]) => i);
|
|
174
174
|
}
|
|
175
175
|
_reCalcAllColumns() {
|
|
176
|
-
this._alreadyFilteredOutRows =
|
|
176
|
+
this._alreadyFilteredOutRows = H(), this._getAllFilterColumns().forEach((e) => e.__clearCache()), this._reCalcWithNoCacheColumns();
|
|
177
177
|
}
|
|
178
178
|
_setCriteriaWithoutReCalc(e, t) {
|
|
179
179
|
const n = this._range;
|
|
@@ -183,7 +183,7 @@ class L extends B {
|
|
|
183
183
|
if (e > o || e < i)
|
|
184
184
|
throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
|
|
185
185
|
let l;
|
|
186
|
-
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new
|
|
186
|
+
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new qe(
|
|
187
187
|
this.unitId,
|
|
188
188
|
this.subUnitId,
|
|
189
189
|
this._worksheet,
|
|
@@ -202,26 +202,26 @@ class L extends B {
|
|
|
202
202
|
this._hasCriteria$.next(this._filterColumnByIndex.size > 0);
|
|
203
203
|
}
|
|
204
204
|
_rebuildAlreadyFilteredOutRowsWithCache() {
|
|
205
|
-
const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) =>
|
|
205
|
+
const e = this._getAllFilterColumns().filter((t) => t.hasCache()).reduce((t, n) => z(t, n.filteredOutRows), /* @__PURE__ */ new Set());
|
|
206
206
|
this._alreadyFilteredOutRows = e;
|
|
207
207
|
}
|
|
208
208
|
_reCalcWithNoCacheColumns() {
|
|
209
209
|
const e = this._getAllFilterColumns().filter((t) => !t.hasCache());
|
|
210
210
|
for (const t of e) {
|
|
211
211
|
const n = t.reCalc();
|
|
212
|
-
n && (this._alreadyFilteredOutRows =
|
|
212
|
+
n && (this._alreadyFilteredOutRows = z(this._alreadyFilteredOutRows, n));
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
class
|
|
216
|
+
class qe extends b {
|
|
217
217
|
constructor(e, t, n, i, o) {
|
|
218
218
|
super();
|
|
219
|
-
|
|
219
|
+
g(this, "_filteredOutRows", null);
|
|
220
220
|
/** Cache the filter function. */
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
g(this, "_filterFn", null);
|
|
222
|
+
g(this, "_range", null);
|
|
223
|
+
g(this, "_column", 0);
|
|
224
|
+
g(this, "_filterByValues", !1);
|
|
225
225
|
this.unitId = e, this.subUnitId = t, this._worksheet = n, this._criteria = i, this._filterColumnContext = o;
|
|
226
226
|
}
|
|
227
227
|
get filteredOutRows() {
|
|
@@ -239,7 +239,7 @@ class Ve extends B {
|
|
|
239
239
|
serialize() {
|
|
240
240
|
if (!this._criteria)
|
|
241
241
|
throw new Error("[FilterColumn]: could not serialize without a filter column!");
|
|
242
|
-
return
|
|
242
|
+
return q.deepClone({
|
|
243
243
|
...this._criteria,
|
|
244
244
|
colId: this._column
|
|
245
245
|
});
|
|
@@ -255,7 +255,7 @@ class Ve extends B {
|
|
|
255
255
|
this._criteria = e, this._generateFilterFn(), this._filteredOutRows = null;
|
|
256
256
|
}
|
|
257
257
|
getColumnData() {
|
|
258
|
-
return
|
|
258
|
+
return q.deepClone(this._criteria);
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
261
261
|
* Trigger new calculation on this `FilterModel` instance.
|
|
@@ -278,120 +278,122 @@ class Ve extends B {
|
|
|
278
278
|
const { row: a, rowSpan: u, col: c } = l;
|
|
279
279
|
if (o.has(a) && (!u || u === 1))
|
|
280
280
|
continue;
|
|
281
|
-
const h = this._filterByValues ?
|
|
281
|
+
const h = this._filterByValues ? fe(this._worksheet.getCell(a, c)) : et(this._worksheet, a, c);
|
|
282
282
|
if (!this._filterFn(h) && (i.add(a), u))
|
|
283
|
-
for (let
|
|
284
|
-
i.add(a +
|
|
283
|
+
for (let _ = 1; _ < u; _++)
|
|
284
|
+
i.add(a + _);
|
|
285
285
|
}
|
|
286
286
|
return i;
|
|
287
287
|
}
|
|
288
288
|
_generateFilterFn() {
|
|
289
|
-
this._criteria && (this._filterFn =
|
|
289
|
+
this._criteria && (this._filterFn = Ge(this._criteria), this._filterByValues = !!this._criteria.filters);
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function Ge(s) {
|
|
293
293
|
if (s.filters)
|
|
294
|
-
return
|
|
294
|
+
return Je(s.filters);
|
|
295
295
|
if (s.customFilters)
|
|
296
|
-
return
|
|
296
|
+
return Xe(s.customFilters);
|
|
297
297
|
throw new Error("[FilterModel]: other types of filters are not supported yet.");
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function Je(s) {
|
|
300
300
|
const r = !!s.blank, e = new Set(s.filters);
|
|
301
301
|
return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
const r = s.customFilters.map((e) =>
|
|
305
|
-
return
|
|
303
|
+
function Xe(s) {
|
|
304
|
+
const r = s.customFilters.map((e) => ke(e));
|
|
305
|
+
return Ze(r) ? s.and ? Ye(r) : Ke(r) : r[0];
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function Ye(s) {
|
|
308
308
|
const [r, e] = s;
|
|
309
309
|
return (t) => r(t) && e(t);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Ke(s) {
|
|
312
312
|
const [r, e] = s;
|
|
313
313
|
return (t) => r(t) || e(t);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Ze(s) {
|
|
316
316
|
return s.length === 2;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function ke(s) {
|
|
319
319
|
const r = s.val;
|
|
320
|
-
if (s.operator ===
|
|
321
|
-
return (n) =>
|
|
322
|
-
if (
|
|
323
|
-
if (!
|
|
320
|
+
if (s.operator === O.NOT_EQUALS && !Y(r))
|
|
321
|
+
return (n) => ne.fn(n, r);
|
|
322
|
+
if (Ve(s.operator)) {
|
|
323
|
+
if (!Y(r))
|
|
324
324
|
return () => !1;
|
|
325
|
-
const n =
|
|
325
|
+
const n = X(s.operator), i = Number(r);
|
|
326
326
|
return (o) => n.fn(o, i);
|
|
327
327
|
}
|
|
328
|
-
const e =
|
|
328
|
+
const e = X(s.operator);
|
|
329
329
|
return (t) => e.fn(t, r);
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function et(s, r, e) {
|
|
332
332
|
const t = s.getCell(r, e);
|
|
333
333
|
if (!t)
|
|
334
334
|
return null;
|
|
335
335
|
const n = s.getCellRaw(r, e);
|
|
336
|
-
return t && !n ?
|
|
336
|
+
return t && !n ? K(t) : n ? t.t === j.NUMBER && typeof t.v == "string" ? n.v : K(n) : null;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function K(s) {
|
|
339
339
|
var t, n;
|
|
340
340
|
const r = (n = (t = s.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
|
|
341
341
|
if (r)
|
|
342
342
|
return r.trimEnd();
|
|
343
343
|
const e = s.v;
|
|
344
|
-
return typeof e == "string" ? s.t ===
|
|
344
|
+
return typeof e == "string" ? s.t === j.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? s.t === j.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
|
|
345
345
|
}
|
|
346
|
-
const
|
|
346
|
+
const R = {
|
|
347
347
|
id: "sheet.mutation.set-filter-range",
|
|
348
|
-
type:
|
|
348
|
+
type: $.MUTATION,
|
|
349
349
|
handler: (s, r) => {
|
|
350
350
|
const { subUnitId: e, unitId: t, range: n } = r;
|
|
351
|
-
return s.get(
|
|
351
|
+
return s.get(S).ensureFilterModel(t, e).setRange(n), !0;
|
|
352
352
|
}
|
|
353
353
|
}, F = {
|
|
354
354
|
id: "sheet.mutation.set-filter-criteria",
|
|
355
|
-
type:
|
|
355
|
+
type: $.MUTATION,
|
|
356
356
|
handler: (s, r) => {
|
|
357
|
-
const { subUnitId: e, unitId: t, criteria: n, col: i, reCalc: o = !0 } = r, a = s.get(
|
|
357
|
+
const { subUnitId: e, unitId: t, criteria: n, col: i, reCalc: o = !0 } = r, a = s.get(S).getFilterModel(t, e);
|
|
358
358
|
return a ? (a.setCriteria(i, n, o), !0) : !1;
|
|
359
359
|
}
|
|
360
|
-
},
|
|
360
|
+
}, A = {
|
|
361
361
|
id: "sheet.mutation.remove-filter",
|
|
362
|
-
type:
|
|
362
|
+
type: $.MUTATION,
|
|
363
363
|
handler: (s, r) => {
|
|
364
364
|
const { unitId: e, subUnitId: t } = r;
|
|
365
|
-
return s.get(
|
|
365
|
+
return s.get(S).removeFilterModel(e, t);
|
|
366
366
|
}
|
|
367
|
-
},
|
|
367
|
+
}, ae = {
|
|
368
368
|
id: "sheet.mutation.re-calc-filter",
|
|
369
|
-
type:
|
|
369
|
+
type: $.MUTATION,
|
|
370
370
|
handler: (s, r) => {
|
|
371
|
-
const { unitId: e, subUnitId: t } = r, i = s.get(
|
|
371
|
+
const { unitId: e, subUnitId: t } = r, i = s.get(S).getFilterModel(e, t);
|
|
372
372
|
return i ? (i.reCalc(), !0) : !1;
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
var
|
|
376
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
375
|
+
var tt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, st = (s, r, e, t) => {
|
|
376
|
+
for (var n = t > 1 ? void 0 : t ? rt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
|
|
377
377
|
(o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
|
|
378
|
-
return t && n &&
|
|
379
|
-
},
|
|
380
|
-
const
|
|
381
|
-
|
|
378
|
+
return t && n && tt(r, e, n), n;
|
|
379
|
+
}, W = (s, r) => (e, t) => r(e, t, s);
|
|
380
|
+
const nt = /* @__PURE__ */ new Set([
|
|
381
|
+
R.id,
|
|
382
382
|
F.id,
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
]),
|
|
386
|
-
let
|
|
383
|
+
A.id,
|
|
384
|
+
ae.id
|
|
385
|
+
]), ce = "SHEET_FILTER_PLUGIN";
|
|
386
|
+
let S = class extends b {
|
|
387
387
|
constructor(r, e, t) {
|
|
388
388
|
super();
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
g(this, "_filterModels", /* @__PURE__ */ new Map());
|
|
390
|
+
g(this, "_loadedUnitId$", new x(null));
|
|
391
|
+
g(this, "loadedUnitId$", this._loadedUnitId$.asObservable());
|
|
392
|
+
g(this, "_errorMsg$", new x(null));
|
|
393
|
+
g(this, "errorMsg$", this._errorMsg$.asObservable());
|
|
394
|
+
g(this, "_activeFilterModel$", new x(null));
|
|
393
395
|
/** An observable value emitting the current Workbook's active Worksheet's filter model (if there is one). */
|
|
394
|
-
|
|
396
|
+
g(this, "activeFilterModel$", this._activeFilterModel$.asObservable());
|
|
395
397
|
this._resourcesManagerService = r, this._univerInstanceService = e, this._commandService = t, this._initModel(), this._initActiveFilterModel();
|
|
396
398
|
}
|
|
397
399
|
/** The current Workbook's active Worksheet's filter model (if there is one). */
|
|
@@ -413,7 +415,7 @@ let v = class extends B {
|
|
|
413
415
|
const i = n.getSheetBySheetId(e);
|
|
414
416
|
if (!i)
|
|
415
417
|
throw new Error(`[SheetsFilterService]: could not create "FilterModel" on a non-existing worksheet ${e}!`);
|
|
416
|
-
const o = new
|
|
418
|
+
const o = new B(r, e, i);
|
|
417
419
|
return this._cacheFilterModel(r, e, o), o;
|
|
418
420
|
}
|
|
419
421
|
getFilterModel(r, e) {
|
|
@@ -424,17 +426,20 @@ let v = class extends B {
|
|
|
424
426
|
const t = this.getFilterModel(r, e);
|
|
425
427
|
return t ? (t.dispose(), this._filterModels.get(r).delete(e), !0) : !1;
|
|
426
428
|
}
|
|
429
|
+
setFilterErrorMsg(r) {
|
|
430
|
+
this._errorMsg$.next(r);
|
|
431
|
+
}
|
|
427
432
|
_updateActiveFilterModel() {
|
|
428
433
|
let r;
|
|
429
434
|
try {
|
|
430
|
-
if (r = this._univerInstanceService.getCurrentUnitForType(
|
|
435
|
+
if (r = this._univerInstanceService.getCurrentUnitForType(V.UNIVER_SHEET), !r) {
|
|
431
436
|
this._activeFilterModel$.next(null);
|
|
432
437
|
return;
|
|
433
438
|
}
|
|
434
439
|
} catch {
|
|
435
440
|
return;
|
|
436
441
|
}
|
|
437
|
-
const e = r.
|
|
442
|
+
const e = r.getRawActiveSheet();
|
|
438
443
|
if (!e) {
|
|
439
444
|
this._activeFilterModel$.next(null);
|
|
440
445
|
return;
|
|
@@ -444,13 +449,13 @@ let v = class extends B {
|
|
|
444
449
|
}
|
|
445
450
|
_initActiveFilterModel() {
|
|
446
451
|
this.disposeWithMe(
|
|
447
|
-
|
|
452
|
+
pe(
|
|
448
453
|
// source1: executing filter related mutations
|
|
449
|
-
|
|
454
|
+
me(this._commandService.onCommandExecuted).pipe(we(([r]) => r.type === $.MUTATION && nt.has(r.id))),
|
|
450
455
|
// source2: activate sheet changes
|
|
451
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(
|
|
456
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(V.UNIVER_SHEET).pipe(Fe((r) => {
|
|
452
457
|
var e;
|
|
453
|
-
return (e = r == null ? void 0 : r.activeSheet$) != null ? e :
|
|
458
|
+
return (e = r == null ? void 0 : r.activeSheet$) != null ? e : ve(null);
|
|
454
459
|
}))
|
|
455
460
|
).subscribe(() => this._updateActiveFilterModel())
|
|
456
461
|
);
|
|
@@ -467,13 +472,13 @@ let v = class extends B {
|
|
|
467
472
|
_deserializeAutoFiltersForUnit(r, e) {
|
|
468
473
|
const t = this._univerInstanceService.getUniverSheetInstance(r);
|
|
469
474
|
Object.keys(e).forEach((n) => {
|
|
470
|
-
const i = e[n], o =
|
|
475
|
+
const i = e[n], o = B.deserialize(r, n, t.getSheetBySheetId(n), i);
|
|
471
476
|
this._cacheFilterModel(r, n, o);
|
|
472
477
|
});
|
|
473
478
|
}
|
|
474
479
|
_initModel() {
|
|
475
480
|
this._resourcesManagerService.registerPluginResource({
|
|
476
|
-
pluginName:
|
|
481
|
+
pluginName: ce,
|
|
477
482
|
businesses: [2],
|
|
478
483
|
toJson: (r) => this._serializeAutoFiltersForUnit(r),
|
|
479
484
|
parseJson: (r) => JSON.parse(r),
|
|
@@ -490,13 +495,13 @@ let v = class extends B {
|
|
|
490
495
|
this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
|
|
491
496
|
}
|
|
492
497
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
],
|
|
499
|
-
function
|
|
498
|
+
S = st([
|
|
499
|
+
ee(te.Ready, S),
|
|
500
|
+
W(0, _e),
|
|
501
|
+
W(1, re),
|
|
502
|
+
W(2, se)
|
|
503
|
+
], S);
|
|
504
|
+
function it(s, r) {
|
|
500
505
|
for (let e = 0; e < s.length; e++) {
|
|
501
506
|
let t = e;
|
|
502
507
|
if (s[e])
|
|
@@ -505,31 +510,31 @@ function rt(s, r) {
|
|
|
505
510
|
}
|
|
506
511
|
return s.filter((e) => e !== null);
|
|
507
512
|
}
|
|
508
|
-
function
|
|
509
|
-
return
|
|
513
|
+
function E(s) {
|
|
514
|
+
return it(s, (r, e) => r.id === F.id && e.id === F.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
|
|
510
515
|
}
|
|
511
|
-
var
|
|
512
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
516
|
+
var ot = Object.defineProperty, lt = Object.getOwnPropertyDescriptor, at = (s, r, e, t) => {
|
|
517
|
+
for (var n = t > 1 ? void 0 : t ? lt(r, e) : r, i = s.length - 1, o; i >= 0; i--)
|
|
513
518
|
(o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
|
|
514
|
-
return t && n &&
|
|
515
|
-
},
|
|
516
|
-
let
|
|
519
|
+
return t && n && ot(r, e, n), n;
|
|
520
|
+
}, N = (s, r) => (e, t) => r(e, t, s);
|
|
521
|
+
let L = class extends b {
|
|
517
522
|
constructor(s, r, e, t, n) {
|
|
518
|
-
super(), this._commandService = s, this._sheetInterceptorService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._refRangeService = n, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener();
|
|
523
|
+
super(), this._commandService = s, this._sheetInterceptorService = r, this._sheetsFilterService = e, this._univerInstanceService = t, this._refRangeService = n, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling();
|
|
519
524
|
}
|
|
520
525
|
_initCommands() {
|
|
521
526
|
[
|
|
522
527
|
F,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
528
|
+
R,
|
|
529
|
+
ae,
|
|
530
|
+
A
|
|
526
531
|
].forEach((s) => this.disposeWithMe(this._commandService.registerCommand(s)));
|
|
527
532
|
}
|
|
528
533
|
_initInterceptors() {
|
|
529
534
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
530
535
|
getMutations: (e) => this._getUpdateFilter(e)
|
|
531
536
|
}));
|
|
532
|
-
const s = new
|
|
537
|
+
const s = new ge(), r = (e, t) => {
|
|
533
538
|
var a;
|
|
534
539
|
const n = this._univerInstanceService.getUniverSheetInstance(e);
|
|
535
540
|
if (!n || !(n == null ? void 0 : n.getSheetBySheetId(t)))
|
|
@@ -537,31 +542,31 @@ let P = class extends B {
|
|
|
537
542
|
s.dispose();
|
|
538
543
|
const o = (a = this._sheetsFilterService.getFilterModel(e, t)) == null ? void 0 : a.getRange(), l = (u) => {
|
|
539
544
|
switch (u.id) {
|
|
540
|
-
case
|
|
541
|
-
const c = u.params, h = c.unitId || e,
|
|
542
|
-
return this._handleInsertRowCommand(c, h,
|
|
545
|
+
case Be.id: {
|
|
546
|
+
const c = u.params, h = c.unitId || e, _ = c.subUnitId || t;
|
|
547
|
+
return this._handleInsertRowCommand(c, h, _);
|
|
543
548
|
}
|
|
544
|
-
case
|
|
545
|
-
const c = u.params, h = c.unitId || e,
|
|
546
|
-
return this._handleInsertColCommand(c, h,
|
|
549
|
+
case Le.id: {
|
|
550
|
+
const c = u.params, h = c.unitId || e, _ = c.subUnitId || t;
|
|
551
|
+
return this._handleInsertColCommand(c, h, _);
|
|
547
552
|
}
|
|
548
|
-
case
|
|
553
|
+
case Pe.id: {
|
|
549
554
|
const c = u.params;
|
|
550
555
|
return this._handleRemoveColCommand(c, e, t);
|
|
551
556
|
}
|
|
552
|
-
case
|
|
557
|
+
case Ie.id: {
|
|
553
558
|
const c = u.params;
|
|
554
559
|
return this._handleRemoveRowCommand(c, e, t);
|
|
555
560
|
}
|
|
556
|
-
case
|
|
561
|
+
case J.MoveColsCommandId: {
|
|
557
562
|
const c = u.params;
|
|
558
563
|
return this._handleMoveColsCommand(c, e, t);
|
|
559
564
|
}
|
|
560
|
-
case
|
|
565
|
+
case J.MoveRowsCommandId: {
|
|
561
566
|
const c = u.params;
|
|
562
567
|
return this._handleMoveRowsCommand(c, e, t);
|
|
563
568
|
}
|
|
564
|
-
case
|
|
569
|
+
case $e.id: {
|
|
565
570
|
const c = u.params;
|
|
566
571
|
return this._handleMoveRangeCommand(c, e, t);
|
|
567
572
|
}
|
|
@@ -571,13 +576,13 @@ let P = class extends B {
|
|
|
571
576
|
o && s.add(this._refRangeService.registerRefRange(o, l, e, t));
|
|
572
577
|
};
|
|
573
578
|
this.disposeWithMe(this._commandService.onCommandExecuted((e) => {
|
|
574
|
-
if (e.id ===
|
|
579
|
+
if (e.id === Ee.id) {
|
|
575
580
|
const t = e.params, n = t.subUnitId, i = t.unitId;
|
|
576
581
|
if (!n || !i)
|
|
577
582
|
return;
|
|
578
583
|
r(i, n);
|
|
579
584
|
}
|
|
580
|
-
if (e.id ===
|
|
585
|
+
if (e.id === R.id) {
|
|
581
586
|
const t = e.params, n = t.subUnitId, i = t.unitId;
|
|
582
587
|
if (!n || !i)
|
|
583
588
|
return;
|
|
@@ -593,7 +598,7 @@ let P = class extends B {
|
|
|
593
598
|
_getUpdateFilter(s) {
|
|
594
599
|
const { id: r } = s;
|
|
595
600
|
switch (r) {
|
|
596
|
-
case
|
|
601
|
+
case Oe.id: {
|
|
597
602
|
const e = s.params;
|
|
598
603
|
return this._handleRemoveSheetCommand(e, e.unitId, e.subUnitId);
|
|
599
604
|
}
|
|
@@ -604,14 +609,14 @@ let P = class extends B {
|
|
|
604
609
|
};
|
|
605
610
|
}
|
|
606
611
|
_handleInsertColCommand(s, r, e) {
|
|
607
|
-
var
|
|
608
|
-
const t = this._sheetsFilterService.getFilterModel(r, e), n = (
|
|
612
|
+
var m;
|
|
613
|
+
const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
|
|
609
614
|
if (!t || !n)
|
|
610
615
|
return this._handleNull();
|
|
611
616
|
const { startColumn: i, endColumn: o } = n, { startColumn: l, endColumn: a } = s.range, u = a - l + 1;
|
|
612
617
|
if (a > o)
|
|
613
618
|
return this._handleNull();
|
|
614
|
-
const c = [], h = [],
|
|
619
|
+
const c = [], h = [], _ = l, p = {
|
|
615
620
|
unitId: r,
|
|
616
621
|
subUnitId: e,
|
|
617
622
|
range: {
|
|
@@ -619,28 +624,28 @@ let P = class extends B {
|
|
|
619
624
|
startColumn: l <= i ? i + u : i,
|
|
620
625
|
endColumn: o + u
|
|
621
626
|
}
|
|
622
|
-
},
|
|
627
|
+
}, C = {
|
|
623
628
|
unitId: r,
|
|
624
629
|
subUnitId: e,
|
|
625
630
|
range: n
|
|
626
631
|
};
|
|
627
|
-
c.push({ id:
|
|
628
|
-
const
|
|
629
|
-
if (
|
|
630
|
-
const { undos:
|
|
631
|
-
c.push(...
|
|
632
|
+
c.push({ id: R.id, params: p }), h.push({ id: R.id, params: C });
|
|
633
|
+
const f = t.getAllFilterColumns().filter((d) => d[0] >= _);
|
|
634
|
+
if (f.length !== 0) {
|
|
635
|
+
const { undos: d, redos: v } = this.moveCriteria(r, e, f, u);
|
|
636
|
+
c.push(...v), h.push(...d);
|
|
632
637
|
}
|
|
633
|
-
return { redos:
|
|
638
|
+
return { redos: E(c), undos: E(h) };
|
|
634
639
|
}
|
|
635
640
|
_handleInsertRowCommand(s, r, e) {
|
|
636
|
-
var
|
|
637
|
-
const t = this._sheetsFilterService.getFilterModel(r, e), n = (
|
|
641
|
+
var C;
|
|
642
|
+
const t = this._sheetsFilterService.getFilterModel(r, e), n = (C = t == null ? void 0 : t.getRange()) != null ? C : null;
|
|
638
643
|
if (!t || !n)
|
|
639
644
|
return this._handleNull();
|
|
640
645
|
const { startRow: i, endRow: o } = n, { startRow: l, endRow: a } = s.range, u = a - l + 1;
|
|
641
646
|
if (a > o)
|
|
642
647
|
return this._handleNull();
|
|
643
|
-
const c = [], h = [],
|
|
648
|
+
const c = [], h = [], _ = {
|
|
644
649
|
unitId: r,
|
|
645
650
|
subUnitId: e,
|
|
646
651
|
range: {
|
|
@@ -653,9 +658,9 @@ let P = class extends B {
|
|
|
653
658
|
subUnitId: e,
|
|
654
659
|
range: n
|
|
655
660
|
};
|
|
656
|
-
return c.push({ id:
|
|
657
|
-
redos:
|
|
658
|
-
undos:
|
|
661
|
+
return c.push({ id: R.id, params: _ }), h.push({ id: R.id, params: p }), {
|
|
662
|
+
redos: E(c),
|
|
663
|
+
undos: E(h)
|
|
659
664
|
};
|
|
660
665
|
}
|
|
661
666
|
_handleRemoveColCommand(s, r, e) {
|
|
@@ -666,37 +671,37 @@ let P = class extends B {
|
|
|
666
671
|
const { startColumn: i, endColumn: o } = n, { startColumn: l, endColumn: a } = s.range;
|
|
667
672
|
if (l > o)
|
|
668
673
|
return this._handleNull();
|
|
669
|
-
const u = [], c = [], h = a < i ? 0 : Math.min(a, o) - Math.max(l, i) + 1,
|
|
670
|
-
p.forEach((
|
|
671
|
-
const [
|
|
672
|
-
|
|
674
|
+
const u = [], c = [], h = a < i ? 0 : Math.min(a, o) - Math.max(l, i) + 1, _ = a - l + 1, p = t.getAllFilterColumns();
|
|
675
|
+
p.forEach((f) => {
|
|
676
|
+
const [m, d] = f;
|
|
677
|
+
m <= a && m >= l && (u.push({ id: F.id, params: { unitId: r, subUnitId: e, col: m, criteria: null } }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: m, criteria: { ...d.serialize(), colId: m } } }));
|
|
673
678
|
});
|
|
674
|
-
const
|
|
675
|
-
const [
|
|
676
|
-
return
|
|
679
|
+
const C = p.filter((f) => {
|
|
680
|
+
const [m, d] = f;
|
|
681
|
+
return m > a;
|
|
677
682
|
});
|
|
678
|
-
if (
|
|
679
|
-
const { undos:
|
|
680
|
-
u.push(...
|
|
683
|
+
if (C.length > 0) {
|
|
684
|
+
const { undos: f, redos: m } = this.moveCriteria(r, e, C, -_);
|
|
685
|
+
u.push(...m), c.push(...f);
|
|
681
686
|
}
|
|
682
687
|
if (h === o - i + 1) {
|
|
683
|
-
const
|
|
688
|
+
const f = {
|
|
684
689
|
unitId: r,
|
|
685
690
|
subUnitId: e
|
|
686
691
|
};
|
|
687
|
-
u.push({ id:
|
|
692
|
+
u.push({ id: A.id, params: f });
|
|
688
693
|
} else if (i <= l) {
|
|
689
|
-
const
|
|
694
|
+
const f = o - h, m = {
|
|
690
695
|
unitId: r,
|
|
691
696
|
subUnitId: e,
|
|
692
697
|
range: {
|
|
693
698
|
...n,
|
|
694
|
-
endColumn:
|
|
699
|
+
endColumn: f
|
|
695
700
|
}
|
|
696
701
|
};
|
|
697
|
-
u.push({ id:
|
|
702
|
+
u.push({ id: R.id, params: m });
|
|
698
703
|
} else {
|
|
699
|
-
const
|
|
704
|
+
const f = {
|
|
700
705
|
unitId: r,
|
|
701
706
|
subUnitId: e,
|
|
702
707
|
range: {
|
|
@@ -705,64 +710,65 @@ let P = class extends B {
|
|
|
705
710
|
endColumn: o - (a - l + 1)
|
|
706
711
|
}
|
|
707
712
|
};
|
|
708
|
-
u.push({ id:
|
|
713
|
+
u.push({ id: R.id, params: f });
|
|
709
714
|
}
|
|
710
|
-
return c.push({ id:
|
|
711
|
-
undos:
|
|
712
|
-
redos:
|
|
715
|
+
return c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } }), {
|
|
716
|
+
undos: E(c),
|
|
717
|
+
redos: E(u)
|
|
713
718
|
};
|
|
714
719
|
}
|
|
715
720
|
_handleRemoveRowCommand(s, r, e) {
|
|
716
|
-
var
|
|
721
|
+
var C;
|
|
717
722
|
const t = this._sheetsFilterService.getFilterModel(r, e);
|
|
718
723
|
if (!t)
|
|
719
724
|
return this._handleNull();
|
|
720
725
|
const n = t.getRange(), { startRow: i, endRow: o } = n, { startRow: l, endRow: a } = s.range;
|
|
721
726
|
if (l > o)
|
|
722
727
|
return this._handleNull();
|
|
723
|
-
const u = [], c = [], h = t.getAllFilterColumns(),
|
|
724
|
-
c.push({ id:
|
|
728
|
+
const u = [], c = [], h = t.getAllFilterColumns(), _ = i <= a && i >= l;
|
|
729
|
+
c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
|
|
725
730
|
const p = Math.min(a, o) - Math.max(l, i) + 1;
|
|
726
|
-
if (p === o - i + 1 ||
|
|
731
|
+
if (p === o - i + 1 || _) {
|
|
727
732
|
const w = {
|
|
728
733
|
unitId: r,
|
|
729
734
|
subUnitId: e
|
|
730
735
|
};
|
|
731
|
-
u.push({ id:
|
|
732
|
-
const [
|
|
736
|
+
u.push({ id: A.id, params: w }), h.forEach((f) => {
|
|
737
|
+
const [m, d] = f, v = {
|
|
733
738
|
unitId: r,
|
|
734
739
|
subUnitId: e,
|
|
735
|
-
col:
|
|
736
|
-
criteria: { ...
|
|
740
|
+
col: m,
|
|
741
|
+
criteria: { ...d.serialize(), colId: m }
|
|
737
742
|
};
|
|
738
|
-
c.push({ id: F.id, params:
|
|
743
|
+
c.push({ id: F.id, params: v });
|
|
739
744
|
});
|
|
740
745
|
} else {
|
|
741
|
-
const w = (
|
|
746
|
+
const w = (C = this._univerInstanceService.getUniverSheetInstance(r)) == null ? void 0 : C.getSheetBySheetId(e);
|
|
742
747
|
if (!w)
|
|
743
748
|
return this._handleNull();
|
|
744
|
-
const
|
|
745
|
-
for (let
|
|
746
|
-
w.getRowFiltered(
|
|
747
|
-
const
|
|
749
|
+
const f = [];
|
|
750
|
+
for (let M = l; M <= a; M++)
|
|
751
|
+
w.getRowFiltered(M) && f.push(M);
|
|
752
|
+
const m = Math.min(i, l), d = m + (o - i) - p + f.length, v = {
|
|
748
753
|
unitId: r,
|
|
749
754
|
subUnitId: e,
|
|
750
755
|
range: {
|
|
751
756
|
...n,
|
|
752
|
-
startRow:
|
|
753
|
-
endRow:
|
|
757
|
+
startRow: m,
|
|
758
|
+
endRow: d
|
|
754
759
|
}
|
|
755
760
|
};
|
|
756
|
-
u.push({ id:
|
|
761
|
+
u.push({ id: R.id, params: v });
|
|
757
762
|
}
|
|
758
763
|
return {
|
|
759
|
-
undos:
|
|
760
|
-
redos:
|
|
764
|
+
undos: E(c),
|
|
765
|
+
redos: E(u)
|
|
761
766
|
};
|
|
762
767
|
}
|
|
768
|
+
// eslint-disable-next-line max-lines-per-function
|
|
763
769
|
_handleMoveColsCommand(s, r, e) {
|
|
764
|
-
var
|
|
765
|
-
const t = this._sheetsFilterService.getFilterModel(r, e), n = (
|
|
770
|
+
var m;
|
|
771
|
+
const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
|
|
766
772
|
if (!t || !n)
|
|
767
773
|
return this._handleNull();
|
|
768
774
|
const { startColumn: i, endColumn: o } = n, { fromRange: l, toRange: a } = s;
|
|
@@ -774,39 +780,44 @@ let P = class extends B {
|
|
|
774
780
|
colIndex: d,
|
|
775
781
|
filter: t.getFilterColumn(d)
|
|
776
782
|
};
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
criteria: { ...g.serialize(), colId: S }
|
|
788
|
-
};
|
|
789
|
-
if (u.push({ id: F.id, params: le }), c.push({ id: y.id, params: { unitId: r, subUnitId: e, col: S, criteria: { ...(O = t.getFilterColumn(S)) == null ? void 0 : O.serialize(), colId: S } } }), !((j = h[f]) != null && j.filter)) {
|
|
790
|
-
const ae = {
|
|
783
|
+
G(l.startColumn, l.endColumn - l.startColumn + 1, a.startColumn, h);
|
|
784
|
+
let _ = n.startColumn, p = n.endColumn;
|
|
785
|
+
i >= l.startColumn && i <= l.endColumn && a.startColumn > l.startColumn && l.endColumn < o && (_ = l.endColumn + 1), o >= l.startColumn && o <= l.endColumn && a.startColumn < l.startColumn && l.startColumn > i && (p = l.startColumn - 1);
|
|
786
|
+
const C = Object.keys(h).map((d) => Number(d)), w = C.find((d) => h[d].colIndex === p), f = C.find((d) => h[d].colIndex === _);
|
|
787
|
+
if (C.forEach((d) => {
|
|
788
|
+
var D, Q;
|
|
789
|
+
const { colIndex: v, filter: M } = h[d], y = d;
|
|
790
|
+
if (M) {
|
|
791
|
+
if (y >= f && y <= w) {
|
|
792
|
+
const U = {
|
|
791
793
|
unitId: r,
|
|
792
794
|
subUnitId: e,
|
|
793
|
-
col:
|
|
795
|
+
col: y,
|
|
796
|
+
criteria: { ...M.serialize(), colId: y }
|
|
797
|
+
};
|
|
798
|
+
u.push({ id: F.id, params: U }), c.push({ id: A.id, params: { unitId: r, subUnitId: e, col: y, criteria: { ...(D = t.getFilterColumn(y)) == null ? void 0 : D.serialize(), colId: y } } });
|
|
799
|
+
}
|
|
800
|
+
if (!((Q = h[v]) != null && Q.filter)) {
|
|
801
|
+
const U = {
|
|
802
|
+
unitId: r,
|
|
803
|
+
subUnitId: e,
|
|
804
|
+
col: v,
|
|
794
805
|
criteria: null
|
|
795
806
|
};
|
|
796
|
-
u.push({ id: F.id, params:
|
|
807
|
+
u.push({ id: F.id, params: U }), c.push({ id: F.id, params: { unitId: r, subUnitId: e, col: v, criteria: { ...M.serialize(), colId: v } } });
|
|
797
808
|
}
|
|
798
809
|
}
|
|
799
|
-
}), i !==
|
|
810
|
+
}), i !== f || o !== w) {
|
|
800
811
|
const d = {
|
|
801
812
|
unitId: r,
|
|
802
813
|
subUnitId: e,
|
|
803
814
|
range: {
|
|
804
815
|
...n,
|
|
805
|
-
startColumn:
|
|
806
|
-
endColumn:
|
|
816
|
+
startColumn: f,
|
|
817
|
+
endColumn: w
|
|
807
818
|
}
|
|
808
819
|
};
|
|
809
|
-
u.unshift({ id:
|
|
820
|
+
u.unshift({ id: R.id, params: d }), c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
|
|
810
821
|
}
|
|
811
822
|
return {
|
|
812
823
|
undos: c,
|
|
@@ -814,8 +825,8 @@ let P = class extends B {
|
|
|
814
825
|
};
|
|
815
826
|
}
|
|
816
827
|
_handleMoveRowsCommand(s, r, e) {
|
|
817
|
-
var
|
|
818
|
-
const t = this._sheetsFilterService.getFilterModel(r, e), n = (
|
|
828
|
+
var m;
|
|
829
|
+
const t = this._sheetsFilterService.getFilterModel(r, e), n = (m = t == null ? void 0 : t.getRange()) != null ? m : null;
|
|
819
830
|
if (!t || !n)
|
|
820
831
|
return this._handleNull();
|
|
821
832
|
const { startRow: i, endRow: o } = n, { fromRange: l, toRange: a } = s;
|
|
@@ -824,21 +835,23 @@ let P = class extends B {
|
|
|
824
835
|
const u = [], c = [], h = {};
|
|
825
836
|
for (let d = i; d <= o; d++)
|
|
826
837
|
h[d] = {
|
|
827
|
-
|
|
838
|
+
oldIndex: d
|
|
828
839
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
840
|
+
const _ = i;
|
|
841
|
+
let p = o;
|
|
842
|
+
o >= l.startRow && o <= l.endRow && a.startRow < l.startRow && l.startRow > i && (p = l.startRow - 1), G(l.startRow, l.endRow - l.startRow + 1, a.startRow, h);
|
|
843
|
+
const C = Object.keys(h).map((d) => Number(d)), w = C.find((d) => h[d].oldIndex === p), f = C.find((d) => h[d].oldIndex === _);
|
|
844
|
+
if (i !== f || o !== w) {
|
|
832
845
|
const d = {
|
|
833
846
|
unitId: r,
|
|
834
847
|
subUnitId: e,
|
|
835
848
|
range: {
|
|
836
849
|
...n,
|
|
837
|
-
startRow:
|
|
838
|
-
endRow:
|
|
850
|
+
startRow: f,
|
|
851
|
+
endRow: w
|
|
839
852
|
}
|
|
840
853
|
};
|
|
841
|
-
u.unshift({ id:
|
|
854
|
+
u.unshift({ id: R.id, params: d }), c.push({ id: R.id, params: { range: n, unitId: r, subUnitId: e } });
|
|
842
855
|
}
|
|
843
856
|
return {
|
|
844
857
|
redos: u,
|
|
@@ -853,24 +866,24 @@ let P = class extends B {
|
|
|
853
866
|
if (!o)
|
|
854
867
|
return this._handleNull();
|
|
855
868
|
const l = [], a = [];
|
|
856
|
-
if (
|
|
869
|
+
if (k.contains(t, o)) {
|
|
857
870
|
const u = o.startRow - t.startRow, c = o.startColumn - t.startColumn, h = {
|
|
858
871
|
startRow: n.startRow + u,
|
|
859
872
|
startColumn: n.startColumn + c,
|
|
860
873
|
endRow: n.startRow + u + (o.endRow - o.startRow),
|
|
861
874
|
endColumn: n.startColumn + c + (o.endColumn - o.startColumn)
|
|
862
|
-
},
|
|
863
|
-
id:
|
|
875
|
+
}, _ = {
|
|
876
|
+
id: A.id,
|
|
864
877
|
params: {
|
|
865
878
|
unitId: r,
|
|
866
879
|
subUnitId: e
|
|
867
880
|
}
|
|
868
|
-
}, p = { id:
|
|
869
|
-
l.push(
|
|
870
|
-
const w = i.getAllFilterColumns(),
|
|
871
|
-
w.forEach((
|
|
872
|
-
const [
|
|
873
|
-
|
|
881
|
+
}, p = { id: R.id, params: { unitId: r, subUnitId: e, range: h } }, C = { id: R.id, params: { unitId: r, subUnitId: e, range: o } };
|
|
882
|
+
l.push(_, p), a.push(_, C);
|
|
883
|
+
const w = i.getAllFilterColumns(), f = n.startColumn - t.startColumn;
|
|
884
|
+
w.forEach((m) => {
|
|
885
|
+
const [d, v] = m;
|
|
886
|
+
v && (l.push({ id: F.id, params: { unitId: r, subUnitId: e, col: d + f, criteria: { ...v.serialize(), colId: d + f } } }), a.push({ id: F.id, params: { unitId: r, subUnitId: e, col: d, criteria: { ...v.serialize(), colId: d } } }));
|
|
874
887
|
});
|
|
875
888
|
}
|
|
876
889
|
return {
|
|
@@ -889,7 +902,7 @@ let P = class extends B {
|
|
|
889
902
|
return t.getAllFilterColumns().forEach((a) => {
|
|
890
903
|
const [u, c] = a;
|
|
891
904
|
o.push({ id: F.id, params: { unitId: r, subUnitId: e, col: a, criteria: { ...c.serialize(), colId: a } } });
|
|
892
|
-
}), i.push({ id:
|
|
905
|
+
}), i.push({ id: A.id, params: { unitId: r, subUnitId: e, range: n } }), o.unshift({ id: R.id, params: { range: n, unitId: r, subUnitId: e } }), {
|
|
893
906
|
undos: o,
|
|
894
907
|
redos: i
|
|
895
908
|
};
|
|
@@ -898,7 +911,7 @@ let P = class extends B {
|
|
|
898
911
|
return { redos: [], undos: [] };
|
|
899
912
|
}
|
|
900
913
|
_initRowFilteredInterceptor() {
|
|
901
|
-
this.disposeWithMe(this._sheetInterceptorService.intercept(
|
|
914
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(ye.ROW_FILTERED, {
|
|
902
915
|
handler: (s, r) => {
|
|
903
916
|
var e, t;
|
|
904
917
|
return s ? !0 : (t = (e = this._sheetsFilterService.getFilterModel(
|
|
@@ -960,7 +973,7 @@ let P = class extends B {
|
|
|
960
973
|
return;
|
|
961
974
|
const n = Array.from(t.filteredOutRows).sort((l, a) => l - a), i = [];
|
|
962
975
|
let o = !1;
|
|
963
|
-
if (s.id ===
|
|
976
|
+
if (s.id === Ae.id) {
|
|
964
977
|
const { startRow: l, endRow: a } = s.params.range, u = n.filter((c) => c >= l && c <= a);
|
|
965
978
|
n.forEach((c) => {
|
|
966
979
|
if (c < l)
|
|
@@ -972,7 +985,7 @@ let P = class extends B {
|
|
|
972
985
|
i.push(c - (a - l + 1 - u.length));
|
|
973
986
|
});
|
|
974
987
|
}
|
|
975
|
-
if (s.id ===
|
|
988
|
+
if (s.id === Te.id) {
|
|
976
989
|
const { startRow: l, endRow: a } = s.params.range;
|
|
977
990
|
n.forEach((u) => {
|
|
978
991
|
u >= l ? (o = !0, i.push(u + (a - l + 1))) : i.push(u);
|
|
@@ -981,51 +994,64 @@ let P = class extends B {
|
|
|
981
994
|
o && (t.filteredOutRows = new Set(i));
|
|
982
995
|
}));
|
|
983
996
|
}
|
|
997
|
+
_initErrorHandling() {
|
|
998
|
+
this.disposeWithMe(this._commandService.beforeCommandExecuted((s) => {
|
|
999
|
+
const r = s.params, e = Ne(this._univerInstanceService);
|
|
1000
|
+
if (!e)
|
|
1001
|
+
return;
|
|
1002
|
+
const { subUnitId: t, unitId: n } = e, i = this._sheetsFilterService.getFilterModel(n, t);
|
|
1003
|
+
if (!i)
|
|
1004
|
+
return;
|
|
1005
|
+
const o = i.getRange();
|
|
1006
|
+
if (s.id === xe.id && r.fromRange.startRow <= o.startRow && r.fromRange.endRow >= o.startRow)
|
|
1007
|
+
throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
|
|
1008
|
+
}));
|
|
1009
|
+
}
|
|
984
1010
|
};
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
],
|
|
993
|
-
var
|
|
994
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
1011
|
+
L = at([
|
|
1012
|
+
ee(te.Ready, L),
|
|
1013
|
+
N(0, se),
|
|
1014
|
+
N(1, P(Se)),
|
|
1015
|
+
N(2, P(S)),
|
|
1016
|
+
N(3, re),
|
|
1017
|
+
N(4, P(Me))
|
|
1018
|
+
], L);
|
|
1019
|
+
var ct = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, dt = (s, r, e, t) => {
|
|
1020
|
+
for (var n = t > 1 ? void 0 : t ? ut(r, e) : r, i = s.length - 1, o; i >= 0; i--)
|
|
995
1021
|
(o = s[i]) && (n = (t ? o(r, e, n) : o(n)) || n);
|
|
996
|
-
return t && n &&
|
|
997
|
-
},
|
|
998
|
-
let
|
|
1022
|
+
return t && n && ct(r, e, n), n;
|
|
1023
|
+
}, ht = (s, r) => (e, t) => r(e, t, s), I;
|
|
1024
|
+
let Z = (I = class extends Ce {
|
|
999
1025
|
constructor(s, r) {
|
|
1000
1026
|
super(), this._injector = r;
|
|
1001
1027
|
}
|
|
1002
1028
|
onStarting(s) {
|
|
1003
1029
|
[
|
|
1004
|
-
[
|
|
1005
|
-
[
|
|
1030
|
+
[S],
|
|
1031
|
+
[L]
|
|
1006
1032
|
].forEach((r) => s.add(r));
|
|
1007
1033
|
}
|
|
1008
|
-
},
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
],
|
|
1034
|
+
}, g(I, "type", V.UNIVER_SHEET), g(I, "pluginName", ce), I);
|
|
1035
|
+
Z = dt([
|
|
1036
|
+
ht(1, P(Re))
|
|
1037
|
+
], Z);
|
|
1012
1038
|
export {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1039
|
+
O as CustomFilterOperator,
|
|
1040
|
+
nt as FILTER_MUTATIONS,
|
|
1041
|
+
qe as FilterColumn,
|
|
1042
|
+
B as FilterModel,
|
|
1043
|
+
ae as ReCalcSheetsFilterMutation,
|
|
1044
|
+
A as RemoveSheetsFilterMutation,
|
|
1045
|
+
ce as SHEET_FILTER_SNAPSHOT_ID,
|
|
1020
1046
|
F as SetSheetsFilterCriteriaMutation,
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1047
|
+
R as SetSheetsFilterRangeMutation,
|
|
1048
|
+
S as SheetsFilterService,
|
|
1049
|
+
Z as UniverSheetsFilterPlugin,
|
|
1050
|
+
We as equals,
|
|
1051
|
+
X as getCustomFilterFn,
|
|
1052
|
+
be as greaterThan,
|
|
1053
|
+
Ue as greaterThanOrEqualTo,
|
|
1054
|
+
ze as lessThan,
|
|
1055
|
+
He as lessThanOrEqualTo,
|
|
1056
|
+
ne as notEquals
|
|
1031
1057
|
};
|