tabulator-tables 5.1.5 → 5.1.8

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.
@@ -10,7 +10,7 @@ assignees: ''
10
10
  <!--
11
11
  YOUR BUG REPORT MUST CONTAIN A LINK TO A JSFiddle OR Codepen THAT DEMONSTRATES THE ISSUE OR IT WILL BE CLOSED WITHOUT DISCUSSION
12
12
 
13
- Please read the Bug Reporting Guide before completing this issue: http://tabulator.info/community#bug
13
+ Please read the Bug Reporting Guide before completing this issue: http://tabulator.info/community/bug
14
14
 
15
15
  Please make sure you fill in all the sections of this template to give us the best chance of helping you
16
16
  -->
@@ -23,8 +23,9 @@ A clear and concise description of what the bug is.
23
23
 
24
24
  **Working Example**
25
25
  YOU MUST include a link to a JS Fiddle or Codepen that demonstrates the problem, it is very hard to diagnose an issue from a simple description.
26
-
27
26
  <!--
27
+ Please read the Minimal Reproducable Example guide if you are unsure what the example should look like http://tabulator.info/community/mre
28
+
28
29
  ISSUES CREATED WITHOUT THIS EXAMPLE WILL BE CLOSED WITHOUT DISCUSSION
29
30
  -->
30
31
 
@@ -8,7 +8,7 @@ assignees: ''
8
8
  ---
9
9
 
10
10
  <!--
11
- Please read the Feature Requesting Guide before completing this issue: http://tabulator.info/community#feature
11
+ Please read the Feature Requesting Guide before completing this issue: http://tabulator.info/community/feature
12
12
  -->
13
13
 
14
14
  *Is your feature request related to a problem? Please describe.**
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.8",
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.8 (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,17 @@
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
+ this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));
2608
+ this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));
2609
+ }
2610
+ }, {
2611
+ key: "clearVisRowCache",
2612
+ value: function clearVisRowCache() {
2613
+ this.visibleRows = null;
2601
2614
  } //////////////////////////////////////
2602
2615
  ///////// Public Functions ///////////
2603
2616
  //////////////////////////////////////
@@ -2774,19 +2787,15 @@
2774
2787
  var cell = row.cells[colEnd];
2775
2788
  rowEl.appendChild(cell.getElement());
2776
2789
  cell.column.reinitializeWidth();
2777
- collsWidth += cell.column.getWidth();
2778
-
2779
- if (collsWidth > this.vDomScrollPosRight) {
2780
- break;
2781
- }
2790
+ collsWidth += cell.column.getWidth(); // if(collsWidth > this.vDomScrollPosRight){
2791
+ // break;
2792
+ // }
2782
2793
  }
2783
2794
 
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
- }
2795
+ rowEl.parentNode.removeChild(rowEl); // this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));
2796
+ // for(colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++){
2797
+ // this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);
2798
+ // }
2790
2799
 
2791
2800
  this.rerenderColumns(false, true);
2792
2801
  }
@@ -2822,18 +2831,27 @@
2822
2831
  value: function reinitializeRows() {
2823
2832
  var _this5 = this;
2824
2833
 
2825
- var rows = this.table.rowManager.getVisibleRows();
2834
+ var rows = this.getVisibleRows();
2826
2835
  rows.forEach(function (row) {
2827
2836
  _this5.reinitializeRow(row, true);
2828
2837
  });
2829
2838
  }
