@guiexpert/react-table 18.1.79 → 18.1.81

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