@guiexpert/react-table 18.1.74 → 18.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 +581 -78
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -479,6 +479,8 @@ class he {
|
|
|
479
479
|
doSort(e) {
|
|
480
480
|
return !1;
|
|
481
481
|
}
|
|
482
|
+
sort(e) {
|
|
483
|
+
}
|
|
482
484
|
isEditable(e, t) {
|
|
483
485
|
var o, i;
|
|
484
486
|
const s = (o = this.columnDefs) == null ? void 0 : o[t];
|
|
@@ -536,7 +538,13 @@ class pe {
|
|
|
536
538
|
}
|
|
537
539
|
class F extends he {
|
|
538
540
|
constructor(e, t, s, o = [], i = "ge-selected-row", r = "ge-focused-row") {
|
|
539
|
-
super(e, o, s), this.areaIdent = e, this.rows = t, this.defaultRowHeight = s, this.columnDefs = o, this.selectedRowClass = i, this.focusedRowClass = r, this.
|
|
541
|
+
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 pe(), this._focusedRowIndex = 0, this.filteredRows = [...t], this.properties = o.map((l) => l.property);
|
|
542
|
+
}
|
|
543
|
+
getFocusedRowIndex() {
|
|
544
|
+
return this._focusedRowIndex;
|
|
545
|
+
}
|
|
546
|
+
setFocusedRowIndex(e) {
|
|
547
|
+
this._focusedRowIndex = e;
|
|
540
548
|
}
|
|
541
549
|
setRows(e) {
|
|
542
550
|
this.rows = e, this.filteredRows = [...e];
|
|
@@ -568,6 +576,28 @@ class F extends he {
|
|
|
568
576
|
getAllRows() {
|
|
569
577
|
return this.rows;
|
|
570
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
|
|
581
|
+
*
|
|
582
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
583
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
584
|
+
* and returns true if the row matches the criteria
|
|
585
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found
|
|
586
|
+
*/
|
|
587
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
588
|
+
return this.getFilteredRows().find((s) => t(e, s));
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Searches through all rows to find a row that matches the given criteria based on the predicate function.
|
|
592
|
+
*
|
|
593
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria
|
|
594
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
|
|
595
|
+
* and returns true if the row matches the criteria
|
|
596
|
+
* @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
|
|
597
|
+
*/
|
|
598
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
599
|
+
return this.getAllRows().find((s) => t(e, s));
|
|
600
|
+
}
|
|
571
601
|
getRowHeight(e) {
|
|
572
602
|
return this.defaultRowHeight;
|
|
573
603
|
}
|
|
@@ -584,6 +614,9 @@ class F extends he {
|
|
|
584
614
|
}
|
|
585
615
|
return !0;
|
|
586
616
|
}
|
|
617
|
+
sort(e) {
|
|
618
|
+
this.filteredRows = this.filteredRows.sort(e);
|
|
619
|
+
}
|
|
587
620
|
getValueByT(e, t) {
|
|
588
621
|
if (e && t)
|
|
589
622
|
return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
|
|
@@ -593,7 +626,7 @@ class F extends he {
|
|
|
593
626
|
}
|
|
594
627
|
getCustomClassesAt(e, t) {
|
|
595
628
|
const s = super.getCustomClassesAt(e, t);
|
|
596
|
-
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this.
|
|
629
|
+
return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this._focusedRowIndex === e && s.push(this.focusedRowClass), s;
|
|
597
630
|
}
|
|
598
631
|
genericFlatTableSortComparator(e, t) {
|
|
599
632
|
const s = this.columnDefs.find((o) => o.property === e);
|
|
@@ -821,25 +854,90 @@ class ge {
|
|
|
821
854
|
getSelectionModel() {
|
|
822
855
|
return this.tableScope.selectionModel();
|
|
823
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Automatically resizes all columns to fit their content.
|
|
859
|
+
*
|
|
860
|
+
* @param {boolean} recalcWrappers - Determines whether to recalculate wrapper dimensions after resizing columns.
|
|
861
|
+
* Default value is true.
|
|
862
|
+
*
|
|
863
|
+
* @return {void} - This method doesn't return anything.
|
|
864
|
+
*/
|
|
824
865
|
autoResizeColumns(e = !0) {
|
|
825
866
|
this.tableScope.autoResizeColumns(e);
|
|
826
867
|
}
|
|
868
|
+
/**
|
|
869
|
+
* Recalculates the dimensions of all wrapper elements in the table.
|
|
870
|
+
*
|
|
871
|
+
* This method is typically called after changes to the table structure or content
|
|
872
|
+
* that might affect the layout, such as resizing columns or changing row heights.
|
|
873
|
+
* It ensures that all wrapper elements are properly sized to match their content.
|
|
874
|
+
*
|
|
875
|
+
* @return {void} - This method doesn't return anything.
|
|
876
|
+
*/
|
|
827
877
|
recalcWrappers() {
|
|
828
878
|
this.tableScope.recalcWrappers();
|
|
829
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Sets the width of a specific column in the table.
|
|
882
|
+
*
|
|
883
|
+
* @param {number} columnIndex - The index of the column to resize.
|
|
884
|
+
* @param {number} width - The new width to set for the column, in pixels.
|
|
885
|
+
*
|
|
886
|
+
* @return {void} - This method doesn't return anything.
|
|
887
|
+
*/
|
|
830
888
|
setColumnWidth(e, t) {
|
|
831
889
|
this.tableScope.setColumnWidth(e, t);
|
|
832
890
|
}
|
|
891
|
+
/**
|
|
892
|
+
* Retrieves the table model that contains all data and structure information for the table.
|
|
893
|
+
*
|
|
894
|
+
* @return {TableModelIf} The table model interface that provides access to the table's data structure,
|
|
895
|
+
* including header, body, and footer area models.
|
|
896
|
+
*/
|
|
833
897
|
getTableModel() {
|
|
834
898
|
return this.tableScope.tableModel;
|
|
835
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* Retrieves the area model for the body section of the table.
|
|
902
|
+
*
|
|
903
|
+
* @return {AreaModelIf} The area model interface that provides access to the table's body data,
|
|
904
|
+
* including rows, cells, and their values.
|
|
905
|
+
*/
|
|
836
906
|
getBodyModel() {
|
|
837
907
|
return this.tableScope.tableModel.getBodyModel();
|
|
838
908
|
}
|
|
909
|
+
/**
|
|
910
|
+
* Sets the rows data for the table body, replacing any existing rows.
|
|
911
|
+
*
|
|
912
|
+
* @template T - The type of elements in the rows array
|
|
913
|
+
* @param {T[]} rows - An array of data objects to set as the table's rows
|
|
914
|
+
*
|
|
915
|
+
* @description
|
|
916
|
+
* This method replaces all existing rows in the table body with the provided array of data objects.
|
|
917
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
918
|
+
*
|
|
919
|
+
* @return {void} - This method doesn't return anything.
|
|
920
|
+
*
|
|
921
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
922
|
+
*/
|
|
839
923
|
setRows(e) {
|
|
840
924
|
const t = this.getBodyModel();
|
|
841
925
|
t instanceof F ? t.setRows(e) : console.warn("setRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
842
926
|
}
|
|
927
|
+
/**
|
|
928
|
+
* Adds new rows to the end of the table body.
|
|
929
|
+
*
|
|
930
|
+
* @template T - The type of elements in the rows array
|
|
931
|
+
* @param {T[]} rows - An array of data objects to append to the table's existing rows
|
|
932
|
+
*
|
|
933
|
+
* @description
|
|
934
|
+
* This method appends the provided array of data objects to the end of the existing rows in the table body.
|
|
935
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
936
|
+
*
|
|
937
|
+
* @return {void} - This method doesn't return anything.
|
|
938
|
+
*
|
|
939
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
940
|
+
*/
|
|
843
941
|
addRows(e) {
|
|
844
942
|
const t = this.getBodyModel();
|
|
845
943
|
if (t instanceof F) {
|
|
@@ -849,6 +947,22 @@ class ge {
|
|
|
849
947
|
} else
|
|
850
948
|
console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
851
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* Inserts new rows at a specific position in the table body.
|
|
952
|
+
*
|
|
953
|
+
* @template T - The type of elements in the rows array
|
|
954
|
+
* @param {T[]} rows - An array of data objects to insert into the table
|
|
955
|
+
* @param {number} rowIndex - The index position where the new rows should be inserted
|
|
956
|
+
*
|
|
957
|
+
* @description
|
|
958
|
+
* This method inserts the provided array of data objects at the specified index position in the table body.
|
|
959
|
+
* Existing rows at or after the specified index will be shifted down.
|
|
960
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
961
|
+
*
|
|
962
|
+
* @return {void} - This method doesn't return anything.
|
|
963
|
+
*
|
|
964
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
965
|
+
*/
|
|
852
966
|
addRowsAt(e, t) {
|
|
853
967
|
const s = this.getBodyModel();
|
|
854
968
|
if (s instanceof F) {
|
|
@@ -858,6 +972,23 @@ class ge {
|
|
|
858
972
|
} else
|
|
859
973
|
console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
860
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* Removes specified rows from the table body.
|
|
977
|
+
*
|
|
978
|
+
* @template T - The type of elements in the rows array
|
|
979
|
+
* @param {T[]} rows - An array of data objects to remove from the table
|
|
980
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
981
|
+
* - Default predicate uses strict equality (===)
|
|
982
|
+
* - The function should return true if the rows are considered a match
|
|
983
|
+
*
|
|
984
|
+
* @description
|
|
985
|
+
* This method removes rows from the table body that match any of the provided rows based on the predicate function.
|
|
986
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
987
|
+
*
|
|
988
|
+
* @return {void} - This method doesn't return anything.
|
|
989
|
+
*
|
|
990
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
991
|
+
*/
|
|
861
992
|
removeRows(e, t = (s, o) => s === o) {
|
|
862
993
|
const s = this.getBodyModel();
|
|
863
994
|
if (s instanceof F) {
|
|
@@ -866,10 +997,168 @@ class ge {
|
|
|
866
997
|
} else
|
|
867
998
|
console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
868
999
|
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Searches for and returns rows from the table body that match the given criteria.
|
|
1002
|
+
*
|
|
1003
|
+
* @template T - The type of elements in the rows array
|
|
1004
|
+
*
|
|
1005
|
+
* @description
|
|
1006
|
+
* This method searches through the table body model for rows that match the provided criteria.
|
|
1007
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1008
|
+
* The method uses a predicate function to determine matches between rows.
|
|
1009
|
+
*
|
|
1010
|
+
* @param {T[]} rows - An array of rows to search for in the table body
|
|
1011
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines if two rows match
|
|
1012
|
+
* - Default predicate uses strict equality (===)
|
|
1013
|
+
* - The function should return true if the rows are considered a match
|
|
1014
|
+
* - Parameters:
|
|
1015
|
+
* - a: The row from the table body being checked
|
|
1016
|
+
* - b: The row from the input array being searched for
|
|
1017
|
+
*
|
|
1018
|
+
* @returns {T[]} An array containing all matching rows found in the table body
|
|
1019
|
+
* - Returns an empty array if:
|
|
1020
|
+
* - The body model is not an instance of AreaModelObjectArray
|
|
1021
|
+
* - No matches are found
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* // Find rows with simple equality comparison
|
|
1025
|
+
* const matchingRows = table.findRows([row1, row2]);
|
|
1026
|
+
*
|
|
1027
|
+
* @example
|
|
1028
|
+
* // Find rows with custom comparison logic
|
|
1029
|
+
* const matchingRows = table.findRows([row1, row2], (a, b) => a.id === b.id);
|
|
1030
|
+
*
|
|
1031
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1032
|
+
*/
|
|
869
1033
|
findRows(e, t = (s, o) => s === o) {
|
|
870
1034
|
const s = this.getBodyModel();
|
|
871
1035
|
return s instanceof F ? 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), []);
|
|
872
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Searches through the filtered rows of the table to find a row that matches specific criteria.
|
|
1039
|
+
* This method only works with tables that use AreaModelObjectArray as their body model.
|
|
1040
|
+
*
|
|
1041
|
+
* @template T - The type of the row objects in the table
|
|
1042
|
+
*
|
|
1043
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1044
|
+
* Only needs to include the properties you want to match against.
|
|
1045
|
+
*
|
|
1046
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1047
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1048
|
+
*
|
|
1049
|
+
* @returns {T | undefined} The first matching row from the filtered rows, or undefined if no match is found
|
|
1050
|
+
* or if the body model is not an instance of AreaModelObjectArray.
|
|
1051
|
+
*
|
|
1052
|
+
* @example
|
|
1053
|
+
* ```typescript
|
|
1054
|
+
* interface Person {
|
|
1055
|
+
* id: number;
|
|
1056
|
+
* name: string;
|
|
1057
|
+
* age: number;
|
|
1058
|
+
* }
|
|
1059
|
+
*
|
|
1060
|
+
* // Find a person by exact match
|
|
1061
|
+
* const criteria = { name: "John", age: 30 };
|
|
1062
|
+
* const person = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1063
|
+
* criteria,
|
|
1064
|
+
* (criteria, row) => row.name === criteria.name && row.age === criteria.age
|
|
1065
|
+
* );
|
|
1066
|
+
*
|
|
1067
|
+
* // Find a person by partial name match
|
|
1068
|
+
* const searchCriteria = { name: "Jo" };
|
|
1069
|
+
* const person2 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1070
|
+
* searchCriteria,
|
|
1071
|
+
* (criteria, row) => row.name.toLowerCase().includes(criteria.name!.toLowerCase())
|
|
1072
|
+
* );
|
|
1073
|
+
*
|
|
1074
|
+
* // Find a person within age range
|
|
1075
|
+
* const ageCriteria = { minAge: 25, maxAge: 35 };
|
|
1076
|
+
* const person3 = tableApi.findRowFromFilteredRowsByAllCriteria<Person>(
|
|
1077
|
+
* ageCriteria,
|
|
1078
|
+
* (criteria, row) => row.age >= criteria.minAge! && row.age <= criteria.maxAge!
|
|
1079
|
+
* );
|
|
1080
|
+
* ```
|
|
1081
|
+
*
|
|
1082
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1083
|
+
*
|
|
1084
|
+
* @remarks
|
|
1085
|
+
* - This method only searches through filtered rows (rows that are currently visible in the table)
|
|
1086
|
+
* - If you need to search through all rows (including filtered out ones), use findRowFromAllRowsByAllCriteria instead
|
|
1087
|
+
* - The predicate function gives you full control over how to match rows against your criteria
|
|
1088
|
+
* - Returns undefined if either no match is found or if the table's body model is not compatible
|
|
1089
|
+
*/
|
|
1090
|
+
findRowFromFilteredRowsByAllCriteria(e, t) {
|
|
1091
|
+
const s = this.getBodyModel();
|
|
1092
|
+
if (s instanceof F)
|
|
1093
|
+
return s.getFilteredRows().find((i) => t(e, i));
|
|
1094
|
+
console.warn("findRowFromFilteredRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Searches through all rows in the table's body model to find a row that matches specified criteria.
|
|
1098
|
+
* This method works only with AreaModelObjectArray<T> body models.
|
|
1099
|
+
*
|
|
1100
|
+
* @template T - The type of objects/rows in the table
|
|
1101
|
+
*
|
|
1102
|
+
* @param {Partial<T>} criteria - A partial object containing the search criteria.
|
|
1103
|
+
* Only needs to include the properties you want to match against.
|
|
1104
|
+
*
|
|
1105
|
+
* @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that defines how to match rows against the criteria.
|
|
1106
|
+
* Returns true if the row matches the criteria, false otherwise.
|
|
1107
|
+
*
|
|
1108
|
+
* @returns {T | undefined} The first matching row, or undefined if no match is found or if the body model is not AreaModelObjectArray.
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* // Find a user row by id and name
|
|
1112
|
+
* const criteria = { id: 1, name: "John" };
|
|
1113
|
+
* const user = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1114
|
+
* (criteria, row) => row.id === criteria.id && row.name === criteria.name
|
|
1115
|
+
* );
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* // Find a product row with partial match on name
|
|
1119
|
+
* const criteria = { name: "Phone" };
|
|
1120
|
+
* const product = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1121
|
+
* (criteria, row) => row.name.includes(criteria.name)
|
|
1122
|
+
* );
|
|
1123
|
+
*
|
|
1124
|
+
* @example
|
|
1125
|
+
* // Find an order with complex matching logic
|
|
1126
|
+
* const criteria = { total: 100, status: "pending" };
|
|
1127
|
+
* const order = tableApi.findRowFromAllRowsByAllCriteria(criteria,
|
|
1128
|
+
* (criteria, row) => {
|
|
1129
|
+
* return row.total > criteria.total &&
|
|
1130
|
+
* row.status === criteria.status &&
|
|
1131
|
+
* row.items.length > 0;
|
|
1132
|
+
* }
|
|
1133
|
+
* );
|
|
1134
|
+
*
|
|
1135
|
+
* @throws {Warning} Logs a warning to console if the body model is not an instance of AreaModelObjectArray
|
|
1136
|
+
*/
|
|
1137
|
+
findRowFromAllRowsByAllCriteria(e, t) {
|
|
1138
|
+
const s = this.getBodyModel();
|
|
1139
|
+
if (s instanceof F)
|
|
1140
|
+
return s.getAllRows().find((i) => t(e, i));
|
|
1141
|
+
console.warn("findRowFromAllRowsByAllCriteria(...) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Updates existing rows in the table body with new data.
|
|
1145
|
+
*
|
|
1146
|
+
* @template T - The type of elements in the rows array
|
|
1147
|
+
* @param {T[]} rows - An array of data objects containing the updated values
|
|
1148
|
+
* @param {(a: T, b: T) => boolean} predicate - A comparison function that determines which rows to update
|
|
1149
|
+
* - Default predicate uses strict equality (===)
|
|
1150
|
+
* - The function should return true if the row should be updated
|
|
1151
|
+
*
|
|
1152
|
+
* @description
|
|
1153
|
+
* This method updates existing rows in the table body with new values from the provided rows array.
|
|
1154
|
+
* For each row in the table, if the predicate returns true when compared with any row in the provided array,
|
|
1155
|
+
* all properties from the provided row will be copied to the existing row.
|
|
1156
|
+
* It only works with tables that use AreaModelObjectArray as their body model.
|
|
1157
|
+
*
|
|
1158
|
+
* @return {void} - This method doesn't return anything.
|
|
1159
|
+
*
|
|
1160
|
+
* @throws {Warning} Logs a console warning if the table's body model is not an AreaModelObjectArray
|
|
1161
|
+
*/
|
|
873
1162
|
updateRows(e, t = (s, o) => s === o) {
|
|
874
1163
|
const s = this.getBodyModel();
|
|
875
1164
|
if (s instanceof F) {
|
|
@@ -882,12 +1171,165 @@ class ge {
|
|
|
882
1171
|
} else
|
|
883
1172
|
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);
|
|
884
1173
|
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Re-applies the current sorting configuration to the table data.
|
|
1176
|
+
*
|
|
1177
|
+
* @description
|
|
1178
|
+
* This method triggers a re-sort of the table data using the current sorting configuration.
|
|
1179
|
+
* It's useful when the underlying data has changed and needs to be re-sorted without changing
|
|
1180
|
+
* the sort columns or direction.
|
|
1181
|
+
*
|
|
1182
|
+
* @return {void} - This method doesn't return anything.
|
|
1183
|
+
*/
|
|
885
1184
|
reSort() {
|
|
886
1185
|
this.tableScope.reSort();
|
|
887
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Sorts the table data using a custom comparison function.
|
|
1189
|
+
*
|
|
1190
|
+
* This method allows sorting of table rows by providing a custom comparison function. The comparison function
|
|
1191
|
+
* should follow the standard JavaScript array sort comparator pattern, returning:
|
|
1192
|
+
* - A negative number if the first element should be sorted before the second
|
|
1193
|
+
* - A positive number if the first element should be sorted after the second
|
|
1194
|
+
* - Zero if the elements are equal
|
|
1195
|
+
*
|
|
1196
|
+
* @param compareFn - A function that defines the sort order. The function should accept two arguments
|
|
1197
|
+
* and return a number indicating their relative order:
|
|
1198
|
+
* - Negative number: first argument should come before second
|
|
1199
|
+
* - Positive number: second argument should come before first
|
|
1200
|
+
* - Zero: elements are equal
|
|
1201
|
+
*
|
|
1202
|
+
* @example
|
|
1203
|
+
* // Sort table rows by a specific property in ascending order
|
|
1204
|
+
* table.api.sort((a, b) => {
|
|
1205
|
+
* if (a.name < b.name) return -1;
|
|
1206
|
+
* if (a.name > b.name) return 1;
|
|
1207
|
+
* return 0;
|
|
1208
|
+
* });
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // Sort numbers in descending order
|
|
1212
|
+
* table.api.sort((a, b) => b.value - a.value);
|
|
1213
|
+
*
|
|
1214
|
+
* @example
|
|
1215
|
+
* // Sort with multiple criteria
|
|
1216
|
+
* table.api.sort((a, b) => {
|
|
1217
|
+
* // First sort by status
|
|
1218
|
+
* const statusCompare = a.status.localeCompare(b.status);
|
|
1219
|
+
* if (statusCompare !== 0) return statusCompare;
|
|
1220
|
+
*
|
|
1221
|
+
* // Then sort by name if status is equal
|
|
1222
|
+
* return a.name.localeCompare(b.name);
|
|
1223
|
+
* });
|
|
1224
|
+
*
|
|
1225
|
+
* @example
|
|
1226
|
+
* // Case-insensitive string sorting
|
|
1227
|
+
* table.api.sort((a, b) =>
|
|
1228
|
+
* a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
|
1229
|
+
* );
|
|
1230
|
+
*/
|
|
1231
|
+
sort(e) {
|
|
1232
|
+
this.tableScope.sort(e);
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
1236
|
+
* This method checks if the target row is within the currently visible range and
|
|
1237
|
+
* adjusts the scroll position if it's not visible.
|
|
1238
|
+
*
|
|
1239
|
+
* The method performs the following:
|
|
1240
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
1241
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
1242
|
+
* 3. Scrolls to make the row visible if needed
|
|
1243
|
+
*
|
|
1244
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
1245
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* // Ensure row 5 is visible in the viewport
|
|
1249
|
+
* tableApi.ensureRowIsVisible(5);
|
|
1250
|
+
*
|
|
1251
|
+
* @example
|
|
1252
|
+
* // Example usage in a component
|
|
1253
|
+
* class MyTableComponent {
|
|
1254
|
+
* private tableApi: TableApi;
|
|
1255
|
+
*
|
|
1256
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
1257
|
+
* // This will scroll the row into view if it's not visible
|
|
1258
|
+
* const didScroll = this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1259
|
+
*
|
|
1260
|
+
* if (didScroll) {
|
|
1261
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
1262
|
+
* } else {
|
|
1263
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
1264
|
+
* }
|
|
1265
|
+
* }
|
|
1266
|
+
* }
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* // Example with row selection
|
|
1270
|
+
* class TableHandler {
|
|
1271
|
+
* selectAndShowRow(rowIndex: number) {
|
|
1272
|
+
* // First ensure the row is visible
|
|
1273
|
+
* this.tableApi.ensureRowIsVisible(rowIndex);
|
|
1274
|
+
*
|
|
1275
|
+
* // Then perform selection
|
|
1276
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
1277
|
+
* }
|
|
1278
|
+
* }
|
|
1279
|
+
*
|
|
1280
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
1281
|
+
*
|
|
1282
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
1283
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
1284
|
+
*/
|
|
1285
|
+
ensureRowIsVisible(e) {
|
|
1286
|
+
return this.tableScope.ensureRowIsVisible(e);
|
|
1287
|
+
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Retrieves the number of rows currently displayed in the table.
|
|
1290
|
+
*
|
|
1291
|
+
* @description
|
|
1292
|
+
* This method returns the count of rows that are currently visible in the table after
|
|
1293
|
+
* applying any filtering, pagination, or other visibility constraints.
|
|
1294
|
+
*
|
|
1295
|
+
* @return {number} The number of rows currently displayed in the table.
|
|
1296
|
+
*/
|
|
888
1297
|
getDisplayedRowCount() {
|
|
889
1298
|
return this.tableScope.getDisplayedRowCount();
|
|
890
1299
|
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Returns the index of the first visible row in the table's viewport.
|
|
1302
|
+
*
|
|
1303
|
+
* This method retrieves the first visible row index from the table's scope, which is useful
|
|
1304
|
+
* for virtual scrolling and viewport-related calculations. The index represents the topmost
|
|
1305
|
+
* visible row in the current scroll position of the table.
|
|
1306
|
+
*
|
|
1307
|
+
* This value is maintained internally by the table and updated during scrolling operations.
|
|
1308
|
+
* It's particularly important for:
|
|
1309
|
+
* - Virtual scrolling optimization
|
|
1310
|
+
* - Calculating visible range of rows
|
|
1311
|
+
* - Viewport-related operations
|
|
1312
|
+
* - Scroll position restoration
|
|
1313
|
+
*
|
|
1314
|
+
* @returns {number} The index of the first visible row in the table's viewport.
|
|
1315
|
+
* Returns -1 if no rows are visible or if the table is not yet rendered.
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```typescript
|
|
1319
|
+
* // Get the first visible row index
|
|
1320
|
+
* const tableApi = new TableApi(tableScope);
|
|
1321
|
+
* const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
|
|
1322
|
+
*
|
|
1323
|
+
* // Use the index for scroll position calculations
|
|
1324
|
+
* if (firstVisibleIndex >= 0) {
|
|
1325
|
+
* // Perform operations with the first visible row
|
|
1326
|
+
* console.log(`First visible row index: ${firstVisibleIndex}`);
|
|
1327
|
+
* }
|
|
1328
|
+
* ```
|
|
1329
|
+
*/
|
|
1330
|
+
getFirstVisibleRowIndex() {
|
|
1331
|
+
return this.tableScope.getFirstVisibleRowIndex();
|
|
1332
|
+
}
|
|
891
1333
|
}
|
|
892
1334
|
class z {
|
|
893
1335
|
constructor(e) {
|
|
@@ -1214,7 +1656,7 @@ class Se {
|
|
|
1214
1656
|
this.dom.setStyle(this.contentWrapperDiv, "width", e), this.dom.setStyle(this.contentWrapperDiv, "height", t);
|
|
1215
1657
|
}
|
|
1216
1658
|
}
|
|
1217
|
-
class
|
|
1659
|
+
class A {
|
|
1218
1660
|
/**
|
|
1219
1661
|
* Represents a constructor for a class.
|
|
1220
1662
|
* @constructor
|
|
@@ -1228,7 +1670,7 @@ class E {
|
|
|
1228
1670
|
this.r1 = e, this.c1 = t, this.r2 = s, this.c2 = o, this.gammaRange = i;
|
|
1229
1671
|
}
|
|
1230
1672
|
static create(e) {
|
|
1231
|
-
return e.gammaRange === void 0 && (e.gammaRange = !1), new
|
|
1673
|
+
return e.gammaRange === void 0 && (e.gammaRange = !1), new A(
|
|
1232
1674
|
e.rowIndex1,
|
|
1233
1675
|
e.columnIndex1,
|
|
1234
1676
|
e.rowIndex2,
|
|
@@ -1237,13 +1679,13 @@ class E {
|
|
|
1237
1679
|
);
|
|
1238
1680
|
}
|
|
1239
1681
|
static singleCell(e, t) {
|
|
1240
|
-
return new
|
|
1682
|
+
return new A(e, t, e, t);
|
|
1241
1683
|
}
|
|
1242
1684
|
static singleRow(e) {
|
|
1243
|
-
return new
|
|
1685
|
+
return new A(e, 0, e, Number.MAX_SAFE_INTEGER);
|
|
1244
1686
|
}
|
|
1245
1687
|
static singleColumn(e) {
|
|
1246
|
-
return new
|
|
1688
|
+
return new A(0, e, Number.MAX_SAFE_INTEGER, e);
|
|
1247
1689
|
}
|
|
1248
1690
|
isInRange(e, t) {
|
|
1249
1691
|
return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
|
|
@@ -1265,7 +1707,7 @@ class ye {
|
|
|
1265
1707
|
i === 0 && (i = 1), r === 0 && (r = 1);
|
|
1266
1708
|
const l = "gammaCells" in this.areaModel;
|
|
1267
1709
|
this.colAndRowspanRanges.push(
|
|
1268
|
-
new
|
|
1710
|
+
new A(s, o, s + r - 1, o + i - 1, l)
|
|
1269
1711
|
);
|
|
1270
1712
|
}
|
|
1271
1713
|
}
|
|
@@ -1282,19 +1724,19 @@ class ye {
|
|
|
1282
1724
|
return !1;
|
|
1283
1725
|
}
|
|
1284
1726
|
}
|
|
1285
|
-
class
|
|
1727
|
+
class we {
|
|
1286
1728
|
constructor(e, t, s) {
|
|
1287
1729
|
this.header = e, this.body = t, this.footer = s;
|
|
1288
1730
|
}
|
|
1289
1731
|
}
|
|
1290
|
-
class
|
|
1732
|
+
class xe extends Se {
|
|
1291
1733
|
constructor(e, t, s, o) {
|
|
1292
1734
|
var r, l;
|
|
1293
1735
|
super(e, t, s, o), this.dragging = !1, this.editing = !1, this.storedColumnWidths = [], this.scrollLeft = 0, this.scrollViewportLeft = 0, this.scrollFactorY = 0, this.scrollFactorX = 0, this.cleanupFunctions = {
|
|
1294
1736
|
header: [],
|
|
1295
1737
|
body: [],
|
|
1296
1738
|
footer: []
|
|
1297
|
-
}, this.tree = !1, this.colAndRowspanModels = new
|
|
1739
|
+
}, this.tree = !1, this.colAndRowspanModels = new we(), 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), (l = this.tableOptions) != null && l.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), V(t.getAreaModel("body")) && (this.tree = !0), ["header", "body", "footer"].forEach(
|
|
1298
1740
|
(a) => {
|
|
1299
1741
|
var n;
|
|
1300
1742
|
this.colAndRowspanModels[a] = new ye(t, t.getAreaModel(a)), (n = this.colAndRowspanModels[a]) == null || n.init();
|
|
@@ -1559,38 +2001,38 @@ class we extends Se {
|
|
|
1559
2001
|
let d = t;
|
|
1560
2002
|
const u = this.tableModel.getColumnCount(), g = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
|
|
1561
2003
|
for (let m = 0; m < h; m++) {
|
|
1562
|
-
const
|
|
1563
|
-
if (
|
|
2004
|
+
const w = d, S = m === h - 1, v = this.tableModel.getRowHeight(e, m);
|
|
2005
|
+
if (w + v > 0) {
|
|
1564
2006
|
this.firstVisibleRowIndex = m;
|
|
1565
|
-
let
|
|
2007
|
+
let x = { left: l, width: a, height: v, top: w, index: m }, y = this.dom.addRowDiv(o, x, m, e, "center");
|
|
1566
2008
|
const M = b;
|
|
1567
2009
|
if (this.adjustColumnsToRowParent({
|
|
1568
2010
|
areaIdent: e,
|
|
1569
2011
|
sideIdent: "center",
|
|
1570
2012
|
areaModel: c,
|
|
1571
|
-
geo:
|
|
2013
|
+
geo: x,
|
|
1572
2014
|
parent: y,
|
|
1573
2015
|
rowIndex: m,
|
|
1574
2016
|
columnIndexStart: M,
|
|
1575
2017
|
columnIndexEnd: u - g - 1,
|
|
1576
2018
|
verticalFixed: !1,
|
|
1577
2019
|
lastRowOfModel: S
|
|
1578
|
-
}), n.left > 0 && (
|
|
2020
|
+
}), n.left > 0 && (x = { left: l, width: this.areaBodyWestGeo.width, height: v, top: w, index: m }, y = this.dom.addRowDiv(s, x, m, e, "west"), this.adjustColumnsToRowParent({
|
|
1579
2021
|
areaIdent: e,
|
|
1580
2022
|
sideIdent: "west",
|
|
1581
2023
|
areaModel: c,
|
|
1582
|
-
geo:
|
|
2024
|
+
geo: x,
|
|
1583
2025
|
parent: y,
|
|
1584
2026
|
rowIndex: m,
|
|
1585
2027
|
columnIndexStart: 0,
|
|
1586
2028
|
columnIndexEnd: M - 1,
|
|
1587
2029
|
verticalFixed: !0,
|
|
1588
2030
|
lastRowOfModel: S
|
|
1589
|
-
})), n.right > 0 && (
|
|
2031
|
+
})), n.right > 0 && (x = { left: l, width: this.areaBodyEastGeo.width, height: v, top: w, index: m }, y = this.dom.addRowDiv(i, x, m, e, "east"), this.adjustColumnsToRowParent({
|
|
1590
2032
|
areaIdent: e,
|
|
1591
2033
|
sideIdent: "east",
|
|
1592
2034
|
areaModel: c,
|
|
1593
|
-
geo:
|
|
2035
|
+
geo: x,
|
|
1594
2036
|
parent: y,
|
|
1595
2037
|
rowIndex: m,
|
|
1596
2038
|
columnIndexStart: u - g,
|
|
@@ -1598,7 +2040,7 @@ class we extends Se {
|
|
|
1598
2040
|
verticalFixed: !0,
|
|
1599
2041
|
lastRowOfModel: S
|
|
1600
2042
|
})), e === "header" && this.tree && m === h - 1) {
|
|
1601
|
-
const
|
|
2043
|
+
const E = this.dom.applyStyle(
|
|
1602
2044
|
this.dom.setAttribute(
|
|
1603
2045
|
this.dom.addDiv(y, new T(16, 20, 20, 8)),
|
|
1604
2046
|
"data-ge-action",
|
|
@@ -1607,8 +2049,8 @@ class we extends Se {
|
|
|
1607
2049
|
{ cursor: "pointer" }
|
|
1608
2050
|
), R = this.tableOptions.treeOptions.arrowExpandCollapseAll;
|
|
1609
2051
|
if (R) {
|
|
1610
|
-
const
|
|
1611
|
-
this.dom.domService.appendChild(
|
|
2052
|
+
const L = this.dom.domService.createText(R.content);
|
|
2053
|
+
this.dom.domService.appendChild(E, L), R.style && this.dom.applyStyleString(E, R.style);
|
|
1612
2054
|
}
|
|
1613
2055
|
}
|
|
1614
2056
|
}
|
|
@@ -1620,17 +2062,17 @@ class we extends Se {
|
|
|
1620
2062
|
if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
|
|
1621
2063
|
const m = ((f = this.colAndRowspanModels[e]) == null ? void 0 : f.getRanges()) ?? [];
|
|
1622
2064
|
if (m.length)
|
|
1623
|
-
for (const
|
|
1624
|
-
let S = 0, v = o.child,
|
|
1625
|
-
if (
|
|
1626
|
-
v = s.child,
|
|
1627
|
-
else if (g > 0 &&
|
|
1628
|
-
v = i.child,
|
|
2065
|
+
for (const w of m) {
|
|
2066
|
+
let S = 0, v = o.child, x = "center";
|
|
2067
|
+
if (w.c1 < b)
|
|
2068
|
+
v = s.child, x = "west";
|
|
2069
|
+
else if (g > 0 && w.c1 >= u - g)
|
|
2070
|
+
v = i.child, x = "east";
|
|
1629
2071
|
else {
|
|
1630
2072
|
const y = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1631
|
-
S = this.scrollFactorX * y - this.areaBodyWestGeo.width,
|
|
2073
|
+
S = this.scrollFactorX * y - this.areaBodyWestGeo.width, x = "center";
|
|
1632
2074
|
}
|
|
1633
|
-
this.drawBigCell(
|
|
2075
|
+
this.drawBigCell(w, S, t, c, v, x);
|
|
1634
2076
|
}
|
|
1635
2077
|
}
|
|
1636
2078
|
}
|
|
@@ -1738,20 +2180,20 @@ class we extends Se {
|
|
|
1738
2180
|
const d = 0, u = !!(e === "body" && t);
|
|
1739
2181
|
let g = h;
|
|
1740
2182
|
for (let f = l; f <= a; f++) {
|
|
1741
|
-
const m = g,
|
|
1742
|
-
if (
|
|
2183
|
+
const m = g, w = this.tableModel.getColumnWidth(f);
|
|
2184
|
+
if (w > 0 && m + w > 0) {
|
|
1743
2185
|
let S = o.height;
|
|
1744
|
-
const v = s.getRowspanAt(r, f),
|
|
1745
|
-
v > 1 && (S = this.getRowHeights(r, r + v - 1, s).reduce((
|
|
1746
|
-
let y =
|
|
1747
|
-
|
|
2186
|
+
const v = s.getRowspanAt(r, f), x = s.getColspanAt(r, f);
|
|
2187
|
+
v > 1 && (S = this.getRowHeights(r, r + v - 1, s).reduce((E, R) => E + R, 0));
|
|
2188
|
+
let y = w;
|
|
2189
|
+
x > 1 && (y = this.getColumnWidths(f, f + x - 1).reduce((E, R) => E + R, 0));
|
|
1748
2190
|
let M = !1;
|
|
1749
2191
|
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (M = !0), this.draggingTargetColumnIndex === f && e !== "header") {
|
|
1750
2192
|
this.renderDragTargetDiv(i, m, d, y, S);
|
|
1751
|
-
const
|
|
1752
|
-
this.dom.addColumnBorderDivs(this.tableOptions, i,
|
|
2193
|
+
const E = { left: m, top: d, width: y, height: S };
|
|
2194
|
+
this.dom.addColumnBorderDivs(this.tableOptions, i, E, e, t);
|
|
1753
2195
|
} else {
|
|
1754
|
-
const
|
|
2196
|
+
const E = this.renderSelectedBackgroundDiv(M, u, t, s, r, f, i, m, d, y, S);
|
|
1755
2197
|
"gammaCells" in s && s.getValueAt(r, f) && (M = !1), M || this.renderCell({
|
|
1756
2198
|
areaModel: s,
|
|
1757
2199
|
areaIdent: e,
|
|
@@ -1763,7 +2205,7 @@ class we extends Se {
|
|
|
1763
2205
|
width: y,
|
|
1764
2206
|
height: S,
|
|
1765
2207
|
parent: i,
|
|
1766
|
-
cellSelected:
|
|
2208
|
+
cellSelected: E,
|
|
1767
2209
|
lastRowOfModel: c,
|
|
1768
2210
|
gammaRange: !0
|
|
1769
2211
|
}), e === "header" && this.tableOptions.columnsResizable && this.renderHeaderCellResizeHandle({
|
|
@@ -1777,7 +2219,7 @@ class we extends Se {
|
|
|
1777
2219
|
});
|
|
1778
2220
|
}
|
|
1779
2221
|
}
|
|
1780
|
-
if (g = g +
|
|
2222
|
+
if (g = g + w, g > this.areaBodyCenterGeo.width)
|
|
1781
2223
|
break;
|
|
1782
2224
|
}
|
|
1783
2225
|
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(g - 1, 1, o.height, 0), i);
|
|
@@ -1814,12 +2256,12 @@ class we extends Se {
|
|
|
1814
2256
|
const C = b;
|
|
1815
2257
|
(j = C.children) != null && j.length ? C.expanded ? f = "expanded" : f = "collapsed" : f = "hidden";
|
|
1816
2258
|
}
|
|
1817
|
-
let
|
|
2259
|
+
let w;
|
|
1818
2260
|
if (t === "header") {
|
|
1819
2261
|
const C = this.tableModel.getColumnDef(i);
|
|
1820
|
-
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (
|
|
2262
|
+
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (w = C == null ? void 0 : C.sortState);
|
|
1821
2263
|
}
|
|
1822
|
-
const S = e.getValueAt(o, i), v = u ? "" : `${S}`,
|
|
2264
|
+
const S = e.getValueAt(o, i), v = u ? "" : `${S}`, x = e.isRowChecked(o), y = this.dom.addColumnDiv(
|
|
1823
2265
|
{
|
|
1824
2266
|
parent: c,
|
|
1825
2267
|
geo: g,
|
|
@@ -1830,17 +2272,17 @@ class we extends Se {
|
|
|
1830
2272
|
text: v,
|
|
1831
2273
|
treeArrow: f,
|
|
1832
2274
|
tableOptions: this.tableOptions,
|
|
1833
|
-
checkedType:
|
|
1834
|
-
sortState:
|
|
2275
|
+
checkedType: x,
|
|
2276
|
+
sortState: w
|
|
1835
2277
|
}
|
|
1836
2278
|
), M = e.getTooltipAt(o, i);
|
|
1837
2279
|
M && this.dom.setAttribute(y, "title", M);
|
|
1838
|
-
const
|
|
1839
|
-
|
|
2280
|
+
const E = this.tableModel.getColumnDef(i);
|
|
2281
|
+
E && E.classes[t] && this.dom.addClasses(E.classes[t], y);
|
|
1840
2282
|
let R;
|
|
1841
2283
|
u && (R = u.render(y, o, i, t, e, S, this.dom.domService));
|
|
1842
|
-
const
|
|
1843
|
-
if (
|
|
2284
|
+
const L = e.getCustomClassesAt(o, i);
|
|
2285
|
+
if (L.length && this.dom.addClasses(L, y), this.dom.addColumnBorderDivs(this.tableOptions, c, g, t, s), h && this.dom.addHorizontalBorder({ left: r, width: l, height: a, top: n + a }, c), this.getFocusModel && t === "body") {
|
|
1844
2286
|
const C = this.getFocusModel();
|
|
1845
2287
|
C != null && C.hasFocus(o, i) && this.dom.addFocusBorderDivs(c, g, {});
|
|
1846
2288
|
}
|
|
@@ -2024,16 +2466,16 @@ class we extends Se {
|
|
|
2024
2466
|
sideIdent: o,
|
|
2025
2467
|
text: b
|
|
2026
2468
|
}, m = this.dom.addColumnDiv(f);
|
|
2027
|
-
let
|
|
2028
|
-
g && (
|
|
2469
|
+
let w;
|
|
2470
|
+
g && (w = g.render(m, n, l, t, i, u, this.dom.domService), w && this.cleanupFunctions[t].push(w));
|
|
2029
2471
|
const S = i.getCustomClassesAt(n, l);
|
|
2030
2472
|
S.length && this.dom.addClasses(S, m);
|
|
2031
2473
|
const v = this.tableModel.getColumnDef(l);
|
|
2032
2474
|
v && v.classes[t] && this.dom.addClasses(v.classes[t], m), this.dom.addColumnBorderDivs(this.tableOptions, a, d, t, o);
|
|
2033
|
-
const
|
|
2034
|
-
if (
|
|
2035
|
-
for (const y in
|
|
2036
|
-
this.dom.setStyle(m, y,
|
|
2475
|
+
const x = i.getCustomStyleAt(n, l);
|
|
2476
|
+
if (x)
|
|
2477
|
+
for (const y in x)
|
|
2478
|
+
this.dom.setStyle(m, y, x[y]);
|
|
2037
2479
|
s = s + h;
|
|
2038
2480
|
}
|
|
2039
2481
|
}
|
|
@@ -2195,7 +2637,7 @@ class ve {
|
|
|
2195
2637
|
}
|
|
2196
2638
|
}
|
|
2197
2639
|
}
|
|
2198
|
-
class
|
|
2640
|
+
class Ae {
|
|
2199
2641
|
constructor(e = -1, t = -1) {
|
|
2200
2642
|
this.rowIndex = e, this.columnIndex = t;
|
|
2201
2643
|
}
|
|
@@ -2205,10 +2647,10 @@ class G {
|
|
|
2205
2647
|
this.cells = e;
|
|
2206
2648
|
}
|
|
2207
2649
|
static createSingle(e, t) {
|
|
2208
|
-
return new G([new
|
|
2650
|
+
return new G([new Ae(e, t)]);
|
|
2209
2651
|
}
|
|
2210
2652
|
}
|
|
2211
|
-
class
|
|
2653
|
+
class Ee {
|
|
2212
2654
|
constructor(e) {
|
|
2213
2655
|
var t, s;
|
|
2214
2656
|
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);
|
|
@@ -2218,7 +2660,7 @@ class Ae {
|
|
|
2218
2660
|
let s = !1, o = !1;
|
|
2219
2661
|
if (this.getSelectionModel && this.getFocusModel) {
|
|
2220
2662
|
const d = this.getSelectionModel(), u = this.getFocusModel();
|
|
2221
|
-
d && u && (u.hasFocus(e.rowIndex, e.columnIndex) || (u.setFocus(e.rowIndex, e.columnIndex), this.tableScope.onFocusChanged(u), s = !0), (i = e.originalEvent) != null && i.shiftKey || d.hasSelection() && (d.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (d.addSelection(this.createRangeByEvents(e, this.previousEvt)), o = !0, s = !0) : (l = e.originalEvent) != null && l.altKey && ((a = e.originalEvent) != null && a.ctrlKey || (n = e.originalEvent) != null && n.metaKey) ? (d.removeSelection(
|
|
2663
|
+
d && u && (u.hasFocus(e.rowIndex, e.columnIndex) || (u.setFocus(e.rowIndex, e.columnIndex), this.tableScope.onFocusChanged(u), s = !0), (i = e.originalEvent) != null && i.shiftKey || d.hasSelection() && (d.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (d.addSelection(this.createRangeByEvents(e, this.previousEvt)), o = !0, s = !0) : (l = e.originalEvent) != null && l.altKey && ((a = e.originalEvent) != null && a.ctrlKey || (n = e.originalEvent) != null && n.metaKey) ? (d.removeSelection(A.singleCell(e.rowIndex, e.columnIndex)), o = !0, s = !0) : (c = e.originalEvent) != null && c.ctrlKey || (h = e.originalEvent) != null && h.metaKey ? (d.addSelection(A.singleCell(e.rowIndex, e.columnIndex)), o = !0, s = !0) : (d.firstClick(e.rowIndex, e.columnIndex), s = !0), this.tableScope.onSelectionChanged(d));
|
|
2222
2664
|
}
|
|
2223
2665
|
return o ? this.previousEvt = void 0 : this.previousEvt = e == null ? void 0 : e.clone(), s;
|
|
2224
2666
|
}
|
|
@@ -2241,7 +2683,7 @@ class Ae {
|
|
|
2241
2683
|
createRangeByEvents(e, t) {
|
|
2242
2684
|
t || (t = e);
|
|
2243
2685
|
const s = Math.min(e.rowIndex, t == null ? void 0 : t.rowIndex), o = Math.max(e.rowIndex, t == null ? void 0 : t.rowIndex), i = Math.min(e.columnIndex, t == null ? void 0 : t.columnIndex), r = Math.max(e.columnIndex, t == null ? void 0 : t.columnIndex);
|
|
2244
|
-
return
|
|
2686
|
+
return A.create({
|
|
2245
2687
|
rowIndex1: s,
|
|
2246
2688
|
columnIndex1: i,
|
|
2247
2689
|
rowIndex2: o,
|
|
@@ -2449,7 +2891,7 @@ class ee {
|
|
|
2449
2891
|
e.setAttribute(t, s);
|
|
2450
2892
|
}
|
|
2451
2893
|
}
|
|
2452
|
-
class
|
|
2894
|
+
class Fe {
|
|
2453
2895
|
render(e, t, s, o, i, r, l) {
|
|
2454
2896
|
if (i.isEditable(t, s)) {
|
|
2455
2897
|
l.addClass(e, "ge-table-row-input-div");
|
|
@@ -2470,7 +2912,7 @@ class ke {
|
|
|
2470
2912
|
}
|
|
2471
2913
|
}
|
|
2472
2914
|
}
|
|
2473
|
-
class
|
|
2915
|
+
class ke {
|
|
2474
2916
|
constructor(e = "none", t = "single") {
|
|
2475
2917
|
this.selectionType = e, this.selectionMode = t, this.ranges = [], this.negativeRanges = [], this.allSelected = !1, this.silent = !1, this.listenerArr = [];
|
|
2476
2918
|
}
|
|
@@ -2489,7 +2931,7 @@ class Fe {
|
|
|
2489
2931
|
this.silent || this.listenerArr.forEach((e) => e.onSelectionChanged(this));
|
|
2490
2932
|
}
|
|
2491
2933
|
firstClick(e, t) {
|
|
2492
|
-
this.selectionType === "row" ? this.addRange(
|
|
2934
|
+
this.selectionType === "row" ? this.addRange(A.singleRow(e)) : this.selectionType === "column" && this.addRange(A.singleColumn(t));
|
|
2493
2935
|
}
|
|
2494
2936
|
getSelectionCount(e, t) {
|
|
2495
2937
|
let s = 0;
|
|
@@ -2540,10 +2982,10 @@ class Fe {
|
|
|
2540
2982
|
if (this.selectionType === "none")
|
|
2541
2983
|
return;
|
|
2542
2984
|
let t = e;
|
|
2543
|
-
this.selectionType === "row" ? t =
|
|
2985
|
+
this.selectionType === "row" ? t = A.singleRow(e.r1) : this.selectionType === "column" && (t = A.singleColumn(e.c1)), this.negativeRanges.push(t), this.fireChangeEvent();
|
|
2544
2986
|
}
|
|
2545
2987
|
togglePoint(e, t) {
|
|
2546
|
-
this.getSelectionCount(e, t) > 0 ? this.removeSelection(
|
|
2988
|
+
this.getSelectionCount(e, t) > 0 ? this.removeSelection(A.singleCell(e, t)) : this.addSelection(A.singleCell(e, t));
|
|
2547
2989
|
}
|
|
2548
2990
|
isSelected(e, t) {
|
|
2549
2991
|
return this.getSelectionCount(e, t) > 0;
|
|
@@ -2603,17 +3045,17 @@ class te {
|
|
|
2603
3045
|
}
|
|
2604
3046
|
// `⊖ `, `⊕ `;
|
|
2605
3047
|
}
|
|
2606
|
-
const
|
|
3048
|
+
const Oe = new ke(), Le = new Ie("cell");
|
|
2607
3049
|
class se {
|
|
2608
3050
|
constructor() {
|
|
2609
3051
|
this.overflowX = "auto", this.overflowY = "auto", this.horizontalBorderVisible = !0, this.verticalBorderVisible = !0, this.footerSeparatorBorderVisible = !0, this.headerSeparatorBorderVisible = !0, this.fixedEastSeparatorBorderVisible = !0, this.fixedWestSeparatorBorderVisible = !0, this.tableTopBorderVisible = !0, this.tableBottomBorderVisible = !0, this.hoverRowVisible = !0, this.hoverColumnVisible = !0, this.columnsResizable = !0, this.columnsDraggable = !0, this.columnResizeHandleWidthInPx = 4, this.defaultRowHeights = {
|
|
2610
3052
|
header: 34,
|
|
2611
3053
|
body: 34,
|
|
2612
3054
|
footer: 34
|
|
2613
|
-
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new Z(), this.headerGroupOptions = new te(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new Q(), this.sortOrder = ["asc", "desc"], this.shortcutActionsDisabled = !1, this.resizeEventDebounceDelay = 500, this.getEditRenderer = (e, t) => new
|
|
3055
|
+
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new Z(), this.headerGroupOptions = new te(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new Q(), this.sortOrder = ["asc", "desc"], this.shortcutActionsDisabled = !1, this.resizeEventDebounceDelay = 500, this.getEditRenderer = (e, t) => new Fe(), this.getSelectionModel = () => Oe, this.getFocusModel = () => Le;
|
|
2614
3056
|
}
|
|
2615
3057
|
}
|
|
2616
|
-
const
|
|
3058
|
+
const O = class O {
|
|
2617
3059
|
/**
|
|
2618
3060
|
* Returns the content to be copied based on the provided table model, selection model, and focus model.
|
|
2619
3061
|
*
|
|
@@ -2636,9 +3078,9 @@ const L = class L {
|
|
|
2636
3078
|
const h = t.isSelected(a, c) ? e.getBodyModel().getTextValueAt(a, c) : "";
|
|
2637
3079
|
n.push(h);
|
|
2638
3080
|
}
|
|
2639
|
-
l.push(n.join(
|
|
3081
|
+
l.push(n.join(O.columnSeparatorChar));
|
|
2640
3082
|
}
|
|
2641
|
-
return o(l.join(
|
|
3083
|
+
return o(l.join(O.rowSeparatorChar));
|
|
2642
3084
|
}
|
|
2643
3085
|
}
|
|
2644
3086
|
if (s) {
|
|
@@ -2691,13 +3133,13 @@ const L = class L {
|
|
|
2691
3133
|
mergeRanges(e) {
|
|
2692
3134
|
let t;
|
|
2693
3135
|
for (const s of e)
|
|
2694
|
-
t ? (t.r1 = Math.min(t.r1, s.r1), t.c1 = Math.min(t.c1, s.c1), t.r2 = Math.max(t.r2, s.r2), t.c2 = Math.max(t.c2, s.c2)) : t = new
|
|
3136
|
+
t ? (t.r1 = Math.min(t.r1, s.r1), t.c1 = Math.min(t.c1, s.c1), t.r2 = Math.max(t.r2, s.r2), t.c2 = Math.max(t.c2, s.c2)) : t = new A(s.r1, s.c1, s.r2, s.c2);
|
|
2695
3137
|
return t;
|
|
2696
3138
|
}
|
|
2697
3139
|
};
|
|
2698
|
-
|
|
3140
|
+
O.columnSeparatorChar = " ", O.rowSeparatorChar = `
|
|
2699
3141
|
`;
|
|
2700
|
-
let P =
|
|
3142
|
+
let P = O;
|
|
2701
3143
|
class Be {
|
|
2702
3144
|
constructor(e, t = 500) {
|
|
2703
3145
|
this.tableScope = e, this.debounceDelay = t, new ResizeObserver(le(this.handleResize.bind(this), t)).observe(this.tableScope.hostElement);
|
|
@@ -2813,10 +3255,10 @@ class Pe {
|
|
|
2813
3255
|
return this.createZip(s);
|
|
2814
3256
|
}
|
|
2815
3257
|
}
|
|
2816
|
-
class U extends
|
|
3258
|
+
class U extends xe {
|
|
2817
3259
|
constructor(e, t, s, o, i, r = new P(), l = new Pe()) {
|
|
2818
3260
|
var c;
|
|
2819
|
-
if (super(e, t, new ne(s), o), this.eventListener = i, this.copyService = r, this.excelService = l, this.licenseManager = k.getInstance(), this.selectionService = new
|
|
3261
|
+
if (super(e, t, new ne(s), o), this.eventListener = i, this.copyService = r, this.excelService = l, this.licenseManager = k.getInstance(), this.selectionService = new Ee(this), this.api = new ge(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) {
|
|
2820
3262
|
const h = this.tableOptions.autoRestoreOptions, d = h.getStorageKeyFn;
|
|
2821
3263
|
d && (h.autoRestoreScrollPosition && (this.storeScrollPosStateService = new fe(d)), h.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new me(d)), h.autoRestoreSortingState && (this.storeSortingService = new be(d)));
|
|
2822
3264
|
}
|
|
@@ -3238,9 +3680,70 @@ class U extends we {
|
|
|
3238
3680
|
let e = ((t = this.storeSortingService) == null ? void 0 : t.getSortItems()) ?? [];
|
|
3239
3681
|
this.tableModel.doSort(e);
|
|
3240
3682
|
}
|
|
3683
|
+
sort(e) {
|
|
3684
|
+
this.tableModel.sort(e);
|
|
3685
|
+
}
|
|
3241
3686
|
getDisplayedRowCount() {
|
|
3242
3687
|
return this.displayedRowCount;
|
|
3243
3688
|
}
|
|
3689
|
+
/**
|
|
3690
|
+
* Ensures that a specific row is visible in the viewport by scrolling if necessary.
|
|
3691
|
+
* This method checks if the target row is within the currently visible range and
|
|
3692
|
+
* adjusts the scroll position if it's not visible.
|
|
3693
|
+
*
|
|
3694
|
+
* The method performs the following:
|
|
3695
|
+
* 1. Checks if the row is above the current viewport (before first visible row)
|
|
3696
|
+
* 2. Checks if the row is below the current viewport (after last visible row)
|
|
3697
|
+
* 3. Scrolls to make the row visible if needed
|
|
3698
|
+
*
|
|
3699
|
+
* @param {number} rowIndex - The index of the row to make visible
|
|
3700
|
+
* @returns {boolean} Returns true if scrolling was needed and performed, false if the row was already visible
|
|
3701
|
+
*
|
|
3702
|
+
* @example
|
|
3703
|
+
* // Ensure row 5 is visible in the viewport
|
|
3704
|
+
* tableScope.ensureRowIsVisible(5);
|
|
3705
|
+
*
|
|
3706
|
+
* @example
|
|
3707
|
+
* // Example usage in a component
|
|
3708
|
+
* class MyTableComponent {
|
|
3709
|
+
* private tableScope: TableScope;
|
|
3710
|
+
*
|
|
3711
|
+
* scrollToSpecificRow(rowIndex: number) {
|
|
3712
|
+
* // This will scroll the row into view if it's not visible
|
|
3713
|
+
* const didScroll = this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3714
|
+
*
|
|
3715
|
+
* if (didScroll) {
|
|
3716
|
+
* console.log(`Table scrolled to show row ${rowIndex}`);
|
|
3717
|
+
* } else {
|
|
3718
|
+
* console.log(`Row ${rowIndex} was already visible`);
|
|
3719
|
+
* }
|
|
3720
|
+
* }
|
|
3721
|
+
* }
|
|
3722
|
+
*
|
|
3723
|
+
* @example
|
|
3724
|
+
* // Example with row selection
|
|
3725
|
+
* class TableHandler {
|
|
3726
|
+
* selectAndShowRow(rowIndex: number) {
|
|
3727
|
+
* // First ensure the row is visible
|
|
3728
|
+
* this.tableScope.ensureRowIsVisible(rowIndex);
|
|
3729
|
+
*
|
|
3730
|
+
* // Then perform selection
|
|
3731
|
+
* this.selectionModel.selectRow(rowIndex);
|
|
3732
|
+
* }
|
|
3733
|
+
* }
|
|
3734
|
+
*
|
|
3735
|
+
* @throws {Error} Implicitly may throw if rowIndex is not a number or if required properties are undefined
|
|
3736
|
+
*
|
|
3737
|
+
* @see {@link scrollToIndex} - The underlying method used for scrolling
|
|
3738
|
+
* @see {@link getDisplayedRowCount} - Related method for getting visible row count
|
|
3739
|
+
*/
|
|
3740
|
+
ensureRowIsVisible(e) {
|
|
3741
|
+
const t = this.firstVisibleRowIndex, s = this.firstVisibleRowIndex + this.displayedRowCount - 1;
|
|
3742
|
+
return e < t ? (this.scrollToIndex(0, e), !0) : e > s ? (this.scrollToIndex(0, e - this.displayedRowCount + 1), !0) : !1;
|
|
3743
|
+
}
|
|
3744
|
+
getFirstVisibleRowIndex() {
|
|
3745
|
+
return this.firstVisibleRowIndex;
|
|
3746
|
+
}
|
|
3244
3747
|
}
|
|
3245
3748
|
const W = class W {
|
|
3246
3749
|
};
|
|
@@ -3569,14 +4072,14 @@ function Ne({
|
|
|
3569
4072
|
onMouseMoved: (S) => {
|
|
3570
4073
|
t && t(S);
|
|
3571
4074
|
}
|
|
3572
|
-
},
|
|
4075
|
+
}, w = new U(
|
|
3573
4076
|
f,
|
|
3574
4077
|
p,
|
|
3575
4078
|
new ee(),
|
|
3576
4079
|
e,
|
|
3577
4080
|
m
|
|
3578
4081
|
);
|
|
3579
|
-
|
|
4082
|
+
w.firstInit(), h && h(w.getApi()), d && k.getInstance().setLicenseKey(d);
|
|
3580
4083
|
};
|
|
3581
4084
|
return /* @__PURE__ */ oe(
|
|
3582
4085
|
"div",
|