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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulator-tables",
3
- "version": "5.3.1",
3
+ "version": "5.3.2",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -444,14 +444,14 @@ export default class ColumnManager extends CoreFeature {
444
444
  }
445
445
 
446
446
  moveColumn(from, to, after){
447
- this.moveColumnActual(from, to, after);
448
-
449
447
  to.element.parentNode.insertBefore(from.element, to.element);
450
448
 
451
449
  if(after){
452
450
  to.element.parentNode.insertBefore(to.element, from.element);
453
451
  }
454
452
 
453
+ this.moveColumnActual(from, to, after);
454
+
455
455
  this.verticalAlignHeaders();
456
456
 
457
457
  this.table.rowManager.reinitialize();
@@ -604,81 +604,82 @@ export default class RowManager extends CoreFeature{
604
604
  index = 0,
605
605
  cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"];
606
606
 
607
-
608
- if(typeof handler === "function"){
609
- index = this.dataPipeline.findIndex((item) => {
610
- return item.handler === handler;
611
- });
612
-
613
- if(index > -1){
614
- stage = "dataPipeline";
615
-
616
- if(skipStage){
617
- if(index == this.dataPipeline.length - 1){
618
- stage = "display";
619
- }else{
620
- index++;
621
- }
622
- }
623
- }else{
624
- index = this.displayPipeline.findIndex((item) => {
607
+ if(!this.table.destroyed){
608
+ if(typeof handler === "function"){
609
+ index = this.dataPipeline.findIndex((item) => {
625
610
  return item.handler === handler;
626
611
  });
627
612
 
628
613
  if(index > -1){
629
- stage = "displayPipeline";
614
+ stage = "dataPipeline";
630
615
 
631
616
  if(skipStage){
632
- if(index == this.displayPipeline.length - 1){
633
- stage = "end";
617
+ if(index == this.dataPipeline.length - 1){
618
+ stage = "display";
634
619
  }else{
635
620
  index++;
636
621
  }
637
622
  }
638
623
  }else{
639
- console.error("Unable to refresh data, invalid handler provided", handler);
640
- return;
624
+ index = this.displayPipeline.findIndex((item) => {
625
+ return item.handler === handler;
626
+ });
627
+
628
+ if(index > -1){
629
+ stage = "displayPipeline";
630
+
631
+ if(skipStage){
632
+ if(index == this.displayPipeline.length - 1){
633
+ stage = "end";
634
+ }else{
635
+ index++;
636
+ }
637
+ }
638
+ }else{
639
+ console.error("Unable to refresh data, invalid handler provided", handler);
640
+ return;
641
+ }
641
642
  }
642
- }
643
- }else{
644
- stage = handler || "all";
645
- index = 0;
646
- }
647
-
648
- if(this.redrawBlock){
649
- if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){
650
- this.redrawBlockRestoreConfig = {
651
- handler: handler,
652
- skipStage: skipStage,
653
- renderInPosition: renderInPosition,
654
- stage:stage,
655
- index:index,
656
- };
643
+ }else{
644
+ stage = handler || "all";
645
+ index = 0;
657
646
  }
658
647
 
659
- return;
660
- }else{
661
- if(Helpers.elVisible(this.element)){
662
- if(renderInPosition){
663
- this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));
648
+ if(this.redrawBlock){
649
+ if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){
650
+ this.redrawBlockRestoreConfig = {
651
+ handler: handler,
652
+ skipStage: skipStage,
653
+ renderInPosition: renderInPosition,
654
+ stage:stage,
655
+ index:index,
656
+ };
657
+ }
658
+
659
+ return;
660
+ }else{
661
+ if(Helpers.elVisible(this.element)){
662
+ if(renderInPosition){
663
+ this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));
664
+ }else{
665
+ this.refreshPipelines(handler, stage, index, renderInPosition);
666
+
667
+ if(!handler){
668
+ this.table.columnManager.renderer.renderColumns();
669
+ }
670
+
671
+ this.renderTable();
672
+
673
+ if(table.options.layoutColumnsOnNewData){
674
+ this.table.columnManager.redraw(true);
675
+ }
676
+ }
664
677
  }else{
665
678
  this.refreshPipelines(handler, stage, index, renderInPosition);
666
-
667
- if(!handler){
668
- this.table.columnManager.renderer.renderColumns();
669
- }
670
-
671
- this.renderTable();
672
-
673
- if(table.options.layoutColumnsOnNewData){
674
- this.table.columnManager.redraw(true);
675
- }
676
679
  }
677
- }else{
678
- this.refreshPipelines(handler, stage, index, renderInPosition);
680
+
681
+ this.dispatch("data-refreshed");
679
682
  }
680
-
681
- this.dispatch("data-refreshed");
682
683
  }
683
684
  }
684
685
 
@@ -711,7 +712,7 @@ export default class RowManager extends CoreFeature{
711
712
  case "displayPipeline":
712
713
  for(let i = index; i < this.displayPipeline.length; i++){
713
714
  let result = this.displayPipeline[i].handler((i ? this.getDisplayRows(i - 1) : this.activeRows).slice(0), renderInPosition);
714
-
715
+
715
716
  this.setDisplayRows(result || this.getDisplayRows(i - 1).slice(0), i);
716
717
  }
717
718
 
@@ -754,22 +755,11 @@ export default class RowManager extends CoreFeature{
754
755
 
755
756
  //set display row pipeline data
756
757
  setDisplayRows(displayRows, index){
757
-
758
- var output = true;
759
-
760
- if(index && typeof this.displayRows[index] != "undefined"){
761
- this.displayRows[index] = displayRows;
762
- output = true;
763
- }else{
764
- this.displayRows.push(displayRows);
765
- output = index = this.displayRows.length -1;
766
- }
767
-
758
+ this.displayRows[index] = displayRows;
759
+
768
760
  if(index == this.displayRows.length -1){
769
761
  this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;
770
762
  }
771
-
772
- return output;
773
763
  }
774
764
 
775
765
  getDisplayRows(index){
@@ -417,7 +417,7 @@ class Tabulator {
417
417
  data = JSON.parse(data);
418
418
  }
419
419
 
420
- if(data){
420
+ if(data && data.length > 0){
421
421
  data.forEach((item) => {
422
422
  var row = this.rowManager.findRow(item[this.options.index]);
423
423
 
@@ -483,7 +483,7 @@ class Tabulator {
483
483
  data = JSON.parse(data);
484
484
  }
485
485
 
486
- if(data){
486
+ if(data && data.length > 0){
487
487
  data.forEach((item) => {
488
488
  var row = this.rowManager.findRow(item[this.options.index]);
489
489
 
@@ -236,12 +236,13 @@ export default class InteractionManager extends CoreFeature {
236
236
  //ensure row component is looked up before cell
237
237
  var keys = Object.keys(targets).reverse(),
238
238
  listener = this.listeners[type],
239
+ matches = {},
239
240
  targetMatches = {};
240
241
 
241
242
  for(let key of keys){
242
- let component;
243
- let target = targets[key];
244
- let previousTarget = this.previousTargets[key];
243
+ let component,
244
+ target = targets[key],
245
+ previousTarget = this.previousTargets[key];
245
246
 
246
247
  if(previousTarget && previousTarget.target === target){
247
248
  component = previousTarget.component;
@@ -270,8 +271,8 @@ export default class InteractionManager extends CoreFeature {
270
271
 
271
272
  case "cell":
272
273
  if(listener.components.includes("cell")){
273
- if(targets["row"] instanceof Row){
274
- component = targets["row"].findCell(target);
274
+ if(matches["row"] instanceof Row){
275
+ component = matches["row"].findCell(target);
275
276
  }else{
276
277
  if(targets["row"]){
277
278
  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?");
@@ -283,7 +284,7 @@ export default class InteractionManager extends CoreFeature {
283
284
  }
284
285
 
285
286
  if(component){
286
- targets[key] = component;
287
+ matches[key] = component;
287
288
  targetMatches[key] = {
288
289
  target:target,
289
290
  component:component,
@@ -293,12 +294,12 @@ export default class InteractionManager extends CoreFeature {
293
294
 
294
295
  this.previousTargets = targetMatches;
295
296
 
296
- return targets;
297
+ return matches;
297
298
  }
298
299
 
299
300
  triggerEvents(type, e, targets){
300
301
  var listener = this.listeners[type];
301
-
302
+
302
303
  for(let key in targets){
303
304
  if(targets[key] && listener.components.includes(key)){
304
305
  this.dispatch(key + "-" + type, e, targets[key]);
@@ -128,7 +128,7 @@ class Interaction extends Module{
128
128
  var range;
129
129
 
130
130
  if(this.table.modExists("edit")){
131
- if (this.table.modules.edit.currentCell === this){
131
+ if (this.table.modules.edit.currentCell === cell){
132
132
  return; //prevent instant selection of editor content
133
133
  }
134
134
  }
@@ -169,7 +169,6 @@ class Sort extends Module{
169
169
  }
170
170
  }
171
171
 
172
-
173
172
  if (this.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {
174
173
  sorters = this.getSort();
175
174
 
@@ -180,11 +179,9 @@ class Sort extends Module{
180
179
  if(match > -1){
181
180
  sorters[match].dir = dir;
182
181
 
183
- if(match != sorters.length -1){
184
- match = sorters.splice(match, 1)[0];
185
- if(dir != "none"){
186
- sorters.push(match);
187
- }
182
+ match = sorters.splice(match, 1)[0];
183
+ if(dir != "none"){
184
+ sorters.push(match);
188
185
  }
189
186
  }else{
190
187
  if(dir != "none"){
@@ -399,7 +396,7 @@ class Sort extends Module{
399
396
  var sortEl = column.modules.sort.element,
400
397
  arrowEl;
401
398
 
402
- if(typeof this.table.options.headerSortElement === "function"){
399
+ if(column.definition.headerSort && typeof this.table.options.headerSortElement === "function"){
403
400
  while(sortEl.firstChild) sortEl.removeChild(sortEl.firstChild);
404
401
 
405
402
  arrowEl = this.table.options.headerSortElement.call(this.table, column.getComponent(), dir);