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.
@@ -1,4 +1,4 @@
1
- /* Tabulator v5.1.5 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.1.8 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -7342,6 +7342,7 @@ class Edit extends Module{
7342
7342
  cell.column.definition.cellEditing.call(this.table, component);
7343
7343
  }
7344
7344
 
7345
+ this.dispatch("cell-editing", cell);
7345
7346
  this.dispatchExternal("cellEditing", component);
7346
7347
 
7347
7348
  params = typeof cell.column.modules.edit.params === "function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;
@@ -9236,14 +9237,12 @@ function datetime(cell, formatterParams, onRendered){
9236
9237
  var newDatetime = inputFormat === "iso" ? DT.fromISO(String(value)) : DT.fromFormat(String(value), inputFormat);
9237
9238
 
9238
9239
  if(newDatetime.isValid){
9239
-
9240
9240
  if(formatterParams.timezone){
9241
- newDatetime = newDatetime.shiftTimezone(formatterParams.timezone);
9241
+ newDatetime = newDatetime.setZone(formatterParams.timezone);
9242
9242
  }
9243
9243
 
9244
9244
  return newDatetime.toFormat(outputFormat);
9245
9245
  }else {
9246
-
9247
9246
  if(invalid === true || !value){
9248
9247
  return value;
9249
9248
  }else if(typeof invalid === "function"){
@@ -13125,6 +13124,7 @@ class Menu extends Module{
13125
13124
 
13126
13125
  setTimeout(() => {
13127
13126
  this.table.rowManager.element.addEventListener("scroll", this.blurEvent);
13127
+ this.subscribe("cell-editing", this.blurEvent);
13128
13128
  document.body.addEventListener("click", this.blurEvent);
13129
13129
  document.body.addEventListener("contextmenu", this.blurEvent);
13130
13130
  window.addEventListener("resize", this.blurEvent);
@@ -13147,13 +13147,11 @@ class Menu extends Module{
13147
13147
  }
13148
13148
 
13149
13149
  //move menu to start on bottom edge if it is too close to the edge of the screen
13150
- if((y + element.offsetHeight) >= this.menuContainer.offsetHeight){
13151
- element.style.top = "";
13152
-
13150
+ if((y + element.offsetHeight) > this.menuContainer.offsetHeight) {
13153
13151
  if(parentEl){
13154
- element.style.bottom = (this.menuContainer.offsetHeight - parentOffset.top - parentEl.offsetHeight - 1) + "px";
13152
+ element.style.top = (parseInt(element.style.top) - element.offsetHeight + parentEl.offsetHeight + 1) + "px";
13155
13153
  }else {
13156
- element.style.bottom = (this.menuContainer.offsetHeight - y) + "px";
13154
+ element.style.top = (parseInt(element.style.top) - element.offsetHeight) + "px";
13157
13155
  }
13158
13156
  }
13159
13157
  }
@@ -13180,6 +13178,7 @@ class Menu extends Module{
13180
13178
  document.body.removeEventListener("contextmenu", this.blurEvent);
13181
13179
  window.removeEventListener("resize", this.blurEvent);
13182
13180
  this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);
13181
+ this.unsubscribe("cell-editing", this.blurEvent);
13183
13182
 
13184
13183
  if(this.currentComponent){
13185
13184
  this.dispatchExternal("menuClosed", this.currentComponent.getComponent());
@@ -18830,8 +18829,9 @@ class VirtualDomHorizontal extends Renderer{
18830
18829
  this.fitDataColAvg = 0;
18831
18830
 
18832
18831
  this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen
18833
-
18834
18832
 
18833
+ this.visibleRows = null;
18834
+
18835
18835
  this.initialized = false;
18836
18836
  this.isFitData = false;
18837
18837
 
@@ -18841,6 +18841,7 @@ class VirtualDomHorizontal extends Renderer{
18841
18841
  initialize(){
18842
18842
  this.compatibilityCheck();
18843
18843
  this.layoutCheck();
18844
+ this.vertScrollListen();
18844
18845
  }
18845
18846
 
18846
18847
  compatibilityCheck(){
@@ -18880,10 +18881,19 @@ class VirtualDomHorizontal extends Renderer{
18880
18881
 
18881
18882
  return ok;
18882
18883
  }
18883
-
18884
+
18884
18885
  layoutCheck(){
18885
18886
  this.isFitData = this.options("layout").startsWith('fitData');
18886
18887
  }
18888
+
18889
+ vertScrollListen(){
18890
+ this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));
18891
+ this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));
18892
+ }
18893
+
18894
+ clearVisRowCache(){
18895
+ this.visibleRows = null;
18896
+ }
18887
18897
 
18888
18898
  //////////////////////////////////////
18889
18899
  ///////// Public Functions ///////////
@@ -18892,6 +18902,7 @@ class VirtualDomHorizontal extends Renderer{
18892
18902
  renderColumns(row, force){
18893
18903
  this.dataChange();
18894
18904
  }
18905
+
18895
18906
 
18896
18907
  scrollColumns(left, dir){
18897
18908
  if(this.scrollLeft != left){
@@ -18900,20 +18911,20 @@ class VirtualDomHorizontal extends Renderer{
18900
18911
  this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));
18901
18912
  }
18902
18913
  }
18903
-
18914
+
18904
18915
  calcWindowBuffer(){
18905
18916
  var buffer = this.elementVertical.clientWidth;
18906
-
18917
+
18907
18918
  this.table.columnManager.columnsByIndex.forEach((column) => {
18908
18919
  if(column.visible){
18909
18920
  var width = column.getWidth();
18910
-
18921
+
18911
18922
  if(width > buffer){
18912
18923
  buffer = width;
18913
18924
  }
18914
18925
  }
18915
18926
  });
18916
-
18927
+
18917
18928
  this.windowBuffer = buffer * 2;
18918
18929
  }
18919
18930
 
@@ -18931,20 +18942,20 @@ class VirtualDomHorizontal extends Renderer{
18931
18942
  }
18932
18943
 
18933
18944
  this.clear();
18934
-
18945
+
18935
18946
  this.calcWindowBuffer();
18936
18947
 
18937
18948
  this.scrollLeft = this.elementVertical.scrollLeft;
18938
18949
 
18939
18950
  this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;
18940
18951
  this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;
18941
-
18952
+
18942
18953
  this.table.columnManager.columnsByIndex.forEach((column) => {
18943
18954
  var config = {};
18944
18955
 
18945
18956
  if(column.visible){
18946
18957
  var width = column.getWidth();
18947
-
18958
+
18948
18959
  config.leftPos = colPos;
18949
18960
  config.rightPos = colPos + width;
18950
18961
 
@@ -19071,18 +19082,18 @@ class VirtualDomHorizontal extends Renderer{
19071
19082
 
19072
19083
  collsWidth += cell.column.getWidth();
19073
19084
 
19074
- if(collsWidth > this.vDomScrollPosRight){
19075
- break;
19076
- }
19085
+ // if(collsWidth > this.vDomScrollPosRight){
19086
+ // break;
19087
+ // }
19077
19088
  }
19078
19089
 
19079
19090
  rowEl.parentNode.removeChild(rowEl);
19080
19091
 
19081
- this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));
19092
+ // this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));
19082
19093
 
19083
- for(colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++){
19084
- this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);
19085
- }
19094
+ // for(colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++){
19095
+ // this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);
19096
+ // }
19086
19097
 
19087
19098
  this.rerenderColumns(false, true);
19088
19099
  }
@@ -19113,17 +19124,25 @@ class VirtualDomHorizontal extends Renderer{
19113
19124
  }
19114
19125
 
19115
19126
  reinitializeRows(){
19116
- var rows = this.table.rowManager.getVisibleRows();
19127
+ var rows = this.getVisibleRows();
19117
19128
  rows.forEach((row) => {
19118
19129
  this.reinitializeRow(row, true);
19119
19130
  });
19120
19131
  }
19121
19132
 
19133
+ getVisibleRows(){
19134
+ if (!this.visibleRows){
19135
+ this.visibleRows = this.table.rowManager.getVisibleRows();
19136
+ }
19137
+
19138
+ return this.visibleRows;
19139
+ }
19140
+
19122
19141
  scroll(diff){
19123
19142
  this.vDomScrollPosLeft += diff;
19124
19143
  this.vDomScrollPosRight += diff;
19125
-
19126
- if(diff > (this.elementVertical.clientWidth * .8)){
19144
+
19145
+ if(Math.abs(diff) > (this.windowBuffer / 2)){
19127
19146
  this.rerenderColumns();
19128
19147
  }else {
19129
19148
  if(diff > 0){
@@ -19148,131 +19167,165 @@ class VirtualDomHorizontal extends Renderer{
19148
19167
  }
19149
19168
 
19150
19169
  addColRight(){
19151
- var column = this.columns[this.rightCol + 1],
19152
- rows;
19170
+ var changes = false;
19153
19171
 
19154
- if(column && column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){
19155
- rows = this.table.rowManager.getVisibleRows();
19156
-
19157
- rows.forEach((row) => {
19158
- if(row.type !== "group"){
19159
- var cell = row.getCell(column);
19160
- row.getElement().appendChild(cell.getElement());
19161
- cell.cellRendered();
19162
- }
19163
- });
19164
-
19165
- this.fitDataColActualWidthCheck(column);
19172
+ while(true){
19166
19173
 
19167
- this.rightCol++; // Don't move this below the >= check below
19174
+ let column = this.columns[this.rightCol + 1];
19168
19175
 
19169
- if(this.rightCol >= (this.columns.length - 1)){
19170
- this.vDomPadRight = 0;
19176
+ if(column){
19177
+ if(column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){
19178
+ changes = true;
19179
+
19180
+ this.getVisibleRows().forEach((row) => {
19181
+ if(row.type !== "group"){
19182
+ var cell = row.getCell(column);
19183
+ row.getElement().appendChild(cell.getElement());
19184
+ cell.cellRendered();
19185
+ }
19186
+ });
19187
+
19188
+ this.fitDataColActualWidthCheck(column);
19189
+
19190
+ this.rightCol++; // Don't move this below the >= check below
19191
+
19192
+ if(this.rightCol >= (this.columns.length - 1)){
19193
+ this.vDomPadRight = 0;
19194
+ }else {
19195
+ this.vDomPadRight -= column.getWidth();
19196
+ }
19197
+ }else {
19198
+ break;
19199
+ }
19171
19200
  }else {
19172
- this.vDomPadRight -= column.getWidth();
19201
+ break;
19173
19202
  }
19174
-
19203
+ }
19204
+
19205
+ if(changes){
19175
19206
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
19176
-
19177
- this.addColRight();
19178
19207
  }
19179
19208
  }
19180
19209
 
19181
19210
  addColLeft(){
19182
- var column = this.columns[this.leftCol - 1],
19183
- rows;
19211
+ var changes = false;
19184
19212
 
19185
- if(column && column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){
19186
- var rows = this.table.rowManager.getVisibleRows();
19213
+ while(true){
19214
+ let column = this.columns[this.leftCol - 1];
19187
19215
 
19188
- rows.forEach((row) => {
19189
- if(row.type !== "group"){
19190
- var cell = row.getCell(column);
19191
- row.getElement().prepend(cell.getElement());
19192
- cell.cellRendered();
19216
+ if(column){
19217
+ if(column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){
19218
+ changes = true;
19219
+
19220
+ this.getVisibleRows().forEach((row) => {
19221
+ if(row.type !== "group"){
19222
+ var cell = row.getCell(column);
19223
+ row.getElement().prepend(cell.getElement());
19224
+ cell.cellRendered();
19225
+ }
19226
+ });
19227
+
19228
+ this.leftCol--; // don't move this below the <= check below
19229
+
19230
+ if(this.leftCol <= 0){ // replicating logic in addColRight
19231
+ this.vDomPadLeft = 0;
19232
+ }else {
19233
+ this.vDomPadLeft -= column.getWidth();
19234
+ }
19235
+
19236
+ let diff = this.fitDataColActualWidthCheck(column);
19237
+
19238
+ if(diff){
19239
+ this.scrollLeft = this.elementVertical.scrollLeft = this.elementVertical.scrollLeft + diff;
19240
+ this.vDomPadRight -= diff;
19241
+ }
19242
+
19243
+ }else {
19244
+ break;
19193
19245
  }
19194
- });
19195
-
19196
- this.fitDataColActualWidthCheck(column);
19197
-
19198
- this.leftCol--; // don't move this below the <= check below
19199
-
19200
- if(this.leftCol <= 0){ // replicating logic in addColRight
19201
- this.vDomPadLeft = 0;
19202
19246
  }else {
19203
- this.vDomPadLeft -= column.getWidth();
19247
+ break;
19204
19248
  }
19205
-
19249
+ }
19250
+
19251
+ if(changes){
19206
19252
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
19207
-
19208
-
19209
- this.addColLeft();
19210
19253
  }
19211
19254
  }
19212
19255
 
19213
- removeColRight(column){
19214
- var column = this.columns[this.rightCol],
19215
- rows;
19256
+ removeColRight(){
19257
+ var changes = false;
19216
19258
 
19217
- if(column && column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){
19218
- rows = this.table.rowManager.getVisibleRows();
19219
-
19220
- column.modules.vdomHoz.visible = false;
19259
+ while(true){
19260
+ let column = this.columns[this.rightCol];
19221
19261
 
19222
- rows.forEach((row) => {
19223
- if(row.type !== "group"){
19224
- var cell = row.getCell(column);
19225
- try {
19226
- row.getElement().removeChild(cell.getElement());
19227
- } catch (ex) {
19228
- console.warn("Could not removeColRight", ex.message);
19229
- }
19262
+ if(column){
19263
+ if(column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){
19264
+ changes = true;
19265
+
19266
+ this.getVisibleRows().forEach((row) => {
19267
+ if(row.type !== "group"){
19268
+ var cell = row.getCell(column);
19269
+
19270
+ try {
19271
+ row.getElement().removeChild(cell.getElement());
19272
+ } catch (ex) {
19273
+ console.warn("Could not removeColRight", ex.message);
19274
+ }
19275
+ }
19276
+ });
19277
+
19278
+ this.vDomPadRight += column.getWidth();
19279
+ this.rightCol --;
19280
+ }else {
19281
+ break;
19230
19282
  }
19231
- });
19232
-
19233
- this.vDomPadRight += column.getWidth();
19283
+ }else {
19284
+ break;
19285
+ }
19286
+ }
19287
+
19288
+ if(changes){
19234
19289
  this.tableElement.style.paddingRight = this.vDomPadRight + "px";
19235
-
19236
- this.rightCol --;
19237
-
19238
- this.removeColRight();
19239
19290
  }
19240
19291
  }
19241
19292
 
19242
19293
  removeColLeft(){
19243
- var column = this.columns[this.leftCol],
19244
- rows;
19294
+ var changes = false;
19245
19295
 
19246
- if(column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){
19247
- rows = this.table.rowManager.getVisibleRows();
19296
+ while(true){
19297
+ let column = this.columns[this.leftCol];
19248
19298
 
19249
- rows.forEach((row) => {
19250
- var cell, el;
19251
-
19252
- if(row.type !== "group"){
19253
- cell = row.getCell(column);
19254
-
19255
- if(cell){
19256
- el = cell.getElement();
19257
-
19258
- if(el.parentNode){
19299
+ if(column){
19300
+ if(column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){
19301
+ changes = true;
19302
+
19303
+ this.getVisibleRows().forEach((row) => {
19304
+ if(row.type !== "group"){
19305
+ var cell = row.getCell(column);
19306
+
19259
19307
  try {
19260
- row.getElement().removeChild(el);
19308
+ row.getElement().removeChild(cell.getElement());
19261
19309
  } catch (ex) {
19262
19310
  console.warn("Could not removeColLeft", ex.message);
19263
19311
  }
19264
19312
  }
19265
- }
19313
+ });
19314
+
19315
+ this.vDomPadLeft += column.getWidth();
19316
+ this.leftCol ++;
19317
+ }else {
19318
+ break;
19266
19319
  }
19267
- });
19268
-
19269
- this.vDomPadLeft += column.getWidth();
19320
+ }else {
19321
+ break;
19322
+ }
19323
+ }
19324
+
19325
+ if(changes){
19270
19326
  this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";
19271
-
19272
- this.leftCol ++;
19273
-
19274
- this.removeColLeft();
19275
19327
  }
19328
+
19276
19329
  }
19277
19330
 
19278
19331
  fitDataColActualWidthCheck(column){
@@ -19287,12 +19340,14 @@ class VirtualDomHorizontal extends Renderer{
19287
19340
  if(widthDiff){
19288
19341
  column.modules.vdomHoz.rightPos += widthDiff;
19289
19342
  column.modules.vdomHoz.width = newWidth;
19290
- this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff);
19343
+ this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);
19291
19344
  }
19292
19345
 
19293
19346
  column.modules.vdomHoz.fitDataCheck = false;
19294
19347
  }
19295
- };
19348
+
19349
+ return widthDiff;
19350
+ }
19296
19351
 
19297
19352
  initializeRow(row){
19298
19353
  if(row.type !== "group"){
@@ -22136,14 +22191,14 @@ class ComponentFunctionBinder{
22136
22191
  }
22137
22192
 
22138
22193
  if(this.bindings[type][funcName]){
22139
- console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, hanlder);
22194
+ console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler);
22140
22195
  }else {
22141
22196
  this.bindings[type][funcName] = handler;
22142
22197
  }
22143
22198
  }
22144
22199
 
22145
22200
  handle(type, component, name){
22146
- if(this.bindings[type] && this.bindings[type][name]){
22201
+ if(this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function'){
22147
22202
  return this.bindings[type][name].bind(null, component);
22148
22203
  }else {
22149
22204
  if(name !== "then" && typeof name === "string" && !name.startsWith("_")){