@univerjs/sheets-filter 0.8.2 → 0.8.3-nightly.202506271607
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 +257 -257
- package/lib/index.js +257 -257
- package/lib/types/index.d.ts +7 -6
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
- package/LICENSE +0 -176
package/lib/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
var ve = Object.defineProperty;
|
|
2
2
|
var Me = (i, r, e) => r in i ? ve(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
|
|
3
3
|
var w = (i, r, e) => Me(i, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
-
import { isNumeric as Ee, Disposable as B, Rectangle as K, mergeSets as G, Tools as te, extractPureTextFromCell as ye, CellValueType as X, UniverInstanceType as D, fromCallback as Oe, CommandType as E, IResourceManagerService as Ae, IUniverInstanceService as T, ICommandService as N,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { isNumeric as Ee, Disposable as B, Rectangle as K, mergeSets as G, Tools as te, extractPureTextFromCell as ye, CellValueType as X, UniverInstanceType as D, fromCallback as Oe, CommandType as E, IResourceManagerService as Ae, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as q, sequenceExecute as Te, ErrorService as Ne, LocaleService as xe, Inject as I, Optional as Ie, DisposableCollection as $e, moveMatrixArray as re, Plugin as Pe, merge as Ue, touchDependencies as De, Injector as Le, IConfigService as Be } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as b, SheetsSelectionsService as be, isSingleCellSelection as He, expandToContinuousRange as de, SheetInterceptorService as ze, RefRangeService as We, SetWorksheetActiveOperation as Ve, CopySheetCommand as je, RemoveSheetCommand as ke, INTERCEPTOR_POINT as qe, RemoveRowMutation as Qe, InsertRowMutation as Ge, SetRangeValuesMutation as Je, MoveRowsCommand as Ye, MoveRangeCommand as Ke, EffectRefRangId as ne, RemoveRowCommand as Xe, RemoveColCommand as Ze, InsertColCommand as et, InsertRowCommand as tt } from "@univerjs/sheets";
|
|
6
|
+
import { BehaviorSubject as L, merge as rt, filter as nt, switchMap as it, of as st } from "rxjs";
|
|
7
|
+
import { DataSyncPrimaryController as ot } from "@univerjs/rpc";
|
|
8
8
|
import { IActiveDirtyManagerService as lt, ISheetRowFilteredService as at } from "@univerjs/engine-formula";
|
|
9
|
-
const
|
|
9
|
+
const ue = "sheet.mutation.set-filter-range", he = "sheet.mutation.set-filter-criteria", me = "sheet.mutation.remove-filter", fe = "sheet.mutation.re-calc-filter", ge = /* @__PURE__ */ new Set([
|
|
10
10
|
ue,
|
|
11
11
|
he,
|
|
12
12
|
me,
|
|
13
13
|
fe
|
|
14
14
|
]);
|
|
15
15
|
var 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 || {});
|
|
16
|
-
const
|
|
16
|
+
const ct = {
|
|
17
17
|
operator: x.GREATER_THAN,
|
|
18
18
|
fn: (i, r) => U(i) ? i > r : !1
|
|
19
|
-
},
|
|
19
|
+
}, dt = {
|
|
20
20
|
operator: x.GREATER_THAN_OR_EQUAL,
|
|
21
21
|
fn: (i, r) => U(i) ? i >= r : !1
|
|
22
|
-
},
|
|
22
|
+
}, ut = {
|
|
23
23
|
operator: x.LESS_THAN,
|
|
24
24
|
fn: (i, r) => U(i) ? i < r : !1
|
|
25
|
-
},
|
|
25
|
+
}, ht = {
|
|
26
26
|
operator: x.LESS_THAN_OR_EQUAL,
|
|
27
27
|
fn: (i, r) => U(i) ? i <= r : !1
|
|
28
|
-
},
|
|
28
|
+
}, mt = {
|
|
29
29
|
operator: x.EQUAL,
|
|
30
30
|
fn: (i, r) => U(i) ? i === r : !1
|
|
31
31
|
}, _e = {
|
|
@@ -35,36 +35,36 @@ const dt = {
|
|
|
35
35
|
if (r === " ")
|
|
36
36
|
return i != null;
|
|
37
37
|
const e = Ce(i);
|
|
38
|
-
return e &&
|
|
38
|
+
return e && Rt(r) ? !pe(r).test(e) : e !== r;
|
|
39
39
|
}
|
|
40
40
|
return U(i) ? i !== r : !0;
|
|
41
41
|
}
|
|
42
|
-
}, Re = /* @__PURE__ */ new Map([]),
|
|
43
|
-
|
|
42
|
+
}, Re = /* @__PURE__ */ new Map([]), ft = [ct, dt, ut, ht, mt, _e];
|
|
43
|
+
ft.forEach((i) => {
|
|
44
44
|
Re.set(i.operator, i);
|
|
45
45
|
});
|
|
46
|
-
function
|
|
46
|
+
function gt(i) {
|
|
47
47
|
return !!i;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const _t = {
|
|
50
50
|
fn: (i, r) => {
|
|
51
51
|
const e = Ce(i);
|
|
52
52
|
return e === null ? r === "" : pe(r).test(e);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
function
|
|
56
|
-
return i ? Re.get(i) :
|
|
55
|
+
function ie(i) {
|
|
56
|
+
return i ? Re.get(i) : _t;
|
|
57
57
|
}
|
|
58
58
|
function U(i) {
|
|
59
59
|
return typeof i == "number";
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function se(i) {
|
|
62
62
|
return !!(typeof i == "number" || typeof i == "string" && Ee(i));
|
|
63
63
|
}
|
|
64
64
|
function Ce(i) {
|
|
65
65
|
return typeof i == "boolean" || i == null ? null : typeof i == "string" ? i : i.toString();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function Rt(i) {
|
|
68
68
|
return typeof i == "number" ? !1 : i.indexOf("*") !== -1 || i.indexOf("?") !== -1;
|
|
69
69
|
}
|
|
70
70
|
function pe(i) {
|
|
@@ -190,7 +190,7 @@ class V extends B {
|
|
|
190
190
|
if (e > o || e < s)
|
|
191
191
|
throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
|
|
192
192
|
let l;
|
|
193
|
-
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new
|
|
193
|
+
this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new Ct(
|
|
194
194
|
this.unitId,
|
|
195
195
|
this.subUnitId,
|
|
196
196
|
this._worksheet,
|
|
@@ -220,7 +220,7 @@ class V extends B {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
class
|
|
223
|
+
class Ct extends B {
|
|
224
224
|
constructor(e, t, n, s, o) {
|
|
225
225
|
super();
|
|
226
226
|
w(this, "_filteredOutRows", null);
|
|
@@ -285,7 +285,7 @@ class pt extends B {
|
|
|
285
285
|
const { row: a, rowSpan: c, col: h } = l;
|
|
286
286
|
if (o.has(a) && (!c || c === 1))
|
|
287
287
|
continue;
|
|
288
|
-
const d = this._filterByValues ? ye(this._worksheet.getCell(a, h)) :
|
|
288
|
+
const d = this._filterByValues ? ye(this._worksheet.getCell(a, h)) : yt(this._worksheet, a, h);
|
|
289
289
|
if (!this._filterFn(d) && (s.add(a), c))
|
|
290
290
|
for (let u = 1; u < c; u++)
|
|
291
291
|
s.add(a + u);
|
|
@@ -293,62 +293,62 @@ class pt extends B {
|
|
|
293
293
|
return s;
|
|
294
294
|
}
|
|
295
295
|
_generateFilterFn() {
|
|
296
|
-
this._criteria && (this._filterFn =
|
|
296
|
+
this._criteria && (this._filterFn = pt(this._criteria), this._filterByValues = !!this._criteria.filters);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function pt(i) {
|
|
300
300
|
if (i.filters)
|
|
301
|
-
return
|
|
301
|
+
return Ft(i.filters);
|
|
302
302
|
if (i.customFilters)
|
|
303
|
-
return
|
|
303
|
+
return wt(i.customFilters);
|
|
304
304
|
throw new Error("[FilterModel]: other types of filters are not supported yet.");
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function Ft(i) {
|
|
307
307
|
const r = !!i.blank, e = new Set(i.filters);
|
|
308
308
|
return (t) => t === void 0 || t === "" ? r : e.has(typeof t == "string" ? t : `${t}`);
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
const r = i.customFilters.map((e) =>
|
|
312
|
-
return
|
|
310
|
+
function wt(i) {
|
|
311
|
+
const r = i.customFilters.map((e) => Et(e));
|
|
312
|
+
return Mt(r) ? i.and ? St(r) : vt(r) : r[0];
|
|
313
313
|
}
|
|
314
|
-
function
|
|
314
|
+
function St(i) {
|
|
315
315
|
const [r, e] = i;
|
|
316
316
|
return (t) => r(t) && e(t);
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function vt(i) {
|
|
319
319
|
const [r, e] = i;
|
|
320
320
|
return (t) => r(t) || e(t);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Mt(i) {
|
|
323
323
|
return i.length === 2;
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function Et(i) {
|
|
326
326
|
const r = i.val;
|
|
327
|
-
if (i.operator === x.NOT_EQUALS && !
|
|
327
|
+
if (i.operator === x.NOT_EQUALS && !se(r))
|
|
328
328
|
return (n) => _e.fn(n, r);
|
|
329
|
-
if (
|
|
330
|
-
if (!
|
|
331
|
-
const n =
|
|
329
|
+
if (gt(i.operator)) {
|
|
330
|
+
if (!se(r)) return () => !1;
|
|
331
|
+
const n = ie(i.operator), s = Number(r);
|
|
332
332
|
return (o) => n.fn(o, s);
|
|
333
333
|
}
|
|
334
|
-
const e =
|
|
334
|
+
const e = ie(i.operator);
|
|
335
335
|
return (t) => e.fn(t, r);
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function yt(i, r, e) {
|
|
338
338
|
const t = i.getCell(r, e);
|
|
339
339
|
if (!t) return null;
|
|
340
340
|
const n = i.getCellRaw(r, e);
|
|
341
|
-
return t && !n ?
|
|
341
|
+
return t && !n ? oe(t) : n ? t.t === X.NUMBER && typeof t.v == "string" ? n.v : oe(n) : null;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
343
|
+
function oe(i) {
|
|
344
344
|
var t, n;
|
|
345
345
|
const r = (n = (t = i.p) == null ? void 0 : t.body) == null ? void 0 : n.dataStream;
|
|
346
346
|
if (r) return r.trimEnd();
|
|
347
347
|
const e = i.v;
|
|
348
348
|
return typeof e == "string" ? i.t === X.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === X.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
|
|
349
349
|
}
|
|
350
|
-
var
|
|
351
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
350
|
+
var Ot = Object.getOwnPropertyDescriptor, At = (i, r, e, t) => {
|
|
351
|
+
for (var n = t > 1 ? void 0 : t ? Ot(r, e) : r, s = i.length - 1, o; s >= 0; s--)
|
|
352
352
|
(o = i[s]) && (n = o(n) || n);
|
|
353
353
|
return n;
|
|
354
354
|
}, Y = (i, r) => (e, t) => r(e, t, i);
|
|
@@ -420,13 +420,13 @@ let M = class extends B {
|
|
|
420
420
|
}
|
|
421
421
|
_initActiveFilterModel() {
|
|
422
422
|
this.disposeWithMe(
|
|
423
|
-
|
|
423
|
+
rt(
|
|
424
424
|
// source1: executing filter related mutations
|
|
425
|
-
Oe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
|
|
425
|
+
Oe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(nt(([r]) => r.type === E.MUTATION && ge.has(r.id))),
|
|
426
426
|
// source2: activate sheet changes
|
|
427
|
-
this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(
|
|
427
|
+
this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(it((r) => {
|
|
428
428
|
var e;
|
|
429
|
-
return (e = r == null ? void 0 : r.activeSheet$) != null ? e :
|
|
429
|
+
return (e = r == null ? void 0 : r.activeSheet$) != null ? e : st(null);
|
|
430
430
|
}))
|
|
431
431
|
).subscribe(() => this._updateActiveFilterModel())
|
|
432
432
|
);
|
|
@@ -466,7 +466,7 @@ let M = class extends B {
|
|
|
466
466
|
this._filterModels.has(r) || this._filterModels.set(r, /* @__PURE__ */ new Map()), this._filterModels.get(r).set(e, t);
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
|
-
M =
|
|
469
|
+
M = At([
|
|
470
470
|
Y(0, Ae),
|
|
471
471
|
Y(1, T),
|
|
472
472
|
Y(2, N)
|
|
@@ -499,8 +499,171 @@ const R = {
|
|
|
499
499
|
const { unitId: e, subUnitId: t } = r, s = i.get(M).getFilterModel(e, t);
|
|
500
500
|
return s ? (s.reCalc(), !0) : !1;
|
|
501
501
|
}
|
|
502
|
+
}, Tt = {
|
|
503
|
+
id: "sheet.command.set-filter-range",
|
|
504
|
+
type: E.COMMAND,
|
|
505
|
+
handler: (i, r) => {
|
|
506
|
+
const e = i.get(M), t = i.get(N), n = i.get(q), s = i.get(T), { unitId: o, subUnitId: l, range: a } = r;
|
|
507
|
+
if (!b(s, r) || e.getFilterModel(o, l)) return !1;
|
|
508
|
+
if (a.endRow === a.startRow) {
|
|
509
|
+
const f = i.get(Ne), g = i.get(xe);
|
|
510
|
+
return f.emit(g.t("sheets-filter.command.not-valid-filter-range")), !1;
|
|
511
|
+
}
|
|
512
|
+
const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, u = t.syncExecuteCommand(d.id, d.params);
|
|
513
|
+
return u && n.pushUndoRedo({
|
|
514
|
+
unitID: o,
|
|
515
|
+
undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
|
|
516
|
+
redoMutations: [d]
|
|
517
|
+
}), u;
|
|
518
|
+
}
|
|
519
|
+
}, Nt = {
|
|
520
|
+
id: "sheet.command.remove-sheet-filter",
|
|
521
|
+
type: E.COMMAND,
|
|
522
|
+
handler: (i, r) => {
|
|
523
|
+
const e = i.get(T), t = i.get(M), n = i.get(N), s = i.get(q), o = b(e, r);
|
|
524
|
+
if (!o) return !1;
|
|
525
|
+
const { unitId: l, subUnitId: a } = o, c = t.getFilterModel(l, a);
|
|
526
|
+
if (!c) return !1;
|
|
527
|
+
const h = c == null ? void 0 : c.serialize(), d = xt(l, a, h), u = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
|
|
528
|
+
return u && s.pushUndoRedo({
|
|
529
|
+
unitID: l,
|
|
530
|
+
undoMutations: d,
|
|
531
|
+
redoMutations: [{ id: y.id, params: { unitId: l, subUnitId: a } }]
|
|
532
|
+
}), u;
|
|
533
|
+
}
|
|
534
|
+
}, Gt = {
|
|
535
|
+
id: "sheet.command.smart-toggle-filter",
|
|
536
|
+
type: E.COMMAND,
|
|
537
|
+
handler: async (i) => {
|
|
538
|
+
const r = i.get(T), e = i.get(M), t = i.get(N), n = r.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
|
|
539
|
+
if (!s || !n) return !1;
|
|
540
|
+
const o = n.getUnitId(), l = s.getSheetId();
|
|
541
|
+
if (e.getFilterModel(o, l))
|
|
542
|
+
return t.executeCommand(Nt.id, { unitId: o, subUnitId: l });
|
|
543
|
+
const h = i.get(be).getCurrentLastSelection();
|
|
544
|
+
if (!h) return !1;
|
|
545
|
+
const d = h.range, u = He(h) ? de(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
|
|
546
|
+
return t.executeCommand(Tt.id, {
|
|
547
|
+
unitId: o,
|
|
548
|
+
subUnitId: l,
|
|
549
|
+
range: u
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}, Jt = {
|
|
553
|
+
id: "sheet.command.set-filter-criteria",
|
|
554
|
+
type: E.COMMAND,
|
|
555
|
+
handler: (i, r) => {
|
|
556
|
+
const e = i.get(M), t = i.get(N), n = i.get(q), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
|
|
557
|
+
if (!c) return !1;
|
|
558
|
+
const h = c.getRange();
|
|
559
|
+
if (!h || l < h.startColumn || l > h.endColumn) return !1;
|
|
560
|
+
const d = c.getFilterColumn(l), u = $t(s, o, l, d), f = {
|
|
561
|
+
id: p.id,
|
|
562
|
+
params: {
|
|
563
|
+
unitId: s,
|
|
564
|
+
subUnitId: o,
|
|
565
|
+
col: l,
|
|
566
|
+
criteria: a
|
|
567
|
+
}
|
|
568
|
+
}, g = t.syncExecuteCommand(f.id, f.params);
|
|
569
|
+
return g && n.pushUndoRedo({
|
|
570
|
+
unitID: s,
|
|
571
|
+
undoMutations: [u],
|
|
572
|
+
redoMutations: [f]
|
|
573
|
+
}), g;
|
|
574
|
+
}
|
|
575
|
+
}, Yt = {
|
|
576
|
+
id: "sheet.command.clear-filter-criteria",
|
|
577
|
+
type: E.COMMAND,
|
|
578
|
+
handler: (i, r) => {
|
|
579
|
+
const e = i.get(M), t = i.get(q), n = i.get(N), s = i.get(T), o = b(s, r);
|
|
580
|
+
if (!o) return !1;
|
|
581
|
+
const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
|
|
582
|
+
if (!c) return !1;
|
|
583
|
+
const h = c.serialize(), d = we(l, a, h), u = It(l, a, h);
|
|
584
|
+
return Te(u, n).result ? (t.pushUndoRedo({
|
|
585
|
+
unitID: l,
|
|
586
|
+
undoMutations: d,
|
|
587
|
+
redoMutations: u
|
|
588
|
+
}), !0) : !1;
|
|
589
|
+
}
|
|
590
|
+
}, Kt = {
|
|
591
|
+
id: "sheet.command.re-calc-filter",
|
|
592
|
+
type: E.COMMAND,
|
|
593
|
+
handler: (i, r) => {
|
|
594
|
+
const e = i.get(M), t = i.get(N), n = i.get(T), s = b(n, r);
|
|
595
|
+
if (!s) return !1;
|
|
596
|
+
const { unitId: o, subUnitId: l } = s;
|
|
597
|
+
return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(W.id, { unitId: o, subUnitId: l }) : !1;
|
|
598
|
+
}
|
|
502
599
|
};
|
|
503
|
-
function
|
|
600
|
+
function xt(i, r, e) {
|
|
601
|
+
const t = [], n = {
|
|
602
|
+
id: R.id,
|
|
603
|
+
params: {
|
|
604
|
+
unitId: i,
|
|
605
|
+
subUnitId: r,
|
|
606
|
+
range: e.ref
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
return t.push(n), we(i, r, e).forEach((o) => t.push(o)), t;
|
|
610
|
+
}
|
|
611
|
+
function we(i, r, e) {
|
|
612
|
+
var n;
|
|
613
|
+
const t = [];
|
|
614
|
+
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
615
|
+
const o = {
|
|
616
|
+
id: p.id,
|
|
617
|
+
params: {
|
|
618
|
+
unitId: i,
|
|
619
|
+
subUnitId: r,
|
|
620
|
+
col: s.colId,
|
|
621
|
+
criteria: s
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
t.push(o);
|
|
625
|
+
}), t;
|
|
626
|
+
}
|
|
627
|
+
function It(i, r, e) {
|
|
628
|
+
var n;
|
|
629
|
+
const t = [];
|
|
630
|
+
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
631
|
+
const o = {
|
|
632
|
+
id: p.id,
|
|
633
|
+
params: {
|
|
634
|
+
unitId: i,
|
|
635
|
+
subUnitId: r,
|
|
636
|
+
col: s.colId,
|
|
637
|
+
criteria: null
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
t.push(o);
|
|
641
|
+
}), t;
|
|
642
|
+
}
|
|
643
|
+
function $t(i, r, e, t) {
|
|
644
|
+
if (!t)
|
|
645
|
+
return {
|
|
646
|
+
id: p.id,
|
|
647
|
+
params: {
|
|
648
|
+
unitId: i,
|
|
649
|
+
subUnitId: r,
|
|
650
|
+
col: e,
|
|
651
|
+
criteria: null
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const n = t.serialize();
|
|
655
|
+
return {
|
|
656
|
+
id: p.id,
|
|
657
|
+
params: {
|
|
658
|
+
unitId: i,
|
|
659
|
+
subUnitId: r,
|
|
660
|
+
col: e,
|
|
661
|
+
criteria: n
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
const Pt = "sheets-filter.config", le = {};
|
|
666
|
+
function Ut(i, r) {
|
|
504
667
|
for (let e = 0; e < i.length; e++) {
|
|
505
668
|
let t = e;
|
|
506
669
|
if (i[e])
|
|
@@ -510,17 +673,17 @@ function Nt(i, r) {
|
|
|
510
673
|
return i.filter((e) => e !== null);
|
|
511
674
|
}
|
|
512
675
|
function $(i) {
|
|
513
|
-
return
|
|
676
|
+
return Ut(i, (r, e) => r.id === p.id && e.id === p.id && r.params.unitId === e.params.unitId && r.params.subUnitId === e.params.subUnitId && r.params.col === e.params.col);
|
|
514
677
|
}
|
|
515
|
-
var
|
|
516
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
678
|
+
var Dt = Object.getOwnPropertyDescriptor, Lt = (i, r, e, t) => {
|
|
679
|
+
for (var n = t > 1 ? void 0 : t ? Dt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
|
|
517
680
|
(o = i[s]) && (n = o(n) || n);
|
|
518
681
|
return n;
|
|
519
682
|
}, P = (i, r) => (e, t) => r(e, t, i);
|
|
520
683
|
let j = class extends B {
|
|
521
684
|
constructor(r, e, t, n, s, o) {
|
|
522
685
|
super();
|
|
523
|
-
w(this, "_disposableCollection", new
|
|
686
|
+
w(this, "_disposableCollection", new $e());
|
|
524
687
|
this._commandService = r, this._sheetInterceptorService = e, this._sheetsFilterService = t, this._univerInstanceService = n, this._refRangeService = s, this._dataSyncPrimaryController = o, this._initCommands(), this._initRowFilteredInterceptor(), this._initInterceptors(), this._commandExecutedListener(), this._initErrorHandling();
|
|
525
688
|
}
|
|
526
689
|
_initCommands() {
|
|
@@ -538,7 +701,7 @@ let j = class extends B {
|
|
|
538
701
|
this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
|
|
539
702
|
getMutations: (r) => this._getUpdateFilter(r)
|
|
540
703
|
})), this.disposeWithMe(this._commandService.onCommandExecuted((r) => {
|
|
541
|
-
if (r.id ===
|
|
704
|
+
if (r.id === Ve.id) {
|
|
542
705
|
const e = r.params, t = e.subUnitId, n = e.unitId;
|
|
543
706
|
if (!t || !n)
|
|
544
707
|
return;
|
|
@@ -564,19 +727,19 @@ let j = class extends B {
|
|
|
564
727
|
if (!t || !n) return;
|
|
565
728
|
const s = (l = this._sheetsFilterService.getFilterModel(r, e)) == null ? void 0 : l.getRange(), o = (a) => {
|
|
566
729
|
switch (a.id) {
|
|
567
|
-
case
|
|
730
|
+
case tt.id: {
|
|
568
731
|
const c = a.params, h = c.unitId || r, d = c.subUnitId || e;
|
|
569
732
|
return this._handleInsertRowCommand(c, h, d);
|
|
570
733
|
}
|
|
571
|
-
case
|
|
734
|
+
case et.id: {
|
|
572
735
|
const c = a.params, h = c.unitId || r, d = c.subUnitId || e;
|
|
573
736
|
return this._handleInsertColCommand(c, h, d);
|
|
574
737
|
}
|
|
575
|
-
case
|
|
738
|
+
case Ze.id: {
|
|
576
739
|
const c = a.params;
|
|
577
740
|
return this._handleRemoveColCommand(c, r, e);
|
|
578
741
|
}
|
|
579
|
-
case
|
|
742
|
+
case Xe.id: {
|
|
580
743
|
const c = a.params;
|
|
581
744
|
return this._handleRemoveRowCommand(c, r, e);
|
|
582
745
|
}
|
|
@@ -588,7 +751,7 @@ let j = class extends B {
|
|
|
588
751
|
const c = a.params;
|
|
589
752
|
return this._handleMoveRowsCommand(c, r, e);
|
|
590
753
|
}
|
|
591
|
-
case
|
|
754
|
+
case Ke.id: {
|
|
592
755
|
const c = a.params;
|
|
593
756
|
return this._handleMoveRangeCommand(c, r, e);
|
|
594
757
|
}
|
|
@@ -600,11 +763,11 @@ let j = class extends B {
|
|
|
600
763
|
_getUpdateFilter(r) {
|
|
601
764
|
const { id: e } = r;
|
|
602
765
|
switch (e) {
|
|
603
|
-
case
|
|
766
|
+
case ke.id: {
|
|
604
767
|
const t = r.params;
|
|
605
768
|
return this._handleRemoveSheetCommand(t, t.unitId, t.subUnitId);
|
|
606
769
|
}
|
|
607
|
-
case
|
|
770
|
+
case je.id: {
|
|
608
771
|
const t = r.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = t;
|
|
609
772
|
return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
|
|
610
773
|
}
|
|
@@ -947,7 +1110,7 @@ let j = class extends B {
|
|
|
947
1110
|
return { redos: [], undos: [] };
|
|
948
1111
|
}
|
|
949
1112
|
_initRowFilteredInterceptor() {
|
|
950
|
-
this.disposeWithMe(this._sheetInterceptorService.intercept(
|
|
1113
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(qe.ROW_FILTERED, {
|
|
951
1114
|
// sheet-interceptor.service.ts
|
|
952
1115
|
handler: (r, e) => {
|
|
953
1116
|
var t, n;
|
|
@@ -1016,7 +1179,7 @@ let j = class extends B {
|
|
|
1016
1179
|
if (!s) return;
|
|
1017
1180
|
const o = Array.from(s.filteredOutRows).sort((d, u) => d - u), l = [];
|
|
1018
1181
|
let a = !1;
|
|
1019
|
-
if (r.id ===
|
|
1182
|
+
if (r.id === Qe.id) {
|
|
1020
1183
|
const { startRow: d, endRow: u } = r.params.range, f = o.filter((g) => g >= d && g <= u);
|
|
1021
1184
|
o.forEach((g) => {
|
|
1022
1185
|
if (g < d)
|
|
@@ -1028,13 +1191,13 @@ let j = class extends B {
|
|
|
1028
1191
|
l.push(g - (u - d + 1 - f.length));
|
|
1029
1192
|
});
|
|
1030
1193
|
}
|
|
1031
|
-
if (r.id ===
|
|
1194
|
+
if (r.id === Ge.id) {
|
|
1032
1195
|
const { startRow: d, endRow: u } = r.params.range;
|
|
1033
1196
|
o.forEach((f) => {
|
|
1034
1197
|
f >= d ? (a = !0, l.push(f + (u - d + 1))) : l.push(f);
|
|
1035
1198
|
});
|
|
1036
1199
|
}
|
|
1037
|
-
if (a && (s.filteredOutRows = new Set(l)), r.id ===
|
|
1200
|
+
if (a && (s.filteredOutRows = new Set(l)), r.id === Je.id && !(e != null && e.onlyLocal)) {
|
|
1038
1201
|
const d = this._getExtendRegion(t, n);
|
|
1039
1202
|
if (d) {
|
|
1040
1203
|
const u = r.params.cellValue;
|
|
@@ -1085,7 +1248,7 @@ let j = class extends B {
|
|
|
1085
1248
|
const { subUnitId: n, unitId: s } = t, o = this._sheetsFilterService.getFilterModel(s, n);
|
|
1086
1249
|
if (!o) return;
|
|
1087
1250
|
const l = o.getRange();
|
|
1088
|
-
if (r.id ===
|
|
1251
|
+
if (r.id === Ye.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
|
|
1089
1252
|
throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
|
|
1090
1253
|
}));
|
|
1091
1254
|
}
|
|
@@ -1094,16 +1257,16 @@ let j = class extends B {
|
|
|
1094
1257
|
return !(e.length === 0 || e.every((t) => t == null));
|
|
1095
1258
|
}
|
|
1096
1259
|
};
|
|
1097
|
-
j =
|
|
1260
|
+
j = Lt([
|
|
1098
1261
|
P(0, N),
|
|
1099
|
-
P(1, I(
|
|
1262
|
+
P(1, I(ze)),
|
|
1100
1263
|
P(2, I(M)),
|
|
1101
1264
|
P(3, T),
|
|
1102
|
-
P(4, I(
|
|
1103
|
-
P(5,
|
|
1265
|
+
P(4, I(We)),
|
|
1266
|
+
P(5, Ie(ot))
|
|
1104
1267
|
], j);
|
|
1105
|
-
var
|
|
1106
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
1268
|
+
var Bt = Object.getOwnPropertyDescriptor, bt = (i, r, e, t) => {
|
|
1269
|
+
for (var n = t > 1 ? void 0 : t ? Bt(r, e) : r, s = i.length - 1, o; s >= 0; s--)
|
|
1107
1270
|
(o = i[s]) && (n = o(n) || n);
|
|
1108
1271
|
return n;
|
|
1109
1272
|
}, H = (i, r) => (e, t) => r(e, t, i);
|
|
@@ -1156,26 +1319,26 @@ let k = class extends B {
|
|
|
1156
1319
|
});
|
|
1157
1320
|
}
|
|
1158
1321
|
};
|
|
1159
|
-
k =
|
|
1322
|
+
k = bt([
|
|
1160
1323
|
H(0, I(lt)),
|
|
1161
1324
|
H(1, I(at)),
|
|
1162
1325
|
H(2, I(M)),
|
|
1163
1326
|
H(3, T)
|
|
1164
1327
|
], k);
|
|
1165
|
-
var
|
|
1166
|
-
for (var n = t > 1 ? void 0 : t ?
|
|
1328
|
+
var Ht = Object.getOwnPropertyDescriptor, zt = (i, r, e, t) => {
|
|
1329
|
+
for (var n = t > 1 ? void 0 : t ? Ht(r, e) : r, s = i.length - 1, o; s >= 0; s--)
|
|
1167
1330
|
(o = i[s]) && (n = o(n) || n);
|
|
1168
1331
|
return n;
|
|
1169
1332
|
}, ae = (i, r) => (e, t) => r(e, t, i), z;
|
|
1170
|
-
let ce = (z = class extends
|
|
1171
|
-
constructor(i =
|
|
1333
|
+
let ce = (z = class extends Pe {
|
|
1334
|
+
constructor(i = le, r, e) {
|
|
1172
1335
|
super(), this._config = i, this._injector = r, this._configService = e;
|
|
1173
|
-
const { ...t } =
|
|
1336
|
+
const { ...t } = Ue(
|
|
1174
1337
|
{},
|
|
1175
|
-
|
|
1338
|
+
le,
|
|
1176
1339
|
this._config
|
|
1177
1340
|
);
|
|
1178
|
-
this._configService.setConfig(
|
|
1341
|
+
this._configService.setConfig(Pt, t);
|
|
1179
1342
|
}
|
|
1180
1343
|
onStarting() {
|
|
1181
1344
|
[
|
|
@@ -1185,202 +1348,39 @@ let ce = (z = class extends xe {
|
|
|
1185
1348
|
].forEach((i) => this._injector.add(i));
|
|
1186
1349
|
}
|
|
1187
1350
|
onReady() {
|
|
1188
|
-
|
|
1351
|
+
De(this._injector, [
|
|
1189
1352
|
[k],
|
|
1190
1353
|
[j]
|
|
1191
1354
|
]);
|
|
1192
1355
|
}
|
|
1193
1356
|
}, w(z, "type", D.UNIVER_SHEET), w(z, "pluginName", Fe), z);
|
|
1194
|
-
ce =
|
|
1195
|
-
ae(1, I(
|
|
1196
|
-
ae(2,
|
|
1357
|
+
ce = zt([
|
|
1358
|
+
ae(1, I(Le)),
|
|
1359
|
+
ae(2, Be)
|
|
1197
1360
|
], ce);
|
|
1198
|
-
const Lt = {
|
|
1199
|
-
id: "sheet.command.set-filter-range",
|
|
1200
|
-
type: E.COMMAND,
|
|
1201
|
-
handler: (i, r) => {
|
|
1202
|
-
const e = i.get(M), t = i.get(N), n = i.get(q), s = i.get(T), { unitId: o, subUnitId: l, range: a } = r;
|
|
1203
|
-
if (!b(s, r) || e.getFilterModel(o, l)) return !1;
|
|
1204
|
-
if (a.endRow === a.startRow) {
|
|
1205
|
-
const f = i.get(Le), g = i.get(Be);
|
|
1206
|
-
return f.emit(g.t("sheets-filter.command.not-valid-filter-range")), !1;
|
|
1207
|
-
}
|
|
1208
|
-
const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, u = t.syncExecuteCommand(d.id, d.params);
|
|
1209
|
-
return u && n.pushUndoRedo({
|
|
1210
|
-
unitID: o,
|
|
1211
|
-
undoMutations: [{ id: y.id, params: { unitId: o, subUnitId: l } }],
|
|
1212
|
-
redoMutations: [d]
|
|
1213
|
-
}), u;
|
|
1214
|
-
}
|
|
1215
|
-
}, Bt = {
|
|
1216
|
-
id: "sheet.command.remove-sheet-filter",
|
|
1217
|
-
type: E.COMMAND,
|
|
1218
|
-
handler: (i, r) => {
|
|
1219
|
-
const e = i.get(T), t = i.get(M), n = i.get(N), s = i.get(q), o = b(e, r);
|
|
1220
|
-
if (!o) return !1;
|
|
1221
|
-
const { unitId: l, subUnitId: a } = o, c = t.getFilterModel(l, a);
|
|
1222
|
-
if (!c) return !1;
|
|
1223
|
-
const h = c == null ? void 0 : c.serialize(), d = bt(l, a, h), u = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
|
|
1224
|
-
return u && s.pushUndoRedo({
|
|
1225
|
-
unitID: l,
|
|
1226
|
-
undoMutations: d,
|
|
1227
|
-
redoMutations: [{ id: y.id, params: { unitId: l, subUnitId: a } }]
|
|
1228
|
-
}), u;
|
|
1229
|
-
}
|
|
1230
|
-
}, Gt = {
|
|
1231
|
-
id: "sheet.command.smart-toggle-filter",
|
|
1232
|
-
type: E.COMMAND,
|
|
1233
|
-
handler: async (i) => {
|
|
1234
|
-
const r = i.get(T), e = i.get(M), t = i.get(N), n = r.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
|
|
1235
|
-
if (!s || !n) return !1;
|
|
1236
|
-
const o = n.getUnitId(), l = s.getSheetId();
|
|
1237
|
-
if (e.getFilterModel(o, l))
|
|
1238
|
-
return t.executeCommand(Bt.id, { unitId: o, subUnitId: l });
|
|
1239
|
-
const h = i.get(tt).getCurrentLastSelection();
|
|
1240
|
-
if (!h) return !1;
|
|
1241
|
-
const d = h.range, u = rt(h) ? de(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d;
|
|
1242
|
-
return t.executeCommand(Lt.id, {
|
|
1243
|
-
unitId: o,
|
|
1244
|
-
subUnitId: l,
|
|
1245
|
-
range: u
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
}, Jt = {
|
|
1249
|
-
id: "sheet.command.set-filter-criteria",
|
|
1250
|
-
type: E.COMMAND,
|
|
1251
|
-
handler: (i, r) => {
|
|
1252
|
-
const e = i.get(M), t = i.get(N), n = i.get(q), { unitId: s, subUnitId: o, col: l, criteria: a } = r, c = e.getFilterModel(s, o);
|
|
1253
|
-
if (!c) return !1;
|
|
1254
|
-
const h = c.getRange();
|
|
1255
|
-
if (!h || l < h.startColumn || l > h.endColumn) return !1;
|
|
1256
|
-
const d = c.getFilterColumn(l), u = zt(s, o, l, d), f = {
|
|
1257
|
-
id: p.id,
|
|
1258
|
-
params: {
|
|
1259
|
-
unitId: s,
|
|
1260
|
-
subUnitId: o,
|
|
1261
|
-
col: l,
|
|
1262
|
-
criteria: a
|
|
1263
|
-
}
|
|
1264
|
-
}, g = t.syncExecuteCommand(f.id, f.params);
|
|
1265
|
-
return g && n.pushUndoRedo({
|
|
1266
|
-
unitID: s,
|
|
1267
|
-
undoMutations: [u],
|
|
1268
|
-
redoMutations: [f]
|
|
1269
|
-
}), g;
|
|
1270
|
-
}
|
|
1271
|
-
}, Yt = {
|
|
1272
|
-
id: "sheet.command.clear-filter-criteria",
|
|
1273
|
-
type: E.COMMAND,
|
|
1274
|
-
handler: (i, r) => {
|
|
1275
|
-
const e = i.get(M), t = i.get(q), n = i.get(N), s = i.get(T), o = b(s, r);
|
|
1276
|
-
if (!o) return !1;
|
|
1277
|
-
const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
|
|
1278
|
-
if (!c) return !1;
|
|
1279
|
-
const h = c.serialize(), d = we(l, a, h), u = Ht(l, a, h);
|
|
1280
|
-
return De(u, n).result ? (t.pushUndoRedo({
|
|
1281
|
-
unitID: l,
|
|
1282
|
-
undoMutations: d,
|
|
1283
|
-
redoMutations: u
|
|
1284
|
-
}), !0) : !1;
|
|
1285
|
-
}
|
|
1286
|
-
}, Kt = {
|
|
1287
|
-
id: "sheet.command.re-calc-filter",
|
|
1288
|
-
type: E.COMMAND,
|
|
1289
|
-
handler: (i, r) => {
|
|
1290
|
-
const e = i.get(M), t = i.get(N), n = i.get(T), s = b(n, r);
|
|
1291
|
-
if (!s) return !1;
|
|
1292
|
-
const { unitId: o, subUnitId: l } = s;
|
|
1293
|
-
return e.getFilterModel(s.unitId, s.subUnitId) ? t.executeCommand(W.id, { unitId: o, subUnitId: l }) : !1;
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
function bt(i, r, e) {
|
|
1297
|
-
const t = [], n = {
|
|
1298
|
-
id: R.id,
|
|
1299
|
-
params: {
|
|
1300
|
-
unitId: i,
|
|
1301
|
-
subUnitId: r,
|
|
1302
|
-
range: e.ref
|
|
1303
|
-
}
|
|
1304
|
-
};
|
|
1305
|
-
return t.push(n), we(i, r, e).forEach((o) => t.push(o)), t;
|
|
1306
|
-
}
|
|
1307
|
-
function we(i, r, e) {
|
|
1308
|
-
var n;
|
|
1309
|
-
const t = [];
|
|
1310
|
-
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
1311
|
-
const o = {
|
|
1312
|
-
id: p.id,
|
|
1313
|
-
params: {
|
|
1314
|
-
unitId: i,
|
|
1315
|
-
subUnitId: r,
|
|
1316
|
-
col: s.colId,
|
|
1317
|
-
criteria: s
|
|
1318
|
-
}
|
|
1319
|
-
};
|
|
1320
|
-
t.push(o);
|
|
1321
|
-
}), t;
|
|
1322
|
-
}
|
|
1323
|
-
function Ht(i, r, e) {
|
|
1324
|
-
var n;
|
|
1325
|
-
const t = [];
|
|
1326
|
-
return (n = e.filterColumns) == null || n.forEach((s) => {
|
|
1327
|
-
const o = {
|
|
1328
|
-
id: p.id,
|
|
1329
|
-
params: {
|
|
1330
|
-
unitId: i,
|
|
1331
|
-
subUnitId: r,
|
|
1332
|
-
col: s.colId,
|
|
1333
|
-
criteria: null
|
|
1334
|
-
}
|
|
1335
|
-
};
|
|
1336
|
-
t.push(o);
|
|
1337
|
-
}), t;
|
|
1338
|
-
}
|
|
1339
|
-
function zt(i, r, e, t) {
|
|
1340
|
-
if (!t)
|
|
1341
|
-
return {
|
|
1342
|
-
id: p.id,
|
|
1343
|
-
params: {
|
|
1344
|
-
unitId: i,
|
|
1345
|
-
subUnitId: r,
|
|
1346
|
-
col: e,
|
|
1347
|
-
criteria: null
|
|
1348
|
-
}
|
|
1349
|
-
};
|
|
1350
|
-
const n = t.serialize();
|
|
1351
|
-
return {
|
|
1352
|
-
id: p.id,
|
|
1353
|
-
params: {
|
|
1354
|
-
unitId: i,
|
|
1355
|
-
subUnitId: r,
|
|
1356
|
-
col: e,
|
|
1357
|
-
criteria: n
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
1361
|
export {
|
|
1362
1362
|
Yt as ClearSheetsFilterCriteriaCommand,
|
|
1363
1363
|
x as CustomFilterOperator,
|
|
1364
1364
|
ge as FILTER_MUTATIONS,
|
|
1365
|
-
|
|
1365
|
+
Ct as FilterColumn,
|
|
1366
1366
|
V as FilterModel,
|
|
1367
1367
|
Kt as ReCalcSheetsFilterCommand,
|
|
1368
1368
|
W as ReCalcSheetsFilterMutation,
|
|
1369
|
-
|
|
1369
|
+
Nt as RemoveSheetFilterCommand,
|
|
1370
1370
|
y as RemoveSheetsFilterMutation,
|
|
1371
1371
|
Fe as SHEET_FILTER_SNAPSHOT_ID,
|
|
1372
|
-
|
|
1372
|
+
Tt as SetSheetFilterRangeCommand,
|
|
1373
1373
|
Jt as SetSheetsFilterCriteriaCommand,
|
|
1374
1374
|
p as SetSheetsFilterCriteriaMutation,
|
|
1375
1375
|
R as SetSheetsFilterRangeMutation,
|
|
1376
1376
|
M as SheetsFilterService,
|
|
1377
1377
|
Gt as SmartToggleSheetsFilterCommand,
|
|
1378
1378
|
ce as UniverSheetsFilterPlugin,
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1379
|
+
mt as equals,
|
|
1380
|
+
ie as getCustomFilterFn,
|
|
1381
|
+
ct as greaterThan,
|
|
1382
|
+
dt as greaterThanOrEqualTo,
|
|
1383
|
+
ut as lessThan,
|
|
1384
|
+
ht as lessThanOrEqualTo,
|
|
1385
1385
|
_e as notEquals
|
|
1386
1386
|
};
|