tabulator-tables 5.3.1 → 5.3.4

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.
Files changed (40) hide show
  1. package/bower.json +1 -1
  2. package/dist/css/tabulator_bootstrap3.css +1 -1
  3. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  4. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  5. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  6. package/dist/css/tabulator_bootstrap4.css +4 -4
  7. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  8. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  9. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  10. package/dist/css/tabulator_bootstrap5.css +4 -4
  11. package/dist/css/tabulator_bootstrap5.css.map +1 -1
  12. package/dist/css/tabulator_bootstrap5.min.css +1 -1
  13. package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
  14. package/dist/js/tabulator.js +225 -216
  15. package/dist/js/tabulator.js.map +1 -1
  16. package/dist/js/tabulator.min.js +2 -2
  17. package/dist/js/tabulator.min.js.map +1 -1
  18. package/dist/js/tabulator_esm.js +379 -377
  19. package/dist/js/tabulator_esm.js.map +1 -1
  20. package/dist/js/tabulator_esm.min.js +2 -2
  21. package/dist/js/tabulator_esm.min.js.map +1 -1
  22. package/package.json +1 -1
  23. package/src/js/core/ColumnManager.js +7 -3
  24. package/src/js/core/Module.js +54 -23
  25. package/src/js/core/RowManager.js +81 -94
  26. package/src/js/core/Tabulator.js +2 -2
  27. package/src/js/core/tools/InteractionMonitor.js +9 -8
  28. package/src/js/modules/DataTree/DataTree.js +0 -10
  29. package/src/js/modules/FrozenRows/FrozenRows.js +3 -2
  30. package/src/js/modules/GroupRows/Group.js +3 -7
  31. package/src/js/modules/GroupRows/GroupComponent.js +1 -1
  32. package/src/js/modules/GroupRows/GroupRows.js +200 -200
  33. package/src/js/modules/Interaction/Interaction.js +1 -1
  34. package/src/js/modules/Page/Page.js +2 -12
  35. package/src/js/modules/Persistence/Persistence.js +3 -2
  36. package/src/js/modules/SelectRow/SelectRow.js +8 -4
  37. package/src/js/modules/Sort/Sort.js +4 -7
  38. package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +1 -1
  39. package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +1 -1
  40. package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulator-tables",
