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