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