tabulator-tables 5.1.4 → 5.1.5

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.
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.1.4 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.1.5 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -14901,17 +14901,18 @@ class Page extends Module{
14901
14901
  this.trackChanges();
14902
14902
  }
14903
14903
 
14904
- _setPageCounter(totalRows){
14905
- var content, currentRow;
14904
+ _setPageCounter(totalRows, size, currentRow){
14905
+ var content;
14906
14906
 
14907
14907
  if(this.pageCounter){
14908
- currentRow = ((this.page - 1) * this.size) + 1;
14909
14908
 
14910
14909
  if(this.mode === "remote"){
14910
+ size = this.size;
14911
+ currentRow = ((this.page - 1) * this.size) + 1;
14911
14912
  totalRows = this.remoteRowCountEstimate;
14912
14913
  }
14913
14914
 
14914
- content = this.pageCounter.call(this, this.size, currentRow, this.page, totalRows, this.max);
14915
+ content = this.pageCounter.call(this, size, currentRow, this.page, totalRows, this.max);
14915
14916
 
14916
14917
  switch(typeof content){
14917
14918
  case "object":
@@ -15051,7 +15052,12 @@ class Page extends Module{
15051
15052
 
15052
15053
  //return appropriate rows for current page
15053
15054
  getRows(data){
15054
- var output, start, end;
15055
+ var actualRowPageSize = 0,
15056
+ output, start, end, actualStartRow;
15057
+
15058
+ var actualRows = data.filter((row) => {
15059
+ return row.type === "row";
15060
+ });
15055
15061
 
15056
15062
  if(this.mode == "local"){
15057
15063
  output = [];
@@ -15066,21 +15072,30 @@ class Page extends Module{
15066
15072
  end = start + parseInt(this.size);
15067
15073
  }
15068
15074
 
15069
-
15070
15075
  this._setPageButtons();
15071
15076
 
15072
15077
  for(let i = start; i < end; i++){
15073
- if(data[i]){
15074
- output.push(data[i]);
15078
+ let row = data[i];
15079
+
15080
+ if(row){
15081
+ output.push(row);
15082
+
15083
+ if(row.type === "row"){
15084
+ if(!actualStartRow){
15085
+ actualStartRow = row;
15086
+ }
15087
+
15088
+ actualRowPageSize++;
15089
+ }
15075
15090
  }
15076
15091
  }
15077
-
15078
- this._setPageCounter(data.length);
15092
+
15093
+ this._setPageCounter(actualRows.length, actualRowPageSize, actualStartRow ? (actualRows.indexOf(actualStartRow) + 1) : 0);
15079
15094
 
15080
15095
  return output;
15081
15096
  }else {
15082
15097
  this._setPageButtons();
15083
- this._setPageCounter(data.length);
15098
+ this._setPageCounter(actualRows.length);
15084
15099
 
15085
15100
  return data.slice(0);
15086
15101
  }
@@ -18814,15 +18829,18 @@ class VirtualDomHorizontal extends Renderer{
18814
18829
 
18815
18830
  this.fitDataColAvg = 0;
18816
18831
 
18817
- this.window = 200; //pixel margin to make column visible before it is shown on screen
18832
+ this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
18833
+
18818
18834
 
18819
18835
  this.initialized = false;
18836
+ this.isFitData = false;
18820
18837
 
18821
18838
  this.columns = [];
18822
18839
  }
18823
18840
 
18824
18841
  initialize(){
18825
18842
  this.compatibilityCheck();
18843
+ this.layoutCheck();
18826
18844
  }
18827
18845
 
18828
18846
  compatibilityCheck(){
@@ -18862,6 +18880,10 @@ class VirtualDomHorizontal extends Renderer{
18862
18880
 
18863
18881
  return ok;
18864
18882
  }
18883
+
18884
+ layoutCheck(){
18885
+ this.isFitData = this.options("layout").startsWith('fitData');
18886
+ }
18865
18887
 
18866
18888
  //////////////////////////////////////
18867
18889
  ///////// Public Functions ///////////
@@ -18875,42 +18897,60 @@ class VirtualDomHorizontal extends Renderer{
18875
18897
  if(this.scrollLeft != left){
18876
18898
  this.scrollLeft = left;
18877
18899
 
18878
- this.scroll(left - (this.vDomScrollPosLeft + this.window));
18900
+ this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));
18879
18901
  }
18880
18902
  }
18903
+
18904
+ calcWindowBuffer(){
18905
+ var buffer = this.elementVertical.clientWidth;
18906
+
18907
+ this.table.columnManager.columnsByIndex.forEach((column) => {
18908
+ if(column.visible){
18909
+ var width = column.getWidth();
18910
+
18911
+ if(width > buffer){
18912
+ buffer = width;
18913
+ }
18914
+ }
18915
+ });
18916
+
18917
+ this.windowBuffer = buffer * 2;
18918
+ }
18881
18919
 
18882
18920
  rerenderColumns(update, blockRedraw){
18883
18921
  var old = {
18884
18922
  cols:this.columns,
18885
18923
  leftCol:this.leftCol,
18886
18924
  rightCol:this.rightCol,
18887
- };
18925
+ },
18926
+ colPos = 0;
18927
+
18888
18928
 
18889
18929
  if(update && !this.initialized){
18890
18930
  return;
18891
18931
  }
18892
18932
 
18893
18933
  this.clear();
18934
+
18935
+ this.calcWindowBuffer();
18894
18936
 
18895
18937
  this.scrollLeft = this.elementVertical.scrollLeft;
18896
18938
 
18897
- this.vDomScrollPosLeft = this.scrollLeft - this.window;
18898
- this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window;
18899
-
18900
- var colPos = 0;
18901
-
18939
+ this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;
18940
+ this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
18941
+
18902
18942
  this.table.columnManager.columnsByIndex.forEach((column) => {
18903
18943
  var config = {};
18904
18944
 
18905
18945
  if(column.visible){
18906
18946
  var width = column.getWidth();
18907
-
18947
+
18908
18948
  config.leftPos = colPos;
18909
18949
  config.rightPos = colPos + width;
18910
18950
 
18911
18951
  config.width = width;
18912
18952
 
18913
- if (this.options("layout") === "fitData") {
18953
+ if (this.isFitData) {
18914
18954
  config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
18915
18955
  }
18916
18956
 
@@ -18999,7 +19039,7 @@ class VirtualDomHorizontal extends Renderer{
18999
19039
  colEnd = 0,
19000
19040
  row, rowEl;
19001
19041
 
19002
- if(this.options("layout") === "fitData"){
19042
+ if(this.isFitData){
19003
19043
  this.table.columnManager.columnsByIndex.forEach((column) => {
19004
19044
  if(!column.definition.width && column.visible){
19005
19045
  change = true;
@@ -19009,7 +19049,7 @@ class VirtualDomHorizontal extends Renderer{
19009
19049
  if(change){
19010
19050
  if(change && this.table.rowManager.getDisplayRows().length){
19011
19051
 
19012
- this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window;
19052
+ this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
19013
19053
 
19014
19054
  var row = this.chain("rows-sample", [1], [], () => {
19015
19055
  return this.table.rowManager.getDisplayRows();