3
- "version": "5.3.1",
3
+ "version": "5.3.4",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -286,6 +286,8 @@ export default class ColumnManager extends CoreFeature {
286
286
  var minHeight = 0;
287
287
 
288
288
  if(!this.redrawBlock){
289
+
290
+ this.headersElement.style.height="";
289
291
 
290
292
  this.columns.forEach((column) => {
291
293
  column.clearVerticalAlign();
@@ -298,7 +300,9 @@ export default class ColumnManager extends CoreFeature {
298
300
  minHeight = height;
299
301
  }
300
302
  });
301
-
303
+
304
+ this.headersElement.style.height = minHeight + "px";
305
+
302
306
  this.columns.forEach((column) => {
303
307
  column.verticalAlign(this.table.options.columnHeaderVertAlign, minHeight);
304
308
  });
@@ -444,14 +448,14 @@ export default class ColumnManager extends CoreFeature {
444
448
  }
445
449
 
446
450
  moveColumn(from, to, after){
447
- this.moveColumnActual(from, to, after);
448
-
449
451
  to.element.parentNode.insertBefore(from.element, to.element);
450
452
 
451
453
  if(after){
452
454
  to.element.parentNode.insertBefore(to.element, from.element);
453
455
  }
454
456
 
457
+ this.moveColumnActual(from, to, after);
458
+
455
459
  this.verticalAlignHeaders();
456
460
 
457
461
  this.table.rowManager.reinitialize();
@@ -2,90 +2,121 @@ import CoreFeature from './CoreFeature.js';
2
2
  import Popup from './tools/Popup.js';
3
3
 
4
4
  class Module extends CoreFeature{
5
-
5
+
6
6
  constructor(table, name){
7
7
  super(table);
8
-
8
+
9
9
  this._handler = null;
10
10
  }
11
-
11
+
12
12
  initialize(){
13
13
  // setup module when table is initialized, to be overridden in module
14
14
  }
15
-
16
-
15
+
16
+
17
17
  ///////////////////////////////////
18
18
  ////// Options Registration ///////
19
19
  ///////////////////////////////////
20
-
20
+
21
21
  registerTableOption(key, value){
22
22
  this.table.optionsList.register(key, value);
23
23
  }
24
-
24
+
25
25
  registerColumnOption(key, value){
26
26
  this.table.columnManager.optionsList.register(key, value);
27
27
  }
28
-
28
+
29
29
  ///////////////////////////////////
30
30
  /// Public Function Registration ///
31
31
  ///////////////////////////////////
32
-
32
+
33
33
  registerTableFunction(name, func){
34
34
  if(typeof this.table[name] === "undefined"){
35
35
  this.table[name] = (...args) => {
36
36
  this.table.initGuard(name);
37
-
37
+
38
38
  return func(...args);
39
39
  };
40
40
  }else{
41
41
  console.warn("Unable to bind table function, name already in use", name);
42
42
  }
43
43
  }
44
-
44
+
45
45
  registerComponentFunction(component, func, handler){
46
46
  return this.table.componentFunctionBinder.bind(component, func, handler);
47
47
  }
48
-
48
+
49
49
  ///////////////////////////////////
50
50
  ////////// Data Pipeline //////////
51
51
  ///////////////////////////////////
52
-
52
+
53
53
  registerDataHandler(handler, priority){
54
54
  this.table.rowManager.registerDataPipelineHandler(handler, priority);
55
55
  this._handler = handler;
56
56
  }
57
-
57
+
58
58
  registerDisplayHandler(handler, priority){
59
59
  this.table.rowManager.registerDisplayPipelineHandler(handler, priority);
60
60
  this._handler = handler;
61
61
  }
62
+
63
+ displayRows(adjust){
64
+ var index = this.table.rowManager.displayRows.length - 1,
65
+ lookupIndex;
66
+
67
+ if(this._handler){
68
+ lookupIndex = this.table.rowManager.displayPipeline.findIndex((item) => {
69
+ return item.handler === this._handler;
70
+ });
71
+
72
+ if(lookupIndex > -1){
73
+ index = lookupIndex;
74
+ }
75
+ }
76
+
77
+ if(adjust){
78
+ index = index + adjust;
79
+ }
62
80
 
81
+ if(this._handler){
82
+ if(index > -1){
83
+ return this.table.rowManager.getDisplayRows(index);
84
+ }else{
85
+ return this.activeRows();
86
+ }
87
+ }
88
+ }
89
+
90
+ activeRows(){
91
+ return this.table.rowManager.activeRows;
92
+ }
93
+
63
94
  refreshData(renderInPosition, handler){
64
95
  if(!handler){
65
96
  handler = this._handler;
66
97
  }
67
-
98
+
68
99
  if(handler){
69
100
  this.table.rowManager.refreshActiveData(handler, false, renderInPosition);
70
101
  }
71
102
  }
72
-
103
+
73
104
  ///////////////////////////////////
74
105
  //////// Footer Management ////////
75
106
  ///////////////////////////////////
76
-
107
+
77
108
  footerAppend(element){
78
109
  return this.table.footerManager.append(element);
79
110
  }
80
-
111
+
81
112
  footerPrepend(element){
82
113
  return this.table.footerManager.prepend(element);
83
114
  }
84
-
115
+
85
116
  footerRemove(element){
86
117
  return this.table.footerManager.remove(element);
87
118
  }
88
-
119
+
89
120
  ///////////////////////////////////
90
121
  //////// Popups Management ////////
91
122
  ///////////////////////////////////
@@ -93,15 +124,15 @@ class Module extends CoreFeature{
93
124
  popup(menuEl, menuContainer){
94
125
  return new Popup(this.table, menuEl, menuContainer);
95
126
  }
96
-
127
+
97
128
  ///////////////////////////////////
98
129
  //////// Alert Management ////////
99
130
  ///////////////////////////////////
100
-
131
+
101
132
  alert(content, type){
102
133
  return this.table.alertManager.alert(content, type);
103
134
  }
104
-
135
+
105
136
  clearAlert(){
106
137
  return this.table.alertManager.clear();
107
138
  }
@@ -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
 
@@ -748,28 +749,13 @@ export default class RowManager extends CoreFeature{
748
749
  this.displayRowsCount = this.displayRows[0].length;
749
750
  }
750
751
 
751
- getNextDisplayIndex(){
752
- return this.displayRows.length;
753
- }
754
-
755
752
  //set display row pipeline data
756
753
  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
-
754
+ this.displayRows[index] = displayRows;
755
+
768
756
  if(index == this.displayRows.length -1){
769
757
  this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;
770
758
  }
771
-
772
- return output;
773
759
  }
774
760
 
775
761
  getDisplayRows(index){
@@ -800,23 +786,24 @@ export default class RowManager extends CoreFeature{
800
786
 
801
787
  //return only actual rows (not group headers etc)
802
788
  getRows(type){
803
- var rows;
804
-
805
- switch(type){
806
- case "active":
807
- rows = this.activeRows;
808
- break;
809
-
810
- case "display":
811
- rows = this.table.rowManager.getDisplayRows();
812
- break;
813
-
814
- case "visible":
815
- rows = this.getVisibleRows(false, true);
816
- break;
789
+ var rows = [];
790
+
791
+ if(!type || type === true){
792
+ rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;
793
+ }else{
794
+ switch(type){
795
+ case "active":
796
+ rows = this.activeRows;
797
+ break;
817
798
 
818
- default:
819
- rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;
799
+ case "display":
800
+ rows = this.table.rowManager.getDisplayRows();
801
+ break;
802
+
803
+ case "visible":
804
+ rows = this.getVisibleRows(false, true);
805
+ break;
806
+ }
820
807
  }
821
808
 
822
809
  return rows;
@@ -925,9 +912,6 @@ export default class RowManager extends CoreFeature{
925
912
 
926
913
  this.scrollTop = 0;
927
914
  this.scrollLeft = 0;
928
-
929
- // clear empty table placeholder min
930
- this.tableElement.style.minWidth = "";
931
915
 
932
916
  this.renderer.clearRows();
933
917
  }
@@ -945,6 +929,9 @@ export default class RowManager extends CoreFeature{
945
929
  if(this.placeholder && this.placeholder.parentNode){
946
930
  this.placeholder.parentNode.removeChild(this.placeholder);
947
931
  }
932
+
933
+ // clear empty table placeholder min
934
+ this.tableElement.style.minWidth = "";
948
935
  }
949
936
 
950
937
  _positionPlaceholder(){
@@ -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]);
@@ -18,8 +18,6 @@ class DataTree extends Module{
18
18
 
19
19
  this.startOpen = function(){};
20
20
 
21
- this.displayIndex = 0;
22
-
23
21
  this.registerTableOption("dataTree", false); //enable data tree
24
22
  this.registerTableOption("dataTreeFilter", true); //filter child rows
25
23
  this.registerTableOption("dataTreeSort", true); //sort child rows
@@ -295,14 +293,6 @@ class DataTree extends Module{
295
293
  }
296
294
  }
297
295
 
298
- setDisplayIndex (index) {
299
- this.displayIndex = index;
300
- }
301
-
302
- getDisplayIndex () {
303
- return this.displayIndex;
304
- }
305
-
306
296
  getRows(rows){
307
297
  var output = [];
308
298
 
@@ -100,12 +100,13 @@ class FrozenRows extends Module{
100
100
  this.topElement.appendChild(row.getElement());
101
101
  row.initialize();
102
102
  row.normalizeHeight();
103
- this.table.rowManager.adjustTableSize();
104
-
103
+
105
104
  this.rows.push(row);
106
105
 
107
106
  this.refreshData(false, "display");
108
107
 
108
+ this.table.rowManager.adjustTableSize();
109
+
109
110
  this.styleRows();
110
111
 
111
112
  }else{
@@ -379,9 +379,7 @@ class Group{
379
379
  });
380
380
  }
381
381
 
382
- this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
383
-
384
- this.groupManager.checkBasicModeGroupHeaderWidth();
382
+ this.groupManager.updateGroupRows(true);
385
383
 
386
384
  }else{
387
385
  this.groupManager.updateGroupRows(true);
@@ -419,10 +417,8 @@ class Group{
419
417
  prev = rowEl;
420
418
  });
421
419
  }
422
-
423
- this.groupManager.table.rowManager.setDisplayRows(this.groupManager.updateGroupRows(), this.groupManager.getDisplayIndex());
424
-
425
- this.groupManager.checkBasicModeGroupHeaderWidth();
420
+
421
+ this.groupManager.updateGroupRows(true);
426
422
  }else{
427
423
  this.groupManager.updateGroupRows(true);
428
424
  }
@@ -40,7 +40,7 @@ class GroupComponent {
40
40
  }
41
41
 
42
42
  isVisible(){
43
- return this._group.visible;
43
+ return this._group._visible;
44
44
  }
45
45
 
46
46
  show(){