@guiexpert/vue3-table 3.1.72 → 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 +574 -70
- 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,15 +612,19 @@ 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)
|
|
620
|
+
return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
|
|
587
621
|
}
|
|
588
622
|
changeColumnOrder(e, t) {
|
|
589
623
|
this.arrayMove(this.properties, e, t), super.changeColumnOrder(e, t);
|
|
590
624
|
}
|
|
591
625
|
getCustomClassesAt(e, t) {
|
|
592
626
|
const s = super.getCustomClassesAt(e, t);
|
|
593
|
-
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;
|
|
594
628
|
}
|
|
595
629
|
genericFlatTableSortComparator(e, t) {
|
|
596
630
|
const s = this.columnDefs.find((o) => o.property === e);
|
|
@@ -818,58 +852,314 @@ class fe {
|
|
|
818
852
|
getSelectionModel() {
|
|
819
853
|
return this.tableScope.selectionModel();
|
|
820
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
|
+
*/
|
|
821
863
|
autoResizeColumns(e = !0) {
|
|
822
864
|
this.tableScope.autoResizeColumns(e);
|
|
823
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
|
+
*/
|
|
824
875
|
recalcWrappers() {
|
|
825
876
|
this.tableScope.recalcWrappers();
|
|
826
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
|
+
*/
|
|
827
886
|
setColumnWidth(e, t) {
|
|
828
887
|
this.tableScope.setColumnWidth(e, t);
|
|
829
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
|
+
*/
|
|
830
895
|
getTableModel() {
|
|
831
896
|
return this.tableScope.tableModel;
|
|
832
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
|
+
*/
|
|
833
904
|
getBodyModel() {
|
|
834
905
|
return this.tableScope.tableModel.getBodyModel();
|
|
835
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
|
+
*/
|
|
836
921
|
setRows(e) {
|
|
837
922
|
const t = this.getBodyModel();
|
|
838
|
-
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);
|
|
839
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
|
+
*/
|
|
840
939
|
addRows(e) {
|
|
841
940
|
const t = this.getBodyModel();
|
|
842
|
-
if (t instanceof
|
|
941
|
+
if (t instanceof k) {
|
|
843
942
|
const s = t;
|
|
844
943
|
let o = s.getAllRows();
|
|
845
944
|
s.setRows([...o, ...e]);
|
|
846
945
|
} else
|
|
847
946
|
console.warn("addRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof t, t);
|
|
848
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
|
+
*/
|
|
849
964
|
addRowsAt(e, t) {
|
|
850
965
|
const s = this.getBodyModel();
|
|
851
|
-
if (s instanceof
|
|
966
|
+
if (s instanceof k) {
|
|
852
967
|
const o = s;
|
|
853
968
|
let i = o.getAllRows();
|
|
854
969
|
o.setRows([...i.slice(0, t), ...e, ...i.slice(t)]);
|
|
855
970
|
} else
|
|
856
971
|
console.warn("addRowsAt<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
857
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
|
+
*/
|
|
858
990
|
removeRows(e, t = (s, o) => s === o) {
|
|
859
991
|
const s = this.getBodyModel();
|
|
860
|
-
if (s instanceof
|
|
992
|
+
if (s instanceof k) {
|
|
861
993
|
const o = s, i = o.getAllRows().filter((r) => !e.some((a) => t(r, a)));
|
|
862
994
|
o.setRows(i);
|
|
863
995
|
} else
|
|
864
996
|
console.warn("removeRows<T>(rows: T[]) only works with AreaModelObjectArray<T>, but this body area model is ", typeof s, s);
|
|
865
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
|
+
*/
|
|
866
1031
|
findRows(e, t = (s, o) => s === o) {
|
|
867
1032
|
const s = this.getBodyModel();
|
|
868
|
-
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);
|
|
869
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
|
+
*/
|
|
870
1160
|
updateRows(e, t = (s, o) => s === o) {
|
|
871
1161
|
const s = this.getBodyModel();
|
|
872
|
-
if (s instanceof
|
|
1162
|
+
if (s instanceof k) {
|
|
873
1163
|
let i = s.getAllRows();
|
|
874
1164
|
for (const r of i)
|
|
875
1165
|
for (const a of e)
|
|
@@ -879,12 +1169,165 @@ class fe {
|
|
|
879
1169
|
} else
|
|
880
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);
|
|
881
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
|
+
*/
|
|
882
1182
|
reSort() {
|
|
883
1183
|
this.tableScope.reSort();
|
|
884
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
|
+
*/
|
|
885
1295
|
getDisplayedRowCount() {
|
|
886
1296
|
return this.tableScope.getDisplayedRowCount();
|
|
887
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
|
+
}
|
|
888
1331
|
}
|
|
889
1332
|
class G {
|
|
890
1333
|
constructor(e) {
|
|
@@ -1246,7 +1689,7 @@ class A {
|
|
|
1246
1689
|
return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
|
|
1247
1690
|
}
|
|
1248
1691
|
}
|
|
1249
|
-
class
|
|
1692
|
+
class we {
|
|
1250
1693
|
constructor(e, t) {
|
|
1251
1694
|
this.tableModel = e, this.areaModel = t, this.colAndRowspanRanges = void 0;
|
|
1252
1695
|
}
|
|
@@ -1279,7 +1722,7 @@ class xe {
|
|
|
1279
1722
|
return !1;
|
|
1280
1723
|
}
|
|
1281
1724
|
}
|
|
1282
|
-
class
|
|
1725
|
+
class xe {
|
|
1283
1726
|
constructor(e, t, s) {
|
|
1284
1727
|
this.header = e, this.body = t, this.footer = s;
|
|
1285
1728
|
}
|
|
@@ -1291,10 +1734,10 @@ class Ce extends ye {
|
|
|
1291
1734
|
header: [],
|
|
1292
1735
|
body: [],
|
|
1293
1736
|
footer: []
|
|
1294
|
-
}, 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(
|
|
1295
1738
|
(l) => {
|
|
1296
1739
|
var n;
|
|
1297
|
-
this.colAndRowspanModels[l] = new
|
|
1740
|
+
this.colAndRowspanModels[l] = new we(t, t.getAreaModel(l)), (n = this.colAndRowspanModels[l]) == null || n.init();
|
|
1298
1741
|
}
|
|
1299
1742
|
);
|
|
1300
1743
|
}
|
|
@@ -1556,11 +1999,11 @@ class Ce extends ye {
|
|
|
1556
1999
|
let h = t;
|
|
1557
2000
|
const m = this.tableModel.getColumnCount(), g = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
|
|
1558
2001
|
for (let u = 0; u < p; u++) {
|
|
1559
|
-
const
|
|
1560
|
-
if (
|
|
2002
|
+
const w = h, x = u === p - 1, v = this.tableModel.getRowHeight(e, u);
|
|
2003
|
+
if (w + v > 0) {
|
|
1561
2004
|
this.firstVisibleRowIndex = u;
|
|
1562
|
-
let y = { left: a, width: l, height: v, top:
|
|
1563
|
-
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;
|
|
1564
2007
|
if (this.adjustColumnsToRowParent({
|
|
1565
2008
|
areaIdent: e,
|
|
1566
2009
|
sideIdent: "center",
|
|
@@ -1568,11 +2011,11 @@ class Ce extends ye {
|
|
|
1568
2011
|
geo: y,
|
|
1569
2012
|
parent: S,
|
|
1570
2013
|
rowIndex: u,
|
|
1571
|
-
columnIndexStart:
|
|
2014
|
+
columnIndexStart: M,
|
|
1572
2015
|
columnIndexEnd: m - g - 1,
|
|
1573
2016
|
verticalFixed: !1,
|
|
1574
|
-
lastRowOfModel:
|
|
1575
|
-
}), 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({
|
|
1576
2019
|
areaIdent: e,
|
|
1577
2020
|
sideIdent: "west",
|
|
1578
2021
|
areaModel: c,
|
|
@@ -1580,10 +2023,10 @@ class Ce extends ye {
|
|
|
1580
2023
|
parent: S,
|
|
1581
2024
|
rowIndex: u,
|
|
1582
2025
|
columnIndexStart: 0,
|
|
1583
|
-
columnIndexEnd:
|
|
2026
|
+
columnIndexEnd: M - 1,
|
|
1584
2027
|
verticalFixed: !0,
|
|
1585
|
-
lastRowOfModel:
|
|
1586
|
-
})), 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({
|
|
1587
2030
|
areaIdent: e,
|
|
1588
2031
|
sideIdent: "east",
|
|
1589
2032
|
areaModel: c,
|
|
@@ -1593,7 +2036,7 @@ class Ce extends ye {
|
|
|
1593
2036
|
columnIndexStart: m - g,
|
|
1594
2037
|
columnIndexEnd: m - 1,
|
|
1595
2038
|
verticalFixed: !0,
|
|
1596
|
-
lastRowOfModel:
|
|
2039
|
+
lastRowOfModel: x
|
|
1597
2040
|
})), e === "header" && this.tree && u === p - 1) {
|
|
1598
2041
|
const E = this.dom.applyStyle(
|
|
1599
2042
|
this.dom.setAttribute(
|
|
@@ -1602,10 +2045,10 @@ class Ce extends ye {
|
|
|
1602
2045
|
"toggleExpandCollapseAll"
|
|
1603
2046
|
),
|
|
1604
2047
|
{ cursor: "pointer" }
|
|
1605
|
-
),
|
|
1606
|
-
if (
|
|
1607
|
-
const O = this.dom.domService.createText(
|
|
1608
|
-
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);
|
|
1609
2052
|
}
|
|
1610
2053
|
}
|
|
1611
2054
|
}
|
|
@@ -1617,17 +2060,17 @@ class Ce extends ye {
|
|
|
1617
2060
|
if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
|
|
1618
2061
|
const u = ((f = this.colAndRowspanModels[e]) == null ? void 0 : f.getRanges()) ?? [];
|
|
1619
2062
|
if (u.length)
|
|
1620
|
-
for (const
|
|
1621
|
-
let
|
|
1622
|
-
if (
|
|
2063
|
+
for (const w of u) {
|
|
2064
|
+
let x = 0, v = o.child, y = "center";
|
|
2065
|
+
if (w.c1 < b)
|
|
1623
2066
|
v = s.child, y = "west";
|
|
1624
|
-
else if (g > 0 &&
|
|
2067
|
+
else if (g > 0 && w.c1 >= m - g)
|
|
1625
2068
|
v = i.child, y = "east";
|
|
1626
2069
|
else {
|
|
1627
2070
|
const S = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
|
|
1628
|
-
|
|
2071
|
+
x = this.scrollFactorX * S - this.areaBodyWestGeo.width, y = "center";
|
|
1629
2072
|
}
|
|
1630
|
-
this.drawBigCell(
|
|
2073
|
+
this.drawBigCell(w, x, t, c, v, y);
|
|
1631
2074
|
}
|
|
1632
2075
|
}
|
|
1633
2076
|
}
|
|
@@ -1735,21 +2178,21 @@ class Ce extends ye {
|
|
|
1735
2178
|
const h = 0, m = !!(e === "body" && t);
|
|
1736
2179
|
let g = p;
|
|
1737
2180
|
for (let f = a; f <= l; f++) {
|
|
1738
|
-
const u = g,
|
|
1739
|
-
if (
|
|
1740
|
-
let
|
|
2181
|
+
const u = g, w = this.tableModel.getColumnWidth(f);
|
|
2182
|
+
if (w > 0 && u + w > 0) {
|
|
2183
|
+
let x = o.height;
|
|
1741
2184
|
const v = s.getRowspanAt(r, f), y = s.getColspanAt(r, f);
|
|
1742
|
-
v > 1 && (
|
|
1743
|
-
let S =
|
|
1744
|
-
y > 1 && (S = this.getColumnWidths(f, f + y - 1).reduce((E,
|
|
1745
|
-
let
|
|
1746
|
-
if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, f) && (
|
|
1747
|
-
this.renderDragTargetDiv(i, u, h, S,
|
|
1748
|
-
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 };
|
|
1749
2192
|
this.dom.addColumnBorderDivs(this.tableOptions, i, E, e, t);
|
|
1750
2193
|
} else {
|
|
1751
|
-
const E = this.renderSelectedBackgroundDiv(
|
|
1752
|
-
"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({
|
|
1753
2196
|
areaModel: s,
|
|
1754
2197
|
areaIdent: e,
|
|
1755
2198
|
sideIdent: t,
|
|
@@ -1758,7 +2201,7 @@ class Ce extends ye {
|
|
|
1758
2201
|
left: u,
|
|
1759
2202
|
top: h,
|
|
1760
2203
|
width: S,
|
|
1761
|
-
height:
|
|
2204
|
+
height: x,
|
|
1762
2205
|
parent: i,
|
|
1763
2206
|
cellSelected: E,
|
|
1764
2207
|
lastRowOfModel: c,
|
|
@@ -1769,12 +2212,12 @@ class Ce extends ye {
|
|
|
1769
2212
|
cellLeft: u,
|
|
1770
2213
|
cellTop: h,
|
|
1771
2214
|
cellWidth: S,
|
|
1772
|
-
cellHeight:
|
|
2215
|
+
cellHeight: x,
|
|
1773
2216
|
parent: i
|
|
1774
2217
|
});
|
|
1775
2218
|
}
|
|
1776
2219
|
}
|
|
1777
|
-
if (g = g +
|
|
2220
|
+
if (g = g + w, g > this.areaBodyCenterGeo.width)
|
|
1778
2221
|
break;
|
|
1779
2222
|
}
|
|
1780
2223
|
this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(g - 1, 1, o.height, 0), i);
|
|
@@ -1811,12 +2254,12 @@ class Ce extends ye {
|
|
|
1811
2254
|
const C = b;
|
|
1812
2255
|
(U = C.children) != null && U.length ? C.expanded ? f = "expanded" : f = "collapsed" : f = "hidden";
|
|
1813
2256
|
}
|
|
1814
|
-
let
|
|
2257
|
+
let w;
|
|
1815
2258
|
if (t === "header") {
|
|
1816
2259
|
const C = this.tableModel.getColumnDef(i);
|
|
1817
|
-
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (
|
|
2260
|
+
(!(C != null && C.sortIconVisible) || C != null && C.sortIconVisible()) && (w = C == null ? void 0 : C.sortState);
|
|
1818
2261
|
}
|
|
1819
|
-
const
|
|
2262
|
+
const x = e.getValueAt(o, i), v = m ? "" : `${x}`, y = e.isRowChecked(o), S = this.dom.addColumnDiv(
|
|
1820
2263
|
{
|
|
1821
2264
|
parent: c,
|
|
1822
2265
|
geo: g,
|
|
@@ -1828,14 +2271,14 @@ class Ce extends ye {
|
|
|
1828
2271
|
treeArrow: f,
|
|
1829
2272
|
tableOptions: this.tableOptions,
|
|
1830
2273
|
checkedType: y,
|
|
1831
|
-
sortState:
|
|
2274
|
+
sortState: w
|
|
1832
2275
|
}
|
|
1833
|
-
),
|
|
1834
|
-
|
|
2276
|
+
), M = e.getTooltipAt(o, i);
|
|
2277
|
+
M && this.dom.setAttribute(S, "title", M);
|
|
1835
2278
|
const E = this.tableModel.getColumnDef(i);
|
|
1836
2279
|
E && E.classes[t] && this.dom.addClasses(E.classes[t], S);
|
|
1837
|
-
let
|
|
1838
|
-
m && (
|
|
2280
|
+
let R;
|
|
2281
|
+
m && (R = m.render(S, o, i, t, e, x, this.dom.domService));
|
|
1839
2282
|
const O = e.getCustomClassesAt(o, i);
|
|
1840
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") {
|
|
1841
2284
|
const C = this.getFocusModel();
|
|
@@ -1846,7 +2289,7 @@ class Ce extends ye {
|
|
|
1846
2289
|
if ($)
|
|
1847
2290
|
for (const C in $)
|
|
1848
2291
|
this.dom.setStyle(S, C, $[C]);
|
|
1849
|
-
return [S,
|
|
2292
|
+
return [S, R];
|
|
1850
2293
|
}
|
|
1851
2294
|
/**
|
|
1852
2295
|
* Applies CSS classes to an HTML element.
|
|
@@ -2021,10 +2464,10 @@ class Ce extends ye {
|
|
|
2021
2464
|
sideIdent: o,
|
|
2022
2465
|
text: b
|
|
2023
2466
|
}, u = this.dom.addColumnDiv(f);
|
|
2024
|
-
let
|
|
2025
|
-
g && (
|
|
2026
|
-
const
|
|
2027
|
-
|
|
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);
|
|
2028
2471
|
const v = this.tableModel.getColumnDef(a);
|
|
2029
2472
|
v && v.classes[t] && this.dom.addClasses(v.classes[t], u), this.dom.addColumnBorderDivs(this.tableOptions, l, h, t, o);
|
|
2030
2473
|
const y = i.getCustomStyleAt(n, a);
|
|
@@ -2205,7 +2648,7 @@ class z {
|
|
|
2205
2648
|
return new z([new Ee(e, t)]);
|
|
2206
2649
|
}
|
|
2207
2650
|
}
|
|
2208
|
-
class
|
|
2651
|
+
class Re {
|
|
2209
2652
|
constructor(e) {
|
|
2210
2653
|
var t, s;
|
|
2211
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);
|
|
@@ -2246,7 +2689,7 @@ class Me {
|
|
|
2246
2689
|
});
|
|
2247
2690
|
}
|
|
2248
2691
|
}
|
|
2249
|
-
class
|
|
2692
|
+
class Me {
|
|
2250
2693
|
get() {
|
|
2251
2694
|
return {
|
|
2252
2695
|
f2: "START_EDITING",
|
|
@@ -2326,7 +2769,7 @@ class ke {
|
|
|
2326
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)));
|
|
2327
2770
|
}
|
|
2328
2771
|
assignPredefinedSystemShortcutMappings() {
|
|
2329
|
-
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());
|
|
2330
2773
|
}
|
|
2331
2774
|
isMacintosh() {
|
|
2332
2775
|
return navigator.platform.indexOf("Mac") > -1;
|
|
@@ -2813,7 +3256,7 @@ class We {
|
|
|
2813
3256
|
class N extends Ce {
|
|
2814
3257
|
constructor(e, t, s, o, i, r = new B(), a = new We()) {
|
|
2815
3258
|
var c;
|
|
2816
|
-
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) {
|
|
2817
3260
|
const p = this.tableOptions.autoRestoreOptions, h = p.getStorageKeyFn;
|
|
2818
3261
|
h && (p.autoRestoreScrollPosition && (this.storeScrollPosStateService = new ue(h)), p.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new be(h)), p.autoRestoreSortingState && (this.storeSortingService = new Se(h)));
|
|
2819
3262
|
}
|
|
@@ -3235,9 +3678,70 @@ class N extends Ce {
|
|
|
3235
3678
|
let e = ((t = this.storeSortingService) == null ? void 0 : t.getSortItems()) ?? [];
|
|
3236
3679
|
this.tableModel.doSort(e);
|
|
3237
3680
|
}
|
|
3681
|
+
sort(e) {
|
|
3682
|
+
this.tableModel.sort(e);
|
|
3683
|
+
}
|
|
3238
3684
|
getDisplayedRowCount() {
|
|
3239
3685
|
return this.displayedRowCount;
|
|
3240
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
|
+
}
|
|
3241
3745
|
}
|
|
3242
3746
|
const P = class P {
|
|
3243
3747
|
};
|
|
@@ -3591,7 +4095,7 @@ const $e = se({
|
|
|
3591
4095
|
};
|
|
3592
4096
|
return ie(() => {
|
|
3593
4097
|
t.value && s(t.value);
|
|
3594
|
-
}), d.licenseKey &&
|
|
4098
|
+
}), d.licenseKey && F.getInstance().setLicenseKey(d.licenseKey), {
|
|
3595
4099
|
root: t
|
|
3596
4100
|
};
|
|
3597
4101
|
}
|