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.
package/bower.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tabulator",
3
3
  "main": "dist/js/tabulator.js",
4
- "version": "5.1.4",
4
+ "version": "5.1.5",
5
5
  "description": "Interactive table generation JavaScript library",
6
6
  "keywords": [
7
7
  "table",
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.1.4 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.1.5 (c) Oliver Folkerd 2022 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -2542,9 +2542,10 @@
2542
2542
  _this.vDomPadLeft = 0;
2543
2543
  _this.vDomPadRight = 0;
2544
2544
  _this.fitDataColAvg = 0;
2545
- _this.window = 200; //pixel margin to make column visible before it is shown on screen
2545
+ _this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
2546
2546
 
2547
2547
  _this.initialized = false;
2548
+ _this.isFitData = false;
2548
2549
  _this.columns = [];
2549
2550
  return _this;
2550
2551
  }
@@ -2553,6 +2554,7 @@
2553
2554
  key: "initialize",
2554
2555
  value: function initialize() {
2555
2556
  this.compatibilityCheck();
2557
+ this.layoutCheck();
2556
2558
  }
2557
2559
  }, {
2558
2560
  key: "compatibilityCheck",
@@ -2591,6 +2593,11 @@
2591
2593
 
2592
2594
 
2593
2595
  return ok;
2596
+ }
2597
+ }, {
2598
+ key: "layoutCheck",
2599
+ value: function layoutCheck() {
2600
+ this.isFitData = this.options("layout").startsWith('fitData');
2594
2601
  } //////////////////////////////////////
2595
2602
  ///////// Public Functions ///////////
2596
2603
  //////////////////////////////////////
@@ -2605,9 +2612,24 @@
2605
2612
  value: function scrollColumns(left, dir) {
2606
2613
  if (this.scrollLeft != left) {
2607
2614
  this.scrollLeft = left;
2608
- this.scroll(left - (this.vDomScrollPosLeft + this.window));
2615
+ this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));
2609
2616
  }
2610
2617
  }
2618
+ }, {
2619
+ key: "calcWindowBuffer",
2620
+ value: function calcWindowBuffer() {
2621
+ var buffer = this.elementVertical.clientWidth;
2622
+ this.table.columnManager.columnsByIndex.forEach(function (column) {
2623
+ if (column.visible) {
2624
+ var width = column.getWidth();
2625
+
2626
+ if (width > buffer) {
2627
+ buffer = width;
2628
+ }
2629
+ }
2630
+ });
2631
+ this.windowBuffer = buffer * 2;
2632
+ }
2611
2633
  }, {
2612
2634
  key: "rerenderColumns",
2613
2635
  value: function rerenderColumns(update, blockRedraw) {
@@ -2617,17 +2639,18 @@
2617
2639
  cols: this.columns,
2618
2640
  leftCol: this.leftCol,
2619
2641
  rightCol: this.rightCol
2620
- };
2642
+ },
2643
+ colPos = 0;
2621
2644
 
2622
2645
  if (update && !this.initialized) {
2623
2646
  return;
2624
2647
  }
2625
2648
 
2626
2649
  this.clear();
2650
+ this.calcWindowBuffer();
2627
2651
  this.scrollLeft = this.elementVertical.scrollLeft;
2628
- this.vDomScrollPosLeft = this.scrollLeft - this.window;
2629
- this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window;
2630
- var colPos = 0;
2652
+ this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;
2653
+ this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
2631
2654
  this.table.columnManager.columnsByIndex.forEach(function (column) {
2632
2655
  var config = {};
2633
2656
 
@@ -2637,7 +2660,7 @@
2637
2660
  config.rightPos = colPos + width;
2638
2661
  config.width = width;
2639
2662
 
2640
- if (_this2.options("layout") === "fitData") {
2663
+ if (_this2.isFitData) {
2641
2664
  config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
2642
2665
  }
2643
2666
 
@@ -2728,7 +2751,7 @@
2728
2751
  row,
2729
2752
  rowEl;
2730
2753
 
2731
- if (this.options("layout") === "fitData") {
2754
+ if (this.isFitData) {
2732
2755
  this.table.columnManager.columnsByIndex.forEach(function (column) {
2733
2756
  if (!column.definition.width && column.visible) {
2734
2757
  change = true;
@@ -2737,7 +2760,7 @@
2737
2760
 
2738
2761
  if (change) {
2739
2762
  if (change && this.table.rowManager.getDisplayRows().length) {
2740
- this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window;
2763
+ this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
2741
2764
  var row = this.chain("rows-sample", [1], [], function () {
2742
2765
  return _this3.table.rowManager.getDisplayRows();
2743
2766
  })[0];
@@ -21913,17 +21936,17 @@
21913
21936
  }
21914
21937
  }, {
21915
21938
  key: "_setPageCounter",
21916
- value: function _setPageCounter(totalRows) {
21917
- var content, currentRow;
21939
+ value: function _setPageCounter(totalRows, size, currentRow) {
21940
+ var content;
21918
21941
 
21919
21942
  if (this.pageCounter) {
21920
- currentRow = (this.page - 1) * this.size + 1;
21921
-
21922
21943
  if (this.mode === "remote") {
21944
+ size = this.size;
21945
+ currentRow = (this.page - 1) * this.size + 1;
21923
21946
  totalRows = this.remoteRowCountEstimate;
21924
21947
  }
21925
21948
 
21926
- content = this.pageCounter.call(this, this.size, currentRow, this.page, totalRows, this.max);
21949
+ content = this.pageCounter.call(this, size, currentRow, this.page, totalRows, this.max);
21927
21950
 
21928
21951
  switch (_typeof(content)) {
21929
21952
  case "object":
@@ -22071,7 +22094,14 @@
22071
22094
  }, {
22072
22095
  key: "getRows",
22073
22096
  value: function getRows(data) {
22074
- var output, start, end;
22097
+ var actualRowPageSize = 0,
22098
+ output,
22099
+ start,
22100
+ end,
22101
+ actualStartRow;
22102
+ var actualRows = data.filter(function (row) {
22103
+ return row.type === "row";
22104
+ });
22075
22105
 
22076
22106
  if (this.mode == "local") {
22077
22107
  output = [];
@@ -22088,18 +22118,28 @@
22088
22118
  this._setPageButtons();
22089
22119
 
22090
22120
  for (var i = start; i < end; i++) {
22091
- if (data[i]) {
22092
- output.push(data[i]);
22121
+ var row = data[i];
22122
+
22123
+ if (row) {
22124
+ output.push(row);
22125
+
22126
+ if (row.type === "row") {
22127
+ if (!actualStartRow) {
22128
+ actualStartRow = row;
22129
+ }
22130
+
22131
+ actualRowPageSize++;
22132
+ }
22093
22133
  }
22094
22134
  }
22095
22135
 
22096
- this._setPageCounter(data.length);
22136
+ this._setPageCounter(actualRows.length, actualRowPageSize, actualStartRow ? actualRows.indexOf(actualStartRow) + 1 : 0);
22097
22137
 
22098
22138
  return output;
22099
22139
  } else {
22100
22140
  this._setPageButtons();
22101
22141
 
22102
- this._setPageCounter(data.length);
22142
+ this._setPageCounter(actualRows.length);
22103
22143
 
22104
22144
  return data.slice(0);
22105
22145
  }