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