tabulator-tables 5.0.5 → 5.0.9

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 (85) hide show
  1. package/bower.json +1 -1
  2. package/build/rollup.js +1 -1
  3. package/dist/css/tabulator.css +4 -0
  4. package/dist/css/tabulator.css.map +1 -1
  5. package/dist/css/tabulator.min.css +1 -1
  6. package/dist/css/tabulator.min.css.map +1 -1
  7. package/dist/css/tabulator_bootstrap3.css +4 -0
  8. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  9. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  10. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  11. package/dist/css/tabulator_bootstrap4.css +4 -0
  12. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  13. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  14. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  15. package/dist/css/tabulator_bulma.css +4 -0
  16. package/dist/css/tabulator_bulma.css.map +1 -1
  17. package/dist/css/tabulator_bulma.min.css +1 -1
  18. package/dist/css/tabulator_bulma.min.css.map +1 -1
  19. package/dist/css/tabulator_materialize.css +4 -0
  20. package/dist/css/tabulator_materialize.css.map +1 -1
  21. package/dist/css/tabulator_materialize.min.css +1 -1
  22. package/dist/css/tabulator_materialize.min.css.map +1 -1
  23. package/dist/css/tabulator_midnight.css +4 -0
  24. package/dist/css/tabulator_midnight.css.map +1 -1
  25. package/dist/css/tabulator_midnight.min.css +1 -1
  26. package/dist/css/tabulator_midnight.min.css.map +1 -1
  27. package/dist/css/tabulator_modern.css +4 -0
  28. package/dist/css/tabulator_modern.css.map +1 -1
  29. package/dist/css/tabulator_modern.min.css +1 -1
  30. package/dist/css/tabulator_modern.min.css.map +1 -1
  31. package/dist/css/tabulator_semanticui.css +4 -0
  32. package/dist/css/tabulator_semanticui.css.map +1 -1
  33. package/dist/css/tabulator_semanticui.min.css +1 -1
  34. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  35. package/dist/css/tabulator_simple.css +4 -0
  36. package/dist/css/tabulator_simple.css.map +1 -1
  37. package/dist/css/tabulator_simple.min.css +1 -1
  38. package/dist/css/tabulator_simple.min.css.map +1 -1
  39. package/dist/css/tabulator_site.css +4 -0
  40. package/dist/css/tabulator_site.css.map +1 -1
  41. package/dist/css/tabulator_site.min.css +1 -1
  42. package/dist/css/tabulator_site.min.css.map +1 -1
  43. package/dist/js/tabulator.js +412 -256
  44. package/dist/js/tabulator.js.map +1 -1
  45. package/dist/js/tabulator.min.js +2 -2
  46. package/dist/js/tabulator.min.js.map +1 -1
  47. package/dist/js/tabulator_esm.js +501 -351
  48. package/dist/js/tabulator_esm.js.map +1 -1
  49. package/dist/js/tabulator_esm.min.js +2 -2
  50. package/dist/js/tabulator_esm.min.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/js/core/ColumnManager.js +8 -7
  53. package/src/js/core/CoreFeature.js +1 -5
  54. package/src/js/core/RowManager.js +8 -2
  55. package/src/js/core/Tabulator.js +126 -100
  56. package/src/js/core/column/Column.js +1 -1
  57. package/src/js/core/defaults/options.js +1 -1
  58. package/src/js/core/rendering/Renderer.js +2 -1
  59. package/src/js/core/rendering/renderers/VirtualDomVertical.js +1 -1
  60. package/src/js/core/tools/{ComponentFuctionBinder.js → ComponentFunctionBinder.js} +1 -1
  61. package/src/js/core/tools/DataLoader.js +1 -1
  62. package/src/js/core/tools/InteractionMonitor.js +126 -49
  63. package/src/js/core/tools/OptionsList.js +2 -2
  64. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +14 -1
  65. package/src/js/modules/DataTree/DataTree.js +18 -9
  66. package/src/js/modules/Download/defaults/downloaders/pdf.js +0 -2
  67. package/src/js/modules/Download/defaults/downloaders/xlsx.js +3 -2
  68. package/src/js/modules/Edit/Edit.js +1 -8
  69. package/src/js/modules/Edit/defaults/editors/progress.js +2 -2
  70. package/src/js/modules/Export/Export.js +1 -1
  71. package/src/js/modules/Filter/Filter.js +9 -4
  72. package/src/js/modules/Format/defaults/formatters/datetime.js +2 -2
  73. package/src/js/modules/Format/defaults/formatters/datetimediff.js +1 -1
  74. package/src/js/modules/Format/defaults/formatters/money.js +8 -1
  75. package/src/js/modules/FrozenRows/FrozenRows.js +4 -1
  76. package/src/js/modules/GroupRows/Group.js +16 -6
  77. package/src/js/modules/GroupRows/GroupRows.js +41 -29
  78. package/src/js/modules/History/History.js +3 -1
  79. package/src/js/modules/HtmlTableImport/HtmlTableImport.js +5 -7
  80. package/src/js/modules/MoveColumns/MoveColumns.js +64 -61
  81. package/src/js/modules/Page/Page.js +8 -10
  82. package/src/js/modules/SelectRow/SelectRow.js +5 -10
  83. package/src/js/modules/Sort/Sort.js +1 -1
  84. package/src/js/modules/Sort/defaults/sorters/datetime.js +3 -2
  85. package/src/scss/tabulator.scss +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabulator-tables",
