tabulator-tables 5.2.6 → 5.2.7

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.2.6 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.2.7 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -195,7 +195,13 @@ class Popup extends CoreFeature{
195
195
  this.blurEvent = this.hide.bind(this, false);
196
196
  this.escEvent = this._escapeCheck.bind(this);
197
197
 
198
- this.destroyBinding = this.hide.bind(this, true);
198
+ this.destroyBinding = this.tableDestroyed;
199
+ this.destroyed = false;
200
+ }
201
+
202
+ tableDestroyed(){
203
+ this.destroyed = true;
204
+ this.hide(true);
199
205
  }
200
206
 
201
207
  _lookupContainer(){
@@ -279,6 +285,10 @@ class Popup extends CoreFeature{
279
285
 
280
286
  show(origin, position){
281
287
  var x, y, parentEl, parentOffset, coords;
288
+
289
+ if(this.destroyed || this.table.destroyed){
290
+ return this;
291
+ }
282
292
 
283
293
  if(origin instanceof HTMLElement){
284
294
  parentEl = origin;
@@ -315,6 +325,10 @@ class Popup extends CoreFeature{
315
325
  this.visible = true;
316
326
 
317
327
  this.subscribe("table-destroy", this.destroyBinding);
328
+
329
+ this.element.addEventListener("mousedown", (e) => {
330
+ e.stopPropagation();
331
+ });
318
332
 
319
333
  return this;
320
334
  }
@@ -366,8 +380,10 @@ class Popup extends CoreFeature{
366
380
  this.subscribe("cell-editing", this.blurEvent);
367
381
  document.body.addEventListener("click", this.blurEvent);
368
382
  document.body.addEventListener("contextmenu", this.blurEvent);
383
+ document.body.addEventListener("mousedown", this.blurEvent);
369
384
  window.addEventListener("resize", this.blurEvent);
370
385
  document.body.addEventListener("keydown", this.escEvent);
386
+
371
387
  }, 100);
372
388
 
373
389
  this.blurCallback = callback;
@@ -388,6 +404,7 @@ class Popup extends CoreFeature{
388
404
  document.body.removeEventListener("keydown", this.escEvent);
389
405
  document.body.removeEventListener("click", this.blurEvent);
390
406
  document.body.removeEventListener("contextmenu", this.blurEvent);
407
+ document.body.removeEventListener("mousedown", this.blurEvent);
391
408
  window.removeEventListener("resize", this.blurEvent);
392
409
  this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);
393
410
  this.unsubscribe("cell-editing", this.blurEvent);
@@ -5513,6 +5530,8 @@ class Edit{
5513
5530
 
5514
5531
  this.listIteration = 0;
5515
5532
 
5533
+ this.lastAction="";
5534
+
5516
5535
  this.blurable = true;
5517
5536
 
5518
5537
  this.actions = {
@@ -5643,7 +5662,7 @@ class Edit{
5643
5662
  _initializeParams(params){
5644
5663
  var valueKeys = ["values", "valuesURL", "valuesLookup"],
5645
5664
  valueCheck;
5646
-
5665
+
5647
5666
  params = Object.assign({}, params);
5648
5667
 
5649
5668
  params.verticalNavigation = params.verticalNavigation || "editor";
@@ -5652,9 +5671,9 @@ class Edit{
5652
5671
  params.filterDelay = typeof params.filterDelay === "undefined" ? 300 : params.filterDelay;
5653
5672
 
5654
5673
  params.emptyValue = Object.keys(params).includes("emptyValue") ? params.emptyValue : "";
5655
-
5674
+
5656
5675
  valueCheck = Object.keys(params).filter(key => valueKeys.includes(key)).length;
5657
-
5676
+
5658
5677
  if(!valueCheck){
5659
5678
  console.warn("list editor config error - either the values, valuesURL, or valuesLookup option must be set");
5660
5679
  }else if(valueCheck > 1){
@@ -5854,10 +5873,12 @@ class Edit{
5854
5873
  }
5855
5874
 
5856
5875
  _keyEnter(e){
5857
- if(this.focusedItem){
5858
- this._chooseItem(this.focusedItem);
5876
+ if(this.params.autocomplete && this.lastAction === "typing"){
5877
+ this._resolveValue(true);
5859
5878
  }else {
5860
- this._cancel();
5879
+ if(this.focusedItem){
5880
+ this._chooseItem(this.focusedItem);
5881
+ }
5861
5882
  }
5862
5883
  }
5863
5884
 
@@ -5886,6 +5907,7 @@ class Edit{
5886
5907
 
5887
5908
  _keyAutoCompLetter(e){
5888
5909
  this._filter();
5910
+ this.lastAction = "typing";
5889
5911
  this.typing = true;
5890
5912
  }
5891
5913
 
@@ -5910,6 +5932,8 @@ class Edit{
5910
5932
  }
5911
5933
 
5912
5934
  _focusItem(item){
5935
+ this.lastAction = "focus";
5936
+
5913
5937
  if(this.focusedItem && this.focusedItem.element){
5914
5938
  this.focusedItem.element.classList.remove("focused");
5915
5939
  }
@@ -6079,6 +6103,12 @@ class Edit{
6079
6103
 
6080
6104
  this._parseListItem(value, data, 0);
6081
6105
  });
6106
+
6107
+ if(!this.currentItems.length && this.params.freetext){
6108
+ this.input.value = this.initialValues;
6109
+ this.typing = true;
6110
+ this.lastAction = "typing";
6111
+ }
6082
6112
 
6083
6113
  this.data = data;
6084
6114
 
@@ -6422,6 +6452,8 @@ class Edit{
6422
6452
  }else {
6423
6453
  this.currentItems = [item];
6424
6454
  item.selected = true;
6455
+
6456
+ console.log("choose");
6425
6457
 
6426
6458
  this.input.value = item.label;
6427
6459
 
@@ -24020,6 +24052,7 @@ class Tabulator {
24020
24052
  this.optionsList = new OptionsList(this, "table constructor");
24021
24053
 
24022
24054
  this.initialized = false;
24055
+ this.destroyed = false;
24023
24056
 
24024
24057
  if(this.initializeElement(element)){
24025
24058
 
@@ -24248,6 +24281,8 @@ class Tabulator {
24248
24281
  destroy(){
24249
24282
  var element = this.element;
24250
24283
 
24284
+ this.destroyed = true;
24285
+
24251
24286
  TableRegistry.deregister(this); //deregister table from inter-device communication
24252
24287
 
24253
24288
  this.eventBus.dispatch("table-destroy");