@guiexpert/vue3-table 3.0.1 → 3.0.3

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