@univerjs/sheets-table 0.6.10-experimental.20250418-8830bd4
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/README.md +21 -0
- package/lib/cjs/facade.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/es/facade.js +67 -0
- package/lib/es/index.js +2696 -0
- package/lib/facade.js +67 -0
- package/lib/index.js +2696 -0
- package/lib/types/commands/commands/add-sheet-table.command.d.ts +11 -0
- package/lib/types/commands/commands/add-table-theme.command.d.ts +8 -0
- package/lib/types/commands/commands/delete-sheet-table.command.d.ts +3 -0
- package/lib/types/commands/commands/remove-table-theme.command.d.ts +7 -0
- package/lib/types/commands/commands/set-sheet-table.command.d.ts +7 -0
- package/lib/types/commands/commands/set-table-filter.command.d.ts +3 -0
- package/lib/types/commands/commands/sheet-table-row-col.command.d.ts +11 -0
- package/lib/types/commands/mutations/add-sheet-table.mutation.d.ts +14 -0
- package/lib/types/commands/mutations/delete-sheet-table.mutation.d.ts +7 -0
- package/lib/types/commands/mutations/set-sheet-table.mutation.d.ts +9 -0
- package/lib/types/commands/mutations/set-table-filter.mutation.d.ts +11 -0
- package/lib/types/const.d.ts +18 -0
- package/lib/types/controllers/sheet-table-range.controller.d.ts +9 -0
- package/lib/types/controllers/sheet-table-ref-range.controller.d.ts +19 -0
- package/lib/types/controllers/sheet-table-theme.controller.d.ts +12 -0
- package/lib/types/controllers/sheets-table.controller.d.ts +19 -0
- package/lib/types/controllers/table-filter.controller.d.ts +18 -0
- package/lib/types/controllers/table-theme.factory.d.ts +88 -0
- package/lib/types/facade/f-workbook.d.ts +88 -0
- package/lib/types/facade/f-worksheet.d.ts +17 -0
- package/lib/types/facade/index.d.ts +19 -0
- package/lib/types/index.d.ts +42 -0
- package/lib/types/model/filter-util/condition.d.ts +11 -0
- package/lib/types/model/filter-util/date-filter-util.d.ts +210 -0
- package/lib/types/model/filter-util/manual.d.ts +7 -0
- package/lib/types/model/filter-util/number-filter-util.d.ts +32 -0
- package/lib/types/model/filter-util/text-filter-util.d.ts +8 -0
- package/lib/types/model/filter-util/top-n.d.ts +29 -0
- package/lib/types/model/table-column.d.ts +24 -0
- package/lib/types/model/table-filter.d.ts +26 -0
- package/lib/types/model/table-manager.d.ts +79 -0
- package/lib/types/model/table.d.ts +81 -0
- package/lib/types/plugin.d.ts +12 -0
- package/lib/types/services/table-service.d.ts +18 -0
- package/lib/types/types/enum.d.ts +115 -0
- package/lib/types/types/type.d.ts +205 -0
- package/lib/types/util.d.ts +16 -0
- package/lib/umd/facade.js +1 -0
- package/lib/umd/index.js +1 -0
- package/package.json +81 -0
package/lib/es/index.js
ADDED
|
@@ -0,0 +1,2696 @@
|
|
|
1
|
+
var ze = Object.defineProperty;
|
|
2
|
+
var Ke = (t, e, n) => e in t ? ze(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var b = (t, e, n) => Ke(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { CellValueType as V, BorderStyleTypes as Xe, generateRandomId as L, IUniverInstanceService as J, Inject as S, LocaleService as fe, Disposable as k, CommandType as y, IUndoRedoService as $, ICommandService as x, sequenceExecute as A, IResourceManagerService as Ze, Rectangle as Re, RTree as et, InterceptorEffectEnum as tt, UniverInstanceType as Ce, Injector as Ae, Plugin as nt, registerDependencies as rt, touchDependencies as Ie } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as U, AddRangeThemeMutation as Be, RemoveRangeThemeMutation as Le, SheetRangeThemeModel as We, SheetInterceptorService as Se, INTERCEPTOR_POINT as Ee, SheetsSelectionsService as de, InsertRowMutation as He, RemoveRowMutation as Pe, getMoveRangeUndoRedoMutations as he, InsertColMutation as Ve, RemoveColMutation as qe, IExclusiveRangeService as st, RefRangeService as at, RemoveColCommand as ot, RemoveRowCommand as it, InsertColCommand as lt, InsertRowCommand as ut, SheetRangeThemeService as ct, RangeThemeStyle as dt } from "@univerjs/sheets";
|
|
6
|
+
import { Subject as Q, BehaviorSubject as Je, filter as ge, switchMap as Me } from "rxjs";
|
|
7
|
+
var ke = /* @__PURE__ */ ((t) => (t.None = "none", t.String = "string", t.Number = "number", t.Date = "date", t.Bool = "bool", t.Checkbox = "checkbox", t.List = "list", t))(ke || {}), ee = /* @__PURE__ */ ((t) => (t.manual = "manual", t.condition = "condition", t))(ee || {}), O = /* @__PURE__ */ ((t) => (t.Date = "date", t.Number = "number", t.String = "string", t.Logic = "logic", t))(O || {}), F = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.GreaterThan = "greaterThan", t.GreaterThanOrEqual = "greaterThanOrEqual", t.LessThan = "lessThan", t.LessThanOrEqual = "lessThanOrEqual", t.Between = "between", t.NotBetween = "notBetween", t.Above = "above", t.Below = "below", t.TopN = "topN", t))(F || {}), H = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.Contains = "contains", t.NotContains = "notContains", t.StartsWith = "startsWith", t.EndsWith = "endsWith", t))(H || {}), g = /* @__PURE__ */ ((t) => (t.Equal = "equal", t.NotEqual = "notEqual", t.After = "after", t.AfterOrEqual = "afterOrEqual", t.Before = "before", t.BeforeOrEqual = "beforeOrEqual", t.Between = "between", t.NotBetween = "notBetween", t.Today = "today", t.Yesterday = "yesterday", t.Tomorrow = "tomorrow", t.ThisWeek = "thisWeek", t.LastWeek = "lastWeek", t.NextWeek = "nextWeek", t.ThisMonth = "thisMonth", t.LastMonth = "lastMonth", t.NextMonth = "nextMonth", t.ThisQuarter = "thisQuarter", t.LastQuarter = "lastQuarter", t.NextQuarter = "nextQuarter", t.ThisYear = "thisYear", t.LastYear = "lastYear", t.NextYear = "nextYear", t.YearToDate = "yearToDate", t.Quarter = "quarter", t.Month = "month", t.M1 = "m1", t.M2 = "m2", t.M3 = "m3", t.M4 = "m4", t.M5 = "m5", t.M6 = "m6", t.M7 = "m7", t.M8 = "m8", t.M9 = "m9", t.M10 = "m10", t.M11 = "m11", t.M12 = "m12", t.Q1 = "q1", t.Q2 = "q2", t.Q3 = "q3", t.Q4 = "q4", t))(g || {}), P = /* @__PURE__ */ ((t) => (t[t.FilteredSortNone = 1] = "FilteredSortNone", t[t.FilteredSortAsc = 2] = "FilteredSortAsc", t[t.FilteredSortDesc = 3] = "FilteredSortDesc", t[t.FilterNoneSortNone = 4] = "FilterNoneSortNone", t[t.FilterNoneSortAsc = 5] = "FilterNoneSortAsc", t[t.FilterNoneSortDesc = 6] = "FilterNoneSortDesc", t))(P || {}), G = /* @__PURE__ */ ((t) => (t.Asc = "asc", t.Desc = "desc", t.None = "none", t))(G || {}), T = /* @__PURE__ */ ((t) => (t.Insert = "insert", t.Delete = "delete", t))(T || {}), D = /* @__PURE__ */ ((t) => (t.Row = "row", t.Col = "column", t))(D || {});
|
|
8
|
+
function Z(t, e) {
|
|
9
|
+
return `${e} ${t}`;
|
|
10
|
+
}
|
|
11
|
+
const ve = "TRUE", Fe = "FALSE", ht = (t) => {
|
|
12
|
+
var n;
|
|
13
|
+
return ((n = t.body) == null ? void 0 : n.dataStream.replace(/\r\n$/, "")) || "";
|
|
14
|
+
};
|
|
15
|
+
function Qe(t) {
|
|
16
|
+
if (t) {
|
|
17
|
+
const { v: e, t: n, p: r } = t;
|
|
18
|
+
return r ? ht(r) : (n === V.FORCE_STRING || n === V.STRING) && e !== void 0 && e !== null ? String(e) : n === V.BOOLEAN ? e ? ve : Fe : n === V.NUMBER ? String(e) : typeof e === "boolean" ? e ? ve : Fe : e == null ? "" : String(e);
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
function gt(t, e) {
|
|
23
|
+
if (t !== void 0)
|
|
24
|
+
switch (e) {
|
|
25
|
+
case G.Asc:
|
|
26
|
+
return P.FilteredSortAsc;
|
|
27
|
+
case G.Desc:
|
|
28
|
+
return P.FilteredSortDesc;
|
|
29
|
+
default:
|
|
30
|
+
return P.FilteredSortNone;
|
|
31
|
+
}
|
|
32
|
+
else
|
|
33
|
+
switch (e) {
|
|
34
|
+
case G.Asc:
|
|
35
|
+
return P.FilterNoneSortAsc;
|
|
36
|
+
case G.Desc:
|
|
37
|
+
return P.FilterNoneSortDesc;
|
|
38
|
+
default:
|
|
39
|
+
return P.FilterNoneSortNone;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function mt(t) {
|
|
43
|
+
return t ? t.filterType === ee.condition : !1;
|
|
44
|
+
}
|
|
45
|
+
function jn(t) {
|
|
46
|
+
return t ? t.filterType === ee.manual : !1;
|
|
47
|
+
}
|
|
48
|
+
const N = {
|
|
49
|
+
s: Xe.THIN,
|
|
50
|
+
cl: {
|
|
51
|
+
rgb: "rgb(95 101 116)"
|
|
52
|
+
}
|
|
53
|
+
}, zn = {
|
|
54
|
+
headerRowStyle: {
|
|
55
|
+
bd: {
|
|
56
|
+
t: N
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
headerColumnStyle: {
|
|
60
|
+
bd: {
|
|
61
|
+
l: N
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
lastColumnStyle: {
|
|
65
|
+
bd: {
|
|
66
|
+
r: N
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
lastRowStyle: {
|
|
70
|
+
bd: {
|
|
71
|
+
b: N
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, Kn = (t, e) => {
|
|
75
|
+
if (t === "headerRowStyle") {
|
|
76
|
+
if (!e.bd)
|
|
77
|
+
return {
|
|
78
|
+
...e,
|
|
79
|
+
bd: {
|
|
80
|
+
t: N
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
} else if (t === "lastRowStyle") {
|
|
84
|
+
if (!e.bd)
|
|
85
|
+
return {
|
|
86
|
+
...e,
|
|
87
|
+
bd: {
|
|
88
|
+
b: N
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
} else if (t === "lastColumnStyle") {
|
|
92
|
+
if (!e.bd)
|
|
93
|
+
return {
|
|
94
|
+
...e,
|
|
95
|
+
bd: {
|
|
96
|
+
r: N
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
} else if (t === "headerColumnStyle" && !e.bd)
|
|
100
|
+
return {
|
|
101
|
+
...e,
|
|
102
|
+
bd: {
|
|
103
|
+
l: N
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return e;
|
|
107
|
+
}, bt = [
|
|
108
|
+
[["#6280F9", "#FFFFFF", "#BAC6F8", "#D2DAFA"], ["#fff"]],
|
|
109
|
+
[["#16BDCA", "#FFFFFF", "#EDFAFA", "#AFECEF"], ["#000"]],
|
|
110
|
+
[["#31C48D", "#FFFFFF", "#F3FAF7", "#BCF0DA"], ["#fff"]],
|
|
111
|
+
[["#AC94FA", "#FFFFFF", "#F6F5FF", "#EDEBFE"], ["#fff"]],
|
|
112
|
+
[["#F17EBB", "#FFFFFF", "#FDF2F8", "#FCE8F3"], ["#fff"]],
|
|
113
|
+
[["#F98080", "#FFFFFF", "#FDF2F2", "#FDE8E8"], ["#fff"]]
|
|
114
|
+
], Y = bt.map((t, e) => {
|
|
115
|
+
const [n, r] = t, [s, a, o, l] = n, [u] = r;
|
|
116
|
+
return {
|
|
117
|
+
name: `table-default-${e}`,
|
|
118
|
+
style: {
|
|
119
|
+
headerRowStyle: {
|
|
120
|
+
bg: {
|
|
121
|
+
rgb: s
|
|
122
|
+
},
|
|
123
|
+
cl: {
|
|
124
|
+
rgb: u
|
|
125
|
+
},
|
|
126
|
+
bd: {
|
|
127
|
+
t: N
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
headerColumnStyle: {
|
|
131
|
+
bd: {
|
|
132
|
+
l: N
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
firstRowStyle: {
|
|
136
|
+
bg: {
|
|
137
|
+
rgb: a
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
secondRowStyle: {
|
|
141
|
+
bg: {
|
|
142
|
+
rgb: o
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
lastRowStyle: {
|
|
146
|
+
bg: {
|
|
147
|
+
rgb: l
|
|
148
|
+
},
|
|
149
|
+
bd: {
|
|
150
|
+
b: N
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
lastColumnStyle: {
|
|
154
|
+
bd: {
|
|
155
|
+
r: N
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
class q {
|
|
162
|
+
constructor(e, n) {
|
|
163
|
+
b(this, "dataType");
|
|
164
|
+
b(this, "id");
|
|
165
|
+
b(this, "displayName");
|
|
166
|
+
b(this, "formula");
|
|
167
|
+
b(this, "meta");
|
|
168
|
+
b(this, "style");
|
|
169
|
+
this.id = e, this.displayName = n, this.dataType = ke.String, this.formula = "", this.meta = {}, this.style = {};
|
|
170
|
+
}
|
|
171
|
+
getMeta() {
|
|
172
|
+
return this.meta;
|
|
173
|
+
}
|
|
174
|
+
setMeta(e) {
|
|
175
|
+
this.meta = e;
|
|
176
|
+
}
|
|
177
|
+
getDisplayName() {
|
|
178
|
+
return this.displayName;
|
|
179
|
+
}
|
|
180
|
+
toJSON() {
|
|
181
|
+
return {
|
|
182
|
+
id: this.id,
|
|
183
|
+
displayName: this.displayName,
|
|
184
|
+
dataType: this.dataType,
|
|
185
|
+
formula: this.formula,
|
|
186
|
+
meta: this.meta,
|
|
187
|
+
style: this.style
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
fromJSON(e) {
|
|
191
|
+
this.id = e.id, this.displayName = e.displayName, this.dataType = e.dataType, this.formula = e.formula, this.meta = e.meta, this.style = e.style;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const wt = (t) => t.getMonth() <= 2, Rt = (t) => {
|
|
195
|
+
const e = t.getMonth();
|
|
196
|
+
return e > 2 && e <= 5;
|
|
197
|
+
}, pt = (t) => {
|
|
198
|
+
const e = t.getMonth();
|
|
199
|
+
return e > 5 && e <= 8;
|
|
200
|
+
}, ft = (t) => {
|
|
201
|
+
const e = t.getMonth();
|
|
202
|
+
return e > 8 && e <= 11;
|
|
203
|
+
}, Ct = (t) => t.getMonth() === 0, St = (t) => t.getMonth() === 1, _t = (t) => t.getMonth() === 2, Tt = (t) => t.getMonth() === 3, It = (t) => t.getMonth() === 4, Mt = (t) => t.getMonth() === 5, vt = (t) => t.getMonth() === 6, Ft = (t) => t.getMonth() === 7, Dt = (t) => t.getMonth() === 8, yt = (t) => t.getMonth() === 9, Nt = (t) => t.getMonth() === 10, xt = (t) => t.getMonth() === 11, Ot = (t, e = /* @__PURE__ */ new Date()) => t.toDateString() === e.toDateString(), Ut = (t, e = /* @__PURE__ */ new Date()) => {
|
|
204
|
+
const n = new Date(e);
|
|
205
|
+
return n.setDate(n.getDate() + 1), t.toDateString() === n.toDateString();
|
|
206
|
+
}, $t = (t, e = /* @__PURE__ */ new Date()) => {
|
|
207
|
+
const n = new Date(e);
|
|
208
|
+
return n.setDate(n.getDate() - 1), t.toDateString() === n.toDateString();
|
|
209
|
+
}, j = (t) => {
|
|
210
|
+
const e = t.getDay(), n = t.getDate() - e + (e === 0 ? -6 : 1), r = new Date(t);
|
|
211
|
+
return r.setDate(n), r;
|
|
212
|
+
}, Ye = 7 * 24 * 60 * 60 * 1e3, At = (t, e = /* @__PURE__ */ new Date()) => {
|
|
213
|
+
const n = j(t), r = j(e);
|
|
214
|
+
return n.toDateString() === r.toDateString();
|
|
215
|
+
}, Bt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
216
|
+
const n = j(t), r = new Date(j(e).getTime() + Ye);
|
|
217
|
+
return n.toDateString() === r.toDateString();
|
|
218
|
+
}, Lt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
219
|
+
const n = j(t), r = new Date(j(e).getTime() - Ye);
|
|
220
|
+
return n.toDateString() === r.toDateString();
|
|
221
|
+
}, Wt = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth(), Et = (t) => {
|
|
222
|
+
const e = new Date(t);
|
|
223
|
+
return e.setHours(0, 0, 0, 0), e.setDate(1), e;
|
|
224
|
+
}, Ht = (t, e = /* @__PURE__ */ new Date()) => {
|
|
225
|
+
const n = new Date(e);
|
|
226
|
+
n.setHours(0, 0, 0, 0), n.setMonth(n.getMonth() + 1, 1);
|
|
227
|
+
const r = new Date(n);
|
|
228
|
+
r.setMonth(r.getMonth() + 1, 0);
|
|
229
|
+
const s = t.getTime();
|
|
230
|
+
return s >= n.getTime() && s < r.getTime();
|
|
231
|
+
}, Pt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
232
|
+
const n = Et(e), r = new Date(n);
|
|
233
|
+
r.setMonth(r.getMonth() + 1, 0);
|
|
234
|
+
const s = t.getTime();
|
|
235
|
+
return s >= n.getTime() && s < r.getTime();
|
|
236
|
+
}, _e = (t) => {
|
|
237
|
+
const e = new Date(t);
|
|
238
|
+
e.setHours(0, 0, 0, 0), e.setDate(1);
|
|
239
|
+
const n = e.getMonth();
|
|
240
|
+
return e.setMonth(n - n % 3), e;
|
|
241
|
+
}, Vt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
242
|
+
const n = _e(e), r = new Date(n);
|
|
243
|
+
r.setMonth(r.getMonth() + 3);
|
|
244
|
+
const s = t.getTime();
|
|
245
|
+
return s >= n.getTime() && s < r.getTime();
|
|
246
|
+
}, qt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
247
|
+
const n = _e(e), r = new Date(n);
|
|
248
|
+
r.setMonth(r.getMonth() + 3);
|
|
249
|
+
const s = new Date(r);
|
|
250
|
+
s.setMonth(s.getMonth() + 3, 0);
|
|
251
|
+
const a = t.getTime();
|
|
252
|
+
return a >= r.getTime() && a < s.getTime();
|
|
253
|
+
}, Jt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
254
|
+
const n = _e(e), r = new Date(n);
|
|
255
|
+
r.setMonth(r.getMonth() - 3);
|
|
256
|
+
const s = new Date(n);
|
|
257
|
+
s.setDate(0);
|
|
258
|
+
const a = t.getTime();
|
|
259
|
+
return a >= r.getTime() && a < s.getTime();
|
|
260
|
+
}, kt = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear(), Qt = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() + 1, Yt = (t, e = /* @__PURE__ */ new Date()) => t.getFullYear() === e.getFullYear() - 1, Gt = (t, e = /* @__PURE__ */ new Date()) => {
|
|
261
|
+
const n = new Date(e);
|
|
262
|
+
n.setHours(0, 0, 0, 0), n.setMonth(0, 1);
|
|
263
|
+
const r = t.getTime();
|
|
264
|
+
return r >= n.getTime() && r < e.getTime();
|
|
265
|
+
};
|
|
266
|
+
function jt(t) {
|
|
267
|
+
switch (t.compareType) {
|
|
268
|
+
case g.Equal: {
|
|
269
|
+
const e = t.expectedValue;
|
|
270
|
+
return (n) => n.getTime() === e.getTime();
|
|
271
|
+
}
|
|
272
|
+
case g.NotEqual: {
|
|
273
|
+
const e = t.expectedValue;
|
|
274
|
+
return (n) => n.getTime() !== e.getTime();
|
|
275
|
+
}
|
|
276
|
+
case g.After: {
|
|
277
|
+
const e = t.expectedValue;
|
|
278
|
+
return (n) => n.getTime() > e.getTime();
|
|
279
|
+
}
|
|
280
|
+
case g.Before: {
|
|
281
|
+
const e = t.expectedValue;
|
|
282
|
+
return (n) => n.getTime() < e.getTime();
|
|
283
|
+
}
|
|
284
|
+
case g.AfterOrEqual: {
|
|
285
|
+
const e = t.expectedValue;
|
|
286
|
+
return (n) => n.getTime() >= e.getTime();
|
|
287
|
+
}
|
|
288
|
+
case g.BeforeOrEqual: {
|
|
289
|
+
const e = t.expectedValue;
|
|
290
|
+
return (n) => n.getTime() <= e.getTime();
|
|
291
|
+
}
|
|
292
|
+
case g.Between:
|
|
293
|
+
return (e) => {
|
|
294
|
+
const [n, r] = t.expectedValue;
|
|
295
|
+
return e.getTime() >= new Date(n).getTime() && e.getTime() <= new Date(r).getTime();
|
|
296
|
+
};
|
|
297
|
+
case g.NotBetween:
|
|
298
|
+
return (e) => {
|
|
299
|
+
const [n, r] = t.expectedValue;
|
|
300
|
+
return e.getTime() < new Date(n).getTime() || e.getTime() > new Date(r).getTime();
|
|
301
|
+
};
|
|
302
|
+
case g.Today: {
|
|
303
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
304
|
+
return (n) => Ot(n, e);
|
|
305
|
+
}
|
|
306
|
+
case g.Yesterday: {
|
|
307
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
308
|
+
return (n) => $t(n, e);
|
|
309
|
+
}
|
|
310
|
+
case g.Tomorrow: {
|
|
311
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
312
|
+
return (n) => Ut(n, e);
|
|
313
|
+
}
|
|
314
|
+
case g.ThisWeek: {
|
|
315
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
316
|
+
return (n) => At(n, e);
|
|
317
|
+
}
|
|
318
|
+
case g.LastWeek: {
|
|
319
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
320
|
+
return (n) => Lt(n, e);
|
|
321
|
+
}
|
|
322
|
+
case g.NextWeek: {
|
|
323
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
324
|
+
return (n) => Bt(n, e);
|
|
325
|
+
}
|
|
326
|
+
case g.ThisMonth: {
|
|
327
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
328
|
+
return (n) => Wt(n, e);
|
|
329
|
+
}
|
|
330
|
+
case g.LastMonth: {
|
|
331
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
332
|
+
return (n) => Pt(n, e);
|
|
333
|
+
}
|
|
334
|
+
case g.NextMonth: {
|
|
335
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
336
|
+
return (n) => Ht(n, e);
|
|
337
|
+
}
|
|
338
|
+
case g.ThisQuarter: {
|
|
339
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
340
|
+
return (n) => Vt(n, e);
|
|
341
|
+
}
|
|
342
|
+
case g.LastQuarter: {
|
|
343
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
344
|
+
return (n) => Jt(n, e);
|
|
345
|
+
}
|
|
346
|
+
case g.NextQuarter: {
|
|
347
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
348
|
+
return (n) => qt(n, e);
|
|
349
|
+
}
|
|
350
|
+
case g.ThisYear: {
|
|
351
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
352
|
+
return (n) => kt(n, e);
|
|
353
|
+
}
|
|
354
|
+
case g.LastYear: {
|
|
355
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
356
|
+
return (n) => Yt(n, e);
|
|
357
|
+
}
|
|
358
|
+
case g.NextYear: {
|
|
359
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
360
|
+
return (n) => Qt(n, e);
|
|
361
|
+
}
|
|
362
|
+
case g.YearToDate: {
|
|
363
|
+
const e = t.anchorTime ? new Date(t.anchorTime) : /* @__PURE__ */ new Date();
|
|
364
|
+
return (n) => Gt(n, e);
|
|
365
|
+
}
|
|
366
|
+
case g.M1:
|
|
367
|
+
return Ct;
|
|
368
|
+
case g.M2:
|
|
369
|
+
return St;
|
|
370
|
+
case g.M3:
|
|
371
|
+
return _t;
|
|
372
|
+
case g.M4:
|
|
373
|
+
return Tt;
|
|
374
|
+
case g.M5:
|
|
375
|
+
return It;
|
|
376
|
+
case g.M6:
|
|
377
|
+
return Mt;
|
|
378
|
+
case g.M7:
|
|
379
|
+
return vt;
|
|
380
|
+
case g.M8:
|
|
381
|
+
return Ft;
|
|
382
|
+
case g.M9:
|
|
383
|
+
return Dt;
|
|
384
|
+
case g.M10:
|
|
385
|
+
return yt;
|
|
386
|
+
case g.M11:
|
|
387
|
+
return Nt;
|
|
388
|
+
case g.M12:
|
|
389
|
+
return xt;
|
|
390
|
+
case g.Q1:
|
|
391
|
+
return wt;
|
|
392
|
+
case g.Q2:
|
|
393
|
+
return Rt;
|
|
394
|
+
case g.Q3:
|
|
395
|
+
return pt;
|
|
396
|
+
case g.Q4:
|
|
397
|
+
return ft;
|
|
398
|
+
default:
|
|
399
|
+
throw new Error("Unsupported compare type");
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
class zt {
|
|
403
|
+
/**
|
|
404
|
+
* Initializes a new instance of the Heap class.
|
|
405
|
+
*/
|
|
406
|
+
constructor() {
|
|
407
|
+
b(this, "heap");
|
|
408
|
+
this.heap = [];
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Swaps the elements at the given indices in the heap.
|
|
412
|
+
* @param index1 The index of the first element.
|
|
413
|
+
* @param index2 The index of the second element.
|
|
414
|
+
*/
|
|
415
|
+
swap(e, n) {
|
|
416
|
+
const r = this.heap[e];
|
|
417
|
+
this.heap[e] = this.heap[n], this.heap[n] = r;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Returns the index of the parent node for the given index.
|
|
421
|
+
* @param index The index of the node.
|
|
422
|
+
* @returns The index of the parent node.
|
|
423
|
+
*/
|
|
424
|
+
getParentIndex(e) {
|
|
425
|
+
return Math.floor((e - 1) / 2);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Returns the index of the left child node for the given index.
|
|
429
|
+
* @param index The index of the node.
|
|
430
|
+
* @returns The index of the left child node.
|
|
431
|
+
*/
|
|
432
|
+
getLeftIndex(e) {
|
|
433
|
+
return e * 2 + 1;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Returns the index of the right child node for the given index.
|
|
437
|
+
* @param index The index of the node.
|
|
438
|
+
* @returns The index of the right child node.
|
|
439
|
+
*/
|
|
440
|
+
getRightIndex(e) {
|
|
441
|
+
return e * 2 + 2;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Returns the number of elements in the heap.
|
|
445
|
+
* @returns The number of elements in the heap.
|
|
446
|
+
*/
|
|
447
|
+
size() {
|
|
448
|
+
return this.heap.length;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Returns the minimum value in the heap without removing it.
|
|
452
|
+
* @returns The minimum value in the heap.
|
|
453
|
+
*/
|
|
454
|
+
peek() {
|
|
455
|
+
return this.heap[0];
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* @description Returns whether the heap includes the given value.
|
|
459
|
+
* @param {number} value The value to be checked.
|
|
460
|
+
* @returns {boolean} return true if the heap includes the given value
|
|
461
|
+
*/
|
|
462
|
+
include(e) {
|
|
463
|
+
return this.heap.includes(e);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
class Kt extends zt {
|
|
467
|
+
/**
|
|
468
|
+
* Initializes a new instance of the MinHeap class.
|
|
469
|
+
*/
|
|
470
|
+
constructor() {
|
|
471
|
+
super();
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Moves the element at the given index up the heap until it satisfies the min heap property.
|
|
475
|
+
* @param index The index of the element to be shifted up.
|
|
476
|
+
*/
|
|
477
|
+
shiftUp(e) {
|
|
478
|
+
if (e === 0)
|
|
479
|
+
return;
|
|
480
|
+
const n = this.getParentIndex(e);
|
|
481
|
+
this.heap[n] > this.heap[e] && (this.swap(n, e), this.shiftUp(n));
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Moves the element at the given index down the heap until it satisfies the min heap property.
|
|
485
|
+
* @param index The index of the element to be shifted down.
|
|
486
|
+
*/
|
|
487
|
+
shiftDown(e) {
|
|
488
|
+
const n = this.getLeftIndex(e), r = this.getRightIndex(e);
|
|
489
|
+
this.heap[n] < this.heap[e] && (this.swap(n, e), this.shiftDown(n)), this.heap[r] < this.heap[e] && (this.swap(r, e), this.shiftDown(r));
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Inserts a new value into the min heap.
|
|
493
|
+
* @param value The value to be inserted.
|
|
494
|
+
*/
|
|
495
|
+
insert(e) {
|
|
496
|
+
this.heap.push(e), this.shiftUp(this.heap.length - 1);
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Removes and returns the minimum value from the min heap.
|
|
500
|
+
*/
|
|
501
|
+
pop() {
|
|
502
|
+
this.heap[0] = this.heap.pop(), this.shiftDown(0);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const Xt = (t, e) => {
|
|
506
|
+
const n = new Kt();
|
|
507
|
+
for (const r of t)
|
|
508
|
+
n.insert(r), n.size() > e && n.pop();
|
|
509
|
+
return n.heap;
|
|
510
|
+
}, Zt = (t, e) => t > e, en = (t, e) => t < e, tn = (t, e, n) => Xt(t, e).includes(n);
|
|
511
|
+
function nn(t, e) {
|
|
512
|
+
switch (t.compareType) {
|
|
513
|
+
case F.Equal: {
|
|
514
|
+
const n = Number(t.expectedValue);
|
|
515
|
+
return (r) => r === n;
|
|
516
|
+
}
|
|
517
|
+
case F.NotEqual: {
|
|
518
|
+
const n = Number(t.expectedValue);
|
|
519
|
+
return (r) => r !== n;
|
|
520
|
+
}
|
|
521
|
+
case F.GreaterThan: {
|
|
522
|
+
const n = Number(t.expectedValue);
|
|
523
|
+
return (r) => r > n;
|
|
524
|
+
}
|
|
525
|
+
case F.GreaterThanOrEqual: {
|
|
526
|
+
const n = Number(t.expectedValue);
|
|
527
|
+
return (r) => r >= n;
|
|
528
|
+
}
|
|
529
|
+
case F.LessThan: {
|
|
530
|
+
const n = Number(t.expectedValue);
|
|
531
|
+
return (r) => r < n;
|
|
532
|
+
}
|
|
533
|
+
case F.LessThanOrEqual: {
|
|
534
|
+
const n = Number(t.expectedValue);
|
|
535
|
+
return (r) => r <= n;
|
|
536
|
+
}
|
|
537
|
+
case F.Between: {
|
|
538
|
+
const [n, r] = t.expectedValue, s = Number(n), a = Number(r);
|
|
539
|
+
return s > a ? (o) => o >= a && o <= s : (o) => o >= s && o <= a;
|
|
540
|
+
}
|
|
541
|
+
case F.NotBetween: {
|
|
542
|
+
const [n, r] = t.expectedValue, s = Number(n), a = Number(r);
|
|
543
|
+
return s > a ? (o) => o < a || o > s : (o) => o < s || o > a;
|
|
544
|
+
}
|
|
545
|
+
case F.Above: {
|
|
546
|
+
const n = e.average;
|
|
547
|
+
return (r) => Zt(r, n);
|
|
548
|
+
}
|
|
549
|
+
case F.Below: {
|
|
550
|
+
const n = e.average;
|
|
551
|
+
return (r) => en(r, n);
|
|
552
|
+
}
|
|
553
|
+
case F.TopN: {
|
|
554
|
+
const n = e.list, r = Number(t.expectedValue);
|
|
555
|
+
return (s) => tn(n, r, s);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const K = (t) => {
|
|
560
|
+
const n = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\*/g, ".*").replace(/\\\?/g, ".");
|
|
561
|
+
return new RegExp(`^${n}$`);
|
|
562
|
+
}, rn = (t, e) => K(e).test(t), sn = (t, e) => !K(e).test(t), an = (t, e) => K(`*${e}*`).test(t), on = (t, e) => !K(`*${e}*`).test(t), ln = (t, e) => K(`${e}*`).test(t), un = (t, e) => K(`*${e}`).test(t);
|
|
563
|
+
function cn(t) {
|
|
564
|
+
switch (t.compareType) {
|
|
565
|
+
case H.Equal:
|
|
566
|
+
return (e) => rn(e, t.expectedValue);
|
|
567
|
+
case H.NotEqual:
|
|
568
|
+
return (e) => sn(e, t.expectedValue);
|
|
569
|
+
case H.Contains:
|
|
570
|
+
return (e) => an(e, t.expectedValue);
|
|
571
|
+
case H.NotContains:
|
|
572
|
+
return (e) => on(e, t.expectedValue);
|
|
573
|
+
case H.StartsWith:
|
|
574
|
+
return (e) => ln(e, t.expectedValue);
|
|
575
|
+
case H.EndsWith:
|
|
576
|
+
return (e) => un(e, t.expectedValue);
|
|
577
|
+
default:
|
|
578
|
+
return console.error(`Unknown filter operator: ${t.compareType}`), (e) => !0;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const dn = /* @__PURE__ */ new Set([
|
|
582
|
+
F.Above,
|
|
583
|
+
F.Below,
|
|
584
|
+
F.TopN
|
|
585
|
+
]);
|
|
586
|
+
g.Today, g.Yesterday, g.Tomorrow, g.ThisWeek, g.LastWeek, g.NextWeek, g.ThisMonth, g.LastMonth, g.NextMonth, g.ThisQuarter, g.LastQuarter, g.NextQuarter, g.NextYear, g.ThisYear, g.LastYear, g.YearToDate;
|
|
587
|
+
function Ge(t) {
|
|
588
|
+
return dn.has(t);
|
|
589
|
+
}
|
|
590
|
+
function hn(t, e) {
|
|
591
|
+
if (Ge(t.filterInfo.compareType))
|
|
592
|
+
return (n) => !0;
|
|
593
|
+
switch (t.filterInfo.conditionType) {
|
|
594
|
+
case O.Date:
|
|
595
|
+
return jt(t.filterInfo);
|
|
596
|
+
case O.Number:
|
|
597
|
+
return nn(t.filterInfo, e);
|
|
598
|
+
case O.String:
|
|
599
|
+
return cn(t.filterInfo);
|
|
600
|
+
case O.Logic:
|
|
601
|
+
default:
|
|
602
|
+
return (n) => !0;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function oe(t, e, n, r) {
|
|
606
|
+
switch (r) {
|
|
607
|
+
case O.Date: {
|
|
608
|
+
const s = De(t, e, n);
|
|
609
|
+
return s ? bn(s) : null;
|
|
610
|
+
}
|
|
611
|
+
case O.Number:
|
|
612
|
+
return De(t, e, n);
|
|
613
|
+
case O.String:
|
|
614
|
+
default:
|
|
615
|
+
return mn(t, e, n);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
const gn = (t) => {
|
|
619
|
+
var n;
|
|
620
|
+
return ((n = t.body) == null ? void 0 : n.dataStream.replace(/\r\n$/, "")) || "";
|
|
621
|
+
};
|
|
622
|
+
function mn(t, e, n) {
|
|
623
|
+
const r = t.getCell(e, n);
|
|
624
|
+
if (!r) return null;
|
|
625
|
+
const { v: s, t: a, p: o } = r;
|
|
626
|
+
return o ? gn(o) : typeof s == "string" ? a === V.BOOLEAN ? s.toUpperCase() : s : typeof s == "number" ? a === V.BOOLEAN ? s ? "TRUE" : "FALSE" : s : typeof s == "boolean" ? s ? "TRUE" : "FALSE" : s === void 0 ? "(空白)" : String(s);
|
|
627
|
+
}
|
|
628
|
+
function De(t, e, n) {
|
|
629
|
+
const r = t.getCell(e, n);
|
|
630
|
+
if (!r) return null;
|
|
631
|
+
const { v: s, t: a, p: o } = r;
|
|
632
|
+
return o ? null : typeof s == "string" && a === V.NUMBER ? Number(t.getCellRaw(e, n).v) : Number(s);
|
|
633
|
+
}
|
|
634
|
+
function bn(t) {
|
|
635
|
+
const e = new Date(Date.UTC(1900, 0, 1, 0, 0, 0)), n = new Date(Date.UTC(1900, 1, 28, 0, 0, 0));
|
|
636
|
+
let r = t - 1;
|
|
637
|
+
return r > (n.getTime() - e.getTime()) / (1e3 * 3600 * 24) && (r -= 1), r < 0 && (r = t), new Date(e.getTime() + r * (1e3 * 3600 * 24));
|
|
638
|
+
}
|
|
639
|
+
class ye {
|
|
640
|
+
constructor() {
|
|
641
|
+
b(this, "_tableColumnFilterList");
|
|
642
|
+
b(this, "_tableSortInfo");
|
|
643
|
+
b(this, "_filterOutRows");
|
|
644
|
+
this._tableColumnFilterList = [];
|
|
645
|
+
}
|
|
646
|
+
setColumnFilter(e, n) {
|
|
647
|
+
n ? this._tableColumnFilterList[e] = n : this._tableColumnFilterList[e] = void 0;
|
|
648
|
+
}
|
|
649
|
+
setSortState(e, n) {
|
|
650
|
+
this._tableSortInfo = { columnIndex: e, sortState: n };
|
|
651
|
+
}
|
|
652
|
+
getColumnFilter(e) {
|
|
653
|
+
return this._tableColumnFilterList[e];
|
|
654
|
+
}
|
|
655
|
+
getFilterState(e) {
|
|
656
|
+
var r;
|
|
657
|
+
const n = ((r = this._tableSortInfo) == null ? void 0 : r.columnIndex) === e ? this._tableSortInfo.sortState : G.None;
|
|
658
|
+
return gt(this._tableColumnFilterList[e], n);
|
|
659
|
+
}
|
|
660
|
+
getSortState() {
|
|
661
|
+
var e;
|
|
662
|
+
return (e = this._tableSortInfo) != null ? e : {};
|
|
663
|
+
}
|
|
664
|
+
getFilterStates(e) {
|
|
665
|
+
const n = [], { startColumn: r, endColumn: s } = e;
|
|
666
|
+
for (let a = r; a <= s; a++)
|
|
667
|
+
n.push(this.getFilterState(a - r));
|
|
668
|
+
return n;
|
|
669
|
+
}
|
|
670
|
+
getFilterOutRows() {
|
|
671
|
+
return this._filterOutRows;
|
|
672
|
+
}
|
|
673
|
+
doFilter(e, n) {
|
|
674
|
+
const r = /* @__PURE__ */ new Set(), s = this._tableColumnFilterList;
|
|
675
|
+
for (let a = 0; a < s.length; a++)
|
|
676
|
+
s[a] && this.doColumnFilter(e, n, a, r);
|
|
677
|
+
return this._filterOutRows = r, r;
|
|
678
|
+
}
|
|
679
|
+
doColumnFilter(e, n, r, s) {
|
|
680
|
+
const a = this._tableColumnFilterList[r];
|
|
681
|
+
if (a && e) {
|
|
682
|
+
const { startRow: o, endRow: l, startColumn: u } = n, i = u + r, h = this.getExecuteFunc(e, n, r, a);
|
|
683
|
+
for (let d = o; d <= l; d++) {
|
|
684
|
+
const c = mt(a) ? a.filterInfo.conditionType : O.String;
|
|
685
|
+
oe(e, d, i, c) === null ? s.add(d) : h(oe(e, d, i, c)) || s.add(d);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
_getNumberCalculatedOptions(e, n, r) {
|
|
690
|
+
const { startRow: s, endRow: a, startColumn: o } = n, l = o + r, u = [];
|
|
691
|
+
let i = 0, h = 0;
|
|
692
|
+
for (let d = s; d <= a; d++) {
|
|
693
|
+
const c = oe(e, d, l, O.Number);
|
|
694
|
+
c !== null && (u.push(c), i++, h += c);
|
|
695
|
+
}
|
|
696
|
+
return {
|
|
697
|
+
list: u,
|
|
698
|
+
average: i > 0 ? h / i : 0
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
getExecuteFunc(e, n, r, s) {
|
|
702
|
+
if (s.filterType === ee.manual) {
|
|
703
|
+
const a = new Set(s.values);
|
|
704
|
+
return (o) => a.has(o);
|
|
705
|
+
} else if (s.filterType === ee.condition) {
|
|
706
|
+
const o = Ge(s.filterInfo.compareType) ? this._getNumberCalculatedOptions(e, n, r) : void 0;
|
|
707
|
+
return hn(s, o);
|
|
708
|
+
} else
|
|
709
|
+
return (a) => !0;
|
|
710
|
+
}
|
|
711
|
+
toJSON() {
|
|
712
|
+
return {
|
|
713
|
+
tableColumnFilterList: this._tableColumnFilterList,
|
|
714
|
+
tableSortInfo: this._tableSortInfo
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
fromJSON(e) {
|
|
718
|
+
var n;
|
|
719
|
+
this._tableColumnFilterList = (n = e.tableColumnFilterList) != null ? n : [], e.tableSortInfo && (this._tableSortInfo = e.tableSortInfo);
|
|
720
|
+
}
|
|
721
|
+
dispose() {
|
|
722
|
+
this._tableColumnFilterList = [];
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
class Ne {
|
|
726
|
+
constructor(e, n, r, s, a = {}) {
|
|
727
|
+
b(this, "_id");
|
|
728
|
+
b(this, "_name");
|
|
729
|
+
/**
|
|
730
|
+
* @property {string} tableStyleId The table style id. If the property is empty, the default style will be used.
|
|
731
|
+
*/
|
|
732
|
+
b(this, "_tableStyleId");
|
|
733
|
+
b(this, "_showHeader");
|
|
734
|
+
b(this, "_showFooter");
|
|
735
|
+
b(this, "_range");
|
|
736
|
+
b(this, "_columns", /* @__PURE__ */ new Map());
|
|
737
|
+
b(this, "_columnOrder", []);
|
|
738
|
+
b(this, "tableMeta");
|
|
739
|
+
b(this, "_tableFilters");
|
|
740
|
+
b(this, "_subUnitId");
|
|
741
|
+
this._id = e, this._range = r, this._name = n, this._tableFilters = new ye(), this._init(s, a);
|
|
742
|
+
}
|
|
743
|
+
_init(e, n) {
|
|
744
|
+
var r;
|
|
745
|
+
if (this._tableStyleId = n == null ? void 0 : n.tableStyleId, this._showHeader = (r = n == null ? void 0 : n.showHeader) != null ? r : !0, this._showFooter = !1, n.columns)
|
|
746
|
+
n.columns.forEach((s) => {
|
|
747
|
+
const a = s.id || L(), o = new q(a, s.displayName);
|
|
748
|
+
o.fromJSON(s), this._columns.set(a, o), this._columnOrder.push(a);
|
|
749
|
+
});
|
|
750
|
+
else {
|
|
751
|
+
const s = this.getRange(), a = s.startColumn, o = s.endColumn;
|
|
752
|
+
for (let l = a; l <= o; l++) {
|
|
753
|
+
const u = L(), i = new q(u, e[l - a]);
|
|
754
|
+
this._columns.set(u, i), this._columnOrder.push(u);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
n.filters && n.filters.forEach((a, o) => {
|
|
758
|
+
a && this._tableFilters.setColumnFilter(o, a);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
setTableFilterColumn(e, n) {
|
|
762
|
+
this._tableFilters.setColumnFilter(e, n);
|
|
763
|
+
}
|
|
764
|
+
getTableFilterColumn(e) {
|
|
765
|
+
return this._tableFilters.getColumnFilter(e);
|
|
766
|
+
}
|
|
767
|
+
getTableFilters() {
|
|
768
|
+
return this._tableFilters;
|
|
769
|
+
}
|
|
770
|
+
getTableFilterRange() {
|
|
771
|
+
const e = this.getRange(), n = this.isShowHeader(), r = this.isShowFooter(), { startRow: s, startColumn: a, endRow: o, endColumn: l } = e, u = n ? s + 1 : s, i = r ? o - 1 : o;
|
|
772
|
+
return {
|
|
773
|
+
startRow: u,
|
|
774
|
+
startColumn: a,
|
|
775
|
+
endRow: i,
|
|
776
|
+
endColumn: l
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
setColumns(e) {
|
|
780
|
+
this._columns.clear(), this._columnOrder = [], e.forEach((n) => {
|
|
781
|
+
const r = new q(n.id, n.displayName);
|
|
782
|
+
r.fromJSON(n), this._columns.set(n.id, r), this._columnOrder.push(n.id);
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
getColumnsCount() {
|
|
786
|
+
return this._columnOrder.length;
|
|
787
|
+
}
|
|
788
|
+
insertColumn(e, n) {
|
|
789
|
+
const r = n.id;
|
|
790
|
+
this._columns.set(r, n), this._columnOrder.splice(e, 0, r);
|
|
791
|
+
}
|
|
792
|
+
removeColumn(e) {
|
|
793
|
+
const n = this._columnOrder[e];
|
|
794
|
+
this._columns.delete(n), this._columnOrder.splice(e, 1);
|
|
795
|
+
}
|
|
796
|
+
setTableMeta(e) {
|
|
797
|
+
this.tableMeta = e;
|
|
798
|
+
}
|
|
799
|
+
getTableMeta() {
|
|
800
|
+
return this.tableMeta;
|
|
801
|
+
}
|
|
802
|
+
getColumn(e) {
|
|
803
|
+
return this._columns.get(e);
|
|
804
|
+
}
|
|
805
|
+
getTableColumnByIndex(e) {
|
|
806
|
+
const n = this._columnOrder[e];
|
|
807
|
+
return this.getColumn(n);
|
|
808
|
+
}
|
|
809
|
+
getColumnNameByIndex(e) {
|
|
810
|
+
var r;
|
|
811
|
+
const n = this._columnOrder[e];
|
|
812
|
+
return ((r = this.getColumn(n)) == null ? void 0 : r.getDisplayName()) || "";
|
|
813
|
+
}
|
|
814
|
+
getId() {
|
|
815
|
+
return this._id;
|
|
816
|
+
}
|
|
817
|
+
getRangeInfo() {
|
|
818
|
+
return {
|
|
819
|
+
...this._range
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
getRange() {
|
|
823
|
+
return { ...this._range };
|
|
824
|
+
}
|
|
825
|
+
setRange(e) {
|
|
826
|
+
this._range = e;
|
|
827
|
+
}
|
|
828
|
+
setDisplayName(e) {
|
|
829
|
+
this._name = e;
|
|
830
|
+
}
|
|
831
|
+
getDisplayName() {
|
|
832
|
+
return this._name;
|
|
833
|
+
}
|
|
834
|
+
getSubunitId() {
|
|
835
|
+
return this._subUnitId;
|
|
836
|
+
}
|
|
837
|
+
setSubunitId(e) {
|
|
838
|
+
this._subUnitId = e;
|
|
839
|
+
}
|
|
840
|
+
getTableStyleId() {
|
|
841
|
+
var e;
|
|
842
|
+
return (e = this._tableStyleId) != null ? e : Y[0].name;
|
|
843
|
+
}
|
|
844
|
+
setTableStyleId(e) {
|
|
845
|
+
this._tableStyleId = e;
|
|
846
|
+
}
|
|
847
|
+
isShowHeader() {
|
|
848
|
+
var e;
|
|
849
|
+
return (e = this._showHeader) != null ? e : !0;
|
|
850
|
+
}
|
|
851
|
+
setShowHeader(e) {
|
|
852
|
+
this._showHeader = e;
|
|
853
|
+
}
|
|
854
|
+
isShowFooter() {
|
|
855
|
+
var e;
|
|
856
|
+
return (e = this._showFooter) != null ? e : !1;
|
|
857
|
+
}
|
|
858
|
+
getTableInfo() {
|
|
859
|
+
return {
|
|
860
|
+
id: this._id,
|
|
861
|
+
subUnitId: this._subUnitId,
|
|
862
|
+
name: this._name,
|
|
863
|
+
range: this.getRangeInfo(),
|
|
864
|
+
meta: this.tableMeta,
|
|
865
|
+
showHeader: this._showHeader,
|
|
866
|
+
columns: this._columnOrder.map((e) => this._columns.get(e).toJSON())
|
|
867
|
+
};
|
|
868
|
+
}
|
|
869
|
+
getTableConfig() {
|
|
870
|
+
return {
|
|
871
|
+
name: this.getDisplayName(),
|
|
872
|
+
range: this.getRangeInfo(),
|
|
873
|
+
options: {
|
|
874
|
+
showHeader: this._showHeader,
|
|
875
|
+
showFooter: this._showFooter
|
|
876
|
+
},
|
|
877
|
+
tableStyleId: this._tableStyleId
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
getFilterStates(e) {
|
|
881
|
+
return this._tableFilters.getFilterStates(e);
|
|
882
|
+
}
|
|
883
|
+
toJSON() {
|
|
884
|
+
const e = [];
|
|
885
|
+
return this._columns.forEach((n) => {
|
|
886
|
+
e.push(n.toJSON());
|
|
887
|
+
}), {
|
|
888
|
+
id: this._id,
|
|
889
|
+
name: this._name,
|
|
890
|
+
range: this.getRangeInfo(),
|
|
891
|
+
options: {
|
|
892
|
+
showHeader: this._showHeader,
|
|
893
|
+
showFooter: this._showFooter,
|
|
894
|
+
tableStyleId: this._tableStyleId
|
|
895
|
+
},
|
|
896
|
+
// TODO: support filter
|
|
897
|
+
filters: this._tableFilters.toJSON(),
|
|
898
|
+
columns: e,
|
|
899
|
+
meta: this.tableMeta
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
fromJSON(e) {
|
|
903
|
+
this._id = e.id, this._name = e.name, this._range = e.range, this.tableMeta = e.meta, this._tableStyleId = e.options.tableStyleId || "", this._showHeader = e.options.showHeader || !0, this._showFooter = e.options.showFooter || !0, e.columns.forEach((r) => {
|
|
904
|
+
const s = new q(r.id, r.displayName);
|
|
905
|
+
s.fromJSON(r), this._columns.set(r.id, s), this._columnOrder.push(r.id);
|
|
906
|
+
}), this._tableFilters = new ye(), this._tableFilters.fromJSON(e.filters);
|
|
907
|
+
}
|
|
908
|
+
dispose() {
|
|
909
|
+
this._id = "", this._name = "", this._tableStyleId = "", this._showHeader = !0, this._showFooter = !0, delete this._range, this._columns.clear(), this._columnOrder = [];
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
var wn = Object.getOwnPropertyDescriptor, Rn = (t, e, n, r) => {
|
|
913
|
+
for (var s = r > 1 ? void 0 : r ? wn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
914
|
+
(o = t[a]) && (s = o(s) || s);
|
|
915
|
+
return s;
|
|
916
|
+
}, xe = (t, e) => (n, r) => e(n, r, t);
|
|
917
|
+
let _ = class extends k {
|
|
918
|
+
constructor(e, n) {
|
|
919
|
+
super();
|
|
920
|
+
b(this, "_tableMap");
|
|
921
|
+
b(this, "_tableAdd$", new Q());
|
|
922
|
+
b(this, "tableAdd$", this._tableAdd$.asObservable());
|
|
923
|
+
b(this, "_tableDelete$", new Q());
|
|
924
|
+
b(this, "tableDelete$", this._tableDelete$.asObservable());
|
|
925
|
+
b(this, "_tableNameChanged$", new Q());
|
|
926
|
+
b(this, "tableNameChanged$", this._tableNameChanged$.asObservable());
|
|
927
|
+
b(this, "_tableRangeChanged$", new Q());
|
|
928
|
+
b(this, "tableRangeChanged$", this._tableRangeChanged$.asObservable());
|
|
929
|
+
b(this, "_tableThemeChanged$", new Q());
|
|
930
|
+
b(this, "tableThemeChanged$", this._tableThemeChanged$.asObservable());
|
|
931
|
+
b(this, "_tableFilterChanged$", new Q());
|
|
932
|
+
b(this, "tableFilterChanged$", this._tableFilterChanged$.asObservable());
|
|
933
|
+
b(this, "_tableInitStatus", new Je(!1));
|
|
934
|
+
b(this, "tableInitStatus$", this._tableInitStatus.asObservable());
|
|
935
|
+
this._univerInstanceService = e, this._localeService = n, this._tableMap = /* @__PURE__ */ new Map();
|
|
936
|
+
}
|
|
937
|
+
_ensureUnit(e) {
|
|
938
|
+
return this._tableMap.has(e) || this._tableMap.set(e, /* @__PURE__ */ new Map()), this._tableMap.get(e);
|
|
939
|
+
}
|
|
940
|
+
getColumnHeader(e, n, r, s) {
|
|
941
|
+
var d;
|
|
942
|
+
const a = (d = this._univerInstanceService.getUnit(e)) == null ? void 0 : d.getSheetBySheetId(n), { startRow: o, startColumn: l, endColumn: u } = r, i = [], h = s != null ? s : "Column";
|
|
943
|
+
for (let c = l; c <= u; c++)
|
|
944
|
+
i.push(Qe(a == null ? void 0 : a.getCell(o, c)) || Z(c - l + 1, h));
|
|
945
|
+
return i;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Add a table to univer.
|
|
949
|
+
* @param {string} unitId The unit id of the table.
|
|
950
|
+
* @param {string} subUnitId The subunit id of the table.
|
|
951
|
+
* @param {string} name The table name, it should be unique in the unit or it will be appended with a number.
|
|
952
|
+
* @param {ITableRange} range The range of the table, it contains the unit id and subunit id.
|
|
953
|
+
* @param {ITableOptions} [options] Other options of the table.
|
|
954
|
+
* @returns {string} The table id.
|
|
955
|
+
*/
|
|
956
|
+
addTable(e, n, r, s, a, o, l) {
|
|
957
|
+
const u = o != null ? o : L(), i = a || this.getColumnHeader(e, n, s), h = new Ne(u, r, s, i, l);
|
|
958
|
+
return h.setSubunitId(n), this._ensureUnit(e).set(u, h), this._tableAdd$.next({
|
|
959
|
+
unitId: e,
|
|
960
|
+
subUnitId: n,
|
|
961
|
+
range: s,
|
|
962
|
+
tableName: r,
|
|
963
|
+
tableId: u
|
|
964
|
+
}), u;
|
|
965
|
+
}
|
|
966
|
+
addFilter(e, n, r, s) {
|
|
967
|
+
const a = this.getTable(e, n);
|
|
968
|
+
if (a) {
|
|
969
|
+
a.getTableFilters().setColumnFilter(r, s);
|
|
970
|
+
const l = a.getSubunitId();
|
|
971
|
+
this._tableFilterChanged$.next({
|
|
972
|
+
unitId: e,
|
|
973
|
+
subUnitId: l,
|
|
974
|
+
tableId: n
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
getFilterRanges(e, n) {
|
|
979
|
+
const r = this._tableMap.get(e);
|
|
980
|
+
if (!r)
|
|
981
|
+
return [];
|
|
982
|
+
const s = [];
|
|
983
|
+
return r.forEach((a) => {
|
|
984
|
+
a.getSubunitId() === n && a.isShowHeader() && s.push(a.getRange());
|
|
985
|
+
}), s;
|
|
986
|
+
}
|
|
987
|
+
getSheetFilterRangeWithState(e, n) {
|
|
988
|
+
const r = this._tableMap.get(e);
|
|
989
|
+
if (!r)
|
|
990
|
+
return [];
|
|
991
|
+
const s = [];
|
|
992
|
+
return r.forEach((a) => {
|
|
993
|
+
a.getSubunitId() === n && a.isShowHeader() && s.push({
|
|
994
|
+
tableId: a.getId(),
|
|
995
|
+
range: a.getRange(),
|
|
996
|
+
states: a.getFilterStates(a.getRange())
|
|
997
|
+
});
|
|
998
|
+
}), s;
|
|
999
|
+
}
|
|
1000
|
+
getTable(e, n) {
|
|
1001
|
+
const r = this._tableMap.get(e);
|
|
1002
|
+
if (r)
|
|
1003
|
+
return r.get(n);
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Get the unique table name, in excel, the table name should be unique because it is used as a reference.
|
|
1007
|
+
* @param {string} unitId The unit id of the table.
|
|
1008
|
+
* @param {string} baseName The base name of the table.
|
|
1009
|
+
* @returns {string} The unique table name
|
|
1010
|
+
*/
|
|
1011
|
+
getUniqueTableName(e, n) {
|
|
1012
|
+
const r = this._tableMap.get(e);
|
|
1013
|
+
if (!r)
|
|
1014
|
+
return n;
|
|
1015
|
+
const s = new Set(Array.from(r.values()).map((l) => l.getDisplayName()));
|
|
1016
|
+
let a = n, o = 1;
|
|
1017
|
+
for (; s.has(a); )
|
|
1018
|
+
a = `${n}-${o}`, o++;
|
|
1019
|
+
return a;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Get table by unit id and table id.
|
|
1023
|
+
* @param {string} unitId The unit id of the table.
|
|
1024
|
+
* @param {string} tableId The table id.
|
|
1025
|
+
* @returns {Table} The table.
|
|
1026
|
+
*/
|
|
1027
|
+
getTableById(e, n) {
|
|
1028
|
+
return this.getTable(e, n);
|
|
1029
|
+
}
|
|
1030
|
+
getTableList(e) {
|
|
1031
|
+
const n = this._tableMap.get(e);
|
|
1032
|
+
return n ? Array.from(n.values()).map((r) => ({ ...r.getTableInfo(), unitId: e })) : [];
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Get the table list by unit id and subunit id.
|
|
1036
|
+
* @param {string} unitId The unit id of the table.
|
|
1037
|
+
* @param {string} subUnitId The subunit id of the table.
|
|
1038
|
+
* @returns {Table[]} The table list.
|
|
1039
|
+
*/
|
|
1040
|
+
getTablesBySubunitId(e, n) {
|
|
1041
|
+
const r = this._tableMap.get(e);
|
|
1042
|
+
return r ? Array.from(r.values()).filter((s) => s.getSubunitId() === n) : [];
|
|
1043
|
+
}
|
|
1044
|
+
getTablesInfoBySubunitId(e, n) {
|
|
1045
|
+
return this.getTablesBySubunitId(e, n).map((r) => ({
|
|
1046
|
+
id: r.getId(),
|
|
1047
|
+
name: r.getDisplayName(),
|
|
1048
|
+
range: r.getRange()
|
|
1049
|
+
}));
|
|
1050
|
+
}
|
|
1051
|
+
deleteTable(e, n) {
|
|
1052
|
+
const r = this._tableMap.get(e), s = r == null ? void 0 : r.get(n);
|
|
1053
|
+
if (s) {
|
|
1054
|
+
const a = s.getTableInfo(), o = s.getTableStyleId();
|
|
1055
|
+
r == null || r.delete(n);
|
|
1056
|
+
const { subUnitId: l, range: u, name: i } = a;
|
|
1057
|
+
this._tableDelete$.next({
|
|
1058
|
+
unitId: e,
|
|
1059
|
+
subUnitId: l,
|
|
1060
|
+
tableId: n,
|
|
1061
|
+
range: u,
|
|
1062
|
+
tableName: i,
|
|
1063
|
+
tableStyleId: o
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
operationTableRowCol(e, n, r) {
|
|
1068
|
+
const s = this.getTableById(e, n);
|
|
1069
|
+
if (!s) return;
|
|
1070
|
+
const { operationType: a, rowColType: o, index: l, count: u, columnsJson: i } = r, h = s.getRange(), d = { ...h };
|
|
1071
|
+
if (a === T.Insert) {
|
|
1072
|
+
if (o === "row")
|
|
1073
|
+
d.endRow += u;
|
|
1074
|
+
else if (o === "column") {
|
|
1075
|
+
d.endColumn += u;
|
|
1076
|
+
for (let c = 0; c < u; c++) {
|
|
1077
|
+
const m = this._localeService.t("sheets-table.columnPrefix"), C = new q(L(), Z(s.getColumnsCount() + 1 + c, m));
|
|
1078
|
+
i != null && i[c] && C.fromJSON(i[c]);
|
|
1079
|
+
const w = l + c - h.startColumn;
|
|
1080
|
+
s.insertColumn(w, C);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
} else if (o === "row")
|
|
1084
|
+
d.endRow -= u;
|
|
1085
|
+
else if (o === "column") {
|
|
1086
|
+
d.endColumn -= u;
|
|
1087
|
+
for (let c = u - 1; c >= 0; c--) {
|
|
1088
|
+
const m = l + c - h.startColumn;
|
|
1089
|
+
s.removeColumn(m);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
s.setRange(d), this._tableRangeChanged$.next({
|
|
1093
|
+
unitId: e,
|
|
1094
|
+
subUnitId: s.getSubunitId(),
|
|
1095
|
+
tableId: n,
|
|
1096
|
+
range: d,
|
|
1097
|
+
oldRange: h
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
updateTableRange(e, n, r) {
|
|
1101
|
+
const s = this.getTableById(e, n);
|
|
1102
|
+
if (!s) return;
|
|
1103
|
+
const a = s.getRange(), o = r.newRange;
|
|
1104
|
+
if (o.startColumn < a.startColumn) {
|
|
1105
|
+
const l = a.startColumn - o.startColumn, u = this._localeService.t("sheets-table.columnPrefix");
|
|
1106
|
+
for (let i = 0; i < l; i++)
|
|
1107
|
+
s.insertColumn(a.startColumn, new q(L(), Z(s.getColumnsCount() + 1, u)));
|
|
1108
|
+
} else if (o.startColumn > a.startColumn) {
|
|
1109
|
+
const l = o.startColumn - a.startColumn;
|
|
1110
|
+
for (let u = l - 1; u >= 0; u--) {
|
|
1111
|
+
const i = o.startColumn + u - a.startColumn;
|
|
1112
|
+
s.removeColumn(i);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
if (o.endColumn < a.endColumn) {
|
|
1116
|
+
const l = a.endColumn - o.endColumn;
|
|
1117
|
+
for (let u = l - 1; u >= 0; u--) {
|
|
1118
|
+
const i = o.endColumn + u - a.startColumn;
|
|
1119
|
+
s.removeColumn(i);
|
|
1120
|
+
}
|
|
1121
|
+
} else if (o.endColumn > a.endColumn) {
|
|
1122
|
+
const l = o.endColumn - a.endColumn;
|
|
1123
|
+
for (let u = 0; u < l; u++)
|
|
1124
|
+
s.insertColumn(a.endColumn, new q(L(), Z(s.getColumnsCount() + 1, "Column")));
|
|
1125
|
+
}
|
|
1126
|
+
s.setRange(o), this._tableRangeChanged$.next({
|
|
1127
|
+
unitId: e,
|
|
1128
|
+
subUnitId: s.getSubunitId(),
|
|
1129
|
+
tableId: n,
|
|
1130
|
+
range: o,
|
|
1131
|
+
oldRange: a
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
setTableByConfig(e, n, r) {
|
|
1135
|
+
var c;
|
|
1136
|
+
const s = this._tableMap.get(e), a = s == null ? void 0 : s.get(n);
|
|
1137
|
+
if (!a) return;
|
|
1138
|
+
const o = a.getSubunitId(), { name: l, updateRange: u, rowColOperation: i, theme: h, options: d } = r;
|
|
1139
|
+
if (l) {
|
|
1140
|
+
const m = a.getDisplayName();
|
|
1141
|
+
a.setDisplayName(l), this._tableNameChanged$.next({
|
|
1142
|
+
unitId: e,
|
|
1143
|
+
subUnitId: o,
|
|
1144
|
+
tableId: n,
|
|
1145
|
+
tableName: l,
|
|
1146
|
+
oldTableName: m
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
if (i && this.operationTableRowCol(e, n, i), u && this.updateTableRange(e, n, u), h) {
|
|
1150
|
+
const m = (c = a.getTableStyleId()) != null ? c : "default";
|
|
1151
|
+
a.setTableStyleId(h), this._tableThemeChanged$.next({
|
|
1152
|
+
unitId: e,
|
|
1153
|
+
subUnitId: o,
|
|
1154
|
+
tableId: n,
|
|
1155
|
+
theme: h,
|
|
1156
|
+
oldTheme: m
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
d && d.showHeader !== void 0 && a.setShowHeader(d.showHeader);
|
|
1160
|
+
}
|
|
1161
|
+
toJSON(e) {
|
|
1162
|
+
const n = {}, r = this._tableMap.get(e);
|
|
1163
|
+
return r && r.forEach((s) => {
|
|
1164
|
+
const a = s.getSubunitId();
|
|
1165
|
+
n[a] || (n[a] = []), n[a].push(s.toJSON());
|
|
1166
|
+
}), n;
|
|
1167
|
+
}
|
|
1168
|
+
fromJSON(e, n) {
|
|
1169
|
+
const r = this._ensureUnit(e);
|
|
1170
|
+
Object.keys(n).forEach((a) => {
|
|
1171
|
+
const o = U(this._univerInstanceService, { unitId: e, subUnitId: a });
|
|
1172
|
+
if (!o)
|
|
1173
|
+
return;
|
|
1174
|
+
const l = o.worksheet;
|
|
1175
|
+
n[a].forEach((i) => {
|
|
1176
|
+
const h = this.getColumnHeader(e, a, i.range), d = new Ne(i.id, i.name, i.range, h, i.options);
|
|
1177
|
+
if (d.setTableMeta(i.meta), i.columns.length && d.setColumns(i.columns), i.filters) {
|
|
1178
|
+
const c = d.getTableFilters();
|
|
1179
|
+
c.fromJSON(i.filters), c.doFilter(l, d.getTableFilterRange());
|
|
1180
|
+
}
|
|
1181
|
+
d.setSubunitId(a), r.set(i.id, d), this._tableAdd$.next({
|
|
1182
|
+
unitId: e,
|
|
1183
|
+
subUnitId: a,
|
|
1184
|
+
range: i.range,
|
|
1185
|
+
tableName: i.name,
|
|
1186
|
+
tableId: i.id
|
|
1187
|
+
});
|
|
1188
|
+
});
|
|
1189
|
+
}), this._tableInitStatus.next(!0);
|
|
1190
|
+
}
|
|
1191
|
+
deleteUnitId(e) {
|
|
1192
|
+
this._tableMap.delete(e);
|
|
1193
|
+
}
|
|
1194
|
+
dispose() {
|
|
1195
|
+
super.dispose(), this._tableMap.forEach((e) => {
|
|
1196
|
+
e.forEach((n) => n.dispose()), e.clear();
|
|
1197
|
+
}), this._tableMap.clear();
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
_ = Rn([
|
|
1201
|
+
xe(0, J),
|
|
1202
|
+
xe(1, S(fe))
|
|
1203
|
+
], _);
|
|
1204
|
+
var pn = Object.getOwnPropertyDescriptor, fn = (t, e, n, r) => {
|
|
1205
|
+
for (var s = r > 1 ? void 0 : r ? pn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
1206
|
+
(o = t[a]) && (s = o(s) || s);
|
|
1207
|
+
return s;
|
|
1208
|
+
}, Cn = (t, e) => (n, r) => e(n, r, t);
|
|
1209
|
+
let z = class extends k {
|
|
1210
|
+
constructor(t) {
|
|
1211
|
+
super(), this._tableManager = t;
|
|
1212
|
+
}
|
|
1213
|
+
getTableInfo(t, e) {
|
|
1214
|
+
const n = this._tableManager.getTable(t, e);
|
|
1215
|
+
if (n)
|
|
1216
|
+
return {
|
|
1217
|
+
unitId: t,
|
|
1218
|
+
...n.getTableInfo()
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
getTableList(t) {
|
|
1222
|
+
return this._tableManager.getTableList(t);
|
|
1223
|
+
}
|
|
1224
|
+
addTable(t, e, n, r, s, a, o) {
|
|
1225
|
+
return this._tableManager.addTable(t, e, n, r, s, a, o);
|
|
1226
|
+
}
|
|
1227
|
+
deleteTable(t, e, n) {
|
|
1228
|
+
this._tableManager.deleteTable(t, n);
|
|
1229
|
+
}
|
|
1230
|
+
getTableMeta(t, e) {
|
|
1231
|
+
var n;
|
|
1232
|
+
return (n = this._tableManager.getTable(t, e)) == null ? void 0 : n.getTableMeta();
|
|
1233
|
+
}
|
|
1234
|
+
setTableMeta(t, e, n) {
|
|
1235
|
+
var r;
|
|
1236
|
+
(r = this._tableManager.getTable(t, e)) == null || r.setTableMeta(n);
|
|
1237
|
+
}
|
|
1238
|
+
getTableColumnMeta(t, e, n) {
|
|
1239
|
+
var r, s;
|
|
1240
|
+
return (s = (r = this._tableManager.getTable(t, e)) == null ? void 0 : r.getTableColumnByIndex(n)) == null ? void 0 : s.getMeta();
|
|
1241
|
+
}
|
|
1242
|
+
selTableColumnMeta(t, e, n, r) {
|
|
1243
|
+
var s, a;
|
|
1244
|
+
(a = (s = this._tableManager.getTable(t, e)) == null ? void 0 : s.getTableColumnByIndex(n)) == null || a.setMeta(r);
|
|
1245
|
+
}
|
|
1246
|
+
addFilter(t, e, n, r) {
|
|
1247
|
+
this._tableManager.addFilter(t, e, n, r);
|
|
1248
|
+
}
|
|
1249
|
+
getCellValueWithConditionType(t, e, n, r = O.String) {
|
|
1250
|
+
return oe(t, e, n, r);
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
z = fn([
|
|
1254
|
+
Cn(0, S(_))
|
|
1255
|
+
], z);
|
|
1256
|
+
const te = {
|
|
1257
|
+
id: "sheet.mutation.add-table",
|
|
1258
|
+
type: y.MUTATION,
|
|
1259
|
+
handler: (t, e) => {
|
|
1260
|
+
const { tableId: n, unitId: r, subUnitId: s, name: a, range: o, header: l, options: u } = e;
|
|
1261
|
+
return t.get(z).addTable(r, s, a, o, l, n, u), !0;
|
|
1262
|
+
}
|
|
1263
|
+
}, ne = {
|
|
1264
|
+
id: "sheet.mutation.delete-table",
|
|
1265
|
+
type: y.MUTATION,
|
|
1266
|
+
handler: (t, e) => {
|
|
1267
|
+
const { unitId: n, subUnitId: r, tableId: s } = e;
|
|
1268
|
+
return t.get(z).deleteTable(n, r, s), !0;
|
|
1269
|
+
}
|
|
1270
|
+
}, Sn = {
|
|
1271
|
+
id: "sheet.command.add-table",
|
|
1272
|
+
type: y.COMMAND,
|
|
1273
|
+
handler: (t, e) => {
|
|
1274
|
+
var w;
|
|
1275
|
+
if (!e)
|
|
1276
|
+
return !1;
|
|
1277
|
+
const n = t.get($), r = t.get(x), s = t.get(fe), a = (w = e.id) != null ? w : L();
|
|
1278
|
+
let o = e.name;
|
|
1279
|
+
if (!o) {
|
|
1280
|
+
const R = t.get(_).getTableList(e.unitId).length;
|
|
1281
|
+
o = `${s.t("sheets-table.tablePrefix")} ${R + 1}`;
|
|
1282
|
+
}
|
|
1283
|
+
const l = [], u = [], i = t.get(_), { unitId: h, subUnitId: d, range: c } = e, m = i.getColumnHeader(h, d, c, s.t("sheets-table.columnPrefix"));
|
|
1284
|
+
return l.push({ id: te.id, params: { ...e, tableId: a, name: o, header: m } }), u.push({ id: ne.id, params: { tableId: a, unitId: e.unitId } }), A(l, r) && n.pushUndoRedo({
|
|
1285
|
+
unitID: e.unitId,
|
|
1286
|
+
undoMutations: u,
|
|
1287
|
+
redoMutations: l
|
|
1288
|
+
}), !0;
|
|
1289
|
+
}
|
|
1290
|
+
}, p = {
|
|
1291
|
+
id: "sheet.mutation.set-sheet-table",
|
|
1292
|
+
type: y.MUTATION,
|
|
1293
|
+
handler: (t, e) => {
|
|
1294
|
+
if (!e)
|
|
1295
|
+
return !1;
|
|
1296
|
+
const { unitId: n, tableId: r, config: s } = e;
|
|
1297
|
+
return t.get(_).setTableByConfig(n, r, s), !0;
|
|
1298
|
+
}
|
|
1299
|
+
}, _n = {
|
|
1300
|
+
id: "sheet.command.add-table-theme",
|
|
1301
|
+
type: y.COMMAND,
|
|
1302
|
+
handler: (t, e) => {
|
|
1303
|
+
if (!e)
|
|
1304
|
+
return !1;
|
|
1305
|
+
const n = t.get(_), { unitId: r, tableId: s, themeStyle: a } = e, o = [], l = [], u = n.getTableById(r, s);
|
|
1306
|
+
if (!u) return !1;
|
|
1307
|
+
const i = u.getSubunitId();
|
|
1308
|
+
o.push({
|
|
1309
|
+
id: Be.id,
|
|
1310
|
+
params: {
|
|
1311
|
+
unitId: r,
|
|
1312
|
+
subUnitId: i,
|
|
1313
|
+
styleJSON: a.toJson()
|
|
1314
|
+
}
|
|
1315
|
+
}), o.push({
|
|
1316
|
+
id: p.id,
|
|
1317
|
+
params: {
|
|
1318
|
+
unitId: r,
|
|
1319
|
+
subUnitId: i,
|
|
1320
|
+
tableId: s,
|
|
1321
|
+
config: {
|
|
1322
|
+
theme: a.getName()
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
}), l.push({
|
|
1326
|
+
id: p.id,
|
|
1327
|
+
params: {
|
|
1328
|
+
unitId: r,
|
|
1329
|
+
subUnitId: i,
|
|
1330
|
+
tableId: s,
|
|
1331
|
+
config: {
|
|
1332
|
+
themeStyle: u.getTableStyleId()
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}), l.push({
|
|
1336
|
+
id: Le.id,
|
|
1337
|
+
params: {
|
|
1338
|
+
unitId: r,
|
|
1339
|
+
subUnitId: i,
|
|
1340
|
+
styleName: a.getName()
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
const h = t.get(x);
|
|
1344
|
+
return A(o, h) && t.get($).pushUndoRedo({
|
|
1345
|
+
unitID: r,
|
|
1346
|
+
undoMutations: l,
|
|
1347
|
+
redoMutations: o
|
|
1348
|
+
}), !0;
|
|
1349
|
+
}
|
|
1350
|
+
}, Tn = {
|
|
1351
|
+
id: "sheet.command.delete-table",
|
|
1352
|
+
type: y.COMMAND,
|
|
1353
|
+
handler: (t, e) => {
|
|
1354
|
+
if (!e)
|
|
1355
|
+
return !1;
|
|
1356
|
+
const n = t.get($), r = t.get(x), s = t.get(_), a = [], o = [], l = s.getTable(e.unitId, e.tableId), u = l == null ? void 0 : l.toJSON();
|
|
1357
|
+
if (!u)
|
|
1358
|
+
throw new Error("[TableManager]: Table not found");
|
|
1359
|
+
return a.push({ id: ne.id, params: { ...e } }), o.push({
|
|
1360
|
+
id: te.id,
|
|
1361
|
+
params: {
|
|
1362
|
+
unitId: e.unitId,
|
|
1363
|
+
subUnitId: e.subUnitId,
|
|
1364
|
+
tableId: e.tableId,
|
|
1365
|
+
name: u.name,
|
|
1366
|
+
range: u.range,
|
|
1367
|
+
options: u.options
|
|
1368
|
+
}
|
|
1369
|
+
}), A(a, r) && n.pushUndoRedo({
|
|
1370
|
+
unitID: e.unitId,
|
|
1371
|
+
undoMutations: o,
|
|
1372
|
+
redoMutations: a
|
|
1373
|
+
}), !0;
|
|
1374
|
+
}
|
|
1375
|
+
}, In = {
|
|
1376
|
+
id: "sheet.command.remove-table-theme",
|
|
1377
|
+
type: y.COMMAND,
|
|
1378
|
+
handler: (t, e) => {
|
|
1379
|
+
if (!e)
|
|
1380
|
+
return !1;
|
|
1381
|
+
const { unitId: n, tableId: r, themeName: s } = e, a = t.get(_), o = t.get(We), l = a.getTableById(n, r);
|
|
1382
|
+
if (!l) return !1;
|
|
1383
|
+
const u = l.getSubunitId(), i = [], h = [], d = o.getRegisteredRangeThemes().filter((R) => R == null ? void 0 : R.startsWith("table-default"));
|
|
1384
|
+
let m = o.getRegisteredRangeThemes().filter((R) => R == null ? void 0 : R.startsWith("table-custom")).find((R) => R !== s);
|
|
1385
|
+
m || (m = d[0]), i.push({ id: p.id, params: { unitId: n, subUnitId: u, tableId: r, config: { theme: m } } }), i.push({ id: Le.id, params: { unitId: n, subUnitId: u, styleName: s } });
|
|
1386
|
+
const C = o.getDefaultRangeThemeStyle(s);
|
|
1387
|
+
C && (h.push({ id: Be.id, params: { unitId: n, subUnitId: u, styleJSON: C.toJson() } }), h.push({ id: p.id, params: { unitId: n, subUnitId: u, tableId: r, config: { theme: s } } }));
|
|
1388
|
+
const w = t.get(x);
|
|
1389
|
+
return A(i, w) && t.get($).pushUndoRedo({
|
|
1390
|
+
unitID: n,
|
|
1391
|
+
redoMutations: i,
|
|
1392
|
+
undoMutations: h
|
|
1393
|
+
}), !0;
|
|
1394
|
+
}
|
|
1395
|
+
}, Mn = {
|
|
1396
|
+
id: "sheet.command.set-table-config",
|
|
1397
|
+
type: y.COMMAND,
|
|
1398
|
+
handler: (t, e) => {
|
|
1399
|
+
if (!e)
|
|
1400
|
+
return !1;
|
|
1401
|
+
const { unitId: n, tableId: r, name: s, updateRange: a, rowColOperation: o, theme: l } = e, i = t.get(_).getTableById(n, r);
|
|
1402
|
+
if (!i) return !1;
|
|
1403
|
+
const h = {}, d = {};
|
|
1404
|
+
s && (h.name = i.getDisplayName(), d.name = s), o && (h.rowColOperation = {
|
|
1405
|
+
operationType: o.operationType === T.Insert ? T.Delete : T.Insert,
|
|
1406
|
+
rowColType: o.rowColType,
|
|
1407
|
+
index: o.index,
|
|
1408
|
+
count: o.count
|
|
1409
|
+
}, d.rowColOperation = o), a && (h.updateRange = {
|
|
1410
|
+
newRange: i.getRange()
|
|
1411
|
+
}, d.updateRange = a), l && (h.theme = i.getTableStyleId(), d.theme = l);
|
|
1412
|
+
const c = {
|
|
1413
|
+
unitId: n,
|
|
1414
|
+
subUnitId: i.getSubunitId(),
|
|
1415
|
+
tableId: r,
|
|
1416
|
+
config: d
|
|
1417
|
+
};
|
|
1418
|
+
return t.get(x).executeCommand(p.id, c), t.get($).pushUndoRedo({
|
|
1419
|
+
unitID: n,
|
|
1420
|
+
undoMutations: [
|
|
1421
|
+
{
|
|
1422
|
+
id: p.id,
|
|
1423
|
+
params: {
|
|
1424
|
+
unitId: n,
|
|
1425
|
+
subUnitId: i.getSubunitId(),
|
|
1426
|
+
tableId: r,
|
|
1427
|
+
config: h
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
],
|
|
1431
|
+
redoMutations: [
|
|
1432
|
+
{
|
|
1433
|
+
id: p.id,
|
|
1434
|
+
params: c
|
|
1435
|
+
}
|
|
1436
|
+
]
|
|
1437
|
+
}), !0;
|
|
1438
|
+
}
|
|
1439
|
+
}, pe = {
|
|
1440
|
+
id: "sheet.mutation.set-table-filter",
|
|
1441
|
+
type: y.MUTATION,
|
|
1442
|
+
handler: (t, e) => {
|
|
1443
|
+
const { tableId: n, unitId: r, column: s, tableFilter: a } = e;
|
|
1444
|
+
return t.get(_).addFilter(r, n, s, a), !0;
|
|
1445
|
+
}
|
|
1446
|
+
}, vn = {
|
|
1447
|
+
id: "sheet.command.set-table-filter",
|
|
1448
|
+
type: y.COMMAND,
|
|
1449
|
+
handler: (t, e) => {
|
|
1450
|
+
if (!e)
|
|
1451
|
+
return !1;
|
|
1452
|
+
const n = t.get($), r = t.get(x), s = e.tableId || L(), a = [], o = [];
|
|
1453
|
+
return a.push({ id: pe.id, params: { ...e, tableId: s } }), o.push({ id: pe.id, params: { ...e, tableId: s, tableFilter: void 0 } }), A(a, r) && n.pushUndoRedo({
|
|
1454
|
+
unitID: e.unitId,
|
|
1455
|
+
undoMutations: o,
|
|
1456
|
+
redoMutations: a
|
|
1457
|
+
}), !0;
|
|
1458
|
+
}
|
|
1459
|
+
}, je = "SHEET_TABLE_PLUGIN", se = "SHEET_TABLE";
|
|
1460
|
+
var Fn = Object.getOwnPropertyDescriptor, Dn = (t, e, n, r) => {
|
|
1461
|
+
for (var s = r > 1 ? void 0 : r ? Fn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
1462
|
+
(o = t[a]) && (s = o(s) || s);
|
|
1463
|
+
return s;
|
|
1464
|
+
}, me = (t, e) => (n, r) => e(n, r, t);
|
|
1465
|
+
let W = class extends k {
|
|
1466
|
+
constructor(e, n, r) {
|
|
1467
|
+
super();
|
|
1468
|
+
b(this, "_tableRangeRTree", /* @__PURE__ */ new Map());
|
|
1469
|
+
this._sheetInterceptorService = e, this._tableManager = n, this._resourceManagerService = r, this._initSnapshot(), this.registerTableChangeEvent(), this.registerTableHeaderInterceptor();
|
|
1470
|
+
}
|
|
1471
|
+
getContainerTableWithRange(e, n, r) {
|
|
1472
|
+
const s = this._ensureTableRangeRTree(e), o = Array.from(s.bulkSearch([{ unitId: e, sheetId: n, range: r }])).find((l) => {
|
|
1473
|
+
const u = this._tableManager.getTable(e, String(l));
|
|
1474
|
+
return u ? Re.contains(u.getRange(), r) : !1;
|
|
1475
|
+
});
|
|
1476
|
+
if (o)
|
|
1477
|
+
return this._tableManager.getTable(e, String(o));
|
|
1478
|
+
}
|
|
1479
|
+
_ensureTableRangeRTree(e) {
|
|
1480
|
+
return this._tableRangeRTree.has(e) || this._tableRangeRTree.set(e, new et()), this._tableRangeRTree.get(e);
|
|
1481
|
+
}
|
|
1482
|
+
registerTableChangeEvent() {
|
|
1483
|
+
this.disposeWithMe(
|
|
1484
|
+
this._tableManager.tableAdd$.subscribe((e) => {
|
|
1485
|
+
const { range: n, tableId: r, unitId: s, subUnitId: a } = e;
|
|
1486
|
+
this._ensureTableRangeRTree(s).insert({
|
|
1487
|
+
unitId: s,
|
|
1488
|
+
sheetId: a,
|
|
1489
|
+
id: r,
|
|
1490
|
+
range: { ...n }
|
|
1491
|
+
});
|
|
1492
|
+
})
|
|
1493
|
+
), this.disposeWithMe(
|
|
1494
|
+
this._tableManager.tableRangeChanged$.subscribe((e) => {
|
|
1495
|
+
const { range: n, tableId: r, unitId: s, subUnitId: a, oldRange: o } = e, l = this._ensureTableRangeRTree(s);
|
|
1496
|
+
l.remove({
|
|
1497
|
+
unitId: s,
|
|
1498
|
+
sheetId: a,
|
|
1499
|
+
id: r,
|
|
1500
|
+
range: { ...o }
|
|
1501
|
+
}), l.insert({
|
|
1502
|
+
unitId: s,
|
|
1503
|
+
sheetId: a,
|
|
1504
|
+
id: r,
|
|
1505
|
+
range: { ...n }
|
|
1506
|
+
});
|
|
1507
|
+
})
|
|
1508
|
+
), this.disposeWithMe(
|
|
1509
|
+
this._tableManager.tableDelete$.subscribe((e) => {
|
|
1510
|
+
const { tableId: n, unitId: r, subUnitId: s, range: a } = e;
|
|
1511
|
+
this._ensureTableRangeRTree(r).remove({
|
|
1512
|
+
unitId: r,
|
|
1513
|
+
sheetId: s,
|
|
1514
|
+
id: n,
|
|
1515
|
+
range: { ...a }
|
|
1516
|
+
});
|
|
1517
|
+
})
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
registerTableHeaderInterceptor() {
|
|
1521
|
+
this.disposeWithMe(
|
|
1522
|
+
this._sheetInterceptorService.intercept(Ee.CELL_CONTENT, {
|
|
1523
|
+
effect: tt.Value,
|
|
1524
|
+
handler: (e, n, r) => {
|
|
1525
|
+
const { row: s, col: a, unitId: o, subUnitId: l } = n, u = this._ensureTableRangeRTree(o);
|
|
1526
|
+
if ((e == null ? void 0 : e.v) === void 0 && u) {
|
|
1527
|
+
const h = Array.from(u.bulkSearch([{ unitId: o, sheetId: l, range: { startColumn: a, endColumn: a, startRow: s, endRow: s } }]));
|
|
1528
|
+
if (h.length > 0) {
|
|
1529
|
+
const d = this._tableManager.getTable(o, h[0]);
|
|
1530
|
+
if (d) {
|
|
1531
|
+
const c = d.getRange(), m = a - c.startColumn;
|
|
1532
|
+
if (c.startRow === s) {
|
|
1533
|
+
const w = d.getColumnNameByIndex(m), f = { ...e, v: w };
|
|
1534
|
+
return r(f);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return r(e);
|
|
1540
|
+
}
|
|
1541
|
+
})
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
_toJson(e) {
|
|
1545
|
+
return this._tableManager.toJSON(e);
|
|
1546
|
+
}
|
|
1547
|
+
_fromJSON(e, n) {
|
|
1548
|
+
return this._tableManager.fromJSON(e, n);
|
|
1549
|
+
}
|
|
1550
|
+
_deleteUnitId(e) {
|
|
1551
|
+
this._tableManager.deleteUnitId(e);
|
|
1552
|
+
}
|
|
1553
|
+
_initSnapshot() {
|
|
1554
|
+
this.disposeWithMe(this._resourceManagerService.registerPluginResource({
|
|
1555
|
+
toJson: (e) => JSON.stringify(this._toJson(e)),
|
|
1556
|
+
parseJson: (e) => {
|
|
1557
|
+
if (!e)
|
|
1558
|
+
return {};
|
|
1559
|
+
try {
|
|
1560
|
+
return JSON.parse(e);
|
|
1561
|
+
} catch {
|
|
1562
|
+
return {};
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
businesses: [Ce.UNIVER_SHEET],
|
|
1566
|
+
pluginName: je,
|
|
1567
|
+
onLoad: (e, n) => {
|
|
1568
|
+
this._fromJSON(e, n);
|
|
1569
|
+
},
|
|
1570
|
+
onUnLoad: (e) => {
|
|
1571
|
+
this._deleteUnitId(e);
|
|
1572
|
+
}
|
|
1573
|
+
}));
|
|
1574
|
+
}
|
|
1575
|
+
dispose() {
|
|
1576
|
+
super.dispose(), this._tableRangeRTree.clear();
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
W = Dn([
|
|
1580
|
+
me(0, S(Se)),
|
|
1581
|
+
me(1, S(_)),
|
|
1582
|
+
me(2, S(Ze))
|
|
1583
|
+
], W);
|
|
1584
|
+
const yn = {
|
|
1585
|
+
id: "sheet.command.table-insert-row",
|
|
1586
|
+
type: y.COMMAND,
|
|
1587
|
+
handler: (t) => {
|
|
1588
|
+
const e = t.get(J), n = U(e);
|
|
1589
|
+
if (!n)
|
|
1590
|
+
return !1;
|
|
1591
|
+
const { workbook: r, worksheet: s, unitId: a, subUnitId: o } = n, u = t.get(de).getCurrentSelections();
|
|
1592
|
+
if (!u.length || u.length > 1)
|
|
1593
|
+
return !1;
|
|
1594
|
+
t.get(_);
|
|
1595
|
+
const h = u[0].range, c = t.get(W).getContainerTableWithRange(a, o, h);
|
|
1596
|
+
if (!c) return !1;
|
|
1597
|
+
const m = h.endRow - h.startRow + 1, w = s.getRowCount() - 1, f = s.getCellMatrix().getDataRange().endRow, R = [], I = [];
|
|
1598
|
+
if (w - f < m)
|
|
1599
|
+
R.push({
|
|
1600
|
+
id: He.id,
|
|
1601
|
+
params: {
|
|
1602
|
+
unitId: a,
|
|
1603
|
+
subUnitId: o,
|
|
1604
|
+
range: { ...h }
|
|
1605
|
+
}
|
|
1606
|
+
}), R.push({
|
|
1607
|
+
id: p.id,
|
|
1608
|
+
params: {
|
|
1609
|
+
unitId: a,
|
|
1610
|
+
subUnitId: o,
|
|
1611
|
+
tableId: c.getId(),
|
|
1612
|
+
config: {
|
|
1613
|
+
updateRange: {
|
|
1614
|
+
newRange: {
|
|
1615
|
+
...c.getRange(),
|
|
1616
|
+
endRow: c.getRange().endRow + m
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}), I.push({
|
|
1622
|
+
id: p.id,
|
|
1623
|
+
params: {
|
|
1624
|
+
unitId: a,
|
|
1625
|
+
subUnitId: o,
|
|
1626
|
+
tableId: c.getId(),
|
|
1627
|
+
config: {
|
|
1628
|
+
updateRange: {
|
|
1629
|
+
newRange: c.getRange()
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}), I.push({
|
|
1634
|
+
id: Pe.id,
|
|
1635
|
+
params: {
|
|
1636
|
+
unitId: a,
|
|
1637
|
+
subUnitId: o,
|
|
1638
|
+
range: { ...h }
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
else {
|
|
1642
|
+
const M = { ...c.getRange() };
|
|
1643
|
+
R.push({
|
|
1644
|
+
id: p.id,
|
|
1645
|
+
params: {
|
|
1646
|
+
unitId: a,
|
|
1647
|
+
subUnitId: o,
|
|
1648
|
+
tableId: c.getId(),
|
|
1649
|
+
config: {
|
|
1650
|
+
updateRange: {
|
|
1651
|
+
newRange: {
|
|
1652
|
+
...M,
|
|
1653
|
+
endRow: M.endRow + m
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}), I.push({
|
|
1659
|
+
id: p.id,
|
|
1660
|
+
params: {
|
|
1661
|
+
unitId: a,
|
|
1662
|
+
subUnitId: o,
|
|
1663
|
+
tableId: c.getId(),
|
|
1664
|
+
config: {
|
|
1665
|
+
updateRange: {
|
|
1666
|
+
newRange: { ...M }
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
const X = he(
|
|
1672
|
+
t,
|
|
1673
|
+
{
|
|
1674
|
+
unitId: a,
|
|
1675
|
+
subUnitId: o,
|
|
1676
|
+
range: {
|
|
1677
|
+
startRow: h.startRow,
|
|
1678
|
+
endRow: f,
|
|
1679
|
+
startColumn: M.startColumn,
|
|
1680
|
+
endColumn: M.endColumn
|
|
1681
|
+
}
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
unitId: a,
|
|
1685
|
+
subUnitId: o,
|
|
1686
|
+
range: {
|
|
1687
|
+
startRow: h.startRow + m,
|
|
1688
|
+
endRow: f + m,
|
|
1689
|
+
startColumn: M.startColumn,
|
|
1690
|
+
endColumn: M.endColumn
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
);
|
|
1694
|
+
X && (R.push(...X.redos), I.push(...X.undos));
|
|
1695
|
+
}
|
|
1696
|
+
const B = t.get(x);
|
|
1697
|
+
return A(R, B) && t.get($).pushUndoRedo({
|
|
1698
|
+
unitID: a,
|
|
1699
|
+
undoMutations: I,
|
|
1700
|
+
redoMutations: R
|
|
1701
|
+
}), !0;
|
|
1702
|
+
}
|
|
1703
|
+
}, Nn = {
|
|
1704
|
+
id: "sheet.command.table-insert-col",
|
|
1705
|
+
type: y.COMMAND,
|
|
1706
|
+
handler: (t) => {
|
|
1707
|
+
const e = t.get(J), n = U(e);
|
|
1708
|
+
if (!n)
|
|
1709
|
+
return !1;
|
|
1710
|
+
const { worksheet: r, unitId: s, subUnitId: a } = n, l = t.get(de).getCurrentSelections();
|
|
1711
|
+
if (!l.length || l.length > 1)
|
|
1712
|
+
return !1;
|
|
1713
|
+
const i = l[0].range, d = t.get(W).getContainerTableWithRange(s, a, i);
|
|
1714
|
+
if (!d) return !1;
|
|
1715
|
+
const c = i.endColumn - i.startColumn + 1, C = r.getColumnCount() - 1, w = r.getCellMatrix().getDataRange().endColumn, f = [], R = [];
|
|
1716
|
+
if (C - w < c)
|
|
1717
|
+
f.push({
|
|
1718
|
+
id: Ve.id,
|
|
1719
|
+
params: {
|
|
1720
|
+
unitId: s,
|
|
1721
|
+
subUnitId: a,
|
|
1722
|
+
range: { ...i }
|
|
1723
|
+
}
|
|
1724
|
+
}), f.push({
|
|
1725
|
+
id: p.id,
|
|
1726
|
+
params: {
|
|
1727
|
+
unitId: s,
|
|
1728
|
+
subUnitId: a,
|
|
1729
|
+
tableId: d.getId(),
|
|
1730
|
+
config: {
|
|
1731
|
+
rowColOperation: {
|
|
1732
|
+
operationType: T.Insert,
|
|
1733
|
+
rowColType: D.Col,
|
|
1734
|
+
index: i.startColumn,
|
|
1735
|
+
count: c
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}), R.push({
|
|
1740
|
+
id: p.id,
|
|
1741
|
+
params: {
|
|
1742
|
+
unitId: s,
|
|
1743
|
+
subUnitId: a,
|
|
1744
|
+
tableId: d.getId(),
|
|
1745
|
+
config: {
|
|
1746
|
+
rowColOperation: {
|
|
1747
|
+
operationType: T.Delete,
|
|
1748
|
+
rowColType: D.Col,
|
|
1749
|
+
index: i.startColumn,
|
|
1750
|
+
count: c
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}), R.push({
|
|
1755
|
+
id: qe.id,
|
|
1756
|
+
params: {
|
|
1757
|
+
unitId: s,
|
|
1758
|
+
subUnitId: a,
|
|
1759
|
+
range: { ...i }
|
|
1760
|
+
}
|
|
1761
|
+
});
|
|
1762
|
+
else {
|
|
1763
|
+
const v = d.getRange();
|
|
1764
|
+
f.push({
|
|
1765
|
+
id: p.id,
|
|
1766
|
+
params: {
|
|
1767
|
+
unitId: s,
|
|
1768
|
+
subUnitId: a,
|
|
1769
|
+
tableId: d.getId(),
|
|
1770
|
+
config: {
|
|
1771
|
+
rowColOperation: {
|
|
1772
|
+
operationType: T.Insert,
|
|
1773
|
+
rowColType: D.Col,
|
|
1774
|
+
index: i.startColumn,
|
|
1775
|
+
count: c
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}), R.push({
|
|
1780
|
+
id: p.id,
|
|
1781
|
+
params: {
|
|
1782
|
+
unitId: s,
|
|
1783
|
+
subUnitId: a,
|
|
1784
|
+
tableId: d.getId(),
|
|
1785
|
+
config: {
|
|
1786
|
+
rowColOperation: {
|
|
1787
|
+
operationType: T.Delete,
|
|
1788
|
+
rowColType: D.Col,
|
|
1789
|
+
index: i.startColumn,
|
|
1790
|
+
count: c
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
});
|
|
1795
|
+
const M = he(
|
|
1796
|
+
t,
|
|
1797
|
+
{
|
|
1798
|
+
unitId: s,
|
|
1799
|
+
subUnitId: a,
|
|
1800
|
+
range: {
|
|
1801
|
+
startRow: v.startRow,
|
|
1802
|
+
endRow: v.endRow,
|
|
1803
|
+
startColumn: i.startColumn,
|
|
1804
|
+
endColumn: w
|
|
1805
|
+
}
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
unitId: s,
|
|
1809
|
+
subUnitId: a,
|
|
1810
|
+
range: {
|
|
1811
|
+
startRow: v.startRow,
|
|
1812
|
+
endRow: v.endRow,
|
|
1813
|
+
startColumn: i.startColumn + c,
|
|
1814
|
+
endColumn: w + c
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
);
|
|
1818
|
+
M && (f.push(...M.redos), R.push(...M.undos));
|
|
1819
|
+
}
|
|
1820
|
+
const I = t.get(x);
|
|
1821
|
+
return A(f, I) && t.get($).pushUndoRedo({
|
|
1822
|
+
unitID: s,
|
|
1823
|
+
undoMutations: R,
|
|
1824
|
+
redoMutations: f
|
|
1825
|
+
}), !0;
|
|
1826
|
+
}
|
|
1827
|
+
}, xn = {
|
|
1828
|
+
id: "sheet.command.table-remove-row",
|
|
1829
|
+
type: y.COMMAND,
|
|
1830
|
+
handler: (t, e) => {
|
|
1831
|
+
if (!e)
|
|
1832
|
+
return !1;
|
|
1833
|
+
const n = t.get(J), r = U(n);
|
|
1834
|
+
if (!r)
|
|
1835
|
+
return !1;
|
|
1836
|
+
const { unitId: s, subUnitId: a } = r, l = t.get(de).getCurrentSelections();
|
|
1837
|
+
if (!l.length || l.length > 1)
|
|
1838
|
+
return !1;
|
|
1839
|
+
const i = l[0].range, d = t.get(W).getContainerTableWithRange(s, a, i);
|
|
1840
|
+
if (!d) return !1;
|
|
1841
|
+
const c = i.endRow - i.startRow + 1, m = [], C = [], w = d.getRange();
|
|
1842
|
+
m.push({
|
|
1843
|
+
id: p.id,
|
|
1844
|
+
params: {
|
|
1845
|
+
unitId: s,
|
|
1846
|
+
subUnitId: a,
|
|
1847
|
+
tableId: d.getId(),
|
|
1848
|
+
config: {
|
|
1849
|
+
updateRange: {
|
|
1850
|
+
newRange: {
|
|
1851
|
+
...w,
|
|
1852
|
+
endRow: w.endRow - c
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}), C.push({
|
|
1858
|
+
id: p.id,
|
|
1859
|
+
params: {
|
|
1860
|
+
unitId: s,
|
|
1861
|
+
subUnitId: a,
|
|
1862
|
+
tableId: d.getId(),
|
|
1863
|
+
config: {
|
|
1864
|
+
updateRange: {
|
|
1865
|
+
newRange: { ...w }
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
const R = r.worksheet.getCellMatrix().getDataRange().endRow, I = he(
|
|
1871
|
+
t,
|
|
1872
|
+
{
|
|
1873
|
+
unitId: s,
|
|
1874
|
+
subUnitId: a,
|
|
1875
|
+
range: {
|
|
1876
|
+
startRow: i.endRow + 1,
|
|
1877
|
+
endRow: R,
|
|
1878
|
+
startColumn: w.startColumn,
|
|
1879
|
+
endColumn: w.endColumn
|
|
1880
|
+
}
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
unitId: s,
|
|
1884
|
+
subUnitId: a,
|
|
1885
|
+
range: {
|
|
1886
|
+
startRow: i.startRow,
|
|
1887
|
+
endRow: R - c,
|
|
1888
|
+
startColumn: w.startColumn,
|
|
1889
|
+
endColumn: w.endColumn
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
);
|
|
1893
|
+
I && (m.push(...I.redos), C.push(...I.undos));
|
|
1894
|
+
const B = t.get(x);
|
|
1895
|
+
return A(m, B) && t.get($).pushUndoRedo({
|
|
1896
|
+
unitID: s,
|
|
1897
|
+
undoMutations: C,
|
|
1898
|
+
redoMutations: m
|
|
1899
|
+
}), !0;
|
|
1900
|
+
}
|
|
1901
|
+
}, On = {
|
|
1902
|
+
id: "sheet.command.table-remove-col",
|
|
1903
|
+
type: y.COMMAND,
|
|
1904
|
+
handler: (t, e) => {
|
|
1905
|
+
if (!e)
|
|
1906
|
+
return !1;
|
|
1907
|
+
const n = t.get(J), r = U(n);
|
|
1908
|
+
if (!r)
|
|
1909
|
+
return !1;
|
|
1910
|
+
const { workbook: s, unitId: a, subUnitId: o } = r;
|
|
1911
|
+
t.get(_);
|
|
1912
|
+
const u = t.get(de).getCurrentSelections();
|
|
1913
|
+
if (!u.length || u.length > 1)
|
|
1914
|
+
return !1;
|
|
1915
|
+
const h = u[0].range, c = t.get(W).getContainerTableWithRange(a, o, h);
|
|
1916
|
+
if (!c) return !1;
|
|
1917
|
+
const m = h.endColumn - h.startColumn + 1, C = [], w = [], f = c.getRange();
|
|
1918
|
+
C.push({
|
|
1919
|
+
id: p.id,
|
|
1920
|
+
params: {
|
|
1921
|
+
unitId: a,
|
|
1922
|
+
subUnitId: o,
|
|
1923
|
+
tableId: c.getId(),
|
|
1924
|
+
config: {
|
|
1925
|
+
rowColOperation: {
|
|
1926
|
+
operationType: T.Delete,
|
|
1927
|
+
rowColType: D.Col,
|
|
1928
|
+
index: h.startColumn,
|
|
1929
|
+
count: m
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
});
|
|
1934
|
+
const R = [], I = h.startColumn - f.startColumn;
|
|
1935
|
+
for (let re = 0; re < m; re++) {
|
|
1936
|
+
const Te = c.getTableInfo().columns[I + re];
|
|
1937
|
+
Te && R.push(Te);
|
|
1938
|
+
}
|
|
1939
|
+
w.push({
|
|
1940
|
+
id: p.id,
|
|
1941
|
+
params: {
|
|
1942
|
+
unitId: a,
|
|
1943
|
+
subUnitId: o,
|
|
1944
|
+
tableId: c.getId(),
|
|
1945
|
+
config: {
|
|
1946
|
+
rowColOperation: {
|
|
1947
|
+
operationType: T.Insert,
|
|
1948
|
+
rowColType: D.Col,
|
|
1949
|
+
index: h.startColumn,
|
|
1950
|
+
count: m,
|
|
1951
|
+
columnsJson: R
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
const v = r.worksheet.getCellMatrix().getDataRange().endColumn, M = he(
|
|
1957
|
+
t,
|
|
1958
|
+
{
|
|
1959
|
+
unitId: a,
|
|
1960
|
+
subUnitId: o,
|
|
1961
|
+
range: {
|
|
1962
|
+
startRow: f.startRow,
|
|
1963
|
+
endRow: f.endRow,
|
|
1964
|
+
startColumn: h.endColumn + 1,
|
|
1965
|
+
endColumn: v
|
|
1966
|
+
}
|
|
1967
|
+
},
|
|
1968
|
+
{
|
|
1969
|
+
unitId: a,
|
|
1970
|
+
subUnitId: o,
|
|
1971
|
+
range: {
|
|
1972
|
+
startRow: f.startRow,
|
|
1973
|
+
endRow: f.endRow,
|
|
1974
|
+
startColumn: h.startColumn,
|
|
1975
|
+
endColumn: v - m
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
);
|
|
1979
|
+
M && (C.push(...M.redos), w.push(...M.undos));
|
|
1980
|
+
const X = t.get(x);
|
|
1981
|
+
return A(C, X) && t.get($).pushUndoRedo({
|
|
1982
|
+
unitID: a,
|
|
1983
|
+
undoMutations: w,
|
|
1984
|
+
redoMutations: C
|
|
1985
|
+
}), !0;
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
var Un = Object.getOwnPropertyDescriptor, $n = (t, e, n, r) => {
|
|
1989
|
+
for (var s = r > 1 ? void 0 : r ? Un(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
1990
|
+
(o = t[a]) && (s = o(s) || s);
|
|
1991
|
+
return s;
|
|
1992
|
+
}, Oe = (t, e) => (n, r) => e(n, r, t);
|
|
1993
|
+
let ie = class extends k {
|
|
1994
|
+
constructor(t, e) {
|
|
1995
|
+
super(), this._tableManager = t, this._exclusiveRangeService = e, this._initRangeListener();
|
|
1996
|
+
}
|
|
1997
|
+
_initRangeListener() {
|
|
1998
|
+
this.disposeWithMe(
|
|
1999
|
+
this._tableManager.tableRangeChanged$.subscribe((t) => {
|
|
2000
|
+
const { range: e, tableId: n, unitId: r, subUnitId: s } = t;
|
|
2001
|
+
this._exclusiveRangeService.clearExclusiveRangesByGroupId(r, s, se, n), this._exclusiveRangeService.addExclusiveRange(r, s, se, [{
|
|
2002
|
+
range: { ...e },
|
|
2003
|
+
groupId: n
|
|
2004
|
+
}]);
|
|
2005
|
+
})
|
|
2006
|
+
), this.disposeWithMe(
|
|
2007
|
+
this._tableManager.tableAdd$.subscribe((t) => {
|
|
2008
|
+
const { tableId: e, unitId: n, subUnitId: r, range: s } = t;
|
|
2009
|
+
this._exclusiveRangeService.addExclusiveRange(n, r, se, [{
|
|
2010
|
+
range: { ...s },
|
|
2011
|
+
groupId: e
|
|
2012
|
+
}]);
|
|
2013
|
+
})
|
|
2014
|
+
), this.disposeWithMe(
|
|
2015
|
+
this._tableManager.tableDelete$.subscribe((t) => {
|
|
2016
|
+
const { tableId: e, unitId: n, subUnitId: r } = t;
|
|
2017
|
+
this._exclusiveRangeService.clearExclusiveRangesByGroupId(n, r, se, e);
|
|
2018
|
+
})
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
ie = $n([
|
|
2023
|
+
Oe(0, S(_)),
|
|
2024
|
+
Oe(1, S(st))
|
|
2025
|
+
], ie);
|
|
2026
|
+
var An = Object.getOwnPropertyDescriptor, Bn = (t, e, n, r) => {
|
|
2027
|
+
for (var s = r > 1 ? void 0 : r ? An(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
2028
|
+
(o = t[a]) && (s = o(s) || s);
|
|
2029
|
+
return s;
|
|
2030
|
+
}, E = (t, e) => (n, r) => e(n, r, t);
|
|
2031
|
+
let le = class extends k {
|
|
2032
|
+
constructor(t, e, n, r, s, a, o) {
|
|
2033
|
+
super(), this._commandService = t, this._refRangeService = e, this._univerInstanceService = n, this._injector = r, this._sheetInterceptorService = s, this._tableManager = a, this._localeService = o, this._initCommandInterceptor(), this._initCommandListener();
|
|
2034
|
+
}
|
|
2035
|
+
_initCommandInterceptor() {
|
|
2036
|
+
const t = this;
|
|
2037
|
+
this._sheetInterceptorService.interceptCommand({
|
|
2038
|
+
getMutations(e) {
|
|
2039
|
+
const n = { redos: [], undos: [] }, { id: r, params: s } = e;
|
|
2040
|
+
switch (r) {
|
|
2041
|
+
case ut.id:
|
|
2042
|
+
return t._generateTableMutationWithInsertRow(s);
|
|
2043
|
+
case lt.id:
|
|
2044
|
+
return t._generateTableMutationWithInsertCol(s);
|
|
2045
|
+
case it.id:
|
|
2046
|
+
return t._generateTableMutationWithRemoveRow(s);
|
|
2047
|
+
case ot.id:
|
|
2048
|
+
return t._generateTableMutationWithRemoveCol(s);
|
|
2049
|
+
}
|
|
2050
|
+
return n;
|
|
2051
|
+
}
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
_generateTableMutationWithInsertRow(t) {
|
|
2055
|
+
const e = [], n = [], r = U(this._univerInstanceService);
|
|
2056
|
+
if (!r)
|
|
2057
|
+
return { undos: e, redos: n };
|
|
2058
|
+
const { unitId: s, subUnitId: a } = r, o = this._tableManager.getTablesBySubunitId(s, a);
|
|
2059
|
+
if (!o.length)
|
|
2060
|
+
return { undos: e, redos: n };
|
|
2061
|
+
const { range: l } = t;
|
|
2062
|
+
return o.forEach((u) => {
|
|
2063
|
+
const i = u.getRange();
|
|
2064
|
+
if (l.startRow > i.startRow && l.startRow <= i.endRow) {
|
|
2065
|
+
const h = l.endRow - l.startRow + 1;
|
|
2066
|
+
n.push({
|
|
2067
|
+
id: p.id,
|
|
2068
|
+
params: {
|
|
2069
|
+
unitId: s,
|
|
2070
|
+
subUnitId: a,
|
|
2071
|
+
tableId: u.getId(),
|
|
2072
|
+
config: {
|
|
2073
|
+
updateRange: {
|
|
2074
|
+
newRange: {
|
|
2075
|
+
...i,
|
|
2076
|
+
endRow: i.endRow + h
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}), e.push({
|
|
2082
|
+
id: p.id,
|
|
2083
|
+
params: {
|
|
2084
|
+
unitId: s,
|
|
2085
|
+
subUnitId: a,
|
|
2086
|
+
tableId: u.getId(),
|
|
2087
|
+
config: {
|
|
2088
|
+
updateRange: {
|
|
2089
|
+
newRange: {
|
|
2090
|
+
...i
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
2097
|
+
}), { undos: e, redos: n };
|
|
2098
|
+
}
|
|
2099
|
+
_generateTableMutationWithInsertCol(t) {
|
|
2100
|
+
const e = [], n = [], r = U(this._univerInstanceService);
|
|
2101
|
+
if (!r)
|
|
2102
|
+
return { undos: e, redos: n };
|
|
2103
|
+
const { unitId: s, subUnitId: a } = r, o = this._tableManager.getTablesBySubunitId(s, a);
|
|
2104
|
+
if (!o.length)
|
|
2105
|
+
return { undos: e, redos: n };
|
|
2106
|
+
const { range: l } = t;
|
|
2107
|
+
return o.forEach((u) => {
|
|
2108
|
+
const i = u.getRange();
|
|
2109
|
+
if (l.startColumn > i.startColumn && l.startColumn <= i.endColumn) {
|
|
2110
|
+
const h = l.endColumn - l.startColumn + 1;
|
|
2111
|
+
n.push({
|
|
2112
|
+
id: p.id,
|
|
2113
|
+
params: {
|
|
2114
|
+
unitId: s,
|
|
2115
|
+
subUnitId: a,
|
|
2116
|
+
tableId: u.getId(),
|
|
2117
|
+
config: {
|
|
2118
|
+
rowColOperation: {
|
|
2119
|
+
operationType: T.Insert,
|
|
2120
|
+
rowColType: D.Col,
|
|
2121
|
+
index: l.startColumn,
|
|
2122
|
+
count: h
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
}), e.push({
|
|
2127
|
+
id: p.id,
|
|
2128
|
+
params: {
|
|
2129
|
+
unitId: s,
|
|
2130
|
+
subUnitId: a,
|
|
2131
|
+
tableId: u.getId(),
|
|
2132
|
+
config: {
|
|
2133
|
+
rowColOperation: {
|
|
2134
|
+
operationType: T.Delete,
|
|
2135
|
+
rowColType: D.Col,
|
|
2136
|
+
index: l.startColumn,
|
|
2137
|
+
count: h
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
}), { undos: e, redos: n };
|
|
2144
|
+
}
|
|
2145
|
+
_generateTableMutationWithRemoveRow(t) {
|
|
2146
|
+
const e = [], n = [], r = [], s = [], a = U(this._univerInstanceService);
|
|
2147
|
+
if (!a)
|
|
2148
|
+
return { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2149
|
+
const { unitId: o, subUnitId: l } = a, u = this._tableManager.getTablesBySubunitId(o, l);
|
|
2150
|
+
if (!u.length)
|
|
2151
|
+
return { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2152
|
+
const { range: i } = t, h = i.endRow - i.startRow + 1;
|
|
2153
|
+
return u.forEach((d) => {
|
|
2154
|
+
const c = d.getRange();
|
|
2155
|
+
if (Re.intersects(c, i))
|
|
2156
|
+
if (i.startRow <= c.startRow && i.endRow >= c.startRow) {
|
|
2157
|
+
r.push({
|
|
2158
|
+
id: ne.id,
|
|
2159
|
+
params: {
|
|
2160
|
+
unitId: o,
|
|
2161
|
+
subUnitId: l,
|
|
2162
|
+
tableId: d.getId()
|
|
2163
|
+
}
|
|
2164
|
+
});
|
|
2165
|
+
const m = d.toJSON();
|
|
2166
|
+
e.push({
|
|
2167
|
+
id: te.id,
|
|
2168
|
+
params: {
|
|
2169
|
+
unitId: o,
|
|
2170
|
+
subUnitId: l,
|
|
2171
|
+
tableId: m.id,
|
|
2172
|
+
name: m.name,
|
|
2173
|
+
range: m.range,
|
|
2174
|
+
options: m.options
|
|
2175
|
+
}
|
|
2176
|
+
});
|
|
2177
|
+
} else i.startRow > c.startRow && i.startRow <= c.endRow ? (n.push({
|
|
2178
|
+
id: p.id,
|
|
2179
|
+
params: {
|
|
2180
|
+
unitId: o,
|
|
2181
|
+
subUnitId: l,
|
|
2182
|
+
tableId: d.getId(),
|
|
2183
|
+
config: {
|
|
2184
|
+
updateRange: {
|
|
2185
|
+
newRange: {
|
|
2186
|
+
...c,
|
|
2187
|
+
endRow: c.endRow - h
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}), e.push({
|
|
2193
|
+
id: p.id,
|
|
2194
|
+
params: {
|
|
2195
|
+
unitId: o,
|
|
2196
|
+
subUnitId: l,
|
|
2197
|
+
tableId: d.getId(),
|
|
2198
|
+
config: {
|
|
2199
|
+
updateRange: {
|
|
2200
|
+
newRange: {
|
|
2201
|
+
...c
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
})) : i.startRow < c.endRow && i.endRow >= c.endRow && (n.push({
|
|
2207
|
+
id: p.id,
|
|
2208
|
+
params: {
|
|
2209
|
+
unitId: o,
|
|
2210
|
+
subUnitId: l,
|
|
2211
|
+
tableId: d.getId(),
|
|
2212
|
+
config: {
|
|
2213
|
+
updateRange: {
|
|
2214
|
+
newRange: {
|
|
2215
|
+
...c,
|
|
2216
|
+
endRow: i.startRow - 1
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}), e.push({
|
|
2222
|
+
id: p.id,
|
|
2223
|
+
params: {
|
|
2224
|
+
unitId: o,
|
|
2225
|
+
subUnitId: l,
|
|
2226
|
+
tableId: d.getId(),
|
|
2227
|
+
config: {
|
|
2228
|
+
updateRange: {
|
|
2229
|
+
newRange: {
|
|
2230
|
+
...c
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
}));
|
|
2236
|
+
}), { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2237
|
+
}
|
|
2238
|
+
_generateTableMutationWithRemoveCol(t) {
|
|
2239
|
+
const e = [], n = [], r = [], s = [], a = U(this._univerInstanceService);
|
|
2240
|
+
if (!a)
|
|
2241
|
+
return { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2242
|
+
const { unitId: o, subUnitId: l } = a, u = this._tableManager.getTablesBySubunitId(o, l);
|
|
2243
|
+
if (!u.length)
|
|
2244
|
+
return { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2245
|
+
const { range: i } = t, h = i.endColumn - i.startColumn + 1;
|
|
2246
|
+
return u.forEach((d) => {
|
|
2247
|
+
const c = d.getRange();
|
|
2248
|
+
if (Re.intersects(c, i)) {
|
|
2249
|
+
if (i.startColumn <= c.startColumn && i.endColumn >= c.endColumn) {
|
|
2250
|
+
r.push({
|
|
2251
|
+
id: ne.id,
|
|
2252
|
+
params: {
|
|
2253
|
+
unitId: o,
|
|
2254
|
+
subUnitId: l,
|
|
2255
|
+
tableId: d.getId()
|
|
2256
|
+
}
|
|
2257
|
+
});
|
|
2258
|
+
const m = d.toJSON(), { startRow: C, startColumn: w, endColumn: f } = m.range, R = this._univerInstanceService.getUnit(o), I = R == null ? void 0 : R.getSheetBySheetId(l);
|
|
2259
|
+
if (!I)
|
|
2260
|
+
return { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2261
|
+
const B = [];
|
|
2262
|
+
for (let v = w; v <= f; v++)
|
|
2263
|
+
B.push(Qe(I == null ? void 0 : I.getCell(C, v)) || Z(v - w + 1, this._localeService.t("sheets-table.columnPrefix")));
|
|
2264
|
+
e.push({
|
|
2265
|
+
id: te.id,
|
|
2266
|
+
params: {
|
|
2267
|
+
unitId: o,
|
|
2268
|
+
subUnitId: l,
|
|
2269
|
+
tableId: m.id,
|
|
2270
|
+
name: m.name,
|
|
2271
|
+
header: B,
|
|
2272
|
+
range: m.range,
|
|
2273
|
+
options: m.options
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
} else if (i.startColumn <= c.startColumn && i.endColumn >= c.startColumn) {
|
|
2277
|
+
const m = i.endColumn - c.startColumn + 1;
|
|
2278
|
+
n.push({
|
|
2279
|
+
id: p.id,
|
|
2280
|
+
params: {
|
|
2281
|
+
unitId: o,
|
|
2282
|
+
subUnitId: l,
|
|
2283
|
+
tableId: d.getId(),
|
|
2284
|
+
config: {
|
|
2285
|
+
rowColOperation: {
|
|
2286
|
+
operationType: T.Delete,
|
|
2287
|
+
rowColType: D.Col,
|
|
2288
|
+
index: c.startColumn,
|
|
2289
|
+
count: m
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
const C = [];
|
|
2295
|
+
for (let w = 0; w < m; w++) {
|
|
2296
|
+
const f = d.getTableColumnByIndex(w);
|
|
2297
|
+
f && C.push(f.toJSON());
|
|
2298
|
+
}
|
|
2299
|
+
e.push({
|
|
2300
|
+
id: p.id,
|
|
2301
|
+
params: {
|
|
2302
|
+
unitId: o,
|
|
2303
|
+
subUnitId: l,
|
|
2304
|
+
tableId: d.getId(),
|
|
2305
|
+
config: {
|
|
2306
|
+
rowColOperation: {
|
|
2307
|
+
operationType: T.Insert,
|
|
2308
|
+
rowColType: D.Col,
|
|
2309
|
+
index: c.startColumn,
|
|
2310
|
+
count: m,
|
|
2311
|
+
columnsJson: C
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
});
|
|
2316
|
+
} else if (i.startColumn > c.startColumn && i.endColumn > c.endColumn) {
|
|
2317
|
+
const m = c.endColumn - i.startColumn + 1;
|
|
2318
|
+
n.push({
|
|
2319
|
+
id: p.id,
|
|
2320
|
+
params: {
|
|
2321
|
+
unitId: o,
|
|
2322
|
+
subUnitId: l,
|
|
2323
|
+
tableId: d.getId(),
|
|
2324
|
+
config: {
|
|
2325
|
+
rowColOperation: {
|
|
2326
|
+
operationType: T.Delete,
|
|
2327
|
+
rowColType: D.Col,
|
|
2328
|
+
index: i.startColumn,
|
|
2329
|
+
count: m
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
});
|
|
2334
|
+
const C = [], w = i.startColumn - c.startColumn;
|
|
2335
|
+
for (let f = 0; f < m; f++) {
|
|
2336
|
+
const R = d.getTableColumnByIndex(f + w);
|
|
2337
|
+
R && C.push(R.toJSON());
|
|
2338
|
+
}
|
|
2339
|
+
e.push({
|
|
2340
|
+
id: p.id,
|
|
2341
|
+
params: {
|
|
2342
|
+
unitId: o,
|
|
2343
|
+
subUnitId: l,
|
|
2344
|
+
tableId: d.getId(),
|
|
2345
|
+
config: {
|
|
2346
|
+
rowColOperation: {
|
|
2347
|
+
operationType: T.Insert,
|
|
2348
|
+
rowColType: D.Col,
|
|
2349
|
+
index: i.startColumn,
|
|
2350
|
+
count: h,
|
|
2351
|
+
columnsJson: C
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
});
|
|
2356
|
+
} else if (i.startColumn > c.startColumn && i.endColumn <= c.endColumn) {
|
|
2357
|
+
n.push({
|
|
2358
|
+
id: p.id,
|
|
2359
|
+
params: {
|
|
2360
|
+
unitId: o,
|
|
2361
|
+
subUnitId: l,
|
|
2362
|
+
tableId: d.getId(),
|
|
2363
|
+
config: {
|
|
2364
|
+
rowColOperation: {
|
|
2365
|
+
operationType: T.Delete,
|
|
2366
|
+
rowColType: D.Col,
|
|
2367
|
+
index: i.startColumn,
|
|
2368
|
+
count: h
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
const m = [], C = i.startColumn - c.startColumn;
|
|
2374
|
+
for (let w = 0; w < h; w++) {
|
|
2375
|
+
const f = d.getTableColumnByIndex(w + C);
|
|
2376
|
+
f && m.push(f.toJSON());
|
|
2377
|
+
}
|
|
2378
|
+
e.push({
|
|
2379
|
+
id: p.id,
|
|
2380
|
+
params: {
|
|
2381
|
+
unitId: o,
|
|
2382
|
+
subUnitId: l,
|
|
2383
|
+
tableId: d.getId(),
|
|
2384
|
+
config: {
|
|
2385
|
+
rowColOperation: {
|
|
2386
|
+
operationType: T.Insert,
|
|
2387
|
+
rowColType: D.Col,
|
|
2388
|
+
index: i.startColumn,
|
|
2389
|
+
count: h,
|
|
2390
|
+
columnsJson: m
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
}), { undos: e, redos: n, preRedos: r, preUndos: s };
|
|
2398
|
+
}
|
|
2399
|
+
_initCommandListener() {
|
|
2400
|
+
this._commandService.onCommandExecuted((t) => {
|
|
2401
|
+
if (t.id === He.id) {
|
|
2402
|
+
const e = t.params, { unitId: n, subUnitId: r, range: s } = e, a = s.endRow - s.startRow + 1;
|
|
2403
|
+
this._tableManager.getTablesBySubunitId(n, r).forEach((l) => {
|
|
2404
|
+
const u = l.getRange();
|
|
2405
|
+
s.startRow <= u.startRow && this._tableManager.updateTableRange(n, l.getId(), {
|
|
2406
|
+
newRange: {
|
|
2407
|
+
...u,
|
|
2408
|
+
startRow: u.startRow + a,
|
|
2409
|
+
endRow: u.endRow + a
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
});
|
|
2413
|
+
} else if (t.id === Ve.id) {
|
|
2414
|
+
const e = t.params, { unitId: n, subUnitId: r, range: s } = e, a = s.endColumn - s.startColumn + 1;
|
|
2415
|
+
this._tableManager.getTablesBySubunitId(n, r).forEach((l) => {
|
|
2416
|
+
const u = l.getRange();
|
|
2417
|
+
s.startColumn <= u.startColumn && this._tableManager.updateTableRange(n, l.getId(), {
|
|
2418
|
+
newRange: {
|
|
2419
|
+
...u,
|
|
2420
|
+
startColumn: u.startColumn + a,
|
|
2421
|
+
endColumn: u.endColumn + a
|
|
2422
|
+
}
|
|
2423
|
+
});
|
|
2424
|
+
});
|
|
2425
|
+
} else if (t.id === Pe.id) {
|
|
2426
|
+
const e = t.params, { unitId: n, subUnitId: r, range: s } = e, a = s.endRow - s.startRow + 1;
|
|
2427
|
+
this._tableManager.getTablesBySubunitId(n, r).forEach((l) => {
|
|
2428
|
+
const u = l.getRange();
|
|
2429
|
+
s.startRow < u.startRow && this._tableManager.updateTableRange(n, l.getId(), {
|
|
2430
|
+
newRange: {
|
|
2431
|
+
...u,
|
|
2432
|
+
startRow: u.startRow - a,
|
|
2433
|
+
endRow: u.endRow - a
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
});
|
|
2437
|
+
} else if (t.id === qe.id) {
|
|
2438
|
+
const e = t.params, { unitId: n, subUnitId: r, range: s } = e, a = s.endColumn - s.startColumn + 1;
|
|
2439
|
+
this._tableManager.getTablesBySubunitId(n, r).forEach((l) => {
|
|
2440
|
+
const u = l.getRange();
|
|
2441
|
+
s.startColumn < u.startColumn && this._tableManager.updateTableRange(n, l.getId(), {
|
|
2442
|
+
newRange: {
|
|
2443
|
+
...u,
|
|
2444
|
+
startColumn: u.startColumn - a,
|
|
2445
|
+
endColumn: u.endColumn - a
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
});
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
le = Bn([
|
|
2454
|
+
E(0, S(x)),
|
|
2455
|
+
E(1, S(at)),
|
|
2456
|
+
E(2, S(J)),
|
|
2457
|
+
E(3, S(Ae)),
|
|
2458
|
+
E(4, S(Se)),
|
|
2459
|
+
E(5, S(_)),
|
|
2460
|
+
E(6, S(fe))
|
|
2461
|
+
], le);
|
|
2462
|
+
var Ln = Object.getOwnPropertyDescriptor, Wn = (t, e, n, r) => {
|
|
2463
|
+
for (var s = r > 1 ? void 0 : r ? Ln(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
2464
|
+
(o = t[a]) && (s = o(s) || s);
|
|
2465
|
+
return s;
|
|
2466
|
+
}, be = (t, e) => (n, r) => e(n, r, t);
|
|
2467
|
+
let ue = class extends k {
|
|
2468
|
+
constructor(t, e, n) {
|
|
2469
|
+
super(), this._tableManager = t, this._sheetRangeThemeService = e, this._sheetRangeThemeModel = n, this.registerTableChangeEvent(), this._initDefaultTableTheme();
|
|
2470
|
+
}
|
|
2471
|
+
registerTableChangeEvent() {
|
|
2472
|
+
this.disposeWithMe(
|
|
2473
|
+
this._tableManager.tableAdd$.subscribe((t) => {
|
|
2474
|
+
const { range: e, tableId: n, unitId: r, subUnitId: s } = t, o = this._tableManager.getTable(r, n).getTableStyleId() || Y[0].name;
|
|
2475
|
+
this._sheetRangeThemeService.registerRangeThemeStyle(o, {
|
|
2476
|
+
unitId: r,
|
|
2477
|
+
subUnitId: s,
|
|
2478
|
+
range: { ...e }
|
|
2479
|
+
});
|
|
2480
|
+
})
|
|
2481
|
+
), this.disposeWithMe(
|
|
2482
|
+
this._tableManager.tableRangeChanged$.subscribe((t) => {
|
|
2483
|
+
const { range: e, oldRange: n, tableId: r, unitId: s, subUnitId: a } = t, l = this._tableManager.getTable(s, r).getTableStyleId() || Y[0].name;
|
|
2484
|
+
this._sheetRangeThemeService.removeRangeThemeRule(l, {
|
|
2485
|
+
unitId: s,
|
|
2486
|
+
subUnitId: a,
|
|
2487
|
+
range: { ...n }
|
|
2488
|
+
}), this._sheetRangeThemeService.registerRangeThemeStyle(l, {
|
|
2489
|
+
unitId: s,
|
|
2490
|
+
subUnitId: a,
|
|
2491
|
+
range: { ...e }
|
|
2492
|
+
});
|
|
2493
|
+
})
|
|
2494
|
+
), this.disposeWithMe(
|
|
2495
|
+
this._tableManager.tableThemeChanged$.subscribe((t) => {
|
|
2496
|
+
const { theme: e, oldTheme: n, tableId: r, unitId: s, subUnitId: a } = t, l = this._tableManager.getTable(s, r).getRange();
|
|
2497
|
+
this._sheetRangeThemeService.removeRangeThemeRule(n, {
|
|
2498
|
+
unitId: s,
|
|
2499
|
+
subUnitId: a,
|
|
2500
|
+
range: { ...l }
|
|
2501
|
+
}), this._sheetRangeThemeService.registerRangeThemeStyle(e, {
|
|
2502
|
+
unitId: s,
|
|
2503
|
+
subUnitId: a,
|
|
2504
|
+
range: { ...l }
|
|
2505
|
+
});
|
|
2506
|
+
})
|
|
2507
|
+
), this.disposeWithMe(
|
|
2508
|
+
this._tableManager.tableDelete$.subscribe((t) => {
|
|
2509
|
+
const { range: e, unitId: n, subUnitId: r, tableStyleId: s = Y[0].name } = t;
|
|
2510
|
+
this._sheetRangeThemeService.removeRangeThemeRule(s, {
|
|
2511
|
+
unitId: n,
|
|
2512
|
+
subUnitId: r,
|
|
2513
|
+
range: { ...e }
|
|
2514
|
+
});
|
|
2515
|
+
})
|
|
2516
|
+
);
|
|
2517
|
+
}
|
|
2518
|
+
_initDefaultTableTheme() {
|
|
2519
|
+
for (let t = 0; t < Y.length; t++) {
|
|
2520
|
+
const { name: e, style: n } = Y[t], r = new dt(e, n);
|
|
2521
|
+
this._sheetRangeThemeModel.registerDefaultRangeTheme(r);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
dispose() {
|
|
2525
|
+
super.dispose();
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
ue = Wn([
|
|
2529
|
+
be(0, S(_)),
|
|
2530
|
+
be(1, S(ct)),
|
|
2531
|
+
be(2, S(We))
|
|
2532
|
+
], ue);
|
|
2533
|
+
var En = Object.getOwnPropertyDescriptor, Hn = (t, e, n, r) => {
|
|
2534
|
+
for (var s = r > 1 ? void 0 : r ? En(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
2535
|
+
(o = t[a]) && (s = o(s) || s);
|
|
2536
|
+
return s;
|
|
2537
|
+
}, we = (t, e) => (n, r) => e(n, r, t);
|
|
2538
|
+
const Pn = () => /* @__PURE__ */ new Set();
|
|
2539
|
+
let ce = class extends k {
|
|
2540
|
+
constructor(e, n, r) {
|
|
2541
|
+
super();
|
|
2542
|
+
b(this, "_tableFilteredOutRows$", new Je(Pn()));
|
|
2543
|
+
b(this, "tableFilteredOutRows$", this._tableFilteredOutRows$.asObservable());
|
|
2544
|
+
b(this, "_subscription", null);
|
|
2545
|
+
this._tableManager = e, this._sheetInterceptorService = n, this._univerInstanceService = r, this.registerFilterChangeEvent(), this.initTableHiddenRowIntercept(), this._initFilteredOutRows();
|
|
2546
|
+
}
|
|
2547
|
+
get tableFilteredOutRows() {
|
|
2548
|
+
return this._tableFilteredOutRows$.value;
|
|
2549
|
+
}
|
|
2550
|
+
set tableFilteredOutRows(e) {
|
|
2551
|
+
this._tableFilteredOutRows$.next(e);
|
|
2552
|
+
}
|
|
2553
|
+
initTableHiddenRowIntercept() {
|
|
2554
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(Ee.ROW_FILTERED, {
|
|
2555
|
+
// 这里需要保证优先级高于sheet的筛选,因为筛选没有next,低于筛选的不会触发interceptor
|
|
2556
|
+
priority: 100,
|
|
2557
|
+
handler: (e, n, r) => {
|
|
2558
|
+
if (e) return !0;
|
|
2559
|
+
const s = this.tableFilteredOutRows.has(n.row);
|
|
2560
|
+
return s ? !0 : r(s);
|
|
2561
|
+
}
|
|
2562
|
+
}));
|
|
2563
|
+
}
|
|
2564
|
+
_initFilteredOutRows() {
|
|
2565
|
+
this._tableManager.tableInitStatus$.pipe(
|
|
2566
|
+
ge((e) => e),
|
|
2567
|
+
Me(() => this._univerInstanceService.getCurrentTypeOfUnit$(Ce.UNIVER_SHEET)),
|
|
2568
|
+
ge((e) => e != null),
|
|
2569
|
+
Me((e) => e.activeSheet$),
|
|
2570
|
+
ge((e) => e != null)
|
|
2571
|
+
).subscribe(() => {
|
|
2572
|
+
const e = U(this._univerInstanceService);
|
|
2573
|
+
if (!e)
|
|
2574
|
+
return;
|
|
2575
|
+
const { unitId: n, subUnitId: r } = e;
|
|
2576
|
+
this.tableFilteredOutRows.clear(), this._tableManager.getTablesBySubunitId(n, r).forEach((a) => {
|
|
2577
|
+
const o = a.getTableFilters().getFilterOutRows();
|
|
2578
|
+
if (o)
|
|
2579
|
+
for (const l of o)
|
|
2580
|
+
this.tableFilteredOutRows.add(l);
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
registerFilterChangeEvent() {
|
|
2585
|
+
this.disposeWithMe(
|
|
2586
|
+
this._tableManager.tableFilterChanged$.subscribe((e) => {
|
|
2587
|
+
var i;
|
|
2588
|
+
const { unitId: n, subUnitId: r, tableId: s } = e, a = (i = this._univerInstanceService.getUnit(n)) == null ? void 0 : i.getSheetBySheetId(r), o = this._tableManager.getTable(n, s);
|
|
2589
|
+
if (!a || !o)
|
|
2590
|
+
return;
|
|
2591
|
+
this.tableFilteredOutRows.clear(), o.getTableFilters().doFilter(a, o.getTableFilterRange()), this._tableManager.getTablesBySubunitId(n, r).forEach((h) => {
|
|
2592
|
+
const d = h.getTableFilters().getFilterOutRows();
|
|
2593
|
+
if (d)
|
|
2594
|
+
for (const c of d)
|
|
2595
|
+
this.tableFilteredOutRows.add(c);
|
|
2596
|
+
});
|
|
2597
|
+
})
|
|
2598
|
+
);
|
|
2599
|
+
}
|
|
2600
|
+
dispose() {
|
|
2601
|
+
var e;
|
|
2602
|
+
super.dispose(), (e = this._subscription) == null || e.unsubscribe();
|
|
2603
|
+
}
|
|
2604
|
+
};
|
|
2605
|
+
ce = Hn([
|
|
2606
|
+
we(0, S(_)),
|
|
2607
|
+
we(1, S(Se)),
|
|
2608
|
+
we(2, S(J))
|
|
2609
|
+
], ce);
|
|
2610
|
+
var Vn = Object.getOwnPropertyDescriptor, qn = (t, e, n, r) => {
|
|
2611
|
+
for (var s = r > 1 ? void 0 : r ? Vn(e, n) : e, a = t.length - 1, o; a >= 0; a--)
|
|
2612
|
+
(o = t[a]) && (s = o(s) || s);
|
|
2613
|
+
return s;
|
|
2614
|
+
}, Ue = (t, e) => (n, r) => e(n, r, t), ae;
|
|
2615
|
+
let $e = (ae = class extends nt {
|
|
2616
|
+
constructor(t = {}, e, n) {
|
|
2617
|
+
super(), this._config = t, this._injector = e, this._commandService = n, this._initRegisterCommand();
|
|
2618
|
+
}
|
|
2619
|
+
onStarting() {
|
|
2620
|
+
rt(this._injector, [
|
|
2621
|
+
[_],
|
|
2622
|
+
[ue],
|
|
2623
|
+
[W],
|
|
2624
|
+
[z],
|
|
2625
|
+
[ce],
|
|
2626
|
+
[ie],
|
|
2627
|
+
[le]
|
|
2628
|
+
]), Ie(this._injector, [
|
|
2629
|
+
[ie],
|
|
2630
|
+
[le],
|
|
2631
|
+
[ue],
|
|
2632
|
+
[W],
|
|
2633
|
+
[z],
|
|
2634
|
+
[ce]
|
|
2635
|
+
]);
|
|
2636
|
+
}
|
|
2637
|
+
onReady() {
|
|
2638
|
+
Ie(this._injector, [
|
|
2639
|
+
[_]
|
|
2640
|
+
]);
|
|
2641
|
+
}
|
|
2642
|
+
_initRegisterCommand() {
|
|
2643
|
+
[
|
|
2644
|
+
Sn,
|
|
2645
|
+
te,
|
|
2646
|
+
Tn,
|
|
2647
|
+
ne,
|
|
2648
|
+
pe,
|
|
2649
|
+
vn,
|
|
2650
|
+
Mn,
|
|
2651
|
+
p,
|
|
2652
|
+
_n,
|
|
2653
|
+
In,
|
|
2654
|
+
yn,
|
|
2655
|
+
Nn,
|
|
2656
|
+
xn,
|
|
2657
|
+
On
|
|
2658
|
+
].forEach((t) => this._commandService.registerCommand(t));
|
|
2659
|
+
}
|
|
2660
|
+
}, b(ae, "pluginName", je), b(ae, "type", Ce.UNIVER_SHEET), ae);
|
|
2661
|
+
$e = qn([
|
|
2662
|
+
Ue(1, S(Ae)),
|
|
2663
|
+
Ue(2, S(x))
|
|
2664
|
+
], $e);
|
|
2665
|
+
export {
|
|
2666
|
+
Sn as AddSheetTableCommand,
|
|
2667
|
+
te as AddSheetTableMutation,
|
|
2668
|
+
_n as AddTableThemeCommand,
|
|
2669
|
+
Tn as DeleteSheetTableCommand,
|
|
2670
|
+
ne as DeleteSheetTableMutation,
|
|
2671
|
+
In as RemoveTableThemeCommand,
|
|
2672
|
+
Mn as SetSheetTableCommand,
|
|
2673
|
+
vn as SetSheetTableFilterCommand,
|
|
2674
|
+
pe as SetSheetTableFilterMutation,
|
|
2675
|
+
p as SetSheetTableMutation,
|
|
2676
|
+
Nn as SheetTableInsertColCommand,
|
|
2677
|
+
yn as SheetTableInsertRowCommand,
|
|
2678
|
+
On as SheetTableRemoveColCommand,
|
|
2679
|
+
xn as SheetTableRemoveRowCommand,
|
|
2680
|
+
z as SheetTableService,
|
|
2681
|
+
P as SheetsTableButtonStateEnum,
|
|
2682
|
+
W as SheetsTableController,
|
|
2683
|
+
G as SheetsTableSortStateEnum,
|
|
2684
|
+
ke as TableColumnDataTypeEnum,
|
|
2685
|
+
ee as TableColumnFilterTypeEnum,
|
|
2686
|
+
O as TableConditionTypeEnum,
|
|
2687
|
+
g as TableDateCompareTypeEnum,
|
|
2688
|
+
_ as TableManager,
|
|
2689
|
+
F as TableNumberCompareTypeEnum,
|
|
2690
|
+
H as TableStringCompareTypeEnum,
|
|
2691
|
+
$e as UniverSheetTablePlugin,
|
|
2692
|
+
zn as customEmptyThemeWithBorderStyle,
|
|
2693
|
+
mt as isConditionFilter,
|
|
2694
|
+
jn as isManualFilter,
|
|
2695
|
+
Kn as processStyleWithBorderStyle
|
|
2696
|
+
};
|