@guiexpert/vue3-table 1.0.9 → 1.0.14
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/GuiexpertTablePlugin.d.ts +10 -0
- package/GuiexpertTablePlugin.d.ts.map +1 -0
- package/components/ComponentRendererWrapper.d.ts +10 -0
- package/components/ComponentRendererWrapper.d.ts.map +1 -0
- package/components/GuiexpertTable.vue.d.ts +4 -0
- package/components/GuiexpertTable.vue.d.ts.map +1 -0
- package/components/index.d.ts +3 -0
- package/components/index.d.ts.map +1 -0
- package/favicon.ico +0 -0
- package/index.cjs +20 -0
- package/index.js +2999 -0
- package/main.d.ts +2 -0
- package/main.d.ts.map +1 -0
- package/package.json +6 -3
- package/style.css +1 -0
- package/README.md +0 -102
- package/index.cjs.js +0 -20
- package/index.es.js +0 -2060
- package/vue3-table.cjs.js +0 -20
- package/vue3-table.es.js +0 -2060
- package/vue3-table.umd.js +0 -20
package/index.js
ADDED
|
@@ -0,0 +1,2999 @@
|
|
|
1
|
+
import { defineComponent, ref, onMounted, openBlock, createElementBlock } from "vue";
|
|
2
|
+
class GeMouseEvent {
|
|
3
|
+
constructor(rowIndex = -1, rowTop = -1, columnIndex = -1, columnLeft = -1, areaIdent, sideIdent, originalEvent, clickCount = 0, draggingX = 0, draggingY = 0, action = "") {
|
|
4
|
+
this.rowIndex = rowIndex;
|
|
5
|
+
this.rowTop = rowTop;
|
|
6
|
+
this.columnIndex = columnIndex;
|
|
7
|
+
this.columnLeft = columnLeft;
|
|
8
|
+
this.areaIdent = areaIdent;
|
|
9
|
+
this.sideIdent = sideIdent;
|
|
10
|
+
this.originalEvent = originalEvent;
|
|
11
|
+
this.clickCount = clickCount;
|
|
12
|
+
this.draggingX = draggingX;
|
|
13
|
+
this.draggingY = draggingY;
|
|
14
|
+
this.action = action;
|
|
15
|
+
}
|
|
16
|
+
clone() {
|
|
17
|
+
return new GeMouseEvent(this.rowIndex, this.rowTop, this.columnIndex, this.columnLeft, this.areaIdent, this.sideIdent, this.originalEvent, this.clickCount, this.draggingX, this.draggingY, this.action);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class Icon {
|
|
21
|
+
constructor(content = ">", style = "", classes = []) {
|
|
22
|
+
this.content = content;
|
|
23
|
+
this.style = style;
|
|
24
|
+
this.classes = classes;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class TreeOptions {
|
|
28
|
+
constructor(arrowExpanded = new Icon(">", "transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;", ["gt-table-tree-arrow-expanded"]), arrowCollapsed = new Icon(">", "", ["ge-table-tree-arrow-collapsed"]), arrowPlaceholder = new Icon(">", "color:transparent;", ["gt-table-tree-arrow-hidden"]), arrowExpandCollapseAll = new Icon("\u2195", "", ["gt-table-tree-arrow-expanded-all"])) {
|
|
29
|
+
this.arrowExpanded = arrowExpanded;
|
|
30
|
+
this.arrowCollapsed = arrowCollapsed;
|
|
31
|
+
this.arrowPlaceholder = arrowPlaceholder;
|
|
32
|
+
this.arrowExpandCollapseAll = arrowExpandCollapseAll;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class SortedOptions {
|
|
36
|
+
constructor(iconAsc = new Icon("\u2191", "", ["ge-header-sorted-asc"]), iconDesc = new Icon("\u2193", "", ["ge-header-sorted-desc"]), iconPlaceholder = new Icon("\u2191", "color:transparent;", [])) {
|
|
37
|
+
this.iconAsc = iconAsc;
|
|
38
|
+
this.iconDesc = iconDesc;
|
|
39
|
+
this.iconPlaceholder = iconPlaceholder;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class ConvenienceDomService {
|
|
43
|
+
constructor(domService) {
|
|
44
|
+
this.domService = domService;
|
|
45
|
+
}
|
|
46
|
+
setStyle(el, style, value) {
|
|
47
|
+
this.domService.setStyle(el, style, value);
|
|
48
|
+
return el;
|
|
49
|
+
}
|
|
50
|
+
applyStyle(ele, style) {
|
|
51
|
+
for (const key in style) {
|
|
52
|
+
this.domService.setStyle(ele, key, style[key]);
|
|
53
|
+
}
|
|
54
|
+
return ele;
|
|
55
|
+
}
|
|
56
|
+
applyDisplayNoneStyle(ele) {
|
|
57
|
+
this.domService.setStyle(ele, "display", "none");
|
|
58
|
+
return ele;
|
|
59
|
+
}
|
|
60
|
+
applyDisplayBlockStyle(ele) {
|
|
61
|
+
this.domService.setStyle(ele, "display", "block");
|
|
62
|
+
return ele;
|
|
63
|
+
}
|
|
64
|
+
applyStyleInPx(ele, geoData) {
|
|
65
|
+
Object.entries(geoData).forEach(([key, value]) => this.domService.setStyle(ele, key, value + "px"));
|
|
66
|
+
return ele;
|
|
67
|
+
}
|
|
68
|
+
applyStylePosistionRelative(ele) {
|
|
69
|
+
this.domService.setStyle(ele, "position", "relative");
|
|
70
|
+
this.domService.setStyle(ele, "overflow", "clip");
|
|
71
|
+
return ele;
|
|
72
|
+
}
|
|
73
|
+
applyStylePosistionAbsolute(ele) {
|
|
74
|
+
this.domService.setStyle(ele, "position", "absolute");
|
|
75
|
+
return ele;
|
|
76
|
+
}
|
|
77
|
+
applyStyleFullSize(ele) {
|
|
78
|
+
this.domService.setStyle(ele, "width", "100%");
|
|
79
|
+
this.domService.setStyle(ele, "height", "100%");
|
|
80
|
+
return ele;
|
|
81
|
+
}
|
|
82
|
+
applyStyleOverflowAuto(overflowX = "auto", overflowY = "auto", ele) {
|
|
83
|
+
this.domService.setStyle(ele, "overflow-x", overflowX);
|
|
84
|
+
this.domService.setStyle(ele, "overflow-y", overflowY);
|
|
85
|
+
return ele;
|
|
86
|
+
}
|
|
87
|
+
applyStyleNoPadding(ele) {
|
|
88
|
+
this.domService.setStyle(ele, "padding", "0");
|
|
89
|
+
this.domService.setStyle(ele, "margin", "0");
|
|
90
|
+
this.domService.setStyle(ele, "border", "0");
|
|
91
|
+
return ele;
|
|
92
|
+
}
|
|
93
|
+
appendRelativeChildDiv(parent) {
|
|
94
|
+
const child = this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));
|
|
95
|
+
this.domService.appendChild(parent, child);
|
|
96
|
+
this.applyStylePosistionAbsolute(parent);
|
|
97
|
+
const cache = {};
|
|
98
|
+
return { parent, child, cache };
|
|
99
|
+
}
|
|
100
|
+
appendText(parent, text) {
|
|
101
|
+
const div = this.domService.createText(text);
|
|
102
|
+
this.domService.appendChild(parent, div);
|
|
103
|
+
return div;
|
|
104
|
+
}
|
|
105
|
+
addClass(clazz, div) {
|
|
106
|
+
if (clazz.includes(" ")) {
|
|
107
|
+
clazz.split(" ").forEach((c) => this.domService.addClass(div, c));
|
|
108
|
+
} else {
|
|
109
|
+
this.domService.addClass(div, clazz);
|
|
110
|
+
}
|
|
111
|
+
return div;
|
|
112
|
+
}
|
|
113
|
+
addClasses(classes, div) {
|
|
114
|
+
if (classes) {
|
|
115
|
+
for (const c of classes) {
|
|
116
|
+
this.domService.addClass(div, c);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return div;
|
|
120
|
+
}
|
|
121
|
+
setAttribute(div, key, value) {
|
|
122
|
+
if (key && value) {
|
|
123
|
+
this.domService.setAttribute(div, key, value);
|
|
124
|
+
}
|
|
125
|
+
return div;
|
|
126
|
+
}
|
|
127
|
+
createAreaDivWithClass(clazz, parent, areaIdent, sideIdent) {
|
|
128
|
+
const div = this.domService.createElement("div");
|
|
129
|
+
this.addClass(clazz, div);
|
|
130
|
+
this.domService.setAttribute(div, "data-area", areaIdent);
|
|
131
|
+
this.domService.setAttribute(div, "data-side", sideIdent);
|
|
132
|
+
this.domService.appendChild(parent, div);
|
|
133
|
+
return div;
|
|
134
|
+
}
|
|
135
|
+
createDivWithClass(clazz, parent) {
|
|
136
|
+
const div = this.domService.createElement("div");
|
|
137
|
+
this.addClass(clazz, div);
|
|
138
|
+
this.domService.appendChild(parent, div);
|
|
139
|
+
return div;
|
|
140
|
+
}
|
|
141
|
+
addRowDiv(divScope, geo, rowIndex = -1, areaIdent, sideIdent, text = "") {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const cacheKey = (_a = geo.index) !== null && _a !== void 0 ? _a : -1;
|
|
144
|
+
const div = this.getDivOrCreateDiv(cacheKey, divScope);
|
|
145
|
+
this.domService.addClass(div, "ge-table-row-div");
|
|
146
|
+
this.domService.addClass(div, `ge-table-row-div-${geo.index}`);
|
|
147
|
+
if (areaIdent === "body" && sideIdent === "center") {
|
|
148
|
+
const oddEven = ((_b = geo === null || geo === void 0 ? void 0 : geo.index) !== null && _b !== void 0 ? _b : 0) % 2 === 0 ? "even" : "odd";
|
|
149
|
+
this.domService.addClass(div, `ge-table-row-${oddEven}`);
|
|
150
|
+
}
|
|
151
|
+
this.domService.setStyle(div, "display", "clip");
|
|
152
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
153
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
154
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
155
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
156
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
157
|
+
this.domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
158
|
+
this.domService.setAttribute(div, "data-area", `${areaIdent}`);
|
|
159
|
+
if (text) {
|
|
160
|
+
const textElement = this.domService.createText(text);
|
|
161
|
+
this.domService.appendChild(div, textElement);
|
|
162
|
+
}
|
|
163
|
+
this.domService.appendChild(divScope.child, div);
|
|
164
|
+
return div;
|
|
165
|
+
}
|
|
166
|
+
addColumnDiv(parent, geo, rowIndex = -1, columnIndex = -1, areaIdent, sideIdent, text = "", treeArrow, tableOptions, checkedType = void 0, sortState) {
|
|
167
|
+
var _a;
|
|
168
|
+
const treeOptions = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.treeOptions;
|
|
169
|
+
const checkboxWithoutExtraColumn = tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.showCheckboxWihoutExtraColumn;
|
|
170
|
+
const div = this.domService.createElement("div");
|
|
171
|
+
this.domService.addClass(div, "ge-table-col-div");
|
|
172
|
+
this.domService.addClass(div, `ge-table-col-div-${geo.index}`);
|
|
173
|
+
this.domService.setAttribute(div, "data-col-index", `${geo.index}`);
|
|
174
|
+
this.domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
175
|
+
this.domService.setAttribute(div, "data-area", `${areaIdent}`);
|
|
176
|
+
const oddEven = ((_a = geo === null || geo === void 0 ? void 0 : geo.index) !== null && _a !== void 0 ? _a : 0) % 2 === 0 ? "even" : "odd";
|
|
177
|
+
if (areaIdent === "body" && sideIdent === "center") {
|
|
178
|
+
this.domService.addClass(div, `ge-table-column-${oddEven}`);
|
|
179
|
+
}
|
|
180
|
+
this.domService.setStyle(div, "display", "clip");
|
|
181
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
182
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
183
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
184
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
185
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
186
|
+
if (treeArrow && treeArrow !== "none") {
|
|
187
|
+
this.domService.addClass(div, "ge-table-col-tree");
|
|
188
|
+
this.addArrowDiv(div, treeArrow, treeOptions, rowIndex, columnIndex, areaIdent);
|
|
189
|
+
}
|
|
190
|
+
if (checkboxWithoutExtraColumn && columnIndex === 0 && checkedType) {
|
|
191
|
+
this.addCheckboxToDiv(div, checkedType, areaIdent, rowIndex);
|
|
192
|
+
}
|
|
193
|
+
if (text) {
|
|
194
|
+
const firstTreeColumn = treeArrow !== "none" && columnIndex === 0;
|
|
195
|
+
this.addLabelDiv(div, text, firstTreeColumn, rowIndex, columnIndex, areaIdent);
|
|
196
|
+
}
|
|
197
|
+
if (sortState) {
|
|
198
|
+
this.addSortedIcon(div, sortState, tableOptions === null || tableOptions === void 0 ? void 0 : tableOptions.sortedOptions, columnIndex);
|
|
199
|
+
}
|
|
200
|
+
this.domService.appendChild(parent, div);
|
|
201
|
+
return div;
|
|
202
|
+
}
|
|
203
|
+
addCheckboxToDiv(parent, checkedType, areaIdent, rowIndex) {
|
|
204
|
+
const div = this.domService.createElement("div");
|
|
205
|
+
const checked = checkedType === "full" ? "checked" : "";
|
|
206
|
+
div.innerHTML = `
|
|
207
|
+
<input
|
|
208
|
+
type="checkbox"
|
|
209
|
+
data-area="${areaIdent}"
|
|
210
|
+
data-row-index="${rowIndex}"
|
|
211
|
+
data-input-type="checkbox"
|
|
212
|
+
${checked}
|
|
213
|
+
class="ge-table-row-checkbox"> `;
|
|
214
|
+
this.domService.setStyle(div, "display", "inline");
|
|
215
|
+
this.domService.setStyle(div, "width", "inherit");
|
|
216
|
+
this.domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
217
|
+
this.domService.appendChild(parent, div);
|
|
218
|
+
return div;
|
|
219
|
+
}
|
|
220
|
+
addLabelDiv(parent, text = "", firstTreeColumn = false, rowIndex = -1, columnIndex = -1, areaIdent = "body") {
|
|
221
|
+
const div = this.domService.createElement("div");
|
|
222
|
+
this.domService.addClass(div, "ge-table-label-div");
|
|
223
|
+
this.domService.setStyle(div, "position", "relative");
|
|
224
|
+
this.domService.setStyle(div, "background", "transparent");
|
|
225
|
+
this.domService.setStyle(div, "width", "100%");
|
|
226
|
+
this.domService.setStyle(div, "height", "100%");
|
|
227
|
+
this.domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
228
|
+
this.domService.setAttribute(div, "data-col-index", `${columnIndex}`);
|
|
229
|
+
this.domService.setAttribute(div, "data-area", `${areaIdent}`);
|
|
230
|
+
if (text) {
|
|
231
|
+
if (firstTreeColumn) {
|
|
232
|
+
const textElement = this.domService.createText(text);
|
|
233
|
+
this.domService.appendChild(div, textElement);
|
|
234
|
+
} else {
|
|
235
|
+
const div2 = this.domService.createElement("div");
|
|
236
|
+
this.domService.appendChild(div, div2);
|
|
237
|
+
const textElement = this.domService.createText(text);
|
|
238
|
+
this.domService.addClass(div2, "ge-table-label");
|
|
239
|
+
this.domService.appendChild(div2, textElement);
|
|
240
|
+
this.domService.setAttribute(div2, "data-row-index", `${rowIndex}`);
|
|
241
|
+
this.domService.setAttribute(div2, "data-col-index", `${columnIndex}`);
|
|
242
|
+
this.domService.setAttribute(div2, "data-area", `${areaIdent}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
this.domService.appendChild(parent, div);
|
|
246
|
+
return div;
|
|
247
|
+
}
|
|
248
|
+
addSortedIcon(parent, sorted = "", sortedOptions = new SortedOptions(), columnIndex = -1) {
|
|
249
|
+
const div = this.domService.createElement("div");
|
|
250
|
+
this.domService.addClass(div, "ge-table-sorted-icon-div");
|
|
251
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
252
|
+
this.domService.setStyle(div, "top", "0");
|
|
253
|
+
this.domService.setStyle(div, "right", "0");
|
|
254
|
+
this.domService.setStyle(div, "width", "20px");
|
|
255
|
+
this.domService.setStyle(div, "background", "transparent");
|
|
256
|
+
this.domService.setStyle(div, "cursor", "pointer");
|
|
257
|
+
this.domService.setAttribute(div, "data-col-index", `${columnIndex}`);
|
|
258
|
+
this.domService.setAttribute(div, "data-area", "header");
|
|
259
|
+
let treeOptionsArrow;
|
|
260
|
+
if (sorted === "asc") {
|
|
261
|
+
treeOptionsArrow = sortedOptions.iconAsc;
|
|
262
|
+
} else if (sorted === "desc") {
|
|
263
|
+
treeOptionsArrow = sortedOptions.iconDesc;
|
|
264
|
+
} else {
|
|
265
|
+
treeOptionsArrow = sortedOptions.iconPlaceholder;
|
|
266
|
+
}
|
|
267
|
+
const content = treeOptionsArrow.content;
|
|
268
|
+
const textElement = this.domService.createText(content);
|
|
269
|
+
this.domService.appendChild(div, textElement);
|
|
270
|
+
if (treeOptionsArrow.style) {
|
|
271
|
+
this.applyStyleString(div, treeOptionsArrow.style);
|
|
272
|
+
}
|
|
273
|
+
for (const clazz of treeOptionsArrow.classes) {
|
|
274
|
+
this.domService.addClass(div, clazz);
|
|
275
|
+
}
|
|
276
|
+
this.domService.appendChild(parent, div);
|
|
277
|
+
return div;
|
|
278
|
+
}
|
|
279
|
+
addArrowDiv(parent, arrow = "none", treeOptions = new TreeOptions(), rowIndex = -1, columnIndex = -1, areaIdent = "body") {
|
|
280
|
+
const div = this.domService.createElement("div");
|
|
281
|
+
this.domService.addClass(div, "ge-table-tree-arrow-div");
|
|
282
|
+
this.domService.setStyle(div, "display", "inline-block");
|
|
283
|
+
this.domService.setStyle(div, "position", "");
|
|
284
|
+
this.domService.setStyle(div, "width", "20px");
|
|
285
|
+
this.domService.setStyle(div, "background", "transparent");
|
|
286
|
+
this.domService.setStyle(div, "cursor", "pointer");
|
|
287
|
+
this.domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
288
|
+
this.domService.setAttribute(div, "data-col-index", `${columnIndex}`);
|
|
289
|
+
this.domService.setAttribute(div, "data-area", `${areaIdent}`);
|
|
290
|
+
let treeOptionsArrow;
|
|
291
|
+
if (arrow === "expanded") {
|
|
292
|
+
treeOptionsArrow = treeOptions.arrowExpanded;
|
|
293
|
+
} else if (arrow === "collapsed") {
|
|
294
|
+
treeOptionsArrow = treeOptions.arrowCollapsed;
|
|
295
|
+
} else {
|
|
296
|
+
treeOptionsArrow = treeOptions.arrowPlaceholder;
|
|
297
|
+
}
|
|
298
|
+
const content = treeOptionsArrow.content;
|
|
299
|
+
const textElement = this.domService.createText(content);
|
|
300
|
+
this.domService.appendChild(div, textElement);
|
|
301
|
+
if (treeOptionsArrow.style) {
|
|
302
|
+
this.applyStyleString(div, treeOptionsArrow.style);
|
|
303
|
+
}
|
|
304
|
+
for (const clazz of treeOptionsArrow.classes) {
|
|
305
|
+
this.domService.addClass(div, clazz);
|
|
306
|
+
}
|
|
307
|
+
this.domService.appendChild(parent, div);
|
|
308
|
+
return div;
|
|
309
|
+
}
|
|
310
|
+
addColumnBorderDivs(tableOptions, parent, geo, areaIdent, sideIdent) {
|
|
311
|
+
if (tableOptions.verticalBorderVisible) {
|
|
312
|
+
const clazz = `ge-table-${areaIdent}-${sideIdent}-vertical-border`;
|
|
313
|
+
this.addVerticalBorder(geo, parent, clazz);
|
|
314
|
+
}
|
|
315
|
+
if (tableOptions.horizontalBorderVisible) {
|
|
316
|
+
const clazz = `ge-table-${areaIdent}-${sideIdent}-horizontal-border`;
|
|
317
|
+
this.addHorizontalBorder(geo, parent, clazz);
|
|
318
|
+
}
|
|
319
|
+
return parent;
|
|
320
|
+
}
|
|
321
|
+
addHorizontalBorder(geo, parent, clazz = "ge-table-body-center-horizontal-border") {
|
|
322
|
+
const div = this.domService.createElement("div");
|
|
323
|
+
this.domService.addClass(div, clazz);
|
|
324
|
+
this.domService.setStyle(div, "display", "clip");
|
|
325
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
326
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
327
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
328
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
329
|
+
this.domService.setStyle(div, "height", `1px`);
|
|
330
|
+
this.domService.appendChild(parent, div);
|
|
331
|
+
return div;
|
|
332
|
+
}
|
|
333
|
+
addFocusBorderDivs(parent, geo, style) {
|
|
334
|
+
let div = this.domService.createElement("div");
|
|
335
|
+
this.domService.addClass(div, "ge-table-focus-border");
|
|
336
|
+
this.domService.setStyle(div, "display", "clip");
|
|
337
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
338
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
339
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
340
|
+
this.domService.setStyle(div, "width", `1px`);
|
|
341
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
342
|
+
this.applyStyle(div, style);
|
|
343
|
+
this.domService.appendChild(parent, div);
|
|
344
|
+
div = this.domService.createElement("div");
|
|
345
|
+
this.domService.addClass(div, "ge-table-focus-border");
|
|
346
|
+
this.domService.setStyle(div, "display", "clip");
|
|
347
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
348
|
+
this.domService.setStyle(div, "left", `${geo.left + geo.width - 1}px`);
|
|
349
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
350
|
+
this.domService.setStyle(div, "width", `1px`);
|
|
351
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
352
|
+
this.applyStyle(div, style);
|
|
353
|
+
this.domService.appendChild(parent, div);
|
|
354
|
+
div = this.domService.createElement("div");
|
|
355
|
+
this.domService.addClass(div, "ge-table-focus-border");
|
|
356
|
+
this.domService.setStyle(div, "display", "clip");
|
|
357
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
358
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
359
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
360
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
361
|
+
this.domService.setStyle(div, "height", `1px`);
|
|
362
|
+
this.applyStyle(div, style);
|
|
363
|
+
this.domService.appendChild(parent, div);
|
|
364
|
+
div = this.domService.createElement("div");
|
|
365
|
+
this.domService.addClass(div, "ge-table-focus-border");
|
|
366
|
+
this.domService.setStyle(div, "display", "clip");
|
|
367
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
368
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
369
|
+
this.domService.setStyle(div, "top", `${geo.top + geo.height - 1}px`);
|
|
370
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
371
|
+
this.domService.setStyle(div, "height", `1px`);
|
|
372
|
+
this.applyStyle(div, style);
|
|
373
|
+
this.domService.appendChild(parent, div);
|
|
374
|
+
return parent;
|
|
375
|
+
}
|
|
376
|
+
addVerticalBorder(geo, parent, clazz = "ge-table-body-center-vertical-border") {
|
|
377
|
+
const div = this.domService.createElement("div");
|
|
378
|
+
this.domService.addClass(div, clazz);
|
|
379
|
+
this.domService.setStyle(div, "display", "clip");
|
|
380
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
381
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
382
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
383
|
+
this.domService.setStyle(div, "width", `1px`);
|
|
384
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
385
|
+
this.domService.appendChild(parent, div);
|
|
386
|
+
return div;
|
|
387
|
+
}
|
|
388
|
+
addDiv(parent, geo, clazz = "") {
|
|
389
|
+
const div = this.domService.createElement("div");
|
|
390
|
+
if (clazz) {
|
|
391
|
+
this.domService.addClass(div, clazz);
|
|
392
|
+
}
|
|
393
|
+
this.domService.setStyle(div, "display", "clip");
|
|
394
|
+
this.domService.setStyle(div, "position", "absolute");
|
|
395
|
+
this.domService.setStyle(div, "left", `${geo.left}px`);
|
|
396
|
+
this.domService.setStyle(div, "top", `${geo.top}px`);
|
|
397
|
+
this.domService.setStyle(div, "width", `${geo.width}px`);
|
|
398
|
+
this.domService.setStyle(div, "height", `${geo.height}px`);
|
|
399
|
+
this.domService.appendChild(parent, div);
|
|
400
|
+
return div;
|
|
401
|
+
}
|
|
402
|
+
applyStyleString(div, style) {
|
|
403
|
+
const cmds = style.split(";").map((s) => s.trim()).filter((s) => s);
|
|
404
|
+
for (const cmd of cmds) {
|
|
405
|
+
const [key, value] = cmd.split(":");
|
|
406
|
+
this.domService.setStyle(div, key.trim(), value.trim());
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
getDivOrCreateDiv(cacheKey, divScope) {
|
|
410
|
+
let div = divScope.cache[cacheKey];
|
|
411
|
+
if (div) {
|
|
412
|
+
div.innerText = "";
|
|
413
|
+
return div;
|
|
414
|
+
}
|
|
415
|
+
div = this.domService.createElement("div");
|
|
416
|
+
divScope.cache[cacheKey] = div;
|
|
417
|
+
return div;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
class TreeRow {
|
|
421
|
+
constructor(data, expanded = true, children, parent, deep = 0, checked = false, keep = false) {
|
|
422
|
+
this.data = data;
|
|
423
|
+
this.expanded = expanded;
|
|
424
|
+
this.children = children;
|
|
425
|
+
this.parent = parent;
|
|
426
|
+
this.deep = deep;
|
|
427
|
+
this.checked = checked;
|
|
428
|
+
this.keep = keep;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const getAreaIdentByString = (s) => {
|
|
432
|
+
if (s === "header") {
|
|
433
|
+
return "header";
|
|
434
|
+
}
|
|
435
|
+
if (s === "footer") {
|
|
436
|
+
return "footer";
|
|
437
|
+
}
|
|
438
|
+
return "body";
|
|
439
|
+
};
|
|
440
|
+
class MouseTargetData {
|
|
441
|
+
constructor(eventTarget, tableScope) {
|
|
442
|
+
this.rowIdx = -1;
|
|
443
|
+
this.colIdx = -1;
|
|
444
|
+
this.action = null;
|
|
445
|
+
this.inputType = null;
|
|
446
|
+
this.className = "";
|
|
447
|
+
if (eventTarget === null)
|
|
448
|
+
return;
|
|
449
|
+
if (eventTarget instanceof HTMLDivElement || eventTarget instanceof HTMLSpanElement || eventTarget instanceof HTMLInputElement) {
|
|
450
|
+
this.className = eventTarget.className;
|
|
451
|
+
this.action = eventTarget.getAttribute("data-ge-action");
|
|
452
|
+
this.inputType = eventTarget.getAttribute("data-input-type");
|
|
453
|
+
this.rowIdx = Number(eventTarget.getAttribute("data-row-index"));
|
|
454
|
+
this.colIdx = Number(eventTarget.getAttribute("data-col-index"));
|
|
455
|
+
const area = eventTarget.getAttribute("data-area");
|
|
456
|
+
if (area) {
|
|
457
|
+
this.areaIdent = getAreaIdentByString(area);
|
|
458
|
+
this.areaModel = tableScope.tableModel.getAreaModel(this.areaIdent);
|
|
459
|
+
this.row = this.areaModel.getRowByIndex(this.rowIdx);
|
|
460
|
+
}
|
|
461
|
+
if (eventTarget instanceof HTMLInputElement) {
|
|
462
|
+
const target = eventTarget;
|
|
463
|
+
this.value = target.value;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
class MouseHandler {
|
|
469
|
+
constructor(tableScope) {
|
|
470
|
+
this.tableScope = tableScope;
|
|
471
|
+
this.expandedAll = true;
|
|
472
|
+
this.mouseDown = false;
|
|
473
|
+
this.dragging = false;
|
|
474
|
+
this.tableScope.hostElement.addEventListener("click", this.onHostElementClicked.bind(this));
|
|
475
|
+
this.tableScope.hostElement.addEventListener("dblclick", this.onHostElementDblClicked.bind(this));
|
|
476
|
+
this.tableScope.hostElement.addEventListener("mousedown", this.onMouseDown.bind(this));
|
|
477
|
+
this.tableScope.hostElement.addEventListener("mousemove", this.onMouseMove.bind(this));
|
|
478
|
+
this.tableScope.hostElement.addEventListener("mouseup", this.onMouseUp.bind(this));
|
|
479
|
+
this.tableScope.hostElement.addEventListener("contextmenu", this.onContextmenu.bind(this));
|
|
480
|
+
this.tableScope.hostElement["_MouseHandler"] = "true";
|
|
481
|
+
this.tableScope.scrollViewport.addEventListener("scroll", this.tableScope.adjustAfterScrolling.bind(this.tableScope));
|
|
482
|
+
[window, this.tableScope.hostElement].forEach((ele) => ele.addEventListener("resize", this.tableScope.adjustContainersAndRows.bind(this.tableScope)));
|
|
483
|
+
}
|
|
484
|
+
onContextmenu(evt) {
|
|
485
|
+
this.mouseEvent = evt;
|
|
486
|
+
const mouseMoveEvent = this.tableScope.createGeMouseEvent(this.mouseEvent);
|
|
487
|
+
this.tableScope.contextmenu(mouseMoveEvent);
|
|
488
|
+
}
|
|
489
|
+
onHostElementClicked(event) {
|
|
490
|
+
const mouseTargetData = new MouseTargetData(event.target, this.tableScope);
|
|
491
|
+
if (mouseTargetData.action === "toggleExpandCollapseAll") {
|
|
492
|
+
this.expandedAll = !this.expandedAll;
|
|
493
|
+
this.tableScope.toggleExpandCollapseAll(this.expandedAll);
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
event.stopPropagation();
|
|
496
|
+
} else if (mouseTargetData.inputType === "checkbox" && mouseTargetData.areaIdent) {
|
|
497
|
+
this.tableScope.toggleRowCheckbox(mouseTargetData.rowIdx, mouseTargetData.colIdx, mouseTargetData.areaIdent);
|
|
498
|
+
event.preventDefault();
|
|
499
|
+
event.stopPropagation();
|
|
500
|
+
} else if (mouseTargetData.row instanceof TreeRow && mouseTargetData.areaModel) {
|
|
501
|
+
const altClickOnFirstCol = mouseTargetData.colIdx === this.getArrowColumnIndex() && event.altKey;
|
|
502
|
+
const clickOnArrow = mouseTargetData.className.includes("ge-table-tree-arrow-div");
|
|
503
|
+
console.info(clickOnArrow, altClickOnFirstCol);
|
|
504
|
+
if (altClickOnFirstCol || clickOnArrow) {
|
|
505
|
+
event.preventDefault();
|
|
506
|
+
event.stopPropagation();
|
|
507
|
+
const tr = mouseTargetData.row;
|
|
508
|
+
tr.expanded = !tr.expanded;
|
|
509
|
+
if ("recalcVisibleTreeRows" in mouseTargetData.areaModel) {
|
|
510
|
+
mouseTargetData.areaModel.recalcVisibleTreeRows();
|
|
511
|
+
}
|
|
512
|
+
this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth);
|
|
513
|
+
this.tableScope.adjustContainersAndRows();
|
|
514
|
+
this.updateCollapsedExpandedState(tr);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
if (mouseTargetData.areaIdent === "body" && this.tableScope.tableOptions.getFocusModel) {
|
|
518
|
+
const fm = this.tableScope.tableOptions.getFocusModel();
|
|
519
|
+
fm === null || fm === void 0 ? void 0 : fm.clear();
|
|
520
|
+
fm === null || fm === void 0 ? void 0 : fm.setFocus(mouseTargetData.rowIdx, mouseTargetData.colIdx);
|
|
521
|
+
}
|
|
522
|
+
this.publishGeMouseEvent(event, 1);
|
|
523
|
+
}
|
|
524
|
+
onHostElementDblClicked(event) {
|
|
525
|
+
if (event.target instanceof HTMLElement) {
|
|
526
|
+
const target = event.target;
|
|
527
|
+
const area = target.getAttribute("data-area");
|
|
528
|
+
const areaIdent = getAreaIdentByString(area);
|
|
529
|
+
const rowIdx = Number(target.getAttribute("data-row-index"));
|
|
530
|
+
const colIdx = Number(target.getAttribute("data-col-index"));
|
|
531
|
+
const areaModel = this.tableScope.tableModel.getAreaModel(areaIdent);
|
|
532
|
+
if (area && areaIdent === "header") {
|
|
533
|
+
if (this.tableScope.tableModel.isSortable(colIdx)) {
|
|
534
|
+
this.tableScope.clearSelection();
|
|
535
|
+
this.tableScope.onHeaderDblClicked(event, rowIdx, colIdx);
|
|
536
|
+
}
|
|
537
|
+
} else if (target.getAttribute("data-row-index")) {
|
|
538
|
+
const row = areaModel.getRowByIndex(rowIdx);
|
|
539
|
+
if (area && areaIdent === "body") {
|
|
540
|
+
if (areaModel.isEditable(rowIdx, colIdx)) {
|
|
541
|
+
this.tableScope.clearSelection();
|
|
542
|
+
this.tableScope.initRenderEditor(rowIdx, colIdx);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (row instanceof TreeRow) {
|
|
546
|
+
if (colIdx === this.getArrowColumnIndex()) {
|
|
547
|
+
event.preventDefault();
|
|
548
|
+
event.stopPropagation();
|
|
549
|
+
const tr = row;
|
|
550
|
+
tr.expanded = !tr.expanded;
|
|
551
|
+
if ("recalcVisibleTreeRows" in areaModel) {
|
|
552
|
+
areaModel.recalcVisibleTreeRows();
|
|
553
|
+
}
|
|
554
|
+
this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth);
|
|
555
|
+
this.tableScope.adjustContainersAndRows();
|
|
556
|
+
this.updateCollapsedExpandedState(tr);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
this.publishGeMouseEvent(event, 2);
|
|
562
|
+
}
|
|
563
|
+
publishGeMouseEvent(event, clickCount) {
|
|
564
|
+
var _a;
|
|
565
|
+
this.mouseEvent = event;
|
|
566
|
+
this.geMouseEventOld = (_a = this.geMouseEvent) === null || _a === void 0 ? void 0 : _a.clone();
|
|
567
|
+
this.geMouseEvent = this.tableScope.createGeMouseEvent(event);
|
|
568
|
+
if (this.geMouseEvent) {
|
|
569
|
+
this.geMouseEvent.clickCount = clickCount;
|
|
570
|
+
}
|
|
571
|
+
this.tableScope.onMouseClicked(this.geMouseEvent, this.geMouseEventOld);
|
|
572
|
+
}
|
|
573
|
+
updateCollapsedExpandedState(tr) {
|
|
574
|
+
var _a, _b, _c, _d, _e;
|
|
575
|
+
const getRowId = (_b = (_a = this.tableScope.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) === null || _b === void 0 ? void 0 : _b.getRowId;
|
|
576
|
+
if (getRowId) {
|
|
577
|
+
const mode = (_c = this.tableScope.storeStateCollapsedExpandService) === null || _c === void 0 ? void 0 : _c.collapsedExpandedStateGet().mode;
|
|
578
|
+
const push = mode === "collapsed" && !tr.expanded || mode === "expanded" && tr.expanded;
|
|
579
|
+
const remove = mode === "collapsed" && tr.expanded || mode === "expanded" && !tr.expanded;
|
|
580
|
+
const rowId = getRowId(tr.data);
|
|
581
|
+
if (push) {
|
|
582
|
+
(_d = this.tableScope.storeStateCollapsedExpandService) === null || _d === void 0 ? void 0 : _d.collapsedStateIdsPush(rowId);
|
|
583
|
+
} else if (remove) {
|
|
584
|
+
(_e = this.tableScope.storeStateCollapsedExpandService) === null || _e === void 0 ? void 0 : _e.collapsedStateIdsRemove(rowId);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
getArrowColumnIndex() {
|
|
589
|
+
const rowCheckboxVisible = this.tableScope.tableModel.isRowCheckboxVisible();
|
|
590
|
+
return rowCheckboxVisible ? 1 : 0;
|
|
591
|
+
}
|
|
592
|
+
onMouseDown(evt) {
|
|
593
|
+
this.mouseEvent = evt;
|
|
594
|
+
this.startMouseEvent = this.tableScope.createGeMouseEvent(this.mouseEvent);
|
|
595
|
+
this.tableScope.onMouseDown(this.startMouseEvent);
|
|
596
|
+
this.mouseDown = true;
|
|
597
|
+
}
|
|
598
|
+
onMouseMove(evt) {
|
|
599
|
+
this.mouseEvent = evt;
|
|
600
|
+
if (this.mouseDown) {
|
|
601
|
+
this.dragging = true;
|
|
602
|
+
requestAnimationFrame(this.mouseDraggingOnFrame.bind(this));
|
|
603
|
+
} else {
|
|
604
|
+
requestAnimationFrame(this.mouseMoveOnFrame.bind(this));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
onMouseUp(evt) {
|
|
608
|
+
this.mouseEvent = evt;
|
|
609
|
+
if (this.dragging) {
|
|
610
|
+
requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this));
|
|
611
|
+
}
|
|
612
|
+
this.mouseDown = false;
|
|
613
|
+
this.dragging = false;
|
|
614
|
+
}
|
|
615
|
+
mouseDraggingOnFrame() {
|
|
616
|
+
var _a;
|
|
617
|
+
if (this.mouseEvent) {
|
|
618
|
+
const mouseEvent = this.tableScope.createGeMouseEvent(this.mouseEvent);
|
|
619
|
+
if ((_a = this.startMouseEvent) === null || _a === void 0 ? void 0 : _a.originalEvent) {
|
|
620
|
+
mouseEvent.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX;
|
|
621
|
+
mouseEvent.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY;
|
|
622
|
+
}
|
|
623
|
+
this.tableScope.mouseDraggingOnFrame(mouseEvent);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
mouseDraggingEndOnFrame() {
|
|
627
|
+
var _a;
|
|
628
|
+
if (this.mouseEvent) {
|
|
629
|
+
const mouseEvent = this.tableScope.createGeMouseEvent(this.mouseEvent);
|
|
630
|
+
if ((_a = this.startMouseEvent) === null || _a === void 0 ? void 0 : _a.originalEvent) {
|
|
631
|
+
mouseEvent.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX;
|
|
632
|
+
mouseEvent.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY;
|
|
633
|
+
}
|
|
634
|
+
this.tableScope.mouseDraggingEndOnFrame(mouseEvent);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
mouseMoveOnFrame() {
|
|
638
|
+
if (this.mouseEvent) {
|
|
639
|
+
const mouseMoveEvent = this.tableScope.createGeMouseEvent(this.mouseEvent);
|
|
640
|
+
this.tableScope.mouseMove(mouseMoveEvent);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
class TableApi {
|
|
645
|
+
constructor(tableScope) {
|
|
646
|
+
this.tableScope = tableScope;
|
|
647
|
+
}
|
|
648
|
+
updateCells(events) {
|
|
649
|
+
this.tableScope.updateCells(events);
|
|
650
|
+
}
|
|
651
|
+
externalFilterChanged() {
|
|
652
|
+
this.tableScope.externalFilterChanged();
|
|
653
|
+
}
|
|
654
|
+
scrollToPixel(_px = 0, _py = 0) {
|
|
655
|
+
}
|
|
656
|
+
scrollToIndex(_indexX = 0, _indexY = 0) {
|
|
657
|
+
}
|
|
658
|
+
setHeaderVisible(_visible = true) {
|
|
659
|
+
}
|
|
660
|
+
setColumnVisible(_column, _visible = true) {
|
|
661
|
+
}
|
|
662
|
+
isColumnVisible(_column) {
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
isHeaderVisible() {
|
|
666
|
+
return true;
|
|
667
|
+
}
|
|
668
|
+
setFooterVisible(_visible = true) {
|
|
669
|
+
}
|
|
670
|
+
isFooterVisible() {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
repaint() {
|
|
674
|
+
this.tableScope.repaint();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
class TreeRowService {
|
|
678
|
+
flattenTree(rows, ret = []) {
|
|
679
|
+
var _a;
|
|
680
|
+
for (const row of rows) {
|
|
681
|
+
if (this.isVisible(row)) {
|
|
682
|
+
ret.push(row);
|
|
683
|
+
}
|
|
684
|
+
if ((_a = row.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
685
|
+
this.flattenTree(row.children, ret);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
return ret;
|
|
689
|
+
}
|
|
690
|
+
isVisible(row) {
|
|
691
|
+
if (!row.parent) {
|
|
692
|
+
return true;
|
|
693
|
+
}
|
|
694
|
+
if (!row.parent.expanded) {
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
return this.isVisible(row.parent);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
class AbstractAreaModel {
|
|
701
|
+
constructor(areaIdent, columnDefs = [], defaultRowHeight = -1) {
|
|
702
|
+
this.areaIdent = areaIdent;
|
|
703
|
+
this.columnDefs = columnDefs;
|
|
704
|
+
this.defaultRowHeight = defaultRowHeight;
|
|
705
|
+
this.rowSelectionModel = void 0;
|
|
706
|
+
this.yPositions = [];
|
|
707
|
+
this.cellRenderers = columnDefs.map((def) => def.rendererMap[areaIdent]);
|
|
708
|
+
}
|
|
709
|
+
getTooltipAt(_rowIndex, _columnIndex) {
|
|
710
|
+
return "";
|
|
711
|
+
}
|
|
712
|
+
getCellRenderer(_rowIndex, columnIndex) {
|
|
713
|
+
if (columnIndex < this.cellRenderers.length) {
|
|
714
|
+
return this.cellRenderers[columnIndex];
|
|
715
|
+
}
|
|
716
|
+
return void 0;
|
|
717
|
+
}
|
|
718
|
+
getColspanAt(_rowIndex, _columnIndex) {
|
|
719
|
+
return 0;
|
|
720
|
+
}
|
|
721
|
+
getCustomClassesAt(_rowIndex, _columnIndex) {
|
|
722
|
+
return [];
|
|
723
|
+
}
|
|
724
|
+
getCustomStyleAt(_rowIndex, _columnIndex) {
|
|
725
|
+
return void 0;
|
|
726
|
+
}
|
|
727
|
+
getRowspanAt(_rowIndex, _columnIndex) {
|
|
728
|
+
return 0;
|
|
729
|
+
}
|
|
730
|
+
getRowByIndex(_rowIndex) {
|
|
731
|
+
return void 0;
|
|
732
|
+
}
|
|
733
|
+
isRowCheckable(_rowIndex) {
|
|
734
|
+
return true;
|
|
735
|
+
}
|
|
736
|
+
isRowChecked(rowIndex) {
|
|
737
|
+
var _a;
|
|
738
|
+
const row = this.getRowByIndex(rowIndex);
|
|
739
|
+
return (_a = this.rowSelectionModel) === null || _a === void 0 ? void 0 : _a.isRowChecked(row);
|
|
740
|
+
}
|
|
741
|
+
setRowChecked(rowIndex, checked) {
|
|
742
|
+
if (this.rowSelectionModel) {
|
|
743
|
+
const row = this.getRowByIndex(rowIndex);
|
|
744
|
+
this.rowSelectionModel.checkRow(row, checked);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
getMaxColspan() {
|
|
748
|
+
return 31;
|
|
749
|
+
}
|
|
750
|
+
getMaxRowspan() {
|
|
751
|
+
return 31;
|
|
752
|
+
}
|
|
753
|
+
getYPosByRowIndex(rowIndex) {
|
|
754
|
+
if (this.defaultRowHeight > 0) {
|
|
755
|
+
return this.defaultRowHeight * rowIndex;
|
|
756
|
+
}
|
|
757
|
+
return this.yPositions[rowIndex];
|
|
758
|
+
}
|
|
759
|
+
init() {
|
|
760
|
+
if (!this.yPositions.length && this.getRowCount() !== void 0) {
|
|
761
|
+
if (this.defaultRowHeight === -1) {
|
|
762
|
+
this.calcYPositions();
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
isFilterable() {
|
|
767
|
+
return this.areaIdent === "body";
|
|
768
|
+
}
|
|
769
|
+
doSort(_sortItems) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
isEditable(_rowIndex, columnIndex) {
|
|
773
|
+
if (this.columnDefs && columnIndex < this.columnDefs.length && this.columnDefs[columnIndex].editable) {
|
|
774
|
+
return this.columnDefs[columnIndex].editable();
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
setValue(rowIndex, columnIndex, value) {
|
|
779
|
+
var _a;
|
|
780
|
+
const editInputPipe = (_a = this.columnDefs[columnIndex]) === null || _a === void 0 ? void 0 : _a.editInputPipe;
|
|
781
|
+
if (editInputPipe) {
|
|
782
|
+
value = editInputPipe(value, rowIndex, columnIndex);
|
|
783
|
+
}
|
|
784
|
+
const row = this.getRowByIndex(rowIndex);
|
|
785
|
+
const property = this.columnDefs[columnIndex].property;
|
|
786
|
+
if (property.includes(".")) {
|
|
787
|
+
return this.setPropertyValue(row, property.split("."), value);
|
|
788
|
+
}
|
|
789
|
+
row[property] = value;
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
isSelectable(_rowIndex, _columnIndex) {
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
changeColumnOrder(sourceColumnIndex, targetColumnIndex) {
|
|
796
|
+
this.arrayMove(this.cellRenderers, sourceColumnIndex, targetColumnIndex);
|
|
797
|
+
}
|
|
798
|
+
setPropertyValue(o, props, value) {
|
|
799
|
+
const prop = props.shift();
|
|
800
|
+
if (prop) {
|
|
801
|
+
let o2 = o[prop];
|
|
802
|
+
if (o2 && props.length) {
|
|
803
|
+
return this.setPropertyValue(o2, props, value);
|
|
804
|
+
} else {
|
|
805
|
+
o[prop] = value;
|
|
806
|
+
return true;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
arrayMove(arr, fromIndex, toIndex) {
|
|
812
|
+
const element = arr.splice(fromIndex, 1)[0];
|
|
813
|
+
arr.splice(toIndex, 0, element);
|
|
814
|
+
return arr;
|
|
815
|
+
}
|
|
816
|
+
calcYPositions() {
|
|
817
|
+
const rowCount = this.getRowCount();
|
|
818
|
+
this.yPositions = new Array(rowCount + 1);
|
|
819
|
+
this.yPositions[0] = 0;
|
|
820
|
+
for (let i = 0; i < rowCount; i++) {
|
|
821
|
+
this.yPositions[i + 1] = this.getRowHeight(i) + this.yPositions[i];
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
class SorterService {
|
|
826
|
+
genericSortComparator(va, vb, f) {
|
|
827
|
+
if (typeof va === "number" && typeof vb === "number") {
|
|
828
|
+
return f * (va - vb);
|
|
829
|
+
}
|
|
830
|
+
if (typeof va === "string" && typeof vb === "string") {
|
|
831
|
+
return f * va.localeCompare(vb);
|
|
832
|
+
}
|
|
833
|
+
if (typeof va === "boolean" && typeof vb === "boolean") {
|
|
834
|
+
const a = va ? -1 : 1;
|
|
835
|
+
const b = vb ? -1 : 1;
|
|
836
|
+
return f * (a - b);
|
|
837
|
+
}
|
|
838
|
+
if (va instanceof Date && vb instanceof Date) {
|
|
839
|
+
return f * (va.getTime() - vb.getTime());
|
|
840
|
+
}
|
|
841
|
+
if (va instanceof Array && vb instanceof Array) {
|
|
842
|
+
const arr1 = va;
|
|
843
|
+
const arr2 = vb;
|
|
844
|
+
if (arr1.length && arr2.length) {
|
|
845
|
+
return this.genericSortComparator(arr1[0], arr2[0], f);
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return f * ("" + va).localeCompare("" + vb);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
class AreaModelTree extends AbstractAreaModel {
|
|
852
|
+
constructor(areaIdent, rows, defaultRowHeight, columnDefs = []) {
|
|
853
|
+
super(areaIdent, columnDefs, defaultRowHeight);
|
|
854
|
+
this.areaIdent = areaIdent;
|
|
855
|
+
this.rows = rows;
|
|
856
|
+
this.defaultRowHeight = defaultRowHeight;
|
|
857
|
+
this.columnDefs = columnDefs;
|
|
858
|
+
this.sorterService = new SorterService();
|
|
859
|
+
this.service = new TreeRowService();
|
|
860
|
+
this.properties = columnDefs.map((def) => def.property);
|
|
861
|
+
this.flattenRows = this.service.flattenTree(rows);
|
|
862
|
+
this.filteredFlattenRows = [...this.flattenRows];
|
|
863
|
+
}
|
|
864
|
+
changeColumnOrder(sourceColumnIndex, targetColumnIndex) {
|
|
865
|
+
this.arrayMove(this.properties, sourceColumnIndex, targetColumnIndex);
|
|
866
|
+
super.changeColumnOrder(sourceColumnIndex, targetColumnIndex);
|
|
867
|
+
}
|
|
868
|
+
recalcVisibleTreeRows() {
|
|
869
|
+
this.filteredFlattenRows = this.service.flattenTree(this.rows);
|
|
870
|
+
}
|
|
871
|
+
getFilteredFlattenRows() {
|
|
872
|
+
return this.filteredFlattenRows;
|
|
873
|
+
}
|
|
874
|
+
getRowCount() {
|
|
875
|
+
let n = 0;
|
|
876
|
+
for (const r of this.filteredFlattenRows) {
|
|
877
|
+
if (this.service.isVisible(r)) {
|
|
878
|
+
n++;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return n;
|
|
882
|
+
}
|
|
883
|
+
getValueAt(rowIndex, columnIndex) {
|
|
884
|
+
const row = this.getRowByIndex(rowIndex);
|
|
885
|
+
if (row) {
|
|
886
|
+
const prop = this.properties[columnIndex];
|
|
887
|
+
if (prop) {
|
|
888
|
+
if (prop.includes(".")) {
|
|
889
|
+
return this.getPropertyValue(row.data, prop.split("."));
|
|
890
|
+
}
|
|
891
|
+
return row.data[prop];
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return "";
|
|
895
|
+
}
|
|
896
|
+
getRowHeight(_rowIndex) {
|
|
897
|
+
return this.defaultRowHeight;
|
|
898
|
+
}
|
|
899
|
+
getCustomClassesAt(rowIndex, _columnIndex) {
|
|
900
|
+
const row = this.filteredFlattenRows[rowIndex];
|
|
901
|
+
return ["ge-table-tree-cell", "ge-table-tree-deep-" + row.deep];
|
|
902
|
+
}
|
|
903
|
+
getRowByIndex(idx) {
|
|
904
|
+
return this.filteredFlattenRows[idx];
|
|
905
|
+
}
|
|
906
|
+
getValueByT(t, property) {
|
|
907
|
+
if (property.includes(".")) {
|
|
908
|
+
return this.getPropertyValue(t, property.split("."));
|
|
909
|
+
}
|
|
910
|
+
return t[property];
|
|
911
|
+
}
|
|
912
|
+
externalFilterChanged(predictFn) {
|
|
913
|
+
this.lastPredictFn = predictFn;
|
|
914
|
+
this.doFiltering();
|
|
915
|
+
}
|
|
916
|
+
doSort(sortItems) {
|
|
917
|
+
const { columnIndex, sortState } = sortItems[sortItems.length - 1];
|
|
918
|
+
const f = sortState === "asc" ? 1 : sortState === "desc" ? -1 : 0;
|
|
919
|
+
const property = this.properties[columnIndex];
|
|
920
|
+
this.treeSort(this.rows, property, f);
|
|
921
|
+
this.flattenRows = this.service.flattenTree(this.rows);
|
|
922
|
+
this.filteredFlattenRows = [...this.flattenRows];
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
toggleExpandCollapseAll(expanded) {
|
|
926
|
+
this.expandAllRecursive(this.rows, expanded);
|
|
927
|
+
this.flattenRows = this.service.flattenTree(this.rows);
|
|
928
|
+
this.doFiltering();
|
|
929
|
+
}
|
|
930
|
+
setAllParentsOk(item) {
|
|
931
|
+
if (item.parent) {
|
|
932
|
+
item.parent.keep = true;
|
|
933
|
+
this.setAllParentsOk(item.parent);
|
|
934
|
+
}
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
setValue(rowIndex, columnIndex, value) {
|
|
938
|
+
var _a;
|
|
939
|
+
const editInputPipe = (_a = this.columnDefs[columnIndex]) === null || _a === void 0 ? void 0 : _a.editInputPipe;
|
|
940
|
+
if (editInputPipe) {
|
|
941
|
+
value = editInputPipe(value, rowIndex, columnIndex);
|
|
942
|
+
}
|
|
943
|
+
const treeRow = this.getRowByIndex(rowIndex);
|
|
944
|
+
if (treeRow) {
|
|
945
|
+
const row = treeRow.data;
|
|
946
|
+
const property = this.columnDefs[columnIndex].property;
|
|
947
|
+
if (property.includes(".")) {
|
|
948
|
+
return this.setPropertyValue(row, property.split("."), value);
|
|
949
|
+
}
|
|
950
|
+
row[property] = value;
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
genericTreeTableSortComparator(property, f) {
|
|
956
|
+
return (a, b) => {
|
|
957
|
+
const va = this.getValueByT(a.data, property);
|
|
958
|
+
const vb = this.getValueByT(b.data, property);
|
|
959
|
+
return this.sorterService.genericSortComparator(va, vb, f);
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
expandAllRecursive(arr, expanded) {
|
|
963
|
+
for (const row of arr) {
|
|
964
|
+
row.expanded = expanded;
|
|
965
|
+
if (row.children) {
|
|
966
|
+
this.expandAllRecursive(row.children, expanded);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
doFiltering() {
|
|
971
|
+
if (!this.lastPredictFn) {
|
|
972
|
+
this.filteredFlattenRows = [...this.flattenRows ? this.flattenRows : []];
|
|
973
|
+
} else {
|
|
974
|
+
if (!this.flattenRows) {
|
|
975
|
+
this.flattenRows = [];
|
|
976
|
+
}
|
|
977
|
+
let maxDeep = 0;
|
|
978
|
+
this.flattenRows.forEach((v) => {
|
|
979
|
+
maxDeep = Math.max(maxDeep, v.deep);
|
|
980
|
+
});
|
|
981
|
+
const okRows = this.flattenRows.filter((value, index, array) => {
|
|
982
|
+
return this.lastPredictFn(value, index, array);
|
|
983
|
+
});
|
|
984
|
+
this.flattenRows.forEach((v) => v.keep = false);
|
|
985
|
+
this.flattenRows.forEach((v) => {
|
|
986
|
+
if (okRows.includes(v)) {
|
|
987
|
+
v.keep = true;
|
|
988
|
+
this.setAllParentsOk(v);
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
this.filteredFlattenRows = this.flattenRows.filter((value, _index, _array) => {
|
|
992
|
+
return value.keep;
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
getPropertyValue(o, props) {
|
|
997
|
+
const prop = props.shift();
|
|
998
|
+
let o2 = o[prop];
|
|
999
|
+
if (o2 && props.length) {
|
|
1000
|
+
return this.getPropertyValue(o2, props);
|
|
1001
|
+
}
|
|
1002
|
+
return o2;
|
|
1003
|
+
}
|
|
1004
|
+
treeSort(rows, property, f) {
|
|
1005
|
+
rows.sort(this.genericTreeTableSortComparator(property, f));
|
|
1006
|
+
for (const row of rows) {
|
|
1007
|
+
if (row.children) {
|
|
1008
|
+
this.treeSort(row.children, property, f);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
class AbstractStoreStateService {
|
|
1014
|
+
constructor(fn) {
|
|
1015
|
+
this.getStorageKeyFn = fn;
|
|
1016
|
+
}
|
|
1017
|
+
autoConvertMapToObject(item) {
|
|
1018
|
+
const obj = {};
|
|
1019
|
+
if (item instanceof Map) {
|
|
1020
|
+
const map = item;
|
|
1021
|
+
for (const item2 of [...map]) {
|
|
1022
|
+
const [key, value] = item2;
|
|
1023
|
+
obj[key] = value;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return obj;
|
|
1027
|
+
}
|
|
1028
|
+
checkAndPersistItem(keySuffix, item) {
|
|
1029
|
+
const fn = this.getStorageKeyFn;
|
|
1030
|
+
if (fn) {
|
|
1031
|
+
const key = fn();
|
|
1032
|
+
if (key) {
|
|
1033
|
+
const subKey = key + keySuffix;
|
|
1034
|
+
if ((item + "").includes("Map")) {
|
|
1035
|
+
const obj = this.autoConvertMapToObject(item);
|
|
1036
|
+
this.persistItem(subKey, obj);
|
|
1037
|
+
} else {
|
|
1038
|
+
this.persistItem(subKey, item);
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
persistItem(subKey, item) {
|
|
1044
|
+
if (item) {
|
|
1045
|
+
localStorage.setItem(subKey, JSON.stringify(item));
|
|
1046
|
+
} else {
|
|
1047
|
+
localStorage.removeItem(subKey);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
loadFromLocalStorage(subKey) {
|
|
1051
|
+
const item = localStorage.getItem(subKey);
|
|
1052
|
+
if (item) {
|
|
1053
|
+
return JSON.parse(item);
|
|
1054
|
+
}
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
class StoreStateScrollPosService extends AbstractStoreStateService {
|
|
1059
|
+
constructor(fn) {
|
|
1060
|
+
super(fn);
|
|
1061
|
+
this.SCROLL_STATE = "scrollState";
|
|
1062
|
+
this.scrollOffset = [0, 0];
|
|
1063
|
+
this.load();
|
|
1064
|
+
}
|
|
1065
|
+
getScrollOffset() {
|
|
1066
|
+
return this.scrollOffset;
|
|
1067
|
+
}
|
|
1068
|
+
updateScrollOffset(xy) {
|
|
1069
|
+
this.scrollOffset = xy;
|
|
1070
|
+
this.checkAndPersistItem(this.SCROLL_STATE, this.scrollOffset);
|
|
1071
|
+
}
|
|
1072
|
+
load() {
|
|
1073
|
+
const fn = this.getStorageKeyFn;
|
|
1074
|
+
if (fn) {
|
|
1075
|
+
const key = fn();
|
|
1076
|
+
if (key) {
|
|
1077
|
+
const subKey4 = key + this.SCROLL_STATE;
|
|
1078
|
+
let scrollOffset = this.loadFromLocalStorage(subKey4);
|
|
1079
|
+
this.scrollOffset = scrollOffset ? scrollOffset : [0, 0];
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
class CollapsedExpandedData {
|
|
1085
|
+
constructor(mode = "collapsed", rowIds = [], allCollapsed = false, allExpanded = false) {
|
|
1086
|
+
this.mode = mode;
|
|
1087
|
+
this.rowIds = rowIds;
|
|
1088
|
+
this.allCollapsed = allCollapsed;
|
|
1089
|
+
this.allExpanded = allExpanded;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
class StoreStateCollapsedExpandService extends AbstractStoreStateService {
|
|
1093
|
+
constructor(fn) {
|
|
1094
|
+
super(fn);
|
|
1095
|
+
this.COLLAPSED_EXPANDED_STATE = "collapsedExpandedState";
|
|
1096
|
+
this.collapsedExpandedState = new CollapsedExpandedData();
|
|
1097
|
+
this.load();
|
|
1098
|
+
}
|
|
1099
|
+
collapsedExpandedStateGet() {
|
|
1100
|
+
return this.collapsedExpandedState;
|
|
1101
|
+
}
|
|
1102
|
+
collapsedExpandedStateIncludes(rowId) {
|
|
1103
|
+
return this.collapsedExpandedState.rowIds.includes(rowId);
|
|
1104
|
+
}
|
|
1105
|
+
collapsedStateIdsPush(id) {
|
|
1106
|
+
if (!this.collapsedExpandedState.rowIds.includes(id)) {
|
|
1107
|
+
this.collapsedExpandedState.rowIds.push(id);
|
|
1108
|
+
this.collapsedExpandedState.allCollapsed = false;
|
|
1109
|
+
this.collapsedExpandedState.allExpanded = false;
|
|
1110
|
+
this.persist();
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
collapsedStateIdsRemove(id) {
|
|
1114
|
+
const idx = this.collapsedExpandedState.rowIds.indexOf(id);
|
|
1115
|
+
if (idx !== -1) {
|
|
1116
|
+
this.collapsedExpandedState.rowIds.splice(idx, 1);
|
|
1117
|
+
this.collapsedExpandedState.allCollapsed = false;
|
|
1118
|
+
this.collapsedExpandedState.allExpanded = false;
|
|
1119
|
+
this.persist();
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
collapsedStateAll(expand) {
|
|
1123
|
+
this.collapsedExpandedState.rowIds = [];
|
|
1124
|
+
this.collapsedExpandedState.mode = expand ? "collapsed" : "expanded";
|
|
1125
|
+
this.collapsedExpandedState.allCollapsed = !expand;
|
|
1126
|
+
this.collapsedExpandedState.allExpanded = expand;
|
|
1127
|
+
this.persist();
|
|
1128
|
+
}
|
|
1129
|
+
load() {
|
|
1130
|
+
const fn = this.getStorageKeyFn;
|
|
1131
|
+
if (fn) {
|
|
1132
|
+
const key = fn();
|
|
1133
|
+
if (key) {
|
|
1134
|
+
const subKey2 = key + this.COLLAPSED_EXPANDED_STATE;
|
|
1135
|
+
const data = this.loadFromLocalStorage(subKey2);
|
|
1136
|
+
if (data) {
|
|
1137
|
+
this.collapsedExpandedState = data;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
persist() {
|
|
1143
|
+
this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE, this.collapsedExpandedState);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
class StoreStateSortingService extends AbstractStoreStateService {
|
|
1147
|
+
constructor(fn) {
|
|
1148
|
+
super(fn);
|
|
1149
|
+
this.SORTING_STATE = "sortingState";
|
|
1150
|
+
this.sortItems = [];
|
|
1151
|
+
this.load();
|
|
1152
|
+
}
|
|
1153
|
+
getSortItems() {
|
|
1154
|
+
return this.sortItems;
|
|
1155
|
+
}
|
|
1156
|
+
setSortItems(sortItems) {
|
|
1157
|
+
this.sortItems = sortItems;
|
|
1158
|
+
this.checkAndPersistItem(this.SORTING_STATE, this.sortItems);
|
|
1159
|
+
}
|
|
1160
|
+
load() {
|
|
1161
|
+
const fn = this.getStorageKeyFn;
|
|
1162
|
+
if (fn) {
|
|
1163
|
+
const key = fn();
|
|
1164
|
+
if (key) {
|
|
1165
|
+
const subKey = key + this.SORTING_STATE;
|
|
1166
|
+
let sortItems = this.loadFromLocalStorage(subKey);
|
|
1167
|
+
this.sortItems = sortItems ? sortItems : [];
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
class GeoData {
|
|
1173
|
+
constructor(left = 0, width = 0, height = 0, top = 0, index) {
|
|
1174
|
+
this.left = left;
|
|
1175
|
+
this.width = width;
|
|
1176
|
+
this.height = height;
|
|
1177
|
+
this.top = top;
|
|
1178
|
+
this.index = index;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
class EleScope {
|
|
1182
|
+
constructor(hostElement, tableModel, dom, tableOptions) {
|
|
1183
|
+
var _a, _b;
|
|
1184
|
+
this.hostElement = hostElement;
|
|
1185
|
+
this.tableModel = tableModel;
|
|
1186
|
+
this.dom = dom;
|
|
1187
|
+
this.tableOptions = tableOptions;
|
|
1188
|
+
this.scrollTop = 0;
|
|
1189
|
+
this.areaBodyWestGeo = new GeoData();
|
|
1190
|
+
this.areaBodyCenterGeo = new GeoData();
|
|
1191
|
+
this.areaBodyEastGeo = new GeoData();
|
|
1192
|
+
const hostEle = this.hostElement;
|
|
1193
|
+
hostEle.innerText = "";
|
|
1194
|
+
this.dom.setAttribute(hostEle, "tabindex", "0");
|
|
1195
|
+
this.dom.setStyle(this.dom.addClass("ge-table", hostEle), "position", "relative");
|
|
1196
|
+
this.hoverRow = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-hover-row", hostEle));
|
|
1197
|
+
this.hoverColumn = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-hover-column", hostEle));
|
|
1198
|
+
this.areaHeaderWest = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-header ge-table-header-west", hostEle, "header", "west")));
|
|
1199
|
+
this.areaHeaderCenter = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-header ge-table-header-center", hostEle, "header", "center")));
|
|
1200
|
+
this.areaHeaderEast = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-header ge-table-header-east", hostEle, "body", "east")));
|
|
1201
|
+
this.areaBodyWest = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-body ge-table-body-west", hostEle, "body", "west")));
|
|
1202
|
+
this.areaBodyEast = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-body ge-table-body-east", hostEle, "body", "east")));
|
|
1203
|
+
this.areaFooterWest = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-footer ge-table-footer-west", hostEle, "footer", "west")));
|
|
1204
|
+
this.areaFooterCenter = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-footer ge-table-footer-center", hostEle, "footer", "center")));
|
|
1205
|
+
this.areaFooterEast = dom.appendRelativeChildDiv(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-footer ge-table-footer-east", hostEle, "footer", "east")));
|
|
1206
|
+
this.scrollViewport = dom.applyStyleOverflowAuto((_a = this.tableOptions.overflowX) !== null && _a !== void 0 ? _a : "auto", (_b = this.tableOptions.overflowY) !== null && _b !== void 0 ? _b : "auto", dom.applyStyleNoPadding(dom.applyStylePosistionAbsolute(dom.createAreaDivWithClass("ge-table-scroll-viewport", hostEle, "body", "center"))));
|
|
1207
|
+
this.contentWrapperDiv = dom.applyStyleNoPadding(dom.applyStylePosistionRelative(dom.createDivWithClass("ge-table-scroll-content-wrapper", this.scrollViewport)));
|
|
1208
|
+
this.contentDiv = dom.applyStyleNoPadding(dom.applyStylePosistionRelative(dom.createDivWithClass("ge-table-scroll-content", this.contentWrapperDiv)));
|
|
1209
|
+
this.areaBodyCenter = dom.appendRelativeChildDiv(dom.createDivWithClass("ge-table-body-center", this.contentDiv));
|
|
1210
|
+
this.borderHeaderBottom = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-header-border", hostEle));
|
|
1211
|
+
this.borderFixedWest = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-west-fixed-column-border", hostEle));
|
|
1212
|
+
this.borderFixedEast = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-east-fixed-column-border", hostEle));
|
|
1213
|
+
this.borderFooterTop = dom.applyStylePosistionAbsolute(dom.createDivWithClass("ge-table-footer-border", hostEle));
|
|
1214
|
+
}
|
|
1215
|
+
adjustContainersAndRows() {
|
|
1216
|
+
const padding = this.tableModel.getPadding();
|
|
1217
|
+
const w = this.hostElement.clientWidth;
|
|
1218
|
+
const h = this.hostElement.clientHeight;
|
|
1219
|
+
this.dom.applyStyle(this.scrollViewport, {
|
|
1220
|
+
width: `${w - padding.left}px`,
|
|
1221
|
+
height: `${h - padding.top}px`,
|
|
1222
|
+
top: `${padding.top}px`,
|
|
1223
|
+
left: `${padding.left}px`
|
|
1224
|
+
});
|
|
1225
|
+
this.scrollTop = this.scrollViewport.scrollTop;
|
|
1226
|
+
this.dom.applyStyle(this.contentDiv, {
|
|
1227
|
+
width: `${this.scrollViewport.clientWidth}px`,
|
|
1228
|
+
height: `${this.scrollViewport.clientHeight}px`,
|
|
1229
|
+
top: `${this.scrollTop}px`,
|
|
1230
|
+
left: `${this.scrollViewport.scrollLeft}px`
|
|
1231
|
+
});
|
|
1232
|
+
this.areaBodyWestGeo.width = padding.left;
|
|
1233
|
+
this.areaBodyWestGeo.height = h - padding.top - padding.bottom;
|
|
1234
|
+
this.areaBodyWestGeo.top = padding.top;
|
|
1235
|
+
this.areaBodyWestGeo.left = 0;
|
|
1236
|
+
this.dom.applyStyleInPx(this.areaBodyWest.parent, this.areaBodyWestGeo);
|
|
1237
|
+
if (this.tableOptions.fixedWestSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount()) {
|
|
1238
|
+
this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest, {
|
|
1239
|
+
width: `1px`,
|
|
1240
|
+
height: `${this.areaBodyWestGeo.height}px`,
|
|
1241
|
+
top: `${this.areaBodyWestGeo.top}px`,
|
|
1242
|
+
left: `${this.areaBodyWestGeo.width}px`
|
|
1243
|
+
}));
|
|
1244
|
+
} else {
|
|
1245
|
+
this.dom.applyDisplayNoneStyle(this.borderFixedWest);
|
|
1246
|
+
}
|
|
1247
|
+
this.areaBodyEastGeo.width = padding.right;
|
|
1248
|
+
this.areaBodyEastGeo.height = h - padding.top - padding.bottom;
|
|
1249
|
+
this.areaBodyEastGeo.top = padding.top;
|
|
1250
|
+
this.areaBodyEastGeo.left = w - padding.right;
|
|
1251
|
+
this.dom.applyStyleInPx(this.areaBodyEast.parent, this.areaBodyEastGeo);
|
|
1252
|
+
if (this.tableOptions.fixedEastSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount()) {
|
|
1253
|
+
this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast, {
|
|
1254
|
+
width: `1px`,
|
|
1255
|
+
height: `${this.areaBodyEastGeo.height}px`,
|
|
1256
|
+
top: `${this.areaBodyEastGeo.top}px`,
|
|
1257
|
+
left: `${this.areaBodyEastGeo.left}px`
|
|
1258
|
+
}));
|
|
1259
|
+
} else {
|
|
1260
|
+
this.dom.applyDisplayNoneStyle(this.borderFixedEast);
|
|
1261
|
+
}
|
|
1262
|
+
this.areaBodyCenterGeo.width = w - padding.left - padding.right;
|
|
1263
|
+
this.areaBodyCenterGeo.height = h - padding.top - padding.bottom;
|
|
1264
|
+
this.areaBodyCenterGeo.top = 0;
|
|
1265
|
+
this.areaBodyCenterGeo.left = 0;
|
|
1266
|
+
this.dom.applyStyleInPx(this.areaBodyCenter.parent, this.areaBodyCenterGeo);
|
|
1267
|
+
this.dom.applyStyle(this.areaHeaderCenter.parent, {
|
|
1268
|
+
width: `${w - padding.left - padding.right}px`,
|
|
1269
|
+
height: `${padding.top}px`,
|
|
1270
|
+
top: "0",
|
|
1271
|
+
left: `${padding.left}px`
|
|
1272
|
+
});
|
|
1273
|
+
this.dom.applyStyle(this.areaHeaderWest.parent, {
|
|
1274
|
+
width: `${padding.left}px`,
|
|
1275
|
+
height: `${padding.top}px`,
|
|
1276
|
+
top: "0",
|
|
1277
|
+
left: "0"
|
|
1278
|
+
});
|
|
1279
|
+
this.dom.applyStyle(this.areaHeaderEast.parent, {
|
|
1280
|
+
width: `${padding.right}px`,
|
|
1281
|
+
height: `${padding.top}px`,
|
|
1282
|
+
top: "0",
|
|
1283
|
+
left: `${w - padding.right}px`
|
|
1284
|
+
});
|
|
1285
|
+
if (this.tableOptions.headerSeparatorBorderVisible && this.tableModel.isHeaderVisibe()) {
|
|
1286
|
+
this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom, {
|
|
1287
|
+
width: `${w}px`,
|
|
1288
|
+
height: "1px",
|
|
1289
|
+
top: `${padding.top}px`,
|
|
1290
|
+
left: "0px"
|
|
1291
|
+
}));
|
|
1292
|
+
} else {
|
|
1293
|
+
this.dom.applyDisplayNoneStyle(this.borderHeaderBottom);
|
|
1294
|
+
}
|
|
1295
|
+
this.dom.applyStyle(this.areaFooterWest.parent, {
|
|
1296
|
+
width: `${padding.left}px`,
|
|
1297
|
+
height: `${padding.bottom}px`,
|
|
1298
|
+
top: `${h - padding.bottom}px`,
|
|
1299
|
+
left: "0"
|
|
1300
|
+
});
|
|
1301
|
+
this.dom.applyStyle(this.areaFooterCenter.parent, {
|
|
1302
|
+
width: `${w - padding.left - padding.right}px`,
|
|
1303
|
+
height: `${padding.bottom}px`,
|
|
1304
|
+
top: `${h - padding.bottom}px`,
|
|
1305
|
+
left: `${padding.left}px`
|
|
1306
|
+
});
|
|
1307
|
+
this.dom.applyStyle(this.areaFooterEast.parent, {
|
|
1308
|
+
width: `${padding.right}px`,
|
|
1309
|
+
height: `${padding.bottom}px`,
|
|
1310
|
+
top: `${h - padding.bottom}px`,
|
|
1311
|
+
left: `${w - padding.right}px`
|
|
1312
|
+
});
|
|
1313
|
+
if (this.tableOptions.footerSeparatorBorderVisible && this.tableModel.isFooterVisibe()) {
|
|
1314
|
+
this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop, {
|
|
1315
|
+
width: `${w}px`,
|
|
1316
|
+
height: "1px",
|
|
1317
|
+
top: `${h - padding.bottom}px`,
|
|
1318
|
+
left: "0px"
|
|
1319
|
+
}));
|
|
1320
|
+
} else {
|
|
1321
|
+
this.dom.applyDisplayNoneStyle(this.borderFooterTop);
|
|
1322
|
+
}
|
|
1323
|
+
this.adjustAfterScrolling();
|
|
1324
|
+
}
|
|
1325
|
+
adjustAfterScrolling() {
|
|
1326
|
+
}
|
|
1327
|
+
resetSizeOfWrapperDiv() {
|
|
1328
|
+
const w = `${this.tableModel.getContentWidthInPixel()}px`;
|
|
1329
|
+
const h = `${this.tableModel.getContentHeightInPixel() + 1}px`;
|
|
1330
|
+
this.dom.setStyle(this.contentWrapperDiv, "width", w);
|
|
1331
|
+
this.dom.setStyle(this.contentWrapperDiv, "height", h);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
class CellRange {
|
|
1335
|
+
constructor(r1, c1, r2, c2, gammaRange = false) {
|
|
1336
|
+
this.r1 = r1;
|
|
1337
|
+
this.c1 = c1;
|
|
1338
|
+
this.r2 = r2;
|
|
1339
|
+
this.c2 = c2;
|
|
1340
|
+
this.gammaRange = gammaRange;
|
|
1341
|
+
}
|
|
1342
|
+
static create(params) {
|
|
1343
|
+
if (params.gammaRange === void 0) {
|
|
1344
|
+
params.gammaRange = false;
|
|
1345
|
+
}
|
|
1346
|
+
return new CellRange(params.rowIndex1, params.columnIndex1, params.rowIndex2, params.columnIndex2, params.gammaRange);
|
|
1347
|
+
}
|
|
1348
|
+
static singleCell(rowIndex, columnIndex) {
|
|
1349
|
+
return new CellRange(rowIndex, columnIndex, rowIndex, columnIndex);
|
|
1350
|
+
}
|
|
1351
|
+
static singleRow(rowIndex) {
|
|
1352
|
+
return new CellRange(rowIndex, 0, rowIndex, Number.MAX_SAFE_INTEGER);
|
|
1353
|
+
}
|
|
1354
|
+
static singleColumn(columnIndex) {
|
|
1355
|
+
return new CellRange(0, columnIndex, Number.MAX_SAFE_INTEGER, columnIndex);
|
|
1356
|
+
}
|
|
1357
|
+
isInRange(rowIndex, columnIndex) {
|
|
1358
|
+
return rowIndex >= this.r1 && rowIndex <= this.r2 && columnIndex >= this.c1 && columnIndex <= this.c2;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
class ColAndRowspanModel {
|
|
1362
|
+
constructor(tableModel, areaModel) {
|
|
1363
|
+
this.tableModel = tableModel;
|
|
1364
|
+
this.areaModel = areaModel;
|
|
1365
|
+
this.colAndRowspanRanges = void 0;
|
|
1366
|
+
}
|
|
1367
|
+
init() {
|
|
1368
|
+
if (this.areaModel.getMaxColspan() < 2 && this.areaModel.getMaxRowspan() < 2) {
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
this.colAndRowspanRanges = [];
|
|
1372
|
+
const rowCount = this.areaModel.getRowCount();
|
|
1373
|
+
const colCount = this.tableModel.getColumnCount();
|
|
1374
|
+
for (let r = 0; r < rowCount; r++) {
|
|
1375
|
+
for (let c = 0; c < colCount; c++) {
|
|
1376
|
+
let cs = this.areaModel.getColspanAt(r, c);
|
|
1377
|
+
let rs = this.areaModel.getRowspanAt(r, c);
|
|
1378
|
+
if (cs > 1 || rs > 1) {
|
|
1379
|
+
if (cs === 0) {
|
|
1380
|
+
cs = 1;
|
|
1381
|
+
}
|
|
1382
|
+
if (rs === 0) {
|
|
1383
|
+
rs = 1;
|
|
1384
|
+
}
|
|
1385
|
+
const gammaRange = this.areaModel.hasOwnProperty("gammaCells");
|
|
1386
|
+
this.colAndRowspanRanges.push(new CellRange(r, c, r + rs - 1, c + cs - 1, gammaRange));
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
getRanges() {
|
|
1392
|
+
if (this.colAndRowspanRanges) {
|
|
1393
|
+
return this.colAndRowspanRanges;
|
|
1394
|
+
}
|
|
1395
|
+
return [];
|
|
1396
|
+
}
|
|
1397
|
+
isInRange(rowIndex, columnIndex) {
|
|
1398
|
+
if (this.colAndRowspanRanges) {
|
|
1399
|
+
for (const range of this.colAndRowspanRanges) {
|
|
1400
|
+
if (range.isInRange(rowIndex, columnIndex)) {
|
|
1401
|
+
return true;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
class AreaObjectMap {
|
|
1409
|
+
constructor(header, body, footer) {
|
|
1410
|
+
this.header = header;
|
|
1411
|
+
this.body = body;
|
|
1412
|
+
this.footer = footer;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
class RenderScope extends EleScope {
|
|
1416
|
+
constructor(hostElement, tableModel, dom, tableOptions) {
|
|
1417
|
+
var _a, _b;
|
|
1418
|
+
super(hostElement, tableModel, dom, tableOptions);
|
|
1419
|
+
this.scrollLeft = 0;
|
|
1420
|
+
this.scrollViewportLeft = 0;
|
|
1421
|
+
this.scrollFactorY = 0;
|
|
1422
|
+
this.scrollFactorX = 0;
|
|
1423
|
+
this.cleanupFunctions = {
|
|
1424
|
+
header: [],
|
|
1425
|
+
body: [],
|
|
1426
|
+
footer: []
|
|
1427
|
+
};
|
|
1428
|
+
this.tree = false;
|
|
1429
|
+
this.colAndRowspanModels = new AreaObjectMap();
|
|
1430
|
+
this.firstVisibleRowIndex = -1;
|
|
1431
|
+
this.draggingTargetColumnIndex = -1;
|
|
1432
|
+
this.removables = [];
|
|
1433
|
+
this.editing = false;
|
|
1434
|
+
if (this.tableModel.getSelectionModel) {
|
|
1435
|
+
this.getSelectionModel = this.tableModel.getSelectionModel;
|
|
1436
|
+
} else if ((_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.getSelectionModel) {
|
|
1437
|
+
this.getSelectionModel = this.tableOptions.getSelectionModel;
|
|
1438
|
+
}
|
|
1439
|
+
if ((_b = this.tableOptions) === null || _b === void 0 ? void 0 : _b.getFocusModel) {
|
|
1440
|
+
this.getFocusModel = this.tableOptions.getFocusModel;
|
|
1441
|
+
}
|
|
1442
|
+
if (tableModel.getAreaModel("body") instanceof AreaModelTree) {
|
|
1443
|
+
this.tree = true;
|
|
1444
|
+
}
|
|
1445
|
+
const aereaIds = ["header", "body", "footer"];
|
|
1446
|
+
aereaIds.forEach((areaIdent) => {
|
|
1447
|
+
var _a2;
|
|
1448
|
+
this.colAndRowspanModels[areaIdent] = new ColAndRowspanModel(tableModel, tableModel.getAreaModel(areaIdent));
|
|
1449
|
+
(_a2 = this.colAndRowspanModels[areaIdent]) === null || _a2 === void 0 ? void 0 : _a2.init();
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
isEditing() {
|
|
1453
|
+
return this.editing;
|
|
1454
|
+
}
|
|
1455
|
+
resetEditorRenderer() {
|
|
1456
|
+
this.editorRenderer = void 0;
|
|
1457
|
+
this.editorRendererRow = -1;
|
|
1458
|
+
this.editorRendererColumn = -1;
|
|
1459
|
+
this.editing = false;
|
|
1460
|
+
}
|
|
1461
|
+
clearSelection() {
|
|
1462
|
+
if (this.getSelectionModel) {
|
|
1463
|
+
const sm = this.getSelectionModel();
|
|
1464
|
+
sm === null || sm === void 0 ? void 0 : sm.clear();
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
initRenderEditor(rowIdx, colIdx) {
|
|
1468
|
+
var _a;
|
|
1469
|
+
let rnFn = (_a = this.tableModel.getColumnDef(colIdx)) === null || _a === void 0 ? void 0 : _a.getEditRenderer;
|
|
1470
|
+
if (!rnFn) {
|
|
1471
|
+
rnFn = this.tableOptions.getEditRenderer;
|
|
1472
|
+
}
|
|
1473
|
+
if (rnFn) {
|
|
1474
|
+
this.editorRenderer = rnFn(rowIdx, colIdx);
|
|
1475
|
+
if (this.editorRenderer) {
|
|
1476
|
+
this.editorRendererRow = rowIdx;
|
|
1477
|
+
this.editorRendererColumn = colIdx;
|
|
1478
|
+
this.editing = true;
|
|
1479
|
+
this.repaint();
|
|
1480
|
+
const input = document.querySelector("input.ge-table-cell-editor-input");
|
|
1481
|
+
if (input) {
|
|
1482
|
+
input.focus();
|
|
1483
|
+
}
|
|
1484
|
+
} else {
|
|
1485
|
+
this.resetEditorRenderer();
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
repaint() {
|
|
1490
|
+
this.adjustAfterScrolling();
|
|
1491
|
+
}
|
|
1492
|
+
adjustAfterScrolling() {
|
|
1493
|
+
var _a;
|
|
1494
|
+
for (const cleaning of this.removables) {
|
|
1495
|
+
cleaning.remove();
|
|
1496
|
+
}
|
|
1497
|
+
this.hideHoverRow();
|
|
1498
|
+
this.hideHoverColumn();
|
|
1499
|
+
this.scrollTop = this.scrollViewport.scrollTop;
|
|
1500
|
+
this.scrollLeft = this.scrollViewport.scrollLeft;
|
|
1501
|
+
this.debounce(this.checkForScrollPosSaving.bind(this));
|
|
1502
|
+
this.scrollFactorY = this.scrollTop / (this.scrollViewport.scrollHeight - this.scrollViewport.clientHeight);
|
|
1503
|
+
this.scrollFactorX = this.scrollLeft / (this.scrollViewport.scrollWidth - this.scrollViewport.clientWidth);
|
|
1504
|
+
if (isNaN(this.scrollFactorY)) {
|
|
1505
|
+
this.scrollFactorY = 0;
|
|
1506
|
+
}
|
|
1507
|
+
if (isNaN(this.scrollFactorX)) {
|
|
1508
|
+
this.scrollFactorX = 0;
|
|
1509
|
+
}
|
|
1510
|
+
this.adjustBody();
|
|
1511
|
+
this.adjustArea("footer");
|
|
1512
|
+
this.adjustArea("header");
|
|
1513
|
+
if (this.tableOptions.tableTopBorderVisible) {
|
|
1514
|
+
this.removables.push(this.dom.addHorizontalBorder(new GeoData(0, this.hostElement.clientWidth, 1, 0), this.hostElement, "ge-table-border"));
|
|
1515
|
+
}
|
|
1516
|
+
if (this.tableOptions.tableBottomBorderVisible) {
|
|
1517
|
+
this.removables.push(this.dom.addHorizontalBorder(new GeoData(0, this.hostElement.clientWidth, 1, this.hostElement.clientHeight - 1), this.hostElement, "ge-table-border"));
|
|
1518
|
+
}
|
|
1519
|
+
if (this.tableModel.getFixedLeftColumnCount() > 0) {
|
|
1520
|
+
this.removables.push(this.dom.addVerticalBorder(new GeoData(this.areaBodyWest.child.clientWidth, 1, this.hostElement.clientHeight, 0), this.hostElement, "ge-table-body-west-vertical-border"));
|
|
1521
|
+
}
|
|
1522
|
+
if (((_a = this.tableModel.getAreaModel("header")) === null || _a === void 0 ? void 0 : _a.getRowCount()) > 0) {
|
|
1523
|
+
this.removables.push(this.dom.addHorizontalBorder(new GeoData(0, this.hostElement.clientWidth, 1, this.areaHeaderCenter.child.clientHeight), this.hostElement, "ge-table-body-west-vertical-border"));
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
checkForScrollPosSaving() {
|
|
1527
|
+
var _a, _b;
|
|
1528
|
+
if (this.storeScrollPosStateService && ((_b = (_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) === null || _b === void 0 ? void 0 : _b.autoRestoreScrollPosition)) {
|
|
1529
|
+
this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft, this.scrollTop]);
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
updateCells(events) {
|
|
1533
|
+
events.forEach((evt) => this.tableModel.getAreaModel(evt.area).setValue(evt.rowIndex, evt.columnIndex, evt.value));
|
|
1534
|
+
this.repaint();
|
|
1535
|
+
}
|
|
1536
|
+
getAreaAndSideIdentByAttr(srcElement) {
|
|
1537
|
+
if (srcElement) {
|
|
1538
|
+
const dataArea = this.getStringByAttr(srcElement, "data-area");
|
|
1539
|
+
const dataSide = this.getStringByAttr(srcElement, "data-side");
|
|
1540
|
+
if (dataSide && dataArea) {
|
|
1541
|
+
return [dataArea, dataSide];
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
return [void 0, void 0];
|
|
1545
|
+
}
|
|
1546
|
+
getArea(rowIdent, sideIdent) {
|
|
1547
|
+
if (rowIdent === "header") {
|
|
1548
|
+
if (sideIdent === "west")
|
|
1549
|
+
return this.areaHeaderWest;
|
|
1550
|
+
if (sideIdent === "center")
|
|
1551
|
+
return this.areaHeaderCenter;
|
|
1552
|
+
if (sideIdent === "east")
|
|
1553
|
+
return this.areaHeaderEast;
|
|
1554
|
+
} else if (rowIdent === "body") {
|
|
1555
|
+
if (sideIdent === "west")
|
|
1556
|
+
return this.areaBodyWest;
|
|
1557
|
+
if (sideIdent === "center")
|
|
1558
|
+
return this.areaBodyCenter;
|
|
1559
|
+
if (sideIdent === "east")
|
|
1560
|
+
return this.areaBodyEast;
|
|
1561
|
+
} else if (rowIdent === "footer") {
|
|
1562
|
+
if (sideIdent === "west")
|
|
1563
|
+
return this.areaFooterWest;
|
|
1564
|
+
if (sideIdent === "center")
|
|
1565
|
+
return this.areaFooterCenter;
|
|
1566
|
+
if (sideIdent === "east")
|
|
1567
|
+
return this.areaFooterEast;
|
|
1568
|
+
}
|
|
1569
|
+
throw Error(`Wrong area identifier: row:${rowIdent}, col:${sideIdent}`);
|
|
1570
|
+
}
|
|
1571
|
+
adjustBody() {
|
|
1572
|
+
const virtualRowDivTopF1 = this.areaBodyCenterGeo.height - this.tableModel.getContentHeightInPixel();
|
|
1573
|
+
const virtualRowDivTop = this.scrollFactorY * virtualRowDivTopF1;
|
|
1574
|
+
this.dom.setStyle(this.contentDiv, "top", `${this.scrollTop}px`);
|
|
1575
|
+
this.dom.setStyle(this.contentDiv, "left", `${this.scrollViewport.scrollLeft}px`);
|
|
1576
|
+
this.adjustArea("body", virtualRowDivTop);
|
|
1577
|
+
}
|
|
1578
|
+
getNumberByAttr(srcElement, key) {
|
|
1579
|
+
var _a;
|
|
1580
|
+
if (srcElement) {
|
|
1581
|
+
const attr = (_a = srcElement.closest("[" + key + "]")) === null || _a === void 0 ? void 0 : _a.getAttribute(key);
|
|
1582
|
+
if (attr)
|
|
1583
|
+
return Number(attr);
|
|
1584
|
+
}
|
|
1585
|
+
return -1;
|
|
1586
|
+
}
|
|
1587
|
+
getStringByAttr(srcElement, key) {
|
|
1588
|
+
var _a;
|
|
1589
|
+
if (srcElement) {
|
|
1590
|
+
const attr = (_a = srcElement.closest("[" + key + "]")) === null || _a === void 0 ? void 0 : _a.getAttribute(key);
|
|
1591
|
+
if (attr)
|
|
1592
|
+
return attr;
|
|
1593
|
+
}
|
|
1594
|
+
return "";
|
|
1595
|
+
}
|
|
1596
|
+
adjustArea(areaIdent, yStart = 0) {
|
|
1597
|
+
var _a, _b;
|
|
1598
|
+
const westArea = this.getArea(areaIdent, "west");
|
|
1599
|
+
const centerArea = this.getArea(areaIdent, "center");
|
|
1600
|
+
const eastArea = this.getArea(areaIdent, "east");
|
|
1601
|
+
const divHeight = centerArea.child.clientHeight;
|
|
1602
|
+
westArea.child.innerText = "";
|
|
1603
|
+
centerArea.child.innerText = "";
|
|
1604
|
+
eastArea.child.innerText = "";
|
|
1605
|
+
const left = 0;
|
|
1606
|
+
const width = this.areaBodyCenterGeo.width;
|
|
1607
|
+
const padding = this.tableModel.getPadding();
|
|
1608
|
+
const areaModel = this.tableModel.getAreaModel(areaIdent);
|
|
1609
|
+
const rowCount = areaModel.getRowCount();
|
|
1610
|
+
while (this.cleanupFunctions[areaIdent].length) {
|
|
1611
|
+
const fn = this.cleanupFunctions[areaIdent].shift();
|
|
1612
|
+
if (fn) {
|
|
1613
|
+
fn();
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
let y = yStart;
|
|
1617
|
+
const columnCount = this.tableModel.getColumnCount();
|
|
1618
|
+
const fixedRightColumnCount = this.tableModel.getFixedRightColumnCount();
|
|
1619
|
+
const fixedLeftColumnCount = this.tableModel.getFixedLeftColumnCount();
|
|
1620
|
+
for (let index = 0; index < rowCount; index++) {
|
|
1621
|
+
const top = y;
|
|
1622
|
+
const lastRowOfModel = index === rowCount - 1;
|
|
1623
|
+
const height = this.tableModel.getRowHeight(areaIdent, index);
|
|
1624
|
+
if (top + height > 0) {
|
|
1625
|
+
this.firstVisibleRowIndex = index;
|
|
1626
|
+
let geo = { left, width, height, top, index };
|
|
1627
|
+
let rowDiv = this.dom.addRowDiv(centerArea, geo, index, areaIdent, "center");
|
|
1628
|
+
const centerStartCol = fixedLeftColumnCount;
|
|
1629
|
+
this.adjustColumnsToRowParent({
|
|
1630
|
+
areaIdent,
|
|
1631
|
+
sideIdent: "center",
|
|
1632
|
+
areaModel,
|
|
1633
|
+
geo,
|
|
1634
|
+
parent: rowDiv,
|
|
1635
|
+
rowIndex: index,
|
|
1636
|
+
columnIndexStart: centerStartCol,
|
|
1637
|
+
columnIndexEnd: columnCount - fixedRightColumnCount - 1,
|
|
1638
|
+
verticalFixed: false,
|
|
1639
|
+
lastRowOfModel
|
|
1640
|
+
});
|
|
1641
|
+
if (padding.left > 0) {
|
|
1642
|
+
geo = { left, width: this.areaBodyWestGeo.width, height, top, index };
|
|
1643
|
+
rowDiv = this.dom.addRowDiv(westArea, geo, index, areaIdent, "west");
|
|
1644
|
+
this.adjustColumnsToRowParent({
|
|
1645
|
+
areaIdent,
|
|
1646
|
+
sideIdent: "west",
|
|
1647
|
+
areaModel,
|
|
1648
|
+
geo,
|
|
1649
|
+
parent: rowDiv,
|
|
1650
|
+
rowIndex: index,
|
|
1651
|
+
columnIndexStart: 0,
|
|
1652
|
+
columnIndexEnd: centerStartCol - 1,
|
|
1653
|
+
verticalFixed: true,
|
|
1654
|
+
lastRowOfModel
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
if (padding.right > 0) {
|
|
1658
|
+
geo = { left, width: this.areaBodyEastGeo.width, height, top, index };
|
|
1659
|
+
rowDiv = this.dom.addRowDiv(eastArea, geo, index, areaIdent, "east");
|
|
1660
|
+
this.adjustColumnsToRowParent({
|
|
1661
|
+
areaIdent,
|
|
1662
|
+
sideIdent: "east",
|
|
1663
|
+
areaModel,
|
|
1664
|
+
geo,
|
|
1665
|
+
parent: rowDiv,
|
|
1666
|
+
rowIndex: index,
|
|
1667
|
+
columnIndexStart: columnCount - fixedRightColumnCount,
|
|
1668
|
+
columnIndexEnd: columnCount - 1,
|
|
1669
|
+
verticalFixed: true,
|
|
1670
|
+
lastRowOfModel
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
if (areaIdent === "header" && this.tree && index === rowCount - 1) {
|
|
1674
|
+
const div = this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(rowDiv, new GeoData(16, 20, 20, 8)), "data-ge-action", "toggleExpandCollapseAll"), { "cursor": "pointer" });
|
|
1675
|
+
const treeOptionsArrow = this.tableOptions.treeOptions.arrowExpandCollapseAll;
|
|
1676
|
+
if (treeOptionsArrow) {
|
|
1677
|
+
const textElement = this.dom.domService.createText(treeOptionsArrow.content);
|
|
1678
|
+
this.dom.domService.appendChild(div, textElement);
|
|
1679
|
+
if (treeOptionsArrow.style) {
|
|
1680
|
+
this.dom.applyStyleString(div, treeOptionsArrow.style);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
y = y + height;
|
|
1686
|
+
if (y > divHeight) {
|
|
1687
|
+
break;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
if (this.colAndRowspanModels && this.colAndRowspanModels[areaIdent]) {
|
|
1691
|
+
const ranges = (_b = (_a = this.colAndRowspanModels[areaIdent]) === null || _a === void 0 ? void 0 : _a.getRanges()) !== null && _b !== void 0 ? _b : [];
|
|
1692
|
+
if (ranges.length) {
|
|
1693
|
+
for (const range of ranges) {
|
|
1694
|
+
let xStart = 0;
|
|
1695
|
+
let child = centerArea.child;
|
|
1696
|
+
let sideIdent = "center";
|
|
1697
|
+
if (range.c1 < fixedLeftColumnCount) {
|
|
1698
|
+
child = westArea.child;
|
|
1699
|
+
sideIdent = "west";
|
|
1700
|
+
} else if (fixedRightColumnCount > 0 && range.c1 >= columnCount - fixedRightColumnCount) {
|
|
1701
|
+
child = eastArea.child;
|
|
1702
|
+
sideIdent = "east";
|
|
1703
|
+
} else {
|
|
1704
|
+
const virtualRowDivLeftF1 = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1705
|
+
xStart = this.scrollFactorX * virtualRowDivLeftF1 - this.areaBodyWestGeo.width;
|
|
1706
|
+
sideIdent = "center";
|
|
1707
|
+
}
|
|
1708
|
+
this.drawBigCell(range, xStart, yStart, areaModel, child, sideIdent);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
drawBigCell(range, xStart, yStart, areaModel, parentDiv, sideIdent) {
|
|
1714
|
+
const y1 = yStart + this.getRowHeights(0, range.r1 - 1, areaModel).reduce((a, b) => a + b, 0);
|
|
1715
|
+
const columnCount = this.tableModel.getColumnCount();
|
|
1716
|
+
const fixedRightColumnCount = this.tableModel.getFixedRightColumnCount();
|
|
1717
|
+
let firstColIdx = 0;
|
|
1718
|
+
if (fixedRightColumnCount > 0 && range.c1 >= columnCount - fixedRightColumnCount) {
|
|
1719
|
+
firstColIdx = columnCount - fixedRightColumnCount;
|
|
1720
|
+
}
|
|
1721
|
+
const x1 = xStart + this.getColumnWidths(firstColIdx, range.c1 - 1).reduce((a, b) => a + b, 0);
|
|
1722
|
+
const h = this.getRowHeights(range.r1, range.r2, areaModel).reduce((a, b) => a + b, 0);
|
|
1723
|
+
const w = this.getColumnWidths(range.c1, range.c2).reduce((a, b) => a + b, 0);
|
|
1724
|
+
let cellSelected = false;
|
|
1725
|
+
const selectionModel2 = this.getSelectionModel ? this.getSelectionModel() : void 0;
|
|
1726
|
+
if (selectionModel2) {
|
|
1727
|
+
const count = selectionModel2.getSelectionCount(range.r1, range.c1);
|
|
1728
|
+
cellSelected = count > 0;
|
|
1729
|
+
}
|
|
1730
|
+
if (range.gammaRange) {
|
|
1731
|
+
console.info("TODO here", range);
|
|
1732
|
+
this.renderCell({
|
|
1733
|
+
areaModel,
|
|
1734
|
+
areaIdent: areaModel.areaIdent,
|
|
1735
|
+
sideIdent,
|
|
1736
|
+
rowIndex: range.r1,
|
|
1737
|
+
columnIndex: range.c1,
|
|
1738
|
+
left: x1,
|
|
1739
|
+
top: y1,
|
|
1740
|
+
width: w,
|
|
1741
|
+
height: h,
|
|
1742
|
+
parent: parentDiv,
|
|
1743
|
+
cellSelected,
|
|
1744
|
+
lastRowOfModel: true,
|
|
1745
|
+
gammaRange: range.gammaRange
|
|
1746
|
+
});
|
|
1747
|
+
} else {
|
|
1748
|
+
this.renderCell({
|
|
1749
|
+
areaModel,
|
|
1750
|
+
areaIdent: areaModel.areaIdent,
|
|
1751
|
+
sideIdent,
|
|
1752
|
+
rowIndex: range.r1,
|
|
1753
|
+
columnIndex: range.c1,
|
|
1754
|
+
left: x1,
|
|
1755
|
+
top: y1,
|
|
1756
|
+
width: w,
|
|
1757
|
+
height: h,
|
|
1758
|
+
parent: parentDiv,
|
|
1759
|
+
cellSelected,
|
|
1760
|
+
lastRowOfModel: true,
|
|
1761
|
+
gammaRange: range.gammaRange
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
if (areaModel.areaIdent === "header" && this.tableOptions.columnsResizable) {
|
|
1765
|
+
this.renderHeaderCellResizeHandle({
|
|
1766
|
+
rowIndex: range.r1,
|
|
1767
|
+
columnIndex: range.c1,
|
|
1768
|
+
cellLeft: x1,
|
|
1769
|
+
cellTop: y1,
|
|
1770
|
+
cellWidth: w,
|
|
1771
|
+
cellHeight: h,
|
|
1772
|
+
parent: parentDiv
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
findRowOfImportantRowspanCell(areaModel, rowIndex, colIndex) {
|
|
1777
|
+
const maxRowspan = areaModel.getMaxRowspan();
|
|
1778
|
+
for (let r = rowIndex - 1; r > -1; r--) {
|
|
1779
|
+
const rowspan = areaModel.getRowspanAt(r, colIndex);
|
|
1780
|
+
if (rowspan > 1 && r + rowspan + 1 >= rowIndex) {
|
|
1781
|
+
return r;
|
|
1782
|
+
}
|
|
1783
|
+
if (rowIndex - r > maxRowspan) {
|
|
1784
|
+
return -1;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return -1;
|
|
1788
|
+
}
|
|
1789
|
+
adjustColumnsToRowParent({ areaIdent, sideIdent, areaModel, geo, parent, rowIndex, columnIndexStart, columnIndexEnd, verticalFixed = false, lastRowOfModel = false }) {
|
|
1790
|
+
var _a;
|
|
1791
|
+
this.scrollViewportLeft = this.scrollViewport.scrollLeft;
|
|
1792
|
+
let virtualRowDivLeft = 0;
|
|
1793
|
+
if (!verticalFixed) {
|
|
1794
|
+
const virtualRowDivLeftF1 = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1795
|
+
virtualRowDivLeft = this.scrollFactorX * virtualRowDivLeftF1;
|
|
1796
|
+
}
|
|
1797
|
+
const top = 0;
|
|
1798
|
+
const renderSelection = !!(areaIdent === "body" && sideIdent);
|
|
1799
|
+
let x = virtualRowDivLeft;
|
|
1800
|
+
for (let index = columnIndexStart; index <= columnIndexEnd; index++) {
|
|
1801
|
+
const left = x;
|
|
1802
|
+
const w = this.tableModel.getColumnWidth(index);
|
|
1803
|
+
if (w > 0 && left + w > 0) {
|
|
1804
|
+
let height = geo.height;
|
|
1805
|
+
const rowspan = areaModel.getRowspanAt(rowIndex, index);
|
|
1806
|
+
const colspan = areaModel.getColspanAt(rowIndex, index);
|
|
1807
|
+
if (rowspan > 1) {
|
|
1808
|
+
height = this.getRowHeights(rowIndex, rowIndex + rowspan - 1, areaModel).reduce((a, b) => a + b, 0);
|
|
1809
|
+
}
|
|
1810
|
+
let width = w;
|
|
1811
|
+
if (colspan > 1) {
|
|
1812
|
+
width = this.getColumnWidths(index, index + colspan - 1).reduce((a, b) => a + b, 0);
|
|
1813
|
+
}
|
|
1814
|
+
let skip = false;
|
|
1815
|
+
if (this.colAndRowspanModels && this.colAndRowspanModels[areaIdent]) {
|
|
1816
|
+
if ((_a = this.colAndRowspanModels[areaIdent]) === null || _a === void 0 ? void 0 : _a.isInRange(rowIndex, index)) {
|
|
1817
|
+
skip = true;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
if (this.draggingTargetColumnIndex === index && areaIdent !== "header") {
|
|
1821
|
+
this.renderDragTargetDiv(parent, left, top, width, height);
|
|
1822
|
+
const geo1 = { left, top, width, height };
|
|
1823
|
+
this.dom.addColumnBorderDivs(this.tableOptions, parent, geo1, areaIdent, sideIdent);
|
|
1824
|
+
} else {
|
|
1825
|
+
const cellSelected = this.renderSelectedBackgroundDiv(skip, renderSelection, sideIdent, areaModel, rowIndex, index, parent, left, top, width, height);
|
|
1826
|
+
if (!skip) {
|
|
1827
|
+
this.renderCell({
|
|
1828
|
+
areaModel,
|
|
1829
|
+
areaIdent,
|
|
1830
|
+
sideIdent,
|
|
1831
|
+
rowIndex,
|
|
1832
|
+
columnIndex: index,
|
|
1833
|
+
left,
|
|
1834
|
+
top,
|
|
1835
|
+
width,
|
|
1836
|
+
height,
|
|
1837
|
+
parent,
|
|
1838
|
+
cellSelected,
|
|
1839
|
+
lastRowOfModel,
|
|
1840
|
+
gammaRange: true
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
if (areaIdent === "header" && this.tableOptions.columnsResizable) {
|
|
1844
|
+
this.renderHeaderCellResizeHandle({
|
|
1845
|
+
rowIndex,
|
|
1846
|
+
columnIndex: index,
|
|
1847
|
+
cellLeft: left,
|
|
1848
|
+
cellTop: top,
|
|
1849
|
+
cellWidth: width,
|
|
1850
|
+
cellHeight: height,
|
|
1851
|
+
parent
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
x = x + w;
|
|
1857
|
+
if (x > this.areaBodyCenterGeo.width) {
|
|
1858
|
+
break;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
if (this.tableOptions.verticalBorderVisible) {
|
|
1862
|
+
this.dom.addVerticalBorder(new GeoData(x - 1, 1, geo.height, 0), parent);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
getTreeArrowColumnIndex() {
|
|
1866
|
+
if (this.tableOptions.showCheckboxWihoutExtraColumn) {
|
|
1867
|
+
return 0;
|
|
1868
|
+
}
|
|
1869
|
+
if (this.tableModel.isRowCheckboxVisible()) {
|
|
1870
|
+
return 1;
|
|
1871
|
+
}
|
|
1872
|
+
return 0;
|
|
1873
|
+
}
|
|
1874
|
+
addAndRenderCellDiv({ areaModel, areaIdent, sideIdent, rowIndex, index, left, width, height, top, parent, lastRowOfModel }) {
|
|
1875
|
+
var _a;
|
|
1876
|
+
const editor = this.editorRenderer && this.editorRendererRow === rowIndex && this.editorRendererColumn === index;
|
|
1877
|
+
const cellRenderer = editor ? this.editorRenderer : areaModel.getCellRenderer(rowIndex, index);
|
|
1878
|
+
const geo = { left, width, height, top, index };
|
|
1879
|
+
const rowObject = areaModel.getRowByIndex(rowIndex);
|
|
1880
|
+
let treeArrow = "none";
|
|
1881
|
+
const arrowIndexOk = index === this.getTreeArrowColumnIndex();
|
|
1882
|
+
if (arrowIndexOk && rowObject instanceof TreeRow) {
|
|
1883
|
+
const tr = rowObject;
|
|
1884
|
+
if ((_a = tr.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1885
|
+
if (tr.expanded) {
|
|
1886
|
+
treeArrow = "expanded";
|
|
1887
|
+
} else {
|
|
1888
|
+
treeArrow = "collapsed";
|
|
1889
|
+
}
|
|
1890
|
+
} else {
|
|
1891
|
+
treeArrow = "hidden";
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
let sortState = void 0;
|
|
1895
|
+
if (areaIdent === "header") {
|
|
1896
|
+
const columnDef2 = this.tableModel.getColumnDef(index);
|
|
1897
|
+
if (!(columnDef2 === null || columnDef2 === void 0 ? void 0 : columnDef2.sortIconVisible) || (columnDef2 === null || columnDef2 === void 0 ? void 0 : columnDef2.sortIconVisible())) {
|
|
1898
|
+
sortState = columnDef2 === null || columnDef2 === void 0 ? void 0 : columnDef2.sortState;
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
const val = areaModel.getValueAt(rowIndex, index);
|
|
1902
|
+
const text = cellRenderer ? "" : `${val}`;
|
|
1903
|
+
const checkedType = areaModel.isRowChecked(rowIndex);
|
|
1904
|
+
const cell = this.dom.addColumnDiv(parent, geo, rowIndex, index, areaIdent, sideIdent, text, treeArrow, this.tableOptions, checkedType, sortState);
|
|
1905
|
+
const tooltip = areaModel.getTooltipAt(rowIndex, index);
|
|
1906
|
+
if (tooltip) {
|
|
1907
|
+
this.dom.setAttribute(cell, "title", tooltip);
|
|
1908
|
+
}
|
|
1909
|
+
const columnDef = this.tableModel.getColumnDef(index);
|
|
1910
|
+
if (columnDef && columnDef.classes[areaIdent]) {
|
|
1911
|
+
this.dom.addClasses(columnDef.classes[areaIdent], cell);
|
|
1912
|
+
}
|
|
1913
|
+
let fn = void 0;
|
|
1914
|
+
if (cellRenderer) {
|
|
1915
|
+
fn = cellRenderer.render(cell, rowIndex, index, areaIdent, areaModel, val, this.dom.domService);
|
|
1916
|
+
}
|
|
1917
|
+
const classes = areaModel.getCustomClassesAt(rowIndex, index);
|
|
1918
|
+
if (classes.length) {
|
|
1919
|
+
this.dom.addClasses(classes, cell);
|
|
1920
|
+
}
|
|
1921
|
+
this.dom.addColumnBorderDivs(this.tableOptions, parent, geo, areaIdent, sideIdent);
|
|
1922
|
+
if (lastRowOfModel) {
|
|
1923
|
+
this.dom.addHorizontalBorder({ left, width, height, top: top + height }, parent);
|
|
1924
|
+
}
|
|
1925
|
+
if (this.getFocusModel && areaIdent === "body") {
|
|
1926
|
+
const fm = this.getFocusModel();
|
|
1927
|
+
if (fm === null || fm === void 0 ? void 0 : fm.hasFocus(rowIndex, index)) {
|
|
1928
|
+
this.dom.addFocusBorderDivs(parent, geo, {});
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
if (areaIdent === "header") {
|
|
1932
|
+
this.dom.setAttribute(cell, "data-ge-action", "drag-column");
|
|
1933
|
+
}
|
|
1934
|
+
const styles = areaModel.getCustomStyleAt(rowIndex, index);
|
|
1935
|
+
if (styles) {
|
|
1936
|
+
for (const css in styles) {
|
|
1937
|
+
this.dom.setStyle(cell, css, styles[css]);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
return [cell, fn];
|
|
1941
|
+
}
|
|
1942
|
+
getColumnWidths(startIndex, endIndex) {
|
|
1943
|
+
const ret = [];
|
|
1944
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
1945
|
+
ret.push(this.tableModel.getColumnWidth(i));
|
|
1946
|
+
}
|
|
1947
|
+
return ret;
|
|
1948
|
+
}
|
|
1949
|
+
getRowHeights(startIndex, endIndex, areaModel) {
|
|
1950
|
+
const ret = [];
|
|
1951
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
1952
|
+
ret.push(areaModel.getRowHeight(i));
|
|
1953
|
+
}
|
|
1954
|
+
return ret;
|
|
1955
|
+
}
|
|
1956
|
+
adjustHoverRows(mouseMoveEvent) {
|
|
1957
|
+
if (this.tableOptions.hoverRowVisible && mouseMoveEvent.rowIndex > -1) {
|
|
1958
|
+
const width = this.hostElement.clientWidth;
|
|
1959
|
+
const rowHeight = this.tableModel.getAreaModel("body").getRowHeight(mouseMoveEvent.rowIndex);
|
|
1960
|
+
const top = mouseMoveEvent.rowTop + this.areaHeaderCenter.parent.clientHeight - this.scrollTop;
|
|
1961
|
+
this.dom.applyStyle(this.hoverRow, {
|
|
1962
|
+
"left": "0",
|
|
1963
|
+
"top": top + "px",
|
|
1964
|
+
"width": width + "px",
|
|
1965
|
+
"height": rowHeight + "px",
|
|
1966
|
+
"display": "block"
|
|
1967
|
+
});
|
|
1968
|
+
} else {
|
|
1969
|
+
this.hideHoverRow();
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
hideHoverRow() {
|
|
1973
|
+
this.dom.applyStyle(this.hoverRow, {
|
|
1974
|
+
"display": "none"
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
adjustHoverColumns(mouseMoveEvent) {
|
|
1978
|
+
if (this.tableOptions.hoverColumnVisible && mouseMoveEvent.rowIndex > -1) {
|
|
1979
|
+
const height = this.hostElement.clientHeight;
|
|
1980
|
+
const width = this.tableModel.getColumnWidth(mouseMoveEvent.columnIndex);
|
|
1981
|
+
const fixedWest = this.areaBodyWestGeo.width;
|
|
1982
|
+
const left = mouseMoveEvent.columnLeft + this.tableModel.getPadding().left - this.scrollLeft - fixedWest;
|
|
1983
|
+
this.dom.applyStyle(this.hoverColumn, {
|
|
1984
|
+
"left": left + "px",
|
|
1985
|
+
"top": "0px",
|
|
1986
|
+
"width": width + "px",
|
|
1987
|
+
"height": height + "px",
|
|
1988
|
+
"display": "block"
|
|
1989
|
+
});
|
|
1990
|
+
} else {
|
|
1991
|
+
this.hideHoverColumn();
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
hideHoverColumn() {
|
|
1995
|
+
this.dom.applyStyle(this.hoverColumn, {
|
|
1996
|
+
"display": "none"
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
debounce(fn, delay = 1e3) {
|
|
2000
|
+
if (this.debounceTimeout) {
|
|
2001
|
+
clearTimeout(this.debounceTimeout);
|
|
2002
|
+
}
|
|
2003
|
+
this.debounceTimeout = setTimeout(fn.bind(this), delay);
|
|
2004
|
+
}
|
|
2005
|
+
renderDragTargetDiv(parent, left, top, width, height) {
|
|
2006
|
+
const div = this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-drop-zone", parent));
|
|
2007
|
+
this.dom.setStyle(div, "left", `${left}px`);
|
|
2008
|
+
this.dom.setStyle(div, "top", `${top}px`);
|
|
2009
|
+
this.dom.setStyle(div, "width", `${width}px`);
|
|
2010
|
+
this.dom.setStyle(div, "height", `${height}px`);
|
|
2011
|
+
return div;
|
|
2012
|
+
}
|
|
2013
|
+
renderSelectedBackgroundDiv(skip, renderSelection, sideIdent, areaModel, rowIndex, index, parent, left, top, width, height) {
|
|
2014
|
+
let cellSelected = false;
|
|
2015
|
+
if (!skip && renderSelection && areaModel.isSelectable(rowIndex, index)) {
|
|
2016
|
+
if (this.getSelectionModel) {
|
|
2017
|
+
const selectionModel2 = this.getSelectionModel();
|
|
2018
|
+
if (selectionModel2) {
|
|
2019
|
+
const count = selectionModel2.getSelectionCount(rowIndex, index);
|
|
2020
|
+
cellSelected = count > 0;
|
|
2021
|
+
for (let i = 0; i < count; i++) {
|
|
2022
|
+
const div = this.dom.applyStylePosistionAbsolute(
|
|
2023
|
+
this.dom.createDivWithClass(`ge-table-${areaModel.areaIdent}-${sideIdent}-selected-range`, parent)
|
|
2024
|
+
);
|
|
2025
|
+
this.dom.setStyle(div, "left", `${left}px`);
|
|
2026
|
+
this.dom.setStyle(div, "top", `${top}px`);
|
|
2027
|
+
this.dom.setStyle(div, "width", `${width}px`);
|
|
2028
|
+
this.dom.setStyle(div, "height", `${height}px`);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
return cellSelected;
|
|
2034
|
+
}
|
|
2035
|
+
renderCell({ areaModel, areaIdent, sideIdent, rowIndex, columnIndex, left, top, width, height, parent, cellSelected, lastRowOfModel, gammaRange }) {
|
|
2036
|
+
const [div, fn] = this.addAndRenderCellDiv({
|
|
2037
|
+
areaModel,
|
|
2038
|
+
areaIdent,
|
|
2039
|
+
sideIdent,
|
|
2040
|
+
rowIndex,
|
|
2041
|
+
index: columnIndex,
|
|
2042
|
+
left,
|
|
2043
|
+
width,
|
|
2044
|
+
height,
|
|
2045
|
+
top,
|
|
2046
|
+
parent,
|
|
2047
|
+
lastRowOfModel,
|
|
2048
|
+
gammaRange
|
|
2049
|
+
});
|
|
2050
|
+
if (cellSelected) {
|
|
2051
|
+
this.dom.addClass(`ge-table-${areaIdent}-${sideIdent}-selected-range`, div);
|
|
2052
|
+
}
|
|
2053
|
+
if (fn) {
|
|
2054
|
+
this.cleanupFunctions[areaIdent].push(fn);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
renderHeaderCellResizeHandle({ rowIndex, columnIndex, cellLeft, cellTop, cellWidth, cellHeight, parent }) {
|
|
2058
|
+
var _a;
|
|
2059
|
+
const domService = this.dom.domService;
|
|
2060
|
+
const handleWidth = (_a = this.tableOptions.columnResizeHandleWidthInPx) !== null && _a !== void 0 ? _a : 2;
|
|
2061
|
+
const div = domService.createElement("div");
|
|
2062
|
+
domService.setAttribute(div, "data-col-index", `${columnIndex}`);
|
|
2063
|
+
domService.setAttribute(div, "data-row-index", `${rowIndex}`);
|
|
2064
|
+
domService.setAttribute(div, "data-area", "header");
|
|
2065
|
+
domService.setAttribute(div, "data-ge-action", "resize-column");
|
|
2066
|
+
domService.addClass(div, `ge-table-column-resize-handle`);
|
|
2067
|
+
domService.setStyle(div, "display", "clip");
|
|
2068
|
+
domService.setStyle(div, "position", "absolute");
|
|
2069
|
+
domService.setStyle(div, "cursor", "col-resize");
|
|
2070
|
+
domService.setStyle(div, "left", `${cellLeft + cellWidth - handleWidth}px`);
|
|
2071
|
+
domService.setStyle(div, "top", `${cellTop}px`);
|
|
2072
|
+
domService.setStyle(div, "width", `${handleWidth}px`);
|
|
2073
|
+
domService.setStyle(div, "height", `${cellHeight}px`);
|
|
2074
|
+
domService.appendChild(parent, div);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
class SortItem {
|
|
2078
|
+
constructor(columnIndex, sortState) {
|
|
2079
|
+
this.columnIndex = columnIndex;
|
|
2080
|
+
this.sortState = sortState;
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
class InputHandler {
|
|
2084
|
+
constructor(tableScope) {
|
|
2085
|
+
this.tableScope = tableScope;
|
|
2086
|
+
this.tableScope.hostElement.addEventListener("change", this.onHostElementChanged.bind(this));
|
|
2087
|
+
}
|
|
2088
|
+
onHostElementChanged(event) {
|
|
2089
|
+
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLSelectElement || event.target instanceof HTMLTextAreaElement) {
|
|
2090
|
+
const htmpInputEle = event.target;
|
|
2091
|
+
const areaIdentStr = htmpInputEle.getAttribute("data-area");
|
|
2092
|
+
const rowIndexStr = htmpInputEle.getAttribute("data-row-index");
|
|
2093
|
+
const columnIndexStr = htmpInputEle.getAttribute("data-col-index");
|
|
2094
|
+
if (areaIdentStr && rowIndexStr && columnIndexStr) {
|
|
2095
|
+
const area = getAreaIdentByString(areaIdentStr);
|
|
2096
|
+
const rowIndex = Number(rowIndexStr);
|
|
2097
|
+
const columnIndex = Number(columnIndexStr);
|
|
2098
|
+
this.tableScope.updateModelValueAfterEdit(area, rowIndex, columnIndex, htmpInputEle.value);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
class GeCellIndices {
|
|
2104
|
+
constructor(rowIndex = -1, columnIndex = -1) {
|
|
2105
|
+
this.rowIndex = rowIndex;
|
|
2106
|
+
this.columnIndex = columnIndex;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
class GeModelChangeEvent {
|
|
2110
|
+
constructor(cells) {
|
|
2111
|
+
this.cells = cells;
|
|
2112
|
+
}
|
|
2113
|
+
static createSingle(rowIndex, columnIndex) {
|
|
2114
|
+
return new GeModelChangeEvent([new GeCellIndices(rowIndex, columnIndex)]);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
class SelectionService {
|
|
2118
|
+
constructor(tableScope) {
|
|
2119
|
+
var _a, _b;
|
|
2120
|
+
this.tableScope = tableScope;
|
|
2121
|
+
if ((_a = this.tableScope.tableOptions) === null || _a === void 0 ? void 0 : _a.getSelectionModel) {
|
|
2122
|
+
this.getSelectionModel = this.tableScope.tableOptions.getSelectionModel;
|
|
2123
|
+
}
|
|
2124
|
+
if ((_b = this.tableScope.tableOptions) === null || _b === void 0 ? void 0 : _b.getFocusModel) {
|
|
2125
|
+
this.getFocusModel = this.tableScope.tableOptions.getFocusModel;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
onMouseClicked(evt, _previousEvt) {
|
|
2129
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2130
|
+
let dirty = false;
|
|
2131
|
+
let deletePreviousEvent = false;
|
|
2132
|
+
if (this.getSelectionModel && this.getFocusModel) {
|
|
2133
|
+
const sm = this.getSelectionModel();
|
|
2134
|
+
const fm = this.getFocusModel();
|
|
2135
|
+
if (sm && fm) {
|
|
2136
|
+
if (!fm.hasFocus(evt.rowIndex, evt.columnIndex)) {
|
|
2137
|
+
fm.setFocus(evt.rowIndex, evt.columnIndex);
|
|
2138
|
+
dirty = true;
|
|
2139
|
+
}
|
|
2140
|
+
if (!((_a = evt.originalEvent) === null || _a === void 0 ? void 0 : _a.shiftKey)) {
|
|
2141
|
+
if (sm.hasSelection()) {
|
|
2142
|
+
sm.clear();
|
|
2143
|
+
dirty = true;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (((_b = evt.originalEvent) === null || _b === void 0 ? void 0 : _b.shiftKey) && this.previousEvt) {
|
|
2147
|
+
sm.addSelection(this.createRangeByEvents(evt, this.previousEvt));
|
|
2148
|
+
deletePreviousEvent = true;
|
|
2149
|
+
dirty = true;
|
|
2150
|
+
} else if (((_c = evt.originalEvent) === null || _c === void 0 ? void 0 : _c.ctrlKey) || ((_d = evt.originalEvent) === null || _d === void 0 ? void 0 : _d.metaKey)) {
|
|
2151
|
+
sm.addSelection(CellRange.singleCell(evt.rowIndex, evt.columnIndex));
|
|
2152
|
+
deletePreviousEvent = true;
|
|
2153
|
+
dirty = true;
|
|
2154
|
+
} else if (((_e = evt.originalEvent) === null || _e === void 0 ? void 0 : _e.altKey) && (((_f = evt.originalEvent) === null || _f === void 0 ? void 0 : _f.ctrlKey) || ((_g = evt.originalEvent) === null || _g === void 0 ? void 0 : _g.metaKey))) {
|
|
2155
|
+
sm.removeSelection(CellRange.singleCell(evt.rowIndex, evt.columnIndex));
|
|
2156
|
+
deletePreviousEvent = true;
|
|
2157
|
+
dirty = true;
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
if (deletePreviousEvent) {
|
|
2162
|
+
this.previousEvt = void 0;
|
|
2163
|
+
} else {
|
|
2164
|
+
this.previousEvt = evt === null || evt === void 0 ? void 0 : evt.clone();
|
|
2165
|
+
}
|
|
2166
|
+
return dirty;
|
|
2167
|
+
}
|
|
2168
|
+
onActionTriggered(actionId) {
|
|
2169
|
+
if (this.getSelectionModel && this.getFocusModel) {
|
|
2170
|
+
const sm = this.getSelectionModel();
|
|
2171
|
+
const fm = this.getFocusModel();
|
|
2172
|
+
if (sm && fm) {
|
|
2173
|
+
if (actionId === "SELECT_ALL") {
|
|
2174
|
+
sm.selectAll();
|
|
2175
|
+
this.tableScope.repaint();
|
|
2176
|
+
return true;
|
|
2177
|
+
}
|
|
2178
|
+
if (actionId === "DESELECT_ALL") {
|
|
2179
|
+
sm.clear();
|
|
2180
|
+
this.tableScope.repaint();
|
|
2181
|
+
return true;
|
|
2182
|
+
}
|
|
2183
|
+
if (actionId === "TOGGLE_SELECTION") {
|
|
2184
|
+
const [row, col] = fm.getFocus();
|
|
2185
|
+
sm.togglePoint(row, col);
|
|
2186
|
+
this.tableScope.repaint();
|
|
2187
|
+
return true;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
return false;
|
|
2192
|
+
}
|
|
2193
|
+
createRangeByEvents(evt, previousEvt) {
|
|
2194
|
+
if (!previousEvt) {
|
|
2195
|
+
previousEvt = evt;
|
|
2196
|
+
}
|
|
2197
|
+
const r1 = Math.min(evt.rowIndex, previousEvt === null || previousEvt === void 0 ? void 0 : previousEvt.rowIndex);
|
|
2198
|
+
const r2 = Math.max(evt.rowIndex, previousEvt === null || previousEvt === void 0 ? void 0 : previousEvt.rowIndex);
|
|
2199
|
+
const c1 = Math.min(evt.columnIndex, previousEvt === null || previousEvt === void 0 ? void 0 : previousEvt.columnIndex);
|
|
2200
|
+
const c2 = Math.max(evt.columnIndex, previousEvt === null || previousEvt === void 0 ? void 0 : previousEvt.columnIndex);
|
|
2201
|
+
return CellRange.create({
|
|
2202
|
+
rowIndex1: r1,
|
|
2203
|
+
columnIndex1: c1,
|
|
2204
|
+
rowIndex2: r2,
|
|
2205
|
+
columnIndex2: c2
|
|
2206
|
+
});
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
class WindowsShortcutActionIdMapping {
|
|
2210
|
+
get() {
|
|
2211
|
+
return {
|
|
2212
|
+
"f2": "START_EDITING",
|
|
2213
|
+
"space": "TOGGLE_SELECTION",
|
|
2214
|
+
"ctrl+num_add": "SELECT_ALL",
|
|
2215
|
+
"ctrl+a": "SELECT_ALL",
|
|
2216
|
+
"ctrl+shift+a": "DESELECT_ALL",
|
|
2217
|
+
"ctrl+x": "DESELECT_ALL",
|
|
2218
|
+
"ctrl+num_subtract": "DESELECT_ALL",
|
|
2219
|
+
"cmd -": "DESELECT_ALL",
|
|
2220
|
+
"arrowup": "NAVIGATE_UP",
|
|
2221
|
+
"arrowdown": "NAVIGATE_DOWN",
|
|
2222
|
+
"arrowleft": "NAVIGATE_LEFT",
|
|
2223
|
+
"arrowright": "NAVIGATE_RIGHT"
|
|
2224
|
+
};
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
class OsxShortcutActionIdMapping {
|
|
2228
|
+
get() {
|
|
2229
|
+
return {
|
|
2230
|
+
"f2": "START_EDITING",
|
|
2231
|
+
"space": "TOGGLE_SELECTION",
|
|
2232
|
+
"ctrl+num_add": "SELECT_ALL",
|
|
2233
|
+
"cmd+a": "SELECT_ALL",
|
|
2234
|
+
"ctrl+a": "SELECT_ALL",
|
|
2235
|
+
"cmd+x": "DESELECT_ALL",
|
|
2236
|
+
"cmd+shift+a": "DESELECT_ALL",
|
|
2237
|
+
"ctrl+shift+a": "DESELECT_ALL",
|
|
2238
|
+
"ctrl+num_subtract": "DESELECT_ALL",
|
|
2239
|
+
"ctrl -": "DESELECT_ALL",
|
|
2240
|
+
"arrowup": "NAVIGATE_UP",
|
|
2241
|
+
"arrowdown": "NAVIGATE_DOWN",
|
|
2242
|
+
"arrowleft": "NAVIGATE_LEFT",
|
|
2243
|
+
"arrowright": "NAVIGATE_RIGHT"
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
class ShortcutService {
|
|
2248
|
+
constructor(tableScope) {
|
|
2249
|
+
this.tableScope = tableScope;
|
|
2250
|
+
this.shortcutActionIdMapping = {};
|
|
2251
|
+
this.listener = [];
|
|
2252
|
+
this.listener.push(tableScope);
|
|
2253
|
+
this.init();
|
|
2254
|
+
}
|
|
2255
|
+
addListener(listener) {
|
|
2256
|
+
if (!this.listener.includes(listener)) {
|
|
2257
|
+
this.listener.push(listener);
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
init() {
|
|
2261
|
+
if (this.isMacintosh()) {
|
|
2262
|
+
Object.assign(this.shortcutActionIdMapping, new OsxShortcutActionIdMapping().get());
|
|
2263
|
+
} else {
|
|
2264
|
+
Object.assign(this.shortcutActionIdMapping, new WindowsShortcutActionIdMapping().get());
|
|
2265
|
+
}
|
|
2266
|
+
Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping);
|
|
2267
|
+
if (this.isDebug()) {
|
|
2268
|
+
console.debug("ShortcutService", this.shortcutActionIdMapping);
|
|
2269
|
+
}
|
|
2270
|
+
this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this));
|
|
2271
|
+
}
|
|
2272
|
+
isMacintosh() {
|
|
2273
|
+
return navigator.platform.indexOf("Mac") > -1;
|
|
2274
|
+
}
|
|
2275
|
+
isDebug() {
|
|
2276
|
+
return this.isLocalhost();
|
|
2277
|
+
}
|
|
2278
|
+
isLocalhost() {
|
|
2279
|
+
return location.hostname === "localhost" || location.hostname === "127.0.0.1";
|
|
2280
|
+
}
|
|
2281
|
+
onKeyDown(evt) {
|
|
2282
|
+
const actionId = this.findEnty(evt);
|
|
2283
|
+
if (actionId) {
|
|
2284
|
+
const consumed = this.emit(actionId);
|
|
2285
|
+
if (consumed) {
|
|
2286
|
+
evt.preventDefault();
|
|
2287
|
+
evt.stopPropagation();
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
emit(actionId) {
|
|
2292
|
+
if (this.isDebug()) {
|
|
2293
|
+
console.debug("ShortcutService emit:", actionId);
|
|
2294
|
+
}
|
|
2295
|
+
let ret = false;
|
|
2296
|
+
for (const l of this.listener) {
|
|
2297
|
+
const consumed = l.onActionTriggered(actionId);
|
|
2298
|
+
if (consumed) {
|
|
2299
|
+
ret = true;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
return ret;
|
|
2303
|
+
}
|
|
2304
|
+
findEnty(evt) {
|
|
2305
|
+
const tokens = this.getTokenByEvent(evt);
|
|
2306
|
+
if (this.isDebug()) {
|
|
2307
|
+
console.debug("ShortcutService tokens:", tokens);
|
|
2308
|
+
}
|
|
2309
|
+
for (const key in this.shortcutActionIdMapping) {
|
|
2310
|
+
const shortcutTokens = key.replace(/opt/g, "alt").replace(/cmd/g, "meta").split(/[\+ ]/g).sort();
|
|
2311
|
+
if (this.areTokensEquals(tokens, shortcutTokens)) {
|
|
2312
|
+
return this.shortcutActionIdMapping[key];
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
return void 0;
|
|
2316
|
+
}
|
|
2317
|
+
areTokensEquals(tokens1, tokens2) {
|
|
2318
|
+
if (tokens1.length !== tokens2.length) {
|
|
2319
|
+
return false;
|
|
2320
|
+
}
|
|
2321
|
+
if (tokens1.length === 0) {
|
|
2322
|
+
return false;
|
|
2323
|
+
}
|
|
2324
|
+
for (let i = 0; i < tokens1.length; i++) {
|
|
2325
|
+
if (tokens1[i] !== tokens2[i]) {
|
|
2326
|
+
return false;
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
return true;
|
|
2330
|
+
}
|
|
2331
|
+
getTokenByEvent(evt) {
|
|
2332
|
+
const tokens = [];
|
|
2333
|
+
if (evt.altKey) {
|
|
2334
|
+
tokens.push("alt");
|
|
2335
|
+
}
|
|
2336
|
+
if (evt.shiftKey) {
|
|
2337
|
+
tokens.push("shift");
|
|
2338
|
+
}
|
|
2339
|
+
if (evt.ctrlKey) {
|
|
2340
|
+
tokens.push("ctrl");
|
|
2341
|
+
}
|
|
2342
|
+
if (evt.metaKey) {
|
|
2343
|
+
tokens.push("meta");
|
|
2344
|
+
}
|
|
2345
|
+
if (evt.code) {
|
|
2346
|
+
tokens.push(evt.code.toLowerCase().replace(/key/g, ""));
|
|
2347
|
+
}
|
|
2348
|
+
return tokens.sort();
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
class EventAdapter {
|
|
2352
|
+
onCheckboxChanged(_evt) {
|
|
2353
|
+
}
|
|
2354
|
+
onContextmenu(_evt) {
|
|
2355
|
+
}
|
|
2356
|
+
onModelChanged(_evt) {
|
|
2357
|
+
}
|
|
2358
|
+
onMouseClicked(_evt) {
|
|
2359
|
+
}
|
|
2360
|
+
onMouseDragging(_evt) {
|
|
2361
|
+
}
|
|
2362
|
+
onMouseDraggingEnd(_evt) {
|
|
2363
|
+
}
|
|
2364
|
+
onMouseMoved(_evt) {
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
class TableScope extends RenderScope {
|
|
2368
|
+
constructor(hostElement, tableModel, domService, tableOptions, eventListener) {
|
|
2369
|
+
var _a;
|
|
2370
|
+
super(hostElement, tableModel, new ConvenienceDomService(domService), tableOptions);
|
|
2371
|
+
this.eventListener = eventListener;
|
|
2372
|
+
this.selectionService = new SelectionService(this);
|
|
2373
|
+
this.api = new TableApi(this);
|
|
2374
|
+
this.mouseStartAction = "";
|
|
2375
|
+
this.mouseStartWidth = -1;
|
|
2376
|
+
this.mouseStartColumnIndex = -1;
|
|
2377
|
+
this.dragFrom = -1;
|
|
2378
|
+
this.dragTo = -1;
|
|
2379
|
+
if (!eventListener) {
|
|
2380
|
+
this.eventListener = new EventAdapter();
|
|
2381
|
+
}
|
|
2382
|
+
if ((_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) {
|
|
2383
|
+
const autoRestoreOptions = this.tableOptions.autoRestoreOptions;
|
|
2384
|
+
const keyFn = autoRestoreOptions.getStorageKeyFn;
|
|
2385
|
+
if (keyFn) {
|
|
2386
|
+
if (autoRestoreOptions.autoRestoreScrollPosition) {
|
|
2387
|
+
this.storeScrollPosStateService = new StoreStateScrollPosService(keyFn);
|
|
2388
|
+
}
|
|
2389
|
+
if (autoRestoreOptions.autoRestoreCollapsedExpandedState) {
|
|
2390
|
+
this.storeStateCollapsedExpandService = new StoreStateCollapsedExpandService(keyFn);
|
|
2391
|
+
}
|
|
2392
|
+
if (autoRestoreOptions.autoRestoreSortingState) {
|
|
2393
|
+
this.storeSortingService = new StoreStateSortingService(keyFn);
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
this.mouseHandler = new MouseHandler(this);
|
|
2398
|
+
this.inputHandler = new InputHandler(this);
|
|
2399
|
+
this.shortcutService = new ShortcutService(this);
|
|
2400
|
+
this.shortcutService.addListener(this.selectionService);
|
|
2401
|
+
}
|
|
2402
|
+
onActionTriggered(actionId) {
|
|
2403
|
+
if (actionId === "NAVIGATE_DOWN") {
|
|
2404
|
+
if (this.changeFocusCell(0, 1)) {
|
|
2405
|
+
return true;
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
if (actionId === "NAVIGATE_UP") {
|
|
2409
|
+
if (this.changeFocusCell(0, -1)) {
|
|
2410
|
+
return true;
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
if (actionId === "NAVIGATE_LEFT") {
|
|
2414
|
+
if (this.changeFocusCell(-1, 0)) {
|
|
2415
|
+
return true;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
if (actionId === "NAVIGATE_RIGHT") {
|
|
2419
|
+
if (this.changeFocusCell(1, 0)) {
|
|
2420
|
+
return true;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (actionId === "START_EDITING") {
|
|
2424
|
+
if (this.getFocusModel) {
|
|
2425
|
+
const fm = this.getFocusModel();
|
|
2426
|
+
if (fm) {
|
|
2427
|
+
const [rowIdx, colIdx] = fm.getFocus();
|
|
2428
|
+
if (this.tableModel.getBodyModel().isEditable(rowIdx, colIdx)) {
|
|
2429
|
+
this.clearSelection();
|
|
2430
|
+
this.initRenderEditor(rowIdx, colIdx);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
return true;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
return false;
|
|
2437
|
+
}
|
|
2438
|
+
updateModelValueAfterEdit(areaIdent, rowIndex, columnIndex, value) {
|
|
2439
|
+
if (areaIdent === "body") {
|
|
2440
|
+
const bodyAreaModel = this.tableModel.getAreaModel(areaIdent);
|
|
2441
|
+
const ok = bodyAreaModel.setValue(rowIndex, columnIndex, value);
|
|
2442
|
+
if (ok) {
|
|
2443
|
+
this.resetEditorRenderer();
|
|
2444
|
+
this.repaint();
|
|
2445
|
+
this.eventListener.onModelChanged(GeModelChangeEvent.createSingle(rowIndex, columnIndex));
|
|
2446
|
+
this.hostElement.focus();
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
getApi() {
|
|
2451
|
+
return this.api;
|
|
2452
|
+
}
|
|
2453
|
+
firstInit() {
|
|
2454
|
+
var _a;
|
|
2455
|
+
this.tableModel.init();
|
|
2456
|
+
if ((_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.externalFilterFunction) {
|
|
2457
|
+
this.externalFilterChanged(false);
|
|
2458
|
+
}
|
|
2459
|
+
this.autoRestoreCollapsedExpandedState();
|
|
2460
|
+
this.autoRestoreSortingState();
|
|
2461
|
+
this.resetSizeOfWrapperDiv();
|
|
2462
|
+
this.adjustContainersAndRows();
|
|
2463
|
+
this.autoRestoreScrollPosition();
|
|
2464
|
+
}
|
|
2465
|
+
createGeMouseEvent(mouseEvent) {
|
|
2466
|
+
const ret = new GeMouseEvent();
|
|
2467
|
+
ret.originalEvent = mouseEvent;
|
|
2468
|
+
if (mouseEvent) {
|
|
2469
|
+
const target = mouseEvent.target;
|
|
2470
|
+
[ret.areaIdent, ret.sideIdent] = this.getAreaAndSideIdentByAttr(target);
|
|
2471
|
+
ret.rowIndex = this.getNumberByAttr(target, "data-row-index");
|
|
2472
|
+
ret.columnIndex = this.getNumberByAttr(target, "data-col-index");
|
|
2473
|
+
ret.action = this.getStringByAttr(target, "data-ge-action");
|
|
2474
|
+
if (ret.areaIdent) {
|
|
2475
|
+
const am = this.tableModel.getAreaModel(ret.areaIdent);
|
|
2476
|
+
ret.rowTop = am.getYPosByRowIndex(ret.rowIndex);
|
|
2477
|
+
}
|
|
2478
|
+
ret.columnLeft = this.tableModel.getXPosByColumnIndex(ret.columnIndex);
|
|
2479
|
+
if (mouseEvent.ctrlKey && mouseEvent.altKey) {
|
|
2480
|
+
const bodyY = mouseEvent.clientY - this.hostElement.offsetTop - this.areaHeaderCenter.parent.clientHeight;
|
|
2481
|
+
const bodyX = mouseEvent.clientX - this.hostElement.offsetLeft - this.areaBodyWestGeo.width;
|
|
2482
|
+
this.debugOnce(bodyX, bodyY);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
return ret;
|
|
2486
|
+
}
|
|
2487
|
+
onMouseDown(mouseEvent) {
|
|
2488
|
+
if (mouseEvent.columnIndex > -1 && mouseEvent.action && ["resize-column", "drag-column"].includes(mouseEvent.action)) {
|
|
2489
|
+
this.mouseStartWidth = this.tableModel.getColumnWidth(mouseEvent.columnIndex);
|
|
2490
|
+
this.mouseStartAction = mouseEvent.action;
|
|
2491
|
+
this.mouseStartColumnIndex = mouseEvent.columnIndex;
|
|
2492
|
+
if (this.mouseStartAction === "drag-column") {
|
|
2493
|
+
this.dragFrom = this.mouseStartColumnIndex;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
mouseDraggingOnFrame(mouseEvent) {
|
|
2498
|
+
this.eventListener.onMouseDragging(mouseEvent);
|
|
2499
|
+
this.mouseEvent = mouseEvent;
|
|
2500
|
+
if (this.mouseStartColumnIndex > -1 && this.mouseStartAction === "resize-column" && this.tableOptions.columnsResizable) {
|
|
2501
|
+
this.resizeColumn(mouseEvent);
|
|
2502
|
+
} else if (this.mouseStartAction === "drag-column" && mouseEvent.columnIndex > -1 && this.tableOptions.columnsDraggable) {
|
|
2503
|
+
this.draggingTargetColumnIndex = mouseEvent.columnIndex;
|
|
2504
|
+
this.dragTo = this.draggingTargetColumnIndex;
|
|
2505
|
+
if (this.dragFrom > -1 && this.dragTo > -1 && this.dragFrom !== this.dragTo) {
|
|
2506
|
+
this.tableModel.changeColumnOrder(this.dragFrom, this.dragTo);
|
|
2507
|
+
this.dragFrom = this.dragTo;
|
|
2508
|
+
this.resetSizeOfWrapperDiv();
|
|
2509
|
+
this.adjustContainersAndRows();
|
|
2510
|
+
}
|
|
2511
|
+
this.repaint();
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
mouseDraggingEndOnFrame(mouseEvent) {
|
|
2515
|
+
this.eventListener.onMouseDraggingEnd(mouseEvent);
|
|
2516
|
+
this.draggingTargetColumnIndex = -1;
|
|
2517
|
+
if (this.mouseStartAction === "resize-column") {
|
|
2518
|
+
this.resizeColumn(mouseEvent);
|
|
2519
|
+
} else if (this.mouseStartAction === "drag-column") {
|
|
2520
|
+
this.repaint();
|
|
2521
|
+
}
|
|
2522
|
+
this.mouseStartWidth = -1;
|
|
2523
|
+
this.mouseStartColumnIndex = -1;
|
|
2524
|
+
this.dragFrom = -1;
|
|
2525
|
+
this.dragTo = -1;
|
|
2526
|
+
this.mouseStartAction = "";
|
|
2527
|
+
}
|
|
2528
|
+
mouseMove(mouseMoveEvent) {
|
|
2529
|
+
this.eventListener.onMouseMoved(mouseMoveEvent);
|
|
2530
|
+
this.adjustHoverRows(mouseMoveEvent);
|
|
2531
|
+
this.adjustHoverColumns(mouseMoveEvent);
|
|
2532
|
+
}
|
|
2533
|
+
contextmenu(mouseMoveEvent) {
|
|
2534
|
+
this.eventListener.onContextmenu(mouseMoveEvent);
|
|
2535
|
+
}
|
|
2536
|
+
toggleExpandCollapseAll(expand = true) {
|
|
2537
|
+
var _a;
|
|
2538
|
+
const bodyAreaModel = this.tableModel.getBodyModel();
|
|
2539
|
+
if (bodyAreaModel instanceof AreaModelTree) {
|
|
2540
|
+
const amt = bodyAreaModel;
|
|
2541
|
+
amt.toggleExpandCollapseAll(expand);
|
|
2542
|
+
this.repaint();
|
|
2543
|
+
(_a = this.storeStateCollapsedExpandService) === null || _a === void 0 ? void 0 : _a.collapsedStateAll(expand);
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
toggleRowCheckbox(rowIdx, _colIdx, areaIdent) {
|
|
2547
|
+
var _a;
|
|
2548
|
+
const areaModel = this.tableModel.getAreaModel(areaIdent);
|
|
2549
|
+
const state = areaModel.isRowChecked(rowIdx);
|
|
2550
|
+
const unsel = state === void 0 || state === "semi" || state === "none";
|
|
2551
|
+
areaModel.setRowChecked(rowIdx, unsel);
|
|
2552
|
+
this.repaint();
|
|
2553
|
+
const selectedRows = (_a = areaModel.rowSelectionModel) === null || _a === void 0 ? void 0 : _a.getCheckedRows();
|
|
2554
|
+
this.eventListener.onCheckboxChanged(selectedRows ? selectedRows : []);
|
|
2555
|
+
}
|
|
2556
|
+
onMouseClicked(evt, previousEvt) {
|
|
2557
|
+
let dirty = this.selectionService.onMouseClicked(evt, previousEvt);
|
|
2558
|
+
if (!dirty && this.getFocusModel) {
|
|
2559
|
+
const fm = this.getFocusModel();
|
|
2560
|
+
if (fm) {
|
|
2561
|
+
dirty = fm.hasChanged();
|
|
2562
|
+
fm.clearChanged();
|
|
2563
|
+
if (dirty) {
|
|
2564
|
+
this.resetEditorRenderer();
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
this.eventListener.onMouseClicked(evt);
|
|
2569
|
+
if (dirty) {
|
|
2570
|
+
this.debounce(this.repaint.bind(this), 10);
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
externalFilterChanged(clearSelection = true) {
|
|
2574
|
+
const predictFn = this.tableOptions.externalFilterFunction;
|
|
2575
|
+
if (predictFn) {
|
|
2576
|
+
if (clearSelection) {
|
|
2577
|
+
this.clearSelectionModel();
|
|
2578
|
+
}
|
|
2579
|
+
this.tableModel.externalFilterChanged(predictFn);
|
|
2580
|
+
this.scrollViewport.scrollTo(0, 0);
|
|
2581
|
+
this.tableModel.recalcHeightAndPadding();
|
|
2582
|
+
this.resetSizeOfWrapperDiv();
|
|
2583
|
+
this.repaint();
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
onHeaderDblClicked(event, _rowIdx, colIdx) {
|
|
2587
|
+
var _a, _b, _c;
|
|
2588
|
+
const colDef = this.tableModel.getColumnDef(colIdx);
|
|
2589
|
+
if ((colDef === null || colDef === void 0 ? void 0 : colDef.sortable) && colDef.sortable()) {
|
|
2590
|
+
event.preventDefault();
|
|
2591
|
+
event.stopPropagation();
|
|
2592
|
+
const states = colDef.sortStatesOrder ? colDef.sortStatesOrder : this.tableOptions.sortOrder;
|
|
2593
|
+
const currentState = (_a = colDef.sortState) !== null && _a !== void 0 ? _a : "";
|
|
2594
|
+
const newState = states[(states.indexOf(currentState) + 1) % states.length];
|
|
2595
|
+
const sortItem = new SortItem(colIdx, newState);
|
|
2596
|
+
const done = this.tableModel.doSort([sortItem]);
|
|
2597
|
+
if (done) {
|
|
2598
|
+
(_b = this.tableModel.getColumnDefs()) === null || _b === void 0 ? void 0 : _b.forEach((cd) => cd.sortState = "");
|
|
2599
|
+
colDef.sortState = newState;
|
|
2600
|
+
}
|
|
2601
|
+
this.repaint();
|
|
2602
|
+
(_c = this.storeSortingService) === null || _c === void 0 ? void 0 : _c.setSortItems([sortItem]);
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
changeFocusCell(dx, dy) {
|
|
2606
|
+
if (!this.isEditing() && this.getFocusModel) {
|
|
2607
|
+
const fm = this.getFocusModel();
|
|
2608
|
+
if (fm) {
|
|
2609
|
+
const [rowIdx, colIdx] = fm.getFocus();
|
|
2610
|
+
fm.setFocus(rowIdx + dy, colIdx + dx);
|
|
2611
|
+
this.repaint();
|
|
2612
|
+
return true;
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
return false;
|
|
2616
|
+
}
|
|
2617
|
+
resizeColumn(mouseEvent) {
|
|
2618
|
+
this.tableModel.setColumnWidth(this.mouseStartColumnIndex, this.mouseStartWidth + mouseEvent.draggingX);
|
|
2619
|
+
this.tableModel.recalcPadding();
|
|
2620
|
+
this.resetSizeOfWrapperDiv();
|
|
2621
|
+
this.adjustContainersAndRows();
|
|
2622
|
+
}
|
|
2623
|
+
clearSelectionModel() {
|
|
2624
|
+
var _a;
|
|
2625
|
+
if (this.getSelectionModel) {
|
|
2626
|
+
(_a = this.getSelectionModel()) === null || _a === void 0 ? void 0 : _a.clear();
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
debugOnce(bodyX, bodyY) {
|
|
2630
|
+
var _a;
|
|
2631
|
+
console.clear();
|
|
2632
|
+
console.info("this.hostElement.offsetTop", this.hostElement.offsetTop);
|
|
2633
|
+
console.info("this.hostElement.scrollHeight", this.hostElement.scrollHeight);
|
|
2634
|
+
console.info("this.scrollViewportTop", this.scrollTop);
|
|
2635
|
+
console.info("this.areaHeaderCenter.parent.clientHeight", this.areaHeaderCenter.parent.clientHeight);
|
|
2636
|
+
console.info("bodyY", bodyY);
|
|
2637
|
+
console.info("bodyX", bodyX);
|
|
2638
|
+
console.info("rows", this.firstVisibleRowIndex);
|
|
2639
|
+
console.info("");
|
|
2640
|
+
console.info("this.tableModel", this.tableModel);
|
|
2641
|
+
console.info("");
|
|
2642
|
+
console.info("this.mouseMoveEvent.clientX", (_a = this.mouseHandler.mouseEvent) === null || _a === void 0 ? void 0 : _a.clientX);
|
|
2643
|
+
console.info("this.hostElement.offsetLeft", this.hostElement.offsetLeft);
|
|
2644
|
+
console.info("this.areaBodyWestGeo.width", this.areaBodyWestGeo.width);
|
|
2645
|
+
}
|
|
2646
|
+
autoRestoreScrollPosition() {
|
|
2647
|
+
var _a;
|
|
2648
|
+
if (((_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) && this.storeScrollPosStateService) {
|
|
2649
|
+
const autoRestoreOptions = this.tableOptions.autoRestoreOptions;
|
|
2650
|
+
if (autoRestoreOptions.autoRestoreScrollPosition) {
|
|
2651
|
+
const scrollOffset = this.storeScrollPosStateService.getScrollOffset();
|
|
2652
|
+
if (scrollOffset) {
|
|
2653
|
+
this.scrollViewport.scrollTo(...scrollOffset);
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
autoRestoreSortingState() {
|
|
2659
|
+
var _a, _b;
|
|
2660
|
+
if (((_b = (_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) === null || _b === void 0 ? void 0 : _b.autoRestoreSortingState) && this.storeSortingService) {
|
|
2661
|
+
const sortItems = this.storeSortingService.getSortItems();
|
|
2662
|
+
if (sortItems === null || sortItems === void 0 ? void 0 : sortItems.length) {
|
|
2663
|
+
const areaModel = this.tableModel.getBodyModel();
|
|
2664
|
+
areaModel.doSort(sortItems);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
autoRestoreCollapsedExpandedState() {
|
|
2669
|
+
var _a, _b;
|
|
2670
|
+
if (((_b = (_a = this.tableOptions) === null || _a === void 0 ? void 0 : _a.autoRestoreOptions) === null || _b === void 0 ? void 0 : _b.getRowId) && this.storeStateCollapsedExpandService) {
|
|
2671
|
+
const autoRestoreOptions = this.tableOptions.autoRestoreOptions;
|
|
2672
|
+
const getRowId = autoRestoreOptions.getRowId;
|
|
2673
|
+
if (autoRestoreOptions.autoRestoreCollapsedExpandedState && getRowId) {
|
|
2674
|
+
const state = this.storeStateCollapsedExpandService.collapsedExpandedStateGet();
|
|
2675
|
+
const areaModel = this.tableModel.getAreaModel("body");
|
|
2676
|
+
if (areaModel instanceof AreaModelTree) {
|
|
2677
|
+
const amtr = areaModel;
|
|
2678
|
+
const rowCount = areaModel.getRowCount();
|
|
2679
|
+
for (let i = 0; i < rowCount; i++) {
|
|
2680
|
+
const row = areaModel.getRowByIndex(i);
|
|
2681
|
+
if (row) {
|
|
2682
|
+
if (state.allExpanded) {
|
|
2683
|
+
row.expanded = true;
|
|
2684
|
+
} else if (state.allCollapsed) {
|
|
2685
|
+
row.expanded = false;
|
|
2686
|
+
} else {
|
|
2687
|
+
const rowId = getRowId(row.data);
|
|
2688
|
+
if (state.mode === "expanded") {
|
|
2689
|
+
row.expanded = this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(rowId);
|
|
2690
|
+
} else if (state.mode === "collapsed") {
|
|
2691
|
+
row.expanded = !this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(rowId);
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
amtr.recalcVisibleTreeRows();
|
|
2697
|
+
}
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
class InputCellRenderer {
|
|
2703
|
+
render(cellDiv, rowIndex, columnIndex, areaIdent, areaModel, _cellValue, domService) {
|
|
2704
|
+
if (areaModel.isEditable(rowIndex, columnIndex)) {
|
|
2705
|
+
domService.addClass(cellDiv, "ge-table-row-input-div");
|
|
2706
|
+
const val = areaModel.getValueAt(rowIndex, columnIndex);
|
|
2707
|
+
cellDiv.innerHTML = `
|
|
2708
|
+
<input
|
|
2709
|
+
type="text"
|
|
2710
|
+
value="${val}"
|
|
2711
|
+
autofocus
|
|
2712
|
+
onfocus="this.setSelectionRange(0, this.value.length)"
|
|
2713
|
+
data-listen="change"
|
|
2714
|
+
data-area="${areaIdent}"
|
|
2715
|
+
data-row-index="${rowIndex}"
|
|
2716
|
+
data-col-index="${columnIndex}"
|
|
2717
|
+
data-input-type="text"
|
|
2718
|
+
style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
|
|
2719
|
+
class="ge-table-cell-editor-input">`;
|
|
2720
|
+
}
|
|
2721
|
+
return void 0;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
class SelectionModel {
|
|
2725
|
+
constructor(selectionType = "none", selectionMode = "single") {
|
|
2726
|
+
this.selectionType = selectionType;
|
|
2727
|
+
this.selectionMode = selectionMode;
|
|
2728
|
+
this.ranges = [];
|
|
2729
|
+
this.negativeRanges = [];
|
|
2730
|
+
this.allSelected = false;
|
|
2731
|
+
}
|
|
2732
|
+
getSelectionCount(rowIndex, columnIndex) {
|
|
2733
|
+
let count = 0;
|
|
2734
|
+
for (const range of this.ranges) {
|
|
2735
|
+
if (range.isInRange(rowIndex, columnIndex)) {
|
|
2736
|
+
count++;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
if (this.allSelected) {
|
|
2740
|
+
count++;
|
|
2741
|
+
}
|
|
2742
|
+
if (this.isInNegativeRange(rowIndex, columnIndex)) {
|
|
2743
|
+
count = 0;
|
|
2744
|
+
}
|
|
2745
|
+
return count;
|
|
2746
|
+
}
|
|
2747
|
+
isInNegativeRange(rowIndex, columnIndex) {
|
|
2748
|
+
for (const range of this.negativeRanges) {
|
|
2749
|
+
if (range.isInRange(rowIndex, columnIndex)) {
|
|
2750
|
+
return true;
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
return false;
|
|
2754
|
+
}
|
|
2755
|
+
getRanges() {
|
|
2756
|
+
return this.ranges;
|
|
2757
|
+
}
|
|
2758
|
+
clear() {
|
|
2759
|
+
this.ranges = [];
|
|
2760
|
+
this.negativeRanges = [];
|
|
2761
|
+
this.allSelected = false;
|
|
2762
|
+
}
|
|
2763
|
+
hasSelection() {
|
|
2764
|
+
return !!this.ranges.length;
|
|
2765
|
+
}
|
|
2766
|
+
selectAll() {
|
|
2767
|
+
this.allSelected = true;
|
|
2768
|
+
}
|
|
2769
|
+
addSelection(range) {
|
|
2770
|
+
this.addRange(range);
|
|
2771
|
+
}
|
|
2772
|
+
removeSelection(range) {
|
|
2773
|
+
if (this.selectionType === "none") {
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
let r = range;
|
|
2777
|
+
if (this.selectionType === "row") {
|
|
2778
|
+
r = CellRange.singleRow(range.r1);
|
|
2779
|
+
} else if (this.selectionType === "column") {
|
|
2780
|
+
r = CellRange.singleColumn(range.c1);
|
|
2781
|
+
}
|
|
2782
|
+
this.negativeRanges.push(r);
|
|
2783
|
+
}
|
|
2784
|
+
togglePoint(row, col) {
|
|
2785
|
+
if (this.getSelectionCount(row, col) > 0) {
|
|
2786
|
+
this.removeSelection(CellRange.singleCell(row, col));
|
|
2787
|
+
} else {
|
|
2788
|
+
this.addSelection(CellRange.singleCell(row, col));
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
addRange(range) {
|
|
2792
|
+
if (this.selectionType === "none") {
|
|
2793
|
+
return;
|
|
2794
|
+
}
|
|
2795
|
+
this.allSelected = false;
|
|
2796
|
+
if (this.selectionMode === "single") {
|
|
2797
|
+
this.ranges = [];
|
|
2798
|
+
}
|
|
2799
|
+
if (this.selectionType === "row") {
|
|
2800
|
+
range.c1 = 0;
|
|
2801
|
+
range.c2 = Number.MAX_SAFE_INTEGER;
|
|
2802
|
+
} else if (this.selectionType === "column") {
|
|
2803
|
+
range.r1 = 0;
|
|
2804
|
+
range.r2 = Number.MAX_SAFE_INTEGER;
|
|
2805
|
+
} else if (this.selectionType === "cell") {
|
|
2806
|
+
range.r2 = range.r1;
|
|
2807
|
+
range.c2 = range.c1;
|
|
2808
|
+
} else if (this.selectionType === "range")
|
|
2809
|
+
;
|
|
2810
|
+
this.ranges.push(range);
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
class FocusModel {
|
|
2814
|
+
constructor(selectionType = "none") {
|
|
2815
|
+
this.selectionType = selectionType;
|
|
2816
|
+
this.rowIndex = -1;
|
|
2817
|
+
this.columnIndex = -1;
|
|
2818
|
+
this.changed = false;
|
|
2819
|
+
}
|
|
2820
|
+
clearChanged() {
|
|
2821
|
+
this.changed = false;
|
|
2822
|
+
}
|
|
2823
|
+
hasChanged() {
|
|
2824
|
+
return this.changed;
|
|
2825
|
+
}
|
|
2826
|
+
clear() {
|
|
2827
|
+
this.rowIndex = -1;
|
|
2828
|
+
this.columnIndex = -1;
|
|
2829
|
+
}
|
|
2830
|
+
setFocus(rowIndex, columnIndex) {
|
|
2831
|
+
if (this.rowIndex !== rowIndex || this.columnIndex !== columnIndex) {
|
|
2832
|
+
this.rowIndex = rowIndex;
|
|
2833
|
+
this.columnIndex = columnIndex;
|
|
2834
|
+
this.changed = true;
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
hasFocus(rowIndex, columnIndex) {
|
|
2838
|
+
return this.rowIndex === rowIndex && this.columnIndex === columnIndex;
|
|
2839
|
+
}
|
|
2840
|
+
getFocus() {
|
|
2841
|
+
return [this.rowIndex, this.columnIndex];
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
const selectionModel = new SelectionModel();
|
|
2845
|
+
const focusModel = new FocusModel("cell");
|
|
2846
|
+
class TableOptions {
|
|
2847
|
+
constructor() {
|
|
2848
|
+
this.overflowX = "auto";
|
|
2849
|
+
this.overflowY = "auto";
|
|
2850
|
+
this.horizontalBorderVisible = true;
|
|
2851
|
+
this.verticalBorderVisible = true;
|
|
2852
|
+
this.footerSeparatorBorderVisible = true;
|
|
2853
|
+
this.headerSeparatorBorderVisible = true;
|
|
2854
|
+
this.fixedEastSeparatorBorderVisible = true;
|
|
2855
|
+
this.fixedWestSeparatorBorderVisible = true;
|
|
2856
|
+
this.tableTopBorderVisible = true;
|
|
2857
|
+
this.tableBottomBorderVisible = true;
|
|
2858
|
+
this.hoverRowVisible = true;
|
|
2859
|
+
this.hoverColumnVisible = true;
|
|
2860
|
+
this.columnsResizable = true;
|
|
2861
|
+
this.columnsDraggable = true;
|
|
2862
|
+
this.columnResizeHandleWidthInPx = 4;
|
|
2863
|
+
this.defaultRowHeights = {
|
|
2864
|
+
header: 34,
|
|
2865
|
+
body: 34,
|
|
2866
|
+
footer: 34
|
|
2867
|
+
};
|
|
2868
|
+
this.footerVerticalSeparator = false;
|
|
2869
|
+
this.headerToggleExpandCollapseIcons = false;
|
|
2870
|
+
this.headerVerticalSeparator = false;
|
|
2871
|
+
this.treeOptions = new TreeOptions();
|
|
2872
|
+
this.showCheckboxWihoutExtraColumn = false;
|
|
2873
|
+
this.externalFilterFunction = void 0;
|
|
2874
|
+
this.sortedOptions = new SortedOptions();
|
|
2875
|
+
this.sortOrder = ["asc", "desc"];
|
|
2876
|
+
this.getEditRenderer = (_rowIndex, _columnIndex) => new InputCellRenderer();
|
|
2877
|
+
this.getSelectionModel = () => selectionModel;
|
|
2878
|
+
this.getFocusModel = () => focusModel;
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
class SimpleDomService {
|
|
2882
|
+
setStyle(el, style, value) {
|
|
2883
|
+
el.style[style] = value;
|
|
2884
|
+
return el;
|
|
2885
|
+
}
|
|
2886
|
+
appendText(parent, text) {
|
|
2887
|
+
const div = this.createText(text);
|
|
2888
|
+
this.appendChild(parent, div);
|
|
2889
|
+
return div;
|
|
2890
|
+
}
|
|
2891
|
+
addClass(div, clazz) {
|
|
2892
|
+
if (clazz.includes(" ")) {
|
|
2893
|
+
clazz.split(" ").forEach((c) => div.classList.add(c));
|
|
2894
|
+
} else {
|
|
2895
|
+
div.classList.add(clazz);
|
|
2896
|
+
}
|
|
2897
|
+
return div;
|
|
2898
|
+
}
|
|
2899
|
+
appendChild(parent, child) {
|
|
2900
|
+
parent.appendChild(child);
|
|
2901
|
+
}
|
|
2902
|
+
createElement(name) {
|
|
2903
|
+
return document.createElement(name);
|
|
2904
|
+
}
|
|
2905
|
+
createText(value) {
|
|
2906
|
+
return document.createTextNode(value);
|
|
2907
|
+
}
|
|
2908
|
+
setAttribute(ele, key, value) {
|
|
2909
|
+
ele.setAttribute(key, value);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
var GuiexpertTable_vue_vue_type_style_index_0_lang = "";
|
|
2913
|
+
var _export_sfc = (sfc, props) => {
|
|
2914
|
+
const target = sfc.__vccOpts || sfc;
|
|
2915
|
+
for (const [key, val] of props) {
|
|
2916
|
+
target[key] = val;
|
|
2917
|
+
}
|
|
2918
|
+
return target;
|
|
2919
|
+
};
|
|
2920
|
+
const _sfc_main = defineComponent({
|
|
2921
|
+
inheritAttrs: false,
|
|
2922
|
+
props: {
|
|
2923
|
+
tableModel: {
|
|
2924
|
+
required: true
|
|
2925
|
+
},
|
|
2926
|
+
tableOptions: {
|
|
2927
|
+
required: false,
|
|
2928
|
+
default: new TableOptions()
|
|
2929
|
+
},
|
|
2930
|
+
debounceMouseClickDelay: {
|
|
2931
|
+
required: false,
|
|
2932
|
+
default: 150
|
|
2933
|
+
}
|
|
2934
|
+
},
|
|
2935
|
+
emits: [
|
|
2936
|
+
"tableReady",
|
|
2937
|
+
"mouseClicked",
|
|
2938
|
+
"mouseDragging",
|
|
2939
|
+
"checkboxChanged",
|
|
2940
|
+
"contextmenu",
|
|
2941
|
+
"modelChanged",
|
|
2942
|
+
"mouseDraggingEnd",
|
|
2943
|
+
"mouseMoved"
|
|
2944
|
+
],
|
|
2945
|
+
setup(props, { emit }) {
|
|
2946
|
+
const root = ref(null);
|
|
2947
|
+
const initTable = (ele) => {
|
|
2948
|
+
const listener = {
|
|
2949
|
+
onCheckboxChanged: (evt) => {
|
|
2950
|
+
emit("checkboxChanged", evt);
|
|
2951
|
+
},
|
|
2952
|
+
onContextmenu: (evt) => {
|
|
2953
|
+
emit("contextmenu", evt);
|
|
2954
|
+
},
|
|
2955
|
+
onModelChanged: (evt) => {
|
|
2956
|
+
emit("modelChanged", evt);
|
|
2957
|
+
},
|
|
2958
|
+
onMouseClicked: (evt) => {
|
|
2959
|
+
emit("mouseClicked", evt);
|
|
2960
|
+
},
|
|
2961
|
+
onMouseDragging: (evt) => {
|
|
2962
|
+
emit("mouseDragging", evt);
|
|
2963
|
+
},
|
|
2964
|
+
onMouseDraggingEnd: (evt) => {
|
|
2965
|
+
emit("mouseDraggingEnd", evt);
|
|
2966
|
+
},
|
|
2967
|
+
onMouseMoved: (evt) => {
|
|
2968
|
+
emit("mouseMoved", evt);
|
|
2969
|
+
}
|
|
2970
|
+
};
|
|
2971
|
+
const tableScope = new TableScope(ele, props.tableModel, new SimpleDomService(), props.tableOptions, listener);
|
|
2972
|
+
tableScope.firstInit();
|
|
2973
|
+
emit("tableReady", tableScope.getApi());
|
|
2974
|
+
};
|
|
2975
|
+
onMounted(() => {
|
|
2976
|
+
if (root.value) {
|
|
2977
|
+
initTable(root.value);
|
|
2978
|
+
}
|
|
2979
|
+
});
|
|
2980
|
+
return {
|
|
2981
|
+
root
|
|
2982
|
+
};
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
const _hoisted_1 = {
|
|
2986
|
+
ref: "root",
|
|
2987
|
+
class: "container-div",
|
|
2988
|
+
style: { "width": "100%", "height": "100%", "background-color": "transparent", "padding": "0", "margin": "0" }
|
|
2989
|
+
};
|
|
2990
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2991
|
+
return openBlock(), createElementBlock("div", _hoisted_1, null, 512);
|
|
2992
|
+
}
|
|
2993
|
+
var GuiexpertTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
2994
|
+
var GuiexpertTablePlugin = {
|
|
2995
|
+
install: (app, options = { img: "" }) => {
|
|
2996
|
+
app.component("GuiexpertTable", GuiexpertTable);
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
export { GuiexpertTable, GuiexpertTablePlugin as default };
|