2839
+ }, {
2840
+ key: "getVisibleRows",
2841
+ value: function getVisibleRows() {
2842
+ if (!this.visibleRows) {
2843
+ this.visibleRows = this.table.rowManager.getVisibleRows();
2844
+ }
2845
+
2846
+ return this.visibleRows;
2847
+ }
2830
2848
  }, {
2831
2849
  key: "scroll",
2832
2850
  value: function scroll(diff) {
2833
2851
  this.vDomScrollPosLeft += diff;
2834
2852
  this.vDomScrollPosRight += diff;
2835
2853
 
2836
- if (diff > this.elementVertical.clientWidth * .8) {
2854
+ if (Math.abs(diff) > this.windowBuffer / 2) {
2837
2855
  this.rerenderColumns();
2838
2856
  } else {
2839
2857
  if (diff > 0) {
@@ -2859,117 +2877,197 @@
2859
2877
  }, {
2860
2878
  key: "addColRight",
2861
2879
  value: function addColRight() {
2862
- var column = this.columns[this.rightCol + 1],
2863
- rows;
2880
+ var _this6 = this;
2864
2881
 
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
2882
+ var changes = false;
2883
+
2884
+ var _loop = function _loop() {
2885
+ var column = _this6.columns[_this6.rightCol + 1];
2886
+
2887
+ if (column) {
2888
+ if (column.modules.vdomHoz.leftPos <= _this6.vDomScrollPosRight) {
2889
+ changes = true;
2890
+
2891
+ _this6.getVisibleRows().forEach(function (row) {
2892
+ if (row.type !== "group") {
2893
+ var cell = row.getCell(column);
2894
+ row.getElement().appendChild(cell.getElement());
2895
+ cell.cellRendered();
2896
+ }
2897
+ });
2898
+
2899
+ _this6.fitDataColActualWidthCheck(column);
2876
2900
 
2877
- if (this.rightCol >= this.columns.length - 1) {
2878
- this.vDomPadRight = 0;
2901
+ _this6.rightCol++; // Don't move this below the >= check below
2902
+
2903
+ if (_this6.rightCol >= _this6.columns.length - 1) {
2904
+ _this6.vDomPadRight = 0;
2905
+ } else {
2906
+ _this6.vDomPadRight -= column.getWidth();
2907
+ }
2908
+ } else {
2909
+ return "break";
2910
+ }
2879
2911
  } else {
2880
- this.vDomPadRight -= column.getWidth();
2912
+ return "break";
2881
2913
  }
2914
+ };
2915
+
2916
+ while (true) {
2917
+ var _ret = _loop();
2882
2918
 
2919
+ if (_ret === "break") break;
2920
+ }
2921
+
2922
+ if (changes) {
2883
2923
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
2884
- this.addColRight();
2885
2924
  }
2886
2925
  }
2887
2926
  }, {
2888
2927
  key: "addColLeft",
2889
2928
  value: function addColLeft() {
2890
- var column = this.columns[this.leftCol - 1],
2891
- rows;
2929
+ var _this7 = this;
2892
2930
 
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
2931
+ var changes = false;
2932
+
2933
+ var _loop2 = function _loop2() {
2934
+ var column = _this7.columns[_this7.leftCol - 1];
2935
+
2936
+ if (column) {
2937
+ if (column.modules.vdomHoz.rightPos >= _this7.vDomScrollPosLeft) {
2938
+ changes = true;
2939
+
2940
+ _this7.getVisibleRows().forEach(function (row) {
2941
+ if (row.type !== "group") {
2942
+ var cell = row.getCell(column);
2943
+ row.getElement().prepend(cell.getElement());
2944
+ cell.cellRendered();
2945
+ }
2946
+ });
2947
+
2948
+ _this7.leftCol--; // don't move this below the <= check below
2949
+
2950
+ if (_this7.leftCol <= 0) {
2951
+ // replicating logic in addColRight
2952
+ _this7.vDomPadLeft = 0;
2953
+ } else {
2954
+ _this7.vDomPadLeft -= column.getWidth();
2955
+ }
2956
+
2957
+ var diff = _this7.fitDataColActualWidthCheck(column);
2904
2958
 
2905
- if (this.leftCol <= 0) {
2906
- // replicating logic in addColRight
2907
- this.vDomPadLeft = 0;
2959
+ if (diff) {
2960
+ _this7.scrollLeft = _this7.elementVertical.scrollLeft = _this7.elementVertical.scrollLeft + diff;
2961
+ _this7.vDomPadRight -= diff;
2962
+ }
2963
+ } else {
2964
+ return "break";
2965
+ }
2908
2966
  } else {
2909
- this.vDomPadLeft -= column.getWidth();
2967
+ return "break";
2910
2968
  }
2969
+ };
2970
+
2971
+ while (true) {
2972
+ var _ret2 = _loop2();
2973
+
2974
+ if (_ret2 === "break") break;
2975
+ }
2911
2976
 
2977
+ if (changes) {
2912
2978
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
2913
- this.addColLeft();
2914
2979
  }
2915
2980
  }
2916
2981
  }, {
2917
2982
  key: "removeColRight",
2918
- value: function removeColRight(column) {
2919
- var column = this.columns[this.rightCol],
2920
- rows;
2983
+ value: function removeColRight() {
2984
+ var _this8 = this;
2921
2985
 
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);
2986
+ var changes = false;
2928
2987
 
2929
- try {
2930
- row.getElement().removeChild(cell.getElement());
2931
- } catch (ex) {
2932
- console.warn("Could not removeColRight", ex.message);
2933
- }
2988
+ var _loop3 = function _loop3() {
2989
+ var column = _this8.columns[_this8.rightCol];
2990
+
2991
+ if (column) {
2992
+ if (column.modules.vdomHoz.leftPos > _this8.vDomScrollPosRight) {
2993
+ changes = true;
2994
+
2995
+ _this8.getVisibleRows().forEach(function (row) {
2996
+ if (row.type !== "group") {
2997
+ var cell = row.getCell(column);
2998
+
2999
+ try {
3000
+ row.getElement().removeChild(cell.getElement());
3001
+ } catch (ex) {
3002
+ console.warn("Could not removeColRight", ex.message);
3003
+ }
3004
+ }
3005
+ });
3006
+
3007
+ _this8.vDomPadRight += column.getWidth();
3008
+ _this8.rightCol--;
3009
+ } else {
3010
+ return "break";
2934
3011
  }
2935
- });
2936
- this.vDomPadRight += column.getWidth();
3012
+ } else {
3013
+ return "break";
3014
+ }
3015
+ };
3016
+
3017
+ while (true) {
3018
+ var _ret3 = _loop3();
3019
+
3020
+ if (_ret3 === "break") break;
3021
+ }
3022
+
3023
+ if (changes) {
2937
3024
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
2938
- this.rightCol--;
2939
- this.removeColRight();
2940
3025
  }
2941
3026
  }
2942
3027
  }, {
2943
3028
  key: "removeColLeft",
2944
3029
  value: function removeColLeft() {
2945
- var column = this.columns[this.leftCol],
2946
- rows;
3030
+ var _this9 = this;
2947
3031
 
2948
- if (column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft) {
2949
- rows = this.table.rowManager.getVisibleRows();
2950
- rows.forEach(function (row) {
2951
- var cell, el;
3032
+ var changes = false;
2952
3033
 
2953
- if (row.type !== "group") {
2954
- cell = row.getCell(column);
3034
+ var _loop4 = function _loop4() {
3035
+ var column = _this9.columns[_this9.leftCol];
2955
3036
 
2956
- if (cell) {
2957
- el = cell.getElement();
3037
+ if (column) {
3038
+ if (column.modules.vdomHoz.rightPos < _this9.vDomScrollPosLeft) {
3039
+ changes = true;
3040
+
3041
+ _this9.getVisibleRows().forEach(function (row) {
3042
+ if (row.type !== "group") {
3043
+ var cell = row.getCell(column);
2958
3044
 
2959
- if (el.parentNode) {
2960
3045
  try {
2961
- row.getElement().removeChild(el);
3046
+ row.getElement().removeChild(cell.getElement());
2962
3047
  } catch (ex) {
2963
3048
  console.warn("Could not removeColLeft", ex.message);
2964
3049
  }
2965
3050
  }
2966
- }
3051
+ });
3052
+
3053
+ _this9.vDomPadLeft += column.getWidth();
3054
+ _this9.leftCol++;
3055
+ } else {
3056
+ return "break";
2967
3057
  }
2968
- });
2969
- this.vDomPadLeft += column.getWidth();
3058
+ } else {
3059
+ return "break";
3060
+ }
3061
+ };
3062
+
3063
+ while (true) {
3064
+ var _ret4 = _loop4();
3065
+
3066
+ if (_ret4 === "break") break;
3067
+ }
3068
+
3069
+ if (changes) {
2970
3070
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
2971
- this.leftCol++;
2972
- this.removeColLeft();
2973
3071
  }
2974
3072
  }
2975
3073
  }, {
@@ -2985,11 +3083,13 @@
2985
3083
  if (widthDiff) {
2986
3084
  column.modules.vdomHoz.rightPos += widthDiff;
2987
3085
  column.modules.vdomHoz.width = newWidth;
2988
- this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff);
3086
+ this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);
2989
3087
  }
2990
3088
 
2991
3089
  column.modules.vdomHoz.fitDataCheck = false;
2992
3090
  }
3091
+
3092
+ return widthDiff;
2993
3093
  }
2994
3094
  }, {
2995
3095
  key: "initializeRow",
@@ -6575,7 +6675,7 @@
6575
6675
  }
6576
6676
 
6577
6677
  if (this.bindings[type][funcName]) {
6578
- console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, hanlder);
6678
+ console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler);
6579
6679
  } else {
6580
6680
  this.bindings[type][funcName] = handler;
6581
6681
  }
@@ -6583,7 +6683,7 @@
6583
6683
  }, {
6584
6684
  key: "handle",
6585
6685
  value: function handle(type, component, name) {
6586
- if (this.bindings[type] && this.bindings[type][name]) {
6686
+ if (this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function') {
6587
6687
  return this.bindings[type][name].bind(null, component);
6588
6688
  } else {
6589
6689
  if (name !== "then" && typeof name === "string" && !name.startsWith("_")) {
@@ -14015,6 +14115,7 @@
14015
14115
  cell.column.definition.cellEditing.call(this.table, component);
14016
14116
  }
14017
14117
 
14118
+ this.dispatch("cell-editing", cell);
14018
14119
  this.dispatchExternal("cellEditing", component);
14019
14120
  params = typeof cell.column.modules.edit.params === "function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;
14020
14121
  cellEditor = cell.column.modules.edit.editor.call(self, component, onRendered, success, cancel, params); //if editor returned, add to DOM, if false, abort edit
@@ -15973,7 +16074,7 @@
15973
16074
 
15974
16075
  if (newDatetime.isValid) {
15975
16076
  if (formatterParams.timezone) {
15976
- newDatetime = newDatetime.shiftTimezone(formatterParams.timezone);
16077
+ newDatetime = newDatetime.setZone(formatterParams.timezone);
15977
16078
  }
15978
16079
 
15979
16080
  return newDatetime.toFormat(outputFormat);
@@ -20064,6 +20165,8 @@
20064
20165
  setTimeout(function () {
20065
20166
  _this4.table.rowManager.element.addEventListener("scroll", _this4.blurEvent);
20066
20167
 
20168
+ _this4.subscribe("cell-editing", _this4.blurEvent);
20169
+
20067
20170
  document.body.addEventListener("click", _this4.blurEvent);
20068
20171
  document.body.addEventListener("contextmenu", _this4.blurEvent);
20069
20172
  window.addEventListener("resize", _this4.blurEvent);
@@ -20084,13 +20187,11 @@
20084
20187
  } //move menu to start on bottom edge if it is too close to the edge of the screen
20085
20188
 
20086
20189
 
20087
- if (y + element.offsetHeight >= this.menuContainer.offsetHeight) {
20088
- element.style.top = "";
20089
-
20190
+ if (y + element.offsetHeight > this.menuContainer.offsetHeight) {
20090
20191
  if (parentEl) {
20091
- element.style.bottom = this.menuContainer.offsetHeight - parentOffset.top - parentEl.offsetHeight - 1 + "px";
20192
+ element.style.top = parseInt(element.style.top) - element.offsetHeight + parentEl.offsetHeight + 1 + "px";
20092
20193
  } else {
20093
- element.style.bottom = this.menuContainer.offsetHeight - y + "px";
20194
+ element.style.top = parseInt(element.style.top) - element.offsetHeight + "px";
20094
20195
  }
20095
20196
  }
20096
20197
  }
@@ -20119,6 +20220,7 @@
20119
20220
  document.body.removeEventListener("contextmenu", this.blurEvent);
20120
20221
  window.removeEventListener("resize", this.blurEvent);
20121
20222
  this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);
20223
+ this.unsubscribe("cell-editing", this.blurEvent);
20122
20224
 
20123
20225
  if (this.currentComponent) {
20124
20226
  this.dispatchExternal("menuClosed", this.currentComponent.getComponent());