@guiexpert/vue3-table 1.0.9 → 1.0.13

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