3
- "version": "5.0.5",
3
+ "version": "5.0.9",
4
4
  "description": "Interactive table generation JavaScript library",
5
5
  "style": "dist/css/tabulator.css",
6
6
  "main": "dist/js/tabulator.js",
@@ -7,6 +7,8 @@ import OptionsList from './tools/OptionsList.js';
7
7
  import RendererBasicHorizontal from './rendering/renderers/BasicHorizontal.js';
8
8
  import RendererVirtualDomHorizontal from './rendering/renderers/VirtualDomHorizontal.js';
9
9
 
10
+ import defaultColumnOptions from './column/defaults/options.js';
11
+
10
12
  export default class ColumnManager extends CoreFeature {
11
13
 
12
14
  constructor (table){
@@ -19,7 +21,7 @@ export default class ColumnManager extends CoreFeature {
19
21
  this.columnsByIndex = []; //columns by index
20
22
  this.columnsByField = {}; //columns by field
21
23
  this.scrollLeft = 0;
22
- this.optionsList = new OptionsList(this.table, "column definition");
24
+ this.optionsList = new OptionsList(this.table, "column definition", defaultColumnOptions);
23
25
 
24
26
  this.renderer = null;
25
27
  }
@@ -232,8 +234,9 @@ export default class ColumnManager extends CoreFeature {
232
234
  index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;
233
235
 
234
236
  if(nextToColumn && index > -1){
235
- var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn());
236
- var nextEl = nextToColumn.getElement();
237
+ var topColumn = nextToColumn.getTopColumn()
238
+ var parentIndex = this.columns.indexOf(topColumn);
239
+ var nextEl = topColumn.getElement();
237
240
 
238
241
  if(before){
239
242
  this.columns.splice(parentIndex, 0, column);
@@ -347,7 +350,7 @@ export default class ColumnManager extends CoreFeature {
347
350
  return this.columnsByIndex[index];
348
351
  }
349
352
 
350
- getFirstVisibileColumn(index){
353
+ getFirstVisibleColumn(index){
351
354
  var index = this.columnsByIndex.findIndex((col) => {
352
355
  return col.visible;
353
356
  });
@@ -608,13 +611,11 @@ export default class ColumnManager extends CoreFeature {
608
611
 
609
612
  this.dispatch("column-add", definition, before, nextToColumn);
610
613
 
611
- this.redraw(true);
612
-
613
614
  if(this.layoutMode() != "fitColumns"){
614
615
  column.reinitializeWidth();
615
616
  }
616
617
 
617
- this.verticalAlignHeaders();
618
+ this.redraw(true);
618
619
 
619
620
  this.table.rowManager.reinitialize();
620
621
 
@@ -102,11 +102,7 @@ export default class CoreFeature{
102
102
  //////////////// Options /////////////////
103
103
  //////////////////////////////////////////
104
104
 
105
- options(key, value){
106
- if(typeof value !== "undefined"){
107
- this.table.options[key] = value;
108
- }
109
-
105
+ options(key){
110
106
  return this.table.options[key];
111
107
  }
112
108
 
@@ -772,8 +772,14 @@ export default class RowManager extends CoreFeature{
772
772
  }
773
773
  }
774
774
 
775
- getVisibleRows(viewable){
776
- return this.renderer.visibleRows(!viewable);
775
+ getVisibleRows(chain, viewable){
776
+ var rows = Object.assign([], this.renderer.visibleRows(!viewable));
777
+
778
+ if(chain){
779
+ rows = this.chain("rows-visible", [viewable], rows, rows);
780
+ }
781
+
782
+ return rows;
777
783
  }
778
784
 
779
785
  //repeat action accross display rows
@@ -7,7 +7,7 @@ import RowManager from './RowManager.js';
7
7
  import FooterManager from './FooterManager.js';
8
8
 
9
9
  import InteractionMonitor from './tools/InteractionMonitor.js';
10
- import ComponentFuctionBinder from './tools/ComponentFuctionBinder.js';
10
+ import ComponentFunctionBinder from './tools/ComponentFunctionBinder.js';
11
11
  import DataLoader from './tools/DataLoader.js';
12
12
 
13
13
  import ExternalEventBus from './tools/ExternalEventBus.js';
@@ -33,11 +33,11 @@ class Tabulator {
33
33
  this.interactionMonitor = false; //track user interaction
34
34
  this.browser = ""; //hold current browser type
35
35
  this.browserSlow = false; //handle reduced functionality for slower browsers
36
- this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence
36
+ this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance
37
37
  this.rtl = false; //check if the table is in RTL mode
38
38
  this.originalElement = null; //hold original table element if it has been replaced
39
39
 
40
- this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions
40
+ this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions
41
41
  this.dataLoader = false; //bind component functions
42
42
 
43
43
  this.modules = {}; //hold all modules bound to this table
@@ -52,13 +52,13 @@ class Tabulator {
52
52
 
53
53
  this.initialzeCoreSystems(options);
54
54
 
55
- //delay table creation to allow event bindings immediatly after the constructor
55
+ //delay table creation to allow event bindings immediately after the constructor
56
56
  setTimeout(() => {
57
57
  this._create();
58
58
  })
59
59
  }
60
60
 
61
- TableRegistry.register(this); //register table for inderdevice communication
61
+ TableRegistry.register(this); //register table for inter-device communication
62
62
  }
63
63
 
64
64
  initializeElement(element){
@@ -92,7 +92,7 @@ class Tabulator {
92
92
 
93
93
  this._clearObjectPointers();
94
94
 
95
- this._mapDepricatedFunctionality();
95
+ this._mapDeprecatedFunctionality();
96
96
 
97
97
  this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);
98
98
  this.eventBus = new InternalEventBus(this.options.debugEventsInternal);
@@ -105,8 +105,8 @@ class Tabulator {
105
105
  this.footerManager.initialize();
106
106
  }
107
107
 
108
- //convert depricated functionality to new functions
109
- _mapDepricatedFunctionality(){
108
+ //convert deprecated functionality to new functions
109
+ _mapDeprecatedFunctionality(){
110
110
  //all previously deprecated functionality removed in the 5.0 release
111
111
  }
112
112
 
@@ -127,7 +127,7 @@ class Tabulator {
127
127
  this.element.classList.remove("tabulator-block-select");
128
128
  }
129
129
 
130
- //concreate table
130
+ //create table
131
131
  _create(){
132
132
  this.externalEvents.dispatch("tableBuilding");
133
133
  this.eventBus.dispatch("table-building");
@@ -232,6 +232,8 @@ class Tabulator {
232
232
  var element = this.element,
233
233
  options = this.options;
234
234
 
235
+ this.interactionMonitor.initialize();
236
+
235
237
  this.columnManager.initialize();
236
238
  this.rowManager.initialize();
237
239
 
@@ -290,7 +292,7 @@ class Tabulator {
290
292
  destroy(){
291
293
  var element = this.element;
292
294
 
293
- TableRegistry.deregister(this); //deregister table from inderdevice communication
295
+ TableRegistry.deregister(this); //deregister table from inter-device communication
294
296
 
295
297
  this.eventBus.dispatch("table-destroy");
296
298
 
@@ -409,68 +411,80 @@ class Tabulator {
409
411
 
410
412
  //replace data, keeping table in position with same sort
411
413
  replaceData(data, params, config){
412
- return this.dataLoader.load(data, params, config, true, true);
414
+ if(this.initialized){
415
+ return this.dataLoader.load(data, params, config, true, true);
416
+ }else{
417
+ console.warn("replaceData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
418
+ }
413
419
  }
414
420
 
415
421
  //update table data
416
422
  updateData(data){
417
423
  var responses = 0;
418
424
 
419
- return new Promise((resolve, reject) => {
420
- this.dataLoader.blockActiveLoad();
425
+ if(this.initialized){
426
+ return new Promise((resolve, reject) => {
427
+ this.dataLoader.blockActiveLoad();
421
428
 
422
- if(typeof data === "string"){
423
- data = JSON.parse(data);
424
- }
429
+ if(typeof data === "string"){
430
+ data = JSON.parse(data);
431
+ }
425
432
 
426
- if(data){
427
- data.forEach((item) => {
428
- var row = this.rowManager.findRow(item[this.options.index]);
433
+ if(data){
434
+ data.forEach((item) => {
435
+ var row = this.rowManager.findRow(item[this.options.index]);
429
436
 
430
- if(row){
431
- responses++;
437
+ if(row){
438
+ responses++;
432
439
 
433
- row.updateData(item)
434
- .then(()=>{
435
- responses--;
440
+ row.updateData(item)
441
+ .then(()=>{
442
+ responses--;
436
443
 
437
- if(!responses){
438
- resolve();
439
- }
440
- });
441
- }
442
- });
443
- }else{
444
- console.warn("Update Error - No data provided");
445
- reject("Update Error - No data provided");
446
- }
447
- });
444
+ if(!responses){
445
+ resolve();
446
+ }
447
+ });
448
+ }
449
+ });
450
+ }else{
451
+ console.warn("Update Error - No data provided");
452
+ reject("Update Error - No data provided");
453
+ }
454
+ });
455
+ }else{
456
+ console.warn("updateData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
457
+ }
448
458
  }
449
459
 
450
460
  addData(data, pos, index){
451
- return new Promise((resolve, reject) => {
452
- this.dataLoader.blockActiveLoad();
461
+ if(this.initialized){
462
+ return new Promise((resolve, reject) => {
463
+ this.dataLoader.blockActiveLoad();
453
464
 
454
- if(typeof data === "string"){
455
- data = JSON.parse(data);
456
- }
465
+ if(typeof data === "string"){
466
+ data = JSON.parse(data);
467
+ }
457
468
 
458
- if(data){
459
- this.rowManager.addRows(data, pos, index)
460
- .then((rows) => {
461
- var output = [];
469
+ if(data){
470
+ this.rowManager.addRows(data, pos, index)
471
+ .then((rows) => {
472
+ var output = [];
462
473
 
463
- rows.forEach(function(row){
464
- output.push(row.getComponent());
465
- });
474
+ rows.forEach(function(row){
475
+ output.push(row.getComponent());
476
+ });
466
477
 
467
- resolve(output);
468
- });
469
- }else{
470
- console.warn("Update Error - No data provided");
471
- reject("Update Error - No data provided");
472
- }
473
- });
478
+ resolve(output);
479
+ });
480
+ }else{
481
+ console.warn("Update Error - No data provided");
482
+ reject("Update Error - No data provided");
483
+ }
484
+ });
485
+ }else{
486
+ console.warn("addData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
487
+ }
474
488
  }
475
489
 
476
490
  //update table data
@@ -478,46 +492,50 @@ class Tabulator {
478
492
  var rows = [],
479
493
  responses = 0;
480
494
 
481
- return new Promise((resolve, reject) => {
482
- this.dataLoader.blockActiveLoad();
483
-
484
- if(typeof data === "string"){
485
- data = JSON.parse(data);
486
- }
495
+ if(this.initialized){
496
+ return new Promise((resolve, reject) => {
497
+ this.dataLoader.blockActiveLoad();
487
498
 
488
- if(data){
489
- data.forEach((item) => {
490
- var row = this.rowManager.findRow(item[this.options.index]);
499
+ if(typeof data === "string"){
500
+ data = JSON.parse(data);
501
+ }
491
502
 
492
- responses++;
503
+ if(data){
504
+ data.forEach((item) => {
505
+ var row = this.rowManager.findRow(item[this.options.index]);
493
506
 
494
- if(row){
495
- row.updateData(item)
496
- .then(()=>{
497
- responses--;
498
- rows.push(row.getComponent());
507
+ responses++;
499
508
 
500
- if(!responses){
501
- resolve(rows);
502
- }
503
- });
504
- }else{
505
- this.rowManager.addRows(item)
506
- .then((newRows)=>{
507
- responses--;
508
- rows.push(newRows[0].getComponent());
509
-
510
- if(!responses){
511
- resolve(rows);
512
- }
513
- });
514
- }
515
- });
516
- }else{
517
- console.warn("Update Error - No data provided");
518
- reject("Update Error - No data provided");
519
- }
520
- });
509
+ if(row){
510
+ row.updateData(item)
511
+ .then(()=>{
512
+ responses--;
513
+ rows.push(row.getComponent());
514
+
515
+ if(!responses){
516
+ resolve(rows);
517
+ }
518
+ });
519
+ }else{
520
+ this.rowManager.addRows(item)
521
+ .then((newRows)=>{
522
+ responses--;
523
+ rows.push(newRows[0].getComponent());
524
+
525
+ if(!responses){
526
+ resolve(rows);
527
+ }
528
+ });
529
+ }
530
+ });
531
+ }else{
532
+ console.warn("Update Error - No data provided");
533
+ reject("Update Error - No data provided");
534
+ }
535
+ });
536
+ }else{
537
+ console.warn("updateOrAddData failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
538
+ }
521
539
  }
522
540
 
523
541
  //get row object
@@ -582,14 +600,18 @@ class Tabulator {
582
600
 
583
601
  //add row to table
584
602
  addRow(data, pos, index){
585
- if(typeof data === "string"){
586
- data = JSON.parse(data);
587
- }
603
+ if(this.initialized){
604
+ if(typeof data === "string"){
605
+ data = JSON.parse(data);
606
+ }
588
607
 
589
- return this.rowManager.addRows(data, pos, index)
590
- .then((rows)=>{
591
- return rows[0].getComponent();
592
- });
608
+ return this.rowManager.addRows(data, pos, index)
609
+ .then((rows)=>{
610
+ return rows[0].getComponent();
611
+ });
612
+ }else{
613
+ console.warn("addRow failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
614
+ }
593
615
  }
594
616
 
595
617
  //update a row if it exitsts otherwise create it
@@ -624,7 +646,7 @@ class Tabulator {
624
646
  if(row){
625
647
  return row.updateData(data)
626
648
  .then(()=>{
627
- resolve(row.getComponent());
649
+ return Promise.resolve(row.getComponent());
628
650
  })
629
651
  }else{
630
652
  console.warn("Update Error - No matching row found:", index);
@@ -798,8 +820,12 @@ class Tabulator {
798
820
  //////////// General Public Functions ////////////
799
821
  //redraw list without updating data
800
822
  redraw(force){
801
- this.columnManager.redraw(force);
802
- this.rowManager.redraw(force);
823
+ if(this.initialized){
824
+ this.columnManager.redraw(force);
825
+ this.rowManager.redraw(force);
826
+ }else{
827
+ console.warn("redraw failed - table not yet initialized. Please wait for the `tableBuilt` event before calling this function.");
828
+ }
803
829
  }
804
830
 
805
831
  setHeight(height){
@@ -147,7 +147,7 @@ class Column extends CoreFeature{
147
147
  var def = this.definition;
148
148
 
149
149
  //set header tooltips
150
- var tooltip = typeof def.headerTooltip === "undefined" ? def.tooltip : def.headerTooltip;
150
+ var tooltip = def.headerTooltip;
151
151
 
152
152
  if(tooltip){
153
153
  if(tooltip === true){
@@ -19,7 +19,7 @@ export default {
19
19
  autoColumns:false, //build columns from data row structure
20
20
  autoColumnsDefinitions:false,
21
21
 
22
- nestedFieldSeparator:".", //seperatpr for nested data
22
+ nestedFieldSeparator:".", //separator for nested data
23
23
 
24
24
  tooltipGenerationMode:"load", //when to generate tooltips
25
25
 
@@ -146,8 +146,9 @@ export default class Renderer extends CoreFeature{
146
146
  if(!ifVisible){
147
147
  if(Helpers.elVisible(rowEl)){
148
148
  offset = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top;
149
-
149
+
150
150
  if(offset > 0 && offset < this.elementVertical.clientHeight - rowEl.offsetHeight){
151
+ resolve();
151
152
  return false;
152
153
  }
153
154
  }
@@ -44,7 +44,7 @@ export default class VirtualDomVertical extends Renderer{
44
44
 
45
45
  element.style.paddingTop = "";
46
46
  element.style.paddingBottom = "";
47
- element.style.minWidth = "";
47
+ // element.style.minWidth = "";
48
48
  element.style.minHeight = "";
49
49
  element.style.display = "";
50
50
  element.style.visibility = "";
@@ -1,4 +1,4 @@
1
- export default class ComponentFuctionBinder{
1
+ export default class ComponentFunctionBinder{
2
2
 
3
3
  constructor(table){
4
4
  this.table = table;
@@ -72,7 +72,7 @@ export default class DataLoader extends CoreFeature{
72
72
  }
73
73
 
74
74
  //get params for request
75
- var params = this.chain("data-params", [data, config, silent], params || {}, {});
75
+ params = this.chain("data-params", [data, config, silent], params || {}, params || {});
76
76
 
77
77
  params = this.mapParams(params, this.table.options.dataSendParams);
78
78