@guiexpert/vue3-table 3.1.74 → 3.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 +5 -5
- package/index.js +572 -69
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -7,14 +7,14 @@ function ne(d, e = 500) {
|
|
|
7
7
|
}, e);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
class
|
|
10
|
+
class F {
|
|
11
11
|
// The constructor is private to prevent direct construction calls
|
|
12
12
|
// with the `new` operator
|
|
13
13
|
constructor() {
|
|
14
14
|
this.alreadySet = !1;
|
|
15
15
|
}
|
|
16
16
|
static getInstance() {
|
|
17
|
-
return
|
|
17
|
+
return F.instance || (F.instance = new F()), F.instance;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Method to set the license key for the application.
|
|
@@ -477,6 +477,8 @@ class pe {
|
|
|
477
477
|
doSort(e) {
|
|
478
478
|
return !1;
|
|
479
479
|
}
|
|
480
|
+
sort(e) {
|
|
481
|
+
}
|
|
480
482
|
isEditable(e, t) {
|
|
481
483
|
var o, i;
|
|
482
484
|
const s = (o = this.columnDefs) == null ? void 0 : o[t];
|
|
@@ -532,9 +534,15 @@ class ge {
|
|
|
532
534
|
return s * ("" + e).localeCompare("" + t);
|
|
533
535
|
}
|
|
534
536
|
}
|
|
535
|
-
class
|
|
537
|
+
class k extends pe {
|
|
536
538
|
constructor(e, t, s, o = [], i = "ge-selected-row", r = "ge-focused-row") {
|
|
537
|
-
super(e, o, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = o, this.selectedRowClass = i, this.focusedRowClass = r, this.
|
|
539
|
+
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 ge(), this._focusedRowIndex = 0, this.filteredRows = [...t], this.properties = o.map((a) => a.property);
|
|
540
|
+
}
|
|
541
|
+
get focusedRowIndex() {
|
|
542
|
+
return this._focusedRowIndex;
|
|
543
|
+
}
|
|
544
|
+
set focusedRowIndex(e) {
|
|
545
|
+
this._focusedRowIndex = e;
|
|
538
546
|
}
|
|
539
547
|
setRows(e) {
|
|
540
548
|
this.rows = e, this.filteredRows = [...e];
|
|
@@ -566,6 +574,28 @@ class F extends pe {
|
|
|
566
574
|
getAllRows() {
|
|
567
575
|
return this.rows;
|
|
568
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
|
|
579
|
+
*
|
|
580
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
581
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
582
|
+
* and returns true if the row matches the criteria
|
|
583
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found
|
|
584
|
+
*/
|
|
585
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
586
|
+
return this.getFilteredRows().find((s) => t(e, s));
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Searches through all rows to find a row that matches the given criteria based on the predicate function.
|
|
590
|
+
*
|
|
591
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
592
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
593
|
+
* and returns true if the row matches the criteria
|
|
594
|
+
* @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
|
|
595
|
+
*/
|
|
596
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
597
|
+
return this.getAllRows().find((s) => t(e, s));
|
|
598
|
+
}
|
|
569
599
|
getRowHeight(e) {
|
|
570
600
|
return this.defaultRowHeight;
|
|
571
601
|
}
|
|
@@ -582,6 +612,9 @@ class F extends pe {
|
|
|
582
612
|
}
|
|
583
613
|
return !0;
|
|
584
614
|
}
|
|
615
|
+
sort(e) {
|
|
616
|
+
this.filteredRows = this.filteredRows.sort(e);
|
|
617
|
+
}
|
|
585
618
|
getValueByT(e, t) {
|
|
586
619
|
if (e && t)
|
|
587
620
|
return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
|
|
@@ -591,7 +624,7 @@ class F extends pe {
|
|
|
591
624
|
}
|
|
592
625
|
getCustomClassesAt(e, t) {
|
|
593
626
|
const s = super.getCustomClassesAt(e, t);
|
|
594
|
-
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this.
|
|
627
|
+
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this._focusedRowIndex === e && s.push(this.focusedRowClass), s;
|
|
595
628
|
}
|
|
596
629
|
genericFlatTableSortComparator(e, t) {
|
|
597
630
|
const s = this.columnDefs.find((o) => o.property === e);
|
|
@@ -819,58 +852,314 @@ class fe {
|
|
|
819
852
|
getSelectionModel() {
|
|
820
853
|
return this.tableScope.selectionModel();
|
|
821
854
|
}
|
|
855
|
+
/**
|
|
856
|
+
* Automatically resizes all columns to fit their content.
|
|
857
|
+
*
|
|
858
|
+
* @param {boolean} recalcWrappers - Determines whether to recalculate wrapper dimensions after resizing columns.
|
|
859
|
+
* Default value is true.
|
|
860
|
+
*
|
|
861
|
+
* @return {void} - This method doesn't return anything.
|
|
862
|
+
*/
|
|
822
863
|
autoResizeColumns(e = !0) {
|
|
823
864
|
this.tableScope.autoResizeColumns(e);
|
|
824
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* Recalculates the dimensions of all wrapper elements in the table.
|
|
868
|
+
*
|
|
869
|
+
* This method is typically called after changes to the table structure or content
|
|
870
|
+
* that might affect the layout, such as resizing columns or changing row heights.
|
|
871
|
+
* It ensures that all wrapper elements are properly sized to match their content.
|
|
872
|
+
*
|
|
873
|
+
* @return {void} - This method doesn't return anything.
|
|
874
|
+
*/
|
|
825
875
|
recalcWrappers() {
|
|
826
876
|
this.tableScope.recalcWrappers();
|
|
827
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* Sets the width of a specific column in the table.
|
|
880
|
+
*
|
|
881
|
+
* @param {number} columnIndex - The index of the column to resize.
|
|
882
|
+
* @param {number} width - The new width to set for the column, in pixels.
|
|
883
|
+
*
|
|
884
|
+
* @return {void} - This method doesn't return anything.
|
|
885
|
+
*/
|
|
828
886
|
setColumnWidth(e, t) {
|
|
829
887
|
this.tableScope.setColumnWidth(e, t);
|
|
830
888
|
}
|
|
889
|
+
/**
|
|
890
|
+
* Retrieves the table model that contains all data and structure information for the table.
|
|
891
|
+
*
|
|
892
|
+
* @return {TableModelIf} The table model interface that provides access to the table's data structure,
|
|
893
|
+
* including header, body, and footer area models.
|
|
894
|
+
*/
|
|
831
895
|
getTableModel() {
|
|
832
896
|
return this.tableScope.tableModel;
|
|
833
897
|
}
|
|
898
|
+
/**
|
|
899
|
+
* Retrieves the area model for the body section of the table.
|
|
900
|
+
*
|
|
901
|
+
* @return {AreaModelIf} The area model interface that provides access to the table's body data,
|
|
902
|
+
* including rows, cells, and their values.
|
|
903
|
+
*/
|
|
834
904
|
getBodyModel() {
|
|
835
905
|
return this.tableScope.tableModel.getBodyModel();
|
|
836
906
|
}
|
|
907
|
+
/**
|
|
908
|
+
* Sets the rows data for the table body, replacing any existing rows.
|
|
909
|
+
*
|
|
910
|
+
* @template T - The type of elements in the rows array
|
|
911
|
+
* @param {T[]} rows - An array of data objects to set as the table's rows
|
|
912
|
+
*
|
|
913
|
+
* @description
|
|
914
|
+
* This method replaces all existing rows in the table body with the provided array of data objects.
|
|
915
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
916
|
+
*
|
|
917
|
+
* @return {void} - This method doesn't return anything.
|
|
918
|
+
*
|
|
919
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
920
|
+
*/
|
|
837
921
|
setRows(e) {
|
|
838
922
|
const t = this.getBodyModel();
|
|
839
|
-
t instanceof
|
|
923
|
+
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);
|
|
840
924
|
}
|
|
925
|
+
/**
|
|
926
|
+
* Adds new rows to the end of the table body.
|
|
927
|
+
*
|
|
928
|
+
* @template T - The type of elements in the rows array
|
|
929
|
+
* @param {T[]} rows - An array of data objects to append to the table's existing rows
|
|
930
|
+
*
|
|
931
|
+
* @description
|
|
932
|
+
* This method appends the provided array of data objects to the end of the existing rows in the table body.
|
|
933
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
934
|
+
*
|
|
935
|
+
* @return {void} - This method doesn't return anything.
|
|
936
|
+
*
|
|
937
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
938
|
+
*/
|
|
841
939
|
addRows(e) {
|
|
842
940
|
const t = this.getBodyModel();
|
|
843
|
-
if (t instanceof
|
|
941
|
+
if (t instanceof k) {
|
|
844
942
|
const s = t;
|
|
845
943
|
let o = s.getAllRows();
|
|
846
944
|
s.setRows([...o, ...e]);
|
|
847
945
|
} else
|
|
848
946
|
console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
849
947
|
}
|
|
948
|
+
/**
|
|
949
|
+
* Inserts new rows at a specific position in the table body.
|
|
950
|
+
*
|
|
951
|
+
* @template T - The type of elements in the rows array
|
|
952
|
+
* @param {T[]} rows - An array of data objects to insert into the table
|
|
953
|
+
* @param {number} rowIndex - The index position where the new rows should be inserted
|
|
954
|
+
*
|
|
955
|
+
* @description
|
|
956
|
+
* This method inserts the provided array of data objects at the specified index position in the table body.
|
|
957
|
+
* Existing rows at or after the specified index will be shifted down.
|
|
958
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
959
|
+
*
|
|
960
|
+
* @return {void} - This method doesn't return anything.
|
|
961
|
+
*
|
|
962
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
963
|
+
*/
|
|
850
964
|
addRowsAt(e, t) {
|
|
851
965
|
const s = this.getBodyModel();
|
|
852
|
-
if (s instanceof
|
|
966
|
+
if (s instanceof k) {
|
|
853
967
|
const o = s;
|
|
854
968
|
let i = o.getAllRows();
|
|
855
969
|
o.setRows([...i.slice(0, t), ...e, ...i.slice(t)]);
|
|
856
970
|
} else
|
|
857
971
|
console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
858
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* Removes specified rows from the table body.
|
|
975
|
+
*
|
|
976
|
+
* @template T - The type of elements in the rows array
|
|
977
|
+
* @param {T[]} rows - An array of data objects to remove from the table
|
|
978
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
979
|
+
* - Default predicate uses strict equality (===)
|
|
980
|
+
* - The function should return true if the rows are considered a match
|
|
981
|
+
*
|
|
982
|
+
* @description
|
|
983
|
+
* This method removes rows from the table body that match any of the provided rows based on the predicate function.
|
|
984
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
985
|
+
*
|
|
986
|
+
* @return {void} - This method doesn't return anything.
|
|
987
|
+
*
|
|
988
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
989
|
+
*/
|
|
859
990
|
removeRows(e, t = (s, o) => s === o) {
|
|
860
991
|
const s = this.getBodyModel();
|
|
861
|
-
if (s instanceof
|
|
992
|
+
if (s instanceof k) {
|
|
862
993
|
const o = s, i = o.getAllRows().filter((r) => !e.some((a) => t(r, a)));
|
|
863
994
|
o.setRows(i);
|
|
864
995
|
} else
|
|
865
996
|
console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
866
997
|
}
|
|
998
|
+
/**
|
|
999
|
+
* Searches for and returns rows from the table body that match the given criteria.
|
|
1000
|
+
*
|
|
1001
|
+
* @template T - The type of elements in the rows array
|
|
1002
|
+
*
|
|
1003
|
+
* @description
|
|
1004
|
+
* This method searches through the table body model for rows that match the provided criteria.
|
|
1005
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1006
|
+
* The method uses a predicate function to determine matches between rows.
|
|
1007
|
+
*
|
|
1008
|
+
* @param {T[]} rows - An array of rows to search for in the table body
|
|
1009
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1010
|
+
* - Default predicate uses strict equality (===)
|
|
1011
|
+
* - The function should return true if the rows are considered a match
|
|
1012
|
+
* - Parameters:
|
|
1013
|
+
* - a: The row from the table body being checked
|
|
1014
|
+
* - b: The row from the input array being searched for
|
|
1015
|
+
*
|
|
1016
|
+
* @returns {T[]} An array containing all matching rows found in the table body
|
|
1017
|
+
* - Returns an empty array if:
|
|
1018
|
+
* - The body model is not an instance of AreaModelObjectArray
|
|
1019
|
+
* - No matches are found
|
|
1020
|
+
*
|
|
1021
|
+
* @example
|
|
1022
|
+
* // Find rows with simple equality comparison
|
|
1023
|
+
* const matchingRows = table.findRows([row1, row2]);
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* // Find rows with custom comparison logic
|
|
1027
|
+
* const matchingRows = table.findRows([row1, row2], (a, b) => a.id === b.id);
|
|
1028
|
+
*
|
|
1029
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1030
|
+
*/
|
|
867
1031
|
findRows(e, t = (s, o) => s === o) {
|
|
868
1032
|
const s = this.getBodyModel();
|
|
869
|
-
return s instanceof
|
|
1033
|
+
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), []);
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Searches through the filtered rows of the table to find a row that matches specific criteria.
|
|
1037
|
+
* This method only works with tables that use AreaModelObjectArray as their body model.
|
|
1038
|
+
*
|
|
1039
|
+
* @template T - The type of the row objects in the table
|
|
1040
|
+
*
|
|
1041
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1042
|
+
* Only needs to include the properties you want to match against.
|
|
1043
|
+
*
|
|
1044
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1045
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1046
|
+
*
|
|
1047
|
+
* @returns {T | undefined} The first matching row from the filtered rows, or undefined if no match is found
|
|
1048
|
+
* or if the body model is not an instance of AreaModelObjectArray.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* interface Person {
|
|
1053
|
+
* id: number;
|
|
1054
|
+
* name: string;
|
|
1055
|
+
* age: number;
|
|
1056
|
+
* }
|
|
1057
|
+
*
|
|
1058
|
+
* // Find a person by exact match
|
|
1059
|
+
* const criteria = { name: "John", age: 30 };
|
|
1060
|
+
* const person = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1061
|
+
* criteria,
|
|
1062
|
+
* (criteria, row) => row.name === criteria.name && row.age === criteria.age
|
|
1063
|
+
* );
|
|
1064
|
+
*
|
|
1065
|
+
* // Find a person by partial name match
|
|
1066
|
+
* const searchCriteria = { name: "Jo" };
|
|
1067
|
+
* const person2 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1068
|
+
* searchCriteria,
|
|
1069
|
+
* (criteria, row) => row.name.toLowerCase().includes(criteria.name!.toLowerCase())
|
|
1070
|
+
* );
|
|
1071
|
+
*
|
|
1072
|
+
* // Find a person within age range
|
|
1073
|
+
* const ageCriteria = { minAge: 25, maxAge: 35 };
|
|
1074
|
+
* const person3 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1075
|
+
* ageCriteria,
|
|
1076
|
+
* (criteria, row) => row.age >= criteria.minAge! && row.age <= criteria.maxAge!
|
|
1077
|
+
* );
|
|
1078
|
+
* ```
|
|
1079
|
+
*
|
|
1080
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1081
|
+
*
|
|
1082
|
+
* @remarks
|
|
1083
|
+
* - This method only searches through filtered rows (rows that are currently visible in the table)
|
|
1084
|
+
* - If you need to search through all rows (including filtered out ones), use findRowFromAllRowsByAllCriteria instead
|
|
1085
|
+
* - The predicate function gives you full control over how to match rows against your criteria
|
|
1086
|
+
* - Returns undefined if either no match is found or if the table's body model is not compatible
|
|
1087
|
+
*/
|
|
1088
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
1089
|
+
const s = this.getBodyModel();
|
|
1090
|
+
if (s instanceof k)
|
|
1091
|
+
return s.getFilteredRows().find((i) => t(e, i));
|
|
1092
|
+
console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Searches through all rows in the table's body model to find a row that matches specified criteria.
|
|
1096
|
+
* This method works only with AreaModelObjectArray<T> body models.
|
|
1097
|
+
*
|
|
1098
|
+
* @template T - The type of objects/rows in the table
|
|
1099
|
+
*
|
|
1100
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1101
|
+
* Only needs to include the properties you want to match against.
|
|
1102
|
+
*
|
|
1103
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1104
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1105
|
+
*
|
|
1106
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found or if the body model is not AreaModelObjectArray.
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
* // Find a user row by id and name
|
|
1110
|
+
* const criteria = { id: 1, name: "John" };
|
|
1111
|
+
* const user = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1112
|
+
* (criteria, row) => row.id === criteria.id && row.name === criteria.name
|
|
1113
|
+
* );
|
|
1114
|
+
*
|
|
1115
|
+
* @example
|
|
1116
|
+
* // Find a product row with partial match on name
|
|
1117
|
+
* const criteria = { name: "Phone" };
|
|
1118
|
+
* const product = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1119
|
+
* (criteria, row) => row.name.includes(criteria.name)
|
|
1120
|
+
* );
|
|
1121
|
+
*
|
|
1122
|
+
* @example
|
|
1123
|
+
* // Find an order with complex matching logic
|
|
1124
|
+
* const criteria = { total: 100, status: "pending" };
|
|
1125
|
+
* const order = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1126
|
+
* (criteria, row) => {
|
|
1127
|
+
* return row.total > criteria.total &&
|
|
1128
|
+
* row.status === criteria.status &&
|
|
1129
|
+
* row.items.length > 0;
|
|
1130
|
+
* }
|
|
1131
|
+
* );
|
|
1132
|
+
*
|
|
1133
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1134
|
+
*/
|
|
1135
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
1136
|
+
const s = this.getBodyModel();
|
|
1137
|
+
if (s instanceof k)
|
|
1138
|
+
return s.getAllRows().find((i) => t(e, i));
|
|
1139
|
+
console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
870
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Updates existing rows in the table body with new data.
|
|
1143
|
+
*
|
|
1144
|
+
* @template T - The type of elements in the rows array
|
|
1145
|
+
* @param {T[]} rows - An array of data objects containing the updated values
|
|
1146
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines which rows to update
|
|
1147
|
+
* - Default predicate uses strict equality (===)
|
|
1148
|
+
* - The function should return true if the row should be updated
|
|
1149
|
+
*
|
|
1150
|
+
* @description
|
|
1151
|
+
* This method updates existing rows in the table body with new values from the provided rows array.
|
|
1152
|
+
* For each row in the table, if the predicate returns true when compared with any row in the provided array,
|
|
1153
|
+
* all properties from the provided row will be copied to the existing row.
|
|
1154
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1155
|
+
*
|
|
1156
|
+
* @return {void} - This method doesn't return anything.
|
|
1157
|
+
*
|
|
1158
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1159
|
+
*/
|
|
871
1160
|
updateRows(e, t = (s, o) => s === o) {
|
|
872
1161
|
const s = this.getBodyModel();
|
|
873
|
-
if (s instanceof
|
|
1162
|
+
if (s instanceof k) {
|
|
874
1163
|
let i = s.getAllRows();
|
|
875
1164
|
for (const r of i)
|
|
876
1165
|
for (const a of e)
|
|
@@ -880,12 +1169,165 @@ class fe {
|
|
|
880
1169
|
} else
|
|
881
1170
|
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);
|
|
882
1171
|
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Re-applies the current sorting configuration to the table data.
|
|
1174
|
+
*
|
|
1175
|
+
* @description
|
|
1176
|
+
* This method triggers a re-sort of the table data using the current sorting configuration.
|
|
1177
|
+
* It's useful when the underlying data has changed and needs to be re-sorted without changing
|
|
1178
|
+
* the sort columns or direction.
|
|
1179
|
+
*
|
|
1180
|
+
* @return {void} - This method doesn't return anything.
|
|
1181
|
+
*/
|
|
883
1182
|
reSort() {
|
|
884
1183
|
this.tableScope.reSort();
|
|
885
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Sorts the table data using a custom comparison function.
|
|
1187
|
+
*
|
|
1188
|
+
* This method allows sorting of table rows by providing a custom comparison function. The comparison function
|
|
1189
|
+
* should follow the standard JavaScript array sort comparator pattern, returning:
|
|
1190
|
+
* - A negative number if the first element should be sorted before the second
|
|
1191
|
+
* - A positive number if the first element should be sorted after the second
|
|
1192
|
+
* - Zero if the elements are equal
|
|
1193
|
+
*
|
|
1194
|
+
* @param compareFn - A function that defines the sort order. The function should accept two arguments
|
|
1195
|
+
* and return a number indicating their relative order:
|
|
1196
|
+
* - Negative number: first argument should come before second
|
|
1197
|
+
* - Positive number: second argument should come before first
|
|
1198
|
+
* - Zero: elements are equal
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* // Sort table rows by a specific property in ascending order
|
|
1202
|
+
* table.api.sort((a, b) => {
|
|
1203
|
+
* if (a.name < b.name) return -1;
|
|
1204
|
+
* if (a.name > b.name) return 1;
|
|
1205
|
+
* return 0;
|
|
1206
|
+
* });
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* // Sort numbers in descending order
|
|
1210
|
+
* table.api.sort((a, b) => b.value - a.value);
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
* // Sort with multiple criteria
|
|
1214
|
+
* table.api.sort((a, b) => {
|
|
1215
|
+
* // First sort by status
|
|
1216
|
+
* const statusCompare = a.status.localeCompare(b.status);
|
|
1217
|
+
* if (statusCompare !== 0) return statusCompare;
|
|
1218
|
+
*
|
|
1219
|
+
* // Then sort by name if status is equal
|
|
1220
|
+
* return a.name.localeCompare(b.name);
|
|
1221
|
+
* });
|
|
1222
|
+
*
|
|
1223
|
+
* @example
|
|
1224
|
+
* // Case-insensitive string sorting
|
|
1225
|
+
* table.api.sort((a, b) =>
|
|
1226
|
+
* a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
1227
|
+
* );
|
|
1228
|
+
*/
|
|
1229
|
+
sort(e) {
|
|
1230
|
+
this.tableScope.sort(e);
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
1234
|
+
* This method checks if the target row is within the currently visible range and
|
|
1235
|
+
* adjusts the scroll position if it's not visible.
|
|
1236
|
+
*
|
|
1237
|
+
* The method performs the following:
|
|
1238
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
1239
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
1240
|
+
* 3. Scrolls to make the row visible if needed
|
|
1241
|
+
*
|
|
1242
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
1243
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* // Ensure row 5 is visible in the viewport
|
|
1247
|
+
* tableApi.ensureRowIsVisible(5);
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* // Example usage in a component
|
|
1251
|
+
* class MyTableComponent {
|
|
1252
|
+
* private tableApi: TableApi;
|
|
1253
|
+
*
|
|
1254
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
1255
|
+
* // This will scroll the row into view if it's not visible
|
|
1256
|
+
* const didScroll = this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1257
|
+
*
|
|
1258
|
+
* if (didScroll) {
|
|
1259
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
1260
|
+
* } else {
|
|
1261
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
1262
|
+
* }
|
|
1263
|
+
* }
|
|
1264
|
+
* }
|
|
1265
|
+
*
|
|
1266
|
+
* @example
|
|
1267
|
+
* // Example with row selection
|
|
1268
|
+
* class TableHandler {
|
|
1269
|
+
* selectAndShowRow(rowIndex: number) {
|
|
1270
|
+
* // First ensure the row is visible
|
|
1271
|
+
* this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1272
|
+
*
|
|
1273
|
+
* // Then perform selection
|
|
1274
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
1275
|
+
* }
|
|
1276
|
+
* }
|
|
1277
|
+
*
|
|
1278
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
1279
|
+
*
|
|
1280
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
1281
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
1282
|
+
*/
|
|
1283
|
+
ensureRowIsVisible(e) {
|
|
1284
|
+
return this.tableScope.ensureRowIsVisible(e);
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Retrieves the number of rows currently displayed in the table.
|
|
1288
|
+
*
|
|
1289
|
+
* @description
|
|
1290
|
+
* This method returns the count of rows that are currently visible in the table after
|
|
1291
|
+
* applying any filtering, pagination, or other visibility constraints.
|
|
1292
|
+
*
|
|
1293
|
+
* @return {number} The number of rows currently displayed in the table.
|
|
1294
|
+
*/
|
|
886
1295
|
getDisplayedRowCount() {
|
|
887
1296
|
return this.tableScope.getDisplayedRowCount();
|
|
888
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Returns the index of the first visible row in the table's viewport.
|
|
1300
|
+
*
|
|
1301
|
+
* This method retrieves the first visible row index from the table's scope, which is useful
|
|
1302
|
+
* for virtual scrolling and viewport-related calculations. The index represents the topmost
|
|
1303
|
+
* visible row in the current scroll position of the table.
|
|
1304
|
+
*
|
|
1305
|
+
* This value is maintained internally by the table and updated during scrolling operations.
|
|
1306
|
+
* It's particularly important for:
|
|
1307
|
+
* - Virtual scrolling optimization
|
|
1308
|
+
* - Calculating visible range of rows
|
|
1309
|
+
* - Viewport-related operations
|
|
1310
|
+
* - Scroll position restoration
|
|
1311
|
+
*
|
|
1312
|
+
* @returns {number} The index of the first visible row in the table's viewport.
|
|
1313
|
+
* Returns -1 if no rows are visible or if the table is not yet rendered.
|
|
1314
|
+
*
|
|
1315
|
+
* @example
|
|
1316
|
+
* ```typescript
|
|
1317
|
+
* // Get the first visible row index
|
|
1318
|
+
* const tableApi = new TableApi(tableScope);
|
|
1319
|
+
* const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
|
|
1320
|
+
*
|
|
1321
|
+
* // Use the index for scroll position calculations
|
|
1322
|
+
* if (firstVisibleIndex >= 0) {
|
|
1323
|
+
* // Perform operations with the first visible row
|
|
1324
|
+
* console.log(`First visible row index: ${firstVisibleIndex}`);
|
|
1325
|
+
* }
|
|
1326
|
+
* ```
|
|
1327
|
+
*/
|
|
1328
|
+
getFirstVisibleRowIndex() {
|
|
1329
|
+
return this.tableScope.getFirstVisibleRowIndex();
|
|
1330
|
+
}
|
|
889
1331
|
}
|
|
890
1332
|
class G {
|
|
891
1333
|
constructor(e) {
|
|
@@ -1247,7 +1689,7 @@ class A {
|
|
|
1247
1689
|
return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
|
|
1248
1690
|
}
|
|
1249
1691
|
}
|
|
1250
|
-
class
|
|
1692
|
+
class we {
|
|
1251
1693
|
constructor(e, t) {
|
|
1252
1694
|
this.tableModel = e, this.areaModel = t, this.colAndRowspanRanges = void 0;
|
|
1253
1695
|
}
|
|
@@ -1280,7 +1722,7 @@ class xe {
|
|
|
1280
1722
|
return !1;
|
|
1281
1723
|
}
|
|
1282
1724
|
}
|
|
1283
|
-
class
|
|
1725
|
+
class xe {
|
|
1284
1726
|
constructor(e, t, s) {
|
|
1285
1727
|
this.header = e, this.body = t, this.footer = s;
|
|
1286
1728
|
}
|
|
@@ -1292,10 +1734,10 @@ class Ce extends ye {
|
|
|
1292
1734
|
header: [],
|
|
1293
1735
|
body: [],
|
|
1294
1736
|
footer: []
|
|
1295
|
-
}, this.tree = !1, this.colAndRowspanModels = new
|
|
1737
|
+
}, this.tree = !1, this.colAndRowspanModels = new xe(), this.firstVisibleRowIndex = -1, this.draggingTargetColumnIndex = -1, this.removables = [], this.displayedRowCount = 0, this.tableModel.getSelectionModel ? this.getSelectionModel = this.tableModel.getSelectionModel : (r = this.tableOptions) != null && r.getSelectionModel && (this.getSelectionModel = this.tableOptions.getSelectionModel), (a = this.tableOptions) != null && a.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), H(t.getAreaModel("body")) && (this.tree = !0), ["header", "body", "footer"].forEach(
|
|
1296
1738
|
(l) => {
|
|
1297
1739
|
var n;
|
|
1298
|
-
this.colAndRowspanModels[l] = new
|
|
1740
|
+
this.colAndRowspanModels[l] = new we(t, t.getAreaModel(l)), (n = this.colAndRowspanModels[l]) == null || n.init();
|
|
1299
1741
|
}
|
|
1300
1742
|
);
|
|
1301
1743
|
}
|
|
@@ -1557,11 +1999,11 @@ class Ce extends ye {
|
|
|
1557
1999
|
let h = t;
|
|
1558
2000
|
const m = this.tableModel.getColumnCount(), g = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
|
|
1559
2001
|
for (let u = 0; u < p; u++) {
|
|
1560
|
-
const
|
|
1561
|
-
if (
|
|
2002
|
+
const w = h, x = u === p - 1, v = this.tableModel.getRowHeight(e, u);
|
|
2003
|
+
if (w + v > 0) {
|
|
1562
2004
|
this.firstVisibleRowIndex = u;
|
|
1563
|
-
let y = { left: a, width: l, height: v, top:
|
|
1564
|
-
const
|
|
2005
|
+
let y = { left: a, width: l, height: v, top: w, index: u }, S = this.dom.addRowDiv(o, y, u, e, "center");
|
|
2006
|
+
const M = b;
|
|
1565
2007
|
if (this.adjustColumnsToRowParent({
|
|
1566
2008
|
areaIdent: e,
|
|
1567
2009
|
sideIdent: "center",
|
|
@@ -1569,11 +2011,11 @@ class Ce extends ye {
|
|
|
1569
2011
|
geo: y,
|
|
1570
2012
|
parent: S,
|
|
1571
2013
|
rowIndex: u,
|
|
1572
|
-
columnIndexStart:
|
|
2014
|
+
columnIndexStart: M,
|
|
1573
2015
|
columnIndexEnd: m - g - 1,
|
|
1574
2016
|
verticalFixed: !1,
|
|
1575
|
-
lastRowOfModel:
|
|
1576
|
-
}), n.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height: v, top:
|
|
2017
|
+
lastRowOfModel: x
|
|
2018
|
+
}), n.left > 0 && (y = { left: a, width: this.areaBodyWestGeo.width, height: v, top: w, index: u }, S = this.dom.addRowDiv(s, y, u, e, "west"), this.adjustColumnsToRowParent({
|
|
1577
2019
|
areaIdent: e,
|
|
1578
2020
|
sideIdent: "west",
|
|
1579
2021
|
areaModel: c,
|
|
@@ -1581,10 +2023,10 @@ class Ce extends ye {
|
|
|
1581
2023
|
parent: S,
|
|
1582
2024
|
rowIndex: u,
|
|
1583
2025
|
columnIndexStart: 0,
|
|
1584
|
-
columnIndexEnd:
|
|
2026
|
+
columnIndexEnd: M - 1,
|
|
1585
2027
|
verticalFixed: !0,
|
|
1586
|
-
lastRowOfModel:
|
|
1587
|
-
})), n.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height: v, top:
|
|
2028
|
+
lastRowOfModel: x
|
|
2029
|
+
})), n.right > 0 && (y = { left: a, width: this.areaBodyEastGeo.width, height: v, top: w, index: u }, S = this.dom.addRowDiv(i, y, u, e, "east"), this.adjustColumnsToRowParent({
|
|
1588
2030
|
areaIdent: e,
|
|
1589
2031
|
sideIdent: "east",
|
|
1590
2032
|
areaModel: c,
|
|
@@ -1594,7 +2036,7 @@ class Ce extends ye {
|
|
|
1594
2036
|
columnIndexStart: m - g,
|
|
1595
2037
|
columnIndexEnd: m - 1,
|
|
1596
2038
|
verticalFixed: !0,
|
|
1597
|
-
lastRowOfModel:
|
|
2039
|
+
lastRowOfModel: x
|
|
1598
2040
|
})), e === "header" && this.tree && u === p - 1) {
|
|
1599
2041
|
const E = this.dom.applyStyle(
|
|
1600
2042
|
this.dom.setAttribute(
|
|
@@ -1603,10 +2045,10 @@ class Ce extends ye {
|
|
|
1603
2045
|
"toggleExpandCollapseAll"
|
|
1604
2046
|
),
|
|
1605
2047
|
{ cursor: "pointer" }
|
|
1606
|
-
),
|
|
1607
|
-
if (
|
|
1608
|
-
const O = this.dom.domService.createText(
|
|
1609
|
-
this.dom.domService.appendChild(E, O),
|
|
2048
|
+
), R = this.tableOptions.treeOptions.arrowExpandCollapseAll;
|
|
2049
|
+
if (R) {
|
|
2050
|
+
const O = this.dom.domService.createText(R.content);
|
|
2051
|
+
this.dom.domService.appendChild(E, O), R.style && this.dom.applyStyleString(E, R.style);
|
|
1610
2052
|
}
|
|
1611
2053
|
}
|
|
1612
2054
|
}
|
|
@@ -1618,17 +2060,17 @@ class Ce extends ye {
|
|
|
1618
2060
|
if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
|
|
1619
2061
|
const u = ((f = this.colAndRowspanModels[e]) == null ? void 0 : f.getRanges()) ?? [];
|
|
1620
2062
|
if (u.length)
|
|
1621
|
-
for (const
|
|
1622
|
-
let
|
|
1623
|
-
if (
|
|
2063
|
+
for (const w of u) {
|
|
2064
|
+
let x = 0, v = o.child, y = "center";
|
|
2065
|
+
if (w.c1 < b)
|
|
1624
2066
|
v = s.child, y = "west";
|
|
1625
|
-
else if (g > 0 &&
|
|
2067
|
+
else if (g > 0 && w.c1 >= m - g)
|
|
1626
2068
|
v = i.child, y = "east";
|
|
1627
2069
|
else {
|
|
1628
2070
|
const S = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1629
|
-
|
|
2071
|
+
x = this.scrollFactorX * S - this.areaBodyWestGeo.width, y = "center";
|
|
1630
2072
|
}
|
|
1631
|
-
this.drawBigCell(
|
|
2073
|
+
this.drawBigCell(w, x, t, c, v, y);
|
|
1632
2074
|
}
|
|
1633
2075
|
}
|
|
1634
2076
|
}
|
|
@@ -1736,21 +2178,21 @@ class Ce extends ye {
|
|
|
1736
2178
|
const h = 0, m = !!(e === "body" && t);
|
|
1737
2179
|
let g = p;
|
|
1738
2180
|
for (let f = a; f <= l; f++) {
|
|
1739
|
-
const u = g,
|
|
1740
|
-
if (
|
|
1741
|
-
let
|
|
2181
|
+
const u = g, w = this.tableModel.getColumnWidth(f);
|
|
2182
|
+
if (w > 0 && u + w > 0) {
|
|
2183
|
+
let x = o.height;
|
|
1742
2184
|
const v = s.getRowspanAt(r, f), y = s.getColspanAt(r, f);
|
|
1743
|
-
v > 1 && (
|
|
1744
|
-
let S =
|
|
1745
|
-
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((E,
|
|
1746
|
-
let
|
|
1747
|
-
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (
|
|
1748
|
-
this.renderDragTargetDiv(i, u, h, S,
|
|
1749
|
-
const E = { left: u, top: h, width: S, height:
|
|
2185
|
+
v > 1 && (x = this.getRowHeights(r, r + v - 1, s).reduce((E, R) => E + R, 0));
|
|
2186
|
+
let S = w;
|
|
2187
|
+
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((E, R) => E + R, 0));
|
|
2188
|
+
let M = !1;
|
|
2189
|
+
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (M = !0), this.draggingTargetColumnIndex === f && e !== "header") {
|
|
2190
|
+
this.renderDragTargetDiv(i, u, h, S, x);
|
|
2191
|
+
const E = { left: u, top: h, width: S, height: x };
|
|
1750
2192
|
this.dom.addColumnBorderDivs(this.tableOptions, i, E, e, t);
|
|
1751
2193
|
} else {
|
|
1752
|
-
const E = this.renderSelectedBackgroundDiv(
|
|
1753
|
-
"gammaCells" in s && s.getValueAt(r, f) && (
|
|
2194
|
+
const E = this.renderSelectedBackgroundDiv(M, m, t, s, r, f, i, u, h, S, x);
|
|
2195
|
+
"gammaCells" in s && s.getValueAt(r, f) && (M = !1), M || this.renderCell({
|
|
1754
2196
|
areaModel: s,
|
|
1755
2197
|
areaIdent: e,
|
|
1756
2198
|
sideIdent: t,
|
|
@@ -1759,7 +2201,7 @@ class Ce extends ye {
|
|
|
1759
2201
|
left: u,
|
|
1760
2202
|
top: h,
|
|
1761
2203
|
width: S,
|
|
1762
|
-
height:
|
|
2204
|
+
height: x,
|
|
1763
2205
|
parent: i,
|
|
1764
2206
|
cellSelected: E,
|
|
1765
2207
|
lastRowOfModel: c,
|
|
@@ -1770,12 +2212,12 @@ class Ce extends ye {
|
|
|
1770
2212
|
cellLeft: u,
|
|
1771
2213
|
cellTop: h,
|
|
1772
2214
|
cellWidth: S,
|
|
1773
|
-
cellHeight:
|
|
2215
|
+
cellHeight: x,
|
|
1774
2216
|
parent: i
|
|
1775
2217
|
});
|
|
1776
2218
|
}
|
|
1777
2219
|
}
|
|
1778
|
-
if (g = g +
|
|
2220
|
+
if (g = g + w, g > this.areaBodyCenterGeo.width)
|
|
1779
2221
|
break;
|
|
1780
2222
|
}
|
|
1781
2223
|
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(g - 1, 1, o.height, 0), i);
|
|
@@ -1812,12 +2254,12 @@ class Ce extends ye {
|
|
|
1812
2254
|
const C = b;
|
|
1813
2255
|
(U = C.children) != null && U.length ? C.expanded ? f = "expanded" : f = "collapsed" : f = "hidden";
|
|
1814
2256
|
}
|
|
1815
|
-
let
|
|
2257
|
+
let w;
|
|
1816
2258
|
if (t === "header") {
|
|
1817
2259
|
const C = this.tableModel.getColumnDef(i);
|
|
1818
|
-
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (
|
|
2260
|
+
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (w = C == null ? void 0 : C.sortState);
|
|
1819
2261
|
}
|
|
1820
|
-
const
|
|
2262
|
+
const x = e.getValueAt(o, i), v = m ? "" : `${x}`, y = e.isRowChecked(o), S = this.dom.addColumnDiv(
|
|
1821
2263
|
{
|
|
1822
2264
|
parent: c,
|
|
1823
2265
|
geo: g,
|
|
@@ -1829,14 +2271,14 @@ class Ce extends ye {
|
|
|
1829
2271
|
treeArrow: f,
|
|
1830
2272
|
tableOptions: this.tableOptions,
|
|
1831
2273
|
checkedType: y,
|
|
1832
|
-
sortState:
|
|
2274
|
+
sortState: w
|
|
1833
2275
|
}
|
|
1834
|
-
),
|
|
1835
|
-
|
|
2276
|
+
), M = e.getTooltipAt(o, i);
|
|
2277
|
+
M && this.dom.setAttribute(S, "title", M);
|
|
1836
2278
|
const E = this.tableModel.getColumnDef(i);
|
|
1837
2279
|
E && E.classes[t] && this.dom.addClasses(E.classes[t], S);
|
|
1838
|
-
let
|
|
1839
|
-
m && (
|
|
2280
|
+
let R;
|
|
2281
|
+
m && (R = m.render(S, o, i, t, e, x, this.dom.domService));
|
|
1840
2282
|
const O = e.getCustomClassesAt(o, i);
|
|
1841
2283
|
if (O.length && this.dom.addClasses(O, S), this.dom.addColumnBorderDivs(this.tableOptions, c, g, t, s), p && this.dom.addHorizontalBorder({ left: r, width: a, height: l, top: n + l }, c), this.getFocusModel && t === "body") {
|
|
1842
2284
|
const C = this.getFocusModel();
|
|
@@ -1847,7 +2289,7 @@ class Ce extends ye {
|
|
|
1847
2289
|
if ($)
|
|
1848
2290
|
for (const C in $)
|
|
1849
2291
|
this.dom.setStyle(S, C, $[C]);
|
|
1850
|
-
return [S,
|
|
2292
|
+
return [S, R];
|
|
1851
2293
|
}
|
|
1852
2294
|
/**
|
|
1853
2295
|
* Applies CSS classes to an HTML element.
|
|
@@ -2022,10 +2464,10 @@ class Ce extends ye {
|
|
|
2022
2464
|
sideIdent: o,
|
|
2023
2465
|
text: b
|
|
2024
2466
|
}, u = this.dom.addColumnDiv(f);
|
|
2025
|
-
let
|
|
2026
|
-
g && (
|
|
2027
|
-
const
|
|
2028
|
-
|
|
2467
|
+
let w;
|
|
2468
|
+
g && (w = g.render(u, n, a, t, i, m, this.dom.domService), w && this.cleanupFunctions[t].push(w));
|
|
2469
|
+
const x = i.getCustomClassesAt(n, a);
|
|
2470
|
+
x.length && this.dom.addClasses(x, u);
|
|
2029
2471
|
const v = this.tableModel.getColumnDef(a);
|
|
2030
2472
|
v && v.classes[t] && this.dom.addClasses(v.classes[t], u), this.dom.addColumnBorderDivs(this.tableOptions, l, h, t, o);
|
|
2031
2473
|
const y = i.getCustomStyleAt(n, a);
|
|
@@ -2206,7 +2648,7 @@ class z {
|
|
|
2206
2648
|
return new z([new Ee(e, t)]);
|
|
2207
2649
|
}
|
|
2208
2650
|
}
|
|
2209
|
-
class
|
|
2651
|
+
class Re {
|
|
2210
2652
|
constructor(e) {
|
|
2211
2653
|
var t, s;
|
|
2212
2654
|
this.tableScope = e, (t = this.tableScope.tableOptions) != null && t.getSelectionModel && (this.getSelectionModel = this.tableScope.tableOptions.getSelectionModel), (s = this.tableScope.tableOptions) != null && s.getFocusModel && (this.getFocusModel = this.tableScope.tableOptions.getFocusModel);
|
|
@@ -2247,7 +2689,7 @@ class Me {
|
|
|
2247
2689
|
});
|
|
2248
2690
|
}
|
|
2249
2691
|
}
|
|
2250
|
-
class
|
|
2692
|
+
class Me {
|
|
2251
2693
|
get() {
|
|
2252
2694
|
return {
|
|
2253
2695
|
f2: "START_EDITING",
|
|
@@ -2327,7 +2769,7 @@ class ke {
|
|
|
2327
2769
|
(t = (e = this.tableScope) == null ? void 0 : e.tableOptions) != null && t.shortcutActionsDisabled ? this.isDebug() && console.debug("ShortcutService skipped.") : (this.assignPredefinedSystemShortcutMappings(), Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping), this.isDebug() && console.debug("ShortcutService", this.shortcutActionIdMapping), this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this)));
|
|
2328
2770
|
}
|
|
2329
2771
|
assignPredefinedSystemShortcutMappings() {
|
|
2330
|
-
this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new Te().get()) : Object.assign(this.shortcutActionIdMapping, new
|
|
2772
|
+
this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new Te().get()) : Object.assign(this.shortcutActionIdMapping, new Me().get());
|
|
2331
2773
|
}
|
|
2332
2774
|
isMacintosh() {
|
|
2333
2775
|
return navigator.platform.indexOf("Mac") > -1;
|
|
@@ -2814,7 +3256,7 @@ class We {
|
|
|
2814
3256
|
class N extends Ce {
|
|
2815
3257
|
constructor(e, t, s, o, i, r = new B(), a = new We()) {
|
|
2816
3258
|
var c;
|
|
2817
|
-
if (super(e, t, new ce(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager =
|
|
3259
|
+
if (super(e, t, new ce(s), o), this.eventListener = i, this.copyService = r, this.excelService = a, this.licenseManager = F.getInstance(), this.selectionService = new Re(this), this.api = new fe(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 K()), (c = this.tableOptions) != null && c.autoRestoreOptions) {
|
|
2818
3260
|
const p = this.tableOptions.autoRestoreOptions, h = p.getStorageKeyFn;
|
|
2819
3261
|
h && (p.autoRestoreScrollPosition && (this.storeScrollPosStateService = new ue(h)), p.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new be(h)), p.autoRestoreSortingState && (this.storeSortingService = new Se(h)));
|
|
2820
3262
|
}
|
|
@@ -3236,9 +3678,70 @@ class N extends Ce {
|
|
|
3236
3678
|
let e = ((t = this.storeSortingService) == null ? void 0 : t.getSortItems()) ?? [];
|
|
3237
3679
|
this.tableModel.doSort(e);
|
|
3238
3680
|
}
|
|
3681
|
+
sort(e) {
|
|
3682
|
+
this.tableModel.sort(e);
|
|
3683
|
+
}
|
|
3239
3684
|
getDisplayedRowCount() {
|
|
3240
3685
|
return this.displayedRowCount;
|
|
3241
3686
|
}
|
|
3687
|
+
/**
|
|
3688
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
3689
|
+
* This method checks if the target row is within the currently visible range and
|
|
3690
|
+
* adjusts the scroll position if it's not visible.
|
|
3691
|
+
*
|
|
3692
|
+
* The method performs the following:
|
|
3693
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
3694
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
3695
|
+
* 3. Scrolls to make the row visible if needed
|
|
3696
|
+
*
|
|
3697
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
3698
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
3699
|
+
*
|
|
3700
|
+
* @example
|
|
3701
|
+
* // Ensure row 5 is visible in the viewport
|
|
3702
|
+
* tableScope.ensureRowIsVisible(5);
|
|
3703
|
+
*
|
|
3704
|
+
* @example
|
|
3705
|
+
* // Example usage in a component
|
|
3706
|
+
* class MyTableComponent {
|
|
3707
|
+
* private tableScope: TableScope;
|
|
3708
|
+
*
|
|
3709
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
3710
|
+
* // This will scroll the row into view if it's not visible
|
|
3711
|
+
* const didScroll = this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3712
|
+
*
|
|
3713
|
+
* if (didScroll) {
|
|
3714
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
3715
|
+
* } else {
|
|
3716
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
3717
|
+
* }
|
|
3718
|
+
* }
|
|
3719
|
+
* }
|
|
3720
|
+
*
|
|
3721
|
+
* @example
|
|
3722
|
+
* // Example with row selection
|
|
3723
|
+
* class TableHandler {
|
|
3724
|
+
* selectAndShowRow(rowIndex: number) {
|
|
3725
|
+
* // First ensure the row is visible
|
|
3726
|
+
* this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3727
|
+
*
|
|
3728
|
+
* // Then perform selection
|
|
3729
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
3730
|
+
* }
|
|
3731
|
+
* }
|
|
3732
|
+
*
|
|
3733
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
3734
|
+
*
|
|
3735
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
3736
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
3737
|
+
*/
|
|
3738
|
+
ensureRowIsVisible(e) {
|
|
3739
|
+
const t = this.firstVisibleRowIndex, s = this.firstVisibleRowIndex + this.displayedRowCount - 1;
|
|
3740
|
+
return e < t ? (this.scrollToIndex(0, e), !0) : e > s ? (this.scrollToIndex(0, e - this.displayedRowCount + 1), !0) : !1;
|
|
3741
|
+
}
|
|
3742
|
+
getFirstVisibleRowIndex() {
|
|
3743
|
+
return this.firstVisibleRowIndex;
|
|
3744
|
+
}
|
|
3242
3745
|
}
|
|
3243
3746
|
const P = class P {
|
|
3244
3747
|
};
|
|
@@ -3592,7 +4095,7 @@ const $e = se({
|
|
|
3592
4095
|
};
|
|
3593
4096
|
return ie(() => {
|
|
3594
4097
|
t.value && s(t.value);
|
|
3595
|
-
}), d.licenseKey &&
|
|
4098
|
+
}), d.licenseKey && F.getInstance().setLicenseKey(d.licenseKey), {
|
|
3596
4099
|
root: t
|
|
3597
4100
|
};
|
|
3598
4101
|
}
|