@guiexpert/solid-table 1.1.72 → 1.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +6 -6
- package/index.js +648 -144
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
equals:
|
|
1
|
+
const ke = (l, e) => l === e, oe = Symbol("solid-proxy"), Ie = typeof Proxy == "function", fe = {
|
|
2
|
+
equals: ke
|
|
3
3
|
};
|
|
4
|
-
let we =
|
|
5
|
-
const
|
|
4
|
+
let we = Ce;
|
|
5
|
+
const B = 1, z = 2, xe = {
|
|
6
6
|
owned: null,
|
|
7
7
|
cleanups: null,
|
|
8
8
|
context: null,
|
|
9
9
|
owner: null
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
let te = null, Oe = null, x = null,
|
|
11
|
+
var M = null;
|
|
12
|
+
let te = null, Oe = null, x = null, R = null, O = null, Z = 0;
|
|
13
13
|
function Le(l, e) {
|
|
14
|
-
const t = x, s =
|
|
14
|
+
const t = x, s = M, o = l.length === 0, i = e === void 0 ? s : e, r = o ? xe : {
|
|
15
15
|
owned: null,
|
|
16
16
|
cleanups: null,
|
|
17
17
|
context: i ? i.context : null,
|
|
18
18
|
owner: i
|
|
19
19
|
}, a = o ? l : () => l(() => Q(() => $(r)));
|
|
20
|
-
|
|
20
|
+
M = r, x = null;
|
|
21
21
|
try {
|
|
22
22
|
return _(a, !0);
|
|
23
23
|
} finally {
|
|
24
|
-
x = t,
|
|
24
|
+
x = t, M = s;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function ie(l, e, t) {
|
|
28
|
-
const s = ae(l, e, !1,
|
|
28
|
+
const s = ae(l, e, !1, B);
|
|
29
29
|
V(s);
|
|
30
30
|
}
|
|
31
31
|
function Be(l, e, t) {
|
|
32
32
|
we = Ne;
|
|
33
|
-
const s = ae(l, e, !1,
|
|
33
|
+
const s = ae(l, e, !1, B);
|
|
34
34
|
s.user = !0, O ? O.push(s) : V(s);
|
|
35
35
|
}
|
|
36
36
|
function Pe(l, e, t) {
|
|
@@ -53,10 +53,10 @@ function We(l) {
|
|
|
53
53
|
}
|
|
54
54
|
function He() {
|
|
55
55
|
if (this.sources && this.state)
|
|
56
|
-
if (this.state ===
|
|
56
|
+
if (this.state === B) V(this);
|
|
57
57
|
else {
|
|
58
|
-
const l =
|
|
59
|
-
|
|
58
|
+
const l = R;
|
|
59
|
+
R = null, _(() => j(this), !1), R = l;
|
|
60
60
|
}
|
|
61
61
|
if (x) {
|
|
62
62
|
const l = this.observers ? this.observers.length : 0;
|
|
@@ -69,10 +69,10 @@ function $e(l, e, t) {
|
|
|
69
69
|
return (!l.comparator || !l.comparator(s, e)) && (l.value = e, l.observers && l.observers.length && _(() => {
|
|
70
70
|
for (let o = 0; o < l.observers.length; o += 1) {
|
|
71
71
|
const i = l.observers[o], r = te && te.running;
|
|
72
|
-
r && te.disposed.has(i), (r ? !i.tState : !i.state) && (i.pure ?
|
|
72
|
+
r && te.disposed.has(i), (r ? !i.tState : !i.state) && (i.pure ? R.push(i) : O.push(i), i.observers && ve(i)), r || (i.state = B);
|
|
73
73
|
}
|
|
74
|
-
if (
|
|
75
|
-
throw
|
|
74
|
+
if (R.length > 1e6)
|
|
75
|
+
throw R = [], new Error();
|
|
76
76
|
}, !1)), e;
|
|
77
77
|
}
|
|
78
78
|
function V(l) {
|
|
@@ -87,18 +87,18 @@ function V(l) {
|
|
|
87
87
|
}
|
|
88
88
|
function Ve(l, e, t) {
|
|
89
89
|
let s;
|
|
90
|
-
const o =
|
|
91
|
-
x =
|
|
90
|
+
const o = M, i = x;
|
|
91
|
+
x = M = l;
|
|
92
92
|
try {
|
|
93
93
|
s = l.fn(e);
|
|
94
94
|
} catch (r) {
|
|
95
|
-
return l.pure && (l.state =
|
|
95
|
+
return l.pure && (l.state = B, l.owned && l.owned.forEach($), l.owned = null), l.updatedAt = t + 1, Ae(r);
|
|
96
96
|
} finally {
|
|
97
|
-
x = i,
|
|
97
|
+
x = i, M = o;
|
|
98
98
|
}
|
|
99
99
|
(!l.updatedAt || l.updatedAt <= t) && (l.updatedAt != null && "observers" in l ? $e(l, s) : l.value = s, l.updatedAt = t);
|
|
100
100
|
}
|
|
101
|
-
function ae(l, e, t, s =
|
|
101
|
+
function ae(l, e, t, s = B, o) {
|
|
102
102
|
const i = {
|
|
103
103
|
fn: l,
|
|
104
104
|
state: s,
|
|
@@ -108,11 +108,11 @@ function ae(l, e, t, s = L, o) {
|
|
|
108
108
|
sourceSlots: null,
|
|
109
109
|
cleanups: null,
|
|
110
110
|
value: e,
|
|
111
|
-
owner:
|
|
112
|
-
context:
|
|
111
|
+
owner: M,
|
|
112
|
+
context: M ? M.context : null,
|
|
113
113
|
pure: t
|
|
114
114
|
};
|
|
115
|
-
return
|
|
115
|
+
return M === null || M !== xe && (M.owned ? M.owned.push(i) : M.owned = [i]), i;
|
|
116
116
|
}
|
|
117
117
|
function U(l) {
|
|
118
118
|
if (l.state === 0) return;
|
|
@@ -122,30 +122,30 @@ function U(l) {
|
|
|
122
122
|
for (; (l = l.owner) && (!l.updatedAt || l.updatedAt < Z); )
|
|
123
123
|
l.state && e.push(l);
|
|
124
124
|
for (let t = e.length - 1; t >= 0; t--)
|
|
125
|
-
if (l = e[t], l.state ===
|
|
125
|
+
if (l = e[t], l.state === B)
|
|
126
126
|
V(l);
|
|
127
127
|
else if (l.state === z) {
|
|
128
|
-
const s =
|
|
129
|
-
|
|
128
|
+
const s = R;
|
|
129
|
+
R = null, _(() => j(l, e[0]), !1), R = s;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
function _(l, e) {
|
|
133
|
-
if (
|
|
133
|
+
if (R) return l();
|
|
134
134
|
let t = !1;
|
|
135
|
-
e || (
|
|
135
|
+
e || (R = []), O ? t = !0 : O = [], Z++;
|
|
136
136
|
try {
|
|
137
137
|
const s = l();
|
|
138
138
|
return _e(t), s;
|
|
139
139
|
} catch (s) {
|
|
140
|
-
t || (O = null),
|
|
140
|
+
t || (O = null), R = null, Ae(s);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
function _e(l) {
|
|
144
|
-
if (
|
|
144
|
+
if (R && (Ce(R), R = null), l) return;
|
|
145
145
|
const e = O;
|
|
146
146
|
O = null, e.length && _(() => we(e), !1);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Ce(l) {
|
|
149
149
|
for (let e = 0; e < l.length; e++) U(l[e]);
|
|
150
150
|
}
|
|
151
151
|
function Ne(l) {
|
|
@@ -162,14 +162,14 @@ function j(l, e) {
|
|
|
162
162
|
const s = l.sources[t];
|
|
163
163
|
if (s.sources) {
|
|
164
164
|
const o = s.state;
|
|
165
|
-
o ===
|
|
165
|
+
o === B ? s !== e && (!s.updatedAt || s.updatedAt < Z) && U(s) : o === z && j(s, e);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function ve(l) {
|
|
170
170
|
for (let e = 0; e < l.observers.length; e += 1) {
|
|
171
171
|
const t = l.observers[e];
|
|
172
|
-
t.state || (t.state = z, t.pure ?
|
|
172
|
+
t.state || (t.state = z, t.pure ? R.push(t) : O.push(t), t.observers && ve(t));
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
function $(l) {
|
|
@@ -201,7 +201,7 @@ function Ge(l) {
|
|
|
201
201
|
cause: l
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function Ae(l, e = M) {
|
|
205
205
|
throw Ge(l);
|
|
206
206
|
}
|
|
207
207
|
function G() {
|
|
@@ -240,7 +240,7 @@ function Ue() {
|
|
|
240
240
|
if (t !== void 0) return t;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Ee(...l) {
|
|
244
244
|
let e = !1;
|
|
245
245
|
for (let r = 0; r < l.length; r++) {
|
|
246
246
|
const a = l[r];
|
|
@@ -368,11 +368,11 @@ function X(l, e, t, s, o) {
|
|
|
368
368
|
return t;
|
|
369
369
|
if (r) {
|
|
370
370
|
let a = t[0];
|
|
371
|
-
a && a.nodeType === 3 ? a.data !== e && (a.data = e) : a = document.createTextNode(e), t =
|
|
371
|
+
a && a.nodeType === 3 ? a.data !== e && (a.data = e) : a = document.createTextNode(e), t = W(l, t, s, a);
|
|
372
372
|
} else
|
|
373
373
|
t !== "" && typeof t == "string" ? t = l.firstChild.data = e : t = l.textContent = e;
|
|
374
374
|
} else if (e == null || i === "boolean")
|
|
375
|
-
t =
|
|
375
|
+
t = W(l, t, s);
|
|
376
376
|
else {
|
|
377
377
|
if (i === "function")
|
|
378
378
|
return ie(() => {
|
|
@@ -385,13 +385,13 @@ function X(l, e, t, s, o) {
|
|
|
385
385
|
if (re(a, e, t, o))
|
|
386
386
|
return ie(() => t = X(l, a, t, s, !0)), () => t;
|
|
387
387
|
if (a.length === 0) {
|
|
388
|
-
if (t =
|
|
389
|
-
} else n ? t.length === 0 ? ue(l, a, s) : je(l, t, a) : (t &&
|
|
388
|
+
if (t = W(l, t, s), r) return t;
|
|
389
|
+
} else n ? t.length === 0 ? ue(l, a, s) : je(l, t, a) : (t && W(l), ue(l, a));
|
|
390
390
|
t = a;
|
|
391
391
|
} else if (e.nodeType) {
|
|
392
392
|
if (Array.isArray(t)) {
|
|
393
|
-
if (r) return t =
|
|
394
|
-
|
|
393
|
+
if (r) return t = W(l, t, s, e);
|
|
394
|
+
W(l, t, null, e);
|
|
395
395
|
} else t == null || t === "" || !l.firstChild ? l.appendChild(e) : l.replaceChild(e, l.firstChild);
|
|
396
396
|
t = e;
|
|
397
397
|
}
|
|
@@ -426,7 +426,7 @@ function re(l, e, t, s) {
|
|
|
426
426
|
function ue(l, e, t = null) {
|
|
427
427
|
for (let s = 0, o = e.length; s < o; s++) l.insertBefore(e[s], t);
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function W(l, e, t, s) {
|
|
430
430
|
if (t === void 0) return l.textContent = "";
|
|
431
431
|
const o = s || document.createTextNode("");
|
|
432
432
|
if (e.length) {
|
|
@@ -446,7 +446,7 @@ class Tt {
|
|
|
446
446
|
this.code = e;
|
|
447
447
|
}
|
|
448
448
|
render(e, t, s, o, i, r, a) {
|
|
449
|
-
const n =
|
|
449
|
+
const n = Ee({
|
|
450
450
|
rowIndex: t,
|
|
451
451
|
columnIndex: s,
|
|
452
452
|
areaIdent: o,
|
|
@@ -470,14 +470,14 @@ function qe(l, e = 500) {
|
|
|
470
470
|
}, e);
|
|
471
471
|
};
|
|
472
472
|
}
|
|
473
|
-
class
|
|
473
|
+
class P {
|
|
474
474
|
// The constructor is private to prevent direct construction calls
|
|
475
475
|
// with the `new` operator
|
|
476
476
|
constructor() {
|
|
477
477
|
this.alreadySet = !1;
|
|
478
478
|
}
|
|
479
479
|
static getInstance() {
|
|
480
|
-
return
|
|
480
|
+
return P.instance || (P.instance = new P()), P.instance;
|
|
481
481
|
}
|
|
482
482
|
/**
|
|
483
483
|
* Method to set the license key for the application.
|
|
@@ -526,7 +526,7 @@ class I {
|
|
|
526
526
|
this.content = e, this.style = t, this.classes = s;
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
-
class
|
|
529
|
+
class Re {
|
|
530
530
|
constructor(e = new I(
|
|
531
531
|
">",
|
|
532
532
|
"transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",
|
|
@@ -547,7 +547,7 @@ class Me {
|
|
|
547
547
|
this.arrowExpanded = e, this.arrowCollapsed = t, this.arrowPlaceholder = s, this.arrowExpandCollapseAll = o;
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
|
-
class
|
|
550
|
+
class Me {
|
|
551
551
|
constructor(e = new I("↑", "", ["ge-header-sorted-asc"]), t = new I("↓", "", ["ge-header-sorted-desc"]), s = new I("↑", "color:transparent;", [])) {
|
|
552
552
|
this.iconAsc = e, this.iconDesc = t, this.iconPlaceholder = s;
|
|
553
553
|
}
|
|
@@ -672,7 +672,7 @@ class Ze {
|
|
|
672
672
|
}
|
|
673
673
|
return this.domService.appendChild(e, a), a;
|
|
674
674
|
}
|
|
675
|
-
addSortedIcon(e, t = "", s = new
|
|
675
|
+
addSortedIcon(e, t = "", s = new Me(), o = -1) {
|
|
676
676
|
const i = this.domService.createElement("div");
|
|
677
677
|
this.domService.addClass(i, "ge-table-sorted-icon-div"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "top", "0"), this.domService.setStyle(i, "right", "0"), this.domService.setStyle(i, "width", "20px"), this.domService.setStyle(i, "background", "transparent"), this.domService.setStyle(i, "cursor", "pointer"), this.domService.setAttribute(i, "data-col-index", `${o}`), this.domService.setAttribute(i, "data-area", "header");
|
|
678
678
|
let r;
|
|
@@ -683,7 +683,7 @@ class Ze {
|
|
|
683
683
|
this.domService.addClass(i, d);
|
|
684
684
|
return this.domService.appendChild(e, i), i;
|
|
685
685
|
}
|
|
686
|
-
addArrowDiv(e, t = "none", s = new
|
|
686
|
+
addArrowDiv(e, t = "none", s = new Re(), o = -1, i = -1, r = "body") {
|
|
687
687
|
const a = this.domService.createElement("div");
|
|
688
688
|
this.domService.addClass(a, "ge-table-tree-arrow-div"), this.domService.setStyle(a, "display", "inline-block"), this.domService.setStyle(a, "position", ""), this.domService.setStyle(a, "width", "20px"), this.domService.setStyle(a, "background", "transparent"), this.domService.setStyle(a, "cursor", "pointer"), this.domService.setAttribute(a, "data-row-index", `${o}`), this.domService.setAttribute(a, "data-col-index", `${i}`), this.domService.setAttribute(a, "data-area", `${r}`);
|
|
689
689
|
let n;
|
|
@@ -940,6 +940,8 @@ class tt {
|
|
|
940
940
|
doSort(e) {
|
|
941
941
|
return !1;
|
|
942
942
|
}
|
|
943
|
+
sort(e) {
|
|
944
|
+
}
|
|
943
945
|
isEditable(e, t) {
|
|
944
946
|
var o, i;
|
|
945
947
|
const s = (o = this.columnDefs) == null ? void 0 : o[t];
|
|
@@ -995,9 +997,15 @@ class st {
|
|
|
995
997
|
return s * ("" + e).localeCompare("" + t);
|
|
996
998
|
}
|
|
997
999
|
}
|
|
998
|
-
class
|
|
1000
|
+
class L extends tt {
|
|
999
1001
|
constructor(e, t, s, o = [], i = "ge-selected-row", r = "ge-focused-row") {
|
|
1000
|
-
super(e, o, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = o, this.selectedRowClass = i, this.focusedRowClass = r, this.
|
|
1002
|
+
super(e, o, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = o, this.selectedRowClass = i, this.focusedRowClass = r, this.sorterService = new st(), this._focusedRowIndex = 0, this.filteredRows = [...t], this.properties = o.map((a) => a.property);
|
|
1003
|
+
}
|
|
1004
|
+
get focusedRowIndex() {
|
|
1005
|
+
return this._focusedRowIndex;
|
|
1006
|
+
}
|
|
1007
|
+
set focusedRowIndex(e) {
|
|
1008
|
+
this._focusedRowIndex = e;
|
|
1001
1009
|
}
|
|
1002
1010
|
setRows(e) {
|
|
1003
1011
|
this.rows = e, this.filteredRows = [...e];
|
|
@@ -1029,6 +1037,28 @@ class W extends tt {
|
|
|
1029
1037
|
getAllRows() {
|
|
1030
1038
|
return this.rows;
|
|
1031
1039
|
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
|
|
1042
|
+
*
|
|
1043
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
1044
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
1045
|
+
* and returns true if the row matches the criteria
|
|
1046
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found
|
|
1047
|
+
*/
|
|
1048
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
1049
|
+
return this.getFilteredRows().find((s) => t(e, s));
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Searches through all rows to find a row that matches the given criteria based on the predicate function.
|
|
1053
|
+
*
|
|
1054
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
1055
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
1056
|
+
* and returns true if the row matches the criteria
|
|
1057
|
+
* @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
|
|
1058
|
+
*/
|
|
1059
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
1060
|
+
return this.getAllRows().find((s) => t(e, s));
|
|
1061
|
+
}
|
|
1032
1062
|
getRowHeight(e) {
|
|
1033
1063
|
return this.defaultRowHeight;
|
|
1034
1064
|
}
|
|
@@ -1045,15 +1075,19 @@ class W extends tt {
|
|
|
1045
1075
|
}
|
|
1046
1076
|
return !0;
|
|
1047
1077
|
}
|
|
1078
|
+
sort(e) {
|
|
1079
|
+
this.filteredRows = this.filteredRows.sort(e);
|
|
1080
|
+
}
|
|
1048
1081
|
getValueByT(e, t) {
|
|
1049
|
-
|
|
1082
|
+
if (e && t)
|
|
1083
|
+
return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
|
|
1050
1084
|
}
|
|
1051
1085
|
changeColumnOrder(e, t) {
|
|
1052
1086
|
this.arrayMove(this.properties, e, t), super.changeColumnOrder(e, t);
|
|
1053
1087
|
}
|
|
1054
1088
|
getCustomClassesAt(e, t) {
|
|
1055
1089
|
const s = super.getCustomClassesAt(e, t);
|
|
1056
|
-
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this.
|
|
1090
|
+
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this._focusedRowIndex === e && s.push(this.focusedRowClass), s;
|
|
1057
1091
|
}
|
|
1058
1092
|
genericFlatTableSortComparator(e, t) {
|
|
1059
1093
|
const s = this.columnDefs.find((o) => o.property === e);
|
|
@@ -1281,58 +1315,314 @@ class ot {
|
|
|
1281
1315
|
getSelectionModel() {
|
|
1282
1316
|
return this.tableScope.selectionModel();
|
|
1283
1317
|
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Automatically resizes all columns to fit their content.
|
|
1320
|
+
*
|
|
1321
|
+
* @param {boolean} recalcWrappers - Determines whether to recalculate wrapper dimensions after resizing columns.
|
|
1322
|
+
* Default value is true.
|
|
1323
|
+
*
|
|
1324
|
+
* @return {void} - This method doesn't return anything.
|
|
1325
|
+
*/
|
|
1284
1326
|
autoResizeColumns(e = !0) {
|
|
1285
1327
|
this.tableScope.autoResizeColumns(e);
|
|
1286
1328
|
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Recalculates the dimensions of all wrapper elements in the table.
|
|
1331
|
+
*
|
|
1332
|
+
* This method is typically called after changes to the table structure or content
|
|
1333
|
+
* that might affect the layout, such as resizing columns or changing row heights.
|
|
1334
|
+
* It ensures that all wrapper elements are properly sized to match their content.
|
|
1335
|
+
*
|
|
1336
|
+
* @return {void} - This method doesn't return anything.
|
|
1337
|
+
*/
|
|
1287
1338
|
recalcWrappers() {
|
|
1288
1339
|
this.tableScope.recalcWrappers();
|
|
1289
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Sets the width of a specific column in the table.
|
|
1343
|
+
*
|
|
1344
|
+
* @param {number} columnIndex - The index of the column to resize.
|
|
1345
|
+
* @param {number} width - The new width to set for the column, in pixels.
|
|
1346
|
+
*
|
|
1347
|
+
* @return {void} - This method doesn't return anything.
|
|
1348
|
+
*/
|
|
1290
1349
|
setColumnWidth(e, t) {
|
|
1291
1350
|
this.tableScope.setColumnWidth(e, t);
|
|
1292
1351
|
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Retrieves the table model that contains all data and structure information for the table.
|
|
1354
|
+
*
|
|
1355
|
+
* @return {TableModelIf} The table model interface that provides access to the table's data structure,
|
|
1356
|
+
* including header, body, and footer area models.
|
|
1357
|
+
*/
|
|
1293
1358
|
getTableModel() {
|
|
1294
1359
|
return this.tableScope.tableModel;
|
|
1295
1360
|
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Retrieves the area model for the body section of the table.
|
|
1363
|
+
*
|
|
1364
|
+
* @return {AreaModelIf} The area model interface that provides access to the table's body data,
|
|
1365
|
+
* including rows, cells, and their values.
|
|
1366
|
+
*/
|
|
1296
1367
|
getBodyModel() {
|
|
1297
1368
|
return this.tableScope.tableModel.getBodyModel();
|
|
1298
1369
|
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Sets the rows data for the table body, replacing any existing rows.
|
|
1372
|
+
*
|
|
1373
|
+
* @template T - The type of elements in the rows array
|
|
1374
|
+
* @param {T[]} rows - An array of data objects to set as the table's rows
|
|
1375
|
+
*
|
|
1376
|
+
* @description
|
|
1377
|
+
* This method replaces all existing rows in the table body with the provided array of data objects.
|
|
1378
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1379
|
+
*
|
|
1380
|
+
* @return {void} - This method doesn't return anything.
|
|
1381
|
+
*
|
|
1382
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1383
|
+
*/
|
|
1299
1384
|
setRows(e) {
|
|
1300
1385
|
const t = this.getBodyModel();
|
|
1301
|
-
t instanceof
|
|
1386
|
+
t instanceof L ? t.setRows(e) : console.warn("setRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
1302
1387
|
}
|
|
1388
|
+
/**
|
|
1389
|
+
* Adds new rows to the end of the table body.
|
|
1390
|
+
*
|
|
1391
|
+
* @template T - The type of elements in the rows array
|
|
1392
|
+
* @param {T[]} rows - An array of data objects to append to the table's existing rows
|
|
1393
|
+
*
|
|
1394
|
+
* @description
|
|
1395
|
+
* This method appends the provided array of data objects to the end of the existing rows in the table body.
|
|
1396
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1397
|
+
*
|
|
1398
|
+
* @return {void} - This method doesn't return anything.
|
|
1399
|
+
*
|
|
1400
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1401
|
+
*/
|
|
1303
1402
|
addRows(e) {
|
|
1304
1403
|
const t = this.getBodyModel();
|
|
1305
|
-
if (t instanceof
|
|
1404
|
+
if (t instanceof L) {
|
|
1306
1405
|
const s = t;
|
|
1307
1406
|
let o = s.getAllRows();
|
|
1308
1407
|
s.setRows([...o, ...e]);
|
|
1309
1408
|
} else
|
|
1310
1409
|
console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
1311
1410
|
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Inserts new rows at a specific position in the table body.
|
|
1413
|
+
*
|
|
1414
|
+
* @template T - The type of elements in the rows array
|
|
1415
|
+
* @param {T[]} rows - An array of data objects to insert into the table
|
|
1416
|
+
* @param {number} rowIndex - The index position where the new rows should be inserted
|
|
1417
|
+
*
|
|
1418
|
+
* @description
|
|
1419
|
+
* This method inserts the provided array of data objects at the specified index position in the table body.
|
|
1420
|
+
* Existing rows at or after the specified index will be shifted down.
|
|
1421
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1422
|
+
*
|
|
1423
|
+
* @return {void} - This method doesn't return anything.
|
|
1424
|
+
*
|
|
1425
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1426
|
+
*/
|
|
1312
1427
|
addRowsAt(e, t) {
|
|
1313
1428
|
const s = this.getBodyModel();
|
|
1314
|
-
if (s instanceof
|
|
1429
|
+
if (s instanceof L) {
|
|
1315
1430
|
const o = s;
|
|
1316
1431
|
let i = o.getAllRows();
|
|
1317
1432
|
o.setRows([...i.slice(0, t), ...e, ...i.slice(t)]);
|
|
1318
1433
|
} else
|
|
1319
1434
|
console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1320
1435
|
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Removes specified rows from the table body.
|
|
1438
|
+
*
|
|
1439
|
+
* @template T - The type of elements in the rows array
|
|
1440
|
+
* @param {T[]} rows - An array of data objects to remove from the table
|
|
1441
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1442
|
+
* - Default predicate uses strict equality (===)
|
|
1443
|
+
* - The function should return true if the rows are considered a match
|
|
1444
|
+
*
|
|
1445
|
+
* @description
|
|
1446
|
+
* This method removes rows from the table body that match any of the provided rows based on the predicate function.
|
|
1447
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1448
|
+
*
|
|
1449
|
+
* @return {void} - This method doesn't return anything.
|
|
1450
|
+
*
|
|
1451
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1452
|
+
*/
|
|
1321
1453
|
removeRows(e, t = (s, o) => s === o) {
|
|
1322
1454
|
const s = this.getBodyModel();
|
|
1323
|
-
if (s instanceof
|
|
1455
|
+
if (s instanceof L) {
|
|
1324
1456
|
const o = s, i = o.getAllRows().filter((r) => !e.some((a) => t(r, a)));
|
|
1325
1457
|
o.setRows(i);
|
|
1326
1458
|
} else
|
|
1327
1459
|
console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1328
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Searches for and returns rows from the table body that match the given criteria.
|
|
1463
|
+
*
|
|
1464
|
+
* @template T - The type of elements in the rows array
|
|
1465
|
+
*
|
|
1466
|
+
* @description
|
|
1467
|
+
* This method searches through the table body model for rows that match the provided criteria.
|
|
1468
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1469
|
+
* The method uses a predicate function to determine matches between rows.
|
|
1470
|
+
*
|
|
1471
|
+
* @param {T[]} rows - An array of rows to search for in the table body
|
|
1472
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1473
|
+
* - Default predicate uses strict equality (===)
|
|
1474
|
+
* - The function should return true if the rows are considered a match
|
|
1475
|
+
* - Parameters:
|
|
1476
|
+
* - a: The row from the table body being checked
|
|
1477
|
+
* - b: The row from the input array being searched for
|
|
1478
|
+
*
|
|
1479
|
+
* @returns {T[]} An array containing all matching rows found in the table body
|
|
1480
|
+
* - Returns an empty array if:
|
|
1481
|
+
* - The body model is not an instance of AreaModelObjectArray
|
|
1482
|
+
* - No matches are found
|
|
1483
|
+
*
|
|
1484
|
+
* @example
|
|
1485
|
+
* // Find rows with simple equality comparison
|
|
1486
|
+
* const matchingRows = table.findRows([row1, row2]);
|
|
1487
|
+
*
|
|
1488
|
+
* @example
|
|
1489
|
+
* // Find rows with custom comparison logic
|
|
1490
|
+
* const matchingRows = table.findRows([row1, row2], (a, b) => a.id === b.id);
|
|
1491
|
+
*
|
|
1492
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1493
|
+
*/
|
|
1329
1494
|
findRows(e, t = (s, o) => s === o) {
|
|
1330
1495
|
const s = this.getBodyModel();
|
|
1331
|
-
return s instanceof
|
|
1496
|
+
return s instanceof L ? s.getAllRows().filter((i) => e.some((r) => t(i, r))) : (console.warn("findRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s), []);
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Searches through the filtered rows of the table to find a row that matches specific criteria.
|
|
1500
|
+
* This method only works with tables that use AreaModelObjectArray as their body model.
|
|
1501
|
+
*
|
|
1502
|
+
* @template T - The type of the row objects in the table
|
|
1503
|
+
*
|
|
1504
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1505
|
+
* Only needs to include the properties you want to match against.
|
|
1506
|
+
*
|
|
1507
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1508
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1509
|
+
*
|
|
1510
|
+
* @returns {T | undefined} The first matching row from the filtered rows, or undefined if no match is found
|
|
1511
|
+
* or if the body model is not an instance of AreaModelObjectArray.
|
|
1512
|
+
*
|
|
1513
|
+
* @example
|
|
1514
|
+
* ```typescript
|
|
1515
|
+
* interface Person {
|
|
1516
|
+
* id: number;
|
|
1517
|
+
* name: string;
|
|
1518
|
+
* age: number;
|
|
1519
|
+
* }
|
|
1520
|
+
*
|
|
1521
|
+
* // Find a person by exact match
|
|
1522
|
+
* const criteria = { name: "John", age: 30 };
|
|
1523
|
+
* const person = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1524
|
+
* criteria,
|
|
1525
|
+
* (criteria, row) => row.name === criteria.name && row.age === criteria.age
|
|
1526
|
+
* );
|
|
1527
|
+
*
|
|
1528
|
+
* // Find a person by partial name match
|
|
1529
|
+
* const searchCriteria = { name: "Jo" };
|
|
1530
|
+
* const person2 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1531
|
+
* searchCriteria,
|
|
1532
|
+
* (criteria, row) => row.name.toLowerCase().includes(criteria.name!.toLowerCase())
|
|
1533
|
+
* );
|
|
1534
|
+
*
|
|
1535
|
+
* // Find a person within age range
|
|
1536
|
+
* const ageCriteria = { minAge: 25, maxAge: 35 };
|
|
1537
|
+
* const person3 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1538
|
+
* ageCriteria,
|
|
1539
|
+
* (criteria, row) => row.age >= criteria.minAge! && row.age <= criteria.maxAge!
|
|
1540
|
+
* );
|
|
1541
|
+
* ```
|
|
1542
|
+
*
|
|
1543
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1544
|
+
*
|
|
1545
|
+
* @remarks
|
|
1546
|
+
* - This method only searches through filtered rows (rows that are currently visible in the table)
|
|
1547
|
+
* - If you need to search through all rows (including filtered out ones), use findRowFromAllRowsByAllCriteria instead
|
|
1548
|
+
* - The predicate function gives you full control over how to match rows against your criteria
|
|
1549
|
+
* - Returns undefined if either no match is found or if the table's body model is not compatible
|
|
1550
|
+
*/
|
|
1551
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
1552
|
+
const s = this.getBodyModel();
|
|
1553
|
+
if (s instanceof L)
|
|
1554
|
+
return s.getFilteredRows().find((i) => t(e, i));
|
|
1555
|
+
console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Searches through all rows in the table's body model to find a row that matches specified criteria.
|
|
1559
|
+
* This method works only with AreaModelObjectArray<T> body models.
|
|
1560
|
+
*
|
|
1561
|
+
* @template T - The type of objects/rows in the table
|
|
1562
|
+
*
|
|
1563
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1564
|
+
* Only needs to include the properties you want to match against.
|
|
1565
|
+
*
|
|
1566
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1567
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1568
|
+
*
|
|
1569
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found or if the body model is not AreaModelObjectArray.
|
|
1570
|
+
*
|
|
1571
|
+
* @example
|
|
1572
|
+
* // Find a user row by id and name
|
|
1573
|
+
* const criteria = { id: 1, name: "John" };
|
|
1574
|
+
* const user = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1575
|
+
* (criteria, row) => row.id === criteria.id && row.name === criteria.name
|
|
1576
|
+
* );
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* // Find a product row with partial match on name
|
|
1580
|
+
* const criteria = { name: "Phone" };
|
|
1581
|
+
* const product = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1582
|
+
* (criteria, row) => row.name.includes(criteria.name)
|
|
1583
|
+
* );
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* // Find an order with complex matching logic
|
|
1587
|
+
* const criteria = { total: 100, status: "pending" };
|
|
1588
|
+
* const order = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1589
|
+
* (criteria, row) => {
|
|
1590
|
+
* return row.total > criteria.total &&
|
|
1591
|
+
* row.status === criteria.status &&
|
|
1592
|
+
* row.items.length > 0;
|
|
1593
|
+
* }
|
|
1594
|
+
* );
|
|
1595
|
+
*
|
|
1596
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1597
|
+
*/
|
|
1598
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
1599
|
+
const s = this.getBodyModel();
|
|
1600
|
+
if (s instanceof L)
|
|
1601
|
+
return s.getAllRows().find((i) => t(e, i));
|
|
1602
|
+
console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1332
1603
|
}
|
|
1604
|
+
/**
|
|
1605
|
+
* Updates existing rows in the table body with new data.
|
|
1606
|
+
*
|
|
1607
|
+
* @template T - The type of elements in the rows array
|
|
1608
|
+
* @param {T[]} rows - An array of data objects containing the updated values
|
|
1609
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines which rows to update
|
|
1610
|
+
* - Default predicate uses strict equality (===)
|
|
1611
|
+
* - The function should return true if the row should be updated
|
|
1612
|
+
*
|
|
1613
|
+
* @description
|
|
1614
|
+
* This method updates existing rows in the table body with new values from the provided rows array.
|
|
1615
|
+
* For each row in the table, if the predicate returns true when compared with any row in the provided array,
|
|
1616
|
+
* all properties from the provided row will be copied to the existing row.
|
|
1617
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1618
|
+
*
|
|
1619
|
+
* @return {void} - This method doesn't return anything.
|
|
1620
|
+
*
|
|
1621
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1622
|
+
*/
|
|
1333
1623
|
updateRows(e, t = (s, o) => s === o) {
|
|
1334
1624
|
const s = this.getBodyModel();
|
|
1335
|
-
if (s instanceof
|
|
1625
|
+
if (s instanceof L) {
|
|
1336
1626
|
let i = s.getAllRows();
|
|
1337
1627
|
for (const r of i)
|
|
1338
1628
|
for (const a of e)
|
|
@@ -1342,12 +1632,165 @@ class ot {
|
|
|
1342
1632
|
} else
|
|
1343
1633
|
console.warn("updateRows<T>(rows: T[], predicate: (a: T, b: T) => boolean) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1344
1634
|
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Re-applies the current sorting configuration to the table data.
|
|
1637
|
+
*
|
|
1638
|
+
* @description
|
|
1639
|
+
* This method triggers a re-sort of the table data using the current sorting configuration.
|
|
1640
|
+
* It's useful when the underlying data has changed and needs to be re-sorted without changing
|
|
1641
|
+
* the sort columns or direction.
|
|
1642
|
+
*
|
|
1643
|
+
* @return {void} - This method doesn't return anything.
|
|
1644
|
+
*/
|
|
1345
1645
|
reSort() {
|
|
1346
1646
|
this.tableScope.reSort();
|
|
1347
1647
|
}
|
|
1648
|
+
/**
|
|
1649
|
+
* Sorts the table data using a custom comparison function.
|
|
1650
|
+
*
|
|
1651
|
+
* This method allows sorting of table rows by providing a custom comparison function. The comparison function
|
|
1652
|
+
* should follow the standard JavaScript array sort comparator pattern, returning:
|
|
1653
|
+
* - A negative number if the first element should be sorted before the second
|
|
1654
|
+
* - A positive number if the first element should be sorted after the second
|
|
1655
|
+
* - Zero if the elements are equal
|
|
1656
|
+
*
|
|
1657
|
+
* @param compareFn - A function that defines the sort order. The function should accept two arguments
|
|
1658
|
+
* and return a number indicating their relative order:
|
|
1659
|
+
* - Negative number: first argument should come before second
|
|
1660
|
+
* - Positive number: second argument should come before first
|
|
1661
|
+
* - Zero: elements are equal
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* // Sort table rows by a specific property in ascending order
|
|
1665
|
+
* table.api.sort((a, b) => {
|
|
1666
|
+
* if (a.name < b.name) return -1;
|
|
1667
|
+
* if (a.name > b.name) return 1;
|
|
1668
|
+
* return 0;
|
|
1669
|
+
* });
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* // Sort numbers in descending order
|
|
1673
|
+
* table.api.sort((a, b) => b.value - a.value);
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* // Sort with multiple criteria
|
|
1677
|
+
* table.api.sort((a, b) => {
|
|
1678
|
+
* // First sort by status
|
|
1679
|
+
* const statusCompare = a.status.localeCompare(b.status);
|
|
1680
|
+
* if (statusCompare !== 0) return statusCompare;
|
|
1681
|
+
*
|
|
1682
|
+
* // Then sort by name if status is equal
|
|
1683
|
+
* return a.name.localeCompare(b.name);
|
|
1684
|
+
* });
|
|
1685
|
+
*
|
|
1686
|
+
* @example
|
|
1687
|
+
* // Case-insensitive string sorting
|
|
1688
|
+
* table.api.sort((a, b) =>
|
|
1689
|
+
* a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
1690
|
+
* );
|
|
1691
|
+
*/
|
|
1692
|
+
sort(e) {
|
|
1693
|
+
this.tableScope.sort(e);
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
1697
|
+
* This method checks if the target row is within the currently visible range and
|
|
1698
|
+
* adjusts the scroll position if it's not visible.
|
|
1699
|
+
*
|
|
1700
|
+
* The method performs the following:
|
|
1701
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
1702
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
1703
|
+
* 3. Scrolls to make the row visible if needed
|
|
1704
|
+
*
|
|
1705
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
1706
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* // Ensure row 5 is visible in the viewport
|
|
1710
|
+
* tableApi.ensureRowIsVisible(5);
|
|
1711
|
+
*
|
|
1712
|
+
* @example
|
|
1713
|
+
* // Example usage in a component
|
|
1714
|
+
* class MyTableComponent {
|
|
1715
|
+
* private tableApi: TableApi;
|
|
1716
|
+
*
|
|
1717
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
1718
|
+
* // This will scroll the row into view if it's not visible
|
|
1719
|
+
* const didScroll = this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1720
|
+
*
|
|
1721
|
+
* if (didScroll) {
|
|
1722
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
1723
|
+
* } else {
|
|
1724
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
1725
|
+
* }
|
|
1726
|
+
* }
|
|
1727
|
+
* }
|
|
1728
|
+
*
|
|
1729
|
+
* @example
|
|
1730
|
+
* // Example with row selection
|
|
1731
|
+
* class TableHandler {
|
|
1732
|
+
* selectAndShowRow(rowIndex: number) {
|
|
1733
|
+
* // First ensure the row is visible
|
|
1734
|
+
* this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1735
|
+
*
|
|
1736
|
+
* // Then perform selection
|
|
1737
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
1738
|
+
* }
|
|
1739
|
+
* }
|
|
1740
|
+
*
|
|
1741
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
1742
|
+
*
|
|
1743
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
1744
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
1745
|
+
*/
|
|
1746
|
+
ensureRowIsVisible(e) {
|
|
1747
|
+
return this.tableScope.ensureRowIsVisible(e);
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Retrieves the number of rows currently displayed in the table.
|
|
1751
|
+
*
|
|
1752
|
+
* @description
|
|
1753
|
+
* This method returns the count of rows that are currently visible in the table after
|
|
1754
|
+
* applying any filtering, pagination, or other visibility constraints.
|
|
1755
|
+
*
|
|
1756
|
+
* @return {number} The number of rows currently displayed in the table.
|
|
1757
|
+
*/
|
|
1348
1758
|
getDisplayedRowCount() {
|
|
1349
1759
|
return this.tableScope.getDisplayedRowCount();
|
|
1350
1760
|
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Returns the index of the first visible row in the table's viewport.
|
|
1763
|
+
*
|
|
1764
|
+
* This method retrieves the first visible row index from the table's scope, which is useful
|
|
1765
|
+
* for virtual scrolling and viewport-related calculations. The index represents the topmost
|
|
1766
|
+
* visible row in the current scroll position of the table.
|
|
1767
|
+
*
|
|
1768
|
+
* This value is maintained internally by the table and updated during scrolling operations.
|
|
1769
|
+
* It's particularly important for:
|
|
1770
|
+
* - Virtual scrolling optimization
|
|
1771
|
+
* - Calculating visible range of rows
|
|
1772
|
+
* - Viewport-related operations
|
|
1773
|
+
* - Scroll position restoration
|
|
1774
|
+
*
|
|
1775
|
+
* @returns {number} The index of the first visible row in the table's viewport.
|
|
1776
|
+
* Returns -1 if no rows are visible or if the table is not yet rendered.
|
|
1777
|
+
*
|
|
1778
|
+
* @example
|
|
1779
|
+
* ```typescript
|
|
1780
|
+
* // Get the first visible row index
|
|
1781
|
+
* const tableApi = new TableApi(tableScope);
|
|
1782
|
+
* const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
|
|
1783
|
+
*
|
|
1784
|
+
* // Use the index for scroll position calculations
|
|
1785
|
+
* if (firstVisibleIndex >= 0) {
|
|
1786
|
+
* // Perform operations with the first visible row
|
|
1787
|
+
* console.log(`First visible row index: ${firstVisibleIndex}`);
|
|
1788
|
+
* }
|
|
1789
|
+
* ```
|
|
1790
|
+
*/
|
|
1791
|
+
getFirstVisibleRowIndex() {
|
|
1792
|
+
return this.tableScope.getFirstVisibleRowIndex();
|
|
1793
|
+
}
|
|
1351
1794
|
}
|
|
1352
1795
|
class de {
|
|
1353
1796
|
constructor(e) {
|
|
@@ -1498,14 +1941,14 @@ class at extends de {
|
|
|
1498
1941
|
}
|
|
1499
1942
|
}
|
|
1500
1943
|
}
|
|
1501
|
-
class
|
|
1944
|
+
class k {
|
|
1502
1945
|
constructor(e = 0, t = 0, s = 0, o = 0, i) {
|
|
1503
1946
|
this.left = e, this.width = t, this.height = s, this.top = o, this.index = i;
|
|
1504
1947
|
}
|
|
1505
1948
|
}
|
|
1506
1949
|
class nt {
|
|
1507
1950
|
constructor(e, t, s, o) {
|
|
1508
|
-
this.hostElement = e, this.tableModel = t, this.dom = s, this.tableOptions = o, this.scrollTop = 0, this.areaBodyWestGeo = new
|
|
1951
|
+
this.hostElement = e, this.tableModel = t, this.dom = s, this.tableOptions = o, this.scrollTop = 0, this.areaBodyWestGeo = new k(), this.areaBodyCenterGeo = new k(), this.areaBodyEastGeo = new k();
|
|
1509
1952
|
const i = this.hostElement;
|
|
1510
1953
|
i.innerText = "", this.dom.setAttribute(i, "tabindex", "0"), this.dom.setStyle(
|
|
1511
1954
|
this.dom.addClass("ge-table", i),
|
|
@@ -1674,7 +2117,7 @@ class nt {
|
|
|
1674
2117
|
this.dom.setStyle(this.contentWrapperDiv, "width", e), this.dom.setStyle(this.contentWrapperDiv, "height", t);
|
|
1675
2118
|
}
|
|
1676
2119
|
}
|
|
1677
|
-
class
|
|
2120
|
+
class E {
|
|
1678
2121
|
/**
|
|
1679
2122
|
* Represents a constructor for a class.
|
|
1680
2123
|
* @constructor
|
|
@@ -1688,7 +2131,7 @@ class A {
|
|
|
1688
2131
|
this.r1 = e, this.c1 = t, this.r2 = s, this.c2 = o, this.gammaRange = i;
|
|
1689
2132
|
}
|
|
1690
2133
|
static create(e) {
|
|
1691
|
-
return e.gammaRange === void 0 && (e.gammaRange = !1), new
|
|
2134
|
+
return e.gammaRange === void 0 && (e.gammaRange = !1), new E(
|
|
1692
2135
|
e.rowIndex1,
|
|
1693
2136
|
e.columnIndex1,
|
|
1694
2137
|
e.rowIndex2,
|
|
@@ -1697,13 +2140,13 @@ class A {
|
|
|
1697
2140
|
);
|
|
1698
2141
|
}
|
|
1699
2142
|
static singleCell(e, t) {
|
|
1700
|
-
return new
|
|
2143
|
+
return new E(e, t, e, t);
|
|
1701
2144
|
}
|
|
1702
2145
|
static singleRow(e) {
|
|
1703
|
-
return new
|
|
2146
|
+
return new E(e, 0, e, Number.MAX_SAFE_INTEGER);
|
|
1704
2147
|
}
|
|
1705
2148
|
static singleColumn(e) {
|
|
1706
|
-
return new
|
|
2149
|
+
return new E(0, e, Number.MAX_SAFE_INTEGER, e);
|
|
1707
2150
|
}
|
|
1708
2151
|
isInRange(e, t) {
|
|
1709
2152
|
return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
|
|
@@ -1725,7 +2168,7 @@ class ct {
|
|
|
1725
2168
|
i === 0 && (i = 1), r === 0 && (r = 1);
|
|
1726
2169
|
const a = "gammaCells" in this.areaModel;
|
|
1727
2170
|
this.colAndRowspanRanges.push(
|
|
1728
|
-
new
|
|
2171
|
+
new E(s, o, s + r - 1, o + i - 1, a)
|
|
1729
2172
|
);
|
|
1730
2173
|
}
|
|
1731
2174
|
}
|
|
@@ -1843,19 +2286,19 @@ class ht extends nt {
|
|
|
1843
2286
|
for (const t of this.removables)
|
|
1844
2287
|
t.remove();
|
|
1845
2288
|
this.hideHoverRow(), this.hideHoverColumn(), this.scrollTop = this.scrollViewport.scrollTop, this.scrollLeft = this.scrollViewport.scrollLeft, this.debounce(this.checkForScrollPosSaving.bind(this)), this.scrollFactorY = this.scrollTop / (this.scrollViewport.scrollHeight - this.scrollViewport.clientHeight), this.scrollFactorX = this.scrollLeft / (this.scrollViewport.scrollWidth - this.scrollViewport.clientWidth), isNaN(this.scrollFactorY) && (this.scrollFactorY = 0), isNaN(this.scrollFactorX) && (this.scrollFactorX = 0), this.adjustBody(), this.adjustArea("footer"), this.adjustArea("header"), this.tableOptions.tableTopBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
|
|
1846
|
-
new
|
|
2289
|
+
new k(0, this.hostElement.clientWidth, 1, 0),
|
|
1847
2290
|
this.hostElement,
|
|
1848
2291
|
"ge-table-border"
|
|
1849
2292
|
)), this.tableOptions.tableBottomBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
|
|
1850
|
-
new
|
|
2293
|
+
new k(0, this.hostElement.clientWidth, 1, this.hostElement.clientHeight - 1),
|
|
1851
2294
|
this.hostElement,
|
|
1852
2295
|
"ge-table-border"
|
|
1853
2296
|
)), this.tableModel.getFixedLeftColumnCount() > 0 && this.removables.push(this.dom.addVerticalBorder(
|
|
1854
|
-
new
|
|
2297
|
+
new k(this.areaBodyWest.child.clientWidth, 1, this.hostElement.clientHeight, 0),
|
|
1855
2298
|
this.hostElement,
|
|
1856
2299
|
"ge-table-body-west-vertical-border"
|
|
1857
2300
|
)), ((e = this.tableModel.getAreaModel("header")) == null ? void 0 : e.getRowCount()) > 0 && this.removables.push(this.dom.addHorizontalBorder(
|
|
1858
|
-
new
|
|
2301
|
+
new k(0, this.hostElement.clientWidth, 1, this.areaHeaderCenter.child.clientHeight),
|
|
1859
2302
|
this.hostElement,
|
|
1860
2303
|
"ge-table-body-west-vertical-border"
|
|
1861
2304
|
));
|
|
@@ -2019,11 +2462,11 @@ class ht extends nt {
|
|
|
2019
2462
|
let p = t;
|
|
2020
2463
|
const u = this.tableModel.getColumnCount(), g = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
|
|
2021
2464
|
for (let m = 0; m < h; m++) {
|
|
2022
|
-
const w = p,
|
|
2023
|
-
if (w +
|
|
2465
|
+
const w = p, C = m === h - 1, A = this.tableModel.getRowHeight(e, m);
|
|
2466
|
+
if (w + A > 0) {
|
|
2024
2467
|
this.firstVisibleRowIndex = m;
|
|
2025
|
-
let y = { left: a, width: n, height:
|
|
2026
|
-
const
|
|
2468
|
+
let y = { left: a, width: n, height: A, top: w, index: m }, S = this.dom.addRowDiv(o, y, m, e, "center");
|
|
2469
|
+
const F = b;
|
|
2027
2470
|
if (this.adjustColumnsToRowParent({
|
|
2028
2471
|
areaIdent: e,
|
|
2029
2472
|
sideIdent: "center",
|
|
@@ -2031,11 +2474,11 @@ class ht extends nt {
|
|
|
2031
2474
|
geo: y,
|
|
2032
2475
|
parent: S,
|
|
2033
2476
|
rowIndex: m,
|
|
2034
|
-
columnIndexStart:
|
|
2477
|
+
columnIndexStart: F,
|
|
2035
2478
|
columnIndexEnd: u - g - 1,
|
|
2036
2479
|
verticalFixed: !1,
|
|
2037
|
-
lastRowOfModel:
|
|
2038
|
-
}), d.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height:
|
|
2480
|
+
lastRowOfModel: C
|
|
2481
|
+
}), d.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height: A, top: w, index: m }, S = this.dom.addRowDiv(s, y, m, e, "west"), this.adjustColumnsToRowParent({
|
|
2039
2482
|
areaIdent: e,
|
|
2040
2483
|
sideIdent: "west",
|
|
2041
2484
|
areaModel: c,
|
|
@@ -2043,10 +2486,10 @@ class ht extends nt {
|
|
|
2043
2486
|
parent: S,
|
|
2044
2487
|
rowIndex: m,
|
|
2045
2488
|
columnIndexStart: 0,
|
|
2046
|
-
columnIndexEnd:
|
|
2489
|
+
columnIndexEnd: F - 1,
|
|
2047
2490
|
verticalFixed: !0,
|
|
2048
|
-
lastRowOfModel:
|
|
2049
|
-
})), d.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height:
|
|
2491
|
+
lastRowOfModel: C
|
|
2492
|
+
})), d.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height: A, top: w, index: m }, S = this.dom.addRowDiv(i, y, m, e, "east"), this.adjustColumnsToRowParent({
|
|
2050
2493
|
areaIdent: e,
|
|
2051
2494
|
sideIdent: "east",
|
|
2052
2495
|
areaModel: c,
|
|
@@ -2056,11 +2499,11 @@ class ht extends nt {
|
|
|
2056
2499
|
columnIndexStart: u - g,
|
|
2057
2500
|
columnIndexEnd: u - 1,
|
|
2058
2501
|
verticalFixed: !0,
|
|
2059
|
-
lastRowOfModel:
|
|
2502
|
+
lastRowOfModel: C
|
|
2060
2503
|
})), e === "header" && this.tree && m === h - 1) {
|
|
2061
2504
|
const T = this.dom.applyStyle(
|
|
2062
2505
|
this.dom.setAttribute(
|
|
2063
|
-
this.dom.addDiv(S, new
|
|
2506
|
+
this.dom.addDiv(S, new k(16, 20, 20, 8)),
|
|
2064
2507
|
"data-ge-action",
|
|
2065
2508
|
"toggleExpandCollapseAll"
|
|
2066
2509
|
),
|
|
@@ -2072,7 +2515,7 @@ class ht extends nt {
|
|
|
2072
2515
|
}
|
|
2073
2516
|
}
|
|
2074
2517
|
}
|
|
2075
|
-
if (p = p +
|
|
2518
|
+
if (p = p + A, p > r) {
|
|
2076
2519
|
e === "body" && (this.displayedRowCount = this.firstVisibleRowIndex - m);
|
|
2077
2520
|
break;
|
|
2078
2521
|
}
|
|
@@ -2081,16 +2524,16 @@ class ht extends nt {
|
|
|
2081
2524
|
const m = ((f = this.colAndRowspanModels[e]) == null ? void 0 : f.getRanges()) ?? [];
|
|
2082
2525
|
if (m.length)
|
|
2083
2526
|
for (const w of m) {
|
|
2084
|
-
let
|
|
2527
|
+
let C = 0, A = o.child, y = "center";
|
|
2085
2528
|
if (w.c1 < b)
|
|
2086
|
-
|
|
2529
|
+
A = s.child, y = "west";
|
|
2087
2530
|
else if (g > 0 && w.c1 >= u - g)
|
|
2088
|
-
|
|
2531
|
+
A = i.child, y = "east";
|
|
2089
2532
|
else {
|
|
2090
2533
|
const S = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
2091
|
-
|
|
2534
|
+
C = this.scrollFactorX * S - this.areaBodyWestGeo.width, y = "center";
|
|
2092
2535
|
}
|
|
2093
|
-
this.drawBigCell(w,
|
|
2536
|
+
this.drawBigCell(w, C, t, c, A, y);
|
|
2094
2537
|
}
|
|
2095
2538
|
}
|
|
2096
2539
|
}
|
|
@@ -2200,19 +2643,19 @@ class ht extends nt {
|
|
|
2200
2643
|
for (let f = a; f <= n; f++) {
|
|
2201
2644
|
const m = g, w = this.tableModel.getColumnWidth(f);
|
|
2202
2645
|
if (w > 0 && m + w > 0) {
|
|
2203
|
-
let
|
|
2204
|
-
const
|
|
2205
|
-
|
|
2646
|
+
let C = o.height;
|
|
2647
|
+
const A = s.getRowspanAt(r, f), y = s.getColspanAt(r, f);
|
|
2648
|
+
A > 1 && (C = this.getRowHeights(r, r + A - 1, s).reduce((T, D) => T + D, 0));
|
|
2206
2649
|
let S = w;
|
|
2207
2650
|
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((T, D) => T + D, 0));
|
|
2208
|
-
let
|
|
2209
|
-
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (
|
|
2210
|
-
this.renderDragTargetDiv(i, m, p, S,
|
|
2211
|
-
const T = { left: m, top: p, width: S, height:
|
|
2651
|
+
let F = !1;
|
|
2652
|
+
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (F = !0), this.draggingTargetColumnIndex === f && e !== "header") {
|
|
2653
|
+
this.renderDragTargetDiv(i, m, p, S, C);
|
|
2654
|
+
const T = { left: m, top: p, width: S, height: C };
|
|
2212
2655
|
this.dom.addColumnBorderDivs(this.tableOptions, i, T, e, t);
|
|
2213
2656
|
} else {
|
|
2214
|
-
const T = this.renderSelectedBackgroundDiv(
|
|
2215
|
-
"gammaCells" in s && s.getValueAt(r, f) && (
|
|
2657
|
+
const T = this.renderSelectedBackgroundDiv(F, u, t, s, r, f, i, m, p, S, C);
|
|
2658
|
+
"gammaCells" in s && s.getValueAt(r, f) && (F = !1), F || this.renderCell({
|
|
2216
2659
|
areaModel: s,
|
|
2217
2660
|
areaIdent: e,
|
|
2218
2661
|
sideIdent: t,
|
|
@@ -2221,7 +2664,7 @@ class ht extends nt {
|
|
|
2221
2664
|
left: m,
|
|
2222
2665
|
top: p,
|
|
2223
2666
|
width: S,
|
|
2224
|
-
height:
|
|
2667
|
+
height: C,
|
|
2225
2668
|
parent: i,
|
|
2226
2669
|
cellSelected: T,
|
|
2227
2670
|
lastRowOfModel: c,
|
|
@@ -2232,7 +2675,7 @@ class ht extends nt {
|
|
|
2232
2675
|
cellLeft: m,
|
|
2233
2676
|
cellTop: p,
|
|
2234
2677
|
cellWidth: S,
|
|
2235
|
-
cellHeight:
|
|
2678
|
+
cellHeight: C,
|
|
2236
2679
|
parent: i
|
|
2237
2680
|
});
|
|
2238
2681
|
}
|
|
@@ -2240,7 +2683,7 @@ class ht extends nt {
|
|
|
2240
2683
|
if (g = g + w, g > this.areaBodyCenterGeo.width)
|
|
2241
2684
|
break;
|
|
2242
2685
|
}
|
|
2243
|
-
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new
|
|
2686
|
+
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new k(g - 1, 1, o.height, 0), i);
|
|
2244
2687
|
}
|
|
2245
2688
|
/**
|
|
2246
2689
|
* Retrieves the column index of the tree arrow column in the table.
|
|
@@ -2271,15 +2714,15 @@ class ht extends nt {
|
|
|
2271
2714
|
const u = this.editorRenderer && this.editorRendererRow === o && this.editorRendererColumn === i ? this.editorRenderer : e.getCellRenderer(o, i), g = { left: r, width: a, height: n, top: d, index: i }, b = e.getRowByIndex(o);
|
|
2272
2715
|
let f = "none";
|
|
2273
2716
|
if (i === this.getTreeArrowColumnIndex() && K(b)) {
|
|
2274
|
-
const
|
|
2275
|
-
(ge =
|
|
2717
|
+
const v = b;
|
|
2718
|
+
(ge = v.children) != null && ge.length ? v.expanded ? f = "expanded" : f = "collapsed" : f = "hidden";
|
|
2276
2719
|
}
|
|
2277
2720
|
let w;
|
|
2278
2721
|
if (t === "header") {
|
|
2279
|
-
const
|
|
2280
|
-
(!(
|
|
2722
|
+
const v = this.tableModel.getColumnDef(i);
|
|
2723
|
+
(!(v != null && v.sortIconVisible) || v != null && v.sortIconVisible()) && (w = v == null ? void 0 : v.sortState);
|
|
2281
2724
|
}
|
|
2282
|
-
const
|
|
2725
|
+
const C = e.getValueAt(o, i), A = u ? "" : `${C}`, y = e.isRowChecked(o), S = this.dom.addColumnDiv(
|
|
2283
2726
|
{
|
|
2284
2727
|
parent: c,
|
|
2285
2728
|
geo: g,
|
|
@@ -2287,28 +2730,28 @@ class ht extends nt {
|
|
|
2287
2730
|
columnIndex: i,
|
|
2288
2731
|
areaIdent: t,
|
|
2289
2732
|
sideIdent: s,
|
|
2290
|
-
text:
|
|
2733
|
+
text: A,
|
|
2291
2734
|
treeArrow: f,
|
|
2292
2735
|
tableOptions: this.tableOptions,
|
|
2293
2736
|
checkedType: y,
|
|
2294
2737
|
sortState: w
|
|
2295
2738
|
}
|
|
2296
|
-
),
|
|
2297
|
-
|
|
2739
|
+
), F = e.getTooltipAt(o, i);
|
|
2740
|
+
F && this.dom.setAttribute(S, "title", F);
|
|
2298
2741
|
const T = this.tableModel.getColumnDef(i);
|
|
2299
2742
|
T && T.classes[t] && this.dom.addClasses(T.classes[t], S);
|
|
2300
2743
|
let D;
|
|
2301
|
-
u && (D = u.render(S, o, i, t, e,
|
|
2744
|
+
u && (D = u.render(S, o, i, t, e, C, this.dom.domService));
|
|
2302
2745
|
const N = e.getCustomClassesAt(o, i);
|
|
2303
2746
|
if (N.length && this.dom.addClasses(N, S), this.dom.addColumnBorderDivs(this.tableOptions, c, g, t, s), h && this.dom.addHorizontalBorder({ left: r, width: a, height: n, top: d + n }, c), this.getFocusModel && t === "body") {
|
|
2304
|
-
const
|
|
2305
|
-
|
|
2747
|
+
const v = this.getFocusModel();
|
|
2748
|
+
v != null && v.hasFocus(o, i) && this.dom.addFocusBorderDivs(c, g, {});
|
|
2306
2749
|
}
|
|
2307
2750
|
t === "header" && this.dom.setAttribute(S, "data-ge-action", "drag-column");
|
|
2308
2751
|
const ee = e.getCustomStyleAt(o, i);
|
|
2309
2752
|
if (ee)
|
|
2310
|
-
for (const
|
|
2311
|
-
this.dom.setStyle(S,
|
|
2753
|
+
for (const v in ee)
|
|
2754
|
+
this.dom.setStyle(S, v, ee[v]);
|
|
2312
2755
|
return [S, D];
|
|
2313
2756
|
}
|
|
2314
2757
|
/**
|
|
@@ -2486,10 +2929,10 @@ class ht extends nt {
|
|
|
2486
2929
|
}, m = this.dom.addColumnDiv(f);
|
|
2487
2930
|
let w;
|
|
2488
2931
|
g && (w = g.render(m, d, a, t, i, u, this.dom.domService), w && this.cleanupFunctions[t].push(w));
|
|
2489
|
-
const
|
|
2490
|
-
|
|
2491
|
-
const
|
|
2492
|
-
|
|
2932
|
+
const C = i.getCustomClassesAt(d, a);
|
|
2933
|
+
C.length && this.dom.addClasses(C, m);
|
|
2934
|
+
const A = this.tableModel.getColumnDef(a);
|
|
2935
|
+
A && A.classes[t] && this.dom.addClasses(A.classes[t], m), this.dom.addColumnBorderDivs(this.tableOptions, n, p, t, o);
|
|
2493
2936
|
const y = i.getCustomStyleAt(d, a);
|
|
2494
2937
|
if (y)
|
|
2495
2938
|
for (const S in y)
|
|
@@ -2678,7 +3121,7 @@ class ut {
|
|
|
2678
3121
|
let s = !1, o = !1;
|
|
2679
3122
|
if (this.getSelectionModel && this.getFocusModel) {
|
|
2680
3123
|
const p = this.getSelectionModel(), u = this.getFocusModel();
|
|
2681
|
-
p && u && (u.hasFocus(e.rowIndex, e.columnIndex) || (u.setFocus(e.rowIndex, e.columnIndex), this.tableScope.onFocusChanged(u), s = !0), (i = e.originalEvent) != null && i.shiftKey || p.hasSelection() && (p.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (p.addSelection(this.createRangeByEvents(e, this.previousEvt)), o = !0, s = !0) : (a = e.originalEvent) != null && a.altKey && ((n = e.originalEvent) != null && n.ctrlKey || (d = e.originalEvent) != null && d.metaKey) ? (p.removeSelection(
|
|
3124
|
+
p && u && (u.hasFocus(e.rowIndex, e.columnIndex) || (u.setFocus(e.rowIndex, e.columnIndex), this.tableScope.onFocusChanged(u), s = !0), (i = e.originalEvent) != null && i.shiftKey || p.hasSelection() && (p.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (p.addSelection(this.createRangeByEvents(e, this.previousEvt)), o = !0, s = !0) : (a = e.originalEvent) != null && a.altKey && ((n = e.originalEvent) != null && n.ctrlKey || (d = e.originalEvent) != null && d.metaKey) ? (p.removeSelection(E.singleCell(e.rowIndex, e.columnIndex)), o = !0, s = !0) : (c = e.originalEvent) != null && c.ctrlKey || (h = e.originalEvent) != null && h.metaKey ? (p.addSelection(E.singleCell(e.rowIndex, e.columnIndex)), o = !0, s = !0) : (p.firstClick(e.rowIndex, e.columnIndex), s = !0), this.tableScope.onSelectionChanged(p));
|
|
2682
3125
|
}
|
|
2683
3126
|
return o ? this.previousEvt = void 0 : this.previousEvt = e == null ? void 0 : e.clone(), s;
|
|
2684
3127
|
}
|
|
@@ -2701,7 +3144,7 @@ class ut {
|
|
|
2701
3144
|
createRangeByEvents(e, t) {
|
|
2702
3145
|
t || (t = e);
|
|
2703
3146
|
const s = Math.min(e.rowIndex, t == null ? void 0 : t.rowIndex), o = Math.max(e.rowIndex, t == null ? void 0 : t.rowIndex), i = Math.min(e.columnIndex, t == null ? void 0 : t.columnIndex), r = Math.max(e.columnIndex, t == null ? void 0 : t.columnIndex);
|
|
2704
|
-
return
|
|
3147
|
+
return E.create({
|
|
2705
3148
|
rowIndex1: s,
|
|
2706
3149
|
columnIndex1: i,
|
|
2707
3150
|
rowIndex2: o,
|
|
@@ -2949,7 +3392,7 @@ class xt {
|
|
|
2949
3392
|
this.silent || this.listenerArr.forEach((e) => e.onSelectionChanged(this));
|
|
2950
3393
|
}
|
|
2951
3394
|
firstClick(e, t) {
|
|
2952
|
-
this.selectionType === "row" ? this.addRange(
|
|
3395
|
+
this.selectionType === "row" ? this.addRange(E.singleRow(e)) : this.selectionType === "column" && this.addRange(E.singleColumn(t));
|
|
2953
3396
|
}
|
|
2954
3397
|
getSelectionCount(e, t) {
|
|
2955
3398
|
let s = 0;
|
|
@@ -3000,10 +3443,10 @@ class xt {
|
|
|
3000
3443
|
if (this.selectionType === "none")
|
|
3001
3444
|
return;
|
|
3002
3445
|
let t = e;
|
|
3003
|
-
this.selectionType === "row" ? t =
|
|
3446
|
+
this.selectionType === "row" ? t = E.singleRow(e.r1) : this.selectionType === "column" && (t = E.singleColumn(e.c1)), this.negativeRanges.push(t), this.fireChangeEvent();
|
|
3004
3447
|
}
|
|
3005
3448
|
togglePoint(e, t) {
|
|
3006
|
-
this.getSelectionCount(e, t) > 0 ? this.removeSelection(
|
|
3449
|
+
this.getSelectionCount(e, t) > 0 ? this.removeSelection(E.singleCell(e, t)) : this.addSelection(E.singleCell(e, t));
|
|
3007
3450
|
}
|
|
3008
3451
|
isSelected(e, t) {
|
|
3009
3452
|
return this.getSelectionCount(e, t) > 0;
|
|
@@ -3012,7 +3455,7 @@ class xt {
|
|
|
3012
3455
|
this.selectionType !== "none" && (this.allSelected = !1, this.selectionMode === "single" && (this.ranges = []), this.selectionType === "row" ? (e.c1 = 0, e.c2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "column" ? (e.r1 = 0, e.r2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "cell" ? (e.r2 = e.r1, e.c2 = e.c1) : this.selectionType, this.ranges.push(e), this.fireChangeEvent());
|
|
3013
3456
|
}
|
|
3014
3457
|
}
|
|
3015
|
-
class
|
|
3458
|
+
class Ct {
|
|
3016
3459
|
constructor(e = "none") {
|
|
3017
3460
|
this.selectionType = e, this.rowIndex = -1, this.columnIndex = -1, this.changed = !1, this.listenerArr = [];
|
|
3018
3461
|
}
|
|
@@ -3063,14 +3506,14 @@ class De {
|
|
|
3063
3506
|
}
|
|
3064
3507
|
// `⊖ `, `⊕ `;
|
|
3065
3508
|
}
|
|
3066
|
-
const
|
|
3067
|
-
class
|
|
3509
|
+
const vt = new xt(), At = new Ct("cell");
|
|
3510
|
+
class Fe {
|
|
3068
3511
|
constructor() {
|
|
3069
3512
|
this.overflowX = "auto", this.overflowY = "auto", this.horizontalBorderVisible = !0, this.verticalBorderVisible = !0, this.footerSeparatorBorderVisible = !0, this.headerSeparatorBorderVisible = !0, this.fixedEastSeparatorBorderVisible = !0, this.fixedWestSeparatorBorderVisible = !0, this.tableTopBorderVisible = !0, this.tableBottomBorderVisible = !0, this.hoverRowVisible = !0, this.hoverColumnVisible = !0, this.columnsResizable = !0, this.columnsDraggable = !0, this.columnResizeHandleWidthInPx = 4, this.defaultRowHeights = {
|
|
3070
3513
|
header: 34,
|
|
3071
3514
|
body: 34,
|
|
3072
3515
|
footer: 34
|
|
3073
|
-
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new
|
|
3516
|
+
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new Re(), this.headerGroupOptions = new De(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new Me(), this.sortOrder = ["asc", "desc"], this.shortcutActionsDisabled = !1, this.resizeEventDebounceDelay = 500, this.getEditRenderer = (e, t) => new wt(), this.getSelectionModel = () => vt, this.getFocusModel = () => At;
|
|
3074
3517
|
}
|
|
3075
3518
|
}
|
|
3076
3519
|
const H = class H {
|
|
@@ -3151,14 +3594,14 @@ const H = class H {
|
|
|
3151
3594
|
mergeRanges(e) {
|
|
3152
3595
|
let t;
|
|
3153
3596
|
for (const s of e)
|
|
3154
|
-
t ? (t.r1 = Math.min(t.r1, s.r1), t.c1 = Math.min(t.c1, s.c1), t.r2 = Math.max(t.r2, s.r2), t.c2 = Math.max(t.c2, s.c2)) : t = new
|
|
3597
|
+
t ? (t.r1 = Math.min(t.r1, s.r1), t.c1 = Math.min(t.c1, s.c1), t.r2 = Math.max(t.r2, s.r2), t.c2 = Math.max(t.c2, s.c2)) : t = new E(s.r1, s.c1, s.r2, s.c2);
|
|
3155
3598
|
return t;
|
|
3156
3599
|
}
|
|
3157
3600
|
};
|
|
3158
3601
|
H.columnSeparatorChar = " ", H.rowSeparatorChar = `
|
|
3159
3602
|
`;
|
|
3160
3603
|
let Y = H;
|
|
3161
|
-
class
|
|
3604
|
+
class Et {
|
|
3162
3605
|
constructor(e, t = 500) {
|
|
3163
3606
|
this.tableScope = e, this.debounceDelay = t, new ResizeObserver(qe(this.handleResize.bind(this), t)).observe(this.tableScope.hostElement);
|
|
3164
3607
|
}
|
|
@@ -3167,7 +3610,7 @@ class At {
|
|
|
3167
3610
|
this.tableScope.recalcColumnWidths(s);
|
|
3168
3611
|
}
|
|
3169
3612
|
}
|
|
3170
|
-
class
|
|
3613
|
+
class Rt {
|
|
3171
3614
|
/**
|
|
3172
3615
|
* Downloads a matrix data as an Excel file.
|
|
3173
3616
|
*
|
|
@@ -3274,13 +3717,13 @@ class Mt {
|
|
|
3274
3717
|
}
|
|
3275
3718
|
}
|
|
3276
3719
|
class pe extends ht {
|
|
3277
|
-
constructor(e, t, s, o, i, r = new Y(), a = new
|
|
3720
|
+
constructor(e, t, s, o, i, r = new Y(), a = new Rt()) {
|
|
3278
3721
|
var c;
|
|
3279
|
-
if (super(e, t, new Ze(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager =
|
|
3722
|
+
if (super(e, t, new Ze(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager = P.getInstance(), this.selectionService = new ut(this), this.api = new ot(this), this.mouseStartAction = "", this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, this.lastDragFrom = -1, this.lastDragTo = -1, this.firstDraggingRendering = !0, this.lastContextmenu = Date.now(), t.setTableScope(this), i || (this.eventListener = new be()), (c = this.tableOptions) != null && c.autoRestoreOptions) {
|
|
3280
3723
|
const h = this.tableOptions.autoRestoreOptions, p = h.getStorageKeyFn;
|
|
3281
3724
|
p && (h.autoRestoreScrollPosition && (this.storeScrollPosStateService = new it(p)), h.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new lt(p)), h.autoRestoreSortingState && (this.storeSortingService = new at(p)));
|
|
3282
3725
|
}
|
|
3283
|
-
this.mouseHandler = new et(this), this.inputHandler = new gt(this), this.resizeHandler = new
|
|
3726
|
+
this.mouseHandler = new et(this), this.inputHandler = new gt(this), this.resizeHandler = new Et(this, o.resizeEventDebounceDelay), this.shortcutService = new yt(this), this.shortcutService.addListener(this.selectionService);
|
|
3284
3727
|
const n = this.getSelectionModel ? this.getSelectionModel() : void 0;
|
|
3285
3728
|
n && n.addEventSelectionChangedListener(this);
|
|
3286
3729
|
const d = this.getFocusModel ? this.getFocusModel() : void 0;
|
|
@@ -3298,7 +3741,7 @@ class pe extends ht {
|
|
|
3298
3741
|
*
|
|
3299
3742
|
* @return {TableScope} - The newly created TableScope instance.
|
|
3300
3743
|
*/
|
|
3301
|
-
static create(e, t, s = new
|
|
3744
|
+
static create(e, t, s = new Fe(), o = new be(), i = new Te(), r = new Y()) {
|
|
3302
3745
|
return new pe(e, t, i, s, o, r);
|
|
3303
3746
|
}
|
|
3304
3747
|
/**
|
|
@@ -3698,9 +4141,70 @@ class pe extends ht {
|
|
|
3698
4141
|
let e = ((t = this.storeSortingService) == null ? void 0 : t.getSortItems()) ?? [];
|
|
3699
4142
|
this.tableModel.doSort(e);
|
|
3700
4143
|
}
|
|
4144
|
+
sort(e) {
|
|
4145
|
+
this.tableModel.sort(e);
|
|
4146
|
+
}
|
|
3701
4147
|
getDisplayedRowCount() {
|
|
3702
4148
|
return this.displayedRowCount;
|
|
3703
4149
|
}
|
|
4150
|
+
/**
|
|
4151
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
4152
|
+
* This method checks if the target row is within the currently visible range and
|
|
4153
|
+
* adjusts the scroll position if it's not visible.
|
|
4154
|
+
*
|
|
4155
|
+
* The method performs the following:
|
|
4156
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
4157
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
4158
|
+
* 3. Scrolls to make the row visible if needed
|
|
4159
|
+
*
|
|
4160
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
4161
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
4162
|
+
*
|
|
4163
|
+
* @example
|
|
4164
|
+
* // Ensure row 5 is visible in the viewport
|
|
4165
|
+
* tableScope.ensureRowIsVisible(5);
|
|
4166
|
+
*
|
|
4167
|
+
* @example
|
|
4168
|
+
* // Example usage in a component
|
|
4169
|
+
* class MyTableComponent {
|
|
4170
|
+
* private tableScope: TableScope;
|
|
4171
|
+
*
|
|
4172
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
4173
|
+
* // This will scroll the row into view if it's not visible
|
|
4174
|
+
* const didScroll = this.tableScope.ensureRowIsVisible(rowIndex);
|
|
4175
|
+
*
|
|
4176
|
+
* if (didScroll) {
|
|
4177
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
4178
|
+
* } else {
|
|
4179
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
4180
|
+
* }
|
|
4181
|
+
* }
|
|
4182
|
+
* }
|
|
4183
|
+
*
|
|
4184
|
+
* @example
|
|
4185
|
+
* // Example with row selection
|
|
4186
|
+
* class TableHandler {
|
|
4187
|
+
* selectAndShowRow(rowIndex: number) {
|
|
4188
|
+
* // First ensure the row is visible
|
|
4189
|
+
* this.tableScope.ensureRowIsVisible(rowIndex);
|
|
4190
|
+
*
|
|
4191
|
+
* // Then perform selection
|
|
4192
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
4193
|
+
* }
|
|
4194
|
+
* }
|
|
4195
|
+
*
|
|
4196
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
4197
|
+
*
|
|
4198
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
4199
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
4200
|
+
*/
|
|
4201
|
+
ensureRowIsVisible(e) {
|
|
4202
|
+
const t = this.firstVisibleRowIndex, s = this.firstVisibleRowIndex + this.displayedRowCount - 1;
|
|
4203
|
+
return e < t ? (this.scrollToIndex(0, e), !0) : e > s ? (this.scrollToIndex(0, e - this.displayedRowCount + 1), !0) : !1;
|
|
4204
|
+
}
|
|
4205
|
+
getFirstVisibleRowIndex() {
|
|
4206
|
+
return this.firstVisibleRowIndex;
|
|
4207
|
+
}
|
|
3704
4208
|
}
|
|
3705
4209
|
const J = class J {
|
|
3706
4210
|
};
|
|
@@ -3980,12 +4484,12 @@ const q = class q {
|
|
|
3980
4484
|
};
|
|
3981
4485
|
q.toggleHeaderGroup = "toggleHeaderGroup";
|
|
3982
4486
|
let ye = q;
|
|
3983
|
-
var
|
|
3984
|
-
const
|
|
4487
|
+
var Mt = /* @__PURE__ */ Ke("<div>");
|
|
4488
|
+
const Ft = (l) => {
|
|
3985
4489
|
let e;
|
|
3986
|
-
const t =
|
|
4490
|
+
const t = Ee({
|
|
3987
4491
|
tableModel: null,
|
|
3988
|
-
tableOptions: new
|
|
4492
|
+
tableOptions: new Fe()
|
|
3989
4493
|
}, l);
|
|
3990
4494
|
return We(() => {
|
|
3991
4495
|
const s = {
|
|
@@ -4058,14 +4562,14 @@ const kt = (l) => {
|
|
|
4058
4562
|
detail: o.getApi(),
|
|
4059
4563
|
bubbles: !0
|
|
4060
4564
|
});
|
|
4061
|
-
e && e.dispatchEvent(i), t.licenseKey &&
|
|
4565
|
+
e && e.dispatchEvent(i), t.licenseKey && P.getInstance().setLicenseKey(t.licenseKey);
|
|
4062
4566
|
}), (() => {
|
|
4063
|
-
var s =
|
|
4567
|
+
var s = Mt(), o = e;
|
|
4064
4568
|
return typeof o == "function" ? Ye(o, s) : e = s, s;
|
|
4065
4569
|
})();
|
|
4066
4570
|
};
|
|
4067
4571
|
export {
|
|
4068
4572
|
Tt as ComponentRendererWrapper,
|
|
4069
|
-
|
|
4573
|
+
Ft as GuiexpertTable,
|
|
4070
4574
|
Dt as GuiexpertTableProps
|
|
4071
4575
|
};
|