@guiexpert/svelte-table 4.1.74 → 4.1.76
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 +5 -5
- package/index.js +588 -85
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var j = (n, e, t) =>
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var xe = (n, e, t) => e in n ? we(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var j = (n, e, t) => xe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { createEventDispatcher as Ce, onMount as ve } from "svelte";
|
|
5
5
|
function B() {
|
|
6
6
|
}
|
|
@@ -22,13 +22,13 @@ function Ae(n, e) {
|
|
|
22
22
|
function Ee(n) {
|
|
23
23
|
return Object.keys(n).length === 0;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Re(n, e, t) {
|
|
26
26
|
n.insertBefore(e, t || null);
|
|
27
27
|
}
|
|
28
28
|
function ge(n) {
|
|
29
29
|
n.parentNode && n.parentNode.removeChild(n);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function Me(n) {
|
|
32
32
|
return document.createElement(n);
|
|
33
33
|
}
|
|
34
34
|
function Te(n, e, t) {
|
|
@@ -37,11 +37,11 @@ function Te(n, e, t) {
|
|
|
37
37
|
function De(n) {
|
|
38
38
|
return Array.from(n.childNodes);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function _(n, e, t, s) {
|
|
41
41
|
t == null ? n.style.removeProperty(e) : n.style.setProperty(e, t, "");
|
|
42
42
|
}
|
|
43
43
|
let Z;
|
|
44
|
-
function
|
|
44
|
+
function $(n) {
|
|
45
45
|
Z = n;
|
|
46
46
|
}
|
|
47
47
|
const O = [], K = [];
|
|
@@ -55,21 +55,21 @@ function J(n) {
|
|
|
55
55
|
P.push(n);
|
|
56
56
|
}
|
|
57
57
|
const X = /* @__PURE__ */ new Set();
|
|
58
|
-
let
|
|
58
|
+
let I = 0;
|
|
59
59
|
function fe() {
|
|
60
|
-
if (
|
|
60
|
+
if (I !== 0)
|
|
61
61
|
return;
|
|
62
62
|
const n = Z;
|
|
63
63
|
do {
|
|
64
64
|
try {
|
|
65
|
-
for (;
|
|
66
|
-
const e = O[
|
|
67
|
-
|
|
65
|
+
for (; I < O.length; ) {
|
|
66
|
+
const e = O[I];
|
|
67
|
+
I++, $(e), Ie(e.$$);
|
|
68
68
|
}
|
|
69
69
|
} catch (e) {
|
|
70
|
-
throw O.length = 0,
|
|
70
|
+
throw O.length = 0, I = 0, e;
|
|
71
71
|
}
|
|
72
|
-
for (
|
|
72
|
+
for ($(null), O.length = 0, I = 0; K.length; ) K.pop()();
|
|
73
73
|
for (let e = 0; e < P.length; e += 1) {
|
|
74
74
|
const t = P[e];
|
|
75
75
|
X.has(t) || (X.add(t), t());
|
|
@@ -78,7 +78,7 @@ function fe() {
|
|
|
78
78
|
} while (O.length);
|
|
79
79
|
for (; ae.length; )
|
|
80
80
|
ae.pop()();
|
|
81
|
-
Y = !1, X.clear(),
|
|
81
|
+
Y = !1, X.clear(), $(n);
|
|
82
82
|
}
|
|
83
83
|
function Ie(n) {
|
|
84
84
|
if (n.fragment !== null) {
|
|
@@ -102,16 +102,16 @@ function Pe(n, e, t) {
|
|
|
102
102
|
n.$$.on_destroy ? n.$$.on_destroy.push(...i) : z(i), n.$$.on_mount = [];
|
|
103
103
|
}), o.forEach(J);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function _e(n, e) {
|
|
106
106
|
const t = n.$$;
|
|
107
107
|
t.fragment !== null && (Oe(t.after_update), z(t.on_destroy), t.fragment && t.fragment.d(e), t.on_destroy = t.fragment = null, t.ctx = []);
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function $e(n, e) {
|
|
110
110
|
n.$$.dirty[0] === -1 && (O.push(n), Fe(), n.$$.dirty.fill(0)), n.$$.dirty[e / 31 | 0] |= 1 << e % 31;
|
|
111
111
|
}
|
|
112
112
|
function We(n, e, t, s, o, i, r = null, a = [-1]) {
|
|
113
113
|
const l = Z;
|
|
114
|
-
|
|
114
|
+
$(n);
|
|
115
115
|
const c = n.$$ = {
|
|
116
116
|
fragment: null,
|
|
117
117
|
ctx: [],
|
|
@@ -137,7 +137,7 @@ function We(n, e, t, s, o, i, r = null, a = [-1]) {
|
|
|
137
137
|
let h = !1;
|
|
138
138
|
if (c.ctx = t ? t(n, e.props || {}, (d, p, ...u) => {
|
|
139
139
|
const g = u.length ? u[0] : p;
|
|
140
|
-
return c.ctx && o(c.ctx[d], c.ctx[d] = g) && (!c.skip_bound && c.bound[d] && c.bound[d](g), h &&
|
|
140
|
+
return c.ctx && o(c.ctx[d], c.ctx[d] = g) && (!c.skip_bound && c.bound[d] && c.bound[d](g), h && $e(n, d)), p;
|
|
141
141
|
}) : [], c.update(), h = !0, z(c.before_update), c.fragment = s ? s(c.ctx) : !1, e.target) {
|
|
142
142
|
if (e.hydrate) {
|
|
143
143
|
const d = De(e.target);
|
|
@@ -146,7 +146,7 @@ function We(n, e, t, s, o, i, r = null, a = [-1]) {
|
|
|
146
146
|
c.fragment && c.fragment.c();
|
|
147
147
|
e.intro && Be(n.$$.fragment), Pe(n, e.target, e.anchor), fe();
|
|
148
148
|
}
|
|
149
|
-
|
|
149
|
+
$(l);
|
|
150
150
|
}
|
|
151
151
|
class He {
|
|
152
152
|
constructor() {
|
|
@@ -169,7 +169,7 @@ class He {
|
|
|
169
169
|
}
|
|
170
170
|
/** @returns {void} */
|
|
171
171
|
$destroy() {
|
|
172
|
-
|
|
172
|
+
_e(this, 1), this.$destroy = B;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* @template {Extract<keyof Events, string>} K
|
|
@@ -204,14 +204,14 @@ function Ne(n, e = 500) {
|
|
|
204
204
|
}, e);
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
class
|
|
207
|
+
class F {
|
|
208
208
|
// The constructor is private to prevent direct construction calls
|
|
209
209
|
// with the `new` operator
|
|
210
210
|
constructor() {
|
|
211
211
|
this.alreadySet = !1;
|
|
212
212
|
}
|
|
213
213
|
static getInstance() {
|
|
214
|
-
return
|
|
214
|
+
return F.instance || (F.instance = new F()), F.instance;
|
|
215
215
|
}
|
|
216
216
|
/**
|
|
217
217
|
* Method to set the license key for the application.
|
|
@@ -674,6 +674,8 @@ class je {
|
|
|
674
674
|
doSort(e) {
|
|
675
675
|
return !1;
|
|
676
676
|
}
|
|
677
|
+
sort(e) {
|
|
678
|
+
}
|
|
677
679
|
isEditable(e, t) {
|
|
678
680
|
var o, i;
|
|
679
681
|
const s = (o = this.columnDefs) == null ? void 0 : o[t];
|
|
@@ -729,9 +731,15 @@ class Xe {
|
|
|
729
731
|
return s * ("" + e).localeCompare("" + t);
|
|
730
732
|
}
|
|
731
733
|
}
|
|
732
|
-
class
|
|
734
|
+
class k extends je {
|
|
733
735
|
constructor(e, t, s, o = [], i = "ge-selected-row", r = "ge-focused-row") {
|
|
734
|
-
super(e, o, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = o, this.selectedRowClass = i, this.focusedRowClass = r, this.
|
|
736
|
+
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 Xe(), this._focusedRowIndex = 0, this.filteredRows = [...t], this.properties = o.map((a) => a.property);
|
|
737
|
+
}
|
|
738
|
+
getFocusedRowIndex() {
|
|
739
|
+
return this._focusedRowIndex;
|
|
740
|
+
}
|
|
741
|
+
setFocusedRowIndex(e) {
|
|
742
|
+
this._focusedRowIndex = e;
|
|
735
743
|
}
|
|
736
744
|
setRows(e) {
|
|
737
745
|
this.rows = e, this.filteredRows = [...e];
|
|
@@ -763,6 +771,28 @@ class I extends je {
|
|
|
763
771
|
getAllRows() {
|
|
764
772
|
return this.rows;
|
|
765
773
|
}
|
|
774
|
+
/**
|
|
775
|
+
* Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
|
|
776
|
+
*
|
|
777
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
778
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
779
|
+
* and returns true if the row matches the criteria
|
|
780
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found
|
|
781
|
+
*/
|
|
782
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
783
|
+
return this.getFilteredRows().find((s) => t(e, s));
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Searches through all rows to find a row that matches the given criteria based on the predicate function.
|
|
787
|
+
*
|
|
788
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
789
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
790
|
+
* and returns true if the row matches the criteria
|
|
791
|
+
* @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
|
|
792
|
+
*/
|
|
793
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
794
|
+
return this.getAllRows().find((s) => t(e, s));
|
|
795
|
+
}
|
|
766
796
|
getRowHeight(e) {
|
|
767
797
|
return this.defaultRowHeight;
|
|
768
798
|
}
|
|
@@ -779,6 +809,9 @@ class I extends je {
|
|
|
779
809
|
}
|
|
780
810
|
return !0;
|
|
781
811
|
}
|
|
812
|
+
sort(e) {
|
|
813
|
+
this.filteredRows = this.filteredRows.sort(e);
|
|
814
|
+
}
|
|
782
815
|
getValueByT(e, t) {
|
|
783
816
|
if (e && t)
|
|
784
817
|
return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
|
|
@@ -788,7 +821,7 @@ class I extends je {
|
|
|
788
821
|
}
|
|
789
822
|
getCustomClassesAt(e, t) {
|
|
790
823
|
const s = super.getCustomClassesAt(e, t);
|
|
791
|
-
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this.
|
|
824
|
+
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this._focusedRowIndex === e && s.push(this.focusedRowClass), s;
|
|
792
825
|
}
|
|
793
826
|
genericFlatTableSortComparator(e, t) {
|
|
794
827
|
const s = this.columnDefs.find((o) => o.property === e);
|
|
@@ -1016,58 +1049,314 @@ class Ke {
|
|
|
1016
1049
|
getSelectionModel() {
|
|
1017
1050
|
return this.tableScope.selectionModel();
|
|
1018
1051
|
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Automatically resizes all columns to fit their content.
|
|
1054
|
+
*
|
|
1055
|
+
* @param {boolean} recalcWrappers - Determines whether to recalculate wrapper dimensions after resizing columns.
|
|
1056
|
+
* Default value is true.
|
|
1057
|
+
*
|
|
1058
|
+
* @return {void} - This method doesn't return anything.
|
|
1059
|
+
*/
|
|
1019
1060
|
autoResizeColumns(e = !0) {
|
|
1020
1061
|
this.tableScope.autoResizeColumns(e);
|
|
1021
1062
|
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Recalculates the dimensions of all wrapper elements in the table.
|
|
1065
|
+
*
|
|
1066
|
+
* This method is typically called after changes to the table structure or content
|
|
1067
|
+
* that might affect the layout, such as resizing columns or changing row heights.
|
|
1068
|
+
* It ensures that all wrapper elements are properly sized to match their content.
|
|
1069
|
+
*
|
|
1070
|
+
* @return {void} - This method doesn't return anything.
|
|
1071
|
+
*/
|
|
1022
1072
|
recalcWrappers() {
|
|
1023
1073
|
this.tableScope.recalcWrappers();
|
|
1024
1074
|
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Sets the width of a specific column in the table.
|
|
1077
|
+
*
|
|
1078
|
+
* @param {number} columnIndex - The index of the column to resize.
|
|
1079
|
+
* @param {number} width - The new width to set for the column, in pixels.
|
|
1080
|
+
*
|
|
1081
|
+
* @return {void} - This method doesn't return anything.
|
|
1082
|
+
*/
|
|
1025
1083
|
setColumnWidth(e, t) {
|
|
1026
1084
|
this.tableScope.setColumnWidth(e, t);
|
|
1027
1085
|
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Retrieves the table model that contains all data and structure information for the table.
|
|
1088
|
+
*
|
|
1089
|
+
* @return {TableModelIf} The table model interface that provides access to the table's data structure,
|
|
1090
|
+
* including header, body, and footer area models.
|
|
1091
|
+
*/
|
|
1028
1092
|
getTableModel() {
|
|
1029
1093
|
return this.tableScope.tableModel;
|
|
1030
1094
|
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Retrieves the area model for the body section of the table.
|
|
1097
|
+
*
|
|
1098
|
+
* @return {AreaModelIf} The area model interface that provides access to the table's body data,
|
|
1099
|
+
* including rows, cells, and their values.
|
|
1100
|
+
*/
|
|
1031
1101
|
getBodyModel() {
|
|
1032
1102
|
return this.tableScope.tableModel.getBodyModel();
|
|
1033
1103
|
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Sets the rows data for the table body, replacing any existing rows.
|
|
1106
|
+
*
|
|
1107
|
+
* @template T - The type of elements in the rows array
|
|
1108
|
+
* @param {T[]} rows - An array of data objects to set as the table's rows
|
|
1109
|
+
*
|
|
1110
|
+
* @description
|
|
1111
|
+
* This method replaces all existing rows in the table body with the provided array of data objects.
|
|
1112
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1113
|
+
*
|
|
1114
|
+
* @return {void} - This method doesn't return anything.
|
|
1115
|
+
*
|
|
1116
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1117
|
+
*/
|
|
1034
1118
|
setRows(e) {
|
|
1035
1119
|
const t = this.getBodyModel();
|
|
1036
|
-
t instanceof
|
|
1120
|
+
t instanceof k ? t.setRows(e) : console.warn("setRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
1037
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Adds new rows to the end of the table body.
|
|
1124
|
+
*
|
|
1125
|
+
* @template T - The type of elements in the rows array
|
|
1126
|
+
* @param {T[]} rows - An array of data objects to append to the table's existing rows
|
|
1127
|
+
*
|
|
1128
|
+
* @description
|
|
1129
|
+
* This method appends the provided array of data objects to the end of the existing rows in the table body.
|
|
1130
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1131
|
+
*
|
|
1132
|
+
* @return {void} - This method doesn't return anything.
|
|
1133
|
+
*
|
|
1134
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1135
|
+
*/
|
|
1038
1136
|
addRows(e) {
|
|
1039
1137
|
const t = this.getBodyModel();
|
|
1040
|
-
if (t instanceof
|
|
1138
|
+
if (t instanceof k) {
|
|
1041
1139
|
const s = t;
|
|
1042
1140
|
let o = s.getAllRows();
|
|
1043
1141
|
s.setRows([...o, ...e]);
|
|
1044
1142
|
} else
|
|
1045
1143
|
console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
1046
1144
|
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Inserts new rows at a specific position in the table body.
|
|
1147
|
+
*
|
|
1148
|
+
* @template T - The type of elements in the rows array
|
|
1149
|
+
* @param {T[]} rows - An array of data objects to insert into the table
|
|
1150
|
+
* @param {number} rowIndex - The index position where the new rows should be inserted
|
|
1151
|
+
*
|
|
1152
|
+
* @description
|
|
1153
|
+
* This method inserts the provided array of data objects at the specified index position in the table body.
|
|
1154
|
+
* Existing rows at or after the specified index will be shifted down.
|
|
1155
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1156
|
+
*
|
|
1157
|
+
* @return {void} - This method doesn't return anything.
|
|
1158
|
+
*
|
|
1159
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1160
|
+
*/
|
|
1047
1161
|
addRowsAt(e, t) {
|
|
1048
1162
|
const s = this.getBodyModel();
|
|
1049
|
-
if (s instanceof
|
|
1163
|
+
if (s instanceof k) {
|
|
1050
1164
|
const o = s;
|
|
1051
1165
|
let i = o.getAllRows();
|
|
1052
1166
|
o.setRows([...i.slice(0, t), ...e, ...i.slice(t)]);
|
|
1053
1167
|
} else
|
|
1054
1168
|
console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1055
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Removes specified rows from the table body.
|
|
1172
|
+
*
|
|
1173
|
+
* @template T - The type of elements in the rows array
|
|
1174
|
+
* @param {T[]} rows - An array of data objects to remove from the table
|
|
1175
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1176
|
+
* - Default predicate uses strict equality (===)
|
|
1177
|
+
* - The function should return true if the rows are considered a match
|
|
1178
|
+
*
|
|
1179
|
+
* @description
|
|
1180
|
+
* This method removes rows from the table body that match any of the provided rows based on the predicate function.
|
|
1181
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1182
|
+
*
|
|
1183
|
+
* @return {void} - This method doesn't return anything.
|
|
1184
|
+
*
|
|
1185
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1186
|
+
*/
|
|
1056
1187
|
removeRows(e, t = (s, o) => s === o) {
|
|
1057
1188
|
const s = this.getBodyModel();
|
|
1058
|
-
if (s instanceof
|
|
1189
|
+
if (s instanceof k) {
|
|
1059
1190
|
const o = s, i = o.getAllRows().filter((r) => !e.some((a) => t(r, a)));
|
|
1060
1191
|
o.setRows(i);
|
|
1061
1192
|
} else
|
|
1062
1193
|
console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1063
1194
|
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Searches for and returns rows from the table body that match the given criteria.
|
|
1197
|
+
*
|
|
1198
|
+
* @template T - The type of elements in the rows array
|
|
1199
|
+
*
|
|
1200
|
+
* @description
|
|
1201
|
+
* This method searches through the table body model for rows that match the provided criteria.
|
|
1202
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1203
|
+
* The method uses a predicate function to determine matches between rows.
|
|
1204
|
+
*
|
|
1205
|
+
* @param {T[]} rows - An array of rows to search for in the table body
|
|
1206
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1207
|
+
* - Default predicate uses strict equality (===)
|
|
1208
|
+
* - The function should return true if the rows are considered a match
|
|
1209
|
+
* - Parameters:
|
|
1210
|
+
* - a: The row from the table body being checked
|
|
1211
|
+
* - b: The row from the input array being searched for
|
|
1212
|
+
*
|
|
1213
|
+
* @returns {T[]} An array containing all matching rows found in the table body
|
|
1214
|
+
* - Returns an empty array if:
|
|
1215
|
+
* - The body model is not an instance of AreaModelObjectArray
|
|
1216
|
+
* - No matches are found
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* // Find rows with simple equality comparison
|
|
1220
|
+
* const matchingRows = table.findRows([row1, row2]);
|
|
1221
|
+
*
|
|
1222
|
+
* @example
|
|
1223
|
+
* // Find rows with custom comparison logic
|
|
1224
|
+
* const matchingRows = table.findRows([row1, row2], (a, b) => a.id === b.id);
|
|
1225
|
+
*
|
|
1226
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1227
|
+
*/
|
|
1064
1228
|
findRows(e, t = (s, o) => s === o) {
|
|
1065
1229
|
const s = this.getBodyModel();
|
|
1066
|
-
return s instanceof
|
|
1230
|
+
return s instanceof k ? 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), []);
|
|
1067
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Searches through the filtered rows of the table to find a row that matches specific criteria.
|
|
1234
|
+
* This method only works with tables that use AreaModelObjectArray as their body model.
|
|
1235
|
+
*
|
|
1236
|
+
* @template T - The type of the row objects in the table
|
|
1237
|
+
*
|
|
1238
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1239
|
+
* Only needs to include the properties you want to match against.
|
|
1240
|
+
*
|
|
1241
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1242
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1243
|
+
*
|
|
1244
|
+
* @returns {T | undefined} The first matching row from the filtered rows, or undefined if no match is found
|
|
1245
|
+
* or if the body model is not an instance of AreaModelObjectArray.
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* ```typescript
|
|
1249
|
+
* interface Person {
|
|
1250
|
+
* id: number;
|
|
1251
|
+
* name: string;
|
|
1252
|
+
* age: number;
|
|
1253
|
+
* }
|
|
1254
|
+
*
|
|
1255
|
+
* // Find a person by exact match
|
|
1256
|
+
* const criteria = { name: "John", age: 30 };
|
|
1257
|
+
* const person = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1258
|
+
* criteria,
|
|
1259
|
+
* (criteria, row) => row.name === criteria.name && row.age === criteria.age
|
|
1260
|
+
* );
|
|
1261
|
+
*
|
|
1262
|
+
* // Find a person by partial name match
|
|
1263
|
+
* const searchCriteria = { name: "Jo" };
|
|
1264
|
+
* const person2 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1265
|
+
* searchCriteria,
|
|
1266
|
+
* (criteria, row) => row.name.toLowerCase().includes(criteria.name!.toLowerCase())
|
|
1267
|
+
* );
|
|
1268
|
+
*
|
|
1269
|
+
* // Find a person within age range
|
|
1270
|
+
* const ageCriteria = { minAge: 25, maxAge: 35 };
|
|
1271
|
+
* const person3 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1272
|
+
* ageCriteria,
|
|
1273
|
+
* (criteria, row) => row.age >= criteria.minAge! && row.age <= criteria.maxAge!
|
|
1274
|
+
* );
|
|
1275
|
+
* ```
|
|
1276
|
+
*
|
|
1277
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1278
|
+
*
|
|
1279
|
+
* @remarks
|
|
1280
|
+
* - This method only searches through filtered rows (rows that are currently visible in the table)
|
|
1281
|
+
* - If you need to search through all rows (including filtered out ones), use findRowFromAllRowsByAllCriteria instead
|
|
1282
|
+
* - The predicate function gives you full control over how to match rows against your criteria
|
|
1283
|
+
* - Returns undefined if either no match is found or if the table's body model is not compatible
|
|
1284
|
+
*/
|
|
1285
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
1286
|
+
const s = this.getBodyModel();
|
|
1287
|
+
if (s instanceof k)
|
|
1288
|
+
return s.getFilteredRows().find((i) => t(e, i));
|
|
1289
|
+
console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Searches through all rows in the table's body model to find a row that matches specified criteria.
|
|
1293
|
+
* This method works only with AreaModelObjectArray<T> body models.
|
|
1294
|
+
*
|
|
1295
|
+
* @template T - The type of objects/rows in the table
|
|
1296
|
+
*
|
|
1297
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1298
|
+
* Only needs to include the properties you want to match against.
|
|
1299
|
+
*
|
|
1300
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1301
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1302
|
+
*
|
|
1303
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found or if the body model is not AreaModelObjectArray.
|
|
1304
|
+
*
|
|
1305
|
+
* @example
|
|
1306
|
+
* // Find a user row by id and name
|
|
1307
|
+
* const criteria = { id: 1, name: "John" };
|
|
1308
|
+
* const user = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1309
|
+
* (criteria, row) => row.id === criteria.id && row.name === criteria.name
|
|
1310
|
+
* );
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
* // Find a product row with partial match on name
|
|
1314
|
+
* const criteria = { name: "Phone" };
|
|
1315
|
+
* const product = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1316
|
+
* (criteria, row) => row.name.includes(criteria.name)
|
|
1317
|
+
* );
|
|
1318
|
+
*
|
|
1319
|
+
* @example
|
|
1320
|
+
* // Find an order with complex matching logic
|
|
1321
|
+
* const criteria = { total: 100, status: "pending" };
|
|
1322
|
+
* const order = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1323
|
+
* (criteria, row) => {
|
|
1324
|
+
* return row.total > criteria.total &&
|
|
1325
|
+
* row.status === criteria.status &&
|
|
1326
|
+
* row.items.length > 0;
|
|
1327
|
+
* }
|
|
1328
|
+
* );
|
|
1329
|
+
*
|
|
1330
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1331
|
+
*/
|
|
1332
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
1333
|
+
const s = this.getBodyModel();
|
|
1334
|
+
if (s instanceof k)
|
|
1335
|
+
return s.getAllRows().find((i) => t(e, i));
|
|
1336
|
+
console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Updates existing rows in the table body with new data.
|
|
1340
|
+
*
|
|
1341
|
+
* @template T - The type of elements in the rows array
|
|
1342
|
+
* @param {T[]} rows - An array of data objects containing the updated values
|
|
1343
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines which rows to update
|
|
1344
|
+
* - Default predicate uses strict equality (===)
|
|
1345
|
+
* - The function should return true if the row should be updated
|
|
1346
|
+
*
|
|
1347
|
+
* @description
|
|
1348
|
+
* This method updates existing rows in the table body with new values from the provided rows array.
|
|
1349
|
+
* For each row in the table, if the predicate returns true when compared with any row in the provided array,
|
|
1350
|
+
* all properties from the provided row will be copied to the existing row.
|
|
1351
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1352
|
+
*
|
|
1353
|
+
* @return {void} - This method doesn't return anything.
|
|
1354
|
+
*
|
|
1355
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1356
|
+
*/
|
|
1068
1357
|
updateRows(e, t = (s, o) => s === o) {
|
|
1069
1358
|
const s = this.getBodyModel();
|
|
1070
|
-
if (s instanceof
|
|
1359
|
+
if (s instanceof k) {
|
|
1071
1360
|
let i = s.getAllRows();
|
|
1072
1361
|
for (const r of i)
|
|
1073
1362
|
for (const a of e)
|
|
@@ -1077,12 +1366,165 @@ class Ke {
|
|
|
1077
1366
|
} else
|
|
1078
1367
|
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);
|
|
1079
1368
|
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Re-applies the current sorting configuration to the table data.
|
|
1371
|
+
*
|
|
1372
|
+
* @description
|
|
1373
|
+
* This method triggers a re-sort of the table data using the current sorting configuration.
|
|
1374
|
+
* It's useful when the underlying data has changed and needs to be re-sorted without changing
|
|
1375
|
+
* the sort columns or direction.
|
|
1376
|
+
*
|
|
1377
|
+
* @return {void} - This method doesn't return anything.
|
|
1378
|
+
*/
|
|
1080
1379
|
reSort() {
|
|
1081
1380
|
this.tableScope.reSort();
|
|
1082
1381
|
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Sorts the table data using a custom comparison function.
|
|
1384
|
+
*
|
|
1385
|
+
* This method allows sorting of table rows by providing a custom comparison function. The comparison function
|
|
1386
|
+
* should follow the standard JavaScript array sort comparator pattern, returning:
|
|
1387
|
+
* - A negative number if the first element should be sorted before the second
|
|
1388
|
+
* - A positive number if the first element should be sorted after the second
|
|
1389
|
+
* - Zero if the elements are equal
|
|
1390
|
+
*
|
|
1391
|
+
* @param compareFn - A function that defines the sort order. The function should accept two arguments
|
|
1392
|
+
* and return a number indicating their relative order:
|
|
1393
|
+
* - Negative number: first argument should come before second
|
|
1394
|
+
* - Positive number: second argument should come before first
|
|
1395
|
+
* - Zero: elements are equal
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* // Sort table rows by a specific property in ascending order
|
|
1399
|
+
* table.api.sort((a, b) => {
|
|
1400
|
+
* if (a.name < b.name) return -1;
|
|
1401
|
+
* if (a.name > b.name) return 1;
|
|
1402
|
+
* return 0;
|
|
1403
|
+
* });
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* // Sort numbers in descending order
|
|
1407
|
+
* table.api.sort((a, b) => b.value - a.value);
|
|
1408
|
+
*
|
|
1409
|
+
* @example
|
|
1410
|
+
* // Sort with multiple criteria
|
|
1411
|
+
* table.api.sort((a, b) => {
|
|
1412
|
+
* // First sort by status
|
|
1413
|
+
* const statusCompare = a.status.localeCompare(b.status);
|
|
1414
|
+
* if (statusCompare !== 0) return statusCompare;
|
|
1415
|
+
*
|
|
1416
|
+
* // Then sort by name if status is equal
|
|
1417
|
+
* return a.name.localeCompare(b.name);
|
|
1418
|
+
* });
|
|
1419
|
+
*
|
|
1420
|
+
* @example
|
|
1421
|
+
* // Case-insensitive string sorting
|
|
1422
|
+
* table.api.sort((a, b) =>
|
|
1423
|
+
* a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
1424
|
+
* );
|
|
1425
|
+
*/
|
|
1426
|
+
sort(e) {
|
|
1427
|
+
this.tableScope.sort(e);
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
1431
|
+
* This method checks if the target row is within the currently visible range and
|
|
1432
|
+
* adjusts the scroll position if it's not visible.
|
|
1433
|
+
*
|
|
1434
|
+
* The method performs the following:
|
|
1435
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
1436
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
1437
|
+
* 3. Scrolls to make the row visible if needed
|
|
1438
|
+
*
|
|
1439
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
1440
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
1441
|
+
*
|
|
1442
|
+
* @example
|
|
1443
|
+
* // Ensure row 5 is visible in the viewport
|
|
1444
|
+
* tableApi.ensureRowIsVisible(5);
|
|
1445
|
+
*
|
|
1446
|
+
* @example
|
|
1447
|
+
* // Example usage in a component
|
|
1448
|
+
* class MyTableComponent {
|
|
1449
|
+
* private tableApi: TableApi;
|
|
1450
|
+
*
|
|
1451
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
1452
|
+
* // This will scroll the row into view if it's not visible
|
|
1453
|
+
* const didScroll = this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1454
|
+
*
|
|
1455
|
+
* if (didScroll) {
|
|
1456
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
1457
|
+
* } else {
|
|
1458
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
1459
|
+
* }
|
|
1460
|
+
* }
|
|
1461
|
+
* }
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* // Example with row selection
|
|
1465
|
+
* class TableHandler {
|
|
1466
|
+
* selectAndShowRow(rowIndex: number) {
|
|
1467
|
+
* // First ensure the row is visible
|
|
1468
|
+
* this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1469
|
+
*
|
|
1470
|
+
* // Then perform selection
|
|
1471
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
1472
|
+
* }
|
|
1473
|
+
* }
|
|
1474
|
+
*
|
|
1475
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
1476
|
+
*
|
|
1477
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
1478
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
1479
|
+
*/
|
|
1480
|
+
ensureRowIsVisible(e) {
|
|
1481
|
+
return this.tableScope.ensureRowIsVisible(e);
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Retrieves the number of rows currently displayed in the table.
|
|
1485
|
+
*
|
|
1486
|
+
* @description
|
|
1487
|
+
* This method returns the count of rows that are currently visible in the table after
|
|
1488
|
+
* applying any filtering, pagination, or other visibility constraints.
|
|
1489
|
+
*
|
|
1490
|
+
* @return {number} The number of rows currently displayed in the table.
|
|
1491
|
+
*/
|
|
1083
1492
|
getDisplayedRowCount() {
|
|
1084
1493
|
return this.tableScope.getDisplayedRowCount();
|
|
1085
1494
|
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Returns the index of the first visible row in the table's viewport.
|
|
1497
|
+
*
|
|
1498
|
+
* This method retrieves the first visible row index from the table's scope, which is useful
|
|
1499
|
+
* for virtual scrolling and viewport-related calculations. The index represents the topmost
|
|
1500
|
+
* visible row in the current scroll position of the table.
|
|
1501
|
+
*
|
|
1502
|
+
* This value is maintained internally by the table and updated during scrolling operations.
|
|
1503
|
+
* It's particularly important for:
|
|
1504
|
+
* - Virtual scrolling optimization
|
|
1505
|
+
* - Calculating visible range of rows
|
|
1506
|
+
* - Viewport-related operations
|
|
1507
|
+
* - Scroll position restoration
|
|
1508
|
+
*
|
|
1509
|
+
* @returns {number} The index of the first visible row in the table's viewport.
|
|
1510
|
+
* Returns -1 if no rows are visible or if the table is not yet rendered.
|
|
1511
|
+
*
|
|
1512
|
+
* @example
|
|
1513
|
+
* ```typescript
|
|
1514
|
+
* // Get the first visible row index
|
|
1515
|
+
* const tableApi = new TableApi(tableScope);
|
|
1516
|
+
* const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
|
|
1517
|
+
*
|
|
1518
|
+
* // Use the index for scroll position calculations
|
|
1519
|
+
* if (firstVisibleIndex >= 0) {
|
|
1520
|
+
* // Perform operations with the first visible row
|
|
1521
|
+
* console.log(`First visible row index: ${firstVisibleIndex}`);
|
|
1522
|
+
* }
|
|
1523
|
+
* ```
|
|
1524
|
+
*/
|
|
1525
|
+
getFirstVisibleRowIndex() {
|
|
1526
|
+
return this.tableScope.getFirstVisibleRowIndex();
|
|
1527
|
+
}
|
|
1086
1528
|
}
|
|
1087
1529
|
class te {
|
|
1088
1530
|
constructor(e) {
|
|
@@ -1754,11 +2196,11 @@ class st extends Qe {
|
|
|
1754
2196
|
let p = t;
|
|
1755
2197
|
const u = this.tableModel.getColumnCount(), g = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
|
|
1756
2198
|
for (let m = 0; m < d; m++) {
|
|
1757
|
-
const
|
|
1758
|
-
if (
|
|
2199
|
+
const w = p, x = m === d - 1, v = this.tableModel.getRowHeight(e, m);
|
|
2200
|
+
if (w + v > 0) {
|
|
1759
2201
|
this.firstVisibleRowIndex = m;
|
|
1760
|
-
let y = { left: a, width: l, height: v, top:
|
|
1761
|
-
const
|
|
2202
|
+
let y = { left: a, width: l, height: v, top: w, index: m }, S = this.dom.addRowDiv(o, y, m, e, "center");
|
|
2203
|
+
const M = b;
|
|
1762
2204
|
if (this.adjustColumnsToRowParent({
|
|
1763
2205
|
areaIdent: e,
|
|
1764
2206
|
sideIdent: "center",
|
|
@@ -1766,11 +2208,11 @@ class st extends Qe {
|
|
|
1766
2208
|
geo: y,
|
|
1767
2209
|
parent: S,
|
|
1768
2210
|
rowIndex: m,
|
|
1769
|
-
columnIndexStart:
|
|
2211
|
+
columnIndexStart: M,
|
|
1770
2212
|
columnIndexEnd: u - g - 1,
|
|
1771
2213
|
verticalFixed: !1,
|
|
1772
|
-
lastRowOfModel:
|
|
1773
|
-
}), c.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height: v, top:
|
|
2214
|
+
lastRowOfModel: x
|
|
2215
|
+
}), c.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height: v, top: w, index: m }, S = this.dom.addRowDiv(s, y, m, e, "west"), this.adjustColumnsToRowParent({
|
|
1774
2216
|
areaIdent: e,
|
|
1775
2217
|
sideIdent: "west",
|
|
1776
2218
|
areaModel: h,
|
|
@@ -1778,10 +2220,10 @@ class st extends Qe {
|
|
|
1778
2220
|
parent: S,
|
|
1779
2221
|
rowIndex: m,
|
|
1780
2222
|
columnIndexStart: 0,
|
|
1781
|
-
columnIndexEnd:
|
|
2223
|
+
columnIndexEnd: M - 1,
|
|
1782
2224
|
verticalFixed: !0,
|
|
1783
|
-
lastRowOfModel:
|
|
1784
|
-
})), c.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height: v, top:
|
|
2225
|
+
lastRowOfModel: x
|
|
2226
|
+
})), c.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height: v, top: w, index: m }, S = this.dom.addRowDiv(i, y, m, e, "east"), this.adjustColumnsToRowParent({
|
|
1785
2227
|
areaIdent: e,
|
|
1786
2228
|
sideIdent: "east",
|
|
1787
2229
|
areaModel: h,
|
|
@@ -1791,7 +2233,7 @@ class st extends Qe {
|
|
|
1791
2233
|
columnIndexStart: u - g,
|
|
1792
2234
|
columnIndexEnd: u - 1,
|
|
1793
2235
|
verticalFixed: !0,
|
|
1794
|
-
lastRowOfModel:
|
|
2236
|
+
lastRowOfModel: x
|
|
1795
2237
|
})), e === "header" && this.tree && m === d - 1) {
|
|
1796
2238
|
const E = this.dom.applyStyle(
|
|
1797
2239
|
this.dom.setAttribute(
|
|
@@ -1800,10 +2242,10 @@ class st extends Qe {
|
|
|
1800
2242
|
"toggleExpandCollapseAll"
|
|
1801
2243
|
),
|
|
1802
2244
|
{ cursor: "pointer" }
|
|
1803
|
-
),
|
|
1804
|
-
if (
|
|
1805
|
-
const W = this.dom.domService.createText(
|
|
1806
|
-
this.dom.domService.appendChild(E, W),
|
|
2245
|
+
), R = this.tableOptions.treeOptions.arrowExpandCollapseAll;
|
|
2246
|
+
if (R) {
|
|
2247
|
+
const W = this.dom.domService.createText(R.content);
|
|
2248
|
+
this.dom.domService.appendChild(E, W), R.style && this.dom.applyStyleString(E, R.style);
|
|
1807
2249
|
}
|
|
1808
2250
|
}
|
|
1809
2251
|
}
|
|
@@ -1815,17 +2257,17 @@ class st extends Qe {
|
|
|
1815
2257
|
if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
|
|
1816
2258
|
const m = ((f = this.colAndRowspanModels[e]) == null ? void 0 : f.getRanges()) ?? [];
|
|
1817
2259
|
if (m.length)
|
|
1818
|
-
for (const
|
|
1819
|
-
let
|
|
1820
|
-
if (
|
|
2260
|
+
for (const w of m) {
|
|
2261
|
+
let x = 0, v = o.child, y = "center";
|
|
2262
|
+
if (w.c1 < b)
|
|
1821
2263
|
v = s.child, y = "west";
|
|
1822
|
-
else if (g > 0 &&
|
|
2264
|
+
else if (g > 0 && w.c1 >= u - g)
|
|
1823
2265
|
v = i.child, y = "east";
|
|
1824
2266
|
else {
|
|
1825
2267
|
const S = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1826
|
-
|
|
2268
|
+
x = this.scrollFactorX * S - this.areaBodyWestGeo.width, y = "center";
|
|
1827
2269
|
}
|
|
1828
|
-
this.drawBigCell(
|
|
2270
|
+
this.drawBigCell(w, x, t, h, v, y);
|
|
1829
2271
|
}
|
|
1830
2272
|
}
|
|
1831
2273
|
}
|
|
@@ -1933,21 +2375,21 @@ class st extends Qe {
|
|
|
1933
2375
|
const p = 0, u = !!(e === "body" && t);
|
|
1934
2376
|
let g = d;
|
|
1935
2377
|
for (let f = a; f <= l; f++) {
|
|
1936
|
-
const m = g,
|
|
1937
|
-
if (
|
|
1938
|
-
let
|
|
2378
|
+
const m = g, w = this.tableModel.getColumnWidth(f);
|
|
2379
|
+
if (w > 0 && m + w > 0) {
|
|
2380
|
+
let x = o.height;
|
|
1939
2381
|
const v = s.getRowspanAt(r, f), y = s.getColspanAt(r, f);
|
|
1940
|
-
v > 1 && (
|
|
1941
|
-
let S =
|
|
1942
|
-
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((E,
|
|
1943
|
-
let
|
|
1944
|
-
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (
|
|
1945
|
-
this.renderDragTargetDiv(i, m, p, S,
|
|
1946
|
-
const E = { left: m, top: p, width: S, height:
|
|
2382
|
+
v > 1 && (x = this.getRowHeights(r, r + v - 1, s).reduce((E, R) => E + R, 0));
|
|
2383
|
+
let S = w;
|
|
2384
|
+
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((E, R) => E + R, 0));
|
|
2385
|
+
let M = !1;
|
|
2386
|
+
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (M = !0), this.draggingTargetColumnIndex === f && e !== "header") {
|
|
2387
|
+
this.renderDragTargetDiv(i, m, p, S, x);
|
|
2388
|
+
const E = { left: m, top: p, width: S, height: x };
|
|
1947
2389
|
this.dom.addColumnBorderDivs(this.tableOptions, i, E, e, t);
|
|
1948
2390
|
} else {
|
|
1949
|
-
const E = this.renderSelectedBackgroundDiv(
|
|
1950
|
-
"gammaCells" in s && s.getValueAt(r, f) && (
|
|
2391
|
+
const E = this.renderSelectedBackgroundDiv(M, u, t, s, r, f, i, m, p, S, x);
|
|
2392
|
+
"gammaCells" in s && s.getValueAt(r, f) && (M = !1), M || this.renderCell({
|
|
1951
2393
|
areaModel: s,
|
|
1952
2394
|
areaIdent: e,
|
|
1953
2395
|
sideIdent: t,
|
|
@@ -1956,7 +2398,7 @@ class st extends Qe {
|
|
|
1956
2398
|
left: m,
|
|
1957
2399
|
top: p,
|
|
1958
2400
|
width: S,
|
|
1959
|
-
height:
|
|
2401
|
+
height: x,
|
|
1960
2402
|
parent: i,
|
|
1961
2403
|
cellSelected: E,
|
|
1962
2404
|
lastRowOfModel: h,
|
|
@@ -1967,12 +2409,12 @@ class st extends Qe {
|
|
|
1967
2409
|
cellLeft: m,
|
|
1968
2410
|
cellTop: p,
|
|
1969
2411
|
cellWidth: S,
|
|
1970
|
-
cellHeight:
|
|
2412
|
+
cellHeight: x,
|
|
1971
2413
|
parent: i
|
|
1972
2414
|
});
|
|
1973
2415
|
}
|
|
1974
2416
|
}
|
|
1975
|
-
if (g = g +
|
|
2417
|
+
if (g = g + w, g > this.areaBodyCenterGeo.width)
|
|
1976
2418
|
break;
|
|
1977
2419
|
}
|
|
1978
2420
|
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(g - 1, 1, o.height, 0), i);
|
|
@@ -2009,12 +2451,12 @@ class st extends Qe {
|
|
|
2009
2451
|
const C = b;
|
|
2010
2452
|
(ie = C.children) != null && ie.length ? C.expanded ? f = "expanded" : f = "collapsed" : f = "hidden";
|
|
2011
2453
|
}
|
|
2012
|
-
let
|
|
2454
|
+
let w;
|
|
2013
2455
|
if (t === "header") {
|
|
2014
2456
|
const C = this.tableModel.getColumnDef(i);
|
|
2015
|
-
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (
|
|
2457
|
+
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (w = C == null ? void 0 : C.sortState);
|
|
2016
2458
|
}
|
|
2017
|
-
const
|
|
2459
|
+
const x = e.getValueAt(o, i), v = u ? "" : `${x}`, y = e.isRowChecked(o), S = this.dom.addColumnDiv(
|
|
2018
2460
|
{
|
|
2019
2461
|
parent: h,
|
|
2020
2462
|
geo: g,
|
|
@@ -2026,14 +2468,14 @@ class st extends Qe {
|
|
|
2026
2468
|
treeArrow: f,
|
|
2027
2469
|
tableOptions: this.tableOptions,
|
|
2028
2470
|
checkedType: y,
|
|
2029
|
-
sortState:
|
|
2471
|
+
sortState: w
|
|
2030
2472
|
}
|
|
2031
|
-
),
|
|
2032
|
-
|
|
2473
|
+
), M = e.getTooltipAt(o, i);
|
|
2474
|
+
M && this.dom.setAttribute(S, "title", M);
|
|
2033
2475
|
const E = this.tableModel.getColumnDef(i);
|
|
2034
2476
|
E && E.classes[t] && this.dom.addClasses(E.classes[t], S);
|
|
2035
|
-
let
|
|
2036
|
-
u && (
|
|
2477
|
+
let R;
|
|
2478
|
+
u && (R = u.render(S, o, i, t, e, x, this.dom.domService));
|
|
2037
2479
|
const W = e.getCustomClassesAt(o, i);
|
|
2038
2480
|
if (W.length && this.dom.addClasses(W, S), this.dom.addColumnBorderDivs(this.tableOptions, h, g, t, s), d && this.dom.addHorizontalBorder({ left: r, width: a, height: l, top: c + l }, h), this.getFocusModel && t === "body") {
|
|
2039
2481
|
const C = this.getFocusModel();
|
|
@@ -2044,7 +2486,7 @@ class st extends Qe {
|
|
|
2044
2486
|
if (U)
|
|
2045
2487
|
for (const C in U)
|
|
2046
2488
|
this.dom.setStyle(S, C, U[C]);
|
|
2047
|
-
return [S,
|
|
2489
|
+
return [S, R];
|
|
2048
2490
|
}
|
|
2049
2491
|
/**
|
|
2050
2492
|
* Applies CSS classes to an HTML element.
|
|
@@ -2219,10 +2661,10 @@ class st extends Qe {
|
|
|
2219
2661
|
sideIdent: o,
|
|
2220
2662
|
text: b
|
|
2221
2663
|
}, m = this.dom.addColumnDiv(f);
|
|
2222
|
-
let
|
|
2223
|
-
g && (
|
|
2224
|
-
const
|
|
2225
|
-
|
|
2664
|
+
let w;
|
|
2665
|
+
g && (w = g.render(m, c, a, t, i, u, this.dom.domService), w && this.cleanupFunctions[t].push(w));
|
|
2666
|
+
const x = i.getCustomClassesAt(c, a);
|
|
2667
|
+
x.length && this.dom.addClasses(x, m);
|
|
2226
2668
|
const v = this.tableModel.getColumnDef(a);
|
|
2227
2669
|
v && v.classes[t] && this.dom.addClasses(v.classes[t], m), this.dom.addColumnBorderDivs(this.tableOptions, l, p, t, o);
|
|
2228
2670
|
const y = i.getCustomStyleAt(c, a);
|
|
@@ -3011,7 +3453,7 @@ class bt {
|
|
|
3011
3453
|
class oe extends st {
|
|
3012
3454
|
constructor(e, t, s, o, i, r = new V(), a = new bt()) {
|
|
3013
3455
|
var h;
|
|
3014
|
-
if (super(e, t, new Ge(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager =
|
|
3456
|
+
if (super(e, t, new Ge(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager = F.getInstance(), this.selectionService = new at(this), this.api = new Ke(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 ne()), (h = this.tableOptions) != null && h.autoRestoreOptions) {
|
|
3015
3457
|
const d = this.tableOptions.autoRestoreOptions, p = d.getStorageKeyFn;
|
|
3016
3458
|
p && (d.autoRestoreScrollPosition && (this.storeScrollPosStateService = new Ye(p)), d.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new qe(p)), d.autoRestoreSortingState && (this.storeSortingService = new Ze(p)));
|
|
3017
3459
|
}
|
|
@@ -3433,9 +3875,70 @@ class oe extends st {
|
|
|
3433
3875
|
let e = ((t = this.storeSortingService) == null ? void 0 : t.getSortItems()) ?? [];
|
|
3434
3876
|
this.tableModel.doSort(e);
|
|
3435
3877
|
}
|
|
3878
|
+
sort(e) {
|
|
3879
|
+
this.tableModel.sort(e);
|
|
3880
|
+
}
|
|
3436
3881
|
getDisplayedRowCount() {
|
|
3437
3882
|
return this.displayedRowCount;
|
|
3438
3883
|
}
|
|
3884
|
+
/**
|
|
3885
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
3886
|
+
* This method checks if the target row is within the currently visible range and
|
|
3887
|
+
* adjusts the scroll position if it's not visible.
|
|
3888
|
+
*
|
|
3889
|
+
* The method performs the following:
|
|
3890
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
3891
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
3892
|
+
* 3. Scrolls to make the row visible if needed
|
|
3893
|
+
*
|
|
3894
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
3895
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
3896
|
+
*
|
|
3897
|
+
* @example
|
|
3898
|
+
* // Ensure row 5 is visible in the viewport
|
|
3899
|
+
* tableScope.ensureRowIsVisible(5);
|
|
3900
|
+
*
|
|
3901
|
+
* @example
|
|
3902
|
+
* // Example usage in a component
|
|
3903
|
+
* class MyTableComponent {
|
|
3904
|
+
* private tableScope: TableScope;
|
|
3905
|
+
*
|
|
3906
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
3907
|
+
* // This will scroll the row into view if it's not visible
|
|
3908
|
+
* const didScroll = this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3909
|
+
*
|
|
3910
|
+
* if (didScroll) {
|
|
3911
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
3912
|
+
* } else {
|
|
3913
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
3914
|
+
* }
|
|
3915
|
+
* }
|
|
3916
|
+
* }
|
|
3917
|
+
*
|
|
3918
|
+
* @example
|
|
3919
|
+
* // Example with row selection
|
|
3920
|
+
* class TableHandler {
|
|
3921
|
+
* selectAndShowRow(rowIndex: number) {
|
|
3922
|
+
* // First ensure the row is visible
|
|
3923
|
+
* this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3924
|
+
*
|
|
3925
|
+
* // Then perform selection
|
|
3926
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
3927
|
+
* }
|
|
3928
|
+
* }
|
|
3929
|
+
*
|
|
3930
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
3931
|
+
*
|
|
3932
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
3933
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
3934
|
+
*/
|
|
3935
|
+
ensureRowIsVisible(e) {
|
|
3936
|
+
const t = this.firstVisibleRowIndex, s = this.firstVisibleRowIndex + this.displayedRowCount - 1;
|
|
3937
|
+
return e < t ? (this.scrollToIndex(0, e), !0) : e > s ? (this.scrollToIndex(0, e - this.displayedRowCount + 1), !0) : !1;
|
|
3938
|
+
}
|
|
3939
|
+
getFirstVisibleRowIndex() {
|
|
3940
|
+
return this.firstVisibleRowIndex;
|
|
3941
|
+
}
|
|
3439
3942
|
}
|
|
3440
3943
|
const N = class N {
|
|
3441
3944
|
};
|
|
@@ -3719,10 +4222,10 @@ function St(n) {
|
|
|
3719
4222
|
let e;
|
|
3720
4223
|
return {
|
|
3721
4224
|
c() {
|
|
3722
|
-
e =
|
|
4225
|
+
e = Me("div"), Te(e, "class", "ge-table"), _(e, "width", "100%"), _(e, "height", "100%"), _(e, "background-color", "transparent"), _(e, "padding", "0"), _(e, "margin", "0");
|
|
3723
4226
|
},
|
|
3724
4227
|
m(t, s) {
|
|
3725
|
-
|
|
4228
|
+
Re(t, e, s), n[4](e);
|
|
3726
4229
|
},
|
|
3727
4230
|
p: B,
|
|
3728
4231
|
i: B,
|
|
@@ -3765,7 +4268,7 @@ function yt(n, e, t) {
|
|
|
3765
4268
|
a("mouseMoved", d);
|
|
3766
4269
|
}
|
|
3767
4270
|
}, h = new oe(r, s, new be(), o, c);
|
|
3768
|
-
h.firstInit(), a("tableReady", h.getApi()), i &&
|
|
4271
|
+
h.firstInit(), a("tableReady", h.getApi()), i && F.getInstance().setLicenseKey(i);
|
|
3769
4272
|
});
|
|
3770
4273
|
function l(c) {
|
|
3771
4274
|
K[c ? "unshift" : "push"](() => {
|