@guiexpert/svelte-table 1.0.10 → 4.0.1

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