@univerjs/sheets-filter 0.16.1 → 0.17.0

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/index.js CHANGED
@@ -1,75 +1,75 @@
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 { createREGEXFromWildChar as ge, isNumeric as Le, Disposable as U, Rectangle as te, mergeSets as K, Tools as se, extractPureTextFromCell as Ue, CellValueType as k, ColorKit as oe, UniverInstanceType as D, fromCallback as Pe, CommandType as O, IResourceManagerService as De, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as Be, LocaleService as ze, Inject as A, Optional as He, DisposableCollection as _e, moveMatrixArray as le, IConfigService as Ce, 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 re, 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 ae, RemoveRowCommand as ot, RemoveColCommand as lt, InsertColCommand as at, InsertRowCommand as ct, InsertColMutation as Re, RemoveColMutation as pe, MoveColsMutation as Se } 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 Fe = "sheet.mutation.set-filter-range", we = "sheet.mutation.set-filter-criteria", ve = "sheet.mutation.remove-filter", Me = "sheet.mutation.re-calc-filter", Ee = /* @__PURE__ */ new Set([
11
- Fe,
1
+ var $e = Object.defineProperty;
2
+ var Le = (i, t, e) => t in i ? $e(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
+ var C = (i, t, e) => Le(i, typeof t != "symbol" ? t + "" : t, e);
4
+ import { createREGEXFromWildChar as _e, isNumeric as Ue, Disposable as P, Rectangle as te, mergeSets as K, Tools as se, extractPureTextFromCell as Pe, CellValueType as k, ColorKit as oe, UniverInstanceType as B, fromCallback as De, CommandType as O, IResourceManagerService as Be, IUniverInstanceService as T, ICommandService as N, IUndoRedoService as J, sequenceExecute as j, ErrorService as ze, LocaleService as He, Inject as A, Optional as Ve, DisposableCollection as Ce, moveMatrixArray as le, IConfigService as Re, Plugin as We, merge as je, touchDependencies as ke, Injector as qe } from "@univerjs/core";
5
+ import { getSheetCommandTarget as V, SheetsSelectionsService as Ge, isSingleCellSelection as Qe, expandToContinuousRange as re, SheetInterceptorService as Je, RefRangeService as Ze, ZebraCrossingCacheController as Ke, SetWorksheetActiveOperation as Ye, CopySheetCommand as Xe, RemoveSheetCommand as et, INTERCEPTOR_POINT as tt, RemoveRowMutation as rt, InsertRowMutation as nt, SetRangeValuesMutation as it, MoveRowsCommand as st, MoveRangeCommand as ot, EffectRefRangId as ae, RemoveRowCommand as lt, RemoveColCommand as at, InsertColCommand as ct, InsertRowCommand as dt, InsertColMutation as pe, RemoveColMutation as Se, MoveColsMutation as Fe } from "@univerjs/sheets";
6
+ import { BehaviorSubject as $, merge as ut, filter as ht, switchMap as ft, of as mt } from "rxjs";
7
+ import { COLOR_BLACK_RGB as gt } from "@univerjs/engine-render";
8
+ import { DataSyncPrimaryController as _t } from "@univerjs/rpc";
9
+ import { IActiveDirtyManagerService as Ct, ISheetRowFilteredService as Rt } from "@univerjs/engine-formula";
10
+ const we = "sheet.mutation.set-filter-range", ve = "sheet.mutation.set-filter-criteria", Me = "sheet.mutation.remove-filter", Ee = "sheet.mutation.re-calc-filter", Oe = /* @__PURE__ */ new Set([
12
11
  we,
13
12
  ve,
14
- Me
13
+ Me,
14
+ Ee
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 || {}), I = /* @__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))(I || {});
17
- const Rt = {
17
+ const pt = {
18
18
  operator: I.GREATER_THAN,
19
- fn: (i, t) => P(i) ? i > t : !1
20
- }, pt = {
21
- operator: I.GREATER_THAN_OR_EQUAL,
22
- fn: (i, t) => P(i) ? i >= t : !1
19
+ fn: (i, t) => D(i) ? i > t : !1
23
20
  }, St = {
24
- operator: I.LESS_THAN,
25
- fn: (i, t) => P(i) ? i < t : !1
21
+ operator: I.GREATER_THAN_OR_EQUAL,
22
+ fn: (i, t) => D(i) ? i >= t : !1
26
23
  }, Ft = {
27
- operator: I.LESS_THAN_OR_EQUAL,
28
- fn: (i, t) => P(i) ? i <= t : !1
24
+ operator: I.LESS_THAN,
25
+ fn: (i, t) => D(i) ? i < t : !1
29
26
  }, wt = {
27
+ operator: I.LESS_THAN_OR_EQUAL,
28
+ fn: (i, t) => D(i) ? i <= t : !1
29
+ }, vt = {
30
30
  operator: I.EQUAL,
31
- fn: (i, t) => P(i) ? i === t : !1
32
- }, Oe = {
31
+ fn: (i, t) => D(i) ? i === t : !1
32
+ }, ye = {
33
33
  operator: I.NOT_EQUALS,
34
34
  fn: (i, t) => {
35
35
  if (typeof t == "string") {
36
36
  if (t === " ")
37
37
  return i != null;
38
- const e = Ae(i);
39
- return e && Ot(t) ? !ge(t).test(e) : e !== t;
38
+ const e = Ne(i);
39
+ return e && yt(t) ? !_e(t).test(e) : e !== t;
40
40
  }
41
- return P(i) ? i !== t : !0;
41
+ return D(i) ? i !== t : !0;
42
42
  }
43
- }, ye = /* @__PURE__ */ new Map([]), vt = [Rt, pt, St, Ft, wt, Oe];
44
- vt.forEach((i) => {
45
- ye.set(i.operator, i);
43
+ }, Ae = /* @__PURE__ */ new Map([]), Mt = [pt, St, Ft, wt, vt, ye];
44
+ Mt.forEach((i) => {
45
+ Ae.set(i.operator, i);
46
46
  });
47
- function Mt(i) {
47
+ function Et(i) {
48
48
  return !!i;
49
49
  }
50
- const Et = {
50
+ const Ot = {
51
51
  fn: (i, t) => {
52
- const e = Ae(i);
53
- return e === null ? t === "" : ge(t).test(e);
52
+ const e = Ne(i);
53
+ return e === null ? t === "" : _e(t).test(e);
54
54
  }
55
55
  };
56
56
  function ce(i) {
57
- return i ? ye.get(i) : Et;
57
+ return i ? Ae.get(i) : Ot;
58
58
  }
59
- function P(i) {
59
+ function D(i) {
60
60
  return typeof i == "number";
61
61
  }
62
62
  function de(i) {
63
- return !!(typeof i == "number" || typeof i == "string" && Le(i));
63
+ return !!(typeof i == "number" || typeof i == "string" && Ue(i));
64
64
  }
65
- function Ae(i) {
65
+ function Ne(i) {
66
66
  return typeof i == "boolean" || i == null ? null : typeof i == "string" ? i : i.toString();
67
67
  }
68
- function Ot(i) {
68
+ function yt(i) {
69
69
  return typeof i == "number" ? !1 : i.indexOf("*") !== -1 || i.indexOf("?") !== -1;
70
70
  }
71
71
  const Y = () => /* @__PURE__ */ new Set();
72
- class q extends U {
72
+ class q extends P {
73
73
  constructor(e, r, n) {
74
74
  super();
75
75
  C(this, "_filteredOutRows$", new $(Y()));
@@ -187,7 +187,7 @@ class q extends U {
187
187
  if (e > o || e < s)
188
188
  throw new Error(`[FilterModel] could not set criteria on column ${e} which is out of range!`);
189
189
  let l;
190
- this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new yt(
190
+ this._filterColumnByIndex.has(e) ? l = this._filterColumnByIndex.get(e) : (l = new At(
191
191
  this.unitId,
192
192
  this.subUnitId,
193
193
  this._worksheet,
@@ -217,7 +217,7 @@ class q extends U {
217
217
  }
218
218
  }
219
219
  }
220
- class yt extends U {
220
+ class At extends P {
221
221
  constructor(e, r, n, s, o) {
222
222
  super();
223
223
  C(this, "_filteredOutRows", null);
@@ -285,30 +285,30 @@ class yt extends U {
285
285
  const { row: a, rowSpan: c, col: u } = l;
286
286
  if (o.has(a) && (!c || c === 1))
287
287
  continue;
288
- 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))
288
+ if (!(this._filterBy === b.VALUES ? this._filterFn(Pe(this._worksheet.getCell(a, u))) : this._filterBy === b.COLORS ? this._filterFn(this._worksheet.getComposedCellStyle(a, u)) : this._filterFn(Pt(this._worksheet, a, u))) && (s.add(a), c))
289
289
  for (let h = 1; h < c; h++)
290
290
  s.add(a + h);
291
291
  }
292
292
  return s;
293
293
  }
294
294
  _generateFilterFn() {
295
- this._criteria && (this._filterFn = At(this._criteria), this._filterBy = this._criteria.filters ? b.VALUES : this._criteria.colorFilters ? b.COLORS : b.CONDITIONS);
295
+ this._criteria && (this._filterFn = Nt(this._criteria), this._filterBy = this._criteria.filters ? b.VALUES : this._criteria.colorFilters ? b.COLORS : b.CONDITIONS);
296
296
  }
297
297
  }
298
- function At(i) {
298
+ function Nt(i) {
299
299
  if (i.filters)
300
- return Nt(i.filters);
300
+ return Tt(i.filters);
301
301
  if (i.colorFilters)
302
- return Tt(i.colorFilters);
302
+ return It(i.colorFilters);
303
303
  if (i.customFilters)
304
- return It(i.customFilters);
304
+ return xt(i.customFilters);
305
305
  throw new Error("[FilterModel]: other types of filters are not supported yet.");
306
306
  }
307
- function Nt(i) {
307
+ function Tt(i) {
308
308
  const t = !!i.blank, e = new Set(i.filters);
309
309
  return (r) => r === void 0 || r === "" ? t : e.has(typeof r == "string" ? r : `${r}`);
310
310
  }
311
- function Tt(i) {
311
+ function It(i) {
312
312
  if (i.cellFillColors) {
313
313
  const t = new Set(i.cellFillColors);
314
314
  return (e) => {
@@ -324,33 +324,33 @@ function Tt(i) {
324
324
  return (e) => {
325
325
  var n;
326
326
  if (!e || !((n = e.cl) != null && n.rgb))
327
- return !!t.has(mt);
327
+ return !!t.has(gt);
328
328
  const r = new oe(e.cl.rgb).toRgbString();
329
329
  return t.has(r);
330
330
  };
331
331
  }
332
332
  throw new Error("[FilterModel]: color filters are not supported yet.");
333
333
  }
334
- function It(i) {
335
- const t = i.customFilters.map((e) => Lt(e));
336
- return $t(t) ? i.and ? xt(t) : bt(t) : t[0];
337
- }
338
334
  function xt(i) {
335
+ const t = i.customFilters.map((e) => Ut(e));
336
+ return Lt(t) ? i.and ? bt(t) : $t(t) : t[0];
337
+ }
338
+ function bt(i) {
339
339
  const [t, e] = i;
340
340
  return (r) => t(r) && e(r);
341
341
  }
342
- function bt(i) {
342
+ function $t(i) {
343
343
  const [t, e] = i;
344
344
  return (r) => t(r) || e(r);
345
345
  }
346
- function $t(i) {
346
+ function Lt(i) {
347
347
  return i.length === 2;
348
348
  }
349
- function Lt(i) {
349
+ function Ut(i) {
350
350
  const t = i.val;
351
351
  if (i.operator === I.NOT_EQUALS && !de(t))
352
- return (n) => Oe.fn(n, t);
353
- if (Mt(i.operator)) {
352
+ return (n) => ye.fn(n, t);
353
+ if (Et(i.operator)) {
354
354
  if (!de(t)) return () => !1;
355
355
  const n = ce(i.operator), s = Number(t);
356
356
  return (o) => n.fn(o, s);
@@ -358,7 +358,7 @@ function Lt(i) {
358
358
  const e = ce(i.operator);
359
359
  return (r) => e.fn(r, t);
360
360
  }
361
- function Ut(i, t, e) {
361
+ function Pt(i, t, e) {
362
362
  const r = i.getCell(t, e);
363
363
  if (!r) return null;
364
364
  const n = i.getCellRaw(t, e);
@@ -371,13 +371,13 @@ function ue(i) {
371
371
  const e = i.v;
372
372
  return typeof e == "string" ? i.t === k.BOOLEAN ? e.toUpperCase() : e : typeof e == "number" ? i.t === k.BOOLEAN ? e ? "TRUE" : "FALSE" : e : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : "";
373
373
  }
374
- var Pt = Object.getOwnPropertyDescriptor, Dt = (i, t, e, r) => {
375
- for (var n = r > 1 ? void 0 : r ? Pt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
374
+ var Dt = Object.getOwnPropertyDescriptor, Bt = (i, t, e, r) => {
375
+ for (var n = r > 1 ? void 0 : r ? Dt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
376
376
  (o = i[s]) && (n = o(n) || n);
377
377
  return n;
378
378
  }, X = (i, t) => (e, r) => t(e, r, i);
379
- const Ne = "SHEET_FILTER_PLUGIN";
380
- let M = class extends U {
379
+ const Te = "SHEET_FILTER_PLUGIN";
380
+ let M = class extends P {
381
381
  constructor(t, e, r) {
382
382
  super();
383
383
  C(this, "_filterModels", /* @__PURE__ */ new Map());
@@ -426,7 +426,7 @@ let M = class extends U {
426
426
  _updateActiveFilterModel() {
427
427
  let t;
428
428
  try {
429
- if (t = this._univerInstanceService.getCurrentUnitForType(D.UNIVER_SHEET), !t) {
429
+ if (t = this._univerInstanceService.getCurrentUnitForType(B.UNIVER_SHEET), !t) {
430
430
  this._activeFilterModel$.next(null);
431
431
  return;
432
432
  }
@@ -444,13 +444,13 @@ let M = class extends U {
444
444
  }
445
445
  _initActiveFilterModel() {
446
446
  this.disposeWithMe(
447
- dt(
447
+ ut(
448
448
  // source1: executing filter related mutations
449
- Pe(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ut(([t]) => t.type === O.MUTATION && Ee.has(t.id))),
449
+ De(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(ht(([t]) => t.type === O.MUTATION && Oe.has(t.id))),
450
450
  // source2: activate sheet changes
451
- this._univerInstanceService.getCurrentTypeOfUnit$(D.UNIVER_SHEET).pipe(ht((t) => {
451
+ this._univerInstanceService.getCurrentTypeOfUnit$(B.UNIVER_SHEET).pipe(ft((t) => {
452
452
  var e;
453
- return (e = t == null ? void 0 : t.activeSheet$) != null ? e : ft(null);
453
+ return (e = t == null ? void 0 : t.activeSheet$) != null ? e : mt(null);
454
454
  }))
455
455
  ).subscribe(() => this._updateActiveFilterModel())
456
456
  );
@@ -478,8 +478,8 @@ let M = class extends U {
478
478
  }
479
479
  _initModel() {
480
480
  this._resourcesManagerService.registerPluginResource({
481
- pluginName: Ne,
482
- businesses: [D.UNIVER_SHEET],
481
+ pluginName: Te,
482
+ businesses: [B.UNIVER_SHEET],
483
483
  toJson: (t) => this._serializeAutoFiltersForUnit(t),
484
484
  parseJson: (t) => JSON.parse(t),
485
485
  onLoad: (t, e) => {
@@ -495,47 +495,47 @@ let M = class extends U {
495
495
  this._filterModels.has(t) || this._filterModels.set(t, /* @__PURE__ */ new Map()), this._filterModels.get(t).set(e, r);
496
496
  }
497
497
  };
498
- M = Dt([
499
- X(0, De),
498
+ M = Bt([
499
+ X(0, Be),
500
500
  X(1, T),
501
501
  X(2, N)
502
502
  ], M);
503
503
  const R = {
504
- id: Fe,
504
+ id: we,
505
505
  type: O.MUTATION,
506
506
  handler: (i, t) => {
507
507
  const { subUnitId: e, unitId: r, range: n } = t;
508
508
  return i.get(M).ensureFilterModel(r, e).setRange(n), !0;
509
509
  }
510
510
  }, p = {
511
- id: we,
511
+ id: ve,
512
512
  type: O.MUTATION,
513
513
  handler: (i, t) => {
514
514
  const { subUnitId: e, unitId: r, criteria: n, col: s, reCalc: o = !0 } = t, a = i.get(M).getFilterModel(r, e);
515
515
  return a ? (a.setCriteria(s, n, o), !0) : !1;
516
516
  }
517
517
  }, y = {
518
- id: ve,
518
+ id: Me,
519
519
  type: O.MUTATION,
520
520
  handler: (i, t) => {
521
521
  const { unitId: e, subUnitId: r } = t;
522
522
  return i.get(M).removeFilterModel(e, r);
523
523
  }
524
- }, B = {
525
- id: Me,
524
+ }, z = {
525
+ id: Ee,
526
526
  type: O.MUTATION,
527
527
  handler: (i, t) => {
528
528
  const { unitId: e, subUnitId: r } = t, s = i.get(M).getFilterModel(e, r);
529
529
  return s ? (s.reCalc(), !0) : !1;
530
530
  }
531
- }, Bt = {
531
+ }, zt = {
532
532
  id: "sheet.command.set-filter-range",
533
533
  type: O.COMMAND,
534
534
  handler: (i, t) => {
535
535
  const e = i.get(M), r = i.get(N), n = i.get(J), s = i.get(T), { unitId: o, subUnitId: l, range: a } = t;
536
- if (!H(s, t) || e.getFilterModel(o, l)) return !1;
536
+ if (!V(s, t) || e.getFilterModel(o, l)) return !1;
537
537
  if (a.endRow === a.startRow) {
538
- const g = i.get(Be), _ = i.get(ze);
538
+ const g = i.get(ze), _ = i.get(He);
539
539
  return g.emit(_.t("sheets-filter.command.not-valid-filter-range")), !1;
540
540
  }
541
541
  const d = { id: R.id, params: { unitId: o, subUnitId: l, range: a } }, h = r.syncExecuteCommand(d.id, d.params);
@@ -545,43 +545,43 @@ const R = {
545
545
  redoMutations: [d]
546
546
  }), h;
547
547
  }
548
- }, zt = {
548
+ }, Ht = {
549
549
  id: "sheet.command.remove-sheet-filter",
550
550
  type: O.COMMAND,
551
551
  handler: (i, t) => {
552
- const e = i.get(T), r = i.get(M), n = i.get(N), s = i.get(J), o = H(e, t);
552
+ const e = i.get(T), r = i.get(M), n = i.get(N), s = i.get(J), o = V(e, t);
553
553
  if (!o) return !1;
554
554
  const { unitId: l, subUnitId: a } = o, c = r.getFilterModel(l, a);
555
555
  if (!c) return !1;
556
- const u = c == null ? void 0 : c.serialize(), d = Ht(l, a, u), h = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
556
+ const u = c == null ? void 0 : c.serialize(), d = Vt(l, a, u), h = n.syncExecuteCommand(y.id, { unitId: l, subUnitId: a });
557
557
  return h && s.pushUndoRedo({
558
558
  unitID: l,
559
559
  undoMutations: d,
560
560
  redoMutations: [{ id: y.id, params: { unitId: l, subUnitId: a } }]
561
561
  }), h;
562
562
  }
563
- }, ar = {
563
+ }, ur = {
564
564
  id: "sheet.command.smart-toggle-filter",
565
565
  type: O.COMMAND,
566
566
  handler: async (i) => {
567
- const t = i.get(T), e = i.get(M), r = i.get(N), n = t.getCurrentUnitForType(D.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
567
+ const t = i.get(T), e = i.get(M), r = i.get(N), n = t.getCurrentUnitForType(B.UNIVER_SHEET), s = n == null ? void 0 : n.getActiveSheet();
568
568
  if (!s || !n) return !1;
569
569
  const o = n.getUnitId(), l = s.getSheetId();
570
570
  if (e.getFilterModel(o, l))
571
- return r.executeCommand(zt.id, { unitId: o, subUnitId: l });
572
- const u = i.get(qe).getCurrentLastSelection();
571
+ return r.executeCommand(Ht.id, { unitId: o, subUnitId: l });
572
+ const u = i.get(Ge).getCurrentLastSelection();
573
573
  if (!u) return !1;
574
574
  const d = u.range, h = (
575
575
  // If the selection is a single cell, we should expand it to a continuous range in all directions.
576
- Ge(u) ? re(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d.startRow === d.endRow ? re(d, { down: !0 }, s) : d
576
+ Qe(u) ? re(d, { left: !0, right: !0, up: !0, down: !0 }, s) : d.startRow === d.endRow ? re(d, { down: !0 }, s) : d
577
577
  );
578
- return r.executeCommand(Bt.id, {
578
+ return r.executeCommand(zt.id, {
579
579
  unitId: o,
580
580
  subUnitId: l,
581
581
  range: h
582
582
  });
583
583
  }
584
- }, cr = {
584
+ }, hr = {
585
585
  id: "sheet.command.set-filter-criteria",
586
586
  type: O.COMMAND,
587
587
  handler: (i, t) => {
@@ -589,7 +589,7 @@ const R = {
589
589
  if (!c) return !1;
590
590
  const u = c.getRange();
591
591
  if (!u || l < u.startColumn || l > u.endColumn) return !1;
592
- const d = c.getFilterColumn(l), h = Wt(s, o, l, d), g = {
592
+ const d = c.getFilterColumn(l), h = jt(s, o, l, d), g = {
593
593
  id: p.id,
594
594
  params: {
595
595
  unitId: s,
@@ -604,32 +604,32 @@ const R = {
604
604
  redoMutations: [g]
605
605
  }), _;
606
606
  }
607
- }, dr = {
607
+ }, fr = {
608
608
  id: "sheet.command.clear-filter-criteria",
609
609
  type: O.COMMAND,
610
610
  handler: (i, t) => {
611
- const e = i.get(M), r = i.get(J), n = i.get(N), s = i.get(T), o = H(s, t);
611
+ const e = i.get(M), r = i.get(J), n = i.get(N), s = i.get(T), o = V(s, t);
612
612
  if (!o) return !1;
613
613
  const { unitId: l, subUnitId: a } = o, c = e.getFilterModel(o.unitId, o.subUnitId);
614
614
  if (!c) return !1;
615
- const u = c.serialize(), d = Te(l, a, u), h = Vt(l, a, u);
615
+ const u = c.serialize(), d = Ie(l, a, u), h = Wt(l, a, u);
616
616
  return j(h, n).result ? (r.pushUndoRedo({
617
617
  unitID: l,
618
618
  undoMutations: d,
619
619
  redoMutations: h
620
620
  }), !0) : !1;
621
621
  }
622
- }, ur = {
622
+ }, mr = {
623
623
  id: "sheet.command.re-calc-filter",
624
624
  type: O.COMMAND,
625
625
  handler: (i, t) => {
626
- const e = i.get(M), r = i.get(N), n = i.get(T), s = H(n, t);
626
+ const e = i.get(M), r = i.get(N), n = i.get(T), s = V(n, t);
627
627
  if (!s) return !1;
628
628
  const { unitId: o, subUnitId: l } = s;
629
- return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(B.id, { unitId: o, subUnitId: l }) : !1;
629
+ return e.getFilterModel(s.unitId, s.subUnitId) ? r.executeCommand(z.id, { unitId: o, subUnitId: l }) : !1;
630
630
  }
631
631
  };
632
- function Ht(i, t, e) {
632
+ function Vt(i, t, e) {
633
633
  const r = [], n = {
634
634
  id: R.id,
635
635
  params: {
@@ -638,9 +638,9 @@ function Ht(i, t, e) {
638
638
  range: e.ref
639
639
  }
640
640
  };
641
- return r.push(n), Te(i, t, e).forEach((o) => r.push(o)), r;
641
+ return r.push(n), Ie(i, t, e).forEach((o) => r.push(o)), r;
642
642
  }
643
- function Te(i, t, e) {
643
+ function Ie(i, t, e) {
644
644
  var n;
645
645
  const r = [];
646
646
  return (n = e.filterColumns) == null || n.forEach((s) => {
@@ -656,7 +656,7 @@ function Te(i, t, e) {
656
656
  r.push(o);
657
657
  }), r;
658
658
  }
659
- function Vt(i, t, e) {
659
+ function Wt(i, t, e) {
660
660
  var n;
661
661
  const r = [];
662
662
  return (n = e.filterColumns) == null || n.forEach((s) => {
@@ -672,7 +672,7 @@ function Vt(i, t, e) {
672
672
  r.push(o);
673
673
  }), r;
674
674
  }
675
- function Wt(i, t, e, r) {
675
+ function jt(i, t, e, r) {
676
676
  if (!r)
677
677
  return {
678
678
  id: p.id,
@@ -694,8 +694,8 @@ function Wt(i, t, e, r) {
694
694
  }
695
695
  };
696
696
  }
697
- const Ie = "sheets-filter.config", he = {};
698
- function jt(i, t) {
697
+ const xe = "sheets-filter.config", he = {};
698
+ function kt(i, t) {
699
699
  for (let e = 0; e < i.length; e++) {
700
700
  let r = e;
701
701
  if (i[e])
@@ -705,17 +705,17 @@ function jt(i, t) {
705
705
  return i.filter((e) => e !== null);
706
706
  }
707
707
  function L(i) {
708
- 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);
708
+ return kt(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);
709
709
  }
710
- var kt = Object.getOwnPropertyDescriptor, qt = (i, t, e, r) => {
711
- for (var n = r > 1 ? void 0 : r ? kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
710
+ var qt = Object.getOwnPropertyDescriptor, Gt = (i, t, e, r) => {
711
+ for (var n = r > 1 ? void 0 : r ? qt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
712
712
  (o = i[s]) && (n = o(n) || n);
713
713
  return n;
714
714
  }, x = (i, t) => (e, r) => t(e, r, i);
715
- let z = class extends U {
715
+ let H = class extends P {
716
716
  constructor(t, e, r, n, s, o, l) {
717
717
  super();
718
- C(this, "_disposableCollection", new _e());
718
+ C(this, "_disposableCollection", new Ce());
719
719
  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();
720
720
  }
721
721
  _initZebraCrossingCacheListener() {
@@ -733,7 +733,7 @@ let z = class extends U {
733
733
  [
734
734
  p,
735
735
  R,
736
- B,
736
+ z,
737
737
  y
738
738
  ].forEach((t) => {
739
739
  var e;
@@ -744,7 +744,7 @@ let z = class extends U {
744
744
  this.disposeWithMe(this._sheetInterceptorService.interceptCommand({
745
745
  getMutations: (t) => this._getUpdateFilter(t)
746
746
  })), this.disposeWithMe(this._commandService.onCommandExecuted((t) => {
747
- if (t.id === Ke.id) {
747
+ if (t.id === Ye.id) {
748
748
  const e = t.params, r = e.subUnitId, n = e.unitId;
749
749
  if (!r || !n)
750
750
  return;
@@ -770,19 +770,19 @@ let z = class extends U {
770
770
  if (!r || !n) return;
771
771
  const s = (l = this._sheetsFilterService.getFilterModel(t, e)) == null ? void 0 : l.getRange(), o = (a) => {
772
772
  switch (a.id) {
773
- case ct.id: {
773
+ case dt.id: {
774
774
  const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
775
775
  return this._handleInsertRowCommand(c, u, d);
776
776
  }
777
- case at.id: {
777
+ case ct.id: {
778
778
  const c = a.params, u = c.unitId || t, d = c.subUnitId || e;
779
779
  return this.handleInsertColCommand(c.range, u, d);
780
780
  }
781
- case lt.id: {
781
+ case at.id: {
782
782
  const c = a.params;
783
783
  return this.handleRemoveColCommand(c.range, t, e);
784
784
  }
785
- case ot.id: {
785
+ case lt.id: {
786
786
  const c = a.params;
787
787
  return this._handleRemoveRowCommand(c, t, e);
788
788
  }
@@ -797,7 +797,7 @@ let z = class extends U {
797
797
  const c = a.params;
798
798
  return this._handleMoveRowsCommand(c, t, e);
799
799
  }
800
- case st.id: {
800
+ case ot.id: {
801
801
  const c = a.params;
802
802
  return this._handleMoveRangeCommand(c, t, e);
803
803
  }
@@ -809,11 +809,11 @@ let z = class extends U {
809
809
  _getUpdateFilter(t) {
810
810
  const { id: e } = t;
811
811
  switch (e) {
812
- case Xe.id: {
812
+ case et.id: {
813
813
  const r = t.params;
814
814
  return this._handleRemoveSheetCommand(r, r.unitId, r.subUnitId);
815
815
  }
816
- case Ye.id: {
816
+ case Xe.id: {
817
817
  const r = t.params, { targetSubUnitId: n, unitId: s, subUnitId: o } = r;
818
818
  return !s || !o || !n ? this._handleNull() : this._handleCopySheetCommand(s, o, n);
819
819
  }
@@ -1012,13 +1012,13 @@ let z = class extends U {
1012
1012
  subUnitId: n,
1013
1013
  col: E,
1014
1014
  criteria: { ...v.serialize(), colId: E }
1015
- }, xe = {
1015
+ }, be = {
1016
1016
  unitId: r,
1017
1017
  subUnitId: n,
1018
1018
  col: E,
1019
1019
  criteria: s.getFilterColumn(E) ? { ...(ne = s.getFilterColumn(E)) == null ? void 0 : ne.serialize(), colId: E } : null
1020
1020
  };
1021
- c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: xe });
1021
+ c.push({ id: p.id, params: Z }), u.push({ id: p.id, params: be });
1022
1022
  }
1023
1023
  if (!((ie = d[m]) != null && ie.filter)) {
1024
1024
  const Z = {
@@ -1074,7 +1074,7 @@ let z = class extends U {
1074
1074
  endRow: w
1075
1075
  }
1076
1076
  };
1077
- 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 } });
1077
+ u.push({ id: R.id, params: m }, { id: z.id, params: { unitId: e, subUnitId: r } }), d.push({ id: R.id, params: { range: s, unitId: e, subUnitId: r } }, { id: z.id, params: { unitId: e, subUnitId: r } });
1078
1078
  }
1079
1079
  return {
1080
1080
  redos: u,
@@ -1156,7 +1156,7 @@ let z = class extends U {
1156
1156
  return { redos: [], undos: [] };
1157
1157
  }
1158
1158
  _initRowFilteredInterceptor() {
1159
- this.disposeWithMe(this._sheetInterceptorService.intercept(et.ROW_FILTERED, {
1159
+ this.disposeWithMe(this._sheetInterceptorService.intercept(tt.ROW_FILTERED, {
1160
1160
  // sheet-interceptor.service.ts
1161
1161
  handler: (t, e) => {
1162
1162
  var r, n;
@@ -1225,7 +1225,7 @@ let z = class extends U {
1225
1225
  if (!s) return;
1226
1226
  const o = Array.from(s.filteredOutRows).sort((d, h) => d - h), l = [];
1227
1227
  let a = !1;
1228
- if (t.id === tt.id) {
1228
+ if (t.id === rt.id) {
1229
1229
  const { startRow: d, endRow: h } = t.params.range, g = o.filter((_) => _ >= d && _ <= h);
1230
1230
  o.forEach((_) => {
1231
1231
  if (_ < d)
@@ -1237,13 +1237,13 @@ let z = class extends U {
1237
1237
  l.push(_ - (h - d + 1 - g.length));
1238
1238
  });
1239
1239
  }
1240
- if (t.id === rt.id) {
1240
+ if (t.id === nt.id) {
1241
1241
  const { startRow: d, endRow: h } = t.params.range;
1242
1242
  o.forEach((g) => {
1243
1243
  g >= d ? (a = !0, l.push(g + (h - d + 1))) : l.push(g);
1244
1244
  });
1245
1245
  }
1246
- if (a && (s.filteredOutRows = new Set(l)), t.id === nt.id && !(e != null && e.onlyLocal)) {
1246
+ if (a && (s.filteredOutRows = new Set(l)), t.id === it.id && !(e != null && e.onlyLocal)) {
1247
1247
  const d = this._getExtendRegion(r, n);
1248
1248
  if (d) {
1249
1249
  const h = t.params.cellValue;
@@ -1289,12 +1289,12 @@ let z = class extends U {
1289
1289
  }
1290
1290
  _initErrorHandling() {
1291
1291
  this.disposeWithMe(this._commandService.beforeCommandExecuted((t) => {
1292
- const e = t.params, r = H(this._univerInstanceService, e);
1292
+ const e = t.params, r = V(this._univerInstanceService, e);
1293
1293
  if (!r) return;
1294
1294
  const { subUnitId: n, unitId: s } = r, o = this._sheetsFilterService.getFilterModel(s, n);
1295
1295
  if (!o) return;
1296
1296
  const l = o.getRange();
1297
- if (t.id === it.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1297
+ if (t.id === st.id && e.fromRange.startRow <= l.startRow && e.fromRange.endRow < l.endRow && e.fromRange.endRow >= l.startRow)
1298
1298
  throw this._sheetsFilterService.setFilterErrorMsg("sheets-filter.msg.filter-header-forbidden"), new Error("[SheetsFilterController]: Cannot move header row of filter");
1299
1299
  }));
1300
1300
  }
@@ -1303,39 +1303,39 @@ let z = class extends U {
1303
1303
  return !(e.length === 0 || e.every((r) => r == null));
1304
1304
  }
1305
1305
  };
1306
- z = qt([
1306
+ H = Gt([
1307
1307
  x(0, N),
1308
- x(1, A(Qe)),
1308
+ x(1, A(Je)),
1309
1309
  x(2, A(M)),
1310
1310
  x(3, T),
1311
- x(4, A(Je)),
1312
- x(5, He(gt)),
1313
- x(6, A(Ze))
1314
- ], z);
1315
- var Gt = Object.getOwnPropertyDescriptor, Qt = (i, t, e, r) => {
1316
- for (var n = r > 1 ? void 0 : r ? Gt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1311
+ x(4, A(Ze)),
1312
+ x(5, Ve(_t)),
1313
+ x(6, A(Ke))
1314
+ ], H);
1315
+ var Qt = Object.getOwnPropertyDescriptor, Jt = (i, t, e, r) => {
1316
+ for (var n = r > 1 ? void 0 : r ? Qt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1317
1317
  (o = i[s]) && (n = o(n) || n);
1318
1318
  return n;
1319
1319
  }, ee = (i, t) => (e, r) => t(e, r, i);
1320
- const Jt = [
1320
+ const Zt = [
1321
1321
  p.id,
1322
- B.id
1323
- ], Zt = [
1324
- Re.id,
1322
+ z.id
1323
+ ], Kt = [
1325
1324
  pe.id,
1326
- Se.id
1325
+ Se.id,
1326
+ Fe.id
1327
1327
  ];
1328
- let G = class extends U {
1328
+ let G = class extends P {
1329
1329
  constructor(t, e, r) {
1330
1330
  var s;
1331
1331
  super();
1332
- C(this, "_d", new _e());
1332
+ C(this, "_d", new Ce());
1333
1333
  C(this, "_visible$", new $(!1));
1334
1334
  C(this, "visible$", this._visible$.asObservable());
1335
1335
  C(this, "_enabled$", new $(!0));
1336
1336
  C(this, "enabled$", this._enabled$.asObservable());
1337
1337
  this._sheetsFilterController = t, this._commandService = e, this._configService = r;
1338
- const n = this._configService.getConfig(Ie);
1338
+ const n = this._configService.getConfig(xe);
1339
1339
  n != null && n.enableSyncSwitch && (this._visible$.next(!0), typeof n.enableSyncSwitch == "object" && this.setEnabled((s = n.enableSyncSwitch.defaultValue) != null ? s : !0));
1340
1340
  }
1341
1341
  get visible() {
@@ -1350,18 +1350,18 @@ let G = class extends U {
1350
1350
  _initOnlyLocalListener() {
1351
1351
  this._d.add(
1352
1352
  this._commandService.beforeCommandExecuted((t, e) => {
1353
- Jt.includes(t.id) && (e || (e = {}), e.onlyLocal = !0);
1353
+ Zt.includes(t.id) && (e || (e = {}), e.onlyLocal = !0);
1354
1354
  })
1355
1355
  ), this._d.add(
1356
1356
  this._commandService.onCommandExecuted((t, e) => {
1357
- if (Zt.includes(t.id) && (e != null && e.fromCollab)) {
1358
- if (t.id === Re.id) {
1357
+ if (Kt.includes(t.id) && (e != null && e.fromCollab)) {
1358
+ if (t.id === pe.id) {
1359
1359
  const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleInsertColCommand(r, n, s);
1360
1360
  j(o, this._commandService, e);
1361
- } else if (t.id === pe.id) {
1361
+ } else if (t.id === Se.id) {
1362
1362
  const { range: r, unitId: n, subUnitId: s } = t.params, { redos: o } = this._sheetsFilterController.handleRemoveColCommand(r, n, s);
1363
1363
  j(o, this._commandService, e);
1364
- } else if (t.id === Se.id) {
1364
+ } else if (t.id === Fe.id) {
1365
1365
  const { sourceRange: r, targetRange: n, unitId: s, subUnitId: o } = t.params, { redos: l } = this._sheetsFilterController.handleMoveColsCommand({ fromRange: r, toRange: n }, s, o);
1366
1366
  j(l, this._commandService, e);
1367
1367
  }
@@ -1370,22 +1370,26 @@ let G = class extends U {
1370
1370
  );
1371
1371
  }
1372
1372
  };
1373
- G = Qt([
1374
- ee(0, A(z)),
1373
+ G = Jt([
1374
+ ee(0, A(H)),
1375
1375
  ee(1, N),
1376
- ee(2, Ce)
1376
+ ee(2, Re)
1377
1377
  ], G);
1378
- var Kt = Object.getOwnPropertyDescriptor, Yt = (i, t, e, r) => {
1379
- for (var n = r > 1 ? void 0 : r ? Kt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1378
+ const Yt = "@univerjs/sheets-filter", Xt = "0.17.0", fe = {
1379
+ name: Yt,
1380
+ version: Xt
1381
+ };
1382
+ var er = Object.getOwnPropertyDescriptor, tr = (i, t, e, r) => {
1383
+ for (var n = r > 1 ? void 0 : r ? er(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1380
1384
  (o = i[s]) && (n = o(n) || n);
1381
1385
  return n;
1382
- }, V = (i, t) => (e, r) => t(e, r, i);
1383
- let Q = class extends U {
1386
+ }, W = (i, t) => (e, r) => t(e, r, i);
1387
+ let Q = class extends P {
1384
1388
  constructor(i, t, e, r) {
1385
1389
  super(), this._activeDirtyManagerService = i, this._sheetRowFilteredService = t, this._sheetsFilterService = e, this._univerInstanceService = r, this._initFormulaDirtyRange(), this._registerSheetRowFiltered();
1386
1390
  }
1387
1391
  _initFormulaDirtyRange() {
1388
- Ee.forEach((i) => {
1392
+ Oe.forEach((i) => {
1389
1393
  this._activeDirtyManagerService.register(
1390
1394
  i,
1391
1395
  {
@@ -1429,72 +1433,72 @@ let Q = class extends U {
1429
1433
  });
1430
1434
  }
1431
1435
  };
1432
- Q = Yt([
1433
- V(0, A(_t)),
1434
- V(1, A(Ct)),
1435
- V(2, A(M)),
1436
- V(3, T)
1436
+ Q = tr([
1437
+ W(0, A(Ct)),
1438
+ W(1, A(Rt)),
1439
+ W(2, A(M)),
1440
+ W(3, T)
1437
1441
  ], Q);
1438
- var Xt = Object.getOwnPropertyDescriptor, er = (i, t, e, r) => {
1439
- for (var n = r > 1 ? void 0 : r ? Xt(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1442
+ var rr = Object.getOwnPropertyDescriptor, nr = (i, t, e, r) => {
1443
+ for (var n = r > 1 ? void 0 : r ? rr(t, e) : t, s = i.length - 1, o; s >= 0; s--)
1440
1444
  (o = i[s]) && (n = o(n) || n);
1441
1445
  return n;
1442
- }, fe = (i, t) => (e, r) => t(e, r, i), W;
1443
- let me = (W = class extends Ve {
1446
+ }, me = (i, t) => (e, r) => t(e, r, i), U;
1447
+ let ge = (U = class extends We {
1444
1448
  constructor(i = he, t, e) {
1445
1449
  super(), this._config = i, this._injector = t, this._configService = e;
1446
- const { ...r } = We(
1450
+ const { ...r } = je(
1447
1451
  {},
1448
1452
  he,
1449
1453
  this._config
1450
1454
  );
1451
- this._configService.setConfig(Ie, r);
1455
+ this._configService.setConfig(xe, r);
1452
1456
  }
1453
1457
  onStarting() {
1454
1458
  [
1455
1459
  [Q],
1456
1460
  [M],
1457
- [z],
1461
+ [H],
1458
1462
  [G]
1459
1463
  ].forEach((i) => this._injector.add(i));
1460
1464
  }
1461
1465
  onReady() {
1462
- je(this._injector, [
1466
+ ke(this._injector, [
1463
1467
  [Q],
1464
- [z],
1468
+ [H],
1465
1469
  [G]
1466
1470
  ]);
1467
1471
  }
1468
- }, C(W, "type", D.UNIVER_SHEET), C(W, "pluginName", Ne), W);
1469
- me = er([
1470
- fe(1, A(ke)),
1471
- fe(2, Ce)
1472
- ], me);
1472
+ }, C(U, "type", B.UNIVER_SHEET), C(U, "pluginName", Te), C(U, "packageName", fe.name), C(U, "version", fe.version), U);
1473
+ ge = nr([
1474
+ me(1, A(qe)),
1475
+ me(2, Re)
1476
+ ], ge);
1473
1477
  export {
1474
- dr as ClearSheetsFilterCriteriaCommand,
1478
+ fr as ClearSheetsFilterCriteriaCommand,
1475
1479
  I as CustomFilterOperator,
1476
- Ee as FILTER_MUTATIONS,
1480
+ Oe as FILTER_MUTATIONS,
1477
1481
  b as FilterBy,
1478
- yt as FilterColumn,
1482
+ At as FilterColumn,
1479
1483
  q as FilterModel,
1480
- ur as ReCalcSheetsFilterCommand,
1481
- B as ReCalcSheetsFilterMutation,
1482
- zt as RemoveSheetFilterCommand,
1484
+ mr as ReCalcSheetsFilterCommand,
1485
+ z as ReCalcSheetsFilterMutation,
1486
+ Ht as RemoveSheetFilterCommand,
1483
1487
  y as RemoveSheetsFilterMutation,
1484
- Ne as SHEET_FILTER_SNAPSHOT_ID,
1485
- Bt as SetSheetFilterRangeCommand,
1486
- cr as SetSheetsFilterCriteriaCommand,
1488
+ Te as SHEET_FILTER_SNAPSHOT_ID,
1489
+ zt as SetSheetFilterRangeCommand,
1490
+ hr as SetSheetsFilterCriteriaCommand,
1487
1491
  p as SetSheetsFilterCriteriaMutation,
1488
1492
  R as SetSheetsFilterRangeMutation,
1489
1493
  M as SheetsFilterService,
1490
1494
  G as SheetsFilterSyncController,
1491
- ar as SmartToggleSheetsFilterCommand,
1492
- me as UniverSheetsFilterPlugin,
1493
- wt as equals,
1495
+ ur as SmartToggleSheetsFilterCommand,
1496
+ ge as UniverSheetsFilterPlugin,
1497
+ vt as equals,
1494
1498
  ce as getCustomFilterFn,
1495
- Rt as greaterThan,
1496
- pt as greaterThanOrEqualTo,
1497
- St as lessThan,
1498
- Ft as lessThanOrEqualTo,
1499
- Oe as notEquals
1499
+ pt as greaterThan,
1500
+ St as greaterThanOrEqualTo,
1501
+ Ft as lessThan,
1502
+ wt as lessThanOrEqualTo,
1503
+ ye as notEquals
1500
1504
  };