@guiexpert/svelte-table 0.0.1 → 1.0.3

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/index.js ADDED
@@ -0,0 +1,2201 @@
1
+ import { createEventDispatcher as re, onMount as le } from "svelte";
2
+ function O() {
3
+ }
4
+ function Z(n) {
5
+ return n();
6
+ }
7
+ function J() {
8
+ return /* @__PURE__ */ Object.create(null);
9
+ }
10
+ function P(n) {
11
+ n.forEach(Z);
12
+ }
13
+ function ee(n) {
14
+ return typeof n == "function";
15
+ }
16
+ function ne(n, e) {
17
+ return n != n ? e == e : n !== e || n && typeof n == "object" || typeof n == "function";
18
+ }
19
+ function ae(n) {
20
+ return Object.keys(n).length === 0;
21
+ }
22
+ function de(n, e, t) {
23
+ n.insertBefore(e, t || null);
24
+ }
25
+ function te(n) {
26
+ n.parentNode && n.parentNode.removeChild(n);
27
+ }
28
+ function he(n) {
29
+ return document.createElement(n);
30
+ }
31
+ function ce(n, e, t) {
32
+ t == null ? n.removeAttribute(e) : n.getAttribute(e) !== t && n.setAttribute(e, t);
33
+ }
34
+ function pe(n) {
35
+ return Array.from(n.childNodes);
36
+ }
37
+ function $(n, e, t, s) {
38
+ t == null ? n.style.removeProperty(e) : n.style.setProperty(e, t, s ? "important" : "");
39
+ }
40
+ let z;
41
+ function L(n) {
42
+ z = n;
43
+ }
44
+ const F = [], V = [];
45
+ let _ = [];
46
+ const Q = [], ue = /* @__PURE__ */ Promise.resolve();
47
+ let W = !1;
48
+ function fe() {
49
+ W || (W = !0, ue.then(se));
50
+ }
51
+ function G(n) {
52
+ _.push(n);
53
+ }
54
+ const H = /* @__PURE__ */ new Set();
55
+ let D = 0;
56
+ function se() {
57
+ if (D !== 0)
58
+ return;
59
+ const n = z;
60
+ do {
61
+ try {
62
+ for (; D < F.length; ) {
63
+ const e = F[D];
64
+ D++, L(e), ge(e.$$);
65
+ }
66
+ } catch (e) {
67
+ throw F.length = 0, D = 0, e;
68
+ }
69
+ for (L(null), F.length = 0, D = 0; V.length; )
70
+ V.pop()();
71
+ for (let e = 0; e < _.length; e += 1) {
72
+ const t = _[e];
73
+ H.has(t) || (H.add(t), t());
74
+ }
75
+ _.length = 0;
76
+ } while (F.length);
77
+ for (; Q.length; )
78
+ Q.pop()();
79
+ W = !1, H.clear(), L(n);
80
+ }
81
+ function ge(n) {
82
+ if (n.fragment !== null) {
83
+ n.update(), P(n.before_update);
84
+ const e = n.dirty;
85
+ n.dirty = [-1], n.fragment && n.fragment.p(n.ctx, e), n.after_update.forEach(G);
86
+ }
87
+ }
88
+ function Se(n) {
89
+ const e = [], t = [];
90
+ _.forEach((s) => n.indexOf(s) === -1 ? e.push(s) : t.push(s)), t.forEach((s) => s()), _ = e;
91
+ }
92
+ const me = /* @__PURE__ */ new Set();
93
+ function be(n, e) {
94
+ n && n.i && (me.delete(n), n.i(e));
95
+ }
96
+ function ye(n, e, t, s) {
97
+ const { fragment: i, after_update: o } = n.$$;
98
+ i && i.m(e, t), s || G(() => {
99
+ const r = n.$$.on_mount.map(Z).filter(ee);
100
+ n.$$.on_destroy ? n.$$.on_destroy.push(...r) : P(r), n.$$.on_mount = [];
101
+ }), o.forEach(G);
102
+ }
103
+ function we(n, e) {
104
+ const t = n.$$;
105
+ t.fragment !== null && (Se(t.after_update), P(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
106
+ }
107
+ function xe(n, e) {
108
+ n.$$.dirty[0] === -1 && (F.push(n), fe(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
109
+ }
110
+ function ve(n, e, t, s, i, o, r, a = [-1]) {
111
+ const l = z;
112
+ L(n);
113
+ const d = n.$$ = {
114
+ fragment: null,
115
+ ctx: [],
116
+ // state
117
+ props: o,
118
+ update: O,
119
+ not_equal: i,
120
+ bound: J(),
121
+ // lifecycle
122
+ on_mount: [],
123
+ on_destroy: [],
124
+ on_disconnect: [],
125
+ before_update: [],
126
+ after_update: [],
127
+ context: new Map(e.context || (l ? l.$$.context : [])),
128
+ // everything else
129
+ callbacks: J(),
130
+ dirty: a,
131
+ skip_bound: !1,
132
+ root: e.target || l.$$.root
133
+ };
134
+ r && r(d.root);
135
+ let h = !1;
136
+ if (d.ctx = t ? t(n, e.props || {}, (p, g, ...S) => {
137
+ const c = S.length ? S[0] : g;
138
+ return d.ctx && i(d.ctx[p], d.ctx[p] = c) && (!d.skip_bound && d.bound[p] && d.bound[p](c), h && xe(n, p)), g;
139
+ }) : [], d.update(), h = !0, P(d.before_update), d.fragment = s ? s(d.ctx) : !1, e.target) {
140
+ if (e.hydrate) {
141
+ const p = pe(e.target);
142
+ d.fragment && d.fragment.l(p), p.forEach(te);
143
+ } else
144
+ d.fragment && d.fragment.c();
145
+ e.intro && be(n.$$.fragment), ye(n, e.target, e.anchor, e.customElement), se();
146
+ }
147
+ L(l);
148
+ }
149
+ class Ce {
150
+ $destroy() {
151
+ we(this, 1), this.$destroy = O;
152
+ }
153
+ $on(e, t) {
154
+ if (!ee(t))
155
+ return O;
156
+ const s = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
157
+ return s.push(t), () => {
158
+ const i = s.indexOf(t);
159
+ i !== -1 && s.splice(i, 1);
160
+ };
161
+ }
162
+ $set(e) {
163
+ this.$$set && !ae(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
164
+ }
165
+ }
166
+ class X {
167
+ constructor(e = -1, t = -1, s = -1, i = -1, o, r, a, l = 0, d = 0, h = 0, p = "") {
168
+ this.rowIndex = e, this.rowTop = t, this.columnIndex = s, this.columnLeft = i, this.areaIdent = o, this.sideIdent = r, this.originalEvent = a, this.clickCount = l, this.draggingX = d, this.draggingY = h, this.action = p;
169
+ }
170
+ clone() {
171
+ return new X(
172
+ this.rowIndex,
173
+ this.rowTop,
174
+ this.columnIndex,
175
+ this.columnLeft,
176
+ this.areaIdent,
177
+ this.sideIdent,
178
+ this.originalEvent,
179
+ this.clickCount,
180
+ this.draggingX,
181
+ this.draggingY,
182
+ this.action
183
+ );
184
+ }
185
+ }
186
+ class I {
187
+ constructor(e = ">", t = "", s = []) {
188
+ this.content = e, this.style = t, this.classes = s;
189
+ }
190
+ }
191
+ class ie {
192
+ constructor(e = new I(
193
+ ">",
194
+ "transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",
195
+ ["gt-table-tree-arrow-expanded"]
196
+ ), t = new I(
197
+ ">",
198
+ "",
199
+ ["ge-table-tree-arrow-collapsed"]
200
+ ), s = new I(
201
+ ">",
202
+ "color:transparent;",
203
+ ["gt-table-tree-arrow-hidden"]
204
+ ), i = new I(
205
+ "↕",
206
+ "",
207
+ ["gt-table-tree-arrow-expanded-all"]
208
+ )) {
209
+ this.arrowExpanded = e, this.arrowCollapsed = t, this.arrowPlaceholder = s, this.arrowExpandCollapseAll = i;
210
+ }
211
+ }
212
+ class oe {
213
+ constructor(e = new I("↑", "", ["ge-header-sorted-asc"]), t = new I("↓", "", ["ge-header-sorted-desc"]), s = new I("↑", "color:transparent;", [])) {
214
+ this.iconAsc = e, this.iconDesc = t, this.iconPlaceholder = s;
215
+ }
216
+ }
217
+ class Ee {
218
+ constructor(e) {
219
+ this.domService = e;
220
+ }
221
+ setStyle(e, t, s) {
222
+ return this.domService.setStyle(e, t, s), e;
223
+ }
224
+ applyStyle(e, t) {
225
+ for (const s in t)
226
+ this.domService.setStyle(e, s, t[s]);
227
+ return e;
228
+ }
229
+ applyDisplayNoneStyle(e) {
230
+ return this.domService.setStyle(e, "display", "none"), e;
231
+ }
232
+ applyDisplayBlockStyle(e) {
233
+ return this.domService.setStyle(e, "display", "block"), e;
234
+ }
235
+ applyStyleInPx(e, t) {
236
+ return Object.entries(t).forEach(([s, i]) => this.domService.setStyle(e, s, i + "px")), e;
237
+ }
238
+ applyStylePosistionRelative(e) {
239
+ return this.domService.setStyle(e, "position", "relative"), this.domService.setStyle(e, "overflow", "clip"), e;
240
+ }
241
+ applyStylePosistionAbsolute(e) {
242
+ return this.domService.setStyle(e, "position", "absolute"), e;
243
+ }
244
+ applyStyleFullSize(e) {
245
+ return this.domService.setStyle(e, "width", "100%"), this.domService.setStyle(e, "height", "100%"), e;
246
+ }
247
+ applyStyleOverflowAuto(e = "auto", t = "auto", s) {
248
+ return this.domService.setStyle(s, "overflow-x", e), this.domService.setStyle(s, "overflow-y", t), s;
249
+ }
250
+ applyStyleNoPadding(e) {
251
+ return this.domService.setStyle(e, "padding", "0"), this.domService.setStyle(e, "margin", "0"), this.domService.setStyle(e, "border", "0"), e;
252
+ }
253
+ appendRelativeChildDiv(e) {
254
+ const t = this.applyStylePosistionRelative(
255
+ this.applyStyleFullSize(
256
+ this.applyStyleNoPadding(
257
+ this.domService.createElement("div")
258
+ )
259
+ )
260
+ );
261
+ return this.domService.appendChild(e, t), this.applyStylePosistionAbsolute(e), { parent: e, child: t, cache: {} };
262
+ }
263
+ appendText(e, t) {
264
+ const s = this.domService.createText(t);
265
+ return this.domService.appendChild(e, s), s;
266
+ }
267
+ addClass(e, t) {
268
+ return e.includes(" ") ? e.split(" ").forEach((s) => this.domService.addClass(t, s)) : this.domService.addClass(t, e), t;
269
+ }
270
+ addClasses(e, t) {
271
+ if (e)
272
+ for (const s of e)
273
+ this.domService.addClass(t, s);
274
+ return t;
275
+ }
276
+ setAttribute(e, t, s) {
277
+ return t && s && this.domService.setAttribute(e, t, s), e;
278
+ }
279
+ createAreaDivWithClass(e, t, s, i) {
280
+ const o = this.domService.createElement("div");
281
+ return this.addClass(e, o), this.domService.setAttribute(o, "data-area", s), this.domService.setAttribute(o, "data-side", i), this.domService.appendChild(t, o), o;
282
+ }
283
+ createDivWithClass(e, t) {
284
+ const s = this.domService.createElement("div");
285
+ return this.addClass(e, s), this.domService.appendChild(t, s), s;
286
+ }
287
+ addRowDiv(e, t, s = -1, i, o, r = "") {
288
+ const a = t.index ?? -1, l = this.getDivOrCreateDiv(a, e);
289
+ if (this.domService.addClass(l, "ge-table-row-div"), this.domService.addClass(l, `ge-table-row-div-${t.index}`), i === "body" && o === "center") {
290
+ const d = ((t == null ? void 0 : t.index) ?? 0) % 2 === 0 ? "even" : "odd";
291
+ this.domService.addClass(l, `ge-table-row-${d}`);
292
+ }
293
+ if (this.domService.setStyle(l, "display", "clip"), this.domService.setStyle(l, "position", "absolute"), this.domService.setStyle(l, "left", `${t.left}px`), this.domService.setStyle(l, "top", `${t.top}px`), this.domService.setStyle(l, "width", `${t.width}px`), this.domService.setStyle(l, "height", `${t.height}px`), this.domService.setAttribute(l, "data-row-index", `${s}`), this.domService.setAttribute(l, "data-area", `${i}`), r) {
294
+ const d = this.domService.createText(r);
295
+ this.domService.appendChild(l, d);
296
+ }
297
+ return this.domService.appendChild(e.child, l), l;
298
+ }
299
+ addColumnDiv(e, t, s = -1, i = -1, o, r, a = "", l, d, h = void 0, p) {
300
+ const g = d == null ? void 0 : d.treeOptions, S = d == null ? void 0 : d.showCheckboxWihoutExtraColumn, c = this.domService.createElement("div");
301
+ this.domService.addClass(c, "ge-table-col-div"), this.domService.addClass(c, `ge-table-col-div-${t.index}`), this.domService.setAttribute(c, "data-col-index", `${t.index}`), this.domService.setAttribute(c, "data-row-index", `${s}`), this.domService.setAttribute(c, "data-area", `${o}`);
302
+ const b = ((t == null ? void 0 : t.index) ?? 0) % 2 === 0 ? "even" : "odd";
303
+ if (o === "body" && r === "center" && this.domService.addClass(c, `ge-table-column-${b}`), this.domService.setStyle(c, "display", "clip"), this.domService.setStyle(c, "position", "absolute"), this.domService.setStyle(c, "left", `${t.left}px`), this.domService.setStyle(c, "top", `${t.top}px`), this.domService.setStyle(c, "width", `${t.width}px`), this.domService.setStyle(c, "height", `${t.height}px`), l && l !== "none" && (this.domService.addClass(c, "ge-table-col-tree"), this.addArrowDiv(c, l, g, s, i, o)), S && i === 0 && h && this.addCheckboxToDiv(c, h, o, s), a) {
304
+ const u = l !== "none" && i === 0;
305
+ this.addLabelDiv(c, a, u, s, i, o);
306
+ }
307
+ return p && this.addSortedIcon(c, p, d == null ? void 0 : d.sortedOptions, i), this.domService.appendChild(e, c), c;
308
+ }
309
+ addCheckboxToDiv(e, t, s, i) {
310
+ const o = this.domService.createElement("div"), r = t === "full" ? "checked" : "";
311
+ return o.innerHTML = `
312
+ <input
313
+ type="checkbox"
314
+ data-area="${s}"
315
+ data-row-index="${i}"
316
+ data-input-type="checkbox"
317
+ ${r}
318
+ class="ge-table-row-checkbox"> `, this.domService.setStyle(o, "display", "inline"), this.domService.setStyle(o, "width", "inherit"), this.domService.setAttribute(o, "data-row-index", `${i}`), this.domService.appendChild(e, o), o;
319
+ }
320
+ addLabelDiv(e, t = "", s = !1, i = -1, o = -1, r = "body") {
321
+ const a = this.domService.createElement("div");
322
+ if (this.domService.addClass(a, "ge-table-label-div"), this.domService.setStyle(a, "position", "relative"), this.domService.setStyle(a, "background", "transparent"), this.domService.setStyle(a, "width", "100%"), this.domService.setStyle(a, "height", "100%"), this.domService.setAttribute(a, "data-row-index", `${i}`), this.domService.setAttribute(a, "data-col-index", `${o}`), this.domService.setAttribute(a, "data-area", `${r}`), t)
323
+ if (s) {
324
+ const l = this.domService.createText(t);
325
+ this.domService.appendChild(a, l);
326
+ } else {
327
+ const l = this.domService.createElement("div");
328
+ this.domService.appendChild(a, l);
329
+ const d = this.domService.createText(t);
330
+ this.domService.addClass(l, "ge-table-label"), this.domService.appendChild(l, d), this.domService.setAttribute(l, "data-row-index", `${i}`), this.domService.setAttribute(l, "data-col-index", `${o}`), this.domService.setAttribute(l, "data-area", `${r}`);
331
+ }
332
+ return this.domService.appendChild(e, a), a;
333
+ }
334
+ addSortedIcon(e, t = "", s = new oe(), i = -1) {
335
+ const o = this.domService.createElement("div");
336
+ this.domService.addClass(o, "ge-table-sorted-icon-div"), this.domService.setStyle(o, "position", "absolute"), this.domService.setStyle(o, "top", "0"), this.domService.setStyle(o, "right", "0"), this.domService.setStyle(o, "width", "20px"), this.domService.setStyle(o, "background", "transparent"), this.domService.setStyle(o, "cursor", "pointer"), this.domService.setAttribute(o, "data-col-index", `${i}`), this.domService.setAttribute(o, "data-area", "header");
337
+ let r;
338
+ t === "asc" ? r = s.iconAsc : t === "desc" ? r = s.iconDesc : r = s.iconPlaceholder;
339
+ const a = r.content, l = this.domService.createText(a);
340
+ this.domService.appendChild(o, l), r.style && this.applyStyleString(o, r.style);
341
+ for (const d of r.classes)
342
+ this.domService.addClass(o, d);
343
+ return this.domService.appendChild(e, o), o;
344
+ }
345
+ addArrowDiv(e, t = "none", s = new ie(), i = -1, o = -1, r = "body") {
346
+ const a = this.domService.createElement("div");
347
+ this.domService.addClass(a, "ge-table-tree-arrow-div"), this.domService.setStyle(a, "display", "inline-block"), this.domService.setStyle(a, "position", ""), this.domService.setStyle(a, "width", "20px"), this.domService.setStyle(a, "background", "transparent"), this.domService.setStyle(a, "cursor", "pointer"), this.domService.setAttribute(a, "data-row-index", `${i}`), this.domService.setAttribute(a, "data-col-index", `${o}`), this.domService.setAttribute(a, "data-area", `${r}`);
348
+ let l;
349
+ t === "expanded" ? l = s.arrowExpanded : t === "collapsed" ? l = s.arrowCollapsed : l = s.arrowPlaceholder;
350
+ const d = l.content, h = this.domService.createText(d);
351
+ this.domService.appendChild(a, h), l.style && this.applyStyleString(a, l.style);
352
+ for (const p of l.classes)
353
+ this.domService.addClass(a, p);
354
+ return this.domService.appendChild(e, a), a;
355
+ }
356
+ addColumnBorderDivs(e, t, s, i, o) {
357
+ if (e.verticalBorderVisible) {
358
+ const r = `ge-table-${i}-${o}-vertical-border`;
359
+ this.addVerticalBorder(s, t, r);
360
+ }
361
+ if (e.horizontalBorderVisible) {
362
+ const r = `ge-table-${i}-${o}-horizontal-border`;
363
+ this.addHorizontalBorder(s, t, r);
364
+ }
365
+ return t;
366
+ }
367
+ addHorizontalBorder(e, t, s = "ge-table-body-center-horizontal-border") {
368
+ const i = this.domService.createElement("div");
369
+ return this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${e.left}px`), this.domService.setStyle(i, "top", `${e.top}px`), this.domService.setStyle(i, "width", `${e.width}px`), this.domService.setStyle(i, "height", "1px"), this.domService.appendChild(t, i), i;
370
+ }
371
+ addFocusBorderDivs(e, t, s) {
372
+ let i = this.domService.createElement("div");
373
+ return this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${t.height}px`), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left + t.width - 1}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${t.height}px`), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", "1px"), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top + t.height - 1}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", "1px"), this.applyStyle(i, s), this.domService.appendChild(e, i), e;
374
+ }
375
+ addVerticalBorder(e, t, s = "ge-table-body-center-vertical-border") {
376
+ const i = this.domService.createElement("div");
377
+ return this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${e.left}px`), this.domService.setStyle(i, "top", `${e.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${e.height}px`), this.domService.appendChild(t, i), i;
378
+ }
379
+ addDiv(e, t, s = "") {
380
+ const i = this.domService.createElement("div");
381
+ return s && this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", `${t.height}px`), this.domService.appendChild(e, i), i;
382
+ }
383
+ applyStyleString(e, t) {
384
+ const s = t.split(";").map((i) => i.trim()).filter((i) => i);
385
+ for (const i of s) {
386
+ const [o, r] = i.split(":");
387
+ this.domService.setStyle(e, o.trim(), r.trim());
388
+ }
389
+ }
390
+ getDivOrCreateDiv(e, t) {
391
+ let s = t.cache[e];
392
+ return s ? (s.innerText = "", s) : (s = this.domService.createElement("div"), t.cache[e] = s, s);
393
+ }
394
+ }
395
+ class N {
396
+ constructor(e, t = !0, s, i, o = 0, r = !1, a = !1) {
397
+ this.data = e, this.expanded = t, this.children = s, this.parent = i, this.deep = o, this.checked = r, this.keep = a;
398
+ }
399
+ }
400
+ const K = (n) => n === "header" ? "header" : n === "footer" ? "footer" : "body";
401
+ class Ae {
402
+ constructor(e, t) {
403
+ if (this.rowIdx = -1, this.colIdx = -1, this.action = null, this.inputType = null, this.className = "", e !== null && (e instanceof HTMLDivElement || e instanceof HTMLSpanElement || e instanceof HTMLInputElement)) {
404
+ this.className = e.className, this.action = e.getAttribute("data-ge-action"), this.inputType = e.getAttribute("data-input-type"), this.rowIdx = Number(e.getAttribute("data-row-index")), this.colIdx = Number(e.getAttribute("data-col-index"));
405
+ const s = e.getAttribute("data-area");
406
+ if (s && (this.areaIdent = K(s), this.areaModel = t.tableModel.getAreaModel(this.areaIdent), this.row = this.areaModel.getRowByIndex(this.rowIdx)), e instanceof HTMLInputElement) {
407
+ const i = e;
408
+ this.value = i.value;
409
+ }
410
+ }
411
+ }
412
+ }
413
+ class Re {
414
+ constructor(e) {
415
+ this.tableScope = e, this.expandedAll = !0, this.mouseDown = !1, this.dragging = !1, this.tableScope.hostElement.addEventListener("click", this.onHostElementClicked.bind(this)), this.tableScope.hostElement.addEventListener("dblclick", this.onHostElementDblClicked.bind(this)), this.tableScope.hostElement.addEventListener("mousedown", this.onMouseDown.bind(this)), this.tableScope.hostElement.addEventListener("mousemove", this.onMouseMove.bind(this)), this.tableScope.hostElement.addEventListener("mouseup", this.onMouseUp.bind(this)), this.tableScope.hostElement.addEventListener("contextmenu", this.onContextmenu.bind(this)), this.tableScope.hostElement._MouseHandler = "true", this.tableScope.scrollViewport.addEventListener("scroll", this.tableScope.adjustAfterScrolling.bind(this.tableScope)), [window, this.tableScope.hostElement].forEach(
416
+ (t) => t.addEventListener("resize", this.tableScope.adjustContainersAndRows.bind(this.tableScope))
417
+ );
418
+ }
419
+ onContextmenu(e) {
420
+ this.mouseEvent = e;
421
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
422
+ this.tableScope.contextmenu(t);
423
+ }
424
+ onHostElementClicked(e) {
425
+ const t = new Ae(e.target, this.tableScope);
426
+ if (t.action === "toggleExpandCollapseAll")
427
+ this.expandedAll = !this.expandedAll, this.tableScope.toggleExpandCollapseAll(this.expandedAll), e.preventDefault(), e.stopPropagation();
428
+ else if (t.inputType === "checkbox" && t.areaIdent)
429
+ this.tableScope.toggleRowCheckbox(t.rowIdx, t.colIdx, t.areaIdent), e.preventDefault(), e.stopPropagation();
430
+ else if (t.row instanceof N && t.areaModel) {
431
+ const s = t.colIdx === this.getArrowColumnIndex() && e.altKey, i = t.className.includes("ge-table-tree-arrow-div");
432
+ if (console.info(i, s), s || i) {
433
+ e.preventDefault(), e.stopPropagation();
434
+ const o = t.row;
435
+ o.expanded = !o.expanded, "recalcVisibleTreeRows" in t.areaModel && t.areaModel.recalcVisibleTreeRows(), this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth), this.tableScope.adjustContainersAndRows(), this.updateCollapsedExpandedState(o);
436
+ }
437
+ }
438
+ if (t.areaIdent === "body" && this.tableScope.tableOptions.getFocusModel) {
439
+ const s = this.tableScope.tableOptions.getFocusModel();
440
+ s == null || s.clear(), s == null || s.setFocus(t.rowIdx, t.colIdx);
441
+ }
442
+ this.publishGeMouseEvent(e, 1);
443
+ }
444
+ onHostElementDblClicked(e) {
445
+ if (e.target instanceof HTMLElement) {
446
+ const t = e.target, s = t.getAttribute("data-area"), i = K(s), o = Number(t.getAttribute("data-row-index")), r = Number(t.getAttribute("data-col-index")), a = this.tableScope.tableModel.getAreaModel(i);
447
+ if (s && i === "header")
448
+ this.tableScope.tableModel.isSortable(r) && (this.tableScope.clearSelection(), this.tableScope.onHeaderDblClicked(e, o, r));
449
+ else if (t.getAttribute("data-row-index")) {
450
+ const l = a.getRowByIndex(o);
451
+ if (s && i === "body" && a.isEditable(o, r) && (this.tableScope.clearSelection(), this.tableScope.initRenderEditor(o, r)), l instanceof N && r === this.getArrowColumnIndex()) {
452
+ e.preventDefault(), e.stopPropagation();
453
+ const d = l;
454
+ d.expanded = !d.expanded, "recalcVisibleTreeRows" in a && a.recalcVisibleTreeRows(), this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth), this.tableScope.adjustContainersAndRows(), this.updateCollapsedExpandedState(d);
455
+ }
456
+ }
457
+ }
458
+ this.publishGeMouseEvent(e, 2);
459
+ }
460
+ publishGeMouseEvent(e, t) {
461
+ var s;
462
+ this.mouseEvent = e, this.geMouseEventOld = (s = this.geMouseEvent) == null ? void 0 : s.clone(), this.geMouseEvent = this.tableScope.createGeMouseEvent(e), this.geMouseEvent && (this.geMouseEvent.clickCount = t), this.tableScope.onMouseClicked(this.geMouseEvent, this.geMouseEventOld);
463
+ }
464
+ updateCollapsedExpandedState(e) {
465
+ var s, i, o, r, a;
466
+ const t = (i = (s = this.tableScope.tableOptions) == null ? void 0 : s.autoRestoreOptions) == null ? void 0 : i.getRowId;
467
+ if (t) {
468
+ const l = (o = this.tableScope.storeStateCollapsedExpandService) == null ? void 0 : o.collapsedExpandedStateGet().mode, d = l === "collapsed" && !e.expanded || l === "expanded" && e.expanded, h = l === "collapsed" && e.expanded || l === "expanded" && !e.expanded, p = t(e.data);
469
+ d ? (r = this.tableScope.storeStateCollapsedExpandService) == null || r.collapsedStateIdsPush(p) : h && ((a = this.tableScope.storeStateCollapsedExpandService) == null || a.collapsedStateIdsRemove(p));
470
+ }
471
+ }
472
+ getArrowColumnIndex() {
473
+ return this.tableScope.tableModel.isRowCheckboxVisible() ? 1 : 0;
474
+ }
475
+ onMouseDown(e) {
476
+ this.mouseEvent = e, this.startMouseEvent = this.tableScope.createGeMouseEvent(this.mouseEvent), this.tableScope.onMouseDown(this.startMouseEvent), this.mouseDown = !0;
477
+ }
478
+ onMouseMove(e) {
479
+ this.mouseEvent = e, this.mouseDown ? (this.dragging = !0, requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))) : requestAnimationFrame(this.mouseMoveOnFrame.bind(this));
480
+ }
481
+ onMouseUp(e) {
482
+ this.mouseEvent = e, this.dragging && requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)), this.mouseDown = !1, this.dragging = !1;
483
+ }
484
+ mouseDraggingOnFrame() {
485
+ var e;
486
+ if (this.mouseEvent) {
487
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
488
+ (e = this.startMouseEvent) != null && e.originalEvent && (t.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX, t.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY), this.tableScope.mouseDraggingOnFrame(t);
489
+ }
490
+ }
491
+ mouseDraggingEndOnFrame() {
492
+ var e;
493
+ if (this.mouseEvent) {
494
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
495
+ (e = this.startMouseEvent) != null && e.originalEvent && (t.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX, t.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY), this.tableScope.mouseDraggingEndOnFrame(t);
496
+ }
497
+ }
498
+ mouseMoveOnFrame() {
499
+ if (this.mouseEvent) {
500
+ const e = this.tableScope.createGeMouseEvent(this.mouseEvent);
501
+ this.tableScope.mouseMove(e);
502
+ }
503
+ }
504
+ }
505
+ class Me {
506
+ constructor(e) {
507
+ this.tableScope = e;
508
+ }
509
+ updateCells(e) {
510
+ this.tableScope.updateCells(e);
511
+ }
512
+ externalFilterChanged() {
513
+ this.tableScope.externalFilterChanged();
514
+ }
515
+ scrollToPixel(e = 0, t = 0) {
516
+ }
517
+ scrollToIndex(e = 0, t = 0) {
518
+ }
519
+ setHeaderVisible(e = !0) {
520
+ }
521
+ setColumnVisible(e, t = !0) {
522
+ }
523
+ isColumnVisible(e) {
524
+ return !0;
525
+ }
526
+ isHeaderVisible() {
527
+ return !0;
528
+ }
529
+ setFooterVisible(e = !0) {
530
+ }
531
+ isFooterVisible() {
532
+ return !0;
533
+ }
534
+ repaint() {
535
+ this.tableScope.repaint();
536
+ }
537
+ }
538
+ class Te {
539
+ flattenTree(e, t = []) {
540
+ var s;
541
+ for (const i of e)
542
+ this.isVisible(i) && t.push(i), (s = i.children) != null && s.length && this.flattenTree(i.children, t);
543
+ return t;
544
+ }
545
+ isVisible(e) {
546
+ return e.parent ? e.parent.expanded ? this.isVisible(e.parent) : !1 : !0;
547
+ }
548
+ }
549
+ class Ie {
550
+ constructor(e, t = [], s = -1) {
551
+ this.areaIdent = e, this.columnDefs = t, this.defaultRowHeight = s, this.rowSelectionModel = void 0, this.yPositions = [], this.cellRenderers = t.map((i) => i.rendererMap[e]);
552
+ }
553
+ getTooltipAt(e, t) {
554
+ return "";
555
+ }
556
+ getCellRenderer(e, t) {
557
+ if (t < this.cellRenderers.length)
558
+ return this.cellRenderers[t];
559
+ }
560
+ getColspanAt(e, t) {
561
+ return 0;
562
+ }
563
+ getCustomClassesAt(e, t) {
564
+ return [];
565
+ }
566
+ getCustomStyleAt(e, t) {
567
+ }
568
+ getRowspanAt(e, t) {
569
+ return 0;
570
+ }
571
+ getRowByIndex(e) {
572
+ }
573
+ isRowCheckable(e) {
574
+ return !0;
575
+ }
576
+ isRowChecked(e) {
577
+ var s;
578
+ const t = this.getRowByIndex(e);
579
+ return (s = this.rowSelectionModel) == null ? void 0 : s.isRowChecked(t);
580
+ }
581
+ setRowChecked(e, t) {
582
+ if (this.rowSelectionModel) {
583
+ const s = this.getRowByIndex(e);
584
+ this.rowSelectionModel.checkRow(s, t);
585
+ }
586
+ }
587
+ getMaxColspan() {
588
+ return 31;
589
+ }
590
+ getMaxRowspan() {
591
+ return 31;
592
+ }
593
+ getYPosByRowIndex(e) {
594
+ return this.defaultRowHeight > 0 ? this.defaultRowHeight * e : this.yPositions[e];
595
+ }
596
+ init() {
597
+ !this.yPositions.length && this.getRowCount() !== void 0 && this.defaultRowHeight === -1 && this.calcYPositions();
598
+ }
599
+ isFilterable() {
600
+ return this.areaIdent === "body";
601
+ }
602
+ doSort(e) {
603
+ return !1;
604
+ }
605
+ isEditable(e, t) {
606
+ return this.columnDefs && t < this.columnDefs.length && this.columnDefs[t].editable ? this.columnDefs[t].editable() : !1;
607
+ }
608
+ setValue(e, t, s) {
609
+ var a;
610
+ const i = (a = this.columnDefs[t]) == null ? void 0 : a.editInputPipe;
611
+ i && (s = i(s, e, t));
612
+ const o = this.getRowByIndex(e), r = this.columnDefs[t].property;
613
+ return r.includes(".") ? this.setPropertyValue(o, r.split("."), s) : (o[r] = s, !0);
614
+ }
615
+ isSelectable(e, t) {
616
+ return !0;
617
+ }
618
+ changeColumnOrder(e, t) {
619
+ this.arrayMove(this.cellRenderers, e, t);
620
+ }
621
+ setPropertyValue(e, t, s) {
622
+ const i = t.shift();
623
+ if (i) {
624
+ let o = e[i];
625
+ return o && t.length ? this.setPropertyValue(o, t, s) : (e[i] = s, !0);
626
+ }
627
+ return !1;
628
+ }
629
+ arrayMove(e, t, s) {
630
+ const i = e.splice(t, 1)[0];
631
+ return e.splice(s, 0, i), e;
632
+ }
633
+ calcYPositions() {
634
+ const e = this.getRowCount();
635
+ this.yPositions = new Array(e + 1), this.yPositions[0] = 0;
636
+ for (let t = 0; t < e; t++)
637
+ this.yPositions[t + 1] = this.getRowHeight(t) + this.yPositions[t];
638
+ }
639
+ }
640
+ class De {
641
+ genericSortComparator(e, t, s) {
642
+ if (typeof e == "number" && typeof t == "number")
643
+ return s * (e - t);
644
+ if (typeof e == "string" && typeof t == "string")
645
+ return s * e.localeCompare(t);
646
+ if (typeof e == "boolean" && typeof t == "boolean")
647
+ return s * ((e ? -1 : 1) - (t ? -1 : 1));
648
+ if (e instanceof Date && t instanceof Date)
649
+ return s * (e.getTime() - t.getTime());
650
+ if (e instanceof Array && t instanceof Array) {
651
+ const i = e, o = t;
652
+ if (i.length && o.length)
653
+ return this.genericSortComparator(i[0], o[0], s);
654
+ }
655
+ return s * ("" + e).localeCompare("" + t);
656
+ }
657
+ }
658
+ class j extends Ie {
659
+ constructor(e, t, s, i = []) {
660
+ super(e, i, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = i, this.sorterService = new De(), this.service = new Te(), this.properties = i.map((o) => o.property), this.flattenRows = this.service.flattenTree(t), this.filteredFlattenRows = [...this.flattenRows];
661
+ }
662
+ changeColumnOrder(e, t) {
663
+ this.arrayMove(this.properties, e, t), super.changeColumnOrder(e, t);
664
+ }
665
+ recalcVisibleTreeRows() {
666
+ this.filteredFlattenRows = this.service.flattenTree(this.rows);
667
+ }
668
+ getFilteredFlattenRows() {
669
+ return this.filteredFlattenRows;
670
+ }
671
+ getRowCount() {
672
+ let e = 0;
673
+ for (const t of this.filteredFlattenRows)
674
+ this.service.isVisible(t) && e++;
675
+ return e;
676
+ }
677
+ getValueAt(e, t) {
678
+ const s = this.getRowByIndex(e);
679
+ if (s) {
680
+ const i = this.properties[t];
681
+ if (i)
682
+ return i.includes(".") ? this.getPropertyValue(s.data, i.split(".")) : s.data[i];
683
+ }
684
+ return "";
685
+ }
686
+ getRowHeight(e) {
687
+ return this.defaultRowHeight;
688
+ }
689
+ getCustomClassesAt(e, t) {
690
+ return ["ge-table-tree-cell", "ge-table-tree-deep-" + this.filteredFlattenRows[e].deep];
691
+ }
692
+ getRowByIndex(e) {
693
+ return this.filteredFlattenRows[e];
694
+ }
695
+ getValueByT(e, t) {
696
+ return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
697
+ }
698
+ externalFilterChanged(e) {
699
+ this.lastPredictFn = e, this.doFiltering();
700
+ }
701
+ doSort(e) {
702
+ const { columnIndex: t, sortState: s } = e[e.length - 1], i = s === "asc" ? 1 : s === "desc" ? -1 : 0, o = this.properties[t];
703
+ return this.treeSort(this.rows, o, i), this.flattenRows = this.service.flattenTree(this.rows), this.filteredFlattenRows = [...this.flattenRows], !0;
704
+ }
705
+ toggleExpandCollapseAll(e) {
706
+ this.expandAllRecursive(this.rows, e), this.flattenRows = this.service.flattenTree(this.rows), this.doFiltering();
707
+ }
708
+ setAllParentsOk(e) {
709
+ return e.parent && (e.parent.keep = !0, this.setAllParentsOk(e.parent)), !1;
710
+ }
711
+ setValue(e, t, s) {
712
+ var r;
713
+ const i = (r = this.columnDefs[t]) == null ? void 0 : r.editInputPipe;
714
+ i && (s = i(s, e, t));
715
+ const o = this.getRowByIndex(e);
716
+ if (o) {
717
+ const a = o.data, l = this.columnDefs[t].property;
718
+ return l.includes(".") ? this.setPropertyValue(a, l.split("."), s) : (a[l] = s, !0);
719
+ }
720
+ return !1;
721
+ }
722
+ genericTreeTableSortComparator(e, t) {
723
+ return (s, i) => {
724
+ const o = this.getValueByT(s.data, e), r = this.getValueByT(i.data, e);
725
+ return this.sorterService.genericSortComparator(o, r, t);
726
+ };
727
+ }
728
+ expandAllRecursive(e, t) {
729
+ for (const s of e)
730
+ s.expanded = t, s.children && this.expandAllRecursive(s.children, t);
731
+ }
732
+ doFiltering() {
733
+ if (!this.lastPredictFn)
734
+ this.filteredFlattenRows = [...this.flattenRows ? this.flattenRows : []];
735
+ else {
736
+ this.flattenRows || (this.flattenRows = []);
737
+ let e = 0;
738
+ this.flattenRows.forEach((s) => {
739
+ e = Math.max(e, s.deep);
740
+ });
741
+ const t = this.flattenRows.filter(
742
+ (s, i, o) => this.lastPredictFn(s, i, o)
743
+ );
744
+ this.flattenRows.forEach((s) => s.keep = !1), this.flattenRows.forEach((s) => {
745
+ t.includes(s) && (s.keep = !0, this.setAllParentsOk(s));
746
+ }), this.filteredFlattenRows = this.flattenRows.filter(
747
+ (s, i, o) => s.keep
748
+ );
749
+ }
750
+ }
751
+ getPropertyValue(e, t) {
752
+ const s = t.shift();
753
+ let i = e[s];
754
+ return i && t.length ? this.getPropertyValue(i, t) : i;
755
+ }
756
+ treeSort(e, t, s) {
757
+ e.sort(this.genericTreeTableSortComparator(t, s));
758
+ for (const i of e)
759
+ i.children && this.treeSort(i.children, t, s);
760
+ }
761
+ }
762
+ class Y {
763
+ constructor(e) {
764
+ this.getStorageKeyFn = e;
765
+ }
766
+ autoConvertMapToObject(e) {
767
+ const t = {};
768
+ if (e instanceof Map) {
769
+ const s = e;
770
+ for (const i of [...s]) {
771
+ const [
772
+ o,
773
+ r
774
+ ] = i;
775
+ t[o] = r;
776
+ }
777
+ }
778
+ return t;
779
+ }
780
+ checkAndPersistItem(e, t) {
781
+ const s = this.getStorageKeyFn;
782
+ if (s) {
783
+ const i = s();
784
+ if (i) {
785
+ const o = i + e;
786
+ if ((t + "").includes("Map")) {
787
+ const r = this.autoConvertMapToObject(t);
788
+ this.persistItem(o, r);
789
+ } else
790
+ this.persistItem(o, t);
791
+ }
792
+ }
793
+ }
794
+ persistItem(e, t) {
795
+ t ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
796
+ }
797
+ loadFromLocalStorage(e) {
798
+ const t = localStorage.getItem(e);
799
+ return t ? JSON.parse(t) : null;
800
+ }
801
+ // private loadItems() {
802
+ // const fn = this.getStorageKeyFn;
803
+ // if (fn) {
804
+ // const key = fn();
805
+ // if (key) {
806
+ // // A main key is given by function from options
807
+ // const subKey = key + this.CHECKED_STATE;
808
+ // const arr = this.loadFromLocalStorage<Array<string | number>>(subKey);
809
+ // if (arr) {
810
+ // this.checkedStateIds.length = 0;
811
+ // arr.forEach(a => this.checkedStateIds.push(a));
812
+ // }
813
+ //
814
+ // const subKey2 = key + this.COLLAPSED_EXPANDED_STATE;
815
+ // const data = this.loadFromLocalStorage<CollapsedExpandedData>(subKey2);
816
+ // if (data) {
817
+ // this.collapsedExpandedState = data;
818
+ // }
819
+ //
820
+ // const subKey3 = key + this.SELECTED_STATE;
821
+ // const arr3 = this.loadFromLocalStorage<object>(subKey3);
822
+ // if (arr3) {
823
+ // const map: Map<string | number, string[]> = new Map(Object.entries(arr3));
824
+ // if (map) {
825
+ // this.selectedStateIds.clear();
826
+ // map.forEach((col, k) => this.selectedStateIds.set(k, col));
827
+ // }
828
+ // }
829
+ //
830
+ // const subKey4 = key + this.SCROLL_STATE;
831
+ // let scrollOffset = this.loadFromLocalStorage<[number, number]>(subKey4);
832
+ // this.scrollOffset = scrollOffset ? scrollOffset : [0, 0];
833
+ // }
834
+ // }
835
+ // }
836
+ }
837
+ class Fe extends Y {
838
+ constructor(e) {
839
+ super(e), this.SCROLL_STATE = "scrollState", this.scrollOffset = [0, 0], this.load();
840
+ }
841
+ getScrollOffset() {
842
+ return this.scrollOffset;
843
+ }
844
+ updateScrollOffset(e) {
845
+ this.scrollOffset = e, this.checkAndPersistItem(this.SCROLL_STATE, this.scrollOffset);
846
+ }
847
+ load() {
848
+ const e = this.getStorageKeyFn;
849
+ if (e) {
850
+ const t = e();
851
+ if (t) {
852
+ const s = t + this.SCROLL_STATE;
853
+ let i = this.loadFromLocalStorage(s);
854
+ this.scrollOffset = i || [0, 0];
855
+ }
856
+ }
857
+ }
858
+ }
859
+ class Oe {
860
+ constructor(e = "collapsed", t = [], s = !1, i = !1) {
861
+ this.mode = e, this.rowIds = t, this.allCollapsed = s, this.allExpanded = i;
862
+ }
863
+ }
864
+ class _e extends Y {
865
+ constructor(e) {
866
+ super(e), this.COLLAPSED_EXPANDED_STATE = "collapsedExpandedState", this.collapsedExpandedState = new Oe(), this.load();
867
+ }
868
+ collapsedExpandedStateGet() {
869
+ return this.collapsedExpandedState;
870
+ }
871
+ collapsedExpandedStateIncludes(e) {
872
+ return this.collapsedExpandedState.rowIds.includes(e);
873
+ }
874
+ collapsedStateIdsPush(e) {
875
+ this.collapsedExpandedState.rowIds.includes(e) || (this.collapsedExpandedState.rowIds.push(e), this.collapsedExpandedState.allCollapsed = !1, this.collapsedExpandedState.allExpanded = !1, this.persist());
876
+ }
877
+ collapsedStateIdsRemove(e) {
878
+ const t = this.collapsedExpandedState.rowIds.indexOf(e);
879
+ t !== -1 && (this.collapsedExpandedState.rowIds.splice(t, 1), this.collapsedExpandedState.allCollapsed = !1, this.collapsedExpandedState.allExpanded = !1, this.persist());
880
+ }
881
+ collapsedStateAll(e) {
882
+ this.collapsedExpandedState.rowIds = [], this.collapsedExpandedState.mode = e ? "collapsed" : "expanded", this.collapsedExpandedState.allCollapsed = !e, this.collapsedExpandedState.allExpanded = e, this.persist();
883
+ }
884
+ load() {
885
+ const e = this.getStorageKeyFn;
886
+ if (e) {
887
+ const t = e();
888
+ if (t) {
889
+ const s = t + this.COLLAPSED_EXPANDED_STATE, i = this.loadFromLocalStorage(s);
890
+ i && (this.collapsedExpandedState = i);
891
+ }
892
+ }
893
+ }
894
+ persist() {
895
+ this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE, this.collapsedExpandedState);
896
+ }
897
+ }
898
+ class $e extends Y {
899
+ constructor(e) {
900
+ super(e), this.SORTING_STATE = "sortingState", this.sortItems = [], this.load();
901
+ }
902
+ getSortItems() {
903
+ return this.sortItems;
904
+ }
905
+ setSortItems(e) {
906
+ this.sortItems = e, this.checkAndPersistItem(this.SORTING_STATE, this.sortItems);
907
+ }
908
+ load() {
909
+ const e = this.getStorageKeyFn;
910
+ if (e) {
911
+ const t = e();
912
+ if (t) {
913
+ const s = t + this.SORTING_STATE;
914
+ let i = this.loadFromLocalStorage(s);
915
+ this.sortItems = i || [];
916
+ }
917
+ }
918
+ }
919
+ }
920
+ class T {
921
+ constructor(e = 0, t = 0, s = 0, i = 0, o) {
922
+ this.left = e, this.width = t, this.height = s, this.top = i, this.index = o;
923
+ }
924
+ }
925
+ class Le {
926
+ constructor(e, t, s, i) {
927
+ this.hostElement = e, this.tableModel = t, this.dom = s, this.tableOptions = i, this.scrollTop = 0, this.areaBodyWestGeo = new T(), this.areaBodyCenterGeo = new T(), this.areaBodyEastGeo = new T();
928
+ const o = this.hostElement;
929
+ o.innerText = "", this.dom.setAttribute(o, "tabindex", "0"), this.dom.setStyle(
930
+ this.dom.addClass("ge-table", o),
931
+ "position",
932
+ "relative"
933
+ ), this.hoverRow = s.applyStylePosistionAbsolute(
934
+ s.createDivWithClass("ge-table-hover-row", o)
935
+ ), this.hoverColumn = s.applyStylePosistionAbsolute(
936
+ s.createDivWithClass("ge-table-hover-column", o)
937
+ ), this.areaHeaderWest = s.appendRelativeChildDiv(
938
+ s.applyStylePosistionAbsolute(
939
+ s.createAreaDivWithClass("ge-table-header ge-table-header-west", o, "header", "west")
940
+ )
941
+ ), this.areaHeaderCenter = s.appendRelativeChildDiv(
942
+ s.applyStylePosistionAbsolute(
943
+ s.createAreaDivWithClass("ge-table-header ge-table-header-center", o, "header", "center")
944
+ )
945
+ ), this.areaHeaderEast = s.appendRelativeChildDiv(
946
+ s.applyStylePosistionAbsolute(
947
+ s.createAreaDivWithClass("ge-table-header ge-table-header-east", o, "body", "east")
948
+ )
949
+ ), this.areaBodyWest = s.appendRelativeChildDiv(
950
+ s.applyStylePosistionAbsolute(
951
+ s.createAreaDivWithClass("ge-table-body ge-table-body-west", o, "body", "west")
952
+ )
953
+ ), this.areaBodyEast = s.appendRelativeChildDiv(
954
+ s.applyStylePosistionAbsolute(
955
+ s.createAreaDivWithClass("ge-table-body ge-table-body-east", o, "body", "east")
956
+ )
957
+ ), this.areaFooterWest = s.appendRelativeChildDiv(
958
+ s.applyStylePosistionAbsolute(
959
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-west", o, "footer", "west")
960
+ )
961
+ ), this.areaFooterCenter = s.appendRelativeChildDiv(
962
+ s.applyStylePosistionAbsolute(
963
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-center", o, "footer", "center")
964
+ )
965
+ ), this.areaFooterEast = s.appendRelativeChildDiv(
966
+ s.applyStylePosistionAbsolute(
967
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-east", o, "footer", "east")
968
+ )
969
+ ), this.scrollViewport = s.applyStyleOverflowAuto(
970
+ this.tableOptions.overflowX ?? "auto",
971
+ this.tableOptions.overflowY ?? "auto",
972
+ s.applyStyleNoPadding(
973
+ s.applyStylePosistionAbsolute(
974
+ s.createAreaDivWithClass("ge-table-scroll-viewport", o, "body", "center")
975
+ )
976
+ )
977
+ ), this.contentWrapperDiv = s.applyStyleNoPadding(
978
+ s.applyStylePosistionRelative(
979
+ s.createDivWithClass("ge-table-scroll-content-wrapper", this.scrollViewport)
980
+ )
981
+ ), this.contentDiv = s.applyStyleNoPadding(
982
+ s.applyStylePosistionRelative(
983
+ s.createDivWithClass("ge-table-scroll-content", this.contentWrapperDiv)
984
+ )
985
+ ), this.areaBodyCenter = s.appendRelativeChildDiv(
986
+ s.createDivWithClass("ge-table-body-center", this.contentDiv)
987
+ ), this.borderHeaderBottom = s.applyStylePosistionAbsolute(
988
+ s.createDivWithClass("ge-table-header-border", o)
989
+ ), this.borderFixedWest = s.applyStylePosistionAbsolute(
990
+ s.createDivWithClass("ge-table-west-fixed-column-border", o)
991
+ ), this.borderFixedEast = s.applyStylePosistionAbsolute(
992
+ s.createDivWithClass("ge-table-east-fixed-column-border", o)
993
+ ), this.borderFooterTop = s.applyStylePosistionAbsolute(
994
+ s.createDivWithClass("ge-table-footer-border", o)
995
+ );
996
+ }
997
+ adjustContainersAndRows() {
998
+ const e = this.tableModel.getPadding(), t = this.hostElement.clientWidth, s = this.hostElement.clientHeight;
999
+ this.dom.applyStyle(this.scrollViewport, {
1000
+ width: `${t - e.left}px`,
1001
+ height: `${s - e.top}px`,
1002
+ top: `${e.top}px`,
1003
+ left: `${e.left}px`
1004
+ }), this.scrollTop = this.scrollViewport.scrollTop, this.dom.applyStyle(this.contentDiv, {
1005
+ width: `${this.scrollViewport.clientWidth}px`,
1006
+ height: `${this.scrollViewport.clientHeight}px`,
1007
+ top: `${this.scrollTop}px`,
1008
+ left: `${this.scrollViewport.scrollLeft}px`
1009
+ }), this.areaBodyWestGeo.width = e.left, this.areaBodyWestGeo.height = s - e.top - e.bottom, this.areaBodyWestGeo.top = e.top, this.areaBodyWestGeo.left = 0, this.dom.applyStyleInPx(this.areaBodyWest.parent, this.areaBodyWestGeo), this.tableOptions.fixedWestSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount() ? this.dom.applyDisplayBlockStyle(
1010
+ this.dom.applyStyle(this.borderFixedWest, {
1011
+ width: "1px",
1012
+ height: `${this.areaBodyWestGeo.height}px`,
1013
+ top: `${this.areaBodyWestGeo.top}px`,
1014
+ left: `${this.areaBodyWestGeo.width}px`
1015
+ })
1016
+ ) : this.dom.applyDisplayNoneStyle(this.borderFixedWest), this.areaBodyEastGeo.width = e.right, this.areaBodyEastGeo.height = s - e.top - e.bottom, this.areaBodyEastGeo.top = e.top, this.areaBodyEastGeo.left = t - e.right, this.dom.applyStyleInPx(this.areaBodyEast.parent, this.areaBodyEastGeo), this.tableOptions.fixedEastSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount() ? this.dom.applyDisplayBlockStyle(
1017
+ this.dom.applyStyle(this.borderFixedEast, {
1018
+ width: "1px",
1019
+ height: `${this.areaBodyEastGeo.height}px`,
1020
+ top: `${this.areaBodyEastGeo.top}px`,
1021
+ left: `${this.areaBodyEastGeo.left}px`
1022
+ })
1023
+ ) : this.dom.applyDisplayNoneStyle(this.borderFixedEast), this.areaBodyCenterGeo.width = t - e.left - e.right, this.areaBodyCenterGeo.height = s - e.top - e.bottom, this.areaBodyCenterGeo.top = 0, this.areaBodyCenterGeo.left = 0, this.dom.applyStyleInPx(this.areaBodyCenter.parent, this.areaBodyCenterGeo), this.dom.applyStyle(this.areaHeaderCenter.parent, {
1024
+ width: `${t - e.left - e.right}px`,
1025
+ height: `${e.top}px`,
1026
+ top: "0",
1027
+ left: `${e.left}px`
1028
+ }), this.dom.applyStyle(this.areaHeaderWest.parent, {
1029
+ width: `${e.left}px`,
1030
+ height: `${e.top}px`,
1031
+ top: "0",
1032
+ left: "0"
1033
+ }), this.dom.applyStyle(this.areaHeaderEast.parent, {
1034
+ width: `${e.right}px`,
1035
+ height: `${e.top}px`,
1036
+ top: "0",
1037
+ left: `${t - e.right}px`
1038
+ }), this.tableOptions.headerSeparatorBorderVisible && this.tableModel.isHeaderVisibe() ? this.dom.applyDisplayBlockStyle(
1039
+ this.dom.applyStyle(this.borderHeaderBottom, {
1040
+ width: `${t}px`,
1041
+ height: "1px",
1042
+ top: `${e.top}px`,
1043
+ left: "0px"
1044
+ })
1045
+ ) : this.dom.applyDisplayNoneStyle(this.borderHeaderBottom), this.dom.applyStyle(this.areaFooterWest.parent, {
1046
+ width: `${e.left}px`,
1047
+ height: `${e.bottom}px`,
1048
+ top: `${s - e.bottom}px`,
1049
+ left: "0"
1050
+ }), this.dom.applyStyle(this.areaFooterCenter.parent, {
1051
+ width: `${t - e.left - e.right}px`,
1052
+ height: `${e.bottom}px`,
1053
+ top: `${s - e.bottom}px`,
1054
+ left: `${e.left}px`
1055
+ }), this.dom.applyStyle(this.areaFooterEast.parent, {
1056
+ width: `${e.right}px`,
1057
+ height: `${e.bottom}px`,
1058
+ top: `${s - e.bottom}px`,
1059
+ left: `${t - e.right}px`
1060
+ }), this.tableOptions.footerSeparatorBorderVisible && this.tableModel.isFooterVisibe() ? this.dom.applyDisplayBlockStyle(
1061
+ this.dom.applyStyle(this.borderFooterTop, {
1062
+ width: `${t}px`,
1063
+ height: "1px",
1064
+ top: `${s - e.bottom}px`,
1065
+ left: "0px"
1066
+ })
1067
+ ) : this.dom.applyDisplayNoneStyle(this.borderFooterTop), this.adjustAfterScrolling();
1068
+ }
1069
+ adjustAfterScrolling() {
1070
+ }
1071
+ resetSizeOfWrapperDiv() {
1072
+ const e = `${this.tableModel.getContentWidthInPixel()}px`, t = `${this.tableModel.getContentHeightInPixel() + 1}px`;
1073
+ this.dom.setStyle(this.contentWrapperDiv, "width", e), this.dom.setStyle(this.contentWrapperDiv, "height", t);
1074
+ }
1075
+ }
1076
+ class A {
1077
+ constructor(e, t, s, i, o = !1) {
1078
+ this.r1 = e, this.c1 = t, this.r2 = s, this.c2 = i, this.gammaRange = o;
1079
+ }
1080
+ static create(e) {
1081
+ return e.gammaRange === void 0 && (e.gammaRange = !1), new A(
1082
+ e.rowIndex1,
1083
+ e.columnIndex1,
1084
+ e.rowIndex2,
1085
+ e.columnIndex2,
1086
+ e.gammaRange
1087
+ );
1088
+ }
1089
+ static singleCell(e, t) {
1090
+ return new A(e, t, e, t);
1091
+ }
1092
+ static singleRow(e) {
1093
+ return new A(e, 0, e, Number.MAX_SAFE_INTEGER);
1094
+ }
1095
+ static singleColumn(e) {
1096
+ return new A(0, e, Number.MAX_SAFE_INTEGER, e);
1097
+ }
1098
+ isInRange(e, t) {
1099
+ return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
1100
+ }
1101
+ }
1102
+ class Be {
1103
+ constructor(e, t) {
1104
+ this.tableModel = e, this.areaModel = t, this.colAndRowspanRanges = void 0;
1105
+ }
1106
+ init() {
1107
+ if (this.areaModel.getMaxColspan() < 2 && this.areaModel.getMaxRowspan() < 2)
1108
+ return;
1109
+ this.colAndRowspanRanges = [];
1110
+ const e = this.areaModel.getRowCount(), t = this.tableModel.getColumnCount();
1111
+ for (let s = 0; s < e; s++)
1112
+ for (let i = 0; i < t; i++) {
1113
+ let o = this.areaModel.getColspanAt(s, i), r = this.areaModel.getRowspanAt(s, i);
1114
+ if (o > 1 || r > 1) {
1115
+ o === 0 && (o = 1), r === 0 && (r = 1);
1116
+ const a = this.areaModel.hasOwnProperty("gammaCells");
1117
+ this.colAndRowspanRanges.push(
1118
+ new A(s, i, s + r - 1, i + o - 1, a)
1119
+ );
1120
+ }
1121
+ }
1122
+ }
1123
+ getRanges() {
1124
+ return this.colAndRowspanRanges ? this.colAndRowspanRanges : [];
1125
+ }
1126
+ isInRange(e, t) {
1127
+ if (this.colAndRowspanRanges) {
1128
+ for (const s of this.colAndRowspanRanges)
1129
+ if (s.isInRange(e, t))
1130
+ return !0;
1131
+ }
1132
+ return !1;
1133
+ }
1134
+ }
1135
+ class Pe {
1136
+ constructor(e, t, s) {
1137
+ this.header = e, this.body = t, this.footer = s;
1138
+ }
1139
+ }
1140
+ class ke extends Le {
1141
+ constructor(e, t, s, i) {
1142
+ var r, a;
1143
+ super(e, t, s, i), this.scrollLeft = 0, this.scrollViewportLeft = 0, this.scrollFactorY = 0, this.scrollFactorX = 0, this.cleanupFunctions = {
1144
+ header: [],
1145
+ body: [],
1146
+ footer: []
1147
+ }, this.tree = !1, this.colAndRowspanModels = new Pe(), this.firstVisibleRowIndex = -1, this.draggingTargetColumnIndex = -1, this.removables = [], this.editing = !1, this.tableModel.getSelectionModel ? this.getSelectionModel = this.tableModel.getSelectionModel : (r = this.tableOptions) != null && r.getSelectionModel && (this.getSelectionModel = this.tableOptions.getSelectionModel), (a = this.tableOptions) != null && a.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), t.getAreaModel("body") instanceof j && (this.tree = !0), ["header", "body", "footer"].forEach(
1148
+ (l) => {
1149
+ var d;
1150
+ this.colAndRowspanModels[l] = new Be(t, t.getAreaModel(l)), (d = this.colAndRowspanModels[l]) == null || d.init();
1151
+ }
1152
+ );
1153
+ }
1154
+ isEditing() {
1155
+ return this.editing;
1156
+ }
1157
+ resetEditorRenderer() {
1158
+ this.editorRenderer = void 0, this.editorRendererRow = -1, this.editorRendererColumn = -1, this.editing = !1;
1159
+ }
1160
+ clearSelection() {
1161
+ if (this.getSelectionModel) {
1162
+ const e = this.getSelectionModel();
1163
+ e == null || e.clear();
1164
+ }
1165
+ }
1166
+ initRenderEditor(e, t) {
1167
+ var i;
1168
+ let s = (i = this.tableModel.getColumnDef(t)) == null ? void 0 : i.getEditRenderer;
1169
+ if (s || (s = this.tableOptions.getEditRenderer), s)
1170
+ if (this.editorRenderer = s(e, t), this.editorRenderer) {
1171
+ this.editorRendererRow = e, this.editorRendererColumn = t, this.editing = !0, this.repaint();
1172
+ const o = document.querySelector("input.ge-table-cell-editor-input");
1173
+ o && o.focus();
1174
+ } else
1175
+ this.resetEditorRenderer();
1176
+ }
1177
+ repaint() {
1178
+ this.adjustAfterScrolling();
1179
+ }
1180
+ adjustAfterScrolling() {
1181
+ var e;
1182
+ for (const t of this.removables)
1183
+ t.remove();
1184
+ this.hideHoverRow(), this.hideHoverColumn(), this.scrollTop = this.scrollViewport.scrollTop, this.scrollLeft = this.scrollViewport.scrollLeft, this.debounce(this.checkForScrollPosSaving.bind(this)), this.scrollFactorY = this.scrollTop / (this.scrollViewport.scrollHeight - this.scrollViewport.clientHeight), this.scrollFactorX = this.scrollLeft / (this.scrollViewport.scrollWidth - this.scrollViewport.clientWidth), isNaN(this.scrollFactorY) && (this.scrollFactorY = 0), isNaN(this.scrollFactorX) && (this.scrollFactorX = 0), this.adjustBody(), this.adjustArea("footer"), this.adjustArea("header"), this.tableOptions.tableTopBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
1185
+ new T(0, this.hostElement.clientWidth, 1, 0),
1186
+ this.hostElement,
1187
+ "ge-table-border"
1188
+ )), this.tableOptions.tableBottomBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
1189
+ new T(0, this.hostElement.clientWidth, 1, this.hostElement.clientHeight - 1),
1190
+ this.hostElement,
1191
+ "ge-table-border"
1192
+ )), this.tableModel.getFixedLeftColumnCount() > 0 && this.removables.push(this.dom.addVerticalBorder(
1193
+ new T(this.areaBodyWest.child.clientWidth, 1, this.hostElement.clientHeight, 0),
1194
+ this.hostElement,
1195
+ "ge-table-body-west-vertical-border"
1196
+ )), ((e = this.tableModel.getAreaModel("header")) == null ? void 0 : e.getRowCount()) > 0 && this.removables.push(this.dom.addHorizontalBorder(
1197
+ new T(0, this.hostElement.clientWidth, 1, this.areaHeaderCenter.child.clientHeight),
1198
+ this.hostElement,
1199
+ "ge-table-body-west-vertical-border"
1200
+ ));
1201
+ }
1202
+ checkForScrollPosSaving() {
1203
+ var e, t;
1204
+ this.storeScrollPosStateService && ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.autoRestoreScrollPosition) && this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft, this.scrollTop]);
1205
+ }
1206
+ updateCells(e) {
1207
+ e.forEach(
1208
+ (t) => this.tableModel.getAreaModel(t.area).setValue(t.rowIndex, t.columnIndex, t.value)
1209
+ ), this.repaint();
1210
+ }
1211
+ getAreaAndSideIdentByAttr(e) {
1212
+ if (e) {
1213
+ const t = this.getStringByAttr(e, "data-area"), s = this.getStringByAttr(e, "data-side");
1214
+ if (s && t)
1215
+ return [t, s];
1216
+ }
1217
+ return [void 0, void 0];
1218
+ }
1219
+ getArea(e, t) {
1220
+ if (e === "header") {
1221
+ if (t === "west")
1222
+ return this.areaHeaderWest;
1223
+ if (t === "center")
1224
+ return this.areaHeaderCenter;
1225
+ if (t === "east")
1226
+ return this.areaHeaderEast;
1227
+ } else if (e === "body") {
1228
+ if (t === "west")
1229
+ return this.areaBodyWest;
1230
+ if (t === "center")
1231
+ return this.areaBodyCenter;
1232
+ if (t === "east")
1233
+ return this.areaBodyEast;
1234
+ } else if (e === "footer") {
1235
+ if (t === "west")
1236
+ return this.areaFooterWest;
1237
+ if (t === "center")
1238
+ return this.areaFooterCenter;
1239
+ if (t === "east")
1240
+ return this.areaFooterEast;
1241
+ }
1242
+ throw Error(`Wrong area identifier: row:${e}, col:${t}`);
1243
+ }
1244
+ adjustBody() {
1245
+ const e = this.areaBodyCenterGeo.height - this.tableModel.getContentHeightInPixel(), t = this.scrollFactorY * e;
1246
+ this.dom.setStyle(this.contentDiv, "top", `${this.scrollTop}px`), this.dom.setStyle(this.contentDiv, "left", `${this.scrollViewport.scrollLeft}px`), this.adjustArea("body", t);
1247
+ }
1248
+ getNumberByAttr(e, t) {
1249
+ var s;
1250
+ if (e) {
1251
+ const i = (s = e.closest("[" + t + "]")) == null ? void 0 : s.getAttribute(t);
1252
+ if (i)
1253
+ return Number(i);
1254
+ }
1255
+ return -1;
1256
+ }
1257
+ getStringByAttr(e, t) {
1258
+ var s;
1259
+ if (e) {
1260
+ const i = (s = e.closest("[" + t + "]")) == null ? void 0 : s.getAttribute(t);
1261
+ if (i)
1262
+ return i;
1263
+ }
1264
+ return "";
1265
+ }
1266
+ adjustArea(e, t = 0) {
1267
+ var u;
1268
+ const s = this.getArea(e, "west"), i = this.getArea(e, "center"), o = this.getArea(e, "east"), r = i.child.clientHeight;
1269
+ s.child.innerText = "", i.child.innerText = "", o.child.innerText = "";
1270
+ const a = 0, l = this.areaBodyCenterGeo.width, d = this.tableModel.getPadding(), h = this.tableModel.getAreaModel(e), p = h.getRowCount();
1271
+ for (; this.cleanupFunctions[e].length; ) {
1272
+ const f = this.cleanupFunctions[e].shift();
1273
+ f && f();
1274
+ }
1275
+ let g = t;
1276
+ const S = this.tableModel.getColumnCount(), c = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
1277
+ for (let f = 0; f < p; f++) {
1278
+ const x = g, v = f === p - 1, C = this.tableModel.getRowHeight(e, f);
1279
+ if (x + C > 0) {
1280
+ this.firstVisibleRowIndex = f;
1281
+ let w = { left: a, width: l, height: C, top: x, index: f }, m = this.dom.addRowDiv(i, w, f, e, "center");
1282
+ const M = b;
1283
+ if (this.adjustColumnsToRowParent({
1284
+ areaIdent: e,
1285
+ sideIdent: "center",
1286
+ areaModel: h,
1287
+ geo: w,
1288
+ parent: m,
1289
+ rowIndex: f,
1290
+ columnIndexStart: M,
1291
+ columnIndexEnd: S - c - 1,
1292
+ verticalFixed: !1,
1293
+ lastRowOfModel: v
1294
+ }), d.left > 0 && (w = { left: a, width: this.areaBodyWestGeo.width, height: C, top: x, index: f }, m = this.dom.addRowDiv(s, w, f, e, "west"), this.adjustColumnsToRowParent({
1295
+ areaIdent: e,
1296
+ sideIdent: "west",
1297
+ areaModel: h,
1298
+ geo: w,
1299
+ parent: m,
1300
+ rowIndex: f,
1301
+ columnIndexStart: 0,
1302
+ columnIndexEnd: M - 1,
1303
+ verticalFixed: !0,
1304
+ lastRowOfModel: v
1305
+ })), d.right > 0 && (w = { left: a, width: this.areaBodyEastGeo.width, height: C, top: x, index: f }, m = this.dom.addRowDiv(o, w, f, e, "east"), this.adjustColumnsToRowParent({
1306
+ areaIdent: e,
1307
+ sideIdent: "east",
1308
+ areaModel: h,
1309
+ geo: w,
1310
+ parent: m,
1311
+ rowIndex: f,
1312
+ columnIndexStart: S - c,
1313
+ columnIndexEnd: S - 1,
1314
+ verticalFixed: !0,
1315
+ lastRowOfModel: v
1316
+ })), e === "header" && this.tree && f === p - 1) {
1317
+ const E = this.dom.applyStyle(
1318
+ this.dom.setAttribute(
1319
+ this.dom.addDiv(m, new T(16, 20, 20, 8)),
1320
+ "data-ge-action",
1321
+ "toggleExpandCollapseAll"
1322
+ ),
1323
+ { cursor: "pointer" }
1324
+ ), R = this.tableOptions.treeOptions.arrowExpandCollapseAll;
1325
+ if (R) {
1326
+ const B = this.dom.domService.createText(R.content);
1327
+ this.dom.domService.appendChild(E, B), R.style && this.dom.applyStyleString(E, R.style);
1328
+ }
1329
+ }
1330
+ }
1331
+ if (g = g + C, g > r)
1332
+ break;
1333
+ }
1334
+ if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
1335
+ const f = ((u = this.colAndRowspanModels[e]) == null ? void 0 : u.getRanges()) ?? [];
1336
+ if (f.length)
1337
+ for (const x of f) {
1338
+ let v = 0, C = i.child, w = "center";
1339
+ if (x.c1 < b)
1340
+ C = s.child, w = "west";
1341
+ else if (c > 0 && x.c1 >= S - c)
1342
+ C = o.child, w = "east";
1343
+ else {
1344
+ const m = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
1345
+ v = this.scrollFactorX * m - this.areaBodyWestGeo.width, w = "center";
1346
+ }
1347
+ this.drawBigCell(x, v, t, h, C, w);
1348
+ }
1349
+ }
1350
+ }
1351
+ /**
1352
+ * Draws big cells (rowspan and or colspan) in body/center
1353
+ * @param range CellRange
1354
+ * @param xStart X position in pixel for top left corner
1355
+ * @param yStart Y position in pixel for top left corner
1356
+ * @param areaModel AreaModelIf
1357
+ * @param parentDiv Parent div as HTMLDivElement
1358
+ * @param sideIdent SideIdent (west,center,east)
1359
+ * @protected
1360
+ */
1361
+ drawBigCell(e, t, s, i, o, r) {
1362
+ const a = s + this.getRowHeights(0, e.r1 - 1, i).reduce((u, f) => u + f, 0), l = this.tableModel.getColumnCount(), d = this.tableModel.getFixedRightColumnCount();
1363
+ let h = 0;
1364
+ d > 0 && e.c1 >= l - d && (h = l - d);
1365
+ const p = t + this.getColumnWidths(h, e.c1 - 1).reduce((u, f) => u + f, 0), g = this.getRowHeights(e.r1, e.r2, i).reduce((u, f) => u + f, 0), S = this.getColumnWidths(e.c1, e.c2).reduce((u, f) => u + f, 0);
1366
+ let c = !1;
1367
+ const b = this.getSelectionModel ? this.getSelectionModel() : void 0;
1368
+ b && (c = b.getSelectionCount(e.r1, e.c1) > 0), e.gammaRange ? (console.info("TODO here", e), this.renderCell({
1369
+ areaModel: i,
1370
+ areaIdent: i.areaIdent,
1371
+ sideIdent: r,
1372
+ rowIndex: e.r1,
1373
+ columnIndex: e.c1,
1374
+ left: p,
1375
+ top: a,
1376
+ width: S,
1377
+ height: g,
1378
+ parent: o,
1379
+ cellSelected: c,
1380
+ lastRowOfModel: !0,
1381
+ gammaRange: e.gammaRange
1382
+ })) : this.renderCell({
1383
+ areaModel: i,
1384
+ areaIdent: i.areaIdent,
1385
+ sideIdent: r,
1386
+ rowIndex: e.r1,
1387
+ columnIndex: e.c1,
1388
+ left: p,
1389
+ top: a,
1390
+ width: S,
1391
+ height: g,
1392
+ parent: o,
1393
+ cellSelected: c,
1394
+ lastRowOfModel: !0,
1395
+ gammaRange: e.gammaRange
1396
+ }), i.areaIdent === "header" && this.tableOptions.columnsResizable && this.renderHeaderCellResizeHandle({
1397
+ rowIndex: e.r1,
1398
+ columnIndex: e.c1,
1399
+ cellLeft: p,
1400
+ cellTop: a,
1401
+ cellWidth: S,
1402
+ cellHeight: g,
1403
+ parent: o
1404
+ });
1405
+ }
1406
+ findRowOfImportantRowspanCell(e, t, s) {
1407
+ const i = e.getMaxRowspan();
1408
+ for (let o = t - 1; o > -1; o--) {
1409
+ const r = e.getRowspanAt(o, s);
1410
+ if (r > 1 && o + r + 1 >= t)
1411
+ return o;
1412
+ if (t - o > i)
1413
+ return -1;
1414
+ }
1415
+ return -1;
1416
+ }
1417
+ adjustColumnsToRowParent({
1418
+ areaIdent: e,
1419
+ sideIdent: t,
1420
+ areaModel: s,
1421
+ geo: i,
1422
+ parent: o,
1423
+ rowIndex: r,
1424
+ columnIndexStart: a,
1425
+ columnIndexEnd: l,
1426
+ verticalFixed: d = !1,
1427
+ lastRowOfModel: h = !1
1428
+ }) {
1429
+ var b;
1430
+ this.scrollViewportLeft = this.scrollViewport.scrollLeft;
1431
+ let p = 0;
1432
+ if (!d) {
1433
+ const u = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
1434
+ p = this.scrollFactorX * u;
1435
+ }
1436
+ const g = 0, S = !!(e === "body" && t);
1437
+ let c = p;
1438
+ for (let u = a; u <= l; u++) {
1439
+ const f = c, x = this.tableModel.getColumnWidth(u);
1440
+ if (x > 0 && f + x > 0) {
1441
+ let v = i.height;
1442
+ const C = s.getRowspanAt(r, u), w = s.getColspanAt(r, u);
1443
+ C > 1 && (v = this.getRowHeights(r, r + C - 1, s).reduce((E, R) => E + R, 0));
1444
+ let m = x;
1445
+ w > 1 && (m = this.getColumnWidths(u, u + w - 1).reduce((E, R) => E + R, 0));
1446
+ let M = !1;
1447
+ if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, u) && (M = !0), this.draggingTargetColumnIndex === u && e !== "header") {
1448
+ this.renderDragTargetDiv(o, f, g, m, v);
1449
+ const E = { left: f, top: g, width: m, height: v };
1450
+ this.dom.addColumnBorderDivs(this.tableOptions, o, E, e, t);
1451
+ } else {
1452
+ const E = this.renderSelectedBackgroundDiv(M, S, t, s, r, u, o, f, g, m, v);
1453
+ M || this.renderCell({
1454
+ areaModel: s,
1455
+ areaIdent: e,
1456
+ sideIdent: t,
1457
+ rowIndex: r,
1458
+ columnIndex: u,
1459
+ left: f,
1460
+ top: g,
1461
+ width: m,
1462
+ height: v,
1463
+ parent: o,
1464
+ cellSelected: E,
1465
+ lastRowOfModel: h,
1466
+ gammaRange: !0
1467
+ }), e === "header" && this.tableOptions.columnsResizable && this.renderHeaderCellResizeHandle({
1468
+ rowIndex: r,
1469
+ columnIndex: u,
1470
+ cellLeft: f,
1471
+ cellTop: g,
1472
+ cellWidth: m,
1473
+ cellHeight: v,
1474
+ parent: o
1475
+ });
1476
+ }
1477
+ }
1478
+ if (c = c + x, c > this.areaBodyCenterGeo.width)
1479
+ break;
1480
+ }
1481
+ this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(c - 1, 1, i.height, 0), o);
1482
+ }
1483
+ getTreeArrowColumnIndex() {
1484
+ return this.tableOptions.showCheckboxWihoutExtraColumn ? 0 : this.tableModel.isRowCheckboxVisible() ? 1 : 0;
1485
+ }
1486
+ addAndRenderCellDiv({
1487
+ areaModel: e,
1488
+ areaIdent: t,
1489
+ sideIdent: s,
1490
+ rowIndex: i,
1491
+ index: o,
1492
+ left: r,
1493
+ width: a,
1494
+ height: l,
1495
+ top: d,
1496
+ parent: h,
1497
+ lastRowOfModel: p
1498
+ }) {
1499
+ var U;
1500
+ const S = this.editorRenderer && this.editorRendererRow === i && this.editorRendererColumn === o ? this.editorRenderer : e.getCellRenderer(i, o), c = { left: r, width: a, height: l, top: d, index: o }, b = e.getRowByIndex(i);
1501
+ let u = "none";
1502
+ if (o === this.getTreeArrowColumnIndex() && b instanceof N) {
1503
+ const y = b;
1504
+ (U = y.children) != null && U.length ? y.expanded ? u = "expanded" : u = "collapsed" : u = "hidden";
1505
+ }
1506
+ let x;
1507
+ if (t === "header") {
1508
+ const y = this.tableModel.getColumnDef(o);
1509
+ (!(y != null && y.sortIconVisible) || y != null && y.sortIconVisible()) && (x = y == null ? void 0 : y.sortState);
1510
+ }
1511
+ const v = e.getValueAt(i, o), C = S ? "" : `${v}`, w = e.isRowChecked(i), m = this.dom.addColumnDiv(
1512
+ h,
1513
+ c,
1514
+ i,
1515
+ o,
1516
+ t,
1517
+ s,
1518
+ C,
1519
+ u,
1520
+ this.tableOptions,
1521
+ w,
1522
+ x
1523
+ ), M = e.getTooltipAt(i, o);
1524
+ M && this.dom.setAttribute(m, "title", M);
1525
+ const E = this.tableModel.getColumnDef(o);
1526
+ E && E.classes[t] && this.dom.addClasses(E.classes[t], m);
1527
+ let R;
1528
+ S && (R = S.render(m, i, o, t, e, v, this.dom.domService));
1529
+ const B = e.getCustomClassesAt(i, o);
1530
+ if (B.length && this.dom.addClasses(B, m), this.dom.addColumnBorderDivs(this.tableOptions, h, c, t, s), p && this.dom.addHorizontalBorder({ left: r, width: a, height: l, top: d + l }, h), this.getFocusModel && t === "body") {
1531
+ const y = this.getFocusModel();
1532
+ y != null && y.hasFocus(i, o) && this.dom.addFocusBorderDivs(h, c, {});
1533
+ }
1534
+ t === "header" && this.dom.setAttribute(m, "data-ge-action", "drag-column");
1535
+ const k = e.getCustomStyleAt(i, o);
1536
+ if (k)
1537
+ for (const y in k)
1538
+ this.dom.setStyle(m, y, k[y]);
1539
+ return [m, R];
1540
+ }
1541
+ getColumnWidths(e, t) {
1542
+ const s = [];
1543
+ for (let i = e; i <= t; i++)
1544
+ s.push(this.tableModel.getColumnWidth(i));
1545
+ return s;
1546
+ }
1547
+ getRowHeights(e, t, s) {
1548
+ const i = [];
1549
+ for (let o = e; o <= t; o++)
1550
+ i.push(s.getRowHeight(o));
1551
+ return i;
1552
+ }
1553
+ adjustHoverRows(e) {
1554
+ if (this.tableOptions.hoverRowVisible && e.rowIndex > -1) {
1555
+ const t = this.hostElement.clientWidth, s = this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex), i = e.rowTop + this.areaHeaderCenter.parent.clientHeight - this.scrollTop;
1556
+ this.dom.applyStyle(this.hoverRow, {
1557
+ left: "0",
1558
+ top: i + "px",
1559
+ width: t + "px",
1560
+ height: s + "px",
1561
+ display: "block"
1562
+ });
1563
+ } else
1564
+ this.hideHoverRow();
1565
+ }
1566
+ hideHoverRow() {
1567
+ this.dom.applyStyle(this.hoverRow, {
1568
+ display: "none"
1569
+ });
1570
+ }
1571
+ adjustHoverColumns(e) {
1572
+ if (this.tableOptions.hoverColumnVisible && e.rowIndex > -1) {
1573
+ const t = this.hostElement.clientHeight, s = this.tableModel.getColumnWidth(e.columnIndex), i = this.areaBodyWestGeo.width, o = e.columnLeft + this.tableModel.getPadding().left - this.scrollLeft - i;
1574
+ this.dom.applyStyle(this.hoverColumn, {
1575
+ left: o + "px",
1576
+ top: "0px",
1577
+ width: s + "px",
1578
+ height: t + "px",
1579
+ display: "block"
1580
+ });
1581
+ } else
1582
+ this.hideHoverColumn();
1583
+ }
1584
+ hideHoverColumn() {
1585
+ this.dom.applyStyle(this.hoverColumn, {
1586
+ display: "none"
1587
+ });
1588
+ }
1589
+ debounce(e, t = 1e3) {
1590
+ this.debounceTimeout && clearTimeout(this.debounceTimeout), this.debounceTimeout = setTimeout(e.bind(this), t);
1591
+ }
1592
+ renderDragTargetDiv(e, t, s, i, o) {
1593
+ const r = this.dom.applyStylePosistionAbsolute(
1594
+ this.dom.createDivWithClass("ge-table-drop-zone", e)
1595
+ );
1596
+ return this.dom.setStyle(r, "left", `${t}px`), this.dom.setStyle(r, "top", `${s}px`), this.dom.setStyle(r, "width", `${i}px`), this.dom.setStyle(r, "height", `${o}px`), r;
1597
+ }
1598
+ renderSelectedBackgroundDiv(e, t, s, i, o, r, a, l, d, h, p) {
1599
+ let g = !1;
1600
+ if (!e && t && i.isSelectable(o, r) && this.getSelectionModel) {
1601
+ const S = this.getSelectionModel();
1602
+ if (S) {
1603
+ const c = S.getSelectionCount(o, r);
1604
+ g = c > 0;
1605
+ for (let b = 0; b < c; b++) {
1606
+ const u = this.dom.applyStylePosistionAbsolute(
1607
+ // ge-table-body-west-selected-range
1608
+ this.dom.createDivWithClass(`ge-table-${i.areaIdent}-${s}-selected-range`, a)
1609
+ );
1610
+ this.dom.setStyle(u, "left", `${l}px`), this.dom.setStyle(u, "top", `${d}px`), this.dom.setStyle(u, "width", `${h}px`), this.dom.setStyle(u, "height", `${p}px`);
1611
+ }
1612
+ }
1613
+ }
1614
+ return g;
1615
+ }
1616
+ renderCell({
1617
+ areaModel: e,
1618
+ areaIdent: t,
1619
+ sideIdent: s,
1620
+ rowIndex: i,
1621
+ columnIndex: o,
1622
+ left: r,
1623
+ top: a,
1624
+ width: l,
1625
+ height: d,
1626
+ parent: h,
1627
+ cellSelected: p,
1628
+ lastRowOfModel: g,
1629
+ gammaRange: S
1630
+ }) {
1631
+ const [c, b] = this.addAndRenderCellDiv({
1632
+ areaModel: e,
1633
+ areaIdent: t,
1634
+ sideIdent: s,
1635
+ rowIndex: i,
1636
+ index: o,
1637
+ left: r,
1638
+ width: l,
1639
+ height: d,
1640
+ top: a,
1641
+ parent: h,
1642
+ lastRowOfModel: g,
1643
+ gammaRange: S
1644
+ });
1645
+ p && this.dom.addClass(`ge-table-${t}-${s}-selected-range`, c), b && this.cleanupFunctions[t].push(b);
1646
+ }
1647
+ renderHeaderCellResizeHandle({ rowIndex: e, columnIndex: t, cellLeft: s, cellTop: i, cellWidth: o, cellHeight: r, parent: a }) {
1648
+ const l = this.dom.domService, d = this.tableOptions.columnResizeHandleWidthInPx ?? 2, h = l.createElement("div");
1649
+ l.setAttribute(h, "data-col-index", `${t}`), l.setAttribute(h, "data-row-index", `${e}`), l.setAttribute(h, "data-area", "header"), l.setAttribute(h, "data-ge-action", "resize-column"), l.addClass(h, "ge-table-column-resize-handle"), l.setStyle(h, "display", "clip"), l.setStyle(h, "position", "absolute"), l.setStyle(h, "cursor", "col-resize"), l.setStyle(h, "left", `${s + o - d}px`), l.setStyle(h, "top", `${i}px`), l.setStyle(h, "width", `${d}px`), l.setStyle(h, "height", `${r}px`), l.appendChild(a, h);
1650
+ }
1651
+ }
1652
+ class He {
1653
+ constructor(e, t) {
1654
+ this.columnIndex = e, this.sortState = t;
1655
+ }
1656
+ }
1657
+ class Ve {
1658
+ constructor(e) {
1659
+ this.tableScope = e, this.tableScope.hostElement.addEventListener("change", this.onHostElementChanged.bind(this));
1660
+ }
1661
+ onHostElementChanged(e) {
1662
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement || e.target instanceof HTMLTextAreaElement) {
1663
+ const t = e.target, s = t.getAttribute("data-area"), i = t.getAttribute("data-row-index"), o = t.getAttribute("data-col-index");
1664
+ if (s && i && o) {
1665
+ const r = K(s), a = Number(i), l = Number(o);
1666
+ this.tableScope.updateModelValueAfterEdit(r, a, l, t.value);
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ class We {
1672
+ constructor(e = -1, t = -1) {
1673
+ this.rowIndex = e, this.columnIndex = t;
1674
+ }
1675
+ }
1676
+ class q {
1677
+ constructor(e) {
1678
+ this.cells = e;
1679
+ }
1680
+ static createSingle(e, t) {
1681
+ return new q([new We(e, t)]);
1682
+ }
1683
+ }
1684
+ class Ge {
1685
+ constructor(e) {
1686
+ var t, s;
1687
+ this.tableScope = e, (t = this.tableScope.tableOptions) != null && t.getSelectionModel && (this.getSelectionModel = this.tableScope.tableOptions.getSelectionModel), (s = this.tableScope.tableOptions) != null && s.getFocusModel && (this.getFocusModel = this.tableScope.tableOptions.getFocusModel);
1688
+ }
1689
+ onMouseClicked(e, t) {
1690
+ var o, r, a, l, d, h, p;
1691
+ let s = !1, i = !1;
1692
+ if (this.getSelectionModel && this.getFocusModel) {
1693
+ const g = this.getSelectionModel(), S = this.getFocusModel();
1694
+ g && S && (S.hasFocus(e.rowIndex, e.columnIndex) || (S.setFocus(e.rowIndex, e.columnIndex), s = !0), (o = e.originalEvent) != null && o.shiftKey || g.hasSelection() && (g.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (g.addSelection(this.createRangeByEvents(e, this.previousEvt)), i = !0, s = !0) : (a = e.originalEvent) != null && a.ctrlKey || (l = e.originalEvent) != null && l.metaKey ? (g.addSelection(A.singleCell(e.rowIndex, e.columnIndex)), i = !0, s = !0) : (d = e.originalEvent) != null && d.altKey && ((h = e.originalEvent) != null && h.ctrlKey || (p = e.originalEvent) != null && p.metaKey) && (g.removeSelection(A.singleCell(e.rowIndex, e.columnIndex)), i = !0, s = !0));
1695
+ }
1696
+ return i ? this.previousEvt = void 0 : this.previousEvt = e == null ? void 0 : e.clone(), s;
1697
+ }
1698
+ onActionTriggered(e) {
1699
+ if (this.getSelectionModel && this.getFocusModel) {
1700
+ const t = this.getSelectionModel(), s = this.getFocusModel();
1701
+ if (t && s) {
1702
+ if (e === "SELECT_ALL")
1703
+ return t.selectAll(), this.tableScope.repaint(), !0;
1704
+ if (e === "DESELECT_ALL")
1705
+ return t.clear(), this.tableScope.repaint(), !0;
1706
+ if (e === "TOGGLE_SELECTION") {
1707
+ const [i, o] = s.getFocus();
1708
+ return t.togglePoint(i, o), this.tableScope.repaint(), !0;
1709
+ }
1710
+ }
1711
+ }
1712
+ return !1;
1713
+ }
1714
+ createRangeByEvents(e, t) {
1715
+ t || (t = e);
1716
+ const s = Math.min(e.rowIndex, t == null ? void 0 : t.rowIndex), i = Math.max(e.rowIndex, t == null ? void 0 : t.rowIndex), o = Math.min(e.columnIndex, t == null ? void 0 : t.columnIndex), r = Math.max(e.columnIndex, t == null ? void 0 : t.columnIndex);
1717
+ return A.create({
1718
+ rowIndex1: s,
1719
+ columnIndex1: o,
1720
+ rowIndex2: i,
1721
+ columnIndex2: r
1722
+ });
1723
+ }
1724
+ }
1725
+ class Ne {
1726
+ get() {
1727
+ return {
1728
+ f2: "START_EDITING",
1729
+ space: "TOGGLE_SELECTION",
1730
+ "ctrl+num_add": "SELECT_ALL",
1731
+ "ctrl+a": "SELECT_ALL",
1732
+ "ctrl+shift+a": "DESELECT_ALL",
1733
+ "ctrl+x": "DESELECT_ALL",
1734
+ "ctrl+num_subtract": "DESELECT_ALL",
1735
+ "cmd -": "DESELECT_ALL",
1736
+ arrowup: "NAVIGATE_UP",
1737
+ arrowdown: "NAVIGATE_DOWN",
1738
+ arrowleft: "NAVIGATE_LEFT",
1739
+ arrowright: "NAVIGATE_RIGHT"
1740
+ };
1741
+ }
1742
+ }
1743
+ class je {
1744
+ get() {
1745
+ return {
1746
+ f2: "START_EDITING",
1747
+ space: "TOGGLE_SELECTION",
1748
+ "ctrl+num_add": "SELECT_ALL",
1749
+ "cmd+a": "SELECT_ALL",
1750
+ "ctrl+a": "SELECT_ALL",
1751
+ "cmd+x": "DESELECT_ALL",
1752
+ "cmd+shift+a": "DESELECT_ALL",
1753
+ "ctrl+shift+a": "DESELECT_ALL",
1754
+ "ctrl+num_subtract": "DESELECT_ALL",
1755
+ "ctrl -": "DESELECT_ALL",
1756
+ arrowup: "NAVIGATE_UP",
1757
+ arrowdown: "NAVIGATE_DOWN",
1758
+ arrowleft: "NAVIGATE_LEFT",
1759
+ arrowright: "NAVIGATE_RIGHT"
1760
+ };
1761
+ }
1762
+ }
1763
+ class ze {
1764
+ constructor(e) {
1765
+ this.tableScope = e, this.shortcutActionIdMapping = {}, this.listener = [], this.listener.push(e), this.init();
1766
+ }
1767
+ addListener(e) {
1768
+ this.listener.includes(e) || this.listener.push(e);
1769
+ }
1770
+ init() {
1771
+ this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new je().get()) : Object.assign(this.shortcutActionIdMapping, new Ne().get()), Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping), this.isDebug() && console.debug("ShortcutService", this.shortcutActionIdMapping), this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this));
1772
+ }
1773
+ isMacintosh() {
1774
+ return navigator.platform.indexOf("Mac") > -1;
1775
+ }
1776
+ isDebug() {
1777
+ return this.isLocalhost();
1778
+ }
1779
+ isLocalhost() {
1780
+ return location.hostname === "localhost" || location.hostname === "127.0.0.1";
1781
+ }
1782
+ onKeyDown(e) {
1783
+ const t = this.findEnty(e);
1784
+ t && this.emit(t) && (e.preventDefault(), e.stopPropagation());
1785
+ }
1786
+ emit(e) {
1787
+ this.isDebug() && console.debug("ShortcutService emit:", e);
1788
+ let t = !1;
1789
+ for (const s of this.listener)
1790
+ s.onActionTriggered(e) && (t = !0);
1791
+ return t;
1792
+ }
1793
+ findEnty(e) {
1794
+ const t = this.getTokenByEvent(e);
1795
+ this.isDebug() && console.debug("ShortcutService tokens:", t);
1796
+ for (const s in this.shortcutActionIdMapping) {
1797
+ const i = s.replace(/opt/g, "alt").replace(/cmd/g, "meta").split(/[\+ ]/g).sort();
1798
+ if (this.areTokensEquals(t, i))
1799
+ return this.shortcutActionIdMapping[s];
1800
+ }
1801
+ }
1802
+ areTokensEquals(e, t) {
1803
+ if (e.length !== t.length || e.length === 0)
1804
+ return !1;
1805
+ for (let s = 0; s < e.length; s++)
1806
+ if (e[s] !== t[s])
1807
+ return !1;
1808
+ return !0;
1809
+ }
1810
+ getTokenByEvent(e) {
1811
+ const t = [];
1812
+ return e.altKey && t.push("alt"), e.shiftKey && t.push("shift"), e.ctrlKey && t.push("ctrl"), e.metaKey && t.push("meta"), e.code && t.push(e.code.toLowerCase().replace(/key/g, "")), t.sort();
1813
+ }
1814
+ }
1815
+ class Xe {
1816
+ onCheckboxChanged(e) {
1817
+ }
1818
+ onContextmenu(e) {
1819
+ }
1820
+ onModelChanged(e) {
1821
+ }
1822
+ onMouseClicked(e) {
1823
+ }
1824
+ onMouseDragging(e) {
1825
+ }
1826
+ onMouseDraggingEnd(e) {
1827
+ }
1828
+ onMouseMoved(e) {
1829
+ }
1830
+ }
1831
+ class Ke extends ke {
1832
+ constructor(e, t, s, i, o) {
1833
+ var r;
1834
+ if (super(
1835
+ e,
1836
+ t,
1837
+ new Ee(s),
1838
+ i
1839
+ ), this.eventListener = o, this.selectionService = new Ge(this), this.api = new Me(this), this.mouseStartAction = "", this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, o || (this.eventListener = new Xe()), (r = this.tableOptions) != null && r.autoRestoreOptions) {
1840
+ const a = this.tableOptions.autoRestoreOptions, l = a.getStorageKeyFn;
1841
+ l && (a.autoRestoreScrollPosition && (this.storeScrollPosStateService = new Fe(l)), a.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new _e(l)), a.autoRestoreSortingState && (this.storeSortingService = new $e(l)));
1842
+ }
1843
+ this.mouseHandler = new Re(this), this.inputHandler = new Ve(this), this.shortcutService = new ze(this), this.shortcutService.addListener(this.selectionService);
1844
+ }
1845
+ onActionTriggered(e) {
1846
+ if (e === "NAVIGATE_DOWN" && this.changeFocusCell(0, 1) || e === "NAVIGATE_UP" && this.changeFocusCell(0, -1) || e === "NAVIGATE_LEFT" && this.changeFocusCell(-1, 0) || e === "NAVIGATE_RIGHT" && this.changeFocusCell(1, 0))
1847
+ return !0;
1848
+ if (e === "START_EDITING" && this.getFocusModel) {
1849
+ const t = this.getFocusModel();
1850
+ if (t) {
1851
+ const [s, i] = t.getFocus();
1852
+ this.tableModel.getBodyModel().isEditable(s, i) && (this.clearSelection(), this.initRenderEditor(s, i));
1853
+ }
1854
+ return !0;
1855
+ }
1856
+ return !1;
1857
+ }
1858
+ updateModelValueAfterEdit(e, t, s, i) {
1859
+ e === "body" && this.tableModel.getAreaModel(e).setValue(t, s, i) && (this.resetEditorRenderer(), this.repaint(), this.eventListener.onModelChanged(q.createSingle(t, s)), this.hostElement.focus());
1860
+ }
1861
+ getApi() {
1862
+ return this.api;
1863
+ }
1864
+ /*
1865
+ * Called by the table component
1866
+ */
1867
+ firstInit() {
1868
+ var e;
1869
+ this.tableModel.init(), (e = this.tableOptions) != null && e.externalFilterFunction && this.externalFilterChanged(!1), this.autoRestoreCollapsedExpandedState(), this.autoRestoreSortingState(), this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows(), this.autoRestoreScrollPosition();
1870
+ }
1871
+ createGeMouseEvent(e) {
1872
+ const t = new X();
1873
+ if (t.originalEvent = e, e) {
1874
+ const s = e.target;
1875
+ if ([t.areaIdent, t.sideIdent] = this.getAreaAndSideIdentByAttr(s), t.rowIndex = this.getNumberByAttr(s, "data-row-index"), t.columnIndex = this.getNumberByAttr(s, "data-col-index"), t.action = this.getStringByAttr(s, "data-ge-action"), t.areaIdent) {
1876
+ const i = this.tableModel.getAreaModel(t.areaIdent);
1877
+ t.rowTop = i.getYPosByRowIndex(t.rowIndex);
1878
+ }
1879
+ if (t.columnLeft = this.tableModel.getXPosByColumnIndex(t.columnIndex), e.ctrlKey && e.altKey) {
1880
+ const i = e.clientY - this.hostElement.offsetTop - this.areaHeaderCenter.parent.clientHeight, o = e.clientX - this.hostElement.offsetLeft - this.areaBodyWestGeo.width;
1881
+ this.debugOnce(o, i);
1882
+ }
1883
+ }
1884
+ return t;
1885
+ }
1886
+ onMouseDown(e) {
1887
+ e.columnIndex > -1 && e.action && ["resize-column", "drag-column"].includes(e.action) && (this.mouseStartWidth = this.tableModel.getColumnWidth(e.columnIndex), this.mouseStartAction = e.action, this.mouseStartColumnIndex = e.columnIndex, this.mouseStartAction === "drag-column" && (this.dragFrom = this.mouseStartColumnIndex));
1888
+ }
1889
+ mouseDraggingOnFrame(e) {
1890
+ this.eventListener.onMouseDragging(e), this.mouseEvent = e, this.mouseStartColumnIndex > -1 && this.mouseStartAction === "resize-column" && this.tableOptions.columnsResizable ? this.resizeColumn(e) : this.mouseStartAction === "drag-column" && e.columnIndex > -1 && this.tableOptions.columnsDraggable && (this.draggingTargetColumnIndex = e.columnIndex, this.dragTo = this.draggingTargetColumnIndex, this.dragFrom > -1 && this.dragTo > -1 && this.dragFrom !== this.dragTo && (this.tableModel.changeColumnOrder(this.dragFrom, this.dragTo), this.dragFrom = this.dragTo, this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows()), this.repaint());
1891
+ }
1892
+ mouseDraggingEndOnFrame(e) {
1893
+ this.eventListener.onMouseDraggingEnd(e), this.draggingTargetColumnIndex = -1, this.mouseStartAction === "resize-column" ? this.resizeColumn(e) : this.mouseStartAction === "drag-column" && this.repaint(), this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, this.mouseStartAction = "";
1894
+ }
1895
+ mouseMove(e) {
1896
+ this.eventListener.onMouseMoved(e), this.adjustHoverRows(e), this.adjustHoverColumns(e);
1897
+ }
1898
+ contextmenu(e) {
1899
+ this.eventListener.onContextmenu(e);
1900
+ }
1901
+ toggleExpandCollapseAll(e = !0) {
1902
+ var s;
1903
+ const t = this.tableModel.getBodyModel();
1904
+ t instanceof j && (t.toggleExpandCollapseAll(e), this.repaint(), (s = this.storeStateCollapsedExpandService) == null || s.collapsedStateAll(e));
1905
+ }
1906
+ toggleRowCheckbox(e, t, s) {
1907
+ var l;
1908
+ const i = this.tableModel.getAreaModel(s), o = i.isRowChecked(e), r = o === void 0 || o === "semi" || o === "none";
1909
+ i.setRowChecked(e, r), this.repaint();
1910
+ const a = (l = i.rowSelectionModel) == null ? void 0 : l.getCheckedRows();
1911
+ this.eventListener.onCheckboxChanged(a || []);
1912
+ }
1913
+ onMouseClicked(e, t) {
1914
+ let s = this.selectionService.onMouseClicked(e, t);
1915
+ if (!s && this.getFocusModel) {
1916
+ const i = this.getFocusModel();
1917
+ i && (s = i.hasChanged(), i.clearChanged(), s && this.resetEditorRenderer());
1918
+ }
1919
+ this.eventListener.onMouseClicked(e), s && this.debounce(this.repaint.bind(this), 10);
1920
+ }
1921
+ externalFilterChanged(e = !0) {
1922
+ const t = this.tableOptions.externalFilterFunction;
1923
+ t && (e && this.clearSelectionModel(), this.tableModel.externalFilterChanged(t), this.scrollViewport.scrollTo(0, 0), this.tableModel.recalcHeightAndPadding(), this.resetSizeOfWrapperDiv(), this.repaint());
1924
+ }
1925
+ onHeaderDblClicked(e, t, s) {
1926
+ var o, r;
1927
+ const i = this.tableModel.getColumnDef(s);
1928
+ if (i != null && i.sortable && i.sortable()) {
1929
+ e.preventDefault(), e.stopPropagation();
1930
+ const a = i.sortStatesOrder ? i.sortStatesOrder : this.tableOptions.sortOrder, l = i.sortState ?? "", d = a[(a.indexOf(l) + 1) % a.length], h = new He(s, d);
1931
+ this.tableModel.doSort([h]) && ((o = this.tableModel.getColumnDefs()) == null || o.forEach((g) => g.sortState = ""), i.sortState = d), this.repaint(), (r = this.storeSortingService) == null || r.setSortItems([h]);
1932
+ }
1933
+ }
1934
+ changeFocusCell(e, t) {
1935
+ if (!this.isEditing() && this.getFocusModel) {
1936
+ const s = this.getFocusModel();
1937
+ if (s) {
1938
+ const [i, o] = s.getFocus();
1939
+ return s.setFocus(i + t, o + e), this.repaint(), !0;
1940
+ }
1941
+ }
1942
+ return !1;
1943
+ }
1944
+ resizeColumn(e) {
1945
+ this.tableModel.setColumnWidth(this.mouseStartColumnIndex, this.mouseStartWidth + e.draggingX), this.tableModel.recalcPadding(), this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows();
1946
+ }
1947
+ clearSelectionModel() {
1948
+ var e;
1949
+ this.getSelectionModel && ((e = this.getSelectionModel()) == null || e.clear());
1950
+ }
1951
+ debugOnce(e, t) {
1952
+ var s;
1953
+ console.clear(), console.info("this.hostElement.offsetTop", this.hostElement.offsetTop), console.info("this.hostElement.scrollHeight", this.hostElement.scrollHeight), console.info("this.scrollViewportTop", this.scrollTop), console.info("this.areaHeaderCenter.parent.clientHeight", this.areaHeaderCenter.parent.clientHeight), console.info("bodyY", t), console.info("bodyX", e), console.info("rows", this.firstVisibleRowIndex), console.info(""), console.info("this.tableModel", this.tableModel), console.info(""), console.info("this.mouseMoveEvent.clientX", (s = this.mouseHandler.mouseEvent) == null ? void 0 : s.clientX), console.info("this.hostElement.offsetLeft", this.hostElement.offsetLeft), console.info("this.areaBodyWestGeo.width", this.areaBodyWestGeo.width);
1954
+ }
1955
+ autoRestoreScrollPosition() {
1956
+ var e;
1957
+ if ((e = this.tableOptions) != null && e.autoRestoreOptions && this.storeScrollPosStateService && this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition) {
1958
+ const s = this.storeScrollPosStateService.getScrollOffset();
1959
+ s && this.scrollViewport.scrollTo(...s);
1960
+ }
1961
+ }
1962
+ autoRestoreSortingState() {
1963
+ var e, t;
1964
+ if ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.autoRestoreSortingState && this.storeSortingService) {
1965
+ const s = this.storeSortingService.getSortItems();
1966
+ s != null && s.length && this.tableModel.getBodyModel().doSort(s);
1967
+ }
1968
+ }
1969
+ autoRestoreCollapsedExpandedState() {
1970
+ var e, t;
1971
+ if ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.getRowId && this.storeStateCollapsedExpandService) {
1972
+ const s = this.tableOptions.autoRestoreOptions, i = s.getRowId;
1973
+ if (s.autoRestoreCollapsedExpandedState && i) {
1974
+ const o = this.storeStateCollapsedExpandService.collapsedExpandedStateGet(), r = this.tableModel.getAreaModel("body");
1975
+ if (r instanceof j) {
1976
+ const a = r, l = r.getRowCount();
1977
+ for (let d = 0; d < l; d++) {
1978
+ const h = r.getRowByIndex(d);
1979
+ if (h)
1980
+ if (o.allExpanded)
1981
+ h.expanded = !0;
1982
+ else if (o.allCollapsed)
1983
+ h.expanded = !1;
1984
+ else {
1985
+ const p = i(h.data);
1986
+ o.mode === "expanded" ? h.expanded = this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p) : o.mode === "collapsed" && (h.expanded = !this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(p));
1987
+ }
1988
+ }
1989
+ a.recalcVisibleTreeRows();
1990
+ }
1991
+ }
1992
+ }
1993
+ }
1994
+ }
1995
+ class Ye {
1996
+ render(e, t, s, i, o, r, a) {
1997
+ if (o.isEditable(t, s)) {
1998
+ a.addClass(e, "ge-table-row-input-div");
1999
+ const l = o.getValueAt(t, s);
2000
+ e.innerHTML = `
2001
+ <input
2002
+ type="text"
2003
+ value="${l}"
2004
+ autofocus
2005
+ onfocus="this.setSelectionRange(0, this.value.length)"
2006
+ data-listen="change"
2007
+ data-area="${i}"
2008
+ data-row-index="${t}"
2009
+ data-col-index="${s}"
2010
+ data-input-type="text"
2011
+ style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
2012
+ class="ge-table-cell-editor-input">`;
2013
+ }
2014
+ }
2015
+ }
2016
+ class qe {
2017
+ constructor(e = "none", t = "single") {
2018
+ this.selectionType = e, this.selectionMode = t, this.ranges = [], this.negativeRanges = [], this.allSelected = !1;
2019
+ }
2020
+ getSelectionCount(e, t) {
2021
+ let s = 0;
2022
+ for (const i of this.ranges)
2023
+ i.isInRange(e, t) && s++;
2024
+ return this.allSelected && s++, this.isInNegativeRange(e, t) && (s = 0), s;
2025
+ }
2026
+ isInNegativeRange(e, t) {
2027
+ for (const s of this.negativeRanges)
2028
+ if (s.isInRange(e, t))
2029
+ return !0;
2030
+ return !1;
2031
+ }
2032
+ getRanges() {
2033
+ return this.ranges;
2034
+ }
2035
+ clear() {
2036
+ this.ranges = [], this.negativeRanges = [], this.allSelected = !1;
2037
+ }
2038
+ hasSelection() {
2039
+ return !!this.ranges.length;
2040
+ }
2041
+ selectAll() {
2042
+ this.allSelected = !0;
2043
+ }
2044
+ addSelection(e) {
2045
+ this.addRange(e);
2046
+ }
2047
+ removeSelection(e) {
2048
+ if (this.selectionType === "none")
2049
+ return;
2050
+ let t = e;
2051
+ this.selectionType === "row" ? t = A.singleRow(e.r1) : this.selectionType === "column" && (t = A.singleColumn(e.c1)), this.negativeRanges.push(t);
2052
+ }
2053
+ togglePoint(e, t) {
2054
+ this.getSelectionCount(e, t) > 0 ? this.removeSelection(A.singleCell(e, t)) : this.addSelection(A.singleCell(e, t));
2055
+ }
2056
+ addRange(e) {
2057
+ this.selectionType !== "none" && (this.allSelected = !1, this.selectionMode === "single" && (this.ranges = []), this.selectionType === "row" ? (e.c1 = 0, e.c2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "column" ? (e.r1 = 0, e.r2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "cell" ? (e.r2 = e.r1, e.c2 = e.c1) : this.selectionType, this.ranges.push(e));
2058
+ }
2059
+ }
2060
+ class Ue {
2061
+ constructor(e = "none") {
2062
+ this.selectionType = e, this.rowIndex = -1, this.columnIndex = -1, this.changed = !1;
2063
+ }
2064
+ clearChanged() {
2065
+ this.changed = !1;
2066
+ }
2067
+ hasChanged() {
2068
+ return this.changed;
2069
+ }
2070
+ clear() {
2071
+ this.rowIndex = -1, this.columnIndex = -1;
2072
+ }
2073
+ setFocus(e, t) {
2074
+ (this.rowIndex !== e || this.columnIndex !== t) && (this.rowIndex = e, this.columnIndex = t, this.changed = !0);
2075
+ }
2076
+ hasFocus(e, t) {
2077
+ return this.rowIndex === e && this.columnIndex === t;
2078
+ }
2079
+ getFocus() {
2080
+ return [this.rowIndex, this.columnIndex];
2081
+ }
2082
+ }
2083
+ const Je = new qe(), Qe = new Ue("cell");
2084
+ class Ze {
2085
+ constructor() {
2086
+ this.overflowX = "auto", this.overflowY = "auto", this.horizontalBorderVisible = !0, this.verticalBorderVisible = !0, this.footerSeparatorBorderVisible = !0, this.headerSeparatorBorderVisible = !0, this.fixedEastSeparatorBorderVisible = !0, this.fixedWestSeparatorBorderVisible = !0, this.tableTopBorderVisible = !0, this.tableBottomBorderVisible = !0, this.hoverRowVisible = !0, this.hoverColumnVisible = !0, this.columnsResizable = !0, this.columnsDraggable = !0, this.columnResizeHandleWidthInPx = 4, this.defaultRowHeights = {
2087
+ header: 34,
2088
+ body: 34,
2089
+ footer: 34
2090
+ }, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new ie(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new oe(), this.sortOrder = ["asc", "desc"], this.getEditRenderer = (e, t) => new Ye(), this.getSelectionModel = () => Je, this.getFocusModel = () => Qe;
2091
+ }
2092
+ }
2093
+ class et {
2094
+ setStyle(e, t, s) {
2095
+ return e.style[t] = s, e;
2096
+ }
2097
+ appendText(e, t) {
2098
+ const s = this.createText(t);
2099
+ return this.appendChild(e, s), s;
2100
+ }
2101
+ addClass(e, t) {
2102
+ return t.includes(" ") ? t.split(" ").forEach((s) => e.classList.add(s)) : e.classList.add(t), e;
2103
+ }
2104
+ appendChild(e, t) {
2105
+ e.appendChild(t);
2106
+ }
2107
+ createElement(e) {
2108
+ return document.createElement(e);
2109
+ }
2110
+ createText(e) {
2111
+ return document.createTextNode(e);
2112
+ }
2113
+ setAttribute(e, t, s) {
2114
+ e.setAttribute(t, s);
2115
+ }
2116
+ }
2117
+ function tt(n) {
2118
+ let e;
2119
+ return {
2120
+ c() {
2121
+ e = he("div"), ce(e, "class", "ge-table"), $(e, "width", "100%"), $(e, "height", "100%"), $(e, "background-color", "transparent"), $(e, "padding", "0"), $(e, "margin", "0");
2122
+ },
2123
+ m(t, s) {
2124
+ de(t, e, s), n[3](e);
2125
+ },
2126
+ p: O,
2127
+ i: O,
2128
+ o: O,
2129
+ d(t) {
2130
+ t && te(e), n[3](null);
2131
+ }
2132
+ };
2133
+ }
2134
+ function st(n, e, t) {
2135
+ let { tableModel: s } = e, { tableOptions: i = new Ze() } = e, o;
2136
+ const r = re();
2137
+ le(() => {
2138
+ const l = {
2139
+ onCheckboxChanged: (h) => {
2140
+ r("checkboxChanged", h);
2141
+ },
2142
+ onContextmenu: (h) => {
2143
+ r("contextmenu", h);
2144
+ },
2145
+ onModelChanged: (h) => {
2146
+ r("modelChanged", h);
2147
+ },
2148
+ onMouseClicked: (h) => {
2149
+ r("mouseClicked", h);
2150
+ },
2151
+ onMouseDragging: (h) => {
2152
+ r("mouseDragging", h);
2153
+ },
2154
+ onMouseDraggingEnd: (h) => {
2155
+ r("mouseDraggingEnd", h);
2156
+ },
2157
+ onMouseMoved: (h) => {
2158
+ r("mouseMoved", h);
2159
+ }
2160
+ }, d = new Ke(o, s, new et(), i, l);
2161
+ d.firstInit(), r("tableReady", d.getApi());
2162
+ });
2163
+ function a(l) {
2164
+ V[l ? "unshift" : "push"](() => {
2165
+ o = l, t(0, o);
2166
+ });
2167
+ }
2168
+ return n.$$set = (l) => {
2169
+ "tableModel" in l && t(1, s = l.tableModel), "tableOptions" in l && t(2, i = l.tableOptions);
2170
+ }, [o, s, i, a];
2171
+ }
2172
+ class ot extends Ce {
2173
+ constructor(e) {
2174
+ super(), ve(this, e, st, tt, ne, { tableModel: 1, tableOptions: 2 });
2175
+ }
2176
+ }
2177
+ class rt {
2178
+ constructor(e) {
2179
+ this.Component = e;
2180
+ }
2181
+ render(e, t, s, i, o, r, a) {
2182
+ const l = new this.Component({
2183
+ target: e,
2184
+ props: {
2185
+ cellDiv: e,
2186
+ rowIndex: t,
2187
+ columnIndex: s,
2188
+ areaIdent: i,
2189
+ areaModel: o,
2190
+ cellValue: r
2191
+ }
2192
+ });
2193
+ return () => {
2194
+ l.$destroy();
2195
+ };
2196
+ }
2197
+ }
2198
+ export {
2199
+ rt as ComponentRendererWrapper,
2200
+ ot as GuiexpertTable
2201
+ };