@guiexpert/vue3-table 3.1.79 → 3.1.80

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.
Files changed (2) hide show
  1. package/index.js +1013 -41
  2. package/package.json +5 -3
package/index.js CHANGED
@@ -535,28 +535,128 @@ class ge {
535
535
  }
536
536
  }
537
537
  class D extends pe {
538
+ /**
539
+ * Creates an instance of AreaModelObjectArray.
540
+ *
541
+ * @param {AreaIdent} areaIdent - Identifies which area of the table this model represents ('header', 'body', or 'footer')
542
+ * @param {T[]} rows - The array of objects that represent the rows in this area
543
+ * @param {number} defaultRowHeight - The default height for rows in this area (in pixels)
544
+ * @param {ColumnDefIf[]} [columnDefs=[]] - Definitions for the columns in this area
545
+ * @param {string} [selectedRowClass='ge-selected-row'] - CSS class to apply to selected rows
546
+ * @param {string} [focusedRowClass='ge-focused-row'] - CSS class to apply to the focused row
547
+ *
548
+ * @example
549
+ * const rows = [
550
+ * { id: 1, name: 'John', age: 30 },
551
+ * { id: 2, name: 'Jane', age: 25 }
552
+ * ];
553
+ *
554
+ * const columnDefs = [
555
+ * { property: 'id', headerLabel: 'ID', width: 50 },
556
+ * { property: 'name', headerLabel: 'Name', width: 150 },
557
+ * { property: 'age', headerLabel: 'Age', width: 100 }
558
+ * ];
559
+ *
560
+ * const bodyAreaModel = new AreaModelObjectArray(
561
+ * 'body',
562
+ * rows,
563
+ * 30,
564
+ * columnDefs
565
+ * );
566
+ */
538
567
  constructor(e, t, s, o = [], i = "ge-selected-row", r = "ge-focused-row") {
539
568
  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
569
  }
570
+ /**
571
+ * Gets the index of the currently focused row.
572
+ *
573
+ * @returns {number} The index of the focused row
574
+ *
575
+ * @example
576
+ * const focusedRowIndex = bodyAreaModel.getFocusedRowIndex();
577
+ * console.log(`The focused row is at index ${focusedRowIndex}`);
578
+ */
541
579
  getFocusedRowIndex() {
542
580
  return this._focusedRowIndex;
543
581
  }
582
+ /**
583
+ * Sets the index of the focused row.
584
+ * This will apply the focused row styling to the specified row.
585
+ *
586
+ * @param {number} value - The index of the row to focus
587
+ *
588
+ * @example
589
+ * // Focus the second row (index 1)
590
+ * bodyAreaModel.setFocusedRowIndex(1);
591
+ */
544
592
  setFocusedRowIndex(e) {
545
593
  this._focusedRowIndex = e;
546
594
  }
595
+ /**
596
+ * Replaces the current rows array with a new one.
597
+ * This also resets the filtered rows to match the new rows array.
598
+ *
599
+ * @param {T[]} rows - The new array of row objects
600
+ *
601
+ * @example
602
+ * // Replace the current rows with new data
603
+ * const newRows = [
604
+ * { id: 4, name: 'Alice', age: 35 },
605
+ * { id: 5, name: 'Charlie', age: 45 }
606
+ * ];
607
+ * bodyAreaModel.setRows(newRows);
608
+ */
547
609
  setRows(e) {
548
610
  this.rows = e, this.filteredRows = [...e];
549
611
  }
612
+ /**
613
+ * Filters both the original rows and filtered rows arrays using the provided predicate function.
614
+ * Unlike `externalFilterChanged`, this method permanently modifies the original rows array.
615
+ *
616
+ * @param {(row: T) => boolean} predict - A function that returns true for rows to keep and false for rows to filter out
617
+ *
618
+ * @example
619
+ * // Remove all rows where age is less than 30
620
+ * bodyAreaModel.filterRowsByPredict(row => row.age >= 30);
621
+ */
550
622
  filterRowsByPredict(e) {
551
623
  this.rows = this.rows.filter(e), this.filteredRows = this.filteredRows.filter(e);
552
624
  }
553
625
  /**
554
- * return row count of filtered rows
626
+ * Returns the number of rows in the filtered rows array.
627
+ * This is used to determine how many rows should be rendered in the table.
628
+ *
629
+ * @returns {number} The number of rows in the filtered rows array
630
+ *
631
+ * @example
632
+ * const rowCount = bodyAreaModel.getRowCount();
633
+ * console.log(`The table has ${rowCount} rows`);
555
634
  */
556
635
  getRowCount() {
557
636
  var e;
558
637
  return ((e = this.filteredRows) == null ? void 0 : e.length) ?? 0;
559
638
  }
639
+ /**
640
+ * Gets the value at the specified row and column indices.
641
+ * This method handles tree rows and nested properties.
642
+ *
643
+ * @param {number} rowIndex - The index of the row
644
+ * @param {number} columnIndex - The index of the column
645
+ * @returns {any} The value at the specified cell, or an empty string if not found
646
+ *
647
+ * @example
648
+ * // Get the value in the first row, second column
649
+ * const value = bodyAreaModel.getValueAt(0, 1);
650
+ * console.log(`The value is: ${value}`);
651
+ *
652
+ * @example
653
+ * // Iterate through all cells in a row
654
+ * const rowIndex = 0;
655
+ * for (let colIndex = 0; colIndex < columnDefs.length; colIndex++) {
656
+ * const value = bodyAreaModel.getValueAt(rowIndex, colIndex);
657
+ * console.log(`Cell (${rowIndex}, ${colIndex}): ${value}`);
658
+ * }
659
+ */
560
660
  getValueAt(e, t) {
561
661
  const s = this.properties[t];
562
662
  let o = this.filteredRows[e];
@@ -565,46 +665,176 @@ class D extends pe {
565
665
  /**
566
666
  * Retrieves the filtered and sorted rows from the dataset.
567
667
  * These rows are used for rendering the table.
668
+ * Unlike `getAllRows()`, this method returns only the rows that match any applied filters.
568
669
  *
569
- * @return {T[]} An array containing the filtered (and sorted) rows.
670
+ * @returns {T[]} An array containing the filtered (and sorted) rows
671
+ *
672
+ * @example
673
+ * // Get all filtered rows
674
+ * const filteredRows = bodyAreaModel.getFilteredRows();
675
+ *
676
+ * // Count rows that match a certain condition
677
+ * const adultsCount = filteredRows.filter(row => row.age >= 18).length;
570
678
  */
571
679
  getFilteredRows() {
572
680
  return this.filteredRows;
573
681
  }
682
+ /**
683
+ * Returns the original, unfiltered array of rows.
684
+ * This can be useful when you need to access all data regardless of any applied filters.
685
+ *
686
+ * @returns {T[]} The original array of row objects
687
+ *
688
+ * @example
689
+ * // Get all rows, including those filtered out
690
+ * const allRows = bodyAreaModel.getAllRows();
691
+ *
692
+ * // Calculate average age across all rows
693
+ * const totalAge = allRows.reduce((sum, row) => sum + row.age, 0);
694
+ * const averageAge = totalAge / allRows.length;
695
+ */
574
696
  getAllRows() {
575
697
  return this.rows;
576
698
  }
577
699
  /**
578
700
  * Returns the first row from the filtered rows that matches the given criteria based on the provided predicate function.
701
+ * This method only searches within the filtered rows, not the original rows array.
579
702
  *
580
703
  * @param {Partial<T>} criteria - A partial object containing the search criteria
581
704
  * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
582
705
  * and returns true if the row matches the criteria
583
706
  * @returns {T | undefined} The first matching row, or undefined if no match is found
707
+ *
708
+ * @example
709
+ * // Find a user by name in the filtered rows
710
+ * const criteria = { name: 'John' };
711
+ * const user = bodyAreaModel.findRowFromFilteredRowsByAllCriteria(
712
+ * criteria,
713
+ * (criteria, row) => row.name === criteria.name
714
+ * );
715
+ *
716
+ * @example
717
+ * // Find a user by age range in the filtered rows
718
+ * const criteria = { minAge: 25, maxAge: 35 };
719
+ * const user = bodyAreaModel.findRowFromFilteredRowsByAllCriteria(
720
+ * criteria,
721
+ * (criteria, row) => row.age >= criteria.minAge && row.age <= criteria.maxAge
722
+ * );
584
723
  */
585
724
  findRowFromFilteredRowsByAllCriteria(e, t) {
586
725
  return this.getFilteredRows().find((s) => t(e, s));
587
726
  }
588
727
  /**
589
728
  * Searches through all rows to find a row that matches the given criteria based on the predicate function.
729
+ * This method searches within the original rows array, including rows that may have been filtered out.
590
730
  *
591
731
  * @param {Partial<T>} criteria - A partial object containing the search criteria
592
732
  * @param {(criteria: Partial<T>, row: T) => boolean} predicate - A function that takes the search criteria and a row,
593
733
  * and returns true if the row matches the criteria
594
734
  * @returns {T | undefined} The first matching row from all rows, or undefined if no match is found
735
+ *
736
+ * @example
737
+ * // Find a user by ID in all rows
738
+ * const criteria = { id: 42 };
739
+ * const user = bodyAreaModel.findRowFromAllRowsByAllCriteria(
740
+ * criteria,
741
+ * (criteria, row) => row.id === criteria.id
742
+ * );
743
+ *
744
+ * @example
745
+ * // Find a user with a specific property value in all rows
746
+ * const criteria = { department: 'Engineering', role: 'Manager' };
747
+ * const user = bodyAreaModel.findRowFromAllRowsByAllCriteria(
748
+ * criteria,
749
+ * (criteria, row) => row.department === criteria.department && row.role === criteria.role
750
+ * );
595
751
  */
596
752
  findRowFromAllRowsByAllCriteria(e, t) {
597
753
  return this.getAllRows().find((s) => t(e, s));
598
754
  }
755
+ /**
756
+ * Returns the height of the row at the specified index.
757
+ * This implementation always returns the default row height.
758
+ * Override this method in subclasses to support variable row heights.
759
+ *
760
+ * @param {number} _rowIndex - The index of the row (unused in this implementation)
761
+ * @returns {number} The height of the row in pixels
762
+ *
763
+ * @example
764
+ * const rowHeight = bodyAreaModel.getRowHeight(0);
765
+ * console.log(`The first row has a height of ${rowHeight}px`);
766
+ */
599
767
  getRowHeight(e) {
600
768
  return this.defaultRowHeight;
601
769
  }
770
+ /**
771
+ * Returns the row object at the specified index from the filtered rows array.
772
+ * This method overrides the parent class implementation.
773
+ *
774
+ * @param {number} rowIndex - The index of the row to retrieve
775
+ * @returns {any} The row object at the specified index, or undefined if the index is out of bounds
776
+ *
777
+ * @example
778
+ * // Get the first row object
779
+ * const row = bodyAreaModel.getRowByIndex(0);
780
+ * console.log('First row:', row);
781
+ *
782
+ * @example
783
+ * // Iterate through all rows
784
+ * for (let i = 0; i < bodyAreaModel.getRowCount(); i++) {
785
+ * const row = bodyAreaModel.getRowByIndex(i);
786
+ * console.log(`Row ${i}:`, row);
787
+ * }
788
+ */
602
789
  getRowByIndex(e) {
603
790
  return this.filteredRows[e];
604
791
  }
792
+ /**
793
+ * Applies an external filter function to the rows array.
794
+ * This method updates the filtered rows array without modifying the original rows array.
795
+ *
796
+ * @param {FilterFunction<any>} predictFn - A function that returns true for rows to keep and false for rows to filter out
797
+ *
798
+ * @example
799
+ * // Filter rows where age is greater than 30
800
+ * bodyAreaModel.externalFilterChanged(row => row.age > 30);
801
+ *
802
+ * @example
803
+ * // Filter rows based on a search term
804
+ * const searchTerm = 'john';
805
+ * bodyAreaModel.externalFilterChanged(row =>
806
+ * row.name.toLowerCase().includes(searchTerm.toLowerCase())
807
+ * );
808
+ *
809
+ * @example
810
+ * // Clear all filters
811
+ * bodyAreaModel.externalFilterChanged(() => true);
812
+ */
605
813
  externalFilterChanged(e) {
606
814
  this.filteredRows = this.rows ? this.rows.filter(e) : [];
607
815
  }
816
+ /**
817
+ * Sorts the filtered rows based on the provided sort items.
818
+ * This method supports sorting by multiple columns with different sort directions.
819
+ *
820
+ * @param {SortItem[]} sortItems - An array of sort items, each containing a column index and sort state
821
+ * @returns {boolean} Always returns true to indicate sorting was performed
822
+ *
823
+ * @example
824
+ * // Sort by age in ascending order
825
+ * bodyAreaModel.doSort([{ columnIndex: 2, sortState: 'asc' }]);
826
+ *
827
+ * @example
828
+ * // Sort by name in descending order, then by age in ascending order
829
+ * bodyAreaModel.doSort([
830
+ * { columnIndex: 1, sortState: 'desc' },
831
+ * { columnIndex: 2, sortState: 'asc' }
832
+ * ]);
833
+ *
834
+ * @example
835
+ * // Clear sorting
836
+ * bodyAreaModel.doSort([{ columnIndex: 0, sortState: 'none' }]);
837
+ */
608
838
  doSort(e) {
609
839
  for (const t of e) {
610
840
  const { columnIndex: s, sortState: o } = t, i = o === "asc" ? 1 : o === "desc" ? -1 : 0, r = this.properties[s];
@@ -612,20 +842,110 @@ class D extends pe {
612
842
  }
613
843
  return !0;
614
844
  }
845
+ /**
846
+ * Sorts the filtered rows using a custom comparator function.
847
+ * This method provides more flexibility than `doSort()` for complex sorting logic.
848
+ *
849
+ * @param {(a: T, b: T) => number} compareFn - A function that compares two rows and returns a number:
850
+ * - Negative if a should come before b
851
+ * - Positive if a should come after b
852
+ * - Zero if they are equivalent for sorting purposes
853
+ *
854
+ * @example
855
+ * // Sort by name length
856
+ * bodyAreaModel.sort((a, b) => a.name.length - b.name.length);
857
+ *
858
+ * @example
859
+ * // Sort by a computed value
860
+ * bodyAreaModel.sort((a, b) => {
861
+ * const scoreA = a.wins * 3 + a.draws;
862
+ * const scoreB = b.wins * 3 + b.draws;
863
+ * return scoreB - scoreA; // Descending order
864
+ * });
865
+ */
615
866
  sort(e) {
616
867
  this.filteredRows = this.filteredRows.sort(e);
617
868
  }
869
+ /**
870
+ * Gets a value from an object using a property path.
871
+ * This method supports accessing nested properties using dot notation (e.g., 'person.name').
872
+ *
873
+ * @param {T} t - The object to get the value from
874
+ * @param {string} property - The property path to access (e.g., 'name' or 'person.contact.email')
875
+ * @returns {any} The value at the specified property path, or undefined if not found
876
+ *
877
+ * @example
878
+ * const user = { id: 1, name: 'John', contact: { email: 'john@example.com' } };
879
+ *
880
+ * // Access simple property
881
+ * const name = bodyAreaModel.getValueByT(user, 'name');
882
+ * console.log(name); // 'John'
883
+ *
884
+ * // Access nested property
885
+ * const email = bodyAreaModel.getValueByT(user, 'contact.email');
886
+ * console.log(email); // 'john@example.com'
887
+ */
618
888
  getValueByT(e, t) {
619
889
  if (e && t)
620
890
  return t.includes(".") ? this.getPropertyValue(e, t.split(".")) : e[t];
621
891
  }
892
+ /**
893
+ * Changes the order of columns by moving a column from one position to another.
894
+ * This method updates both the properties array and calls the parent class implementation.
895
+ *
896
+ * @param {number} sourceColumnIndex - The index of the column to move
897
+ * @param {number} targetColumnIndex - The index where the column should be moved to
898
+ *
899
+ * @example
900
+ * // Move the second column (index 1) to the fourth position (index 3)
901
+ * bodyAreaModel.changeColumnOrder(1, 3);
902
+ *
903
+ * @example
904
+ * // Move the last column to the first position
905
+ * const lastIndex = bodyAreaModel.columnDefs.length - 1;
906
+ * bodyAreaModel.changeColumnOrder(lastIndex, 0);
907
+ */
622
908
  changeColumnOrder(e, t) {
623
909
  this.arrayMove(this.properties, e, t), super.changeColumnOrder(e, t);
624
910
  }
911
+ /**
912
+ * Gets the custom CSS classes that should be applied to a cell.
913
+ * This method extends the parent class implementation to add selection and focus classes.
914
+ *
915
+ * @param {number} rowIndex - The index of the row
916
+ * @param {number} _columnIndex - The index of the column (unused in this implementation)
917
+ * @returns {string[]} An array of CSS class names to apply to the cell
918
+ *
919
+ * @example
920
+ * // Get the CSS classes for a cell
921
+ * const classes = bodyAreaModel.getCustomClassesAt(1, 2);
922
+ * console.log('CSS classes:', classes);
923
+ *
924
+ * @example
925
+ * // Apply the classes to a cell element
926
+ * const cellElement = document.createElement('div');
927
+ * const classes = bodyAreaModel.getCustomClassesAt(rowIndex, columnIndex);
928
+ * cellElement.classList.add(...classes);
929
+ */
625
930
  getCustomClassesAt(e, t) {
626
931
  const s = super.getCustomClassesAt(e, t);
627
932
  return this.getRowByIndex(e).selected && s.push(this.selectedRowClass), this._focusedRowIndex === e && s.push(this.focusedRowClass), s;
628
933
  }
934
+ /**
935
+ * Creates a comparator function for sorting rows based on a property and sort direction.
936
+ * This method supports custom sort comparators defined in column definitions.
937
+ *
938
+ * @param {string} property - The property to sort by
939
+ * @param {number} f - The sort direction factor: 1 for ascending, -1 for descending, 0 for no sorting
940
+ * @returns {(a: T, b: T) => number} A comparator function that compares two rows
941
+ *
942
+ * @example
943
+ * // Create a comparator for sorting by name in ascending order
944
+ * const comparator = bodyAreaModel.genericFlatTableSortComparator('name', 1);
945
+ *
946
+ * // Sort the rows using the comparator
947
+ * const sortedRows = [...bodyAreaModel.getFilteredRows()].sort(comparator);
948
+ */
629
949
  genericFlatTableSortComparator(e, t) {
630
950
  const s = this.columnDefs.find((o) => o.property === e);
631
951
  return (o, i) => {
@@ -633,6 +953,16 @@ class D extends pe {
633
953
  return s != null && s.sortComparator ? t * s.sortComparator(r, a, o, i, t) : this.sorterService.genericSortComparator(r, a, t);
634
954
  };
635
955
  }
956
+ /**
957
+ * Recursively gets a value from an object using an array of property names.
958
+ * This is a helper method used by `getValueByT` to access nested properties.
959
+ *
960
+ * @param {any} o - The object to get the value from
961
+ * @param {string[]} props - An array of property names representing the path to the value
962
+ * @returns {any} The value at the specified property path, or undefined if not found
963
+ *
964
+ * @private
965
+ */
636
966
  getPropertyValue(e, t) {
637
967
  const s = t.shift(), o = e[s];
638
968
  return o && t.length ? this.getPropertyValue(o, t) : o;
@@ -643,41 +973,302 @@ class ue {
643
973
  this.tableScope = e;
644
974
  }
645
975
  /**
646
- * Updates the cells in the table based on the provided events.
976
+ * Updates the cells in the table with the provided cell update events.
647
977
  *
648
- * @param {TableCellUpdateEventIf[]} events - The array of events representing the updates to perform on the cells.
649
- * @param {boolean} [repaintAll=false] - Optional parameter indicating whether to repaint all cells or not. Default value is false. If true, the full table will be rendered. If false, the table cell will be rendered immediately.
978
+ * This method allows you to update specific cells in the table without requiring a full table repaint,
979
+ * which can significantly improve performance when updating large tables frequently.
650
980
  *
651
- * @return {void} - This method doesn't return anything.
981
+ * @param {TableCellUpdateEventIf[]} events - An array of cell update events, each defining a single cell update operation.
982
+ * Each event must specify:
983
+ * - area: The table area to update ('header', 'body', or 'footer')
984
+ * - rowIndex: The row index of the cell to update
985
+ * - columnIndex: The column index of the cell to update
986
+ * - value: The new value to set for the cell
987
+ * - cssClasses: Optional object mapping CSS class names to boolean values
988
+ * (true to add the class, false to remove it)
989
+ *
990
+ * @param {boolean} [repaintAll=false] - Whether to repaint the entire table after updating cells.
991
+ * - If true: All cells will be repainted after updating (slower but ensures visual consistency)
992
+ * - If false: Only the modified cells will be repainted (faster, recommended for frequent updates)
993
+ *
994
+ * @returns {void}
995
+ *
996
+ * @example
997
+ * // Update a single cell with a new value and CSS classes
998
+ * tableApi.updateCells([{
999
+ * area: 'body',
1000
+ * rowIndex: 3,
1001
+ * columnIndex: 2,
1002
+ * value: 42,
1003
+ * cssClasses: {
1004
+ * 'highlight': true, // Add 'highlight' class
1005
+ * 'error': false // Remove 'error' class if present
1006
+ * }
1007
+ * }]);
1008
+ *
1009
+ * @example
1010
+ * // Update multiple cells at once
1011
+ * tableApi.updateCells([
1012
+ * {
1013
+ * area: 'body',
1014
+ * rowIndex: 1,
1015
+ * columnIndex: 1,
1016
+ * value: 'New Value 1',
1017
+ * cssClasses: { 'updated': true }
1018
+ * },
1019
+ * {
1020
+ * area: 'body',
1021
+ * rowIndex: 2,
1022
+ * columnIndex: 3,
1023
+ * value: 'New Value 2',
1024
+ * cssClasses: { 'updated': true }
1025
+ * }
1026
+ * ]);
1027
+ *
1028
+ * @example
1029
+ * // Update cells and repaint the entire table
1030
+ * tableApi.updateCells([
1031
+ * { area: 'body', rowIndex: 0, columnIndex: 0, value: 'Hello', cssClasses: { 'bg-green-0': true } },
1032
+ * { area: 'body', rowIndex: 1, columnIndex: 1, value: 'World', cssClasses: { 'bg-red-0': true } }
1033
+ * ], true);
1034
+ *
1035
+ * @example
1036
+ * // High-performance animation example (update without full repaint)
1037
+ * function animateCell() {
1038
+ * const value = Math.sin(Date.now() / 1000) * 50;
1039
+ * const cssClasses = {
1040
+ * 'positive': value > 0,
1041
+ * 'negative': value < 0
1042
+ * };
1043
+ *
1044
+ * tableApi.updateCells([{
1045
+ * area: 'body',
1046
+ * rowIndex: 0,
1047
+ * columnIndex: 0,
1048
+ * value: Math.round(value),
1049
+ * cssClasses
1050
+ * }]);
1051
+ *
1052
+ * requestAnimationFrame(animateCell);
1053
+ * }
1054
+ * animateCell();
652
1055
  */
653
1056
  updateCells(e, t = !1) {
654
1057
  this.tableScope.updateCells(e, t);
655
1058
  }
656
1059
  /**
657
- * Notifies that the external filter has changed.
1060
+ * Notifies the table that an external filter has been changed and needs to be applied.
658
1061
  *
659
- * @return {void}
1062
+ * This method is used when an external filter condition (defined by `tableOptions.externalFilterFunction`)
1063
+ * has changed and the table needs to refresh its display to reflect the new filtering criteria.
1064
+ *
1065
+ * When called, this method:
1066
+ * 1. Applies the external filter function to all rows
1067
+ * 2. Clears the current selection (by default)
1068
+ * 3. Scrolls to the top of the table
1069
+ * 4. Recalculates table dimensions
1070
+ * 5. Repaints the table to display only the filtered rows
1071
+ *
1072
+ * @example
1073
+ * ```typescript
1074
+ * // Define an external filter function in your table options
1075
+ * const tableOptions = {
1076
+ * externalFilterFunction: (row: MyRowType) => {
1077
+ * // Return true to include the row, false to filter it out
1078
+ * return row.status === 'active';
1079
+ * }
1080
+ * };
1081
+ *
1082
+ * // Initialize your table with these options
1083
+ * const tableApi = new TableApi(tableScope);
1084
+ *
1085
+ * // Later, when filter criteria change (e.g., in a search input handler)
1086
+ * function onFilterTextChanged() {
1087
+ * // Update the filter function if needed
1088
+ * tableOptions.externalFilterFunction = (row: MyRowType) => {
1089
+ * return row.name.includes(searchText);
1090
+ * };
1091
+ *
1092
+ * // Apply the updated filter
1093
+ * tableApi.externalFilterChanged();
1094
+ * }
1095
+ * ```
1096
+ *
1097
+ * @returns {void}
1098
+ * @see TableScope.externalFilterChanged
660
1099
  */
661
1100
  externalFilterChanged() {
662
1101
  this.tableScope.externalFilterChanged();
663
1102
  }
664
1103
  /**
665
- * Scrolls the table body to the specified pixel coordinates.
1104
+ * Scrolls the table content to the specified pixel coordinates.
666
1105
  *
667
- * @param {number} px - The horizontal pixel coordinate to scroll to. Defaults to 0.
668
- * @param {number} py - The vertical pixel coordinate to scroll to. Defaults to 0.
669
- * @return {void}
1106
+ * This method allows programmatic scrolling of the table viewport to exact pixel positions.
1107
+ * It delegates the scrolling operation to the underlying TableScope instance.
1108
+ *
1109
+ * @param {number} px - The horizontal pixel coordinate to scroll to. Defaults to 0 (leftmost position).
1110
+ * @param {number} py - The vertical pixel coordinate to scroll to. Defaults to 0 (topmost position).
1111
+ * @returns {void}
1112
+ *
1113
+ * @example
1114
+ * // Scroll to the top-left corner of the table
1115
+ * tableApi.scrollToPixel(0, 0);
1116
+ *
1117
+ * @example
1118
+ * // Scroll 200 pixels horizontally and 150 pixels vertically
1119
+ * tableApi.scrollToPixel(200, 150);
1120
+ *
1121
+ * @example
1122
+ * // Scroll only vertically, keeping the current horizontal position
1123
+ * tableApi.scrollToPixel(undefined, 300);
1124
+ *
1125
+ * @example
1126
+ * // Example in a component that needs precise scrolling control
1127
+ * class TableScroller {
1128
+ * private tableApi: TableApi;
1129
+ *
1130
+ * constructor(tableApi: TableApi) {
1131
+ * this.tableApi = tableApi;
1132
+ * }
1133
+ *
1134
+ * scrollToPosition(x: number, y: number) {
1135
+ * // Scroll to exact pixel coordinates
1136
+ * this.tableApi.scrollToPixel(x, y);
1137
+ * }
1138
+ *
1139
+ * scrollHalfway() {
1140
+ * const tableModel = this.tableApi.getTableModel();
1141
+ * const totalWidth = tableModel.getContentWidthInPixel();
1142
+ * const totalHeight = tableModel.getContentHeightInPixel();
1143
+ *
1144
+ * // Scroll to the middle of the table content
1145
+ * this.tableApi.scrollToPixel(totalWidth / 2, totalHeight / 2);
1146
+ * }
1147
+ * }
1148
+ *
1149
+ * @example
1150
+ * // Advanced usage with animated scrolling
1151
+ * class SmoothScroller {
1152
+ * private tableApi: TableApi;
1153
+ * private animationFrameId: number | null = null;
1154
+ *
1155
+ * constructor(tableApi: TableApi) {
1156
+ * this.tableApi = tableApi;
1157
+ * }
1158
+ *
1159
+ * smoothScrollTo(targetX: number, targetY: number, duration: number = 500) {
1160
+ * // Cancel any ongoing animation
1161
+ * if (this.animationFrameId !== null) {
1162
+ * cancelAnimationFrame(this.animationFrameId);
1163
+ * }
1164
+ *
1165
+ * const startTime = performance.now();
1166
+ * const startX = this.tableApi.getTableScope().getScrollLeft();
1167
+ * const startY = this.tableApi.getTableScope().getScrollTop();
1168
+ * const distanceX = targetX - startX;
1169
+ * const distanceY = targetY - startY;
1170
+ *
1171
+ * const step = (currentTime: number) => {
1172
+ * const elapsed = currentTime - startTime;
1173
+ * const progress = Math.min(elapsed / duration, 1);
1174
+ *
1175
+ * // Use easing function for smooth animation
1176
+ * const easeProgress = 1 - Math.pow(1 - progress, 3); // Cubic ease-out
1177
+ *
1178
+ * const currentX = startX + distanceX * easeProgress;
1179
+ * const currentY = startY + distanceY * easeProgress;
1180
+ *
1181
+ * this.tableApi.scrollToPixel(currentX, currentY);
1182
+ *
1183
+ * if (progress < 1) {
1184
+ * this.animationFrameId = requestAnimationFrame(step);
1185
+ * } else {
1186
+ * this.animationFrameId = null;
1187
+ * }
1188
+ * };
1189
+ *
1190
+ * this.animationFrameId = requestAnimationFrame(step);
1191
+ * }
1192
+ *
1193
+ * cancelAnimation() {
1194
+ * if (this.animationFrameId !== null) {
1195
+ * cancelAnimationFrame(this.animationFrameId);
1196
+ * this.animationFrameId = null;
1197
+ * }
1198
+ * }
1199
+ * }
1200
+ *
1201
+ * @see {@link scrollToIndex} - For scrolling based on row and column indices
1202
+ * @see {@link ensureRowIsVisible} - For scrolling to make a specific row visible
670
1203
  */
671
1204
  scrollToPixel(e = 0, t = 0) {
672
1205
  this.tableScope.scrollToPixel(e, t);
673
1206
  }
674
1207
  /**
675
- * Scrolls to the specified index in both horizontal and vertical directions.
1208
+ * Scrolls the table to display the specified row and column indices at the top-left corner of the viewport.
676
1209
  *
677
- * @param {number} indexX - The index of the column to scroll to in the horizontal direction. Default is 0.
678
- * @param {number} indexY - The index of the row to scroll to in the vertical direction. Default is 0.
1210
+ * This method allows programmatic scrolling to a specific position in the table grid based on row and column indices.
1211
+ * It uses the underlying TableScope's scrolling mechanism to navigate to the target location.
679
1212
  *
680
- * @return undefined
1213
+ * @param {number} indexX - The horizontal index (column) to scroll to. Defaults to 0 (leftmost column).
1214
+ * @param {number} indexY - The vertical index (row) to scroll to. Defaults to 0 (topmost row).
1215
+ * @returns {void}
1216
+ *
1217
+ * @example
1218
+ * // Scroll to the 5th row, keeping the current horizontal scroll position
1219
+ * tableApi.scrollToIndex(0, 5);
1220
+ *
1221
+ * @example
1222
+ * // Scroll to column 3, row 10
1223
+ * tableApi.scrollToIndex(3, 10);
1224
+ *
1225
+ * @example
1226
+ * // Example in a component that needs to navigate to specific content
1227
+ * class TableNavigator {
1228
+ * private tableApi: TableApi;
1229
+ *
1230
+ * constructor(tableApi: TableApi) {
1231
+ * this.tableApi = tableApi;
1232
+ * }
1233
+ *
1234
+ * goToCell(columnIndex: number, rowIndex: number) {
1235
+ * // Navigate directly to the specified cell position
1236
+ * this.tableApi.scrollToIndex(columnIndex, rowIndex);
1237
+ *
1238
+ * // Optional: Select the cell after navigating to it
1239
+ * const selectionModel = this.tableApi.getSelectionModel();
1240
+ * if (selectionModel) {
1241
+ * selectionModel.selectCell(rowIndex, columnIndex);
1242
+ * }
1243
+ * }
1244
+ * }
1245
+ *
1246
+ * @example
1247
+ * // Advanced usage with search functionality
1248
+ * class TableSearcher {
1249
+ * findAndScrollToMatch(searchTerm: string) {
1250
+ * const tableModel = this.tableApi.getTableModel();
1251
+ * const bodyModel = tableModel.getAreaModel('body');
1252
+ *
1253
+ * // Search for the term in the table data
1254
+ * for (let row = 0; row < bodyModel.getRowCount(); row++) {
1255
+ * for (let col = 0; col < tableModel.getColumnCount(); col++) {
1256
+ * const cellContent = bodyModel.getValueAt(row, col)?.toString() || '';
1257
+ *
1258
+ * if (cellContent.includes(searchTerm)) {
1259
+ * // Found a match, scroll to it
1260
+ * this.tableApi.scrollToIndex(col, row);
1261
+ * return true;
1262
+ * }
1263
+ * }
1264
+ * }
1265
+ *
1266
+ * return false; // No match found
1267
+ * }
1268
+ * }
1269
+ *
1270
+ * @see {@link scrollToPixel} - For scrolling to specific pixel coordinates
1271
+ * @see {@link ensureRowIsVisible} - For scrolling to make a specific row visible
681
1272
  */
682
1273
  scrollToIndex(e = 0, t = 0) {
683
1274
  this.tableScope.scrollToIndex(e, t);
@@ -738,19 +1329,71 @@ class ue {
738
1329
  /**
739
1330
  * Repaints the table.
740
1331
  *
741
- * This method calls the repaint method of the tableScope object
742
- * to update and redraw the table based on the latest data.
1332
+ * This method refreshes the visual representation of the table by delegating to the
1333
+ * tableScope's repaint functionality. Use this method whenever the table's visual state
1334
+ * needs to be updated after data changes, selection changes, or any modifications that
1335
+ * affect the rendered output.
1336
+ *
1337
+ * Repainting the table ensures that all visible cells, rows, and styling reflect the
1338
+ * current state of the underlying data model and configuration settings.
1339
+ *
1340
+ * @example
1341
+ * // Update data and repaint the table
1342
+ * const tableApi = new TableApi(tableScope);
1343
+ * tableApi.setRows(newData);
1344
+ * tableApi.repaint();
1345
+ *
1346
+ * @example
1347
+ * // Update selection and repaint to show the visual change
1348
+ * tableApi.getSelectionModel().selectCell(2, 3);
1349
+ * tableApi.repaint();
1350
+ *
1351
+ * @example
1352
+ * // After changing column visibility, repaint to reflect changes
1353
+ * tableApi.setColumnVisible(0, false);
1354
+ * tableApi.repaint();
1355
+ *
1356
+ * @returns {void}
743
1357
  */
744
1358
  repaint() {
745
1359
  this.tableScope.repaint();
746
1360
  }
747
1361
  /**
748
- * Repaints the table scope with hard repaint.
749
- * Repaints the UI by resetting the size of the wrapper div,
750
- * adjusting the containers and rows, and performing additional adjustments
751
- * after scrolling.
1362
+ * Performs a complete repaint of the table by triggering a hard repaint on the underlying table scope.
752
1363
  *
753
- * @return {void}
1364
+ * A hard repaint is more thorough than a regular repaint and performs the following operations:
1365
+ * - Recalculates the height and padding of the table model
1366
+ * - Resets the size of the wrapper div elements
1367
+ * - Adjusts containers and rows positioning
1368
+ * - Makes additional adjustments after scrolling
1369
+ *
1370
+ * Use this method when regular repaint isn't sufficient, such as when:
1371
+ * - Table dimensions have significantly changed
1372
+ * - The structure of data has been modified (rows/columns added or removed)
1373
+ * - The table layout needs complete recalculation
1374
+ * - After major DOM changes affecting the table's container
1375
+ *
1376
+ * @example
1377
+ * // Example 1: Basic usage
1378
+ * tableApi.repaintHard();
1379
+ *
1380
+ * @example
1381
+ * // Example 2: Using after major data changes
1382
+ * tableApi.setRows(newDataSet);
1383
+ * tableApi.repaintHard();
1384
+ *
1385
+ * @example
1386
+ * // Example 3: Using after resizing a container
1387
+ * window.addEventListener('resize', () => {
1388
+ * tableApi.repaintHard();
1389
+ * });
1390
+ *
1391
+ * @example
1392
+ * // Example 4: Using after changing column visibility
1393
+ * tableApi.setColumnVisible(2, false);
1394
+ * tableApi.repaintHard();
1395
+ *
1396
+ * @returns {void} This method doesn't return a value
754
1397
  */
755
1398
  repaintHard() {
756
1399
  this.tableScope.repaintHard();
@@ -766,8 +1409,30 @@ class ue {
766
1409
  this.tableScope.recalcColumnWidths(e);
767
1410
  }
768
1411
  /**
769
- * Clears the current selection of the table.
770
- * The table will be rendered automatically.
1412
+ * Clears the current selection in the table.
1413
+ *
1414
+ * This method removes any selected cells, rows, or columns in the table.
1415
+ * It provides a convenient way to programmatically clear all selections in the table
1416
+ * without having to access the underlying selection model directly.
1417
+ *
1418
+ * When called, this method delegates to the table scope's clearSelection method with
1419
+ * a parameter value of true, which ensures the table is automatically repainted after
1420
+ * the selection is cleared.
1421
+ *
1422
+ * @example
1423
+ * // Clear all selections in the table
1424
+ * tableApi.clearSelection();
1425
+ *
1426
+ * // Example usage in a component
1427
+ * class MyComponent {
1428
+ * @ViewChild('tableComponent') tableComponent: TableComponent;
1429
+ *
1430
+ * resetTableSelection(): void {
1431
+ * if (this.tableComponent?.api) {
1432
+ * this.tableComponent.api.clearSelection();
1433
+ * }
1434
+ * }
1435
+ * }
771
1436
  *
772
1437
  * @returns {void}
773
1438
  */
@@ -775,12 +1440,31 @@ class ue {
775
1440
  this.tableScope.clearSelection(!0);
776
1441
  }
777
1442
  /**
778
- * Sets the selection model for the table scope.
1443
+ * Sets the selection model for the table.
779
1444
  *
780
- * @param {SelectionModel} sm - The selection model to be set.
781
- * @param {boolean} [repaint=true] - Indicates whether the table should be repainted after setting the selection model. Default value is true.
1445
+ * This method allows you to replace the current selection model with a new one,
1446
+ * which controls how cells, rows, or columns can be selected in the table.
782
1447
  *
783
- * @return {void}
1448
+ * @param {SelectionModel} sm - The new selection model to be set. This model defines
1449
+ * the selection behavior including selection type (none, cell, row, column),
1450
+ * selection mode (single, multi), and manages the selected ranges.
1451
+ * @param {boolean} [repaint=true] - Whether to repaint the table after changing the selection model.
1452
+ * Default is true, which immediately reflects the change visually.
1453
+ * Set to false if you want to avoid immediate repainting.
1454
+ *
1455
+ * @example
1456
+ * // Create a new selection model with row selection and multi-select mode
1457
+ * const selectionModel = new SelectionModel("row", "multi");
1458
+ *
1459
+ * // Set the new selection model and repaint the table
1460
+ * tableApi.setSelectionModel(selectionModel);
1461
+ *
1462
+ * // Set a selection model without repainting (if you plan to make more changes)
1463
+ * tableApi.setSelectionModel(selectionModel, false);
1464
+ * // ... make other changes ...
1465
+ * tableApi.repaint(); // Now repaint once
1466
+ *
1467
+ * @returns {void}
784
1468
  */
785
1469
  setSelectionModel(e, t = !0) {
786
1470
  this.tableScope.setSelectionModel(e, t);
@@ -796,9 +1480,36 @@ class ue {
796
1480
  this.tableScope.onActionTriggered(e);
797
1481
  }
798
1482
  /**
799
- * Retrieves the mapping of shortcuts to corresponding action in the current table scope.
1483
+ * Retrieves the shortcut action mapping from the table's shortcut service.
1484
+ *
1485
+ * This method provides access to the keyboard shortcut configuration that defines
1486
+ * which keys trigger specific actions in the table. The mapping contains key-value
1487
+ * pairs where:
1488
+ * - Keys are string representations of keyboard shortcuts (e.g., "ctrl+c", "shift+arrow_down")
1489
+ * - Values are ActionId values representing the corresponding table actions
1490
+ *
1491
+ * This mapping can be useful for:
1492
+ * - Displaying available shortcuts to users
1493
+ * - Creating custom shortcut documentation
1494
+ * - Dynamically checking which actions are available via keyboard
1495
+ * - Extending or integrating with the table's shortcut system
1496
+ *
1497
+ * @returns {ShortcutActionIdMapping} An object mapping shortcut key combinations to their corresponding action IDs.
1498
+ * For example: { "ctrl+c": "COPY_2_CLIPBOARD", "arrow_down": "NAVIGATE_DOWN" }
1499
+ *
1500
+ * @example
1501
+ * // Get all available shortcuts in the table
1502
+ * const shortcuts = tableApi.getShortcutActionMapping();
800
1503
  *
801
- * @return {ShortcutActionIdMapping} The mapping of shortcuts to corresponding action.
1504
+ * // Check if a specific shortcut exists
1505
+ * if (shortcuts["ctrl+c"]) {
1506
+ * console.log("Copy shortcut is available with action:", shortcuts["ctrl+c"]);
1507
+ * }
1508
+ *
1509
+ * // Display available shortcuts in the UI
1510
+ * Object.entries(shortcuts).forEach(([key, actionId]) => {
1511
+ * console.log(`${key}: ${actionId}`);
1512
+ * });
802
1513
  */
803
1514
  getShortcutActionMapping() {
804
1515
  return this.tableScope.shortcutService.getShortcutActionMapping();
@@ -806,7 +1517,35 @@ class ue {
806
1517
  /**
807
1518
  * Copies the selected data from the table to the clipboard.
808
1519
  *
809
- * @return {Promise<string>} - A promise that resolves with the copied data as a string.
1520
+ * This method leverages the copyService to extract and copy the currently selected data
1521
+ * from the table. It works with the current selection state and focus position to determine
1522
+ * what content should be copied.
1523
+ *
1524
+ * The copied data is formatted as tab-separated text that can be pasted into spreadsheet
1525
+ * applications like Excel or text editors while maintaining the tabular structure.
1526
+ *
1527
+ * @example
1528
+ * // Copy the currently selected data to clipboard
1529
+ * tableApi.copyToClipboard().then(content => {
1530
+ * console.log('Copied to clipboard:', content);
1531
+ * });
1532
+ *
1533
+ * // Using with a button click handler
1534
+ * function onCopyButtonClick() {
1535
+ * if (tableApi) {
1536
+ * tableApi.copyToClipboard()
1537
+ * .then(content => {
1538
+ * console.log('Successfully copied data to clipboard');
1539
+ * // Optionally do something with the copied content
1540
+ * })
1541
+ * .catch(error => {
1542
+ * console.error('Failed to copy to clipboard:', error);
1543
+ * });
1544
+ * }
1545
+ * }
1546
+ *
1547
+ * @returns {Promise<string>} A promise that resolves with the copied data as a string.
1548
+ * The string contains the tab-separated representation of the selected table data.
810
1549
  */
811
1550
  copyToClipboard() {
812
1551
  return this.tableScope.copyService.copyToClipboard(
@@ -816,11 +1555,33 @@ class ue {
816
1555
  );
817
1556
  }
818
1557
  /**
819
- * Generates and downloads an Excel file based on the table data.
1558
+ * Downloads the current table data as an Excel file.
1559
+ *
1560
+ * This method extracts all visible data from the table (including header, body, and footer areas),
1561
+ * converts it into a matrix format, and triggers a download of an Excel file containing this data.
820
1562
  *
821
- * @param {string} fileName - The name of the Excel file to be downloaded. Defaults to 'table.xlsx'.
822
- * @param {string} author - The author of the Excel file. If not provided, it will remain empty.
823
- * @return {void} No return value. Initiates a file download of the Excel document.
1563
+ * The method works by:
1564
+ * 1. Creating an empty matrix to hold all table data
1565
+ * 2. Iterating through each area of the table (header, body, footer)
1566
+ * 3. For each area, iterating through all rows and columns to extract cell values
1567
+ * 4. Passing the complete data matrix to the Excel service for file generation and download
1568
+ *
1569
+ * @param {string} fileName - The name of the Excel file to be downloaded (default: 'table.xlsx')
1570
+ * @param {string} author - Optional metadata for the Excel file to specify the author (default: '')
1571
+ *
1572
+ * @returns {void} The result of the excelService.downloadExcel method call
1573
+ *
1574
+ * @example
1575
+ * // Download table data with default filename
1576
+ * tableApi.downloadExcel();
1577
+ *
1578
+ * @example
1579
+ * // Download table data with custom filename and author
1580
+ * tableApi.downloadExcel('sales-report.xlsx', 'John Doe');
1581
+ *
1582
+ * @example
1583
+ * // Download table data with custom filename only
1584
+ * tableApi.downloadExcel('quarterly-data.xlsx');
824
1585
  */
825
1586
  downloadExcel(e = "table.xlsx", t = "") {
826
1587
  const s = [], o = this.tableScope.tableModel.getColumnCount(), i = ["header", "body", "footer"];
@@ -836,18 +1597,66 @@ class ue {
836
1597
  return this.tableScope.excelService.downloadExcel(s, e, t);
837
1598
  }
838
1599
  /**
839
- * Retrieves the current scope of the table.
1600
+ * Returns the TableScope instance associated with this TableApi.
1601
+ *
1602
+ * The TableScope provides access to the core functionality and internal state of the table component,
1603
+ * including rendering, event handling, selection, and other low-level operations.
1604
+ *
1605
+ * This method is useful for advanced customization scenarios where you need direct access
1606
+ * to the table's internal structure and behaviors.
1607
+ *
1608
+ * @returns {TableScope} The TableScope instance that controls this table component
840
1609
  *
841
- * @returns {TableScope} The current scope of the table.
1610
+ * @example
1611
+ * // Access the TableScope to perform a custom operation
1612
+ * const tableApi = new TableApi(myTableScope);
1613
+ * const tableScope = tableApi.getTableScope();
1614
+ *
1615
+ * // Example: Manually trigger a context menu at a specific location
1616
+ * const mouseEvent = new MouseEvent('contextmenu');
1617
+ * const geMouseEvent = tableScope.createGeMouseEvent(mouseEvent);
1618
+ * tableScope.contextmenu(geMouseEvent);
842
1619
  */
843
1620
  getTableScope() {
844
1621
  return this.tableScope;
845
1622
  }
846
1623
  /**
847
- * Retrieves the selection model of the table.
1624
+ * Returns the current selection model for the table.
1625
+ *
1626
+ * The selection model manages cell selection state, including single cells, ranges, rows, and columns.
1627
+ * This method provides access to the selection model instance, allowing operations like:
1628
+ * - Checking if cells are selected
1629
+ * - Getting selection ranges
1630
+ * - Modifying selections
1631
+ * - Adding/removing selection event listeners
1632
+ *
1633
+ * @returns {SelectionModelIf | undefined} The current selection model if available, otherwise undefined.
1634
+ *
1635
+ * @example
1636
+ * // Get the selection model
1637
+ * const selectionModel = tableApi.getSelectionModel();
1638
+ *
1639
+ * // Check if a specific cell is selected
1640
+ * if (selectionModel?.isSelected(3, 2)) {
1641
+ * console.log('Cell at row 3, column 2 is selected');
1642
+ * }
1643
+ *
1644
+ * // Get all selected ranges
1645
+ * const ranges = selectionModel?.getRanges();
1646
+ * console.log('Selected ranges:', ranges);
1647
+ *
1648
+ * // Clear all selections
1649
+ * selectionModel?.clear();
848
1650
  *
849
- * @return {SelectionModelIf | undefined} The selection model of the table,
850
- * or undefined if no selection model is available.
1651
+ * // Toggle selection of a cell
1652
+ * selectionModel?.togglePoint(5, 1);
1653
+ *
1654
+ * // Add a selection change listener
1655
+ * selectionModel?.addEventSelectionChangedListener({
1656
+ * selectionChanged: () => {
1657
+ * console.log('Selection has changed');
1658
+ * }
1659
+ * });
851
1660
  */
852
1661
  getSelectionModel() {
853
1662
  return this.tableScope.selectionModel();
@@ -1328,18 +2137,181 @@ class ue {
1328
2137
  getFirstVisibleRowIndex() {
1329
2138
  return this.tableScope.getFirstVisibleRowIndex();
1330
2139
  }
2140
+ /**
2141
+ * Retrieves the index of the first fully visible row in the table's viewport.
2142
+ *
2143
+ * A row is considered "fully visible" when it's completely within the visible area of the table.
2144
+ * This differs from the regular "visible" row, which might be partially visible at the edges of the viewport.
2145
+ *
2146
+ * This method is useful for:
2147
+ * - Determining which rows are completely in view for operations that require full visibility
2148
+ * - Implementing pagination or virtualization logic that needs to know complete row visibility
2149
+ * - Supporting keyboard navigation that should skip partially visible rows
2150
+ *
2151
+ * @returns {number} The index of the first fully visible row, or -1 if no rows are fully visible
2152
+ *
2153
+ * @example
2154
+ * // Get the first fully visible row index
2155
+ * const firstFullVisibleRow = tableApi.getFirstFullVisibleRowIndex();
2156
+ *
2157
+ * // Check if a specific row is fully visible
2158
+ * const isRowFullyVisible = (rowIndex) => {
2159
+ * const firstFullVisible = tableApi.getFirstFullVisibleRowIndex();
2160
+ * const lastFullVisible = tableApi.getLastFullVisibleRowIndex();
2161
+ * return rowIndex >= firstFullVisible && rowIndex <= lastFullVisible;
2162
+ * };
2163
+ */
1331
2164
  getFirstFullVisibleRowIndex() {
1332
2165
  return this.tableScope.getFirstFullVisibleRowIndex();
1333
2166
  }
2167
+ /**
2168
+ * Returns the index of the last row that is visible in the table's viewport.
2169
+ *
2170
+ * This method retrieves the last visible row index from the table scope, which keeps
2171
+ * track of which rows are currently visible as the user scrolls through the table.
2172
+ *
2173
+ * This can be useful for:
2174
+ * - Implementing virtualized scrolling optimizations
2175
+ * - Determining if specific rows are currently in view
2176
+ * - Implementing features that need to know the visible range of rows
2177
+ *
2178
+ * @returns {number} The index of the last visible row in the table viewport
2179
+ *
2180
+ * @example
2181
+ * // Check if a specific row is currently visible in the viewport
2182
+ * const lastVisibleIndex = tableApi.getLastVisibleRowIndex();
2183
+ * const firstVisibleIndex = tableApi.getFirstVisibleRowIndex();
2184
+ * const isRowVisible = rowIndex >= firstVisibleIndex && rowIndex <= lastVisibleIndex;
2185
+ *
2186
+ * @example
2187
+ * // Get the range of visible rows
2188
+ * const visibleRowsRange = {
2189
+ * first: tableApi.getFirstVisibleRowIndex(),
2190
+ * last: tableApi.getLastVisibleRowIndex()
2191
+ * };
2192
+ * console.log(`Visible rows: ${visibleRowsRange.first} to ${visibleRowsRange.last}`);
2193
+ */
1334
2194
  getLastVisibleRowIndex() {
1335
2195
  return this.tableScope.getLastVisibleRowIndex();
1336
2196
  }
2197
+ /**
2198
+ * Returns the index of the last fully visible row in the table's viewport.
2199
+ *
2200
+ * This method retrieves the last row that is completely visible within the current
2201
+ * viewport of the table. A row is considered "fully visible" when its entire height
2202
+ * is visible without any portion being cut off by the viewport boundaries.
2203
+ *
2204
+ * The distinction between "visible" and "fully visible" is important when scrolling:
2205
+ * - A row can be partially visible (some portion is in view)
2206
+ * - A row can be fully visible (the entire row is in view)
2207
+ *
2208
+ * @returns {number} The index of the last fully visible row in the table.
2209
+ * If no row is fully visible or the table is empty, the method might return -1.
2210
+ *
2211
+ * @example
2212
+ * ```typescript
2213
+ * // Get the index of the last fully visible row
2214
+ * const lastVisibleRowIndex = tableApi.getLastFullVisibleRowIndex();
2215
+ *
2216
+ * // Use this information to determine if a specific row is fully visible
2217
+ * const isRowFullyVisible = rowIndex <= lastVisibleRowIndex && rowIndex >= tableApi.getFirstFullVisibleRowIndex();
2218
+ *
2219
+ * // Can be used with scrolling operations to ensure certain rows are visible
2220
+ * if (rowIndex > lastVisibleRowIndex) {
2221
+ * tableApi.ensureRowIsVisible(rowIndex);
2222
+ * }
2223
+ * ```
2224
+ */
1337
2225
  getLastFullVisibleRowIndex() {
1338
2226
  return this.tableScope.getLastFullVisibleRowIndex();
1339
2227
  }
2228
+ /**
2229
+ * Checks whether logging is currently active for the table component.
2230
+ *
2231
+ * This method returns the current state of logging for the table. When logging is active,
2232
+ * the table outputs detailed information about its operations to the console, including:
2233
+ *
2234
+ * - Rendering processes and lifecycle events
2235
+ * - Data modifications and updates
2236
+ * - Event handling and user interactions
2237
+ * - Performance metrics and state changes
2238
+ *
2239
+ * Logging can be toggled using the `setLoggingActive(boolean)` method.
2240
+ *
2241
+ * @returns {boolean} True if logging is currently enabled, false otherwise.
2242
+ *
2243
+ * @example
2244
+ * // Check if logging is enabled
2245
+ * if (tableApi.isLoggingActive()) {
2246
+ * console.log("Table logging is currently active");
2247
+ * }
2248
+ *
2249
+ * // Conditionally enable logging only if it's not already active
2250
+ * if (!tableApi.isLoggingActive()) {
2251
+ * tableApi.setLoggingActive(true);
2252
+ *
2253
+ * // Perform operations that need debugging
2254
+ * tableApi.updateCells([
2255
+ * {
2256
+ * area: "body",
2257
+ * rowIndex: 2,
2258
+ * columnIndex: 3,
2259
+ * value: "New Value",
2260
+ * cssClasses: { "highlight": true }
2261
+ * }
2262
+ * ]);
2263
+ *
2264
+ * // Run some additional operations...
2265
+ *
2266
+ * // Disable logging when finished
2267
+ * tableApi.setLoggingActive(false);
2268
+ * }
2269
+ */
1340
2270
  setLoggingActive(e) {
1341
2271
  this.tableScope.loggingActive = e;
1342
2272
  }
2273
+ /**
2274
+ * Checks whether logging is currently active for the table component.
2275
+ *
2276
+ * This method returns the current state of logging for the table. When logging is active,
2277
+ * the table outputs detailed information about its operations to the console, including:
2278
+ *
2279
+ * - Rendering processes and lifecycle events
2280
+ * - Data modifications and updates
2281
+ * - Event handling and user interactions
2282
+ * - Performance metrics and state changes
2283
+ *
2284
+ * Logging can be toggled using the `setLoggingActive(boolean)` method.
2285
+ *
2286
+ * @returns {boolean} True if logging is currently enabled, false otherwise.
2287
+ *
2288
+ * @example
2289
+ * // Check if logging is enabled
2290
+ * if (tableApi.isLoggingActive()) {
2291
+ * console.log("Table logging is currently active");
2292
+ * }
2293
+ *
2294
+ * // Conditionally enable logging only if it's not already active
2295
+ * if (!tableApi.isLoggingActive()) {
2296
+ * tableApi.setLoggingActive(true);
2297
+ *
2298
+ * // Perform operations that need debugging
2299
+ * tableApi.updateCells([
2300
+ * {
2301
+ * area: "body",
2302
+ * rowIndex: 2,
2303
+ * columnIndex: 3,
2304
+ * value: "New Value",
2305
+ * cssClasses: { "highlight": true }
2306
+ * }
2307
+ * ]);
2308
+ *
2309
+ * // Run some additional operations...
2310
+ *
2311
+ * // Disable logging when finished
2312
+ * tableApi.setLoggingActive(false);
2313
+ * }
2314
+ */
1343
2315
  isLoggingActive() {
1344
2316
  return this.tableScope.loggingActive;
1345
2317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/vue3-table",
3
- "version": "3.1.79",
3
+ "version": "3.1.80",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -8,7 +8,9 @@
8
8
  "entryFile": "src/index.ts"
9
9
  },
10
10
  "publishConfig": {
11
- "directory": "dist"
11
+ "directory": "dist",
12
+ "registry": "https://registry.npmjs.org/",
13
+ "access": "public"
12
14
  },
13
15
  "exports": {
14
16
  ".": {
@@ -21,7 +23,7 @@
21
23
  "vue": "^3.2.47",
22
24
  "vue-i18n": "11.1.2",
23
25
  "vue-router": "^4.1.6",
24
- "@guiexpert/table": "^1.1.79"
26
+ "@guiexpert/table": "^1.1.80"
25
27
  },
26
28
  "devDependencies": {
27
29
  "@cypress/vue": "^5.0.4",