tabulator-tables 5.1.5 → 5.1.6

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.5",
4
+ "version": "5.1.6",
5
5
  "description": "Interactive table generation JavaScript library",
6
6
  "keywords": [
7
7
  "table",
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.1.5 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.1.6 (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) :
@@ -2544,6 +2544,7 @@
2544
2544
  _this.fitDataColAvg = 0;
2545
2545
  _this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
2546
2546
 
2547
+ _this.visibleRows = null;
2547
2548
  _this.initialized = false;
2548
2549
  _this.isFitData = false;
2549
2550
  _this.columns = [];
@@ -2555,6 +2556,7 @@
2555
2556
  value: function initialize() {
2556
2557
  this.compatibilityCheck();
2557
2558
  this.layoutCheck();
2559
+ this.vertScrollListen();
2558
2560
  }
2559
2561
  }, {
2560
2562
  key: "compatibilityCheck",
@@ -2598,6 +2600,15 @@
2598
2600
  key: "layoutCheck",
2599
2601
  value: function layoutCheck() {
2600
2602
  this.isFitData = this.options("layout").startsWith('fitData');
2603
+ }
2604
+ }, {
2605
+ key: "vertScrollListen",
2606
+ value: function vertScrollListen() {
2607
+ var _this2 = this;
2608
+
2609
+ this.subscribe("scroll-vertical", function () {
2610
+ _this2.visibleRows = null;
2611
+ });
2601
2612
  } //////////////////////////////////////
2602
2613
  ///////// Public Functions ///////////
2603
2614
  //////////////////////////////////////
@@ -2633,7 +2644,7 @@
2633
2644
  }, {
2634
2645
  key: "rerenderColumns",
2635
2646
  value: function rerenderColumns(update, blockRedraw) {
2636
- var _this2 = this;
2647
+ var _this3 = this;
2637
2648
 
2638
2649
  var old = {
2639
2650
  cols: this.columns,
@@ -2660,26 +2671,26 @@
2660
2671
  config.rightPos = colPos + width;
2661
2672
  config.width = width;
2662
2673
 
2663
- if (_this2.isFitData) {
2674
+ if (_this3.isFitData) {
2664
2675
  config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;
2665
2676
  }
2666
2677
 
2667
- if (colPos + width > _this2.vDomScrollPosLeft && colPos < _this2.vDomScrollPosRight) {
2678
+ if (colPos + width > _this3.vDomScrollPosLeft && colPos < _this3.vDomScrollPosRight) {
2668
2679
  //column is visible
2669
- if (_this2.leftCol == -1) {
2670
- _this2.leftCol = _this2.columns.length;
2671
- _this2.vDomPadLeft = colPos;
2680
+ if (_this3.leftCol == -1) {
2681
+ _this3.leftCol = _this3.columns.length;
2682
+ _this3.vDomPadLeft = colPos;
2672
2683
  }
2673
2684
 
2674
- _this2.rightCol = _this2.columns.length;
2685
+ _this3.rightCol = _this3.columns.length;
2675
2686
  } else {
2676
2687
  // column is hidden
2677
- if (_this2.leftCol !== -1) {
2678
- _this2.vDomPadRight += width;
2688
+ if (_this3.leftCol !== -1) {
2689
+ _this3.vDomPadRight += width;
2679
2690
  }
2680
2691
  }
2681
2692
 
2682
- _this2.columns.push(column);
2693
+ _this3.columns.push(column);
2683
2694
 
2684
2695
  column.modules.vdomHoz = config;
2685
2696
  colPos += width;
@@ -2743,7 +2754,7 @@
2743
2754
  }, {
2744
2755
  key: "dataChange",
2745
2756
  value: function dataChange() {
2746
- var _this3 = this;
2757
+ var _this4 = this;
2747
2758
 
2748
2759
  var change = false,
2749
2760
  collsWidth = 0,
@@ -2762,7 +2773,7 @@
2762
2773
  if (change && this.table.rowManager.getDisplayRows().length) {
2763
2774
  this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
2764
2775
  var row = this.chain("rows-sample", [1], [], function () {
2765
- return _this3.table.rowManager.getDisplayRows();
2776
+ return _this4.table.rowManager.getDisplayRows();
2766
2777
  })[0];
2767
2778
 
2768
2779
  if (row) {
@@ -2774,19 +2785,15 @@
2774
2785
  var cell = row.cells[colEnd];
2775
2786
  rowEl.appendChild(cell.getElement());
2776
2787
  cell.column.reinitializeWidth();
2777
- collsWidth += cell.column.getWidth();
2778
-
2779
- if (collsWidth > this.vDomScrollPosRight) {
2780
- break;
2781
- }
2788
+ collsWidth += cell.column.getWidth(); // if(collsWidth > this.vDomScrollPosRight){
2789
+ // break;
2790
+ // }
2782
2791
  }
2783
2792
 
2784
- rowEl.parentNode.removeChild(rowEl);
2785
- this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));
2786
-
2787
- for (colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++) {
2788
- this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);
2789
- }
2793
+ rowEl.parentNode.removeChild(rowEl); // this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));
2794
+ // for(colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++){
2795
+ // this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);
2796
+ // }
2790
2797
 
2791
2798
  this.rerenderColumns(false, true);
2792
2799
  }
@@ -2802,7 +2809,7 @@
2802
2809
  }, {
2803
2810
  key: "reinitChanged",
2804
2811
  value: function reinitChanged(old) {
2805
- var _this4 = this;
2812
+ var _this5 = this;
2806
2813
 
2807
2814
  var match = true;
2808
2815
 
@@ -2811,7 +2818,7 @@
2811
2818
  }
2812
2819
 
2813
2820
  old.cols.forEach(function (col, i) {
2814
- if (col !== _this4.columns[i]) {
2821
+ if (col !== _this5.columns[i]) {
2815
2822
  match = false;
2816
2823
  }
2817
2824
  });
@@ -2820,20 +2827,29 @@
2820
2827
  }, {
2821
2828
  key: "reinitializeRows",
2822
2829
  value: function reinitializeRows() {
2823
- var _this5 = this;
2830
+ var _this6 = this;
2824
2831
 
2825
- var rows = this.table.rowManager.getVisibleRows();
2832
+ var rows = this.getVisibleRows();
2826
2833
  rows.forEach(function (row) {
2827
- _this5.reinitializeRow(row, true);
2834
+ _this6.reinitializeRow(row, true);
2828
2835
  });
2829
2836
  }
2837
+ }, {
2838
+ key: "getVisibleRows",
2839
+ value: function getVisibleRows() {
2840
+ if (!this.visibleRows) {
2841
+ this.visibleRows = this.table.rowManager.getVisibleRows();
2842
+ }
2843
+
2844
+ return this.visibleRows;
2845
+ }
2830
2846
  }, {
2831
2847
  key: "scroll",
2832
2848
  value: function scroll(diff) {
2833
2849
  this.vDomScrollPosLeft += diff;
2834
2850
  this.vDomScrollPosRight += diff;
2835
2851
 
2836
- if (diff > this.elementVertical.clientWidth * .8) {
2852
+ if (Math.abs(diff) > this.windowBuffer / 2) {
2837
2853
  this.rerenderColumns();
2838
2854
  } else {
2839
2855
  if (diff > 0) {
@@ -2859,117 +2875,197 @@
2859
2875
  }, {
2860
2876
  key: "addColRight",
2861
2877
  value: function addColRight() {
2862
- var column = this.columns[this.rightCol + 1],
2863
- rows;
2878
+ var _this7 = this;
2864
2879
 
2865
- if (column && column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight) {
2866
- rows = this.table.rowManager.getVisibleRows();
2867
- rows.forEach(function (row) {
2868
- if (row.type !== "group") {
2869
- var cell = row.getCell(column);
2870
- row.getElement().appendChild(cell.getElement());
2871
- cell.cellRendered();
2872
- }
2873
- });
2874
- this.fitDataColActualWidthCheck(column);
2875
- this.rightCol++; // Don't move this below the >= check below
2880
+ var changes = false;
2881
+
2882
+ var _loop = function _loop() {
2883
+ var column = _this7.columns[_this7.rightCol + 1];
2884
+
2885
+ if (column) {
2886
+ if (column.modules.vdomHoz.leftPos <= _this7.vDomScrollPosRight) {
2887
+ changes = true;
2888
+
2889
+ _this7.getVisibleRows().forEach(function (row) {
2890
+ if (row.type !== "group") {
2891
+ var cell = row.getCell(column);
2892
+ row.getElement().appendChild(cell.getElement());
2893
+ cell.cellRendered();
2894
+ }
2895
+ });
2876
2896
 
2877
- if (this.rightCol >= this.columns.length - 1) {
2878
- this.vDomPadRight = 0;
2897
+ _this7.fitDataColActualWidthCheck(column);
2898
+
2899
+ _this7.rightCol++; // Don't move this below the >= check below
2900
+
2901
+ if (_this7.rightCol >= _this7.columns.length - 1) {
2902
+ _this7.vDomPadRight = 0;
2903
+ } else {
2904
+ _this7.vDomPadRight -= column.getWidth();
2905
+ }
2906
+ } else {
2907
+ return "break";
2908
+ }
2879
2909
  } else {
2880
- this.vDomPadRight -= column.getWidth();
2910
+ return "break";
2881
2911
  }
2912
+ };
2882
2913
 
2914
+ while (true) {
2915
+ var _ret = _loop();
2916
+
2917
+ if (_ret === "break") break;
2918
+ }
2919
+
2920
+ if (changes) {
2883
2921
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
2884
- this.addColRight();
2885
2922
  }
2886
2923
  }
2887
2924
  }, {
2888
2925
  key: "addColLeft",
2889
2926
  value: function addColLeft() {
2890
- var column = this.columns[this.leftCol - 1],
2891
- rows;
2927
+ var _this8 = this;
2892
2928
 
2893
- if (column && column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft) {
2894
- var rows = this.table.rowManager.getVisibleRows();
2895
- rows.forEach(function (row) {
2896
- if (row.type !== "group") {
2897
- var cell = row.getCell(column);
2898
- row.getElement().prepend(cell.getElement());
2899
- cell.cellRendered();
2900
- }
2901
- });
2902
- this.fitDataColActualWidthCheck(column);
2903
- this.leftCol--; // don't move this below the <= check below
2929
+ var changes = false;
2930
+
2931
+ var _loop2 = function _loop2() {
2932
+ var column = _this8.columns[_this8.leftCol - 1];
2933
+
2934
+ if (column) {
2935
+ if (column.modules.vdomHoz.rightPos >= _this8.vDomScrollPosLeft) {
2936
+ changes = true;
2937
+
2938
+ _this8.getVisibleRows().forEach(function (row) {
2939
+ if (row.type !== "group") {
2940
+ var cell = row.getCell(column);
2941
+ row.getElement().prepend(cell.getElement());
2942
+ cell.cellRendered();
2943
+ }
2944
+ });
2904
2945
 
2905
- if (this.leftCol <= 0) {
2906
- // replicating logic in addColRight
2907
- this.vDomPadLeft = 0;
2946
+ _this8.leftCol--; // don't move this below the <= check below
2947
+
2948
+ if (_this8.leftCol <= 0) {
2949
+ // replicating logic in addColRight
2950
+ _this8.vDomPadLeft = 0;
2951
+ } else {
2952
+ _this8.vDomPadLeft -= column.getWidth();
2953
+ }
2954
+
2955
+ var diff = _this8.fitDataColActualWidthCheck(column);
2956
+
2957
+ if (diff) {
2958
+ _this8.scrollLeft = _this8.elementVertical.scrollLeft = _this8.elementVertical.scrollLeft + diff;
2959
+ _this8.vDomPadRight -= diff;
2960
+ }
2961
+ } else {
2962
+ return "break";
2963
+ }
2908
2964
  } else {
2909
- this.vDomPadLeft -= column.getWidth();
2965
+ return "break";
2910
2966
  }
2967
+ };
2968
+
2969
+ while (true) {
2970
+ var _ret2 = _loop2();
2911
2971
 
2972
+ if (_ret2 === "break") break;
2973
+ }
2974
+
2975
+ if (changes) {
2912
2976
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
2913
- this.addColLeft();
2914
2977
  }
2915
2978
  }
2916
2979
  }, {
2917
2980
  key: "removeColRight",
2918
- value: function removeColRight(column) {
2919
- var column = this.columns[this.rightCol],
2920
- rows;
2981
+ value: function removeColRight() {
2982
+ var _this9 = this;
2921
2983
 
2922
- if (column && column.modules.vdomHoz.leftPos > this.vDomScrollPosRight) {
2923
- rows = this.table.rowManager.getVisibleRows();
2924
- column.modules.vdomHoz.visible = false;
2925
- rows.forEach(function (row) {
2926
- if (row.type !== "group") {
2927
- var cell = row.getCell(column);
2984
+ var changes = false;
2928
2985
 
2929
- try {
2930
- row.getElement().removeChild(cell.getElement());
2931
- } catch (ex) {
2932
- console.warn("Could not removeColRight", ex.message);
2933
- }
2986
+ var _loop3 = function _loop3() {
2987
+ var column = _this9.columns[_this9.rightCol];
2988
+
2989
+ if (column) {
2990
+ if (column.modules.vdomHoz.leftPos > _this9.vDomScrollPosRight) {
2991
+ changes = true;
2992
+
2993
+ _this9.getVisibleRows().forEach(function (row) {
2994
+ if (row.type !== "group") {
2995
+ var cell = row.getCell(column);
2996
+
2997
+ try {
2998
+ row.getElement().removeChild(cell.getElement());
2999
+ } catch (ex) {
3000
+ console.warn("Could not removeColRight", ex.message);
3001
+ }
3002
+ }
3003
+ });
3004
+
3005
+ _this9.vDomPadRight += column.getWidth();
3006
+ _this9.rightCol--;
3007
+ } else {
3008
+ return "break";
2934
3009
  }
2935
- });
2936
- this.vDomPadRight += column.getWidth();
3010
+ } else {
3011
+ return "break";
3012
+ }
3013
+ };
3014
+
3015
+ while (true) {
3016
+ var _ret3 = _loop3();
3017
+
3018
+ if (_ret3 === "break") break;
3019
+ }
3020
+
3021
+ if (changes) {
2937
3022
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
2938
- this.rightCol--;
2939
- this.removeColRight();
2940
3023
  }
2941
3024
  }
2942
3025
  }, {
2943
3026
  key: "removeColLeft",
2944
3027
  value: function removeColLeft() {
2945
- var column = this.columns[this.leftCol],
2946
- rows;
3028
+ var _this10 = this;
2947
3029
 
2948
- if (column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft) {
2949
- rows = this.table.rowManager.getVisibleRows();
2950
- rows.forEach(function (row) {
2951
- var cell, el;
3030
+ var changes = false;
2952
3031
 
2953
- if (row.type !== "group") {
2954
- cell = row.getCell(column);
3032
+ var _loop4 = function _loop4() {
3033
+ var column = _this10.columns[_this10.leftCol];
2955
3034
 
2956
- if (cell) {
2957
- el = cell.getElement();
3035
+ if (column) {
3036
+ if (column.modules.vdomHoz.rightPos < _this10.vDomScrollPosLeft) {
3037
+ changes = true;
3038
+
3039
+ _this10.getVisibleRows().forEach(function (row) {
3040
+ if (row.type !== "group") {
3041
+ var cell = row.getCell(column);
2958
3042
 
2959
- if (el.parentNode) {
2960
3043
  try {
2961
- row.getElement().removeChild(el);
3044
+ row.getElement().removeChild(cell.getElement());
2962
3045
  } catch (ex) {
2963
3046
  console.warn("Could not removeColLeft", ex.message);
2964
3047
  }
2965
3048
  }
2966
- }
3049
+ });
3050
+
3051
+ _this10.vDomPadLeft += column.getWidth();
3052
+ _this10.leftCol++;
3053
+ } else {
3054
+ return "break";
2967
3055
  }
2968
- });
2969
- this.vDomPadLeft += column.getWidth();
3056
+ } else {
3057
+ return "break";
3058
+ }
3059
+ };
3060
+
3061
+ while (true) {
3062
+ var _ret4 = _loop4();
3063
+
3064
+ if (_ret4 === "break") break;
3065
+ }
3066
+
3067
+ if (changes) {
2970
3068
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
2971
- this.leftCol++;
2972
- this.removeColLeft();
2973
3069
  }
2974
3070
  }
2975
3071
  }, {
@@ -2985,11 +3081,13 @@
2985
3081
  if (widthDiff) {
2986
3082
  column.modules.vdomHoz.rightPos += widthDiff;
2987
3083
  column.modules.vdomHoz.width = newWidth;
2988
- this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff);
3084
+ this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);
2989
3085
  }
2990
3086
 
2991
3087
  column.modules.vdomHoz.fitDataCheck = false;
2992
3088
  }
3089
+
3090
+ return widthDiff;
2993
3091
  }
2994
3092
  }, {
2995
3093
  key: "initializeRow",
@@ -20084,13 +20182,11 @@
20084
20182
  } //move menu to start on bottom edge if it is too close to the edge of the screen
20085
20183
 
20086
20184
 
20087
- if (y + element.offsetHeight >= this.menuContainer.offsetHeight) {
20088
- element.style.top = "";
20089
-
20185
+ if (y + element.offsetHeight > this.menuContainer.offsetHeight) {
20090
20186
  if (parentEl) {
20091
- element.style.bottom = this.menuContainer.offsetHeight - parentOffset.top - parentEl.offsetHeight - 1 + "px";
20187
+ element.style.top = parseInt(element.style.top) - element.offsetHeight + parentEl.offsetHeight + 1 + "px";
20092
20188
  } else {
20093
- element.style.bottom = this.menuContainer.offsetHeight - y + "px";
20189
+ element.style.top = parseInt(element.style.top) - element.offsetHeight + "px";
20094
20190
  }
20095
20191
  }
20096
20192
  }