tabulator-tables 5.3.1 → 5.3.2

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.3.1 (c) Oliver Folkerd 2022 */
1
+ /* Tabulator v5.3.2 (c) Oliver Folkerd 2022 */
2
2
  class CoreFeature{
3
3
 
4
4
  constructor(table){
@@ -13085,7 +13085,7 @@ class Interaction extends Module{
13085
13085
  var range;
13086
13086
 
13087
13087
  if(this.table.modExists("edit")){
13088
- if (this.table.modules.edit.currentCell === this){
13088
+ if (this.table.modules.edit.currentCell === cell){
13089
13089
  return; //prevent instant selection of editor content
13090
13090
  }
13091
13091
  }
@@ -18862,7 +18862,6 @@ class Sort extends Module{
18862
18862
  }
18863
18863
  }
18864
18864
 
18865
-
18866
18865
  if (this.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {
18867
18866
  sorters = this.getSort();
18868
18867
 
@@ -18873,11 +18872,9 @@ class Sort extends Module{
18873
18872
  if(match > -1){
18874
18873
  sorters[match].dir = dir;
18875
18874
 
18876
- if(match != sorters.length -1){
18877
- match = sorters.splice(match, 1)[0];
18878
- if(dir != "none"){
18879
- sorters.push(match);
18880
- }
18875
+ match = sorters.splice(match, 1)[0];
18876
+ if(dir != "none"){
18877
+ sorters.push(match);
18881
18878
  }
18882
18879
  }else {
18883
18880
  if(dir != "none"){
@@ -19092,7 +19089,7 @@ class Sort extends Module{
19092
19089
  var sortEl = column.modules.sort.element,
19093
19090
  arrowEl;
19094
19091
 
19095
- if(typeof this.table.options.headerSortElement === "function"){
19092
+ if(column.definition.headerSort && typeof this.table.options.headerSortElement === "function"){
19096
19093
  while(sortEl.firstChild) sortEl.removeChild(sortEl.firstChild);
19097
19094
 
19098
19095
  arrowEl = this.table.options.headerSortElement.call(this.table, column.getComponent(), dir);
@@ -21075,14 +21072,14 @@ class ColumnManager extends CoreFeature {
21075
21072
  }
21076
21073
 
21077
21074
  moveColumn(from, to, after){
21078
- this.moveColumnActual(from, to, after);
21079
-
21080
21075
  to.element.parentNode.insertBefore(from.element, to.element);
21081
21076
 
21082
21077
  if(after){
21083
21078
  to.element.parentNode.insertBefore(to.element, from.element);
21084
21079
  }
21085
21080
 
21081
+ this.moveColumnActual(from, to, after);
21082
+
21086
21083
  this.verticalAlignHeaders();
21087
21084
 
21088
21085
  this.table.rowManager.reinitialize();
@@ -22597,81 +22594,82 @@ class RowManager extends CoreFeature{
22597
22594
  index = 0,
22598
22595
  cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"];
22599
22596
 
22600
-
22601
- if(typeof handler === "function"){
22602
- index = this.dataPipeline.findIndex((item) => {
22603
- return item.handler === handler;
22604
- });
22605
-
22606
- if(index > -1){
22607
- stage = "dataPipeline";
22608
-
22609
- if(skipStage){
22610
- if(index == this.dataPipeline.length - 1){
22611
- stage = "display";
22612
- }else {
22613
- index++;
22614
- }
22615
- }
22616
- }else {
22617
- index = this.displayPipeline.findIndex((item) => {
22597
+ if(!this.table.destroyed){
22598
+ if(typeof handler === "function"){
22599
+ index = this.dataPipeline.findIndex((item) => {
22618
22600
  return item.handler === handler;
22619
22601
  });
22620
22602
 
22621
22603
  if(index > -1){
22622
- stage = "displayPipeline";
22604
+ stage = "dataPipeline";
22623
22605
 
22624
22606
  if(skipStage){
22625
- if(index == this.displayPipeline.length - 1){
22626
- stage = "end";
22607
+ if(index == this.dataPipeline.length - 1){
22608
+ stage = "display";
22627
22609
  }else {
22628
22610
  index++;
22629
22611
  }
22630
22612
  }
22631
22613
  }else {
22632
- console.error("Unable to refresh data, invalid handler provided", handler);
22633
- return;
22614
+ index = this.displayPipeline.findIndex((item) => {
22615
+ return item.handler === handler;
22616
+ });
22617
+
22618
+ if(index > -1){
22619
+ stage = "displayPipeline";
22620
+
22621
+ if(skipStage){
22622
+ if(index == this.displayPipeline.length - 1){
22623
+ stage = "end";
22624
+ }else {
22625
+ index++;
22626
+ }
22627
+ }
22628
+ }else {
22629
+ console.error("Unable to refresh data, invalid handler provided", handler);
22630
+ return;
22631
+ }
22634
22632
  }
22635
- }
22636
- }else {
22637
- stage = handler || "all";
22638
- index = 0;
22639
- }
22640
-
22641
- if(this.redrawBlock){
22642
- if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){
22643
- this.redrawBlockRestoreConfig = {
22644
- handler: handler,
22645
- skipStage: skipStage,
22646
- renderInPosition: renderInPosition,
22647
- stage:stage,
22648
- index:index,
22649
- };
22633
+ }else {
22634
+ stage = handler || "all";
22635
+ index = 0;
22650
22636
  }
22651
22637
 
22652
- return;
22653
- }else {
22654
- if(Helpers.elVisible(this.element)){
22655
- if(renderInPosition){
22656
- this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));
22638
+ if(this.redrawBlock){
22639
+ if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){
22640
+ this.redrawBlockRestoreConfig = {
22641
+ handler: handler,
22642
+ skipStage: skipStage,
22643
+ renderInPosition: renderInPosition,
22644
+ stage:stage,
22645
+ index:index,
22646
+ };
22647
+ }
22648
+
22649
+ return;
22650
+ }else {
22651
+ if(Helpers.elVisible(this.element)){
22652
+ if(renderInPosition){
22653
+ this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));
22654
+ }else {
22655
+ this.refreshPipelines(handler, stage, index, renderInPosition);
22656
+
22657
+ if(!handler){
22658
+ this.table.columnManager.renderer.renderColumns();
22659
+ }
22660
+
22661
+ this.renderTable();
22662
+
22663
+ if(table.options.layoutColumnsOnNewData){
22664
+ this.table.columnManager.redraw(true);
22665
+ }
22666
+ }
22657
22667
  }else {
22658
22668
  this.refreshPipelines(handler, stage, index, renderInPosition);
22659
-
22660
- if(!handler){
22661
- this.table.columnManager.renderer.renderColumns();
22662
- }
22663
-
22664
- this.renderTable();
22665
-
22666
- if(table.options.layoutColumnsOnNewData){
22667
- this.table.columnManager.redraw(true);
22668
- }
22669
22669
  }
22670
- }else {
22671
- this.refreshPipelines(handler, stage, index, renderInPosition);
22670
+
22671
+ this.dispatch("data-refreshed");
22672
22672
  }
22673
-
22674
- this.dispatch("data-refreshed");
22675
22673
  }
22676
22674
  }
22677
22675
 
@@ -22704,7 +22702,7 @@ class RowManager extends CoreFeature{
22704
22702
  case "displayPipeline":
22705
22703
  for(let i = index; i < this.displayPipeline.length; i++){
22706
22704
  let result = this.displayPipeline[i].handler((i ? this.getDisplayRows(i - 1) : this.activeRows).slice(0), renderInPosition);
22707
-
22705
+
22708
22706
  this.setDisplayRows(result || this.getDisplayRows(i - 1).slice(0), i);
22709
22707
  }
22710
22708
 
@@ -22747,22 +22745,11 @@ class RowManager extends CoreFeature{
22747
22745
 
22748
22746
  //set display row pipeline data
22749
22747
  setDisplayRows(displayRows, index){
22750
-
22751
- var output = true;
22752
-
22753
- if(index && typeof this.displayRows[index] != "undefined"){
22754
- this.displayRows[index] = displayRows;
22755
- output = true;
22756
- }else {
22757
- this.displayRows.push(displayRows);
22758
- output = index = this.displayRows.length -1;
22759
- }
22760
-
22748
+ this.displayRows[index] = displayRows;
22749
+
22761
22750
  if(index == this.displayRows.length -1){
22762
22751
  this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;
22763
22752
  }
22764
-
22765
- return output;
22766
22753
  }
22767
22754
 
22768
22755
  getDisplayRows(index){
@@ -23397,12 +23384,13 @@ class InteractionManager extends CoreFeature {
23397
23384
  //ensure row component is looked up before cell
23398
23385
  var keys = Object.keys(targets).reverse(),
23399
23386
  listener = this.listeners[type],
23387
+ matches = {},
23400
23388
  targetMatches = {};
23401
23389
 
23402
23390
  for(let key of keys){
23403
- let component;
23404
- let target = targets[key];
23405
- let previousTarget = this.previousTargets[key];
23391
+ let component,
23392
+ target = targets[key],
23393
+ previousTarget = this.previousTargets[key];
23406
23394
 
23407
23395
  if(previousTarget && previousTarget.target === target){
23408
23396
  component = previousTarget.component;
@@ -23431,8 +23419,8 @@ class InteractionManager extends CoreFeature {
23431
23419
 
23432
23420
  case "cell":
23433
23421
  if(listener.components.includes("cell")){
23434
- if(targets["row"] instanceof Row){
23435
- component = targets["row"].findCell(target);
23422
+ if(matches["row"] instanceof Row){
23423
+ component = matches["row"].findCell(target);
23436
23424
  }else {
23437
23425
  if(targets["row"]){
23438
23426
  console.warn("Event Target Lookup Error - The row this cell is attached to cannot be found, has the table been reinitialized without being destroyed first?");
@@ -23444,7 +23432,7 @@ class InteractionManager extends CoreFeature {
23444
23432
  }
23445
23433
 
23446
23434
  if(component){
23447
- targets[key] = component;
23435
+ matches[key] = component;
23448
23436
  targetMatches[key] = {
23449
23437
  target:target,
23450
23438
  component:component,
@@ -23454,12 +23442,12 @@ class InteractionManager extends CoreFeature {
23454
23442
 
23455
23443
  this.previousTargets = targetMatches;
23456
23444
 
23457
- return targets;
23445
+ return matches;
23458
23446
  }
23459
23447
 
23460
23448
  triggerEvents(type, e, targets){
23461
23449
  var listener = this.listeners[type];
23462
-
23450
+
23463
23451
  for(let key in targets){
23464
23452
  if(targets[key] && listener.components.includes(key)){
23465
23453
  this.dispatch(key + "-" + type, e, targets[key]);
@@ -25133,7 +25121,7 @@ class Tabulator {
25133
25121
  data = JSON.parse(data);
25134
25122
  }
25135
25123
 
25136
- if(data){
25124
+ if(data && data.length > 0){
25137
25125
  data.forEach((item) => {
25138
25126
  var row = this.rowManager.findRow(item[this.options.index]);
25139
25127
 
@@ -25199,7 +25187,7 @@ class Tabulator {
25199
25187
  data = JSON.parse(data);
25200
25188
  }
25201
25189
 
25202
- if(data){
25190
+ if(data && data.length > 0){
25203
25191
  data.forEach((item) => {
25204
25192
  var row = this.rowManager.findRow(item[this.options.index]);
25205
25193